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, version 3 of the License ONLY.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 {$INCLUDE ../shared/a_modes.inc}
21 g_language
, g_weapons
, utils
;
23 function GenPlayerName (n
: Integer): String;
25 procedure g_Options_SetDefault
;
26 procedure g_Options_SetDefaultVideo
;
27 procedure g_Options_Read(FileName
: String);
28 procedure g_Options_Write(FileName
: String);
29 procedure g_Options_Write_Gameplay_Custom(FileName
: String);
30 procedure g_Options_Write_Gameplay_Net(FileName
: String);
31 procedure g_Options_Write_Net_Server(FileName
: String);
32 procedure g_Options_Write_Net_Client(FileName
: String);
33 procedure g_Options_Commands (p
: SSArray
);
35 const DF_Default_Megawad_Start
= 'megawads/DOOM2D.WAD:\MAP01';
41 gWinSizeX
, gWinSizeY
: Integer;
42 gWinMaximized
: Boolean;
44 glLegacyNPOT
: Boolean;
45 glRenderToFBO
: Boolean = True;
46 gTextureFilter
: Boolean;
50 gMaxSimSounds
: Integer;
51 gMuteWhenInactive
: Boolean;
58 gDrawBackGround
: Boolean;
59 gShowMessages
: Boolean;
60 gRevertPlayers
: Boolean;
62 gAskLanguage
: Boolean;
63 gSaveStats
: Boolean = False;
64 gScreenshotStats
: Boolean = False;
71 gcTeamDamage
: Boolean;
73 gcWeaponStay
: Boolean;
76 gcDeathmatchKeys
: Boolean = True;
77 gcSpawnInvul
: Integer = 0;
84 gnTeamDamage
: Boolean;
86 gnWeaponStay
: Boolean;
89 gnDeathmatchKeys
: Boolean = True;
90 gnSpawnInvul
: Integer = 0;
91 gsSDLSampleRate
: Integer;
92 gsSDLBufferSize
: Integer;
93 gDefaultMegawadStart
: AnsiString;
94 gBerserkAutoswitch
: Boolean;
95 glNPOTOverride
: Boolean = false;
100 {$INCLUDE ../nogl/noGLuses.inc}
104 e_log
, e_input
, g_console
, g_window
, g_sound
, g_gfx
, g_player
, Math
,
105 g_map
, g_net
, g_netmaster
, SysUtils
, CONFIG
, g_game
, g_main
, e_texture
,
106 g_items
, wadreader
, e_graphics
, g_touch
, envvars
, g_system
;
111 function GenPlayerName (n
: Integer): String;
114 Result
:= GetUserName
;
116 Result
:= 'Player' + IntToStr(machine
MOD 10000);
118 Result
:= Copy(Result
, 1, 12) + ' '
120 Result
:= Copy(Result
, 1, 10) + ' ' + IntToStr(n
)
124 procedure g_Options_SetDefaultVideo
;
125 var display
: TSDL_DisplayMode
;
127 var target
, closest
: TSDL_DisplayMode
; percentage
: Integer;
130 (* Display 0 = Primary display *)
132 gScreenHeight
:= 480;
135 //gBPP := SDL_BITSPERPIXEL(dispaly.format);
138 gFullScreen
:= True; (* rotation not allowed? *)
140 gFullScreen
:= False;
142 if SDL_GetDesktopDisplayMode(0, @display
) = 0 then
145 gWinSizeX
:= display
.w
;
146 gWinSizeY
:= display
.h
;
148 (* Window must be smaller than display *)
149 closest
.w
:= display
.w
;
150 closest
.h
:= display
.h
;
152 while (display
.w
- closest
.w
< 48) or (display
.h
- closest
.h
< 48) do
154 if percentage
< 25 then
156 closest
.w
:= display
.w
* 75 div 100;
157 closest
.h
:= display
.h
* 75 div 100;
160 target
.w
:= display
.w
* percentage
div 100;
161 target
.h
:= display
.h
* percentage
div 100;
162 target
.format
:= 0; (* didn't care *)
163 target
.refresh_rate
:= 0; (* didn't care *)
164 target
.driverdata
:= nil; (* init *)
165 SDL_GetClosestDisplayMode(0, @target
, @closest
);
168 gWinSizeX
:= closest
.w
;
169 gWinSizeY
:= closest
.h
;
170 //gBPP := SDL_BITSPERPIXEL(closest.format); (* Resolution list didn't work for some reason *)
175 e_LogWritefln('SDL: Failed to get desktop display mode: %s', [SDL_GetError
])
177 (* Must be positioned on primary display *)
178 gWinMaximized
:= False;
180 gTextureFilter
:= True;
181 glLegacyNPOT
:= False;
182 gRC_Width
:= gWinSizeX
;
183 gRC_Height
:= gWinSizeY
;
184 gRC_FullScreen
:= gFullScreen
;
185 gRC_Maximized
:= gWinMaximized
;
186 e_LogWriteLn('g_Options_SetDefaultVideo: w = ' + IntToStr(gWinSizeX
) + ' h = ' + IntToStr(gWinSizeY
));
187 g_Console_ResetBinds
;
190 procedure g_Options_SetDefaultVideo
;
195 gFullScreen
:= False;
196 gWinMaximized
:= False;
198 gTextureFilter
:= True;
199 glLegacyNPOT
:= False;
200 gScreenWidth
:= gWinSizeX
;
201 gScreenHeight
:= gWinSizeY
;
202 gRC_Width
:= gWinSizeX
;
203 gRC_Height
:= gWinSizeY
;
204 gRC_FullScreen
:= gFullScreen
;
205 gRC_Maximized
:= gWinMaximized
;
206 e_LogWriteLn('g_Options_SetDefaultVideo: w = ' + IntToStr(gWinSizeX
) + ' h = ' + IntToStr(gWinSizeY
));
207 g_Console_ResetBinds
;
211 procedure g_Options_SetDefault();
220 gMuteWhenInactive
:= False;
221 gAnnouncer
:= ANNOUNCE_MEPLUS
;
222 gSoundEffectsDF
:= True;
223 gUseChatSounds
:= True;
224 gsSDLSampleRate
:= 44100;
225 gsSDLBufferSize
:= 2048;
227 g_Sound_SetupAllVolumes(gSoundLevel
, gMusicLevel
);
229 with gPlayer1Settings
do
231 Name
:= GenPlayerName(1);
232 Model
:= STD_PLAYER_MODEL
;
233 Color
.R
:= PLAYER1_DEF_COLOR
.R
;
234 Color
.G
:= PLAYER1_DEF_COLOR
.G
;
235 Color
.B
:= PLAYER1_DEF_COLOR
.B
;
239 with gPlayer2Settings
do
241 Name
:= GenPlayerName(2);
242 Model
:= STD_PLAYER_MODEL
;
243 Color
.R
:= PLAYER2_DEF_COLOR
.R
;
244 Color
.G
:= PLAYER2_DEF_COLOR
.G
;
245 Color
.B
:= PLAYER2_DEF_COLOR
.B
;
249 (* section Joysticks *)
250 for i
:= 0 to e_MaxJoys
- 1 do
252 e_JoystickDeadzones
[i
] := 8192
257 g_Shells_SetMax(300);
259 g_Corpses_SetMax(20);
261 ITEM_RESPAWNTIME
:= 60 * 36;
267 gDrawBackGround
:= True;
268 gShowMessages
:= True;
269 gRevertPlayers
:= False;
271 wadoptDebug
:= False;
273 e_FastScreenshots
:= True;
274 gDefaultMegawadStart
:= DF_Default_Megawad_Start
;
275 gBerserkAutoswitch
:= True;
279 gAskLanguage
:= True;
280 gLanguage
:= LANGUAGE_ENGLISH
;
282 (* section GameplayCustom *)
284 gcGameMode
:= _lc
[I_MENU_GAME_TYPE_DM
];
289 gcTeamDamage
:= False;
291 gcWeaponStay
:= False;
293 gcBotsVS
:= 'Everybody';
294 gcDeathmatchKeys
:= True;
297 (* section GameplayNetwork *)
299 gnGameMode
:= _lc
[I_MENU_GAME_TYPE_DM
];
304 gnTeamDamage
:= False;
306 gnWeaponStay
:= False;
308 gnBotsVS
:= 'Everybody';
309 gnDeathmatchKeys
:= True;
312 (* section MasterServer *)
313 NetSlistIP
:= 'mpms.doom2d.org';
314 NetSlistPort
:= 25665;
315 g_Net_Slist_Set(NetSlistIP
, NetSlistPort
, NetSlistList
);
318 NetServerName
:= 'Unnamed Server';
322 NetAllowRCON
:= False;
323 NetRCONPassword
:= 'default';
324 NetUseMaster
:= True;
327 NetMasterRate
:= 60000;
328 NetForwardPorts
:= False;
332 NetForcePlayerUpdate
:= False;
333 NetPredictSelf
:= True;
334 NetClientIP
:= '127.0.0.1';
335 NetClientPort
:= NetPort
;
338 procedure g_Options_Read(FileName
: String);
343 procedure ReadInteger (VAR v
: Integer; param
: String; minv
: Integer = Low(Integer); maxv
: Integer = High(Integer));
345 v
:= Max(Min(config
.ReadInt(section
, param
, v
), maxv
), minv
)
348 procedure ReadInteger (VAR v
: LongWord; param
: String; minv
: LongWord = Low(LongWord); maxv
: LongWord = High(LongWord)); overload
;
350 v
:= Max(Min(config
.ReadInt(section
, param
, v
), maxv
), minv
)
353 procedure ReadInteger (VAR v
: Word; param
: String; minv
: Word = Low(Word); maxv
: Word = High(Word)); overload
;
355 v
:= Max(Min(config
.ReadInt(section
, param
, v
), maxv
), minv
)
358 procedure ReadInteger (VAR v
: Byte; param
: String; minv
: Byte = Low(Byte); maxv
: Byte = High(Byte)); overload
;
360 v
:= Max(Min(config
.ReadInt(section
, param
, v
), maxv
), minv
)
363 procedure ReadBoolean (VAR v
: Boolean; param
: String);
365 v
:= config
.ReadBool(section
, param
, v
)
368 procedure ReadString (VAR v
: String; param
: String);
370 v
:= config
.ReadStr(section
, param
, v
)
374 gAskLanguage
:= True;
375 e_WriteLog('Reading config', TMsgType
.Notify
);
376 g_Options_SetDefault
;
378 if FileExists(FileName
) = False then
380 e_WriteLog('Config file '+FileName
+' not found', TMsgType
.Warning
);
381 g_Options_SetDefaultVideo
;
385 config
:= TConfig
.CreateFile(FileName
);
387 section
:= 'Player1';
388 with gPlayer1Settings
do
390 ReadString(Name
, 'name');
391 ReadString(Model
, 'model');
392 ReadInteger(Color
.R
, 'red', 0, 255);
393 ReadInteger(Color
.G
, 'green', 0, 255);
394 ReadInteger(Color
.B
, 'blue', 0, 255);
395 ReadInteger(Team
, 'team');
396 if (Team
< TEAM_RED
) or (Team
> TEAM_BLUE
) then
400 section
:= 'Player2';
401 with gPlayer2Settings
do
403 ReadString(Name
, 'name');
404 ReadString(Model
, 'model');
405 ReadInteger(Color
.R
, 'red', 0, 255);
406 ReadInteger(Color
.G
, 'green', 0, 255);
407 ReadInteger(Color
.B
, 'blue', 0, 255);
408 ReadInteger(Team
, 'team');
409 if (Team
< TEAM_RED
) or (Team
> TEAM_BLUE
) then
413 section
:= 'GameplayCustom';
414 ReadString(gcMap
, 'Map');
415 ReadString(gcGameMode
, 'GameMode');
416 ReadInteger(gcTimeLimit
, 'TimeLimit', 0, 65535);
417 ReadInteger(gcGoalLimit
, 'GoalLimit', 0, 65535);
418 ReadInteger(gcMaxLives
, 'MaxLives', 0, 255);
419 ReadInteger(gcPlayers
, 'Players', 0, 2);
420 ReadBoolean(gcTeamDamage
, 'TeamDamage');
421 ReadBoolean(gcAllowExit
, 'AllowExit');
422 ReadBoolean(gcWeaponStay
, 'WeaponStay');
423 ReadBoolean(gcMonsters
, 'Monsters');
424 ReadString(gcBotsVS
, 'BotsVS');
425 ReadBoolean(gcDeathmatchKeys
, 'DeathmatchKeys');
426 ReadInteger(gcSpawnInvul
, 'SpawnInvul');
428 with gGameSettings
do
430 GameMode
:= g_Game_TextToMode(gcGameMode
);
431 if GameMode
= GM_NONE
then
433 if GameMode
= GM_SINGLE
then
435 TimeLimit
:= gcTimeLimit
;
436 GoalLimit
:= gcGoalLimit
;
437 MaxLives
:= gcMaxLives
;
441 Options
:= Options
or GAME_OPTION_TEAMDAMAGE
;
443 Options
:= Options
or GAME_OPTION_ALLOWEXIT
;
445 Options
:= Options
or GAME_OPTION_WEAPONSTAY
;
447 Options
:= Options
or GAME_OPTION_MONSTERS
;
448 if gcBotsVS
= 'Everybody' then
449 Options
:= Options
or GAME_OPTION_BOTVSPLAYER
or GAME_OPTION_BOTVSMONSTER
;
450 if gcBotsVS
= 'Players' then
451 Options
:= Options
or GAME_OPTION_BOTVSPLAYER
;
452 if gcBotsVS
= 'Monsters' then
453 Options
:= Options
or GAME_OPTION_BOTVSMONSTER
;
454 if gcDeathmatchKeys
then
455 Options
:= Options
or GAME_OPTION_DMKEYS
;
458 section
:= 'GameplayNetwork';
459 ReadString(gnMap
, 'Map');
460 ReadString(gnGameMode
, 'GameMode');
461 ReadInteger(gnTimeLimit
, 'TimeLimit', 0, 65535);
462 ReadInteger(gnGoalLimit
, 'GoalLimit', 0, 65535);
463 ReadInteger(gnMaxLives
, 'MaxLives', 0, 255);
464 ReadInteger(gnPlayers
, 'Players', 0, 2);
465 ReadBoolean(gnTeamDamage
, 'TeamDamage');
466 ReadBoolean(gnAllowExit
, 'AllowExit');
467 ReadBoolean(gnWeaponStay
, 'WeaponStay');
468 ReadBoolean(gnMonsters
, 'Monsters');
469 ReadString(gnBotsVS
, 'BotsVS');
470 ReadBoolean(gnDeathmatchKeys
, 'DeathmatchKeys');
471 ReadInteger(gnSpawnInvul
, 'SpawnInvul');
473 section
:= 'MasterServer';
474 ReadString(NetSlistIP
, 'IP');
475 ReadInteger(NetSlistPort
, 'Port', 0, 65535);
476 ReadString(NetSlistList
, 'List');
477 g_Net_Slist_Set(NetSlistIP
, NetSlistPort
, NetSlistList
);
480 ReadString(NetServerName
, 'Name');
481 ReadString(NetPassword
, 'Password');
482 ReadInteger(NetPort
, 'Port', 0, 65535);
483 ReadInteger(NetMaxClients
, 'MaxClients', 0, NET_MAXCLIENTS
);
484 ReadBoolean(NetAllowRCON
, 'RCON');
485 ReadString(NetRCONPassword
, 'RCONPassword');
486 ReadBoolean(NetUseMaster
, 'SyncWithMaster');
487 ReadInteger(NetUpdateRate
, 'UpdateInterval', 0);
488 ReadInteger(NetRelupdRate
, 'ReliableUpdateInterval', 0);
489 ReadInteger(NetMasterRate
, 'MasterSyncInterval', 1);
490 ReadBoolean(NetForwardPorts
, 'ForwardPorts');
493 ReadInteger(NetInterpLevel
, 'InterpolationSteps', 0);
494 ReadBoolean(NetForcePlayerUpdate
, 'ForcePlayerUpdate');
495 ReadBoolean(NetPredictSelf
, 'PredictSelf');
496 ReadString(NetClientIP
, 'LastIP');
497 ReadInteger(NetClientPort
, 'LastPort', 0, 65535);
501 //if gTextureFilter then TEXTUREFILTER := GL_LINEAR else TEXTUREFILTER := GL_NEAREST;
504 procedure g_Options_Write(FileName
: String);
507 e_WriteLog('Writing config', TMsgType
.Notify
);
509 config
:= TConfig
.CreateFile(FileName
);
511 with config
, gPlayer1Settings
do
513 WriteStr('Player1', 'Name', Name
);
514 WriteStr('Player1', 'model', Model
);
515 WriteInt('Player1', 'red', Color
.R
);
516 WriteInt('Player1', 'green', Color
.G
);
517 WriteInt('Player1', 'blue', Color
.B
);
518 WriteInt('Player1', 'team', Team
);
521 with config
, gPlayer2Settings
do
523 WriteStr('Player2', 'Name', Name
);
524 WriteStr('Player2', 'model', Model
);
525 WriteInt('Player2', 'red', Color
.R
);
526 WriteInt('Player2', 'green', Color
.G
);
527 WriteInt('Player2', 'blue', Color
.B
);
528 WriteInt('Player2', 'team', Team
);
531 config
.WriteStr ('GameplayCustom', 'Map', gcMap
);
532 config
.WriteStr ('GameplayCustom', 'GameMode', gcGameMode
);
533 config
.WriteInt ('GameplayCustom', 'TimeLimit', gcTimeLimit
);
534 config
.WriteInt ('GameplayCustom', 'GoalLimit', gcGoalLimit
);
535 config
.WriteInt ('GameplayCustom', 'MaxLives', gcMaxLives
);
536 config
.WriteInt ('GameplayCustom', 'Players', gcPlayers
);
537 config
.WriteBool('GameplayCustom', 'TeamDamage', gcTeamDamage
);
538 config
.WriteBool('GameplayCustom', 'AllowExit', gcAllowExit
);
539 config
.WriteBool('GameplayCustom', 'WeaponStay', gcWeaponStay
);
540 config
.WriteBool('GameplayCustom', 'Monsters', gcMonsters
);
541 config
.WriteStr ('GameplayCustom', 'BotsVS', gcBotsVS
);
542 config
.WriteBool('GameplayCustom', 'DeathmatchKeys', gcDeathmatchKeys
);
543 config
.WriteInt ('GameplayCustom', 'SpawnInvul', gcSpawnInvul
);
545 config
.WriteStr ('GameplayNetwork', 'Map', gnMap
);
546 config
.WriteStr ('GameplayNetwork', 'GameMode', gnGameMode
);
547 config
.WriteInt ('GameplayNetwork', 'TimeLimit', gnTimeLimit
);
548 config
.WriteInt ('GameplayNetwork', 'GoalLimit', gnGoalLimit
);
549 config
.WriteInt ('GameplayNetwork', 'MaxLives', gnMaxLives
);
550 config
.WriteInt ('GameplayNetwork', 'Players', gnPlayers
);
551 config
.WriteBool('GameplayNetwork', 'TeamDamage', gnTeamDamage
);
552 config
.WriteBool('GameplayNetwork', 'AllowExit', gnAllowExit
);
553 config
.WriteBool('GameplayNetwork', 'WeaponStay', gnWeaponStay
);
554 config
.WriteBool('GameplayNetwork', 'Monsters', gnMonsters
);
555 config
.WriteStr ('GameplayNetwork', 'BotsVS', gnBotsVS
);
556 config
.WriteBool('GameplayNetwork', 'DeathmatchKeys', gnDeathmatchKeys
);
557 config
.WriteInt ('GameplayNetwork', 'SpawnInvul', gnSpawnInvul
);
559 config
.WriteStr('MasterServer', 'IP', NetSlistIP
);
560 config
.WriteInt('MasterServer', 'Port', NetSlistPort
);
561 config
.WriteStr('MasterServer', 'List', NetSlistList
);
563 config
.WriteStr ('Server', 'Name', NetServerName
);
564 config
.WriteStr ('Server', 'Password', NetPassword
);
565 config
.WriteInt ('Server', 'Port', NetPort
);
566 config
.WriteInt ('Server', 'MaxClients', NetMaxClients
);
567 config
.WriteBool('Server', 'RCON', NetAllowRCON
);
568 config
.WriteStr ('Server', 'RCONPassword', NetRCONPassword
);
569 config
.WriteBool('Server', 'SyncWithMaster', NetUseMaster
);
570 config
.WriteBool('Server', 'ForwardPorts', NetForwardPorts
);
571 config
.WriteInt ('Server', 'UpdateInterval', NetUpdateRate
);
572 config
.WriteInt ('Server', 'ReliableUpdateInterval', NetRelupdRate
);
573 config
.WriteInt ('Server', 'MasterSyncInterval', NetMasterRate
);
575 config
.WriteInt ('Client', 'InterpolationSteps', NetInterpLevel
);
576 config
.WriteBool ('Client', 'ForcePlayerUpdate', NetForcePlayerUpdate
);
577 config
.WriteBool ('Client', 'PredictSelf', NetPredictSelf
);
578 config
.WriteStr ('Client', 'LastIP', NetClientIP
);
579 config
.WriteInt ('Client', 'LastPort', NetClientPort
);
581 config
.SaveFile(FileName
);
585 procedure g_Options_Write_Gameplay_Custom(FileName
: String);
589 e_WriteLog('Writing custom gameplay config', TMsgType
.Notify
);
591 config
:= TConfig
.CreateFile(FileName
);
593 config
.WriteStr ('GameplayCustom', 'Map', gcMap
);
594 config
.WriteStr ('GameplayCustom', 'GameMode', gcGameMode
);
595 config
.WriteInt ('GameplayCustom', 'TimeLimit', gcTimeLimit
);
596 config
.WriteInt ('GameplayCustom', 'GoalLimit', gcGoalLimit
);
597 config
.WriteInt ('GameplayCustom', 'MaxLives', gcMaxLives
);
598 config
.WriteInt ('GameplayCustom', 'Players', gcPlayers
);
599 config
.WriteBool('GameplayCustom', 'TeamDamage', gcTeamDamage
);
600 config
.WriteBool('GameplayCustom', 'AllowExit', gcAllowExit
);
601 config
.WriteBool('GameplayCustom', 'WeaponStay', gcWeaponStay
);
602 config
.WriteBool('GameplayCustom', 'Monsters', gcMonsters
);
603 config
.WriteStr ('GameplayCustom', 'BotsVS', gcBotsVS
);
604 config
.WriteBool('GameplayCustom', 'DeathmatchKeys', gcDeathmatchKeys
);
605 config
.WriteInt ('GameplayCustom', 'SpawnInvul', gcSpawnInvul
);
607 config
.SaveFile(FileName
);
611 procedure g_Options_Write_Gameplay_Net(FileName
: String);
615 e_WriteLog('Writing network gameplay config', TMsgType
.Notify
);
617 config
:= TConfig
.CreateFile(FileName
);
619 config
.WriteStr ('GameplayNetwork', 'Map', gnMap
);
620 config
.WriteStr ('GameplayNetwork', 'GameMode', gnGameMode
);
621 config
.WriteInt ('GameplayNetwork', 'TimeLimit', gnTimeLimit
);
622 config
.WriteInt ('GameplayNetwork', 'GoalLimit', gnGoalLimit
);
623 config
.WriteInt ('GameplayNetwork', 'MaxLives', gnMaxLives
);
624 config
.WriteInt ('GameplayNetwork', 'Players', gnPlayers
);
625 config
.WriteBool('GameplayNetwork', 'TeamDamage', gnTeamDamage
);
626 config
.WriteBool('GameplayNetwork', 'AllowExit', gnAllowExit
);
627 config
.WriteBool('GameplayNetwork', 'WeaponStay', gnWeaponStay
);
628 config
.WriteBool('GameplayNetwork', 'Monsters', gnMonsters
);
629 config
.WriteStr ('GameplayNetwork', 'BotsVS', gnBotsVS
);
630 config
.WriteBool('GameplayNetwork', 'DeathmatchKeys', gnDeathmatchKeys
);
631 config
.WriteInt ('GameplayNetwork', 'SpawnInvul', gnSpawnInvul
);
633 config
.SaveFile(FileName
);
637 procedure g_Options_Write_Net_Server(FileName
: String);
641 e_WriteLog('Writing server config', TMsgType
.Notify
);
643 config
:= TConfig
.CreateFile(FileName
);
645 config
.WriteStr ('Server', 'Name', NetServerName
);
646 config
.WriteStr ('Server', 'Password', NetPassword
);
647 config
.WriteInt ('Server', 'Port', NetPort
);
648 config
.WriteInt ('Server', 'MaxClients', NetMaxClients
);
649 config
.WriteBool('Server', 'SyncWithMaster', NetUseMaster
);
650 config
.WriteBool('Server', 'ForwardPorts', NetForwardPorts
);
652 config
.SaveFile(FileName
);
656 procedure g_Options_Write_Net_Client(FileName
: String);
660 e_WriteLog('Writing client config', TMsgType
.Notify
);
662 config
:= TConfig
.CreateFile(FileName
);
664 config
.WriteStr('Client', 'LastIP', NetClientIP
);
665 config
.WriteInt('Client', 'LastPort', NetClientPort
);
667 config
.SaveFile(FileName
);
671 procedure g_Options_Commands (p
: SSArray
);
672 var cmd
: AnsiString; i
: Integer;
674 cmd
:= LowerCase(p
[0]);
678 sys_EnableVSync(gVSync
);
679 gRC_Width
:= Max(1, gRC_Width
);
680 gRC_Height
:= Max(1, gRC_Height
);
681 gBPP
:= Max(1, gBPP
);
682 if sys_SetDisplayMode(gRC_Width
, gRC_Height
, gBPP
, gRC_FullScreen
, gRC_Maximized
) = True then
683 e_LogWriteln('resolution changed')
685 e_LogWriteln('resolution not changed')
689 if Length(p
) = 2 then
691 gAskLanguage
:= true;
692 gLanguage
:= LANGUAGE_ENGLISH
;
693 case LowerCase(p
[1]) of
696 gAskLanguage
:= false;
697 gLanguage
:= LANGUAGE_ENGLISH
;
701 gAskLanguage
:= false;
702 gLanguage
:= LANGUAGE_RUSSIAN
;
706 gAskLanguage
:= true;
707 gLanguage
:= LANGUAGE_ENGLISH
;
710 g_Language_Set(gLanguage
)
714 e_LogWritefln('usage: %s <English|Russian|Ask>', [cmd
])
719 if Length(p
) = 2 then
721 i
:= Max(0, StrToInt(p
[1]));
724 else if Length(p
) = 1 then
726 e_LogWritefln('%s', [g_GFX_GetMax()])
730 e_LogWritefln('usage: %s <n>', [cmd
])
735 if Length(p
) = 2 then
737 i
:= Max(0, StrToInt(p
[1]));
740 else if Length(p
) = 1 then
742 e_LogWritefln('%s', [g_Shells_GetMax()])
746 e_LogWritefln('usage: %s <n>', [cmd
])
751 if Length(p
) = 2 then
753 i
:= Max(0, StrToInt(p
[1]));
756 else if Length(p
) = 1 then
758 e_LogWritefln('%s', [g_Gibs_GetMax()])
762 e_LogWritefln('usage: %s <n>', [cmd
])
767 if Length(p
) = 2 then
769 i
:= Max(0, StrToInt(p
[1]));
772 else if Length(p
) = 1 then
774 e_LogWritefln('%s', [g_Corpses_GetMax()])
778 e_LogWritefln('usage: %s <n>', [cmd
])
781 'g_item_respawn_time':
783 if Length(p
) = 2 then
784 ITEM_RESPAWNTIME
:= Max(0, StrToInt(p
[1])) * 36
785 else if Length(p
) = 1 then
786 e_LogWritefln('%s', [ITEM_RESPAWNTIME
div 36])
788 e_LogWritefln('usage: %s <n>', [cmd
])
795 machine
:= Random(10000);
798 conRegVar('r_width', @gRC_Width
, '', '');
799 conRegVar('r_height', @gRC_Height
, '', '');
800 conRegVar('r_fullscreen', @gRC_FullScreen
, '', '');
801 conRegVar('r_maximized', @gRC_Maximized
, '', '');
802 conRegVar('r_bpp', @gBPP
, '', '');
803 conRegVar('r_vsync', @gVSync
, '', '');
804 conRegVar('r_texfilter', @gTextureFilter
, '', '');
805 conRegVar('r_npot', @glNPOTOverride
, '', '');
808 conRegVar('s_nosound', @gNoSound
, '', '');
809 conRegVar('s_soundvolume', @gSoundLevel
, '', '');
810 conRegVar('s_musicvolume', @gMusicLevel
, '', '');
811 conRegVar('s_maxsim', @gMaxSimSounds
, '', ''); // e_sound_fmod/sdl?
812 conRegVar('s_muteinactive', @gMuteWhenInactive
, '', '');
813 conRegVar('s_announcer', @gAnnouncer
, '', '');
814 conRegVar('s_sfx', @gSoundEffectsDF
, '', '');
815 conRegVar('s_chatsounds', @gUseChatSounds
, '', '');
816 {$IFDEF USE_SDLMIXER}
817 conRegVar('sdl_mixer_samplerate', @gsSDLSampleRate
, '', '');
818 conRegVar('sdl_mixer_buffersize', @gsSDLBufferSize
, '', '');
822 conRegVar('g_gibs_count', @gGibsCount
, '', '');
823 conRegVar('g_blood_count', @gBloodCount
, '', '');
824 conRegVar('g_adv_blood', @gAdvBlood
, '', '');
825 conRegVar('g_adv_corpses', @gAdvCorpses
, '', '');
826 conRegVar('g_adv_gibs', @gAdvGibs
, '', '');
827 conRegVar('r_flash', @gFlash
, '', '');
828 conRegVar('r_background', @gDrawBackGround
, '', '');
829 conRegVar('g_show_messages', @gShowMessages
, '', '');
830 conRegVar('r_revert_players', @gRevertPlayers
, '', '');
831 conRegVar('r_chat_bubble', @gChatBubble
, '', '');
832 conRegVar('sfs_debug', @wadoptDebug
, '', '');
833 conRegVar('sfs_fastmode', @wadoptFast
, '', '');
834 conRegVar('g_fast_screenshots', @e_FastScreenshots
, '', '');
835 conRegVar('g_default_megawad', @gDefaultMegawadStart
, '', '');
836 conRegVar('g_save_stats', @gSaveStats
, '', '');
837 conRegVar('g_screenshot_stats', @gScreenshotStats
, '', '');