DEADSOFTWARE

changed mode from DELPHI to OBJFPC (with heavy customization, see "shared/a_modes...
[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;
133 implementation
135 uses
136 e_log, e_input, g_window, g_sound, g_gfx, g_player, Math,
137 g_map, g_net, g_netmaster, SysUtils, CONFIG, g_game, g_main, e_texture,
138 g_items, GL, GLExt, wadreader, e_graphics;
140 procedure g_Options_SetDefault();
141 var
142 i: Integer;
143 begin
144 g_Sound_SetupAllVolumes(75, 65);
145 gMaxSimSounds := 8;
146 gMuteWhenInactive := False;
147 gAnnouncer := ANNOUNCE_MEPLUS;
148 gSoundEffectsDF := True;
149 g_GFX_SetMax(2000);
150 g_Gibs_SetMax(150);
151 g_Corpses_SetMax(20);
152 g_Shells_SetMax(300);
153 gGibsCount := 32;
154 gBloodCount := 3;
155 gAdvBlood := True;
156 gAdvCorpses := True;
157 gAdvGibs := True;
158 gFlash := 1;
159 gDrawBackGround := True;
160 gShowMessages := True;
161 gRevertPlayers := False;
163 for i := 0 to e_MaxJoys-1 do
164 e_JoystickDeadzones[i] := 8192;
166 with gGameControls.GameControls do
167 begin
168 TakeScreenshot := 183;
169 Stat := 15;
170 Chat := 20; // [T]
171 TeamChat := 21; // [Y]
172 end;
174 with gGameControls.P1Control do
175 begin
176 KeyRight := 77;
177 KeyLeft := 75;
178 KeyUp := 72;
179 KeyDown := 76;
180 KeyFire := 184;
181 KeyJump := 157;
182 KeyNextWeapon := 73;
183 KeyPrevWeapon := 71;
184 KeyOpen := 54;
185 KeyStrafe := 0;
186 for i := 0 to High(KeyWeapon) do
187 KeyWeapon[i] := 0;
189 KeyRight2 := 0;
190 KeyLeft2 := 0;
191 KeyUp2 := 0;
192 KeyDown2 := 0;
193 KeyFire2 := 0;
194 KeyJump2 := 0;
195 KeyNextWeapon2 := 0;
196 KeyPrevWeapon2 := 0;
197 KeyOpen2 := 0;
198 KeyStrafe2 := 0;
199 for i := 0 to High(KeyWeapon2) do
200 KeyWeapon2[i] := 0;
201 end;
203 with gGameControls.P2Control do
204 begin
205 KeyRight := 33;
206 KeyLeft := 31;
207 KeyUp := 18;
208 KeyDown := 32;
209 KeyFire := 30;
210 KeyJump := 16;
211 KeyNextWeapon := 19;
212 KeyPrevWeapon := 17;
213 KeyOpen := 58;
214 KeyStrafe := 0;
215 for i := 0 to High(KeyWeapon) do
216 KeyWeapon[i] := 0;
218 KeyRight2 := 0;
219 KeyLeft2 := 0;
220 KeyUp2 := 0;
221 KeyDown2 := 0;
222 KeyFire2 := 0;
223 KeyJump2 := 0;
224 KeyNextWeapon2 := 0;
225 KeyPrevWeapon2 := 0;
226 KeyOpen2 := 0;
227 KeyStrafe2 := 0;
228 for i := 0 to High(KeyWeapon2) do
229 KeyWeapon2[i] := 0;
230 end;
232 with gPlayer1Settings do
233 begin
234 Name := 'Player1';
235 Model := STD_PLAYER_MODEL;
236 Color.R := PLAYER1_DEF_COLOR.R;
237 Color.G := PLAYER1_DEF_COLOR.G;
238 Color.B := PLAYER1_DEF_COLOR.B;
239 Team := TEAM_RED;
240 end;
242 with gPlayer2Settings do
243 begin
244 Name := 'Player2';
245 Model := STD_PLAYER_MODEL;
246 Color.R := PLAYER2_DEF_COLOR.R;
247 Color.G := PLAYER2_DEF_COLOR.G;
248 Color.B := PLAYER2_DEF_COLOR.B;
249 Team := TEAM_BLUE;
250 end;
252 NetUseMaster := True;
253 g_Net_Slist_Set('mpms.doom2d.org', 25665);
254 end;
256 procedure g_Options_Read(FileName: String);
257 var
258 config: TConfig;
259 str: String;
260 i: Integer;
261 begin
262 gAskLanguage := True;
263 e_WriteLog('Reading config', MSG_NOTIFY);
265 if not FileExists(FileName) then
266 begin
267 e_WriteLog('Config file '+FileName+' not found', MSG_WARNING);
268 g_Options_SetDefault();
270 // Default video options:
271 gScreenWidth := 800;
272 gScreenHeight := 600;
273 gWinRealPosX := 0;
274 gWinRealPosY := 0;
275 gWinMaximized := False;
276 gFullScreen := False;
277 gBPP := 32;
278 gVSync := False;
279 gTextureFilter := True;
280 glLegacyNPOT := False;
282 Exit;
283 end;
285 config := TConfig.CreateFile(FileName);
287 gScreenWidth := config.ReadInt('Video', 'ScreenWidth', 800);
288 if gScreenWidth < 640 then
289 gScreenWidth := 640;
290 gScreenHeight := config.ReadInt('Video', 'ScreenHeight', 600);
291 if gScreenHeight < 480 then
292 gScreenHeight := 480;
293 gWinRealPosX := config.ReadInt('Video', 'WinPosX', 0);
294 if gWinRealPosX < 0 then
295 gWinRealPosX := 0;
296 gWinRealPosY := config.ReadInt('Video', 'WinPosY', 0);
297 if gWinRealPosY < 0 then
298 gWinRealPosY := 0;
299 gFullScreen := config.ReadBool('Video', 'Fullscreen', False);
300 gWinMaximized := config.ReadBool('Video', 'Maximized', False);
301 gBPP := config.ReadInt('Video', 'BPP', 32);
302 gFreq := config.ReadInt('Video', 'Freq', 0);
303 gVSync := config.ReadBool('Video', 'VSync', True);
304 gTextureFilter := config.ReadBool('Video', 'TextureFilter', True);
305 glLegacyNPOT := config.ReadBool('Video', 'LegacyCompatible', False);
307 gNoSound := config.ReadBool('Sound', 'NoSound', False);
308 gSoundLevel := Min(config.ReadInt('Sound', 'SoundLevel', 75), 255);
309 gMusicLevel := Min(config.ReadInt('Sound', 'MusicLevel', 65), 255);
310 gMaxSimSounds := Max(Min(config.ReadInt('Sound', 'MaxSimSounds', 8), 66), 2);
311 gMuteWhenInactive := config.ReadBool('Sound', 'MuteInactive', False);
312 gAnnouncer := Min(Max(config.ReadInt('Sound', 'Announcer', ANNOUNCE_MEPLUS), ANNOUNCE_NONE), ANNOUNCE_ALL);
313 gSoundEffectsDF := config.ReadBool('Sound', 'SoundEffectsDF', True);
314 gsSDLSampleRate := Min(Max(config.ReadInt('Sound', 'SDLSampleRate', 44100), 11025), 96000);
315 gsSDLBufferSize := Min(Max(config.ReadInt('Sound', 'SDLBufferSize', 2048), 64), 16384);
317 with gGameControls.GameControls do
318 begin
319 TakeScreenshot := config.ReadInt('GameControls', 'TakeScreenshot', 183);
320 Stat := config.ReadInt('GameControls', 'Stat', 15);
321 Chat := config.ReadInt('GameControls', 'Chat', 20);
322 TeamChat := config.ReadInt('GameControls', 'TeamChat', 21);
323 end;
325 with gGameControls.P1Control, config do
326 begin
327 KeyRight := ReadInt('Player1', 'KeyRight', 33);
328 KeyLeft := ReadInt('Player1', 'KeyLeft', 31);
329 KeyUp := ReadInt('Player1', 'KeyUp', 18);
330 KeyDown := ReadInt('Player1', 'KeyDown', 32);
331 KeyFire := ReadInt('Player1', 'KeyFire', 30);
332 KeyJump := ReadInt('Player1', 'KeyJump', 16);
333 KeyNextWeapon := ReadInt('Player1', 'KeyNextWeapon', 19);
334 KeyPrevWeapon := ReadInt('Player1', 'KeyPrevWeapon', 17);
335 KeyOpen := ReadInt('Player1', 'KeyOpen', 58);
336 KeyStrafe := ReadInt('Player1', 'KeyStrafe', 0);
337 for i := 0 to High(KeyWeapon) do
338 KeyWeapon[i] := ReadInt('Player1', 'KeyWeapon' + IntToStr(i), 0);
340 KeyRight2 := ReadInt('Player1', 'KeyRight2', 0);
341 KeyLeft2 := ReadInt('Player1', 'KeyLeft2', 0);
342 KeyUp2 := ReadInt('Player1', 'KeyUp2', 0);
343 KeyDown2 := ReadInt('Player1', 'KeyDown2', 0);
344 KeyFire2 := ReadInt('Player1', 'KeyFire2', 0);
345 KeyJump2 := ReadInt('Player1', 'KeyJump2', 0);
346 KeyNextWeapon2 := ReadInt('Player1', 'KeyNextWeapon2', 0);
347 KeyPrevWeapon2 := ReadInt('Player1', 'KeyPrevWeapon2', 0);
348 KeyOpen2 := ReadInt('Player1', 'KeyOpen2', 0);
349 KeyStrafe2 := ReadInt('Player1', 'KeyStrafe2', 0);
350 for i := 0 to High(KeyWeapon2) do
351 KeyWeapon2[i] := ReadInt('Player1', 'KeyWeapon2' + IntToStr(i), 0);
352 end;
354 with gPlayer1Settings, config do
355 begin
356 Name := ReadStr('Player1', 'name', 'Player1');
357 Model := ReadStr('Player1', 'model', STD_PLAYER_MODEL);
358 Color.R := Min(Abs(ReadInt('Player1', 'red', PLAYER1_DEF_COLOR.R)), 255);
359 Color.G := Min(Abs(ReadInt('Player1', 'green', PLAYER1_DEF_COLOR.G)), 255);
360 Color.B := Min(Abs(ReadInt('Player1', 'blue', PLAYER1_DEF_COLOR.B)), 255);
361 Team := ReadInt('Player1', 'team', TEAM_RED);
362 if (Team < TEAM_RED) or (Team > TEAM_BLUE) then
363 Team := TEAM_RED;
364 end;
366 with gGameControls.P2Control, config do
367 begin
368 KeyRight := ReadInt('Player2', 'KeyRight', 205);
369 KeyLeft := ReadInt('Player2', 'KeyLeft', 203);
370 KeyUp := ReadInt('Player2', 'KeyUp', 200);
371 KeyDown := ReadInt('Player2', 'KeyDown', 208);
372 KeyFire := ReadInt('Player2', 'KeyFire', 184);
373 KeyJump := ReadInt('Player2', 'KeyJump', 157);
374 KeyNextWeapon := ReadInt('Player2', 'KeyNextWeapon', 73);
375 KeyPrevWeapon := ReadInt('Player2', 'KeyPrevWeapon', 71);
376 KeyOpen := ReadInt('Player2', 'KeyOpen', 54);
377 KeyStrafe := ReadInt('Player2', 'KeyStrafe', 0);
378 for i := 0 to High(KeyWeapon) do
379 KeyWeapon[i] := ReadInt('Player2', 'KeyWeapon' + IntToStr(i), 0);
381 KeyRight2 := ReadInt('Player2', 'KeyRight2', 0);
382 KeyLeft2 := ReadInt('Player2', 'KeyLeft2', 0);
383 KeyUp2 := ReadInt('Player2', 'KeyUp2', 0);
384 KeyDown2 := ReadInt('Player2', 'KeyDown2', 0);
385 KeyFire2 := ReadInt('Player2', 'KeyFire2', 0);
386 KeyJump2 := ReadInt('Player2', 'KeyJump2', 0);
387 KeyNextWeapon2 := ReadInt('Player2', 'KeyNextWeapon2', 0);
388 KeyPrevWeapon2 := ReadInt('Player2', 'KeyPrevWeapon2', 0);
389 KeyOpen2 := ReadInt('Player2', 'KeyOpen2', 0);
390 KeyStrafe2 := ReadInt('Player2', 'KeyStrafe2', 0);
391 for i := 0 to High(KeyWeapon2) do
392 KeyWeapon2[i] := ReadInt('Player2', 'KeyWeapon2' + IntToStr(i), 0);
393 end;
395 with gPlayer2Settings, config do
396 begin
397 Name := ReadStr('Player2', 'name', 'Player2');
398 Model := ReadStr('Player2', 'model', STD_PLAYER_MODEL);
399 Color.R := Min(Abs(ReadInt('Player2', 'red', PLAYER2_DEF_COLOR.R)), 255);
400 Color.G := Min(Abs(ReadInt('Player2', 'green', PLAYER2_DEF_COLOR.G)), 255);
401 Color.B := Min(Abs(ReadInt('Player2', 'blue', PLAYER2_DEF_COLOR.B)), 255);
402 Team := ReadInt('Player2', 'team', TEAM_BLUE);
403 if (Team < TEAM_RED) or (Team > TEAM_BLUE) then
404 Team := TEAM_RED;
405 end;
407 for i := 0 to e_MaxJoys-1 do
408 e_JoystickDeadzones[i] := config.ReadInt('Joysticks', 'Deadzone' + IntToStr(i), 8192);
410 g_GFX_SetMax(Min(config.ReadInt('Game', 'MaxParticles', 1000), 50000));
411 g_Shells_SetMax(Min(config.ReadInt('Game', 'MaxShells', 300), 600));
412 g_Gibs_SetMax(Min(config.ReadInt('Game', 'MaxGibs', 150), 500));
413 g_Corpses_SetMax(Min(config.ReadInt('Game', 'MaxCorpses', 20), 100));
415 case config.ReadInt('Game', 'GibsCount', 3) of
416 0: gGibsCount := 0;
417 1: gGibsCount := 8;
418 2: gGibsCount := 16;
419 3: gGibsCount := 32;
420 else gGibsCount := 48;
421 end;
423 ITEM_RESPAWNTIME := 36*Max(config.ReadInt('Game', 'ItemRespawnTime', 60), 0);
424 gBloodCount := Min(config.ReadInt('Game', 'BloodCount', 4), 4);
425 gAdvBlood := config.ReadBool('Game', 'AdvancesBlood', True);
426 gAdvCorpses := config.ReadBool('Game', 'AdvancesCorpses', True);
427 gAdvGibs := config.ReadBool('Game', 'AdvancesGibs', True);
428 gFlash := Min(Max(config.ReadInt('Game', 'Flash', 1), 0), 2);
429 gDrawBackGround := config.ReadBool('Game', 'BackGround', True);
430 gShowMessages := config.ReadBool('Game', 'Messages', True);
431 gRevertPlayers := config.ReadBool('Game', 'RevertPlayers', False);
432 gChatBubble := Min(Max(config.ReadInt('Game', 'ChatBubble', 4), 0), 4);
433 gSFSDebug := config.ReadBool('Game', 'SFSDebug', False);
434 wadoptDebug := gSFSDebug;
435 gSFSFastMode := config.ReadBool('Game', 'SFSFastMode', False);
436 wadoptFast := gSFSFastMode;
437 e_FastScreenshots := config.ReadBool('Game', 'FastScreenshots', True);
438 gDefaultMegawadStart := config.ReadStr('Game', 'DefaultMegawadStart', 'megawads/DOOM2D.WAD:\MAP01');
440 // Ãåéìïëåé â ñâîåé èãðå
441 gcMap := config.ReadStr('GameplayCustom', 'Map', '');
442 gcGameMode := config.ReadStr('GameplayCustom', 'GameMode', _lc[I_MENU_GAME_TYPE_DM]);
443 gcTimeLimit := Min(Max(config.ReadInt('GameplayCustom', 'TimeLimit', 0), 0), 65535);
444 gcGoalLimit := Min(Max(config.ReadInt('GameplayCustom', 'GoalLimit', 0), 0), 65535);
445 gcMaxLives := Min(Max(config.ReadInt('GameplayCustom', 'MaxLives', 0), 0), 255);
446 gcPlayers := Min(Max(config.ReadInt('GameplayCustom', 'Players', 1), 0), 2);
447 gcTeamDamage := config.ReadBool('GameplayCustom', 'TeamDamage', False);
448 gcAllowExit := config.ReadBool('GameplayCustom', 'AllowExit', True);
449 gcWeaponStay := config.ReadBool('GameplayCustom', 'WeaponStay', False);
450 gcMonsters := config.ReadBool('GameplayCustom', 'Monsters', False);
451 gcBotsVS := config.ReadStr('GameplayCustom', 'BotsVS', 'Everybody');
453 with gGameSettings do
454 begin
455 GameMode := g_Game_TextToMode(gcGameMode);
456 if GameMode = GM_NONE then
457 GameMode := GM_DM;
458 if GameMode = GM_SINGLE then
459 GameMode := GM_COOP;
460 TimeLimit := gcTimeLimit;
461 GoalLimit := gcGoalLimit;
462 MaxLives := gcMaxLives;
464 Options := 0;
465 if gcTeamDamage then
466 Options := Options or GAME_OPTION_TEAMDAMAGE;
467 if gcAllowExit then
468 Options := Options or GAME_OPTION_ALLOWEXIT;
469 if gcWeaponStay then
470 Options := Options or GAME_OPTION_WEAPONSTAY;
471 if gcMonsters then
472 Options := Options or GAME_OPTION_MONSTERS;
473 if gcBotsVS = 'Everybody' then
474 Options := Options or GAME_OPTION_BOTVSPLAYER or GAME_OPTION_BOTVSMONSTER;
475 if gcBotsVS = 'Players' then
476 Options := Options or GAME_OPTION_BOTVSPLAYER;
477 if gcBotsVS = 'Monsters' then
478 Options := Options or GAME_OPTION_BOTVSMONSTER;
479 end;
481 // Ãåéìïëåé â ñåòåâîé èãðå
482 gnMap := config.ReadStr('GameplayNetwork', 'Map', '');
483 gnGameMode := config.ReadStr('GameplayNetwork', 'GameMode', _lc[I_MENU_GAME_TYPE_DM]);
484 gnTimeLimit := Min(Max(config.ReadInt('GameplayNetwork', 'TimeLimit', 0), 0), 65535);
485 gnGoalLimit := Min(Max(config.ReadInt('GameplayNetwork', 'GoalLimit', 0), 0), 65535);
486 gnMaxLives := Min(Max(config.ReadInt('GameplayNetwork', 'MaxLives', 0), 0), 255);
487 gnPlayers := Min(Max(config.ReadInt('GameplayNetwork', 'Players', 1), 0), 2);
488 gnTeamDamage := config.ReadBool('GameplayNetwork', 'TeamDamage', False);
489 gnAllowExit := config.ReadBool('GameplayNetwork', 'AllowExit', True);
490 gnWeaponStay := config.ReadBool('GameplayNetwork', 'WeaponStay', False);
491 gnMonsters := config.ReadBool('GameplayNetwork', 'Monsters', False);
492 gnBotsVS := config.ReadStr('GameplayNetwork', 'BotsVS', 'Everybody');
494 // Îáùèå ñåòåâûå
495 NetSlistIP := config.ReadStr('MasterServer', 'IP', 'mpms.doom2d.org');
496 NetSlistPort := config.ReadInt('MasterServer', 'Port', 25665);
498 // Ñåðâåð
499 NetServerName := config.ReadStr('Server', 'Name', 'Unnamed Server');
500 NetPassword := config.ReadStr('Server', 'Password', '');
501 NetPort := Min(Max(0, config.ReadInt('Server', 'Port', 25666)), 65535);
502 NetMaxClients := Min(Max(0, config.ReadInt('Server', 'MaxClients', 16)), NET_MAXCLIENTS);
503 NetAllowRCON := config.ReadBool('Server', 'RCON', False);
504 NetRCONPassword := config.ReadStr('Server', 'RCONPassword', 'default');
505 NetUseMaster := config.ReadBool('Server', 'SyncWithMaster', True);
506 NetUpdateRate := Max(0, config.ReadInt('Server', 'UpdateInterval', 0));
507 NetRelupdRate := Max(0, config.ReadInt('Server', 'ReliableUpdateInterval', 18));
508 NetMasterRate := Max(1, config.ReadInt('Server', 'MasterSyncInterval', 60000));
510 // Êëèåíò
511 NetInterpLevel := Max(0, config.ReadInt('Client', 'InterpolationSteps', 2));
512 NetForcePlayerUpdate := config.ReadBool('Client', 'ForcePlayerUpdate', False);
513 NetPredictSelf := config.ReadBool('Client', 'PredictSelf', True);
514 NetClientIP := config.ReadStr('Client', 'LastIP', '127.0.0.1');
515 NetClientPort := Max(0, config.ReadInt('Client', 'LastPort', 25666));
517 // ßçûê:
518 str := config.ReadStr('Game', 'Language', '');
519 if (str = LANGUAGE_RUSSIAN) or
520 (str = LANGUAGE_ENGLISH) then
521 begin
522 gLanguage := str;
523 gAskLanguage := False;
524 end
525 else
526 gLanguage := LANGUAGE_ENGLISH;
528 config.Free();
530 if gTextureFilter then
531 TEXTUREFILTER := GL_LINEAR
532 else
533 TEXTUREFILTER := GL_NEAREST;
534 end;
536 procedure g_Options_Write(FileName: String);
537 var
538 config: TConfig;
539 i: Integer;
540 begin
541 e_WriteLog('Writing config', MSG_NOTIFY);
543 config := TConfig.CreateFile(FileName);
545 config.WriteInt('Video', 'ScreenWidth', gScreenWidth);
546 config.WriteInt('Video', 'ScreenHeight', gScreenHeight);
547 config.WriteInt('Video', 'WinPosX', gWinRealPosX);
548 config.WriteInt('Video', 'WinPosY', gWinRealPosY);
549 config.WriteBool('Video', 'Fullscreen', gFullScreen);
550 config.WriteBool('Video', 'Maximized', gWinMaximized);
551 config.WriteInt('Video', 'BPP', gBPP);
552 config.WriteBool('Video', 'VSync', gVSync);
553 config.WriteBool('Video', 'TextureFilter', gTextureFilter);
554 config.WriteBool('Video', 'LegacyCompatible', glLegacyNPOT);
556 config.WriteBool('Sound', 'NoSound', gNoSound);
557 config.WriteInt('Sound', 'SoundLevel', gSoundLevel);
558 config.WriteInt('Sound', 'MusicLevel', gMusicLevel);
559 config.WriteInt('Sound', 'MaxSimSounds', gMaxSimSounds);
560 config.WriteBool('Sound', 'MuteInactive', gMuteWhenInactive);
561 config.WriteInt('Sound', 'Announcer', gAnnouncer);
562 config.WriteBool('Sound', 'SoundEffectsDF', gSoundEffectsDF);
563 config.WriteInt('Sound', 'SDLSampleRate', gsSDLSampleRate);
564 config.WriteInt('Sound', 'SDLBufferSize', gsSDLBufferSize);
566 with config, gGameControls.GameControls do
567 begin
568 WriteInt('GameControls', 'TakeScreenshot', TakeScreenshot);
569 WriteInt('GameControls', 'Stat', Stat);
570 WriteInt('GameControls', 'Chat', Chat);
571 WriteInt('GameControls', 'TeamChat', TeamChat);
572 end;
574 with config, gGameControls.P1Control, gPlayer1Settings do
575 begin
576 WriteInt('Player1', 'KeyRight', KeyRight);
577 WriteInt('Player1', 'KeyLeft', KeyLeft);
578 WriteInt('Player1', 'KeyUp', KeyUp);
579 WriteInt('Player1', 'KeyDown', KeyDown);
580 WriteInt('Player1', 'KeyFire', KeyFire);
581 WriteInt('Player1', 'KeyJump', KeyJump);
582 WriteInt('Player1', 'KeyNextWeapon', KeyNextWeapon);
583 WriteInt('Player1', 'KeyPrevWeapon', KeyPrevWeapon);
584 WriteInt('Player1', 'KeyOpen', KeyOpen);
585 WriteInt('Player1', 'KeyStrafe', KeyStrafe);
586 for i := 0 to High(KeyWeapon) do
587 WriteInt('Player1', 'KeyWeapon' + IntToStr(i), KeyWeapon[i]);
589 WriteInt('Player1', 'KeyRight2', KeyRight2);
590 WriteInt('Player1', 'KeyLeft2', KeyLeft2);
591 WriteInt('Player1', 'KeyUp2', KeyUp2);
592 WriteInt('Player1', 'KeyDown2', KeyDown2);
593 WriteInt('Player1', 'KeyFire2', KeyFire2);
594 WriteInt('Player1', 'KeyJump2', KeyJump2);
595 WriteInt('Player1', 'KeyNextWeapon2', KeyNextWeapon2);
596 WriteInt('Player1', 'KeyPrevWeapon2', KeyPrevWeapon2);
597 WriteInt('Player1', 'KeyOpen2', KeyOpen2);
598 WriteInt('Player1', 'KeyStrafe2', KeyStrafe2);
599 for i := 0 to High(KeyWeapon2) do
600 WriteInt('Player1', 'KeyWeapon2' + IntToStr(i), KeyWeapon2[i]);
602 WriteStr('Player1', 'Name', Name);
603 WriteStr('Player1', 'model', Model);
604 WriteInt('Player1', 'red', Color.R);
605 WriteInt('Player1', 'green', Color.G);
606 WriteInt('Player1', 'blue', Color.B);
607 WriteInt('Player1', 'team', Team);
608 end;
610 with config, gGameControls.P2Control, gPlayer2Settings do
611 begin
612 WriteInt('Player2', 'KeyRight', KeyRight);
613 WriteInt('Player2', 'KeyLeft', KeyLeft);
614 WriteInt('Player2', 'KeyUp', KeyUp);
615 WriteInt('Player2', 'KeyDown', KeyDown);
616 WriteInt('Player2', 'KeyFire', KeyFire);
617 WriteInt('Player2', 'KeyJump', KeyJump);
618 WriteInt('Player2', 'KeyNextWeapon', KeyNextWeapon);
619 WriteInt('Player2', 'KeyPrevWeapon', KeyPrevWeapon);
620 WriteInt('Player2', 'KeyOpen', KeyOpen);
621 WriteInt('Player2', 'KeyStrafe', KeyStrafe);
622 for i := 0 to High(KeyWeapon) do
623 WriteInt('Player2', 'KeyWeapon' + IntToStr(i), KeyWeapon[i]);
625 WriteInt('Player2', 'KeyRight2', KeyRight2);
626 WriteInt('Player2', 'KeyLeft2', KeyLeft2);
627 WriteInt('Player2', 'KeyUp2', KeyUp2);
628 WriteInt('Player2', 'KeyDown2', KeyDown2);
629 WriteInt('Player2', 'KeyFire2', KeyFire2);
630 WriteInt('Player2', 'KeyJump2', KeyJump2);
631 WriteInt('Player2', 'KeyNextWeapon2', KeyNextWeapon2);
632 WriteInt('Player2', 'KeyPrevWeapon2', KeyPrevWeapon2);
633 WriteInt('Player2', 'KeyOpen2', KeyOpen2);
634 WriteInt('Player2', 'KeyStrafe2', KeyStrafe2);
635 for i := 0 to High(KeyWeapon2) do
636 WriteInt('Player2', 'KeyWeapon2' + IntToStr(i), KeyWeapon2[i]);
638 WriteStr('Player2', 'Name', Name);
639 WriteStr('Player2', 'model', Model);
640 WriteInt('Player2', 'red', Color.R);
641 WriteInt('Player2', 'green', Color.G);
642 WriteInt('Player2', 'blue', Color.B);
643 WriteInt('Player2', 'team', Team);
644 end;
646 for i := 0 to e_MaxJoys-1 do
647 config.WriteInt('Joysticks', 'Deadzone' + IntToStr(i), e_JoystickDeadzones[i]);
649 with config do
650 case gGibsCount of
651 0: config.WriteInt('Game', 'GibsCount', 0);
652 8: config.WriteInt('Game', 'GibsCount', 1);
653 16: config.WriteInt('Game', 'GibsCount', 2);
654 32: config.WriteInt('Game', 'GibsCount', 3);
655 else config.WriteInt('Game', 'GibsCount', 4);
656 end;
658 config.WriteInt('Game', 'ItemRespawnTime', ITEM_RESPAWNTIME div 36);
659 config.WriteInt('Game', 'MaxParticles', g_GFX_GetMax());
660 config.WriteInt('Game', 'MaxShells', g_Shells_GetMax());
661 config.WriteInt('Game', 'MaxGibs', g_Gibs_GetMax());
662 config.WriteInt('Game', 'MaxCorpses', g_Corpses_GetMax());
663 config.WriteInt('Game', 'BloodCount', gBloodCount);
664 config.WriteBool('Game', 'AdvancesBlood', gAdvBlood);
665 config.WriteBool('Game', 'AdvancesCorpses', gAdvCorpses);
666 config.WriteBool('Game', 'AdvancesGibs', gAdvGibs);
667 config.WriteInt('Game', 'Flash', gFlash);
668 config.WriteBool('Game', 'BackGround', gDrawBackGround);
669 config.WriteBool('Game', 'Messages', gShowMessages);
670 config.WriteBool('Game', 'RevertPlayers', gRevertPlayers);
671 config.WriteInt('Game', 'ChatBubble', gChatBubble);
672 config.WriteBool('Game', 'SFSDebug', gSFSDebug);
673 config.WriteBool('Game', 'SFSFastMode', gSFSFastMode);
674 config.WriteBool('Game', 'FastScreenshots', e_FastScreenshots);
675 config.WriteStr('Game', 'DefaultMegawadStart', gDefaultMegawadStart);
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', MSG_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', MSG_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', MSG_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', MSG_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', MSG_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', MSG_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.