DEADSOFTWARE

experiments with fullscreen switching -- failed, but i left the commented code for...
[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 gUseChatSounds := True;
151 g_GFX_SetMax(2000);
152 g_Gibs_SetMax(150);
153 g_Corpses_SetMax(20);
154 g_Shells_SetMax(300);
155 gGibsCount := 32;
156 gBloodCount := 3;
157 gAdvBlood := True;
158 gAdvCorpses := True;
159 gAdvGibs := True;
160 gFlash := 1;
161 gDrawBackGround := True;
162 gShowMessages := True;
163 gRevertPlayers := False;
165 for i := 0 to e_MaxJoys-1 do
166 e_JoystickDeadzones[i] := 8192;
168 with gGameControls.GameControls do
169 begin
170 TakeScreenshot := 183;
171 Stat := 15;
172 Chat := 20; // [T]
173 TeamChat := 21; // [Y]
174 end;
176 with gGameControls.P1Control do
177 begin
178 KeyRight := 77;
179 KeyLeft := 75;
180 KeyUp := 72;
181 KeyDown := 76;
182 KeyFire := 184;
183 KeyJump := 157;
184 KeyNextWeapon := 73;
185 KeyPrevWeapon := 71;
186 KeyOpen := 54;
187 KeyStrafe := 0;
188 for i := 0 to High(KeyWeapon) do
189 KeyWeapon[i] := 0;
191 KeyRight2 := 0;
192 KeyLeft2 := 0;
193 KeyUp2 := 0;
194 KeyDown2 := 0;
195 KeyFire2 := 0;
196 KeyJump2 := 0;
197 KeyNextWeapon2 := 0;
198 KeyPrevWeapon2 := 0;
199 KeyOpen2 := 0;
200 KeyStrafe2 := 0;
201 for i := 0 to High(KeyWeapon2) do
202 KeyWeapon2[i] := 0;
203 end;
205 with gGameControls.P2Control do
206 begin
207 KeyRight := 33;
208 KeyLeft := 31;
209 KeyUp := 18;
210 KeyDown := 32;
211 KeyFire := 30;
212 KeyJump := 16;
213 KeyNextWeapon := 19;
214 KeyPrevWeapon := 17;
215 KeyOpen := 58;
216 KeyStrafe := 0;
217 for i := 0 to High(KeyWeapon) do
218 KeyWeapon[i] := 0;
220 KeyRight2 := 0;
221 KeyLeft2 := 0;
222 KeyUp2 := 0;
223 KeyDown2 := 0;
224 KeyFire2 := 0;
225 KeyJump2 := 0;
226 KeyNextWeapon2 := 0;
227 KeyPrevWeapon2 := 0;
228 KeyOpen2 := 0;
229 KeyStrafe2 := 0;
230 for i := 0 to High(KeyWeapon2) do
231 KeyWeapon2[i] := 0;
232 end;
234 with gPlayer1Settings do
235 begin
236 Name := 'Player1';
237 Model := STD_PLAYER_MODEL;
238 Color.R := PLAYER1_DEF_COLOR.R;
239 Color.G := PLAYER1_DEF_COLOR.G;
240 Color.B := PLAYER1_DEF_COLOR.B;
241 Team := TEAM_RED;
242 end;
244 with gPlayer2Settings do
245 begin
246 Name := 'Player2';
247 Model := STD_PLAYER_MODEL;
248 Color.R := PLAYER2_DEF_COLOR.R;
249 Color.G := PLAYER2_DEF_COLOR.G;
250 Color.B := PLAYER2_DEF_COLOR.B;
251 Team := TEAM_BLUE;
252 end;
254 NetUseMaster := True;
255 NetForwardPorts := False;
256 g_Net_Slist_Set('mpms.doom2d.org', 25665);
257 end;
259 procedure g_Options_Read(FileName: String);
260 var
261 config: TConfig;
262 str: String;
263 i: Integer;
264 begin
265 gAskLanguage := True;
266 e_WriteLog('Reading config', TMsgType.Notify);
268 if not FileExists(FileName) then
269 begin
270 e_WriteLog('Config file '+FileName+' not found', TMsgType.Warning);
271 g_Options_SetDefault();
273 // Default video options:
274 gScreenWidth := 800;
275 gScreenHeight := 600;
276 gWinRealPosX := 0;
277 gWinRealPosY := 0;
278 gWinMaximized := False;
279 gFullScreen := False;
280 gBPP := 32;
281 gVSync := False;
282 gTextureFilter := True;
283 glLegacyNPOT := False;
285 Exit;
286 end;
288 config := TConfig.CreateFile(FileName);
290 gScreenWidth := config.ReadInt('Video', 'ScreenWidth', 800);
291 if gScreenWidth < 640 then
292 gScreenWidth := 640;
293 gScreenHeight := config.ReadInt('Video', 'ScreenHeight', 600);
294 if gScreenHeight < 480 then
295 gScreenHeight := 480;
296 gWinRealPosX := config.ReadInt('Video', 'WinPosX', 0);
297 if gWinRealPosX < 0 then
298 gWinRealPosX := 0;
299 gWinRealPosY := config.ReadInt('Video', 'WinPosY', 0);
300 if gWinRealPosY < 0 then
301 gWinRealPosY := 0;
302 gFullScreen := config.ReadBool('Video', 'Fullscreen', False);
303 gWinMaximized := config.ReadBool('Video', 'Maximized', False);
304 gBPP := config.ReadInt('Video', 'BPP', 32);
305 gFreq := config.ReadInt('Video', 'Freq', 0);
306 gVSync := config.ReadBool('Video', 'VSync', True);
307 gTextureFilter := config.ReadBool('Video', 'TextureFilter', True);
308 glLegacyNPOT := config.ReadBool('Video', 'LegacyCompatible', False);
310 gNoSound := config.ReadBool('Sound', 'NoSound', False);
311 gSoundLevel := Min(config.ReadInt('Sound', 'SoundLevel', 75), 255);
312 gMusicLevel := Min(config.ReadInt('Sound', 'MusicLevel', 65), 255);
313 gMaxSimSounds := Max(Min(config.ReadInt('Sound', 'MaxSimSounds', 8), 66), 2);
314 gMuteWhenInactive := config.ReadBool('Sound', 'MuteInactive', False);
315 gAnnouncer := Min(Max(config.ReadInt('Sound', 'Announcer', ANNOUNCE_MEPLUS), ANNOUNCE_NONE), ANNOUNCE_ALL);
316 gSoundEffectsDF := config.ReadBool('Sound', 'SoundEffectsDF', True);
317 gUseChatSounds := config.ReadBool('Sound', 'ChatSounds', True);
318 gsSDLSampleRate := Min(Max(config.ReadInt('Sound', 'SDLSampleRate', 44100), 11025), 96000);
319 gsSDLBufferSize := Min(Max(config.ReadInt('Sound', 'SDLBufferSize', 2048), 64), 16384);
321 with gGameControls.GameControls do
322 begin
323 TakeScreenshot := config.ReadInt('GameControls', 'TakeScreenshot', 183);
324 Stat := config.ReadInt('GameControls', 'Stat', 15);
325 Chat := config.ReadInt('GameControls', 'Chat', 20);
326 TeamChat := config.ReadInt('GameControls', 'TeamChat', 21);
327 end;
329 with gGameControls.P1Control, config do
330 begin
331 KeyRight := ReadInt('Player1', 'KeyRight', 33);
332 KeyLeft := ReadInt('Player1', 'KeyLeft', 31);
333 KeyUp := ReadInt('Player1', 'KeyUp', 18);
334 KeyDown := ReadInt('Player1', 'KeyDown', 32);
335 KeyFire := ReadInt('Player1', 'KeyFire', 30);
336 KeyJump := ReadInt('Player1', 'KeyJump', 16);
337 KeyNextWeapon := ReadInt('Player1', 'KeyNextWeapon', 19);
338 KeyPrevWeapon := ReadInt('Player1', 'KeyPrevWeapon', 17);
339 KeyOpen := ReadInt('Player1', 'KeyOpen', 58);
340 KeyStrafe := ReadInt('Player1', 'KeyStrafe', 0);
341 for i := 0 to High(KeyWeapon) do
342 KeyWeapon[i] := ReadInt('Player1', 'KeyWeapon' + IntToStr(i), 0);
344 KeyRight2 := ReadInt('Player1', 'KeyRight2', 0);
345 KeyLeft2 := ReadInt('Player1', 'KeyLeft2', 0);
346 KeyUp2 := ReadInt('Player1', 'KeyUp2', 0);
347 KeyDown2 := ReadInt('Player1', 'KeyDown2', 0);
348 KeyFire2 := ReadInt('Player1', 'KeyFire2', 0);
349 KeyJump2 := ReadInt('Player1', 'KeyJump2', 0);
350 KeyNextWeapon2 := ReadInt('Player1', 'KeyNextWeapon2', 0);
351 KeyPrevWeapon2 := ReadInt('Player1', 'KeyPrevWeapon2', 0);
352 KeyOpen2 := ReadInt('Player1', 'KeyOpen2', 0);
353 KeyStrafe2 := ReadInt('Player1', 'KeyStrafe2', 0);
354 for i := 0 to High(KeyWeapon2) do
355 KeyWeapon2[i] := ReadInt('Player1', 'KeyWeapon2' + IntToStr(i), 0);
356 end;
358 with gPlayer1Settings, config do
359 begin
360 Name := ReadStr('Player1', 'name', 'Player1');
361 Model := ReadStr('Player1', 'model', STD_PLAYER_MODEL);
362 Color.R := Min(Abs(ReadInt('Player1', 'red', PLAYER1_DEF_COLOR.R)), 255);
363 Color.G := Min(Abs(ReadInt('Player1', 'green', PLAYER1_DEF_COLOR.G)), 255);
364 Color.B := Min(Abs(ReadInt('Player1', 'blue', PLAYER1_DEF_COLOR.B)), 255);
365 Team := ReadInt('Player1', 'team', TEAM_RED);
366 if (Team < TEAM_RED) or (Team > TEAM_BLUE) then
367 Team := TEAM_RED;
368 end;
370 with gGameControls.P2Control, config do
371 begin
372 KeyRight := ReadInt('Player2', 'KeyRight', 205);
373 KeyLeft := ReadInt('Player2', 'KeyLeft', 203);
374 KeyUp := ReadInt('Player2', 'KeyUp', 200);
375 KeyDown := ReadInt('Player2', 'KeyDown', 208);
376 KeyFire := ReadInt('Player2', 'KeyFire', 184);
377 KeyJump := ReadInt('Player2', 'KeyJump', 157);
378 KeyNextWeapon := ReadInt('Player2', 'KeyNextWeapon', 73);
379 KeyPrevWeapon := ReadInt('Player2', 'KeyPrevWeapon', 71);
380 KeyOpen := ReadInt('Player2', 'KeyOpen', 54);
381 KeyStrafe := ReadInt('Player2', 'KeyStrafe', 0);
382 for i := 0 to High(KeyWeapon) do
383 KeyWeapon[i] := ReadInt('Player2', 'KeyWeapon' + IntToStr(i), 0);
385 KeyRight2 := ReadInt('Player2', 'KeyRight2', 0);
386 KeyLeft2 := ReadInt('Player2', 'KeyLeft2', 0);
387 KeyUp2 := ReadInt('Player2', 'KeyUp2', 0);
388 KeyDown2 := ReadInt('Player2', 'KeyDown2', 0);
389 KeyFire2 := ReadInt('Player2', 'KeyFire2', 0);
390 KeyJump2 := ReadInt('Player2', 'KeyJump2', 0);
391 KeyNextWeapon2 := ReadInt('Player2', 'KeyNextWeapon2', 0);
392 KeyPrevWeapon2 := ReadInt('Player2', 'KeyPrevWeapon2', 0);
393 KeyOpen2 := ReadInt('Player2', 'KeyOpen2', 0);
394 KeyStrafe2 := ReadInt('Player2', 'KeyStrafe2', 0);
395 for i := 0 to High(KeyWeapon2) do
396 KeyWeapon2[i] := ReadInt('Player2', 'KeyWeapon2' + IntToStr(i), 0);
397 end;
399 with gPlayer2Settings, config do
400 begin
401 Name := ReadStr('Player2', 'name', 'Player2');
402 Model := ReadStr('Player2', 'model', STD_PLAYER_MODEL);
403 Color.R := Min(Abs(ReadInt('Player2', 'red', PLAYER2_DEF_COLOR.R)), 255);
404 Color.G := Min(Abs(ReadInt('Player2', 'green', PLAYER2_DEF_COLOR.G)), 255);
405 Color.B := Min(Abs(ReadInt('Player2', 'blue', PLAYER2_DEF_COLOR.B)), 255);
406 Team := ReadInt('Player2', 'team', TEAM_BLUE);
407 if (Team < TEAM_RED) or (Team > TEAM_BLUE) then
408 Team := TEAM_RED;
409 end;
411 for i := 0 to e_MaxJoys-1 do
412 e_JoystickDeadzones[i] := config.ReadInt('Joysticks', 'Deadzone' + IntToStr(i), 8192);
414 g_GFX_SetMax(Min(config.ReadInt('Game', 'MaxParticles', 1000), 50000));
415 g_Shells_SetMax(Min(config.ReadInt('Game', 'MaxShells', 300), 600));
416 g_Gibs_SetMax(Min(config.ReadInt('Game', 'MaxGibs', 150), 500));
417 g_Corpses_SetMax(Min(config.ReadInt('Game', 'MaxCorpses', 20), 100));
419 case config.ReadInt('Game', 'GibsCount', 3) of
420 0: gGibsCount := 0;
421 1: gGibsCount := 8;
422 2: gGibsCount := 16;
423 3: gGibsCount := 32;
424 else gGibsCount := 48;
425 end;
427 ITEM_RESPAWNTIME := 36*Max(config.ReadInt('Game', 'ItemRespawnTime', 60), 0);
428 gBloodCount := Min(config.ReadInt('Game', 'BloodCount', 4), 4);
429 gAdvBlood := config.ReadBool('Game', 'AdvancesBlood', True);
430 gAdvCorpses := config.ReadBool('Game', 'AdvancesCorpses', True);
431 gAdvGibs := config.ReadBool('Game', 'AdvancesGibs', True);
432 gFlash := Min(Max(config.ReadInt('Game', 'Flash', 1), 0), 2);
433 gDrawBackGround := config.ReadBool('Game', 'BackGround', True);
434 gShowMessages := config.ReadBool('Game', 'Messages', True);
435 gRevertPlayers := config.ReadBool('Game', 'RevertPlayers', False);
436 gChatBubble := Min(Max(config.ReadInt('Game', 'ChatBubble', 4), 0), 4);
437 gSFSDebug := config.ReadBool('Game', 'SFSDebug', False);
438 wadoptDebug := gSFSDebug;
439 gSFSFastMode := config.ReadBool('Game', 'SFSFastMode', False);
440 wadoptFast := gSFSFastMode;
441 e_FastScreenshots := config.ReadBool('Game', 'FastScreenshots', True);
442 gDefaultMegawadStart := config.ReadStr('Game', 'DefaultMegawadStart', DF_Default_Megawad_Start);
443 gBerserkAutoswitch := config.ReadBool('Game', 'BerserkAutoswitching', True);
445 // Ãåéìïëåé â ñâîåé èãðå
446 gcMap := config.ReadStr('GameplayCustom', 'Map', '');
447 gcGameMode := config.ReadStr('GameplayCustom', 'GameMode', _lc[I_MENU_GAME_TYPE_DM]);
448 gcTimeLimit := Min(Max(config.ReadInt('GameplayCustom', 'TimeLimit', 0), 0), 65535);
449 gcGoalLimit := Min(Max(config.ReadInt('GameplayCustom', 'GoalLimit', 0), 0), 65535);
450 gcMaxLives := Min(Max(config.ReadInt('GameplayCustom', 'MaxLives', 0), 0), 255);
451 gcPlayers := Min(Max(config.ReadInt('GameplayCustom', 'Players', 1), 0), 2);
452 gcTeamDamage := config.ReadBool('GameplayCustom', 'TeamDamage', False);
453 gcAllowExit := config.ReadBool('GameplayCustom', 'AllowExit', True);
454 gcWeaponStay := config.ReadBool('GameplayCustom', 'WeaponStay', False);
455 gcMonsters := config.ReadBool('GameplayCustom', 'Monsters', False);
456 gcBotsVS := config.ReadStr('GameplayCustom', 'BotsVS', 'Everybody');
458 with gGameSettings do
459 begin
460 GameMode := g_Game_TextToMode(gcGameMode);
461 if GameMode = GM_NONE then
462 GameMode := GM_DM;
463 if GameMode = GM_SINGLE then
464 GameMode := GM_COOP;
465 TimeLimit := gcTimeLimit;
466 GoalLimit := gcGoalLimit;
467 MaxLives := gcMaxLives;
469 Options := 0;
470 if gcTeamDamage then
471 Options := Options or GAME_OPTION_TEAMDAMAGE;
472 if gcAllowExit then
473 Options := Options or GAME_OPTION_ALLOWEXIT;
474 if gcWeaponStay then
475 Options := Options or GAME_OPTION_WEAPONSTAY;
476 if gcMonsters then
477 Options := Options or GAME_OPTION_MONSTERS;
478 if gcBotsVS = 'Everybody' then
479 Options := Options or GAME_OPTION_BOTVSPLAYER or GAME_OPTION_BOTVSMONSTER;
480 if gcBotsVS = 'Players' then
481 Options := Options or GAME_OPTION_BOTVSPLAYER;
482 if gcBotsVS = 'Monsters' then
483 Options := Options or GAME_OPTION_BOTVSMONSTER;
484 end;
486 // Ãåéìïëåé â ñåòåâîé èãðå
487 gnMap := config.ReadStr('GameplayNetwork', 'Map', '');
488 gnGameMode := config.ReadStr('GameplayNetwork', 'GameMode', _lc[I_MENU_GAME_TYPE_DM]);
489 gnTimeLimit := Min(Max(config.ReadInt('GameplayNetwork', 'TimeLimit', 0), 0), 65535);
490 gnGoalLimit := Min(Max(config.ReadInt('GameplayNetwork', 'GoalLimit', 0), 0), 65535);
491 gnMaxLives := Min(Max(config.ReadInt('GameplayNetwork', 'MaxLives', 0), 0), 255);
492 gnPlayers := Min(Max(config.ReadInt('GameplayNetwork', 'Players', 1), 0), 2);
493 gnTeamDamage := config.ReadBool('GameplayNetwork', 'TeamDamage', False);
494 gnAllowExit := config.ReadBool('GameplayNetwork', 'AllowExit', True);
495 gnWeaponStay := config.ReadBool('GameplayNetwork', 'WeaponStay', False);
496 gnMonsters := config.ReadBool('GameplayNetwork', 'Monsters', False);
497 gnBotsVS := config.ReadStr('GameplayNetwork', 'BotsVS', 'Everybody');
499 // Îáùèå ñåòåâûå
500 NetSlistIP := config.ReadStr('MasterServer', 'IP', 'mpms.doom2d.org');
501 NetSlistPort := config.ReadInt('MasterServer', 'Port', 25665);
503 // Ñåðâåð
504 NetServerName := config.ReadStr('Server', 'Name', 'Unnamed Server');
505 NetPassword := config.ReadStr('Server', 'Password', '');
506 NetPort := Min(Max(0, config.ReadInt('Server', 'Port', 25666)), 65535);
507 NetMaxClients := Min(Max(0, config.ReadInt('Server', 'MaxClients', 16)), NET_MAXCLIENTS);
508 NetAllowRCON := config.ReadBool('Server', 'RCON', False);
509 NetRCONPassword := config.ReadStr('Server', 'RCONPassword', 'default');
510 NetUseMaster := config.ReadBool('Server', 'SyncWithMaster', True);
511 NetUpdateRate := Max(0, config.ReadInt('Server', 'UpdateInterval', 0));
512 NetRelupdRate := Max(0, config.ReadInt('Server', 'ReliableUpdateInterval', 18));
513 NetMasterRate := Max(1, config.ReadInt('Server', 'MasterSyncInterval', 60000));
514 NetForwardPorts := config.ReadBool('Server', 'ForwardPorts', False);
516 // Êëèåíò
517 NetInterpLevel := Max(0, config.ReadInt('Client', 'InterpolationSteps', 2));
518 NetForcePlayerUpdate := config.ReadBool('Client', 'ForcePlayerUpdate', False);
519 NetPredictSelf := config.ReadBool('Client', 'PredictSelf', True);
520 NetClientIP := config.ReadStr('Client', 'LastIP', '127.0.0.1');
521 NetClientPort := Max(0, config.ReadInt('Client', 'LastPort', 25666));
523 // ßçûê:
524 str := config.ReadStr('Game', 'Language', '');
525 if (str = LANGUAGE_RUSSIAN) or
526 (str = LANGUAGE_ENGLISH) then
527 begin
528 gLanguage := str;
529 gAskLanguage := False;
530 end
531 else
532 gLanguage := LANGUAGE_ENGLISH;
534 config.Free();
536 //if gTextureFilter then TEXTUREFILTER := GL_LINEAR else TEXTUREFILTER := GL_NEAREST;
537 end;
539 procedure g_Options_Write(FileName: String);
540 var
541 config: TConfig;
542 i: Integer;
543 begin
544 e_WriteLog('Writing config', TMsgType.Notify);
546 config := TConfig.CreateFile(FileName);
548 config.WriteInt('Video', 'ScreenWidth', gScreenWidth);
549 config.WriteInt('Video', 'ScreenHeight', gScreenHeight);
550 config.WriteInt('Video', 'WinPosX', gWinRealPosX);
551 config.WriteInt('Video', 'WinPosY', gWinRealPosY);
552 config.WriteBool('Video', 'Fullscreen', gFullScreen);
553 config.WriteBool('Video', 'Maximized', gWinMaximized);
554 config.WriteInt('Video', 'BPP', gBPP);
555 config.WriteBool('Video', 'VSync', gVSync);
556 config.WriteBool('Video', 'TextureFilter', gTextureFilter);
557 config.WriteBool('Video', 'LegacyCompatible', glLegacyNPOT);
559 config.WriteBool('Sound', 'NoSound', gNoSound);
560 config.WriteInt('Sound', 'SoundLevel', gSoundLevel);
561 config.WriteInt('Sound', 'MusicLevel', gMusicLevel);
562 config.WriteInt('Sound', 'MaxSimSounds', gMaxSimSounds);
563 config.WriteBool('Sound', 'MuteInactive', gMuteWhenInactive);
564 config.WriteInt('Sound', 'Announcer', gAnnouncer);
565 config.WriteBool('Sound', 'SoundEffectsDF', gSoundEffectsDF);
566 config.WriteBool('Sound', 'ChatSounds', gUseChatSounds);
567 config.WriteInt('Sound', 'SDLSampleRate', gsSDLSampleRate);
568 config.WriteInt('Sound', 'SDLBufferSize', gsSDLBufferSize);
570 with config, gGameControls.GameControls do
571 begin
572 WriteInt('GameControls', 'TakeScreenshot', TakeScreenshot);
573 WriteInt('GameControls', 'Stat', Stat);
574 WriteInt('GameControls', 'Chat', Chat);
575 WriteInt('GameControls', 'TeamChat', TeamChat);
576 end;
578 with config, gGameControls.P1Control, gPlayer1Settings do
579 begin
580 WriteInt('Player1', 'KeyRight', KeyRight);
581 WriteInt('Player1', 'KeyLeft', KeyLeft);
582 WriteInt('Player1', 'KeyUp', KeyUp);
583 WriteInt('Player1', 'KeyDown', KeyDown);
584 WriteInt('Player1', 'KeyFire', KeyFire);
585 WriteInt('Player1', 'KeyJump', KeyJump);
586 WriteInt('Player1', 'KeyNextWeapon', KeyNextWeapon);
587 WriteInt('Player1', 'KeyPrevWeapon', KeyPrevWeapon);
588 WriteInt('Player1', 'KeyOpen', KeyOpen);
589 WriteInt('Player1', 'KeyStrafe', KeyStrafe);
590 for i := 0 to High(KeyWeapon) do
591 WriteInt('Player1', 'KeyWeapon' + IntToStr(i), KeyWeapon[i]);
593 WriteInt('Player1', 'KeyRight2', KeyRight2);
594 WriteInt('Player1', 'KeyLeft2', KeyLeft2);
595 WriteInt('Player1', 'KeyUp2', KeyUp2);
596 WriteInt('Player1', 'KeyDown2', KeyDown2);
597 WriteInt('Player1', 'KeyFire2', KeyFire2);
598 WriteInt('Player1', 'KeyJump2', KeyJump2);
599 WriteInt('Player1', 'KeyNextWeapon2', KeyNextWeapon2);
600 WriteInt('Player1', 'KeyPrevWeapon2', KeyPrevWeapon2);
601 WriteInt('Player1', 'KeyOpen2', KeyOpen2);
602 WriteInt('Player1', 'KeyStrafe2', KeyStrafe2);
603 for i := 0 to High(KeyWeapon2) do
604 WriteInt('Player1', 'KeyWeapon2' + IntToStr(i), KeyWeapon2[i]);
606 WriteStr('Player1', 'Name', Name);
607 WriteStr('Player1', 'model', Model);
608 WriteInt('Player1', 'red', Color.R);
609 WriteInt('Player1', 'green', Color.G);
610 WriteInt('Player1', 'blue', Color.B);
611 WriteInt('Player1', 'team', Team);
612 end;
614 with config, gGameControls.P2Control, gPlayer2Settings do
615 begin
616 WriteInt('Player2', 'KeyRight', KeyRight);
617 WriteInt('Player2', 'KeyLeft', KeyLeft);
618 WriteInt('Player2', 'KeyUp', KeyUp);
619 WriteInt('Player2', 'KeyDown', KeyDown);
620 WriteInt('Player2', 'KeyFire', KeyFire);
621 WriteInt('Player2', 'KeyJump', KeyJump);
622 WriteInt('Player2', 'KeyNextWeapon', KeyNextWeapon);
623 WriteInt('Player2', 'KeyPrevWeapon', KeyPrevWeapon);
624 WriteInt('Player2', 'KeyOpen', KeyOpen);
625 WriteInt('Player2', 'KeyStrafe', KeyStrafe);
626 for i := 0 to High(KeyWeapon) do
627 WriteInt('Player2', 'KeyWeapon' + IntToStr(i), KeyWeapon[i]);
629 WriteInt('Player2', 'KeyRight2', KeyRight2);
630 WriteInt('Player2', 'KeyLeft2', KeyLeft2);
631 WriteInt('Player2', 'KeyUp2', KeyUp2);
632 WriteInt('Player2', 'KeyDown2', KeyDown2);
633 WriteInt('Player2', 'KeyFire2', KeyFire2);
634 WriteInt('Player2', 'KeyJump2', KeyJump2);
635 WriteInt('Player2', 'KeyNextWeapon2', KeyNextWeapon2);
636 WriteInt('Player2', 'KeyPrevWeapon2', KeyPrevWeapon2);
637 WriteInt('Player2', 'KeyOpen2', KeyOpen2);
638 WriteInt('Player2', 'KeyStrafe2', KeyStrafe2);
639 for i := 0 to High(KeyWeapon2) do
640 WriteInt('Player2', 'KeyWeapon2' + IntToStr(i), KeyWeapon2[i]);
642 WriteStr('Player2', 'Name', Name);
643 WriteStr('Player2', 'model', Model);
644 WriteInt('Player2', 'red', Color.R);
645 WriteInt('Player2', 'green', Color.G);
646 WriteInt('Player2', 'blue', Color.B);
647 WriteInt('Player2', 'team', Team);
648 end;
650 for i := 0 to e_MaxJoys-1 do
651 config.WriteInt('Joysticks', 'Deadzone' + IntToStr(i), e_JoystickDeadzones[i]);
653 with config do
654 case gGibsCount of
655 0: config.WriteInt('Game', 'GibsCount', 0);
656 8: config.WriteInt('Game', 'GibsCount', 1);
657 16: config.WriteInt('Game', 'GibsCount', 2);
658 32: config.WriteInt('Game', 'GibsCount', 3);
659 else config.WriteInt('Game', 'GibsCount', 4);
660 end;
662 config.WriteInt('Game', 'ItemRespawnTime', ITEM_RESPAWNTIME div 36);
663 config.WriteInt('Game', 'MaxParticles', g_GFX_GetMax());
664 config.WriteInt('Game', 'MaxShells', g_Shells_GetMax());
665 config.WriteInt('Game', 'MaxGibs', g_Gibs_GetMax());
666 config.WriteInt('Game', 'MaxCorpses', g_Corpses_GetMax());
667 config.WriteInt('Game', 'BloodCount', gBloodCount);
668 config.WriteBool('Game', 'AdvancesBlood', gAdvBlood);
669 config.WriteBool('Game', 'AdvancesCorpses', gAdvCorpses);
670 config.WriteBool('Game', 'AdvancesGibs', gAdvGibs);
671 config.WriteInt('Game', 'Flash', gFlash);
672 config.WriteBool('Game', 'BackGround', gDrawBackGround);
673 config.WriteBool('Game', 'Messages', gShowMessages);
674 config.WriteBool('Game', 'RevertPlayers', gRevertPlayers);
675 config.WriteInt('Game', 'ChatBubble', gChatBubble);
676 config.WriteBool('Game', 'SFSDebug', gSFSDebug);
677 config.WriteBool('Game', 'SFSFastMode', gSFSFastMode);
678 config.WriteBool('Game', 'FastScreenshots', e_FastScreenshots);
679 config.WriteStr('Game', 'DefaultMegawadStart', gDefaultMegawadStart);
680 config.WriteBool('Game', 'BerserkAutoswitching', gBerserkAutoswitch);
682 config.WriteStr ('GameplayCustom', 'Map', gcMap);
683 config.WriteStr ('GameplayCustom', 'GameMode', gcGameMode);
684 config.WriteInt ('GameplayCustom', 'TimeLimit', gcTimeLimit);
685 config.WriteInt ('GameplayCustom', 'GoalLimit', gcGoalLimit);
686 config.WriteInt ('GameplayCustom', 'MaxLives', gcMaxLives);
687 config.WriteInt ('GameplayCustom', 'Players', gcPlayers);
688 config.WriteBool('GameplayCustom', 'TeamDamage', gcTeamDamage);
689 config.WriteBool('GameplayCustom', 'AllowExit', gcAllowExit);
690 config.WriteBool('GameplayCustom', 'WeaponStay', gcWeaponStay);
691 config.WriteBool('GameplayCustom', 'Monsters', gcMonsters);
692 config.WriteStr ('GameplayCustom', 'BotsVS', gcBotsVS);
694 config.WriteStr ('GameplayNetwork', 'Map', gnMap);
695 config.WriteStr ('GameplayNetwork', 'GameMode', gnGameMode);
696 config.WriteInt ('GameplayNetwork', 'TimeLimit', gnTimeLimit);
697 config.WriteInt ('GameplayNetwork', 'GoalLimit', gnGoalLimit);
698 config.WriteInt ('GameplayNetwork', 'MaxLives', gnMaxLives);
699 config.WriteInt ('GameplayNetwork', 'Players', gnPlayers);
700 config.WriteBool('GameplayNetwork', 'TeamDamage', gnTeamDamage);
701 config.WriteBool('GameplayNetwork', 'AllowExit', gnAllowExit);
702 config.WriteBool('GameplayNetwork', 'WeaponStay', gnWeaponStay);
703 config.WriteBool('GameplayNetwork', 'Monsters', gnMonsters);
704 config.WriteStr ('GameplayNetwork', 'BotsVS', gnBotsVS);
706 config.WriteStr('MasterServer', 'IP', NetSlistIP);
707 config.WriteInt('MasterServer', 'Port', NetSlistPort);
709 config.WriteStr ('Server', 'Name', NetServerName);
710 config.WriteStr ('Server', 'Password', NetPassword);
711 config.WriteInt ('Server', 'Port', NetPort);
712 config.WriteInt ('Server', 'MaxClients', NetMaxClients);
713 config.WriteBool('Server', 'RCON', NetAllowRCON);
714 config.WriteStr ('Server', 'RCONPassword', NetRCONPassword);
715 config.WriteBool('Server', 'SyncWithMaster', NetUseMaster);
716 config.WriteBool('Server', 'ForwardPorts', NetForwardPorts);
717 config.WriteInt ('Server', 'UpdateInterval', NetUpdateRate);
718 config.WriteInt ('Server', 'ReliableUpdateInterval', NetRelupdRate);
719 config.WriteInt ('Server', 'MasterSyncInterval', NetMasterRate);
721 config.WriteInt ('Client', 'InterpolationSteps', NetInterpLevel);
722 config.WriteBool ('Client', 'ForcePlayerUpdate', NetForcePlayerUpdate);
723 config.WriteBool ('Client', 'PredictSelf', NetPredictSelf);
724 config.WriteStr ('Client', 'LastIP', NetClientIP);
725 config.WriteInt ('Client', 'LastPort', NetClientPort);
727 config.SaveFile(FileName);
728 config.Free();
729 end;
731 procedure g_Options_Write_Language(FileName: String);
732 var
733 config: TConfig;
734 begin
735 e_WriteLog('Writing language config', TMsgType.Notify);
737 config := TConfig.CreateFile(FileName);
738 config.WriteStr('Game', 'Language', gLanguage);
739 config.SaveFile(FileName);
740 config.Free();
741 end;
743 procedure g_Options_Write_Video(FileName: String);
744 var
745 config: TConfig;
746 sW, sH: Integer;
747 begin
748 e_WriteLog('Writing resolution to config', TMsgType.Notify);
750 config := TConfig.CreateFile(FileName);
752 if gWinMaximized and (not gFullscreen) then
753 begin
754 sW := gWinSizeX;
755 sH := gWinSizeY;
756 end
757 else
758 begin
759 sW := gScreenWidth;
760 sH := gScreenHeight;
761 end;
762 e_LogWritefln(' (ws=%dx%d) (ss=%dx%d)', [gWinSizeX, gWinSizeY, gScreenWidth, gScreenHeight]);
764 config.WriteInt('Video', 'ScreenWidth', sW);
765 config.WriteInt('Video', 'ScreenHeight', sH);
766 config.WriteInt('Video', 'WinPosX', gWinRealPosX);
767 config.WriteInt('Video', 'WinPosY', gWinRealPosY);
768 config.WriteBool('Video', 'Fullscreen', gFullscreen);
769 config.WriteBool('Video', 'Maximized', gWinMaximized);
771 config.SaveFile(FileName);
772 config.Free();
773 end;
775 procedure g_Options_Write_Gameplay_Custom(FileName: String);
776 var
777 config: TConfig;
778 begin
779 e_WriteLog('Writing custom gameplay config', TMsgType.Notify);
781 config := TConfig.CreateFile(FileName);
783 config.WriteStr ('GameplayCustom', 'Map', gcMap);
784 config.WriteStr ('GameplayCustom', 'GameMode', gcGameMode);
785 config.WriteInt ('GameplayCustom', 'TimeLimit', gcTimeLimit);
786 config.WriteInt ('GameplayCustom', 'GoalLimit', gcGoalLimit);
787 config.WriteInt ('GameplayCustom', 'MaxLives', gcMaxLives);
788 config.WriteInt ('GameplayCustom', 'Players', gcPlayers);
789 config.WriteBool('GameplayCustom', 'TeamDamage', gcTeamDamage);
790 config.WriteBool('GameplayCustom', 'AllowExit', gcAllowExit);
791 config.WriteBool('GameplayCustom', 'WeaponStay', gcWeaponStay);
792 config.WriteBool('GameplayCustom', 'Monsters', gcMonsters);
793 config.WriteStr ('GameplayCustom', 'BotsVS', gcBotsVS);
795 config.SaveFile(FileName);
796 config.Free();
797 end;
799 procedure g_Options_Write_Gameplay_Net(FileName: String);
800 var
801 config: TConfig;
802 begin
803 e_WriteLog('Writing network gameplay config', TMsgType.Notify);
805 config := TConfig.CreateFile(FileName);
807 config.WriteStr ('GameplayNetwork', 'Map', gnMap);
808 config.WriteStr ('GameplayNetwork', 'GameMode', gnGameMode);
809 config.WriteInt ('GameplayNetwork', 'TimeLimit', gnTimeLimit);
810 config.WriteInt ('GameplayNetwork', 'GoalLimit', gnGoalLimit);
811 config.WriteInt ('GameplayNetwork', 'MaxLives', gnMaxLives);
812 config.WriteInt ('GameplayNetwork', 'Players', gnPlayers);
813 config.WriteBool('GameplayNetwork', 'TeamDamage', gnTeamDamage);
814 config.WriteBool('GameplayNetwork', 'AllowExit', gnAllowExit);
815 config.WriteBool('GameplayNetwork', 'WeaponStay', gnWeaponStay);
816 config.WriteBool('GameplayNetwork', 'Monsters', gnMonsters);
817 config.WriteStr ('GameplayNetwork', 'BotsVS', gnBotsVS);
819 config.SaveFile(FileName);
820 config.Free();
821 end;
823 procedure g_Options_Write_Net_Server(FileName: String);
824 var
825 config: TConfig;
826 begin
827 e_WriteLog('Writing server config', TMsgType.Notify);
829 config := TConfig.CreateFile(FileName);
831 config.WriteStr ('Server', 'Name', NetServerName);
832 config.WriteStr ('Server', 'Password', NetPassword);
833 config.WriteInt ('Server', 'Port', NetPort);
834 config.WriteInt ('Server', 'MaxClients', NetMaxClients);
835 config.WriteBool('Server', 'SyncWithMaster', NetUseMaster);
836 config.WriteBool('Server', 'ForwardPorts', NetForwardPorts);
838 config.SaveFile(FileName);
839 config.Free();
840 end;
842 procedure g_Options_Write_Net_Client(FileName: String);
843 var
844 config: TConfig;
845 begin
846 e_WriteLog('Writing client config', TMsgType.Notify);
848 config := TConfig.CreateFile(FileName);
850 config.WriteStr('Client', 'LastIP', NetClientIP);
851 config.WriteInt('Client', 'LastPort', NetClientPort);
853 config.SaveFile(FileName);
854 config.Free();
855 end;
857 end.