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}
24 SysUtils
, Classes
, MAPDEF
,
25 g_base
, g_basic
, g_player
, g_res_downloader
,
26 g_sound
, utils
, md5
, mempool
, xprofiler
,
31 TGameSettings
= record
38 ItemRespawnTime
: Word;
49 TDelayedEvent
= record
58 Sound
: TPlayableSound
;
59 Tags
: Array of String;
63 TPlayerSettings
= record
82 function g_Game_IsNet(): Boolean;
83 function g_Game_IsServer(): Boolean;
84 function g_Game_IsClient(): Boolean;
85 procedure g_Game_Init();
86 procedure g_Game_Free (freeTextures
: Boolean=true);
87 procedure g_Game_LoadData();
88 procedure g_Game_FreeData();
89 procedure g_Game_Update();
90 procedure g_Game_PreUpdate();
91 procedure g_Game_Quit();
92 function g_Game_ModeToText(Mode
: Byte): string;
93 function g_Game_TextToMode(Mode
: string): Byte;
94 procedure g_Game_ExecuteEvent(Name
: String);
95 function g_Game_DelayEvent(DEType
: Byte; Time
: LongWord; Num
: Integer = 0; Str
: String = ''): Integer;
96 procedure g_Game_AddPlayer(Team
: Byte = TEAM_NONE
);
97 procedure g_Game_RemovePlayer();
98 procedure g_Game_Spectate();
99 procedure g_Game_SpectateCenterView();
100 procedure g_Game_StartSingle(Map
: String; TwoPlayers
: Boolean; nPlayers
: Byte);
101 procedure g_Game_StartCustom(Map
: String; GameMode
: Byte; TimeLimit
, GoalLimit
: Word; MaxLives
: Byte; Options
: LongWord; nPlayers
: Byte);
102 procedure g_Game_StartServer(Map
: String; GameMode
: Byte; TimeLimit
, GoalLimit
: Word; MaxLives
: Byte; Options
: LongWord; nPlayers
: Byte; IPAddr
: LongWord; Port
: Word);
103 procedure g_Game_StartClient(Addr
: String; Port
: Word; PW
: String);
104 procedure g_Game_Restart();
105 procedure g_Game_RestartLevel();
106 procedure g_Game_RestartRound(NoMapRestart
: Boolean = False);
107 function g_Game_ClientWAD (NewWAD
: String; const WHash
: TMD5Digest
): AnsiString;
108 function g_Game_StartMap(asMegawad
: Boolean; Map
: String; Force
: Boolean = False; const oldMapPath
: AnsiString=''): Boolean;
109 procedure g_Game_ChangeMap(const MapPath
: String);
110 procedure g_Game_ExitLevel(const Map
: AnsiString);
111 function g_Game_GetFirstMap(WAD
: String): String;
112 function g_Game_GetNextMap(): String;
113 procedure g_Game_NextLevel();
114 procedure g_Game_Pause(Enable
: Boolean);
115 procedure g_Game_HolmesPause(Enable
: Boolean);
116 function g_Game_IsWatchedPlayer(UID
: Word): Boolean;
117 function g_Game_IsWatchedTeam(Team
: Byte): Boolean;
118 procedure g_Game_Message(Msg
: String; Time
: Word);
119 procedure g_Game_LoadMapList(FileName
: String);
120 procedure g_Game_PauseAllSounds(Enable
: Boolean);
121 procedure g_Game_StopAllSounds(all
: Boolean);
122 procedure g_Game_UpdateTriggerSounds();
123 function g_Game_GetMegaWADInfo(WAD
: String): TMegaWADInfo
;
124 procedure g_Game_ChatSound(Text: String; Taunt
: Boolean = True);
125 procedure g_Game_Announce_GoodShot(SpawnerUID
: Word);
126 procedure g_Game_Announce_KillCombo(Param
: Integer);
127 procedure g_Game_Announce_BodyKill(SpawnerUID
: Word);
128 procedure g_Game_StartVote(Command
, Initiator
: string);
129 procedure g_Game_CheckVote
;
131 procedure g_TakeScreenShot(Filename
: string = '');
133 procedure g_FatalError(Text: String);
134 procedure g_SimpleError(Text: String);
135 function g_Game_IsTestMap(): Boolean;
136 procedure g_Game_DeleteTestMap();
137 procedure GameCVars(P
: SSArray
);
138 procedure PlayerSettingsCVars(P
: SSArray
);
139 procedure SystemCommands(P
: SSArray
);
140 procedure GameCommands(P
: SSArray
);
141 procedure GameCheats(P
: SSArray
);
142 procedure DebugCommands(P
: SSArray
);
143 procedure g_Game_Process_Params
;
144 procedure g_Game_SetLoadingText(Text: String; Max
: Integer; reWrite
: Boolean);
145 procedure g_Game_StepLoading(Value
: Integer = -1);
146 procedure g_Game_ClearLoading();
147 procedure g_Game_SetDebugMode();
149 function IsActivePlayer(p
: TPlayer
): Boolean;
150 function GetActivePlayerID_Next(Skip
: Integer = -1): Integer;
151 procedure SortGameStat(var stat
: TPlayerStatArray
);
155 procedure g_Game_InGameMenu(Show
: Boolean);
158 procedure CharPress (C
: AnsiChar);
160 procedure KeyPress (K
: Word);
162 { procedure SetWinPause(Enable: Boolean); }
167 LOADING_SHOW_STEP
= 100;
168 LOADING_INTERLINE
= 20;
186 EXIT_ENDLEVELSINGLE
= 4;
187 EXIT_ENDLEVELCUSTOM
= 5;
189 GAME_OPTION_RESERVED
= 1;
190 GAME_OPTION_TEAMDAMAGE
= 2;
191 GAME_OPTION_ALLOWEXIT
= 4;
192 GAME_OPTION_WEAPONSTAY
= 8;
193 GAME_OPTION_MONSTERS
= 16;
194 GAME_OPTION_BOTVSPLAYER
= 32;
195 GAME_OPTION_BOTVSMONSTER
= 64;
196 GAME_OPTION_DMKEYS
= 128;
197 GAME_OPTION_TEAMHITTRACE
= 256;
198 GAME_OPTION_TEAMHITPROJECTILE
= 512;
199 GAME_OPTION_TEAMABSORBDAMAGE
= 1024;
204 STATE_INTERCUSTOM
= 3;
205 STATE_INTERSINGLE
= 4;
211 LMS_RESPAWN_NONE
= 0;
212 LMS_RESPAWN_WARMUP
= 1;
213 LMS_RESPAWN_FINAL
= 2;
230 CONFIG_FILENAME
= 'Doom2DF.cfg';
232 TEST_MAP_NAME
= '$$$_TEST_$$$';
234 STD_PLAYER_MODEL
= 'Doomer';
242 STATFILE_VERSION
= $03;
245 gGameSettings
: TGameSettings
;
246 gPlayer1Settings
: TPlayerSettings
;
247 gPlayer2Settings
: TPlayerSettings
;
249 gPlayerScreenSize
: TDFPoint
;
250 gPlayer1ScreenCoord
: TDFPoint
;
251 gPlayer2ScreenCoord
: TDFPoint
;
252 gPlayer1
: TPlayer
= nil;
253 gPlayer2
: TPlayer
= nil;
254 gPlayerDrawn
: TPlayer
= nil;
256 gLerpFactor
: Single = 1.0;
257 gSwitchGameMode
: Byte = GM_DM
;
258 gHearPoint1
, gHearPoint2
: THearPoint
;
259 gSoundEffectsDF
: Boolean = False;
260 gSoundTriggerTime
: Word = 0;
261 gAnnouncer
: Integer = ANNOUNCE_NONE
;
262 goodsnd
: array[0..3] of TPlayableSound
;
263 killsnd
: array[0..3] of TPlayableSound
;
264 hahasnd
: array[0..2] of TPlayableSound
;
265 sound_get_flag
: array[0..1] of TPlayableSound
;
266 sound_lost_flag
: array[0..1] of TPlayableSound
;
267 sound_ret_flag
: array[0..1] of TPlayableSound
;
268 sound_cap_flag
: array[0..1] of TPlayableSound
;
269 gBodyKillEvent
: Integer = -1;
270 gDefInterTime
: ShortInt = -1;
271 gInterEndTime
: LongWord = 0;
272 gInterTime
: LongWord = 0;
273 gServInterTime
: Byte = 0;
274 gGameStartTime
: LongWord = 0;
275 gTotalMonsters
: Integer = 0;
276 gPauseMain
: Boolean = false;
277 gPauseHolmes
: Boolean = false;
278 gShowTime
: Boolean = False;
279 gShowFPS
: Boolean = False;
280 gShowGoals
: Boolean = True;
281 gShowStat
: Boolean = True;
282 gShowPIDs
: Boolean = False;
283 gShowKillMsg
: Boolean = True;
284 gShowLives
: Boolean = True;
285 gShowPing
: Boolean = False;
286 gShowMap
: Boolean = False;
288 gState
: Byte = STATE_NONE
;
290 sWidth
, sHeight
: Word;
291 gSpectMode
: Byte = SPECT_NONE
;
292 gSpectHUD
: Boolean = True;
293 gSpectKeyPress
: Boolean = False;
294 gSpectX
: Integer = 0;
295 gSpectY
: Integer = 0;
296 gSpectStep
: Byte = 8;
297 gSpectViewTwo
: Boolean = False;
298 gSpectPID1
: Integer = -1;
299 gSpectPID2
: Integer = -1;
300 gSpectAuto
: Boolean = False;
301 gSpectAutoNext
: LongWord;
302 gSpectAutoStepX
: Integer;
303 gSpectAutoStepY
: Integer;
304 gMusic
: TMusic
= nil;
305 gLoadGameMode
: Boolean;
306 gCheats
: Boolean = False;
307 gMapOnce
: Boolean = False;
308 gMapToDelete
: String;
309 gTempDelete
: Boolean = False;
310 gLastMap
: Boolean = False;
313 gResolutionChange
: Boolean = False;
314 gRC_Width
, gRC_Height
: Integer;
315 gRC_FullScreen
, gRC_Maximized
: Boolean;
316 gLanguageChange
: Boolean = False;
317 gDebugMode
: Boolean = False;
318 g_debug_Sounds
: Boolean = False;
319 g_debug_Frames
: Boolean = False;
320 g_debug_WinMsgs
: Boolean = False;
321 g_debug_MonsterOff
: Boolean = False;
322 g_debug_BotAIOff
: Byte = 0;
323 g_debug_HealthBar
: Boolean = False;
324 g_Debug_Player
: Boolean = False;
325 gCoopMonstersKilled
: Word = 0;
326 gCoopSecretsFound
: Word = 0;
327 gCoopTotalMonstersKilled
: Word = 0;
328 gCoopTotalSecretsFound
: Word = 0;
329 gCoopTotalMonsters
: Word = 0;
330 gCoopTotalSecrets
: Word = 0;
331 gStatsOff
: Boolean = False;
332 gStatsPressed
: Boolean = False;
333 gExitByTrigger
: Boolean = False;
334 gNextMap
: String = '';
335 gLMSRespawn
: Byte = LMS_RESPAWN_NONE
;
336 gLMSRespawnTime
: Cardinal = 0;
337 gLMSSoftSpawn
: Boolean = False;
338 gMissionFailed
: Boolean = False;
339 gVoteInProgress
: Boolean = False;
340 gVotePassed
: Boolean = False;
341 gVoteCommand
: string = '';
342 gVoteTimer
: Cardinal = 0;
343 gVoteCmdTimer
: Cardinal = 0;
344 gVoteCount
: Integer = 0;
345 gVoteTimeout
: Cardinal = 30;
346 gVoted
: Boolean = False;
347 gVotesEnabled
: Boolean = True;
348 gEvents
: Array of TGameEvent
;
349 gDelayedEvents
: Array of TDelayedEvent
;
350 gUseChatSounds
: Boolean = True;
351 gChatSounds
: Array of TChatSound
;
352 gSelectWeapon
: Array [0..1, WP_FIRST
..WP_LAST
] of Boolean; // [player, weapon]
353 gInterReadyCount
: Integer = 0;
355 g_dbg_ignore_bounds
: Boolean = false;
356 r_smallmap_h
: Integer = 0; // 0: left; 1: center; 2: right
357 r_smallmap_v
: Integer = 2; // 0: top; 1: center; 2: bottom
359 // move button values:
360 // bits 0-1: l/r state:
361 // 0: neither left, nor right pressed
364 // bits 4-5: l/r state when strafe was pressed
365 P1MoveButton
: Byte = 0;
366 P2MoveButton
: Byte = 0;
368 g_profile_frame_update
: Boolean = false;
369 g_profile_frame_draw
: Boolean = false;
370 g_profile_collision
: Boolean = false;
371 g_profile_los
: Boolean = false;
372 g_profile_history_size
: Integer = 1000;
374 g_rlayer_back
: Boolean = true;
375 g_rlayer_step
: Boolean = true;
376 g_rlayer_wall
: Boolean = true;
377 g_rlayer_door
: Boolean = true;
378 g_rlayer_acid1
: Boolean = true;
379 g_rlayer_acid2
: Boolean = true;
380 g_rlayer_water
: Boolean = true;
381 g_rlayer_fore
: Boolean = true;
383 wNeedTimeReset
: Boolean = false;
385 procedure g_ResetDynlights ();
386 procedure g_AddDynLight (x
, y
, radius
: Integer; r
, g
, b
, a
: Single);
387 procedure g_DynLightExplosion (x
, y
, radius
: Integer; r
, g
, b
: Single);
389 function conIsCheatsEnabled (): Boolean; inline;
390 function gPause (): Boolean; inline;
392 type (* private state *)
393 TEndCustomGameStat
= record
394 PlayerStat
: TPlayerStatArray
;
398 Map
, MapName
: String;
401 TEndSingleGameStat
= record
402 PlayerStat
: Array [0..1] of record
408 TotalSecrets
: Integer;
411 TLoadingStat
= record
415 Msgs
: Array of String;
417 PBarWasHere
: Boolean; // did we draw a progress bar for this message?
421 x
, y
, radius
: Integer;
424 exploRadius
: Integer;
427 var (* private state *)
428 CustomStat
: TEndCustomGameStat
;
429 StatShotDone
: Boolean;
430 StatFilename
: string = ''; // used by stat screenshot to save with the same name as the csv
431 SingleStat
: TEndSingleGameStat
;
432 LoadingStat
: TLoadingStat
;
435 EndingGameCounter
: Byte;
437 g_playerLight
: Boolean;
438 g_dynLights
: array of TDynLight
= nil;
439 g_dynLightCount
: Integer = 0;
440 EndPicPath
: AnsiString; // full path, used by render
445 {$IFDEF ENABLE_HOLMES}
461 e_input
, e_log
, g_console
, g_items
, g_map
, g_panel
,
462 g_playermodel
, g_options
, Math
,
463 g_triggers
, g_monsters
, e_sound
, CONFIG
,
464 g_language
, g_net
, g_phys
,
465 ENet
, e_msg
, g_netmsg
, g_netmaster
,
469 charbuff
: packed array [0..15] of AnsiChar = (
470 ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '
473 function Translit (const S
: AnsiString): AnsiString;
478 for i
:= 1 to Length(Result
) do
481 #
$C9: Result
[i
] := 'Q';
482 #
$D6: Result
[i
] := 'W';
483 #
$D3: Result
[i
] := 'E';
484 #
$CA: Result
[i
] := 'R';
485 #
$C5: Result
[i
] := 'T';
486 #
$CD: Result
[i
] := 'Y';
487 #
$C3: Result
[i
] := 'U';
488 #
$D8: Result
[i
] := 'I';
489 #
$D9: Result
[i
] := 'O';
490 #
$C7: Result
[i
] := 'P';
491 #
$D5: Result
[i
] := '['; //Chr(219);
492 #
$DA: Result
[i
] := ']'; //Chr(221);
493 #
$D4: Result
[i
] := 'A';
494 #
$DB: Result
[i
] := 'S';
495 #
$C2: Result
[i
] := 'D';
496 #
$C0: Result
[i
] := 'F';
497 #
$CF: Result
[i
] := 'G';
498 #
$D0: Result
[i
] := 'H';
499 #
$CE: Result
[i
] := 'J';
500 #
$CB: Result
[i
] := 'K';
501 #
$C4: Result
[i
] := 'L';
502 #
$C6: Result
[i
] := ';'; //Chr(186);
503 #
$DD: Result
[i
] := #39; //Chr(222);
504 #
$DF: Result
[i
] := 'Z';
505 #
$D7: Result
[i
] := 'X';
506 #
$D1: Result
[i
] := 'C';
507 #
$CC: Result
[i
] := 'V';
508 #
$C8: Result
[i
] := 'B';
509 #
$D2: Result
[i
] := 'N';
510 #
$DC: Result
[i
] := 'M';
511 #
$C1: Result
[i
] := ','; //Chr(188);
512 #
$DE: Result
[i
] := '.'; //Chr(190);
518 function CheckCheat (ct
: TStrings_Locale
; eofs
: Integer=0): Boolean;
523 ls2
:= Translit(CheatRus
[ct
]);
524 if length(ls1
) = 0 then ls1
:= '~';
525 if length(ls2
) = 0 then ls2
:= '~';
527 (Copy(charbuff
, 17-Length(ls1
)-eofs
, Length(ls1
)) = ls1
) or
528 (Translit(Copy(charbuff
, 17-Length(ls1
)-eofs
, Length(ls1
))) = ls1
) or
529 (Copy(charbuff
, 17-Length(ls2
)-eofs
, Length(ls2
)) = ls2
) or
530 (Translit(Copy(charbuff
, 17-Length(ls2
)-eofs
, Length(ls2
))) = ls2
);
532 if ct = I_GAME_CHEAT_JETPACK then
534 e_WriteLog('ls1: ['+ls1+']', MSG_NOTIFY);
535 e_WriteLog('ls2: ['+ls2+']', MSG_NOTIFY);
536 e_WriteLog('bf0: ['+Copy(charbuff, 17-Length(ls1)-eofs, Length(ls1))+']', MSG_NOTIFY);
537 e_WriteLog('bf1: ['+Translit(Copy(charbuff, 17-Length(ls1)-eofs, Length(ls1)))+']', MSG_NOTIFY);
538 e_WriteLog('bf2: ['+Copy(charbuff, 17-Length(ls2)-eofs, Length(ls2))+']', MSG_NOTIFY);
539 e_WriteLog('bf3: ['+Translit(Copy(charbuff, 17-Length(ls2)-eofs, Length(ls2)))+']', MSG_NOTIFY);
555 if (not gGameOn) or (not gCheats) or ((gGameSettings.GameType <> GT_SINGLE) and
556 (gGameSettings.GameMode <> GM_COOP) and (not gDebugMode))
557 or g_Game_IsNet then Exit;
559 if not gGameOn
then exit
;
560 if not conIsCheatsEnabled
then exit
;
562 s
:= 'SOUND_GAME_RADIO';
565 if CheckCheat(I_GAME_CHEAT_GODMODE
) then
567 if gPlayer1
<> nil then gPlayer1
.GodMode
:= not gPlayer1
.GodMode
;
568 if gPlayer2
<> nil then gPlayer2
.GodMode
:= not gPlayer2
.GodMode
;
572 if CheckCheat(I_GAME_CHEAT_WEAPONS
) then
574 if gPlayer1
<> nil then gPlayer1
.AllRulez(False);
575 if gPlayer2
<> nil then gPlayer2
.AllRulez(False);
579 if CheckCheat(I_GAME_CHEAT_HEALTH
) then
581 if gPlayer1
<> nil then gPlayer1
.AllRulez(True);
582 if gPlayer2
<> nil then gPlayer2
.AllRulez(True);
586 if CheckCheat(I_GAME_CHEAT_DEATH
) then
588 if gPlayer1
<> nil then gPlayer1
.Damage(CHEAT_DAMAGE
, 0, 0, 0, HIT_TRAP
);
589 if gPlayer2
<> nil then gPlayer2
.Damage(CHEAT_DAMAGE
, 0, 0, 0, HIT_TRAP
);
590 s
:= 'SOUND_MONSTER_HAHA';
594 if CheckCheat(I_GAME_CHEAT_DOORS
) then
596 g_Triggers_OpenAll();
600 if CheckCheat(I_GAME_CHEAT_NEXTMAP
) then
602 if gTriggers
<> nil then
603 for a
:= 0 to High(gTriggers
) do
604 if gTriggers
[a
].TriggerType
= TRIGGER_EXIT
then
606 gExitByTrigger
:= True;
607 //g_Game_ExitLevel(gTriggers[a].Data.MapName);
608 g_Game_ExitLevel(gTriggers
[a
].tgcMap
);
614 s2
:= Copy(charbuff
, 15, 2);
615 if CheckCheat(I_GAME_CHEAT_CHANGEMAP
, 2) and (s2
[1] >= '0') and (s2
[1] <= '9') and (s2
[2] >= '0') and (s2
[2] <= '9') then
617 if g_Map_Exist(gGameSettings
.WAD
+ ':\MAP' + s2
) then
625 if CheckCheat(I_GAME_CHEAT_FLY
) then
631 if CheckCheat(I_GAME_CHEAT_JUMPS
) then
633 VEL_JUMP
:= 30-VEL_JUMP
;
637 if CheckCheat(I_GAME_CHEAT_SPEED
) then
639 MAX_RUNVEL
:= 32-MAX_RUNVEL
;
643 if CheckCheat(I_GAME_CHEAT_SUIT
) then
645 if gPlayer1
<> nil then gPlayer1
.GiveItem(ITEM_SUIT
);
646 if gPlayer2
<> nil then gPlayer2
.GiveItem(ITEM_SUIT
);
650 if CheckCheat(I_GAME_CHEAT_AIR
) then
652 if gPlayer1
<> nil then gPlayer1
.GiveItem(ITEM_OXYGEN
);
653 if gPlayer2
<> nil then gPlayer2
.GiveItem(ITEM_OXYGEN
);
657 if CheckCheat(I_GAME_CHEAT_BERSERK
) then
659 if gPlayer1
<> nil then gPlayer1
.GiveItem(ITEM_MEDKIT_BLACK
);
660 if gPlayer2
<> nil then gPlayer2
.GiveItem(ITEM_MEDKIT_BLACK
);
664 if CheckCheat(I_GAME_CHEAT_JETPACK
) then
666 if gPlayer1
<> nil then gPlayer1
.GiveItem(ITEM_JETPACK
);
667 if gPlayer2
<> nil then gPlayer2
.GiveItem(ITEM_JETPACK
);
671 if CheckCheat(I_GAME_CHEAT_NOCLIP
) then
673 if gPlayer1
<> nil then gPlayer1
.SwitchNoClip
;
674 if gPlayer2
<> nil then gPlayer2
.SwitchNoClip
;
678 if CheckCheat(I_GAME_CHEAT_NOTARGET
) then
680 if gPlayer1
<> nil then gPlayer1
.NoTarget
:= not gPlayer1
.NoTarget
;
681 if gPlayer2
<> nil then gPlayer2
.NoTarget
:= not gPlayer2
.NoTarget
;
685 if CheckCheat(I_GAME_CHEAT_NORELOAD
) then
687 if gPlayer1
<> nil then gPlayer1
.NoReload
:= not gPlayer1
.NoReload
;
688 if gPlayer2
<> nil then gPlayer2
.NoReload
:= not gPlayer2
.NoReload
;
691 if CheckCheat(I_GAME_CHEAT_AIMLINE
) then
693 gAimLine
:= not gAimLine
;
696 if CheckCheat(I_GAME_CHEAT_AUTOMAP
) then
698 gShowMap
:= not gShowMap
;
709 procedure KeyPress (K
: Word);
710 var Msg
: g_gui
.TMessage
;
715 if (g_ActiveWindow
<> nil) then
717 Msg
.Msg
:= WM_KEYDOWN
;
718 Msg
.WParam
:= VK_ESCAPE
;
719 g_ActiveWindow
.OnMessage(Msg
);
720 if (not g_Game_IsNet
) and (g_ActiveWindow
= nil) then g_Game_Pause(false); //Fn loves to do this
722 else if (gState
<> STATE_FOLD
) then
724 if gGameOn
or (gState
= STATE_INTERSINGLE
) or (gState
= STATE_INTERCUSTOM
) then
726 g_Game_InGameMenu(True);
728 else if (gExit
= 0) and (gState
<> STATE_SLIST
) then
730 if (gState
<> STATE_MENU
) then
732 if (NetMode
<> NET_NONE
) then
734 g_Game_StopAllSounds(True);
736 gState
:= STATE_MENU
;
740 g_GUI_ShowWindow('MainMenu');
741 g_Sound_PlayEx('MENU_OPEN');
746 IK_F2
, IK_F3
, IK_F4
, IK_F5
, IK_F6
, IK_F7
, IK_F10
:
747 begin // <F2> .. <F6> � <F12>
748 if gGameOn
and (not gConsoleShow
) and (not gChatShow
) then
750 while (g_ActiveWindow
<> nil) do g_GUI_HideWindow(False);
751 if (not g_Game_IsNet
) then g_Game_Pause(True);
753 IK_F2
: g_Menu_Show_SaveMenu();
754 IK_F3
: g_Menu_Show_LoadMenu();
755 IK_F4
: g_Menu_Show_GameSetGame();
756 IK_F5
: g_Menu_Show_OptionsVideo();
757 IK_F6
: g_Menu_Show_OptionsSound();
758 IK_F7
: g_Menu_Show_EndGameMenu();
759 IK_F10
: g_Menu_Show_QuitGameMenu();
766 gJustChatted
:= False;
767 if gConsoleShow
or gChatShow
then
769 g_Console_Control(K
);
771 else if (g_ActiveWindow
<> nil) then
773 Msg
.Msg
:= WM_KEYDOWN
;
775 g_ActiveWindow
.OnMessage(Msg
);
777 else if (gState
= STATE_MENU
) then
779 g_GUI_ShowWindow('MainMenu');
780 g_Sound_PlayEx('MENU_OPEN');
786 procedure KeyPress (K
: Word);
788 gJustChatted
:= False;
789 if gConsoleShow
or gChatShow
then
791 g_Console_Control(K
);
797 procedure CharPress (C
: AnsiChar);
799 var Msg
: g_gui
.TMessage
;
803 if gConsoleShow
or gChatShow
then
808 else if g_ActiveWindow
<> nil then
811 Msg
.WParam
:= Ord(C
);
812 g_ActiveWindow
.OnMessage(Msg
);
819 charbuff
[a
] := charbuff
[a
+ 1];
821 charbuff
[15] := upcase1251(C
);
828 // ////////////////////////////////////////////////////////////////////////// //
829 function gPause (): Boolean; inline; begin result
:= gPauseMain
or gPauseHolmes
; end;
831 procedure g_ResetDynlights ();
835 if not gwin_has_stencil
then begin g_dynLightCount
:= 0; exit
; end;
837 for idx
:= 0 to g_dynLightCount
-1 do
839 if g_dynLights
[idx
].exploCount
= -666 then
846 Inc(g_dynLights
[idx
].exploCount
);
847 if (g_dynLights
[idx
].exploCount
< 10) then
849 g_dynLights
[idx
].radius
:= g_dynLights
[idx
].exploRadius
+g_dynLights
[idx
].exploCount
*8;
850 g_dynLights
[idx
].a
:= 0.4+g_dynLights
[idx
].exploCount
/10;
851 if (g_dynLights
[idx
].a
> 0.8) then g_dynLights
[idx
].a
:= 0.8;
852 if lnum
<> idx
then g_dynLights
[lnum
] := g_dynLights
[idx
];
857 g_dynLightCount
:= lnum
;
860 procedure g_AddDynLight (x
, y
, radius
: Integer; r
, g
, b
, a
: Single);
862 if not gwin_has_stencil
then exit
;
863 if g_dynLightCount
= length(g_dynLights
) then SetLength(g_dynLights
, g_dynLightCount
+1024);
864 g_dynLights
[g_dynLightCount
].x
:= x
;
865 g_dynLights
[g_dynLightCount
].y
:= y
;
866 g_dynLights
[g_dynLightCount
].radius
:= radius
;
867 g_dynLights
[g_dynLightCount
].r
:= r
;
868 g_dynLights
[g_dynLightCount
].g
:= g
;
869 g_dynLights
[g_dynLightCount
].b
:= b
;
870 g_dynLights
[g_dynLightCount
].a
:= a
;
871 g_dynLights
[g_dynLightCount
].exploCount
:= -666;
872 Inc(g_dynLightCount
);
875 procedure g_DynLightExplosion (x
, y
, radius
: Integer; r
, g
, b
: Single);
877 if not gwin_has_stencil
then exit
;
878 if g_dynLightCount
= length(g_dynLights
) then SetLength(g_dynLights
, g_dynLightCount
+1024);
879 g_dynLights
[g_dynLightCount
].x
:= x
;
880 g_dynLights
[g_dynLightCount
].y
:= y
;
881 g_dynLights
[g_dynLightCount
].radius
:= 0;
882 g_dynLights
[g_dynLightCount
].exploRadius
:= radius
;
883 g_dynLights
[g_dynLightCount
].r
:= r
;
884 g_dynLights
[g_dynLightCount
].g
:= g
;
885 g_dynLights
[g_dynLightCount
].b
:= b
;
886 g_dynLights
[g_dynLightCount
].a
:= 0;
887 g_dynLights
[g_dynLightCount
].exploCount
:= 0;
888 Inc(g_dynLightCount
);
891 // ////////////////////////////////////////////////////////////////////////// //
892 function conIsCheatsEnabled (): Boolean; inline;
895 if g_Game_IsNet
then exit
;
896 if not gDebugMode
then
898 //if not gCheats then exit;
899 if not (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
]) then exit
;
900 if not (gGameSettings
.GameMode
in [GM_COOP
, GM_SINGLE
]) then exit
;
905 // ////////////////////////////////////////////////////////////////////////// //
907 TParamStrValue
= record
912 TParamStrValues
= Array of TParamStrValue
;
915 INTER_ACTION_TEXT
= 1;
916 INTER_ACTION_PIC
= 2;
917 INTER_ACTION_MUSIC
= 3;
922 DataLoaded
: Boolean = False;
924 MapList
: SSArray
= nil;
925 MapIndex
: Integer = -1;
926 InterReadyTime
: Integer = -1;
927 StatDate
: string = '';
942 function Compare(a
, b
: TPlayerStat
): Integer;
944 if a
.Spectator
then Result
:= 1
945 else if b
.Spectator
then Result
:= -1
946 else if a
.Frags
< b
.Frags
then Result
:= 1
947 else if a
.Frags
> b
.Frags
then Result
:= -1
948 else if a
.Deaths
< b
.Deaths
then Result
:= -1
949 else if a
.Deaths
> b
.Deaths
then Result
:= 1
950 else if a
.Kills
< b
.Kills
then Result
:= -1
954 procedure SortGameStat(var stat
: TPlayerStatArray
);
959 if stat
= nil then Exit
;
961 for I
:= High(stat
) downto Low(stat
) do
962 for J
:= Low(stat
) to High(stat
) - 1 do
963 if Compare(stat
[J
], stat
[J
+ 1]) = 1 then
966 stat
[J
] := stat
[J
+ 1];
971 // saves a shitty CSV containing the game stats passed to it
972 procedure SaveGameStat(Stat
: TEndCustomGameStat
; Path
: string);
975 dir
, fname
, map
, mode
, etime
: String;
979 dir
:= e_GetWriteableDir(StatsDirs
);
980 // stats are placed in stats/yy/mm/dd/*.csv
981 fname
:= e_CatPath(dir
, Path
);
982 ForceDirectories(fname
); // ensure yy/mm/dd exists within the stats dir
983 fname
:= e_CatPath(fname
, StatFilename
+ '.csv');
984 AssignFile(s
, fname
);
987 // line 1: stats ver, datetime, server name, map name, game mode, time limit, score limit, dmflags, game time, num players
988 if g_Game_IsNet
then fname
:= NetServerName
else fname
:= '';
989 map
:= g_ExtractWadNameNoPath(gMapInfo
.Map
) + ':/' + g_ExtractFileName(gMapInfo
.Map
);
990 mode
:= g_Game_ModeToText(Stat
.GameMode
);
991 etime
:= Format('%d:%.2d:%.2d', [
992 Stat
.GameTime
div 1000 div 3600,
993 (Stat
.GameTime
div 1000 div 60) mod 60,
994 Stat
.GameTime
div 1000 mod 60
996 WriteLn(s
, 'stats_ver,datetime,server,map,mode,timelimit,scorelimit,dmflags,time,num_players');
997 WriteLn(s
, Format('%d,%s,%s,%s,%s,%u,%u,%u,%s,%d', [
1003 gGameSettings
.TimeLimit
,
1004 gGameSettings
.GoalLimit
,
1005 gGameSettings
.Options
,
1007 Length(Stat
.PlayerStat
)
1009 // line 2: game specific shit
1010 // if it's a team game: red score, blue score
1011 // if it's a coop game: monsters killed, monsters total, secrets found, secrets total
1012 // otherwise nothing
1013 if Stat
.GameMode
in [GM_TDM
, GM_CTF
] then
1015 Format('red_score,blue_score' + LineEnding
+ '%d,%d', [Stat
.TeamStat
[TEAM_RED
].Goals
, Stat
.TeamStat
[TEAM_BLUE
].Goals
]))
1016 else if Stat
.GameMode
in [GM_COOP
, GM_SINGLE
] then
1018 Format('mon_killed,mon_total,secrets_found,secrets_total' + LineEnding
+ '%d,%d,%d,%d',[gCoopMonstersKilled
, gTotalMonsters
, gCoopSecretsFound
, gSecretsCount
]));
1019 // lines 3-...: team, player name, frags, deaths
1020 WriteLn(s
, 'team,name,frags,deaths');
1021 for I
:= Low(Stat
.PlayerStat
) to High(Stat
.PlayerStat
) do
1022 with Stat
.PlayerStat
[I
] do
1023 WriteLn(s
, Format('%d,%s,%d,%d', [Team
, dquoteStr(Name
), Frags
, Deaths
]));
1025 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_WRITE
], [fname
]));
1028 g_Console_Add('could not create gamestats file "' + fname
+ '"');
1033 function g_Game_ModeToText(Mode
: Byte): string;
1037 GM_DM
: Result
:= _lc
[I_MENU_GAME_TYPE_DM
];
1038 GM_TDM
: Result
:= _lc
[I_MENU_GAME_TYPE_TDM
];
1039 GM_CTF
: Result
:= _lc
[I_MENU_GAME_TYPE_CTF
];
1040 GM_COOP
: Result
:= _lc
[I_MENU_GAME_TYPE_COOP
];
1041 GM_SINGLE
: Result
:= _lc
[I_MENU_GAME_TYPE_SINGLE
];
1045 function g_Game_TextToMode(Mode
: string): Byte;
1048 Mode
:= UpperCase(Mode
);
1049 if Mode
= _lc
[I_MENU_GAME_TYPE_DM
] then
1054 if Mode
= _lc
[I_MENU_GAME_TYPE_TDM
] then
1059 if Mode
= _lc
[I_MENU_GAME_TYPE_CTF
] then
1064 if Mode
= _lc
[I_MENU_GAME_TYPE_COOP
] then
1069 if Mode
= _lc
[I_MENU_GAME_TYPE_SINGLE
] then
1071 Result
:= GM_SINGLE
;
1076 function g_Game_IsNet(): Boolean;
1078 Result
:= (gGameSettings
.GameType
in [GT_SERVER
, GT_CLIENT
]);
1081 function g_Game_IsServer(): Boolean;
1083 Result
:= (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
, GT_SERVER
]);
1086 function g_Game_IsClient(): Boolean;
1088 Result
:= (gGameSettings
.GameType
= GT_CLIENT
);
1091 function g_Game_GetMegaWADInfo(WAD
: String): TMegaWADInfo
;
1098 Result
.name
:= ExtractFileName(WAD
);
1099 Result
.description
:= '';
1100 Result
.author
:= '';
1102 w
:= TWADFile
.Create();
1105 if not w
.GetResource('INTERSCRIPT', p
, len
) then
1111 cfg
:= TConfig
.CreateMem(p
, len
);
1112 Result
.name
:= cfg
.ReadStr('megawad', 'name', ExtractFileName(WAD
));
1113 Result
.description
:= cfg
.ReadStr('megawad', 'description', '');
1114 Result
.author
:= cfg
.ReadStr('megawad', 'author', '');
1115 Result
.pic
:= cfg
.ReadStr('megawad', 'pic', '');
1121 procedure g_Game_FreeWAD
;
1124 g_Sound_Delete('MUSIC_endmus');
1125 ZeroMemory(@MegaWAD
, SizeOf(MegaWAD
));
1126 gGameSettings
.WAD
:= '';
1129 procedure g_Game_LoadWAD(WAD
: string);
1138 gGameSettings
.WAD
:= WAD
;
1139 if not (gGameSettings
.GameMode
in [GM_COOP
, GM_SINGLE
]) then
1142 MegaWAD
.info
:= g_Game_GetMegaWADInfo(WAD
);
1144 w
:= TWADFile
.Create();
1147 if not w
.GetResource('INTERSCRIPT', p
, len
) then
1153 cfg
:= TConfig
.CreateMem(p
, len
);
1156 MegaWAD
.endpic
:= cfg
.ReadStr('megawad', 'endpic', '');
1157 if MegaWAD
.endpic
<> '' then
1158 EndPicPath
:= e_GetResourcePath(WadDirs
, MegaWAD
.endpic
, WAD
);
1160 MegaWAD
.endmus
:= cfg
.ReadStr('megawad', 'endmus', 'Standart.wad:D2DMUS\КОНЕЦ');
1161 if MegaWAD
.endmus
<> '' then
1163 s
:= e_GetResourcePath(WadDirs
, MegaWAD
.endmus
, WAD
);
1164 g_Sound_CreateWADEx('MUSIC_endmus', s
, True);
1172 {procedure start_trigger(t: string);
1176 function next_trigger(): Boolean;
1180 procedure DisableCheats();
1186 if gPlayer1
<> nil then gPlayer1
.GodMode
:= False;
1187 if gPlayer2
<> nil then gPlayer2
.GodMode
:= False;
1188 if gPlayer1
<> nil then gPlayer1
.NoTarget
:= False;
1189 if gPlayer2
<> nil then gPlayer2
.NoTarget
:= False;
1191 {$IF DEFINED(D2F_DEBUG)}
1192 if gPlayer1
<> nil then gPlayer1
.NoTarget
:= True;
1193 gAimLine
:= g_dbg_aimline_on
;
1197 procedure g_Game_ExecuteEvent(Name
: String);
1203 if gEvents
= nil then
1205 for a
:= 0 to High(gEvents
) do
1206 if gEvents
[a
].Name
= Name
then
1208 if gEvents
[a
].Command
<> '' then
1209 g_Console_Process(gEvents
[a
].Command
, True);
1214 function g_Game_DelayEvent(DEType
: Byte; Time
: LongWord; Num
: Integer = 0; Str
: String = ''): Integer;
1219 if gDelayedEvents
<> nil then
1220 for a
:= 0 to High(gDelayedEvents
) do
1221 if not gDelayedEvents
[a
].Pending
then
1228 SetLength(gDelayedEvents
, Length(gDelayedEvents
) + 1);
1229 n
:= High(gDelayedEvents
);
1231 gDelayedEvents
[n
].Pending
:= True;
1232 gDelayedEvents
[n
].DEType
:= DEType
;
1233 gDelayedEvents
[n
].DENum
:= Num
;
1234 gDelayedEvents
[n
].DEStr
:= Str
;
1235 if DEType
= DE_GLOBEVENT
then
1236 gDelayedEvents
[n
].Time
:= (GetTickCount64() {div 1000}) + Time
1238 gDelayedEvents
[n
].Time
:= gTime
+ Time
;
1242 procedure EndGame();
1248 if g_Game_IsNet
and g_Game_IsServer
then
1249 MH_SEND_GameEvent(NET_EV_MAPEND
, Byte(gMissionFailed
));
1252 gPauseMain
:= false;
1253 gPauseHolmes
:= false;
1256 g_Game_StopAllSounds(False);
1261 EndingGameCounter
:= 0;
1263 {$IFDEF ENABLE_MENU}
1264 g_ActiveWindow
:= nil;
1267 gLMSRespawn
:= LMS_RESPAWN_NONE
;
1268 gLMSRespawnTime
:= 0;
1271 EXIT_SIMPLE
: // Выход через меню или конец теста
1275 begin // Это был тест
1279 begin // Выход в главное меню
1280 {$IFDEF DISABLE_MENU}
1281 gState
:= STATE_MENU
; // ???
1283 gMusic
.SetByName('MUSIC_MENU');
1285 if gState
<> STATE_SLIST
then
1287 g_GUI_ShowWindow('MainMenu');
1288 gState
:= STATE_MENU
;
1292 // Обновляем список серверов
1293 slReturnPressed
:= True;
1294 if g_Net_Slist_Fetch(slCurrent
) then
1296 if slCurrent
= nil then
1297 slWaitStr
:= _lc
[I_NET_SLIST_NOSERVERS
];
1300 slWaitStr
:= _lc
[I_NET_SLIST_ERROR
];
1301 g_Serverlist_GenerateTable(slCurrent
, slTable
);
1304 g_Game_ExecuteEvent('ongameend');
1308 EXIT_RESTART
: // Начать уровень сначала
1310 if not g_Game_IsClient
then g_Game_Restart();
1313 EXIT_ENDLEVELCUSTOM
: // Закончился уровень в Своей игре
1315 // Статистика Своей игры:
1316 FileName
:= g_ExtractWadName(gMapInfo
.Map
);
1318 CustomStat
.GameTime
:= gTime
;
1319 CustomStat
.Map
:= ExtractFileName(FileName
)+':'+g_ExtractFileName(gMapInfo
.Map
); //ResName;
1320 CustomStat
.MapName
:= gMapInfo
.Name
;
1321 CustomStat
.GameMode
:= gGameSettings
.GameMode
;
1322 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
1323 CustomStat
.TeamStat
:= gTeamStat
;
1325 CustomStat
.PlayerStat
:= nil;
1327 // Статистика игроков:
1328 if gPlayers
<> nil then
1330 for a
:= 0 to High(gPlayers
) do
1331 if gPlayers
[a
] <> nil then
1333 SetLength(CustomStat
.PlayerStat
, Length(CustomStat
.PlayerStat
)+1);
1334 with CustomStat
.PlayerStat
[High(CustomStat
.PlayerStat
)] do
1337 Name
:= gPlayers
[a
].Name
;
1338 Frags
:= gPlayers
[a
].Frags
;
1339 Deaths
:= gPlayers
[a
].Death
;
1340 Kills
:= gPlayers
[a
].Kills
;
1341 Team
:= gPlayers
[a
].Team
;
1342 Color
:= gPlayers
[a
].Model
.Color
;
1343 Spectator
:= gPlayers
[a
].FSpectator
;
1347 SortGameStat(CustomStat
.PlayerStat
);
1349 if (gSaveStats
or gScreenshotStats
) and (Length(CustomStat
.PlayerStat
) > 1) then
1352 if g_Game_IsNet
then StatFilename
:= NetServerName
else StatFilename
:= 'local';
1353 StatDate
:= FormatDateTime('yymmdd_hhnnss', t
);
1354 StatFilename
:= StatFilename
+ '_' + CustomStat
.Map
+ '_' + g_Game_ModeToText(CustomStat
.GameMode
);
1355 StatFilename
:= sanitizeFilename(StatFilename
) + '_' + StatDate
;
1357 SaveGameStat(CustomStat
, FormatDateTime('yyyy"/"mm"/"dd', t
));
1360 StatShotDone
:= False;
1363 g_Game_ExecuteEvent('onmapend');
1364 if not g_Game_IsClient
then g_Player_ResetReady
;
1365 gInterReadyCount
:= 0;
1367 // Затухающий экран:
1368 EndingGameCounter
:= 255;
1369 gState
:= STATE_FOLD
;
1371 if gDefInterTime
< 0 then
1372 gInterEndTime
:= IfThen((gGameSettings
.GameType
= GT_SERVER
) and (gPlayer1
= nil), 15000, 25000)
1374 gInterEndTime
:= gDefInterTime
* 1000;
1377 EXIT_ENDLEVELSINGLE
: // Закончился уровень в Одиночной игре
1379 // Статистика Одиночной игры:
1380 SingleStat
.GameTime
:= gTime
;
1381 SingleStat
.TwoPlayers
:= gPlayer2
<> nil;
1382 SingleStat
.TotalSecrets
:= gSecretsCount
;
1383 // Статистика первого игрока:
1384 SingleStat
.PlayerStat
[0].Kills
:= gPlayer1
.MonsterKills
;
1385 SingleStat
.PlayerStat
[0].Secrets
:= gPlayer1
.Secrets
;
1386 // Статистика второго игрока (если есть):
1387 if SingleStat
.TwoPlayers
then
1389 SingleStat
.PlayerStat
[1].Kills
:= gPlayer2
.MonsterKills
;
1390 SingleStat
.PlayerStat
[1].Secrets
:= gPlayer2
.Secrets
;
1393 g_Game_ExecuteEvent('onmapend');
1396 if gNextMap
<> '' then
1398 gMusic
.SetByName('MUSIC_INTERMUS');
1400 gState
:= STATE_INTERSINGLE
;
1403 g_Game_ExecuteEvent('oninter');
1405 else // Больше нет карт
1407 // Затухающий экран:
1408 EndingGameCounter
:= 255;
1409 gState
:= STATE_FOLD
;
1414 // Окончание обработано:
1415 if gExit
<> EXIT_QUIT
then
1419 procedure g_Game_Init();
1423 gTempDelete
:= False;
1425 sfsGCDisable(); // temporary disable removing of temporary volumes
1428 g_Game_ClearLoading();
1429 g_Game_SetLoadingText(Format('Doom 2D: Forever %s', [GAME_VERSION
]), 0, False);
1430 g_Game_SetLoadingText('', 0, False);
1432 // g_Game_SetLoadingText(_lc[I_LOAD_MODELS], 0, False);
1435 gPauseMain
:= false;
1436 gPauseHolmes
:= false;
1439 {e_MouseInfo.Accel := 1.0;}
1441 g_Game_SetLoadingText(_lc
[I_LOAD_GAME_DATA
], 0, False);
1444 g_Game_SetLoadingText(_lc
[I_LOAD_MUSIC
], 0, False);
1445 g_Sound_CreateWADEx('MUSIC_INTERMUS', GameWAD
+':MUSIC\INTERMUS', True);
1446 g_Sound_CreateWADEx('MUSIC_MENU', GameWAD
+':MUSIC\MENU', True);
1447 g_Sound_CreateWADEx('MUSIC_ROUNDMUS', GameWAD
+':MUSIC\ROUNDMUS', True, True);
1448 g_Sound_CreateWADEx('MUSIC_STDENDMUS', GameWAD
+':MUSIC\ENDMUS', True);
1450 gMusic
:= TMusic
.Create();
1451 gMusic
.SetByName('MUSIC_MENU');
1454 gGameSettings
.WarmupTime
:= 30;
1456 gState
:= STATE_MENU
;
1458 SetLength(gEvents
, 6);
1459 gEvents
[0].Name
:= 'ongamestart';
1460 gEvents
[1].Name
:= 'ongameend';
1461 gEvents
[2].Name
:= 'onmapstart';
1462 gEvents
[3].Name
:= 'onmapend';
1463 gEvents
[4].Name
:= 'oninter';
1464 gEvents
[5].Name
:= 'onwadend';
1466 sfsGCEnable(); // enable releasing unused volumes
1470 procedure g_Game_Free(freeTextures
: Boolean=true);
1472 if NetMode
= NET_CLIENT
then g_Net_Disconnect();
1473 if NetMode
= NET_SERVER
then g_Net_Host_Die();
1475 g_Map_Free(freeTextures
);
1477 g_Player_RemoveAllCorpses();
1479 gGameSettings
.GameType
:= GT_NONE
;
1480 if gGameSettings
.GameMode
= GM_SINGLE
then
1481 gGameSettings
.GameMode
:= GM_DM
;
1482 gSwitchGameMode
:= gGameSettings
.GameMode
;
1485 gExitByTrigger
:= False;
1488 function IsActivePlayer(p
: TPlayer
): Boolean;
1493 Result
:= (not p
.FDummy
) and (not p
.FSpectator
);
1496 function GetActivePlayerID_Next(Skip
: Integer = -1): Integer;
1502 if gPlayers
= nil then
1506 for a
:= Low(gPlayers
) to High(gPlayers
) do
1507 if IsActivePlayer(gPlayers
[a
]) then
1509 SetLength(ids
, Length(ids
) + 1);
1510 ids
[High(ids
)] := gPlayers
[a
].UID
;
1511 if gPlayers
[a
].UID
= Skip
then
1514 if Length(ids
) = 0 then
1519 Result
:= ids
[(idx
+ 1) mod Length(ids
)];
1522 function GetActivePlayerID_Prev(Skip
: Integer = -1): Integer;
1528 if gPlayers
= nil then
1532 for a
:= Low(gPlayers
) to High(gPlayers
) do
1533 if IsActivePlayer(gPlayers
[a
]) then
1535 SetLength(ids
, Length(ids
) + 1);
1536 ids
[High(ids
)] := gPlayers
[a
].UID
;
1537 if gPlayers
[a
].UID
= Skip
then
1540 if Length(ids
) = 0 then
1543 Result
:= ids
[Length(ids
) - 1]
1545 Result
:= ids
[(Length(ids
) - 1 + idx
) mod Length(ids
)];
1548 function GetActivePlayerID_Random(Skip
: Integer = -1): Integer;
1554 if gPlayers
= nil then
1558 for a
:= Low(gPlayers
) to High(gPlayers
) do
1559 if IsActivePlayer(gPlayers
[a
]) then
1561 SetLength(ids
, Length(ids
) + 1);
1562 ids
[High(ids
)] := gPlayers
[a
].UID
;
1563 if gPlayers
[a
].UID
= Skip
then
1566 if Length(ids
) = 0 then
1568 if Length(ids
) = 1 then
1573 Result
:= ids
[Random(Length(ids
))];
1575 while (idx
<> -1) and (Result
= Skip
) and (a
> 0) do
1577 Result
:= ids
[Random(Length(ids
))];
1582 function GetRandomSpectMode(Current
: Byte): Byte;
1589 0: Result
:= SPECT_STATS
;
1590 1: Result
:= SPECT_MAPVIEW
;
1591 2: Result
:= SPECT_MAPVIEW
;
1592 3: Result
:= SPECT_PLAYERS
;
1593 4: Result
:= SPECT_PLAYERS
;
1594 5: Result
:= SPECT_PLAYERS
;
1595 6: Result
:= SPECT_PLAYERS
;
1597 if (Current
in [SPECT_STATS
, SPECT_MAPVIEW
]) and (Current
= Result
) then
1601 procedure ProcessPlayerControls (plr
: TPlayer
; p
: Integer; var MoveButton
: Byte);
1607 if (plr
= nil) then exit
;
1608 if (p
= 2) then time
:= 1000 else time
:= 1;
1609 strafeDir
:= MoveButton
shr 4;
1610 MoveButton
:= MoveButton
and $0F;
1612 if gPlayerAction
[p
, ACTION_MOVELEFT
] and (not gPlayerAction
[p
, ACTION_MOVERIGHT
]) then
1613 MoveButton
:= 1 // Нажата только "Влево"
1614 else if (not gPlayerAction
[p
, ACTION_MOVELEFT
]) and gPlayerAction
[p
, ACTION_MOVERIGHT
] then
1615 MoveButton
:= 2 // Нажата только "Вправо"
1616 else if (not gPlayerAction
[p
, ACTION_MOVELEFT
]) and (not gPlayerAction
[p
, ACTION_MOVERIGHT
]) then
1617 MoveButton
:= 0; // Не нажаты ни "Влево", ни "Вправо"
1619 // Сейчас или раньше были нажаты "Влево"/"Вправо" => передаем игроку:
1620 if MoveButton
= 1 then
1621 plr
.PressKey(KEY_LEFT
, time
)
1622 else if MoveButton
= 2 then
1623 plr
.PressKey(KEY_RIGHT
, time
);
1625 // if we have "strafe" key, turn off old strafe mechanics
1626 if gPlayerAction
[p
, ACTION_STRAFE
] then
1628 // new strafe mechanics
1629 if (strafeDir
= 0) then
1630 strafeDir
:= MoveButton
; // start strafing
1631 // now set direction according to strafe (reversed)
1632 if (strafeDir
= 2) then
1633 plr
.SetDirection(TDirection
.D_LEFT
)
1634 else if (strafeDir
= 1) then
1635 plr
.SetDirection(TDirection
.D_RIGHT
)
1639 strafeDir
:= 0; // not strafing anymore
1640 // Раньше была нажата "Вправо", а сейчас "Влево" => бежим вправо, смотрим влево:
1641 if (MoveButton
= 2) and gPlayerAction
[p
, ACTION_MOVELEFT
] then
1642 plr
.SetDirection(TDirection
.D_LEFT
)
1643 // Раньше была нажата "Влево", а сейчас "Вправо" => бежим влево, смотрим вправо:
1644 else if (MoveButton
= 1) and gPlayerAction
[p
, ACTION_MOVERIGHT
] then
1645 plr
.SetDirection(TDirection
.D_RIGHT
)
1646 // Что-то было нажато и не изменилось => куда бежим, туда и смотрим:
1647 else if MoveButton
<> 0 then
1648 plr
.SetDirection(TDirection(MoveButton
-1))
1651 // fix movebutton state
1652 MoveButton
:= MoveButton
or (strafeDir
shl 4);
1654 // Остальные клавиши:
1655 if gPlayerAction
[p
, ACTION_JUMP
] then plr
.PressKey(KEY_JUMP
, time
);
1656 if gPlayerAction
[p
, ACTION_LOOKUP
] then plr
.PressKey(KEY_UP
, time
);
1657 if gPlayerAction
[p
, ACTION_LOOKDOWN
] then plr
.PressKey(KEY_DOWN
, time
);
1658 if gPlayerAction
[p
, ACTION_ATTACK
] then plr
.PressKey(KEY_FIRE
);
1659 if gPlayerAction
[p
, ACTION_WEAPNEXT
] then plr
.PressKey(KEY_NEXTWEAPON
);
1660 if gPlayerAction
[p
, ACTION_WEAPPREV
] then plr
.PressKey(KEY_PREVWEAPON
);
1661 if gPlayerAction
[p
, ACTION_ACTIVATE
] then plr
.PressKey(KEY_OPEN
);
1663 gPlayerAction
[p
, ACTION_WEAPNEXT
] := False; // HACK, remove after readyweaon&pendinweapon implementation
1664 gPlayerAction
[p
, ACTION_WEAPPREV
] := False; // HACK, remove after readyweaon&pendinweapon implementation
1666 for i
:= WP_FIRST
to WP_LAST
do
1668 if gSelectWeapon
[p
, i
] then
1670 plr
.QueueWeaponSwitch(i
); // all choices are passed there, and god will take the best
1671 gSelectWeapon
[p
, i
] := False
1675 {$IFDEF ENABLE_MENU}
1676 // HACK: add dynlight here
1677 if gwin_k8_enable_light_experiments
then
1679 if e_KeyPressed(IK_F8
) and gGameOn
and (not gConsoleShow
) and (g_ActiveWindow
= nil) then
1681 g_playerLight
:= true;
1683 if e_KeyPressed(IK_F9
) and gGameOn
and (not gConsoleShow
) and (g_ActiveWindow
= nil) then
1685 g_playerLight
:= false;
1689 if gwin_has_stencil
and g_playerLight
then g_AddDynLight(plr
.GameX
+32, plr
.GameY
+40, 128, 1, 1, 0, 0.6);
1693 // HACK: don't have a "key was pressed" function
1694 procedure InterReady();
1696 if InterReadyTime
> gTime
then Exit
;
1697 InterReadyTime
:= gTime
+ 3000;
1698 MC_SEND_CheatRequest(NET_CHEAT_READY
);
1701 procedure g_Game_PreUpdate();
1703 // these are in separate PreUpdate functions because they can interact during Update()
1704 // and are synced over the net
1705 // we don't care that much about corpses and gibs
1706 g_Player_PreUpdate();
1707 g_Monsters_PreUpdate();
1708 g_Items_PreUpdate();
1709 g_Weapon_PreUpdate();
1712 procedure g_Game_Update();
1714 {$IFDEF ENABLE_MENU}
1715 Msg
: g_gui
.TMessage
;
1722 function sendMonsPos (mon
: TMonster
): Boolean;
1724 result
:= false; // don't stop
1725 // this will also reset "need-send" flag
1726 if mon
.gncNeedSend
then
1728 MH_SEND_MonsterPos(mon
.UID
);
1730 else if (mon
.MonsterType
= MONSTER_BARREL
) then
1732 if (mon
.GameVelX
<> 0) or (mon
.GameVelY
<> 0) then MH_SEND_MonsterPos(mon
.UID
);
1734 else if (mon
.MonsterState
<> MONSTATE_SLEEP
) then
1736 if (mon
.MonsterState
<> MONSTATE_DEAD
) or (mon
.GameVelX
<> 0) or (mon
.GameVelY
<> 0) then MH_SEND_MonsterPos(mon
.UID
);
1740 function sendMonsPosUnexpected (mon
: TMonster
): Boolean;
1742 result
:= false; // don't stop
1743 // this will also reset "need-send" flag
1744 if mon
.gncNeedSend
then MH_SEND_MonsterPos(mon
.UID
);
1748 reliableUpdate
: Boolean;
1753 // Пора выключать игру:
1754 if gExit
= EXIT_QUIT
then
1756 // Игра закончилась - обрабатываем:
1760 if gExit
= EXIT_QUIT
then
1764 // Читаем клавиатуру и джойстик, если окно активно
1765 // no need to, as we'll do it in event handler
1767 // Обновляем консоль (движение и сообщения):
1770 if (NetMode
= NET_NONE
) and (g_Game_IsNet
) and (gGameOn
or (gState
in [STATE_FOLD
, STATE_INTERCUSTOM
])) then
1772 gExit
:= EXIT_SIMPLE
;
1777 // process master server communications
1778 g_Net_Slist_Pulse();
1781 STATE_INTERSINGLE
, // Статистка после прохождения уровня в Одиночной игре
1782 STATE_INTERCUSTOM
, // Статистка после прохождения уровня в Своей игре
1783 STATE_INTERTEXT
, // Текст между уровнями
1784 STATE_INTERPIC
: // Картинка между уровнями
1786 if g_Game_IsNet
and g_Game_IsServer
then
1788 gInterTime
:= gInterTime
+ GAME_TICK
;
1789 a
:= Min((gInterEndTime
- gInterTime
) div 1000 + 1, 255);
1790 if a
<> gServInterTime
then
1792 gServInterTime
:= a
;
1793 MH_SEND_TimeSync(gServInterTime
);
1797 if (not g_Game_IsClient
) and
1801 e_KeyPressed(IK_RETURN
) or e_KeyPressed(IK_KPRETURN
) or e_KeyPressed(IK_SPACE
) or
1802 e_KeyPressed(VK_FIRE
) or e_KeyPressed(VK_OPEN
) or
1803 e_KeyPressed(JOY0_ATTACK
) or e_KeyPressed(JOY1_ATTACK
) or
1804 e_KeyPressed(JOY2_ATTACK
) or e_KeyPressed(JOY3_ATTACK
)
1806 and (not gJustChatted
) and (not gConsoleShow
) and (not gChatShow
)
1807 {$IFDEF ENABLE_MENU}
1808 and (g_ActiveWindow
= nil)
1811 or (g_Game_IsNet
and ((gInterTime
> gInterEndTime
) or ((gInterReadyCount
>= NetClientCount
) and (NetClientCount
> 0))))
1814 begin // Нажали <Enter>/<Пробел> или прошло достаточно времени:
1815 g_Game_StopAllSounds(True);
1817 if gMapOnce
then // Это был тест
1818 gExit
:= EXIT_SIMPLE
1820 if gNextMap
<> '' then // Переходим на следующую карту
1821 g_Game_ChangeMap(gNextMap
)
1822 else // Следующей карты нет
1824 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
] then
1826 // Выход в главное меню:
1828 {$IFDEF ENABLE_MENU}
1829 g_GUI_ShowWindow('MainMenu');
1830 gMusic
.SetByName('MUSIC_MENU');
1833 gState
:= STATE_MENU
;
1836 // Финальная картинка:
1837 g_Game_ExecuteEvent('onwadend');
1839 if not gMusic
.SetByName('MUSIC_endmus') then
1840 gMusic
.SetByName('MUSIC_STDENDMUS');
1842 gState
:= STATE_ENDPIC
;
1844 g_Game_ExecuteEvent('ongameend');
1849 else if g_Game_IsClient
and
1852 e_KeyPressed(IK_RETURN
) or e_KeyPressed(IK_KPRETURN
) or e_KeyPressed(IK_SPACE
) or
1853 e_KeyPressed(VK_FIRE
) or e_KeyPressed(VK_OPEN
) or
1854 e_KeyPressed(JOY0_ATTACK
) or e_KeyPressed(JOY1_ATTACK
) or
1855 e_KeyPressed(JOY2_ATTACK
) or e_KeyPressed(JOY3_ATTACK
)
1857 and (not gJustChatted
) and (not gConsoleShow
) and (not gChatShow
)
1858 {$IFDEF ENABLE_MENU}
1859 and (g_ActiveWindow
= nil)
1868 if gState
= STATE_INTERTEXT
then
1869 if InterText
.counter
> 0 then
1870 InterText
.counter
:= InterText
.counter
- 1;
1873 STATE_FOLD
: // Затухание экрана
1875 if EndingGameCounter
= 0 then
1877 // Закончился уровень в Своей игре:
1878 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
1880 InterReadyTime
:= -1;
1881 if gLastMap
and (gGameSettings
.GameMode
= GM_COOP
) then
1883 g_Game_ExecuteEvent('onwadend');
1884 if not gMusic
.SetByName('MUSIC_endmus') then
1885 gMusic
.SetByName('MUSIC_STDENDMUS');
1888 gMusic
.SetByName('MUSIC_ROUNDMUS');
1891 gState
:= STATE_INTERCUSTOM
;
1894 else // Закончилась последняя карта в Одиночной игре
1896 gMusic
.SetByName('MUSIC_INTERMUS');
1898 gState
:= STATE_INTERSINGLE
;
1901 g_Game_ExecuteEvent('oninter');
1904 DecMin(EndingGameCounter
, 6, 0);
1907 STATE_ENDPIC
: // Картинка окончания мегаВада
1909 if gMapOnce
then // Это был тест
1911 gExit
:= EXIT_SIMPLE
;
1917 g_Serverlist_Control(slCurrent
, slTable
);
1920 // Статистика по Tab:
1922 IsDrawStat
:= (not gConsoleShow
) and (not gChatShow
) and (gGameSettings
.GameType
<> GT_SINGLE
) and g_Console_Action(ACTION_SCORES
);
1925 if gGameOn
and not gPause
and (gState
<> STATE_FOLD
) then
1927 // Время += 28 миллисекунд:
1928 gTime
:= gTime
+ GAME_TICK
;
1930 // Сообщение посередине экрана:
1931 if MessageTime
= 0 then
1933 if MessageTime
> 0 then
1934 MessageTime
:= MessageTime
- 1;
1936 if (g_Game_IsServer
) then
1938 // Был задан лимит времени:
1939 if (gGameSettings
.TimeLimit
> 0) then
1940 if (gTime
- gGameStartTime
) div 1000 >= gGameSettings
.TimeLimit
then
1941 begin // Он прошел => конец уровня
1946 // Надо респавнить игроков в LMS:
1947 if (gLMSRespawn
> LMS_RESPAWN_NONE
) and (gLMSRespawnTime
< gTime
) then
1948 g_Game_RestartRound(gLMSSoftSpawn
);
1950 // Проверим результат голосования, если время прошло
1951 if gVoteInProgress
and (gVoteTimer
< gTime
) then
1953 else if gVotePassed
and (gVoteCmdTimer
< gTime
) then
1955 g_Console_Process(gVoteCommand
);
1957 gVotePassed
:= False;
1960 // Замеряем время захвата флагов
1961 if gFlags
[FLAG_RED
].State
= FLAG_STATE_CAPTURED
then
1962 gFlags
[FLAG_RED
].CaptureTime
:= gFlags
[FLAG_RED
].CaptureTime
+ GAME_TICK
;
1963 if gFlags
[FLAG_BLUE
].State
= FLAG_STATE_CAPTURED
then
1964 gFlags
[FLAG_BLUE
].CaptureTime
:= gFlags
[FLAG_BLUE
].CaptureTime
+ GAME_TICK
;
1966 // Был задан лимит побед:
1967 if (gGameSettings
.GoalLimit
> 0) then
1971 if gGameSettings
.GameMode
= GM_DM
then
1972 begin // В DM ищем игрока с max фрагами
1973 for i
:= 0 to High(gPlayers
) do
1974 if gPlayers
[i
] <> nil then
1975 if gPlayers
[i
].Frags
> b
then
1976 b
:= gPlayers
[i
].Frags
;
1979 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
1980 begin // В CTF/TDM выбираем команду с наибольшим счетом
1981 b
:= Max(gTeamStat
[TEAM_RED
].Goals
, gTeamStat
[TEAM_BLUE
].Goals
);
1984 // Лимит побед набран => конец уровня:
1985 if b
>= gGameSettings
.GoalLimit
then
1992 // Обрабатываем клавиши игроков:
1993 if gPlayer1
<> nil then gPlayer1
.ReleaseKeys();
1994 if gPlayer2
<> nil then gPlayer2
.ReleaseKeys();
1995 {$IFDEF DISABLE_MENU}
1996 if (not gConsoleShow
) and (not gChatShow
) then
1998 if (not gConsoleShow
) and (not gChatShow
) and (g_ActiveWindow
= nil) then
2001 ProcessPlayerControls(gPlayer1
, 0, P1MoveButton
);
2002 ProcessPlayerControls(gPlayer2
, 1, P2MoveButton
);
2003 end // if not console
2006 if g_Game_IsNet
and (gPlayer1
<> nil) then gPlayer1
.PressKey(KEY_CHAT
, 10000);
2008 // process weapon switch queue
2012 if (gPlayer1
= nil) and (gPlayer2
= nil)
2013 and (not gConsoleShow
) and (not gChatShow
)
2014 {$IFDEF ENABLE_MENU}
2015 and (g_ActiveWindow
= nil)
2019 if not gSpectKeyPress
then
2021 if gPlayerAction
[0, ACTION_JUMP
] and (not gSpectAuto
) then
2023 // switch spect mode
2025 SPECT_NONE
: ; // not spectator
2027 SPECT_MAPVIEW
: Inc(gSpectMode
);
2028 SPECT_PLAYERS
: gSpectMode
:= SPECT_STATS
; // reset to 1
2030 gSpectKeyPress
:= True;
2032 if (gSpectMode
= SPECT_MAPVIEW
)
2033 and (not gSpectAuto
) then
2035 if gPlayerAction
[0, ACTION_MOVELEFT
] then
2036 gSpectX
:= Max(gSpectX
- gSpectStep
, 0);
2037 if gPlayerAction
[0, ACTION_MOVERIGHT
] then
2038 gSpectX
:= Min(gSpectX
+ gSpectStep
, gMapInfo
.Width
- gScreenWidth
);
2039 if gPlayerAction
[0, ACTION_LOOKUP
] then
2040 gSpectY
:= Max(gSpectY
- gSpectStep
, 0);
2041 if gPlayerAction
[0, ACTION_LOOKDOWN
] then
2042 gSpectY
:= Min(gSpectY
+ gSpectStep
, gMapInfo
.Height
- gScreenHeight
);
2043 if gPlayerAction
[0, ACTION_WEAPPREV
] then
2046 if gSpectStep
> 4 then gSpectStep
:= gSpectStep
shr 1;
2047 gSpectKeyPress
:= True;
2049 if gPlayerAction
[0, ACTION_WEAPNEXT
] then
2052 if gSpectStep
< 64 then gSpectStep
:= gSpectStep
shl 1;
2053 gSpectKeyPress
:= True;
2056 if (gSpectMode
= SPECT_PLAYERS
)
2057 and (not gSpectAuto
) then
2059 if gPlayerAction
[0, ACTION_LOOKUP
] then
2062 gSpectViewTwo
:= True;
2063 gSpectKeyPress
:= True;
2065 if gPlayerAction
[0, ACTION_LOOKDOWN
] then
2067 // remove second view
2068 gSpectViewTwo
:= False;
2069 gSpectKeyPress
:= True;
2071 if gPlayerAction
[0, ACTION_MOVELEFT
] then
2073 // prev player (view 1)
2074 gSpectPID1
:= GetActivePlayerID_Prev(gSpectPID1
);
2075 gSpectKeyPress
:= True;
2077 if gPlayerAction
[0, ACTION_MOVERIGHT
] then
2079 // next player (view 1)
2080 gSpectPID1
:= GetActivePlayerID_Next(gSpectPID1
);
2081 gSpectKeyPress
:= True;
2083 if gPlayerAction
[0, ACTION_WEAPPREV
] then
2085 // prev player (view 2)
2086 gSpectPID2
:= GetActivePlayerID_Prev(gSpectPID2
);
2087 gSpectKeyPress
:= True;
2089 if gPlayerAction
[0, ACTION_WEAPNEXT
] then
2091 // next player (view 2)
2092 gSpectPID2
:= GetActivePlayerID_Next(gSpectPID2
);
2093 gSpectKeyPress
:= True;
2096 if gPlayerAction
[0, ACTION_ATTACK
] then
2098 if (gSpectMode
= SPECT_STATS
) and (not gSpectAuto
) then
2101 gSpectAutoNext
:= 0;
2102 gSpectViewTwo
:= False;
2103 gSpectKeyPress
:= True;
2108 gSpectMode
:= SPECT_STATS
;
2109 gSpectAuto
:= False;
2110 gSpectKeyPress
:= True;
2115 if (not gPlayerAction
[0, ACTION_JUMP
]) and
2116 (not gPlayerAction
[0, ACTION_ATTACK
]) and
2117 (not gPlayerAction
[0, ACTION_MOVELEFT
]) and
2118 (not gPlayerAction
[0, ACTION_MOVERIGHT
]) and
2119 (not gPlayerAction
[0, ACTION_LOOKUP
]) and
2120 (not gPlayerAction
[0, ACTION_LOOKDOWN
]) and
2121 (not gPlayerAction
[0, ACTION_WEAPPREV
]) and
2122 (not gPlayerAction
[0, ACTION_WEAPNEXT
]) then
2123 gSpectKeyPress
:= False;
2127 if gSpectMode
= SPECT_MAPVIEW
then
2129 i
:= Min(Max(gSpectX
+ gSpectAutoStepX
, 0), gMapInfo
.Width
- gScreenWidth
);
2131 gSpectAutoNext
:= gTime
2134 i
:= Min(Max(gSpectY
+ gSpectAutoStepY
, 0), gMapInfo
.Height
- gScreenHeight
);
2136 gSpectAutoNext
:= gTime
2140 if gSpectAutoNext
<= gTime
then
2142 if gSpectAutoNext
> 0 then
2144 gSpectMode
:= GetRandomSpectMode(gSpectMode
);
2148 gSpectX
:= Random(gMapInfo
.Width
- gScreenWidth
);
2149 gSpectY
:= Random(gMapInfo
.Height
- gScreenHeight
);
2150 gSpectAutoStepX
:= Random(9) - 4;
2151 gSpectAutoStepY
:= Random(9) - 4;
2152 if ((gSpectX
< 800) and (gSpectAutoStepX
< 0)) or
2153 ((gSpectX
> gMapInfo
.Width
- gScreenWidth
- 800) and (gSpectAutoStepX
> 0)) then
2154 gSpectAutoStepX
:= gSpectAutoStepX
* -1;
2155 if ((gSpectY
< 800) and (gSpectAutoStepY
< 0)) or
2156 ((gSpectY
> gMapInfo
.Height
- gScreenHeight
- 800) and (gSpectAutoStepY
> 0)) then
2157 gSpectAutoStepY
:= gSpectAutoStepY
* -1;
2161 gSpectPID1
:= GetActivePlayerID_Random(gSpectPID1
);
2166 SPECT_STATS
: gSpectAutoNext
:= gTime
+ (Random(3) + 5) * 1000;
2167 SPECT_MAPVIEW
: gSpectAutoNext
:= gTime
+ (Random(4) + 7) * 1000;
2168 SPECT_PLAYERS
: gSpectAutoNext
:= gTime
+ (Random(7) + 8) * 1000;
2174 // Обновляем все остальное:
2177 g_Triggers_Update();
2179 g_Monsters_Update();
2183 g_Player_UpdateAll();
2184 {$IFDEF ENABLE_GIBS}
2187 g_Player_UpdatePhysicalObjects();
2189 // server: send newly spawned monsters unconditionally
2190 if (gGameSettings
.GameType
= GT_SERVER
) then
2192 if (Length(gMonstersSpawned
) > 0) then
2194 for I
:= 0 to High(gMonstersSpawned
) do MH_SEND_MonsterSpawn(gMonstersSpawned
[I
]);
2195 SetLength(gMonstersSpawned
, 0);
2199 if (gSoundTriggerTime
> 8) then
2201 g_Game_UpdateTriggerSounds();
2202 gSoundTriggerTime
:= 0;
2206 Inc(gSoundTriggerTime
);
2209 if (NetMode
= NET_SERVER
) then
2211 Inc(NetTimeToUpdate
);
2212 Inc(NetTimeToReliable
);
2214 // send monster updates
2215 if (NetTimeToReliable
>= NetRelupdRate
) or (NetTimeToUpdate
>= NetUpdateRate
) then
2217 // send all monsters (periodic sync)
2218 reliableUpdate
:= (NetTimeToReliable
>= NetRelupdRate
);
2220 for I
:= 0 to High(gPlayers
) do
2222 if (gPlayers
[I
] <> nil) then MH_SEND_PlayerPos(reliableUpdate
, gPlayers
[I
].UID
);
2225 g_Mons_ForEach(sendMonsPos
);
2227 if reliableUpdate
then
2229 NetTimeToReliable
:= 0;
2230 NetTimeToUpdate
:= NetUpdateRate
;
2234 NetTimeToUpdate
:= 0;
2239 // send only mosters with some unexpected changes
2240 g_Mons_ForEach(sendMonsPosUnexpected
);
2243 // send unexpected platform changes
2244 g_Map_NetSendInterestingPanels();
2246 g_Net_Slist_ServerUpdate();
2248 if NetUseMaster then
2250 if (gTime >= NetTimeToMaster) or g_Net_Slist_IsConnectionInProgress then
2252 if (not g_Net_Slist_IsConnectionActive) then g_Net_Slist_Connect(false); // non-blocking connection to the master
2254 NetTimeToMaster := gTime + NetMasterRate;
2259 else if (NetMode
= NET_CLIENT
) then
2261 MC_SEND_PlayerPos();
2263 end; // if gameOn ...
2265 // Активно окно интерфейса - передаем клавиши ему:
2266 {$IFDEF ENABLE_MENU}
2267 if g_ActiveWindow
<> nil then
2269 w
:= e_GetFirstKeyPressed();
2271 if (w
<> IK_INVALID
) then
2273 Msg
.Msg
:= MESSAGE_DIKEY
;
2275 g_ActiveWindow
.OnMessage(Msg
);
2278 // Если оно от этого не закрылось, то обновляем:
2279 if g_ActiveWindow
<> nil then
2280 g_ActiveWindow
.Update();
2282 // Нужно сменить разрешение:
2283 if gResolutionChange
then
2286 e_WriteLog('Changing resolution', TMsgType
.Notify
);
2289 gResolutionChange
:= False;
2290 g_ActiveWindow
:= nil;
2293 // Нужно сменить язык:
2294 if gLanguageChange
then
2296 //e_WriteLog('Read language file', MSG_NOTIFY);
2297 //g_Language_Load(DataDir + gLanguage + '.txt');
2298 g_Language_Set(gLanguage
);
2300 gLanguageChange
:= False;
2304 // Горячая клавиша для вызова меню выхода из игры (F10):
2305 if e_KeyPressed(IK_F10
) and
2307 (not gConsoleShow
) and
2308 (g_ActiveWindow
= nil) then
2314 Time
:= GetTickCount64() {div 1000};
2316 // Обработка отложенных событий:
2317 if gDelayedEvents
<> nil then
2318 for a
:= 0 to High(gDelayedEvents
) do
2319 if gDelayedEvents
[a
].Pending
and
2321 ((gDelayedEvents
[a
].DEType
= DE_GLOBEVENT
) and (gDelayedEvents
[a
].Time
<= Time
)) or
2322 ((gDelayedEvents
[a
].DEType
> DE_GLOBEVENT
) and (gDelayedEvents
[a
].Time
<= gTime
))
2325 case gDelayedEvents
[a
].DEType
of
2327 g_Game_ExecuteEvent(gDelayedEvents
[a
].DEStr
);
2330 g_Game_Announce_GoodShot(gDelayedEvents
[a
].DENum
);
2334 g_Game_Announce_KillCombo(gDelayedEvents
[a
].DENum
);
2335 if g_Game_IsNet
and g_Game_IsServer
then
2336 MH_SEND_GameEvent(NET_EV_KILLCOMBO
, gDelayedEvents
[a
].DENum
);
2340 g_Game_Announce_BodyKill(gDelayedEvents
[a
].DENum
);
2342 gDelayedEvents
[a
].Pending
:= False;
2345 // Каждую секунду обновляем счетчик обновлений:
2346 UPSCounter
:= UPSCounter
+ 1;
2347 if Time
- UPSTime
>= 1000 then
2356 g_Weapon_AddDynLights();
2357 g_Items_AddDynLights();
2361 procedure g_Game_LoadChatSounds(Resource
: string);
2364 FileName
, Snd
: string;
2366 len
, cnt
, tags
, i
, j
: Integer;
2369 FileName
:= g_ExtractWadName(Resource
);
2371 WAD
:= TWADFile
.Create();
2372 WAD
.ReadFile(FileName
);
2374 if not WAD
.GetResource(g_ExtractFilePathName(Resource
), p
, len
) then
2381 cfg
:= TConfig
.CreateMem(p
, len
);
2382 cnt
:= cfg
.ReadInt('ChatSounds', 'Count', 0);
2384 SetLength(gChatSounds
, cnt
);
2385 for i
:= 0 to Length(gChatSounds
) - 1 do
2387 gChatSounds
[i
].Sound
:= nil;
2388 Snd
:= Trim(cfg
.ReadStr(IntToStr(i
), 'Sound', ''));
2389 tags
:= cfg
.ReadInt(IntToStr(i
), 'Tags', 0);
2390 if (Snd
= '') or (Tags
<= 0) then
2392 g_Sound_CreateWADEx('SOUND_CHAT_MACRO' + IntToStr(i
), GameWAD
+':'+Snd
);
2393 gChatSounds
[i
].Sound
:= TPlayableSound
.Create();
2394 gChatSounds
[i
].Sound
.SetByName('SOUND_CHAT_MACRO' + IntToStr(i
));
2395 SetLength(gChatSounds
[i
].Tags
, tags
);
2396 for j
:= 0 to tags
- 1 do
2397 gChatSounds
[i
].Tags
[j
] := toLowerCase1251(cfg
.ReadStr(IntToStr(i
), 'Tag' + IntToStr(j
), ''));
2398 gChatSounds
[i
].FullWord
:= cfg
.ReadBool(IntToStr(i
), 'FullWord', False);
2405 procedure g_Game_FreeChatSounds();
2409 for i
:= 0 to Length(gChatSounds
) - 1 do
2411 gChatSounds
[i
].Sound
.Free();
2412 g_Sound_Delete('SOUND_CHAT_MACRO' + IntToStr(i
));
2414 SetLength(gChatSounds
, 0);
2418 procedure g_Game_LoadData();
2420 if DataLoaded
then Exit
;
2422 e_WriteLog('Loading game data...', TMsgType
.Notify
);
2424 g_Sound_CreateWADEx('SOUND_GAME_TELEPORT', GameWAD
+':SOUNDS\TELEPORT');
2425 g_Sound_CreateWADEx('SOUND_GAME_NOTELEPORT', GameWAD
+':SOUNDS\NOTELEPORT');
2426 g_Sound_CreateWADEx('SOUND_GAME_SECRET', GameWAD
+':SOUNDS\SECRET');
2427 g_Sound_CreateWADEx('SOUND_GAME_DOOROPEN', GameWAD
+':SOUNDS\DOOROPEN');
2428 g_Sound_CreateWADEx('SOUND_GAME_DOORCLOSE', GameWAD
+':SOUNDS\DOORCLOSE');
2429 g_Sound_CreateWADEx('SOUND_GAME_BULK1', GameWAD
+':SOUNDS\BULK1');
2430 g_Sound_CreateWADEx('SOUND_GAME_BULK2', GameWAD
+':SOUNDS\BULK2');
2431 g_Sound_CreateWADEx('SOUND_GAME_BUBBLE1', GameWAD
+':SOUNDS\BUBBLE1');
2432 g_Sound_CreateWADEx('SOUND_GAME_BUBBLE2', GameWAD
+':SOUNDS\BUBBLE2');
2433 g_Sound_CreateWADEx('SOUND_GAME_BURNING', GameWAD
+':SOUNDS\BURNING');
2434 g_Sound_CreateWADEx('SOUND_GAME_SWITCH1', GameWAD
+':SOUNDS\SWITCH1');
2435 g_Sound_CreateWADEx('SOUND_GAME_SWITCH0', GameWAD
+':SOUNDS\SWITCH0');
2436 g_Sound_CreateWADEx('SOUND_GAME_RADIO', GameWAD
+':SOUNDS\RADIO');
2437 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD1', GameWAD
+':SOUNDS\GOOD1');
2438 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD2', GameWAD
+':SOUNDS\GOOD2');
2439 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD3', GameWAD
+':SOUNDS\GOOD3');
2440 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD4', GameWAD
+':SOUNDS\GOOD4');
2441 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL2X', GameWAD
+':SOUNDS\KILL2X');
2442 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL3X', GameWAD
+':SOUNDS\KILL3X');
2443 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL4X', GameWAD
+':SOUNDS\KILL4X');
2444 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILLMX', GameWAD
+':SOUNDS\KILLMX');
2445 g_Sound_CreateWADEx('SOUND_ANNOUNCER_MUHAHA1', GameWAD
+':SOUNDS\MUHAHA1');
2446 g_Sound_CreateWADEx('SOUND_ANNOUNCER_MUHAHA2', GameWAD
+':SOUNDS\MUHAHA2');
2447 g_Sound_CreateWADEx('SOUND_ANNOUNCER_MUHAHA3', GameWAD
+':SOUNDS\MUHAHA3');
2448 g_Sound_CreateWADEx('SOUND_CTF_GET1', GameWAD
+':SOUNDS\GETFLAG1');
2449 g_Sound_CreateWADEx('SOUND_CTF_GET2', GameWAD
+':SOUNDS\GETFLAG2');
2450 g_Sound_CreateWADEx('SOUND_CTF_LOST1', GameWAD
+':SOUNDS\LOSTFLG1');
2451 g_Sound_CreateWADEx('SOUND_CTF_LOST2', GameWAD
+':SOUNDS\LOSTFLG2');
2452 g_Sound_CreateWADEx('SOUND_CTF_RETURN1', GameWAD
+':SOUNDS\RETFLAG1');
2453 g_Sound_CreateWADEx('SOUND_CTF_RETURN2', GameWAD
+':SOUNDS\RETFLAG2');
2454 g_Sound_CreateWADEx('SOUND_CTF_CAPTURE1', GameWAD
+':SOUNDS\CAPFLAG1');
2455 g_Sound_CreateWADEx('SOUND_CTF_CAPTURE2', GameWAD
+':SOUNDS\CAPFLAG2');
2457 goodsnd
[0] := TPlayableSound
.Create();
2458 goodsnd
[1] := TPlayableSound
.Create();
2459 goodsnd
[2] := TPlayableSound
.Create();
2460 goodsnd
[3] := TPlayableSound
.Create();
2462 goodsnd
[0].SetByName('SOUND_ANNOUNCER_GOOD1');
2463 goodsnd
[1].SetByName('SOUND_ANNOUNCER_GOOD2');
2464 goodsnd
[2].SetByName('SOUND_ANNOUNCER_GOOD3');
2465 goodsnd
[3].SetByName('SOUND_ANNOUNCER_GOOD4');
2467 killsnd
[0] := TPlayableSound
.Create();
2468 killsnd
[1] := TPlayableSound
.Create();
2469 killsnd
[2] := TPlayableSound
.Create();
2470 killsnd
[3] := TPlayableSound
.Create();
2472 killsnd
[0].SetByName('SOUND_ANNOUNCER_KILL2X');
2473 killsnd
[1].SetByName('SOUND_ANNOUNCER_KILL3X');
2474 killsnd
[2].SetByName('SOUND_ANNOUNCER_KILL4X');
2475 killsnd
[3].SetByName('SOUND_ANNOUNCER_KILLMX');
2477 hahasnd
[0] := TPlayableSound
.Create();
2478 hahasnd
[1] := TPlayableSound
.Create();
2479 hahasnd
[2] := TPlayableSound
.Create();
2481 hahasnd
[0].SetByName('SOUND_ANNOUNCER_MUHAHA1');
2482 hahasnd
[1].SetByName('SOUND_ANNOUNCER_MUHAHA2');
2483 hahasnd
[2].SetByName('SOUND_ANNOUNCER_MUHAHA3');
2485 sound_get_flag
[0] := TPlayableSound
.Create();
2486 sound_get_flag
[1] := TPlayableSound
.Create();
2487 sound_lost_flag
[0] := TPlayableSound
.Create();
2488 sound_lost_flag
[1] := TPlayableSound
.Create();
2489 sound_ret_flag
[0] := TPlayableSound
.Create();
2490 sound_ret_flag
[1] := TPlayableSound
.Create();
2491 sound_cap_flag
[0] := TPlayableSound
.Create();
2492 sound_cap_flag
[1] := TPlayableSound
.Create();
2494 sound_get_flag
[0].SetByName('SOUND_CTF_GET1');
2495 sound_get_flag
[1].SetByName('SOUND_CTF_GET2');
2496 sound_lost_flag
[0].SetByName('SOUND_CTF_LOST1');
2497 sound_lost_flag
[1].SetByName('SOUND_CTF_LOST2');
2498 sound_ret_flag
[0].SetByName('SOUND_CTF_RETURN1');
2499 sound_ret_flag
[1].SetByName('SOUND_CTF_RETURN2');
2500 sound_cap_flag
[0].SetByName('SOUND_CTF_CAPTURE1');
2501 sound_cap_flag
[1].SetByName('SOUND_CTF_CAPTURE2');
2503 g_Game_LoadChatSounds(GameWAD
+':CHATSND\SNDCFG');
2505 g_Game_SetLoadingText(_lc
[I_LOAD_ITEMS_DATA
], 0, False);
2508 g_Game_SetLoadingText(_lc
[I_LOAD_WEAPONS_DATA
], 0, False);
2509 g_Weapon_LoadData();
2511 g_Monsters_LoadData();
2516 procedure g_Game_Quit();
2518 g_Game_StopAllSounds(True);
2521 g_PlayerModel_FreeData();
2523 //g_Menu_Free(); //k8: this segfaults after resolution change; who cares?
2526 if NetInitDone
then g_Net_Free
;
2528 // remove map after test
2529 if gMapToDelete
<> '' then
2530 g_Game_DeleteTestMap();
2539 procedure g_Game_FreeData();
2541 if not DataLoaded
then Exit
;
2544 g_Weapon_FreeData();
2545 g_Monsters_FreeData();
2547 e_WriteLog('Releasing game data...', TMsgType
.Notify
);
2549 g_Sound_Delete('SOUND_GAME_TELEPORT');
2550 g_Sound_Delete('SOUND_GAME_NOTELEPORT');
2551 g_Sound_Delete('SOUND_GAME_SECRET');
2552 g_Sound_Delete('SOUND_GAME_DOOROPEN');
2553 g_Sound_Delete('SOUND_GAME_DOORCLOSE');
2554 g_Sound_Delete('SOUND_GAME_BULK1');
2555 g_Sound_Delete('SOUND_GAME_BULK2');
2556 g_Sound_Delete('SOUND_GAME_BUBBLE1');
2557 g_Sound_Delete('SOUND_GAME_BUBBLE2');
2558 g_Sound_Delete('SOUND_GAME_BURNING');
2559 g_Sound_Delete('SOUND_GAME_SWITCH1');
2560 g_Sound_Delete('SOUND_GAME_SWITCH0');
2567 g_Sound_Delete('SOUND_ANNOUNCER_GOOD1');
2568 g_Sound_Delete('SOUND_ANNOUNCER_GOOD2');
2569 g_Sound_Delete('SOUND_ANNOUNCER_GOOD3');
2570 g_Sound_Delete('SOUND_ANNOUNCER_GOOD4');
2577 g_Sound_Delete('SOUND_ANNOUNCER_KILL2X');
2578 g_Sound_Delete('SOUND_ANNOUNCER_KILL3X');
2579 g_Sound_Delete('SOUND_ANNOUNCER_KILL4X');
2580 g_Sound_Delete('SOUND_ANNOUNCER_KILLMX');
2586 g_Sound_Delete('SOUND_ANNOUNCER_MUHAHA1');
2587 g_Sound_Delete('SOUND_ANNOUNCER_MUHAHA2');
2588 g_Sound_Delete('SOUND_ANNOUNCER_MUHAHA3');
2590 sound_get_flag
[0].Free();
2591 sound_get_flag
[1].Free();
2592 sound_lost_flag
[0].Free();
2593 sound_lost_flag
[1].Free();
2594 sound_ret_flag
[0].Free();
2595 sound_ret_flag
[1].Free();
2596 sound_cap_flag
[0].Free();
2597 sound_cap_flag
[1].Free();
2599 g_Sound_Delete('SOUND_CTF_GET1');
2600 g_Sound_Delete('SOUND_CTF_GET2');
2601 g_Sound_Delete('SOUND_CTF_LOST1');
2602 g_Sound_Delete('SOUND_CTF_LOST2');
2603 g_Sound_Delete('SOUND_CTF_RETURN1');
2604 g_Sound_Delete('SOUND_CTF_RETURN2');
2605 g_Sound_Delete('SOUND_CTF_CAPTURE1');
2606 g_Sound_Delete('SOUND_CTF_CAPTURE2');
2608 g_Game_FreeChatSounds();
2610 DataLoaded
:= False;
2613 procedure g_FatalError(Text: String);
2615 g_Console_Add(Format(_lc
[I_FATAL_ERROR
], [Text]), True);
2616 e_WriteLog(Format(_lc
[I_FATAL_ERROR
], [Text]), TMsgType
.Warning
);
2618 gExit
:= EXIT_SIMPLE
;
2619 if gGameOn
then EndGame
;
2622 procedure g_SimpleError(Text: String);
2624 g_Console_Add(Format(_lc
[I_SIMPLE_ERROR
], [Text]), True);
2625 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], [Text]), TMsgType
.Warning
);
2628 procedure g_Game_AddPlayer(Team
: Byte = TEAM_NONE
);
2630 if ((not gGameOn
) and (gState
<> STATE_INTERCUSTOM
))
2631 or (not (gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
])) then
2634 if (gGameSettings
.MaxLives
> 0) and (gLMSRespawn
= LMS_RESPAWN_NONE
) then
2637 if gPlayer1
= nil then
2639 if g_Game_IsClient
then
2641 if NetPlrUID1
> -1 then
2642 MC_SEND_CheatRequest(NET_CHEAT_SPECTATE
);
2646 if not (Team
in [TEAM_RED
, TEAM_BLUE
]) then
2647 Team
:= gPlayer1Settings
.Team
;
2649 // Создание первого игрока:
2650 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
2651 gPlayer1Settings
.Color
,
2653 if gPlayer1
= nil then
2654 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]))
2657 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
2658 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [gPlayer1
.Name
]), True);
2659 if g_Game_IsServer
and g_Game_IsNet
then
2660 MH_SEND_PlayerCreate(gPlayer1
.UID
);
2661 gPlayer1
.Respawn(False, True);
2662 g_Net_Slist_ServerPlayerComes();
2667 if gPlayer2
= nil then
2669 if g_Game_IsClient
then
2671 if NetPlrUID2
> -1 then
2672 gPlayer2
:= g_Player_Get(NetPlrUID2
);
2676 if not (Team
in [TEAM_RED
, TEAM_BLUE
]) then
2677 Team
:= gPlayer2Settings
.Team
;
2679 // Создание второго игрока:
2680 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
2681 gPlayer2Settings
.Color
,
2683 if gPlayer2
= nil then
2684 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]))
2687 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
2688 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [gPlayer2
.Name
]), True);
2689 if g_Game_IsServer
and g_Game_IsNet
then
2690 MH_SEND_PlayerCreate(gPlayer2
.UID
);
2691 gPlayer2
.Respawn(False, True);
2692 g_Net_Slist_ServerPlayerComes();
2699 procedure g_Game_RemovePlayer();
2703 if ((not gGameOn
) and (gState
<> STATE_INTERCUSTOM
))
2704 or (not (gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
])) then
2709 if g_Game_IsServer
then
2712 Pl
.Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
2713 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [Pl
.Name
]), True);
2714 g_Player_Remove(Pl
.UID
);
2715 g_Net_Slist_ServerPlayerLeaves();
2719 gSpectLatchPID2
:= Pl
.UID
;
2727 if g_Game_IsServer
then
2730 Pl
.Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
2731 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [Pl
.Name
]), True);
2732 g_Player_Remove(Pl
.UID
);
2733 g_Net_Slist_ServerPlayerLeaves();
2736 gSpectLatchPID1
:= Pl
.UID
;
2738 MC_SEND_CheatRequest(NET_CHEAT_SPECTATE
);
2742 g_Net_Slist_ServerPlayerLeaves();
2745 procedure g_Game_Spectate();
2747 g_Game_RemovePlayer();
2748 if gPlayer1
<> nil then
2749 g_Game_RemovePlayer();
2752 procedure g_Game_SpectateCenterView();
2754 gSpectX
:= Max(gMapInfo
.Width
div 2 - gScreenWidth
div 2, 0);
2755 gSpectY
:= Max(gMapInfo
.Height
div 2 - gScreenHeight
div 2, 0);
2758 procedure g_Game_StartSingle(Map
: String; TwoPlayers
: Boolean; nPlayers
: Byte);
2765 e_WriteLog('Starting singleplayer game...', TMsgType
.Notify
);
2767 g_Game_ClearLoading();
2770 FillByte(gGameSettings
, SizeOf(TGameSettings
), 0);
2773 gGameSettings
.GameType
:= GT_SINGLE
;
2774 gGameSettings
.MaxLives
:= 0;
2775 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_ALLOWEXIT
;
2776 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_MONSTERS
;
2777 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_BOTVSMONSTER
;
2778 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_TEAMHITPROJECTILE
;
2779 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_TEAMHITTRACE
;
2780 gSwitchGameMode
:= GM_SINGLE
;
2782 gLMSRespawn
:= LMS_RESPAWN_NONE
;
2783 gLMSRespawnTime
:= 0;
2784 gSpectLatchPID1
:= 0;
2785 gSpectLatchPID2
:= 0;
2787 g_Game_ExecuteEvent('ongamestart');
2789 // Создание первого игрока:
2790 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
2791 gPlayer1Settings
.Color
,
2792 gPlayer1Settings
.Team
, False));
2793 if gPlayer1
= nil then
2795 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
2799 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
2802 // Создание второго игрока, если есть:
2805 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
2806 gPlayer2Settings
.Color
,
2807 gPlayer2Settings
.Team
, False));
2808 if gPlayer2
= nil then
2810 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
2814 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
2818 // Загрузка и запуск карты:
2819 if not g_Game_StartMap(false{asMegawad}, MAP
, True) then
2821 if (Pos(':\', Map
) > 0) or (Pos(':/', Map
) > 0) then tmps
:= Map
else tmps
:= gGameSettings
.WAD
+ ':\' + MAP
;
2822 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [tmps
]));
2826 // Настройки игроков и ботов:
2830 for i
:= nPl
+1 to nPlayers
do
2831 g_Player_Create(STD_PLAYER_MODEL
, _RGB(0, 0, 0), 0, True);
2834 procedure g_Game_StartCustom(Map
: String; GameMode
: Byte;
2835 TimeLimit
, GoalLimit
: Word;
2837 Options
: LongWord; nPlayers
: Byte);
2843 e_WriteLog('Starting custom game...', TMsgType
.Notify
);
2845 g_Game_ClearLoading();
2848 gGameSettings
.GameType
:= GT_CUSTOM
;
2849 gGameSettings
.GameMode
:= GameMode
;
2850 gSwitchGameMode
:= GameMode
;
2851 gGameSettings
.TimeLimit
:= TimeLimit
;
2852 gGameSettings
.GoalLimit
:= GoalLimit
;
2853 gGameSettings
.MaxLives
:= IfThen(GameMode
= GM_CTF
, 0, MaxLives
);
2854 gGameSettings
.Options
:= Options
;
2856 gCoopTotalMonstersKilled
:= 0;
2857 gCoopTotalSecretsFound
:= 0;
2858 gCoopTotalMonsters
:= 0;
2859 gCoopTotalSecrets
:= 0;
2863 gLMSRespawn
:= LMS_RESPAWN_NONE
;
2864 gLMSRespawnTime
:= 0;
2865 gSpectLatchPID1
:= 0;
2866 gSpectLatchPID2
:= 0;
2868 g_Game_ExecuteEvent('ongamestart');
2870 // Режим наблюдателя:
2871 if nPlayers
= 0 then
2878 if nPlayers
>= 1 then
2880 // Создание первого игрока:
2881 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
2882 gPlayer1Settings
.Color
,
2883 gPlayer1Settings
.Team
, False));
2884 if gPlayer1
= nil then
2886 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
2890 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
2894 if nPlayers
>= 2 then
2896 // Создание второго игрока:
2897 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
2898 gPlayer2Settings
.Color
,
2899 gPlayer2Settings
.Team
, False));
2900 if gPlayer2
= nil then
2902 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
2906 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
2910 // Загрузка и запуск карты:
2911 if not g_Game_StartMap(true{asMegawad}, Map
, True) then
2913 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [Map
]));
2917 // Нет точек появления:
2918 if (g_Map_GetPointCount(RESPAWNPOINT_PLAYER1
) +
2919 g_Map_GetPointCount(RESPAWNPOINT_PLAYER2
) +
2920 g_Map_GetPointCount(RESPAWNPOINT_DM
) +
2921 g_Map_GetPointCount(RESPAWNPOINT_RED
)+
2922 g_Map_GetPointCount(RESPAWNPOINT_BLUE
)) < 1 then
2924 g_FatalError(_lc
[I_GAME_ERROR_GET_SPAWN
]);
2928 // Настройки игроков и ботов:
2932 for i
:= nPl
+1 to nPlayers
do
2933 g_Player_Create(STD_PLAYER_MODEL
, _RGB(0, 0, 0), 0, True);
2936 procedure g_Game_StartServer(Map
: String; GameMode
: Byte;
2937 TimeLimit
, GoalLimit
: Word; MaxLives
: Byte;
2938 Options
: LongWord; nPlayers
: Byte;
2939 IPAddr
: LongWord; Port
: Word);
2942 g_Net_Slist_ServerClosed();
2944 e_WriteLog('Starting net game (server)...', TMsgType
.Notify
);
2946 g_Game_ClearLoading();
2949 gGameSettings
.GameType
:= GT_SERVER
;
2950 gGameSettings
.GameMode
:= GameMode
;
2951 gSwitchGameMode
:= GameMode
;
2952 gGameSettings
.TimeLimit
:= TimeLimit
;
2953 gGameSettings
.GoalLimit
:= GoalLimit
;
2954 gGameSettings
.MaxLives
:= IfThen(GameMode
= GM_CTF
, 0, MaxLives
);
2955 gGameSettings
.Options
:= Options
;
2957 gCoopTotalMonstersKilled
:= 0;
2958 gCoopTotalSecretsFound
:= 0;
2959 gCoopTotalMonsters
:= 0;
2960 gCoopTotalSecrets
:= 0;
2964 gLMSRespawn
:= LMS_RESPAWN_NONE
;
2965 gLMSRespawnTime
:= 0;
2966 gSpectLatchPID1
:= 0;
2967 gSpectLatchPID2
:= 0;
2969 g_Game_ExecuteEvent('ongamestart');
2971 // Режим наблюдателя:
2972 if nPlayers
= 0 then
2978 if nPlayers
>= 1 then
2980 // Создание первого игрока:
2981 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
2982 gPlayer1Settings
.Color
,
2983 gPlayer1Settings
.Team
, False));
2984 if gPlayer1
= nil then
2986 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
2990 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
2993 if nPlayers
>= 2 then
2995 // Создание второго игрока:
2996 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
2997 gPlayer2Settings
.Color
,
2998 gPlayer2Settings
.Team
, False));
2999 if gPlayer2
= nil then
3001 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
3005 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
3008 g_Game_SetLoadingText(_lc
[I_LOAD_HOST
], 0, False);
3009 if NetForwardPorts
then
3010 g_Game_SetLoadingText(_lc
[I_LOAD_PORTS
], 0, False);
3013 if not g_Net_Host(IPAddr
, Port
, NetMaxClients
) then
3015 g_FatalError(_lc
[I_NET_MSG
] + Format(_lc
[I_NET_ERR_HOST
], [Port
]));
3019 g_Net_Slist_Set(NetMasterList
);
3021 g_Net_Slist_ServerStarted();
3023 // Загрузка и запуск карты:
3024 if not g_Game_StartMap(false{asMegawad}, Map
, True) then
3026 g_Net_Slist_ServerClosed();
3027 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [Map
]));
3031 // Нет точек появления:
3032 if (g_Map_GetPointCount(RESPAWNPOINT_PLAYER1
) +
3033 g_Map_GetPointCount(RESPAWNPOINT_PLAYER2
) +
3034 g_Map_GetPointCount(RESPAWNPOINT_DM
) +
3035 g_Map_GetPointCount(RESPAWNPOINT_RED
)+
3036 g_Map_GetPointCount(RESPAWNPOINT_BLUE
)) < 1 then
3038 g_Net_Slist_ServerClosed();
3039 g_FatalError(_lc
[I_GAME_ERROR_GET_SPAWN
]);
3043 // Настройки игроков и ботов:
3046 g_Net_Slist_ServerMapStarted();
3047 NetState
:= NET_STATE_GAME
;
3050 procedure g_Game_StartClient(Addr
: String; Port
: Word; PW
: String);
3065 e_WriteLog('Starting net game (client)...', TMsgType
.Notify
);
3066 e_WriteLog('NET: Trying to connect to ' + Addr
+ ':' + IntToStr(Port
) + '...', TMsgType
.Notify
);
3068 g_Game_ClearLoading();
3071 gGameSettings
.GameType
:= GT_CLIENT
;
3073 gCoopTotalMonstersKilled
:= 0;
3074 gCoopTotalSecretsFound
:= 0;
3075 gCoopTotalMonsters
:= 0;
3076 gCoopTotalSecrets
:= 0;
3080 g_Game_ExecuteEvent('ongamestart');
3082 NetState
:= NET_STATE_AUTH
;
3084 g_Game_SetLoadingText(_lc
[I_LOAD_CONNECT
], 0, False);
3086 // create (or update) map/resource databases
3087 g_Res_CreateDatabases(true);
3089 gLMSRespawn
:= LMS_RESPAWN_NONE
;
3090 gLMSRespawnTime
:= 0;
3091 gSpectLatchPID1
:= 0;
3092 gSpectLatchPID2
:= 0;
3095 if not g_Net_Connect(Addr
, Port
) then
3097 g_FatalError(_lc
[I_NET_MSG
] + _lc
[I_NET_ERR_CONN
]);
3098 NetState
:= NET_STATE_NONE
;
3102 g_Game_SetLoadingText(_lc
[I_LOAD_SEND_INFO
], 0, False);
3104 g_Game_SetLoadingText(_lc
[I_LOAD_WAIT_INFO
], 0, False);
3109 // fuck! https://www.mail-archive.com/enet-discuss@cubik.org/msg00852.html
3110 // tl;dr: on shitdows, we can get -1 sometimes, and it is *NOT* a failure.
3111 // thank you, enet. let's ignore failures altogether then.
3112 while (enet_host_service(NetHost
, @NetEvent
, 50) > 0) do
3114 if (NetEvent
.kind
= ENET_EVENT_TYPE_RECEIVE
) then
3116 if (NetEvent
.channelID
= NET_CHAN_DOWNLOAD_EX
) then
3118 // ignore all download packets, they're processed by separate code
3119 enet_packet_destroy(NetEvent
.packet
);
3122 Ptr
:= NetEvent
.packet
^.data
;
3123 if not InMsg
.Init(Ptr
, NetEvent
.packet
^.dataLength
, True) then
3125 enet_packet_destroy(NetEvent
.packet
);
3129 InMsg
.ReadLongWord(); // skip size
3130 MID
:= InMsg
.ReadByte();
3132 if (MID
= NET_MSG_INFO
) and (State
= 0) then
3134 NetMyID
:= InMsg
.ReadByte();
3135 NetPlrUID1
:= InMsg
.ReadWord();
3137 WadName
:= InMsg
.ReadString();
3138 Map
:= InMsg
.ReadString();
3140 gWADHash
:= InMsg
.ReadMD5();
3142 gGameSettings
.GameMode
:= InMsg
.ReadByte();
3143 gSwitchGameMode
:= gGameSettings
.GameMode
;
3144 gGameSettings
.GoalLimit
:= InMsg
.ReadWord();
3145 gGameSettings
.TimeLimit
:= InMsg
.ReadWord();
3146 gGameSettings
.MaxLives
:= InMsg
.ReadByte();
3147 gGameSettings
.Options
:= InMsg
.ReadLongWord();
3148 T
:= InMsg
.ReadLongWord();
3150 //newResPath := g_Res_SearchSameWAD(MapsDir, WadName, gWADHash);
3151 //if newResPath = '' then
3153 //g_Game_SetLoadingText(_lc[I_LOAD_DL_RES], 0, False);
3154 newResPath
:= g_Res_DownloadMapWAD(ExtractFileName(WadName
), gWADHash
);
3155 if newResPath
= '' then
3157 g_FatalError(_lc
[I_NET_ERR_HASH
]);
3158 enet_packet_destroy(NetEvent
.packet
);
3159 NetState
:= NET_STATE_NONE
;
3162 e_LogWritefln('using downloaded map wad [%s] for [%s]`', [newResPath
, WadName
], TMsgType
.Notify
);
3164 //newResPath := ExtractRelativePath(MapsDir, newResPath);
3167 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
3168 gPlayer1Settings
.Color
,
3169 gPlayer1Settings
.Team
, False));
3171 if gPlayer1
= nil then
3173 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
3175 enet_packet_destroy(NetEvent
.packet
);
3176 NetState
:= NET_STATE_NONE
;
3180 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
3181 gPlayer1
.UID
:= NetPlrUID1
;
3182 gPlayer1
.Reset(True);
3184 if not g_Game_StartMap(false{asMegawad}, newResPath
+ ':\' + Map
, True) then
3186 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [WadName
+ ':\' + Map
]));
3188 enet_packet_destroy(NetEvent
.packet
);
3189 NetState
:= NET_STATE_NONE
;
3197 enet_packet_destroy(NetEvent
.packet
);
3201 enet_packet_destroy(NetEvent
.packet
);
3205 if (NetEvent
.kind
= ENET_EVENT_TYPE_DISCONNECT
) then
3208 if (NetEvent
.data
<= NET_DISC_MAX
) then
3209 g_Console_Add(_lc
[I_NET_MSG_ERROR
] + _lc
[I_NET_ERR_CONN
] + ' ' +
3210 _lc
[TStrings_Locale(Cardinal(I_NET_DISC_NONE
) + NetEvent
.data
)], True);
3217 ProcessLoading(true);
3219 if g_Net_UserRequestExit() then
3228 g_FatalError(_lc
[I_NET_MSG
] + _lc
[I_NET_ERR_CONN
]);
3229 NetState
:= NET_STATE_NONE
;
3234 NetState
:= NET_STATE_GAME
;
3235 MC_SEND_FullStateRequest
;
3236 e_WriteLog('NET: Connection successful.', TMsgType
.Notify
);
3240 lastAsMegaWad
: Boolean = false;
3242 procedure g_Game_ChangeMap(const MapPath
: String);
3246 g_Game_ClearLoading();
3248 Force
:= gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
];
3249 // Если уровень завершился по триггеру Выход, не очищать инвентарь
3250 if gExitByTrigger
then
3253 gExitByTrigger
:= False;
3255 if not g_Game_StartMap(lastAsMegaWad
, MapPath
, Force
) then
3256 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [MapPath
]));
3259 procedure g_Game_Restart();
3263 if g_Game_IsClient
then
3265 map
:= g_ExtractFileName(gMapInfo
.Map
);
3266 e_LogWritefln('g_Game_Restart: map = "%s" gCurrentMapFileName = "%s"', [map
, gCurrentMapFileName
]);
3270 g_Game_ClearLoading();
3271 g_Game_StartMap(lastAsMegaWad
, Map
, True, gCurrentMapFileName
);
3274 function g_Game_StartMap (asMegawad
: Boolean; Map
: String; Force
: Boolean = False; const oldMapPath
: AnsiString=''): Boolean;
3276 NewWAD
, ResName
: String;
3280 g_Map_Free((Map
<> gCurrentMapFileName
) and (oldMapPath
<> gCurrentMapFileName
));
3281 g_Player_RemoveAllCorpses();
3283 if (not g_Game_IsClient
) and
3284 (gSwitchGameMode
<> gGameSettings
.GameMode
) and
3285 (gGameSettings
.GameMode
<> GM_SINGLE
) then
3287 if gSwitchGameMode
= GM_CTF
then
3288 gGameSettings
.MaxLives
:= 0;
3289 gGameSettings
.GameMode
:= gSwitchGameMode
;
3292 gSwitchGameMode
:= gGameSettings
.GameMode
;
3294 g_Player_ResetTeams();
3296 lastAsMegaWad
:= asMegawad
;
3297 if isWadPath(Map
) then
3299 NewWAD
:= g_ExtractWadName(Map
);
3300 ResName
:= g_ExtractFileName(Map
);
3301 if g_Game_IsServer
then
3303 nws
:= findDiskWad(NewWAD
);
3304 //writeln('000: Map=[', Map, ']; nws=[', nws, ']; NewWAD=[', NewWAD, ']');
3307 if (length(nws
) = 0) then nws
:= e_FindWad(MegawadDirs
, NewWAD
);
3308 if (length(nws
) = 0) then nws
:= e_FindWad(MapDirs
, NewWAD
);
3312 if (length(nws
) = 0) then nws
:= e_FindWad(MapDirs
, NewWAD
);
3313 if (length(nws
) = 0) then nws
:= e_FindWad(MegawadDirs
, NewWAD
);
3315 //if (length(nws) = 0) then nws := e_FindWad(MapDownloadDirs, NewWAD);
3316 //writeln('001: Map=[', Map, ']; nws=[', nws, ']; NewWAD=[', NewWAD, ']');
3318 if (length(nws
) = 0) then
3320 ResName
:= ''; // failed
3325 if (g_Game_IsNet
) then gWADHash
:= MD5File(nws
);
3326 //writeln('********: nws=', nws, ' : Map=', Map, ' : nw=', NewWAD, ' : resname=', ResName);
3327 g_Game_LoadWAD(NewWAD
);
3332 // hash received in MC_RECV_GameEvent -> NET_EV_MAPSTART
3333 NewWAD
:= g_Game_ClientWAD(NewWAD
, gWADHash
);
3338 NewWAD
:= gGameSettings
.WAD
;
3344 //writeln('********: gsw=', gGameSettings.WAD, '; rn=', ResName);
3346 if (ResName
<> '') and (NewWAD
<> '') then
3348 //result := g_Map_Load(gGameSettings.WAD + ':\' + ResName);
3349 result
:= g_Map_Load(NewWAD
+':\'+ResName
);
3351 r_Render_LoadTextures
;
3356 g_Player_ResetAll(Force
or gLastMap
, gGameSettings
.GameType
= GT_SINGLE
);
3358 gState
:= STATE_NONE
;
3359 {$IFDEF ENABLE_MENU}
3360 g_ActiveWindow
:= nil;
3365 wNeedTimeReset
:= True;
3367 if gGameSettings
.GameMode
= GM_CTF
then
3369 g_Map_ResetFlag(FLAG_RED
);
3370 g_Map_ResetFlag(FLAG_BLUE
);
3371 // CTF, а флагов нет:
3372 if not g_Map_HaveFlagPoints() then
3373 g_SimpleError(_lc
[I_GAME_ERROR_CTF
]);
3378 gState
:= STATE_MENU
;
3383 gPauseMain
:= false;
3384 gPauseHolmes
:= false;
3385 NetTimeToUpdate
:= 1;
3386 NetTimeToReliable
:= 0;
3387 NetTimeToMaster
:= NetMasterRate
;
3388 gSpectLatchPID1
:= 0;
3389 gSpectLatchPID2
:= 0;
3390 gMissionFailed
:= False;
3393 gCoopMonstersKilled
:= 0;
3394 gCoopSecretsFound
:= 0;
3396 gVoteInProgress
:= False;
3397 gVotePassed
:= False;
3403 if not gGameOn
then Exit
;
3405 g_Game_SpectateCenterView();
3407 if g_Game_IsServer
then
3409 if (gGameSettings
.MaxLives
> 0) and (gGameSettings
.WarmupTime
> 0) then
3411 gLMSRespawn
:= LMS_RESPAWN_WARMUP
;
3412 gLMSRespawnTime
:= gTime
+ gGameSettings
.WarmupTime
*1000;
3413 gLMSSoftSpawn
:= True;
3414 if g_Game_IsNet
then
3415 MH_SEND_GameEvent(NET_EV_LMS_WARMUP
, gLMSRespawnTime
- gTime
);
3419 gLMSRespawn
:= LMS_RESPAWN_NONE
;
3420 gLMSRespawnTime
:= 0;
3424 if NetMode
= NET_SERVER
then
3426 MH_SEND_GameEvent(NET_EV_MAPSTART
, gGameSettings
.GameMode
, Map
);
3429 g_Net_Slist_ServerMapStarted();
3431 if NetClients
<> nil then
3432 for I
:= 0 to High(NetClients
) do
3433 if NetClients
[I
].Used
then
3435 NetClients
[I
].Voted
:= False;
3436 if NetClients
[I
].RequestedFullUpdate
then
3438 MH_SEND_Everything((NetClients
[I
].State
= NET_STATE_AUTH
), I
);
3439 NetClients
[I
].RequestedFullUpdate
:= False;
3443 g_Net_UnbanNonPermHosts();
3448 gCoopTotalMonstersKilled
:= 0;
3449 gCoopTotalSecretsFound
:= 0;
3450 gCoopTotalMonsters
:= 0;
3451 gCoopTotalSecrets
:= 0;
3455 g_Game_ExecuteEvent('onmapstart');
3458 procedure SetFirstLevel
;
3462 MapList
:= g_Map_GetMapsList(gGameSettings
.WAD
);
3463 if MapList
= nil then
3466 SortSArray(MapList
);
3467 gNextMap
:= MapList
[Low(MapList
)];
3472 procedure g_Game_ExitLevel(const Map
: AnsiString);
3476 gCoopTotalMonstersKilled
:= gCoopTotalMonstersKilled
+ gCoopMonstersKilled
;
3477 gCoopTotalSecretsFound
:= gCoopTotalSecretsFound
+ gCoopSecretsFound
;
3478 gCoopTotalMonsters
:= gCoopTotalMonsters
+ gTotalMonsters
;
3479 gCoopTotalSecrets
:= gCoopTotalSecrets
+ gSecretsCount
;
3481 // Вышли в выход в Одиночной игре:
3482 if gGameSettings
.GameType
= GT_SINGLE
then
3483 gExit
:= EXIT_ENDLEVELSINGLE
3484 else // Вышли в выход в Своей игре
3486 gExit
:= EXIT_ENDLEVELCUSTOM
;
3487 if gGameSettings
.GameMode
= GM_COOP
then
3488 g_Player_RememberAll
;
3490 if not g_Map_Exist(gGameSettings
.WAD
+ ':\' + gNextMap
) then
3493 if gGameSettings
.GameMode
= GM_COOP
then
3496 gStatsPressed
:= True;
3497 gNextMap
:= 'MAP01';
3499 if not g_Map_Exist(gGameSettings
.WAD
+ ':\' + gNextMap
) then
3502 if g_Game_IsNet
then
3504 MH_SEND_GameStats();
3505 MH_SEND_CoopStats();
3511 procedure g_Game_RestartLevel();
3515 if gGameSettings
.GameMode
= GM_SINGLE
then
3520 gExit
:= EXIT_ENDLEVELCUSTOM
;
3521 Map
:= g_ExtractFileName(gMapInfo
.Map
);
3525 function g_Game_ClientWAD (NewWAD
: String; const WHash
: TMD5Digest
): AnsiString;
3527 gWAD
{, xwad}: String;
3530 if not g_Game_IsClient
then Exit
;
3531 //e_LogWritefln('*** g_Game_ClientWAD: `%s`', [NewWAD]);
3533 gWAD
:= g_Res_DownloadMapWAD(ExtractFileName(NewWAD
), WHash
);
3538 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_WAD
], [ExtractFileName(NewWAD
)]));
3542 e_LogWritefln('using downloaded client map wad [%s] for [%s]', [gWAD
, NewWAD
], TMsgType
.Notify
);
3545 g_Game_LoadWAD(NewWAD
);
3549 if LowerCase(NewWAD) = LowerCase(gGameSettings.WAD) then Exit;
3550 gWAD := g_Res_SearchSameWAD(MapsDir, ExtractFileName(NewWAD), WHash);
3553 g_Game_SetLoadingText(_lc[I_LOAD_DL_RES], 0, False);
3554 gWAD := g_Res_DownloadMapWAD(ExtractFileName(NewWAD), WHash);
3558 g_FatalError(Format(_lc[I_GAME_ERROR_MAP_WAD], [ExtractFileName(NewWAD)]));
3562 NewWAD := ExtractRelativePath(MapsDir, gWAD);
3563 g_Game_LoadWAD(NewWAD);
3567 procedure g_Game_RestartRound(NoMapRestart
: Boolean = False);
3569 i
, n
, nb
, nr
: Integer;
3571 if not g_Game_IsServer
then Exit
;
3572 if gLMSRespawn
= LMS_RESPAWN_NONE
then Exit
;
3573 gLMSRespawn
:= LMS_RESPAWN_NONE
;
3574 gLMSRespawnTime
:= 0;
3577 if (gGameSettings
.GameMode
= GM_COOP
) and not NoMapRestart
then
3579 gMissionFailed
:= True;
3580 g_Game_RestartLevel
;
3584 n
:= 0; nb
:= 0; nr
:= 0;
3585 for i
:= Low(gPlayers
) to High(gPlayers
) do
3586 if (gPlayers
[i
] <> nil) and
3587 ((not gPlayers
[i
].FSpectator
) or gPlayers
[i
].FWantsInGame
or
3588 (gPlayers
[i
] is TBot
)) then
3591 if gPlayers
[i
].Team
= TEAM_RED
then Inc(nr
)
3592 else if gPlayers
[i
].Team
= TEAM_BLUE
then Inc(nb
)
3595 if (n
< 1) or ((gGameSettings
.GameMode
= GM_TDM
) and ((nr
= 0) or (nb
= 0))) then
3597 // wait a second until the fuckers finally decide to join
3598 gLMSRespawn
:= LMS_RESPAWN_WARMUP
;
3599 gLMSRespawnTime
:= gTime
+ gGameSettings
.WarmupTime
*1000;
3600 gLMSSoftSpawn
:= NoMapRestart
;
3601 if g_Game_IsNet
then
3602 MH_SEND_GameEvent(NET_EV_LMS_WARMUP
, gLMSRespawnTime
- gTime
);
3606 g_Player_RemoveAllCorpses
;
3607 g_Game_Message(_lc
[I_MESSAGE_LMS_START
], 144);
3608 if g_Game_IsNet
then
3609 MH_SEND_GameEvent(NET_EV_LMS_START
);
3611 for i
:= Low(gPlayers
) to High(gPlayers
) do
3613 if gPlayers
[i
] = nil then continue
;
3614 if gPlayers
[i
] is TBot
then gPlayers
[i
].FWantsInGame
:= True;
3615 // don't touch normal spectators
3616 if gPlayers
[i
].FSpectator
and not gPlayers
[i
].FWantsInGame
then
3618 gPlayers
[i
].FNoRespawn
:= True;
3619 gPlayers
[i
].Lives
:= 0;
3620 if g_Game_IsNet
then
3621 MH_SEND_PlayerStats(gPlayers
[I
].UID
);
3624 gPlayers
[i
].FNoRespawn
:= False;
3625 gPlayers
[i
].Lives
:= gGameSettings
.MaxLives
;
3626 gPlayers
[i
].Respawn(False, True);
3627 if gGameSettings
.GameMode
= GM_COOP
then
3629 gPlayers
[i
].Frags
:= 0;
3630 gPlayers
[i
].RecallState
;
3632 if (gPlayer1
= nil) and (gSpectLatchPID1
> 0) then
3633 gPlayer1
:= g_Player_Get(gSpectLatchPID1
);
3634 if (gPlayer2
= nil) and (gSpectLatchPID2
> 0) then
3635 gPlayer2
:= g_Player_Get(gSpectLatchPID2
);
3638 g_Items_RestartRound();
3640 gLMSSoftSpawn
:= False;
3643 function g_Game_GetFirstMap(WAD
: String): String;
3647 MapList
:= g_Map_GetMapsList(WAD
);
3648 if MapList
= nil then
3651 SortSArray(MapList
);
3652 Result
:= MapList
[Low(MapList
)];
3654 if not g_Map_Exist(WAD
+ ':\' + Result
) then
3660 function g_Game_GetNextMap(): String;
3667 MapList
:= g_Map_GetMapsList(gGameSettings
.WAD
);
3668 if MapList
= nil then
3671 Map
:= g_ExtractFileName(gMapInfo
.Map
);
3673 SortSArray(MapList
);
3675 for I
:= Low(MapList
) to High(MapList
) do
3676 if Map
= MapList
[I
] then
3682 if MapIndex
<> -255 then
3684 if MapIndex
= High(MapList
) then
3685 Result
:= MapList
[Low(MapList
)]
3687 Result
:= MapList
[MapIndex
+ 1];
3689 if not g_Map_Exist(gGameSettings
.WAD
+ ':\' + Result
) then Result
:= Map
;
3695 procedure g_Game_NextLevel();
3697 if gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
, GM_COOP
] then
3698 gExit
:= EXIT_ENDLEVELCUSTOM
3701 gExit
:= EXIT_ENDLEVELSINGLE
;
3705 if gNextMap
<> '' then Exit
;
3706 gNextMap
:= g_Game_GetNextMap();
3709 function g_Game_IsTestMap(): Boolean;
3711 result
:= StrEquCI1251(TEST_MAP_NAME
, g_ExtractFileName(gMapInfo
.Map
));
3714 procedure g_Game_DeleteTestMap();
3717 //MapName: AnsiString;
3725 a
:= Pos('.wad:\', toLowerCase1251(gMapToDelete
));
3726 if (a
= 0) then a
:= Pos('.wad:/', toLowerCase1251(gMapToDelete
));
3727 if (a
= 0) then exit
;
3729 // Выделяем имя wad-файла и имя карты
3730 WadName
:= Copy(gMapToDelete
, 1, a
+3);
3731 Delete(gMapToDelete
, 1, a
+5);
3732 gMapToDelete
:= UpperCase(gMapToDelete
);
3734 //CopyMemory(@MapName[0], @gMapToDelete[1], Min(16, Length(gMapToDelete)));
3737 // Имя карты не стандартное тестовое:
3738 if MapName <> TEST_MAP_NAME then
3741 if not gTempDelete then
3743 time := g_GetFileTime(WadName);
3744 WAD := TWADFile.Create();
3747 if not WAD.ReadFile(WadName) then
3748 begin // Нет такого WAD-файла
3753 // Составляем список карт и ищем нужную:
3755 MapList := WAD.GetResourcesList('');
3757 if MapList <> nil then
3758 for a := 0 to High(MapList) do
3759 if MapList[a] = MapName then
3761 // Удаляем и сохраняем:
3762 WAD.RemoveResource('', MapName);
3763 WAD.SaveTo(WadName);
3768 g_SetFileTime(WadName, time);
3771 if gTempDelete
then DeleteFile(WadName
);
3774 procedure GameCVars(P
: SSArray
);
3777 stat
: TPlayerStatArray
;
3780 procedure ParseGameFlag(Flag
: LongWord; OffMsg
, OnMsg
: TStrings_Locale
; OnMapChange
: Boolean = False);
3784 if Length(P
) > 1 then
3789 gsGameFlags
:= gsGameFlags
or Flag
3791 gsGameFlags
:= gsGameFlags
and (not Flag
);
3793 if g_Game_IsServer
then
3796 gGameSettings
.Options
:= gGameSettings
.Options
or Flag
3798 gGameSettings
.Options
:= gGameSettings
.Options
and (not Flag
);
3799 if g_Game_IsNet
then MH_SEND_GameSettings
;
3803 if LongBool(gsGameFlags
and Flag
) then
3804 g_Console_Add(_lc
[OnMsg
])
3806 g_Console_Add(_lc
[OffMsg
]);
3808 if OnMapChange
and g_Game_IsServer
then
3809 g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
3814 cmd
:= LowerCase(P
[0]);
3816 if cmd
= 'g_gamemode' then
3818 if (Length(P
) > 1) then
3820 a
:= g_Game_TextToMode(P
[1]);
3821 if a
= GM_SINGLE
then a
:= GM_COOP
;
3822 gsGameMode
:= g_Game_ModeToText(a
);
3823 if g_Game_IsServer
then
3825 gSwitchGameMode
:= a
;
3826 if (gGameOn
and (gGameSettings
.GameMode
= GM_SINGLE
)) or
3827 (gState
= STATE_INTERSINGLE
) then
3828 gSwitchGameMode
:= GM_SINGLE
;
3830 gGameSettings
.GameMode
:= gSwitchGameMode
;
3834 if gSwitchGameMode
= gGameSettings
.GameMode
then
3835 g_Console_Add(Format(_lc
[I_MSG_GAMEMODE_CURRENT
],
3836 [g_Game_ModeToText(gGameSettings
.GameMode
)]))
3838 g_Console_Add(Format(_lc
[I_MSG_GAMEMODE_CHANGE
],
3839 [g_Game_ModeToText(gGameSettings
.GameMode
),
3840 g_Game_ModeToText(gSwitchGameMode
)]));
3842 else if cmd
= 'g_friendlyfire' then
3844 ParseGameFlag(GAME_OPTION_TEAMDAMAGE
, I_MSG_FRIENDLY_FIRE_OFF
, I_MSG_FRIENDLY_FIRE_ON
);
3846 else if cmd
= 'g_friendly_absorb_damage' then
3848 ParseGameFlag(GAME_OPTION_TEAMABSORBDAMAGE
, I_MSG_FRIENDLY_FIRE_OFF
, I_MSG_FRIENDLY_FIRE_ON
);
3850 else if cmd
= 'g_friendly_hit_trace' then
3852 ParseGameFlag(GAME_OPTION_TEAMHITTRACE
, I_MSG_FRIENDLY_FIRE_OFF
, I_MSG_FRIENDLY_FIRE_ON
);
3854 else if cmd
= 'g_friendly_hit_projectile' then
3856 ParseGameFlag(GAME_OPTION_TEAMHITPROJECTILE
, I_MSG_FRIENDLY_FIRE_OFF
, I_MSG_FRIENDLY_FIRE_ON
);
3858 else if cmd
= 'g_weaponstay' then
3860 ParseGameFlag(GAME_OPTION_WEAPONSTAY
, I_MSG_WEAPONSTAY_OFF
, I_MSG_WEAPONSTAY_ON
);
3862 else if cmd
= 'g_allow_exit' then
3864 ParseGameFlag(GAME_OPTION_ALLOWEXIT
, I_MSG_ALLOWEXIT_OFF
, I_MSG_ALLOWEXIT_ON
, True);
3866 else if cmd
= 'g_allow_monsters' then
3868 ParseGameFlag(GAME_OPTION_MONSTERS
, I_MSG_ALLOWMON_OFF
, I_MSG_ALLOWMON_ON
, True);
3870 else if cmd
= 'g_bot_vsplayers' then
3872 ParseGameFlag(GAME_OPTION_BOTVSPLAYER
, I_MSG_BOTSVSPLAYERS_OFF
, I_MSG_BOTSVSPLAYERS_ON
);
3874 else if cmd
= 'g_bot_vsmonsters' then
3876 ParseGameFlag(GAME_OPTION_BOTVSMONSTER
, I_MSG_BOTSVSMONSTERS_OFF
, I_MSG_BOTSVSMONSTERS_ON
);
3878 else if cmd
= 'g_dm_keys' then
3880 ParseGameFlag(GAME_OPTION_DMKEYS
, I_MSG_DMKEYS_OFF
, I_MSG_DMKEYS_ON
, True);
3882 else if cmd
= 'g_gameflags' then
3884 if Length(P
) > 1 then
3886 gsGameFlags
:= StrToDWordDef(P
[1], gsGameFlags
);
3887 if g_Game_IsServer
then
3889 gGameSettings
.Options
:= gsGameFlags
;
3890 if g_Game_IsNet
then MH_SEND_GameSettings
;
3894 g_Console_Add(Format('%s %u', [cmd
, gsGameFlags
]));
3896 else if cmd
= 'g_warmup_time' then
3898 if Length(P
) > 1 then
3900 gsWarmupTime
:= nclamp(StrToIntDef(P
[1], gsWarmupTime
), 0, $FFFF);
3901 if g_Game_IsServer
then
3903 gGameSettings
.WarmupTime
:= gsWarmupTime
;
3904 // extend warmup if it's already going
3905 if gLMSRespawn
= LMS_RESPAWN_WARMUP
then
3907 gLMSRespawnTime
:= gTime
+ gsWarmupTime
* 1000;
3908 if g_Game_IsNet
then MH_SEND_GameEvent(NET_EV_LMS_WARMUP
, gLMSRespawnTime
- gTime
);
3910 if g_Game_IsNet
then MH_SEND_GameSettings
;
3914 g_Console_Add(Format(_lc
[I_MSG_WARMUP
], [Integer(gsWarmupTime
)]));
3915 if g_Game_IsServer
then g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
3917 else if cmd
= 'g_spawn_invul' then
3919 if Length(P
) > 1 then
3921 gsSpawnInvul
:= nclamp(StrToIntDef(P
[1], gsSpawnInvul
), 0, $FFFF);
3922 if g_Game_IsServer
then
3924 gGameSettings
.SpawnInvul
:= gsSpawnInvul
;
3925 if g_Game_IsNet
then MH_SEND_GameSettings
;
3929 g_Console_Add(Format('%s %d', [cmd
, Integer(gsSpawnInvul
)]));
3931 else if cmd
= 'g_item_respawn_time' then
3933 if Length(P
) > 1 then
3935 gsItemRespawnTime
:= nclamp(StrToIntDef(P
[1], gsItemRespawnTime
), 0, $FFFF);
3936 if g_Game_IsServer
then
3938 gGameSettings
.ItemRespawnTime
:= gsItemRespawnTime
;
3939 if g_Game_IsNet
then MH_SEND_GameSettings
;
3943 g_Console_Add(Format('%s %d', [cmd
, Integer(gsItemRespawnTime
)]));
3944 if g_Game_IsServer
then g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
3946 else if cmd
= 'sv_intertime' then
3948 if (Length(P
) > 1) then
3949 gDefInterTime
:= Min(Max(StrToIntDef(P
[1], gDefInterTime
), -1), 120);
3951 g_Console_Add(cmd
+ ' = ' + IntToStr(gDefInterTime
));
3953 else if cmd
= 'g_max_particles' then
3955 if Length(p
) = 2 then
3958 a
:= Max(0, StrToInt(p
[1]));
3962 else if Length(p
) = 1 then
3965 e_LogWritefln('%s', [g_GFX_GetMax()])
3967 e_LogWritefln('%s', [0])
3972 e_LogWritefln('usage: %s <n>', [cmd
])
3975 else if cmd
= 'g_max_shells' then
3977 if Length(p
) = 2 then
3979 a
:= Max(0, StrToInt(p
[1]));
3982 else if Length(p
) = 1 then
3984 e_LogWritefln('%s', [g_Shells_GetMax()])
3988 e_LogWritefln('usage: %s <n>', [cmd
])
3991 else if cmd
= 'g_max_gibs' then
3993 if Length(p
) = 2 then
3995 {$IFDEF ENABLE_GIBS}
3996 a
:= Max(0, StrToInt(p
[1]));
4000 else if Length(p
) = 1 then
4002 {$IFDEF ENABLE_GIBS}
4003 e_LogWritefln('%s', [g_Gibs_GetMax()])
4005 e_LogWritefln('%s', [0])
4010 e_LogWritefln('usage: %s <n>', [cmd
])
4013 else if cmd
= 'g_max_corpses' then
4015 if Length(p
) = 2 then
4017 a
:= Max(0, StrToInt(p
[1]));
4020 else if Length(p
) = 1 then
4022 e_LogWritefln('%s', [g_Corpses_GetMax()])
4026 e_LogWritefln('usage: %s <n>', [cmd
])
4029 else if cmd
= 'g_scorelimit' then
4031 if Length(P
) > 1 then
4033 gsGoalLimit
:= nclamp(StrToIntDef(P
[1], gsGoalLimit
), 0, $FFFF);
4035 if g_Game_IsServer
then
4038 if gGameSettings
.GameMode
= GM_DM
then
4040 stat
:= g_Player_GetStats();
4042 for a
:= 0 to High(stat
) do
4043 if stat
[a
].Frags
> b
then
4047 b
:= Max(gTeamStat
[TEAM_RED
].Goals
, gTeamStat
[TEAM_BLUE
].Goals
);
4049 // if someone has a higher score, set it to that instead
4050 gsGoalLimit
:= max(gsGoalLimit
, b
);
4051 gGameSettings
.GoalLimit
:= gsGoalLimit
;
4053 if g_Game_IsNet
then MH_SEND_GameSettings
;
4057 g_Console_Add(Format(_lc
[I_MSG_SCORE_LIMIT
], [Integer(gsGoalLimit
)]));
4059 else if cmd
= 'g_timelimit' then
4061 if Length(P
) > 1 then
4063 gsTimeLimit
:= nclamp(StrToIntDef(P
[1], gsTimeLimit
), 0, $FFFF);
4064 if g_Game_IsServer
then
4066 gGameSettings
.TimeLimit
:= gsTimeLimit
;
4067 if g_Game_IsNet
then MH_SEND_GameSettings
;
4070 g_Console_Add(Format(_lc
[I_MSG_TIME_LIMIT
],
4071 [gsTimeLimit
div 3600,
4072 (gsTimeLimit
div 60) mod 60,
4073 gsTimeLimit
mod 60]));
4075 else if cmd
= 'g_maxlives' then
4077 if Length(P
) > 1 then
4079 gsMaxLives
:= nclamp(StrToIntDef(P
[1], gsMaxLives
), 0, $FFFF);
4080 if g_Game_IsServer
then
4082 gGameSettings
.MaxLives
:= gsMaxLives
;
4083 if g_Game_IsNet
then MH_SEND_GameSettings
;
4087 g_Console_Add(Format(_lc
[I_MSG_LIVES
], [Integer(gsMaxLives
)]));
4091 procedure PlayerSettingsCVars(P
: SSArray
);
4096 function ParseTeam(s
: string): Byte;
4100 'red', '1': result
:= TEAM_RED
;
4101 'blue', '2': result
:= TEAM_BLUE
;
4102 else result
:= TEAM_NONE
;
4106 cmd
:= LowerCase(P
[0]);
4110 if (Length(P
) > 1) then
4112 gPlayer1Settings
.Name
:= b_Text_Unformat(P
[1]);
4113 if g_Game_IsClient
then
4114 MC_SEND_PlayerSettings
4115 else if gGameOn
and (gPlayer1
<> nil) then
4117 gPlayer1
.Name
:= b_Text_Unformat(P
[1]);
4118 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer1
.UID
);
4124 if (Length(P
) > 1) then
4126 gPlayer2Settings
.Name
:= b_Text_Unformat(P
[1]);
4127 if g_Game_IsClient
then
4128 MC_SEND_PlayerSettings
4129 else if gGameOn
and (gPlayer2
<> nil) then
4131 gPlayer2
.Name
:= b_Text_Unformat(P
[1]);
4132 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer2
.UID
);
4138 if Length(P
) > 3 then
4140 gPlayer1Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
4141 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
4142 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
4143 if g_Game_IsClient
then
4144 MC_SEND_PlayerSettings
4145 else if gGameOn
and (gPlayer1
<> nil) then
4147 gPlayer1
.SetColor(gPlayer1Settings
.Color
);
4148 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer1
.UID
);
4154 if Length(P
) > 3 then
4156 gPlayer2Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
4157 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
4158 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
4159 if g_Game_IsClient
then
4160 MC_SEND_PlayerSettings
4161 else if gGameOn
and (gPlayer2
<> nil) then
4163 gPlayer2
.SetColor(gPlayer2Settings
.Color
);
4164 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer2
.UID
);
4170 if (Length(P
) > 1) then
4172 gPlayer1Settings
.Model
:= P
[1];
4173 if g_Game_IsClient
then
4174 MC_SEND_PlayerSettings
4175 else if gGameOn
and (gPlayer1
<> nil) then
4177 gPlayer1
.FActualModelName
:= gPlayer1Settings
.Model
;
4178 gPlayer1
.SetModel(gPlayer1Settings
.Model
);
4179 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer1
.UID
);
4185 if (Length(P
) > 1) then
4187 gPlayer2Settings
.Model
:= P
[1];
4188 if g_Game_IsClient
then
4189 MC_SEND_PlayerSettings
4190 else if gGameOn
and (gPlayer2
<> nil) then
4192 gPlayer2
.FActualModelName
:= gPlayer2Settings
.Model
;
4193 gPlayer2
.SetModel(gPlayer2Settings
.Model
);
4194 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer2
.UID
);
4200 // TODO: switch teams if in game or store this separately
4201 if (Length(P
) > 1) then
4203 team
:= ParseTeam(P
[1]);
4204 if team
= TEAM_NONE
then
4205 g_Console_Add('expected ''red'', ''blue'', 1 or 2')
4206 else if not gGameOn
and not g_Game_IsNet
then
4207 gPlayer1Settings
.Team
:= team
4209 g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
4214 // TODO: switch teams if in game or store this separately
4215 if (Length(P
) > 1) then
4217 team
:= ParseTeam(P
[1]);
4218 if team
= TEAM_NONE
then
4219 g_Console_Add('expected ''red'', ''blue'', 1 or 2')
4220 else if not gGameOn
and not g_Game_IsNet
then
4221 gPlayer2Settings
.Team
:= team
4223 g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
4229 procedure PrintHeapStats();
4233 hs
:= GetFPCHeapStatus();
4234 e_LogWriteLn ('v===== heap status =====v');
4235 e_LogWriteFln('max heap size = %d k', [hs
.MaxHeapSize
div 1024]);
4236 e_LogWriteFln('max heap used = %d k', [hs
.MaxHeapUsed
div 1024]);
4237 e_LogWriteFln('cur heap size = %d k', [hs
.CurrHeapSize
div 1024]);
4238 e_LogWriteFln('cur heap used = %d k', [hs
.CurrHeapUsed
div 1024]);
4239 e_LogWriteFln('cur heap free = %d k', [hs
.CurrHeapFree
div 1024]);
4240 e_LogWriteLn ('^=======================^');
4243 procedure DebugCommands(P
: SSArray
);
4250 // Команды отладочного режима:
4251 if {gDebugMode}conIsCheatsEnabled
then
4253 cmd
:= LowerCase(P
[0]);
4254 if cmd
= 'd_window' then
4256 g_Console_Add(Format('gScreenWidth = %d, gScreenHeight = %d', [gScreenWidth
, gScreenHeight
]));
4257 g_Console_Add(Format('gScreenWidth = %d, gScreenHeight = %d', [gScreenWidth
, gScreenHeight
]));
4259 else if cmd
= 'd_sounds' then
4261 if (Length(P
) > 1) and
4262 ((P
[1] = '1') or (P
[1] = '0')) then
4263 g_Debug_Sounds
:= (P
[1][1] = '1');
4265 g_Console_Add(Format('d_sounds is %d', [Byte(g_Debug_Sounds
)]));
4267 else if cmd
= 'd_frames' then
4269 if (Length(P
) > 1) and
4270 ((P
[1] = '1') or (P
[1] = '0')) then
4271 g_Debug_Frames
:= (P
[1][1] = '1');
4273 g_Console_Add(Format('d_frames is %d', [Byte(g_Debug_Frames
)]));
4275 else if cmd
= 'd_winmsg' then
4277 if (Length(P
) > 1) and
4278 ((P
[1] = '1') or (P
[1] = '0')) then
4279 g_Debug_WinMsgs
:= (P
[1][1] = '1');
4281 g_Console_Add(Format('d_winmsg is %d', [Byte(g_Debug_WinMsgs
)]));
4283 else if (cmd
= 'd_monoff') and not g_Game_IsNet
then
4285 if (Length(P
) > 1) and
4286 ((P
[1] = '1') or (P
[1] = '0')) then
4287 g_Debug_MonsterOff
:= (P
[1][1] = '1');
4289 g_Console_Add(Format('d_monoff is %d', [Byte(g_debug_MonsterOff
)]));
4291 else if (cmd
= 'd_botoff') and not g_Game_IsNet
then
4293 if Length(P
) > 1 then
4295 '0': g_debug_BotAIOff
:= 0;
4296 '1': g_debug_BotAIOff
:= 1;
4297 '2': g_debug_BotAIOff
:= 2;
4298 '3': g_debug_BotAIOff
:= 3;
4301 g_Console_Add(Format('d_botoff is %d', [g_debug_BotAIOff
]));
4303 else if cmd
= 'd_monster' then
4305 if gGameOn
and (gPlayer1
<> nil) and (gPlayer1
.alive
) and (not g_Game_IsNet
) then
4306 if Length(P
) < 2 then
4308 g_Console_Add(cmd
+ ' [ID | Name] [behaviour]');
4309 g_Console_Add('ID | Name');
4310 for b
:= MONSTER_DEMON
to MONSTER_MAN
do
4311 g_Console_Add(Format('%2d | %s', [b
, g_Mons_NameByTypeId(b
)]));
4312 conwriteln('behav. num'#10'normal 0'#10'killer 1'#10'maniac 2'#10'insane 3'#10'cannibal 4'#10'good 5');
4315 a
:= StrToIntDef(P
[1], 0);
4316 if (a
< MONSTER_DEMON
) or (a
> MONSTER_MAN
) then
4317 a
:= g_Mons_TypeIdByName(P
[1]);
4319 if (a
< MONSTER_DEMON
) or (a
> MONSTER_MAN
) then
4320 g_Console_Add(Format(_lc
[I_MSG_NO_MONSTER
], [P
[1]]))
4323 with gPlayer1
.Obj
do
4325 mon
:= g_Monsters_Create(a
,
4326 X
+ Rect
.X
+ (Rect
.Width
div 2),
4327 Y
+ Rect
.Y
+ Rect
.Height
,
4328 gPlayer1
.Direction
, True);
4330 if (Length(P
) > 2) and (mon
<> nil) then
4332 if (CompareText(P
[2], 'normal') = 0) then mon
.MonsterBehaviour
:= BH_NORMAL
4333 else if (CompareText(P
[2], 'killer') = 0) then mon
.MonsterBehaviour
:= BH_KILLER
4334 else if (CompareText(P
[2], 'maniac') = 0) then mon
.MonsterBehaviour
:= BH_MANIAC
4335 else if (CompareText(P
[2], 'insane') = 0) then mon
.MonsterBehaviour
:= BH_INSANE
4336 else if (CompareText(P
[2], 'cannibal') = 0) then mon
.MonsterBehaviour
:= BH_CANNIBAL
4337 else if (CompareText(P
[2], 'good') = 0) then mon
.MonsterBehaviour
:= BH_GOOD
4338 else if (CompareText(P
[2], 'friend') = 0) then mon
.MonsterBehaviour
:= BH_GOOD
4339 else if (CompareText(P
[2], 'friendly') = 0) then mon
.MonsterBehaviour
:= BH_GOOD
4340 else mon
.MonsterBehaviour
:= Min(Max(StrToIntDef(P
[2], BH_NORMAL
), BH_NORMAL
), BH_GOOD
);
4345 else if (cmd
= 'd_health') then
4347 if (Length(P
) > 1) and
4348 ((P
[1] = '1') or (P
[1] = '0')) then
4349 g_debug_HealthBar
:= (P
[1][1] = '1');
4351 g_Console_Add(Format('d_health is %d', [Byte(g_debug_HealthBar
)]));
4353 else if (cmd
= 'd_player') then
4355 if (Length(P
) > 1) and
4356 ((P
[1] = '1') or (P
[1] = '0')) then
4357 g_debug_Player
:= (P
[1][1] = '1');
4359 g_Console_Add(Format(cmd
+ ' is %d', [Byte(g_Debug_Player
)]));
4361 else if (cmd
= 'd_mem') then
4367 g_Console_Add(_lc
[I_MSG_NOT_DEBUG
]);
4371 procedure GameCheats(P
: SSArray
);
4377 if (not gGameOn
) or (not conIsCheatsEnabled
) then
4379 g_Console_Add('not available');
4385 g_Console_Add('where is the player?!');
4388 cmd
:= LowerCase(P
[0]);
4392 plr
.GodMode
:= not plr
.GodMode
;
4393 if plr
.GodMode
then g_Console_Add('player is godlike now') else g_Console_Add('player is mortal now');
4396 // give <health|exit|weapons|air|suit|jetpack|berserk|all>
4397 if cmd
= 'give' then
4399 if length(P
) < 2 then begin g_Console_Add('give what?!'); exit
; end;
4400 for f
:= 1 to High(P
) do
4402 cmd
:= LowerCase(P
[f
]);
4403 if cmd
= 'health' then begin plr
.RestoreHealthArmor(); g_Console_Add('player feels himself better'); continue
; end;
4404 if (cmd
= 'all') {or (cmd = 'weapons')} then begin plr
.AllRulez(False); g_Console_Add('player got the gifts'); continue
; end;
4405 if cmd
= 'exit' then
4407 if gTriggers
<> nil then
4409 for a
:= 0 to High(gTriggers
) do
4411 if gTriggers
[a
].TriggerType
= TRIGGER_EXIT
then
4413 g_Console_Add('player left the map');
4414 gExitByTrigger
:= True;
4415 //g_Game_ExitLevel(gTriggers[a].Data.MapName);
4416 g_Game_ExitLevel(gTriggers
[a
].tgcMap
);
4424 if cmd
= 'air' then begin plr
.GiveItem(ITEM_OXYGEN
); g_Console_Add('player got some air'); continue
; end;
4425 if cmd
= 'jetpack' then begin plr
.GiveItem(ITEM_JETPACK
); g_Console_Add('player got a jetpack'); continue
; end;
4426 if cmd
= 'suit' then begin plr
.GiveItem(ITEM_SUIT
); g_Console_Add('player got an envirosuit'); continue
; end;
4427 if cmd
= 'berserk' then begin plr
.GiveItem(ITEM_MEDKIT_BLACK
); g_Console_Add('player got a berserk pack'); continue
; end;
4428 if cmd
= 'backpack' then begin plr
.GiveItem(ITEM_AMMO_BACKPACK
); g_Console_Add('player got a backpack'); continue
; end;
4430 if cmd
= 'helmet' then begin plr
.GiveItem(ITEM_HELMET
); g_Console_Add('player got a helmet'); continue
; end;
4431 if cmd
= 'bottle' then begin plr
.GiveItem(ITEM_BOTTLE
); g_Console_Add('player got a bottle of health'); continue
; end;
4433 if cmd
= 'stimpack' then begin plr
.GiveItem(ITEM_MEDKIT_SMALL
); g_Console_Add('player got a stimpack'); continue
; end;
4434 if (cmd
= 'medkit') or (cmd
= 'medikit') or (cmd
= 'medpack') or (cmd
= 'medipack') then begin plr
.GiveItem(ITEM_MEDKIT_LARGE
); g_Console_Add('player got a '+cmd
); continue
; end;
4436 if cmd
= 'greenarmor' then begin plr
.GiveItem(ITEM_ARMOR_GREEN
); g_Console_Add('player got a security armor'); continue
; end;
4437 if cmd
= 'bluearmor' then begin plr
.GiveItem(ITEM_ARMOR_BLUE
); g_Console_Add('player got a combat armor'); continue
; end;
4439 if (cmd
= 'megasphere') or (cmd
= 'mega') then begin plr
.GiveItem(ITEM_SPHERE_BLUE
); g_Console_Add('player got a megasphere'); continue
; end;
4440 if (cmd
= 'soulsphere') or (cmd
= 'soul')then begin plr
.GiveItem(ITEM_SPHERE_WHITE
); g_Console_Add('player got a soul sphere'); continue
; end;
4442 if (cmd
= 'invul') or (cmd
= 'invulnerability') then begin plr
.GiveItem(ITEM_INVUL
); g_Console_Add('player got invulnerability'); continue
; end;
4443 if (cmd
= 'invis') or (cmd
= 'invisibility') then begin plr
.GiveItem(ITEM_INVIS
); g_Console_Add('player got invisibility'); continue
; end;
4445 if cmd
= 'redkey' then begin plr
.GiveItem(ITEM_KEY_RED
); g_Console_Add('player got the red key'); continue
; end;
4446 if cmd
= 'greenkey' then begin plr
.GiveItem(ITEM_KEY_GREEN
); g_Console_Add('player got the green key'); continue
; end;
4447 if cmd
= 'bluekey' then begin plr
.GiveItem(ITEM_KEY_BLUE
); g_Console_Add('player got the blue key'); continue
; end;
4449 if (cmd
= 'shotgun') or (cmd
= 'sg') then begin plr
.GiveItem(ITEM_WEAPON_SHOTGUN1
); g_Console_Add('player got a shotgun'); continue
; end;
4450 if (cmd
= 'supershotgun') or (cmd
= 'ssg') then begin plr
.GiveItem(ITEM_WEAPON_SHOTGUN2
); g_Console_Add('player got a supershotgun'); continue
; end;
4451 if cmd
= 'chaingun' then begin plr
.GiveItem(ITEM_WEAPON_CHAINGUN
); g_Console_Add('player got a chaingun'); continue
; end;
4452 if (cmd
= 'launcher') or (cmd
= 'rocketlauncher') or (cmd
= 'rl') then begin plr
.GiveItem(ITEM_WEAPON_ROCKETLAUNCHER
); g_Console_Add('player got a rocket launcher'); continue
; end;
4453 if cmd
= 'plasmagun' then begin plr
.GiveItem(ITEM_WEAPON_PLASMA
); g_Console_Add('player got a plasma gun'); continue
; end;
4454 if cmd
= 'bfg' then begin plr
.GiveItem(ITEM_WEAPON_BFG
); g_Console_Add('player got a BFG-9000'); continue
; end;
4456 if (cmd
= 'shotgunzz') or (cmd
= 'sgzz') then begin plr
.GiveItem(ITEM_WEAPON_SHOTGUN1
); plr
.GiveItem(ITEM_AMMO_SHELLS_BOX
); g_Console_Add('player got a shotgun'); continue
; end;
4457 if (cmd
= 'supershotgunzz') or (cmd
= 'ssgzz') then begin plr
.GiveItem(ITEM_WEAPON_SHOTGUN2
); plr
.GiveItem(ITEM_AMMO_SHELLS_BOX
); g_Console_Add('player got a supershotgun'); continue
; end;
4458 if cmd
= 'chaingunzz' then begin plr
.GiveItem(ITEM_WEAPON_CHAINGUN
); plr
.GiveItem(ITEM_AMMO_BULLETS_BOX
); g_Console_Add('player got a chaingun'); continue
; end;
4459 if (cmd
= 'launcherzz') or (cmd
= 'rocketlauncherzz') or (cmd
= 'rlzz') then begin plr
.GiveItem(ITEM_WEAPON_ROCKETLAUNCHER
); plr
.GiveItem(ITEM_AMMO_ROCKET_BOX
); g_Console_Add('player got a rocket launcher'); continue
; end;
4460 if cmd
= 'plasmagunzz' then begin plr
.GiveItem(ITEM_WEAPON_PLASMA
); plr
.GiveItem(ITEM_AMMO_CELL_BIG
); g_Console_Add('player got a plasma gun'); continue
; end;
4461 if cmd
= 'bfgzz' then begin plr
.GiveItem(ITEM_WEAPON_BFG
); plr
.GiveItem(ITEM_AMMO_CELL_BIG
); g_Console_Add('player got a BFG-9000'); continue
; end;
4463 if cmd
= 'superchaingun' then begin plr
.GiveItem(ITEM_WEAPON_SUPERPULEMET
); g_Console_Add('player got a superchaingun'); continue
; end;
4464 if cmd
= 'superchaingunzz' then begin plr
.GiveItem(ITEM_WEAPON_SUPERPULEMET
); plr
.GiveItem(ITEM_AMMO_BULLETS_BOX
); g_Console_Add('player got a superchaingun'); continue
; end;
4466 if (cmd
= 'flamer') or (cmd
= 'flamethrower') or (cmd
= 'ft') then begin plr
.GiveItem(ITEM_WEAPON_FLAMETHROWER
); g_Console_Add('player got a flame thrower'); continue
; end;
4467 if (cmd
= 'flamerzz') or (cmd
= 'flamethrowerzz') or (cmd
= 'ftzz') then begin plr
.GiveItem(ITEM_WEAPON_FLAMETHROWER
); plr
.GiveItem(ITEM_AMMO_FUELCAN
); g_Console_Add('player got a flame thrower'); continue
; end;
4469 if cmd
= 'chainsaw' then begin plr
.GiveItem(ITEM_WEAPON_SAW
); g_Console_Add('player got a chainsaw'); continue
; end;
4471 if cmd
= 'ammo' then
4473 plr
.GiveItem(ITEM_AMMO_SHELLS_BOX
);
4474 plr
.GiveItem(ITEM_AMMO_BULLETS_BOX
);
4475 plr
.GiveItem(ITEM_AMMO_CELL_BIG
);
4476 plr
.GiveItem(ITEM_AMMO_ROCKET_BOX
);
4477 plr
.GiveItem(ITEM_AMMO_FUELCAN
);
4478 g_Console_Add('player got some ammo');
4482 if cmd
= 'clip' then begin plr
.GiveItem(ITEM_AMMO_BULLETS
); g_Console_Add('player got some bullets'); continue
; end;
4483 if cmd
= 'bullets' then begin plr
.GiveItem(ITEM_AMMO_BULLETS_BOX
); g_Console_Add('player got a box of bullets'); continue
; end;
4485 if cmd
= 'shells' then begin plr
.GiveItem(ITEM_AMMO_SHELLS
); g_Console_Add('player got some shells'); continue
; end;
4486 if cmd
= 'shellbox' then begin plr
.GiveItem(ITEM_AMMO_SHELLS_BOX
); g_Console_Add('player got a box of shells'); continue
; end;
4488 if cmd
= 'cells' then begin plr
.GiveItem(ITEM_AMMO_CELL
); g_Console_Add('player got some cells'); continue
; end;
4489 if cmd
= 'battery' then begin plr
.GiveItem(ITEM_AMMO_CELL_BIG
); g_Console_Add('player got cell battery'); continue
; end;
4491 if cmd
= 'rocket' then begin plr
.GiveItem(ITEM_AMMO_ROCKET
); g_Console_Add('player got a rocket'); continue
; end;
4492 if cmd
= 'rocketbox' then begin plr
.GiveItem(ITEM_AMMO_ROCKET_BOX
); g_Console_Add('player got some rockets'); continue
; end;
4494 if (cmd
= 'fuel') or (cmd
= 'fuelcan') then begin plr
.GiveItem(ITEM_AMMO_FUELCAN
); g_Console_Add('player got fuel canister'); continue
; end;
4496 if cmd
= 'weapons' then
4498 plr
.GiveItem(ITEM_WEAPON_SHOTGUN1
);
4499 plr
.GiveItem(ITEM_WEAPON_SHOTGUN2
);
4500 plr
.GiveItem(ITEM_WEAPON_CHAINGUN
);
4501 plr
.GiveItem(ITEM_WEAPON_ROCKETLAUNCHER
);
4502 plr
.GiveItem(ITEM_WEAPON_PLASMA
);
4503 plr
.GiveItem(ITEM_WEAPON_BFG
);
4504 g_Console_Add('player got weapons');
4508 if cmd
= 'keys' then
4510 plr
.GiveItem(ITEM_KEY_RED
);
4511 plr
.GiveItem(ITEM_KEY_GREEN
);
4512 plr
.GiveItem(ITEM_KEY_BLUE
);
4513 g_Console_Add('player got all keys');
4517 g_Console_Add('i don''t know how to give '''+cmd
+'''!');
4522 if cmd
= 'open' then
4524 g_Console_Add('player activated sesame');
4525 g_Triggers_OpenAll();
4532 if gFly
then g_Console_Add('player feels himself lighter') else g_Console_Add('player lost his wings');
4536 if cmd
= 'noclip' then
4539 g_Console_Add('wall hardeness adjusted');
4543 if cmd
= 'notarget' then
4545 plr
.NoTarget
:= not plr
.NoTarget
;
4546 if plr
.NoTarget
then g_Console_Add('player hides in shadows') else g_Console_Add('player is brave again');
4550 if cmd
= 'noreload' then
4552 plr
.NoReload
:= not plr
.NoReload
;
4553 if plr
.NoReload
then g_Console_Add('player is action hero now') else g_Console_Add('player is ordinary man now');
4557 if cmd
= 'speedy' then
4559 MAX_RUNVEL
:= 32-MAX_RUNVEL
;
4560 g_Console_Add('speed adjusted');
4564 if cmd
= 'jumpy' then
4566 VEL_JUMP
:= 30-VEL_JUMP
;
4567 g_Console_Add('jump height adjusted');
4571 if cmd
= 'automap' then
4573 gShowMap
:= not gShowMap
;
4574 if gShowMap
then g_Console_Add('player gains second sight') else g_Console_Add('player lost second sight');
4578 if cmd
= 'aimline' then
4580 gAimLine
:= not gAimLine
;
4581 if gAimLine
then g_Console_Add('player gains laser sight') else g_Console_Add('player lost laser sight');
4586 procedure GameCommands(P
: SSArray
);
4592 pl
: pTNetClient
= nil;
4600 cmd
:= LowerCase(P
[0]);
4602 if cmd
= 'pause' then
4604 {$IFDEF ENABLE_MENU}
4605 if (g_ActiveWindow
= nil) then
4606 g_Game_Pause(not gPauseMain
);
4608 g_Game_Pause(not gPauseMain
);
4611 else if cmd
= 'endgame' then
4612 gExit
:= EXIT_SIMPLE
4613 else if cmd
= 'restart' then
4615 if gGameOn
or (gState
in [STATE_INTERSINGLE
, STATE_INTERCUSTOM
]) then
4617 if g_Game_IsClient
then
4619 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4624 g_Console_Add(_lc
[I_MSG_NOT_GAME
]);
4626 else if cmd
= 'kick' then
4628 if g_Game_IsServer
then
4630 if Length(P
) < 2 then
4632 g_Console_Add('kick <name>');
4637 g_Console_Add('kick <name>');
4641 if g_Game_IsNet
then
4642 pl
:= g_Net_Client_ByName(P
[1]);
4645 s
:= g_Net_ClientName_ByID(pl
^.ID
);
4646 enet_peer_disconnect(pl
^.Peer
, NET_DISC_KICK
);
4647 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
4648 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
4649 g_Net_Slist_ServerPlayerLeaves();
4650 end else if gPlayers
<> nil then
4651 for a
:= Low(gPlayers
) to High(gPlayers
) do
4652 if gPlayers
[a
] <> nil then
4653 if Copy(LowerCase(gPlayers
[a
].Name
), 1, Length(P
[1])) = LowerCase(P
[1]) then
4655 // Не отключать основных игроков в сингле
4656 if not(gPlayers
[a
] is TBot
) and (gGameSettings
.GameType
= GT_SINGLE
) then
4658 gPlayers
[a
].Lives
:= 0;
4659 gPlayers
[a
].Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
4660 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [gPlayers
[a
].Name
]), True);
4661 g_Player_Remove(gPlayers
[a
].UID
);
4662 g_Net_Slist_ServerPlayerLeaves();
4663 // Если не перемешать, при добавлении новых ботов появятся старые
4667 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
4669 else if cmd
= 'kick_id' then
4671 if g_Game_IsServer
and g_Game_IsNet
then
4673 if Length(P
) < 2 then
4675 g_Console_Add('kick_id <client ID>');
4680 g_Console_Add('kick_id <client ID>');
4684 a
:= StrToIntDef(P
[1], 0);
4685 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
4687 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
4689 s
:= g_Net_ClientName_ByID(NetClients
[a
].ID
);
4690 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_KICK
);
4691 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
4692 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
4693 g_Net_Slist_ServerPlayerLeaves();
4697 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4699 else if cmd
= 'kick_pid' then
4701 if g_Game_IsServer
and g_Game_IsNet
then
4703 if Length(P
) < 2 then
4705 g_Console_Add('kick_pid <player ID>');
4710 g_Console_Add('kick_pid <player ID>');
4714 a
:= StrToIntDef(P
[1], 0);
4715 pl
:= g_Net_Client_ByPlayer(a
);
4716 if (pl
<> nil) and pl
^.Used
and (pl
^.Peer
<> nil) then
4718 s
:= g_Net_ClientName_ByID(pl
^.ID
);
4719 enet_peer_disconnect(pl
^.Peer
, NET_DISC_KICK
);
4720 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
4721 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
4722 g_Net_Slist_ServerPlayerLeaves();
4725 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4727 else if cmd
= 'ban' then
4729 if g_Game_IsServer
and g_Game_IsNet
then
4731 if Length(P
) < 2 then
4733 g_Console_Add('ban <name>');
4738 g_Console_Add('ban <name>');
4742 pl
:= g_Net_Client_ByName(P
[1]);
4745 s
:= g_Net_ClientName_ByID(pl
^.ID
);
4746 g_Net_BanHost(pl
^.Peer
^.address
.host
, False);
4747 enet_peer_disconnect(pl
^.Peer
, NET_DISC_TEMPBAN
);
4748 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
4749 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
4750 g_Net_Slist_ServerPlayerLeaves();
4752 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
4754 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4756 else if cmd
= 'ban_id' then
4758 if g_Game_IsServer
and g_Game_IsNet
then
4760 if Length(P
) < 2 then
4762 g_Console_Add('ban_id <client ID>');
4767 g_Console_Add('ban_id <client ID>');
4771 a
:= StrToIntDef(P
[1], 0);
4772 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
4773 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
4775 s
:= g_Net_ClientName_ByID(NetClients
[a
].ID
);
4776 g_Net_BanHost(NetClients
[a
].Peer
^.address
.host
, False);
4777 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_TEMPBAN
);
4778 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
4779 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
4780 g_Net_Slist_ServerPlayerLeaves();
4783 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4785 else if cmd
= 'ban_pid' then
4787 if g_Game_IsServer
and g_Game_IsNet
then
4789 if Length(P
) < 2 then
4791 g_Console_Add('ban_pid <player ID>');
4796 g_Console_Add('ban_pid <player ID>');
4800 a
:= StrToIntDef(P
[1], 0);
4801 pl
:= g_Net_Client_ByPlayer(a
);
4802 if (pl
<> nil) and pl
^.Used
and (pl
^.Peer
<> nil) then
4804 s
:= g_Net_ClientName_ByID(pl
^.ID
);
4805 g_Net_BanHost(pl
^.Peer
^.address
.host
, False);
4806 enet_peer_disconnect(pl
^.Peer
, NET_DISC_TEMPBAN
);
4807 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
4808 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
4809 g_Net_Slist_ServerPlayerLeaves();
4812 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4814 else if cmd
= 'permban' then
4816 if g_Game_IsServer
and g_Game_IsNet
then
4818 if Length(P
) < 2 then
4820 g_Console_Add('permban <name>');
4825 g_Console_Add('permban <name>');
4829 pl
:= g_Net_Client_ByName(P
[1]);
4832 s
:= g_Net_ClientName_ByID(pl
^.ID
);
4833 g_Net_BanHost(pl
^.Peer
^.address
.host
);
4834 enet_peer_disconnect(pl
^.Peer
, NET_DISC_BAN
);
4835 g_Net_SaveBanList();
4836 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
4837 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
4838 g_Net_Slist_ServerPlayerLeaves();
4840 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
4842 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4844 else if cmd
= 'permban_id' then
4846 if g_Game_IsServer
and g_Game_IsNet
then
4848 if Length(P
) < 2 then
4850 g_Console_Add('permban_id <client ID>');
4855 g_Console_Add('permban_id <client ID>');
4859 a
:= StrToIntDef(P
[1], 0);
4860 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
4861 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
4863 s
:= g_Net_ClientName_ByID(NetClients
[a
].ID
);
4864 g_Net_BanHost(NetClients
[a
].Peer
^.address
.host
);
4865 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_BAN
);
4866 g_Net_SaveBanList();
4867 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
4868 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
4869 g_Net_Slist_ServerPlayerLeaves();
4872 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4874 else if cmd
= 'permban_pid' then
4876 if g_Game_IsServer
and g_Game_IsNet
then
4878 if Length(P
) < 2 then
4880 g_Console_Add('permban_pid <player ID>');
4885 g_Console_Add('permban_pid <player ID>');
4889 a
:= StrToIntDef(P
[1], 0);
4890 pl
:= g_Net_Client_ByPlayer(a
);
4891 if (pl
<> nil) and pl
^.Used
and (pl
^.Peer
<> nil) then
4893 s
:= g_Net_ClientName_ByID(pl
^.ID
);
4894 g_Net_BanHost(pl
^.Peer
^.address
.host
);
4895 enet_peer_disconnect(pl
^.Peer
, NET_DISC_BAN
);
4896 g_Net_SaveBanList();
4897 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
4898 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
4899 g_Net_Slist_ServerPlayerLeaves();
4902 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4904 else if cmd
= 'permban_ip' then
4906 if g_Game_IsServer
and g_Game_IsNet
then
4908 if Length(P
) < 2 then
4910 g_Console_Add('permban_ip <IP address>');
4915 g_Console_Add('permban_ip <IP address>');
4919 g_Net_BanHost(P
[1]);
4920 g_Net_SaveBanList();
4921 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [P
[1]]));
4923 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4925 else if cmd
= 'unban' then
4927 if g_Game_IsServer
and g_Game_IsNet
then
4929 if Length(P
) < 2 then
4931 g_Console_Add('unban <IP Address>');
4936 g_Console_Add('unban <IP Address>');
4940 if g_Net_UnbanHost(P
[1]) then
4942 g_Console_Add(Format(_lc
[I_MSG_UNBAN_OK
], [P
[1]]));
4943 g_Net_SaveBanList();
4945 g_Console_Add(Format(_lc
[I_MSG_UNBAN_FAIL
], [P
[1]]));
4947 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4949 else if cmd
= 'clientlist' then
4951 if g_Game_IsServer
and g_Game_IsNet
then
4954 if NetClients
<> nil then
4955 for a
:= Low(NetClients
) to High(NetClients
) do
4956 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
4958 plr
:= g_Player_Get(NetClients
[a
].Player
);
4959 if plr
= nil then continue
;
4961 g_Console_Add(Format('#%2d: %-15s | %s', [a
,
4962 IpToStr(NetClients
[a
].Peer
^.address
.host
), plr
.Name
]));
4965 g_Console_Add(_lc
[I_MSG_NOCLIENTS
]);
4967 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4969 else if cmd
= 'connect' then
4971 if (NetMode
= NET_NONE
) then
4973 if Length(P
) < 2 then
4975 g_Console_Add('connect <IP> [port] [password]');
4980 g_Console_Add('connect <IP> [port] [password]');
4984 if Length(P
) > 2 then
4985 prt
:= StrToIntDef(P
[2], 25666)
4989 if Length(P
) > 3 then
4994 g_Game_StartClient(P
[1], prt
, pw
);
4997 else if cmd
= 'disconnect' then
4999 if (NetMode
= NET_CLIENT
) then
5002 else if cmd
= 'reconnect' then
5004 if (NetMode
= NET_SERVER
) then
5007 if (NetMode
= NET_CLIENT
) then
5010 gExit
:= EXIT_SIMPLE
;
5014 //TODO: Use last successful password to reconnect, instead of ''
5015 g_Game_StartClient(NetClientIP
, NetClientPort
, '');
5017 else if (cmd
= 'addbot') or
5018 (cmd
= 'bot_add') then
5020 if Length(P
) > 2 then
5021 g_Bot_Add(TEAM_NONE
, StrToIntDef(P
[1], 2), StrToIntDef(P
[2], 100))
5022 else if Length(P
) > 1 then
5023 g_Bot_Add(TEAM_NONE
, StrToIntDef(P
[1], 2))
5025 g_Bot_Add(TEAM_NONE
, 2);
5027 else if cmd
= 'bot_addlist' then
5029 if Length(P
) > 1 then
5031 if Length(P
) = 2 then
5032 g_Bot_AddList(TEAM_NONE
, P
[1], StrToIntDef(P
[1], -1))
5033 else if Length(P
) = 3 then
5034 g_Bot_AddList(TEAM_NONE
, P
[1], StrToIntDef(P
[1], -1), StrToIntDef(P
[2], 100))
5036 g_Bot_AddList(IfThen(P
[2] = 'red', TEAM_RED
, TEAM_BLUE
), P
[1], StrToIntDef(P
[1], -1));
5039 else if cmd
= 'bot_removeall' then
5041 else if cmd
= 'chat' then
5043 if g_Game_IsNet
then
5045 if Length(P
) > 1 then
5047 for a
:= 1 to High(P
) do
5048 chstr
:= chstr
+ P
[a
] + ' ';
5050 if Length(chstr
) > 200 then SetLength(chstr
, 200);
5052 if Length(chstr
) < 1 then
5054 g_Console_Add('chat <text>');
5058 chstr
:= b_Text_Format(chstr
);
5059 if g_Game_IsClient
then
5060 MC_SEND_Chat(chstr
, NET_CHAT_PLAYER
)
5062 MH_SEND_Chat(gPlayer1Settings
.Name
+ ': ' + chstr
, NET_CHAT_PLAYER
);
5065 g_Console_Add('chat <text>');
5067 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
5069 else if cmd
= 'teamchat' then
5071 if g_Game_IsNet
and (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
5073 if Length(P
) > 1 then
5075 for a
:= 1 to High(P
) do
5076 chstr
:= chstr
+ P
[a
] + ' ';
5078 if Length(chstr
) > 200 then SetLength(chstr
, 200);
5080 if Length(chstr
) < 1 then
5082 g_Console_Add('teamchat <text>');
5086 chstr
:= b_Text_Format(chstr
);
5087 if g_Game_IsClient
then
5088 MC_SEND_Chat(chstr
, NET_CHAT_TEAM
)
5090 MH_SEND_Chat(gPlayer1Settings
.Name
+ ': ' + chstr
, NET_CHAT_TEAM
,
5091 gPlayer1Settings
.Team
);
5094 g_Console_Add('teamchat <text>');
5096 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
5098 else if cmd
= 'game' then
5100 if gGameSettings
.GameType
<> GT_NONE
then
5102 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
5105 if Length(P
) = 1 then
5107 g_Console_Add(cmd
+ ' <WAD> [MAP] [# players]');
5110 // game not started yet, load fist map from some wad
5112 s
:= addWadExtension(P
[1]);
5113 found
:= e_FindResource(AllMapDirs
, s
);
5117 P
[1] := ExpandFileName(P
[1]);
5118 // if map not choosed then set first map
5119 if Length(P
) < 3 then
5122 P
[2] := g_Game_GetFirstMap(P
[1]);
5125 s
:= P
[1] + ':\' + UpperCase(P
[2]);
5127 if g_Map_Exist(s
) then
5131 with gGameSettings
do
5133 Options
:= gsGameFlags
;
5134 GameMode
:= g_Game_TextToMode(gsGameMode
);
5135 if gSwitchGameMode
<> GM_NONE
then
5136 GameMode
:= gSwitchGameMode
;
5137 if GameMode
= GM_NONE
then GameMode
:= GM_DM
;
5138 if GameMode
= GM_SINGLE
then GameMode
:= GM_COOP
;
5140 if Length(P
) >= 4 then
5141 b
:= StrToIntDef(P
[3], 1);
5142 g_Game_StartCustom(s
, GameMode
, TimeLimit
,
5143 GoalLimit
, MaxLives
, Options
, b
);
5148 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
5150 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [UpperCase(P
[2]), P
[1]]));
5152 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]));
5154 else if cmd
= 'host' then
5156 if gGameSettings
.GameType
<> GT_NONE
then
5158 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
5161 if Length(P
) < 4 then
5163 g_Console_Add(cmd
+ ' <listen IP> <port> <WAD> [MAP] [# players]');
5166 if not StrToIp(P
[1], listen
) then
5168 prt
:= StrToIntDef(P
[2], 25666);
5170 s
:= addWadExtension(P
[3]);
5171 found
:= e_FindResource(AllMapDirs
, s
);
5175 // get first map in wad, if not specified
5176 if Length(P
) < 5 then
5179 P
[4] := g_Game_GetFirstMap(P
[1]);
5181 s
:= P
[3] + ':\' + UpperCase(P
[4]);
5182 if g_Map_Exist(s
) then
5186 with gGameSettings
do
5188 Options
:= gsGameFlags
;
5189 GameMode
:= g_Game_TextToMode(gsGameMode
);
5190 if gSwitchGameMode
<> GM_NONE
then GameMode
:= gSwitchGameMode
;
5191 if GameMode
= GM_NONE
then GameMode
:= GM_DM
;
5192 if GameMode
= GM_SINGLE
then GameMode
:= GM_COOP
;
5194 if Length(P
) >= 6 then
5195 b
:= StrToIntDef(P
[5], 0);
5196 g_Game_StartServer(s
, GameMode
, TimeLimit
, GoalLimit
, MaxLives
, Options
, b
, listen
, prt
)
5202 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[3]]))
5204 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [UpperCase(P
[4]), P
[3]]))
5209 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[3]]))
5212 else if cmd
= 'map' then
5214 if Length(P
) = 1 then
5216 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
5218 g_Console_Add(cmd
+ ' <MAP>');
5219 g_Console_Add(cmd
+ ' <WAD> [MAP]')
5223 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
])
5228 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
5230 if Length(P
) < 3 then
5232 // first param is map or wad
5233 s
:= UpperCase(P
[1]);
5234 if g_Map_Exist(gGameSettings
.WAD
+ ':\' + s
) then
5236 gExitByTrigger
:= False;
5239 // already in game, finish current map
5241 gExit
:= EXIT_ENDLEVELCUSTOM
;
5245 // intermission, so change map immediately
5252 found
:= e_FindResource(AllMapDirs
, s
);
5254 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [s
, 'WAD ' + P
[1]]));
5257 // no such map, found wad
5260 P
[1] := ExpandFileName(pw
);
5261 P
[2] := g_Game_GetFirstMap(P
[1]);
5262 s
:= P
[1] + ':\' + P
[2];
5263 if g_Map_Exist(s
) then
5265 gExitByTrigger
:= False;
5268 // already in game, finish current map
5270 gExit
:= EXIT_ENDLEVELCUSTOM
5274 // intermission, so change map immediately
5281 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
5283 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]))
5288 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]))
5294 s
:= addWadExtension(P
[1]);
5295 found
:= e_FindResource(AllMapDirs
, s
);
5299 P
[2] := UpperCase(P
[2]);
5300 s
:= P
[1] + ':\' + P
[2];
5301 if g_Map_Exist(s
) then
5303 gExitByTrigger
:= False;
5307 gExit
:= EXIT_ENDLEVELCUSTOM
5316 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]))
5321 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]))
5327 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
])
5331 else if cmd
= 'nextmap' then
5333 if not(gGameOn
or (gState
= STATE_INTERCUSTOM
)) then
5335 g_Console_Add(_lc
[I_MSG_NOT_GAME
])
5340 if Length(P
) = 1 then
5342 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
5344 g_Console_Add(cmd
+ ' <MAP>');
5345 g_Console_Add(cmd
+ ' <WAD> [MAP]');
5350 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
5356 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
5358 if Length(P
) < 3 then
5360 // first param is map or wad
5361 s
:= UpperCase(P
[1]);
5362 if g_Map_Exist(gGameSettings
.WAD
+ ':\' + s
) then
5365 gExitByTrigger
:= False;
5371 // no such map, found wad
5372 pw
:= addWadExtension(P
[1]);
5373 found
:= e_FindResource(MapDirs
, pw
);
5375 found
:= e_FindResource(WadDirs
, pw
);
5377 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [s
, P
[1]]));
5380 // map not specified, select first map
5382 P
[2] := g_Game_GetFirstMap(P
[1]);
5383 s
:= P
[1] + ':\' + P
[2];
5384 if g_Map_Exist(s
) then
5386 gExitByTrigger
:= False;
5393 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
5395 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]))
5400 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]))
5406 // specified two params wad + map
5407 pw
:= addWadExtension(P
[1]);
5408 found
:= e_FindResource(MapDirs
, pw
);
5410 found
:= e_FindResource(MapDirs
, pw
);
5414 P
[2] := UpperCase(P
[2]);
5415 s
:= P
[1] + ':\' + P
[2];
5416 if g_Map_Exist(s
) then
5418 gExitByTrigger
:= False;
5424 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]))
5429 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]))
5435 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
])
5440 if gNextMap
= '' then
5441 g_Console_Add(_lc
[I_MSG_NEXTMAP_UNSET
])
5443 g_Console_Add(Format(_lc
[I_MSG_NEXTMAP_SET
], [gNextMap
]))
5447 else if (cmd
= 'endmap') or (cmd
= 'goodbye') then
5451 g_Console_Add(_lc
[I_MSG_NOT_GAME
])
5455 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
5457 gExitByTrigger
:= False;
5458 // next map not specified, try to find trigger EXIT
5459 if (gNextMap
= '') and (gTriggers
<> nil) then
5461 for a
:= 0 to High(gTriggers
) do
5463 if gTriggers
[a
].TriggerType
= TRIGGER_EXIT
then
5465 gExitByTrigger
:= True;
5466 //gNextMap := gTriggers[a].Data.MapName;
5467 gNextMap
:= gTriggers
[a
].tgcMap
;
5472 if gNextMap
= '' then
5473 gNextMap
:= g_Game_GetNextMap();
5474 if not isWadPath(gNextMap
) then
5475 s
:= gGameSettings
.WAD
+ ':\' + gNextMap
5478 if g_Map_Exist(s
) then
5479 gExit
:= EXIT_ENDLEVELCUSTOM
5481 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [gNextMap
]))
5485 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
])
5489 else if (cmd
= 'event') then
5491 if (Length(P
) <= 1) then
5493 for a
:= 0 to High(gEvents
) do
5494 if gEvents
[a
].Command
= '' then
5495 g_Console_Add(gEvents
[a
].Name
+ ' <none>')
5497 g_Console_Add(gEvents
[a
].Name
+ ' "' + gEvents
[a
].Command
+ '"');
5500 if (Length(P
) = 2) then
5502 for a
:= 0 to High(gEvents
) do
5503 if gEvents
[a
].Name
= P
[1] then
5504 if gEvents
[a
].Command
= '' then
5505 g_Console_Add(gEvents
[a
].Name
+ ' <none>')
5507 g_Console_Add(gEvents
[a
].Name
+ ' "' + gEvents
[a
].Command
+ '"');
5510 for a
:= 0 to High(gEvents
) do
5511 if gEvents
[a
].Name
= P
[1] then
5513 gEvents
[a
].Command
:= '';
5514 for b
:= 2 to High(P
) do
5515 if Pos(' ', P
[b
]) = 0 then
5516 gEvents
[a
].Command
:= gEvents
[a
].Command
+ ' ' + P
[b
]
5518 gEvents
[a
].Command
:= gEvents
[a
].Command
+ ' "' + P
[b
] + '"';
5519 gEvents
[a
].Command
:= Trim(gEvents
[a
].Command
);
5523 else if cmd
= 'suicide' then
5527 if g_Game_IsClient
then
5528 MC_SEND_CheatRequest(NET_CHEAT_SUICIDE
)
5531 if gPlayer1
<> nil then
5532 gPlayer1
.Damage(SUICIDE_DAMAGE
, gPlayer1
.UID
, 0, 0, HIT_SELF
);
5533 if gPlayer2
<> nil then
5534 gPlayer2
.Damage(SUICIDE_DAMAGE
, gPlayer2
.UID
, 0, 0, HIT_SELF
);
5538 else if cmd
= 'screenshot' then
5544 else if cmd
= 'weapon' then
5546 if Length(p
) = 2 then
5548 a
:= WP_FIRST
+ StrToInt(p
[1]) - 1;
5549 if (a
>= WP_FIRST
) and (a
<= WP_LAST
) then
5550 gSelectWeapon
[0, a
] := True
5553 else if (cmd
= 'p1_weapon') or (cmd
= 'p2_weapon') then
5555 if Length(p
) = 2 then
5557 a
:= WP_FIRST
+ StrToInt(p
[1]) - 1;
5558 b
:= ord(cmd
[2]) - ord('1');
5559 if (a
>= WP_FIRST
) and (a
<= WP_LAST
) then
5560 gSelectWeapon
[b
, a
] := True
5563 // Команды Своей игры:
5564 else if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
5566 if cmd
= 'bot_addred' then
5568 if Length(P
) > 1 then
5569 g_Bot_Add(TEAM_RED
, StrToIntDef(P
[1], 2))
5571 g_Bot_Add(TEAM_RED
, 2);
5573 else if cmd
= 'bot_addblue' then
5575 if Length(P
) > 1 then
5576 g_Bot_Add(TEAM_BLUE
, StrToIntDef(P
[1], 2))
5578 g_Bot_Add(TEAM_BLUE
, 2);
5580 else if cmd
= 'spectate' then
5586 else if cmd
= 'say' then
5588 if g_Game_IsServer
and g_Game_IsNet
then
5590 if Length(P
) > 1 then
5593 for a
:= 1 to High(P
) do
5594 chstr
:= chstr
+ P
[a
] + ' ';
5596 if Length(chstr
) > 200 then SetLength(chstr
, 200);
5598 if Length(chstr
) < 1 then
5600 g_Console_Add('say <text>');
5604 chstr
:= b_Text_Format(chstr
);
5605 MH_SEND_Chat(chstr
, NET_CHAT_PLAYER
);
5607 else g_Console_Add('say <text>');
5609 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
5611 else if cmd
= 'tell' then
5613 if g_Game_IsServer
and g_Game_IsNet
then
5615 if (Length(P
) > 2) and (P
[1] <> '') then
5618 for a
:= 2 to High(P
) do
5619 chstr
:= chstr
+ P
[a
] + ' ';
5621 if Length(chstr
) > 200 then SetLength(chstr
, 200);
5623 if Length(chstr
) < 1 then
5625 g_Console_Add('tell <playername> <text>');
5629 pl
:= g_Net_Client_ByName(P
[1]);
5631 MH_SEND_Chat(b_Text_Format(chstr
), NET_CHAT_PLAYER
, pl
^.ID
)
5633 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
5635 else g_Console_Add('tell <playername> <text>');
5637 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
5639 else if cmd
= 'centerprint' then
5641 if (Length(P
) > 2) and (P
[1] <> '') then
5644 for a
:= 2 to High(P
) do
5645 chstr
:= chstr
+ P
[a
] + ' ';
5647 if Length(chstr
) > 200 then SetLength(chstr
, 200);
5649 if Length(chstr
) < 1 then
5651 g_Console_Add('centerprint <timeout> <text>');
5655 a
:= StrToIntDef(P
[1], 100);
5656 chstr
:= b_Text_Format(chstr
);
5657 g_Game_Message(chstr
, a
);
5658 if g_Game_IsNet
and g_Game_IsServer
then
5659 MH_SEND_GameEvent(NET_EV_BIGTEXT
, a
, chstr
);
5661 else g_Console_Add('centerprint <timeout> <text>');
5663 else if (cmd
= 'overtime') and not g_Game_IsClient
then
5665 if (Length(P
) = 1) or (StrToIntDef(P
[1], -1) <= 0) then
5667 // Дополнительное время:
5668 gGameSettings
.TimeLimit
:= (gTime
- gGameStartTime
) div 1000 + Word(StrToIntDef(P
[1], 0));
5670 g_Console_Add(Format(_lc
[I_MSG_TIME_LIMIT
],
5671 [gGameSettings
.TimeLimit
div 3600,
5672 (gGameSettings
.TimeLimit
div 60) mod 60,
5673 gGameSettings
.TimeLimit
mod 60]));
5674 if g_Game_IsNet
then MH_SEND_GameSettings
;
5676 else if (cmd
= 'rcon_password') and g_Game_IsClient
then
5678 if (Length(P
) <= 1) then
5679 g_Console_Add('rcon_password <password>')
5681 MC_SEND_RCONPassword(P
[1]);
5683 else if cmd
= 'rcon' then
5685 if g_Game_IsClient
then
5687 if Length(P
) > 1 then
5690 for a
:= 1 to High(P
) do
5691 chstr
:= chstr
+ P
[a
] + ' ';
5693 if Length(chstr
) > 200 then SetLength(chstr
, 200);
5695 if Length(chstr
) < 1 then
5697 g_Console_Add('rcon <command>');
5701 MC_SEND_RCONCommand(chstr
);
5703 else g_Console_Add('rcon <command>');
5706 else if cmd
= 'ready' then
5708 if g_Game_IsServer
and (gLMSRespawn
= LMS_RESPAWN_WARMUP
) then
5709 gLMSRespawnTime
:= gTime
+ 100;
5711 else if (cmd
= 'callvote') and g_Game_IsNet
then
5713 if Length(P
) > 1 then
5716 for a
:= 1 to High(P
) do begin
5717 if a
> 1 then chstr
:= chstr
+ ' ';
5718 chstr
:= chstr
+ P
[a
];
5721 if Length(chstr
) > 200 then SetLength(chstr
, 200);
5723 if Length(chstr
) < 1 then
5725 g_Console_Add('callvote <command>');
5729 if g_Game_IsClient
then
5730 MC_SEND_Vote(True, chstr
)
5732 g_Game_StartVote(chstr
, gPlayer1Settings
.Name
);
5733 g_Console_Process('vote', True);
5736 g_Console_Add('callvote <command>');
5738 else if (cmd
= 'vote') and g_Game_IsNet
then
5740 if g_Game_IsClient
then
5742 else if gVoteInProgress
then
5744 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
5745 a
:= Floor((NetClientCount
+1)/2.0) + 1
5747 a
:= Floor(NetClientCount
/2.0) + 1;
5752 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_REVOKED
], [gPlayer1Settings
.Name
, gVoteCount
, a
]), True);
5753 MH_SEND_VoteEvent(NET_VE_REVOKE
, gPlayer1Settings
.Name
, 'a', gVoteCount
, a
);
5759 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_VOTE
], [gPlayer1Settings
.Name
, gVoteCount
, a
]), True);
5760 MH_SEND_VoteEvent(NET_VE_VOTE
, gPlayer1Settings
.Name
, 'a', gVoteCount
, a
);
5768 procedure SystemCommands(P
: SSArray
);
5772 cmd
:= LowerCase(P
[0]);
5785 if Length(p
) = 2 then
5787 gMaxFPS
:= StrToIntDef(p
[1], gMaxFPS
);
5789 gFrameTime
:= 1000 div gMaxFPS
5793 e_LogWritefln('r_maxfps %d', [gMaxFPS
]);
5797 if Length(p
) = 2 then
5799 gAskLanguage
:= true;
5800 gLanguage
:= LANGUAGE_ENGLISH
;
5801 case LowerCase(p
[1]) of
5804 gAskLanguage
:= false;
5805 gLanguage
:= LANGUAGE_ENGLISH
;
5809 gAskLanguage
:= false;
5810 gLanguage
:= LANGUAGE_RUSSIAN
;
5814 gAskLanguage
:= true;
5815 gLanguage
:= LANGUAGE_ENGLISH
;
5818 g_Language_Set(gLanguage
);
5822 e_LogWritefln('usage: %s <English|Russian|Ask>', [cmd
]);
5829 procedure g_TakeScreenShot(Filename
: string = '');
5830 var t
: TDateTime
; dir
, date
, name
: String;
5832 if e_NoGraphics
then
5835 dir
:= e_GetWriteableDir(ScreenshotDirs
);
5836 if Filename
= '' then
5839 DateTimeToString(date
, 'yyyy-mm-dd-hh-nn-ss', t
);
5840 Filename
:= 'screenshot-' + date
;
5843 name
:= e_CatPath(dir
, Filename
+ '.png');
5844 if r_Render_WriteScreenShot(name
) then
5845 g_Console_Add(Format(_lc
[I_CONSOLE_SCREENSHOT
], [name
]))
5847 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_WRITE
], [name
]));
5851 {$IFDEF ENABLE_MENU}
5852 procedure g_Game_InGameMenu(Show
: Boolean);
5854 if (g_ActiveWindow
= nil) and Show
then
5856 if gGameSettings
.GameType
= GT_SINGLE
then
5857 g_GUI_ShowWindow('GameSingleMenu')
5860 if g_Game_IsClient
then
5861 g_GUI_ShowWindow('GameClientMenu')
5863 if g_Game_IsNet
then
5864 g_GUI_ShowWindow('GameServerMenu')
5866 g_GUI_ShowWindow('GameCustomMenu');
5868 g_Sound_PlayEx('MENU_OPEN');
5870 // Пауза при меню только в одиночной игре:
5871 if (not g_Game_IsNet
) then
5875 if (g_ActiveWindow
<> nil) and (not Show
) then
5877 // Пауза при меню только в одиночной игре:
5878 if (not g_Game_IsNet
) then
5879 g_Game_Pause(False);
5884 procedure g_Game_Pause (Enable
: Boolean);
5888 if not gGameOn
then exit
;
5890 if not (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
]) then exit
;
5893 gPauseMain
:= Enable
;
5895 if (gPause
<> oldPause
) then g_Game_PauseAllSounds(gPause
);
5898 procedure g_Game_HolmesPause (Enable
: Boolean);
5902 if not gGameOn
then exit
;
5903 if not (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
]) then exit
;
5906 gPauseHolmes
:= Enable
;
5908 if (gPause
<> oldPause
) then g_Game_PauseAllSounds(gPause
);
5911 procedure g_Game_PauseAllSounds(Enable
: Boolean);
5916 if gTriggers
<> nil then
5917 for i
:= 0 to High(gTriggers
) do
5918 with gTriggers
[i
] do
5919 if (TriggerType
= TRIGGER_SOUND
) and
5921 Sound
.IsPlaying() then
5923 Sound
.Pause(Enable
);
5927 if gPlayers
<> nil then
5928 for i
:= 0 to High(gPlayers
) do
5929 if gPlayers
[i
] <> nil then
5930 gPlayers
[i
].PauseSounds(Enable
);
5933 if gMusic
<> nil then
5934 gMusic
.Pause(Enable
);
5937 procedure g_Game_StopAllSounds(all
: Boolean);
5941 if gTriggers
<> nil then
5942 for i
:= 0 to High(gTriggers
) do
5943 with gTriggers
[i
] do
5944 if (TriggerType
= TRIGGER_SOUND
) and
5948 if gMusic
<> nil then
5955 procedure g_Game_UpdateTriggerSounds
;
5958 if gTriggers
<> nil then
5959 for i
:= 0 to High(gTriggers
) do
5960 with gTriggers
[i
] do
5961 if (TriggerType
= TRIGGER_SOUND
) and (Sound
<> nil) and tgcLocal
and Sound
.IsPlaying() then
5962 Sound
.SetCoordsRect(X
, Y
, Width
, Height
, tgcVolume
/ 255.0)
5965 function g_Game_IsWatchedPlayer(UID
: Word): Boolean;
5968 if (gPlayer1
<> nil) and (gPlayer1
.UID
= UID
) then
5973 if (gPlayer2
<> nil) and (gPlayer2
.UID
= UID
) then
5978 if gSpectMode
<> SPECT_PLAYERS
then
5980 if gSpectPID1
= UID
then
5985 if gSpectViewTwo
and (gSpectPID2
= UID
) then
5992 function g_Game_IsWatchedTeam(Team
: Byte): Boolean;
5997 if (gPlayer1
<> nil) and (gPlayer1
.Team
= Team
) then
6002 if (gPlayer2
<> nil) and (gPlayer2
.Team
= Team
) then
6007 if gSpectMode
<> SPECT_PLAYERS
then
6009 Pl
:= g_Player_Get(gSpectPID1
);
6010 if (Pl
<> nil) and (Pl
.Team
= Team
) then
6015 if gSpectViewTwo
then
6017 Pl
:= g_Player_Get(gSpectPID2
);
6018 if (Pl
<> nil) and (Pl
.Team
= Team
) then
6026 procedure g_Game_Message (Msg
: string; Time
: Word);
6029 MessageTime
:= Time
;
6032 procedure g_Game_ChatSound(Text: String; Taunt
: Boolean = True);
6034 punct
: Array[0..13] of String =
6035 ('.', ',', ':', ';', '!', '?', '(', ')', '''', '"', '/', '\', '*', '^');
6041 function IsPunctuation(S
: String): Boolean;
6046 if Length(S
) <> 1 then
6048 for i
:= Low(punct
) to High(punct
) do
6049 if S
= punct
[i
] then
6055 function FilterPunctuation(S
: String): String;
6059 for i
:= Low(punct
) to High(punct
) do
6060 S
:= StringReplace(S
, punct
[i
], ' ', [rfReplaceAll
]);
6066 if gUseChatSounds
and Taunt
and (gChatSounds
<> nil) and (Pos(': ', Text) > 0) then
6068 // remove player name
6069 Delete(Text, 1, Pos(': ', Text) + 2 - 1);
6070 // for FullWord check
6071 Text := toLowerCase1251(' ' + Text + ' ');
6072 fpText
:= FilterPunctuation(Text);
6074 for i
:= 0 to Length(gChatSounds
) - 1 do
6077 for j
:= 0 to Length(gChatSounds
[i
].Tags
) - 1 do
6079 if gChatSounds
[i
].FullWord
and (not IsPunctuation(gChatSounds
[i
].Tags
[j
])) then
6080 ok
:= Pos(' ' + gChatSounds
[i
].Tags
[j
] + ' ', fpText
) > 0
6082 ok
:= Pos(gChatSounds
[i
].Tags
[j
], Text) > 0;
6088 gChatSounds
[i
].Sound
.Play();
6094 g_Sound_PlayEx('SOUND_GAME_RADIO');
6097 procedure g_Game_Announce_GoodShot(SpawnerUID
: Word);
6106 if not g_Game_IsWatchedPlayer(SpawnerUID
) then
6110 if goodsnd
[a
].IsPlaying() then
6113 goodsnd
[Random(4)].Play();
6116 procedure g_Game_Announce_KillCombo(Param
: Integer);
6123 UID
:= Param
and $FFFF;
6128 Pl
:= g_Player_Get(UID
);
6137 g_Console_Add(Format(_lc
[I_PLAYER_KILL_2X
], [Name
]), True);
6141 g_Console_Add(Format(_lc
[I_PLAYER_KILL_3X
], [Name
]), True);
6145 g_Console_Add(Format(_lc
[I_PLAYER_KILL_4X
], [Name
]), True);
6149 g_Console_Add(Format(_lc
[I_PLAYER_KILL_MX
], [Name
]), True);
6157 if not g_Game_IsWatchedPlayer(UID
) then
6160 if (not g_Game_IsWatchedPlayer(UID
)) and (c
< 4) then
6164 if killsnd
[n
].IsPlaying() then
6169 procedure g_Game_Announce_BodyKill(SpawnerUID
: Word);
6177 if not g_Game_IsWatchedPlayer(SpawnerUID
) then
6181 if hahasnd
[a
].IsPlaying() then
6184 hahasnd
[Random(3)].Play();
6187 procedure g_Game_StartVote(Command
, Initiator
: string);
6191 if not gVotesEnabled
then Exit
;
6192 if gGameSettings
.GameType
<> GT_SERVER
then Exit
;
6193 if gVoteInProgress
or gVotePassed
then
6195 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_INPROGRESS
], [gVoteCommand
]), True);
6196 MH_SEND_VoteEvent(NET_VE_INPROGRESS
, gVoteCommand
);
6199 gVoteInProgress
:= True;
6200 gVotePassed
:= False;
6201 gVoteTimer
:= gTime
+ gVoteTimeout
* 1000;
6204 gVoteCommand
:= Command
;
6206 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
6207 Need
:= Floor((NetClientCount
+1)/2.0)+1
6209 Need
:= Floor(NetClientCount
/2.0)+1;
6210 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_STARTED
], [Initiator
, Command
, Need
]), True);
6211 MH_SEND_VoteEvent(NET_VE_STARTED
, Initiator
, Command
, Need
);
6214 procedure g_Game_CheckVote
;
6218 if gGameSettings
.GameType
<> GT_SERVER
then Exit
;
6219 if not gVoteInProgress
then Exit
;
6221 if (gTime
>= gVoteTimer
) then
6223 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
6224 Need
:= Floor((NetClientCount
+1)/2.0) + 1
6226 Need
:= Floor(NetClientCount
/2.0) + 1;
6227 if gVoteCount
>= Need
then
6229 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_PASSED
], [gVoteCommand
]), True);
6230 MH_SEND_VoteEvent(NET_VE_PASSED
, gVoteCommand
);
6231 gVotePassed
:= True;
6232 gVoteCmdTimer
:= gTime
+ 5000;
6236 g_Console_Add(_lc
[I_MESSAGE_VOTE_FAILED
], True);
6237 MH_SEND_VoteEvent(NET_VE_FAILED
);
6239 if NetClients
<> nil then
6240 for I
:= Low(NetClients
) to High(NetClients
) do
6241 if NetClients
[i
].Used
then
6242 NetClients
[i
].Voted
:= False;
6243 gVoteInProgress
:= False;
6249 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
6250 Need
:= Floor((NetClientCount
+1)/2.0) + 1
6252 Need
:= Floor(NetClientCount
/2.0) + 1;
6253 if gVoteCount
>= Need
then
6255 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_PASSED
], [gVoteCommand
]), True);
6256 MH_SEND_VoteEvent(NET_VE_PASSED
, gVoteCommand
);
6257 gVoteInProgress
:= False;
6258 gVotePassed
:= True;
6259 gVoteCmdTimer
:= gTime
+ 5000;
6262 if NetClients
<> nil then
6263 for I
:= Low(NetClients
) to High(NetClients
) do
6264 if NetClients
[i
].Used
then
6265 NetClients
[i
].Voted
:= False;
6270 procedure g_Game_LoadMapList(FileName
: string);
6278 if not FileExists(FileName
) then Exit
;
6280 AssignFile(ListFile
, FileName
);
6282 while not EOF(ListFile
) do
6284 ReadLn(ListFile
, s
);
6287 if s
= '' then Continue
;
6289 SetLength(MapList
, Length(MapList
)+1);
6290 MapList
[High(MapList
)] := s
;
6292 CloseFile(ListFile
);
6295 procedure g_Game_SetDebugMode();
6298 // Читы (даже в своей игре):
6302 procedure g_Game_SetLoadingText(Text: String; Max
: Integer; reWrite
: Boolean);
6306 if Length(LoadingStat
.Msgs
) = 0 then
6312 begin // Переходим на следующую строку или скроллируем:
6313 if NextMsg
= Length(Msgs
) then
6315 for i
:= 0 to High(Msgs
)-1 do
6316 Msgs
[i
] := Msgs
[i
+1];
6324 Msgs
[NextMsg
-1] := Text;
6328 PBarWasHere
:= false;
6331 {$IFDEF ENABLE_MENU}
6332 g_ActiveWindow
:= nil;
6335 ProcessLoading(true);
6338 procedure g_Game_StepLoading(Value
: Integer = -1);
6349 if (ShowCount
> LOADING_SHOW_STEP
) or (Value
> -1) then
6357 procedure g_Game_ClearLoading();
6366 len
:= ((gScreenHeight
div 3)*2 - 50) div LOADING_INTERLINE
;
6367 if len
< 1 then len
:= 1;
6368 SetLength(Msgs
, len
);
6369 for len
:= Low(Msgs
) to High(Msgs
) do
6372 PBarWasHere
:= false;
6376 procedure Parse_Params(var pars
: TParamStrValues
);
6383 while i
<= ParamCount
do
6386 if (s
[1] = '-') and (Length(s
) > 1) then
6388 if (s
[2] = '-') and (Length(s
) > 2) then
6389 begin // Одиночный параметр
6390 SetLength(pars
, Length(pars
) + 1);
6391 with pars
[High(pars
)] do
6393 Name
:= LowerCase(s
);
6398 if (i
< ParamCount
) then
6399 begin // Параметр со значением
6401 SetLength(pars
, Length(pars
) + 1);
6402 with pars
[High(pars
)] do
6404 Name
:= LowerCase(s
);
6405 Value
:= LowerCase(ParamStr(i
));
6414 function Find_Param_Value(var pars
: TParamStrValues
; aName
: String): String;
6419 for i
:= 0 to High(pars
) do
6420 if pars
[i
].Name
= aName
then
6422 Result
:= pars
[i
].Value
;
6427 procedure g_Game_Process_Params();
6429 pars
: TParamStrValues
;
6432 LimT
, LimS
: Integer;
6443 s
:= Find_Param_Value(pars
, '--debug');
6446 g_Game_SetDebugMode();
6447 s
:= Find_Param_Value(pars
, '--netdump');
6452 // Connect when game loads
6453 ip
:= Find_Param_Value(pars
, '-connect');
6457 s
:= Find_Param_Value(pars
, '-port');
6458 if (s
= '') or not TryStrToInt(s
, Port
) then
6461 s
:= Find_Param_Value(pars
, '-pw');
6463 g_Game_StartClient(ip
, Port
, s
);
6467 s
:= LowerCase(Find_Param_Value(pars
, '-dbg-mainwad'));
6470 gDefaultMegawadStart
:= s
;
6473 if (Find_Param_Value(pars
, '--dbg-mainwad-restore') <> '') or
6474 (Find_Param_Value(pars
, '--dbg-mainwad-default') <> '') then
6476 gDefaultMegawadStart
:= DF_Default_Megawad_Start
;
6479 // Start map when game loads:
6480 map
:= LowerCase(Find_Param_Value(pars
, '-map'));
6481 if isWadPath(map
) then
6484 s
:= Find_Param_Value(pars
, '-gm');
6485 GMode
:= g_Game_TextToMode(s
);
6486 if GMode
= GM_NONE
then GMode
:= GM_DM
;
6487 if GMode
= GM_SINGLE
then GMode
:= GM_COOP
;
6490 s
:= Find_Param_Value(pars
, '-limt');
6491 if (s
= '') or (not TryStrToInt(s
, LimT
)) then
6497 s
:= Find_Param_Value(pars
, '-lims');
6498 if (s
= '') or (not TryStrToInt(s
, LimS
)) then
6504 s
:= Find_Param_Value(pars
, '-lives');
6505 if (s
= '') or (not TryStrToInt(s
, Lives
)) then
6511 s
:= Find_Param_Value(pars
, '-opt');
6515 Opt
:= StrToIntDef(s
, 0);
6518 s
:= Find_Param_Value(pars
, '--close');
6522 // Override map to test:
6523 s
:= LowerCase(Find_Param_Value(pars
, '-testmap'));
6526 if e_IsValidResourceName(s
) then
6527 e_FindResource(AllMapDirs
, s
);
6528 gTestMap
:= ExpandFileName(s
);
6531 // Delete test map after play:
6532 s
:= Find_Param_Value(pars
, '--testdelete');
6535 //gMapToDelete := MapsDir + map;
6536 e_WriteLog('"--testdelete" is deprecated, use --tempdelete.', TMsgType
.Fatal
);
6540 // Delete temporary WAD after play:
6541 s
:= Find_Param_Value(pars
, '--tempdelete');
6542 if (s
<> '') and (gTestMap
<> '') then
6544 gMapToDelete
:= gTestMap
;
6545 gTempDelete
:= True;
6548 // Number of players:
6549 s
:= Find_Param_Value(pars
, '-pl');
6551 n
:= DEFAULT_PLAYERS
6553 n
:= StrToIntDef(s
, DEFAULT_PLAYERS
);
6556 s
:= Find_Param_Value(pars
, '-port');
6557 if (s
= '') or not TryStrToInt(s
, Port
) then
6558 g_Game_StartCustom(map
, GMode
, LimT
, LimS
, Lives
, Opt
, n
)
6560 g_Game_StartServer(map
, GMode
, LimT
, LimS
, Lives
, Opt
, n
, 0, Port
);
6563 // Execute script when game loads:
6564 s
:= Find_Param_Value(pars
, '-exec');
6567 // if not isWadPath(s) then
6568 // s := GameDir + '/' + s;
6573 if IOResult
<> 0 then
6575 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], ['Failed to read file: ' + s
]), TMsgType
.Warning
);
6576 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_READ
], [s
]));
6580 e_WriteLog('Executing script: ' + s
, TMsgType
.Notify
);
6581 g_Console_Add(Format(_lc
[I_CONSOLE_EXEC
], [s
]));
6586 if IOResult
<> 0 then
6588 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], ['Failed to read file: ' + s
]), TMsgType
.Warning
);
6589 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_READ
], [s
]));
6593 if Pos('#', s
) <> 1 then // script comment
6594 g_Console_Process(s
, True);
6605 conRegVar('pf_draw_frame', @g_profile_frame_draw
, 'draw frame rendering profiles', 'render profiles');
6606 //conRegVar('pf_update_frame', @g_profile_frame_update, 'draw frame updating profiles', 'update profiles');
6607 conRegVar('pf_coldet', @g_profile_collision
, 'draw collision detection profiles', 'coldet profiles');
6608 conRegVar('pf_los', @g_profile_los
, 'draw monster LOS profiles', 'monster LOS profiles');
6610 conRegVar('r_sq_draw', @gdbg_map_use_accel_render
, 'accelerated spatial queries in rendering', 'accelerated rendering');
6611 conRegVar('cd_sq_enabled', @gdbg_map_use_accel_coldet
, 'accelerated spatial queries in map coldet', 'accelerated map coldet');
6612 conRegVar('mon_sq_enabled', @gmon_debug_use_sqaccel
, 'accelerated spatial queries for monsters', 'accelerated monster coldet');
6613 conRegVar('wtrace_sq_enabled', @gwep_debug_fast_trace
, 'accelerated spatial queries for weapon hitscan trace', 'accelerated weapon hitscan');
6616 conRegVar('pr_enabled', @gpart_dbg_enabled
, 'enable/disable particles', 'particles');
6617 conRegVar('pr_phys_enabled', @gpart_dbg_phys_enabled
, 'enable/disable particle physics', 'particle physics');
6620 conRegVar('los_enabled', @gmon_dbg_los_enabled
, 'enable/disable monster LOS calculations', 'monster LOS', true);
6621 conRegVar('mon_think', @gmon_debug_think
, 'enable/disable monster thinking', 'monster thinking', true);
6623 {$IFDEF ENABLE_HOLMES}
6624 conRegVar('dbg_holmes', @g_holmes_enabled
, 'enable/disable Holmes', 'Holmes', true);
6627 conRegVar('dbg_ignore_level_bounds', @g_dbg_ignore_bounds
, 'ignore level bounds', '', false);
6629 conRegVar('light_enabled', @gwin_k8_enable_light_experiments
, 'enable/disable dynamic lighting', 'lighting');
6630 conRegVar('light_player_halo', @g_playerLight
, 'enable/disable player halo', 'player light halo');
6632 conRegVar('r_smallmap_align_h', @r_smallmap_h
, 'halign: 0: left; 1: center; 2: right', 'horizontal aligning of small maps');
6633 conRegVar('r_smallmap_align_v', @r_smallmap_v
, 'valign: 0: top; 1: center; 2: bottom', 'vertial aligning of small maps');
6635 conRegVar('r_showfps', @gShowFPS
, 'draw fps counter', 'draw fps counter');
6636 conRegVar('r_showtime', @gShowTime
, 'show game time', 'show game time');
6637 conRegVar('r_showping', @gShowPing
, 'show ping', 'show ping');
6638 conRegVar('r_showscore', @gShowGoals
, 'show score', 'show score');
6639 conRegVar('r_showkillmsg', @gShowKillMsg
, 'show kill log', 'show kill log');
6640 conRegVar('r_showlives', @gShowLives
, 'show lives', 'show lives');
6641 conRegVar('r_showspect', @gSpectHUD
, 'show spectator hud', 'show spectator hud');
6642 conRegVar('r_showstat', @gShowStat
, 'show stats', 'show stats');
6643 conRegVar('r_showpids', @gShowPIDs
, 'show PIDs', 'show PIDs');