DEADSOFTWARE

979fe4510cd9d9144e8e3faff46a47a44cc6fe41
[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;
23 function GenPlayerName (n: Integer): String;
25 procedure g_Options_SetDefault();
26 procedure g_Options_Read(FileName: String);
27 procedure g_Options_Write(FileName: String);
28 procedure g_Options_Write_Language(FileName: String);
29 procedure g_Options_Write_Video(FileName: String);
30 procedure g_Options_Write_Gameplay_Custom(FileName: String);
31 procedure g_Options_Write_Gameplay_Net(FileName: String);
32 procedure g_Options_Write_Net_Server(FileName: String);
33 procedure g_Options_Write_Net_Client(FileName: String);
35 const DF_Default_Megawad_Start = 'megawads/DOOM2D.WAD:\MAP01';
37 var
38 // gGameControls: TControls;
39 gScreenWidth: Word;
40 gScreenHeight: Word;
41 gWinRealPosX: Integer;
42 gWinRealPosY: Integer;
43 gBPP: Byte;
44 gFreq: Byte;
45 gFullscreen: Boolean;
46 gWinMaximized: Boolean;
47 gVSync: Boolean;
48 glLegacyNPOT: Boolean;
49 gTextureFilter: Boolean;
50 gNoSound: Boolean;
51 gSoundLevel: Byte;
52 gMusicLevel: Byte;
53 gMaxSimSounds: Byte;
54 gMuteWhenInactive: Boolean;
55 gAdvCorpses: Boolean;
56 gAdvBlood: Boolean;
57 gAdvGibs: Boolean;
58 gGibsCount: Integer;
59 gBloodCount: Byte;
60 gFlash: Byte;
61 gDrawBackGround: Boolean;
62 gShowMessages: Boolean;
63 gRevertPlayers: Boolean;
64 gLanguage: String;
65 gAskLanguage: Boolean;
66 gcMap: String;
67 gcGameMode: String;
68 gcTimeLimit: Word;
69 gcGoalLimit: Word;
70 gcMaxLives: Byte;
71 gcPlayers: Byte;
72 gcTeamDamage: Boolean;
73 gcAllowExit: Boolean;
74 gcWeaponStay: Boolean;
75 gcMonsters: Boolean;
76 gcBotsVS: String;
77 gnMap: String;
78 gnGameMode: String;
79 gnTimeLimit: Word;
80 gnGoalLimit: Word;
81 gnMaxLives: Byte;
82 gnPlayers: Byte;
83 gnTeamDamage: Boolean;
84 gnAllowExit: Boolean;
85 gnWeaponStay: Boolean;
86 gnMonsters: Boolean;
87 gnBotsVS: String;
88 gsSDLSampleRate: Integer;
89 gsSDLBufferSize: Integer;
90 gSFSDebug: Boolean;
91 gSFSFastMode: Boolean;
92 gDefaultMegawadStart: AnsiString;
93 gBerserkAutoswitch: Boolean;
95 implementation
97 uses
98 {$INCLUDE ../nogl/noGLuses.inc}
99 e_log, e_input, g_console, g_window, g_sound, g_gfx, g_player, Math,
100 g_map, g_net, g_netmaster, SysUtils, CONFIG, g_game, g_main, e_texture,
101 g_items, wadreader, e_graphics, g_touch, SDL2, envvars;
103 var
104 machine: Integer;
106 function GenPlayerName (n: Integer): String;
107 begin
108 ASSERT(n >= 1);
109 Result := GetUserName;
110 if Result = '' then
111 Result := 'Player' + IntToStr(machine MOD 10000);
112 if n = 1 then
113 Result := Copy(Result, 1, 12) + ' '
114 else
115 Result := Copy(Result, 1, 10) + ' ' + IntToStr(n)
116 end;
118 procedure g_Options_SetDefaultVideo;
119 var
120 target, closest, display: TSDL_DisplayMode;
121 percentage: Integer;
122 begin
123 (* Display 0 = Primary display *)
124 SDL_GetDesktopDisplayMode(0, @display);
125 {$IF DEFINED(ANDROID)}
126 gScreenWidth := display.w;
127 gScreenHeight := display.h;
128 //gBPP := SDL_BITSPERPIXEL(dispaly.format);
129 gBPP := 32;
130 gFullScreen := True; (* rotation not allowed? *)
131 {$ELSE}
132 (* Window must be smaller than display *)
133 closest.w := display.w;
134 closest.h := display.h;
135 percentage := 75;
136 while (display.w - closest.w < 48) or (display.h - closest.h < 48) do
137 begin
138 if percentage < 25 then
139 begin
140 closest.w := display.w * 75 div 100;
141 closest.h := display.h * 75 div 100;
142 break;
143 end;
144 target.w := display.w * percentage div 100;
145 target.h := display.h * percentage div 100;
146 target.format := 0; (* didn't care *)
147 target.refresh_rate := 0; (* didn't care *)
148 target.driverdata := nil; (* init *)
149 SDL_GetClosestDisplayMode(0, @target, @closest);
150 Dec(percentage);
151 end;
152 gScreenWidth := closest.w;
153 gScreenHeight := closest.h;
154 //gBPP := SDL_BITSPERPIXEL(closest.format); (* Resolution list didn't work for some reason *)
155 gBPP := 32;
156 gFullScreen := False;
157 {$ENDIF}
158 (* Must be positioned on primary display *)
159 gWinRealPosX := SDL_WINDOWPOS_CENTERED;
160 gWinRealPosY := SDL_WINDOWPOS_CENTERED;
161 gWinMaximized := False;
162 gVSync := True;
163 gTextureFilter := True;
164 glLegacyNPOT := False;
165 e_LogWriteLn('g_Options_SetDefaultVideo: w = ' + IntToStr(gScreenWidth) + ' h = ' + IntToStr(gScreenHeight));
166 g_Console_ResetBinds;
167 end;
169 procedure g_Options_SetDefault();
170 var
171 i: Integer;
172 begin
173 (* section Sound *)
174 gNoSound := False;
175 gSoundLevel := 75;
176 gMusicLevel := 65;
177 gMaxSimSounds := 8;
178 gMuteWhenInactive := False;
179 gAnnouncer := ANNOUNCE_MEPLUS;
180 gSoundEffectsDF := True;
181 gUseChatSounds := True;
182 gsSDLSampleRate := 44100;
183 gsSDLBufferSize := 2048;
185 g_Sound_SetupAllVolumes(gSoundLevel, gMusicLevel);
187 with gPlayer1Settings do
188 begin
189 Name := GenPlayerName(1);
190 Model := STD_PLAYER_MODEL;
191 Color.R := PLAYER1_DEF_COLOR.R;
192 Color.G := PLAYER1_DEF_COLOR.G;
193 Color.B := PLAYER1_DEF_COLOR.B;
194 Team := TEAM_RED;
195 end;
197 with gPlayer2Settings do
198 begin
199 Name := GenPlayerName(2);
200 Model := STD_PLAYER_MODEL;
201 Color.R := PLAYER2_DEF_COLOR.R;
202 Color.G := PLAYER2_DEF_COLOR.G;
203 Color.B := PLAYER2_DEF_COLOR.B;
204 Team := TEAM_BLUE;
205 end;
207 (* section Joysticks *)
208 for i := 0 to e_MaxJoys - 1 do
209 begin
210 e_JoystickDeadzones[i] := 8192
211 end;
213 (* section Game *)
214 g_GFX_SetMax(2000);
215 g_Shells_SetMax(300);
216 g_Gibs_SetMax(150);
217 g_Corpses_SetMax(20);
218 gGibsCount := 32;
219 ITEM_RESPAWNTIME := 60 * 36;
220 gBloodCount := 4;
221 gAdvBlood := True;
222 gAdvCorpses := True;
223 gAdvGibs := True;
224 gFlash := 1;
225 gDrawBackGround := True;
226 gShowMessages := True;
227 gRevertPlayers := False;
228 gChatBubble := 4;
229 gSFSDebug := False;
230 gSFSFastMode := False;
231 e_FastScreenshots := True;
232 gDefaultMegawadStart := DF_Default_Megawad_Start;
233 gBerserkAutoswitch := True;
234 g_dbg_scale := 1.0;
236 gAskLanguage := True;
237 gLanguage := LANGUAGE_ENGLISH;
239 (* section GameplayCustom *)
240 gcMap := '';
241 gcGameMode := _lc[I_MENU_GAME_TYPE_DM];
242 gcTimeLimit := 0;
243 gcGoalLimit := 0;
244 gcMaxLives := 0;
245 gcPlayers := 1;
246 gcTeamDamage := False;
247 gcAllowExit := True;
248 gcWeaponStay := False;
249 gcMonsters := False;
250 gcBotsVS := 'Everybody';
252 (* section GameplayNetwork *)
253 gnMap := '';
254 gnGameMode := _lc[I_MENU_GAME_TYPE_DM];
255 gnTimeLimit := 0;
256 gnGoalLimit := 0;
257 gnMaxLives := 0;
258 gnPlayers := 1;
259 gnTeamDamage := False;
260 gnAllowExit := True;
261 gnWeaponStay := False;
262 gnMonsters := False;
263 gnBotsVS := 'Everybody';
265 (* section MasterServer *)
266 NetSlistIP := 'mpms.doom2d.org';
267 NetSlistPort := 25665;
268 g_Net_Slist_Set(NetSlistIP, NetSlistPort);
270 (* section Server *)
271 NetServerName := 'Unnamed Server';
272 NetPassword := '';
273 NetPort := 25666;
274 NetMaxClients := 16;
275 NetAllowRCON := False;
276 NetRCONPassword := 'default';
277 NetUseMaster := True;
278 NetUpdateRate := 0;
279 NetRelupdRate := 18;
280 NetMasterRate := 60000;
281 NetForwardPorts := False;
283 (* section Client *)
284 NetInterpLevel := 2;
285 NetForcePlayerUpdate := False;
286 NetPredictSelf := True;
287 NetClientIP := '127.0.0.1';
288 NetClientPort := NetPort;
289 end;
291 procedure g_Options_Read(FileName: String);
292 var
293 i: Integer;
294 config: TConfig;
295 section: String;
297 procedure ReadInteger (VAR v: Integer; param: String; minv: Integer = Low(Integer); maxv: Integer = High(Integer));
298 begin
299 v := Max(Min(config.ReadInt(section, param, v), maxv), minv)
300 end;
302 procedure ReadInteger (VAR v: LongWord; param: String; minv: LongWord = Low(LongWord); maxv: LongWord = High(LongWord)); overload;
303 begin
304 v := Max(Min(config.ReadInt(section, param, v), maxv), minv)
305 end;
307 procedure ReadInteger (VAR v: Word; param: String; minv: Word = Low(Word); maxv: Word = High(Word)); overload;
308 begin
309 v := Max(Min(config.ReadInt(section, param, v), maxv), minv)
310 end;
312 procedure ReadInteger (VAR v: Byte; param: String; minv: Byte = Low(Byte); maxv: Byte = High(Byte)); overload;
313 begin
314 v := Max(Min(config.ReadInt(section, param, v), maxv), minv)
315 end;
317 procedure ReadBoolean (VAR v: Boolean; param: String);
318 begin
319 v := config.ReadBool(section, param, v)
320 end;
322 procedure ReadString (VAR v: String; param: String);
323 begin
324 v := config.ReadStr(section, param, v)
325 end;
327 begin
328 gAskLanguage := True;
329 e_WriteLog('Reading config', TMsgType.Notify);
330 g_Options_SetDefault;
332 if FileExists(FileName) = False then
333 begin
334 e_WriteLog('Config file '+FileName+' not found', TMsgType.Warning);
335 g_Options_SetDefaultVideo;
336 Exit
337 end;
339 config := TConfig.CreateFile(FileName);
341 section := 'Video';
342 ReadInteger(gScreenWidth, 'ScreenWidth', 0);
343 ReadInteger(gScreenHeight, 'ScreenHeight', 0);
344 ReadInteger(gWinRealPosX, 'WinPosX', 60);
345 ReadInteger(gWinRealPosY, 'WinPosY', 60);
346 ReadBoolean(gFullScreen, 'Fullscreen');
347 ReadBoolean(gWinMaximized, 'Maximized');
348 ReadInteger(gBPP, 'BPP', 0);
349 ReadInteger(gFreq, 'Freq', 0);
350 ReadBoolean(gVSync, 'VSync');
351 ReadBoolean(gTextureFilter, 'TextureFilter');
352 ReadBoolean(glLegacyNPOT, 'LegacyCompatible');
354 section := 'Sound';
355 ReadBoolean(gNoSound, 'NoSound');
356 ReadInteger(gSoundLevel, 'SoundLevel', 0, 255);
357 ReadInteger(gMusicLevel, 'MusicLevel', 0, 255);
358 ReadInteger(gMaxSimSounds, 'MaxSimSounds', 2, 66);
359 ReadBoolean(gMuteWhenInactive, 'MuteInactive');
360 ReadInteger(gAnnouncer, 'Announcer', ANNOUNCE_NONE, ANNOUNCE_ALL);
361 ReadBoolean(gSoundEffectsDF, 'SoundEffectsDF');
362 ReadBoolean(gUseChatSounds, 'ChatSounds');
363 ReadInteger(gsSDLSampleRate, 'SDLSampleRate', 11025, 96000);
364 ReadInteger(gsSDLBufferSize, 'SDLBufferSize', 64, 16384);
366 section := 'Player1';
367 with gPlayer1Settings do
368 begin
369 ReadString(Name, 'name');
370 ReadString(Model, 'model');
371 ReadInteger(Color.R, 'red', 0, 255);
372 ReadInteger(Color.G, 'green', 0, 255);
373 ReadInteger(Color.B, 'blue', 0, 255);
374 ReadInteger(Team, 'team');
375 if (Team < TEAM_RED) or (Team > TEAM_BLUE) then
376 Team := TEAM_RED;
377 end;
379 section := 'Player2';
380 with gPlayer2Settings do
381 begin
382 ReadString(Name, 'name');
383 ReadString(Model, 'model');
384 ReadInteger(Color.R, 'red', 0, 255);
385 ReadInteger(Color.G, 'green', 0, 255);
386 ReadInteger(Color.B, 'blue', 0, 255);
387 ReadInteger(Team, 'team');
388 if (Team < TEAM_RED) or (Team > TEAM_BLUE) then
389 Team := TEAM_RED;
390 end;
392 section := 'Joysticks';
393 for i := 0 to e_MaxJoys - 1 do
394 begin
395 ReadInteger(e_JoystickDeadzones[i], 'Deadzone' + IntToStr(i))
396 end;
398 section := 'Game';
399 ReadInteger(i, 'MaxParticles', 0, 50000); g_GFX_SetMax(i);
400 ReadInteger(i, 'MaxShells', 0, 600); g_Shells_SetMax(i);
401 ReadInteger(i, 'MaxGibs', 0, 500); g_Gibs_SetMax(i);
402 ReadInteger(i, 'MaxCorpses', 0, 100); g_Corpses_SetMax(i);
403 ReadInteger(i, 'GibsCount');
404 case i of
405 0: gGibsCount := 0;
406 1: gGibsCount := 8;
407 2: gGibsCount := 16;
408 3: gGibsCount := 32;
409 else gGibsCount := 48;
410 end;
411 i := ITEM_RESPAWNTIME div 36; ReadInteger(i, 'ItemRespawnTime', 0); ITEM_RESPAWNTIME := i * 36;
412 ReadInteger(gBloodCount, 'BloodCount', 0, 4);
413 ReadBoolean(gAdvBlood, 'AdvancesBlood');
414 ReadBoolean(gAdvCorpses, 'AdvancesCorpses');
415 ReadBoolean(gAdvGibs, 'AdvancesGibs');
416 ReadInteger(gFlash, 'Flash', 0, 2);
417 ReadBoolean(gDrawBackGround, 'BackGround');
418 ReadBoolean(gShowMessages, 'Messages');
419 ReadBoolean(gRevertPlayers, 'RevertPlayers');
420 ReadInteger(gChatBubble, 'ChatBubble', 0, 4);
421 ReadBoolean(gSFSDebug, 'SFSDebug'); wadoptDebug := gSFSDebug;
422 ReadBoolean(gSFSFastMode, 'SFSFastMode'); wadoptFast := gSFSFastMode;
423 ReadBoolean(e_FastScreenshots, 'FastScreenshots');
424 ReadString(gDefaultMegawadStart, 'DefaultMegawadStart');
425 ReadBoolean(gBerserkAutoswitch, 'BerserkAutoswitching');
426 i := Trunc(g_dbg_scale * 100); ReadInteger(i, 'Scale', 100); g_dbg_scale := i / 100;
427 ReadString(gLanguage, 'Language');
428 if (gLanguage = LANGUAGE_RUSSIAN) or (gLanguage = LANGUAGE_ENGLISH) then
429 gAskLanguage := False
430 else
431 gLanguage := LANGUAGE_ENGLISH;
433 section := 'GameplayCustom';
434 ReadString(gcMap, 'Map');
435 ReadString(gcGameMode, 'GameMode');
436 ReadInteger(gcTimeLimit, 'TimeLimit', 0, 65535);
437 ReadInteger(gcGoalLimit, 'GoalLimit', 0, 65535);
438 ReadInteger(gcMaxLives, 'MaxLives', 0, 255);
439 ReadInteger(gcPlayers, 'Players', 0, 2);
440 ReadBoolean(gcTeamDamage, 'TeamDamage');
441 ReadBoolean(gcAllowExit, 'AllowExit');
442 ReadBoolean(gcWeaponStay, 'WeaponStay');
443 ReadBoolean(gcMonsters, 'Monsters');
444 ReadString(gcBotsVS, 'BotsVS');
446 with gGameSettings do
447 begin
448 GameMode := g_Game_TextToMode(gcGameMode);
449 if GameMode = GM_NONE then
450 GameMode := GM_DM;
451 if GameMode = GM_SINGLE then
452 GameMode := GM_COOP;
453 TimeLimit := gcTimeLimit;
454 GoalLimit := gcGoalLimit;
455 MaxLives := gcMaxLives;
457 Options := 0;
458 if gcTeamDamage then
459 Options := Options or GAME_OPTION_TEAMDAMAGE;
460 if gcAllowExit then
461 Options := Options or GAME_OPTION_ALLOWEXIT;
462 if gcWeaponStay then
463 Options := Options or GAME_OPTION_WEAPONSTAY;
464 if gcMonsters then
465 Options := Options or GAME_OPTION_MONSTERS;
466 if gcBotsVS = 'Everybody' then
467 Options := Options or GAME_OPTION_BOTVSPLAYER or GAME_OPTION_BOTVSMONSTER;
468 if gcBotsVS = 'Players' then
469 Options := Options or GAME_OPTION_BOTVSPLAYER;
470 if gcBotsVS = 'Monsters' then
471 Options := Options or GAME_OPTION_BOTVSMONSTER;
472 end;
474 section := 'GameplayNetwork';
475 ReadString(gnMap, 'Map');
476 ReadString(gnGameMode, 'GameMode');
477 ReadInteger(gnTimeLimit, 'TimeLimit', 0, 65535);
478 ReadInteger(gnGoalLimit, 'GoalLimit', 0, 65535);
479 ReadInteger(gnMaxLives, 'MaxLives', 0, 255);
480 ReadInteger(gnPlayers, 'Players', 0, 2);
481 ReadBoolean(gnTeamDamage, 'TeamDamage');
482 ReadBoolean(gnAllowExit, 'AllowExit');
483 ReadBoolean(gnWeaponStay, 'WeaponStay');
484 ReadBoolean(gnMonsters, 'Monsters');
485 ReadString(gnBotsVS, 'BotsVS');
487 section := 'MasterServer';
488 ReadString(NetSlistIP, 'IP');
489 ReadInteger(NetSlistPort, 'Port', 0, 65535);
490 g_Net_Slist_Set(NetSlistIP, NetSlistPort);
492 section := 'Server';
493 ReadString(NetServerName, 'Name');
494 ReadString(NetPassword, 'Password');
495 ReadInteger(NetPort, 'Port', 0, 65535);
496 ReadInteger(NetMaxClients, 'MaxClients', 0, NET_MAXCLIENTS);
497 ReadBoolean(NetAllowRCON, 'RCON');
498 ReadString(NetRCONPassword, 'RCONPassword');
499 ReadBoolean(NetUseMaster, 'SyncWithMaster');
500 ReadInteger(NetUpdateRate, 'UpdateInterval', 0);
501 ReadInteger(NetRelupdRate, 'ReliableUpdateInterval', 0);
502 ReadInteger(NetMasterRate, 'MasterSyncInterval', 1);
503 ReadBoolean(NetForwardPorts, 'ForwardPorts');
505 section := 'Client';
506 ReadInteger(NetInterpLevel, 'InterpolationSteps', 0);
507 ReadBoolean(NetForcePlayerUpdate, 'ForcePlayerUpdate');
508 ReadBoolean(NetPredictSelf, 'PredictSelf');
509 ReadString(NetClientIP, 'LastIP');
510 ReadInteger(NetClientPort, 'LastPort', 0, 65535);
512 config.Free();
514 //if gTextureFilter then TEXTUREFILTER := GL_LINEAR else TEXTUREFILTER := GL_NEAREST;
515 end;
517 procedure g_Options_Write(FileName: String);
518 var
519 config: TConfig;
520 i: Integer;
521 begin
522 e_WriteLog('Writing config', TMsgType.Notify);
524 config := TConfig.CreateFile(FileName);
526 config.WriteInt('Video', 'ScreenWidth', gScreenWidth);
527 config.WriteInt('Video', 'ScreenHeight', gScreenHeight);
528 config.WriteInt('Video', 'WinPosX', gWinRealPosX);
529 config.WriteInt('Video', 'WinPosY', gWinRealPosY);
530 config.WriteBool('Video', 'Fullscreen', gFullScreen);
531 config.WriteBool('Video', 'Maximized', gWinMaximized);
532 config.WriteInt('Video', 'BPP', gBPP);
533 config.WriteBool('Video', 'VSync', gVSync);
534 config.WriteBool('Video', 'TextureFilter', gTextureFilter);
535 config.WriteBool('Video', 'LegacyCompatible', glLegacyNPOT);
537 config.WriteBool('Sound', 'NoSound', gNoSound);
538 config.WriteInt('Sound', 'SoundLevel', gSoundLevel);
539 config.WriteInt('Sound', 'MusicLevel', gMusicLevel);
540 config.WriteInt('Sound', 'MaxSimSounds', gMaxSimSounds);
541 config.WriteBool('Sound', 'MuteInactive', gMuteWhenInactive);
542 config.WriteInt('Sound', 'Announcer', gAnnouncer);
543 config.WriteBool('Sound', 'SoundEffectsDF', gSoundEffectsDF);
544 config.WriteBool('Sound', 'ChatSounds', gUseChatSounds);
545 config.WriteInt('Sound', 'SDLSampleRate', gsSDLSampleRate);
546 config.WriteInt('Sound', 'SDLBufferSize', gsSDLBufferSize);
548 with config, gPlayer1Settings do
549 begin
550 WriteStr('Player1', 'Name', Name);
551 WriteStr('Player1', 'model', Model);
552 WriteInt('Player1', 'red', Color.R);
553 WriteInt('Player1', 'green', Color.G);
554 WriteInt('Player1', 'blue', Color.B);
555 WriteInt('Player1', 'team', Team);
556 end;
558 with config, gPlayer2Settings do
559 begin
560 WriteStr('Player2', 'Name', Name);
561 WriteStr('Player2', 'model', Model);
562 WriteInt('Player2', 'red', Color.R);
563 WriteInt('Player2', 'green', Color.G);
564 WriteInt('Player2', 'blue', Color.B);
565 WriteInt('Player2', 'team', Team);
566 end;
568 for i := 0 to e_MaxJoys-1 do
569 config.WriteInt('Joysticks', 'Deadzone' + IntToStr(i), e_JoystickDeadzones[i]);
571 with config do
572 case gGibsCount of
573 0: config.WriteInt('Game', 'GibsCount', 0);
574 8: config.WriteInt('Game', 'GibsCount', 1);
575 16: config.WriteInt('Game', 'GibsCount', 2);
576 32: config.WriteInt('Game', 'GibsCount', 3);
577 else config.WriteInt('Game', 'GibsCount', 4);
578 end;
580 config.WriteInt('Game', 'ItemRespawnTime', ITEM_RESPAWNTIME div 36);
581 config.WriteInt('Game', 'MaxParticles', g_GFX_GetMax());
582 config.WriteInt('Game', 'MaxShells', g_Shells_GetMax());
583 config.WriteInt('Game', 'MaxGibs', g_Gibs_GetMax());
584 config.WriteInt('Game', 'MaxCorpses', g_Corpses_GetMax());
585 config.WriteInt('Game', 'BloodCount', gBloodCount);
586 config.WriteBool('Game', 'AdvancesBlood', gAdvBlood);
587 config.WriteBool('Game', 'AdvancesCorpses', gAdvCorpses);
588 config.WriteBool('Game', 'AdvancesGibs', gAdvGibs);
589 config.WriteInt('Game', 'Flash', gFlash);
590 config.WriteBool('Game', 'BackGround', gDrawBackGround);
591 config.WriteBool('Game', 'Messages', gShowMessages);
592 config.WriteBool('Game', 'RevertPlayers', gRevertPlayers);
593 config.WriteInt('Game', 'ChatBubble', gChatBubble);
594 config.WriteBool('Game', 'SFSDebug', gSFSDebug);
595 config.WriteBool('Game', 'SFSFastMode', gSFSFastMode);
596 config.WriteBool('Game', 'FastScreenshots', e_FastScreenshots);
597 config.WriteStr('Game', 'DefaultMegawadStart', gDefaultMegawadStart);
598 config.WriteBool('Game', 'BerserkAutoswitching', gBerserkAutoswitch);
599 config.WriteInt('Game', 'Scale', Round(g_dbg_scale * 100));
601 config.WriteStr ('GameplayCustom', 'Map', gcMap);
602 config.WriteStr ('GameplayCustom', 'GameMode', gcGameMode);
603 config.WriteInt ('GameplayCustom', 'TimeLimit', gcTimeLimit);
604 config.WriteInt ('GameplayCustom', 'GoalLimit', gcGoalLimit);
605 config.WriteInt ('GameplayCustom', 'MaxLives', gcMaxLives);
606 config.WriteInt ('GameplayCustom', 'Players', gcPlayers);
607 config.WriteBool('GameplayCustom', 'TeamDamage', gcTeamDamage);
608 config.WriteBool('GameplayCustom', 'AllowExit', gcAllowExit);
609 config.WriteBool('GameplayCustom', 'WeaponStay', gcWeaponStay);
610 config.WriteBool('GameplayCustom', 'Monsters', gcMonsters);
611 config.WriteStr ('GameplayCustom', 'BotsVS', gcBotsVS);
613 config.WriteStr ('GameplayNetwork', 'Map', gnMap);
614 config.WriteStr ('GameplayNetwork', 'GameMode', gnGameMode);
615 config.WriteInt ('GameplayNetwork', 'TimeLimit', gnTimeLimit);
616 config.WriteInt ('GameplayNetwork', 'GoalLimit', gnGoalLimit);
617 config.WriteInt ('GameplayNetwork', 'MaxLives', gnMaxLives);
618 config.WriteInt ('GameplayNetwork', 'Players', gnPlayers);
619 config.WriteBool('GameplayNetwork', 'TeamDamage', gnTeamDamage);
620 config.WriteBool('GameplayNetwork', 'AllowExit', gnAllowExit);
621 config.WriteBool('GameplayNetwork', 'WeaponStay', gnWeaponStay);
622 config.WriteBool('GameplayNetwork', 'Monsters', gnMonsters);
623 config.WriteStr ('GameplayNetwork', 'BotsVS', gnBotsVS);
625 config.WriteStr('MasterServer', 'IP', NetSlistIP);
626 config.WriteInt('MasterServer', 'Port', NetSlistPort);
628 config.WriteStr ('Server', 'Name', NetServerName);
629 config.WriteStr ('Server', 'Password', NetPassword);
630 config.WriteInt ('Server', 'Port', NetPort);
631 config.WriteInt ('Server', 'MaxClients', NetMaxClients);
632 config.WriteBool('Server', 'RCON', NetAllowRCON);
633 config.WriteStr ('Server', 'RCONPassword', NetRCONPassword);
634 config.WriteBool('Server', 'SyncWithMaster', NetUseMaster);
635 config.WriteBool('Server', 'ForwardPorts', NetForwardPorts);
636 config.WriteInt ('Server', 'UpdateInterval', NetUpdateRate);
637 config.WriteInt ('Server', 'ReliableUpdateInterval', NetRelupdRate);
638 config.WriteInt ('Server', 'MasterSyncInterval', NetMasterRate);
640 config.WriteInt ('Client', 'InterpolationSteps', NetInterpLevel);
641 config.WriteBool ('Client', 'ForcePlayerUpdate', NetForcePlayerUpdate);
642 config.WriteBool ('Client', 'PredictSelf', NetPredictSelf);
643 config.WriteStr ('Client', 'LastIP', NetClientIP);
644 config.WriteInt ('Client', 'LastPort', NetClientPort);
646 config.SaveFile(FileName);
647 config.Free();
648 end;
650 procedure g_Options_Write_Language(FileName: String);
651 var
652 config: TConfig;
653 begin
654 e_WriteLog('Writing language config', TMsgType.Notify);
656 config := TConfig.CreateFile(FileName);
657 config.WriteStr('Game', 'Language', gLanguage);
658 config.SaveFile(FileName);
659 config.Free();
660 end;
662 procedure g_Options_Write_Video(FileName: String);
663 var
664 config: TConfig;
665 sW, sH: Integer;
666 begin
667 e_WriteLog('Writing resolution to config', TMsgType.Notify);
669 config := TConfig.CreateFile(FileName);
671 if gWinMaximized and (not gFullscreen) then
672 begin
673 sW := gWinSizeX;
674 sH := gWinSizeY;
675 end
676 else
677 begin
678 sW := gScreenWidth;
679 sH := gScreenHeight;
680 end;
681 e_LogWritefln(' (ws=%dx%d) (ss=%dx%d)', [gWinSizeX, gWinSizeY, gScreenWidth, gScreenHeight]);
683 config.WriteInt('Video', 'ScreenWidth', sW);
684 config.WriteInt('Video', 'ScreenHeight', sH);
685 config.WriteInt('Video', 'WinPosX', gWinRealPosX);
686 config.WriteInt('Video', 'WinPosY', gWinRealPosY);
687 config.WriteBool('Video', 'Fullscreen', gFullscreen);
688 config.WriteBool('Video', 'Maximized', gWinMaximized);
690 config.WriteStr('Player1', 'Name', gPlayer1Settings.Name);
691 config.WriteStr('Player2', 'Name', gPlayer2Settings.Name);
693 config.SaveFile(FileName);
694 config.Free();
695 end;
697 procedure g_Options_Write_Gameplay_Custom(FileName: String);
698 var
699 config: TConfig;
700 begin
701 e_WriteLog('Writing custom gameplay config', TMsgType.Notify);
703 config := TConfig.CreateFile(FileName);
705 config.WriteStr ('GameplayCustom', 'Map', gcMap);
706 config.WriteStr ('GameplayCustom', 'GameMode', gcGameMode);
707 config.WriteInt ('GameplayCustom', 'TimeLimit', gcTimeLimit);
708 config.WriteInt ('GameplayCustom', 'GoalLimit', gcGoalLimit);
709 config.WriteInt ('GameplayCustom', 'MaxLives', gcMaxLives);
710 config.WriteInt ('GameplayCustom', 'Players', gcPlayers);
711 config.WriteBool('GameplayCustom', 'TeamDamage', gcTeamDamage);
712 config.WriteBool('GameplayCustom', 'AllowExit', gcAllowExit);
713 config.WriteBool('GameplayCustom', 'WeaponStay', gcWeaponStay);
714 config.WriteBool('GameplayCustom', 'Monsters', gcMonsters);
715 config.WriteStr ('GameplayCustom', 'BotsVS', gcBotsVS);
717 config.SaveFile(FileName);
718 config.Free();
719 end;
721 procedure g_Options_Write_Gameplay_Net(FileName: String);
722 var
723 config: TConfig;
724 begin
725 e_WriteLog('Writing network gameplay config', TMsgType.Notify);
727 config := TConfig.CreateFile(FileName);
729 config.WriteStr ('GameplayNetwork', 'Map', gnMap);
730 config.WriteStr ('GameplayNetwork', 'GameMode', gnGameMode);
731 config.WriteInt ('GameplayNetwork', 'TimeLimit', gnTimeLimit);
732 config.WriteInt ('GameplayNetwork', 'GoalLimit', gnGoalLimit);
733 config.WriteInt ('GameplayNetwork', 'MaxLives', gnMaxLives);
734 config.WriteInt ('GameplayNetwork', 'Players', gnPlayers);
735 config.WriteBool('GameplayNetwork', 'TeamDamage', gnTeamDamage);
736 config.WriteBool('GameplayNetwork', 'AllowExit', gnAllowExit);
737 config.WriteBool('GameplayNetwork', 'WeaponStay', gnWeaponStay);
738 config.WriteBool('GameplayNetwork', 'Monsters', gnMonsters);
739 config.WriteStr ('GameplayNetwork', 'BotsVS', gnBotsVS);
741 config.SaveFile(FileName);
742 config.Free();
743 end;
745 procedure g_Options_Write_Net_Server(FileName: String);
746 var
747 config: TConfig;
748 begin
749 e_WriteLog('Writing server config', TMsgType.Notify);
751 config := TConfig.CreateFile(FileName);
753 config.WriteStr ('Server', 'Name', NetServerName);
754 config.WriteStr ('Server', 'Password', NetPassword);
755 config.WriteInt ('Server', 'Port', NetPort);
756 config.WriteInt ('Server', 'MaxClients', NetMaxClients);
757 config.WriteBool('Server', 'SyncWithMaster', NetUseMaster);
758 config.WriteBool('Server', 'ForwardPorts', NetForwardPorts);
760 config.SaveFile(FileName);
761 config.Free();
762 end;
764 procedure g_Options_Write_Net_Client(FileName: String);
765 var
766 config: TConfig;
767 begin
768 e_WriteLog('Writing client config', TMsgType.Notify);
770 config := TConfig.CreateFile(FileName);
772 config.WriteStr('Client', 'LastIP', NetClientIP);
773 config.WriteInt('Client', 'LastPort', NetClientPort);
775 config.SaveFile(FileName);
776 config.Free();
777 end;
779 initialization
780 Randomize;
781 machine := Random(10000)
782 end.