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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
|
/* Starshatter OpenSource Distribution
Copyright (c) 1997-2004, Destroyer Studios LLC.
All Rights Reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name "Destroyer Studios" nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
SUBSYSTEM: Stars.exe
FILE: NetData.h
AUTHOR: John DiCamillo
OVERVIEW
========
Payload structures for multiplayer network packets
*/
#ifndef NetData_h
#define NetData_h
#include "Types.h"
#include "Geometry.h"
#include "Text.h"
// +--------------------------------------------------------------------+
// UNRELIABLE: 0x01 - 0x0F
const BYTE NET_PING = 0x01;
const BYTE NET_PONG = 0x02;
const BYTE NET_OBJ_LOC = 0x03;
// RELIABLE: 0x10 - 0x7F
const BYTE NET_JOIN_REQUEST = 0x10;
const BYTE NET_JOIN_ANNOUNCE = 0x11;
const BYTE NET_QUIT_REQUEST = 0x12;
const BYTE NET_QUIT_ANNOUNCE = 0x13;
const BYTE NET_KICK_REQUEST = 0x14;
const BYTE NET_KICK_ANNOUNCE = 0x15;
const BYTE NET_GAME_OVER = 0x16;
const BYTE NET_COMM_MESSAGE = 0x17;
const BYTE NET_CHAT_MESSAGE = 0x18;
const BYTE NET_DISCONNECT = 0x19;
const BYTE NET_OBJ_DAMAGE = 0x20;
const BYTE NET_OBJ_KILL = 0x21;
const BYTE NET_OBJ_SPAWN = 0x22;
const BYTE NET_OBJ_HYPER = 0x23;
const BYTE NET_OBJ_TARGET = 0x24;
const BYTE NET_OBJ_EMCON = 0x25;
const BYTE NET_SYS_DAMAGE = 0x26;
const BYTE NET_SYS_STATUS = 0x27;
const BYTE NET_ELEM_CREATE = 0x28;
const BYTE NET_SHIP_LAUNCH = 0x29;
const BYTE NET_NAV_DATA = 0x2A;
const BYTE NET_NAV_DELETE = 0x2B;
const BYTE NET_ELEM_REQUEST = 0x2C;
const BYTE NET_WEP_TRIGGER = 0x30;
const BYTE NET_WEP_RELEASE = 0x31;
const BYTE NET_WEP_DESTROY = 0x32;
const BYTE NET_SELF_DESTRUCT = 0x3F;
// +--------------------------------------------------------------------+
class Ship;
// +--------------------------------------------------------------------+
class NetData
{
public:
static const char* TYPENAME() { return "NetData"; }
NetData() { }
virtual ~NetData() { }
virtual int Type() const { return 0; }
virtual int Length() const { return 0; }
virtual BYTE* Pack() { return 0; }
virtual bool Unpack(const BYTE* data) { return 0; }
virtual DWORD GetObjID() const { return 0; }
virtual void SetObjID(DWORD o) { }
};
// +--------------------------------------------------------------------+
class NetObjLoc : public NetData
{
public:
static const char* TYPENAME() { return "NetObjLoc"; }
NetObjLoc() : objid(0), throttle(false), augmenter(false), shield(0) { }
NetObjLoc(DWORD oid, const Point& pos, const Point& orient, const Point& vel) :
objid(oid), location(pos), euler(orient), velocity(vel),
throttle(false), augmenter(false), gear(false), shield(0) { }
enum { TYPE=NET_OBJ_LOC, SIZE=24 };
virtual BYTE* Pack();
virtual bool Unpack(const BYTE* data);
virtual int Type() const { return TYPE; }
virtual int Length() const { return SIZE; }
virtual DWORD GetObjID() const { return objid; }
virtual void SetObjID(DWORD id) { objid = id; }
Point GetLocation() const { return location; }
Point GetVelocity() const { return velocity; }
Point GetOrientation() const { return euler; }
bool GetThrottle() const { return throttle; }
bool GetAugmenter() const { return augmenter; }
bool GetGearDown() const { return gear; }
int GetShield() const { return shield; }
void SetLocation(const Point& loc) { location = loc; }
void SetVelocity(const Point& v) { velocity = v; }
void SetOrientation(const Point& o) { euler = o; }
void SetThrottle(bool t) { throttle = t; }
void SetAugmenter(bool a) { augmenter = a; }
void SetGearDown(bool g) { gear = g; }
void SetShield(int s) { shield = s; }
private:
DWORD objid;
Point location;
Point velocity;
Point euler;
bool throttle;
bool augmenter;
bool gear;
int shield;
BYTE data[SIZE];
};
// +--------------------------------------------------------------------+
class NetJoinRequest : public NetData
{
public:
static const char* TYPENAME() { return "NetJoinRequest"; }
NetJoinRequest() : index(0) { }
enum { TYPE=NET_JOIN_REQUEST, SIZE=128 };
virtual BYTE* Pack();
virtual bool Unpack(const BYTE* data);
virtual int Type() const { return TYPE; }
virtual int Length() const { return SIZE; }
const char* GetName() const { return name; }
const char* GetPassword() const { return pass; }
const char* GetSerialNumber() const { return serno; }
const char* GetElement() const { return elem; }
int GetIndex() const { return index; }
void SetName(const char* n) { name = n; }
void SetPassword(const char* p) { pass = p; }
void SetSerialNumber(const char* s){ serno = s; }
void SetElement(const char* n) { elem = n; }
void SetIndex(int n) { index = n; }
private:
Text name; // callsign
Text pass; // password
Text serno; // box cdkey
Text elem; // element to join
int index; // one-based index
BYTE data[SIZE];
};
// +--------------------------------------------------------------------+
class NetJoinAnnounce : public NetData
{
public:
static const char* TYPENAME() { return "NetJoinAnnounce"; }
NetJoinAnnounce();
enum { TYPE=NET_JOIN_ANNOUNCE, SIZE=200 };
virtual BYTE* Pack();
virtual bool Unpack(const BYTE* data);
virtual int Type() const { return TYPE; }
virtual int Length() const { return SIZE; }
virtual DWORD GetObjID() const { return objid; }
virtual void SetObjID(DWORD o) { objid = o; }
const char* GetName() const { return name; }
const char* GetElement() const { return elem; }
const char* GetRegion() const { return region; }
const Point& GetLocation() const { return loc; }
const Point& GetVelocity() const { return velocity; }
int GetIndex() const { return index; }
double GetIntegrity() const { return integrity; }
int GetRespawns() const { return respawns; }
int GetDecoys() const { return decoys; }
int GetProbes() const { return probes; }
int GetFuel() const { return fuel; }
int GetShield() const { return shield; }
const int* GetAmmo() const { return ammo; }
void SetShip(Ship* s);
void SetName(const char* n) { name = n; }
void SetElement(const char* n) { elem = n; }
void SetRegion(const char* r) { region = r; }
void SetLocation(const Point& l) { loc = l; }
void SetVelocity(const Point& v) { velocity = v; }
void SetIndex(int n) { index = n; }
void SetIntegrity(double n) { integrity = (float) n; }
void SetRespawns(int n) { respawns = n; }
void SetDecoys(int n) { decoys = n; }
void SetProbes(int n) { probes = n; }
void SetFuel(int n) { fuel = n; }
void SetShield(int n) { shield = n; }
void SetAmmo(const int* a);
virtual DWORD GetNetID() const { return nid; }
virtual void SetNetID(DWORD n) { nid = n; }
private:
Text name; // callsign
Text elem; // element to join
Text region; // region ship is in
Point loc; // location of ship
Point velocity; // velocity of ship
int index; // one-based index
float integrity; // hull integrity
int respawns;
int decoys;
int probes;
int fuel;
int shield;
int ammo[16];
DWORD objid;
DWORD nid; // not sent over network
BYTE data[SIZE];
};
// +--------------------------------------------------------------------+
class NetQuitAnnounce : public NetData
{
public:
static const char* TYPENAME() { return "NetQuitAnnounce"; }
NetQuitAnnounce() : objid(0), disconnected(false) { }
enum { TYPE=NET_QUIT_ANNOUNCE, SIZE=5 };
virtual BYTE* Pack();
virtual bool Unpack(const BYTE* data);
virtual int Type() const { return TYPE; }
virtual int Length() const { return SIZE; }
virtual DWORD GetObjID() const { return objid; }
virtual void SetObjID(DWORD o) { objid = o; }
virtual bool GetDisconnected() const { return disconnected; }
virtual void SetDisconnected(bool d) { disconnected = d; }
private:
DWORD objid;
bool disconnected;
BYTE data[SIZE];
};
// +--------------------------------------------------------------------+
class NetDisconnect : public NetData
{
public:
static const char* TYPENAME() { return "NetDisconnect"; }
NetDisconnect() { }
enum { TYPE=NET_DISCONNECT, SIZE=2 };
virtual BYTE* Pack();
virtual bool Unpack(const BYTE* data);
virtual int Type() const { return TYPE; }
virtual int Length() const { return SIZE; }
private:
BYTE data[SIZE];
};
// +--------------------------------------------------------------------+
class NetObjDamage : public NetData
{
public:
static const char* TYPENAME() { return "NetObjDamage"; }
NetObjDamage() : objid(0), damage(0), shotid(0) { }
enum { TYPE=NET_OBJ_DAMAGE, SIZE=12 };
virtual BYTE* Pack();
virtual bool Unpack(const BYTE* data);
virtual int Type() const { return TYPE; }
virtual int Length() const { return SIZE; }
virtual DWORD GetObjID() const { return objid; }
virtual void SetObjID(DWORD o) { objid = o; }
virtual DWORD GetShotID() const { return shotid; }
virtual void SetShotID(DWORD o) { shotid = o; }
float GetDamage() const { return damage; }
void SetDamage(float d) { damage = d; }
private:
DWORD objid;
float damage;
DWORD shotid;
BYTE data[SIZE];
};
// +--------------------------------------------------------------------+
class NetObjKill : public NetData
{
public:
static const char* TYPENAME() { return "NetObjKill"; }
NetObjKill() : objid(0), kill_id(0), killtype(0), respawn(false), deck(0) { }
enum { TYPE=NET_OBJ_KILL, SIZE=24,
KILL_MISC = 0,
KILL_PRIMARY,
KILL_SECONDARY,
KILL_COLLISION,
KILL_CRASH,
KILL_DOCK
};
virtual BYTE* Pack();
virtual bool Unpack(const BYTE* data);
virtual int Type() const { return TYPE; }
virtual int Length() const { return SIZE; }
virtual DWORD GetObjID() const { return objid; }
virtual void SetObjID(DWORD o) { objid = o; }
virtual DWORD GetKillerID() const { return kill_id; }
virtual void SetKillerID(DWORD o) { kill_id = o; }
virtual int GetKillType() const { return killtype;}
virtual void SetKillType(int t) { killtype = t; }
virtual bool GetRespawn() const { return respawn; }
virtual void SetRespawn(bool r) { respawn = r; }
virtual Point GetRespawnLoc() const { return loc; }
virtual void SetRespawnLoc(const Point& p) { loc = p; }
virtual int GetFlightDeck() const { return deck; }
virtual void SetFlightDeck(int n) { deck = n; }
private:
DWORD objid;
DWORD kill_id;
int killtype;
bool respawn;
Point loc;
int deck;
BYTE data[SIZE];
};
// +--------------------------------------------------------------------+
class NetObjHyper : public NetData
{
public:
static const char* TYPENAME() { return "NetObjHyper"; }
NetObjHyper() : objid(0), fc_src(0), fc_dst(0), transtype(0) { }
enum { TYPE=NET_OBJ_HYPER, SIZE=56 };
virtual BYTE* Pack();
virtual bool Unpack(const BYTE* data);
virtual int Type() const { return TYPE; }
virtual int Length() const { return SIZE; }
virtual DWORD GetObjID() const { return objid; }
virtual void SetObjID(DWORD id) { objid = id; }
const Point& GetLocation() const { return location; }
const Text& GetRegion() const { return region; }
DWORD GetFarcaster1() const { return fc_src; }
DWORD GetFarcaster2() const { return fc_dst; }
int GetTransitionType() const { return transtype; }
void SetLocation(const Point& loc) { location = loc; }
void SetRegion(const char* rgn) { region = rgn; }
void SetFarcaster1(DWORD f) { fc_src = f; }
void SetFarcaster2(DWORD f) { fc_dst = f; }
void SetTransitionType(int t) { transtype = t; }
private:
DWORD objid;
Point location;
Text region;
DWORD fc_src;
DWORD fc_dst;
int transtype;
BYTE data[SIZE];
};
// +--------------------------------------------------------------------+
class NetObjTarget : public NetData
{
public:
static const char* TYPENAME() { return "NetObjTarget"; }
NetObjTarget() : objid(0), tgtid(0), sysix(0) { }
enum { TYPE=NET_OBJ_TARGET, SIZE=7 };
virtual BYTE* Pack();
virtual bool Unpack(const BYTE* data);
virtual int Type() const { return TYPE; }
virtual int Length() const { return SIZE; }
virtual DWORD GetObjID() const { return objid; }
virtual void SetObjID(DWORD o) { objid = o; }
DWORD GetTgtID() const { return tgtid; }
void SetTgtID(DWORD o) { tgtid = o; }
int GetSubtarget() const { return sysix; }
void SetSubtarget(int n) { sysix = n; }
private:
DWORD objid;
DWORD tgtid;
int sysix;
BYTE data[SIZE];
};
// +--------------------------------------------------------------------+
class NetObjEmcon : public NetData
{
public:
static const char* TYPENAME() { return "NetObjEmcon"; }
NetObjEmcon() : objid(0), emcon(0) { }
enum { TYPE=NET_OBJ_EMCON, SIZE=5 };
virtual BYTE* Pack();
virtual bool Unpack(const BYTE* data);
virtual int Type() const { return TYPE; }
virtual int Length() const { return SIZE; }
virtual DWORD GetObjID() const { return objid; }
virtual void SetObjID(DWORD o) { objid = o; }
int GetEMCON() const { return emcon; }
void SetEMCON(int n) { emcon = n; }
private:
DWORD objid;
int emcon;
BYTE data[SIZE];
};
// +--------------------------------------------------------------------+
class NetSysDamage : public NetData
{
public:
static const char* TYPENAME() { return "NetSysDamage"; }
NetSysDamage() : objid(0), sysix(-1), dmgtype(0), damage(0) { }
enum { TYPE=NET_SYS_DAMAGE, SIZE=12 };
virtual BYTE* Pack();
virtual bool Unpack(const BYTE* data);
virtual int Type() const { return TYPE; }
virtual int Length() const { return SIZE; }
virtual DWORD GetObjID() const { return objid; }
virtual void SetObjID(DWORD o) { objid = o; }
int GetSystem() const { return sysix; }
void SetSystem(int n) { sysix = n; }
BYTE GetDamageType() const { return dmgtype; }
void SetDamageType(BYTE t) { dmgtype = t; }
double GetDamage() const { return damage; }
void SetDamage(double d) { damage = d; }
private:
DWORD objid;
int sysix;
BYTE dmgtype;
double damage;
BYTE data[SIZE];
};
// +--------------------------------------------------------------------+
class NetSysStatus : public NetData
{
public:
static const char* TYPENAME() { return "NetSysStatus"; }
NetSysStatus() : objid(0), sysix(-1), status(0), power(0), reactor(0),
avail(1) { }
enum { TYPE=NET_SYS_STATUS, SIZE=12 };
virtual BYTE* Pack();
virtual bool Unpack(const BYTE* data);
virtual int Type() const { return TYPE; }
virtual int Length() const { return SIZE; }
virtual DWORD GetObjID() const { return objid; }
virtual void SetObjID(DWORD o) { objid = o; }
int GetSystem() const { return sysix; }
void SetSystem(int n) { sysix = n; }
BYTE GetStatus() const { return status; }
void SetStatus(BYTE s) { status = s; }
int GetPower() const { return power; }
void SetPower(int n) { power = n; }
int GetReactor() const { return reactor; }
void SetReactor(int n) { reactor = n; }
double GetAvailability() const { return avail; }
void SetAvailablility(double a) { avail = a; }
private:
DWORD objid;
int sysix;
int status;
int power;
int reactor;
double avail;
BYTE data[SIZE];
};
// +--------------------------------------------------------------------+
class NetWepTrigger : public NetData
{
public:
static const char* TYPENAME() { return "NetWepTrigger"; }
NetWepTrigger() : objid(0), tgtid(0), sysix(-1), index(0), count(0),
decoy(false), probe(false) { }
enum { TYPE=NET_WEP_TRIGGER, SIZE=10 };
virtual BYTE* Pack();
virtual bool Unpack(const BYTE* data);
virtual int Type() const { return TYPE; }
virtual int Length() const { return SIZE; }
virtual DWORD GetObjID() const { return objid; }
virtual void SetObjID(DWORD o) { objid = o; }
DWORD GetTgtID() const { return tgtid; }
void SetTgtID(DWORD o) { tgtid = o; }
int GetSubtarget() const { return sysix; }
void SetSubtarget(int n) { sysix = n; }
int GetIndex() const { return index; }
void SetIndex(int n) { index = n; }
int GetCount() const { return count; }
void SetCount(int n) { count = n; }
bool GetDecoy() const { return decoy; }
void SetDecoy(bool d) { decoy = d; }
bool GetProbe() const { return probe; }
void SetProbe(bool p) { probe = p; }
private:
DWORD objid;
DWORD tgtid;
int sysix;
int index;
int count;
bool decoy;
bool probe;
BYTE data[SIZE];
};
// +--------------------------------------------------------------------+
class NetWepRelease : public NetData
{
public:
static const char* TYPENAME() { return "NetWepRelease"; }
NetWepRelease() : objid(0), tgtid(0), wepid(0), sysix(-1), index(0),
decoy(false), probe(false) { }
enum { TYPE=NET_WEP_RELEASE, SIZE=11 };
virtual BYTE* Pack();
virtual bool Unpack(const BYTE* data);
virtual int Type() const { return TYPE; }
virtual int Length() const { return SIZE; }
virtual DWORD GetObjID() const { return objid; }
virtual void SetObjID(DWORD o) { objid = o; }
DWORD GetTgtID() const { return tgtid; }
void SetTgtID(DWORD o) { tgtid = o; }
int GetSubtarget() const { return sysix; }
void SetSubtarget(int n) { sysix = n; }
DWORD GetWepID() const { return wepid; }
void SetWepID(DWORD o) { wepid = o; }
int GetIndex() const { return index; }
void SetIndex(int n) { index = n; }
bool GetDecoy() const { return decoy; }
void SetDecoy(bool d) { decoy = d; }
bool GetProbe() const { return probe; }
void SetProbe(bool p) { probe = p; }
private:
DWORD objid;
DWORD tgtid;
DWORD wepid;
int sysix;
int index;
bool decoy;
bool probe;
BYTE data[SIZE];
};
// +--------------------------------------------------------------------+
class NetWepDestroy : public NetData
{
public:
static const char* TYPENAME() { return "NetWepDestroy"; }
NetWepDestroy() : objid(0) { }
enum { TYPE=NET_WEP_DESTROY, SIZE=4 };
virtual BYTE* Pack();
virtual bool Unpack(const BYTE* data);
virtual int Type() const { return TYPE; }
virtual int Length() const { return SIZE; }
virtual DWORD GetObjID() const { return objid; }
virtual void SetObjID(DWORD o) { objid = o; }
private:
DWORD objid;
BYTE data[SIZE];
};
// +--------------------------------------------------------------------+
class RadioMessage;
class NetCommMsg : public NetData
{
public:
static const char* TYPENAME() { return "NetCommMsg"; }
NetCommMsg() : objid(0), radio_message(0), length(0) { }
virtual ~NetCommMsg();
enum { TYPE=NET_COMM_MESSAGE, SIZE=200 };
virtual BYTE* Pack();
virtual bool Unpack(const BYTE* data);
virtual int Type() const { return TYPE; }
virtual int Length() const { return length; }
virtual DWORD GetObjID() const { return objid; }
virtual void SetObjID(DWORD o) { objid = o; }
RadioMessage* GetRadioMessage() { return radio_message; }
void SetRadioMessage(RadioMessage* m);
private:
DWORD objid;
RadioMessage* radio_message;
int length;
BYTE data[SIZE];
};
// +--------------------------------------------------------------------+
class NetChatMsg : public NetData
{
public:
static const char* TYPENAME() { return "NetChatMsg"; }
NetChatMsg() : dstid(0), length(0) { }
enum { TYPE=NET_CHAT_MESSAGE, SIZE=210, MAX_CHAT=160, HDR_LEN=4, NAME_LEN=32 };
virtual BYTE* Pack();
virtual bool Unpack(const BYTE* data);
virtual int Type() const { return TYPE; }
virtual int Length() const { return length; }
virtual DWORD GetDstID() const { return dstid; }
virtual void SetDstID(DWORD d) { dstid = d; }
const Text& GetName() const { return name; }
void SetName(const char* m) { name = m; }
const Text& GetText() const { return text; }
void SetText(const char* m) { text = m; }
private:
DWORD dstid;
Text name;
Text text;
int length;
BYTE data[SIZE];
};
// +--------------------------------------------------------------------+
class NetElemRequest : public NetData
{
public:
static const char* TYPENAME() { return "NetElemRequest"; }
NetElemRequest();
enum { TYPE=NET_ELEM_REQUEST, SIZE=64, NAME_LEN=32 };
virtual BYTE* Pack();
virtual bool Unpack(const BYTE* data);
virtual int Type() const { return TYPE; }
virtual int Length() const { return SIZE; }
const Text& GetName() const { return name; }
void SetName(const char* m) { name = m; }
private:
Text name;
BYTE data[SIZE];
};
// +--------------------------------------------------------------------+
class NetElemCreate : public NetData
{
public:
static const char* TYPENAME() { return "NetElemCreate"; }
NetElemCreate();
enum { TYPE=NET_ELEM_CREATE, SIZE=192, NAME_LEN=32 };
virtual BYTE* Pack();
virtual bool Unpack(const BYTE* data);
virtual int Type() const { return TYPE; }
virtual int Length() const { return SIZE; }
const Text& GetName() const { return name; }
void SetName(const char* m) { name = m; }
const Text& GetCommander() const { return commander; }
void SetCommander(const char* m) { commander = m; }
const Text& GetObjective() const { return objective; }
void SetObjective(const char* m) { objective = m; }
const Text& GetCarrier() const { return carrier; }
void SetCarrier(const char* m) { carrier = m; }
int GetIFF() const { return iff; }
void SetIFF(int n) { iff = n; }
int GetType() const { return type; }
void SetType(int n) { type = n; }
int GetIntel() const { return intel; }
void SetIntel(int n) { intel = n; }
int GetObjCode() const { return obj_code; }
void SetObjCode(int n) { obj_code = n; }
int GetSquadron() const { return squadron; }
void SetSquadron(int n) { squadron = n; }
int* GetLoadout() { return load; }
void SetLoadout(int* n);
int* GetSlots() { return slots; }
void SetSlots(int* n);
bool GetAlert() const { return alert; }
void SetAlert(bool a) { alert = a; }
bool GetInFlight() const { return in_flight; }
void SetInFlight(bool f) { in_flight = f; }
private:
Text name;
int iff;
int type;
int intel;
int obj_code;
int squadron;
Text commander;
Text objective;
Text carrier;
int load[16];
int slots[4];
bool alert;
bool in_flight;
BYTE data[SIZE];
};
// +--------------------------------------------------------------------+
class NetShipLaunch : public NetData
{
public:
static const char* TYPENAME() { return "NetShipLaunch"; }
NetShipLaunch() : objid(0), squadron(0), slot(0) { }
enum { TYPE=NET_SHIP_LAUNCH, SIZE=16 };
virtual BYTE* Pack();
virtual bool Unpack(const BYTE* data);
virtual int Type() const { return TYPE; }
virtual int Length() const { return SIZE; }
virtual DWORD GetObjID() const { return objid; }
virtual int GetSquadron() const { return squadron; }
virtual int GetSlot() const { return slot; }
virtual void SetObjID(DWORD o) { objid = o; }
virtual void SetSquadron(int s) { squadron = s; }
virtual void SetSlot(int s) { slot = s; }
private:
DWORD objid;
int squadron;
int slot;
BYTE data[SIZE];
};
// +--------------------------------------------------------------------+
class Instruction;
class NetNavData : public NetData
{
public:
static const char* TYPENAME() { return "NetNavData"; }
NetNavData();
virtual ~NetNavData();
enum { TYPE=NET_NAV_DATA, SIZE=144, NAME_LEN=32 };
virtual BYTE* Pack();
virtual bool Unpack(const BYTE* data);
virtual int Type() const { return TYPE; }
virtual int Length() const { return SIZE; }
virtual DWORD GetObjID() const { return objid; }
bool IsAdd() const { return create; }
bool IsEdit() const { return !create; }
const Text& GetElem() const { return elem; }
int GetIndex() const { return index; }
Instruction* GetNavPoint() const { return navpoint; }
virtual void SetObjID(DWORD o) { objid = o; }
void SetAdd(bool b) { create = b; }
void SetElem(const char* e) { elem = e; }
void SetIndex(int n) { index = n; }
void SetNavPoint(Instruction* n);
private:
DWORD objid;
bool create;
Text elem;
int index;
Instruction* navpoint;
BYTE data[SIZE];
};
// +--------------------------------------------------------------------+
class NetNavDelete : public NetData
{
public:
static const char* TYPENAME() { return "NetNavDelete"; }
NetNavDelete() : objid(0), index(0) { }
enum { TYPE=NET_NAV_DELETE, SIZE=40 };
virtual BYTE* Pack();
virtual bool Unpack(const BYTE* data);
virtual int Type() const { return TYPE; }
virtual int Length() const { return SIZE; }
virtual DWORD GetObjID() const { return objid; }
const Text& GetElem() const { return elem; }
int GetIndex() const { return index; }
virtual void SetObjID(DWORD o) { objid = o; }
void SetElem(const char* e) { elem = e; }
void SetIndex(int n) { index = n; }
private:
DWORD objid;
Text elem;
int index;
BYTE data[SIZE];
};
// +--------------------------------------------------------------------+
class NetSelfDestruct : public NetData
{
public:
static const char* TYPENAME() { return "NetSelfDestruct"; }
NetSelfDestruct() : objid(0), damage(0) { }
enum { TYPE=NET_SELF_DESTRUCT, SIZE=8 };
virtual BYTE* Pack();
virtual bool Unpack(const BYTE* data);
virtual int Type() const { return TYPE; }
virtual int Length() const { return SIZE; }
virtual DWORD GetObjID() const { return objid; }
virtual void SetObjID(DWORD o) { objid = o; }
float GetDamage() const { return damage; }
void SetDamage(float d) { damage = d; }
private:
DWORD objid;
float damage;
BYTE data[SIZE];
};
// +--------------------------------------------------------------------+
#endif NetData_h
|