DEADSOFTWARE

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