1 (* Copyright (C) Doom 2D: Forever Developers
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, version 3 of the License ONLY.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 {$INCLUDE ../shared/a_modes.inc}
23 g_basic
, g_player
, e_graphics
, g_res_downloader
,
24 g_sound
, g_gui
, utils
, md5
, mempool
, xprofiler
,
28 TGameSettings
= record
44 TDelayedEvent
= record
53 Sound
: TPlayableSound
;
54 Tags
: Array of String;
58 TPlayerSettings
= record
77 function g_Game_IsNet(): Boolean;
78 function g_Game_IsServer(): Boolean;
79 function g_Game_IsClient(): Boolean;
80 procedure g_Game_Init();
81 procedure g_Game_Free (freeTextures
: Boolean=true);
82 procedure g_Game_LoadData();
83 procedure g_Game_FreeData();
84 procedure g_Game_Update();
85 procedure g_Game_Draw();
86 procedure g_Game_Quit();
87 procedure g_Game_SetupScreenSize();
88 procedure g_Game_ChangeResolution(newWidth
, newHeight
: Word; nowFull
, nowMax
: Boolean);
89 function g_Game_ModeToText(Mode
: Byte): string;
90 function g_Game_TextToMode(Mode
: string): Byte;
91 procedure g_Game_ExecuteEvent(Name
: String);
92 function g_Game_DelayEvent(DEType
: Byte; Time
: LongWord; Num
: Integer = 0; Str
: String = ''): Integer;
93 procedure g_Game_AddPlayer(Team
: Byte = TEAM_NONE
);
94 procedure g_Game_RemovePlayer();
95 procedure g_Game_Spectate();
96 procedure g_Game_SpectateCenterView();
97 procedure g_Game_StartSingle(Map
: String; TwoPlayers
: Boolean; nPlayers
: Byte);
98 procedure g_Game_StartCustom(Map
: String; GameMode
: Byte; TimeLimit
, GoalLimit
: Word; MaxLives
: Byte; Options
: LongWord; nPlayers
: Byte);
99 procedure g_Game_StartServer(Map
: String; GameMode
: Byte; TimeLimit
, GoalLimit
: Word; MaxLives
: Byte; Options
: LongWord; nPlayers
: Byte; IPAddr
: LongWord; Port
: Word);
100 procedure g_Game_StartClient(Addr
: String; Port
: Word; PW
: String);
101 procedure g_Game_Restart();
102 procedure g_Game_RestartLevel();
103 procedure g_Game_RestartRound(NoMapRestart
: Boolean = False);
104 function g_Game_ClientWAD (NewWAD
: String; const WHash
: TMD5Digest
): AnsiString;
105 procedure g_Game_SaveOptions();
106 function g_Game_StartMap(asMegawad
: Boolean; Map
: String; Force
: Boolean = False; const oldMapPath
: AnsiString=''): Boolean;
107 procedure g_Game_ChangeMap(const MapPath
: String);
108 procedure g_Game_ExitLevel(const Map
: AnsiString);
109 function g_Game_GetFirstMap(WAD
: String): String;
110 function g_Game_GetNextMap(): String;
111 procedure g_Game_NextLevel();
112 procedure g_Game_Pause(Enable
: Boolean);
113 procedure g_Game_HolmesPause(Enable
: Boolean);
114 procedure g_Game_InGameMenu(Show
: Boolean);
115 function g_Game_IsWatchedPlayer(UID
: Word): Boolean;
116 function g_Game_IsWatchedTeam(Team
: Byte): Boolean;
117 procedure g_Game_Message(Msg
: String; Time
: Word);
118 procedure g_Game_LoadMapList(FileName
: String);
119 procedure g_Game_PauseAllSounds(Enable
: Boolean);
120 procedure g_Game_StopAllSounds(all
: Boolean);
121 procedure g_Game_UpdateTriggerSounds();
122 function g_Game_GetMegaWADInfo(WAD
: String): TMegaWADInfo
;
123 procedure g_Game_ChatSound(Text: String; Taunt
: Boolean = True);
124 procedure g_Game_Announce_GoodShot(SpawnerUID
: Word);
125 procedure g_Game_Announce_KillCombo(Param
: Integer);
126 procedure g_Game_Announce_BodyKill(SpawnerUID
: Word);
127 procedure g_Game_StartVote(Command
, Initiator
: string);
128 procedure g_Game_CheckVote
;
129 procedure g_TakeScreenShot();
130 procedure g_FatalError(Text: String);
131 procedure g_SimpleError(Text: String);
132 function g_Game_IsTestMap(): Boolean;
133 procedure g_Game_DeleteTestMap();
134 procedure GameCVars(P
: SSArray
);
135 procedure GameCommands(P
: SSArray
);
136 procedure GameCheats(P
: SSArray
);
137 procedure DebugCommands(P
: SSArray
);
138 procedure g_Game_Process_Params
;
139 procedure g_Game_SetLoadingText(Text: String; Max
: Integer; reWrite
: Boolean);
140 procedure g_Game_StepLoading(Value
: Integer = -1);
141 procedure g_Game_ClearLoading();
142 procedure g_Game_SetDebugMode();
143 procedure DrawLoadingStat();
144 procedure DrawMenuBackground(tex
: AnsiString);
146 { procedure SetWinPause(Enable: Boolean); }
151 LOADING_SHOW_STEP
= 100;
152 LOADING_INTERLINE
= 20;
167 MESSAGE_DIKEY
= WM_USER
+ 1;
172 EXIT_ENDLEVELSINGLE
= 4;
173 EXIT_ENDLEVELCUSTOM
= 5;
175 GAME_OPTION_RESERVED
= 1;
176 GAME_OPTION_TEAMDAMAGE
= 2;
177 GAME_OPTION_ALLOWEXIT
= 4;
178 GAME_OPTION_WEAPONSTAY
= 8;
179 GAME_OPTION_MONSTERS
= 16;
180 GAME_OPTION_BOTVSPLAYER
= 32;
181 GAME_OPTION_BOTVSMONSTER
= 64;
186 STATE_INTERCUSTOM
= 3;
187 STATE_INTERSINGLE
= 4;
193 LMS_RESPAWN_NONE
= 0;
194 LMS_RESPAWN_WARMUP
= 1;
195 LMS_RESPAWN_FINAL
= 2;
212 CONFIG_FILENAME
= 'Doom2DF.cfg';
214 TEST_MAP_NAME
= '$$$_TEST_$$$';
216 STD_PLAYER_MODEL
= 'Doomer';
226 gGameSettings
: TGameSettings
;
227 gPlayer1Settings
: TPlayerSettings
;
228 gPlayer2Settings
: TPlayerSettings
;
230 gPlayerScreenSize
: TDFPoint
;
231 gPlayer1ScreenCoord
: TDFPoint
;
232 gPlayer2ScreenCoord
: TDFPoint
;
233 gPlayer1
: TPlayer
= nil;
234 gPlayer2
: TPlayer
= nil;
235 gPlayerDrawn
: TPlayer
= nil;
237 gSwitchGameMode
: Byte = GM_DM
;
238 gHearPoint1
, gHearPoint2
: THearPoint
;
239 gSoundEffectsDF
: Boolean = False;
240 gSoundTriggerTime
: Word = 0;
241 gAnnouncer
: Byte = ANNOUNCE_NONE
;
242 goodsnd
: array[0..3] of TPlayableSound
;
243 killsnd
: array[0..3] of TPlayableSound
;
244 hahasnd
: array[0..2] of TPlayableSound
;
245 sound_get_flag
: array[0..1] of TPlayableSound
;
246 sound_lost_flag
: array[0..1] of TPlayableSound
;
247 sound_ret_flag
: array[0..1] of TPlayableSound
;
248 sound_cap_flag
: array[0..1] of TPlayableSound
;
249 gBodyKillEvent
: Integer = -1;
250 gDefInterTime
: ShortInt = -1;
251 gInterEndTime
: LongWord = 0;
252 gInterTime
: LongWord = 0;
253 gServInterTime
: Byte = 0;
254 gGameStartTime
: LongWord = 0;
255 gTotalMonsters
: Integer = 0;
256 gPauseMain
: Boolean = false;
257 gPauseHolmes
: Boolean = false;
258 gShowTime
: Boolean = False;
259 gShowFPS
: Boolean = False;
260 gShowGoals
: Boolean = True;
261 gShowStat
: Boolean = True;
262 gShowKillMsg
: Boolean = True;
263 gShowLives
: Boolean = True;
264 gShowPing
: Boolean = False;
265 gShowMap
: Boolean = False;
267 gState
: Byte = STATE_NONE
;
269 sWidth
, sHeight
: Word;
270 gSpectMode
: Byte = SPECT_NONE
;
271 gSpectHUD
: Boolean = True;
272 gSpectKeyPress
: Boolean = False;
273 gSpectX
: Integer = 0;
274 gSpectY
: Integer = 0;
275 gSpectStep
: Byte = 8;
276 gSpectViewTwo
: Boolean = False;
277 gSpectPID1
: Integer = -1;
278 gSpectPID2
: Integer = -1;
279 gSpectAuto
: Boolean = False;
280 gSpectAutoNext
: LongWord;
281 gSpectAutoStepX
: Integer;
282 gSpectAutoStepY
: Integer;
283 gMusic
: TMusic
= nil;
284 gLoadGameMode
: Boolean;
285 gCheats
: Boolean = False;
286 gMapOnce
: Boolean = False;
287 gMapToDelete
: String;
288 gTempDelete
: Boolean = False;
289 gLastMap
: Boolean = False;
290 gWinPosX
, gWinPosY
: Integer;
291 gWinSizeX
, gWinSizeY
: Integer;
292 gWinFrameX
, gWinFrameY
, gWinCaption
: Integer;
293 gWinActive
: Boolean = True; // by default window is active, lol
294 gResolutionChange
: Boolean = False;
295 gRC_Width
, gRC_Height
: Word;
296 gRC_FullScreen
, gRC_Maximized
: Boolean;
297 gLanguageChange
: Boolean = False;
298 gDebugMode
: Boolean = False;
299 g_debug_Sounds
: Boolean = False;
300 g_debug_Frames
: Boolean = False;
301 g_debug_WinMsgs
: Boolean = False;
302 g_debug_MonsterOff
: Boolean = False;
303 g_debug_BotAIOff
: Byte = 0;
304 g_debug_HealthBar
: Boolean = False;
305 g_Debug_Player
: Boolean = False;
306 gCoopMonstersKilled
: Word = 0;
307 gCoopSecretsFound
: Word = 0;
308 gCoopTotalMonstersKilled
: Word = 0;
309 gCoopTotalSecretsFound
: Word = 0;
310 gCoopTotalMonsters
: Word = 0;
311 gCoopTotalSecrets
: Word = 0;
312 gStatsOff
: Boolean = False;
313 gStatsPressed
: Boolean = False;
314 gExitByTrigger
: Boolean = False;
315 gNextMap
: String = '';
316 gLMSRespawn
: Byte = LMS_RESPAWN_NONE
;
317 gLMSRespawnTime
: Cardinal = 0;
318 gLMSSoftSpawn
: Boolean = False;
319 gMissionFailed
: Boolean = False;
320 gVoteInProgress
: Boolean = False;
321 gVotePassed
: Boolean = False;
322 gVoteCommand
: string = '';
323 gVoteTimer
: Cardinal = 0;
324 gVoteCmdTimer
: Cardinal = 0;
325 gVoteCount
: Integer = 0;
326 gVoteTimeout
: Cardinal = 30;
327 gVoted
: Boolean = False;
328 gVotesEnabled
: Boolean = True;
329 gEvents
: Array of TGameEvent
;
330 gDelayedEvents
: Array of TDelayedEvent
;
331 gUseChatSounds
: Boolean = True;
332 gChatSounds
: Array of TChatSound
;
333 gSelectWeapon
: Array [0..1, WP_FIRST
..WP_LAST
] of Boolean; // [player, weapon]
334 gInterReadyCount
: Integer = 0;
336 g_dbg_ignore_bounds
: Boolean = false;
337 r_smallmap_h
: Integer = 0; // 0: left; 1: center; 2: right
338 r_smallmap_v
: Integer = 2; // 0: top; 1: center; 2: bottom
340 // move button values:
341 // bits 0-1: l/r state:
342 // 0: neither left, nor right pressed
345 // bits 4-5: l/r state when strafe was pressed
346 P1MoveButton
: Byte = 0;
347 P2MoveButton
: Byte = 0;
349 g_profile_frame_update
: Boolean = false;
350 g_profile_frame_draw
: Boolean = false;
351 g_profile_collision
: Boolean = false;
352 g_profile_los
: Boolean = false;
353 g_profile_history_size
: Integer = 1000;
355 g_rlayer_back
: Boolean = true;
356 g_rlayer_step
: Boolean = true;
357 g_rlayer_wall
: Boolean = true;
358 g_rlayer_door
: Boolean = true;
359 g_rlayer_acid1
: Boolean = true;
360 g_rlayer_acid2
: Boolean = true;
361 g_rlayer_water
: Boolean = true;
362 g_rlayer_fore
: Boolean = true;
365 procedure g_ResetDynlights ();
366 procedure g_AddDynLight (x
, y
, radius
: Integer; r
, g
, b
, a
: Single);
367 procedure g_DynLightExplosion (x
, y
, radius
: Integer; r
, g
, b
: Single);
369 function conIsCheatsEnabled (): Boolean; inline;
370 function gPause (): Boolean; inline;
376 {$INCLUDE ../nogl/noGLuses.inc}
377 {$IFDEF ENABLE_HOLMES}
380 e_texture
, e_res
, g_textures
, g_main
, g_window
, g_menu
,
381 e_input
, e_log
, g_console
, g_items
, g_map
, g_panel
,
382 g_playermodel
, g_gfx
, g_options
, Math
,
383 g_triggers
, g_monsters
, e_sound
, CONFIG
,
385 ENet
, e_msg
, g_netmsg
, g_netmaster
,
386 sfs
, wadreader
, g_system
;
390 hasPBarGfx
: Boolean = false;
393 // ////////////////////////////////////////////////////////////////////////// //
394 function gPause (): Boolean; inline; begin result
:= gPauseMain
or gPauseHolmes
; end;
397 // ////////////////////////////////////////////////////////////////////////// //
398 function conIsCheatsEnabled (): Boolean; inline;
401 if g_Game_IsNet
then exit
;
402 if not gDebugMode
then
404 //if not gCheats then exit;
405 if not (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
]) then exit
;
406 if not (gGameSettings
.GameMode
in [GM_COOP
, GM_SINGLE
]) then exit
;
412 // ////////////////////////////////////////////////////////////////////////// //
414 profileFrameDraw
: TProfiler
= nil;
417 // ////////////////////////////////////////////////////////////////////////// //
420 x
, y
, radius
: Integer;
423 exploRadius
: Integer;
427 g_dynLights
: array of TDynLight
= nil;
428 g_dynLightCount
: Integer = 0;
429 g_playerLight
: Boolean = false;
431 procedure g_ResetDynlights ();
435 if not gwin_has_stencil
then begin g_dynLightCount
:= 0; exit
; end;
437 for idx
:= 0 to g_dynLightCount
-1 do
439 if g_dynLights
[idx
].exploCount
= -666 then
446 Inc(g_dynLights
[idx
].exploCount
);
447 if (g_dynLights
[idx
].exploCount
< 10) then
449 g_dynLights
[idx
].radius
:= g_dynLights
[idx
].exploRadius
+g_dynLights
[idx
].exploCount
*8;
450 g_dynLights
[idx
].a
:= 0.4+g_dynLights
[idx
].exploCount
/10;
451 if (g_dynLights
[idx
].a
> 0.8) then g_dynLights
[idx
].a
:= 0.8;
452 if lnum
<> idx
then g_dynLights
[lnum
] := g_dynLights
[idx
];
457 g_dynLightCount
:= lnum
;
460 procedure g_AddDynLight (x
, y
, radius
: Integer; r
, g
, b
, a
: Single);
462 if not gwin_has_stencil
then exit
;
463 if g_dynLightCount
= length(g_dynLights
) then SetLength(g_dynLights
, g_dynLightCount
+1024);
464 g_dynLights
[g_dynLightCount
].x
:= x
;
465 g_dynLights
[g_dynLightCount
].y
:= y
;
466 g_dynLights
[g_dynLightCount
].radius
:= radius
;
467 g_dynLights
[g_dynLightCount
].r
:= r
;
468 g_dynLights
[g_dynLightCount
].g
:= g
;
469 g_dynLights
[g_dynLightCount
].b
:= b
;
470 g_dynLights
[g_dynLightCount
].a
:= a
;
471 g_dynLights
[g_dynLightCount
].exploCount
:= -666;
472 Inc(g_dynLightCount
);
475 procedure g_DynLightExplosion (x
, y
, radius
: Integer; r
, g
, b
: Single);
477 if not gwin_has_stencil
then exit
;
478 if g_dynLightCount
= length(g_dynLights
) then SetLength(g_dynLights
, g_dynLightCount
+1024);
479 g_dynLights
[g_dynLightCount
].x
:= x
;
480 g_dynLights
[g_dynLightCount
].y
:= y
;
481 g_dynLights
[g_dynLightCount
].radius
:= 0;
482 g_dynLights
[g_dynLightCount
].exploRadius
:= radius
;
483 g_dynLights
[g_dynLightCount
].r
:= r
;
484 g_dynLights
[g_dynLightCount
].g
:= g
;
485 g_dynLights
[g_dynLightCount
].b
:= b
;
486 g_dynLights
[g_dynLightCount
].a
:= 0;
487 g_dynLights
[g_dynLightCount
].exploCount
:= 0;
488 Inc(g_dynLightCount
);
492 // ////////////////////////////////////////////////////////////////////////// //
493 function calcProfilesHeight (prof
: TProfiler
): Integer;
496 if (prof
= nil) then exit
;
497 if (length(prof
.bars
) = 0) then exit
;
498 result
:= length(prof
.bars
)*(16+2);
502 function drawProfiles (x
, y
: Integer; prof
: TProfiler
): Integer;
509 if (prof
= nil) then exit
;
511 if (length(prof
.bars
) = 0) then exit
;
513 hgt
:= calcProfilesHeight(prof
);
514 if (x
< 0) then x
:= gScreenWidth
-(wdt
-1)+x
;
515 if (y
< 0) then y
:= gScreenHeight
-(hgt
-1)+y
;
517 //e_DrawFillQuad(x, y, x+wdt-1, y+hgt-1, 255, 255, 255, 200, B_BLEND);
518 //e_DrawFillQuad(x, y, x+wdt-1, y+hgt-1, 20, 20, 20, 0, B_NONE);
519 e_DarkenQuadWH(x
, y
, wdt
, hgt
, 150);
522 for ii
:= 0 to High(prof
.bars
) do
524 e_TextureFontPrintEx(x
+2+4*prof
.bars
[ii
].level
, yy
, Format('%s: %d', [prof
.bars
[ii
].name
, prof
.bars
[ii
].value
]), gStdFont
, 255, 255, 0, 1, false);
531 // ////////////////////////////////////////////////////////////////////////// //
533 TEndCustomGameStat
= record
534 PlayerStat
: TPlayerStatArray
;
538 Map
, MapName
: String;
541 TEndSingleGameStat
= record
542 PlayerStat
: Array [0..1] of record
548 TotalSecrets
: Integer;
551 TLoadingStat
= record
555 Msgs
: Array of String;
557 PBarWasHere
: Boolean; // did we draw a progress bar for this message?
560 TParamStrValue
= record
565 TParamStrValues
= Array of TParamStrValue
;
568 INTER_ACTION_TEXT
= 1;
569 INTER_ACTION_PIC
= 2;
570 INTER_ACTION_MUSIC
= 3;
574 FPSCounter
, UPSCounter
: Word;
575 FPSTime
, UPSTime
: LongWord;
576 DataLoaded
: Boolean = False;
577 IsDrawStat
: Boolean = False;
578 CustomStat
: TEndCustomGameStat
;
579 SingleStat
: TEndSingleGameStat
;
580 LoadingStat
: TLoadingStat
;
581 EndingGameCounter
: Byte = 0;
584 MessageLineLength
: Integer = 80;
585 MapList
: SSArray
= nil;
586 MapIndex
: Integer = -1;
587 InterReadyTime
: Integer = -1;
593 text: Array of ShortString;
594 anim
: Array of ShortString;
595 pic
: Array of ShortString;
596 mus
: Array of ShortString;
598 triggers
: Array of record
600 actions
: Array of record
601 action
, p1
, p2
: Integer;
604 cur_trigger
: Integer;
617 function Compare(a
, b
: TPlayerStat
): Integer;
619 if a
.Spectator
then Result
:= 1
620 else if b
.Spectator
then Result
:= -1
621 else if a
.Frags
< b
.Frags
then Result
:= 1
622 else if a
.Frags
> b
.Frags
then Result
:= -1
623 else if a
.Deaths
< b
.Deaths
then Result
:= -1
624 else if a
.Deaths
> b
.Deaths
then Result
:= 1
625 else if a
.Kills
< b
.Kills
then Result
:= -1
629 procedure SortGameStat(var stat
: TPlayerStatArray
);
634 if stat
= nil then Exit
;
636 for I
:= High(stat
) downto Low(stat
) do
637 for J
:= Low(stat
) to High(stat
) - 1 do
638 if Compare(stat
[J
], stat
[J
+ 1]) = 1 then
641 stat
[J
] := stat
[J
+ 1];
646 function g_Game_ModeToText(Mode
: Byte): string;
650 GM_DM
: Result
:= _lc
[I_MENU_GAME_TYPE_DM
];
651 GM_TDM
: Result
:= _lc
[I_MENU_GAME_TYPE_TDM
];
652 GM_CTF
: Result
:= _lc
[I_MENU_GAME_TYPE_CTF
];
653 GM_COOP
: Result
:= _lc
[I_MENU_GAME_TYPE_COOP
];
654 GM_SINGLE
: Result
:= _lc
[I_MENU_GAME_TYPE_SINGLE
];
658 function g_Game_TextToMode(Mode
: string): Byte;
661 Mode
:= UpperCase(Mode
);
662 if Mode
= _lc
[I_MENU_GAME_TYPE_DM
] then
667 if Mode
= _lc
[I_MENU_GAME_TYPE_TDM
] then
672 if Mode
= _lc
[I_MENU_GAME_TYPE_CTF
] then
677 if Mode
= _lc
[I_MENU_GAME_TYPE_COOP
] then
682 if Mode
= _lc
[I_MENU_GAME_TYPE_SINGLE
] then
689 function g_Game_IsNet(): Boolean;
691 Result
:= (gGameSettings
.GameType
in [GT_SERVER
, GT_CLIENT
]);
694 function g_Game_IsServer(): Boolean;
696 Result
:= (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
, GT_SERVER
]);
699 function g_Game_IsClient(): Boolean;
701 Result
:= (gGameSettings
.GameType
= GT_CLIENT
);
704 function g_Game_GetMegaWADInfo(WAD
: String): TMegaWADInfo
;
711 Result
.name
:= ExtractFileName(WAD
);
712 Result
.description
:= '';
715 w
:= TWADFile
.Create();
718 if not w
.GetResource('INTERSCRIPT', p
, len
) then
724 cfg
:= TConfig
.CreateMem(p
, len
);
725 Result
.name
:= cfg
.ReadStr('megawad', 'name', ExtractFileName(WAD
));
726 Result
.description
:= cfg
.ReadStr('megawad', 'description', '');
727 Result
.author
:= cfg
.ReadStr('megawad', 'author', '');
728 Result
.pic
:= cfg
.ReadStr('megawad', 'pic', '');
734 procedure g_Game_FreeWAD();
738 for a
:= 0 to High(MegaWAD
.res
.pic
) do
739 if MegaWAD
.res
.pic
[a
] <> '' then
740 g_Texture_Delete(MegaWAD
.res
.pic
[a
]);
742 for a
:= 0 to High(MegaWAD
.res
.mus
) do
743 if MegaWAD
.res
.mus
[a
] <> '' then
744 g_Sound_Delete(MegaWAD
.res
.mus
[a
]);
746 MegaWAD
.res
.pic
:= nil;
747 MegaWAD
.res
.text := nil;
748 MegaWAD
.res
.anim
:= nil;
749 MegaWAD
.res
.mus
:= nil;
750 MegaWAD
.triggers
:= nil;
752 g_Texture_Delete('TEXTURE_endpic');
753 g_Sound_Delete('MUSIC_endmus');
755 ZeroMemory(@MegaWAD
, SizeOf(MegaWAD
));
756 gGameSettings
.WAD
:= '';
759 procedure g_Game_LoadWAD(WAD
: string);
768 gGameSettings
.WAD
:= WAD
;
769 if not (gGameSettings
.GameMode
in [GM_COOP
, GM_SINGLE
]) then
772 MegaWAD
.info
:= g_Game_GetMegaWADInfo(WAD
);
774 w
:= TWADFile
.Create();
777 if not w
.GetResource('INTERSCRIPT', p
, len
) then
783 cfg
:= TConfig
.CreateMem(p
, len
);
788 s := cfg.ReadStr('pic', 'pic'+IntToStr(b), '');
789 if s = '' then Break;
792 SetLength(MegaWAD.res.pic, Length(MegaWAD.res.pic)+1);
793 MegaWAD.res.pic[High(MegaWAD.res.pic)] := s;
795 g_Texture_CreateWADEx(s, s);
801 s := cfg.ReadStr('mus', 'mus'+IntToStr(b), '');
802 if s = '' then Break;
805 SetLength(MegaWAD.res.mus, Length(MegaWAD.res.mus)+1);
806 MegaWAD.res.mus[High(MegaWAD.res.mus)] := s;
808 g_Music_CreateWADEx(s, s);
811 MegaWAD
.endpic
:= cfg
.ReadStr('megawad', 'endpic', '');
812 if MegaWAD
.endpic
<> '' then
814 TEXTUREFILTER
:= GL_LINEAR
;
815 s
:= e_GetResourcePath(WadDirs
, MegaWAD
.endpic
, WAD
);
816 g_Texture_CreateWADEx('TEXTURE_endpic', s
);
817 TEXTUREFILTER
:= GL_NEAREST
;
819 MegaWAD
.endmus
:= cfg
.ReadStr('megawad', 'endmus', 'Standart.wad:D2DMUS\ÊÎÍÅÖ');
820 if MegaWAD
.endmus
<> '' then
822 s
:= e_GetResourcePath(WadDirs
, MegaWAD
.endmus
, WAD
);
823 g_Sound_CreateWADEx('MUSIC_endmus', s
, True);
831 {procedure start_trigger(t: string);
835 function next_trigger(): Boolean;
839 procedure DisableCheats();
845 if gPlayer1
<> nil then gPlayer1
.GodMode
:= False;
846 if gPlayer2
<> nil then gPlayer2
.GodMode
:= False;
847 if gPlayer1
<> nil then gPlayer1
.NoTarget
:= False;
848 if gPlayer2
<> nil then gPlayer2
.NoTarget
:= False;
850 {$IF DEFINED(D2F_DEBUG)}
851 if gPlayer1
<> nil then gPlayer1
.NoTarget
:= True;
852 gAimLine
:= g_dbg_aimline_on
;
856 procedure g_Game_ExecuteEvent(Name
: String);
862 if gEvents
= nil then
864 for a
:= 0 to High(gEvents
) do
865 if gEvents
[a
].Name
= Name
then
867 if gEvents
[a
].Command
<> '' then
868 g_Console_Process(gEvents
[a
].Command
, True);
873 function g_Game_DelayEvent(DEType
: Byte; Time
: LongWord; Num
: Integer = 0; Str
: String = ''): Integer;
878 if gDelayedEvents
<> nil then
879 for a
:= 0 to High(gDelayedEvents
) do
880 if not gDelayedEvents
[a
].Pending
then
887 SetLength(gDelayedEvents
, Length(gDelayedEvents
) + 1);
888 n
:= High(gDelayedEvents
);
890 gDelayedEvents
[n
].Pending
:= True;
891 gDelayedEvents
[n
].DEType
:= DEType
;
892 gDelayedEvents
[n
].DENum
:= Num
;
893 gDelayedEvents
[n
].DEStr
:= Str
;
894 if DEType
= DE_GLOBEVENT
then
895 gDelayedEvents
[n
].Time
:= (sys_GetTicks() {div 1000}) + Time
897 gDelayedEvents
[n
].Time
:= gTime
+ Time
;
906 if g_Game_IsNet
and g_Game_IsServer
then
907 MH_SEND_GameEvent(NET_EV_MAPEND
, Byte(gMissionFailed
));
911 gPauseHolmes
:= false;
914 g_Game_StopAllSounds(False);
919 EndingGameCounter
:= 0;
920 g_ActiveWindow
:= nil;
922 gLMSRespawn
:= LMS_RESPAWN_NONE
;
923 gLMSRespawnTime
:= 0;
926 EXIT_SIMPLE
: // Âûõîä ÷åðåç ìåíþ èëè êîíåö òåñòà
931 begin // Ýòî áûë òåñò
935 begin // Âûõîä â ãëàâíîå ìåíþ
936 gMusic
.SetByName('MUSIC_MENU');
938 if gState
<> STATE_SLIST
then
940 g_GUI_ShowWindow('MainMenu');
941 gState
:= STATE_MENU
;
944 // Îáíîâëÿåì ñïèñîê ñåðâåðîâ
945 slReturnPressed
:= True;
946 if g_Net_Slist_Fetch(slCurrent
) then
948 if slCurrent
= nil then
949 slWaitStr
:= _lc
[I_NET_SLIST_NOSERVERS
];
952 slWaitStr
:= _lc
[I_NET_SLIST_ERROR
];
953 g_Serverlist_GenerateTable(slCurrent
, slTable
);
956 g_Game_ExecuteEvent('ongameend');
960 EXIT_RESTART
: // Íà÷àòü óðîâåíü ñíà÷àëà
962 if not g_Game_IsClient
then g_Game_Restart();
965 EXIT_ENDLEVELCUSTOM
: // Çàêîí÷èëñÿ óðîâåíü â Ñâîåé èãðå
967 // Ñòàòèñòèêà Ñâîåé èãðû:
968 FileName
:= g_ExtractWadName(gMapInfo
.Map
);
970 CustomStat
.GameTime
:= gTime
;
971 CustomStat
.Map
:= ExtractFileName(FileName
)+':'+g_ExtractFileName(gMapInfo
.Map
); //ResName;
972 CustomStat
.MapName
:= gMapInfo
.Name
;
973 CustomStat
.GameMode
:= gGameSettings
.GameMode
;
974 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
975 CustomStat
.TeamStat
:= gTeamStat
;
977 CustomStat
.PlayerStat
:= nil;
979 // Ñòàòèñòèêà èãðîêîâ:
980 if gPlayers
<> nil then
982 for a
:= 0 to High(gPlayers
) do
983 if gPlayers
[a
] <> nil then
985 SetLength(CustomStat
.PlayerStat
, Length(CustomStat
.PlayerStat
)+1);
986 with CustomStat
.PlayerStat
[High(CustomStat
.PlayerStat
)] do
989 Name
:= gPlayers
[a
].Name
;
990 Frags
:= gPlayers
[a
].Frags
;
991 Deaths
:= gPlayers
[a
].Death
;
992 Kills
:= gPlayers
[a
].Kills
;
993 Team
:= gPlayers
[a
].Team
;
994 Color
:= gPlayers
[a
].Model
.Color
;
995 Spectator
:= gPlayers
[a
].FSpectator
;
999 SortGameStat(CustomStat
.PlayerStat
);
1002 g_Game_ExecuteEvent('onmapend');
1003 if not g_Game_IsClient
then g_Player_ResetReady
;
1004 gInterReadyCount
:= 0;
1006 // Çàòóõàþùèé ýêðàí:
1007 EndingGameCounter
:= 255;
1008 gState
:= STATE_FOLD
;
1010 if gDefInterTime
< 0 then
1011 gInterEndTime
:= IfThen((gGameSettings
.GameType
= GT_SERVER
) and (gPlayer1
= nil), 15000, 25000)
1013 gInterEndTime
:= gDefInterTime
* 1000;
1016 EXIT_ENDLEVELSINGLE
: // Çàêîí÷èëñÿ óðîâåíü â Îäèíî÷íîé èãðå
1018 // Ñòàòèñòèêà Îäèíî÷íîé èãðû:
1019 SingleStat
.GameTime
:= gTime
;
1020 SingleStat
.TwoPlayers
:= gPlayer2
<> nil;
1021 SingleStat
.TotalSecrets
:= gSecretsCount
;
1022 // Ñòàòèñòèêà ïåðâîãî èãðîêà:
1023 SingleStat
.PlayerStat
[0].Kills
:= gPlayer1
.MonsterKills
;
1024 SingleStat
.PlayerStat
[0].Secrets
:= gPlayer1
.Secrets
;
1025 // Ñòàòèñòèêà âòîðîãî èãðîêà (åñëè åñòü):
1026 if SingleStat
.TwoPlayers
then
1028 SingleStat
.PlayerStat
[1].Kills
:= gPlayer2
.MonsterKills
;
1029 SingleStat
.PlayerStat
[1].Secrets
:= gPlayer2
.Secrets
;
1032 g_Game_ExecuteEvent('onmapend');
1035 if gNextMap
<> '' then
1037 gMusic
.SetByName('MUSIC_INTERMUS');
1039 gState
:= STATE_INTERSINGLE
;
1042 g_Game_ExecuteEvent('oninter');
1044 else // Áîëüøå íåò êàðò
1046 // Çàòóõàþùèé ýêðàí:
1047 EndingGameCounter
:= 255;
1048 gState
:= STATE_FOLD
;
1053 // Îêîí÷àíèå îáðàáîòàíî:
1054 if gExit
<> EXIT_QUIT
then
1058 procedure drawTime(X
, Y
: Integer); inline;
1060 e_TextureFontPrint(x
, y
,
1061 Format('%d:%.2d:%.2d', [
1062 gTime
div 1000 div 3600,
1063 (gTime
div 1000 div 60) mod 60,
1064 gTime
div 1000 mod 60
1069 procedure DrawStat();
1071 pc
, x
, y
, w
, h
: Integer;
1072 w1
, w2
, w3
, w4
: Integer;
1074 cw
, ch
, r
, g
, b
, rr
, gg
, bb
: Byte;
1077 stat
: TPlayerStatArray
;
1084 pc
:= g_Player_GetCount
;
1085 e_TextureFontGetSize(gStdFont
, cw
, ch
);
1087 w
:= gScreenWidth
-(gScreenWidth
div 5);
1088 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
1091 h
:= 40+ch
*5+(ch
+8)*pc
;
1092 x
:= (gScreenWidth
div 2)-(w
div 2);
1093 y
:= (gScreenHeight
div 2)-(h
div 2);
1095 e_DrawFillQuad(x
, y
, x
+w
-1, y
+h
-1, 64, 64, 64, 32);
1096 e_DrawQuad(x
, y
, x
+w
-1, y
+h
-1, 255, 127, 0);
1098 drawTime(x
+w
-78, y
+8);
1100 wad
:= g_ExtractWadNameNoPath(gMapInfo
.Map
);
1101 map
:= g_ExtractFileName(gMapInfo
.Map
);
1102 mapstr
:= wad
+ ':\' + map
+ ' - ' + gMapInfo
.Name
;
1104 case gGameSettings
.GameMode
of
1107 if gGameSettings
.MaxLives
= 0 then
1108 s1
:= _lc
[I_GAME_DM
]
1110 s1
:= _lc
[I_GAME_LMS
];
1111 s2
:= Format(_lc
[I_GAME_FRAG_LIMIT
], [gGameSettings
.GoalLimit
]);
1112 s3
:= Format(_lc
[I_GAME_TIME_LIMIT
], [gGameSettings
.TimeLimit
div 3600, (gGameSettings
.TimeLimit
div 60) mod 60, gGameSettings
.TimeLimit
mod 60]);
1117 if gGameSettings
.MaxLives
= 0 then
1118 s1
:= _lc
[I_GAME_TDM
]
1120 s1
:= _lc
[I_GAME_TLMS
];
1121 s2
:= Format(_lc
[I_GAME_FRAG_LIMIT
], [gGameSettings
.GoalLimit
]);
1122 s3
:= Format(_lc
[I_GAME_TIME_LIMIT
], [gGameSettings
.TimeLimit
div 3600, (gGameSettings
.TimeLimit
div 60) mod 60, gGameSettings
.TimeLimit
mod 60]);
1127 s1
:= _lc
[I_GAME_CTF
];
1128 s2
:= Format(_lc
[I_GAME_SCORE_LIMIT
], [gGameSettings
.GoalLimit
]);
1129 s3
:= Format(_lc
[I_GAME_TIME_LIMIT
], [gGameSettings
.TimeLimit
div 3600, (gGameSettings
.TimeLimit
div 60) mod 60, gGameSettings
.TimeLimit
mod 60]);
1134 if gGameSettings
.MaxLives
= 0 then
1135 s1
:= _lc
[I_GAME_COOP
]
1137 s1
:= _lc
[I_GAME_SURV
];
1138 s2
:= _lc
[I_GAME_MONSTERS
] + ' ' + IntToStr(gCoopMonstersKilled
) + '/' + IntToStr(gTotalMonsters
);
1139 s3
:= _lc
[I_GAME_SECRETS
] + ' ' + IntToStr(gCoopSecretsFound
) + '/' + IntToStr(gSecretsCount
);
1150 e_TextureFontPrintEx(x
+(w
div 2)-(Length(s1
)*cw
div 2), _y
, s1
, gStdFont
, 255, 255, 255, 1);
1152 e_TextureFontPrintEx(x
+(w
div 2)-(Length(mapstr
)*cw
div 2), _y
, mapstr
, gStdFont
, 200, 200, 200, 1);
1154 e_TextureFontPrintEx(x
+16, _y
, s2
, gStdFont
, 200, 200, 200, 1);
1156 e_TextureFontPrintEx(x
+w
-16-(Length(s3
))*cw
, _y
, s3
,
1157 gStdFont
, 200, 200, 200, 1);
1159 if NetMode
= NET_SERVER
then
1160 e_TextureFontPrintEx(x
+8, y
+ 8, _lc
[I_NET_SERVER
], gStdFont
, 255, 255, 255, 1)
1162 if NetMode
= NET_CLIENT
then
1163 e_TextureFontPrintEx(x
+8, y
+ 8,
1164 NetClientIP
+ ':' + IntToStr(NetClientPort
), gStdFont
, 255, 255, 255, 1);
1168 stat
:= g_Player_GetStats();
1171 w2
:= (w
-16) div 6 + 48; // øèðèíà 2 ñòîëáöà
1172 w3
:= (w
-16) div 6; // øèðèíà 3 è 4 ñòîëáöîâ
1174 w1
:= w
-16-w2
-w3
-w4
; // îñòàâøååñÿ ïðîñòðàíñòâî - äëÿ öâåòà è èìåíè èãðîêà
1176 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
1180 for a
:= TEAM_RED
to TEAM_BLUE
do
1182 if a
= TEAM_RED
then
1184 s1
:= _lc
[I_GAME_TEAM_RED
];
1191 s1
:= _lc
[I_GAME_TEAM_BLUE
];
1197 e_TextureFontPrintEx(x
+16, _y
, s1
, gStdFont
, r
, g
, b
, 1);
1198 e_TextureFontPrintEx(x
+w1
+16, _y
, IntToStr(gTeamStat
[a
].Goals
),
1199 gStdFont
, r
, g
, b
, 1);
1201 _y
:= _y
+ch
+(ch
div 4);
1202 e_DrawLine(1, x
+16, _y
, x
+w
-16, _y
, r
, g
, b
);
1203 _y
:= _y
+(ch
div 4);
1205 for aa
:= 0 to High(stat
) do
1206 if stat
[aa
].Team
= a
then
1222 e_TextureFontPrintEx(x
+16, _y
, Name
, gStdFont
, rr
, gg
, bb
, 1);
1224 e_TextureFontPrintEx(x
+w1
+16, _y
, Format(_lc
[I_GAME_PING_MS
], [Ping
, Loss
]), gStdFont
, rr
, gg
, bb
, 1);
1226 e_TextureFontPrintEx(x
+w1
+w2
+16, _y
, IntToStr(Frags
), gStdFont
, rr
, gg
, bb
, 1);
1228 e_TextureFontPrintEx(x
+w1
+w2
+w3
+16, _y
, IntToStr(Deaths
), gStdFont
, rr
, gg
, bb
, 1);
1235 else if gGameSettings
.GameMode
in [GM_DM
, GM_COOP
] then
1238 e_TextureFontPrintEx(x
+16, _y
, _lc
[I_GAME_PLAYER_NAME
], gStdFont
, 255, 127, 0, 1);
1239 e_TextureFontPrintEx(x
+16+w1
, _y
, _lc
[I_GAME_PING
], gStdFont
, 255, 127, 0, 1);
1240 e_TextureFontPrintEx(x
+16+w1
+w2
, _y
, _lc
[I_GAME_FRAGS
], gStdFont
, 255, 127, 0, 1);
1241 e_TextureFontPrintEx(x
+16+w1
+w2
+w3
, _y
, _lc
[I_GAME_DEATHS
], gStdFont
, 255, 127, 0, 1);
1244 for aa
:= 0 to High(stat
) do
1258 e_DrawFillQuad(x
+16, _y
+4, x
+32-1, _y
+16+4-1, Color
.R
, Color
.G
, Color
.B
, 0);
1259 e_DrawQuad(x
+16, _y
+4, x
+32-1, _y
+16+4-1, 192, 192, 192);
1261 e_TextureFontPrintEx(x
+16+16+8, _y
+4, Name
, gStdFont
, r
, g
, 0, 1);
1263 e_TextureFontPrintEx(x
+w1
+16, _y
+4, Format(_lc
[I_GAME_PING_MS
], [Ping
, Loss
]), gStdFont
, r
, g
, 0, 1);
1265 e_TextureFontPrintEx(x
+w1
+w2
+16, _y
+4, IntToStr(Frags
), gStdFont
, r
, g
, 0, 1);
1267 e_TextureFontPrintEx(x
+w1
+w2
+w3
+16, _y
+4, IntToStr(Deaths
), gStdFont
, r
, g
, 0, 1);
1273 procedure g_Game_Init();
1276 knownFiles
: array of AnsiString = nil;
1278 wext
, s
: AnsiString;
1283 gTempDelete
:= False;
1285 sfsGCDisable(); // temporary disable removing of temporary volumes
1288 TEXTUREFILTER
:= GL_LINEAR
;
1289 g_Texture_CreateWADEx('MENU_BACKGROUND', GameWAD
+':TEXTURES\TITLE');
1290 g_Texture_CreateWADEx('INTER', GameWAD
+':TEXTURES\INTER');
1291 g_Texture_CreateWADEx('ENDGAME_EN', GameWAD
+':TEXTURES\ENDGAME_EN');
1292 g_Texture_CreateWADEx('ENDGAME_RU', GameWAD
+':TEXTURES\ENDGAME_RU');
1293 TEXTUREFILTER
:= GL_NEAREST
;
1295 LoadStdFont('STDTXT', 'STDFONT', gStdFont
);
1296 LoadFont('MENUTXT', 'MENUFONT', gMenuFont
);
1297 LoadFont('SMALLTXT', 'SMALLFONT', gMenuSmallFont
);
1299 g_Game_ClearLoading();
1300 g_Game_SetLoadingText(Format('Doom 2D: Forever %s', [GAME_VERSION
]), 0, False);
1301 g_Game_SetLoadingText('', 0, False);
1303 g_Game_SetLoadingText(_lc
[I_LOAD_CONSOLE
], 0, False);
1306 g_Game_SetLoadingText(_lc
[I_LOAD_MODELS
], 0, False);
1307 g_PlayerModel_LoadData();
1309 // load models from all possible wad types, in all known directories
1310 // this does a loosy job (linear search, ooph!), but meh
1311 for wext
in wadExtensions
do
1313 for f
:= High(ModelDirs
) downto Low(ModelDirs
) do
1315 if (FindFirst(ModelDirs
[f
]+DirectorySeparator
+'*'+wext
, faAnyFile
, SR
) = 0) then
1319 for s
in knownFiles
do
1321 if (strEquCI1251(forceFilenameExt(SR
.Name
, ''), forceFilenameExt(ExtractFileName(s
), ''))) then
1329 SetLength(knownFiles
, length(knownFiles
)+1);
1330 knownFiles
[High(knownFiles
)] := ModelDirs
[f
]+DirectorySeparator
+SR
.Name
;
1332 until (FindNext(SR
) <> 0);
1338 if (length(knownFiles
) = 0) then raise Exception
.Create('no player models found!');
1340 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
);
1341 for s
in knownFiles
do
1343 if not g_PlayerModel_Load(s
) then e_LogWritefln('Error loading model "%s"', [s
], TMsgType
.Warning
);
1347 gPauseMain
:= false;
1348 gPauseHolmes
:= false;
1351 {e_MouseInfo.Accel := 1.0;}
1353 g_Game_SetLoadingText(_lc
[I_LOAD_GAME_DATA
], 0, False);
1356 g_Game_SetLoadingText(_lc
[I_LOAD_MUSIC
], 0, False);
1357 g_Sound_CreateWADEx('MUSIC_INTERMUS', GameWAD
+':MUSIC\INTERMUS', True);
1358 g_Sound_CreateWADEx('MUSIC_MENU', GameWAD
+':MUSIC\MENU', True);
1359 g_Sound_CreateWADEx('MUSIC_ROUNDMUS', GameWAD
+':MUSIC\ROUNDMUS', True, True);
1360 g_Sound_CreateWADEx('MUSIC_STDENDMUS', GameWAD
+':MUSIC\ENDMUS', True);
1363 g_Game_SetLoadingText(_lc
[I_LOAD_MENUS
], 0, False);
1367 gMusic
:= TMusic
.Create();
1368 gMusic
.SetByName('MUSIC_MENU');
1371 gGameSettings
.WarmupTime
:= 30;
1373 gState
:= STATE_MENU
;
1375 SetLength(gEvents
, 6);
1376 gEvents
[0].Name
:= 'ongamestart';
1377 gEvents
[1].Name
:= 'ongameend';
1378 gEvents
[2].Name
:= 'onmapstart';
1379 gEvents
[3].Name
:= 'onmapend';
1380 gEvents
[4].Name
:= 'oninter';
1381 gEvents
[5].Name
:= 'onwadend';
1383 sfsGCEnable(); // enable releasing unused volumes
1387 procedure g_Game_Free(freeTextures
: Boolean=true);
1389 if NetMode
= NET_CLIENT
then g_Net_Disconnect();
1390 if NetMode
= NET_SERVER
then g_Net_Host_Die();
1392 g_Map_Free(freeTextures
);
1394 g_Player_RemoveAllCorpses();
1396 gGameSettings
.GameType
:= GT_NONE
;
1397 if gGameSettings
.GameMode
= GM_SINGLE
then
1398 gGameSettings
.GameMode
:= GM_DM
;
1399 gSwitchGameMode
:= gGameSettings
.GameMode
;
1402 gExitByTrigger
:= False;
1405 function IsActivePlayer(p
: TPlayer
): Boolean;
1410 Result
:= (not p
.FDummy
) and (not p
.FSpectator
);
1413 function GetActivePlayer_ByID(ID
: Integer): TPlayer
;
1420 if gPlayers
= nil then
1422 for a
:= Low(gPlayers
) to High(gPlayers
) do
1423 if IsActivePlayer(gPlayers
[a
]) then
1425 if gPlayers
[a
].UID
<> ID
then
1427 Result
:= gPlayers
[a
];
1432 function GetActivePlayerID_Next(Skip
: Integer = -1): Integer;
1438 if gPlayers
= nil then
1442 for a
:= Low(gPlayers
) to High(gPlayers
) do
1443 if IsActivePlayer(gPlayers
[a
]) then
1445 SetLength(ids
, Length(ids
) + 1);
1446 ids
[High(ids
)] := gPlayers
[a
].UID
;
1447 if gPlayers
[a
].UID
= Skip
then
1450 if Length(ids
) = 0 then
1455 Result
:= ids
[(idx
+ 1) mod Length(ids
)];
1458 function GetActivePlayerID_Prev(Skip
: Integer = -1): Integer;
1464 if gPlayers
= nil then
1468 for a
:= Low(gPlayers
) to High(gPlayers
) do
1469 if IsActivePlayer(gPlayers
[a
]) then
1471 SetLength(ids
, Length(ids
) + 1);
1472 ids
[High(ids
)] := gPlayers
[a
].UID
;
1473 if gPlayers
[a
].UID
= Skip
then
1476 if Length(ids
) = 0 then
1479 Result
:= ids
[Length(ids
) - 1]
1481 Result
:= ids
[(Length(ids
) - 1 + idx
) mod Length(ids
)];
1484 function GetActivePlayerID_Random(Skip
: Integer = -1): Integer;
1490 if gPlayers
= nil then
1494 for a
:= Low(gPlayers
) to High(gPlayers
) do
1495 if IsActivePlayer(gPlayers
[a
]) then
1497 SetLength(ids
, Length(ids
) + 1);
1498 ids
[High(ids
)] := gPlayers
[a
].UID
;
1499 if gPlayers
[a
].UID
= Skip
then
1502 if Length(ids
) = 0 then
1504 if Length(ids
) = 1 then
1509 Result
:= ids
[Random(Length(ids
))];
1511 while (idx
<> -1) and (Result
= Skip
) and (a
> 0) do
1513 Result
:= ids
[Random(Length(ids
))];
1518 function GetRandomSpectMode(Current
: Byte): Byte;
1525 0: Result
:= SPECT_STATS
;
1526 1: Result
:= SPECT_MAPVIEW
;
1527 2: Result
:= SPECT_MAPVIEW
;
1528 3: Result
:= SPECT_PLAYERS
;
1529 4: Result
:= SPECT_PLAYERS
;
1530 5: Result
:= SPECT_PLAYERS
;
1531 6: Result
:= SPECT_PLAYERS
;
1533 if (Current
in [SPECT_STATS
, SPECT_MAPVIEW
]) and (Current
= Result
) then
1537 procedure ProcessPlayerControls (plr
: TPlayer
; p
: Integer; var MoveButton
: Byte);
1543 if (plr
= nil) then exit
;
1544 if (p
= 2) then time
:= 1000 else time
:= 1;
1545 strafeDir
:= MoveButton
shr 4;
1546 MoveButton
:= MoveButton
and $0F;
1548 if gPlayerAction
[p
, ACTION_MOVELEFT
] and (not gPlayerAction
[p
, ACTION_MOVERIGHT
]) then
1549 MoveButton
:= 1 // Íàæàòà òîëüêî "Âëåâî"
1550 else if (not gPlayerAction
[p
, ACTION_MOVELEFT
]) and gPlayerAction
[p
, ACTION_MOVERIGHT
] then
1551 MoveButton
:= 2 // Íàæàòà òîëüêî "Âïðàâî"
1552 else if (not gPlayerAction
[p
, ACTION_MOVELEFT
]) and (not gPlayerAction
[p
, ACTION_MOVERIGHT
]) then
1553 MoveButton
:= 0; // Íå íàæàòû íè "Âëåâî", íè "Âïðàâî"
1555 // Ñåé÷àñ èëè ðàíüøå áûëè íàæàòû "Âëåâî"/"Âïðàâî" => ïåðåäàåì èãðîêó:
1556 if MoveButton
= 1 then
1557 plr
.PressKey(KEY_LEFT
, time
)
1558 else if MoveButton
= 2 then
1559 plr
.PressKey(KEY_RIGHT
, time
);
1561 // if we have "strafe" key, turn off old strafe mechanics
1562 if gPlayerAction
[p
, ACTION_STRAFE
] then
1564 // new strafe mechanics
1565 if (strafeDir
= 0) then
1566 strafeDir
:= MoveButton
; // start strafing
1567 // now set direction according to strafe (reversed)
1568 if (strafeDir
= 2) then
1569 plr
.SetDirection(TDirection
.D_LEFT
)
1570 else if (strafeDir
= 1) then
1571 plr
.SetDirection(TDirection
.D_RIGHT
)
1575 strafeDir
:= 0; // not strafing anymore
1576 // Ðàíüøå áûëà íàæàòà "Âïðàâî", à ñåé÷àñ "Âëåâî" => áåæèì âïðàâî, ñìîòðèì âëåâî:
1577 if (MoveButton
= 2) and gPlayerAction
[p
, ACTION_MOVELEFT
] then
1578 plr
.SetDirection(TDirection
.D_LEFT
)
1579 // Ðàíüøå áûëà íàæàòà "Âëåâî", à ñåé÷àñ "Âïðàâî" => áåæèì âëåâî, ñìîòðèì âïðàâî:
1580 else if (MoveButton
= 1) and gPlayerAction
[p
, ACTION_MOVERIGHT
] then
1581 plr
.SetDirection(TDirection
.D_RIGHT
)
1582 // ×òî-òî áûëî íàæàòî è íå èçìåíèëîñü => êóäà áåæèì, òóäà è ñìîòðèì:
1583 else if MoveButton
<> 0 then
1584 plr
.SetDirection(TDirection(MoveButton
-1))
1587 // fix movebutton state
1588 MoveButton
:= MoveButton
or (strafeDir
shl 4);
1590 // Îñòàëüíûå êëàâèøè:
1591 if gPlayerAction
[p
, ACTION_JUMP
] then plr
.PressKey(KEY_JUMP
, time
);
1592 if gPlayerAction
[p
, ACTION_LOOKUP
] then plr
.PressKey(KEY_UP
, time
);
1593 if gPlayerAction
[p
, ACTION_LOOKDOWN
] then plr
.PressKey(KEY_DOWN
, time
);
1594 if gPlayerAction
[p
, ACTION_ATTACK
] then plr
.PressKey(KEY_FIRE
);
1595 if gPlayerAction
[p
, ACTION_WEAPNEXT
] then plr
.PressKey(KEY_NEXTWEAPON
);
1596 if gPlayerAction
[p
, ACTION_WEAPPREV
] then plr
.PressKey(KEY_PREVWEAPON
);
1597 if gPlayerAction
[p
, ACTION_ACTIVATE
] then plr
.PressKey(KEY_OPEN
);
1599 gPlayerAction
[p
, ACTION_WEAPNEXT
] := False; // HACK, remove after readyweaon&pendinweapon implementation
1600 gPlayerAction
[p
, ACTION_WEAPPREV
] := False; // HACK, remove after readyweaon&pendinweapon implementation
1602 for i
:= WP_FIRST
to WP_LAST
do
1604 if gSelectWeapon
[p
, i
] then
1606 plr
.QueueWeaponSwitch(i
); // all choices are passed there, and god will take the best
1607 gSelectWeapon
[p
, i
] := False
1611 // HACK: add dynlight here
1612 if gwin_k8_enable_light_experiments
then
1614 if e_KeyPressed(IK_F8
) and gGameOn
and (not gConsoleShow
) and (g_ActiveWindow
= nil) then
1616 g_playerLight
:= true;
1618 if e_KeyPressed(IK_F9
) and gGameOn
and (not gConsoleShow
) and (g_ActiveWindow
= nil) then
1620 g_playerLight
:= false;
1624 if gwin_has_stencil
and g_playerLight
then g_AddDynLight(plr
.GameX
+32, plr
.GameY
+40, 128, 1, 1, 0, 0.6);
1627 // HACK: don't have a "key was pressed" function
1628 procedure InterReady();
1630 if InterReadyTime
> gTime
then Exit
;
1631 InterReadyTime
:= gTime
+ 3000;
1632 MC_SEND_CheatRequest(NET_CHEAT_READY
);
1635 procedure g_Game_Update();
1637 Msg
: g_gui
.TMessage
;
1643 function sendMonsPos (mon
: TMonster
): Boolean;
1645 result
:= false; // don't stop
1646 // this will also reset "need-send" flag
1647 if mon
.gncNeedSend
then
1649 MH_SEND_MonsterPos(mon
.UID
);
1651 else if (mon
.MonsterType
= MONSTER_BARREL
) then
1653 if (mon
.GameVelX
<> 0) or (mon
.GameVelY
<> 0) then MH_SEND_MonsterPos(mon
.UID
);
1655 else if (mon
.MonsterState
<> MONSTATE_SLEEP
) then
1657 if (mon
.MonsterState
<> MONSTATE_DEAD
) or (mon
.GameVelX
<> 0) or (mon
.GameVelY
<> 0) then MH_SEND_MonsterPos(mon
.UID
);
1661 function sendMonsPosUnexpected (mon
: TMonster
): Boolean;
1663 result
:= false; // don't stop
1664 // this will also reset "need-send" flag
1665 if mon
.gncNeedSend
then MH_SEND_MonsterPos(mon
.UID
);
1669 reliableUpdate
: Boolean;
1674 // Ïîðà âûêëþ÷àòü èãðó:
1675 if gExit
= EXIT_QUIT
then
1677 // Èãðà çàêîí÷èëàñü - îáðàáàòûâàåì:
1681 if gExit
= EXIT_QUIT
then
1685 // ×èòàåì êëàâèàòóðó è äæîéñòèê, åñëè îêíî àêòèâíî
1686 // no need to, as we'll do it in event handler
1688 // Îáíîâëÿåì êîíñîëü (äâèæåíèå è ñîîáùåíèÿ):
1691 if (NetMode
= NET_NONE
) and (g_Game_IsNet
) and (gGameOn
or (gState
in [STATE_FOLD
, STATE_INTERCUSTOM
])) then
1693 gExit
:= EXIT_SIMPLE
;
1698 // process master server communications
1699 g_Net_Slist_Pulse();
1702 STATE_INTERSINGLE
, // Ñòàòèñòêà ïîñëå ïðîõîæäåíèÿ óðîâíÿ â Îäèíî÷íîé èãðå
1703 STATE_INTERCUSTOM
, // Ñòàòèñòêà ïîñëå ïðîõîæäåíèÿ óðîâíÿ â Ñâîåé èãðå
1704 STATE_INTERTEXT
, // Òåêñò ìåæäó óðîâíÿìè
1705 STATE_INTERPIC
: // Êàðòèíêà ìåæäó óðîâíÿìè
1707 if g_Game_IsNet
and g_Game_IsServer
then
1709 gInterTime
:= gInterTime
+ GAME_TICK
;
1710 a
:= Min((gInterEndTime
- gInterTime
) div 1000 + 1, 255);
1711 if a
<> gServInterTime
then
1713 gServInterTime
:= a
;
1714 MH_SEND_TimeSync(gServInterTime
);
1718 if (not g_Game_IsClient
) and
1722 e_KeyPressed(IK_RETURN
) or e_KeyPressed(IK_KPRETURN
) or e_KeyPressed(IK_SPACE
) or
1723 e_KeyPressed(VK_FIRE
) or e_KeyPressed(VK_OPEN
) or
1724 e_KeyPressed(JOY0_ATTACK
) or e_KeyPressed(JOY1_ATTACK
) or
1725 e_KeyPressed(JOY2_ATTACK
) or e_KeyPressed(JOY3_ATTACK
)
1727 and (not gJustChatted
) and (not gConsoleShow
) and (not gChatShow
)
1728 and (g_ActiveWindow
= nil)
1730 or (g_Game_IsNet
and ((gInterTime
> gInterEndTime
) or (gInterReadyCount
>= NetClientCount
)))
1733 begin // Íàæàëè <Enter>/<Ïðîáåë> èëè ïðîøëî äîñòàòî÷íî âðåìåíè:
1734 g_Game_StopAllSounds(True);
1736 if gMapOnce
then // Ýòî áûë òåñò
1737 gExit
:= EXIT_SIMPLE
1739 if gNextMap
<> '' then // Ïåðåõîäèì íà ñëåäóþùóþ êàðòó
1740 g_Game_ChangeMap(gNextMap
)
1741 else // Ñëåäóþùåé êàðòû íåò
1743 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
] then
1745 // Âûõîä â ãëàâíîå ìåíþ:
1747 g_GUI_ShowWindow('MainMenu');
1748 gMusic
.SetByName('MUSIC_MENU');
1750 gState
:= STATE_MENU
;
1753 // Ôèíàëüíàÿ êàðòèíêà:
1754 g_Game_ExecuteEvent('onwadend');
1756 if not gMusic
.SetByName('MUSIC_endmus') then
1757 gMusic
.SetByName('MUSIC_STDENDMUS');
1759 gState
:= STATE_ENDPIC
;
1761 g_Game_ExecuteEvent('ongameend');
1766 else if g_Game_IsClient
and
1769 e_KeyPressed(IK_RETURN
) or e_KeyPressed(IK_KPRETURN
) or e_KeyPressed(IK_SPACE
) or
1770 e_KeyPressed(VK_FIRE
) or e_KeyPressed(VK_OPEN
) or
1771 e_KeyPressed(JOY0_ATTACK
) or e_KeyPressed(JOY1_ATTACK
) or
1772 e_KeyPressed(JOY2_ATTACK
) or e_KeyPressed(JOY3_ATTACK
)
1774 and (not gJustChatted
) and (not gConsoleShow
) and (not gChatShow
)
1775 and (g_ActiveWindow
= nil)
1783 if gState
= STATE_INTERTEXT
then
1784 if InterText
.counter
> 0 then
1785 InterText
.counter
:= InterText
.counter
- 1;
1788 STATE_FOLD
: // Çàòóõàíèå ýêðàíà
1790 if EndingGameCounter
= 0 then
1792 // Çàêîí÷èëñÿ óðîâåíü â Ñâîåé èãðå:
1793 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
1795 InterReadyTime
:= -1;
1796 if gLastMap
and (gGameSettings
.GameMode
= GM_COOP
) then
1798 g_Game_ExecuteEvent('onwadend');
1799 if not gMusic
.SetByName('MUSIC_endmus') then
1800 gMusic
.SetByName('MUSIC_STDENDMUS');
1803 gMusic
.SetByName('MUSIC_ROUNDMUS');
1806 gState
:= STATE_INTERCUSTOM
;
1809 else // Çàêîí÷èëàñü ïîñëåäíÿÿ êàðòà â Îäèíî÷íîé èãðå
1811 gMusic
.SetByName('MUSIC_INTERMUS');
1813 gState
:= STATE_INTERSINGLE
;
1816 g_Game_ExecuteEvent('oninter');
1819 DecMin(EndingGameCounter
, 6, 0);
1822 STATE_ENDPIC
: // Êàðòèíêà îêîí÷àíèÿ ìåãàÂàäà
1824 if gMapOnce
then // Ýòî áûë òåñò
1826 gExit
:= EXIT_SIMPLE
;
1832 g_Serverlist_Control(slCurrent
, slTable
);
1835 // Ñòàòèñòèêà ïî Tab:
1837 IsDrawStat
:= (not gConsoleShow
) and (not gChatShow
) and (gGameSettings
.GameType
<> GT_SINGLE
) and g_Console_Action(ACTION_SCORES
);
1840 if gGameOn
and not gPause
and (gState
<> STATE_FOLD
) then
1842 // Âðåìÿ += 28 ìèëëèñåêóíä:
1843 gTime
:= gTime
+ GAME_TICK
;
1845 // Ñîîáùåíèå ïîñåðåäèíå ýêðàíà:
1846 if MessageTime
= 0 then
1848 if MessageTime
> 0 then
1849 MessageTime
:= MessageTime
- 1;
1851 if (g_Game_IsServer
) then
1853 // Áûë çàäàí ëèìèò âðåìåíè:
1854 if (gGameSettings
.TimeLimit
> 0) then
1855 if (gTime
- gGameStartTime
) div 1000 >= gGameSettings
.TimeLimit
then
1856 begin // Îí ïðîøåë => êîíåö óðîâíÿ
1861 // Íàäî ðåñïàâíèòü èãðîêîâ â LMS:
1862 if (gLMSRespawn
> LMS_RESPAWN_NONE
) and (gLMSRespawnTime
< gTime
) then
1863 g_Game_RestartRound(gLMSSoftSpawn
);
1865 // Ïðîâåðèì ðåçóëüòàò ãîëîñîâàíèÿ, åñëè âðåìÿ ïðîøëî
1866 if gVoteInProgress
and (gVoteTimer
< gTime
) then
1868 else if gVotePassed
and (gVoteCmdTimer
< gTime
) then
1870 g_Console_Process(gVoteCommand
);
1872 gVotePassed
:= False;
1875 // Çàìåðÿåì âðåìÿ çàõâàòà ôëàãîâ
1876 if gFlags
[FLAG_RED
].State
= FLAG_STATE_CAPTURED
then
1877 gFlags
[FLAG_RED
].CaptureTime
:= gFlags
[FLAG_RED
].CaptureTime
+ GAME_TICK
;
1878 if gFlags
[FLAG_BLUE
].State
= FLAG_STATE_CAPTURED
then
1879 gFlags
[FLAG_BLUE
].CaptureTime
:= gFlags
[FLAG_BLUE
].CaptureTime
+ GAME_TICK
;
1881 // Áûë çàäàí ëèìèò ïîáåä:
1882 if (gGameSettings
.GoalLimit
> 0) then
1886 if gGameSettings
.GameMode
= GM_DM
then
1887 begin // Â DM èùåì èãðîêà ñ max ôðàãàìè
1888 for i
:= 0 to High(gPlayers
) do
1889 if gPlayers
[i
] <> nil then
1890 if gPlayers
[i
].Frags
> b
then
1891 b
:= gPlayers
[i
].Frags
;
1894 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
1895 begin //  CTF/TDM âûáèðàåì êîìàíäó ñ íàèáîëüøèì ñ÷åòîì
1896 b
:= Max(gTeamStat
[TEAM_RED
].Goals
, gTeamStat
[TEAM_BLUE
].Goals
);
1899 // Ëèìèò ïîáåä íàáðàí => êîíåö óðîâíÿ:
1900 if b
>= gGameSettings
.GoalLimit
then
1907 // Îáðàáàòûâàåì êëàâèøè èãðîêîâ:
1908 if gPlayer1
<> nil then gPlayer1
.ReleaseKeys();
1909 if gPlayer2
<> nil then gPlayer2
.ReleaseKeys();
1910 if (not gConsoleShow
) and (not gChatShow
) and (g_ActiveWindow
= nil) then
1912 ProcessPlayerControls(gPlayer1
, 0, P1MoveButton
);
1913 ProcessPlayerControls(gPlayer2
, 1, P2MoveButton
);
1914 end // if not console
1917 if g_Game_IsNet
and (gPlayer1
<> nil) then gPlayer1
.PressKey(KEY_CHAT
, 10000);
1919 // process weapon switch queue
1923 if (gPlayer1
= nil) and (gPlayer2
= nil) and
1924 (not gConsoleShow
) and (not gChatShow
) and (g_ActiveWindow
= nil) then
1926 if not gSpectKeyPress
then
1928 if gPlayerAction
[0, ACTION_JUMP
] and (not gSpectAuto
) then
1930 // switch spect mode
1932 SPECT_NONE
: ; // not spectator
1934 SPECT_MAPVIEW
: Inc(gSpectMode
);
1935 SPECT_PLAYERS
: gSpectMode
:= SPECT_STATS
; // reset to 1
1937 gSpectKeyPress
:= True;
1939 if (gSpectMode
= SPECT_MAPVIEW
)
1940 and (not gSpectAuto
) then
1942 if gPlayerAction
[0, ACTION_MOVELEFT
] then
1943 gSpectX
:= Max(gSpectX
- gSpectStep
, 0);
1944 if gPlayerAction
[0, ACTION_MOVERIGHT
] then
1945 gSpectX
:= Min(gSpectX
+ gSpectStep
, gMapInfo
.Width
- gScreenWidth
);
1946 if gPlayerAction
[0, ACTION_LOOKUP
] then
1947 gSpectY
:= Max(gSpectY
- gSpectStep
, 0);
1948 if gPlayerAction
[0, ACTION_LOOKDOWN
] then
1949 gSpectY
:= Min(gSpectY
+ gSpectStep
, gMapInfo
.Height
- gScreenHeight
);
1950 if gPlayerAction
[0, ACTION_WEAPPREV
] then
1953 if gSpectStep
> 4 then gSpectStep
:= gSpectStep
shr 1;
1954 gSpectKeyPress
:= True;
1956 if gPlayerAction
[0, ACTION_WEAPNEXT
] then
1959 if gSpectStep
< 64 then gSpectStep
:= gSpectStep
shl 1;
1960 gSpectKeyPress
:= True;
1963 if (gSpectMode
= SPECT_PLAYERS
)
1964 and (not gSpectAuto
) then
1966 if gPlayerAction
[0, ACTION_LOOKUP
] then
1969 gSpectViewTwo
:= True;
1970 gSpectKeyPress
:= True;
1972 if gPlayerAction
[0, ACTION_LOOKDOWN
] then
1974 // remove second view
1975 gSpectViewTwo
:= False;
1976 gSpectKeyPress
:= True;
1978 if gPlayerAction
[0, ACTION_MOVELEFT
] then
1980 // prev player (view 1)
1981 gSpectPID1
:= GetActivePlayerID_Prev(gSpectPID1
);
1982 gSpectKeyPress
:= True;
1984 if gPlayerAction
[0, ACTION_MOVERIGHT
] then
1986 // next player (view 1)
1987 gSpectPID1
:= GetActivePlayerID_Next(gSpectPID1
);
1988 gSpectKeyPress
:= True;
1990 if gPlayerAction
[0, ACTION_WEAPPREV
] then
1992 // prev player (view 2)
1993 gSpectPID2
:= GetActivePlayerID_Prev(gSpectPID2
);
1994 gSpectKeyPress
:= True;
1996 if gPlayerAction
[0, ACTION_WEAPNEXT
] then
1998 // next player (view 2)
1999 gSpectPID2
:= GetActivePlayerID_Next(gSpectPID2
);
2000 gSpectKeyPress
:= True;
2003 if gPlayerAction
[0, ACTION_ATTACK
] then
2005 if (gSpectMode
= SPECT_STATS
) and (not gSpectAuto
) then
2008 gSpectAutoNext
:= 0;
2009 gSpectViewTwo
:= False;
2010 gSpectKeyPress
:= True;
2015 gSpectMode
:= SPECT_STATS
;
2016 gSpectAuto
:= False;
2017 gSpectKeyPress
:= True;
2022 if (not gPlayerAction
[0, ACTION_JUMP
]) and
2023 (not gPlayerAction
[0, ACTION_ATTACK
]) and
2024 (not gPlayerAction
[0, ACTION_MOVELEFT
]) and
2025 (not gPlayerAction
[0, ACTION_MOVERIGHT
]) and
2026 (not gPlayerAction
[0, ACTION_LOOKUP
]) and
2027 (not gPlayerAction
[0, ACTION_LOOKDOWN
]) and
2028 (not gPlayerAction
[0, ACTION_WEAPPREV
]) and
2029 (not gPlayerAction
[0, ACTION_WEAPNEXT
]) then
2030 gSpectKeyPress
:= False;
2034 if gSpectMode
= SPECT_MAPVIEW
then
2036 i
:= Min(Max(gSpectX
+ gSpectAutoStepX
, 0), gMapInfo
.Width
- gScreenWidth
);
2038 gSpectAutoNext
:= gTime
2041 i
:= Min(Max(gSpectY
+ gSpectAutoStepY
, 0), gMapInfo
.Height
- gScreenHeight
);
2043 gSpectAutoNext
:= gTime
2047 if gSpectAutoNext
<= gTime
then
2049 if gSpectAutoNext
> 0 then
2051 gSpectMode
:= GetRandomSpectMode(gSpectMode
);
2055 gSpectX
:= Random(gMapInfo
.Width
- gScreenWidth
);
2056 gSpectY
:= Random(gMapInfo
.Height
- gScreenHeight
);
2057 gSpectAutoStepX
:= Random(9) - 4;
2058 gSpectAutoStepY
:= Random(9) - 4;
2059 if ((gSpectX
< 800) and (gSpectAutoStepX
< 0)) or
2060 ((gSpectX
> gMapInfo
.Width
- gScreenWidth
- 800) and (gSpectAutoStepX
> 0)) then
2061 gSpectAutoStepX
:= gSpectAutoStepX
* -1;
2062 if ((gSpectY
< 800) and (gSpectAutoStepY
< 0)) or
2063 ((gSpectY
> gMapInfo
.Height
- gScreenHeight
- 800) and (gSpectAutoStepY
> 0)) then
2064 gSpectAutoStepY
:= gSpectAutoStepY
* -1;
2068 gSpectPID1
:= GetActivePlayerID_Random(gSpectPID1
);
2073 SPECT_STATS
: gSpectAutoNext
:= gTime
+ (Random(3) + 5) * 1000;
2074 SPECT_MAPVIEW
: gSpectAutoNext
:= gTime
+ (Random(4) + 7) * 1000;
2075 SPECT_PLAYERS
: gSpectAutoNext
:= gTime
+ (Random(7) + 8) * 1000;
2081 // Îáíîâëÿåì âñå îñòàëüíîå:
2084 g_Triggers_Update();
2086 g_Monsters_Update();
2088 g_Player_UpdateAll();
2089 g_Player_UpdatePhysicalObjects();
2091 // server: send newly spawned monsters unconditionally
2092 if (gGameSettings
.GameType
= GT_SERVER
) then
2094 if (Length(gMonstersSpawned
) > 0) then
2096 for I
:= 0 to High(gMonstersSpawned
) do MH_SEND_MonsterSpawn(gMonstersSpawned
[I
]);
2097 SetLength(gMonstersSpawned
, 0);
2101 if (gSoundTriggerTime
> 8) then
2103 g_Game_UpdateTriggerSounds();
2104 gSoundTriggerTime
:= 0;
2108 Inc(gSoundTriggerTime
);
2111 if (NetMode
= NET_SERVER
) then
2113 Inc(NetTimeToUpdate
);
2114 Inc(NetTimeToReliable
);
2116 // send monster updates
2117 if (NetTimeToReliable
>= NetRelupdRate
) or (NetTimeToUpdate
>= NetUpdateRate
) then
2119 // send all monsters (periodic sync)
2120 reliableUpdate
:= (NetTimeToReliable
>= NetRelupdRate
);
2122 for I
:= 0 to High(gPlayers
) do
2124 if (gPlayers
[I
] <> nil) then MH_SEND_PlayerPos(reliableUpdate
, gPlayers
[I
].UID
);
2127 g_Mons_ForEach(sendMonsPos
);
2129 if reliableUpdate
then
2131 NetTimeToReliable
:= 0;
2132 NetTimeToUpdate
:= NetUpdateRate
;
2136 NetTimeToUpdate
:= 0;
2141 // send only mosters with some unexpected changes
2142 g_Mons_ForEach(sendMonsPosUnexpected
);
2145 // send unexpected platform changes
2146 g_Map_NetSendInterestingPanels();
2148 g_Net_Slist_ServerUpdate();
2150 if NetUseMaster then
2152 if (gTime >= NetTimeToMaster) or g_Net_Slist_IsConnectionInProgress then
2154 if (not g_Net_Slist_IsConnectionActive) then g_Net_Slist_Connect(false); // non-blocking connection to the master
2156 NetTimeToMaster := gTime + NetMasterRate;
2161 else if (NetMode
= NET_CLIENT
) then
2163 MC_SEND_PlayerPos();
2165 end; // if gameOn ...
2167 // Àêòèâíî îêíî èíòåðôåéñà - ïåðåäàåì êëàâèøè åìó:
2168 if g_ActiveWindow
<> nil then
2170 w
:= e_GetFirstKeyPressed();
2172 if (w
<> IK_INVALID
) then
2174 Msg
.Msg
:= MESSAGE_DIKEY
;
2176 g_ActiveWindow
.OnMessage(Msg
);
2179 // Åñëè îíî îò ýòîãî íå çàêðûëîñü, òî îáíîâëÿåì:
2180 if g_ActiveWindow
<> nil then
2181 g_ActiveWindow
.Update();
2183 // Íóæíî ñìåíèòü ðàçðåøåíèå:
2184 if gResolutionChange
then
2186 e_WriteLog('Changing resolution', TMsgType
.Notify
);
2187 g_Game_ChangeResolution(gRC_Width
, gRC_Height
, gRC_FullScreen
, gRC_Maximized
);
2188 gResolutionChange
:= False;
2189 g_ActiveWindow
:= nil;
2192 // Íóæíî ñìåíèòü ÿçûê:
2193 if gLanguageChange
then
2195 //e_WriteLog('Read language file', MSG_NOTIFY);
2196 //g_Language_Load(DataDir + gLanguage + '.txt');
2197 g_Language_Set(gLanguage
);
2201 gLanguageChange
:= False;
2205 // Ãîðÿ÷àÿ êëàâèøà äëÿ âûçîâà ìåíþ âûõîäà èç èãðû (F10):
2206 if e_KeyPressed(IK_F10
) and
2208 (not gConsoleShow
) and
2209 (g_ActiveWindow
= nil) then
2214 Time
:= sys_GetTicks() {div 1000};
2216 // Îáðàáîòêà îòëîæåííûõ ñîáûòèé:
2217 if gDelayedEvents
<> nil then
2218 for a
:= 0 to High(gDelayedEvents
) do
2219 if gDelayedEvents
[a
].Pending
and
2221 ((gDelayedEvents
[a
].DEType
= DE_GLOBEVENT
) and (gDelayedEvents
[a
].Time
<= Time
)) or
2222 ((gDelayedEvents
[a
].DEType
> DE_GLOBEVENT
) and (gDelayedEvents
[a
].Time
<= gTime
))
2225 case gDelayedEvents
[a
].DEType
of
2227 g_Game_ExecuteEvent(gDelayedEvents
[a
].DEStr
);
2230 g_Game_Announce_GoodShot(gDelayedEvents
[a
].DENum
);
2234 g_Game_Announce_KillCombo(gDelayedEvents
[a
].DENum
);
2235 if g_Game_IsNet
and g_Game_IsServer
then
2236 MH_SEND_GameEvent(NET_EV_KILLCOMBO
, gDelayedEvents
[a
].DENum
);
2240 g_Game_Announce_BodyKill(gDelayedEvents
[a
].DENum
);
2242 gDelayedEvents
[a
].Pending
:= False;
2245 // Êàæäóþ ñåêóíäó îáíîâëÿåì ñ÷åò÷èê îáíîâëåíèé:
2246 UPSCounter
:= UPSCounter
+ 1;
2247 if Time
- UPSTime
>= 1000 then
2256 g_Weapon_AddDynLights();
2257 g_Items_AddDynLights();
2261 procedure g_Game_LoadChatSounds(Resource
: string);
2264 FileName
, Snd
: string;
2266 len
, cnt
, tags
, i
, j
: Integer;
2269 FileName
:= g_ExtractWadName(Resource
);
2271 WAD
:= TWADFile
.Create();
2272 WAD
.ReadFile(FileName
);
2274 if not WAD
.GetResource(g_ExtractFilePathName(Resource
), p
, len
) then
2281 cfg
:= TConfig
.CreateMem(p
, len
);
2282 cnt
:= cfg
.ReadInt('ChatSounds', 'Count', 0);
2284 SetLength(gChatSounds
, cnt
);
2285 for i
:= 0 to Length(gChatSounds
) - 1 do
2287 gChatSounds
[i
].Sound
:= nil;
2288 Snd
:= Trim(cfg
.ReadStr(IntToStr(i
), 'Sound', ''));
2289 tags
:= cfg
.ReadInt(IntToStr(i
), 'Tags', 0);
2290 if (Snd
= '') or (Tags
<= 0) then
2292 g_Sound_CreateWADEx('SOUND_CHAT_MACRO' + IntToStr(i
), GameWAD
+':'+Snd
);
2293 gChatSounds
[i
].Sound
:= TPlayableSound
.Create();
2294 gChatSounds
[i
].Sound
.SetByName('SOUND_CHAT_MACRO' + IntToStr(i
));
2295 SetLength(gChatSounds
[i
].Tags
, tags
);
2296 for j
:= 0 to tags
- 1 do
2297 gChatSounds
[i
].Tags
[j
] := toLowerCase1251(cfg
.ReadStr(IntToStr(i
), 'Tag' + IntToStr(j
), ''));
2298 gChatSounds
[i
].FullWord
:= cfg
.ReadBool(IntToStr(i
), 'FullWord', False);
2305 procedure g_Game_FreeChatSounds();
2309 for i
:= 0 to Length(gChatSounds
) - 1 do
2311 gChatSounds
[i
].Sound
.Free();
2312 g_Sound_Delete('SOUND_CHAT_MACRO' + IntToStr(i
));
2314 SetLength(gChatSounds
, 0);
2318 procedure g_Game_LoadData();
2325 if DataLoaded
then Exit
;
2327 e_WriteLog('Loading game data...', TMsgType
.Notify
);
2329 g_Texture_CreateWADEx('NOTEXTURE', GameWAD
+':TEXTURES\NOTEXTURE');
2330 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUD', GameWAD
+':TEXTURES\HUD');
2331 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDAIR', GameWAD
+':TEXTURES\AIRBAR');
2332 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDJET', GameWAD
+':TEXTURES\JETBAR');
2333 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDBG', GameWAD
+':TEXTURES\HUDBG');
2334 g_Texture_CreateWADEx('TEXTURE_PLAYER_ARMORHUD', GameWAD
+':TEXTURES\ARMORHUD');
2335 g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG', GameWAD
+':TEXTURES\FLAGHUD_R_BASE');
2336 g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG_S', GameWAD
+':TEXTURES\FLAGHUD_R_STOLEN');
2337 g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG_D', GameWAD
+':TEXTURES\FLAGHUD_R_DROP');
2338 g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG', GameWAD
+':TEXTURES\FLAGHUD_B_BASE');
2339 g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG_S', GameWAD
+':TEXTURES\FLAGHUD_B_STOLEN');
2340 g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG_D', GameWAD
+':TEXTURES\FLAGHUD_B_DROP');
2341 g_Texture_CreateWADEx('TEXTURE_PLAYER_TALKBUBBLE', GameWAD
+':TEXTURES\TALKBUBBLE');
2342 g_Texture_CreateWADEx('TEXTURE_PLAYER_INVULPENTA', GameWAD
+':TEXTURES\PENTA');
2343 g_Texture_CreateWADEx('TEXTURE_PLAYER_INDICATOR', GameWAD
+':TEXTURES\PLRIND');
2346 if not g_Texture_CreateWADEx('UI_GFX_PBAR_LEFT', GameWAD
+':TEXTURES\LLEFT') then hasPBarGfx
:= false;
2347 if not g_Texture_CreateWADEx('UI_GFX_PBAR_MARKER', GameWAD
+':TEXTURES\LMARKER') then hasPBarGfx
:= false;
2348 if not g_Texture_CreateWADEx('UI_GFX_PBAR_MIDDLE', GameWAD
+':TEXTURES\LMIDDLE') then hasPBarGfx
:= false;
2349 if not g_Texture_CreateWADEx('UI_GFX_PBAR_RIGHT', GameWAD
+':TEXTURES\LRIGHT') then hasPBarGfx
:= false;
2353 g_Texture_GetSize('UI_GFX_PBAR_LEFT', wl
, hl
);
2354 g_Texture_GetSize('UI_GFX_PBAR_RIGHT', wr
, hr
);
2355 g_Texture_GetSize('UI_GFX_PBAR_MIDDLE', wb
, hb
);
2356 g_Texture_GetSize('UI_GFX_PBAR_MARKER', wm
, hm
);
2357 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
2363 hasPBarGfx
:= false;
2367 g_Frames_CreateWAD(nil, 'FRAMES_TELEPORT', GameWAD
+':TEXTURES\TELEPORT', 64, 64, 10, False);
2368 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH', GameWAD
+':WEAPONS\PUNCH', 64, 64, 4, False);
2369 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_UP', GameWAD
+':WEAPONS\PUNCH_UP', 64, 64, 4, False);
2370 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_DN', GameWAD
+':WEAPONS\PUNCH_DN', 64, 64, 4, False);
2371 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_BERSERK', GameWAD
+':WEAPONS\PUNCHB', 64, 64, 4, False);
2372 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_BERSERK_UP', GameWAD
+':WEAPONS\PUNCHB_UP', 64, 64, 4, False);
2373 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_BERSERK_DN', GameWAD
+':WEAPONS\PUNCHB_DN', 64, 64, 4, False);
2374 g_Sound_CreateWADEx('SOUND_GAME_TELEPORT', GameWAD
+':SOUNDS\TELEPORT');
2375 g_Sound_CreateWADEx('SOUND_GAME_NOTELEPORT', GameWAD
+':SOUNDS\NOTELEPORT');
2376 g_Sound_CreateWADEx('SOUND_GAME_SECRET', GameWAD
+':SOUNDS\SECRET');
2377 g_Sound_CreateWADEx('SOUND_GAME_DOOROPEN', GameWAD
+':SOUNDS\DOOROPEN');
2378 g_Sound_CreateWADEx('SOUND_GAME_DOORCLOSE', GameWAD
+':SOUNDS\DOORCLOSE');
2379 g_Sound_CreateWADEx('SOUND_GAME_BULK1', GameWAD
+':SOUNDS\BULK1');
2380 g_Sound_CreateWADEx('SOUND_GAME_BULK2', GameWAD
+':SOUNDS\BULK2');
2381 g_Sound_CreateWADEx('SOUND_GAME_BUBBLE1', GameWAD
+':SOUNDS\BUBBLE1');
2382 g_Sound_CreateWADEx('SOUND_GAME_BUBBLE2', GameWAD
+':SOUNDS\BUBBLE2');
2383 g_Sound_CreateWADEx('SOUND_GAME_BURNING', GameWAD
+':SOUNDS\BURNING');
2384 g_Sound_CreateWADEx('SOUND_GAME_SWITCH1', GameWAD
+':SOUNDS\SWITCH1');
2385 g_Sound_CreateWADEx('SOUND_GAME_SWITCH0', GameWAD
+':SOUNDS\SWITCH0');
2386 g_Sound_CreateWADEx('SOUND_GAME_RADIO', GameWAD
+':SOUNDS\RADIO');
2387 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD1', GameWAD
+':SOUNDS\GOOD1');
2388 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD2', GameWAD
+':SOUNDS\GOOD2');
2389 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD3', GameWAD
+':SOUNDS\GOOD3');
2390 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD4', GameWAD
+':SOUNDS\GOOD4');
2391 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL2X', GameWAD
+':SOUNDS\KILL2X');
2392 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL3X', GameWAD
+':SOUNDS\KILL3X');
2393 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL4X', GameWAD
+':SOUNDS\KILL4X');
2394 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILLMX', GameWAD
+':SOUNDS\KILLMX');
2395 g_Sound_CreateWADEx('SOUND_ANNOUNCER_MUHAHA1', GameWAD
+':SOUNDS\MUHAHA1');
2396 g_Sound_CreateWADEx('SOUND_ANNOUNCER_MUHAHA2', GameWAD
+':SOUNDS\MUHAHA2');
2397 g_Sound_CreateWADEx('SOUND_ANNOUNCER_MUHAHA3', GameWAD
+':SOUNDS\MUHAHA3');
2398 g_Sound_CreateWADEx('SOUND_CTF_GET1', GameWAD
+':SOUNDS\GETFLAG1');
2399 g_Sound_CreateWADEx('SOUND_CTF_GET2', GameWAD
+':SOUNDS\GETFLAG2');
2400 g_Sound_CreateWADEx('SOUND_CTF_LOST1', GameWAD
+':SOUNDS\LOSTFLG1');
2401 g_Sound_CreateWADEx('SOUND_CTF_LOST2', GameWAD
+':SOUNDS\LOSTFLG2');
2402 g_Sound_CreateWADEx('SOUND_CTF_RETURN1', GameWAD
+':SOUNDS\RETFLAG1');
2403 g_Sound_CreateWADEx('SOUND_CTF_RETURN2', GameWAD
+':SOUNDS\RETFLAG2');
2404 g_Sound_CreateWADEx('SOUND_CTF_CAPTURE1', GameWAD
+':SOUNDS\CAPFLAG1');
2405 g_Sound_CreateWADEx('SOUND_CTF_CAPTURE2', GameWAD
+':SOUNDS\CAPFLAG2');
2407 goodsnd
[0] := TPlayableSound
.Create();
2408 goodsnd
[1] := TPlayableSound
.Create();
2409 goodsnd
[2] := TPlayableSound
.Create();
2410 goodsnd
[3] := TPlayableSound
.Create();
2412 goodsnd
[0].SetByName('SOUND_ANNOUNCER_GOOD1');
2413 goodsnd
[1].SetByName('SOUND_ANNOUNCER_GOOD2');
2414 goodsnd
[2].SetByName('SOUND_ANNOUNCER_GOOD3');
2415 goodsnd
[3].SetByName('SOUND_ANNOUNCER_GOOD4');
2417 killsnd
[0] := TPlayableSound
.Create();
2418 killsnd
[1] := TPlayableSound
.Create();
2419 killsnd
[2] := TPlayableSound
.Create();
2420 killsnd
[3] := TPlayableSound
.Create();
2422 killsnd
[0].SetByName('SOUND_ANNOUNCER_KILL2X');
2423 killsnd
[1].SetByName('SOUND_ANNOUNCER_KILL3X');
2424 killsnd
[2].SetByName('SOUND_ANNOUNCER_KILL4X');
2425 killsnd
[3].SetByName('SOUND_ANNOUNCER_KILLMX');
2427 hahasnd
[0] := TPlayableSound
.Create();
2428 hahasnd
[1] := TPlayableSound
.Create();
2429 hahasnd
[2] := TPlayableSound
.Create();
2431 hahasnd
[0].SetByName('SOUND_ANNOUNCER_MUHAHA1');
2432 hahasnd
[1].SetByName('SOUND_ANNOUNCER_MUHAHA2');
2433 hahasnd
[2].SetByName('SOUND_ANNOUNCER_MUHAHA3');
2435 sound_get_flag
[0] := TPlayableSound
.Create();
2436 sound_get_flag
[1] := TPlayableSound
.Create();
2437 sound_lost_flag
[0] := TPlayableSound
.Create();
2438 sound_lost_flag
[1] := TPlayableSound
.Create();
2439 sound_ret_flag
[0] := TPlayableSound
.Create();
2440 sound_ret_flag
[1] := TPlayableSound
.Create();
2441 sound_cap_flag
[0] := TPlayableSound
.Create();
2442 sound_cap_flag
[1] := TPlayableSound
.Create();
2444 sound_get_flag
[0].SetByName('SOUND_CTF_GET1');
2445 sound_get_flag
[1].SetByName('SOUND_CTF_GET2');
2446 sound_lost_flag
[0].SetByName('SOUND_CTF_LOST1');
2447 sound_lost_flag
[1].SetByName('SOUND_CTF_LOST2');
2448 sound_ret_flag
[0].SetByName('SOUND_CTF_RETURN1');
2449 sound_ret_flag
[1].SetByName('SOUND_CTF_RETURN2');
2450 sound_cap_flag
[0].SetByName('SOUND_CTF_CAPTURE1');
2451 sound_cap_flag
[1].SetByName('SOUND_CTF_CAPTURE2');
2453 g_Game_LoadChatSounds(GameWAD
+':CHATSND\SNDCFG');
2455 g_Game_SetLoadingText(_lc
[I_LOAD_ITEMS_DATA
], 0, False);
2458 g_Game_SetLoadingText(_lc
[I_LOAD_WEAPONS_DATA
], 0, False);
2459 g_Weapon_LoadData();
2461 g_Monsters_LoadData();
2466 procedure g_Game_FreeData();
2468 if not DataLoaded
then Exit
;
2471 g_Weapon_FreeData();
2472 g_Monsters_FreeData();
2474 e_WriteLog('Releasing game data...', TMsgType
.Notify
);
2476 g_Texture_Delete('NOTEXTURE');
2477 g_Texture_Delete('TEXTURE_PLAYER_HUD');
2478 g_Texture_Delete('TEXTURE_PLAYER_HUDBG');
2479 g_Texture_Delete('TEXTURE_PLAYER_ARMORHUD');
2480 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG');
2481 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG_S');
2482 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG_D');
2483 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG');
2484 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG_S');
2485 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG_D');
2486 g_Texture_Delete('TEXTURE_PLAYER_TALKBUBBLE');
2487 g_Texture_Delete('TEXTURE_PLAYER_INVULPENTA');
2488 g_Frames_DeleteByName('FRAMES_TELEPORT');
2489 g_Frames_DeleteByName('FRAMES_PUNCH');
2490 g_Frames_DeleteByName('FRAMES_PUNCH_UP');
2491 g_Frames_DeleteByName('FRAMES_PUNCH_DN');
2492 g_Frames_DeleteByName('FRAMES_PUNCH_BERSERK');
2493 g_Frames_DeleteByName('FRAMES_PUNCH_BERSERK_UP');
2494 g_Frames_DeleteByName('FRAMES_PUNCH_BERSERK_DN');
2495 g_Sound_Delete('SOUND_GAME_TELEPORT');
2496 g_Sound_Delete('SOUND_GAME_NOTELEPORT');
2497 g_Sound_Delete('SOUND_GAME_SECRET');
2498 g_Sound_Delete('SOUND_GAME_DOOROPEN');
2499 g_Sound_Delete('SOUND_GAME_DOORCLOSE');
2500 g_Sound_Delete('SOUND_GAME_BULK1');
2501 g_Sound_Delete('SOUND_GAME_BULK2');
2502 g_Sound_Delete('SOUND_GAME_BUBBLE1');
2503 g_Sound_Delete('SOUND_GAME_BUBBLE2');
2504 g_Sound_Delete('SOUND_GAME_BURNING');
2505 g_Sound_Delete('SOUND_GAME_SWITCH1');
2506 g_Sound_Delete('SOUND_GAME_SWITCH0');
2513 g_Sound_Delete('SOUND_ANNOUNCER_GOOD1');
2514 g_Sound_Delete('SOUND_ANNOUNCER_GOOD2');
2515 g_Sound_Delete('SOUND_ANNOUNCER_GOOD3');
2516 g_Sound_Delete('SOUND_ANNOUNCER_GOOD4');
2523 g_Sound_Delete('SOUND_ANNOUNCER_KILL2X');
2524 g_Sound_Delete('SOUND_ANNOUNCER_KILL3X');
2525 g_Sound_Delete('SOUND_ANNOUNCER_KILL4X');
2526 g_Sound_Delete('SOUND_ANNOUNCER_KILLMX');
2532 g_Sound_Delete('SOUND_ANNOUNCER_MUHAHA1');
2533 g_Sound_Delete('SOUND_ANNOUNCER_MUHAHA2');
2534 g_Sound_Delete('SOUND_ANNOUNCER_MUHAHA3');
2536 sound_get_flag
[0].Free();
2537 sound_get_flag
[1].Free();
2538 sound_lost_flag
[0].Free();
2539 sound_lost_flag
[1].Free();
2540 sound_ret_flag
[0].Free();
2541 sound_ret_flag
[1].Free();
2542 sound_cap_flag
[0].Free();
2543 sound_cap_flag
[1].Free();
2545 g_Sound_Delete('SOUND_CTF_GET1');
2546 g_Sound_Delete('SOUND_CTF_GET2');
2547 g_Sound_Delete('SOUND_CTF_LOST1');
2548 g_Sound_Delete('SOUND_CTF_LOST2');
2549 g_Sound_Delete('SOUND_CTF_RETURN1');
2550 g_Sound_Delete('SOUND_CTF_RETURN2');
2551 g_Sound_Delete('SOUND_CTF_CAPTURE1');
2552 g_Sound_Delete('SOUND_CTF_CAPTURE2');
2554 g_Game_FreeChatSounds();
2556 DataLoaded
:= False;
2559 procedure DrawCustomStat();
2565 ww2
, hh2
, r
, g
, b
, rr
, gg
, bb
: Byte;
2566 s1
, s2
, topstr
: String;
2568 e_TextureFontGetSize(gStdFont
, ww2
, hh2
);
2572 if g_Console_Action(ACTION_SCORES
) then
2574 if not gStatsPressed
then
2576 gStatsOff
:= not gStatsOff
;
2577 gStatsPressed
:= True;
2581 gStatsPressed
:= False;
2585 s1
:= _lc
[I_MENU_INTER_NOTICE_TAB
];
2586 w
:= (Length(s1
) * ww2
) div 2;
2587 x
:= gScreenWidth
div 2 - w
;
2589 e_TextureFontPrint(x
, y
, s1
, gStdFont
);
2593 if (gGameSettings
.GameMode
= GM_COOP
) then
2595 if gMissionFailed
then
2596 topstr
:= _lc
[I_MENU_INTER_MISSION_FAIL
]
2598 topstr
:= _lc
[I_MENU_INTER_LEVEL_COMPLETE
];
2601 topstr
:= _lc
[I_MENU_INTER_ROUND_OVER
];
2603 e_CharFont_GetSize(gMenuFont
, topstr
, ww1
, hh1
);
2604 e_CharFont_Print(gMenuFont
, (gScreenWidth
div 2)-(ww1
div 2), 16, topstr
);
2606 if g_Game_IsNet
then
2608 topstr
:= Format(_lc
[I_MENU_INTER_NOTICE_TIME
], [gServInterTime
]);
2609 if not gChatShow
then
2610 e_TextureFontPrintEx((gScreenWidth
div 2)-(Length(topstr
)*ww2
div 2),
2611 gScreenHeight
-(hh2
+4)*2, topstr
, gStdFont
, 255, 255, 255, 1);
2614 if g_Game_IsClient
then
2615 topstr
:= _lc
[I_MENU_INTER_NOTICE_MAP
]
2617 topstr
:= _lc
[I_MENU_INTER_NOTICE_SPACE
];
2618 if not gChatShow
then
2619 e_TextureFontPrintEx((gScreenWidth
div 2)-(Length(topstr
)*ww2
div 2),
2620 gScreenHeight
-(hh2
+4), topstr
, gStdFont
, 255, 255, 255, 1);
2625 w
:= gScreenWidth
-x
*2;
2631 e_DrawFillQuad(x
, y
, gScreenWidth
-x
-1, gScreenHeight
-y
-1, 64, 64, 64, 32);
2632 e_DrawQuad(x
, y
, gScreenWidth
-x
-1, gScreenHeight
-y
-1, 255, 127, 0);
2634 m
:= Max(Length(_lc
[I_MENU_MAP
])+1, Length(_lc
[I_GAME_GAME_TIME
])+1)*ww2
;
2636 case CustomStat
.GameMode
of
2639 if gGameSettings
.MaxLives
= 0 then
2640 s1
:= _lc
[I_GAME_DM
]
2642 s1
:= _lc
[I_GAME_LMS
];
2646 if gGameSettings
.MaxLives
= 0 then
2647 s1
:= _lc
[I_GAME_TDM
]
2649 s1
:= _lc
[I_GAME_TLMS
];
2651 GM_CTF
: s1
:= _lc
[I_GAME_CTF
];
2654 if gGameSettings
.MaxLives
= 0 then
2655 s1
:= _lc
[I_GAME_COOP
]
2657 s1
:= _lc
[I_GAME_SURV
];
2663 e_TextureFontPrintEx(x
+(w
div 2)-(Length(s1
)*ww2
div 2), _y
, s1
, gStdFont
, 255, 255, 255, 1);
2667 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_MENU_MAP
], gStdFont
, 255, 127, 0, 1);
2668 e_TextureFontPrint(x
+8+m
, _y
, Format('%s - %s', [CustomStat
.Map
, CustomStat
.MapName
]), gStdFont
);
2671 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_GAME_TIME
], gStdFont
, 255, 127, 0, 1);
2672 e_TextureFontPrint(x
+8+m
, _y
, Format('%d:%.2d:%.2d', [CustomStat
.GameTime
div 1000 div 3600,
2673 (CustomStat
.GameTime
div 1000 div 60) mod 60,
2674 CustomStat
.GameTime
div 1000 mod 60]), gStdFont
);
2676 pc
:= Length(CustomStat
.PlayerStat
);
2677 if pc
= 0 then Exit
;
2679 if CustomStat
.GameMode
= GM_COOP
then
2681 m
:= Max(Length(_lc
[I_GAME_MONSTERS
])+1, Length(_lc
[I_GAME_SECRETS
])+1)*ww2
;
2683 s2
:= _lc
[I_GAME_MONSTERS
];
2684 e_TextureFontPrintEx(x
+8, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2685 e_TextureFontPrintEx(x
+8+m
, _y
, IntToStr(gCoopMonstersKilled
) + '/' + IntToStr(gTotalMonsters
), gStdFont
, 255, 255, 255, 1);
2687 s2
:= _lc
[I_GAME_SECRETS
];
2688 e_TextureFontPrintEx(x
+8, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2689 e_TextureFontPrintEx(x
+8+m
, _y
, IntToStr(gCoopSecretsFound
) + '/' + IntToStr(gSecretsCount
), gStdFont
, 255, 255, 255, 1);
2692 m
:= Max(Length(_lc
[I_GAME_MONSTERS_TOTAL
])+1, Length(_lc
[I_GAME_SECRETS_TOTAL
])+1)*ww2
;
2694 s2
:= _lc
[I_GAME_MONSTERS_TOTAL
];
2695 e_TextureFontPrintEx(x
+250, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2696 e_TextureFontPrintEx(x
+250+m
, _y
, IntToStr(gCoopTotalMonstersKilled
) + '/' + IntToStr(gCoopTotalMonsters
), gStdFont
, 255, 255, 255, 1);
2698 s2
:= _lc
[I_GAME_SECRETS_TOTAL
];
2699 e_TextureFontPrintEx(x
+250, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2700 e_TextureFontPrintEx(x
+250+m
, _y
, IntToStr(gCoopTotalSecretsFound
) + '/' + IntToStr(gCoopTotalSecrets
), gStdFont
, 255, 255, 255, 1);
2704 if CustomStat
.GameMode
in [GM_TDM
, GM_CTF
] then
2709 if TeamStat
[TEAM_RED
].Goals
> TeamStat
[TEAM_BLUE
].Goals
then s1
:= _lc
[I_GAME_WIN_RED
]
2710 else if TeamStat
[TEAM_BLUE
].Goals
> TeamStat
[TEAM_RED
].Goals
then s1
:= _lc
[I_GAME_WIN_BLUE
]
2711 else s1
:= _lc
[I_GAME_WIN_DRAW
];
2713 e_TextureFontPrintEx(x
+8+(w
div 2)-(Length(s1
)*ww2
div 2), _y
, s1
, gStdFont
, 255, 255, 255, 1);
2716 for t
:= TEAM_RED
to TEAM_BLUE
do
2718 if t
= TEAM_RED
then
2720 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_TEAM_RED
],
2721 gStdFont
, 255, 0, 0, 1);
2722 e_TextureFontPrintEx(x
+w1
+8, _y
, IntToStr(CustomStat
.TeamStat
[TEAM_RED
].Goals
),
2723 gStdFont
, 255, 0, 0, 1);
2730 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_TEAM_BLUE
],
2731 gStdFont
, 0, 0, 255, 1);
2732 e_TextureFontPrintEx(x
+w1
+8, _y
, IntToStr(CustomStat
.TeamStat
[TEAM_BLUE
].Goals
),
2733 gStdFont
, 0, 0, 255, 1);
2739 e_DrawLine(1, x
+8, _y
+20, x
-8+w
, _y
+20, r
, g
, b
);
2742 for p
:= 0 to High(CustomStat
.PlayerStat
) do
2743 if CustomStat
.PlayerStat
[p
].Team
= t
then
2744 with CustomStat
.PlayerStat
[p
] do
2758 if (gPlayers
[Num
] <> nil) and (gPlayers
[Num
].FReady
) then
2759 e_TextureFontPrintEx(x
+16, _y
, Name
+ ' *', gStdFont
, rr
, gg
, bb
, 1)
2761 e_TextureFontPrintEx(x
+16, _y
, Name
, gStdFont
, rr
, gg
, bb
, 1);
2762 e_TextureFontPrintEx(x
+w1
+16, _y
, IntToStr(Frags
), gStdFont
, rr
, gg
, bb
, 1);
2763 e_TextureFontPrintEx(x
+w1
+w2
+16, _y
, IntToStr(Deaths
), gStdFont
, rr
, gg
, bb
, 1);
2770 else if CustomStat
.GameMode
in [GM_DM
, GM_COOP
] then
2773 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_PLAYER_NAME
], gStdFont
, 255, 127, 0, 1);
2774 e_TextureFontPrintEx(x
+8+w1
, _y
, _lc
[I_GAME_FRAGS
], gStdFont
, 255, 127, 0, 1);
2775 e_TextureFontPrintEx(x
+8+w1
+w2
, _y
, _lc
[I_GAME_DEATHS
], gStdFont
, 255, 127, 0, 1);
2778 for p
:= 0 to High(CustomStat
.PlayerStat
) do
2779 with CustomStat
.PlayerStat
[p
] do
2781 e_DrawFillQuad(x
+8, _y
+4, x
+24-1, _y
+16+4-1, Color
.R
, Color
.G
, Color
.B
, 0);
2788 if (gPlayers
[Num
] <> nil) and (gPlayers
[Num
].FReady
) then
2789 e_TextureFontPrintEx(x
+8+16+8, _y
+4, Name
+ ' *', gStdFont
, r
, r
, r
, 1, True)
2791 e_TextureFontPrintEx(x
+8+16+8, _y
+4, Name
, gStdFont
, r
, r
, r
, 1, True);
2792 e_TextureFontPrintEx(x
+w1
+8+16+8, _y
+4, IntToStr(Frags
), gStdFont
, r
, r
, r
, 1, True);
2793 e_TextureFontPrintEx(x
+w1
+w2
+8+16+8, _y
+4, IntToStr(Deaths
), gStdFont
, r
, r
, r
, 1, True);
2799 procedure DrawSingleStat();
2801 tm
, key_x
, val_x
, y
: Integer;
2805 procedure player_stat(n
: Integer);
2811 s1
:= Format(' %d ', [SingleStat
.PlayerStat
[n
].Kills
]);
2812 s2
:= Format(' %d', [gTotalMonsters
]);
2814 e_CharFont_Print(gMenuFont
, key_x
, y
, _lc
[I_MENU_INTER_KILLS
]);
2815 e_CharFont_PrintEx(gMenuFont
, val_x
, y
, s1
, _RGB(255, 0, 0));
2816 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2817 e_CharFont_Print(gMenuFont
, val_x
+w1
, y
, '/');
2819 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2820 e_CharFont_PrintEx(gMenuFont
, val_x
+w1
, y
, s2
, _RGB(255, 0, 0));
2822 // "Kills-per-minute: ##.#":
2823 s1
:= _lc
[I_MENU_INTER_KPM
];
2825 kpm
:= (SingleStat
.PlayerStat
[n
].Kills
/ tm
) * 60
2827 kpm
:= SingleStat
.PlayerStat
[n
].Kills
;
2828 s2
:= Format(' %.1f', [kpm
]);
2830 e_CharFont_Print(gMenuFont
, key_x
, y
+32, s1
);
2831 e_CharFont_PrintEx(gMenuFont
, val_x
, y
+32, s2
, _RGB(255, 0, 0));
2833 // "Secrets found: # / #":
2834 s1
:= Format(' %d ', [SingleStat
.PlayerStat
[n
].Secrets
]);
2835 s2
:= Format(' %d', [SingleStat
.TotalSecrets
]);
2837 e_CharFont_Print(gMenuFont
, key_x
, y
+64, _lc
[I_MENU_INTER_SECRETS
]);
2838 e_CharFont_PrintEx(gMenuFont
, val_x
, y
+64, s1
, _RGB(255, 0, 0));
2839 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2840 e_CharFont_Print(gMenuFont
, val_x
+w1
, y
+64, '/');
2842 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2843 e_CharFont_PrintEx(gMenuFont
, val_x
+w1
, y
+64, s2
, _RGB(255, 0, 0));
2847 // "Level Complete":
2848 e_CharFont_GetSize(gMenuFont
, _lc
[I_MENU_INTER_LEVEL_COMPLETE
], w1
, h
);
2849 e_CharFont_Print(gMenuFont
, (gScreenWidth
-w1
) div 2, 32, _lc
[I_MENU_INTER_LEVEL_COMPLETE
]);
2851 // Îïðåäåëÿåì êîîðäèíàòû âûðàâíèâàíèÿ ïî ñàìîé äëèííîé ñòðîêå:
2852 s1
:= _lc
[I_MENU_INTER_KPM
];
2853 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2856 e_CharFont_GetSize(gMenuFont
, s1
, w2
, h
);
2858 key_x
:= (gScreenWidth
-w1
-w2
) div 2;
2859 val_x
:= key_x
+ w1
;
2862 tm
:= SingleStat
.GameTime
div 1000;
2863 s1
:= _lc
[I_MENU_INTER_TIME
];
2864 s2
:= Format(' %d:%.2d:%.2d', [tm
div (60*60), (tm
mod (60*60)) div 60, tm
mod 60]);
2866 e_CharFont_Print(gMenuFont
, key_x
, 80, s1
);
2867 e_CharFont_PrintEx(gMenuFont
, val_x
, 80, s2
, _RGB(255, 0, 0));
2869 if SingleStat
.TwoPlayers
then
2872 s1
:= _lc
[I_MENU_PLAYER_1
];
2873 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2874 e_CharFont_Print(gMenuFont
, (gScreenWidth
-w1
) div 2, 128, s1
);
2876 // Ñòàòèñòèêà ïåðâîãî èãðîêà:
2881 s1
:= _lc
[I_MENU_PLAYER_2
];
2882 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2883 e_CharFont_Print(gMenuFont
, (gScreenWidth
-w1
) div 2, 288, s1
);
2885 // Ñòàòèñòèêà âòîðîãî èãðîêà:
2891 // Ñòàòèñòèêà ïåðâîãî èãðîêà:
2897 procedure DrawLoadingStat();
2898 procedure drawRect (x
, y
, w
, h
: Integer);
2900 if (w
< 1) or (h
< 1) then exit
;
2902 glVertex2f(x
+0.375, y
+0.375);
2903 glVertex2f(x
+w
+0.375, y
+0.375);
2904 glVertex2f(x
+w
+0.375, y
+h
+0.375);
2905 glVertex2f(x
+0.375, y
+h
+0.375);
2909 function drawPBar (cur
, total
: Integer; washere
: Boolean): Boolean;
2911 rectW
, rectH
: Integer;
2918 idl
, idr
, idb
, idm
: LongWord;
2922 if (total
< 1) then exit
;
2923 if (cur
< 1) then exit
; // don't blink
2924 if (not washere
) and (cur
>= total
) then exit
; // don't blink
2925 //if (cur < 0) then cur := 0;
2926 //if (cur > total) then cur := total;
2929 if (hasPBarGfx
) then
2931 g_Texture_Get('UI_GFX_PBAR_LEFT', idl
);
2932 g_Texture_GetSize('UI_GFX_PBAR_LEFT', wl
, hl
);
2933 g_Texture_Get('UI_GFX_PBAR_RIGHT', idr
);
2934 g_Texture_GetSize('UI_GFX_PBAR_RIGHT', wr
, hr
);
2935 g_Texture_Get('UI_GFX_PBAR_MIDDLE', idb
);
2936 g_Texture_GetSize('UI_GFX_PBAR_MIDDLE', wb
, hb
);
2937 g_Texture_Get('UI_GFX_PBAR_MARKER', idm
);
2938 g_Texture_GetSize('UI_GFX_PBAR_MARKER', wm
, hm
);
2940 //rectW := gScreenWidth-360;
2941 rectW
:= trunc(624.0*gScreenWidth
/1024.0);
2944 x0
:= (gScreenWidth
-rectW
) div 2;
2945 y0
:= gScreenHeight
-rectH
-64;
2946 if (y0
< 2) then y0
:= 2;
2948 glEnable(GL_SCISSOR_TEST
);
2951 glScissor(x0
, gScreenHeight
-y0
-rectH
, rectW
, rectH
);
2952 e_DrawSize(idl
, x0
, y0
, 0, true, false, wl
, hl
);
2953 e_DrawSize(idr
, x0
+rectW
-wr
, y0
, 0, true, false, wr
, hr
);
2956 glScissor(x0
+wl
, gScreenHeight
-y0
-rectH
, rectW
-wl
-wr
, rectH
);
2958 while (f
< x0
+rectW
) do
2960 e_DrawSize(idb
, f
, y0
, 0, true, false, wb
, hb
);
2965 wdt
:= (rectW
-wl
-wr
)*cur
div total
;
2966 if (wdt
> rectW
-wl
-wr
) then wdt
:= rectW
-wr
-wr
;
2969 my
:= y0
; // don't be so smart, ketmar: +(rectH-wm) div 2;
2970 glScissor(x0
+wl
, gScreenHeight
-my
-rectH
, wdt
, hm
);
2974 e_DrawSize(idm
, f
, y0
, 0, true, false, wm
, hm
);
2980 glScissor(0, 0, gScreenWidth
, gScreenHeight
);
2984 rectW
:= gScreenWidth
-64;
2987 x0
:= (gScreenWidth
-rectW
) div 2;
2988 y0
:= gScreenHeight
-rectH
-64;
2989 if (y0
< 2) then y0
:= 2;
2991 glDisable(GL_BLEND
);
2992 glDisable(GL_TEXTURE_2D
);
2994 //glClearColor(0, 0, 0, 0);
2995 //glClear(GL_COLOR_BUFFER_BIT);
2997 glColor4ub(127, 127, 127, 255);
2998 drawRect(x0
-2, y0
-2, rectW
+4, rectH
+4);
3000 glColor4ub(0, 0, 0, 255);
3001 drawRect(x0
-1, y0
-1, rectW
+2, rectH
+2);
3003 glColor4ub(127, 127, 127, 255);
3004 wdt
:= rectW
*cur
div total
;
3005 if (wdt
> rectW
) then wdt
:= rectW
;
3006 drawRect(x0
, y0
, wdt
, rectH
);
3015 if (Length(LoadingStat
.Msgs
) = 0) then exit
;
3017 e_CharFont_GetSize(gMenuFont
, _lc
[I_MENU_LOADING
], ww
, hh
);
3018 yy
:= (gScreenHeight
div 3);
3019 e_CharFont_Print(gMenuFont
, (gScreenWidth
div 2)-(ww
div 2), yy
-2*hh
, _lc
[I_MENU_LOADING
]);
3020 xx
:= (gScreenWidth
div 3);
3024 for i
:= 0 to NextMsg
-1 do
3026 if (i
= (NextMsg
-1)) and (MaxValue
> 0) then
3027 s
:= Format('%s: %d/%d', [Msgs
[i
], CurValue
, MaxValue
])
3031 e_CharFont_PrintEx(gMenuSmallFont
, xx
, yy
, s
, _RGB(255, 0, 0));
3032 yy
:= yy
+ LOADING_INTERLINE
;
3033 PBarWasHere
:= drawPBar(CurValue
, MaxValue
, PBarWasHere
);
3038 procedure DrawMenuBackground(tex
: AnsiString);
3044 if g_Texture_Get(tex
, ID
) then
3046 e_Clear(GL_COLOR_BUFFER_BIT
, 0, 0, 0);
3047 e_GetTextureSize(ID
, @w
, @h
);
3049 w
:= round(w
* 1.333 * (gScreenHeight
/ h
))
3051 w
:= trunc(w
* (gScreenHeight
/ h
));
3052 e_DrawSize(ID
, (gScreenWidth
- w
) div 2, 0, 0, False, False, w
, gScreenHeight
);
3054 else e_Clear(GL_COLOR_BUFFER_BIT
, 0, 0, 0);
3057 procedure DrawMinimap(p
: TPlayer
; RenderRect
: e_graphics
.TRect
);
3059 a
, aX
, aY
, aX2
, aY2
, Scale
, ScaleSz
: Integer;
3061 function monDraw (mon
: TMonster
): Boolean;
3063 result
:= false; // don't stop
3068 // Ëåâûé âåðõíèé óãîë
3069 aX
:= Obj
.X
div ScaleSz
+ 1;
3070 aY
:= Obj
.Y
div ScaleSz
+ 1;
3072 aX2
:= max(Obj
.Rect
.Width
div ScaleSz
, 1);
3073 aY2
:= max(Obj
.Rect
.Height
div ScaleSz
, 1);
3074 // Ïðàâûé íèæíèé óãîë
3075 aX2
:= aX
+ aX2
- 1;
3076 aY2
:= aY
+ aY2
- 1;
3077 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 255, 0, 0);
3083 if (gMapInfo
.Width
> RenderRect
.Right
- RenderRect
.Left
) or
3084 (gMapInfo
.Height
> RenderRect
.Bottom
- RenderRect
.Top
) then
3087 // Ñêîëüêî ïèêñåëîâ êàðòû â 1 ïèêñåëå ìèíè-êàðòû:
3088 ScaleSz
:= 16 div Scale
;
3089 // Ðàçìåðû ìèíè-êàðòû:
3090 aX
:= max(gMapInfo
.Width
div ScaleSz
, 1);
3091 aY
:= max(gMapInfo
.Height
div ScaleSz
, 1);
3093 e_DrawFillQuad(0, 0, aX
-1, aY
-1, 0, 0, 0, 0);
3095 if gWalls
<> nil then
3098 for a
:= 0 to High(gWalls
) do
3100 if PanelType
<> 0 then
3102 // Ëåâûé âåðõíèé óãîë:
3103 aX
:= X
div ScaleSz
;
3104 aY
:= Y
div ScaleSz
;
3106 aX2
:= max(Width
div ScaleSz
, 1);
3107 aY2
:= max(Height
div ScaleSz
, 1);
3108 // Ïðàâûé íèæíèé óãîë:
3109 aX2
:= aX
+ aX2
- 1;
3110 aY2
:= aY
+ aY2
- 1;
3113 PANEL_WALL
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 208, 208, 208, 0);
3114 PANEL_OPENDOOR
, PANEL_CLOSEDOOR
:
3115 if Enabled
then e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 160, 160, 160, 0);
3119 if gSteps
<> nil then
3122 for a
:= 0 to High(gSteps
) do
3124 if PanelType
<> 0 then
3126 // Ëåâûé âåðõíèé óãîë:
3127 aX
:= X
div ScaleSz
;
3128 aY
:= Y
div ScaleSz
;
3130 aX2
:= max(Width
div ScaleSz
, 1);
3131 aY2
:= max(Height
div ScaleSz
, 1);
3132 // Ïðàâûé íèæíèé óãîë:
3133 aX2
:= aX
+ aX2
- 1;
3134 aY2
:= aY
+ aY2
- 1;
3136 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 128, 128, 128, 0);
3139 if gLifts
<> nil then
3142 for a
:= 0 to High(gLifts
) do
3144 if PanelType
<> 0 then
3146 // Ëåâûé âåðõíèé óãîë:
3147 aX
:= X
div ScaleSz
;
3148 aY
:= Y
div ScaleSz
;
3150 aX2
:= max(Width
div ScaleSz
, 1);
3151 aY2
:= max(Height
div ScaleSz
, 1);
3152 // Ïðàâûé íèæíèé óãîë:
3153 aX2
:= aX
+ aX2
- 1;
3154 aY2
:= aY
+ aY2
- 1;
3157 LIFTTYPE_UP
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 116, 72, 36, 0);
3158 LIFTTYPE_DOWN
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 116, 124, 96, 0);
3159 LIFTTYPE_LEFT
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 200, 80, 4, 0);
3160 LIFTTYPE_RIGHT
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 252, 140, 56, 0);
3164 if gWater
<> nil then
3167 for a
:= 0 to High(gWater
) do
3169 if PanelType
<> 0 then
3171 // Ëåâûé âåðõíèé óãîë:
3172 aX
:= X
div ScaleSz
;
3173 aY
:= Y
div ScaleSz
;
3175 aX2
:= max(Width
div ScaleSz
, 1);
3176 aY2
:= max(Height
div ScaleSz
, 1);
3177 // Ïðàâûé íèæíèé óãîë:
3178 aX2
:= aX
+ aX2
- 1;
3179 aY2
:= aY
+ aY2
- 1;
3181 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 0, 192, 0);
3184 if gAcid1
<> nil then
3186 // Ðèñóåì êèñëîòó 1:
3187 for a
:= 0 to High(gAcid1
) do
3189 if PanelType
<> 0 then
3191 // Ëåâûé âåðõíèé óãîë:
3192 aX
:= X
div ScaleSz
;
3193 aY
:= Y
div ScaleSz
;
3195 aX2
:= max(Width
div ScaleSz
, 1);
3196 aY2
:= max(Height
div ScaleSz
, 1);
3197 // Ïðàâûé íèæíèé óãîë:
3198 aX2
:= aX
+ aX2
- 1;
3199 aY2
:= aY
+ aY2
- 1;
3201 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 176, 0, 0);
3204 if gAcid2
<> nil then
3206 // Ðèñóåì êèñëîòó 2:
3207 for a
:= 0 to High(gAcid2
) do
3209 if PanelType
<> 0 then
3211 // Ëåâûé âåðõíèé óãîë:
3212 aX
:= X
div ScaleSz
;
3213 aY
:= Y
div ScaleSz
;
3215 aX2
:= max(Width
div ScaleSz
, 1);
3216 aY2
:= max(Height
div ScaleSz
, 1);
3217 // Ïðàâûé íèæíèé óãîë:
3218 aX2
:= aX
+ aX2
- 1;
3219 aY2
:= aY
+ aY2
- 1;
3221 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 176, 0, 0, 0);
3224 if gPlayers
<> nil then
3227 for a
:= 0 to High(gPlayers
) do
3228 if gPlayers
[a
] <> nil then with gPlayers
[a
] do
3230 // Ëåâûé âåðõíèé óãîë:
3231 aX
:= Obj
.X
div ScaleSz
+ 1;
3232 aY
:= Obj
.Y
div ScaleSz
+ 1;
3234 aX2
:= max(Obj
.Rect
.Width
div ScaleSz
, 1);
3235 aY2
:= max(Obj
.Rect
.Height
div ScaleSz
, 1);
3236 // Ïðàâûé íèæíèé óãîë:
3237 aX2
:= aX
+ aX2
- 1;
3238 aY2
:= aY
+ aY2
- 1;
3240 if gPlayers
[a
] = p
then
3241 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 255, 0, 0)
3244 TEAM_RED
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 0, 0, 0);
3245 TEAM_BLUE
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 0, 255, 0);
3246 else e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 128, 0, 0);
3251 g_Mons_ForEach(monDraw
);
3256 procedure renderAmbientQuad (hasAmbient
: Boolean; constref ambColor
: TDFColor
);
3258 if not hasAmbient
then exit
;
3259 e_AmbientQuad(sX
, sY
, sWidth
, sHeight
, ambColor
.r
, ambColor
.g
, ambColor
.b
, ambColor
.a
);
3263 // setup sX, sY, sWidth, sHeight, and transformation matrix before calling this!
3264 //FIXME: broken for splitscreen mode
3265 procedure renderDynLightsInternal ();
3267 //hasAmbient: Boolean;
3268 //ambColor: TDFColor;
3270 lx
, ly
, lrad
: Integer;
3271 scxywh
: array[0..3] of GLint
;
3274 if e_NoGraphics
then exit
;
3276 //TODO: lights should be in separate grid, i think
3277 // but on the other side: grid may be slower for dynlights, as their lifetime is short
3278 if (not gwin_k8_enable_light_experiments
) or (not gwin_has_stencil
) or (g_dynLightCount
< 1) then exit
;
3281 //ambColor := gCurrentMap['light_ambient'].rgba;
3282 //hasAmbient := (not ambColor.isOpaque) or (not ambColor.isBlack);
3284 { // this will multiply incoming color to alpha from framebuffer
3286 glBlendFunc(GL_DST_ALPHA, GL_ONE);
3290 * light rendering: (INVALID!)
3291 * glStencilFunc(GL_EQUAL, 0, $ff);
3293 * glClear(GL_STENCIL_BUFFER_BIT);
3294 * glStencilOp(GL_KEEP, GL_KEEP, GL_INCR);
3295 * draw shadow volume into stencil buffer
3296 * glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); // modify color buffer
3297 * glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); // don't modify stencil buffer
3299 * draw color-less quad with light alpha (WARNING! don't touch color!)
3300 * glEnable(GL_BLEND);
3301 * glBlendFunc(GL_DST_ALPHA, GL_ONE);
3302 * draw all geometry up to and including walls (with alpha-testing, probably) -- this does lighting
3304 wassc
:= (glIsEnabled(GL_SCISSOR_TEST
) <> 0);
3305 if wassc
then glGetIntegerv(GL_SCISSOR_BOX
, @scxywh
[0]) else glGetIntegerv(GL_VIEWPORT
, @scxywh
[0]);
3307 // setup OpenGL parameters
3308 glStencilMask($FFFFFFFF);
3309 glStencilFunc(GL_ALWAYS
, 0, $FFFFFFFF);
3310 glEnable(GL_STENCIL_TEST
);
3311 glEnable(GL_SCISSOR_TEST
);
3312 glClear(GL_STENCIL_BUFFER_BIT
);
3313 glStencilFunc(GL_EQUAL
, 0, $ff);
3315 for lln
:= 0 to g_dynLightCount
-1 do
3317 lx
:= g_dynLights
[lln
].x
;
3318 ly
:= g_dynLights
[lln
].y
;
3319 lrad
:= g_dynLights
[lln
].radius
;
3320 if (lrad
< 3) then continue
;
3322 if (lx
-sX
+lrad
< 0) then continue
;
3323 if (ly
-sY
+lrad
< 0) then continue
;
3324 if (lx
-sX
-lrad
>= gPlayerScreenSize
.X
) then continue
;
3325 if (ly
-sY
-lrad
>= gPlayerScreenSize
.Y
) then continue
;
3327 // set scissor to optimize drawing
3328 if (g_dbg_scale
= 1.0) then
3330 glScissor((lx
-sX
)-lrad
+2, gPlayerScreenSize
.Y
-(ly
-sY
)-lrad
-1+2, lrad
*2-4, lrad
*2-4);
3334 glScissor(0, 0, gWinSizeX
, gWinSizeY
);
3336 // no need to clear stencil buffer, light blitting will do it for us... but only for normal scale
3337 if (g_dbg_scale
<> 1.0) then glClear(GL_STENCIL_BUFFER_BIT
);
3338 glStencilOp(GL_KEEP
, GL_KEEP
, GL_INCR
);
3339 // draw extruded panels
3340 glDisable(GL_TEXTURE_2D
);
3341 glDisable(GL_BLEND
);
3342 glColorMask(GL_FALSE
, GL_FALSE
, GL_FALSE
, GL_FALSE
); // no need to modify color buffer
3343 if (lrad
> 4) then g_Map_DrawPanelShadowVolumes(lx
, ly
, lrad
);
3344 // render light texture
3345 glColorMask(GL_TRUE
, GL_TRUE
, GL_TRUE
, GL_TRUE
); // modify color buffer
3346 glStencilOp(GL_ZERO
, GL_ZERO
, GL_ZERO
); // draw light, and clear stencil buffer
3349 glBlendFunc(GL_SRC_ALPHA
, GL_ONE_MINUS_SRC_ALPHA
);
3350 glEnable(GL_TEXTURE_2D
);
3351 // color and opacity
3352 glColor4f(g_dynLights
[lln
].r
, g_dynLights
[lln
].g
, g_dynLights
[lln
].b
, g_dynLights
[lln
].a
);
3353 glBindTexture(GL_TEXTURE_2D
, g_Texture_Light());
3355 glTexCoord2f(0.0, 0.0); glVertex2i(lx
-lrad
, ly
-lrad
); // top-left
3356 glTexCoord2f(1.0, 0.0); glVertex2i(lx
+lrad
, ly
-lrad
); // top-right
3357 glTexCoord2f(1.0, 1.0); glVertex2i(lx
+lrad
, ly
+lrad
); // bottom-right
3358 glTexCoord2f(0.0, 1.0); glVertex2i(lx
-lrad
, ly
+lrad
); // bottom-left
3363 glDisable(GL_STENCIL_TEST
);
3364 glDisable(GL_BLEND
);
3365 glDisable(GL_SCISSOR_TEST
);
3366 //glScissor(0, 0, sWidth, sHeight);
3368 glScissor(scxywh
[0], scxywh
[1], scxywh
[2], scxywh
[3]);
3369 if wassc
then glEnable(GL_SCISSOR_TEST
) else glDisable(GL_SCISSOR_TEST
);
3373 function fixViewportForScale (): Boolean;
3375 nx0
, ny0
, nw
, nh
: Integer;
3378 if (g_dbg_scale
<> 1.0) then
3381 nx0
:= round(sX
-(gPlayerScreenSize
.X
-(sWidth
*g_dbg_scale
))/2/g_dbg_scale
);
3382 ny0
:= round(sY
-(gPlayerScreenSize
.Y
-(sHeight
*g_dbg_scale
))/2/g_dbg_scale
);
3383 nw
:= round(sWidth
/g_dbg_scale
);
3384 nh
:= round(sHeight
/g_dbg_scale
);
3393 // setup sX, sY, sWidth, sHeight, and transformation matrix before calling this!
3394 // WARNING! this WILL CALL `glTranslatef()`, but won't restore matrices!
3395 procedure renderMapInternal (backXOfs
, backYOfs
: Integer; setTransMatrix
: Boolean);
3397 TDrawCB
= procedure ();
3400 hasAmbient
: Boolean;
3402 doAmbient
: Boolean = false;
3404 procedure drawPanelType (profname
: AnsiString; panType
: DWord
; doDraw
: Boolean);
3409 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin(profname
);
3410 if gdbg_map_use_accel_render
then
3412 tagmask
:= panelTypeToTag(panType
);
3413 while (gDrawPanelList
.count
> 0) do
3415 pan
:= TPanel(gDrawPanelList
.front());
3416 if ((pan
.tag
and tagmask
) = 0) then break
;
3417 if doDraw
then pan
.Draw(doAmbient
, ambColor
);
3418 gDrawPanelList
.popFront();
3423 if doDraw
then g_Map_DrawPanels(panType
, hasAmbient
, ambColor
);
3425 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
3428 procedure drawOther (profname
: AnsiString; cb
: TDrawCB
);
3430 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin(profname
);
3431 if assigned(cb
) then cb();
3432 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
3436 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin('total');
3438 // our accelerated renderer will collect all panels to gDrawPanelList
3439 // we can use panel tag to render level parts (see GridTagXXX in g_map.pas)
3440 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin('collect');
3441 if gdbg_map_use_accel_render
then
3443 g_Map_CollectDrawPanels(sX
, sY
, sWidth
, sHeight
);
3445 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
3447 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin('skyback');
3448 g_Map_DrawBack(backXOfs
, backYOfs
);
3449 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
3451 if setTransMatrix
then
3453 //if (g_dbg_scale <> 1.0) then glTranslatef(0.0, -0.375/2, 0);
3454 glScalef(g_dbg_scale
, g_dbg_scale
, 1.0);
3455 glTranslatef(-sX
, -sY
, 0);
3459 ambColor
:= gCurrentMap
['light_ambient'].rgba
;
3460 hasAmbient
:= (not ambColor
.isOpaque
) or (not ambColor
.isBlack
);
3465 //writeln('color: (', ambColor.r, ',', ambColor.g, ',', ambColor.b, ',', ambColor.a, ')');
3466 glColor4ub(ambColor.r, ambColor.g, ambColor.b, ambColor.a);
3467 glClear(GL_COLOR_BUFFER_BIT);
3470 //writeln('color: (', ambColor.r, ',', ambColor.g, ',', ambColor.b, ',', ambColor.a, ')');
3473 drawPanelType('*back', PANEL_BACK
, g_rlayer_back
);
3474 drawPanelType('*step', PANEL_STEP
, g_rlayer_step
);
3475 drawOther('items', @g_Items_Draw
);
3476 drawOther('weapons', @g_Weapon_Draw
);
3477 drawOther('shells', @g_Player_DrawShells
);
3478 drawOther('drawall', @g_Player_DrawAll
);
3479 drawOther('corpses', @g_Player_DrawCorpses
);
3480 drawPanelType('*wall', PANEL_WALL
, g_rlayer_wall
);
3481 drawOther('monsters', @g_Monsters_Draw
);
3482 drawOther('itemdrop', @g_Items_DrawDrop
);
3483 drawPanelType('*door', PANEL_CLOSEDOOR
, g_rlayer_door
);
3484 drawOther('gfx', @g_GFX_Draw
);
3485 drawOther('flags', @g_Map_DrawFlags
);
3486 drawPanelType('*acid1', PANEL_ACID1
, g_rlayer_acid1
);
3487 drawPanelType('*acid2', PANEL_ACID2
, g_rlayer_acid2
);
3488 drawPanelType('*water', PANEL_WATER
, g_rlayer_water
);
3489 drawOther('dynlights', @renderDynLightsInternal
);
3491 if hasAmbient
{and ((not g_playerLight) or (not gwin_has_stencil) or (g_dynLightCount < 1))} then
3493 renderAmbientQuad(hasAmbient
, ambColor
);
3497 drawPanelType('*fore', PANEL_FORE
, g_rlayer_fore
);
3500 if g_debug_HealthBar
then
3502 g_Monsters_DrawHealth();
3503 g_Player_DrawHealth();
3506 if (profileFrameDraw
<> nil) then profileFrameDraw
.mainEnd(); // map rendering
3510 procedure DrawMapView(x
, y
, w
, h
: Integer);
3517 bx
:= Round(x
/(gMapInfo
.Width
- w
)*(gBackSize
.X
- w
));
3518 by
:= Round(y
/(gMapInfo
.Height
- h
)*(gBackSize
.Y
- h
));
3525 fixViewportForScale();
3526 renderMapInternal(-bx
, -by
, true);
3532 procedure DrawPlayer(p
: TPlayer
);
3534 px
, py
, a
, b
, c
, d
, i
: Integer;
3537 if (p
= nil) or (p
.FDummy
) then
3540 g_Map_DrawBack(0, 0);
3545 if (profileFrameDraw
= nil) then profileFrameDraw
:= TProfiler
.Create('RENDER', g_profile_history_size
);
3546 if (profileFrameDraw
<> nil) then profileFrameDraw
.mainBegin(g_profile_frame_draw
);
3552 px
:= p
.GameX
+ PLAYER_RECT_CX
;
3553 py
:= p
.GameY
+ PLAYER_RECT_CY
+p
.Obj
.slopeUpLeft
;
3555 if (g_dbg_scale
= 1.0) and (not g_dbg_ignore_bounds
) then
3557 if (px
> (gPlayerScreenSize
.X
div 2)) then a
:= -px
+(gPlayerScreenSize
.X
div 2) else a
:= 0;
3558 if (py
> (gPlayerScreenSize
.Y
div 2)) then b
:= -py
+(gPlayerScreenSize
.Y
div 2) else b
:= 0;
3560 if (px
> gMapInfo
.Width
-(gPlayerScreenSize
.X
div 2)) then a
:= -gMapInfo
.Width
+gPlayerScreenSize
.X
;
3561 if (py
> gMapInfo
.Height
-(gPlayerScreenSize
.Y
div 2)) then b
:= -gMapInfo
.Height
+gPlayerScreenSize
.Y
;
3563 if (gMapInfo
.Width
= gPlayerScreenSize
.X
) then a
:= 0
3564 else if (gMapInfo
.Width
< gPlayerScreenSize
.X
) then
3567 a
:= (gPlayerScreenSize
.X
-gMapInfo
.Width
) div 2;
3570 if (gMapInfo
.Height
= gPlayerScreenSize
.Y
) then b
:= 0
3571 else if (gMapInfo
.Height
< gPlayerScreenSize
.Y
) then
3574 b
:= (gPlayerScreenSize
.Y
-gMapInfo
.Height
) div 2;
3579 // scaled, ignore level bounds
3580 a
:= -px
+(gPlayerScreenSize
.X
div 2);
3581 b
:= -py
+(gPlayerScreenSize
.Y
div 2);
3584 if p
.IncCam
<> 0 then
3586 if py
> gMapInfo
.Height
-(gPlayerScreenSize
.Y
div 2) then
3588 if p
.IncCam
> 120-(py
-(gMapInfo
.Height
-(gPlayerScreenSize
.Y
div 2))) then
3590 p
.IncCam
:= 120-(py
-(gMapInfo
.Height
-(gPlayerScreenSize
.Y
div 2)));
3594 if py
< gPlayerScreenSize
.Y
div 2 then
3596 if p
.IncCam
< -120+((gPlayerScreenSize
.Y
div 2)-py
) then
3598 p
.IncCam
:= -120+((gPlayerScreenSize
.Y
div 2)-py
);
3602 if p
.IncCam
< 0 then
3604 while (py
+(gPlayerScreenSize
.Y
div 2)-p
.IncCam
> gMapInfo
.Height
) and (p
.IncCam
< 0) do p
.IncCam
:= p
.IncCam
+1; //Inc(p.IncCam);
3607 if p
.IncCam
> 0 then
3609 while (py
-(gPlayerScreenSize
.Y
div 2)-p
.IncCam
< 0) and (p
.IncCam
> 0) do p
.IncCam
:= p
.IncCam
-1; //Dec(p.IncCam);
3613 if (px
< gPlayerScreenSize
.X
div 2) or (gMapInfo
.Width
-gPlayerScreenSize
.X
<= 256) then c
:= 0
3614 else if (px
> gMapInfo
.Width
-(gPlayerScreenSize
.X
div 2)) then c
:= gBackSize
.X
-gPlayerScreenSize
.X
3615 else c
:= round((px
-(gPlayerScreenSize
.X
div 2))/(gMapInfo
.Width
-gPlayerScreenSize
.X
)*(gBackSize
.X
-gPlayerScreenSize
.X
));
3617 if (py
-p
.IncCam
<= gPlayerScreenSize
.Y
div 2) or (gMapInfo
.Height
-gPlayerScreenSize
.Y
<= 256) then d
:= 0
3618 else if (py
-p
.IncCam
>= gMapInfo
.Height
-(gPlayerScreenSize
.Y
div 2)) then d
:= gBackSize
.Y
-gPlayerScreenSize
.Y
3619 else d
:= round((py
-p
.IncCam
-(gPlayerScreenSize
.Y
div 2))/(gMapInfo
.Height
-gPlayerScreenSize
.Y
)*(gBackSize
.Y
-gPlayerScreenSize
.Y
));
3622 sY
:= -(b
+p
.IncCam
);
3623 sWidth
:= gPlayerScreenSize
.X
;
3624 sHeight
:= gPlayerScreenSize
.Y
;
3626 //glTranslatef(a, b+p.IncCam, 0);
3628 //if (p = gPlayer1) and (g_dbg_scale >= 1.0) then g_Holmes_plrViewSize(sWidth, sHeight);
3630 //conwritefln('OLD: (%s,%s)-(%s,%s)', [sX, sY, sWidth, sHeight]);
3631 fixViewportForScale();
3632 //conwritefln(' (%s,%s)-(%s,%s)', [sX, sY, sWidth, sHeight]);
3634 if (g_dbg_scale
<> 1.0) and (not g_dbg_ignore_bounds
) then
3636 if (sX
+sWidth
> gMapInfo
.Width
) then sX
:= gMapInfo
.Width
-sWidth
;
3637 if (sY
+sHeight
> gMapInfo
.Height
) then sY
:= gMapInfo
.Height
-sHeight
;
3638 if (sX
< 0) then sX
:= 0;
3639 if (sY
< 0) then sY
:= 0;
3641 if (gBackSize
.X
<= gPlayerScreenSize
.X
) or (gMapInfo
.Width
<= sWidth
) then c
:= 0 else c
:= trunc((gBackSize
.X
-gPlayerScreenSize
.X
)*sX
/(gMapInfo
.Width
-sWidth
));
3642 if (gBackSize
.Y
<= gPlayerScreenSize
.Y
) or (gMapInfo
.Height
<= sHeight
) then d
:= 0 else d
:= trunc((gBackSize
.Y
-gPlayerScreenSize
.Y
)*sY
/(gMapInfo
.Height
-sHeight
));
3645 //r_smallmap_h: 0: left; 1: center; 2: right
3646 //r_smallmap_v: 0: top; 1: center; 2: bottom
3648 if (gMapInfo
.Width
= sWidth
) then
3652 else if (gMapInfo
.Width
< sWidth
) then
3654 case r_smallmap_h
of
3655 1: sX
:= -((sWidth
-gMapInfo
.Width
) div 2); // center
3656 2: sX
:= -(sWidth
-gMapInfo
.Width
); // right
3657 else sX
:= 0; // left
3661 if (gMapInfo
.Height
= sHeight
) then
3665 else if (gMapInfo
.Height
< sHeight
) then
3667 case r_smallmap_v
of
3668 1: sY
:= -((sHeight
-gMapInfo
.Height
) div 2); // center
3669 2: sY
:= -(sHeight
-gMapInfo
.Height
); // bottom
3670 else sY
:= 0; // top
3676 p
.viewPortW
:= sWidth
;
3677 p
.viewPortH
:= sHeight
;
3679 {$IFDEF ENABLE_HOLMES}
3680 if (p
= gPlayer1
) then
3682 g_Holmes_plrViewPos(sX
, sY
);
3683 g_Holmes_plrViewSize(sWidth
, sHeight
);
3687 renderMapInternal(-c
, -d
, true);
3689 if (gGameSettings
.GameMode
<> GM_SINGLE
) and (gPlayerIndicator
> 0) then
3690 case gPlayerIndicator
of
3692 p
.DrawIndicator(_RGB(255, 255, 255));
3695 for i
:= 0 to High(gPlayers
) do
3696 if gPlayers
[i
] <> nil then
3697 if gPlayers
[i
] = p
then p
.DrawIndicator(_RGB(255, 255, 255))
3698 else if (gPlayers
[i
].Team
= p
.Team
) and (gPlayers
[i
].Team
<> TEAM_NONE
) then
3699 if gPlayerIndicatorStyle
= 1 then
3700 gPlayers
[i
].DrawIndicator(_RGB(192, 192, 192))
3701 else gPlayers
[i
].DrawIndicator(gPlayers
[i
].GetColor
);
3704 if p
.FSpectator
then
3705 e_TextureFontPrintEx(p
.GameX
+ PLAYER_RECT_CX
- 4,
3706 p
.GameY
+ PLAYER_RECT_CY
- 4,
3707 'X', gStdFont
, 255, 255, 255, 1, True);
3709 for a := 0 to High(gCollideMap) do
3710 for b := 0 to High(gCollideMap[a]) do
3713 if ByteBool(gCollideMap[a, b] and MARK_WALL) then
3715 if ByteBool(gCollideMap[a, b] and MARK_DOOR) then
3719 1: e_DrawPoint(1, b, a, 200, 200, 200);
3720 2: e_DrawPoint(1, b, a, 64, 64, 255);
3721 3: e_DrawPoint(1, b, a, 255, 0, 255);
3731 if gShowMap
then DrawMinimap(p
, _TRect(0, 0, 128, 128));
3732 if g_Debug_Player
then
3733 g_Player_DrawDebug(p
);
3737 procedure drawProfilers ();
3742 if g_profile_frame_draw
and (profileFrameDraw
<> nil) then px
:= px
-drawProfiles(px
, py
, profileFrameDraw
);
3743 if g_profile_collision
and (profMapCollision
<> nil) then begin px
:= px
-drawProfiles(px
, py
, profMapCollision
); py
-= calcProfilesHeight(profMonsLOS
); end;
3744 if g_profile_los
and (profMonsLOS
<> nil) then begin px
:= px
-drawProfiles(px
, py
, profMonsLOS
); py
-= calcProfilesHeight(profMonsLOS
); end;
3747 procedure g_Game_Draw();
3754 plView1
, plView2
: TPlayer
;
3757 if gExit
= EXIT_QUIT
then Exit
;
3759 Time
:= sys_GetTicks() {div 1000};
3760 FPSCounter
:= FPSCounter
+1;
3761 if Time
- FPSTime
>= 1000 then
3768 if gGameOn
or (gState
= STATE_FOLD
) then
3770 if (gPlayer1
<> nil) and (gPlayer2
<> nil) then
3772 gSpectMode
:= SPECT_NONE
;
3773 if not gRevertPlayers
then
3775 plView1
:= gPlayer1
;
3776 plView2
:= gPlayer2
;
3780 plView1
:= gPlayer2
;
3781 plView2
:= gPlayer1
;
3785 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
3787 gSpectMode
:= SPECT_NONE
;
3788 if gPlayer2
= nil then
3791 plView1
:= gPlayer2
;
3800 if (plView1
= nil) and (plView2
= nil) and (gSpectMode
= SPECT_NONE
) then
3801 gSpectMode
:= SPECT_STATS
;
3803 if gSpectMode
= SPECT_PLAYERS
then
3804 if gPlayers
<> nil then
3806 plView1
:= GetActivePlayer_ByID(gSpectPID1
);
3807 if plView1
= nil then
3809 gSpectPID1
:= GetActivePlayerID_Next();
3810 plView1
:= GetActivePlayer_ByID(gSpectPID1
);
3812 if gSpectViewTwo
then
3814 plView2
:= GetActivePlayer_ByID(gSpectPID2
);
3815 if plView2
= nil then
3817 gSpectPID2
:= GetActivePlayerID_Next();
3818 plView2
:= GetActivePlayer_ByID(gSpectPID2
);
3823 if gSpectMode
= SPECT_MAPVIEW
then
3825 // Ðåæèì ïðîñìîòðà êàðòû
3827 e_SetViewPort(0, 0, gScreenWidth
, gScreenHeight
);
3828 DrawMapView(gSpectX
, gSpectY
, gScreenWidth
, gScreenHeight
);
3829 gHearPoint1
.Active
:= True;
3830 gHearPoint1
.Coords
.X
:= gScreenWidth
div 2 + gSpectX
;
3831 gHearPoint1
.Coords
.Y
:= gScreenHeight
div 2 + gSpectY
;
3832 gHearPoint2
.Active
:= False;
3836 Split
:= (plView1
<> nil) and (plView2
<> nil);
3838 // Òî÷êè ñëóõà èãðîêîâ
3839 if plView1
<> nil then
3841 gHearPoint1
.Active
:= True;
3842 gHearPoint1
.Coords
.X
:= plView1
.GameX
+ PLAYER_RECT
.Width
;
3843 gHearPoint1
.Coords
.Y
:= plView1
.GameY
+ PLAYER_RECT
.Height
DIV 2;
3845 gHearPoint1
.Active
:= False;
3846 if plView2
<> nil then
3848 gHearPoint2
.Active
:= True;
3849 gHearPoint2
.Coords
.X
:= plView2
.GameX
+ PLAYER_RECT
.Width
;
3850 gHearPoint2
.Coords
.Y
:= plView2
.GameY
+ PLAYER_RECT
.Height
DIV 2;
3852 gHearPoint2
.Active
:= False;
3854 // Ðàçìåð ýêðàíîâ èãðîêîâ:
3855 gPlayerScreenSize
.X
:= gScreenWidth
-196;
3858 gPlayerScreenSize
.Y
:= gScreenHeight
div 2;
3859 if gScreenHeight
mod 2 = 0 then
3860 Dec(gPlayerScreenSize
.Y
);
3863 gPlayerScreenSize
.Y
:= gScreenHeight
;
3866 if gScreenHeight
mod 2 = 0 then
3867 e_SetViewPort(0, gPlayerScreenSize
.Y
+2, gPlayerScreenSize
.X
+196, gPlayerScreenSize
.Y
)
3869 e_SetViewPort(0, gPlayerScreenSize
.Y
+1, gPlayerScreenSize
.X
+196, gPlayerScreenSize
.Y
);
3871 DrawPlayer(plView1
);
3872 gPlayer1ScreenCoord
.X
:= sX
;
3873 gPlayer1ScreenCoord
.Y
:= sY
;
3877 e_SetViewPort(0, 0, gPlayerScreenSize
.X
+196, gPlayerScreenSize
.Y
);
3879 DrawPlayer(plView2
);
3880 gPlayer2ScreenCoord
.X
:= sX
;
3881 gPlayer2ScreenCoord
.Y
:= sY
;
3884 e_SetViewPort(0, 0, gScreenWidth
, gScreenHeight
);
3887 e_DrawLine(2, 0, gScreenHeight
div 2, gScreenWidth
, gScreenHeight
div 2, 0, 0, 0);
3890 {$IFDEF ENABLE_HOLMES}
3892 if (g_holmes_enabled
) then g_Holmes_Draw();
3895 if MessageText
<> '' then
3899 e_CharFont_GetSizeFmt(gMenuFont
, MessageText
, w
, h
);
3901 e_CharFont_PrintFmt(gMenuFont
, (gScreenWidth
div 2)-(w
div 2),
3902 (gScreenHeight
div 2)-(h
div 2), MessageText
)
3904 e_CharFont_PrintFmt(gMenuFont
, (gScreenWidth
div 2)-(w
div 2),
3905 Round(gScreenHeight
/ 2.75)-(h
div 2), MessageText
);
3908 if IsDrawStat
or (gSpectMode
= 1) then DrawStat();
3910 if gSpectHUD
and (not gChatShow
) and (gSpectMode
<> SPECT_NONE
) and (not gSpectAuto
) then
3912 // Draw spectator GUI
3915 e_TextureFontGetSize(gStdFont
, ww
, hh
);
3918 e_TextureFontPrintEx(0, gScreenHeight
- (hh
+2)*2, 'MODE: Stats', gStdFont
, 255, 255, 255, 1);
3920 e_TextureFontPrintEx(0, gScreenHeight
- (hh
+2)*2, 'MODE: Observe Map', gStdFont
, 255, 255, 255, 1);
3922 e_TextureFontPrintEx(0, gScreenHeight
- (hh
+2)*2, 'MODE: Watch Players', gStdFont
, 255, 255, 255, 1);
3924 e_TextureFontPrintEx(2*ww
, gScreenHeight
- (hh
+2), '< jump >', gStdFont
, 255, 255, 255, 1);
3925 if gSpectMode
= SPECT_STATS
then
3927 e_TextureFontPrintEx(16*ww
, gScreenHeight
- (hh
+2)*2, 'Autoview', gStdFont
, 255, 255, 255, 1);
3928 e_TextureFontPrintEx(16*ww
, gScreenHeight
- (hh
+2), '< fire >', gStdFont
, 255, 255, 255, 1);
3930 if gSpectMode
= SPECT_MAPVIEW
then
3932 e_TextureFontPrintEx(22*ww
, gScreenHeight
- (hh
+2)*2, '[-]', gStdFont
, 255, 255, 255, 1);
3933 e_TextureFontPrintEx(26*ww
, gScreenHeight
- (hh
+2)*2, 'Step ' + IntToStr(gSpectStep
), gStdFont
, 255, 255, 255, 1);
3934 e_TextureFontPrintEx(34*ww
, gScreenHeight
- (hh
+2)*2, '[+]', gStdFont
, 255, 255, 255, 1);
3935 e_TextureFontPrintEx(18*ww
, gScreenHeight
- (hh
+2), '<prev weap>', gStdFont
, 255, 255, 255, 1);
3936 e_TextureFontPrintEx(30*ww
, gScreenHeight
- (hh
+2), '<next weap>', gStdFont
, 255, 255, 255, 1);
3938 if gSpectMode
= SPECT_PLAYERS
then
3940 e_TextureFontPrintEx(22*ww
, gScreenHeight
- (hh
+2)*2, 'Player 1', gStdFont
, 255, 255, 255, 1);
3941 e_TextureFontPrintEx(20*ww
, gScreenHeight
- (hh
+2), '<left/right>', gStdFont
, 255, 255, 255, 1);
3942 if gSpectViewTwo
then
3944 e_TextureFontPrintEx(37*ww
, gScreenHeight
- (hh
+2)*2, 'Player 2', gStdFont
, 255, 255, 255, 1);
3945 e_TextureFontPrintEx(34*ww
, gScreenHeight
- (hh
+2), '<prev w/next w>', gStdFont
, 255, 255, 255, 1);
3946 e_TextureFontPrintEx(52*ww
, gScreenHeight
- (hh
+2)*2, '2x View', gStdFont
, 255, 255, 255, 1);
3947 e_TextureFontPrintEx(51*ww
, gScreenHeight
- (hh
+2), '<up/down>', gStdFont
, 255, 255, 255, 1);
3951 e_TextureFontPrintEx(35*ww
, gScreenHeight
- (hh
+2)*2, '2x View', gStdFont
, 255, 255, 255, 1);
3952 e_TextureFontPrintEx(34*ww
, gScreenHeight
- (hh
+2), '<up/down>', gStdFont
, 255, 255, 255, 1);
3958 if gPauseMain
and gGameOn
and (g_ActiveWindow
= nil) then
3960 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
3961 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
3963 e_CharFont_GetSize(gMenuFont
, _lc
[I_MENU_PAUSE
], w
, h
);
3964 e_CharFont_Print(gMenuFont
, (gScreenWidth
div 2)-(w
div 2),
3965 (gScreenHeight
div 2)-(h
div 2), _lc
[I_MENU_PAUSE
]);
3970 if (gState
= STATE_MENU
) then
3972 if (g_ActiveWindow
= nil) or (g_ActiveWindow
.BackTexture
= '') then DrawMenuBackground('MENU_BACKGROUND');
3973 // F3 at menu will show game loading dialog
3974 if e_KeyPressed(IK_F3
) then g_Menu_Show_LoadMenu(true);
3975 if (g_ActiveWindow
<> nil) then
3977 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
3978 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
3982 // F3 at titlepic will show game loading dialog
3983 if e_KeyPressed(IK_F3
) then
3985 g_Menu_Show_LoadMenu(true);
3986 if (g_ActiveWindow
<> nil) then e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
3991 if gState
= STATE_FOLD
then
3993 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 0, 0, 0, EndingGameCounter
);
3996 if gState
= STATE_INTERCUSTOM
then
3998 if gLastMap
and (gGameSettings
.GameMode
= GM_COOP
) then
4000 back
:= 'TEXTURE_endpic';
4001 if not g_Texture_Get(back
, ID
) then
4002 back
:= _lc
[I_TEXTURE_ENDPIC
];
4007 DrawMenuBackground(back
);
4011 if g_ActiveWindow
<> nil then
4013 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4014 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4018 if gState
= STATE_INTERSINGLE
then
4020 if EndingGameCounter
> 0 then
4022 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 0, 0, 0, EndingGameCounter
);
4028 DrawMenuBackground(back
);
4032 if g_ActiveWindow
<> nil then
4034 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4035 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4040 if gState
= STATE_ENDPIC
then
4043 if g_Texture_Get('TEXTURE_endpic', ID
) then DrawMenuBackground('TEXTURE_endpic')
4044 else DrawMenuBackground(_lc
[I_TEXTURE_ENDPIC
]);
4046 if g_ActiveWindow
<> nil then
4048 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4049 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4053 if gState
= STATE_SLIST
then
4055 // if g_Texture_Get('MENU_BACKGROUND', ID) then
4057 // e_DrawSize(ID, 0, 0, 0, False, False, gScreenWidth, gScreenHeight);
4058 // //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4060 DrawMenuBackground('MENU_BACKGROUND');
4061 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4062 g_Serverlist_Draw(slCurrent
, slTable
);
4066 if g_ActiveWindow
<> nil then
4070 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4071 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4073 g_ActiveWindow
.Draw();
4080 if g_debug_Sounds
and gGameOn
then
4082 for w
:= 0 to High(e_SoundsArray
) do
4083 for h
:= 0 to e_SoundsArray
[w
].nRefs
do
4084 e_DrawPoint(1, w
+100, h
+100, 255, 0, 0);
4089 e_TextureFontPrint(0, 0, Format('FPS: %d', [FPS
]), gStdFont
);
4090 e_TextureFontPrint(0, 16, Format('UPS: %d', [UPS
]), gStdFont
);
4093 if gGameOn
and gShowTime
then
4094 drawTime(gScreenWidth
-72, gScreenHeight
-16);
4096 if gGameOn
then drawProfilers();
4098 {$IFDEF ENABLE_HOLMES}
4105 procedure g_Game_Quit();
4107 g_Game_StopAllSounds(True);
4109 g_Game_SaveOptions();
4111 g_PlayerModel_FreeData();
4112 g_Texture_DeleteAll();
4113 g_Frames_DeleteAll();
4115 //g_Menu_Free(); //k8: this segfaults after resolution change; who cares?
4118 if NetInitDone
then g_Net_Free
;
4120 // Íàäî óäàëèòü êàðòó ïîñëå òåñòà:
4121 if gMapToDelete
<> '' then
4122 g_Game_DeleteTestMap();
4128 procedure g_FatalError(Text: String);
4130 g_Console_Add(Format(_lc
[I_FATAL_ERROR
], [Text]), True);
4131 e_WriteLog(Format(_lc
[I_FATAL_ERROR
], [Text]), TMsgType
.Warning
);
4133 gExit
:= EXIT_SIMPLE
;
4136 procedure g_SimpleError(Text: String);
4138 g_Console_Add(Format(_lc
[I_SIMPLE_ERROR
], [Text]), True);
4139 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], [Text]), TMsgType
.Warning
);
4142 procedure g_Game_SetupScreenSize();
4144 RES_FACTOR
= 4.0 / 3.0;
4150 // Ðàçìåð ýêðàíîâ èãðîêîâ:
4151 gPlayerScreenSize
.X
:= gScreenWidth
-196;
4152 if (gPlayer1
<> nil) and (gPlayer2
<> nil) then
4153 gPlayerScreenSize
.Y
:= gScreenHeight
div 2
4155 gPlayerScreenSize
.Y
:= gScreenHeight
;
4157 // Ðàçìåð çàäíåãî ïëàíà:
4158 if BackID
<> DWORD(-1) then
4161 if (gScreenWidth
*s
> gMapInfo
.Width
) or
4162 (gScreenHeight
*s
> gMapInfo
.Height
) then
4164 gBackSize
.X
:= gScreenWidth
;
4165 gBackSize
.Y
:= gScreenHeight
;
4169 e_GetTextureSize(BackID
, @bw
, @bh
);
4170 rf
:= Single(bw
) / Single(bh
);
4171 if (rf
> RES_FACTOR
) then bw
:= Round(Single(bh
) * RES_FACTOR
)
4172 else if (rf
< RES_FACTOR
) then bh
:= Round(Single(bw
) / RES_FACTOR
);
4173 s
:= Max(gScreenWidth
/ bw
, gScreenHeight
/ bh
);
4174 if (s
< 1.0) then s
:= 1.0;
4175 gBackSize
.X
:= Round(bw
*s
);
4176 gBackSize
.Y
:= Round(bh
*s
);
4181 procedure g_Game_ChangeResolution(newWidth
, newHeight
: Word; nowFull
, nowMax
: Boolean);
4183 sys_SetDisplayMode(newWidth
, newHeight
, gBPP
, nowFull
);
4186 procedure g_Game_AddPlayer(Team
: Byte = TEAM_NONE
);
4188 if ((not gGameOn
) and (gState
<> STATE_INTERCUSTOM
))
4189 or (not (gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
])) then
4191 if gPlayer1
= nil then
4193 if g_Game_IsClient
then
4195 if NetPlrUID1
> -1 then
4197 MC_SEND_CheatRequest(NET_CHEAT_SPECTATE
);
4198 gPlayer1
:= g_Player_Get(NetPlrUID1
);
4203 if not (Team
in [TEAM_RED
, TEAM_BLUE
]) then
4204 Team
:= gPlayer1Settings
.Team
;
4206 // Ñîçäàíèå ïåðâîãî èãðîêà:
4207 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4208 gPlayer1Settings
.Color
,
4210 if gPlayer1
= nil then
4211 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]))
4214 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4215 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [gPlayer1
.Name
]), True);
4216 if g_Game_IsServer
and g_Game_IsNet
then
4217 MH_SEND_PlayerCreate(gPlayer1
.UID
);
4218 gPlayer1
.Respawn(False, True);
4219 g_Net_Slist_ServerPlayerComes();
4224 if gPlayer2
= nil then
4226 if g_Game_IsClient
then
4228 if NetPlrUID2
> -1 then
4229 gPlayer2
:= g_Player_Get(NetPlrUID2
);
4233 if not (Team
in [TEAM_RED
, TEAM_BLUE
]) then
4234 Team
:= gPlayer2Settings
.Team
;
4236 // Ñîçäàíèå âòîðîãî èãðîêà:
4237 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
4238 gPlayer2Settings
.Color
,
4240 if gPlayer2
= nil then
4241 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]))
4244 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
4245 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [gPlayer2
.Name
]), True);
4246 if g_Game_IsServer
and g_Game_IsNet
then
4247 MH_SEND_PlayerCreate(gPlayer2
.UID
);
4248 gPlayer2
.Respawn(False, True);
4249 g_Net_Slist_ServerPlayerComes();
4256 procedure g_Game_RemovePlayer();
4260 if ((not gGameOn
) and (gState
<> STATE_INTERCUSTOM
))
4261 or (not (gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
])) then
4266 if g_Game_IsServer
then
4269 Pl
.Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
4270 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [Pl
.Name
]), True);
4271 g_Player_Remove(Pl
.UID
);
4272 g_Net_Slist_ServerPlayerLeaves();
4280 if g_Game_IsServer
then
4283 Pl
.Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
4284 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [Pl
.Name
]), True);
4285 g_Player_Remove(Pl
.UID
);
4286 g_Net_Slist_ServerPlayerLeaves();
4290 MC_SEND_CheatRequest(NET_CHEAT_SPECTATE
);
4294 g_Net_Slist_ServerPlayerLeaves();
4297 procedure g_Game_Spectate();
4299 g_Game_RemovePlayer();
4300 if gPlayer1
<> nil then
4301 g_Game_RemovePlayer();
4304 procedure g_Game_SpectateCenterView();
4306 gSpectX
:= Max(gMapInfo
.Width
div 2 - gScreenWidth
div 2, 0);
4307 gSpectY
:= Max(gMapInfo
.Height
div 2 - gScreenHeight
div 2, 0);
4310 procedure g_Game_StartSingle(Map
: String; TwoPlayers
: Boolean; nPlayers
: Byte);
4317 e_WriteLog('Starting singleplayer game...', TMsgType
.Notify
);
4319 g_Game_ClearLoading();
4322 FillByte(gGameSettings
, SizeOf(TGameSettings
), 0);
4325 gGameSettings
.GameType
:= GT_SINGLE
;
4326 gGameSettings
.MaxLives
:= 0;
4327 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_ALLOWEXIT
;
4328 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_MONSTERS
;
4329 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_BOTVSMONSTER
;
4330 gSwitchGameMode
:= GM_SINGLE
;
4332 g_Game_ExecuteEvent('ongamestart');
4334 // Óñòàíîâêà ðàçìåðîâ îêîí èãðîêîâ:
4335 g_Game_SetupScreenSize();
4337 // Ñîçäàíèå ïåðâîãî èãðîêà:
4338 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4339 gPlayer1Settings
.Color
,
4340 gPlayer1Settings
.Team
, False));
4341 if gPlayer1
= nil then
4343 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
4347 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4350 // Ñîçäàíèå âòîðîãî èãðîêà, åñëè åñòü:
4353 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
4354 gPlayer2Settings
.Color
,
4355 gPlayer2Settings
.Team
, False));
4356 if gPlayer2
= nil then
4358 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
4362 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
4366 // Çàãðóçêà è çàïóñê êàðòû:
4367 if not g_Game_StartMap(false{asMegawad}, MAP
, True) then
4369 if (Pos(':\', Map
) > 0) or (Pos(':/', Map
) > 0) then tmps
:= Map
else tmps
:= gGameSettings
.WAD
+ ':\' + MAP
;
4370 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [tmps
]));
4374 // Íàñòðîéêè èãðîêîâ è áîòîâ:
4378 for i
:= nPl
+1 to nPlayers
do
4379 g_Player_Create(STD_PLAYER_MODEL
, _RGB(0, 0, 0), 0, True);
4382 procedure g_Game_StartCustom(Map
: String; GameMode
: Byte;
4383 TimeLimit
, GoalLimit
: Word;
4385 Options
: LongWord; nPlayers
: Byte);
4391 e_WriteLog('Starting custom game...', TMsgType
.Notify
);
4393 g_Game_ClearLoading();
4396 gGameSettings
.GameType
:= GT_CUSTOM
;
4397 gGameSettings
.GameMode
:= GameMode
;
4398 gSwitchGameMode
:= GameMode
;
4399 gGameSettings
.TimeLimit
:= TimeLimit
;
4400 gGameSettings
.GoalLimit
:= GoalLimit
;
4401 gGameSettings
.MaxLives
:= IfThen(GameMode
= GM_CTF
, 0, MaxLives
);
4402 gGameSettings
.Options
:= Options
;
4404 gCoopTotalMonstersKilled
:= 0;
4405 gCoopTotalSecretsFound
:= 0;
4406 gCoopTotalMonsters
:= 0;
4407 gCoopTotalSecrets
:= 0;
4411 g_Game_ExecuteEvent('ongamestart');
4413 // Óñòàíîâêà ðàçìåðîâ îêîí èãðîêîâ:
4414 g_Game_SetupScreenSize();
4416 // Ðåæèì íàáëþäàòåëÿ:
4417 if nPlayers
= 0 then
4424 if nPlayers
>= 1 then
4426 // Ñîçäàíèå ïåðâîãî èãðîêà:
4427 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4428 gPlayer1Settings
.Color
,
4429 gPlayer1Settings
.Team
, False));
4430 if gPlayer1
= nil then
4432 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
4436 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4440 if nPlayers
>= 2 then
4442 // Ñîçäàíèå âòîðîãî èãðîêà:
4443 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
4444 gPlayer2Settings
.Color
,
4445 gPlayer2Settings
.Team
, False));
4446 if gPlayer2
= nil then
4448 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
4452 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
4456 // Çàãðóçêà è çàïóñê êàðòû:
4457 if not g_Game_StartMap(true{asMegawad}, Map
, True) then
4459 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [Map
]));
4463 // Íåò òî÷åê ïîÿâëåíèÿ:
4464 if (g_Map_GetPointCount(RESPAWNPOINT_PLAYER1
) +
4465 g_Map_GetPointCount(RESPAWNPOINT_PLAYER2
) +
4466 g_Map_GetPointCount(RESPAWNPOINT_DM
) +
4467 g_Map_GetPointCount(RESPAWNPOINT_RED
)+
4468 g_Map_GetPointCount(RESPAWNPOINT_BLUE
)) < 1 then
4470 g_FatalError(_lc
[I_GAME_ERROR_GET_SPAWN
]);
4474 // Íàñòðîéêè èãðîêîâ è áîòîâ:
4478 for i
:= nPl
+1 to nPlayers
do
4479 g_Player_Create(STD_PLAYER_MODEL
, _RGB(0, 0, 0), 0, True);
4482 procedure g_Game_StartServer(Map
: String; GameMode
: Byte;
4483 TimeLimit
, GoalLimit
: Word; MaxLives
: Byte;
4484 Options
: LongWord; nPlayers
: Byte;
4485 IPAddr
: LongWord; Port
: Word);
4488 g_Net_Slist_ServerClosed();
4490 e_WriteLog('Starting net game (server)...', TMsgType
.Notify
);
4492 g_Game_ClearLoading();
4495 gGameSettings
.GameType
:= GT_SERVER
;
4496 gGameSettings
.GameMode
:= GameMode
;
4497 gSwitchGameMode
:= GameMode
;
4498 gGameSettings
.TimeLimit
:= TimeLimit
;
4499 gGameSettings
.GoalLimit
:= GoalLimit
;
4500 gGameSettings
.MaxLives
:= IfThen(GameMode
= GM_CTF
, 0, MaxLives
);
4501 gGameSettings
.Options
:= Options
;
4503 gCoopTotalMonstersKilled
:= 0;
4504 gCoopTotalSecretsFound
:= 0;
4505 gCoopTotalMonsters
:= 0;
4506 gCoopTotalSecrets
:= 0;
4510 g_Game_ExecuteEvent('ongamestart');
4512 // Óñòàíîâêà ðàçìåðîâ îêíà èãðîêà
4513 g_Game_SetupScreenSize();
4515 // Ðåæèì íàáëþäàòåëÿ:
4516 if nPlayers
= 0 then
4522 if nPlayers
>= 1 then
4524 // Ñîçäàíèå ïåðâîãî èãðîêà:
4525 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4526 gPlayer1Settings
.Color
,
4527 gPlayer1Settings
.Team
, False));
4528 if gPlayer1
= nil then
4530 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
4534 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4537 if nPlayers
>= 2 then
4539 // Ñîçäàíèå âòîðîãî èãðîêà:
4540 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
4541 gPlayer2Settings
.Color
,
4542 gPlayer2Settings
.Team
, False));
4543 if gPlayer2
= nil then
4545 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
4549 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
4552 g_Game_SetLoadingText(_lc
[I_LOAD_HOST
], 0, False);
4553 if NetForwardPorts
then
4554 g_Game_SetLoadingText(_lc
[I_LOAD_PORTS
], 0, False);
4557 if not g_Net_Host(IPAddr
, Port
, NetMaxClients
) then
4559 g_FatalError(_lc
[I_NET_MSG
] + _lc
[I_NET_ERR_HOST
]);
4563 g_Net_Slist_Set(NetSlistIP
, NetSlistPort
, NetSlistList
);
4565 g_Net_Slist_ServerStarted();
4567 // Çàãðóçêà è çàïóñê êàðòû:
4568 if not g_Game_StartMap(false{asMegawad}, Map
, True) then
4570 g_Net_Slist_ServerClosed();
4571 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [Map
]));
4575 // Íåò òî÷åê ïîÿâëåíèÿ:
4576 if (g_Map_GetPointCount(RESPAWNPOINT_PLAYER1
) +
4577 g_Map_GetPointCount(RESPAWNPOINT_PLAYER2
) +
4578 g_Map_GetPointCount(RESPAWNPOINT_DM
) +
4579 g_Map_GetPointCount(RESPAWNPOINT_RED
)+
4580 g_Map_GetPointCount(RESPAWNPOINT_BLUE
)) < 1 then
4582 g_Net_Slist_ServerClosed();
4583 g_FatalError(_lc
[I_GAME_ERROR_GET_SPAWN
]);
4587 // Íàñòðîéêè èãðîêîâ è áîòîâ:
4590 g_Net_Slist_ServerMapStarted();
4591 NetState
:= NET_STATE_GAME
;
4594 procedure g_Game_StartClient(Addr
: String; Port
: Word; PW
: String);
4609 e_WriteLog('Starting net game (client)...', TMsgType
.Notify
);
4610 e_WriteLog('NET: Trying to connect to ' + Addr
+ ':' + IntToStr(Port
) + '...', TMsgType
.Notify
);
4612 g_Game_ClearLoading();
4615 gGameSettings
.GameType
:= GT_CLIENT
;
4617 gCoopTotalMonstersKilled
:= 0;
4618 gCoopTotalSecretsFound
:= 0;
4619 gCoopTotalMonsters
:= 0;
4620 gCoopTotalSecrets
:= 0;
4624 g_Game_ExecuteEvent('ongamestart');
4626 // Óñòàíîâêà ðàçìåðîâ îêîí èãðîêîâ:
4627 g_Game_SetupScreenSize();
4629 NetState
:= NET_STATE_AUTH
;
4631 g_Game_SetLoadingText(_lc
[I_LOAD_CONNECT
], 0, False);
4633 // create (or update) map/resource databases
4634 g_Res_CreateDatabases(true);
4637 if not g_Net_Connect(Addr
, Port
) then
4639 g_FatalError(_lc
[I_NET_MSG
] + _lc
[I_NET_ERR_CONN
]);
4640 NetState
:= NET_STATE_NONE
;
4644 g_Game_SetLoadingText(_lc
[I_LOAD_SEND_INFO
], 0, False);
4646 g_Game_SetLoadingText(_lc
[I_LOAD_WAIT_INFO
], 0, False);
4651 // fuck! https://www.mail-archive.com/enet-discuss@cubik.org/msg00852.html
4652 // tl;dr: on shitdows, we can get -1 sometimes, and it is *NOT* a failure.
4653 // thank you, enet. let's ignore failures altogether then.
4654 while (enet_host_service(NetHost
, @NetEvent
, 50) > 0) do
4656 if (NetEvent
.kind
= ENET_EVENT_TYPE_RECEIVE
) then
4658 if (NetEvent
.channelID
= NET_CHAN_DOWNLOAD_EX
) then
4660 // ignore all download packets, they're processed by separate code
4661 enet_packet_destroy(NetEvent
.packet
);
4664 Ptr
:= NetEvent
.packet
^.data
;
4665 if not InMsg
.Init(Ptr
, NetEvent
.packet
^.dataLength
, True) then
4667 enet_packet_destroy(NetEvent
.packet
);
4671 InMsg
.ReadLongWord(); // skip size
4672 MID
:= InMsg
.ReadByte();
4674 if (MID
= NET_MSG_INFO
) and (State
= 0) then
4676 NetMyID
:= InMsg
.ReadByte();
4677 NetPlrUID1
:= InMsg
.ReadWord();
4679 WadName
:= InMsg
.ReadString();
4680 Map
:= InMsg
.ReadString();
4682 gWADHash
:= InMsg
.ReadMD5();
4684 gGameSettings
.GameMode
:= InMsg
.ReadByte();
4685 gSwitchGameMode
:= gGameSettings
.GameMode
;
4686 gGameSettings
.GoalLimit
:= InMsg
.ReadWord();
4687 gGameSettings
.TimeLimit
:= InMsg
.ReadWord();
4688 gGameSettings
.MaxLives
:= InMsg
.ReadByte();
4689 gGameSettings
.Options
:= InMsg
.ReadLongWord();
4690 T
:= InMsg
.ReadLongWord();
4692 //newResPath := g_Res_SearchSameWAD(MapsDir, WadName, gWADHash);
4693 //if newResPath = '' then
4695 //g_Game_SetLoadingText(_lc[I_LOAD_DL_RES], 0, False);
4696 newResPath
:= g_Res_DownloadMapWAD(WadName
, gWADHash
);
4697 if newResPath
= '' then
4699 g_FatalError(_lc
[I_NET_ERR_HASH
]);
4700 enet_packet_destroy(NetEvent
.packet
);
4701 NetState
:= NET_STATE_NONE
;
4704 e_LogWritefln('using downloaded map wad [%s] for [%s]`', [newResPath
, WadName
], TMsgType
.Notify
);
4706 //newResPath := ExtractRelativePath(MapsDir, newResPath);
4709 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4710 gPlayer1Settings
.Color
,
4711 gPlayer1Settings
.Team
, False));
4713 if gPlayer1
= nil then
4715 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
4717 enet_packet_destroy(NetEvent
.packet
);
4718 NetState
:= NET_STATE_NONE
;
4722 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4723 gPlayer1
.UID
:= NetPlrUID1
;
4724 gPlayer1
.Reset(True);
4726 if not g_Game_StartMap(false{asMegawad}, newResPath
+ ':\' + Map
, True) then
4728 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [WadName
+ ':\' + Map
]));
4730 enet_packet_destroy(NetEvent
.packet
);
4731 NetState
:= NET_STATE_NONE
;
4739 enet_packet_destroy(NetEvent
.packet
);
4743 enet_packet_destroy(NetEvent
.packet
);
4747 if (NetEvent
.kind
= ENET_EVENT_TYPE_DISCONNECT
) then
4750 if (NetEvent
.data
<= NET_DISC_MAX
) then
4751 g_Console_Add(_lc
[I_NET_MSG_ERROR
] + _lc
[I_NET_ERR_CONN
] + ' ' +
4752 _lc
[TStrings_Locale(Cardinal(I_NET_DISC_NONE
) + NetEvent
.data
)], True);
4759 ProcessLoading(true);
4761 if g_Net_UserRequestExit() then
4770 g_FatalError(_lc
[I_NET_MSG
] + _lc
[I_NET_ERR_CONN
]);
4771 NetState
:= NET_STATE_NONE
;
4775 gLMSRespawn
:= LMS_RESPAWN_NONE
;
4776 gLMSRespawnTime
:= 0;
4779 NetState
:= NET_STATE_GAME
;
4780 MC_SEND_FullStateRequest
;
4781 e_WriteLog('NET: Connection successful.', TMsgType
.Notify
);
4784 procedure g_Game_SaveOptions
;
4787 s
:= e_GetWriteableDir(ConfigDirs
);
4789 g_Options_Write_Video(s
+ '/' + CONFIG_FILENAME
)
4791 e_LogWritefln('unable to find or create directory for configs', []);
4795 lastAsMegaWad
: Boolean = false;
4797 procedure g_Game_ChangeMap(const MapPath
: String);
4801 g_Game_ClearLoading();
4803 Force
:= gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
];
4804 // Åñëè óðîâåíü çàâåðøèëñÿ ïî òðèããåðó Âûõîä, íå î÷èùàòü èíâåíòàðü
4805 if gExitByTrigger
then
4808 gExitByTrigger
:= False;
4810 if not g_Game_StartMap(lastAsMegaWad
, MapPath
, Force
) then
4811 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [MapPath
]));
4814 procedure g_Game_Restart();
4818 if g_Game_IsClient
then
4820 map
:= g_ExtractFileName(gMapInfo
.Map
);
4821 e_LogWritefln('g_Game_Restart: map = "%s" gCurrentMapFileName = "%s"', [map
, gCurrentMapFileName
]);
4825 g_Game_ClearLoading();
4826 g_Game_StartMap(lastAsMegaWad
, Map
, True, gCurrentMapFileName
);
4829 function g_Game_StartMap (asMegawad
: Boolean; Map
: String; Force
: Boolean = False; const oldMapPath
: AnsiString=''): Boolean;
4831 NewWAD
, ResName
: String;
4835 g_Map_Free((Map
<> gCurrentMapFileName
) and (oldMapPath
<> gCurrentMapFileName
));
4836 g_Player_RemoveAllCorpses();
4838 if (not g_Game_IsClient
) and
4839 (gSwitchGameMode
<> gGameSettings
.GameMode
) and
4840 (gGameSettings
.GameMode
<> GM_SINGLE
) then
4842 if gSwitchGameMode
= GM_CTF
then
4843 gGameSettings
.MaxLives
:= 0;
4844 gGameSettings
.GameMode
:= gSwitchGameMode
;
4847 gSwitchGameMode
:= gGameSettings
.GameMode
;
4849 g_Player_ResetTeams();
4851 lastAsMegaWad
:= asMegawad
;
4852 if isWadPath(Map
) then
4854 NewWAD
:= g_ExtractWadName(Map
);
4855 ResName
:= g_ExtractFileName(Map
);
4856 if g_Game_IsServer
then
4858 nws
:= findDiskWad(NewWAD
);
4859 //writeln('000: Map=[', Map, ']; nws=[', nws, ']; NewWAD=[', NewWAD, ']');
4862 if (length(nws
) = 0) then nws
:= e_FindWad(MegawadDirs
, NewWAD
);
4863 if (length(nws
) = 0) then nws
:= e_FindWad(MapDirs
, NewWAD
);
4867 if (length(nws
) = 0) then nws
:= e_FindWad(MapDirs
, NewWAD
);
4868 if (length(nws
) = 0) then nws
:= e_FindWad(MegawadDirs
, NewWAD
);
4870 //if (length(nws) = 0) then nws := e_FindWad(MapDownloadDirs, NewWAD);
4871 //writeln('001: Map=[', Map, ']; nws=[', nws, ']; NewWAD=[', NewWAD, ']');
4873 if (length(nws
) = 0) then
4875 ResName
:= ''; // failed
4880 if (g_Game_IsNet
) then gWADHash
:= MD5File(nws
);
4881 //writeln('********: nws=', nws, ' : Map=', Map, ' : nw=', NewWAD, ' : resname=', ResName);
4882 g_Game_LoadWAD(NewWAD
);
4887 // hash received in MC_RECV_GameEvent -> NET_EV_MAPSTART
4888 NewWAD
:= g_Game_ClientWAD(NewWAD
, gWADHash
);
4893 NewWAD
:= gGameSettings
.WAD
;
4897 //writeln('********: gsw=', gGameSettings.WAD, '; rn=', ResName);
4899 if (ResName
<> '') and (NewWAD
<> '') then
4901 //result := g_Map_Load(gGameSettings.WAD + ':\' + ResName);
4902 result
:= g_Map_Load(NewWAD
+':\'+ResName
);
4906 g_Player_ResetAll(Force
or gLastMap
, gGameSettings
.GameType
= GT_SINGLE
);
4908 gState
:= STATE_NONE
;
4909 g_ActiveWindow
:= nil;
4915 if gGameSettings
.GameMode
= GM_CTF
then
4917 g_Map_ResetFlag(FLAG_RED
);
4918 g_Map_ResetFlag(FLAG_BLUE
);
4919 // CTF, à ôëàãîâ íåò:
4920 if not g_Map_HaveFlagPoints() then
4921 g_SimpleError(_lc
[I_GAME_ERROR_CTF
]);
4926 gState
:= STATE_MENU
;
4931 gPauseMain
:= false;
4932 gPauseHolmes
:= false;
4934 NetTimeToUpdate
:= 1;
4935 NetTimeToReliable
:= 0;
4936 NetTimeToMaster
:= NetMasterRate
;
4937 gLMSRespawn
:= LMS_RESPAWN_NONE
;
4938 gLMSRespawnTime
:= 0;
4939 gMissionFailed
:= False;
4942 gCoopMonstersKilled
:= 0;
4943 gCoopSecretsFound
:= 0;
4945 gVoteInProgress
:= False;
4946 gVotePassed
:= False;
4952 if not gGameOn
then Exit
;
4954 g_Game_SpectateCenterView();
4956 if (gGameSettings
.MaxLives
> 0) and (gGameSettings
.WarmupTime
> 0) then
4958 gLMSRespawn
:= LMS_RESPAWN_WARMUP
;
4959 gLMSRespawnTime
:= gTime
+ gGameSettings
.WarmupTime
*1000;
4960 gLMSSoftSpawn
:= True;
4961 if NetMode
= NET_SERVER
then
4962 MH_SEND_GameEvent(NET_EV_LMS_WARMUP
, (gLMSRespawnTime
- gTime
) div 1000)
4964 g_Console_Add(Format(_lc
[I_MSG_WARMUP_START
], [(gLMSRespawnTime
- gTime
) div 1000]), True);
4967 if NetMode
= NET_SERVER
then
4969 MH_SEND_GameEvent(NET_EV_MAPSTART
, gGameSettings
.GameMode
, Map
);
4972 g_Net_Slist_ServerMapStarted();
4974 if NetClients
<> nil then
4975 for I
:= 0 to High(NetClients
) do
4976 if NetClients
[I
].Used
then
4978 NetClients
[I
].Voted
:= False;
4979 if NetClients
[I
].RequestedFullUpdate
then
4981 MH_SEND_Everything((NetClients
[I
].State
= NET_STATE_AUTH
), I
);
4982 NetClients
[I
].RequestedFullUpdate
:= False;
4986 g_Net_UnbanNonPermHosts();
4991 gCoopTotalMonstersKilled
:= 0;
4992 gCoopTotalSecretsFound
:= 0;
4993 gCoopTotalMonsters
:= 0;
4994 gCoopTotalSecrets
:= 0;
4998 g_Game_ExecuteEvent('onmapstart');
5001 procedure SetFirstLevel
;
5005 MapList
:= g_Map_GetMapsList(gGameSettings
.WAD
);
5006 if MapList
= nil then
5009 SortSArray(MapList
);
5010 gNextMap
:= MapList
[Low(MapList
)];
5015 procedure g_Game_ExitLevel(const Map
: AnsiString);
5019 gCoopTotalMonstersKilled
:= gCoopTotalMonstersKilled
+ gCoopMonstersKilled
;
5020 gCoopTotalSecretsFound
:= gCoopTotalSecretsFound
+ gCoopSecretsFound
;
5021 gCoopTotalMonsters
:= gCoopTotalMonsters
+ gTotalMonsters
;
5022 gCoopTotalSecrets
:= gCoopTotalSecrets
+ gSecretsCount
;
5024 // Âûøëè â âûõîä â Îäèíî÷íîé èãðå:
5025 if gGameSettings
.GameType
= GT_SINGLE
then
5026 gExit
:= EXIT_ENDLEVELSINGLE
5027 else // Âûøëè â âûõîä â Ñâîåé èãðå
5029 gExit
:= EXIT_ENDLEVELCUSTOM
;
5030 if gGameSettings
.GameMode
= GM_COOP
then
5031 g_Player_RememberAll
;
5033 if not g_Map_Exist(gGameSettings
.WAD
+ ':\' + gNextMap
) then
5036 if gGameSettings
.GameMode
= GM_COOP
then
5039 gStatsPressed
:= True;
5040 gNextMap
:= 'MAP01';
5042 if not g_Map_Exist(gGameSettings
.WAD
+ ':\' + gNextMap
) then
5045 if g_Game_IsNet
then
5047 MH_SEND_GameStats();
5048 MH_SEND_CoopStats();
5054 procedure g_Game_RestartLevel();
5058 if gGameSettings
.GameMode
= GM_SINGLE
then
5063 gExit
:= EXIT_ENDLEVELCUSTOM
;
5064 Map
:= g_ExtractFileName(gMapInfo
.Map
);
5068 function g_Game_ClientWAD (NewWAD
: String; const WHash
: TMD5Digest
): AnsiString;
5070 gWAD
{, xwad}: String;
5073 if not g_Game_IsClient
then Exit
;
5074 //e_LogWritefln('*** g_Game_ClientWAD: `%s`', [NewWAD]);
5076 gWAD
:= g_Res_DownloadMapWAD(ExtractFileName(NewWAD
), WHash
);
5081 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_WAD
], [ExtractFileName(NewWAD
)]));
5086 xwad := ExtractRelativePath(MapsDir, gWAD);
5087 e_LogWritefln('using downloaded client map wad [%s] for [%s]`', [xwad, NewWAD], TMsgType.Notify);
5089 g_Game_LoadWAD(NewWAD);
5092 e_LogWritefln('using downloaded client map wad [%s]`', [NewWAD
], TMsgType
.Notify
);
5093 g_Game_LoadWAD(NewWAD
);
5097 if LowerCase(NewWAD) = LowerCase(gGameSettings.WAD) then Exit;
5098 gWAD := g_Res_SearchSameWAD(MapsDir, ExtractFileName(NewWAD), WHash);
5101 g_Game_SetLoadingText(_lc[I_LOAD_DL_RES], 0, False);
5102 gWAD := g_Res_DownloadMapWAD(ExtractFileName(NewWAD), WHash);
5106 g_FatalError(Format(_lc[I_GAME_ERROR_MAP_WAD], [ExtractFileName(NewWAD)]));
5110 NewWAD := ExtractRelativePath(MapsDir, gWAD);
5111 g_Game_LoadWAD(NewWAD);
5115 procedure g_Game_RestartRound(NoMapRestart
: Boolean = False);
5117 i
, n
, nb
, nr
: Integer;
5119 function monRespawn (mon
: TMonster
): Boolean;
5121 result
:= false; // don't stop
5122 if not mon
.FNoRespawn
then mon
.Respawn();
5126 if not g_Game_IsServer
then Exit
;
5127 if gLMSRespawn
= LMS_RESPAWN_NONE
then Exit
;
5128 gLMSRespawn
:= LMS_RESPAWN_NONE
;
5129 gLMSRespawnTime
:= 0;
5132 if (gGameSettings
.GameMode
= GM_COOP
) and not NoMapRestart
then
5134 gMissionFailed
:= True;
5135 g_Game_RestartLevel
;
5139 n
:= 0; nb
:= 0; nr
:= 0;
5140 for i
:= Low(gPlayers
) to High(gPlayers
) do
5141 if (gPlayers
[i
] <> nil) and
5142 ((not gPlayers
[i
].FSpectator
) or gPlayers
[i
].FWantsInGame
or
5143 (gPlayers
[i
] is TBot
)) then
5146 if gPlayers
[i
].Team
= TEAM_RED
then Inc(nr
)
5147 else if gPlayers
[i
].Team
= TEAM_BLUE
then Inc(nb
)
5150 if (n
< 2) or ((gGameSettings
.GameMode
= GM_TDM
) and ((nr
= 0) or (nb
= 0))) then
5152 // wait a second until the fuckers finally decide to join
5153 gLMSRespawn
:= LMS_RESPAWN_WARMUP
;
5154 gLMSRespawnTime
:= gTime
+ 1000;
5155 gLMSSoftSpawn
:= NoMapRestart
;
5159 g_Player_RemoveAllCorpses
;
5160 g_Game_Message(_lc
[I_MESSAGE_LMS_START
], 144);
5161 if g_Game_IsNet
then
5162 MH_SEND_GameEvent(NET_EV_LMS_START
);
5164 for i
:= Low(gPlayers
) to High(gPlayers
) do
5166 if gPlayers
[i
] = nil then continue
;
5167 if gPlayers
[i
] is TBot
then gPlayers
[i
].FWantsInGame
:= True;
5168 // don't touch normal spectators
5169 if gPlayers
[i
].FSpectator
and not gPlayers
[i
].FWantsInGame
then
5171 gPlayers
[i
].FNoRespawn
:= True;
5172 gPlayers
[i
].Lives
:= 0;
5173 if g_Game_IsNet
then
5174 MH_SEND_PlayerStats(gPlayers
[I
].UID
);
5177 gPlayers
[i
].FNoRespawn
:= False;
5178 gPlayers
[i
].Lives
:= gGameSettings
.MaxLives
;
5179 gPlayers
[i
].Respawn(False, True);
5180 if gGameSettings
.GameMode
= GM_COOP
then
5182 gPlayers
[i
].Frags
:= 0;
5183 gPlayers
[i
].RecallState
;
5185 if (gPlayer1
= nil) and (gLMSPID1
> 0) then
5186 gPlayer1
:= g_Player_Get(gLMSPID1
);
5187 if (gPlayer2
= nil) and (gLMSPID2
> 0) then
5188 gPlayer2
:= g_Player_Get(gLMSPID2
);
5191 g_Items_RestartRound();
5194 g_Mons_ForEach(monRespawn
);
5196 gLMSSoftSpawn
:= False;
5199 function g_Game_GetFirstMap(WAD
: String): String;
5203 MapList
:= g_Map_GetMapsList(WAD
);
5204 if MapList
= nil then
5207 SortSArray(MapList
);
5208 Result
:= MapList
[Low(MapList
)];
5210 if not g_Map_Exist(WAD
+ ':\' + Result
) then
5216 function g_Game_GetNextMap(): String;
5223 MapList
:= g_Map_GetMapsList(gGameSettings
.WAD
);
5224 if MapList
= nil then
5227 Map
:= g_ExtractFileName(gMapInfo
.Map
);
5229 SortSArray(MapList
);
5231 for I
:= Low(MapList
) to High(MapList
) do
5232 if Map
= MapList
[I
] then
5238 if MapIndex
<> -255 then
5240 if MapIndex
= High(MapList
) then
5241 Result
:= MapList
[Low(MapList
)]
5243 Result
:= MapList
[MapIndex
+ 1];
5245 if not g_Map_Exist(gGameSettings
.WAD
+ ':\' + Result
) then Result
:= Map
;
5251 procedure g_Game_NextLevel();
5253 if gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
, GM_COOP
] then
5254 gExit
:= EXIT_ENDLEVELCUSTOM
5257 gExit
:= EXIT_ENDLEVELSINGLE
;
5261 if gNextMap
<> '' then Exit
;
5262 gNextMap
:= g_Game_GetNextMap();
5265 function g_Game_IsTestMap(): Boolean;
5267 result
:= StrEquCI1251(TEST_MAP_NAME
, g_ExtractFileName(gMapInfo
.Map
));
5270 procedure g_Game_DeleteTestMap();
5273 //MapName: AnsiString;
5281 a
:= Pos('.wad:\', toLowerCase1251(gMapToDelete
));
5282 if (a
= 0) then a
:= Pos('.wad:/', toLowerCase1251(gMapToDelete
));
5283 if (a
= 0) then exit
;
5285 // Âûäåëÿåì èìÿ wad-ôàéëà è èìÿ êàðòû
5286 WadName
:= Copy(gMapToDelete
, 1, a
+3);
5287 Delete(gMapToDelete
, 1, a
+5);
5288 gMapToDelete
:= UpperCase(gMapToDelete
);
5290 //CopyMemory(@MapName[0], @gMapToDelete[1], Min(16, Length(gMapToDelete)));
5293 // Èìÿ êàðòû íå ñòàíäàðòíîå òåñòîâîå:
5294 if MapName <> TEST_MAP_NAME then
5297 if not gTempDelete then
5299 time := g_GetFileTime(WadName);
5300 WAD := TWADFile.Create();
5303 if not WAD.ReadFile(WadName) then
5304 begin // Íåò òàêîãî WAD-ôàéëà
5309 // Ñîñòàâëÿåì ñïèñîê êàðò è èùåì íóæíóþ:
5311 MapList := WAD.GetResourcesList('');
5313 if MapList <> nil then
5314 for a := 0 to High(MapList) do
5315 if MapList[a] = MapName then
5317 // Óäàëÿåì è ñîõðàíÿåì:
5318 WAD.RemoveResource('', MapName);
5319 WAD.SaveTo(WadName);
5324 g_SetFileTime(WadName, time);
5327 if gTempDelete
then DeleteFile(WadName
);
5330 procedure GameCVars(P
: SSArray
);
5333 stat
: TPlayerStatArray
;
5338 cmd
:= LowerCase(P
[0]);
5339 if (cmd
= 'g_friendlyfire') and not g_Game_IsClient
then
5341 with gGameSettings
do
5343 if (Length(P
) > 1) and
5344 ((P
[1] = '1') or (P
[1] = '0')) then
5346 if (P
[1][1] = '1') then
5347 Options
:= Options
or GAME_OPTION_TEAMDAMAGE
5349 Options
:= Options
and (not GAME_OPTION_TEAMDAMAGE
);
5352 if (LongBool(Options
and GAME_OPTION_TEAMDAMAGE
)) then
5353 g_Console_Add(_lc
[I_MSG_FRIENDLY_FIRE_ON
])
5355 g_Console_Add(_lc
[I_MSG_FRIENDLY_FIRE_OFF
]);
5357 if g_Game_IsNet
then MH_SEND_GameSettings
;
5360 else if (cmd
= 'g_weaponstay') and not g_Game_IsClient
then
5362 with gGameSettings
do
5364 if (Length(P
) > 1) and
5365 ((P
[1] = '1') or (P
[1] = '0')) then
5367 if (P
[1][1] = '1') then
5368 Options
:= Options
or GAME_OPTION_WEAPONSTAY
5370 Options
:= Options
and (not GAME_OPTION_WEAPONSTAY
);
5373 if (LongBool(Options
and GAME_OPTION_WEAPONSTAY
)) then
5374 g_Console_Add(_lc
[I_MSG_WEAPONSTAY_ON
])
5376 g_Console_Add(_lc
[I_MSG_WEAPONSTAY_OFF
]);
5378 if g_Game_IsNet
then MH_SEND_GameSettings
;
5381 else if cmd
= 'g_gamemode' then
5383 a
:= g_Game_TextToMode(P
[1]);
5384 if a
= GM_SINGLE
then a
:= GM_COOP
;
5385 if (Length(P
) > 1) and (a
<> GM_NONE
) and (not g_Game_IsClient
) then
5387 gSwitchGameMode
:= a
;
5388 if (gGameOn
and (gGameSettings
.GameMode
= GM_SINGLE
)) or
5389 (gState
= STATE_INTERSINGLE
) then
5390 gSwitchGameMode
:= GM_SINGLE
;
5392 gGameSettings
.GameMode
:= gSwitchGameMode
;
5394 if gSwitchGameMode
= gGameSettings
.GameMode
then
5395 g_Console_Add(Format(_lc
[I_MSG_GAMEMODE_CURRENT
],
5396 [g_Game_ModeToText(gGameSettings
.GameMode
)]))
5398 g_Console_Add(Format(_lc
[I_MSG_GAMEMODE_CHANGE
],
5399 [g_Game_ModeToText(gGameSettings
.GameMode
),
5400 g_Game_ModeToText(gSwitchGameMode
)]));
5402 else if (cmd
= 'g_allow_exit') and not g_Game_IsClient
then
5404 with gGameSettings
do
5406 if (Length(P
) > 1) and
5407 ((P
[1] = '1') or (P
[1] = '0')) then
5409 if (P
[1][1] = '1') then
5410 Options
:= Options
or GAME_OPTION_ALLOWEXIT
5412 Options
:= Options
and (not GAME_OPTION_ALLOWEXIT
);
5415 if (LongBool(Options
and GAME_OPTION_ALLOWEXIT
)) then
5416 g_Console_Add(_lc
[I_MSG_ALLOWEXIT_ON
])
5418 g_Console_Add(_lc
[I_MSG_ALLOWEXIT_OFF
]);
5419 g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
5421 if g_Game_IsNet
then MH_SEND_GameSettings
;
5424 else if (cmd
= 'g_allow_monsters') and not g_Game_IsClient
then
5426 with gGameSettings
do
5428 if (Length(P
) > 1) and
5429 ((P
[1] = '1') or (P
[1] = '0')) then
5431 if (P
[1][1] = '1') then
5432 Options
:= Options
or GAME_OPTION_MONSTERS
5434 Options
:= Options
and (not GAME_OPTION_MONSTERS
);
5437 if (LongBool(Options
and GAME_OPTION_MONSTERS
)) then
5438 g_Console_Add(_lc
[I_MSG_ALLOWMON_ON
])
5440 g_Console_Add(_lc
[I_MSG_ALLOWMON_OFF
]);
5441 g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
5443 if g_Game_IsNet
then MH_SEND_GameSettings
;
5446 else if (cmd
= 'g_bot_vsplayers') and not g_Game_IsClient
then
5448 with gGameSettings
do
5450 if (Length(P
) > 1) and
5451 ((P
[1] = '1') or (P
[1] = '0')) then
5453 if (P
[1][1] = '1') then
5454 Options
:= Options
or GAME_OPTION_BOTVSPLAYER
5456 Options
:= Options
and (not GAME_OPTION_BOTVSPLAYER
);
5459 if (LongBool(Options
and GAME_OPTION_BOTVSPLAYER
)) then
5460 g_Console_Add(_lc
[I_MSG_BOTSVSPLAYERS_ON
])
5462 g_Console_Add(_lc
[I_MSG_BOTSVSPLAYERS_OFF
]);
5464 if g_Game_IsNet
then MH_SEND_GameSettings
;
5467 else if (cmd
= 'g_bot_vsmonsters') and not g_Game_IsClient
then
5469 with gGameSettings
do
5471 if (Length(P
) > 1) and
5472 ((P
[1] = '1') or (P
[1] = '0')) then
5474 if (P
[1][1] = '1') then
5475 Options
:= Options
or GAME_OPTION_BOTVSMONSTER
5477 Options
:= Options
and (not GAME_OPTION_BOTVSMONSTER
);
5480 if (LongBool(Options
and GAME_OPTION_BOTVSMONSTER
)) then
5481 g_Console_Add(_lc
[I_MSG_BOTSVSMONSTERS_ON
])
5483 g_Console_Add(_lc
[I_MSG_BOTSVSMONSTERS_OFF
]);
5485 if g_Game_IsNet
then MH_SEND_GameSettings
;
5488 else if (cmd
= 'g_warmuptime') and not g_Game_IsClient
then
5490 if Length(P
) > 1 then
5492 if StrToIntDef(P
[1], gGameSettings
.WarmupTime
) = 0 then
5493 gGameSettings
.WarmupTime
:= 30
5495 gGameSettings
.WarmupTime
:= StrToIntDef(P
[1], gGameSettings
.WarmupTime
);
5498 g_Console_Add(Format(_lc
[I_MSG_WARMUP
],
5499 [gGameSettings
.WarmupTime
]));
5500 g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
5502 else if cmd
= 'net_interp' then
5504 if (Length(P
) > 1) then
5505 NetInterpLevel
:= StrToIntDef(P
[1], NetInterpLevel
);
5506 g_Console_Add('net_interp = ' + IntToStr(NetInterpLevel
));
5507 s
:= e_GetWriteableDir(ConfigDirs
);
5510 config
:= TConfig
.CreateFile(s
+ '/' + CONFIG_FILENAME
);
5511 config
.WriteInt('Client', 'InterpolationSteps', NetInterpLevel
);
5512 config
.SaveFile(s
+ '/' + CONFIG_FILENAME
);
5516 else if cmd
= 'net_forceplayerupdate' then
5518 if (Length(P
) > 1) and ((P
[1] = '1') or (P
[1] = '0')) then
5519 NetForcePlayerUpdate
:= (P
[1][1] = '1');
5521 if NetForcePlayerUpdate
then
5522 g_Console_Add('net_forceplayerupdate = 1')
5524 g_Console_Add('net_forceplayerupdate = 0');
5526 s
:= e_GetWriteableDir(ConfigDirs
);
5529 config
:= TConfig
.CreateFile(s
+ '/' + CONFIG_FILENAME
);
5530 config
.WriteBool('Client', 'ForcePlayerUpdate', NetForcePlayerUpdate
);
5531 config
.SaveFile(s
+ '/' + CONFIG_FILENAME
);
5535 else if cmd
= 'net_predictself' then
5537 if (Length(P
) > 1) and
5538 ((P
[1] = '1') or (P
[1] = '0')) then
5539 NetPredictSelf
:= (P
[1][1] = '1');
5541 if NetPredictSelf
then
5542 g_Console_Add('net_predictself = 1')
5544 g_Console_Add('net_predictself = 0');
5546 s
:= e_GetWriteableDir(ConfigDirs
);
5549 config
:= TConfig
.CreateFile(s
+ '/' + CONFIG_FILENAME
);
5550 config
.WriteBool('Client', 'PredictSelf', NetPredictSelf
);
5551 config
.SaveFile(s
+ '/' + CONFIG_FILENAME
);
5555 else if cmd
= 'sv_name' then
5557 if (Length(P
) > 1) and (Length(P
[1]) > 0) then
5559 NetServerName
:= P
[1];
5560 if Length(NetServerName
) > 64 then
5561 SetLength(NetServerName
, 64);
5562 g_Net_Slist_ServerRenamed();
5565 g_Console_Add(cmd
+ ' = "' + NetServerName
+ '"');
5567 else if cmd
= 'sv_passwd' then
5569 if (Length(P
) > 1) and (Length(P
[1]) > 0) then
5571 NetPassword
:= P
[1];
5572 if Length(NetPassword
) > 24 then
5573 SetLength(NetPassword
, 24);
5574 g_Net_Slist_ServerRenamed();
5577 g_Console_Add(cmd
+ ' = "' + AnsiLowerCase(NetPassword
) + '"');
5579 else if cmd
= 'sv_maxplrs' then
5581 if (Length(P
) > 1) then
5583 NetMaxClients
:= Min(Max(StrToIntDef(P
[1], NetMaxClients
), 1), NET_MAXCLIENTS
);
5584 if g_Game_IsServer
and g_Game_IsNet
then
5587 for a
:= 0 to High(NetClients
) do
5589 if NetClients
[a
].Used
then
5592 if b
> NetMaxClients
then
5594 s
:= g_Player_Get(NetClients
[a
].Player
).Name
;
5595 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_FULL
);
5596 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
5597 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
5601 g_Net_Slist_ServerRenamed();
5605 g_Console_Add(cmd
+ ' = ' + IntToStr(NetMaxClients
));
5607 else if cmd
= 'sv_public' then
5609 if (Length(P
) > 1) then
5611 NetUseMaster
:= StrToIntDef(P
[1], Byte(NetUseMaster
)) > 0;
5612 if NetUseMaster
then g_Net_Slist_Public() else g_Net_Slist_Private();
5615 g_Console_Add(cmd
+ ' = ' + IntToStr(Byte(NetUseMaster
)));
5617 else if cmd
= 'sv_intertime' then
5619 if (Length(P
) > 1) then
5620 gDefInterTime
:= Min(Max(StrToIntDef(P
[1], gDefInterTime
), -1), 120);
5622 g_Console_Add(cmd
+ ' = ' + IntToStr(gDefInterTime
));
5624 else if cmd
= 'p1_name' then
5626 if (Length(P
) > 1) and gGameOn
then
5628 if g_Game_IsClient
then
5630 gPlayer1Settings
.Name
:= b_Text_Unformat(P
[1]);
5631 MC_SEND_PlayerSettings
;
5634 if gPlayer1
<> nil then
5636 gPlayer1
.Name
:= b_Text_Unformat(P
[1]);
5637 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer1
.UID
);
5640 gPlayer1Settings
.Name
:= b_Text_Unformat(P
[1]);
5643 else if cmd
= 'p2_name' then
5645 if (Length(P
) > 1) and gGameOn
then
5647 if g_Game_IsClient
then
5649 gPlayer2Settings
.Name
:= b_Text_Unformat(P
[1]);
5650 MC_SEND_PlayerSettings
;
5653 if gPlayer2
<> nil then
5655 gPlayer2
.Name
:= b_Text_Unformat(P
[1]);
5656 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer2
.UID
);
5659 gPlayer2Settings
.Name
:= b_Text_Unformat(P
[1]);
5662 else if cmd
= 'p1_color' then
5664 if Length(P
) > 3 then
5665 if g_Game_IsClient
then
5667 gPlayer1Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
5668 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
5669 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
5670 MC_SEND_PlayerSettings
;
5673 if gPlayer1
<> nil then
5675 gPlayer1
.Model
.SetColor(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
5676 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
5677 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
5678 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer1
.UID
);
5681 gPlayer1Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
5682 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
5683 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
5685 else if (cmd
= 'p2_color') and not g_Game_IsNet
then
5687 if Length(P
) > 3 then
5688 if g_Game_IsClient
then
5690 gPlayer2Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
5691 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
5692 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
5693 MC_SEND_PlayerSettings
;
5696 if gPlayer2
<> nil then
5698 gPlayer2
.Model
.SetColor(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
5699 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
5700 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
5701 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer2
.UID
);
5704 gPlayer2Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
5705 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
5706 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
5708 else if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
5710 if cmd
= 'r_showscore' then
5712 if (Length(P
) > 1) and
5713 ((P
[1] = '1') or (P
[1] = '0')) then
5714 gShowGoals
:= (P
[1][1] = '1');
5717 g_Console_Add(_lc
[I_MSG_SCORE_ON
])
5719 g_Console_Add(_lc
[I_MSG_SCORE_OFF
]);
5721 else if cmd
= 'r_showstat' then
5723 if (Length(P
) > 1) and
5724 ((P
[1] = '1') or (P
[1] = '0')) then
5725 gShowStat
:= (P
[1][1] = '1');
5728 g_Console_Add(_lc
[I_MSG_STATS_ON
])
5730 g_Console_Add(_lc
[I_MSG_STATS_OFF
]);
5732 else if cmd
= 'r_showkillmsg' then
5734 if (Length(P
) > 1) and
5735 ((P
[1] = '1') or (P
[1] = '0')) then
5736 gShowKillMsg
:= (P
[1][1] = '1');
5738 if gShowKillMsg
then
5739 g_Console_Add(_lc
[I_MSG_KILL_MSGS_ON
])
5741 g_Console_Add(_lc
[I_MSG_KILL_MSGS_OFF
]);
5743 else if cmd
= 'r_showlives' then
5745 if (Length(P
) > 1) and
5746 ((P
[1] = '1') or (P
[1] = '0')) then
5747 gShowLives
:= (P
[1][1] = '1');
5750 g_Console_Add(_lc
[I_MSG_LIVES_ON
])
5752 g_Console_Add(_lc
[I_MSG_LIVES_OFF
]);
5754 else if cmd
= 'r_showspect' then
5756 if (Length(P
) > 1) and
5757 ((P
[1] = '1') or (P
[1] = '0')) then
5758 gSpectHUD
:= (P
[1][1] = '1');
5761 g_Console_Add(_lc
[I_MSG_SPECT_HUD_ON
])
5763 g_Console_Add(_lc
[I_MSG_SPECT_HUD_OFF
]);
5765 else if cmd
= 'r_showping' then
5767 if (Length(P
) > 1) and
5768 ((P
[1] = '1') or (P
[1] = '0')) then
5769 gShowPing
:= (P
[1][1] = '1');
5772 g_Console_Add(_lc
[I_MSG_PING_ON
])
5774 g_Console_Add(_lc
[I_MSG_PING_OFF
]);
5776 else if (cmd
= 'g_scorelimit') and not g_Game_IsClient
then
5778 if Length(P
) > 1 then
5780 if StrToIntDef(P
[1], gGameSettings
.GoalLimit
) = 0 then
5781 gGameSettings
.GoalLimit
:= 0
5786 if gGameSettings
.GameMode
= GM_DM
then
5788 stat
:= g_Player_GetStats();
5790 for a
:= 0 to High(stat
) do
5791 if stat
[a
].Frags
> b
then
5795 b
:= Max(gTeamStat
[TEAM_RED
].Goals
, gTeamStat
[TEAM_BLUE
].Goals
);
5797 gGameSettings
.GoalLimit
:= Max(StrToIntDef(P
[1], gGameSettings
.GoalLimit
), b
);
5800 if g_Game_IsNet
then MH_SEND_GameSettings
;
5803 g_Console_Add(Format(_lc
[I_MSG_SCORE_LIMIT
], [gGameSettings
.GoalLimit
]));
5805 else if (cmd
= 'g_timelimit') and not g_Game_IsClient
then
5807 if (Length(P
) > 1) and (StrToIntDef(P
[1], -1) >= 0) then
5808 gGameSettings
.TimeLimit
:= StrToIntDef(P
[1], -1);
5810 g_Console_Add(Format(_lc
[I_MSG_TIME_LIMIT
],
5811 [gGameSettings
.TimeLimit
div 3600,
5812 (gGameSettings
.TimeLimit
div 60) mod 60,
5813 gGameSettings
.TimeLimit
mod 60]));
5814 if g_Game_IsNet
then MH_SEND_GameSettings
;
5816 else if (cmd
= 'g_maxlives') and not g_Game_IsClient
then
5818 if Length(P
) > 1 then
5820 if StrToIntDef(P
[1], gGameSettings
.MaxLives
) = 0 then
5821 gGameSettings
.MaxLives
:= 0
5825 stat
:= g_Player_GetStats();
5827 for a
:= 0 to High(stat
) do
5828 if stat
[a
].Lives
> b
then
5830 gGameSettings
.MaxLives
:=
5831 Max(StrToIntDef(P
[1], gGameSettings
.MaxLives
), b
);
5835 g_Console_Add(Format(_lc
[I_MSG_LIVES
],
5836 [gGameSettings
.MaxLives
]));
5837 if g_Game_IsNet
then MH_SEND_GameSettings
;
5842 procedure PrintHeapStats();
5846 hs
:= GetFPCHeapStatus();
5847 e_LogWriteLn ('v===== heap status =====v');
5848 e_LogWriteFln('max heap size = %d k', [hs
.MaxHeapSize
div 1024]);
5849 e_LogWriteFln('max heap used = %d k', [hs
.MaxHeapUsed
div 1024]);
5850 e_LogWriteFln('cur heap size = %d k', [hs
.CurrHeapSize
div 1024]);
5851 e_LogWriteFln('cur heap used = %d k', [hs
.CurrHeapUsed
div 1024]);
5852 e_LogWriteFln('cur heap free = %d k', [hs
.CurrHeapFree
div 1024]);
5853 e_LogWriteLn ('^=======================^');
5856 procedure DebugCommands(P
: SSArray
);
5863 // Êîìàíäû îòëàäî÷íîãî ðåæèìà:
5864 if {gDebugMode}conIsCheatsEnabled
then
5866 cmd
:= LowerCase(P
[0]);
5867 if cmd
= 'd_window' then
5869 g_Console_Add(Format('gWinPosX = %d, gWinPosY %d', [gWinPosX
, gWinPosY
]));
5870 g_Console_Add(Format('gWinRealPosX = %d, gWinRealPosY %d', [gWinRealPosX
, gWinRealPosY
]));
5871 g_Console_Add(Format('gScreenWidth = %d, gScreenHeight = %d', [gScreenWidth
, gScreenHeight
]));
5872 g_Console_Add(Format('gWinSizeX = %d, gWinSizeY = %d', [gWinSizeX
, gWinSizeY
]));
5873 g_Console_Add(Format('Frame X = %d, Y = %d, Caption Y = %d', [gWinFrameX
, gWinFrameY
, gWinCaption
]));
5875 else if cmd
= 'd_sounds' then
5877 if (Length(P
) > 1) and
5878 ((P
[1] = '1') or (P
[1] = '0')) then
5879 g_Debug_Sounds
:= (P
[1][1] = '1');
5881 g_Console_Add(Format('d_sounds is %d', [Byte(g_Debug_Sounds
)]));
5883 else if cmd
= 'd_frames' then
5885 if (Length(P
) > 1) and
5886 ((P
[1] = '1') or (P
[1] = '0')) then
5887 g_Debug_Frames
:= (P
[1][1] = '1');
5889 g_Console_Add(Format('d_frames is %d', [Byte(g_Debug_Frames
)]));
5891 else if cmd
= 'd_winmsg' then
5893 if (Length(P
) > 1) and
5894 ((P
[1] = '1') or (P
[1] = '0')) then
5895 g_Debug_WinMsgs
:= (P
[1][1] = '1');
5897 g_Console_Add(Format('d_winmsg is %d', [Byte(g_Debug_WinMsgs
)]));
5899 else if (cmd
= 'd_monoff') and not g_Game_IsNet
then
5901 if (Length(P
) > 1) and
5902 ((P
[1] = '1') or (P
[1] = '0')) then
5903 g_Debug_MonsterOff
:= (P
[1][1] = '1');
5905 g_Console_Add(Format('d_monoff is %d', [Byte(g_debug_MonsterOff
)]));
5907 else if (cmd
= 'd_botoff') and not g_Game_IsNet
then
5909 if Length(P
) > 1 then
5911 '0': g_debug_BotAIOff
:= 0;
5912 '1': g_debug_BotAIOff
:= 1;
5913 '2': g_debug_BotAIOff
:= 2;
5914 '3': g_debug_BotAIOff
:= 3;
5917 g_Console_Add(Format('d_botoff is %d', [g_debug_BotAIOff
]));
5919 else if cmd
= 'd_monster' then
5921 if gGameOn
and (gPlayer1
<> nil) and (gPlayer1
.alive
) and (not g_Game_IsNet
) then
5922 if Length(P
) < 2 then
5924 g_Console_Add(cmd
+ ' [ID | Name] [behaviour]');
5925 g_Console_Add('ID | Name');
5926 for b
:= MONSTER_DEMON
to MONSTER_MAN
do
5927 g_Console_Add(Format('%2d | %s', [b
, g_Mons_NameByTypeId(b
)]));
5928 conwriteln('behav. num'#10'normal 0'#10'killer 1'#10'maniac 2'#10'insane 3'#10'cannibal 4'#10'good 5');
5931 a
:= StrToIntDef(P
[1], 0);
5932 if (a
< MONSTER_DEMON
) or (a
> MONSTER_MAN
) then
5933 a
:= g_Mons_TypeIdByName(P
[1]);
5935 if (a
< MONSTER_DEMON
) or (a
> MONSTER_MAN
) then
5936 g_Console_Add(Format(_lc
[I_MSG_NO_MONSTER
], [P
[1]]))
5939 with gPlayer1
.Obj
do
5941 mon
:= g_Monsters_Create(a
,
5942 X
+ Rect
.X
+ (Rect
.Width
div 2),
5943 Y
+ Rect
.Y
+ Rect
.Height
,
5944 gPlayer1
.Direction
, True);
5946 if (Length(P
) > 2) and (mon
<> nil) then
5948 if (CompareText(P
[2], 'normal') = 0) then mon
.MonsterBehaviour
:= BH_NORMAL
5949 else if (CompareText(P
[2], 'killer') = 0) then mon
.MonsterBehaviour
:= BH_KILLER
5950 else if (CompareText(P
[2], 'maniac') = 0) then mon
.MonsterBehaviour
:= BH_MANIAC
5951 else if (CompareText(P
[2], 'insane') = 0) then mon
.MonsterBehaviour
:= BH_INSANE
5952 else if (CompareText(P
[2], 'cannibal') = 0) then mon
.MonsterBehaviour
:= BH_CANNIBAL
5953 else if (CompareText(P
[2], 'good') = 0) then mon
.MonsterBehaviour
:= BH_GOOD
5954 else if (CompareText(P
[2], 'friend') = 0) then mon
.MonsterBehaviour
:= BH_GOOD
5955 else if (CompareText(P
[2], 'friendly') = 0) then mon
.MonsterBehaviour
:= BH_GOOD
5956 else mon
.MonsterBehaviour
:= Min(Max(StrToIntDef(P
[2], BH_NORMAL
), BH_NORMAL
), BH_GOOD
);
5961 else if (cmd
= 'd_health') then
5963 if (Length(P
) > 1) and
5964 ((P
[1] = '1') or (P
[1] = '0')) then
5965 g_debug_HealthBar
:= (P
[1][1] = '1');
5967 g_Console_Add(Format('d_health is %d', [Byte(g_debug_HealthBar
)]));
5969 else if (cmd
= 'd_player') then
5971 if (Length(P
) > 1) and
5972 ((P
[1] = '1') or (P
[1] = '0')) then
5973 g_debug_Player
:= (P
[1][1] = '1');
5975 g_Console_Add(Format(cmd
+ ' is %d', [Byte(g_Debug_Player
)]));
5977 else if (cmd
= 'd_mem') then
5983 g_Console_Add(_lc
[I_MSG_NOT_DEBUG
]);
5987 procedure GameCheats(P
: SSArray
);
5993 if (not gGameOn
) or (not conIsCheatsEnabled
) then
5995 g_Console_Add('not available');
6001 g_Console_Add('where is the player?!');
6004 cmd
:= LowerCase(P
[0]);
6008 plr
.GodMode
:= not plr
.GodMode
;
6009 if plr
.GodMode
then g_Console_Add('player is godlike now') else g_Console_Add('player is mortal now');
6012 // give <health|exit|weapons|air|suit|jetpack|berserk|all>
6013 if cmd
= 'give' then
6015 if length(P
) < 2 then begin g_Console_Add('give what?!'); exit
; end;
6016 for f
:= 1 to High(P
) do
6018 cmd
:= LowerCase(P
[f
]);
6019 if cmd
= 'health' then begin plr
.RestoreHealthArmor(); g_Console_Add('player feels himself better'); continue
; end;
6020 if (cmd
= 'all') {or (cmd = 'weapons')} then begin plr
.AllRulez(False); g_Console_Add('player got the gifts'); continue
; end;
6021 if cmd
= 'exit' then
6023 if gTriggers
<> nil then
6025 for a
:= 0 to High(gTriggers
) do
6027 if gTriggers
[a
].TriggerType
= TRIGGER_EXIT
then
6029 g_Console_Add('player left the map');
6030 gExitByTrigger
:= True;
6031 //g_Game_ExitLevel(gTriggers[a].Data.MapName);
6032 g_Game_ExitLevel(gTriggers
[a
].tgcMap
);
6040 if cmd
= 'air' then begin plr
.GiveItem(ITEM_OXYGEN
); g_Console_Add('player got some air'); continue
; end;
6041 if cmd
= 'jetpack' then begin plr
.GiveItem(ITEM_JETPACK
); g_Console_Add('player got a jetpack'); continue
; end;
6042 if cmd
= 'suit' then begin plr
.GiveItem(ITEM_SUIT
); g_Console_Add('player got an envirosuit'); continue
; end;
6043 if cmd
= 'berserk' then begin plr
.GiveItem(ITEM_MEDKIT_BLACK
); g_Console_Add('player got a berserk pack'); continue
; end;
6044 if cmd
= 'backpack' then begin plr
.GiveItem(ITEM_AMMO_BACKPACK
); g_Console_Add('player got a backpack'); continue
; end;
6046 if cmd
= 'helmet' then begin plr
.GiveItem(ITEM_HELMET
); g_Console_Add('player got a helmet'); continue
; end;
6047 if cmd
= 'bottle' then begin plr
.GiveItem(ITEM_BOTTLE
); g_Console_Add('player got a bottle of health'); continue
; end;
6049 if cmd
= 'stimpack' then begin plr
.GiveItem(ITEM_MEDKIT_SMALL
); g_Console_Add('player got a stimpack'); continue
; end;
6050 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;
6052 if cmd
= 'greenarmor' then begin plr
.GiveItem(ITEM_ARMOR_GREEN
); g_Console_Add('player got a security armor'); continue
; end;
6053 if cmd
= 'bluearmor' then begin plr
.GiveItem(ITEM_ARMOR_BLUE
); g_Console_Add('player got a combat armor'); continue
; end;
6055 if (cmd
= 'megasphere') or (cmd
= 'mega') then begin plr
.GiveItem(ITEM_SPHERE_BLUE
); g_Console_Add('player got a megasphere'); continue
; end;
6056 if (cmd
= 'soulsphere') or (cmd
= 'soul')then begin plr
.GiveItem(ITEM_SPHERE_WHITE
); g_Console_Add('player got a soul sphere'); continue
; end;
6058 if (cmd
= 'invul') or (cmd
= 'invulnerability') then begin plr
.GiveItem(ITEM_INVUL
); g_Console_Add('player got invulnerability'); continue
; end;
6059 if (cmd
= 'invis') or (cmd
= 'invisibility') then begin plr
.GiveItem(ITEM_INVIS
); g_Console_Add('player got invisibility'); continue
; end;
6061 if cmd
= 'redkey' then begin plr
.GiveItem(ITEM_KEY_RED
); g_Console_Add('player got the red key'); continue
; end;
6062 if cmd
= 'greenkey' then begin plr
.GiveItem(ITEM_KEY_GREEN
); g_Console_Add('player got the green key'); continue
; end;
6063 if cmd
= 'bluekey' then begin plr
.GiveItem(ITEM_KEY_BLUE
); g_Console_Add('player got the blue key'); continue
; end;
6065 if (cmd
= 'shotgun') or (cmd
= 'sg') then begin plr
.GiveItem(ITEM_WEAPON_SHOTGUN1
); g_Console_Add('player got a shotgun'); continue
; end;
6066 if (cmd
= 'supershotgun') or (cmd
= 'ssg') then begin plr
.GiveItem(ITEM_WEAPON_SHOTGUN2
); g_Console_Add('player got a supershotgun'); continue
; end;
6067 if cmd
= 'chaingun' then begin plr
.GiveItem(ITEM_WEAPON_CHAINGUN
); g_Console_Add('player got a chaingun'); continue
; end;
6068 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;
6069 if cmd
= 'plasmagun' then begin plr
.GiveItem(ITEM_WEAPON_PLASMA
); g_Console_Add('player got a plasma gun'); continue
; end;
6070 if cmd
= 'bfg' then begin plr
.GiveItem(ITEM_WEAPON_BFG
); g_Console_Add('player got a BFG-9000'); continue
; end;
6072 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;
6073 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;
6074 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;
6075 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;
6076 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;
6077 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;
6079 if cmd
= 'superchaingun' then begin plr
.GiveItem(ITEM_WEAPON_SUPERPULEMET
); g_Console_Add('player got a superchaingun'); continue
; end;
6080 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;
6082 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;
6083 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;
6085 if cmd
= 'chainsaw' then begin plr
.GiveItem(ITEM_WEAPON_SAW
); g_Console_Add('player got a chainsaw'); continue
; end;
6087 if cmd
= 'ammo' then
6089 plr
.GiveItem(ITEM_AMMO_SHELLS_BOX
);
6090 plr
.GiveItem(ITEM_AMMO_BULLETS_BOX
);
6091 plr
.GiveItem(ITEM_AMMO_CELL_BIG
);
6092 plr
.GiveItem(ITEM_AMMO_ROCKET_BOX
);
6093 plr
.GiveItem(ITEM_AMMO_FUELCAN
);
6094 g_Console_Add('player got some ammo');
6098 if cmd
= 'clip' then begin plr
.GiveItem(ITEM_AMMO_BULLETS
); g_Console_Add('player got some bullets'); continue
; end;
6099 if cmd
= 'bullets' then begin plr
.GiveItem(ITEM_AMMO_BULLETS_BOX
); g_Console_Add('player got a box of bullets'); continue
; end;
6101 if cmd
= 'shells' then begin plr
.GiveItem(ITEM_AMMO_SHELLS
); g_Console_Add('player got some shells'); continue
; end;
6102 if cmd
= 'shellbox' then begin plr
.GiveItem(ITEM_AMMO_SHELLS_BOX
); g_Console_Add('player got a box of shells'); continue
; end;
6104 if cmd
= 'cells' then begin plr
.GiveItem(ITEM_AMMO_CELL
); g_Console_Add('player got some cells'); continue
; end;
6105 if cmd
= 'battery' then begin plr
.GiveItem(ITEM_AMMO_CELL_BIG
); g_Console_Add('player got cell battery'); continue
; end;
6107 if cmd
= 'rocket' then begin plr
.GiveItem(ITEM_AMMO_ROCKET
); g_Console_Add('player got a rocket'); continue
; end;
6108 if cmd
= 'rocketbox' then begin plr
.GiveItem(ITEM_AMMO_ROCKET_BOX
); g_Console_Add('player got some rockets'); continue
; end;
6110 if (cmd
= 'fuel') or (cmd
= 'fuelcan') then begin plr
.GiveItem(ITEM_AMMO_FUELCAN
); g_Console_Add('player got fuel canister'); continue
; end;
6112 if cmd
= 'weapons' then
6114 plr
.GiveItem(ITEM_WEAPON_SHOTGUN1
);
6115 plr
.GiveItem(ITEM_WEAPON_SHOTGUN2
);
6116 plr
.GiveItem(ITEM_WEAPON_CHAINGUN
);
6117 plr
.GiveItem(ITEM_WEAPON_ROCKETLAUNCHER
);
6118 plr
.GiveItem(ITEM_WEAPON_PLASMA
);
6119 plr
.GiveItem(ITEM_WEAPON_BFG
);
6120 g_Console_Add('player got weapons');
6124 if cmd
= 'keys' then
6126 plr
.GiveItem(ITEM_KEY_RED
);
6127 plr
.GiveItem(ITEM_KEY_GREEN
);
6128 plr
.GiveItem(ITEM_KEY_BLUE
);
6129 g_Console_Add('player got all keys');
6133 g_Console_Add('i don''t know how to give '''+cmd
+'''!');
6138 if cmd
= 'open' then
6140 g_Console_Add('player activated sesame');
6141 g_Triggers_OpenAll();
6148 if gFly
then g_Console_Add('player feels himself lighter') else g_Console_Add('player lost his wings');
6152 if cmd
= 'noclip' then
6155 g_Console_Add('wall hardeness adjusted');
6159 if cmd
= 'notarget' then
6161 plr
.NoTarget
:= not plr
.NoTarget
;
6162 if plr
.NoTarget
then g_Console_Add('player hides in shadows') else g_Console_Add('player is brave again');
6166 if cmd
= 'noreload' then
6168 plr
.NoReload
:= not plr
.NoReload
;
6169 if plr
.NoReload
then g_Console_Add('player is action hero now') else g_Console_Add('player is ordinary man now');
6173 if cmd
= 'speedy' then
6175 MAX_RUNVEL
:= 32-MAX_RUNVEL
;
6176 g_Console_Add('speed adjusted');
6180 if cmd
= 'jumpy' then
6182 VEL_JUMP
:= 30-VEL_JUMP
;
6183 g_Console_Add('jump height adjusted');
6187 if cmd
= 'automap' then
6189 gShowMap
:= not gShowMap
;
6190 if gShowMap
then g_Console_Add('player gains second sight') else g_Console_Add('player lost second sight');
6194 if cmd
= 'aimline' then
6196 gAimLine
:= not gAimLine
;
6197 if gAimLine
then g_Console_Add('player gains laser sight') else g_Console_Add('player lost laser sight');
6202 procedure GameCommands(P
: SSArray
);
6208 pl
: pTNetClient
= nil;
6216 cmd
:= LowerCase(P
[0]);
6218 if (cmd
= 'quit') or
6225 else if cmd
= 'pause' then
6227 if (g_ActiveWindow
= nil) then
6228 g_Game_Pause(not gPauseMain
);
6230 else if cmd
= 'endgame' then
6231 gExit
:= EXIT_SIMPLE
6232 else if cmd
= 'restart' then
6234 if gGameOn
or (gState
in [STATE_INTERSINGLE
, STATE_INTERCUSTOM
]) then
6236 if g_Game_IsClient
then
6238 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6243 g_Console_Add(_lc
[I_MSG_NOT_GAME
]);
6245 else if cmd
= 'kick' then
6247 if g_Game_IsServer
then
6249 if Length(P
) < 2 then
6251 g_Console_Add('kick <name>');
6256 g_Console_Add('kick <name>');
6260 if g_Game_IsNet
then
6261 pl
:= g_Net_Client_ByName(P
[1]);
6264 s
:= g_Net_ClientName_ByID(pl
^.ID
);
6265 enet_peer_disconnect(pl
^.Peer
, NET_DISC_KICK
);
6266 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
6267 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
6268 g_Net_Slist_ServerPlayerLeaves();
6269 end else if gPlayers
<> nil then
6270 for a
:= Low(gPlayers
) to High(gPlayers
) do
6271 if gPlayers
[a
] <> nil then
6272 if Copy(LowerCase(gPlayers
[a
].Name
), 1, Length(P
[1])) = LowerCase(P
[1]) then
6274 // Íå îòêëþ÷àòü îñíîâíûõ èãðîêîâ â ñèíãëå
6275 if not(gPlayers
[a
] is TBot
) and (gGameSettings
.GameType
= GT_SINGLE
) then
6277 gPlayers
[a
].Lives
:= 0;
6278 gPlayers
[a
].Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
6279 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [gPlayers
[a
].Name
]), True);
6280 g_Player_Remove(gPlayers
[a
].UID
);
6281 g_Net_Slist_ServerPlayerLeaves();
6282 // Åñëè íå ïåðåìåøàòü, ïðè äîáàâëåíèè íîâûõ áîòîâ ïîÿâÿòñÿ ñòàðûå
6286 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6288 else if cmd
= 'kick_id' then
6290 if g_Game_IsServer
and g_Game_IsNet
then
6292 if Length(P
) < 2 then
6294 g_Console_Add('kick_id <client ID>');
6299 g_Console_Add('kick_id <client ID>');
6303 a
:= StrToIntDef(P
[1], 0);
6304 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
6306 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
6308 s
:= g_Net_ClientName_ByID(NetClients
[a
].ID
);
6309 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_KICK
);
6310 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
6311 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
6312 g_Net_Slist_ServerPlayerLeaves();
6316 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6318 else if cmd
= 'ban' then
6320 if g_Game_IsServer
and g_Game_IsNet
then
6322 if Length(P
) < 2 then
6324 g_Console_Add('ban <name>');
6329 g_Console_Add('ban <name>');
6333 pl
:= g_Net_Client_ByName(P
[1]);
6336 s
:= g_Net_ClientName_ByID(pl
^.ID
);
6337 g_Net_BanHost(pl
^.Peer
^.address
.host
, False);
6338 enet_peer_disconnect(pl
^.Peer
, NET_DISC_TEMPBAN
);
6339 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
6340 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
6341 g_Net_Slist_ServerPlayerLeaves();
6343 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
6345 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6347 else if cmd
= 'ban_id' then
6349 if g_Game_IsServer
and g_Game_IsNet
then
6351 if Length(P
) < 2 then
6353 g_Console_Add('ban_id <client ID>');
6358 g_Console_Add('ban_id <client ID>');
6362 a
:= StrToIntDef(P
[1], 0);
6363 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
6364 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
6366 s
:= g_Net_ClientName_ByID(NetClients
[a
].ID
);
6367 g_Net_BanHost(NetClients
[a
].Peer
^.address
.host
, False);
6368 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_TEMPBAN
);
6369 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
6370 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
6371 g_Net_Slist_ServerPlayerLeaves();
6374 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6376 else if cmd
= 'permban' then
6378 if g_Game_IsServer
and g_Game_IsNet
then
6380 if Length(P
) < 2 then
6382 g_Console_Add('permban <name>');
6387 g_Console_Add('permban <name>');
6391 pl
:= g_Net_Client_ByName(P
[1]);
6394 s
:= g_Net_ClientName_ByID(pl
^.ID
);
6395 g_Net_BanHost(pl
^.Peer
^.address
.host
);
6396 enet_peer_disconnect(pl
^.Peer
, NET_DISC_BAN
);
6397 g_Net_SaveBanList();
6398 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
6399 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
6400 g_Net_Slist_ServerPlayerLeaves();
6402 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
6404 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6406 else if cmd
= 'permban_id' then
6408 if g_Game_IsServer
and g_Game_IsNet
then
6410 if Length(P
) < 2 then
6412 g_Console_Add('permban_id <client ID>');
6417 g_Console_Add('permban_id <client ID>');
6421 a
:= StrToIntDef(P
[1], 0);
6422 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
6423 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
6425 s
:= g_Net_ClientName_ByID(NetClients
[a
].ID
);
6426 g_Net_BanHost(NetClients
[a
].Peer
^.address
.host
);
6427 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_BAN
);
6428 g_Net_SaveBanList();
6429 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
6430 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
6431 g_Net_Slist_ServerPlayerLeaves();
6434 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6436 else if cmd
= 'unban' then
6438 if g_Game_IsServer
and g_Game_IsNet
then
6440 if Length(P
) < 2 then
6442 g_Console_Add('unban <IP Address>');
6447 g_Console_Add('unban <IP Address>');
6451 if g_Net_UnbanHost(P
[1]) then
6453 g_Console_Add(Format(_lc
[I_MSG_UNBAN_OK
], [P
[1]]));
6454 g_Net_SaveBanList();
6456 g_Console_Add(Format(_lc
[I_MSG_UNBAN_FAIL
], [P
[1]]));
6458 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6460 else if cmd
= 'clientlist' then
6462 if g_Game_IsServer
and g_Game_IsNet
then
6465 if NetClients
<> nil then
6466 for a
:= Low(NetClients
) to High(NetClients
) do
6467 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
6469 plr
:= g_Player_Get(NetClients
[a
].Player
);
6470 if plr
= nil then continue
;
6472 g_Console_Add(Format('#%2d: %-15s | %s', [a
,
6473 IpToStr(NetClients
[a
].Peer
^.address
.host
), plr
.Name
]));
6476 g_Console_Add(_lc
[I_MSG_NOCLIENTS
]);
6478 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6480 else if cmd
= 'connect' then
6482 if (NetMode
= NET_NONE
) then
6484 if Length(P
) < 2 then
6486 g_Console_Add('connect <IP> [port] [password]');
6491 g_Console_Add('connect <IP> [port] [password]');
6495 if Length(P
) > 2 then
6496 prt
:= StrToIntDef(P
[2], 25666)
6500 if Length(P
) > 3 then
6505 g_Game_StartClient(P
[1], prt
, pw
);
6508 else if cmd
= 'disconnect' then
6510 if (NetMode
= NET_CLIENT
) then
6513 else if cmd
= 'reconnect' then
6515 if (NetMode
= NET_SERVER
) then
6518 if (NetMode
= NET_CLIENT
) then
6521 gExit
:= EXIT_SIMPLE
;
6525 //TODO: Use last successful password to reconnect, instead of ''
6526 g_Game_StartClient(NetClientIP
, NetClientPort
, '');
6528 else if (cmd
= 'addbot') or
6529 (cmd
= 'bot_add') then
6531 if Length(P
) > 2 then
6532 g_Bot_Add(TEAM_NONE
, StrToIntDef(P
[1], 2), StrToIntDef(P
[2], 100))
6533 else if Length(P
) > 1 then
6534 g_Bot_Add(TEAM_NONE
, StrToIntDef(P
[1], 2))
6536 g_Bot_Add(TEAM_NONE
, 2);
6538 else if cmd
= 'bot_addlist' then
6540 if Length(P
) > 1 then
6542 if Length(P
) = 2 then
6543 g_Bot_AddList(TEAM_NONE
, P
[1], StrToIntDef(P
[1], -1))
6544 else if Length(P
) = 3 then
6545 g_Bot_AddList(TEAM_NONE
, P
[1], StrToIntDef(P
[1], -1), StrToIntDef(P
[2], 100))
6547 g_Bot_AddList(IfThen(P
[2] = 'red', TEAM_RED
, TEAM_BLUE
), P
[1], StrToIntDef(P
[1], -1));
6550 else if cmd
= 'bot_removeall' then
6552 else if cmd
= 'chat' then
6554 if g_Game_IsNet
then
6556 if Length(P
) > 1 then
6558 for a
:= 1 to High(P
) do
6559 chstr
:= chstr
+ P
[a
] + ' ';
6561 if Length(chstr
) > 200 then SetLength(chstr
, 200);
6563 if Length(chstr
) < 1 then
6565 g_Console_Add('chat <text>');
6569 chstr
:= b_Text_Format(chstr
);
6570 if g_Game_IsClient
then
6571 MC_SEND_Chat(chstr
, NET_CHAT_PLAYER
)
6573 MH_SEND_Chat(gPlayer1Settings
.Name
+ ': ' + chstr
, NET_CHAT_PLAYER
);
6576 g_Console_Add('chat <text>');
6578 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6580 else if cmd
= 'teamchat' then
6582 if g_Game_IsNet
and (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
6584 if Length(P
) > 1 then
6586 for a
:= 1 to High(P
) do
6587 chstr
:= chstr
+ P
[a
] + ' ';
6589 if Length(chstr
) > 200 then SetLength(chstr
, 200);
6591 if Length(chstr
) < 1 then
6593 g_Console_Add('teamchat <text>');
6597 chstr
:= b_Text_Format(chstr
);
6598 if g_Game_IsClient
then
6599 MC_SEND_Chat(chstr
, NET_CHAT_TEAM
)
6601 MH_SEND_Chat(gPlayer1Settings
.Name
+ ': ' + chstr
, NET_CHAT_TEAM
,
6602 gPlayer1Settings
.Team
);
6605 g_Console_Add('teamchat <text>');
6607 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6609 else if cmd
= 'game' then
6611 if gGameSettings
.GameType
<> GT_NONE
then
6613 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6616 if Length(P
) = 1 then
6618 g_Console_Add(cmd
+ ' <WAD> [MAP] [# players]');
6621 // game not started yet, load fist map from some wad
6623 s
:= addWadExtension(P
[1]);
6624 found
:= e_FindResource(AllMapDirs
, s
);
6628 P
[1] := ExpandFileName(P
[1]);
6629 // if map not choosed then set first map
6630 if Length(P
) < 3 then
6633 P
[2] := g_Game_GetFirstMap(P
[1]);
6636 s
:= P
[1] + ':\' + UpperCase(P
[2]);
6638 if g_Map_Exist(s
) then
6642 with gGameSettings
do
6644 GameMode
:= g_Game_TextToMode(gcGameMode
);
6645 if gSwitchGameMode
<> GM_NONE
then
6646 GameMode
:= gSwitchGameMode
;
6647 if GameMode
= GM_NONE
then GameMode
:= GM_DM
;
6648 if GameMode
= GM_SINGLE
then GameMode
:= GM_COOP
;
6650 if Length(P
) >= 4 then
6651 b
:= StrToIntDef(P
[3], 1);
6652 g_Game_StartCustom(s
, GameMode
, TimeLimit
,
6653 GoalLimit
, MaxLives
, Options
, b
);
6658 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
6660 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [UpperCase(P
[2]), P
[1]]));
6662 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]));
6664 else if cmd
= 'host' then
6666 if gGameSettings
.GameType
<> GT_NONE
then
6668 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6671 if Length(P
) < 4 then
6673 g_Console_Add(cmd
+ ' <listen IP> <port> <WAD> [MAP] [# players]');
6676 if not StrToIp(P
[1], listen
) then
6678 prt
:= StrToIntDef(P
[2], 25666);
6680 s
:= addWadExtension(P
[3]);
6681 found
:= e_FindResource(AllMapDirs
, s
);
6685 // get first map in wad, if not specified
6686 if Length(P
) < 5 then
6689 P
[4] := g_Game_GetFirstMap(P
[1]);
6691 s
:= P
[3] + ':\' + UpperCase(P
[4]);
6692 if g_Map_Exist(s
) then
6696 with gGameSettings
do
6698 GameMode
:= g_Game_TextToMode(gcGameMode
);
6699 if gSwitchGameMode
<> GM_NONE
then GameMode
:= gSwitchGameMode
;
6700 if GameMode
= GM_NONE
then GameMode
:= GM_DM
;
6701 if GameMode
= GM_SINGLE
then GameMode
:= GM_COOP
;
6703 if Length(P
) >= 6 then
6704 b
:= StrToIntDef(P
[5], 0);
6705 g_Game_StartServer(s
, GameMode
, TimeLimit
, GoalLimit
, MaxLives
, Options
, b
, listen
, prt
)
6711 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[3]]))
6713 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [UpperCase(P
[4]), P
[3]]))
6718 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[3]]))
6721 else if cmd
= 'map' then
6723 if Length(P
) = 1 then
6725 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
6727 g_Console_Add(cmd
+ ' <MAP>');
6728 g_Console_Add(cmd
+ ' <WAD> [MAP]')
6732 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
])
6737 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
6739 if Length(P
) < 3 then
6741 // first param is map or wad
6742 s
:= UpperCase(P
[1]);
6743 if g_Map_Exist(gGameSettings
.WAD
+ ':\' + s
) then
6745 gExitByTrigger
:= False;
6748 // already in game, finish current map
6750 gExit
:= EXIT_ENDLEVELCUSTOM
;
6754 // intermission, so change map immediately
6761 found
:= e_FindResource(AllMapDirs
, s
);
6763 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [s
, 'WAD ' + P
[1]]));
6766 // no such map, found wad
6769 P
[1] := ExpandFileName(pw
);
6770 P
[2] := g_Game_GetFirstMap(P
[1]);
6771 s
:= P
[1] + ':\' + P
[2];
6772 if g_Map_Exist(s
) then
6774 gExitByTrigger
:= False;
6777 // already in game, finish current map
6779 gExit
:= EXIT_ENDLEVELCUSTOM
6783 // intermission, so change map immediately
6790 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
6792 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]))
6797 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]))
6803 s
:= addWadExtension(P
[1]);
6804 found
:= e_FindResource(AllMapDirs
, s
);
6808 P
[2] := UpperCase(P
[2]);
6809 s
:= P
[1] + ':\' + P
[2];
6810 if g_Map_Exist(s
) then
6812 gExitByTrigger
:= False;
6816 gExit
:= EXIT_ENDLEVELCUSTOM
6825 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]))
6830 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]))
6836 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
])
6840 else if cmd
= 'nextmap' then
6842 if not(gGameOn
or (gState
= STATE_INTERCUSTOM
)) then
6844 g_Console_Add(_lc
[I_MSG_NOT_GAME
])
6849 if Length(P
) = 1 then
6851 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
6853 g_Console_Add(cmd
+ ' <MAP>');
6854 g_Console_Add(cmd
+ ' <WAD> [MAP]');
6859 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6865 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
6867 if Length(P
) < 3 then
6869 // first param is map or wad
6870 s
:= UpperCase(P
[1]);
6871 if g_Map_Exist(gGameSettings
.WAD
+ ':\' + s
) then
6874 gExitByTrigger
:= False;
6880 // no such map, found wad
6881 pw
:= addWadExtension(P
[1]);
6882 found
:= e_FindResource(MapDirs
, pw
);
6884 found
:= e_FindResource(WadDirs
, pw
);
6886 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [s
, P
[1]]));
6889 // map not specified, select first map
6891 P
[2] := g_Game_GetFirstMap(P
[1]);
6892 s
:= P
[1] + ':\' + P
[2];
6893 if g_Map_Exist(s
) then
6895 gExitByTrigger
:= False;
6902 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
6904 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]))
6909 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]))
6915 // specified two params wad + map
6916 pw
:= addWadExtension(P
[1]);
6917 found
:= e_FindResource(MapDirs
, pw
);
6919 found
:= e_FindResource(MapDirs
, pw
);
6923 P
[2] := UpperCase(P
[2]);
6924 s
:= P
[1] + ':\' + P
[2];
6925 if g_Map_Exist(s
) then
6927 gExitByTrigger
:= False;
6933 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]))
6938 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]))
6944 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
])
6949 if gNextMap
= '' then
6950 g_Console_Add(_lc
[I_MSG_NEXTMAP_UNSET
])
6952 g_Console_Add(Format(_lc
[I_MSG_NEXTMAP_SET
], [gNextMap
]))
6956 else if (cmd
= 'endmap') or (cmd
= 'goodbye') then
6960 g_Console_Add(_lc
[I_MSG_NOT_GAME
])
6964 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
6966 gExitByTrigger
:= False;
6967 // next map not specified, try to find trigger EXIT
6968 if (gNextMap
= '') and (gTriggers
<> nil) then
6970 for a
:= 0 to High(gTriggers
) do
6972 if gTriggers
[a
].TriggerType
= TRIGGER_EXIT
then
6974 gExitByTrigger
:= True;
6975 //gNextMap := gTriggers[a].Data.MapName;
6976 gNextMap
:= gTriggers
[a
].tgcMap
;
6981 if gNextMap
= '' then
6982 gNextMap
:= g_Game_GetNextMap();
6983 if not isWadPath(gNextMap
) then
6984 s
:= gGameSettings
.WAD
+ ':\' + gNextMap
6987 if g_Map_Exist(s
) then
6988 gExit
:= EXIT_ENDLEVELCUSTOM
6990 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [gNextMap
]))
6994 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
])
6998 else if (cmd
= 'event') then
7000 if (Length(P
) <= 1) then
7002 for a
:= 0 to High(gEvents
) do
7003 if gEvents
[a
].Command
= '' then
7004 g_Console_Add(gEvents
[a
].Name
+ ' <none>')
7006 g_Console_Add(gEvents
[a
].Name
+ ' "' + gEvents
[a
].Command
+ '"');
7009 if (Length(P
) = 2) then
7011 for a
:= 0 to High(gEvents
) do
7012 if gEvents
[a
].Name
= P
[1] then
7013 if gEvents
[a
].Command
= '' then
7014 g_Console_Add(gEvents
[a
].Name
+ ' <none>')
7016 g_Console_Add(gEvents
[a
].Name
+ ' "' + gEvents
[a
].Command
+ '"');
7019 for a
:= 0 to High(gEvents
) do
7020 if gEvents
[a
].Name
= P
[1] then
7022 gEvents
[a
].Command
:= '';
7023 for b
:= 2 to High(P
) do
7024 if Pos(' ', P
[b
]) = 0 then
7025 gEvents
[a
].Command
:= gEvents
[a
].Command
+ ' ' + P
[b
]
7027 gEvents
[a
].Command
:= gEvents
[a
].Command
+ ' "' + P
[b
] + '"';
7028 gEvents
[a
].Command
:= Trim(gEvents
[a
].Command
);
7032 else if cmd
= 'suicide' then
7036 if g_Game_IsClient
then
7037 MC_SEND_CheatRequest(NET_CHEAT_SUICIDE
)
7040 if gPlayer1
<> nil then
7041 gPlayer1
.Damage(SUICIDE_DAMAGE
, gPlayer1
.UID
, 0, 0, HIT_SELF
);
7042 if gPlayer2
<> nil then
7043 gPlayer2
.Damage(SUICIDE_DAMAGE
, gPlayer2
.UID
, 0, 0, HIT_SELF
);
7047 else if cmd
= 'screenshot' then
7051 else if cmd
= 'weapon' then
7053 if Length(p
) = 2 then
7055 a
:= WP_FIRST
+ StrToInt(p
[1]) - 1;
7056 if (a
>= WP_FIRST
) and (a
<= WP_LAST
) then
7057 gSelectWeapon
[0, a
] := True
7060 else if (cmd
= 'p1_weapon') or (cmd
= 'p2_weapon') then
7062 if Length(p
) = 2 then
7064 a
:= WP_FIRST
+ StrToInt(p
[1]) - 1;
7065 b
:= ord(cmd
[2]) - ord('1');
7066 if (a
>= WP_FIRST
) and (a
<= WP_LAST
) then
7067 gSelectWeapon
[b
, a
] := True
7070 // Êîìàíäû Ñâîåé èãðû:
7071 else if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
7073 if cmd
= 'bot_addred' then
7075 if Length(P
) > 1 then
7076 g_Bot_Add(TEAM_RED
, StrToIntDef(P
[1], 2))
7078 g_Bot_Add(TEAM_RED
, 2);
7080 else if cmd
= 'bot_addblue' then
7082 if Length(P
) > 1 then
7083 g_Bot_Add(TEAM_BLUE
, StrToIntDef(P
[1], 2))
7085 g_Bot_Add(TEAM_BLUE
, 2);
7087 else if cmd
= 'spectate' then
7093 else if cmd
= 'say' then
7095 if g_Game_IsServer
and g_Game_IsNet
then
7097 if Length(P
) > 1 then
7100 for a
:= 1 to High(P
) do
7101 chstr
:= chstr
+ P
[a
] + ' ';
7103 if Length(chstr
) > 200 then SetLength(chstr
, 200);
7105 if Length(chstr
) < 1 then
7107 g_Console_Add('say <text>');
7111 chstr
:= b_Text_Format(chstr
);
7112 MH_SEND_Chat(chstr
, NET_CHAT_PLAYER
);
7114 else g_Console_Add('say <text>');
7116 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
7118 else if cmd
= 'tell' then
7120 if g_Game_IsServer
and g_Game_IsNet
then
7122 if (Length(P
) > 2) and (P
[1] <> '') then
7125 for a
:= 2 to High(P
) do
7126 chstr
:= chstr
+ P
[a
] + ' ';
7128 if Length(chstr
) > 200 then SetLength(chstr
, 200);
7130 if Length(chstr
) < 1 then
7132 g_Console_Add('tell <playername> <text>');
7136 pl
:= g_Net_Client_ByName(P
[1]);
7138 MH_SEND_Chat(b_Text_Format(chstr
), NET_CHAT_PLAYER
, pl
^.ID
)
7140 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
7142 else g_Console_Add('tell <playername> <text>');
7144 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
7146 else if (cmd
= 'overtime') and not g_Game_IsClient
then
7148 if (Length(P
) = 1) or (StrToIntDef(P
[1], -1) <= 0) then
7150 // Äîïîëíèòåëüíîå âðåìÿ:
7151 gGameSettings
.TimeLimit
:= (gTime
- gGameStartTime
) div 1000 + Word(StrToIntDef(P
[1], 0));
7153 g_Console_Add(Format(_lc
[I_MSG_TIME_LIMIT
],
7154 [gGameSettings
.TimeLimit
div 3600,
7155 (gGameSettings
.TimeLimit
div 60) mod 60,
7156 gGameSettings
.TimeLimit
mod 60]));
7157 if g_Game_IsNet
then MH_SEND_GameSettings
;
7159 else if (cmd
= 'rcon_password') and g_Game_IsClient
then
7161 if (Length(P
) <= 1) then
7162 g_Console_Add('rcon_password <password>')
7164 MC_SEND_RCONPassword(P
[1]);
7166 else if cmd
= 'rcon' then
7168 if g_Game_IsClient
then
7170 if Length(P
) > 1 then
7173 for a
:= 1 to High(P
) do
7174 chstr
:= chstr
+ P
[a
] + ' ';
7176 if Length(chstr
) > 200 then SetLength(chstr
, 200);
7178 if Length(chstr
) < 1 then
7180 g_Console_Add('rcon <command>');
7184 MC_SEND_RCONCommand(chstr
);
7186 else g_Console_Add('rcon <command>');
7189 else if cmd
= 'ready' then
7191 if g_Game_IsServer
and (gLMSRespawn
= LMS_RESPAWN_WARMUP
) then
7192 gLMSRespawnTime
:= gTime
+ 100;
7194 else if (cmd
= 'callvote') and g_Game_IsNet
then
7196 if Length(P
) > 1 then
7199 for a
:= 1 to High(P
) do begin
7200 if a
> 1 then chstr
:= chstr
+ ' ';
7201 chstr
:= chstr
+ P
[a
];
7204 if Length(chstr
) > 200 then SetLength(chstr
, 200);
7206 if Length(chstr
) < 1 then
7208 g_Console_Add('callvote <command>');
7212 if g_Game_IsClient
then
7213 MC_SEND_Vote(True, chstr
)
7215 g_Game_StartVote(chstr
, gPlayer1Settings
.Name
);
7216 g_Console_Process('vote', True);
7219 g_Console_Add('callvote <command>');
7221 else if (cmd
= 'vote') and g_Game_IsNet
then
7223 if g_Game_IsClient
then
7225 else if gVoteInProgress
then
7227 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
7228 a
:= Floor((NetClientCount
+1)/2.0) + 1
7230 a
:= Floor(NetClientCount
/2.0) + 1;
7235 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_REVOKED
], [gPlayer1Settings
.Name
, gVoteCount
, a
]), True);
7236 MH_SEND_VoteEvent(NET_VE_REVOKE
, gPlayer1Settings
.Name
, 'a', gVoteCount
, a
);
7242 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_VOTE
], [gPlayer1Settings
.Name
, gVoteCount
, a
]), True);
7243 MH_SEND_VoteEvent(NET_VE_VOTE
, gPlayer1Settings
.Name
, 'a', gVoteCount
, a
);
7251 procedure g_TakeScreenShot
;
7252 var s
: TStream
; t
: TDateTime
; date
, name
: String;
7254 if e_NoGraphics
then Exit
;
7256 DateTimeToString(date
, 'yyyy-mm-dd-hh-nn-ss', t
);
7257 name
:= 'screenshot-' + date
+ '.png';
7259 s
:= e_CreateResource(ScreenshotDirs
, name
);
7260 e_MakeScreenshot(s
, gScreenWidth
, gScreenHeight
);
7261 g_Console_Add(Format(_lc
[I_CONSOLE_SCREENSHOT
], [name
]))
7263 g_Console_Add('oh shit, i can''t create screenshot!')
7267 procedure g_Game_InGameMenu(Show
: Boolean);
7269 if (g_ActiveWindow
= nil) and Show
then
7271 if gGameSettings
.GameType
= GT_SINGLE
then
7272 g_GUI_ShowWindow('GameSingleMenu')
7275 if g_Game_IsClient
then
7276 g_GUI_ShowWindow('GameClientMenu')
7278 if g_Game_IsNet
then
7279 g_GUI_ShowWindow('GameServerMenu')
7281 g_GUI_ShowWindow('GameCustomMenu');
7283 g_Sound_PlayEx('MENU_OPEN');
7285 // Ïàóçà ïðè ìåíþ òîëüêî â îäèíî÷íîé èãðå:
7286 if (not g_Game_IsNet
) then
7290 if (g_ActiveWindow
<> nil) and (not Show
) then
7292 // Ïàóçà ïðè ìåíþ òîëüêî â îäèíî÷íîé èãðå:
7293 if (not g_Game_IsNet
) then
7294 g_Game_Pause(False);
7298 procedure g_Game_Pause (Enable
: Boolean);
7302 if not gGameOn
then exit
;
7304 if not (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
]) then exit
;
7307 gPauseMain
:= Enable
;
7309 if (gPause
<> oldPause
) then g_Game_PauseAllSounds(gPause
);
7312 procedure g_Game_HolmesPause (Enable
: Boolean);
7316 if not gGameOn
then exit
;
7317 if not (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
]) then exit
;
7320 gPauseHolmes
:= Enable
;
7322 if (gPause
<> oldPause
) then g_Game_PauseAllSounds(gPause
);
7325 procedure g_Game_PauseAllSounds(Enable
: Boolean);
7330 if gTriggers
<> nil then
7331 for i
:= 0 to High(gTriggers
) do
7332 with gTriggers
[i
] do
7333 if (TriggerType
= TRIGGER_SOUND
) and
7335 Sound
.IsPlaying() then
7337 Sound
.Pause(Enable
);
7341 if gPlayers
<> nil then
7342 for i
:= 0 to High(gPlayers
) do
7343 if gPlayers
[i
] <> nil then
7344 gPlayers
[i
].PauseSounds(Enable
);
7347 if gMusic
<> nil then
7348 gMusic
.Pause(Enable
);
7351 procedure g_Game_StopAllSounds(all
: Boolean);
7355 if gTriggers
<> nil then
7356 for i
:= 0 to High(gTriggers
) do
7357 with gTriggers
[i
] do
7358 if (TriggerType
= TRIGGER_SOUND
) and
7362 if gMusic
<> nil then
7369 procedure g_Game_UpdateTriggerSounds
;
7372 if gTriggers
<> nil then
7373 for i
:= 0 to High(gTriggers
) do
7374 with gTriggers
[i
] do
7375 if (TriggerType
= TRIGGER_SOUND
) and (Sound
<> nil) and tgcLocal
and Sound
.IsPlaying() then
7376 Sound
.SetCoordsRect(X
, Y
, Width
, Height
, tgcVolume
/ 255.0)
7379 function g_Game_IsWatchedPlayer(UID
: Word): Boolean;
7382 if (gPlayer1
<> nil) and (gPlayer1
.UID
= UID
) then
7387 if (gPlayer2
<> nil) and (gPlayer2
.UID
= UID
) then
7392 if gSpectMode
<> SPECT_PLAYERS
then
7394 if gSpectPID1
= UID
then
7399 if gSpectViewTwo
and (gSpectPID2
= UID
) then
7406 function g_Game_IsWatchedTeam(Team
: Byte): Boolean;
7411 if (gPlayer1
<> nil) and (gPlayer1
.Team
= Team
) then
7416 if (gPlayer2
<> nil) and (gPlayer2
.Team
= Team
) then
7421 if gSpectMode
<> SPECT_PLAYERS
then
7423 Pl
:= g_Player_Get(gSpectPID1
);
7424 if (Pl
<> nil) and (Pl
.Team
= Team
) then
7429 if gSpectViewTwo
then
7431 Pl
:= g_Player_Get(gSpectPID2
);
7432 if (Pl
<> nil) and (Pl
.Team
= Team
) then
7440 procedure g_Game_Message(Msg
: string; Time
: Word);
7442 MessageLineLength
:= (gScreenWidth
- 204) div e_CharFont_GetMaxWidth(gMenuFont
);
7443 MessageText
:= b_Text_Wrap(b_Text_Format(Msg
), MessageLineLength
);
7444 MessageTime
:= Time
;
7447 procedure g_Game_ChatSound(Text: String; Taunt
: Boolean = True);
7449 punct
: Array[0..13] of String =
7450 ('.', ',', ':', ';', '!', '?', '(', ')', '''', '"', '/', '\', '*', '^');
7456 function IsPunctuation(S
: String): Boolean;
7461 if Length(S
) <> 1 then
7463 for i
:= Low(punct
) to High(punct
) do
7464 if S
= punct
[i
] then
7470 function FilterPunctuation(S
: String): String;
7474 for i
:= Low(punct
) to High(punct
) do
7475 S
:= StringReplace(S
, punct
[i
], ' ', [rfReplaceAll
]);
7481 if gUseChatSounds
and Taunt
and (gChatSounds
<> nil) and (Pos(': ', Text) > 0) then
7483 // remove player name
7484 Delete(Text, 1, Pos(': ', Text) + 2 - 1);
7485 // for FullWord check
7486 Text := toLowerCase1251(' ' + Text + ' ');
7487 fpText
:= FilterPunctuation(Text);
7489 for i
:= 0 to Length(gChatSounds
) - 1 do
7492 for j
:= 0 to Length(gChatSounds
[i
].Tags
) - 1 do
7494 if gChatSounds
[i
].FullWord
and (not IsPunctuation(gChatSounds
[i
].Tags
[j
])) then
7495 ok
:= Pos(' ' + gChatSounds
[i
].Tags
[j
] + ' ', fpText
) > 0
7497 ok
:= Pos(gChatSounds
[i
].Tags
[j
], Text) > 0;
7503 gChatSounds
[i
].Sound
.Play();
7509 g_Sound_PlayEx('SOUND_GAME_RADIO');
7512 procedure g_Game_Announce_GoodShot(SpawnerUID
: Word);
7521 if not g_Game_IsWatchedPlayer(SpawnerUID
) then
7525 if goodsnd
[a
].IsPlaying() then
7528 goodsnd
[Random(4)].Play();
7531 procedure g_Game_Announce_KillCombo(Param
: Integer);
7538 UID
:= Param
and $FFFF;
7543 Pl
:= g_Player_Get(UID
);
7552 g_Console_Add(Format(_lc
[I_PLAYER_KILL_2X
], [Name
]), True);
7556 g_Console_Add(Format(_lc
[I_PLAYER_KILL_3X
], [Name
]), True);
7560 g_Console_Add(Format(_lc
[I_PLAYER_KILL_4X
], [Name
]), True);
7564 g_Console_Add(Format(_lc
[I_PLAYER_KILL_MX
], [Name
]), True);
7572 if not g_Game_IsWatchedPlayer(UID
) then
7575 if (not g_Game_IsWatchedPlayer(UID
)) and (c
< 4) then
7579 if killsnd
[n
].IsPlaying() then
7584 procedure g_Game_Announce_BodyKill(SpawnerUID
: Word);
7593 if not g_Game_IsWatchedPlayer(SpawnerUID
) then
7597 if hahasnd
[a
].IsPlaying() then
7600 hahasnd
[Random(3)].Play();
7603 procedure g_Game_StartVote(Command
, Initiator
: string);
7607 if not gVotesEnabled
then Exit
;
7608 if gGameSettings
.GameType
<> GT_SERVER
then Exit
;
7609 if gVoteInProgress
or gVotePassed
then
7611 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_INPROGRESS
], [gVoteCommand
]), True);
7612 MH_SEND_VoteEvent(NET_VE_INPROGRESS
, gVoteCommand
);
7615 gVoteInProgress
:= True;
7616 gVotePassed
:= False;
7617 gVoteTimer
:= gTime
+ gVoteTimeout
* 1000;
7620 gVoteCommand
:= Command
;
7622 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
7623 Need
:= Floor((NetClientCount
+1)/2.0)+1
7625 Need
:= Floor(NetClientCount
/2.0)+1;
7626 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_STARTED
], [Initiator
, Command
, Need
]), True);
7627 MH_SEND_VoteEvent(NET_VE_STARTED
, Initiator
, Command
, Need
);
7630 procedure g_Game_CheckVote
;
7634 if gGameSettings
.GameType
<> GT_SERVER
then Exit
;
7635 if not gVoteInProgress
then Exit
;
7637 if (gTime
>= gVoteTimer
) then
7639 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
7640 Need
:= Floor((NetClientCount
+1)/2.0) + 1
7642 Need
:= Floor(NetClientCount
/2.0) + 1;
7643 if gVoteCount
>= Need
then
7645 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_PASSED
], [gVoteCommand
]), True);
7646 MH_SEND_VoteEvent(NET_VE_PASSED
, gVoteCommand
);
7647 gVotePassed
:= True;
7648 gVoteCmdTimer
:= gTime
+ 5000;
7652 g_Console_Add(_lc
[I_MESSAGE_VOTE_FAILED
], True);
7653 MH_SEND_VoteEvent(NET_VE_FAILED
);
7655 if NetClients
<> nil then
7656 for I
:= Low(NetClients
) to High(NetClients
) do
7657 if NetClients
[i
].Used
then
7658 NetClients
[i
].Voted
:= False;
7659 gVoteInProgress
:= False;
7665 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
7666 Need
:= Floor((NetClientCount
+1)/2.0) + 1
7668 Need
:= Floor(NetClientCount
/2.0) + 1;
7669 if gVoteCount
>= Need
then
7671 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_PASSED
], [gVoteCommand
]), True);
7672 MH_SEND_VoteEvent(NET_VE_PASSED
, gVoteCommand
);
7673 gVoteInProgress
:= False;
7674 gVotePassed
:= True;
7675 gVoteCmdTimer
:= gTime
+ 5000;
7678 if NetClients
<> nil then
7679 for I
:= Low(NetClients
) to High(NetClients
) do
7680 if NetClients
[i
].Used
then
7681 NetClients
[i
].Voted
:= False;
7686 procedure g_Game_LoadMapList(FileName
: string);
7694 if not FileExists(FileName
) then Exit
;
7696 AssignFile(ListFile
, FileName
);
7698 while not EOF(ListFile
) do
7700 ReadLn(ListFile
, s
);
7703 if s
= '' then Continue
;
7705 SetLength(MapList
, Length(MapList
)+1);
7706 MapList
[High(MapList
)] := s
;
7708 CloseFile(ListFile
);
7711 procedure g_Game_SetDebugMode();
7714 // ×èòû (äàæå â ñâîåé èãðå):
7718 procedure g_Game_SetLoadingText(Text: String; Max
: Integer; reWrite
: Boolean);
7722 if Length(LoadingStat
.Msgs
) = 0 then
7728 begin // Ïåðåõîäèì íà ñëåäóþùóþ ñòðîêó èëè ñêðîëëèðóåì:
7729 if NextMsg
= Length(Msgs
) then
7731 for i
:= 0 to High(Msgs
)-1 do
7732 Msgs
[i
] := Msgs
[i
+1];
7740 Msgs
[NextMsg
-1] := Text;
7744 PBarWasHere
:= false;
7747 g_ActiveWindow
:= nil;
7749 ProcessLoading(true);
7752 procedure g_Game_StepLoading(Value
: Integer = -1);
7763 if (ShowCount
> LOADING_SHOW_STEP
) or (Value
> -1) then
7771 procedure g_Game_ClearLoading();
7780 len
:= ((gScreenHeight
div 3)*2 - 50) div LOADING_INTERLINE
;
7781 if len
< 1 then len
:= 1;
7782 SetLength(Msgs
, len
);
7783 for len
:= Low(Msgs
) to High(Msgs
) do
7786 PBarWasHere
:= false;
7790 procedure Parse_Params(var pars
: TParamStrValues
);
7797 while i
<= ParamCount
do
7800 if (s
[1] = '-') and (Length(s
) > 1) then
7802 if (s
[2] = '-') and (Length(s
) > 2) then
7803 begin // Îäèíî÷íûé ïàðàìåòð
7804 SetLength(pars
, Length(pars
) + 1);
7805 with pars
[High(pars
)] do
7807 Name
:= LowerCase(s
);
7812 if (i
< ParamCount
) then
7813 begin // Ïàðàìåòð ñî çíà÷åíèåì
7815 SetLength(pars
, Length(pars
) + 1);
7816 with pars
[High(pars
)] do
7818 Name
:= LowerCase(s
);
7819 Value
:= LowerCase(ParamStr(i
));
7828 function Find_Param_Value(var pars
: TParamStrValues
; aName
: String): String;
7833 for i
:= 0 to High(pars
) do
7834 if pars
[i
].Name
= aName
then
7836 Result
:= pars
[i
].Value
;
7841 procedure g_Game_Process_Params();
7843 pars
: TParamStrValues
;
7846 LimT
, LimS
: Integer;
7857 s
:= Find_Param_Value(pars
, '--debug');
7860 g_Game_SetDebugMode();
7861 s
:= Find_Param_Value(pars
, '--netdump');
7866 // Connect when game loads
7867 ip
:= Find_Param_Value(pars
, '-connect');
7871 s
:= Find_Param_Value(pars
, '-port');
7872 if (s
= '') or not TryStrToInt(s
, Port
) then
7875 s
:= Find_Param_Value(pars
, '-pw');
7877 g_Game_StartClient(ip
, Port
, s
);
7881 s
:= LowerCase(Find_Param_Value(pars
, '-dbg-mainwad'));
7884 gDefaultMegawadStart
:= s
;
7887 if (Find_Param_Value(pars
, '--dbg-mainwad-restore') <> '') or
7888 (Find_Param_Value(pars
, '--dbg-mainwad-default') <> '') then
7890 gDefaultMegawadStart
:= DF_Default_Megawad_Start
;
7893 // Start map when game loads:
7894 map
:= LowerCase(Find_Param_Value(pars
, '-map'));
7895 if isWadPath(map
) then
7898 s
:= Find_Param_Value(pars
, '-gm');
7899 GMode
:= g_Game_TextToMode(s
);
7900 if GMode
= GM_NONE
then GMode
:= GM_DM
;
7901 if GMode
= GM_SINGLE
then GMode
:= GM_COOP
;
7904 s
:= Find_Param_Value(pars
, '-limt');
7905 if (s
= '') or (not TryStrToInt(s
, LimT
)) then
7911 s
:= Find_Param_Value(pars
, '-lims');
7912 if (s
= '') or (not TryStrToInt(s
, LimS
)) then
7918 s
:= Find_Param_Value(pars
, '-lives');
7919 if (s
= '') or (not TryStrToInt(s
, Lives
)) then
7925 s
:= Find_Param_Value(pars
, '-opt');
7927 Opt
:= GAME_OPTION_ALLOWEXIT
or GAME_OPTION_BOTVSPLAYER
or GAME_OPTION_BOTVSMONSTER
7929 Opt
:= StrToIntDef(s
, 0);
7931 Opt
:= GAME_OPTION_ALLOWEXIT
or GAME_OPTION_BOTVSPLAYER
or GAME_OPTION_BOTVSMONSTER
;
7934 s
:= Find_Param_Value(pars
, '--close');
7938 // Override map to test:
7939 s
:= LowerCase(Find_Param_Value(pars
, '-testmap'));
7942 if e_IsValidResourceName(s
) then
7943 e_FindResource(AllMapDirs
, s
);
7944 gTestMap
:= ExpandFileName(s
);
7947 // Delete test map after play:
7948 s
:= Find_Param_Value(pars
, '--testdelete');
7951 //gMapToDelete := MapsDir + map;
7952 e_WriteLog('"--testdelete" is deprecated, use --tempdelete.', TMsgType
.Fatal
);
7956 // Delete temporary WAD after play:
7957 s
:= Find_Param_Value(pars
, '--tempdelete');
7958 if (s
<> '') and (gTestMap
<> '') then
7960 gMapToDelete
:= gTestMap
;
7961 gTempDelete
:= True;
7964 // Number of players:
7965 s
:= Find_Param_Value(pars
, '-pl');
7967 n
:= DEFAULT_PLAYERS
7969 n
:= StrToIntDef(s
, DEFAULT_PLAYERS
);
7972 s
:= Find_Param_Value(pars
, '-port');
7973 if (s
= '') or not TryStrToInt(s
, Port
) then
7974 g_Game_StartCustom(map
, GMode
, LimT
, LimS
, Lives
, Opt
, n
)
7976 g_Game_StartServer(map
, GMode
, LimT
, LimS
, Lives
, Opt
, n
, 0, Port
);
7979 // Execute script when game loads:
7980 s
:= Find_Param_Value(pars
, '-exec');
7983 // if not isWadPath(s) then
7984 // s := GameDir + '/' + s;
7989 if IOResult
<> 0 then
7991 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], ['Failed to read file: ' + s
]), TMsgType
.Warning
);
7992 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_READ
], [s
]));
7996 e_WriteLog('Executing script: ' + s
, TMsgType
.Notify
);
7997 g_Console_Add(Format(_lc
[I_CONSOLE_EXEC
], [s
]));
8002 if IOResult
<> 0 then
8004 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], ['Failed to read file: ' + s
]), TMsgType
.Warning
);
8005 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_READ
], [s
]));
8009 if Pos('#', s
) <> 1 then // script comment
8010 g_Console_Process(s
, True);
8021 conRegVar('pf_draw_frame', @g_profile_frame_draw
, 'draw frame rendering profiles', 'render profiles');
8022 //conRegVar('pf_update_frame', @g_profile_frame_update, 'draw frame updating profiles', 'update profiles');
8023 conRegVar('pf_coldet', @g_profile_collision
, 'draw collision detection profiles', 'coldet profiles');
8024 conRegVar('pf_los', @g_profile_los
, 'draw monster LOS profiles', 'monster LOS profiles');
8026 conRegVar('r_sq_draw', @gdbg_map_use_accel_render
, 'accelerated spatial queries in rendering', 'accelerated rendering');
8027 conRegVar('cd_sq_enabled', @gdbg_map_use_accel_coldet
, 'accelerated spatial queries in map coldet', 'accelerated map coldet');
8028 conRegVar('mon_sq_enabled', @gmon_debug_use_sqaccel
, 'accelerated spatial queries for monsters', 'accelerated monster coldet');
8029 conRegVar('wtrace_sq_enabled', @gwep_debug_fast_trace
, 'accelerated spatial queries for weapon hitscan trace', 'accelerated weapon hitscan');
8031 conRegVar('pr_enabled', @gpart_dbg_enabled
, 'enable/disable particles', 'particles');
8032 conRegVar('pr_phys_enabled', @gpart_dbg_phys_enabled
, 'enable/disable particle physics', 'particle physics');
8034 conRegVar('los_enabled', @gmon_dbg_los_enabled
, 'enable/disable monster LOS calculations', 'monster LOS', true);
8035 conRegVar('mon_think', @gmon_debug_think
, 'enable/disable monster thinking', 'monster thinking', true);
8037 {$IFDEF ENABLE_HOLMES}
8038 conRegVar('dbg_holmes', @g_holmes_enabled
, 'enable/disable Holmes', 'Holmes', true);
8041 conRegVar('dbg_ignore_level_bounds', @g_dbg_ignore_bounds
, 'ignore level bounds', '', false);
8043 conRegVar('r_scale', @g_dbg_scale
, 0.01, 100.0, 'render scale', '', false);
8045 conRegVar('light_enabled', @gwin_k8_enable_light_experiments
, 'enable/disable dynamic lighting', 'lighting');
8046 conRegVar('light_player_halo', @g_playerLight
, 'enable/disable player halo', 'player light halo');
8048 conRegVar('r_smallmap_align_h', @r_smallmap_h
, 'halign: 0: left; 1: center; 2: right', 'horizontal aligning of small maps');
8049 conRegVar('r_smallmap_align_v', @r_smallmap_v
, 'valign: 0: top; 1: center; 2: bottom', 'vertial aligning of small maps');
8051 conRegVar('r_showfps', @gShowFPS
, 'draw fps counter', 'draw fps counter');
8052 conRegVar('r_showtime', @gShowTime
, 'show game time', 'show game time');