DEADSOFTWARE

hidden "Game/DefaultMegawadStart" option to change default playing wads
[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, either version 3 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *)
16 {$INCLUDE ../shared/a_modes.inc}
17 unit g_options;
19 interface
21 uses
22 g_language, g_weapons;
24 type
25 TPlayerControl = record
26 KeyRight: Word;
27 KeyLeft: Word;
28 KeyUp: Word;
29 KeyDown: Word;
30 KeyFire: Word;
31 KeyJump: Word;
32 KeyNextWeapon: Word;
33 KeyPrevWeapon: Word;
34 KeyOpen: Word;
35 KeyStrafe: Word;
36 KeyWeapon: array [WP_FIRST..WP_LAST] of Word;
38 KeyRight2: Word;
39 KeyLeft2: Word;
40 KeyUp2: Word;
41 KeyDown2: Word;
42 KeyFire2: Word;
43 KeyJump2: Word;
44 KeyNextWeapon2: Word;
45 KeyPrevWeapon2: Word;
46 KeyOpen2: Word;
47 KeyStrafe2: Word;
48 KeyWeapon2: array [WP_FIRST..WP_LAST] of Word;
49 end;
51 TGameControls = record
52 TakeScreenshot: Word;
53 Stat: Word;
54 Chat: Word;
55 TeamChat: Word;
56 end;
58 TControls = record
59 GameControls: TGameControls;
60 P1Control: TPlayerControl;
61 P2Control: TPlayerControl;
62 end;
64 procedure g_Options_SetDefault();
65 procedure g_Options_Read(FileName: String);
66 procedure g_Options_Write(FileName: String);
67 procedure g_Options_Write_Language(FileName: String);
68 procedure g_Options_Write_Video(FileName: String);
69 procedure g_Options_Write_Gameplay_Custom(FileName: String);
70 procedure g_Options_Write_Gameplay_Net(FileName: String);
71 procedure g_Options_Write_Net_Server(FileName: String);
72 procedure g_Options_Write_Net_Client(FileName: String);
74 var
75 gGameControls: TControls;
76 gScreenWidth: Word = 800;
77 gScreenHeight: Word = 600;
78 gWinRealPosX: Integer = 0;
79 gWinRealPosY: Integer = 0;
80 gBPP: Byte = 32;
81 gFreq: Byte = 0;
82 gFullscreen: Boolean = False;
83 gWinMaximized: Boolean = False;
84 gVSync: Boolean = False;
85 glLegacyNPOT: Boolean = False;
86 gTextureFilter: Boolean = True;
87 gNoSound: Boolean = False;
88 gSoundLevel: Byte = 75;
89 gMusicLevel: Byte = 65;
90 gMaxSimSounds: Byte = 8;
91 gMuteWhenInactive: Boolean = False;
92 gAdvCorpses: Boolean = True;
93 gAdvBlood: Boolean = True;
94 gAdvGibs: Boolean = True;
95 gGibsCount: Integer = 32;
96 gBloodCount: Byte = 3;
97 gFlash: Byte = 1;
98 gDrawBackGround: Boolean = True;
99 gShowMessages: Boolean = True;
100 gRevertPlayers: Boolean = False;
101 gLanguage: String = LANGUAGE_ENGLISH;
102 gAskLanguage: Boolean = True;
103 gcMap: String = '';
104 gcGameMode: String = '';
105 gcTimeLimit: Word = 0;
106 gcGoalLimit: Word = 0;
107 gcMaxLives: Byte = 0;
108 gcPlayers: Byte = 1;
109 gcTeamDamage: Boolean = False;
110 gcAllowExit: Boolean = True;
111 gcWeaponStay: Boolean = False;
112 gcMonsters: Boolean = False;
113 gcBotsVS: String = 'Everybody';
114 gnMap: String = '';
115 gnGameMode: String = '';
116 gnTimeLimit: Word = 0;
117 gnGoalLimit: Word = 0;
118 gnMaxLives: Byte = 0;
119 gnPlayers: Byte = 1;
120 gnTeamDamage: Boolean = False;
121 gnAllowExit: Boolean = True;
122 gnWeaponStay: Boolean = False;
123 gnMonsters: Boolean = False;
124 gnBotsVS: String = 'Everybody';
125 gsSDLSampleRate: Integer = 44100;
126 gsSDLBufferSize: Integer = 2048;
127 gSFSDebug: Boolean = False;
128 gSFSFastMode: Boolean = False;
129 gDefaultMegawadStart: AnsiString = 'megawads/DOOM2D.WAD:\MAP01';
131 implementation
133 uses
134 e_log, e_input, g_window, g_sound, g_gfx, g_player, Math,
135 g_map, g_net, g_netmaster, SysUtils, CONFIG, g_game, g_main, e_textures,
136 g_items, GL, GLExt, wadreader, e_graphics;
138 procedure g_Options_SetDefault();
139 var
140 i: Integer;
141 begin
142 g_Sound_SetupAllVolumes(75, 65);
143 gMaxSimSounds := 8;
144 gMuteWhenInactive := False;
145 gAnnouncer := ANNOUNCE_MEPLUS;
146 gSoundEffectsDF := True;
147 g_GFX_SetMax(2000);
148 g_Gibs_SetMax(150);
149 g_Corpses_SetMax(20);
150 g_Shells_SetMax(300);
151 gGibsCount := 32;
152 gBloodCount := 3;
153 gAdvBlood := True;
154 gAdvCorpses := True;
155 gAdvGibs := True;
156 gFlash := 1;
157 gDrawBackGround := True;
158 gShowMessages := True;
159 gRevertPlayers := False;
161 for i := 0 to e_MaxJoys-1 do
162 e_JoystickDeadzones[i] := 8192;
164 with gGameControls.GameControls do
165 begin
166 TakeScreenshot := 183;
167 Stat := 15;
168 Chat := 20; // [T]
169 TeamChat := 21; // [Y]
170 end;
172 with gGameControls.P1Control do
173 begin
174 KeyRight := 77;
175 KeyLeft := 75;
176 KeyUp := 72;
177 KeyDown := 76;
178 KeyFire := 184;
179 KeyJump := 157;
180 KeyNextWeapon := 73;
181 KeyPrevWeapon := 71;
182 KeyOpen := 54;
183 KeyStrafe := 0;
184 for i := 0 to High(KeyWeapon) do
185 KeyWeapon[i] := 0;
187 KeyRight2 := 0;
188 KeyLeft2 := 0;
189 KeyUp2 := 0;
190 KeyDown2 := 0;
191 KeyFire2 := 0;
192 KeyJump2 := 0;
193 KeyNextWeapon2 := 0;
194 KeyPrevWeapon2 := 0;
195 KeyOpen2 := 0;
196 KeyStrafe2 := 0;
197 for i := 0 to High(KeyWeapon2) do
198 KeyWeapon2[i] := 0;
199 end;
201 with gGameControls.P2Control do
202 begin
203 KeyRight := 33;
204 KeyLeft := 31;
205 KeyUp := 18;
206 KeyDown := 32;
207 KeyFire := 30;
208 KeyJump := 16;
209 KeyNextWeapon := 19;
210 KeyPrevWeapon := 17;
211 KeyOpen := 58;
212 KeyStrafe := 0;
213 for i := 0 to High(KeyWeapon) do
214 KeyWeapon[i] := 0;
216 KeyRight2 := 0;
217 KeyLeft2 := 0;
218 KeyUp2 := 0;
219 KeyDown2 := 0;
220 KeyFire2 := 0;
221 KeyJump2 := 0;
222 KeyNextWeapon2 := 0;
223 KeyPrevWeapon2 := 0;
224 KeyOpen2 := 0;
225 KeyStrafe2 := 0;
226 for i := 0 to High(KeyWeapon2) do
227 KeyWeapon2[i] := 0;
228 end;
230 with gPlayer1Settings do
231 begin
232 Name := 'Player1';
233 Model := STD_PLAYER_MODEL;
234 Color.R := PLAYER1_DEF_COLOR.R;
235 Color.G := PLAYER1_DEF_COLOR.G;
236 Color.B := PLAYER1_DEF_COLOR.B;
237 Team := TEAM_RED;
238 end;
240 with gPlayer2Settings do
241 begin
242 Name := 'Player2';
243 Model := STD_PLAYER_MODEL;
244 Color.R := PLAYER2_DEF_COLOR.R;
245 Color.G := PLAYER2_DEF_COLOR.G;
246 Color.B := PLAYER2_DEF_COLOR.B;
247 Team := TEAM_BLUE;
248 end;
250 NetUseMaster := True;
251 g_Net_Slist_Set('mpms.doom2d.org', 25665);
252 end;
254 procedure g_Options_Read(FileName: String);
255 var
256 config: TConfig;
257 str: String;
258 i: Integer;
259 begin
260 gAskLanguage := True;
261 e_WriteLog('Reading config', MSG_NOTIFY);
263 if not FileExists(FileName) then
264 begin
265 e_WriteLog('Config file '+FileName+' not found', MSG_WARNING);
266 g_Options_SetDefault();
268 // Default video options:
269 gScreenWidth := 800;
270 gScreenHeight := 600;
271 gWinRealPosX := 0;
272 gWinRealPosY := 0;
273 gWinMaximized := False;
274 gFullScreen := False;
275 gBPP := 32;
276 gVSync := False;
277 gTextureFilter := True;
278 glLegacyNPOT := False;
280 Exit;
281 end;
283 config := TConfig.CreateFile(FileName);
285 gScreenWidth := config.ReadInt('Video', 'ScreenWidth', 800);
286 if gScreenWidth < 640 then
287 gScreenWidth := 640;
288 gScreenHeight := config.ReadInt('Video', 'ScreenHeight', 600);
289 if gScreenHeight < 480 then
290 gScreenHeight := 480;
291 gWinRealPosX := config.ReadInt('Video', 'WinPosX', 0);
292 if gWinRealPosX < 0 then
293 gWinRealPosX := 0;
294 gWinRealPosY := config.ReadInt('Video', 'WinPosY', 0);
295 if gWinRealPosY < 0 then
296 gWinRealPosY := 0;
297 gFullScreen := config.ReadBool('Video', 'Fullscreen', False);
298 gWinMaximized := config.ReadBool('Video', 'Maximized', False);
299 gBPP := config.ReadInt('Video', 'BPP', 32);
300 gFreq := config.ReadInt('Video', 'Freq', 0);
301 gVSync := config.ReadBool('Video', 'VSync', True);
302 gTextureFilter := config.ReadBool('Video', 'TextureFilter', True);
303 glLegacyNPOT := config.ReadBool('Video', 'LegacyCompatible', False);
305 gNoSound := config.ReadBool('Sound', 'NoSound', False);
306 gSoundLevel := Min(config.ReadInt('Sound', 'SoundLevel', 75), 255);
307 gMusicLevel := Min(config.ReadInt('Sound', 'MusicLevel', 65), 255);
308 gMaxSimSounds := Max(Min(config.ReadInt('Sound', 'MaxSimSounds', 8), 66), 2);
309 gMuteWhenInactive := config.ReadBool('Sound', 'MuteInactive', False);
310 gAnnouncer := Min(Max(config.ReadInt('Sound', 'Announcer', ANNOUNCE_MEPLUS), ANNOUNCE_NONE), ANNOUNCE_ALL);
311 gSoundEffectsDF := config.ReadBool('Sound', 'SoundEffectsDF', True);
312 gsSDLSampleRate := Min(Max(config.ReadInt('Sound', 'SDLSampleRate', 44100), 11025), 96000);
313 gsSDLBufferSize := Min(Max(config.ReadInt('Sound', 'SDLBufferSize', 2048), 64), 16384);
315 with gGameControls.GameControls do
316 begin
317 TakeScreenshot := config.ReadInt('GameControls', 'TakeScreenshot', 183);
318 Stat := config.ReadInt('GameControls', 'Stat', 15);
319 Chat := config.ReadInt('GameControls', 'Chat', 20);
320 TeamChat := config.ReadInt('GameControls', 'TeamChat', 21);
321 end;
323 with gGameControls.P1Control, config do
324 begin
325 KeyRight := ReadInt('Player1', 'KeyRight', 33);
326 KeyLeft := ReadInt('Player1', 'KeyLeft', 31);
327 KeyUp := ReadInt('Player1', 'KeyUp', 18);
328 KeyDown := ReadInt('Player1', 'KeyDown', 32);
329 KeyFire := ReadInt('Player1', 'KeyFire', 30);
330 KeyJump := ReadInt('Player1', 'KeyJump', 16);
331 KeyNextWeapon := ReadInt('Player1', 'KeyNextWeapon', 19);
332 KeyPrevWeapon := ReadInt('Player1', 'KeyPrevWeapon', 17);
333 KeyOpen := ReadInt('Player1', 'KeyOpen', 58);
334 KeyStrafe := ReadInt('Player1', 'KeyStrafe', 0);
335 for i := 0 to High(KeyWeapon) do
336 KeyWeapon[i] := ReadInt('Player1', 'KeyWeapon' + IntToStr(i), 0);
338 KeyRight2 := ReadInt('Player1', 'KeyRight2', 0);
339 KeyLeft2 := ReadInt('Player1', 'KeyLeft2', 0);
340 KeyUp2 := ReadInt('Player1', 'KeyUp2', 0);
341 KeyDown2 := ReadInt('Player1', 'KeyDown2', 0);
342 KeyFire2 := ReadInt('Player1', 'KeyFire2', 0);
343 KeyJump2 := ReadInt('Player1', 'KeyJump2', 0);
344 KeyNextWeapon2 := ReadInt('Player1', 'KeyNextWeapon2', 0);
345 KeyPrevWeapon2 := ReadInt('Player1', 'KeyPrevWeapon2', 0);
346 KeyOpen2 := ReadInt('Player1', 'KeyOpen2', 0);
347 KeyStrafe2 := ReadInt('Player1', 'KeyStrafe2', 0);
348 for i := 0 to High(KeyWeapon2) do
349 KeyWeapon2[i] := ReadInt('Player1', 'KeyWeapon2' + IntToStr(i), 0);
350 end;
352 with gPlayer1Settings, config do
353 begin
354 Name := ReadStr('Player1', 'name', 'Player1');
355 Model := ReadStr('Player1', 'model', STD_PLAYER_MODEL);
356 Color.R := Min(Abs(ReadInt('Player1', 'red', PLAYER1_DEF_COLOR.R)), 255);
357 Color.G := Min(Abs(ReadInt('Player1', 'green', PLAYER1_DEF_COLOR.G)), 255);
358 Color.B := Min(Abs(ReadInt('Player1', 'blue', PLAYER1_DEF_COLOR.B)), 255);
359 Team := ReadInt('Player1', 'team', TEAM_RED);
360 if (Team < TEAM_RED) or (Team > TEAM_BLUE) then
361 Team := TEAM_RED;
362 end;
364 with gGameControls.P2Control, config do
365 begin
366 KeyRight := ReadInt('Player2', 'KeyRight', 205);
367 KeyLeft := ReadInt('Player2', 'KeyLeft', 203);
368 KeyUp := ReadInt('Player2', 'KeyUp', 200);
369 KeyDown := ReadInt('Player2', 'KeyDown', 208);
370 KeyFire := ReadInt('Player2', 'KeyFire', 184);
371 KeyJump := ReadInt('Player2', 'KeyJump', 157);
372 KeyNextWeapon := ReadInt('Player2', 'KeyNextWeapon', 73);
373 KeyPrevWeapon := ReadInt('Player2', 'KeyPrevWeapon', 71);
374 KeyOpen := ReadInt('Player2', 'KeyOpen', 54);
375 KeyStrafe := ReadInt('Player2', 'KeyStrafe', 0);
376 for i := 0 to High(KeyWeapon) do
377 KeyWeapon[i] := ReadInt('Player2', 'KeyWeapon' + IntToStr(i), 0);
379 KeyRight2 := ReadInt('Player2', 'KeyRight2', 0);
380 KeyLeft2 := ReadInt('Player2', 'KeyLeft2', 0);
381 KeyUp2 := ReadInt('Player2', 'KeyUp2', 0);
382 KeyDown2 := ReadInt('Player2', 'KeyDown2', 0);
383 KeyFire2 := ReadInt('Player2', 'KeyFire2', 0);
384 KeyJump2 := ReadInt('Player2', 'KeyJump2', 0);
385 KeyNextWeapon2 := ReadInt('Player2', 'KeyNextWeapon2', 0);
386 KeyPrevWeapon2 := ReadInt('Player2', 'KeyPrevWeapon2', 0);
387 KeyOpen2 := ReadInt('Player2', 'KeyOpen2', 0);
388 KeyStrafe2 := ReadInt('Player2', 'KeyStrafe2', 0);
389 for i := 0 to High(KeyWeapon2) do
390 KeyWeapon2[i] := ReadInt('Player2', 'KeyWeapon2' + IntToStr(i), 0);
391 end;
393 with gPlayer2Settings, config do
394 begin
395 Name := ReadStr('Player2', 'name', 'Player2');
396 Model := ReadStr('Player2', 'model', STD_PLAYER_MODEL);
397 Color.R := Min(Abs(ReadInt('Player2', 'red', PLAYER2_DEF_COLOR.R)), 255);
398 Color.G := Min(Abs(ReadInt('Player2', 'green', PLAYER2_DEF_COLOR.G)), 255);
399 Color.B := Min(Abs(ReadInt('Player2', 'blue', PLAYER2_DEF_COLOR.B)), 255);
400 Team := ReadInt('Player2', 'team', TEAM_BLUE);
401 if (Team < TEAM_RED) or (Team > TEAM_BLUE) then
402 Team := TEAM_RED;
403 end;
405 for i := 0 to e_MaxJoys-1 do
406 e_JoystickDeadzones[i] := config.ReadInt('Joysticks', 'Deadzone' + IntToStr(i), 8192);
408 g_GFX_SetMax(Min(config.ReadInt('Game', 'MaxParticles', 1000), 50000));
409 g_Shells_SetMax(Min(config.ReadInt('Game', 'MaxShells', 300), 600));
410 g_Gibs_SetMax(Min(config.ReadInt('Game', 'MaxGibs', 150), 500));
411 g_Corpses_SetMax(Min(config.ReadInt('Game', 'MaxCorpses', 20), 100));
413 case config.ReadInt('Game', 'GibsCount', 3) of
414 0: gGibsCount := 0;
415 1: gGibsCount := 8;
416 2: gGibsCount := 16;
417 3: gGibsCount := 32;
418 else gGibsCount := 48;
419 end;
421 ITEM_RESPAWNTIME := 36*Max(config.ReadInt('Game', 'ItemRespawnTime', 60), 0);
422 gBloodCount := Min(config.ReadInt('Game', 'BloodCount', 4), 4);
423 gAdvBlood := config.ReadBool('Game', 'AdvancesBlood', True);
424 gAdvCorpses := config.ReadBool('Game', 'AdvancesCorpses', True);
425 gAdvGibs := config.ReadBool('Game', 'AdvancesGibs', True);
426 gFlash := Min(Max(config.ReadInt('Game', 'Flash', 1), 0), 2);
427 gDrawBackGround := config.ReadBool('Game', 'BackGround', True);
428 gShowMessages := config.ReadBool('Game', 'Messages', True);
429 gRevertPlayers := config.ReadBool('Game', 'RevertPlayers', False);
430 gChatBubble := Min(Max(config.ReadInt('Game', 'ChatBubble', 4), 0), 4);
431 gSFSDebug := config.ReadBool('Game', 'SFSDebug', False);
432 wadoptDebug := gSFSDebug;
433 gSFSFastMode := config.ReadBool('Game', 'SFSFastMode', False);
434 wadoptFast := gSFSFastMode;
435 e_FastScreenshots := config.ReadBool('Game', 'FastScreenshots', True);
436 gDefaultMegawadStart := config.ReadStr('Game', 'DefaultMegawadStart', 'megawads/DOOM2D.WAD:\MAP01');
438 // Ãåéìïëåé â ñâîåé èãðå
439 gcMap := config.ReadStr('GameplayCustom', 'Map', '');
440 gcGameMode := config.ReadStr('GameplayCustom', 'GameMode', _lc[I_MENU_GAME_TYPE_DM]);
441 gcTimeLimit := Min(Max(config.ReadInt('GameplayCustom', 'TimeLimit', 0), 0), 65535);
442 gcGoalLimit := Min(Max(config.ReadInt('GameplayCustom', 'GoalLimit', 0), 0), 65535);
443 gcMaxLives := Min(Max(config.ReadInt('GameplayCustom', 'MaxLives', 0), 0), 255);
444 gcPlayers := Min(Max(config.ReadInt('GameplayCustom', 'Players', 1), 0), 2);
445 gcTeamDamage := config.ReadBool('GameplayCustom', 'TeamDamage', False);
446 gcAllowExit := config.ReadBool('GameplayCustom', 'AllowExit', True);
447 gcWeaponStay := config.ReadBool('GameplayCustom', 'WeaponStay', False);
448 gcMonsters := config.ReadBool('GameplayCustom', 'Monsters', False);
449 gcBotsVS := config.ReadStr('GameplayCustom', 'BotsVS', 'Everybody');
451 with gGameSettings do
452 begin
453 GameMode := g_Game_TextToMode(gcGameMode);
454 if GameMode = GM_NONE then
455 GameMode := GM_DM;
456 if GameMode = GM_SINGLE then
457 GameMode := GM_COOP;
458 TimeLimit := gcTimeLimit;
459 GoalLimit := gcGoalLimit;
460 MaxLives := gcMaxLives;
462 Options := 0;
463 if gcTeamDamage then
464 Options := Options or GAME_OPTION_TEAMDAMAGE;
465 if gcAllowExit then
466 Options := Options or GAME_OPTION_ALLOWEXIT;
467 if gcWeaponStay then
468 Options := Options or GAME_OPTION_WEAPONSTAY;
469 if gcMonsters then
470 Options := Options or GAME_OPTION_MONSTERS;
471 if gcBotsVS = 'Everybody' then
472 Options := Options or GAME_OPTION_BOTVSPLAYER or GAME_OPTION_BOTVSMONSTER;
473 if gcBotsVS = 'Players' then
474 Options := Options or GAME_OPTION_BOTVSPLAYER;
475 if gcBotsVS = 'Monsters' then
476 Options := Options or GAME_OPTION_BOTVSMONSTER;
477 end;
479 // Ãåéìïëåé â ñåòåâîé èãðå
480 gnMap := config.ReadStr('GameplayNetwork', 'Map', '');
481 gnGameMode := config.ReadStr('GameplayNetwork', 'GameMode', _lc[I_MENU_GAME_TYPE_DM]);
482 gnTimeLimit := Min(Max(config.ReadInt('GameplayNetwork', 'TimeLimit', 0), 0), 65535);
483 gnGoalLimit := Min(Max(config.ReadInt('GameplayNetwork', 'GoalLimit', 0), 0), 65535);
484 gnMaxLives := Min(Max(config.ReadInt('GameplayNetwork', 'MaxLives', 0), 0), 255);
485 gnPlayers := Min(Max(config.ReadInt('GameplayNetwork', 'Players', 1), 0), 2);
486 gnTeamDamage := config.ReadBool('GameplayNetwork', 'TeamDamage', False);
487 gnAllowExit := config.ReadBool('GameplayNetwork', 'AllowExit', True);
488 gnWeaponStay := config.ReadBool('GameplayNetwork', 'WeaponStay', False);
489 gnMonsters := config.ReadBool('GameplayNetwork', 'Monsters', False);
490 gnBotsVS := config.ReadStr('GameplayNetwork', 'BotsVS', 'Everybody');
492 // Îáùèå ñåòåâûå
493 NetSlistIP := config.ReadStr('MasterServer', 'IP', 'mpms.doom2d.org');
494 NetSlistPort := config.ReadInt('MasterServer', 'Port', 25665);
496 // Ñåðâåð
497 NetServerName := config.ReadStr('Server', 'Name', 'Unnamed Server');
498 NetPassword := config.ReadStr('Server', 'Password', '');
499 NetPort := Min(Max(0, config.ReadInt('Server', 'Port', 25666)), 65535);
500 NetMaxClients := Min(Max(0, config.ReadInt('Server', 'MaxClients', 16)), NET_MAXCLIENTS);
501 NetAllowRCON := config.ReadBool('Server', 'RCON', False);
502 NetRCONPassword := config.ReadStr('Server', 'RCONPassword', 'default');
503 NetUseMaster := config.ReadBool('Server', 'SyncWithMaster', True);
504 NetUpdateRate := Max(0, config.ReadInt('Server', 'UpdateInterval', 0));
505 NetRelupdRate := Max(0, config.ReadInt('Server', 'ReliableUpdateInterval', 18));
506 NetMasterRate := Max(1, config.ReadInt('Server', 'MasterSyncInterval', 60000));
508 // Êëèåíò
509 NetInterpLevel := Max(0, config.ReadInt('Client', 'InterpolationSteps', 2));
510 NetForcePlayerUpdate := config.ReadBool('Client', 'ForcePlayerUpdate', False);
511 NetPredictSelf := config.ReadBool('Client', 'PredictSelf', True);
512 NetClientIP := config.ReadStr('Client', 'LastIP', '127.0.0.1');
513 NetClientPort := Max(0, config.ReadInt('Client', 'LastPort', 25666));
515 // ßçûê:
516 str := config.ReadStr('Game', 'Language', '');
517 if (str = LANGUAGE_RUSSIAN) or
518 (str = LANGUAGE_ENGLISH) then
519 begin
520 gLanguage := str;
521 gAskLanguage := False;
522 end
523 else
524 gLanguage := LANGUAGE_ENGLISH;
526 config.Free();
528 if gTextureFilter then
529 TEXTUREFILTER := GL_LINEAR
530 else
531 TEXTUREFILTER := GL_NEAREST;
532 end;
534 procedure g_Options_Write(FileName: String);
535 var
536 config: TConfig;
537 i: Integer;
538 begin
539 e_WriteLog('Writing config', MSG_NOTIFY);
541 config := TConfig.CreateFile(FileName);
543 config.WriteInt('Video', 'ScreenWidth', gScreenWidth);
544 config.WriteInt('Video', 'ScreenHeight', gScreenHeight);
545 config.WriteInt('Video', 'WinPosX', gWinRealPosX);
546 config.WriteInt('Video', 'WinPosY', gWinRealPosY);
547 config.WriteBool('Video', 'Fullscreen', gFullScreen);
548 config.WriteBool('Video', 'Maximized', gWinMaximized);
549 config.WriteInt('Video', 'BPP', gBPP);
550 config.WriteBool('Video', 'VSync', gVSync);
551 config.WriteBool('Video', 'TextureFilter', gTextureFilter);
552 config.WriteBool('Video', 'LegacyCompatible', glLegacyNPOT);
554 config.WriteBool('Sound', 'NoSound', gNoSound);
555 config.WriteInt('Sound', 'SoundLevel', gSoundLevel);
556 config.WriteInt('Sound', 'MusicLevel', gMusicLevel);
557 config.WriteInt('Sound', 'MaxSimSounds', gMaxSimSounds);
558 config.WriteBool('Sound', 'MuteInactive', gMuteWhenInactive);
559 config.WriteInt('Sound', 'Announcer', gAnnouncer);
560 config.WriteBool('Sound', 'SoundEffectsDF', gSoundEffectsDF);
561 config.WriteInt('Sound', 'SDLSampleRate', gsSDLSampleRate);
562 config.WriteInt('Sound', 'SDLBufferSize', gsSDLBufferSize);
564 with config, gGameControls.GameControls do
565 begin
566 WriteInt('GameControls', 'TakeScreenshot', TakeScreenshot);
567 WriteInt('GameControls', 'Stat', Stat);
568 WriteInt('GameControls', 'Chat', Chat);
569 WriteInt('GameControls', 'TeamChat', TeamChat);
570 end;
572 with config, gGameControls.P1Control, gPlayer1Settings do
573 begin
574 WriteInt('Player1', 'KeyRight', KeyRight);
575 WriteInt('Player1', 'KeyLeft', KeyLeft);
576 WriteInt('Player1', 'KeyUp', KeyUp);
577 WriteInt('Player1', 'KeyDown', KeyDown);
578 WriteInt('Player1', 'KeyFire', KeyFire);
579 WriteInt('Player1', 'KeyJump', KeyJump);
580 WriteInt('Player1', 'KeyNextWeapon', KeyNextWeapon);
581 WriteInt('Player1', 'KeyPrevWeapon', KeyPrevWeapon);
582 WriteInt('Player1', 'KeyOpen', KeyOpen);
583 WriteInt('Player1', 'KeyStrafe', KeyStrafe);
584 for i := 0 to High(KeyWeapon) do
585 WriteInt('Player1', 'KeyWeapon' + IntToStr(i), KeyWeapon[i]);
587 WriteInt('Player1', 'KeyRight2', KeyRight2);
588 WriteInt('Player1', 'KeyLeft2', KeyLeft2);
589 WriteInt('Player1', 'KeyUp2', KeyUp2);
590 WriteInt('Player1', 'KeyDown2', KeyDown2);
591 WriteInt('Player1', 'KeyFire2', KeyFire2);
592 WriteInt('Player1', 'KeyJump2', KeyJump2);
593 WriteInt('Player1', 'KeyNextWeapon2', KeyNextWeapon2);
594 WriteInt('Player1', 'KeyPrevWeapon2', KeyPrevWeapon2);
595 WriteInt('Player1', 'KeyOpen2', KeyOpen2);
596 WriteInt('Player1', 'KeyStrafe2', KeyStrafe2);
597 for i := 0 to High(KeyWeapon2) do
598 WriteInt('Player1', 'KeyWeapon2' + IntToStr(i), KeyWeapon2[i]);
600 WriteStr('Player1', 'Name', Name);
601 WriteStr('Player1', 'model', Model);
602 WriteInt('Player1', 'red', Color.R);
603 WriteInt('Player1', 'green', Color.G);
604 WriteInt('Player1', 'blue', Color.B);
605 WriteInt('Player1', 'team', Team);
606 end;
608 with config, gGameControls.P2Control, gPlayer2Settings do
609 begin
610 WriteInt('Player2', 'KeyRight', KeyRight);
611 WriteInt('Player2', 'KeyLeft', KeyLeft);
612 WriteInt('Player2', 'KeyUp', KeyUp);
613 WriteInt('Player2', 'KeyDown', KeyDown);
614 WriteInt('Player2', 'KeyFire', KeyFire);
615 WriteInt('Player2', 'KeyJump', KeyJump);
616 WriteInt('Player2', 'KeyNextWeapon', KeyNextWeapon);
617 WriteInt('Player2', 'KeyPrevWeapon', KeyPrevWeapon);
618 WriteInt('Player2', 'KeyOpen', KeyOpen);
619 WriteInt('Player2', 'KeyStrafe', KeyStrafe);
620 for i := 0 to High(KeyWeapon) do
621 WriteInt('Player2', 'KeyWeapon' + IntToStr(i), KeyWeapon[i]);
623 WriteInt('Player2', 'KeyRight2', KeyRight2);
624 WriteInt('Player2', 'KeyLeft2', KeyLeft2);
625 WriteInt('Player2', 'KeyUp2', KeyUp2);
626 WriteInt('Player2', 'KeyDown2', KeyDown2);
627 WriteInt('Player2', 'KeyFire2', KeyFire2);
628 WriteInt('Player2', 'KeyJump2', KeyJump2);
629 WriteInt('Player2', 'KeyNextWeapon2', KeyNextWeapon2);
630 WriteInt('Player2', 'KeyPrevWeapon2', KeyPrevWeapon2);
631 WriteInt('Player2', 'KeyOpen2', KeyOpen2);
632 WriteInt('Player2', 'KeyStrafe2', KeyStrafe2);
633 for i := 0 to High(KeyWeapon2) do
634 WriteInt('Player2', 'KeyWeapon2' + IntToStr(i), KeyWeapon2[i]);
636 WriteStr('Player2', 'Name', Name);
637 WriteStr('Player2', 'model', Model);
638 WriteInt('Player2', 'red', Color.R);
639 WriteInt('Player2', 'green', Color.G);
640 WriteInt('Player2', 'blue', Color.B);
641 WriteInt('Player2', 'team', Team);
642 end;
644 for i := 0 to e_MaxJoys-1 do
645 config.WriteInt('Joysticks', 'Deadzone' + IntToStr(i), e_JoystickDeadzones[i]);
647 with config do
648 case gGibsCount of
649 0: config.WriteInt('Game', 'GibsCount', 0);
650 8: config.WriteInt('Game', 'GibsCount', 1);
651 16: config.WriteInt('Game', 'GibsCount', 2);
652 32: config.WriteInt('Game', 'GibsCount', 3);
653 else config.WriteInt('Game', 'GibsCount', 4);
654 end;
656 config.WriteInt('Game', 'ItemRespawnTime', ITEM_RESPAWNTIME div 36);
657 config.WriteInt('Game', 'MaxParticles', g_GFX_GetMax());
658 config.WriteInt('Game', 'MaxShells', g_Shells_GetMax());
659 config.WriteInt('Game', 'MaxGibs', g_Gibs_GetMax());
660 config.WriteInt('Game', 'MaxCorpses', g_Corpses_GetMax());
661 config.WriteInt('Game', 'BloodCount', gBloodCount);
662 config.WriteBool('Game', 'AdvancesBlood', gAdvBlood);
663 config.WriteBool('Game', 'AdvancesCorpses', gAdvCorpses);
664 config.WriteBool('Game', 'AdvancesGibs', gAdvGibs);
665 config.WriteInt('Game', 'Flash', gFlash);
666 config.WriteBool('Game', 'BackGround', gDrawBackGround);
667 config.WriteBool('Game', 'Messages', gShowMessages);
668 config.WriteBool('Game', 'RevertPlayers', gRevertPlayers);
669 config.WriteInt('Game', 'ChatBubble', gChatBubble);
670 config.WriteBool('Game', 'SFSDebug', gSFSDebug);
671 config.WriteBool('Game', 'SFSFastMode', gSFSFastMode);
672 config.WriteBool('Game', 'FastScreenshots', e_FastScreenshots);
673 config.WriteStr('Game', 'DefaultMegawadStart', gDefaultMegawadStart);
675 config.WriteStr ('GameplayCustom', 'Map', gcMap);
676 config.WriteStr ('GameplayCustom', 'GameMode', gcGameMode);
677 config.WriteInt ('GameplayCustom', 'TimeLimit', gcTimeLimit);
678 config.WriteInt ('GameplayCustom', 'GoalLimit', gcGoalLimit);
679 config.WriteInt ('GameplayCustom', 'MaxLives', gcMaxLives);
680 config.WriteInt ('GameplayCustom', 'Players', gcPlayers);
681 config.WriteBool('GameplayCustom', 'TeamDamage', gcTeamDamage);
682 config.WriteBool('GameplayCustom', 'AllowExit', gcAllowExit);
683 config.WriteBool('GameplayCustom', 'WeaponStay', gcWeaponStay);
684 config.WriteBool('GameplayCustom', 'Monsters', gcMonsters);
685 config.WriteStr ('GameplayCustom', 'BotsVS', gcBotsVS);
687 config.WriteStr ('GameplayNetwork', 'Map', gnMap);
688 config.WriteStr ('GameplayNetwork', 'GameMode', gnGameMode);
689 config.WriteInt ('GameplayNetwork', 'TimeLimit', gnTimeLimit);
690 config.WriteInt ('GameplayNetwork', 'GoalLimit', gnGoalLimit);
691 config.WriteInt ('GameplayNetwork', 'MaxLives', gnMaxLives);
692 config.WriteInt ('GameplayNetwork', 'Players', gnPlayers);
693 config.WriteBool('GameplayNetwork', 'TeamDamage', gnTeamDamage);
694 config.WriteBool('GameplayNetwork', 'AllowExit', gnAllowExit);
695 config.WriteBool('GameplayNetwork', 'WeaponStay', gnWeaponStay);
696 config.WriteBool('GameplayNetwork', 'Monsters', gnMonsters);
697 config.WriteStr ('GameplayNetwork', 'BotsVS', gnBotsVS);
699 config.WriteStr('MasterServer', 'IP', NetSlistIP);
700 config.WriteInt('MasterServer', 'Port', NetSlistPort);
702 config.WriteStr ('Server', 'Name', NetServerName);
703 config.WriteStr ('Server', 'Password', NetPassword);
704 config.WriteInt ('Server', 'Port', NetPort);
705 config.WriteInt ('Server', 'MaxClients', NetMaxClients);
706 config.WriteBool('Server', 'RCON', NetAllowRCON);
707 config.WriteStr ('Server', 'RCONPassword', NetRCONPassword);
708 config.WriteBool('Server', 'SyncWithMaster', NetUseMaster);
709 config.WriteInt ('Server', 'UpdateInterval', NetUpdateRate);
710 config.WriteInt ('Server', 'ReliableUpdateInterval', NetRelupdRate);
711 config.WriteInt ('Server', 'MasterSyncInterval', NetMasterRate);
713 config.WriteInt ('Client', 'InterpolationSteps', NetInterpLevel);
714 config.WriteBool ('Client', 'ForcePlayerUpdate', NetForcePlayerUpdate);
715 config.WriteBool ('Client', 'PredictSelf', NetPredictSelf);
716 config.WriteStr ('Client', 'LastIP', NetClientIP);
717 config.WriteInt ('Client', 'LastPort', NetClientPort);
719 config.SaveFile(FileName);
720 config.Free();
721 end;
723 procedure g_Options_Write_Language(FileName: String);
724 var
725 config: TConfig;
726 begin
727 e_WriteLog('Writing language config', MSG_NOTIFY);
729 config := TConfig.CreateFile(FileName);
730 config.WriteStr('Game', 'Language', gLanguage);
731 config.SaveFile(FileName);
732 config.Free();
733 end;
735 procedure g_Options_Write_Video(FileName: String);
736 var
737 config: TConfig;
738 sW, sH: Integer;
739 begin
740 e_WriteLog('Writing resolution to config', MSG_NOTIFY);
742 config := TConfig.CreateFile(FileName);
744 if gWinMaximized and (not gFullscreen) then
745 begin
746 sW := gWinSizeX;
747 sH := gWinSizeY;
748 end
749 else
750 begin
751 sW := gScreenWidth;
752 sH := gScreenHeight;
753 end;
755 config.WriteInt('Video', 'ScreenWidth', sW);
756 config.WriteInt('Video', 'ScreenHeight', sH);
757 config.WriteInt('Video', 'WinPosX', gWinRealPosX);
758 config.WriteInt('Video', 'WinPosY', gWinRealPosY);
759 config.WriteBool('Video', 'Fullscreen', gFullscreen);
760 config.WriteBool('Video', 'Maximized', gWinMaximized);
762 config.SaveFile(FileName);
763 config.Free();
764 end;
766 procedure g_Options_Write_Gameplay_Custom(FileName: String);
767 var
768 config: TConfig;
769 begin
770 e_WriteLog('Writing custom gameplay config', MSG_NOTIFY);
772 config := TConfig.CreateFile(FileName);
774 config.WriteStr ('GameplayCustom', 'Map', gcMap);
775 config.WriteStr ('GameplayCustom', 'GameMode', gcGameMode);
776 config.WriteInt ('GameplayCustom', 'TimeLimit', gcTimeLimit);
777 config.WriteInt ('GameplayCustom', 'GoalLimit', gcGoalLimit);
778 config.WriteInt ('GameplayCustom', 'MaxLives', gcMaxLives);
779 config.WriteInt ('GameplayCustom', 'Players', gcPlayers);
780 config.WriteBool('GameplayCustom', 'TeamDamage', gcTeamDamage);
781 config.WriteBool('GameplayCustom', 'AllowExit', gcAllowExit);
782 config.WriteBool('GameplayCustom', 'WeaponStay', gcWeaponStay);
783 config.WriteBool('GameplayCustom', 'Monsters', gcMonsters);
784 config.WriteStr ('GameplayCustom', 'BotsVS', gcBotsVS);
786 config.SaveFile(FileName);
787 config.Free();
788 end;
790 procedure g_Options_Write_Gameplay_Net(FileName: String);
791 var
792 config: TConfig;
793 begin
794 e_WriteLog('Writing network gameplay config', MSG_NOTIFY);
796 config := TConfig.CreateFile(FileName);
798 config.WriteStr ('GameplayNetwork', 'Map', gnMap);
799 config.WriteStr ('GameplayNetwork', 'GameMode', gnGameMode);
800 config.WriteInt ('GameplayNetwork', 'TimeLimit', gnTimeLimit);
801 config.WriteInt ('GameplayNetwork', 'GoalLimit', gnGoalLimit);
802 config.WriteInt ('GameplayNetwork', 'MaxLives', gnMaxLives);
803 config.WriteInt ('GameplayNetwork', 'Players', gnPlayers);
804 config.WriteBool('GameplayNetwork', 'TeamDamage', gnTeamDamage);
805 config.WriteBool('GameplayNetwork', 'AllowExit', gnAllowExit);
806 config.WriteBool('GameplayNetwork', 'WeaponStay', gnWeaponStay);
807 config.WriteBool('GameplayNetwork', 'Monsters', gnMonsters);
808 config.WriteStr ('GameplayNetwork', 'BotsVS', gnBotsVS);
810 config.SaveFile(FileName);
811 config.Free();
812 end;
814 procedure g_Options_Write_Net_Server(FileName: String);
815 var
816 config: TConfig;
817 begin
818 e_WriteLog('Writing server config', MSG_NOTIFY);
820 config := TConfig.CreateFile(FileName);
822 config.WriteStr ('Server', 'Name', NetServerName);
823 config.WriteStr ('Server', 'Password', NetPassword);
824 config.WriteInt ('Server', 'Port', NetPort);
825 config.WriteInt ('Server', 'MaxClients', NetMaxClients);
826 config.WriteBool('Server', 'SyncWithMaster', NetUseMaster);
828 config.SaveFile(FileName);
829 config.Free();
830 end;
832 procedure g_Options_Write_Net_Client(FileName: String);
833 var
834 config: TConfig;
835 begin
836 e_WriteLog('Writing client config', MSG_NOTIFY);
838 config := TConfig.CreateFile(FileName);
840 config.WriteStr('Client', 'LastIP', NetClientIP);
841 config.WriteInt('Client', 'LastPort', NetClientPort);
843 config.SaveFile(FileName);
844 config.Free();
845 end;
847 end.