DEADSOFTWARE

nuke g_respawn_items
[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 gBPP: Integer;
39 gFreq: Byte;
40 gFullscreen: Boolean;
41 gWinSizeX, gWinSizeY: Integer;
42 gWinMaximized: Boolean;
43 gVSync: Boolean;
44 glLegacyNPOT: Boolean;
45 glRenderToFBO: Boolean = True;
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 gWinSizeX := 640;
134 gWinSizeY := 480;
135 //gBPP := SDL_BITSPERPIXEL(dispaly.format);
136 gBPP := 32;
137 {$IFDEF ANDROID}
138 gFullScreen := True; (* rotation not allowed? *)
139 {$ELSE}
140 gFullScreen := False;
141 {$ENDIF}
142 if SDL_GetDesktopDisplayMode(0, @display) = 0 then
143 begin
144 {$IFDEF ANDROID}
145 gWinSizeX := display.w;
146 gWinSizeY := display.h;
147 {$ELSE}
148 (* Window must be smaller than display *)
149 closest.w := display.w;
150 closest.h := display.h;
151 percentage := 75;
152 while (display.w - closest.w < 48) or (display.h - closest.h < 48) do
153 begin
154 if percentage < 25 then
155 begin
156 closest.w := display.w * 75 div 100;
157 closest.h := display.h * 75 div 100;
158 break;
159 end;
160 target.w := display.w * percentage div 100;
161 target.h := display.h * percentage div 100;
162 target.format := 0; (* didn't care *)
163 target.refresh_rate := 0; (* didn't care *)
164 target.driverdata := nil; (* init *)
165 SDL_GetClosestDisplayMode(0, @target, @closest);
166 Dec(percentage);
167 end;
168 gWinSizeX := closest.w;
169 gWinSizeY := closest.h;
170 //gBPP := SDL_BITSPERPIXEL(closest.format); (* Resolution list didn't work for some reason *)
171 {$ENDIF}
172 end
173 else
174 begin
175 e_LogWritefln('SDL: Failed to get desktop display mode: %s', [SDL_GetError])
176 end;
177 (* Must be positioned on primary display *)
178 gWinMaximized := False;
179 gVSync := True;
180 gTextureFilter := True;
181 glLegacyNPOT := False;
182 gRC_Width := gWinSizeX;
183 gRC_Height := gWinSizeY;
184 gRC_FullScreen := gFullScreen;
185 gRC_Maximized := gWinMaximized;
186 e_LogWriteLn('g_Options_SetDefaultVideo: w = ' + IntToStr(gWinSizeX) + ' h = ' + IntToStr(gWinSizeY));
187 g_Console_ResetBinds;
188 end;
189 {$ELSE}
190 procedure g_Options_SetDefaultVideo;
191 begin
192 gWinSizeX := 640;
193 gWinSizeY := 480;
194 gBPP := 32;
195 gFullScreen := False;
196 gWinMaximized := False;
197 gVSync := True;
198 gTextureFilter := True;
199 glLegacyNPOT := False;
200 gScreenWidth := gWinSizeX;
201 gScreenHeight := gWinSizeY;
202 gRC_Width := gWinSizeX;
203 gRC_Height := gWinSizeY;
204 gRC_FullScreen := gFullScreen;
205 gRC_Maximized := gWinMaximized;
206 e_LogWriteLn('g_Options_SetDefaultVideo: w = ' + IntToStr(gWinSizeX) + ' h = ' + IntToStr(gWinSizeY));
207 g_Console_ResetBinds;
208 end;
209 {$ENDIF}
211 procedure g_Options_SetDefault();
212 var
213 i: Integer;
214 begin
215 (* section Sound *)
216 gNoSound := False;
217 gSoundLevel := 75;
218 gMusicLevel := 65;
219 gMaxSimSounds := 8;
220 gMuteWhenInactive := False;
221 gAnnouncer := ANNOUNCE_MEPLUS;
222 gSoundEffectsDF := True;
223 gUseChatSounds := True;
224 gsSDLSampleRate := 44100;
225 gsSDLBufferSize := 2048;
227 g_Sound_SetupAllVolumes(gSoundLevel, gMusicLevel);
229 with gPlayer1Settings do
230 begin
231 Name := GenPlayerName(1);
232 Model := STD_PLAYER_MODEL;
233 Color.R := PLAYER1_DEF_COLOR.R;
234 Color.G := PLAYER1_DEF_COLOR.G;
235 Color.B := PLAYER1_DEF_COLOR.B;
236 Team := TEAM_RED;
237 end;
239 with gPlayer2Settings do
240 begin
241 Name := GenPlayerName(2);
242 Model := STD_PLAYER_MODEL;
243 Color.R := PLAYER2_DEF_COLOR.R;
244 Color.G := PLAYER2_DEF_COLOR.G;
245 Color.B := PLAYER2_DEF_COLOR.B;
246 Team := TEAM_BLUE;
247 end;
249 (* section Joysticks *)
250 for i := 0 to e_MaxJoys - 1 do
251 begin
252 e_JoystickDeadzones[i] := 8192
253 end;
255 (* section Game *)
256 g_GFX_SetMax(2000);
257 g_Shells_SetMax(300);
258 g_Gibs_SetMax(150);
259 g_Corpses_SetMax(20);
260 gGibsCount := 32;
261 ITEM_RESPAWNTIME := 60 * 36;
262 gBloodCount := 4;
263 gAdvBlood := True;
264 gAdvCorpses := True;
265 gAdvGibs := True;
266 gFlash := 1;
267 gDrawBackGround := True;
268 gShowMessages := True;
269 gRevertPlayers := False;
270 gChatBubble := 4;
271 wadoptDebug := False;
272 wadoptFast := False;
273 e_FastScreenshots := True;
274 gDefaultMegawadStart := DF_Default_Megawad_Start;
275 gBerserkAutoswitch := True;
276 g_dbg_scale := 1.0;
277 gSaveStats := False;
279 gAskLanguage := True;
280 gLanguage := LANGUAGE_ENGLISH;
282 (* section GameplayCustom *)
283 gcMap := '';
284 gcGameMode := _lc[I_MENU_GAME_TYPE_DM];
285 gcTimeLimit := 0;
286 gcGoalLimit := 0;
287 gcMaxLives := 0;
288 gcPlayers := 1;
289 gcTeamDamage := False;
290 gcAllowExit := True;
291 gcWeaponStay := False;
292 gcMonsters := False;
293 gcBotsVS := 'Everybody';
294 gcDeathmatchKeys := True;
295 gcSpawnInvul := 0;
297 (* section GameplayNetwork *)
298 gnMap := '';
299 gnGameMode := _lc[I_MENU_GAME_TYPE_DM];
300 gnTimeLimit := 0;
301 gnGoalLimit := 0;
302 gnMaxLives := 0;
303 gnPlayers := 1;
304 gnTeamDamage := False;
305 gnAllowExit := True;
306 gnWeaponStay := False;
307 gnMonsters := False;
308 gnBotsVS := 'Everybody';
309 gnDeathmatchKeys := True;
310 gnSpawnInvul := 0;
312 (* section MasterServer *)
313 NetSlistIP := 'mpms.doom2d.org';
314 NetSlistPort := 25665;
315 g_Net_Slist_Set(NetSlistIP, NetSlistPort, NetSlistList);
317 (* section Server *)
318 NetServerName := 'Unnamed Server';
319 NetPassword := '';
320 NetPort := 25666;
321 NetMaxClients := 16;
322 NetAllowRCON := False;
323 NetRCONPassword := 'default';
324 NetUseMaster := True;
325 NetUpdateRate := 0;
326 NetRelupdRate := 18;
327 NetMasterRate := 60000;
328 NetForwardPorts := False;
330 (* section Client *)
331 NetInterpLevel := 2;
332 NetForcePlayerUpdate := False;
333 NetPredictSelf := True;
334 NetClientIP := '127.0.0.1';
335 NetClientPort := NetPort;
336 end;
338 procedure g_Options_Read(FileName: String);
339 var
340 config: TConfig;
341 section: String;
343 procedure ReadInteger (VAR v: Integer; param: String; minv: Integer = Low(Integer); maxv: Integer = High(Integer));
344 begin
345 v := Max(Min(config.ReadInt(section, param, v), maxv), minv)
346 end;
348 procedure ReadInteger (VAR v: LongWord; param: String; minv: LongWord = Low(LongWord); maxv: LongWord = High(LongWord)); overload;
349 begin
350 v := Max(Min(config.ReadInt(section, param, v), maxv), minv)
351 end;
353 procedure ReadInteger (VAR v: Word; param: String; minv: Word = Low(Word); maxv: Word = High(Word)); overload;
354 begin
355 v := Max(Min(config.ReadInt(section, param, v), maxv), minv)
356 end;
358 procedure ReadInteger (VAR v: Byte; param: String; minv: Byte = Low(Byte); maxv: Byte = High(Byte)); overload;
359 begin
360 v := Max(Min(config.ReadInt(section, param, v), maxv), minv)
361 end;
363 procedure ReadBoolean (VAR v: Boolean; param: String);
364 begin
365 v := config.ReadBool(section, param, v)
366 end;
368 procedure ReadString (VAR v: String; param: String);
369 begin
370 v := config.ReadStr(section, param, v)
371 end;
373 begin
374 gAskLanguage := True;
375 e_WriteLog('Reading config', TMsgType.Notify);
376 g_Options_SetDefault;
378 if FileExists(FileName) = False then
379 begin
380 e_WriteLog('Config file '+FileName+' not found', TMsgType.Warning);
381 g_Options_SetDefaultVideo;
382 Exit
383 end;
385 config := TConfig.CreateFile(FileName);
387 section := 'Player1';
388 with gPlayer1Settings do
389 begin
390 ReadString(Name, 'name');
391 ReadString(Model, 'model');
392 ReadInteger(Color.R, 'red', 0, 255);
393 ReadInteger(Color.G, 'green', 0, 255);
394 ReadInteger(Color.B, 'blue', 0, 255);
395 ReadInteger(Team, 'team');
396 if (Team < TEAM_RED) or (Team > TEAM_BLUE) then
397 Team := TEAM_RED;
398 end;
400 section := 'Player2';
401 with gPlayer2Settings do
402 begin
403 ReadString(Name, 'name');
404 ReadString(Model, 'model');
405 ReadInteger(Color.R, 'red', 0, 255);
406 ReadInteger(Color.G, 'green', 0, 255);
407 ReadInteger(Color.B, 'blue', 0, 255);
408 ReadInteger(Team, 'team');
409 if (Team < TEAM_RED) or (Team > TEAM_BLUE) then
410 Team := TEAM_RED;
411 end;
413 section := 'GameplayCustom';
414 ReadString(gcMap, 'Map');
415 ReadString(gcGameMode, 'GameMode');
416 ReadInteger(gcTimeLimit, 'TimeLimit', 0, 65535);
417 ReadInteger(gcGoalLimit, 'GoalLimit', 0, 65535);
418 ReadInteger(gcMaxLives, 'MaxLives', 0, 255);
419 ReadInteger(gcPlayers, 'Players', 0, 2);
420 ReadBoolean(gcTeamDamage, 'TeamDamage');
421 ReadBoolean(gcAllowExit, 'AllowExit');
422 ReadBoolean(gcWeaponStay, 'WeaponStay');
423 ReadBoolean(gcMonsters, 'Monsters');
424 ReadString(gcBotsVS, 'BotsVS');
425 ReadBoolean(gcDeathmatchKeys, 'DeathmatchKeys');
426 ReadInteger(gcSpawnInvul, 'SpawnInvul');
428 with gGameSettings do
429 begin
430 GameMode := g_Game_TextToMode(gcGameMode);
431 if GameMode = GM_NONE then
432 GameMode := GM_DM;
433 if GameMode = GM_SINGLE then
434 GameMode := GM_COOP;
435 TimeLimit := gcTimeLimit;
436 GoalLimit := gcGoalLimit;
437 MaxLives := gcMaxLives;
439 Options := 0;
440 if gcTeamDamage then
441 Options := Options or GAME_OPTION_TEAMDAMAGE;
442 if gcAllowExit then
443 Options := Options or GAME_OPTION_ALLOWEXIT;
444 if gcWeaponStay then
445 Options := Options or GAME_OPTION_WEAPONSTAY;
446 if gcMonsters then
447 Options := Options or GAME_OPTION_MONSTERS;
448 if gcBotsVS = 'Everybody' then
449 Options := Options or GAME_OPTION_BOTVSPLAYER or GAME_OPTION_BOTVSMONSTER;
450 if gcBotsVS = 'Players' then
451 Options := Options or GAME_OPTION_BOTVSPLAYER;
452 if gcBotsVS = 'Monsters' then
453 Options := Options or GAME_OPTION_BOTVSMONSTER;
454 if gcDeathmatchKeys then
455 Options := Options or GAME_OPTION_DMKEYS;
456 end;
458 section := 'GameplayNetwork';
459 ReadString(gnMap, 'Map');
460 ReadString(gnGameMode, 'GameMode');
461 ReadInteger(gnTimeLimit, 'TimeLimit', 0, 65535);
462 ReadInteger(gnGoalLimit, 'GoalLimit', 0, 65535);
463 ReadInteger(gnMaxLives, 'MaxLives', 0, 255);
464 ReadInteger(gnPlayers, 'Players', 0, 2);
465 ReadBoolean(gnTeamDamage, 'TeamDamage');
466 ReadBoolean(gnAllowExit, 'AllowExit');
467 ReadBoolean(gnWeaponStay, 'WeaponStay');
468 ReadBoolean(gnMonsters, 'Monsters');
469 ReadString(gnBotsVS, 'BotsVS');
470 ReadBoolean(gnDeathmatchKeys, 'DeathmatchKeys');
471 ReadInteger(gnSpawnInvul, 'SpawnInvul');
473 section := 'MasterServer';
474 ReadString(NetSlistIP, 'IP');
475 ReadInteger(NetSlistPort, 'Port', 0, 65535);
476 ReadString(NetSlistList, 'List');
477 g_Net_Slist_Set(NetSlistIP, NetSlistPort, NetSlistList);
479 section := 'Server';
480 ReadString(NetServerName, 'Name');
481 ReadString(NetPassword, 'Password');
482 ReadInteger(NetPort, 'Port', 0, 65535);
483 ReadInteger(NetMaxClients, 'MaxClients', 0, NET_MAXCLIENTS);
484 ReadBoolean(NetAllowRCON, 'RCON');
485 ReadString(NetRCONPassword, 'RCONPassword');
486 ReadBoolean(NetUseMaster, 'SyncWithMaster');
487 ReadInteger(NetUpdateRate, 'UpdateInterval', 0);
488 ReadInteger(NetRelupdRate, 'ReliableUpdateInterval', 0);
489 ReadInteger(NetMasterRate, 'MasterSyncInterval', 1);
490 ReadBoolean(NetForwardPorts, 'ForwardPorts');
492 section := 'Client';
493 ReadInteger(NetInterpLevel, 'InterpolationSteps', 0);
494 ReadBoolean(NetForcePlayerUpdate, 'ForcePlayerUpdate');
495 ReadBoolean(NetPredictSelf, 'PredictSelf');
496 ReadString(NetClientIP, 'LastIP');
497 ReadInteger(NetClientPort, 'LastPort', 0, 65535);
499 config.Free();
501 //if gTextureFilter then TEXTUREFILTER := GL_LINEAR else TEXTUREFILTER := GL_NEAREST;
502 end;
504 procedure g_Options_Write(FileName: String);
505 var config: TConfig;
506 begin
507 e_WriteLog('Writing config', TMsgType.Notify);
509 config := TConfig.CreateFile(FileName);
511 with config, gPlayer1Settings do
512 begin
513 WriteStr('Player1', 'Name', Name);
514 WriteStr('Player1', 'model', Model);
515 WriteInt('Player1', 'red', Color.R);
516 WriteInt('Player1', 'green', Color.G);
517 WriteInt('Player1', 'blue', Color.B);
518 WriteInt('Player1', 'team', Team);
519 end;
521 with config, gPlayer2Settings do
522 begin
523 WriteStr('Player2', 'Name', Name);
524 WriteStr('Player2', 'model', Model);
525 WriteInt('Player2', 'red', Color.R);
526 WriteInt('Player2', 'green', Color.G);
527 WriteInt('Player2', 'blue', Color.B);
528 WriteInt('Player2', 'team', Team);
529 end;
531 config.WriteStr ('GameplayCustom', 'Map', gcMap);
532 config.WriteStr ('GameplayCustom', 'GameMode', gcGameMode);
533 config.WriteInt ('GameplayCustom', 'TimeLimit', gcTimeLimit);
534 config.WriteInt ('GameplayCustom', 'GoalLimit', gcGoalLimit);
535 config.WriteInt ('GameplayCustom', 'MaxLives', gcMaxLives);
536 config.WriteInt ('GameplayCustom', 'Players', gcPlayers);
537 config.WriteBool('GameplayCustom', 'TeamDamage', gcTeamDamage);
538 config.WriteBool('GameplayCustom', 'AllowExit', gcAllowExit);
539 config.WriteBool('GameplayCustom', 'WeaponStay', gcWeaponStay);
540 config.WriteBool('GameplayCustom', 'Monsters', gcMonsters);
541 config.WriteStr ('GameplayCustom', 'BotsVS', gcBotsVS);
542 config.WriteBool('GameplayCustom', 'DeathmatchKeys', gcDeathmatchKeys);
543 config.WriteInt ('GameplayCustom', 'SpawnInvul', gcSpawnInvul);
545 config.WriteStr ('GameplayNetwork', 'Map', gnMap);
546 config.WriteStr ('GameplayNetwork', 'GameMode', gnGameMode);
547 config.WriteInt ('GameplayNetwork', 'TimeLimit', gnTimeLimit);
548 config.WriteInt ('GameplayNetwork', 'GoalLimit', gnGoalLimit);
549 config.WriteInt ('GameplayNetwork', 'MaxLives', gnMaxLives);
550 config.WriteInt ('GameplayNetwork', 'Players', gnPlayers);
551 config.WriteBool('GameplayNetwork', 'TeamDamage', gnTeamDamage);
552 config.WriteBool('GameplayNetwork', 'AllowExit', gnAllowExit);
553 config.WriteBool('GameplayNetwork', 'WeaponStay', gnWeaponStay);
554 config.WriteBool('GameplayNetwork', 'Monsters', gnMonsters);
555 config.WriteStr ('GameplayNetwork', 'BotsVS', gnBotsVS);
556 config.WriteBool('GameplayNetwork', 'DeathmatchKeys', gnDeathmatchKeys);
557 config.WriteInt ('GameplayNetwork', 'SpawnInvul', gnSpawnInvul);
559 config.WriteStr('MasterServer', 'IP', NetSlistIP);
560 config.WriteInt('MasterServer', 'Port', NetSlistPort);
561 config.WriteStr('MasterServer', 'List', NetSlistList);
563 config.WriteStr ('Server', 'Name', NetServerName);
564 config.WriteStr ('Server', 'Password', NetPassword);
565 config.WriteInt ('Server', 'Port', NetPort);
566 config.WriteInt ('Server', 'MaxClients', NetMaxClients);
567 config.WriteBool('Server', 'RCON', NetAllowRCON);
568 config.WriteStr ('Server', 'RCONPassword', NetRCONPassword);
569 config.WriteBool('Server', 'SyncWithMaster', NetUseMaster);
570 config.WriteBool('Server', 'ForwardPorts', NetForwardPorts);
571 config.WriteInt ('Server', 'UpdateInterval', NetUpdateRate);
572 config.WriteInt ('Server', 'ReliableUpdateInterval', NetRelupdRate);
573 config.WriteInt ('Server', 'MasterSyncInterval', NetMasterRate);
575 config.WriteInt ('Client', 'InterpolationSteps', NetInterpLevel);
576 config.WriteBool ('Client', 'ForcePlayerUpdate', NetForcePlayerUpdate);
577 config.WriteBool ('Client', 'PredictSelf', NetPredictSelf);
578 config.WriteStr ('Client', 'LastIP', NetClientIP);
579 config.WriteInt ('Client', 'LastPort', NetClientPort);
581 config.SaveFile(FileName);
582 config.Free();
583 end;
585 procedure g_Options_Write_Gameplay_Custom(FileName: String);
586 var
587 config: TConfig;
588 begin
589 e_WriteLog('Writing custom gameplay config', TMsgType.Notify);
591 config := TConfig.CreateFile(FileName);
593 config.WriteStr ('GameplayCustom', 'Map', gcMap);
594 config.WriteStr ('GameplayCustom', 'GameMode', gcGameMode);
595 config.WriteInt ('GameplayCustom', 'TimeLimit', gcTimeLimit);
596 config.WriteInt ('GameplayCustom', 'GoalLimit', gcGoalLimit);
597 config.WriteInt ('GameplayCustom', 'MaxLives', gcMaxLives);
598 config.WriteInt ('GameplayCustom', 'Players', gcPlayers);
599 config.WriteBool('GameplayCustom', 'TeamDamage', gcTeamDamage);
600 config.WriteBool('GameplayCustom', 'AllowExit', gcAllowExit);
601 config.WriteBool('GameplayCustom', 'WeaponStay', gcWeaponStay);
602 config.WriteBool('GameplayCustom', 'Monsters', gcMonsters);
603 config.WriteStr ('GameplayCustom', 'BotsVS', gcBotsVS);
604 config.WriteBool('GameplayCustom', 'DeathmatchKeys', gcDeathmatchKeys);
605 config.WriteInt ('GameplayCustom', 'SpawnInvul', gcSpawnInvul);
607 config.SaveFile(FileName);
608 config.Free();
609 end;
611 procedure g_Options_Write_Gameplay_Net(FileName: String);
612 var
613 config: TConfig;
614 begin
615 e_WriteLog('Writing network gameplay config', TMsgType.Notify);
617 config := TConfig.CreateFile(FileName);
619 config.WriteStr ('GameplayNetwork', 'Map', gnMap);
620 config.WriteStr ('GameplayNetwork', 'GameMode', gnGameMode);
621 config.WriteInt ('GameplayNetwork', 'TimeLimit', gnTimeLimit);
622 config.WriteInt ('GameplayNetwork', 'GoalLimit', gnGoalLimit);
623 config.WriteInt ('GameplayNetwork', 'MaxLives', gnMaxLives);
624 config.WriteInt ('GameplayNetwork', 'Players', gnPlayers);
625 config.WriteBool('GameplayNetwork', 'TeamDamage', gnTeamDamage);
626 config.WriteBool('GameplayNetwork', 'AllowExit', gnAllowExit);
627 config.WriteBool('GameplayNetwork', 'WeaponStay', gnWeaponStay);
628 config.WriteBool('GameplayNetwork', 'Monsters', gnMonsters);
629 config.WriteStr ('GameplayNetwork', 'BotsVS', gnBotsVS);
630 config.WriteBool('GameplayNetwork', 'DeathmatchKeys', gnDeathmatchKeys);
631 config.WriteInt ('GameplayNetwork', 'SpawnInvul', gnSpawnInvul);
633 config.SaveFile(FileName);
634 config.Free();
635 end;
637 procedure g_Options_Write_Net_Server(FileName: String);
638 var
639 config: TConfig;
640 begin
641 e_WriteLog('Writing server config', TMsgType.Notify);
643 config := TConfig.CreateFile(FileName);
645 config.WriteStr ('Server', 'Name', NetServerName);
646 config.WriteStr ('Server', 'Password', NetPassword);
647 config.WriteInt ('Server', 'Port', NetPort);
648 config.WriteInt ('Server', 'MaxClients', NetMaxClients);
649 config.WriteBool('Server', 'SyncWithMaster', NetUseMaster);
650 config.WriteBool('Server', 'ForwardPorts', NetForwardPorts);
652 config.SaveFile(FileName);
653 config.Free();
654 end;
656 procedure g_Options_Write_Net_Client(FileName: String);
657 var
658 config: TConfig;
659 begin
660 e_WriteLog('Writing client config', TMsgType.Notify);
662 config := TConfig.CreateFile(FileName);
664 config.WriteStr('Client', 'LastIP', NetClientIP);
665 config.WriteInt('Client', 'LastPort', NetClientPort);
667 config.SaveFile(FileName);
668 config.Free();
669 end;
671 procedure g_Options_Commands (p: SSArray);
672 var cmd: AnsiString; i: Integer;
673 begin
674 cmd := LowerCase(p[0]);
675 case cmd of
676 'r_reset':
677 begin
678 sys_EnableVSync(gVSync);
679 gRC_Width := Max(1, gRC_Width);
680 gRC_Height := Max(1, gRC_Height);
681 gBPP := Max(1, gBPP);
682 if sys_SetDisplayMode(gRC_Width, gRC_Height, gBPP, gRC_FullScreen, gRC_Maximized) = True then
683 e_LogWriteln('resolution changed')
684 else
685 e_LogWriteln('resolution not changed')
686 end;
687 'g_language':
688 begin
689 if Length(p) = 2 then
690 begin
691 gAskLanguage := true;
692 gLanguage := LANGUAGE_ENGLISH;
693 case LowerCase(p[1]) of
694 'english':
695 begin
696 gAskLanguage := false;
697 gLanguage := LANGUAGE_ENGLISH;
698 end;
699 'russian':
700 begin
701 gAskLanguage := false;
702 gLanguage := LANGUAGE_RUSSIAN;
703 end;
704 'ask':
705 begin
706 gAskLanguage := true;
707 gLanguage := LANGUAGE_ENGLISH;
708 end;
709 end;
710 g_Language_Set(gLanguage)
711 end
712 else
713 begin
714 e_LogWritefln('usage: %s <English|Russian|Ask>', [cmd])
715 end
716 end;
717 'g_max_particles':
718 begin
719 if Length(p) = 2 then
720 begin
721 i := Max(0, StrToInt(p[1]));
722 g_GFX_SetMax(i)
723 end
724 else if Length(p) = 1 then
725 begin
726 e_LogWritefln('%s', [g_GFX_GetMax()])
727 end
728 else
729 begin
730 e_LogWritefln('usage: %s <n>', [cmd])
731 end
732 end;
733 'g_max_shells':
734 begin
735 if Length(p) = 2 then
736 begin
737 i := Max(0, StrToInt(p[1]));
738 g_Shells_SetMax(i)
739 end
740 else if Length(p) = 1 then
741 begin
742 e_LogWritefln('%s', [g_Shells_GetMax()])
743 end
744 else
745 begin
746 e_LogWritefln('usage: %s <n>', [cmd])
747 end
748 end;
749 'g_max_gibs':
750 begin
751 if Length(p) = 2 then
752 begin
753 i := Max(0, StrToInt(p[1]));
754 g_Gibs_SetMax(i)
755 end
756 else if Length(p) = 1 then
757 begin
758 e_LogWritefln('%s', [g_Gibs_GetMax()])
759 end
760 else
761 begin
762 e_LogWritefln('usage: %s <n>', [cmd])
763 end
764 end;
765 'g_max_corpses':
766 begin
767 if Length(p) = 2 then
768 begin
769 i := Max(0, StrToInt(p[1]));
770 g_Corpses_SetMax(i)
771 end
772 else if Length(p) = 1 then
773 begin
774 e_LogWritefln('%s', [g_Corpses_GetMax()])
775 end
776 else
777 begin
778 e_LogWritefln('usage: %s <n>', [cmd])
779 end
780 end;
781 'g_item_respawn_time':
782 begin
783 if Length(p) = 2 then
784 ITEM_RESPAWNTIME := Max(0, StrToInt(p[1])) * 36
785 else if Length(p) = 1 then
786 e_LogWritefln('%s', [ITEM_RESPAWNTIME div 36])
787 else
788 e_LogWritefln('usage: %s <n>', [cmd])
789 end;
790 end;
791 end;
793 initialization
794 Randomize;
795 machine := Random(10000);
797 (* Video *)
798 conRegVar('r_width', @gRC_Width, '', '');
799 conRegVar('r_height', @gRC_Height, '', '');
800 conRegVar('r_fullscreen', @gRC_FullScreen, '', '');
801 conRegVar('r_maximized', @gRC_Maximized, '', '');
802 conRegVar('r_bpp', @gBPP, '', '');
803 conRegVar('r_vsync', @gVSync, '', '');
804 conRegVar('r_texfilter', @gTextureFilter, '', '');
805 conRegVar('r_npot', @glNPOTOverride, '', '');
807 (* Sound *)
808 conRegVar('s_nosound', @gNoSound, '', '');
809 conRegVar('s_soundvolume', @gSoundLevel, '', '');
810 conRegVar('s_musicvolume', @gMusicLevel, '', '');
811 conRegVar('s_maxsim', @gMaxSimSounds, '', ''); // e_sound_fmod/sdl?
812 conRegVar('s_muteinactive', @gMuteWhenInactive, '', '');
813 conRegVar('s_announcer', @gAnnouncer, '', '');
814 conRegVar('s_sfx', @gSoundEffectsDF, '', '');
815 conRegVar('s_chatsounds', @gUseChatSounds, '', '');
816 {$IFDEF USE_SDLMIXER}
817 conRegVar('sdl_mixer_samplerate', @gsSDLSampleRate, '', '');
818 conRegVar('sdl_mixer_buffersize', @gsSDLBufferSize, '', '');
819 {$ENDIF}
821 (* Game *)
822 conRegVar('g_gibs_count', @gGibsCount, '', '');
823 conRegVar('g_blood_count', @gBloodCount, '', '');
824 conRegVar('g_adv_blood', @gAdvBlood, '', '');
825 conRegVar('g_adv_corpses', @gAdvCorpses, '', '');
826 conRegVar('g_adv_gibs', @gAdvGibs, '', '');
827 conRegVar('r_flash', @gFlash, '', '');
828 conRegVar('r_background', @gDrawBackGround, '', '');
829 conRegVar('g_show_messages', @gShowMessages, '', '');
830 conRegVar('r_revert_players', @gRevertPlayers, '', '');
831 conRegVar('r_chat_bubble', @gChatBubble, '', '');
832 conRegVar('sfs_debug', @wadoptDebug, '', '');
833 conRegVar('sfs_fastmode', @wadoptFast, '', '');
834 conRegVar('g_fast_screenshots', @e_FastScreenshots, '', '');
835 conRegVar('g_default_megawad', @gDefaultMegawadStart, '', '');
836 conRegVar('g_save_stats', @gSaveStats, '', '');
837 conRegVar('g_screenshot_stats', @gScreenshotStats, '', '');
838 end.