DEADSOFTWARE

.cfg option to control autoswitching to superfist: Game/BerserkAutoswitch
[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', MSG_NOTIFY);
266 if not FileExists(FileName) then
267 begin
268 e_WriteLog('Config file '+FileName+' not found', MSG_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', 'megawads/DOOM2D.WAD:\MAP01');
440 gBerserkAutoswitch := config.ReadBool('Game', 'BerserkAutoswitch', False);
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
533 TEXTUREFILTER := GL_LINEAR
534 else
535 TEXTUREFILTER := GL_NEAREST;
536 end;
538 procedure g_Options_Write(FileName: String);
539 var
540 config: TConfig;
541 i: Integer;
542 begin
543 e_WriteLog('Writing config', MSG_NOTIFY);
545 config := TConfig.CreateFile(FileName);
547 config.WriteInt('Video', 'ScreenWidth', gScreenWidth);
548 config.WriteInt('Video', 'ScreenHeight', gScreenHeight);
549 config.WriteInt('Video', 'WinPosX', gWinRealPosX);
550 config.WriteInt('Video', 'WinPosY', gWinRealPosY);
551 config.WriteBool('Video', 'Fullscreen', gFullScreen);
552 config.WriteBool('Video', 'Maximized', gWinMaximized);
553 config.WriteInt('Video', 'BPP', gBPP);
554 config.WriteBool('Video', 'VSync', gVSync);
555 config.WriteBool('Video', 'TextureFilter', gTextureFilter);
556 config.WriteBool('Video', 'LegacyCompatible', glLegacyNPOT);
558 config.WriteBool('Sound', 'NoSound', gNoSound);
559 config.WriteInt('Sound', 'SoundLevel', gSoundLevel);
560 config.WriteInt('Sound', 'MusicLevel', gMusicLevel);
561 config.WriteInt('Sound', 'MaxSimSounds', gMaxSimSounds);
562 config.WriteBool('Sound', 'MuteInactive', gMuteWhenInactive);
563 config.WriteInt('Sound', 'Announcer', gAnnouncer);
564 config.WriteBool('Sound', 'SoundEffectsDF', gSoundEffectsDF);
565 config.WriteInt('Sound', 'SDLSampleRate', gsSDLSampleRate);
566 config.WriteInt('Sound', 'SDLBufferSize', gsSDLBufferSize);
568 with config, gGameControls.GameControls do
569 begin
570 WriteInt('GameControls', 'TakeScreenshot', TakeScreenshot);
571 WriteInt('GameControls', 'Stat', Stat);
572 WriteInt('GameControls', 'Chat', Chat);
573 WriteInt('GameControls', 'TeamChat', TeamChat);
574 end;
576 with config, gGameControls.P1Control, gPlayer1Settings do
577 begin
578 WriteInt('Player1', 'KeyRight', KeyRight);
579 WriteInt('Player1', 'KeyLeft', KeyLeft);
580 WriteInt('Player1', 'KeyUp', KeyUp);
581 WriteInt('Player1', 'KeyDown', KeyDown);
582 WriteInt('Player1', 'KeyFire', KeyFire);
583 WriteInt('Player1', 'KeyJump', KeyJump);
584 WriteInt('Player1', 'KeyNextWeapon', KeyNextWeapon);
585 WriteInt('Player1', 'KeyPrevWeapon', KeyPrevWeapon);
586 WriteInt('Player1', 'KeyOpen', KeyOpen);
587 WriteInt('Player1', 'KeyStrafe', KeyStrafe);
588 for i := 0 to High(KeyWeapon) do
589 WriteInt('Player1', 'KeyWeapon' + IntToStr(i), KeyWeapon[i]);
591 WriteInt('Player1', 'KeyRight2', KeyRight2);
592 WriteInt('Player1', 'KeyLeft2', KeyLeft2);
593 WriteInt('Player1', 'KeyUp2', KeyUp2);
594 WriteInt('Player1', 'KeyDown2', KeyDown2);
595 WriteInt('Player1', 'KeyFire2', KeyFire2);
596 WriteInt('Player1', 'KeyJump2', KeyJump2);
597 WriteInt('Player1', 'KeyNextWeapon2', KeyNextWeapon2);
598 WriteInt('Player1', 'KeyPrevWeapon2', KeyPrevWeapon2);
599 WriteInt('Player1', 'KeyOpen2', KeyOpen2);
600 WriteInt('Player1', 'KeyStrafe2', KeyStrafe2);
601 for i := 0 to High(KeyWeapon2) do
602 WriteInt('Player1', 'KeyWeapon2' + IntToStr(i), KeyWeapon2[i]);
604 WriteStr('Player1', 'Name', Name);
605 WriteStr('Player1', 'model', Model);
606 WriteInt('Player1', 'red', Color.R);
607 WriteInt('Player1', 'green', Color.G);
608 WriteInt('Player1', 'blue', Color.B);
609 WriteInt('Player1', 'team', Team);
610 end;
612 with config, gGameControls.P2Control, gPlayer2Settings do
613 begin
614 WriteInt('Player2', 'KeyRight', KeyRight);
615 WriteInt('Player2', 'KeyLeft', KeyLeft);
616 WriteInt('Player2', 'KeyUp', KeyUp);
617 WriteInt('Player2', 'KeyDown', KeyDown);
618 WriteInt('Player2', 'KeyFire', KeyFire);
619 WriteInt('Player2', 'KeyJump', KeyJump);
620 WriteInt('Player2', 'KeyNextWeapon', KeyNextWeapon);
621 WriteInt('Player2', 'KeyPrevWeapon', KeyPrevWeapon);
622 WriteInt('Player2', 'KeyOpen', KeyOpen);
623 WriteInt('Player2', 'KeyStrafe', KeyStrafe);
624 for i := 0 to High(KeyWeapon) do
625 WriteInt('Player2', 'KeyWeapon' + IntToStr(i), KeyWeapon[i]);
627 WriteInt('Player2', 'KeyRight2', KeyRight2);
628 WriteInt('Player2', 'KeyLeft2', KeyLeft2);
629 WriteInt('Player2', 'KeyUp2', KeyUp2);
630 WriteInt('Player2', 'KeyDown2', KeyDown2);
631 WriteInt('Player2', 'KeyFire2', KeyFire2);
632 WriteInt('Player2', 'KeyJump2', KeyJump2);
633 WriteInt('Player2', 'KeyNextWeapon2', KeyNextWeapon2);
634 WriteInt('Player2', 'KeyPrevWeapon2', KeyPrevWeapon2);
635 WriteInt('Player2', 'KeyOpen2', KeyOpen2);
636 WriteInt('Player2', 'KeyStrafe2', KeyStrafe2);
637 for i := 0 to High(KeyWeapon2) do
638 WriteInt('Player2', 'KeyWeapon2' + IntToStr(i), KeyWeapon2[i]);
640 WriteStr('Player2', 'Name', Name);
641 WriteStr('Player2', 'model', Model);
642 WriteInt('Player2', 'red', Color.R);
643 WriteInt('Player2', 'green', Color.G);
644 WriteInt('Player2', 'blue', Color.B);
645 WriteInt('Player2', 'team', Team);
646 end;
648 for i := 0 to e_MaxJoys-1 do
649 config.WriteInt('Joysticks', 'Deadzone' + IntToStr(i), e_JoystickDeadzones[i]);
651 with config do
652 case gGibsCount of
653 0: config.WriteInt('Game', 'GibsCount', 0);
654 8: config.WriteInt('Game', 'GibsCount', 1);
655 16: config.WriteInt('Game', 'GibsCount', 2);
656 32: config.WriteInt('Game', 'GibsCount', 3);
657 else config.WriteInt('Game', 'GibsCount', 4);
658 end;
660 config.WriteInt('Game', 'ItemRespawnTime', ITEM_RESPAWNTIME div 36);
661 config.WriteInt('Game', 'MaxParticles', g_GFX_GetMax());
662 config.WriteInt('Game', 'MaxShells', g_Shells_GetMax());
663 config.WriteInt('Game', 'MaxGibs', g_Gibs_GetMax());
664 config.WriteInt('Game', 'MaxCorpses', g_Corpses_GetMax());
665 config.WriteInt('Game', 'BloodCount', gBloodCount);
666 config.WriteBool('Game', 'AdvancesBlood', gAdvBlood);
667 config.WriteBool('Game', 'AdvancesCorpses', gAdvCorpses);
668 config.WriteBool('Game', 'AdvancesGibs', gAdvGibs);
669 config.WriteInt('Game', 'Flash', gFlash);
670 config.WriteBool('Game', 'BackGround', gDrawBackGround);
671 config.WriteBool('Game', 'Messages', gShowMessages);
672 config.WriteBool('Game', 'RevertPlayers', gRevertPlayers);
673 config.WriteInt('Game', 'ChatBubble', gChatBubble);
674 config.WriteBool('Game', 'SFSDebug', gSFSDebug);
675 config.WriteBool('Game', 'SFSFastMode', gSFSFastMode);
676 config.WriteBool('Game', 'FastScreenshots', e_FastScreenshots);
677 config.WriteStr('Game', 'DefaultMegawadStart', gDefaultMegawadStart);
678 config.WriteBool('Game', 'BerserkAutoswitch', gBerserkAutoswitch);
680 config.WriteStr ('GameplayCustom', 'Map', gcMap);
681 config.WriteStr ('GameplayCustom', 'GameMode', gcGameMode);
682 config.WriteInt ('GameplayCustom', 'TimeLimit', gcTimeLimit);
683 config.WriteInt ('GameplayCustom', 'GoalLimit', gcGoalLimit);
684 config.WriteInt ('GameplayCustom', 'MaxLives', gcMaxLives);
685 config.WriteInt ('GameplayCustom', 'Players', gcPlayers);
686 config.WriteBool('GameplayCustom', 'TeamDamage', gcTeamDamage);
687 config.WriteBool('GameplayCustom', 'AllowExit', gcAllowExit);
688 config.WriteBool('GameplayCustom', 'WeaponStay', gcWeaponStay);
689 config.WriteBool('GameplayCustom', 'Monsters', gcMonsters);
690 config.WriteStr ('GameplayCustom', 'BotsVS', gcBotsVS);
692 config.WriteStr ('GameplayNetwork', 'Map', gnMap);
693 config.WriteStr ('GameplayNetwork', 'GameMode', gnGameMode);
694 config.WriteInt ('GameplayNetwork', 'TimeLimit', gnTimeLimit);
695 config.WriteInt ('GameplayNetwork', 'GoalLimit', gnGoalLimit);
696 config.WriteInt ('GameplayNetwork', 'MaxLives', gnMaxLives);
697 config.WriteInt ('GameplayNetwork', 'Players', gnPlayers);
698 config.WriteBool('GameplayNetwork', 'TeamDamage', gnTeamDamage);
699 config.WriteBool('GameplayNetwork', 'AllowExit', gnAllowExit);
700 config.WriteBool('GameplayNetwork', 'WeaponStay', gnWeaponStay);
701 config.WriteBool('GameplayNetwork', 'Monsters', gnMonsters);
702 config.WriteStr ('GameplayNetwork', 'BotsVS', gnBotsVS);
704 config.WriteStr('MasterServer', 'IP', NetSlistIP);
705 config.WriteInt('MasterServer', 'Port', NetSlistPort);
707 config.WriteStr ('Server', 'Name', NetServerName);
708 config.WriteStr ('Server', 'Password', NetPassword);
709 config.WriteInt ('Server', 'Port', NetPort);
710 config.WriteInt ('Server', 'MaxClients', NetMaxClients);
711 config.WriteBool('Server', 'RCON', NetAllowRCON);
712 config.WriteStr ('Server', 'RCONPassword', NetRCONPassword);
713 config.WriteBool('Server', 'SyncWithMaster', NetUseMaster);
714 config.WriteInt ('Server', 'UpdateInterval', NetUpdateRate);
715 config.WriteInt ('Server', 'ReliableUpdateInterval', NetRelupdRate);
716 config.WriteInt ('Server', 'MasterSyncInterval', NetMasterRate);
718 config.WriteInt ('Client', 'InterpolationSteps', NetInterpLevel);
719 config.WriteBool ('Client', 'ForcePlayerUpdate', NetForcePlayerUpdate);
720 config.WriteBool ('Client', 'PredictSelf', NetPredictSelf);
721 config.WriteStr ('Client', 'LastIP', NetClientIP);
722 config.WriteInt ('Client', 'LastPort', NetClientPort);
724 config.SaveFile(FileName);
725 config.Free();
726 end;
728 procedure g_Options_Write_Language(FileName: String);
729 var
730 config: TConfig;
731 begin
732 e_WriteLog('Writing language config', MSG_NOTIFY);
734 config := TConfig.CreateFile(FileName);
735 config.WriteStr('Game', 'Language', gLanguage);
736 config.SaveFile(FileName);
737 config.Free();
738 end;
740 procedure g_Options_Write_Video(FileName: String);
741 var
742 config: TConfig;
743 sW, sH: Integer;
744 begin
745 e_WriteLog('Writing resolution to config', MSG_NOTIFY);
747 config := TConfig.CreateFile(FileName);
749 if gWinMaximized and (not gFullscreen) then
750 begin
751 sW := gWinSizeX;
752 sH := gWinSizeY;
753 end
754 else
755 begin
756 sW := gScreenWidth;
757 sH := gScreenHeight;
758 end;
760 config.WriteInt('Video', 'ScreenWidth', sW);
761 config.WriteInt('Video', 'ScreenHeight', sH);
762 config.WriteInt('Video', 'WinPosX', gWinRealPosX);
763 config.WriteInt('Video', 'WinPosY', gWinRealPosY);
764 config.WriteBool('Video', 'Fullscreen', gFullscreen);
765 config.WriteBool('Video', 'Maximized', gWinMaximized);
767 config.SaveFile(FileName);
768 config.Free();
769 end;
771 procedure g_Options_Write_Gameplay_Custom(FileName: String);
772 var
773 config: TConfig;
774 begin
775 e_WriteLog('Writing custom gameplay config', MSG_NOTIFY);
777 config := TConfig.CreateFile(FileName);
779 config.WriteStr ('GameplayCustom', 'Map', gcMap);
780 config.WriteStr ('GameplayCustom', 'GameMode', gcGameMode);
781 config.WriteInt ('GameplayCustom', 'TimeLimit', gcTimeLimit);
782 config.WriteInt ('GameplayCustom', 'GoalLimit', gcGoalLimit);
783 config.WriteInt ('GameplayCustom', 'MaxLives', gcMaxLives);
784 config.WriteInt ('GameplayCustom', 'Players', gcPlayers);
785 config.WriteBool('GameplayCustom', 'TeamDamage', gcTeamDamage);
786 config.WriteBool('GameplayCustom', 'AllowExit', gcAllowExit);
787 config.WriteBool('GameplayCustom', 'WeaponStay', gcWeaponStay);
788 config.WriteBool('GameplayCustom', 'Monsters', gcMonsters);
789 config.WriteStr ('GameplayCustom', 'BotsVS', gcBotsVS);
791 config.SaveFile(FileName);
792 config.Free();
793 end;
795 procedure g_Options_Write_Gameplay_Net(FileName: String);
796 var
797 config: TConfig;
798 begin
799 e_WriteLog('Writing network gameplay config', MSG_NOTIFY);
801 config := TConfig.CreateFile(FileName);
803 config.WriteStr ('GameplayNetwork', 'Map', gnMap);
804 config.WriteStr ('GameplayNetwork', 'GameMode', gnGameMode);
805 config.WriteInt ('GameplayNetwork', 'TimeLimit', gnTimeLimit);
806 config.WriteInt ('GameplayNetwork', 'GoalLimit', gnGoalLimit);
807 config.WriteInt ('GameplayNetwork', 'MaxLives', gnMaxLives);
808 config.WriteInt ('GameplayNetwork', 'Players', gnPlayers);
809 config.WriteBool('GameplayNetwork', 'TeamDamage', gnTeamDamage);
810 config.WriteBool('GameplayNetwork', 'AllowExit', gnAllowExit);
811 config.WriteBool('GameplayNetwork', 'WeaponStay', gnWeaponStay);
812 config.WriteBool('GameplayNetwork', 'Monsters', gnMonsters);
813 config.WriteStr ('GameplayNetwork', 'BotsVS', gnBotsVS);
815 config.SaveFile(FileName);
816 config.Free();
817 end;
819 procedure g_Options_Write_Net_Server(FileName: String);
820 var
821 config: TConfig;
822 begin
823 e_WriteLog('Writing server config', MSG_NOTIFY);
825 config := TConfig.CreateFile(FileName);
827 config.WriteStr ('Server', 'Name', NetServerName);
828 config.WriteStr ('Server', 'Password', NetPassword);
829 config.WriteInt ('Server', 'Port', NetPort);
830 config.WriteInt ('Server', 'MaxClients', NetMaxClients);
831 config.WriteBool('Server', 'SyncWithMaster', NetUseMaster);
833 config.SaveFile(FileName);
834 config.Free();
835 end;
837 procedure g_Options_Write_Net_Client(FileName: String);
838 var
839 config: TConfig;
840 begin
841 e_WriteLog('Writing client config', MSG_NOTIFY);
843 config := TConfig.CreateFile(FileName);
845 config.WriteStr('Client', 'LastIP', NetClientIP);
846 config.WriteInt('Client', 'LastPort', NetClientPort);
848 config.SaveFile(FileName);
849 config.Free();
850 end;
852 end.