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 // Game header file
13 // Created 28/6/02
14 // Jason Boettcher
15 
16 #ifndef __LIEROX_H__
17 #define __LIEROX_H__
18 
19 
20 // HINT: for AI debug define _AI_DEBUG in your IDE/compiler
21 
22 
23 #include <list>
24 #include <string>
25 #include <setjmp.h>
26 #include "Options.h"
27 #include "CFont.h"
28 #include "CVec.h"
29 #include "Consts.h"
30 #include "CInput.h"
31 #include "types.h"
32 
33 class profile_t;
34 class IpToCountryDB;
35 
36 
37 
38 // Game types
39 enum GameType_t {
40 	GME_LOCAL=0,
41 	GME_HOST,
42 	GME_JOIN
43 };
44 
45 // LieroX structure
46 struct lierox_t {
lierox_tlierox_t47 	lierox_t() :
48 			bVideoModeChanged(false), bQuitGame(false), bQuitEngine(false), bQuitCtrlC(false)
49 			, iGameType(GME_LOCAL), bHosted(false) {}
50 	AbsTime	currentTime;
51 	TimeDiff	fDeltaTime;
52 	TimeDiff	fRealDeltaTime; // Delta time used for network synchronization,
53 							// it is not clamped unlike the above one
54 	CFont	cFont;
55 	CFont	cOutlineFont;
56 
57 	bool	bVideoModeChanged;
58 
59 	bool	bQuitGame;
60 	bool	bQuitEngine;
61 	bool	bQuitCtrlC;
62 
63 	int		debug_int;
64 	float	debug_float;
65 	CVec	debug_pos;
66 
67 	GameType_t iGameType;
68 	bool	bHosted;  // True if the user has run the server at least once this session
69 
70 	// Default Colours
71 	Color			clNormalLabel;
72 	Color			clHeading;
73 	Color			clSubHeading;
74 	Color			clChatText;
75 	Color			clNetworkText;
76 	Color			clPrivateText;
77 	Color			clNormalText;
78 	Color			clNotice;
79 	Color			clDropDownText;
80 	Color			clDisabled;
81 	Color			clListView;
82 	Color			clTextBox;
83 	Color			clMouseOver;
84 	Color			clError;
85 	Color			clCredits1;
86 	Color			clCredits2;
87 	Color			clPopupMenu;
88 	Color			clWaiting;
89 	Color			clReady;
90 	Color			clPlayerName;
91 	Color			clBoxLight;
92 	Color			clBoxDark;
93 	Color			clWinBtnBody;
94 	Color			clWinBtnLight;
95 	Color			clWinBtnDark;
96 	Color			clMPlayerTime;
97 	Color			clMPlayerSong;
98 	Color			clChatBoxBackground;
99 	Color			clDialogBackground;
100 	Color			clGameBackground;
101 	Color			clViewportSplit;
102 	Color			clScrollbarBack;
103 	Color			clScrollbarBackLight;
104 	Color			clScrollbarFront;
105 	Color			clScrollbarHighlight;
106 	Color			clScrollbarShadow;
107 	Color			clSliderLight;
108 	Color			clSliderDark;
109 	Color			clCurrentSettingsBg;
110 	Color			clScoreBackground;
111 	Color			clScoreHighlight;
112 	Color			clDialogCaption;
113 	Color			clPlayerDividingLine;
114 	Color			clLine;
115 	Color			clProgress;
116 	Color			clListviewSelected;
117 	Color			clComboboxSelected;
118 	Color			clComboboxShowAllMain;
119 	Color			clComboboxShowAllBorder;
120 	Color			clMenuSelected;
121 	Color			clMenuBackground;
122 	Color			clGameChatter;
123 	Color			clSelection;
124 	Color			clTextboxCursor;
125 	Color			clGameChatCursor;
126 	Color			clConsoleCursor;
127 	Color			clConsoleNormal;
128 	Color			clConsoleNotify;
129 	Color			clConsoleError;
130 	Color			clConsoleWarning;
131 	Color			clConsoleDev;
132 	Color			clConsoleChat;
133 	Color			clReturningToLobby;
134 	Color			clTeamColors[4];
135 	Color			clTagHighlight;
136 	Color			clHealthLabel;
137 	Color			clWeaponLabel;
138 	Color			clLivesLabel;
139 	Color			clKillsLabel;
140 	Color			clFPSLabel;
141 	Color			clPingLabel;
142 	Color			clSpecMsgLabel;
143 	Color			clLoadingLabel;
144 	Color			clIpLoadingLabel;
145 	Color			clWeaponSelectionTitle;
146 	Color			clWeaponSelectionActive;
147 	Color			clWeaponSelectionDefault;
148 	Color			clRopeColors[2];
149 	Color			clLaserSightColors[2];
150 	Color			clTimeLeftLabel;
151 	Color			clTimeLeftWarnLabel;
152 
153 
154 	Color			clPink;
155 	Color			clWhite;
156 	Color			clBlack;
157 
158 
159 	std::string	debug_string;
160 
161 
162 	CInput		cTakeScreenshot;
163 	CInput		cSwitchMode;
164 	CInput		cIrcChat;
165 	CInput		cConsoleToggle;
166 	void setupInputs();
167 	bool isAnyControlKeyDown() const;
168 };
169 
170 
171 // Object structure (for maprandom_t)
172 // HINT: DON'T change the variable types because they are saved directly to the file (CMap.cpp)
173 class object_t { public:
174 	Sint32		Type;
175 	Sint32		Size;
176 	Sint32     X, Y;
177 };
178 
179 
180 /*
181 // Random map data
182 // TODO: Move in lierox_t if needed, actually random map layouts not used anymore, so it should be removed
183 class maprandom_t { public:
184 	maprandom_t()  { psObjects = NULL; bUsed = false; }
185     bool        bUsed;
186     std::string szTheme;
187     int         nNumObjects;
188     object_t    *psObjects;
189 };
190 */
191 
192 
193 
194 extern	lierox_t		*tLX;
195 extern  bool			bDisableSound; // only true in dedicated mode or if soundinit failed; it's false even if you did not activate sound
196 extern	bool			bDedicated;
197 extern  bool			bJoystickSupport;
198 extern  bool			bRestartGameAfterQuit;
199 
200 #ifndef WIN32
201 extern	sigjmp_buf longJumpBuffer;
202 #endif
203 
204 
205 typedef bool (*TStartFunction) (void* data);
206 extern  TStartFunction	startFunction;
207 extern	void*			startFunctionData;
208 
209 class FileListCacheIntf;
210 extern FileListCacheIntf* mapList;
211 extern FileListCacheIntf* modList;
212 extern FileListCacheIntf* skinList;
213 extern FileListCacheIntf* settingsPresetList;
214 void updateFileListCaches();
215 
216 // Main Routines
217 void    ParseArguments(int argc, char *argv[]);
218 int		InitializeLieroX();
219 void	ShutdownLieroX();
220 void	GameLoopFrame();
221 void	QuittoMenu();
222 void	GotoLocalMenu();
223 void	GotoNetMenu();
224 
225 void	SetQuitEngineFlag(const std::string& reason);
226 void	ResetQuitEngineFlag();
227 bool	Warning_QuitEngineFlagSet(const std::string& preText = "");
228 
229 // Miscellanous routines
230 float	GetFixedRandomNum(uchar index);
231 void	ConvertTime(TimeDiff time, int *hours, int *minutes, int *seconds);
232 bool    MouseInRect(int x, int y, int w, int h);
233 
234 void	printf(const std::string& txt);
235 
236 
237 
238 enum GameState {
239 	S_INACTIVE, // server was not started
240 	S_SVRLOBBY, // in lobby
241 	S_SVRWEAPONS, // in game: in weapon selection
242 	S_SVRPLAYING, // in game: playing
243 	S_CLICONNECTING, // client game: connecting right now
244 	S_CLILOBBY,
245 	S_CLIWEAPONS,
246 	S_CLIPLAYING
247 };
248 
GameStateAsString(GameState s)249 inline std::string GameStateAsString(GameState s) {
250 	switch(s) {
251 		case S_INACTIVE: return "S_INACTIVE";
252 		case S_SVRLOBBY: return "S_SVRLOBBY";
253 		case S_SVRWEAPONS: return "S_SVRWEAPONS";
254 		case S_SVRPLAYING: return "S_SVRPLAYING";
255 		case S_CLICONNECTING: return "S_CLICONNECTING";
256 		case S_CLILOBBY: return "S_CLILOBBY";
257 		case S_CLIWEAPONS: return "S_CLIWEAPONS";
258 		case S_CLIPLAYING: return "S_CLIPLAYING";
259 	}
260 	return "INVALID GAMESTATE";
261 }
262 
263 GameState currentGameState();
264 
265 #endif  //  __LIEROX_H__
266