DEADSOFTWARE

added "SFSFastMode" hidden option; turned on by default
[d2df-sdl.git] / src / game / g_options.pas
1 unit g_options;
3 interface
5 uses
6 g_language;
8 type
9 TPlayerControl = record
10 KeyRight: Word;
11 KeyLeft: Word;
12 KeyUp: Word;
13 KeyDown: Word;
14 KeyFire: Word;
15 KeyJump: Word;
16 KeyNextWeapon: Word;
17 KeyPrevWeapon: Word;
18 KeyOpen: Word;
19 end;
21 TGameControls = record
22 TakeScreenshot: Word;
23 Stat: Word;
24 Chat: Word;
25 TeamChat: Word;
26 end;
28 TControls = record
29 GameControls: TGameControls;
30 P1Control: TPlayerControl;
31 P2Control: TPlayerControl;
32 end;
34 procedure g_Options_SetDefault();
35 procedure g_Options_Read(FileName: String);
36 procedure g_Options_Write(FileName: String);
37 procedure g_Options_Write_Language(FileName: String);
38 procedure g_Options_Write_Video(FileName: String);
39 procedure g_Options_Write_Gameplay_Custom(FileName: String);
40 procedure g_Options_Write_Gameplay_Net(FileName: String);
41 procedure g_Options_Write_Net_Server(FileName: String);
42 procedure g_Options_Write_Net_Client(FileName: String);
44 var
45 gGameControls: TControls;
46 gScreenWidth: Word = 800;
47 gScreenHeight: Word = 600;
48 gWinRealPosX: Integer = 0;
49 gWinRealPosY: Integer = 0;
50 gBPP: Byte = 32;
51 gFreq: Byte = 0;
52 gFullscreen: Boolean = False;
53 gWinMaximized: Boolean = False;
54 gVSync: Boolean = False;
55 glLegacyNPOT: Boolean = False;
56 gTextureFilter: Boolean = True;
57 gNoSound: Boolean = False;
58 gSoundLevel: Byte = 75;
59 gMusicLevel: Byte = 65;
60 gMaxSimSounds: Byte = 8;
61 gMuteWhenInactive: Boolean = False;
62 gAdvCorpses: Boolean = True;
63 gAdvBlood: Boolean = True;
64 gAdvGibs: Boolean = True;
65 gGibsCount: Integer = 32;
66 gBloodCount: Byte = 3;
67 gFlash: Byte = 1;
68 gDrawBackGround: Boolean = True;
69 gShowMessages: Boolean = True;
70 gRevertPlayers: Boolean = False;
71 gLanguage: String = LANGUAGE_ENGLISH;
72 gAskLanguage: Boolean = True;
73 gcMap: String = '';
74 gcGameMode: String = '';
75 gcTimeLimit: Word = 0;
76 gcGoalLimit: Word = 0;
77 gcMaxLives: Byte = 0;
78 gcPlayers: Byte = 1;
79 gcTeamDamage: Boolean = False;
80 gcAllowExit: Boolean = True;
81 gcWeaponStay: Boolean = False;
82 gcMonsters: Boolean = False;
83 gcBotsVS: String = 'Everybody';
84 gnMap: String = '';
85 gnGameMode: String = '';
86 gnTimeLimit: Word = 0;
87 gnGoalLimit: Word = 0;
88 gnMaxLives: Byte = 0;
89 gnPlayers: Byte = 1;
90 gnTeamDamage: Boolean = False;
91 gnAllowExit: Boolean = True;
92 gnWeaponStay: Boolean = False;
93 gnMonsters: Boolean = False;
94 gnBotsVS: String = 'Everybody';
95 gsSDLSampleRate: Integer = 44100;
96 gsSDLBufferSize: Integer = 2048;
97 gSFSDebug: Boolean = False;
98 gSFSFastMode: Boolean = True;
100 implementation
102 uses
103 e_log, e_input, g_window, g_sound, g_gfx, g_player, Math,
104 g_map, g_net, g_netmaster, SysUtils, CONFIG, g_game, g_main, e_textures,
105 g_items, GL, GLExt;
107 procedure g_Options_SetDefault();
108 var
109 i: Integer;
110 begin
111 g_Sound_SetupAllVolumes(75, 65);
112 gMaxSimSounds := 8;
113 gMuteWhenInactive := False;
114 gAnnouncer := ANNOUNCE_MEPLUS;
115 gSoundEffectsDF := True;
116 g_GFX_SetMax(2000);
117 g_Gibs_SetMax(150);
118 g_Corpses_SetMax(20);
119 g_Shells_SetMax(300);
120 gGibsCount := 32;
121 gBloodCount := 3;
122 gAdvBlood := True;
123 gAdvCorpses := True;
124 gAdvGibs := True;
125 gFlash := 1;
126 gDrawBackGround := True;
127 gShowMessages := True;
128 gRevertPlayers := False;
130 for i := 0 to e_MaxJoys-1 do
131 e_JoystickDeadzones[i] := 8192;
133 with gGameControls.GameControls do
134 begin
135 TakeScreenshot := 183;
136 Stat := 15;
137 Chat := 20; // [T]
138 TeamChat := 21; // [Y]
139 end;
141 with gGameControls.P1Control do
142 begin
143 KeyRight := 77;
144 KeyLeft := 75;
145 KeyUp := 72;
146 KeyDown := 76;
147 KeyFire := 184;
148 KeyJump := 157;
149 KeyNextWeapon := 73;
150 KeyPrevWeapon := 71;
151 KeyOpen := 54;
152 end;
154 with gGameControls.P2Control do
155 begin
156 KeyRight := 33;
157 KeyLeft := 31;
158 KeyUp := 18;
159 KeyDown := 32;
160 KeyFire := 30;
161 KeyJump := 16;
162 KeyNextWeapon := 19;
163 KeyPrevWeapon := 17;
164 KeyOpen := 58;
165 end;
167 with gPlayer1Settings do
168 begin
169 Name := 'Player1';
170 Model := STD_PLAYER_MODEL;
171 Color.R := PLAYER1_DEF_COLOR.R;
172 Color.G := PLAYER1_DEF_COLOR.G;
173 Color.B := PLAYER1_DEF_COLOR.B;
174 Team := TEAM_RED;
175 end;
177 with gPlayer2Settings do
178 begin
179 Name := 'Player2';
180 Model := STD_PLAYER_MODEL;
181 Color.R := PLAYER2_DEF_COLOR.R;
182 Color.G := PLAYER2_DEF_COLOR.G;
183 Color.B := PLAYER2_DEF_COLOR.B;
184 Team := TEAM_BLUE;
185 end;
187 NetUseMaster := True;
188 g_Net_Slist_Set('mpms.doom2d.org', 25665);
189 end;
191 procedure g_Options_Read(FileName: String);
192 var
193 config: TConfig;
194 str: String;
195 i: Integer;
196 begin
197 gAskLanguage := True;
198 e_WriteLog('Reading config', MSG_NOTIFY);
200 if not FileExists(FileName) then
201 begin
202 e_WriteLog('Config file '+FileName+' not found', MSG_WARNING);
203 g_Options_SetDefault();
205 // Default video options:
206 gScreenWidth := 800;
207 gScreenHeight := 600;
208 gWinRealPosX := 0;
209 gWinRealPosY := 0;
210 gWinMaximized := False;
211 gFullScreen := False;
212 gBPP := 32;
213 gVSync := False;
214 gTextureFilter := True;
215 glLegacyNPOT := False;
217 Exit;
218 end;
220 config := TConfig.CreateFile(FileName);
222 gScreenWidth := config.ReadInt('Video', 'ScreenWidth', 800);
223 if gScreenWidth < 640 then
224 gScreenWidth := 640;
225 gScreenHeight := config.ReadInt('Video', 'ScreenHeight', 600);
226 if gScreenHeight < 480 then
227 gScreenHeight := 480;
228 gWinRealPosX := config.ReadInt('Video', 'WinPosX', 0);
229 if gWinRealPosX < 0 then
230 gWinRealPosX := 0;
231 gWinRealPosY := config.ReadInt('Video', 'WinPosY', 0);
232 if gWinRealPosY < 0 then
233 gWinRealPosY := 0;
234 gFullScreen := config.ReadBool('Video', 'Fullscreen', False);
235 gWinMaximized := config.ReadBool('Video', 'Maximized', False);
236 gBPP := config.ReadInt('Video', 'BPP', 32);
237 gFreq := config.ReadInt('Video', 'Freq', 0);
238 gVSync := config.ReadBool('Video', 'VSync', True);
239 gTextureFilter := config.ReadBool('Video', 'TextureFilter', True);
240 glLegacyNPOT := config.ReadBool('Video', 'LegacyCompatible', False);
242 gNoSound := config.ReadBool('Sound', 'NoSound', False);
243 gSoundLevel := Min(config.ReadInt('Sound', 'SoundLevel', 75), 255);
244 gMusicLevel := Min(config.ReadInt('Sound', 'MusicLevel', 65), 255);
245 gMaxSimSounds := Max(Min(config.ReadInt('Sound', 'MaxSimSounds', 8), 66), 2);
246 gMuteWhenInactive := config.ReadBool('Sound', 'MuteInactive', False);
247 gAnnouncer := Min(Max(config.ReadInt('Sound', 'Announcer', ANNOUNCE_MEPLUS), ANNOUNCE_NONE), ANNOUNCE_ALL);
248 gSoundEffectsDF := config.ReadBool('Sound', 'SoundEffectsDF', True);
249 gsSDLSampleRate := Min(Max(config.ReadInt('Sound', 'SDLSampleRate', 44100), 11025), 96000);
250 gsSDLBufferSize := Min(Max(config.ReadInt('Sound', 'SDLBufferSize', 2048), 64), 16384);
252 with gGameControls.GameControls do
253 begin
254 TakeScreenshot := config.ReadInt('GameControls', 'TakeScreenshot', 183);
255 Stat := config.ReadInt('GameControls', 'Stat', 15);
256 Chat := config.ReadInt('GameControls', 'Chat', 20);
257 TeamChat := config.ReadInt('GameControls', 'TeamChat', 21);
258 end;
260 with gGameControls.P1Control, config do
261 begin
262 KeyRight := ReadInt('Player1', 'KeyRight', 33);
263 KeyLeft := ReadInt('Player1', 'KeyLeft', 31);
264 KeyUp := ReadInt('Player1', 'KeyUp', 18);
265 KeyDown := ReadInt('Player1', 'KeyDown', 32);
266 KeyFire := ReadInt('Player1', 'KeyFire', 30);
267 KeyJump := ReadInt('Player1', 'KeyJump', 16);
268 KeyNextWeapon := ReadInt('Player1', 'KeyNextWeapon', 19);
269 KeyPrevWeapon := ReadInt('Player1', 'KeyPrevWeapon', 17);
270 KeyOpen := ReadInt('Player1', 'KeyOpen', 58);
271 end;
273 with gPlayer1Settings, config do
274 begin
275 Name := ReadStr('Player1', 'name', 'Player1');
276 Model := ReadStr('Player1', 'model', STD_PLAYER_MODEL);
277 Color.R := Min(Abs(ReadInt('Player1', 'red', PLAYER1_DEF_COLOR.R)), 255);
278 Color.G := Min(Abs(ReadInt('Player1', 'green', PLAYER1_DEF_COLOR.G)), 255);
279 Color.B := Min(Abs(ReadInt('Player1', 'blue', PLAYER1_DEF_COLOR.B)), 255);
280 Team := ReadInt('Player1', 'team', TEAM_RED);
281 if (Team < TEAM_RED) or (Team > TEAM_BLUE) then
282 Team := TEAM_RED;
283 end;
285 with gGameControls.P2Control, config do
286 begin
287 KeyRight := ReadInt('Player2', 'KeyRight', 205);
288 KeyLeft := ReadInt('Player2', 'KeyLeft', 203);
289 KeyUp := ReadInt('Player2', 'KeyUp', 200);
290 KeyDown := ReadInt('Player2', 'KeyDown', 208);
291 KeyFire := ReadInt('Player2', 'KeyFire', 184);
292 KeyJump := ReadInt('Player2', 'KeyJump', 157);
293 KeyNextWeapon := ReadInt('Player2', 'KeyNextWeapon', 73);
294 KeyPrevWeapon := ReadInt('Player2', 'KeyPrevWeapon', 71);
295 KeyOpen := ReadInt('Player2', 'KeyOpen', 54);
296 end;
298 with gPlayer2Settings, config do
299 begin
300 Name := ReadStr('Player2', 'name', 'Player2');
301 Model := ReadStr('Player2', 'model', STD_PLAYER_MODEL);
302 Color.R := Min(Abs(ReadInt('Player2', 'red', PLAYER2_DEF_COLOR.R)), 255);
303 Color.G := Min(Abs(ReadInt('Player2', 'green', PLAYER2_DEF_COLOR.G)), 255);
304 Color.B := Min(Abs(ReadInt('Player2', 'blue', PLAYER2_DEF_COLOR.B)), 255);
305 Team := ReadInt('Player2', 'team', TEAM_BLUE);
306 if (Team < TEAM_RED) or (Team > TEAM_BLUE) then
307 Team := TEAM_RED;
308 end;
310 for i := 0 to e_MaxJoys-1 do
311 e_JoystickDeadzones[i] := config.ReadInt('Joysticks', 'Deadzone' + IntToStr(i), 8192);
313 g_GFX_SetMax(Min(config.ReadInt('Game', 'MaxParticles', 1000), 50000));
314 g_Shells_SetMax(Min(config.ReadInt('Game', 'MaxShells', 300), 600));
315 g_Gibs_SetMax(Min(config.ReadInt('Game', 'MaxGibs', 150), 500));
316 g_Corpses_SetMax(Min(config.ReadInt('Game', 'MaxCorpses', 20), 100));
318 case config.ReadInt('Game', 'GibsCount', 3) of
319 0: gGibsCount := 0;
320 1: gGibsCount := 8;
321 2: gGibsCount := 16;
322 3: gGibsCount := 32;
323 else gGibsCount := 48;
324 end;
326 ITEM_RESPAWNTIME := 36*Max(config.ReadInt('Game', 'ItemRespawnTime', 60), 0);
327 gBloodCount := Min(config.ReadInt('Game', 'BloodCount', 4), 4);
328 gAdvBlood := config.ReadBool('Game', 'AdvancesBlood', True);
329 gAdvCorpses := config.ReadBool('Game', 'AdvancesCorpses', True);
330 gAdvGibs := config.ReadBool('Game', 'AdvancesGibs', True);
331 gFlash := Min(Max(config.ReadInt('Game', 'Flash', 1), 0), 2);
332 gDrawBackGround := config.ReadBool('Game', 'BackGround', True);
333 gShowMessages := config.ReadBool('Game', 'Messages', True);
334 gRevertPlayers := config.ReadBool('Game', 'RevertPlayers', False);
335 gChatBubble := Min(Max(config.ReadInt('Game', 'ChatBubble', 4), 0), 4);
336 gSFSDebug := config.ReadBool('Game', 'SFSDebug', False);
337 gSFSFastMode := config.ReadBool('Game', 'SFSFastMode', True);
339 // Ãåéìïëåé â ñâîåé èãðå
340 gcMap := config.ReadStr('GameplayCustom', 'Map', '');
341 gcGameMode := config.ReadStr('GameplayCustom', 'GameMode', _lc[I_MENU_GAME_TYPE_DM]);
342 gcTimeLimit := Min(Max(config.ReadInt('GameplayCustom', 'TimeLimit', 0), 0), 65535);
343 gcGoalLimit := Min(Max(config.ReadInt('GameplayCustom', 'GoalLimit', 0), 0), 65535);
344 gcMaxLives := Min(Max(config.ReadInt('GameplayCustom', 'MaxLives', 0), 0), 255);
345 gcPlayers := Min(Max(config.ReadInt('GameplayCustom', 'Players', 1), 0), 2);
346 gcTeamDamage := config.ReadBool('GameplayCustom', 'TeamDamage', False);
347 gcAllowExit := config.ReadBool('GameplayCustom', 'AllowExit', True);
348 gcWeaponStay := config.ReadBool('GameplayCustom', 'WeaponStay', False);
349 gcMonsters := config.ReadBool('GameplayCustom', 'Monsters', False);
350 gcBotsVS := config.ReadStr('GameplayCustom', 'BotsVS', 'Everybody');
352 with gGameSettings do
353 begin
354 GameMode := g_Game_TextToMode(gcGameMode);
355 if GameMode = GM_NONE then
356 GameMode := GM_DM;
357 if GameMode = GM_SINGLE then
358 GameMode := GM_COOP;
359 TimeLimit := gcTimeLimit;
360 GoalLimit := gcGoalLimit;
361 MaxLives := gcMaxLives;
363 Options := 0;
364 if gcTeamDamage then
365 Options := Options or GAME_OPTION_TEAMDAMAGE;
366 if gcAllowExit then
367 Options := Options or GAME_OPTION_ALLOWEXIT;
368 if gcWeaponStay then
369 Options := Options or GAME_OPTION_WEAPONSTAY;
370 if gcMonsters then
371 Options := Options or GAME_OPTION_MONSTERS;
372 if gcBotsVS = 'Everybody' then
373 Options := Options or GAME_OPTION_BOTVSPLAYER or GAME_OPTION_BOTVSMONSTER;
374 if gcBotsVS = 'Players' then
375 Options := Options or GAME_OPTION_BOTVSPLAYER;
376 if gcBotsVS = 'Monsters' then
377 Options := Options or GAME_OPTION_BOTVSMONSTER;
378 end;
380 // Ãåéìïëåé â ñåòåâîé èãðå
381 gnMap := config.ReadStr('GameplayNetwork', 'Map', '');
382 gnGameMode := config.ReadStr('GameplayNetwork', 'GameMode', _lc[I_MENU_GAME_TYPE_DM]);
383 gnTimeLimit := Min(Max(config.ReadInt('GameplayNetwork', 'TimeLimit', 0), 0), 65535);
384 gnGoalLimit := Min(Max(config.ReadInt('GameplayNetwork', 'GoalLimit', 0), 0), 65535);
385 gnMaxLives := Min(Max(config.ReadInt('GameplayNetwork', 'MaxLives', 0), 0), 255);
386 gnPlayers := Min(Max(config.ReadInt('GameplayNetwork', 'Players', 1), 0), 2);
387 gnTeamDamage := config.ReadBool('GameplayNetwork', 'TeamDamage', False);
388 gnAllowExit := config.ReadBool('GameplayNetwork', 'AllowExit', True);
389 gnWeaponStay := config.ReadBool('GameplayNetwork', 'WeaponStay', False);
390 gnMonsters := config.ReadBool('GameplayNetwork', 'Monsters', False);
391 gnBotsVS := config.ReadStr('GameplayNetwork', 'BotsVS', 'Everybody');
393 // Îáùèå ñåòåâûå
394 NetSlistIP := config.ReadStr('MasterServer', 'IP', 'mpms.doom2d.org');
395 NetSlistPort := config.ReadInt('MasterServer', 'Port', 25665);
397 // Ñåðâåð
398 NetServerName := config.ReadStr('Server', 'Name', 'Unnamed Server');
399 NetPassword := config.ReadStr('Server', 'Password', '');
400 NetPort := Min(Max(0, config.ReadInt('Server', 'Port', 25666)), 65535);
401 NetMaxClients := Min(Max(0, config.ReadInt('Server', 'MaxClients', 16)), NET_MAXCLIENTS);
402 NetAllowRCON := config.ReadBool('Server', 'RCON', False);
403 NetRCONPassword := config.ReadStr('Server', 'RCONPassword', 'default');
404 NetUseMaster := config.ReadBool('Server', 'SyncWithMaster', True);
405 NetUpdateRate := Max(0, config.ReadInt('Server', 'UpdateInterval', 0));
406 NetRelupdRate := Max(0, config.ReadInt('Server', 'ReliableUpdateInterval', 18));
407 NetMasterRate := Max(1, config.ReadInt('Server', 'MasterSyncInterval', 60000));
409 // Êëèåíò
410 NetInterpLevel := Max(0, config.ReadInt('Client', 'InterpolationSteps', 2));
411 NetForcePlayerUpdate := config.ReadBool('Client', 'ForcePlayerUpdate', False);
412 NetPredictSelf := config.ReadBool('Client', 'PredictSelf', True);
413 NetClientIP := config.ReadStr('Client', 'LastIP', '127.0.0.1');
414 NetClientPort := Max(0, config.ReadInt('Client', 'LastPort', 25666));
416 // ßçûê:
417 str := config.ReadStr('Game', 'Language', '');
418 if (str = LANGUAGE_RUSSIAN) or
419 (str = LANGUAGE_ENGLISH) then
420 begin
421 gLanguage := str;
422 gAskLanguage := False;
423 end
424 else
425 gLanguage := LANGUAGE_ENGLISH;
427 config.Free();
429 if gTextureFilter then
430 TEXTUREFILTER := GL_LINEAR
431 else
432 TEXTUREFILTER := GL_NEAREST;
433 end;
435 procedure g_Options_Write(FileName: String);
436 var
437 config: TConfig;
438 i: Integer;
439 begin
440 e_WriteLog('Writing config', MSG_NOTIFY);
442 config := TConfig.CreateFile(FileName);
444 config.WriteInt('Video', 'ScreenWidth', gScreenWidth);
445 config.WriteInt('Video', 'ScreenHeight', gScreenHeight);
446 config.WriteInt('Video', 'WinPosX', gWinRealPosX);
447 config.WriteInt('Video', 'WinPosY', gWinRealPosY);
448 config.WriteBool('Video', 'Fullscreen', gFullScreen);
449 config.WriteBool('Video', 'Maximized', gWinMaximized);
450 config.WriteInt('Video', 'BPP', gBPP);
451 config.WriteBool('Video', 'VSync', gVSync);
452 config.WriteBool('Video', 'TextureFilter', gTextureFilter);
453 config.WriteBool('Video', 'LegacyCompatible', glLegacyNPOT);
455 config.WriteBool('Sound', 'NoSound', gNoSound);
456 config.WriteInt('Sound', 'SoundLevel', gSoundLevel);
457 config.WriteInt('Sound', 'MusicLevel', gMusicLevel);
458 config.WriteInt('Sound', 'MaxSimSounds', gMaxSimSounds);
459 config.WriteBool('Sound', 'MuteInactive', gMuteWhenInactive);
460 config.WriteInt('Sound', 'Announcer', gAnnouncer);
461 config.WriteBool('Sound', 'SoundEffectsDF', gSoundEffectsDF);
462 config.WriteInt('Sound', 'SDLSampleRate', gsSDLSampleRate);
463 config.WriteInt('Sound', 'SDLBufferSize', gsSDLBufferSize);
465 with config, gGameControls.GameControls do
466 begin
467 WriteInt('GameControls', 'TakeScreenshot', TakeScreenshot);
468 WriteInt('GameControls', 'Stat', Stat);
469 WriteInt('GameControls', 'Chat', Chat);
470 WriteInt('GameControls', 'TeamChat', TeamChat);
471 end;
473 with config, gGameControls.P1Control, gPlayer1Settings do
474 begin
475 WriteInt('Player1', 'KeyRight', KeyRight);
476 WriteInt('Player1', 'KeyLeft', KeyLeft);
477 WriteInt('Player1', 'KeyUp', KeyUp);
478 WriteInt('Player1', 'KeyDown', KeyDown);
479 WriteInt('Player1', 'KeyFire', KeyFire);
480 WriteInt('Player1', 'KeyJump', KeyJump);
481 WriteInt('Player1', 'KeyNextWeapon', KeyNextWeapon);
482 WriteInt('Player1', 'KeyPrevWeapon', KeyPrevWeapon);
483 WriteInt('Player1', 'KeyOpen', KeyOpen);
485 WriteStr('Player1', 'Name', Name);
486 WriteStr('Player1', 'model', Model);
487 WriteInt('Player1', 'red', Color.R);
488 WriteInt('Player1', 'green', Color.G);
489 WriteInt('Player1', 'blue', Color.B);
490 WriteInt('Player1', 'team', Team);
491 end;
493 with config, gGameControls.P2Control, gPlayer2Settings do
494 begin
495 WriteInt('Player2', 'KeyRight', KeyRight);
496 WriteInt('Player2', 'KeyLeft', KeyLeft);
497 WriteInt('Player2', 'KeyUp', KeyUp);
498 WriteInt('Player2', 'KeyDown', KeyDown);
499 WriteInt('Player2', 'KeyFire', KeyFire);
500 WriteInt('Player2', 'KeyJump', KeyJump);
501 WriteInt('Player2', 'KeyNextWeapon', KeyNextWeapon);
502 WriteInt('Player2', 'KeyPrevWeapon', KeyPrevWeapon);
503 WriteInt('Player2', 'KeyOpen', KeyOpen);
505 WriteStr('Player2', 'Name', Name);
506 WriteStr('Player2', 'model', Model);
507 WriteInt('Player2', 'red', Color.R);
508 WriteInt('Player2', 'green', Color.G);
509 WriteInt('Player2', 'blue', Color.B);
510 WriteInt('Player2', 'team', Team);
511 end;
513 for i := 0 to e_MaxJoys-1 do
514 config.WriteInt('Joysticks', 'Deadzone' + IntToStr(i), e_JoystickDeadzones[i]);
516 with config do
517 case gGibsCount of
518 0: config.WriteInt('Game', 'GibsCount', 0);
519 8: config.WriteInt('Game', 'GibsCount', 1);
520 16: config.WriteInt('Game', 'GibsCount', 2);
521 32: config.WriteInt('Game', 'GibsCount', 3);
522 else config.WriteInt('Game', 'GibsCount', 4);
523 end;
525 config.WriteInt('Game', 'ItemRespawnTime', ITEM_RESPAWNTIME div 36);
526 config.WriteInt('Game', 'MaxParticles', g_GFX_GetMax());
527 config.WriteInt('Game', 'MaxShells', g_Shells_GetMax());
528 config.WriteInt('Game', 'MaxGibs', g_Gibs_GetMax());
529 config.WriteInt('Game', 'MaxCorpses', g_Corpses_GetMax());
530 config.WriteInt('Game', 'BloodCount', gBloodCount);
531 config.WriteBool('Game', 'AdvancesBlood', gAdvBlood);
532 config.WriteBool('Game', 'AdvancesCorpses', gAdvCorpses);
533 config.WriteBool('Game', 'AdvancesGibs', gAdvGibs);
534 config.WriteInt('Game', 'Flash', gFlash);
535 config.WriteBool('Game', 'BackGround', gDrawBackGround);
536 config.WriteBool('Game', 'Messages', gShowMessages);
537 config.WriteBool('Game', 'RevertPlayers', gRevertPlayers);
538 config.WriteInt('Game', 'ChatBubble', gChatBubble);
539 config.WriteBool('Game', 'SFSDebug', gSFSDebug);
540 config.WriteBool('Game', 'SFSFastMode', gSFSFastMode);
542 config.WriteStr ('GameplayCustom', 'Map', gcMap);
543 config.WriteStr ('GameplayCustom', 'GameMode', gcGameMode);
544 config.WriteInt ('GameplayCustom', 'TimeLimit', gcTimeLimit);
545 config.WriteInt ('GameplayCustom', 'GoalLimit', gcGoalLimit);
546 config.WriteInt ('GameplayCustom', 'MaxLives', gcMaxLives);
547 config.WriteInt ('GameplayCustom', 'Players', gcPlayers);
548 config.WriteBool('GameplayCustom', 'TeamDamage', gcTeamDamage);
549 config.WriteBool('GameplayCustom', 'AllowExit', gcAllowExit);
550 config.WriteBool('GameplayCustom', 'WeaponStay', gcWeaponStay);
551 config.WriteBool('GameplayCustom', 'Monsters', gcMonsters);
552 config.WriteStr ('GameplayCustom', 'BotsVS', gcBotsVS);
554 config.WriteStr ('GameplayNetwork', 'Map', gnMap);
555 config.WriteStr ('GameplayNetwork', 'GameMode', gnGameMode);
556 config.WriteInt ('GameplayNetwork', 'TimeLimit', gnTimeLimit);
557 config.WriteInt ('GameplayNetwork', 'GoalLimit', gnGoalLimit);
558 config.WriteInt ('GameplayNetwork', 'MaxLives', gnMaxLives);
559 config.WriteInt ('GameplayNetwork', 'Players', gnPlayers);
560 config.WriteBool('GameplayNetwork', 'TeamDamage', gnTeamDamage);
561 config.WriteBool('GameplayNetwork', 'AllowExit', gnAllowExit);
562 config.WriteBool('GameplayNetwork', 'WeaponStay', gnWeaponStay);
563 config.WriteBool('GameplayNetwork', 'Monsters', gnMonsters);
564 config.WriteStr ('GameplayNetwork', 'BotsVS', gnBotsVS);
566 config.WriteStr('MasterServer', 'IP', NetSlistIP);
567 config.WriteInt('MasterServer', 'Port', NetSlistPort);
569 config.WriteStr ('Server', 'Name', NetServerName);
570 config.WriteStr ('Server', 'Password', NetPassword);
571 config.WriteInt ('Server', 'Port', NetPort);
572 config.WriteInt ('Server', 'MaxClients', NetMaxClients);
573 config.WriteBool('Server', 'RCON', NetAllowRCON);
574 config.WriteStr ('Server', 'RCONPassword', NetRCONPassword);
575 config.WriteBool('Server', 'SyncWithMaster', NetUseMaster);
576 config.WriteInt ('Server', 'UpdateInterval', NetUpdateRate);
577 config.WriteInt ('Server', 'ReliableUpdateInterval', NetRelupdRate);
578 config.WriteInt ('Server', 'MasterSyncInterval', NetMasterRate);
580 config.WriteInt ('Client', 'InterpolationSteps', NetInterpLevel);
581 config.WriteBool ('Client', 'ForcePlayerUpdate', NetForcePlayerUpdate);
582 config.WriteBool ('Client', 'PredictSelf', NetPredictSelf);
583 config.WriteStr ('Client', 'LastIP', NetClientIP);
584 config.WriteInt ('Client', 'LastPort', NetClientPort);
586 config.SaveFile(FileName);
587 config.Free();
588 end;
590 procedure g_Options_Write_Language(FileName: String);
591 var
592 config: TConfig;
593 begin
594 e_WriteLog('Writing language config', MSG_NOTIFY);
596 config := TConfig.CreateFile(FileName);
597 config.WriteStr('Game', 'Language', gLanguage);
598 config.SaveFile(FileName);
599 config.Free();
600 end;
602 procedure g_Options_Write_Video(FileName: String);
603 var
604 config: TConfig;
605 sW, sH: Integer;
606 begin
607 e_WriteLog('Writing resolution to config', MSG_NOTIFY);
609 config := TConfig.CreateFile(FileName);
611 if gWinMaximized and (not gFullscreen) then
612 begin
613 sW := gWinSizeX;
614 sH := gWinSizeY;
615 end
616 else
617 begin
618 sW := gScreenWidth;
619 sH := gScreenHeight;
620 end;
622 config.WriteInt('Video', 'ScreenWidth', sW);
623 config.WriteInt('Video', 'ScreenHeight', sH);
624 config.WriteInt('Video', 'WinPosX', gWinRealPosX);
625 config.WriteInt('Video', 'WinPosY', gWinRealPosY);
626 config.WriteBool('Video', 'Fullscreen', gFullscreen);
627 config.WriteBool('Video', 'Maximized', gWinMaximized);
629 config.SaveFile(FileName);
630 config.Free();
631 end;
633 procedure g_Options_Write_Gameplay_Custom(FileName: String);
634 var
635 config: TConfig;
636 begin
637 e_WriteLog('Writing custom gameplay config', MSG_NOTIFY);
639 config := TConfig.CreateFile(FileName);
641 config.WriteStr ('GameplayCustom', 'Map', gcMap);
642 config.WriteStr ('GameplayCustom', 'GameMode', gcGameMode);
643 config.WriteInt ('GameplayCustom', 'TimeLimit', gcTimeLimit);
644 config.WriteInt ('GameplayCustom', 'GoalLimit', gcGoalLimit);
645 config.WriteInt ('GameplayCustom', 'MaxLives', gcMaxLives);
646 config.WriteInt ('GameplayCustom', 'Players', gcPlayers);
647 config.WriteBool('GameplayCustom', 'TeamDamage', gcTeamDamage);
648 config.WriteBool('GameplayCustom', 'AllowExit', gcAllowExit);
649 config.WriteBool('GameplayCustom', 'WeaponStay', gcWeaponStay);
650 config.WriteBool('GameplayCustom', 'Monsters', gcMonsters);
651 config.WriteStr ('GameplayCustom', 'BotsVS', gcBotsVS);
653 config.SaveFile(FileName);
654 config.Free();
655 end;
657 procedure g_Options_Write_Gameplay_Net(FileName: String);
658 var
659 config: TConfig;
660 begin
661 e_WriteLog('Writing network gameplay config', MSG_NOTIFY);
663 config := TConfig.CreateFile(FileName);
665 config.WriteStr ('GameplayNetwork', 'Map', gnMap);
666 config.WriteStr ('GameplayNetwork', 'GameMode', gnGameMode);
667 config.WriteInt ('GameplayNetwork', 'TimeLimit', gnTimeLimit);
668 config.WriteInt ('GameplayNetwork', 'GoalLimit', gnGoalLimit);
669 config.WriteInt ('GameplayNetwork', 'MaxLives', gnMaxLives);
670 config.WriteInt ('GameplayNetwork', 'Players', gnPlayers);
671 config.WriteBool('GameplayNetwork', 'TeamDamage', gnTeamDamage);
672 config.WriteBool('GameplayNetwork', 'AllowExit', gnAllowExit);
673 config.WriteBool('GameplayNetwork', 'WeaponStay', gnWeaponStay);
674 config.WriteBool('GameplayNetwork', 'Monsters', gnMonsters);
675 config.WriteStr ('GameplayNetwork', 'BotsVS', gnBotsVS);
677 config.SaveFile(FileName);
678 config.Free();
679 end;
681 procedure g_Options_Write_Net_Server(FileName: String);
682 var
683 config: TConfig;
684 begin
685 e_WriteLog('Writing server config', MSG_NOTIFY);
687 config := TConfig.CreateFile(FileName);
689 config.WriteStr ('Server', 'Name', NetServerName);
690 config.WriteStr ('Server', 'Password', NetPassword);
691 config.WriteInt ('Server', 'Port', NetPort);
692 config.WriteInt ('Server', 'MaxClients', NetMaxClients);
693 config.WriteBool('Server', 'SyncWithMaster', NetUseMaster);
695 config.SaveFile(FileName);
696 config.Free();
697 end;
699 procedure g_Options_Write_Net_Client(FileName: String);
700 var
701 config: TConfig;
702 begin
703 e_WriteLog('Writing client config', MSG_NOTIFY);
705 config := TConfig.CreateFile(FileName);
707 config.WriteStr('Client', 'LastIP', NetClientIP);
708 config.WriteInt('Client', 'LastPort', NetClientPort);
710 config.SaveFile(FileName);
711 config.Free();
712 end;
714 end.