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 function g_Game_StartMap(asMegawad
: Boolean; Map
: String; Force
: Boolean = False; const oldMapPath
: AnsiString=''): Boolean;
106 procedure g_Game_ChangeMap(const MapPath
: String);
107 procedure g_Game_ExitLevel(const Map
: AnsiString);
108 function g_Game_GetFirstMap(WAD
: String): String;
109 function g_Game_GetNextMap(): String;
110 procedure g_Game_NextLevel();
111 procedure g_Game_Pause(Enable
: Boolean);
112 procedure g_Game_HolmesPause(Enable
: Boolean);
113 procedure g_Game_InGameMenu(Show
: Boolean);
114 function g_Game_IsWatchedPlayer(UID
: Word): Boolean;
115 function g_Game_IsWatchedTeam(Team
: Byte): Boolean;
116 procedure g_Game_Message(Msg
: String; Time
: Word);
117 procedure g_Game_LoadMapList(FileName
: String);
118 procedure g_Game_PauseAllSounds(Enable
: Boolean);
119 procedure g_Game_StopAllSounds(all
: Boolean);
120 procedure g_Game_UpdateTriggerSounds();
121 function g_Game_GetMegaWADInfo(WAD
: String): TMegaWADInfo
;
122 procedure g_Game_ChatSound(Text: String; Taunt
: Boolean = True);
123 procedure g_Game_Announce_GoodShot(SpawnerUID
: Word);
124 procedure g_Game_Announce_KillCombo(Param
: Integer);
125 procedure g_Game_Announce_BodyKill(SpawnerUID
: Word);
126 procedure g_Game_StartVote(Command
, Initiator
: string);
127 procedure g_Game_CheckVote
;
128 procedure g_TakeScreenShot();
129 procedure g_FatalError(Text: String);
130 procedure g_SimpleError(Text: String);
131 function g_Game_IsTestMap(): Boolean;
132 procedure g_Game_DeleteTestMap();
133 procedure GameCVars(P
: SSArray
);
134 procedure GameCommands(P
: SSArray
);
135 procedure GameCheats(P
: SSArray
);
136 procedure DebugCommands(P
: SSArray
);
137 procedure g_Game_Process_Params
;
138 procedure g_Game_SetLoadingText(Text: String; Max
: Integer; reWrite
: Boolean);
139 procedure g_Game_StepLoading(Value
: Integer = -1);
140 procedure g_Game_ClearLoading();
141 procedure g_Game_SetDebugMode();
142 procedure DrawLoadingStat();
143 procedure DrawMenuBackground(tex
: AnsiString);
145 { procedure SetWinPause(Enable: Boolean); }
150 LOADING_SHOW_STEP
= 100;
151 LOADING_INTERLINE
= 20;
166 MESSAGE_DIKEY
= WM_USER
+ 1;
171 EXIT_ENDLEVELSINGLE
= 4;
172 EXIT_ENDLEVELCUSTOM
= 5;
174 GAME_OPTION_RESERVED
= 1;
175 GAME_OPTION_TEAMDAMAGE
= 2;
176 GAME_OPTION_ALLOWEXIT
= 4;
177 GAME_OPTION_WEAPONSTAY
= 8;
178 GAME_OPTION_MONSTERS
= 16;
179 GAME_OPTION_BOTVSPLAYER
= 32;
180 GAME_OPTION_BOTVSMONSTER
= 64;
185 STATE_INTERCUSTOM
= 3;
186 STATE_INTERSINGLE
= 4;
192 LMS_RESPAWN_NONE
= 0;
193 LMS_RESPAWN_WARMUP
= 1;
194 LMS_RESPAWN_FINAL
= 2;
211 CONFIG_FILENAME
= 'Doom2DF.cfg';
213 TEST_MAP_NAME
= '$$$_TEST_$$$';
215 STD_PLAYER_MODEL
= 'Doomer';
225 gGameSettings
: TGameSettings
;
226 gPlayer1Settings
: TPlayerSettings
;
227 gPlayer2Settings
: TPlayerSettings
;
229 gPlayerScreenSize
: TDFPoint
;
230 gPlayer1ScreenCoord
: TDFPoint
;
231 gPlayer2ScreenCoord
: TDFPoint
;
232 gPlayer1
: TPlayer
= nil;
233 gPlayer2
: TPlayer
= nil;
234 gPlayerDrawn
: TPlayer
= nil;
236 gSwitchGameMode
: Byte = GM_DM
;
237 gHearPoint1
, gHearPoint2
: THearPoint
;
238 gSoundEffectsDF
: Boolean = False;
239 gSoundTriggerTime
: Word = 0;
240 gAnnouncer
: Integer = ANNOUNCE_NONE
;
241 goodsnd
: array[0..3] of TPlayableSound
;
242 killsnd
: array[0..3] of TPlayableSound
;
243 hahasnd
: array[0..2] of TPlayableSound
;
244 sound_get_flag
: array[0..1] of TPlayableSound
;
245 sound_lost_flag
: array[0..1] of TPlayableSound
;
246 sound_ret_flag
: array[0..1] of TPlayableSound
;
247 sound_cap_flag
: array[0..1] of TPlayableSound
;
248 gBodyKillEvent
: Integer = -1;
249 gDefInterTime
: ShortInt = -1;
250 gInterEndTime
: LongWord = 0;
251 gInterTime
: LongWord = 0;
252 gServInterTime
: Byte = 0;
253 gGameStartTime
: LongWord = 0;
254 gTotalMonsters
: Integer = 0;
255 gPauseMain
: Boolean = false;
256 gPauseHolmes
: Boolean = false;
257 gShowTime
: Boolean = False;
258 gShowFPS
: Boolean = False;
259 gShowGoals
: Boolean = True;
260 gShowStat
: Boolean = True;
261 gShowKillMsg
: Boolean = True;
262 gShowLives
: Boolean = True;
263 gShowPing
: Boolean = False;
264 gShowMap
: Boolean = False;
266 gState
: Byte = STATE_NONE
;
268 sWidth
, sHeight
: Word;
269 gSpectMode
: Byte = SPECT_NONE
;
270 gSpectHUD
: Boolean = True;
271 gSpectKeyPress
: Boolean = False;
272 gSpectX
: Integer = 0;
273 gSpectY
: Integer = 0;
274 gSpectStep
: Byte = 8;
275 gSpectViewTwo
: Boolean = False;
276 gSpectPID1
: Integer = -1;
277 gSpectPID2
: Integer = -1;
278 gSpectAuto
: Boolean = False;
279 gSpectAutoNext
: LongWord;
280 gSpectAutoStepX
: Integer;
281 gSpectAutoStepY
: Integer;
282 gMusic
: TMusic
= nil;
283 gLoadGameMode
: Boolean;
284 gCheats
: Boolean = False;
285 gMapOnce
: Boolean = False;
286 gMapToDelete
: String;
287 gTempDelete
: Boolean = False;
288 gLastMap
: Boolean = False;
289 gWinSizeX
, gWinSizeY
: Integer;
290 gWinFrameX
, gWinFrameY
, gWinCaption
: Integer;
291 gWinActive
: Boolean = True; // by default window is active, lol
292 gResolutionChange
: Boolean = False;
293 gRC_Width
, gRC_Height
: Integer;
294 gRC_FullScreen
, gRC_Maximized
: Boolean;
295 gLanguageChange
: Boolean = False;
296 gDebugMode
: Boolean = False;
297 g_debug_Sounds
: Boolean = False;
298 g_debug_Frames
: Boolean = False;
299 g_debug_WinMsgs
: Boolean = False;
300 g_debug_MonsterOff
: Boolean = False;
301 g_debug_BotAIOff
: Byte = 0;
302 g_debug_HealthBar
: Boolean = False;
303 g_Debug_Player
: Boolean = False;
304 gCoopMonstersKilled
: Word = 0;
305 gCoopSecretsFound
: Word = 0;
306 gCoopTotalMonstersKilled
: Word = 0;
307 gCoopTotalSecretsFound
: Word = 0;
308 gCoopTotalMonsters
: Word = 0;
309 gCoopTotalSecrets
: Word = 0;
310 gStatsOff
: Boolean = False;
311 gStatsPressed
: Boolean = False;
312 gExitByTrigger
: Boolean = False;
313 gNextMap
: String = '';
314 gLMSRespawn
: Byte = LMS_RESPAWN_NONE
;
315 gLMSRespawnTime
: Cardinal = 0;
316 gLMSSoftSpawn
: Boolean = False;
317 gMissionFailed
: Boolean = False;
318 gVoteInProgress
: Boolean = False;
319 gVotePassed
: Boolean = False;
320 gVoteCommand
: string = '';
321 gVoteTimer
: Cardinal = 0;
322 gVoteCmdTimer
: Cardinal = 0;
323 gVoteCount
: Integer = 0;
324 gVoteTimeout
: Cardinal = 30;
325 gVoted
: Boolean = False;
326 gVotesEnabled
: Boolean = True;
327 gEvents
: Array of TGameEvent
;
328 gDelayedEvents
: Array of TDelayedEvent
;
329 gUseChatSounds
: Boolean = True;
330 gChatSounds
: Array of TChatSound
;
331 gSelectWeapon
: Array [0..1, WP_FIRST
..WP_LAST
] of Boolean; // [player, weapon]
332 gInterReadyCount
: Integer = 0;
334 g_dbg_ignore_bounds
: Boolean = false;
335 r_smallmap_h
: Integer = 0; // 0: left; 1: center; 2: right
336 r_smallmap_v
: Integer = 2; // 0: top; 1: center; 2: bottom
338 // move button values:
339 // bits 0-1: l/r state:
340 // 0: neither left, nor right pressed
343 // bits 4-5: l/r state when strafe was pressed
344 P1MoveButton
: Byte = 0;
345 P2MoveButton
: Byte = 0;
347 g_profile_frame_update
: Boolean = false;
348 g_profile_frame_draw
: Boolean = false;
349 g_profile_collision
: Boolean = false;
350 g_profile_los
: Boolean = false;
351 g_profile_history_size
: Integer = 1000;
353 g_rlayer_back
: Boolean = true;
354 g_rlayer_step
: Boolean = true;
355 g_rlayer_wall
: Boolean = true;
356 g_rlayer_door
: Boolean = true;
357 g_rlayer_acid1
: Boolean = true;
358 g_rlayer_acid2
: Boolean = true;
359 g_rlayer_water
: Boolean = true;
360 g_rlayer_fore
: Boolean = true;
363 procedure g_ResetDynlights ();
364 procedure g_AddDynLight (x
, y
, radius
: Integer; r
, g
, b
, a
: Single);
365 procedure g_DynLightExplosion (x
, y
, radius
: Integer; r
, g
, b
: Single);
367 function conIsCheatsEnabled (): Boolean; inline;
368 function gPause (): Boolean; inline;
374 {$INCLUDE ../nogl/noGLuses.inc}
375 {$IFDEF ENABLE_HOLMES}
378 e_texture
, e_res
, g_textures
, g_main
, g_window
, g_menu
,
379 e_input
, e_log
, g_console
, g_items
, g_map
, g_panel
,
380 g_playermodel
, g_gfx
, g_options
, Math
,
381 g_triggers
, g_monsters
, e_sound
, CONFIG
,
383 ENet
, e_msg
, g_netmsg
, g_netmaster
,
384 sfs
, wadreader
, g_system
;
388 hasPBarGfx
: Boolean = false;
391 // ////////////////////////////////////////////////////////////////////////// //
392 function gPause (): Boolean; inline; begin result
:= gPauseMain
or gPauseHolmes
; end;
395 // ////////////////////////////////////////////////////////////////////////// //
396 function conIsCheatsEnabled (): Boolean; inline;
399 if g_Game_IsNet
then exit
;
400 if not gDebugMode
then
402 //if not gCheats then exit;
403 if not (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
]) then exit
;
404 if not (gGameSettings
.GameMode
in [GM_COOP
, GM_SINGLE
]) then exit
;
410 // ////////////////////////////////////////////////////////////////////////// //
412 profileFrameDraw
: TProfiler
= nil;
415 // ////////////////////////////////////////////////////////////////////////// //
418 x
, y
, radius
: Integer;
421 exploRadius
: Integer;
425 g_dynLights
: array of TDynLight
= nil;
426 g_dynLightCount
: Integer = 0;
427 g_playerLight
: Boolean = false;
429 procedure g_ResetDynlights ();
433 if not gwin_has_stencil
then begin g_dynLightCount
:= 0; exit
; end;
435 for idx
:= 0 to g_dynLightCount
-1 do
437 if g_dynLights
[idx
].exploCount
= -666 then
444 Inc(g_dynLights
[idx
].exploCount
);
445 if (g_dynLights
[idx
].exploCount
< 10) then
447 g_dynLights
[idx
].radius
:= g_dynLights
[idx
].exploRadius
+g_dynLights
[idx
].exploCount
*8;
448 g_dynLights
[idx
].a
:= 0.4+g_dynLights
[idx
].exploCount
/10;
449 if (g_dynLights
[idx
].a
> 0.8) then g_dynLights
[idx
].a
:= 0.8;
450 if lnum
<> idx
then g_dynLights
[lnum
] := g_dynLights
[idx
];
455 g_dynLightCount
:= lnum
;
458 procedure g_AddDynLight (x
, y
, radius
: Integer; r
, g
, b
, a
: Single);
460 if not gwin_has_stencil
then exit
;
461 if g_dynLightCount
= length(g_dynLights
) then SetLength(g_dynLights
, g_dynLightCount
+1024);
462 g_dynLights
[g_dynLightCount
].x
:= x
;
463 g_dynLights
[g_dynLightCount
].y
:= y
;
464 g_dynLights
[g_dynLightCount
].radius
:= radius
;
465 g_dynLights
[g_dynLightCount
].r
:= r
;
466 g_dynLights
[g_dynLightCount
].g
:= g
;
467 g_dynLights
[g_dynLightCount
].b
:= b
;
468 g_dynLights
[g_dynLightCount
].a
:= a
;
469 g_dynLights
[g_dynLightCount
].exploCount
:= -666;
470 Inc(g_dynLightCount
);
473 procedure g_DynLightExplosion (x
, y
, radius
: Integer; r
, g
, b
: Single);
475 if not gwin_has_stencil
then exit
;
476 if g_dynLightCount
= length(g_dynLights
) then SetLength(g_dynLights
, g_dynLightCount
+1024);
477 g_dynLights
[g_dynLightCount
].x
:= x
;
478 g_dynLights
[g_dynLightCount
].y
:= y
;
479 g_dynLights
[g_dynLightCount
].radius
:= 0;
480 g_dynLights
[g_dynLightCount
].exploRadius
:= radius
;
481 g_dynLights
[g_dynLightCount
].r
:= r
;
482 g_dynLights
[g_dynLightCount
].g
:= g
;
483 g_dynLights
[g_dynLightCount
].b
:= b
;
484 g_dynLights
[g_dynLightCount
].a
:= 0;
485 g_dynLights
[g_dynLightCount
].exploCount
:= 0;
486 Inc(g_dynLightCount
);
490 // ////////////////////////////////////////////////////////////////////////// //
491 function calcProfilesHeight (prof
: TProfiler
): Integer;
494 if (prof
= nil) then exit
;
495 if (length(prof
.bars
) = 0) then exit
;
496 result
:= length(prof
.bars
)*(16+2);
500 function drawProfiles (x
, y
: Integer; prof
: TProfiler
): Integer;
507 if (prof
= nil) then exit
;
509 if (length(prof
.bars
) = 0) then exit
;
511 hgt
:= calcProfilesHeight(prof
);
512 if (x
< 0) then x
:= gScreenWidth
-(wdt
-1)+x
;
513 if (y
< 0) then y
:= gScreenHeight
-(hgt
-1)+y
;
515 //e_DrawFillQuad(x, y, x+wdt-1, y+hgt-1, 255, 255, 255, 200, B_BLEND);
516 //e_DrawFillQuad(x, y, x+wdt-1, y+hgt-1, 20, 20, 20, 0, B_NONE);
517 e_DarkenQuadWH(x
, y
, wdt
, hgt
, 150);
520 for ii
:= 0 to High(prof
.bars
) do
522 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);
529 // ////////////////////////////////////////////////////////////////////////// //
531 TEndCustomGameStat
= record
532 PlayerStat
: TPlayerStatArray
;
536 Map
, MapName
: String;
539 TEndSingleGameStat
= record
540 PlayerStat
: Array [0..1] of record
546 TotalSecrets
: Integer;
549 TLoadingStat
= record
553 Msgs
: Array of String;
555 PBarWasHere
: Boolean; // did we draw a progress bar for this message?
558 TParamStrValue
= record
563 TParamStrValues
= Array of TParamStrValue
;
566 INTER_ACTION_TEXT
= 1;
567 INTER_ACTION_PIC
= 2;
568 INTER_ACTION_MUSIC
= 3;
572 FPSCounter
, UPSCounter
: Word;
573 FPSTime
, UPSTime
: LongWord;
574 DataLoaded
: Boolean = False;
575 IsDrawStat
: Boolean = False;
576 CustomStat
: TEndCustomGameStat
;
577 SingleStat
: TEndSingleGameStat
;
578 LoadingStat
: TLoadingStat
;
579 EndingGameCounter
: Byte = 0;
582 MessageLineLength
: Integer = 80;
583 MapList
: SSArray
= nil;
584 MapIndex
: Integer = -1;
585 InterReadyTime
: Integer = -1;
591 text: Array of ShortString;
592 anim
: Array of ShortString;
593 pic
: Array of ShortString;
594 mus
: Array of ShortString;
596 triggers
: Array of record
598 actions
: Array of record
599 action
, p1
, p2
: Integer;
602 cur_trigger
: Integer;
615 function Compare(a
, b
: TPlayerStat
): Integer;
617 if a
.Spectator
then Result
:= 1
618 else if b
.Spectator
then Result
:= -1
619 else if a
.Frags
< b
.Frags
then Result
:= 1
620 else if a
.Frags
> b
.Frags
then Result
:= -1
621 else if a
.Deaths
< b
.Deaths
then Result
:= -1
622 else if a
.Deaths
> b
.Deaths
then Result
:= 1
623 else if a
.Kills
< b
.Kills
then Result
:= -1
627 procedure SortGameStat(var stat
: TPlayerStatArray
);
632 if stat
= nil then Exit
;
634 for I
:= High(stat
) downto Low(stat
) do
635 for J
:= Low(stat
) to High(stat
) - 1 do
636 if Compare(stat
[J
], stat
[J
+ 1]) = 1 then
639 stat
[J
] := stat
[J
+ 1];
644 function g_Game_ModeToText(Mode
: Byte): string;
648 GM_DM
: Result
:= _lc
[I_MENU_GAME_TYPE_DM
];
649 GM_TDM
: Result
:= _lc
[I_MENU_GAME_TYPE_TDM
];
650 GM_CTF
: Result
:= _lc
[I_MENU_GAME_TYPE_CTF
];
651 GM_COOP
: Result
:= _lc
[I_MENU_GAME_TYPE_COOP
];
652 GM_SINGLE
: Result
:= _lc
[I_MENU_GAME_TYPE_SINGLE
];
656 function g_Game_TextToMode(Mode
: string): Byte;
659 Mode
:= UpperCase(Mode
);
660 if Mode
= _lc
[I_MENU_GAME_TYPE_DM
] then
665 if Mode
= _lc
[I_MENU_GAME_TYPE_TDM
] then
670 if Mode
= _lc
[I_MENU_GAME_TYPE_CTF
] then
675 if Mode
= _lc
[I_MENU_GAME_TYPE_COOP
] then
680 if Mode
= _lc
[I_MENU_GAME_TYPE_SINGLE
] then
687 function g_Game_IsNet(): Boolean;
689 Result
:= (gGameSettings
.GameType
in [GT_SERVER
, GT_CLIENT
]);
692 function g_Game_IsServer(): Boolean;
694 Result
:= (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
, GT_SERVER
]);
697 function g_Game_IsClient(): Boolean;
699 Result
:= (gGameSettings
.GameType
= GT_CLIENT
);
702 function g_Game_GetMegaWADInfo(WAD
: String): TMegaWADInfo
;
709 Result
.name
:= ExtractFileName(WAD
);
710 Result
.description
:= '';
713 w
:= TWADFile
.Create();
716 if not w
.GetResource('INTERSCRIPT', p
, len
) then
722 cfg
:= TConfig
.CreateMem(p
, len
);
723 Result
.name
:= cfg
.ReadStr('megawad', 'name', ExtractFileName(WAD
));
724 Result
.description
:= cfg
.ReadStr('megawad', 'description', '');
725 Result
.author
:= cfg
.ReadStr('megawad', 'author', '');
726 Result
.pic
:= cfg
.ReadStr('megawad', 'pic', '');
732 procedure g_Game_FreeWAD();
736 for a
:= 0 to High(MegaWAD
.res
.pic
) do
737 if MegaWAD
.res
.pic
[a
] <> '' then
738 g_Texture_Delete(MegaWAD
.res
.pic
[a
]);
740 for a
:= 0 to High(MegaWAD
.res
.mus
) do
741 if MegaWAD
.res
.mus
[a
] <> '' then
742 g_Sound_Delete(MegaWAD
.res
.mus
[a
]);
744 MegaWAD
.res
.pic
:= nil;
745 MegaWAD
.res
.text := nil;
746 MegaWAD
.res
.anim
:= nil;
747 MegaWAD
.res
.mus
:= nil;
748 MegaWAD
.triggers
:= nil;
750 g_Texture_Delete('TEXTURE_endpic');
751 g_Sound_Delete('MUSIC_endmus');
753 ZeroMemory(@MegaWAD
, SizeOf(MegaWAD
));
754 gGameSettings
.WAD
:= '';
757 procedure g_Game_LoadWAD(WAD
: string);
766 gGameSettings
.WAD
:= WAD
;
767 if not (gGameSettings
.GameMode
in [GM_COOP
, GM_SINGLE
]) then
770 MegaWAD
.info
:= g_Game_GetMegaWADInfo(WAD
);
772 w
:= TWADFile
.Create();
775 if not w
.GetResource('INTERSCRIPT', p
, len
) then
781 cfg
:= TConfig
.CreateMem(p
, len
);
786 s := cfg.ReadStr('pic', 'pic'+IntToStr(b), '');
787 if s = '' then Break;
790 SetLength(MegaWAD.res.pic, Length(MegaWAD.res.pic)+1);
791 MegaWAD.res.pic[High(MegaWAD.res.pic)] := s;
793 g_Texture_CreateWADEx(s, s);
799 s := cfg.ReadStr('mus', 'mus'+IntToStr(b), '');
800 if s = '' then Break;
803 SetLength(MegaWAD.res.mus, Length(MegaWAD.res.mus)+1);
804 MegaWAD.res.mus[High(MegaWAD.res.mus)] := s;
806 g_Music_CreateWADEx(s, s);
809 MegaWAD
.endpic
:= cfg
.ReadStr('megawad', 'endpic', '');
810 if MegaWAD
.endpic
<> '' then
812 TEXTUREFILTER
:= GL_LINEAR
;
813 s
:= e_GetResourcePath(WadDirs
, MegaWAD
.endpic
, WAD
);
814 g_Texture_CreateWADEx('TEXTURE_endpic', s
);
815 TEXTUREFILTER
:= GL_NEAREST
;
817 MegaWAD
.endmus
:= cfg
.ReadStr('megawad', 'endmus', 'Standart.wad:D2DMUS\ÊÎÍÅÖ');
818 if MegaWAD
.endmus
<> '' then
820 s
:= e_GetResourcePath(WadDirs
, MegaWAD
.endmus
, WAD
);
821 g_Sound_CreateWADEx('MUSIC_endmus', s
, True);
829 {procedure start_trigger(t: string);
833 function next_trigger(): Boolean;
837 procedure DisableCheats();
843 if gPlayer1
<> nil then gPlayer1
.GodMode
:= False;
844 if gPlayer2
<> nil then gPlayer2
.GodMode
:= False;
845 if gPlayer1
<> nil then gPlayer1
.NoTarget
:= False;
846 if gPlayer2
<> nil then gPlayer2
.NoTarget
:= False;
848 {$IF DEFINED(D2F_DEBUG)}
849 if gPlayer1
<> nil then gPlayer1
.NoTarget
:= True;
850 gAimLine
:= g_dbg_aimline_on
;
854 procedure g_Game_ExecuteEvent(Name
: String);
860 if gEvents
= nil then
862 for a
:= 0 to High(gEvents
) do
863 if gEvents
[a
].Name
= Name
then
865 if gEvents
[a
].Command
<> '' then
866 g_Console_Process(gEvents
[a
].Command
, True);
871 function g_Game_DelayEvent(DEType
: Byte; Time
: LongWord; Num
: Integer = 0; Str
: String = ''): Integer;
876 if gDelayedEvents
<> nil then
877 for a
:= 0 to High(gDelayedEvents
) do
878 if not gDelayedEvents
[a
].Pending
then
885 SetLength(gDelayedEvents
, Length(gDelayedEvents
) + 1);
886 n
:= High(gDelayedEvents
);
888 gDelayedEvents
[n
].Pending
:= True;
889 gDelayedEvents
[n
].DEType
:= DEType
;
890 gDelayedEvents
[n
].DENum
:= Num
;
891 gDelayedEvents
[n
].DEStr
:= Str
;
892 if DEType
= DE_GLOBEVENT
then
893 gDelayedEvents
[n
].Time
:= (sys_GetTicks() {div 1000}) + Time
895 gDelayedEvents
[n
].Time
:= gTime
+ Time
;
904 if g_Game_IsNet
and g_Game_IsServer
then
905 MH_SEND_GameEvent(NET_EV_MAPEND
, Byte(gMissionFailed
));
909 gPauseHolmes
:= false;
912 g_Game_StopAllSounds(False);
917 EndingGameCounter
:= 0;
918 g_ActiveWindow
:= nil;
920 gLMSRespawn
:= LMS_RESPAWN_NONE
;
921 gLMSRespawnTime
:= 0;
924 EXIT_SIMPLE
: // Âûõîä ÷åðåç ìåíþ èëè êîíåö òåñòà
929 begin // Ýòî áûë òåñò
933 begin // Âûõîä â ãëàâíîå ìåíþ
934 gMusic
.SetByName('MUSIC_MENU');
936 if gState
<> STATE_SLIST
then
938 g_GUI_ShowWindow('MainMenu');
939 gState
:= STATE_MENU
;
942 // Îáíîâëÿåì ñïèñîê ñåðâåðîâ
943 slReturnPressed
:= True;
944 if g_Net_Slist_Fetch(slCurrent
) then
946 if slCurrent
= nil then
947 slWaitStr
:= _lc
[I_NET_SLIST_NOSERVERS
];
950 slWaitStr
:= _lc
[I_NET_SLIST_ERROR
];
951 g_Serverlist_GenerateTable(slCurrent
, slTable
);
954 g_Game_ExecuteEvent('ongameend');
958 EXIT_RESTART
: // Íà÷àòü óðîâåíü ñíà÷àëà
960 if not g_Game_IsClient
then g_Game_Restart();
963 EXIT_ENDLEVELCUSTOM
: // Çàêîí÷èëñÿ óðîâåíü â Ñâîåé èãðå
965 // Ñòàòèñòèêà Ñâîåé èãðû:
966 FileName
:= g_ExtractWadName(gMapInfo
.Map
);
968 CustomStat
.GameTime
:= gTime
;
969 CustomStat
.Map
:= ExtractFileName(FileName
)+':'+g_ExtractFileName(gMapInfo
.Map
); //ResName;
970 CustomStat
.MapName
:= gMapInfo
.Name
;
971 CustomStat
.GameMode
:= gGameSettings
.GameMode
;
972 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
973 CustomStat
.TeamStat
:= gTeamStat
;
975 CustomStat
.PlayerStat
:= nil;
977 // Ñòàòèñòèêà èãðîêîâ:
978 if gPlayers
<> nil then
980 for a
:= 0 to High(gPlayers
) do
981 if gPlayers
[a
] <> nil then
983 SetLength(CustomStat
.PlayerStat
, Length(CustomStat
.PlayerStat
)+1);
984 with CustomStat
.PlayerStat
[High(CustomStat
.PlayerStat
)] do
987 Name
:= gPlayers
[a
].Name
;
988 Frags
:= gPlayers
[a
].Frags
;
989 Deaths
:= gPlayers
[a
].Death
;
990 Kills
:= gPlayers
[a
].Kills
;
991 Team
:= gPlayers
[a
].Team
;
992 Color
:= gPlayers
[a
].Model
.Color
;
993 Spectator
:= gPlayers
[a
].FSpectator
;
997 SortGameStat(CustomStat
.PlayerStat
);
1000 g_Game_ExecuteEvent('onmapend');
1001 if not g_Game_IsClient
then g_Player_ResetReady
;
1002 gInterReadyCount
:= 0;
1004 // Çàòóõàþùèé ýêðàí:
1005 EndingGameCounter
:= 255;
1006 gState
:= STATE_FOLD
;
1008 if gDefInterTime
< 0 then
1009 gInterEndTime
:= IfThen((gGameSettings
.GameType
= GT_SERVER
) and (gPlayer1
= nil), 15000, 25000)
1011 gInterEndTime
:= gDefInterTime
* 1000;
1014 EXIT_ENDLEVELSINGLE
: // Çàêîí÷èëñÿ óðîâåíü â Îäèíî÷íîé èãðå
1016 // Ñòàòèñòèêà Îäèíî÷íîé èãðû:
1017 SingleStat
.GameTime
:= gTime
;
1018 SingleStat
.TwoPlayers
:= gPlayer2
<> nil;
1019 SingleStat
.TotalSecrets
:= gSecretsCount
;
1020 // Ñòàòèñòèêà ïåðâîãî èãðîêà:
1021 SingleStat
.PlayerStat
[0].Kills
:= gPlayer1
.MonsterKills
;
1022 SingleStat
.PlayerStat
[0].Secrets
:= gPlayer1
.Secrets
;
1023 // Ñòàòèñòèêà âòîðîãî èãðîêà (åñëè åñòü):
1024 if SingleStat
.TwoPlayers
then
1026 SingleStat
.PlayerStat
[1].Kills
:= gPlayer2
.MonsterKills
;
1027 SingleStat
.PlayerStat
[1].Secrets
:= gPlayer2
.Secrets
;
1030 g_Game_ExecuteEvent('onmapend');
1033 if gNextMap
<> '' then
1035 gMusic
.SetByName('MUSIC_INTERMUS');
1037 gState
:= STATE_INTERSINGLE
;
1040 g_Game_ExecuteEvent('oninter');
1042 else // Áîëüøå íåò êàðò
1044 // Çàòóõàþùèé ýêðàí:
1045 EndingGameCounter
:= 255;
1046 gState
:= STATE_FOLD
;
1051 // Îêîí÷àíèå îáðàáîòàíî:
1052 if gExit
<> EXIT_QUIT
then
1056 procedure drawTime(X
, Y
: Integer); inline;
1058 e_TextureFontPrint(x
, y
,
1059 Format('%d:%.2d:%.2d', [
1060 gTime
div 1000 div 3600,
1061 (gTime
div 1000 div 60) mod 60,
1062 gTime
div 1000 mod 60
1067 procedure DrawStat();
1069 pc
, x
, y
, w
, h
: Integer;
1070 w1
, w2
, w3
, w4
: Integer;
1072 cw
, ch
, r
, g
, b
, rr
, gg
, bb
: Byte;
1075 stat
: TPlayerStatArray
;
1082 pc
:= g_Player_GetCount
;
1083 e_TextureFontGetSize(gStdFont
, cw
, ch
);
1085 w
:= gScreenWidth
-(gScreenWidth
div 5);
1086 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
1089 h
:= 40+ch
*5+(ch
+8)*pc
;
1090 x
:= (gScreenWidth
div 2)-(w
div 2);
1091 y
:= (gScreenHeight
div 2)-(h
div 2);
1093 e_DrawFillQuad(x
, y
, x
+w
-1, y
+h
-1, 64, 64, 64, 32);
1094 e_DrawQuad(x
, y
, x
+w
-1, y
+h
-1, 255, 127, 0);
1096 drawTime(x
+w
-78, y
+8);
1098 wad
:= g_ExtractWadNameNoPath(gMapInfo
.Map
);
1099 map
:= g_ExtractFileName(gMapInfo
.Map
);
1100 mapstr
:= wad
+ ':\' + map
+ ' - ' + gMapInfo
.Name
;
1102 case gGameSettings
.GameMode
of
1105 if gGameSettings
.MaxLives
= 0 then
1106 s1
:= _lc
[I_GAME_DM
]
1108 s1
:= _lc
[I_GAME_LMS
];
1109 s2
:= Format(_lc
[I_GAME_FRAG_LIMIT
], [gGameSettings
.GoalLimit
]);
1110 s3
:= Format(_lc
[I_GAME_TIME_LIMIT
], [gGameSettings
.TimeLimit
div 3600, (gGameSettings
.TimeLimit
div 60) mod 60, gGameSettings
.TimeLimit
mod 60]);
1115 if gGameSettings
.MaxLives
= 0 then
1116 s1
:= _lc
[I_GAME_TDM
]
1118 s1
:= _lc
[I_GAME_TLMS
];
1119 s2
:= Format(_lc
[I_GAME_FRAG_LIMIT
], [gGameSettings
.GoalLimit
]);
1120 s3
:= Format(_lc
[I_GAME_TIME_LIMIT
], [gGameSettings
.TimeLimit
div 3600, (gGameSettings
.TimeLimit
div 60) mod 60, gGameSettings
.TimeLimit
mod 60]);
1125 s1
:= _lc
[I_GAME_CTF
];
1126 s2
:= Format(_lc
[I_GAME_SCORE_LIMIT
], [gGameSettings
.GoalLimit
]);
1127 s3
:= Format(_lc
[I_GAME_TIME_LIMIT
], [gGameSettings
.TimeLimit
div 3600, (gGameSettings
.TimeLimit
div 60) mod 60, gGameSettings
.TimeLimit
mod 60]);
1132 if gGameSettings
.MaxLives
= 0 then
1133 s1
:= _lc
[I_GAME_COOP
]
1135 s1
:= _lc
[I_GAME_SURV
];
1136 s2
:= _lc
[I_GAME_MONSTERS
] + ' ' + IntToStr(gCoopMonstersKilled
) + '/' + IntToStr(gTotalMonsters
);
1137 s3
:= _lc
[I_GAME_SECRETS
] + ' ' + IntToStr(gCoopSecretsFound
) + '/' + IntToStr(gSecretsCount
);
1148 e_TextureFontPrintEx(x
+(w
div 2)-(Length(s1
)*cw
div 2), _y
, s1
, gStdFont
, 255, 255, 255, 1);
1150 e_TextureFontPrintEx(x
+(w
div 2)-(Length(mapstr
)*cw
div 2), _y
, mapstr
, gStdFont
, 200, 200, 200, 1);
1152 e_TextureFontPrintEx(x
+16, _y
, s2
, gStdFont
, 200, 200, 200, 1);
1154 e_TextureFontPrintEx(x
+w
-16-(Length(s3
))*cw
, _y
, s3
,
1155 gStdFont
, 200, 200, 200, 1);
1157 if NetMode
= NET_SERVER
then
1158 e_TextureFontPrintEx(x
+8, y
+ 8, _lc
[I_NET_SERVER
], gStdFont
, 255, 255, 255, 1)
1160 if NetMode
= NET_CLIENT
then
1161 e_TextureFontPrintEx(x
+8, y
+ 8,
1162 NetClientIP
+ ':' + IntToStr(NetClientPort
), gStdFont
, 255, 255, 255, 1);
1166 stat
:= g_Player_GetStats();
1169 w2
:= (w
-16) div 6 + 48; // øèðèíà 2 ñòîëáöà
1170 w3
:= (w
-16) div 6; // øèðèíà 3 è 4 ñòîëáöîâ
1172 w1
:= w
-16-w2
-w3
-w4
; // îñòàâøååñÿ ïðîñòðàíñòâî - äëÿ öâåòà è èìåíè èãðîêà
1174 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
1178 for a
:= TEAM_RED
to TEAM_BLUE
do
1180 if a
= TEAM_RED
then
1182 s1
:= _lc
[I_GAME_TEAM_RED
];
1189 s1
:= _lc
[I_GAME_TEAM_BLUE
];
1195 e_TextureFontPrintEx(x
+16, _y
, s1
, gStdFont
, r
, g
, b
, 1);
1196 e_TextureFontPrintEx(x
+w1
+16, _y
, IntToStr(gTeamStat
[a
].Goals
),
1197 gStdFont
, r
, g
, b
, 1);
1199 _y
:= _y
+ch
+(ch
div 4);
1200 e_DrawLine(1, x
+16, _y
, x
+w
-16, _y
, r
, g
, b
);
1201 _y
:= _y
+(ch
div 4);
1203 for aa
:= 0 to High(stat
) do
1204 if stat
[aa
].Team
= a
then
1220 e_TextureFontPrintEx(x
+16, _y
, Name
, gStdFont
, rr
, gg
, bb
, 1);
1222 e_TextureFontPrintEx(x
+w1
+16, _y
, Format(_lc
[I_GAME_PING_MS
], [Ping
, Loss
]), gStdFont
, rr
, gg
, bb
, 1);
1224 e_TextureFontPrintEx(x
+w1
+w2
+16, _y
, IntToStr(Frags
), gStdFont
, rr
, gg
, bb
, 1);
1226 e_TextureFontPrintEx(x
+w1
+w2
+w3
+16, _y
, IntToStr(Deaths
), gStdFont
, rr
, gg
, bb
, 1);
1233 else if gGameSettings
.GameMode
in [GM_DM
, GM_COOP
] then
1236 e_TextureFontPrintEx(x
+16, _y
, _lc
[I_GAME_PLAYER_NAME
], gStdFont
, 255, 127, 0, 1);
1237 e_TextureFontPrintEx(x
+16+w1
, _y
, _lc
[I_GAME_PING
], gStdFont
, 255, 127, 0, 1);
1238 e_TextureFontPrintEx(x
+16+w1
+w2
, _y
, _lc
[I_GAME_FRAGS
], gStdFont
, 255, 127, 0, 1);
1239 e_TextureFontPrintEx(x
+16+w1
+w2
+w3
, _y
, _lc
[I_GAME_DEATHS
], gStdFont
, 255, 127, 0, 1);
1242 for aa
:= 0 to High(stat
) do
1256 e_DrawFillQuad(x
+16, _y
+4, x
+32-1, _y
+16+4-1, Color
.R
, Color
.G
, Color
.B
, 0);
1257 e_DrawQuad(x
+16, _y
+4, x
+32-1, _y
+16+4-1, 192, 192, 192);
1259 e_TextureFontPrintEx(x
+16+16+8, _y
+4, Name
, gStdFont
, r
, g
, 0, 1);
1261 e_TextureFontPrintEx(x
+w1
+16, _y
+4, Format(_lc
[I_GAME_PING_MS
], [Ping
, Loss
]), gStdFont
, r
, g
, 0, 1);
1263 e_TextureFontPrintEx(x
+w1
+w2
+16, _y
+4, IntToStr(Frags
), gStdFont
, r
, g
, 0, 1);
1265 e_TextureFontPrintEx(x
+w1
+w2
+w3
+16, _y
+4, IntToStr(Deaths
), gStdFont
, r
, g
, 0, 1);
1271 procedure g_Game_Init();
1274 knownFiles
: array of AnsiString = nil;
1276 wext
, s
: AnsiString;
1281 gTempDelete
:= False;
1283 sfsGCDisable(); // temporary disable removing of temporary volumes
1286 TEXTUREFILTER
:= GL_LINEAR
;
1287 g_Texture_CreateWADEx('MENU_BACKGROUND', GameWAD
+':TEXTURES\TITLE');
1288 g_Texture_CreateWADEx('INTER', GameWAD
+':TEXTURES\INTER');
1289 g_Texture_CreateWADEx('ENDGAME_EN', GameWAD
+':TEXTURES\ENDGAME_EN');
1290 g_Texture_CreateWADEx('ENDGAME_RU', GameWAD
+':TEXTURES\ENDGAME_RU');
1291 TEXTUREFILTER
:= GL_NEAREST
;
1293 LoadStdFont('STDTXT', 'STDFONT', gStdFont
);
1294 LoadFont('MENUTXT', 'MENUFONT', gMenuFont
);
1295 LoadFont('SMALLTXT', 'SMALLFONT', gMenuSmallFont
);
1297 g_Game_ClearLoading();
1298 g_Game_SetLoadingText(Format('Doom 2D: Forever %s', [GAME_VERSION
]), 0, False);
1299 g_Game_SetLoadingText('', 0, False);
1301 g_Game_SetLoadingText(_lc
[I_LOAD_CONSOLE
], 0, False);
1304 g_Game_SetLoadingText(_lc
[I_LOAD_MODELS
], 0, False);
1305 g_PlayerModel_LoadData();
1307 // load models from all possible wad types, in all known directories
1308 // this does a loosy job (linear search, ooph!), but meh
1309 for wext
in wadExtensions
do
1311 for f
:= High(ModelDirs
) downto Low(ModelDirs
) do
1313 if (FindFirst(ModelDirs
[f
]+DirectorySeparator
+'*'+wext
, faAnyFile
, SR
) = 0) then
1317 for s
in knownFiles
do
1319 if (strEquCI1251(forceFilenameExt(SR
.Name
, ''), forceFilenameExt(ExtractFileName(s
), ''))) then
1327 SetLength(knownFiles
, length(knownFiles
)+1);
1328 knownFiles
[High(knownFiles
)] := ModelDirs
[f
]+DirectorySeparator
+SR
.Name
;
1330 until (FindNext(SR
) <> 0);
1336 if (length(knownFiles
) = 0) then raise Exception
.Create('no player models found!');
1338 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
);
1339 for s
in knownFiles
do
1341 if not g_PlayerModel_Load(s
) then e_LogWritefln('Error loading model "%s"', [s
], TMsgType
.Warning
);
1345 gPauseMain
:= false;
1346 gPauseHolmes
:= false;
1349 {e_MouseInfo.Accel := 1.0;}
1351 g_Game_SetLoadingText(_lc
[I_LOAD_GAME_DATA
], 0, False);
1354 g_Game_SetLoadingText(_lc
[I_LOAD_MUSIC
], 0, False);
1355 g_Sound_CreateWADEx('MUSIC_INTERMUS', GameWAD
+':MUSIC\INTERMUS', True);
1356 g_Sound_CreateWADEx('MUSIC_MENU', GameWAD
+':MUSIC\MENU', True);
1357 g_Sound_CreateWADEx('MUSIC_ROUNDMUS', GameWAD
+':MUSIC\ROUNDMUS', True, True);
1358 g_Sound_CreateWADEx('MUSIC_STDENDMUS', GameWAD
+':MUSIC\ENDMUS', True);
1361 g_Game_SetLoadingText(_lc
[I_LOAD_MENUS
], 0, False);
1365 gMusic
:= TMusic
.Create();
1366 gMusic
.SetByName('MUSIC_MENU');
1369 gGameSettings
.WarmupTime
:= 30;
1371 gState
:= STATE_MENU
;
1373 SetLength(gEvents
, 6);
1374 gEvents
[0].Name
:= 'ongamestart';
1375 gEvents
[1].Name
:= 'ongameend';
1376 gEvents
[2].Name
:= 'onmapstart';
1377 gEvents
[3].Name
:= 'onmapend';
1378 gEvents
[4].Name
:= 'oninter';
1379 gEvents
[5].Name
:= 'onwadend';
1381 sfsGCEnable(); // enable releasing unused volumes
1385 procedure g_Game_Free(freeTextures
: Boolean=true);
1387 if NetMode
= NET_CLIENT
then g_Net_Disconnect();
1388 if NetMode
= NET_SERVER
then g_Net_Host_Die();
1390 g_Map_Free(freeTextures
);
1392 g_Player_RemoveAllCorpses();
1394 gGameSettings
.GameType
:= GT_NONE
;
1395 if gGameSettings
.GameMode
= GM_SINGLE
then
1396 gGameSettings
.GameMode
:= GM_DM
;
1397 gSwitchGameMode
:= gGameSettings
.GameMode
;
1400 gExitByTrigger
:= False;
1403 function IsActivePlayer(p
: TPlayer
): Boolean;
1408 Result
:= (not p
.FDummy
) and (not p
.FSpectator
);
1411 function GetActivePlayer_ByID(ID
: Integer): TPlayer
;
1418 if gPlayers
= nil then
1420 for a
:= Low(gPlayers
) to High(gPlayers
) do
1421 if IsActivePlayer(gPlayers
[a
]) then
1423 if gPlayers
[a
].UID
<> ID
then
1425 Result
:= gPlayers
[a
];
1430 function GetActivePlayerID_Next(Skip
: Integer = -1): Integer;
1436 if gPlayers
= nil then
1440 for a
:= Low(gPlayers
) to High(gPlayers
) do
1441 if IsActivePlayer(gPlayers
[a
]) then
1443 SetLength(ids
, Length(ids
) + 1);
1444 ids
[High(ids
)] := gPlayers
[a
].UID
;
1445 if gPlayers
[a
].UID
= Skip
then
1448 if Length(ids
) = 0 then
1453 Result
:= ids
[(idx
+ 1) mod Length(ids
)];
1456 function GetActivePlayerID_Prev(Skip
: Integer = -1): Integer;
1462 if gPlayers
= nil then
1466 for a
:= Low(gPlayers
) to High(gPlayers
) do
1467 if IsActivePlayer(gPlayers
[a
]) then
1469 SetLength(ids
, Length(ids
) + 1);
1470 ids
[High(ids
)] := gPlayers
[a
].UID
;
1471 if gPlayers
[a
].UID
= Skip
then
1474 if Length(ids
) = 0 then
1477 Result
:= ids
[Length(ids
) - 1]
1479 Result
:= ids
[(Length(ids
) - 1 + idx
) mod Length(ids
)];
1482 function GetActivePlayerID_Random(Skip
: Integer = -1): Integer;
1488 if gPlayers
= nil then
1492 for a
:= Low(gPlayers
) to High(gPlayers
) do
1493 if IsActivePlayer(gPlayers
[a
]) then
1495 SetLength(ids
, Length(ids
) + 1);
1496 ids
[High(ids
)] := gPlayers
[a
].UID
;
1497 if gPlayers
[a
].UID
= Skip
then
1500 if Length(ids
) = 0 then
1502 if Length(ids
) = 1 then
1507 Result
:= ids
[Random(Length(ids
))];
1509 while (idx
<> -1) and (Result
= Skip
) and (a
> 0) do
1511 Result
:= ids
[Random(Length(ids
))];
1516 function GetRandomSpectMode(Current
: Byte): Byte;
1523 0: Result
:= SPECT_STATS
;
1524 1: Result
:= SPECT_MAPVIEW
;
1525 2: Result
:= SPECT_MAPVIEW
;
1526 3: Result
:= SPECT_PLAYERS
;
1527 4: Result
:= SPECT_PLAYERS
;
1528 5: Result
:= SPECT_PLAYERS
;
1529 6: Result
:= SPECT_PLAYERS
;
1531 if (Current
in [SPECT_STATS
, SPECT_MAPVIEW
]) and (Current
= Result
) then
1535 procedure ProcessPlayerControls (plr
: TPlayer
; p
: Integer; var MoveButton
: Byte);
1541 if (plr
= nil) then exit
;
1542 if (p
= 2) then time
:= 1000 else time
:= 1;
1543 strafeDir
:= MoveButton
shr 4;
1544 MoveButton
:= MoveButton
and $0F;
1546 if gPlayerAction
[p
, ACTION_MOVELEFT
] and (not gPlayerAction
[p
, ACTION_MOVERIGHT
]) then
1547 MoveButton
:= 1 // Íàæàòà òîëüêî "Âëåâî"
1548 else if (not gPlayerAction
[p
, ACTION_MOVELEFT
]) and gPlayerAction
[p
, ACTION_MOVERIGHT
] then
1549 MoveButton
:= 2 // Íàæàòà òîëüêî "Âïðàâî"
1550 else if (not gPlayerAction
[p
, ACTION_MOVELEFT
]) and (not gPlayerAction
[p
, ACTION_MOVERIGHT
]) then
1551 MoveButton
:= 0; // Íå íàæàòû íè "Âëåâî", íè "Âïðàâî"
1553 // Ñåé÷àñ èëè ðàíüøå áûëè íàæàòû "Âëåâî"/"Âïðàâî" => ïåðåäàåì èãðîêó:
1554 if MoveButton
= 1 then
1555 plr
.PressKey(KEY_LEFT
, time
)
1556 else if MoveButton
= 2 then
1557 plr
.PressKey(KEY_RIGHT
, time
);
1559 // if we have "strafe" key, turn off old strafe mechanics
1560 if gPlayerAction
[p
, ACTION_STRAFE
] then
1562 // new strafe mechanics
1563 if (strafeDir
= 0) then
1564 strafeDir
:= MoveButton
; // start strafing
1565 // now set direction according to strafe (reversed)
1566 if (strafeDir
= 2) then
1567 plr
.SetDirection(TDirection
.D_LEFT
)
1568 else if (strafeDir
= 1) then
1569 plr
.SetDirection(TDirection
.D_RIGHT
)
1573 strafeDir
:= 0; // not strafing anymore
1574 // Ðàíüøå áûëà íàæàòà "Âïðàâî", à ñåé÷àñ "Âëåâî" => áåæèì âïðàâî, ñìîòðèì âëåâî:
1575 if (MoveButton
= 2) and gPlayerAction
[p
, ACTION_MOVELEFT
] then
1576 plr
.SetDirection(TDirection
.D_LEFT
)
1577 // Ðàíüøå áûëà íàæàòà "Âëåâî", à ñåé÷àñ "Âïðàâî" => áåæèì âëåâî, ñìîòðèì âïðàâî:
1578 else if (MoveButton
= 1) and gPlayerAction
[p
, ACTION_MOVERIGHT
] then
1579 plr
.SetDirection(TDirection
.D_RIGHT
)
1580 // ×òî-òî áûëî íàæàòî è íå èçìåíèëîñü => êóäà áåæèì, òóäà è ñìîòðèì:
1581 else if MoveButton
<> 0 then
1582 plr
.SetDirection(TDirection(MoveButton
-1))
1585 // fix movebutton state
1586 MoveButton
:= MoveButton
or (strafeDir
shl 4);
1588 // Îñòàëüíûå êëàâèøè:
1589 if gPlayerAction
[p
, ACTION_JUMP
] then plr
.PressKey(KEY_JUMP
, time
);
1590 if gPlayerAction
[p
, ACTION_LOOKUP
] then plr
.PressKey(KEY_UP
, time
);
1591 if gPlayerAction
[p
, ACTION_LOOKDOWN
] then plr
.PressKey(KEY_DOWN
, time
);
1592 if gPlayerAction
[p
, ACTION_ATTACK
] then plr
.PressKey(KEY_FIRE
);
1593 if gPlayerAction
[p
, ACTION_WEAPNEXT
] then plr
.PressKey(KEY_NEXTWEAPON
);
1594 if gPlayerAction
[p
, ACTION_WEAPPREV
] then plr
.PressKey(KEY_PREVWEAPON
);
1595 if gPlayerAction
[p
, ACTION_ACTIVATE
] then plr
.PressKey(KEY_OPEN
);
1597 gPlayerAction
[p
, ACTION_WEAPNEXT
] := False; // HACK, remove after readyweaon&pendinweapon implementation
1598 gPlayerAction
[p
, ACTION_WEAPPREV
] := False; // HACK, remove after readyweaon&pendinweapon implementation
1600 for i
:= WP_FIRST
to WP_LAST
do
1602 if gSelectWeapon
[p
, i
] then
1604 plr
.QueueWeaponSwitch(i
); // all choices are passed there, and god will take the best
1605 gSelectWeapon
[p
, i
] := False
1609 // HACK: add dynlight here
1610 if gwin_k8_enable_light_experiments
then
1612 if e_KeyPressed(IK_F8
) and gGameOn
and (not gConsoleShow
) and (g_ActiveWindow
= nil) then
1614 g_playerLight
:= true;
1616 if e_KeyPressed(IK_F9
) and gGameOn
and (not gConsoleShow
) and (g_ActiveWindow
= nil) then
1618 g_playerLight
:= false;
1622 if gwin_has_stencil
and g_playerLight
then g_AddDynLight(plr
.GameX
+32, plr
.GameY
+40, 128, 1, 1, 0, 0.6);
1625 // HACK: don't have a "key was pressed" function
1626 procedure InterReady();
1628 if InterReadyTime
> gTime
then Exit
;
1629 InterReadyTime
:= gTime
+ 3000;
1630 MC_SEND_CheatRequest(NET_CHEAT_READY
);
1633 procedure g_Game_Update();
1635 Msg
: g_gui
.TMessage
;
1641 function sendMonsPos (mon
: TMonster
): Boolean;
1643 result
:= false; // don't stop
1644 // this will also reset "need-send" flag
1645 if mon
.gncNeedSend
then
1647 MH_SEND_MonsterPos(mon
.UID
);
1649 else if (mon
.MonsterType
= MONSTER_BARREL
) then
1651 if (mon
.GameVelX
<> 0) or (mon
.GameVelY
<> 0) then MH_SEND_MonsterPos(mon
.UID
);
1653 else if (mon
.MonsterState
<> MONSTATE_SLEEP
) then
1655 if (mon
.MonsterState
<> MONSTATE_DEAD
) or (mon
.GameVelX
<> 0) or (mon
.GameVelY
<> 0) then MH_SEND_MonsterPos(mon
.UID
);
1659 function sendMonsPosUnexpected (mon
: TMonster
): Boolean;
1661 result
:= false; // don't stop
1662 // this will also reset "need-send" flag
1663 if mon
.gncNeedSend
then MH_SEND_MonsterPos(mon
.UID
);
1667 reliableUpdate
: Boolean;
1672 // Ïîðà âûêëþ÷àòü èãðó:
1673 if gExit
= EXIT_QUIT
then
1675 // Èãðà çàêîí÷èëàñü - îáðàáàòûâàåì:
1679 if gExit
= EXIT_QUIT
then
1683 // ×èòàåì êëàâèàòóðó è äæîéñòèê, åñëè îêíî àêòèâíî
1684 // no need to, as we'll do it in event handler
1686 // Îáíîâëÿåì êîíñîëü (äâèæåíèå è ñîîáùåíèÿ):
1689 if (NetMode
= NET_NONE
) and (g_Game_IsNet
) and (gGameOn
or (gState
in [STATE_FOLD
, STATE_INTERCUSTOM
])) then
1691 gExit
:= EXIT_SIMPLE
;
1696 // process master server communications
1697 g_Net_Slist_Pulse();
1700 STATE_INTERSINGLE
, // Ñòàòèñòêà ïîñëå ïðîõîæäåíèÿ óðîâíÿ â Îäèíî÷íîé èãðå
1701 STATE_INTERCUSTOM
, // Ñòàòèñòêà ïîñëå ïðîõîæäåíèÿ óðîâíÿ â Ñâîåé èãðå
1702 STATE_INTERTEXT
, // Òåêñò ìåæäó óðîâíÿìè
1703 STATE_INTERPIC
: // Êàðòèíêà ìåæäó óðîâíÿìè
1705 if g_Game_IsNet
and g_Game_IsServer
then
1707 gInterTime
:= gInterTime
+ GAME_TICK
;
1708 a
:= Min((gInterEndTime
- gInterTime
) div 1000 + 1, 255);
1709 if a
<> gServInterTime
then
1711 gServInterTime
:= a
;
1712 MH_SEND_TimeSync(gServInterTime
);
1716 if (not g_Game_IsClient
) and
1720 e_KeyPressed(IK_RETURN
) or e_KeyPressed(IK_KPRETURN
) or e_KeyPressed(IK_SPACE
) or
1721 e_KeyPressed(VK_FIRE
) or e_KeyPressed(VK_OPEN
) or
1722 e_KeyPressed(JOY0_ATTACK
) or e_KeyPressed(JOY1_ATTACK
) or
1723 e_KeyPressed(JOY2_ATTACK
) or e_KeyPressed(JOY3_ATTACK
)
1725 and (not gJustChatted
) and (not gConsoleShow
) and (not gChatShow
)
1726 and (g_ActiveWindow
= nil)
1728 or (g_Game_IsNet
and ((gInterTime
> gInterEndTime
) or (gInterReadyCount
>= NetClientCount
)))
1731 begin // Íàæàëè <Enter>/<Ïðîáåë> èëè ïðîøëî äîñòàòî÷íî âðåìåíè:
1732 g_Game_StopAllSounds(True);
1734 if gMapOnce
then // Ýòî áûë òåñò
1735 gExit
:= EXIT_SIMPLE
1737 if gNextMap
<> '' then // Ïåðåõîäèì íà ñëåäóþùóþ êàðòó
1738 g_Game_ChangeMap(gNextMap
)
1739 else // Ñëåäóþùåé êàðòû íåò
1741 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
] then
1743 // Âûõîä â ãëàâíîå ìåíþ:
1745 g_GUI_ShowWindow('MainMenu');
1746 gMusic
.SetByName('MUSIC_MENU');
1748 gState
:= STATE_MENU
;
1751 // Ôèíàëüíàÿ êàðòèíêà:
1752 g_Game_ExecuteEvent('onwadend');
1754 if not gMusic
.SetByName('MUSIC_endmus') then
1755 gMusic
.SetByName('MUSIC_STDENDMUS');
1757 gState
:= STATE_ENDPIC
;
1759 g_Game_ExecuteEvent('ongameend');
1764 else if g_Game_IsClient
and
1767 e_KeyPressed(IK_RETURN
) or e_KeyPressed(IK_KPRETURN
) or e_KeyPressed(IK_SPACE
) or
1768 e_KeyPressed(VK_FIRE
) or e_KeyPressed(VK_OPEN
) or
1769 e_KeyPressed(JOY0_ATTACK
) or e_KeyPressed(JOY1_ATTACK
) or
1770 e_KeyPressed(JOY2_ATTACK
) or e_KeyPressed(JOY3_ATTACK
)
1772 and (not gJustChatted
) and (not gConsoleShow
) and (not gChatShow
)
1773 and (g_ActiveWindow
= nil)
1781 if gState
= STATE_INTERTEXT
then
1782 if InterText
.counter
> 0 then
1783 InterText
.counter
:= InterText
.counter
- 1;
1786 STATE_FOLD
: // Çàòóõàíèå ýêðàíà
1788 if EndingGameCounter
= 0 then
1790 // Çàêîí÷èëñÿ óðîâåíü â Ñâîåé èãðå:
1791 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
1793 InterReadyTime
:= -1;
1794 if gLastMap
and (gGameSettings
.GameMode
= GM_COOP
) then
1796 g_Game_ExecuteEvent('onwadend');
1797 if not gMusic
.SetByName('MUSIC_endmus') then
1798 gMusic
.SetByName('MUSIC_STDENDMUS');
1801 gMusic
.SetByName('MUSIC_ROUNDMUS');
1804 gState
:= STATE_INTERCUSTOM
;
1807 else // Çàêîí÷èëàñü ïîñëåäíÿÿ êàðòà â Îäèíî÷íîé èãðå
1809 gMusic
.SetByName('MUSIC_INTERMUS');
1811 gState
:= STATE_INTERSINGLE
;
1814 g_Game_ExecuteEvent('oninter');
1817 DecMin(EndingGameCounter
, 6, 0);
1820 STATE_ENDPIC
: // Êàðòèíêà îêîí÷àíèÿ ìåãàÂàäà
1822 if gMapOnce
then // Ýòî áûë òåñò
1824 gExit
:= EXIT_SIMPLE
;
1830 g_Serverlist_Control(slCurrent
, slTable
);
1833 // Ñòàòèñòèêà ïî Tab:
1835 IsDrawStat
:= (not gConsoleShow
) and (not gChatShow
) and (gGameSettings
.GameType
<> GT_SINGLE
) and g_Console_Action(ACTION_SCORES
);
1838 if gGameOn
and not gPause
and (gState
<> STATE_FOLD
) then
1840 // Âðåìÿ += 28 ìèëëèñåêóíä:
1841 gTime
:= gTime
+ GAME_TICK
;
1843 // Ñîîáùåíèå ïîñåðåäèíå ýêðàíà:
1844 if MessageTime
= 0 then
1846 if MessageTime
> 0 then
1847 MessageTime
:= MessageTime
- 1;
1849 if (g_Game_IsServer
) then
1851 // Áûë çàäàí ëèìèò âðåìåíè:
1852 if (gGameSettings
.TimeLimit
> 0) then
1853 if (gTime
- gGameStartTime
) div 1000 >= gGameSettings
.TimeLimit
then
1854 begin // Îí ïðîøåë => êîíåö óðîâíÿ
1859 // Íàäî ðåñïàâíèòü èãðîêîâ â LMS:
1860 if (gLMSRespawn
> LMS_RESPAWN_NONE
) and (gLMSRespawnTime
< gTime
) then
1861 g_Game_RestartRound(gLMSSoftSpawn
);
1863 // Ïðîâåðèì ðåçóëüòàò ãîëîñîâàíèÿ, åñëè âðåìÿ ïðîøëî
1864 if gVoteInProgress
and (gVoteTimer
< gTime
) then
1866 else if gVotePassed
and (gVoteCmdTimer
< gTime
) then
1868 g_Console_Process(gVoteCommand
);
1870 gVotePassed
:= False;
1873 // Çàìåðÿåì âðåìÿ çàõâàòà ôëàãîâ
1874 if gFlags
[FLAG_RED
].State
= FLAG_STATE_CAPTURED
then
1875 gFlags
[FLAG_RED
].CaptureTime
:= gFlags
[FLAG_RED
].CaptureTime
+ GAME_TICK
;
1876 if gFlags
[FLAG_BLUE
].State
= FLAG_STATE_CAPTURED
then
1877 gFlags
[FLAG_BLUE
].CaptureTime
:= gFlags
[FLAG_BLUE
].CaptureTime
+ GAME_TICK
;
1879 // Áûë çàäàí ëèìèò ïîáåä:
1880 if (gGameSettings
.GoalLimit
> 0) then
1884 if gGameSettings
.GameMode
= GM_DM
then
1885 begin // Â DM èùåì èãðîêà ñ max ôðàãàìè
1886 for i
:= 0 to High(gPlayers
) do
1887 if gPlayers
[i
] <> nil then
1888 if gPlayers
[i
].Frags
> b
then
1889 b
:= gPlayers
[i
].Frags
;
1892 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
1893 begin //  CTF/TDM âûáèðàåì êîìàíäó ñ íàèáîëüøèì ñ÷åòîì
1894 b
:= Max(gTeamStat
[TEAM_RED
].Goals
, gTeamStat
[TEAM_BLUE
].Goals
);
1897 // Ëèìèò ïîáåä íàáðàí => êîíåö óðîâíÿ:
1898 if b
>= gGameSettings
.GoalLimit
then
1905 // Îáðàáàòûâàåì êëàâèøè èãðîêîâ:
1906 if gPlayer1
<> nil then gPlayer1
.ReleaseKeys();
1907 if gPlayer2
<> nil then gPlayer2
.ReleaseKeys();
1908 if (not gConsoleShow
) and (not gChatShow
) and (g_ActiveWindow
= nil) then
1910 ProcessPlayerControls(gPlayer1
, 0, P1MoveButton
);
1911 ProcessPlayerControls(gPlayer2
, 1, P2MoveButton
);
1912 end // if not console
1915 if g_Game_IsNet
and (gPlayer1
<> nil) then gPlayer1
.PressKey(KEY_CHAT
, 10000);
1917 // process weapon switch queue
1921 if (gPlayer1
= nil) and (gPlayer2
= nil) and
1922 (not gConsoleShow
) and (not gChatShow
) and (g_ActiveWindow
= nil) then
1924 if not gSpectKeyPress
then
1926 if gPlayerAction
[0, ACTION_JUMP
] and (not gSpectAuto
) then
1928 // switch spect mode
1930 SPECT_NONE
: ; // not spectator
1932 SPECT_MAPVIEW
: Inc(gSpectMode
);
1933 SPECT_PLAYERS
: gSpectMode
:= SPECT_STATS
; // reset to 1
1935 gSpectKeyPress
:= True;
1937 if (gSpectMode
= SPECT_MAPVIEW
)
1938 and (not gSpectAuto
) then
1940 if gPlayerAction
[0, ACTION_MOVELEFT
] then
1941 gSpectX
:= Max(gSpectX
- gSpectStep
, 0);
1942 if gPlayerAction
[0, ACTION_MOVERIGHT
] then
1943 gSpectX
:= Min(gSpectX
+ gSpectStep
, gMapInfo
.Width
- gScreenWidth
);
1944 if gPlayerAction
[0, ACTION_LOOKUP
] then
1945 gSpectY
:= Max(gSpectY
- gSpectStep
, 0);
1946 if gPlayerAction
[0, ACTION_LOOKDOWN
] then
1947 gSpectY
:= Min(gSpectY
+ gSpectStep
, gMapInfo
.Height
- gScreenHeight
);
1948 if gPlayerAction
[0, ACTION_WEAPPREV
] then
1951 if gSpectStep
> 4 then gSpectStep
:= gSpectStep
shr 1;
1952 gSpectKeyPress
:= True;
1954 if gPlayerAction
[0, ACTION_WEAPNEXT
] then
1957 if gSpectStep
< 64 then gSpectStep
:= gSpectStep
shl 1;
1958 gSpectKeyPress
:= True;
1961 if (gSpectMode
= SPECT_PLAYERS
)
1962 and (not gSpectAuto
) then
1964 if gPlayerAction
[0, ACTION_LOOKUP
] then
1967 gSpectViewTwo
:= True;
1968 gSpectKeyPress
:= True;
1970 if gPlayerAction
[0, ACTION_LOOKDOWN
] then
1972 // remove second view
1973 gSpectViewTwo
:= False;
1974 gSpectKeyPress
:= True;
1976 if gPlayerAction
[0, ACTION_MOVELEFT
] then
1978 // prev player (view 1)
1979 gSpectPID1
:= GetActivePlayerID_Prev(gSpectPID1
);
1980 gSpectKeyPress
:= True;
1982 if gPlayerAction
[0, ACTION_MOVERIGHT
] then
1984 // next player (view 1)
1985 gSpectPID1
:= GetActivePlayerID_Next(gSpectPID1
);
1986 gSpectKeyPress
:= True;
1988 if gPlayerAction
[0, ACTION_WEAPPREV
] then
1990 // prev player (view 2)
1991 gSpectPID2
:= GetActivePlayerID_Prev(gSpectPID2
);
1992 gSpectKeyPress
:= True;
1994 if gPlayerAction
[0, ACTION_WEAPNEXT
] then
1996 // next player (view 2)
1997 gSpectPID2
:= GetActivePlayerID_Next(gSpectPID2
);
1998 gSpectKeyPress
:= True;
2001 if gPlayerAction
[0, ACTION_ATTACK
] then
2003 if (gSpectMode
= SPECT_STATS
) and (not gSpectAuto
) then
2006 gSpectAutoNext
:= 0;
2007 gSpectViewTwo
:= False;
2008 gSpectKeyPress
:= True;
2013 gSpectMode
:= SPECT_STATS
;
2014 gSpectAuto
:= False;
2015 gSpectKeyPress
:= True;
2020 if (not gPlayerAction
[0, ACTION_JUMP
]) and
2021 (not gPlayerAction
[0, ACTION_ATTACK
]) and
2022 (not gPlayerAction
[0, ACTION_MOVELEFT
]) and
2023 (not gPlayerAction
[0, ACTION_MOVERIGHT
]) and
2024 (not gPlayerAction
[0, ACTION_LOOKUP
]) and
2025 (not gPlayerAction
[0, ACTION_LOOKDOWN
]) and
2026 (not gPlayerAction
[0, ACTION_WEAPPREV
]) and
2027 (not gPlayerAction
[0, ACTION_WEAPNEXT
]) then
2028 gSpectKeyPress
:= False;
2032 if gSpectMode
= SPECT_MAPVIEW
then
2034 i
:= Min(Max(gSpectX
+ gSpectAutoStepX
, 0), gMapInfo
.Width
- gScreenWidth
);
2036 gSpectAutoNext
:= gTime
2039 i
:= Min(Max(gSpectY
+ gSpectAutoStepY
, 0), gMapInfo
.Height
- gScreenHeight
);
2041 gSpectAutoNext
:= gTime
2045 if gSpectAutoNext
<= gTime
then
2047 if gSpectAutoNext
> 0 then
2049 gSpectMode
:= GetRandomSpectMode(gSpectMode
);
2053 gSpectX
:= Random(gMapInfo
.Width
- gScreenWidth
);
2054 gSpectY
:= Random(gMapInfo
.Height
- gScreenHeight
);
2055 gSpectAutoStepX
:= Random(9) - 4;
2056 gSpectAutoStepY
:= Random(9) - 4;
2057 if ((gSpectX
< 800) and (gSpectAutoStepX
< 0)) or
2058 ((gSpectX
> gMapInfo
.Width
- gScreenWidth
- 800) and (gSpectAutoStepX
> 0)) then
2059 gSpectAutoStepX
:= gSpectAutoStepX
* -1;
2060 if ((gSpectY
< 800) and (gSpectAutoStepY
< 0)) or
2061 ((gSpectY
> gMapInfo
.Height
- gScreenHeight
- 800) and (gSpectAutoStepY
> 0)) then
2062 gSpectAutoStepY
:= gSpectAutoStepY
* -1;
2066 gSpectPID1
:= GetActivePlayerID_Random(gSpectPID1
);
2071 SPECT_STATS
: gSpectAutoNext
:= gTime
+ (Random(3) + 5) * 1000;
2072 SPECT_MAPVIEW
: gSpectAutoNext
:= gTime
+ (Random(4) + 7) * 1000;
2073 SPECT_PLAYERS
: gSpectAutoNext
:= gTime
+ (Random(7) + 8) * 1000;
2079 // Îáíîâëÿåì âñå îñòàëüíîå:
2082 g_Triggers_Update();
2084 g_Monsters_Update();
2086 g_Player_UpdateAll();
2087 g_Player_UpdatePhysicalObjects();
2089 // server: send newly spawned monsters unconditionally
2090 if (gGameSettings
.GameType
= GT_SERVER
) then
2092 if (Length(gMonstersSpawned
) > 0) then
2094 for I
:= 0 to High(gMonstersSpawned
) do MH_SEND_MonsterSpawn(gMonstersSpawned
[I
]);
2095 SetLength(gMonstersSpawned
, 0);
2099 if (gSoundTriggerTime
> 8) then
2101 g_Game_UpdateTriggerSounds();
2102 gSoundTriggerTime
:= 0;
2106 Inc(gSoundTriggerTime
);
2109 if (NetMode
= NET_SERVER
) then
2111 Inc(NetTimeToUpdate
);
2112 Inc(NetTimeToReliable
);
2114 // send monster updates
2115 if (NetTimeToReliable
>= NetRelupdRate
) or (NetTimeToUpdate
>= NetUpdateRate
) then
2117 // send all monsters (periodic sync)
2118 reliableUpdate
:= (NetTimeToReliable
>= NetRelupdRate
);
2120 for I
:= 0 to High(gPlayers
) do
2122 if (gPlayers
[I
] <> nil) then MH_SEND_PlayerPos(reliableUpdate
, gPlayers
[I
].UID
);
2125 g_Mons_ForEach(sendMonsPos
);
2127 if reliableUpdate
then
2129 NetTimeToReliable
:= 0;
2130 NetTimeToUpdate
:= NetUpdateRate
;
2134 NetTimeToUpdate
:= 0;
2139 // send only mosters with some unexpected changes
2140 g_Mons_ForEach(sendMonsPosUnexpected
);
2143 // send unexpected platform changes
2144 g_Map_NetSendInterestingPanels();
2146 g_Net_Slist_ServerUpdate();
2148 if NetUseMaster then
2150 if (gTime >= NetTimeToMaster) or g_Net_Slist_IsConnectionInProgress then
2152 if (not g_Net_Slist_IsConnectionActive) then g_Net_Slist_Connect(false); // non-blocking connection to the master
2154 NetTimeToMaster := gTime + NetMasterRate;
2159 else if (NetMode
= NET_CLIENT
) then
2161 MC_SEND_PlayerPos();
2163 end; // if gameOn ...
2165 // Àêòèâíî îêíî èíòåðôåéñà - ïåðåäàåì êëàâèøè åìó:
2166 if g_ActiveWindow
<> nil then
2168 w
:= e_GetFirstKeyPressed();
2170 if (w
<> IK_INVALID
) then
2172 Msg
.Msg
:= MESSAGE_DIKEY
;
2174 g_ActiveWindow
.OnMessage(Msg
);
2177 // Åñëè îíî îò ýòîãî íå çàêðûëîñü, òî îáíîâëÿåì:
2178 if g_ActiveWindow
<> nil then
2179 g_ActiveWindow
.Update();
2181 // Íóæíî ñìåíèòü ðàçðåøåíèå:
2182 if gResolutionChange
then
2184 e_WriteLog('Changing resolution', TMsgType
.Notify
);
2185 g_Game_ChangeResolution(gRC_Width
, gRC_Height
, gRC_FullScreen
, gRC_Maximized
);
2186 gResolutionChange
:= False;
2187 g_ActiveWindow
:= nil;
2190 // Íóæíî ñìåíèòü ÿçûê:
2191 if gLanguageChange
then
2193 //e_WriteLog('Read language file', MSG_NOTIFY);
2194 //g_Language_Load(DataDir + gLanguage + '.txt');
2195 g_Language_Set(gLanguage
);
2199 gLanguageChange
:= False;
2203 // Ãîðÿ÷àÿ êëàâèøà äëÿ âûçîâà ìåíþ âûõîäà èç èãðû (F10):
2204 if e_KeyPressed(IK_F10
) and
2206 (not gConsoleShow
) and
2207 (g_ActiveWindow
= nil) then
2212 Time
:= sys_GetTicks() {div 1000};
2214 // Îáðàáîòêà îòëîæåííûõ ñîáûòèé:
2215 if gDelayedEvents
<> nil then
2216 for a
:= 0 to High(gDelayedEvents
) do
2217 if gDelayedEvents
[a
].Pending
and
2219 ((gDelayedEvents
[a
].DEType
= DE_GLOBEVENT
) and (gDelayedEvents
[a
].Time
<= Time
)) or
2220 ((gDelayedEvents
[a
].DEType
> DE_GLOBEVENT
) and (gDelayedEvents
[a
].Time
<= gTime
))
2223 case gDelayedEvents
[a
].DEType
of
2225 g_Game_ExecuteEvent(gDelayedEvents
[a
].DEStr
);
2228 g_Game_Announce_GoodShot(gDelayedEvents
[a
].DENum
);
2232 g_Game_Announce_KillCombo(gDelayedEvents
[a
].DENum
);
2233 if g_Game_IsNet
and g_Game_IsServer
then
2234 MH_SEND_GameEvent(NET_EV_KILLCOMBO
, gDelayedEvents
[a
].DENum
);
2238 g_Game_Announce_BodyKill(gDelayedEvents
[a
].DENum
);
2240 gDelayedEvents
[a
].Pending
:= False;
2243 // Êàæäóþ ñåêóíäó îáíîâëÿåì ñ÷åò÷èê îáíîâëåíèé:
2244 UPSCounter
:= UPSCounter
+ 1;
2245 if Time
- UPSTime
>= 1000 then
2254 g_Weapon_AddDynLights();
2255 g_Items_AddDynLights();
2259 procedure g_Game_LoadChatSounds(Resource
: string);
2262 FileName
, Snd
: string;
2264 len
, cnt
, tags
, i
, j
: Integer;
2267 FileName
:= g_ExtractWadName(Resource
);
2269 WAD
:= TWADFile
.Create();
2270 WAD
.ReadFile(FileName
);
2272 if not WAD
.GetResource(g_ExtractFilePathName(Resource
), p
, len
) then
2279 cfg
:= TConfig
.CreateMem(p
, len
);
2280 cnt
:= cfg
.ReadInt('ChatSounds', 'Count', 0);
2282 SetLength(gChatSounds
, cnt
);
2283 for i
:= 0 to Length(gChatSounds
) - 1 do
2285 gChatSounds
[i
].Sound
:= nil;
2286 Snd
:= Trim(cfg
.ReadStr(IntToStr(i
), 'Sound', ''));
2287 tags
:= cfg
.ReadInt(IntToStr(i
), 'Tags', 0);
2288 if (Snd
= '') or (Tags
<= 0) then
2290 g_Sound_CreateWADEx('SOUND_CHAT_MACRO' + IntToStr(i
), GameWAD
+':'+Snd
);
2291 gChatSounds
[i
].Sound
:= TPlayableSound
.Create();
2292 gChatSounds
[i
].Sound
.SetByName('SOUND_CHAT_MACRO' + IntToStr(i
));
2293 SetLength(gChatSounds
[i
].Tags
, tags
);
2294 for j
:= 0 to tags
- 1 do
2295 gChatSounds
[i
].Tags
[j
] := toLowerCase1251(cfg
.ReadStr(IntToStr(i
), 'Tag' + IntToStr(j
), ''));
2296 gChatSounds
[i
].FullWord
:= cfg
.ReadBool(IntToStr(i
), 'FullWord', False);
2303 procedure g_Game_FreeChatSounds();
2307 for i
:= 0 to Length(gChatSounds
) - 1 do
2309 gChatSounds
[i
].Sound
.Free();
2310 g_Sound_Delete('SOUND_CHAT_MACRO' + IntToStr(i
));
2312 SetLength(gChatSounds
, 0);
2316 procedure g_Game_LoadData();
2323 if DataLoaded
then Exit
;
2325 e_WriteLog('Loading game data...', TMsgType
.Notify
);
2327 g_Texture_CreateWADEx('NOTEXTURE', GameWAD
+':TEXTURES\NOTEXTURE');
2328 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUD', GameWAD
+':TEXTURES\HUD');
2329 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDAIR', GameWAD
+':TEXTURES\AIRBAR');
2330 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDJET', GameWAD
+':TEXTURES\JETBAR');
2331 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDBG', GameWAD
+':TEXTURES\HUDBG');
2332 g_Texture_CreateWADEx('TEXTURE_PLAYER_ARMORHUD', GameWAD
+':TEXTURES\ARMORHUD');
2333 g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG', GameWAD
+':TEXTURES\FLAGHUD_R_BASE');
2334 g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG_S', GameWAD
+':TEXTURES\FLAGHUD_R_STOLEN');
2335 g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG_D', GameWAD
+':TEXTURES\FLAGHUD_R_DROP');
2336 g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG', GameWAD
+':TEXTURES\FLAGHUD_B_BASE');
2337 g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG_S', GameWAD
+':TEXTURES\FLAGHUD_B_STOLEN');
2338 g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG_D', GameWAD
+':TEXTURES\FLAGHUD_B_DROP');
2339 g_Texture_CreateWADEx('TEXTURE_PLAYER_TALKBUBBLE', GameWAD
+':TEXTURES\TALKBUBBLE');
2340 g_Texture_CreateWADEx('TEXTURE_PLAYER_INVULPENTA', GameWAD
+':TEXTURES\PENTA');
2341 g_Texture_CreateWADEx('TEXTURE_PLAYER_INDICATOR', GameWAD
+':TEXTURES\PLRIND');
2344 if not g_Texture_CreateWADEx('UI_GFX_PBAR_LEFT', GameWAD
+':TEXTURES\LLEFT') then hasPBarGfx
:= false;
2345 if not g_Texture_CreateWADEx('UI_GFX_PBAR_MARKER', GameWAD
+':TEXTURES\LMARKER') then hasPBarGfx
:= false;
2346 if not g_Texture_CreateWADEx('UI_GFX_PBAR_MIDDLE', GameWAD
+':TEXTURES\LMIDDLE') then hasPBarGfx
:= false;
2347 if not g_Texture_CreateWADEx('UI_GFX_PBAR_RIGHT', GameWAD
+':TEXTURES\LRIGHT') then hasPBarGfx
:= false;
2351 g_Texture_GetSize('UI_GFX_PBAR_LEFT', wl
, hl
);
2352 g_Texture_GetSize('UI_GFX_PBAR_RIGHT', wr
, hr
);
2353 g_Texture_GetSize('UI_GFX_PBAR_MIDDLE', wb
, hb
);
2354 g_Texture_GetSize('UI_GFX_PBAR_MARKER', wm
, hm
);
2355 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
2361 hasPBarGfx
:= false;
2365 g_Frames_CreateWAD(nil, 'FRAMES_TELEPORT', GameWAD
+':TEXTURES\TELEPORT', 64, 64, 10, False);
2366 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH', GameWAD
+':WEAPONS\PUNCH', 64, 64, 4, False);
2367 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_UP', GameWAD
+':WEAPONS\PUNCH_UP', 64, 64, 4, False);
2368 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_DN', GameWAD
+':WEAPONS\PUNCH_DN', 64, 64, 4, False);
2369 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_BERSERK', GameWAD
+':WEAPONS\PUNCHB', 64, 64, 4, False);
2370 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_BERSERK_UP', GameWAD
+':WEAPONS\PUNCHB_UP', 64, 64, 4, False);
2371 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_BERSERK_DN', GameWAD
+':WEAPONS\PUNCHB_DN', 64, 64, 4, False);
2372 g_Sound_CreateWADEx('SOUND_GAME_TELEPORT', GameWAD
+':SOUNDS\TELEPORT');
2373 g_Sound_CreateWADEx('SOUND_GAME_NOTELEPORT', GameWAD
+':SOUNDS\NOTELEPORT');
2374 g_Sound_CreateWADEx('SOUND_GAME_SECRET', GameWAD
+':SOUNDS\SECRET');
2375 g_Sound_CreateWADEx('SOUND_GAME_DOOROPEN', GameWAD
+':SOUNDS\DOOROPEN');
2376 g_Sound_CreateWADEx('SOUND_GAME_DOORCLOSE', GameWAD
+':SOUNDS\DOORCLOSE');
2377 g_Sound_CreateWADEx('SOUND_GAME_BULK1', GameWAD
+':SOUNDS\BULK1');
2378 g_Sound_CreateWADEx('SOUND_GAME_BULK2', GameWAD
+':SOUNDS\BULK2');
2379 g_Sound_CreateWADEx('SOUND_GAME_BUBBLE1', GameWAD
+':SOUNDS\BUBBLE1');
2380 g_Sound_CreateWADEx('SOUND_GAME_BUBBLE2', GameWAD
+':SOUNDS\BUBBLE2');
2381 g_Sound_CreateWADEx('SOUND_GAME_BURNING', GameWAD
+':SOUNDS\BURNING');
2382 g_Sound_CreateWADEx('SOUND_GAME_SWITCH1', GameWAD
+':SOUNDS\SWITCH1');
2383 g_Sound_CreateWADEx('SOUND_GAME_SWITCH0', GameWAD
+':SOUNDS\SWITCH0');
2384 g_Sound_CreateWADEx('SOUND_GAME_RADIO', GameWAD
+':SOUNDS\RADIO');
2385 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD1', GameWAD
+':SOUNDS\GOOD1');
2386 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD2', GameWAD
+':SOUNDS\GOOD2');
2387 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD3', GameWAD
+':SOUNDS\GOOD3');
2388 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD4', GameWAD
+':SOUNDS\GOOD4');
2389 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL2X', GameWAD
+':SOUNDS\KILL2X');
2390 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL3X', GameWAD
+':SOUNDS\KILL3X');
2391 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL4X', GameWAD
+':SOUNDS\KILL4X');
2392 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILLMX', GameWAD
+':SOUNDS\KILLMX');
2393 g_Sound_CreateWADEx('SOUND_ANNOUNCER_MUHAHA1', GameWAD
+':SOUNDS\MUHAHA1');
2394 g_Sound_CreateWADEx('SOUND_ANNOUNCER_MUHAHA2', GameWAD
+':SOUNDS\MUHAHA2');
2395 g_Sound_CreateWADEx('SOUND_ANNOUNCER_MUHAHA3', GameWAD
+':SOUNDS\MUHAHA3');
2396 g_Sound_CreateWADEx('SOUND_CTF_GET1', GameWAD
+':SOUNDS\GETFLAG1');
2397 g_Sound_CreateWADEx('SOUND_CTF_GET2', GameWAD
+':SOUNDS\GETFLAG2');
2398 g_Sound_CreateWADEx('SOUND_CTF_LOST1', GameWAD
+':SOUNDS\LOSTFLG1');
2399 g_Sound_CreateWADEx('SOUND_CTF_LOST2', GameWAD
+':SOUNDS\LOSTFLG2');
2400 g_Sound_CreateWADEx('SOUND_CTF_RETURN1', GameWAD
+':SOUNDS\RETFLAG1');
2401 g_Sound_CreateWADEx('SOUND_CTF_RETURN2', GameWAD
+':SOUNDS\RETFLAG2');
2402 g_Sound_CreateWADEx('SOUND_CTF_CAPTURE1', GameWAD
+':SOUNDS\CAPFLAG1');
2403 g_Sound_CreateWADEx('SOUND_CTF_CAPTURE2', GameWAD
+':SOUNDS\CAPFLAG2');
2405 goodsnd
[0] := TPlayableSound
.Create();
2406 goodsnd
[1] := TPlayableSound
.Create();
2407 goodsnd
[2] := TPlayableSound
.Create();
2408 goodsnd
[3] := TPlayableSound
.Create();
2410 goodsnd
[0].SetByName('SOUND_ANNOUNCER_GOOD1');
2411 goodsnd
[1].SetByName('SOUND_ANNOUNCER_GOOD2');
2412 goodsnd
[2].SetByName('SOUND_ANNOUNCER_GOOD3');
2413 goodsnd
[3].SetByName('SOUND_ANNOUNCER_GOOD4');
2415 killsnd
[0] := TPlayableSound
.Create();
2416 killsnd
[1] := TPlayableSound
.Create();
2417 killsnd
[2] := TPlayableSound
.Create();
2418 killsnd
[3] := TPlayableSound
.Create();
2420 killsnd
[0].SetByName('SOUND_ANNOUNCER_KILL2X');
2421 killsnd
[1].SetByName('SOUND_ANNOUNCER_KILL3X');
2422 killsnd
[2].SetByName('SOUND_ANNOUNCER_KILL4X');
2423 killsnd
[3].SetByName('SOUND_ANNOUNCER_KILLMX');
2425 hahasnd
[0] := TPlayableSound
.Create();
2426 hahasnd
[1] := TPlayableSound
.Create();
2427 hahasnd
[2] := TPlayableSound
.Create();
2429 hahasnd
[0].SetByName('SOUND_ANNOUNCER_MUHAHA1');
2430 hahasnd
[1].SetByName('SOUND_ANNOUNCER_MUHAHA2');
2431 hahasnd
[2].SetByName('SOUND_ANNOUNCER_MUHAHA3');
2433 sound_get_flag
[0] := TPlayableSound
.Create();
2434 sound_get_flag
[1] := TPlayableSound
.Create();
2435 sound_lost_flag
[0] := TPlayableSound
.Create();
2436 sound_lost_flag
[1] := TPlayableSound
.Create();
2437 sound_ret_flag
[0] := TPlayableSound
.Create();
2438 sound_ret_flag
[1] := TPlayableSound
.Create();
2439 sound_cap_flag
[0] := TPlayableSound
.Create();
2440 sound_cap_flag
[1] := TPlayableSound
.Create();
2442 sound_get_flag
[0].SetByName('SOUND_CTF_GET1');
2443 sound_get_flag
[1].SetByName('SOUND_CTF_GET2');
2444 sound_lost_flag
[0].SetByName('SOUND_CTF_LOST1');
2445 sound_lost_flag
[1].SetByName('SOUND_CTF_LOST2');
2446 sound_ret_flag
[0].SetByName('SOUND_CTF_RETURN1');
2447 sound_ret_flag
[1].SetByName('SOUND_CTF_RETURN2');
2448 sound_cap_flag
[0].SetByName('SOUND_CTF_CAPTURE1');
2449 sound_cap_flag
[1].SetByName('SOUND_CTF_CAPTURE2');
2451 g_Game_LoadChatSounds(GameWAD
+':CHATSND\SNDCFG');
2453 g_Game_SetLoadingText(_lc
[I_LOAD_ITEMS_DATA
], 0, False);
2456 g_Game_SetLoadingText(_lc
[I_LOAD_WEAPONS_DATA
], 0, False);
2457 g_Weapon_LoadData();
2459 g_Monsters_LoadData();
2464 procedure g_Game_FreeData();
2466 if not DataLoaded
then Exit
;
2469 g_Weapon_FreeData();
2470 g_Monsters_FreeData();
2472 e_WriteLog('Releasing game data...', TMsgType
.Notify
);
2474 g_Texture_Delete('NOTEXTURE');
2475 g_Texture_Delete('TEXTURE_PLAYER_HUD');
2476 g_Texture_Delete('TEXTURE_PLAYER_HUDBG');
2477 g_Texture_Delete('TEXTURE_PLAYER_ARMORHUD');
2478 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG');
2479 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG_S');
2480 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG_D');
2481 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG');
2482 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG_S');
2483 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG_D');
2484 g_Texture_Delete('TEXTURE_PLAYER_TALKBUBBLE');
2485 g_Texture_Delete('TEXTURE_PLAYER_INVULPENTA');
2486 g_Frames_DeleteByName('FRAMES_TELEPORT');
2487 g_Frames_DeleteByName('FRAMES_PUNCH');
2488 g_Frames_DeleteByName('FRAMES_PUNCH_UP');
2489 g_Frames_DeleteByName('FRAMES_PUNCH_DN');
2490 g_Frames_DeleteByName('FRAMES_PUNCH_BERSERK');
2491 g_Frames_DeleteByName('FRAMES_PUNCH_BERSERK_UP');
2492 g_Frames_DeleteByName('FRAMES_PUNCH_BERSERK_DN');
2493 g_Sound_Delete('SOUND_GAME_TELEPORT');
2494 g_Sound_Delete('SOUND_GAME_NOTELEPORT');
2495 g_Sound_Delete('SOUND_GAME_SECRET');
2496 g_Sound_Delete('SOUND_GAME_DOOROPEN');
2497 g_Sound_Delete('SOUND_GAME_DOORCLOSE');
2498 g_Sound_Delete('SOUND_GAME_BULK1');
2499 g_Sound_Delete('SOUND_GAME_BULK2');
2500 g_Sound_Delete('SOUND_GAME_BUBBLE1');
2501 g_Sound_Delete('SOUND_GAME_BUBBLE2');
2502 g_Sound_Delete('SOUND_GAME_BURNING');
2503 g_Sound_Delete('SOUND_GAME_SWITCH1');
2504 g_Sound_Delete('SOUND_GAME_SWITCH0');
2511 g_Sound_Delete('SOUND_ANNOUNCER_GOOD1');
2512 g_Sound_Delete('SOUND_ANNOUNCER_GOOD2');
2513 g_Sound_Delete('SOUND_ANNOUNCER_GOOD3');
2514 g_Sound_Delete('SOUND_ANNOUNCER_GOOD4');
2521 g_Sound_Delete('SOUND_ANNOUNCER_KILL2X');
2522 g_Sound_Delete('SOUND_ANNOUNCER_KILL3X');
2523 g_Sound_Delete('SOUND_ANNOUNCER_KILL4X');
2524 g_Sound_Delete('SOUND_ANNOUNCER_KILLMX');
2530 g_Sound_Delete('SOUND_ANNOUNCER_MUHAHA1');
2531 g_Sound_Delete('SOUND_ANNOUNCER_MUHAHA2');
2532 g_Sound_Delete('SOUND_ANNOUNCER_MUHAHA3');
2534 sound_get_flag
[0].Free();
2535 sound_get_flag
[1].Free();
2536 sound_lost_flag
[0].Free();
2537 sound_lost_flag
[1].Free();
2538 sound_ret_flag
[0].Free();
2539 sound_ret_flag
[1].Free();
2540 sound_cap_flag
[0].Free();
2541 sound_cap_flag
[1].Free();
2543 g_Sound_Delete('SOUND_CTF_GET1');
2544 g_Sound_Delete('SOUND_CTF_GET2');
2545 g_Sound_Delete('SOUND_CTF_LOST1');
2546 g_Sound_Delete('SOUND_CTF_LOST2');
2547 g_Sound_Delete('SOUND_CTF_RETURN1');
2548 g_Sound_Delete('SOUND_CTF_RETURN2');
2549 g_Sound_Delete('SOUND_CTF_CAPTURE1');
2550 g_Sound_Delete('SOUND_CTF_CAPTURE2');
2552 g_Game_FreeChatSounds();
2554 DataLoaded
:= False;
2557 procedure DrawCustomStat();
2563 ww2
, hh2
, r
, g
, b
, rr
, gg
, bb
: Byte;
2564 s1
, s2
, topstr
: String;
2566 e_TextureFontGetSize(gStdFont
, ww2
, hh2
);
2570 if g_Console_Action(ACTION_SCORES
) then
2572 if not gStatsPressed
then
2574 gStatsOff
:= not gStatsOff
;
2575 gStatsPressed
:= True;
2579 gStatsPressed
:= False;
2583 s1
:= _lc
[I_MENU_INTER_NOTICE_TAB
];
2584 w
:= (Length(s1
) * ww2
) div 2;
2585 x
:= gScreenWidth
div 2 - w
;
2587 e_TextureFontPrint(x
, y
, s1
, gStdFont
);
2591 if (gGameSettings
.GameMode
= GM_COOP
) then
2593 if gMissionFailed
then
2594 topstr
:= _lc
[I_MENU_INTER_MISSION_FAIL
]
2596 topstr
:= _lc
[I_MENU_INTER_LEVEL_COMPLETE
];
2599 topstr
:= _lc
[I_MENU_INTER_ROUND_OVER
];
2601 e_CharFont_GetSize(gMenuFont
, topstr
, ww1
, hh1
);
2602 e_CharFont_Print(gMenuFont
, (gScreenWidth
div 2)-(ww1
div 2), 16, topstr
);
2604 if g_Game_IsNet
then
2606 topstr
:= Format(_lc
[I_MENU_INTER_NOTICE_TIME
], [gServInterTime
]);
2607 if not gChatShow
then
2608 e_TextureFontPrintEx((gScreenWidth
div 2)-(Length(topstr
)*ww2
div 2),
2609 gScreenHeight
-(hh2
+4)*2, topstr
, gStdFont
, 255, 255, 255, 1);
2612 if g_Game_IsClient
then
2613 topstr
:= _lc
[I_MENU_INTER_NOTICE_MAP
]
2615 topstr
:= _lc
[I_MENU_INTER_NOTICE_SPACE
];
2616 if not gChatShow
then
2617 e_TextureFontPrintEx((gScreenWidth
div 2)-(Length(topstr
)*ww2
div 2),
2618 gScreenHeight
-(hh2
+4), topstr
, gStdFont
, 255, 255, 255, 1);
2623 w
:= gScreenWidth
-x
*2;
2629 e_DrawFillQuad(x
, y
, gScreenWidth
-x
-1, gScreenHeight
-y
-1, 64, 64, 64, 32);
2630 e_DrawQuad(x
, y
, gScreenWidth
-x
-1, gScreenHeight
-y
-1, 255, 127, 0);
2632 m
:= Max(Length(_lc
[I_MENU_MAP
])+1, Length(_lc
[I_GAME_GAME_TIME
])+1)*ww2
;
2634 case CustomStat
.GameMode
of
2637 if gGameSettings
.MaxLives
= 0 then
2638 s1
:= _lc
[I_GAME_DM
]
2640 s1
:= _lc
[I_GAME_LMS
];
2644 if gGameSettings
.MaxLives
= 0 then
2645 s1
:= _lc
[I_GAME_TDM
]
2647 s1
:= _lc
[I_GAME_TLMS
];
2649 GM_CTF
: s1
:= _lc
[I_GAME_CTF
];
2652 if gGameSettings
.MaxLives
= 0 then
2653 s1
:= _lc
[I_GAME_COOP
]
2655 s1
:= _lc
[I_GAME_SURV
];
2661 e_TextureFontPrintEx(x
+(w
div 2)-(Length(s1
)*ww2
div 2), _y
, s1
, gStdFont
, 255, 255, 255, 1);
2665 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_MENU_MAP
], gStdFont
, 255, 127, 0, 1);
2666 e_TextureFontPrint(x
+8+m
, _y
, Format('%s - %s', [CustomStat
.Map
, CustomStat
.MapName
]), gStdFont
);
2669 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_GAME_TIME
], gStdFont
, 255, 127, 0, 1);
2670 e_TextureFontPrint(x
+8+m
, _y
, Format('%d:%.2d:%.2d', [CustomStat
.GameTime
div 1000 div 3600,
2671 (CustomStat
.GameTime
div 1000 div 60) mod 60,
2672 CustomStat
.GameTime
div 1000 mod 60]), gStdFont
);
2674 pc
:= Length(CustomStat
.PlayerStat
);
2675 if pc
= 0 then Exit
;
2677 if CustomStat
.GameMode
= GM_COOP
then
2679 m
:= Max(Length(_lc
[I_GAME_MONSTERS
])+1, Length(_lc
[I_GAME_SECRETS
])+1)*ww2
;
2681 s2
:= _lc
[I_GAME_MONSTERS
];
2682 e_TextureFontPrintEx(x
+8, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2683 e_TextureFontPrintEx(x
+8+m
, _y
, IntToStr(gCoopMonstersKilled
) + '/' + IntToStr(gTotalMonsters
), gStdFont
, 255, 255, 255, 1);
2685 s2
:= _lc
[I_GAME_SECRETS
];
2686 e_TextureFontPrintEx(x
+8, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2687 e_TextureFontPrintEx(x
+8+m
, _y
, IntToStr(gCoopSecretsFound
) + '/' + IntToStr(gSecretsCount
), gStdFont
, 255, 255, 255, 1);
2690 m
:= Max(Length(_lc
[I_GAME_MONSTERS_TOTAL
])+1, Length(_lc
[I_GAME_SECRETS_TOTAL
])+1)*ww2
;
2692 s2
:= _lc
[I_GAME_MONSTERS_TOTAL
];
2693 e_TextureFontPrintEx(x
+250, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2694 e_TextureFontPrintEx(x
+250+m
, _y
, IntToStr(gCoopTotalMonstersKilled
) + '/' + IntToStr(gCoopTotalMonsters
), gStdFont
, 255, 255, 255, 1);
2696 s2
:= _lc
[I_GAME_SECRETS_TOTAL
];
2697 e_TextureFontPrintEx(x
+250, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2698 e_TextureFontPrintEx(x
+250+m
, _y
, IntToStr(gCoopTotalSecretsFound
) + '/' + IntToStr(gCoopTotalSecrets
), gStdFont
, 255, 255, 255, 1);
2702 if CustomStat
.GameMode
in [GM_TDM
, GM_CTF
] then
2707 if TeamStat
[TEAM_RED
].Goals
> TeamStat
[TEAM_BLUE
].Goals
then s1
:= _lc
[I_GAME_WIN_RED
]
2708 else if TeamStat
[TEAM_BLUE
].Goals
> TeamStat
[TEAM_RED
].Goals
then s1
:= _lc
[I_GAME_WIN_BLUE
]
2709 else s1
:= _lc
[I_GAME_WIN_DRAW
];
2711 e_TextureFontPrintEx(x
+8+(w
div 2)-(Length(s1
)*ww2
div 2), _y
, s1
, gStdFont
, 255, 255, 255, 1);
2714 for t
:= TEAM_RED
to TEAM_BLUE
do
2716 if t
= TEAM_RED
then
2718 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_TEAM_RED
],
2719 gStdFont
, 255, 0, 0, 1);
2720 e_TextureFontPrintEx(x
+w1
+8, _y
, IntToStr(CustomStat
.TeamStat
[TEAM_RED
].Goals
),
2721 gStdFont
, 255, 0, 0, 1);
2728 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_TEAM_BLUE
],
2729 gStdFont
, 0, 0, 255, 1);
2730 e_TextureFontPrintEx(x
+w1
+8, _y
, IntToStr(CustomStat
.TeamStat
[TEAM_BLUE
].Goals
),
2731 gStdFont
, 0, 0, 255, 1);
2737 e_DrawLine(1, x
+8, _y
+20, x
-8+w
, _y
+20, r
, g
, b
);
2740 for p
:= 0 to High(CustomStat
.PlayerStat
) do
2741 if CustomStat
.PlayerStat
[p
].Team
= t
then
2742 with CustomStat
.PlayerStat
[p
] do
2756 if (gPlayers
[Num
] <> nil) and (gPlayers
[Num
].FReady
) then
2757 e_TextureFontPrintEx(x
+16, _y
, Name
+ ' *', gStdFont
, rr
, gg
, bb
, 1)
2759 e_TextureFontPrintEx(x
+16, _y
, Name
, gStdFont
, rr
, gg
, bb
, 1);
2760 e_TextureFontPrintEx(x
+w1
+16, _y
, IntToStr(Frags
), gStdFont
, rr
, gg
, bb
, 1);
2761 e_TextureFontPrintEx(x
+w1
+w2
+16, _y
, IntToStr(Deaths
), gStdFont
, rr
, gg
, bb
, 1);
2768 else if CustomStat
.GameMode
in [GM_DM
, GM_COOP
] then
2771 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_PLAYER_NAME
], gStdFont
, 255, 127, 0, 1);
2772 e_TextureFontPrintEx(x
+8+w1
, _y
, _lc
[I_GAME_FRAGS
], gStdFont
, 255, 127, 0, 1);
2773 e_TextureFontPrintEx(x
+8+w1
+w2
, _y
, _lc
[I_GAME_DEATHS
], gStdFont
, 255, 127, 0, 1);
2776 for p
:= 0 to High(CustomStat
.PlayerStat
) do
2777 with CustomStat
.PlayerStat
[p
] do
2779 e_DrawFillQuad(x
+8, _y
+4, x
+24-1, _y
+16+4-1, Color
.R
, Color
.G
, Color
.B
, 0);
2786 if (gPlayers
[Num
] <> nil) and (gPlayers
[Num
].FReady
) then
2787 e_TextureFontPrintEx(x
+8+16+8, _y
+4, Name
+ ' *', gStdFont
, r
, r
, r
, 1, True)
2789 e_TextureFontPrintEx(x
+8+16+8, _y
+4, Name
, gStdFont
, r
, r
, r
, 1, True);
2790 e_TextureFontPrintEx(x
+w1
+8+16+8, _y
+4, IntToStr(Frags
), gStdFont
, r
, r
, r
, 1, True);
2791 e_TextureFontPrintEx(x
+w1
+w2
+8+16+8, _y
+4, IntToStr(Deaths
), gStdFont
, r
, r
, r
, 1, True);
2797 procedure DrawSingleStat();
2799 tm
, key_x
, val_x
, y
: Integer;
2803 procedure player_stat(n
: Integer);
2809 s1
:= Format(' %d ', [SingleStat
.PlayerStat
[n
].Kills
]);
2810 s2
:= Format(' %d', [gTotalMonsters
]);
2812 e_CharFont_Print(gMenuFont
, key_x
, y
, _lc
[I_MENU_INTER_KILLS
]);
2813 e_CharFont_PrintEx(gMenuFont
, val_x
, y
, s1
, _RGB(255, 0, 0));
2814 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2815 e_CharFont_Print(gMenuFont
, val_x
+w1
, y
, '/');
2817 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2818 e_CharFont_PrintEx(gMenuFont
, val_x
+w1
, y
, s2
, _RGB(255, 0, 0));
2820 // "Kills-per-minute: ##.#":
2821 s1
:= _lc
[I_MENU_INTER_KPM
];
2823 kpm
:= (SingleStat
.PlayerStat
[n
].Kills
/ tm
) * 60
2825 kpm
:= SingleStat
.PlayerStat
[n
].Kills
;
2826 s2
:= Format(' %.1f', [kpm
]);
2828 e_CharFont_Print(gMenuFont
, key_x
, y
+32, s1
);
2829 e_CharFont_PrintEx(gMenuFont
, val_x
, y
+32, s2
, _RGB(255, 0, 0));
2831 // "Secrets found: # / #":
2832 s1
:= Format(' %d ', [SingleStat
.PlayerStat
[n
].Secrets
]);
2833 s2
:= Format(' %d', [SingleStat
.TotalSecrets
]);
2835 e_CharFont_Print(gMenuFont
, key_x
, y
+64, _lc
[I_MENU_INTER_SECRETS
]);
2836 e_CharFont_PrintEx(gMenuFont
, val_x
, y
+64, s1
, _RGB(255, 0, 0));
2837 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2838 e_CharFont_Print(gMenuFont
, val_x
+w1
, y
+64, '/');
2840 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2841 e_CharFont_PrintEx(gMenuFont
, val_x
+w1
, y
+64, s2
, _RGB(255, 0, 0));
2845 // "Level Complete":
2846 e_CharFont_GetSize(gMenuFont
, _lc
[I_MENU_INTER_LEVEL_COMPLETE
], w1
, h
);
2847 e_CharFont_Print(gMenuFont
, (gScreenWidth
-w1
) div 2, 32, _lc
[I_MENU_INTER_LEVEL_COMPLETE
]);
2849 // Îïðåäåëÿåì êîîðäèíàòû âûðàâíèâàíèÿ ïî ñàìîé äëèííîé ñòðîêå:
2850 s1
:= _lc
[I_MENU_INTER_KPM
];
2851 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2854 e_CharFont_GetSize(gMenuFont
, s1
, w2
, h
);
2856 key_x
:= (gScreenWidth
-w1
-w2
) div 2;
2857 val_x
:= key_x
+ w1
;
2860 tm
:= SingleStat
.GameTime
div 1000;
2861 s1
:= _lc
[I_MENU_INTER_TIME
];
2862 s2
:= Format(' %d:%.2d:%.2d', [tm
div (60*60), (tm
mod (60*60)) div 60, tm
mod 60]);
2864 e_CharFont_Print(gMenuFont
, key_x
, 80, s1
);
2865 e_CharFont_PrintEx(gMenuFont
, val_x
, 80, s2
, _RGB(255, 0, 0));
2867 if SingleStat
.TwoPlayers
then
2870 s1
:= _lc
[I_MENU_PLAYER_1
];
2871 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2872 e_CharFont_Print(gMenuFont
, (gScreenWidth
-w1
) div 2, 128, s1
);
2874 // Ñòàòèñòèêà ïåðâîãî èãðîêà:
2879 s1
:= _lc
[I_MENU_PLAYER_2
];
2880 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2881 e_CharFont_Print(gMenuFont
, (gScreenWidth
-w1
) div 2, 288, s1
);
2883 // Ñòàòèñòèêà âòîðîãî èãðîêà:
2889 // Ñòàòèñòèêà ïåðâîãî èãðîêà:
2895 procedure DrawLoadingStat();
2896 procedure drawRect (x
, y
, w
, h
: Integer);
2898 if (w
< 1) or (h
< 1) then exit
;
2900 glVertex2f(x
+0.375, y
+0.375);
2901 glVertex2f(x
+w
+0.375, y
+0.375);
2902 glVertex2f(x
+w
+0.375, y
+h
+0.375);
2903 glVertex2f(x
+0.375, y
+h
+0.375);
2907 function drawPBar (cur
, total
: Integer; washere
: Boolean): Boolean;
2909 rectW
, rectH
: Integer;
2916 idl
, idr
, idb
, idm
: LongWord;
2920 if (total
< 1) then exit
;
2921 if (cur
< 1) then exit
; // don't blink
2922 if (not washere
) and (cur
>= total
) then exit
; // don't blink
2923 //if (cur < 0) then cur := 0;
2924 //if (cur > total) then cur := total;
2927 if (hasPBarGfx
) then
2929 g_Texture_Get('UI_GFX_PBAR_LEFT', idl
);
2930 g_Texture_GetSize('UI_GFX_PBAR_LEFT', wl
, hl
);
2931 g_Texture_Get('UI_GFX_PBAR_RIGHT', idr
);
2932 g_Texture_GetSize('UI_GFX_PBAR_RIGHT', wr
, hr
);
2933 g_Texture_Get('UI_GFX_PBAR_MIDDLE', idb
);
2934 g_Texture_GetSize('UI_GFX_PBAR_MIDDLE', wb
, hb
);
2935 g_Texture_Get('UI_GFX_PBAR_MARKER', idm
);
2936 g_Texture_GetSize('UI_GFX_PBAR_MARKER', wm
, hm
);
2938 //rectW := gScreenWidth-360;
2939 rectW
:= trunc(624.0*gScreenWidth
/1024.0);
2942 x0
:= (gScreenWidth
-rectW
) div 2;
2943 y0
:= gScreenHeight
-rectH
-64;
2944 if (y0
< 2) then y0
:= 2;
2946 glEnable(GL_SCISSOR_TEST
);
2949 glScissor(x0
, gScreenHeight
-y0
-rectH
, rectW
, rectH
);
2950 e_DrawSize(idl
, x0
, y0
, 0, true, false, wl
, hl
);
2951 e_DrawSize(idr
, x0
+rectW
-wr
, y0
, 0, true, false, wr
, hr
);
2954 glScissor(x0
+wl
, gScreenHeight
-y0
-rectH
, rectW
-wl
-wr
, rectH
);
2956 while (f
< x0
+rectW
) do
2958 e_DrawSize(idb
, f
, y0
, 0, true, false, wb
, hb
);
2963 wdt
:= (rectW
-wl
-wr
)*cur
div total
;
2964 if (wdt
> rectW
-wl
-wr
) then wdt
:= rectW
-wr
-wr
;
2967 my
:= y0
; // don't be so smart, ketmar: +(rectH-wm) div 2;
2968 glScissor(x0
+wl
, gScreenHeight
-my
-rectH
, wdt
, hm
);
2972 e_DrawSize(idm
, f
, y0
, 0, true, false, wm
, hm
);
2978 glScissor(0, 0, gScreenWidth
, gScreenHeight
);
2982 rectW
:= gScreenWidth
-64;
2985 x0
:= (gScreenWidth
-rectW
) div 2;
2986 y0
:= gScreenHeight
-rectH
-64;
2987 if (y0
< 2) then y0
:= 2;
2989 glDisable(GL_BLEND
);
2990 glDisable(GL_TEXTURE_2D
);
2992 //glClearColor(0, 0, 0, 0);
2993 //glClear(GL_COLOR_BUFFER_BIT);
2995 glColor4ub(127, 127, 127, 255);
2996 drawRect(x0
-2, y0
-2, rectW
+4, rectH
+4);
2998 glColor4ub(0, 0, 0, 255);
2999 drawRect(x0
-1, y0
-1, rectW
+2, rectH
+2);
3001 glColor4ub(127, 127, 127, 255);
3002 wdt
:= rectW
*cur
div total
;
3003 if (wdt
> rectW
) then wdt
:= rectW
;
3004 drawRect(x0
, y0
, wdt
, rectH
);
3013 if (Length(LoadingStat
.Msgs
) = 0) then exit
;
3015 e_CharFont_GetSize(gMenuFont
, _lc
[I_MENU_LOADING
], ww
, hh
);
3016 yy
:= (gScreenHeight
div 3);
3017 e_CharFont_Print(gMenuFont
, (gScreenWidth
div 2)-(ww
div 2), yy
-2*hh
, _lc
[I_MENU_LOADING
]);
3018 xx
:= (gScreenWidth
div 3);
3022 for i
:= 0 to NextMsg
-1 do
3024 if (i
= (NextMsg
-1)) and (MaxValue
> 0) then
3025 s
:= Format('%s: %d/%d', [Msgs
[i
], CurValue
, MaxValue
])
3029 e_CharFont_PrintEx(gMenuSmallFont
, xx
, yy
, s
, _RGB(255, 0, 0));
3030 yy
:= yy
+ LOADING_INTERLINE
;
3031 PBarWasHere
:= drawPBar(CurValue
, MaxValue
, PBarWasHere
);
3036 procedure DrawMenuBackground(tex
: AnsiString);
3042 if g_Texture_Get(tex
, ID
) then
3044 e_Clear(GL_COLOR_BUFFER_BIT
, 0, 0, 0);
3045 e_GetTextureSize(ID
, @w
, @h
);
3047 w
:= round(w
* 1.333 * (gScreenHeight
/ h
))
3049 w
:= trunc(w
* (gScreenHeight
/ h
));
3050 e_DrawSize(ID
, (gScreenWidth
- w
) div 2, 0, 0, False, False, w
, gScreenHeight
);
3052 else e_Clear(GL_COLOR_BUFFER_BIT
, 0, 0, 0);
3055 procedure DrawMinimap(p
: TPlayer
; RenderRect
: e_graphics
.TRect
);
3057 a
, aX
, aY
, aX2
, aY2
, Scale
, ScaleSz
: Integer;
3059 function monDraw (mon
: TMonster
): Boolean;
3061 result
:= false; // don't stop
3066 // Ëåâûé âåðõíèé óãîë
3067 aX
:= Obj
.X
div ScaleSz
+ 1;
3068 aY
:= Obj
.Y
div ScaleSz
+ 1;
3070 aX2
:= max(Obj
.Rect
.Width
div ScaleSz
, 1);
3071 aY2
:= max(Obj
.Rect
.Height
div ScaleSz
, 1);
3072 // Ïðàâûé íèæíèé óãîë
3073 aX2
:= aX
+ aX2
- 1;
3074 aY2
:= aY
+ aY2
- 1;
3075 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 255, 0, 0);
3081 if (gMapInfo
.Width
> RenderRect
.Right
- RenderRect
.Left
) or
3082 (gMapInfo
.Height
> RenderRect
.Bottom
- RenderRect
.Top
) then
3085 // Ñêîëüêî ïèêñåëîâ êàðòû â 1 ïèêñåëå ìèíè-êàðòû:
3086 ScaleSz
:= 16 div Scale
;
3087 // Ðàçìåðû ìèíè-êàðòû:
3088 aX
:= max(gMapInfo
.Width
div ScaleSz
, 1);
3089 aY
:= max(gMapInfo
.Height
div ScaleSz
, 1);
3091 e_DrawFillQuad(0, 0, aX
-1, aY
-1, 0, 0, 0, 0);
3093 if gWalls
<> nil then
3096 for a
:= 0 to High(gWalls
) do
3098 if PanelType
<> 0 then
3100 // Ëåâûé âåðõíèé óãîë:
3101 aX
:= X
div ScaleSz
;
3102 aY
:= Y
div ScaleSz
;
3104 aX2
:= max(Width
div ScaleSz
, 1);
3105 aY2
:= max(Height
div ScaleSz
, 1);
3106 // Ïðàâûé íèæíèé óãîë:
3107 aX2
:= aX
+ aX2
- 1;
3108 aY2
:= aY
+ aY2
- 1;
3111 PANEL_WALL
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 208, 208, 208, 0);
3112 PANEL_OPENDOOR
, PANEL_CLOSEDOOR
:
3113 if Enabled
then e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 160, 160, 160, 0);
3117 if gSteps
<> nil then
3120 for a
:= 0 to High(gSteps
) do
3122 if PanelType
<> 0 then
3124 // Ëåâûé âåðõíèé óãîë:
3125 aX
:= X
div ScaleSz
;
3126 aY
:= Y
div ScaleSz
;
3128 aX2
:= max(Width
div ScaleSz
, 1);
3129 aY2
:= max(Height
div ScaleSz
, 1);
3130 // Ïðàâûé íèæíèé óãîë:
3131 aX2
:= aX
+ aX2
- 1;
3132 aY2
:= aY
+ aY2
- 1;
3134 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 128, 128, 128, 0);
3137 if gLifts
<> nil then
3140 for a
:= 0 to High(gLifts
) do
3142 if PanelType
<> 0 then
3144 // Ëåâûé âåðõíèé óãîë:
3145 aX
:= X
div ScaleSz
;
3146 aY
:= Y
div ScaleSz
;
3148 aX2
:= max(Width
div ScaleSz
, 1);
3149 aY2
:= max(Height
div ScaleSz
, 1);
3150 // Ïðàâûé íèæíèé óãîë:
3151 aX2
:= aX
+ aX2
- 1;
3152 aY2
:= aY
+ aY2
- 1;
3155 LIFTTYPE_UP
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 116, 72, 36, 0);
3156 LIFTTYPE_DOWN
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 116, 124, 96, 0);
3157 LIFTTYPE_LEFT
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 200, 80, 4, 0);
3158 LIFTTYPE_RIGHT
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 252, 140, 56, 0);
3162 if gWater
<> nil then
3165 for a
:= 0 to High(gWater
) do
3167 if PanelType
<> 0 then
3169 // Ëåâûé âåðõíèé óãîë:
3170 aX
:= X
div ScaleSz
;
3171 aY
:= Y
div ScaleSz
;
3173 aX2
:= max(Width
div ScaleSz
, 1);
3174 aY2
:= max(Height
div ScaleSz
, 1);
3175 // Ïðàâûé íèæíèé óãîë:
3176 aX2
:= aX
+ aX2
- 1;
3177 aY2
:= aY
+ aY2
- 1;
3179 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 0, 192, 0);
3182 if gAcid1
<> nil then
3184 // Ðèñóåì êèñëîòó 1:
3185 for a
:= 0 to High(gAcid1
) do
3187 if PanelType
<> 0 then
3189 // Ëåâûé âåðõíèé óãîë:
3190 aX
:= X
div ScaleSz
;
3191 aY
:= Y
div ScaleSz
;
3193 aX2
:= max(Width
div ScaleSz
, 1);
3194 aY2
:= max(Height
div ScaleSz
, 1);
3195 // Ïðàâûé íèæíèé óãîë:
3196 aX2
:= aX
+ aX2
- 1;
3197 aY2
:= aY
+ aY2
- 1;
3199 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 176, 0, 0);
3202 if gAcid2
<> nil then
3204 // Ðèñóåì êèñëîòó 2:
3205 for a
:= 0 to High(gAcid2
) do
3207 if PanelType
<> 0 then
3209 // Ëåâûé âåðõíèé óãîë:
3210 aX
:= X
div ScaleSz
;
3211 aY
:= Y
div ScaleSz
;
3213 aX2
:= max(Width
div ScaleSz
, 1);
3214 aY2
:= max(Height
div ScaleSz
, 1);
3215 // Ïðàâûé íèæíèé óãîë:
3216 aX2
:= aX
+ aX2
- 1;
3217 aY2
:= aY
+ aY2
- 1;
3219 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 176, 0, 0, 0);
3222 if gPlayers
<> nil then
3225 for a
:= 0 to High(gPlayers
) do
3226 if gPlayers
[a
] <> nil then with gPlayers
[a
] do
3228 // Ëåâûé âåðõíèé óãîë:
3229 aX
:= Obj
.X
div ScaleSz
+ 1;
3230 aY
:= Obj
.Y
div ScaleSz
+ 1;
3232 aX2
:= max(Obj
.Rect
.Width
div ScaleSz
, 1);
3233 aY2
:= max(Obj
.Rect
.Height
div ScaleSz
, 1);
3234 // Ïðàâûé íèæíèé óãîë:
3235 aX2
:= aX
+ aX2
- 1;
3236 aY2
:= aY
+ aY2
- 1;
3238 if gPlayers
[a
] = p
then
3239 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 255, 0, 0)
3242 TEAM_RED
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 0, 0, 0);
3243 TEAM_BLUE
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 0, 255, 0);
3244 else e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 128, 0, 0);
3249 g_Mons_ForEach(monDraw
);
3254 procedure renderAmbientQuad (hasAmbient
: Boolean; constref ambColor
: TDFColor
);
3256 if not hasAmbient
then exit
;
3257 e_AmbientQuad(sX
, sY
, sWidth
, sHeight
, ambColor
.r
, ambColor
.g
, ambColor
.b
, ambColor
.a
);
3261 // setup sX, sY, sWidth, sHeight, and transformation matrix before calling this!
3262 //FIXME: broken for splitscreen mode
3263 procedure renderDynLightsInternal ();
3265 //hasAmbient: Boolean;
3266 //ambColor: TDFColor;
3268 lx
, ly
, lrad
: Integer;
3269 scxywh
: array[0..3] of GLint
;
3272 if e_NoGraphics
then exit
;
3274 //TODO: lights should be in separate grid, i think
3275 // but on the other side: grid may be slower for dynlights, as their lifetime is short
3276 if (not gwin_k8_enable_light_experiments
) or (not gwin_has_stencil
) or (g_dynLightCount
< 1) then exit
;
3279 //ambColor := gCurrentMap['light_ambient'].rgba;
3280 //hasAmbient := (not ambColor.isOpaque) or (not ambColor.isBlack);
3282 { // this will multiply incoming color to alpha from framebuffer
3284 glBlendFunc(GL_DST_ALPHA, GL_ONE);
3288 * light rendering: (INVALID!)
3289 * glStencilFunc(GL_EQUAL, 0, $ff);
3291 * glClear(GL_STENCIL_BUFFER_BIT);
3292 * glStencilOp(GL_KEEP, GL_KEEP, GL_INCR);
3293 * draw shadow volume into stencil buffer
3294 * glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); // modify color buffer
3295 * glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); // don't modify stencil buffer
3297 * draw color-less quad with light alpha (WARNING! don't touch color!)
3298 * glEnable(GL_BLEND);
3299 * glBlendFunc(GL_DST_ALPHA, GL_ONE);
3300 * draw all geometry up to and including walls (with alpha-testing, probably) -- this does lighting
3302 wassc
:= (glIsEnabled(GL_SCISSOR_TEST
) <> 0);
3303 if wassc
then glGetIntegerv(GL_SCISSOR_BOX
, @scxywh
[0]) else glGetIntegerv(GL_VIEWPORT
, @scxywh
[0]);
3305 // setup OpenGL parameters
3306 glStencilMask($FFFFFFFF);
3307 glStencilFunc(GL_ALWAYS
, 0, $FFFFFFFF);
3308 glEnable(GL_STENCIL_TEST
);
3309 glEnable(GL_SCISSOR_TEST
);
3310 glClear(GL_STENCIL_BUFFER_BIT
);
3311 glStencilFunc(GL_EQUAL
, 0, $ff);
3313 for lln
:= 0 to g_dynLightCount
-1 do
3315 lx
:= g_dynLights
[lln
].x
;
3316 ly
:= g_dynLights
[lln
].y
;
3317 lrad
:= g_dynLights
[lln
].radius
;
3318 if (lrad
< 3) then continue
;
3320 if (lx
-sX
+lrad
< 0) then continue
;
3321 if (ly
-sY
+lrad
< 0) then continue
;
3322 if (lx
-sX
-lrad
>= gPlayerScreenSize
.X
) then continue
;
3323 if (ly
-sY
-lrad
>= gPlayerScreenSize
.Y
) then continue
;
3325 // set scissor to optimize drawing
3326 if (g_dbg_scale
= 1.0) then
3328 glScissor((lx
-sX
)-lrad
+2, gPlayerScreenSize
.Y
-(ly
-sY
)-lrad
-1+2, lrad
*2-4, lrad
*2-4);
3332 glScissor(0, 0, gWinSizeX
, gWinSizeY
);
3334 // no need to clear stencil buffer, light blitting will do it for us... but only for normal scale
3335 if (g_dbg_scale
<> 1.0) then glClear(GL_STENCIL_BUFFER_BIT
);
3336 glStencilOp(GL_KEEP
, GL_KEEP
, GL_INCR
);
3337 // draw extruded panels
3338 glDisable(GL_TEXTURE_2D
);
3339 glDisable(GL_BLEND
);
3340 glColorMask(GL_FALSE
, GL_FALSE
, GL_FALSE
, GL_FALSE
); // no need to modify color buffer
3341 if (lrad
> 4) then g_Map_DrawPanelShadowVolumes(lx
, ly
, lrad
);
3342 // render light texture
3343 glColorMask(GL_TRUE
, GL_TRUE
, GL_TRUE
, GL_TRUE
); // modify color buffer
3344 glStencilOp(GL_ZERO
, GL_ZERO
, GL_ZERO
); // draw light, and clear stencil buffer
3347 glBlendFunc(GL_SRC_ALPHA
, GL_ONE_MINUS_SRC_ALPHA
);
3348 glEnable(GL_TEXTURE_2D
);
3349 // color and opacity
3350 glColor4f(g_dynLights
[lln
].r
, g_dynLights
[lln
].g
, g_dynLights
[lln
].b
, g_dynLights
[lln
].a
);
3351 glBindTexture(GL_TEXTURE_2D
, g_Texture_Light());
3353 glTexCoord2f(0.0, 0.0); glVertex2i(lx
-lrad
, ly
-lrad
); // top-left
3354 glTexCoord2f(1.0, 0.0); glVertex2i(lx
+lrad
, ly
-lrad
); // top-right
3355 glTexCoord2f(1.0, 1.0); glVertex2i(lx
+lrad
, ly
+lrad
); // bottom-right
3356 glTexCoord2f(0.0, 1.0); glVertex2i(lx
-lrad
, ly
+lrad
); // bottom-left
3361 glDisable(GL_STENCIL_TEST
);
3362 glDisable(GL_BLEND
);
3363 glDisable(GL_SCISSOR_TEST
);
3364 //glScissor(0, 0, sWidth, sHeight);
3366 glScissor(scxywh
[0], scxywh
[1], scxywh
[2], scxywh
[3]);
3367 if wassc
then glEnable(GL_SCISSOR_TEST
) else glDisable(GL_SCISSOR_TEST
);
3371 function fixViewportForScale (): Boolean;
3373 nx0
, ny0
, nw
, nh
: Integer;
3376 if (g_dbg_scale
<> 1.0) then
3379 nx0
:= round(sX
-(gPlayerScreenSize
.X
-(sWidth
*g_dbg_scale
))/2/g_dbg_scale
);
3380 ny0
:= round(sY
-(gPlayerScreenSize
.Y
-(sHeight
*g_dbg_scale
))/2/g_dbg_scale
);
3381 nw
:= round(sWidth
/g_dbg_scale
);
3382 nh
:= round(sHeight
/g_dbg_scale
);
3391 // setup sX, sY, sWidth, sHeight, and transformation matrix before calling this!
3392 // WARNING! this WILL CALL `glTranslatef()`, but won't restore matrices!
3393 procedure renderMapInternal (backXOfs
, backYOfs
: Integer; setTransMatrix
: Boolean);
3395 TDrawCB
= procedure ();
3398 hasAmbient
: Boolean;
3400 doAmbient
: Boolean = false;
3402 procedure drawPanelType (profname
: AnsiString; panType
: DWord
; doDraw
: Boolean);
3407 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin(profname
);
3408 if gdbg_map_use_accel_render
then
3410 tagmask
:= panelTypeToTag(panType
);
3411 while (gDrawPanelList
.count
> 0) do
3413 pan
:= TPanel(gDrawPanelList
.front());
3414 if ((pan
.tag
and tagmask
) = 0) then break
;
3415 if doDraw
then pan
.Draw(doAmbient
, ambColor
);
3416 gDrawPanelList
.popFront();
3421 if doDraw
then g_Map_DrawPanels(panType
, hasAmbient
, ambColor
);
3423 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
3426 procedure drawOther (profname
: AnsiString; cb
: TDrawCB
);
3428 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin(profname
);
3429 if assigned(cb
) then cb();
3430 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
3434 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin('total');
3436 // our accelerated renderer will collect all panels to gDrawPanelList
3437 // we can use panel tag to render level parts (see GridTagXXX in g_map.pas)
3438 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin('collect');
3439 if gdbg_map_use_accel_render
then
3441 g_Map_CollectDrawPanels(sX
, sY
, sWidth
, sHeight
);
3443 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
3445 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin('skyback');
3446 g_Map_DrawBack(backXOfs
, backYOfs
);
3447 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
3449 if setTransMatrix
then
3451 //if (g_dbg_scale <> 1.0) then glTranslatef(0.0, -0.375/2, 0);
3452 glScalef(g_dbg_scale
, g_dbg_scale
, 1.0);
3453 glTranslatef(-sX
, -sY
, 0);
3457 ambColor
:= gCurrentMap
['light_ambient'].rgba
;
3458 hasAmbient
:= (not ambColor
.isOpaque
) or (not ambColor
.isBlack
);
3463 //writeln('color: (', ambColor.r, ',', ambColor.g, ',', ambColor.b, ',', ambColor.a, ')');
3464 glColor4ub(ambColor.r, ambColor.g, ambColor.b, ambColor.a);
3465 glClear(GL_COLOR_BUFFER_BIT);
3468 //writeln('color: (', ambColor.r, ',', ambColor.g, ',', ambColor.b, ',', ambColor.a, ')');
3471 drawPanelType('*back', PANEL_BACK
, g_rlayer_back
);
3472 drawPanelType('*step', PANEL_STEP
, g_rlayer_step
);
3473 drawOther('items', @g_Items_Draw
);
3474 drawOther('weapons', @g_Weapon_Draw
);
3475 drawOther('shells', @g_Player_DrawShells
);
3476 drawOther('drawall', @g_Player_DrawAll
);
3477 drawOther('corpses', @g_Player_DrawCorpses
);
3478 drawPanelType('*wall', PANEL_WALL
, g_rlayer_wall
);
3479 drawOther('monsters', @g_Monsters_Draw
);
3480 drawOther('itemdrop', @g_Items_DrawDrop
);
3481 drawPanelType('*door', PANEL_CLOSEDOOR
, g_rlayer_door
);
3482 drawOther('gfx', @g_GFX_Draw
);
3483 drawOther('flags', @g_Map_DrawFlags
);
3484 drawPanelType('*acid1', PANEL_ACID1
, g_rlayer_acid1
);
3485 drawPanelType('*acid2', PANEL_ACID2
, g_rlayer_acid2
);
3486 drawPanelType('*water', PANEL_WATER
, g_rlayer_water
);
3487 drawOther('dynlights', @renderDynLightsInternal
);
3489 if hasAmbient
{and ((not g_playerLight) or (not gwin_has_stencil) or (g_dynLightCount < 1))} then
3491 renderAmbientQuad(hasAmbient
, ambColor
);
3495 drawPanelType('*fore', PANEL_FORE
, g_rlayer_fore
);
3498 if g_debug_HealthBar
then
3500 g_Monsters_DrawHealth();
3501 g_Player_DrawHealth();
3504 if (profileFrameDraw
<> nil) then profileFrameDraw
.mainEnd(); // map rendering
3508 procedure DrawMapView(x
, y
, w
, h
: Integer);
3515 bx
:= Round(x
/(gMapInfo
.Width
- w
)*(gBackSize
.X
- w
));
3516 by
:= Round(y
/(gMapInfo
.Height
- h
)*(gBackSize
.Y
- h
));
3523 fixViewportForScale();
3524 renderMapInternal(-bx
, -by
, true);
3530 procedure DrawPlayer(p
: TPlayer
);
3532 px
, py
, a
, b
, c
, d
, i
: Integer;
3535 if (p
= nil) or (p
.FDummy
) then
3538 g_Map_DrawBack(0, 0);
3543 if (profileFrameDraw
= nil) then profileFrameDraw
:= TProfiler
.Create('RENDER', g_profile_history_size
);
3544 if (profileFrameDraw
<> nil) then profileFrameDraw
.mainBegin(g_profile_frame_draw
);
3550 px
:= p
.GameX
+ PLAYER_RECT_CX
;
3551 py
:= p
.GameY
+ PLAYER_RECT_CY
+p
.Obj
.slopeUpLeft
;
3553 if (g_dbg_scale
= 1.0) and (not g_dbg_ignore_bounds
) then
3555 if (px
> (gPlayerScreenSize
.X
div 2)) then a
:= -px
+(gPlayerScreenSize
.X
div 2) else a
:= 0;
3556 if (py
> (gPlayerScreenSize
.Y
div 2)) then b
:= -py
+(gPlayerScreenSize
.Y
div 2) else b
:= 0;
3558 if (px
> gMapInfo
.Width
-(gPlayerScreenSize
.X
div 2)) then a
:= -gMapInfo
.Width
+gPlayerScreenSize
.X
;
3559 if (py
> gMapInfo
.Height
-(gPlayerScreenSize
.Y
div 2)) then b
:= -gMapInfo
.Height
+gPlayerScreenSize
.Y
;
3561 if (gMapInfo
.Width
= gPlayerScreenSize
.X
) then a
:= 0
3562 else if (gMapInfo
.Width
< gPlayerScreenSize
.X
) then
3565 a
:= (gPlayerScreenSize
.X
-gMapInfo
.Width
) div 2;
3568 if (gMapInfo
.Height
= gPlayerScreenSize
.Y
) then b
:= 0
3569 else if (gMapInfo
.Height
< gPlayerScreenSize
.Y
) then
3572 b
:= (gPlayerScreenSize
.Y
-gMapInfo
.Height
) div 2;
3577 // scaled, ignore level bounds
3578 a
:= -px
+(gPlayerScreenSize
.X
div 2);
3579 b
:= -py
+(gPlayerScreenSize
.Y
div 2);
3582 if p
.IncCam
<> 0 then
3584 if py
> gMapInfo
.Height
-(gPlayerScreenSize
.Y
div 2) then
3586 if p
.IncCam
> 120-(py
-(gMapInfo
.Height
-(gPlayerScreenSize
.Y
div 2))) then
3588 p
.IncCam
:= 120-(py
-(gMapInfo
.Height
-(gPlayerScreenSize
.Y
div 2)));
3592 if py
< gPlayerScreenSize
.Y
div 2 then
3594 if p
.IncCam
< -120+((gPlayerScreenSize
.Y
div 2)-py
) then
3596 p
.IncCam
:= -120+((gPlayerScreenSize
.Y
div 2)-py
);
3600 if p
.IncCam
< 0 then
3602 while (py
+(gPlayerScreenSize
.Y
div 2)-p
.IncCam
> gMapInfo
.Height
) and (p
.IncCam
< 0) do p
.IncCam
:= p
.IncCam
+1; //Inc(p.IncCam);
3605 if p
.IncCam
> 0 then
3607 while (py
-(gPlayerScreenSize
.Y
div 2)-p
.IncCam
< 0) and (p
.IncCam
> 0) do p
.IncCam
:= p
.IncCam
-1; //Dec(p.IncCam);
3611 if (px
< gPlayerScreenSize
.X
div 2) or (gMapInfo
.Width
-gPlayerScreenSize
.X
<= 256) then c
:= 0
3612 else if (px
> gMapInfo
.Width
-(gPlayerScreenSize
.X
div 2)) then c
:= gBackSize
.X
-gPlayerScreenSize
.X
3613 else c
:= round((px
-(gPlayerScreenSize
.X
div 2))/(gMapInfo
.Width
-gPlayerScreenSize
.X
)*(gBackSize
.X
-gPlayerScreenSize
.X
));
3615 if (py
-p
.IncCam
<= gPlayerScreenSize
.Y
div 2) or (gMapInfo
.Height
-gPlayerScreenSize
.Y
<= 256) then d
:= 0
3616 else if (py
-p
.IncCam
>= gMapInfo
.Height
-(gPlayerScreenSize
.Y
div 2)) then d
:= gBackSize
.Y
-gPlayerScreenSize
.Y
3617 else d
:= round((py
-p
.IncCam
-(gPlayerScreenSize
.Y
div 2))/(gMapInfo
.Height
-gPlayerScreenSize
.Y
)*(gBackSize
.Y
-gPlayerScreenSize
.Y
));
3620 sY
:= -(b
+p
.IncCam
);
3621 sWidth
:= gPlayerScreenSize
.X
;
3622 sHeight
:= gPlayerScreenSize
.Y
;
3624 //glTranslatef(a, b+p.IncCam, 0);
3626 //if (p = gPlayer1) and (g_dbg_scale >= 1.0) then g_Holmes_plrViewSize(sWidth, sHeight);
3628 //conwritefln('OLD: (%s,%s)-(%s,%s)', [sX, sY, sWidth, sHeight]);
3629 fixViewportForScale();
3630 //conwritefln(' (%s,%s)-(%s,%s)', [sX, sY, sWidth, sHeight]);
3632 if (g_dbg_scale
<> 1.0) and (not g_dbg_ignore_bounds
) then
3634 if (sX
+sWidth
> gMapInfo
.Width
) then sX
:= gMapInfo
.Width
-sWidth
;
3635 if (sY
+sHeight
> gMapInfo
.Height
) then sY
:= gMapInfo
.Height
-sHeight
;
3636 if (sX
< 0) then sX
:= 0;
3637 if (sY
< 0) then sY
:= 0;
3639 if (gBackSize
.X
<= gPlayerScreenSize
.X
) or (gMapInfo
.Width
<= sWidth
) then c
:= 0 else c
:= trunc((gBackSize
.X
-gPlayerScreenSize
.X
)*sX
/(gMapInfo
.Width
-sWidth
));
3640 if (gBackSize
.Y
<= gPlayerScreenSize
.Y
) or (gMapInfo
.Height
<= sHeight
) then d
:= 0 else d
:= trunc((gBackSize
.Y
-gPlayerScreenSize
.Y
)*sY
/(gMapInfo
.Height
-sHeight
));
3643 //r_smallmap_h: 0: left; 1: center; 2: right
3644 //r_smallmap_v: 0: top; 1: center; 2: bottom
3646 if (gMapInfo
.Width
= sWidth
) then
3650 else if (gMapInfo
.Width
< sWidth
) then
3652 case r_smallmap_h
of
3653 1: sX
:= -((sWidth
-gMapInfo
.Width
) div 2); // center
3654 2: sX
:= -(sWidth
-gMapInfo
.Width
); // right
3655 else sX
:= 0; // left
3659 if (gMapInfo
.Height
= sHeight
) then
3663 else if (gMapInfo
.Height
< sHeight
) then
3665 case r_smallmap_v
of
3666 1: sY
:= -((sHeight
-gMapInfo
.Height
) div 2); // center
3667 2: sY
:= -(sHeight
-gMapInfo
.Height
); // bottom
3668 else sY
:= 0; // top
3674 p
.viewPortW
:= sWidth
;
3675 p
.viewPortH
:= sHeight
;
3677 {$IFDEF ENABLE_HOLMES}
3678 if (p
= gPlayer1
) then
3680 g_Holmes_plrViewPos(sX
, sY
);
3681 g_Holmes_plrViewSize(sWidth
, sHeight
);
3685 renderMapInternal(-c
, -d
, true);
3687 if (gGameSettings
.GameMode
<> GM_SINGLE
) and (gPlayerIndicator
> 0) then
3688 case gPlayerIndicator
of
3690 p
.DrawIndicator(_RGB(255, 255, 255));
3693 for i
:= 0 to High(gPlayers
) do
3694 if gPlayers
[i
] <> nil then
3695 if gPlayers
[i
] = p
then p
.DrawIndicator(_RGB(255, 255, 255))
3696 else if (gPlayers
[i
].Team
= p
.Team
) and (gPlayers
[i
].Team
<> TEAM_NONE
) then
3697 if gPlayerIndicatorStyle
= 1 then
3698 gPlayers
[i
].DrawIndicator(_RGB(192, 192, 192))
3699 else gPlayers
[i
].DrawIndicator(gPlayers
[i
].GetColor
);
3702 if p
.FSpectator
then
3703 e_TextureFontPrintEx(p
.GameX
+ PLAYER_RECT_CX
- 4,
3704 p
.GameY
+ PLAYER_RECT_CY
- 4,
3705 'X', gStdFont
, 255, 255, 255, 1, True);
3707 for a := 0 to High(gCollideMap) do
3708 for b := 0 to High(gCollideMap[a]) do
3711 if ByteBool(gCollideMap[a, b] and MARK_WALL) then
3713 if ByteBool(gCollideMap[a, b] and MARK_DOOR) then
3717 1: e_DrawPoint(1, b, a, 200, 200, 200);
3718 2: e_DrawPoint(1, b, a, 64, 64, 255);
3719 3: e_DrawPoint(1, b, a, 255, 0, 255);
3729 if gShowMap
then DrawMinimap(p
, _TRect(0, 0, 128, 128));
3730 if g_Debug_Player
then
3731 g_Player_DrawDebug(p
);
3735 procedure drawProfilers ();
3740 if g_profile_frame_draw
and (profileFrameDraw
<> nil) then px
:= px
-drawProfiles(px
, py
, profileFrameDraw
);
3741 if g_profile_collision
and (profMapCollision
<> nil) then begin px
:= px
-drawProfiles(px
, py
, profMapCollision
); py
-= calcProfilesHeight(profMonsLOS
); end;
3742 if g_profile_los
and (profMonsLOS
<> nil) then begin px
:= px
-drawProfiles(px
, py
, profMonsLOS
); py
-= calcProfilesHeight(profMonsLOS
); end;
3745 procedure g_Game_Draw();
3752 plView1
, plView2
: TPlayer
;
3755 if gExit
= EXIT_QUIT
then Exit
;
3757 Time
:= sys_GetTicks() {div 1000};
3758 FPSCounter
:= FPSCounter
+1;
3759 if Time
- FPSTime
>= 1000 then
3766 if gGameOn
or (gState
= STATE_FOLD
) then
3768 if (gPlayer1
<> nil) and (gPlayer2
<> nil) then
3770 gSpectMode
:= SPECT_NONE
;
3771 if not gRevertPlayers
then
3773 plView1
:= gPlayer1
;
3774 plView2
:= gPlayer2
;
3778 plView1
:= gPlayer2
;
3779 plView2
:= gPlayer1
;
3783 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
3785 gSpectMode
:= SPECT_NONE
;
3786 if gPlayer2
= nil then
3789 plView1
:= gPlayer2
;
3798 if (plView1
= nil) and (plView2
= nil) and (gSpectMode
= SPECT_NONE
) then
3799 gSpectMode
:= SPECT_STATS
;
3801 if gSpectMode
= SPECT_PLAYERS
then
3802 if gPlayers
<> nil then
3804 plView1
:= GetActivePlayer_ByID(gSpectPID1
);
3805 if plView1
= nil then
3807 gSpectPID1
:= GetActivePlayerID_Next();
3808 plView1
:= GetActivePlayer_ByID(gSpectPID1
);
3810 if gSpectViewTwo
then
3812 plView2
:= GetActivePlayer_ByID(gSpectPID2
);
3813 if plView2
= nil then
3815 gSpectPID2
:= GetActivePlayerID_Next();
3816 plView2
:= GetActivePlayer_ByID(gSpectPID2
);
3821 if gSpectMode
= SPECT_MAPVIEW
then
3823 // Ðåæèì ïðîñìîòðà êàðòû
3825 e_SetViewPort(0, 0, gScreenWidth
, gScreenHeight
);
3826 DrawMapView(gSpectX
, gSpectY
, gScreenWidth
, gScreenHeight
);
3827 gHearPoint1
.Active
:= True;
3828 gHearPoint1
.Coords
.X
:= gScreenWidth
div 2 + gSpectX
;
3829 gHearPoint1
.Coords
.Y
:= gScreenHeight
div 2 + gSpectY
;
3830 gHearPoint2
.Active
:= False;
3834 Split
:= (plView1
<> nil) and (plView2
<> nil);
3836 // Òî÷êè ñëóõà èãðîêîâ
3837 if plView1
<> nil then
3839 gHearPoint1
.Active
:= True;
3840 gHearPoint1
.Coords
.X
:= plView1
.GameX
+ PLAYER_RECT
.Width
;
3841 gHearPoint1
.Coords
.Y
:= plView1
.GameY
+ PLAYER_RECT
.Height
DIV 2;
3843 gHearPoint1
.Active
:= False;
3844 if plView2
<> nil then
3846 gHearPoint2
.Active
:= True;
3847 gHearPoint2
.Coords
.X
:= plView2
.GameX
+ PLAYER_RECT
.Width
;
3848 gHearPoint2
.Coords
.Y
:= plView2
.GameY
+ PLAYER_RECT
.Height
DIV 2;
3850 gHearPoint2
.Active
:= False;
3852 // Ðàçìåð ýêðàíîâ èãðîêîâ:
3853 gPlayerScreenSize
.X
:= gScreenWidth
-196;
3856 gPlayerScreenSize
.Y
:= gScreenHeight
div 2;
3857 if gScreenHeight
mod 2 = 0 then
3858 Dec(gPlayerScreenSize
.Y
);
3861 gPlayerScreenSize
.Y
:= gScreenHeight
;
3864 if gScreenHeight
mod 2 = 0 then
3865 e_SetViewPort(0, gPlayerScreenSize
.Y
+2, gPlayerScreenSize
.X
+196, gPlayerScreenSize
.Y
)
3867 e_SetViewPort(0, gPlayerScreenSize
.Y
+1, gPlayerScreenSize
.X
+196, gPlayerScreenSize
.Y
);
3869 DrawPlayer(plView1
);
3870 gPlayer1ScreenCoord
.X
:= sX
;
3871 gPlayer1ScreenCoord
.Y
:= sY
;
3875 e_SetViewPort(0, 0, gPlayerScreenSize
.X
+196, gPlayerScreenSize
.Y
);
3877 DrawPlayer(plView2
);
3878 gPlayer2ScreenCoord
.X
:= sX
;
3879 gPlayer2ScreenCoord
.Y
:= sY
;
3882 e_SetViewPort(0, 0, gScreenWidth
, gScreenHeight
);
3885 e_DrawLine(2, 0, gScreenHeight
div 2, gScreenWidth
, gScreenHeight
div 2, 0, 0, 0);
3888 {$IFDEF ENABLE_HOLMES}
3890 if (g_holmes_enabled
) then g_Holmes_Draw();
3893 if MessageText
<> '' then
3897 e_CharFont_GetSizeFmt(gMenuFont
, MessageText
, w
, h
);
3899 e_CharFont_PrintFmt(gMenuFont
, (gScreenWidth
div 2)-(w
div 2),
3900 (gScreenHeight
div 2)-(h
div 2), MessageText
)
3902 e_CharFont_PrintFmt(gMenuFont
, (gScreenWidth
div 2)-(w
div 2),
3903 Round(gScreenHeight
/ 2.75)-(h
div 2), MessageText
);
3906 if IsDrawStat
or (gSpectMode
= 1) then DrawStat();
3908 if gSpectHUD
and (not gChatShow
) and (gSpectMode
<> SPECT_NONE
) and (not gSpectAuto
) then
3910 // Draw spectator GUI
3913 e_TextureFontGetSize(gStdFont
, ww
, hh
);
3916 e_TextureFontPrintEx(0, gScreenHeight
- (hh
+2)*2, 'MODE: Stats', gStdFont
, 255, 255, 255, 1);
3918 e_TextureFontPrintEx(0, gScreenHeight
- (hh
+2)*2, 'MODE: Observe Map', gStdFont
, 255, 255, 255, 1);
3920 e_TextureFontPrintEx(0, gScreenHeight
- (hh
+2)*2, 'MODE: Watch Players', gStdFont
, 255, 255, 255, 1);
3922 e_TextureFontPrintEx(2*ww
, gScreenHeight
- (hh
+2), '< jump >', gStdFont
, 255, 255, 255, 1);
3923 if gSpectMode
= SPECT_STATS
then
3925 e_TextureFontPrintEx(16*ww
, gScreenHeight
- (hh
+2)*2, 'Autoview', gStdFont
, 255, 255, 255, 1);
3926 e_TextureFontPrintEx(16*ww
, gScreenHeight
- (hh
+2), '< fire >', gStdFont
, 255, 255, 255, 1);
3928 if gSpectMode
= SPECT_MAPVIEW
then
3930 e_TextureFontPrintEx(22*ww
, gScreenHeight
- (hh
+2)*2, '[-]', gStdFont
, 255, 255, 255, 1);
3931 e_TextureFontPrintEx(26*ww
, gScreenHeight
- (hh
+2)*2, 'Step ' + IntToStr(gSpectStep
), gStdFont
, 255, 255, 255, 1);
3932 e_TextureFontPrintEx(34*ww
, gScreenHeight
- (hh
+2)*2, '[+]', gStdFont
, 255, 255, 255, 1);
3933 e_TextureFontPrintEx(18*ww
, gScreenHeight
- (hh
+2), '<prev weap>', gStdFont
, 255, 255, 255, 1);
3934 e_TextureFontPrintEx(30*ww
, gScreenHeight
- (hh
+2), '<next weap>', gStdFont
, 255, 255, 255, 1);
3936 if gSpectMode
= SPECT_PLAYERS
then
3938 e_TextureFontPrintEx(22*ww
, gScreenHeight
- (hh
+2)*2, 'Player 1', gStdFont
, 255, 255, 255, 1);
3939 e_TextureFontPrintEx(20*ww
, gScreenHeight
- (hh
+2), '<left/right>', gStdFont
, 255, 255, 255, 1);
3940 if gSpectViewTwo
then
3942 e_TextureFontPrintEx(37*ww
, gScreenHeight
- (hh
+2)*2, 'Player 2', gStdFont
, 255, 255, 255, 1);
3943 e_TextureFontPrintEx(34*ww
, gScreenHeight
- (hh
+2), '<prev w/next w>', gStdFont
, 255, 255, 255, 1);
3944 e_TextureFontPrintEx(52*ww
, gScreenHeight
- (hh
+2)*2, '2x View', gStdFont
, 255, 255, 255, 1);
3945 e_TextureFontPrintEx(51*ww
, gScreenHeight
- (hh
+2), '<up/down>', gStdFont
, 255, 255, 255, 1);
3949 e_TextureFontPrintEx(35*ww
, gScreenHeight
- (hh
+2)*2, '2x View', gStdFont
, 255, 255, 255, 1);
3950 e_TextureFontPrintEx(34*ww
, gScreenHeight
- (hh
+2), '<up/down>', gStdFont
, 255, 255, 255, 1);
3956 if gPauseMain
and gGameOn
and (g_ActiveWindow
= nil) then
3958 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
3959 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
3961 e_CharFont_GetSize(gMenuFont
, _lc
[I_MENU_PAUSE
], w
, h
);
3962 e_CharFont_Print(gMenuFont
, (gScreenWidth
div 2)-(w
div 2),
3963 (gScreenHeight
div 2)-(h
div 2), _lc
[I_MENU_PAUSE
]);
3968 if (gState
= STATE_MENU
) then
3970 if (g_ActiveWindow
= nil) or (g_ActiveWindow
.BackTexture
= '') then DrawMenuBackground('MENU_BACKGROUND');
3971 // F3 at menu will show game loading dialog
3972 if e_KeyPressed(IK_F3
) then g_Menu_Show_LoadMenu(true);
3973 if (g_ActiveWindow
<> nil) then
3975 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
3976 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
3980 // F3 at titlepic will show game loading dialog
3981 if e_KeyPressed(IK_F3
) then
3983 g_Menu_Show_LoadMenu(true);
3984 if (g_ActiveWindow
<> nil) then e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
3989 if gState
= STATE_FOLD
then
3991 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 0, 0, 0, EndingGameCounter
);
3994 if gState
= STATE_INTERCUSTOM
then
3996 if gLastMap
and (gGameSettings
.GameMode
= GM_COOP
) then
3998 back
:= 'TEXTURE_endpic';
3999 if not g_Texture_Get(back
, ID
) then
4000 back
:= _lc
[I_TEXTURE_ENDPIC
];
4005 DrawMenuBackground(back
);
4009 if g_ActiveWindow
<> nil then
4011 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4012 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4016 if gState
= STATE_INTERSINGLE
then
4018 if EndingGameCounter
> 0 then
4020 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 0, 0, 0, EndingGameCounter
);
4026 DrawMenuBackground(back
);
4030 if g_ActiveWindow
<> nil then
4032 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4033 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4038 if gState
= STATE_ENDPIC
then
4041 if g_Texture_Get('TEXTURE_endpic', ID
) then DrawMenuBackground('TEXTURE_endpic')
4042 else DrawMenuBackground(_lc
[I_TEXTURE_ENDPIC
]);
4044 if g_ActiveWindow
<> nil then
4046 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4047 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4051 if gState
= STATE_SLIST
then
4053 // if g_Texture_Get('MENU_BACKGROUND', ID) then
4055 // e_DrawSize(ID, 0, 0, 0, False, False, gScreenWidth, gScreenHeight);
4056 // //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4058 DrawMenuBackground('MENU_BACKGROUND');
4059 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4060 g_Serverlist_Draw(slCurrent
, slTable
);
4064 if g_ActiveWindow
<> nil then
4068 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4069 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4071 g_ActiveWindow
.Draw();
4078 if g_debug_Sounds
and gGameOn
then
4080 for w
:= 0 to High(e_SoundsArray
) do
4081 for h
:= 0 to e_SoundsArray
[w
].nRefs
do
4082 e_DrawPoint(1, w
+100, h
+100, 255, 0, 0);
4087 e_TextureFontPrint(0, 0, Format('FPS: %d', [FPS
]), gStdFont
);
4088 e_TextureFontPrint(0, 16, Format('UPS: %d', [UPS
]), gStdFont
);
4091 if gGameOn
and gShowTime
then
4092 drawTime(gScreenWidth
-72, gScreenHeight
-16);
4094 if gGameOn
then drawProfilers();
4096 {$IFDEF ENABLE_HOLMES}
4103 procedure g_Game_Quit();
4105 g_Game_StopAllSounds(True);
4108 g_PlayerModel_FreeData();
4109 g_Texture_DeleteAll();
4110 g_Frames_DeleteAll();
4112 //g_Menu_Free(); //k8: this segfaults after resolution change; who cares?
4115 if NetInitDone
then g_Net_Free
;
4117 // Íàäî óäàëèòü êàðòó ïîñëå òåñòà:
4118 if gMapToDelete
<> '' then
4119 g_Game_DeleteTestMap();
4125 procedure g_FatalError(Text: String);
4127 g_Console_Add(Format(_lc
[I_FATAL_ERROR
], [Text]), True);
4128 e_WriteLog(Format(_lc
[I_FATAL_ERROR
], [Text]), TMsgType
.Warning
);
4130 gExit
:= EXIT_SIMPLE
;
4133 procedure g_SimpleError(Text: String);
4135 g_Console_Add(Format(_lc
[I_SIMPLE_ERROR
], [Text]), True);
4136 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], [Text]), TMsgType
.Warning
);
4139 procedure g_Game_SetupScreenSize();
4141 RES_FACTOR
= 4.0 / 3.0;
4147 // Ðàçìåð ýêðàíîâ èãðîêîâ:
4148 gPlayerScreenSize
.X
:= gScreenWidth
-196;
4149 if (gPlayer1
<> nil) and (gPlayer2
<> nil) then
4150 gPlayerScreenSize
.Y
:= gScreenHeight
div 2
4152 gPlayerScreenSize
.Y
:= gScreenHeight
;
4154 // Ðàçìåð çàäíåãî ïëàíà:
4155 if BackID
<> DWORD(-1) then
4158 if (gScreenWidth
*s
> gMapInfo
.Width
) or
4159 (gScreenHeight
*s
> gMapInfo
.Height
) then
4161 gBackSize
.X
:= gScreenWidth
;
4162 gBackSize
.Y
:= gScreenHeight
;
4166 e_GetTextureSize(BackID
, @bw
, @bh
);
4167 rf
:= Single(bw
) / Single(bh
);
4168 if (rf
> RES_FACTOR
) then bw
:= Round(Single(bh
) * RES_FACTOR
)
4169 else if (rf
< RES_FACTOR
) then bh
:= Round(Single(bw
) / RES_FACTOR
);
4170 s
:= Max(gScreenWidth
/ bw
, gScreenHeight
/ bh
);
4171 if (s
< 1.0) then s
:= 1.0;
4172 gBackSize
.X
:= Round(bw
*s
);
4173 gBackSize
.Y
:= Round(bh
*s
);
4178 procedure g_Game_ChangeResolution(newWidth
, newHeight
: Word; nowFull
, nowMax
: Boolean);
4180 sys_SetDisplayMode(newWidth
, newHeight
, gBPP
, nowFull
);
4183 procedure g_Game_AddPlayer(Team
: Byte = TEAM_NONE
);
4185 if ((not gGameOn
) and (gState
<> STATE_INTERCUSTOM
))
4186 or (not (gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
])) then
4188 if gPlayer1
= nil then
4190 if g_Game_IsClient
then
4192 if NetPlrUID1
> -1 then
4194 MC_SEND_CheatRequest(NET_CHEAT_SPECTATE
);
4195 gPlayer1
:= g_Player_Get(NetPlrUID1
);
4200 if not (Team
in [TEAM_RED
, TEAM_BLUE
]) then
4201 Team
:= gPlayer1Settings
.Team
;
4203 // Ñîçäàíèå ïåðâîãî èãðîêà:
4204 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4205 gPlayer1Settings
.Color
,
4207 if gPlayer1
= nil then
4208 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]))
4211 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4212 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [gPlayer1
.Name
]), True);
4213 if g_Game_IsServer
and g_Game_IsNet
then
4214 MH_SEND_PlayerCreate(gPlayer1
.UID
);
4215 gPlayer1
.Respawn(False, True);
4216 g_Net_Slist_ServerPlayerComes();
4221 if gPlayer2
= nil then
4223 if g_Game_IsClient
then
4225 if NetPlrUID2
> -1 then
4226 gPlayer2
:= g_Player_Get(NetPlrUID2
);
4230 if not (Team
in [TEAM_RED
, TEAM_BLUE
]) then
4231 Team
:= gPlayer2Settings
.Team
;
4233 // Ñîçäàíèå âòîðîãî èãðîêà:
4234 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
4235 gPlayer2Settings
.Color
,
4237 if gPlayer2
= nil then
4238 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]))
4241 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
4242 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [gPlayer2
.Name
]), True);
4243 if g_Game_IsServer
and g_Game_IsNet
then
4244 MH_SEND_PlayerCreate(gPlayer2
.UID
);
4245 gPlayer2
.Respawn(False, True);
4246 g_Net_Slist_ServerPlayerComes();
4253 procedure g_Game_RemovePlayer();
4257 if ((not gGameOn
) and (gState
<> STATE_INTERCUSTOM
))
4258 or (not (gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
])) then
4263 if g_Game_IsServer
then
4266 Pl
.Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
4267 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [Pl
.Name
]), True);
4268 g_Player_Remove(Pl
.UID
);
4269 g_Net_Slist_ServerPlayerLeaves();
4277 if g_Game_IsServer
then
4280 Pl
.Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
4281 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [Pl
.Name
]), True);
4282 g_Player_Remove(Pl
.UID
);
4283 g_Net_Slist_ServerPlayerLeaves();
4287 MC_SEND_CheatRequest(NET_CHEAT_SPECTATE
);
4291 g_Net_Slist_ServerPlayerLeaves();
4294 procedure g_Game_Spectate();
4296 g_Game_RemovePlayer();
4297 if gPlayer1
<> nil then
4298 g_Game_RemovePlayer();
4301 procedure g_Game_SpectateCenterView();
4303 gSpectX
:= Max(gMapInfo
.Width
div 2 - gScreenWidth
div 2, 0);
4304 gSpectY
:= Max(gMapInfo
.Height
div 2 - gScreenHeight
div 2, 0);
4307 procedure g_Game_StartSingle(Map
: String; TwoPlayers
: Boolean; nPlayers
: Byte);
4314 e_WriteLog('Starting singleplayer game...', TMsgType
.Notify
);
4316 g_Game_ClearLoading();
4319 FillByte(gGameSettings
, SizeOf(TGameSettings
), 0);
4322 gGameSettings
.GameType
:= GT_SINGLE
;
4323 gGameSettings
.MaxLives
:= 0;
4324 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_ALLOWEXIT
;
4325 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_MONSTERS
;
4326 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_BOTVSMONSTER
;
4327 gSwitchGameMode
:= GM_SINGLE
;
4329 g_Game_ExecuteEvent('ongamestart');
4331 // Óñòàíîâêà ðàçìåðîâ îêîí èãðîêîâ:
4332 g_Game_SetupScreenSize();
4334 // Ñîçäàíèå ïåðâîãî èãðîêà:
4335 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4336 gPlayer1Settings
.Color
,
4337 gPlayer1Settings
.Team
, False));
4338 if gPlayer1
= nil then
4340 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
4344 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4347 // Ñîçäàíèå âòîðîãî èãðîêà, åñëè åñòü:
4350 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
4351 gPlayer2Settings
.Color
,
4352 gPlayer2Settings
.Team
, False));
4353 if gPlayer2
= nil then
4355 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
4359 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
4363 // Çàãðóçêà è çàïóñê êàðòû:
4364 if not g_Game_StartMap(false{asMegawad}, MAP
, True) then
4366 if (Pos(':\', Map
) > 0) or (Pos(':/', Map
) > 0) then tmps
:= Map
else tmps
:= gGameSettings
.WAD
+ ':\' + MAP
;
4367 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [tmps
]));
4371 // Íàñòðîéêè èãðîêîâ è áîòîâ:
4375 for i
:= nPl
+1 to nPlayers
do
4376 g_Player_Create(STD_PLAYER_MODEL
, _RGB(0, 0, 0), 0, True);
4379 procedure g_Game_StartCustom(Map
: String; GameMode
: Byte;
4380 TimeLimit
, GoalLimit
: Word;
4382 Options
: LongWord; nPlayers
: Byte);
4388 e_WriteLog('Starting custom game...', TMsgType
.Notify
);
4390 g_Game_ClearLoading();
4393 gGameSettings
.GameType
:= GT_CUSTOM
;
4394 gGameSettings
.GameMode
:= GameMode
;
4395 gSwitchGameMode
:= GameMode
;
4396 gGameSettings
.TimeLimit
:= TimeLimit
;
4397 gGameSettings
.GoalLimit
:= GoalLimit
;
4398 gGameSettings
.MaxLives
:= IfThen(GameMode
= GM_CTF
, 0, MaxLives
);
4399 gGameSettings
.Options
:= Options
;
4401 gCoopTotalMonstersKilled
:= 0;
4402 gCoopTotalSecretsFound
:= 0;
4403 gCoopTotalMonsters
:= 0;
4404 gCoopTotalSecrets
:= 0;
4408 g_Game_ExecuteEvent('ongamestart');
4410 // Óñòàíîâêà ðàçìåðîâ îêîí èãðîêîâ:
4411 g_Game_SetupScreenSize();
4413 // Ðåæèì íàáëþäàòåëÿ:
4414 if nPlayers
= 0 then
4421 if nPlayers
>= 1 then
4423 // Ñîçäàíèå ïåðâîãî èãðîêà:
4424 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4425 gPlayer1Settings
.Color
,
4426 gPlayer1Settings
.Team
, False));
4427 if gPlayer1
= nil then
4429 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
4433 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4437 if nPlayers
>= 2 then
4439 // Ñîçäàíèå âòîðîãî èãðîêà:
4440 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
4441 gPlayer2Settings
.Color
,
4442 gPlayer2Settings
.Team
, False));
4443 if gPlayer2
= nil then
4445 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
4449 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
4453 // Çàãðóçêà è çàïóñê êàðòû:
4454 if not g_Game_StartMap(true{asMegawad}, Map
, True) then
4456 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [Map
]));
4460 // Íåò òî÷åê ïîÿâëåíèÿ:
4461 if (g_Map_GetPointCount(RESPAWNPOINT_PLAYER1
) +
4462 g_Map_GetPointCount(RESPAWNPOINT_PLAYER2
) +
4463 g_Map_GetPointCount(RESPAWNPOINT_DM
) +
4464 g_Map_GetPointCount(RESPAWNPOINT_RED
)+
4465 g_Map_GetPointCount(RESPAWNPOINT_BLUE
)) < 1 then
4467 g_FatalError(_lc
[I_GAME_ERROR_GET_SPAWN
]);
4471 // Íàñòðîéêè èãðîêîâ è áîòîâ:
4475 for i
:= nPl
+1 to nPlayers
do
4476 g_Player_Create(STD_PLAYER_MODEL
, _RGB(0, 0, 0), 0, True);
4479 procedure g_Game_StartServer(Map
: String; GameMode
: Byte;
4480 TimeLimit
, GoalLimit
: Word; MaxLives
: Byte;
4481 Options
: LongWord; nPlayers
: Byte;
4482 IPAddr
: LongWord; Port
: Word);
4485 g_Net_Slist_ServerClosed();
4487 e_WriteLog('Starting net game (server)...', TMsgType
.Notify
);
4489 g_Game_ClearLoading();
4492 gGameSettings
.GameType
:= GT_SERVER
;
4493 gGameSettings
.GameMode
:= GameMode
;
4494 gSwitchGameMode
:= GameMode
;
4495 gGameSettings
.TimeLimit
:= TimeLimit
;
4496 gGameSettings
.GoalLimit
:= GoalLimit
;
4497 gGameSettings
.MaxLives
:= IfThen(GameMode
= GM_CTF
, 0, MaxLives
);
4498 gGameSettings
.Options
:= Options
;
4500 gCoopTotalMonstersKilled
:= 0;
4501 gCoopTotalSecretsFound
:= 0;
4502 gCoopTotalMonsters
:= 0;
4503 gCoopTotalSecrets
:= 0;
4507 g_Game_ExecuteEvent('ongamestart');
4509 // Óñòàíîâêà ðàçìåðîâ îêíà èãðîêà
4510 g_Game_SetupScreenSize();
4512 // Ðåæèì íàáëþäàòåëÿ:
4513 if nPlayers
= 0 then
4519 if nPlayers
>= 1 then
4521 // Ñîçäàíèå ïåðâîãî èãðîêà:
4522 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4523 gPlayer1Settings
.Color
,
4524 gPlayer1Settings
.Team
, False));
4525 if gPlayer1
= nil then
4527 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
4531 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4534 if nPlayers
>= 2 then
4536 // Ñîçäàíèå âòîðîãî èãðîêà:
4537 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
4538 gPlayer2Settings
.Color
,
4539 gPlayer2Settings
.Team
, False));
4540 if gPlayer2
= nil then
4542 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
4546 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
4549 g_Game_SetLoadingText(_lc
[I_LOAD_HOST
], 0, False);
4550 if NetForwardPorts
then
4551 g_Game_SetLoadingText(_lc
[I_LOAD_PORTS
], 0, False);
4554 if not g_Net_Host(IPAddr
, Port
, NetMaxClients
) then
4556 g_FatalError(_lc
[I_NET_MSG
] + _lc
[I_NET_ERR_HOST
]);
4560 g_Net_Slist_Set(NetSlistIP
, NetSlistPort
, NetSlistList
);
4562 g_Net_Slist_ServerStarted();
4564 // Çàãðóçêà è çàïóñê êàðòû:
4565 if not g_Game_StartMap(false{asMegawad}, Map
, True) then
4567 g_Net_Slist_ServerClosed();
4568 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [Map
]));
4572 // Íåò òî÷åê ïîÿâëåíèÿ:
4573 if (g_Map_GetPointCount(RESPAWNPOINT_PLAYER1
) +
4574 g_Map_GetPointCount(RESPAWNPOINT_PLAYER2
) +
4575 g_Map_GetPointCount(RESPAWNPOINT_DM
) +
4576 g_Map_GetPointCount(RESPAWNPOINT_RED
)+
4577 g_Map_GetPointCount(RESPAWNPOINT_BLUE
)) < 1 then
4579 g_Net_Slist_ServerClosed();
4580 g_FatalError(_lc
[I_GAME_ERROR_GET_SPAWN
]);
4584 // Íàñòðîéêè èãðîêîâ è áîòîâ:
4587 g_Net_Slist_ServerMapStarted();
4588 NetState
:= NET_STATE_GAME
;
4591 procedure g_Game_StartClient(Addr
: String; Port
: Word; PW
: String);
4606 e_WriteLog('Starting net game (client)...', TMsgType
.Notify
);
4607 e_WriteLog('NET: Trying to connect to ' + Addr
+ ':' + IntToStr(Port
) + '...', TMsgType
.Notify
);
4609 g_Game_ClearLoading();
4612 gGameSettings
.GameType
:= GT_CLIENT
;
4614 gCoopTotalMonstersKilled
:= 0;
4615 gCoopTotalSecretsFound
:= 0;
4616 gCoopTotalMonsters
:= 0;
4617 gCoopTotalSecrets
:= 0;
4621 g_Game_ExecuteEvent('ongamestart');
4623 // Óñòàíîâêà ðàçìåðîâ îêîí èãðîêîâ:
4624 g_Game_SetupScreenSize();
4626 NetState
:= NET_STATE_AUTH
;
4628 g_Game_SetLoadingText(_lc
[I_LOAD_CONNECT
], 0, False);
4630 // create (or update) map/resource databases
4631 g_Res_CreateDatabases(true);
4634 if not g_Net_Connect(Addr
, Port
) then
4636 g_FatalError(_lc
[I_NET_MSG
] + _lc
[I_NET_ERR_CONN
]);
4637 NetState
:= NET_STATE_NONE
;
4641 g_Game_SetLoadingText(_lc
[I_LOAD_SEND_INFO
], 0, False);
4643 g_Game_SetLoadingText(_lc
[I_LOAD_WAIT_INFO
], 0, False);
4648 // fuck! https://www.mail-archive.com/enet-discuss@cubik.org/msg00852.html
4649 // tl;dr: on shitdows, we can get -1 sometimes, and it is *NOT* a failure.
4650 // thank you, enet. let's ignore failures altogether then.
4651 while (enet_host_service(NetHost
, @NetEvent
, 50) > 0) do
4653 if (NetEvent
.kind
= ENET_EVENT_TYPE_RECEIVE
) then
4655 if (NetEvent
.channelID
= NET_CHAN_DOWNLOAD_EX
) then
4657 // ignore all download packets, they're processed by separate code
4658 enet_packet_destroy(NetEvent
.packet
);
4661 Ptr
:= NetEvent
.packet
^.data
;
4662 if not InMsg
.Init(Ptr
, NetEvent
.packet
^.dataLength
, True) then
4664 enet_packet_destroy(NetEvent
.packet
);
4668 InMsg
.ReadLongWord(); // skip size
4669 MID
:= InMsg
.ReadByte();
4671 if (MID
= NET_MSG_INFO
) and (State
= 0) then
4673 NetMyID
:= InMsg
.ReadByte();
4674 NetPlrUID1
:= InMsg
.ReadWord();
4676 WadName
:= InMsg
.ReadString();
4677 Map
:= InMsg
.ReadString();
4679 gWADHash
:= InMsg
.ReadMD5();
4681 gGameSettings
.GameMode
:= InMsg
.ReadByte();
4682 gSwitchGameMode
:= gGameSettings
.GameMode
;
4683 gGameSettings
.GoalLimit
:= InMsg
.ReadWord();
4684 gGameSettings
.TimeLimit
:= InMsg
.ReadWord();
4685 gGameSettings
.MaxLives
:= InMsg
.ReadByte();
4686 gGameSettings
.Options
:= InMsg
.ReadLongWord();
4687 T
:= InMsg
.ReadLongWord();
4689 //newResPath := g_Res_SearchSameWAD(MapsDir, WadName, gWADHash);
4690 //if newResPath = '' then
4692 //g_Game_SetLoadingText(_lc[I_LOAD_DL_RES], 0, False);
4693 newResPath
:= g_Res_DownloadMapWAD(ExtractFileName(WadName
), gWADHash
);
4694 if newResPath
= '' then
4696 g_FatalError(_lc
[I_NET_ERR_HASH
]);
4697 enet_packet_destroy(NetEvent
.packet
);
4698 NetState
:= NET_STATE_NONE
;
4701 e_LogWritefln('using downloaded map wad [%s] for [%s]`', [newResPath
, WadName
], TMsgType
.Notify
);
4703 //newResPath := ExtractRelativePath(MapsDir, newResPath);
4706 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4707 gPlayer1Settings
.Color
,
4708 gPlayer1Settings
.Team
, False));
4710 if gPlayer1
= nil then
4712 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
4714 enet_packet_destroy(NetEvent
.packet
);
4715 NetState
:= NET_STATE_NONE
;
4719 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4720 gPlayer1
.UID
:= NetPlrUID1
;
4721 gPlayer1
.Reset(True);
4723 if not g_Game_StartMap(false{asMegawad}, newResPath
+ ':\' + Map
, True) then
4725 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [WadName
+ ':\' + Map
]));
4727 enet_packet_destroy(NetEvent
.packet
);
4728 NetState
:= NET_STATE_NONE
;
4736 enet_packet_destroy(NetEvent
.packet
);
4740 enet_packet_destroy(NetEvent
.packet
);
4744 if (NetEvent
.kind
= ENET_EVENT_TYPE_DISCONNECT
) then
4747 if (NetEvent
.data
<= NET_DISC_MAX
) then
4748 g_Console_Add(_lc
[I_NET_MSG_ERROR
] + _lc
[I_NET_ERR_CONN
] + ' ' +
4749 _lc
[TStrings_Locale(Cardinal(I_NET_DISC_NONE
) + NetEvent
.data
)], True);
4756 ProcessLoading(true);
4758 if g_Net_UserRequestExit() then
4767 g_FatalError(_lc
[I_NET_MSG
] + _lc
[I_NET_ERR_CONN
]);
4768 NetState
:= NET_STATE_NONE
;
4772 gLMSRespawn
:= LMS_RESPAWN_NONE
;
4773 gLMSRespawnTime
:= 0;
4776 NetState
:= NET_STATE_GAME
;
4777 MC_SEND_FullStateRequest
;
4778 e_WriteLog('NET: Connection successful.', TMsgType
.Notify
);
4782 lastAsMegaWad
: Boolean = false;
4784 procedure g_Game_ChangeMap(const MapPath
: String);
4788 g_Game_ClearLoading();
4790 Force
:= gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
];
4791 // Åñëè óðîâåíü çàâåðøèëñÿ ïî òðèããåðó Âûõîä, íå î÷èùàòü èíâåíòàðü
4792 if gExitByTrigger
then
4795 gExitByTrigger
:= False;
4797 if not g_Game_StartMap(lastAsMegaWad
, MapPath
, Force
) then
4798 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [MapPath
]));
4801 procedure g_Game_Restart();
4805 if g_Game_IsClient
then
4807 map
:= g_ExtractFileName(gMapInfo
.Map
);
4808 e_LogWritefln('g_Game_Restart: map = "%s" gCurrentMapFileName = "%s"', [map
, gCurrentMapFileName
]);
4812 g_Game_ClearLoading();
4813 g_Game_StartMap(lastAsMegaWad
, Map
, True, gCurrentMapFileName
);
4816 function g_Game_StartMap (asMegawad
: Boolean; Map
: String; Force
: Boolean = False; const oldMapPath
: AnsiString=''): Boolean;
4818 NewWAD
, ResName
: String;
4822 g_Map_Free((Map
<> gCurrentMapFileName
) and (oldMapPath
<> gCurrentMapFileName
));
4823 g_Player_RemoveAllCorpses();
4825 if (not g_Game_IsClient
) and
4826 (gSwitchGameMode
<> gGameSettings
.GameMode
) and
4827 (gGameSettings
.GameMode
<> GM_SINGLE
) then
4829 if gSwitchGameMode
= GM_CTF
then
4830 gGameSettings
.MaxLives
:= 0;
4831 gGameSettings
.GameMode
:= gSwitchGameMode
;
4834 gSwitchGameMode
:= gGameSettings
.GameMode
;
4836 g_Player_ResetTeams();
4838 lastAsMegaWad
:= asMegawad
;
4839 if isWadPath(Map
) then
4841 NewWAD
:= g_ExtractWadName(Map
);
4842 ResName
:= g_ExtractFileName(Map
);
4843 if g_Game_IsServer
then
4845 nws
:= findDiskWad(NewWAD
);
4846 //writeln('000: Map=[', Map, ']; nws=[', nws, ']; NewWAD=[', NewWAD, ']');
4849 if (length(nws
) = 0) then nws
:= e_FindWad(MegawadDirs
, NewWAD
);
4850 if (length(nws
) = 0) then nws
:= e_FindWad(MapDirs
, NewWAD
);
4854 if (length(nws
) = 0) then nws
:= e_FindWad(MapDirs
, NewWAD
);
4855 if (length(nws
) = 0) then nws
:= e_FindWad(MegawadDirs
, NewWAD
);
4857 //if (length(nws) = 0) then nws := e_FindWad(MapDownloadDirs, NewWAD);
4858 //writeln('001: Map=[', Map, ']; nws=[', nws, ']; NewWAD=[', NewWAD, ']');
4860 if (length(nws
) = 0) then
4862 ResName
:= ''; // failed
4867 if (g_Game_IsNet
) then gWADHash
:= MD5File(nws
);
4868 //writeln('********: nws=', nws, ' : Map=', Map, ' : nw=', NewWAD, ' : resname=', ResName);
4869 g_Game_LoadWAD(NewWAD
);
4874 // hash received in MC_RECV_GameEvent -> NET_EV_MAPSTART
4875 NewWAD
:= g_Game_ClientWAD(NewWAD
, gWADHash
);
4880 NewWAD
:= gGameSettings
.WAD
;
4884 //writeln('********: gsw=', gGameSettings.WAD, '; rn=', ResName);
4886 if (ResName
<> '') and (NewWAD
<> '') then
4888 //result := g_Map_Load(gGameSettings.WAD + ':\' + ResName);
4889 result
:= g_Map_Load(NewWAD
+':\'+ResName
);
4893 g_Player_ResetAll(Force
or gLastMap
, gGameSettings
.GameType
= GT_SINGLE
);
4895 gState
:= STATE_NONE
;
4896 g_ActiveWindow
:= nil;
4902 if gGameSettings
.GameMode
= GM_CTF
then
4904 g_Map_ResetFlag(FLAG_RED
);
4905 g_Map_ResetFlag(FLAG_BLUE
);
4906 // CTF, à ôëàãîâ íåò:
4907 if not g_Map_HaveFlagPoints() then
4908 g_SimpleError(_lc
[I_GAME_ERROR_CTF
]);
4913 gState
:= STATE_MENU
;
4918 gPauseMain
:= false;
4919 gPauseHolmes
:= false;
4921 NetTimeToUpdate
:= 1;
4922 NetTimeToReliable
:= 0;
4923 NetTimeToMaster
:= NetMasterRate
;
4924 gLMSRespawn
:= LMS_RESPAWN_NONE
;
4925 gLMSRespawnTime
:= 0;
4926 gMissionFailed
:= False;
4929 gCoopMonstersKilled
:= 0;
4930 gCoopSecretsFound
:= 0;
4932 gVoteInProgress
:= False;
4933 gVotePassed
:= False;
4939 if not gGameOn
then Exit
;
4941 g_Game_SpectateCenterView();
4943 if (gGameSettings
.MaxLives
> 0) and (gGameSettings
.WarmupTime
> 0) then
4945 gLMSRespawn
:= LMS_RESPAWN_WARMUP
;
4946 gLMSRespawnTime
:= gTime
+ gGameSettings
.WarmupTime
*1000;
4947 gLMSSoftSpawn
:= True;
4948 if NetMode
= NET_SERVER
then
4949 MH_SEND_GameEvent(NET_EV_LMS_WARMUP
, (gLMSRespawnTime
- gTime
) div 1000)
4951 g_Console_Add(Format(_lc
[I_MSG_WARMUP_START
], [(gLMSRespawnTime
- gTime
) div 1000]), True);
4954 if NetMode
= NET_SERVER
then
4956 MH_SEND_GameEvent(NET_EV_MAPSTART
, gGameSettings
.GameMode
, Map
);
4959 g_Net_Slist_ServerMapStarted();
4961 if NetClients
<> nil then
4962 for I
:= 0 to High(NetClients
) do
4963 if NetClients
[I
].Used
then
4965 NetClients
[I
].Voted
:= False;
4966 if NetClients
[I
].RequestedFullUpdate
then
4968 MH_SEND_Everything((NetClients
[I
].State
= NET_STATE_AUTH
), I
);
4969 NetClients
[I
].RequestedFullUpdate
:= False;
4973 g_Net_UnbanNonPermHosts();
4978 gCoopTotalMonstersKilled
:= 0;
4979 gCoopTotalSecretsFound
:= 0;
4980 gCoopTotalMonsters
:= 0;
4981 gCoopTotalSecrets
:= 0;
4985 g_Game_ExecuteEvent('onmapstart');
4988 procedure SetFirstLevel
;
4992 MapList
:= g_Map_GetMapsList(gGameSettings
.WAD
);
4993 if MapList
= nil then
4996 SortSArray(MapList
);
4997 gNextMap
:= MapList
[Low(MapList
)];
5002 procedure g_Game_ExitLevel(const Map
: AnsiString);
5006 gCoopTotalMonstersKilled
:= gCoopTotalMonstersKilled
+ gCoopMonstersKilled
;
5007 gCoopTotalSecretsFound
:= gCoopTotalSecretsFound
+ gCoopSecretsFound
;
5008 gCoopTotalMonsters
:= gCoopTotalMonsters
+ gTotalMonsters
;
5009 gCoopTotalSecrets
:= gCoopTotalSecrets
+ gSecretsCount
;
5011 // Âûøëè â âûõîä â Îäèíî÷íîé èãðå:
5012 if gGameSettings
.GameType
= GT_SINGLE
then
5013 gExit
:= EXIT_ENDLEVELSINGLE
5014 else // Âûøëè â âûõîä â Ñâîåé èãðå
5016 gExit
:= EXIT_ENDLEVELCUSTOM
;
5017 if gGameSettings
.GameMode
= GM_COOP
then
5018 g_Player_RememberAll
;
5020 if not g_Map_Exist(gGameSettings
.WAD
+ ':\' + gNextMap
) then
5023 if gGameSettings
.GameMode
= GM_COOP
then
5026 gStatsPressed
:= True;
5027 gNextMap
:= 'MAP01';
5029 if not g_Map_Exist(gGameSettings
.WAD
+ ':\' + gNextMap
) then
5032 if g_Game_IsNet
then
5034 MH_SEND_GameStats();
5035 MH_SEND_CoopStats();
5041 procedure g_Game_RestartLevel();
5045 if gGameSettings
.GameMode
= GM_SINGLE
then
5050 gExit
:= EXIT_ENDLEVELCUSTOM
;
5051 Map
:= g_ExtractFileName(gMapInfo
.Map
);
5055 function g_Game_ClientWAD (NewWAD
: String; const WHash
: TMD5Digest
): AnsiString;
5057 gWAD
{, xwad}: String;
5060 if not g_Game_IsClient
then Exit
;
5061 //e_LogWritefln('*** g_Game_ClientWAD: `%s`', [NewWAD]);
5063 gWAD
:= g_Res_DownloadMapWAD(ExtractFileName(NewWAD
), WHash
);
5068 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_WAD
], [ExtractFileName(NewWAD
)]));
5072 e_LogWritefln('using downloaded client map wad [%s] for [%s]', [gWAD
, NewWAD
], TMsgType
.Notify
);
5075 g_Game_LoadWAD(NewWAD
);
5079 if LowerCase(NewWAD) = LowerCase(gGameSettings.WAD) then Exit;
5080 gWAD := g_Res_SearchSameWAD(MapsDir, ExtractFileName(NewWAD), WHash);
5083 g_Game_SetLoadingText(_lc[I_LOAD_DL_RES], 0, False);
5084 gWAD := g_Res_DownloadMapWAD(ExtractFileName(NewWAD), WHash);
5088 g_FatalError(Format(_lc[I_GAME_ERROR_MAP_WAD], [ExtractFileName(NewWAD)]));
5092 NewWAD := ExtractRelativePath(MapsDir, gWAD);
5093 g_Game_LoadWAD(NewWAD);
5097 procedure g_Game_RestartRound(NoMapRestart
: Boolean = False);
5099 i
, n
, nb
, nr
: Integer;
5101 function monRespawn (mon
: TMonster
): Boolean;
5103 result
:= false; // don't stop
5104 if not mon
.FNoRespawn
then mon
.Respawn();
5108 if not g_Game_IsServer
then Exit
;
5109 if gLMSRespawn
= LMS_RESPAWN_NONE
then Exit
;
5110 gLMSRespawn
:= LMS_RESPAWN_NONE
;
5111 gLMSRespawnTime
:= 0;
5114 if (gGameSettings
.GameMode
= GM_COOP
) and not NoMapRestart
then
5116 gMissionFailed
:= True;
5117 g_Game_RestartLevel
;
5121 n
:= 0; nb
:= 0; nr
:= 0;
5122 for i
:= Low(gPlayers
) to High(gPlayers
) do
5123 if (gPlayers
[i
] <> nil) and
5124 ((not gPlayers
[i
].FSpectator
) or gPlayers
[i
].FWantsInGame
or
5125 (gPlayers
[i
] is TBot
)) then
5128 if gPlayers
[i
].Team
= TEAM_RED
then Inc(nr
)
5129 else if gPlayers
[i
].Team
= TEAM_BLUE
then Inc(nb
)
5132 if (n
< 2) or ((gGameSettings
.GameMode
= GM_TDM
) and ((nr
= 0) or (nb
= 0))) then
5134 // wait a second until the fuckers finally decide to join
5135 gLMSRespawn
:= LMS_RESPAWN_WARMUP
;
5136 gLMSRespawnTime
:= gTime
+ 1000;
5137 gLMSSoftSpawn
:= NoMapRestart
;
5141 g_Player_RemoveAllCorpses
;
5142 g_Game_Message(_lc
[I_MESSAGE_LMS_START
], 144);
5143 if g_Game_IsNet
then
5144 MH_SEND_GameEvent(NET_EV_LMS_START
);
5146 for i
:= Low(gPlayers
) to High(gPlayers
) do
5148 if gPlayers
[i
] = nil then continue
;
5149 if gPlayers
[i
] is TBot
then gPlayers
[i
].FWantsInGame
:= True;
5150 // don't touch normal spectators
5151 if gPlayers
[i
].FSpectator
and not gPlayers
[i
].FWantsInGame
then
5153 gPlayers
[i
].FNoRespawn
:= True;
5154 gPlayers
[i
].Lives
:= 0;
5155 if g_Game_IsNet
then
5156 MH_SEND_PlayerStats(gPlayers
[I
].UID
);
5159 gPlayers
[i
].FNoRespawn
:= False;
5160 gPlayers
[i
].Lives
:= gGameSettings
.MaxLives
;
5161 gPlayers
[i
].Respawn(False, True);
5162 if gGameSettings
.GameMode
= GM_COOP
then
5164 gPlayers
[i
].Frags
:= 0;
5165 gPlayers
[i
].RecallState
;
5167 if (gPlayer1
= nil) and (gLMSPID1
> 0) then
5168 gPlayer1
:= g_Player_Get(gLMSPID1
);
5169 if (gPlayer2
= nil) and (gLMSPID2
> 0) then
5170 gPlayer2
:= g_Player_Get(gLMSPID2
);
5173 g_Items_RestartRound();
5176 g_Mons_ForEach(monRespawn
);
5178 gLMSSoftSpawn
:= False;
5181 function g_Game_GetFirstMap(WAD
: String): String;
5185 MapList
:= g_Map_GetMapsList(WAD
);
5186 if MapList
= nil then
5189 SortSArray(MapList
);
5190 Result
:= MapList
[Low(MapList
)];
5192 if not g_Map_Exist(WAD
+ ':\' + Result
) then
5198 function g_Game_GetNextMap(): String;
5205 MapList
:= g_Map_GetMapsList(gGameSettings
.WAD
);
5206 if MapList
= nil then
5209 Map
:= g_ExtractFileName(gMapInfo
.Map
);
5211 SortSArray(MapList
);
5213 for I
:= Low(MapList
) to High(MapList
) do
5214 if Map
= MapList
[I
] then
5220 if MapIndex
<> -255 then
5222 if MapIndex
= High(MapList
) then
5223 Result
:= MapList
[Low(MapList
)]
5225 Result
:= MapList
[MapIndex
+ 1];
5227 if not g_Map_Exist(gGameSettings
.WAD
+ ':\' + Result
) then Result
:= Map
;
5233 procedure g_Game_NextLevel();
5235 if gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
, GM_COOP
] then
5236 gExit
:= EXIT_ENDLEVELCUSTOM
5239 gExit
:= EXIT_ENDLEVELSINGLE
;
5243 if gNextMap
<> '' then Exit
;
5244 gNextMap
:= g_Game_GetNextMap();
5247 function g_Game_IsTestMap(): Boolean;
5249 result
:= StrEquCI1251(TEST_MAP_NAME
, g_ExtractFileName(gMapInfo
.Map
));
5252 procedure g_Game_DeleteTestMap();
5255 //MapName: AnsiString;
5263 a
:= Pos('.wad:\', toLowerCase1251(gMapToDelete
));
5264 if (a
= 0) then a
:= Pos('.wad:/', toLowerCase1251(gMapToDelete
));
5265 if (a
= 0) then exit
;
5267 // Âûäåëÿåì èìÿ wad-ôàéëà è èìÿ êàðòû
5268 WadName
:= Copy(gMapToDelete
, 1, a
+3);
5269 Delete(gMapToDelete
, 1, a
+5);
5270 gMapToDelete
:= UpperCase(gMapToDelete
);
5272 //CopyMemory(@MapName[0], @gMapToDelete[1], Min(16, Length(gMapToDelete)));
5275 // Èìÿ êàðòû íå ñòàíäàðòíîå òåñòîâîå:
5276 if MapName <> TEST_MAP_NAME then
5279 if not gTempDelete then
5281 time := g_GetFileTime(WadName);
5282 WAD := TWADFile.Create();
5285 if not WAD.ReadFile(WadName) then
5286 begin // Íåò òàêîãî WAD-ôàéëà
5291 // Ñîñòàâëÿåì ñïèñîê êàðò è èùåì íóæíóþ:
5293 MapList := WAD.GetResourcesList('');
5295 if MapList <> nil then
5296 for a := 0 to High(MapList) do
5297 if MapList[a] = MapName then
5299 // Óäàëÿåì è ñîõðàíÿåì:
5300 WAD.RemoveResource('', MapName);
5301 WAD.SaveTo(WadName);
5306 g_SetFileTime(WadName, time);
5309 if gTempDelete
then DeleteFile(WadName
);
5312 procedure GameCVars(P
: SSArray
);
5315 stat
: TPlayerStatArray
;
5320 cmd
:= LowerCase(P
[0]);
5321 if (cmd
= 'g_friendlyfire') and not g_Game_IsClient
then
5323 with gGameSettings
do
5325 if (Length(P
) > 1) and
5326 ((P
[1] = '1') or (P
[1] = '0')) then
5328 if (P
[1][1] = '1') then
5329 Options
:= Options
or GAME_OPTION_TEAMDAMAGE
5331 Options
:= Options
and (not GAME_OPTION_TEAMDAMAGE
);
5334 if (LongBool(Options
and GAME_OPTION_TEAMDAMAGE
)) then
5335 g_Console_Add(_lc
[I_MSG_FRIENDLY_FIRE_ON
])
5337 g_Console_Add(_lc
[I_MSG_FRIENDLY_FIRE_OFF
]);
5339 if g_Game_IsNet
then MH_SEND_GameSettings
;
5342 else if (cmd
= 'g_weaponstay') and not g_Game_IsClient
then
5344 with gGameSettings
do
5346 if (Length(P
) > 1) and
5347 ((P
[1] = '1') or (P
[1] = '0')) then
5349 if (P
[1][1] = '1') then
5350 Options
:= Options
or GAME_OPTION_WEAPONSTAY
5352 Options
:= Options
and (not GAME_OPTION_WEAPONSTAY
);
5355 if (LongBool(Options
and GAME_OPTION_WEAPONSTAY
)) then
5356 g_Console_Add(_lc
[I_MSG_WEAPONSTAY_ON
])
5358 g_Console_Add(_lc
[I_MSG_WEAPONSTAY_OFF
]);
5360 if g_Game_IsNet
then MH_SEND_GameSettings
;
5363 else if cmd
= 'g_gamemode' then
5365 a
:= g_Game_TextToMode(P
[1]);
5366 if a
= GM_SINGLE
then a
:= GM_COOP
;
5367 if (Length(P
) > 1) and (a
<> GM_NONE
) and (not g_Game_IsClient
) then
5369 gSwitchGameMode
:= a
;
5370 if (gGameOn
and (gGameSettings
.GameMode
= GM_SINGLE
)) or
5371 (gState
= STATE_INTERSINGLE
) then
5372 gSwitchGameMode
:= GM_SINGLE
;
5374 gGameSettings
.GameMode
:= gSwitchGameMode
;
5376 if gSwitchGameMode
= gGameSettings
.GameMode
then
5377 g_Console_Add(Format(_lc
[I_MSG_GAMEMODE_CURRENT
],
5378 [g_Game_ModeToText(gGameSettings
.GameMode
)]))
5380 g_Console_Add(Format(_lc
[I_MSG_GAMEMODE_CHANGE
],
5381 [g_Game_ModeToText(gGameSettings
.GameMode
),
5382 g_Game_ModeToText(gSwitchGameMode
)]));
5384 else if (cmd
= 'g_allow_exit') and not g_Game_IsClient
then
5386 with gGameSettings
do
5388 if (Length(P
) > 1) and
5389 ((P
[1] = '1') or (P
[1] = '0')) then
5391 if (P
[1][1] = '1') then
5392 Options
:= Options
or GAME_OPTION_ALLOWEXIT
5394 Options
:= Options
and (not GAME_OPTION_ALLOWEXIT
);
5397 if (LongBool(Options
and GAME_OPTION_ALLOWEXIT
)) then
5398 g_Console_Add(_lc
[I_MSG_ALLOWEXIT_ON
])
5400 g_Console_Add(_lc
[I_MSG_ALLOWEXIT_OFF
]);
5401 g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
5403 if g_Game_IsNet
then MH_SEND_GameSettings
;
5406 else if (cmd
= 'g_allow_monsters') and not g_Game_IsClient
then
5408 with gGameSettings
do
5410 if (Length(P
) > 1) and
5411 ((P
[1] = '1') or (P
[1] = '0')) then
5413 if (P
[1][1] = '1') then
5414 Options
:= Options
or GAME_OPTION_MONSTERS
5416 Options
:= Options
and (not GAME_OPTION_MONSTERS
);
5419 if (LongBool(Options
and GAME_OPTION_MONSTERS
)) then
5420 g_Console_Add(_lc
[I_MSG_ALLOWMON_ON
])
5422 g_Console_Add(_lc
[I_MSG_ALLOWMON_OFF
]);
5423 g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
5425 if g_Game_IsNet
then MH_SEND_GameSettings
;
5428 else if (cmd
= 'g_bot_vsplayers') and not g_Game_IsClient
then
5430 with gGameSettings
do
5432 if (Length(P
) > 1) and
5433 ((P
[1] = '1') or (P
[1] = '0')) then
5435 if (P
[1][1] = '1') then
5436 Options
:= Options
or GAME_OPTION_BOTVSPLAYER
5438 Options
:= Options
and (not GAME_OPTION_BOTVSPLAYER
);
5441 if (LongBool(Options
and GAME_OPTION_BOTVSPLAYER
)) then
5442 g_Console_Add(_lc
[I_MSG_BOTSVSPLAYERS_ON
])
5444 g_Console_Add(_lc
[I_MSG_BOTSVSPLAYERS_OFF
]);
5446 if g_Game_IsNet
then MH_SEND_GameSettings
;
5449 else if (cmd
= 'g_bot_vsmonsters') and not g_Game_IsClient
then
5451 with gGameSettings
do
5453 if (Length(P
) > 1) and
5454 ((P
[1] = '1') or (P
[1] = '0')) then
5456 if (P
[1][1] = '1') then
5457 Options
:= Options
or GAME_OPTION_BOTVSMONSTER
5459 Options
:= Options
and (not GAME_OPTION_BOTVSMONSTER
);
5462 if (LongBool(Options
and GAME_OPTION_BOTVSMONSTER
)) then
5463 g_Console_Add(_lc
[I_MSG_BOTSVSMONSTERS_ON
])
5465 g_Console_Add(_lc
[I_MSG_BOTSVSMONSTERS_OFF
]);
5467 if g_Game_IsNet
then MH_SEND_GameSettings
;
5470 else if (cmd
= 'g_warmuptime') and not g_Game_IsClient
then
5472 if Length(P
) > 1 then
5474 if StrToIntDef(P
[1], gGameSettings
.WarmupTime
) = 0 then
5475 gGameSettings
.WarmupTime
:= 30
5477 gGameSettings
.WarmupTime
:= StrToIntDef(P
[1], gGameSettings
.WarmupTime
);
5480 g_Console_Add(Format(_lc
[I_MSG_WARMUP
],
5481 [gGameSettings
.WarmupTime
]));
5482 g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
5484 else if cmd
= 'net_interp' then
5486 if (Length(P
) > 1) then
5487 NetInterpLevel
:= StrToIntDef(P
[1], NetInterpLevel
);
5488 g_Console_Add('net_interp = ' + IntToStr(NetInterpLevel
));
5489 s
:= e_GetWriteableDir(ConfigDirs
);
5492 config
:= TConfig
.CreateFile(s
+ '/' + CONFIG_FILENAME
);
5493 config
.WriteInt('Client', 'InterpolationSteps', NetInterpLevel
);
5494 config
.SaveFile(s
+ '/' + CONFIG_FILENAME
);
5498 else if cmd
= 'net_forceplayerupdate' then
5500 if (Length(P
) > 1) and ((P
[1] = '1') or (P
[1] = '0')) then
5501 NetForcePlayerUpdate
:= (P
[1][1] = '1');
5503 if NetForcePlayerUpdate
then
5504 g_Console_Add('net_forceplayerupdate = 1')
5506 g_Console_Add('net_forceplayerupdate = 0');
5508 s
:= e_GetWriteableDir(ConfigDirs
);
5511 config
:= TConfig
.CreateFile(s
+ '/' + CONFIG_FILENAME
);
5512 config
.WriteBool('Client', 'ForcePlayerUpdate', NetForcePlayerUpdate
);
5513 config
.SaveFile(s
+ '/' + CONFIG_FILENAME
);
5517 else if cmd
= 'net_predictself' then
5519 if (Length(P
) > 1) and
5520 ((P
[1] = '1') or (P
[1] = '0')) then
5521 NetPredictSelf
:= (P
[1][1] = '1');
5523 if NetPredictSelf
then
5524 g_Console_Add('net_predictself = 1')
5526 g_Console_Add('net_predictself = 0');
5528 s
:= e_GetWriteableDir(ConfigDirs
);
5531 config
:= TConfig
.CreateFile(s
+ '/' + CONFIG_FILENAME
);
5532 config
.WriteBool('Client', 'PredictSelf', NetPredictSelf
);
5533 config
.SaveFile(s
+ '/' + CONFIG_FILENAME
);
5537 else if cmd
= 'sv_name' then
5539 if (Length(P
) > 1) and (Length(P
[1]) > 0) then
5541 NetServerName
:= P
[1];
5542 if Length(NetServerName
) > 64 then
5543 SetLength(NetServerName
, 64);
5544 g_Net_Slist_ServerRenamed();
5547 g_Console_Add(cmd
+ ' = "' + NetServerName
+ '"');
5549 else if cmd
= 'sv_passwd' then
5551 if (Length(P
) > 1) and (Length(P
[1]) > 0) then
5553 NetPassword
:= P
[1];
5554 if Length(NetPassword
) > 24 then
5555 SetLength(NetPassword
, 24);
5556 g_Net_Slist_ServerRenamed();
5559 g_Console_Add(cmd
+ ' = "' + AnsiLowerCase(NetPassword
) + '"');
5561 else if cmd
= 'sv_maxplrs' then
5563 if (Length(P
) > 1) then
5565 NetMaxClients
:= Min(Max(StrToIntDef(P
[1], NetMaxClients
), 1), NET_MAXCLIENTS
);
5566 if g_Game_IsServer
and g_Game_IsNet
then
5569 for a
:= 0 to High(NetClients
) do
5571 if NetClients
[a
].Used
then
5574 if b
> NetMaxClients
then
5576 s
:= g_Player_Get(NetClients
[a
].Player
).Name
;
5577 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_FULL
);
5578 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
5579 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
5583 g_Net_Slist_ServerRenamed();
5587 g_Console_Add(cmd
+ ' = ' + IntToStr(NetMaxClients
));
5589 else if cmd
= 'sv_public' then
5591 if (Length(P
) > 1) then
5593 NetUseMaster
:= StrToIntDef(P
[1], Byte(NetUseMaster
)) > 0;
5594 if NetUseMaster
then g_Net_Slist_Public() else g_Net_Slist_Private();
5597 g_Console_Add(cmd
+ ' = ' + IntToStr(Byte(NetUseMaster
)));
5599 else if cmd
= 'sv_intertime' then
5601 if (Length(P
) > 1) then
5602 gDefInterTime
:= Min(Max(StrToIntDef(P
[1], gDefInterTime
), -1), 120);
5604 g_Console_Add(cmd
+ ' = ' + IntToStr(gDefInterTime
));
5606 else if cmd
= 'p1_name' then
5608 if (Length(P
) > 1) and gGameOn
then
5610 if g_Game_IsClient
then
5612 gPlayer1Settings
.Name
:= b_Text_Unformat(P
[1]);
5613 MC_SEND_PlayerSettings
;
5616 if gPlayer1
<> nil then
5618 gPlayer1
.Name
:= b_Text_Unformat(P
[1]);
5619 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer1
.UID
);
5622 gPlayer1Settings
.Name
:= b_Text_Unformat(P
[1]);
5625 else if cmd
= 'p2_name' then
5627 if (Length(P
) > 1) and gGameOn
then
5629 if g_Game_IsClient
then
5631 gPlayer2Settings
.Name
:= b_Text_Unformat(P
[1]);
5632 MC_SEND_PlayerSettings
;
5635 if gPlayer2
<> nil then
5637 gPlayer2
.Name
:= b_Text_Unformat(P
[1]);
5638 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer2
.UID
);
5641 gPlayer2Settings
.Name
:= b_Text_Unformat(P
[1]);
5644 else if cmd
= 'p1_color' then
5646 if Length(P
) > 3 then
5647 if g_Game_IsClient
then
5649 gPlayer1Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
5650 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
5651 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
5652 MC_SEND_PlayerSettings
;
5655 if gPlayer1
<> nil then
5657 gPlayer1
.Model
.SetColor(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
5658 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
5659 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
5660 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer1
.UID
);
5663 gPlayer1Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
5664 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
5665 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
5667 else if (cmd
= 'p2_color') and not g_Game_IsNet
then
5669 if Length(P
) > 3 then
5670 if g_Game_IsClient
then
5672 gPlayer2Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
5673 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
5674 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
5675 MC_SEND_PlayerSettings
;
5678 if gPlayer2
<> nil then
5680 gPlayer2
.Model
.SetColor(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
5681 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
5682 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
5683 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer2
.UID
);
5686 gPlayer2Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
5687 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
5688 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
5690 else if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
5692 if cmd
= 'r_showscore' then
5694 if (Length(P
) > 1) and
5695 ((P
[1] = '1') or (P
[1] = '0')) then
5696 gShowGoals
:= (P
[1][1] = '1');
5699 g_Console_Add(_lc
[I_MSG_SCORE_ON
])
5701 g_Console_Add(_lc
[I_MSG_SCORE_OFF
]);
5703 else if cmd
= 'r_showstat' then
5705 if (Length(P
) > 1) and
5706 ((P
[1] = '1') or (P
[1] = '0')) then
5707 gShowStat
:= (P
[1][1] = '1');
5710 g_Console_Add(_lc
[I_MSG_STATS_ON
])
5712 g_Console_Add(_lc
[I_MSG_STATS_OFF
]);
5714 else if cmd
= 'r_showkillmsg' then
5716 if (Length(P
) > 1) and
5717 ((P
[1] = '1') or (P
[1] = '0')) then
5718 gShowKillMsg
:= (P
[1][1] = '1');
5720 if gShowKillMsg
then
5721 g_Console_Add(_lc
[I_MSG_KILL_MSGS_ON
])
5723 g_Console_Add(_lc
[I_MSG_KILL_MSGS_OFF
]);
5725 else if cmd
= 'r_showlives' then
5727 if (Length(P
) > 1) and
5728 ((P
[1] = '1') or (P
[1] = '0')) then
5729 gShowLives
:= (P
[1][1] = '1');
5732 g_Console_Add(_lc
[I_MSG_LIVES_ON
])
5734 g_Console_Add(_lc
[I_MSG_LIVES_OFF
]);
5736 else if cmd
= 'r_showspect' then
5738 if (Length(P
) > 1) and
5739 ((P
[1] = '1') or (P
[1] = '0')) then
5740 gSpectHUD
:= (P
[1][1] = '1');
5743 g_Console_Add(_lc
[I_MSG_SPECT_HUD_ON
])
5745 g_Console_Add(_lc
[I_MSG_SPECT_HUD_OFF
]);
5747 else if cmd
= 'r_showping' then
5749 if (Length(P
) > 1) and
5750 ((P
[1] = '1') or (P
[1] = '0')) then
5751 gShowPing
:= (P
[1][1] = '1');
5754 g_Console_Add(_lc
[I_MSG_PING_ON
])
5756 g_Console_Add(_lc
[I_MSG_PING_OFF
]);
5758 else if (cmd
= 'g_scorelimit') and not g_Game_IsClient
then
5760 if Length(P
) > 1 then
5762 if StrToIntDef(P
[1], gGameSettings
.GoalLimit
) = 0 then
5763 gGameSettings
.GoalLimit
:= 0
5768 if gGameSettings
.GameMode
= GM_DM
then
5770 stat
:= g_Player_GetStats();
5772 for a
:= 0 to High(stat
) do
5773 if stat
[a
].Frags
> b
then
5777 b
:= Max(gTeamStat
[TEAM_RED
].Goals
, gTeamStat
[TEAM_BLUE
].Goals
);
5779 gGameSettings
.GoalLimit
:= Max(StrToIntDef(P
[1], gGameSettings
.GoalLimit
), b
);
5782 if g_Game_IsNet
then MH_SEND_GameSettings
;
5785 g_Console_Add(Format(_lc
[I_MSG_SCORE_LIMIT
], [gGameSettings
.GoalLimit
]));
5787 else if (cmd
= 'g_timelimit') and not g_Game_IsClient
then
5789 if (Length(P
) > 1) and (StrToIntDef(P
[1], -1) >= 0) then
5790 gGameSettings
.TimeLimit
:= StrToIntDef(P
[1], -1);
5792 g_Console_Add(Format(_lc
[I_MSG_TIME_LIMIT
],
5793 [gGameSettings
.TimeLimit
div 3600,
5794 (gGameSettings
.TimeLimit
div 60) mod 60,
5795 gGameSettings
.TimeLimit
mod 60]));
5796 if g_Game_IsNet
then MH_SEND_GameSettings
;
5798 else if (cmd
= 'g_maxlives') and not g_Game_IsClient
then
5800 if Length(P
) > 1 then
5802 if StrToIntDef(P
[1], gGameSettings
.MaxLives
) = 0 then
5803 gGameSettings
.MaxLives
:= 0
5807 stat
:= g_Player_GetStats();
5809 for a
:= 0 to High(stat
) do
5810 if stat
[a
].Lives
> b
then
5812 gGameSettings
.MaxLives
:=
5813 Max(StrToIntDef(P
[1], gGameSettings
.MaxLives
), b
);
5817 g_Console_Add(Format(_lc
[I_MSG_LIVES
],
5818 [gGameSettings
.MaxLives
]));
5819 if g_Game_IsNet
then MH_SEND_GameSettings
;
5824 procedure PrintHeapStats();
5828 hs
:= GetFPCHeapStatus();
5829 e_LogWriteLn ('v===== heap status =====v');
5830 e_LogWriteFln('max heap size = %d k', [hs
.MaxHeapSize
div 1024]);
5831 e_LogWriteFln('max heap used = %d k', [hs
.MaxHeapUsed
div 1024]);
5832 e_LogWriteFln('cur heap size = %d k', [hs
.CurrHeapSize
div 1024]);
5833 e_LogWriteFln('cur heap used = %d k', [hs
.CurrHeapUsed
div 1024]);
5834 e_LogWriteFln('cur heap free = %d k', [hs
.CurrHeapFree
div 1024]);
5835 e_LogWriteLn ('^=======================^');
5838 procedure DebugCommands(P
: SSArray
);
5845 // Êîìàíäû îòëàäî÷íîãî ðåæèìà:
5846 if {gDebugMode}conIsCheatsEnabled
then
5848 cmd
:= LowerCase(P
[0]);
5849 if cmd
= 'd_window' then
5851 g_Console_Add(Format('gScreenWidth = %d, gScreenHeight = %d', [gScreenWidth
, gScreenHeight
]));
5852 g_Console_Add(Format('gWinSizeX = %d, gWinSizeY = %d', [gWinSizeX
, gWinSizeY
]));
5853 g_Console_Add(Format('Frame X = %d, Y = %d, Caption Y = %d', [gWinFrameX
, gWinFrameY
, gWinCaption
]));
5855 else if cmd
= 'd_sounds' then
5857 if (Length(P
) > 1) and
5858 ((P
[1] = '1') or (P
[1] = '0')) then
5859 g_Debug_Sounds
:= (P
[1][1] = '1');
5861 g_Console_Add(Format('d_sounds is %d', [Byte(g_Debug_Sounds
)]));
5863 else if cmd
= 'd_frames' then
5865 if (Length(P
) > 1) and
5866 ((P
[1] = '1') or (P
[1] = '0')) then
5867 g_Debug_Frames
:= (P
[1][1] = '1');
5869 g_Console_Add(Format('d_frames is %d', [Byte(g_Debug_Frames
)]));
5871 else if cmd
= 'd_winmsg' then
5873 if (Length(P
) > 1) and
5874 ((P
[1] = '1') or (P
[1] = '0')) then
5875 g_Debug_WinMsgs
:= (P
[1][1] = '1');
5877 g_Console_Add(Format('d_winmsg is %d', [Byte(g_Debug_WinMsgs
)]));
5879 else if (cmd
= 'd_monoff') and not g_Game_IsNet
then
5881 if (Length(P
) > 1) and
5882 ((P
[1] = '1') or (P
[1] = '0')) then
5883 g_Debug_MonsterOff
:= (P
[1][1] = '1');
5885 g_Console_Add(Format('d_monoff is %d', [Byte(g_debug_MonsterOff
)]));
5887 else if (cmd
= 'd_botoff') and not g_Game_IsNet
then
5889 if Length(P
) > 1 then
5891 '0': g_debug_BotAIOff
:= 0;
5892 '1': g_debug_BotAIOff
:= 1;
5893 '2': g_debug_BotAIOff
:= 2;
5894 '3': g_debug_BotAIOff
:= 3;
5897 g_Console_Add(Format('d_botoff is %d', [g_debug_BotAIOff
]));
5899 else if cmd
= 'd_monster' then
5901 if gGameOn
and (gPlayer1
<> nil) and (gPlayer1
.alive
) and (not g_Game_IsNet
) then
5902 if Length(P
) < 2 then
5904 g_Console_Add(cmd
+ ' [ID | Name] [behaviour]');
5905 g_Console_Add('ID | Name');
5906 for b
:= MONSTER_DEMON
to MONSTER_MAN
do
5907 g_Console_Add(Format('%2d | %s', [b
, g_Mons_NameByTypeId(b
)]));
5908 conwriteln('behav. num'#10'normal 0'#10'killer 1'#10'maniac 2'#10'insane 3'#10'cannibal 4'#10'good 5');
5911 a
:= StrToIntDef(P
[1], 0);
5912 if (a
< MONSTER_DEMON
) or (a
> MONSTER_MAN
) then
5913 a
:= g_Mons_TypeIdByName(P
[1]);
5915 if (a
< MONSTER_DEMON
) or (a
> MONSTER_MAN
) then
5916 g_Console_Add(Format(_lc
[I_MSG_NO_MONSTER
], [P
[1]]))
5919 with gPlayer1
.Obj
do
5921 mon
:= g_Monsters_Create(a
,
5922 X
+ Rect
.X
+ (Rect
.Width
div 2),
5923 Y
+ Rect
.Y
+ Rect
.Height
,
5924 gPlayer1
.Direction
, True);
5926 if (Length(P
) > 2) and (mon
<> nil) then
5928 if (CompareText(P
[2], 'normal') = 0) then mon
.MonsterBehaviour
:= BH_NORMAL
5929 else if (CompareText(P
[2], 'killer') = 0) then mon
.MonsterBehaviour
:= BH_KILLER
5930 else if (CompareText(P
[2], 'maniac') = 0) then mon
.MonsterBehaviour
:= BH_MANIAC
5931 else if (CompareText(P
[2], 'insane') = 0) then mon
.MonsterBehaviour
:= BH_INSANE
5932 else if (CompareText(P
[2], 'cannibal') = 0) then mon
.MonsterBehaviour
:= BH_CANNIBAL
5933 else if (CompareText(P
[2], 'good') = 0) then mon
.MonsterBehaviour
:= BH_GOOD
5934 else if (CompareText(P
[2], 'friend') = 0) then mon
.MonsterBehaviour
:= BH_GOOD
5935 else if (CompareText(P
[2], 'friendly') = 0) then mon
.MonsterBehaviour
:= BH_GOOD
5936 else mon
.MonsterBehaviour
:= Min(Max(StrToIntDef(P
[2], BH_NORMAL
), BH_NORMAL
), BH_GOOD
);
5941 else if (cmd
= 'd_health') then
5943 if (Length(P
) > 1) and
5944 ((P
[1] = '1') or (P
[1] = '0')) then
5945 g_debug_HealthBar
:= (P
[1][1] = '1');
5947 g_Console_Add(Format('d_health is %d', [Byte(g_debug_HealthBar
)]));
5949 else if (cmd
= 'd_player') then
5951 if (Length(P
) > 1) and
5952 ((P
[1] = '1') or (P
[1] = '0')) then
5953 g_debug_Player
:= (P
[1][1] = '1');
5955 g_Console_Add(Format(cmd
+ ' is %d', [Byte(g_Debug_Player
)]));
5957 else if (cmd
= 'd_mem') then
5963 g_Console_Add(_lc
[I_MSG_NOT_DEBUG
]);
5967 procedure GameCheats(P
: SSArray
);
5973 if (not gGameOn
) or (not conIsCheatsEnabled
) then
5975 g_Console_Add('not available');
5981 g_Console_Add('where is the player?!');
5984 cmd
:= LowerCase(P
[0]);
5988 plr
.GodMode
:= not plr
.GodMode
;
5989 if plr
.GodMode
then g_Console_Add('player is godlike now') else g_Console_Add('player is mortal now');
5992 // give <health|exit|weapons|air|suit|jetpack|berserk|all>
5993 if cmd
= 'give' then
5995 if length(P
) < 2 then begin g_Console_Add('give what?!'); exit
; end;
5996 for f
:= 1 to High(P
) do
5998 cmd
:= LowerCase(P
[f
]);
5999 if cmd
= 'health' then begin plr
.RestoreHealthArmor(); g_Console_Add('player feels himself better'); continue
; end;
6000 if (cmd
= 'all') {or (cmd = 'weapons')} then begin plr
.AllRulez(False); g_Console_Add('player got the gifts'); continue
; end;
6001 if cmd
= 'exit' then
6003 if gTriggers
<> nil then
6005 for a
:= 0 to High(gTriggers
) do
6007 if gTriggers
[a
].TriggerType
= TRIGGER_EXIT
then
6009 g_Console_Add('player left the map');
6010 gExitByTrigger
:= True;
6011 //g_Game_ExitLevel(gTriggers[a].Data.MapName);
6012 g_Game_ExitLevel(gTriggers
[a
].tgcMap
);
6020 if cmd
= 'air' then begin plr
.GiveItem(ITEM_OXYGEN
); g_Console_Add('player got some air'); continue
; end;
6021 if cmd
= 'jetpack' then begin plr
.GiveItem(ITEM_JETPACK
); g_Console_Add('player got a jetpack'); continue
; end;
6022 if cmd
= 'suit' then begin plr
.GiveItem(ITEM_SUIT
); g_Console_Add('player got an envirosuit'); continue
; end;
6023 if cmd
= 'berserk' then begin plr
.GiveItem(ITEM_MEDKIT_BLACK
); g_Console_Add('player got a berserk pack'); continue
; end;
6024 if cmd
= 'backpack' then begin plr
.GiveItem(ITEM_AMMO_BACKPACK
); g_Console_Add('player got a backpack'); continue
; end;
6026 if cmd
= 'helmet' then begin plr
.GiveItem(ITEM_HELMET
); g_Console_Add('player got a helmet'); continue
; end;
6027 if cmd
= 'bottle' then begin plr
.GiveItem(ITEM_BOTTLE
); g_Console_Add('player got a bottle of health'); continue
; end;
6029 if cmd
= 'stimpack' then begin plr
.GiveItem(ITEM_MEDKIT_SMALL
); g_Console_Add('player got a stimpack'); continue
; end;
6030 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;
6032 if cmd
= 'greenarmor' then begin plr
.GiveItem(ITEM_ARMOR_GREEN
); g_Console_Add('player got a security armor'); continue
; end;
6033 if cmd
= 'bluearmor' then begin plr
.GiveItem(ITEM_ARMOR_BLUE
); g_Console_Add('player got a combat armor'); continue
; end;
6035 if (cmd
= 'megasphere') or (cmd
= 'mega') then begin plr
.GiveItem(ITEM_SPHERE_BLUE
); g_Console_Add('player got a megasphere'); continue
; end;
6036 if (cmd
= 'soulsphere') or (cmd
= 'soul')then begin plr
.GiveItem(ITEM_SPHERE_WHITE
); g_Console_Add('player got a soul sphere'); continue
; end;
6038 if (cmd
= 'invul') or (cmd
= 'invulnerability') then begin plr
.GiveItem(ITEM_INVUL
); g_Console_Add('player got invulnerability'); continue
; end;
6039 if (cmd
= 'invis') or (cmd
= 'invisibility') then begin plr
.GiveItem(ITEM_INVIS
); g_Console_Add('player got invisibility'); continue
; end;
6041 if cmd
= 'redkey' then begin plr
.GiveItem(ITEM_KEY_RED
); g_Console_Add('player got the red key'); continue
; end;
6042 if cmd
= 'greenkey' then begin plr
.GiveItem(ITEM_KEY_GREEN
); g_Console_Add('player got the green key'); continue
; end;
6043 if cmd
= 'bluekey' then begin plr
.GiveItem(ITEM_KEY_BLUE
); g_Console_Add('player got the blue key'); continue
; end;
6045 if (cmd
= 'shotgun') or (cmd
= 'sg') then begin plr
.GiveItem(ITEM_WEAPON_SHOTGUN1
); g_Console_Add('player got a shotgun'); continue
; end;
6046 if (cmd
= 'supershotgun') or (cmd
= 'ssg') then begin plr
.GiveItem(ITEM_WEAPON_SHOTGUN2
); g_Console_Add('player got a supershotgun'); continue
; end;
6047 if cmd
= 'chaingun' then begin plr
.GiveItem(ITEM_WEAPON_CHAINGUN
); g_Console_Add('player got a chaingun'); continue
; end;
6048 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;
6049 if cmd
= 'plasmagun' then begin plr
.GiveItem(ITEM_WEAPON_PLASMA
); g_Console_Add('player got a plasma gun'); continue
; end;
6050 if cmd
= 'bfg' then begin plr
.GiveItem(ITEM_WEAPON_BFG
); g_Console_Add('player got a BFG-9000'); continue
; end;
6052 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;
6053 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;
6054 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;
6055 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;
6056 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;
6057 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;
6059 if cmd
= 'superchaingun' then begin plr
.GiveItem(ITEM_WEAPON_SUPERPULEMET
); g_Console_Add('player got a superchaingun'); continue
; end;
6060 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;
6062 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;
6063 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;
6065 if cmd
= 'chainsaw' then begin plr
.GiveItem(ITEM_WEAPON_SAW
); g_Console_Add('player got a chainsaw'); continue
; end;
6067 if cmd
= 'ammo' then
6069 plr
.GiveItem(ITEM_AMMO_SHELLS_BOX
);
6070 plr
.GiveItem(ITEM_AMMO_BULLETS_BOX
);
6071 plr
.GiveItem(ITEM_AMMO_CELL_BIG
);
6072 plr
.GiveItem(ITEM_AMMO_ROCKET_BOX
);
6073 plr
.GiveItem(ITEM_AMMO_FUELCAN
);
6074 g_Console_Add('player got some ammo');
6078 if cmd
= 'clip' then begin plr
.GiveItem(ITEM_AMMO_BULLETS
); g_Console_Add('player got some bullets'); continue
; end;
6079 if cmd
= 'bullets' then begin plr
.GiveItem(ITEM_AMMO_BULLETS_BOX
); g_Console_Add('player got a box of bullets'); continue
; end;
6081 if cmd
= 'shells' then begin plr
.GiveItem(ITEM_AMMO_SHELLS
); g_Console_Add('player got some shells'); continue
; end;
6082 if cmd
= 'shellbox' then begin plr
.GiveItem(ITEM_AMMO_SHELLS_BOX
); g_Console_Add('player got a box of shells'); continue
; end;
6084 if cmd
= 'cells' then begin plr
.GiveItem(ITEM_AMMO_CELL
); g_Console_Add('player got some cells'); continue
; end;
6085 if cmd
= 'battery' then begin plr
.GiveItem(ITEM_AMMO_CELL_BIG
); g_Console_Add('player got cell battery'); continue
; end;
6087 if cmd
= 'rocket' then begin plr
.GiveItem(ITEM_AMMO_ROCKET
); g_Console_Add('player got a rocket'); continue
; end;
6088 if cmd
= 'rocketbox' then begin plr
.GiveItem(ITEM_AMMO_ROCKET_BOX
); g_Console_Add('player got some rockets'); continue
; end;
6090 if (cmd
= 'fuel') or (cmd
= 'fuelcan') then begin plr
.GiveItem(ITEM_AMMO_FUELCAN
); g_Console_Add('player got fuel canister'); continue
; end;
6092 if cmd
= 'weapons' then
6094 plr
.GiveItem(ITEM_WEAPON_SHOTGUN1
);
6095 plr
.GiveItem(ITEM_WEAPON_SHOTGUN2
);
6096 plr
.GiveItem(ITEM_WEAPON_CHAINGUN
);
6097 plr
.GiveItem(ITEM_WEAPON_ROCKETLAUNCHER
);
6098 plr
.GiveItem(ITEM_WEAPON_PLASMA
);
6099 plr
.GiveItem(ITEM_WEAPON_BFG
);
6100 g_Console_Add('player got weapons');
6104 if cmd
= 'keys' then
6106 plr
.GiveItem(ITEM_KEY_RED
);
6107 plr
.GiveItem(ITEM_KEY_GREEN
);
6108 plr
.GiveItem(ITEM_KEY_BLUE
);
6109 g_Console_Add('player got all keys');
6113 g_Console_Add('i don''t know how to give '''+cmd
+'''!');
6118 if cmd
= 'open' then
6120 g_Console_Add('player activated sesame');
6121 g_Triggers_OpenAll();
6128 if gFly
then g_Console_Add('player feels himself lighter') else g_Console_Add('player lost his wings');
6132 if cmd
= 'noclip' then
6135 g_Console_Add('wall hardeness adjusted');
6139 if cmd
= 'notarget' then
6141 plr
.NoTarget
:= not plr
.NoTarget
;
6142 if plr
.NoTarget
then g_Console_Add('player hides in shadows') else g_Console_Add('player is brave again');
6146 if cmd
= 'noreload' then
6148 plr
.NoReload
:= not plr
.NoReload
;
6149 if plr
.NoReload
then g_Console_Add('player is action hero now') else g_Console_Add('player is ordinary man now');
6153 if cmd
= 'speedy' then
6155 MAX_RUNVEL
:= 32-MAX_RUNVEL
;
6156 g_Console_Add('speed adjusted');
6160 if cmd
= 'jumpy' then
6162 VEL_JUMP
:= 30-VEL_JUMP
;
6163 g_Console_Add('jump height adjusted');
6167 if cmd
= 'automap' then
6169 gShowMap
:= not gShowMap
;
6170 if gShowMap
then g_Console_Add('player gains second sight') else g_Console_Add('player lost second sight');
6174 if cmd
= 'aimline' then
6176 gAimLine
:= not gAimLine
;
6177 if gAimLine
then g_Console_Add('player gains laser sight') else g_Console_Add('player lost laser sight');
6182 procedure GameCommands(P
: SSArray
);
6188 pl
: pTNetClient
= nil;
6196 cmd
:= LowerCase(P
[0]);
6198 if (cmd
= 'quit') or
6205 else if cmd
= 'pause' then
6207 if (g_ActiveWindow
= nil) then
6208 g_Game_Pause(not gPauseMain
);
6210 else if cmd
= 'endgame' then
6211 gExit
:= EXIT_SIMPLE
6212 else if cmd
= 'restart' then
6214 if gGameOn
or (gState
in [STATE_INTERSINGLE
, STATE_INTERCUSTOM
]) then
6216 if g_Game_IsClient
then
6218 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6223 g_Console_Add(_lc
[I_MSG_NOT_GAME
]);
6225 else if cmd
= 'kick' then
6227 if g_Game_IsServer
then
6229 if Length(P
) < 2 then
6231 g_Console_Add('kick <name>');
6236 g_Console_Add('kick <name>');
6240 if g_Game_IsNet
then
6241 pl
:= g_Net_Client_ByName(P
[1]);
6244 s
:= g_Net_ClientName_ByID(pl
^.ID
);
6245 enet_peer_disconnect(pl
^.Peer
, NET_DISC_KICK
);
6246 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
6247 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
6248 g_Net_Slist_ServerPlayerLeaves();
6249 end else if gPlayers
<> nil then
6250 for a
:= Low(gPlayers
) to High(gPlayers
) do
6251 if gPlayers
[a
] <> nil then
6252 if Copy(LowerCase(gPlayers
[a
].Name
), 1, Length(P
[1])) = LowerCase(P
[1]) then
6254 // Íå îòêëþ÷àòü îñíîâíûõ èãðîêîâ â ñèíãëå
6255 if not(gPlayers
[a
] is TBot
) and (gGameSettings
.GameType
= GT_SINGLE
) then
6257 gPlayers
[a
].Lives
:= 0;
6258 gPlayers
[a
].Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
6259 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [gPlayers
[a
].Name
]), True);
6260 g_Player_Remove(gPlayers
[a
].UID
);
6261 g_Net_Slist_ServerPlayerLeaves();
6262 // Åñëè íå ïåðåìåøàòü, ïðè äîáàâëåíèè íîâûõ áîòîâ ïîÿâÿòñÿ ñòàðûå
6266 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6268 else if cmd
= 'kick_id' then
6270 if g_Game_IsServer
and g_Game_IsNet
then
6272 if Length(P
) < 2 then
6274 g_Console_Add('kick_id <client ID>');
6279 g_Console_Add('kick_id <client ID>');
6283 a
:= StrToIntDef(P
[1], 0);
6284 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
6286 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
6288 s
:= g_Net_ClientName_ByID(NetClients
[a
].ID
);
6289 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_KICK
);
6290 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
6291 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
6292 g_Net_Slist_ServerPlayerLeaves();
6296 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6298 else if cmd
= 'ban' then
6300 if g_Game_IsServer
and g_Game_IsNet
then
6302 if Length(P
) < 2 then
6304 g_Console_Add('ban <name>');
6309 g_Console_Add('ban <name>');
6313 pl
:= g_Net_Client_ByName(P
[1]);
6316 s
:= g_Net_ClientName_ByID(pl
^.ID
);
6317 g_Net_BanHost(pl
^.Peer
^.address
.host
, False);
6318 enet_peer_disconnect(pl
^.Peer
, NET_DISC_TEMPBAN
);
6319 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
6320 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
6321 g_Net_Slist_ServerPlayerLeaves();
6323 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
6325 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6327 else if cmd
= 'ban_id' then
6329 if g_Game_IsServer
and g_Game_IsNet
then
6331 if Length(P
) < 2 then
6333 g_Console_Add('ban_id <client ID>');
6338 g_Console_Add('ban_id <client ID>');
6342 a
:= StrToIntDef(P
[1], 0);
6343 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
6344 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
6346 s
:= g_Net_ClientName_ByID(NetClients
[a
].ID
);
6347 g_Net_BanHost(NetClients
[a
].Peer
^.address
.host
, False);
6348 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_TEMPBAN
);
6349 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
6350 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
6351 g_Net_Slist_ServerPlayerLeaves();
6354 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6356 else if cmd
= 'permban' then
6358 if g_Game_IsServer
and g_Game_IsNet
then
6360 if Length(P
) < 2 then
6362 g_Console_Add('permban <name>');
6367 g_Console_Add('permban <name>');
6371 pl
:= g_Net_Client_ByName(P
[1]);
6374 s
:= g_Net_ClientName_ByID(pl
^.ID
);
6375 g_Net_BanHost(pl
^.Peer
^.address
.host
);
6376 enet_peer_disconnect(pl
^.Peer
, NET_DISC_BAN
);
6377 g_Net_SaveBanList();
6378 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
6379 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
6380 g_Net_Slist_ServerPlayerLeaves();
6382 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
6384 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6386 else if cmd
= 'permban_id' then
6388 if g_Game_IsServer
and g_Game_IsNet
then
6390 if Length(P
) < 2 then
6392 g_Console_Add('permban_id <client ID>');
6397 g_Console_Add('permban_id <client ID>');
6401 a
:= StrToIntDef(P
[1], 0);
6402 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
6403 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
6405 s
:= g_Net_ClientName_ByID(NetClients
[a
].ID
);
6406 g_Net_BanHost(NetClients
[a
].Peer
^.address
.host
);
6407 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_BAN
);
6408 g_Net_SaveBanList();
6409 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
6410 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
6411 g_Net_Slist_ServerPlayerLeaves();
6414 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6416 else if cmd
= 'unban' then
6418 if g_Game_IsServer
and g_Game_IsNet
then
6420 if Length(P
) < 2 then
6422 g_Console_Add('unban <IP Address>');
6427 g_Console_Add('unban <IP Address>');
6431 if g_Net_UnbanHost(P
[1]) then
6433 g_Console_Add(Format(_lc
[I_MSG_UNBAN_OK
], [P
[1]]));
6434 g_Net_SaveBanList();
6436 g_Console_Add(Format(_lc
[I_MSG_UNBAN_FAIL
], [P
[1]]));
6438 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6440 else if cmd
= 'clientlist' then
6442 if g_Game_IsServer
and g_Game_IsNet
then
6445 if NetClients
<> nil then
6446 for a
:= Low(NetClients
) to High(NetClients
) do
6447 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
6449 plr
:= g_Player_Get(NetClients
[a
].Player
);
6450 if plr
= nil then continue
;
6452 g_Console_Add(Format('#%2d: %-15s | %s', [a
,
6453 IpToStr(NetClients
[a
].Peer
^.address
.host
), plr
.Name
]));
6456 g_Console_Add(_lc
[I_MSG_NOCLIENTS
]);
6458 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6460 else if cmd
= 'connect' then
6462 if (NetMode
= NET_NONE
) then
6464 if Length(P
) < 2 then
6466 g_Console_Add('connect <IP> [port] [password]');
6471 g_Console_Add('connect <IP> [port] [password]');
6475 if Length(P
) > 2 then
6476 prt
:= StrToIntDef(P
[2], 25666)
6480 if Length(P
) > 3 then
6485 g_Game_StartClient(P
[1], prt
, pw
);
6488 else if cmd
= 'disconnect' then
6490 if (NetMode
= NET_CLIENT
) then
6493 else if cmd
= 'reconnect' then
6495 if (NetMode
= NET_SERVER
) then
6498 if (NetMode
= NET_CLIENT
) then
6501 gExit
:= EXIT_SIMPLE
;
6505 //TODO: Use last successful password to reconnect, instead of ''
6506 g_Game_StartClient(NetClientIP
, NetClientPort
, '');
6508 else if (cmd
= 'addbot') or
6509 (cmd
= 'bot_add') then
6511 if Length(P
) > 2 then
6512 g_Bot_Add(TEAM_NONE
, StrToIntDef(P
[1], 2), StrToIntDef(P
[2], 100))
6513 else if Length(P
) > 1 then
6514 g_Bot_Add(TEAM_NONE
, StrToIntDef(P
[1], 2))
6516 g_Bot_Add(TEAM_NONE
, 2);
6518 else if cmd
= 'bot_addlist' then
6520 if Length(P
) > 1 then
6522 if Length(P
) = 2 then
6523 g_Bot_AddList(TEAM_NONE
, P
[1], StrToIntDef(P
[1], -1))
6524 else if Length(P
) = 3 then
6525 g_Bot_AddList(TEAM_NONE
, P
[1], StrToIntDef(P
[1], -1), StrToIntDef(P
[2], 100))
6527 g_Bot_AddList(IfThen(P
[2] = 'red', TEAM_RED
, TEAM_BLUE
), P
[1], StrToIntDef(P
[1], -1));
6530 else if cmd
= 'bot_removeall' then
6532 else if cmd
= 'chat' then
6534 if g_Game_IsNet
then
6536 if Length(P
) > 1 then
6538 for a
:= 1 to High(P
) do
6539 chstr
:= chstr
+ P
[a
] + ' ';
6541 if Length(chstr
) > 200 then SetLength(chstr
, 200);
6543 if Length(chstr
) < 1 then
6545 g_Console_Add('chat <text>');
6549 chstr
:= b_Text_Format(chstr
);
6550 if g_Game_IsClient
then
6551 MC_SEND_Chat(chstr
, NET_CHAT_PLAYER
)
6553 MH_SEND_Chat(gPlayer1Settings
.Name
+ ': ' + chstr
, NET_CHAT_PLAYER
);
6556 g_Console_Add('chat <text>');
6558 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6560 else if cmd
= 'teamchat' then
6562 if g_Game_IsNet
and (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
6564 if Length(P
) > 1 then
6566 for a
:= 1 to High(P
) do
6567 chstr
:= chstr
+ P
[a
] + ' ';
6569 if Length(chstr
) > 200 then SetLength(chstr
, 200);
6571 if Length(chstr
) < 1 then
6573 g_Console_Add('teamchat <text>');
6577 chstr
:= b_Text_Format(chstr
);
6578 if g_Game_IsClient
then
6579 MC_SEND_Chat(chstr
, NET_CHAT_TEAM
)
6581 MH_SEND_Chat(gPlayer1Settings
.Name
+ ': ' + chstr
, NET_CHAT_TEAM
,
6582 gPlayer1Settings
.Team
);
6585 g_Console_Add('teamchat <text>');
6587 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6589 else if cmd
= 'game' then
6591 if gGameSettings
.GameType
<> GT_NONE
then
6593 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6596 if Length(P
) = 1 then
6598 g_Console_Add(cmd
+ ' <WAD> [MAP] [# players]');
6601 // game not started yet, load fist map from some wad
6603 s
:= addWadExtension(P
[1]);
6604 found
:= e_FindResource(AllMapDirs
, s
);
6608 P
[1] := ExpandFileName(P
[1]);
6609 // if map not choosed then set first map
6610 if Length(P
) < 3 then
6613 P
[2] := g_Game_GetFirstMap(P
[1]);
6616 s
:= P
[1] + ':\' + UpperCase(P
[2]);
6618 if g_Map_Exist(s
) then
6622 with gGameSettings
do
6624 GameMode
:= g_Game_TextToMode(gcGameMode
);
6625 if gSwitchGameMode
<> GM_NONE
then
6626 GameMode
:= gSwitchGameMode
;
6627 if GameMode
= GM_NONE
then GameMode
:= GM_DM
;
6628 if GameMode
= GM_SINGLE
then GameMode
:= GM_COOP
;
6630 if Length(P
) >= 4 then
6631 b
:= StrToIntDef(P
[3], 1);
6632 g_Game_StartCustom(s
, GameMode
, TimeLimit
,
6633 GoalLimit
, MaxLives
, Options
, b
);
6638 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
6640 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [UpperCase(P
[2]), P
[1]]));
6642 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]));
6644 else if cmd
= 'host' then
6646 if gGameSettings
.GameType
<> GT_NONE
then
6648 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6651 if Length(P
) < 4 then
6653 g_Console_Add(cmd
+ ' <listen IP> <port> <WAD> [MAP] [# players]');
6656 if not StrToIp(P
[1], listen
) then
6658 prt
:= StrToIntDef(P
[2], 25666);
6660 s
:= addWadExtension(P
[3]);
6661 found
:= e_FindResource(AllMapDirs
, s
);
6665 // get first map in wad, if not specified
6666 if Length(P
) < 5 then
6669 P
[4] := g_Game_GetFirstMap(P
[1]);
6671 s
:= P
[3] + ':\' + UpperCase(P
[4]);
6672 if g_Map_Exist(s
) then
6676 with gGameSettings
do
6678 GameMode
:= g_Game_TextToMode(gcGameMode
);
6679 if gSwitchGameMode
<> GM_NONE
then GameMode
:= gSwitchGameMode
;
6680 if GameMode
= GM_NONE
then GameMode
:= GM_DM
;
6681 if GameMode
= GM_SINGLE
then GameMode
:= GM_COOP
;
6683 if Length(P
) >= 6 then
6684 b
:= StrToIntDef(P
[5], 0);
6685 g_Game_StartServer(s
, GameMode
, TimeLimit
, GoalLimit
, MaxLives
, Options
, b
, listen
, prt
)
6691 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[3]]))
6693 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [UpperCase(P
[4]), P
[3]]))
6698 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[3]]))
6701 else if cmd
= 'map' then
6703 if Length(P
) = 1 then
6705 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
6707 g_Console_Add(cmd
+ ' <MAP>');
6708 g_Console_Add(cmd
+ ' <WAD> [MAP]')
6712 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
])
6717 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
6719 if Length(P
) < 3 then
6721 // first param is map or wad
6722 s
:= UpperCase(P
[1]);
6723 if g_Map_Exist(gGameSettings
.WAD
+ ':\' + s
) then
6725 gExitByTrigger
:= False;
6728 // already in game, finish current map
6730 gExit
:= EXIT_ENDLEVELCUSTOM
;
6734 // intermission, so change map immediately
6741 found
:= e_FindResource(AllMapDirs
, s
);
6743 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [s
, 'WAD ' + P
[1]]));
6746 // no such map, found wad
6749 P
[1] := ExpandFileName(pw
);
6750 P
[2] := g_Game_GetFirstMap(P
[1]);
6751 s
:= P
[1] + ':\' + P
[2];
6752 if g_Map_Exist(s
) then
6754 gExitByTrigger
:= False;
6757 // already in game, finish current map
6759 gExit
:= EXIT_ENDLEVELCUSTOM
6763 // intermission, so change map immediately
6770 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
6772 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]))
6777 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]))
6783 s
:= addWadExtension(P
[1]);
6784 found
:= e_FindResource(AllMapDirs
, s
);
6788 P
[2] := UpperCase(P
[2]);
6789 s
:= P
[1] + ':\' + P
[2];
6790 if g_Map_Exist(s
) then
6792 gExitByTrigger
:= False;
6796 gExit
:= EXIT_ENDLEVELCUSTOM
6805 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]))
6810 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]))
6816 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
])
6820 else if cmd
= 'nextmap' then
6822 if not(gGameOn
or (gState
= STATE_INTERCUSTOM
)) then
6824 g_Console_Add(_lc
[I_MSG_NOT_GAME
])
6829 if Length(P
) = 1 then
6831 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
6833 g_Console_Add(cmd
+ ' <MAP>');
6834 g_Console_Add(cmd
+ ' <WAD> [MAP]');
6839 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6845 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
6847 if Length(P
) < 3 then
6849 // first param is map or wad
6850 s
:= UpperCase(P
[1]);
6851 if g_Map_Exist(gGameSettings
.WAD
+ ':\' + s
) then
6854 gExitByTrigger
:= False;
6860 // no such map, found wad
6861 pw
:= addWadExtension(P
[1]);
6862 found
:= e_FindResource(MapDirs
, pw
);
6864 found
:= e_FindResource(WadDirs
, pw
);
6866 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [s
, P
[1]]));
6869 // map not specified, select first map
6871 P
[2] := g_Game_GetFirstMap(P
[1]);
6872 s
:= P
[1] + ':\' + P
[2];
6873 if g_Map_Exist(s
) then
6875 gExitByTrigger
:= False;
6882 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
6884 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]))
6889 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]))
6895 // specified two params wad + map
6896 pw
:= addWadExtension(P
[1]);
6897 found
:= e_FindResource(MapDirs
, pw
);
6899 found
:= e_FindResource(MapDirs
, pw
);
6903 P
[2] := UpperCase(P
[2]);
6904 s
:= P
[1] + ':\' + P
[2];
6905 if g_Map_Exist(s
) then
6907 gExitByTrigger
:= False;
6913 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]))
6918 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]))
6924 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
])
6929 if gNextMap
= '' then
6930 g_Console_Add(_lc
[I_MSG_NEXTMAP_UNSET
])
6932 g_Console_Add(Format(_lc
[I_MSG_NEXTMAP_SET
], [gNextMap
]))
6936 else if (cmd
= 'endmap') or (cmd
= 'goodbye') then
6940 g_Console_Add(_lc
[I_MSG_NOT_GAME
])
6944 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
6946 gExitByTrigger
:= False;
6947 // next map not specified, try to find trigger EXIT
6948 if (gNextMap
= '') and (gTriggers
<> nil) then
6950 for a
:= 0 to High(gTriggers
) do
6952 if gTriggers
[a
].TriggerType
= TRIGGER_EXIT
then
6954 gExitByTrigger
:= True;
6955 //gNextMap := gTriggers[a].Data.MapName;
6956 gNextMap
:= gTriggers
[a
].tgcMap
;
6961 if gNextMap
= '' then
6962 gNextMap
:= g_Game_GetNextMap();
6963 if not isWadPath(gNextMap
) then
6964 s
:= gGameSettings
.WAD
+ ':\' + gNextMap
6967 if g_Map_Exist(s
) then
6968 gExit
:= EXIT_ENDLEVELCUSTOM
6970 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [gNextMap
]))
6974 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
])
6978 else if (cmd
= 'event') then
6980 if (Length(P
) <= 1) then
6982 for a
:= 0 to High(gEvents
) do
6983 if gEvents
[a
].Command
= '' then
6984 g_Console_Add(gEvents
[a
].Name
+ ' <none>')
6986 g_Console_Add(gEvents
[a
].Name
+ ' "' + gEvents
[a
].Command
+ '"');
6989 if (Length(P
) = 2) then
6991 for a
:= 0 to High(gEvents
) do
6992 if gEvents
[a
].Name
= P
[1] then
6993 if gEvents
[a
].Command
= '' then
6994 g_Console_Add(gEvents
[a
].Name
+ ' <none>')
6996 g_Console_Add(gEvents
[a
].Name
+ ' "' + gEvents
[a
].Command
+ '"');
6999 for a
:= 0 to High(gEvents
) do
7000 if gEvents
[a
].Name
= P
[1] then
7002 gEvents
[a
].Command
:= '';
7003 for b
:= 2 to High(P
) do
7004 if Pos(' ', P
[b
]) = 0 then
7005 gEvents
[a
].Command
:= gEvents
[a
].Command
+ ' ' + P
[b
]
7007 gEvents
[a
].Command
:= gEvents
[a
].Command
+ ' "' + P
[b
] + '"';
7008 gEvents
[a
].Command
:= Trim(gEvents
[a
].Command
);
7012 else if cmd
= 'suicide' then
7016 if g_Game_IsClient
then
7017 MC_SEND_CheatRequest(NET_CHEAT_SUICIDE
)
7020 if gPlayer1
<> nil then
7021 gPlayer1
.Damage(SUICIDE_DAMAGE
, gPlayer1
.UID
, 0, 0, HIT_SELF
);
7022 if gPlayer2
<> nil then
7023 gPlayer2
.Damage(SUICIDE_DAMAGE
, gPlayer2
.UID
, 0, 0, HIT_SELF
);
7027 else if cmd
= 'screenshot' then
7031 else if cmd
= 'weapon' then
7033 if Length(p
) = 2 then
7035 a
:= WP_FIRST
+ StrToInt(p
[1]) - 1;
7036 if (a
>= WP_FIRST
) and (a
<= WP_LAST
) then
7037 gSelectWeapon
[0, a
] := True
7040 else if (cmd
= 'p1_weapon') or (cmd
= 'p2_weapon') then
7042 if Length(p
) = 2 then
7044 a
:= WP_FIRST
+ StrToInt(p
[1]) - 1;
7045 b
:= ord(cmd
[2]) - ord('1');
7046 if (a
>= WP_FIRST
) and (a
<= WP_LAST
) then
7047 gSelectWeapon
[b
, a
] := True
7050 // Êîìàíäû Ñâîåé èãðû:
7051 else if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
7053 if cmd
= 'bot_addred' then
7055 if Length(P
) > 1 then
7056 g_Bot_Add(TEAM_RED
, StrToIntDef(P
[1], 2))
7058 g_Bot_Add(TEAM_RED
, 2);
7060 else if cmd
= 'bot_addblue' then
7062 if Length(P
) > 1 then
7063 g_Bot_Add(TEAM_BLUE
, StrToIntDef(P
[1], 2))
7065 g_Bot_Add(TEAM_BLUE
, 2);
7067 else if cmd
= 'spectate' then
7073 else if cmd
= 'say' then
7075 if g_Game_IsServer
and g_Game_IsNet
then
7077 if Length(P
) > 1 then
7080 for a
:= 1 to High(P
) do
7081 chstr
:= chstr
+ P
[a
] + ' ';
7083 if Length(chstr
) > 200 then SetLength(chstr
, 200);
7085 if Length(chstr
) < 1 then
7087 g_Console_Add('say <text>');
7091 chstr
:= b_Text_Format(chstr
);
7092 MH_SEND_Chat(chstr
, NET_CHAT_PLAYER
);
7094 else g_Console_Add('say <text>');
7096 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
7098 else if cmd
= 'tell' then
7100 if g_Game_IsServer
and g_Game_IsNet
then
7102 if (Length(P
) > 2) and (P
[1] <> '') then
7105 for a
:= 2 to High(P
) do
7106 chstr
:= chstr
+ P
[a
] + ' ';
7108 if Length(chstr
) > 200 then SetLength(chstr
, 200);
7110 if Length(chstr
) < 1 then
7112 g_Console_Add('tell <playername> <text>');
7116 pl
:= g_Net_Client_ByName(P
[1]);
7118 MH_SEND_Chat(b_Text_Format(chstr
), NET_CHAT_PLAYER
, pl
^.ID
)
7120 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
7122 else g_Console_Add('tell <playername> <text>');
7124 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
7126 else if (cmd
= 'overtime') and not g_Game_IsClient
then
7128 if (Length(P
) = 1) or (StrToIntDef(P
[1], -1) <= 0) then
7130 // Äîïîëíèòåëüíîå âðåìÿ:
7131 gGameSettings
.TimeLimit
:= (gTime
- gGameStartTime
) div 1000 + Word(StrToIntDef(P
[1], 0));
7133 g_Console_Add(Format(_lc
[I_MSG_TIME_LIMIT
],
7134 [gGameSettings
.TimeLimit
div 3600,
7135 (gGameSettings
.TimeLimit
div 60) mod 60,
7136 gGameSettings
.TimeLimit
mod 60]));
7137 if g_Game_IsNet
then MH_SEND_GameSettings
;
7139 else if (cmd
= 'rcon_password') and g_Game_IsClient
then
7141 if (Length(P
) <= 1) then
7142 g_Console_Add('rcon_password <password>')
7144 MC_SEND_RCONPassword(P
[1]);
7146 else if cmd
= 'rcon' then
7148 if g_Game_IsClient
then
7150 if Length(P
) > 1 then
7153 for a
:= 1 to High(P
) do
7154 chstr
:= chstr
+ P
[a
] + ' ';
7156 if Length(chstr
) > 200 then SetLength(chstr
, 200);
7158 if Length(chstr
) < 1 then
7160 g_Console_Add('rcon <command>');
7164 MC_SEND_RCONCommand(chstr
);
7166 else g_Console_Add('rcon <command>');
7169 else if cmd
= 'ready' then
7171 if g_Game_IsServer
and (gLMSRespawn
= LMS_RESPAWN_WARMUP
) then
7172 gLMSRespawnTime
:= gTime
+ 100;
7174 else if (cmd
= 'callvote') and g_Game_IsNet
then
7176 if Length(P
) > 1 then
7179 for a
:= 1 to High(P
) do begin
7180 if a
> 1 then chstr
:= chstr
+ ' ';
7181 chstr
:= chstr
+ P
[a
];
7184 if Length(chstr
) > 200 then SetLength(chstr
, 200);
7186 if Length(chstr
) < 1 then
7188 g_Console_Add('callvote <command>');
7192 if g_Game_IsClient
then
7193 MC_SEND_Vote(True, chstr
)
7195 g_Game_StartVote(chstr
, gPlayer1Settings
.Name
);
7196 g_Console_Process('vote', True);
7199 g_Console_Add('callvote <command>');
7201 else if (cmd
= 'vote') and g_Game_IsNet
then
7203 if g_Game_IsClient
then
7205 else if gVoteInProgress
then
7207 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
7208 a
:= Floor((NetClientCount
+1)/2.0) + 1
7210 a
:= Floor(NetClientCount
/2.0) + 1;
7215 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_REVOKED
], [gPlayer1Settings
.Name
, gVoteCount
, a
]), True);
7216 MH_SEND_VoteEvent(NET_VE_REVOKE
, gPlayer1Settings
.Name
, 'a', gVoteCount
, a
);
7222 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_VOTE
], [gPlayer1Settings
.Name
, gVoteCount
, a
]), True);
7223 MH_SEND_VoteEvent(NET_VE_VOTE
, gPlayer1Settings
.Name
, 'a', gVoteCount
, a
);
7231 procedure g_TakeScreenShot
;
7232 var s
: TStream
; t
: TDateTime
; dir
, date
, name
: String;
7234 if e_NoGraphics
then Exit
;
7237 dir
:= e_GetWriteableDir(ScreenshotDirs
);
7238 DateTimeToString(date
, 'yyyy-mm-dd-hh-nn-ss', t
);
7239 name
:= e_CatPath(dir
, 'screenshot-' + date
+ '.png');
7240 s
:= createDiskFile(name
);
7242 e_MakeScreenshot(s
, gScreenWidth
, gScreenHeight
);
7244 g_Console_Add(Format(_lc
[I_CONSOLE_SCREENSHOT
], [name
]))
7246 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_WRITE
], [name
]));
7251 g_Console_Add('oh shit, i can''t create screenshot!')
7255 procedure g_Game_InGameMenu(Show
: Boolean);
7257 if (g_ActiveWindow
= nil) and Show
then
7259 if gGameSettings
.GameType
= GT_SINGLE
then
7260 g_GUI_ShowWindow('GameSingleMenu')
7263 if g_Game_IsClient
then
7264 g_GUI_ShowWindow('GameClientMenu')
7266 if g_Game_IsNet
then
7267 g_GUI_ShowWindow('GameServerMenu')
7269 g_GUI_ShowWindow('GameCustomMenu');
7271 g_Sound_PlayEx('MENU_OPEN');
7273 // Ïàóçà ïðè ìåíþ òîëüêî â îäèíî÷íîé èãðå:
7274 if (not g_Game_IsNet
) then
7278 if (g_ActiveWindow
<> nil) and (not Show
) then
7280 // Ïàóçà ïðè ìåíþ òîëüêî â îäèíî÷íîé èãðå:
7281 if (not g_Game_IsNet
) then
7282 g_Game_Pause(False);
7286 procedure g_Game_Pause (Enable
: Boolean);
7290 if not gGameOn
then exit
;
7292 if not (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
]) then exit
;
7295 gPauseMain
:= Enable
;
7297 if (gPause
<> oldPause
) then g_Game_PauseAllSounds(gPause
);
7300 procedure g_Game_HolmesPause (Enable
: Boolean);
7304 if not gGameOn
then exit
;
7305 if not (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
]) then exit
;
7308 gPauseHolmes
:= Enable
;
7310 if (gPause
<> oldPause
) then g_Game_PauseAllSounds(gPause
);
7313 procedure g_Game_PauseAllSounds(Enable
: Boolean);
7318 if gTriggers
<> nil then
7319 for i
:= 0 to High(gTriggers
) do
7320 with gTriggers
[i
] do
7321 if (TriggerType
= TRIGGER_SOUND
) and
7323 Sound
.IsPlaying() then
7325 Sound
.Pause(Enable
);
7329 if gPlayers
<> nil then
7330 for i
:= 0 to High(gPlayers
) do
7331 if gPlayers
[i
] <> nil then
7332 gPlayers
[i
].PauseSounds(Enable
);
7335 if gMusic
<> nil then
7336 gMusic
.Pause(Enable
);
7339 procedure g_Game_StopAllSounds(all
: Boolean);
7343 if gTriggers
<> nil then
7344 for i
:= 0 to High(gTriggers
) do
7345 with gTriggers
[i
] do
7346 if (TriggerType
= TRIGGER_SOUND
) and
7350 if gMusic
<> nil then
7357 procedure g_Game_UpdateTriggerSounds
;
7360 if gTriggers
<> nil then
7361 for i
:= 0 to High(gTriggers
) do
7362 with gTriggers
[i
] do
7363 if (TriggerType
= TRIGGER_SOUND
) and (Sound
<> nil) and tgcLocal
and Sound
.IsPlaying() then
7364 Sound
.SetCoordsRect(X
, Y
, Width
, Height
, tgcVolume
/ 255.0)
7367 function g_Game_IsWatchedPlayer(UID
: Word): Boolean;
7370 if (gPlayer1
<> nil) and (gPlayer1
.UID
= UID
) then
7375 if (gPlayer2
<> nil) and (gPlayer2
.UID
= UID
) then
7380 if gSpectMode
<> SPECT_PLAYERS
then
7382 if gSpectPID1
= UID
then
7387 if gSpectViewTwo
and (gSpectPID2
= UID
) then
7394 function g_Game_IsWatchedTeam(Team
: Byte): Boolean;
7399 if (gPlayer1
<> nil) and (gPlayer1
.Team
= Team
) then
7404 if (gPlayer2
<> nil) and (gPlayer2
.Team
= Team
) then
7409 if gSpectMode
<> SPECT_PLAYERS
then
7411 Pl
:= g_Player_Get(gSpectPID1
);
7412 if (Pl
<> nil) and (Pl
.Team
= Team
) then
7417 if gSpectViewTwo
then
7419 Pl
:= g_Player_Get(gSpectPID2
);
7420 if (Pl
<> nil) and (Pl
.Team
= Team
) then
7428 procedure g_Game_Message(Msg
: string; Time
: Word);
7430 MessageLineLength
:= (gScreenWidth
- 204) div e_CharFont_GetMaxWidth(gMenuFont
);
7431 MessageText
:= b_Text_Wrap(b_Text_Format(Msg
), MessageLineLength
);
7432 MessageTime
:= Time
;
7435 procedure g_Game_ChatSound(Text: String; Taunt
: Boolean = True);
7437 punct
: Array[0..13] of String =
7438 ('.', ',', ':', ';', '!', '?', '(', ')', '''', '"', '/', '\', '*', '^');
7444 function IsPunctuation(S
: String): Boolean;
7449 if Length(S
) <> 1 then
7451 for i
:= Low(punct
) to High(punct
) do
7452 if S
= punct
[i
] then
7458 function FilterPunctuation(S
: String): String;
7462 for i
:= Low(punct
) to High(punct
) do
7463 S
:= StringReplace(S
, punct
[i
], ' ', [rfReplaceAll
]);
7469 if gUseChatSounds
and Taunt
and (gChatSounds
<> nil) and (Pos(': ', Text) > 0) then
7471 // remove player name
7472 Delete(Text, 1, Pos(': ', Text) + 2 - 1);
7473 // for FullWord check
7474 Text := toLowerCase1251(' ' + Text + ' ');
7475 fpText
:= FilterPunctuation(Text);
7477 for i
:= 0 to Length(gChatSounds
) - 1 do
7480 for j
:= 0 to Length(gChatSounds
[i
].Tags
) - 1 do
7482 if gChatSounds
[i
].FullWord
and (not IsPunctuation(gChatSounds
[i
].Tags
[j
])) then
7483 ok
:= Pos(' ' + gChatSounds
[i
].Tags
[j
] + ' ', fpText
) > 0
7485 ok
:= Pos(gChatSounds
[i
].Tags
[j
], Text) > 0;
7491 gChatSounds
[i
].Sound
.Play();
7497 g_Sound_PlayEx('SOUND_GAME_RADIO');
7500 procedure g_Game_Announce_GoodShot(SpawnerUID
: Word);
7509 if not g_Game_IsWatchedPlayer(SpawnerUID
) then
7513 if goodsnd
[a
].IsPlaying() then
7516 goodsnd
[Random(4)].Play();
7519 procedure g_Game_Announce_KillCombo(Param
: Integer);
7526 UID
:= Param
and $FFFF;
7531 Pl
:= g_Player_Get(UID
);
7540 g_Console_Add(Format(_lc
[I_PLAYER_KILL_2X
], [Name
]), True);
7544 g_Console_Add(Format(_lc
[I_PLAYER_KILL_3X
], [Name
]), True);
7548 g_Console_Add(Format(_lc
[I_PLAYER_KILL_4X
], [Name
]), True);
7552 g_Console_Add(Format(_lc
[I_PLAYER_KILL_MX
], [Name
]), True);
7560 if not g_Game_IsWatchedPlayer(UID
) then
7563 if (not g_Game_IsWatchedPlayer(UID
)) and (c
< 4) then
7567 if killsnd
[n
].IsPlaying() then
7572 procedure g_Game_Announce_BodyKill(SpawnerUID
: Word);
7581 if not g_Game_IsWatchedPlayer(SpawnerUID
) then
7585 if hahasnd
[a
].IsPlaying() then
7588 hahasnd
[Random(3)].Play();
7591 procedure g_Game_StartVote(Command
, Initiator
: string);
7595 if not gVotesEnabled
then Exit
;
7596 if gGameSettings
.GameType
<> GT_SERVER
then Exit
;
7597 if gVoteInProgress
or gVotePassed
then
7599 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_INPROGRESS
], [gVoteCommand
]), True);
7600 MH_SEND_VoteEvent(NET_VE_INPROGRESS
, gVoteCommand
);
7603 gVoteInProgress
:= True;
7604 gVotePassed
:= False;
7605 gVoteTimer
:= gTime
+ gVoteTimeout
* 1000;
7608 gVoteCommand
:= Command
;
7610 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
7611 Need
:= Floor((NetClientCount
+1)/2.0)+1
7613 Need
:= Floor(NetClientCount
/2.0)+1;
7614 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_STARTED
], [Initiator
, Command
, Need
]), True);
7615 MH_SEND_VoteEvent(NET_VE_STARTED
, Initiator
, Command
, Need
);
7618 procedure g_Game_CheckVote
;
7622 if gGameSettings
.GameType
<> GT_SERVER
then Exit
;
7623 if not gVoteInProgress
then Exit
;
7625 if (gTime
>= gVoteTimer
) then
7627 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
7628 Need
:= Floor((NetClientCount
+1)/2.0) + 1
7630 Need
:= Floor(NetClientCount
/2.0) + 1;
7631 if gVoteCount
>= Need
then
7633 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_PASSED
], [gVoteCommand
]), True);
7634 MH_SEND_VoteEvent(NET_VE_PASSED
, gVoteCommand
);
7635 gVotePassed
:= True;
7636 gVoteCmdTimer
:= gTime
+ 5000;
7640 g_Console_Add(_lc
[I_MESSAGE_VOTE_FAILED
], True);
7641 MH_SEND_VoteEvent(NET_VE_FAILED
);
7643 if NetClients
<> nil then
7644 for I
:= Low(NetClients
) to High(NetClients
) do
7645 if NetClients
[i
].Used
then
7646 NetClients
[i
].Voted
:= False;
7647 gVoteInProgress
:= False;
7653 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
7654 Need
:= Floor((NetClientCount
+1)/2.0) + 1
7656 Need
:= Floor(NetClientCount
/2.0) + 1;
7657 if gVoteCount
>= Need
then
7659 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_PASSED
], [gVoteCommand
]), True);
7660 MH_SEND_VoteEvent(NET_VE_PASSED
, gVoteCommand
);
7661 gVoteInProgress
:= False;
7662 gVotePassed
:= True;
7663 gVoteCmdTimer
:= gTime
+ 5000;
7666 if NetClients
<> nil then
7667 for I
:= Low(NetClients
) to High(NetClients
) do
7668 if NetClients
[i
].Used
then
7669 NetClients
[i
].Voted
:= False;
7674 procedure g_Game_LoadMapList(FileName
: string);
7682 if not FileExists(FileName
) then Exit
;
7684 AssignFile(ListFile
, FileName
);
7686 while not EOF(ListFile
) do
7688 ReadLn(ListFile
, s
);
7691 if s
= '' then Continue
;
7693 SetLength(MapList
, Length(MapList
)+1);
7694 MapList
[High(MapList
)] := s
;
7696 CloseFile(ListFile
);
7699 procedure g_Game_SetDebugMode();
7702 // ×èòû (äàæå â ñâîåé èãðå):
7706 procedure g_Game_SetLoadingText(Text: String; Max
: Integer; reWrite
: Boolean);
7710 if Length(LoadingStat
.Msgs
) = 0 then
7716 begin // Ïåðåõîäèì íà ñëåäóþùóþ ñòðîêó èëè ñêðîëëèðóåì:
7717 if NextMsg
= Length(Msgs
) then
7719 for i
:= 0 to High(Msgs
)-1 do
7720 Msgs
[i
] := Msgs
[i
+1];
7728 Msgs
[NextMsg
-1] := Text;
7732 PBarWasHere
:= false;
7735 g_ActiveWindow
:= nil;
7737 ProcessLoading(true);
7740 procedure g_Game_StepLoading(Value
: Integer = -1);
7751 if (ShowCount
> LOADING_SHOW_STEP
) or (Value
> -1) then
7759 procedure g_Game_ClearLoading();
7768 len
:= ((gScreenHeight
div 3)*2 - 50) div LOADING_INTERLINE
;
7769 if len
< 1 then len
:= 1;
7770 SetLength(Msgs
, len
);
7771 for len
:= Low(Msgs
) to High(Msgs
) do
7774 PBarWasHere
:= false;
7778 procedure Parse_Params(var pars
: TParamStrValues
);
7785 while i
<= ParamCount
do
7788 if (s
[1] = '-') and (Length(s
) > 1) then
7790 if (s
[2] = '-') and (Length(s
) > 2) then
7791 begin // Îäèíî÷íûé ïàðàìåòð
7792 SetLength(pars
, Length(pars
) + 1);
7793 with pars
[High(pars
)] do
7795 Name
:= LowerCase(s
);
7800 if (i
< ParamCount
) then
7801 begin // Ïàðàìåòð ñî çíà÷åíèåì
7803 SetLength(pars
, Length(pars
) + 1);
7804 with pars
[High(pars
)] do
7806 Name
:= LowerCase(s
);
7807 Value
:= LowerCase(ParamStr(i
));
7816 function Find_Param_Value(var pars
: TParamStrValues
; aName
: String): String;
7821 for i
:= 0 to High(pars
) do
7822 if pars
[i
].Name
= aName
then
7824 Result
:= pars
[i
].Value
;
7829 procedure g_Game_Process_Params();
7831 pars
: TParamStrValues
;
7834 LimT
, LimS
: Integer;
7845 s
:= Find_Param_Value(pars
, '--debug');
7848 g_Game_SetDebugMode();
7849 s
:= Find_Param_Value(pars
, '--netdump');
7854 // Connect when game loads
7855 ip
:= Find_Param_Value(pars
, '-connect');
7859 s
:= Find_Param_Value(pars
, '-port');
7860 if (s
= '') or not TryStrToInt(s
, Port
) then
7863 s
:= Find_Param_Value(pars
, '-pw');
7865 g_Game_StartClient(ip
, Port
, s
);
7869 s
:= LowerCase(Find_Param_Value(pars
, '-dbg-mainwad'));
7872 gDefaultMegawadStart
:= s
;
7875 if (Find_Param_Value(pars
, '--dbg-mainwad-restore') <> '') or
7876 (Find_Param_Value(pars
, '--dbg-mainwad-default') <> '') then
7878 gDefaultMegawadStart
:= DF_Default_Megawad_Start
;
7881 // Start map when game loads:
7882 map
:= LowerCase(Find_Param_Value(pars
, '-map'));
7883 if isWadPath(map
) then
7886 s
:= Find_Param_Value(pars
, '-gm');
7887 GMode
:= g_Game_TextToMode(s
);
7888 if GMode
= GM_NONE
then GMode
:= GM_DM
;
7889 if GMode
= GM_SINGLE
then GMode
:= GM_COOP
;
7892 s
:= Find_Param_Value(pars
, '-limt');
7893 if (s
= '') or (not TryStrToInt(s
, LimT
)) then
7899 s
:= Find_Param_Value(pars
, '-lims');
7900 if (s
= '') or (not TryStrToInt(s
, LimS
)) then
7906 s
:= Find_Param_Value(pars
, '-lives');
7907 if (s
= '') or (not TryStrToInt(s
, Lives
)) then
7913 s
:= Find_Param_Value(pars
, '-opt');
7915 Opt
:= GAME_OPTION_ALLOWEXIT
or GAME_OPTION_BOTVSPLAYER
or GAME_OPTION_BOTVSMONSTER
7917 Opt
:= StrToIntDef(s
, 0);
7919 Opt
:= GAME_OPTION_ALLOWEXIT
or GAME_OPTION_BOTVSPLAYER
or GAME_OPTION_BOTVSMONSTER
;
7922 s
:= Find_Param_Value(pars
, '--close');
7926 // Override map to test:
7927 s
:= LowerCase(Find_Param_Value(pars
, '-testmap'));
7930 if e_IsValidResourceName(s
) then
7931 e_FindResource(AllMapDirs
, s
);
7932 gTestMap
:= ExpandFileName(s
);
7935 // Delete test map after play:
7936 s
:= Find_Param_Value(pars
, '--testdelete');
7939 //gMapToDelete := MapsDir + map;
7940 e_WriteLog('"--testdelete" is deprecated, use --tempdelete.', TMsgType
.Fatal
);
7944 // Delete temporary WAD after play:
7945 s
:= Find_Param_Value(pars
, '--tempdelete');
7946 if (s
<> '') and (gTestMap
<> '') then
7948 gMapToDelete
:= gTestMap
;
7949 gTempDelete
:= True;
7952 // Number of players:
7953 s
:= Find_Param_Value(pars
, '-pl');
7955 n
:= DEFAULT_PLAYERS
7957 n
:= StrToIntDef(s
, DEFAULT_PLAYERS
);
7960 s
:= Find_Param_Value(pars
, '-port');
7961 if (s
= '') or not TryStrToInt(s
, Port
) then
7962 g_Game_StartCustom(map
, GMode
, LimT
, LimS
, Lives
, Opt
, n
)
7964 g_Game_StartServer(map
, GMode
, LimT
, LimS
, Lives
, Opt
, n
, 0, Port
);
7967 // Execute script when game loads:
7968 s
:= Find_Param_Value(pars
, '-exec');
7971 // if not isWadPath(s) then
7972 // s := GameDir + '/' + s;
7977 if IOResult
<> 0 then
7979 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], ['Failed to read file: ' + s
]), TMsgType
.Warning
);
7980 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_READ
], [s
]));
7984 e_WriteLog('Executing script: ' + s
, TMsgType
.Notify
);
7985 g_Console_Add(Format(_lc
[I_CONSOLE_EXEC
], [s
]));
7990 if IOResult
<> 0 then
7992 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], ['Failed to read file: ' + s
]), TMsgType
.Warning
);
7993 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_READ
], [s
]));
7997 if Pos('#', s
) <> 1 then // script comment
7998 g_Console_Process(s
, True);
8009 conRegVar('pf_draw_frame', @g_profile_frame_draw
, 'draw frame rendering profiles', 'render profiles');
8010 //conRegVar('pf_update_frame', @g_profile_frame_update, 'draw frame updating profiles', 'update profiles');
8011 conRegVar('pf_coldet', @g_profile_collision
, 'draw collision detection profiles', 'coldet profiles');
8012 conRegVar('pf_los', @g_profile_los
, 'draw monster LOS profiles', 'monster LOS profiles');
8014 conRegVar('r_sq_draw', @gdbg_map_use_accel_render
, 'accelerated spatial queries in rendering', 'accelerated rendering');
8015 conRegVar('cd_sq_enabled', @gdbg_map_use_accel_coldet
, 'accelerated spatial queries in map coldet', 'accelerated map coldet');
8016 conRegVar('mon_sq_enabled', @gmon_debug_use_sqaccel
, 'accelerated spatial queries for monsters', 'accelerated monster coldet');
8017 conRegVar('wtrace_sq_enabled', @gwep_debug_fast_trace
, 'accelerated spatial queries for weapon hitscan trace', 'accelerated weapon hitscan');
8019 conRegVar('pr_enabled', @gpart_dbg_enabled
, 'enable/disable particles', 'particles');
8020 conRegVar('pr_phys_enabled', @gpart_dbg_phys_enabled
, 'enable/disable particle physics', 'particle physics');
8022 conRegVar('los_enabled', @gmon_dbg_los_enabled
, 'enable/disable monster LOS calculations', 'monster LOS', true);
8023 conRegVar('mon_think', @gmon_debug_think
, 'enable/disable monster thinking', 'monster thinking', true);
8025 {$IFDEF ENABLE_HOLMES}
8026 conRegVar('dbg_holmes', @g_holmes_enabled
, 'enable/disable Holmes', 'Holmes', true);
8029 conRegVar('dbg_ignore_level_bounds', @g_dbg_ignore_bounds
, 'ignore level bounds', '', false);
8031 conRegVar('r_scale', @g_dbg_scale
, 0.01, 100.0, 'render scale', '', false);
8033 conRegVar('light_enabled', @gwin_k8_enable_light_experiments
, 'enable/disable dynamic lighting', 'lighting');
8034 conRegVar('light_player_halo', @g_playerLight
, 'enable/disable player halo', 'player light halo');
8036 conRegVar('r_smallmap_align_h', @r_smallmap_h
, 'halign: 0: left; 1: center; 2: right', 'horizontal aligning of small maps');
8037 conRegVar('r_smallmap_align_v', @r_smallmap_v
, 'valign: 0: top; 1: center; 2: bottom', 'vertial aligning of small maps');
8039 conRegVar('r_showfps', @gShowFPS
, 'draw fps counter', 'draw fps counter');
8040 conRegVar('r_showtime', @gShowTime
, 'show game time', 'show game time');