506fc186424753429b21151925830bb1a0b6376d
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
;
151 if Result
= '' then Result
:= 'Player' + IntToStr(machine
MOD 10000);
152 if n
> 1 then Result
:= Copy(Result
, 1, 10) + (' ' + IntToStr(n
))
155 procedure g_Options_SetDefaultVideo
;
157 target
, closest
, display
: TSDL_DisplayMode
;
160 (* Display 0 = Primary display *)
161 SDL_GetDesktopDisplayMode(0, @display
);
162 {$IF DEFINED(ANDROID)}
163 gScreenWidth
:= display
.w
;
164 gScreenHeight
:= display
.h
;
165 //gBPP := SDL_BITSPERPIXEL(dispaly.format);
167 gFullScreen
:= True; (* rotation not allowed? *)
169 (* Window must be smaller than display *)
170 closest
.w
:= display
.w
;
171 closest
.h
:= display
.h
;
173 while (display
.w
- closest
.w
< 48) or (display
.h
- closest
.h
< 48) do
175 if percentage
< 25 then
177 closest
.w
:= display
.w
* 75 div 100;
178 closest
.h
:= display
.h
* 75 div 100;
181 target
.w
:= display
.w
* percentage
div 100;
182 target
.h
:= display
.h
* percentage
div 100;
183 target
.format
:= 0; (* didn't care *)
184 target
.refresh_rate
:= 0; (* didn't care *)
185 target
.driverdata
:= nil; (* init *)
186 SDL_GetClosestDisplayMode(0, @target
, @closest
);
189 gScreenWidth
:= closest
.w
;
190 gScreenHeight
:= closest
.h
;
191 //gBPP := SDL_BITSPERPIXEL(closest.format); (* Resolution list didn't work for some reason *)
193 gFullScreen
:= False;
195 (* Must be positioned on primary display *)
196 gWinRealPosX
:= SDL_WINDOWPOS_CENTERED
;
197 gWinRealPosY
:= SDL_WINDOWPOS_CENTERED
;
198 gWinMaximized
:= False;
200 gTextureFilter
:= True;
201 glLegacyNPOT
:= False;
202 e_LogWriteLn('g_Options_SetDefaultVideo: w = ' + IntToStr(gScreenWidth
) + ' h = ' + IntToStr(gScreenHeight
));
205 procedure g_Options_SetDefault();
214 gMuteWhenInactive
:= False;
215 gAnnouncer
:= ANNOUNCE_MEPLUS
;
216 gSoundEffectsDF
:= True;
217 gUseChatSounds
:= True;
218 gsSDLSampleRate
:= 44100;
219 gsSDLBufferSize
:= 2048;
221 g_Sound_SetupAllVolumes(gSoundLevel
, gMusicLevel
);
223 (* section GameControls *)
224 with gGameControls
.GameControls
do
226 TakeScreenshot
:= SDL_SCANCODE_F12
;
227 Stat
:= SDL_SCANCODE_TAB
;
228 Chat
:= SDL_SCANCODE_T
;
229 TeamChat
:= SDL_SCANCODE_Y
;
232 (* section Player1 *)
233 with gGameControls
.P1Control
do
235 KeyRight
:= SDL_SCANCODE_KP_6
;
236 KeyLeft
:= SDL_SCANCODE_KP_4
;
237 KeyUp
:= SDL_SCANCODE_KP_8
;
238 KeyDown
:= SDL_SCANCODE_KP_5
;
239 KeyFire
:= SDL_SCANCODE_SLASH
;
240 KeyJump
:= SDL_SCANCODE_RCTRL
;
241 KeyNextWeapon
:= SDL_SCANCODE_KP_9
;
242 KeyPrevWeapon
:= SDL_SCANCODE_KP_7
;
243 KeyOpen
:= SDL_SCANCODE_RSHIFT
;
244 KeyStrafe
:= SDL_SCANCODE_PERIOD
;
248 KeyWeapon
[i
] := SDL_SCANCODE_1
+ i (* 1, ..., 9, 0 *)
250 KeyWeapon
[10] := SDL_SCANCODE_MINUS
;
251 for i
:= 11 to High(KeyWeapon
) do
256 KeyRight2
:= VK_RIGHT
;
262 KeyNextWeapon2
:= VK_NEXT
;
263 KeyPrevWeapon2
:= VK_PREV
;
265 KeyStrafe2
:= VK_STRAFE
;
267 for i
:= 0 to High(KeyWeapon2
) do
269 KeyWeapon2
[i
] := VK_0
+ i
273 with gPlayer1Settings
do
275 Name
:= GenPlayerName(1);
276 Model
:= STD_PLAYER_MODEL
;
277 Color
.R
:= PLAYER1_DEF_COLOR
.R
;
278 Color
.G
:= PLAYER1_DEF_COLOR
.G
;
279 Color
.B
:= PLAYER1_DEF_COLOR
.B
;
283 (* section Player2 *)
284 with gGameControls
.P2Control
do
286 KeyRight
:= SDL_SCANCODE_D
;
287 KeyLeft
:= SDL_SCANCODE_A
;
288 KeyUp
:= SDL_SCANCODE_W
;
289 KeyDown
:= SDL_SCANCODE_S
;
290 KeyFire
:= SDL_SCANCODE_G
;
291 KeyJump
:= SDL_SCANCODE_SPACE
;
292 KeyNextWeapon
:= SDL_SCANCODE_E
;
293 KeyPrevWeapon
:= SDL_SCANCODE_Q
;
294 KeyOpen
:= SDL_SCANCODE_F
;
295 KeyStrafe
:= SDL_SCANCODE_LSHIFT
;
296 for i
:= 0 to High(KeyWeapon
) do
312 for i
:= 0 to High(KeyWeapon2
) do
318 with gPlayer2Settings
do
320 Name
:= GenPlayerName(2);
321 Model
:= STD_PLAYER_MODEL
;
322 Color
.R
:= PLAYER2_DEF_COLOR
.R
;
323 Color
.G
:= PLAYER2_DEF_COLOR
.G
;
324 Color
.B
:= PLAYER2_DEF_COLOR
.B
;
328 (* section Joysticks *)
329 for i
:= 0 to e_MaxJoys
- 1 do
331 e_JoystickDeadzones
[i
] := 8192
336 g_touch_fire
:= True;
337 g_touch_offset
:= 50;
338 g_touch_alt
:= False;
342 g_Shells_SetMax(300);
344 g_Corpses_SetMax(20);
346 ITEM_RESPAWNTIME
:= 60 * 36;
352 gDrawBackGround
:= True;
353 gShowMessages
:= True;
354 gRevertPlayers
:= False;
357 gSFSFastMode
:= False;
358 e_FastScreenshots
:= True;
359 gDefaultMegawadStart
:= DF_Default_Megawad_Start
;
360 gBerserkAutoswitch
:= True;
363 gAskLanguage
:= True;
364 gLanguage
:= LANGUAGE_ENGLISH
;
366 (* section GameplayCustom *)
368 gcGameMode
:= _lc
[I_MENU_GAME_TYPE_DM
];
373 gcTeamDamage
:= False;
375 gcWeaponStay
:= False;
377 gcBotsVS
:= 'Everybody';
379 (* section GameplayNetwork *)
381 gnGameMode
:= _lc
[I_MENU_GAME_TYPE_DM
];
386 gnTeamDamage
:= False;
388 gnWeaponStay
:= False;
390 gnBotsVS
:= 'Everybody';
392 (* section MasterServer *)
393 NetSlistIP
:= 'mpms.doom2d.org';
394 NetSlistPort
:= 25665;
395 g_Net_Slist_Set(NetSlistIP
, NetSlistPort
);
398 NetServerName
:= 'Unnamed Server';
402 NetAllowRCON
:= False;
403 NetRCONPassword
:= 'default';
404 NetUseMaster
:= True;
407 NetMasterRate
:= 60000;
408 NetForwardPorts
:= False;
412 NetForcePlayerUpdate
:= False;
413 NetPredictSelf
:= True;
414 NetClientIP
:= '127.0.0.1';
415 NetClientPort
:= NetPort
;
418 procedure g_Options_Read(FileName
: String);
424 procedure ReadInteger (VAR v
: Integer; param
: String; minv
: Integer = Low(Integer); maxv
: Integer = High(Integer));
426 v
:= Max(Min(config
.ReadInt(section
, param
, v
), maxv
), minv
)
429 procedure ReadInteger (VAR v
: LongWord; param
: String; minv
: LongWord = Low(LongWord); maxv
: LongWord = High(LongWord)); overload
;
431 v
:= Max(Min(config
.ReadInt(section
, param
, v
), maxv
), minv
)
434 procedure ReadInteger (VAR v
: Word; param
: String; minv
: Word = Low(Word); maxv
: Word = High(Word)); overload
;
436 v
:= Max(Min(config
.ReadInt(section
, param
, v
), maxv
), minv
)
439 procedure ReadInteger (VAR v
: Byte; param
: String; minv
: Byte = Low(Byte); maxv
: Byte = High(Byte)); overload
;
441 v
:= Max(Min(config
.ReadInt(section
, param
, v
), maxv
), minv
)
444 procedure ReadBoolean (VAR v
: Boolean; param
: String);
446 v
:= config
.ReadBool(section
, param
, v
)
449 procedure ReadString (VAR v
: String; param
: String);
451 v
:= config
.ReadStr(section
, param
, v
)
455 gAskLanguage
:= True;
456 e_WriteLog('Reading config', TMsgType
.Notify
);
457 g_Options_SetDefault
;
459 if FileExists(FileName
) = False then
461 e_WriteLog('Config file '+FileName
+' not found', TMsgType
.Warning
);
462 g_Options_SetDefaultVideo
;
466 config
:= TConfig
.CreateFile(FileName
);
469 ReadInteger(gScreenWidth
, 'ScreenWidth', 0);
470 ReadInteger(gScreenHeight
, 'ScreenHeight', 0);
471 ReadInteger(gWinRealPosX
, 'WinPosX', 60);
472 ReadInteger(gWinRealPosY
, 'WinPosY', 60);
473 ReadBoolean(gFullScreen
, 'Fullscreen');
474 ReadBoolean(gWinMaximized
, 'Maximized');
475 ReadInteger(gBPP
, 'BPP', 0);
476 ReadInteger(gFreq
, 'Freq', 0);
477 ReadBoolean(gVSync
, 'VSync');
478 ReadBoolean(gTextureFilter
, 'TextureFilter');
479 ReadBoolean(glLegacyNPOT
, 'LegacyCompatible');
482 ReadBoolean(gNoSound
, 'NoSound');
483 ReadInteger(gSoundLevel
, 'SoundLevel', 0, 255);
484 ReadInteger(gMusicLevel
, 'MusicLevel', 0, 255);
485 ReadInteger(gMaxSimSounds
, 'MaxSimSounds', 2, 66);
486 ReadBoolean(gMuteWhenInactive
, 'MuteInactive');
487 ReadInteger(gAnnouncer
, 'Announcer', ANNOUNCE_NONE
, ANNOUNCE_ALL
);
488 ReadBoolean(gSoundEffectsDF
, 'SoundEffectsDF');
489 ReadBoolean(gUseChatSounds
, 'ChatSounds');
490 ReadInteger(gsSDLSampleRate
, 'SDLSampleRate', 11025, 96000);
491 ReadInteger(gsSDLBufferSize
, 'SDLBufferSize', 64, 16384);
493 section
:= 'GameControls';
494 with gGameControls
.GameControls
do
496 ReadInteger(TakeScreenshot
, 'TakeScreenshot');
497 ReadInteger(Stat
, 'Stat');
498 ReadInteger(Chat
, 'Chat');
499 ReadInteger(TeamChat
, 'TeamChat');
502 section
:= 'Player1';
503 with gGameControls
.P1Control
do
505 ReadInteger(KeyRight
, 'KeyRight');
506 ReadInteger(KeyLeft
, 'KeyLeft');
507 ReadInteger(KeyUp
, 'KeyUp');
508 ReadInteger(KeyDown
, 'KeyDown');
509 ReadInteger(KeyFire
, 'KeyFire');
510 ReadInteger(KeyJump
, 'KeyJump');
511 ReadInteger(KeyNextWeapon
, 'KeyNextWeapon');
512 ReadInteger(KeyPrevWeapon
, 'KeyPrevWeapon');
513 ReadInteger(KeyOpen
, 'KeyOpen');
514 ReadInteger(KeyStrafe
, 'KeyStrafe');
516 for i
:= 0 to High(KeyWeapon
) do
518 ReadInteger(KeyWeapon
[i
], 'KeyWeapon' + IntToStr(i
))
521 ReadInteger(KeyRight2
, 'KeyRight2');
522 ReadInteger(KeyLeft2
, 'KeyLeft2');
523 ReadInteger(KeyUp2
, 'KeyUp2');
524 ReadInteger(KeyDown2
, 'KeyDown2');
525 ReadInteger(KeyFire2
, 'KeyFire2');
526 ReadInteger(KeyJump2
, 'KeyJump2');
527 ReadInteger(KeyNextWeapon2
, 'KeyNextWeapon2');
528 ReadInteger(KeyPrevWeapon2
, 'KeyPrevWeapon2');
529 ReadInteger(KeyOpen2
, 'KeyOpen2');
530 ReadInteger(KeyStrafe2
, 'KeyStrafe2');
532 for i
:= 0 to High(KeyWeapon2
) do
534 ReadInteger(KeyWeapon2
[i
], 'KeyWeapon2' + IntToStr(i
))
538 section
:= 'Player1';
539 with gPlayer1Settings
do
541 ReadString(Name
, 'name');
542 ReadString(Model
, 'model');
543 ReadInteger(Color
.R
, 'red', 0, 255);
544 ReadInteger(Color
.G
, 'green', 0, 255);
545 ReadInteger(Color
.B
, 'blue', 0, 255);
546 ReadInteger(Team
, 'team');
547 if (Team
< TEAM_RED
) or (Team
> TEAM_BLUE
) then
551 section
:= 'Player2';
552 with gGameControls
.P2Control
do
554 ReadInteger(KeyRight
, 'KeyRight');
555 ReadInteger(KeyLeft
, 'KeyLeft');
556 ReadInteger(KeyUp
, 'KeyUp');
557 ReadInteger(KeyDown
, 'KeyDown');
558 ReadInteger(KeyFire
, 'KeyFire');
559 ReadInteger(KeyJump
, 'KeyJump');
560 ReadInteger(KeyNextWeapon
, 'KeyNextWeapon');
561 ReadInteger(KeyPrevWeapon
, 'KeyPrevWeapon');
562 ReadInteger(KeyOpen
, 'KeyOpen');
563 ReadInteger(KeyStrafe
, 'KeyStrafe');
565 for i
:= 0 to High(KeyWeapon
) do
567 ReadInteger(KeyWeapon
[i
], 'KeyWeapon' + IntToStr(i
))
570 ReadInteger(KeyRight2
, 'KeyRight2');
571 ReadInteger(KeyLeft2
, 'KeyLeft2');
572 ReadInteger(KeyUp2
, 'KeyUp2');
573 ReadInteger(KeyDown2
, 'KeyDown2');
574 ReadInteger(KeyFire2
, 'KeyFire2');
575 ReadInteger(KeyJump2
, 'KeyJump2');
576 ReadInteger(KeyNextWeapon2
, 'KeyNextWeapon2');
577 ReadInteger(KeyPrevWeapon2
, 'KeyPrevWeapon2');
578 ReadInteger(KeyOpen2
, 'KeyOpen2');
579 ReadInteger(KeyStrafe2
, 'KeyStrafe2');
581 for i
:= 0 to High(KeyWeapon2
) do
583 ReadInteger(KeyWeapon2
[i
], 'KeyWeapon2' + IntToStr(i
))
587 section
:= 'Player2';
588 with gPlayer2Settings
do
590 ReadString(Name
, 'name');
591 ReadString(Model
, 'model');
592 ReadInteger(Color
.R
, 'red', 0, 255);
593 ReadInteger(Color
.G
, 'green', 0, 255);
594 ReadInteger(Color
.B
, 'blue', 0, 255);
595 ReadInteger(Team
, 'team');
596 if (Team
< TEAM_RED
) or (Team
> TEAM_BLUE
) then
600 section
:= 'Joysticks';
601 for i
:= 0 to e_MaxJoys
- 1 do
603 ReadInteger(e_JoystickDeadzones
[i
], 'Deadzone' + IntToStr(i
))
607 i
:= Trunc(g_touch_size
* 10); ReadInteger(i
, 'Size', 0); g_touch_size
:= i
/ 10;
608 ReadBoolean(g_touch_fire
, 'Fire');
609 i
:= Round(g_touch_offset
); ReadInteger(i
, 'Offset', 0, 100); g_touch_offset
:= i
;
610 ReadBoolean(g_touch_alt
, 'Alt');
613 ReadInteger(i
, 'MaxParticles', 1000, 50000); g_GFX_SetMax(i
);
614 ReadInteger(i
, 'MaxShells', 300, 600); g_Shells_SetMax(i
);
615 ReadInteger(i
, 'MaxGibs', 150, 500); g_Gibs_SetMax(i
);
616 ReadInteger(i
, 'MaxCorpses', 20, 100); g_Corpses_SetMax(i
);
617 ReadInteger(i
, 'GibsCount');
623 else gGibsCount
:= 48;
625 i
:= ITEM_RESPAWNTIME
div 36; ReadInteger(i
, 'ItemRespawnTime', 0); ITEM_RESPAWNTIME
:= i
* 36;
626 ReadInteger(gBloodCount
, 'BloodCount', 0, 4);
627 ReadBoolean(gAdvBlood
, 'AdvancesBlood');
628 ReadBoolean(gAdvCorpses
, 'AdvancesCorpses');
629 ReadBoolean(gAdvGibs
, 'AdvancesGibs');
630 ReadInteger(gFlash
, 'Flash', 0, 2);
631 ReadBoolean(gDrawBackGround
, 'BackGround');
632 ReadBoolean(gShowMessages
, 'Messages');
633 ReadBoolean(gRevertPlayers
, 'RevertPlayers');
634 ReadInteger(gChatBubble
, 'ChatBubble', 0, 4);
635 ReadBoolean(gSFSDebug
, 'SFSDebug'); wadoptDebug
:= gSFSDebug
;
636 ReadBoolean(gSFSFastMode
, 'SFSFastMode'); wadoptFast
:= gSFSFastMode
;
637 ReadBoolean(e_FastScreenshots
, 'FastScreenshots');
638 ReadString(gDefaultMegawadStart
, 'DefaultMegawadStart');
639 ReadBoolean(gBerserkAutoswitch
, 'BerserkAutoswitching');
640 i
:= Trunc(g_dbg_scale
* 100); ReadInteger(i
, 'Scale', 100); g_dbg_scale
:= i
/ 100;
641 ReadString(gLanguage
, 'Language');
642 if (gLanguage
= LANGUAGE_RUSSIAN
) or (gLanguage
= LANGUAGE_ENGLISH
) then
643 gAskLanguage
:= False
645 gLanguage
:= LANGUAGE_ENGLISH
;
647 section
:= 'GameplayCustom';
648 ReadString(gcMap
, 'Map');
649 ReadString(gcGameMode
, 'GameMode');
650 ReadInteger(gcTimeLimit
, 'TimeLimit', 0, 65535);
651 ReadInteger(gcGoalLimit
, 'GoalLimit', 0, 65535);
652 ReadInteger(gcMaxLives
, 'MaxLives', 0, 255);
653 ReadInteger(gcPlayers
, 'Players', 0, 2);
654 ReadBoolean(gcTeamDamage
, 'TeamDamage');
655 ReadBoolean(gcAllowExit
, 'AllowExit');
656 ReadBoolean(gcWeaponStay
, 'WeaponStay');
657 ReadBoolean(gcMonsters
, 'Monsters');
658 ReadString(gcBotsVS
, 'BotsVS');
660 with gGameSettings
do
662 GameMode
:= g_Game_TextToMode(gcGameMode
);
663 if GameMode
= GM_NONE
then
665 if GameMode
= GM_SINGLE
then
667 TimeLimit
:= gcTimeLimit
;
668 GoalLimit
:= gcGoalLimit
;
669 MaxLives
:= gcMaxLives
;
673 Options
:= Options
or GAME_OPTION_TEAMDAMAGE
;
675 Options
:= Options
or GAME_OPTION_ALLOWEXIT
;
677 Options
:= Options
or GAME_OPTION_WEAPONSTAY
;
679 Options
:= Options
or GAME_OPTION_MONSTERS
;
680 if gcBotsVS
= 'Everybody' then
681 Options
:= Options
or GAME_OPTION_BOTVSPLAYER
or GAME_OPTION_BOTVSMONSTER
;
682 if gcBotsVS
= 'Players' then
683 Options
:= Options
or GAME_OPTION_BOTVSPLAYER
;
684 if gcBotsVS
= 'Monsters' then
685 Options
:= Options
or GAME_OPTION_BOTVSMONSTER
;
688 section
:= 'GameplayNetwork';
689 ReadString(gnMap
, 'Map');
690 ReadString(gnGameMode
, 'GameMode');
691 ReadInteger(gnTimeLimit
, 'TimeLimit', 0, 65535);
692 ReadInteger(gnGoalLimit
, 'GoalLimit', 0, 65535);
693 ReadInteger(gnMaxLives
, 'MaxLives', 0, 255);
694 ReadInteger(gnPlayers
, 'Players', 0, 2);
695 ReadBoolean(gnTeamDamage
, 'TeamDamage');
696 ReadBoolean(gnAllowExit
, 'AllowExit');
697 ReadBoolean(gnWeaponStay
, 'WeaponStay');
698 ReadBoolean(gnMonsters
, 'Monsters');
699 ReadString(gnBotsVS
, 'BotsVS');
701 section
:= 'MasterServer';
702 ReadString(NetSlistIP
, 'IP');
703 ReadInteger(NetSlistPort
, 'Port', 0, 65535);
704 g_Net_Slist_Set(NetSlistIP
, NetSlistPort
);
707 ReadString(NetServerName
, 'Name');
708 ReadString(NetPassword
, 'Password');
709 ReadInteger(NetPort
, 'Port', 0, 65535);
710 ReadInteger(NetMaxClients
, 'MaxClients', 0, NET_MAXCLIENTS
);
711 ReadBoolean(NetAllowRCON
, 'RCON');
712 ReadString(NetRCONPassword
, 'RCONPassword');
713 ReadBoolean(NetUseMaster
, 'SyncWithMaster');
714 ReadInteger(NetUpdateRate
, 'UpdateInterval', 0);
715 ReadInteger(NetRelupdRate
, 'ReliableUpdateInterval', 0);
716 ReadInteger(NetMasterRate
, 'MasterSyncInterval', 1);
717 ReadBoolean(NetForwardPorts
, 'ForwardPorts');
720 ReadInteger(NetInterpLevel
, 'InterpolationSteps', 0);
721 ReadBoolean(NetForcePlayerUpdate
, 'ForcePlayerUpdate');
722 ReadBoolean(NetPredictSelf
, 'PredictSelf');
723 ReadString(NetClientIP
, 'LastIP');
724 ReadInteger(NetClientPort
, 'LastPort', 0, 65535);
728 //if gTextureFilter then TEXTUREFILTER := GL_LINEAR else TEXTUREFILTER := GL_NEAREST;
731 procedure g_Options_Write(FileName
: String);
736 e_WriteLog('Writing config', TMsgType
.Notify
);
738 config
:= TConfig
.CreateFile(FileName
);
740 config
.WriteInt('Video', 'ScreenWidth', gScreenWidth
);
741 config
.WriteInt('Video', 'ScreenHeight', gScreenHeight
);
742 config
.WriteInt('Video', 'WinPosX', gWinRealPosX
);
743 config
.WriteInt('Video', 'WinPosY', gWinRealPosY
);
744 config
.WriteBool('Video', 'Fullscreen', gFullScreen
);
745 config
.WriteBool('Video', 'Maximized', gWinMaximized
);
746 config
.WriteInt('Video', 'BPP', gBPP
);
747 config
.WriteBool('Video', 'VSync', gVSync
);
748 config
.WriteBool('Video', 'TextureFilter', gTextureFilter
);
749 config
.WriteBool('Video', 'LegacyCompatible', glLegacyNPOT
);
751 config
.WriteBool('Sound', 'NoSound', gNoSound
);
752 config
.WriteInt('Sound', 'SoundLevel', gSoundLevel
);
753 config
.WriteInt('Sound', 'MusicLevel', gMusicLevel
);
754 config
.WriteInt('Sound', 'MaxSimSounds', gMaxSimSounds
);
755 config
.WriteBool('Sound', 'MuteInactive', gMuteWhenInactive
);
756 config
.WriteInt('Sound', 'Announcer', gAnnouncer
);
757 config
.WriteBool('Sound', 'SoundEffectsDF', gSoundEffectsDF
);
758 config
.WriteBool('Sound', 'ChatSounds', gUseChatSounds
);
759 config
.WriteInt('Sound', 'SDLSampleRate', gsSDLSampleRate
);
760 config
.WriteInt('Sound', 'SDLBufferSize', gsSDLBufferSize
);
762 with config
, gGameControls
.GameControls
do
764 WriteInt('GameControls', 'TakeScreenshot', TakeScreenshot
);
765 WriteInt('GameControls', 'Stat', Stat
);
766 WriteInt('GameControls', 'Chat', Chat
);
767 WriteInt('GameControls', 'TeamChat', TeamChat
);
770 with config
, gGameControls
.P1Control
, gPlayer1Settings
do
772 WriteInt('Player1', 'KeyRight', KeyRight
);
773 WriteInt('Player1', 'KeyLeft', KeyLeft
);
774 WriteInt('Player1', 'KeyUp', KeyUp
);
775 WriteInt('Player1', 'KeyDown', KeyDown
);
776 WriteInt('Player1', 'KeyFire', KeyFire
);
777 WriteInt('Player1', 'KeyJump', KeyJump
);
778 WriteInt('Player1', 'KeyNextWeapon', KeyNextWeapon
);
779 WriteInt('Player1', 'KeyPrevWeapon', KeyPrevWeapon
);
780 WriteInt('Player1', 'KeyOpen', KeyOpen
);
781 WriteInt('Player1', 'KeyStrafe', KeyStrafe
);
782 for i
:= 0 to High(KeyWeapon
) do
783 WriteInt('Player1', 'KeyWeapon' + IntToStr(i
), KeyWeapon
[i
]);
785 WriteInt('Player1', 'KeyRight2', KeyRight2
);
786 WriteInt('Player1', 'KeyLeft2', KeyLeft2
);
787 WriteInt('Player1', 'KeyUp2', KeyUp2
);
788 WriteInt('Player1', 'KeyDown2', KeyDown2
);
789 WriteInt('Player1', 'KeyFire2', KeyFire2
);
790 WriteInt('Player1', 'KeyJump2', KeyJump2
);
791 WriteInt('Player1', 'KeyNextWeapon2', KeyNextWeapon2
);
792 WriteInt('Player1', 'KeyPrevWeapon2', KeyPrevWeapon2
);
793 WriteInt('Player1', 'KeyOpen2', KeyOpen2
);
794 WriteInt('Player1', 'KeyStrafe2', KeyStrafe2
);
795 for i
:= 0 to High(KeyWeapon2
) do
796 WriteInt('Player1', 'KeyWeapon2' + IntToStr(i
), KeyWeapon2
[i
]);
798 WriteStr('Player1', 'Name', Name
);
799 WriteStr('Player1', 'model', Model
);
800 WriteInt('Player1', 'red', Color
.R
);
801 WriteInt('Player1', 'green', Color
.G
);
802 WriteInt('Player1', 'blue', Color
.B
);
803 WriteInt('Player1', 'team', Team
);
806 with config
, gGameControls
.P2Control
, gPlayer2Settings
do
808 WriteInt('Player2', 'KeyRight', KeyRight
);
809 WriteInt('Player2', 'KeyLeft', KeyLeft
);
810 WriteInt('Player2', 'KeyUp', KeyUp
);
811 WriteInt('Player2', 'KeyDown', KeyDown
);
812 WriteInt('Player2', 'KeyFire', KeyFire
);
813 WriteInt('Player2', 'KeyJump', KeyJump
);
814 WriteInt('Player2', 'KeyNextWeapon', KeyNextWeapon
);
815 WriteInt('Player2', 'KeyPrevWeapon', KeyPrevWeapon
);
816 WriteInt('Player2', 'KeyOpen', KeyOpen
);
817 WriteInt('Player2', 'KeyStrafe', KeyStrafe
);
818 for i
:= 0 to High(KeyWeapon
) do
819 WriteInt('Player2', 'KeyWeapon' + IntToStr(i
), KeyWeapon
[i
]);
821 WriteInt('Player2', 'KeyRight2', KeyRight2
);
822 WriteInt('Player2', 'KeyLeft2', KeyLeft2
);
823 WriteInt('Player2', 'KeyUp2', KeyUp2
);
824 WriteInt('Player2', 'KeyDown2', KeyDown2
);
825 WriteInt('Player2', 'KeyFire2', KeyFire2
);
826 WriteInt('Player2', 'KeyJump2', KeyJump2
);
827 WriteInt('Player2', 'KeyNextWeapon2', KeyNextWeapon2
);
828 WriteInt('Player2', 'KeyPrevWeapon2', KeyPrevWeapon2
);
829 WriteInt('Player2', 'KeyOpen2', KeyOpen2
);
830 WriteInt('Player2', 'KeyStrafe2', KeyStrafe2
);
831 for i
:= 0 to High(KeyWeapon2
) do
832 WriteInt('Player2', 'KeyWeapon2' + IntToStr(i
), KeyWeapon2
[i
]);
834 WriteStr('Player2', 'Name', Name
);
835 WriteStr('Player2', 'model', Model
);
836 WriteInt('Player2', 'red', Color
.R
);
837 WriteInt('Player2', 'green', Color
.G
);
838 WriteInt('Player2', 'blue', Color
.B
);
839 WriteInt('Player2', 'team', Team
);
842 for i
:= 0 to e_MaxJoys
-1 do
843 config
.WriteInt('Joysticks', 'Deadzone' + IntToStr(i
), e_JoystickDeadzones
[i
]);
845 config
.WriteInt('Touch', 'Size', Round(g_touch_size
* 10));
846 config
.WriteBool('Touch', 'Fire', g_touch_fire
);
847 config
.WriteInt('Touch', 'Offset', Round(g_touch_offset
));
848 config
.WriteBool('Touch', 'Alt', g_touch_alt
);
852 0: config
.WriteInt('Game', 'GibsCount', 0);
853 8: config
.WriteInt('Game', 'GibsCount', 1);
854 16: config
.WriteInt('Game', 'GibsCount', 2);
855 32: config
.WriteInt('Game', 'GibsCount', 3);
856 else config
.WriteInt('Game', 'GibsCount', 4);
859 config
.WriteInt('Game', 'ItemRespawnTime', ITEM_RESPAWNTIME
div 36);
860 config
.WriteInt('Game', 'MaxParticles', g_GFX_GetMax());
861 config
.WriteInt('Game', 'MaxShells', g_Shells_GetMax());
862 config
.WriteInt('Game', 'MaxGibs', g_Gibs_GetMax());
863 config
.WriteInt('Game', 'MaxCorpses', g_Corpses_GetMax());
864 config
.WriteInt('Game', 'BloodCount', gBloodCount
);
865 config
.WriteBool('Game', 'AdvancesBlood', gAdvBlood
);
866 config
.WriteBool('Game', 'AdvancesCorpses', gAdvCorpses
);
867 config
.WriteBool('Game', 'AdvancesGibs', gAdvGibs
);
868 config
.WriteInt('Game', 'Flash', gFlash
);
869 config
.WriteBool('Game', 'BackGround', gDrawBackGround
);
870 config
.WriteBool('Game', 'Messages', gShowMessages
);
871 config
.WriteBool('Game', 'RevertPlayers', gRevertPlayers
);
872 config
.WriteInt('Game', 'ChatBubble', gChatBubble
);
873 config
.WriteBool('Game', 'SFSDebug', gSFSDebug
);
874 config
.WriteBool('Game', 'SFSFastMode', gSFSFastMode
);
875 config
.WriteBool('Game', 'FastScreenshots', e_FastScreenshots
);
876 config
.WriteStr('Game', 'DefaultMegawadStart', gDefaultMegawadStart
);
877 config
.WriteBool('Game', 'BerserkAutoswitching', gBerserkAutoswitch
);
878 config
.WriteInt('Game', 'Scale', Round(g_dbg_scale
* 100));
880 config
.WriteStr ('GameplayCustom', 'Map', gcMap
);
881 config
.WriteStr ('GameplayCustom', 'GameMode', gcGameMode
);
882 config
.WriteInt ('GameplayCustom', 'TimeLimit', gcTimeLimit
);
883 config
.WriteInt ('GameplayCustom', 'GoalLimit', gcGoalLimit
);
884 config
.WriteInt ('GameplayCustom', 'MaxLives', gcMaxLives
);
885 config
.WriteInt ('GameplayCustom', 'Players', gcPlayers
);
886 config
.WriteBool('GameplayCustom', 'TeamDamage', gcTeamDamage
);
887 config
.WriteBool('GameplayCustom', 'AllowExit', gcAllowExit
);
888 config
.WriteBool('GameplayCustom', 'WeaponStay', gcWeaponStay
);
889 config
.WriteBool('GameplayCustom', 'Monsters', gcMonsters
);
890 config
.WriteStr ('GameplayCustom', 'BotsVS', gcBotsVS
);
892 config
.WriteStr ('GameplayNetwork', 'Map', gnMap
);
893 config
.WriteStr ('GameplayNetwork', 'GameMode', gnGameMode
);
894 config
.WriteInt ('GameplayNetwork', 'TimeLimit', gnTimeLimit
);
895 config
.WriteInt ('GameplayNetwork', 'GoalLimit', gnGoalLimit
);
896 config
.WriteInt ('GameplayNetwork', 'MaxLives', gnMaxLives
);
897 config
.WriteInt ('GameplayNetwork', 'Players', gnPlayers
);
898 config
.WriteBool('GameplayNetwork', 'TeamDamage', gnTeamDamage
);
899 config
.WriteBool('GameplayNetwork', 'AllowExit', gnAllowExit
);
900 config
.WriteBool('GameplayNetwork', 'WeaponStay', gnWeaponStay
);
901 config
.WriteBool('GameplayNetwork', 'Monsters', gnMonsters
);
902 config
.WriteStr ('GameplayNetwork', 'BotsVS', gnBotsVS
);
904 config
.WriteStr('MasterServer', 'IP', NetSlistIP
);
905 config
.WriteInt('MasterServer', 'Port', NetSlistPort
);
907 config
.WriteStr ('Server', 'Name', NetServerName
);
908 config
.WriteStr ('Server', 'Password', NetPassword
);
909 config
.WriteInt ('Server', 'Port', NetPort
);
910 config
.WriteInt ('Server', 'MaxClients', NetMaxClients
);
911 config
.WriteBool('Server', 'RCON', NetAllowRCON
);
912 config
.WriteStr ('Server', 'RCONPassword', NetRCONPassword
);
913 config
.WriteBool('Server', 'SyncWithMaster', NetUseMaster
);
914 config
.WriteBool('Server', 'ForwardPorts', NetForwardPorts
);
915 config
.WriteInt ('Server', 'UpdateInterval', NetUpdateRate
);
916 config
.WriteInt ('Server', 'ReliableUpdateInterval', NetRelupdRate
);
917 config
.WriteInt ('Server', 'MasterSyncInterval', NetMasterRate
);
919 config
.WriteInt ('Client', 'InterpolationSteps', NetInterpLevel
);
920 config
.WriteBool ('Client', 'ForcePlayerUpdate', NetForcePlayerUpdate
);
921 config
.WriteBool ('Client', 'PredictSelf', NetPredictSelf
);
922 config
.WriteStr ('Client', 'LastIP', NetClientIP
);
923 config
.WriteInt ('Client', 'LastPort', NetClientPort
);
925 config
.SaveFile(FileName
);
929 procedure g_Options_Write_Language(FileName
: String);
933 e_WriteLog('Writing language config', TMsgType
.Notify
);
935 config
:= TConfig
.CreateFile(FileName
);
936 config
.WriteStr('Game', 'Language', gLanguage
);
937 config
.SaveFile(FileName
);
941 procedure g_Options_Write_Video(FileName
: String);
946 e_WriteLog('Writing resolution to config', TMsgType
.Notify
);
948 config
:= TConfig
.CreateFile(FileName
);
950 if gWinMaximized
and (not gFullscreen
) then
960 e_LogWritefln(' (ws=%dx%d) (ss=%dx%d)', [gWinSizeX
, gWinSizeY
, gScreenWidth
, gScreenHeight
]);
962 config
.WriteInt('Video', 'ScreenWidth', sW
);
963 config
.WriteInt('Video', 'ScreenHeight', sH
);
964 config
.WriteInt('Video', 'WinPosX', gWinRealPosX
);
965 config
.WriteInt('Video', 'WinPosY', gWinRealPosY
);
966 config
.WriteBool('Video', 'Fullscreen', gFullscreen
);
967 config
.WriteBool('Video', 'Maximized', gWinMaximized
);
969 config
.SaveFile(FileName
);
973 procedure g_Options_Write_Gameplay_Custom(FileName
: String);
977 e_WriteLog('Writing custom gameplay config', TMsgType
.Notify
);
979 config
:= TConfig
.CreateFile(FileName
);
981 config
.WriteStr ('GameplayCustom', 'Map', gcMap
);
982 config
.WriteStr ('GameplayCustom', 'GameMode', gcGameMode
);
983 config
.WriteInt ('GameplayCustom', 'TimeLimit', gcTimeLimit
);
984 config
.WriteInt ('GameplayCustom', 'GoalLimit', gcGoalLimit
);
985 config
.WriteInt ('GameplayCustom', 'MaxLives', gcMaxLives
);
986 config
.WriteInt ('GameplayCustom', 'Players', gcPlayers
);
987 config
.WriteBool('GameplayCustom', 'TeamDamage', gcTeamDamage
);
988 config
.WriteBool('GameplayCustom', 'AllowExit', gcAllowExit
);
989 config
.WriteBool('GameplayCustom', 'WeaponStay', gcWeaponStay
);
990 config
.WriteBool('GameplayCustom', 'Monsters', gcMonsters
);
991 config
.WriteStr ('GameplayCustom', 'BotsVS', gcBotsVS
);
993 config
.SaveFile(FileName
);
997 procedure g_Options_Write_Gameplay_Net(FileName
: String);
1001 e_WriteLog('Writing network gameplay config', TMsgType
.Notify
);
1003 config
:= TConfig
.CreateFile(FileName
);
1005 config
.WriteStr ('GameplayNetwork', 'Map', gnMap
);
1006 config
.WriteStr ('GameplayNetwork', 'GameMode', gnGameMode
);
1007 config
.WriteInt ('GameplayNetwork', 'TimeLimit', gnTimeLimit
);
1008 config
.WriteInt ('GameplayNetwork', 'GoalLimit', gnGoalLimit
);
1009 config
.WriteInt ('GameplayNetwork', 'MaxLives', gnMaxLives
);
1010 config
.WriteInt ('GameplayNetwork', 'Players', gnPlayers
);
1011 config
.WriteBool('GameplayNetwork', 'TeamDamage', gnTeamDamage
);
1012 config
.WriteBool('GameplayNetwork', 'AllowExit', gnAllowExit
);
1013 config
.WriteBool('GameplayNetwork', 'WeaponStay', gnWeaponStay
);
1014 config
.WriteBool('GameplayNetwork', 'Monsters', gnMonsters
);
1015 config
.WriteStr ('GameplayNetwork', 'BotsVS', gnBotsVS
);
1017 config
.SaveFile(FileName
);
1021 procedure g_Options_Write_Net_Server(FileName
: String);
1025 e_WriteLog('Writing server config', TMsgType
.Notify
);
1027 config
:= TConfig
.CreateFile(FileName
);
1029 config
.WriteStr ('Server', 'Name', NetServerName
);
1030 config
.WriteStr ('Server', 'Password', NetPassword
);
1031 config
.WriteInt ('Server', 'Port', NetPort
);
1032 config
.WriteInt ('Server', 'MaxClients', NetMaxClients
);
1033 config
.WriteBool('Server', 'SyncWithMaster', NetUseMaster
);
1034 config
.WriteBool('Server', 'ForwardPorts', NetForwardPorts
);
1036 config
.SaveFile(FileName
);
1040 procedure g_Options_Write_Net_Client(FileName
: String);
1044 e_WriteLog('Writing client config', TMsgType
.Notify
);
1046 config
:= TConfig
.CreateFile(FileName
);
1048 config
.WriteStr('Client', 'LastIP', NetClientIP
);
1049 config
.WriteInt('Client', 'LastPort', NetClientPort
);
1051 config
.SaveFile(FileName
);
1056 machine
:= Random(10000)