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
, r_graphics
, g_res_downloader
,
24 g_sound
, g_gui
, utils
, md5
, mempool
, xprofiler
,
28 TGameSettings
= record
35 ItemRespawnTime
: Word;
46 TDelayedEvent
= record
55 Sound
: TPlayableSound
;
56 Tags
: Array of String;
60 TPlayerSettings
= record
79 function g_Game_IsNet(): Boolean;
80 function g_Game_IsServer(): Boolean;
81 function g_Game_IsClient(): Boolean;
82 procedure g_Game_Init();
83 procedure g_Game_Free (freeTextures
: Boolean=true);
84 procedure g_Game_LoadData();
85 procedure g_Game_FreeData();
86 procedure g_Game_Update();
87 procedure g_Game_PreUpdate();
88 procedure g_Game_Quit();
89 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
, r_playermodel
;
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 r_PlayerModel_Initialize
;
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 r_PlayerModel_Finalize
;
2289 g_PlayerModel_FreeData();
2290 g_Texture_DeleteAll();
2291 g_Frames_DeleteAll();
2293 //g_Menu_Free(); //k8: this segfaults after resolution change; who cares?
2296 if NetInitDone
then g_Net_Free
;
2298 // remove map after test
2299 if gMapToDelete
<> '' then
2300 g_Game_DeleteTestMap();
2306 procedure g_Game_FreeData();
2308 if not DataLoaded
then Exit
;
2311 g_Weapon_FreeData();
2312 g_Monsters_FreeData();
2314 e_WriteLog('Releasing game data...', TMsgType
.Notify
);
2316 g_Texture_Delete('NOTEXTURE');
2317 g_Texture_Delete('TEXTURE_PLAYER_HUD');
2318 g_Texture_Delete('TEXTURE_PLAYER_HUDBG');
2319 g_Texture_Delete('TEXTURE_PLAYER_ARMORHUD');
2320 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG');
2321 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG_S');
2322 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG_D');
2323 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG');
2324 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG_S');
2325 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG_D');
2326 g_Texture_Delete('TEXTURE_PLAYER_TALKBUBBLE');
2327 g_Texture_Delete('TEXTURE_PLAYER_INVULPENTA');
2328 g_Frames_DeleteByName('FRAMES_TELEPORT');
2329 g_Frames_DeleteByName('FRAMES_PUNCH');
2330 g_Frames_DeleteByName('FRAMES_PUNCH_UP');
2331 g_Frames_DeleteByName('FRAMES_PUNCH_DN');
2332 g_Frames_DeleteByName('FRAMES_PUNCH_BERSERK');
2333 g_Frames_DeleteByName('FRAMES_PUNCH_BERSERK_UP');
2334 g_Frames_DeleteByName('FRAMES_PUNCH_BERSERK_DN');
2335 g_Sound_Delete('SOUND_GAME_TELEPORT');
2336 g_Sound_Delete('SOUND_GAME_NOTELEPORT');
2337 g_Sound_Delete('SOUND_GAME_SECRET');
2338 g_Sound_Delete('SOUND_GAME_DOOROPEN');
2339 g_Sound_Delete('SOUND_GAME_DOORCLOSE');
2340 g_Sound_Delete('SOUND_GAME_BULK1');
2341 g_Sound_Delete('SOUND_GAME_BULK2');
2342 g_Sound_Delete('SOUND_GAME_BUBBLE1');
2343 g_Sound_Delete('SOUND_GAME_BUBBLE2');
2344 g_Sound_Delete('SOUND_GAME_BURNING');
2345 g_Sound_Delete('SOUND_GAME_SWITCH1');
2346 g_Sound_Delete('SOUND_GAME_SWITCH0');
2353 g_Sound_Delete('SOUND_ANNOUNCER_GOOD1');
2354 g_Sound_Delete('SOUND_ANNOUNCER_GOOD2');
2355 g_Sound_Delete('SOUND_ANNOUNCER_GOOD3');
2356 g_Sound_Delete('SOUND_ANNOUNCER_GOOD4');
2363 g_Sound_Delete('SOUND_ANNOUNCER_KILL2X');
2364 g_Sound_Delete('SOUND_ANNOUNCER_KILL3X');
2365 g_Sound_Delete('SOUND_ANNOUNCER_KILL4X');
2366 g_Sound_Delete('SOUND_ANNOUNCER_KILLMX');
2372 g_Sound_Delete('SOUND_ANNOUNCER_MUHAHA1');
2373 g_Sound_Delete('SOUND_ANNOUNCER_MUHAHA2');
2374 g_Sound_Delete('SOUND_ANNOUNCER_MUHAHA3');
2376 sound_get_flag
[0].Free();
2377 sound_get_flag
[1].Free();
2378 sound_lost_flag
[0].Free();
2379 sound_lost_flag
[1].Free();
2380 sound_ret_flag
[0].Free();
2381 sound_ret_flag
[1].Free();
2382 sound_cap_flag
[0].Free();
2383 sound_cap_flag
[1].Free();
2385 g_Sound_Delete('SOUND_CTF_GET1');
2386 g_Sound_Delete('SOUND_CTF_GET2');
2387 g_Sound_Delete('SOUND_CTF_LOST1');
2388 g_Sound_Delete('SOUND_CTF_LOST2');
2389 g_Sound_Delete('SOUND_CTF_RETURN1');
2390 g_Sound_Delete('SOUND_CTF_RETURN2');
2391 g_Sound_Delete('SOUND_CTF_CAPTURE1');
2392 g_Sound_Delete('SOUND_CTF_CAPTURE2');
2394 g_Game_FreeChatSounds();
2396 DataLoaded
:= False;
2399 procedure g_FatalError(Text: String);
2401 g_Console_Add(Format(_lc
[I_FATAL_ERROR
], [Text]), True);
2402 e_WriteLog(Format(_lc
[I_FATAL_ERROR
], [Text]), TMsgType
.Warning
);
2404 gExit
:= EXIT_SIMPLE
;
2405 if gGameOn
then EndGame
;
2408 procedure g_SimpleError(Text: String);
2410 g_Console_Add(Format(_lc
[I_SIMPLE_ERROR
], [Text]), True);
2411 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], [Text]), TMsgType
.Warning
);
2414 procedure g_Game_SetupScreenSize();
2416 RES_FACTOR
= 4.0 / 3.0;
2422 // Размер экранов игроков:
2423 gPlayerScreenSize
.X
:= gScreenWidth
-196;
2424 if (gPlayer1
<> nil) and (gPlayer2
<> nil) then
2425 gPlayerScreenSize
.Y
:= gScreenHeight
div 2
2427 gPlayerScreenSize
.Y
:= gScreenHeight
;
2429 // Размер заднего плана:
2430 if BackID
<> DWORD(-1) then
2433 if (gScreenWidth
*s
> gMapInfo
.Width
) or
2434 (gScreenHeight
*s
> gMapInfo
.Height
) then
2436 gBackSize
.X
:= gScreenWidth
;
2437 gBackSize
.Y
:= gScreenHeight
;
2441 e_GetTextureSize(BackID
, @bw
, @bh
);
2442 rf
:= Single(bw
) / Single(bh
);
2443 if (rf
> RES_FACTOR
) then bw
:= Round(Single(bh
) * RES_FACTOR
)
2444 else if (rf
< RES_FACTOR
) then bh
:= Round(Single(bw
) / RES_FACTOR
);
2445 s
:= Max(gScreenWidth
/ bw
, gScreenHeight
/ bh
);
2446 if (s
< 1.0) then s
:= 1.0;
2447 gBackSize
.X
:= Round(bw
*s
);
2448 gBackSize
.Y
:= Round(bh
*s
);
2453 procedure g_Game_ChangeResolution(newWidth
, newHeight
: Word; nowFull
, nowMax
: Boolean);
2455 sys_SetDisplayMode(newWidth
, newHeight
, gBPP
, nowFull
, nowMax
);
2458 procedure g_Game_AddPlayer(Team
: Byte = TEAM_NONE
);
2460 if ((not gGameOn
) and (gState
<> STATE_INTERCUSTOM
))
2461 or (not (gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
])) then
2464 if (gGameSettings
.MaxLives
> 0) and (gLMSRespawn
= LMS_RESPAWN_NONE
) then
2467 if gPlayer1
= nil then
2469 if g_Game_IsClient
then
2471 if NetPlrUID1
> -1 then
2472 MC_SEND_CheatRequest(NET_CHEAT_SPECTATE
);
2476 if not (Team
in [TEAM_RED
, TEAM_BLUE
]) then
2477 Team
:= gPlayer1Settings
.Team
;
2479 // Создание первого игрока:
2480 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
2481 gPlayer1Settings
.Color
,
2483 if gPlayer1
= nil then
2484 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]))
2487 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
2488 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [gPlayer1
.Name
]), True);
2489 if g_Game_IsServer
and g_Game_IsNet
then
2490 MH_SEND_PlayerCreate(gPlayer1
.UID
);
2491 gPlayer1
.Respawn(False, True);
2492 g_Net_Slist_ServerPlayerComes();
2497 if gPlayer2
= nil then
2499 if g_Game_IsClient
then
2501 if NetPlrUID2
> -1 then
2502 gPlayer2
:= g_Player_Get(NetPlrUID2
);
2506 if not (Team
in [TEAM_RED
, TEAM_BLUE
]) then
2507 Team
:= gPlayer2Settings
.Team
;
2509 // Создание второго игрока:
2510 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
2511 gPlayer2Settings
.Color
,
2513 if gPlayer2
= nil then
2514 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]))
2517 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
2518 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [gPlayer2
.Name
]), True);
2519 if g_Game_IsServer
and g_Game_IsNet
then
2520 MH_SEND_PlayerCreate(gPlayer2
.UID
);
2521 gPlayer2
.Respawn(False, True);
2522 g_Net_Slist_ServerPlayerComes();
2529 procedure g_Game_RemovePlayer();
2533 if ((not gGameOn
) and (gState
<> STATE_INTERCUSTOM
))
2534 or (not (gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
])) then
2539 if g_Game_IsServer
then
2542 Pl
.Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
2543 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [Pl
.Name
]), True);
2544 g_Player_Remove(Pl
.UID
);
2545 g_Net_Slist_ServerPlayerLeaves();
2549 gSpectLatchPID2
:= Pl
.UID
;
2557 if g_Game_IsServer
then
2560 Pl
.Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
2561 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [Pl
.Name
]), True);
2562 g_Player_Remove(Pl
.UID
);
2563 g_Net_Slist_ServerPlayerLeaves();
2566 gSpectLatchPID1
:= Pl
.UID
;
2568 MC_SEND_CheatRequest(NET_CHEAT_SPECTATE
);
2572 g_Net_Slist_ServerPlayerLeaves();
2575 procedure g_Game_Spectate();
2577 g_Game_RemovePlayer();
2578 if gPlayer1
<> nil then
2579 g_Game_RemovePlayer();
2582 procedure g_Game_SpectateCenterView();
2584 gSpectX
:= Max(gMapInfo
.Width
div 2 - gScreenWidth
div 2, 0);
2585 gSpectY
:= Max(gMapInfo
.Height
div 2 - gScreenHeight
div 2, 0);
2588 procedure g_Game_StartSingle(Map
: String; TwoPlayers
: Boolean; nPlayers
: Byte);
2595 e_WriteLog('Starting singleplayer game...', TMsgType
.Notify
);
2597 g_Game_ClearLoading();
2600 FillByte(gGameSettings
, SizeOf(TGameSettings
), 0);
2603 gGameSettings
.GameType
:= GT_SINGLE
;
2604 gGameSettings
.MaxLives
:= 0;
2605 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_ALLOWEXIT
;
2606 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_MONSTERS
;
2607 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_BOTVSMONSTER
;
2608 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_TEAMHITPROJECTILE
;
2609 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_TEAMHITTRACE
;
2610 gSwitchGameMode
:= GM_SINGLE
;
2612 gLMSRespawn
:= LMS_RESPAWN_NONE
;
2613 gLMSRespawnTime
:= 0;
2614 gSpectLatchPID1
:= 0;
2615 gSpectLatchPID2
:= 0;
2617 g_Game_ExecuteEvent('ongamestart');
2619 // Установка размеров окон игроков:
2620 g_Game_SetupScreenSize();
2622 // Создание первого игрока:
2623 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
2624 gPlayer1Settings
.Color
,
2625 gPlayer1Settings
.Team
, False));
2626 if gPlayer1
= nil then
2628 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
2632 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
2635 // Создание второго игрока, если есть:
2638 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
2639 gPlayer2Settings
.Color
,
2640 gPlayer2Settings
.Team
, False));
2641 if gPlayer2
= nil then
2643 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
2647 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
2651 // Загрузка и запуск карты:
2652 if not g_Game_StartMap(false{asMegawad}, MAP
, True) then
2654 if (Pos(':\', Map
) > 0) or (Pos(':/', Map
) > 0) then tmps
:= Map
else tmps
:= gGameSettings
.WAD
+ ':\' + MAP
;
2655 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [tmps
]));
2659 // Настройки игроков и ботов:
2663 for i
:= nPl
+1 to nPlayers
do
2664 g_Player_Create(STD_PLAYER_MODEL
, _RGB(0, 0, 0), 0, True);
2667 procedure g_Game_StartCustom(Map
: String; GameMode
: Byte;
2668 TimeLimit
, GoalLimit
: Word;
2670 Options
: LongWord; nPlayers
: Byte);
2676 e_WriteLog('Starting custom game...', TMsgType
.Notify
);
2678 g_Game_ClearLoading();
2681 gGameSettings
.GameType
:= GT_CUSTOM
;
2682 gGameSettings
.GameMode
:= GameMode
;
2683 gSwitchGameMode
:= GameMode
;
2684 gGameSettings
.TimeLimit
:= TimeLimit
;
2685 gGameSettings
.GoalLimit
:= GoalLimit
;
2686 gGameSettings
.MaxLives
:= IfThen(GameMode
= GM_CTF
, 0, MaxLives
);
2687 gGameSettings
.Options
:= Options
;
2689 gCoopTotalMonstersKilled
:= 0;
2690 gCoopTotalSecretsFound
:= 0;
2691 gCoopTotalMonsters
:= 0;
2692 gCoopTotalSecrets
:= 0;
2696 gLMSRespawn
:= LMS_RESPAWN_NONE
;
2697 gLMSRespawnTime
:= 0;
2698 gSpectLatchPID1
:= 0;
2699 gSpectLatchPID2
:= 0;
2701 g_Game_ExecuteEvent('ongamestart');
2703 // Установка размеров окон игроков:
2704 g_Game_SetupScreenSize();
2706 // Режим наблюдателя:
2707 if nPlayers
= 0 then
2714 if nPlayers
>= 1 then
2716 // Создание первого игрока:
2717 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
2718 gPlayer1Settings
.Color
,
2719 gPlayer1Settings
.Team
, False));
2720 if gPlayer1
= nil then
2722 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
2726 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
2730 if nPlayers
>= 2 then
2732 // Создание второго игрока:
2733 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
2734 gPlayer2Settings
.Color
,
2735 gPlayer2Settings
.Team
, False));
2736 if gPlayer2
= nil then
2738 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
2742 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
2746 // Загрузка и запуск карты:
2747 if not g_Game_StartMap(true{asMegawad}, Map
, True) then
2749 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [Map
]));
2753 // Нет точек появления:
2754 if (g_Map_GetPointCount(RESPAWNPOINT_PLAYER1
) +
2755 g_Map_GetPointCount(RESPAWNPOINT_PLAYER2
) +
2756 g_Map_GetPointCount(RESPAWNPOINT_DM
) +
2757 g_Map_GetPointCount(RESPAWNPOINT_RED
)+
2758 g_Map_GetPointCount(RESPAWNPOINT_BLUE
)) < 1 then
2760 g_FatalError(_lc
[I_GAME_ERROR_GET_SPAWN
]);
2764 // Настройки игроков и ботов:
2768 for i
:= nPl
+1 to nPlayers
do
2769 g_Player_Create(STD_PLAYER_MODEL
, _RGB(0, 0, 0), 0, True);
2772 procedure g_Game_StartServer(Map
: String; GameMode
: Byte;
2773 TimeLimit
, GoalLimit
: Word; MaxLives
: Byte;
2774 Options
: LongWord; nPlayers
: Byte;
2775 IPAddr
: LongWord; Port
: Word);
2778 g_Net_Slist_ServerClosed();
2780 e_WriteLog('Starting net game (server)...', TMsgType
.Notify
);
2782 g_Game_ClearLoading();
2785 gGameSettings
.GameType
:= GT_SERVER
;
2786 gGameSettings
.GameMode
:= GameMode
;
2787 gSwitchGameMode
:= GameMode
;
2788 gGameSettings
.TimeLimit
:= TimeLimit
;
2789 gGameSettings
.GoalLimit
:= GoalLimit
;
2790 gGameSettings
.MaxLives
:= IfThen(GameMode
= GM_CTF
, 0, MaxLives
);
2791 gGameSettings
.Options
:= Options
;
2793 gCoopTotalMonstersKilled
:= 0;
2794 gCoopTotalSecretsFound
:= 0;
2795 gCoopTotalMonsters
:= 0;
2796 gCoopTotalSecrets
:= 0;
2800 gLMSRespawn
:= LMS_RESPAWN_NONE
;
2801 gLMSRespawnTime
:= 0;
2802 gSpectLatchPID1
:= 0;
2803 gSpectLatchPID2
:= 0;
2805 g_Game_ExecuteEvent('ongamestart');
2807 // Установка размеров окна игрока
2808 g_Game_SetupScreenSize();
2810 // Режим наблюдателя:
2811 if nPlayers
= 0 then
2817 if nPlayers
>= 1 then
2819 // Создание первого игрока:
2820 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
2821 gPlayer1Settings
.Color
,
2822 gPlayer1Settings
.Team
, False));
2823 if gPlayer1
= nil then
2825 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
2829 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
2832 if nPlayers
>= 2 then
2834 // Создание второго игрока:
2835 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
2836 gPlayer2Settings
.Color
,
2837 gPlayer2Settings
.Team
, False));
2838 if gPlayer2
= nil then
2840 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
2844 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
2847 g_Game_SetLoadingText(_lc
[I_LOAD_HOST
], 0, False);
2848 if NetForwardPorts
then
2849 g_Game_SetLoadingText(_lc
[I_LOAD_PORTS
], 0, False);
2852 if not g_Net_Host(IPAddr
, Port
, NetMaxClients
) then
2854 g_FatalError(_lc
[I_NET_MSG
] + Format(_lc
[I_NET_ERR_HOST
], [Port
]));
2858 g_Net_Slist_Set(NetMasterList
);
2860 g_Net_Slist_ServerStarted();
2862 // Загрузка и запуск карты:
2863 if not g_Game_StartMap(false{asMegawad}, Map
, True) then
2865 g_Net_Slist_ServerClosed();
2866 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [Map
]));
2870 // Нет точек появления:
2871 if (g_Map_GetPointCount(RESPAWNPOINT_PLAYER1
) +
2872 g_Map_GetPointCount(RESPAWNPOINT_PLAYER2
) +
2873 g_Map_GetPointCount(RESPAWNPOINT_DM
) +
2874 g_Map_GetPointCount(RESPAWNPOINT_RED
)+
2875 g_Map_GetPointCount(RESPAWNPOINT_BLUE
)) < 1 then
2877 g_Net_Slist_ServerClosed();
2878 g_FatalError(_lc
[I_GAME_ERROR_GET_SPAWN
]);
2882 // Настройки игроков и ботов:
2885 g_Net_Slist_ServerMapStarted();
2886 NetState
:= NET_STATE_GAME
;
2889 procedure g_Game_StartClient(Addr
: String; Port
: Word; PW
: String);
2904 e_WriteLog('Starting net game (client)...', TMsgType
.Notify
);
2905 e_WriteLog('NET: Trying to connect to ' + Addr
+ ':' + IntToStr(Port
) + '...', TMsgType
.Notify
);
2907 g_Game_ClearLoading();
2910 gGameSettings
.GameType
:= GT_CLIENT
;
2912 gCoopTotalMonstersKilled
:= 0;
2913 gCoopTotalSecretsFound
:= 0;
2914 gCoopTotalMonsters
:= 0;
2915 gCoopTotalSecrets
:= 0;
2919 g_Game_ExecuteEvent('ongamestart');
2921 // Установка размеров окон игроков:
2922 g_Game_SetupScreenSize();
2924 NetState
:= NET_STATE_AUTH
;
2926 g_Game_SetLoadingText(_lc
[I_LOAD_CONNECT
], 0, False);
2928 // create (or update) map/resource databases
2929 g_Res_CreateDatabases(true);
2931 gLMSRespawn
:= LMS_RESPAWN_NONE
;
2932 gLMSRespawnTime
:= 0;
2933 gSpectLatchPID1
:= 0;
2934 gSpectLatchPID2
:= 0;
2937 if not g_Net_Connect(Addr
, Port
) then
2939 g_FatalError(_lc
[I_NET_MSG
] + _lc
[I_NET_ERR_CONN
]);
2940 NetState
:= NET_STATE_NONE
;
2944 g_Game_SetLoadingText(_lc
[I_LOAD_SEND_INFO
], 0, False);
2946 g_Game_SetLoadingText(_lc
[I_LOAD_WAIT_INFO
], 0, False);
2951 // fuck! https://www.mail-archive.com/enet-discuss@cubik.org/msg00852.html
2952 // tl;dr: on shitdows, we can get -1 sometimes, and it is *NOT* a failure.
2953 // thank you, enet. let's ignore failures altogether then.
2954 while (enet_host_service(NetHost
, @NetEvent
, 50) > 0) do
2956 if (NetEvent
.kind
= ENET_EVENT_TYPE_RECEIVE
) then
2958 if (NetEvent
.channelID
= NET_CHAN_DOWNLOAD_EX
) then
2960 // ignore all download packets, they're processed by separate code
2961 enet_packet_destroy(NetEvent
.packet
);
2964 Ptr
:= NetEvent
.packet
^.data
;
2965 if not InMsg
.Init(Ptr
, NetEvent
.packet
^.dataLength
, True) then
2967 enet_packet_destroy(NetEvent
.packet
);
2971 InMsg
.ReadLongWord(); // skip size
2972 MID
:= InMsg
.ReadByte();
2974 if (MID
= NET_MSG_INFO
) and (State
= 0) then
2976 NetMyID
:= InMsg
.ReadByte();
2977 NetPlrUID1
:= InMsg
.ReadWord();
2979 WadName
:= InMsg
.ReadString();
2980 Map
:= InMsg
.ReadString();
2982 gWADHash
:= InMsg
.ReadMD5();
2984 gGameSettings
.GameMode
:= InMsg
.ReadByte();
2985 gSwitchGameMode
:= gGameSettings
.GameMode
;
2986 gGameSettings
.GoalLimit
:= InMsg
.ReadWord();
2987 gGameSettings
.TimeLimit
:= InMsg
.ReadWord();
2988 gGameSettings
.MaxLives
:= InMsg
.ReadByte();
2989 gGameSettings
.Options
:= InMsg
.ReadLongWord();
2990 T
:= InMsg
.ReadLongWord();
2992 //newResPath := g_Res_SearchSameWAD(MapsDir, WadName, gWADHash);
2993 //if newResPath = '' then
2995 //g_Game_SetLoadingText(_lc[I_LOAD_DL_RES], 0, False);
2996 newResPath
:= g_Res_DownloadMapWAD(ExtractFileName(WadName
), gWADHash
);
2997 if newResPath
= '' then
2999 g_FatalError(_lc
[I_NET_ERR_HASH
]);
3000 enet_packet_destroy(NetEvent
.packet
);
3001 NetState
:= NET_STATE_NONE
;
3004 e_LogWritefln('using downloaded map wad [%s] for [%s]`', [newResPath
, WadName
], TMsgType
.Notify
);
3006 //newResPath := ExtractRelativePath(MapsDir, newResPath);
3009 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
3010 gPlayer1Settings
.Color
,
3011 gPlayer1Settings
.Team
, False));
3013 if gPlayer1
= nil then
3015 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
3017 enet_packet_destroy(NetEvent
.packet
);
3018 NetState
:= NET_STATE_NONE
;
3022 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
3023 gPlayer1
.UID
:= NetPlrUID1
;
3024 gPlayer1
.Reset(True);
3026 if not g_Game_StartMap(false{asMegawad}, newResPath
+ ':\' + Map
, True) then
3028 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [WadName
+ ':\' + Map
]));
3030 enet_packet_destroy(NetEvent
.packet
);
3031 NetState
:= NET_STATE_NONE
;
3039 enet_packet_destroy(NetEvent
.packet
);
3043 enet_packet_destroy(NetEvent
.packet
);
3047 if (NetEvent
.kind
= ENET_EVENT_TYPE_DISCONNECT
) then
3050 if (NetEvent
.data
<= NET_DISC_MAX
) then
3051 g_Console_Add(_lc
[I_NET_MSG_ERROR
] + _lc
[I_NET_ERR_CONN
] + ' ' +
3052 _lc
[TStrings_Locale(Cardinal(I_NET_DISC_NONE
) + NetEvent
.data
)], True);
3059 ProcessLoading(true);
3061 if g_Net_UserRequestExit() then
3070 g_FatalError(_lc
[I_NET_MSG
] + _lc
[I_NET_ERR_CONN
]);
3071 NetState
:= NET_STATE_NONE
;
3076 NetState
:= NET_STATE_GAME
;
3077 MC_SEND_FullStateRequest
;
3078 e_WriteLog('NET: Connection successful.', TMsgType
.Notify
);
3082 lastAsMegaWad
: Boolean = false;
3084 procedure g_Game_ChangeMap(const MapPath
: String);
3088 g_Game_ClearLoading();
3090 Force
:= gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
];
3091 // Если уровень завершился по триггеру Выход, не очищать инвентарь
3092 if gExitByTrigger
then
3095 gExitByTrigger
:= False;
3097 if not g_Game_StartMap(lastAsMegaWad
, MapPath
, Force
) then
3098 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [MapPath
]));
3101 procedure g_Game_Restart();
3105 if g_Game_IsClient
then
3107 map
:= g_ExtractFileName(gMapInfo
.Map
);
3108 e_LogWritefln('g_Game_Restart: map = "%s" gCurrentMapFileName = "%s"', [map
, gCurrentMapFileName
]);
3112 g_Game_ClearLoading();
3113 g_Game_StartMap(lastAsMegaWad
, Map
, True, gCurrentMapFileName
);
3116 function g_Game_StartMap (asMegawad
: Boolean; Map
: String; Force
: Boolean = False; const oldMapPath
: AnsiString=''): Boolean;
3118 NewWAD
, ResName
: String;
3122 g_Map_Free((Map
<> gCurrentMapFileName
) and (oldMapPath
<> gCurrentMapFileName
));
3123 g_Player_RemoveAllCorpses();
3125 if (not g_Game_IsClient
) and
3126 (gSwitchGameMode
<> gGameSettings
.GameMode
) and
3127 (gGameSettings
.GameMode
<> GM_SINGLE
) then
3129 if gSwitchGameMode
= GM_CTF
then
3130 gGameSettings
.MaxLives
:= 0;
3131 gGameSettings
.GameMode
:= gSwitchGameMode
;
3134 gSwitchGameMode
:= gGameSettings
.GameMode
;
3136 g_Player_ResetTeams();
3138 lastAsMegaWad
:= asMegawad
;
3139 if isWadPath(Map
) then
3141 NewWAD
:= g_ExtractWadName(Map
);
3142 ResName
:= g_ExtractFileName(Map
);
3143 if g_Game_IsServer
then
3145 nws
:= findDiskWad(NewWAD
);
3146 //writeln('000: Map=[', Map, ']; nws=[', nws, ']; NewWAD=[', NewWAD, ']');
3149 if (length(nws
) = 0) then nws
:= e_FindWad(MegawadDirs
, NewWAD
);
3150 if (length(nws
) = 0) then nws
:= e_FindWad(MapDirs
, NewWAD
);
3154 if (length(nws
) = 0) then nws
:= e_FindWad(MapDirs
, NewWAD
);
3155 if (length(nws
) = 0) then nws
:= e_FindWad(MegawadDirs
, NewWAD
);
3157 //if (length(nws) = 0) then nws := e_FindWad(MapDownloadDirs, NewWAD);
3158 //writeln('001: Map=[', Map, ']; nws=[', nws, ']; NewWAD=[', NewWAD, ']');
3160 if (length(nws
) = 0) then
3162 ResName
:= ''; // failed
3167 if (g_Game_IsNet
) then gWADHash
:= MD5File(nws
);
3168 //writeln('********: nws=', nws, ' : Map=', Map, ' : nw=', NewWAD, ' : resname=', ResName);
3169 g_Game_LoadWAD(NewWAD
);
3174 // hash received in MC_RECV_GameEvent -> NET_EV_MAPSTART
3175 NewWAD
:= g_Game_ClientWAD(NewWAD
, gWADHash
);
3180 NewWAD
:= gGameSettings
.WAD
;
3186 //writeln('********: gsw=', gGameSettings.WAD, '; rn=', ResName);
3188 if (ResName
<> '') and (NewWAD
<> '') then
3190 //result := g_Map_Load(gGameSettings.WAD + ':\' + ResName);
3191 result
:= g_Map_Load(NewWAD
+':\'+ResName
);
3195 g_Player_ResetAll(Force
or gLastMap
, gGameSettings
.GameType
= GT_SINGLE
);
3197 gState
:= STATE_NONE
;
3198 g_ActiveWindow
:= nil;
3204 if gGameSettings
.GameMode
= GM_CTF
then
3206 g_Map_ResetFlag(FLAG_RED
);
3207 g_Map_ResetFlag(FLAG_BLUE
);
3208 // CTF, а флагов нет:
3209 if not g_Map_HaveFlagPoints() then
3210 g_SimpleError(_lc
[I_GAME_ERROR_CTF
]);
3215 gState
:= STATE_MENU
;
3220 gPauseMain
:= false;
3221 gPauseHolmes
:= false;
3222 NetTimeToUpdate
:= 1;
3223 NetTimeToReliable
:= 0;
3224 NetTimeToMaster
:= NetMasterRate
;
3225 gSpectLatchPID1
:= 0;
3226 gSpectLatchPID2
:= 0;
3227 gMissionFailed
:= False;
3230 gCoopMonstersKilled
:= 0;
3231 gCoopSecretsFound
:= 0;
3233 gVoteInProgress
:= False;
3234 gVotePassed
:= False;
3240 if not gGameOn
then Exit
;
3242 g_Game_SpectateCenterView();
3244 if g_Game_IsServer
then
3246 if (gGameSettings
.MaxLives
> 0) and (gGameSettings
.WarmupTime
> 0) then
3248 gLMSRespawn
:= LMS_RESPAWN_WARMUP
;
3249 gLMSRespawnTime
:= gTime
+ gGameSettings
.WarmupTime
*1000;
3250 gLMSSoftSpawn
:= True;
3251 if g_Game_IsNet
then
3252 MH_SEND_GameEvent(NET_EV_LMS_WARMUP
, gLMSRespawnTime
- gTime
);
3256 gLMSRespawn
:= LMS_RESPAWN_NONE
;
3257 gLMSRespawnTime
:= 0;
3261 if NetMode
= NET_SERVER
then
3263 MH_SEND_GameEvent(NET_EV_MAPSTART
, gGameSettings
.GameMode
, Map
);
3266 g_Net_Slist_ServerMapStarted();
3268 if NetClients
<> nil then
3269 for I
:= 0 to High(NetClients
) do
3270 if NetClients
[I
].Used
then
3272 NetClients
[I
].Voted
:= False;
3273 if NetClients
[I
].RequestedFullUpdate
then
3275 MH_SEND_Everything((NetClients
[I
].State
= NET_STATE_AUTH
), I
);
3276 NetClients
[I
].RequestedFullUpdate
:= False;
3280 g_Net_UnbanNonPermHosts();
3285 gCoopTotalMonstersKilled
:= 0;
3286 gCoopTotalSecretsFound
:= 0;
3287 gCoopTotalMonsters
:= 0;
3288 gCoopTotalSecrets
:= 0;
3292 g_Game_ExecuteEvent('onmapstart');
3295 procedure SetFirstLevel
;
3299 MapList
:= g_Map_GetMapsList(gGameSettings
.WAD
);
3300 if MapList
= nil then
3303 SortSArray(MapList
);
3304 gNextMap
:= MapList
[Low(MapList
)];
3309 procedure g_Game_ExitLevel(const Map
: AnsiString);
3313 gCoopTotalMonstersKilled
:= gCoopTotalMonstersKilled
+ gCoopMonstersKilled
;
3314 gCoopTotalSecretsFound
:= gCoopTotalSecretsFound
+ gCoopSecretsFound
;
3315 gCoopTotalMonsters
:= gCoopTotalMonsters
+ gTotalMonsters
;
3316 gCoopTotalSecrets
:= gCoopTotalSecrets
+ gSecretsCount
;
3318 // Вышли в выход в Одиночной игре:
3319 if gGameSettings
.GameType
= GT_SINGLE
then
3320 gExit
:= EXIT_ENDLEVELSINGLE
3321 else // Вышли в выход в Своей игре
3323 gExit
:= EXIT_ENDLEVELCUSTOM
;
3324 if gGameSettings
.GameMode
= GM_COOP
then
3325 g_Player_RememberAll
;
3327 if not g_Map_Exist(gGameSettings
.WAD
+ ':\' + gNextMap
) then
3330 if gGameSettings
.GameMode
= GM_COOP
then
3333 gStatsPressed
:= True;
3334 gNextMap
:= 'MAP01';
3336 if not g_Map_Exist(gGameSettings
.WAD
+ ':\' + gNextMap
) then
3339 if g_Game_IsNet
then
3341 MH_SEND_GameStats();
3342 MH_SEND_CoopStats();
3348 procedure g_Game_RestartLevel();
3352 if gGameSettings
.GameMode
= GM_SINGLE
then
3357 gExit
:= EXIT_ENDLEVELCUSTOM
;
3358 Map
:= g_ExtractFileName(gMapInfo
.Map
);
3362 function g_Game_ClientWAD (NewWAD
: String; const WHash
: TMD5Digest
): AnsiString;
3364 gWAD
{, xwad}: String;
3367 if not g_Game_IsClient
then Exit
;
3368 //e_LogWritefln('*** g_Game_ClientWAD: `%s`', [NewWAD]);
3370 gWAD
:= g_Res_DownloadMapWAD(ExtractFileName(NewWAD
), WHash
);
3375 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_WAD
], [ExtractFileName(NewWAD
)]));
3379 e_LogWritefln('using downloaded client map wad [%s] for [%s]', [gWAD
, NewWAD
], TMsgType
.Notify
);
3382 g_Game_LoadWAD(NewWAD
);
3386 if LowerCase(NewWAD) = LowerCase(gGameSettings.WAD) then Exit;
3387 gWAD := g_Res_SearchSameWAD(MapsDir, ExtractFileName(NewWAD), WHash);
3390 g_Game_SetLoadingText(_lc[I_LOAD_DL_RES], 0, False);
3391 gWAD := g_Res_DownloadMapWAD(ExtractFileName(NewWAD), WHash);
3395 g_FatalError(Format(_lc[I_GAME_ERROR_MAP_WAD], [ExtractFileName(NewWAD)]));
3399 NewWAD := ExtractRelativePath(MapsDir, gWAD);
3400 g_Game_LoadWAD(NewWAD);
3404 procedure g_Game_RestartRound(NoMapRestart
: Boolean = False);
3406 i
, n
, nb
, nr
: Integer;
3408 if not g_Game_IsServer
then Exit
;
3409 if gLMSRespawn
= LMS_RESPAWN_NONE
then Exit
;
3410 gLMSRespawn
:= LMS_RESPAWN_NONE
;
3411 gLMSRespawnTime
:= 0;
3414 if (gGameSettings
.GameMode
= GM_COOP
) and not NoMapRestart
then
3416 gMissionFailed
:= True;
3417 g_Game_RestartLevel
;
3421 n
:= 0; nb
:= 0; nr
:= 0;
3422 for i
:= Low(gPlayers
) to High(gPlayers
) do
3423 if (gPlayers
[i
] <> nil) and
3424 ((not gPlayers
[i
].FSpectator
) or gPlayers
[i
].FWantsInGame
or
3425 (gPlayers
[i
] is TBot
)) then
3428 if gPlayers
[i
].Team
= TEAM_RED
then Inc(nr
)
3429 else if gPlayers
[i
].Team
= TEAM_BLUE
then Inc(nb
)
3432 if (n
< 1) or ((gGameSettings
.GameMode
= GM_TDM
) and ((nr
= 0) or (nb
= 0))) then
3434 // wait a second until the fuckers finally decide to join
3435 gLMSRespawn
:= LMS_RESPAWN_WARMUP
;
3436 gLMSRespawnTime
:= gTime
+ gGameSettings
.WarmupTime
*1000;
3437 gLMSSoftSpawn
:= NoMapRestart
;
3438 if g_Game_IsNet
then
3439 MH_SEND_GameEvent(NET_EV_LMS_WARMUP
, gLMSRespawnTime
- gTime
);
3443 g_Player_RemoveAllCorpses
;
3444 g_Game_Message(_lc
[I_MESSAGE_LMS_START
], 144);
3445 if g_Game_IsNet
then
3446 MH_SEND_GameEvent(NET_EV_LMS_START
);
3448 for i
:= Low(gPlayers
) to High(gPlayers
) do
3450 if gPlayers
[i
] = nil then continue
;
3451 if gPlayers
[i
] is TBot
then gPlayers
[i
].FWantsInGame
:= True;
3452 // don't touch normal spectators
3453 if gPlayers
[i
].FSpectator
and not gPlayers
[i
].FWantsInGame
then
3455 gPlayers
[i
].FNoRespawn
:= True;
3456 gPlayers
[i
].Lives
:= 0;
3457 if g_Game_IsNet
then
3458 MH_SEND_PlayerStats(gPlayers
[I
].UID
);
3461 gPlayers
[i
].FNoRespawn
:= False;
3462 gPlayers
[i
].Lives
:= gGameSettings
.MaxLives
;
3463 gPlayers
[i
].Respawn(False, True);
3464 if gGameSettings
.GameMode
= GM_COOP
then
3466 gPlayers
[i
].Frags
:= 0;
3467 gPlayers
[i
].RecallState
;
3469 if (gPlayer1
= nil) and (gSpectLatchPID1
> 0) then
3470 gPlayer1
:= g_Player_Get(gSpectLatchPID1
);
3471 if (gPlayer2
= nil) and (gSpectLatchPID2
> 0) then
3472 gPlayer2
:= g_Player_Get(gSpectLatchPID2
);
3475 g_Items_RestartRound();
3477 gLMSSoftSpawn
:= False;
3480 function g_Game_GetFirstMap(WAD
: String): String;
3484 MapList
:= g_Map_GetMapsList(WAD
);
3485 if MapList
= nil then
3488 SortSArray(MapList
);
3489 Result
:= MapList
[Low(MapList
)];
3491 if not g_Map_Exist(WAD
+ ':\' + Result
) then
3497 function g_Game_GetNextMap(): String;
3504 MapList
:= g_Map_GetMapsList(gGameSettings
.WAD
);
3505 if MapList
= nil then
3508 Map
:= g_ExtractFileName(gMapInfo
.Map
);
3510 SortSArray(MapList
);
3512 for I
:= Low(MapList
) to High(MapList
) do
3513 if Map
= MapList
[I
] then
3519 if MapIndex
<> -255 then
3521 if MapIndex
= High(MapList
) then
3522 Result
:= MapList
[Low(MapList
)]
3524 Result
:= MapList
[MapIndex
+ 1];
3526 if not g_Map_Exist(gGameSettings
.WAD
+ ':\' + Result
) then Result
:= Map
;
3532 procedure g_Game_NextLevel();
3534 if gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
, GM_COOP
] then
3535 gExit
:= EXIT_ENDLEVELCUSTOM
3538 gExit
:= EXIT_ENDLEVELSINGLE
;
3542 if gNextMap
<> '' then Exit
;
3543 gNextMap
:= g_Game_GetNextMap();
3546 function g_Game_IsTestMap(): Boolean;
3548 result
:= StrEquCI1251(TEST_MAP_NAME
, g_ExtractFileName(gMapInfo
.Map
));
3551 procedure g_Game_DeleteTestMap();
3554 //MapName: AnsiString;
3562 a
:= Pos('.wad:\', toLowerCase1251(gMapToDelete
));
3563 if (a
= 0) then a
:= Pos('.wad:/', toLowerCase1251(gMapToDelete
));
3564 if (a
= 0) then exit
;
3566 // Выделяем имя wad-файла и имя карты
3567 WadName
:= Copy(gMapToDelete
, 1, a
+3);
3568 Delete(gMapToDelete
, 1, a
+5);
3569 gMapToDelete
:= UpperCase(gMapToDelete
);
3571 //CopyMemory(@MapName[0], @gMapToDelete[1], Min(16, Length(gMapToDelete)));
3574 // Имя карты не стандартное тестовое:
3575 if MapName <> TEST_MAP_NAME then
3578 if not gTempDelete then
3580 time := g_GetFileTime(WadName);
3581 WAD := TWADFile.Create();
3584 if not WAD.ReadFile(WadName) then
3585 begin // Нет такого WAD-файла
3590 // Составляем список карт и ищем нужную:
3592 MapList := WAD.GetResourcesList('');
3594 if MapList <> nil then
3595 for a := 0 to High(MapList) do
3596 if MapList[a] = MapName then
3598 // Удаляем и сохраняем:
3599 WAD.RemoveResource('', MapName);
3600 WAD.SaveTo(WadName);
3605 g_SetFileTime(WadName, time);
3608 if gTempDelete
then DeleteFile(WadName
);
3611 procedure GameCVars(P
: SSArray
);
3614 stat
: TPlayerStatArray
;
3617 procedure ParseGameFlag(Flag
: LongWord; OffMsg
, OnMsg
: TStrings_Locale
; OnMapChange
: Boolean = False);
3621 if Length(P
) > 1 then
3626 gsGameFlags
:= gsGameFlags
or Flag
3628 gsGameFlags
:= gsGameFlags
and (not Flag
);
3630 if g_Game_IsServer
then
3633 gGameSettings
.Options
:= gGameSettings
.Options
or Flag
3635 gGameSettings
.Options
:= gGameSettings
.Options
and (not Flag
);
3636 if g_Game_IsNet
then MH_SEND_GameSettings
;
3640 if LongBool(gsGameFlags
and Flag
) then
3641 g_Console_Add(_lc
[OnMsg
])
3643 g_Console_Add(_lc
[OffMsg
]);
3645 if OnMapChange
and g_Game_IsServer
then
3646 g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
3651 cmd
:= LowerCase(P
[0]);
3653 if cmd
= 'g_gamemode' then
3655 if (Length(P
) > 1) then
3657 a
:= g_Game_TextToMode(P
[1]);
3658 if a
= GM_SINGLE
then a
:= GM_COOP
;
3659 gsGameMode
:= g_Game_ModeToText(a
);
3660 if g_Game_IsServer
then
3662 gSwitchGameMode
:= a
;
3663 if (gGameOn
and (gGameSettings
.GameMode
= GM_SINGLE
)) or
3664 (gState
= STATE_INTERSINGLE
) then
3665 gSwitchGameMode
:= GM_SINGLE
;
3667 gGameSettings
.GameMode
:= gSwitchGameMode
;
3671 if gSwitchGameMode
= gGameSettings
.GameMode
then
3672 g_Console_Add(Format(_lc
[I_MSG_GAMEMODE_CURRENT
],
3673 [g_Game_ModeToText(gGameSettings
.GameMode
)]))
3675 g_Console_Add(Format(_lc
[I_MSG_GAMEMODE_CHANGE
],
3676 [g_Game_ModeToText(gGameSettings
.GameMode
),
3677 g_Game_ModeToText(gSwitchGameMode
)]));
3679 else if cmd
= 'g_friendlyfire' then
3681 ParseGameFlag(GAME_OPTION_TEAMDAMAGE
, I_MSG_FRIENDLY_FIRE_OFF
, I_MSG_FRIENDLY_FIRE_ON
);
3683 else if cmd
= 'g_friendly_absorb_damage' then
3685 ParseGameFlag(GAME_OPTION_TEAMABSORBDAMAGE
, I_MSG_FRIENDLY_FIRE_OFF
, I_MSG_FRIENDLY_FIRE_ON
);
3687 else if cmd
= 'g_friendly_hit_trace' then
3689 ParseGameFlag(GAME_OPTION_TEAMHITTRACE
, I_MSG_FRIENDLY_FIRE_OFF
, I_MSG_FRIENDLY_FIRE_ON
);
3691 else if cmd
= 'g_friendly_hit_projectile' then
3693 ParseGameFlag(GAME_OPTION_TEAMHITPROJECTILE
, I_MSG_FRIENDLY_FIRE_OFF
, I_MSG_FRIENDLY_FIRE_ON
);
3695 else if cmd
= 'g_weaponstay' then
3697 ParseGameFlag(GAME_OPTION_WEAPONSTAY
, I_MSG_WEAPONSTAY_OFF
, I_MSG_WEAPONSTAY_ON
);
3699 else if cmd
= 'g_allow_exit' then
3701 ParseGameFlag(GAME_OPTION_ALLOWEXIT
, I_MSG_ALLOWEXIT_OFF
, I_MSG_ALLOWEXIT_ON
, True);
3703 else if cmd
= 'g_allow_monsters' then
3705 ParseGameFlag(GAME_OPTION_MONSTERS
, I_MSG_ALLOWMON_OFF
, I_MSG_ALLOWMON_ON
, True);
3707 else if cmd
= 'g_bot_vsplayers' then
3709 ParseGameFlag(GAME_OPTION_BOTVSPLAYER
, I_MSG_BOTSVSPLAYERS_OFF
, I_MSG_BOTSVSPLAYERS_ON
);
3711 else if cmd
= 'g_bot_vsmonsters' then
3713 ParseGameFlag(GAME_OPTION_BOTVSMONSTER
, I_MSG_BOTSVSMONSTERS_OFF
, I_MSG_BOTSVSMONSTERS_ON
);
3715 else if cmd
= 'g_dm_keys' then
3717 ParseGameFlag(GAME_OPTION_DMKEYS
, I_MSG_DMKEYS_OFF
, I_MSG_DMKEYS_ON
, True);
3719 else if cmd
= 'g_gameflags' then
3721 if Length(P
) > 1 then
3723 gsGameFlags
:= StrToDWordDef(P
[1], gsGameFlags
);
3724 if g_Game_IsServer
then
3726 gGameSettings
.Options
:= gsGameFlags
;
3727 if g_Game_IsNet
then MH_SEND_GameSettings
;
3731 g_Console_Add(Format('%s %u', [cmd
, gsGameFlags
]));
3733 else if cmd
= 'g_warmup_time' then
3735 if Length(P
) > 1 then
3737 gsWarmupTime
:= nclamp(StrToIntDef(P
[1], gsWarmupTime
), 0, $FFFF);
3738 if g_Game_IsServer
then
3740 gGameSettings
.WarmupTime
:= gsWarmupTime
;
3741 // extend warmup if it's already going
3742 if gLMSRespawn
= LMS_RESPAWN_WARMUP
then
3744 gLMSRespawnTime
:= gTime
+ gsWarmupTime
* 1000;
3745 if g_Game_IsNet
then MH_SEND_GameEvent(NET_EV_LMS_WARMUP
, gLMSRespawnTime
- gTime
);
3747 if g_Game_IsNet
then MH_SEND_GameSettings
;
3751 g_Console_Add(Format(_lc
[I_MSG_WARMUP
], [Integer(gsWarmupTime
)]));
3752 if g_Game_IsServer
then g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
3754 else if cmd
= 'g_spawn_invul' then
3756 if Length(P
) > 1 then
3758 gsSpawnInvul
:= nclamp(StrToIntDef(P
[1], gsSpawnInvul
), 0, $FFFF);
3759 if g_Game_IsServer
then
3761 gGameSettings
.SpawnInvul
:= gsSpawnInvul
;
3762 if g_Game_IsNet
then MH_SEND_GameSettings
;
3766 g_Console_Add(Format('%s %d', [cmd
, Integer(gsSpawnInvul
)]));
3768 else if cmd
= 'g_item_respawn_time' then
3770 if Length(P
) > 1 then
3772 gsItemRespawnTime
:= nclamp(StrToIntDef(P
[1], gsItemRespawnTime
), 0, $FFFF);
3773 if g_Game_IsServer
then
3775 gGameSettings
.ItemRespawnTime
:= gsItemRespawnTime
;
3776 if g_Game_IsNet
then MH_SEND_GameSettings
;
3780 g_Console_Add(Format('%s %d', [cmd
, Integer(gsItemRespawnTime
)]));
3781 if g_Game_IsServer
then g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
3783 else if cmd
= 'sv_intertime' then
3785 if (Length(P
) > 1) then
3786 gDefInterTime
:= Min(Max(StrToIntDef(P
[1], gDefInterTime
), -1), 120);
3788 g_Console_Add(cmd
+ ' = ' + IntToStr(gDefInterTime
));
3790 else if cmd
= 'g_max_particles' then
3792 if Length(p
) = 2 then
3794 a
:= Max(0, StrToInt(p
[1]));
3797 else if Length(p
) = 1 then
3799 e_LogWritefln('%s', [g_GFX_GetMax()])
3803 e_LogWritefln('usage: %s <n>', [cmd
])
3806 else if cmd
= 'g_max_shells' then
3808 if Length(p
) = 2 then
3810 a
:= Max(0, StrToInt(p
[1]));
3813 else if Length(p
) = 1 then
3815 e_LogWritefln('%s', [g_Shells_GetMax()])
3819 e_LogWritefln('usage: %s <n>', [cmd
])
3822 else if cmd
= 'g_max_gibs' then
3824 if Length(p
) = 2 then
3826 a
:= Max(0, StrToInt(p
[1]));
3829 else if Length(p
) = 1 then
3831 e_LogWritefln('%s', [g_Gibs_GetMax()])
3835 e_LogWritefln('usage: %s <n>', [cmd
])
3838 else if cmd
= 'g_max_corpses' then
3840 if Length(p
) = 2 then
3842 a
:= Max(0, StrToInt(p
[1]));
3845 else if Length(p
) = 1 then
3847 e_LogWritefln('%s', [g_Corpses_GetMax()])
3851 e_LogWritefln('usage: %s <n>', [cmd
])
3854 else if cmd
= 'g_scorelimit' then
3856 if Length(P
) > 1 then
3858 gsGoalLimit
:= nclamp(StrToIntDef(P
[1], gsGoalLimit
), 0, $FFFF);
3860 if g_Game_IsServer
then
3863 if gGameSettings
.GameMode
= GM_DM
then
3865 stat
:= g_Player_GetStats();
3867 for a
:= 0 to High(stat
) do
3868 if stat
[a
].Frags
> b
then
3872 b
:= Max(gTeamStat
[TEAM_RED
].Goals
, gTeamStat
[TEAM_BLUE
].Goals
);
3874 // if someone has a higher score, set it to that instead
3875 gsGoalLimit
:= max(gsGoalLimit
, b
);
3876 gGameSettings
.GoalLimit
:= gsGoalLimit
;
3878 if g_Game_IsNet
then MH_SEND_GameSettings
;
3882 g_Console_Add(Format(_lc
[I_MSG_SCORE_LIMIT
], [Integer(gsGoalLimit
)]));
3884 else if cmd
= 'g_timelimit' then
3886 if Length(P
) > 1 then
3888 gsTimeLimit
:= nclamp(StrToIntDef(P
[1], gsTimeLimit
), 0, $FFFF);
3889 if g_Game_IsServer
then
3891 gGameSettings
.TimeLimit
:= gsTimeLimit
;
3892 if g_Game_IsNet
then MH_SEND_GameSettings
;
3895 g_Console_Add(Format(_lc
[I_MSG_TIME_LIMIT
],
3896 [gsTimeLimit
div 3600,
3897 (gsTimeLimit
div 60) mod 60,
3898 gsTimeLimit
mod 60]));
3900 else if cmd
= 'g_maxlives' then
3902 if Length(P
) > 1 then
3904 gsMaxLives
:= nclamp(StrToIntDef(P
[1], gsMaxLives
), 0, $FFFF);
3905 if g_Game_IsServer
then
3907 gGameSettings
.MaxLives
:= gsMaxLives
;
3908 if g_Game_IsNet
then MH_SEND_GameSettings
;
3912 g_Console_Add(Format(_lc
[I_MSG_LIVES
], [Integer(gsMaxLives
)]));
3916 procedure PlayerSettingsCVars(P
: SSArray
);
3921 function ParseTeam(s
: string): Byte;
3925 'red', '1': result
:= TEAM_RED
;
3926 'blue', '2': result
:= TEAM_BLUE
;
3927 else result
:= TEAM_NONE
;
3931 cmd
:= LowerCase(P
[0]);
3935 if (Length(P
) > 1) then
3937 gPlayer1Settings
.Name
:= b_Text_Unformat(P
[1]);
3938 if g_Game_IsClient
then
3939 MC_SEND_PlayerSettings
3940 else if gGameOn
and (gPlayer1
<> nil) then
3942 gPlayer1
.Name
:= b_Text_Unformat(P
[1]);
3943 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer1
.UID
);
3949 if (Length(P
) > 1) then
3951 gPlayer2Settings
.Name
:= b_Text_Unformat(P
[1]);
3952 if g_Game_IsClient
then
3953 MC_SEND_PlayerSettings
3954 else if gGameOn
and (gPlayer2
<> nil) then
3956 gPlayer2
.Name
:= b_Text_Unformat(P
[1]);
3957 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer2
.UID
);
3963 if Length(P
) > 3 then
3965 gPlayer1Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
3966 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
3967 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
3968 if g_Game_IsClient
then
3969 MC_SEND_PlayerSettings
3970 else if gGameOn
and (gPlayer1
<> nil) then
3972 gPlayer1
.SetColor(gPlayer1Settings
.Color
);
3973 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer1
.UID
);
3979 if Length(P
) > 3 then
3981 gPlayer2Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
3982 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
3983 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
3984 if g_Game_IsClient
then
3985 MC_SEND_PlayerSettings
3986 else if gGameOn
and (gPlayer2
<> nil) then
3988 gPlayer2
.SetColor(gPlayer2Settings
.Color
);
3989 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer2
.UID
);
3995 if (Length(P
) > 1) then
3997 gPlayer1Settings
.Model
:= P
[1];
3998 if g_Game_IsClient
then
3999 MC_SEND_PlayerSettings
4000 else if gGameOn
and (gPlayer1
<> nil) then
4002 gPlayer1
.FActualModelName
:= gPlayer1Settings
.Model
;
4003 gPlayer1
.SetModel(gPlayer1Settings
.Model
);
4004 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer1
.UID
);
4010 if (Length(P
) > 1) then
4012 gPlayer2Settings
.Model
:= P
[1];
4013 if g_Game_IsClient
then
4014 MC_SEND_PlayerSettings
4015 else if gGameOn
and (gPlayer2
<> nil) then
4017 gPlayer2
.FActualModelName
:= gPlayer2Settings
.Model
;
4018 gPlayer2
.SetModel(gPlayer2Settings
.Model
);
4019 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer2
.UID
);
4025 // TODO: switch teams if in game or store this separately
4026 if (Length(P
) > 1) then
4028 team
:= ParseTeam(P
[1]);
4029 if team
= TEAM_NONE
then
4030 g_Console_Add('expected ''red'', ''blue'', 1 or 2')
4031 else if not gGameOn
and not g_Game_IsNet
then
4032 gPlayer1Settings
.Team
:= team
4034 g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
4039 // TODO: switch teams if in game or store this separately
4040 if (Length(P
) > 1) then
4042 team
:= ParseTeam(P
[1]);
4043 if team
= TEAM_NONE
then
4044 g_Console_Add('expected ''red'', ''blue'', 1 or 2')
4045 else if not gGameOn
and not g_Game_IsNet
then
4046 gPlayer2Settings
.Team
:= team
4048 g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
4054 procedure PrintHeapStats();
4058 hs
:= GetFPCHeapStatus();
4059 e_LogWriteLn ('v===== heap status =====v');
4060 e_LogWriteFln('max heap size = %d k', [hs
.MaxHeapSize
div 1024]);
4061 e_LogWriteFln('max heap used = %d k', [hs
.MaxHeapUsed
div 1024]);
4062 e_LogWriteFln('cur heap size = %d k', [hs
.CurrHeapSize
div 1024]);
4063 e_LogWriteFln('cur heap used = %d k', [hs
.CurrHeapUsed
div 1024]);
4064 e_LogWriteFln('cur heap free = %d k', [hs
.CurrHeapFree
div 1024]);
4065 e_LogWriteLn ('^=======================^');
4068 procedure DebugCommands(P
: SSArray
);
4075 // Команды отладочного режима:
4076 if {gDebugMode}conIsCheatsEnabled
then
4078 cmd
:= LowerCase(P
[0]);
4079 if cmd
= 'd_window' then
4081 g_Console_Add(Format('gScreenWidth = %d, gScreenHeight = %d', [gScreenWidth
, gScreenHeight
]));
4082 g_Console_Add(Format('gScreenWidth = %d, gScreenHeight = %d', [gScreenWidth
, gScreenHeight
]));
4084 else if cmd
= 'd_sounds' then
4086 if (Length(P
) > 1) and
4087 ((P
[1] = '1') or (P
[1] = '0')) then
4088 g_Debug_Sounds
:= (P
[1][1] = '1');
4090 g_Console_Add(Format('d_sounds is %d', [Byte(g_Debug_Sounds
)]));
4092 else if cmd
= 'd_frames' then
4094 if (Length(P
) > 1) and
4095 ((P
[1] = '1') or (P
[1] = '0')) then
4096 g_Debug_Frames
:= (P
[1][1] = '1');
4098 g_Console_Add(Format('d_frames is %d', [Byte(g_Debug_Frames
)]));
4100 else if cmd
= 'd_winmsg' then
4102 if (Length(P
) > 1) and
4103 ((P
[1] = '1') or (P
[1] = '0')) then
4104 g_Debug_WinMsgs
:= (P
[1][1] = '1');
4106 g_Console_Add(Format('d_winmsg is %d', [Byte(g_Debug_WinMsgs
)]));
4108 else if (cmd
= 'd_monoff') and not g_Game_IsNet
then
4110 if (Length(P
) > 1) and
4111 ((P
[1] = '1') or (P
[1] = '0')) then
4112 g_Debug_MonsterOff
:= (P
[1][1] = '1');
4114 g_Console_Add(Format('d_monoff is %d', [Byte(g_debug_MonsterOff
)]));
4116 else if (cmd
= 'd_botoff') and not g_Game_IsNet
then
4118 if Length(P
) > 1 then
4120 '0': g_debug_BotAIOff
:= 0;
4121 '1': g_debug_BotAIOff
:= 1;
4122 '2': g_debug_BotAIOff
:= 2;
4123 '3': g_debug_BotAIOff
:= 3;
4126 g_Console_Add(Format('d_botoff is %d', [g_debug_BotAIOff
]));
4128 else if cmd
= 'd_monster' then
4130 if gGameOn
and (gPlayer1
<> nil) and (gPlayer1
.alive
) and (not g_Game_IsNet
) then
4131 if Length(P
) < 2 then
4133 g_Console_Add(cmd
+ ' [ID | Name] [behaviour]');
4134 g_Console_Add('ID | Name');
4135 for b
:= MONSTER_DEMON
to MONSTER_MAN
do
4136 g_Console_Add(Format('%2d | %s', [b
, g_Mons_NameByTypeId(b
)]));
4137 conwriteln('behav. num'#10'normal 0'#10'killer 1'#10'maniac 2'#10'insane 3'#10'cannibal 4'#10'good 5');
4140 a
:= StrToIntDef(P
[1], 0);
4141 if (a
< MONSTER_DEMON
) or (a
> MONSTER_MAN
) then
4142 a
:= g_Mons_TypeIdByName(P
[1]);
4144 if (a
< MONSTER_DEMON
) or (a
> MONSTER_MAN
) then
4145 g_Console_Add(Format(_lc
[I_MSG_NO_MONSTER
], [P
[1]]))
4148 with gPlayer1
.Obj
do
4150 mon
:= g_Monsters_Create(a
,
4151 X
+ Rect
.X
+ (Rect
.Width
div 2),
4152 Y
+ Rect
.Y
+ Rect
.Height
,
4153 gPlayer1
.Direction
, True);
4155 if (Length(P
) > 2) and (mon
<> nil) then
4157 if (CompareText(P
[2], 'normal') = 0) then mon
.MonsterBehaviour
:= BH_NORMAL
4158 else if (CompareText(P
[2], 'killer') = 0) then mon
.MonsterBehaviour
:= BH_KILLER
4159 else if (CompareText(P
[2], 'maniac') = 0) then mon
.MonsterBehaviour
:= BH_MANIAC
4160 else if (CompareText(P
[2], 'insane') = 0) then mon
.MonsterBehaviour
:= BH_INSANE
4161 else if (CompareText(P
[2], 'cannibal') = 0) then mon
.MonsterBehaviour
:= BH_CANNIBAL
4162 else if (CompareText(P
[2], 'good') = 0) then mon
.MonsterBehaviour
:= BH_GOOD
4163 else if (CompareText(P
[2], 'friend') = 0) then mon
.MonsterBehaviour
:= BH_GOOD
4164 else if (CompareText(P
[2], 'friendly') = 0) then mon
.MonsterBehaviour
:= BH_GOOD
4165 else mon
.MonsterBehaviour
:= Min(Max(StrToIntDef(P
[2], BH_NORMAL
), BH_NORMAL
), BH_GOOD
);
4170 else if (cmd
= 'd_health') then
4172 if (Length(P
) > 1) and
4173 ((P
[1] = '1') or (P
[1] = '0')) then
4174 g_debug_HealthBar
:= (P
[1][1] = '1');
4176 g_Console_Add(Format('d_health is %d', [Byte(g_debug_HealthBar
)]));
4178 else if (cmd
= 'd_player') then
4180 if (Length(P
) > 1) and
4181 ((P
[1] = '1') or (P
[1] = '0')) then
4182 g_debug_Player
:= (P
[1][1] = '1');
4184 g_Console_Add(Format(cmd
+ ' is %d', [Byte(g_Debug_Player
)]));
4186 else if (cmd
= 'd_mem') then
4192 g_Console_Add(_lc
[I_MSG_NOT_DEBUG
]);
4196 procedure GameCheats(P
: SSArray
);
4202 if (not gGameOn
) or (not conIsCheatsEnabled
) then
4204 g_Console_Add('not available');
4210 g_Console_Add('where is the player?!');
4213 cmd
:= LowerCase(P
[0]);
4217 plr
.GodMode
:= not plr
.GodMode
;
4218 if plr
.GodMode
then g_Console_Add('player is godlike now') else g_Console_Add('player is mortal now');
4221 // give <health|exit|weapons|air|suit|jetpack|berserk|all>
4222 if cmd
= 'give' then
4224 if length(P
) < 2 then begin g_Console_Add('give what?!'); exit
; end;
4225 for f
:= 1 to High(P
) do
4227 cmd
:= LowerCase(P
[f
]);
4228 if cmd
= 'health' then begin plr
.RestoreHealthArmor(); g_Console_Add('player feels himself better'); continue
; end;
4229 if (cmd
= 'all') {or (cmd = 'weapons')} then begin plr
.AllRulez(False); g_Console_Add('player got the gifts'); continue
; end;
4230 if cmd
= 'exit' then
4232 if gTriggers
<> nil then
4234 for a
:= 0 to High(gTriggers
) do
4236 if gTriggers
[a
].TriggerType
= TRIGGER_EXIT
then
4238 g_Console_Add('player left the map');
4239 gExitByTrigger
:= True;
4240 //g_Game_ExitLevel(gTriggers[a].Data.MapName);
4241 g_Game_ExitLevel(gTriggers
[a
].tgcMap
);
4249 if cmd
= 'air' then begin plr
.GiveItem(ITEM_OXYGEN
); g_Console_Add('player got some air'); continue
; end;
4250 if cmd
= 'jetpack' then begin plr
.GiveItem(ITEM_JETPACK
); g_Console_Add('player got a jetpack'); continue
; end;
4251 if cmd
= 'suit' then begin plr
.GiveItem(ITEM_SUIT
); g_Console_Add('player got an envirosuit'); continue
; end;
4252 if cmd
= 'berserk' then begin plr
.GiveItem(ITEM_MEDKIT_BLACK
); g_Console_Add('player got a berserk pack'); continue
; end;
4253 if cmd
= 'backpack' then begin plr
.GiveItem(ITEM_AMMO_BACKPACK
); g_Console_Add('player got a backpack'); continue
; end;
4255 if cmd
= 'helmet' then begin plr
.GiveItem(ITEM_HELMET
); g_Console_Add('player got a helmet'); continue
; end;
4256 if cmd
= 'bottle' then begin plr
.GiveItem(ITEM_BOTTLE
); g_Console_Add('player got a bottle of health'); continue
; end;
4258 if cmd
= 'stimpack' then begin plr
.GiveItem(ITEM_MEDKIT_SMALL
); g_Console_Add('player got a stimpack'); continue
; end;
4259 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;
4261 if cmd
= 'greenarmor' then begin plr
.GiveItem(ITEM_ARMOR_GREEN
); g_Console_Add('player got a security armor'); continue
; end;
4262 if cmd
= 'bluearmor' then begin plr
.GiveItem(ITEM_ARMOR_BLUE
); g_Console_Add('player got a combat armor'); continue
; end;
4264 if (cmd
= 'megasphere') or (cmd
= 'mega') then begin plr
.GiveItem(ITEM_SPHERE_BLUE
); g_Console_Add('player got a megasphere'); continue
; end;
4265 if (cmd
= 'soulsphere') or (cmd
= 'soul')then begin plr
.GiveItem(ITEM_SPHERE_WHITE
); g_Console_Add('player got a soul sphere'); continue
; end;
4267 if (cmd
= 'invul') or (cmd
= 'invulnerability') then begin plr
.GiveItem(ITEM_INVUL
); g_Console_Add('player got invulnerability'); continue
; end;
4268 if (cmd
= 'invis') or (cmd
= 'invisibility') then begin plr
.GiveItem(ITEM_INVIS
); g_Console_Add('player got invisibility'); continue
; end;
4270 if cmd
= 'redkey' then begin plr
.GiveItem(ITEM_KEY_RED
); g_Console_Add('player got the red key'); continue
; end;
4271 if cmd
= 'greenkey' then begin plr
.GiveItem(ITEM_KEY_GREEN
); g_Console_Add('player got the green key'); continue
; end;
4272 if cmd
= 'bluekey' then begin plr
.GiveItem(ITEM_KEY_BLUE
); g_Console_Add('player got the blue key'); continue
; end;
4274 if (cmd
= 'shotgun') or (cmd
= 'sg') then begin plr
.GiveItem(ITEM_WEAPON_SHOTGUN1
); g_Console_Add('player got a shotgun'); continue
; end;
4275 if (cmd
= 'supershotgun') or (cmd
= 'ssg') then begin plr
.GiveItem(ITEM_WEAPON_SHOTGUN2
); g_Console_Add('player got a supershotgun'); continue
; end;
4276 if cmd
= 'chaingun' then begin plr
.GiveItem(ITEM_WEAPON_CHAINGUN
); g_Console_Add('player got a chaingun'); continue
; end;
4277 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;
4278 if cmd
= 'plasmagun' then begin plr
.GiveItem(ITEM_WEAPON_PLASMA
); g_Console_Add('player got a plasma gun'); continue
; end;
4279 if cmd
= 'bfg' then begin plr
.GiveItem(ITEM_WEAPON_BFG
); g_Console_Add('player got a BFG-9000'); continue
; end;
4281 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;
4282 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;
4283 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;
4284 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;
4285 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;
4286 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;
4288 if cmd
= 'superchaingun' then begin plr
.GiveItem(ITEM_WEAPON_SUPERPULEMET
); g_Console_Add('player got a superchaingun'); continue
; end;
4289 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;
4291 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;
4292 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;
4294 if cmd
= 'chainsaw' then begin plr
.GiveItem(ITEM_WEAPON_SAW
); g_Console_Add('player got a chainsaw'); continue
; end;
4296 if cmd
= 'ammo' then
4298 plr
.GiveItem(ITEM_AMMO_SHELLS_BOX
);
4299 plr
.GiveItem(ITEM_AMMO_BULLETS_BOX
);
4300 plr
.GiveItem(ITEM_AMMO_CELL_BIG
);
4301 plr
.GiveItem(ITEM_AMMO_ROCKET_BOX
);
4302 plr
.GiveItem(ITEM_AMMO_FUELCAN
);
4303 g_Console_Add('player got some ammo');
4307 if cmd
= 'clip' then begin plr
.GiveItem(ITEM_AMMO_BULLETS
); g_Console_Add('player got some bullets'); continue
; end;
4308 if cmd
= 'bullets' then begin plr
.GiveItem(ITEM_AMMO_BULLETS_BOX
); g_Console_Add('player got a box of bullets'); continue
; end;
4310 if cmd
= 'shells' then begin plr
.GiveItem(ITEM_AMMO_SHELLS
); g_Console_Add('player got some shells'); continue
; end;
4311 if cmd
= 'shellbox' then begin plr
.GiveItem(ITEM_AMMO_SHELLS_BOX
); g_Console_Add('player got a box of shells'); continue
; end;
4313 if cmd
= 'cells' then begin plr
.GiveItem(ITEM_AMMO_CELL
); g_Console_Add('player got some cells'); continue
; end;
4314 if cmd
= 'battery' then begin plr
.GiveItem(ITEM_AMMO_CELL_BIG
); g_Console_Add('player got cell battery'); continue
; end;
4316 if cmd
= 'rocket' then begin plr
.GiveItem(ITEM_AMMO_ROCKET
); g_Console_Add('player got a rocket'); continue
; end;
4317 if cmd
= 'rocketbox' then begin plr
.GiveItem(ITEM_AMMO_ROCKET_BOX
); g_Console_Add('player got some rockets'); continue
; end;
4319 if (cmd
= 'fuel') or (cmd
= 'fuelcan') then begin plr
.GiveItem(ITEM_AMMO_FUELCAN
); g_Console_Add('player got fuel canister'); continue
; end;
4321 if cmd
= 'weapons' then
4323 plr
.GiveItem(ITEM_WEAPON_SHOTGUN1
);
4324 plr
.GiveItem(ITEM_WEAPON_SHOTGUN2
);
4325 plr
.GiveItem(ITEM_WEAPON_CHAINGUN
);
4326 plr
.GiveItem(ITEM_WEAPON_ROCKETLAUNCHER
);
4327 plr
.GiveItem(ITEM_WEAPON_PLASMA
);
4328 plr
.GiveItem(ITEM_WEAPON_BFG
);
4329 g_Console_Add('player got weapons');
4333 if cmd
= 'keys' then
4335 plr
.GiveItem(ITEM_KEY_RED
);
4336 plr
.GiveItem(ITEM_KEY_GREEN
);
4337 plr
.GiveItem(ITEM_KEY_BLUE
);
4338 g_Console_Add('player got all keys');
4342 g_Console_Add('i don''t know how to give '''+cmd
+'''!');
4347 if cmd
= 'open' then
4349 g_Console_Add('player activated sesame');
4350 g_Triggers_OpenAll();
4357 if gFly
then g_Console_Add('player feels himself lighter') else g_Console_Add('player lost his wings');
4361 if cmd
= 'noclip' then
4364 g_Console_Add('wall hardeness adjusted');
4368 if cmd
= 'notarget' then
4370 plr
.NoTarget
:= not plr
.NoTarget
;
4371 if plr
.NoTarget
then g_Console_Add('player hides in shadows') else g_Console_Add('player is brave again');
4375 if cmd
= 'noreload' then
4377 plr
.NoReload
:= not plr
.NoReload
;
4378 if plr
.NoReload
then g_Console_Add('player is action hero now') else g_Console_Add('player is ordinary man now');
4382 if cmd
= 'speedy' then
4384 MAX_RUNVEL
:= 32-MAX_RUNVEL
;
4385 g_Console_Add('speed adjusted');
4389 if cmd
= 'jumpy' then
4391 VEL_JUMP
:= 30-VEL_JUMP
;
4392 g_Console_Add('jump height adjusted');
4396 if cmd
= 'automap' then
4398 gShowMap
:= not gShowMap
;
4399 if gShowMap
then g_Console_Add('player gains second sight') else g_Console_Add('player lost second sight');
4403 if cmd
= 'aimline' then
4405 gAimLine
:= not gAimLine
;
4406 if gAimLine
then g_Console_Add('player gains laser sight') else g_Console_Add('player lost laser sight');
4411 procedure GameCommands(P
: SSArray
);
4417 pl
: pTNetClient
= nil;
4425 cmd
:= LowerCase(P
[0]);
4427 if cmd
= 'pause' then
4429 if (g_ActiveWindow
= nil) then
4430 g_Game_Pause(not gPauseMain
);
4432 else if cmd
= 'endgame' then
4433 gExit
:= EXIT_SIMPLE
4434 else if cmd
= 'restart' then
4436 if gGameOn
or (gState
in [STATE_INTERSINGLE
, STATE_INTERCUSTOM
]) then
4438 if g_Game_IsClient
then
4440 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4445 g_Console_Add(_lc
[I_MSG_NOT_GAME
]);
4447 else if cmd
= 'kick' then
4449 if g_Game_IsServer
then
4451 if Length(P
) < 2 then
4453 g_Console_Add('kick <name>');
4458 g_Console_Add('kick <name>');
4462 if g_Game_IsNet
then
4463 pl
:= g_Net_Client_ByName(P
[1]);
4466 s
:= g_Net_ClientName_ByID(pl
^.ID
);
4467 enet_peer_disconnect(pl
^.Peer
, NET_DISC_KICK
);
4468 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
4469 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
4470 g_Net_Slist_ServerPlayerLeaves();
4471 end else if gPlayers
<> nil then
4472 for a
:= Low(gPlayers
) to High(gPlayers
) do
4473 if gPlayers
[a
] <> nil then
4474 if Copy(LowerCase(gPlayers
[a
].Name
), 1, Length(P
[1])) = LowerCase(P
[1]) then
4476 // Не отключать основных игроков в сингле
4477 if not(gPlayers
[a
] is TBot
) and (gGameSettings
.GameType
= GT_SINGLE
) then
4479 gPlayers
[a
].Lives
:= 0;
4480 gPlayers
[a
].Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
4481 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [gPlayers
[a
].Name
]), True);
4482 g_Player_Remove(gPlayers
[a
].UID
);
4483 g_Net_Slist_ServerPlayerLeaves();
4484 // Если не перемешать, при добавлении новых ботов появятся старые
4488 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
4490 else if cmd
= 'kick_id' then
4492 if g_Game_IsServer
and g_Game_IsNet
then
4494 if Length(P
) < 2 then
4496 g_Console_Add('kick_id <client ID>');
4501 g_Console_Add('kick_id <client ID>');
4505 a
:= StrToIntDef(P
[1], 0);
4506 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
4508 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
4510 s
:= g_Net_ClientName_ByID(NetClients
[a
].ID
);
4511 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_KICK
);
4512 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
4513 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
4514 g_Net_Slist_ServerPlayerLeaves();
4518 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4520 else if cmd
= 'kick_pid' then
4522 if g_Game_IsServer
and g_Game_IsNet
then
4524 if Length(P
) < 2 then
4526 g_Console_Add('kick_pid <player ID>');
4531 g_Console_Add('kick_pid <player ID>');
4535 a
:= StrToIntDef(P
[1], 0);
4536 pl
:= g_Net_Client_ByPlayer(a
);
4537 if (pl
<> nil) and pl
^.Used
and (pl
^.Peer
<> nil) then
4539 s
:= g_Net_ClientName_ByID(pl
^.ID
);
4540 enet_peer_disconnect(pl
^.Peer
, NET_DISC_KICK
);
4541 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
4542 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
4543 g_Net_Slist_ServerPlayerLeaves();
4546 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4548 else if cmd
= 'ban' then
4550 if g_Game_IsServer
and g_Game_IsNet
then
4552 if Length(P
) < 2 then
4554 g_Console_Add('ban <name>');
4559 g_Console_Add('ban <name>');
4563 pl
:= g_Net_Client_ByName(P
[1]);
4566 s
:= g_Net_ClientName_ByID(pl
^.ID
);
4567 g_Net_BanHost(pl
^.Peer
^.address
.host
, False);
4568 enet_peer_disconnect(pl
^.Peer
, NET_DISC_TEMPBAN
);
4569 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
4570 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
4571 g_Net_Slist_ServerPlayerLeaves();
4573 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
4575 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4577 else if cmd
= 'ban_id' then
4579 if g_Game_IsServer
and g_Game_IsNet
then
4581 if Length(P
) < 2 then
4583 g_Console_Add('ban_id <client ID>');
4588 g_Console_Add('ban_id <client ID>');
4592 a
:= StrToIntDef(P
[1], 0);
4593 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
4594 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
4596 s
:= g_Net_ClientName_ByID(NetClients
[a
].ID
);
4597 g_Net_BanHost(NetClients
[a
].Peer
^.address
.host
, False);
4598 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_TEMPBAN
);
4599 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
4600 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
4601 g_Net_Slist_ServerPlayerLeaves();
4604 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4606 else if cmd
= 'ban_pid' then
4608 if g_Game_IsServer
and g_Game_IsNet
then
4610 if Length(P
) < 2 then
4612 g_Console_Add('ban_pid <player ID>');
4617 g_Console_Add('ban_pid <player ID>');
4621 a
:= StrToIntDef(P
[1], 0);
4622 pl
:= g_Net_Client_ByPlayer(a
);
4623 if (pl
<> nil) and pl
^.Used
and (pl
^.Peer
<> nil) then
4625 s
:= g_Net_ClientName_ByID(pl
^.ID
);
4626 g_Net_BanHost(pl
^.Peer
^.address
.host
, False);
4627 enet_peer_disconnect(pl
^.Peer
, NET_DISC_TEMPBAN
);
4628 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
4629 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
4630 g_Net_Slist_ServerPlayerLeaves();
4633 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4635 else if cmd
= 'permban' then
4637 if g_Game_IsServer
and g_Game_IsNet
then
4639 if Length(P
) < 2 then
4641 g_Console_Add('permban <name>');
4646 g_Console_Add('permban <name>');
4650 pl
:= g_Net_Client_ByName(P
[1]);
4653 s
:= g_Net_ClientName_ByID(pl
^.ID
);
4654 g_Net_BanHost(pl
^.Peer
^.address
.host
);
4655 enet_peer_disconnect(pl
^.Peer
, NET_DISC_BAN
);
4656 g_Net_SaveBanList();
4657 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
4658 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
4659 g_Net_Slist_ServerPlayerLeaves();
4661 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
4663 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4665 else if cmd
= 'permban_id' then
4667 if g_Game_IsServer
and g_Game_IsNet
then
4669 if Length(P
) < 2 then
4671 g_Console_Add('permban_id <client ID>');
4676 g_Console_Add('permban_id <client ID>');
4680 a
:= StrToIntDef(P
[1], 0);
4681 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
4682 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
4684 s
:= g_Net_ClientName_ByID(NetClients
[a
].ID
);
4685 g_Net_BanHost(NetClients
[a
].Peer
^.address
.host
);
4686 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_BAN
);
4687 g_Net_SaveBanList();
4688 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
4689 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
4690 g_Net_Slist_ServerPlayerLeaves();
4693 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4695 else if cmd
= 'permban_pid' then
4697 if g_Game_IsServer
and g_Game_IsNet
then
4699 if Length(P
) < 2 then
4701 g_Console_Add('permban_pid <player ID>');
4706 g_Console_Add('permban_pid <player ID>');
4710 a
:= StrToIntDef(P
[1], 0);
4711 pl
:= g_Net_Client_ByPlayer(a
);
4712 if (pl
<> nil) and pl
^.Used
and (pl
^.Peer
<> nil) then
4714 s
:= g_Net_ClientName_ByID(pl
^.ID
);
4715 g_Net_BanHost(pl
^.Peer
^.address
.host
);
4716 enet_peer_disconnect(pl
^.Peer
, NET_DISC_BAN
);
4717 g_Net_SaveBanList();
4718 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
4719 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
4720 g_Net_Slist_ServerPlayerLeaves();
4723 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4725 else if cmd
= 'permban_ip' then
4727 if g_Game_IsServer
and g_Game_IsNet
then
4729 if Length(P
) < 2 then
4731 g_Console_Add('permban_ip <IP address>');
4736 g_Console_Add('permban_ip <IP address>');
4740 g_Net_BanHost(P
[1]);
4741 g_Net_SaveBanList();
4742 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [P
[1]]));
4744 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4746 else if cmd
= 'unban' then
4748 if g_Game_IsServer
and g_Game_IsNet
then
4750 if Length(P
) < 2 then
4752 g_Console_Add('unban <IP Address>');
4757 g_Console_Add('unban <IP Address>');
4761 if g_Net_UnbanHost(P
[1]) then
4763 g_Console_Add(Format(_lc
[I_MSG_UNBAN_OK
], [P
[1]]));
4764 g_Net_SaveBanList();
4766 g_Console_Add(Format(_lc
[I_MSG_UNBAN_FAIL
], [P
[1]]));
4768 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4770 else if cmd
= 'clientlist' then
4772 if g_Game_IsServer
and g_Game_IsNet
then
4775 if NetClients
<> nil then
4776 for a
:= Low(NetClients
) to High(NetClients
) do
4777 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
4779 plr
:= g_Player_Get(NetClients
[a
].Player
);
4780 if plr
= nil then continue
;
4782 g_Console_Add(Format('#%2d: %-15s | %s', [a
,
4783 IpToStr(NetClients
[a
].Peer
^.address
.host
), plr
.Name
]));
4786 g_Console_Add(_lc
[I_MSG_NOCLIENTS
]);
4788 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4790 else if cmd
= 'connect' then
4792 if (NetMode
= NET_NONE
) then
4794 if Length(P
) < 2 then
4796 g_Console_Add('connect <IP> [port] [password]');
4801 g_Console_Add('connect <IP> [port] [password]');
4805 if Length(P
) > 2 then
4806 prt
:= StrToIntDef(P
[2], 25666)
4810 if Length(P
) > 3 then
4815 g_Game_StartClient(P
[1], prt
, pw
);
4818 else if cmd
= 'disconnect' then
4820 if (NetMode
= NET_CLIENT
) then
4823 else if cmd
= 'reconnect' then
4825 if (NetMode
= NET_SERVER
) then
4828 if (NetMode
= NET_CLIENT
) then
4831 gExit
:= EXIT_SIMPLE
;
4835 //TODO: Use last successful password to reconnect, instead of ''
4836 g_Game_StartClient(NetClientIP
, NetClientPort
, '');
4838 else if (cmd
= 'addbot') or
4839 (cmd
= 'bot_add') then
4841 if Length(P
) > 2 then
4842 g_Bot_Add(TEAM_NONE
, StrToIntDef(P
[1], 2), StrToIntDef(P
[2], 100))
4843 else if Length(P
) > 1 then
4844 g_Bot_Add(TEAM_NONE
, StrToIntDef(P
[1], 2))
4846 g_Bot_Add(TEAM_NONE
, 2);
4848 else if cmd
= 'bot_addlist' then
4850 if Length(P
) > 1 then
4852 if Length(P
) = 2 then
4853 g_Bot_AddList(TEAM_NONE
, P
[1], StrToIntDef(P
[1], -1))
4854 else if Length(P
) = 3 then
4855 g_Bot_AddList(TEAM_NONE
, P
[1], StrToIntDef(P
[1], -1), StrToIntDef(P
[2], 100))
4857 g_Bot_AddList(IfThen(P
[2] = 'red', TEAM_RED
, TEAM_BLUE
), P
[1], StrToIntDef(P
[1], -1));
4860 else if cmd
= 'bot_removeall' then
4862 else if cmd
= 'chat' then
4864 if g_Game_IsNet
then
4866 if Length(P
) > 1 then
4868 for a
:= 1 to High(P
) do
4869 chstr
:= chstr
+ P
[a
] + ' ';
4871 if Length(chstr
) > 200 then SetLength(chstr
, 200);
4873 if Length(chstr
) < 1 then
4875 g_Console_Add('chat <text>');
4879 chstr
:= b_Text_Format(chstr
);
4880 if g_Game_IsClient
then
4881 MC_SEND_Chat(chstr
, NET_CHAT_PLAYER
)
4883 MH_SEND_Chat(gPlayer1Settings
.Name
+ ': ' + chstr
, NET_CHAT_PLAYER
);
4886 g_Console_Add('chat <text>');
4888 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
4890 else if cmd
= 'teamchat' then
4892 if g_Game_IsNet
and (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
4894 if Length(P
) > 1 then
4896 for a
:= 1 to High(P
) do
4897 chstr
:= chstr
+ P
[a
] + ' ';
4899 if Length(chstr
) > 200 then SetLength(chstr
, 200);
4901 if Length(chstr
) < 1 then
4903 g_Console_Add('teamchat <text>');
4907 chstr
:= b_Text_Format(chstr
);
4908 if g_Game_IsClient
then
4909 MC_SEND_Chat(chstr
, NET_CHAT_TEAM
)
4911 MH_SEND_Chat(gPlayer1Settings
.Name
+ ': ' + chstr
, NET_CHAT_TEAM
,
4912 gPlayer1Settings
.Team
);
4915 g_Console_Add('teamchat <text>');
4917 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
4919 else if cmd
= 'game' then
4921 if gGameSettings
.GameType
<> GT_NONE
then
4923 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
4926 if Length(P
) = 1 then
4928 g_Console_Add(cmd
+ ' <WAD> [MAP] [# players]');
4931 // game not started yet, load fist map from some wad
4933 s
:= addWadExtension(P
[1]);
4934 found
:= e_FindResource(AllMapDirs
, s
);
4938 P
[1] := ExpandFileName(P
[1]);
4939 // if map not choosed then set first map
4940 if Length(P
) < 3 then
4943 P
[2] := g_Game_GetFirstMap(P
[1]);
4946 s
:= P
[1] + ':\' + UpperCase(P
[2]);
4948 if g_Map_Exist(s
) then
4952 with gGameSettings
do
4954 Options
:= gsGameFlags
;
4955 GameMode
:= g_Game_TextToMode(gsGameMode
);
4956 if gSwitchGameMode
<> GM_NONE
then
4957 GameMode
:= gSwitchGameMode
;
4958 if GameMode
= GM_NONE
then GameMode
:= GM_DM
;
4959 if GameMode
= GM_SINGLE
then GameMode
:= GM_COOP
;
4961 if Length(P
) >= 4 then
4962 b
:= StrToIntDef(P
[3], 1);
4963 g_Game_StartCustom(s
, GameMode
, TimeLimit
,
4964 GoalLimit
, MaxLives
, Options
, b
);
4969 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
4971 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [UpperCase(P
[2]), P
[1]]));
4973 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]));
4975 else if cmd
= 'host' then
4977 if gGameSettings
.GameType
<> GT_NONE
then
4979 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
4982 if Length(P
) < 4 then
4984 g_Console_Add(cmd
+ ' <listen IP> <port> <WAD> [MAP] [# players]');
4987 if not StrToIp(P
[1], listen
) then
4989 prt
:= StrToIntDef(P
[2], 25666);
4991 s
:= addWadExtension(P
[3]);
4992 found
:= e_FindResource(AllMapDirs
, s
);
4996 // get first map in wad, if not specified
4997 if Length(P
) < 5 then
5000 P
[4] := g_Game_GetFirstMap(P
[1]);
5002 s
:= P
[3] + ':\' + UpperCase(P
[4]);
5003 if g_Map_Exist(s
) then
5007 with gGameSettings
do
5009 Options
:= gsGameFlags
;
5010 GameMode
:= g_Game_TextToMode(gsGameMode
);
5011 if gSwitchGameMode
<> GM_NONE
then GameMode
:= gSwitchGameMode
;
5012 if GameMode
= GM_NONE
then GameMode
:= GM_DM
;
5013 if GameMode
= GM_SINGLE
then GameMode
:= GM_COOP
;
5015 if Length(P
) >= 6 then
5016 b
:= StrToIntDef(P
[5], 0);
5017 g_Game_StartServer(s
, GameMode
, TimeLimit
, GoalLimit
, MaxLives
, Options
, b
, listen
, prt
)
5023 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[3]]))
5025 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [UpperCase(P
[4]), P
[3]]))
5030 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[3]]))
5033 else if cmd
= 'map' then
5035 if Length(P
) = 1 then
5037 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
5039 g_Console_Add(cmd
+ ' <MAP>');
5040 g_Console_Add(cmd
+ ' <WAD> [MAP]')
5044 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
])
5049 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
5051 if Length(P
) < 3 then
5053 // first param is map or wad
5054 s
:= UpperCase(P
[1]);
5055 if g_Map_Exist(gGameSettings
.WAD
+ ':\' + s
) then
5057 gExitByTrigger
:= False;
5060 // already in game, finish current map
5062 gExit
:= EXIT_ENDLEVELCUSTOM
;
5066 // intermission, so change map immediately
5073 found
:= e_FindResource(AllMapDirs
, s
);
5075 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [s
, 'WAD ' + P
[1]]));
5078 // no such map, found wad
5081 P
[1] := ExpandFileName(pw
);
5082 P
[2] := g_Game_GetFirstMap(P
[1]);
5083 s
:= P
[1] + ':\' + P
[2];
5084 if g_Map_Exist(s
) then
5086 gExitByTrigger
:= False;
5089 // already in game, finish current map
5091 gExit
:= EXIT_ENDLEVELCUSTOM
5095 // intermission, so change map immediately
5102 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
5104 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]))
5109 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]))
5115 s
:= addWadExtension(P
[1]);
5116 found
:= e_FindResource(AllMapDirs
, s
);
5120 P
[2] := UpperCase(P
[2]);
5121 s
:= P
[1] + ':\' + P
[2];
5122 if g_Map_Exist(s
) then
5124 gExitByTrigger
:= False;
5128 gExit
:= EXIT_ENDLEVELCUSTOM
5137 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]))
5142 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]))
5148 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
])
5152 else if cmd
= 'nextmap' then
5154 if not(gGameOn
or (gState
= STATE_INTERCUSTOM
)) then
5156 g_Console_Add(_lc
[I_MSG_NOT_GAME
])
5161 if Length(P
) = 1 then
5163 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
5165 g_Console_Add(cmd
+ ' <MAP>');
5166 g_Console_Add(cmd
+ ' <WAD> [MAP]');
5171 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
5177 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
5179 if Length(P
) < 3 then
5181 // first param is map or wad
5182 s
:= UpperCase(P
[1]);
5183 if g_Map_Exist(gGameSettings
.WAD
+ ':\' + s
) then
5186 gExitByTrigger
:= False;
5192 // no such map, found wad
5193 pw
:= addWadExtension(P
[1]);
5194 found
:= e_FindResource(MapDirs
, pw
);
5196 found
:= e_FindResource(WadDirs
, pw
);
5198 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [s
, P
[1]]));
5201 // map not specified, select first map
5203 P
[2] := g_Game_GetFirstMap(P
[1]);
5204 s
:= P
[1] + ':\' + P
[2];
5205 if g_Map_Exist(s
) then
5207 gExitByTrigger
:= False;
5214 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
5216 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]))
5221 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]))
5227 // specified two params wad + map
5228 pw
:= addWadExtension(P
[1]);
5229 found
:= e_FindResource(MapDirs
, pw
);
5231 found
:= e_FindResource(MapDirs
, pw
);
5235 P
[2] := UpperCase(P
[2]);
5236 s
:= P
[1] + ':\' + P
[2];
5237 if g_Map_Exist(s
) then
5239 gExitByTrigger
:= False;
5245 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]))
5250 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]))
5256 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
])
5261 if gNextMap
= '' then
5262 g_Console_Add(_lc
[I_MSG_NEXTMAP_UNSET
])
5264 g_Console_Add(Format(_lc
[I_MSG_NEXTMAP_SET
], [gNextMap
]))
5268 else if (cmd
= 'endmap') or (cmd
= 'goodbye') then
5272 g_Console_Add(_lc
[I_MSG_NOT_GAME
])
5276 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
5278 gExitByTrigger
:= False;
5279 // next map not specified, try to find trigger EXIT
5280 if (gNextMap
= '') and (gTriggers
<> nil) then
5282 for a
:= 0 to High(gTriggers
) do
5284 if gTriggers
[a
].TriggerType
= TRIGGER_EXIT
then
5286 gExitByTrigger
:= True;
5287 //gNextMap := gTriggers[a].Data.MapName;
5288 gNextMap
:= gTriggers
[a
].tgcMap
;
5293 if gNextMap
= '' then
5294 gNextMap
:= g_Game_GetNextMap();
5295 if not isWadPath(gNextMap
) then
5296 s
:= gGameSettings
.WAD
+ ':\' + gNextMap
5299 if g_Map_Exist(s
) then
5300 gExit
:= EXIT_ENDLEVELCUSTOM
5302 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [gNextMap
]))
5306 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
])
5310 else if (cmd
= 'event') then
5312 if (Length(P
) <= 1) then
5314 for a
:= 0 to High(gEvents
) do
5315 if gEvents
[a
].Command
= '' then
5316 g_Console_Add(gEvents
[a
].Name
+ ' <none>')
5318 g_Console_Add(gEvents
[a
].Name
+ ' "' + gEvents
[a
].Command
+ '"');
5321 if (Length(P
) = 2) then
5323 for a
:= 0 to High(gEvents
) do
5324 if gEvents
[a
].Name
= P
[1] then
5325 if gEvents
[a
].Command
= '' then
5326 g_Console_Add(gEvents
[a
].Name
+ ' <none>')
5328 g_Console_Add(gEvents
[a
].Name
+ ' "' + gEvents
[a
].Command
+ '"');
5331 for a
:= 0 to High(gEvents
) do
5332 if gEvents
[a
].Name
= P
[1] then
5334 gEvents
[a
].Command
:= '';
5335 for b
:= 2 to High(P
) do
5336 if Pos(' ', P
[b
]) = 0 then
5337 gEvents
[a
].Command
:= gEvents
[a
].Command
+ ' ' + P
[b
]
5339 gEvents
[a
].Command
:= gEvents
[a
].Command
+ ' "' + P
[b
] + '"';
5340 gEvents
[a
].Command
:= Trim(gEvents
[a
].Command
);
5344 else if cmd
= 'suicide' then
5348 if g_Game_IsClient
then
5349 MC_SEND_CheatRequest(NET_CHEAT_SUICIDE
)
5352 if gPlayer1
<> nil then
5353 gPlayer1
.Damage(SUICIDE_DAMAGE
, gPlayer1
.UID
, 0, 0, HIT_SELF
);
5354 if gPlayer2
<> nil then
5355 gPlayer2
.Damage(SUICIDE_DAMAGE
, gPlayer2
.UID
, 0, 0, HIT_SELF
);
5359 else if cmd
= 'screenshot' then
5363 else if cmd
= 'weapon' then
5365 if Length(p
) = 2 then
5367 a
:= WP_FIRST
+ StrToInt(p
[1]) - 1;
5368 if (a
>= WP_FIRST
) and (a
<= WP_LAST
) then
5369 gSelectWeapon
[0, a
] := True
5372 else if (cmd
= 'p1_weapon') or (cmd
= 'p2_weapon') then
5374 if Length(p
) = 2 then
5376 a
:= WP_FIRST
+ StrToInt(p
[1]) - 1;
5377 b
:= ord(cmd
[2]) - ord('1');
5378 if (a
>= WP_FIRST
) and (a
<= WP_LAST
) then
5379 gSelectWeapon
[b
, a
] := True
5382 // Команды Своей игры:
5383 else if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
5385 if cmd
= 'bot_addred' then
5387 if Length(P
) > 1 then
5388 g_Bot_Add(TEAM_RED
, StrToIntDef(P
[1], 2))
5390 g_Bot_Add(TEAM_RED
, 2);
5392 else if cmd
= 'bot_addblue' then
5394 if Length(P
) > 1 then
5395 g_Bot_Add(TEAM_BLUE
, StrToIntDef(P
[1], 2))
5397 g_Bot_Add(TEAM_BLUE
, 2);
5399 else if cmd
= 'spectate' then
5405 else if cmd
= 'say' then
5407 if g_Game_IsServer
and g_Game_IsNet
then
5409 if Length(P
) > 1 then
5412 for a
:= 1 to High(P
) do
5413 chstr
:= chstr
+ P
[a
] + ' ';
5415 if Length(chstr
) > 200 then SetLength(chstr
, 200);
5417 if Length(chstr
) < 1 then
5419 g_Console_Add('say <text>');
5423 chstr
:= b_Text_Format(chstr
);
5424 MH_SEND_Chat(chstr
, NET_CHAT_PLAYER
);
5426 else g_Console_Add('say <text>');
5428 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
5430 else if cmd
= 'tell' then
5432 if g_Game_IsServer
and g_Game_IsNet
then
5434 if (Length(P
) > 2) and (P
[1] <> '') then
5437 for a
:= 2 to High(P
) do
5438 chstr
:= chstr
+ P
[a
] + ' ';
5440 if Length(chstr
) > 200 then SetLength(chstr
, 200);
5442 if Length(chstr
) < 1 then
5444 g_Console_Add('tell <playername> <text>');
5448 pl
:= g_Net_Client_ByName(P
[1]);
5450 MH_SEND_Chat(b_Text_Format(chstr
), NET_CHAT_PLAYER
, pl
^.ID
)
5452 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
5454 else g_Console_Add('tell <playername> <text>');
5456 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
5458 else if cmd
= 'centerprint' then
5460 if (Length(P
) > 2) and (P
[1] <> '') then
5463 for a
:= 2 to High(P
) do
5464 chstr
:= chstr
+ P
[a
] + ' ';
5466 if Length(chstr
) > 200 then SetLength(chstr
, 200);
5468 if Length(chstr
) < 1 then
5470 g_Console_Add('centerprint <timeout> <text>');
5474 a
:= StrToIntDef(P
[1], 100);
5475 chstr
:= b_Text_Format(chstr
);
5476 g_Game_Message(chstr
, a
);
5477 if g_Game_IsNet
and g_Game_IsServer
then
5478 MH_SEND_GameEvent(NET_EV_BIGTEXT
, a
, chstr
);
5480 else g_Console_Add('centerprint <timeout> <text>');
5482 else if (cmd
= 'overtime') and not g_Game_IsClient
then
5484 if (Length(P
) = 1) or (StrToIntDef(P
[1], -1) <= 0) then
5486 // Дополнительное время:
5487 gGameSettings
.TimeLimit
:= (gTime
- gGameStartTime
) div 1000 + Word(StrToIntDef(P
[1], 0));
5489 g_Console_Add(Format(_lc
[I_MSG_TIME_LIMIT
],
5490 [gGameSettings
.TimeLimit
div 3600,
5491 (gGameSettings
.TimeLimit
div 60) mod 60,
5492 gGameSettings
.TimeLimit
mod 60]));
5493 if g_Game_IsNet
then MH_SEND_GameSettings
;
5495 else if (cmd
= 'rcon_password') and g_Game_IsClient
then
5497 if (Length(P
) <= 1) then
5498 g_Console_Add('rcon_password <password>')
5500 MC_SEND_RCONPassword(P
[1]);
5502 else if cmd
= 'rcon' then
5504 if g_Game_IsClient
then
5506 if Length(P
) > 1 then
5509 for a
:= 1 to High(P
) do
5510 chstr
:= chstr
+ P
[a
] + ' ';
5512 if Length(chstr
) > 200 then SetLength(chstr
, 200);
5514 if Length(chstr
) < 1 then
5516 g_Console_Add('rcon <command>');
5520 MC_SEND_RCONCommand(chstr
);
5522 else g_Console_Add('rcon <command>');
5525 else if cmd
= 'ready' then
5527 if g_Game_IsServer
and (gLMSRespawn
= LMS_RESPAWN_WARMUP
) then
5528 gLMSRespawnTime
:= gTime
+ 100;
5530 else if (cmd
= 'callvote') and g_Game_IsNet
then
5532 if Length(P
) > 1 then
5535 for a
:= 1 to High(P
) do begin
5536 if a
> 1 then chstr
:= chstr
+ ' ';
5537 chstr
:= chstr
+ P
[a
];
5540 if Length(chstr
) > 200 then SetLength(chstr
, 200);
5542 if Length(chstr
) < 1 then
5544 g_Console_Add('callvote <command>');
5548 if g_Game_IsClient
then
5549 MC_SEND_Vote(True, chstr
)
5551 g_Game_StartVote(chstr
, gPlayer1Settings
.Name
);
5552 g_Console_Process('vote', True);
5555 g_Console_Add('callvote <command>');
5557 else if (cmd
= 'vote') and g_Game_IsNet
then
5559 if g_Game_IsClient
then
5561 else if gVoteInProgress
then
5563 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
5564 a
:= Floor((NetClientCount
+1)/2.0) + 1
5566 a
:= Floor(NetClientCount
/2.0) + 1;
5571 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_REVOKED
], [gPlayer1Settings
.Name
, gVoteCount
, a
]), True);
5572 MH_SEND_VoteEvent(NET_VE_REVOKE
, gPlayer1Settings
.Name
, 'a', gVoteCount
, a
);
5578 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_VOTE
], [gPlayer1Settings
.Name
, gVoteCount
, a
]), True);
5579 MH_SEND_VoteEvent(NET_VE_VOTE
, gPlayer1Settings
.Name
, 'a', gVoteCount
, a
);
5587 procedure SystemCommands(P
: SSArray
);
5591 cmd
:= LowerCase(P
[0]);
5600 gRC_Width
:= Max(1, gRC_Width
);
5601 gRC_Height
:= Max(1, gRC_Height
);
5602 gBPP
:= Max(1, gBPP
);
5603 if sys_SetDisplayMode(gRC_Width
, gRC_Height
, gBPP
, gRC_FullScreen
, gRC_Maximized
) = True then
5604 e_LogWriteln('resolution changed')
5606 e_LogWriteln('resolution not changed');
5607 sys_EnableVSync(gVSync
);
5611 if Length(p
) = 2 then
5613 gMaxFPS
:= StrToIntDef(p
[1], gMaxFPS
);
5615 gFrameTime
:= 1000 div gMaxFPS
5619 e_LogWritefln('r_maxfps %d', [gMaxFPS
]);
5623 if Length(p
) = 2 then
5625 gAskLanguage
:= true;
5626 gLanguage
:= LANGUAGE_ENGLISH
;
5627 case LowerCase(p
[1]) of
5630 gAskLanguage
:= false;
5631 gLanguage
:= LANGUAGE_ENGLISH
;
5635 gAskLanguage
:= false;
5636 gLanguage
:= LANGUAGE_RUSSIAN
;
5640 gAskLanguage
:= true;
5641 gLanguage
:= LANGUAGE_ENGLISH
;
5644 g_Language_Set(gLanguage
);
5648 e_LogWritefln('usage: %s <English|Russian|Ask>', [cmd
]);
5654 procedure g_TakeScreenShot(Filename
: string = '');
5655 var s
: TStream
; t
: TDateTime
; dir
, date
, name
: String;
5657 if e_NoGraphics
then Exit
;
5659 dir
:= e_GetWriteableDir(ScreenshotDirs
);
5661 if Filename
= '' then
5664 DateTimeToString(date
, 'yyyy-mm-dd-hh-nn-ss', t
);
5665 Filename
:= 'screenshot-' + date
;
5668 name
:= e_CatPath(dir
, Filename
+ '.png');
5669 s
:= createDiskFile(name
);
5671 e_MakeScreenshot(s
, gScreenWidth
, gScreenHeight
);
5673 g_Console_Add(Format(_lc
[I_CONSOLE_SCREENSHOT
], [name
]))
5675 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_WRITE
], [name
]));
5680 g_Console_Add('oh shit, i can''t create screenshot!')
5684 procedure g_Game_InGameMenu(Show
: Boolean);
5686 if (g_ActiveWindow
= nil) and Show
then
5688 if gGameSettings
.GameType
= GT_SINGLE
then
5689 g_GUI_ShowWindow('GameSingleMenu')
5692 if g_Game_IsClient
then
5693 g_GUI_ShowWindow('GameClientMenu')
5695 if g_Game_IsNet
then
5696 g_GUI_ShowWindow('GameServerMenu')
5698 g_GUI_ShowWindow('GameCustomMenu');
5700 g_Sound_PlayEx('MENU_OPEN');
5702 // Пауза при меню только в одиночной игре:
5703 if (not g_Game_IsNet
) then
5707 if (g_ActiveWindow
<> nil) and (not Show
) then
5709 // Пауза при меню только в одиночной игре:
5710 if (not g_Game_IsNet
) then
5711 g_Game_Pause(False);
5715 procedure g_Game_Pause (Enable
: Boolean);
5719 if not gGameOn
then exit
;
5721 if not (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
]) then exit
;
5724 gPauseMain
:= Enable
;
5726 if (gPause
<> oldPause
) then g_Game_PauseAllSounds(gPause
);
5729 procedure g_Game_HolmesPause (Enable
: Boolean);
5733 if not gGameOn
then exit
;
5734 if not (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
]) then exit
;
5737 gPauseHolmes
:= Enable
;
5739 if (gPause
<> oldPause
) then g_Game_PauseAllSounds(gPause
);
5742 procedure g_Game_PauseAllSounds(Enable
: Boolean);
5747 if gTriggers
<> nil then
5748 for i
:= 0 to High(gTriggers
) do
5749 with gTriggers
[i
] do
5750 if (TriggerType
= TRIGGER_SOUND
) and
5752 Sound
.IsPlaying() then
5754 Sound
.Pause(Enable
);
5758 if gPlayers
<> nil then
5759 for i
:= 0 to High(gPlayers
) do
5760 if gPlayers
[i
] <> nil then
5761 gPlayers
[i
].PauseSounds(Enable
);
5764 if gMusic
<> nil then
5765 gMusic
.Pause(Enable
);
5768 procedure g_Game_StopAllSounds(all
: Boolean);
5772 if gTriggers
<> nil then
5773 for i
:= 0 to High(gTriggers
) do
5774 with gTriggers
[i
] do
5775 if (TriggerType
= TRIGGER_SOUND
) and
5779 if gMusic
<> nil then
5786 procedure g_Game_UpdateTriggerSounds
;
5789 if gTriggers
<> nil then
5790 for i
:= 0 to High(gTriggers
) do
5791 with gTriggers
[i
] do
5792 if (TriggerType
= TRIGGER_SOUND
) and (Sound
<> nil) and tgcLocal
and Sound
.IsPlaying() then
5793 Sound
.SetCoordsRect(X
, Y
, Width
, Height
, tgcVolume
/ 255.0)
5796 function g_Game_IsWatchedPlayer(UID
: Word): Boolean;
5799 if (gPlayer1
<> nil) and (gPlayer1
.UID
= UID
) then
5804 if (gPlayer2
<> nil) and (gPlayer2
.UID
= UID
) then
5809 if gSpectMode
<> SPECT_PLAYERS
then
5811 if gSpectPID1
= UID
then
5816 if gSpectViewTwo
and (gSpectPID2
= UID
) then
5823 function g_Game_IsWatchedTeam(Team
: Byte): Boolean;
5828 if (gPlayer1
<> nil) and (gPlayer1
.Team
= Team
) then
5833 if (gPlayer2
<> nil) and (gPlayer2
.Team
= Team
) then
5838 if gSpectMode
<> SPECT_PLAYERS
then
5840 Pl
:= g_Player_Get(gSpectPID1
);
5841 if (Pl
<> nil) and (Pl
.Team
= Team
) then
5846 if gSpectViewTwo
then
5848 Pl
:= g_Player_Get(gSpectPID2
);
5849 if (Pl
<> nil) and (Pl
.Team
= Team
) then
5857 procedure g_Game_Message(Msg
: string; Time
: Word);
5859 MessageLineLength
:= (gScreenWidth
- 204) div e_CharFont_GetMaxWidth(gMenuFont
);
5860 MessageText
:= b_Text_Wrap(b_Text_Format(Msg
), MessageLineLength
);
5861 MessageTime
:= Time
;
5864 procedure g_Game_ChatSound(Text: String; Taunt
: Boolean = True);
5866 punct
: Array[0..13] of String =
5867 ('.', ',', ':', ';', '!', '?', '(', ')', '''', '"', '/', '\', '*', '^');
5873 function IsPunctuation(S
: String): Boolean;
5878 if Length(S
) <> 1 then
5880 for i
:= Low(punct
) to High(punct
) do
5881 if S
= punct
[i
] then
5887 function FilterPunctuation(S
: String): String;
5891 for i
:= Low(punct
) to High(punct
) do
5892 S
:= StringReplace(S
, punct
[i
], ' ', [rfReplaceAll
]);
5898 if gUseChatSounds
and Taunt
and (gChatSounds
<> nil) and (Pos(': ', Text) > 0) then
5900 // remove player name
5901 Delete(Text, 1, Pos(': ', Text) + 2 - 1);
5902 // for FullWord check
5903 Text := toLowerCase1251(' ' + Text + ' ');
5904 fpText
:= FilterPunctuation(Text);
5906 for i
:= 0 to Length(gChatSounds
) - 1 do
5909 for j
:= 0 to Length(gChatSounds
[i
].Tags
) - 1 do
5911 if gChatSounds
[i
].FullWord
and (not IsPunctuation(gChatSounds
[i
].Tags
[j
])) then
5912 ok
:= Pos(' ' + gChatSounds
[i
].Tags
[j
] + ' ', fpText
) > 0
5914 ok
:= Pos(gChatSounds
[i
].Tags
[j
], Text) > 0;
5920 gChatSounds
[i
].Sound
.Play();
5926 g_Sound_PlayEx('SOUND_GAME_RADIO');
5929 procedure g_Game_Announce_GoodShot(SpawnerUID
: Word);
5938 if not g_Game_IsWatchedPlayer(SpawnerUID
) then
5942 if goodsnd
[a
].IsPlaying() then
5945 goodsnd
[Random(4)].Play();
5948 procedure g_Game_Announce_KillCombo(Param
: Integer);
5955 UID
:= Param
and $FFFF;
5960 Pl
:= g_Player_Get(UID
);
5969 g_Console_Add(Format(_lc
[I_PLAYER_KILL_2X
], [Name
]), True);
5973 g_Console_Add(Format(_lc
[I_PLAYER_KILL_3X
], [Name
]), True);
5977 g_Console_Add(Format(_lc
[I_PLAYER_KILL_4X
], [Name
]), True);
5981 g_Console_Add(Format(_lc
[I_PLAYER_KILL_MX
], [Name
]), True);
5989 if not g_Game_IsWatchedPlayer(UID
) then
5992 if (not g_Game_IsWatchedPlayer(UID
)) and (c
< 4) then
5996 if killsnd
[n
].IsPlaying() then
6001 procedure g_Game_Announce_BodyKill(SpawnerUID
: Word);
6009 if not g_Game_IsWatchedPlayer(SpawnerUID
) then
6013 if hahasnd
[a
].IsPlaying() then
6016 hahasnd
[Random(3)].Play();
6019 procedure g_Game_StartVote(Command
, Initiator
: string);
6023 if not gVotesEnabled
then Exit
;
6024 if gGameSettings
.GameType
<> GT_SERVER
then Exit
;
6025 if gVoteInProgress
or gVotePassed
then
6027 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_INPROGRESS
], [gVoteCommand
]), True);
6028 MH_SEND_VoteEvent(NET_VE_INPROGRESS
, gVoteCommand
);
6031 gVoteInProgress
:= True;
6032 gVotePassed
:= False;
6033 gVoteTimer
:= gTime
+ gVoteTimeout
* 1000;
6036 gVoteCommand
:= Command
;
6038 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
6039 Need
:= Floor((NetClientCount
+1)/2.0)+1
6041 Need
:= Floor(NetClientCount
/2.0)+1;
6042 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_STARTED
], [Initiator
, Command
, Need
]), True);
6043 MH_SEND_VoteEvent(NET_VE_STARTED
, Initiator
, Command
, Need
);
6046 procedure g_Game_CheckVote
;
6050 if gGameSettings
.GameType
<> GT_SERVER
then Exit
;
6051 if not gVoteInProgress
then Exit
;
6053 if (gTime
>= gVoteTimer
) then
6055 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
6056 Need
:= Floor((NetClientCount
+1)/2.0) + 1
6058 Need
:= Floor(NetClientCount
/2.0) + 1;
6059 if gVoteCount
>= Need
then
6061 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_PASSED
], [gVoteCommand
]), True);
6062 MH_SEND_VoteEvent(NET_VE_PASSED
, gVoteCommand
);
6063 gVotePassed
:= True;
6064 gVoteCmdTimer
:= gTime
+ 5000;
6068 g_Console_Add(_lc
[I_MESSAGE_VOTE_FAILED
], True);
6069 MH_SEND_VoteEvent(NET_VE_FAILED
);
6071 if NetClients
<> nil then
6072 for I
:= Low(NetClients
) to High(NetClients
) do
6073 if NetClients
[i
].Used
then
6074 NetClients
[i
].Voted
:= False;
6075 gVoteInProgress
:= False;
6081 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
6082 Need
:= Floor((NetClientCount
+1)/2.0) + 1
6084 Need
:= Floor(NetClientCount
/2.0) + 1;
6085 if gVoteCount
>= Need
then
6087 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_PASSED
], [gVoteCommand
]), True);
6088 MH_SEND_VoteEvent(NET_VE_PASSED
, gVoteCommand
);
6089 gVoteInProgress
:= False;
6090 gVotePassed
:= True;
6091 gVoteCmdTimer
:= gTime
+ 5000;
6094 if NetClients
<> nil then
6095 for I
:= Low(NetClients
) to High(NetClients
) do
6096 if NetClients
[i
].Used
then
6097 NetClients
[i
].Voted
:= False;
6102 procedure g_Game_LoadMapList(FileName
: string);
6110 if not FileExists(FileName
) then Exit
;
6112 AssignFile(ListFile
, FileName
);
6114 while not EOF(ListFile
) do
6116 ReadLn(ListFile
, s
);
6119 if s
= '' then Continue
;
6121 SetLength(MapList
, Length(MapList
)+1);
6122 MapList
[High(MapList
)] := s
;
6124 CloseFile(ListFile
);
6127 procedure g_Game_SetDebugMode();
6130 // Читы (даже в своей игре):
6134 procedure g_Game_SetLoadingText(Text: String; Max
: Integer; reWrite
: Boolean);
6138 if Length(LoadingStat
.Msgs
) = 0 then
6144 begin // Переходим на следующую строку или скроллируем:
6145 if NextMsg
= Length(Msgs
) then
6147 for i
:= 0 to High(Msgs
)-1 do
6148 Msgs
[i
] := Msgs
[i
+1];
6156 Msgs
[NextMsg
-1] := Text;
6160 PBarWasHere
:= false;
6163 g_ActiveWindow
:= nil;
6165 ProcessLoading(true);
6168 procedure g_Game_StepLoading(Value
: Integer = -1);
6179 if (ShowCount
> LOADING_SHOW_STEP
) or (Value
> -1) then
6187 procedure g_Game_ClearLoading();
6196 len
:= ((gScreenHeight
div 3)*2 - 50) div LOADING_INTERLINE
;
6197 if len
< 1 then len
:= 1;
6198 SetLength(Msgs
, len
);
6199 for len
:= Low(Msgs
) to High(Msgs
) do
6202 PBarWasHere
:= false;
6206 procedure Parse_Params(var pars
: TParamStrValues
);
6213 while i
<= ParamCount
do
6216 if (s
[1] = '-') and (Length(s
) > 1) then
6218 if (s
[2] = '-') and (Length(s
) > 2) then
6219 begin // Одиночный параметр
6220 SetLength(pars
, Length(pars
) + 1);
6221 with pars
[High(pars
)] do
6223 Name
:= LowerCase(s
);
6228 if (i
< ParamCount
) then
6229 begin // Параметр со значением
6231 SetLength(pars
, Length(pars
) + 1);
6232 with pars
[High(pars
)] do
6234 Name
:= LowerCase(s
);
6235 Value
:= LowerCase(ParamStr(i
));
6244 function Find_Param_Value(var pars
: TParamStrValues
; aName
: String): String;
6249 for i
:= 0 to High(pars
) do
6250 if pars
[i
].Name
= aName
then
6252 Result
:= pars
[i
].Value
;
6257 procedure g_Game_Process_Params();
6259 pars
: TParamStrValues
;
6262 LimT
, LimS
: Integer;
6273 s
:= Find_Param_Value(pars
, '--debug');
6276 g_Game_SetDebugMode();
6277 s
:= Find_Param_Value(pars
, '--netdump');
6282 // Connect when game loads
6283 ip
:= Find_Param_Value(pars
, '-connect');
6287 s
:= Find_Param_Value(pars
, '-port');
6288 if (s
= '') or not TryStrToInt(s
, Port
) then
6291 s
:= Find_Param_Value(pars
, '-pw');
6293 g_Game_StartClient(ip
, Port
, s
);
6297 s
:= LowerCase(Find_Param_Value(pars
, '-dbg-mainwad'));
6300 gDefaultMegawadStart
:= s
;
6303 if (Find_Param_Value(pars
, '--dbg-mainwad-restore') <> '') or
6304 (Find_Param_Value(pars
, '--dbg-mainwad-default') <> '') then
6306 gDefaultMegawadStart
:= DF_Default_Megawad_Start
;
6309 // Start map when game loads:
6310 map
:= LowerCase(Find_Param_Value(pars
, '-map'));
6311 if isWadPath(map
) then
6314 s
:= Find_Param_Value(pars
, '-gm');
6315 GMode
:= g_Game_TextToMode(s
);
6316 if GMode
= GM_NONE
then GMode
:= GM_DM
;
6317 if GMode
= GM_SINGLE
then GMode
:= GM_COOP
;
6320 s
:= Find_Param_Value(pars
, '-limt');
6321 if (s
= '') or (not TryStrToInt(s
, LimT
)) then
6327 s
:= Find_Param_Value(pars
, '-lims');
6328 if (s
= '') or (not TryStrToInt(s
, LimS
)) then
6334 s
:= Find_Param_Value(pars
, '-lives');
6335 if (s
= '') or (not TryStrToInt(s
, Lives
)) then
6341 s
:= Find_Param_Value(pars
, '-opt');
6345 Opt
:= StrToIntDef(s
, 0);
6348 s
:= Find_Param_Value(pars
, '--close');
6352 // Override map to test:
6353 s
:= LowerCase(Find_Param_Value(pars
, '-testmap'));
6356 if e_IsValidResourceName(s
) then
6357 e_FindResource(AllMapDirs
, s
);
6358 gTestMap
:= ExpandFileName(s
);
6361 // Delete test map after play:
6362 s
:= Find_Param_Value(pars
, '--testdelete');
6365 //gMapToDelete := MapsDir + map;
6366 e_WriteLog('"--testdelete" is deprecated, use --tempdelete.', TMsgType
.Fatal
);
6370 // Delete temporary WAD after play:
6371 s
:= Find_Param_Value(pars
, '--tempdelete');
6372 if (s
<> '') and (gTestMap
<> '') then
6374 gMapToDelete
:= gTestMap
;
6375 gTempDelete
:= True;
6378 // Number of players:
6379 s
:= Find_Param_Value(pars
, '-pl');
6381 n
:= DEFAULT_PLAYERS
6383 n
:= StrToIntDef(s
, DEFAULT_PLAYERS
);
6386 s
:= Find_Param_Value(pars
, '-port');
6387 if (s
= '') or not TryStrToInt(s
, Port
) then
6388 g_Game_StartCustom(map
, GMode
, LimT
, LimS
, Lives
, Opt
, n
)
6390 g_Game_StartServer(map
, GMode
, LimT
, LimS
, Lives
, Opt
, n
, 0, Port
);
6393 // Execute script when game loads:
6394 s
:= Find_Param_Value(pars
, '-exec');
6397 // if not isWadPath(s) then
6398 // s := GameDir + '/' + s;
6403 if IOResult
<> 0 then
6405 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], ['Failed to read file: ' + s
]), TMsgType
.Warning
);
6406 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_READ
], [s
]));
6410 e_WriteLog('Executing script: ' + s
, TMsgType
.Notify
);
6411 g_Console_Add(Format(_lc
[I_CONSOLE_EXEC
], [s
]));
6416 if IOResult
<> 0 then
6418 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], ['Failed to read file: ' + s
]), TMsgType
.Warning
);
6419 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_READ
], [s
]));
6423 if Pos('#', s
) <> 1 then // script comment
6424 g_Console_Process(s
, True);
6435 conRegVar('pf_draw_frame', @g_profile_frame_draw
, 'draw frame rendering profiles', 'render profiles');
6436 //conRegVar('pf_update_frame', @g_profile_frame_update, 'draw frame updating profiles', 'update profiles');
6437 conRegVar('pf_coldet', @g_profile_collision
, 'draw collision detection profiles', 'coldet profiles');
6438 conRegVar('pf_los', @g_profile_los
, 'draw monster LOS profiles', 'monster LOS profiles');
6440 conRegVar('r_sq_draw', @gdbg_map_use_accel_render
, 'accelerated spatial queries in rendering', 'accelerated rendering');
6441 conRegVar('cd_sq_enabled', @gdbg_map_use_accel_coldet
, 'accelerated spatial queries in map coldet', 'accelerated map coldet');
6442 conRegVar('mon_sq_enabled', @gmon_debug_use_sqaccel
, 'accelerated spatial queries for monsters', 'accelerated monster coldet');
6443 conRegVar('wtrace_sq_enabled', @gwep_debug_fast_trace
, 'accelerated spatial queries for weapon hitscan trace', 'accelerated weapon hitscan');
6445 conRegVar('pr_enabled', @gpart_dbg_enabled
, 'enable/disable particles', 'particles');
6446 conRegVar('pr_phys_enabled', @gpart_dbg_phys_enabled
, 'enable/disable particle physics', 'particle physics');
6448 conRegVar('los_enabled', @gmon_dbg_los_enabled
, 'enable/disable monster LOS calculations', 'monster LOS', true);
6449 conRegVar('mon_think', @gmon_debug_think
, 'enable/disable monster thinking', 'monster thinking', true);
6451 {$IFDEF ENABLE_HOLMES}
6452 conRegVar('dbg_holmes', @g_holmes_enabled
, 'enable/disable Holmes', 'Holmes', true);
6455 conRegVar('dbg_ignore_level_bounds', @g_dbg_ignore_bounds
, 'ignore level bounds', '', false);
6457 conRegVar('r_scale', @g_dbg_scale
, 0.01, 100.0, 'render scale', '', false);
6458 conRegVar('r_resolution_scale', @r_pixel_scale
, 0.01, 100.0, 'upscale factor', '', false);
6460 conRegVar('light_enabled', @gwin_k8_enable_light_experiments
, 'enable/disable dynamic lighting', 'lighting');
6461 conRegVar('light_player_halo', @g_playerLight
, 'enable/disable player halo', 'player light halo');
6463 conRegVar('r_smallmap_align_h', @r_smallmap_h
, 'halign: 0: left; 1: center; 2: right', 'horizontal aligning of small maps');
6464 conRegVar('r_smallmap_align_v', @r_smallmap_v
, 'valign: 0: top; 1: center; 2: bottom', 'vertial aligning of small maps');
6466 conRegVar('r_showfps', @gShowFPS
, 'draw fps counter', 'draw fps counter');
6467 conRegVar('r_showtime', @gShowTime
, 'show game time', 'show game time');
6468 conRegVar('r_showping', @gShowPing
, 'show ping', 'show ping');
6469 conRegVar('r_showscore', @gShowGoals
, 'show score', 'show score');
6470 conRegVar('r_showkillmsg', @gShowKillMsg
, 'show kill log', 'show kill log');
6471 conRegVar('r_showlives', @gShowLives
, 'show lives', 'show lives');
6472 conRegVar('r_showspect', @gSpectHUD
, 'show spectator hud', 'show spectator hud');
6473 conRegVar('r_showstat', @gShowStat
, 'show stats', 'show stats');
6474 conRegVar('r_showpids', @gShowPIDs
, 'show PIDs', 'show PIDs');