54 data[ 2] = (BYTE) ((objid & 0xff00) >> 8);
55 data[ 3] = (BYTE) ((objid & 0x00ff) );
62 data[ 4] = (BYTE) ((x & 0x00ff0000) >> 16);
63 data[ 5] = (BYTE) ((x & 0x0000ff00) >> 8);
64 data[ 6] = (BYTE) ((x & 0x000000ff) );
66 data[ 7] = (BYTE) ((y & 0x00ff0000) >> 16);
67 data[ 8] = (BYTE) ((y & 0x0000ff00) >> 8);
68 data[ 9] = (BYTE) ((y & 0x000000ff) );
70 data[10] = (BYTE) ((z & 0x00ff0000) >> 16);
71 data[11] = (BYTE) ((z & 0x0000ff00) >> 8);
72 data[12] = (BYTE) ((z & 0x000000ff) );
79 data[13] = (BYTE) ((vx & 0xff00) >> 8);
80 data[14] = (BYTE) ((vx & 0x00ff));
82 data[15] = (BYTE) ((vy & 0xff00) >> 8);
83 data[16] = (BYTE) ((vy & 0x00ff));
85 data[17] = (BYTE) ((vz & 0xff00) >> 8);
86 data[18] = (BYTE) ((vz & 0x00ff));
89 if (_finite(euler.
x)) {
90 while (euler.
x < 0) euler.
x += 2*
PI;
91 while (euler.
x > 2*
PI) euler.
x -= 2*
PI;
97 if (_finite(euler.
y)) {
98 while (euler.
y < 0) euler.
y += 2*
PI;
99 while (euler.
y > 2*
PI) euler.
y -= 2*
PI;
105 if (_finite(euler.
z)) {
106 while (euler.
z < 0) euler.
z += 2*
PI;
107 while (euler.
z > 2*
PI) euler.
z -= 2*
PI;
113 WORD ox = (WORD) (((
int) (euler.
x /
EULER_SCALE)) & 0x000003ff);
114 WORD oy = (WORD) (((
int) (euler.
y /
EULER_SCALE)) & 0x000003ff);
115 WORD oz = (WORD) (((
int) (euler.
z /
EULER_SCALE)) & 0x000003ff);
117 DWORD o = (ox << 20) | (oy << 10) | (oz);
119 data[19] = (BYTE) ((o & 0xff000000) >> 24);
120 data[20] = (BYTE) ((o & 0x00ff0000) >> 16);
121 data[21] = (BYTE) ((o & 0x0000ff00) >> 8);
122 data[22] = (BYTE) ((o & 0x000000ff) );
125 data[23] = throttle << 7 |
128 (shield >> 2) & 0x1f;
136 if (p && p[0] ==
TYPE && p[1] ==
SIZE) {
137 CopyMemory(data, p,
SIZE);
139 objid = (data[ 2] << 8) |
142 int x = (data[ 4] << 16) |
146 int y = (data[ 7] << 16) |
150 int z = (data[10] << 16) |
154 int vx = (data[13] << 8) |
157 int vy = (data[15] << 8) |
160 int vz = (data[17] << 8) |
163 DWORD o = (data[19] << 24) |
168 WORD ox = (WORD) ((o >> 20) & 0x03ff);
169 WORD oy = (WORD) ((o >> 10) & 0x03ff);
170 WORD oz = (WORD) ((o ) & 0x03ff);
172 throttle = data[23] & 0x80 ?
true :
false;
173 augmenter = data[23] & 0x40 ?
true :
false;
174 gear = data[23] & 0x20 ?
true :
false;
175 shield = (data[23] & 0x1f) << 2;
191 ZeroMemory(data,
SIZE);
196 for (
int i = 0; i < name.
length() && i < 16; i++)
199 for (
int i = 0; i < pass.
length() && i < 16; i++)
200 data[18+i] = pass[i];
202 for (
int i = 0; i < elem.
length() && i < 31; i++)
203 data[34+i] = elem[i];
205 data[65] = (BYTE) index;
207 for (
int i = 0; i < serno.
length() && i < 60; i++)
208 data[66+i] = serno[i];
216 if (p && p[0] ==
TYPE && p[1] ==
SIZE) {
217 CopyMemory(data, p,
SIZE);
221 CopyMemory(buf, data+2, 16);
225 CopyMemory(buf, data+18, 16);
229 CopyMemory(buf, data+34, 31);
235 CopyMemory(buf, data+66, 60);
247 : index(0), integrity(0), respawns(0), decoys(0), probes(0), fuel(0),
250 ZeroMemory(ammo,
sizeof(ammo));
257 CopyMemory(ammo, a,
sizeof(ammo));
297 ZeroMemory(data,
SIZE);
301 data[ 2] = (BYTE) ((objid & 0xff00) >> 8);
302 data[ 3] = (BYTE) ((objid & 0x00ff) );
304 float* f = (
float*) (data + 4);
305 *f++ = (float) loc.
x;
306 *f++ = (
float) loc.
y;
307 *f++ = (float) loc.
z;
308 *f++ = (
float) integrity;
310 for (
int i = 0; i < name.
length() && i < 16; i++)
311 data[20+i] = name[i];
313 for (
int i = 0; i < elem.
length() && i < 32; i++)
314 data[36+i] = elem[i];
316 for (
int i = 0; i < region.
length() && i < 32; i++)
317 data[68+i] = region[i];
319 int* p = (
int*) (data + 100);
324 data[112]= (BYTE) fuel;
325 data[113]= (BYTE) shield;
327 BYTE* a = data + 116;
328 for (
int i = 0; i < 16; i++) {
337 data[180] = (BYTE) index;
339 f = (
float*) (data + 184);
340 *f++ = (float) velocity.
x;
341 *f++ = (
float) velocity.
y;
342 *f++ = (float) velocity.
z;
350 if (p && p[0] ==
TYPE && p[1] ==
SIZE) {
351 CopyMemory(data, p,
SIZE);
353 objid = (data[2] << 8) | data[3];
355 float* f = (
float*) (data + 4);
362 CopyMemory(buf, data+20, 16);
366 CopyMemory(buf, data+36, 32);
370 CopyMemory(buf, data+68, 32);
374 int* p = (
int*) (data + 100);
382 CopyMemory(ammo, data+116, 16);
386 f = (
float*) (data + 184);
402 ZeroMemory(data,
SIZE);
407 data[2] = (BYTE) ((objid & 0xff00) >> 8);
408 data[3] = (BYTE) ((objid & 0x00ff) );
409 data[4] = (BYTE) (disconnected);
417 if (p && p[0] ==
TYPE && p[1] ==
SIZE) {
418 CopyMemory(data, p,
SIZE);
420 objid = (data[2] << 8) | data[3];
421 disconnected = data[4] ?
true :
false;
434 ZeroMemory(data,
SIZE);
445 if (p && p[0] ==
TYPE && p[1] ==
SIZE) {
446 CopyMemory(data, p,
SIZE);
458 ZeroMemory(data,
SIZE);
463 data[2] = (BYTE) ((objid & 0xff00) >> 8);
464 data[3] = (BYTE) ((objid & 0x00ff) );
465 data[4] = (BYTE) ((shotid & 0xff00) >> 8);
466 data[5] = (BYTE) ((shotid & 0x00ff) );
468 float* p = (
float*) (data + 6);
477 if (p && p[0] ==
TYPE && p[1] ==
SIZE) {
478 CopyMemory(data, p,
SIZE);
480 objid = (data[2] << 8) | data[3];
481 shotid = (data[4] << 8) | data[5];
482 damage = *(
float*) (data + 6);
495 ZeroMemory(data,
SIZE);
500 data[2] = (BYTE) ((objid & 0xff00) >> 8);
501 data[3] = (BYTE) ((objid & 0x00ff) );
503 float* p = (
float*) (data + 4);
506 data[8] = (BYTE) (sysix+1);
515 if (p && p[0] ==
TYPE && p[1] ==
SIZE) {
516 CopyMemory(data, p,
SIZE);
518 objid = (data[2] << 8) | data[3];
519 damage = *(
float*) (data + 4);
535 ZeroMemory(data,
SIZE);
540 data[2] = (BYTE) ((objid & 0xff00) >> 8);
541 data[3] = (BYTE) ((objid & 0x00ff) );
542 data[4] = (BYTE) (sysix+1);
543 data[5] = (BYTE) (status);
544 data[6] = (BYTE) (power);
545 data[7] = (BYTE) (reactor);
547 float* f = (
float*) (data + 8);
556 if (p && p[0] ==
TYPE && p[1] ==
SIZE) {
557 CopyMemory(data, p,
SIZE);
559 objid = (data[2] << 8) | data[3];
565 float* f = (
float*) (data + 8);
580 ZeroMemory(data,
SIZE);
585 data[2] = (BYTE) ((objid & 0xff00) >> 8);
586 data[3] = (BYTE) ((objid & 0x00ff) );
587 data[4] = (BYTE) ((kill_id & 0xff00) >> 8);
588 data[5] = (BYTE) ((kill_id & 0x00ff) );
589 data[6] = (BYTE) killtype;
590 data[7] = (BYTE) respawn;
592 float* f = (
float*) (data + 8);
593 *f++ = (float) loc.
x;
594 *f++ = (
float) loc.
y;
595 *f++ = (float) loc.
z;
597 data[20] = (BYTE) deck;
605 if (p && p[0] ==
TYPE && p[1] ==
SIZE) {
606 CopyMemory(data, p,
SIZE);
608 objid = (data[2] << 8) | data[3];
609 kill_id = (data[4] << 8) | data[5];
611 respawn = data[7] ?
true :
false;
613 float* f = (
float*) (data + 8);
631 ZeroMemory(data,
SIZE);
636 data[2] = (BYTE) ((objid & 0xff00) >> 8);
637 data[3] = (BYTE) ((objid & 0x00ff) );
638 data[4] = (BYTE) ((fc_src & 0xff00) >> 8);
639 data[5] = (BYTE) ((fc_src & 0x00ff) );
640 data[6] = (BYTE) ((fc_dst & 0xff00) >> 8);
641 data[7] = (BYTE) ((fc_dst & 0x00ff) );
642 data[8] = (BYTE) transtype;
644 float* f = (
float*) (data + 12);
645 *f++ = (float) location.
x;
646 *f++ = (
float) location.
y;
647 *f++ = (float) location.
z;
649 char* p = (
char*) (data + 24);
650 strncpy(p, region.
data(), 31);
658 if (p && p[0] ==
TYPE && p[1] ==
SIZE) {
659 CopyMemory(data, p,
SIZE);
661 objid = (data[2] << 8) | data[3];
662 fc_src = (data[4] << 8) | data[5];
663 fc_dst = (data[6] << 8) | data[7];
666 float* f = (
float*) (data + 12);
671 region = (
char*) (data + 24);
684 ZeroMemory(data,
SIZE);
689 data[2] = (BYTE) ((objid & 0xff00) >> 8);
690 data[3] = (BYTE) ((objid & 0x00ff) );
691 data[4] = (BYTE) ((tgtid & 0xff00) >> 8);
692 data[5] = (BYTE) ((tgtid & 0x00ff) );
693 data[6] = (BYTE) (sysix+1);
701 if (p && p[0] ==
TYPE && p[1] ==
SIZE) {
702 CopyMemory(data, p,
SIZE);
704 objid = (data[2] << 8) | data[3];
705 tgtid = (data[4] << 8) | data[5];
720 ZeroMemory(data,
SIZE);
725 data[2] = (BYTE) ((objid & 0xff00) >> 8);
726 data[3] = (BYTE) ((objid & 0x00ff) );
727 data[4] = (BYTE) (emcon);
735 if (p && p[0] ==
TYPE && p[1] ==
SIZE) {
736 CopyMemory(data, p,
SIZE);
738 objid = (data[2] << 8) | data[3];
752 ZeroMemory(data,
SIZE);
757 data[2] = (BYTE) ((objid & 0xff00) >> 8);
758 data[3] = (BYTE) ((objid & 0x00ff) );
759 data[4] = (BYTE) ((tgtid & 0xff00) >> 8);
760 data[5] = (BYTE) ((tgtid & 0x00ff) );
761 data[6] = (BYTE) (sysix+1);
762 data[7] = (BYTE) index;
763 data[8] = (BYTE) count;
764 data[9] = ((BYTE) decoy << 1) |
773 if (p && p[0] ==
TYPE && p[1] ==
SIZE) {
774 CopyMemory(data, p,
SIZE);
776 objid = (data[2] << 8) | data[3];
777 tgtid = (data[4] << 8) | data[5];
781 decoy = (data[9] & 0x02) ?
true :
false;
782 probe = (data[9] & 0x01) ?
true :
false;
796 ZeroMemory(data,
SIZE);
801 data[2] = (BYTE) ((objid & 0xff00) >> 8);
802 data[3] = (BYTE) ((objid & 0x00ff) );
803 data[4] = (BYTE) ((tgtid & 0xff00) >> 8);
804 data[5] = (BYTE) ((tgtid & 0x00ff) );
805 data[6] = (BYTE) ((wepid & 0xff00) >> 8);
806 data[7] = (BYTE) ((wepid & 0x00ff) );
807 data[8] = (BYTE) (sysix+1);
808 data[9] = (BYTE) index;
809 data[10] = ((BYTE) decoy << 1) |
818 if (p && p[0] ==
TYPE && p[1] ==
SIZE) {
819 CopyMemory(data, p,
SIZE);
821 objid = (data[2] << 8) | data[3];
822 tgtid = (data[4] << 8) | data[5];
823 wepid = (data[6] << 8) | data[7];
826 decoy = (data[10] & 0x02) ?
true :
false;
827 probe = (data[10] & 0x01) ?
true :
false;
841 ZeroMemory(data,
SIZE);
845 data[2] = (BYTE) ((objid & 0xff00) >> 8);
846 data[3] = (BYTE) ((objid & 0x00ff) );
854 if (p && p[0] ==
TYPE && p[1] ==
SIZE) {
855 CopyMemory(data, p,
SIZE);
856 objid = (data[2] << 8) | data[3];
867 delete radio_message;
873 radio_message =
new(__FILE__,__LINE__)
RadioMessage(*m);
879 ZeroMemory(data,
SIZE);
888 data[1] = (BYTE) length;
890 if (radio_message->
Sender()) {
892 data[2] = (BYTE) ((objid & 0xff00) >> 8);
893 data[3] = (BYTE) ((objid & 0x00ff) );
898 data[4] = (BYTE) ((dstid & 0xff00) >> 8);
899 data[5] = (BYTE) ((dstid & 0x00ff) );
902 data[6] = (BYTE) radio_message->
Action();
903 data[7] = (BYTE) radio_message->
Channel();
908 data[8] = (BYTE) ((tgtid & 0xff00) >> 8);
909 data[9] = (BYTE) ((tgtid & 0x00ff) );
912 float* f = (
float*) (data + 10);
913 *f++ = (float) radio_message->
Location().
x;
914 *f++ = (float) radio_message->
Location().
y;
915 *f++ = (float) radio_message->
Location().
z;
917 char* p = (
char*) (data + 22);
921 strncpy(p, dst_elem->
Name().
data(), 31);
923 p = (
char*) (data + 55);
924 strncpy(p, radio_message->
Info().
data(), 128);
935 if (p && p[0] ==
TYPE) {
937 ZeroMemory(data,
SIZE);
938 CopyMemory(data, p, length);
948 objid = (data[2] << 8) | data[3];
949 dstid = (data[4] << 8) | data[5];
950 tgtid = (data[8] << 8) | data[9];
954 float* f = (
float*) (data + 10);
959 elem_name = (
char*) (data + 22);
962 info = (
char*) (data + 55);
969 delete radio_message;
971 radio_message =
new(__FILE__,__LINE__)
RadioMessage(elem, src, action);
973 radio_message =
new(__FILE__,__LINE__)
RadioMessage(dst, src, action);
1000 ZeroMemory(data,
SIZE);
1002 int chatlen = text.
length();
1010 data[1] = (BYTE) length;
1011 data[2] = (BYTE) ((dstid & 0xff00) >> 8);
1012 data[3] = (BYTE) ((dstid & 0x00ff) );
1014 char* p = (
char*) (data +
HDR_LEN);
1018 strncpy(p, text.
data(), chatlen);
1026 if (p && p[0] ==
TYPE) {
1028 ZeroMemory(data,
SIZE);
1029 CopyMemory(data, p, length);
1031 dstid = (data[2] << 8) | data[3];
1056 ZeroMemory(data,
SIZE);
1069 if (p && p[0] ==
TYPE) {
1070 ZeroMemory(data,
SIZE);
1071 CopyMemory(data, p,
SIZE);
1073 name = (
const char*) (data + 8);
1084 : iff(0), type(0), intel(0), alert(false), in_flight(false)
1086 for (
int i = 0; i < 16; i++)
1094 CopyMemory(load, l,
sizeof(load));
1097 for (
int i = 0; i < 16; i++)
1106 CopyMemory(slots, s,
sizeof(slots));
1109 for (
int i = 0; i < 4; i++)
1117 ZeroMemory(data,
SIZE);
1122 data[2] = (BYTE) iff;
1123 data[3] = (BYTE) type;
1124 data[4] = (BYTE) intel;
1125 data[5] = (BYTE) obj_code;
1127 for (
int i = 0; i < 16; i++)
1128 data[6+i] = (BYTE) load[i];
1131 strncpy((
char*) (data + 54), commander.
data(),
NAME_LEN-1);
1132 strncpy((
char*) (data + 86), objective.
data(),
NAME_LEN-1);
1133 strncpy((
char*) (data + 118), carrier.
data(),
NAME_LEN-1);
1135 data[150] = (BYTE) squadron;
1136 data[151] = (BYTE) slots[0];
1137 data[152] = (BYTE) slots[1];
1138 data[153] = (BYTE) slots[2];
1139 data[154] = (BYTE) slots[3];
1140 data[155] = (BYTE) alert;
1141 data[156] = (BYTE) in_flight;
1149 if (p && p[0] ==
TYPE) {
1150 ZeroMemory(data,
SIZE);
1151 CopyMemory(data, p,
SIZE);
1158 for (
int i = 0; i < 16; i++) {
1159 load[i] = data[6+i] == 255 ? -1 : data[6+i];
1162 name = (
const char*) (data + 22);
1163 commander = (
const char*) (data + 54);
1164 objective = (
const char*) (data + 86);
1165 carrier = (
const char*) (data + 118);
1167 squadron = data[150];
1169 for (
int i = 0; i < 4; i++) {
1170 slots[i] = data[151+i];
1171 if (slots[i] >= 255)
1175 alert = data[155] ?
true :
false;
1176 in_flight = data[156] ?
true :
false;
1189 ZeroMemory(data,
SIZE);
1194 DWORD* p = (DWORD*) (data + 4);
1195 *p++ = (DWORD) objid;
1196 *p++ = (DWORD) squadron;
1197 *p++ = (DWORD) slot;
1205 if (p && p[0] ==
TYPE) {
1206 ZeroMemory(data,
SIZE);
1207 CopyMemory(data, p,
SIZE);
1209 DWORD* p = (DWORD*) (data + 4);
1211 squadron = (int) *p++;
1223 : objid(0), create(true), index(0), navpoint(0)
1241 navpoint =
new(__FILE__,__LINE__)
Instruction(*n);
1247 ZeroMemory(data,
SIZE);
1252 data[ 2] = (BYTE) ((objid & 0xff00) >> 8);
1253 data[ 3] = (BYTE) ((objid & 0x00ff) );
1254 data[ 4] = (BYTE) create;
1255 data[ 5] = (BYTE) index;
1260 data[ 6] = (BYTE) navpoint->
Action();
1261 data[ 7] = (BYTE) navpoint->
Formation();
1262 data[ 8] = (BYTE) navpoint->
Status();
1263 data[ 9] = (BYTE) navpoint->
EMCON();
1265 data[11] = (BYTE) navpoint->
Farcast();
1269 float* f = (
float*) (data + 12);
1270 *f++ = (float) loc.
x;
1271 *f++ = (
float) loc.
y;
1272 *f++ = (float) loc.
z;
1273 *f++ = (
float) navpoint->
HoldTime();
1274 *f++ = (float) navpoint->
Speed();
1280 data[32] = (BYTE) ((tgtid & 0xff00) >> 8);
1281 data[33] = (BYTE) ((tgtid & 0x00ff) );
1293 if (p && p[0] ==
TYPE) {
1294 ZeroMemory(data,
SIZE);
1295 CopyMemory(data, p,
SIZE);
1308 const char* rgn_name = 0;
1309 const char* tgt_name = 0;
1311 objid = (data[ 2] << 8) |
1314 tgtid = (data[32] << 8) |
1317 create = data[ 4] ?
true :
false;
1320 formation = data[ 7];
1323 wep_free = data[10];
1326 float* f = (
float*) (data + 12);
1333 rgn_name = (
const char*) (data + 34);
1334 tgt_name = (
const char*) (data + 66);
1335 elem = (
const char*) (data + 98);
1349 navpoint =
new(__FILE__,__LINE__)
Instruction(rgn, loc, action);
1351 navpoint =
new(__FILE__,__LINE__)
Instruction(rgn_name, loc, action);
1384 ZeroMemory(data,
SIZE);
1389 data[ 2] = (BYTE) ((objid & 0xff00) >> 8);
1390 data[ 3] = (BYTE) ((objid & 0x00ff) );
1391 data[ 4] = (BYTE) index;
1393 strncpy((
char*) (data + 6), elem.
data(), 31);
1401 if (p && p[0] ==
TYPE) {
1402 ZeroMemory(data,
SIZE);
1403 CopyMemory(data, p,
SIZE);
1406 objid = (data[ 2] << 8) |
1410 elem = (
const char*) (data + 6);
1426 ZeroMemory(data,
SIZE);
1431 data[2] = (BYTE) ((objid & 0xff00) >> 8);
1432 data[3] = (BYTE) ((objid & 0x00ff) );
1434 float* p = (
float*) (data + 4);
1443 if (p && p[0] ==
TYPE && p[1] ==
SIZE) {
1444 CopyMemory(data, p,
SIZE);
1446 objid = (data[2] << 8) | data[3];
1447 damage = *(
float*) (data + 4);