Differences From Artifact [0ddeef8a46]:
- File
src/serverutil.mm
— part of check-in
[489124a92f]
at
2025-03-16 10:11:39
on branch trunk
— Use one autorelease pool per frame
This way, nowhere else autorelease pools need to be managed. (user: js, size: 3816) [annotate] [blame] [check-ins using]
To Artifact [3bd542851a]:
- File src/serverutil.mm — part of check-in [c38d75087b] at 2025-03-20 20:11:37 on branch trunk — Convert all references to pointers in protos.h (user: js, size: 3869) [annotate] [blame] [check-ins using]
1 2 3 4 5 6 7 8 | // misc useful functions used by the server #include "cube.h" // all network traffic is in 32bit ints, which are then compressed using the // following simple scheme (assumes that most values are small). void | | | | | | | | | | | | | | | | | | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | // misc useful functions used by the server #include "cube.h" // all network traffic is in 32bit ints, which are then compressed using the // following simple scheme (assumes that most values are small). void putint(uchar **p, int n) { if (n < 128 && n > -127) { *(*p)++ = n; } else if (n < 0x8000 && n >= -0x8000) { *(*p)++ = 0x80; *(*p)++ = n; *(*p)++ = n >> 8; } else { *(*p)++ = 0x81; *(*p)++ = n; *(*p)++ = n >> 8; *(*p)++ = n >> 16; *(*p)++ = n >> 24; } } int getint(uchar **p) { int c = *((char *)*p); (*p)++; if (c == -128) { int n = *(*p)++; n |= *((char *)*p) << 8; (*p)++; return n; } else if (c == -127) { int n = *(*p)++; n |= *(*p)++ << 8; n |= *(*p)++ << 16; return n | (*(*p)++ << 24); } else return c; } void sendstring(OFString *t_, uchar **p) { const char *t = t_.UTF8String; for (size_t i = 0; i < _MAXDEFSTR && *t != '\0'; i++) putint(p, *t++); putint(p, 0); |
︙ | ︙ | |||
118 119 120 121 122 123 124 | { if (!copydata) return NULL; ENetPacket *packet = enet_packet_create( NULL, MAXTRANS + copysize, ENET_PACKET_FLAG_RELIABLE); uchar *start = packet->data; uchar *p = start + 2; | | | | | 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | { if (!copydata) return NULL; ENetPacket *packet = enet_packet_create( NULL, MAXTRANS + copysize, ENET_PACKET_FLAG_RELIABLE); uchar *start = packet->data; uchar *p = start + 2; putint(&p, SV_RECVMAP); sendstring(copyname, &p); putint(&p, copysize); memcpy(p, copydata, copysize); p += copysize; *(ushort *)start = ENET_HOST_TO_NET_16(p - start); enet_packet_resize(packet, p - start); return packet; } |
︙ | ︙ |