DEADSOFTWARE

sfs: remove common dir from pk3 (this should fix invalid zips)
[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;
99 implementation
101 uses
102 e_log, e_input, g_window, g_sound, g_gfx, g_player, Math,
103 g_map, g_net, g_netmaster, SysUtils, CONFIG, g_game, g_main, e_textures,
104 g_items, GL, GLExt;
106 procedure g_Options_SetDefault();
107 var
108 i: Integer;
109 begin
110 g_Sound_SetupAllVolumes(75, 65);
111 gMaxSimSounds := 8;
112 gMuteWhenInactive := False;
113 gAnnouncer := ANNOUNCE_MEPLUS;
114 gSoundEffectsDF := True;
115 g_GFX_SetMax(2000);
116 g_Gibs_SetMax(150);
117 g_Corpses_SetMax(20);
118 g_Shells_SetMax(300);
119 gGibsCount := 32;
120 gBloodCount := 3;
121 gAdvBlood := True;
122 gAdvCorpses := True;
123 gAdvGibs := True;
124 gFlash := 1;
125 gDrawBackGround := True;
126 gShowMessages := True;
127 gRevertPlayers := False;
129 for i := 0 to e_MaxJoys-1 do
130 e_JoystickDeadzones[i] := 8192;
132 with gGameControls.GameControls do
133 begin
134 TakeScreenshot := 183;
135 Stat := 15;
136 Chat := 20; // [T]
137 TeamChat := 21; // [Y]
138 end;
140 with gGameControls.P1Control do
141 begin
142 KeyRight := 77;
143 KeyLeft := 75;
144 KeyUp := 72;
145 KeyDown := 76;
146 KeyFire := 184;
147 KeyJump := 157;
148 KeyNextWeapon := 73;
149 KeyPrevWeapon := 71;
150 KeyOpen := 54;
151 end;
153 with gGameControls.P2Control do
154 begin
155 KeyRight := 33;
156 KeyLeft := 31;
157 KeyUp := 18;
158 KeyDown := 32;
159 KeyFire := 30;
160 KeyJump := 16;
161 KeyNextWeapon := 19;
162 KeyPrevWeapon := 17;
163 KeyOpen := 58;
164 end;
166 with gPlayer1Settings do
167 begin
168 Name := 'Player1';
169 Model := STD_PLAYER_MODEL;
170 Color.R := PLAYER1_DEF_COLOR.R;
171 Color.G := PLAYER1_DEF_COLOR.G;
172 Color.B := PLAYER1_DEF_COLOR.B;
173 Team := TEAM_RED;
174 end;
176 with gPlayer2Settings do
177 begin
178 Name := 'Player2';
179 Model := STD_PLAYER_MODEL;
180 Color.R := PLAYER2_DEF_COLOR.R;
181 Color.G := PLAYER2_DEF_COLOR.G;
182 Color.B := PLAYER2_DEF_COLOR.B;
183 Team := TEAM_BLUE;
184 end;
186 NetUseMaster := True;
187 g_Net_Slist_Set('mpms.doom2d.org', 25665);
188 end;
190 procedure g_Options_Read(FileName: String);
191 var
192 config: TConfig;
193 str: String;
194 i: Integer;
195 begin
196 gAskLanguage := True;
197 e_WriteLog('Reading config', MSG_NOTIFY);
199 if not FileExists(FileName) then
200 begin
201 e_WriteLog('Config file '+FileName+' not found', MSG_WARNING);
202 g_Options_SetDefault();
204 // Default video options:
205 gScreenWidth := 800;
206 gScreenHeight := 600;
207 gWinRealPosX := 0;
208 gWinRealPosY := 0;
209 gWinMaximized := False;
210 gFullScreen := False;
211 gBPP := 32;
212 gVSync := False;
213 gTextureFilter := True;
214 glLegacyNPOT := False;
216 Exit;
217 end;
219 config := TConfig.CreateFile(FileName);
221 gScreenWidth := config.ReadInt('Video', 'ScreenWidth', 800);
222 if gScreenWidth < 640 then
223 gScreenWidth := 640;
224 gScreenHeight := config.ReadInt('Video', 'ScreenHeight', 600);
225 if gScreenHeight < 480 then
226 gScreenHeight := 480;
227 gWinRealPosX := config.ReadInt('Video', 'WinPosX', 0);
228 if gWinRealPosX < 0 then
229 gWinRealPosX := 0;
230 gWinRealPosY := config.ReadInt('Video', 'WinPosY', 0);
231 if gWinRealPosY < 0 then
232 gWinRealPosY := 0;
233 gFullScreen := config.ReadBool('Video', 'Fullscreen', False);
234 gWinMaximized := config.ReadBool('Video', 'Maximized', False);
235 gBPP := config.ReadInt('Video', 'BPP', 32);
236 gFreq := config.ReadInt('Video', 'Freq', 0);
237 gVSync := config.ReadBool('Video', 'VSync', True);
238 gTextureFilter := config.ReadBool('Video', 'TextureFilter', True);
239 glLegacyNPOT := config.ReadBool('Video', 'LegacyCompatible', False);
241 gNoSound := config.ReadBool('Sound', 'NoSound', False);
242 gSoundLevel := Min(config.ReadInt('Sound', 'SoundLevel', 75), 255);
243 gMusicLevel := Min(config.ReadInt('Sound', 'MusicLevel', 65), 255);
244 gMaxSimSounds := Max(Min(config.ReadInt('Sound', 'MaxSimSounds', 8), 66), 2);
245 gMuteWhenInactive := config.ReadBool('Sound', 'MuteInactive', False);
246 gAnnouncer := Min(Max(config.ReadInt('Sound', 'Announcer', ANNOUNCE_MEPLUS), ANNOUNCE_NONE), ANNOUNCE_ALL);
247 gSoundEffectsDF := config.ReadBool('Sound', 'SoundEffectsDF', True);
248 gsSDLSampleRate := Min(Max(config.ReadInt('Sound', 'SDLSampleRate', 44100), 11025), 96000);
249 gsSDLBufferSize := Min(Max(config.ReadInt('Sound', 'SDLBufferSize', 2048), 64), 16384);
251 with gGameControls.GameControls do
252 begin
253 TakeScreenshot := config.ReadInt('GameControls', 'TakeScreenshot', 183);
254 Stat := config.ReadInt('GameControls', 'Stat', 15);
255 Chat := config.ReadInt('GameControls', 'Chat', 20);
256 TeamChat := config.ReadInt('GameControls', 'TeamChat', 21);
257 end;
259 with gGameControls.P1Control, config do
260 begin
261 KeyRight := ReadInt('Player1', 'KeyRight', 33);
262 KeyLeft := ReadInt('Player1', 'KeyLeft', 31);
263 KeyUp := ReadInt('Player1', 'KeyUp', 18);
264 KeyDown := ReadInt('Player1', 'KeyDown', 32);
265 KeyFire := ReadInt('Player1', 'KeyFire', 30);
266 KeyJump := ReadInt('Player1', 'KeyJump', 16);
267 KeyNextWeapon := ReadInt('Player1', 'KeyNextWeapon', 19);
268 KeyPrevWeapon := ReadInt('Player1', 'KeyPrevWeapon', 17);
269 KeyOpen := ReadInt('Player1', 'KeyOpen', 58);
270 end;
272 with gPlayer1Settings, config do
273 begin
274 Name := ReadStr('Player1', 'name', 'Player1');
275 Model := ReadStr('Player1', 'model', STD_PLAYER_MODEL);
276 Color.R := Min(Abs(ReadInt('Player1', 'red', PLAYER1_DEF_COLOR.R)), 255);
277 Color.G := Min(Abs(ReadInt('Player1', 'green', PLAYER1_DEF_COLOR.G)), 255);
278 Color.B := Min(Abs(ReadInt('Player1', 'blue', PLAYER1_DEF_COLOR.B)), 255);
279 Team := ReadInt('Player1', 'team', TEAM_RED);
280 if (Team < TEAM_RED) or (Team > TEAM_BLUE) then
281 Team := TEAM_RED;
282 end;
284 with gGameControls.P2Control, config do
285 begin
286 KeyRight := ReadInt('Player2', 'KeyRight', 205);
287 KeyLeft := ReadInt('Player2', 'KeyLeft', 203);
288 KeyUp := ReadInt('Player2', 'KeyUp', 200);
289 KeyDown := ReadInt('Player2', 'KeyDown', 208);
290 KeyFire := ReadInt('Player2', 'KeyFire', 184);
291 KeyJump := ReadInt('Player2', 'KeyJump', 157);
292 KeyNextWeapon := ReadInt('Player2', 'KeyNextWeapon', 73);
293 KeyPrevWeapon := ReadInt('Player2', 'KeyPrevWeapon', 71);
294 KeyOpen := ReadInt('Player2', 'KeyOpen', 54);
295 end;
297 with gPlayer2Settings, config do
298 begin
299 Name := ReadStr('Player2', 'name', 'Player2');
300 Model := ReadStr('Player2', 'model', STD_PLAYER_MODEL);
301 Color.R := Min(Abs(ReadInt('Player2', 'red', PLAYER2_DEF_COLOR.R)), 255);
302 Color.G := Min(Abs(ReadInt('Player2', 'green', PLAYER2_DEF_COLOR.G)), 255);
303 Color.B := Min(Abs(ReadInt('Player2', 'blue', PLAYER2_DEF_COLOR.B)), 255);
304 Team := ReadInt('Player2', 'team', TEAM_BLUE);
305 if (Team < TEAM_RED) or (Team > TEAM_BLUE) then
306 Team := TEAM_RED;
307 end;
309 for i := 0 to e_MaxJoys-1 do
310 e_JoystickDeadzones[i] := config.ReadInt('Joysticks', 'Deadzone' + IntToStr(i), 8192);
312 g_GFX_SetMax(Min(config.ReadInt('Game', 'MaxParticles', 1000), 50000));
313 g_Shells_SetMax(Min(config.ReadInt('Game', 'MaxShells', 300), 600));
314 g_Gibs_SetMax(Min(config.ReadInt('Game', 'MaxGibs', 150), 500));
315 g_Corpses_SetMax(Min(config.ReadInt('Game', 'MaxCorpses', 20), 100));
317 case config.ReadInt('Game', 'GibsCount', 3) of
318 0: gGibsCount := 0;
319 1: gGibsCount := 8;
320 2: gGibsCount := 16;
321 3: gGibsCount := 32;
322 else gGibsCount := 48;
323 end;
325 ITEM_RESPAWNTIME := 36*Max(config.ReadInt('Game', 'ItemRespawnTime', 60), 0);
326 gBloodCount := Min(config.ReadInt('Game', 'BloodCount', 4), 4);
327 gAdvBlood := config.ReadBool('Game', 'AdvancesBlood', True);
328 gAdvCorpses := config.ReadBool('Game', 'AdvancesCorpses', True);
329 gAdvGibs := config.ReadBool('Game', 'AdvancesGibs', True);
330 gFlash := Min(Max(config.ReadInt('Game', 'Flash', 1), 0), 2);
331 gDrawBackGround := config.ReadBool('Game', 'BackGround', True);
332 gShowMessages := config.ReadBool('Game', 'Messages', True);
333 gRevertPlayers := config.ReadBool('Game', 'RevertPlayers', False);
334 gChatBubble := Min(Max(config.ReadInt('Game', 'ChatBubble', 4), 0), 4);
335 gSFSDebug := config.ReadBool('Game', 'gSFSDebug', False);
337 // Ãåéìïëåé â ñâîåé èãðå
338 gcMap := config.ReadStr('GameplayCustom', 'Map', '');
339 gcGameMode := config.ReadStr('GameplayCustom', 'GameMode', _lc[I_MENU_GAME_TYPE_DM]);
340 gcTimeLimit := Min(Max(config.ReadInt('GameplayCustom', 'TimeLimit', 0), 0), 65535);
341 gcGoalLimit := Min(Max(config.ReadInt('GameplayCustom', 'GoalLimit', 0), 0), 65535);
342 gcMaxLives := Min(Max(config.ReadInt('GameplayCustom', 'MaxLives', 0), 0), 255);
343 gcPlayers := Min(Max(config.ReadInt('GameplayCustom', 'Players', 1), 0), 2);
344 gcTeamDamage := config.ReadBool('GameplayCustom', 'TeamDamage', False);
345 gcAllowExit := config.ReadBool('GameplayCustom', 'AllowExit', True);
346 gcWeaponStay := config.ReadBool('GameplayCustom', 'WeaponStay', False);
347 gcMonsters := config.ReadBool('GameplayCustom', 'Monsters', False);
348 gcBotsVS := config.ReadStr('GameplayCustom', 'BotsVS', 'Everybody');
350 with gGameSettings do
351 begin
352 GameMode := g_Game_TextToMode(gcGameMode);
353 if GameMode = GM_NONE then
354 GameMode := GM_DM;
355 if GameMode = GM_SINGLE then
356 GameMode := GM_COOP;
357 TimeLimit := gcTimeLimit;
358 GoalLimit := gcGoalLimit;
359 MaxLives := gcMaxLives;
361 Options := 0;
362 if gcTeamDamage then
363 Options := Options or GAME_OPTION_TEAMDAMAGE;
364 if gcAllowExit then
365 Options := Options or GAME_OPTION_ALLOWEXIT;
366 if gcWeaponStay then
367 Options := Options or GAME_OPTION_WEAPONSTAY;
368 if gcMonsters then
369 Options := Options or GAME_OPTION_MONSTERS;
370 if gcBotsVS = 'Everybody' then
371 Options := Options or GAME_OPTION_BOTVSPLAYER or GAME_OPTION_BOTVSMONSTER;
372 if gcBotsVS = 'Players' then
373 Options := Options or GAME_OPTION_BOTVSPLAYER;
374 if gcBotsVS = 'Monsters' then
375 Options := Options or GAME_OPTION_BOTVSMONSTER;
376 end;
378 // Ãåéìïëåé â ñåòåâîé èãðå
379 gnMap := config.ReadStr('GameplayNetwork', 'Map', '');
380 gnGameMode := config.ReadStr('GameplayNetwork', 'GameMode', _lc[I_MENU_GAME_TYPE_DM]);
381 gnTimeLimit := Min(Max(config.ReadInt('GameplayNetwork', 'TimeLimit', 0), 0), 65535);
382 gnGoalLimit := Min(Max(config.ReadInt('GameplayNetwork', 'GoalLimit', 0), 0), 65535);
383 gnMaxLives := Min(Max(config.ReadInt('GameplayNetwork', 'MaxLives', 0), 0), 255);
384 gnPlayers := Min(Max(config.ReadInt('GameplayNetwork', 'Players', 1), 0), 2);
385 gnTeamDamage := config.ReadBool('GameplayNetwork', 'TeamDamage', False);
386 gnAllowExit := config.ReadBool('GameplayNetwork', 'AllowExit', True);
387 gnWeaponStay := config.ReadBool('GameplayNetwork', 'WeaponStay', False);
388 gnMonsters := config.ReadBool('GameplayNetwork', 'Monsters', False);
389 gnBotsVS := config.ReadStr('GameplayNetwork', 'BotsVS', 'Everybody');
391 // Îáùèå ñåòåâûå
392 NetSlistIP := config.ReadStr('MasterServer', 'IP', 'mpms.doom2d.org');
393 NetSlistPort := config.ReadInt('MasterServer', 'Port', 25665);
395 // Ñåðâåð
396 NetServerName := config.ReadStr('Server', 'Name', 'Unnamed Server');
397 NetPassword := config.ReadStr('Server', 'Password', '');
398 NetPort := Min(Max(0, config.ReadInt('Server', 'Port', 25666)), 65535);
399 NetMaxClients := Min(Max(0, config.ReadInt('Server', 'MaxClients', 16)), NET_MAXCLIENTS);
400 NetAllowRCON := config.ReadBool('Server', 'RCON', False);
401 NetRCONPassword := config.ReadStr('Server', 'RCONPassword', 'default');
402 NetUseMaster := config.ReadBool('Server', 'SyncWithMaster', True);
403 NetUpdateRate := Max(0, config.ReadInt('Server', 'UpdateInterval', 0));
404 NetRelupdRate := Max(0, config.ReadInt('Server', 'ReliableUpdateInterval', 18));
405 NetMasterRate := Max(1, config.ReadInt('Server', 'MasterSyncInterval', 60000));
407 // Êëèåíò
408 NetInterpLevel := Max(0, config.ReadInt('Client', 'InterpolationSteps', 2));
409 NetForcePlayerUpdate := config.ReadBool('Client', 'ForcePlayerUpdate', False);
410 NetPredictSelf := config.ReadBool('Client', 'PredictSelf', True);
411 NetClientIP := config.ReadStr('Client', 'LastIP', '127.0.0.1');
412 NetClientPort := Max(0, config.ReadInt('Client', 'LastPort', 25666));
414 // ßçûê:
415 str := config.ReadStr('Game', 'Language', '');
416 if (str = LANGUAGE_RUSSIAN) or
417 (str = LANGUAGE_ENGLISH) then
418 begin
419 gLanguage := str;
420 gAskLanguage := False;
421 end
422 else
423 gLanguage := LANGUAGE_ENGLISH;
425 config.Free();
427 if gTextureFilter then
428 TEXTUREFILTER := GL_LINEAR
429 else
430 TEXTUREFILTER := GL_NEAREST;
431 end;
433 procedure g_Options_Write(FileName: String);
434 var
435 config: TConfig;
436 i: Integer;
437 begin
438 e_WriteLog('Writing config', MSG_NOTIFY);
440 config := TConfig.CreateFile(FileName);
442 config.WriteInt('Video', 'ScreenWidth', gScreenWidth);
443 config.WriteInt('Video', 'ScreenHeight', gScreenHeight);
444 config.WriteInt('Video', 'WinPosX', gWinRealPosX);
445 config.WriteInt('Video', 'WinPosY', gWinRealPosY);
446 config.WriteBool('Video', 'Fullscreen', gFullScreen);
447 config.WriteBool('Video', 'Maximized', gWinMaximized);
448 config.WriteInt('Video', 'BPP', gBPP);
449 config.WriteBool('Video', 'VSync', gVSync);
450 config.WriteBool('Video', 'TextureFilter', gTextureFilter);
451 config.WriteBool('Video', 'LegacyCompatible', glLegacyNPOT);
453 config.WriteBool('Sound', 'NoSound', gNoSound);
454 config.WriteInt('Sound', 'SoundLevel', gSoundLevel);
455 config.WriteInt('Sound', 'MusicLevel', gMusicLevel);
456 config.WriteInt('Sound', 'MaxSimSounds', gMaxSimSounds);
457 config.WriteBool('Sound', 'MuteInactive', gMuteWhenInactive);
458 config.WriteInt('Sound', 'Announcer', gAnnouncer);
459 config.WriteBool('Sound', 'SoundEffectsDF', gSoundEffectsDF);
460 config.WriteInt('Sound', 'SDLSampleRate', gsSDLSampleRate);
461 config.WriteInt('Sound', 'SDLBufferSize', gsSDLBufferSize);
463 with config, gGameControls.GameControls do
464 begin
465 WriteInt('GameControls', 'TakeScreenshot', TakeScreenshot);
466 WriteInt('GameControls', 'Stat', Stat);
467 WriteInt('GameControls', 'Chat', Chat);
468 WriteInt('GameControls', 'TeamChat', TeamChat);
469 end;
471 with config, gGameControls.P1Control, gPlayer1Settings do
472 begin
473 WriteInt('Player1', 'KeyRight', KeyRight);
474 WriteInt('Player1', 'KeyLeft', KeyLeft);
475 WriteInt('Player1', 'KeyUp', KeyUp);
476 WriteInt('Player1', 'KeyDown', KeyDown);
477 WriteInt('Player1', 'KeyFire', KeyFire);
478 WriteInt('Player1', 'KeyJump', KeyJump);
479 WriteInt('Player1', 'KeyNextWeapon', KeyNextWeapon);
480 WriteInt('Player1', 'KeyPrevWeapon', KeyPrevWeapon);
481 WriteInt('Player1', 'KeyOpen', KeyOpen);
483 WriteStr('Player1', 'Name', Name);
484 WriteStr('Player1', 'model', Model);
485 WriteInt('Player1', 'red', Color.R);
486 WriteInt('Player1', 'green', Color.G);
487 WriteInt('Player1', 'blue', Color.B);
488 WriteInt('Player1', 'team', Team);
489 end;
491 with config, gGameControls.P2Control, gPlayer2Settings do
492 begin
493 WriteInt('Player2', 'KeyRight', KeyRight);
494 WriteInt('Player2', 'KeyLeft', KeyLeft);
495 WriteInt('Player2', 'KeyUp', KeyUp);
496 WriteInt('Player2', 'KeyDown', KeyDown);
497 WriteInt('Player2', 'KeyFire', KeyFire);
498 WriteInt('Player2', 'KeyJump', KeyJump);
499 WriteInt('Player2', 'KeyNextWeapon', KeyNextWeapon);
500 WriteInt('Player2', 'KeyPrevWeapon', KeyPrevWeapon);
501 WriteInt('Player2', 'KeyOpen', KeyOpen);
503 WriteStr('Player2', 'Name', Name);
504 WriteStr('Player2', 'model', Model);
505 WriteInt('Player2', 'red', Color.R);
506 WriteInt('Player2', 'green', Color.G);
507 WriteInt('Player2', 'blue', Color.B);
508 WriteInt('Player2', 'team', Team);
509 end;
511 for i := 0 to e_MaxJoys-1 do
512 config.WriteInt('Joysticks', 'Deadzone' + IntToStr(i), e_JoystickDeadzones[i]);
514 with config do
515 case gGibsCount of
516 0: config.WriteInt('Game', 'GibsCount', 0);
517 8: config.WriteInt('Game', 'GibsCount', 1);
518 16: config.WriteInt('Game', 'GibsCount', 2);
519 32: config.WriteInt('Game', 'GibsCount', 3);
520 else config.WriteInt('Game', 'GibsCount', 4);
521 end;
523 config.WriteInt('Game', 'ItemRespawnTime', ITEM_RESPAWNTIME div 36);
524 config.WriteInt('Game', 'MaxParticles', g_GFX_GetMax());
525 config.WriteInt('Game', 'MaxShells', g_Shells_GetMax());
526 config.WriteInt('Game', 'MaxGibs', g_Gibs_GetMax());
527 config.WriteInt('Game', 'MaxCorpses', g_Corpses_GetMax());
528 config.WriteInt('Game', 'BloodCount', gBloodCount);
529 config.WriteBool('Game', 'AdvancesBlood', gAdvBlood);
530 config.WriteBool('Game', 'AdvancesCorpses', gAdvCorpses);
531 config.WriteBool('Game', 'AdvancesGibs', gAdvGibs);
532 config.WriteInt('Game', 'Flash', gFlash);
533 config.WriteBool('Game', 'BackGround', gDrawBackGround);
534 config.WriteBool('Game', 'Messages', gShowMessages);
535 config.WriteBool('Game', 'RevertPlayers', gRevertPlayers);
536 config.WriteInt('Game', 'ChatBubble', gChatBubble);
537 config.WriteBool('Game', 'SFSDebug', gSFSDebug);
539 config.WriteStr ('GameplayCustom', 'Map', gcMap);
540 config.WriteStr ('GameplayCustom', 'GameMode', gcGameMode);
541 config.WriteInt ('GameplayCustom', 'TimeLimit', gcTimeLimit);
542 config.WriteInt ('GameplayCustom', 'GoalLimit', gcGoalLimit);
543 config.WriteInt ('GameplayCustom', 'MaxLives', gcMaxLives);
544 config.WriteInt ('GameplayCustom', 'Players', gcPlayers);
545 config.WriteBool('GameplayCustom', 'TeamDamage', gcTeamDamage);
546 config.WriteBool('GameplayCustom', 'AllowExit', gcAllowExit);
547 config.WriteBool('GameplayCustom', 'WeaponStay', gcWeaponStay);
548 config.WriteBool('GameplayCustom', 'Monsters', gcMonsters);
549 config.WriteStr ('GameplayCustom', 'BotsVS', gcBotsVS);
551 config.WriteStr ('GameplayNetwork', 'Map', gnMap);
552 config.WriteStr ('GameplayNetwork', 'GameMode', gnGameMode);
553 config.WriteInt ('GameplayNetwork', 'TimeLimit', gnTimeLimit);
554 config.WriteInt ('GameplayNetwork', 'GoalLimit', gnGoalLimit);
555 config.WriteInt ('GameplayNetwork', 'MaxLives', gnMaxLives);
556 config.WriteInt ('GameplayNetwork', 'Players', gnPlayers);
557 config.WriteBool('GameplayNetwork', 'TeamDamage', gnTeamDamage);
558 config.WriteBool('GameplayNetwork', 'AllowExit', gnAllowExit);
559 config.WriteBool('GameplayNetwork', 'WeaponStay', gnWeaponStay);
560 config.WriteBool('GameplayNetwork', 'Monsters', gnMonsters);
561 config.WriteStr ('GameplayNetwork', 'BotsVS', gnBotsVS);
563 config.WriteStr('MasterServer', 'IP', NetSlistIP);
564 config.WriteInt('MasterServer', 'Port', NetSlistPort);
566 config.WriteStr ('Server', 'Name', NetServerName);
567 config.WriteStr ('Server', 'Password', NetPassword);
568 config.WriteInt ('Server', 'Port', NetPort);
569 config.WriteInt ('Server', 'MaxClients', NetMaxClients);
570 config.WriteBool('Server', 'RCON', NetAllowRCON);
571 config.WriteStr ('Server', 'RCONPassword', NetRCONPassword);
572 config.WriteBool('Server', 'SyncWithMaster', NetUseMaster);
573 config.WriteInt ('Server', 'UpdateInterval', NetUpdateRate);
574 config.WriteInt ('Server', 'ReliableUpdateInterval', NetRelupdRate);
575 config.WriteInt ('Server', 'MasterSyncInterval', NetMasterRate);
577 config.WriteInt ('Client', 'InterpolationSteps', NetInterpLevel);
578 config.WriteBool ('Client', 'ForcePlayerUpdate', NetForcePlayerUpdate);
579 config.WriteBool ('Client', 'PredictSelf', NetPredictSelf);
580 config.WriteStr ('Client', 'LastIP', NetClientIP);
581 config.WriteInt ('Client', 'LastPort', NetClientPort);
583 config.SaveFile(FileName);
584 config.Free();
585 end;
587 procedure g_Options_Write_Language(FileName: String);
588 var
589 config: TConfig;
590 begin
591 e_WriteLog('Writing language config', MSG_NOTIFY);
593 config := TConfig.CreateFile(FileName);
594 config.WriteStr('Game', 'Language', gLanguage);
595 config.SaveFile(FileName);
596 config.Free();
597 end;
599 procedure g_Options_Write_Video(FileName: String);
600 var
601 config: TConfig;
602 sW, sH: Integer;
603 begin
604 e_WriteLog('Writing resolution to config', MSG_NOTIFY);
606 config := TConfig.CreateFile(FileName);
608 if gWinMaximized and (not gFullscreen) then
609 begin
610 sW := gWinSizeX;
611 sH := gWinSizeY;
612 end
613 else
614 begin
615 sW := gScreenWidth;
616 sH := gScreenHeight;
617 end;
619 config.WriteInt('Video', 'ScreenWidth', sW);
620 config.WriteInt('Video', 'ScreenHeight', sH);
621 config.WriteInt('Video', 'WinPosX', gWinRealPosX);
622 config.WriteInt('Video', 'WinPosY', gWinRealPosY);
623 config.WriteBool('Video', 'Fullscreen', gFullscreen);
624 config.WriteBool('Video', 'Maximized', gWinMaximized);
626 config.SaveFile(FileName);
627 config.Free();
628 end;
630 procedure g_Options_Write_Gameplay_Custom(FileName: String);
631 var
632 config: TConfig;
633 begin
634 e_WriteLog('Writing custom gameplay config', MSG_NOTIFY);
636 config := TConfig.CreateFile(FileName);
638 config.WriteStr ('GameplayCustom', 'Map', gcMap);
639 config.WriteStr ('GameplayCustom', 'GameMode', gcGameMode);
640 config.WriteInt ('GameplayCustom', 'TimeLimit', gcTimeLimit);
641 config.WriteInt ('GameplayCustom', 'GoalLimit', gcGoalLimit);
642 config.WriteInt ('GameplayCustom', 'MaxLives', gcMaxLives);
643 config.WriteInt ('GameplayCustom', 'Players', gcPlayers);
644 config.WriteBool('GameplayCustom', 'TeamDamage', gcTeamDamage);
645 config.WriteBool('GameplayCustom', 'AllowExit', gcAllowExit);
646 config.WriteBool('GameplayCustom', 'WeaponStay', gcWeaponStay);
647 config.WriteBool('GameplayCustom', 'Monsters', gcMonsters);
648 config.WriteStr ('GameplayCustom', 'BotsVS', gcBotsVS);
650 config.SaveFile(FileName);
651 config.Free();
652 end;
654 procedure g_Options_Write_Gameplay_Net(FileName: String);
655 var
656 config: TConfig;
657 begin
658 e_WriteLog('Writing network gameplay config', MSG_NOTIFY);
660 config := TConfig.CreateFile(FileName);
662 config.WriteStr ('GameplayNetwork', 'Map', gnMap);
663 config.WriteStr ('GameplayNetwork', 'GameMode', gnGameMode);
664 config.WriteInt ('GameplayNetwork', 'TimeLimit', gnTimeLimit);
665 config.WriteInt ('GameplayNetwork', 'GoalLimit', gnGoalLimit);
666 config.WriteInt ('GameplayNetwork', 'MaxLives', gnMaxLives);
667 config.WriteInt ('GameplayNetwork', 'Players', gnPlayers);
668 config.WriteBool('GameplayNetwork', 'TeamDamage', gnTeamDamage);
669 config.WriteBool('GameplayNetwork', 'AllowExit', gnAllowExit);
670 config.WriteBool('GameplayNetwork', 'WeaponStay', gnWeaponStay);
671 config.WriteBool('GameplayNetwork', 'Monsters', gnMonsters);
672 config.WriteStr ('GameplayNetwork', 'BotsVS', gnBotsVS);
674 config.SaveFile(FileName);
675 config.Free();
676 end;
678 procedure g_Options_Write_Net_Server(FileName: String);
679 var
680 config: TConfig;
681 begin
682 e_WriteLog('Writing server config', MSG_NOTIFY);
684 config := TConfig.CreateFile(FileName);
686 config.WriteStr ('Server', 'Name', NetServerName);
687 config.WriteStr ('Server', 'Password', NetPassword);
688 config.WriteInt ('Server', 'Port', NetPort);
689 config.WriteInt ('Server', 'MaxClients', NetMaxClients);
690 config.WriteBool('Server', 'SyncWithMaster', NetUseMaster);
692 config.SaveFile(FileName);
693 config.Free();
694 end;
696 procedure g_Options_Write_Net_Client(FileName: String);
697 var
698 config: TConfig;
699 begin
700 e_WriteLog('Writing client config', MSG_NOTIFY);
702 config := TConfig.CreateFile(FileName);
704 config.WriteStr('Client', 'LastIP', NetClientIP);
705 config.WriteInt('Client', 'LastPort', NetClientPort);
707 config.SaveFile(FileName);
708 config.Free();
709 end;
711 end.