DEADSOFTWARE

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