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 // Options
13 // Created 21/7/02
14 // Jason Boettcher
15
16
17 #ifndef __OPTIONS_H__
18 #define __OPTIONS_H__
19
20 #include <map>
21 #include <vector>
22 #include <string>
23 #include <cassert>
24 #include "FeatureList.h"
25
26 // Setup input id's
27 enum {
28 // Movement
29 SIN_UP=0,
30 SIN_DOWN,
31 SIN_LEFT,
32 SIN_RIGHT,
33
34 SIN_SHOOT,
35 SIN_JUMP,
36 SIN_SELWEAP,
37 SIN_ROPE,
38
39 SIN_STRAFE,
40 SIN_DIG,
41
42 SIN_WEAPON1,
43 SIN_WEAPON2,
44 SIN_WEAPON3,
45 SIN_WEAPON4,
46 SIN_WEAPON5,
47
48 __SIN_PLY_BOTTOM
49 };
50
51 // General controls
52 enum {
53 SIN_CHAT = 0,
54 SIN_SCORE,
55 SIN_HEALTH,
56 SIN_SETTINGS,
57 SIN_SCREENSHOTS,
58 SIN_VIEWPORTS,
59 SIN_SWITCHMODE,
60 SIN_TOGGLETOPBAR,
61 SIN_TEAMCHAT,
62 SIN_IRCCHAT,
63 SIN_CONSOLETOGGLE,
64
65 __SIN_GENERAL_BOTTOM
66 };
67
68
69 // Network speed types
70 enum NetworkSpeed {
71 NST_MODEM=0,
72 NST_ISDN,
73 NST_LAN,
74 NST_LOCAL // Hidden speed, only for local games
75 };
76
NetworkSpeedString(NetworkSpeed s)77 inline std::string NetworkSpeedString(NetworkSpeed s) {
78 switch(s) {
79 case NST_MODEM: return "Modem";
80 case NST_ISDN: return "ISDN";
81 case NST_LAN: return "DSL/LAN";
82 case NST_LOCAL: return "local";
83 }
84 return "INVALID SPEED";
85 }
86
87
88 // Screenshot formats
89 enum {
90 FMT_BMP,
91 FMT_PNG,
92 FMT_JPG,
93 FMT_GIF
94 };
95
96 // input controls structure (for local players)
97 template<short count>
98 class controls_t {
99 private:
100 std::string ctrl[count];
101 public:
102 std::string& operator[] (const short i) { assert(i >= 0 && (unsigned)i < count ); return ctrl[i]; }
103 const std::string& operator[] (const short i) const { assert(i >= 0 && (unsigned)i < count ); return ctrl[i]; }
104
ControlCount()105 short ControlCount() const { return count; }
106 // TODO: add specific functions
107 };
108
109 typedef controls_t<__SIN_PLY_BOTTOM> PlyControls;
110 typedef controls_t<__SIN_GENERAL_BOTTOM> GeneralControls;
111
112
113 // Network strings
114 class NetworkTexts {
115 public:
116
117 static bool Init();
118 bool LoadFromDisc();
119
120 std::string sHasLeft ;
121 std::string sHasConnected ;
122 std::string sHasTimedOut ;
123
124 std::string sHasBeenKicked ;
125 std::string sHasBeenKickedReason ;
126 std::string sHasBeenBanned ;
127 std::string sHasBeenBannedReason ;
128 std::string sHasBeenMuted ;
129 std::string sHasBeenUnmuted ;
130 std::string sIsSpectating;
131 std::string sIsPlaying;
132
133 std::string sKickedYou ;
134 std::string sKickedYouReason ;
135 std::string sBannedYou ;
136 std::string sBannedYouReason ;
137 std::string sYouTimed ;
138 std::string sYouQuit ;
139
140 std::string sKilled ;
141 std::string sCommitedSuicide ;
142 std::string sFirstBlood ;
143 std::string sTeamkill ;
144 std::string sHasScored;
145 std::string sKilledAFK ;
146
147 std::string sSeekerMessage;
148 std::string sHiderMessage;
149 std::string sCaughtMessage;
150 std::string sHiderVisible;
151 std::string sSeekerVisible;
152 std::string sVisibleMessage;
153 std::string sYouAreHidden;
154 std::string sHiddenMessage;
155
156 std::string sPlayerOut ;
157 std::string sPlayerHasWon ;
158 std::string sTeamOut ;
159 std::string sTeamHasWon ;
160 std::string sTimeLimit ;
161
162 std::string sWormIsIt ;
163
164 std::string sSpree1 ;
165 std::string sSpree2 ;
166 std::string sSpree3 ;
167 std::string sSpree4 ;
168 std::string sSpree5 ;
169
170 std::string sDSpree1 ;
171 std::string sDSpree2 ;
172 std::string sDSpree3 ;
173 std::string sDSpree4 ;
174 std::string sDSpree5 ;
175
176 std::string sServerFull ;
177 std::string sNoEmptySlots ;
178 std::string sWrongProtocol ;
179 std::string sBadVerification ;
180 std::string sNoIpVerification ;
181 std::string sGameInProgress ;
182 std::string sYouAreBanned ;
183 std::string sBotsNotAllowed ;
184 std::string sWantsJoin ;
185
186 std::string sKnownAs;
187 };
188
189
190 class CGameMode;
191 extern const std::string DefaultCfgFilename;
192
193 // Options structure
194 struct GameOptions {
195 GameOptions();
196
197 static bool Init();
198 bool LoadFromDisc(const std::string& cfgfilename);
LoadFromDiscGameOptions199 bool LoadFromDisc() { return LoadFromDisc(cfgFilename); }
200 void SaveToDisc(const std::string& cfgfilename);
SaveToDiscGameOptions201 void SaveToDisc() { SaveToDisc(cfgFilename); }
202 void SaveSectionToDisc(const std::string& section, const std::string& filename);
203
204 // Video
205 bool bFullscreen;
206 bool bShowFPS;
207 bool bOpenGL;
208 std::string sResolution;
209 std::string sVideoPostProcessor;
210 int iColourDepth;
211
212 // Network
213 int iNetworkPort;
214 int iNetworkSpeed;
215 int iMaxUploadBandwidth;
216 bool bCheckBandwidthSanity;
217 bool bUseIpToCountry;
218 std::string sHttpProxy;
219 bool bAutoSetupHttpProxy;
220
221 bool bRegServer;
222 std::string sServerName;
223 std::string sWelcomeMessage;
224 std::string sServerPassword; // Password to authenticate (login chatcmd) as admin; this is not for server-login!
225 bool bAllowWantsJoinMsg;
226 bool bWantsJoinBanned;
227 bool bAllowRemoteBots;
228 bool bForceCompatibleConnect;
229 std::string sForceMinVersion;
230 //Chat message check options
231 int iMaxChatMessageLength;
232 //Server chat logging
233 bool bLogServerChatToMainlog;
234
235 // IRC chat
236 bool bEnableChat;
237 bool bEnableMiniChat; // Mini chat window in Net servers list
238
239 // Audio
240 bool bSoundOn;
241 int iSoundVolume;
242 int iMusicVolume;
243 bool bMusicOn;
244
245 // Game state
246 std::string sNewestVersion;
247 bool bFirstHosting;
248
249 // Controls
250 std::vector<PlyControls> sPlayerControls; // sPC[playernr][controlnr]
251 GeneralControls sGeneralControls;
252
253 // Game
254 int iBloodAmount;
255 bool bShadows;
256 bool bParticles;
257 bool bOldSkoolRope;
258 bool bShowHealth;
259 bool bShowNetRates;
260 bool bShowProjectileUsage;
261 bool bColorizeNicks;
262 bool bAutoTyping;
263 bool bAntiAliasing;
264 bool bMouseAiming;
265 int iMouseSensity;
266 bool bAntilagMovementPrediction;
267 std::string sLastSelectedPlayer;
268 std::string sLastSelectedPlayer2;
269 std::string sTheme;
270 bool bTopBarVisible;
271 bool bDamagePopups;
272 bool bColorizeDamageByWorm;
273 float fCrosshairDistance;
274 float fAimAcceleration;
275 float fAimMaxSpeed;
276 float fAimFriction;
277 bool bAimLikeLX56;
278 bool bTouchscreenTapCycleWeaponsBackwards;
279 int iTouchscreenSensitivity;
280
281 //Killing/dying spree thresholds
282 int iSpreeThreshold1;
283 int iSpreeThreshold2;
284 int iSpreeThreshold3;
285 int iSpreeThreshold4;
286 int iSpreeThreshold5;
287
288 int iDyingSpreeThreshold1;
289 int iDyingSpreeThreshold2;
290 int iDyingSpreeThreshold3;
291 int iDyingSpreeThreshold4;
292 int iDyingSpreeThreshold5;
293
294 // Advanced
295 int nMaxFPS;
296 int iJpegQuality;
297 int iMaxCachedEntries; // Amount of entries to cache, including maps, mods, images and sounds.
298 bool bMatchLogging; // Save screenshot of every game final score
299 bool bRecoverAfterCrash; // If we should try to recover after segfault etc, or generate coredump and quit
300 bool bCheckForUpdates; // Check for new development version on sourceforge.net
301
302 // Misc.
303 bool bLogConvos;
304 bool bShowPing;
305 int iScreenshotFormat;
306 std::string sDedicatedScript;
307 std::string sDedicatedScriptArgs;
308 int iVerbosity; // the higher the number, the higher the amount of debug messages; 0 is default, at 10 it shows backtraces for all warnings
309 bool bLogTimestamps; // Show timestamps in console output
310 bool bAdvancedLobby; // Show advanced game info in join lobby
311 bool bShowCountryFlags;
312 int iRandomTeamForNewWorm; // server will randomly choose a team between 0-iRandomTeamForNewWorm
313 std::string cfgFilename;
314 bool doProjectileSimulationInDedicated;
315 bool bCheckMaxWpnTimeInInstantStart; //Enforce max weapon selection time when instant start is enabled
316
317 // Widget states
318 int iInternetList[7];
319 int iLANList[6];
320 int iFavouritesList[6];
321 bool iGameInfoGroupsShown[GIG_Size];
322 int iInternetSortColumn;
323 int iLANSortColumn;
324 int iFavouritesSortColumn;
325 int iAdvancedLevelLimit;
326
327 // Last used game details - used as game lobby structure in client
328 // Put everything that impacts gameplay here, both server and client-sided
329 class GameInfo {
330 public:
331 GameInfo();
332
333 int iLives;
334 int iKillLimit;
335 float fTimeLimit; // Time limit in minutes
336 int iTagLimit;
337 int iLoadingTime;
338 bool bBonusesOn;
339 bool bShowBonusName;
340 int iMaxPlayers;
341 std::string sMapFile;
342 std::string sMapName; // Decoded map name from map file
343 CGameMode* gameMode;
344 int iGeneralGameType;
345 std::string sGameMode; // Game mode name from server (only for client)
346 std::string sModDir;
347 std::string sModName; // Decoded mod name from script.lgs
348 float fBonusFreq;
349 float fBonusLife;
350 float fRespawnTime;
351 bool bRespawnGroupTeams; // respawn all team in single spot
352 bool bEmptyWeaponsOnRespawn; // When worm respawns it should wait until all weapons are reloaded
353 float fBonusHealthToWeaponChance; // if 0.0f only health will be generated, if 1.0f - only weapons
354 bool bForceRandomWeapons; // only for server; implies bServerChoosesWeapons=true
355 bool bSameWeaponsAsHostWorm; // implies bServerChoosesWeapons=true
356 bool bAllowConnectDuringGame; // >=Beta8
357 bool bAllowStrafing;
358 bool bAllowNickChange;
359 bool bServerSideHealth;
360 int iWeaponSelectionMaxTime; // Auto-kick worms who select their weapons too long
361
362 FeatureSettings features;
363 } tGameInfo;
364
365 // not specified options found in options-file
366 std::map< std::string, std::string > additionalOptions;
367 };
368
369
370 // Option Routines
371 void ShutdownOptions();
372
373
374 extern GameOptions *tLXOptions;
375 extern NetworkTexts *networkTexts;
376
377
378 #endif // __OPTIONS_H__
379