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}
23 g_base
, g_basic
, g_player
, r_graphics
, g_res_downloader
,
24 g_sound
, g_gui
, utils
, md5
, mempool
, xprofiler
,
28 TGameSettings
= record
35 ItemRespawnTime
: Word;
46 TDelayedEvent
= record
55 Sound
: TPlayableSound
;
56 Tags
: Array of String;
60 TPlayerSettings
= record
79 function g_Game_IsNet(): Boolean;
80 function g_Game_IsServer(): Boolean;
81 function g_Game_IsClient(): Boolean;
82 procedure g_Game_Init();
83 procedure g_Game_Free (freeTextures
: Boolean=true);
84 procedure g_Game_LoadData();
85 procedure g_Game_FreeData();
86 procedure g_Game_Update();
87 procedure g_Game_PreUpdate();
88 procedure g_Game_Quit();
89 function g_Game_ModeToText(Mode
: Byte): string;
90 function g_Game_TextToMode(Mode
: string): Byte;
91 procedure g_Game_ExecuteEvent(Name
: String);
92 function g_Game_DelayEvent(DEType
: Byte; Time
: LongWord; Num
: Integer = 0; Str
: String = ''): Integer;
93 procedure g_Game_AddPlayer(Team
: Byte = TEAM_NONE
);
94 procedure g_Game_RemovePlayer();
95 procedure g_Game_Spectate();
96 procedure g_Game_SpectateCenterView();
97 procedure g_Game_StartSingle(Map
: String; TwoPlayers
: Boolean; nPlayers
: Byte);
98 procedure g_Game_StartCustom(Map
: String; GameMode
: Byte; TimeLimit
, GoalLimit
: Word; MaxLives
: Byte; Options
: LongWord; nPlayers
: Byte);
99 procedure g_Game_StartServer(Map
: String; GameMode
: Byte; TimeLimit
, GoalLimit
: Word; MaxLives
: Byte; Options
: LongWord; nPlayers
: Byte; IPAddr
: LongWord; Port
: Word);
100 procedure g_Game_StartClient(Addr
: String; Port
: Word; PW
: String);
101 procedure g_Game_Restart();
102 procedure g_Game_RestartLevel();
103 procedure g_Game_RestartRound(NoMapRestart
: Boolean = False);
104 function g_Game_ClientWAD (NewWAD
: String; const WHash
: TMD5Digest
): AnsiString;
105 function g_Game_StartMap(asMegawad
: Boolean; Map
: String; Force
: Boolean = False; const oldMapPath
: AnsiString=''): Boolean;
106 procedure g_Game_ChangeMap(const MapPath
: String);
107 procedure g_Game_ExitLevel(const Map
: AnsiString);
108 function g_Game_GetFirstMap(WAD
: String): String;
109 function g_Game_GetNextMap(): String;
110 procedure g_Game_NextLevel();
111 procedure g_Game_Pause(Enable
: Boolean);
112 procedure g_Game_HolmesPause(Enable
: Boolean);
113 procedure g_Game_InGameMenu(Show
: Boolean);
114 function g_Game_IsWatchedPlayer(UID
: Word): Boolean;
115 function g_Game_IsWatchedTeam(Team
: Byte): Boolean;
116 procedure g_Game_Message(Msg
: String; Time
: Word);
117 procedure g_Game_LoadMapList(FileName
: String);
118 procedure g_Game_PauseAllSounds(Enable
: Boolean);
119 procedure g_Game_StopAllSounds(all
: Boolean);
120 procedure g_Game_UpdateTriggerSounds();
121 function g_Game_GetMegaWADInfo(WAD
: String): TMegaWADInfo
;
122 procedure g_Game_ChatSound(Text: String; Taunt
: Boolean = True);
123 procedure g_Game_Announce_GoodShot(SpawnerUID
: Word);
124 procedure g_Game_Announce_KillCombo(Param
: Integer);
125 procedure g_Game_Announce_BodyKill(SpawnerUID
: Word);
126 procedure g_Game_StartVote(Command
, Initiator
: string);
127 procedure g_Game_CheckVote
;
128 procedure g_TakeScreenShot(Filename
: string = '');
129 procedure g_FatalError(Text: String);
130 procedure g_SimpleError(Text: String);
131 function g_Game_IsTestMap(): Boolean;
132 procedure g_Game_DeleteTestMap();
133 procedure GameCVars(P
: SSArray
);
134 procedure PlayerSettingsCVars(P
: SSArray
);
135 procedure SystemCommands(P
: SSArray
);
136 procedure GameCommands(P
: SSArray
);
137 procedure GameCheats(P
: SSArray
);
138 procedure DebugCommands(P
: SSArray
);
139 procedure g_Game_Process_Params
;
140 procedure g_Game_SetLoadingText(Text: String; Max
: Integer; reWrite
: Boolean);
141 procedure g_Game_StepLoading(Value
: Integer = -1);
142 procedure g_Game_ClearLoading();
143 procedure g_Game_SetDebugMode();
145 function IsActivePlayer(p
: TPlayer
): Boolean;
146 function GetActivePlayerID_Next(Skip
: Integer = -1): Integer;
147 procedure SortGameStat(var stat
: TPlayerStatArray
);
149 procedure KeyPress (K
: Word);
150 procedure CharPress (C
: AnsiChar);
152 { procedure SetWinPause(Enable: Boolean); }
157 LOADING_SHOW_STEP
= 100;
158 LOADING_INTERLINE
= 20;
173 MESSAGE_DIKEY
= WM_USER
+ 1;
178 EXIT_ENDLEVELSINGLE
= 4;
179 EXIT_ENDLEVELCUSTOM
= 5;
181 GAME_OPTION_RESERVED
= 1;
182 GAME_OPTION_TEAMDAMAGE
= 2;
183 GAME_OPTION_ALLOWEXIT
= 4;
184 GAME_OPTION_WEAPONSTAY
= 8;
185 GAME_OPTION_MONSTERS
= 16;
186 GAME_OPTION_BOTVSPLAYER
= 32;
187 GAME_OPTION_BOTVSMONSTER
= 64;
188 GAME_OPTION_DMKEYS
= 128;
189 GAME_OPTION_TEAMHITTRACE
= 256;
190 GAME_OPTION_TEAMHITPROJECTILE
= 512;
191 GAME_OPTION_TEAMABSORBDAMAGE
= 1024;
196 STATE_INTERCUSTOM
= 3;
197 STATE_INTERSINGLE
= 4;
203 LMS_RESPAWN_NONE
= 0;
204 LMS_RESPAWN_WARMUP
= 1;
205 LMS_RESPAWN_FINAL
= 2;
222 CONFIG_FILENAME
= 'Doom2DF.cfg';
224 TEST_MAP_NAME
= '$$$_TEST_$$$';
226 STD_PLAYER_MODEL
= 'Doomer';
234 STATFILE_VERSION
= $03;
237 gGameSettings
: TGameSettings
;
238 gPlayer1Settings
: TPlayerSettings
;
239 gPlayer2Settings
: TPlayerSettings
;
241 gPlayerScreenSize
: TDFPoint
;
242 gPlayer1ScreenCoord
: TDFPoint
;
243 gPlayer2ScreenCoord
: TDFPoint
;
244 gPlayer1
: TPlayer
= nil;
245 gPlayer2
: TPlayer
= nil;
246 gPlayerDrawn
: TPlayer
= nil;
248 gLerpFactor
: Single = 1.0;
249 gSwitchGameMode
: Byte = GM_DM
;
250 gHearPoint1
, gHearPoint2
: THearPoint
;
251 gSoundEffectsDF
: Boolean = False;
252 gSoundTriggerTime
: Word = 0;
253 gAnnouncer
: Integer = ANNOUNCE_NONE
;
254 goodsnd
: array[0..3] of TPlayableSound
;
255 killsnd
: array[0..3] of TPlayableSound
;
256 hahasnd
: array[0..2] of TPlayableSound
;
257 sound_get_flag
: array[0..1] of TPlayableSound
;
258 sound_lost_flag
: array[0..1] of TPlayableSound
;
259 sound_ret_flag
: array[0..1] of TPlayableSound
;
260 sound_cap_flag
: array[0..1] of TPlayableSound
;
261 gBodyKillEvent
: Integer = -1;
262 gDefInterTime
: ShortInt = -1;
263 gInterEndTime
: LongWord = 0;
264 gInterTime
: LongWord = 0;
265 gServInterTime
: Byte = 0;
266 gGameStartTime
: LongWord = 0;
267 gTotalMonsters
: Integer = 0;
268 gPauseMain
: Boolean = false;
269 gPauseHolmes
: Boolean = false;
270 gShowTime
: Boolean = False;
271 gShowFPS
: Boolean = False;
272 gShowGoals
: Boolean = True;
273 gShowStat
: Boolean = True;
274 gShowPIDs
: Boolean = False;
275 gShowKillMsg
: Boolean = True;
276 gShowLives
: Boolean = True;
277 gShowPing
: Boolean = False;
278 gShowMap
: Boolean = False;
280 gState
: Byte = STATE_NONE
;
282 sWidth
, sHeight
: Word;
283 gSpectMode
: Byte = SPECT_NONE
;
284 gSpectHUD
: Boolean = True;
285 gSpectKeyPress
: Boolean = False;
286 gSpectX
: Integer = 0;
287 gSpectY
: Integer = 0;
288 gSpectStep
: Byte = 8;
289 gSpectViewTwo
: Boolean = False;
290 gSpectPID1
: Integer = -1;
291 gSpectPID2
: Integer = -1;
292 gSpectAuto
: Boolean = False;
293 gSpectAutoNext
: LongWord;
294 gSpectAutoStepX
: Integer;
295 gSpectAutoStepY
: Integer;
296 gMusic
: TMusic
= nil;
297 gLoadGameMode
: Boolean;
298 gCheats
: Boolean = False;
299 gMapOnce
: Boolean = False;
300 gMapToDelete
: String;
301 gTempDelete
: Boolean = False;
302 gLastMap
: Boolean = False;
305 gResolutionChange
: Boolean = False;
306 gRC_Width
, gRC_Height
: Integer;
307 gRC_FullScreen
, gRC_Maximized
: Boolean;
308 gLanguageChange
: Boolean = False;
309 gDebugMode
: Boolean = False;
310 g_debug_Sounds
: Boolean = False;
311 g_debug_Frames
: Boolean = False;
312 g_debug_WinMsgs
: Boolean = False;
313 g_debug_MonsterOff
: Boolean = False;
314 g_debug_BotAIOff
: Byte = 0;
315 g_debug_HealthBar
: Boolean = False;
316 g_Debug_Player
: Boolean = False;
317 gCoopMonstersKilled
: Word = 0;
318 gCoopSecretsFound
: Word = 0;
319 gCoopTotalMonstersKilled
: Word = 0;
320 gCoopTotalSecretsFound
: Word = 0;
321 gCoopTotalMonsters
: Word = 0;
322 gCoopTotalSecrets
: Word = 0;
323 gStatsOff
: Boolean = False;
324 gStatsPressed
: Boolean = False;
325 gExitByTrigger
: Boolean = False;
326 gNextMap
: String = '';
327 gLMSRespawn
: Byte = LMS_RESPAWN_NONE
;
328 gLMSRespawnTime
: Cardinal = 0;
329 gLMSSoftSpawn
: Boolean = False;
330 gMissionFailed
: Boolean = False;
331 gVoteInProgress
: Boolean = False;
332 gVotePassed
: Boolean = False;
333 gVoteCommand
: string = '';
334 gVoteTimer
: Cardinal = 0;
335 gVoteCmdTimer
: Cardinal = 0;
336 gVoteCount
: Integer = 0;
337 gVoteTimeout
: Cardinal = 30;
338 gVoted
: Boolean = False;
339 gVotesEnabled
: Boolean = True;
340 gEvents
: Array of TGameEvent
;
341 gDelayedEvents
: Array of TDelayedEvent
;
342 gUseChatSounds
: Boolean = True;
343 gChatSounds
: Array of TChatSound
;
344 gSelectWeapon
: Array [0..1, WP_FIRST
..WP_LAST
] of Boolean; // [player, weapon]
345 gInterReadyCount
: Integer = 0;
347 g_dbg_ignore_bounds
: Boolean = false;
348 r_smallmap_h
: Integer = 0; // 0: left; 1: center; 2: right
349 r_smallmap_v
: Integer = 2; // 0: top; 1: center; 2: bottom
351 // move button values:
352 // bits 0-1: l/r state:
353 // 0: neither left, nor right pressed
356 // bits 4-5: l/r state when strafe was pressed
357 P1MoveButton
: Byte = 0;
358 P2MoveButton
: Byte = 0;
360 g_profile_frame_update
: Boolean = false;
361 g_profile_frame_draw
: Boolean = false;
362 g_profile_collision
: Boolean = false;
363 g_profile_los
: Boolean = false;
364 g_profile_history_size
: Integer = 1000;
366 g_rlayer_back
: Boolean = true;
367 g_rlayer_step
: Boolean = true;
368 g_rlayer_wall
: Boolean = true;
369 g_rlayer_door
: Boolean = true;
370 g_rlayer_acid1
: Boolean = true;
371 g_rlayer_acid2
: Boolean = true;
372 g_rlayer_water
: Boolean = true;
373 g_rlayer_fore
: Boolean = true;
375 wNeedTimeReset
: Boolean = false;
377 procedure g_ResetDynlights ();
378 procedure g_AddDynLight (x
, y
, radius
: Integer; r
, g
, b
, a
: Single);
379 procedure g_DynLightExplosion (x
, y
, radius
: Integer; r
, g
, b
: Single);
381 function conIsCheatsEnabled (): Boolean; inline;
382 function gPause (): Boolean; inline;
384 type (* private state *)
385 TEndCustomGameStat
= record
386 PlayerStat
: TPlayerStatArray
;
390 Map
, MapName
: String;
393 TEndSingleGameStat
= record
394 PlayerStat
: Array [0..1] of record
400 TotalSecrets
: Integer;
403 TLoadingStat
= record
407 Msgs
: Array of String;
409 PBarWasHere
: Boolean; // did we draw a progress bar for this message?
413 x
, y
, radius
: Integer;
416 exploRadius
: Integer;
419 var (* private state *)
420 CustomStat
: TEndCustomGameStat
;
421 StatShotDone
: Boolean;
422 StatFilename
: string = ''; // used by stat screenshot to save with the same name as the csv
423 SingleStat
: TEndSingleGameStat
;
424 LoadingStat
: TLoadingStat
;
427 EndingGameCounter
: Byte;
429 g_playerLight
: Boolean;
430 g_dynLights
: array of TDynLight
= nil;
431 g_dynLightCount
: Integer = 0;
432 EndPicPath
: AnsiString; // full path, used by render
437 {$IFDEF ENABLE_HOLMES}
440 e_res
, g_window
, g_menu
, r_render
, r_gfx
,
441 e_input
, e_log
, g_console
, r_console
, g_items
, g_map
, g_panel
,
442 g_playermodel
, g_gfx
, g_options
, Math
,
443 g_triggers
, g_monsters
, e_sound
, CONFIG
,
444 g_language
, g_net
, g_phys
,
445 ENet
, e_msg
, g_netmsg
, g_netmaster
,
446 sfs
, wadreader
, g_system
, r_playermodel
;
449 charbuff
: packed array [0..15] of AnsiChar = (
450 ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '
453 function Translit (const S
: AnsiString): AnsiString;
458 for i
:= 1 to Length(Result
) do
461 #
$C9: Result
[i
] := 'Q';
462 #
$D6: Result
[i
] := 'W';
463 #
$D3: Result
[i
] := 'E';
464 #
$CA: Result
[i
] := 'R';
465 #
$C5: Result
[i
] := 'T';
466 #
$CD: Result
[i
] := 'Y';
467 #
$C3: Result
[i
] := 'U';
468 #
$D8: Result
[i
] := 'I';
469 #
$D9: Result
[i
] := 'O';
470 #
$C7: Result
[i
] := 'P';
471 #
$D5: Result
[i
] := '['; //Chr(219);
472 #
$DA: Result
[i
] := ']'; //Chr(221);
473 #
$D4: Result
[i
] := 'A';
474 #
$DB: Result
[i
] := 'S';
475 #
$C2: Result
[i
] := 'D';
476 #
$C0: Result
[i
] := 'F';
477 #
$CF: Result
[i
] := 'G';
478 #
$D0: Result
[i
] := 'H';
479 #
$CE: Result
[i
] := 'J';
480 #
$CB: Result
[i
] := 'K';
481 #
$C4: Result
[i
] := 'L';
482 #
$C6: Result
[i
] := ';'; //Chr(186);
483 #
$DD: Result
[i
] := #39; //Chr(222);
484 #
$DF: Result
[i
] := 'Z';
485 #
$D7: Result
[i
] := 'X';
486 #
$D1: Result
[i
] := 'C';
487 #
$CC: Result
[i
] := 'V';
488 #
$C8: Result
[i
] := 'B';
489 #
$D2: Result
[i
] := 'N';
490 #
$DC: Result
[i
] := 'M';
491 #
$C1: Result
[i
] := ','; //Chr(188);
492 #
$DE: Result
[i
] := '.'; //Chr(190);
498 function CheckCheat (ct
: TStrings_Locale
; eofs
: Integer=0): Boolean;
503 ls2
:= Translit(CheatRus
[ct
]);
504 if length(ls1
) = 0 then ls1
:= '~';
505 if length(ls2
) = 0 then ls2
:= '~';
507 (Copy(charbuff
, 17-Length(ls1
)-eofs
, Length(ls1
)) = ls1
) or
508 (Translit(Copy(charbuff
, 17-Length(ls1
)-eofs
, Length(ls1
))) = ls1
) or
509 (Copy(charbuff
, 17-Length(ls2
)-eofs
, Length(ls2
)) = ls2
) or
510 (Translit(Copy(charbuff
, 17-Length(ls2
)-eofs
, Length(ls2
))) = ls2
);
512 if ct = I_GAME_CHEAT_JETPACK then
514 e_WriteLog('ls1: ['+ls1+']', MSG_NOTIFY);
515 e_WriteLog('ls2: ['+ls2+']', MSG_NOTIFY);
516 e_WriteLog('bf0: ['+Copy(charbuff, 17-Length(ls1)-eofs, Length(ls1))+']', MSG_NOTIFY);
517 e_WriteLog('bf1: ['+Translit(Copy(charbuff, 17-Length(ls1)-eofs, Length(ls1)))+']', MSG_NOTIFY);
518 e_WriteLog('bf2: ['+Copy(charbuff, 17-Length(ls2)-eofs, Length(ls2))+']', MSG_NOTIFY);
519 e_WriteLog('bf3: ['+Translit(Copy(charbuff, 17-Length(ls2)-eofs, Length(ls2)))+']', MSG_NOTIFY);
535 if (not gGameOn) or (not gCheats) or ((gGameSettings.GameType <> GT_SINGLE) and
536 (gGameSettings.GameMode <> GM_COOP) and (not gDebugMode))
537 or g_Game_IsNet then Exit;
539 if not gGameOn
then exit
;
540 if not conIsCheatsEnabled
then exit
;
542 s
:= 'SOUND_GAME_RADIO';
545 if CheckCheat(I_GAME_CHEAT_GODMODE
) then
547 if gPlayer1
<> nil then gPlayer1
.GodMode
:= not gPlayer1
.GodMode
;
548 if gPlayer2
<> nil then gPlayer2
.GodMode
:= not gPlayer2
.GodMode
;
552 if CheckCheat(I_GAME_CHEAT_WEAPONS
) then
554 if gPlayer1
<> nil then gPlayer1
.AllRulez(False);
555 if gPlayer2
<> nil then gPlayer2
.AllRulez(False);
559 if CheckCheat(I_GAME_CHEAT_HEALTH
) then
561 if gPlayer1
<> nil then gPlayer1
.AllRulez(True);
562 if gPlayer2
<> nil then gPlayer2
.AllRulez(True);
566 if CheckCheat(I_GAME_CHEAT_DEATH
) then
568 if gPlayer1
<> nil then gPlayer1
.Damage(CHEAT_DAMAGE
, 0, 0, 0, HIT_TRAP
);
569 if gPlayer2
<> nil then gPlayer2
.Damage(CHEAT_DAMAGE
, 0, 0, 0, HIT_TRAP
);
570 s
:= 'SOUND_MONSTER_HAHA';
574 if CheckCheat(I_GAME_CHEAT_DOORS
) then
576 g_Triggers_OpenAll();
580 if CheckCheat(I_GAME_CHEAT_NEXTMAP
) then
582 if gTriggers
<> nil then
583 for a
:= 0 to High(gTriggers
) do
584 if gTriggers
[a
].TriggerType
= TRIGGER_EXIT
then
586 gExitByTrigger
:= True;
587 //g_Game_ExitLevel(gTriggers[a].Data.MapName);
588 g_Game_ExitLevel(gTriggers
[a
].tgcMap
);
594 s2
:= Copy(charbuff
, 15, 2);
595 if CheckCheat(I_GAME_CHEAT_CHANGEMAP
, 2) and (s2
[1] >= '0') and (s2
[1] <= '9') and (s2
[2] >= '0') and (s2
[2] <= '9') then
597 if g_Map_Exist(gGameSettings
.WAD
+ ':\MAP' + s2
) then
605 if CheckCheat(I_GAME_CHEAT_FLY
) then
611 if CheckCheat(I_GAME_CHEAT_JUMPS
) then
613 VEL_JUMP
:= 30-VEL_JUMP
;
617 if CheckCheat(I_GAME_CHEAT_SPEED
) then
619 MAX_RUNVEL
:= 32-MAX_RUNVEL
;
623 if CheckCheat(I_GAME_CHEAT_SUIT
) then
625 if gPlayer1
<> nil then gPlayer1
.GiveItem(ITEM_SUIT
);
626 if gPlayer2
<> nil then gPlayer2
.GiveItem(ITEM_SUIT
);
630 if CheckCheat(I_GAME_CHEAT_AIR
) then
632 if gPlayer1
<> nil then gPlayer1
.GiveItem(ITEM_OXYGEN
);
633 if gPlayer2
<> nil then gPlayer2
.GiveItem(ITEM_OXYGEN
);
637 if CheckCheat(I_GAME_CHEAT_BERSERK
) then
639 if gPlayer1
<> nil then gPlayer1
.GiveItem(ITEM_MEDKIT_BLACK
);
640 if gPlayer2
<> nil then gPlayer2
.GiveItem(ITEM_MEDKIT_BLACK
);
644 if CheckCheat(I_GAME_CHEAT_JETPACK
) then
646 if gPlayer1
<> nil then gPlayer1
.GiveItem(ITEM_JETPACK
);
647 if gPlayer2
<> nil then gPlayer2
.GiveItem(ITEM_JETPACK
);
651 if CheckCheat(I_GAME_CHEAT_NOCLIP
) then
653 if gPlayer1
<> nil then gPlayer1
.SwitchNoClip
;
654 if gPlayer2
<> nil then gPlayer2
.SwitchNoClip
;
658 if CheckCheat(I_GAME_CHEAT_NOTARGET
) then
660 if gPlayer1
<> nil then gPlayer1
.NoTarget
:= not gPlayer1
.NoTarget
;
661 if gPlayer2
<> nil then gPlayer2
.NoTarget
:= not gPlayer2
.NoTarget
;
665 if CheckCheat(I_GAME_CHEAT_NORELOAD
) then
667 if gPlayer1
<> nil then gPlayer1
.NoReload
:= not gPlayer1
.NoReload
;
668 if gPlayer2
<> nil then gPlayer2
.NoReload
:= not gPlayer2
.NoReload
;
671 if CheckCheat(I_GAME_CHEAT_AIMLINE
) then
673 gAimLine
:= not gAimLine
;
676 if CheckCheat(I_GAME_CHEAT_AUTOMAP
) then
678 gShowMap
:= not gShowMap
;
688 procedure KeyPress (K
: Word);
698 if (g_ActiveWindow
<> nil) then
700 Msg
.Msg
:= WM_KEYDOWN
;
701 Msg
.WParam
:= VK_ESCAPE
;
702 g_ActiveWindow
.OnMessage(Msg
);
703 if (not g_Game_IsNet
) and (g_ActiveWindow
= nil) then g_Game_Pause(false); //Fn loves to do this
705 else if (gState
<> STATE_FOLD
) then
707 if gGameOn
or (gState
= STATE_INTERSINGLE
) or (gState
= STATE_INTERCUSTOM
) then
709 g_Game_InGameMenu(True);
711 else if (gExit
= 0) and (gState
<> STATE_SLIST
) then
713 if (gState
<> STATE_MENU
) then
715 if (NetMode
<> NET_NONE
) then
717 g_Game_StopAllSounds(True);
719 gState
:= STATE_MENU
;
723 g_GUI_ShowWindow('MainMenu');
724 g_Sound_PlayEx('MENU_OPEN');
729 IK_F2
, IK_F3
, IK_F4
, IK_F5
, IK_F6
, IK_F7
, IK_F10
:
730 begin // <F2> .. <F6> � <F12>
731 if gGameOn
and (not gConsoleShow
) and (not gChatShow
) then
733 while (g_ActiveWindow
<> nil) do g_GUI_HideWindow(False);
734 if (not g_Game_IsNet
) then g_Game_Pause(True);
736 IK_F2
: g_Menu_Show_SaveMenu();
737 IK_F3
: g_Menu_Show_LoadMenu();
738 IK_F4
: g_Menu_Show_GameSetGame();
739 IK_F5
: g_Menu_Show_OptionsVideo();
740 IK_F6
: g_Menu_Show_OptionsSound();
741 IK_F7
: g_Menu_Show_EndGameMenu();
742 IK_F10
: g_Menu_Show_QuitGameMenu();
749 gJustChatted
:= False;
750 if gConsoleShow
or gChatShow
then
752 g_Console_Control(K
);
754 else if (g_ActiveWindow
<> nil) then
756 Msg
.Msg
:= WM_KEYDOWN
;
758 g_ActiveWindow
.OnMessage(Msg
);
760 else if (gState
= STATE_MENU
) then
762 g_GUI_ShowWindow('MainMenu');
763 g_Sound_PlayEx('MENU_OPEN');
770 procedure CharPress (C
: AnsiChar);
775 if gConsoleShow
or gChatShow
then
779 else if (g_ActiveWindow
<> nil) then
782 Msg
.WParam
:= Ord(C
);
783 g_ActiveWindow
.OnMessage(Msg
);
787 for a
:= 0 to 14 do charbuff
[a
] := charbuff
[a
+1];
788 charbuff
[15] := upcase1251(C
);
794 // ////////////////////////////////////////////////////////////////////////// //
795 function gPause (): Boolean; inline; begin result
:= gPauseMain
or gPauseHolmes
; end;
797 procedure g_ResetDynlights ();
801 if not gwin_has_stencil
then begin g_dynLightCount
:= 0; exit
; end;
803 for idx
:= 0 to g_dynLightCount
-1 do
805 if g_dynLights
[idx
].exploCount
= -666 then
812 Inc(g_dynLights
[idx
].exploCount
);
813 if (g_dynLights
[idx
].exploCount
< 10) then
815 g_dynLights
[idx
].radius
:= g_dynLights
[idx
].exploRadius
+g_dynLights
[idx
].exploCount
*8;
816 g_dynLights
[idx
].a
:= 0.4+g_dynLights
[idx
].exploCount
/10;
817 if (g_dynLights
[idx
].a
> 0.8) then g_dynLights
[idx
].a
:= 0.8;
818 if lnum
<> idx
then g_dynLights
[lnum
] := g_dynLights
[idx
];
823 g_dynLightCount
:= lnum
;
826 procedure g_AddDynLight (x
, y
, radius
: Integer; r
, g
, b
, a
: Single);
828 if not gwin_has_stencil
then exit
;
829 if g_dynLightCount
= length(g_dynLights
) then SetLength(g_dynLights
, g_dynLightCount
+1024);
830 g_dynLights
[g_dynLightCount
].x
:= x
;
831 g_dynLights
[g_dynLightCount
].y
:= y
;
832 g_dynLights
[g_dynLightCount
].radius
:= radius
;
833 g_dynLights
[g_dynLightCount
].r
:= r
;
834 g_dynLights
[g_dynLightCount
].g
:= g
;
835 g_dynLights
[g_dynLightCount
].b
:= b
;
836 g_dynLights
[g_dynLightCount
].a
:= a
;
837 g_dynLights
[g_dynLightCount
].exploCount
:= -666;
838 Inc(g_dynLightCount
);
841 procedure g_DynLightExplosion (x
, y
, radius
: Integer; r
, g
, b
: Single);
843 if not gwin_has_stencil
then exit
;
844 if g_dynLightCount
= length(g_dynLights
) then SetLength(g_dynLights
, g_dynLightCount
+1024);
845 g_dynLights
[g_dynLightCount
].x
:= x
;
846 g_dynLights
[g_dynLightCount
].y
:= y
;
847 g_dynLights
[g_dynLightCount
].radius
:= 0;
848 g_dynLights
[g_dynLightCount
].exploRadius
:= radius
;
849 g_dynLights
[g_dynLightCount
].r
:= r
;
850 g_dynLights
[g_dynLightCount
].g
:= g
;
851 g_dynLights
[g_dynLightCount
].b
:= b
;
852 g_dynLights
[g_dynLightCount
].a
:= 0;
853 g_dynLights
[g_dynLightCount
].exploCount
:= 0;
854 Inc(g_dynLightCount
);
857 // ////////////////////////////////////////////////////////////////////////// //
858 function conIsCheatsEnabled (): Boolean; inline;
861 if g_Game_IsNet
then exit
;
862 if not gDebugMode
then
864 //if not gCheats then exit;
865 if not (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
]) then exit
;
866 if not (gGameSettings
.GameMode
in [GM_COOP
, GM_SINGLE
]) then exit
;
871 // ////////////////////////////////////////////////////////////////////////// //
873 TParamStrValue
= record
878 TParamStrValues
= Array of TParamStrValue
;
881 INTER_ACTION_TEXT
= 1;
882 INTER_ACTION_PIC
= 2;
883 INTER_ACTION_MUSIC
= 3;
888 DataLoaded
: Boolean = False;
890 MessageLineLength
: Integer = 80;
891 MapList
: SSArray
= nil;
892 MapIndex
: Integer = -1;
893 InterReadyTime
: Integer = -1;
894 StatDate
: string = '';
909 function Compare(a
, b
: TPlayerStat
): Integer;
911 if a
.Spectator
then Result
:= 1
912 else if b
.Spectator
then Result
:= -1
913 else if a
.Frags
< b
.Frags
then Result
:= 1
914 else if a
.Frags
> b
.Frags
then Result
:= -1
915 else if a
.Deaths
< b
.Deaths
then Result
:= -1
916 else if a
.Deaths
> b
.Deaths
then Result
:= 1
917 else if a
.Kills
< b
.Kills
then Result
:= -1
921 procedure SortGameStat(var stat
: TPlayerStatArray
);
926 if stat
= nil then Exit
;
928 for I
:= High(stat
) downto Low(stat
) do
929 for J
:= Low(stat
) to High(stat
) - 1 do
930 if Compare(stat
[J
], stat
[J
+ 1]) = 1 then
933 stat
[J
] := stat
[J
+ 1];
938 // saves a shitty CSV containing the game stats passed to it
939 procedure SaveGameStat(Stat
: TEndCustomGameStat
; Path
: string);
942 dir
, fname
, map
, mode
, etime
: String;
946 dir
:= e_GetWriteableDir(StatsDirs
);
947 // stats are placed in stats/yy/mm/dd/*.csv
948 fname
:= e_CatPath(dir
, Path
);
949 ForceDirectories(fname
); // ensure yy/mm/dd exists within the stats dir
950 fname
:= e_CatPath(fname
, StatFilename
+ '.csv');
951 AssignFile(s
, fname
);
954 // line 1: stats ver, datetime, server name, map name, game mode, time limit, score limit, dmflags, game time, num players
955 if g_Game_IsNet
then fname
:= NetServerName
else fname
:= '';
956 map
:= g_ExtractWadNameNoPath(gMapInfo
.Map
) + ':/' + g_ExtractFileName(gMapInfo
.Map
);
957 mode
:= g_Game_ModeToText(Stat
.GameMode
);
958 etime
:= Format('%d:%.2d:%.2d', [
959 Stat
.GameTime
div 1000 div 3600,
960 (Stat
.GameTime
div 1000 div 60) mod 60,
961 Stat
.GameTime
div 1000 mod 60
963 WriteLn(s
, 'stats_ver,datetime,server,map,mode,timelimit,scorelimit,dmflags,time,num_players');
964 WriteLn(s
, Format('%d,%s,%s,%s,%s,%u,%u,%u,%s,%d', [
970 gGameSettings
.TimeLimit
,
971 gGameSettings
.GoalLimit
,
972 gGameSettings
.Options
,
974 Length(Stat
.PlayerStat
)
976 // line 2: game specific shit
977 // if it's a team game: red score, blue score
978 // if it's a coop game: monsters killed, monsters total, secrets found, secrets total
980 if Stat
.GameMode
in [GM_TDM
, GM_CTF
] then
982 Format('red_score,blue_score' + LineEnding
+ '%d,%d', [Stat
.TeamStat
[TEAM_RED
].Goals
, Stat
.TeamStat
[TEAM_BLUE
].Goals
]))
983 else if Stat
.GameMode
in [GM_COOP
, GM_SINGLE
] then
985 Format('mon_killed,mon_total,secrets_found,secrets_total' + LineEnding
+ '%d,%d,%d,%d',[gCoopMonstersKilled
, gTotalMonsters
, gCoopSecretsFound
, gSecretsCount
]));
986 // lines 3-...: team, player name, frags, deaths
987 WriteLn(s
, 'team,name,frags,deaths');
988 for I
:= Low(Stat
.PlayerStat
) to High(Stat
.PlayerStat
) do
989 with Stat
.PlayerStat
[I
] do
990 WriteLn(s
, Format('%d,%s,%d,%d', [Team
, dquoteStr(Name
), Frags
, Deaths
]));
992 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_WRITE
], [fname
]));
995 g_Console_Add('could not create gamestats file "' + fname
+ '"');
1000 function g_Game_ModeToText(Mode
: Byte): string;
1004 GM_DM
: Result
:= _lc
[I_MENU_GAME_TYPE_DM
];
1005 GM_TDM
: Result
:= _lc
[I_MENU_GAME_TYPE_TDM
];
1006 GM_CTF
: Result
:= _lc
[I_MENU_GAME_TYPE_CTF
];
1007 GM_COOP
: Result
:= _lc
[I_MENU_GAME_TYPE_COOP
];
1008 GM_SINGLE
: Result
:= _lc
[I_MENU_GAME_TYPE_SINGLE
];
1012 function g_Game_TextToMode(Mode
: string): Byte;
1015 Mode
:= UpperCase(Mode
);
1016 if Mode
= _lc
[I_MENU_GAME_TYPE_DM
] then
1021 if Mode
= _lc
[I_MENU_GAME_TYPE_TDM
] then
1026 if Mode
= _lc
[I_MENU_GAME_TYPE_CTF
] then
1031 if Mode
= _lc
[I_MENU_GAME_TYPE_COOP
] then
1036 if Mode
= _lc
[I_MENU_GAME_TYPE_SINGLE
] then
1038 Result
:= GM_SINGLE
;
1043 function g_Game_IsNet(): Boolean;
1045 Result
:= (gGameSettings
.GameType
in [GT_SERVER
, GT_CLIENT
]);
1048 function g_Game_IsServer(): Boolean;
1050 Result
:= (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
, GT_SERVER
]);
1053 function g_Game_IsClient(): Boolean;
1055 Result
:= (gGameSettings
.GameType
= GT_CLIENT
);
1058 function g_Game_GetMegaWADInfo(WAD
: String): TMegaWADInfo
;
1065 Result
.name
:= ExtractFileName(WAD
);
1066 Result
.description
:= '';
1067 Result
.author
:= '';
1069 w
:= TWADFile
.Create();
1072 if not w
.GetResource('INTERSCRIPT', p
, len
) then
1078 cfg
:= TConfig
.CreateMem(p
, len
);
1079 Result
.name
:= cfg
.ReadStr('megawad', 'name', ExtractFileName(WAD
));
1080 Result
.description
:= cfg
.ReadStr('megawad', 'description', '');
1081 Result
.author
:= cfg
.ReadStr('megawad', 'author', '');
1082 Result
.pic
:= cfg
.ReadStr('megawad', 'pic', '');
1088 procedure g_Game_FreeWAD
;
1091 g_Sound_Delete('MUSIC_endmus');
1092 ZeroMemory(@MegaWAD
, SizeOf(MegaWAD
));
1093 gGameSettings
.WAD
:= '';
1096 procedure g_Game_LoadWAD(WAD
: string);
1105 gGameSettings
.WAD
:= WAD
;
1106 if not (gGameSettings
.GameMode
in [GM_COOP
, GM_SINGLE
]) then
1109 MegaWAD
.info
:= g_Game_GetMegaWADInfo(WAD
);
1111 w
:= TWADFile
.Create();
1114 if not w
.GetResource('INTERSCRIPT', p
, len
) then
1120 cfg
:= TConfig
.CreateMem(p
, len
);
1123 MegaWAD
.endpic
:= cfg
.ReadStr('megawad', 'endpic', '');
1124 if MegaWAD
.endpic
<> '' then
1125 EndPicPath
:= e_GetResourcePath(WadDirs
, MegaWAD
.endpic
, WAD
);
1127 MegaWAD
.endmus
:= cfg
.ReadStr('megawad', 'endmus', 'Standart.wad:D2DMUS\КОНЕЦ');
1128 if MegaWAD
.endmus
<> '' then
1130 s
:= e_GetResourcePath(WadDirs
, MegaWAD
.endmus
, WAD
);
1131 g_Sound_CreateWADEx('MUSIC_endmus', s
, True);
1139 {procedure start_trigger(t: string);
1143 function next_trigger(): Boolean;
1147 procedure DisableCheats();
1153 if gPlayer1
<> nil then gPlayer1
.GodMode
:= False;
1154 if gPlayer2
<> nil then gPlayer2
.GodMode
:= False;
1155 if gPlayer1
<> nil then gPlayer1
.NoTarget
:= False;
1156 if gPlayer2
<> nil then gPlayer2
.NoTarget
:= False;
1158 {$IF DEFINED(D2F_DEBUG)}
1159 if gPlayer1
<> nil then gPlayer1
.NoTarget
:= True;
1160 gAimLine
:= g_dbg_aimline_on
;
1164 procedure g_Game_ExecuteEvent(Name
: String);
1170 if gEvents
= nil then
1172 for a
:= 0 to High(gEvents
) do
1173 if gEvents
[a
].Name
= Name
then
1175 if gEvents
[a
].Command
<> '' then
1176 g_Console_Process(gEvents
[a
].Command
, True);
1181 function g_Game_DelayEvent(DEType
: Byte; Time
: LongWord; Num
: Integer = 0; Str
: String = ''): Integer;
1186 if gDelayedEvents
<> nil then
1187 for a
:= 0 to High(gDelayedEvents
) do
1188 if not gDelayedEvents
[a
].Pending
then
1195 SetLength(gDelayedEvents
, Length(gDelayedEvents
) + 1);
1196 n
:= High(gDelayedEvents
);
1198 gDelayedEvents
[n
].Pending
:= True;
1199 gDelayedEvents
[n
].DEType
:= DEType
;
1200 gDelayedEvents
[n
].DENum
:= Num
;
1201 gDelayedEvents
[n
].DEStr
:= Str
;
1202 if DEType
= DE_GLOBEVENT
then
1203 gDelayedEvents
[n
].Time
:= (GetTickCount64() {div 1000}) + Time
1205 gDelayedEvents
[n
].Time
:= gTime
+ Time
;
1209 procedure EndGame();
1215 if g_Game_IsNet
and g_Game_IsServer
then
1216 MH_SEND_GameEvent(NET_EV_MAPEND
, Byte(gMissionFailed
));
1219 gPauseMain
:= false;
1220 gPauseHolmes
:= false;
1223 g_Game_StopAllSounds(False);
1228 EndingGameCounter
:= 0;
1229 g_ActiveWindow
:= nil;
1231 gLMSRespawn
:= LMS_RESPAWN_NONE
;
1232 gLMSRespawnTime
:= 0;
1235 EXIT_SIMPLE
: // Выход через меню или конец теста
1240 begin // Это был тест
1244 begin // Выход в главное меню
1245 gMusic
.SetByName('MUSIC_MENU');
1247 if gState
<> STATE_SLIST
then
1249 g_GUI_ShowWindow('MainMenu');
1250 gState
:= STATE_MENU
;
1253 // Обновляем список серверов
1254 slReturnPressed
:= True;
1255 if g_Net_Slist_Fetch(slCurrent
) then
1257 if slCurrent
= nil then
1258 slWaitStr
:= _lc
[I_NET_SLIST_NOSERVERS
];
1261 slWaitStr
:= _lc
[I_NET_SLIST_ERROR
];
1262 g_Serverlist_GenerateTable(slCurrent
, slTable
);
1265 g_Game_ExecuteEvent('ongameend');
1269 EXIT_RESTART
: // Начать уровень сначала
1271 if not g_Game_IsClient
then g_Game_Restart();
1274 EXIT_ENDLEVELCUSTOM
: // Закончился уровень в Своей игре
1276 // Статистика Своей игры:
1277 FileName
:= g_ExtractWadName(gMapInfo
.Map
);
1279 CustomStat
.GameTime
:= gTime
;
1280 CustomStat
.Map
:= ExtractFileName(FileName
)+':'+g_ExtractFileName(gMapInfo
.Map
); //ResName;
1281 CustomStat
.MapName
:= gMapInfo
.Name
;
1282 CustomStat
.GameMode
:= gGameSettings
.GameMode
;
1283 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
1284 CustomStat
.TeamStat
:= gTeamStat
;
1286 CustomStat
.PlayerStat
:= nil;
1288 // Статистика игроков:
1289 if gPlayers
<> nil then
1291 for a
:= 0 to High(gPlayers
) do
1292 if gPlayers
[a
] <> nil then
1294 SetLength(CustomStat
.PlayerStat
, Length(CustomStat
.PlayerStat
)+1);
1295 with CustomStat
.PlayerStat
[High(CustomStat
.PlayerStat
)] do
1298 Name
:= gPlayers
[a
].Name
;
1299 Frags
:= gPlayers
[a
].Frags
;
1300 Deaths
:= gPlayers
[a
].Death
;
1301 Kills
:= gPlayers
[a
].Kills
;
1302 Team
:= gPlayers
[a
].Team
;
1303 Color
:= gPlayers
[a
].Model
.Color
;
1304 Spectator
:= gPlayers
[a
].FSpectator
;
1308 SortGameStat(CustomStat
.PlayerStat
);
1310 if (gSaveStats
or gScreenshotStats
) and (Length(CustomStat
.PlayerStat
) > 1) then
1313 if g_Game_IsNet
then StatFilename
:= NetServerName
else StatFilename
:= 'local';
1314 StatDate
:= FormatDateTime('yymmdd_hhnnss', t
);
1315 StatFilename
:= StatFilename
+ '_' + CustomStat
.Map
+ '_' + g_Game_ModeToText(CustomStat
.GameMode
);
1316 StatFilename
:= sanitizeFilename(StatFilename
) + '_' + StatDate
;
1318 SaveGameStat(CustomStat
, FormatDateTime('yyyy"/"mm"/"dd', t
));
1321 StatShotDone
:= False;
1324 g_Game_ExecuteEvent('onmapend');
1325 if not g_Game_IsClient
then g_Player_ResetReady
;
1326 gInterReadyCount
:= 0;
1328 // Затухающий экран:
1329 EndingGameCounter
:= 255;
1330 gState
:= STATE_FOLD
;
1332 if gDefInterTime
< 0 then
1333 gInterEndTime
:= IfThen((gGameSettings
.GameType
= GT_SERVER
) and (gPlayer1
= nil), 15000, 25000)
1335 gInterEndTime
:= gDefInterTime
* 1000;
1338 EXIT_ENDLEVELSINGLE
: // Закончился уровень в Одиночной игре
1340 // Статистика Одиночной игры:
1341 SingleStat
.GameTime
:= gTime
;
1342 SingleStat
.TwoPlayers
:= gPlayer2
<> nil;
1343 SingleStat
.TotalSecrets
:= gSecretsCount
;
1344 // Статистика первого игрока:
1345 SingleStat
.PlayerStat
[0].Kills
:= gPlayer1
.MonsterKills
;
1346 SingleStat
.PlayerStat
[0].Secrets
:= gPlayer1
.Secrets
;
1347 // Статистика второго игрока (если есть):
1348 if SingleStat
.TwoPlayers
then
1350 SingleStat
.PlayerStat
[1].Kills
:= gPlayer2
.MonsterKills
;
1351 SingleStat
.PlayerStat
[1].Secrets
:= gPlayer2
.Secrets
;
1354 g_Game_ExecuteEvent('onmapend');
1357 if gNextMap
<> '' then
1359 gMusic
.SetByName('MUSIC_INTERMUS');
1361 gState
:= STATE_INTERSINGLE
;
1364 g_Game_ExecuteEvent('oninter');
1366 else // Больше нет карт
1368 // Затухающий экран:
1369 EndingGameCounter
:= 255;
1370 gState
:= STATE_FOLD
;
1375 // Окончание обработано:
1376 if gExit
<> EXIT_QUIT
then
1380 procedure g_Game_Init();
1384 gTempDelete
:= False;
1386 sfsGCDisable(); // temporary disable removing of temporary volumes
1389 g_Game_ClearLoading();
1390 g_Game_SetLoadingText(Format('Doom 2D: Forever %s', [GAME_VERSION
]), 0, False);
1391 g_Game_SetLoadingText('', 0, False);
1393 // g_Game_SetLoadingText(_lc[I_LOAD_MODELS], 0, False);
1396 gPauseMain
:= false;
1397 gPauseHolmes
:= false;
1400 {e_MouseInfo.Accel := 1.0;}
1402 g_Game_SetLoadingText(_lc
[I_LOAD_GAME_DATA
], 0, False);
1405 g_Game_SetLoadingText(_lc
[I_LOAD_MUSIC
], 0, False);
1406 g_Sound_CreateWADEx('MUSIC_INTERMUS', GameWAD
+':MUSIC\INTERMUS', True);
1407 g_Sound_CreateWADEx('MUSIC_MENU', GameWAD
+':MUSIC\MENU', True);
1408 g_Sound_CreateWADEx('MUSIC_ROUNDMUS', GameWAD
+':MUSIC\ROUNDMUS', True, True);
1409 g_Sound_CreateWADEx('MUSIC_STDENDMUS', GameWAD
+':MUSIC\ENDMUS', True);
1411 gMusic
:= TMusic
.Create();
1412 gMusic
.SetByName('MUSIC_MENU');
1415 gGameSettings
.WarmupTime
:= 30;
1417 gState
:= STATE_MENU
;
1419 SetLength(gEvents
, 6);
1420 gEvents
[0].Name
:= 'ongamestart';
1421 gEvents
[1].Name
:= 'ongameend';
1422 gEvents
[2].Name
:= 'onmapstart';
1423 gEvents
[3].Name
:= 'onmapend';
1424 gEvents
[4].Name
:= 'oninter';
1425 gEvents
[5].Name
:= 'onwadend';
1427 sfsGCEnable(); // enable releasing unused volumes
1431 procedure g_Game_Free(freeTextures
: Boolean=true);
1433 if NetMode
= NET_CLIENT
then g_Net_Disconnect();
1434 if NetMode
= NET_SERVER
then g_Net_Host_Die();
1436 g_Map_Free(freeTextures
);
1438 g_Player_RemoveAllCorpses();
1440 gGameSettings
.GameType
:= GT_NONE
;
1441 if gGameSettings
.GameMode
= GM_SINGLE
then
1442 gGameSettings
.GameMode
:= GM_DM
;
1443 gSwitchGameMode
:= gGameSettings
.GameMode
;
1446 gExitByTrigger
:= False;
1449 function IsActivePlayer(p
: TPlayer
): Boolean;
1454 Result
:= (not p
.FDummy
) and (not p
.FSpectator
);
1457 function GetActivePlayerID_Next(Skip
: Integer = -1): Integer;
1463 if gPlayers
= nil then
1467 for a
:= Low(gPlayers
) to High(gPlayers
) do
1468 if IsActivePlayer(gPlayers
[a
]) then
1470 SetLength(ids
, Length(ids
) + 1);
1471 ids
[High(ids
)] := gPlayers
[a
].UID
;
1472 if gPlayers
[a
].UID
= Skip
then
1475 if Length(ids
) = 0 then
1480 Result
:= ids
[(idx
+ 1) mod Length(ids
)];
1483 function GetActivePlayerID_Prev(Skip
: Integer = -1): Integer;
1489 if gPlayers
= nil then
1493 for a
:= Low(gPlayers
) to High(gPlayers
) do
1494 if IsActivePlayer(gPlayers
[a
]) then
1496 SetLength(ids
, Length(ids
) + 1);
1497 ids
[High(ids
)] := gPlayers
[a
].UID
;
1498 if gPlayers
[a
].UID
= Skip
then
1501 if Length(ids
) = 0 then
1504 Result
:= ids
[Length(ids
) - 1]
1506 Result
:= ids
[(Length(ids
) - 1 + idx
) mod Length(ids
)];
1509 function GetActivePlayerID_Random(Skip
: Integer = -1): Integer;
1515 if gPlayers
= nil then
1519 for a
:= Low(gPlayers
) to High(gPlayers
) do
1520 if IsActivePlayer(gPlayers
[a
]) then
1522 SetLength(ids
, Length(ids
) + 1);
1523 ids
[High(ids
)] := gPlayers
[a
].UID
;
1524 if gPlayers
[a
].UID
= Skip
then
1527 if Length(ids
) = 0 then
1529 if Length(ids
) = 1 then
1534 Result
:= ids
[Random(Length(ids
))];
1536 while (idx
<> -1) and (Result
= Skip
) and (a
> 0) do
1538 Result
:= ids
[Random(Length(ids
))];
1543 function GetRandomSpectMode(Current
: Byte): Byte;
1550 0: Result
:= SPECT_STATS
;
1551 1: Result
:= SPECT_MAPVIEW
;
1552 2: Result
:= SPECT_MAPVIEW
;
1553 3: Result
:= SPECT_PLAYERS
;
1554 4: Result
:= SPECT_PLAYERS
;
1555 5: Result
:= SPECT_PLAYERS
;
1556 6: Result
:= SPECT_PLAYERS
;
1558 if (Current
in [SPECT_STATS
, SPECT_MAPVIEW
]) and (Current
= Result
) then
1562 procedure ProcessPlayerControls (plr
: TPlayer
; p
: Integer; var MoveButton
: Byte);
1568 if (plr
= nil) then exit
;
1569 if (p
= 2) then time
:= 1000 else time
:= 1;
1570 strafeDir
:= MoveButton
shr 4;
1571 MoveButton
:= MoveButton
and $0F;
1573 if gPlayerAction
[p
, ACTION_MOVELEFT
] and (not gPlayerAction
[p
, ACTION_MOVERIGHT
]) then
1574 MoveButton
:= 1 // Нажата только "Влево"
1575 else if (not gPlayerAction
[p
, ACTION_MOVELEFT
]) and gPlayerAction
[p
, ACTION_MOVERIGHT
] then
1576 MoveButton
:= 2 // Нажата только "Вправо"
1577 else if (not gPlayerAction
[p
, ACTION_MOVELEFT
]) and (not gPlayerAction
[p
, ACTION_MOVERIGHT
]) then
1578 MoveButton
:= 0; // Не нажаты ни "Влево", ни "Вправо"
1580 // Сейчас или раньше были нажаты "Влево"/"Вправо" => передаем игроку:
1581 if MoveButton
= 1 then
1582 plr
.PressKey(KEY_LEFT
, time
)
1583 else if MoveButton
= 2 then
1584 plr
.PressKey(KEY_RIGHT
, time
);
1586 // if we have "strafe" key, turn off old strafe mechanics
1587 if gPlayerAction
[p
, ACTION_STRAFE
] then
1589 // new strafe mechanics
1590 if (strafeDir
= 0) then
1591 strafeDir
:= MoveButton
; // start strafing
1592 // now set direction according to strafe (reversed)
1593 if (strafeDir
= 2) then
1594 plr
.SetDirection(TDirection
.D_LEFT
)
1595 else if (strafeDir
= 1) then
1596 plr
.SetDirection(TDirection
.D_RIGHT
)
1600 strafeDir
:= 0; // not strafing anymore
1601 // Раньше была нажата "Вправо", а сейчас "Влево" => бежим вправо, смотрим влево:
1602 if (MoveButton
= 2) and gPlayerAction
[p
, ACTION_MOVELEFT
] then
1603 plr
.SetDirection(TDirection
.D_LEFT
)
1604 // Раньше была нажата "Влево", а сейчас "Вправо" => бежим влево, смотрим вправо:
1605 else if (MoveButton
= 1) and gPlayerAction
[p
, ACTION_MOVERIGHT
] then
1606 plr
.SetDirection(TDirection
.D_RIGHT
)
1607 // Что-то было нажато и не изменилось => куда бежим, туда и смотрим:
1608 else if MoveButton
<> 0 then
1609 plr
.SetDirection(TDirection(MoveButton
-1))
1612 // fix movebutton state
1613 MoveButton
:= MoveButton
or (strafeDir
shl 4);
1615 // Остальные клавиши:
1616 if gPlayerAction
[p
, ACTION_JUMP
] then plr
.PressKey(KEY_JUMP
, time
);
1617 if gPlayerAction
[p
, ACTION_LOOKUP
] then plr
.PressKey(KEY_UP
, time
);
1618 if gPlayerAction
[p
, ACTION_LOOKDOWN
] then plr
.PressKey(KEY_DOWN
, time
);
1619 if gPlayerAction
[p
, ACTION_ATTACK
] then plr
.PressKey(KEY_FIRE
);
1620 if gPlayerAction
[p
, ACTION_WEAPNEXT
] then plr
.PressKey(KEY_NEXTWEAPON
);
1621 if gPlayerAction
[p
, ACTION_WEAPPREV
] then plr
.PressKey(KEY_PREVWEAPON
);
1622 if gPlayerAction
[p
, ACTION_ACTIVATE
] then plr
.PressKey(KEY_OPEN
);
1624 gPlayerAction
[p
, ACTION_WEAPNEXT
] := False; // HACK, remove after readyweaon&pendinweapon implementation
1625 gPlayerAction
[p
, ACTION_WEAPPREV
] := False; // HACK, remove after readyweaon&pendinweapon implementation
1627 for i
:= WP_FIRST
to WP_LAST
do
1629 if gSelectWeapon
[p
, i
] then
1631 plr
.QueueWeaponSwitch(i
); // all choices are passed there, and god will take the best
1632 gSelectWeapon
[p
, i
] := False
1636 // HACK: add dynlight here
1637 if gwin_k8_enable_light_experiments
then
1639 if e_KeyPressed(IK_F8
) and gGameOn
and (not gConsoleShow
) and (g_ActiveWindow
= nil) then
1641 g_playerLight
:= true;
1643 if e_KeyPressed(IK_F9
) and gGameOn
and (not gConsoleShow
) and (g_ActiveWindow
= nil) then
1645 g_playerLight
:= false;
1649 if gwin_has_stencil
and g_playerLight
then g_AddDynLight(plr
.GameX
+32, plr
.GameY
+40, 128, 1, 1, 0, 0.6);
1652 // HACK: don't have a "key was pressed" function
1653 procedure InterReady();
1655 if InterReadyTime
> gTime
then Exit
;
1656 InterReadyTime
:= gTime
+ 3000;
1657 MC_SEND_CheatRequest(NET_CHEAT_READY
);
1660 procedure g_Game_PreUpdate();
1662 // these are in separate PreUpdate functions because they can interact during Update()
1663 // and are synced over the net
1664 // we don't care that much about corpses and gibs
1665 g_Player_PreUpdate();
1666 g_Monsters_PreUpdate();
1667 g_Items_PreUpdate();
1668 g_Weapon_PreUpdate();
1671 procedure g_Game_Update();
1673 Msg
: g_gui
.TMessage
;
1679 function sendMonsPos (mon
: TMonster
): Boolean;
1681 result
:= false; // don't stop
1682 // this will also reset "need-send" flag
1683 if mon
.gncNeedSend
then
1685 MH_SEND_MonsterPos(mon
.UID
);
1687 else if (mon
.MonsterType
= MONSTER_BARREL
) then
1689 if (mon
.GameVelX
<> 0) or (mon
.GameVelY
<> 0) then MH_SEND_MonsterPos(mon
.UID
);
1691 else if (mon
.MonsterState
<> MONSTATE_SLEEP
) then
1693 if (mon
.MonsterState
<> MONSTATE_DEAD
) or (mon
.GameVelX
<> 0) or (mon
.GameVelY
<> 0) then MH_SEND_MonsterPos(mon
.UID
);
1697 function sendMonsPosUnexpected (mon
: TMonster
): Boolean;
1699 result
:= false; // don't stop
1700 // this will also reset "need-send" flag
1701 if mon
.gncNeedSend
then MH_SEND_MonsterPos(mon
.UID
);
1705 reliableUpdate
: Boolean;
1710 // Пора выключать игру:
1711 if gExit
= EXIT_QUIT
then
1713 // Игра закончилась - обрабатываем:
1717 if gExit
= EXIT_QUIT
then
1721 // Читаем клавиатуру и джойстик, если окно активно
1722 // no need to, as we'll do it in event handler
1724 // Обновляем консоль (движение и сообщения):
1728 if (NetMode
= NET_NONE
) and (g_Game_IsNet
) and (gGameOn
or (gState
in [STATE_FOLD
, STATE_INTERCUSTOM
])) then
1730 gExit
:= EXIT_SIMPLE
;
1735 // process master server communications
1736 g_Net_Slist_Pulse();
1739 STATE_INTERSINGLE
, // Статистка после прохождения уровня в Одиночной игре
1740 STATE_INTERCUSTOM
, // Статистка после прохождения уровня в Своей игре
1741 STATE_INTERTEXT
, // Текст между уровнями
1742 STATE_INTERPIC
: // Картинка между уровнями
1744 if g_Game_IsNet
and g_Game_IsServer
then
1746 gInterTime
:= gInterTime
+ GAME_TICK
;
1747 a
:= Min((gInterEndTime
- gInterTime
) div 1000 + 1, 255);
1748 if a
<> gServInterTime
then
1750 gServInterTime
:= a
;
1751 MH_SEND_TimeSync(gServInterTime
);
1755 if (not g_Game_IsClient
) and
1759 e_KeyPressed(IK_RETURN
) or e_KeyPressed(IK_KPRETURN
) or e_KeyPressed(IK_SPACE
) or
1760 e_KeyPressed(VK_FIRE
) or e_KeyPressed(VK_OPEN
) or
1761 e_KeyPressed(JOY0_ATTACK
) or e_KeyPressed(JOY1_ATTACK
) or
1762 e_KeyPressed(JOY2_ATTACK
) or e_KeyPressed(JOY3_ATTACK
)
1764 and (not gJustChatted
) and (not gConsoleShow
) and (not gChatShow
)
1765 and (g_ActiveWindow
= nil)
1767 or (g_Game_IsNet
and ((gInterTime
> gInterEndTime
) or ((gInterReadyCount
>= NetClientCount
) and (NetClientCount
> 0))))
1770 begin // Нажали <Enter>/<Пробел> или прошло достаточно времени:
1771 g_Game_StopAllSounds(True);
1773 if gMapOnce
then // Это был тест
1774 gExit
:= EXIT_SIMPLE
1776 if gNextMap
<> '' then // Переходим на следующую карту
1777 g_Game_ChangeMap(gNextMap
)
1778 else // Следующей карты нет
1780 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
] then
1782 // Выход в главное меню:
1784 g_GUI_ShowWindow('MainMenu');
1785 gMusic
.SetByName('MUSIC_MENU');
1787 gState
:= STATE_MENU
;
1790 // Финальная картинка:
1791 g_Game_ExecuteEvent('onwadend');
1793 if not gMusic
.SetByName('MUSIC_endmus') then
1794 gMusic
.SetByName('MUSIC_STDENDMUS');
1796 gState
:= STATE_ENDPIC
;
1798 g_Game_ExecuteEvent('ongameend');
1803 else if g_Game_IsClient
and
1806 e_KeyPressed(IK_RETURN
) or e_KeyPressed(IK_KPRETURN
) or e_KeyPressed(IK_SPACE
) or
1807 e_KeyPressed(VK_FIRE
) or e_KeyPressed(VK_OPEN
) or
1808 e_KeyPressed(JOY0_ATTACK
) or e_KeyPressed(JOY1_ATTACK
) or
1809 e_KeyPressed(JOY2_ATTACK
) or e_KeyPressed(JOY3_ATTACK
)
1811 and (not gJustChatted
) and (not gConsoleShow
) and (not gChatShow
)
1812 and (g_ActiveWindow
= nil)
1820 if gState
= STATE_INTERTEXT
then
1821 if InterText
.counter
> 0 then
1822 InterText
.counter
:= InterText
.counter
- 1;
1825 STATE_FOLD
: // Затухание экрана
1827 if EndingGameCounter
= 0 then
1829 // Закончился уровень в Своей игре:
1830 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
1832 InterReadyTime
:= -1;
1833 if gLastMap
and (gGameSettings
.GameMode
= GM_COOP
) then
1835 g_Game_ExecuteEvent('onwadend');
1836 if not gMusic
.SetByName('MUSIC_endmus') then
1837 gMusic
.SetByName('MUSIC_STDENDMUS');
1840 gMusic
.SetByName('MUSIC_ROUNDMUS');
1843 gState
:= STATE_INTERCUSTOM
;
1846 else // Закончилась последняя карта в Одиночной игре
1848 gMusic
.SetByName('MUSIC_INTERMUS');
1850 gState
:= STATE_INTERSINGLE
;
1853 g_Game_ExecuteEvent('oninter');
1856 DecMin(EndingGameCounter
, 6, 0);
1859 STATE_ENDPIC
: // Картинка окончания мегаВада
1861 if gMapOnce
then // Это был тест
1863 gExit
:= EXIT_SIMPLE
;
1869 g_Serverlist_Control(slCurrent
, slTable
);
1872 // Статистика по Tab:
1874 IsDrawStat
:= (not gConsoleShow
) and (not gChatShow
) and (gGameSettings
.GameType
<> GT_SINGLE
) and g_Console_Action(ACTION_SCORES
);
1877 if gGameOn
and not gPause
and (gState
<> STATE_FOLD
) then
1879 // Время += 28 миллисекунд:
1880 gTime
:= gTime
+ GAME_TICK
;
1882 // Сообщение посередине экрана:
1883 if MessageTime
= 0 then
1885 if MessageTime
> 0 then
1886 MessageTime
:= MessageTime
- 1;
1888 if (g_Game_IsServer
) then
1890 // Был задан лимит времени:
1891 if (gGameSettings
.TimeLimit
> 0) then
1892 if (gTime
- gGameStartTime
) div 1000 >= gGameSettings
.TimeLimit
then
1893 begin // Он прошел => конец уровня
1898 // Надо респавнить игроков в LMS:
1899 if (gLMSRespawn
> LMS_RESPAWN_NONE
) and (gLMSRespawnTime
< gTime
) then
1900 g_Game_RestartRound(gLMSSoftSpawn
);
1902 // Проверим результат голосования, если время прошло
1903 if gVoteInProgress
and (gVoteTimer
< gTime
) then
1905 else if gVotePassed
and (gVoteCmdTimer
< gTime
) then
1907 g_Console_Process(gVoteCommand
);
1909 gVotePassed
:= False;
1912 // Замеряем время захвата флагов
1913 if gFlags
[FLAG_RED
].State
= FLAG_STATE_CAPTURED
then
1914 gFlags
[FLAG_RED
].CaptureTime
:= gFlags
[FLAG_RED
].CaptureTime
+ GAME_TICK
;
1915 if gFlags
[FLAG_BLUE
].State
= FLAG_STATE_CAPTURED
then
1916 gFlags
[FLAG_BLUE
].CaptureTime
:= gFlags
[FLAG_BLUE
].CaptureTime
+ GAME_TICK
;
1918 // Был задан лимит побед:
1919 if (gGameSettings
.GoalLimit
> 0) then
1923 if gGameSettings
.GameMode
= GM_DM
then
1924 begin // В DM ищем игрока с max фрагами
1925 for i
:= 0 to High(gPlayers
) do
1926 if gPlayers
[i
] <> nil then
1927 if gPlayers
[i
].Frags
> b
then
1928 b
:= gPlayers
[i
].Frags
;
1931 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
1932 begin // В CTF/TDM выбираем команду с наибольшим счетом
1933 b
:= Max(gTeamStat
[TEAM_RED
].Goals
, gTeamStat
[TEAM_BLUE
].Goals
);
1936 // Лимит побед набран => конец уровня:
1937 if b
>= gGameSettings
.GoalLimit
then
1944 // Обрабатываем клавиши игроков:
1945 if gPlayer1
<> nil then gPlayer1
.ReleaseKeys();
1946 if gPlayer2
<> nil then gPlayer2
.ReleaseKeys();
1947 if (not gConsoleShow
) and (not gChatShow
) and (g_ActiveWindow
= nil) then
1949 ProcessPlayerControls(gPlayer1
, 0, P1MoveButton
);
1950 ProcessPlayerControls(gPlayer2
, 1, P2MoveButton
);
1951 end // if not console
1954 if g_Game_IsNet
and (gPlayer1
<> nil) then gPlayer1
.PressKey(KEY_CHAT
, 10000);
1956 // process weapon switch queue
1960 if (gPlayer1
= nil) and (gPlayer2
= nil) and
1961 (not gConsoleShow
) and (not gChatShow
) and (g_ActiveWindow
= nil) then
1963 if not gSpectKeyPress
then
1965 if gPlayerAction
[0, ACTION_JUMP
] and (not gSpectAuto
) then
1967 // switch spect mode
1969 SPECT_NONE
: ; // not spectator
1971 SPECT_MAPVIEW
: Inc(gSpectMode
);
1972 SPECT_PLAYERS
: gSpectMode
:= SPECT_STATS
; // reset to 1
1974 gSpectKeyPress
:= True;
1976 if (gSpectMode
= SPECT_MAPVIEW
)
1977 and (not gSpectAuto
) then
1979 if gPlayerAction
[0, ACTION_MOVELEFT
] then
1980 gSpectX
:= Max(gSpectX
- gSpectStep
, 0);
1981 if gPlayerAction
[0, ACTION_MOVERIGHT
] then
1982 gSpectX
:= Min(gSpectX
+ gSpectStep
, gMapInfo
.Width
- gScreenWidth
);
1983 if gPlayerAction
[0, ACTION_LOOKUP
] then
1984 gSpectY
:= Max(gSpectY
- gSpectStep
, 0);
1985 if gPlayerAction
[0, ACTION_LOOKDOWN
] then
1986 gSpectY
:= Min(gSpectY
+ gSpectStep
, gMapInfo
.Height
- gScreenHeight
);
1987 if gPlayerAction
[0, ACTION_WEAPPREV
] then
1990 if gSpectStep
> 4 then gSpectStep
:= gSpectStep
shr 1;
1991 gSpectKeyPress
:= True;
1993 if gPlayerAction
[0, ACTION_WEAPNEXT
] then
1996 if gSpectStep
< 64 then gSpectStep
:= gSpectStep
shl 1;
1997 gSpectKeyPress
:= True;
2000 if (gSpectMode
= SPECT_PLAYERS
)
2001 and (not gSpectAuto
) then
2003 if gPlayerAction
[0, ACTION_LOOKUP
] then
2006 gSpectViewTwo
:= True;
2007 gSpectKeyPress
:= True;
2009 if gPlayerAction
[0, ACTION_LOOKDOWN
] then
2011 // remove second view
2012 gSpectViewTwo
:= False;
2013 gSpectKeyPress
:= True;
2015 if gPlayerAction
[0, ACTION_MOVELEFT
] then
2017 // prev player (view 1)
2018 gSpectPID1
:= GetActivePlayerID_Prev(gSpectPID1
);
2019 gSpectKeyPress
:= True;
2021 if gPlayerAction
[0, ACTION_MOVERIGHT
] then
2023 // next player (view 1)
2024 gSpectPID1
:= GetActivePlayerID_Next(gSpectPID1
);
2025 gSpectKeyPress
:= True;
2027 if gPlayerAction
[0, ACTION_WEAPPREV
] then
2029 // prev player (view 2)
2030 gSpectPID2
:= GetActivePlayerID_Prev(gSpectPID2
);
2031 gSpectKeyPress
:= True;
2033 if gPlayerAction
[0, ACTION_WEAPNEXT
] then
2035 // next player (view 2)
2036 gSpectPID2
:= GetActivePlayerID_Next(gSpectPID2
);
2037 gSpectKeyPress
:= True;
2040 if gPlayerAction
[0, ACTION_ATTACK
] then
2042 if (gSpectMode
= SPECT_STATS
) and (not gSpectAuto
) then
2045 gSpectAutoNext
:= 0;
2046 gSpectViewTwo
:= False;
2047 gSpectKeyPress
:= True;
2052 gSpectMode
:= SPECT_STATS
;
2053 gSpectAuto
:= False;
2054 gSpectKeyPress
:= True;
2059 if (not gPlayerAction
[0, ACTION_JUMP
]) and
2060 (not gPlayerAction
[0, ACTION_ATTACK
]) and
2061 (not gPlayerAction
[0, ACTION_MOVELEFT
]) and
2062 (not gPlayerAction
[0, ACTION_MOVERIGHT
]) and
2063 (not gPlayerAction
[0, ACTION_LOOKUP
]) and
2064 (not gPlayerAction
[0, ACTION_LOOKDOWN
]) and
2065 (not gPlayerAction
[0, ACTION_WEAPPREV
]) and
2066 (not gPlayerAction
[0, ACTION_WEAPNEXT
]) then
2067 gSpectKeyPress
:= False;
2071 if gSpectMode
= SPECT_MAPVIEW
then
2073 i
:= Min(Max(gSpectX
+ gSpectAutoStepX
, 0), gMapInfo
.Width
- gScreenWidth
);
2075 gSpectAutoNext
:= gTime
2078 i
:= Min(Max(gSpectY
+ gSpectAutoStepY
, 0), gMapInfo
.Height
- gScreenHeight
);
2080 gSpectAutoNext
:= gTime
2084 if gSpectAutoNext
<= gTime
then
2086 if gSpectAutoNext
> 0 then
2088 gSpectMode
:= GetRandomSpectMode(gSpectMode
);
2092 gSpectX
:= Random(gMapInfo
.Width
- gScreenWidth
);
2093 gSpectY
:= Random(gMapInfo
.Height
- gScreenHeight
);
2094 gSpectAutoStepX
:= Random(9) - 4;
2095 gSpectAutoStepY
:= Random(9) - 4;
2096 if ((gSpectX
< 800) and (gSpectAutoStepX
< 0)) or
2097 ((gSpectX
> gMapInfo
.Width
- gScreenWidth
- 800) and (gSpectAutoStepX
> 0)) then
2098 gSpectAutoStepX
:= gSpectAutoStepX
* -1;
2099 if ((gSpectY
< 800) and (gSpectAutoStepY
< 0)) or
2100 ((gSpectY
> gMapInfo
.Height
- gScreenHeight
- 800) and (gSpectAutoStepY
> 0)) then
2101 gSpectAutoStepY
:= gSpectAutoStepY
* -1;
2105 gSpectPID1
:= GetActivePlayerID_Random(gSpectPID1
);
2110 SPECT_STATS
: gSpectAutoNext
:= gTime
+ (Random(3) + 5) * 1000;
2111 SPECT_MAPVIEW
: gSpectAutoNext
:= gTime
+ (Random(4) + 7) * 1000;
2112 SPECT_PLAYERS
: gSpectAutoNext
:= gTime
+ (Random(7) + 8) * 1000;
2118 // Обновляем все остальное:
2121 g_Triggers_Update();
2123 g_Monsters_Update();
2126 g_Player_UpdateAll();
2127 g_Player_UpdatePhysicalObjects();
2129 // server: send newly spawned monsters unconditionally
2130 if (gGameSettings
.GameType
= GT_SERVER
) then
2132 if (Length(gMonstersSpawned
) > 0) then
2134 for I
:= 0 to High(gMonstersSpawned
) do MH_SEND_MonsterSpawn(gMonstersSpawned
[I
]);
2135 SetLength(gMonstersSpawned
, 0);
2139 if (gSoundTriggerTime
> 8) then
2141 g_Game_UpdateTriggerSounds();
2142 gSoundTriggerTime
:= 0;
2146 Inc(gSoundTriggerTime
);
2149 if (NetMode
= NET_SERVER
) then
2151 Inc(NetTimeToUpdate
);
2152 Inc(NetTimeToReliable
);
2154 // send monster updates
2155 if (NetTimeToReliable
>= NetRelupdRate
) or (NetTimeToUpdate
>= NetUpdateRate
) then
2157 // send all monsters (periodic sync)
2158 reliableUpdate
:= (NetTimeToReliable
>= NetRelupdRate
);
2160 for I
:= 0 to High(gPlayers
) do
2162 if (gPlayers
[I
] <> nil) then MH_SEND_PlayerPos(reliableUpdate
, gPlayers
[I
].UID
);
2165 g_Mons_ForEach(sendMonsPos
);
2167 if reliableUpdate
then
2169 NetTimeToReliable
:= 0;
2170 NetTimeToUpdate
:= NetUpdateRate
;
2174 NetTimeToUpdate
:= 0;
2179 // send only mosters with some unexpected changes
2180 g_Mons_ForEach(sendMonsPosUnexpected
);
2183 // send unexpected platform changes
2184 g_Map_NetSendInterestingPanels();
2186 g_Net_Slist_ServerUpdate();
2188 if NetUseMaster then
2190 if (gTime >= NetTimeToMaster) or g_Net_Slist_IsConnectionInProgress then
2192 if (not g_Net_Slist_IsConnectionActive) then g_Net_Slist_Connect(false); // non-blocking connection to the master
2194 NetTimeToMaster := gTime + NetMasterRate;
2199 else if (NetMode
= NET_CLIENT
) then
2201 MC_SEND_PlayerPos();
2203 end; // if gameOn ...
2205 // Активно окно интерфейса - передаем клавиши ему:
2206 if g_ActiveWindow
<> nil then
2208 w
:= e_GetFirstKeyPressed();
2210 if (w
<> IK_INVALID
) then
2212 Msg
.Msg
:= MESSAGE_DIKEY
;
2214 g_ActiveWindow
.OnMessage(Msg
);
2217 // Если оно от этого не закрылось, то обновляем:
2218 if g_ActiveWindow
<> nil then
2219 g_ActiveWindow
.Update();
2221 // Нужно сменить разрешение:
2222 if gResolutionChange
then
2224 e_WriteLog('Changing resolution', TMsgType
.Notify
);
2226 gResolutionChange
:= False;
2227 g_ActiveWindow
:= nil;
2230 // Нужно сменить язык:
2231 if gLanguageChange
then
2233 //e_WriteLog('Read language file', MSG_NOTIFY);
2234 //g_Language_Load(DataDir + gLanguage + '.txt');
2235 g_Language_Set(gLanguage
);
2239 gLanguageChange
:= False;
2243 // Горячая клавиша для вызова меню выхода из игры (F10):
2244 if e_KeyPressed(IK_F10
) and
2246 (not gConsoleShow
) and
2247 (g_ActiveWindow
= nil) then
2252 Time
:= GetTickCount64() {div 1000};
2254 // Обработка отложенных событий:
2255 if gDelayedEvents
<> nil then
2256 for a
:= 0 to High(gDelayedEvents
) do
2257 if gDelayedEvents
[a
].Pending
and
2259 ((gDelayedEvents
[a
].DEType
= DE_GLOBEVENT
) and (gDelayedEvents
[a
].Time
<= Time
)) or
2260 ((gDelayedEvents
[a
].DEType
> DE_GLOBEVENT
) and (gDelayedEvents
[a
].Time
<= gTime
))
2263 case gDelayedEvents
[a
].DEType
of
2265 g_Game_ExecuteEvent(gDelayedEvents
[a
].DEStr
);
2268 g_Game_Announce_GoodShot(gDelayedEvents
[a
].DENum
);
2272 g_Game_Announce_KillCombo(gDelayedEvents
[a
].DENum
);
2273 if g_Game_IsNet
and g_Game_IsServer
then
2274 MH_SEND_GameEvent(NET_EV_KILLCOMBO
, gDelayedEvents
[a
].DENum
);
2278 g_Game_Announce_BodyKill(gDelayedEvents
[a
].DENum
);
2280 gDelayedEvents
[a
].Pending
:= False;
2283 // Каждую секунду обновляем счетчик обновлений:
2284 UPSCounter
:= UPSCounter
+ 1;
2285 if Time
- UPSTime
>= 1000 then
2294 g_Weapon_AddDynLights();
2295 g_Items_AddDynLights();
2299 procedure g_Game_LoadChatSounds(Resource
: string);
2302 FileName
, Snd
: string;
2304 len
, cnt
, tags
, i
, j
: Integer;
2307 FileName
:= g_ExtractWadName(Resource
);
2309 WAD
:= TWADFile
.Create();
2310 WAD
.ReadFile(FileName
);
2312 if not WAD
.GetResource(g_ExtractFilePathName(Resource
), p
, len
) then
2319 cfg
:= TConfig
.CreateMem(p
, len
);
2320 cnt
:= cfg
.ReadInt('ChatSounds', 'Count', 0);
2322 SetLength(gChatSounds
, cnt
);
2323 for i
:= 0 to Length(gChatSounds
) - 1 do
2325 gChatSounds
[i
].Sound
:= nil;
2326 Snd
:= Trim(cfg
.ReadStr(IntToStr(i
), 'Sound', ''));
2327 tags
:= cfg
.ReadInt(IntToStr(i
), 'Tags', 0);
2328 if (Snd
= '') or (Tags
<= 0) then
2330 g_Sound_CreateWADEx('SOUND_CHAT_MACRO' + IntToStr(i
), GameWAD
+':'+Snd
);
2331 gChatSounds
[i
].Sound
:= TPlayableSound
.Create();
2332 gChatSounds
[i
].Sound
.SetByName('SOUND_CHAT_MACRO' + IntToStr(i
));
2333 SetLength(gChatSounds
[i
].Tags
, tags
);
2334 for j
:= 0 to tags
- 1 do
2335 gChatSounds
[i
].Tags
[j
] := toLowerCase1251(cfg
.ReadStr(IntToStr(i
), 'Tag' + IntToStr(j
), ''));
2336 gChatSounds
[i
].FullWord
:= cfg
.ReadBool(IntToStr(i
), 'FullWord', False);
2343 procedure g_Game_FreeChatSounds();
2347 for i
:= 0 to Length(gChatSounds
) - 1 do
2349 gChatSounds
[i
].Sound
.Free();
2350 g_Sound_Delete('SOUND_CHAT_MACRO' + IntToStr(i
));
2352 SetLength(gChatSounds
, 0);
2356 procedure g_Game_LoadData();
2358 if DataLoaded
then Exit
;
2360 e_WriteLog('Loading game data...', TMsgType
.Notify
);
2362 g_Sound_CreateWADEx('SOUND_GAME_TELEPORT', GameWAD
+':SOUNDS\TELEPORT');
2363 g_Sound_CreateWADEx('SOUND_GAME_NOTELEPORT', GameWAD
+':SOUNDS\NOTELEPORT');
2364 g_Sound_CreateWADEx('SOUND_GAME_SECRET', GameWAD
+':SOUNDS\SECRET');
2365 g_Sound_CreateWADEx('SOUND_GAME_DOOROPEN', GameWAD
+':SOUNDS\DOOROPEN');
2366 g_Sound_CreateWADEx('SOUND_GAME_DOORCLOSE', GameWAD
+':SOUNDS\DOORCLOSE');
2367 g_Sound_CreateWADEx('SOUND_GAME_BULK1', GameWAD
+':SOUNDS\BULK1');
2368 g_Sound_CreateWADEx('SOUND_GAME_BULK2', GameWAD
+':SOUNDS\BULK2');
2369 g_Sound_CreateWADEx('SOUND_GAME_BUBBLE1', GameWAD
+':SOUNDS\BUBBLE1');
2370 g_Sound_CreateWADEx('SOUND_GAME_BUBBLE2', GameWAD
+':SOUNDS\BUBBLE2');
2371 g_Sound_CreateWADEx('SOUND_GAME_BURNING', GameWAD
+':SOUNDS\BURNING');
2372 g_Sound_CreateWADEx('SOUND_GAME_SWITCH1', GameWAD
+':SOUNDS\SWITCH1');
2373 g_Sound_CreateWADEx('SOUND_GAME_SWITCH0', GameWAD
+':SOUNDS\SWITCH0');
2374 g_Sound_CreateWADEx('SOUND_GAME_RADIO', GameWAD
+':SOUNDS\RADIO');
2375 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD1', GameWAD
+':SOUNDS\GOOD1');
2376 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD2', GameWAD
+':SOUNDS\GOOD2');
2377 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD3', GameWAD
+':SOUNDS\GOOD3');
2378 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD4', GameWAD
+':SOUNDS\GOOD4');
2379 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL2X', GameWAD
+':SOUNDS\KILL2X');
2380 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL3X', GameWAD
+':SOUNDS\KILL3X');
2381 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL4X', GameWAD
+':SOUNDS\KILL4X');
2382 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILLMX', GameWAD
+':SOUNDS\KILLMX');
2383 g_Sound_CreateWADEx('SOUND_ANNOUNCER_MUHAHA1', GameWAD
+':SOUNDS\MUHAHA1');
2384 g_Sound_CreateWADEx('SOUND_ANNOUNCER_MUHAHA2', GameWAD
+':SOUNDS\MUHAHA2');
2385 g_Sound_CreateWADEx('SOUND_ANNOUNCER_MUHAHA3', GameWAD
+':SOUNDS\MUHAHA3');
2386 g_Sound_CreateWADEx('SOUND_CTF_GET1', GameWAD
+':SOUNDS\GETFLAG1');
2387 g_Sound_CreateWADEx('SOUND_CTF_GET2', GameWAD
+':SOUNDS\GETFLAG2');
2388 g_Sound_CreateWADEx('SOUND_CTF_LOST1', GameWAD
+':SOUNDS\LOSTFLG1');
2389 g_Sound_CreateWADEx('SOUND_CTF_LOST2', GameWAD
+':SOUNDS\LOSTFLG2');
2390 g_Sound_CreateWADEx('SOUND_CTF_RETURN1', GameWAD
+':SOUNDS\RETFLAG1');
2391 g_Sound_CreateWADEx('SOUND_CTF_RETURN2', GameWAD
+':SOUNDS\RETFLAG2');
2392 g_Sound_CreateWADEx('SOUND_CTF_CAPTURE1', GameWAD
+':SOUNDS\CAPFLAG1');
2393 g_Sound_CreateWADEx('SOUND_CTF_CAPTURE2', GameWAD
+':SOUNDS\CAPFLAG2');
2395 goodsnd
[0] := TPlayableSound
.Create();
2396 goodsnd
[1] := TPlayableSound
.Create();
2397 goodsnd
[2] := TPlayableSound
.Create();
2398 goodsnd
[3] := TPlayableSound
.Create();
2400 goodsnd
[0].SetByName('SOUND_ANNOUNCER_GOOD1');
2401 goodsnd
[1].SetByName('SOUND_ANNOUNCER_GOOD2');
2402 goodsnd
[2].SetByName('SOUND_ANNOUNCER_GOOD3');
2403 goodsnd
[3].SetByName('SOUND_ANNOUNCER_GOOD4');
2405 killsnd
[0] := TPlayableSound
.Create();
2406 killsnd
[1] := TPlayableSound
.Create();
2407 killsnd
[2] := TPlayableSound
.Create();
2408 killsnd
[3] := TPlayableSound
.Create();
2410 killsnd
[0].SetByName('SOUND_ANNOUNCER_KILL2X');
2411 killsnd
[1].SetByName('SOUND_ANNOUNCER_KILL3X');
2412 killsnd
[2].SetByName('SOUND_ANNOUNCER_KILL4X');
2413 killsnd
[3].SetByName('SOUND_ANNOUNCER_KILLMX');
2415 hahasnd
[0] := TPlayableSound
.Create();
2416 hahasnd
[1] := TPlayableSound
.Create();
2417 hahasnd
[2] := TPlayableSound
.Create();
2419 hahasnd
[0].SetByName('SOUND_ANNOUNCER_MUHAHA1');
2420 hahasnd
[1].SetByName('SOUND_ANNOUNCER_MUHAHA2');
2421 hahasnd
[2].SetByName('SOUND_ANNOUNCER_MUHAHA3');
2423 sound_get_flag
[0] := TPlayableSound
.Create();
2424 sound_get_flag
[1] := TPlayableSound
.Create();
2425 sound_lost_flag
[0] := TPlayableSound
.Create();
2426 sound_lost_flag
[1] := TPlayableSound
.Create();
2427 sound_ret_flag
[0] := TPlayableSound
.Create();
2428 sound_ret_flag
[1] := TPlayableSound
.Create();
2429 sound_cap_flag
[0] := TPlayableSound
.Create();
2430 sound_cap_flag
[1] := TPlayableSound
.Create();
2432 sound_get_flag
[0].SetByName('SOUND_CTF_GET1');
2433 sound_get_flag
[1].SetByName('SOUND_CTF_GET2');
2434 sound_lost_flag
[0].SetByName('SOUND_CTF_LOST1');
2435 sound_lost_flag
[1].SetByName('SOUND_CTF_LOST2');
2436 sound_ret_flag
[0].SetByName('SOUND_CTF_RETURN1');
2437 sound_ret_flag
[1].SetByName('SOUND_CTF_RETURN2');
2438 sound_cap_flag
[0].SetByName('SOUND_CTF_CAPTURE1');
2439 sound_cap_flag
[1].SetByName('SOUND_CTF_CAPTURE2');
2441 g_Game_LoadChatSounds(GameWAD
+':CHATSND\SNDCFG');
2443 g_Game_SetLoadingText(_lc
[I_LOAD_ITEMS_DATA
], 0, False);
2446 g_Game_SetLoadingText(_lc
[I_LOAD_WEAPONS_DATA
], 0, False);
2447 g_Weapon_LoadData();
2449 g_Monsters_LoadData();
2454 procedure g_Game_Quit();
2456 g_Game_StopAllSounds(True);
2459 g_PlayerModel_FreeData();
2461 //g_Menu_Free(); //k8: this segfaults after resolution change; who cares?
2464 if NetInitDone
then g_Net_Free
;
2466 // remove map after test
2467 if gMapToDelete
<> '' then
2468 g_Game_DeleteTestMap();
2474 procedure g_Game_FreeData();
2476 if not DataLoaded
then Exit
;
2479 g_Weapon_FreeData();
2480 g_Monsters_FreeData();
2482 e_WriteLog('Releasing game data...', TMsgType
.Notify
);
2484 g_Sound_Delete('SOUND_GAME_TELEPORT');
2485 g_Sound_Delete('SOUND_GAME_NOTELEPORT');
2486 g_Sound_Delete('SOUND_GAME_SECRET');
2487 g_Sound_Delete('SOUND_GAME_DOOROPEN');
2488 g_Sound_Delete('SOUND_GAME_DOORCLOSE');
2489 g_Sound_Delete('SOUND_GAME_BULK1');
2490 g_Sound_Delete('SOUND_GAME_BULK2');
2491 g_Sound_Delete('SOUND_GAME_BUBBLE1');
2492 g_Sound_Delete('SOUND_GAME_BUBBLE2');
2493 g_Sound_Delete('SOUND_GAME_BURNING');
2494 g_Sound_Delete('SOUND_GAME_SWITCH1');
2495 g_Sound_Delete('SOUND_GAME_SWITCH0');
2502 g_Sound_Delete('SOUND_ANNOUNCER_GOOD1');
2503 g_Sound_Delete('SOUND_ANNOUNCER_GOOD2');
2504 g_Sound_Delete('SOUND_ANNOUNCER_GOOD3');
2505 g_Sound_Delete('SOUND_ANNOUNCER_GOOD4');
2512 g_Sound_Delete('SOUND_ANNOUNCER_KILL2X');
2513 g_Sound_Delete('SOUND_ANNOUNCER_KILL3X');
2514 g_Sound_Delete('SOUND_ANNOUNCER_KILL4X');
2515 g_Sound_Delete('SOUND_ANNOUNCER_KILLMX');
2521 g_Sound_Delete('SOUND_ANNOUNCER_MUHAHA1');
2522 g_Sound_Delete('SOUND_ANNOUNCER_MUHAHA2');
2523 g_Sound_Delete('SOUND_ANNOUNCER_MUHAHA3');
2525 sound_get_flag
[0].Free();
2526 sound_get_flag
[1].Free();
2527 sound_lost_flag
[0].Free();
2528 sound_lost_flag
[1].Free();
2529 sound_ret_flag
[0].Free();
2530 sound_ret_flag
[1].Free();
2531 sound_cap_flag
[0].Free();
2532 sound_cap_flag
[1].Free();
2534 g_Sound_Delete('SOUND_CTF_GET1');
2535 g_Sound_Delete('SOUND_CTF_GET2');
2536 g_Sound_Delete('SOUND_CTF_LOST1');
2537 g_Sound_Delete('SOUND_CTF_LOST2');
2538 g_Sound_Delete('SOUND_CTF_RETURN1');
2539 g_Sound_Delete('SOUND_CTF_RETURN2');
2540 g_Sound_Delete('SOUND_CTF_CAPTURE1');
2541 g_Sound_Delete('SOUND_CTF_CAPTURE2');
2543 g_Game_FreeChatSounds();
2545 DataLoaded
:= False;
2548 procedure g_FatalError(Text: String);
2550 g_Console_Add(Format(_lc
[I_FATAL_ERROR
], [Text]), True);
2551 e_WriteLog(Format(_lc
[I_FATAL_ERROR
], [Text]), TMsgType
.Warning
);
2553 gExit
:= EXIT_SIMPLE
;
2554 if gGameOn
then EndGame
;
2557 procedure g_SimpleError(Text: String);
2559 g_Console_Add(Format(_lc
[I_SIMPLE_ERROR
], [Text]), True);
2560 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], [Text]), TMsgType
.Warning
);
2563 procedure g_Game_AddPlayer(Team
: Byte = TEAM_NONE
);
2565 if ((not gGameOn
) and (gState
<> STATE_INTERCUSTOM
))
2566 or (not (gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
])) then
2569 if (gGameSettings
.MaxLives
> 0) and (gLMSRespawn
= LMS_RESPAWN_NONE
) then
2572 if gPlayer1
= nil then
2574 if g_Game_IsClient
then
2576 if NetPlrUID1
> -1 then
2577 MC_SEND_CheatRequest(NET_CHEAT_SPECTATE
);
2581 if not (Team
in [TEAM_RED
, TEAM_BLUE
]) then
2582 Team
:= gPlayer1Settings
.Team
;
2584 // Создание первого игрока:
2585 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
2586 gPlayer1Settings
.Color
,
2588 if gPlayer1
= nil then
2589 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]))
2592 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
2593 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [gPlayer1
.Name
]), True);
2594 if g_Game_IsServer
and g_Game_IsNet
then
2595 MH_SEND_PlayerCreate(gPlayer1
.UID
);
2596 gPlayer1
.Respawn(False, True);
2597 g_Net_Slist_ServerPlayerComes();
2602 if gPlayer2
= nil then
2604 if g_Game_IsClient
then
2606 if NetPlrUID2
> -1 then
2607 gPlayer2
:= g_Player_Get(NetPlrUID2
);
2611 if not (Team
in [TEAM_RED
, TEAM_BLUE
]) then
2612 Team
:= gPlayer2Settings
.Team
;
2614 // Создание второго игрока:
2615 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
2616 gPlayer2Settings
.Color
,
2618 if gPlayer2
= nil then
2619 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]))
2622 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
2623 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [gPlayer2
.Name
]), True);
2624 if g_Game_IsServer
and g_Game_IsNet
then
2625 MH_SEND_PlayerCreate(gPlayer2
.UID
);
2626 gPlayer2
.Respawn(False, True);
2627 g_Net_Slist_ServerPlayerComes();
2634 procedure g_Game_RemovePlayer();
2638 if ((not gGameOn
) and (gState
<> STATE_INTERCUSTOM
))
2639 or (not (gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
])) then
2644 if g_Game_IsServer
then
2647 Pl
.Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
2648 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [Pl
.Name
]), True);
2649 g_Player_Remove(Pl
.UID
);
2650 g_Net_Slist_ServerPlayerLeaves();
2654 gSpectLatchPID2
:= Pl
.UID
;
2662 if g_Game_IsServer
then
2665 Pl
.Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
2666 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [Pl
.Name
]), True);
2667 g_Player_Remove(Pl
.UID
);
2668 g_Net_Slist_ServerPlayerLeaves();
2671 gSpectLatchPID1
:= Pl
.UID
;
2673 MC_SEND_CheatRequest(NET_CHEAT_SPECTATE
);
2677 g_Net_Slist_ServerPlayerLeaves();
2680 procedure g_Game_Spectate();
2682 g_Game_RemovePlayer();
2683 if gPlayer1
<> nil then
2684 g_Game_RemovePlayer();
2687 procedure g_Game_SpectateCenterView();
2689 gSpectX
:= Max(gMapInfo
.Width
div 2 - gScreenWidth
div 2, 0);
2690 gSpectY
:= Max(gMapInfo
.Height
div 2 - gScreenHeight
div 2, 0);
2693 procedure g_Game_StartSingle(Map
: String; TwoPlayers
: Boolean; nPlayers
: Byte);
2700 e_WriteLog('Starting singleplayer game...', TMsgType
.Notify
);
2702 g_Game_ClearLoading();
2705 FillByte(gGameSettings
, SizeOf(TGameSettings
), 0);
2708 gGameSettings
.GameType
:= GT_SINGLE
;
2709 gGameSettings
.MaxLives
:= 0;
2710 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_ALLOWEXIT
;
2711 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_MONSTERS
;
2712 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_BOTVSMONSTER
;
2713 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_TEAMHITPROJECTILE
;
2714 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_TEAMHITTRACE
;
2715 gSwitchGameMode
:= GM_SINGLE
;
2717 gLMSRespawn
:= LMS_RESPAWN_NONE
;
2718 gLMSRespawnTime
:= 0;
2719 gSpectLatchPID1
:= 0;
2720 gSpectLatchPID2
:= 0;
2722 g_Game_ExecuteEvent('ongamestart');
2724 // Создание первого игрока:
2725 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
2726 gPlayer1Settings
.Color
,
2727 gPlayer1Settings
.Team
, False));
2728 if gPlayer1
= nil then
2730 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
2734 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
2737 // Создание второго игрока, если есть:
2740 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
2741 gPlayer2Settings
.Color
,
2742 gPlayer2Settings
.Team
, False));
2743 if gPlayer2
= nil then
2745 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
2749 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
2753 // Загрузка и запуск карты:
2754 if not g_Game_StartMap(false{asMegawad}, MAP
, True) then
2756 if (Pos(':\', Map
) > 0) or (Pos(':/', Map
) > 0) then tmps
:= Map
else tmps
:= gGameSettings
.WAD
+ ':\' + MAP
;
2757 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [tmps
]));
2761 // Настройки игроков и ботов:
2765 for i
:= nPl
+1 to nPlayers
do
2766 g_Player_Create(STD_PLAYER_MODEL
, _RGB(0, 0, 0), 0, True);
2769 procedure g_Game_StartCustom(Map
: String; GameMode
: Byte;
2770 TimeLimit
, GoalLimit
: Word;
2772 Options
: LongWord; nPlayers
: Byte);
2778 e_WriteLog('Starting custom game...', TMsgType
.Notify
);
2780 g_Game_ClearLoading();
2783 gGameSettings
.GameType
:= GT_CUSTOM
;
2784 gGameSettings
.GameMode
:= GameMode
;
2785 gSwitchGameMode
:= GameMode
;
2786 gGameSettings
.TimeLimit
:= TimeLimit
;
2787 gGameSettings
.GoalLimit
:= GoalLimit
;
2788 gGameSettings
.MaxLives
:= IfThen(GameMode
= GM_CTF
, 0, MaxLives
);
2789 gGameSettings
.Options
:= Options
;
2791 gCoopTotalMonstersKilled
:= 0;
2792 gCoopTotalSecretsFound
:= 0;
2793 gCoopTotalMonsters
:= 0;
2794 gCoopTotalSecrets
:= 0;
2798 gLMSRespawn
:= LMS_RESPAWN_NONE
;
2799 gLMSRespawnTime
:= 0;
2800 gSpectLatchPID1
:= 0;
2801 gSpectLatchPID2
:= 0;
2803 g_Game_ExecuteEvent('ongamestart');
2805 // Режим наблюдателя:
2806 if nPlayers
= 0 then
2813 if nPlayers
>= 1 then
2815 // Создание первого игрока:
2816 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
2817 gPlayer1Settings
.Color
,
2818 gPlayer1Settings
.Team
, False));
2819 if gPlayer1
= nil then
2821 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
2825 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
2829 if nPlayers
>= 2 then
2831 // Создание второго игрока:
2832 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
2833 gPlayer2Settings
.Color
,
2834 gPlayer2Settings
.Team
, False));
2835 if gPlayer2
= nil then
2837 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
2841 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
2845 // Загрузка и запуск карты:
2846 if not g_Game_StartMap(true{asMegawad}, Map
, True) then
2848 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [Map
]));
2852 // Нет точек появления:
2853 if (g_Map_GetPointCount(RESPAWNPOINT_PLAYER1
) +
2854 g_Map_GetPointCount(RESPAWNPOINT_PLAYER2
) +
2855 g_Map_GetPointCount(RESPAWNPOINT_DM
) +
2856 g_Map_GetPointCount(RESPAWNPOINT_RED
)+
2857 g_Map_GetPointCount(RESPAWNPOINT_BLUE
)) < 1 then
2859 g_FatalError(_lc
[I_GAME_ERROR_GET_SPAWN
]);
2863 // Настройки игроков и ботов:
2867 for i
:= nPl
+1 to nPlayers
do
2868 g_Player_Create(STD_PLAYER_MODEL
, _RGB(0, 0, 0), 0, True);
2871 procedure g_Game_StartServer(Map
: String; GameMode
: Byte;
2872 TimeLimit
, GoalLimit
: Word; MaxLives
: Byte;
2873 Options
: LongWord; nPlayers
: Byte;
2874 IPAddr
: LongWord; Port
: Word);
2877 g_Net_Slist_ServerClosed();
2879 e_WriteLog('Starting net game (server)...', TMsgType
.Notify
);
2881 g_Game_ClearLoading();
2884 gGameSettings
.GameType
:= GT_SERVER
;
2885 gGameSettings
.GameMode
:= GameMode
;
2886 gSwitchGameMode
:= GameMode
;
2887 gGameSettings
.TimeLimit
:= TimeLimit
;
2888 gGameSettings
.GoalLimit
:= GoalLimit
;
2889 gGameSettings
.MaxLives
:= IfThen(GameMode
= GM_CTF
, 0, MaxLives
);
2890 gGameSettings
.Options
:= Options
;
2892 gCoopTotalMonstersKilled
:= 0;
2893 gCoopTotalSecretsFound
:= 0;
2894 gCoopTotalMonsters
:= 0;
2895 gCoopTotalSecrets
:= 0;
2899 gLMSRespawn
:= LMS_RESPAWN_NONE
;
2900 gLMSRespawnTime
:= 0;
2901 gSpectLatchPID1
:= 0;
2902 gSpectLatchPID2
:= 0;
2904 g_Game_ExecuteEvent('ongamestart');
2906 // Режим наблюдателя:
2907 if nPlayers
= 0 then
2913 if nPlayers
>= 1 then
2915 // Создание первого игрока:
2916 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
2917 gPlayer1Settings
.Color
,
2918 gPlayer1Settings
.Team
, False));
2919 if gPlayer1
= nil then
2921 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
2925 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
2928 if nPlayers
>= 2 then
2930 // Создание второго игрока:
2931 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
2932 gPlayer2Settings
.Color
,
2933 gPlayer2Settings
.Team
, False));
2934 if gPlayer2
= nil then
2936 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
2940 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
2943 g_Game_SetLoadingText(_lc
[I_LOAD_HOST
], 0, False);
2944 if NetForwardPorts
then
2945 g_Game_SetLoadingText(_lc
[I_LOAD_PORTS
], 0, False);
2948 if not g_Net_Host(IPAddr
, Port
, NetMaxClients
) then
2950 g_FatalError(_lc
[I_NET_MSG
] + Format(_lc
[I_NET_ERR_HOST
], [Port
]));
2954 g_Net_Slist_Set(NetMasterList
);
2956 g_Net_Slist_ServerStarted();
2958 // Загрузка и запуск карты:
2959 if not g_Game_StartMap(false{asMegawad}, Map
, True) then
2961 g_Net_Slist_ServerClosed();
2962 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [Map
]));
2966 // Нет точек появления:
2967 if (g_Map_GetPointCount(RESPAWNPOINT_PLAYER1
) +
2968 g_Map_GetPointCount(RESPAWNPOINT_PLAYER2
) +
2969 g_Map_GetPointCount(RESPAWNPOINT_DM
) +
2970 g_Map_GetPointCount(RESPAWNPOINT_RED
)+
2971 g_Map_GetPointCount(RESPAWNPOINT_BLUE
)) < 1 then
2973 g_Net_Slist_ServerClosed();
2974 g_FatalError(_lc
[I_GAME_ERROR_GET_SPAWN
]);
2978 // Настройки игроков и ботов:
2981 g_Net_Slist_ServerMapStarted();
2982 NetState
:= NET_STATE_GAME
;
2985 procedure g_Game_StartClient(Addr
: String; Port
: Word; PW
: String);
3000 e_WriteLog('Starting net game (client)...', TMsgType
.Notify
);
3001 e_WriteLog('NET: Trying to connect to ' + Addr
+ ':' + IntToStr(Port
) + '...', TMsgType
.Notify
);
3003 g_Game_ClearLoading();
3006 gGameSettings
.GameType
:= GT_CLIENT
;
3008 gCoopTotalMonstersKilled
:= 0;
3009 gCoopTotalSecretsFound
:= 0;
3010 gCoopTotalMonsters
:= 0;
3011 gCoopTotalSecrets
:= 0;
3015 g_Game_ExecuteEvent('ongamestart');
3017 NetState
:= NET_STATE_AUTH
;
3019 g_Game_SetLoadingText(_lc
[I_LOAD_CONNECT
], 0, False);
3021 // create (or update) map/resource databases
3022 g_Res_CreateDatabases(true);
3024 gLMSRespawn
:= LMS_RESPAWN_NONE
;
3025 gLMSRespawnTime
:= 0;
3026 gSpectLatchPID1
:= 0;
3027 gSpectLatchPID2
:= 0;
3030 if not g_Net_Connect(Addr
, Port
) then
3032 g_FatalError(_lc
[I_NET_MSG
] + _lc
[I_NET_ERR_CONN
]);
3033 NetState
:= NET_STATE_NONE
;
3037 g_Game_SetLoadingText(_lc
[I_LOAD_SEND_INFO
], 0, False);
3039 g_Game_SetLoadingText(_lc
[I_LOAD_WAIT_INFO
], 0, False);
3044 // fuck! https://www.mail-archive.com/enet-discuss@cubik.org/msg00852.html
3045 // tl;dr: on shitdows, we can get -1 sometimes, and it is *NOT* a failure.
3046 // thank you, enet. let's ignore failures altogether then.
3047 while (enet_host_service(NetHost
, @NetEvent
, 50) > 0) do
3049 if (NetEvent
.kind
= ENET_EVENT_TYPE_RECEIVE
) then
3051 if (NetEvent
.channelID
= NET_CHAN_DOWNLOAD_EX
) then
3053 // ignore all download packets, they're processed by separate code
3054 enet_packet_destroy(NetEvent
.packet
);
3057 Ptr
:= NetEvent
.packet
^.data
;
3058 if not InMsg
.Init(Ptr
, NetEvent
.packet
^.dataLength
, True) then
3060 enet_packet_destroy(NetEvent
.packet
);
3064 InMsg
.ReadLongWord(); // skip size
3065 MID
:= InMsg
.ReadByte();
3067 if (MID
= NET_MSG_INFO
) and (State
= 0) then
3069 NetMyID
:= InMsg
.ReadByte();
3070 NetPlrUID1
:= InMsg
.ReadWord();
3072 WadName
:= InMsg
.ReadString();
3073 Map
:= InMsg
.ReadString();
3075 gWADHash
:= InMsg
.ReadMD5();
3077 gGameSettings
.GameMode
:= InMsg
.ReadByte();
3078 gSwitchGameMode
:= gGameSettings
.GameMode
;
3079 gGameSettings
.GoalLimit
:= InMsg
.ReadWord();
3080 gGameSettings
.TimeLimit
:= InMsg
.ReadWord();
3081 gGameSettings
.MaxLives
:= InMsg
.ReadByte();
3082 gGameSettings
.Options
:= InMsg
.ReadLongWord();
3083 T
:= InMsg
.ReadLongWord();
3085 //newResPath := g_Res_SearchSameWAD(MapsDir, WadName, gWADHash);
3086 //if newResPath = '' then
3088 //g_Game_SetLoadingText(_lc[I_LOAD_DL_RES], 0, False);
3089 newResPath
:= g_Res_DownloadMapWAD(ExtractFileName(WadName
), gWADHash
);
3090 if newResPath
= '' then
3092 g_FatalError(_lc
[I_NET_ERR_HASH
]);
3093 enet_packet_destroy(NetEvent
.packet
);
3094 NetState
:= NET_STATE_NONE
;
3097 e_LogWritefln('using downloaded map wad [%s] for [%s]`', [newResPath
, WadName
], TMsgType
.Notify
);
3099 //newResPath := ExtractRelativePath(MapsDir, newResPath);
3102 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
3103 gPlayer1Settings
.Color
,
3104 gPlayer1Settings
.Team
, False));
3106 if gPlayer1
= nil then
3108 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
3110 enet_packet_destroy(NetEvent
.packet
);
3111 NetState
:= NET_STATE_NONE
;
3115 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
3116 gPlayer1
.UID
:= NetPlrUID1
;
3117 gPlayer1
.Reset(True);
3119 if not g_Game_StartMap(false{asMegawad}, newResPath
+ ':\' + Map
, True) then
3121 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [WadName
+ ':\' + Map
]));
3123 enet_packet_destroy(NetEvent
.packet
);
3124 NetState
:= NET_STATE_NONE
;
3132 enet_packet_destroy(NetEvent
.packet
);
3136 enet_packet_destroy(NetEvent
.packet
);
3140 if (NetEvent
.kind
= ENET_EVENT_TYPE_DISCONNECT
) then
3143 if (NetEvent
.data
<= NET_DISC_MAX
) then
3144 g_Console_Add(_lc
[I_NET_MSG_ERROR
] + _lc
[I_NET_ERR_CONN
] + ' ' +
3145 _lc
[TStrings_Locale(Cardinal(I_NET_DISC_NONE
) + NetEvent
.data
)], True);
3152 ProcessLoading(true);
3154 if g_Net_UserRequestExit() then
3163 g_FatalError(_lc
[I_NET_MSG
] + _lc
[I_NET_ERR_CONN
]);
3164 NetState
:= NET_STATE_NONE
;
3169 NetState
:= NET_STATE_GAME
;
3170 MC_SEND_FullStateRequest
;
3171 e_WriteLog('NET: Connection successful.', TMsgType
.Notify
);
3175 lastAsMegaWad
: Boolean = false;
3177 procedure g_Game_ChangeMap(const MapPath
: String);
3181 g_Game_ClearLoading();
3183 Force
:= gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
];
3184 // Если уровень завершился по триггеру Выход, не очищать инвентарь
3185 if gExitByTrigger
then
3188 gExitByTrigger
:= False;
3190 if not g_Game_StartMap(lastAsMegaWad
, MapPath
, Force
) then
3191 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [MapPath
]));
3194 procedure g_Game_Restart();
3198 if g_Game_IsClient
then
3200 map
:= g_ExtractFileName(gMapInfo
.Map
);
3201 e_LogWritefln('g_Game_Restart: map = "%s" gCurrentMapFileName = "%s"', [map
, gCurrentMapFileName
]);
3205 g_Game_ClearLoading();
3206 g_Game_StartMap(lastAsMegaWad
, Map
, True, gCurrentMapFileName
);
3209 function g_Game_StartMap (asMegawad
: Boolean; Map
: String; Force
: Boolean = False; const oldMapPath
: AnsiString=''): Boolean;
3211 NewWAD
, ResName
: String;
3215 g_Map_Free((Map
<> gCurrentMapFileName
) and (oldMapPath
<> gCurrentMapFileName
));
3216 g_Player_RemoveAllCorpses();
3218 if (not g_Game_IsClient
) and
3219 (gSwitchGameMode
<> gGameSettings
.GameMode
) and
3220 (gGameSettings
.GameMode
<> GM_SINGLE
) then
3222 if gSwitchGameMode
= GM_CTF
then
3223 gGameSettings
.MaxLives
:= 0;
3224 gGameSettings
.GameMode
:= gSwitchGameMode
;
3227 gSwitchGameMode
:= gGameSettings
.GameMode
;
3229 g_Player_ResetTeams();
3231 lastAsMegaWad
:= asMegawad
;
3232 if isWadPath(Map
) then
3234 NewWAD
:= g_ExtractWadName(Map
);
3235 ResName
:= g_ExtractFileName(Map
);
3236 if g_Game_IsServer
then
3238 nws
:= findDiskWad(NewWAD
);
3239 //writeln('000: Map=[', Map, ']; nws=[', nws, ']; NewWAD=[', NewWAD, ']');
3242 if (length(nws
) = 0) then nws
:= e_FindWad(MegawadDirs
, NewWAD
);
3243 if (length(nws
) = 0) then nws
:= e_FindWad(MapDirs
, NewWAD
);
3247 if (length(nws
) = 0) then nws
:= e_FindWad(MapDirs
, NewWAD
);
3248 if (length(nws
) = 0) then nws
:= e_FindWad(MegawadDirs
, NewWAD
);
3250 //if (length(nws) = 0) then nws := e_FindWad(MapDownloadDirs, NewWAD);
3251 //writeln('001: Map=[', Map, ']; nws=[', nws, ']; NewWAD=[', NewWAD, ']');
3253 if (length(nws
) = 0) then
3255 ResName
:= ''; // failed
3260 if (g_Game_IsNet
) then gWADHash
:= MD5File(nws
);
3261 //writeln('********: nws=', nws, ' : Map=', Map, ' : nw=', NewWAD, ' : resname=', ResName);
3262 g_Game_LoadWAD(NewWAD
);
3267 // hash received in MC_RECV_GameEvent -> NET_EV_MAPSTART
3268 NewWAD
:= g_Game_ClientWAD(NewWAD
, gWADHash
);
3273 NewWAD
:= gGameSettings
.WAD
;
3279 //writeln('********: gsw=', gGameSettings.WAD, '; rn=', ResName);
3281 if (ResName
<> '') and (NewWAD
<> '') then
3283 //result := g_Map_Load(gGameSettings.WAD + ':\' + ResName);
3284 result
:= g_Map_Load(NewWAD
+':\'+ResName
);
3285 r_Render_LoadTextures
;
3289 g_Player_ResetAll(Force
or gLastMap
, gGameSettings
.GameType
= GT_SINGLE
);
3291 gState
:= STATE_NONE
;
3292 g_ActiveWindow
:= nil;
3296 wNeedTimeReset
:= True;
3298 if gGameSettings
.GameMode
= GM_CTF
then
3300 g_Map_ResetFlag(FLAG_RED
);
3301 g_Map_ResetFlag(FLAG_BLUE
);
3302 // CTF, а флагов нет:
3303 if not g_Map_HaveFlagPoints() then
3304 g_SimpleError(_lc
[I_GAME_ERROR_CTF
]);
3309 gState
:= STATE_MENU
;
3314 gPauseMain
:= false;
3315 gPauseHolmes
:= false;
3316 NetTimeToUpdate
:= 1;
3317 NetTimeToReliable
:= 0;
3318 NetTimeToMaster
:= NetMasterRate
;
3319 gSpectLatchPID1
:= 0;
3320 gSpectLatchPID2
:= 0;
3321 gMissionFailed
:= False;
3324 gCoopMonstersKilled
:= 0;
3325 gCoopSecretsFound
:= 0;
3327 gVoteInProgress
:= False;
3328 gVotePassed
:= False;
3334 if not gGameOn
then Exit
;
3336 g_Game_SpectateCenterView();
3338 if g_Game_IsServer
then
3340 if (gGameSettings
.MaxLives
> 0) and (gGameSettings
.WarmupTime
> 0) then
3342 gLMSRespawn
:= LMS_RESPAWN_WARMUP
;
3343 gLMSRespawnTime
:= gTime
+ gGameSettings
.WarmupTime
*1000;
3344 gLMSSoftSpawn
:= True;
3345 if g_Game_IsNet
then
3346 MH_SEND_GameEvent(NET_EV_LMS_WARMUP
, gLMSRespawnTime
- gTime
);
3350 gLMSRespawn
:= LMS_RESPAWN_NONE
;
3351 gLMSRespawnTime
:= 0;
3355 if NetMode
= NET_SERVER
then
3357 MH_SEND_GameEvent(NET_EV_MAPSTART
, gGameSettings
.GameMode
, Map
);
3360 g_Net_Slist_ServerMapStarted();
3362 if NetClients
<> nil then
3363 for I
:= 0 to High(NetClients
) do
3364 if NetClients
[I
].Used
then
3366 NetClients
[I
].Voted
:= False;
3367 if NetClients
[I
].RequestedFullUpdate
then
3369 MH_SEND_Everything((NetClients
[I
].State
= NET_STATE_AUTH
), I
);
3370 NetClients
[I
].RequestedFullUpdate
:= False;
3374 g_Net_UnbanNonPermHosts();
3379 gCoopTotalMonstersKilled
:= 0;
3380 gCoopTotalSecretsFound
:= 0;
3381 gCoopTotalMonsters
:= 0;
3382 gCoopTotalSecrets
:= 0;
3386 g_Game_ExecuteEvent('onmapstart');
3389 procedure SetFirstLevel
;
3393 MapList
:= g_Map_GetMapsList(gGameSettings
.WAD
);
3394 if MapList
= nil then
3397 SortSArray(MapList
);
3398 gNextMap
:= MapList
[Low(MapList
)];
3403 procedure g_Game_ExitLevel(const Map
: AnsiString);
3407 gCoopTotalMonstersKilled
:= gCoopTotalMonstersKilled
+ gCoopMonstersKilled
;
3408 gCoopTotalSecretsFound
:= gCoopTotalSecretsFound
+ gCoopSecretsFound
;
3409 gCoopTotalMonsters
:= gCoopTotalMonsters
+ gTotalMonsters
;
3410 gCoopTotalSecrets
:= gCoopTotalSecrets
+ gSecretsCount
;
3412 // Вышли в выход в Одиночной игре:
3413 if gGameSettings
.GameType
= GT_SINGLE
then
3414 gExit
:= EXIT_ENDLEVELSINGLE
3415 else // Вышли в выход в Своей игре
3417 gExit
:= EXIT_ENDLEVELCUSTOM
;
3418 if gGameSettings
.GameMode
= GM_COOP
then
3419 g_Player_RememberAll
;
3421 if not g_Map_Exist(gGameSettings
.WAD
+ ':\' + gNextMap
) then
3424 if gGameSettings
.GameMode
= GM_COOP
then
3427 gStatsPressed
:= True;
3428 gNextMap
:= 'MAP01';
3430 if not g_Map_Exist(gGameSettings
.WAD
+ ':\' + gNextMap
) then
3433 if g_Game_IsNet
then
3435 MH_SEND_GameStats();
3436 MH_SEND_CoopStats();
3442 procedure g_Game_RestartLevel();
3446 if gGameSettings
.GameMode
= GM_SINGLE
then
3451 gExit
:= EXIT_ENDLEVELCUSTOM
;
3452 Map
:= g_ExtractFileName(gMapInfo
.Map
);
3456 function g_Game_ClientWAD (NewWAD
: String; const WHash
: TMD5Digest
): AnsiString;
3458 gWAD
{, xwad}: String;
3461 if not g_Game_IsClient
then Exit
;
3462 //e_LogWritefln('*** g_Game_ClientWAD: `%s`', [NewWAD]);
3464 gWAD
:= g_Res_DownloadMapWAD(ExtractFileName(NewWAD
), WHash
);
3469 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_WAD
], [ExtractFileName(NewWAD
)]));
3473 e_LogWritefln('using downloaded client map wad [%s] for [%s]', [gWAD
, NewWAD
], TMsgType
.Notify
);
3476 g_Game_LoadWAD(NewWAD
);
3480 if LowerCase(NewWAD) = LowerCase(gGameSettings.WAD) then Exit;
3481 gWAD := g_Res_SearchSameWAD(MapsDir, ExtractFileName(NewWAD), WHash);
3484 g_Game_SetLoadingText(_lc[I_LOAD_DL_RES], 0, False);
3485 gWAD := g_Res_DownloadMapWAD(ExtractFileName(NewWAD), WHash);
3489 g_FatalError(Format(_lc[I_GAME_ERROR_MAP_WAD], [ExtractFileName(NewWAD)]));
3493 NewWAD := ExtractRelativePath(MapsDir, gWAD);
3494 g_Game_LoadWAD(NewWAD);
3498 procedure g_Game_RestartRound(NoMapRestart
: Boolean = False);
3500 i
, n
, nb
, nr
: Integer;
3502 if not g_Game_IsServer
then Exit
;
3503 if gLMSRespawn
= LMS_RESPAWN_NONE
then Exit
;
3504 gLMSRespawn
:= LMS_RESPAWN_NONE
;
3505 gLMSRespawnTime
:= 0;
3508 if (gGameSettings
.GameMode
= GM_COOP
) and not NoMapRestart
then
3510 gMissionFailed
:= True;
3511 g_Game_RestartLevel
;
3515 n
:= 0; nb
:= 0; nr
:= 0;
3516 for i
:= Low(gPlayers
) to High(gPlayers
) do
3517 if (gPlayers
[i
] <> nil) and
3518 ((not gPlayers
[i
].FSpectator
) or gPlayers
[i
].FWantsInGame
or
3519 (gPlayers
[i
] is TBot
)) then
3522 if gPlayers
[i
].Team
= TEAM_RED
then Inc(nr
)
3523 else if gPlayers
[i
].Team
= TEAM_BLUE
then Inc(nb
)
3526 if (n
< 1) or ((gGameSettings
.GameMode
= GM_TDM
) and ((nr
= 0) or (nb
= 0))) then
3528 // wait a second until the fuckers finally decide to join
3529 gLMSRespawn
:= LMS_RESPAWN_WARMUP
;
3530 gLMSRespawnTime
:= gTime
+ gGameSettings
.WarmupTime
*1000;
3531 gLMSSoftSpawn
:= NoMapRestart
;
3532 if g_Game_IsNet
then
3533 MH_SEND_GameEvent(NET_EV_LMS_WARMUP
, gLMSRespawnTime
- gTime
);
3537 g_Player_RemoveAllCorpses
;
3538 g_Game_Message(_lc
[I_MESSAGE_LMS_START
], 144);
3539 if g_Game_IsNet
then
3540 MH_SEND_GameEvent(NET_EV_LMS_START
);
3542 for i
:= Low(gPlayers
) to High(gPlayers
) do
3544 if gPlayers
[i
] = nil then continue
;
3545 if gPlayers
[i
] is TBot
then gPlayers
[i
].FWantsInGame
:= True;
3546 // don't touch normal spectators
3547 if gPlayers
[i
].FSpectator
and not gPlayers
[i
].FWantsInGame
then
3549 gPlayers
[i
].FNoRespawn
:= True;
3550 gPlayers
[i
].Lives
:= 0;
3551 if g_Game_IsNet
then
3552 MH_SEND_PlayerStats(gPlayers
[I
].UID
);
3555 gPlayers
[i
].FNoRespawn
:= False;
3556 gPlayers
[i
].Lives
:= gGameSettings
.MaxLives
;
3557 gPlayers
[i
].Respawn(False, True);
3558 if gGameSettings
.GameMode
= GM_COOP
then
3560 gPlayers
[i
].Frags
:= 0;
3561 gPlayers
[i
].RecallState
;
3563 if (gPlayer1
= nil) and (gSpectLatchPID1
> 0) then
3564 gPlayer1
:= g_Player_Get(gSpectLatchPID1
);
3565 if (gPlayer2
= nil) and (gSpectLatchPID2
> 0) then
3566 gPlayer2
:= g_Player_Get(gSpectLatchPID2
);
3569 g_Items_RestartRound();
3571 gLMSSoftSpawn
:= False;
3574 function g_Game_GetFirstMap(WAD
: String): String;
3578 MapList
:= g_Map_GetMapsList(WAD
);
3579 if MapList
= nil then
3582 SortSArray(MapList
);
3583 Result
:= MapList
[Low(MapList
)];
3585 if not g_Map_Exist(WAD
+ ':\' + Result
) then
3591 function g_Game_GetNextMap(): String;
3598 MapList
:= g_Map_GetMapsList(gGameSettings
.WAD
);
3599 if MapList
= nil then
3602 Map
:= g_ExtractFileName(gMapInfo
.Map
);
3604 SortSArray(MapList
);
3606 for I
:= Low(MapList
) to High(MapList
) do
3607 if Map
= MapList
[I
] then
3613 if MapIndex
<> -255 then
3615 if MapIndex
= High(MapList
) then
3616 Result
:= MapList
[Low(MapList
)]
3618 Result
:= MapList
[MapIndex
+ 1];
3620 if not g_Map_Exist(gGameSettings
.WAD
+ ':\' + Result
) then Result
:= Map
;
3626 procedure g_Game_NextLevel();
3628 if gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
, GM_COOP
] then
3629 gExit
:= EXIT_ENDLEVELCUSTOM
3632 gExit
:= EXIT_ENDLEVELSINGLE
;
3636 if gNextMap
<> '' then Exit
;
3637 gNextMap
:= g_Game_GetNextMap();
3640 function g_Game_IsTestMap(): Boolean;
3642 result
:= StrEquCI1251(TEST_MAP_NAME
, g_ExtractFileName(gMapInfo
.Map
));
3645 procedure g_Game_DeleteTestMap();
3648 //MapName: AnsiString;
3656 a
:= Pos('.wad:\', toLowerCase1251(gMapToDelete
));
3657 if (a
= 0) then a
:= Pos('.wad:/', toLowerCase1251(gMapToDelete
));
3658 if (a
= 0) then exit
;
3660 // Выделяем имя wad-файла и имя карты
3661 WadName
:= Copy(gMapToDelete
, 1, a
+3);
3662 Delete(gMapToDelete
, 1, a
+5);
3663 gMapToDelete
:= UpperCase(gMapToDelete
);
3665 //CopyMemory(@MapName[0], @gMapToDelete[1], Min(16, Length(gMapToDelete)));
3668 // Имя карты не стандартное тестовое:
3669 if MapName <> TEST_MAP_NAME then
3672 if not gTempDelete then
3674 time := g_GetFileTime(WadName);
3675 WAD := TWADFile.Create();
3678 if not WAD.ReadFile(WadName) then
3679 begin // Нет такого WAD-файла
3684 // Составляем список карт и ищем нужную:
3686 MapList := WAD.GetResourcesList('');
3688 if MapList <> nil then
3689 for a := 0 to High(MapList) do
3690 if MapList[a] = MapName then
3692 // Удаляем и сохраняем:
3693 WAD.RemoveResource('', MapName);
3694 WAD.SaveTo(WadName);
3699 g_SetFileTime(WadName, time);
3702 if gTempDelete
then DeleteFile(WadName
);
3705 procedure GameCVars(P
: SSArray
);
3708 stat
: TPlayerStatArray
;
3711 procedure ParseGameFlag(Flag
: LongWord; OffMsg
, OnMsg
: TStrings_Locale
; OnMapChange
: Boolean = False);
3715 if Length(P
) > 1 then
3720 gsGameFlags
:= gsGameFlags
or Flag
3722 gsGameFlags
:= gsGameFlags
and (not Flag
);
3724 if g_Game_IsServer
then
3727 gGameSettings
.Options
:= gGameSettings
.Options
or Flag
3729 gGameSettings
.Options
:= gGameSettings
.Options
and (not Flag
);
3730 if g_Game_IsNet
then MH_SEND_GameSettings
;
3734 if LongBool(gsGameFlags
and Flag
) then
3735 g_Console_Add(_lc
[OnMsg
])
3737 g_Console_Add(_lc
[OffMsg
]);
3739 if OnMapChange
and g_Game_IsServer
then
3740 g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
3745 cmd
:= LowerCase(P
[0]);
3747 if cmd
= 'g_gamemode' then
3749 if (Length(P
) > 1) then
3751 a
:= g_Game_TextToMode(P
[1]);
3752 if a
= GM_SINGLE
then a
:= GM_COOP
;
3753 gsGameMode
:= g_Game_ModeToText(a
);
3754 if g_Game_IsServer
then
3756 gSwitchGameMode
:= a
;
3757 if (gGameOn
and (gGameSettings
.GameMode
= GM_SINGLE
)) or
3758 (gState
= STATE_INTERSINGLE
) then
3759 gSwitchGameMode
:= GM_SINGLE
;
3761 gGameSettings
.GameMode
:= gSwitchGameMode
;
3765 if gSwitchGameMode
= gGameSettings
.GameMode
then
3766 g_Console_Add(Format(_lc
[I_MSG_GAMEMODE_CURRENT
],
3767 [g_Game_ModeToText(gGameSettings
.GameMode
)]))
3769 g_Console_Add(Format(_lc
[I_MSG_GAMEMODE_CHANGE
],
3770 [g_Game_ModeToText(gGameSettings
.GameMode
),
3771 g_Game_ModeToText(gSwitchGameMode
)]));
3773 else if cmd
= 'g_friendlyfire' then
3775 ParseGameFlag(GAME_OPTION_TEAMDAMAGE
, I_MSG_FRIENDLY_FIRE_OFF
, I_MSG_FRIENDLY_FIRE_ON
);
3777 else if cmd
= 'g_friendly_absorb_damage' then
3779 ParseGameFlag(GAME_OPTION_TEAMABSORBDAMAGE
, I_MSG_FRIENDLY_FIRE_OFF
, I_MSG_FRIENDLY_FIRE_ON
);
3781 else if cmd
= 'g_friendly_hit_trace' then
3783 ParseGameFlag(GAME_OPTION_TEAMHITTRACE
, I_MSG_FRIENDLY_FIRE_OFF
, I_MSG_FRIENDLY_FIRE_ON
);
3785 else if cmd
= 'g_friendly_hit_projectile' then
3787 ParseGameFlag(GAME_OPTION_TEAMHITPROJECTILE
, I_MSG_FRIENDLY_FIRE_OFF
, I_MSG_FRIENDLY_FIRE_ON
);
3789 else if cmd
= 'g_weaponstay' then
3791 ParseGameFlag(GAME_OPTION_WEAPONSTAY
, I_MSG_WEAPONSTAY_OFF
, I_MSG_WEAPONSTAY_ON
);
3793 else if cmd
= 'g_allow_exit' then
3795 ParseGameFlag(GAME_OPTION_ALLOWEXIT
, I_MSG_ALLOWEXIT_OFF
, I_MSG_ALLOWEXIT_ON
, True);
3797 else if cmd
= 'g_allow_monsters' then
3799 ParseGameFlag(GAME_OPTION_MONSTERS
, I_MSG_ALLOWMON_OFF
, I_MSG_ALLOWMON_ON
, True);
3801 else if cmd
= 'g_bot_vsplayers' then
3803 ParseGameFlag(GAME_OPTION_BOTVSPLAYER
, I_MSG_BOTSVSPLAYERS_OFF
, I_MSG_BOTSVSPLAYERS_ON
);
3805 else if cmd
= 'g_bot_vsmonsters' then
3807 ParseGameFlag(GAME_OPTION_BOTVSMONSTER
, I_MSG_BOTSVSMONSTERS_OFF
, I_MSG_BOTSVSMONSTERS_ON
);
3809 else if cmd
= 'g_dm_keys' then
3811 ParseGameFlag(GAME_OPTION_DMKEYS
, I_MSG_DMKEYS_OFF
, I_MSG_DMKEYS_ON
, True);
3813 else if cmd
= 'g_gameflags' then
3815 if Length(P
) > 1 then
3817 gsGameFlags
:= StrToDWordDef(P
[1], gsGameFlags
);
3818 if g_Game_IsServer
then
3820 gGameSettings
.Options
:= gsGameFlags
;
3821 if g_Game_IsNet
then MH_SEND_GameSettings
;
3825 g_Console_Add(Format('%s %u', [cmd
, gsGameFlags
]));
3827 else if cmd
= 'g_warmup_time' then
3829 if Length(P
) > 1 then
3831 gsWarmupTime
:= nclamp(StrToIntDef(P
[1], gsWarmupTime
), 0, $FFFF);
3832 if g_Game_IsServer
then
3834 gGameSettings
.WarmupTime
:= gsWarmupTime
;
3835 // extend warmup if it's already going
3836 if gLMSRespawn
= LMS_RESPAWN_WARMUP
then
3838 gLMSRespawnTime
:= gTime
+ gsWarmupTime
* 1000;
3839 if g_Game_IsNet
then MH_SEND_GameEvent(NET_EV_LMS_WARMUP
, gLMSRespawnTime
- gTime
);
3841 if g_Game_IsNet
then MH_SEND_GameSettings
;
3845 g_Console_Add(Format(_lc
[I_MSG_WARMUP
], [Integer(gsWarmupTime
)]));
3846 if g_Game_IsServer
then g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
3848 else if cmd
= 'g_spawn_invul' then
3850 if Length(P
) > 1 then
3852 gsSpawnInvul
:= nclamp(StrToIntDef(P
[1], gsSpawnInvul
), 0, $FFFF);
3853 if g_Game_IsServer
then
3855 gGameSettings
.SpawnInvul
:= gsSpawnInvul
;
3856 if g_Game_IsNet
then MH_SEND_GameSettings
;
3860 g_Console_Add(Format('%s %d', [cmd
, Integer(gsSpawnInvul
)]));
3862 else if cmd
= 'g_item_respawn_time' then
3864 if Length(P
) > 1 then
3866 gsItemRespawnTime
:= nclamp(StrToIntDef(P
[1], gsItemRespawnTime
), 0, $FFFF);
3867 if g_Game_IsServer
then
3869 gGameSettings
.ItemRespawnTime
:= gsItemRespawnTime
;
3870 if g_Game_IsNet
then MH_SEND_GameSettings
;
3874 g_Console_Add(Format('%s %d', [cmd
, Integer(gsItemRespawnTime
)]));
3875 if g_Game_IsServer
then g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
3877 else if cmd
= 'sv_intertime' then
3879 if (Length(P
) > 1) then
3880 gDefInterTime
:= Min(Max(StrToIntDef(P
[1], gDefInterTime
), -1), 120);
3882 g_Console_Add(cmd
+ ' = ' + IntToStr(gDefInterTime
));
3884 else if cmd
= 'g_max_particles' then
3886 if Length(p
) = 2 then
3888 a
:= Max(0, StrToInt(p
[1]));
3891 else if Length(p
) = 1 then
3893 e_LogWritefln('%s', [g_GFX_GetMax()])
3897 e_LogWritefln('usage: %s <n>', [cmd
])
3900 else if cmd
= 'g_max_shells' then
3902 if Length(p
) = 2 then
3904 a
:= Max(0, StrToInt(p
[1]));
3907 else if Length(p
) = 1 then
3909 e_LogWritefln('%s', [g_Shells_GetMax()])
3913 e_LogWritefln('usage: %s <n>', [cmd
])
3916 else if cmd
= 'g_max_gibs' then
3918 if Length(p
) = 2 then
3920 a
:= Max(0, StrToInt(p
[1]));
3923 else if Length(p
) = 1 then
3925 e_LogWritefln('%s', [g_Gibs_GetMax()])
3929 e_LogWritefln('usage: %s <n>', [cmd
])
3932 else if cmd
= 'g_max_corpses' then
3934 if Length(p
) = 2 then
3936 a
:= Max(0, StrToInt(p
[1]));
3939 else if Length(p
) = 1 then
3941 e_LogWritefln('%s', [g_Corpses_GetMax()])
3945 e_LogWritefln('usage: %s <n>', [cmd
])
3948 else if cmd
= 'g_scorelimit' then
3950 if Length(P
) > 1 then
3952 gsGoalLimit
:= nclamp(StrToIntDef(P
[1], gsGoalLimit
), 0, $FFFF);
3954 if g_Game_IsServer
then
3957 if gGameSettings
.GameMode
= GM_DM
then
3959 stat
:= g_Player_GetStats();
3961 for a
:= 0 to High(stat
) do
3962 if stat
[a
].Frags
> b
then
3966 b
:= Max(gTeamStat
[TEAM_RED
].Goals
, gTeamStat
[TEAM_BLUE
].Goals
);
3968 // if someone has a higher score, set it to that instead
3969 gsGoalLimit
:= max(gsGoalLimit
, b
);
3970 gGameSettings
.GoalLimit
:= gsGoalLimit
;
3972 if g_Game_IsNet
then MH_SEND_GameSettings
;
3976 g_Console_Add(Format(_lc
[I_MSG_SCORE_LIMIT
], [Integer(gsGoalLimit
)]));
3978 else if cmd
= 'g_timelimit' then
3980 if Length(P
) > 1 then
3982 gsTimeLimit
:= nclamp(StrToIntDef(P
[1], gsTimeLimit
), 0, $FFFF);
3983 if g_Game_IsServer
then
3985 gGameSettings
.TimeLimit
:= gsTimeLimit
;
3986 if g_Game_IsNet
then MH_SEND_GameSettings
;
3989 g_Console_Add(Format(_lc
[I_MSG_TIME_LIMIT
],
3990 [gsTimeLimit
div 3600,
3991 (gsTimeLimit
div 60) mod 60,
3992 gsTimeLimit
mod 60]));
3994 else if cmd
= 'g_maxlives' then
3996 if Length(P
) > 1 then
3998 gsMaxLives
:= nclamp(StrToIntDef(P
[1], gsMaxLives
), 0, $FFFF);
3999 if g_Game_IsServer
then
4001 gGameSettings
.MaxLives
:= gsMaxLives
;
4002 if g_Game_IsNet
then MH_SEND_GameSettings
;
4006 g_Console_Add(Format(_lc
[I_MSG_LIVES
], [Integer(gsMaxLives
)]));
4010 procedure PlayerSettingsCVars(P
: SSArray
);
4015 function ParseTeam(s
: string): Byte;
4019 'red', '1': result
:= TEAM_RED
;
4020 'blue', '2': result
:= TEAM_BLUE
;
4021 else result
:= TEAM_NONE
;
4025 cmd
:= LowerCase(P
[0]);
4029 if (Length(P
) > 1) then
4031 gPlayer1Settings
.Name
:= b_Text_Unformat(P
[1]);
4032 if g_Game_IsClient
then
4033 MC_SEND_PlayerSettings
4034 else if gGameOn
and (gPlayer1
<> nil) then
4036 gPlayer1
.Name
:= b_Text_Unformat(P
[1]);
4037 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer1
.UID
);
4043 if (Length(P
) > 1) then
4045 gPlayer2Settings
.Name
:= b_Text_Unformat(P
[1]);
4046 if g_Game_IsClient
then
4047 MC_SEND_PlayerSettings
4048 else if gGameOn
and (gPlayer2
<> nil) then
4050 gPlayer2
.Name
:= b_Text_Unformat(P
[1]);
4051 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer2
.UID
);
4057 if Length(P
) > 3 then
4059 gPlayer1Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
4060 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
4061 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
4062 if g_Game_IsClient
then
4063 MC_SEND_PlayerSettings
4064 else if gGameOn
and (gPlayer1
<> nil) then
4066 gPlayer1
.SetColor(gPlayer1Settings
.Color
);
4067 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer1
.UID
);
4073 if Length(P
) > 3 then
4075 gPlayer2Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
4076 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
4077 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
4078 if g_Game_IsClient
then
4079 MC_SEND_PlayerSettings
4080 else if gGameOn
and (gPlayer2
<> nil) then
4082 gPlayer2
.SetColor(gPlayer2Settings
.Color
);
4083 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer2
.UID
);
4089 if (Length(P
) > 1) then
4091 gPlayer1Settings
.Model
:= P
[1];
4092 if g_Game_IsClient
then
4093 MC_SEND_PlayerSettings
4094 else if gGameOn
and (gPlayer1
<> nil) then
4096 gPlayer1
.FActualModelName
:= gPlayer1Settings
.Model
;
4097 gPlayer1
.SetModel(gPlayer1Settings
.Model
);
4098 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer1
.UID
);
4104 if (Length(P
) > 1) then
4106 gPlayer2Settings
.Model
:= P
[1];
4107 if g_Game_IsClient
then
4108 MC_SEND_PlayerSettings
4109 else if gGameOn
and (gPlayer2
<> nil) then
4111 gPlayer2
.FActualModelName
:= gPlayer2Settings
.Model
;
4112 gPlayer2
.SetModel(gPlayer2Settings
.Model
);
4113 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer2
.UID
);
4119 // TODO: switch teams if in game or store this separately
4120 if (Length(P
) > 1) then
4122 team
:= ParseTeam(P
[1]);
4123 if team
= TEAM_NONE
then
4124 g_Console_Add('expected ''red'', ''blue'', 1 or 2')
4125 else if not gGameOn
and not g_Game_IsNet
then
4126 gPlayer1Settings
.Team
:= team
4128 g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
4133 // TODO: switch teams if in game or store this separately
4134 if (Length(P
) > 1) then
4136 team
:= ParseTeam(P
[1]);
4137 if team
= TEAM_NONE
then
4138 g_Console_Add('expected ''red'', ''blue'', 1 or 2')
4139 else if not gGameOn
and not g_Game_IsNet
then
4140 gPlayer2Settings
.Team
:= team
4142 g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
4148 procedure PrintHeapStats();
4152 hs
:= GetFPCHeapStatus();
4153 e_LogWriteLn ('v===== heap status =====v');
4154 e_LogWriteFln('max heap size = %d k', [hs
.MaxHeapSize
div 1024]);
4155 e_LogWriteFln('max heap used = %d k', [hs
.MaxHeapUsed
div 1024]);
4156 e_LogWriteFln('cur heap size = %d k', [hs
.CurrHeapSize
div 1024]);
4157 e_LogWriteFln('cur heap used = %d k', [hs
.CurrHeapUsed
div 1024]);
4158 e_LogWriteFln('cur heap free = %d k', [hs
.CurrHeapFree
div 1024]);
4159 e_LogWriteLn ('^=======================^');
4162 procedure DebugCommands(P
: SSArray
);
4169 // Команды отладочного режима:
4170 if {gDebugMode}conIsCheatsEnabled
then
4172 cmd
:= LowerCase(P
[0]);
4173 if cmd
= 'd_window' then
4175 g_Console_Add(Format('gScreenWidth = %d, gScreenHeight = %d', [gScreenWidth
, gScreenHeight
]));
4176 g_Console_Add(Format('gScreenWidth = %d, gScreenHeight = %d', [gScreenWidth
, gScreenHeight
]));
4178 else if cmd
= 'd_sounds' then
4180 if (Length(P
) > 1) and
4181 ((P
[1] = '1') or (P
[1] = '0')) then
4182 g_Debug_Sounds
:= (P
[1][1] = '1');
4184 g_Console_Add(Format('d_sounds is %d', [Byte(g_Debug_Sounds
)]));
4186 else if cmd
= 'd_frames' then
4188 if (Length(P
) > 1) and
4189 ((P
[1] = '1') or (P
[1] = '0')) then
4190 g_Debug_Frames
:= (P
[1][1] = '1');
4192 g_Console_Add(Format('d_frames is %d', [Byte(g_Debug_Frames
)]));
4194 else if cmd
= 'd_winmsg' then
4196 if (Length(P
) > 1) and
4197 ((P
[1] = '1') or (P
[1] = '0')) then
4198 g_Debug_WinMsgs
:= (P
[1][1] = '1');
4200 g_Console_Add(Format('d_winmsg is %d', [Byte(g_Debug_WinMsgs
)]));
4202 else if (cmd
= 'd_monoff') and not g_Game_IsNet
then
4204 if (Length(P
) > 1) and
4205 ((P
[1] = '1') or (P
[1] = '0')) then
4206 g_Debug_MonsterOff
:= (P
[1][1] = '1');
4208 g_Console_Add(Format('d_monoff is %d', [Byte(g_debug_MonsterOff
)]));
4210 else if (cmd
= 'd_botoff') and not g_Game_IsNet
then
4212 if Length(P
) > 1 then
4214 '0': g_debug_BotAIOff
:= 0;
4215 '1': g_debug_BotAIOff
:= 1;
4216 '2': g_debug_BotAIOff
:= 2;
4217 '3': g_debug_BotAIOff
:= 3;
4220 g_Console_Add(Format('d_botoff is %d', [g_debug_BotAIOff
]));
4222 else if cmd
= 'd_monster' then
4224 if gGameOn
and (gPlayer1
<> nil) and (gPlayer1
.alive
) and (not g_Game_IsNet
) then
4225 if Length(P
) < 2 then
4227 g_Console_Add(cmd
+ ' [ID | Name] [behaviour]');
4228 g_Console_Add('ID | Name');
4229 for b
:= MONSTER_DEMON
to MONSTER_MAN
do
4230 g_Console_Add(Format('%2d | %s', [b
, g_Mons_NameByTypeId(b
)]));
4231 conwriteln('behav. num'#10'normal 0'#10'killer 1'#10'maniac 2'#10'insane 3'#10'cannibal 4'#10'good 5');
4234 a
:= StrToIntDef(P
[1], 0);
4235 if (a
< MONSTER_DEMON
) or (a
> MONSTER_MAN
) then
4236 a
:= g_Mons_TypeIdByName(P
[1]);
4238 if (a
< MONSTER_DEMON
) or (a
> MONSTER_MAN
) then
4239 g_Console_Add(Format(_lc
[I_MSG_NO_MONSTER
], [P
[1]]))
4242 with gPlayer1
.Obj
do
4244 mon
:= g_Monsters_Create(a
,
4245 X
+ Rect
.X
+ (Rect
.Width
div 2),
4246 Y
+ Rect
.Y
+ Rect
.Height
,
4247 gPlayer1
.Direction
, True);
4249 if (Length(P
) > 2) and (mon
<> nil) then
4251 if (CompareText(P
[2], 'normal') = 0) then mon
.MonsterBehaviour
:= BH_NORMAL
4252 else if (CompareText(P
[2], 'killer') = 0) then mon
.MonsterBehaviour
:= BH_KILLER
4253 else if (CompareText(P
[2], 'maniac') = 0) then mon
.MonsterBehaviour
:= BH_MANIAC
4254 else if (CompareText(P
[2], 'insane') = 0) then mon
.MonsterBehaviour
:= BH_INSANE
4255 else if (CompareText(P
[2], 'cannibal') = 0) then mon
.MonsterBehaviour
:= BH_CANNIBAL
4256 else if (CompareText(P
[2], 'good') = 0) then mon
.MonsterBehaviour
:= BH_GOOD
4257 else if (CompareText(P
[2], 'friend') = 0) then mon
.MonsterBehaviour
:= BH_GOOD
4258 else if (CompareText(P
[2], 'friendly') = 0) then mon
.MonsterBehaviour
:= BH_GOOD
4259 else mon
.MonsterBehaviour
:= Min(Max(StrToIntDef(P
[2], BH_NORMAL
), BH_NORMAL
), BH_GOOD
);
4264 else if (cmd
= 'd_health') then
4266 if (Length(P
) > 1) and
4267 ((P
[1] = '1') or (P
[1] = '0')) then
4268 g_debug_HealthBar
:= (P
[1][1] = '1');
4270 g_Console_Add(Format('d_health is %d', [Byte(g_debug_HealthBar
)]));
4272 else if (cmd
= 'd_player') then
4274 if (Length(P
) > 1) and
4275 ((P
[1] = '1') or (P
[1] = '0')) then
4276 g_debug_Player
:= (P
[1][1] = '1');
4278 g_Console_Add(Format(cmd
+ ' is %d', [Byte(g_Debug_Player
)]));
4280 else if (cmd
= 'd_mem') then
4286 g_Console_Add(_lc
[I_MSG_NOT_DEBUG
]);
4290 procedure GameCheats(P
: SSArray
);
4296 if (not gGameOn
) or (not conIsCheatsEnabled
) then
4298 g_Console_Add('not available');
4304 g_Console_Add('where is the player?!');
4307 cmd
:= LowerCase(P
[0]);
4311 plr
.GodMode
:= not plr
.GodMode
;
4312 if plr
.GodMode
then g_Console_Add('player is godlike now') else g_Console_Add('player is mortal now');
4315 // give <health|exit|weapons|air|suit|jetpack|berserk|all>
4316 if cmd
= 'give' then
4318 if length(P
) < 2 then begin g_Console_Add('give what?!'); exit
; end;
4319 for f
:= 1 to High(P
) do
4321 cmd
:= LowerCase(P
[f
]);
4322 if cmd
= 'health' then begin plr
.RestoreHealthArmor(); g_Console_Add('player feels himself better'); continue
; end;
4323 if (cmd
= 'all') {or (cmd = 'weapons')} then begin plr
.AllRulez(False); g_Console_Add('player got the gifts'); continue
; end;
4324 if cmd
= 'exit' then
4326 if gTriggers
<> nil then
4328 for a
:= 0 to High(gTriggers
) do
4330 if gTriggers
[a
].TriggerType
= TRIGGER_EXIT
then
4332 g_Console_Add('player left the map');
4333 gExitByTrigger
:= True;
4334 //g_Game_ExitLevel(gTriggers[a].Data.MapName);
4335 g_Game_ExitLevel(gTriggers
[a
].tgcMap
);
4343 if cmd
= 'air' then begin plr
.GiveItem(ITEM_OXYGEN
); g_Console_Add('player got some air'); continue
; end;
4344 if cmd
= 'jetpack' then begin plr
.GiveItem(ITEM_JETPACK
); g_Console_Add('player got a jetpack'); continue
; end;
4345 if cmd
= 'suit' then begin plr
.GiveItem(ITEM_SUIT
); g_Console_Add('player got an envirosuit'); continue
; end;
4346 if cmd
= 'berserk' then begin plr
.GiveItem(ITEM_MEDKIT_BLACK
); g_Console_Add('player got a berserk pack'); continue
; end;
4347 if cmd
= 'backpack' then begin plr
.GiveItem(ITEM_AMMO_BACKPACK
); g_Console_Add('player got a backpack'); continue
; end;
4349 if cmd
= 'helmet' then begin plr
.GiveItem(ITEM_HELMET
); g_Console_Add('player got a helmet'); continue
; end;
4350 if cmd
= 'bottle' then begin plr
.GiveItem(ITEM_BOTTLE
); g_Console_Add('player got a bottle of health'); continue
; end;
4352 if cmd
= 'stimpack' then begin plr
.GiveItem(ITEM_MEDKIT_SMALL
); g_Console_Add('player got a stimpack'); continue
; end;
4353 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;
4355 if cmd
= 'greenarmor' then begin plr
.GiveItem(ITEM_ARMOR_GREEN
); g_Console_Add('player got a security armor'); continue
; end;
4356 if cmd
= 'bluearmor' then begin plr
.GiveItem(ITEM_ARMOR_BLUE
); g_Console_Add('player got a combat armor'); continue
; end;
4358 if (cmd
= 'megasphere') or (cmd
= 'mega') then begin plr
.GiveItem(ITEM_SPHERE_BLUE
); g_Console_Add('player got a megasphere'); continue
; end;
4359 if (cmd
= 'soulsphere') or (cmd
= 'soul')then begin plr
.GiveItem(ITEM_SPHERE_WHITE
); g_Console_Add('player got a soul sphere'); continue
; end;
4361 if (cmd
= 'invul') or (cmd
= 'invulnerability') then begin plr
.GiveItem(ITEM_INVUL
); g_Console_Add('player got invulnerability'); continue
; end;
4362 if (cmd
= 'invis') or (cmd
= 'invisibility') then begin plr
.GiveItem(ITEM_INVIS
); g_Console_Add('player got invisibility'); continue
; end;
4364 if cmd
= 'redkey' then begin plr
.GiveItem(ITEM_KEY_RED
); g_Console_Add('player got the red key'); continue
; end;
4365 if cmd
= 'greenkey' then begin plr
.GiveItem(ITEM_KEY_GREEN
); g_Console_Add('player got the green key'); continue
; end;
4366 if cmd
= 'bluekey' then begin plr
.GiveItem(ITEM_KEY_BLUE
); g_Console_Add('player got the blue key'); continue
; end;
4368 if (cmd
= 'shotgun') or (cmd
= 'sg') then begin plr
.GiveItem(ITEM_WEAPON_SHOTGUN1
); g_Console_Add('player got a shotgun'); continue
; end;
4369 if (cmd
= 'supershotgun') or (cmd
= 'ssg') then begin plr
.GiveItem(ITEM_WEAPON_SHOTGUN2
); g_Console_Add('player got a supershotgun'); continue
; end;
4370 if cmd
= 'chaingun' then begin plr
.GiveItem(ITEM_WEAPON_CHAINGUN
); g_Console_Add('player got a chaingun'); continue
; end;
4371 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;
4372 if cmd
= 'plasmagun' then begin plr
.GiveItem(ITEM_WEAPON_PLASMA
); g_Console_Add('player got a plasma gun'); continue
; end;
4373 if cmd
= 'bfg' then begin plr
.GiveItem(ITEM_WEAPON_BFG
); g_Console_Add('player got a BFG-9000'); continue
; end;
4375 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;
4376 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;
4377 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;
4378 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;
4379 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;
4380 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;
4382 if cmd
= 'superchaingun' then begin plr
.GiveItem(ITEM_WEAPON_SUPERPULEMET
); g_Console_Add('player got a superchaingun'); continue
; end;
4383 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;
4385 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;
4386 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;
4388 if cmd
= 'chainsaw' then begin plr
.GiveItem(ITEM_WEAPON_SAW
); g_Console_Add('player got a chainsaw'); continue
; end;
4390 if cmd
= 'ammo' then
4392 plr
.GiveItem(ITEM_AMMO_SHELLS_BOX
);
4393 plr
.GiveItem(ITEM_AMMO_BULLETS_BOX
);
4394 plr
.GiveItem(ITEM_AMMO_CELL_BIG
);
4395 plr
.GiveItem(ITEM_AMMO_ROCKET_BOX
);
4396 plr
.GiveItem(ITEM_AMMO_FUELCAN
);
4397 g_Console_Add('player got some ammo');
4401 if cmd
= 'clip' then begin plr
.GiveItem(ITEM_AMMO_BULLETS
); g_Console_Add('player got some bullets'); continue
; end;
4402 if cmd
= 'bullets' then begin plr
.GiveItem(ITEM_AMMO_BULLETS_BOX
); g_Console_Add('player got a box of bullets'); continue
; end;
4404 if cmd
= 'shells' then begin plr
.GiveItem(ITEM_AMMO_SHELLS
); g_Console_Add('player got some shells'); continue
; end;
4405 if cmd
= 'shellbox' then begin plr
.GiveItem(ITEM_AMMO_SHELLS_BOX
); g_Console_Add('player got a box of shells'); continue
; end;
4407 if cmd
= 'cells' then begin plr
.GiveItem(ITEM_AMMO_CELL
); g_Console_Add('player got some cells'); continue
; end;
4408 if cmd
= 'battery' then begin plr
.GiveItem(ITEM_AMMO_CELL_BIG
); g_Console_Add('player got cell battery'); continue
; end;
4410 if cmd
= 'rocket' then begin plr
.GiveItem(ITEM_AMMO_ROCKET
); g_Console_Add('player got a rocket'); continue
; end;
4411 if cmd
= 'rocketbox' then begin plr
.GiveItem(ITEM_AMMO_ROCKET_BOX
); g_Console_Add('player got some rockets'); continue
; end;
4413 if (cmd
= 'fuel') or (cmd
= 'fuelcan') then begin plr
.GiveItem(ITEM_AMMO_FUELCAN
); g_Console_Add('player got fuel canister'); continue
; end;
4415 if cmd
= 'weapons' then
4417 plr
.GiveItem(ITEM_WEAPON_SHOTGUN1
);
4418 plr
.GiveItem(ITEM_WEAPON_SHOTGUN2
);
4419 plr
.GiveItem(ITEM_WEAPON_CHAINGUN
);
4420 plr
.GiveItem(ITEM_WEAPON_ROCKETLAUNCHER
);
4421 plr
.GiveItem(ITEM_WEAPON_PLASMA
);
4422 plr
.GiveItem(ITEM_WEAPON_BFG
);
4423 g_Console_Add('player got weapons');
4427 if cmd
= 'keys' then
4429 plr
.GiveItem(ITEM_KEY_RED
);
4430 plr
.GiveItem(ITEM_KEY_GREEN
);
4431 plr
.GiveItem(ITEM_KEY_BLUE
);
4432 g_Console_Add('player got all keys');
4436 g_Console_Add('i don''t know how to give '''+cmd
+'''!');
4441 if cmd
= 'open' then
4443 g_Console_Add('player activated sesame');
4444 g_Triggers_OpenAll();
4451 if gFly
then g_Console_Add('player feels himself lighter') else g_Console_Add('player lost his wings');
4455 if cmd
= 'noclip' then
4458 g_Console_Add('wall hardeness adjusted');
4462 if cmd
= 'notarget' then
4464 plr
.NoTarget
:= not plr
.NoTarget
;
4465 if plr
.NoTarget
then g_Console_Add('player hides in shadows') else g_Console_Add('player is brave again');
4469 if cmd
= 'noreload' then
4471 plr
.NoReload
:= not plr
.NoReload
;
4472 if plr
.NoReload
then g_Console_Add('player is action hero now') else g_Console_Add('player is ordinary man now');
4476 if cmd
= 'speedy' then
4478 MAX_RUNVEL
:= 32-MAX_RUNVEL
;
4479 g_Console_Add('speed adjusted');
4483 if cmd
= 'jumpy' then
4485 VEL_JUMP
:= 30-VEL_JUMP
;
4486 g_Console_Add('jump height adjusted');
4490 if cmd
= 'automap' then
4492 gShowMap
:= not gShowMap
;
4493 if gShowMap
then g_Console_Add('player gains second sight') else g_Console_Add('player lost second sight');
4497 if cmd
= 'aimline' then
4499 gAimLine
:= not gAimLine
;
4500 if gAimLine
then g_Console_Add('player gains laser sight') else g_Console_Add('player lost laser sight');
4505 procedure GameCommands(P
: SSArray
);
4511 pl
: pTNetClient
= nil;
4519 cmd
:= LowerCase(P
[0]);
4521 if cmd
= 'pause' then
4523 if (g_ActiveWindow
= nil) then
4524 g_Game_Pause(not gPauseMain
);
4526 else if cmd
= 'endgame' then
4527 gExit
:= EXIT_SIMPLE
4528 else if cmd
= 'restart' then
4530 if gGameOn
or (gState
in [STATE_INTERSINGLE
, STATE_INTERCUSTOM
]) then
4532 if g_Game_IsClient
then
4534 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4539 g_Console_Add(_lc
[I_MSG_NOT_GAME
]);
4541 else if cmd
= 'kick' then
4543 if g_Game_IsServer
then
4545 if Length(P
) < 2 then
4547 g_Console_Add('kick <name>');
4552 g_Console_Add('kick <name>');
4556 if g_Game_IsNet
then
4557 pl
:= g_Net_Client_ByName(P
[1]);
4560 s
:= g_Net_ClientName_ByID(pl
^.ID
);
4561 enet_peer_disconnect(pl
^.Peer
, NET_DISC_KICK
);
4562 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
4563 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
4564 g_Net_Slist_ServerPlayerLeaves();
4565 end else if gPlayers
<> nil then
4566 for a
:= Low(gPlayers
) to High(gPlayers
) do
4567 if gPlayers
[a
] <> nil then
4568 if Copy(LowerCase(gPlayers
[a
].Name
), 1, Length(P
[1])) = LowerCase(P
[1]) then
4570 // Не отключать основных игроков в сингле
4571 if not(gPlayers
[a
] is TBot
) and (gGameSettings
.GameType
= GT_SINGLE
) then
4573 gPlayers
[a
].Lives
:= 0;
4574 gPlayers
[a
].Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
4575 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [gPlayers
[a
].Name
]), True);
4576 g_Player_Remove(gPlayers
[a
].UID
);
4577 g_Net_Slist_ServerPlayerLeaves();
4578 // Если не перемешать, при добавлении новых ботов появятся старые
4582 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
4584 else if cmd
= 'kick_id' then
4586 if g_Game_IsServer
and g_Game_IsNet
then
4588 if Length(P
) < 2 then
4590 g_Console_Add('kick_id <client ID>');
4595 g_Console_Add('kick_id <client ID>');
4599 a
:= StrToIntDef(P
[1], 0);
4600 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
4602 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
4604 s
:= g_Net_ClientName_ByID(NetClients
[a
].ID
);
4605 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_KICK
);
4606 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
4607 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
4608 g_Net_Slist_ServerPlayerLeaves();
4612 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4614 else if cmd
= 'kick_pid' then
4616 if g_Game_IsServer
and g_Game_IsNet
then
4618 if Length(P
) < 2 then
4620 g_Console_Add('kick_pid <player ID>');
4625 g_Console_Add('kick_pid <player ID>');
4629 a
:= StrToIntDef(P
[1], 0);
4630 pl
:= g_Net_Client_ByPlayer(a
);
4631 if (pl
<> nil) and pl
^.Used
and (pl
^.Peer
<> nil) then
4633 s
:= g_Net_ClientName_ByID(pl
^.ID
);
4634 enet_peer_disconnect(pl
^.Peer
, NET_DISC_KICK
);
4635 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
4636 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
4637 g_Net_Slist_ServerPlayerLeaves();
4640 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4642 else if cmd
= 'ban' then
4644 if g_Game_IsServer
and g_Game_IsNet
then
4646 if Length(P
) < 2 then
4648 g_Console_Add('ban <name>');
4653 g_Console_Add('ban <name>');
4657 pl
:= g_Net_Client_ByName(P
[1]);
4660 s
:= g_Net_ClientName_ByID(pl
^.ID
);
4661 g_Net_BanHost(pl
^.Peer
^.address
.host
, False);
4662 enet_peer_disconnect(pl
^.Peer
, NET_DISC_TEMPBAN
);
4663 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
4664 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
4665 g_Net_Slist_ServerPlayerLeaves();
4667 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
4669 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4671 else if cmd
= 'ban_id' then
4673 if g_Game_IsServer
and g_Game_IsNet
then
4675 if Length(P
) < 2 then
4677 g_Console_Add('ban_id <client ID>');
4682 g_Console_Add('ban_id <client ID>');
4686 a
:= StrToIntDef(P
[1], 0);
4687 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
4688 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
4690 s
:= g_Net_ClientName_ByID(NetClients
[a
].ID
);
4691 g_Net_BanHost(NetClients
[a
].Peer
^.address
.host
, False);
4692 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_TEMPBAN
);
4693 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
4694 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
4695 g_Net_Slist_ServerPlayerLeaves();
4698 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4700 else if cmd
= 'ban_pid' then
4702 if g_Game_IsServer
and g_Game_IsNet
then
4704 if Length(P
) < 2 then
4706 g_Console_Add('ban_pid <player ID>');
4711 g_Console_Add('ban_pid <player ID>');
4715 a
:= StrToIntDef(P
[1], 0);
4716 pl
:= g_Net_Client_ByPlayer(a
);
4717 if (pl
<> nil) and pl
^.Used
and (pl
^.Peer
<> nil) then
4719 s
:= g_Net_ClientName_ByID(pl
^.ID
);
4720 g_Net_BanHost(pl
^.Peer
^.address
.host
, False);
4721 enet_peer_disconnect(pl
^.Peer
, NET_DISC_TEMPBAN
);
4722 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
4723 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
4724 g_Net_Slist_ServerPlayerLeaves();
4727 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4729 else if cmd
= 'permban' then
4731 if g_Game_IsServer
and g_Game_IsNet
then
4733 if Length(P
) < 2 then
4735 g_Console_Add('permban <name>');
4740 g_Console_Add('permban <name>');
4744 pl
:= g_Net_Client_ByName(P
[1]);
4747 s
:= g_Net_ClientName_ByID(pl
^.ID
);
4748 g_Net_BanHost(pl
^.Peer
^.address
.host
);
4749 enet_peer_disconnect(pl
^.Peer
, NET_DISC_BAN
);
4750 g_Net_SaveBanList();
4751 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
4752 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
4753 g_Net_Slist_ServerPlayerLeaves();
4755 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
4757 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4759 else if cmd
= 'permban_id' then
4761 if g_Game_IsServer
and g_Game_IsNet
then
4763 if Length(P
) < 2 then
4765 g_Console_Add('permban_id <client ID>');
4770 g_Console_Add('permban_id <client ID>');
4774 a
:= StrToIntDef(P
[1], 0);
4775 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
4776 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
4778 s
:= g_Net_ClientName_ByID(NetClients
[a
].ID
);
4779 g_Net_BanHost(NetClients
[a
].Peer
^.address
.host
);
4780 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_BAN
);
4781 g_Net_SaveBanList();
4782 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
4783 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
4784 g_Net_Slist_ServerPlayerLeaves();
4787 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4789 else if cmd
= 'permban_pid' then
4791 if g_Game_IsServer
and g_Game_IsNet
then
4793 if Length(P
) < 2 then
4795 g_Console_Add('permban_pid <player ID>');
4800 g_Console_Add('permban_pid <player ID>');
4804 a
:= StrToIntDef(P
[1], 0);
4805 pl
:= g_Net_Client_ByPlayer(a
);
4806 if (pl
<> nil) and pl
^.Used
and (pl
^.Peer
<> nil) then
4808 s
:= g_Net_ClientName_ByID(pl
^.ID
);
4809 g_Net_BanHost(pl
^.Peer
^.address
.host
);
4810 enet_peer_disconnect(pl
^.Peer
, NET_DISC_BAN
);
4811 g_Net_SaveBanList();
4812 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
4813 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
4814 g_Net_Slist_ServerPlayerLeaves();
4817 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4819 else if cmd
= 'permban_ip' then
4821 if g_Game_IsServer
and g_Game_IsNet
then
4823 if Length(P
) < 2 then
4825 g_Console_Add('permban_ip <IP address>');
4830 g_Console_Add('permban_ip <IP address>');
4834 g_Net_BanHost(P
[1]);
4835 g_Net_SaveBanList();
4836 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [P
[1]]));
4838 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4840 else if cmd
= 'unban' then
4842 if g_Game_IsServer
and g_Game_IsNet
then
4844 if Length(P
) < 2 then
4846 g_Console_Add('unban <IP Address>');
4851 g_Console_Add('unban <IP Address>');
4855 if g_Net_UnbanHost(P
[1]) then
4857 g_Console_Add(Format(_lc
[I_MSG_UNBAN_OK
], [P
[1]]));
4858 g_Net_SaveBanList();
4860 g_Console_Add(Format(_lc
[I_MSG_UNBAN_FAIL
], [P
[1]]));
4862 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4864 else if cmd
= 'clientlist' then
4866 if g_Game_IsServer
and g_Game_IsNet
then
4869 if NetClients
<> nil then
4870 for a
:= Low(NetClients
) to High(NetClients
) do
4871 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
4873 plr
:= g_Player_Get(NetClients
[a
].Player
);
4874 if plr
= nil then continue
;
4876 g_Console_Add(Format('#%2d: %-15s | %s', [a
,
4877 IpToStr(NetClients
[a
].Peer
^.address
.host
), plr
.Name
]));
4880 g_Console_Add(_lc
[I_MSG_NOCLIENTS
]);
4882 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4884 else if cmd
= 'connect' then
4886 if (NetMode
= NET_NONE
) then
4888 if Length(P
) < 2 then
4890 g_Console_Add('connect <IP> [port] [password]');
4895 g_Console_Add('connect <IP> [port] [password]');
4899 if Length(P
) > 2 then
4900 prt
:= StrToIntDef(P
[2], 25666)
4904 if Length(P
) > 3 then
4909 g_Game_StartClient(P
[1], prt
, pw
);
4912 else if cmd
= 'disconnect' then
4914 if (NetMode
= NET_CLIENT
) then
4917 else if cmd
= 'reconnect' then
4919 if (NetMode
= NET_SERVER
) then
4922 if (NetMode
= NET_CLIENT
) then
4925 gExit
:= EXIT_SIMPLE
;
4929 //TODO: Use last successful password to reconnect, instead of ''
4930 g_Game_StartClient(NetClientIP
, NetClientPort
, '');
4932 else if (cmd
= 'addbot') or
4933 (cmd
= 'bot_add') then
4935 if Length(P
) > 2 then
4936 g_Bot_Add(TEAM_NONE
, StrToIntDef(P
[1], 2), StrToIntDef(P
[2], 100))
4937 else if Length(P
) > 1 then
4938 g_Bot_Add(TEAM_NONE
, StrToIntDef(P
[1], 2))
4940 g_Bot_Add(TEAM_NONE
, 2);
4942 else if cmd
= 'bot_addlist' then
4944 if Length(P
) > 1 then
4946 if Length(P
) = 2 then
4947 g_Bot_AddList(TEAM_NONE
, P
[1], StrToIntDef(P
[1], -1))
4948 else if Length(P
) = 3 then
4949 g_Bot_AddList(TEAM_NONE
, P
[1], StrToIntDef(P
[1], -1), StrToIntDef(P
[2], 100))
4951 g_Bot_AddList(IfThen(P
[2] = 'red', TEAM_RED
, TEAM_BLUE
), P
[1], StrToIntDef(P
[1], -1));
4954 else if cmd
= 'bot_removeall' then
4956 else if cmd
= 'chat' then
4958 if g_Game_IsNet
then
4960 if Length(P
) > 1 then
4962 for a
:= 1 to High(P
) do
4963 chstr
:= chstr
+ P
[a
] + ' ';
4965 if Length(chstr
) > 200 then SetLength(chstr
, 200);
4967 if Length(chstr
) < 1 then
4969 g_Console_Add('chat <text>');
4973 chstr
:= b_Text_Format(chstr
);
4974 if g_Game_IsClient
then
4975 MC_SEND_Chat(chstr
, NET_CHAT_PLAYER
)
4977 MH_SEND_Chat(gPlayer1Settings
.Name
+ ': ' + chstr
, NET_CHAT_PLAYER
);
4980 g_Console_Add('chat <text>');
4982 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
4984 else if cmd
= 'teamchat' then
4986 if g_Game_IsNet
and (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
4988 if Length(P
) > 1 then
4990 for a
:= 1 to High(P
) do
4991 chstr
:= chstr
+ P
[a
] + ' ';
4993 if Length(chstr
) > 200 then SetLength(chstr
, 200);
4995 if Length(chstr
) < 1 then
4997 g_Console_Add('teamchat <text>');
5001 chstr
:= b_Text_Format(chstr
);
5002 if g_Game_IsClient
then
5003 MC_SEND_Chat(chstr
, NET_CHAT_TEAM
)
5005 MH_SEND_Chat(gPlayer1Settings
.Name
+ ': ' + chstr
, NET_CHAT_TEAM
,
5006 gPlayer1Settings
.Team
);
5009 g_Console_Add('teamchat <text>');
5011 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
5013 else if cmd
= 'game' then
5015 if gGameSettings
.GameType
<> GT_NONE
then
5017 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
5020 if Length(P
) = 1 then
5022 g_Console_Add(cmd
+ ' <WAD> [MAP] [# players]');
5025 // game not started yet, load fist map from some wad
5027 s
:= addWadExtension(P
[1]);
5028 found
:= e_FindResource(AllMapDirs
, s
);
5032 P
[1] := ExpandFileName(P
[1]);
5033 // if map not choosed then set first map
5034 if Length(P
) < 3 then
5037 P
[2] := g_Game_GetFirstMap(P
[1]);
5040 s
:= P
[1] + ':\' + UpperCase(P
[2]);
5042 if g_Map_Exist(s
) then
5046 with gGameSettings
do
5048 Options
:= gsGameFlags
;
5049 GameMode
:= g_Game_TextToMode(gsGameMode
);
5050 if gSwitchGameMode
<> GM_NONE
then
5051 GameMode
:= gSwitchGameMode
;
5052 if GameMode
= GM_NONE
then GameMode
:= GM_DM
;
5053 if GameMode
= GM_SINGLE
then GameMode
:= GM_COOP
;
5055 if Length(P
) >= 4 then
5056 b
:= StrToIntDef(P
[3], 1);
5057 g_Game_StartCustom(s
, GameMode
, TimeLimit
,
5058 GoalLimit
, MaxLives
, Options
, b
);
5063 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
5065 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [UpperCase(P
[2]), P
[1]]));
5067 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]));
5069 else if cmd
= 'host' then
5071 if gGameSettings
.GameType
<> GT_NONE
then
5073 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
5076 if Length(P
) < 4 then
5078 g_Console_Add(cmd
+ ' <listen IP> <port> <WAD> [MAP] [# players]');
5081 if not StrToIp(P
[1], listen
) then
5083 prt
:= StrToIntDef(P
[2], 25666);
5085 s
:= addWadExtension(P
[3]);
5086 found
:= e_FindResource(AllMapDirs
, s
);
5090 // get first map in wad, if not specified
5091 if Length(P
) < 5 then
5094 P
[4] := g_Game_GetFirstMap(P
[1]);
5096 s
:= P
[3] + ':\' + UpperCase(P
[4]);
5097 if g_Map_Exist(s
) then
5101 with gGameSettings
do
5103 Options
:= gsGameFlags
;
5104 GameMode
:= g_Game_TextToMode(gsGameMode
);
5105 if gSwitchGameMode
<> GM_NONE
then GameMode
:= gSwitchGameMode
;
5106 if GameMode
= GM_NONE
then GameMode
:= GM_DM
;
5107 if GameMode
= GM_SINGLE
then GameMode
:= GM_COOP
;
5109 if Length(P
) >= 6 then
5110 b
:= StrToIntDef(P
[5], 0);
5111 g_Game_StartServer(s
, GameMode
, TimeLimit
, GoalLimit
, MaxLives
, Options
, b
, listen
, prt
)
5117 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[3]]))
5119 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [UpperCase(P
[4]), P
[3]]))
5124 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[3]]))
5127 else if cmd
= 'map' then
5129 if Length(P
) = 1 then
5131 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
5133 g_Console_Add(cmd
+ ' <MAP>');
5134 g_Console_Add(cmd
+ ' <WAD> [MAP]')
5138 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
])
5143 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
5145 if Length(P
) < 3 then
5147 // first param is map or wad
5148 s
:= UpperCase(P
[1]);
5149 if g_Map_Exist(gGameSettings
.WAD
+ ':\' + s
) then
5151 gExitByTrigger
:= False;
5154 // already in game, finish current map
5156 gExit
:= EXIT_ENDLEVELCUSTOM
;
5160 // intermission, so change map immediately
5167 found
:= e_FindResource(AllMapDirs
, s
);
5169 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [s
, 'WAD ' + P
[1]]));
5172 // no such map, found wad
5175 P
[1] := ExpandFileName(pw
);
5176 P
[2] := g_Game_GetFirstMap(P
[1]);
5177 s
:= P
[1] + ':\' + P
[2];
5178 if g_Map_Exist(s
) then
5180 gExitByTrigger
:= False;
5183 // already in game, finish current map
5185 gExit
:= EXIT_ENDLEVELCUSTOM
5189 // intermission, so change map immediately
5196 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
5198 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]))
5203 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]))
5209 s
:= addWadExtension(P
[1]);
5210 found
:= e_FindResource(AllMapDirs
, s
);
5214 P
[2] := UpperCase(P
[2]);
5215 s
:= P
[1] + ':\' + P
[2];
5216 if g_Map_Exist(s
) then
5218 gExitByTrigger
:= False;
5222 gExit
:= EXIT_ENDLEVELCUSTOM
5231 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]))
5236 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]))
5242 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
])
5246 else if cmd
= 'nextmap' then
5248 if not(gGameOn
or (gState
= STATE_INTERCUSTOM
)) then
5250 g_Console_Add(_lc
[I_MSG_NOT_GAME
])
5255 if Length(P
) = 1 then
5257 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
5259 g_Console_Add(cmd
+ ' <MAP>');
5260 g_Console_Add(cmd
+ ' <WAD> [MAP]');
5265 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
5271 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
5273 if Length(P
) < 3 then
5275 // first param is map or wad
5276 s
:= UpperCase(P
[1]);
5277 if g_Map_Exist(gGameSettings
.WAD
+ ':\' + s
) then
5280 gExitByTrigger
:= False;
5286 // no such map, found wad
5287 pw
:= addWadExtension(P
[1]);
5288 found
:= e_FindResource(MapDirs
, pw
);
5290 found
:= e_FindResource(WadDirs
, pw
);
5292 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [s
, P
[1]]));
5295 // map not specified, select first map
5297 P
[2] := g_Game_GetFirstMap(P
[1]);
5298 s
:= P
[1] + ':\' + P
[2];
5299 if g_Map_Exist(s
) then
5301 gExitByTrigger
:= False;
5308 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
5310 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]))
5315 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]))
5321 // specified two params wad + map
5322 pw
:= addWadExtension(P
[1]);
5323 found
:= e_FindResource(MapDirs
, pw
);
5325 found
:= e_FindResource(MapDirs
, pw
);
5329 P
[2] := UpperCase(P
[2]);
5330 s
:= P
[1] + ':\' + P
[2];
5331 if g_Map_Exist(s
) then
5333 gExitByTrigger
:= False;
5339 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]))
5344 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]))
5350 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
])
5355 if gNextMap
= '' then
5356 g_Console_Add(_lc
[I_MSG_NEXTMAP_UNSET
])
5358 g_Console_Add(Format(_lc
[I_MSG_NEXTMAP_SET
], [gNextMap
]))
5362 else if (cmd
= 'endmap') or (cmd
= 'goodbye') then
5366 g_Console_Add(_lc
[I_MSG_NOT_GAME
])
5370 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
5372 gExitByTrigger
:= False;
5373 // next map not specified, try to find trigger EXIT
5374 if (gNextMap
= '') and (gTriggers
<> nil) then
5376 for a
:= 0 to High(gTriggers
) do
5378 if gTriggers
[a
].TriggerType
= TRIGGER_EXIT
then
5380 gExitByTrigger
:= True;
5381 //gNextMap := gTriggers[a].Data.MapName;
5382 gNextMap
:= gTriggers
[a
].tgcMap
;
5387 if gNextMap
= '' then
5388 gNextMap
:= g_Game_GetNextMap();
5389 if not isWadPath(gNextMap
) then
5390 s
:= gGameSettings
.WAD
+ ':\' + gNextMap
5393 if g_Map_Exist(s
) then
5394 gExit
:= EXIT_ENDLEVELCUSTOM
5396 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [gNextMap
]))
5400 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
])
5404 else if (cmd
= 'event') then
5406 if (Length(P
) <= 1) then
5408 for a
:= 0 to High(gEvents
) do
5409 if gEvents
[a
].Command
= '' then
5410 g_Console_Add(gEvents
[a
].Name
+ ' <none>')
5412 g_Console_Add(gEvents
[a
].Name
+ ' "' + gEvents
[a
].Command
+ '"');
5415 if (Length(P
) = 2) then
5417 for a
:= 0 to High(gEvents
) do
5418 if gEvents
[a
].Name
= P
[1] then
5419 if gEvents
[a
].Command
= '' then
5420 g_Console_Add(gEvents
[a
].Name
+ ' <none>')
5422 g_Console_Add(gEvents
[a
].Name
+ ' "' + gEvents
[a
].Command
+ '"');
5425 for a
:= 0 to High(gEvents
) do
5426 if gEvents
[a
].Name
= P
[1] then
5428 gEvents
[a
].Command
:= '';
5429 for b
:= 2 to High(P
) do
5430 if Pos(' ', P
[b
]) = 0 then
5431 gEvents
[a
].Command
:= gEvents
[a
].Command
+ ' ' + P
[b
]
5433 gEvents
[a
].Command
:= gEvents
[a
].Command
+ ' "' + P
[b
] + '"';
5434 gEvents
[a
].Command
:= Trim(gEvents
[a
].Command
);
5438 else if cmd
= 'suicide' then
5442 if g_Game_IsClient
then
5443 MC_SEND_CheatRequest(NET_CHEAT_SUICIDE
)
5446 if gPlayer1
<> nil then
5447 gPlayer1
.Damage(SUICIDE_DAMAGE
, gPlayer1
.UID
, 0, 0, HIT_SELF
);
5448 if gPlayer2
<> nil then
5449 gPlayer2
.Damage(SUICIDE_DAMAGE
, gPlayer2
.UID
, 0, 0, HIT_SELF
);
5453 else if cmd
= 'screenshot' then
5457 else if cmd
= 'weapon' then
5459 if Length(p
) = 2 then
5461 a
:= WP_FIRST
+ StrToInt(p
[1]) - 1;
5462 if (a
>= WP_FIRST
) and (a
<= WP_LAST
) then
5463 gSelectWeapon
[0, a
] := True
5466 else if (cmd
= 'p1_weapon') or (cmd
= 'p2_weapon') then
5468 if Length(p
) = 2 then
5470 a
:= WP_FIRST
+ StrToInt(p
[1]) - 1;
5471 b
:= ord(cmd
[2]) - ord('1');
5472 if (a
>= WP_FIRST
) and (a
<= WP_LAST
) then
5473 gSelectWeapon
[b
, a
] := True
5476 // Команды Своей игры:
5477 else if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
5479 if cmd
= 'bot_addred' then
5481 if Length(P
) > 1 then
5482 g_Bot_Add(TEAM_RED
, StrToIntDef(P
[1], 2))
5484 g_Bot_Add(TEAM_RED
, 2);
5486 else if cmd
= 'bot_addblue' then
5488 if Length(P
) > 1 then
5489 g_Bot_Add(TEAM_BLUE
, StrToIntDef(P
[1], 2))
5491 g_Bot_Add(TEAM_BLUE
, 2);
5493 else if cmd
= 'spectate' then
5499 else if cmd
= 'say' then
5501 if g_Game_IsServer
and g_Game_IsNet
then
5503 if Length(P
) > 1 then
5506 for a
:= 1 to High(P
) do
5507 chstr
:= chstr
+ P
[a
] + ' ';
5509 if Length(chstr
) > 200 then SetLength(chstr
, 200);
5511 if Length(chstr
) < 1 then
5513 g_Console_Add('say <text>');
5517 chstr
:= b_Text_Format(chstr
);
5518 MH_SEND_Chat(chstr
, NET_CHAT_PLAYER
);
5520 else g_Console_Add('say <text>');
5522 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
5524 else if cmd
= 'tell' then
5526 if g_Game_IsServer
and g_Game_IsNet
then
5528 if (Length(P
) > 2) and (P
[1] <> '') then
5531 for a
:= 2 to High(P
) do
5532 chstr
:= chstr
+ P
[a
] + ' ';
5534 if Length(chstr
) > 200 then SetLength(chstr
, 200);
5536 if Length(chstr
) < 1 then
5538 g_Console_Add('tell <playername> <text>');
5542 pl
:= g_Net_Client_ByName(P
[1]);
5544 MH_SEND_Chat(b_Text_Format(chstr
), NET_CHAT_PLAYER
, pl
^.ID
)
5546 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
5548 else g_Console_Add('tell <playername> <text>');
5550 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
5552 else if cmd
= 'centerprint' then
5554 if (Length(P
) > 2) and (P
[1] <> '') then
5557 for a
:= 2 to High(P
) do
5558 chstr
:= chstr
+ P
[a
] + ' ';
5560 if Length(chstr
) > 200 then SetLength(chstr
, 200);
5562 if Length(chstr
) < 1 then
5564 g_Console_Add('centerprint <timeout> <text>');
5568 a
:= StrToIntDef(P
[1], 100);
5569 chstr
:= b_Text_Format(chstr
);
5570 g_Game_Message(chstr
, a
);
5571 if g_Game_IsNet
and g_Game_IsServer
then
5572 MH_SEND_GameEvent(NET_EV_BIGTEXT
, a
, chstr
);
5574 else g_Console_Add('centerprint <timeout> <text>');
5576 else if (cmd
= 'overtime') and not g_Game_IsClient
then
5578 if (Length(P
) = 1) or (StrToIntDef(P
[1], -1) <= 0) then
5580 // Дополнительное время:
5581 gGameSettings
.TimeLimit
:= (gTime
- gGameStartTime
) div 1000 + Word(StrToIntDef(P
[1], 0));
5583 g_Console_Add(Format(_lc
[I_MSG_TIME_LIMIT
],
5584 [gGameSettings
.TimeLimit
div 3600,
5585 (gGameSettings
.TimeLimit
div 60) mod 60,
5586 gGameSettings
.TimeLimit
mod 60]));
5587 if g_Game_IsNet
then MH_SEND_GameSettings
;
5589 else if (cmd
= 'rcon_password') and g_Game_IsClient
then
5591 if (Length(P
) <= 1) then
5592 g_Console_Add('rcon_password <password>')
5594 MC_SEND_RCONPassword(P
[1]);
5596 else if cmd
= 'rcon' then
5598 if g_Game_IsClient
then
5600 if Length(P
) > 1 then
5603 for a
:= 1 to High(P
) do
5604 chstr
:= chstr
+ P
[a
] + ' ';
5606 if Length(chstr
) > 200 then SetLength(chstr
, 200);
5608 if Length(chstr
) < 1 then
5610 g_Console_Add('rcon <command>');
5614 MC_SEND_RCONCommand(chstr
);
5616 else g_Console_Add('rcon <command>');
5619 else if cmd
= 'ready' then
5621 if g_Game_IsServer
and (gLMSRespawn
= LMS_RESPAWN_WARMUP
) then
5622 gLMSRespawnTime
:= gTime
+ 100;
5624 else if (cmd
= 'callvote') and g_Game_IsNet
then
5626 if Length(P
) > 1 then
5629 for a
:= 1 to High(P
) do begin
5630 if a
> 1 then chstr
:= chstr
+ ' ';
5631 chstr
:= chstr
+ P
[a
];
5634 if Length(chstr
) > 200 then SetLength(chstr
, 200);
5636 if Length(chstr
) < 1 then
5638 g_Console_Add('callvote <command>');
5642 if g_Game_IsClient
then
5643 MC_SEND_Vote(True, chstr
)
5645 g_Game_StartVote(chstr
, gPlayer1Settings
.Name
);
5646 g_Console_Process('vote', True);
5649 g_Console_Add('callvote <command>');
5651 else if (cmd
= 'vote') and g_Game_IsNet
then
5653 if g_Game_IsClient
then
5655 else if gVoteInProgress
then
5657 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
5658 a
:= Floor((NetClientCount
+1)/2.0) + 1
5660 a
:= Floor(NetClientCount
/2.0) + 1;
5665 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_REVOKED
], [gPlayer1Settings
.Name
, gVoteCount
, a
]), True);
5666 MH_SEND_VoteEvent(NET_VE_REVOKE
, gPlayer1Settings
.Name
, 'a', gVoteCount
, a
);
5672 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_VOTE
], [gPlayer1Settings
.Name
, gVoteCount
, a
]), True);
5673 MH_SEND_VoteEvent(NET_VE_VOTE
, gPlayer1Settings
.Name
, 'a', gVoteCount
, a
);
5681 procedure SystemCommands(P
: SSArray
);
5685 cmd
:= LowerCase(P
[0]);
5696 if Length(p
) = 2 then
5698 gMaxFPS
:= StrToIntDef(p
[1], gMaxFPS
);
5700 gFrameTime
:= 1000 div gMaxFPS
5704 e_LogWritefln('r_maxfps %d', [gMaxFPS
]);
5708 if Length(p
) = 2 then
5710 gAskLanguage
:= true;
5711 gLanguage
:= LANGUAGE_ENGLISH
;
5712 case LowerCase(p
[1]) of
5715 gAskLanguage
:= false;
5716 gLanguage
:= LANGUAGE_ENGLISH
;
5720 gAskLanguage
:= false;
5721 gLanguage
:= LANGUAGE_RUSSIAN
;
5725 gAskLanguage
:= true;
5726 gLanguage
:= LANGUAGE_ENGLISH
;
5729 g_Language_Set(gLanguage
);
5733 e_LogWritefln('usage: %s <English|Russian|Ask>', [cmd
]);
5739 procedure g_TakeScreenShot(Filename
: string = '');
5740 var t
: TDateTime
; dir
, date
, name
: String;
5742 if e_NoGraphics
then
5745 dir
:= e_GetWriteableDir(ScreenshotDirs
);
5746 if Filename
= '' then
5749 DateTimeToString(date
, 'yyyy-mm-dd-hh-nn-ss', t
);
5750 Filename
:= 'screenshot-' + date
;
5753 name
:= e_CatPath(dir
, Filename
+ '.png');
5754 if r_Render_WriteScreenShot(name
) then
5755 g_Console_Add(Format(_lc
[I_CONSOLE_SCREENSHOT
], [name
]))
5757 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_WRITE
], [name
]));
5760 procedure g_Game_InGameMenu(Show
: Boolean);
5762 if (g_ActiveWindow
= nil) and Show
then
5764 if gGameSettings
.GameType
= GT_SINGLE
then
5765 g_GUI_ShowWindow('GameSingleMenu')
5768 if g_Game_IsClient
then
5769 g_GUI_ShowWindow('GameClientMenu')
5771 if g_Game_IsNet
then
5772 g_GUI_ShowWindow('GameServerMenu')
5774 g_GUI_ShowWindow('GameCustomMenu');
5776 g_Sound_PlayEx('MENU_OPEN');
5778 // Пауза при меню только в одиночной игре:
5779 if (not g_Game_IsNet
) then
5783 if (g_ActiveWindow
<> nil) and (not Show
) then
5785 // Пауза при меню только в одиночной игре:
5786 if (not g_Game_IsNet
) then
5787 g_Game_Pause(False);
5791 procedure g_Game_Pause (Enable
: Boolean);
5795 if not gGameOn
then exit
;
5797 if not (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
]) then exit
;
5800 gPauseMain
:= Enable
;
5802 if (gPause
<> oldPause
) then g_Game_PauseAllSounds(gPause
);
5805 procedure g_Game_HolmesPause (Enable
: Boolean);
5809 if not gGameOn
then exit
;
5810 if not (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
]) then exit
;
5813 gPauseHolmes
:= Enable
;
5815 if (gPause
<> oldPause
) then g_Game_PauseAllSounds(gPause
);
5818 procedure g_Game_PauseAllSounds(Enable
: Boolean);
5823 if gTriggers
<> nil then
5824 for i
:= 0 to High(gTriggers
) do
5825 with gTriggers
[i
] do
5826 if (TriggerType
= TRIGGER_SOUND
) and
5828 Sound
.IsPlaying() then
5830 Sound
.Pause(Enable
);
5834 if gPlayers
<> nil then
5835 for i
:= 0 to High(gPlayers
) do
5836 if gPlayers
[i
] <> nil then
5837 gPlayers
[i
].PauseSounds(Enable
);
5840 if gMusic
<> nil then
5841 gMusic
.Pause(Enable
);
5844 procedure g_Game_StopAllSounds(all
: Boolean);
5848 if gTriggers
<> nil then
5849 for i
:= 0 to High(gTriggers
) do
5850 with gTriggers
[i
] do
5851 if (TriggerType
= TRIGGER_SOUND
) and
5855 if gMusic
<> nil then
5862 procedure g_Game_UpdateTriggerSounds
;
5865 if gTriggers
<> nil then
5866 for i
:= 0 to High(gTriggers
) do
5867 with gTriggers
[i
] do
5868 if (TriggerType
= TRIGGER_SOUND
) and (Sound
<> nil) and tgcLocal
and Sound
.IsPlaying() then
5869 Sound
.SetCoordsRect(X
, Y
, Width
, Height
, tgcVolume
/ 255.0)
5872 function g_Game_IsWatchedPlayer(UID
: Word): Boolean;
5875 if (gPlayer1
<> nil) and (gPlayer1
.UID
= UID
) then
5880 if (gPlayer2
<> nil) and (gPlayer2
.UID
= UID
) then
5885 if gSpectMode
<> SPECT_PLAYERS
then
5887 if gSpectPID1
= UID
then
5892 if gSpectViewTwo
and (gSpectPID2
= UID
) then
5899 function g_Game_IsWatchedTeam(Team
: Byte): Boolean;
5904 if (gPlayer1
<> nil) and (gPlayer1
.Team
= Team
) then
5909 if (gPlayer2
<> nil) and (gPlayer2
.Team
= Team
) then
5914 if gSpectMode
<> SPECT_PLAYERS
then
5916 Pl
:= g_Player_Get(gSpectPID1
);
5917 if (Pl
<> nil) and (Pl
.Team
= Team
) then
5922 if gSpectViewTwo
then
5924 Pl
:= g_Player_Get(gSpectPID2
);
5925 if (Pl
<> nil) and (Pl
.Team
= Team
) then
5933 procedure g_Game_Message(Msg
: string; Time
: Word);
5935 MessageLineLength
:= (gScreenWidth
- 204) div e_CharFont_GetMaxWidth(gMenuFont
);
5936 MessageText
:= b_Text_Wrap(b_Text_Format(Msg
), MessageLineLength
);
5937 MessageTime
:= Time
;
5940 procedure g_Game_ChatSound(Text: String; Taunt
: Boolean = True);
5942 punct
: Array[0..13] of String =
5943 ('.', ',', ':', ';', '!', '?', '(', ')', '''', '"', '/', '\', '*', '^');
5949 function IsPunctuation(S
: String): Boolean;
5954 if Length(S
) <> 1 then
5956 for i
:= Low(punct
) to High(punct
) do
5957 if S
= punct
[i
] then
5963 function FilterPunctuation(S
: String): String;
5967 for i
:= Low(punct
) to High(punct
) do
5968 S
:= StringReplace(S
, punct
[i
], ' ', [rfReplaceAll
]);
5974 if gUseChatSounds
and Taunt
and (gChatSounds
<> nil) and (Pos(': ', Text) > 0) then
5976 // remove player name
5977 Delete(Text, 1, Pos(': ', Text) + 2 - 1);
5978 // for FullWord check
5979 Text := toLowerCase1251(' ' + Text + ' ');
5980 fpText
:= FilterPunctuation(Text);
5982 for i
:= 0 to Length(gChatSounds
) - 1 do
5985 for j
:= 0 to Length(gChatSounds
[i
].Tags
) - 1 do
5987 if gChatSounds
[i
].FullWord
and (not IsPunctuation(gChatSounds
[i
].Tags
[j
])) then
5988 ok
:= Pos(' ' + gChatSounds
[i
].Tags
[j
] + ' ', fpText
) > 0
5990 ok
:= Pos(gChatSounds
[i
].Tags
[j
], Text) > 0;
5996 gChatSounds
[i
].Sound
.Play();
6002 g_Sound_PlayEx('SOUND_GAME_RADIO');
6005 procedure g_Game_Announce_GoodShot(SpawnerUID
: Word);
6014 if not g_Game_IsWatchedPlayer(SpawnerUID
) then
6018 if goodsnd
[a
].IsPlaying() then
6021 goodsnd
[Random(4)].Play();
6024 procedure g_Game_Announce_KillCombo(Param
: Integer);
6031 UID
:= Param
and $FFFF;
6036 Pl
:= g_Player_Get(UID
);
6045 g_Console_Add(Format(_lc
[I_PLAYER_KILL_2X
], [Name
]), True);
6049 g_Console_Add(Format(_lc
[I_PLAYER_KILL_3X
], [Name
]), True);
6053 g_Console_Add(Format(_lc
[I_PLAYER_KILL_4X
], [Name
]), True);
6057 g_Console_Add(Format(_lc
[I_PLAYER_KILL_MX
], [Name
]), True);
6065 if not g_Game_IsWatchedPlayer(UID
) then
6068 if (not g_Game_IsWatchedPlayer(UID
)) and (c
< 4) then
6072 if killsnd
[n
].IsPlaying() then
6077 procedure g_Game_Announce_BodyKill(SpawnerUID
: Word);
6085 if not g_Game_IsWatchedPlayer(SpawnerUID
) then
6089 if hahasnd
[a
].IsPlaying() then
6092 hahasnd
[Random(3)].Play();
6095 procedure g_Game_StartVote(Command
, Initiator
: string);
6099 if not gVotesEnabled
then Exit
;
6100 if gGameSettings
.GameType
<> GT_SERVER
then Exit
;
6101 if gVoteInProgress
or gVotePassed
then
6103 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_INPROGRESS
], [gVoteCommand
]), True);
6104 MH_SEND_VoteEvent(NET_VE_INPROGRESS
, gVoteCommand
);
6107 gVoteInProgress
:= True;
6108 gVotePassed
:= False;
6109 gVoteTimer
:= gTime
+ gVoteTimeout
* 1000;
6112 gVoteCommand
:= Command
;
6114 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
6115 Need
:= Floor((NetClientCount
+1)/2.0)+1
6117 Need
:= Floor(NetClientCount
/2.0)+1;
6118 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_STARTED
], [Initiator
, Command
, Need
]), True);
6119 MH_SEND_VoteEvent(NET_VE_STARTED
, Initiator
, Command
, Need
);
6122 procedure g_Game_CheckVote
;
6126 if gGameSettings
.GameType
<> GT_SERVER
then Exit
;
6127 if not gVoteInProgress
then Exit
;
6129 if (gTime
>= gVoteTimer
) then
6131 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
6132 Need
:= Floor((NetClientCount
+1)/2.0) + 1
6134 Need
:= Floor(NetClientCount
/2.0) + 1;
6135 if gVoteCount
>= Need
then
6137 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_PASSED
], [gVoteCommand
]), True);
6138 MH_SEND_VoteEvent(NET_VE_PASSED
, gVoteCommand
);
6139 gVotePassed
:= True;
6140 gVoteCmdTimer
:= gTime
+ 5000;
6144 g_Console_Add(_lc
[I_MESSAGE_VOTE_FAILED
], True);
6145 MH_SEND_VoteEvent(NET_VE_FAILED
);
6147 if NetClients
<> nil then
6148 for I
:= Low(NetClients
) to High(NetClients
) do
6149 if NetClients
[i
].Used
then
6150 NetClients
[i
].Voted
:= False;
6151 gVoteInProgress
:= False;
6157 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
6158 Need
:= Floor((NetClientCount
+1)/2.0) + 1
6160 Need
:= Floor(NetClientCount
/2.0) + 1;
6161 if gVoteCount
>= Need
then
6163 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_PASSED
], [gVoteCommand
]), True);
6164 MH_SEND_VoteEvent(NET_VE_PASSED
, gVoteCommand
);
6165 gVoteInProgress
:= False;
6166 gVotePassed
:= True;
6167 gVoteCmdTimer
:= gTime
+ 5000;
6170 if NetClients
<> nil then
6171 for I
:= Low(NetClients
) to High(NetClients
) do
6172 if NetClients
[i
].Used
then
6173 NetClients
[i
].Voted
:= False;
6178 procedure g_Game_LoadMapList(FileName
: string);
6186 if not FileExists(FileName
) then Exit
;
6188 AssignFile(ListFile
, FileName
);
6190 while not EOF(ListFile
) do
6192 ReadLn(ListFile
, s
);
6195 if s
= '' then Continue
;
6197 SetLength(MapList
, Length(MapList
)+1);
6198 MapList
[High(MapList
)] := s
;
6200 CloseFile(ListFile
);
6203 procedure g_Game_SetDebugMode();
6206 // Читы (даже в своей игре):
6210 procedure g_Game_SetLoadingText(Text: String; Max
: Integer; reWrite
: Boolean);
6214 if Length(LoadingStat
.Msgs
) = 0 then
6220 begin // Переходим на следующую строку или скроллируем:
6221 if NextMsg
= Length(Msgs
) then
6223 for i
:= 0 to High(Msgs
)-1 do
6224 Msgs
[i
] := Msgs
[i
+1];
6232 Msgs
[NextMsg
-1] := Text;
6236 PBarWasHere
:= false;
6239 g_ActiveWindow
:= nil;
6241 ProcessLoading(true);
6244 procedure g_Game_StepLoading(Value
: Integer = -1);
6255 if (ShowCount
> LOADING_SHOW_STEP
) or (Value
> -1) then
6263 procedure g_Game_ClearLoading();
6272 len
:= ((gScreenHeight
div 3)*2 - 50) div LOADING_INTERLINE
;
6273 if len
< 1 then len
:= 1;
6274 SetLength(Msgs
, len
);
6275 for len
:= Low(Msgs
) to High(Msgs
) do
6278 PBarWasHere
:= false;
6282 procedure Parse_Params(var pars
: TParamStrValues
);
6289 while i
<= ParamCount
do
6292 if (s
[1] = '-') and (Length(s
) > 1) then
6294 if (s
[2] = '-') and (Length(s
) > 2) then
6295 begin // Одиночный параметр
6296 SetLength(pars
, Length(pars
) + 1);
6297 with pars
[High(pars
)] do
6299 Name
:= LowerCase(s
);
6304 if (i
< ParamCount
) then
6305 begin // Параметр со значением
6307 SetLength(pars
, Length(pars
) + 1);
6308 with pars
[High(pars
)] do
6310 Name
:= LowerCase(s
);
6311 Value
:= LowerCase(ParamStr(i
));
6320 function Find_Param_Value(var pars
: TParamStrValues
; aName
: String): String;
6325 for i
:= 0 to High(pars
) do
6326 if pars
[i
].Name
= aName
then
6328 Result
:= pars
[i
].Value
;
6333 procedure g_Game_Process_Params();
6335 pars
: TParamStrValues
;
6338 LimT
, LimS
: Integer;
6349 s
:= Find_Param_Value(pars
, '--debug');
6352 g_Game_SetDebugMode();
6353 s
:= Find_Param_Value(pars
, '--netdump');
6358 // Connect when game loads
6359 ip
:= Find_Param_Value(pars
, '-connect');
6363 s
:= Find_Param_Value(pars
, '-port');
6364 if (s
= '') or not TryStrToInt(s
, Port
) then
6367 s
:= Find_Param_Value(pars
, '-pw');
6369 g_Game_StartClient(ip
, Port
, s
);
6373 s
:= LowerCase(Find_Param_Value(pars
, '-dbg-mainwad'));
6376 gDefaultMegawadStart
:= s
;
6379 if (Find_Param_Value(pars
, '--dbg-mainwad-restore') <> '') or
6380 (Find_Param_Value(pars
, '--dbg-mainwad-default') <> '') then
6382 gDefaultMegawadStart
:= DF_Default_Megawad_Start
;
6385 // Start map when game loads:
6386 map
:= LowerCase(Find_Param_Value(pars
, '-map'));
6387 if isWadPath(map
) then
6390 s
:= Find_Param_Value(pars
, '-gm');
6391 GMode
:= g_Game_TextToMode(s
);
6392 if GMode
= GM_NONE
then GMode
:= GM_DM
;
6393 if GMode
= GM_SINGLE
then GMode
:= GM_COOP
;
6396 s
:= Find_Param_Value(pars
, '-limt');
6397 if (s
= '') or (not TryStrToInt(s
, LimT
)) then
6403 s
:= Find_Param_Value(pars
, '-lims');
6404 if (s
= '') or (not TryStrToInt(s
, LimS
)) then
6410 s
:= Find_Param_Value(pars
, '-lives');
6411 if (s
= '') or (not TryStrToInt(s
, Lives
)) then
6417 s
:= Find_Param_Value(pars
, '-opt');
6421 Opt
:= StrToIntDef(s
, 0);
6424 s
:= Find_Param_Value(pars
, '--close');
6428 // Override map to test:
6429 s
:= LowerCase(Find_Param_Value(pars
, '-testmap'));
6432 if e_IsValidResourceName(s
) then
6433 e_FindResource(AllMapDirs
, s
);
6434 gTestMap
:= ExpandFileName(s
);
6437 // Delete test map after play:
6438 s
:= Find_Param_Value(pars
, '--testdelete');
6441 //gMapToDelete := MapsDir + map;
6442 e_WriteLog('"--testdelete" is deprecated, use --tempdelete.', TMsgType
.Fatal
);
6446 // Delete temporary WAD after play:
6447 s
:= Find_Param_Value(pars
, '--tempdelete');
6448 if (s
<> '') and (gTestMap
<> '') then
6450 gMapToDelete
:= gTestMap
;
6451 gTempDelete
:= True;
6454 // Number of players:
6455 s
:= Find_Param_Value(pars
, '-pl');
6457 n
:= DEFAULT_PLAYERS
6459 n
:= StrToIntDef(s
, DEFAULT_PLAYERS
);
6462 s
:= Find_Param_Value(pars
, '-port');
6463 if (s
= '') or not TryStrToInt(s
, Port
) then
6464 g_Game_StartCustom(map
, GMode
, LimT
, LimS
, Lives
, Opt
, n
)
6466 g_Game_StartServer(map
, GMode
, LimT
, LimS
, Lives
, Opt
, n
, 0, Port
);
6469 // Execute script when game loads:
6470 s
:= Find_Param_Value(pars
, '-exec');
6473 // if not isWadPath(s) then
6474 // s := GameDir + '/' + s;
6479 if IOResult
<> 0 then
6481 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], ['Failed to read file: ' + s
]), TMsgType
.Warning
);
6482 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_READ
], [s
]));
6486 e_WriteLog('Executing script: ' + s
, TMsgType
.Notify
);
6487 g_Console_Add(Format(_lc
[I_CONSOLE_EXEC
], [s
]));
6492 if IOResult
<> 0 then
6494 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], ['Failed to read file: ' + s
]), TMsgType
.Warning
);
6495 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_READ
], [s
]));
6499 if Pos('#', s
) <> 1 then // script comment
6500 g_Console_Process(s
, True);
6511 conRegVar('pf_draw_frame', @g_profile_frame_draw
, 'draw frame rendering profiles', 'render profiles');
6512 //conRegVar('pf_update_frame', @g_profile_frame_update, 'draw frame updating profiles', 'update profiles');
6513 conRegVar('pf_coldet', @g_profile_collision
, 'draw collision detection profiles', 'coldet profiles');
6514 conRegVar('pf_los', @g_profile_los
, 'draw monster LOS profiles', 'monster LOS profiles');
6516 conRegVar('r_sq_draw', @gdbg_map_use_accel_render
, 'accelerated spatial queries in rendering', 'accelerated rendering');
6517 conRegVar('cd_sq_enabled', @gdbg_map_use_accel_coldet
, 'accelerated spatial queries in map coldet', 'accelerated map coldet');
6518 conRegVar('mon_sq_enabled', @gmon_debug_use_sqaccel
, 'accelerated spatial queries for monsters', 'accelerated monster coldet');
6519 conRegVar('wtrace_sq_enabled', @gwep_debug_fast_trace
, 'accelerated spatial queries for weapon hitscan trace', 'accelerated weapon hitscan');
6521 conRegVar('pr_enabled', @gpart_dbg_enabled
, 'enable/disable particles', 'particles');
6522 conRegVar('pr_phys_enabled', @gpart_dbg_phys_enabled
, 'enable/disable particle physics', 'particle physics');
6524 conRegVar('los_enabled', @gmon_dbg_los_enabled
, 'enable/disable monster LOS calculations', 'monster LOS', true);
6525 conRegVar('mon_think', @gmon_debug_think
, 'enable/disable monster thinking', 'monster thinking', true);
6527 {$IFDEF ENABLE_HOLMES}
6528 conRegVar('dbg_holmes', @g_holmes_enabled
, 'enable/disable Holmes', 'Holmes', true);
6531 conRegVar('dbg_ignore_level_bounds', @g_dbg_ignore_bounds
, 'ignore level bounds', '', false);
6533 conRegVar('light_enabled', @gwin_k8_enable_light_experiments
, 'enable/disable dynamic lighting', 'lighting');
6534 conRegVar('light_player_halo', @g_playerLight
, 'enable/disable player halo', 'player light halo');
6536 conRegVar('r_smallmap_align_h', @r_smallmap_h
, 'halign: 0: left; 1: center; 2: right', 'horizontal aligning of small maps');
6537 conRegVar('r_smallmap_align_v', @r_smallmap_v
, 'valign: 0: top; 1: center; 2: bottom', 'vertial aligning of small maps');
6539 conRegVar('r_showfps', @gShowFPS
, 'draw fps counter', 'draw fps counter');
6540 conRegVar('r_showtime', @gShowTime
, 'show game time', 'show game time');
6541 conRegVar('r_showping', @gShowPing
, 'show ping', 'show ping');
6542 conRegVar('r_showscore', @gShowGoals
, 'show score', 'show score');
6543 conRegVar('r_showkillmsg', @gShowKillMsg
, 'show kill log', 'show kill log');
6544 conRegVar('r_showlives', @gShowLives
, 'show lives', 'show lives');
6545 conRegVar('r_showspect', @gSpectHUD
, 'show spectator hud', 'show spectator hud');
6546 conRegVar('r_showstat', @gShowStat
, 'show stats', 'show stats');
6547 conRegVar('r_showpids', @gShowPIDs
, 'show PIDs', 'show PIDs');