DEADSOFTWARE

changed license to GPLv3 only; sorry, no trust to FSF anymore
[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 gPlayerIndicator := True;
230 gSFSDebug := False;
231 gSFSFastMode := False;
232 e_FastScreenshots := True;
233 gDefaultMegawadStart := DF_Default_Megawad_Start;
234 gBerserkAutoswitch := True;
235 g_dbg_scale := 1.0;
237 gAskLanguage := True;
238 gLanguage := LANGUAGE_ENGLISH;
240 (* section GameplayCustom *)
241 gcMap := '';
242 gcGameMode := _lc[I_MENU_GAME_TYPE_DM];
243 gcTimeLimit := 0;
244 gcGoalLimit := 0;
245 gcMaxLives := 0;
246 gcPlayers := 1;
247 gcTeamDamage := False;
248 gcAllowExit := True;
249 gcWeaponStay := False;
250 gcMonsters := False;
251 gcBotsVS := 'Everybody';
253 (* section GameplayNetwork *)
254 gnMap := '';
255 gnGameMode := _lc[I_MENU_GAME_TYPE_DM];
256 gnTimeLimit := 0;
257 gnGoalLimit := 0;
258 gnMaxLives := 0;
259 gnPlayers := 1;
260 gnTeamDamage := False;
261 gnAllowExit := True;
262 gnWeaponStay := False;
263 gnMonsters := False;
264 gnBotsVS := 'Everybody';
266 (* section MasterServer *)
267 NetSlistIP := 'mpms.doom2d.org';
268 NetSlistPort := 25665;
269 g_Net_Slist_Set(NetSlistIP, NetSlistPort);
271 (* section Server *)
272 NetServerName := 'Unnamed Server';
273 NetPassword := '';
274 NetPort := 25666;
275 NetMaxClients := 16;
276 NetAllowRCON := False;
277 NetRCONPassword := 'default';
278 NetUseMaster := True;
279 NetUpdateRate := 0;
280 NetRelupdRate := 18;
281 NetMasterRate := 60000;
282 NetForwardPorts := False;
284 (* section Client *)
285 NetInterpLevel := 2;
286 NetForcePlayerUpdate := False;
287 NetPredictSelf := True;
288 NetClientIP := '127.0.0.1';
289 NetClientPort := NetPort;
290 end;
292 procedure g_Options_Read(FileName: String);
293 var
294 i: Integer;
295 config: TConfig;
296 section: String;
298 procedure ReadInteger (VAR v: Integer; param: String; minv: Integer = Low(Integer); maxv: Integer = High(Integer));
299 begin
300 v := Max(Min(config.ReadInt(section, param, v), maxv), minv)
301 end;
303 procedure ReadInteger (VAR v: LongWord; param: String; minv: LongWord = Low(LongWord); maxv: LongWord = High(LongWord)); overload;
304 begin
305 v := Max(Min(config.ReadInt(section, param, v), maxv), minv)
306 end;
308 procedure ReadInteger (VAR v: Word; param: String; minv: Word = Low(Word); maxv: Word = High(Word)); overload;
309 begin
310 v := Max(Min(config.ReadInt(section, param, v), maxv), minv)
311 end;
313 procedure ReadInteger (VAR v: Byte; param: String; minv: Byte = Low(Byte); maxv: Byte = High(Byte)); overload;
314 begin
315 v := Max(Min(config.ReadInt(section, param, v), maxv), minv)
316 end;
318 procedure ReadBoolean (VAR v: Boolean; param: String);
319 begin
320 v := config.ReadBool(section, param, v)
321 end;
323 procedure ReadString (VAR v: String; param: String);
324 begin
325 v := config.ReadStr(section, param, v)
326 end;
328 begin
329 gAskLanguage := True;
330 e_WriteLog('Reading config', TMsgType.Notify);
331 g_Options_SetDefault;
333 if FileExists(FileName) = False then
334 begin
335 e_WriteLog('Config file '+FileName+' not found', TMsgType.Warning);
336 g_Options_SetDefaultVideo;
337 Exit
338 end;
340 config := TConfig.CreateFile(FileName);
342 section := 'Video';
343 ReadInteger(gScreenWidth, 'ScreenWidth', 0);
344 ReadInteger(gScreenHeight, 'ScreenHeight', 0);
345 ReadInteger(gWinRealPosX, 'WinPosX', 60);
346 ReadInteger(gWinRealPosY, 'WinPosY', 60);
347 ReadBoolean(gFullScreen, 'Fullscreen');
348 ReadBoolean(gWinMaximized, 'Maximized');
349 ReadInteger(gBPP, 'BPP', 0);
350 ReadInteger(gFreq, 'Freq', 0);
351 ReadBoolean(gVSync, 'VSync');
352 ReadBoolean(gTextureFilter, 'TextureFilter');
353 ReadBoolean(glLegacyNPOT, 'LegacyCompatible');
355 section := 'Sound';
356 ReadBoolean(gNoSound, 'NoSound');
357 ReadInteger(gSoundLevel, 'SoundLevel', 0, 255);
358 ReadInteger(gMusicLevel, 'MusicLevel', 0, 255);
359 ReadInteger(gMaxSimSounds, 'MaxSimSounds', 2, 66);
360 ReadBoolean(gMuteWhenInactive, 'MuteInactive');
361 ReadInteger(gAnnouncer, 'Announcer', ANNOUNCE_NONE, ANNOUNCE_ALL);
362 ReadBoolean(gSoundEffectsDF, 'SoundEffectsDF');
363 ReadBoolean(gUseChatSounds, 'ChatSounds');
364 ReadInteger(gsSDLSampleRate, 'SDLSampleRate', 11025, 96000);
365 ReadInteger(gsSDLBufferSize, 'SDLBufferSize', 64, 16384);
367 section := 'Player1';
368 with gPlayer1Settings do
369 begin
370 ReadString(Name, 'name');
371 ReadString(Model, 'model');
372 ReadInteger(Color.R, 'red', 0, 255);
373 ReadInteger(Color.G, 'green', 0, 255);
374 ReadInteger(Color.B, 'blue', 0, 255);
375 ReadInteger(Team, 'team');
376 if (Team < TEAM_RED) or (Team > TEAM_BLUE) then
377 Team := TEAM_RED;
378 end;
380 section := 'Player2';
381 with gPlayer2Settings do
382 begin
383 ReadString(Name, 'name');
384 ReadString(Model, 'model');
385 ReadInteger(Color.R, 'red', 0, 255);
386 ReadInteger(Color.G, 'green', 0, 255);
387 ReadInteger(Color.B, 'blue', 0, 255);
388 ReadInteger(Team, 'team');
389 if (Team < TEAM_RED) or (Team > TEAM_BLUE) then
390 Team := TEAM_RED;
391 end;
393 section := 'Joysticks';
394 for i := 0 to e_MaxJoys - 1 do
395 begin
396 ReadInteger(e_JoystickDeadzones[i], 'Deadzone' + IntToStr(i))
397 end;
399 section := 'Game';
400 ReadInteger(i, 'MaxParticles', 0, 50000); g_GFX_SetMax(i);
401 ReadInteger(i, 'MaxShells', 0, 600); g_Shells_SetMax(i);
402 ReadInteger(i, 'MaxGibs', 0, 500); g_Gibs_SetMax(i);
403 ReadInteger(i, 'MaxCorpses', 0, 100); g_Corpses_SetMax(i);
404 ReadInteger(i, 'GibsCount');
405 case i of
406 0: gGibsCount := 0;
407 1: gGibsCount := 8;
408 2: gGibsCount := 16;
409 3: gGibsCount := 32;
410 else gGibsCount := 48;
411 end;
412 i := ITEM_RESPAWNTIME div 36; ReadInteger(i, 'ItemRespawnTime', 0); ITEM_RESPAWNTIME := i * 36;
413 ReadInteger(gBloodCount, 'BloodCount', 0, 4);
414 ReadBoolean(gAdvBlood, 'AdvancesBlood');
415 ReadBoolean(gAdvCorpses, 'AdvancesCorpses');
416 ReadBoolean(gAdvGibs, 'AdvancesGibs');
417 ReadInteger(gFlash, 'Flash', 0, 2);
418 ReadBoolean(gDrawBackGround, 'BackGround');
419 ReadBoolean(gShowMessages, 'Messages');
420 ReadBoolean(gRevertPlayers, 'RevertPlayers');
421 ReadInteger(gChatBubble, 'ChatBubble', 0, 4);
422 ReadBoolean(gPlayerIndicator, 'PlayerIndicator');
423 ReadBoolean(gSFSDebug, 'SFSDebug'); wadoptDebug := gSFSDebug;
424 ReadBoolean(gSFSFastMode, 'SFSFastMode'); wadoptFast := gSFSFastMode;
425 ReadBoolean(e_FastScreenshots, 'FastScreenshots');
426 ReadString(gDefaultMegawadStart, 'DefaultMegawadStart');
427 ReadBoolean(gBerserkAutoswitch, 'BerserkAutoswitching');
428 i := Trunc(g_dbg_scale * 100); ReadInteger(i, 'Scale', 100); g_dbg_scale := i / 100;
429 ReadString(gLanguage, 'Language');
430 if (gLanguage = LANGUAGE_RUSSIAN) or (gLanguage = LANGUAGE_ENGLISH) then
431 gAskLanguage := False
432 else
433 gLanguage := LANGUAGE_ENGLISH;
435 section := 'GameplayCustom';
436 ReadString(gcMap, 'Map');
437 ReadString(gcGameMode, 'GameMode');
438 ReadInteger(gcTimeLimit, 'TimeLimit', 0, 65535);
439 ReadInteger(gcGoalLimit, 'GoalLimit', 0, 65535);
440 ReadInteger(gcMaxLives, 'MaxLives', 0, 255);
441 ReadInteger(gcPlayers, 'Players', 0, 2);
442 ReadBoolean(gcTeamDamage, 'TeamDamage');
443 ReadBoolean(gcAllowExit, 'AllowExit');
444 ReadBoolean(gcWeaponStay, 'WeaponStay');
445 ReadBoolean(gcMonsters, 'Monsters');
446 ReadString(gcBotsVS, 'BotsVS');
448 with gGameSettings do
449 begin
450 GameMode := g_Game_TextToMode(gcGameMode);
451 if GameMode = GM_NONE then
452 GameMode := GM_DM;
453 if GameMode = GM_SINGLE then
454 GameMode := GM_COOP;
455 TimeLimit := gcTimeLimit;
456 GoalLimit := gcGoalLimit;
457 MaxLives := gcMaxLives;
459 Options := 0;
460 if gcTeamDamage then
461 Options := Options or GAME_OPTION_TEAMDAMAGE;
462 if gcAllowExit then
463 Options := Options or GAME_OPTION_ALLOWEXIT;
464 if gcWeaponStay then
465 Options := Options or GAME_OPTION_WEAPONSTAY;
466 if gcMonsters then
467 Options := Options or GAME_OPTION_MONSTERS;
468 if gcBotsVS = 'Everybody' then
469 Options := Options or GAME_OPTION_BOTVSPLAYER or GAME_OPTION_BOTVSMONSTER;
470 if gcBotsVS = 'Players' then
471 Options := Options or GAME_OPTION_BOTVSPLAYER;
472 if gcBotsVS = 'Monsters' then
473 Options := Options or GAME_OPTION_BOTVSMONSTER;
474 end;
476 section := 'GameplayNetwork';
477 ReadString(gnMap, 'Map');
478 ReadString(gnGameMode, 'GameMode');
479 ReadInteger(gnTimeLimit, 'TimeLimit', 0, 65535);
480 ReadInteger(gnGoalLimit, 'GoalLimit', 0, 65535);
481 ReadInteger(gnMaxLives, 'MaxLives', 0, 255);
482 ReadInteger(gnPlayers, 'Players', 0, 2);
483 ReadBoolean(gnTeamDamage, 'TeamDamage');
484 ReadBoolean(gnAllowExit, 'AllowExit');
485 ReadBoolean(gnWeaponStay, 'WeaponStay');
486 ReadBoolean(gnMonsters, 'Monsters');
487 ReadString(gnBotsVS, 'BotsVS');
489 section := 'MasterServer';
490 ReadString(NetSlistIP, 'IP');
491 ReadInteger(NetSlistPort, 'Port', 0, 65535);
492 g_Net_Slist_Set(NetSlistIP, NetSlistPort);
494 section := 'Server';
495 ReadString(NetServerName, 'Name');
496 ReadString(NetPassword, 'Password');
497 ReadInteger(NetPort, 'Port', 0, 65535);
498 ReadInteger(NetMaxClients, 'MaxClients', 0, NET_MAXCLIENTS);
499 ReadBoolean(NetAllowRCON, 'RCON');
500 ReadString(NetRCONPassword, 'RCONPassword');
501 ReadBoolean(NetUseMaster, 'SyncWithMaster');
502 ReadInteger(NetUpdateRate, 'UpdateInterval', 0);
503 ReadInteger(NetRelupdRate, 'ReliableUpdateInterval', 0);
504 ReadInteger(NetMasterRate, 'MasterSyncInterval', 1);
505 ReadBoolean(NetForwardPorts, 'ForwardPorts');
507 section := 'Client';
508 ReadInteger(NetInterpLevel, 'InterpolationSteps', 0);
509 ReadBoolean(NetForcePlayerUpdate, 'ForcePlayerUpdate');
510 ReadBoolean(NetPredictSelf, 'PredictSelf');
511 ReadString(NetClientIP, 'LastIP');
512 ReadInteger(NetClientPort, 'LastPort', 0, 65535);
514 config.Free();
516 //if gTextureFilter then TEXTUREFILTER := GL_LINEAR else TEXTUREFILTER := GL_NEAREST;
517 end;
519 procedure g_Options_Write(FileName: String);
520 var
521 config: TConfig;
522 i: Integer;
523 begin
524 e_WriteLog('Writing config', TMsgType.Notify);
526 config := TConfig.CreateFile(FileName);
528 config.WriteInt('Video', 'ScreenWidth', gScreenWidth);
529 config.WriteInt('Video', 'ScreenHeight', gScreenHeight);
530 config.WriteInt('Video', 'WinPosX', gWinRealPosX);
531 config.WriteInt('Video', 'WinPosY', gWinRealPosY);
532 config.WriteBool('Video', 'Fullscreen', gFullScreen);
533 config.WriteBool('Video', 'Maximized', gWinMaximized);
534 config.WriteInt('Video', 'BPP', gBPP);
535 config.WriteBool('Video', 'VSync', gVSync);
536 config.WriteBool('Video', 'TextureFilter', gTextureFilter);
537 config.WriteBool('Video', 'LegacyCompatible', glLegacyNPOT);
539 config.WriteBool('Sound', 'NoSound', gNoSound);
540 config.WriteInt('Sound', 'SoundLevel', gSoundLevel);
541 config.WriteInt('Sound', 'MusicLevel', gMusicLevel);
542 config.WriteInt('Sound', 'MaxSimSounds', gMaxSimSounds);
543 config.WriteBool('Sound', 'MuteInactive', gMuteWhenInactive);
544 config.WriteInt('Sound', 'Announcer', gAnnouncer);
545 config.WriteBool('Sound', 'SoundEffectsDF', gSoundEffectsDF);
546 config.WriteBool('Sound', 'ChatSounds', gUseChatSounds);
547 config.WriteInt('Sound', 'SDLSampleRate', gsSDLSampleRate);
548 config.WriteInt('Sound', 'SDLBufferSize', gsSDLBufferSize);
550 with config, gPlayer1Settings do
551 begin
552 WriteStr('Player1', 'Name', Name);
553 WriteStr('Player1', 'model', Model);
554 WriteInt('Player1', 'red', Color.R);
555 WriteInt('Player1', 'green', Color.G);
556 WriteInt('Player1', 'blue', Color.B);
557 WriteInt('Player1', 'team', Team);
558 end;
560 with config, gPlayer2Settings do
561 begin
562 WriteStr('Player2', 'Name', Name);
563 WriteStr('Player2', 'model', Model);
564 WriteInt('Player2', 'red', Color.R);
565 WriteInt('Player2', 'green', Color.G);
566 WriteInt('Player2', 'blue', Color.B);
567 WriteInt('Player2', 'team', Team);
568 end;
570 for i := 0 to e_MaxJoys-1 do
571 config.WriteInt('Joysticks', 'Deadzone' + IntToStr(i), e_JoystickDeadzones[i]);
573 with config do
574 case gGibsCount of
575 0: config.WriteInt('Game', 'GibsCount', 0);
576 8: config.WriteInt('Game', 'GibsCount', 1);
577 16: config.WriteInt('Game', 'GibsCount', 2);
578 32: config.WriteInt('Game', 'GibsCount', 3);
579 else config.WriteInt('Game', 'GibsCount', 4);
580 end;
582 config.WriteInt('Game', 'ItemRespawnTime', ITEM_RESPAWNTIME div 36);
583 config.WriteInt('Game', 'MaxParticles', g_GFX_GetMax());
584 config.WriteInt('Game', 'MaxShells', g_Shells_GetMax());
585 config.WriteInt('Game', 'MaxGibs', g_Gibs_GetMax());
586 config.WriteInt('Game', 'MaxCorpses', g_Corpses_GetMax());
587 config.WriteInt('Game', 'BloodCount', gBloodCount);
588 config.WriteBool('Game', 'AdvancesBlood', gAdvBlood);
589 config.WriteBool('Game', 'AdvancesCorpses', gAdvCorpses);
590 config.WriteBool('Game', 'AdvancesGibs', gAdvGibs);
591 config.WriteInt('Game', 'Flash', gFlash);
592 config.WriteBool('Game', 'BackGround', gDrawBackGround);
593 config.WriteBool('Game', 'Messages', gShowMessages);
594 config.WriteBool('Game', 'RevertPlayers', gRevertPlayers);
595 config.WriteInt('Game', 'ChatBubble', gChatBubble);
596 config.WriteBool('Game', 'PlayerIndicator', gPlayerIndicator);
597 config.WriteBool('Game', 'SFSDebug', gSFSDebug);
598 config.WriteBool('Game', 'SFSFastMode', gSFSFastMode);
599 config.WriteBool('Game', 'FastScreenshots', e_FastScreenshots);
600 config.WriteStr('Game', 'DefaultMegawadStart', gDefaultMegawadStart);
601 config.WriteBool('Game', 'BerserkAutoswitching', gBerserkAutoswitch);
602 config.WriteInt('Game', 'Scale', Round(g_dbg_scale * 100));
604 config.WriteStr ('GameplayCustom', 'Map', gcMap);
605 config.WriteStr ('GameplayCustom', 'GameMode', gcGameMode);
606 config.WriteInt ('GameplayCustom', 'TimeLimit', gcTimeLimit);
607 config.WriteInt ('GameplayCustom', 'GoalLimit', gcGoalLimit);
608 config.WriteInt ('GameplayCustom', 'MaxLives', gcMaxLives);
609 config.WriteInt ('GameplayCustom', 'Players', gcPlayers);
610 config.WriteBool('GameplayCustom', 'TeamDamage', gcTeamDamage);
611 config.WriteBool('GameplayCustom', 'AllowExit', gcAllowExit);
612 config.WriteBool('GameplayCustom', 'WeaponStay', gcWeaponStay);
613 config.WriteBool('GameplayCustom', 'Monsters', gcMonsters);
614 config.WriteStr ('GameplayCustom', 'BotsVS', gcBotsVS);
616 config.WriteStr ('GameplayNetwork', 'Map', gnMap);
617 config.WriteStr ('GameplayNetwork', 'GameMode', gnGameMode);
618 config.WriteInt ('GameplayNetwork', 'TimeLimit', gnTimeLimit);
619 config.WriteInt ('GameplayNetwork', 'GoalLimit', gnGoalLimit);
620 config.WriteInt ('GameplayNetwork', 'MaxLives', gnMaxLives);
621 config.WriteInt ('GameplayNetwork', 'Players', gnPlayers);
622 config.WriteBool('GameplayNetwork', 'TeamDamage', gnTeamDamage);
623 config.WriteBool('GameplayNetwork', 'AllowExit', gnAllowExit);
624 config.WriteBool('GameplayNetwork', 'WeaponStay', gnWeaponStay);
625 config.WriteBool('GameplayNetwork', 'Monsters', gnMonsters);
626 config.WriteStr ('GameplayNetwork', 'BotsVS', gnBotsVS);
628 config.WriteStr('MasterServer', 'IP', NetSlistIP);
629 config.WriteInt('MasterServer', 'Port', NetSlistPort);
631 config.WriteStr ('Server', 'Name', NetServerName);
632 config.WriteStr ('Server', 'Password', NetPassword);
633 config.WriteInt ('Server', 'Port', NetPort);
634 config.WriteInt ('Server', 'MaxClients', NetMaxClients);
635 config.WriteBool('Server', 'RCON', NetAllowRCON);
636 config.WriteStr ('Server', 'RCONPassword', NetRCONPassword);
637 config.WriteBool('Server', 'SyncWithMaster', NetUseMaster);
638 config.WriteBool('Server', 'ForwardPorts', NetForwardPorts);
639 config.WriteInt ('Server', 'UpdateInterval', NetUpdateRate);
640 config.WriteInt ('Server', 'ReliableUpdateInterval', NetRelupdRate);
641 config.WriteInt ('Server', 'MasterSyncInterval', NetMasterRate);
643 config.WriteInt ('Client', 'InterpolationSteps', NetInterpLevel);
644 config.WriteBool ('Client', 'ForcePlayerUpdate', NetForcePlayerUpdate);
645 config.WriteBool ('Client', 'PredictSelf', NetPredictSelf);
646 config.WriteStr ('Client', 'LastIP', NetClientIP);
647 config.WriteInt ('Client', 'LastPort', NetClientPort);
649 config.SaveFile(FileName);
650 config.Free();
651 end;
653 procedure g_Options_Write_Language(FileName: String);
654 var
655 config: TConfig;
656 begin
657 e_WriteLog('Writing language config', TMsgType.Notify);
659 config := TConfig.CreateFile(FileName);
660 config.WriteStr('Game', 'Language', gLanguage);
661 config.SaveFile(FileName);
662 config.Free();
663 end;
665 procedure g_Options_Write_Video(FileName: String);
666 var
667 config: TConfig;
668 sW, sH: Integer;
669 begin
670 e_WriteLog('Writing resolution to config', TMsgType.Notify);
672 config := TConfig.CreateFile(FileName);
674 if gWinMaximized and (not gFullscreen) then
675 begin
676 sW := gWinSizeX;
677 sH := gWinSizeY;
678 end
679 else
680 begin
681 sW := gScreenWidth;
682 sH := gScreenHeight;
683 end;
684 e_LogWritefln(' (ws=%dx%d) (ss=%dx%d)', [gWinSizeX, gWinSizeY, gScreenWidth, gScreenHeight]);
686 config.WriteInt('Video', 'ScreenWidth', sW);
687 config.WriteInt('Video', 'ScreenHeight', sH);
688 config.WriteInt('Video', 'WinPosX', gWinRealPosX);
689 config.WriteInt('Video', 'WinPosY', gWinRealPosY);
690 config.WriteBool('Video', 'Fullscreen', gFullscreen);
691 config.WriteBool('Video', 'Maximized', gWinMaximized);
693 config.WriteStr('Player1', 'Name', gPlayer1Settings.Name);
694 config.WriteStr('Player2', 'Name', gPlayer2Settings.Name);
696 config.SaveFile(FileName);
697 config.Free();
698 end;
700 procedure g_Options_Write_Gameplay_Custom(FileName: String);
701 var
702 config: TConfig;
703 begin
704 e_WriteLog('Writing custom gameplay config', TMsgType.Notify);
706 config := TConfig.CreateFile(FileName);
708 config.WriteStr ('GameplayCustom', 'Map', gcMap);
709 config.WriteStr ('GameplayCustom', 'GameMode', gcGameMode);
710 config.WriteInt ('GameplayCustom', 'TimeLimit', gcTimeLimit);
711 config.WriteInt ('GameplayCustom', 'GoalLimit', gcGoalLimit);
712 config.WriteInt ('GameplayCustom', 'MaxLives', gcMaxLives);
713 config.WriteInt ('GameplayCustom', 'Players', gcPlayers);
714 config.WriteBool('GameplayCustom', 'TeamDamage', gcTeamDamage);
715 config.WriteBool('GameplayCustom', 'AllowExit', gcAllowExit);
716 config.WriteBool('GameplayCustom', 'WeaponStay', gcWeaponStay);
717 config.WriteBool('GameplayCustom', 'Monsters', gcMonsters);
718 config.WriteStr ('GameplayCustom', 'BotsVS', gcBotsVS);
720 config.SaveFile(FileName);
721 config.Free();
722 end;
724 procedure g_Options_Write_Gameplay_Net(FileName: String);
725 var
726 config: TConfig;
727 begin
728 e_WriteLog('Writing network gameplay config', TMsgType.Notify);
730 config := TConfig.CreateFile(FileName);
732 config.WriteStr ('GameplayNetwork', 'Map', gnMap);
733 config.WriteStr ('GameplayNetwork', 'GameMode', gnGameMode);
734 config.WriteInt ('GameplayNetwork', 'TimeLimit', gnTimeLimit);
735 config.WriteInt ('GameplayNetwork', 'GoalLimit', gnGoalLimit);
736 config.WriteInt ('GameplayNetwork', 'MaxLives', gnMaxLives);
737 config.WriteInt ('GameplayNetwork', 'Players', gnPlayers);
738 config.WriteBool('GameplayNetwork', 'TeamDamage', gnTeamDamage);
739 config.WriteBool('GameplayNetwork', 'AllowExit', gnAllowExit);
740 config.WriteBool('GameplayNetwork', 'WeaponStay', gnWeaponStay);
741 config.WriteBool('GameplayNetwork', 'Monsters', gnMonsters);
742 config.WriteStr ('GameplayNetwork', 'BotsVS', gnBotsVS);
744 config.SaveFile(FileName);
745 config.Free();
746 end;
748 procedure g_Options_Write_Net_Server(FileName: String);
749 var
750 config: TConfig;
751 begin
752 e_WriteLog('Writing server config', TMsgType.Notify);
754 config := TConfig.CreateFile(FileName);
756 config.WriteStr ('Server', 'Name', NetServerName);
757 config.WriteStr ('Server', 'Password', NetPassword);
758 config.WriteInt ('Server', 'Port', NetPort);
759 config.WriteInt ('Server', 'MaxClients', NetMaxClients);
760 config.WriteBool('Server', 'SyncWithMaster', NetUseMaster);
761 config.WriteBool('Server', 'ForwardPorts', NetForwardPorts);
763 config.SaveFile(FileName);
764 config.Free();
765 end;
767 procedure g_Options_Write_Net_Client(FileName: String);
768 var
769 config: TConfig;
770 begin
771 e_WriteLog('Writing client config', TMsgType.Notify);
773 config := TConfig.CreateFile(FileName);
775 config.WriteStr('Client', 'LastIP', NetClientIP);
776 config.WriteInt('Client', 'LastPort', NetClientPort);
778 config.SaveFile(FileName);
779 config.Free();
780 end;
782 initialization
783 Randomize;
784 machine := Random(10000)
785 end.