1 (* Copyright (C) Doom 2D: Forever Developers
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.
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.
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/>.
16 {$INCLUDE ../shared/a_modes.inc}
22 g_language
, g_weapons
;
25 TPlayerControl
= record
36 KeyWeapon
: array [WP_FIRST
..WP_LAST
] of Word;
48 KeyWeapon2
: array [WP_FIRST
..WP_LAST
] of Word;
51 TGameControls
= record
59 GameControls
: TGameControls
;
60 P1Control
: TPlayerControl
;
61 P2Control
: TPlayerControl
;
64 function GenPlayerName (n
: Integer): String;
66 procedure g_Options_SetDefault();
67 procedure g_Options_Read(FileName
: String);
68 procedure g_Options_Write(FileName
: String);
69 procedure g_Options_Write_Language(FileName
: String);
70 procedure g_Options_Write_Video(FileName
: String);
71 procedure g_Options_Write_Gameplay_Custom(FileName
: String);
72 procedure g_Options_Write_Gameplay_Net(FileName
: String);
73 procedure g_Options_Write_Net_Server(FileName
: String);
74 procedure g_Options_Write_Net_Client(FileName
: String);
76 const DF_Default_Megawad_Start
= 'megawads/DOOM2D.WAD:\MAP01';
79 gGameControls
: TControls
;
82 gWinRealPosX
: Integer;
83 gWinRealPosY
: Integer;
87 gWinMaximized
: Boolean;
89 glLegacyNPOT
: Boolean;
90 gTextureFilter
: Boolean;
95 gMuteWhenInactive
: Boolean;
102 gDrawBackGround
: Boolean;
103 gShowMessages
: Boolean;
104 gRevertPlayers
: Boolean;
106 gAskLanguage
: Boolean;
113 gcTeamDamage
: Boolean;
114 gcAllowExit
: Boolean;
115 gcWeaponStay
: Boolean;
124 gnTeamDamage
: Boolean;
125 gnAllowExit
: Boolean;
126 gnWeaponStay
: Boolean;
129 gsSDLSampleRate
: Integer;
130 gsSDLBufferSize
: Integer;
132 gSFSFastMode
: Boolean;
133 gDefaultMegawadStart
: AnsiString;
134 gBerserkAutoswitch
: Boolean;
139 {$INCLUDE ../nogl/noGLuses.inc}
140 e_log
, e_input
, g_window
, g_sound
, g_gfx
, g_player
, Math
,
141 g_map
, g_net
, g_netmaster
, SysUtils
, CONFIG
, g_game
, g_main
, e_texture
,
142 g_items
, wadreader
, e_graphics
, g_touch
, SDL2
, envvars
;
147 function GenPlayerName (n
: Integer): String;
150 Result
:= GetUserName
;
152 Result
:= 'Player' + IntToStr(machine
MOD 10000);
154 Result
:= Copy(Result
, 1, 12) + ' '
156 Result
:= Copy(Result
, 1, 10) + ' ' + IntToStr(n
)
159 procedure g_Options_SetDefaultVideo
;
161 target
, closest
, display
: TSDL_DisplayMode
;
164 (* Display 0 = Primary display *)
165 SDL_GetDesktopDisplayMode(0, @display
);
166 {$IF DEFINED(ANDROID)}
167 gScreenWidth
:= display
.w
;
168 gScreenHeight
:= display
.h
;
169 //gBPP := SDL_BITSPERPIXEL(dispaly.format);
171 gFullScreen
:= True; (* rotation not allowed? *)
173 (* Window must be smaller than display *)
174 closest
.w
:= display
.w
;
175 closest
.h
:= display
.h
;
177 while (display
.w
- closest
.w
< 48) or (display
.h
- closest
.h
< 48) do
179 if percentage
< 25 then
181 closest
.w
:= display
.w
* 75 div 100;
182 closest
.h
:= display
.h
* 75 div 100;
185 target
.w
:= display
.w
* percentage
div 100;
186 target
.h
:= display
.h
* percentage
div 100;
187 target
.format
:= 0; (* didn't care *)
188 target
.refresh_rate
:= 0; (* didn't care *)
189 target
.driverdata
:= nil; (* init *)
190 SDL_GetClosestDisplayMode(0, @target
, @closest
);
193 gScreenWidth
:= closest
.w
;
194 gScreenHeight
:= closest
.h
;
195 //gBPP := SDL_BITSPERPIXEL(closest.format); (* Resolution list didn't work for some reason *)
197 gFullScreen
:= False;
199 (* Must be positioned on primary display *)
200 gWinRealPosX
:= SDL_WINDOWPOS_CENTERED
;
201 gWinRealPosY
:= SDL_WINDOWPOS_CENTERED
;
202 gWinMaximized
:= False;
204 gTextureFilter
:= True;
205 glLegacyNPOT
:= False;
206 e_LogWriteLn('g_Options_SetDefaultVideo: w = ' + IntToStr(gScreenWidth
) + ' h = ' + IntToStr(gScreenHeight
));
209 procedure g_Options_SetDefault();
218 gMuteWhenInactive
:= False;
219 gAnnouncer
:= ANNOUNCE_MEPLUS
;
220 gSoundEffectsDF
:= True;
221 gUseChatSounds
:= True;
222 gsSDLSampleRate
:= 44100;
223 gsSDLBufferSize
:= 2048;
225 g_Sound_SetupAllVolumes(gSoundLevel
, gMusicLevel
);
227 (* section GameControls *)
228 with gGameControls
.GameControls
do
230 TakeScreenshot
:= SDL_SCANCODE_F12
;
231 Stat
:= SDL_SCANCODE_TAB
;
232 Chat
:= SDL_SCANCODE_T
;
233 TeamChat
:= SDL_SCANCODE_Y
;
236 (* section Player1 *)
237 with gGameControls
.P1Control
do
239 KeyRight
:= SDL_SCANCODE_KP_6
;
240 KeyLeft
:= SDL_SCANCODE_KP_4
;
241 KeyUp
:= SDL_SCANCODE_KP_8
;
242 KeyDown
:= SDL_SCANCODE_KP_5
;
243 KeyFire
:= SDL_SCANCODE_SLASH
;
244 KeyJump
:= SDL_SCANCODE_RCTRL
;
245 KeyNextWeapon
:= SDL_SCANCODE_KP_9
;
246 KeyPrevWeapon
:= SDL_SCANCODE_KP_7
;
247 KeyOpen
:= SDL_SCANCODE_RSHIFT
;
248 KeyStrafe
:= SDL_SCANCODE_PERIOD
;
252 KeyWeapon
[i
] := SDL_SCANCODE_1
+ i (* 1, ..., 9, 0 *)
254 KeyWeapon
[10] := SDL_SCANCODE_MINUS
;
255 for i
:= 11 to High(KeyWeapon
) do
260 KeyRight2
:= VK_RIGHT
;
266 KeyNextWeapon2
:= VK_NEXT
;
267 KeyPrevWeapon2
:= VK_PREV
;
269 KeyStrafe2
:= VK_STRAFE
;
271 for i
:= 0 to High(KeyWeapon2
) do
273 KeyWeapon2
[i
] := VK_0
+ i
277 with gPlayer1Settings
do
279 Name
:= GenPlayerName(1);
280 Model
:= STD_PLAYER_MODEL
;
281 Color
.R
:= PLAYER1_DEF_COLOR
.R
;
282 Color
.G
:= PLAYER1_DEF_COLOR
.G
;
283 Color
.B
:= PLAYER1_DEF_COLOR
.B
;
287 (* section Player2 *)
288 with gGameControls
.P2Control
do
290 KeyRight
:= SDL_SCANCODE_D
;
291 KeyLeft
:= SDL_SCANCODE_A
;
292 KeyUp
:= SDL_SCANCODE_W
;
293 KeyDown
:= SDL_SCANCODE_S
;
294 KeyFire
:= SDL_SCANCODE_G
;
295 KeyJump
:= SDL_SCANCODE_SPACE
;
296 KeyNextWeapon
:= SDL_SCANCODE_E
;
297 KeyPrevWeapon
:= SDL_SCANCODE_Q
;
298 KeyOpen
:= SDL_SCANCODE_F
;
299 KeyStrafe
:= SDL_SCANCODE_LSHIFT
;
300 for i
:= 0 to High(KeyWeapon
) do
316 for i
:= 0 to High(KeyWeapon2
) do
322 with gPlayer2Settings
do
324 Name
:= GenPlayerName(2);
325 Model
:= STD_PLAYER_MODEL
;
326 Color
.R
:= PLAYER2_DEF_COLOR
.R
;
327 Color
.G
:= PLAYER2_DEF_COLOR
.G
;
328 Color
.B
:= PLAYER2_DEF_COLOR
.B
;
332 (* section Joysticks *)
333 for i
:= 0 to e_MaxJoys
- 1 do
335 e_JoystickDeadzones
[i
] := 8192
340 g_touch_fire
:= True;
341 g_touch_offset
:= 50;
342 g_touch_alt
:= False;
346 g_Shells_SetMax(300);
348 g_Corpses_SetMax(20);
350 ITEM_RESPAWNTIME
:= 60 * 36;
356 gDrawBackGround
:= True;
357 gShowMessages
:= True;
358 gRevertPlayers
:= False;
360 gPlayerIndicator
:= True;
362 gSFSFastMode
:= False;
363 e_FastScreenshots
:= True;
364 gDefaultMegawadStart
:= DF_Default_Megawad_Start
;
365 gBerserkAutoswitch
:= True;
368 gAskLanguage
:= True;
369 gLanguage
:= LANGUAGE_ENGLISH
;
371 (* section GameplayCustom *)
373 gcGameMode
:= _lc
[I_MENU_GAME_TYPE_DM
];
378 gcTeamDamage
:= False;
380 gcWeaponStay
:= False;
382 gcBotsVS
:= 'Everybody';
384 (* section GameplayNetwork *)
386 gnGameMode
:= _lc
[I_MENU_GAME_TYPE_DM
];
391 gnTeamDamage
:= False;
393 gnWeaponStay
:= False;
395 gnBotsVS
:= 'Everybody';
397 (* section MasterServer *)
398 NetSlistIP
:= 'mpms.doom2d.org';
399 NetSlistPort
:= 25665;
400 g_Net_Slist_Set(NetSlistIP
, NetSlistPort
);
403 NetServerName
:= 'Unnamed Server';
407 NetAllowRCON
:= False;
408 NetRCONPassword
:= 'default';
409 NetUseMaster
:= True;
412 NetMasterRate
:= 60000;
413 NetForwardPorts
:= False;
417 NetForcePlayerUpdate
:= False;
418 NetPredictSelf
:= True;
419 NetClientIP
:= '127.0.0.1';
420 NetClientPort
:= NetPort
;
423 procedure g_Options_Read(FileName
: String);
429 procedure ReadInteger (VAR v
: Integer; param
: String; minv
: Integer = Low(Integer); maxv
: Integer = High(Integer));
431 v
:= Max(Min(config
.ReadInt(section
, param
, v
), maxv
), minv
)
434 procedure ReadInteger (VAR v
: LongWord; param
: String; minv
: LongWord = Low(LongWord); maxv
: LongWord = High(LongWord)); overload
;
436 v
:= Max(Min(config
.ReadInt(section
, param
, v
), maxv
), minv
)
439 procedure ReadInteger (VAR v
: Word; param
: String; minv
: Word = Low(Word); maxv
: Word = High(Word)); overload
;
441 v
:= Max(Min(config
.ReadInt(section
, param
, v
), maxv
), minv
)
444 procedure ReadInteger (VAR v
: Byte; param
: String; minv
: Byte = Low(Byte); maxv
: Byte = High(Byte)); overload
;
446 v
:= Max(Min(config
.ReadInt(section
, param
, v
), maxv
), minv
)
449 procedure ReadBoolean (VAR v
: Boolean; param
: String);
451 v
:= config
.ReadBool(section
, param
, v
)
454 procedure ReadString (VAR v
: String; param
: String);
456 v
:= config
.ReadStr(section
, param
, v
)
460 gAskLanguage
:= True;
461 e_WriteLog('Reading config', TMsgType
.Notify
);
462 g_Options_SetDefault
;
464 if FileExists(FileName
) = False then
466 e_WriteLog('Config file '+FileName
+' not found', TMsgType
.Warning
);
467 g_Options_SetDefaultVideo
;
471 config
:= TConfig
.CreateFile(FileName
);
474 ReadInteger(gScreenWidth
, 'ScreenWidth', 0);
475 ReadInteger(gScreenHeight
, 'ScreenHeight', 0);
476 ReadInteger(gWinRealPosX
, 'WinPosX', 60);
477 ReadInteger(gWinRealPosY
, 'WinPosY', 60);
478 ReadBoolean(gFullScreen
, 'Fullscreen');
479 ReadBoolean(gWinMaximized
, 'Maximized');
480 ReadInteger(gBPP
, 'BPP', 0);
481 ReadInteger(gFreq
, 'Freq', 0);
482 ReadBoolean(gVSync
, 'VSync');
483 ReadBoolean(gTextureFilter
, 'TextureFilter');
484 ReadBoolean(glLegacyNPOT
, 'LegacyCompatible');
487 ReadBoolean(gNoSound
, 'NoSound');
488 ReadInteger(gSoundLevel
, 'SoundLevel', 0, 255);
489 ReadInteger(gMusicLevel
, 'MusicLevel', 0, 255);
490 ReadInteger(gMaxSimSounds
, 'MaxSimSounds', 2, 66);
491 ReadBoolean(gMuteWhenInactive
, 'MuteInactive');
492 ReadInteger(gAnnouncer
, 'Announcer', ANNOUNCE_NONE
, ANNOUNCE_ALL
);
493 ReadBoolean(gSoundEffectsDF
, 'SoundEffectsDF');
494 ReadBoolean(gUseChatSounds
, 'ChatSounds');
495 ReadInteger(gsSDLSampleRate
, 'SDLSampleRate', 11025, 96000);
496 ReadInteger(gsSDLBufferSize
, 'SDLBufferSize', 64, 16384);
498 section
:= 'GameControls';
499 with gGameControls
.GameControls
do
501 ReadInteger(TakeScreenshot
, 'TakeScreenshot');
502 ReadInteger(Stat
, 'Stat');
503 ReadInteger(Chat
, 'Chat');
504 ReadInteger(TeamChat
, 'TeamChat');
507 section
:= 'Player1';
508 with gGameControls
.P1Control
do
510 ReadInteger(KeyRight
, 'KeyRight');
511 ReadInteger(KeyLeft
, 'KeyLeft');
512 ReadInteger(KeyUp
, 'KeyUp');
513 ReadInteger(KeyDown
, 'KeyDown');
514 ReadInteger(KeyFire
, 'KeyFire');
515 ReadInteger(KeyJump
, 'KeyJump');
516 ReadInteger(KeyNextWeapon
, 'KeyNextWeapon');
517 ReadInteger(KeyPrevWeapon
, 'KeyPrevWeapon');
518 ReadInteger(KeyOpen
, 'KeyOpen');
519 ReadInteger(KeyStrafe
, 'KeyStrafe');
521 for i
:= 0 to High(KeyWeapon
) do
523 ReadInteger(KeyWeapon
[i
], 'KeyWeapon' + IntToStr(i
))
526 ReadInteger(KeyRight2
, 'KeyRight2');
527 ReadInteger(KeyLeft2
, 'KeyLeft2');
528 ReadInteger(KeyUp2
, 'KeyUp2');
529 ReadInteger(KeyDown2
, 'KeyDown2');
530 ReadInteger(KeyFire2
, 'KeyFire2');
531 ReadInteger(KeyJump2
, 'KeyJump2');
532 ReadInteger(KeyNextWeapon2
, 'KeyNextWeapon2');
533 ReadInteger(KeyPrevWeapon2
, 'KeyPrevWeapon2');
534 ReadInteger(KeyOpen2
, 'KeyOpen2');
535 ReadInteger(KeyStrafe2
, 'KeyStrafe2');
537 for i
:= 0 to High(KeyWeapon2
) do
539 ReadInteger(KeyWeapon2
[i
], 'KeyWeapon2' + IntToStr(i
))
543 section
:= 'Player1';
544 with gPlayer1Settings
do
546 ReadString(Name
, 'name');
547 ReadString(Model
, 'model');
548 ReadInteger(Color
.R
, 'red', 0, 255);
549 ReadInteger(Color
.G
, 'green', 0, 255);
550 ReadInteger(Color
.B
, 'blue', 0, 255);
551 ReadInteger(Team
, 'team');
552 if (Team
< TEAM_RED
) or (Team
> TEAM_BLUE
) then
556 section
:= 'Player2';
557 with gGameControls
.P2Control
do
559 ReadInteger(KeyRight
, 'KeyRight');
560 ReadInteger(KeyLeft
, 'KeyLeft');
561 ReadInteger(KeyUp
, 'KeyUp');
562 ReadInteger(KeyDown
, 'KeyDown');
563 ReadInteger(KeyFire
, 'KeyFire');
564 ReadInteger(KeyJump
, 'KeyJump');
565 ReadInteger(KeyNextWeapon
, 'KeyNextWeapon');
566 ReadInteger(KeyPrevWeapon
, 'KeyPrevWeapon');
567 ReadInteger(KeyOpen
, 'KeyOpen');
568 ReadInteger(KeyStrafe
, 'KeyStrafe');
570 for i
:= 0 to High(KeyWeapon
) do
572 ReadInteger(KeyWeapon
[i
], 'KeyWeapon' + IntToStr(i
))
575 ReadInteger(KeyRight2
, 'KeyRight2');
576 ReadInteger(KeyLeft2
, 'KeyLeft2');
577 ReadInteger(KeyUp2
, 'KeyUp2');
578 ReadInteger(KeyDown2
, 'KeyDown2');
579 ReadInteger(KeyFire2
, 'KeyFire2');
580 ReadInteger(KeyJump2
, 'KeyJump2');
581 ReadInteger(KeyNextWeapon2
, 'KeyNextWeapon2');
582 ReadInteger(KeyPrevWeapon2
, 'KeyPrevWeapon2');
583 ReadInteger(KeyOpen2
, 'KeyOpen2');
584 ReadInteger(KeyStrafe2
, 'KeyStrafe2');
586 for i
:= 0 to High(KeyWeapon2
) do
588 ReadInteger(KeyWeapon2
[i
], 'KeyWeapon2' + IntToStr(i
))
592 section
:= 'Player2';
593 with gPlayer2Settings
do
595 ReadString(Name
, 'name');
596 ReadString(Model
, 'model');
597 ReadInteger(Color
.R
, 'red', 0, 255);
598 ReadInteger(Color
.G
, 'green', 0, 255);
599 ReadInteger(Color
.B
, 'blue', 0, 255);
600 ReadInteger(Team
, 'team');
601 if (Team
< TEAM_RED
) or (Team
> TEAM_BLUE
) then
605 section
:= 'Joysticks';
606 for i
:= 0 to e_MaxJoys
- 1 do
608 ReadInteger(e_JoystickDeadzones
[i
], 'Deadzone' + IntToStr(i
))
612 i
:= Trunc(g_touch_size
* 10); ReadInteger(i
, 'Size', 0); g_touch_size
:= i
/ 10;
613 ReadBoolean(g_touch_fire
, 'Fire');
614 i
:= Round(g_touch_offset
); ReadInteger(i
, 'Offset', 0, 100); g_touch_offset
:= i
;
615 ReadBoolean(g_touch_alt
, 'Alt');
618 ReadInteger(i
, 'MaxParticles', 1000, 50000); g_GFX_SetMax(i
);
619 ReadInteger(i
, 'MaxShells', 300, 600); g_Shells_SetMax(i
);
620 ReadInteger(i
, 'MaxGibs', 150, 500); g_Gibs_SetMax(i
);
621 ReadInteger(i
, 'MaxCorpses', 20, 100); g_Corpses_SetMax(i
);
622 ReadInteger(i
, 'GibsCount');
628 else gGibsCount
:= 48;
630 i
:= ITEM_RESPAWNTIME
div 36; ReadInteger(i
, 'ItemRespawnTime', 0); ITEM_RESPAWNTIME
:= i
* 36;
631 ReadInteger(gBloodCount
, 'BloodCount', 0, 4);
632 ReadBoolean(gAdvBlood
, 'AdvancesBlood');
633 ReadBoolean(gAdvCorpses
, 'AdvancesCorpses');
634 ReadBoolean(gAdvGibs
, 'AdvancesGibs');
635 ReadInteger(gFlash
, 'Flash', 0, 2);
636 ReadBoolean(gDrawBackGround
, 'BackGround');
637 ReadBoolean(gShowMessages
, 'Messages');
638 ReadBoolean(gRevertPlayers
, 'RevertPlayers');
639 ReadInteger(gChatBubble
, 'ChatBubble', 0, 4);
640 ReadBoolean(gPlayerIndicator
, 'PlayerIndicator');
641 ReadBoolean(gSFSDebug
, 'SFSDebug'); wadoptDebug
:= gSFSDebug
;
642 ReadBoolean(gSFSFastMode
, 'SFSFastMode'); wadoptFast
:= gSFSFastMode
;
643 ReadBoolean(e_FastScreenshots
, 'FastScreenshots');
644 ReadString(gDefaultMegawadStart
, 'DefaultMegawadStart');
645 ReadBoolean(gBerserkAutoswitch
, 'BerserkAutoswitching');
646 i
:= Trunc(g_dbg_scale
* 100); ReadInteger(i
, 'Scale', 100); g_dbg_scale
:= i
/ 100;
647 ReadString(gLanguage
, 'Language');
648 if (gLanguage
= LANGUAGE_RUSSIAN
) or (gLanguage
= LANGUAGE_ENGLISH
) then
649 gAskLanguage
:= False
651 gLanguage
:= LANGUAGE_ENGLISH
;
653 section
:= 'GameplayCustom';
654 ReadString(gcMap
, 'Map');
655 ReadString(gcGameMode
, 'GameMode');
656 ReadInteger(gcTimeLimit
, 'TimeLimit', 0, 65535);
657 ReadInteger(gcGoalLimit
, 'GoalLimit', 0, 65535);
658 ReadInteger(gcMaxLives
, 'MaxLives', 0, 255);
659 ReadInteger(gcPlayers
, 'Players', 0, 2);
660 ReadBoolean(gcTeamDamage
, 'TeamDamage');
661 ReadBoolean(gcAllowExit
, 'AllowExit');
662 ReadBoolean(gcWeaponStay
, 'WeaponStay');
663 ReadBoolean(gcMonsters
, 'Monsters');
664 ReadString(gcBotsVS
, 'BotsVS');
666 with gGameSettings
do
668 GameMode
:= g_Game_TextToMode(gcGameMode
);
669 if GameMode
= GM_NONE
then
671 if GameMode
= GM_SINGLE
then
673 TimeLimit
:= gcTimeLimit
;
674 GoalLimit
:= gcGoalLimit
;
675 MaxLives
:= gcMaxLives
;
679 Options
:= Options
or GAME_OPTION_TEAMDAMAGE
;
681 Options
:= Options
or GAME_OPTION_ALLOWEXIT
;
683 Options
:= Options
or GAME_OPTION_WEAPONSTAY
;
685 Options
:= Options
or GAME_OPTION_MONSTERS
;
686 if gcBotsVS
= 'Everybody' then
687 Options
:= Options
or GAME_OPTION_BOTVSPLAYER
or GAME_OPTION_BOTVSMONSTER
;
688 if gcBotsVS
= 'Players' then
689 Options
:= Options
or GAME_OPTION_BOTVSPLAYER
;
690 if gcBotsVS
= 'Monsters' then
691 Options
:= Options
or GAME_OPTION_BOTVSMONSTER
;
694 section
:= 'GameplayNetwork';
695 ReadString(gnMap
, 'Map');
696 ReadString(gnGameMode
, 'GameMode');
697 ReadInteger(gnTimeLimit
, 'TimeLimit', 0, 65535);
698 ReadInteger(gnGoalLimit
, 'GoalLimit', 0, 65535);
699 ReadInteger(gnMaxLives
, 'MaxLives', 0, 255);
700 ReadInteger(gnPlayers
, 'Players', 0, 2);
701 ReadBoolean(gnTeamDamage
, 'TeamDamage');
702 ReadBoolean(gnAllowExit
, 'AllowExit');
703 ReadBoolean(gnWeaponStay
, 'WeaponStay');
704 ReadBoolean(gnMonsters
, 'Monsters');
705 ReadString(gnBotsVS
, 'BotsVS');
707 section
:= 'MasterServer';
708 ReadString(NetSlistIP
, 'IP');
709 ReadInteger(NetSlistPort
, 'Port', 0, 65535);
710 g_Net_Slist_Set(NetSlistIP
, NetSlistPort
);
713 ReadString(NetServerName
, 'Name');
714 ReadString(NetPassword
, 'Password');
715 ReadInteger(NetPort
, 'Port', 0, 65535);
716 ReadInteger(NetMaxClients
, 'MaxClients', 0, NET_MAXCLIENTS
);
717 ReadBoolean(NetAllowRCON
, 'RCON');
718 ReadString(NetRCONPassword
, 'RCONPassword');
719 ReadBoolean(NetUseMaster
, 'SyncWithMaster');
720 ReadInteger(NetUpdateRate
, 'UpdateInterval', 0);
721 ReadInteger(NetRelupdRate
, 'ReliableUpdateInterval', 0);
722 ReadInteger(NetMasterRate
, 'MasterSyncInterval', 1);
723 ReadBoolean(NetForwardPorts
, 'ForwardPorts');
726 ReadInteger(NetInterpLevel
, 'InterpolationSteps', 0);
727 ReadBoolean(NetForcePlayerUpdate
, 'ForcePlayerUpdate');
728 ReadBoolean(NetPredictSelf
, 'PredictSelf');
729 ReadString(NetClientIP
, 'LastIP');
730 ReadInteger(NetClientPort
, 'LastPort', 0, 65535);
734 //if gTextureFilter then TEXTUREFILTER := GL_LINEAR else TEXTUREFILTER := GL_NEAREST;
737 procedure g_Options_Write(FileName
: String);
742 e_WriteLog('Writing config', TMsgType
.Notify
);
744 config
:= TConfig
.CreateFile(FileName
);
746 config
.WriteInt('Video', 'ScreenWidth', gScreenWidth
);
747 config
.WriteInt('Video', 'ScreenHeight', gScreenHeight
);
748 config
.WriteInt('Video', 'WinPosX', gWinRealPosX
);
749 config
.WriteInt('Video', 'WinPosY', gWinRealPosY
);
750 config
.WriteBool('Video', 'Fullscreen', gFullScreen
);
751 config
.WriteBool('Video', 'Maximized', gWinMaximized
);
752 config
.WriteInt('Video', 'BPP', gBPP
);
753 config
.WriteBool('Video', 'VSync', gVSync
);
754 config
.WriteBool('Video', 'TextureFilter', gTextureFilter
);
755 config
.WriteBool('Video', 'LegacyCompatible', glLegacyNPOT
);
757 config
.WriteBool('Sound', 'NoSound', gNoSound
);
758 config
.WriteInt('Sound', 'SoundLevel', gSoundLevel
);
759 config
.WriteInt('Sound', 'MusicLevel', gMusicLevel
);
760 config
.WriteInt('Sound', 'MaxSimSounds', gMaxSimSounds
);
761 config
.WriteBool('Sound', 'MuteInactive', gMuteWhenInactive
);
762 config
.WriteInt('Sound', 'Announcer', gAnnouncer
);
763 config
.WriteBool('Sound', 'SoundEffectsDF', gSoundEffectsDF
);
764 config
.WriteBool('Sound', 'ChatSounds', gUseChatSounds
);
765 config
.WriteInt('Sound', 'SDLSampleRate', gsSDLSampleRate
);
766 config
.WriteInt('Sound', 'SDLBufferSize', gsSDLBufferSize
);
768 with config
, gGameControls
.GameControls
do
770 WriteInt('GameControls', 'TakeScreenshot', TakeScreenshot
);
771 WriteInt('GameControls', 'Stat', Stat
);
772 WriteInt('GameControls', 'Chat', Chat
);
773 WriteInt('GameControls', 'TeamChat', TeamChat
);
776 with config
, gGameControls
.P1Control
, gPlayer1Settings
do
778 WriteInt('Player1', 'KeyRight', KeyRight
);
779 WriteInt('Player1', 'KeyLeft', KeyLeft
);
780 WriteInt('Player1', 'KeyUp', KeyUp
);
781 WriteInt('Player1', 'KeyDown', KeyDown
);
782 WriteInt('Player1', 'KeyFire', KeyFire
);
783 WriteInt('Player1', 'KeyJump', KeyJump
);
784 WriteInt('Player1', 'KeyNextWeapon', KeyNextWeapon
);
785 WriteInt('Player1', 'KeyPrevWeapon', KeyPrevWeapon
);
786 WriteInt('Player1', 'KeyOpen', KeyOpen
);
787 WriteInt('Player1', 'KeyStrafe', KeyStrafe
);
788 for i
:= 0 to High(KeyWeapon
) do
789 WriteInt('Player1', 'KeyWeapon' + IntToStr(i
), KeyWeapon
[i
]);
791 WriteInt('Player1', 'KeyRight2', KeyRight2
);
792 WriteInt('Player1', 'KeyLeft2', KeyLeft2
);
793 WriteInt('Player1', 'KeyUp2', KeyUp2
);
794 WriteInt('Player1', 'KeyDown2', KeyDown2
);
795 WriteInt('Player1', 'KeyFire2', KeyFire2
);
796 WriteInt('Player1', 'KeyJump2', KeyJump2
);
797 WriteInt('Player1', 'KeyNextWeapon2', KeyNextWeapon2
);
798 WriteInt('Player1', 'KeyPrevWeapon2', KeyPrevWeapon2
);
799 WriteInt('Player1', 'KeyOpen2', KeyOpen2
);
800 WriteInt('Player1', 'KeyStrafe2', KeyStrafe2
);
801 for i
:= 0 to High(KeyWeapon2
) do
802 WriteInt('Player1', 'KeyWeapon2' + IntToStr(i
), KeyWeapon2
[i
]);
804 WriteStr('Player1', 'Name', Name
);
805 WriteStr('Player1', 'model', Model
);
806 WriteInt('Player1', 'red', Color
.R
);
807 WriteInt('Player1', 'green', Color
.G
);
808 WriteInt('Player1', 'blue', Color
.B
);
809 WriteInt('Player1', 'team', Team
);
812 with config
, gGameControls
.P2Control
, gPlayer2Settings
do
814 WriteInt('Player2', 'KeyRight', KeyRight
);
815 WriteInt('Player2', 'KeyLeft', KeyLeft
);
816 WriteInt('Player2', 'KeyUp', KeyUp
);
817 WriteInt('Player2', 'KeyDown', KeyDown
);
818 WriteInt('Player2', 'KeyFire', KeyFire
);
819 WriteInt('Player2', 'KeyJump', KeyJump
);
820 WriteInt('Player2', 'KeyNextWeapon', KeyNextWeapon
);
821 WriteInt('Player2', 'KeyPrevWeapon', KeyPrevWeapon
);
822 WriteInt('Player2', 'KeyOpen', KeyOpen
);
823 WriteInt('Player2', 'KeyStrafe', KeyStrafe
);
824 for i
:= 0 to High(KeyWeapon
) do
825 WriteInt('Player2', 'KeyWeapon' + IntToStr(i
), KeyWeapon
[i
]);
827 WriteInt('Player2', 'KeyRight2', KeyRight2
);
828 WriteInt('Player2', 'KeyLeft2', KeyLeft2
);
829 WriteInt('Player2', 'KeyUp2', KeyUp2
);
830 WriteInt('Player2', 'KeyDown2', KeyDown2
);
831 WriteInt('Player2', 'KeyFire2', KeyFire2
);
832 WriteInt('Player2', 'KeyJump2', KeyJump2
);
833 WriteInt('Player2', 'KeyNextWeapon2', KeyNextWeapon2
);
834 WriteInt('Player2', 'KeyPrevWeapon2', KeyPrevWeapon2
);
835 WriteInt('Player2', 'KeyOpen2', KeyOpen2
);
836 WriteInt('Player2', 'KeyStrafe2', KeyStrafe2
);
837 for i
:= 0 to High(KeyWeapon2
) do
838 WriteInt('Player2', 'KeyWeapon2' + IntToStr(i
), KeyWeapon2
[i
]);
840 WriteStr('Player2', 'Name', Name
);
841 WriteStr('Player2', 'model', Model
);
842 WriteInt('Player2', 'red', Color
.R
);
843 WriteInt('Player2', 'green', Color
.G
);
844 WriteInt('Player2', 'blue', Color
.B
);
845 WriteInt('Player2', 'team', Team
);
848 for i
:= 0 to e_MaxJoys
-1 do
849 config
.WriteInt('Joysticks', 'Deadzone' + IntToStr(i
), e_JoystickDeadzones
[i
]);
851 config
.WriteInt('Touch', 'Size', Round(g_touch_size
* 10));
852 config
.WriteBool('Touch', 'Fire', g_touch_fire
);
853 config
.WriteInt('Touch', 'Offset', Round(g_touch_offset
));
854 config
.WriteBool('Touch', 'Alt', g_touch_alt
);
858 0: config
.WriteInt('Game', 'GibsCount', 0);
859 8: config
.WriteInt('Game', 'GibsCount', 1);
860 16: config
.WriteInt('Game', 'GibsCount', 2);
861 32: config
.WriteInt('Game', 'GibsCount', 3);
862 else config
.WriteInt('Game', 'GibsCount', 4);
865 config
.WriteInt('Game', 'ItemRespawnTime', ITEM_RESPAWNTIME
div 36);
866 config
.WriteInt('Game', 'MaxParticles', g_GFX_GetMax());
867 config
.WriteInt('Game', 'MaxShells', g_Shells_GetMax());
868 config
.WriteInt('Game', 'MaxGibs', g_Gibs_GetMax());
869 config
.WriteInt('Game', 'MaxCorpses', g_Corpses_GetMax());
870 config
.WriteInt('Game', 'BloodCount', gBloodCount
);
871 config
.WriteBool('Game', 'AdvancesBlood', gAdvBlood
);
872 config
.WriteBool('Game', 'AdvancesCorpses', gAdvCorpses
);
873 config
.WriteBool('Game', 'AdvancesGibs', gAdvGibs
);
874 config
.WriteInt('Game', 'Flash', gFlash
);
875 config
.WriteBool('Game', 'BackGround', gDrawBackGround
);
876 config
.WriteBool('Game', 'Messages', gShowMessages
);
877 config
.WriteBool('Game', 'RevertPlayers', gRevertPlayers
);
878 config
.WriteInt('Game', 'ChatBubble', gChatBubble
);
879 config
.WriteBool('Game', 'PlayerIndicator', gPlayerIndicator
);
880 config
.WriteBool('Game', 'SFSDebug', gSFSDebug
);
881 config
.WriteBool('Game', 'SFSFastMode', gSFSFastMode
);
882 config
.WriteBool('Game', 'FastScreenshots', e_FastScreenshots
);
883 config
.WriteStr('Game', 'DefaultMegawadStart', gDefaultMegawadStart
);
884 config
.WriteBool('Game', 'BerserkAutoswitching', gBerserkAutoswitch
);
885 config
.WriteInt('Game', 'Scale', Round(g_dbg_scale
* 100));
887 config
.WriteStr ('GameplayCustom', 'Map', gcMap
);
888 config
.WriteStr ('GameplayCustom', 'GameMode', gcGameMode
);
889 config
.WriteInt ('GameplayCustom', 'TimeLimit', gcTimeLimit
);
890 config
.WriteInt ('GameplayCustom', 'GoalLimit', gcGoalLimit
);
891 config
.WriteInt ('GameplayCustom', 'MaxLives', gcMaxLives
);
892 config
.WriteInt ('GameplayCustom', 'Players', gcPlayers
);
893 config
.WriteBool('GameplayCustom', 'TeamDamage', gcTeamDamage
);
894 config
.WriteBool('GameplayCustom', 'AllowExit', gcAllowExit
);
895 config
.WriteBool('GameplayCustom', 'WeaponStay', gcWeaponStay
);
896 config
.WriteBool('GameplayCustom', 'Monsters', gcMonsters
);
897 config
.WriteStr ('GameplayCustom', 'BotsVS', gcBotsVS
);
899 config
.WriteStr ('GameplayNetwork', 'Map', gnMap
);
900 config
.WriteStr ('GameplayNetwork', 'GameMode', gnGameMode
);
901 config
.WriteInt ('GameplayNetwork', 'TimeLimit', gnTimeLimit
);
902 config
.WriteInt ('GameplayNetwork', 'GoalLimit', gnGoalLimit
);
903 config
.WriteInt ('GameplayNetwork', 'MaxLives', gnMaxLives
);
904 config
.WriteInt ('GameplayNetwork', 'Players', gnPlayers
);
905 config
.WriteBool('GameplayNetwork', 'TeamDamage', gnTeamDamage
);
906 config
.WriteBool('GameplayNetwork', 'AllowExit', gnAllowExit
);
907 config
.WriteBool('GameplayNetwork', 'WeaponStay', gnWeaponStay
);
908 config
.WriteBool('GameplayNetwork', 'Monsters', gnMonsters
);
909 config
.WriteStr ('GameplayNetwork', 'BotsVS', gnBotsVS
);
911 config
.WriteStr('MasterServer', 'IP', NetSlistIP
);
912 config
.WriteInt('MasterServer', 'Port', NetSlistPort
);
914 config
.WriteStr ('Server', 'Name', NetServerName
);
915 config
.WriteStr ('Server', 'Password', NetPassword
);
916 config
.WriteInt ('Server', 'Port', NetPort
);
917 config
.WriteInt ('Server', 'MaxClients', NetMaxClients
);
918 config
.WriteBool('Server', 'RCON', NetAllowRCON
);
919 config
.WriteStr ('Server', 'RCONPassword', NetRCONPassword
);
920 config
.WriteBool('Server', 'SyncWithMaster', NetUseMaster
);
921 config
.WriteBool('Server', 'ForwardPorts', NetForwardPorts
);
922 config
.WriteInt ('Server', 'UpdateInterval', NetUpdateRate
);
923 config
.WriteInt ('Server', 'ReliableUpdateInterval', NetRelupdRate
);
924 config
.WriteInt ('Server', 'MasterSyncInterval', NetMasterRate
);
926 config
.WriteInt ('Client', 'InterpolationSteps', NetInterpLevel
);
927 config
.WriteBool ('Client', 'ForcePlayerUpdate', NetForcePlayerUpdate
);
928 config
.WriteBool ('Client', 'PredictSelf', NetPredictSelf
);
929 config
.WriteStr ('Client', 'LastIP', NetClientIP
);
930 config
.WriteInt ('Client', 'LastPort', NetClientPort
);
932 config
.SaveFile(FileName
);
936 procedure g_Options_Write_Language(FileName
: String);
940 e_WriteLog('Writing language config', TMsgType
.Notify
);
942 config
:= TConfig
.CreateFile(FileName
);
943 config
.WriteStr('Game', 'Language', gLanguage
);
944 config
.SaveFile(FileName
);
948 procedure g_Options_Write_Video(FileName
: String);
953 e_WriteLog('Writing resolution to config', TMsgType
.Notify
);
955 config
:= TConfig
.CreateFile(FileName
);
957 if gWinMaximized
and (not gFullscreen
) then
967 e_LogWritefln(' (ws=%dx%d) (ss=%dx%d)', [gWinSizeX
, gWinSizeY
, gScreenWidth
, gScreenHeight
]);
969 config
.WriteInt('Video', 'ScreenWidth', sW
);
970 config
.WriteInt('Video', 'ScreenHeight', sH
);
971 config
.WriteInt('Video', 'WinPosX', gWinRealPosX
);
972 config
.WriteInt('Video', 'WinPosY', gWinRealPosY
);
973 config
.WriteBool('Video', 'Fullscreen', gFullscreen
);
974 config
.WriteBool('Video', 'Maximized', gWinMaximized
);
976 config
.WriteStr('Player1', 'Name', gPlayer1Settings
.Name
);
977 config
.WriteStr('Player2', 'Name', gPlayer2Settings
.Name
);
979 config
.SaveFile(FileName
);
983 procedure g_Options_Write_Gameplay_Custom(FileName
: String);
987 e_WriteLog('Writing custom gameplay config', TMsgType
.Notify
);
989 config
:= TConfig
.CreateFile(FileName
);
991 config
.WriteStr ('GameplayCustom', 'Map', gcMap
);
992 config
.WriteStr ('GameplayCustom', 'GameMode', gcGameMode
);
993 config
.WriteInt ('GameplayCustom', 'TimeLimit', gcTimeLimit
);
994 config
.WriteInt ('GameplayCustom', 'GoalLimit', gcGoalLimit
);
995 config
.WriteInt ('GameplayCustom', 'MaxLives', gcMaxLives
);
996 config
.WriteInt ('GameplayCustom', 'Players', gcPlayers
);
997 config
.WriteBool('GameplayCustom', 'TeamDamage', gcTeamDamage
);
998 config
.WriteBool('GameplayCustom', 'AllowExit', gcAllowExit
);
999 config
.WriteBool('GameplayCustom', 'WeaponStay', gcWeaponStay
);
1000 config
.WriteBool('GameplayCustom', 'Monsters', gcMonsters
);
1001 config
.WriteStr ('GameplayCustom', 'BotsVS', gcBotsVS
);
1003 config
.SaveFile(FileName
);
1007 procedure g_Options_Write_Gameplay_Net(FileName
: String);
1011 e_WriteLog('Writing network gameplay config', TMsgType
.Notify
);
1013 config
:= TConfig
.CreateFile(FileName
);
1015 config
.WriteStr ('GameplayNetwork', 'Map', gnMap
);
1016 config
.WriteStr ('GameplayNetwork', 'GameMode', gnGameMode
);
1017 config
.WriteInt ('GameplayNetwork', 'TimeLimit', gnTimeLimit
);
1018 config
.WriteInt ('GameplayNetwork', 'GoalLimit', gnGoalLimit
);
1019 config
.WriteInt ('GameplayNetwork', 'MaxLives', gnMaxLives
);
1020 config
.WriteInt ('GameplayNetwork', 'Players', gnPlayers
);
1021 config
.WriteBool('GameplayNetwork', 'TeamDamage', gnTeamDamage
);
1022 config
.WriteBool('GameplayNetwork', 'AllowExit', gnAllowExit
);
1023 config
.WriteBool('GameplayNetwork', 'WeaponStay', gnWeaponStay
);
1024 config
.WriteBool('GameplayNetwork', 'Monsters', gnMonsters
);
1025 config
.WriteStr ('GameplayNetwork', 'BotsVS', gnBotsVS
);
1027 config
.SaveFile(FileName
);
1031 procedure g_Options_Write_Net_Server(FileName
: String);
1035 e_WriteLog('Writing server config', TMsgType
.Notify
);
1037 config
:= TConfig
.CreateFile(FileName
);
1039 config
.WriteStr ('Server', 'Name', NetServerName
);
1040 config
.WriteStr ('Server', 'Password', NetPassword
);
1041 config
.WriteInt ('Server', 'Port', NetPort
);
1042 config
.WriteInt ('Server', 'MaxClients', NetMaxClients
);
1043 config
.WriteBool('Server', 'SyncWithMaster', NetUseMaster
);
1044 config
.WriteBool('Server', 'ForwardPorts', NetForwardPorts
);
1046 config
.SaveFile(FileName
);
1050 procedure g_Options_Write_Net_Client(FileName
: String);
1054 e_WriteLog('Writing client config', TMsgType
.Notify
);
1056 config
:= TConfig
.CreateFile(FileName
);
1058 config
.WriteStr('Client', 'LastIP', NetClientIP
);
1059 config
.WriteInt('Client', 'LastPort', NetClientPort
);
1061 config
.SaveFile(FileName
);
1066 machine
:= Random(10000)