DEADSOFTWARE

fixed error message if default megawad map failed to load
[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 const DF_Default_Megawad_Start = 'megawads/DOOM2D.WAD:\MAP01';
76 var
77 gGameControls: TControls;
78 gScreenWidth: Word = 800;
79 gScreenHeight: Word = 600;
80 gWinRealPosX: Integer = 0;
81 gWinRealPosY: Integer = 0;
82 gBPP: Byte = 32;
83 gFreq: Byte = 0;
84 gFullscreen: Boolean = False;
85 gWinMaximized: Boolean = False;
86 gVSync: Boolean = False;
87 glLegacyNPOT: Boolean = False;
88 gTextureFilter: Boolean = True;
89 gNoSound: Boolean = False;
90 gSoundLevel: Byte = 75;
91 gMusicLevel: Byte = 65;
92 gMaxSimSounds: Byte = 8;
93 gMuteWhenInactive: Boolean = False;
94 gAdvCorpses: Boolean = True;
95 gAdvBlood: Boolean = True;
96 gAdvGibs: Boolean = True;
97 gGibsCount: Integer = 32;
98 gBloodCount: Byte = 3;
99 gFlash: Byte = 1;
100 gDrawBackGround: Boolean = True;
101 gShowMessages: Boolean = True;
102 gRevertPlayers: Boolean = False;
103 gLanguage: String = LANGUAGE_ENGLISH;
104 gAskLanguage: Boolean = True;
105 gcMap: String = '';
106 gcGameMode: String = '';
107 gcTimeLimit: Word = 0;
108 gcGoalLimit: Word = 0;
109 gcMaxLives: Byte = 0;
110 gcPlayers: Byte = 1;
111 gcTeamDamage: Boolean = False;
112 gcAllowExit: Boolean = True;
113 gcWeaponStay: Boolean = False;
114 gcMonsters: Boolean = False;
115 gcBotsVS: String = 'Everybody';
116 gnMap: String = '';
117 gnGameMode: String = '';
118 gnTimeLimit: Word = 0;
119 gnGoalLimit: Word = 0;
120 gnMaxLives: Byte = 0;
121 gnPlayers: Byte = 1;
122 gnTeamDamage: Boolean = False;
123 gnAllowExit: Boolean = True;
124 gnWeaponStay: Boolean = False;
125 gnMonsters: Boolean = False;
126 gnBotsVS: String = 'Everybody';
127 gsSDLSampleRate: Integer = 44100;
128 gsSDLBufferSize: Integer = 2048;
129 gSFSDebug: Boolean = False;
130 gSFSFastMode: Boolean = False;
131 gDefaultMegawadStart: AnsiString = DF_Default_Megawad_Start;
132 gBerserkAutoswitch: Boolean = True;
134 implementation
136 uses
137 e_log, e_input, g_window, g_sound, g_gfx, g_player, Math,
138 g_map, g_net, g_netmaster, SysUtils, CONFIG, g_game, g_main, e_texture,
139 g_items, GL, GLExt, wadreader, e_graphics;
141 procedure g_Options_SetDefault();
142 var
143 i: Integer;
144 begin
145 g_Sound_SetupAllVolumes(75, 65);
146 gMaxSimSounds := 8;
147 gMuteWhenInactive := False;
148 gAnnouncer := ANNOUNCE_MEPLUS;
149 gSoundEffectsDF := True;
150 g_GFX_SetMax(2000);
151 g_Gibs_SetMax(150);
152 g_Corpses_SetMax(20);
153 g_Shells_SetMax(300);
154 gGibsCount := 32;
155 gBloodCount := 3;
156 gAdvBlood := True;
157 gAdvCorpses := True;
158 gAdvGibs := True;
159 gFlash := 1;
160 gDrawBackGround := True;
161 gShowMessages := True;
162 gRevertPlayers := False;
164 for i := 0 to e_MaxJoys-1 do
165 e_JoystickDeadzones[i] := 8192;
167 with gGameControls.GameControls do
168 begin
169 TakeScreenshot := 183;
170 Stat := 15;
171 Chat := 20; // [T]
172 TeamChat := 21; // [Y]
173 end;
175 with gGameControls.P1Control do
176 begin
177 KeyRight := 77;
178 KeyLeft := 75;
179 KeyUp := 72;
180 KeyDown := 76;
181 KeyFire := 184;
182 KeyJump := 157;
183 KeyNextWeapon := 73;
184 KeyPrevWeapon := 71;
185 KeyOpen := 54;
186 KeyStrafe := 0;
187 for i := 0 to High(KeyWeapon) do
188 KeyWeapon[i] := 0;
190 KeyRight2 := 0;
191 KeyLeft2 := 0;
192 KeyUp2 := 0;
193 KeyDown2 := 0;
194 KeyFire2 := 0;
195 KeyJump2 := 0;
196 KeyNextWeapon2 := 0;
197 KeyPrevWeapon2 := 0;
198 KeyOpen2 := 0;
199 KeyStrafe2 := 0;
200 for i := 0 to High(KeyWeapon2) do
201 KeyWeapon2[i] := 0;
202 end;
204 with gGameControls.P2Control do
205 begin
206 KeyRight := 33;
207 KeyLeft := 31;
208 KeyUp := 18;
209 KeyDown := 32;
210 KeyFire := 30;
211 KeyJump := 16;
212 KeyNextWeapon := 19;
213 KeyPrevWeapon := 17;
214 KeyOpen := 58;
215 KeyStrafe := 0;
216 for i := 0 to High(KeyWeapon) do
217 KeyWeapon[i] := 0;
219 KeyRight2 := 0;
220 KeyLeft2 := 0;
221 KeyUp2 := 0;
222 KeyDown2 := 0;
223 KeyFire2 := 0;
224 KeyJump2 := 0;
225 KeyNextWeapon2 := 0;
226 KeyPrevWeapon2 := 0;
227 KeyOpen2 := 0;
228 KeyStrafe2 := 0;
229 for i := 0 to High(KeyWeapon2) do
230 KeyWeapon2[i] := 0;
231 end;
233 with gPlayer1Settings do
234 begin
235 Name := 'Player1';
236 Model := STD_PLAYER_MODEL;
237 Color.R := PLAYER1_DEF_COLOR.R;
238 Color.G := PLAYER1_DEF_COLOR.G;
239 Color.B := PLAYER1_DEF_COLOR.B;
240 Team := TEAM_RED;
241 end;
243 with gPlayer2Settings do
244 begin
245 Name := 'Player2';
246 Model := STD_PLAYER_MODEL;
247 Color.R := PLAYER2_DEF_COLOR.R;
248 Color.G := PLAYER2_DEF_COLOR.G;
249 Color.B := PLAYER2_DEF_COLOR.B;
250 Team := TEAM_BLUE;
251 end;
253 NetUseMaster := True;
254 g_Net_Slist_Set('mpms.doom2d.org', 25665);
255 end;
257 procedure g_Options_Read(FileName: String);
258 var
259 config: TConfig;
260 str: String;
261 i: Integer;
262 begin
263 gAskLanguage := True;
264 e_WriteLog('Reading config', TMsgType.Notify);
266 if not FileExists(FileName) then
267 begin
268 e_WriteLog('Config file '+FileName+' not found', TMsgType.Warning);
269 g_Options_SetDefault();
271 // Default video options:
272 gScreenWidth := 800;
273 gScreenHeight := 600;
274 gWinRealPosX := 0;
275 gWinRealPosY := 0;
276 gWinMaximized := False;
277 gFullScreen := False;
278 gBPP := 32;
279 gVSync := False;
280 gTextureFilter := True;
281 glLegacyNPOT := False;
283 Exit;
284 end;
286 config := TConfig.CreateFile(FileName);
288 gScreenWidth := config.ReadInt('Video', 'ScreenWidth', 800);
289 if gScreenWidth < 640 then
290 gScreenWidth := 640;
291 gScreenHeight := config.ReadInt('Video', 'ScreenHeight', 600);
292 if gScreenHeight < 480 then
293 gScreenHeight := 480;
294 gWinRealPosX := config.ReadInt('Video', 'WinPosX', 0);
295 if gWinRealPosX < 0 then
296 gWinRealPosX := 0;
297 gWinRealPosY := config.ReadInt('Video', 'WinPosY', 0);
298 if gWinRealPosY < 0 then
299 gWinRealPosY := 0;
300 gFullScreen := config.ReadBool('Video', 'Fullscreen', False);
301 gWinMaximized := config.ReadBool('Video', 'Maximized', False);
302 gBPP := config.ReadInt('Video', 'BPP', 32);
303 gFreq := config.ReadInt('Video', 'Freq', 0);
304 gVSync := config.ReadBool('Video', 'VSync', True);
305 gTextureFilter := config.ReadBool('Video', 'TextureFilter', True);
306 glLegacyNPOT := config.ReadBool('Video', 'LegacyCompatible', False);
308 gNoSound := config.ReadBool('Sound', 'NoSound', False);
309 gSoundLevel := Min(config.ReadInt('Sound', 'SoundLevel', 75), 255);
310 gMusicLevel := Min(config.ReadInt('Sound', 'MusicLevel', 65), 255);
311 gMaxSimSounds := Max(Min(config.ReadInt('Sound', 'MaxSimSounds', 8), 66), 2);
312 gMuteWhenInactive := config.ReadBool('Sound', 'MuteInactive', False);
313 gAnnouncer := Min(Max(config.ReadInt('Sound', 'Announcer', ANNOUNCE_MEPLUS), ANNOUNCE_NONE), ANNOUNCE_ALL);
314 gSoundEffectsDF := config.ReadBool('Sound', 'SoundEffectsDF', True);
315 gsSDLSampleRate := Min(Max(config.ReadInt('Sound', 'SDLSampleRate', 44100), 11025), 96000);
316 gsSDLBufferSize := Min(Max(config.ReadInt('Sound', 'SDLBufferSize', 2048), 64), 16384);
318 with gGameControls.GameControls do
319 begin
320 TakeScreenshot := config.ReadInt('GameControls', 'TakeScreenshot', 183);
321 Stat := config.ReadInt('GameControls', 'Stat', 15);
322 Chat := config.ReadInt('GameControls', 'Chat', 20);
323 TeamChat := config.ReadInt('GameControls', 'TeamChat', 21);
324 end;
326 with gGameControls.P1Control, config do
327 begin
328 KeyRight := ReadInt('Player1', 'KeyRight', 33);
329 KeyLeft := ReadInt('Player1', 'KeyLeft', 31);
330 KeyUp := ReadInt('Player1', 'KeyUp', 18);
331 KeyDown := ReadInt('Player1', 'KeyDown', 32);
332 KeyFire := ReadInt('Player1', 'KeyFire', 30);
333 KeyJump := ReadInt('Player1', 'KeyJump', 16);
334 KeyNextWeapon := ReadInt('Player1', 'KeyNextWeapon', 19);
335 KeyPrevWeapon := ReadInt('Player1', 'KeyPrevWeapon', 17);
336 KeyOpen := ReadInt('Player1', 'KeyOpen', 58);
337 KeyStrafe := ReadInt('Player1', 'KeyStrafe', 0);
338 for i := 0 to High(KeyWeapon) do
339 KeyWeapon[i] := ReadInt('Player1', 'KeyWeapon' + IntToStr(i), 0);
341 KeyRight2 := ReadInt('Player1', 'KeyRight2', 0);
342 KeyLeft2 := ReadInt('Player1', 'KeyLeft2', 0);
343 KeyUp2 := ReadInt('Player1', 'KeyUp2', 0);
344 KeyDown2 := ReadInt('Player1', 'KeyDown2', 0);
345 KeyFire2 := ReadInt('Player1', 'KeyFire2', 0);
346 KeyJump2 := ReadInt('Player1', 'KeyJump2', 0);
347 KeyNextWeapon2 := ReadInt('Player1', 'KeyNextWeapon2', 0);
348 KeyPrevWeapon2 := ReadInt('Player1', 'KeyPrevWeapon2', 0);
349 KeyOpen2 := ReadInt('Player1', 'KeyOpen2', 0);
350 KeyStrafe2 := ReadInt('Player1', 'KeyStrafe2', 0);
351 for i := 0 to High(KeyWeapon2) do
352 KeyWeapon2[i] := ReadInt('Player1', 'KeyWeapon2' + IntToStr(i), 0);
353 end;
355 with gPlayer1Settings, config do
356 begin
357 Name := ReadStr('Player1', 'name', 'Player1');
358 Model := ReadStr('Player1', 'model', STD_PLAYER_MODEL);
359 Color.R := Min(Abs(ReadInt('Player1', 'red', PLAYER1_DEF_COLOR.R)), 255);
360 Color.G := Min(Abs(ReadInt('Player1', 'green', PLAYER1_DEF_COLOR.G)), 255);
361 Color.B := Min(Abs(ReadInt('Player1', 'blue', PLAYER1_DEF_COLOR.B)), 255);
362 Team := ReadInt('Player1', 'team', TEAM_RED);
363 if (Team < TEAM_RED) or (Team > TEAM_BLUE) then
364 Team := TEAM_RED;
365 end;
367 with gGameControls.P2Control, config do
368 begin
369 KeyRight := ReadInt('Player2', 'KeyRight', 205);
370 KeyLeft := ReadInt('Player2', 'KeyLeft', 203);
371 KeyUp := ReadInt('Player2', 'KeyUp', 200);
372 KeyDown := ReadInt('Player2', 'KeyDown', 208);
373 KeyFire := ReadInt('Player2', 'KeyFire', 184);
374 KeyJump := ReadInt('Player2', 'KeyJump', 157);
375 KeyNextWeapon := ReadInt('Player2', 'KeyNextWeapon', 73);
376 KeyPrevWeapon := ReadInt('Player2', 'KeyPrevWeapon', 71);
377 KeyOpen := ReadInt('Player2', 'KeyOpen', 54);
378 KeyStrafe := ReadInt('Player2', 'KeyStrafe', 0);
379 for i := 0 to High(KeyWeapon) do
380 KeyWeapon[i] := ReadInt('Player2', 'KeyWeapon' + IntToStr(i), 0);
382 KeyRight2 := ReadInt('Player2', 'KeyRight2', 0);
383 KeyLeft2 := ReadInt('Player2', 'KeyLeft2', 0);
384 KeyUp2 := ReadInt('Player2', 'KeyUp2', 0);
385 KeyDown2 := ReadInt('Player2', 'KeyDown2', 0);
386 KeyFire2 := ReadInt('Player2', 'KeyFire2', 0);
387 KeyJump2 := ReadInt('Player2', 'KeyJump2', 0);
388 KeyNextWeapon2 := ReadInt('Player2', 'KeyNextWeapon2', 0);
389 KeyPrevWeapon2 := ReadInt('Player2', 'KeyPrevWeapon2', 0);
390 KeyOpen2 := ReadInt('Player2', 'KeyOpen2', 0);
391 KeyStrafe2 := ReadInt('Player2', 'KeyStrafe2', 0);
392 for i := 0 to High(KeyWeapon2) do
393 KeyWeapon2[i] := ReadInt('Player2', 'KeyWeapon2' + IntToStr(i), 0);
394 end;
396 with gPlayer2Settings, config do
397 begin
398 Name := ReadStr('Player2', 'name', 'Player2');
399 Model := ReadStr('Player2', 'model', STD_PLAYER_MODEL);
400 Color.R := Min(Abs(ReadInt('Player2', 'red', PLAYER2_DEF_COLOR.R)), 255);
401 Color.G := Min(Abs(ReadInt('Player2', 'green', PLAYER2_DEF_COLOR.G)), 255);
402 Color.B := Min(Abs(ReadInt('Player2', 'blue', PLAYER2_DEF_COLOR.B)), 255);
403 Team := ReadInt('Player2', 'team', TEAM_BLUE);
404 if (Team < TEAM_RED) or (Team > TEAM_BLUE) then
405 Team := TEAM_RED;
406 end;
408 for i := 0 to e_MaxJoys-1 do
409 e_JoystickDeadzones[i] := config.ReadInt('Joysticks', 'Deadzone' + IntToStr(i), 8192);
411 g_GFX_SetMax(Min(config.ReadInt('Game', 'MaxParticles', 1000), 50000));
412 g_Shells_SetMax(Min(config.ReadInt('Game', 'MaxShells', 300), 600));
413 g_Gibs_SetMax(Min(config.ReadInt('Game', 'MaxGibs', 150), 500));
414 g_Corpses_SetMax(Min(config.ReadInt('Game', 'MaxCorpses', 20), 100));
416 case config.ReadInt('Game', 'GibsCount', 3) of
417 0: gGibsCount := 0;
418 1: gGibsCount := 8;
419 2: gGibsCount := 16;
420 3: gGibsCount := 32;
421 else gGibsCount := 48;
422 end;
424 ITEM_RESPAWNTIME := 36*Max(config.ReadInt('Game', 'ItemRespawnTime', 60), 0);
425 gBloodCount := Min(config.ReadInt('Game', 'BloodCount', 4), 4);
426 gAdvBlood := config.ReadBool('Game', 'AdvancesBlood', True);
427 gAdvCorpses := config.ReadBool('Game', 'AdvancesCorpses', True);
428 gAdvGibs := config.ReadBool('Game', 'AdvancesGibs', True);
429 gFlash := Min(Max(config.ReadInt('Game', 'Flash', 1), 0), 2);
430 gDrawBackGround := config.ReadBool('Game', 'BackGround', True);
431 gShowMessages := config.ReadBool('Game', 'Messages', True);
432 gRevertPlayers := config.ReadBool('Game', 'RevertPlayers', False);
433 gChatBubble := Min(Max(config.ReadInt('Game', 'ChatBubble', 4), 0), 4);
434 gSFSDebug := config.ReadBool('Game', 'SFSDebug', False);
435 wadoptDebug := gSFSDebug;
436 gSFSFastMode := config.ReadBool('Game', 'SFSFastMode', False);
437 wadoptFast := gSFSFastMode;
438 e_FastScreenshots := config.ReadBool('Game', 'FastScreenshots', True);
439 gDefaultMegawadStart := config.ReadStr('Game', 'DefaultMegawadStart', DF_Default_Megawad_Start);
440 gBerserkAutoswitch := config.ReadBool('Game', 'BerserkAutoswitching', True);
442 // Ãåéìïëåé â ñâîåé èãðå
443 gcMap := config.ReadStr('GameplayCustom', 'Map', '');
444 gcGameMode := config.ReadStr('GameplayCustom', 'GameMode', _lc[I_MENU_GAME_TYPE_DM]);
445 gcTimeLimit := Min(Max(config.ReadInt('GameplayCustom', 'TimeLimit', 0), 0), 65535);
446 gcGoalLimit := Min(Max(config.ReadInt('GameplayCustom', 'GoalLimit', 0), 0), 65535);
447 gcMaxLives := Min(Max(config.ReadInt('GameplayCustom', 'MaxLives', 0), 0), 255);
448 gcPlayers := Min(Max(config.ReadInt('GameplayCustom', 'Players', 1), 0), 2);
449 gcTeamDamage := config.ReadBool('GameplayCustom', 'TeamDamage', False);
450 gcAllowExit := config.ReadBool('GameplayCustom', 'AllowExit', True);
451 gcWeaponStay := config.ReadBool('GameplayCustom', 'WeaponStay', False);
452 gcMonsters := config.ReadBool('GameplayCustom', 'Monsters', False);
453 gcBotsVS := config.ReadStr('GameplayCustom', 'BotsVS', 'Everybody');
455 with gGameSettings do
456 begin
457 GameMode := g_Game_TextToMode(gcGameMode);
458 if GameMode = GM_NONE then
459 GameMode := GM_DM;
460 if GameMode = GM_SINGLE then
461 GameMode := GM_COOP;
462 TimeLimit := gcTimeLimit;
463 GoalLimit := gcGoalLimit;
464 MaxLives := gcMaxLives;
466 Options := 0;
467 if gcTeamDamage then
468 Options := Options or GAME_OPTION_TEAMDAMAGE;
469 if gcAllowExit then
470 Options := Options or GAME_OPTION_ALLOWEXIT;
471 if gcWeaponStay then
472 Options := Options or GAME_OPTION_WEAPONSTAY;
473 if gcMonsters then
474 Options := Options or GAME_OPTION_MONSTERS;
475 if gcBotsVS = 'Everybody' then
476 Options := Options or GAME_OPTION_BOTVSPLAYER or GAME_OPTION_BOTVSMONSTER;
477 if gcBotsVS = 'Players' then
478 Options := Options or GAME_OPTION_BOTVSPLAYER;
479 if gcBotsVS = 'Monsters' then
480 Options := Options or GAME_OPTION_BOTVSMONSTER;
481 end;
483 // Ãåéìïëåé â ñåòåâîé èãðå
484 gnMap := config.ReadStr('GameplayNetwork', 'Map', '');
485 gnGameMode := config.ReadStr('GameplayNetwork', 'GameMode', _lc[I_MENU_GAME_TYPE_DM]);
486 gnTimeLimit := Min(Max(config.ReadInt('GameplayNetwork', 'TimeLimit', 0), 0), 65535);
487 gnGoalLimit := Min(Max(config.ReadInt('GameplayNetwork', 'GoalLimit', 0), 0), 65535);
488 gnMaxLives := Min(Max(config.ReadInt('GameplayNetwork', 'MaxLives', 0), 0), 255);
489 gnPlayers := Min(Max(config.ReadInt('GameplayNetwork', 'Players', 1), 0), 2);
490 gnTeamDamage := config.ReadBool('GameplayNetwork', 'TeamDamage', False);
491 gnAllowExit := config.ReadBool('GameplayNetwork', 'AllowExit', True);
492 gnWeaponStay := config.ReadBool('GameplayNetwork', 'WeaponStay', False);
493 gnMonsters := config.ReadBool('GameplayNetwork', 'Monsters', False);
494 gnBotsVS := config.ReadStr('GameplayNetwork', 'BotsVS', 'Everybody');
496 // Îáùèå ñåòåâûå
497 NetSlistIP := config.ReadStr('MasterServer', 'IP', 'mpms.doom2d.org');
498 NetSlistPort := config.ReadInt('MasterServer', 'Port', 25665);
500 // Ñåðâåð
501 NetServerName := config.ReadStr('Server', 'Name', 'Unnamed Server');
502 NetPassword := config.ReadStr('Server', 'Password', '');
503 NetPort := Min(Max(0, config.ReadInt('Server', 'Port', 25666)), 65535);
504 NetMaxClients := Min(Max(0, config.ReadInt('Server', 'MaxClients', 16)), NET_MAXCLIENTS);
505 NetAllowRCON := config.ReadBool('Server', 'RCON', False);
506 NetRCONPassword := config.ReadStr('Server', 'RCONPassword', 'default');
507 NetUseMaster := config.ReadBool('Server', 'SyncWithMaster', True);
508 NetUpdateRate := Max(0, config.ReadInt('Server', 'UpdateInterval', 0));
509 NetRelupdRate := Max(0, config.ReadInt('Server', 'ReliableUpdateInterval', 18));
510 NetMasterRate := Max(1, config.ReadInt('Server', 'MasterSyncInterval', 60000));
512 // Êëèåíò
513 NetInterpLevel := Max(0, config.ReadInt('Client', 'InterpolationSteps', 2));
514 NetForcePlayerUpdate := config.ReadBool('Client', 'ForcePlayerUpdate', False);
515 NetPredictSelf := config.ReadBool('Client', 'PredictSelf', True);
516 NetClientIP := config.ReadStr('Client', 'LastIP', '127.0.0.1');
517 NetClientPort := Max(0, config.ReadInt('Client', 'LastPort', 25666));
519 // ßçûê:
520 str := config.ReadStr('Game', 'Language', '');
521 if (str = LANGUAGE_RUSSIAN) or
522 (str = LANGUAGE_ENGLISH) then
523 begin
524 gLanguage := str;
525 gAskLanguage := False;
526 end
527 else
528 gLanguage := LANGUAGE_ENGLISH;
530 config.Free();
532 //if gTextureFilter then TEXTUREFILTER := GL_LINEAR else TEXTUREFILTER := GL_NEAREST;
533 end;
535 procedure g_Options_Write(FileName: String);
536 var
537 config: TConfig;
538 i: Integer;
539 begin
540 e_WriteLog('Writing config', TMsgType.Notify);
542 config := TConfig.CreateFile(FileName);
544 config.WriteInt('Video', 'ScreenWidth', gScreenWidth);
545 config.WriteInt('Video', 'ScreenHeight', gScreenHeight);
546 config.WriteInt('Video', 'WinPosX', gWinRealPosX);
547 config.WriteInt('Video', 'WinPosY', gWinRealPosY);
548 config.WriteBool('Video', 'Fullscreen', gFullScreen);
549 config.WriteBool('Video', 'Maximized', gWinMaximized);
550 config.WriteInt('Video', 'BPP', gBPP);
551 config.WriteBool('Video', 'VSync', gVSync);
552 config.WriteBool('Video', 'TextureFilter', gTextureFilter);
553 config.WriteBool('Video', 'LegacyCompatible', glLegacyNPOT);
555 config.WriteBool('Sound', 'NoSound', gNoSound);
556 config.WriteInt('Sound', 'SoundLevel', gSoundLevel);
557 config.WriteInt('Sound', 'MusicLevel', gMusicLevel);
558 config.WriteInt('Sound', 'MaxSimSounds', gMaxSimSounds);
559 config.WriteBool('Sound', 'MuteInactive', gMuteWhenInactive);
560 config.WriteInt('Sound', 'Announcer', gAnnouncer);
561 config.WriteBool('Sound', 'SoundEffectsDF', gSoundEffectsDF);
562 config.WriteInt('Sound', 'SDLSampleRate', gsSDLSampleRate);
563 config.WriteInt('Sound', 'SDLBufferSize', gsSDLBufferSize);
565 with config, gGameControls.GameControls do
566 begin
567 WriteInt('GameControls', 'TakeScreenshot', TakeScreenshot);
568 WriteInt('GameControls', 'Stat', Stat);
569 WriteInt('GameControls', 'Chat', Chat);
570 WriteInt('GameControls', 'TeamChat', TeamChat);
571 end;
573 with config, gGameControls.P1Control, gPlayer1Settings do
574 begin
575 WriteInt('Player1', 'KeyRight', KeyRight);
576 WriteInt('Player1', 'KeyLeft', KeyLeft);
577 WriteInt('Player1', 'KeyUp', KeyUp);
578 WriteInt('Player1', 'KeyDown', KeyDown);
579 WriteInt('Player1', 'KeyFire', KeyFire);
580 WriteInt('Player1', 'KeyJump', KeyJump);
581 WriteInt('Player1', 'KeyNextWeapon', KeyNextWeapon);
582 WriteInt('Player1', 'KeyPrevWeapon', KeyPrevWeapon);
583 WriteInt('Player1', 'KeyOpen', KeyOpen);
584 WriteInt('Player1', 'KeyStrafe', KeyStrafe);
585 for i := 0 to High(KeyWeapon) do
586 WriteInt('Player1', 'KeyWeapon' + IntToStr(i), KeyWeapon[i]);
588 WriteInt('Player1', 'KeyRight2', KeyRight2);
589 WriteInt('Player1', 'KeyLeft2', KeyLeft2);
590 WriteInt('Player1', 'KeyUp2', KeyUp2);
591 WriteInt('Player1', 'KeyDown2', KeyDown2);
592 WriteInt('Player1', 'KeyFire2', KeyFire2);
593 WriteInt('Player1', 'KeyJump2', KeyJump2);
594 WriteInt('Player1', 'KeyNextWeapon2', KeyNextWeapon2);
595 WriteInt('Player1', 'KeyPrevWeapon2', KeyPrevWeapon2);
596 WriteInt('Player1', 'KeyOpen2', KeyOpen2);
597 WriteInt('Player1', 'KeyStrafe2', KeyStrafe2);
598 for i := 0 to High(KeyWeapon2) do
599 WriteInt('Player1', 'KeyWeapon2' + IntToStr(i), KeyWeapon2[i]);
601 WriteStr('Player1', 'Name', Name);
602 WriteStr('Player1', 'model', Model);
603 WriteInt('Player1', 'red', Color.R);
604 WriteInt('Player1', 'green', Color.G);
605 WriteInt('Player1', 'blue', Color.B);
606 WriteInt('Player1', 'team', Team);
607 end;
609 with config, gGameControls.P2Control, gPlayer2Settings do
610 begin
611 WriteInt('Player2', 'KeyRight', KeyRight);
612 WriteInt('Player2', 'KeyLeft', KeyLeft);
613 WriteInt('Player2', 'KeyUp', KeyUp);
614 WriteInt('Player2', 'KeyDown', KeyDown);
615 WriteInt('Player2', 'KeyFire', KeyFire);
616 WriteInt('Player2', 'KeyJump', KeyJump);
617 WriteInt('Player2', 'KeyNextWeapon', KeyNextWeapon);
618 WriteInt('Player2', 'KeyPrevWeapon', KeyPrevWeapon);
619 WriteInt('Player2', 'KeyOpen', KeyOpen);
620 WriteInt('Player2', 'KeyStrafe', KeyStrafe);
621 for i := 0 to High(KeyWeapon) do
622 WriteInt('Player2', 'KeyWeapon' + IntToStr(i), KeyWeapon[i]);
624 WriteInt('Player2', 'KeyRight2', KeyRight2);
625 WriteInt('Player2', 'KeyLeft2', KeyLeft2);
626 WriteInt('Player2', 'KeyUp2', KeyUp2);
627 WriteInt('Player2', 'KeyDown2', KeyDown2);
628 WriteInt('Player2', 'KeyFire2', KeyFire2);
629 WriteInt('Player2', 'KeyJump2', KeyJump2);
630 WriteInt('Player2', 'KeyNextWeapon2', KeyNextWeapon2);
631 WriteInt('Player2', 'KeyPrevWeapon2', KeyPrevWeapon2);
632 WriteInt('Player2', 'KeyOpen2', KeyOpen2);
633 WriteInt('Player2', 'KeyStrafe2', KeyStrafe2);
634 for i := 0 to High(KeyWeapon2) do
635 WriteInt('Player2', 'KeyWeapon2' + IntToStr(i), KeyWeapon2[i]);
637 WriteStr('Player2', 'Name', Name);
638 WriteStr('Player2', 'model', Model);
639 WriteInt('Player2', 'red', Color.R);
640 WriteInt('Player2', 'green', Color.G);
641 WriteInt('Player2', 'blue', Color.B);
642 WriteInt('Player2', 'team', Team);
643 end;
645 for i := 0 to e_MaxJoys-1 do
646 config.WriteInt('Joysticks', 'Deadzone' + IntToStr(i), e_JoystickDeadzones[i]);
648 with config do
649 case gGibsCount of
650 0: config.WriteInt('Game', 'GibsCount', 0);
651 8: config.WriteInt('Game', 'GibsCount', 1);
652 16: config.WriteInt('Game', 'GibsCount', 2);
653 32: config.WriteInt('Game', 'GibsCount', 3);
654 else config.WriteInt('Game', 'GibsCount', 4);
655 end;
657 config.WriteInt('Game', 'ItemRespawnTime', ITEM_RESPAWNTIME div 36);
658 config.WriteInt('Game', 'MaxParticles', g_GFX_GetMax());
659 config.WriteInt('Game', 'MaxShells', g_Shells_GetMax());
660 config.WriteInt('Game', 'MaxGibs', g_Gibs_GetMax());
661 config.WriteInt('Game', 'MaxCorpses', g_Corpses_GetMax());
662 config.WriteInt('Game', 'BloodCount', gBloodCount);
663 config.WriteBool('Game', 'AdvancesBlood', gAdvBlood);
664 config.WriteBool('Game', 'AdvancesCorpses', gAdvCorpses);
665 config.WriteBool('Game', 'AdvancesGibs', gAdvGibs);
666 config.WriteInt('Game', 'Flash', gFlash);
667 config.WriteBool('Game', 'BackGround', gDrawBackGround);
668 config.WriteBool('Game', 'Messages', gShowMessages);
669 config.WriteBool('Game', 'RevertPlayers', gRevertPlayers);
670 config.WriteInt('Game', 'ChatBubble', gChatBubble);
671 config.WriteBool('Game', 'SFSDebug', gSFSDebug);
672 config.WriteBool('Game', 'SFSFastMode', gSFSFastMode);
673 config.WriteBool('Game', 'FastScreenshots', e_FastScreenshots);
674 config.WriteStr('Game', 'DefaultMegawadStart', gDefaultMegawadStart);
675 config.WriteBool('Game', 'BerserkAutoswitching', gBerserkAutoswitch);
677 config.WriteStr ('GameplayCustom', 'Map', gcMap);
678 config.WriteStr ('GameplayCustom', 'GameMode', gcGameMode);
679 config.WriteInt ('GameplayCustom', 'TimeLimit', gcTimeLimit);
680 config.WriteInt ('GameplayCustom', 'GoalLimit', gcGoalLimit);
681 config.WriteInt ('GameplayCustom', 'MaxLives', gcMaxLives);
682 config.WriteInt ('GameplayCustom', 'Players', gcPlayers);
683 config.WriteBool('GameplayCustom', 'TeamDamage', gcTeamDamage);
684 config.WriteBool('GameplayCustom', 'AllowExit', gcAllowExit);
685 config.WriteBool('GameplayCustom', 'WeaponStay', gcWeaponStay);
686 config.WriteBool('GameplayCustom', 'Monsters', gcMonsters);
687 config.WriteStr ('GameplayCustom', 'BotsVS', gcBotsVS);
689 config.WriteStr ('GameplayNetwork', 'Map', gnMap);
690 config.WriteStr ('GameplayNetwork', 'GameMode', gnGameMode);
691 config.WriteInt ('GameplayNetwork', 'TimeLimit', gnTimeLimit);
692 config.WriteInt ('GameplayNetwork', 'GoalLimit', gnGoalLimit);
693 config.WriteInt ('GameplayNetwork', 'MaxLives', gnMaxLives);
694 config.WriteInt ('GameplayNetwork', 'Players', gnPlayers);
695 config.WriteBool('GameplayNetwork', 'TeamDamage', gnTeamDamage);
696 config.WriteBool('GameplayNetwork', 'AllowExit', gnAllowExit);
697 config.WriteBool('GameplayNetwork', 'WeaponStay', gnWeaponStay);
698 config.WriteBool('GameplayNetwork', 'Monsters', gnMonsters);
699 config.WriteStr ('GameplayNetwork', 'BotsVS', gnBotsVS);
701 config.WriteStr('MasterServer', 'IP', NetSlistIP);
702 config.WriteInt('MasterServer', 'Port', NetSlistPort);
704 config.WriteStr ('Server', 'Name', NetServerName);
705 config.WriteStr ('Server', 'Password', NetPassword);
706 config.WriteInt ('Server', 'Port', NetPort);
707 config.WriteInt ('Server', 'MaxClients', NetMaxClients);
708 config.WriteBool('Server', 'RCON', NetAllowRCON);
709 config.WriteStr ('Server', 'RCONPassword', NetRCONPassword);
710 config.WriteBool('Server', 'SyncWithMaster', NetUseMaster);
711 config.WriteInt ('Server', 'UpdateInterval', NetUpdateRate);
712 config.WriteInt ('Server', 'ReliableUpdateInterval', NetRelupdRate);
713 config.WriteInt ('Server', 'MasterSyncInterval', NetMasterRate);
715 config.WriteInt ('Client', 'InterpolationSteps', NetInterpLevel);
716 config.WriteBool ('Client', 'ForcePlayerUpdate', NetForcePlayerUpdate);
717 config.WriteBool ('Client', 'PredictSelf', NetPredictSelf);
718 config.WriteStr ('Client', 'LastIP', NetClientIP);
719 config.WriteInt ('Client', 'LastPort', NetClientPort);
721 config.SaveFile(FileName);
722 config.Free();
723 end;
725 procedure g_Options_Write_Language(FileName: String);
726 var
727 config: TConfig;
728 begin
729 e_WriteLog('Writing language config', TMsgType.Notify);
731 config := TConfig.CreateFile(FileName);
732 config.WriteStr('Game', 'Language', gLanguage);
733 config.SaveFile(FileName);
734 config.Free();
735 end;
737 procedure g_Options_Write_Video(FileName: String);
738 var
739 config: TConfig;
740 sW, sH: Integer;
741 begin
742 e_WriteLog('Writing resolution to config', TMsgType.Notify);
744 config := TConfig.CreateFile(FileName);
746 if gWinMaximized and (not gFullscreen) then
747 begin
748 sW := gWinSizeX;
749 sH := gWinSizeY;
750 end
751 else
752 begin
753 sW := gScreenWidth;
754 sH := gScreenHeight;
755 end;
757 config.WriteInt('Video', 'ScreenWidth', sW);
758 config.WriteInt('Video', 'ScreenHeight', sH);
759 config.WriteInt('Video', 'WinPosX', gWinRealPosX);
760 config.WriteInt('Video', 'WinPosY', gWinRealPosY);
761 config.WriteBool('Video', 'Fullscreen', gFullscreen);
762 config.WriteBool('Video', 'Maximized', gWinMaximized);
764 config.SaveFile(FileName);
765 config.Free();
766 end;
768 procedure g_Options_Write_Gameplay_Custom(FileName: String);
769 var
770 config: TConfig;
771 begin
772 e_WriteLog('Writing custom gameplay config', TMsgType.Notify);
774 config := TConfig.CreateFile(FileName);
776 config.WriteStr ('GameplayCustom', 'Map', gcMap);
777 config.WriteStr ('GameplayCustom', 'GameMode', gcGameMode);
778 config.WriteInt ('GameplayCustom', 'TimeLimit', gcTimeLimit);
779 config.WriteInt ('GameplayCustom', 'GoalLimit', gcGoalLimit);
780 config.WriteInt ('GameplayCustom', 'MaxLives', gcMaxLives);
781 config.WriteInt ('GameplayCustom', 'Players', gcPlayers);
782 config.WriteBool('GameplayCustom', 'TeamDamage', gcTeamDamage);
783 config.WriteBool('GameplayCustom', 'AllowExit', gcAllowExit);
784 config.WriteBool('GameplayCustom', 'WeaponStay', gcWeaponStay);
785 config.WriteBool('GameplayCustom', 'Monsters', gcMonsters);
786 config.WriteStr ('GameplayCustom', 'BotsVS', gcBotsVS);
788 config.SaveFile(FileName);
789 config.Free();
790 end;
792 procedure g_Options_Write_Gameplay_Net(FileName: String);
793 var
794 config: TConfig;
795 begin
796 e_WriteLog('Writing network gameplay config', TMsgType.Notify);
798 config := TConfig.CreateFile(FileName);
800 config.WriteStr ('GameplayNetwork', 'Map', gnMap);
801 config.WriteStr ('GameplayNetwork', 'GameMode', gnGameMode);
802 config.WriteInt ('GameplayNetwork', 'TimeLimit', gnTimeLimit);
803 config.WriteInt ('GameplayNetwork', 'GoalLimit', gnGoalLimit);
804 config.WriteInt ('GameplayNetwork', 'MaxLives', gnMaxLives);
805 config.WriteInt ('GameplayNetwork', 'Players', gnPlayers);
806 config.WriteBool('GameplayNetwork', 'TeamDamage', gnTeamDamage);
807 config.WriteBool('GameplayNetwork', 'AllowExit', gnAllowExit);
808 config.WriteBool('GameplayNetwork', 'WeaponStay', gnWeaponStay);
809 config.WriteBool('GameplayNetwork', 'Monsters', gnMonsters);
810 config.WriteStr ('GameplayNetwork', 'BotsVS', gnBotsVS);
812 config.SaveFile(FileName);
813 config.Free();
814 end;
816 procedure g_Options_Write_Net_Server(FileName: String);
817 var
818 config: TConfig;
819 begin
820 e_WriteLog('Writing server config', TMsgType.Notify);
822 config := TConfig.CreateFile(FileName);
824 config.WriteStr ('Server', 'Name', NetServerName);
825 config.WriteStr ('Server', 'Password', NetPassword);
826 config.WriteInt ('Server', 'Port', NetPort);
827 config.WriteInt ('Server', 'MaxClients', NetMaxClients);
828 config.WriteBool('Server', 'SyncWithMaster', NetUseMaster);
830 config.SaveFile(FileName);
831 config.Free();
832 end;
834 procedure g_Options_Write_Net_Client(FileName: String);
835 var
836 config: TConfig;
837 begin
838 e_WriteLog('Writing client config', TMsgType.Notify);
840 config := TConfig.CreateFile(FileName);
842 config.WriteStr('Client', 'LastIP', NetClientIP);
843 config.WriteInt('Client', 'LastPort', NetClientPort);
845 config.SaveFile(FileName);
846 config.Free();
847 end;
849 end.