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}
457 {$IFDEF ENABLE_SHELLS}
464 e_input
, e_log
, g_console
, g_items
, g_map
, g_panel
,
465 g_playermodel
, g_options
, Math
,
466 g_triggers
, g_monsters
, e_sound
, CONFIG
,
467 g_language
, g_net
, g_phys
,
468 ENet
, e_msg
, g_netmsg
, g_netmaster
,
472 charbuff
: packed array [0..15] of AnsiChar = (
473 ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '
476 function Translit (const S
: AnsiString): AnsiString;
481 for i
:= 1 to Length(Result
) do
484 #
$C9: Result
[i
] := 'Q';
485 #
$D6: Result
[i
] := 'W';
486 #
$D3: Result
[i
] := 'E';
487 #
$CA: Result
[i
] := 'R';
488 #
$C5: Result
[i
] := 'T';
489 #
$CD: Result
[i
] := 'Y';
490 #
$C3: Result
[i
] := 'U';
491 #
$D8: Result
[i
] := 'I';
492 #
$D9: Result
[i
] := 'O';
493 #
$C7: Result
[i
] := 'P';
494 #
$D5: Result
[i
] := '['; //Chr(219);
495 #
$DA: Result
[i
] := ']'; //Chr(221);
496 #
$D4: Result
[i
] := 'A';
497 #
$DB: Result
[i
] := 'S';
498 #
$C2: Result
[i
] := 'D';
499 #
$C0: Result
[i
] := 'F';
500 #
$CF: Result
[i
] := 'G';
501 #
$D0: Result
[i
] := 'H';
502 #
$CE: Result
[i
] := 'J';
503 #
$CB: Result
[i
] := 'K';
504 #
$C4: Result
[i
] := 'L';
505 #
$C6: Result
[i
] := ';'; //Chr(186);
506 #
$DD: Result
[i
] := #39; //Chr(222);
507 #
$DF: Result
[i
] := 'Z';
508 #
$D7: Result
[i
] := 'X';
509 #
$D1: Result
[i
] := 'C';
510 #
$CC: Result
[i
] := 'V';
511 #
$C8: Result
[i
] := 'B';
512 #
$D2: Result
[i
] := 'N';
513 #
$DC: Result
[i
] := 'M';
514 #
$C1: Result
[i
] := ','; //Chr(188);
515 #
$DE: Result
[i
] := '.'; //Chr(190);
521 function CheckCheat (ct
: TStrings_Locale
; eofs
: Integer=0): Boolean;
526 ls2
:= Translit(CheatRus
[ct
]);
527 if length(ls1
) = 0 then ls1
:= '~';
528 if length(ls2
) = 0 then ls2
:= '~';
530 (Copy(charbuff
, 17-Length(ls1
)-eofs
, Length(ls1
)) = ls1
) or
531 (Translit(Copy(charbuff
, 17-Length(ls1
)-eofs
, Length(ls1
))) = ls1
) or
532 (Copy(charbuff
, 17-Length(ls2
)-eofs
, Length(ls2
)) = ls2
) or
533 (Translit(Copy(charbuff
, 17-Length(ls2
)-eofs
, Length(ls2
))) = ls2
);
535 if ct = I_GAME_CHEAT_JETPACK then
537 e_WriteLog('ls1: ['+ls1+']', MSG_NOTIFY);
538 e_WriteLog('ls2: ['+ls2+']', MSG_NOTIFY);
539 e_WriteLog('bf0: ['+Copy(charbuff, 17-Length(ls1)-eofs, Length(ls1))+']', MSG_NOTIFY);
540 e_WriteLog('bf1: ['+Translit(Copy(charbuff, 17-Length(ls1)-eofs, Length(ls1)))+']', MSG_NOTIFY);
541 e_WriteLog('bf2: ['+Copy(charbuff, 17-Length(ls2)-eofs, Length(ls2))+']', MSG_NOTIFY);
542 e_WriteLog('bf3: ['+Translit(Copy(charbuff, 17-Length(ls2)-eofs, Length(ls2)))+']', MSG_NOTIFY);
558 if (not gGameOn) or (not gCheats) or ((gGameSettings.GameType <> GT_SINGLE) and
559 (gGameSettings.GameMode <> GM_COOP) and (not gDebugMode))
560 or g_Game_IsNet then Exit;
562 if not gGameOn
then exit
;
563 if not conIsCheatsEnabled
then exit
;
565 s
:= 'SOUND_GAME_RADIO';
568 if CheckCheat(I_GAME_CHEAT_GODMODE
) then
570 if gPlayer1
<> nil then gPlayer1
.GodMode
:= not gPlayer1
.GodMode
;
571 if gPlayer2
<> nil then gPlayer2
.GodMode
:= not gPlayer2
.GodMode
;
575 if CheckCheat(I_GAME_CHEAT_WEAPONS
) then
577 if gPlayer1
<> nil then gPlayer1
.AllRulez(False);
578 if gPlayer2
<> nil then gPlayer2
.AllRulez(False);
582 if CheckCheat(I_GAME_CHEAT_HEALTH
) then
584 if gPlayer1
<> nil then gPlayer1
.AllRulez(True);
585 if gPlayer2
<> nil then gPlayer2
.AllRulez(True);
589 if CheckCheat(I_GAME_CHEAT_DEATH
) then
591 if gPlayer1
<> nil then gPlayer1
.Damage(CHEAT_DAMAGE
, 0, 0, 0, HIT_TRAP
);
592 if gPlayer2
<> nil then gPlayer2
.Damage(CHEAT_DAMAGE
, 0, 0, 0, HIT_TRAP
);
593 s
:= 'SOUND_MONSTER_HAHA';
597 if CheckCheat(I_GAME_CHEAT_DOORS
) then
599 g_Triggers_OpenAll();
603 if CheckCheat(I_GAME_CHEAT_NEXTMAP
) then
605 if gTriggers
<> nil then
606 for a
:= 0 to High(gTriggers
) do
607 if gTriggers
[a
].TriggerType
= TRIGGER_EXIT
then
609 gExitByTrigger
:= True;
610 //g_Game_ExitLevel(gTriggers[a].Data.MapName);
611 g_Game_ExitLevel(gTriggers
[a
].tgcMap
);
617 s2
:= Copy(charbuff
, 15, 2);
618 if CheckCheat(I_GAME_CHEAT_CHANGEMAP
, 2) and (s2
[1] >= '0') and (s2
[1] <= '9') and (s2
[2] >= '0') and (s2
[2] <= '9') then
620 if g_Map_Exist(gGameSettings
.WAD
+ ':\MAP' + s2
) then
628 if CheckCheat(I_GAME_CHEAT_FLY
) then
634 if CheckCheat(I_GAME_CHEAT_JUMPS
) then
636 VEL_JUMP
:= 30-VEL_JUMP
;
640 if CheckCheat(I_GAME_CHEAT_SPEED
) then
642 MAX_RUNVEL
:= 32-MAX_RUNVEL
;
646 if CheckCheat(I_GAME_CHEAT_SUIT
) then
648 if gPlayer1
<> nil then gPlayer1
.GiveItem(ITEM_SUIT
);
649 if gPlayer2
<> nil then gPlayer2
.GiveItem(ITEM_SUIT
);
653 if CheckCheat(I_GAME_CHEAT_AIR
) then
655 if gPlayer1
<> nil then gPlayer1
.GiveItem(ITEM_OXYGEN
);
656 if gPlayer2
<> nil then gPlayer2
.GiveItem(ITEM_OXYGEN
);
660 if CheckCheat(I_GAME_CHEAT_BERSERK
) then
662 if gPlayer1
<> nil then gPlayer1
.GiveItem(ITEM_MEDKIT_BLACK
);
663 if gPlayer2
<> nil then gPlayer2
.GiveItem(ITEM_MEDKIT_BLACK
);
667 if CheckCheat(I_GAME_CHEAT_JETPACK
) then
669 if gPlayer1
<> nil then gPlayer1
.GiveItem(ITEM_JETPACK
);
670 if gPlayer2
<> nil then gPlayer2
.GiveItem(ITEM_JETPACK
);
674 if CheckCheat(I_GAME_CHEAT_NOCLIP
) then
676 if gPlayer1
<> nil then gPlayer1
.SwitchNoClip
;
677 if gPlayer2
<> nil then gPlayer2
.SwitchNoClip
;
681 if CheckCheat(I_GAME_CHEAT_NOTARGET
) then
683 if gPlayer1
<> nil then gPlayer1
.NoTarget
:= not gPlayer1
.NoTarget
;
684 if gPlayer2
<> nil then gPlayer2
.NoTarget
:= not gPlayer2
.NoTarget
;
688 if CheckCheat(I_GAME_CHEAT_NORELOAD
) then
690 if gPlayer1
<> nil then gPlayer1
.NoReload
:= not gPlayer1
.NoReload
;
691 if gPlayer2
<> nil then gPlayer2
.NoReload
:= not gPlayer2
.NoReload
;
694 if CheckCheat(I_GAME_CHEAT_AIMLINE
) then
696 gAimLine
:= not gAimLine
;
699 if CheckCheat(I_GAME_CHEAT_AUTOMAP
) then
701 gShowMap
:= not gShowMap
;
712 procedure KeyPress (K
: Word);
713 var Msg
: g_gui
.TMessage
;
718 if (g_ActiveWindow
<> nil) then
720 Msg
.Msg
:= WM_KEYDOWN
;
721 Msg
.WParam
:= VK_ESCAPE
;
722 g_ActiveWindow
.OnMessage(Msg
);
723 if (not g_Game_IsNet
) and (g_ActiveWindow
= nil) then g_Game_Pause(false); //Fn loves to do this
725 else if (gState
<> STATE_FOLD
) then
727 if gGameOn
or (gState
= STATE_INTERSINGLE
) or (gState
= STATE_INTERCUSTOM
) then
729 g_Game_InGameMenu(True);
731 else if (gExit
= 0) and (gState
<> STATE_SLIST
) then
733 if (gState
<> STATE_MENU
) then
735 if (NetMode
<> NET_NONE
) then
737 g_Game_StopAllSounds(True);
739 gState
:= STATE_MENU
;
743 g_GUI_ShowWindow('MainMenu');
744 g_Sound_PlayEx('MENU_OPEN');
749 IK_F2
, IK_F3
, IK_F4
, IK_F5
, IK_F6
, IK_F7
, IK_F10
:
750 begin // <F2> .. <F6> � <F12>
751 if gGameOn
and (not gConsoleShow
) and (not gChatShow
) then
753 while (g_ActiveWindow
<> nil) do g_GUI_HideWindow(False);
754 if (not g_Game_IsNet
) then g_Game_Pause(True);
756 IK_F2
: g_Menu_Show_SaveMenu();
757 IK_F3
: g_Menu_Show_LoadMenu();
758 IK_F4
: g_Menu_Show_GameSetGame();
759 IK_F5
: g_Menu_Show_OptionsVideo();
760 IK_F6
: g_Menu_Show_OptionsSound();
761 IK_F7
: g_Menu_Show_EndGameMenu();
762 IK_F10
: g_Menu_Show_QuitGameMenu();
769 gJustChatted
:= False;
770 if gConsoleShow
or gChatShow
then
772 g_Console_Control(K
);
774 else if (g_ActiveWindow
<> nil) then
776 Msg
.Msg
:= WM_KEYDOWN
;
778 g_ActiveWindow
.OnMessage(Msg
);
780 else if (gState
= STATE_MENU
) then
782 g_GUI_ShowWindow('MainMenu');
783 g_Sound_PlayEx('MENU_OPEN');
789 procedure KeyPress (K
: Word);
791 gJustChatted
:= False;
792 if gConsoleShow
or gChatShow
then
794 g_Console_Control(K
);
800 procedure CharPress (C
: AnsiChar);
802 var Msg
: g_gui
.TMessage
;
806 if gConsoleShow
or gChatShow
then
811 else if g_ActiveWindow
<> nil then
814 Msg
.WParam
:= Ord(C
);
815 g_ActiveWindow
.OnMessage(Msg
);
822 charbuff
[a
] := charbuff
[a
+ 1];
824 charbuff
[15] := upcase1251(C
);
831 // ////////////////////////////////////////////////////////////////////////// //
832 function gPause (): Boolean; inline; begin result
:= gPauseMain
or gPauseHolmes
; end;
834 procedure g_ResetDynlights ();
838 if not gwin_has_stencil
then begin g_dynLightCount
:= 0; exit
; end;
840 for idx
:= 0 to g_dynLightCount
-1 do
842 if g_dynLights
[idx
].exploCount
= -666 then
849 Inc(g_dynLights
[idx
].exploCount
);
850 if (g_dynLights
[idx
].exploCount
< 10) then
852 g_dynLights
[idx
].radius
:= g_dynLights
[idx
].exploRadius
+g_dynLights
[idx
].exploCount
*8;
853 g_dynLights
[idx
].a
:= 0.4+g_dynLights
[idx
].exploCount
/10;
854 if (g_dynLights
[idx
].a
> 0.8) then g_dynLights
[idx
].a
:= 0.8;
855 if lnum
<> idx
then g_dynLights
[lnum
] := g_dynLights
[idx
];
860 g_dynLightCount
:= lnum
;
863 procedure g_AddDynLight (x
, y
, radius
: Integer; r
, g
, b
, a
: Single);
865 if not gwin_has_stencil
then exit
;
866 if g_dynLightCount
= length(g_dynLights
) then SetLength(g_dynLights
, g_dynLightCount
+1024);
867 g_dynLights
[g_dynLightCount
].x
:= x
;
868 g_dynLights
[g_dynLightCount
].y
:= y
;
869 g_dynLights
[g_dynLightCount
].radius
:= radius
;
870 g_dynLights
[g_dynLightCount
].r
:= r
;
871 g_dynLights
[g_dynLightCount
].g
:= g
;
872 g_dynLights
[g_dynLightCount
].b
:= b
;
873 g_dynLights
[g_dynLightCount
].a
:= a
;
874 g_dynLights
[g_dynLightCount
].exploCount
:= -666;
875 Inc(g_dynLightCount
);
878 procedure g_DynLightExplosion (x
, y
, radius
: Integer; r
, g
, b
: Single);
880 if not gwin_has_stencil
then exit
;
881 if g_dynLightCount
= length(g_dynLights
) then SetLength(g_dynLights
, g_dynLightCount
+1024);
882 g_dynLights
[g_dynLightCount
].x
:= x
;
883 g_dynLights
[g_dynLightCount
].y
:= y
;
884 g_dynLights
[g_dynLightCount
].radius
:= 0;
885 g_dynLights
[g_dynLightCount
].exploRadius
:= radius
;
886 g_dynLights
[g_dynLightCount
].r
:= r
;
887 g_dynLights
[g_dynLightCount
].g
:= g
;
888 g_dynLights
[g_dynLightCount
].b
:= b
;
889 g_dynLights
[g_dynLightCount
].a
:= 0;
890 g_dynLights
[g_dynLightCount
].exploCount
:= 0;
891 Inc(g_dynLightCount
);
894 // ////////////////////////////////////////////////////////////////////////// //
895 function conIsCheatsEnabled (): Boolean; inline;
898 if g_Game_IsNet
then exit
;
899 if not gDebugMode
then
901 //if not gCheats then exit;
902 if not (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
]) then exit
;
903 if not (gGameSettings
.GameMode
in [GM_COOP
, GM_SINGLE
]) then exit
;
908 // ////////////////////////////////////////////////////////////////////////// //
910 TParamStrValue
= record
915 TParamStrValues
= Array of TParamStrValue
;
918 INTER_ACTION_TEXT
= 1;
919 INTER_ACTION_PIC
= 2;
920 INTER_ACTION_MUSIC
= 3;
925 DataLoaded
: Boolean = False;
927 MapList
: SSArray
= nil;
928 MapIndex
: Integer = -1;
929 InterReadyTime
: Integer = -1;
930 StatDate
: string = '';
945 function Compare(a
, b
: TPlayerStat
): Integer;
947 if a
.Spectator
then Result
:= 1
948 else if b
.Spectator
then Result
:= -1
949 else if a
.Frags
< b
.Frags
then Result
:= 1
950 else if a
.Frags
> b
.Frags
then Result
:= -1
951 else if a
.Deaths
< b
.Deaths
then Result
:= -1
952 else if a
.Deaths
> b
.Deaths
then Result
:= 1
953 else if a
.Kills
< b
.Kills
then Result
:= -1
957 procedure SortGameStat(var stat
: TPlayerStatArray
);
962 if stat
= nil then Exit
;
964 for I
:= High(stat
) downto Low(stat
) do
965 for J
:= Low(stat
) to High(stat
) - 1 do
966 if Compare(stat
[J
], stat
[J
+ 1]) = 1 then
969 stat
[J
] := stat
[J
+ 1];
974 // saves a shitty CSV containing the game stats passed to it
975 procedure SaveGameStat(Stat
: TEndCustomGameStat
; Path
: string);
978 dir
, fname
, map
, mode
, etime
: String;
982 dir
:= e_GetWriteableDir(StatsDirs
);
983 // stats are placed in stats/yy/mm/dd/*.csv
984 fname
:= e_CatPath(dir
, Path
);
985 ForceDirectories(fname
); // ensure yy/mm/dd exists within the stats dir
986 fname
:= e_CatPath(fname
, StatFilename
+ '.csv');
987 AssignFile(s
, fname
);
990 // line 1: stats ver, datetime, server name, map name, game mode, time limit, score limit, dmflags, game time, num players
991 if g_Game_IsNet
then fname
:= NetServerName
else fname
:= '';
992 map
:= g_ExtractWadNameNoPath(gMapInfo
.Map
) + ':/' + g_ExtractFileName(gMapInfo
.Map
);
993 mode
:= g_Game_ModeToText(Stat
.GameMode
);
994 etime
:= Format('%d:%.2d:%.2d', [
995 Stat
.GameTime
div 1000 div 3600,
996 (Stat
.GameTime
div 1000 div 60) mod 60,
997 Stat
.GameTime
div 1000 mod 60
999 WriteLn(s
, 'stats_ver,datetime,server,map,mode,timelimit,scorelimit,dmflags,time,num_players');
1000 WriteLn(s
, Format('%d,%s,%s,%s,%s,%u,%u,%u,%s,%d', [
1006 gGameSettings
.TimeLimit
,
1007 gGameSettings
.GoalLimit
,
1008 gGameSettings
.Options
,
1010 Length(Stat
.PlayerStat
)
1012 // line 2: game specific shit
1013 // if it's a team game: red score, blue score
1014 // if it's a coop game: monsters killed, monsters total, secrets found, secrets total
1015 // otherwise nothing
1016 if Stat
.GameMode
in [GM_TDM
, GM_CTF
] then
1018 Format('red_score,blue_score' + LineEnding
+ '%d,%d', [Stat
.TeamStat
[TEAM_RED
].Goals
, Stat
.TeamStat
[TEAM_BLUE
].Goals
]))
1019 else if Stat
.GameMode
in [GM_COOP
, GM_SINGLE
] then
1021 Format('mon_killed,mon_total,secrets_found,secrets_total' + LineEnding
+ '%d,%d,%d,%d',[gCoopMonstersKilled
, gTotalMonsters
, gCoopSecretsFound
, gSecretsCount
]));
1022 // lines 3-...: team, player name, frags, deaths
1023 WriteLn(s
, 'team,name,frags,deaths');
1024 for I
:= Low(Stat
.PlayerStat
) to High(Stat
.PlayerStat
) do
1025 with Stat
.PlayerStat
[I
] do
1026 WriteLn(s
, Format('%d,%s,%d,%d', [Team
, dquoteStr(Name
), Frags
, Deaths
]));
1028 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_WRITE
], [fname
]));
1031 g_Console_Add('could not create gamestats file "' + fname
+ '"');
1036 function g_Game_ModeToText(Mode
: Byte): string;
1040 GM_DM
: Result
:= _lc
[I_MENU_GAME_TYPE_DM
];
1041 GM_TDM
: Result
:= _lc
[I_MENU_GAME_TYPE_TDM
];
1042 GM_CTF
: Result
:= _lc
[I_MENU_GAME_TYPE_CTF
];
1043 GM_COOP
: Result
:= _lc
[I_MENU_GAME_TYPE_COOP
];
1044 GM_SINGLE
: Result
:= _lc
[I_MENU_GAME_TYPE_SINGLE
];
1048 function g_Game_TextToMode(Mode
: string): Byte;
1051 Mode
:= UpperCase(Mode
);
1052 if Mode
= _lc
[I_MENU_GAME_TYPE_DM
] then
1057 if Mode
= _lc
[I_MENU_GAME_TYPE_TDM
] then
1062 if Mode
= _lc
[I_MENU_GAME_TYPE_CTF
] then
1067 if Mode
= _lc
[I_MENU_GAME_TYPE_COOP
] then
1072 if Mode
= _lc
[I_MENU_GAME_TYPE_SINGLE
] then
1074 Result
:= GM_SINGLE
;
1079 function g_Game_IsNet(): Boolean;
1081 Result
:= (gGameSettings
.GameType
in [GT_SERVER
, GT_CLIENT
]);
1084 function g_Game_IsServer(): Boolean;
1086 Result
:= (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
, GT_SERVER
]);
1089 function g_Game_IsClient(): Boolean;
1091 Result
:= (gGameSettings
.GameType
= GT_CLIENT
);
1094 function g_Game_GetMegaWADInfo(WAD
: String): TMegaWADInfo
;
1101 Result
.name
:= ExtractFileName(WAD
);
1102 Result
.description
:= '';
1103 Result
.author
:= '';
1105 w
:= TWADFile
.Create();
1108 if not w
.GetResource('INTERSCRIPT', p
, len
) then
1114 cfg
:= TConfig
.CreateMem(p
, len
);
1115 Result
.name
:= cfg
.ReadStr('megawad', 'name', ExtractFileName(WAD
));
1116 Result
.description
:= cfg
.ReadStr('megawad', 'description', '');
1117 Result
.author
:= cfg
.ReadStr('megawad', 'author', '');
1118 Result
.pic
:= cfg
.ReadStr('megawad', 'pic', '');
1124 procedure g_Game_FreeWAD
;
1127 g_Sound_Delete('MUSIC_endmus');
1128 ZeroMemory(@MegaWAD
, SizeOf(MegaWAD
));
1129 gGameSettings
.WAD
:= '';
1132 procedure g_Game_LoadWAD(WAD
: string);
1141 gGameSettings
.WAD
:= WAD
;
1142 if not (gGameSettings
.GameMode
in [GM_COOP
, GM_SINGLE
]) then
1145 MegaWAD
.info
:= g_Game_GetMegaWADInfo(WAD
);
1147 w
:= TWADFile
.Create();
1150 if not w
.GetResource('INTERSCRIPT', p
, len
) then
1156 cfg
:= TConfig
.CreateMem(p
, len
);
1159 MegaWAD
.endpic
:= cfg
.ReadStr('megawad', 'endpic', '');
1160 if MegaWAD
.endpic
<> '' then
1161 EndPicPath
:= e_GetResourcePath(WadDirs
, MegaWAD
.endpic
, WAD
);
1163 MegaWAD
.endmus
:= cfg
.ReadStr('megawad', 'endmus', 'Standart.wad:D2DMUS\КОНЕЦ');
1164 if MegaWAD
.endmus
<> '' then
1166 s
:= e_GetResourcePath(WadDirs
, MegaWAD
.endmus
, WAD
);
1167 g_Sound_CreateWADEx('MUSIC_endmus', s
, True);
1175 {procedure start_trigger(t: string);
1179 function next_trigger(): Boolean;
1183 procedure DisableCheats();
1189 if gPlayer1
<> nil then gPlayer1
.GodMode
:= False;
1190 if gPlayer2
<> nil then gPlayer2
.GodMode
:= False;
1191 if gPlayer1
<> nil then gPlayer1
.NoTarget
:= False;
1192 if gPlayer2
<> nil then gPlayer2
.NoTarget
:= False;
1194 {$IF DEFINED(D2F_DEBUG)}
1195 if gPlayer1
<> nil then gPlayer1
.NoTarget
:= True;
1196 gAimLine
:= g_dbg_aimline_on
;
1200 procedure g_Game_ExecuteEvent(Name
: String);
1206 if gEvents
= nil then
1208 for a
:= 0 to High(gEvents
) do
1209 if gEvents
[a
].Name
= Name
then
1211 if gEvents
[a
].Command
<> '' then
1212 g_Console_Process(gEvents
[a
].Command
, True);
1217 function g_Game_DelayEvent(DEType
: Byte; Time
: LongWord; Num
: Integer = 0; Str
: String = ''): Integer;
1222 if gDelayedEvents
<> nil then
1223 for a
:= 0 to High(gDelayedEvents
) do
1224 if not gDelayedEvents
[a
].Pending
then
1231 SetLength(gDelayedEvents
, Length(gDelayedEvents
) + 1);
1232 n
:= High(gDelayedEvents
);
1234 gDelayedEvents
[n
].Pending
:= True;
1235 gDelayedEvents
[n
].DEType
:= DEType
;
1236 gDelayedEvents
[n
].DENum
:= Num
;
1237 gDelayedEvents
[n
].DEStr
:= Str
;
1238 if DEType
= DE_GLOBEVENT
then
1239 gDelayedEvents
[n
].Time
:= (GetTickCount64() {div 1000}) + Time
1241 gDelayedEvents
[n
].Time
:= gTime
+ Time
;
1245 procedure EndGame();
1251 if g_Game_IsNet
and g_Game_IsServer
then
1252 MH_SEND_GameEvent(NET_EV_MAPEND
, Byte(gMissionFailed
));
1255 gPauseMain
:= false;
1256 gPauseHolmes
:= false;
1259 g_Game_StopAllSounds(False);
1264 EndingGameCounter
:= 0;
1266 {$IFDEF ENABLE_MENU}
1267 g_ActiveWindow
:= nil;
1270 gLMSRespawn
:= LMS_RESPAWN_NONE
;
1271 gLMSRespawnTime
:= 0;
1274 EXIT_SIMPLE
: // Выход через меню или конец теста
1278 begin // Это был тест
1282 begin // Выход в главное меню
1283 {$IFDEF DISABLE_MENU}
1284 gState
:= STATE_MENU
; // ???
1286 gMusic
.SetByName('MUSIC_MENU');
1288 if gState
<> STATE_SLIST
then
1290 g_GUI_ShowWindow('MainMenu');
1291 gState
:= STATE_MENU
;
1295 // Обновляем список серверов
1296 slReturnPressed
:= True;
1297 if g_Net_Slist_Fetch(slCurrent
) then
1299 if slCurrent
= nil then
1300 slWaitStr
:= _lc
[I_NET_SLIST_NOSERVERS
];
1303 slWaitStr
:= _lc
[I_NET_SLIST_ERROR
];
1304 g_Serverlist_GenerateTable(slCurrent
, slTable
);
1307 g_Game_ExecuteEvent('ongameend');
1311 EXIT_RESTART
: // Начать уровень сначала
1313 if not g_Game_IsClient
then g_Game_Restart();
1316 EXIT_ENDLEVELCUSTOM
: // Закончился уровень в Своей игре
1318 // Статистика Своей игры:
1319 FileName
:= g_ExtractWadName(gMapInfo
.Map
);
1321 CustomStat
.GameTime
:= gTime
;
1322 CustomStat
.Map
:= ExtractFileName(FileName
)+':'+g_ExtractFileName(gMapInfo
.Map
); //ResName;
1323 CustomStat
.MapName
:= gMapInfo
.Name
;
1324 CustomStat
.GameMode
:= gGameSettings
.GameMode
;
1325 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
1326 CustomStat
.TeamStat
:= gTeamStat
;
1328 CustomStat
.PlayerStat
:= nil;
1330 // Статистика игроков:
1331 if gPlayers
<> nil then
1333 for a
:= 0 to High(gPlayers
) do
1334 if gPlayers
[a
] <> nil then
1336 SetLength(CustomStat
.PlayerStat
, Length(CustomStat
.PlayerStat
)+1);
1337 with CustomStat
.PlayerStat
[High(CustomStat
.PlayerStat
)] do
1340 Name
:= gPlayers
[a
].Name
;
1341 Frags
:= gPlayers
[a
].Frags
;
1342 Deaths
:= gPlayers
[a
].Death
;
1343 Kills
:= gPlayers
[a
].Kills
;
1344 Team
:= gPlayers
[a
].Team
;
1345 Color
:= gPlayers
[a
].Model
.Color
;
1346 Spectator
:= gPlayers
[a
].FSpectator
;
1350 SortGameStat(CustomStat
.PlayerStat
);
1352 if (gSaveStats
or gScreenshotStats
) and (Length(CustomStat
.PlayerStat
) > 1) then
1355 if g_Game_IsNet
then StatFilename
:= NetServerName
else StatFilename
:= 'local';
1356 StatDate
:= FormatDateTime('yymmdd_hhnnss', t
);
1357 StatFilename
:= StatFilename
+ '_' + CustomStat
.Map
+ '_' + g_Game_ModeToText(CustomStat
.GameMode
);
1358 StatFilename
:= sanitizeFilename(StatFilename
) + '_' + StatDate
;
1360 SaveGameStat(CustomStat
, FormatDateTime('yyyy"/"mm"/"dd', t
));
1363 StatShotDone
:= False;
1366 g_Game_ExecuteEvent('onmapend');
1367 if not g_Game_IsClient
then g_Player_ResetReady
;
1368 gInterReadyCount
:= 0;
1370 // Затухающий экран:
1371 EndingGameCounter
:= 255;
1372 gState
:= STATE_FOLD
;
1374 if gDefInterTime
< 0 then
1375 gInterEndTime
:= IfThen((gGameSettings
.GameType
= GT_SERVER
) and (gPlayer1
= nil), 15000, 25000)
1377 gInterEndTime
:= gDefInterTime
* 1000;
1380 EXIT_ENDLEVELSINGLE
: // Закончился уровень в Одиночной игре
1382 // Статистика Одиночной игры:
1383 SingleStat
.GameTime
:= gTime
;
1384 SingleStat
.TwoPlayers
:= gPlayer2
<> nil;
1385 SingleStat
.TotalSecrets
:= gSecretsCount
;
1386 // Статистика первого игрока:
1387 SingleStat
.PlayerStat
[0].Kills
:= gPlayer1
.MonsterKills
;
1388 SingleStat
.PlayerStat
[0].Secrets
:= gPlayer1
.Secrets
;
1389 // Статистика второго игрока (если есть):
1390 if SingleStat
.TwoPlayers
then
1392 SingleStat
.PlayerStat
[1].Kills
:= gPlayer2
.MonsterKills
;
1393 SingleStat
.PlayerStat
[1].Secrets
:= gPlayer2
.Secrets
;
1396 g_Game_ExecuteEvent('onmapend');
1399 if gNextMap
<> '' then
1401 gMusic
.SetByName('MUSIC_INTERMUS');
1403 gState
:= STATE_INTERSINGLE
;
1406 g_Game_ExecuteEvent('oninter');
1408 else // Больше нет карт
1410 // Затухающий экран:
1411 EndingGameCounter
:= 255;
1412 gState
:= STATE_FOLD
;
1417 // Окончание обработано:
1418 if gExit
<> EXIT_QUIT
then
1422 procedure g_Game_Init();
1426 gTempDelete
:= False;
1428 sfsGCDisable(); // temporary disable removing of temporary volumes
1431 g_Game_ClearLoading();
1432 g_Game_SetLoadingText(Format('Doom 2D: Forever %s', [GAME_VERSION
]), 0, False);
1433 g_Game_SetLoadingText('', 0, False);
1435 // g_Game_SetLoadingText(_lc[I_LOAD_MODELS], 0, False);
1438 gPauseMain
:= false;
1439 gPauseHolmes
:= false;
1442 {e_MouseInfo.Accel := 1.0;}
1444 g_Game_SetLoadingText(_lc
[I_LOAD_GAME_DATA
], 0, False);
1447 g_Game_SetLoadingText(_lc
[I_LOAD_MUSIC
], 0, False);
1448 g_Sound_CreateWADEx('MUSIC_INTERMUS', GameWAD
+':MUSIC\INTERMUS', True);
1449 g_Sound_CreateWADEx('MUSIC_MENU', GameWAD
+':MUSIC\MENU', True);
1450 g_Sound_CreateWADEx('MUSIC_ROUNDMUS', GameWAD
+':MUSIC\ROUNDMUS', True, True);
1451 g_Sound_CreateWADEx('MUSIC_STDENDMUS', GameWAD
+':MUSIC\ENDMUS', True);
1453 gMusic
:= TMusic
.Create();
1454 gMusic
.SetByName('MUSIC_MENU');
1457 gGameSettings
.WarmupTime
:= 30;
1459 gState
:= STATE_MENU
;
1461 SetLength(gEvents
, 6);
1462 gEvents
[0].Name
:= 'ongamestart';
1463 gEvents
[1].Name
:= 'ongameend';
1464 gEvents
[2].Name
:= 'onmapstart';
1465 gEvents
[3].Name
:= 'onmapend';
1466 gEvents
[4].Name
:= 'oninter';
1467 gEvents
[5].Name
:= 'onwadend';
1469 sfsGCEnable(); // enable releasing unused volumes
1473 procedure g_Game_Free(freeTextures
: Boolean=true);
1475 if NetMode
= NET_CLIENT
then g_Net_Disconnect();
1476 if NetMode
= NET_SERVER
then g_Net_Host_Die();
1478 g_Map_Free(freeTextures
);
1480 g_Player_RemoveAllCorpses();
1482 gGameSettings
.GameType
:= GT_NONE
;
1483 if gGameSettings
.GameMode
= GM_SINGLE
then
1484 gGameSettings
.GameMode
:= GM_DM
;
1485 gSwitchGameMode
:= gGameSettings
.GameMode
;
1488 gExitByTrigger
:= False;
1491 function IsActivePlayer(p
: TPlayer
): Boolean;
1496 Result
:= (not p
.FDummy
) and (not p
.FSpectator
);
1499 function GetActivePlayerID_Next(Skip
: Integer = -1): Integer;
1505 if gPlayers
= nil then
1509 for a
:= Low(gPlayers
) to High(gPlayers
) do
1510 if IsActivePlayer(gPlayers
[a
]) then
1512 SetLength(ids
, Length(ids
) + 1);
1513 ids
[High(ids
)] := gPlayers
[a
].UID
;
1514 if gPlayers
[a
].UID
= Skip
then
1517 if Length(ids
) = 0 then
1522 Result
:= ids
[(idx
+ 1) mod Length(ids
)];
1525 function GetActivePlayerID_Prev(Skip
: Integer = -1): Integer;
1531 if gPlayers
= nil then
1535 for a
:= Low(gPlayers
) to High(gPlayers
) do
1536 if IsActivePlayer(gPlayers
[a
]) then
1538 SetLength(ids
, Length(ids
) + 1);
1539 ids
[High(ids
)] := gPlayers
[a
].UID
;
1540 if gPlayers
[a
].UID
= Skip
then
1543 if Length(ids
) = 0 then
1546 Result
:= ids
[Length(ids
) - 1]
1548 Result
:= ids
[(Length(ids
) - 1 + idx
) mod Length(ids
)];
1551 function GetActivePlayerID_Random(Skip
: Integer = -1): Integer;
1557 if gPlayers
= nil then
1561 for a
:= Low(gPlayers
) to High(gPlayers
) do
1562 if IsActivePlayer(gPlayers
[a
]) then
1564 SetLength(ids
, Length(ids
) + 1);
1565 ids
[High(ids
)] := gPlayers
[a
].UID
;
1566 if gPlayers
[a
].UID
= Skip
then
1569 if Length(ids
) = 0 then
1571 if Length(ids
) = 1 then
1576 Result
:= ids
[Random(Length(ids
))];
1578 while (idx
<> -1) and (Result
= Skip
) and (a
> 0) do
1580 Result
:= ids
[Random(Length(ids
))];
1585 function GetRandomSpectMode(Current
: Byte): Byte;
1592 0: Result
:= SPECT_STATS
;
1593 1: Result
:= SPECT_MAPVIEW
;
1594 2: Result
:= SPECT_MAPVIEW
;
1595 3: Result
:= SPECT_PLAYERS
;
1596 4: Result
:= SPECT_PLAYERS
;
1597 5: Result
:= SPECT_PLAYERS
;
1598 6: Result
:= SPECT_PLAYERS
;
1600 if (Current
in [SPECT_STATS
, SPECT_MAPVIEW
]) and (Current
= Result
) then
1604 procedure ProcessPlayerControls (plr
: TPlayer
; p
: Integer; var MoveButton
: Byte);
1610 if (plr
= nil) then exit
;
1611 if (p
= 2) then time
:= 1000 else time
:= 1;
1612 strafeDir
:= MoveButton
shr 4;
1613 MoveButton
:= MoveButton
and $0F;
1615 if gPlayerAction
[p
, ACTION_MOVELEFT
] and (not gPlayerAction
[p
, ACTION_MOVERIGHT
]) then
1616 MoveButton
:= 1 // Нажата только "Влево"
1617 else if (not gPlayerAction
[p
, ACTION_MOVELEFT
]) and gPlayerAction
[p
, ACTION_MOVERIGHT
] then
1618 MoveButton
:= 2 // Нажата только "Вправо"
1619 else if (not gPlayerAction
[p
, ACTION_MOVELEFT
]) and (not gPlayerAction
[p
, ACTION_MOVERIGHT
]) then
1620 MoveButton
:= 0; // Не нажаты ни "Влево", ни "Вправо"
1622 // Сейчас или раньше были нажаты "Влево"/"Вправо" => передаем игроку:
1623 if MoveButton
= 1 then
1624 plr
.PressKey(KEY_LEFT
, time
)
1625 else if MoveButton
= 2 then
1626 plr
.PressKey(KEY_RIGHT
, time
);
1628 // if we have "strafe" key, turn off old strafe mechanics
1629 if gPlayerAction
[p
, ACTION_STRAFE
] then
1631 // new strafe mechanics
1632 if (strafeDir
= 0) then
1633 strafeDir
:= MoveButton
; // start strafing
1634 // now set direction according to strafe (reversed)
1635 if (strafeDir
= 2) then
1636 plr
.SetDirection(TDirection
.D_LEFT
)
1637 else if (strafeDir
= 1) then
1638 plr
.SetDirection(TDirection
.D_RIGHT
)
1642 strafeDir
:= 0; // not strafing anymore
1643 // Раньше была нажата "Вправо", а сейчас "Влево" => бежим вправо, смотрим влево:
1644 if (MoveButton
= 2) and gPlayerAction
[p
, ACTION_MOVELEFT
] then
1645 plr
.SetDirection(TDirection
.D_LEFT
)
1646 // Раньше была нажата "Влево", а сейчас "Вправо" => бежим влево, смотрим вправо:
1647 else if (MoveButton
= 1) and gPlayerAction
[p
, ACTION_MOVERIGHT
] then
1648 plr
.SetDirection(TDirection
.D_RIGHT
)
1649 // Что-то было нажато и не изменилось => куда бежим, туда и смотрим:
1650 else if MoveButton
<> 0 then
1651 plr
.SetDirection(TDirection(MoveButton
-1))
1654 // fix movebutton state
1655 MoveButton
:= MoveButton
or (strafeDir
shl 4);
1657 // Остальные клавиши:
1658 if gPlayerAction
[p
, ACTION_JUMP
] then plr
.PressKey(KEY_JUMP
, time
);
1659 if gPlayerAction
[p
, ACTION_LOOKUP
] then plr
.PressKey(KEY_UP
, time
);
1660 if gPlayerAction
[p
, ACTION_LOOKDOWN
] then plr
.PressKey(KEY_DOWN
, time
);
1661 if gPlayerAction
[p
, ACTION_ATTACK
] then plr
.PressKey(KEY_FIRE
);
1662 if gPlayerAction
[p
, ACTION_WEAPNEXT
] then plr
.PressKey(KEY_NEXTWEAPON
);
1663 if gPlayerAction
[p
, ACTION_WEAPPREV
] then plr
.PressKey(KEY_PREVWEAPON
);
1664 if gPlayerAction
[p
, ACTION_ACTIVATE
] then plr
.PressKey(KEY_OPEN
);
1666 gPlayerAction
[p
, ACTION_WEAPNEXT
] := False; // HACK, remove after readyweaon&pendinweapon implementation
1667 gPlayerAction
[p
, ACTION_WEAPPREV
] := False; // HACK, remove after readyweaon&pendinweapon implementation
1669 for i
:= WP_FIRST
to WP_LAST
do
1671 if gSelectWeapon
[p
, i
] then
1673 plr
.QueueWeaponSwitch(i
); // all choices are passed there, and god will take the best
1674 gSelectWeapon
[p
, i
] := False
1678 {$IFDEF ENABLE_MENU}
1679 // HACK: add dynlight here
1680 if gwin_k8_enable_light_experiments
then
1682 if e_KeyPressed(IK_F8
) and gGameOn
and (not gConsoleShow
) and (g_ActiveWindow
= nil) then
1684 g_playerLight
:= true;
1686 if e_KeyPressed(IK_F9
) and gGameOn
and (not gConsoleShow
) and (g_ActiveWindow
= nil) then
1688 g_playerLight
:= false;
1692 if gwin_has_stencil
and g_playerLight
then g_AddDynLight(plr
.GameX
+32, plr
.GameY
+40, 128, 1, 1, 0, 0.6);
1696 // HACK: don't have a "key was pressed" function
1697 procedure InterReady();
1699 if InterReadyTime
> gTime
then Exit
;
1700 InterReadyTime
:= gTime
+ 3000;
1701 MC_SEND_CheatRequest(NET_CHEAT_READY
);
1704 procedure g_Game_PreUpdate();
1706 // these are in separate PreUpdate functions because they can interact during Update()
1707 // and are synced over the net
1708 // we don't care that much about corpses and gibs
1709 g_Player_PreUpdate();
1710 g_Monsters_PreUpdate();
1711 g_Items_PreUpdate();
1712 g_Weapon_PreUpdate();
1715 procedure g_Game_Update();
1717 {$IFDEF ENABLE_MENU}
1718 Msg
: g_gui
.TMessage
;
1725 function sendMonsPos (mon
: TMonster
): Boolean;
1727 result
:= false; // don't stop
1728 // this will also reset "need-send" flag
1729 if mon
.gncNeedSend
then
1731 MH_SEND_MonsterPos(mon
.UID
);
1733 else if (mon
.MonsterType
= MONSTER_BARREL
) then
1735 if (mon
.GameVelX
<> 0) or (mon
.GameVelY
<> 0) then MH_SEND_MonsterPos(mon
.UID
);
1737 else if (mon
.MonsterState
<> MONSTATE_SLEEP
) then
1739 if (mon
.MonsterState
<> MONSTATE_DEAD
) or (mon
.GameVelX
<> 0) or (mon
.GameVelY
<> 0) then MH_SEND_MonsterPos(mon
.UID
);
1743 function sendMonsPosUnexpected (mon
: TMonster
): Boolean;
1745 result
:= false; // don't stop
1746 // this will also reset "need-send" flag
1747 if mon
.gncNeedSend
then MH_SEND_MonsterPos(mon
.UID
);
1751 reliableUpdate
: Boolean;
1756 // Пора выключать игру:
1757 if gExit
= EXIT_QUIT
then
1759 // Игра закончилась - обрабатываем:
1763 if gExit
= EXIT_QUIT
then
1767 // Читаем клавиатуру и джойстик, если окно активно
1768 // no need to, as we'll do it in event handler
1770 // Обновляем консоль (движение и сообщения):
1773 if (NetMode
= NET_NONE
) and (g_Game_IsNet
) and (gGameOn
or (gState
in [STATE_FOLD
, STATE_INTERCUSTOM
])) then
1775 gExit
:= EXIT_SIMPLE
;
1780 // process master server communications
1781 g_Net_Slist_Pulse();
1784 STATE_INTERSINGLE
, // Статистка после прохождения уровня в Одиночной игре
1785 STATE_INTERCUSTOM
, // Статистка после прохождения уровня в Своей игре
1786 STATE_INTERTEXT
, // Текст между уровнями
1787 STATE_INTERPIC
: // Картинка между уровнями
1789 if g_Game_IsNet
and g_Game_IsServer
then
1791 gInterTime
:= gInterTime
+ GAME_TICK
;
1792 a
:= Min((gInterEndTime
- gInterTime
) div 1000 + 1, 255);
1793 if a
<> gServInterTime
then
1795 gServInterTime
:= a
;
1796 MH_SEND_TimeSync(gServInterTime
);
1800 if (not g_Game_IsClient
) and
1804 e_KeyPressed(IK_RETURN
) or e_KeyPressed(IK_KPRETURN
) or e_KeyPressed(IK_SPACE
) or
1805 e_KeyPressed(VK_FIRE
) or e_KeyPressed(VK_OPEN
) or
1806 e_KeyPressed(JOY0_ATTACK
) or e_KeyPressed(JOY1_ATTACK
) or
1807 e_KeyPressed(JOY2_ATTACK
) or e_KeyPressed(JOY3_ATTACK
)
1809 and (not gJustChatted
) and (not gConsoleShow
) and (not gChatShow
)
1810 {$IFDEF ENABLE_MENU}
1811 and (g_ActiveWindow
= nil)
1814 or (g_Game_IsNet
and ((gInterTime
> gInterEndTime
) or ((gInterReadyCount
>= NetClientCount
) and (NetClientCount
> 0))))
1817 begin // Нажали <Enter>/<Пробел> или прошло достаточно времени:
1818 g_Game_StopAllSounds(True);
1820 if gMapOnce
then // Это был тест
1821 gExit
:= EXIT_SIMPLE
1823 if gNextMap
<> '' then // Переходим на следующую карту
1824 g_Game_ChangeMap(gNextMap
)
1825 else // Следующей карты нет
1827 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
] then
1829 // Выход в главное меню:
1831 {$IFDEF ENABLE_MENU}
1832 g_GUI_ShowWindow('MainMenu');
1833 gMusic
.SetByName('MUSIC_MENU');
1836 gState
:= STATE_MENU
;
1839 // Финальная картинка:
1840 g_Game_ExecuteEvent('onwadend');
1842 if not gMusic
.SetByName('MUSIC_endmus') then
1843 gMusic
.SetByName('MUSIC_STDENDMUS');
1845 gState
:= STATE_ENDPIC
;
1847 g_Game_ExecuteEvent('ongameend');
1852 else if g_Game_IsClient
and
1855 e_KeyPressed(IK_RETURN
) or e_KeyPressed(IK_KPRETURN
) or e_KeyPressed(IK_SPACE
) or
1856 e_KeyPressed(VK_FIRE
) or e_KeyPressed(VK_OPEN
) or
1857 e_KeyPressed(JOY0_ATTACK
) or e_KeyPressed(JOY1_ATTACK
) or
1858 e_KeyPressed(JOY2_ATTACK
) or e_KeyPressed(JOY3_ATTACK
)
1860 and (not gJustChatted
) and (not gConsoleShow
) and (not gChatShow
)
1861 {$IFDEF ENABLE_MENU}
1862 and (g_ActiveWindow
= nil)
1871 if gState
= STATE_INTERTEXT
then
1872 if InterText
.counter
> 0 then
1873 InterText
.counter
:= InterText
.counter
- 1;
1876 STATE_FOLD
: // Затухание экрана
1878 if EndingGameCounter
= 0 then
1880 // Закончился уровень в Своей игре:
1881 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
1883 InterReadyTime
:= -1;
1884 if gLastMap
and (gGameSettings
.GameMode
= GM_COOP
) then
1886 g_Game_ExecuteEvent('onwadend');
1887 if not gMusic
.SetByName('MUSIC_endmus') then
1888 gMusic
.SetByName('MUSIC_STDENDMUS');
1891 gMusic
.SetByName('MUSIC_ROUNDMUS');
1894 gState
:= STATE_INTERCUSTOM
;
1897 else // Закончилась последняя карта в Одиночной игре
1899 gMusic
.SetByName('MUSIC_INTERMUS');
1901 gState
:= STATE_INTERSINGLE
;
1904 g_Game_ExecuteEvent('oninter');
1907 DecMin(EndingGameCounter
, 6, 0);
1910 STATE_ENDPIC
: // Картинка окончания мегаВада
1912 if gMapOnce
then // Это был тест
1914 gExit
:= EXIT_SIMPLE
;
1920 g_Serverlist_Control(slCurrent
, slTable
);
1923 // Статистика по Tab:
1925 IsDrawStat
:= (not gConsoleShow
) and (not gChatShow
) and (gGameSettings
.GameType
<> GT_SINGLE
) and g_Console_Action(ACTION_SCORES
);
1928 if gGameOn
and not gPause
and (gState
<> STATE_FOLD
) then
1930 // Время += 28 миллисекунд:
1931 gTime
:= gTime
+ GAME_TICK
;
1933 // Сообщение посередине экрана:
1934 if MessageTime
= 0 then
1936 if MessageTime
> 0 then
1937 MessageTime
:= MessageTime
- 1;
1939 if (g_Game_IsServer
) then
1941 // Был задан лимит времени:
1942 if (gGameSettings
.TimeLimit
> 0) then
1943 if (gTime
- gGameStartTime
) div 1000 >= gGameSettings
.TimeLimit
then
1944 begin // Он прошел => конец уровня
1949 // Надо респавнить игроков в LMS:
1950 if (gLMSRespawn
> LMS_RESPAWN_NONE
) and (gLMSRespawnTime
< gTime
) then
1951 g_Game_RestartRound(gLMSSoftSpawn
);
1953 // Проверим результат голосования, если время прошло
1954 if gVoteInProgress
and (gVoteTimer
< gTime
) then
1956 else if gVotePassed
and (gVoteCmdTimer
< gTime
) then
1958 g_Console_Process(gVoteCommand
);
1960 gVotePassed
:= False;
1963 // Замеряем время захвата флагов
1964 if gFlags
[FLAG_RED
].State
= FLAG_STATE_CAPTURED
then
1965 gFlags
[FLAG_RED
].CaptureTime
:= gFlags
[FLAG_RED
].CaptureTime
+ GAME_TICK
;
1966 if gFlags
[FLAG_BLUE
].State
= FLAG_STATE_CAPTURED
then
1967 gFlags
[FLAG_BLUE
].CaptureTime
:= gFlags
[FLAG_BLUE
].CaptureTime
+ GAME_TICK
;
1969 // Был задан лимит побед:
1970 if (gGameSettings
.GoalLimit
> 0) then
1974 if gGameSettings
.GameMode
= GM_DM
then
1975 begin // В DM ищем игрока с max фрагами
1976 for i
:= 0 to High(gPlayers
) do
1977 if gPlayers
[i
] <> nil then
1978 if gPlayers
[i
].Frags
> b
then
1979 b
:= gPlayers
[i
].Frags
;
1982 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
1983 begin // В CTF/TDM выбираем команду с наибольшим счетом
1984 b
:= Max(gTeamStat
[TEAM_RED
].Goals
, gTeamStat
[TEAM_BLUE
].Goals
);
1987 // Лимит побед набран => конец уровня:
1988 if b
>= gGameSettings
.GoalLimit
then
1995 // Обрабатываем клавиши игроков:
1996 if gPlayer1
<> nil then gPlayer1
.ReleaseKeys();
1997 if gPlayer2
<> nil then gPlayer2
.ReleaseKeys();
1998 {$IFDEF DISABLE_MENU}
1999 if (not gConsoleShow
) and (not gChatShow
) then
2001 if (not gConsoleShow
) and (not gChatShow
) and (g_ActiveWindow
= nil) then
2004 ProcessPlayerControls(gPlayer1
, 0, P1MoveButton
);
2005 ProcessPlayerControls(gPlayer2
, 1, P2MoveButton
);
2006 end // if not console
2009 if g_Game_IsNet
and (gPlayer1
<> nil) then gPlayer1
.PressKey(KEY_CHAT
, 10000);
2011 // process weapon switch queue
2015 if (gPlayer1
= nil) and (gPlayer2
= nil)
2016 and (not gConsoleShow
) and (not gChatShow
)
2017 {$IFDEF ENABLE_MENU}
2018 and (g_ActiveWindow
= nil)
2022 if not gSpectKeyPress
then
2024 if gPlayerAction
[0, ACTION_JUMP
] and (not gSpectAuto
) then
2026 // switch spect mode
2028 SPECT_NONE
: ; // not spectator
2030 SPECT_MAPVIEW
: Inc(gSpectMode
);
2031 SPECT_PLAYERS
: gSpectMode
:= SPECT_STATS
; // reset to 1
2033 gSpectKeyPress
:= True;
2035 if (gSpectMode
= SPECT_MAPVIEW
)
2036 and (not gSpectAuto
) then
2038 if gPlayerAction
[0, ACTION_MOVELEFT
] then
2039 gSpectX
:= Max(gSpectX
- gSpectStep
, 0);
2040 if gPlayerAction
[0, ACTION_MOVERIGHT
] then
2041 gSpectX
:= Min(gSpectX
+ gSpectStep
, gMapInfo
.Width
- gScreenWidth
);
2042 if gPlayerAction
[0, ACTION_LOOKUP
] then
2043 gSpectY
:= Max(gSpectY
- gSpectStep
, 0);
2044 if gPlayerAction
[0, ACTION_LOOKDOWN
] then
2045 gSpectY
:= Min(gSpectY
+ gSpectStep
, gMapInfo
.Height
- gScreenHeight
);
2046 if gPlayerAction
[0, ACTION_WEAPPREV
] then
2049 if gSpectStep
> 4 then gSpectStep
:= gSpectStep
shr 1;
2050 gSpectKeyPress
:= True;
2052 if gPlayerAction
[0, ACTION_WEAPNEXT
] then
2055 if gSpectStep
< 64 then gSpectStep
:= gSpectStep
shl 1;
2056 gSpectKeyPress
:= True;
2059 if (gSpectMode
= SPECT_PLAYERS
)
2060 and (not gSpectAuto
) then
2062 if gPlayerAction
[0, ACTION_LOOKUP
] then
2065 gSpectViewTwo
:= True;
2066 gSpectKeyPress
:= True;
2068 if gPlayerAction
[0, ACTION_LOOKDOWN
] then
2070 // remove second view
2071 gSpectViewTwo
:= False;
2072 gSpectKeyPress
:= True;
2074 if gPlayerAction
[0, ACTION_MOVELEFT
] then
2076 // prev player (view 1)
2077 gSpectPID1
:= GetActivePlayerID_Prev(gSpectPID1
);
2078 gSpectKeyPress
:= True;
2080 if gPlayerAction
[0, ACTION_MOVERIGHT
] then
2082 // next player (view 1)
2083 gSpectPID1
:= GetActivePlayerID_Next(gSpectPID1
);
2084 gSpectKeyPress
:= True;
2086 if gPlayerAction
[0, ACTION_WEAPPREV
] then
2088 // prev player (view 2)
2089 gSpectPID2
:= GetActivePlayerID_Prev(gSpectPID2
);
2090 gSpectKeyPress
:= True;
2092 if gPlayerAction
[0, ACTION_WEAPNEXT
] then
2094 // next player (view 2)
2095 gSpectPID2
:= GetActivePlayerID_Next(gSpectPID2
);
2096 gSpectKeyPress
:= True;
2099 if gPlayerAction
[0, ACTION_ATTACK
] then
2101 if (gSpectMode
= SPECT_STATS
) and (not gSpectAuto
) then
2104 gSpectAutoNext
:= 0;
2105 gSpectViewTwo
:= False;
2106 gSpectKeyPress
:= True;
2111 gSpectMode
:= SPECT_STATS
;
2112 gSpectAuto
:= False;
2113 gSpectKeyPress
:= True;
2118 if (not gPlayerAction
[0, ACTION_JUMP
]) and
2119 (not gPlayerAction
[0, ACTION_ATTACK
]) and
2120 (not gPlayerAction
[0, ACTION_MOVELEFT
]) and
2121 (not gPlayerAction
[0, ACTION_MOVERIGHT
]) and
2122 (not gPlayerAction
[0, ACTION_LOOKUP
]) and
2123 (not gPlayerAction
[0, ACTION_LOOKDOWN
]) and
2124 (not gPlayerAction
[0, ACTION_WEAPPREV
]) and
2125 (not gPlayerAction
[0, ACTION_WEAPNEXT
]) then
2126 gSpectKeyPress
:= False;
2130 if gSpectMode
= SPECT_MAPVIEW
then
2132 i
:= Min(Max(gSpectX
+ gSpectAutoStepX
, 0), gMapInfo
.Width
- gScreenWidth
);
2134 gSpectAutoNext
:= gTime
2137 i
:= Min(Max(gSpectY
+ gSpectAutoStepY
, 0), gMapInfo
.Height
- gScreenHeight
);
2139 gSpectAutoNext
:= gTime
2143 if gSpectAutoNext
<= gTime
then
2145 if gSpectAutoNext
> 0 then
2147 gSpectMode
:= GetRandomSpectMode(gSpectMode
);
2151 gSpectX
:= Random(gMapInfo
.Width
- gScreenWidth
);
2152 gSpectY
:= Random(gMapInfo
.Height
- gScreenHeight
);
2153 gSpectAutoStepX
:= Random(9) - 4;
2154 gSpectAutoStepY
:= Random(9) - 4;
2155 if ((gSpectX
< 800) and (gSpectAutoStepX
< 0)) or
2156 ((gSpectX
> gMapInfo
.Width
- gScreenWidth
- 800) and (gSpectAutoStepX
> 0)) then
2157 gSpectAutoStepX
:= gSpectAutoStepX
* -1;
2158 if ((gSpectY
< 800) and (gSpectAutoStepY
< 0)) or
2159 ((gSpectY
> gMapInfo
.Height
- gScreenHeight
- 800) and (gSpectAutoStepY
> 0)) then
2160 gSpectAutoStepY
:= gSpectAutoStepY
* -1;
2164 gSpectPID1
:= GetActivePlayerID_Random(gSpectPID1
);
2169 SPECT_STATS
: gSpectAutoNext
:= gTime
+ (Random(3) + 5) * 1000;
2170 SPECT_MAPVIEW
: gSpectAutoNext
:= gTime
+ (Random(4) + 7) * 1000;
2171 SPECT_PLAYERS
: gSpectAutoNext
:= gTime
+ (Random(7) + 8) * 1000;
2177 // Обновляем все остальное:
2180 g_Triggers_Update();
2182 g_Monsters_Update();
2186 g_Player_UpdateAll();
2187 {$IFDEF ENABLE_GIBS}
2190 g_Player_UpdatePhysicalObjects();
2191 {$IFDEF ENABLE_SHELLS}
2195 // server: send newly spawned monsters unconditionally
2196 if (gGameSettings
.GameType
= GT_SERVER
) then
2198 if (Length(gMonstersSpawned
) > 0) then
2200 for I
:= 0 to High(gMonstersSpawned
) do MH_SEND_MonsterSpawn(gMonstersSpawned
[I
]);
2201 SetLength(gMonstersSpawned
, 0);
2205 if (gSoundTriggerTime
> 8) then
2207 g_Game_UpdateTriggerSounds();
2208 gSoundTriggerTime
:= 0;
2212 Inc(gSoundTriggerTime
);
2215 if (NetMode
= NET_SERVER
) then
2217 Inc(NetTimeToUpdate
);
2218 Inc(NetTimeToReliable
);
2220 // send monster updates
2221 if (NetTimeToReliable
>= NetRelupdRate
) or (NetTimeToUpdate
>= NetUpdateRate
) then
2223 // send all monsters (periodic sync)
2224 reliableUpdate
:= (NetTimeToReliable
>= NetRelupdRate
);
2226 for I
:= 0 to High(gPlayers
) do
2228 if (gPlayers
[I
] <> nil) then MH_SEND_PlayerPos(reliableUpdate
, gPlayers
[I
].UID
);
2231 g_Mons_ForEach(sendMonsPos
);
2233 if reliableUpdate
then
2235 NetTimeToReliable
:= 0;
2236 NetTimeToUpdate
:= NetUpdateRate
;
2240 NetTimeToUpdate
:= 0;
2245 // send only mosters with some unexpected changes
2246 g_Mons_ForEach(sendMonsPosUnexpected
);
2249 // send unexpected platform changes
2250 g_Map_NetSendInterestingPanels();
2252 g_Net_Slist_ServerUpdate();
2254 if NetUseMaster then
2256 if (gTime >= NetTimeToMaster) or g_Net_Slist_IsConnectionInProgress then
2258 if (not g_Net_Slist_IsConnectionActive) then g_Net_Slist_Connect(false); // non-blocking connection to the master
2260 NetTimeToMaster := gTime + NetMasterRate;
2265 else if (NetMode
= NET_CLIENT
) then
2267 MC_SEND_PlayerPos();
2269 end; // if gameOn ...
2271 // Активно окно интерфейса - передаем клавиши ему:
2272 {$IFDEF ENABLE_MENU}
2273 if g_ActiveWindow
<> nil then
2275 w
:= e_GetFirstKeyPressed();
2277 if (w
<> IK_INVALID
) then
2279 Msg
.Msg
:= MESSAGE_DIKEY
;
2281 g_ActiveWindow
.OnMessage(Msg
);
2284 // Если оно от этого не закрылось, то обновляем:
2285 if g_ActiveWindow
<> nil then
2286 g_ActiveWindow
.Update();
2288 // Нужно сменить разрешение:
2289 if gResolutionChange
then
2292 e_WriteLog('Changing resolution', TMsgType
.Notify
);
2295 gResolutionChange
:= False;
2296 g_ActiveWindow
:= nil;
2299 // Нужно сменить язык:
2300 if gLanguageChange
then
2302 //e_WriteLog('Read language file', MSG_NOTIFY);
2303 //g_Language_Load(DataDir + gLanguage + '.txt');
2304 g_Language_Set(gLanguage
);
2306 gLanguageChange
:= False;
2310 // Горячая клавиша для вызова меню выхода из игры (F10):
2311 if e_KeyPressed(IK_F10
) and
2313 (not gConsoleShow
) and
2314 (g_ActiveWindow
= nil) then
2320 Time
:= GetTickCount64() {div 1000};
2322 // Обработка отложенных событий:
2323 if gDelayedEvents
<> nil then
2324 for a
:= 0 to High(gDelayedEvents
) do
2325 if gDelayedEvents
[a
].Pending
and
2327 ((gDelayedEvents
[a
].DEType
= DE_GLOBEVENT
) and (gDelayedEvents
[a
].Time
<= Time
)) or
2328 ((gDelayedEvents
[a
].DEType
> DE_GLOBEVENT
) and (gDelayedEvents
[a
].Time
<= gTime
))
2331 case gDelayedEvents
[a
].DEType
of
2333 g_Game_ExecuteEvent(gDelayedEvents
[a
].DEStr
);
2336 g_Game_Announce_GoodShot(gDelayedEvents
[a
].DENum
);
2340 g_Game_Announce_KillCombo(gDelayedEvents
[a
].DENum
);
2341 if g_Game_IsNet
and g_Game_IsServer
then
2342 MH_SEND_GameEvent(NET_EV_KILLCOMBO
, gDelayedEvents
[a
].DENum
);
2346 g_Game_Announce_BodyKill(gDelayedEvents
[a
].DENum
);
2348 gDelayedEvents
[a
].Pending
:= False;
2351 // Каждую секунду обновляем счетчик обновлений:
2352 UPSCounter
:= UPSCounter
+ 1;
2353 if Time
- UPSTime
>= 1000 then
2362 g_Weapon_AddDynLights();
2363 g_Items_AddDynLights();
2367 procedure g_Game_LoadChatSounds(Resource
: string);
2370 FileName
, Snd
: string;
2372 len
, cnt
, tags
, i
, j
: Integer;
2375 FileName
:= g_ExtractWadName(Resource
);
2377 WAD
:= TWADFile
.Create();
2378 WAD
.ReadFile(FileName
);
2380 if not WAD
.GetResource(g_ExtractFilePathName(Resource
), p
, len
) then
2387 cfg
:= TConfig
.CreateMem(p
, len
);
2388 cnt
:= cfg
.ReadInt('ChatSounds', 'Count', 0);
2390 SetLength(gChatSounds
, cnt
);
2391 for i
:= 0 to Length(gChatSounds
) - 1 do
2393 gChatSounds
[i
].Sound
:= nil;
2394 Snd
:= Trim(cfg
.ReadStr(IntToStr(i
), 'Sound', ''));
2395 tags
:= cfg
.ReadInt(IntToStr(i
), 'Tags', 0);
2396 if (Snd
= '') or (Tags
<= 0) then
2398 g_Sound_CreateWADEx('SOUND_CHAT_MACRO' + IntToStr(i
), GameWAD
+':'+Snd
);
2399 gChatSounds
[i
].Sound
:= TPlayableSound
.Create();
2400 gChatSounds
[i
].Sound
.SetByName('SOUND_CHAT_MACRO' + IntToStr(i
));
2401 SetLength(gChatSounds
[i
].Tags
, tags
);
2402 for j
:= 0 to tags
- 1 do
2403 gChatSounds
[i
].Tags
[j
] := toLowerCase1251(cfg
.ReadStr(IntToStr(i
), 'Tag' + IntToStr(j
), ''));
2404 gChatSounds
[i
].FullWord
:= cfg
.ReadBool(IntToStr(i
), 'FullWord', False);
2411 procedure g_Game_FreeChatSounds();
2415 for i
:= 0 to Length(gChatSounds
) - 1 do
2417 gChatSounds
[i
].Sound
.Free();
2418 g_Sound_Delete('SOUND_CHAT_MACRO' + IntToStr(i
));
2420 SetLength(gChatSounds
, 0);
2424 procedure g_Game_LoadData();
2426 if DataLoaded
then Exit
;
2428 e_WriteLog('Loading game data...', TMsgType
.Notify
);
2430 g_Sound_CreateWADEx('SOUND_GAME_TELEPORT', GameWAD
+':SOUNDS\TELEPORT');
2431 g_Sound_CreateWADEx('SOUND_GAME_NOTELEPORT', GameWAD
+':SOUNDS\NOTELEPORT');
2432 g_Sound_CreateWADEx('SOUND_GAME_SECRET', GameWAD
+':SOUNDS\SECRET');
2433 g_Sound_CreateWADEx('SOUND_GAME_DOOROPEN', GameWAD
+':SOUNDS\DOOROPEN');
2434 g_Sound_CreateWADEx('SOUND_GAME_DOORCLOSE', GameWAD
+':SOUNDS\DOORCLOSE');
2435 g_Sound_CreateWADEx('SOUND_GAME_BULK1', GameWAD
+':SOUNDS\BULK1');
2436 g_Sound_CreateWADEx('SOUND_GAME_BULK2', GameWAD
+':SOUNDS\BULK2');
2437 g_Sound_CreateWADEx('SOUND_GAME_BUBBLE1', GameWAD
+':SOUNDS\BUBBLE1');
2438 g_Sound_CreateWADEx('SOUND_GAME_BUBBLE2', GameWAD
+':SOUNDS\BUBBLE2');
2439 g_Sound_CreateWADEx('SOUND_GAME_BURNING', GameWAD
+':SOUNDS\BURNING');
2440 g_Sound_CreateWADEx('SOUND_GAME_SWITCH1', GameWAD
+':SOUNDS\SWITCH1');
2441 g_Sound_CreateWADEx('SOUND_GAME_SWITCH0', GameWAD
+':SOUNDS\SWITCH0');
2442 g_Sound_CreateWADEx('SOUND_GAME_RADIO', GameWAD
+':SOUNDS\RADIO');
2443 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD1', GameWAD
+':SOUNDS\GOOD1');
2444 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD2', GameWAD
+':SOUNDS\GOOD2');
2445 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD3', GameWAD
+':SOUNDS\GOOD3');
2446 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD4', GameWAD
+':SOUNDS\GOOD4');
2447 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL2X', GameWAD
+':SOUNDS\KILL2X');
2448 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL3X', GameWAD
+':SOUNDS\KILL3X');
2449 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL4X', GameWAD
+':SOUNDS\KILL4X');
2450 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILLMX', GameWAD
+':SOUNDS\KILLMX');
2451 g_Sound_CreateWADEx('SOUND_ANNOUNCER_MUHAHA1', GameWAD
+':SOUNDS\MUHAHA1');
2452 g_Sound_CreateWADEx('SOUND_ANNOUNCER_MUHAHA2', GameWAD
+':SOUNDS\MUHAHA2');
2453 g_Sound_CreateWADEx('SOUND_ANNOUNCER_MUHAHA3', GameWAD
+':SOUNDS\MUHAHA3');
2454 g_Sound_CreateWADEx('SOUND_CTF_GET1', GameWAD
+':SOUNDS\GETFLAG1');
2455 g_Sound_CreateWADEx('SOUND_CTF_GET2', GameWAD
+':SOUNDS\GETFLAG2');
2456 g_Sound_CreateWADEx('SOUND_CTF_LOST1', GameWAD
+':SOUNDS\LOSTFLG1');
2457 g_Sound_CreateWADEx('SOUND_CTF_LOST2', GameWAD
+':SOUNDS\LOSTFLG2');
2458 g_Sound_CreateWADEx('SOUND_CTF_RETURN1', GameWAD
+':SOUNDS\RETFLAG1');
2459 g_Sound_CreateWADEx('SOUND_CTF_RETURN2', GameWAD
+':SOUNDS\RETFLAG2');
2460 g_Sound_CreateWADEx('SOUND_CTF_CAPTURE1', GameWAD
+':SOUNDS\CAPFLAG1');
2461 g_Sound_CreateWADEx('SOUND_CTF_CAPTURE2', GameWAD
+':SOUNDS\CAPFLAG2');
2463 goodsnd
[0] := TPlayableSound
.Create();
2464 goodsnd
[1] := TPlayableSound
.Create();
2465 goodsnd
[2] := TPlayableSound
.Create();
2466 goodsnd
[3] := TPlayableSound
.Create();
2468 goodsnd
[0].SetByName('SOUND_ANNOUNCER_GOOD1');
2469 goodsnd
[1].SetByName('SOUND_ANNOUNCER_GOOD2');
2470 goodsnd
[2].SetByName('SOUND_ANNOUNCER_GOOD3');
2471 goodsnd
[3].SetByName('SOUND_ANNOUNCER_GOOD4');
2473 killsnd
[0] := TPlayableSound
.Create();
2474 killsnd
[1] := TPlayableSound
.Create();
2475 killsnd
[2] := TPlayableSound
.Create();
2476 killsnd
[3] := TPlayableSound
.Create();
2478 killsnd
[0].SetByName('SOUND_ANNOUNCER_KILL2X');
2479 killsnd
[1].SetByName('SOUND_ANNOUNCER_KILL3X');
2480 killsnd
[2].SetByName('SOUND_ANNOUNCER_KILL4X');
2481 killsnd
[3].SetByName('SOUND_ANNOUNCER_KILLMX');
2483 hahasnd
[0] := TPlayableSound
.Create();
2484 hahasnd
[1] := TPlayableSound
.Create();
2485 hahasnd
[2] := TPlayableSound
.Create();
2487 hahasnd
[0].SetByName('SOUND_ANNOUNCER_MUHAHA1');
2488 hahasnd
[1].SetByName('SOUND_ANNOUNCER_MUHAHA2');
2489 hahasnd
[2].SetByName('SOUND_ANNOUNCER_MUHAHA3');
2491 sound_get_flag
[0] := TPlayableSound
.Create();
2492 sound_get_flag
[1] := TPlayableSound
.Create();
2493 sound_lost_flag
[0] := TPlayableSound
.Create();
2494 sound_lost_flag
[1] := TPlayableSound
.Create();
2495 sound_ret_flag
[0] := TPlayableSound
.Create();
2496 sound_ret_flag
[1] := TPlayableSound
.Create();
2497 sound_cap_flag
[0] := TPlayableSound
.Create();
2498 sound_cap_flag
[1] := TPlayableSound
.Create();
2500 sound_get_flag
[0].SetByName('SOUND_CTF_GET1');
2501 sound_get_flag
[1].SetByName('SOUND_CTF_GET2');
2502 sound_lost_flag
[0].SetByName('SOUND_CTF_LOST1');
2503 sound_lost_flag
[1].SetByName('SOUND_CTF_LOST2');
2504 sound_ret_flag
[0].SetByName('SOUND_CTF_RETURN1');
2505 sound_ret_flag
[1].SetByName('SOUND_CTF_RETURN2');
2506 sound_cap_flag
[0].SetByName('SOUND_CTF_CAPTURE1');
2507 sound_cap_flag
[1].SetByName('SOUND_CTF_CAPTURE2');
2509 g_Game_LoadChatSounds(GameWAD
+':CHATSND\SNDCFG');
2511 g_Game_SetLoadingText(_lc
[I_LOAD_ITEMS_DATA
], 0, False);
2514 g_Game_SetLoadingText(_lc
[I_LOAD_WEAPONS_DATA
], 0, False);
2515 g_Weapon_LoadData();
2517 g_Monsters_LoadData();
2522 procedure g_Game_Quit();
2524 g_Game_StopAllSounds(True);
2527 g_PlayerModel_FreeData();
2529 //g_Menu_Free(); //k8: this segfaults after resolution change; who cares?
2532 if NetInitDone
then g_Net_Free
;
2534 // remove map after test
2535 if gMapToDelete
<> '' then
2536 g_Game_DeleteTestMap();
2545 procedure g_Game_FreeData();
2547 if not DataLoaded
then Exit
;
2550 g_Weapon_FreeData();
2551 g_Monsters_FreeData();
2553 e_WriteLog('Releasing game data...', TMsgType
.Notify
);
2555 g_Sound_Delete('SOUND_GAME_TELEPORT');
2556 g_Sound_Delete('SOUND_GAME_NOTELEPORT');
2557 g_Sound_Delete('SOUND_GAME_SECRET');
2558 g_Sound_Delete('SOUND_GAME_DOOROPEN');
2559 g_Sound_Delete('SOUND_GAME_DOORCLOSE');
2560 g_Sound_Delete('SOUND_GAME_BULK1');
2561 g_Sound_Delete('SOUND_GAME_BULK2');
2562 g_Sound_Delete('SOUND_GAME_BUBBLE1');
2563 g_Sound_Delete('SOUND_GAME_BUBBLE2');
2564 g_Sound_Delete('SOUND_GAME_BURNING');
2565 g_Sound_Delete('SOUND_GAME_SWITCH1');
2566 g_Sound_Delete('SOUND_GAME_SWITCH0');
2573 g_Sound_Delete('SOUND_ANNOUNCER_GOOD1');
2574 g_Sound_Delete('SOUND_ANNOUNCER_GOOD2');
2575 g_Sound_Delete('SOUND_ANNOUNCER_GOOD3');
2576 g_Sound_Delete('SOUND_ANNOUNCER_GOOD4');
2583 g_Sound_Delete('SOUND_ANNOUNCER_KILL2X');
2584 g_Sound_Delete('SOUND_ANNOUNCER_KILL3X');
2585 g_Sound_Delete('SOUND_ANNOUNCER_KILL4X');
2586 g_Sound_Delete('SOUND_ANNOUNCER_KILLMX');
2592 g_Sound_Delete('SOUND_ANNOUNCER_MUHAHA1');
2593 g_Sound_Delete('SOUND_ANNOUNCER_MUHAHA2');
2594 g_Sound_Delete('SOUND_ANNOUNCER_MUHAHA3');
2596 sound_get_flag
[0].Free();
2597 sound_get_flag
[1].Free();
2598 sound_lost_flag
[0].Free();
2599 sound_lost_flag
[1].Free();
2600 sound_ret_flag
[0].Free();
2601 sound_ret_flag
[1].Free();
2602 sound_cap_flag
[0].Free();
2603 sound_cap_flag
[1].Free();
2605 g_Sound_Delete('SOUND_CTF_GET1');
2606 g_Sound_Delete('SOUND_CTF_GET2');
2607 g_Sound_Delete('SOUND_CTF_LOST1');
2608 g_Sound_Delete('SOUND_CTF_LOST2');
2609 g_Sound_Delete('SOUND_CTF_RETURN1');
2610 g_Sound_Delete('SOUND_CTF_RETURN2');
2611 g_Sound_Delete('SOUND_CTF_CAPTURE1');
2612 g_Sound_Delete('SOUND_CTF_CAPTURE2');
2614 g_Game_FreeChatSounds();
2616 DataLoaded
:= False;
2619 procedure g_FatalError(Text: String);
2621 g_Console_Add(Format(_lc
[I_FATAL_ERROR
], [Text]), True);
2622 e_WriteLog(Format(_lc
[I_FATAL_ERROR
], [Text]), TMsgType
.Warning
);
2624 gExit
:= EXIT_SIMPLE
;
2625 if gGameOn
then EndGame
;
2628 procedure g_SimpleError(Text: String);
2630 g_Console_Add(Format(_lc
[I_SIMPLE_ERROR
], [Text]), True);
2631 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], [Text]), TMsgType
.Warning
);
2634 procedure g_Game_AddPlayer(Team
: Byte = TEAM_NONE
);
2636 if ((not gGameOn
) and (gState
<> STATE_INTERCUSTOM
))
2637 or (not (gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
])) then
2640 if (gGameSettings
.MaxLives
> 0) and (gLMSRespawn
= LMS_RESPAWN_NONE
) then
2643 if gPlayer1
= nil then
2645 if g_Game_IsClient
then
2647 if NetPlrUID1
> -1 then
2648 MC_SEND_CheatRequest(NET_CHEAT_SPECTATE
);
2652 if not (Team
in [TEAM_RED
, TEAM_BLUE
]) then
2653 Team
:= gPlayer1Settings
.Team
;
2655 // Создание первого игрока:
2656 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
2657 gPlayer1Settings
.Color
,
2659 if gPlayer1
= nil then
2660 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]))
2663 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
2664 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [gPlayer1
.Name
]), True);
2665 if g_Game_IsServer
and g_Game_IsNet
then
2666 MH_SEND_PlayerCreate(gPlayer1
.UID
);
2667 gPlayer1
.Respawn(False, True);
2668 g_Net_Slist_ServerPlayerComes();
2673 if gPlayer2
= nil then
2675 if g_Game_IsClient
then
2677 if NetPlrUID2
> -1 then
2678 gPlayer2
:= g_Player_Get(NetPlrUID2
);
2682 if not (Team
in [TEAM_RED
, TEAM_BLUE
]) then
2683 Team
:= gPlayer2Settings
.Team
;
2685 // Создание второго игрока:
2686 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
2687 gPlayer2Settings
.Color
,
2689 if gPlayer2
= nil then
2690 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]))
2693 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
2694 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [gPlayer2
.Name
]), True);
2695 if g_Game_IsServer
and g_Game_IsNet
then
2696 MH_SEND_PlayerCreate(gPlayer2
.UID
);
2697 gPlayer2
.Respawn(False, True);
2698 g_Net_Slist_ServerPlayerComes();
2705 procedure g_Game_RemovePlayer();
2709 if ((not gGameOn
) and (gState
<> STATE_INTERCUSTOM
))
2710 or (not (gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
])) then
2715 if g_Game_IsServer
then
2718 Pl
.Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
2719 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [Pl
.Name
]), True);
2720 g_Player_Remove(Pl
.UID
);
2721 g_Net_Slist_ServerPlayerLeaves();
2725 gSpectLatchPID2
:= Pl
.UID
;
2733 if g_Game_IsServer
then
2736 Pl
.Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
2737 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [Pl
.Name
]), True);
2738 g_Player_Remove(Pl
.UID
);
2739 g_Net_Slist_ServerPlayerLeaves();
2742 gSpectLatchPID1
:= Pl
.UID
;
2744 MC_SEND_CheatRequest(NET_CHEAT_SPECTATE
);
2748 g_Net_Slist_ServerPlayerLeaves();
2751 procedure g_Game_Spectate();
2753 g_Game_RemovePlayer();
2754 if gPlayer1
<> nil then
2755 g_Game_RemovePlayer();
2758 procedure g_Game_SpectateCenterView();
2760 gSpectX
:= Max(gMapInfo
.Width
div 2 - gScreenWidth
div 2, 0);
2761 gSpectY
:= Max(gMapInfo
.Height
div 2 - gScreenHeight
div 2, 0);
2764 procedure g_Game_StartSingle(Map
: String; TwoPlayers
: Boolean; nPlayers
: Byte);
2771 e_WriteLog('Starting singleplayer game...', TMsgType
.Notify
);
2773 g_Game_ClearLoading();
2776 FillByte(gGameSettings
, SizeOf(TGameSettings
), 0);
2779 gGameSettings
.GameType
:= GT_SINGLE
;
2780 gGameSettings
.MaxLives
:= 0;
2781 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_ALLOWEXIT
;
2782 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_MONSTERS
;
2783 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_BOTVSMONSTER
;
2784 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_TEAMHITPROJECTILE
;
2785 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_TEAMHITTRACE
;
2786 gSwitchGameMode
:= GM_SINGLE
;
2788 gLMSRespawn
:= LMS_RESPAWN_NONE
;
2789 gLMSRespawnTime
:= 0;
2790 gSpectLatchPID1
:= 0;
2791 gSpectLatchPID2
:= 0;
2793 g_Game_ExecuteEvent('ongamestart');
2795 // Создание первого игрока:
2796 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
2797 gPlayer1Settings
.Color
,
2798 gPlayer1Settings
.Team
, False));
2799 if gPlayer1
= nil then
2801 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
2805 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
2808 // Создание второго игрока, если есть:
2811 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
2812 gPlayer2Settings
.Color
,
2813 gPlayer2Settings
.Team
, False));
2814 if gPlayer2
= nil then
2816 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
2820 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
2824 // Загрузка и запуск карты:
2825 if not g_Game_StartMap(false{asMegawad}, MAP
, True) then
2827 if (Pos(':\', Map
) > 0) or (Pos(':/', Map
) > 0) then tmps
:= Map
else tmps
:= gGameSettings
.WAD
+ ':\' + MAP
;
2828 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [tmps
]));
2832 // Настройки игроков и ботов:
2836 for i
:= nPl
+1 to nPlayers
do
2837 g_Player_Create(STD_PLAYER_MODEL
, _RGB(0, 0, 0), 0, True);
2840 procedure g_Game_StartCustom(Map
: String; GameMode
: Byte;
2841 TimeLimit
, GoalLimit
: Word;
2843 Options
: LongWord; nPlayers
: Byte);
2849 e_WriteLog('Starting custom game...', TMsgType
.Notify
);
2851 g_Game_ClearLoading();
2854 gGameSettings
.GameType
:= GT_CUSTOM
;
2855 gGameSettings
.GameMode
:= GameMode
;
2856 gSwitchGameMode
:= GameMode
;
2857 gGameSettings
.TimeLimit
:= TimeLimit
;
2858 gGameSettings
.GoalLimit
:= GoalLimit
;
2859 gGameSettings
.MaxLives
:= IfThen(GameMode
= GM_CTF
, 0, MaxLives
);
2860 gGameSettings
.Options
:= Options
;
2862 gCoopTotalMonstersKilled
:= 0;
2863 gCoopTotalSecretsFound
:= 0;
2864 gCoopTotalMonsters
:= 0;
2865 gCoopTotalSecrets
:= 0;
2869 gLMSRespawn
:= LMS_RESPAWN_NONE
;
2870 gLMSRespawnTime
:= 0;
2871 gSpectLatchPID1
:= 0;
2872 gSpectLatchPID2
:= 0;
2874 g_Game_ExecuteEvent('ongamestart');
2876 // Режим наблюдателя:
2877 if nPlayers
= 0 then
2884 if nPlayers
>= 1 then
2886 // Создание первого игрока:
2887 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
2888 gPlayer1Settings
.Color
,
2889 gPlayer1Settings
.Team
, False));
2890 if gPlayer1
= nil then
2892 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
2896 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
2900 if nPlayers
>= 2 then
2902 // Создание второго игрока:
2903 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
2904 gPlayer2Settings
.Color
,
2905 gPlayer2Settings
.Team
, False));
2906 if gPlayer2
= nil then
2908 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
2912 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
2916 // Загрузка и запуск карты:
2917 if not g_Game_StartMap(true{asMegawad}, Map
, True) then
2919 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [Map
]));
2923 // Нет точек появления:
2924 if (g_Map_GetPointCount(RESPAWNPOINT_PLAYER1
) +
2925 g_Map_GetPointCount(RESPAWNPOINT_PLAYER2
) +
2926 g_Map_GetPointCount(RESPAWNPOINT_DM
) +
2927 g_Map_GetPointCount(RESPAWNPOINT_RED
)+
2928 g_Map_GetPointCount(RESPAWNPOINT_BLUE
)) < 1 then
2930 g_FatalError(_lc
[I_GAME_ERROR_GET_SPAWN
]);
2934 // Настройки игроков и ботов:
2938 for i
:= nPl
+1 to nPlayers
do
2939 g_Player_Create(STD_PLAYER_MODEL
, _RGB(0, 0, 0), 0, True);
2942 procedure g_Game_StartServer(Map
: String; GameMode
: Byte;
2943 TimeLimit
, GoalLimit
: Word; MaxLives
: Byte;
2944 Options
: LongWord; nPlayers
: Byte;
2945 IPAddr
: LongWord; Port
: Word);
2948 g_Net_Slist_ServerClosed();
2950 e_WriteLog('Starting net game (server)...', TMsgType
.Notify
);
2952 g_Game_ClearLoading();
2955 gGameSettings
.GameType
:= GT_SERVER
;
2956 gGameSettings
.GameMode
:= GameMode
;
2957 gSwitchGameMode
:= GameMode
;
2958 gGameSettings
.TimeLimit
:= TimeLimit
;
2959 gGameSettings
.GoalLimit
:= GoalLimit
;
2960 gGameSettings
.MaxLives
:= IfThen(GameMode
= GM_CTF
, 0, MaxLives
);
2961 gGameSettings
.Options
:= Options
;
2963 gCoopTotalMonstersKilled
:= 0;
2964 gCoopTotalSecretsFound
:= 0;
2965 gCoopTotalMonsters
:= 0;
2966 gCoopTotalSecrets
:= 0;
2970 gLMSRespawn
:= LMS_RESPAWN_NONE
;
2971 gLMSRespawnTime
:= 0;
2972 gSpectLatchPID1
:= 0;
2973 gSpectLatchPID2
:= 0;
2975 g_Game_ExecuteEvent('ongamestart');
2977 // Режим наблюдателя:
2978 if nPlayers
= 0 then
2984 if nPlayers
>= 1 then
2986 // Создание первого игрока:
2987 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
2988 gPlayer1Settings
.Color
,
2989 gPlayer1Settings
.Team
, False));
2990 if gPlayer1
= nil then
2992 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
2996 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
2999 if nPlayers
>= 2 then
3001 // Создание второго игрока:
3002 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
3003 gPlayer2Settings
.Color
,
3004 gPlayer2Settings
.Team
, False));
3005 if gPlayer2
= nil then
3007 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
3011 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
3014 g_Game_SetLoadingText(_lc
[I_LOAD_HOST
], 0, False);
3015 if NetForwardPorts
then
3016 g_Game_SetLoadingText(_lc
[I_LOAD_PORTS
], 0, False);
3019 if not g_Net_Host(IPAddr
, Port
, NetMaxClients
) then
3021 g_FatalError(_lc
[I_NET_MSG
] + Format(_lc
[I_NET_ERR_HOST
], [Port
]));
3025 g_Net_Slist_Set(NetMasterList
);
3027 g_Net_Slist_ServerStarted();
3029 // Загрузка и запуск карты:
3030 if not g_Game_StartMap(false{asMegawad}, Map
, True) then
3032 g_Net_Slist_ServerClosed();
3033 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [Map
]));
3037 // Нет точек появления:
3038 if (g_Map_GetPointCount(RESPAWNPOINT_PLAYER1
) +
3039 g_Map_GetPointCount(RESPAWNPOINT_PLAYER2
) +
3040 g_Map_GetPointCount(RESPAWNPOINT_DM
) +
3041 g_Map_GetPointCount(RESPAWNPOINT_RED
)+
3042 g_Map_GetPointCount(RESPAWNPOINT_BLUE
)) < 1 then
3044 g_Net_Slist_ServerClosed();
3045 g_FatalError(_lc
[I_GAME_ERROR_GET_SPAWN
]);
3049 // Настройки игроков и ботов:
3052 g_Net_Slist_ServerMapStarted();
3053 NetState
:= NET_STATE_GAME
;
3056 procedure g_Game_StartClient(Addr
: String; Port
: Word; PW
: String);
3071 e_WriteLog('Starting net game (client)...', TMsgType
.Notify
);
3072 e_WriteLog('NET: Trying to connect to ' + Addr
+ ':' + IntToStr(Port
) + '...', TMsgType
.Notify
);
3074 g_Game_ClearLoading();
3077 gGameSettings
.GameType
:= GT_CLIENT
;
3079 gCoopTotalMonstersKilled
:= 0;
3080 gCoopTotalSecretsFound
:= 0;
3081 gCoopTotalMonsters
:= 0;
3082 gCoopTotalSecrets
:= 0;
3086 g_Game_ExecuteEvent('ongamestart');
3088 NetState
:= NET_STATE_AUTH
;
3090 g_Game_SetLoadingText(_lc
[I_LOAD_CONNECT
], 0, False);
3092 // create (or update) map/resource databases
3093 g_Res_CreateDatabases(true);
3095 gLMSRespawn
:= LMS_RESPAWN_NONE
;
3096 gLMSRespawnTime
:= 0;
3097 gSpectLatchPID1
:= 0;
3098 gSpectLatchPID2
:= 0;
3101 if not g_Net_Connect(Addr
, Port
) then
3103 g_FatalError(_lc
[I_NET_MSG
] + _lc
[I_NET_ERR_CONN
]);
3104 NetState
:= NET_STATE_NONE
;
3108 g_Game_SetLoadingText(_lc
[I_LOAD_SEND_INFO
], 0, False);
3110 g_Game_SetLoadingText(_lc
[I_LOAD_WAIT_INFO
], 0, False);
3115 // fuck! https://www.mail-archive.com/enet-discuss@cubik.org/msg00852.html
3116 // tl;dr: on shitdows, we can get -1 sometimes, and it is *NOT* a failure.
3117 // thank you, enet. let's ignore failures altogether then.
3118 while (enet_host_service(NetHost
, @NetEvent
, 50) > 0) do
3120 if (NetEvent
.kind
= ENET_EVENT_TYPE_RECEIVE
) then
3122 if (NetEvent
.channelID
= NET_CHAN_DOWNLOAD_EX
) then
3124 // ignore all download packets, they're processed by separate code
3125 enet_packet_destroy(NetEvent
.packet
);
3128 Ptr
:= NetEvent
.packet
^.data
;
3129 if not InMsg
.Init(Ptr
, NetEvent
.packet
^.dataLength
, True) then
3131 enet_packet_destroy(NetEvent
.packet
);
3135 InMsg
.ReadLongWord(); // skip size
3136 MID
:= InMsg
.ReadByte();
3138 if (MID
= NET_MSG_INFO
) and (State
= 0) then
3140 NetMyID
:= InMsg
.ReadByte();
3141 NetPlrUID1
:= InMsg
.ReadWord();
3143 WadName
:= InMsg
.ReadString();
3144 Map
:= InMsg
.ReadString();
3146 gWADHash
:= InMsg
.ReadMD5();
3148 gGameSettings
.GameMode
:= InMsg
.ReadByte();
3149 gSwitchGameMode
:= gGameSettings
.GameMode
;
3150 gGameSettings
.GoalLimit
:= InMsg
.ReadWord();
3151 gGameSettings
.TimeLimit
:= InMsg
.ReadWord();
3152 gGameSettings
.MaxLives
:= InMsg
.ReadByte();
3153 gGameSettings
.Options
:= InMsg
.ReadLongWord();
3154 T
:= InMsg
.ReadLongWord();
3156 //newResPath := g_Res_SearchSameWAD(MapsDir, WadName, gWADHash);
3157 //if newResPath = '' then
3159 //g_Game_SetLoadingText(_lc[I_LOAD_DL_RES], 0, False);
3160 newResPath
:= g_Res_DownloadMapWAD(ExtractFileName(WadName
), gWADHash
);
3161 if newResPath
= '' then
3163 g_FatalError(_lc
[I_NET_ERR_HASH
]);
3164 enet_packet_destroy(NetEvent
.packet
);
3165 NetState
:= NET_STATE_NONE
;
3168 e_LogWritefln('using downloaded map wad [%s] for [%s]`', [newResPath
, WadName
], TMsgType
.Notify
);
3170 //newResPath := ExtractRelativePath(MapsDir, newResPath);
3173 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
3174 gPlayer1Settings
.Color
,
3175 gPlayer1Settings
.Team
, False));
3177 if gPlayer1
= nil then
3179 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
3181 enet_packet_destroy(NetEvent
.packet
);
3182 NetState
:= NET_STATE_NONE
;
3186 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
3187 gPlayer1
.UID
:= NetPlrUID1
;
3188 gPlayer1
.Reset(True);
3190 if not g_Game_StartMap(false{asMegawad}, newResPath
+ ':\' + Map
, True) then
3192 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [WadName
+ ':\' + Map
]));
3194 enet_packet_destroy(NetEvent
.packet
);
3195 NetState
:= NET_STATE_NONE
;
3203 enet_packet_destroy(NetEvent
.packet
);
3207 enet_packet_destroy(NetEvent
.packet
);
3211 if (NetEvent
.kind
= ENET_EVENT_TYPE_DISCONNECT
) then
3214 if (NetEvent
.data
<= NET_DISC_MAX
) then
3215 g_Console_Add(_lc
[I_NET_MSG_ERROR
] + _lc
[I_NET_ERR_CONN
] + ' ' +
3216 _lc
[TStrings_Locale(Cardinal(I_NET_DISC_NONE
) + NetEvent
.data
)], True);
3223 ProcessLoading(true);
3225 if g_Net_UserRequestExit() then
3234 g_FatalError(_lc
[I_NET_MSG
] + _lc
[I_NET_ERR_CONN
]);
3235 NetState
:= NET_STATE_NONE
;
3240 NetState
:= NET_STATE_GAME
;
3241 MC_SEND_FullStateRequest
;
3242 e_WriteLog('NET: Connection successful.', TMsgType
.Notify
);
3246 lastAsMegaWad
: Boolean = false;
3248 procedure g_Game_ChangeMap(const MapPath
: String);
3252 g_Game_ClearLoading();
3254 Force
:= gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
];
3255 // Если уровень завершился по триггеру Выход, не очищать инвентарь
3256 if gExitByTrigger
then
3259 gExitByTrigger
:= False;
3261 if not g_Game_StartMap(lastAsMegaWad
, MapPath
, Force
) then
3262 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [MapPath
]));
3265 procedure g_Game_Restart();
3269 if g_Game_IsClient
then
3271 map
:= g_ExtractFileName(gMapInfo
.Map
);
3272 e_LogWritefln('g_Game_Restart: map = "%s" gCurrentMapFileName = "%s"', [map
, gCurrentMapFileName
]);
3276 g_Game_ClearLoading();
3277 g_Game_StartMap(lastAsMegaWad
, Map
, True, gCurrentMapFileName
);
3280 function g_Game_StartMap (asMegawad
: Boolean; Map
: String; Force
: Boolean = False; const oldMapPath
: AnsiString=''): Boolean;
3282 NewWAD
, ResName
: String;
3286 g_Map_Free((Map
<> gCurrentMapFileName
) and (oldMapPath
<> gCurrentMapFileName
));
3287 g_Player_RemoveAllCorpses();
3289 if (not g_Game_IsClient
) and
3290 (gSwitchGameMode
<> gGameSettings
.GameMode
) and
3291 (gGameSettings
.GameMode
<> GM_SINGLE
) then
3293 if gSwitchGameMode
= GM_CTF
then
3294 gGameSettings
.MaxLives
:= 0;
3295 gGameSettings
.GameMode
:= gSwitchGameMode
;
3298 gSwitchGameMode
:= gGameSettings
.GameMode
;
3300 g_Player_ResetTeams();
3302 lastAsMegaWad
:= asMegawad
;
3303 if isWadPath(Map
) then
3305 NewWAD
:= g_ExtractWadName(Map
);
3306 ResName
:= g_ExtractFileName(Map
);
3307 if g_Game_IsServer
then
3309 nws
:= findDiskWad(NewWAD
);
3310 //writeln('000: Map=[', Map, ']; nws=[', nws, ']; NewWAD=[', NewWAD, ']');
3313 if (length(nws
) = 0) then nws
:= e_FindWad(MegawadDirs
, NewWAD
);
3314 if (length(nws
) = 0) then nws
:= e_FindWad(MapDirs
, NewWAD
);
3318 if (length(nws
) = 0) then nws
:= e_FindWad(MapDirs
, NewWAD
);
3319 if (length(nws
) = 0) then nws
:= e_FindWad(MegawadDirs
, NewWAD
);
3321 //if (length(nws) = 0) then nws := e_FindWad(MapDownloadDirs, NewWAD);
3322 //writeln('001: Map=[', Map, ']; nws=[', nws, ']; NewWAD=[', NewWAD, ']');
3324 if (length(nws
) = 0) then
3326 ResName
:= ''; // failed
3331 if (g_Game_IsNet
) then gWADHash
:= MD5File(nws
);
3332 //writeln('********: nws=', nws, ' : Map=', Map, ' : nw=', NewWAD, ' : resname=', ResName);
3333 g_Game_LoadWAD(NewWAD
);
3338 // hash received in MC_RECV_GameEvent -> NET_EV_MAPSTART
3339 NewWAD
:= g_Game_ClientWAD(NewWAD
, gWADHash
);
3344 NewWAD
:= gGameSettings
.WAD
;
3350 //writeln('********: gsw=', gGameSettings.WAD, '; rn=', ResName);
3352 if (ResName
<> '') and (NewWAD
<> '') then
3354 //result := g_Map_Load(gGameSettings.WAD + ':\' + ResName);
3355 result
:= g_Map_Load(NewWAD
+':\'+ResName
);
3357 r_Render_LoadTextures
;
3362 g_Player_ResetAll(Force
or gLastMap
, gGameSettings
.GameType
= GT_SINGLE
);
3364 gState
:= STATE_NONE
;
3365 {$IFDEF ENABLE_MENU}
3366 g_ActiveWindow
:= nil;
3371 wNeedTimeReset
:= True;
3373 if gGameSettings
.GameMode
= GM_CTF
then
3375 g_Map_ResetFlag(FLAG_RED
);
3376 g_Map_ResetFlag(FLAG_BLUE
);
3377 // CTF, а флагов нет:
3378 if not g_Map_HaveFlagPoints() then
3379 g_SimpleError(_lc
[I_GAME_ERROR_CTF
]);
3384 gState
:= STATE_MENU
;
3389 gPauseMain
:= false;
3390 gPauseHolmes
:= false;
3391 NetTimeToUpdate
:= 1;
3392 NetTimeToReliable
:= 0;
3393 NetTimeToMaster
:= NetMasterRate
;
3394 gSpectLatchPID1
:= 0;
3395 gSpectLatchPID2
:= 0;
3396 gMissionFailed
:= False;
3399 gCoopMonstersKilled
:= 0;
3400 gCoopSecretsFound
:= 0;
3402 gVoteInProgress
:= False;
3403 gVotePassed
:= False;
3409 if not gGameOn
then Exit
;
3411 g_Game_SpectateCenterView();
3413 if g_Game_IsServer
then
3415 if (gGameSettings
.MaxLives
> 0) and (gGameSettings
.WarmupTime
> 0) then
3417 gLMSRespawn
:= LMS_RESPAWN_WARMUP
;
3418 gLMSRespawnTime
:= gTime
+ gGameSettings
.WarmupTime
*1000;
3419 gLMSSoftSpawn
:= True;
3420 if g_Game_IsNet
then
3421 MH_SEND_GameEvent(NET_EV_LMS_WARMUP
, gLMSRespawnTime
- gTime
);
3425 gLMSRespawn
:= LMS_RESPAWN_NONE
;
3426 gLMSRespawnTime
:= 0;
3430 if NetMode
= NET_SERVER
then
3432 MH_SEND_GameEvent(NET_EV_MAPSTART
, gGameSettings
.GameMode
, Map
);
3435 g_Net_Slist_ServerMapStarted();
3437 if NetClients
<> nil then
3438 for I
:= 0 to High(NetClients
) do
3439 if NetClients
[I
].Used
then
3441 NetClients
[I
].Voted
:= False;
3442 if NetClients
[I
].RequestedFullUpdate
then
3444 MH_SEND_Everything((NetClients
[I
].State
= NET_STATE_AUTH
), I
);
3445 NetClients
[I
].RequestedFullUpdate
:= False;
3449 g_Net_UnbanNonPermHosts();
3454 gCoopTotalMonstersKilled
:= 0;
3455 gCoopTotalSecretsFound
:= 0;
3456 gCoopTotalMonsters
:= 0;
3457 gCoopTotalSecrets
:= 0;
3461 g_Game_ExecuteEvent('onmapstart');
3464 procedure SetFirstLevel
;
3468 MapList
:= g_Map_GetMapsList(gGameSettings
.WAD
);
3469 if MapList
= nil then
3472 SortSArray(MapList
);
3473 gNextMap
:= MapList
[Low(MapList
)];
3478 procedure g_Game_ExitLevel(const Map
: AnsiString);
3482 gCoopTotalMonstersKilled
:= gCoopTotalMonstersKilled
+ gCoopMonstersKilled
;
3483 gCoopTotalSecretsFound
:= gCoopTotalSecretsFound
+ gCoopSecretsFound
;
3484 gCoopTotalMonsters
:= gCoopTotalMonsters
+ gTotalMonsters
;
3485 gCoopTotalSecrets
:= gCoopTotalSecrets
+ gSecretsCount
;
3487 // Вышли в выход в Одиночной игре:
3488 if gGameSettings
.GameType
= GT_SINGLE
then
3489 gExit
:= EXIT_ENDLEVELSINGLE
3490 else // Вышли в выход в Своей игре
3492 gExit
:= EXIT_ENDLEVELCUSTOM
;
3493 if gGameSettings
.GameMode
= GM_COOP
then
3494 g_Player_RememberAll
;
3496 if not g_Map_Exist(gGameSettings
.WAD
+ ':\' + gNextMap
) then
3499 if gGameSettings
.GameMode
= GM_COOP
then
3502 gStatsPressed
:= True;
3503 gNextMap
:= 'MAP01';
3505 if not g_Map_Exist(gGameSettings
.WAD
+ ':\' + gNextMap
) then
3508 if g_Game_IsNet
then
3510 MH_SEND_GameStats();
3511 MH_SEND_CoopStats();
3517 procedure g_Game_RestartLevel();
3521 if gGameSettings
.GameMode
= GM_SINGLE
then
3526 gExit
:= EXIT_ENDLEVELCUSTOM
;
3527 Map
:= g_ExtractFileName(gMapInfo
.Map
);
3531 function g_Game_ClientWAD (NewWAD
: String; const WHash
: TMD5Digest
): AnsiString;
3533 gWAD
{, xwad}: String;
3536 if not g_Game_IsClient
then Exit
;
3537 //e_LogWritefln('*** g_Game_ClientWAD: `%s`', [NewWAD]);
3539 gWAD
:= g_Res_DownloadMapWAD(ExtractFileName(NewWAD
), WHash
);
3544 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_WAD
], [ExtractFileName(NewWAD
)]));
3548 e_LogWritefln('using downloaded client map wad [%s] for [%s]', [gWAD
, NewWAD
], TMsgType
.Notify
);
3551 g_Game_LoadWAD(NewWAD
);
3555 if LowerCase(NewWAD) = LowerCase(gGameSettings.WAD) then Exit;
3556 gWAD := g_Res_SearchSameWAD(MapsDir, ExtractFileName(NewWAD), WHash);
3559 g_Game_SetLoadingText(_lc[I_LOAD_DL_RES], 0, False);
3560 gWAD := g_Res_DownloadMapWAD(ExtractFileName(NewWAD), WHash);
3564 g_FatalError(Format(_lc[I_GAME_ERROR_MAP_WAD], [ExtractFileName(NewWAD)]));
3568 NewWAD := ExtractRelativePath(MapsDir, gWAD);
3569 g_Game_LoadWAD(NewWAD);
3573 procedure g_Game_RestartRound(NoMapRestart
: Boolean = False);
3575 i
, n
, nb
, nr
: Integer;
3577 if not g_Game_IsServer
then Exit
;
3578 if gLMSRespawn
= LMS_RESPAWN_NONE
then Exit
;
3579 gLMSRespawn
:= LMS_RESPAWN_NONE
;
3580 gLMSRespawnTime
:= 0;
3583 if (gGameSettings
.GameMode
= GM_COOP
) and not NoMapRestart
then
3585 gMissionFailed
:= True;
3586 g_Game_RestartLevel
;
3590 n
:= 0; nb
:= 0; nr
:= 0;
3591 for i
:= Low(gPlayers
) to High(gPlayers
) do
3592 if (gPlayers
[i
] <> nil) and
3593 ((not gPlayers
[i
].FSpectator
) or gPlayers
[i
].FWantsInGame
or
3594 (gPlayers
[i
] is TBot
)) then
3597 if gPlayers
[i
].Team
= TEAM_RED
then Inc(nr
)
3598 else if gPlayers
[i
].Team
= TEAM_BLUE
then Inc(nb
)
3601 if (n
< 1) or ((gGameSettings
.GameMode
= GM_TDM
) and ((nr
= 0) or (nb
= 0))) then
3603 // wait a second until the fuckers finally decide to join
3604 gLMSRespawn
:= LMS_RESPAWN_WARMUP
;
3605 gLMSRespawnTime
:= gTime
+ gGameSettings
.WarmupTime
*1000;
3606 gLMSSoftSpawn
:= NoMapRestart
;
3607 if g_Game_IsNet
then
3608 MH_SEND_GameEvent(NET_EV_LMS_WARMUP
, gLMSRespawnTime
- gTime
);
3612 g_Player_RemoveAllCorpses
;
3613 g_Game_Message(_lc
[I_MESSAGE_LMS_START
], 144);
3614 if g_Game_IsNet
then
3615 MH_SEND_GameEvent(NET_EV_LMS_START
);
3617 for i
:= Low(gPlayers
) to High(gPlayers
) do
3619 if gPlayers
[i
] = nil then continue
;
3620 if gPlayers
[i
] is TBot
then gPlayers
[i
].FWantsInGame
:= True;
3621 // don't touch normal spectators
3622 if gPlayers
[i
].FSpectator
and not gPlayers
[i
].FWantsInGame
then
3624 gPlayers
[i
].FNoRespawn
:= True;
3625 gPlayers
[i
].Lives
:= 0;
3626 if g_Game_IsNet
then
3627 MH_SEND_PlayerStats(gPlayers
[I
].UID
);
3630 gPlayers
[i
].FNoRespawn
:= False;
3631 gPlayers
[i
].Lives
:= gGameSettings
.MaxLives
;
3632 gPlayers
[i
].Respawn(False, True);
3633 if gGameSettings
.GameMode
= GM_COOP
then
3635 gPlayers
[i
].Frags
:= 0;
3636 gPlayers
[i
].RecallState
;
3638 if (gPlayer1
= nil) and (gSpectLatchPID1
> 0) then
3639 gPlayer1
:= g_Player_Get(gSpectLatchPID1
);
3640 if (gPlayer2
= nil) and (gSpectLatchPID2
> 0) then
3641 gPlayer2
:= g_Player_Get(gSpectLatchPID2
);
3644 g_Items_RestartRound();
3646 gLMSSoftSpawn
:= False;
3649 function g_Game_GetFirstMap(WAD
: String): String;
3653 MapList
:= g_Map_GetMapsList(WAD
);
3654 if MapList
= nil then
3657 SortSArray(MapList
);
3658 Result
:= MapList
[Low(MapList
)];
3660 if not g_Map_Exist(WAD
+ ':\' + Result
) then
3666 function g_Game_GetNextMap(): String;
3673 MapList
:= g_Map_GetMapsList(gGameSettings
.WAD
);
3674 if MapList
= nil then
3677 Map
:= g_ExtractFileName(gMapInfo
.Map
);
3679 SortSArray(MapList
);
3681 for I
:= Low(MapList
) to High(MapList
) do
3682 if Map
= MapList
[I
] then
3688 if MapIndex
<> -255 then
3690 if MapIndex
= High(MapList
) then
3691 Result
:= MapList
[Low(MapList
)]
3693 Result
:= MapList
[MapIndex
+ 1];
3695 if not g_Map_Exist(gGameSettings
.WAD
+ ':\' + Result
) then Result
:= Map
;
3701 procedure g_Game_NextLevel();
3703 if gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
, GM_COOP
] then
3704 gExit
:= EXIT_ENDLEVELCUSTOM
3707 gExit
:= EXIT_ENDLEVELSINGLE
;
3711 if gNextMap
<> '' then Exit
;
3712 gNextMap
:= g_Game_GetNextMap();
3715 function g_Game_IsTestMap(): Boolean;
3717 result
:= StrEquCI1251(TEST_MAP_NAME
, g_ExtractFileName(gMapInfo
.Map
));
3720 procedure g_Game_DeleteTestMap();
3723 //MapName: AnsiString;
3731 a
:= Pos('.wad:\', toLowerCase1251(gMapToDelete
));
3732 if (a
= 0) then a
:= Pos('.wad:/', toLowerCase1251(gMapToDelete
));
3733 if (a
= 0) then exit
;
3735 // Выделяем имя wad-файла и имя карты
3736 WadName
:= Copy(gMapToDelete
, 1, a
+3);
3737 Delete(gMapToDelete
, 1, a
+5);
3738 gMapToDelete
:= UpperCase(gMapToDelete
);
3740 //CopyMemory(@MapName[0], @gMapToDelete[1], Min(16, Length(gMapToDelete)));
3743 // Имя карты не стандартное тестовое:
3744 if MapName <> TEST_MAP_NAME then
3747 if not gTempDelete then
3749 time := g_GetFileTime(WadName);
3750 WAD := TWADFile.Create();
3753 if not WAD.ReadFile(WadName) then
3754 begin // Нет такого WAD-файла
3759 // Составляем список карт и ищем нужную:
3761 MapList := WAD.GetResourcesList('');
3763 if MapList <> nil then
3764 for a := 0 to High(MapList) do
3765 if MapList[a] = MapName then
3767 // Удаляем и сохраняем:
3768 WAD.RemoveResource('', MapName);
3769 WAD.SaveTo(WadName);
3774 g_SetFileTime(WadName, time);
3777 if gTempDelete
then DeleteFile(WadName
);
3780 procedure GameCVars(P
: SSArray
);
3783 stat
: TPlayerStatArray
;
3786 procedure ParseGameFlag(Flag
: LongWord; OffMsg
, OnMsg
: TStrings_Locale
; OnMapChange
: Boolean = False);
3790 if Length(P
) > 1 then
3795 gsGameFlags
:= gsGameFlags
or Flag
3797 gsGameFlags
:= gsGameFlags
and (not Flag
);
3799 if g_Game_IsServer
then
3802 gGameSettings
.Options
:= gGameSettings
.Options
or Flag
3804 gGameSettings
.Options
:= gGameSettings
.Options
and (not Flag
);
3805 if g_Game_IsNet
then MH_SEND_GameSettings
;
3809 if LongBool(gsGameFlags
and Flag
) then
3810 g_Console_Add(_lc
[OnMsg
])
3812 g_Console_Add(_lc
[OffMsg
]);
3814 if OnMapChange
and g_Game_IsServer
then
3815 g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
3820 cmd
:= LowerCase(P
[0]);
3822 if cmd
= 'g_gamemode' then
3824 if (Length(P
) > 1) then
3826 a
:= g_Game_TextToMode(P
[1]);
3827 if a
= GM_SINGLE
then a
:= GM_COOP
;
3828 gsGameMode
:= g_Game_ModeToText(a
);
3829 if g_Game_IsServer
then
3831 gSwitchGameMode
:= a
;
3832 if (gGameOn
and (gGameSettings
.GameMode
= GM_SINGLE
)) or
3833 (gState
= STATE_INTERSINGLE
) then
3834 gSwitchGameMode
:= GM_SINGLE
;
3836 gGameSettings
.GameMode
:= gSwitchGameMode
;
3840 if gSwitchGameMode
= gGameSettings
.GameMode
then
3841 g_Console_Add(Format(_lc
[I_MSG_GAMEMODE_CURRENT
],
3842 [g_Game_ModeToText(gGameSettings
.GameMode
)]))
3844 g_Console_Add(Format(_lc
[I_MSG_GAMEMODE_CHANGE
],
3845 [g_Game_ModeToText(gGameSettings
.GameMode
),
3846 g_Game_ModeToText(gSwitchGameMode
)]));
3848 else if cmd
= 'g_friendlyfire' then
3850 ParseGameFlag(GAME_OPTION_TEAMDAMAGE
, I_MSG_FRIENDLY_FIRE_OFF
, I_MSG_FRIENDLY_FIRE_ON
);
3852 else if cmd
= 'g_friendly_absorb_damage' then
3854 ParseGameFlag(GAME_OPTION_TEAMABSORBDAMAGE
, I_MSG_FRIENDLY_FIRE_OFF
, I_MSG_FRIENDLY_FIRE_ON
);
3856 else if cmd
= 'g_friendly_hit_trace' then
3858 ParseGameFlag(GAME_OPTION_TEAMHITTRACE
, I_MSG_FRIENDLY_FIRE_OFF
, I_MSG_FRIENDLY_FIRE_ON
);
3860 else if cmd
= 'g_friendly_hit_projectile' then
3862 ParseGameFlag(GAME_OPTION_TEAMHITPROJECTILE
, I_MSG_FRIENDLY_FIRE_OFF
, I_MSG_FRIENDLY_FIRE_ON
);
3864 else if cmd
= 'g_weaponstay' then
3866 ParseGameFlag(GAME_OPTION_WEAPONSTAY
, I_MSG_WEAPONSTAY_OFF
, I_MSG_WEAPONSTAY_ON
);
3868 else if cmd
= 'g_allow_exit' then
3870 ParseGameFlag(GAME_OPTION_ALLOWEXIT
, I_MSG_ALLOWEXIT_OFF
, I_MSG_ALLOWEXIT_ON
, True);
3872 else if cmd
= 'g_allow_monsters' then
3874 ParseGameFlag(GAME_OPTION_MONSTERS
, I_MSG_ALLOWMON_OFF
, I_MSG_ALLOWMON_ON
, True);
3876 else if cmd
= 'g_bot_vsplayers' then
3878 ParseGameFlag(GAME_OPTION_BOTVSPLAYER
, I_MSG_BOTSVSPLAYERS_OFF
, I_MSG_BOTSVSPLAYERS_ON
);
3880 else if cmd
= 'g_bot_vsmonsters' then
3882 ParseGameFlag(GAME_OPTION_BOTVSMONSTER
, I_MSG_BOTSVSMONSTERS_OFF
, I_MSG_BOTSVSMONSTERS_ON
);
3884 else if cmd
= 'g_dm_keys' then
3886 ParseGameFlag(GAME_OPTION_DMKEYS
, I_MSG_DMKEYS_OFF
, I_MSG_DMKEYS_ON
, True);
3888 else if cmd
= 'g_gameflags' then
3890 if Length(P
) > 1 then
3892 gsGameFlags
:= StrToDWordDef(P
[1], gsGameFlags
);
3893 if g_Game_IsServer
then
3895 gGameSettings
.Options
:= gsGameFlags
;
3896 if g_Game_IsNet
then MH_SEND_GameSettings
;
3900 g_Console_Add(Format('%s %u', [cmd
, gsGameFlags
]));
3902 else if cmd
= 'g_warmup_time' then
3904 if Length(P
) > 1 then
3906 gsWarmupTime
:= nclamp(StrToIntDef(P
[1], gsWarmupTime
), 0, $FFFF);
3907 if g_Game_IsServer
then
3909 gGameSettings
.WarmupTime
:= gsWarmupTime
;
3910 // extend warmup if it's already going
3911 if gLMSRespawn
= LMS_RESPAWN_WARMUP
then
3913 gLMSRespawnTime
:= gTime
+ gsWarmupTime
* 1000;
3914 if g_Game_IsNet
then MH_SEND_GameEvent(NET_EV_LMS_WARMUP
, gLMSRespawnTime
- gTime
);
3916 if g_Game_IsNet
then MH_SEND_GameSettings
;
3920 g_Console_Add(Format(_lc
[I_MSG_WARMUP
], [Integer(gsWarmupTime
)]));
3921 if g_Game_IsServer
then g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
3923 else if cmd
= 'g_spawn_invul' then
3925 if Length(P
) > 1 then
3927 gsSpawnInvul
:= nclamp(StrToIntDef(P
[1], gsSpawnInvul
), 0, $FFFF);
3928 if g_Game_IsServer
then
3930 gGameSettings
.SpawnInvul
:= gsSpawnInvul
;
3931 if g_Game_IsNet
then MH_SEND_GameSettings
;
3935 g_Console_Add(Format('%s %d', [cmd
, Integer(gsSpawnInvul
)]));
3937 else if cmd
= 'g_item_respawn_time' then
3939 if Length(P
) > 1 then
3941 gsItemRespawnTime
:= nclamp(StrToIntDef(P
[1], gsItemRespawnTime
), 0, $FFFF);
3942 if g_Game_IsServer
then
3944 gGameSettings
.ItemRespawnTime
:= gsItemRespawnTime
;
3945 if g_Game_IsNet
then MH_SEND_GameSettings
;
3949 g_Console_Add(Format('%s %d', [cmd
, Integer(gsItemRespawnTime
)]));
3950 if g_Game_IsServer
then g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
3952 else if cmd
= 'sv_intertime' then
3954 if (Length(P
) > 1) then
3955 gDefInterTime
:= Min(Max(StrToIntDef(P
[1], gDefInterTime
), -1), 120);
3957 g_Console_Add(cmd
+ ' = ' + IntToStr(gDefInterTime
));
3959 else if cmd
= 'g_max_particles' then
3961 if Length(p
) = 2 then
3964 a
:= Max(0, StrToInt(p
[1]));
3968 else if Length(p
) = 1 then
3971 e_LogWritefln('%s', [g_GFX_GetMax()])
3973 e_LogWritefln('%s', [0])
3978 e_LogWritefln('usage: %s <n>', [cmd
])
3981 else if cmd
= 'g_max_shells' then
3983 if Length(p
) = 2 then
3985 {$IFDEF ENABLE_SHELLS}
3986 a
:= Max(0, StrToInt(p
[1]));
3990 else if Length(p
) = 1 then
3992 {$IFDEF ENABLE_SHELLS}
3993 e_LogWritefln('%s', [g_Shells_GetMax()])
3995 e_LogWritefln('%s', [0])
4000 e_LogWritefln('usage: %s <n>', [cmd
])
4003 else if cmd
= 'g_max_gibs' then
4005 if Length(p
) = 2 then
4007 {$IFDEF ENABLE_GIBS}
4008 a
:= Max(0, StrToInt(p
[1]));
4012 else if Length(p
) = 1 then
4014 {$IFDEF ENABLE_GIBS}
4015 e_LogWritefln('%s', [g_Gibs_GetMax()])
4017 e_LogWritefln('%s', [0])
4022 e_LogWritefln('usage: %s <n>', [cmd
])
4025 else if cmd
= 'g_max_corpses' then
4027 if Length(p
) = 2 then
4029 a
:= Max(0, StrToInt(p
[1]));
4032 else if Length(p
) = 1 then
4034 e_LogWritefln('%s', [g_Corpses_GetMax()])
4038 e_LogWritefln('usage: %s <n>', [cmd
])
4041 else if cmd
= 'g_scorelimit' then
4043 if Length(P
) > 1 then
4045 gsGoalLimit
:= nclamp(StrToIntDef(P
[1], gsGoalLimit
), 0, $FFFF);
4047 if g_Game_IsServer
then
4050 if gGameSettings
.GameMode
= GM_DM
then
4052 stat
:= g_Player_GetStats();
4054 for a
:= 0 to High(stat
) do
4055 if stat
[a
].Frags
> b
then
4059 b
:= Max(gTeamStat
[TEAM_RED
].Goals
, gTeamStat
[TEAM_BLUE
].Goals
);
4061 // if someone has a higher score, set it to that instead
4062 gsGoalLimit
:= max(gsGoalLimit
, b
);
4063 gGameSettings
.GoalLimit
:= gsGoalLimit
;
4065 if g_Game_IsNet
then MH_SEND_GameSettings
;
4069 g_Console_Add(Format(_lc
[I_MSG_SCORE_LIMIT
], [Integer(gsGoalLimit
)]));
4071 else if cmd
= 'g_timelimit' then
4073 if Length(P
) > 1 then
4075 gsTimeLimit
:= nclamp(StrToIntDef(P
[1], gsTimeLimit
), 0, $FFFF);
4076 if g_Game_IsServer
then
4078 gGameSettings
.TimeLimit
:= gsTimeLimit
;
4079 if g_Game_IsNet
then MH_SEND_GameSettings
;
4082 g_Console_Add(Format(_lc
[I_MSG_TIME_LIMIT
],
4083 [gsTimeLimit
div 3600,
4084 (gsTimeLimit
div 60) mod 60,
4085 gsTimeLimit
mod 60]));
4087 else if cmd
= 'g_maxlives' then
4089 if Length(P
) > 1 then
4091 gsMaxLives
:= nclamp(StrToIntDef(P
[1], gsMaxLives
), 0, $FFFF);
4092 if g_Game_IsServer
then
4094 gGameSettings
.MaxLives
:= gsMaxLives
;
4095 if g_Game_IsNet
then MH_SEND_GameSettings
;
4099 g_Console_Add(Format(_lc
[I_MSG_LIVES
], [Integer(gsMaxLives
)]));
4103 procedure PlayerSettingsCVars(P
: SSArray
);
4108 function ParseTeam(s
: string): Byte;
4112 'red', '1': result
:= TEAM_RED
;
4113 'blue', '2': result
:= TEAM_BLUE
;
4114 else result
:= TEAM_NONE
;
4118 cmd
:= LowerCase(P
[0]);
4122 if (Length(P
) > 1) then
4124 gPlayer1Settings
.Name
:= b_Text_Unformat(P
[1]);
4125 if g_Game_IsClient
then
4126 MC_SEND_PlayerSettings
4127 else if gGameOn
and (gPlayer1
<> nil) then
4129 gPlayer1
.Name
:= b_Text_Unformat(P
[1]);
4130 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer1
.UID
);
4136 if (Length(P
) > 1) then
4138 gPlayer2Settings
.Name
:= b_Text_Unformat(P
[1]);
4139 if g_Game_IsClient
then
4140 MC_SEND_PlayerSettings
4141 else if gGameOn
and (gPlayer2
<> nil) then
4143 gPlayer2
.Name
:= b_Text_Unformat(P
[1]);
4144 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer2
.UID
);
4150 if Length(P
) > 3 then
4152 gPlayer1Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
4153 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
4154 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
4155 if g_Game_IsClient
then
4156 MC_SEND_PlayerSettings
4157 else if gGameOn
and (gPlayer1
<> nil) then
4159 gPlayer1
.SetColor(gPlayer1Settings
.Color
);
4160 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer1
.UID
);
4166 if Length(P
) > 3 then
4168 gPlayer2Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
4169 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
4170 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
4171 if g_Game_IsClient
then
4172 MC_SEND_PlayerSettings
4173 else if gGameOn
and (gPlayer2
<> nil) then
4175 gPlayer2
.SetColor(gPlayer2Settings
.Color
);
4176 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer2
.UID
);
4182 if (Length(P
) > 1) then
4184 gPlayer1Settings
.Model
:= P
[1];
4185 if g_Game_IsClient
then
4186 MC_SEND_PlayerSettings
4187 else if gGameOn
and (gPlayer1
<> nil) then
4189 gPlayer1
.FActualModelName
:= gPlayer1Settings
.Model
;
4190 gPlayer1
.SetModel(gPlayer1Settings
.Model
);
4191 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer1
.UID
);
4197 if (Length(P
) > 1) then
4199 gPlayer2Settings
.Model
:= P
[1];
4200 if g_Game_IsClient
then
4201 MC_SEND_PlayerSettings
4202 else if gGameOn
and (gPlayer2
<> nil) then
4204 gPlayer2
.FActualModelName
:= gPlayer2Settings
.Model
;
4205 gPlayer2
.SetModel(gPlayer2Settings
.Model
);
4206 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer2
.UID
);
4212 // TODO: switch teams if in game or store this separately
4213 if (Length(P
) > 1) then
4215 team
:= ParseTeam(P
[1]);
4216 if team
= TEAM_NONE
then
4217 g_Console_Add('expected ''red'', ''blue'', 1 or 2')
4218 else if not gGameOn
and not g_Game_IsNet
then
4219 gPlayer1Settings
.Team
:= team
4221 g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
4226 // TODO: switch teams if in game or store this separately
4227 if (Length(P
) > 1) then
4229 team
:= ParseTeam(P
[1]);
4230 if team
= TEAM_NONE
then
4231 g_Console_Add('expected ''red'', ''blue'', 1 or 2')
4232 else if not gGameOn
and not g_Game_IsNet
then
4233 gPlayer2Settings
.Team
:= team
4235 g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
4241 procedure PrintHeapStats();
4245 hs
:= GetFPCHeapStatus();
4246 e_LogWriteLn ('v===== heap status =====v');
4247 e_LogWriteFln('max heap size = %d k', [hs
.MaxHeapSize
div 1024]);
4248 e_LogWriteFln('max heap used = %d k', [hs
.MaxHeapUsed
div 1024]);
4249 e_LogWriteFln('cur heap size = %d k', [hs
.CurrHeapSize
div 1024]);
4250 e_LogWriteFln('cur heap used = %d k', [hs
.CurrHeapUsed
div 1024]);
4251 e_LogWriteFln('cur heap free = %d k', [hs
.CurrHeapFree
div 1024]);
4252 e_LogWriteLn ('^=======================^');
4255 procedure DebugCommands(P
: SSArray
);
4262 // Команды отладочного режима:
4263 if {gDebugMode}conIsCheatsEnabled
then
4265 cmd
:= LowerCase(P
[0]);
4266 if cmd
= 'd_window' then
4268 g_Console_Add(Format('gScreenWidth = %d, gScreenHeight = %d', [gScreenWidth
, gScreenHeight
]));
4269 g_Console_Add(Format('gScreenWidth = %d, gScreenHeight = %d', [gScreenWidth
, gScreenHeight
]));
4271 else if cmd
= 'd_sounds' then
4273 if (Length(P
) > 1) and
4274 ((P
[1] = '1') or (P
[1] = '0')) then
4275 g_Debug_Sounds
:= (P
[1][1] = '1');
4277 g_Console_Add(Format('d_sounds is %d', [Byte(g_Debug_Sounds
)]));
4279 else if cmd
= 'd_frames' then
4281 if (Length(P
) > 1) and
4282 ((P
[1] = '1') or (P
[1] = '0')) then
4283 g_Debug_Frames
:= (P
[1][1] = '1');
4285 g_Console_Add(Format('d_frames is %d', [Byte(g_Debug_Frames
)]));
4287 else if cmd
= 'd_winmsg' then
4289 if (Length(P
) > 1) and
4290 ((P
[1] = '1') or (P
[1] = '0')) then
4291 g_Debug_WinMsgs
:= (P
[1][1] = '1');
4293 g_Console_Add(Format('d_winmsg is %d', [Byte(g_Debug_WinMsgs
)]));
4295 else if (cmd
= 'd_monoff') and not g_Game_IsNet
then
4297 if (Length(P
) > 1) and
4298 ((P
[1] = '1') or (P
[1] = '0')) then
4299 g_Debug_MonsterOff
:= (P
[1][1] = '1');
4301 g_Console_Add(Format('d_monoff is %d', [Byte(g_debug_MonsterOff
)]));
4303 else if (cmd
= 'd_botoff') and not g_Game_IsNet
then
4305 if Length(P
) > 1 then
4307 '0': g_debug_BotAIOff
:= 0;
4308 '1': g_debug_BotAIOff
:= 1;
4309 '2': g_debug_BotAIOff
:= 2;
4310 '3': g_debug_BotAIOff
:= 3;
4313 g_Console_Add(Format('d_botoff is %d', [g_debug_BotAIOff
]));
4315 else if cmd
= 'd_monster' then
4317 if gGameOn
and (gPlayer1
<> nil) and (gPlayer1
.alive
) and (not g_Game_IsNet
) then
4318 if Length(P
) < 2 then
4320 g_Console_Add(cmd
+ ' [ID | Name] [behaviour]');
4321 g_Console_Add('ID | Name');
4322 for b
:= MONSTER_DEMON
to MONSTER_MAN
do
4323 g_Console_Add(Format('%2d | %s', [b
, g_Mons_NameByTypeId(b
)]));
4324 conwriteln('behav. num'#10'normal 0'#10'killer 1'#10'maniac 2'#10'insane 3'#10'cannibal 4'#10'good 5');
4327 a
:= StrToIntDef(P
[1], 0);
4328 if (a
< MONSTER_DEMON
) or (a
> MONSTER_MAN
) then
4329 a
:= g_Mons_TypeIdByName(P
[1]);
4331 if (a
< MONSTER_DEMON
) or (a
> MONSTER_MAN
) then
4332 g_Console_Add(Format(_lc
[I_MSG_NO_MONSTER
], [P
[1]]))
4335 with gPlayer1
.Obj
do
4337 mon
:= g_Monsters_Create(a
,
4338 X
+ Rect
.X
+ (Rect
.Width
div 2),
4339 Y
+ Rect
.Y
+ Rect
.Height
,
4340 gPlayer1
.Direction
, True);
4342 if (Length(P
) > 2) and (mon
<> nil) then
4344 if (CompareText(P
[2], 'normal') = 0) then mon
.MonsterBehaviour
:= BH_NORMAL
4345 else if (CompareText(P
[2], 'killer') = 0) then mon
.MonsterBehaviour
:= BH_KILLER
4346 else if (CompareText(P
[2], 'maniac') = 0) then mon
.MonsterBehaviour
:= BH_MANIAC
4347 else if (CompareText(P
[2], 'insane') = 0) then mon
.MonsterBehaviour
:= BH_INSANE
4348 else if (CompareText(P
[2], 'cannibal') = 0) then mon
.MonsterBehaviour
:= BH_CANNIBAL
4349 else if (CompareText(P
[2], 'good') = 0) then mon
.MonsterBehaviour
:= BH_GOOD
4350 else if (CompareText(P
[2], 'friend') = 0) then mon
.MonsterBehaviour
:= BH_GOOD
4351 else if (CompareText(P
[2], 'friendly') = 0) then mon
.MonsterBehaviour
:= BH_GOOD
4352 else mon
.MonsterBehaviour
:= Min(Max(StrToIntDef(P
[2], BH_NORMAL
), BH_NORMAL
), BH_GOOD
);
4357 else if (cmd
= 'd_health') then
4359 if (Length(P
) > 1) and
4360 ((P
[1] = '1') or (P
[1] = '0')) then
4361 g_debug_HealthBar
:= (P
[1][1] = '1');
4363 g_Console_Add(Format('d_health is %d', [Byte(g_debug_HealthBar
)]));
4365 else if (cmd
= 'd_player') then
4367 if (Length(P
) > 1) and
4368 ((P
[1] = '1') or (P
[1] = '0')) then
4369 g_debug_Player
:= (P
[1][1] = '1');
4371 g_Console_Add(Format(cmd
+ ' is %d', [Byte(g_Debug_Player
)]));
4373 else if (cmd
= 'd_mem') then
4379 g_Console_Add(_lc
[I_MSG_NOT_DEBUG
]);
4383 procedure GameCheats(P
: SSArray
);
4389 if (not gGameOn
) or (not conIsCheatsEnabled
) then
4391 g_Console_Add('not available');
4397 g_Console_Add('where is the player?!');
4400 cmd
:= LowerCase(P
[0]);
4404 plr
.GodMode
:= not plr
.GodMode
;
4405 if plr
.GodMode
then g_Console_Add('player is godlike now') else g_Console_Add('player is mortal now');
4408 // give <health|exit|weapons|air|suit|jetpack|berserk|all>
4409 if cmd
= 'give' then
4411 if length(P
) < 2 then begin g_Console_Add('give what?!'); exit
; end;
4412 for f
:= 1 to High(P
) do
4414 cmd
:= LowerCase(P
[f
]);
4415 if cmd
= 'health' then begin plr
.RestoreHealthArmor(); g_Console_Add('player feels himself better'); continue
; end;
4416 if (cmd
= 'all') {or (cmd = 'weapons')} then begin plr
.AllRulez(False); g_Console_Add('player got the gifts'); continue
; end;
4417 if cmd
= 'exit' then
4419 if gTriggers
<> nil then
4421 for a
:= 0 to High(gTriggers
) do
4423 if gTriggers
[a
].TriggerType
= TRIGGER_EXIT
then
4425 g_Console_Add('player left the map');
4426 gExitByTrigger
:= True;
4427 //g_Game_ExitLevel(gTriggers[a].Data.MapName);
4428 g_Game_ExitLevel(gTriggers
[a
].tgcMap
);
4436 if cmd
= 'air' then begin plr
.GiveItem(ITEM_OXYGEN
); g_Console_Add('player got some air'); continue
; end;
4437 if cmd
= 'jetpack' then begin plr
.GiveItem(ITEM_JETPACK
); g_Console_Add('player got a jetpack'); continue
; end;
4438 if cmd
= 'suit' then begin plr
.GiveItem(ITEM_SUIT
); g_Console_Add('player got an envirosuit'); continue
; end;
4439 if cmd
= 'berserk' then begin plr
.GiveItem(ITEM_MEDKIT_BLACK
); g_Console_Add('player got a berserk pack'); continue
; end;
4440 if cmd
= 'backpack' then begin plr
.GiveItem(ITEM_AMMO_BACKPACK
); g_Console_Add('player got a backpack'); continue
; end;
4442 if cmd
= 'helmet' then begin plr
.GiveItem(ITEM_HELMET
); g_Console_Add('player got a helmet'); continue
; end;
4443 if cmd
= 'bottle' then begin plr
.GiveItem(ITEM_BOTTLE
); g_Console_Add('player got a bottle of health'); continue
; end;
4445 if cmd
= 'stimpack' then begin plr
.GiveItem(ITEM_MEDKIT_SMALL
); g_Console_Add('player got a stimpack'); continue
; end;
4446 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;
4448 if cmd
= 'greenarmor' then begin plr
.GiveItem(ITEM_ARMOR_GREEN
); g_Console_Add('player got a security armor'); continue
; end;
4449 if cmd
= 'bluearmor' then begin plr
.GiveItem(ITEM_ARMOR_BLUE
); g_Console_Add('player got a combat armor'); continue
; end;
4451 if (cmd
= 'megasphere') or (cmd
= 'mega') then begin plr
.GiveItem(ITEM_SPHERE_BLUE
); g_Console_Add('player got a megasphere'); continue
; end;
4452 if (cmd
= 'soulsphere') or (cmd
= 'soul')then begin plr
.GiveItem(ITEM_SPHERE_WHITE
); g_Console_Add('player got a soul sphere'); continue
; end;
4454 if (cmd
= 'invul') or (cmd
= 'invulnerability') then begin plr
.GiveItem(ITEM_INVUL
); g_Console_Add('player got invulnerability'); continue
; end;
4455 if (cmd
= 'invis') or (cmd
= 'invisibility') then begin plr
.GiveItem(ITEM_INVIS
); g_Console_Add('player got invisibility'); continue
; end;
4457 if cmd
= 'redkey' then begin plr
.GiveItem(ITEM_KEY_RED
); g_Console_Add('player got the red key'); continue
; end;
4458 if cmd
= 'greenkey' then begin plr
.GiveItem(ITEM_KEY_GREEN
); g_Console_Add('player got the green key'); continue
; end;
4459 if cmd
= 'bluekey' then begin plr
.GiveItem(ITEM_KEY_BLUE
); g_Console_Add('player got the blue key'); continue
; end;
4461 if (cmd
= 'shotgun') or (cmd
= 'sg') then begin plr
.GiveItem(ITEM_WEAPON_SHOTGUN1
); g_Console_Add('player got a shotgun'); continue
; end;
4462 if (cmd
= 'supershotgun') or (cmd
= 'ssg') then begin plr
.GiveItem(ITEM_WEAPON_SHOTGUN2
); g_Console_Add('player got a supershotgun'); continue
; end;
4463 if cmd
= 'chaingun' then begin plr
.GiveItem(ITEM_WEAPON_CHAINGUN
); g_Console_Add('player got a chaingun'); continue
; end;
4464 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;
4465 if cmd
= 'plasmagun' then begin plr
.GiveItem(ITEM_WEAPON_PLASMA
); g_Console_Add('player got a plasma gun'); continue
; end;
4466 if cmd
= 'bfg' then begin plr
.GiveItem(ITEM_WEAPON_BFG
); g_Console_Add('player got a BFG-9000'); continue
; end;
4468 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;
4469 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;
4470 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;
4471 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;
4472 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;
4473 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;
4475 if cmd
= 'superchaingun' then begin plr
.GiveItem(ITEM_WEAPON_SUPERPULEMET
); g_Console_Add('player got a superchaingun'); continue
; end;
4476 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;
4478 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;
4479 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;
4481 if cmd
= 'chainsaw' then begin plr
.GiveItem(ITEM_WEAPON_SAW
); g_Console_Add('player got a chainsaw'); continue
; end;
4483 if cmd
= 'ammo' then
4485 plr
.GiveItem(ITEM_AMMO_SHELLS_BOX
);
4486 plr
.GiveItem(ITEM_AMMO_BULLETS_BOX
);
4487 plr
.GiveItem(ITEM_AMMO_CELL_BIG
);
4488 plr
.GiveItem(ITEM_AMMO_ROCKET_BOX
);
4489 plr
.GiveItem(ITEM_AMMO_FUELCAN
);
4490 g_Console_Add('player got some ammo');
4494 if cmd
= 'clip' then begin plr
.GiveItem(ITEM_AMMO_BULLETS
); g_Console_Add('player got some bullets'); continue
; end;
4495 if cmd
= 'bullets' then begin plr
.GiveItem(ITEM_AMMO_BULLETS_BOX
); g_Console_Add('player got a box of bullets'); continue
; end;
4497 if cmd
= 'shells' then begin plr
.GiveItem(ITEM_AMMO_SHELLS
); g_Console_Add('player got some shells'); continue
; end;
4498 if cmd
= 'shellbox' then begin plr
.GiveItem(ITEM_AMMO_SHELLS_BOX
); g_Console_Add('player got a box of shells'); continue
; end;
4500 if cmd
= 'cells' then begin plr
.GiveItem(ITEM_AMMO_CELL
); g_Console_Add('player got some cells'); continue
; end;
4501 if cmd
= 'battery' then begin plr
.GiveItem(ITEM_AMMO_CELL_BIG
); g_Console_Add('player got cell battery'); continue
; end;
4503 if cmd
= 'rocket' then begin plr
.GiveItem(ITEM_AMMO_ROCKET
); g_Console_Add('player got a rocket'); continue
; end;
4504 if cmd
= 'rocketbox' then begin plr
.GiveItem(ITEM_AMMO_ROCKET_BOX
); g_Console_Add('player got some rockets'); continue
; end;
4506 if (cmd
= 'fuel') or (cmd
= 'fuelcan') then begin plr
.GiveItem(ITEM_AMMO_FUELCAN
); g_Console_Add('player got fuel canister'); continue
; end;
4508 if cmd
= 'weapons' then
4510 plr
.GiveItem(ITEM_WEAPON_SHOTGUN1
);
4511 plr
.GiveItem(ITEM_WEAPON_SHOTGUN2
);
4512 plr
.GiveItem(ITEM_WEAPON_CHAINGUN
);
4513 plr
.GiveItem(ITEM_WEAPON_ROCKETLAUNCHER
);
4514 plr
.GiveItem(ITEM_WEAPON_PLASMA
);
4515 plr
.GiveItem(ITEM_WEAPON_BFG
);
4516 g_Console_Add('player got weapons');
4520 if cmd
= 'keys' then
4522 plr
.GiveItem(ITEM_KEY_RED
);
4523 plr
.GiveItem(ITEM_KEY_GREEN
);
4524 plr
.GiveItem(ITEM_KEY_BLUE
);
4525 g_Console_Add('player got all keys');
4529 g_Console_Add('i don''t know how to give '''+cmd
+'''!');
4534 if cmd
= 'open' then
4536 g_Console_Add('player activated sesame');
4537 g_Triggers_OpenAll();
4544 if gFly
then g_Console_Add('player feels himself lighter') else g_Console_Add('player lost his wings');
4548 if cmd
= 'noclip' then
4551 g_Console_Add('wall hardeness adjusted');
4555 if cmd
= 'notarget' then
4557 plr
.NoTarget
:= not plr
.NoTarget
;
4558 if plr
.NoTarget
then g_Console_Add('player hides in shadows') else g_Console_Add('player is brave again');
4562 if cmd
= 'noreload' then
4564 plr
.NoReload
:= not plr
.NoReload
;
4565 if plr
.NoReload
then g_Console_Add('player is action hero now') else g_Console_Add('player is ordinary man now');
4569 if cmd
= 'speedy' then
4571 MAX_RUNVEL
:= 32-MAX_RUNVEL
;
4572 g_Console_Add('speed adjusted');
4576 if cmd
= 'jumpy' then
4578 VEL_JUMP
:= 30-VEL_JUMP
;
4579 g_Console_Add('jump height adjusted');
4583 if cmd
= 'automap' then
4585 gShowMap
:= not gShowMap
;
4586 if gShowMap
then g_Console_Add('player gains second sight') else g_Console_Add('player lost second sight');
4590 if cmd
= 'aimline' then
4592 gAimLine
:= not gAimLine
;
4593 if gAimLine
then g_Console_Add('player gains laser sight') else g_Console_Add('player lost laser sight');
4598 procedure GameCommands(P
: SSArray
);
4604 pl
: pTNetClient
= nil;
4612 cmd
:= LowerCase(P
[0]);
4614 if cmd
= 'pause' then
4616 {$IFDEF ENABLE_MENU}
4617 if (g_ActiveWindow
= nil) then
4618 g_Game_Pause(not gPauseMain
);
4620 g_Game_Pause(not gPauseMain
);
4623 else if cmd
= 'endgame' then
4624 gExit
:= EXIT_SIMPLE
4625 else if cmd
= 'restart' then
4627 if gGameOn
or (gState
in [STATE_INTERSINGLE
, STATE_INTERCUSTOM
]) then
4629 if g_Game_IsClient
then
4631 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4636 g_Console_Add(_lc
[I_MSG_NOT_GAME
]);
4638 else if cmd
= 'kick' then
4640 if g_Game_IsServer
then
4642 if Length(P
) < 2 then
4644 g_Console_Add('kick <name>');
4649 g_Console_Add('kick <name>');
4653 if g_Game_IsNet
then
4654 pl
:= g_Net_Client_ByName(P
[1]);
4657 s
:= g_Net_ClientName_ByID(pl
^.ID
);
4658 enet_peer_disconnect(pl
^.Peer
, NET_DISC_KICK
);
4659 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
4660 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
4661 g_Net_Slist_ServerPlayerLeaves();
4662 end else if gPlayers
<> nil then
4663 for a
:= Low(gPlayers
) to High(gPlayers
) do
4664 if gPlayers
[a
] <> nil then
4665 if Copy(LowerCase(gPlayers
[a
].Name
), 1, Length(P
[1])) = LowerCase(P
[1]) then
4667 // Не отключать основных игроков в сингле
4668 if not(gPlayers
[a
] is TBot
) and (gGameSettings
.GameType
= GT_SINGLE
) then
4670 gPlayers
[a
].Lives
:= 0;
4671 gPlayers
[a
].Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
4672 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [gPlayers
[a
].Name
]), True);
4673 g_Player_Remove(gPlayers
[a
].UID
);
4674 g_Net_Slist_ServerPlayerLeaves();
4675 // Если не перемешать, при добавлении новых ботов появятся старые
4679 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
4681 else if cmd
= 'kick_id' then
4683 if g_Game_IsServer
and g_Game_IsNet
then
4685 if Length(P
) < 2 then
4687 g_Console_Add('kick_id <client ID>');
4692 g_Console_Add('kick_id <client ID>');
4696 a
:= StrToIntDef(P
[1], 0);
4697 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
4699 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
4701 s
:= g_Net_ClientName_ByID(NetClients
[a
].ID
);
4702 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_KICK
);
4703 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
4704 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
4705 g_Net_Slist_ServerPlayerLeaves();
4709 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4711 else if cmd
= 'kick_pid' then
4713 if g_Game_IsServer
and g_Game_IsNet
then
4715 if Length(P
) < 2 then
4717 g_Console_Add('kick_pid <player ID>');
4722 g_Console_Add('kick_pid <player ID>');
4726 a
:= StrToIntDef(P
[1], 0);
4727 pl
:= g_Net_Client_ByPlayer(a
);
4728 if (pl
<> nil) and pl
^.Used
and (pl
^.Peer
<> nil) then
4730 s
:= g_Net_ClientName_ByID(pl
^.ID
);
4731 enet_peer_disconnect(pl
^.Peer
, NET_DISC_KICK
);
4732 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
4733 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
4734 g_Net_Slist_ServerPlayerLeaves();
4737 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4739 else if cmd
= 'ban' then
4741 if g_Game_IsServer
and g_Game_IsNet
then
4743 if Length(P
) < 2 then
4745 g_Console_Add('ban <name>');
4750 g_Console_Add('ban <name>');
4754 pl
:= g_Net_Client_ByName(P
[1]);
4757 s
:= g_Net_ClientName_ByID(pl
^.ID
);
4758 g_Net_BanHost(pl
^.Peer
^.address
.host
, False);
4759 enet_peer_disconnect(pl
^.Peer
, NET_DISC_TEMPBAN
);
4760 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
4761 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
4762 g_Net_Slist_ServerPlayerLeaves();
4764 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
4766 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4768 else if cmd
= 'ban_id' then
4770 if g_Game_IsServer
and g_Game_IsNet
then
4772 if Length(P
) < 2 then
4774 g_Console_Add('ban_id <client ID>');
4779 g_Console_Add('ban_id <client ID>');
4783 a
:= StrToIntDef(P
[1], 0);
4784 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
4785 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
4787 s
:= g_Net_ClientName_ByID(NetClients
[a
].ID
);
4788 g_Net_BanHost(NetClients
[a
].Peer
^.address
.host
, False);
4789 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_TEMPBAN
);
4790 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
4791 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
4792 g_Net_Slist_ServerPlayerLeaves();
4795 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4797 else if cmd
= 'ban_pid' then
4799 if g_Game_IsServer
and g_Game_IsNet
then
4801 if Length(P
) < 2 then
4803 g_Console_Add('ban_pid <player ID>');
4808 g_Console_Add('ban_pid <player ID>');
4812 a
:= StrToIntDef(P
[1], 0);
4813 pl
:= g_Net_Client_ByPlayer(a
);
4814 if (pl
<> nil) and pl
^.Used
and (pl
^.Peer
<> nil) then
4816 s
:= g_Net_ClientName_ByID(pl
^.ID
);
4817 g_Net_BanHost(pl
^.Peer
^.address
.host
, False);
4818 enet_peer_disconnect(pl
^.Peer
, NET_DISC_TEMPBAN
);
4819 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
4820 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
4821 g_Net_Slist_ServerPlayerLeaves();
4824 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4826 else if cmd
= 'permban' then
4828 if g_Game_IsServer
and g_Game_IsNet
then
4830 if Length(P
) < 2 then
4832 g_Console_Add('permban <name>');
4837 g_Console_Add('permban <name>');
4841 pl
:= g_Net_Client_ByName(P
[1]);
4844 s
:= g_Net_ClientName_ByID(pl
^.ID
);
4845 g_Net_BanHost(pl
^.Peer
^.address
.host
);
4846 enet_peer_disconnect(pl
^.Peer
, NET_DISC_BAN
);
4847 g_Net_SaveBanList();
4848 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
4849 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
4850 g_Net_Slist_ServerPlayerLeaves();
4852 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
4854 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4856 else if cmd
= 'permban_id' then
4858 if g_Game_IsServer
and g_Game_IsNet
then
4860 if Length(P
) < 2 then
4862 g_Console_Add('permban_id <client ID>');
4867 g_Console_Add('permban_id <client ID>');
4871 a
:= StrToIntDef(P
[1], 0);
4872 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
4873 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
4875 s
:= g_Net_ClientName_ByID(NetClients
[a
].ID
);
4876 g_Net_BanHost(NetClients
[a
].Peer
^.address
.host
);
4877 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_BAN
);
4878 g_Net_SaveBanList();
4879 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
4880 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
4881 g_Net_Slist_ServerPlayerLeaves();
4884 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4886 else if cmd
= 'permban_pid' then
4888 if g_Game_IsServer
and g_Game_IsNet
then
4890 if Length(P
) < 2 then
4892 g_Console_Add('permban_pid <player ID>');
4897 g_Console_Add('permban_pid <player ID>');
4901 a
:= StrToIntDef(P
[1], 0);
4902 pl
:= g_Net_Client_ByPlayer(a
);
4903 if (pl
<> nil) and pl
^.Used
and (pl
^.Peer
<> nil) then
4905 s
:= g_Net_ClientName_ByID(pl
^.ID
);
4906 g_Net_BanHost(pl
^.Peer
^.address
.host
);
4907 enet_peer_disconnect(pl
^.Peer
, NET_DISC_BAN
);
4908 g_Net_SaveBanList();
4909 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
4910 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
4911 g_Net_Slist_ServerPlayerLeaves();
4914 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4916 else if cmd
= 'permban_ip' then
4918 if g_Game_IsServer
and g_Game_IsNet
then
4920 if Length(P
) < 2 then
4922 g_Console_Add('permban_ip <IP address>');
4927 g_Console_Add('permban_ip <IP address>');
4931 g_Net_BanHost(P
[1]);
4932 g_Net_SaveBanList();
4933 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [P
[1]]));
4935 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4937 else if cmd
= 'unban' then
4939 if g_Game_IsServer
and g_Game_IsNet
then
4941 if Length(P
) < 2 then
4943 g_Console_Add('unban <IP Address>');
4948 g_Console_Add('unban <IP Address>');
4952 if g_Net_UnbanHost(P
[1]) then
4954 g_Console_Add(Format(_lc
[I_MSG_UNBAN_OK
], [P
[1]]));
4955 g_Net_SaveBanList();
4957 g_Console_Add(Format(_lc
[I_MSG_UNBAN_FAIL
], [P
[1]]));
4959 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4961 else if cmd
= 'clientlist' then
4963 if g_Game_IsServer
and g_Game_IsNet
then
4966 if NetClients
<> nil then
4967 for a
:= Low(NetClients
) to High(NetClients
) do
4968 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
4970 plr
:= g_Player_Get(NetClients
[a
].Player
);
4971 if plr
= nil then continue
;
4973 g_Console_Add(Format('#%2d: %-15s | %s', [a
,
4974 IpToStr(NetClients
[a
].Peer
^.address
.host
), plr
.Name
]));
4977 g_Console_Add(_lc
[I_MSG_NOCLIENTS
]);
4979 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4981 else if cmd
= 'connect' then
4983 if (NetMode
= NET_NONE
) then
4985 if Length(P
) < 2 then
4987 g_Console_Add('connect <IP> [port] [password]');
4992 g_Console_Add('connect <IP> [port] [password]');
4996 if Length(P
) > 2 then
4997 prt
:= StrToIntDef(P
[2], 25666)
5001 if Length(P
) > 3 then
5006 g_Game_StartClient(P
[1], prt
, pw
);
5009 else if cmd
= 'disconnect' then
5011 if (NetMode
= NET_CLIENT
) then
5014 else if cmd
= 'reconnect' then
5016 if (NetMode
= NET_SERVER
) then
5019 if (NetMode
= NET_CLIENT
) then
5022 gExit
:= EXIT_SIMPLE
;
5026 //TODO: Use last successful password to reconnect, instead of ''
5027 g_Game_StartClient(NetClientIP
, NetClientPort
, '');
5029 else if (cmd
= 'addbot') or
5030 (cmd
= 'bot_add') then
5032 if Length(P
) > 2 then
5033 g_Bot_Add(TEAM_NONE
, StrToIntDef(P
[1], 2), StrToIntDef(P
[2], 100))
5034 else if Length(P
) > 1 then
5035 g_Bot_Add(TEAM_NONE
, StrToIntDef(P
[1], 2))
5037 g_Bot_Add(TEAM_NONE
, 2);
5039 else if cmd
= 'bot_addlist' then
5041 if Length(P
) > 1 then
5043 if Length(P
) = 2 then
5044 g_Bot_AddList(TEAM_NONE
, P
[1], StrToIntDef(P
[1], -1))
5045 else if Length(P
) = 3 then
5046 g_Bot_AddList(TEAM_NONE
, P
[1], StrToIntDef(P
[1], -1), StrToIntDef(P
[2], 100))
5048 g_Bot_AddList(IfThen(P
[2] = 'red', TEAM_RED
, TEAM_BLUE
), P
[1], StrToIntDef(P
[1], -1));
5051 else if cmd
= 'bot_removeall' then
5053 else if cmd
= 'chat' then
5055 if g_Game_IsNet
then
5057 if Length(P
) > 1 then
5059 for a
:= 1 to High(P
) do
5060 chstr
:= chstr
+ P
[a
] + ' ';
5062 if Length(chstr
) > 200 then SetLength(chstr
, 200);
5064 if Length(chstr
) < 1 then
5066 g_Console_Add('chat <text>');
5070 chstr
:= b_Text_Format(chstr
);
5071 if g_Game_IsClient
then
5072 MC_SEND_Chat(chstr
, NET_CHAT_PLAYER
)
5074 MH_SEND_Chat(gPlayer1Settings
.Name
+ ': ' + chstr
, NET_CHAT_PLAYER
);
5077 g_Console_Add('chat <text>');
5079 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
5081 else if cmd
= 'teamchat' then
5083 if g_Game_IsNet
and (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
5085 if Length(P
) > 1 then
5087 for a
:= 1 to High(P
) do
5088 chstr
:= chstr
+ P
[a
] + ' ';
5090 if Length(chstr
) > 200 then SetLength(chstr
, 200);
5092 if Length(chstr
) < 1 then
5094 g_Console_Add('teamchat <text>');
5098 chstr
:= b_Text_Format(chstr
);
5099 if g_Game_IsClient
then
5100 MC_SEND_Chat(chstr
, NET_CHAT_TEAM
)
5102 MH_SEND_Chat(gPlayer1Settings
.Name
+ ': ' + chstr
, NET_CHAT_TEAM
,
5103 gPlayer1Settings
.Team
);
5106 g_Console_Add('teamchat <text>');
5108 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
5110 else if cmd
= 'game' then
5112 if gGameSettings
.GameType
<> GT_NONE
then
5114 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
5117 if Length(P
) = 1 then
5119 g_Console_Add(cmd
+ ' <WAD> [MAP] [# players]');
5122 // game not started yet, load fist map from some wad
5124 s
:= addWadExtension(P
[1]);
5125 found
:= e_FindResource(AllMapDirs
, s
);
5129 P
[1] := ExpandFileName(P
[1]);
5130 // if map not choosed then set first map
5131 if Length(P
) < 3 then
5134 P
[2] := g_Game_GetFirstMap(P
[1]);
5137 s
:= P
[1] + ':\' + UpperCase(P
[2]);
5139 if g_Map_Exist(s
) then
5143 with gGameSettings
do
5145 Options
:= gsGameFlags
;
5146 GameMode
:= g_Game_TextToMode(gsGameMode
);
5147 if gSwitchGameMode
<> GM_NONE
then
5148 GameMode
:= gSwitchGameMode
;
5149 if GameMode
= GM_NONE
then GameMode
:= GM_DM
;
5150 if GameMode
= GM_SINGLE
then GameMode
:= GM_COOP
;
5152 if Length(P
) >= 4 then
5153 b
:= StrToIntDef(P
[3], 1);
5154 g_Game_StartCustom(s
, GameMode
, TimeLimit
,
5155 GoalLimit
, MaxLives
, Options
, b
);
5160 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
5162 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [UpperCase(P
[2]), P
[1]]));
5164 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]));
5166 else if cmd
= 'host' then
5168 if gGameSettings
.GameType
<> GT_NONE
then
5170 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
5173 if Length(P
) < 4 then
5175 g_Console_Add(cmd
+ ' <listen IP> <port> <WAD> [MAP] [# players]');
5178 if not StrToIp(P
[1], listen
) then
5180 prt
:= StrToIntDef(P
[2], 25666);
5182 s
:= addWadExtension(P
[3]);
5183 found
:= e_FindResource(AllMapDirs
, s
);
5187 // get first map in wad, if not specified
5188 if Length(P
) < 5 then
5191 P
[4] := g_Game_GetFirstMap(P
[1]);
5193 s
:= P
[3] + ':\' + UpperCase(P
[4]);
5194 if g_Map_Exist(s
) then
5198 with gGameSettings
do
5200 Options
:= gsGameFlags
;
5201 GameMode
:= g_Game_TextToMode(gsGameMode
);
5202 if gSwitchGameMode
<> GM_NONE
then GameMode
:= gSwitchGameMode
;
5203 if GameMode
= GM_NONE
then GameMode
:= GM_DM
;
5204 if GameMode
= GM_SINGLE
then GameMode
:= GM_COOP
;
5206 if Length(P
) >= 6 then
5207 b
:= StrToIntDef(P
[5], 0);
5208 g_Game_StartServer(s
, GameMode
, TimeLimit
, GoalLimit
, MaxLives
, Options
, b
, listen
, prt
)
5214 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[3]]))
5216 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [UpperCase(P
[4]), P
[3]]))
5221 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[3]]))
5224 else if cmd
= 'map' then
5226 if Length(P
) = 1 then
5228 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
5230 g_Console_Add(cmd
+ ' <MAP>');
5231 g_Console_Add(cmd
+ ' <WAD> [MAP]')
5235 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
])
5240 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
5242 if Length(P
) < 3 then
5244 // first param is map or wad
5245 s
:= UpperCase(P
[1]);
5246 if g_Map_Exist(gGameSettings
.WAD
+ ':\' + s
) then
5248 gExitByTrigger
:= False;
5251 // already in game, finish current map
5253 gExit
:= EXIT_ENDLEVELCUSTOM
;
5257 // intermission, so change map immediately
5264 found
:= e_FindResource(AllMapDirs
, s
);
5266 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [s
, 'WAD ' + P
[1]]));
5269 // no such map, found wad
5272 P
[1] := ExpandFileName(pw
);
5273 P
[2] := g_Game_GetFirstMap(P
[1]);
5274 s
:= P
[1] + ':\' + P
[2];
5275 if g_Map_Exist(s
) then
5277 gExitByTrigger
:= False;
5280 // already in game, finish current map
5282 gExit
:= EXIT_ENDLEVELCUSTOM
5286 // intermission, so change map immediately
5293 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
5295 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]))
5300 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]))
5306 s
:= addWadExtension(P
[1]);
5307 found
:= e_FindResource(AllMapDirs
, s
);
5311 P
[2] := UpperCase(P
[2]);
5312 s
:= P
[1] + ':\' + P
[2];
5313 if g_Map_Exist(s
) then
5315 gExitByTrigger
:= False;
5319 gExit
:= EXIT_ENDLEVELCUSTOM
5328 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]))
5333 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]))
5339 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
])
5343 else if cmd
= 'nextmap' then
5345 if not(gGameOn
or (gState
= STATE_INTERCUSTOM
)) then
5347 g_Console_Add(_lc
[I_MSG_NOT_GAME
])
5352 if Length(P
) = 1 then
5354 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
5356 g_Console_Add(cmd
+ ' <MAP>');
5357 g_Console_Add(cmd
+ ' <WAD> [MAP]');
5362 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
5368 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
5370 if Length(P
) < 3 then
5372 // first param is map or wad
5373 s
:= UpperCase(P
[1]);
5374 if g_Map_Exist(gGameSettings
.WAD
+ ':\' + s
) then
5377 gExitByTrigger
:= False;
5383 // no such map, found wad
5384 pw
:= addWadExtension(P
[1]);
5385 found
:= e_FindResource(MapDirs
, pw
);
5387 found
:= e_FindResource(WadDirs
, pw
);
5389 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [s
, P
[1]]));
5392 // map not specified, select first map
5394 P
[2] := g_Game_GetFirstMap(P
[1]);
5395 s
:= P
[1] + ':\' + P
[2];
5396 if g_Map_Exist(s
) then
5398 gExitByTrigger
:= False;
5405 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
5407 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]))
5412 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]))
5418 // specified two params wad + map
5419 pw
:= addWadExtension(P
[1]);
5420 found
:= e_FindResource(MapDirs
, pw
);
5422 found
:= e_FindResource(MapDirs
, pw
);
5426 P
[2] := UpperCase(P
[2]);
5427 s
:= P
[1] + ':\' + P
[2];
5428 if g_Map_Exist(s
) then
5430 gExitByTrigger
:= False;
5436 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]))
5441 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]))
5447 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
])
5452 if gNextMap
= '' then
5453 g_Console_Add(_lc
[I_MSG_NEXTMAP_UNSET
])
5455 g_Console_Add(Format(_lc
[I_MSG_NEXTMAP_SET
], [gNextMap
]))
5459 else if (cmd
= 'endmap') or (cmd
= 'goodbye') then
5463 g_Console_Add(_lc
[I_MSG_NOT_GAME
])
5467 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
5469 gExitByTrigger
:= False;
5470 // next map not specified, try to find trigger EXIT
5471 if (gNextMap
= '') and (gTriggers
<> nil) then
5473 for a
:= 0 to High(gTriggers
) do
5475 if gTriggers
[a
].TriggerType
= TRIGGER_EXIT
then
5477 gExitByTrigger
:= True;
5478 //gNextMap := gTriggers[a].Data.MapName;
5479 gNextMap
:= gTriggers
[a
].tgcMap
;
5484 if gNextMap
= '' then
5485 gNextMap
:= g_Game_GetNextMap();
5486 if not isWadPath(gNextMap
) then
5487 s
:= gGameSettings
.WAD
+ ':\' + gNextMap
5490 if g_Map_Exist(s
) then
5491 gExit
:= EXIT_ENDLEVELCUSTOM
5493 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [gNextMap
]))
5497 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
])
5501 else if (cmd
= 'event') then
5503 if (Length(P
) <= 1) then
5505 for a
:= 0 to High(gEvents
) do
5506 if gEvents
[a
].Command
= '' then
5507 g_Console_Add(gEvents
[a
].Name
+ ' <none>')
5509 g_Console_Add(gEvents
[a
].Name
+ ' "' + gEvents
[a
].Command
+ '"');
5512 if (Length(P
) = 2) then
5514 for a
:= 0 to High(gEvents
) do
5515 if gEvents
[a
].Name
= P
[1] then
5516 if gEvents
[a
].Command
= '' then
5517 g_Console_Add(gEvents
[a
].Name
+ ' <none>')
5519 g_Console_Add(gEvents
[a
].Name
+ ' "' + gEvents
[a
].Command
+ '"');
5522 for a
:= 0 to High(gEvents
) do
5523 if gEvents
[a
].Name
= P
[1] then
5525 gEvents
[a
].Command
:= '';
5526 for b
:= 2 to High(P
) do
5527 if Pos(' ', P
[b
]) = 0 then
5528 gEvents
[a
].Command
:= gEvents
[a
].Command
+ ' ' + P
[b
]
5530 gEvents
[a
].Command
:= gEvents
[a
].Command
+ ' "' + P
[b
] + '"';
5531 gEvents
[a
].Command
:= Trim(gEvents
[a
].Command
);
5535 else if cmd
= 'suicide' then
5539 if g_Game_IsClient
then
5540 MC_SEND_CheatRequest(NET_CHEAT_SUICIDE
)
5543 if gPlayer1
<> nil then
5544 gPlayer1
.Damage(SUICIDE_DAMAGE
, gPlayer1
.UID
, 0, 0, HIT_SELF
);
5545 if gPlayer2
<> nil then
5546 gPlayer2
.Damage(SUICIDE_DAMAGE
, gPlayer2
.UID
, 0, 0, HIT_SELF
);
5550 else if cmd
= 'screenshot' then
5556 else if cmd
= 'weapon' then
5558 if Length(p
) = 2 then
5560 a
:= WP_FIRST
+ StrToInt(p
[1]) - 1;
5561 if (a
>= WP_FIRST
) and (a
<= WP_LAST
) then
5562 gSelectWeapon
[0, a
] := True
5565 else if (cmd
= 'p1_weapon') or (cmd
= 'p2_weapon') then
5567 if Length(p
) = 2 then
5569 a
:= WP_FIRST
+ StrToInt(p
[1]) - 1;
5570 b
:= ord(cmd
[2]) - ord('1');
5571 if (a
>= WP_FIRST
) and (a
<= WP_LAST
) then
5572 gSelectWeapon
[b
, a
] := True
5575 // Команды Своей игры:
5576 else if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
5578 if cmd
= 'bot_addred' then
5580 if Length(P
) > 1 then
5581 g_Bot_Add(TEAM_RED
, StrToIntDef(P
[1], 2))
5583 g_Bot_Add(TEAM_RED
, 2);
5585 else if cmd
= 'bot_addblue' then
5587 if Length(P
) > 1 then
5588 g_Bot_Add(TEAM_BLUE
, StrToIntDef(P
[1], 2))
5590 g_Bot_Add(TEAM_BLUE
, 2);
5592 else if cmd
= 'spectate' then
5598 else if cmd
= 'say' then
5600 if g_Game_IsServer
and g_Game_IsNet
then
5602 if Length(P
) > 1 then
5605 for a
:= 1 to High(P
) do
5606 chstr
:= chstr
+ P
[a
] + ' ';
5608 if Length(chstr
) > 200 then SetLength(chstr
, 200);
5610 if Length(chstr
) < 1 then
5612 g_Console_Add('say <text>');
5616 chstr
:= b_Text_Format(chstr
);
5617 MH_SEND_Chat(chstr
, NET_CHAT_PLAYER
);
5619 else g_Console_Add('say <text>');
5621 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
5623 else if cmd
= 'tell' then
5625 if g_Game_IsServer
and g_Game_IsNet
then
5627 if (Length(P
) > 2) and (P
[1] <> '') then
5630 for a
:= 2 to High(P
) do
5631 chstr
:= chstr
+ P
[a
] + ' ';
5633 if Length(chstr
) > 200 then SetLength(chstr
, 200);
5635 if Length(chstr
) < 1 then
5637 g_Console_Add('tell <playername> <text>');
5641 pl
:= g_Net_Client_ByName(P
[1]);
5643 MH_SEND_Chat(b_Text_Format(chstr
), NET_CHAT_PLAYER
, pl
^.ID
)
5645 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
5647 else g_Console_Add('tell <playername> <text>');
5649 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
5651 else if cmd
= 'centerprint' then
5653 if (Length(P
) > 2) and (P
[1] <> '') then
5656 for a
:= 2 to High(P
) do
5657 chstr
:= chstr
+ P
[a
] + ' ';
5659 if Length(chstr
) > 200 then SetLength(chstr
, 200);
5661 if Length(chstr
) < 1 then
5663 g_Console_Add('centerprint <timeout> <text>');
5667 a
:= StrToIntDef(P
[1], 100);
5668 chstr
:= b_Text_Format(chstr
);
5669 g_Game_Message(chstr
, a
);
5670 if g_Game_IsNet
and g_Game_IsServer
then
5671 MH_SEND_GameEvent(NET_EV_BIGTEXT
, a
, chstr
);
5673 else g_Console_Add('centerprint <timeout> <text>');
5675 else if (cmd
= 'overtime') and not g_Game_IsClient
then
5677 if (Length(P
) = 1) or (StrToIntDef(P
[1], -1) <= 0) then
5679 // Дополнительное время:
5680 gGameSettings
.TimeLimit
:= (gTime
- gGameStartTime
) div 1000 + Word(StrToIntDef(P
[1], 0));
5682 g_Console_Add(Format(_lc
[I_MSG_TIME_LIMIT
],
5683 [gGameSettings
.TimeLimit
div 3600,
5684 (gGameSettings
.TimeLimit
div 60) mod 60,
5685 gGameSettings
.TimeLimit
mod 60]));
5686 if g_Game_IsNet
then MH_SEND_GameSettings
;
5688 else if (cmd
= 'rcon_password') and g_Game_IsClient
then
5690 if (Length(P
) <= 1) then
5691 g_Console_Add('rcon_password <password>')
5693 MC_SEND_RCONPassword(P
[1]);
5695 else if cmd
= 'rcon' then
5697 if g_Game_IsClient
then
5699 if Length(P
) > 1 then
5702 for a
:= 1 to High(P
) do
5703 chstr
:= chstr
+ P
[a
] + ' ';
5705 if Length(chstr
) > 200 then SetLength(chstr
, 200);
5707 if Length(chstr
) < 1 then
5709 g_Console_Add('rcon <command>');
5713 MC_SEND_RCONCommand(chstr
);
5715 else g_Console_Add('rcon <command>');
5718 else if cmd
= 'ready' then
5720 if g_Game_IsServer
and (gLMSRespawn
= LMS_RESPAWN_WARMUP
) then
5721 gLMSRespawnTime
:= gTime
+ 100;
5723 else if (cmd
= 'callvote') and g_Game_IsNet
then
5725 if Length(P
) > 1 then
5728 for a
:= 1 to High(P
) do begin
5729 if a
> 1 then chstr
:= chstr
+ ' ';
5730 chstr
:= chstr
+ P
[a
];
5733 if Length(chstr
) > 200 then SetLength(chstr
, 200);
5735 if Length(chstr
) < 1 then
5737 g_Console_Add('callvote <command>');
5741 if g_Game_IsClient
then
5742 MC_SEND_Vote(True, chstr
)
5744 g_Game_StartVote(chstr
, gPlayer1Settings
.Name
);
5745 g_Console_Process('vote', True);
5748 g_Console_Add('callvote <command>');
5750 else if (cmd
= 'vote') and g_Game_IsNet
then
5752 if g_Game_IsClient
then
5754 else if gVoteInProgress
then
5756 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
5757 a
:= Floor((NetClientCount
+1)/2.0) + 1
5759 a
:= Floor(NetClientCount
/2.0) + 1;
5764 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_REVOKED
], [gPlayer1Settings
.Name
, gVoteCount
, a
]), True);
5765 MH_SEND_VoteEvent(NET_VE_REVOKE
, gPlayer1Settings
.Name
, 'a', gVoteCount
, a
);
5771 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_VOTE
], [gPlayer1Settings
.Name
, gVoteCount
, a
]), True);
5772 MH_SEND_VoteEvent(NET_VE_VOTE
, gPlayer1Settings
.Name
, 'a', gVoteCount
, a
);
5780 procedure SystemCommands(P
: SSArray
);
5784 cmd
:= LowerCase(P
[0]);
5797 if Length(p
) = 2 then
5799 gMaxFPS
:= StrToIntDef(p
[1], gMaxFPS
);
5801 gFrameTime
:= 1000 div gMaxFPS
5805 e_LogWritefln('r_maxfps %d', [gMaxFPS
]);
5809 if Length(p
) = 2 then
5811 gAskLanguage
:= true;
5812 gLanguage
:= LANGUAGE_ENGLISH
;
5813 case LowerCase(p
[1]) of
5816 gAskLanguage
:= false;
5817 gLanguage
:= LANGUAGE_ENGLISH
;
5821 gAskLanguage
:= false;
5822 gLanguage
:= LANGUAGE_RUSSIAN
;
5826 gAskLanguage
:= true;
5827 gLanguage
:= LANGUAGE_ENGLISH
;
5830 g_Language_Set(gLanguage
);
5834 e_LogWritefln('usage: %s <English|Russian|Ask>', [cmd
]);
5841 procedure g_TakeScreenShot(Filename
: string = '');
5842 var t
: TDateTime
; dir
, date
, name
: String;
5844 if e_NoGraphics
then
5847 dir
:= e_GetWriteableDir(ScreenshotDirs
);
5848 if Filename
= '' then
5851 DateTimeToString(date
, 'yyyy-mm-dd-hh-nn-ss', t
);
5852 Filename
:= 'screenshot-' + date
;
5855 name
:= e_CatPath(dir
, Filename
+ '.png');
5856 if r_Render_WriteScreenShot(name
) then
5857 g_Console_Add(Format(_lc
[I_CONSOLE_SCREENSHOT
], [name
]))
5859 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_WRITE
], [name
]));
5863 {$IFDEF ENABLE_MENU}
5864 procedure g_Game_InGameMenu(Show
: Boolean);
5866 if (g_ActiveWindow
= nil) and Show
then
5868 if gGameSettings
.GameType
= GT_SINGLE
then
5869 g_GUI_ShowWindow('GameSingleMenu')
5872 if g_Game_IsClient
then
5873 g_GUI_ShowWindow('GameClientMenu')
5875 if g_Game_IsNet
then
5876 g_GUI_ShowWindow('GameServerMenu')
5878 g_GUI_ShowWindow('GameCustomMenu');
5880 g_Sound_PlayEx('MENU_OPEN');
5882 // Пауза при меню только в одиночной игре:
5883 if (not g_Game_IsNet
) then
5887 if (g_ActiveWindow
<> nil) and (not Show
) then
5889 // Пауза при меню только в одиночной игре:
5890 if (not g_Game_IsNet
) then
5891 g_Game_Pause(False);
5896 procedure g_Game_Pause (Enable
: Boolean);
5900 if not gGameOn
then exit
;
5902 if not (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
]) then exit
;
5905 gPauseMain
:= Enable
;
5907 if (gPause
<> oldPause
) then g_Game_PauseAllSounds(gPause
);
5910 procedure g_Game_HolmesPause (Enable
: Boolean);
5914 if not gGameOn
then exit
;
5915 if not (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
]) then exit
;
5918 gPauseHolmes
:= Enable
;
5920 if (gPause
<> oldPause
) then g_Game_PauseAllSounds(gPause
);
5923 procedure g_Game_PauseAllSounds(Enable
: Boolean);
5928 if gTriggers
<> nil then
5929 for i
:= 0 to High(gTriggers
) do
5930 with gTriggers
[i
] do
5931 if (TriggerType
= TRIGGER_SOUND
) and
5933 Sound
.IsPlaying() then
5935 Sound
.Pause(Enable
);
5939 if gPlayers
<> nil then
5940 for i
:= 0 to High(gPlayers
) do
5941 if gPlayers
[i
] <> nil then
5942 gPlayers
[i
].PauseSounds(Enable
);
5945 if gMusic
<> nil then
5946 gMusic
.Pause(Enable
);
5949 procedure g_Game_StopAllSounds(all
: Boolean);
5953 if gTriggers
<> nil then
5954 for i
:= 0 to High(gTriggers
) do
5955 with gTriggers
[i
] do
5956 if (TriggerType
= TRIGGER_SOUND
) and
5960 if gMusic
<> nil then
5967 procedure g_Game_UpdateTriggerSounds
;
5970 if gTriggers
<> nil then
5971 for i
:= 0 to High(gTriggers
) do
5972 with gTriggers
[i
] do
5973 if (TriggerType
= TRIGGER_SOUND
) and (Sound
<> nil) and tgcLocal
and Sound
.IsPlaying() then
5974 Sound
.SetCoordsRect(X
, Y
, Width
, Height
, tgcVolume
/ 255.0)
5977 function g_Game_IsWatchedPlayer(UID
: Word): Boolean;
5980 if (gPlayer1
<> nil) and (gPlayer1
.UID
= UID
) then
5985 if (gPlayer2
<> nil) and (gPlayer2
.UID
= UID
) then
5990 if gSpectMode
<> SPECT_PLAYERS
then
5992 if gSpectPID1
= UID
then
5997 if gSpectViewTwo
and (gSpectPID2
= UID
) then
6004 function g_Game_IsWatchedTeam(Team
: Byte): Boolean;
6009 if (gPlayer1
<> nil) and (gPlayer1
.Team
= Team
) then
6014 if (gPlayer2
<> nil) and (gPlayer2
.Team
= Team
) then
6019 if gSpectMode
<> SPECT_PLAYERS
then
6021 Pl
:= g_Player_Get(gSpectPID1
);
6022 if (Pl
<> nil) and (Pl
.Team
= Team
) then
6027 if gSpectViewTwo
then
6029 Pl
:= g_Player_Get(gSpectPID2
);
6030 if (Pl
<> nil) and (Pl
.Team
= Team
) then
6038 procedure g_Game_Message (Msg
: string; Time
: Word);
6041 MessageTime
:= Time
;
6044 procedure g_Game_ChatSound(Text: String; Taunt
: Boolean = True);
6046 punct
: Array[0..13] of String =
6047 ('.', ',', ':', ';', '!', '?', '(', ')', '''', '"', '/', '\', '*', '^');
6053 function IsPunctuation(S
: String): Boolean;
6058 if Length(S
) <> 1 then
6060 for i
:= Low(punct
) to High(punct
) do
6061 if S
= punct
[i
] then
6067 function FilterPunctuation(S
: String): String;
6071 for i
:= Low(punct
) to High(punct
) do
6072 S
:= StringReplace(S
, punct
[i
], ' ', [rfReplaceAll
]);
6078 if gUseChatSounds
and Taunt
and (gChatSounds
<> nil) and (Pos(': ', Text) > 0) then
6080 // remove player name
6081 Delete(Text, 1, Pos(': ', Text) + 2 - 1);
6082 // for FullWord check
6083 Text := toLowerCase1251(' ' + Text + ' ');
6084 fpText
:= FilterPunctuation(Text);
6086 for i
:= 0 to Length(gChatSounds
) - 1 do
6089 for j
:= 0 to Length(gChatSounds
[i
].Tags
) - 1 do
6091 if gChatSounds
[i
].FullWord
and (not IsPunctuation(gChatSounds
[i
].Tags
[j
])) then
6092 ok
:= Pos(' ' + gChatSounds
[i
].Tags
[j
] + ' ', fpText
) > 0
6094 ok
:= Pos(gChatSounds
[i
].Tags
[j
], Text) > 0;
6100 gChatSounds
[i
].Sound
.Play();
6106 g_Sound_PlayEx('SOUND_GAME_RADIO');
6109 procedure g_Game_Announce_GoodShot(SpawnerUID
: Word);
6118 if not g_Game_IsWatchedPlayer(SpawnerUID
) then
6122 if goodsnd
[a
].IsPlaying() then
6125 goodsnd
[Random(4)].Play();
6128 procedure g_Game_Announce_KillCombo(Param
: Integer);
6135 UID
:= Param
and $FFFF;
6140 Pl
:= g_Player_Get(UID
);
6149 g_Console_Add(Format(_lc
[I_PLAYER_KILL_2X
], [Name
]), True);
6153 g_Console_Add(Format(_lc
[I_PLAYER_KILL_3X
], [Name
]), True);
6157 g_Console_Add(Format(_lc
[I_PLAYER_KILL_4X
], [Name
]), True);
6161 g_Console_Add(Format(_lc
[I_PLAYER_KILL_MX
], [Name
]), True);
6169 if not g_Game_IsWatchedPlayer(UID
) then
6172 if (not g_Game_IsWatchedPlayer(UID
)) and (c
< 4) then
6176 if killsnd
[n
].IsPlaying() then
6181 procedure g_Game_Announce_BodyKill(SpawnerUID
: Word);
6189 if not g_Game_IsWatchedPlayer(SpawnerUID
) then
6193 if hahasnd
[a
].IsPlaying() then
6196 hahasnd
[Random(3)].Play();
6199 procedure g_Game_StartVote(Command
, Initiator
: string);
6203 if not gVotesEnabled
then Exit
;
6204 if gGameSettings
.GameType
<> GT_SERVER
then Exit
;
6205 if gVoteInProgress
or gVotePassed
then
6207 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_INPROGRESS
], [gVoteCommand
]), True);
6208 MH_SEND_VoteEvent(NET_VE_INPROGRESS
, gVoteCommand
);
6211 gVoteInProgress
:= True;
6212 gVotePassed
:= False;
6213 gVoteTimer
:= gTime
+ gVoteTimeout
* 1000;
6216 gVoteCommand
:= Command
;
6218 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
6219 Need
:= Floor((NetClientCount
+1)/2.0)+1
6221 Need
:= Floor(NetClientCount
/2.0)+1;
6222 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_STARTED
], [Initiator
, Command
, Need
]), True);
6223 MH_SEND_VoteEvent(NET_VE_STARTED
, Initiator
, Command
, Need
);
6226 procedure g_Game_CheckVote
;
6230 if gGameSettings
.GameType
<> GT_SERVER
then Exit
;
6231 if not gVoteInProgress
then Exit
;
6233 if (gTime
>= gVoteTimer
) then
6235 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
6236 Need
:= Floor((NetClientCount
+1)/2.0) + 1
6238 Need
:= Floor(NetClientCount
/2.0) + 1;
6239 if gVoteCount
>= Need
then
6241 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_PASSED
], [gVoteCommand
]), True);
6242 MH_SEND_VoteEvent(NET_VE_PASSED
, gVoteCommand
);
6243 gVotePassed
:= True;
6244 gVoteCmdTimer
:= gTime
+ 5000;
6248 g_Console_Add(_lc
[I_MESSAGE_VOTE_FAILED
], True);
6249 MH_SEND_VoteEvent(NET_VE_FAILED
);
6251 if NetClients
<> nil then
6252 for I
:= Low(NetClients
) to High(NetClients
) do
6253 if NetClients
[i
].Used
then
6254 NetClients
[i
].Voted
:= False;
6255 gVoteInProgress
:= False;
6261 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
6262 Need
:= Floor((NetClientCount
+1)/2.0) + 1
6264 Need
:= Floor(NetClientCount
/2.0) + 1;
6265 if gVoteCount
>= Need
then
6267 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_PASSED
], [gVoteCommand
]), True);
6268 MH_SEND_VoteEvent(NET_VE_PASSED
, gVoteCommand
);
6269 gVoteInProgress
:= False;
6270 gVotePassed
:= True;
6271 gVoteCmdTimer
:= gTime
+ 5000;
6274 if NetClients
<> nil then
6275 for I
:= Low(NetClients
) to High(NetClients
) do
6276 if NetClients
[i
].Used
then
6277 NetClients
[i
].Voted
:= False;
6282 procedure g_Game_LoadMapList(FileName
: string);
6290 if not FileExists(FileName
) then Exit
;
6292 AssignFile(ListFile
, FileName
);
6294 while not EOF(ListFile
) do
6296 ReadLn(ListFile
, s
);
6299 if s
= '' then Continue
;
6301 SetLength(MapList
, Length(MapList
)+1);
6302 MapList
[High(MapList
)] := s
;
6304 CloseFile(ListFile
);
6307 procedure g_Game_SetDebugMode();
6310 // Читы (даже в своей игре):
6314 procedure g_Game_SetLoadingText(Text: String; Max
: Integer; reWrite
: Boolean);
6318 if Length(LoadingStat
.Msgs
) = 0 then
6324 begin // Переходим на следующую строку или скроллируем:
6325 if NextMsg
= Length(Msgs
) then
6327 for i
:= 0 to High(Msgs
)-1 do
6328 Msgs
[i
] := Msgs
[i
+1];
6336 Msgs
[NextMsg
-1] := Text;
6340 PBarWasHere
:= false;
6343 {$IFDEF ENABLE_MENU}
6344 g_ActiveWindow
:= nil;
6347 ProcessLoading(true);
6350 procedure g_Game_StepLoading(Value
: Integer = -1);
6361 if (ShowCount
> LOADING_SHOW_STEP
) or (Value
> -1) then
6369 procedure g_Game_ClearLoading();
6378 len
:= ((gScreenHeight
div 3)*2 - 50) div LOADING_INTERLINE
;
6379 if len
< 1 then len
:= 1;
6380 SetLength(Msgs
, len
);
6381 for len
:= Low(Msgs
) to High(Msgs
) do
6384 PBarWasHere
:= false;
6388 procedure Parse_Params(var pars
: TParamStrValues
);
6395 while i
<= ParamCount
do
6398 if (s
[1] = '-') and (Length(s
) > 1) then
6400 if (s
[2] = '-') and (Length(s
) > 2) then
6401 begin // Одиночный параметр
6402 SetLength(pars
, Length(pars
) + 1);
6403 with pars
[High(pars
)] do
6405 Name
:= LowerCase(s
);
6410 if (i
< ParamCount
) then
6411 begin // Параметр со значением
6413 SetLength(pars
, Length(pars
) + 1);
6414 with pars
[High(pars
)] do
6416 Name
:= LowerCase(s
);
6417 Value
:= LowerCase(ParamStr(i
));
6426 function Find_Param_Value(var pars
: TParamStrValues
; aName
: String): String;
6431 for i
:= 0 to High(pars
) do
6432 if pars
[i
].Name
= aName
then
6434 Result
:= pars
[i
].Value
;
6439 procedure g_Game_Process_Params();
6441 pars
: TParamStrValues
;
6444 LimT
, LimS
: Integer;
6455 s
:= Find_Param_Value(pars
, '--debug');
6458 g_Game_SetDebugMode();
6459 s
:= Find_Param_Value(pars
, '--netdump');
6464 // Connect when game loads
6465 ip
:= Find_Param_Value(pars
, '-connect');
6469 s
:= Find_Param_Value(pars
, '-port');
6470 if (s
= '') or not TryStrToInt(s
, Port
) then
6473 s
:= Find_Param_Value(pars
, '-pw');
6475 g_Game_StartClient(ip
, Port
, s
);
6479 s
:= LowerCase(Find_Param_Value(pars
, '-dbg-mainwad'));
6482 gDefaultMegawadStart
:= s
;
6485 if (Find_Param_Value(pars
, '--dbg-mainwad-restore') <> '') or
6486 (Find_Param_Value(pars
, '--dbg-mainwad-default') <> '') then
6488 gDefaultMegawadStart
:= DF_Default_Megawad_Start
;
6491 // Start map when game loads:
6492 map
:= LowerCase(Find_Param_Value(pars
, '-map'));
6493 if isWadPath(map
) then
6496 s
:= Find_Param_Value(pars
, '-gm');
6497 GMode
:= g_Game_TextToMode(s
);
6498 if GMode
= GM_NONE
then GMode
:= GM_DM
;
6499 if GMode
= GM_SINGLE
then GMode
:= GM_COOP
;
6502 s
:= Find_Param_Value(pars
, '-limt');
6503 if (s
= '') or (not TryStrToInt(s
, LimT
)) then
6509 s
:= Find_Param_Value(pars
, '-lims');
6510 if (s
= '') or (not TryStrToInt(s
, LimS
)) then
6516 s
:= Find_Param_Value(pars
, '-lives');
6517 if (s
= '') or (not TryStrToInt(s
, Lives
)) then
6523 s
:= Find_Param_Value(pars
, '-opt');
6527 Opt
:= StrToIntDef(s
, 0);
6530 s
:= Find_Param_Value(pars
, '--close');
6534 // Override map to test:
6535 s
:= LowerCase(Find_Param_Value(pars
, '-testmap'));
6538 if e_IsValidResourceName(s
) then
6539 e_FindResource(AllMapDirs
, s
);
6540 gTestMap
:= ExpandFileName(s
);
6543 // Delete test map after play:
6544 s
:= Find_Param_Value(pars
, '--testdelete');
6547 //gMapToDelete := MapsDir + map;
6548 e_WriteLog('"--testdelete" is deprecated, use --tempdelete.', TMsgType
.Fatal
);
6552 // Delete temporary WAD after play:
6553 s
:= Find_Param_Value(pars
, '--tempdelete');
6554 if (s
<> '') and (gTestMap
<> '') then
6556 gMapToDelete
:= gTestMap
;
6557 gTempDelete
:= True;
6560 // Number of players:
6561 s
:= Find_Param_Value(pars
, '-pl');
6563 n
:= DEFAULT_PLAYERS
6565 n
:= StrToIntDef(s
, DEFAULT_PLAYERS
);
6568 s
:= Find_Param_Value(pars
, '-port');
6569 if (s
= '') or not TryStrToInt(s
, Port
) then
6570 g_Game_StartCustom(map
, GMode
, LimT
, LimS
, Lives
, Opt
, n
)
6572 g_Game_StartServer(map
, GMode
, LimT
, LimS
, Lives
, Opt
, n
, 0, Port
);
6575 // Execute script when game loads:
6576 s
:= Find_Param_Value(pars
, '-exec');
6579 // if not isWadPath(s) then
6580 // s := GameDir + '/' + s;
6585 if IOResult
<> 0 then
6587 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], ['Failed to read file: ' + s
]), TMsgType
.Warning
);
6588 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_READ
], [s
]));
6592 e_WriteLog('Executing script: ' + s
, TMsgType
.Notify
);
6593 g_Console_Add(Format(_lc
[I_CONSOLE_EXEC
], [s
]));
6598 if IOResult
<> 0 then
6600 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], ['Failed to read file: ' + s
]), TMsgType
.Warning
);
6601 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_READ
], [s
]));
6605 if Pos('#', s
) <> 1 then // script comment
6606 g_Console_Process(s
, True);
6617 conRegVar('pf_draw_frame', @g_profile_frame_draw
, 'draw frame rendering profiles', 'render profiles');
6618 //conRegVar('pf_update_frame', @g_profile_frame_update, 'draw frame updating profiles', 'update profiles');
6619 conRegVar('pf_coldet', @g_profile_collision
, 'draw collision detection profiles', 'coldet profiles');
6620 conRegVar('pf_los', @g_profile_los
, 'draw monster LOS profiles', 'monster LOS profiles');
6622 conRegVar('r_sq_draw', @gdbg_map_use_accel_render
, 'accelerated spatial queries in rendering', 'accelerated rendering');
6623 conRegVar('cd_sq_enabled', @gdbg_map_use_accel_coldet
, 'accelerated spatial queries in map coldet', 'accelerated map coldet');
6624 conRegVar('mon_sq_enabled', @gmon_debug_use_sqaccel
, 'accelerated spatial queries for monsters', 'accelerated monster coldet');
6625 conRegVar('wtrace_sq_enabled', @gwep_debug_fast_trace
, 'accelerated spatial queries for weapon hitscan trace', 'accelerated weapon hitscan');
6628 conRegVar('pr_enabled', @gpart_dbg_enabled
, 'enable/disable particles', 'particles');
6629 conRegVar('pr_phys_enabled', @gpart_dbg_phys_enabled
, 'enable/disable particle physics', 'particle physics');
6632 conRegVar('los_enabled', @gmon_dbg_los_enabled
, 'enable/disable monster LOS calculations', 'monster LOS', true);
6633 conRegVar('mon_think', @gmon_debug_think
, 'enable/disable monster thinking', 'monster thinking', true);
6635 {$IFDEF ENABLE_HOLMES}
6636 conRegVar('dbg_holmes', @g_holmes_enabled
, 'enable/disable Holmes', 'Holmes', true);
6639 conRegVar('dbg_ignore_level_bounds', @g_dbg_ignore_bounds
, 'ignore level bounds', '', false);
6641 conRegVar('light_enabled', @gwin_k8_enable_light_experiments
, 'enable/disable dynamic lighting', 'lighting');
6642 conRegVar('light_player_halo', @g_playerLight
, 'enable/disable player halo', 'player light halo');
6644 conRegVar('r_smallmap_align_h', @r_smallmap_h
, 'halign: 0: left; 1: center; 2: right', 'horizontal aligning of small maps');
6645 conRegVar('r_smallmap_align_v', @r_smallmap_v
, 'valign: 0: top; 1: center; 2: bottom', 'vertial aligning of small maps');
6647 conRegVar('r_showfps', @gShowFPS
, 'draw fps counter', 'draw fps counter');
6648 conRegVar('r_showtime', @gShowTime
, 'show game time', 'show game time');
6649 conRegVar('r_showping', @gShowPing
, 'show ping', 'show ping');
6650 conRegVar('r_showscore', @gShowGoals
, 'show score', 'show score');
6651 conRegVar('r_showkillmsg', @gShowKillMsg
, 'show kill log', 'show kill log');
6652 conRegVar('r_showlives', @gShowLives
, 'show lives', 'show lives');
6653 conRegVar('r_showspect', @gSpectHUD
, 'show spectator hud', 'show spectator hud');
6654 conRegVar('r_showstat', @gShowStat
, 'show stats', 'show stats');
6655 conRegVar('r_showpids', @gShowPIDs
, 'show PIDs', 'show PIDs');