Code: Show/Hide clientMessage *generateObjectToggle (Uint16 player, objectInfo *objects, Uint16 num_objects)
{ clientMessage *ret = new clientMessage(4 + 2 * num_objects); if (ret == NULL) return NULL; char *msg = ret->msg; /* Field Length Description 0 1 Type byte: 0x0a 1 2 Player ident (-1 = all players) 3 1 LVZ type byte: 0x35 The following are repeated until the end of the message 4 2 LVZ bitfield */ msg[0] = 0x0a; *(Uint16*)&msg[1] = player; msg[3] = 0x35; memcpy(msg + 4, objects, 2 * num_objects); return ret; } |
Quote: |
5 2* lvz objID bitwise AND with 0x7FFF to turn on, 0x8000 to turn off |
Code: Show/Hide union objectInfo
{ struct { Uint16 id : 15; // Object ident Uint16 disabled : 1; // 1=off, 0=on }; Uint16 n; }; |
Code: Show/Hide sendPublic("*arena size: " + (String) sizeof(Uint16) + " " + (String) sizeof(objectInfo) );
|
Code: Show/Hide #include "stdafx.h" typedef unsigned short Uint16; union objectInfo { struct { Uint16 id : 15; // Object ident Uint16 disabled : 1; // 1=off, 0=on }; Uint16 n; }; int main(int argc, char* argv[]) { printf("%i %i\n", sizeof(Uint16), sizeof(objectInfo)); getchar(); return 0; } |
Code: Show/Hide union objectInfo
{ struct { unsigned id : 15; // Object ident unsigned disabled : 1; // 1=off, 0=on }; Uint16 n; }; |
Samapico wrote: |
In mervbot's spawn.h:
// Increase this beyond 1 when Continuum supports LVZ object toggling with more than 1 object at a time. #define MAX_OBJECTS 1 |
Samapico wrote: |
In spawn.h, there is a different definition of objectInfo |