DEADSOFTWARE

add 'respawn items' flag
[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 gcRespawnItems: Boolean = True;
78 gcSpawnInvul: Integer = 0;
79 gnMap: String;
80 gnGameMode: String;
81 gnTimeLimit: Word;
82 gnGoalLimit: Word;
83 gnMaxLives: Byte;
84 gnPlayers: Byte;
85 gnTeamDamage: Boolean;
86 gnAllowExit: Boolean;
87 gnWeaponStay: Boolean;
88 gnMonsters: Boolean;
89 gnBotsVS: String;
90 gnDeathmatchKeys: Boolean = True;
91 gnRespawnItems: Boolean = True;
92 gnSpawnInvul: Integer = 0;
93 gsSDLSampleRate: Integer;
94 gsSDLBufferSize: Integer;
95 gDefaultMegawadStart: AnsiString;
96 gBerserkAutoswitch: Boolean;
97 glNPOTOverride: Boolean = false;
99 implementation
101 uses
102 {$INCLUDE ../nogl/noGLuses.inc}
103 {$IFDEF USE_SDL2}
104 SDL2,
105 {$ENDIF}
106 e_log, e_input, g_console, g_window, g_sound, g_gfx, g_player, Math,
107 g_map, g_net, g_netmaster, SysUtils, CONFIG, g_game, g_main, e_texture,
108 g_items, wadreader, e_graphics, g_touch, envvars, g_system;
110 var
111 machine: Integer;
113 function GenPlayerName (n: Integer): String;
114 begin
115 ASSERT(n >= 1);
116 Result := GetUserName;
117 if Result = '' then
118 Result := 'Player' + IntToStr(machine MOD 10000);
119 if n = 1 then
120 Result := Copy(Result, 1, 12) + ' '
121 else
122 Result := Copy(Result, 1, 10) + ' ' + IntToStr(n)
123 end;
125 {$IFDEF USE_SDL2}
126 procedure g_Options_SetDefaultVideo;
127 var display: TSDL_DisplayMode;
128 {$IFNDEF ANDROID}
129 var target, closest: TSDL_DisplayMode; percentage: Integer;
130 {$ENDIF}
131 begin
132 (* Display 0 = Primary display *)
133 gScreenWidth := 640;
134 gScreenHeight := 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 gScreenWidth := display.w;
146 gScreenHeight := 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 gScreenWidth := closest.w;
169 gScreenHeight := 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 := gScreenWidth;
183 gRC_Height := gScreenHeight;
184 gRC_FullScreen := gFullScreen;
185 gRC_Maximized := gWinMaximized;
186 e_LogWriteLn('g_Options_SetDefaultVideo: w = ' + IntToStr(gScreenWidth) + ' h = ' + IntToStr(gScreenHeight));
187 g_Console_ResetBinds;
188 end;
189 {$ELSE}
190 procedure g_Options_SetDefaultVideo;
191 begin
192 gScreenWidth := 640;
193 gScreenHeight := 480;
194 gBPP := 32;
195 gFullScreen := False;
196 gWinMaximized := False;
197 gVSync := True;
198 gTextureFilter := True;
199 glLegacyNPOT := False;
200 gRC_Width := gScreenWidth;
201 gRC_Height := gScreenHeight;
202 gRC_FullScreen := gFullScreen;
203 gRC_Maximized := gWinMaximized;
204 e_LogWriteLn('g_Options_SetDefaultVideo: w = ' + IntToStr(gScreenWidth) + ' h = ' + IntToStr(gScreenHeight));
205 g_Console_ResetBinds;
206 end;
207 {$ENDIF}
209 procedure g_Options_SetDefault();
210 var
211 i: Integer;
212 begin
213 (* section Sound *)
214 gNoSound := False;
215 gSoundLevel := 75;
216 gMusicLevel := 65;
217 gMaxSimSounds := 8;
218 gMuteWhenInactive := False;
219 gAnnouncer := ANNOUNCE_MEPLUS;
220 gSoundEffectsDF := True;
221 gUseChatSounds := True;
222 gsSDLSampleRate := 44100;
223 gsSDLBufferSize := 2048;
225 g_Sound_SetupAllVolumes(gSoundLevel, gMusicLevel);
227 with gPlayer1Settings do
228 begin
229 Name := GenPlayerName(1);
230 Model := STD_PLAYER_MODEL;
231 Color.R := PLAYER1_DEF_COLOR.R;
232 Color.G := PLAYER1_DEF_COLOR.G;
233 Color.B := PLAYER1_DEF_COLOR.B;
234 Team := TEAM_RED;
235 end;
237 with gPlayer2Settings do
238 begin
239 Name := GenPlayerName(2);
240 Model := STD_PLAYER_MODEL;
241 Color.R := PLAYER2_DEF_COLOR.R;
242 Color.G := PLAYER2_DEF_COLOR.G;
243 Color.B := PLAYER2_DEF_COLOR.B;
244 Team := TEAM_BLUE;
245 end;
247 (* section Joysticks *)
248 for i := 0 to e_MaxJoys - 1 do
249 begin
250 e_JoystickDeadzones[i] := 8192
251 end;
253 (* section Game *)
254 g_GFX_SetMax(2000);
255 g_Shells_SetMax(300);
256 g_Gibs_SetMax(150);
257 g_Corpses_SetMax(20);
258 gGibsCount := 32;
259 ITEM_RESPAWNTIME := 60 * 36;
260 gBloodCount := 4;
261 gAdvBlood := True;
262 gAdvCorpses := True;
263 gAdvGibs := True;
264 gFlash := 1;
265 gDrawBackGround := True;
266 gShowMessages := True;
267 gRevertPlayers := False;
268 gChatBubble := 4;
269 wadoptDebug := False;
270 wadoptFast := False;
271 e_FastScreenshots := True;
272 gDefaultMegawadStart := DF_Default_Megawad_Start;
273 gBerserkAutoswitch := True;
274 g_dbg_scale := 1.0;
275 gSaveStats := False;
277 gAskLanguage := True;
278 gLanguage := LANGUAGE_ENGLISH;
280 (* section GameplayCustom *)
281 gcMap := '';
282 gcGameMode := _lc[I_MENU_GAME_TYPE_DM];
283 gcTimeLimit := 0;
284 gcGoalLimit := 0;
285 gcMaxLives := 0;
286 gcPlayers := 1;
287 gcTeamDamage := False;
288 gcAllowExit := True;
289 gcWeaponStay := False;
290 gcMonsters := False;
291 gcBotsVS := 'Everybody';
292 gcDeathmatchKeys := True;
293 gcRespawnItems := True;
294 gcSpawnInvul := 0;
296 (* section GameplayNetwork *)
297 gnMap := '';
298 gnGameMode := _lc[I_MENU_GAME_TYPE_DM];
299 gnTimeLimit := 0;
300 gnGoalLimit := 0;
301 gnMaxLives := 0;
302 gnPlayers := 1;
303 gnTeamDamage := False;
304 gnAllowExit := True;
305 gnWeaponStay := False;
306 gnMonsters := False;
307 gnBotsVS := 'Everybody';
308 gnDeathmatchKeys := True;
309 gnRespawnItems := 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 ReadBoolean(gcRespawnItems, 'RespawnItems');
427 ReadInteger(gcSpawnInvul, 'SpawnInvul');
429 with gGameSettings do
430 begin
431 GameMode := g_Game_TextToMode(gcGameMode);
432 if GameMode = GM_NONE then
433 GameMode := GM_DM;
434 if GameMode = GM_SINGLE then
435 GameMode := GM_COOP;
436 TimeLimit := gcTimeLimit;
437 GoalLimit := gcGoalLimit;
438 MaxLives := gcMaxLives;
440 Options := 0;
441 if gcTeamDamage then
442 Options := Options or GAME_OPTION_TEAMDAMAGE;
443 if gcAllowExit then
444 Options := Options or GAME_OPTION_ALLOWEXIT;
445 if gcWeaponStay then
446 Options := Options or GAME_OPTION_WEAPONSTAY;
447 if gcMonsters then
448 Options := Options or GAME_OPTION_MONSTERS;
449 if gcBotsVS = 'Everybody' then
450 Options := Options or GAME_OPTION_BOTVSPLAYER or GAME_OPTION_BOTVSMONSTER;
451 if gcBotsVS = 'Players' then
452 Options := Options or GAME_OPTION_BOTVSPLAYER;
453 if gcBotsVS = 'Monsters' then
454 Options := Options or GAME_OPTION_BOTVSMONSTER;
455 if gcDeathmatchKeys then
456 Options := Options or GAME_OPTION_DMKEYS;
457 if gcRespawnItems then
458 Options := Options or GAME_OPTION_RESPAWNITEMS;
459 end;
461 section := 'GameplayNetwork';
462 ReadString(gnMap, 'Map');
463 ReadString(gnGameMode, 'GameMode');
464 ReadInteger(gnTimeLimit, 'TimeLimit', 0, 65535);
465 ReadInteger(gnGoalLimit, 'GoalLimit', 0, 65535);
466 ReadInteger(gnMaxLives, 'MaxLives', 0, 255);
467 ReadInteger(gnPlayers, 'Players', 0, 2);
468 ReadBoolean(gnTeamDamage, 'TeamDamage');
469 ReadBoolean(gnAllowExit, 'AllowExit');
470 ReadBoolean(gnWeaponStay, 'WeaponStay');
471 ReadBoolean(gnMonsters, 'Monsters');
472 ReadString(gnBotsVS, 'BotsVS');
473 ReadBoolean(gnDeathmatchKeys, 'DeathmatchKeys');
474 ReadBoolean(gnRespawnItems, 'RespawnItems');
475 ReadInteger(gnSpawnInvul, 'SpawnInvul');
477 section := 'MasterServer';
478 ReadString(NetSlistIP, 'IP');
479 ReadInteger(NetSlistPort, 'Port', 0, 65535);
480 ReadString(NetSlistList, 'List');
481 g_Net_Slist_Set(NetSlistIP, NetSlistPort, NetSlistList);
483 section := 'Server';
484 ReadString(NetServerName, 'Name');
485 ReadString(NetPassword, 'Password');
486 ReadInteger(NetPort, 'Port', 0, 65535);
487 ReadInteger(NetMaxClients, 'MaxClients', 0, NET_MAXCLIENTS);
488 ReadBoolean(NetAllowRCON, 'RCON');
489 ReadString(NetRCONPassword, 'RCONPassword');
490 ReadBoolean(NetUseMaster, 'SyncWithMaster');
491 ReadInteger(NetUpdateRate, 'UpdateInterval', 0);
492 ReadInteger(NetRelupdRate, 'ReliableUpdateInterval', 0);
493 ReadInteger(NetMasterRate, 'MasterSyncInterval', 1);
494 ReadBoolean(NetForwardPorts, 'ForwardPorts');
496 section := 'Client';
497 ReadInteger(NetInterpLevel, 'InterpolationSteps', 0);
498 ReadBoolean(NetForcePlayerUpdate, 'ForcePlayerUpdate');
499 ReadBoolean(NetPredictSelf, 'PredictSelf');
500 ReadString(NetClientIP, 'LastIP');
501 ReadInteger(NetClientPort, 'LastPort', 0, 65535);
503 config.Free();
505 //if gTextureFilter then TEXTUREFILTER := GL_LINEAR else TEXTUREFILTER := GL_NEAREST;
506 end;
508 procedure g_Options_Write(FileName: String);
509 var config: TConfig;
510 begin
511 e_WriteLog('Writing config', TMsgType.Notify);
513 config := TConfig.CreateFile(FileName);
515 with config, gPlayer1Settings do
516 begin
517 WriteStr('Player1', 'Name', Name);
518 WriteStr('Player1', 'model', Model);
519 WriteInt('Player1', 'red', Color.R);
520 WriteInt('Player1', 'green', Color.G);
521 WriteInt('Player1', 'blue', Color.B);
522 WriteInt('Player1', 'team', Team);
523 end;
525 with config, gPlayer2Settings do
526 begin
527 WriteStr('Player2', 'Name', Name);
528 WriteStr('Player2', 'model', Model);
529 WriteInt('Player2', 'red', Color.R);
530 WriteInt('Player2', 'green', Color.G);
531 WriteInt('Player2', 'blue', Color.B);
532 WriteInt('Player2', 'team', Team);
533 end;
535 config.WriteStr ('GameplayCustom', 'Map', gcMap);
536 config.WriteStr ('GameplayCustom', 'GameMode', gcGameMode);
537 config.WriteInt ('GameplayCustom', 'TimeLimit', gcTimeLimit);
538 config.WriteInt ('GameplayCustom', 'GoalLimit', gcGoalLimit);
539 config.WriteInt ('GameplayCustom', 'MaxLives', gcMaxLives);
540 config.WriteInt ('GameplayCustom', 'Players', gcPlayers);
541 config.WriteBool('GameplayCustom', 'TeamDamage', gcTeamDamage);
542 config.WriteBool('GameplayCustom', 'AllowExit', gcAllowExit);
543 config.WriteBool('GameplayCustom', 'WeaponStay', gcWeaponStay);
544 config.WriteBool('GameplayCustom', 'Monsters', gcMonsters);
545 config.WriteStr ('GameplayCustom', 'BotsVS', gcBotsVS);
546 config.WriteBool('GameplayCustom', 'DeathmatchKeys', gcDeathmatchKeys);
547 config.WriteBool('GameplayCustom', 'RespawnItems', gcRespawnItems);
548 config.WriteInt ('GameplayCustom', 'SpawnInvul', gcSpawnInvul);
550 config.WriteStr ('GameplayNetwork', 'Map', gnMap);
551 config.WriteStr ('GameplayNetwork', 'GameMode', gnGameMode);
552 config.WriteInt ('GameplayNetwork', 'TimeLimit', gnTimeLimit);
553 config.WriteInt ('GameplayNetwork', 'GoalLimit', gnGoalLimit);
554 config.WriteInt ('GameplayNetwork', 'MaxLives', gnMaxLives);
555 config.WriteInt ('GameplayNetwork', 'Players', gnPlayers);
556 config.WriteBool('GameplayNetwork', 'TeamDamage', gnTeamDamage);
557 config.WriteBool('GameplayNetwork', 'AllowExit', gnAllowExit);
558 config.WriteBool('GameplayNetwork', 'WeaponStay', gnWeaponStay);
559 config.WriteBool('GameplayNetwork', 'Monsters', gnMonsters);
560 config.WriteStr ('GameplayNetwork', 'BotsVS', gnBotsVS);
561 config.WriteBool('GameplayNetwork', 'DeathmatchKeys', gnDeathmatchKeys);
562 config.WriteBool('GameplayNetwork', 'RespawnItems', gnRespawnItems);
563 config.WriteInt ('GameplayNetwork', 'SpawnInvul', gnSpawnInvul);
565 config.WriteStr('MasterServer', 'IP', NetSlistIP);
566 config.WriteInt('MasterServer', 'Port', NetSlistPort);
567 config.WriteStr('MasterServer', 'List', NetSlistList);
569 config.WriteStr ('Server', 'Name', NetServerName);
570 config.WriteStr ('Server', 'Password', NetPassword);
571 config.WriteInt ('Server', 'Port', NetPort);
572 config.WriteInt ('Server', 'MaxClients', NetMaxClients);
573 config.WriteBool('Server', 'RCON', NetAllowRCON);
574 config.WriteStr ('Server', 'RCONPassword', NetRCONPassword);
575 config.WriteBool('Server', 'SyncWithMaster', NetUseMaster);
576 config.WriteBool('Server', 'ForwardPorts', NetForwardPorts);
577 config.WriteInt ('Server', 'UpdateInterval', NetUpdateRate);
578 config.WriteInt ('Server', 'ReliableUpdateInterval', NetRelupdRate);
579 config.WriteInt ('Server', 'MasterSyncInterval', NetMasterRate);
581 config.WriteInt ('Client', 'InterpolationSteps', NetInterpLevel);
582 config.WriteBool ('Client', 'ForcePlayerUpdate', NetForcePlayerUpdate);
583 config.WriteBool ('Client', 'PredictSelf', NetPredictSelf);
584 config.WriteStr ('Client', 'LastIP', NetClientIP);
585 config.WriteInt ('Client', 'LastPort', NetClientPort);
587 config.SaveFile(FileName);
588 config.Free();
589 end;
591 procedure g_Options_Write_Gameplay_Custom(FileName: String);
592 var
593 config: TConfig;
594 begin
595 e_WriteLog('Writing custom gameplay config', TMsgType.Notify);
597 config := TConfig.CreateFile(FileName);
599 config.WriteStr ('GameplayCustom', 'Map', gcMap);
600 config.WriteStr ('GameplayCustom', 'GameMode', gcGameMode);
601 config.WriteInt ('GameplayCustom', 'TimeLimit', gcTimeLimit);
602 config.WriteInt ('GameplayCustom', 'GoalLimit', gcGoalLimit);
603 config.WriteInt ('GameplayCustom', 'MaxLives', gcMaxLives);
604 config.WriteInt ('GameplayCustom', 'Players', gcPlayers);
605 config.WriteBool('GameplayCustom', 'TeamDamage', gcTeamDamage);
606 config.WriteBool('GameplayCustom', 'AllowExit', gcAllowExit);
607 config.WriteBool('GameplayCustom', 'WeaponStay', gcWeaponStay);
608 config.WriteBool('GameplayCustom', 'Monsters', gcMonsters);
609 config.WriteStr ('GameplayCustom', 'BotsVS', gcBotsVS);
610 config.WriteBool('GameplayCustom', 'DeathmatchKeys', gcDeathmatchKeys);
611 config.WriteBool('GameplayCustom', 'RespawnItems', gcRespawnItems);
612 config.WriteInt ('GameplayCustom', 'SpawnInvul', gcSpawnInvul);
614 config.SaveFile(FileName);
615 config.Free();
616 end;
618 procedure g_Options_Write_Gameplay_Net(FileName: String);
619 var
620 config: TConfig;
621 begin
622 e_WriteLog('Writing network gameplay config', TMsgType.Notify);
624 config := TConfig.CreateFile(FileName);
626 config.WriteStr ('GameplayNetwork', 'Map', gnMap);
627 config.WriteStr ('GameplayNetwork', 'GameMode', gnGameMode);
628 config.WriteInt ('GameplayNetwork', 'TimeLimit', gnTimeLimit);
629 config.WriteInt ('GameplayNetwork', 'GoalLimit', gnGoalLimit);
630 config.WriteInt ('GameplayNetwork', 'MaxLives', gnMaxLives);
631 config.WriteInt ('GameplayNetwork', 'Players', gnPlayers);
632 config.WriteBool('GameplayNetwork', 'TeamDamage', gnTeamDamage);
633 config.WriteBool('GameplayNetwork', 'AllowExit', gnAllowExit);
634 config.WriteBool('GameplayNetwork', 'WeaponStay', gnWeaponStay);
635 config.WriteBool('GameplayNetwork', 'Monsters', gnMonsters);
636 config.WriteStr ('GameplayNetwork', 'BotsVS', gnBotsVS);
637 config.WriteBool('GameplayNetwork', 'DeathmatchKeys', gnDeathmatchKeys);
638 config.WriteBool('GameplayNetwork', 'RespawnItems', gnRespawnItems);
639 config.WriteInt ('GameplayNetwork', 'SpawnInvul', gnSpawnInvul);
641 config.SaveFile(FileName);
642 config.Free();
643 end;
645 procedure g_Options_Write_Net_Server(FileName: String);
646 var
647 config: TConfig;
648 begin
649 e_WriteLog('Writing server config', TMsgType.Notify);
651 config := TConfig.CreateFile(FileName);
653 config.WriteStr ('Server', 'Name', NetServerName);
654 config.WriteStr ('Server', 'Password', NetPassword);
655 config.WriteInt ('Server', 'Port', NetPort);
656 config.WriteInt ('Server', 'MaxClients', NetMaxClients);
657 config.WriteBool('Server', 'SyncWithMaster', NetUseMaster);
658 config.WriteBool('Server', 'ForwardPorts', NetForwardPorts);
660 config.SaveFile(FileName);
661 config.Free();
662 end;
664 procedure g_Options_Write_Net_Client(FileName: String);
665 var
666 config: TConfig;
667 begin
668 e_WriteLog('Writing client config', TMsgType.Notify);
670 config := TConfig.CreateFile(FileName);
672 config.WriteStr('Client', 'LastIP', NetClientIP);
673 config.WriteInt('Client', 'LastPort', NetClientPort);
675 config.SaveFile(FileName);
676 config.Free();
677 end;
679 procedure g_Options_Commands (p: SSArray);
680 var cmd: AnsiString; i: Integer;
681 begin
682 cmd := LowerCase(p[0]);
683 case cmd of
684 'r_reset':
685 begin
686 sys_EnableVSync(gVSync);
687 gRC_Width := Max(1, gRC_Width);
688 gRC_Height := Max(1, gRC_Height);
689 gBPP := Max(1, gBPP);
690 if sys_SetDisplayMode(gRC_Width, gRC_Height, gBPP, gRC_FullScreen, gRC_Maximized) = True then
691 e_LogWriteln('resolution changed')
692 else
693 e_LogWriteln('resolution not changed')
694 end;
695 'g_language':
696 begin
697 if Length(p) = 2 then
698 begin
699 gAskLanguage := true;
700 gLanguage := LANGUAGE_ENGLISH;
701 case LowerCase(p[1]) of
702 'english':
703 begin
704 gAskLanguage := false;
705 gLanguage := LANGUAGE_ENGLISH;
706 end;
707 'russian':
708 begin
709 gAskLanguage := false;
710 gLanguage := LANGUAGE_RUSSIAN;
711 end;
712 'ask':
713 begin
714 gAskLanguage := true;
715 gLanguage := LANGUAGE_ENGLISH;
716 end;
717 end;
718 g_Language_Set(gLanguage)
719 end
720 else
721 begin
722 e_LogWritefln('usage: %s <English|Russian|Ask>', [cmd])
723 end
724 end;
725 'g_max_particles':
726 begin
727 if Length(p) = 2 then
728 begin
729 i := Max(0, StrToInt(p[1]));
730 g_GFX_SetMax(i)
731 end
732 else if Length(p) = 1 then
733 begin
734 e_LogWritefln('%s', [g_GFX_GetMax()])
735 end
736 else
737 begin
738 e_LogWritefln('usage: %s <n>', [cmd])
739 end
740 end;
741 'g_max_shells':
742 begin
743 if Length(p) = 2 then
744 begin
745 i := Max(0, StrToInt(p[1]));
746 g_Shells_SetMax(i)
747 end
748 else if Length(p) = 1 then
749 begin
750 e_LogWritefln('%s', [g_Shells_GetMax()])
751 end
752 else
753 begin
754 e_LogWritefln('usage: %s <n>', [cmd])
755 end
756 end;
757 'g_max_gibs':
758 begin
759 if Length(p) = 2 then
760 begin
761 i := Max(0, StrToInt(p[1]));
762 g_Gibs_SetMax(i)
763 end
764 else if Length(p) = 1 then
765 begin
766 e_LogWritefln('%s', [g_Gibs_GetMax()])
767 end
768 else
769 begin
770 e_LogWritefln('usage: %s <n>', [cmd])
771 end
772 end;
773 'g_max_corpses':
774 begin
775 if Length(p) = 2 then
776 begin
777 i := Max(0, StrToInt(p[1]));
778 g_Corpses_SetMax(i)
779 end
780 else if Length(p) = 1 then
781 begin
782 e_LogWritefln('%s', [g_Corpses_GetMax()])
783 end
784 else
785 begin
786 e_LogWritefln('usage: %s <n>', [cmd])
787 end
788 end;
789 'g_item_respawn_time':
790 begin
791 if Length(p) = 2 then
792 ITEM_RESPAWNTIME := Max(0, StrToInt(p[1])) * 36
793 else if Length(p) = 1 then
794 e_LogWritefln('%s', [ITEM_RESPAWNTIME div 36])
795 else
796 e_LogWritefln('usage: %s <n>', [cmd])
797 end;
798 end;
799 end;
801 initialization
802 Randomize;
803 machine := Random(10000);
805 (* Video *)
806 conRegVar('r_width', @gRC_Width, '', '');
807 conRegVar('r_height', @gRC_Height, '', '');
808 conRegVar('r_fullscreen', @gRC_FullScreen, '', '');
809 conRegVar('r_maximized', @gRC_Maximized, '', '');
810 conRegVar('r_bpp', @gBPP, '', '');
811 conRegVar('r_vsync', @gVSync, '', '');
812 conRegVar('r_texfilter', @gTextureFilter, '', '');
813 conRegVar('r_npot', @glNPOTOverride, '', '');
815 (* Sound *)
816 conRegVar('s_nosound', @gNoSound, '', '');
817 conRegVar('s_soundvolume', @gSoundLevel, '', '');
818 conRegVar('s_musicvolume', @gMusicLevel, '', '');
819 conRegVar('s_maxsim', @gMaxSimSounds, '', ''); // e_sound_fmod/sdl?
820 conRegVar('s_muteinactive', @gMuteWhenInactive, '', '');
821 conRegVar('s_announcer', @gAnnouncer, '', '');
822 conRegVar('s_sfx', @gSoundEffectsDF, '', '');
823 conRegVar('s_chatsounds', @gUseChatSounds, '', '');
824 {$IFDEF USE_SDLMIXER}
825 conRegVar('sdl_mixer_samplerate', @gsSDLSampleRate, '', '');
826 conRegVar('sdl_mixer_buffersize', @gsSDLBufferSize, '', '');
827 {$ENDIF}
829 (* Game *)
830 conRegVar('g_gibs_count', @gGibsCount, '', '');
831 conRegVar('g_blood_count', @gBloodCount, '', '');
832 conRegVar('g_adv_blood', @gAdvBlood, '', '');
833 conRegVar('g_adv_corpses', @gAdvCorpses, '', '');
834 conRegVar('g_adv_gibs', @gAdvGibs, '', '');
835 conRegVar('r_flash', @gFlash, '', '');
836 conRegVar('r_background', @gDrawBackGround, '', '');
837 conRegVar('g_show_messages', @gShowMessages, '', '');
838 conRegVar('r_revert_players', @gRevertPlayers, '', '');
839 conRegVar('r_chat_bubble', @gChatBubble, '', '');
840 conRegVar('sfs_debug', @wadoptDebug, '', '');
841 conRegVar('sfs_fastmode', @wadoptFast, '', '');
842 conRegVar('g_fast_screenshots', @e_FastScreenshots, '', '');
843 conRegVar('g_default_megawad', @gDefaultMegawadStart, '', '');
844 conRegVar('g_save_stats', @gSaveStats, '', '');
845 conRegVar('g_screenshot_stats', @gScreenshotStats, '', '');
846 end.