DEADSOFTWARE

move video, sound and language options to dfconfig.cfg
[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: Byte;
57 gFlash: Byte;
58 gDrawBackGround: Boolean;
59 gShowMessages: Boolean;
60 gRevertPlayers: Boolean;
61 gLanguage: String;
62 gAskLanguage: Boolean;
63 gcMap: String;
64 gcGameMode: String;
65 gcTimeLimit: Word;
66 gcGoalLimit: Word;
67 gcMaxLives: Byte;
68 gcPlayers: Byte;
69 gcTeamDamage: Boolean;
70 gcAllowExit: Boolean;
71 gcWeaponStay: Boolean;
72 gcMonsters: Boolean;
73 gcBotsVS: String;
74 gnMap: String;
75 gnGameMode: String;
76 gnTimeLimit: Word;
77 gnGoalLimit: Word;
78 gnMaxLives: Byte;
79 gnPlayers: Byte;
80 gnTeamDamage: Boolean;
81 gnAllowExit: Boolean;
82 gnWeaponStay: Boolean;
83 gnMonsters: Boolean;
84 gnBotsVS: String;
85 gsSDLSampleRate: Integer;
86 gsSDLBufferSize: Integer;
87 gSFSDebug: Boolean;
88 gSFSFastMode: Boolean;
89 gDefaultMegawadStart: AnsiString;
90 gBerserkAutoswitch: Boolean;
91 glNPOTOverride: Boolean = false;
93 implementation
95 uses
96 {$INCLUDE ../nogl/noGLuses.inc}
97 {$IFDEF USE_SDL2}
98 SDL2,
99 {$ENDIF}
100 e_log, e_input, g_console, g_window, g_sound, g_gfx, g_player, Math,
101 g_map, g_net, g_netmaster, SysUtils, CONFIG, g_game, g_main, e_texture,
102 g_items, wadreader, e_graphics, g_touch, envvars, g_system;
104 var
105 machine: Integer;
107 function GenPlayerName (n: Integer): String;
108 begin
109 ASSERT(n >= 1);
110 Result := GetUserName;
111 if Result = '' then
112 Result := 'Player' + IntToStr(machine MOD 10000);
113 if n = 1 then
114 Result := Copy(Result, 1, 12) + ' '
115 else
116 Result := Copy(Result, 1, 10) + ' ' + IntToStr(n)
117 end;
119 {$IFDEF USE_SDL2}
120 procedure g_Options_SetDefaultVideo;
121 var display: TSDL_DisplayMode;
122 {$IFNDEF ANDROID}
123 var target, closest: TSDL_DisplayMode; percentage: Integer;
124 {$ENDIF}
125 begin
126 (* Display 0 = Primary display *)
127 gScreenWidth := 640;
128 gScreenHeight := 480;
129 //gBPP := SDL_BITSPERPIXEL(dispaly.format);
130 gBPP := 32;
131 {$IFDEF ANDROID}
132 gFullScreen := True; (* rotation not allowed? *)
133 {$ELSE}
134 gFullScreen := False;
135 {$ENDIF}
136 if SDL_GetDesktopDisplayMode(0, @display) = 0 then
137 begin
138 {$IFDEF ANDROID}
139 gScreenWidth := display.w;
140 gScreenHeight := display.h;
141 {$ELSE}
142 (* Window must be smaller than display *)
143 closest.w := display.w;
144 closest.h := display.h;
145 percentage := 75;
146 while (display.w - closest.w < 48) or (display.h - closest.h < 48) do
147 begin
148 if percentage < 25 then
149 begin
150 closest.w := display.w * 75 div 100;
151 closest.h := display.h * 75 div 100;
152 break;
153 end;
154 target.w := display.w * percentage div 100;
155 target.h := display.h * percentage div 100;
156 target.format := 0; (* didn't care *)
157 target.refresh_rate := 0; (* didn't care *)
158 target.driverdata := nil; (* init *)
159 SDL_GetClosestDisplayMode(0, @target, @closest);
160 Dec(percentage);
161 end;
162 gScreenWidth := closest.w;
163 gScreenHeight := closest.h;
164 //gBPP := SDL_BITSPERPIXEL(closest.format); (* Resolution list didn't work for some reason *)
165 {$ENDIF}
166 end
167 else
168 begin
169 e_LogWritefln('SDL: Failed to get desktop display mode: %s', [SDL_GetError])
170 end;
171 (* Must be positioned on primary display *)
172 gWinMaximized := False;
173 gVSync := True;
174 gTextureFilter := True;
175 glLegacyNPOT := False;
176 e_LogWriteLn('g_Options_SetDefaultVideo: w = ' + IntToStr(gScreenWidth) + ' h = ' + IntToStr(gScreenHeight));
177 g_Console_ResetBinds;
178 end;
179 {$ELSE}
180 procedure g_Options_SetDefaultVideo;
181 begin
182 gScreenWidth := 640;
183 gScreenHeight := 480;
184 gBPP := 32;
185 gFullScreen := False;
186 gWinMaximized := False;
187 gVSync := True;
188 gTextureFilter := True;
189 glLegacyNPOT := False;
190 e_LogWriteLn('g_Options_SetDefaultVideo: w = ' + IntToStr(gScreenWidth) + ' h = ' + IntToStr(gScreenHeight));
191 g_Console_ResetBinds;
192 end;
193 {$ENDIF}
195 procedure g_Options_SetDefault();
196 var
197 i: Integer;
198 begin
199 (* section Sound *)
200 gNoSound := False;
201 gSoundLevel := 75;
202 gMusicLevel := 65;
203 gMaxSimSounds := 8;
204 gMuteWhenInactive := False;
205 gAnnouncer := ANNOUNCE_MEPLUS;
206 gSoundEffectsDF := True;
207 gUseChatSounds := True;
208 gsSDLSampleRate := 44100;
209 gsSDLBufferSize := 2048;
211 g_Sound_SetupAllVolumes(gSoundLevel, gMusicLevel);
213 with gPlayer1Settings do
214 begin
215 Name := GenPlayerName(1);
216 Model := STD_PLAYER_MODEL;
217 Color.R := PLAYER1_DEF_COLOR.R;
218 Color.G := PLAYER1_DEF_COLOR.G;
219 Color.B := PLAYER1_DEF_COLOR.B;
220 Team := TEAM_RED;
221 end;
223 with gPlayer2Settings do
224 begin
225 Name := GenPlayerName(2);
226 Model := STD_PLAYER_MODEL;
227 Color.R := PLAYER2_DEF_COLOR.R;
228 Color.G := PLAYER2_DEF_COLOR.G;
229 Color.B := PLAYER2_DEF_COLOR.B;
230 Team := TEAM_BLUE;
231 end;
233 (* section Joysticks *)
234 for i := 0 to e_MaxJoys - 1 do
235 begin
236 e_JoystickDeadzones[i] := 8192
237 end;
239 (* section Game *)
240 g_GFX_SetMax(2000);
241 g_Shells_SetMax(300);
242 g_Gibs_SetMax(150);
243 g_Corpses_SetMax(20);
244 gGibsCount := 32;
245 ITEM_RESPAWNTIME := 60 * 36;
246 gBloodCount := 4;
247 gAdvBlood := True;
248 gAdvCorpses := True;
249 gAdvGibs := True;
250 gFlash := 1;
251 gDrawBackGround := True;
252 gShowMessages := True;
253 gRevertPlayers := False;
254 gChatBubble := 4;
255 gSFSDebug := False;
256 gSFSFastMode := False;
257 e_FastScreenshots := True;
258 gDefaultMegawadStart := DF_Default_Megawad_Start;
259 gBerserkAutoswitch := True;
260 g_dbg_scale := 1.0;
262 gAskLanguage := True;
263 gLanguage := LANGUAGE_ENGLISH;
265 (* section GameplayCustom *)
266 gcMap := '';
267 gcGameMode := _lc[I_MENU_GAME_TYPE_DM];
268 gcTimeLimit := 0;
269 gcGoalLimit := 0;
270 gcMaxLives := 0;
271 gcPlayers := 1;
272 gcTeamDamage := False;
273 gcAllowExit := True;
274 gcWeaponStay := False;
275 gcMonsters := False;
276 gcBotsVS := 'Everybody';
278 (* section GameplayNetwork *)
279 gnMap := '';
280 gnGameMode := _lc[I_MENU_GAME_TYPE_DM];
281 gnTimeLimit := 0;
282 gnGoalLimit := 0;
283 gnMaxLives := 0;
284 gnPlayers := 1;
285 gnTeamDamage := False;
286 gnAllowExit := True;
287 gnWeaponStay := False;
288 gnMonsters := False;
289 gnBotsVS := 'Everybody';
291 (* section MasterServer *)
292 NetSlistIP := 'mpms.doom2d.org';
293 NetSlistPort := 25665;
294 g_Net_Slist_Set(NetSlistIP, NetSlistPort, NetSlistList);
296 (* section Server *)
297 NetServerName := 'Unnamed Server';
298 NetPassword := '';
299 NetPort := 25666;
300 NetMaxClients := 16;
301 NetAllowRCON := False;
302 NetRCONPassword := 'default';
303 NetUseMaster := True;
304 NetUpdateRate := 0;
305 NetRelupdRate := 18;
306 NetMasterRate := 60000;
307 NetForwardPorts := False;
309 (* section Client *)
310 NetInterpLevel := 2;
311 NetForcePlayerUpdate := False;
312 NetPredictSelf := True;
313 NetClientIP := '127.0.0.1';
314 NetClientPort := NetPort;
315 end;
317 procedure g_Options_Read(FileName: String);
318 var
319 i: Integer;
320 config: TConfig;
321 section: String;
323 procedure ReadInteger (VAR v: Integer; param: String; minv: Integer = Low(Integer); maxv: Integer = High(Integer));
324 begin
325 v := Max(Min(config.ReadInt(section, param, v), maxv), minv)
326 end;
328 procedure ReadInteger (VAR v: LongWord; param: String; minv: LongWord = Low(LongWord); maxv: LongWord = High(LongWord)); overload;
329 begin
330 v := Max(Min(config.ReadInt(section, param, v), maxv), minv)
331 end;
333 procedure ReadInteger (VAR v: Word; param: String; minv: Word = Low(Word); maxv: Word = High(Word)); overload;
334 begin
335 v := Max(Min(config.ReadInt(section, param, v), maxv), minv)
336 end;
338 procedure ReadInteger (VAR v: Byte; param: String; minv: Byte = Low(Byte); maxv: Byte = High(Byte)); overload;
339 begin
340 v := Max(Min(config.ReadInt(section, param, v), maxv), minv)
341 end;
343 procedure ReadBoolean (VAR v: Boolean; param: String);
344 begin
345 v := config.ReadBool(section, param, v)
346 end;
348 procedure ReadString (VAR v: String; param: String);
349 begin
350 v := config.ReadStr(section, param, v)
351 end;
353 begin
354 gAskLanguage := True;
355 e_WriteLog('Reading config', TMsgType.Notify);
356 g_Options_SetDefault;
358 if FileExists(FileName) = False then
359 begin
360 e_WriteLog('Config file '+FileName+' not found', TMsgType.Warning);
361 g_Options_SetDefaultVideo;
362 Exit
363 end;
365 config := TConfig.CreateFile(FileName);
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 := 'Game';
394 ReadInteger(i, 'MaxParticles', 0, 50000); g_GFX_SetMax(i);
395 ReadInteger(i, 'MaxShells', 0, 600); g_Shells_SetMax(i);
396 ReadInteger(i, 'MaxGibs', 0, 500); g_Gibs_SetMax(i);
397 ReadInteger(i, 'MaxCorpses', 0, 100); g_Corpses_SetMax(i);
398 ReadInteger(i, 'GibsCount');
399 case i of
400 0: gGibsCount := 0;
401 1: gGibsCount := 8;
402 2: gGibsCount := 16;
403 3: gGibsCount := 32;
404 else gGibsCount := 48;
405 end;
406 i := ITEM_RESPAWNTIME div 36; ReadInteger(i, 'ItemRespawnTime', 0); ITEM_RESPAWNTIME := i * 36;
407 ReadInteger(gBloodCount, 'BloodCount', 0, 4);
408 ReadBoolean(gAdvBlood, 'AdvancesBlood');
409 ReadBoolean(gAdvCorpses, 'AdvancesCorpses');
410 ReadBoolean(gAdvGibs, 'AdvancesGibs');
411 ReadInteger(gFlash, 'Flash', 0, 2);
412 ReadBoolean(gDrawBackGround, 'BackGround');
413 ReadBoolean(gShowMessages, 'Messages');
414 ReadBoolean(gRevertPlayers, 'RevertPlayers');
415 ReadInteger(gChatBubble, 'ChatBubble', 0, 4);
416 ReadBoolean(gSFSDebug, 'SFSDebug'); wadoptDebug := gSFSDebug;
417 ReadBoolean(gSFSFastMode, 'SFSFastMode'); wadoptFast := gSFSFastMode;
418 ReadBoolean(e_FastScreenshots, 'FastScreenshots');
419 ReadString(gDefaultMegawadStart, 'DefaultMegawadStart');
420 ReadBoolean(gBerserkAutoswitch, 'BerserkAutoswitching');
421 i := Trunc(g_dbg_scale * 100); ReadInteger(i, 'Scale', 100); g_dbg_scale := i / 100;
423 section := 'GameplayCustom';
424 ReadString(gcMap, 'Map');
425 ReadString(gcGameMode, 'GameMode');
426 ReadInteger(gcTimeLimit, 'TimeLimit', 0, 65535);
427 ReadInteger(gcGoalLimit, 'GoalLimit', 0, 65535);
428 ReadInteger(gcMaxLives, 'MaxLives', 0, 255);
429 ReadInteger(gcPlayers, 'Players', 0, 2);
430 ReadBoolean(gcTeamDamage, 'TeamDamage');
431 ReadBoolean(gcAllowExit, 'AllowExit');
432 ReadBoolean(gcWeaponStay, 'WeaponStay');
433 ReadBoolean(gcMonsters, 'Monsters');
434 ReadString(gcBotsVS, 'BotsVS');
436 with gGameSettings do
437 begin
438 GameMode := g_Game_TextToMode(gcGameMode);
439 if GameMode = GM_NONE then
440 GameMode := GM_DM;
441 if GameMode = GM_SINGLE then
442 GameMode := GM_COOP;
443 TimeLimit := gcTimeLimit;
444 GoalLimit := gcGoalLimit;
445 MaxLives := gcMaxLives;
447 Options := 0;
448 if gcTeamDamage then
449 Options := Options or GAME_OPTION_TEAMDAMAGE;
450 if gcAllowExit then
451 Options := Options or GAME_OPTION_ALLOWEXIT;
452 if gcWeaponStay then
453 Options := Options or GAME_OPTION_WEAPONSTAY;
454 if gcMonsters then
455 Options := Options or GAME_OPTION_MONSTERS;
456 if gcBotsVS = 'Everybody' then
457 Options := Options or GAME_OPTION_BOTVSPLAYER or GAME_OPTION_BOTVSMONSTER;
458 if gcBotsVS = 'Players' then
459 Options := Options or GAME_OPTION_BOTVSPLAYER;
460 if gcBotsVS = 'Monsters' then
461 Options := Options or GAME_OPTION_BOTVSMONSTER;
462 end;
464 section := 'GameplayNetwork';
465 ReadString(gnMap, 'Map');
466 ReadString(gnGameMode, 'GameMode');
467 ReadInteger(gnTimeLimit, 'TimeLimit', 0, 65535);
468 ReadInteger(gnGoalLimit, 'GoalLimit', 0, 65535);
469 ReadInteger(gnMaxLives, 'MaxLives', 0, 255);
470 ReadInteger(gnPlayers, 'Players', 0, 2);
471 ReadBoolean(gnTeamDamage, 'TeamDamage');
472 ReadBoolean(gnAllowExit, 'AllowExit');
473 ReadBoolean(gnWeaponStay, 'WeaponStay');
474 ReadBoolean(gnMonsters, 'Monsters');
475 ReadString(gnBotsVS, 'BotsVS');
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 with config do
536 case gGibsCount of
537 0: config.WriteInt('Game', 'GibsCount', 0);
538 8: config.WriteInt('Game', 'GibsCount', 1);
539 16: config.WriteInt('Game', 'GibsCount', 2);
540 32: config.WriteInt('Game', 'GibsCount', 3);
541 else config.WriteInt('Game', 'GibsCount', 4);
542 end;
544 config.WriteInt('Game', 'ItemRespawnTime', ITEM_RESPAWNTIME div 36);
545 config.WriteInt('Game', 'MaxParticles', g_GFX_GetMax());
546 config.WriteInt('Game', 'MaxShells', g_Shells_GetMax());
547 config.WriteInt('Game', 'MaxGibs', g_Gibs_GetMax());
548 config.WriteInt('Game', 'MaxCorpses', g_Corpses_GetMax());
549 config.WriteInt('Game', 'BloodCount', gBloodCount);
550 config.WriteBool('Game', 'AdvancesBlood', gAdvBlood);
551 config.WriteBool('Game', 'AdvancesCorpses', gAdvCorpses);
552 config.WriteBool('Game', 'AdvancesGibs', gAdvGibs);
553 config.WriteInt('Game', 'Flash', gFlash);
554 config.WriteBool('Game', 'BackGround', gDrawBackGround);
555 config.WriteBool('Game', 'Messages', gShowMessages);
556 config.WriteBool('Game', 'RevertPlayers', gRevertPlayers);
557 config.WriteInt('Game', 'ChatBubble', gChatBubble);
558 config.WriteBool('Game', 'SFSDebug', gSFSDebug);
559 config.WriteBool('Game', 'SFSFastMode', gSFSFastMode);
560 config.WriteBool('Game', 'FastScreenshots', e_FastScreenshots);
561 config.WriteStr('Game', 'DefaultMegawadStart', gDefaultMegawadStart);
562 config.WriteBool('Game', 'BerserkAutoswitching', gBerserkAutoswitch);
563 config.WriteInt('Game', 'Scale', Round(g_dbg_scale * 100));
565 config.WriteStr ('GameplayCustom', 'Map', gcMap);
566 config.WriteStr ('GameplayCustom', 'GameMode', gcGameMode);
567 config.WriteInt ('GameplayCustom', 'TimeLimit', gcTimeLimit);
568 config.WriteInt ('GameplayCustom', 'GoalLimit', gcGoalLimit);
569 config.WriteInt ('GameplayCustom', 'MaxLives', gcMaxLives);
570 config.WriteInt ('GameplayCustom', 'Players', gcPlayers);
571 config.WriteBool('GameplayCustom', 'TeamDamage', gcTeamDamage);
572 config.WriteBool('GameplayCustom', 'AllowExit', gcAllowExit);
573 config.WriteBool('GameplayCustom', 'WeaponStay', gcWeaponStay);
574 config.WriteBool('GameplayCustom', 'Monsters', gcMonsters);
575 config.WriteStr ('GameplayCustom', 'BotsVS', gcBotsVS);
577 config.WriteStr ('GameplayNetwork', 'Map', gnMap);
578 config.WriteStr ('GameplayNetwork', 'GameMode', gnGameMode);
579 config.WriteInt ('GameplayNetwork', 'TimeLimit', gnTimeLimit);
580 config.WriteInt ('GameplayNetwork', 'GoalLimit', gnGoalLimit);
581 config.WriteInt ('GameplayNetwork', 'MaxLives', gnMaxLives);
582 config.WriteInt ('GameplayNetwork', 'Players', gnPlayers);
583 config.WriteBool('GameplayNetwork', 'TeamDamage', gnTeamDamage);
584 config.WriteBool('GameplayNetwork', 'AllowExit', gnAllowExit);
585 config.WriteBool('GameplayNetwork', 'WeaponStay', gnWeaponStay);
586 config.WriteBool('GameplayNetwork', 'Monsters', gnMonsters);
587 config.WriteStr ('GameplayNetwork', 'BotsVS', gnBotsVS);
589 config.WriteStr('MasterServer', 'IP', NetSlistIP);
590 config.WriteInt('MasterServer', 'Port', NetSlistPort);
591 config.WriteStr('MasterServer', 'List', NetSlistList);
593 config.WriteStr ('Server', 'Name', NetServerName);
594 config.WriteStr ('Server', 'Password', NetPassword);
595 config.WriteInt ('Server', 'Port', NetPort);
596 config.WriteInt ('Server', 'MaxClients', NetMaxClients);
597 config.WriteBool('Server', 'RCON', NetAllowRCON);
598 config.WriteStr ('Server', 'RCONPassword', NetRCONPassword);
599 config.WriteBool('Server', 'SyncWithMaster', NetUseMaster);
600 config.WriteBool('Server', 'ForwardPorts', NetForwardPorts);
601 config.WriteInt ('Server', 'UpdateInterval', NetUpdateRate);
602 config.WriteInt ('Server', 'ReliableUpdateInterval', NetRelupdRate);
603 config.WriteInt ('Server', 'MasterSyncInterval', NetMasterRate);
605 config.WriteInt ('Client', 'InterpolationSteps', NetInterpLevel);
606 config.WriteBool ('Client', 'ForcePlayerUpdate', NetForcePlayerUpdate);
607 config.WriteBool ('Client', 'PredictSelf', NetPredictSelf);
608 config.WriteStr ('Client', 'LastIP', NetClientIP);
609 config.WriteInt ('Client', 'LastPort', NetClientPort);
611 config.SaveFile(FileName);
612 config.Free();
613 end;
615 procedure g_Options_Write_Gameplay_Custom(FileName: String);
616 var
617 config: TConfig;
618 begin
619 e_WriteLog('Writing custom gameplay config', TMsgType.Notify);
621 config := TConfig.CreateFile(FileName);
623 config.WriteStr ('GameplayCustom', 'Map', gcMap);
624 config.WriteStr ('GameplayCustom', 'GameMode', gcGameMode);
625 config.WriteInt ('GameplayCustom', 'TimeLimit', gcTimeLimit);
626 config.WriteInt ('GameplayCustom', 'GoalLimit', gcGoalLimit);
627 config.WriteInt ('GameplayCustom', 'MaxLives', gcMaxLives);
628 config.WriteInt ('GameplayCustom', 'Players', gcPlayers);
629 config.WriteBool('GameplayCustom', 'TeamDamage', gcTeamDamage);
630 config.WriteBool('GameplayCustom', 'AllowExit', gcAllowExit);
631 config.WriteBool('GameplayCustom', 'WeaponStay', gcWeaponStay);
632 config.WriteBool('GameplayCustom', 'Monsters', gcMonsters);
633 config.WriteStr ('GameplayCustom', 'BotsVS', gcBotsVS);
635 config.SaveFile(FileName);
636 config.Free();
637 end;
639 procedure g_Options_Write_Gameplay_Net(FileName: String);
640 var
641 config: TConfig;
642 begin
643 e_WriteLog('Writing network gameplay config', TMsgType.Notify);
645 config := TConfig.CreateFile(FileName);
647 config.WriteStr ('GameplayNetwork', 'Map', gnMap);
648 config.WriteStr ('GameplayNetwork', 'GameMode', gnGameMode);
649 config.WriteInt ('GameplayNetwork', 'TimeLimit', gnTimeLimit);
650 config.WriteInt ('GameplayNetwork', 'GoalLimit', gnGoalLimit);
651 config.WriteInt ('GameplayNetwork', 'MaxLives', gnMaxLives);
652 config.WriteInt ('GameplayNetwork', 'Players', gnPlayers);
653 config.WriteBool('GameplayNetwork', 'TeamDamage', gnTeamDamage);
654 config.WriteBool('GameplayNetwork', 'AllowExit', gnAllowExit);
655 config.WriteBool('GameplayNetwork', 'WeaponStay', gnWeaponStay);
656 config.WriteBool('GameplayNetwork', 'Monsters', gnMonsters);
657 config.WriteStr ('GameplayNetwork', 'BotsVS', gnBotsVS);
659 config.SaveFile(FileName);
660 config.Free();
661 end;
663 procedure g_Options_Write_Net_Server(FileName: String);
664 var
665 config: TConfig;
666 begin
667 e_WriteLog('Writing server config', TMsgType.Notify);
669 config := TConfig.CreateFile(FileName);
671 config.WriteStr ('Server', 'Name', NetServerName);
672 config.WriteStr ('Server', 'Password', NetPassword);
673 config.WriteInt ('Server', 'Port', NetPort);
674 config.WriteInt ('Server', 'MaxClients', NetMaxClients);
675 config.WriteBool('Server', 'SyncWithMaster', NetUseMaster);
676 config.WriteBool('Server', 'ForwardPorts', NetForwardPorts);
678 config.SaveFile(FileName);
679 config.Free();
680 end;
682 procedure g_Options_Write_Net_Client(FileName: String);
683 var
684 config: TConfig;
685 begin
686 e_WriteLog('Writing client config', TMsgType.Notify);
688 config := TConfig.CreateFile(FileName);
690 config.WriteStr('Client', 'LastIP', NetClientIP);
691 config.WriteInt('Client', 'LastPort', NetClientPort);
693 config.SaveFile(FileName);
694 config.Free();
695 end;
697 procedure g_Options_Commands (p: SSArray);
698 var cmd: AnsiString;
699 begin
700 cmd := LowerCase(p[0]);
701 case cmd of
702 'r_reset':
703 begin
704 sys_EnableVSync(gVSync);
705 gRC_Width := Max(1, gRC_Width);
706 gRC_Height := Max(1, gRC_Height);
707 gBPP := Max(1, gBPP);
708 if sys_SetDisplayMode(gRC_Width, gRC_Height, gBPP, gRC_FullScreen) = True then
709 e_LogWriteln('resolution changed')
710 else
711 e_LogWriteln('resolution not changed')
712 end;
713 'g_language':
714 begin
715 if Length(p) = 2 then
716 begin
717 gAskLanguage := true;
718 gLanguage := LANGUAGE_ENGLISH;
719 case LowerCase(p[1]) of
720 'english':
721 begin
722 gAskLanguage := false;
723 gLanguage := LANGUAGE_ENGLISH;
724 end;
725 'russian':
726 begin
727 gAskLanguage := false;
728 gLanguage := LANGUAGE_RUSSIAN;
729 end;
730 'ask':
731 begin
732 gAskLanguage := true;
733 gLanguage := LANGUAGE_ENGLISH;
734 end;
735 end;
736 g_Language_Set(gLanguage)
737 end
738 end
739 end;
740 end;
742 initialization
743 Randomize;
744 machine := Random(10000);
746 (* Video *)
747 conRegVar('r_width', @gRC_Width, '', '');
748 conRegVar('r_height', @gRC_Height, '', '');
749 conRegVar('r_fullscreen', @gRC_FullScreen, '', '');
750 conRegVar('r_maximized', @gRC_Maximized, '', '');
751 conRegVar('r_bpp', @gBPP, '', '');
752 conRegVar('r_vsync', @gVSync, '', '');
753 conRegVar('r_texfilter', @gTextureFilter, '', '');
754 conRegVar('r_npot', @glNPOTOverride, '', '');
756 (* Sound *)
757 conRegVar('s_nosound', @gNoSound, '', '');
758 conRegVar('s_soundvolume', @gSoundLevel, '', '');
759 conRegVar('s_musicvolume', @gMusicLevel, '', '');
760 conRegVar('s_maxsim', @gMaxSimSounds, '', ''); // e_sound_fmod/sdl?
761 conRegVar('s_muteinactive', @gMuteWhenInactive, '', '');
762 conRegVar('s_announcer', @gAnnouncer, '', '');
763 conRegVar('s_sfx', @gSoundEffectsDF, '', '');
764 conRegVar('s_chatsounds', @gUseChatSounds, '', '');
765 {$IFDEF USE_SDLMIXER}
766 conRegVar('sdl_mixer_samplerate', @gsSDLSampleRate, '', '');
767 conRegVar('sdl_mixer_buffersize', @gsSDLBufferSize, '', '');
768 {$ENDIF}
769 end.