-
Notifications
You must be signed in to change notification settings - Fork 59
/
CShootList.h
137 lines (98 loc) · 2.72 KB
/
CShootList.h
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
/////////////////////////////////////////
//
// OpenLieroX
//
// code under LGPL, based on JasonBs work,
// enhanced by Dark Charlie and Albert Zeyer
//
//
/////////////////////////////////////////
// Shoot list class
// Created 20/12/02
// Jason Boettcher
#ifndef __CSHOOTLIST_H__
#define __CSHOOTLIST_H__
class CBytestream;
class CWorm;
struct Version;
// Shoot Main flags
#define SMF_LARGEANGLE 0x01
#define SMF_LARGESPEED 0x02
#define SMF_NEGSPEED 0x04
// Shoot Offsets
#define SHF_TIMEOFF 0x01
#define SHF_XPOSOFF 0x02
#define SHF_YPOSOFF 0x04
#define SHF_ANGLEOFF 0x08
#define SHF_SPEEDOFF 0x10
#define SHF_NG_XPOSOFF 0x20
#define SHF_NG_YPOSOFF 0x40
#define SHF_EXTRAFLAGS 0x80
// Shoot Extra offsets
#define SHF_NG_ANGLEOFF 0x01
#define SHF_NG_SPEEDOFF 0x02
#define SHF_LARGEXOFF 0x04
#define SHF_LARGEYOFF 0x08
#define SHF_XWRMVEL 0x10
#define SHF_YWRMVEL 0x20
#define SHF_NG_XWRMVEL 0x40
#define SHF_NG_YWRMVEL 0x80
#define MAX_SHOOTINGS 256
// Weapon Shooting structure
struct shoot_t {
TimeDiff fTime;
int nWeapon;
CVec cPos;
CVec cWormVel;
int nAngle;
int nRandom;
int nSpeed;
int nWormID;
int devID;
bool release;
AbsTime spawnTime();
};
// Shoot list class
class CShootList {
public:
// Constructor
CShootList() {
m_nNumShootings = 0;
m_psShoot = NULL;
m_fStartTime = AbsTime();
m_fLastWrite = AbsTime();
}
// Destructor
~CShootList() {
Shutdown();
}
private:
// Attributes
int m_nNumShootings;
shoot_t *m_psShoot;
AbsTime m_fStartTime;
AbsTime m_fLastWrite;
public:
// Methods
bool Initialize();
void Shutdown();
bool addShoot(int weaponID, TimeDiff serverTime, float fSpeed, int nAngle, CWorm *pcWorm, bool release);
bool writePacket(CBytestream *bs, const Version& receiverVer);
private:
void writeSingle(CBytestream *bs, const Version& receiverVer, int index);
void writeMulti(CBytestream *bs, const Version& receiverVer, int index);
void writeSmallShot(shoot_t *psFirst, CBytestream *bs, const Version& receiverVer, int index);
public:
void readSingle(CBytestream *bs, const Version& senderVer, int max_weapon_id);
static bool skipSingle(CBytestream *bs, const Version& senderVer);
void readMulti(CBytestream *bs, const Version& senderVer, int max_weapon_id);
static bool skipMulti(CBytestream *bs, const Version& senderVer);
void readSmallShot(shoot_t *psFirst, CBytestream *bs, const Version& senderVer, int index);
static bool skipSmallShot(CBytestream *bs, const Version& senderVer);
void Clear();
shoot_t *getShot(int index);
int getNumShots() { return m_nNumShootings; }
AbsTime getStartTime() { return m_fStartTime; }
AbsTime getLastWrite() { return m_fLastWrite; }
};
#endif // __CSHOOTLIST_H__