DEADSOFTWARE

add spawn invulnerability; add option to disable all keys in DM
[d2df-sdl.git] / src / game / g_options.pas
1 (* Copyright (C) Doom 2D: Forever Developers
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, version 3 of the License ONLY.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14 *)
15 {$INCLUDE ../shared/a_modes.inc}
16 unit g_options;
18 interface
20 uses
21 g_language, g_weapons, utils;
23 function GenPlayerName (n: Integer): String;
25 procedure g_Options_SetDefault;
26 procedure g_Options_SetDefaultVideo;
27 procedure g_Options_Read(FileName: String);
28 procedure g_Options_Write(FileName: String);
29 procedure g_Options_Write_Gameplay_Custom(FileName: String);
30 procedure g_Options_Write_Gameplay_Net(FileName: String);
31 procedure g_Options_Write_Net_Server(FileName: String);
32 procedure g_Options_Write_Net_Client(FileName: String);
33 procedure g_Options_Commands (p: SSArray);
35 const DF_Default_Megawad_Start = 'megawads/DOOM2D.WAD:\MAP01';
37 var
38 gScreenWidth: Word;
39 gScreenHeight: Word;
40 gBPP: Integer;
41 gFreq: Byte;
42 gFullscreen: Boolean;
43 gWinMaximized: Boolean;
44 gVSync: Boolean;
45 glLegacyNPOT: Boolean;
46 gTextureFilter: Boolean;
47 gNoSound: Boolean;
48 gSoundLevel: Integer;
49 gMusicLevel: Integer;
50 gMaxSimSounds: Integer;
51 gMuteWhenInactive: Boolean;
52 gAdvCorpses: Boolean;
53 gAdvBlood: Boolean;
54 gAdvGibs: Boolean;
55 gGibsCount: Integer;
56 gBloodCount: Integer;
57 gFlash: Integer;
58 gDrawBackGround: Boolean;
59 gShowMessages: Boolean;
60 gRevertPlayers: Boolean;
61 gLanguage: String;
62 gAskLanguage: Boolean;
63 gSaveStats: Boolean = False;
64 gScreenshotStats: Boolean = False;
65 gcMap: String;
66 gcGameMode: String;
67 gcTimeLimit: Word;
68 gcGoalLimit: Word;
69 gcMaxLives: Byte;
70 gcPlayers: Byte;
71 gcTeamDamage: Boolean;
72 gcAllowExit: Boolean;
73 gcWeaponStay: Boolean;
74 gcMonsters: Boolean;
75 gcBotsVS: String;
76 gcDeathmatchKeys: Boolean = True;
77 gcSpawnInvul: Integer = 0;
78 gnMap: String;
79 gnGameMode: String;
80 gnTimeLimit: Word;
81 gnGoalLimit: Word;
82 gnMaxLives: Byte;
83 gnPlayers: Byte;
84 gnTeamDamage: Boolean;
85 gnAllowExit: Boolean;
86 gnWeaponStay: Boolean;
87 gnMonsters: Boolean;
88 gnBotsVS: String;
89 gnDeathmatchKeys: Boolean = True;
90 gnSpawnInvul: Integer = 0;
91 gsSDLSampleRate: Integer;
92 gsSDLBufferSize: Integer;
93 gDefaultMegawadStart: AnsiString;
94 gBerserkAutoswitch: Boolean;
95 glNPOTOverride: Boolean = false;
97 implementation
99 uses
100 {$INCLUDE ../nogl/noGLuses.inc}
101 {$IFDEF USE_SDL2}
102 SDL2,
103 {$ENDIF}
104 e_log, e_input, g_console, g_window, g_sound, g_gfx, g_player, Math,
105 g_map, g_net, g_netmaster, SysUtils, CONFIG, g_game, g_main, e_texture,
106 g_items, wadreader, e_graphics, g_touch, envvars, g_system;
108 var
109 machine: Integer;
111 function GenPlayerName (n: Integer): String;
112 begin
113 ASSERT(n >= 1);
114 Result := GetUserName;
115 if Result = '' then
116 Result := 'Player' + IntToStr(machine MOD 10000);
117 if n = 1 then
118 Result := Copy(Result, 1, 12) + ' '
119 else
120 Result := Copy(Result, 1, 10) + ' ' + IntToStr(n)
121 end;
123 {$IFDEF USE_SDL2}
124 procedure g_Options_SetDefaultVideo;
125 var display: TSDL_DisplayMode;
126 {$IFNDEF ANDROID}
127 var target, closest: TSDL_DisplayMode; percentage: Integer;
128 {$ENDIF}
129 begin
130 (* Display 0 = Primary display *)
131 gScreenWidth := 640;
132 gScreenHeight := 480;
133 //gBPP := SDL_BITSPERPIXEL(dispaly.format);
134 gBPP := 32;
135 {$IFDEF ANDROID}
136 gFullScreen := True; (* rotation not allowed? *)
137 {$ELSE}
138 gFullScreen := False;
139 {$ENDIF}
140 if SDL_GetDesktopDisplayMode(0, @display) = 0 then
141 begin
142 {$IFDEF ANDROID}
143 gScreenWidth := display.w;
144 gScreenHeight := display.h;
145 {$ELSE}
146 (* Window must be smaller than display *)
147 closest.w := display.w;
148 closest.h := display.h;
149 percentage := 75;
150 while (display.w - closest.w < 48) or (display.h - closest.h < 48) do
151 begin
152 if percentage < 25 then
153 begin
154 closest.w := display.w * 75 div 100;
155 closest.h := display.h * 75 div 100;
156 break;
157 end;
158 target.w := display.w * percentage div 100;
159 target.h := display.h * percentage div 100;
160 target.format := 0; (* didn't care *)
161 target.refresh_rate := 0; (* didn't care *)
162 target.driverdata := nil; (* init *)
163 SDL_GetClosestDisplayMode(0, @target, @closest);
164 Dec(percentage);
165 end;
166 gScreenWidth := closest.w;
167 gScreenHeight := closest.h;
168 //gBPP := SDL_BITSPERPIXEL(closest.format); (* Resolution list didn't work for some reason *)
169 {$ENDIF}
170 end
171 else
172 begin
173 e_LogWritefln('SDL: Failed to get desktop display mode: %s', [SDL_GetError])
174 end;
175 (* Must be positioned on primary display *)
176 gWinMaximized := False;
177 gVSync := True;
178 gTextureFilter := True;
179 glLegacyNPOT := False;
180 gRC_Width := gScreenWidth;
181 gRC_Height := gScreenHeight;
182 gRC_FullScreen := gFullScreen;
183 gRC_Maximized := gWinMaximized;
184 e_LogWriteLn('g_Options_SetDefaultVideo: w = ' + IntToStr(gScreenWidth) + ' h = ' + IntToStr(gScreenHeight));
185 g_Console_ResetBinds;
186 end;
187 {$ELSE}
188 procedure g_Options_SetDefaultVideo;
189 begin
190 gScreenWidth := 640;
191 gScreenHeight := 480;
192 gBPP := 32;
193 gFullScreen := False;
194 gWinMaximized := False;
195 gVSync := True;
196 gTextureFilter := True;
197 glLegacyNPOT := False;
198 gRC_Width := gScreenWidth;
199 gRC_Height := gScreenHeight;
200 gRC_FullScreen := gFullScreen;
201 gRC_Maximized := gWinMaximized;
202 e_LogWriteLn('g_Options_SetDefaultVideo: w = ' + IntToStr(gScreenWidth) + ' h = ' + IntToStr(gScreenHeight));
203 g_Console_ResetBinds;
204 end;
205 {$ENDIF}
207 procedure g_Options_SetDefault();
208 var
209 i: Integer;
210 begin
211 (* section Sound *)
212 gNoSound := False;
213 gSoundLevel := 75;
214 gMusicLevel := 65;
215 gMaxSimSounds := 8;
216 gMuteWhenInactive := False;
217 gAnnouncer := ANNOUNCE_MEPLUS;
218 gSoundEffectsDF := True;
219 gUseChatSounds := True;
220 gsSDLSampleRate := 44100;
221 gsSDLBufferSize := 2048;
223 g_Sound_SetupAllVolumes(gSoundLevel, gMusicLevel);
225 with gPlayer1Settings do
226 begin
227 Name := GenPlayerName(1);
228 Model := STD_PLAYER_MODEL;
229 Color.R := PLAYER1_DEF_COLOR.R;
230 Color.G := PLAYER1_DEF_COLOR.G;
231 Color.B := PLAYER1_DEF_COLOR.B;
232 Team := TEAM_RED;
233 end;
235 with gPlayer2Settings do
236 begin
237 Name := GenPlayerName(2);
238 Model := STD_PLAYER_MODEL;
239 Color.R := PLAYER2_DEF_COLOR.R;
240 Color.G := PLAYER2_DEF_COLOR.G;
241 Color.B := PLAYER2_DEF_COLOR.B;
242 Team := TEAM_BLUE;
243 end;
245 (* section Joysticks *)
246 for i := 0 to e_MaxJoys - 1 do
247 begin
248 e_JoystickDeadzones[i] := 8192
249 end;
251 (* section Game *)
252 g_GFX_SetMax(2000);
253 g_Shells_SetMax(300);
254 g_Gibs_SetMax(150);
255 g_Corpses_SetMax(20);
256 gGibsCount := 32;
257 ITEM_RESPAWNTIME := 60 * 36;
258 gBloodCount := 4;
259 gAdvBlood := True;
260 gAdvCorpses := True;
261 gAdvGibs := True;
262 gFlash := 1;
263 gDrawBackGround := True;
264 gShowMessages := True;
265 gRevertPlayers := False;
266 gChatBubble := 4;
267 wadoptDebug := False;
268 wadoptFast := False;
269 e_FastScreenshots := True;
270 gDefaultMegawadStart := DF_Default_Megawad_Start;
271 gBerserkAutoswitch := True;
272 g_dbg_scale := 1.0;
273 gSaveStats := False;
275 gAskLanguage := True;
276 gLanguage := LANGUAGE_ENGLISH;
278 (* section GameplayCustom *)
279 gcMap := '';
280 gcGameMode := _lc[I_MENU_GAME_TYPE_DM];
281 gcTimeLimit := 0;
282 gcGoalLimit := 0;
283 gcMaxLives := 0;
284 gcPlayers := 1;
285 gcTeamDamage := False;
286 gcAllowExit := True;
287 gcWeaponStay := False;
288 gcMonsters := False;
289 gcBotsVS := 'Everybody';
290 gcDeathmatchKeys := True;
291 gcSpawnInvul := 0;
293 (* section GameplayNetwork *)
294 gnMap := '';
295 gnGameMode := _lc[I_MENU_GAME_TYPE_DM];
296 gnTimeLimit := 0;
297 gnGoalLimit := 0;
298 gnMaxLives := 0;
299 gnPlayers := 1;
300 gnTeamDamage := False;
301 gnAllowExit := True;
302 gnWeaponStay := False;
303 gnMonsters := False;
304 gnBotsVS := 'Everybody';
305 gnDeathmatchKeys := True;
306 gnSpawnInvul := 0;
308 (* section MasterServer *)
309 NetSlistIP := 'mpms.doom2d.org';
310 NetSlistPort := 25665;
311 g_Net_Slist_Set(NetSlistIP, NetSlistPort, NetSlistList);
313 (* section Server *)
314 NetServerName := 'Unnamed Server';
315 NetPassword := '';
316 NetPort := 25666;
317 NetMaxClients := 16;
318 NetAllowRCON := False;
319 NetRCONPassword := 'default';
320 NetUseMaster := True;
321 NetUpdateRate := 0;
322 NetRelupdRate := 18;
323 NetMasterRate := 60000;
324 NetForwardPorts := False;
326 (* section Client *)
327 NetInterpLevel := 2;
328 NetForcePlayerUpdate := False;
329 NetPredictSelf := True;
330 NetClientIP := '127.0.0.1';
331 NetClientPort := NetPort;
332 end;
334 procedure g_Options_Read(FileName: String);
335 var
336 config: TConfig;
337 section: String;
339 procedure ReadInteger (VAR v: Integer; param: String; minv: Integer = Low(Integer); maxv: Integer = High(Integer));
340 begin
341 v := Max(Min(config.ReadInt(section, param, v), maxv), minv)
342 end;
344 procedure ReadInteger (VAR v: LongWord; param: String; minv: LongWord = Low(LongWord); maxv: LongWord = High(LongWord)); overload;
345 begin
346 v := Max(Min(config.ReadInt(section, param, v), maxv), minv)
347 end;
349 procedure ReadInteger (VAR v: Word; param: String; minv: Word = Low(Word); maxv: Word = High(Word)); overload;
350 begin
351 v := Max(Min(config.ReadInt(section, param, v), maxv), minv)
352 end;
354 procedure ReadInteger (VAR v: Byte; param: String; minv: Byte = Low(Byte); maxv: Byte = High(Byte)); overload;
355 begin
356 v := Max(Min(config.ReadInt(section, param, v), maxv), minv)
357 end;
359 procedure ReadBoolean (VAR v: Boolean; param: String);
360 begin
361 v := config.ReadBool(section, param, v)
362 end;
364 procedure ReadString (VAR v: String; param: String);
365 begin
366 v := config.ReadStr(section, param, v)
367 end;
369 begin
370 gAskLanguage := True;
371 e_WriteLog('Reading config', TMsgType.Notify);
372 g_Options_SetDefault;
374 if FileExists(FileName) = False then
375 begin
376 e_WriteLog('Config file '+FileName+' not found', TMsgType.Warning);
377 g_Options_SetDefaultVideo;
378 Exit
379 end;
381 config := TConfig.CreateFile(FileName);
383 section := 'Player1';
384 with gPlayer1Settings do
385 begin
386 ReadString(Name, 'name');
387 ReadString(Model, 'model');
388 ReadInteger(Color.R, 'red', 0, 255);
389 ReadInteger(Color.G, 'green', 0, 255);
390 ReadInteger(Color.B, 'blue', 0, 255);
391 ReadInteger(Team, 'team');
392 if (Team < TEAM_RED) or (Team > TEAM_BLUE) then
393 Team := TEAM_RED;
394 end;
396 section := 'Player2';
397 with gPlayer2Settings do
398 begin
399 ReadString(Name, 'name');
400 ReadString(Model, 'model');
401 ReadInteger(Color.R, 'red', 0, 255);
402 ReadInteger(Color.G, 'green', 0, 255);
403 ReadInteger(Color.B, 'blue', 0, 255);
404 ReadInteger(Team, 'team');
405 if (Team < TEAM_RED) or (Team > TEAM_BLUE) then
406 Team := TEAM_RED;
407 end;
409 section := 'GameplayCustom';
410 ReadString(gcMap, 'Map');
411 ReadString(gcGameMode, 'GameMode');
412 ReadInteger(gcTimeLimit, 'TimeLimit', 0, 65535);
413 ReadInteger(gcGoalLimit, 'GoalLimit', 0, 65535);
414 ReadInteger(gcMaxLives, 'MaxLives', 0, 255);
415 ReadInteger(gcPlayers, 'Players', 0, 2);
416 ReadBoolean(gcTeamDamage, 'TeamDamage');
417 ReadBoolean(gcAllowExit, 'AllowExit');
418 ReadBoolean(gcWeaponStay, 'WeaponStay');
419 ReadBoolean(gcMonsters, 'Monsters');
420 ReadString(gcBotsVS, 'BotsVS');
421 ReadBoolean(gcDeathmatchKeys, 'DeathmatchKeys');
422 ReadInteger(gcSpawnInvul, 'SpawnInvul');
424 with gGameSettings do
425 begin
426 GameMode := g_Game_TextToMode(gcGameMode);
427 if GameMode = GM_NONE then
428 GameMode := GM_DM;
429 if GameMode = GM_SINGLE then
430 GameMode := GM_COOP;
431 TimeLimit := gcTimeLimit;
432 GoalLimit := gcGoalLimit;
433 MaxLives := gcMaxLives;
435 Options := 0;
436 if gcTeamDamage then
437 Options := Options or GAME_OPTION_TEAMDAMAGE;
438 if gcAllowExit then
439 Options := Options or GAME_OPTION_ALLOWEXIT;
440 if gcWeaponStay then
441 Options := Options or GAME_OPTION_WEAPONSTAY;
442 if gcMonsters then
443 Options := Options or GAME_OPTION_MONSTERS;
444 if gcBotsVS = 'Everybody' then
445 Options := Options or GAME_OPTION_BOTVSPLAYER or GAME_OPTION_BOTVSMONSTER;
446 if gcBotsVS = 'Players' then
447 Options := Options or GAME_OPTION_BOTVSPLAYER;
448 if gcBotsVS = 'Monsters' then
449 Options := Options or GAME_OPTION_BOTVSMONSTER;
450 if gcDeathmatchKeys then
451 Options := Options or GAME_OPTION_DMKEYS;
452 end;
454 section := 'GameplayNetwork';
455 ReadString(gnMap, 'Map');
456 ReadString(gnGameMode, 'GameMode');
457 ReadInteger(gnTimeLimit, 'TimeLimit', 0, 65535);
458 ReadInteger(gnGoalLimit, 'GoalLimit', 0, 65535);
459 ReadInteger(gnMaxLives, 'MaxLives', 0, 255);
460 ReadInteger(gnPlayers, 'Players', 0, 2);
461 ReadBoolean(gnTeamDamage, 'TeamDamage');
462 ReadBoolean(gnAllowExit, 'AllowExit');
463 ReadBoolean(gnWeaponStay, 'WeaponStay');
464 ReadBoolean(gnMonsters, 'Monsters');
465 ReadString(gnBotsVS, 'BotsVS');
466 ReadBoolean(gnDeathmatchKeys, 'DeathmatchKeys');
467 ReadInteger(gnSpawnInvul, 'SpawnInvul');
469 section := 'MasterServer';
470 ReadString(NetSlistIP, 'IP');
471 ReadInteger(NetSlistPort, 'Port', 0, 65535);
472 ReadString(NetSlistList, 'List');
473 g_Net_Slist_Set(NetSlistIP, NetSlistPort, NetSlistList);
475 section := 'Server';
476 ReadString(NetServerName, 'Name');
477 ReadString(NetPassword, 'Password');
478 ReadInteger(NetPort, 'Port', 0, 65535);
479 ReadInteger(NetMaxClients, 'MaxClients', 0, NET_MAXCLIENTS);
480 ReadBoolean(NetAllowRCON, 'RCON');
481 ReadString(NetRCONPassword, 'RCONPassword');
482 ReadBoolean(NetUseMaster, 'SyncWithMaster');
483 ReadInteger(NetUpdateRate, 'UpdateInterval', 0);
484 ReadInteger(NetRelupdRate, 'ReliableUpdateInterval', 0);
485 ReadInteger(NetMasterRate, 'MasterSyncInterval', 1);
486 ReadBoolean(NetForwardPorts, 'ForwardPorts');
488 section := 'Client';
489 ReadInteger(NetInterpLevel, 'InterpolationSteps', 0);
490 ReadBoolean(NetForcePlayerUpdate, 'ForcePlayerUpdate');
491 ReadBoolean(NetPredictSelf, 'PredictSelf');
492 ReadString(NetClientIP, 'LastIP');
493 ReadInteger(NetClientPort, 'LastPort', 0, 65535);
495 config.Free();
497 //if gTextureFilter then TEXTUREFILTER := GL_LINEAR else TEXTUREFILTER := GL_NEAREST;
498 end;
500 procedure g_Options_Write(FileName: String);
501 var config: TConfig;
502 begin
503 e_WriteLog('Writing config', TMsgType.Notify);
505 config := TConfig.CreateFile(FileName);
507 with config, gPlayer1Settings do
508 begin
509 WriteStr('Player1', 'Name', Name);
510 WriteStr('Player1', 'model', Model);
511 WriteInt('Player1', 'red', Color.R);
512 WriteInt('Player1', 'green', Color.G);
513 WriteInt('Player1', 'blue', Color.B);
514 WriteInt('Player1', 'team', Team);
515 end;
517 with config, gPlayer2Settings do
518 begin
519 WriteStr('Player2', 'Name', Name);
520 WriteStr('Player2', 'model', Model);
521 WriteInt('Player2', 'red', Color.R);
522 WriteInt('Player2', 'green', Color.G);
523 WriteInt('Player2', 'blue', Color.B);
524 WriteInt('Player2', 'team', Team);
525 end;
527 config.WriteStr ('GameplayCustom', 'Map', gcMap);
528 config.WriteStr ('GameplayCustom', 'GameMode', gcGameMode);
529 config.WriteInt ('GameplayCustom', 'TimeLimit', gcTimeLimit);
530 config.WriteInt ('GameplayCustom', 'GoalLimit', gcGoalLimit);
531 config.WriteInt ('GameplayCustom', 'MaxLives', gcMaxLives);
532 config.WriteInt ('GameplayCustom', 'Players', gcPlayers);
533 config.WriteBool('GameplayCustom', 'TeamDamage', gcTeamDamage);
534 config.WriteBool('GameplayCustom', 'AllowExit', gcAllowExit);
535 config.WriteBool('GameplayCustom', 'WeaponStay', gcWeaponStay);
536 config.WriteBool('GameplayCustom', 'Monsters', gcMonsters);
537 config.WriteStr ('GameplayCustom', 'BotsVS', gcBotsVS);
538 config.WriteBool('GameplayCustom', 'DeathmatchKeys', gcDeathmatchKeys);
539 config.WriteInt ('GameplayCustom', 'SpawnInvul', gcSpawnInvul);
541 config.WriteStr ('GameplayNetwork', 'Map', gnMap);
542 config.WriteStr ('GameplayNetwork', 'GameMode', gnGameMode);
543 config.WriteInt ('GameplayNetwork', 'TimeLimit', gnTimeLimit);
544 config.WriteInt ('GameplayNetwork', 'GoalLimit', gnGoalLimit);
545 config.WriteInt ('GameplayNetwork', 'MaxLives', gnMaxLives);
546 config.WriteInt ('GameplayNetwork', 'Players', gnPlayers);
547 config.WriteBool('GameplayNetwork', 'TeamDamage', gnTeamDamage);
548 config.WriteBool('GameplayNetwork', 'AllowExit', gnAllowExit);
549 config.WriteBool('GameplayNetwork', 'WeaponStay', gnWeaponStay);
550 config.WriteBool('GameplayNetwork', 'Monsters', gnMonsters);
551 config.WriteStr ('GameplayNetwork', 'BotsVS', gnBotsVS);
552 config.WriteBool('GameplayNetwork', 'DeathmatchKeys', gnDeathmatchKeys);
553 config.WriteInt ('GameplayNetwork', 'SpawnInvul', gnSpawnInvul);
555 config.WriteStr('MasterServer', 'IP', NetSlistIP);
556 config.WriteInt('MasterServer', 'Port', NetSlistPort);
557 config.WriteStr('MasterServer', 'List', NetSlistList);
559 config.WriteStr ('Server', 'Name', NetServerName);
560 config.WriteStr ('Server', 'Password', NetPassword);
561 config.WriteInt ('Server', 'Port', NetPort);
562 config.WriteInt ('Server', 'MaxClients', NetMaxClients);
563 config.WriteBool('Server', 'RCON', NetAllowRCON);
564 config.WriteStr ('Server', 'RCONPassword', NetRCONPassword);
565 config.WriteBool('Server', 'SyncWithMaster', NetUseMaster);
566 config.WriteBool('Server', 'ForwardPorts', NetForwardPorts);
567 config.WriteInt ('Server', 'UpdateInterval', NetUpdateRate);
568 config.WriteInt ('Server', 'ReliableUpdateInterval', NetRelupdRate);
569 config.WriteInt ('Server', 'MasterSyncInterval', NetMasterRate);
571 config.WriteInt ('Client', 'InterpolationSteps', NetInterpLevel);
572 config.WriteBool ('Client', 'ForcePlayerUpdate', NetForcePlayerUpdate);
573 config.WriteBool ('Client', 'PredictSelf', NetPredictSelf);
574 config.WriteStr ('Client', 'LastIP', NetClientIP);
575 config.WriteInt ('Client', 'LastPort', NetClientPort);
577 config.SaveFile(FileName);
578 config.Free();
579 end;
581 procedure g_Options_Write_Gameplay_Custom(FileName: String);
582 var
583 config: TConfig;
584 begin
585 e_WriteLog('Writing custom gameplay config', TMsgType.Notify);
587 config := TConfig.CreateFile(FileName);
589 config.WriteStr ('GameplayCustom', 'Map', gcMap);
590 config.WriteStr ('GameplayCustom', 'GameMode', gcGameMode);
591 config.WriteInt ('GameplayCustom', 'TimeLimit', gcTimeLimit);
592 config.WriteInt ('GameplayCustom', 'GoalLimit', gcGoalLimit);
593 config.WriteInt ('GameplayCustom', 'MaxLives', gcMaxLives);
594 config.WriteInt ('GameplayCustom', 'Players', gcPlayers);
595 config.WriteBool('GameplayCustom', 'TeamDamage', gcTeamDamage);
596 config.WriteBool('GameplayCustom', 'AllowExit', gcAllowExit);
597 config.WriteBool('GameplayCustom', 'WeaponStay', gcWeaponStay);
598 config.WriteBool('GameplayCustom', 'Monsters', gcMonsters);
599 config.WriteStr ('GameplayCustom', 'BotsVS', gcBotsVS);
600 config.WriteBool('GameplayCustom', 'DeathmatchKeys', gcDeathmatchKeys);
601 config.WriteInt ('GameplayCustom', 'SpawnInvul', gcSpawnInvul);
603 config.SaveFile(FileName);
604 config.Free();
605 end;
607 procedure g_Options_Write_Gameplay_Net(FileName: String);
608 var
609 config: TConfig;
610 begin
611 e_WriteLog('Writing network gameplay config', TMsgType.Notify);
613 config := TConfig.CreateFile(FileName);
615 config.WriteStr ('GameplayNetwork', 'Map', gnMap);
616 config.WriteStr ('GameplayNetwork', 'GameMode', gnGameMode);
617 config.WriteInt ('GameplayNetwork', 'TimeLimit', gnTimeLimit);
618 config.WriteInt ('GameplayNetwork', 'GoalLimit', gnGoalLimit);
619 config.WriteInt ('GameplayNetwork', 'MaxLives', gnMaxLives);
620 config.WriteInt ('GameplayNetwork', 'Players', gnPlayers);
621 config.WriteBool('GameplayNetwork', 'TeamDamage', gnTeamDamage);
622 config.WriteBool('GameplayNetwork', 'AllowExit', gnAllowExit);
623 config.WriteBool('GameplayNetwork', 'WeaponStay', gnWeaponStay);
624 config.WriteBool('GameplayNetwork', 'Monsters', gnMonsters);
625 config.WriteStr ('GameplayNetwork', 'BotsVS', gnBotsVS);
626 config.WriteBool('GameplayNetwork', 'DeathmatchKeys', gnDeathmatchKeys);
627 config.WriteInt ('GameplayNetwork', 'SpawnInvul', gnSpawnInvul);
629 config.SaveFile(FileName);
630 config.Free();
631 end;
633 procedure g_Options_Write_Net_Server(FileName: String);
634 var
635 config: TConfig;
636 begin
637 e_WriteLog('Writing server config', TMsgType.Notify);
639 config := TConfig.CreateFile(FileName);
641 config.WriteStr ('Server', 'Name', NetServerName);
642 config.WriteStr ('Server', 'Password', NetPassword);
643 config.WriteInt ('Server', 'Port', NetPort);
644 config.WriteInt ('Server', 'MaxClients', NetMaxClients);
645 config.WriteBool('Server', 'SyncWithMaster', NetUseMaster);
646 config.WriteBool('Server', 'ForwardPorts', NetForwardPorts);
648 config.SaveFile(FileName);
649 config.Free();
650 end;
652 procedure g_Options_Write_Net_Client(FileName: String);
653 var
654 config: TConfig;
655 begin
656 e_WriteLog('Writing client config', TMsgType.Notify);
658 config := TConfig.CreateFile(FileName);
660 config.WriteStr('Client', 'LastIP', NetClientIP);
661 config.WriteInt('Client', 'LastPort', NetClientPort);
663 config.SaveFile(FileName);
664 config.Free();
665 end;
667 procedure g_Options_Commands (p: SSArray);
668 var cmd: AnsiString; i: Integer;
669 begin
670 cmd := LowerCase(p[0]);
671 case cmd of
672 'r_reset':
673 begin
674 sys_EnableVSync(gVSync);
675 gRC_Width := Max(1, gRC_Width);
676 gRC_Height := Max(1, gRC_Height);
677 gBPP := Max(1, gBPP);
678 if sys_SetDisplayMode(gRC_Width, gRC_Height, gBPP, gRC_FullScreen, gRC_Maximized) = True then
679 e_LogWriteln('resolution changed')
680 else
681 e_LogWriteln('resolution not changed')
682 end;
683 'g_language':
684 begin
685 if Length(p) = 2 then
686 begin
687 gAskLanguage := true;
688 gLanguage := LANGUAGE_ENGLISH;
689 case LowerCase(p[1]) of
690 'english':
691 begin
692 gAskLanguage := false;
693 gLanguage := LANGUAGE_ENGLISH;
694 end;
695 'russian':
696 begin
697 gAskLanguage := false;
698 gLanguage := LANGUAGE_RUSSIAN;
699 end;
700 'ask':
701 begin
702 gAskLanguage := true;
703 gLanguage := LANGUAGE_ENGLISH;
704 end;
705 end;
706 g_Language_Set(gLanguage)
707 end
708 else
709 begin
710 e_LogWritefln('usage: %s <English|Russian|Ask>', [cmd])
711 end
712 end;
713 'g_max_particles':
714 begin
715 if Length(p) = 2 then
716 begin
717 i := Max(0, StrToInt(p[1]));
718 g_GFX_SetMax(i)
719 end
720 else if Length(p) = 1 then
721 begin
722 e_LogWritefln('%s', [g_GFX_GetMax()])
723 end
724 else
725 begin
726 e_LogWritefln('usage: %s <n>', [cmd])
727 end
728 end;
729 'g_max_shells':
730 begin
731 if Length(p) = 2 then
732 begin
733 i := Max(0, StrToInt(p[1]));
734 g_Shells_SetMax(i)
735 end
736 else if Length(p) = 1 then
737 begin
738 e_LogWritefln('%s', [g_Shells_GetMax()])
739 end
740 else
741 begin
742 e_LogWritefln('usage: %s <n>', [cmd])
743 end
744 end;
745 'g_max_gibs':
746 begin
747 if Length(p) = 2 then
748 begin
749 i := Max(0, StrToInt(p[1]));
750 g_Gibs_SetMax(i)
751 end
752 else if Length(p) = 1 then
753 begin
754 e_LogWritefln('%s', [g_Gibs_GetMax()])
755 end
756 else
757 begin
758 e_LogWritefln('usage: %s <n>', [cmd])
759 end
760 end;
761 'g_max_corpses':
762 begin
763 if Length(p) = 2 then
764 begin
765 i := Max(0, StrToInt(p[1]));
766 g_Corpses_SetMax(i)
767 end
768 else if Length(p) = 1 then
769 begin
770 e_LogWritefln('%s', [g_Corpses_GetMax()])
771 end
772 else
773 begin
774 e_LogWritefln('usage: %s <n>', [cmd])
775 end
776 end;
777 'g_item_respawn_time':
778 begin
779 if Length(p) = 2 then
780 ITEM_RESPAWNTIME := Max(0, StrToInt(p[1])) * 36
781 else if Length(p) = 1 then
782 e_LogWritefln('%s', [ITEM_RESPAWNTIME div 36])
783 else
784 e_LogWritefln('usage: %s <n>', [cmd])
785 end;
786 end;
787 end;
789 initialization
790 Randomize;
791 machine := Random(10000);
793 (* Video *)
794 conRegVar('r_width', @gRC_Width, '', '');
795 conRegVar('r_height', @gRC_Height, '', '');
796 conRegVar('r_fullscreen', @gRC_FullScreen, '', '');
797 conRegVar('r_maximized', @gRC_Maximized, '', '');
798 conRegVar('r_bpp', @gBPP, '', '');
799 conRegVar('r_vsync', @gVSync, '', '');
800 conRegVar('r_texfilter', @gTextureFilter, '', '');
801 conRegVar('r_npot', @glNPOTOverride, '', '');
803 (* Sound *)
804 conRegVar('s_nosound', @gNoSound, '', '');
805 conRegVar('s_soundvolume', @gSoundLevel, '', '');
806 conRegVar('s_musicvolume', @gMusicLevel, '', '');
807 conRegVar('s_maxsim', @gMaxSimSounds, '', ''); // e_sound_fmod/sdl?
808 conRegVar('s_muteinactive', @gMuteWhenInactive, '', '');
809 conRegVar('s_announcer', @gAnnouncer, '', '');
810 conRegVar('s_sfx', @gSoundEffectsDF, '', '');
811 conRegVar('s_chatsounds', @gUseChatSounds, '', '');
812 {$IFDEF USE_SDLMIXER}
813 conRegVar('sdl_mixer_samplerate', @gsSDLSampleRate, '', '');
814 conRegVar('sdl_mixer_buffersize', @gsSDLBufferSize, '', '');
815 {$ENDIF}
817 (* Game *)
818 conRegVar('g_gibs_count', @gGibsCount, '', '');
819 conRegVar('g_blood_count', @gBloodCount, '', '');
820 conRegVar('g_adv_blood', @gAdvBlood, '', '');
821 conRegVar('g_adv_corpses', @gAdvCorpses, '', '');
822 conRegVar('g_adv_gibs', @gAdvGibs, '', '');
823 conRegVar('r_flash', @gFlash, '', '');
824 conRegVar('r_background', @gDrawBackGround, '', '');
825 conRegVar('g_show_messages', @gShowMessages, '', '');
826 conRegVar('r_revert_players', @gRevertPlayers, '', '');
827 conRegVar('r_chat_bubble', @gChatBubble, '', '');
828 conRegVar('sfs_debug', @wadoptDebug, '', '');
829 conRegVar('sfs_fastmode', @wadoptFast, '', '');
830 conRegVar('g_fast_screenshots', @e_FastScreenshots, '', '');
831 conRegVar('g_default_megawad', @gDefaultMegawadStart, '', '');
832 conRegVar('g_save_stats', @gSaveStats, '', '');
833 conRegVar('g_screenshot_stats', @gScreenshotStats, '', '');
834 end.