1 /////////////////////////////////////////
2 //
3 //             OpenLieroX
4 //
5 // code under LGPL, based on JasonBs work,
6 // enhanced by Dark Charlie and Albert Zeyer
7 //
8 //
9 /////////////////////////////////////////
10 
11 
12 // Shoot list class
13 // Created 20/12/02
14 // Jason Boettcher
15 
16 
17 #ifndef __CSHOOTLIST_H__
18 #define __CSHOOTLIST_H__
19 
20 
21 class CBytestream;
22 class CWorm;
23 struct Version;
24 
25 
26 // Shoot Main flags
27 #define		SMF_LARGEANGLE	0x01
28 #define		SMF_LARGESPEED	0x02
29 #define		SMF_NEGSPEED	0x04
30 
31 // Shoot Offsets
32 #define		SHF_TIMEOFF		0x01
33 #define		SHF_XPOSOFF		0x02
34 #define		SHF_YPOSOFF		0x04
35 #define		SHF_ANGLEOFF	0x08
36 #define		SHF_SPEEDOFF	0x10
37 #define		SHF_NG_XPOSOFF	0x20
38 #define		SHF_NG_YPOSOFF	0x40
39 #define		SHF_EXTRAFLAGS	0x80
40 
41 // Shoot Extra offsets
42 #define		SHF_NG_ANGLEOFF	0x01
43 #define		SHF_NG_SPEEDOFF 0x02
44 #define		SHF_LARGEXOFF	0x04
45 #define		SHF_LARGEYOFF	0x08
46 #define		SHF_XWRMVEL		0x10
47 #define		SHF_YWRMVEL		0x20
48 #define		SHF_NG_XWRMVEL	0x40
49 #define		SHF_NG_YWRMVEL	0x80
50 
51 
52 #define		MAX_SHOOTINGS	256
53 
54 
55 // Weapon Shooting structure
56 struct shoot_t {
57 	TimeDiff	fTime;
58 	int		nWeapon;
59 	CVec	cPos;
60 	CVec	cWormVel;
61 	int		nAngle;
62 	uchar	nRandom; // Actually it's a worm shot count
63 	int		nSpeed;
64 	int		nWormID;
65 
66 	bool	release;
67 };
68 
69 
70 
71 // Shoot list class
72 class CShootList {
73 public:
74 	// Constructor
CShootList()75 	CShootList() {
76 		m_nNumShootings = 0;
77 		m_psShoot = NULL;
78 		m_fStartTime = AbsTime();
79 		m_fLastWrite = AbsTime();
80 	}
81 
82 	// Destructor
~CShootList()83 	~CShootList() {
84 		Shutdown();
85 	}
86 
87 
88 private:
89 	// Attributes
90 
91 	int			m_nNumShootings;
92 	shoot_t		*m_psShoot;
93 	AbsTime		m_fStartTime;
94 	AbsTime		m_fLastWrite;
95 
96 
97 
98 public:
99 	// Methods
100 
101 	bool		Initialize();
102 	void		Shutdown();
103 
104 	bool		addShoot(int weaponID, TimeDiff serverTime, float fSpeed, int nAngle, CWorm *pcWorm, bool release);
105 
106 	bool		writePacket(CBytestream *bs, const Version& receiverVer);
107 
108 private:
109 	void		writeSingle(CBytestream *bs, const Version& receiverVer, int index);
110 	void		writeMulti(CBytestream *bs, const Version& receiverVer, int index);
111 	void		writeSmallShot(shoot_t *psFirst, CBytestream *bs, const Version& receiverVer, int index);
112 
113 public:
114 	void		readSingle(CBytestream *bs, const Version& senderVer, int max_weapon_id);
115 	static bool skipSingle(CBytestream *bs, const Version& senderVer);
116 	void		readMulti(CBytestream *bs, const Version& senderVer, int max_weapon_id);
117 	static bool skipMulti(CBytestream *bs, const Version& senderVer);
118 	void		readSmallShot(shoot_t *psFirst, CBytestream *bs, const Version& senderVer, int index);
119 	static bool	skipSmallShot(CBytestream *bs, const Version& senderVer);
120 
121 	void		Clear();
122 
123 	shoot_t		*getShot(int index);
124 
getNumShots()125 	int			getNumShots()			{ return m_nNumShootings; }
getStartTime()126 	AbsTime		getStartTime()			{ return m_fStartTime; }
getLastWrite()127 	AbsTime		getLastWrite()			{ return m_fLastWrite; }
128 
129 };
130 
131 
132 
133 
134 #endif  //  __CSHOOTLIST_H__
135