aboutsummaryrefslogtreecommitdiff
path: root/src/parsec_server/include/g_main_sv.h
blob: 2215e9ad056a543d8e509105d20e99b11499e0a6 (plain)
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
/** PARSEC HEADER: g_main_sv.h
*/

#ifndef _G_MAIN_H_
#define _G_MAIN_H_


// join position control ------------------------------------------------------
//
#define JP_M_S_D 		500				// minimum join position distance
#define JP_RANGE 		1000			// maximum join position range
#define JP_OFS			(JP_RANGE/2)


// afterburner constants ------------------------------------------------------
//
#define AFTERBURNER_SPEED	150000
#define AFTERBURNER_ENERGY	2400


// forward decls --------------------------------------------------------------
//
template <class T> class UTL_List;
class G_Player;
class E_SimShipState;

// default gametime limits ----------------------------------------------------
//
#define DEFAULT_GAME_TIMELIMIT_SEC		600
#define DEFAULT_RESTART_TIMELIMIT_SEC	15
#define DEFAULT_KILL_LIMIT				10

// class handling the gametime management -------------------------------------
//
class G_TimeManagement
{
protected:

	int GameIsEndless;
	refframe_t	m_GameEndRefFrames;			// refframes for timelimit
	refframe_t  m_GameRefFrames;			// refframes of current game
	refframe_t	m_RestartRefFrames;			// refframes of current restart timeout

	refframe_t	m_RefFrameBase;

	int			m_nSecGameTimeLimit;		// timelimit for the game in sec.
	int			m_nSecRestartTimeLimit;		// time to wait between restarts in sec.
public:
	G_TimeManagement();

	// realize console variables
	void RealizeVariables();

	// reset the game time management
	void Reset();

	// start a game
	void StartGame();

	// stop the game ( time limit hit )
	void StopGame_TimeLimit();

	// stop the game ( kill limit hit )
	void StopGame_KillLimit();

	// return whether the game is not yet started
	int IsNotYetStarted();

	// return whether currently a game is running
	int IsGameRunning();

	// return whether the game is finished
	int IsGameFinished();

	// check whether the game time limit is hit
	int IsGameTimeLimitHit();

	// check whether the restart timeout is over
	int IsRestartTimeoutOver();

	// return the current gametime in secs or special gametime codes
	int GetCurGameTime();
};


// class holding the parsec game code -----------------------------------------
//
class G_Main
{
public:

	int						EnergyExtraBoost;
	int 					RepairExtraBoost;
	int 					DumbPackNumMissls;
	int 					HomPackNumMissls;
	int 					SwarmPackNumMissls;
	int 					ProxPackNumMines;

	int 					MegaShieldStrength;

	int						m_NebulaID;

	G_Player*				m_Players;
	UTL_List<G_Player*>*	m_CurConnectedPlayerList;		// linked list of all currently connected players
	UTL_List<G_Player*>*	m_CurJoinedPlayerList;			// linked list of all currently joined players

	G_TimeManagement		m_TimeManager;
	int						m_nKillLimit;

protected:
	// default ctor/dtor
	G_Main();
	~G_Main();

	// walk list of extra objects and advance them ( also handle timeout )
	void _WalkExtraObjects();

	void _WalkCustomObjects();

	// walk list of laser objects and advance them ( also handle timeout )
	void _WalkLaserObjects();
    
    //walk list of missile objects and advance them
    void _WalkMissileObjects();
    
    //Do particle weapon maintenence
    void MaintainDurationWeapons( int playerid );
    
public:

	// SINGLETON pattern
	static G_Main* GetGame()
	{
		static G_Main _TheGame;
		return &_TheGame;
	}

	void Init();

	// connect a player
	void ConnectPlayer( int nClientID );

	// disconnect a player
	void DisconnectPlayer( int nClientID );

	// join a player ( init join position )
	void JoinPlayer( int nClientID, E_SimShipState* pSimShipState );

	// unjoin a player 
	void UnjoinPlayer( int nClientID );

	// return the # of joined players
	int GetNumJoined();

	// retrieve the # of kills by this player
	int GetPlayerKills( int nClientID );

	// retrieve the last unjoin flag of the player
	int GetPlayerLastUnjoinFlag( int nClientID );

	// retrieve the last killer of the player
	int GetPlayerLastKiller( int nClientID );

	// record a kill of another client
	void RecordKill( int nClientID );

	// record a death of the client
	void RecordDeath( int nClientID, int nClientID_Killer );

	// reset the death info of the client
	void ResetDeathInfo( int nClientID );

	// get the playerinfo ( GAME )
	G_Player* GetPlayer( int nClientID );

	// return a list of currently connected players
	UTL_List<G_Player*>* GetCurConnectedPlayerList() { return m_CurConnectedPlayerList; }

	// return a list of currently joined players
	UTL_List<G_Player*>* GetCurJoinedPlayerList() { return m_CurJoinedPlayerList; }

	// maintain weapon firing delays
	void MaintainWeaponDelays();

	// maintain the game
	void MaintainGame();

	// animate projectile objects (lasers and missiles)
	void OBJ_AnimateProjectiles();

	// animate non-projectile objects (extras, mines)
	void OBJ_AnimateNonProjectiles();

	// for maintaining countes on special powerups for players
	void MaintainSpecialsCounters(  );

    //Duration weapons
    void FireDurationWeapons();
    
	// create actual laser object 
	LaserObject* OBJ_CreateLaserObject( ShipObject *shippo, int curlevel, int barrel, int nClientID );

	// create actual dumb missile object
	MissileObject* OBJ_CreateMissileObject( ShipObject *pShip,  int barrel, int nClientID );
	
	// create actual homing missile object
	MissileObject* OBJ_CreateHomingMissileObject( ShipObject *pShip, int barrel, int nClientID, dword targetid );

	// create actual mine object
	MineObject* OBJ_CreateMineObject( ShipObject *pShip, int nClientID );

	// create actual swarm object
	GenObject* OBJ_CreateSwarm( ShipObject *pShip, int nClientID, dword targetid );


	// check availability of specified device
	int OBJ_DeviceAvailable( ShipObject* pShip, int mask );

	// return the current gametime in secs or special gametime codes
	int GetCurGameTime() { return m_TimeManager.GetCurGameTime(); }

	// return whether a game 
	int IsGameRunning() { return m_TimeManager.IsGameRunning(); }

	// realize game vars from console vars
	void RealizeVariables();

	// create a stargate for a specific server at a position, with a direction
	void CreateStargate( int serverid, Vector3* pos_spec, Vector3* dir_spec );

protected:

	// reset all player game vars
	void _ResetPlayerVars();
};

// class for handling game input ----------------------------------------------
//
class G_Input
{
protected:
	G_Input()	{} 
	~G_Input() {}

public:
	// SINGLETON pattern
	static G_Input* GetGameInput()
	{
		static G_Input _TheGameInput;
		return &_TheGameInput;
	}

	// activate the selected gun for a client
	void ActivateGun( int nClientID, int SelectedGun );

	// deactivate the selected gun for a client
	void DeactivateGun( int nClientID, int SelectedGun );

	// launch a dumb or homing missle
	void LaunchMissile( int nClientID,  dword targetid, int missileclass );

	// launch a mine
	void LaunchMine( int nClientID );
    
    //Swarms
    void LaunchSwarm(int nClientID, dword targetid);

    // EMP
    void CreateEMP(int nClientID, byte UpgradeLevel);

};


#endif // _G_MAIN_H_