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_basic
, g_player
, e_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 procedure g_Game_SetupScreenSize();
90 procedure g_Game_ChangeResolution(newWidth
, newHeight
: Word; nowFull
, nowMax
: Boolean);
91 function g_Game_ModeToText(Mode
: Byte): string;
92 function g_Game_TextToMode(Mode
: string): Byte;
93 procedure g_Game_ExecuteEvent(Name
: String);
94 function g_Game_DelayEvent(DEType
: Byte; Time
: LongWord; Num
: Integer = 0; Str
: String = ''): Integer;
95 procedure g_Game_AddPlayer(Team
: Byte = TEAM_NONE
);
96 procedure g_Game_RemovePlayer();
97 procedure g_Game_Spectate();
98 procedure g_Game_SpectateCenterView();
99 procedure g_Game_StartSingle(Map
: String; TwoPlayers
: Boolean; nPlayers
: Byte);
100 procedure g_Game_StartCustom(Map
: String; GameMode
: Byte; TimeLimit
, GoalLimit
: Word; MaxLives
: Byte; Options
: LongWord; nPlayers
: Byte);
101 procedure g_Game_StartServer(Map
: String; GameMode
: Byte; TimeLimit
, GoalLimit
: Word; MaxLives
: Byte; Options
: LongWord; nPlayers
: Byte; IPAddr
: LongWord; Port
: Word);
102 procedure g_Game_StartClient(Addr
: String; Port
: Word; PW
: String);
103 procedure g_Game_Restart();
104 procedure g_Game_RestartLevel();
105 procedure g_Game_RestartRound(NoMapRestart
: Boolean = False);
106 function g_Game_ClientWAD (NewWAD
: String; const WHash
: TMD5Digest
): AnsiString;
107 function g_Game_StartMap(asMegawad
: Boolean; Map
: String; Force
: Boolean = False; const oldMapPath
: AnsiString=''): Boolean;
108 procedure g_Game_ChangeMap(const MapPath
: String);
109 procedure g_Game_ExitLevel(const Map
: AnsiString);
110 function g_Game_GetFirstMap(WAD
: String): String;
111 function g_Game_GetNextMap(): String;
112 procedure g_Game_NextLevel();
113 procedure g_Game_Pause(Enable
: Boolean);
114 procedure g_Game_HolmesPause(Enable
: Boolean);
115 procedure g_Game_InGameMenu(Show
: Boolean);
116 function g_Game_IsWatchedPlayer(UID
: Word): Boolean;
117 function g_Game_IsWatchedTeam(Team
: Byte): Boolean;
118 procedure g_Game_Message(Msg
: String; Time
: Word);
119 procedure g_Game_LoadMapList(FileName
: String);
120 procedure g_Game_PauseAllSounds(Enable
: Boolean);
121 procedure g_Game_StopAllSounds(all
: Boolean);
122 procedure g_Game_UpdateTriggerSounds();
123 function g_Game_GetMegaWADInfo(WAD
: String): TMegaWADInfo
;
124 procedure g_Game_ChatSound(Text: String; Taunt
: Boolean = True);
125 procedure g_Game_Announce_GoodShot(SpawnerUID
: Word);
126 procedure g_Game_Announce_KillCombo(Param
: Integer);
127 procedure g_Game_Announce_BodyKill(SpawnerUID
: Word);
128 procedure g_Game_StartVote(Command
, Initiator
: string);
129 procedure g_Game_CheckVote
;
130 procedure g_TakeScreenShot(Filename
: string = '');
131 procedure g_FatalError(Text: String);
132 procedure g_SimpleError(Text: String);
133 function g_Game_IsTestMap(): Boolean;
134 procedure g_Game_DeleteTestMap();
135 procedure GameCVars(P
: SSArray
);
136 procedure PlayerSettingsCVars(P
: SSArray
);
137 procedure SystemCommands(P
: SSArray
);
138 procedure GameCommands(P
: SSArray
);
139 procedure GameCheats(P
: SSArray
);
140 procedure DebugCommands(P
: SSArray
);
141 procedure g_Game_Process_Params
;
142 procedure g_Game_SetLoadingText(Text: String; Max
: Integer; reWrite
: Boolean);
143 procedure g_Game_StepLoading(Value
: Integer = -1);
144 procedure g_Game_ClearLoading();
145 procedure g_Game_SetDebugMode();
147 function IsActivePlayer(p
: TPlayer
): Boolean;
148 function GetActivePlayerID_Next(Skip
: Integer = -1): Integer;
149 procedure SortGameStat(var stat
: TPlayerStatArray
);
151 { procedure SetWinPause(Enable: Boolean); }
156 LOADING_SHOW_STEP
= 100;
157 LOADING_INTERLINE
= 20;
172 MESSAGE_DIKEY
= WM_USER
+ 1;
177 EXIT_ENDLEVELSINGLE
= 4;
178 EXIT_ENDLEVELCUSTOM
= 5;
180 GAME_OPTION_RESERVED
= 1;
181 GAME_OPTION_TEAMDAMAGE
= 2;
182 GAME_OPTION_ALLOWEXIT
= 4;
183 GAME_OPTION_WEAPONSTAY
= 8;
184 GAME_OPTION_MONSTERS
= 16;
185 GAME_OPTION_BOTVSPLAYER
= 32;
186 GAME_OPTION_BOTVSMONSTER
= 64;
187 GAME_OPTION_DMKEYS
= 128;
188 GAME_OPTION_TEAMHITTRACE
= 256;
189 GAME_OPTION_TEAMHITPROJECTILE
= 512;
190 GAME_OPTION_TEAMABSORBDAMAGE
= 1024;
195 STATE_INTERCUSTOM
= 3;
196 STATE_INTERSINGLE
= 4;
202 LMS_RESPAWN_NONE
= 0;
203 LMS_RESPAWN_WARMUP
= 1;
204 LMS_RESPAWN_FINAL
= 2;
221 CONFIG_FILENAME
= 'Doom2DF.cfg';
223 TEST_MAP_NAME
= '$$$_TEST_$$$';
225 STD_PLAYER_MODEL
= 'Doomer';
233 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;
376 procedure g_ResetDynlights ();
377 procedure g_AddDynLight (x
, y
, radius
: Integer; r
, g
, b
, a
: Single);
378 procedure g_DynLightExplosion (x
, y
, radius
: Integer; r
, g
, b
: Single);
380 function conIsCheatsEnabled (): Boolean; inline;
381 function gPause (): Boolean; inline;
383 type (* private state *)
384 TEndCustomGameStat
= record
385 PlayerStat
: TPlayerStatArray
;
389 Map
, MapName
: String;
392 TEndSingleGameStat
= record
393 PlayerStat
: Array [0..1] of record
399 TotalSecrets
: Integer;
402 TLoadingStat
= record
406 Msgs
: Array of String;
408 PBarWasHere
: Boolean; // did we draw a progress bar for this message?
412 x
, y
, radius
: Integer;
415 exploRadius
: Integer;
418 var (* private state *)
419 CustomStat
: TEndCustomGameStat
;
420 StatShotDone
: Boolean;
421 StatFilename
: string = ''; // used by stat screenshot to save with the same name as the csv
422 SingleStat
: TEndSingleGameStat
;
424 LoadingStat
: TLoadingStat
;
427 EndingGameCounter
: Byte;
429 g_playerLight
: Boolean;
430 g_dynLights
: array of TDynLight
= nil;
431 g_dynLightCount
: Integer = 0;
436 {$INCLUDE ../nogl/noGLuses.inc}
437 {$IFDEF ENABLE_HOLMES}
440 e_texture
, e_res
, g_textures
, g_window
, g_menu
,
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_main
, g_phys
,
445 ENet
, e_msg
, g_netmsg
, g_netmaster
,
446 sfs
, wadreader
, g_system
;
449 // ////////////////////////////////////////////////////////////////////////// //
450 function gPause (): Boolean; inline; begin result
:= gPauseMain
or gPauseHolmes
; end;
452 procedure g_ResetDynlights ();
456 if not gwin_has_stencil
then begin g_dynLightCount
:= 0; exit
; end;
458 for idx
:= 0 to g_dynLightCount
-1 do
460 if g_dynLights
[idx
].exploCount
= -666 then
467 Inc(g_dynLights
[idx
].exploCount
);
468 if (g_dynLights
[idx
].exploCount
< 10) then
470 g_dynLights
[idx
].radius
:= g_dynLights
[idx
].exploRadius
+g_dynLights
[idx
].exploCount
*8;
471 g_dynLights
[idx
].a
:= 0.4+g_dynLights
[idx
].exploCount
/10;
472 if (g_dynLights
[idx
].a
> 0.8) then g_dynLights
[idx
].a
:= 0.8;
473 if lnum
<> idx
then g_dynLights
[lnum
] := g_dynLights
[idx
];
478 g_dynLightCount
:= lnum
;
481 procedure g_AddDynLight (x
, y
, radius
: Integer; r
, g
, b
, a
: Single);
483 if not gwin_has_stencil
then exit
;
484 if g_dynLightCount
= length(g_dynLights
) then SetLength(g_dynLights
, g_dynLightCount
+1024);
485 g_dynLights
[g_dynLightCount
].x
:= x
;
486 g_dynLights
[g_dynLightCount
].y
:= y
;
487 g_dynLights
[g_dynLightCount
].radius
:= radius
;
488 g_dynLights
[g_dynLightCount
].r
:= r
;
489 g_dynLights
[g_dynLightCount
].g
:= g
;
490 g_dynLights
[g_dynLightCount
].b
:= b
;
491 g_dynLights
[g_dynLightCount
].a
:= a
;
492 g_dynLights
[g_dynLightCount
].exploCount
:= -666;
493 Inc(g_dynLightCount
);
496 procedure g_DynLightExplosion (x
, y
, radius
: Integer; r
, g
, b
: Single);
498 if not gwin_has_stencil
then exit
;
499 if g_dynLightCount
= length(g_dynLights
) then SetLength(g_dynLights
, g_dynLightCount
+1024);
500 g_dynLights
[g_dynLightCount
].x
:= x
;
501 g_dynLights
[g_dynLightCount
].y
:= y
;
502 g_dynLights
[g_dynLightCount
].radius
:= 0;
503 g_dynLights
[g_dynLightCount
].exploRadius
:= radius
;
504 g_dynLights
[g_dynLightCount
].r
:= r
;
505 g_dynLights
[g_dynLightCount
].g
:= g
;
506 g_dynLights
[g_dynLightCount
].b
:= b
;
507 g_dynLights
[g_dynLightCount
].a
:= 0;
508 g_dynLights
[g_dynLightCount
].exploCount
:= 0;
509 Inc(g_dynLightCount
);
512 // ////////////////////////////////////////////////////////////////////////// //
513 function conIsCheatsEnabled (): Boolean; inline;
516 if g_Game_IsNet
then exit
;
517 if not gDebugMode
then
519 //if not gCheats then exit;
520 if not (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
]) then exit
;
521 if not (gGameSettings
.GameMode
in [GM_COOP
, GM_SINGLE
]) then exit
;
526 // ////////////////////////////////////////////////////////////////////////// //
528 TParamStrValue
= record
533 TParamStrValues
= Array of TParamStrValue
;
536 INTER_ACTION_TEXT
= 1;
537 INTER_ACTION_PIC
= 2;
538 INTER_ACTION_MUSIC
= 3;
543 DataLoaded
: Boolean = False;
545 MessageLineLength
: Integer = 80;
546 MapList
: SSArray
= nil;
547 MapIndex
: Integer = -1;
548 InterReadyTime
: Integer = -1;
549 StatDate
: string = '';
555 text: Array of ShortString;
556 anim
: Array of ShortString;
557 pic
: Array of ShortString;
558 mus
: Array of ShortString;
560 triggers
: Array of record
562 actions
: Array of record
563 action
, p1
, p2
: Integer;
566 cur_trigger
: Integer;
579 function Compare(a
, b
: TPlayerStat
): Integer;
581 if a
.Spectator
then Result
:= 1
582 else if b
.Spectator
then Result
:= -1
583 else if a
.Frags
< b
.Frags
then Result
:= 1
584 else if a
.Frags
> b
.Frags
then Result
:= -1
585 else if a
.Deaths
< b
.Deaths
then Result
:= -1
586 else if a
.Deaths
> b
.Deaths
then Result
:= 1
587 else if a
.Kills
< b
.Kills
then Result
:= -1
591 procedure SortGameStat(var stat
: TPlayerStatArray
);
596 if stat
= nil then Exit
;
598 for I
:= High(stat
) downto Low(stat
) do
599 for J
:= Low(stat
) to High(stat
) - 1 do
600 if Compare(stat
[J
], stat
[J
+ 1]) = 1 then
603 stat
[J
] := stat
[J
+ 1];
608 // saves a shitty CSV containing the game stats passed to it
609 procedure SaveGameStat(Stat
: TEndCustomGameStat
; Path
: string);
612 dir
, fname
, map
, mode
, etime
: String;
616 dir
:= e_GetWriteableDir(StatsDirs
);
617 // stats are placed in stats/yy/mm/dd/*.csv
618 fname
:= e_CatPath(dir
, Path
);
619 ForceDirectories(fname
); // ensure yy/mm/dd exists within the stats dir
620 fname
:= e_CatPath(fname
, StatFilename
+ '.csv');
621 AssignFile(s
, fname
);
624 // line 1: stats ver, datetime, server name, map name, game mode, time limit, score limit, dmflags, game time, num players
625 if g_Game_IsNet
then fname
:= NetServerName
else fname
:= '';
626 map
:= g_ExtractWadNameNoPath(gMapInfo
.Map
) + ':/' + g_ExtractFileName(gMapInfo
.Map
);
627 mode
:= g_Game_ModeToText(Stat
.GameMode
);
628 etime
:= Format('%d:%.2d:%.2d', [
629 Stat
.GameTime
div 1000 div 3600,
630 (Stat
.GameTime
div 1000 div 60) mod 60,
631 Stat
.GameTime
div 1000 mod 60
633 WriteLn(s
, 'stats_ver,datetime,server,map,mode,timelimit,scorelimit,dmflags,time,num_players');
634 WriteLn(s
, Format('%d,%s,%s,%s,%s,%u,%u,%u,%s,%d', [
640 gGameSettings
.TimeLimit
,
641 gGameSettings
.GoalLimit
,
642 gGameSettings
.Options
,
644 Length(Stat
.PlayerStat
)
646 // line 2: game specific shit
647 // if it's a team game: red score, blue score
648 // if it's a coop game: monsters killed, monsters total, secrets found, secrets total
650 if Stat
.GameMode
in [GM_TDM
, GM_CTF
] then
652 Format('red_score,blue_score' + LineEnding
+ '%d,%d', [Stat
.TeamStat
[TEAM_RED
].Goals
, Stat
.TeamStat
[TEAM_BLUE
].Goals
]))
653 else if Stat
.GameMode
in [GM_COOP
, GM_SINGLE
] then
655 Format('mon_killed,mon_total,secrets_found,secrets_total' + LineEnding
+ '%d,%d,%d,%d',[gCoopMonstersKilled
, gTotalMonsters
, gCoopSecretsFound
, gSecretsCount
]));
656 // lines 3-...: team, player name, frags, deaths
657 WriteLn(s
, 'team,name,frags,deaths');
658 for I
:= Low(Stat
.PlayerStat
) to High(Stat
.PlayerStat
) do
659 with Stat
.PlayerStat
[I
] do
660 WriteLn(s
, Format('%d,%s,%d,%d', [Team
, dquoteStr(Name
), Frags
, Deaths
]));
662 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_WRITE
], [fname
]));
665 g_Console_Add('could not create gamestats file "' + fname
+ '"');
670 function g_Game_ModeToText(Mode
: Byte): string;
674 GM_DM
: Result
:= _lc
[I_MENU_GAME_TYPE_DM
];
675 GM_TDM
: Result
:= _lc
[I_MENU_GAME_TYPE_TDM
];
676 GM_CTF
: Result
:= _lc
[I_MENU_GAME_TYPE_CTF
];
677 GM_COOP
: Result
:= _lc
[I_MENU_GAME_TYPE_COOP
];
678 GM_SINGLE
: Result
:= _lc
[I_MENU_GAME_TYPE_SINGLE
];
682 function g_Game_TextToMode(Mode
: string): Byte;
685 Mode
:= UpperCase(Mode
);
686 if Mode
= _lc
[I_MENU_GAME_TYPE_DM
] then
691 if Mode
= _lc
[I_MENU_GAME_TYPE_TDM
] then
696 if Mode
= _lc
[I_MENU_GAME_TYPE_CTF
] then
701 if Mode
= _lc
[I_MENU_GAME_TYPE_COOP
] then
706 if Mode
= _lc
[I_MENU_GAME_TYPE_SINGLE
] then
713 function g_Game_IsNet(): Boolean;
715 Result
:= (gGameSettings
.GameType
in [GT_SERVER
, GT_CLIENT
]);
718 function g_Game_IsServer(): Boolean;
720 Result
:= (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
, GT_SERVER
]);
723 function g_Game_IsClient(): Boolean;
725 Result
:= (gGameSettings
.GameType
= GT_CLIENT
);
728 function g_Game_GetMegaWADInfo(WAD
: String): TMegaWADInfo
;
735 Result
.name
:= ExtractFileName(WAD
);
736 Result
.description
:= '';
739 w
:= TWADFile
.Create();
742 if not w
.GetResource('INTERSCRIPT', p
, len
) then
748 cfg
:= TConfig
.CreateMem(p
, len
);
749 Result
.name
:= cfg
.ReadStr('megawad', 'name', ExtractFileName(WAD
));
750 Result
.description
:= cfg
.ReadStr('megawad', 'description', '');
751 Result
.author
:= cfg
.ReadStr('megawad', 'author', '');
752 Result
.pic
:= cfg
.ReadStr('megawad', 'pic', '');
758 procedure g_Game_FreeWAD();
762 for a
:= 0 to High(MegaWAD
.res
.pic
) do
763 if MegaWAD
.res
.pic
[a
] <> '' then
764 g_Texture_Delete(MegaWAD
.res
.pic
[a
]);
766 for a
:= 0 to High(MegaWAD
.res
.mus
) do
767 if MegaWAD
.res
.mus
[a
] <> '' then
768 g_Sound_Delete(MegaWAD
.res
.mus
[a
]);
770 MegaWAD
.res
.pic
:= nil;
771 MegaWAD
.res
.text := nil;
772 MegaWAD
.res
.anim
:= nil;
773 MegaWAD
.res
.mus
:= nil;
774 MegaWAD
.triggers
:= nil;
776 g_Texture_Delete('TEXTURE_endpic');
777 g_Sound_Delete('MUSIC_endmus');
779 ZeroMemory(@MegaWAD
, SizeOf(MegaWAD
));
780 gGameSettings
.WAD
:= '';
783 procedure g_Game_LoadWAD(WAD
: string);
792 gGameSettings
.WAD
:= WAD
;
793 if not (gGameSettings
.GameMode
in [GM_COOP
, GM_SINGLE
]) then
796 MegaWAD
.info
:= g_Game_GetMegaWADInfo(WAD
);
798 w
:= TWADFile
.Create();
801 if not w
.GetResource('INTERSCRIPT', p
, len
) then
807 cfg
:= TConfig
.CreateMem(p
, len
);
812 s := cfg.ReadStr('pic', 'pic'+IntToStr(b), '');
813 if s = '' then Break;
816 SetLength(MegaWAD.res.pic, Length(MegaWAD.res.pic)+1);
817 MegaWAD.res.pic[High(MegaWAD.res.pic)] := s;
819 g_Texture_CreateWADEx(s, s);
825 s := cfg.ReadStr('mus', 'mus'+IntToStr(b), '');
826 if s = '' then Break;
829 SetLength(MegaWAD.res.mus, Length(MegaWAD.res.mus)+1);
830 MegaWAD.res.mus[High(MegaWAD.res.mus)] := s;
832 g_Music_CreateWADEx(s, s);
835 MegaWAD
.endpic
:= cfg
.ReadStr('megawad', 'endpic', '');
836 if MegaWAD
.endpic
<> '' then
838 TEXTUREFILTER
:= GL_LINEAR
;
839 s
:= e_GetResourcePath(WadDirs
, MegaWAD
.endpic
, WAD
);
840 g_Texture_CreateWADEx('TEXTURE_endpic', s
);
841 TEXTUREFILTER
:= GL_NEAREST
;
843 MegaWAD
.endmus
:= cfg
.ReadStr('megawad', 'endmus', 'Standart.wad:D2DMUS\КОНЕЦ');
844 if MegaWAD
.endmus
<> '' then
846 s
:= e_GetResourcePath(WadDirs
, MegaWAD
.endmus
, WAD
);
847 g_Sound_CreateWADEx('MUSIC_endmus', s
, True);
855 {procedure start_trigger(t: string);
859 function next_trigger(): Boolean;
863 procedure DisableCheats();
869 if gPlayer1
<> nil then gPlayer1
.GodMode
:= False;
870 if gPlayer2
<> nil then gPlayer2
.GodMode
:= False;
871 if gPlayer1
<> nil then gPlayer1
.NoTarget
:= False;
872 if gPlayer2
<> nil then gPlayer2
.NoTarget
:= False;
874 {$IF DEFINED(D2F_DEBUG)}
875 if gPlayer1
<> nil then gPlayer1
.NoTarget
:= True;
876 gAimLine
:= g_dbg_aimline_on
;
880 procedure g_Game_ExecuteEvent(Name
: String);
886 if gEvents
= nil then
888 for a
:= 0 to High(gEvents
) do
889 if gEvents
[a
].Name
= Name
then
891 if gEvents
[a
].Command
<> '' then
892 g_Console_Process(gEvents
[a
].Command
, True);
897 function g_Game_DelayEvent(DEType
: Byte; Time
: LongWord; Num
: Integer = 0; Str
: String = ''): Integer;
902 if gDelayedEvents
<> nil then
903 for a
:= 0 to High(gDelayedEvents
) do
904 if not gDelayedEvents
[a
].Pending
then
911 SetLength(gDelayedEvents
, Length(gDelayedEvents
) + 1);
912 n
:= High(gDelayedEvents
);
914 gDelayedEvents
[n
].Pending
:= True;
915 gDelayedEvents
[n
].DEType
:= DEType
;
916 gDelayedEvents
[n
].DENum
:= Num
;
917 gDelayedEvents
[n
].DEStr
:= Str
;
918 if DEType
= DE_GLOBEVENT
then
919 gDelayedEvents
[n
].Time
:= (sys_GetTicks() {div 1000}) + Time
921 gDelayedEvents
[n
].Time
:= gTime
+ Time
;
931 if g_Game_IsNet
and g_Game_IsServer
then
932 MH_SEND_GameEvent(NET_EV_MAPEND
, Byte(gMissionFailed
));
936 gPauseHolmes
:= false;
939 g_Game_StopAllSounds(False);
944 EndingGameCounter
:= 0;
945 g_ActiveWindow
:= nil;
947 gLMSRespawn
:= LMS_RESPAWN_NONE
;
948 gLMSRespawnTime
:= 0;
951 EXIT_SIMPLE
: // Выход через меню или конец теста
956 begin // Это был тест
960 begin // Выход в главное меню
961 gMusic
.SetByName('MUSIC_MENU');
963 if gState
<> STATE_SLIST
then
965 g_GUI_ShowWindow('MainMenu');
966 gState
:= STATE_MENU
;
969 // Обновляем список серверов
970 slReturnPressed
:= True;
971 if g_Net_Slist_Fetch(slCurrent
) then
973 if slCurrent
= nil then
974 slWaitStr
:= _lc
[I_NET_SLIST_NOSERVERS
];
977 slWaitStr
:= _lc
[I_NET_SLIST_ERROR
];
978 g_Serverlist_GenerateTable(slCurrent
, slTable
);
981 g_Game_ExecuteEvent('ongameend');
985 EXIT_RESTART
: // Начать уровень сначала
987 if not g_Game_IsClient
then g_Game_Restart();
990 EXIT_ENDLEVELCUSTOM
: // Закончился уровень в Своей игре
992 // Статистика Своей игры:
993 FileName
:= g_ExtractWadName(gMapInfo
.Map
);
995 CustomStat
.GameTime
:= gTime
;
996 CustomStat
.Map
:= ExtractFileName(FileName
)+':'+g_ExtractFileName(gMapInfo
.Map
); //ResName;
997 CustomStat
.MapName
:= gMapInfo
.Name
;
998 CustomStat
.GameMode
:= gGameSettings
.GameMode
;
999 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
1000 CustomStat
.TeamStat
:= gTeamStat
;
1002 CustomStat
.PlayerStat
:= nil;
1004 // Статистика игроков:
1005 if gPlayers
<> nil then
1007 for a
:= 0 to High(gPlayers
) do
1008 if gPlayers
[a
] <> nil then
1010 SetLength(CustomStat
.PlayerStat
, Length(CustomStat
.PlayerStat
)+1);
1011 with CustomStat
.PlayerStat
[High(CustomStat
.PlayerStat
)] do
1014 Name
:= gPlayers
[a
].Name
;
1015 Frags
:= gPlayers
[a
].Frags
;
1016 Deaths
:= gPlayers
[a
].Death
;
1017 Kills
:= gPlayers
[a
].Kills
;
1018 Team
:= gPlayers
[a
].Team
;
1019 Color
:= gPlayers
[a
].Model
.Color
;
1020 Spectator
:= gPlayers
[a
].FSpectator
;
1024 SortGameStat(CustomStat
.PlayerStat
);
1026 if (gSaveStats
or gScreenshotStats
) and (Length(CustomStat
.PlayerStat
) > 1) then
1029 if g_Game_IsNet
then StatFilename
:= NetServerName
else StatFilename
:= 'local';
1030 StatDate
:= FormatDateTime('yymmdd_hhnnss', t
);
1031 StatFilename
:= StatFilename
+ '_' + CustomStat
.Map
+ '_' + g_Game_ModeToText(CustomStat
.GameMode
);
1032 StatFilename
:= sanitizeFilename(StatFilename
) + '_' + StatDate
;
1034 SaveGameStat(CustomStat
, FormatDateTime('yyyy"/"mm"/"dd', t
));
1037 StatShotDone
:= False;
1040 g_Game_ExecuteEvent('onmapend');
1041 if not g_Game_IsClient
then g_Player_ResetReady
;
1042 gInterReadyCount
:= 0;
1044 // Затухающий экран:
1045 EndingGameCounter
:= 255;
1046 gState
:= STATE_FOLD
;
1048 if gDefInterTime
< 0 then
1049 gInterEndTime
:= IfThen((gGameSettings
.GameType
= GT_SERVER
) and (gPlayer1
= nil), 15000, 25000)
1051 gInterEndTime
:= gDefInterTime
* 1000;
1054 EXIT_ENDLEVELSINGLE
: // Закончился уровень в Одиночной игре
1056 // Статистика Одиночной игры:
1057 SingleStat
.GameTime
:= gTime
;
1058 SingleStat
.TwoPlayers
:= gPlayer2
<> nil;
1059 SingleStat
.TotalSecrets
:= gSecretsCount
;
1060 // Статистика первого игрока:
1061 SingleStat
.PlayerStat
[0].Kills
:= gPlayer1
.MonsterKills
;
1062 SingleStat
.PlayerStat
[0].Secrets
:= gPlayer1
.Secrets
;
1063 // Статистика второго игрока (если есть):
1064 if SingleStat
.TwoPlayers
then
1066 SingleStat
.PlayerStat
[1].Kills
:= gPlayer2
.MonsterKills
;
1067 SingleStat
.PlayerStat
[1].Secrets
:= gPlayer2
.Secrets
;
1070 g_Game_ExecuteEvent('onmapend');
1073 if gNextMap
<> '' then
1075 gMusic
.SetByName('MUSIC_INTERMUS');
1077 gState
:= STATE_INTERSINGLE
;
1080 g_Game_ExecuteEvent('oninter');
1082 else // Больше нет карт
1084 // Затухающий экран:
1085 EndingGameCounter
:= 255;
1086 gState
:= STATE_FOLD
;
1091 // Окончание обработано:
1092 if gExit
<> EXIT_QUIT
then
1096 procedure g_Game_Init();
1099 knownFiles
: array of AnsiString = nil;
1101 wext
, s
: AnsiString;
1106 gTempDelete
:= False;
1108 sfsGCDisable(); // temporary disable removing of temporary volumes
1111 TEXTUREFILTER
:= GL_LINEAR
;
1112 g_Texture_CreateWADEx('MENU_BACKGROUND', GameWAD
+':TEXTURES\TITLE');
1113 g_Texture_CreateWADEx('INTER', GameWAD
+':TEXTURES\INTER');
1114 g_Texture_CreateWADEx('ENDGAME_EN', GameWAD
+':TEXTURES\ENDGAME_EN');
1115 g_Texture_CreateWADEx('ENDGAME_RU', GameWAD
+':TEXTURES\ENDGAME_RU');
1116 TEXTUREFILTER
:= GL_NEAREST
;
1118 LoadStdFont('STDTXT', 'STDFONT', gStdFont
);
1119 LoadFont('MENUTXT', 'MENUFONT', gMenuFont
);
1120 LoadFont('SMALLTXT', 'SMALLFONT', gMenuSmallFont
);
1122 g_Game_ClearLoading();
1123 g_Game_SetLoadingText(Format('Doom 2D: Forever %s', [GAME_VERSION
]), 0, False);
1124 g_Game_SetLoadingText('', 0, False);
1126 g_Game_SetLoadingText(_lc
[I_LOAD_CONSOLE
], 0, False);
1130 g_Game_SetLoadingText(_lc
[I_LOAD_MODELS
], 0, False);
1131 g_PlayerModel_LoadData();
1133 // load models from all possible wad types, in all known directories
1134 // this does a loosy job (linear search, ooph!), but meh
1135 for wext
in wadExtensions
do
1137 for f
:= High(ModelDirs
) downto Low(ModelDirs
) do
1139 if (FindFirst(ModelDirs
[f
]+DirectorySeparator
+'*'+wext
, faAnyFile
, SR
) = 0) then
1143 for s
in knownFiles
do
1145 if (strEquCI1251(forceFilenameExt(SR
.Name
, ''), forceFilenameExt(ExtractFileName(s
), ''))) then
1153 SetLength(knownFiles
, length(knownFiles
)+1);
1154 knownFiles
[High(knownFiles
)] := ModelDirs
[f
]+DirectorySeparator
+SR
.Name
;
1156 until (FindNext(SR
) <> 0);
1162 if (length(knownFiles
) = 0) then raise Exception
.Create('no player models found!');
1164 if (length(knownFiles
) = 1) then e_LogWriteln('1 player model found.', TMsgType
.Notify
) else e_LogWritefln('%d player models found.', [Integer(length(knownFiles
))], TMsgType
.Notify
);
1165 for s
in knownFiles
do
1167 if not g_PlayerModel_Load(s
) then e_LogWritefln('Error loading model "%s"', [s
], TMsgType
.Warning
);
1171 gPauseMain
:= false;
1172 gPauseHolmes
:= false;
1175 {e_MouseInfo.Accel := 1.0;}
1177 g_Game_SetLoadingText(_lc
[I_LOAD_GAME_DATA
], 0, False);
1180 g_Game_SetLoadingText(_lc
[I_LOAD_MUSIC
], 0, False);
1181 g_Sound_CreateWADEx('MUSIC_INTERMUS', GameWAD
+':MUSIC\INTERMUS', True);
1182 g_Sound_CreateWADEx('MUSIC_MENU', GameWAD
+':MUSIC\MENU', True);
1183 g_Sound_CreateWADEx('MUSIC_ROUNDMUS', GameWAD
+':MUSIC\ROUNDMUS', True, True);
1184 g_Sound_CreateWADEx('MUSIC_STDENDMUS', GameWAD
+':MUSIC\ENDMUS', True);
1187 g_Game_SetLoadingText(_lc
[I_LOAD_MENUS
], 0, False);
1191 gMusic
:= TMusic
.Create();
1192 gMusic
.SetByName('MUSIC_MENU');
1195 gGameSettings
.WarmupTime
:= 30;
1197 gState
:= STATE_MENU
;
1199 SetLength(gEvents
, 6);
1200 gEvents
[0].Name
:= 'ongamestart';
1201 gEvents
[1].Name
:= 'ongameend';
1202 gEvents
[2].Name
:= 'onmapstart';
1203 gEvents
[3].Name
:= 'onmapend';
1204 gEvents
[4].Name
:= 'oninter';
1205 gEvents
[5].Name
:= 'onwadend';
1207 sfsGCEnable(); // enable releasing unused volumes
1211 procedure g_Game_Free(freeTextures
: Boolean=true);
1213 if NetMode
= NET_CLIENT
then g_Net_Disconnect();
1214 if NetMode
= NET_SERVER
then g_Net_Host_Die();
1216 g_Map_Free(freeTextures
);
1218 g_Player_RemoveAllCorpses();
1220 gGameSettings
.GameType
:= GT_NONE
;
1221 if gGameSettings
.GameMode
= GM_SINGLE
then
1222 gGameSettings
.GameMode
:= GM_DM
;
1223 gSwitchGameMode
:= gGameSettings
.GameMode
;
1226 gExitByTrigger
:= False;
1229 function IsActivePlayer(p
: TPlayer
): Boolean;
1234 Result
:= (not p
.FDummy
) and (not p
.FSpectator
);
1237 function GetActivePlayerID_Next(Skip
: Integer = -1): Integer;
1243 if gPlayers
= nil then
1247 for a
:= Low(gPlayers
) to High(gPlayers
) do
1248 if IsActivePlayer(gPlayers
[a
]) then
1250 SetLength(ids
, Length(ids
) + 1);
1251 ids
[High(ids
)] := gPlayers
[a
].UID
;
1252 if gPlayers
[a
].UID
= Skip
then
1255 if Length(ids
) = 0 then
1260 Result
:= ids
[(idx
+ 1) mod Length(ids
)];
1263 function GetActivePlayerID_Prev(Skip
: Integer = -1): Integer;
1269 if gPlayers
= nil then
1273 for a
:= Low(gPlayers
) to High(gPlayers
) do
1274 if IsActivePlayer(gPlayers
[a
]) then
1276 SetLength(ids
, Length(ids
) + 1);
1277 ids
[High(ids
)] := gPlayers
[a
].UID
;
1278 if gPlayers
[a
].UID
= Skip
then
1281 if Length(ids
) = 0 then
1284 Result
:= ids
[Length(ids
) - 1]
1286 Result
:= ids
[(Length(ids
) - 1 + idx
) mod Length(ids
)];
1289 function GetActivePlayerID_Random(Skip
: Integer = -1): Integer;
1295 if gPlayers
= nil then
1299 for a
:= Low(gPlayers
) to High(gPlayers
) do
1300 if IsActivePlayer(gPlayers
[a
]) then
1302 SetLength(ids
, Length(ids
) + 1);
1303 ids
[High(ids
)] := gPlayers
[a
].UID
;
1304 if gPlayers
[a
].UID
= Skip
then
1307 if Length(ids
) = 0 then
1309 if Length(ids
) = 1 then
1314 Result
:= ids
[Random(Length(ids
))];
1316 while (idx
<> -1) and (Result
= Skip
) and (a
> 0) do
1318 Result
:= ids
[Random(Length(ids
))];
1323 function GetRandomSpectMode(Current
: Byte): Byte;
1330 0: Result
:= SPECT_STATS
;
1331 1: Result
:= SPECT_MAPVIEW
;
1332 2: Result
:= SPECT_MAPVIEW
;
1333 3: Result
:= SPECT_PLAYERS
;
1334 4: Result
:= SPECT_PLAYERS
;
1335 5: Result
:= SPECT_PLAYERS
;
1336 6: Result
:= SPECT_PLAYERS
;
1338 if (Current
in [SPECT_STATS
, SPECT_MAPVIEW
]) and (Current
= Result
) then
1342 procedure ProcessPlayerControls (plr
: TPlayer
; p
: Integer; var MoveButton
: Byte);
1348 if (plr
= nil) then exit
;
1349 if (p
= 2) then time
:= 1000 else time
:= 1;
1350 strafeDir
:= MoveButton
shr 4;
1351 MoveButton
:= MoveButton
and $0F;
1353 if gPlayerAction
[p
, ACTION_MOVELEFT
] and (not gPlayerAction
[p
, ACTION_MOVERIGHT
]) then
1354 MoveButton
:= 1 // Нажата только "Влево"
1355 else if (not gPlayerAction
[p
, ACTION_MOVELEFT
]) and gPlayerAction
[p
, ACTION_MOVERIGHT
] then
1356 MoveButton
:= 2 // Нажата только "Вправо"
1357 else if (not gPlayerAction
[p
, ACTION_MOVELEFT
]) and (not gPlayerAction
[p
, ACTION_MOVERIGHT
]) then
1358 MoveButton
:= 0; // Не нажаты ни "Влево", ни "Вправо"
1360 // Сейчас или раньше были нажаты "Влево"/"Вправо" => передаем игроку:
1361 if MoveButton
= 1 then
1362 plr
.PressKey(KEY_LEFT
, time
)
1363 else if MoveButton
= 2 then
1364 plr
.PressKey(KEY_RIGHT
, time
);
1366 // if we have "strafe" key, turn off old strafe mechanics
1367 if gPlayerAction
[p
, ACTION_STRAFE
] then
1369 // new strafe mechanics
1370 if (strafeDir
= 0) then
1371 strafeDir
:= MoveButton
; // start strafing
1372 // now set direction according to strafe (reversed)
1373 if (strafeDir
= 2) then
1374 plr
.SetDirection(TDirection
.D_LEFT
)
1375 else if (strafeDir
= 1) then
1376 plr
.SetDirection(TDirection
.D_RIGHT
)
1380 strafeDir
:= 0; // not strafing anymore
1381 // Раньше была нажата "Вправо", а сейчас "Влево" => бежим вправо, смотрим влево:
1382 if (MoveButton
= 2) and gPlayerAction
[p
, ACTION_MOVELEFT
] then
1383 plr
.SetDirection(TDirection
.D_LEFT
)
1384 // Раньше была нажата "Влево", а сейчас "Вправо" => бежим влево, смотрим вправо:
1385 else if (MoveButton
= 1) and gPlayerAction
[p
, ACTION_MOVERIGHT
] then
1386 plr
.SetDirection(TDirection
.D_RIGHT
)
1387 // Что-то было нажато и не изменилось => куда бежим, туда и смотрим:
1388 else if MoveButton
<> 0 then
1389 plr
.SetDirection(TDirection(MoveButton
-1))
1392 // fix movebutton state
1393 MoveButton
:= MoveButton
or (strafeDir
shl 4);
1395 // Остальные клавиши:
1396 if gPlayerAction
[p
, ACTION_JUMP
] then plr
.PressKey(KEY_JUMP
, time
);
1397 if gPlayerAction
[p
, ACTION_LOOKUP
] then plr
.PressKey(KEY_UP
, time
);
1398 if gPlayerAction
[p
, ACTION_LOOKDOWN
] then plr
.PressKey(KEY_DOWN
, time
);
1399 if gPlayerAction
[p
, ACTION_ATTACK
] then plr
.PressKey(KEY_FIRE
);
1400 if gPlayerAction
[p
, ACTION_WEAPNEXT
] then plr
.PressKey(KEY_NEXTWEAPON
);
1401 if gPlayerAction
[p
, ACTION_WEAPPREV
] then plr
.PressKey(KEY_PREVWEAPON
);
1402 if gPlayerAction
[p
, ACTION_ACTIVATE
] then plr
.PressKey(KEY_OPEN
);
1404 gPlayerAction
[p
, ACTION_WEAPNEXT
] := False; // HACK, remove after readyweaon&pendinweapon implementation
1405 gPlayerAction
[p
, ACTION_WEAPPREV
] := False; // HACK, remove after readyweaon&pendinweapon implementation
1407 for i
:= WP_FIRST
to WP_LAST
do
1409 if gSelectWeapon
[p
, i
] then
1411 plr
.QueueWeaponSwitch(i
); // all choices are passed there, and god will take the best
1412 gSelectWeapon
[p
, i
] := False
1416 // HACK: add dynlight here
1417 if gwin_k8_enable_light_experiments
then
1419 if e_KeyPressed(IK_F8
) and gGameOn
and (not gConsoleShow
) and (g_ActiveWindow
= nil) then
1421 g_playerLight
:= true;
1423 if e_KeyPressed(IK_F9
) and gGameOn
and (not gConsoleShow
) and (g_ActiveWindow
= nil) then
1425 g_playerLight
:= false;
1429 if gwin_has_stencil
and g_playerLight
then g_AddDynLight(plr
.GameX
+32, plr
.GameY
+40, 128, 1, 1, 0, 0.6);
1432 // HACK: don't have a "key was pressed" function
1433 procedure InterReady();
1435 if InterReadyTime
> gTime
then Exit
;
1436 InterReadyTime
:= gTime
+ 3000;
1437 MC_SEND_CheatRequest(NET_CHEAT_READY
);
1440 procedure g_Game_PreUpdate();
1442 // these are in separate PreUpdate functions because they can interact during Update()
1443 // and are synced over the net
1444 // we don't care that much about corpses and gibs
1445 g_Player_PreUpdate();
1446 g_Monsters_PreUpdate();
1447 g_Items_PreUpdate();
1448 g_Weapon_PreUpdate();
1451 procedure g_Game_Update();
1453 Msg
: g_gui
.TMessage
;
1459 function sendMonsPos (mon
: TMonster
): Boolean;
1461 result
:= false; // don't stop
1462 // this will also reset "need-send" flag
1463 if mon
.gncNeedSend
then
1465 MH_SEND_MonsterPos(mon
.UID
);
1467 else if (mon
.MonsterType
= MONSTER_BARREL
) then
1469 if (mon
.GameVelX
<> 0) or (mon
.GameVelY
<> 0) then MH_SEND_MonsterPos(mon
.UID
);
1471 else if (mon
.MonsterState
<> MONSTATE_SLEEP
) then
1473 if (mon
.MonsterState
<> MONSTATE_DEAD
) or (mon
.GameVelX
<> 0) or (mon
.GameVelY
<> 0) then MH_SEND_MonsterPos(mon
.UID
);
1477 function sendMonsPosUnexpected (mon
: TMonster
): Boolean;
1479 result
:= false; // don't stop
1480 // this will also reset "need-send" flag
1481 if mon
.gncNeedSend
then MH_SEND_MonsterPos(mon
.UID
);
1485 reliableUpdate
: Boolean;
1490 // Пора выключать игру:
1491 if gExit
= EXIT_QUIT
then
1493 // Игра закончилась - обрабатываем:
1497 if gExit
= EXIT_QUIT
then
1501 // Читаем клавиатуру и джойстик, если окно активно
1502 // no need to, as we'll do it in event handler
1504 // Обновляем консоль (движение и сообщения):
1508 if (NetMode
= NET_NONE
) and (g_Game_IsNet
) and (gGameOn
or (gState
in [STATE_FOLD
, STATE_INTERCUSTOM
])) then
1510 gExit
:= EXIT_SIMPLE
;
1515 // process master server communications
1516 g_Net_Slist_Pulse();
1519 STATE_INTERSINGLE
, // Статистка после прохождения уровня в Одиночной игре
1520 STATE_INTERCUSTOM
, // Статистка после прохождения уровня в Своей игре
1521 STATE_INTERTEXT
, // Текст между уровнями
1522 STATE_INTERPIC
: // Картинка между уровнями
1524 if g_Game_IsNet
and g_Game_IsServer
then
1526 gInterTime
:= gInterTime
+ GAME_TICK
;
1527 a
:= Min((gInterEndTime
- gInterTime
) div 1000 + 1, 255);
1528 if a
<> gServInterTime
then
1530 gServInterTime
:= a
;
1531 MH_SEND_TimeSync(gServInterTime
);
1535 if (not g_Game_IsClient
) and
1539 e_KeyPressed(IK_RETURN
) or e_KeyPressed(IK_KPRETURN
) or e_KeyPressed(IK_SPACE
) or
1540 e_KeyPressed(VK_FIRE
) or e_KeyPressed(VK_OPEN
) or
1541 e_KeyPressed(JOY0_ATTACK
) or e_KeyPressed(JOY1_ATTACK
) or
1542 e_KeyPressed(JOY2_ATTACK
) or e_KeyPressed(JOY3_ATTACK
)
1544 and (not gJustChatted
) and (not gConsoleShow
) and (not gChatShow
)
1545 and (g_ActiveWindow
= nil)
1547 or (g_Game_IsNet
and ((gInterTime
> gInterEndTime
) or ((gInterReadyCount
>= NetClientCount
) and (NetClientCount
> 0))))
1550 begin // Нажали <Enter>/<Пробел> или прошло достаточно времени:
1551 g_Game_StopAllSounds(True);
1553 if gMapOnce
then // Это был тест
1554 gExit
:= EXIT_SIMPLE
1556 if gNextMap
<> '' then // Переходим на следующую карту
1557 g_Game_ChangeMap(gNextMap
)
1558 else // Следующей карты нет
1560 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
] then
1562 // Выход в главное меню:
1564 g_GUI_ShowWindow('MainMenu');
1565 gMusic
.SetByName('MUSIC_MENU');
1567 gState
:= STATE_MENU
;
1570 // Финальная картинка:
1571 g_Game_ExecuteEvent('onwadend');
1573 if not gMusic
.SetByName('MUSIC_endmus') then
1574 gMusic
.SetByName('MUSIC_STDENDMUS');
1576 gState
:= STATE_ENDPIC
;
1578 g_Game_ExecuteEvent('ongameend');
1583 else if g_Game_IsClient
and
1586 e_KeyPressed(IK_RETURN
) or e_KeyPressed(IK_KPRETURN
) or e_KeyPressed(IK_SPACE
) or
1587 e_KeyPressed(VK_FIRE
) or e_KeyPressed(VK_OPEN
) or
1588 e_KeyPressed(JOY0_ATTACK
) or e_KeyPressed(JOY1_ATTACK
) or
1589 e_KeyPressed(JOY2_ATTACK
) or e_KeyPressed(JOY3_ATTACK
)
1591 and (not gJustChatted
) and (not gConsoleShow
) and (not gChatShow
)
1592 and (g_ActiveWindow
= nil)
1600 if gState
= STATE_INTERTEXT
then
1601 if InterText
.counter
> 0 then
1602 InterText
.counter
:= InterText
.counter
- 1;
1605 STATE_FOLD
: // Затухание экрана
1607 if EndingGameCounter
= 0 then
1609 // Закончился уровень в Своей игре:
1610 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
1612 InterReadyTime
:= -1;
1613 if gLastMap
and (gGameSettings
.GameMode
= GM_COOP
) then
1615 g_Game_ExecuteEvent('onwadend');
1616 if not gMusic
.SetByName('MUSIC_endmus') then
1617 gMusic
.SetByName('MUSIC_STDENDMUS');
1620 gMusic
.SetByName('MUSIC_ROUNDMUS');
1623 gState
:= STATE_INTERCUSTOM
;
1626 else // Закончилась последняя карта в Одиночной игре
1628 gMusic
.SetByName('MUSIC_INTERMUS');
1630 gState
:= STATE_INTERSINGLE
;
1633 g_Game_ExecuteEvent('oninter');
1636 DecMin(EndingGameCounter
, 6, 0);
1639 STATE_ENDPIC
: // Картинка окончания мегаВада
1641 if gMapOnce
then // Это был тест
1643 gExit
:= EXIT_SIMPLE
;
1649 g_Serverlist_Control(slCurrent
, slTable
);
1652 // Статистика по Tab:
1654 IsDrawStat
:= (not gConsoleShow
) and (not gChatShow
) and (gGameSettings
.GameType
<> GT_SINGLE
) and g_Console_Action(ACTION_SCORES
);
1657 if gGameOn
and not gPause
and (gState
<> STATE_FOLD
) then
1659 // Время += 28 миллисекунд:
1660 gTime
:= gTime
+ GAME_TICK
;
1662 // Сообщение посередине экрана:
1663 if MessageTime
= 0 then
1665 if MessageTime
> 0 then
1666 MessageTime
:= MessageTime
- 1;
1668 if (g_Game_IsServer
) then
1670 // Был задан лимит времени:
1671 if (gGameSettings
.TimeLimit
> 0) then
1672 if (gTime
- gGameStartTime
) div 1000 >= gGameSettings
.TimeLimit
then
1673 begin // Он прошел => конец уровня
1678 // Надо респавнить игроков в LMS:
1679 if (gLMSRespawn
> LMS_RESPAWN_NONE
) and (gLMSRespawnTime
< gTime
) then
1680 g_Game_RestartRound(gLMSSoftSpawn
);
1682 // Проверим результат голосования, если время прошло
1683 if gVoteInProgress
and (gVoteTimer
< gTime
) then
1685 else if gVotePassed
and (gVoteCmdTimer
< gTime
) then
1687 g_Console_Process(gVoteCommand
);
1689 gVotePassed
:= False;
1692 // Замеряем время захвата флагов
1693 if gFlags
[FLAG_RED
].State
= FLAG_STATE_CAPTURED
then
1694 gFlags
[FLAG_RED
].CaptureTime
:= gFlags
[FLAG_RED
].CaptureTime
+ GAME_TICK
;
1695 if gFlags
[FLAG_BLUE
].State
= FLAG_STATE_CAPTURED
then
1696 gFlags
[FLAG_BLUE
].CaptureTime
:= gFlags
[FLAG_BLUE
].CaptureTime
+ GAME_TICK
;
1698 // Был задан лимит побед:
1699 if (gGameSettings
.GoalLimit
> 0) then
1703 if gGameSettings
.GameMode
= GM_DM
then
1704 begin // В DM ищем игрока с max фрагами
1705 for i
:= 0 to High(gPlayers
) do
1706 if gPlayers
[i
] <> nil then
1707 if gPlayers
[i
].Frags
> b
then
1708 b
:= gPlayers
[i
].Frags
;
1711 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
1712 begin // В CTF/TDM выбираем команду с наибольшим счетом
1713 b
:= Max(gTeamStat
[TEAM_RED
].Goals
, gTeamStat
[TEAM_BLUE
].Goals
);
1716 // Лимит побед набран => конец уровня:
1717 if b
>= gGameSettings
.GoalLimit
then
1724 // Обрабатываем клавиши игроков:
1725 if gPlayer1
<> nil then gPlayer1
.ReleaseKeys();
1726 if gPlayer2
<> nil then gPlayer2
.ReleaseKeys();
1727 if (not gConsoleShow
) and (not gChatShow
) and (g_ActiveWindow
= nil) then
1729 ProcessPlayerControls(gPlayer1
, 0, P1MoveButton
);
1730 ProcessPlayerControls(gPlayer2
, 1, P2MoveButton
);
1731 end // if not console
1734 if g_Game_IsNet
and (gPlayer1
<> nil) then gPlayer1
.PressKey(KEY_CHAT
, 10000);
1736 // process weapon switch queue
1740 if (gPlayer1
= nil) and (gPlayer2
= nil) and
1741 (not gConsoleShow
) and (not gChatShow
) and (g_ActiveWindow
= nil) then
1743 if not gSpectKeyPress
then
1745 if gPlayerAction
[0, ACTION_JUMP
] and (not gSpectAuto
) then
1747 // switch spect mode
1749 SPECT_NONE
: ; // not spectator
1751 SPECT_MAPVIEW
: Inc(gSpectMode
);
1752 SPECT_PLAYERS
: gSpectMode
:= SPECT_STATS
; // reset to 1
1754 gSpectKeyPress
:= True;
1756 if (gSpectMode
= SPECT_MAPVIEW
)
1757 and (not gSpectAuto
) then
1759 if gPlayerAction
[0, ACTION_MOVELEFT
] then
1760 gSpectX
:= Max(gSpectX
- gSpectStep
, 0);
1761 if gPlayerAction
[0, ACTION_MOVERIGHT
] then
1762 gSpectX
:= Min(gSpectX
+ gSpectStep
, gMapInfo
.Width
- gScreenWidth
);
1763 if gPlayerAction
[0, ACTION_LOOKUP
] then
1764 gSpectY
:= Max(gSpectY
- gSpectStep
, 0);
1765 if gPlayerAction
[0, ACTION_LOOKDOWN
] then
1766 gSpectY
:= Min(gSpectY
+ gSpectStep
, gMapInfo
.Height
- gScreenHeight
);
1767 if gPlayerAction
[0, ACTION_WEAPPREV
] then
1770 if gSpectStep
> 4 then gSpectStep
:= gSpectStep
shr 1;
1771 gSpectKeyPress
:= True;
1773 if gPlayerAction
[0, ACTION_WEAPNEXT
] then
1776 if gSpectStep
< 64 then gSpectStep
:= gSpectStep
shl 1;
1777 gSpectKeyPress
:= True;
1780 if (gSpectMode
= SPECT_PLAYERS
)
1781 and (not gSpectAuto
) then
1783 if gPlayerAction
[0, ACTION_LOOKUP
] then
1786 gSpectViewTwo
:= True;
1787 gSpectKeyPress
:= True;
1789 if gPlayerAction
[0, ACTION_LOOKDOWN
] then
1791 // remove second view
1792 gSpectViewTwo
:= False;
1793 gSpectKeyPress
:= True;
1795 if gPlayerAction
[0, ACTION_MOVELEFT
] then
1797 // prev player (view 1)
1798 gSpectPID1
:= GetActivePlayerID_Prev(gSpectPID1
);
1799 gSpectKeyPress
:= True;
1801 if gPlayerAction
[0, ACTION_MOVERIGHT
] then
1803 // next player (view 1)
1804 gSpectPID1
:= GetActivePlayerID_Next(gSpectPID1
);
1805 gSpectKeyPress
:= True;
1807 if gPlayerAction
[0, ACTION_WEAPPREV
] then
1809 // prev player (view 2)
1810 gSpectPID2
:= GetActivePlayerID_Prev(gSpectPID2
);
1811 gSpectKeyPress
:= True;
1813 if gPlayerAction
[0, ACTION_WEAPNEXT
] then
1815 // next player (view 2)
1816 gSpectPID2
:= GetActivePlayerID_Next(gSpectPID2
);
1817 gSpectKeyPress
:= True;
1820 if gPlayerAction
[0, ACTION_ATTACK
] then
1822 if (gSpectMode
= SPECT_STATS
) and (not gSpectAuto
) then
1825 gSpectAutoNext
:= 0;
1826 gSpectViewTwo
:= False;
1827 gSpectKeyPress
:= True;
1832 gSpectMode
:= SPECT_STATS
;
1833 gSpectAuto
:= False;
1834 gSpectKeyPress
:= True;
1839 if (not gPlayerAction
[0, ACTION_JUMP
]) and
1840 (not gPlayerAction
[0, ACTION_ATTACK
]) and
1841 (not gPlayerAction
[0, ACTION_MOVELEFT
]) and
1842 (not gPlayerAction
[0, ACTION_MOVERIGHT
]) and
1843 (not gPlayerAction
[0, ACTION_LOOKUP
]) and
1844 (not gPlayerAction
[0, ACTION_LOOKDOWN
]) and
1845 (not gPlayerAction
[0, ACTION_WEAPPREV
]) and
1846 (not gPlayerAction
[0, ACTION_WEAPNEXT
]) then
1847 gSpectKeyPress
:= False;
1851 if gSpectMode
= SPECT_MAPVIEW
then
1853 i
:= Min(Max(gSpectX
+ gSpectAutoStepX
, 0), gMapInfo
.Width
- gScreenWidth
);
1855 gSpectAutoNext
:= gTime
1858 i
:= Min(Max(gSpectY
+ gSpectAutoStepY
, 0), gMapInfo
.Height
- gScreenHeight
);
1860 gSpectAutoNext
:= gTime
1864 if gSpectAutoNext
<= gTime
then
1866 if gSpectAutoNext
> 0 then
1868 gSpectMode
:= GetRandomSpectMode(gSpectMode
);
1872 gSpectX
:= Random(gMapInfo
.Width
- gScreenWidth
);
1873 gSpectY
:= Random(gMapInfo
.Height
- gScreenHeight
);
1874 gSpectAutoStepX
:= Random(9) - 4;
1875 gSpectAutoStepY
:= Random(9) - 4;
1876 if ((gSpectX
< 800) and (gSpectAutoStepX
< 0)) or
1877 ((gSpectX
> gMapInfo
.Width
- gScreenWidth
- 800) and (gSpectAutoStepX
> 0)) then
1878 gSpectAutoStepX
:= gSpectAutoStepX
* -1;
1879 if ((gSpectY
< 800) and (gSpectAutoStepY
< 0)) or
1880 ((gSpectY
> gMapInfo
.Height
- gScreenHeight
- 800) and (gSpectAutoStepY
> 0)) then
1881 gSpectAutoStepY
:= gSpectAutoStepY
* -1;
1885 gSpectPID1
:= GetActivePlayerID_Random(gSpectPID1
);
1890 SPECT_STATS
: gSpectAutoNext
:= gTime
+ (Random(3) + 5) * 1000;
1891 SPECT_MAPVIEW
: gSpectAutoNext
:= gTime
+ (Random(4) + 7) * 1000;
1892 SPECT_PLAYERS
: gSpectAutoNext
:= gTime
+ (Random(7) + 8) * 1000;
1898 // Обновляем все остальное:
1901 g_Triggers_Update();
1903 g_Monsters_Update();
1905 g_Player_UpdateAll();
1906 g_Player_UpdatePhysicalObjects();
1908 // server: send newly spawned monsters unconditionally
1909 if (gGameSettings
.GameType
= GT_SERVER
) then
1911 if (Length(gMonstersSpawned
) > 0) then
1913 for I
:= 0 to High(gMonstersSpawned
) do MH_SEND_MonsterSpawn(gMonstersSpawned
[I
]);
1914 SetLength(gMonstersSpawned
, 0);
1918 if (gSoundTriggerTime
> 8) then
1920 g_Game_UpdateTriggerSounds();
1921 gSoundTriggerTime
:= 0;
1925 Inc(gSoundTriggerTime
);
1928 if (NetMode
= NET_SERVER
) then
1930 Inc(NetTimeToUpdate
);
1931 Inc(NetTimeToReliable
);
1933 // send monster updates
1934 if (NetTimeToReliable
>= NetRelupdRate
) or (NetTimeToUpdate
>= NetUpdateRate
) then
1936 // send all monsters (periodic sync)
1937 reliableUpdate
:= (NetTimeToReliable
>= NetRelupdRate
);
1939 for I
:= 0 to High(gPlayers
) do
1941 if (gPlayers
[I
] <> nil) then MH_SEND_PlayerPos(reliableUpdate
, gPlayers
[I
].UID
);
1944 g_Mons_ForEach(sendMonsPos
);
1946 if reliableUpdate
then
1948 NetTimeToReliable
:= 0;
1949 NetTimeToUpdate
:= NetUpdateRate
;
1953 NetTimeToUpdate
:= 0;
1958 // send only mosters with some unexpected changes
1959 g_Mons_ForEach(sendMonsPosUnexpected
);
1962 // send unexpected platform changes
1963 g_Map_NetSendInterestingPanels();
1965 g_Net_Slist_ServerUpdate();
1967 if NetUseMaster then
1969 if (gTime >= NetTimeToMaster) or g_Net_Slist_IsConnectionInProgress then
1971 if (not g_Net_Slist_IsConnectionActive) then g_Net_Slist_Connect(false); // non-blocking connection to the master
1973 NetTimeToMaster := gTime + NetMasterRate;
1978 else if (NetMode
= NET_CLIENT
) then
1980 MC_SEND_PlayerPos();
1982 end; // if gameOn ...
1984 // Активно окно интерфейса - передаем клавиши ему:
1985 if g_ActiveWindow
<> nil then
1987 w
:= e_GetFirstKeyPressed();
1989 if (w
<> IK_INVALID
) then
1991 Msg
.Msg
:= MESSAGE_DIKEY
;
1993 g_ActiveWindow
.OnMessage(Msg
);
1996 // Если оно от этого не закрылось, то обновляем:
1997 if g_ActiveWindow
<> nil then
1998 g_ActiveWindow
.Update();
2000 // Нужно сменить разрешение:
2001 if gResolutionChange
then
2003 e_WriteLog('Changing resolution', TMsgType
.Notify
);
2004 g_Game_ChangeResolution(gRC_Width
, gRC_Height
, gRC_FullScreen
, gRC_Maximized
);
2005 gResolutionChange
:= False;
2006 g_ActiveWindow
:= nil;
2009 // Нужно сменить язык:
2010 if gLanguageChange
then
2012 //e_WriteLog('Read language file', MSG_NOTIFY);
2013 //g_Language_Load(DataDir + gLanguage + '.txt');
2014 g_Language_Set(gLanguage
);
2018 gLanguageChange
:= False;
2022 // Горячая клавиша для вызова меню выхода из игры (F10):
2023 if e_KeyPressed(IK_F10
) and
2025 (not gConsoleShow
) and
2026 (g_ActiveWindow
= nil) then
2031 Time
:= sys_GetTicks() {div 1000};
2033 // Обработка отложенных событий:
2034 if gDelayedEvents
<> nil then
2035 for a
:= 0 to High(gDelayedEvents
) do
2036 if gDelayedEvents
[a
].Pending
and
2038 ((gDelayedEvents
[a
].DEType
= DE_GLOBEVENT
) and (gDelayedEvents
[a
].Time
<= Time
)) or
2039 ((gDelayedEvents
[a
].DEType
> DE_GLOBEVENT
) and (gDelayedEvents
[a
].Time
<= gTime
))
2042 case gDelayedEvents
[a
].DEType
of
2044 g_Game_ExecuteEvent(gDelayedEvents
[a
].DEStr
);
2047 g_Game_Announce_GoodShot(gDelayedEvents
[a
].DENum
);
2051 g_Game_Announce_KillCombo(gDelayedEvents
[a
].DENum
);
2052 if g_Game_IsNet
and g_Game_IsServer
then
2053 MH_SEND_GameEvent(NET_EV_KILLCOMBO
, gDelayedEvents
[a
].DENum
);
2057 g_Game_Announce_BodyKill(gDelayedEvents
[a
].DENum
);
2059 gDelayedEvents
[a
].Pending
:= False;
2062 // Каждую секунду обновляем счетчик обновлений:
2063 UPSCounter
:= UPSCounter
+ 1;
2064 if Time
- UPSTime
>= 1000 then
2073 g_Weapon_AddDynLights();
2074 g_Items_AddDynLights();
2078 procedure g_Game_LoadChatSounds(Resource
: string);
2081 FileName
, Snd
: string;
2083 len
, cnt
, tags
, i
, j
: Integer;
2086 FileName
:= g_ExtractWadName(Resource
);
2088 WAD
:= TWADFile
.Create();
2089 WAD
.ReadFile(FileName
);
2091 if not WAD
.GetResource(g_ExtractFilePathName(Resource
), p
, len
) then
2098 cfg
:= TConfig
.CreateMem(p
, len
);
2099 cnt
:= cfg
.ReadInt('ChatSounds', 'Count', 0);
2101 SetLength(gChatSounds
, cnt
);
2102 for i
:= 0 to Length(gChatSounds
) - 1 do
2104 gChatSounds
[i
].Sound
:= nil;
2105 Snd
:= Trim(cfg
.ReadStr(IntToStr(i
), 'Sound', ''));
2106 tags
:= cfg
.ReadInt(IntToStr(i
), 'Tags', 0);
2107 if (Snd
= '') or (Tags
<= 0) then
2109 g_Sound_CreateWADEx('SOUND_CHAT_MACRO' + IntToStr(i
), GameWAD
+':'+Snd
);
2110 gChatSounds
[i
].Sound
:= TPlayableSound
.Create();
2111 gChatSounds
[i
].Sound
.SetByName('SOUND_CHAT_MACRO' + IntToStr(i
));
2112 SetLength(gChatSounds
[i
].Tags
, tags
);
2113 for j
:= 0 to tags
- 1 do
2114 gChatSounds
[i
].Tags
[j
] := toLowerCase1251(cfg
.ReadStr(IntToStr(i
), 'Tag' + IntToStr(j
), ''));
2115 gChatSounds
[i
].FullWord
:= cfg
.ReadBool(IntToStr(i
), 'FullWord', False);
2122 procedure g_Game_FreeChatSounds();
2126 for i
:= 0 to Length(gChatSounds
) - 1 do
2128 gChatSounds
[i
].Sound
.Free();
2129 g_Sound_Delete('SOUND_CHAT_MACRO' + IntToStr(i
));
2131 SetLength(gChatSounds
, 0);
2135 procedure g_Game_LoadData();
2142 if DataLoaded
then Exit
;
2144 e_WriteLog('Loading game data...', TMsgType
.Notify
);
2146 g_Texture_CreateWADEx('NOTEXTURE', GameWAD
+':TEXTURES\NOTEXTURE');
2147 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUD', GameWAD
+':TEXTURES\HUD');
2148 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDAIR', GameWAD
+':TEXTURES\AIRBAR');
2149 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDJET', GameWAD
+':TEXTURES\JETBAR');
2150 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDBG', GameWAD
+':TEXTURES\HUDBG');
2151 g_Texture_CreateWADEx('TEXTURE_PLAYER_ARMORHUD', GameWAD
+':TEXTURES\ARMORHUD');
2152 g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG', GameWAD
+':TEXTURES\FLAGHUD_R_BASE');
2153 g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG_S', GameWAD
+':TEXTURES\FLAGHUD_R_STOLEN');
2154 g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG_D', GameWAD
+':TEXTURES\FLAGHUD_R_DROP');
2155 g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG', GameWAD
+':TEXTURES\FLAGHUD_B_BASE');
2156 g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG_S', GameWAD
+':TEXTURES\FLAGHUD_B_STOLEN');
2157 g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG_D', GameWAD
+':TEXTURES\FLAGHUD_B_DROP');
2158 g_Texture_CreateWADEx('TEXTURE_PLAYER_TALKBUBBLE', GameWAD
+':TEXTURES\TALKBUBBLE');
2159 g_Texture_CreateWADEx('TEXTURE_PLAYER_INVULPENTA', GameWAD
+':TEXTURES\PENTA');
2160 g_Texture_CreateWADEx('TEXTURE_PLAYER_INDICATOR', GameWAD
+':TEXTURES\PLRIND');
2163 if not g_Texture_CreateWADEx('UI_GFX_PBAR_LEFT', GameWAD
+':TEXTURES\LLEFT') then hasPBarGfx
:= false;
2164 if not g_Texture_CreateWADEx('UI_GFX_PBAR_MARKER', GameWAD
+':TEXTURES\LMARKER') then hasPBarGfx
:= false;
2165 if not g_Texture_CreateWADEx('UI_GFX_PBAR_MIDDLE', GameWAD
+':TEXTURES\LMIDDLE') then hasPBarGfx
:= false;
2166 if not g_Texture_CreateWADEx('UI_GFX_PBAR_RIGHT', GameWAD
+':TEXTURES\LRIGHT') then hasPBarGfx
:= false;
2170 g_Texture_GetSize('UI_GFX_PBAR_LEFT', wl
, hl
);
2171 g_Texture_GetSize('UI_GFX_PBAR_RIGHT', wr
, hr
);
2172 g_Texture_GetSize('UI_GFX_PBAR_MIDDLE', wb
, hb
);
2173 g_Texture_GetSize('UI_GFX_PBAR_MARKER', wm
, hm
);
2174 if (wl
> 0) and (hl
> 0) and (wr
> 0) and (hr
= hl
) and (wb
> 0) and (hb
= hl
) and (wm
> 0) and (hm
> 0) and (hm
<= hl
) then
2180 hasPBarGfx
:= false;
2184 g_Frames_CreateWAD(nil, 'FRAMES_TELEPORT', GameWAD
+':TEXTURES\TELEPORT', 64, 64, 10, False);
2185 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH', GameWAD
+':WEAPONS\PUNCH', 64, 64, 4, False);
2186 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_UP', GameWAD
+':WEAPONS\PUNCH_UP', 64, 64, 4, False);
2187 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_DN', GameWAD
+':WEAPONS\PUNCH_DN', 64, 64, 4, False);
2188 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_BERSERK', GameWAD
+':WEAPONS\PUNCHB', 64, 64, 4, False);
2189 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_BERSERK_UP', GameWAD
+':WEAPONS\PUNCHB_UP', 64, 64, 4, False);
2190 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_BERSERK_DN', GameWAD
+':WEAPONS\PUNCHB_DN', 64, 64, 4, False);
2191 g_Sound_CreateWADEx('SOUND_GAME_TELEPORT', GameWAD
+':SOUNDS\TELEPORT');
2192 g_Sound_CreateWADEx('SOUND_GAME_NOTELEPORT', GameWAD
+':SOUNDS\NOTELEPORT');
2193 g_Sound_CreateWADEx('SOUND_GAME_SECRET', GameWAD
+':SOUNDS\SECRET');
2194 g_Sound_CreateWADEx('SOUND_GAME_DOOROPEN', GameWAD
+':SOUNDS\DOOROPEN');
2195 g_Sound_CreateWADEx('SOUND_GAME_DOORCLOSE', GameWAD
+':SOUNDS\DOORCLOSE');
2196 g_Sound_CreateWADEx('SOUND_GAME_BULK1', GameWAD
+':SOUNDS\BULK1');
2197 g_Sound_CreateWADEx('SOUND_GAME_BULK2', GameWAD
+':SOUNDS\BULK2');
2198 g_Sound_CreateWADEx('SOUND_GAME_BUBBLE1', GameWAD
+':SOUNDS\BUBBLE1');
2199 g_Sound_CreateWADEx('SOUND_GAME_BUBBLE2', GameWAD
+':SOUNDS\BUBBLE2');
2200 g_Sound_CreateWADEx('SOUND_GAME_BURNING', GameWAD
+':SOUNDS\BURNING');
2201 g_Sound_CreateWADEx('SOUND_GAME_SWITCH1', GameWAD
+':SOUNDS\SWITCH1');
2202 g_Sound_CreateWADEx('SOUND_GAME_SWITCH0', GameWAD
+':SOUNDS\SWITCH0');
2203 g_Sound_CreateWADEx('SOUND_GAME_RADIO', GameWAD
+':SOUNDS\RADIO');
2204 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD1', GameWAD
+':SOUNDS\GOOD1');
2205 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD2', GameWAD
+':SOUNDS\GOOD2');
2206 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD3', GameWAD
+':SOUNDS\GOOD3');
2207 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD4', GameWAD
+':SOUNDS\GOOD4');
2208 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL2X', GameWAD
+':SOUNDS\KILL2X');
2209 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL3X', GameWAD
+':SOUNDS\KILL3X');
2210 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL4X', GameWAD
+':SOUNDS\KILL4X');
2211 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILLMX', GameWAD
+':SOUNDS\KILLMX');
2212 g_Sound_CreateWADEx('SOUND_ANNOUNCER_MUHAHA1', GameWAD
+':SOUNDS\MUHAHA1');
2213 g_Sound_CreateWADEx('SOUND_ANNOUNCER_MUHAHA2', GameWAD
+':SOUNDS\MUHAHA2');
2214 g_Sound_CreateWADEx('SOUND_ANNOUNCER_MUHAHA3', GameWAD
+':SOUNDS\MUHAHA3');
2215 g_Sound_CreateWADEx('SOUND_CTF_GET1', GameWAD
+':SOUNDS\GETFLAG1');
2216 g_Sound_CreateWADEx('SOUND_CTF_GET2', GameWAD
+':SOUNDS\GETFLAG2');
2217 g_Sound_CreateWADEx('SOUND_CTF_LOST1', GameWAD
+':SOUNDS\LOSTFLG1');
2218 g_Sound_CreateWADEx('SOUND_CTF_LOST2', GameWAD
+':SOUNDS\LOSTFLG2');
2219 g_Sound_CreateWADEx('SOUND_CTF_RETURN1', GameWAD
+':SOUNDS\RETFLAG1');
2220 g_Sound_CreateWADEx('SOUND_CTF_RETURN2', GameWAD
+':SOUNDS\RETFLAG2');
2221 g_Sound_CreateWADEx('SOUND_CTF_CAPTURE1', GameWAD
+':SOUNDS\CAPFLAG1');
2222 g_Sound_CreateWADEx('SOUND_CTF_CAPTURE2', GameWAD
+':SOUNDS\CAPFLAG2');
2224 goodsnd
[0] := TPlayableSound
.Create();
2225 goodsnd
[1] := TPlayableSound
.Create();
2226 goodsnd
[2] := TPlayableSound
.Create();
2227 goodsnd
[3] := TPlayableSound
.Create();
2229 goodsnd
[0].SetByName('SOUND_ANNOUNCER_GOOD1');
2230 goodsnd
[1].SetByName('SOUND_ANNOUNCER_GOOD2');
2231 goodsnd
[2].SetByName('SOUND_ANNOUNCER_GOOD3');
2232 goodsnd
[3].SetByName('SOUND_ANNOUNCER_GOOD4');
2234 killsnd
[0] := TPlayableSound
.Create();
2235 killsnd
[1] := TPlayableSound
.Create();
2236 killsnd
[2] := TPlayableSound
.Create();
2237 killsnd
[3] := TPlayableSound
.Create();
2239 killsnd
[0].SetByName('SOUND_ANNOUNCER_KILL2X');
2240 killsnd
[1].SetByName('SOUND_ANNOUNCER_KILL3X');
2241 killsnd
[2].SetByName('SOUND_ANNOUNCER_KILL4X');
2242 killsnd
[3].SetByName('SOUND_ANNOUNCER_KILLMX');
2244 hahasnd
[0] := TPlayableSound
.Create();
2245 hahasnd
[1] := TPlayableSound
.Create();
2246 hahasnd
[2] := TPlayableSound
.Create();
2248 hahasnd
[0].SetByName('SOUND_ANNOUNCER_MUHAHA1');
2249 hahasnd
[1].SetByName('SOUND_ANNOUNCER_MUHAHA2');
2250 hahasnd
[2].SetByName('SOUND_ANNOUNCER_MUHAHA3');
2252 sound_get_flag
[0] := TPlayableSound
.Create();
2253 sound_get_flag
[1] := TPlayableSound
.Create();
2254 sound_lost_flag
[0] := TPlayableSound
.Create();
2255 sound_lost_flag
[1] := TPlayableSound
.Create();
2256 sound_ret_flag
[0] := TPlayableSound
.Create();
2257 sound_ret_flag
[1] := TPlayableSound
.Create();
2258 sound_cap_flag
[0] := TPlayableSound
.Create();
2259 sound_cap_flag
[1] := TPlayableSound
.Create();
2261 sound_get_flag
[0].SetByName('SOUND_CTF_GET1');
2262 sound_get_flag
[1].SetByName('SOUND_CTF_GET2');
2263 sound_lost_flag
[0].SetByName('SOUND_CTF_LOST1');
2264 sound_lost_flag
[1].SetByName('SOUND_CTF_LOST2');
2265 sound_ret_flag
[0].SetByName('SOUND_CTF_RETURN1');
2266 sound_ret_flag
[1].SetByName('SOUND_CTF_RETURN2');
2267 sound_cap_flag
[0].SetByName('SOUND_CTF_CAPTURE1');
2268 sound_cap_flag
[1].SetByName('SOUND_CTF_CAPTURE2');
2270 g_Game_LoadChatSounds(GameWAD
+':CHATSND\SNDCFG');
2272 g_Game_SetLoadingText(_lc
[I_LOAD_ITEMS_DATA
], 0, False);
2275 g_Game_SetLoadingText(_lc
[I_LOAD_WEAPONS_DATA
], 0, False);
2276 g_Weapon_LoadData();
2278 g_Monsters_LoadData();
2283 procedure g_Game_Quit();
2285 g_Game_StopAllSounds(True);
2288 g_PlayerModel_FreeData();
2289 g_Texture_DeleteAll();
2290 g_Frames_DeleteAll();
2292 //g_Menu_Free(); //k8: this segfaults after resolution change; who cares?
2295 if NetInitDone
then g_Net_Free
;
2297 // remove map after test
2298 if gMapToDelete
<> '' then
2299 g_Game_DeleteTestMap();
2305 procedure g_Game_FreeData();
2307 if not DataLoaded
then Exit
;
2310 g_Weapon_FreeData();
2311 g_Monsters_FreeData();
2313 e_WriteLog('Releasing game data...', TMsgType
.Notify
);
2315 g_Texture_Delete('NOTEXTURE');
2316 g_Texture_Delete('TEXTURE_PLAYER_HUD');
2317 g_Texture_Delete('TEXTURE_PLAYER_HUDBG');
2318 g_Texture_Delete('TEXTURE_PLAYER_ARMORHUD');
2319 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG');
2320 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG_S');
2321 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG_D');
2322 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG');
2323 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG_S');
2324 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG_D');
2325 g_Texture_Delete('TEXTURE_PLAYER_TALKBUBBLE');
2326 g_Texture_Delete('TEXTURE_PLAYER_INVULPENTA');
2327 g_Frames_DeleteByName('FRAMES_TELEPORT');
2328 g_Frames_DeleteByName('FRAMES_PUNCH');
2329 g_Frames_DeleteByName('FRAMES_PUNCH_UP');
2330 g_Frames_DeleteByName('FRAMES_PUNCH_DN');
2331 g_Frames_DeleteByName('FRAMES_PUNCH_BERSERK');
2332 g_Frames_DeleteByName('FRAMES_PUNCH_BERSERK_UP');
2333 g_Frames_DeleteByName('FRAMES_PUNCH_BERSERK_DN');
2334 g_Sound_Delete('SOUND_GAME_TELEPORT');
2335 g_Sound_Delete('SOUND_GAME_NOTELEPORT');
2336 g_Sound_Delete('SOUND_GAME_SECRET');
2337 g_Sound_Delete('SOUND_GAME_DOOROPEN');
2338 g_Sound_Delete('SOUND_GAME_DOORCLOSE');
2339 g_Sound_Delete('SOUND_GAME_BULK1');
2340 g_Sound_Delete('SOUND_GAME_BULK2');
2341 g_Sound_Delete('SOUND_GAME_BUBBLE1');
2342 g_Sound_Delete('SOUND_GAME_BUBBLE2');
2343 g_Sound_Delete('SOUND_GAME_BURNING');
2344 g_Sound_Delete('SOUND_GAME_SWITCH1');
2345 g_Sound_Delete('SOUND_GAME_SWITCH0');
2352 g_Sound_Delete('SOUND_ANNOUNCER_GOOD1');
2353 g_Sound_Delete('SOUND_ANNOUNCER_GOOD2');
2354 g_Sound_Delete('SOUND_ANNOUNCER_GOOD3');
2355 g_Sound_Delete('SOUND_ANNOUNCER_GOOD4');
2362 g_Sound_Delete('SOUND_ANNOUNCER_KILL2X');
2363 g_Sound_Delete('SOUND_ANNOUNCER_KILL3X');
2364 g_Sound_Delete('SOUND_ANNOUNCER_KILL4X');
2365 g_Sound_Delete('SOUND_ANNOUNCER_KILLMX');
2371 g_Sound_Delete('SOUND_ANNOUNCER_MUHAHA1');
2372 g_Sound_Delete('SOUND_ANNOUNCER_MUHAHA2');
2373 g_Sound_Delete('SOUND_ANNOUNCER_MUHAHA3');
2375 sound_get_flag
[0].Free();
2376 sound_get_flag
[1].Free();
2377 sound_lost_flag
[0].Free();
2378 sound_lost_flag
[1].Free();
2379 sound_ret_flag
[0].Free();
2380 sound_ret_flag
[1].Free();
2381 sound_cap_flag
[0].Free();
2382 sound_cap_flag
[1].Free();
2384 g_Sound_Delete('SOUND_CTF_GET1');
2385 g_Sound_Delete('SOUND_CTF_GET2');
2386 g_Sound_Delete('SOUND_CTF_LOST1');
2387 g_Sound_Delete('SOUND_CTF_LOST2');
2388 g_Sound_Delete('SOUND_CTF_RETURN1');
2389 g_Sound_Delete('SOUND_CTF_RETURN2');
2390 g_Sound_Delete('SOUND_CTF_CAPTURE1');
2391 g_Sound_Delete('SOUND_CTF_CAPTURE2');
2393 g_Game_FreeChatSounds();
2395 DataLoaded
:= False;
2398 procedure g_FatalError(Text: String);
2400 g_Console_Add(Format(_lc
[I_FATAL_ERROR
], [Text]), True);
2401 e_WriteLog(Format(_lc
[I_FATAL_ERROR
], [Text]), TMsgType
.Warning
);
2403 gExit
:= EXIT_SIMPLE
;
2404 if gGameOn
then EndGame
;
2407 procedure g_SimpleError(Text: String);
2409 g_Console_Add(Format(_lc
[I_SIMPLE_ERROR
], [Text]), True);
2410 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], [Text]), TMsgType
.Warning
);
2413 procedure g_Game_SetupScreenSize();
2415 RES_FACTOR
= 4.0 / 3.0;
2421 // Размер экранов игроков:
2422 gPlayerScreenSize
.X
:= gScreenWidth
-196;
2423 if (gPlayer1
<> nil) and (gPlayer2
<> nil) then
2424 gPlayerScreenSize
.Y
:= gScreenHeight
div 2
2426 gPlayerScreenSize
.Y
:= gScreenHeight
;
2428 // Размер заднего плана:
2429 if BackID
<> DWORD(-1) then
2432 if (gScreenWidth
*s
> gMapInfo
.Width
) or
2433 (gScreenHeight
*s
> gMapInfo
.Height
) then
2435 gBackSize
.X
:= gScreenWidth
;
2436 gBackSize
.Y
:= gScreenHeight
;
2440 e_GetTextureSize(BackID
, @bw
, @bh
);
2441 rf
:= Single(bw
) / Single(bh
);
2442 if (rf
> RES_FACTOR
) then bw
:= Round(Single(bh
) * RES_FACTOR
)
2443 else if (rf
< RES_FACTOR
) then bh
:= Round(Single(bw
) / RES_FACTOR
);
2444 s
:= Max(gScreenWidth
/ bw
, gScreenHeight
/ bh
);
2445 if (s
< 1.0) then s
:= 1.0;
2446 gBackSize
.X
:= Round(bw
*s
);
2447 gBackSize
.Y
:= Round(bh
*s
);
2452 procedure g_Game_ChangeResolution(newWidth
, newHeight
: Word; nowFull
, nowMax
: Boolean);
2454 sys_SetDisplayMode(newWidth
, newHeight
, gBPP
, nowFull
, nowMax
);
2457 procedure g_Game_AddPlayer(Team
: Byte = TEAM_NONE
);
2459 if ((not gGameOn
) and (gState
<> STATE_INTERCUSTOM
))
2460 or (not (gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
])) then
2463 if (gGameSettings
.MaxLives
> 0) and (gLMSRespawn
= LMS_RESPAWN_NONE
) then
2466 if gPlayer1
= nil then
2468 if g_Game_IsClient
then
2470 if NetPlrUID1
> -1 then
2471 MC_SEND_CheatRequest(NET_CHEAT_SPECTATE
);
2475 if not (Team
in [TEAM_RED
, TEAM_BLUE
]) then
2476 Team
:= gPlayer1Settings
.Team
;
2478 // Создание первого игрока:
2479 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
2480 gPlayer1Settings
.Color
,
2482 if gPlayer1
= nil then
2483 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]))
2486 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
2487 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [gPlayer1
.Name
]), True);
2488 if g_Game_IsServer
and g_Game_IsNet
then
2489 MH_SEND_PlayerCreate(gPlayer1
.UID
);
2490 gPlayer1
.Respawn(False, True);
2491 g_Net_Slist_ServerPlayerComes();
2496 if gPlayer2
= nil then
2498 if g_Game_IsClient
then
2500 if NetPlrUID2
> -1 then
2501 gPlayer2
:= g_Player_Get(NetPlrUID2
);
2505 if not (Team
in [TEAM_RED
, TEAM_BLUE
]) then
2506 Team
:= gPlayer2Settings
.Team
;
2508 // Создание второго игрока:
2509 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
2510 gPlayer2Settings
.Color
,
2512 if gPlayer2
= nil then
2513 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]))
2516 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
2517 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [gPlayer2
.Name
]), True);
2518 if g_Game_IsServer
and g_Game_IsNet
then
2519 MH_SEND_PlayerCreate(gPlayer2
.UID
);
2520 gPlayer2
.Respawn(False, True);
2521 g_Net_Slist_ServerPlayerComes();
2528 procedure g_Game_RemovePlayer();
2532 if ((not gGameOn
) and (gState
<> STATE_INTERCUSTOM
))
2533 or (not (gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
])) then
2538 if g_Game_IsServer
then
2541 Pl
.Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
2542 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [Pl
.Name
]), True);
2543 g_Player_Remove(Pl
.UID
);
2544 g_Net_Slist_ServerPlayerLeaves();
2548 gSpectLatchPID2
:= Pl
.UID
;
2556 if g_Game_IsServer
then
2559 Pl
.Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
2560 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [Pl
.Name
]), True);
2561 g_Player_Remove(Pl
.UID
);
2562 g_Net_Slist_ServerPlayerLeaves();
2565 gSpectLatchPID1
:= Pl
.UID
;
2567 MC_SEND_CheatRequest(NET_CHEAT_SPECTATE
);
2571 g_Net_Slist_ServerPlayerLeaves();
2574 procedure g_Game_Spectate();
2576 g_Game_RemovePlayer();
2577 if gPlayer1
<> nil then
2578 g_Game_RemovePlayer();
2581 procedure g_Game_SpectateCenterView();
2583 gSpectX
:= Max(gMapInfo
.Width
div 2 - gScreenWidth
div 2, 0);
2584 gSpectY
:= Max(gMapInfo
.Height
div 2 - gScreenHeight
div 2, 0);
2587 procedure g_Game_StartSingle(Map
: String; TwoPlayers
: Boolean; nPlayers
: Byte);
2594 e_WriteLog('Starting singleplayer game...', TMsgType
.Notify
);
2596 g_Game_ClearLoading();
2599 FillByte(gGameSettings
, SizeOf(TGameSettings
), 0);
2602 gGameSettings
.GameType
:= GT_SINGLE
;
2603 gGameSettings
.MaxLives
:= 0;
2604 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_ALLOWEXIT
;
2605 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_MONSTERS
;
2606 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_BOTVSMONSTER
;
2607 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_TEAMHITPROJECTILE
;
2608 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_TEAMHITTRACE
;
2609 gSwitchGameMode
:= GM_SINGLE
;
2611 gLMSRespawn
:= LMS_RESPAWN_NONE
;
2612 gLMSRespawnTime
:= 0;
2613 gSpectLatchPID1
:= 0;
2614 gSpectLatchPID2
:= 0;
2616 g_Game_ExecuteEvent('ongamestart');
2618 // Установка размеров окон игроков:
2619 g_Game_SetupScreenSize();
2621 // Создание первого игрока:
2622 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
2623 gPlayer1Settings
.Color
,
2624 gPlayer1Settings
.Team
, False));
2625 if gPlayer1
= nil then
2627 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
2631 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
2634 // Создание второго игрока, если есть:
2637 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
2638 gPlayer2Settings
.Color
,
2639 gPlayer2Settings
.Team
, False));
2640 if gPlayer2
= nil then
2642 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
2646 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
2650 // Загрузка и запуск карты:
2651 if not g_Game_StartMap(false{asMegawad}, MAP
, True) then
2653 if (Pos(':\', Map
) > 0) or (Pos(':/', Map
) > 0) then tmps
:= Map
else tmps
:= gGameSettings
.WAD
+ ':\' + MAP
;
2654 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [tmps
]));
2658 // Настройки игроков и ботов:
2662 for i
:= nPl
+1 to nPlayers
do
2663 g_Player_Create(STD_PLAYER_MODEL
, _RGB(0, 0, 0), 0, True);
2666 procedure g_Game_StartCustom(Map
: String; GameMode
: Byte;
2667 TimeLimit
, GoalLimit
: Word;
2669 Options
: LongWord; nPlayers
: Byte);
2675 e_WriteLog('Starting custom game...', TMsgType
.Notify
);
2677 g_Game_ClearLoading();
2680 gGameSettings
.GameType
:= GT_CUSTOM
;
2681 gGameSettings
.GameMode
:= GameMode
;
2682 gSwitchGameMode
:= GameMode
;
2683 gGameSettings
.TimeLimit
:= TimeLimit
;
2684 gGameSettings
.GoalLimit
:= GoalLimit
;
2685 gGameSettings
.MaxLives
:= IfThen(GameMode
= GM_CTF
, 0, MaxLives
);
2686 gGameSettings
.Options
:= Options
;
2688 gCoopTotalMonstersKilled
:= 0;
2689 gCoopTotalSecretsFound
:= 0;
2690 gCoopTotalMonsters
:= 0;
2691 gCoopTotalSecrets
:= 0;
2695 gLMSRespawn
:= LMS_RESPAWN_NONE
;
2696 gLMSRespawnTime
:= 0;
2697 gSpectLatchPID1
:= 0;
2698 gSpectLatchPID2
:= 0;
2700 g_Game_ExecuteEvent('ongamestart');
2702 // Установка размеров окон игроков:
2703 g_Game_SetupScreenSize();
2705 // Режим наблюдателя:
2706 if nPlayers
= 0 then
2713 if nPlayers
>= 1 then
2715 // Создание первого игрока:
2716 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
2717 gPlayer1Settings
.Color
,
2718 gPlayer1Settings
.Team
, False));
2719 if gPlayer1
= nil then
2721 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
2725 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
2729 if nPlayers
>= 2 then
2731 // Создание второго игрока:
2732 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
2733 gPlayer2Settings
.Color
,
2734 gPlayer2Settings
.Team
, False));
2735 if gPlayer2
= nil then
2737 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
2741 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
2745 // Загрузка и запуск карты:
2746 if not g_Game_StartMap(true{asMegawad}, Map
, True) then
2748 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [Map
]));
2752 // Нет точек появления:
2753 if (g_Map_GetPointCount(RESPAWNPOINT_PLAYER1
) +
2754 g_Map_GetPointCount(RESPAWNPOINT_PLAYER2
) +
2755 g_Map_GetPointCount(RESPAWNPOINT_DM
) +
2756 g_Map_GetPointCount(RESPAWNPOINT_RED
)+
2757 g_Map_GetPointCount(RESPAWNPOINT_BLUE
)) < 1 then
2759 g_FatalError(_lc
[I_GAME_ERROR_GET_SPAWN
]);
2763 // Настройки игроков и ботов:
2767 for i
:= nPl
+1 to nPlayers
do
2768 g_Player_Create(STD_PLAYER_MODEL
, _RGB(0, 0, 0), 0, True);
2771 procedure g_Game_StartServer(Map
: String; GameMode
: Byte;
2772 TimeLimit
, GoalLimit
: Word; MaxLives
: Byte;
2773 Options
: LongWord; nPlayers
: Byte;
2774 IPAddr
: LongWord; Port
: Word);
2777 g_Net_Slist_ServerClosed();
2779 e_WriteLog('Starting net game (server)...', TMsgType
.Notify
);
2781 g_Game_ClearLoading();
2784 gGameSettings
.GameType
:= GT_SERVER
;
2785 gGameSettings
.GameMode
:= GameMode
;
2786 gSwitchGameMode
:= GameMode
;
2787 gGameSettings
.TimeLimit
:= TimeLimit
;
2788 gGameSettings
.GoalLimit
:= GoalLimit
;
2789 gGameSettings
.MaxLives
:= IfThen(GameMode
= GM_CTF
, 0, MaxLives
);
2790 gGameSettings
.Options
:= Options
;
2792 gCoopTotalMonstersKilled
:= 0;
2793 gCoopTotalSecretsFound
:= 0;
2794 gCoopTotalMonsters
:= 0;
2795 gCoopTotalSecrets
:= 0;
2799 gLMSRespawn
:= LMS_RESPAWN_NONE
;
2800 gLMSRespawnTime
:= 0;
2801 gSpectLatchPID1
:= 0;
2802 gSpectLatchPID2
:= 0;
2804 g_Game_ExecuteEvent('ongamestart');
2806 // Установка размеров окна игрока
2807 g_Game_SetupScreenSize();
2809 // Режим наблюдателя:
2810 if nPlayers
= 0 then
2816 if nPlayers
>= 1 then
2818 // Создание первого игрока:
2819 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
2820 gPlayer1Settings
.Color
,
2821 gPlayer1Settings
.Team
, False));
2822 if gPlayer1
= nil then
2824 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
2828 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
2831 if nPlayers
>= 2 then
2833 // Создание второго игрока:
2834 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
2835 gPlayer2Settings
.Color
,
2836 gPlayer2Settings
.Team
, False));
2837 if gPlayer2
= nil then
2839 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
2843 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
2846 g_Game_SetLoadingText(_lc
[I_LOAD_HOST
], 0, False);
2847 if NetForwardPorts
then
2848 g_Game_SetLoadingText(_lc
[I_LOAD_PORTS
], 0, False);
2851 if not g_Net_Host(IPAddr
, Port
, NetMaxClients
) then
2853 g_FatalError(_lc
[I_NET_MSG
] + Format(_lc
[I_NET_ERR_HOST
], [Port
]));
2857 g_Net_Slist_Set(NetMasterList
);
2859 g_Net_Slist_ServerStarted();
2861 // Загрузка и запуск карты:
2862 if not g_Game_StartMap(false{asMegawad}, Map
, True) then
2864 g_Net_Slist_ServerClosed();
2865 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [Map
]));
2869 // Нет точек появления:
2870 if (g_Map_GetPointCount(RESPAWNPOINT_PLAYER1
) +
2871 g_Map_GetPointCount(RESPAWNPOINT_PLAYER2
) +
2872 g_Map_GetPointCount(RESPAWNPOINT_DM
) +
2873 g_Map_GetPointCount(RESPAWNPOINT_RED
)+
2874 g_Map_GetPointCount(RESPAWNPOINT_BLUE
)) < 1 then
2876 g_Net_Slist_ServerClosed();
2877 g_FatalError(_lc
[I_GAME_ERROR_GET_SPAWN
]);
2881 // Настройки игроков и ботов:
2884 g_Net_Slist_ServerMapStarted();
2885 NetState
:= NET_STATE_GAME
;
2888 procedure g_Game_StartClient(Addr
: String; Port
: Word; PW
: String);
2903 e_WriteLog('Starting net game (client)...', TMsgType
.Notify
);
2904 e_WriteLog('NET: Trying to connect to ' + Addr
+ ':' + IntToStr(Port
) + '...', TMsgType
.Notify
);
2906 g_Game_ClearLoading();
2909 gGameSettings
.GameType
:= GT_CLIENT
;
2911 gCoopTotalMonstersKilled
:= 0;
2912 gCoopTotalSecretsFound
:= 0;
2913 gCoopTotalMonsters
:= 0;
2914 gCoopTotalSecrets
:= 0;
2918 g_Game_ExecuteEvent('ongamestart');
2920 // Установка размеров окон игроков:
2921 g_Game_SetupScreenSize();
2923 NetState
:= NET_STATE_AUTH
;
2925 g_Game_SetLoadingText(_lc
[I_LOAD_CONNECT
], 0, False);
2927 // create (or update) map/resource databases
2928 g_Res_CreateDatabases(true);
2930 gLMSRespawn
:= LMS_RESPAWN_NONE
;
2931 gLMSRespawnTime
:= 0;
2932 gSpectLatchPID1
:= 0;
2933 gSpectLatchPID2
:= 0;
2936 if not g_Net_Connect(Addr
, Port
) then
2938 g_FatalError(_lc
[I_NET_MSG
] + _lc
[I_NET_ERR_CONN
]);
2939 NetState
:= NET_STATE_NONE
;
2943 g_Game_SetLoadingText(_lc
[I_LOAD_SEND_INFO
], 0, False);
2945 g_Game_SetLoadingText(_lc
[I_LOAD_WAIT_INFO
], 0, False);
2950 // fuck! https://www.mail-archive.com/enet-discuss@cubik.org/msg00852.html
2951 // tl;dr: on shitdows, we can get -1 sometimes, and it is *NOT* a failure.
2952 // thank you, enet. let's ignore failures altogether then.
2953 while (enet_host_service(NetHost
, @NetEvent
, 50) > 0) do
2955 if (NetEvent
.kind
= ENET_EVENT_TYPE_RECEIVE
) then
2957 if (NetEvent
.channelID
= NET_CHAN_DOWNLOAD_EX
) then
2959 // ignore all download packets, they're processed by separate code
2960 enet_packet_destroy(NetEvent
.packet
);
2963 Ptr
:= NetEvent
.packet
^.data
;
2964 if not InMsg
.Init(Ptr
, NetEvent
.packet
^.dataLength
, True) then
2966 enet_packet_destroy(NetEvent
.packet
);
2970 InMsg
.ReadLongWord(); // skip size
2971 MID
:= InMsg
.ReadByte();
2973 if (MID
= NET_MSG_INFO
) and (State
= 0) then
2975 NetMyID
:= InMsg
.ReadByte();
2976 NetPlrUID1
:= InMsg
.ReadWord();
2978 WadName
:= InMsg
.ReadString();
2979 Map
:= InMsg
.ReadString();
2981 gWADHash
:= InMsg
.ReadMD5();
2983 gGameSettings
.GameMode
:= InMsg
.ReadByte();
2984 gSwitchGameMode
:= gGameSettings
.GameMode
;
2985 gGameSettings
.GoalLimit
:= InMsg
.ReadWord();
2986 gGameSettings
.TimeLimit
:= InMsg
.ReadWord();
2987 gGameSettings
.MaxLives
:= InMsg
.ReadByte();
2988 gGameSettings
.Options
:= InMsg
.ReadLongWord();
2989 T
:= InMsg
.ReadLongWord();
2991 //newResPath := g_Res_SearchSameWAD(MapsDir, WadName, gWADHash);
2992 //if newResPath = '' then
2994 //g_Game_SetLoadingText(_lc[I_LOAD_DL_RES], 0, False);
2995 newResPath
:= g_Res_DownloadMapWAD(ExtractFileName(WadName
), gWADHash
);
2996 if newResPath
= '' then
2998 g_FatalError(_lc
[I_NET_ERR_HASH
]);
2999 enet_packet_destroy(NetEvent
.packet
);
3000 NetState
:= NET_STATE_NONE
;
3003 e_LogWritefln('using downloaded map wad [%s] for [%s]`', [newResPath
, WadName
], TMsgType
.Notify
);
3005 //newResPath := ExtractRelativePath(MapsDir, newResPath);
3008 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
3009 gPlayer1Settings
.Color
,
3010 gPlayer1Settings
.Team
, False));
3012 if gPlayer1
= nil then
3014 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
3016 enet_packet_destroy(NetEvent
.packet
);
3017 NetState
:= NET_STATE_NONE
;
3021 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
3022 gPlayer1
.UID
:= NetPlrUID1
;
3023 gPlayer1
.Reset(True);
3025 if not g_Game_StartMap(false{asMegawad}, newResPath
+ ':\' + Map
, True) then
3027 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [WadName
+ ':\' + Map
]));
3029 enet_packet_destroy(NetEvent
.packet
);
3030 NetState
:= NET_STATE_NONE
;
3038 enet_packet_destroy(NetEvent
.packet
);
3042 enet_packet_destroy(NetEvent
.packet
);
3046 if (NetEvent
.kind
= ENET_EVENT_TYPE_DISCONNECT
) then
3049 if (NetEvent
.data
<= NET_DISC_MAX
) then
3050 g_Console_Add(_lc
[I_NET_MSG_ERROR
] + _lc
[I_NET_ERR_CONN
] + ' ' +
3051 _lc
[TStrings_Locale(Cardinal(I_NET_DISC_NONE
) + NetEvent
.data
)], True);
3058 ProcessLoading(true);
3060 if g_Net_UserRequestExit() then
3069 g_FatalError(_lc
[I_NET_MSG
] + _lc
[I_NET_ERR_CONN
]);
3070 NetState
:= NET_STATE_NONE
;
3075 NetState
:= NET_STATE_GAME
;
3076 MC_SEND_FullStateRequest
;
3077 e_WriteLog('NET: Connection successful.', TMsgType
.Notify
);
3081 lastAsMegaWad
: Boolean = false;
3083 procedure g_Game_ChangeMap(const MapPath
: String);
3087 g_Game_ClearLoading();
3089 Force
:= gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
];
3090 // Если уровень завершился по триггеру Выход, не очищать инвентарь
3091 if gExitByTrigger
then
3094 gExitByTrigger
:= False;
3096 if not g_Game_StartMap(lastAsMegaWad
, MapPath
, Force
) then
3097 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [MapPath
]));
3100 procedure g_Game_Restart();
3104 if g_Game_IsClient
then
3106 map
:= g_ExtractFileName(gMapInfo
.Map
);
3107 e_LogWritefln('g_Game_Restart: map = "%s" gCurrentMapFileName = "%s"', [map
, gCurrentMapFileName
]);
3111 g_Game_ClearLoading();
3112 g_Game_StartMap(lastAsMegaWad
, Map
, True, gCurrentMapFileName
);
3115 function g_Game_StartMap (asMegawad
: Boolean; Map
: String; Force
: Boolean = False; const oldMapPath
: AnsiString=''): Boolean;
3117 NewWAD
, ResName
: String;
3121 g_Map_Free((Map
<> gCurrentMapFileName
) and (oldMapPath
<> gCurrentMapFileName
));
3122 g_Player_RemoveAllCorpses();
3124 if (not g_Game_IsClient
) and
3125 (gSwitchGameMode
<> gGameSettings
.GameMode
) and
3126 (gGameSettings
.GameMode
<> GM_SINGLE
) then
3128 if gSwitchGameMode
= GM_CTF
then
3129 gGameSettings
.MaxLives
:= 0;
3130 gGameSettings
.GameMode
:= gSwitchGameMode
;
3133 gSwitchGameMode
:= gGameSettings
.GameMode
;
3135 g_Player_ResetTeams();
3137 lastAsMegaWad
:= asMegawad
;
3138 if isWadPath(Map
) then
3140 NewWAD
:= g_ExtractWadName(Map
);
3141 ResName
:= g_ExtractFileName(Map
);
3142 if g_Game_IsServer
then
3144 nws
:= findDiskWad(NewWAD
);
3145 //writeln('000: Map=[', Map, ']; nws=[', nws, ']; NewWAD=[', NewWAD, ']');
3148 if (length(nws
) = 0) then nws
:= e_FindWad(MegawadDirs
, NewWAD
);
3149 if (length(nws
) = 0) then nws
:= e_FindWad(MapDirs
, NewWAD
);
3153 if (length(nws
) = 0) then nws
:= e_FindWad(MapDirs
, NewWAD
);
3154 if (length(nws
) = 0) then nws
:= e_FindWad(MegawadDirs
, NewWAD
);
3156 //if (length(nws) = 0) then nws := e_FindWad(MapDownloadDirs, NewWAD);
3157 //writeln('001: Map=[', Map, ']; nws=[', nws, ']; NewWAD=[', NewWAD, ']');
3159 if (length(nws
) = 0) then
3161 ResName
:= ''; // failed
3166 if (g_Game_IsNet
) then gWADHash
:= MD5File(nws
);
3167 //writeln('********: nws=', nws, ' : Map=', Map, ' : nw=', NewWAD, ' : resname=', ResName);
3168 g_Game_LoadWAD(NewWAD
);
3173 // hash received in MC_RECV_GameEvent -> NET_EV_MAPSTART
3174 NewWAD
:= g_Game_ClientWAD(NewWAD
, gWADHash
);
3179 NewWAD
:= gGameSettings
.WAD
;
3185 //writeln('********: gsw=', gGameSettings.WAD, '; rn=', ResName);
3187 if (ResName
<> '') and (NewWAD
<> '') then
3189 //result := g_Map_Load(gGameSettings.WAD + ':\' + ResName);
3190 result
:= g_Map_Load(NewWAD
+':\'+ResName
);
3194 g_Player_ResetAll(Force
or gLastMap
, gGameSettings
.GameType
= GT_SINGLE
);
3196 gState
:= STATE_NONE
;
3197 g_ActiveWindow
:= nil;
3203 if gGameSettings
.GameMode
= GM_CTF
then
3205 g_Map_ResetFlag(FLAG_RED
);
3206 g_Map_ResetFlag(FLAG_BLUE
);
3207 // CTF, а флагов нет:
3208 if not g_Map_HaveFlagPoints() then
3209 g_SimpleError(_lc
[I_GAME_ERROR_CTF
]);
3214 gState
:= STATE_MENU
;
3219 gPauseMain
:= false;
3220 gPauseHolmes
:= false;
3221 NetTimeToUpdate
:= 1;
3222 NetTimeToReliable
:= 0;
3223 NetTimeToMaster
:= NetMasterRate
;
3224 gSpectLatchPID1
:= 0;
3225 gSpectLatchPID2
:= 0;
3226 gMissionFailed
:= False;
3229 gCoopMonstersKilled
:= 0;
3230 gCoopSecretsFound
:= 0;
3232 gVoteInProgress
:= False;
3233 gVotePassed
:= False;
3239 if not gGameOn
then Exit
;
3241 g_Game_SpectateCenterView();
3243 if g_Game_IsServer
then
3245 if (gGameSettings
.MaxLives
> 0) and (gGameSettings
.WarmupTime
> 0) then
3247 gLMSRespawn
:= LMS_RESPAWN_WARMUP
;
3248 gLMSRespawnTime
:= gTime
+ gGameSettings
.WarmupTime
*1000;
3249 gLMSSoftSpawn
:= True;
3250 if g_Game_IsNet
then
3251 MH_SEND_GameEvent(NET_EV_LMS_WARMUP
, gLMSRespawnTime
- gTime
);
3255 gLMSRespawn
:= LMS_RESPAWN_NONE
;
3256 gLMSRespawnTime
:= 0;
3260 if NetMode
= NET_SERVER
then
3262 MH_SEND_GameEvent(NET_EV_MAPSTART
, gGameSettings
.GameMode
, Map
);
3265 g_Net_Slist_ServerMapStarted();
3267 if NetClients
<> nil then
3268 for I
:= 0 to High(NetClients
) do
3269 if NetClients
[I
].Used
then
3271 NetClients
[I
].Voted
:= False;
3272 if NetClients
[I
].RequestedFullUpdate
then
3274 MH_SEND_Everything((NetClients
[I
].State
= NET_STATE_AUTH
), I
);
3275 NetClients
[I
].RequestedFullUpdate
:= False;
3279 g_Net_UnbanNonPermHosts();
3284 gCoopTotalMonstersKilled
:= 0;
3285 gCoopTotalSecretsFound
:= 0;
3286 gCoopTotalMonsters
:= 0;
3287 gCoopTotalSecrets
:= 0;
3291 g_Game_ExecuteEvent('onmapstart');
3294 procedure SetFirstLevel
;
3298 MapList
:= g_Map_GetMapsList(gGameSettings
.WAD
);
3299 if MapList
= nil then
3302 SortSArray(MapList
);
3303 gNextMap
:= MapList
[Low(MapList
)];
3308 procedure g_Game_ExitLevel(const Map
: AnsiString);
3312 gCoopTotalMonstersKilled
:= gCoopTotalMonstersKilled
+ gCoopMonstersKilled
;
3313 gCoopTotalSecretsFound
:= gCoopTotalSecretsFound
+ gCoopSecretsFound
;
3314 gCoopTotalMonsters
:= gCoopTotalMonsters
+ gTotalMonsters
;
3315 gCoopTotalSecrets
:= gCoopTotalSecrets
+ gSecretsCount
;
3317 // Вышли в выход в Одиночной игре:
3318 if gGameSettings
.GameType
= GT_SINGLE
then
3319 gExit
:= EXIT_ENDLEVELSINGLE
3320 else // Вышли в выход в Своей игре
3322 gExit
:= EXIT_ENDLEVELCUSTOM
;
3323 if gGameSettings
.GameMode
= GM_COOP
then
3324 g_Player_RememberAll
;
3326 if not g_Map_Exist(gGameSettings
.WAD
+ ':\' + gNextMap
) then
3329 if gGameSettings
.GameMode
= GM_COOP
then
3332 gStatsPressed
:= True;
3333 gNextMap
:= 'MAP01';
3335 if not g_Map_Exist(gGameSettings
.WAD
+ ':\' + gNextMap
) then
3338 if g_Game_IsNet
then
3340 MH_SEND_GameStats();
3341 MH_SEND_CoopStats();
3347 procedure g_Game_RestartLevel();
3351 if gGameSettings
.GameMode
= GM_SINGLE
then
3356 gExit
:= EXIT_ENDLEVELCUSTOM
;
3357 Map
:= g_ExtractFileName(gMapInfo
.Map
);
3361 function g_Game_ClientWAD (NewWAD
: String; const WHash
: TMD5Digest
): AnsiString;
3363 gWAD
{, xwad}: String;
3366 if not g_Game_IsClient
then Exit
;
3367 //e_LogWritefln('*** g_Game_ClientWAD: `%s`', [NewWAD]);
3369 gWAD
:= g_Res_DownloadMapWAD(ExtractFileName(NewWAD
), WHash
);
3374 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_WAD
], [ExtractFileName(NewWAD
)]));
3378 e_LogWritefln('using downloaded client map wad [%s] for [%s]', [gWAD
, NewWAD
], TMsgType
.Notify
);
3381 g_Game_LoadWAD(NewWAD
);
3385 if LowerCase(NewWAD) = LowerCase(gGameSettings.WAD) then Exit;
3386 gWAD := g_Res_SearchSameWAD(MapsDir, ExtractFileName(NewWAD), WHash);
3389 g_Game_SetLoadingText(_lc[I_LOAD_DL_RES], 0, False);
3390 gWAD := g_Res_DownloadMapWAD(ExtractFileName(NewWAD), WHash);
3394 g_FatalError(Format(_lc[I_GAME_ERROR_MAP_WAD], [ExtractFileName(NewWAD)]));
3398 NewWAD := ExtractRelativePath(MapsDir, gWAD);
3399 g_Game_LoadWAD(NewWAD);
3403 procedure g_Game_RestartRound(NoMapRestart
: Boolean = False);
3405 i
, n
, nb
, nr
: Integer;
3407 if not g_Game_IsServer
then Exit
;
3408 if gLMSRespawn
= LMS_RESPAWN_NONE
then Exit
;
3409 gLMSRespawn
:= LMS_RESPAWN_NONE
;
3410 gLMSRespawnTime
:= 0;
3413 if (gGameSettings
.GameMode
= GM_COOP
) and not NoMapRestart
then
3415 gMissionFailed
:= True;
3416 g_Game_RestartLevel
;
3420 n
:= 0; nb
:= 0; nr
:= 0;
3421 for i
:= Low(gPlayers
) to High(gPlayers
) do
3422 if (gPlayers
[i
] <> nil) and
3423 ((not gPlayers
[i
].FSpectator
) or gPlayers
[i
].FWantsInGame
or
3424 (gPlayers
[i
] is TBot
)) then
3427 if gPlayers
[i
].Team
= TEAM_RED
then Inc(nr
)
3428 else if gPlayers
[i
].Team
= TEAM_BLUE
then Inc(nb
)
3431 if (n
< 1) or ((gGameSettings
.GameMode
= GM_TDM
) and ((nr
= 0) or (nb
= 0))) then
3433 // wait a second until the fuckers finally decide to join
3434 gLMSRespawn
:= LMS_RESPAWN_WARMUP
;
3435 gLMSRespawnTime
:= gTime
+ gGameSettings
.WarmupTime
*1000;
3436 gLMSSoftSpawn
:= NoMapRestart
;
3437 if g_Game_IsNet
then
3438 MH_SEND_GameEvent(NET_EV_LMS_WARMUP
, gLMSRespawnTime
- gTime
);
3442 g_Player_RemoveAllCorpses
;
3443 g_Game_Message(_lc
[I_MESSAGE_LMS_START
], 144);
3444 if g_Game_IsNet
then
3445 MH_SEND_GameEvent(NET_EV_LMS_START
);
3447 for i
:= Low(gPlayers
) to High(gPlayers
) do
3449 if gPlayers
[i
] = nil then continue
;
3450 if gPlayers
[i
] is TBot
then gPlayers
[i
].FWantsInGame
:= True;
3451 // don't touch normal spectators
3452 if gPlayers
[i
].FSpectator
and not gPlayers
[i
].FWantsInGame
then
3454 gPlayers
[i
].FNoRespawn
:= True;
3455 gPlayers
[i
].Lives
:= 0;
3456 if g_Game_IsNet
then
3457 MH_SEND_PlayerStats(gPlayers
[I
].UID
);
3460 gPlayers
[i
].FNoRespawn
:= False;
3461 gPlayers
[i
].Lives
:= gGameSettings
.MaxLives
;
3462 gPlayers
[i
].Respawn(False, True);
3463 if gGameSettings
.GameMode
= GM_COOP
then
3465 gPlayers
[i
].Frags
:= 0;
3466 gPlayers
[i
].RecallState
;
3468 if (gPlayer1
= nil) and (gSpectLatchPID1
> 0) then
3469 gPlayer1
:= g_Player_Get(gSpectLatchPID1
);
3470 if (gPlayer2
= nil) and (gSpectLatchPID2
> 0) then
3471 gPlayer2
:= g_Player_Get(gSpectLatchPID2
);
3474 g_Items_RestartRound();
3476 gLMSSoftSpawn
:= False;
3479 function g_Game_GetFirstMap(WAD
: String): String;
3483 MapList
:= g_Map_GetMapsList(WAD
);
3484 if MapList
= nil then
3487 SortSArray(MapList
);
3488 Result
:= MapList
[Low(MapList
)];
3490 if not g_Map_Exist(WAD
+ ':\' + Result
) then
3496 function g_Game_GetNextMap(): String;
3503 MapList
:= g_Map_GetMapsList(gGameSettings
.WAD
);
3504 if MapList
= nil then
3507 Map
:= g_ExtractFileName(gMapInfo
.Map
);
3509 SortSArray(MapList
);
3511 for I
:= Low(MapList
) to High(MapList
) do
3512 if Map
= MapList
[I
] then
3518 if MapIndex
<> -255 then
3520 if MapIndex
= High(MapList
) then
3521 Result
:= MapList
[Low(MapList
)]
3523 Result
:= MapList
[MapIndex
+ 1];
3525 if not g_Map_Exist(gGameSettings
.WAD
+ ':\' + Result
) then Result
:= Map
;
3531 procedure g_Game_NextLevel();
3533 if gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
, GM_COOP
] then
3534 gExit
:= EXIT_ENDLEVELCUSTOM
3537 gExit
:= EXIT_ENDLEVELSINGLE
;
3541 if gNextMap
<> '' then Exit
;
3542 gNextMap
:= g_Game_GetNextMap();
3545 function g_Game_IsTestMap(): Boolean;
3547 result
:= StrEquCI1251(TEST_MAP_NAME
, g_ExtractFileName(gMapInfo
.Map
));
3550 procedure g_Game_DeleteTestMap();
3553 //MapName: AnsiString;
3561 a
:= Pos('.wad:\', toLowerCase1251(gMapToDelete
));
3562 if (a
= 0) then a
:= Pos('.wad:/', toLowerCase1251(gMapToDelete
));
3563 if (a
= 0) then exit
;
3565 // Выделяем имя wad-файла и имя карты
3566 WadName
:= Copy(gMapToDelete
, 1, a
+3);
3567 Delete(gMapToDelete
, 1, a
+5);
3568 gMapToDelete
:= UpperCase(gMapToDelete
);
3570 //CopyMemory(@MapName[0], @gMapToDelete[1], Min(16, Length(gMapToDelete)));
3573 // Имя карты не стандартное тестовое:
3574 if MapName <> TEST_MAP_NAME then
3577 if not gTempDelete then
3579 time := g_GetFileTime(WadName);
3580 WAD := TWADFile.Create();
3583 if not WAD.ReadFile(WadName) then
3584 begin // Нет такого WAD-файла
3589 // Составляем список карт и ищем нужную:
3591 MapList := WAD.GetResourcesList('');
3593 if MapList <> nil then
3594 for a := 0 to High(MapList) do
3595 if MapList[a] = MapName then
3597 // Удаляем и сохраняем:
3598 WAD.RemoveResource('', MapName);
3599 WAD.SaveTo(WadName);
3604 g_SetFileTime(WadName, time);
3607 if gTempDelete
then DeleteFile(WadName
);
3610 procedure GameCVars(P
: SSArray
);
3613 stat
: TPlayerStatArray
;
3616 procedure ParseGameFlag(Flag
: LongWord; OffMsg
, OnMsg
: TStrings_Locale
; OnMapChange
: Boolean = False);
3620 if Length(P
) > 1 then
3625 gsGameFlags
:= gsGameFlags
or Flag
3627 gsGameFlags
:= gsGameFlags
and (not Flag
);
3629 if g_Game_IsServer
then
3632 gGameSettings
.Options
:= gGameSettings
.Options
or Flag
3634 gGameSettings
.Options
:= gGameSettings
.Options
and (not Flag
);
3635 if g_Game_IsNet
then MH_SEND_GameSettings
;
3639 if LongBool(gsGameFlags
and Flag
) then
3640 g_Console_Add(_lc
[OnMsg
])
3642 g_Console_Add(_lc
[OffMsg
]);
3644 if OnMapChange
and g_Game_IsServer
then
3645 g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
3650 cmd
:= LowerCase(P
[0]);
3652 if cmd
= 'g_gamemode' then
3654 if (Length(P
) > 1) then
3656 a
:= g_Game_TextToMode(P
[1]);
3657 if a
= GM_SINGLE
then a
:= GM_COOP
;
3658 gsGameMode
:= g_Game_ModeToText(a
);
3659 if g_Game_IsServer
then
3661 gSwitchGameMode
:= a
;
3662 if (gGameOn
and (gGameSettings
.GameMode
= GM_SINGLE
)) or
3663 (gState
= STATE_INTERSINGLE
) then
3664 gSwitchGameMode
:= GM_SINGLE
;
3666 gGameSettings
.GameMode
:= gSwitchGameMode
;
3670 if gSwitchGameMode
= gGameSettings
.GameMode
then
3671 g_Console_Add(Format(_lc
[I_MSG_GAMEMODE_CURRENT
],
3672 [g_Game_ModeToText(gGameSettings
.GameMode
)]))
3674 g_Console_Add(Format(_lc
[I_MSG_GAMEMODE_CHANGE
],
3675 [g_Game_ModeToText(gGameSettings
.GameMode
),
3676 g_Game_ModeToText(gSwitchGameMode
)]));
3678 else if cmd
= 'g_friendlyfire' then
3680 ParseGameFlag(GAME_OPTION_TEAMDAMAGE
, I_MSG_FRIENDLY_FIRE_OFF
, I_MSG_FRIENDLY_FIRE_ON
);
3682 else if cmd
= 'g_friendly_absorb_damage' then
3684 ParseGameFlag(GAME_OPTION_TEAMABSORBDAMAGE
, I_MSG_FRIENDLY_FIRE_OFF
, I_MSG_FRIENDLY_FIRE_ON
);
3686 else if cmd
= 'g_friendly_hit_trace' then
3688 ParseGameFlag(GAME_OPTION_TEAMHITTRACE
, I_MSG_FRIENDLY_FIRE_OFF
, I_MSG_FRIENDLY_FIRE_ON
);
3690 else if cmd
= 'g_friendly_hit_projectile' then
3692 ParseGameFlag(GAME_OPTION_TEAMHITPROJECTILE
, I_MSG_FRIENDLY_FIRE_OFF
, I_MSG_FRIENDLY_FIRE_ON
);
3694 else if cmd
= 'g_weaponstay' then
3696 ParseGameFlag(GAME_OPTION_WEAPONSTAY
, I_MSG_WEAPONSTAY_OFF
, I_MSG_WEAPONSTAY_ON
);
3698 else if cmd
= 'g_allow_exit' then
3700 ParseGameFlag(GAME_OPTION_ALLOWEXIT
, I_MSG_ALLOWEXIT_OFF
, I_MSG_ALLOWEXIT_ON
, True);
3702 else if cmd
= 'g_allow_monsters' then
3704 ParseGameFlag(GAME_OPTION_MONSTERS
, I_MSG_ALLOWMON_OFF
, I_MSG_ALLOWMON_ON
, True);
3706 else if cmd
= 'g_bot_vsplayers' then
3708 ParseGameFlag(GAME_OPTION_BOTVSPLAYER
, I_MSG_BOTSVSPLAYERS_OFF
, I_MSG_BOTSVSPLAYERS_ON
);
3710 else if cmd
= 'g_bot_vsmonsters' then
3712 ParseGameFlag(GAME_OPTION_BOTVSMONSTER
, I_MSG_BOTSVSMONSTERS_OFF
, I_MSG_BOTSVSMONSTERS_ON
);
3714 else if cmd
= 'g_dm_keys' then
3716 ParseGameFlag(GAME_OPTION_DMKEYS
, I_MSG_DMKEYS_OFF
, I_MSG_DMKEYS_ON
, True);
3718 else if cmd
= 'g_gameflags' then
3720 if Length(P
) > 1 then
3722 gsGameFlags
:= StrToDWordDef(P
[1], gsGameFlags
);
3723 if g_Game_IsServer
then
3725 gGameSettings
.Options
:= gsGameFlags
;
3726 if g_Game_IsNet
then MH_SEND_GameSettings
;
3730 g_Console_Add(Format('%s %u', [cmd
, gsGameFlags
]));
3732 else if cmd
= 'g_warmup_time' then
3734 if Length(P
) > 1 then
3736 gsWarmupTime
:= nclamp(StrToIntDef(P
[1], gsWarmupTime
), 0, $FFFF);
3737 if g_Game_IsServer
then
3739 gGameSettings
.WarmupTime
:= gsWarmupTime
;
3740 // extend warmup if it's already going
3741 if gLMSRespawn
= LMS_RESPAWN_WARMUP
then
3743 gLMSRespawnTime
:= gTime
+ gsWarmupTime
* 1000;
3744 if g_Game_IsNet
then MH_SEND_GameEvent(NET_EV_LMS_WARMUP
, gLMSRespawnTime
- gTime
);
3746 if g_Game_IsNet
then MH_SEND_GameSettings
;
3750 g_Console_Add(Format(_lc
[I_MSG_WARMUP
], [Integer(gsWarmupTime
)]));
3751 if g_Game_IsServer
then g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
3753 else if cmd
= 'g_spawn_invul' then
3755 if Length(P
) > 1 then
3757 gsSpawnInvul
:= nclamp(StrToIntDef(P
[1], gsSpawnInvul
), 0, $FFFF);
3758 if g_Game_IsServer
then
3760 gGameSettings
.SpawnInvul
:= gsSpawnInvul
;
3761 if g_Game_IsNet
then MH_SEND_GameSettings
;
3765 g_Console_Add(Format('%s %d', [cmd
, Integer(gsSpawnInvul
)]));
3767 else if cmd
= 'g_item_respawn_time' then
3769 if Length(P
) > 1 then
3771 gsItemRespawnTime
:= nclamp(StrToIntDef(P
[1], gsItemRespawnTime
), 0, $FFFF);
3772 if g_Game_IsServer
then
3774 gGameSettings
.ItemRespawnTime
:= gsItemRespawnTime
;
3775 if g_Game_IsNet
then MH_SEND_GameSettings
;
3779 g_Console_Add(Format('%s %d', [cmd
, Integer(gsItemRespawnTime
)]));
3780 if g_Game_IsServer
then g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
3782 else if cmd
= 'sv_intertime' then
3784 if (Length(P
) > 1) then
3785 gDefInterTime
:= Min(Max(StrToIntDef(P
[1], gDefInterTime
), -1), 120);
3787 g_Console_Add(cmd
+ ' = ' + IntToStr(gDefInterTime
));
3789 else if cmd
= 'g_max_particles' then
3791 if Length(p
) = 2 then
3793 a
:= Max(0, StrToInt(p
[1]));
3796 else if Length(p
) = 1 then
3798 e_LogWritefln('%s', [g_GFX_GetMax()])
3802 e_LogWritefln('usage: %s <n>', [cmd
])
3805 else if cmd
= 'g_max_shells' then
3807 if Length(p
) = 2 then
3809 a
:= Max(0, StrToInt(p
[1]));
3812 else if Length(p
) = 1 then
3814 e_LogWritefln('%s', [g_Shells_GetMax()])
3818 e_LogWritefln('usage: %s <n>', [cmd
])
3821 else if cmd
= 'g_max_gibs' then
3823 if Length(p
) = 2 then
3825 a
:= Max(0, StrToInt(p
[1]));
3828 else if Length(p
) = 1 then
3830 e_LogWritefln('%s', [g_Gibs_GetMax()])
3834 e_LogWritefln('usage: %s <n>', [cmd
])
3837 else if cmd
= 'g_max_corpses' then
3839 if Length(p
) = 2 then
3841 a
:= Max(0, StrToInt(p
[1]));
3844 else if Length(p
) = 1 then
3846 e_LogWritefln('%s', [g_Corpses_GetMax()])
3850 e_LogWritefln('usage: %s <n>', [cmd
])
3853 else if cmd
= 'g_scorelimit' then
3855 if Length(P
) > 1 then
3857 gsGoalLimit
:= nclamp(StrToIntDef(P
[1], gsGoalLimit
), 0, $FFFF);
3859 if g_Game_IsServer
then
3862 if gGameSettings
.GameMode
= GM_DM
then
3864 stat
:= g_Player_GetStats();
3866 for a
:= 0 to High(stat
) do
3867 if stat
[a
].Frags
> b
then
3871 b
:= Max(gTeamStat
[TEAM_RED
].Goals
, gTeamStat
[TEAM_BLUE
].Goals
);
3873 // if someone has a higher score, set it to that instead
3874 gsGoalLimit
:= max(gsGoalLimit
, b
);
3875 gGameSettings
.GoalLimit
:= gsGoalLimit
;
3877 if g_Game_IsNet
then MH_SEND_GameSettings
;
3881 g_Console_Add(Format(_lc
[I_MSG_SCORE_LIMIT
], [Integer(gsGoalLimit
)]));
3883 else if cmd
= 'g_timelimit' then
3885 if Length(P
) > 1 then
3887 gsTimeLimit
:= nclamp(StrToIntDef(P
[1], gsTimeLimit
), 0, $FFFF);
3888 if g_Game_IsServer
then
3890 gGameSettings
.TimeLimit
:= gsTimeLimit
;
3891 if g_Game_IsNet
then MH_SEND_GameSettings
;
3894 g_Console_Add(Format(_lc
[I_MSG_TIME_LIMIT
],
3895 [gsTimeLimit
div 3600,
3896 (gsTimeLimit
div 60) mod 60,
3897 gsTimeLimit
mod 60]));
3899 else if cmd
= 'g_maxlives' then
3901 if Length(P
) > 1 then
3903 gsMaxLives
:= nclamp(StrToIntDef(P
[1], gsMaxLives
), 0, $FFFF);
3904 if g_Game_IsServer
then
3906 gGameSettings
.MaxLives
:= gsMaxLives
;
3907 if g_Game_IsNet
then MH_SEND_GameSettings
;
3911 g_Console_Add(Format(_lc
[I_MSG_LIVES
], [Integer(gsMaxLives
)]));
3915 procedure PlayerSettingsCVars(P
: SSArray
);
3920 function ParseTeam(s
: string): Byte;
3924 'red', '1': result
:= TEAM_RED
;
3925 'blue', '2': result
:= TEAM_BLUE
;
3926 else result
:= TEAM_NONE
;
3930 cmd
:= LowerCase(P
[0]);
3934 if (Length(P
) > 1) then
3936 gPlayer1Settings
.Name
:= b_Text_Unformat(P
[1]);
3937 if g_Game_IsClient
then
3938 MC_SEND_PlayerSettings
3939 else if gGameOn
and (gPlayer1
<> nil) then
3941 gPlayer1
.Name
:= b_Text_Unformat(P
[1]);
3942 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer1
.UID
);
3948 if (Length(P
) > 1) then
3950 gPlayer2Settings
.Name
:= b_Text_Unformat(P
[1]);
3951 if g_Game_IsClient
then
3952 MC_SEND_PlayerSettings
3953 else if gGameOn
and (gPlayer2
<> nil) then
3955 gPlayer2
.Name
:= b_Text_Unformat(P
[1]);
3956 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer2
.UID
);
3962 if Length(P
) > 3 then
3964 gPlayer1Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
3965 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
3966 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
3967 if g_Game_IsClient
then
3968 MC_SEND_PlayerSettings
3969 else if gGameOn
and (gPlayer1
<> nil) then
3971 gPlayer1
.SetColor(gPlayer1Settings
.Color
);
3972 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer1
.UID
);
3978 if Length(P
) > 3 then
3980 gPlayer2Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
3981 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
3982 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
3983 if g_Game_IsClient
then
3984 MC_SEND_PlayerSettings
3985 else if gGameOn
and (gPlayer2
<> nil) then
3987 gPlayer2
.SetColor(gPlayer2Settings
.Color
);
3988 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer2
.UID
);
3994 if (Length(P
) > 1) then
3996 gPlayer1Settings
.Model
:= P
[1];
3997 if g_Game_IsClient
then
3998 MC_SEND_PlayerSettings
3999 else if gGameOn
and (gPlayer1
<> nil) then
4001 gPlayer1
.FActualModelName
:= gPlayer1Settings
.Model
;
4002 gPlayer1
.SetModel(gPlayer1Settings
.Model
);
4003 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer1
.UID
);
4009 if (Length(P
) > 1) then
4011 gPlayer2Settings
.Model
:= P
[1];
4012 if g_Game_IsClient
then
4013 MC_SEND_PlayerSettings
4014 else if gGameOn
and (gPlayer2
<> nil) then
4016 gPlayer2
.FActualModelName
:= gPlayer2Settings
.Model
;
4017 gPlayer2
.SetModel(gPlayer2Settings
.Model
);
4018 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer2
.UID
);
4024 // TODO: switch teams if in game or store this separately
4025 if (Length(P
) > 1) then
4027 team
:= ParseTeam(P
[1]);
4028 if team
= TEAM_NONE
then
4029 g_Console_Add('expected ''red'', ''blue'', 1 or 2')
4030 else if not gGameOn
and not g_Game_IsNet
then
4031 gPlayer1Settings
.Team
:= team
4033 g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
4038 // TODO: switch teams if in game or store this separately
4039 if (Length(P
) > 1) then
4041 team
:= ParseTeam(P
[1]);
4042 if team
= TEAM_NONE
then
4043 g_Console_Add('expected ''red'', ''blue'', 1 or 2')
4044 else if not gGameOn
and not g_Game_IsNet
then
4045 gPlayer2Settings
.Team
:= team
4047 g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
4053 procedure PrintHeapStats();
4057 hs
:= GetFPCHeapStatus();
4058 e_LogWriteLn ('v===== heap status =====v');
4059 e_LogWriteFln('max heap size = %d k', [hs
.MaxHeapSize
div 1024]);
4060 e_LogWriteFln('max heap used = %d k', [hs
.MaxHeapUsed
div 1024]);
4061 e_LogWriteFln('cur heap size = %d k', [hs
.CurrHeapSize
div 1024]);
4062 e_LogWriteFln('cur heap used = %d k', [hs
.CurrHeapUsed
div 1024]);
4063 e_LogWriteFln('cur heap free = %d k', [hs
.CurrHeapFree
div 1024]);
4064 e_LogWriteLn ('^=======================^');
4067 procedure DebugCommands(P
: SSArray
);
4074 // Команды отладочного режима:
4075 if {gDebugMode}conIsCheatsEnabled
then
4077 cmd
:= LowerCase(P
[0]);
4078 if cmd
= 'd_window' then
4080 g_Console_Add(Format('gScreenWidth = %d, gScreenHeight = %d', [gScreenWidth
, gScreenHeight
]));
4081 g_Console_Add(Format('gScreenWidth = %d, gScreenHeight = %d', [gScreenWidth
, gScreenHeight
]));
4083 else if cmd
= 'd_sounds' then
4085 if (Length(P
) > 1) and
4086 ((P
[1] = '1') or (P
[1] = '0')) then
4087 g_Debug_Sounds
:= (P
[1][1] = '1');
4089 g_Console_Add(Format('d_sounds is %d', [Byte(g_Debug_Sounds
)]));
4091 else if cmd
= 'd_frames' then
4093 if (Length(P
) > 1) and
4094 ((P
[1] = '1') or (P
[1] = '0')) then
4095 g_Debug_Frames
:= (P
[1][1] = '1');
4097 g_Console_Add(Format('d_frames is %d', [Byte(g_Debug_Frames
)]));
4099 else if cmd
= 'd_winmsg' then
4101 if (Length(P
) > 1) and
4102 ((P
[1] = '1') or (P
[1] = '0')) then
4103 g_Debug_WinMsgs
:= (P
[1][1] = '1');
4105 g_Console_Add(Format('d_winmsg is %d', [Byte(g_Debug_WinMsgs
)]));
4107 else if (cmd
= 'd_monoff') and not g_Game_IsNet
then
4109 if (Length(P
) > 1) and
4110 ((P
[1] = '1') or (P
[1] = '0')) then
4111 g_Debug_MonsterOff
:= (P
[1][1] = '1');
4113 g_Console_Add(Format('d_monoff is %d', [Byte(g_debug_MonsterOff
)]));
4115 else if (cmd
= 'd_botoff') and not g_Game_IsNet
then
4117 if Length(P
) > 1 then
4119 '0': g_debug_BotAIOff
:= 0;
4120 '1': g_debug_BotAIOff
:= 1;
4121 '2': g_debug_BotAIOff
:= 2;
4122 '3': g_debug_BotAIOff
:= 3;
4125 g_Console_Add(Format('d_botoff is %d', [g_debug_BotAIOff
]));
4127 else if cmd
= 'd_monster' then
4129 if gGameOn
and (gPlayer1
<> nil) and (gPlayer1
.alive
) and (not g_Game_IsNet
) then
4130 if Length(P
) < 2 then
4132 g_Console_Add(cmd
+ ' [ID | Name] [behaviour]');
4133 g_Console_Add('ID | Name');
4134 for b
:= MONSTER_DEMON
to MONSTER_MAN
do
4135 g_Console_Add(Format('%2d | %s', [b
, g_Mons_NameByTypeId(b
)]));
4136 conwriteln('behav. num'#10'normal 0'#10'killer 1'#10'maniac 2'#10'insane 3'#10'cannibal 4'#10'good 5');
4139 a
:= StrToIntDef(P
[1], 0);
4140 if (a
< MONSTER_DEMON
) or (a
> MONSTER_MAN
) then
4141 a
:= g_Mons_TypeIdByName(P
[1]);
4143 if (a
< MONSTER_DEMON
) or (a
> MONSTER_MAN
) then
4144 g_Console_Add(Format(_lc
[I_MSG_NO_MONSTER
], [P
[1]]))
4147 with gPlayer1
.Obj
do
4149 mon
:= g_Monsters_Create(a
,
4150 X
+ Rect
.X
+ (Rect
.Width
div 2),
4151 Y
+ Rect
.Y
+ Rect
.Height
,
4152 gPlayer1
.Direction
, True);
4154 if (Length(P
) > 2) and (mon
<> nil) then
4156 if (CompareText(P
[2], 'normal') = 0) then mon
.MonsterBehaviour
:= BH_NORMAL
4157 else if (CompareText(P
[2], 'killer') = 0) then mon
.MonsterBehaviour
:= BH_KILLER
4158 else if (CompareText(P
[2], 'maniac') = 0) then mon
.MonsterBehaviour
:= BH_MANIAC
4159 else if (CompareText(P
[2], 'insane') = 0) then mon
.MonsterBehaviour
:= BH_INSANE
4160 else if (CompareText(P
[2], 'cannibal') = 0) then mon
.MonsterBehaviour
:= BH_CANNIBAL
4161 else if (CompareText(P
[2], 'good') = 0) then mon
.MonsterBehaviour
:= BH_GOOD
4162 else if (CompareText(P
[2], 'friend') = 0) then mon
.MonsterBehaviour
:= BH_GOOD
4163 else if (CompareText(P
[2], 'friendly') = 0) then mon
.MonsterBehaviour
:= BH_GOOD
4164 else mon
.MonsterBehaviour
:= Min(Max(StrToIntDef(P
[2], BH_NORMAL
), BH_NORMAL
), BH_GOOD
);
4169 else if (cmd
= 'd_health') then
4171 if (Length(P
) > 1) and
4172 ((P
[1] = '1') or (P
[1] = '0')) then
4173 g_debug_HealthBar
:= (P
[1][1] = '1');
4175 g_Console_Add(Format('d_health is %d', [Byte(g_debug_HealthBar
)]));
4177 else if (cmd
= 'd_player') then
4179 if (Length(P
) > 1) and
4180 ((P
[1] = '1') or (P
[1] = '0')) then
4181 g_debug_Player
:= (P
[1][1] = '1');
4183 g_Console_Add(Format(cmd
+ ' is %d', [Byte(g_Debug_Player
)]));
4185 else if (cmd
= 'd_mem') then
4191 g_Console_Add(_lc
[I_MSG_NOT_DEBUG
]);
4195 procedure GameCheats(P
: SSArray
);
4201 if (not gGameOn
) or (not conIsCheatsEnabled
) then
4203 g_Console_Add('not available');
4209 g_Console_Add('where is the player?!');
4212 cmd
:= LowerCase(P
[0]);
4216 plr
.GodMode
:= not plr
.GodMode
;
4217 if plr
.GodMode
then g_Console_Add('player is godlike now') else g_Console_Add('player is mortal now');
4220 // give <health|exit|weapons|air|suit|jetpack|berserk|all>
4221 if cmd
= 'give' then
4223 if length(P
) < 2 then begin g_Console_Add('give what?!'); exit
; end;
4224 for f
:= 1 to High(P
) do
4226 cmd
:= LowerCase(P
[f
]);
4227 if cmd
= 'health' then begin plr
.RestoreHealthArmor(); g_Console_Add('player feels himself better'); continue
; end;
4228 if (cmd
= 'all') {or (cmd = 'weapons')} then begin plr
.AllRulez(False); g_Console_Add('player got the gifts'); continue
; end;
4229 if cmd
= 'exit' then
4231 if gTriggers
<> nil then
4233 for a
:= 0 to High(gTriggers
) do
4235 if gTriggers
[a
].TriggerType
= TRIGGER_EXIT
then
4237 g_Console_Add('player left the map');
4238 gExitByTrigger
:= True;
4239 //g_Game_ExitLevel(gTriggers[a].Data.MapName);
4240 g_Game_ExitLevel(gTriggers
[a
].tgcMap
);
4248 if cmd
= 'air' then begin plr
.GiveItem(ITEM_OXYGEN
); g_Console_Add('player got some air'); continue
; end;
4249 if cmd
= 'jetpack' then begin plr
.GiveItem(ITEM_JETPACK
); g_Console_Add('player got a jetpack'); continue
; end;
4250 if cmd
= 'suit' then begin plr
.GiveItem(ITEM_SUIT
); g_Console_Add('player got an envirosuit'); continue
; end;
4251 if cmd
= 'berserk' then begin plr
.GiveItem(ITEM_MEDKIT_BLACK
); g_Console_Add('player got a berserk pack'); continue
; end;
4252 if cmd
= 'backpack' then begin plr
.GiveItem(ITEM_AMMO_BACKPACK
); g_Console_Add('player got a backpack'); continue
; end;
4254 if cmd
= 'helmet' then begin plr
.GiveItem(ITEM_HELMET
); g_Console_Add('player got a helmet'); continue
; end;
4255 if cmd
= 'bottle' then begin plr
.GiveItem(ITEM_BOTTLE
); g_Console_Add('player got a bottle of health'); continue
; end;
4257 if cmd
= 'stimpack' then begin plr
.GiveItem(ITEM_MEDKIT_SMALL
); g_Console_Add('player got a stimpack'); continue
; end;
4258 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;
4260 if cmd
= 'greenarmor' then begin plr
.GiveItem(ITEM_ARMOR_GREEN
); g_Console_Add('player got a security armor'); continue
; end;
4261 if cmd
= 'bluearmor' then begin plr
.GiveItem(ITEM_ARMOR_BLUE
); g_Console_Add('player got a combat armor'); continue
; end;
4263 if (cmd
= 'megasphere') or (cmd
= 'mega') then begin plr
.GiveItem(ITEM_SPHERE_BLUE
); g_Console_Add('player got a megasphere'); continue
; end;
4264 if (cmd
= 'soulsphere') or (cmd
= 'soul')then begin plr
.GiveItem(ITEM_SPHERE_WHITE
); g_Console_Add('player got a soul sphere'); continue
; end;
4266 if (cmd
= 'invul') or (cmd
= 'invulnerability') then begin plr
.GiveItem(ITEM_INVUL
); g_Console_Add('player got invulnerability'); continue
; end;
4267 if (cmd
= 'invis') or (cmd
= 'invisibility') then begin plr
.GiveItem(ITEM_INVIS
); g_Console_Add('player got invisibility'); continue
; end;
4269 if cmd
= 'redkey' then begin plr
.GiveItem(ITEM_KEY_RED
); g_Console_Add('player got the red key'); continue
; end;
4270 if cmd
= 'greenkey' then begin plr
.GiveItem(ITEM_KEY_GREEN
); g_Console_Add('player got the green key'); continue
; end;
4271 if cmd
= 'bluekey' then begin plr
.GiveItem(ITEM_KEY_BLUE
); g_Console_Add('player got the blue key'); continue
; end;
4273 if (cmd
= 'shotgun') or (cmd
= 'sg') then begin plr
.GiveItem(ITEM_WEAPON_SHOTGUN1
); g_Console_Add('player got a shotgun'); continue
; end;
4274 if (cmd
= 'supershotgun') or (cmd
= 'ssg') then begin plr
.GiveItem(ITEM_WEAPON_SHOTGUN2
); g_Console_Add('player got a supershotgun'); continue
; end;
4275 if cmd
= 'chaingun' then begin plr
.GiveItem(ITEM_WEAPON_CHAINGUN
); g_Console_Add('player got a chaingun'); continue
; end;
4276 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;
4277 if cmd
= 'plasmagun' then begin plr
.GiveItem(ITEM_WEAPON_PLASMA
); g_Console_Add('player got a plasma gun'); continue
; end;
4278 if cmd
= 'bfg' then begin plr
.GiveItem(ITEM_WEAPON_BFG
); g_Console_Add('player got a BFG-9000'); continue
; end;
4280 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;
4281 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;
4282 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;
4283 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;
4284 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;
4285 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;
4287 if cmd
= 'superchaingun' then begin plr
.GiveItem(ITEM_WEAPON_SUPERPULEMET
); g_Console_Add('player got a superchaingun'); continue
; end;
4288 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;
4290 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;
4291 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;
4293 if cmd
= 'chainsaw' then begin plr
.GiveItem(ITEM_WEAPON_SAW
); g_Console_Add('player got a chainsaw'); continue
; end;
4295 if cmd
= 'ammo' then
4297 plr
.GiveItem(ITEM_AMMO_SHELLS_BOX
);
4298 plr
.GiveItem(ITEM_AMMO_BULLETS_BOX
);
4299 plr
.GiveItem(ITEM_AMMO_CELL_BIG
);
4300 plr
.GiveItem(ITEM_AMMO_ROCKET_BOX
);
4301 plr
.GiveItem(ITEM_AMMO_FUELCAN
);
4302 g_Console_Add('player got some ammo');
4306 if cmd
= 'clip' then begin plr
.GiveItem(ITEM_AMMO_BULLETS
); g_Console_Add('player got some bullets'); continue
; end;
4307 if cmd
= 'bullets' then begin plr
.GiveItem(ITEM_AMMO_BULLETS_BOX
); g_Console_Add('player got a box of bullets'); continue
; end;
4309 if cmd
= 'shells' then begin plr
.GiveItem(ITEM_AMMO_SHELLS
); g_Console_Add('player got some shells'); continue
; end;
4310 if cmd
= 'shellbox' then begin plr
.GiveItem(ITEM_AMMO_SHELLS_BOX
); g_Console_Add('player got a box of shells'); continue
; end;
4312 if cmd
= 'cells' then begin plr
.GiveItem(ITEM_AMMO_CELL
); g_Console_Add('player got some cells'); continue
; end;
4313 if cmd
= 'battery' then begin plr
.GiveItem(ITEM_AMMO_CELL_BIG
); g_Console_Add('player got cell battery'); continue
; end;
4315 if cmd
= 'rocket' then begin plr
.GiveItem(ITEM_AMMO_ROCKET
); g_Console_Add('player got a rocket'); continue
; end;
4316 if cmd
= 'rocketbox' then begin plr
.GiveItem(ITEM_AMMO_ROCKET_BOX
); g_Console_Add('player got some rockets'); continue
; end;
4318 if (cmd
= 'fuel') or (cmd
= 'fuelcan') then begin plr
.GiveItem(ITEM_AMMO_FUELCAN
); g_Console_Add('player got fuel canister'); continue
; end;
4320 if cmd
= 'weapons' then
4322 plr
.GiveItem(ITEM_WEAPON_SHOTGUN1
);
4323 plr
.GiveItem(ITEM_WEAPON_SHOTGUN2
);
4324 plr
.GiveItem(ITEM_WEAPON_CHAINGUN
);
4325 plr
.GiveItem(ITEM_WEAPON_ROCKETLAUNCHER
);
4326 plr
.GiveItem(ITEM_WEAPON_PLASMA
);
4327 plr
.GiveItem(ITEM_WEAPON_BFG
);
4328 g_Console_Add('player got weapons');
4332 if cmd
= 'keys' then
4334 plr
.GiveItem(ITEM_KEY_RED
);
4335 plr
.GiveItem(ITEM_KEY_GREEN
);
4336 plr
.GiveItem(ITEM_KEY_BLUE
);
4337 g_Console_Add('player got all keys');
4341 g_Console_Add('i don''t know how to give '''+cmd
+'''!');
4346 if cmd
= 'open' then
4348 g_Console_Add('player activated sesame');
4349 g_Triggers_OpenAll();
4356 if gFly
then g_Console_Add('player feels himself lighter') else g_Console_Add('player lost his wings');
4360 if cmd
= 'noclip' then
4363 g_Console_Add('wall hardeness adjusted');
4367 if cmd
= 'notarget' then
4369 plr
.NoTarget
:= not plr
.NoTarget
;
4370 if plr
.NoTarget
then g_Console_Add('player hides in shadows') else g_Console_Add('player is brave again');
4374 if cmd
= 'noreload' then
4376 plr
.NoReload
:= not plr
.NoReload
;
4377 if plr
.NoReload
then g_Console_Add('player is action hero now') else g_Console_Add('player is ordinary man now');
4381 if cmd
= 'speedy' then
4383 MAX_RUNVEL
:= 32-MAX_RUNVEL
;
4384 g_Console_Add('speed adjusted');
4388 if cmd
= 'jumpy' then
4390 VEL_JUMP
:= 30-VEL_JUMP
;
4391 g_Console_Add('jump height adjusted');
4395 if cmd
= 'automap' then
4397 gShowMap
:= not gShowMap
;
4398 if gShowMap
then g_Console_Add('player gains second sight') else g_Console_Add('player lost second sight');
4402 if cmd
= 'aimline' then
4404 gAimLine
:= not gAimLine
;
4405 if gAimLine
then g_Console_Add('player gains laser sight') else g_Console_Add('player lost laser sight');
4410 procedure GameCommands(P
: SSArray
);
4416 pl
: pTNetClient
= nil;
4424 cmd
:= LowerCase(P
[0]);
4426 if cmd
= 'pause' then
4428 if (g_ActiveWindow
= nil) then
4429 g_Game_Pause(not gPauseMain
);
4431 else if cmd
= 'endgame' then
4432 gExit
:= EXIT_SIMPLE
4433 else if cmd
= 'restart' then
4435 if gGameOn
or (gState
in [STATE_INTERSINGLE
, STATE_INTERCUSTOM
]) then
4437 if g_Game_IsClient
then
4439 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4444 g_Console_Add(_lc
[I_MSG_NOT_GAME
]);
4446 else if cmd
= 'kick' then
4448 if g_Game_IsServer
then
4450 if Length(P
) < 2 then
4452 g_Console_Add('kick <name>');
4457 g_Console_Add('kick <name>');
4461 if g_Game_IsNet
then
4462 pl
:= g_Net_Client_ByName(P
[1]);
4465 s
:= g_Net_ClientName_ByID(pl
^.ID
);
4466 enet_peer_disconnect(pl
^.Peer
, NET_DISC_KICK
);
4467 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
4468 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
4469 g_Net_Slist_ServerPlayerLeaves();
4470 end else if gPlayers
<> nil then
4471 for a
:= Low(gPlayers
) to High(gPlayers
) do
4472 if gPlayers
[a
] <> nil then
4473 if Copy(LowerCase(gPlayers
[a
].Name
), 1, Length(P
[1])) = LowerCase(P
[1]) then
4475 // Не отключать основных игроков в сингле
4476 if not(gPlayers
[a
] is TBot
) and (gGameSettings
.GameType
= GT_SINGLE
) then
4478 gPlayers
[a
].Lives
:= 0;
4479 gPlayers
[a
].Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
4480 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [gPlayers
[a
].Name
]), True);
4481 g_Player_Remove(gPlayers
[a
].UID
);
4482 g_Net_Slist_ServerPlayerLeaves();
4483 // Если не перемешать, при добавлении новых ботов появятся старые
4487 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
4489 else if cmd
= 'kick_id' then
4491 if g_Game_IsServer
and g_Game_IsNet
then
4493 if Length(P
) < 2 then
4495 g_Console_Add('kick_id <client ID>');
4500 g_Console_Add('kick_id <client ID>');
4504 a
:= StrToIntDef(P
[1], 0);
4505 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
4507 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
4509 s
:= g_Net_ClientName_ByID(NetClients
[a
].ID
);
4510 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_KICK
);
4511 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
4512 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
4513 g_Net_Slist_ServerPlayerLeaves();
4517 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4519 else if cmd
= 'kick_pid' then
4521 if g_Game_IsServer
and g_Game_IsNet
then
4523 if Length(P
) < 2 then
4525 g_Console_Add('kick_pid <player ID>');
4530 g_Console_Add('kick_pid <player ID>');
4534 a
:= StrToIntDef(P
[1], 0);
4535 pl
:= g_Net_Client_ByPlayer(a
);
4536 if (pl
<> nil) and pl
^.Used
and (pl
^.Peer
<> nil) then
4538 s
:= g_Net_ClientName_ByID(pl
^.ID
);
4539 enet_peer_disconnect(pl
^.Peer
, NET_DISC_KICK
);
4540 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
4541 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
4542 g_Net_Slist_ServerPlayerLeaves();
4545 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4547 else if cmd
= 'ban' then
4549 if g_Game_IsServer
and g_Game_IsNet
then
4551 if Length(P
) < 2 then
4553 g_Console_Add('ban <name>');
4558 g_Console_Add('ban <name>');
4562 pl
:= g_Net_Client_ByName(P
[1]);
4565 s
:= g_Net_ClientName_ByID(pl
^.ID
);
4566 g_Net_BanHost(pl
^.Peer
^.address
.host
, False);
4567 enet_peer_disconnect(pl
^.Peer
, NET_DISC_TEMPBAN
);
4568 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
4569 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
4570 g_Net_Slist_ServerPlayerLeaves();
4572 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
4574 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4576 else if cmd
= 'ban_id' then
4578 if g_Game_IsServer
and g_Game_IsNet
then
4580 if Length(P
) < 2 then
4582 g_Console_Add('ban_id <client ID>');
4587 g_Console_Add('ban_id <client ID>');
4591 a
:= StrToIntDef(P
[1], 0);
4592 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
4593 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
4595 s
:= g_Net_ClientName_ByID(NetClients
[a
].ID
);
4596 g_Net_BanHost(NetClients
[a
].Peer
^.address
.host
, False);
4597 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_TEMPBAN
);
4598 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
4599 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
4600 g_Net_Slist_ServerPlayerLeaves();
4603 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4605 else if cmd
= 'ban_pid' then
4607 if g_Game_IsServer
and g_Game_IsNet
then
4609 if Length(P
) < 2 then
4611 g_Console_Add('ban_pid <player ID>');
4616 g_Console_Add('ban_pid <player ID>');
4620 a
:= StrToIntDef(P
[1], 0);
4621 pl
:= g_Net_Client_ByPlayer(a
);
4622 if (pl
<> nil) and pl
^.Used
and (pl
^.Peer
<> nil) then
4624 s
:= g_Net_ClientName_ByID(pl
^.ID
);
4625 g_Net_BanHost(pl
^.Peer
^.address
.host
, False);
4626 enet_peer_disconnect(pl
^.Peer
, NET_DISC_TEMPBAN
);
4627 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
4628 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
4629 g_Net_Slist_ServerPlayerLeaves();
4632 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4634 else if cmd
= 'permban' then
4636 if g_Game_IsServer
and g_Game_IsNet
then
4638 if Length(P
) < 2 then
4640 g_Console_Add('permban <name>');
4645 g_Console_Add('permban <name>');
4649 pl
:= g_Net_Client_ByName(P
[1]);
4652 s
:= g_Net_ClientName_ByID(pl
^.ID
);
4653 g_Net_BanHost(pl
^.Peer
^.address
.host
);
4654 enet_peer_disconnect(pl
^.Peer
, NET_DISC_BAN
);
4655 g_Net_SaveBanList();
4656 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
4657 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
4658 g_Net_Slist_ServerPlayerLeaves();
4660 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
4662 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4664 else if cmd
= 'permban_id' then
4666 if g_Game_IsServer
and g_Game_IsNet
then
4668 if Length(P
) < 2 then
4670 g_Console_Add('permban_id <client ID>');
4675 g_Console_Add('permban_id <client ID>');
4679 a
:= StrToIntDef(P
[1], 0);
4680 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
4681 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
4683 s
:= g_Net_ClientName_ByID(NetClients
[a
].ID
);
4684 g_Net_BanHost(NetClients
[a
].Peer
^.address
.host
);
4685 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_BAN
);
4686 g_Net_SaveBanList();
4687 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
4688 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
4689 g_Net_Slist_ServerPlayerLeaves();
4692 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4694 else if cmd
= 'permban_pid' then
4696 if g_Game_IsServer
and g_Game_IsNet
then
4698 if Length(P
) < 2 then
4700 g_Console_Add('permban_pid <player ID>');
4705 g_Console_Add('permban_pid <player ID>');
4709 a
:= StrToIntDef(P
[1], 0);
4710 pl
:= g_Net_Client_ByPlayer(a
);
4711 if (pl
<> nil) and pl
^.Used
and (pl
^.Peer
<> nil) then
4713 s
:= g_Net_ClientName_ByID(pl
^.ID
);
4714 g_Net_BanHost(pl
^.Peer
^.address
.host
);
4715 enet_peer_disconnect(pl
^.Peer
, NET_DISC_BAN
);
4716 g_Net_SaveBanList();
4717 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
4718 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
4719 g_Net_Slist_ServerPlayerLeaves();
4722 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4724 else if cmd
= 'permban_ip' then
4726 if g_Game_IsServer
and g_Game_IsNet
then
4728 if Length(P
) < 2 then
4730 g_Console_Add('permban_ip <IP address>');
4735 g_Console_Add('permban_ip <IP address>');
4739 g_Net_BanHost(P
[1]);
4740 g_Net_SaveBanList();
4741 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [P
[1]]));
4743 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4745 else if cmd
= 'unban' then
4747 if g_Game_IsServer
and g_Game_IsNet
then
4749 if Length(P
) < 2 then
4751 g_Console_Add('unban <IP Address>');
4756 g_Console_Add('unban <IP Address>');
4760 if g_Net_UnbanHost(P
[1]) then
4762 g_Console_Add(Format(_lc
[I_MSG_UNBAN_OK
], [P
[1]]));
4763 g_Net_SaveBanList();
4765 g_Console_Add(Format(_lc
[I_MSG_UNBAN_FAIL
], [P
[1]]));
4767 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4769 else if cmd
= 'clientlist' then
4771 if g_Game_IsServer
and g_Game_IsNet
then
4774 if NetClients
<> nil then
4775 for a
:= Low(NetClients
) to High(NetClients
) do
4776 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
4778 plr
:= g_Player_Get(NetClients
[a
].Player
);
4779 if plr
= nil then continue
;
4781 g_Console_Add(Format('#%2d: %-15s | %s', [a
,
4782 IpToStr(NetClients
[a
].Peer
^.address
.host
), plr
.Name
]));
4785 g_Console_Add(_lc
[I_MSG_NOCLIENTS
]);
4787 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4789 else if cmd
= 'connect' then
4791 if (NetMode
= NET_NONE
) then
4793 if Length(P
) < 2 then
4795 g_Console_Add('connect <IP> [port] [password]');
4800 g_Console_Add('connect <IP> [port] [password]');
4804 if Length(P
) > 2 then
4805 prt
:= StrToIntDef(P
[2], 25666)
4809 if Length(P
) > 3 then
4814 g_Game_StartClient(P
[1], prt
, pw
);
4817 else if cmd
= 'disconnect' then
4819 if (NetMode
= NET_CLIENT
) then
4822 else if cmd
= 'reconnect' then
4824 if (NetMode
= NET_SERVER
) then
4827 if (NetMode
= NET_CLIENT
) then
4830 gExit
:= EXIT_SIMPLE
;
4834 //TODO: Use last successful password to reconnect, instead of ''
4835 g_Game_StartClient(NetClientIP
, NetClientPort
, '');
4837 else if (cmd
= 'addbot') or
4838 (cmd
= 'bot_add') then
4840 if Length(P
) > 2 then
4841 g_Bot_Add(TEAM_NONE
, StrToIntDef(P
[1], 2), StrToIntDef(P
[2], 100))
4842 else if Length(P
) > 1 then
4843 g_Bot_Add(TEAM_NONE
, StrToIntDef(P
[1], 2))
4845 g_Bot_Add(TEAM_NONE
, 2);
4847 else if cmd
= 'bot_addlist' then
4849 if Length(P
) > 1 then
4851 if Length(P
) = 2 then
4852 g_Bot_AddList(TEAM_NONE
, P
[1], StrToIntDef(P
[1], -1))
4853 else if Length(P
) = 3 then
4854 g_Bot_AddList(TEAM_NONE
, P
[1], StrToIntDef(P
[1], -1), StrToIntDef(P
[2], 100))
4856 g_Bot_AddList(IfThen(P
[2] = 'red', TEAM_RED
, TEAM_BLUE
), P
[1], StrToIntDef(P
[1], -1));
4859 else if cmd
= 'bot_removeall' then
4861 else if cmd
= 'chat' then
4863 if g_Game_IsNet
then
4865 if Length(P
) > 1 then
4867 for a
:= 1 to High(P
) do
4868 chstr
:= chstr
+ P
[a
] + ' ';
4870 if Length(chstr
) > 200 then SetLength(chstr
, 200);
4872 if Length(chstr
) < 1 then
4874 g_Console_Add('chat <text>');
4878 chstr
:= b_Text_Format(chstr
);
4879 if g_Game_IsClient
then
4880 MC_SEND_Chat(chstr
, NET_CHAT_PLAYER
)
4882 MH_SEND_Chat(gPlayer1Settings
.Name
+ ': ' + chstr
, NET_CHAT_PLAYER
);
4885 g_Console_Add('chat <text>');
4887 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
4889 else if cmd
= 'teamchat' then
4891 if g_Game_IsNet
and (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
4893 if Length(P
) > 1 then
4895 for a
:= 1 to High(P
) do
4896 chstr
:= chstr
+ P
[a
] + ' ';
4898 if Length(chstr
) > 200 then SetLength(chstr
, 200);
4900 if Length(chstr
) < 1 then
4902 g_Console_Add('teamchat <text>');
4906 chstr
:= b_Text_Format(chstr
);
4907 if g_Game_IsClient
then
4908 MC_SEND_Chat(chstr
, NET_CHAT_TEAM
)
4910 MH_SEND_Chat(gPlayer1Settings
.Name
+ ': ' + chstr
, NET_CHAT_TEAM
,
4911 gPlayer1Settings
.Team
);
4914 g_Console_Add('teamchat <text>');
4916 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
4918 else if cmd
= 'game' then
4920 if gGameSettings
.GameType
<> GT_NONE
then
4922 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
4925 if Length(P
) = 1 then
4927 g_Console_Add(cmd
+ ' <WAD> [MAP] [# players]');
4930 // game not started yet, load fist map from some wad
4932 s
:= addWadExtension(P
[1]);
4933 found
:= e_FindResource(AllMapDirs
, s
);
4937 P
[1] := ExpandFileName(P
[1]);
4938 // if map not choosed then set first map
4939 if Length(P
) < 3 then
4942 P
[2] := g_Game_GetFirstMap(P
[1]);
4945 s
:= P
[1] + ':\' + UpperCase(P
[2]);
4947 if g_Map_Exist(s
) then
4951 with gGameSettings
do
4953 Options
:= gsGameFlags
;
4954 GameMode
:= g_Game_TextToMode(gsGameMode
);
4955 if gSwitchGameMode
<> GM_NONE
then
4956 GameMode
:= gSwitchGameMode
;
4957 if GameMode
= GM_NONE
then GameMode
:= GM_DM
;
4958 if GameMode
= GM_SINGLE
then GameMode
:= GM_COOP
;
4960 if Length(P
) >= 4 then
4961 b
:= StrToIntDef(P
[3], 1);
4962 g_Game_StartCustom(s
, GameMode
, TimeLimit
,
4963 GoalLimit
, MaxLives
, Options
, b
);
4968 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
4970 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [UpperCase(P
[2]), P
[1]]));
4972 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]));
4974 else if cmd
= 'host' then
4976 if gGameSettings
.GameType
<> GT_NONE
then
4978 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
4981 if Length(P
) < 4 then
4983 g_Console_Add(cmd
+ ' <listen IP> <port> <WAD> [MAP] [# players]');
4986 if not StrToIp(P
[1], listen
) then
4988 prt
:= StrToIntDef(P
[2], 25666);
4990 s
:= addWadExtension(P
[3]);
4991 found
:= e_FindResource(AllMapDirs
, s
);
4995 // get first map in wad, if not specified
4996 if Length(P
) < 5 then
4999 P
[4] := g_Game_GetFirstMap(P
[1]);
5001 s
:= P
[3] + ':\' + UpperCase(P
[4]);
5002 if g_Map_Exist(s
) then
5006 with gGameSettings
do
5008 Options
:= gsGameFlags
;
5009 GameMode
:= g_Game_TextToMode(gsGameMode
);
5010 if gSwitchGameMode
<> GM_NONE
then GameMode
:= gSwitchGameMode
;
5011 if GameMode
= GM_NONE
then GameMode
:= GM_DM
;
5012 if GameMode
= GM_SINGLE
then GameMode
:= GM_COOP
;
5014 if Length(P
) >= 6 then
5015 b
:= StrToIntDef(P
[5], 0);
5016 g_Game_StartServer(s
, GameMode
, TimeLimit
, GoalLimit
, MaxLives
, Options
, b
, listen
, prt
)
5022 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[3]]))
5024 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [UpperCase(P
[4]), P
[3]]))
5029 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[3]]))
5032 else if cmd
= 'map' then
5034 if Length(P
) = 1 then
5036 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
5038 g_Console_Add(cmd
+ ' <MAP>');
5039 g_Console_Add(cmd
+ ' <WAD> [MAP]')
5043 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
])
5048 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
5050 if Length(P
) < 3 then
5052 // first param is map or wad
5053 s
:= UpperCase(P
[1]);
5054 if g_Map_Exist(gGameSettings
.WAD
+ ':\' + s
) then
5056 gExitByTrigger
:= False;
5059 // already in game, finish current map
5061 gExit
:= EXIT_ENDLEVELCUSTOM
;
5065 // intermission, so change map immediately
5072 found
:= e_FindResource(AllMapDirs
, s
);
5074 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [s
, 'WAD ' + P
[1]]));
5077 // no such map, found wad
5080 P
[1] := ExpandFileName(pw
);
5081 P
[2] := g_Game_GetFirstMap(P
[1]);
5082 s
:= P
[1] + ':\' + P
[2];
5083 if g_Map_Exist(s
) then
5085 gExitByTrigger
:= False;
5088 // already in game, finish current map
5090 gExit
:= EXIT_ENDLEVELCUSTOM
5094 // intermission, so change map immediately
5101 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
5103 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]))
5108 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]))
5114 s
:= addWadExtension(P
[1]);
5115 found
:= e_FindResource(AllMapDirs
, s
);
5119 P
[2] := UpperCase(P
[2]);
5120 s
:= P
[1] + ':\' + P
[2];
5121 if g_Map_Exist(s
) then
5123 gExitByTrigger
:= False;
5127 gExit
:= EXIT_ENDLEVELCUSTOM
5136 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]))
5141 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]))
5147 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
])
5151 else if cmd
= 'nextmap' then
5153 if not(gGameOn
or (gState
= STATE_INTERCUSTOM
)) then
5155 g_Console_Add(_lc
[I_MSG_NOT_GAME
])
5160 if Length(P
) = 1 then
5162 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
5164 g_Console_Add(cmd
+ ' <MAP>');
5165 g_Console_Add(cmd
+ ' <WAD> [MAP]');
5170 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
5176 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
5178 if Length(P
) < 3 then
5180 // first param is map or wad
5181 s
:= UpperCase(P
[1]);
5182 if g_Map_Exist(gGameSettings
.WAD
+ ':\' + s
) then
5185 gExitByTrigger
:= False;
5191 // no such map, found wad
5192 pw
:= addWadExtension(P
[1]);
5193 found
:= e_FindResource(MapDirs
, pw
);
5195 found
:= e_FindResource(WadDirs
, pw
);
5197 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [s
, P
[1]]));
5200 // map not specified, select first map
5202 P
[2] := g_Game_GetFirstMap(P
[1]);
5203 s
:= P
[1] + ':\' + P
[2];
5204 if g_Map_Exist(s
) then
5206 gExitByTrigger
:= False;
5213 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
5215 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]))
5220 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]))
5226 // specified two params wad + map
5227 pw
:= addWadExtension(P
[1]);
5228 found
:= e_FindResource(MapDirs
, pw
);
5230 found
:= e_FindResource(MapDirs
, pw
);
5234 P
[2] := UpperCase(P
[2]);
5235 s
:= P
[1] + ':\' + P
[2];
5236 if g_Map_Exist(s
) then
5238 gExitByTrigger
:= False;
5244 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]))
5249 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]))
5255 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
])
5260 if gNextMap
= '' then
5261 g_Console_Add(_lc
[I_MSG_NEXTMAP_UNSET
])
5263 g_Console_Add(Format(_lc
[I_MSG_NEXTMAP_SET
], [gNextMap
]))
5267 else if (cmd
= 'endmap') or (cmd
= 'goodbye') then
5271 g_Console_Add(_lc
[I_MSG_NOT_GAME
])
5275 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
5277 gExitByTrigger
:= False;
5278 // next map not specified, try to find trigger EXIT
5279 if (gNextMap
= '') and (gTriggers
<> nil) then
5281 for a
:= 0 to High(gTriggers
) do
5283 if gTriggers
[a
].TriggerType
= TRIGGER_EXIT
then
5285 gExitByTrigger
:= True;
5286 //gNextMap := gTriggers[a].Data.MapName;
5287 gNextMap
:= gTriggers
[a
].tgcMap
;
5292 if gNextMap
= '' then
5293 gNextMap
:= g_Game_GetNextMap();
5294 if not isWadPath(gNextMap
) then
5295 s
:= gGameSettings
.WAD
+ ':\' + gNextMap
5298 if g_Map_Exist(s
) then
5299 gExit
:= EXIT_ENDLEVELCUSTOM
5301 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [gNextMap
]))
5305 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
])
5309 else if (cmd
= 'event') then
5311 if (Length(P
) <= 1) then
5313 for a
:= 0 to High(gEvents
) do
5314 if gEvents
[a
].Command
= '' then
5315 g_Console_Add(gEvents
[a
].Name
+ ' <none>')
5317 g_Console_Add(gEvents
[a
].Name
+ ' "' + gEvents
[a
].Command
+ '"');
5320 if (Length(P
) = 2) then
5322 for a
:= 0 to High(gEvents
) do
5323 if gEvents
[a
].Name
= P
[1] then
5324 if gEvents
[a
].Command
= '' then
5325 g_Console_Add(gEvents
[a
].Name
+ ' <none>')
5327 g_Console_Add(gEvents
[a
].Name
+ ' "' + gEvents
[a
].Command
+ '"');
5330 for a
:= 0 to High(gEvents
) do
5331 if gEvents
[a
].Name
= P
[1] then
5333 gEvents
[a
].Command
:= '';
5334 for b
:= 2 to High(P
) do
5335 if Pos(' ', P
[b
]) = 0 then
5336 gEvents
[a
].Command
:= gEvents
[a
].Command
+ ' ' + P
[b
]
5338 gEvents
[a
].Command
:= gEvents
[a
].Command
+ ' "' + P
[b
] + '"';
5339 gEvents
[a
].Command
:= Trim(gEvents
[a
].Command
);
5343 else if cmd
= 'suicide' then
5347 if g_Game_IsClient
then
5348 MC_SEND_CheatRequest(NET_CHEAT_SUICIDE
)
5351 if gPlayer1
<> nil then
5352 gPlayer1
.Damage(SUICIDE_DAMAGE
, gPlayer1
.UID
, 0, 0, HIT_SELF
);
5353 if gPlayer2
<> nil then
5354 gPlayer2
.Damage(SUICIDE_DAMAGE
, gPlayer2
.UID
, 0, 0, HIT_SELF
);
5358 else if cmd
= 'screenshot' then
5362 else if cmd
= 'weapon' then
5364 if Length(p
) = 2 then
5366 a
:= WP_FIRST
+ StrToInt(p
[1]) - 1;
5367 if (a
>= WP_FIRST
) and (a
<= WP_LAST
) then
5368 gSelectWeapon
[0, a
] := True
5371 else if (cmd
= 'p1_weapon') or (cmd
= 'p2_weapon') then
5373 if Length(p
) = 2 then
5375 a
:= WP_FIRST
+ StrToInt(p
[1]) - 1;
5376 b
:= ord(cmd
[2]) - ord('1');
5377 if (a
>= WP_FIRST
) and (a
<= WP_LAST
) then
5378 gSelectWeapon
[b
, a
] := True
5381 // Команды Своей игры:
5382 else if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
5384 if cmd
= 'bot_addred' then
5386 if Length(P
) > 1 then
5387 g_Bot_Add(TEAM_RED
, StrToIntDef(P
[1], 2))
5389 g_Bot_Add(TEAM_RED
, 2);
5391 else if cmd
= 'bot_addblue' then
5393 if Length(P
) > 1 then
5394 g_Bot_Add(TEAM_BLUE
, StrToIntDef(P
[1], 2))
5396 g_Bot_Add(TEAM_BLUE
, 2);
5398 else if cmd
= 'spectate' then
5404 else if cmd
= 'say' then
5406 if g_Game_IsServer
and g_Game_IsNet
then
5408 if Length(P
) > 1 then
5411 for a
:= 1 to High(P
) do
5412 chstr
:= chstr
+ P
[a
] + ' ';
5414 if Length(chstr
) > 200 then SetLength(chstr
, 200);
5416 if Length(chstr
) < 1 then
5418 g_Console_Add('say <text>');
5422 chstr
:= b_Text_Format(chstr
);
5423 MH_SEND_Chat(chstr
, NET_CHAT_PLAYER
);
5425 else g_Console_Add('say <text>');
5427 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
5429 else if cmd
= 'tell' then
5431 if g_Game_IsServer
and g_Game_IsNet
then
5433 if (Length(P
) > 2) and (P
[1] <> '') then
5436 for a
:= 2 to High(P
) do
5437 chstr
:= chstr
+ P
[a
] + ' ';
5439 if Length(chstr
) > 200 then SetLength(chstr
, 200);
5441 if Length(chstr
) < 1 then
5443 g_Console_Add('tell <playername> <text>');
5447 pl
:= g_Net_Client_ByName(P
[1]);
5449 MH_SEND_Chat(b_Text_Format(chstr
), NET_CHAT_PLAYER
, pl
^.ID
)
5451 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
5453 else g_Console_Add('tell <playername> <text>');
5455 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
5457 else if cmd
= 'centerprint' then
5459 if (Length(P
) > 2) and (P
[1] <> '') then
5462 for a
:= 2 to High(P
) do
5463 chstr
:= chstr
+ P
[a
] + ' ';
5465 if Length(chstr
) > 200 then SetLength(chstr
, 200);
5467 if Length(chstr
) < 1 then
5469 g_Console_Add('centerprint <timeout> <text>');
5473 a
:= StrToIntDef(P
[1], 100);
5474 chstr
:= b_Text_Format(chstr
);
5475 g_Game_Message(chstr
, a
);
5476 if g_Game_IsNet
and g_Game_IsServer
then
5477 MH_SEND_GameEvent(NET_EV_BIGTEXT
, a
, chstr
);
5479 else g_Console_Add('centerprint <timeout> <text>');
5481 else if (cmd
= 'overtime') and not g_Game_IsClient
then
5483 if (Length(P
) = 1) or (StrToIntDef(P
[1], -1) <= 0) then
5485 // Дополнительное время:
5486 gGameSettings
.TimeLimit
:= (gTime
- gGameStartTime
) div 1000 + Word(StrToIntDef(P
[1], 0));
5488 g_Console_Add(Format(_lc
[I_MSG_TIME_LIMIT
],
5489 [gGameSettings
.TimeLimit
div 3600,
5490 (gGameSettings
.TimeLimit
div 60) mod 60,
5491 gGameSettings
.TimeLimit
mod 60]));
5492 if g_Game_IsNet
then MH_SEND_GameSettings
;
5494 else if (cmd
= 'rcon_password') and g_Game_IsClient
then
5496 if (Length(P
) <= 1) then
5497 g_Console_Add('rcon_password <password>')
5499 MC_SEND_RCONPassword(P
[1]);
5501 else if cmd
= 'rcon' then
5503 if g_Game_IsClient
then
5505 if Length(P
) > 1 then
5508 for a
:= 1 to High(P
) do
5509 chstr
:= chstr
+ P
[a
] + ' ';
5511 if Length(chstr
) > 200 then SetLength(chstr
, 200);
5513 if Length(chstr
) < 1 then
5515 g_Console_Add('rcon <command>');
5519 MC_SEND_RCONCommand(chstr
);
5521 else g_Console_Add('rcon <command>');
5524 else if cmd
= 'ready' then
5526 if g_Game_IsServer
and (gLMSRespawn
= LMS_RESPAWN_WARMUP
) then
5527 gLMSRespawnTime
:= gTime
+ 100;
5529 else if (cmd
= 'callvote') and g_Game_IsNet
then
5531 if Length(P
) > 1 then
5534 for a
:= 1 to High(P
) do begin
5535 if a
> 1 then chstr
:= chstr
+ ' ';
5536 chstr
:= chstr
+ P
[a
];
5539 if Length(chstr
) > 200 then SetLength(chstr
, 200);
5541 if Length(chstr
) < 1 then
5543 g_Console_Add('callvote <command>');
5547 if g_Game_IsClient
then
5548 MC_SEND_Vote(True, chstr
)
5550 g_Game_StartVote(chstr
, gPlayer1Settings
.Name
);
5551 g_Console_Process('vote', True);
5554 g_Console_Add('callvote <command>');
5556 else if (cmd
= 'vote') and g_Game_IsNet
then
5558 if g_Game_IsClient
then
5560 else if gVoteInProgress
then
5562 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
5563 a
:= Floor((NetClientCount
+1)/2.0) + 1
5565 a
:= Floor(NetClientCount
/2.0) + 1;
5570 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_REVOKED
], [gPlayer1Settings
.Name
, gVoteCount
, a
]), True);
5571 MH_SEND_VoteEvent(NET_VE_REVOKE
, gPlayer1Settings
.Name
, 'a', gVoteCount
, a
);
5577 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_VOTE
], [gPlayer1Settings
.Name
, gVoteCount
, a
]), True);
5578 MH_SEND_VoteEvent(NET_VE_VOTE
, gPlayer1Settings
.Name
, 'a', gVoteCount
, a
);
5586 procedure SystemCommands(P
: SSArray
);
5590 cmd
:= LowerCase(P
[0]);
5599 gRC_Width
:= Max(1, gRC_Width
);
5600 gRC_Height
:= Max(1, gRC_Height
);
5601 gBPP
:= Max(1, gBPP
);
5602 if sys_SetDisplayMode(gRC_Width
, gRC_Height
, gBPP
, gRC_FullScreen
, gRC_Maximized
) = True then
5603 e_LogWriteln('resolution changed')
5605 e_LogWriteln('resolution not changed');
5606 sys_EnableVSync(gVSync
);
5610 if Length(p
) = 2 then
5612 gMaxFPS
:= StrToIntDef(p
[1], gMaxFPS
);
5614 gFrameTime
:= 1000 div gMaxFPS
5618 e_LogWritefln('r_maxfps %d', [gMaxFPS
]);
5622 if Length(p
) = 2 then
5624 gAskLanguage
:= true;
5625 gLanguage
:= LANGUAGE_ENGLISH
;
5626 case LowerCase(p
[1]) of
5629 gAskLanguage
:= false;
5630 gLanguage
:= LANGUAGE_ENGLISH
;
5634 gAskLanguage
:= false;
5635 gLanguage
:= LANGUAGE_RUSSIAN
;
5639 gAskLanguage
:= true;
5640 gLanguage
:= LANGUAGE_ENGLISH
;
5643 g_Language_Set(gLanguage
);
5647 e_LogWritefln('usage: %s <English|Russian|Ask>', [cmd
]);
5653 procedure g_TakeScreenShot(Filename
: string = '');
5654 var s
: TStream
; t
: TDateTime
; dir
, date
, name
: String;
5656 if e_NoGraphics
then Exit
;
5658 dir
:= e_GetWriteableDir(ScreenshotDirs
);
5660 if Filename
= '' then
5663 DateTimeToString(date
, 'yyyy-mm-dd-hh-nn-ss', t
);
5664 Filename
:= 'screenshot-' + date
;
5667 name
:= e_CatPath(dir
, Filename
+ '.png');
5668 s
:= createDiskFile(name
);
5670 e_MakeScreenshot(s
, gScreenWidth
, gScreenHeight
);
5672 g_Console_Add(Format(_lc
[I_CONSOLE_SCREENSHOT
], [name
]))
5674 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_WRITE
], [name
]));
5679 g_Console_Add('oh shit, i can''t create screenshot!')
5683 procedure g_Game_InGameMenu(Show
: Boolean);
5685 if (g_ActiveWindow
= nil) and Show
then
5687 if gGameSettings
.GameType
= GT_SINGLE
then
5688 g_GUI_ShowWindow('GameSingleMenu')
5691 if g_Game_IsClient
then
5692 g_GUI_ShowWindow('GameClientMenu')
5694 if g_Game_IsNet
then
5695 g_GUI_ShowWindow('GameServerMenu')
5697 g_GUI_ShowWindow('GameCustomMenu');
5699 g_Sound_PlayEx('MENU_OPEN');
5701 // Пауза при меню только в одиночной игре:
5702 if (not g_Game_IsNet
) then
5706 if (g_ActiveWindow
<> nil) and (not Show
) then
5708 // Пауза при меню только в одиночной игре:
5709 if (not g_Game_IsNet
) then
5710 g_Game_Pause(False);
5714 procedure g_Game_Pause (Enable
: Boolean);
5718 if not gGameOn
then exit
;
5720 if not (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
]) then exit
;
5723 gPauseMain
:= Enable
;
5725 if (gPause
<> oldPause
) then g_Game_PauseAllSounds(gPause
);
5728 procedure g_Game_HolmesPause (Enable
: Boolean);
5732 if not gGameOn
then exit
;
5733 if not (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
]) then exit
;
5736 gPauseHolmes
:= Enable
;
5738 if (gPause
<> oldPause
) then g_Game_PauseAllSounds(gPause
);
5741 procedure g_Game_PauseAllSounds(Enable
: Boolean);
5746 if gTriggers
<> nil then
5747 for i
:= 0 to High(gTriggers
) do
5748 with gTriggers
[i
] do
5749 if (TriggerType
= TRIGGER_SOUND
) and
5751 Sound
.IsPlaying() then
5753 Sound
.Pause(Enable
);
5757 if gPlayers
<> nil then
5758 for i
:= 0 to High(gPlayers
) do
5759 if gPlayers
[i
] <> nil then
5760 gPlayers
[i
].PauseSounds(Enable
);
5763 if gMusic
<> nil then
5764 gMusic
.Pause(Enable
);
5767 procedure g_Game_StopAllSounds(all
: Boolean);
5771 if gTriggers
<> nil then
5772 for i
:= 0 to High(gTriggers
) do
5773 with gTriggers
[i
] do
5774 if (TriggerType
= TRIGGER_SOUND
) and
5778 if gMusic
<> nil then
5785 procedure g_Game_UpdateTriggerSounds
;
5788 if gTriggers
<> nil then
5789 for i
:= 0 to High(gTriggers
) do
5790 with gTriggers
[i
] do
5791 if (TriggerType
= TRIGGER_SOUND
) and (Sound
<> nil) and tgcLocal
and Sound
.IsPlaying() then
5792 Sound
.SetCoordsRect(X
, Y
, Width
, Height
, tgcVolume
/ 255.0)
5795 function g_Game_IsWatchedPlayer(UID
: Word): Boolean;
5798 if (gPlayer1
<> nil) and (gPlayer1
.UID
= UID
) then
5803 if (gPlayer2
<> nil) and (gPlayer2
.UID
= UID
) then
5808 if gSpectMode
<> SPECT_PLAYERS
then
5810 if gSpectPID1
= UID
then
5815 if gSpectViewTwo
and (gSpectPID2
= UID
) then
5822 function g_Game_IsWatchedTeam(Team
: Byte): Boolean;
5827 if (gPlayer1
<> nil) and (gPlayer1
.Team
= Team
) then
5832 if (gPlayer2
<> nil) and (gPlayer2
.Team
= Team
) then
5837 if gSpectMode
<> SPECT_PLAYERS
then
5839 Pl
:= g_Player_Get(gSpectPID1
);
5840 if (Pl
<> nil) and (Pl
.Team
= Team
) then
5845 if gSpectViewTwo
then
5847 Pl
:= g_Player_Get(gSpectPID2
);
5848 if (Pl
<> nil) and (Pl
.Team
= Team
) then
5856 procedure g_Game_Message(Msg
: string; Time
: Word);
5858 MessageLineLength
:= (gScreenWidth
- 204) div e_CharFont_GetMaxWidth(gMenuFont
);
5859 MessageText
:= b_Text_Wrap(b_Text_Format(Msg
), MessageLineLength
);
5860 MessageTime
:= Time
;
5863 procedure g_Game_ChatSound(Text: String; Taunt
: Boolean = True);
5865 punct
: Array[0..13] of String =
5866 ('.', ',', ':', ';', '!', '?', '(', ')', '''', '"', '/', '\', '*', '^');
5872 function IsPunctuation(S
: String): Boolean;
5877 if Length(S
) <> 1 then
5879 for i
:= Low(punct
) to High(punct
) do
5880 if S
= punct
[i
] then
5886 function FilterPunctuation(S
: String): String;
5890 for i
:= Low(punct
) to High(punct
) do
5891 S
:= StringReplace(S
, punct
[i
], ' ', [rfReplaceAll
]);
5897 if gUseChatSounds
and Taunt
and (gChatSounds
<> nil) and (Pos(': ', Text) > 0) then
5899 // remove player name
5900 Delete(Text, 1, Pos(': ', Text) + 2 - 1);
5901 // for FullWord check
5902 Text := toLowerCase1251(' ' + Text + ' ');
5903 fpText
:= FilterPunctuation(Text);
5905 for i
:= 0 to Length(gChatSounds
) - 1 do
5908 for j
:= 0 to Length(gChatSounds
[i
].Tags
) - 1 do
5910 if gChatSounds
[i
].FullWord
and (not IsPunctuation(gChatSounds
[i
].Tags
[j
])) then
5911 ok
:= Pos(' ' + gChatSounds
[i
].Tags
[j
] + ' ', fpText
) > 0
5913 ok
:= Pos(gChatSounds
[i
].Tags
[j
], Text) > 0;
5919 gChatSounds
[i
].Sound
.Play();
5925 g_Sound_PlayEx('SOUND_GAME_RADIO');
5928 procedure g_Game_Announce_GoodShot(SpawnerUID
: Word);
5937 if not g_Game_IsWatchedPlayer(SpawnerUID
) then
5941 if goodsnd
[a
].IsPlaying() then
5944 goodsnd
[Random(4)].Play();
5947 procedure g_Game_Announce_KillCombo(Param
: Integer);
5954 UID
:= Param
and $FFFF;
5959 Pl
:= g_Player_Get(UID
);
5968 g_Console_Add(Format(_lc
[I_PLAYER_KILL_2X
], [Name
]), True);
5972 g_Console_Add(Format(_lc
[I_PLAYER_KILL_3X
], [Name
]), True);
5976 g_Console_Add(Format(_lc
[I_PLAYER_KILL_4X
], [Name
]), True);
5980 g_Console_Add(Format(_lc
[I_PLAYER_KILL_MX
], [Name
]), True);
5988 if not g_Game_IsWatchedPlayer(UID
) then
5991 if (not g_Game_IsWatchedPlayer(UID
)) and (c
< 4) then
5995 if killsnd
[n
].IsPlaying() then
6000 procedure g_Game_Announce_BodyKill(SpawnerUID
: Word);
6008 if not g_Game_IsWatchedPlayer(SpawnerUID
) then
6012 if hahasnd
[a
].IsPlaying() then
6015 hahasnd
[Random(3)].Play();
6018 procedure g_Game_StartVote(Command
, Initiator
: string);
6022 if not gVotesEnabled
then Exit
;
6023 if gGameSettings
.GameType
<> GT_SERVER
then Exit
;
6024 if gVoteInProgress
or gVotePassed
then
6026 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_INPROGRESS
], [gVoteCommand
]), True);
6027 MH_SEND_VoteEvent(NET_VE_INPROGRESS
, gVoteCommand
);
6030 gVoteInProgress
:= True;
6031 gVotePassed
:= False;
6032 gVoteTimer
:= gTime
+ gVoteTimeout
* 1000;
6035 gVoteCommand
:= Command
;
6037 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
6038 Need
:= Floor((NetClientCount
+1)/2.0)+1
6040 Need
:= Floor(NetClientCount
/2.0)+1;
6041 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_STARTED
], [Initiator
, Command
, Need
]), True);
6042 MH_SEND_VoteEvent(NET_VE_STARTED
, Initiator
, Command
, Need
);
6045 procedure g_Game_CheckVote
;
6049 if gGameSettings
.GameType
<> GT_SERVER
then Exit
;
6050 if not gVoteInProgress
then Exit
;
6052 if (gTime
>= gVoteTimer
) then
6054 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
6055 Need
:= Floor((NetClientCount
+1)/2.0) + 1
6057 Need
:= Floor(NetClientCount
/2.0) + 1;
6058 if gVoteCount
>= Need
then
6060 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_PASSED
], [gVoteCommand
]), True);
6061 MH_SEND_VoteEvent(NET_VE_PASSED
, gVoteCommand
);
6062 gVotePassed
:= True;
6063 gVoteCmdTimer
:= gTime
+ 5000;
6067 g_Console_Add(_lc
[I_MESSAGE_VOTE_FAILED
], True);
6068 MH_SEND_VoteEvent(NET_VE_FAILED
);
6070 if NetClients
<> nil then
6071 for I
:= Low(NetClients
) to High(NetClients
) do
6072 if NetClients
[i
].Used
then
6073 NetClients
[i
].Voted
:= False;
6074 gVoteInProgress
:= False;
6080 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
6081 Need
:= Floor((NetClientCount
+1)/2.0) + 1
6083 Need
:= Floor(NetClientCount
/2.0) + 1;
6084 if gVoteCount
>= Need
then
6086 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_PASSED
], [gVoteCommand
]), True);
6087 MH_SEND_VoteEvent(NET_VE_PASSED
, gVoteCommand
);
6088 gVoteInProgress
:= False;
6089 gVotePassed
:= True;
6090 gVoteCmdTimer
:= gTime
+ 5000;
6093 if NetClients
<> nil then
6094 for I
:= Low(NetClients
) to High(NetClients
) do
6095 if NetClients
[i
].Used
then
6096 NetClients
[i
].Voted
:= False;
6101 procedure g_Game_LoadMapList(FileName
: string);
6109 if not FileExists(FileName
) then Exit
;
6111 AssignFile(ListFile
, FileName
);
6113 while not EOF(ListFile
) do
6115 ReadLn(ListFile
, s
);
6118 if s
= '' then Continue
;
6120 SetLength(MapList
, Length(MapList
)+1);
6121 MapList
[High(MapList
)] := s
;
6123 CloseFile(ListFile
);
6126 procedure g_Game_SetDebugMode();
6129 // Читы (даже в своей игре):
6133 procedure g_Game_SetLoadingText(Text: String; Max
: Integer; reWrite
: Boolean);
6137 if Length(LoadingStat
.Msgs
) = 0 then
6143 begin // Переходим на следующую строку или скроллируем:
6144 if NextMsg
= Length(Msgs
) then
6146 for i
:= 0 to High(Msgs
)-1 do
6147 Msgs
[i
] := Msgs
[i
+1];
6155 Msgs
[NextMsg
-1] := Text;
6159 PBarWasHere
:= false;
6162 g_ActiveWindow
:= nil;
6164 ProcessLoading(true);
6167 procedure g_Game_StepLoading(Value
: Integer = -1);
6178 if (ShowCount
> LOADING_SHOW_STEP
) or (Value
> -1) then
6186 procedure g_Game_ClearLoading();
6195 len
:= ((gScreenHeight
div 3)*2 - 50) div LOADING_INTERLINE
;
6196 if len
< 1 then len
:= 1;
6197 SetLength(Msgs
, len
);
6198 for len
:= Low(Msgs
) to High(Msgs
) do
6201 PBarWasHere
:= false;
6205 procedure Parse_Params(var pars
: TParamStrValues
);
6212 while i
<= ParamCount
do
6215 if (s
[1] = '-') and (Length(s
) > 1) then
6217 if (s
[2] = '-') and (Length(s
) > 2) then
6218 begin // Одиночный параметр
6219 SetLength(pars
, Length(pars
) + 1);
6220 with pars
[High(pars
)] do
6222 Name
:= LowerCase(s
);
6227 if (i
< ParamCount
) then
6228 begin // Параметр со значением
6230 SetLength(pars
, Length(pars
) + 1);
6231 with pars
[High(pars
)] do
6233 Name
:= LowerCase(s
);
6234 Value
:= LowerCase(ParamStr(i
));
6243 function Find_Param_Value(var pars
: TParamStrValues
; aName
: String): String;
6248 for i
:= 0 to High(pars
) do
6249 if pars
[i
].Name
= aName
then
6251 Result
:= pars
[i
].Value
;
6256 procedure g_Game_Process_Params();
6258 pars
: TParamStrValues
;
6261 LimT
, LimS
: Integer;
6272 s
:= Find_Param_Value(pars
, '--debug');
6275 g_Game_SetDebugMode();
6276 s
:= Find_Param_Value(pars
, '--netdump');
6281 // Connect when game loads
6282 ip
:= Find_Param_Value(pars
, '-connect');
6286 s
:= Find_Param_Value(pars
, '-port');
6287 if (s
= '') or not TryStrToInt(s
, Port
) then
6290 s
:= Find_Param_Value(pars
, '-pw');
6292 g_Game_StartClient(ip
, Port
, s
);
6296 s
:= LowerCase(Find_Param_Value(pars
, '-dbg-mainwad'));
6299 gDefaultMegawadStart
:= s
;
6302 if (Find_Param_Value(pars
, '--dbg-mainwad-restore') <> '') or
6303 (Find_Param_Value(pars
, '--dbg-mainwad-default') <> '') then
6305 gDefaultMegawadStart
:= DF_Default_Megawad_Start
;
6308 // Start map when game loads:
6309 map
:= LowerCase(Find_Param_Value(pars
, '-map'));
6310 if isWadPath(map
) then
6313 s
:= Find_Param_Value(pars
, '-gm');
6314 GMode
:= g_Game_TextToMode(s
);
6315 if GMode
= GM_NONE
then GMode
:= GM_DM
;
6316 if GMode
= GM_SINGLE
then GMode
:= GM_COOP
;
6319 s
:= Find_Param_Value(pars
, '-limt');
6320 if (s
= '') or (not TryStrToInt(s
, LimT
)) then
6326 s
:= Find_Param_Value(pars
, '-lims');
6327 if (s
= '') or (not TryStrToInt(s
, LimS
)) then
6333 s
:= Find_Param_Value(pars
, '-lives');
6334 if (s
= '') or (not TryStrToInt(s
, Lives
)) then
6340 s
:= Find_Param_Value(pars
, '-opt');
6344 Opt
:= StrToIntDef(s
, 0);
6347 s
:= Find_Param_Value(pars
, '--close');
6351 // Override map to test:
6352 s
:= LowerCase(Find_Param_Value(pars
, '-testmap'));
6355 if e_IsValidResourceName(s
) then
6356 e_FindResource(AllMapDirs
, s
);
6357 gTestMap
:= ExpandFileName(s
);
6360 // Delete test map after play:
6361 s
:= Find_Param_Value(pars
, '--testdelete');
6364 //gMapToDelete := MapsDir + map;
6365 e_WriteLog('"--testdelete" is deprecated, use --tempdelete.', TMsgType
.Fatal
);
6369 // Delete temporary WAD after play:
6370 s
:= Find_Param_Value(pars
, '--tempdelete');
6371 if (s
<> '') and (gTestMap
<> '') then
6373 gMapToDelete
:= gTestMap
;
6374 gTempDelete
:= True;
6377 // Number of players:
6378 s
:= Find_Param_Value(pars
, '-pl');
6380 n
:= DEFAULT_PLAYERS
6382 n
:= StrToIntDef(s
, DEFAULT_PLAYERS
);
6385 s
:= Find_Param_Value(pars
, '-port');
6386 if (s
= '') or not TryStrToInt(s
, Port
) then
6387 g_Game_StartCustom(map
, GMode
, LimT
, LimS
, Lives
, Opt
, n
)
6389 g_Game_StartServer(map
, GMode
, LimT
, LimS
, Lives
, Opt
, n
, 0, Port
);
6392 // Execute script when game loads:
6393 s
:= Find_Param_Value(pars
, '-exec');
6396 // if not isWadPath(s) then
6397 // s := GameDir + '/' + s;
6402 if IOResult
<> 0 then
6404 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], ['Failed to read file: ' + s
]), TMsgType
.Warning
);
6405 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_READ
], [s
]));
6409 e_WriteLog('Executing script: ' + s
, TMsgType
.Notify
);
6410 g_Console_Add(Format(_lc
[I_CONSOLE_EXEC
], [s
]));
6415 if IOResult
<> 0 then
6417 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], ['Failed to read file: ' + s
]), TMsgType
.Warning
);
6418 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_READ
], [s
]));
6422 if Pos('#', s
) <> 1 then // script comment
6423 g_Console_Process(s
, True);
6434 conRegVar('pf_draw_frame', @g_profile_frame_draw
, 'draw frame rendering profiles', 'render profiles');
6435 //conRegVar('pf_update_frame', @g_profile_frame_update, 'draw frame updating profiles', 'update profiles');
6436 conRegVar('pf_coldet', @g_profile_collision
, 'draw collision detection profiles', 'coldet profiles');
6437 conRegVar('pf_los', @g_profile_los
, 'draw monster LOS profiles', 'monster LOS profiles');
6439 conRegVar('r_sq_draw', @gdbg_map_use_accel_render
, 'accelerated spatial queries in rendering', 'accelerated rendering');
6440 conRegVar('cd_sq_enabled', @gdbg_map_use_accel_coldet
, 'accelerated spatial queries in map coldet', 'accelerated map coldet');
6441 conRegVar('mon_sq_enabled', @gmon_debug_use_sqaccel
, 'accelerated spatial queries for monsters', 'accelerated monster coldet');
6442 conRegVar('wtrace_sq_enabled', @gwep_debug_fast_trace
, 'accelerated spatial queries for weapon hitscan trace', 'accelerated weapon hitscan');
6444 conRegVar('pr_enabled', @gpart_dbg_enabled
, 'enable/disable particles', 'particles');
6445 conRegVar('pr_phys_enabled', @gpart_dbg_phys_enabled
, 'enable/disable particle physics', 'particle physics');
6447 conRegVar('los_enabled', @gmon_dbg_los_enabled
, 'enable/disable monster LOS calculations', 'monster LOS', true);
6448 conRegVar('mon_think', @gmon_debug_think
, 'enable/disable monster thinking', 'monster thinking', true);
6450 {$IFDEF ENABLE_HOLMES}
6451 conRegVar('dbg_holmes', @g_holmes_enabled
, 'enable/disable Holmes', 'Holmes', true);
6454 conRegVar('dbg_ignore_level_bounds', @g_dbg_ignore_bounds
, 'ignore level bounds', '', false);
6456 conRegVar('r_scale', @g_dbg_scale
, 0.01, 100.0, 'render scale', '', false);
6457 conRegVar('r_resolution_scale', @r_pixel_scale
, 0.01, 100.0, 'upscale factor', '', false);
6459 conRegVar('light_enabled', @gwin_k8_enable_light_experiments
, 'enable/disable dynamic lighting', 'lighting');
6460 conRegVar('light_player_halo', @g_playerLight
, 'enable/disable player halo', 'player light halo');
6462 conRegVar('r_smallmap_align_h', @r_smallmap_h
, 'halign: 0: left; 1: center; 2: right', 'horizontal aligning of small maps');
6463 conRegVar('r_smallmap_align_v', @r_smallmap_v
, 'valign: 0: top; 1: center; 2: bottom', 'vertial aligning of small maps');
6465 conRegVar('r_showfps', @gShowFPS
, 'draw fps counter', 'draw fps counter');
6466 conRegVar('r_showtime', @gShowTime
, 'show game time', 'show game time');
6467 conRegVar('r_showping', @gShowPing
, 'show ping', 'show ping');
6468 conRegVar('r_showscore', @gShowGoals
, 'show score', 'show score');
6469 conRegVar('r_showkillmsg', @gShowKillMsg
, 'show kill log', 'show kill log');
6470 conRegVar('r_showlives', @gShowLives
, 'show lives', 'show lives');
6471 conRegVar('r_showspect', @gSpectHUD
, 'show spectator hud', 'show spectator hud');
6472 conRegVar('r_showstat', @gShowStat
, 'show stats', 'show stats');
6473 conRegVar('r_showpids', @gShowPIDs
, 'show PIDs', 'show PIDs');