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, either version 3 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 {$INCLUDE ../shared/a_modes.inc}
24 g_basic
, g_player
, e_graphics
, g_res_downloader
,
25 g_sound
, g_gui
, utils
, md5
, mempool
, xprofiler
,
29 TGameSettings
= record
45 TDelayedEvent
= record
54 Sound
: TPlayableSound
;
55 Tags
: Array of String;
59 TPlayerSettings
= record
78 function g_Game_IsNet(): Boolean;
79 function g_Game_IsServer(): Boolean;
80 function g_Game_IsClient(): Boolean;
81 procedure g_Game_Init();
82 procedure g_Game_Free (freeTextures
: Boolean=true);
83 procedure g_Game_LoadData();
84 procedure g_Game_FreeData();
85 procedure g_Game_Update();
86 procedure g_Game_Draw();
87 procedure g_Game_Quit();
88 procedure g_Game_SetupScreenSize();
89 procedure g_Game_ChangeResolution(newWidth
, newHeight
: Word; nowFull
, nowMax
: Boolean);
90 function g_Game_ModeToText(Mode
: Byte): string;
91 function g_Game_TextToMode(Mode
: string): Byte;
92 procedure g_Game_ExecuteEvent(Name
: String);
93 function g_Game_DelayEvent(DEType
: Byte; Time
: LongWord; Num
: Integer = 0; Str
: String = ''): Integer;
94 procedure g_Game_AddPlayer(Team
: Byte = TEAM_NONE
);
95 procedure g_Game_RemovePlayer();
96 procedure g_Game_Spectate();
97 procedure g_Game_SpectateCenterView();
98 procedure g_Game_StartSingle(Map
: String; TwoPlayers
: Boolean; nPlayers
: Byte);
99 procedure g_Game_StartCustom(Map
: String; GameMode
: Byte; TimeLimit
, GoalLimit
: Word; MaxLives
: Byte; Options
: LongWord; nPlayers
: Byte);
100 procedure g_Game_StartServer(Map
: String; GameMode
: Byte; TimeLimit
, GoalLimit
: Word; MaxLives
: Byte; Options
: LongWord; nPlayers
: Byte; IPAddr
: LongWord; Port
: Word);
101 procedure g_Game_StartClient(Addr
: String; Port
: Word; PW
: String);
102 procedure g_Game_Restart();
103 procedure g_Game_RestartLevel();
104 procedure g_Game_RestartRound(NoMapRestart
: Boolean = False);
105 procedure g_Game_ClientWAD(NewWAD
: String; WHash
: TMD5Digest
);
106 procedure g_Game_SaveOptions();
107 function g_Game_StartMap(Map
: String; Force
: Boolean = False; const oldMapPath
: AnsiString=''): Boolean;
108 procedure g_Game_ChangeMap(const MapPath
: String);
109 procedure g_Game_ExitLevel(const Map
: AnsiString);
110 function g_Game_GetFirstMap(WAD
: String): String;
111 function g_Game_GetNextMap(): String;
112 procedure g_Game_NextLevel();
113 procedure g_Game_Pause(Enable
: Boolean);
114 procedure g_Game_HolmesPause(Enable
: Boolean);
115 procedure g_Game_InGameMenu(Show
: Boolean);
116 function g_Game_IsWatchedPlayer(UID
: Word): Boolean;
117 function g_Game_IsWatchedTeam(Team
: Byte): Boolean;
118 procedure g_Game_Message(Msg
: String; Time
: Word);
119 procedure g_Game_LoadMapList(FileName
: String);
120 procedure g_Game_PauseAllSounds(Enable
: Boolean);
121 procedure g_Game_StopAllSounds(all
: Boolean);
122 procedure g_Game_UpdateTriggerSounds();
123 function g_Game_GetMegaWADInfo(WAD
: String): TMegaWADInfo
;
124 procedure g_Game_ChatSound(Text: String; Taunt
: Boolean = True);
125 procedure g_Game_Announce_GoodShot(SpawnerUID
: Word);
126 procedure g_Game_Announce_KillCombo(Param
: Integer);
127 procedure g_Game_Announce_BodyKill(SpawnerUID
: Word);
128 procedure g_Game_StartVote(Command
, Initiator
: string);
129 procedure g_Game_CheckVote
;
130 procedure g_TakeScreenShot();
131 procedure g_FatalError(Text: String);
132 procedure g_SimpleError(Text: String);
133 function g_Game_IsTestMap(): Boolean;
134 procedure g_Game_DeleteTestMap();
135 procedure GameCVars(P
: SSArray
);
136 procedure GameCommands(P
: SSArray
);
137 procedure GameCheats(P
: SSArray
);
138 procedure DebugCommands(P
: SSArray
);
139 procedure g_Game_Process_Params
;
140 procedure g_Game_SetLoadingText(Text: String; Max
: Integer; reWrite
: Boolean);
141 procedure g_Game_StepLoading(Value
: Integer = -1);
142 procedure g_Game_ClearLoading();
143 procedure g_Game_SetDebugMode();
144 procedure DrawLoadingStat();
146 { procedure SetWinPause(Enable: Boolean); }
151 LOADING_SHOW_STEP
= 100;
152 LOADING_INTERLINE
= 20;
167 MESSAGE_DIKEY
= WM_USER
+ 1;
172 EXIT_ENDLEVELSINGLE
= 4;
173 EXIT_ENDLEVELCUSTOM
= 5;
175 GAME_OPTION_RESERVED
= 1;
176 GAME_OPTION_TEAMDAMAGE
= 2;
177 GAME_OPTION_ALLOWEXIT
= 4;
178 GAME_OPTION_WEAPONSTAY
= 8;
179 GAME_OPTION_MONSTERS
= 16;
180 GAME_OPTION_BOTVSPLAYER
= 32;
181 GAME_OPTION_BOTVSMONSTER
= 64;
186 STATE_INTERCUSTOM
= 3;
187 STATE_INTERSINGLE
= 4;
193 LMS_RESPAWN_NONE
= 0;
194 LMS_RESPAWN_WARMUP
= 1;
195 LMS_RESPAWN_FINAL
= 2;
212 CONFIG_FILENAME
= 'Doom2DF.cfg';
213 LOG_FILENAME
= 'Doom2DF.log';
215 TEST_MAP_NAME
= '$$$_TEST_$$$';
217 STD_PLAYER_MODEL
= 'Doomer';
221 gGameSettings
: TGameSettings
;
222 gPlayer1Settings
: TPlayerSettings
;
223 gPlayer2Settings
: TPlayerSettings
;
225 gPlayerScreenSize
: TDFPoint
;
226 gPlayer1ScreenCoord
: TDFPoint
;
227 gPlayer2ScreenCoord
: TDFPoint
;
228 gPlayer1
: TPlayer
= nil;
229 gPlayer2
: TPlayer
= nil;
230 gPlayerDrawn
: TPlayer
= nil;
232 gSwitchGameMode
: Byte = GM_DM
;
233 gHearPoint1
, gHearPoint2
: THearPoint
;
234 gSoundEffectsDF
: Boolean = False;
235 gSoundTriggerTime
: Word = 0;
236 gAnnouncer
: Byte = ANNOUNCE_NONE
;
237 goodsnd
: array[0..3] of TPlayableSound
;
238 killsnd
: array[0..3] of TPlayableSound
;
239 hahasnd
: array[0..2] of TPlayableSound
;
240 sound_get_flag
: array[0..1] of TPlayableSound
;
241 sound_lost_flag
: array[0..1] of TPlayableSound
;
242 sound_ret_flag
: array[0..1] of TPlayableSound
;
243 sound_cap_flag
: array[0..1] of TPlayableSound
;
244 gBodyKillEvent
: Integer = -1;
245 gDefInterTime
: ShortInt = -1;
246 gInterEndTime
: LongWord = 0;
247 gInterTime
: LongWord = 0;
248 gServInterTime
: Byte = 0;
249 gGameStartTime
: LongWord = 0;
250 gTotalMonsters
: Integer = 0;
251 gPauseMain
: Boolean = false;
252 gPauseHolmes
: Boolean = false;
253 gShowTime
: Boolean = True;
254 gShowFPS
: Boolean = False;
255 gShowGoals
: Boolean = True;
256 gShowStat
: Boolean = True;
257 gShowKillMsg
: Boolean = True;
258 gShowLives
: Boolean = True;
259 gShowPing
: Boolean = False;
260 gShowMap
: Boolean = False;
262 gState
: Byte = STATE_NONE
;
264 sWidth
, sHeight
: Word;
265 gSpectMode
: Byte = SPECT_NONE
;
266 gSpectHUD
: Boolean = True;
267 gSpectKeyPress
: Boolean = False;
268 gSpectX
: Integer = 0;
269 gSpectY
: Integer = 0;
270 gSpectStep
: Byte = 8;
271 gSpectViewTwo
: Boolean = False;
272 gSpectPID1
: Integer = -1;
273 gSpectPID2
: Integer = -1;
274 gSpectAuto
: Boolean = False;
275 gSpectAutoNext
: LongWord;
276 gSpectAutoStepX
: Integer;
277 gSpectAutoStepY
: Integer;
278 gMusic
: TMusic
= nil;
279 gLoadGameMode
: Boolean;
280 gCheats
: Boolean = False;
281 gMapOnce
: Boolean = False;
282 gMapToDelete
: String;
283 gTempDelete
: Boolean = False;
284 gLastMap
: Boolean = False;
285 gWinPosX
, gWinPosY
: Integer;
286 gWinSizeX
, gWinSizeY
: Integer;
287 gWinFrameX
, gWinFrameY
, gWinCaption
: Integer;
288 gWinActive
: Boolean = True; // by default window is active, lol
289 gResolutionChange
: Boolean = False;
290 gRC_Width
, gRC_Height
: Word;
291 gRC_FullScreen
, gRC_Maximized
: Boolean;
292 gLanguageChange
: Boolean = False;
293 gDebugMode
: Boolean = False;
294 g_debug_Sounds
: Boolean = False;
295 g_debug_Frames
: Boolean = False;
296 g_debug_WinMsgs
: Boolean = False;
297 g_debug_MonsterOff
: Boolean = False;
298 g_debug_BotAIOff
: Byte = 0;
299 g_debug_HealthBar
: Boolean = False;
300 g_Debug_Player
: Boolean = False;
301 gCoopMonstersKilled
: Word = 0;
302 gCoopSecretsFound
: Word = 0;
303 gCoopTotalMonstersKilled
: Word = 0;
304 gCoopTotalSecretsFound
: Word = 0;
305 gCoopTotalMonsters
: Word = 0;
306 gCoopTotalSecrets
: Word = 0;
307 gStatsOff
: Boolean = False;
308 gStatsPressed
: Boolean = False;
309 gExitByTrigger
: Boolean = False;
310 gNextMap
: String = '';
311 gLMSRespawn
: Byte = LMS_RESPAWN_NONE
;
312 gLMSRespawnTime
: Cardinal = 0;
313 gLMSSoftSpawn
: Boolean = False;
314 gMissionFailed
: Boolean = False;
315 gVoteInProgress
: Boolean = False;
316 gVotePassed
: Boolean = False;
317 gVoteCommand
: string = '';
318 gVoteTimer
: Cardinal = 0;
319 gVoteCmdTimer
: Cardinal = 0;
320 gVoteCount
: Integer = 0;
321 gVoteTimeout
: Cardinal = 30;
322 gVoted
: Boolean = False;
323 gVotesEnabled
: Boolean = True;
324 gEvents
: Array of TGameEvent
;
325 gDelayedEvents
: Array of TDelayedEvent
;
326 gUseChatSounds
: Boolean = True;
327 gChatSounds
: Array of TChatSound
;
328 gSelectWeapon
: Array [0..1, WP_FIRST
..WP_LAST
] of Boolean; // [player, weapon]
329 gInterReadyCount
: Integer = 0;
331 g_dbg_ignore_bounds
: Boolean = false;
332 r_smallmap_h
: Integer = 0; // 0: left; 1: center; 2: right
333 r_smallmap_v
: Integer = 2; // 0: top; 1: center; 2: bottom
335 // move button values:
336 // bits 0-1: l/r state:
337 // 0: neither left, nor right pressed
340 // bits 4-5: l/r state when strafe was pressed
341 P1MoveButton
: Byte = 0;
342 P2MoveButton
: Byte = 0;
344 g_profile_frame_update
: Boolean = false;
345 g_profile_frame_draw
: Boolean = false;
346 g_profile_collision
: Boolean = false;
347 g_profile_los
: Boolean = false;
348 g_profile_history_size
: Integer = 1000;
350 g_rlayer_back
: Boolean = true;
351 g_rlayer_step
: Boolean = true;
352 g_rlayer_wall
: Boolean = true;
353 g_rlayer_door
: Boolean = true;
354 g_rlayer_acid1
: Boolean = true;
355 g_rlayer_acid2
: Boolean = true;
356 g_rlayer_water
: Boolean = true;
357 g_rlayer_fore
: Boolean = true;
360 procedure g_ResetDynlights ();
361 procedure g_AddDynLight (x
, y
, radius
: Integer; r
, g
, b
, a
: Single);
362 procedure g_DynLightExplosion (x
, y
, radius
: Integer; r
, g
, b
: Single);
364 function conIsCheatsEnabled (): Boolean; inline;
365 function gPause (): Boolean; inline;
371 {$INCLUDE ../nogl/noGLuses.inc}
372 {$IFDEF ENABLE_HOLMES}
375 e_texture
, g_textures
, g_main
, g_window
, g_menu
,
376 e_input
, e_log
, g_console
, g_items
, g_map
, g_panel
,
377 g_playermodel
, g_gfx
, g_options
, Math
,
378 g_triggers
, g_monsters
, e_sound
, CONFIG
,
380 ENet
, e_msg
, g_netmsg
, g_netmaster
,
385 hasPBarGfx
: Boolean = false;
388 // ////////////////////////////////////////////////////////////////////////// //
389 function gPause (): Boolean; inline; begin result
:= gPauseMain
or gPauseHolmes
; end;
392 // ////////////////////////////////////////////////////////////////////////// //
393 function conIsCheatsEnabled (): Boolean; inline;
396 if g_Game_IsNet
then exit
;
397 if not gDebugMode
then
399 //if not gCheats then exit;
400 if not (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
]) then exit
;
401 if not (gGameSettings
.GameMode
in [GM_COOP
, GM_SINGLE
]) then exit
;
407 // ////////////////////////////////////////////////////////////////////////// //
409 profileFrameDraw
: TProfiler
= nil;
412 // ////////////////////////////////////////////////////////////////////////// //
415 x
, y
, radius
: Integer;
418 exploRadius
: Integer;
422 g_dynLights
: array of TDynLight
= nil;
423 g_dynLightCount
: Integer = 0;
424 g_playerLight
: Boolean = false;
426 procedure g_ResetDynlights ();
430 if not gwin_has_stencil
then begin g_dynLightCount
:= 0; exit
; end;
432 for idx
:= 0 to g_dynLightCount
-1 do
434 if g_dynLights
[idx
].exploCount
= -666 then
441 Inc(g_dynLights
[idx
].exploCount
);
442 if (g_dynLights
[idx
].exploCount
< 10) then
444 g_dynLights
[idx
].radius
:= g_dynLights
[idx
].exploRadius
+g_dynLights
[idx
].exploCount
*8;
445 g_dynLights
[idx
].a
:= 0.4+g_dynLights
[idx
].exploCount
/10;
446 if (g_dynLights
[idx
].a
> 0.8) then g_dynLights
[idx
].a
:= 0.8;
447 if lnum
<> idx
then g_dynLights
[lnum
] := g_dynLights
[idx
];
452 g_dynLightCount
:= lnum
;
455 procedure g_AddDynLight (x
, y
, radius
: Integer; r
, g
, b
, a
: Single);
457 if not gwin_has_stencil
then exit
;
458 if g_dynLightCount
= length(g_dynLights
) then SetLength(g_dynLights
, g_dynLightCount
+1024);
459 g_dynLights
[g_dynLightCount
].x
:= x
;
460 g_dynLights
[g_dynLightCount
].y
:= y
;
461 g_dynLights
[g_dynLightCount
].radius
:= radius
;
462 g_dynLights
[g_dynLightCount
].r
:= r
;
463 g_dynLights
[g_dynLightCount
].g
:= g
;
464 g_dynLights
[g_dynLightCount
].b
:= b
;
465 g_dynLights
[g_dynLightCount
].a
:= a
;
466 g_dynLights
[g_dynLightCount
].exploCount
:= -666;
467 Inc(g_dynLightCount
);
470 procedure g_DynLightExplosion (x
, y
, radius
: Integer; r
, g
, b
: Single);
472 if not gwin_has_stencil
then exit
;
473 if g_dynLightCount
= length(g_dynLights
) then SetLength(g_dynLights
, g_dynLightCount
+1024);
474 g_dynLights
[g_dynLightCount
].x
:= x
;
475 g_dynLights
[g_dynLightCount
].y
:= y
;
476 g_dynLights
[g_dynLightCount
].radius
:= 0;
477 g_dynLights
[g_dynLightCount
].exploRadius
:= radius
;
478 g_dynLights
[g_dynLightCount
].r
:= r
;
479 g_dynLights
[g_dynLightCount
].g
:= g
;
480 g_dynLights
[g_dynLightCount
].b
:= b
;
481 g_dynLights
[g_dynLightCount
].a
:= 0;
482 g_dynLights
[g_dynLightCount
].exploCount
:= 0;
483 Inc(g_dynLightCount
);
487 // ////////////////////////////////////////////////////////////////////////// //
488 function calcProfilesHeight (prof
: TProfiler
): Integer;
491 if (prof
= nil) then exit
;
492 if (length(prof
.bars
) = 0) then exit
;
493 result
:= length(prof
.bars
)*(16+2);
497 function drawProfiles (x
, y
: Integer; prof
: TProfiler
): Integer;
504 if (prof
= nil) then exit
;
506 if (length(prof
.bars
) = 0) then exit
;
508 hgt
:= calcProfilesHeight(prof
);
509 if (x
< 0) then x
:= gScreenWidth
-(wdt
-1)+x
;
510 if (y
< 0) then y
:= gScreenHeight
-(hgt
-1)+y
;
512 //e_DrawFillQuad(x, y, x+wdt-1, y+hgt-1, 255, 255, 255, 200, B_BLEND);
513 //e_DrawFillQuad(x, y, x+wdt-1, y+hgt-1, 20, 20, 20, 0, B_NONE);
514 e_DarkenQuadWH(x
, y
, wdt
, hgt
, 150);
517 for ii
:= 0 to High(prof
.bars
) do
519 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);
526 // ////////////////////////////////////////////////////////////////////////// //
528 TEndCustomGameStat
= record
529 PlayerStat
: TPlayerStatArray
;
533 Map
, MapName
: String;
536 TEndSingleGameStat
= record
537 PlayerStat
: Array [0..1] of record
543 TotalSecrets
: Integer;
546 TLoadingStat
= record
550 Msgs
: Array of String;
552 PBarWasHere
: Boolean; // did we draw a progress bar for this message?
555 TParamStrValue
= record
560 TParamStrValues
= Array of TParamStrValue
;
563 INTER_ACTION_TEXT
= 1;
564 INTER_ACTION_PIC
= 2;
565 INTER_ACTION_MUSIC
= 3;
569 FPSCounter
, UPSCounter
: Word;
570 FPSTime
, UPSTime
: LongWord;
571 DataLoaded
: Boolean = False;
572 IsDrawStat
: Boolean = False;
573 CustomStat
: TEndCustomGameStat
;
574 SingleStat
: TEndSingleGameStat
;
575 LoadingStat
: TLoadingStat
;
576 EndingGameCounter
: Byte = 0;
579 MessageLineLength
: Integer = 80;
580 MapList
: SSArray
= nil;
581 MapIndex
: Integer = -1;
582 InterReadyTime
: Integer = -1;
588 text: Array of ShortString;
589 anim
: Array of ShortString;
590 pic
: Array of ShortString;
591 mus
: Array of ShortString;
593 triggers
: Array of record
595 actions
: Array of record
596 action
, p1
, p2
: Integer;
599 cur_trigger
: Integer;
612 function Compare(a
, b
: TPlayerStat
): Integer;
614 if a
.Spectator
then Result
:= 1
615 else if b
.Spectator
then Result
:= -1
616 else if a
.Frags
< b
.Frags
then Result
:= 1
617 else if a
.Frags
> b
.Frags
then Result
:= -1
618 else if a
.Deaths
< b
.Deaths
then Result
:= -1
619 else if a
.Deaths
> b
.Deaths
then Result
:= 1
620 else if a
.Kills
< b
.Kills
then Result
:= -1
624 procedure SortGameStat(var stat
: TPlayerStatArray
);
629 if stat
= nil then Exit
;
631 for I
:= High(stat
) downto Low(stat
) do
632 for J
:= Low(stat
) to High(stat
) - 1 do
633 if Compare(stat
[J
], stat
[J
+ 1]) = 1 then
636 stat
[J
] := stat
[J
+ 1];
641 function g_Game_ModeToText(Mode
: Byte): string;
645 GM_DM
: Result
:= _lc
[I_MENU_GAME_TYPE_DM
];
646 GM_TDM
: Result
:= _lc
[I_MENU_GAME_TYPE_TDM
];
647 GM_CTF
: Result
:= _lc
[I_MENU_GAME_TYPE_CTF
];
648 GM_COOP
: Result
:= _lc
[I_MENU_GAME_TYPE_COOP
];
649 GM_SINGLE
: Result
:= _lc
[I_MENU_GAME_TYPE_SINGLE
];
653 function g_Game_TextToMode(Mode
: string): Byte;
656 Mode
:= UpperCase(Mode
);
657 if Mode
= _lc
[I_MENU_GAME_TYPE_DM
] then
662 if Mode
= _lc
[I_MENU_GAME_TYPE_TDM
] then
667 if Mode
= _lc
[I_MENU_GAME_TYPE_CTF
] then
672 if Mode
= _lc
[I_MENU_GAME_TYPE_COOP
] then
677 if Mode
= _lc
[I_MENU_GAME_TYPE_SINGLE
] then
684 function g_Game_IsNet(): Boolean;
686 Result
:= (gGameSettings
.GameType
in [GT_SERVER
, GT_CLIENT
]);
689 function g_Game_IsServer(): Boolean;
691 Result
:= (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
, GT_SERVER
]);
694 function g_Game_IsClient(): Boolean;
696 Result
:= (gGameSettings
.GameType
= GT_CLIENT
);
699 function g_Game_GetMegaWADInfo(WAD
: String): TMegaWADInfo
;
706 Result
.name
:= ExtractFileName(WAD
);
707 Result
.description
:= '';
710 w
:= TWADFile
.Create();
713 if not w
.GetResource('INTERSCRIPT', p
, len
) then
719 cfg
:= TConfig
.CreateMem(p
, len
);
720 Result
.name
:= cfg
.ReadStr('megawad', 'name', ExtractFileName(WAD
));
721 Result
.description
:= cfg
.ReadStr('megawad', 'description', '');
722 Result
.author
:= cfg
.ReadStr('megawad', 'author', '');
723 Result
.pic
:= cfg
.ReadStr('megawad', 'pic', '');
729 procedure g_Game_FreeWAD();
733 for a
:= 0 to High(MegaWAD
.res
.pic
) do
734 if MegaWAD
.res
.pic
[a
] <> '' then
735 g_Texture_Delete(MegaWAD
.res
.pic
[a
]);
737 for a
:= 0 to High(MegaWAD
.res
.mus
) do
738 if MegaWAD
.res
.mus
[a
] <> '' then
739 g_Sound_Delete(MegaWAD
.res
.mus
[a
]);
741 MegaWAD
.res
.pic
:= nil;
742 MegaWAD
.res
.text := nil;
743 MegaWAD
.res
.anim
:= nil;
744 MegaWAD
.res
.mus
:= nil;
745 MegaWAD
.triggers
:= nil;
747 g_Texture_Delete('TEXTURE_endpic');
748 g_Sound_Delete('MUSIC_endmus');
750 ZeroMemory(@MegaWAD
, SizeOf(MegaWAD
));
751 gGameSettings
.WAD
:= '';
754 procedure g_Game_LoadWAD(WAD
: string);
763 gGameSettings
.WAD
:= WAD
;
764 if not (gGameSettings
.GameMode
in [GM_COOP
, GM_SINGLE
]) then
767 MegaWAD
.info
:= g_Game_GetMegaWADInfo(MapsDir
+ WAD
);
769 w
:= TWADFile
.Create();
770 w
.ReadFile(MapsDir
+ WAD
);
772 if not w
.GetResource('INTERSCRIPT', p
, len
) then
778 cfg
:= TConfig
.CreateMem(p
, len
);
783 s := cfg.ReadStr('pic', 'pic'+IntToStr(b), '');
784 if s = '' then Break;
787 SetLength(MegaWAD.res.pic, Length(MegaWAD.res.pic)+1);
788 MegaWAD.res.pic[High(MegaWAD.res.pic)] := s;
790 g_Texture_CreateWADEx(s, s);
796 s := cfg.ReadStr('mus', 'mus'+IntToStr(b), '');
797 if s = '' then Break;
800 SetLength(MegaWAD.res.mus, Length(MegaWAD.res.mus)+1);
801 MegaWAD.res.mus[High(MegaWAD.res.mus)] := s;
803 g_Music_CreateWADEx(s, s);
806 MegaWAD
.endpic
:= cfg
.ReadStr('megawad', 'endpic', '');
807 if MegaWAD
.endpic
<> '' then
809 s
:= g_ExtractWadName(MegaWAD
.endpic
);
810 if s
= '' then s
:= MapsDir
+WAD
else s
:= GameDir
+'/wads/';
811 g_Texture_CreateWADEx('TEXTURE_endpic', s
+MegaWAD
.endpic
);
813 MegaWAD
.endmus
:= cfg
.ReadStr('megawad', 'endmus', 'Standart.wad:D2DMUS\ÊÎÍÅÖ');
814 if MegaWAD
.endmus
<> '' then
816 s
:= g_ExtractWadName(MegaWAD
.endmus
);
817 if s
= '' then s
:= MapsDir
+WAD
else s
:= GameDir
+'/wads/';
818 g_Sound_CreateWADEx('MUSIC_endmus', s
+MegaWAD
.endmus
, True);
826 {procedure start_trigger(t: string);
830 function next_trigger(): Boolean;
834 procedure DisableCheats();
840 if gPlayer1
<> nil then gPlayer1
.GodMode
:= False;
841 if gPlayer2
<> nil then gPlayer2
.GodMode
:= False;
842 if gPlayer1
<> nil then gPlayer1
.NoTarget
:= False;
843 if gPlayer2
<> nil then gPlayer2
.NoTarget
:= False;
845 {$IF DEFINED(D2F_DEBUG)}
846 if gPlayer1
<> nil then gPlayer1
.NoTarget
:= True;
847 gAimLine
:= g_dbg_aimline_on
;
851 procedure g_Game_ExecuteEvent(Name
: String);
857 if gEvents
= nil then
859 for a
:= 0 to High(gEvents
) do
860 if gEvents
[a
].Name
= Name
then
862 if gEvents
[a
].Command
<> '' then
863 g_Console_Process(gEvents
[a
].Command
, True);
868 function g_Game_DelayEvent(DEType
: Byte; Time
: LongWord; Num
: Integer = 0; Str
: String = ''): Integer;
873 if gDelayedEvents
<> nil then
874 for a
:= 0 to High(gDelayedEvents
) do
875 if not gDelayedEvents
[a
].Pending
then
882 SetLength(gDelayedEvents
, Length(gDelayedEvents
) + 1);
883 n
:= High(gDelayedEvents
);
885 gDelayedEvents
[n
].Pending
:= True;
886 gDelayedEvents
[n
].DEType
:= DEType
;
887 gDelayedEvents
[n
].DENum
:= Num
;
888 gDelayedEvents
[n
].DEStr
:= Str
;
889 if DEType
= DE_GLOBEVENT
then
890 gDelayedEvents
[n
].Time
:= (GetTimer() {div 1000}) + Time
892 gDelayedEvents
[n
].Time
:= gTime
+ Time
;
901 if g_Game_IsNet
and g_Game_IsServer
then
902 MH_SEND_GameEvent(NET_EV_MAPEND
, Byte(gMissionFailed
));
906 gPauseHolmes
:= false;
909 g_Game_StopAllSounds(False);
914 EndingGameCounter
:= 0;
915 g_ActiveWindow
:= nil;
917 gLMSRespawn
:= LMS_RESPAWN_NONE
;
918 gLMSRespawnTime
:= 0;
921 EXIT_SIMPLE
: // Âûõîä ÷åðåç ìåíþ èëè êîíåö òåñòà
926 begin // Ýòî áûë òåñò
930 begin // Âûõîä â ãëàâíîå ìåíþ
931 gMusic
.SetByName('MUSIC_MENU');
933 if gState
<> STATE_SLIST
then
935 g_GUI_ShowWindow('MainMenu');
936 gState
:= STATE_MENU
;
939 // Îáíîâëÿåì ñïèñîê ñåðâåðîâ
940 slReturnPressed
:= True;
941 if g_Net_Slist_Fetch(slCurrent
) then
943 if slCurrent
= nil then
944 slWaitStr
:= _lc
[I_NET_SLIST_NOSERVERS
];
947 slWaitStr
:= _lc
[I_NET_SLIST_ERROR
];
948 g_Serverlist_GenerateTable(slCurrent
, slTable
);
951 g_Game_ExecuteEvent('ongameend');
955 EXIT_RESTART
: // Íà÷àòü óðîâåíü ñíà÷àëà
957 if not g_Game_IsClient
then g_Game_Restart();
960 EXIT_ENDLEVELCUSTOM
: // Çàêîí÷èëñÿ óðîâåíü â Ñâîåé èãðå
962 // Ñòàòèñòèêà Ñâîåé èãðû:
963 FileName
:= g_ExtractWadName(gMapInfo
.Map
);
965 CustomStat
.GameTime
:= gTime
;
966 CustomStat
.Map
:= ExtractFileName(FileName
)+':'+g_ExtractFileName(gMapInfo
.Map
); //ResName;
967 CustomStat
.MapName
:= gMapInfo
.Name
;
968 CustomStat
.GameMode
:= gGameSettings
.GameMode
;
969 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
970 CustomStat
.TeamStat
:= gTeamStat
;
972 CustomStat
.PlayerStat
:= nil;
974 // Ñòàòèñòèêà èãðîêîâ:
975 if gPlayers
<> nil then
977 for a
:= 0 to High(gPlayers
) do
978 if gPlayers
[a
] <> nil then
980 SetLength(CustomStat
.PlayerStat
, Length(CustomStat
.PlayerStat
)+1);
981 with CustomStat
.PlayerStat
[High(CustomStat
.PlayerStat
)] do
984 Name
:= gPlayers
[a
].Name
;
985 Frags
:= gPlayers
[a
].Frags
;
986 Deaths
:= gPlayers
[a
].Death
;
987 Kills
:= gPlayers
[a
].Kills
;
988 Team
:= gPlayers
[a
].Team
;
989 Color
:= gPlayers
[a
].Model
.Color
;
990 Spectator
:= gPlayers
[a
].FSpectator
;
994 SortGameStat(CustomStat
.PlayerStat
);
997 g_Game_ExecuteEvent('onmapend');
998 if not g_Game_IsClient
then g_Player_ResetReady
;
999 gInterReadyCount
:= 0;
1001 // Çàòóõàþùèé ýêðàí:
1002 EndingGameCounter
:= 255;
1003 gState
:= STATE_FOLD
;
1005 if gDefInterTime
< 0 then
1006 gInterEndTime
:= IfThen((gGameSettings
.GameType
= GT_SERVER
) and (gPlayer1
= nil), 15000, 25000)
1008 gInterEndTime
:= gDefInterTime
* 1000;
1011 EXIT_ENDLEVELSINGLE
: // Çàêîí÷èëñÿ óðîâåíü â Îäèíî÷íîé èãðå
1013 // Ñòàòèñòèêà Îäèíî÷íîé èãðû:
1014 SingleStat
.GameTime
:= gTime
;
1015 SingleStat
.TwoPlayers
:= gPlayer2
<> nil;
1016 SingleStat
.TotalSecrets
:= gSecretsCount
;
1017 // Ñòàòèñòèêà ïåðâîãî èãðîêà:
1018 SingleStat
.PlayerStat
[0].Kills
:= gPlayer1
.MonsterKills
;
1019 SingleStat
.PlayerStat
[0].Secrets
:= gPlayer1
.Secrets
;
1020 // Ñòàòèñòèêà âòîðîãî èãðîêà (åñëè åñòü):
1021 if SingleStat
.TwoPlayers
then
1023 SingleStat
.PlayerStat
[1].Kills
:= gPlayer2
.MonsterKills
;
1024 SingleStat
.PlayerStat
[1].Secrets
:= gPlayer2
.Secrets
;
1027 g_Game_ExecuteEvent('onmapend');
1030 if gNextMap
<> '' then
1032 gMusic
.SetByName('MUSIC_INTERMUS');
1034 gState
:= STATE_INTERSINGLE
;
1037 g_Game_ExecuteEvent('oninter');
1039 else // Áîëüøå íåò êàðò
1041 // Çàòóõàþùèé ýêðàí:
1042 EndingGameCounter
:= 255;
1043 gState
:= STATE_FOLD
;
1048 // Îêîí÷àíèå îáðàáîòàíî:
1049 if gExit
<> EXIT_QUIT
then
1053 procedure drawTime(X
, Y
: Integer); inline;
1055 e_TextureFontPrint(x
, y
,
1056 Format('%d:%.2d:%.2d', [
1057 gTime
div 1000 div 3600,
1058 (gTime
div 1000 div 60) mod 60,
1059 gTime
div 1000 mod 60
1064 procedure DrawStat();
1066 pc
, x
, y
, w
, h
: Integer;
1067 w1
, w2
, w3
, w4
: Integer;
1069 cw
, ch
, r
, g
, b
, rr
, gg
, bb
: Byte;
1072 stat
: TPlayerStatArray
;
1079 pc
:= g_Player_GetCount
;
1080 e_TextureFontGetSize(gStdFont
, cw
, ch
);
1082 w
:= gScreenWidth
-(gScreenWidth
div 5);
1083 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
1086 h
:= 40+ch
*5+(ch
+8)*pc
;
1087 x
:= (gScreenWidth
div 2)-(w
div 2);
1088 y
:= (gScreenHeight
div 2)-(h
div 2);
1090 e_DrawFillQuad(x
, y
, x
+w
-1, y
+h
-1, 64, 64, 64, 32);
1091 e_DrawQuad(x
, y
, x
+w
-1, y
+h
-1, 255, 127, 0);
1093 drawTime(x
+w
-78, y
+8);
1095 wad
:= g_ExtractWadNameNoPath(gMapInfo
.Map
);
1096 map
:= g_ExtractFileName(gMapInfo
.Map
);
1097 mapstr
:= wad
+ ':\' + map
+ ' - ' + gMapInfo
.Name
;
1099 case gGameSettings
.GameMode
of
1102 if gGameSettings
.MaxLives
= 0 then
1103 s1
:= _lc
[I_GAME_DM
]
1105 s1
:= _lc
[I_GAME_LMS
];
1106 s2
:= Format(_lc
[I_GAME_FRAG_LIMIT
], [gGameSettings
.GoalLimit
]);
1107 s3
:= Format(_lc
[I_GAME_TIME_LIMIT
], [gGameSettings
.TimeLimit
div 3600, (gGameSettings
.TimeLimit
div 60) mod 60, gGameSettings
.TimeLimit
mod 60]);
1112 if gGameSettings
.MaxLives
= 0 then
1113 s1
:= _lc
[I_GAME_TDM
]
1115 s1
:= _lc
[I_GAME_TLMS
];
1116 s2
:= Format(_lc
[I_GAME_FRAG_LIMIT
], [gGameSettings
.GoalLimit
]);
1117 s3
:= Format(_lc
[I_GAME_TIME_LIMIT
], [gGameSettings
.TimeLimit
div 3600, (gGameSettings
.TimeLimit
div 60) mod 60, gGameSettings
.TimeLimit
mod 60]);
1122 s1
:= _lc
[I_GAME_CTF
];
1123 s2
:= Format(_lc
[I_GAME_SCORE_LIMIT
], [gGameSettings
.GoalLimit
]);
1124 s3
:= Format(_lc
[I_GAME_TIME_LIMIT
], [gGameSettings
.TimeLimit
div 3600, (gGameSettings
.TimeLimit
div 60) mod 60, gGameSettings
.TimeLimit
mod 60]);
1129 if gGameSettings
.MaxLives
= 0 then
1130 s1
:= _lc
[I_GAME_COOP
]
1132 s1
:= _lc
[I_GAME_SURV
];
1133 s2
:= _lc
[I_GAME_MONSTERS
] + ' ' + IntToStr(gCoopMonstersKilled
) + '/' + IntToStr(gTotalMonsters
);
1134 s3
:= _lc
[I_GAME_SECRETS
] + ' ' + IntToStr(gCoopSecretsFound
) + '/' + IntToStr(gSecretsCount
);
1145 e_TextureFontPrintEx(x
+(w
div 2)-(Length(s1
)*cw
div 2), _y
, s1
, gStdFont
, 255, 255, 255, 1);
1147 e_TextureFontPrintEx(x
+(w
div 2)-(Length(mapstr
)*cw
div 2), _y
, mapstr
, gStdFont
, 200, 200, 200, 1);
1149 e_TextureFontPrintEx(x
+16, _y
, s2
, gStdFont
, 200, 200, 200, 1);
1151 e_TextureFontPrintEx(x
+w
-16-(Length(s3
))*cw
, _y
, s3
,
1152 gStdFont
, 200, 200, 200, 1);
1154 if NetMode
= NET_SERVER
then
1155 e_TextureFontPrintEx(x
+8, y
+ 8, _lc
[I_NET_SERVER
], gStdFont
, 255, 255, 255, 1)
1157 if NetMode
= NET_CLIENT
then
1158 e_TextureFontPrintEx(x
+8, y
+ 8,
1159 NetClientIP
+ ':' + IntToStr(NetClientPort
), gStdFont
, 255, 255, 255, 1);
1163 stat
:= g_Player_GetStats();
1166 w2
:= (w
-16) div 6 + 48; // øèðèíà 2 ñòîëáöà
1167 w3
:= (w
-16) div 6; // øèðèíà 3 è 4 ñòîëáöîâ
1169 w1
:= w
-16-w2
-w3
-w4
; // îñòàâøååñÿ ïðîñòðàíñòâî - äëÿ öâåòà è èìåíè èãðîêà
1171 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
1175 for a
:= TEAM_RED
to TEAM_BLUE
do
1177 if a
= TEAM_RED
then
1179 s1
:= _lc
[I_GAME_TEAM_RED
];
1186 s1
:= _lc
[I_GAME_TEAM_BLUE
];
1192 e_TextureFontPrintEx(x
+16, _y
, s1
, gStdFont
, r
, g
, b
, 1);
1193 e_TextureFontPrintEx(x
+w1
+16, _y
, IntToStr(gTeamStat
[a
].Goals
),
1194 gStdFont
, r
, g
, b
, 1);
1196 _y
:= _y
+ch
+(ch
div 4);
1197 e_DrawLine(1, x
+16, _y
, x
+w
-16, _y
, r
, g
, b
);
1198 _y
:= _y
+(ch
div 4);
1200 for aa
:= 0 to High(stat
) do
1201 if stat
[aa
].Team
= a
then
1217 e_TextureFontPrintEx(x
+16, _y
, Name
, gStdFont
, rr
, gg
, bb
, 1);
1219 e_TextureFontPrintEx(x
+w1
+16, _y
, Format(_lc
[I_GAME_PING_MS
], [Ping
, Loss
]), gStdFont
, rr
, gg
, bb
, 1);
1221 e_TextureFontPrintEx(x
+w1
+w2
+16, _y
, IntToStr(Frags
), gStdFont
, rr
, gg
, bb
, 1);
1223 e_TextureFontPrintEx(x
+w1
+w2
+w3
+16, _y
, IntToStr(Deaths
), gStdFont
, rr
, gg
, bb
, 1);
1230 else if gGameSettings
.GameMode
in [GM_DM
, GM_COOP
] then
1233 e_TextureFontPrintEx(x
+16, _y
, _lc
[I_GAME_PLAYER_NAME
], gStdFont
, 255, 127, 0, 1);
1234 e_TextureFontPrintEx(x
+16+w1
, _y
, _lc
[I_GAME_PING
], gStdFont
, 255, 127, 0, 1);
1235 e_TextureFontPrintEx(x
+16+w1
+w2
, _y
, _lc
[I_GAME_FRAGS
], gStdFont
, 255, 127, 0, 1);
1236 e_TextureFontPrintEx(x
+16+w1
+w2
+w3
, _y
, _lc
[I_GAME_DEATHS
], gStdFont
, 255, 127, 0, 1);
1239 for aa
:= 0 to High(stat
) do
1253 e_DrawFillQuad(x
+16, _y
+4, x
+32-1, _y
+16+4-1, Color
.R
, Color
.G
, Color
.B
, 0);
1254 e_DrawQuad(x
+16, _y
+4, x
+32-1, _y
+16+4-1, 192, 192, 192);
1256 e_TextureFontPrintEx(x
+16+16+8, _y
+4, Name
, gStdFont
, r
, g
, 0, 1);
1258 e_TextureFontPrintEx(x
+w1
+16, _y
+4, Format(_lc
[I_GAME_PING_MS
], [Ping
, Loss
]), gStdFont
, r
, g
, 0, 1);
1260 e_TextureFontPrintEx(x
+w1
+w2
+16, _y
+4, IntToStr(Frags
), gStdFont
, r
, g
, 0, 1);
1262 e_TextureFontPrintEx(x
+w1
+w2
+w3
+16, _y
+4, IntToStr(Deaths
), gStdFont
, r
, g
, 0, 1);
1268 procedure g_Game_Init();
1274 gTempDelete
:= False;
1276 sfsGCDisable(); // temporary disable removing of temporary volumes
1279 g_Texture_CreateWADEx('MENU_BACKGROUND', GameWAD
+':TEXTURES\TITLE');
1280 g_Texture_CreateWADEx('INTER', GameWAD
+':TEXTURES\INTER');
1281 g_Texture_CreateWADEx('ENDGAME_EN', GameWAD
+':TEXTURES\ENDGAME_EN');
1282 g_Texture_CreateWADEx('ENDGAME_RU', GameWAD
+':TEXTURES\ENDGAME_RU');
1284 LoadStdFont('STDTXT', 'STDFONT', gStdFont
);
1285 LoadFont('MENUTXT', 'MENUFONT', gMenuFont
);
1286 LoadFont('SMALLTXT', 'SMALLFONT', gMenuSmallFont
);
1288 g_Game_ClearLoading();
1289 g_Game_SetLoadingText(Format('Doom 2D: Forever %s', [GAME_VERSION
]), 0, False);
1290 g_Game_SetLoadingText('', 0, False);
1292 g_Game_SetLoadingText(_lc
[I_LOAD_CONSOLE
], 0, False);
1295 g_Game_SetLoadingText(_lc
[I_LOAD_MODELS
], 0, False);
1296 g_PlayerModel_LoadData();
1298 if FindFirst(ModelsDir
+'*.wad', faAnyFile
, SR
) = 0 then
1300 if not g_PlayerModel_Load(ModelsDir
+SR
.Name
) then
1301 e_WriteLog(Format('Error loading model %s', [SR
.Name
]), TMsgType
.Warning
);
1302 until FindNext(SR
) <> 0;
1305 if FindFirst(ModelsDir
+'*.pk3', faAnyFile
, SR
) = 0 then
1307 if not g_PlayerModel_Load(ModelsDir
+SR
.Name
) then
1308 e_WriteLog(Format('Error loading model %s', [SR
.Name
]), TMsgType
.Warning
);
1309 until FindNext(SR
) <> 0;
1312 if FindFirst(ModelsDir
+'*.zip', faAnyFile
, SR
) = 0 then
1314 if not g_PlayerModel_Load(ModelsDir
+SR
.Name
) then
1315 e_WriteLog(Format('Error loading model %s', [SR
.Name
]), TMsgType
.Warning
);
1316 until FindNext(SR
) <> 0;
1320 gPauseMain
:= false;
1321 gPauseHolmes
:= false;
1324 {e_MouseInfo.Accel := 1.0;}
1326 g_Game_SetLoadingText(_lc
[I_LOAD_GAME_DATA
], 0, False);
1329 g_Game_SetLoadingText(_lc
[I_LOAD_MUSIC
], 0, False);
1330 g_Sound_CreateWADEx('MUSIC_INTERMUS', GameWAD
+':MUSIC\INTERMUS', True);
1331 g_Sound_CreateWADEx('MUSIC_MENU', GameWAD
+':MUSIC\MENU', True);
1332 g_Sound_CreateWADEx('MUSIC_ROUNDMUS', GameWAD
+':MUSIC\ROUNDMUS', True, True);
1333 g_Sound_CreateWADEx('MUSIC_STDENDMUS', GameWAD
+':MUSIC\ENDMUS', True);
1335 g_Game_SetLoadingText(_lc
[I_LOAD_MENUS
], 0, False);
1338 gMusic
:= TMusic
.Create();
1339 gMusic
.SetByName('MUSIC_MENU');
1342 gGameSettings
.WarmupTime
:= 30;
1344 gState
:= STATE_MENU
;
1346 SetLength(gEvents
, 6);
1347 gEvents
[0].Name
:= 'ongamestart';
1348 gEvents
[1].Name
:= 'ongameend';
1349 gEvents
[2].Name
:= 'onmapstart';
1350 gEvents
[3].Name
:= 'onmapend';
1351 gEvents
[4].Name
:= 'oninter';
1352 gEvents
[5].Name
:= 'onwadend';
1354 sfsGCEnable(); // enable releasing unused volumes
1358 procedure g_Game_Free(freeTextures
: Boolean=true);
1360 if NetMode
= NET_CLIENT
then g_Net_Disconnect();
1361 if NetMode
= NET_SERVER
then g_Net_Host_Die();
1363 g_Map_Free(freeTextures
);
1365 g_Player_RemoveAllCorpses();
1367 gGameSettings
.GameType
:= GT_NONE
;
1368 if gGameSettings
.GameMode
= GM_SINGLE
then
1369 gGameSettings
.GameMode
:= GM_DM
;
1370 gSwitchGameMode
:= gGameSettings
.GameMode
;
1373 gExitByTrigger
:= False;
1376 function IsActivePlayer(p
: TPlayer
): Boolean;
1381 Result
:= (not p
.FDummy
) and (not p
.FSpectator
);
1384 function GetActivePlayer_ByID(ID
: Integer): TPlayer
;
1391 if gPlayers
= nil then
1393 for a
:= Low(gPlayers
) to High(gPlayers
) do
1394 if IsActivePlayer(gPlayers
[a
]) then
1396 if gPlayers
[a
].UID
<> ID
then
1398 Result
:= gPlayers
[a
];
1403 function GetActivePlayerID_Next(Skip
: Integer = -1): Integer;
1409 if gPlayers
= nil then
1413 for a
:= Low(gPlayers
) to High(gPlayers
) do
1414 if IsActivePlayer(gPlayers
[a
]) then
1416 SetLength(ids
, Length(ids
) + 1);
1417 ids
[High(ids
)] := gPlayers
[a
].UID
;
1418 if gPlayers
[a
].UID
= Skip
then
1421 if Length(ids
) = 0 then
1426 Result
:= ids
[(idx
+ 1) mod Length(ids
)];
1429 function GetActivePlayerID_Prev(Skip
: Integer = -1): Integer;
1435 if gPlayers
= nil then
1439 for a
:= Low(gPlayers
) to High(gPlayers
) do
1440 if IsActivePlayer(gPlayers
[a
]) then
1442 SetLength(ids
, Length(ids
) + 1);
1443 ids
[High(ids
)] := gPlayers
[a
].UID
;
1444 if gPlayers
[a
].UID
= Skip
then
1447 if Length(ids
) = 0 then
1450 Result
:= ids
[Length(ids
) - 1]
1452 Result
:= ids
[(Length(ids
) - 1 + idx
) mod Length(ids
)];
1455 function GetActivePlayerID_Random(Skip
: Integer = -1): Integer;
1461 if gPlayers
= nil then
1465 for a
:= Low(gPlayers
) to High(gPlayers
) do
1466 if IsActivePlayer(gPlayers
[a
]) then
1468 SetLength(ids
, Length(ids
) + 1);
1469 ids
[High(ids
)] := gPlayers
[a
].UID
;
1470 if gPlayers
[a
].UID
= Skip
then
1473 if Length(ids
) = 0 then
1475 if Length(ids
) = 1 then
1480 Result
:= ids
[Random(Length(ids
))];
1482 while (idx
<> -1) and (Result
= Skip
) and (a
> 0) do
1484 Result
:= ids
[Random(Length(ids
))];
1489 function GetRandomSpectMode(Current
: Byte): Byte;
1496 0: Result
:= SPECT_STATS
;
1497 1: Result
:= SPECT_MAPVIEW
;
1498 2: Result
:= SPECT_MAPVIEW
;
1499 3: Result
:= SPECT_PLAYERS
;
1500 4: Result
:= SPECT_PLAYERS
;
1501 5: Result
:= SPECT_PLAYERS
;
1502 6: Result
:= SPECT_PLAYERS
;
1504 if (Current
in [SPECT_STATS
, SPECT_MAPVIEW
]) and (Current
= Result
) then
1508 procedure ProcessPlayerControls (plr
: TPlayer
; p
: Integer; var MoveButton
: Byte);
1514 if (plr
= nil) then exit
;
1515 if (p
= 2) then time
:= 1000 else time
:= 1;
1516 strafeDir
:= MoveButton
shr 4;
1517 MoveButton
:= MoveButton
and $0F;
1519 if gPlayerAction
[p
, ACTION_MOVELEFT
] and (not gPlayerAction
[p
, ACTION_MOVERIGHT
]) then
1520 MoveButton
:= 1 // Íàæàòà òîëüêî "Âëåâî"
1521 else if (not gPlayerAction
[p
, ACTION_MOVELEFT
]) and gPlayerAction
[p
, ACTION_MOVERIGHT
] then
1522 MoveButton
:= 2 // Íàæàòà òîëüêî "Âïðàâî"
1523 else if (not gPlayerAction
[p
, ACTION_MOVELEFT
]) and (not gPlayerAction
[p
, ACTION_MOVERIGHT
]) then
1524 MoveButton
:= 0; // Íå íàæàòû íè "Âëåâî", íè "Âïðàâî"
1526 // Ñåé÷àñ èëè ðàíüøå áûëè íàæàòû "Âëåâî"/"Âïðàâî" => ïåðåäàåì èãðîêó:
1527 if MoveButton
= 1 then
1528 plr
.PressKey(KEY_LEFT
, time
)
1529 else if MoveButton
= 2 then
1530 plr
.PressKey(KEY_RIGHT
, time
);
1532 // if we have "strafe" key, turn off old strafe mechanics
1533 if gPlayerAction
[p
, ACTION_STRAFE
] then
1535 // new strafe mechanics
1536 if (strafeDir
= 0) then
1537 strafeDir
:= MoveButton
; // start strafing
1538 // now set direction according to strafe (reversed)
1539 if (strafeDir
= 2) then
1540 plr
.SetDirection(TDirection
.D_LEFT
)
1541 else if (strafeDir
= 1) then
1542 plr
.SetDirection(TDirection
.D_RIGHT
)
1546 strafeDir
:= 0; // not strafing anymore
1547 // Ðàíüøå áûëà íàæàòà "Âïðàâî", à ñåé÷àñ "Âëåâî" => áåæèì âïðàâî, ñìîòðèì âëåâî:
1548 if (MoveButton
= 2) and gPlayerAction
[p
, ACTION_MOVELEFT
] then
1549 plr
.SetDirection(TDirection
.D_LEFT
)
1550 // Ðàíüøå áûëà íàæàòà "Âëåâî", à ñåé÷àñ "Âïðàâî" => áåæèì âëåâî, ñìîòðèì âïðàâî:
1551 else if (MoveButton
= 1) and gPlayerAction
[p
, ACTION_MOVERIGHT
] then
1552 plr
.SetDirection(TDirection
.D_RIGHT
)
1553 // ×òî-òî áûëî íàæàòî è íå èçìåíèëîñü => êóäà áåæèì, òóäà è ñìîòðèì:
1554 else if MoveButton
<> 0 then
1555 plr
.SetDirection(TDirection(MoveButton
-1))
1558 // fix movebutton state
1559 MoveButton
:= MoveButton
or (strafeDir
shl 4);
1561 // Îñòàëüíûå êëàâèøè:
1562 if gPlayerAction
[p
, ACTION_JUMP
] then plr
.PressKey(KEY_JUMP
, time
);
1563 if gPlayerAction
[p
, ACTION_LOOKUP
] then plr
.PressKey(KEY_UP
, time
);
1564 if gPlayerAction
[p
, ACTION_LOOKDOWN
] then plr
.PressKey(KEY_DOWN
, time
);
1565 if gPlayerAction
[p
, ACTION_ATTACK
] then plr
.PressKey(KEY_FIRE
);
1566 if gPlayerAction
[p
, ACTION_WEAPNEXT
] then plr
.PressKey(KEY_NEXTWEAPON
);
1567 if gPlayerAction
[p
, ACTION_WEAPPREV
] then plr
.PressKey(KEY_PREVWEAPON
);
1568 if gPlayerAction
[p
, ACTION_ACTIVATE
] then plr
.PressKey(KEY_OPEN
);
1570 gPlayerAction
[p
, ACTION_WEAPNEXT
] := False; // HACK, remove after readyweaon&pendinweapon implementation
1571 gPlayerAction
[p
, ACTION_WEAPPREV
] := False; // HACK, remove after readyweaon&pendinweapon implementation
1573 for i
:= WP_FIRST
to WP_LAST
do
1575 if gSelectWeapon
[p
, i
] then
1577 plr
.QueueWeaponSwitch(i
); // all choices are passed there, and god will take the best
1578 gSelectWeapon
[p
, i
] := False
1582 // HACK: add dynlight here
1583 if gwin_k8_enable_light_experiments
then
1585 if e_KeyPressed(IK_F8
) and gGameOn
and (not gConsoleShow
) and (g_ActiveWindow
= nil) then
1587 g_playerLight
:= true;
1589 if e_KeyPressed(IK_F9
) and gGameOn
and (not gConsoleShow
) and (g_ActiveWindow
= nil) then
1591 g_playerLight
:= false;
1595 if gwin_has_stencil
and g_playerLight
then g_AddDynLight(plr
.GameX
+32, plr
.GameY
+40, 128, 1, 1, 0, 0.6);
1598 // HACK: don't have a "key was pressed" function
1599 procedure InterReady();
1601 if InterReadyTime
> gTime
then Exit
;
1602 InterReadyTime
:= gTime
+ 3000;
1603 MC_SEND_CheatRequest(NET_CHEAT_READY
);
1606 procedure g_Game_Update();
1608 Msg
: g_gui
.TMessage
;
1614 function sendMonsPos (mon
: TMonster
): Boolean;
1616 result
:= false; // don't stop
1617 // this will also reset "need-send" flag
1618 if mon
.gncNeedSend
then
1620 MH_SEND_MonsterPos(mon
.UID
);
1622 else if (mon
.MonsterType
= MONSTER_BARREL
) then
1624 if (mon
.GameVelX
<> 0) or (mon
.GameVelY
<> 0) then MH_SEND_MonsterPos(mon
.UID
);
1626 else if (mon
.MonsterState
<> MONSTATE_SLEEP
) then
1628 if (mon
.MonsterState
<> MONSTATE_DEAD
) or (mon
.GameVelX
<> 0) or (mon
.GameVelY
<> 0) then MH_SEND_MonsterPos(mon
.UID
);
1632 function sendMonsPosUnexpected (mon
: TMonster
): Boolean;
1634 result
:= false; // don't stop
1635 // this will also reset "need-send" flag
1636 if mon
.gncNeedSend
then MH_SEND_MonsterPos(mon
.UID
);
1640 reliableUpdate
: Boolean;
1645 // Ïîðà âûêëþ÷àòü èãðó:
1646 if gExit
= EXIT_QUIT
then
1648 // Èãðà çàêîí÷èëàñü - îáðàáàòûâàåì:
1652 if gExit
= EXIT_QUIT
then
1656 // ×èòàåì êëàâèàòóðó è äæîéñòèê, åñëè îêíî àêòèâíî
1657 // no need to, as we'll do it in event handler
1659 // Îáíîâëÿåì êîíñîëü (äâèæåíèå è ñîîáùåíèÿ):
1662 if (NetMode
= NET_NONE
) and (g_Game_IsNet
) and (gGameOn
or (gState
in [STATE_FOLD
, STATE_INTERCUSTOM
])) then
1664 gExit
:= EXIT_SIMPLE
;
1670 STATE_INTERSINGLE
, // Ñòàòèñòêà ïîñëå ïðîõîæäåíèÿ óðîâíÿ â Îäèíî÷íîé èãðå
1671 STATE_INTERCUSTOM
, // Ñòàòèñòêà ïîñëå ïðîõîæäåíèÿ óðîâíÿ â Ñâîåé èãðå
1672 STATE_INTERTEXT
, // Òåêñò ìåæäó óðîâíÿìè
1673 STATE_INTERPIC
: // Êàðòèíêà ìåæäó óðîâíÿìè
1675 if g_Game_IsNet
and g_Game_IsServer
then
1677 gInterTime
:= gInterTime
+ GAME_TICK
;
1678 a
:= Min((gInterEndTime
- gInterTime
) div 1000 + 1, 255);
1679 if a
<> gServInterTime
then
1681 gServInterTime
:= a
;
1682 MH_SEND_TimeSync(gServInterTime
);
1686 if (not g_Game_IsClient
) and
1690 e_KeyPressed(IK_RETURN
) or e_KeyPressed(IK_KPRETURN
) or e_KeyPressed(IK_SPACE
) or
1691 e_KeyPressed(VK_FIRE
) or e_KeyPressed(VK_OPEN
) or
1692 e_KeyPressed(JOY0_ATTACK
) or e_KeyPressed(JOY1_ATTACK
) or
1693 e_KeyPressed(JOY2_ATTACK
) or e_KeyPressed(JOY3_ATTACK
)
1695 and (not gJustChatted
) and (not gConsoleShow
) and (not gChatShow
)
1696 and (g_ActiveWindow
= nil)
1698 or (g_Game_IsNet
and ((gInterTime
> gInterEndTime
) or (gInterReadyCount
>= NetClientCount
)))
1701 begin // Íàæàëè <Enter>/<Ïðîáåë> èëè ïðîøëî äîñòàòî÷íî âðåìåíè:
1702 g_Game_StopAllSounds(True);
1704 if gMapOnce
then // Ýòî áûë òåñò
1705 gExit
:= EXIT_SIMPLE
1707 if gNextMap
<> '' then // Ïåðåõîäèì íà ñëåäóþùóþ êàðòó
1708 g_Game_ChangeMap(gNextMap
)
1709 else // Ñëåäóþùåé êàðòû íåò
1711 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
] then
1713 // Âûõîä â ãëàâíîå ìåíþ:
1715 g_GUI_ShowWindow('MainMenu');
1716 gMusic
.SetByName('MUSIC_MENU');
1718 gState
:= STATE_MENU
;
1721 // Ôèíàëüíàÿ êàðòèíêà:
1722 g_Game_ExecuteEvent('onwadend');
1724 if not gMusic
.SetByName('MUSIC_endmus') then
1725 gMusic
.SetByName('MUSIC_STDENDMUS');
1727 gState
:= STATE_ENDPIC
;
1729 g_Game_ExecuteEvent('ongameend');
1734 else if g_Game_IsClient
and
1737 e_KeyPressed(IK_RETURN
) or e_KeyPressed(IK_KPRETURN
) or e_KeyPressed(IK_SPACE
) or
1738 e_KeyPressed(VK_FIRE
) or e_KeyPressed(VK_OPEN
) or
1739 e_KeyPressed(JOY0_ATTACK
) or e_KeyPressed(JOY1_ATTACK
) or
1740 e_KeyPressed(JOY2_ATTACK
) or e_KeyPressed(JOY3_ATTACK
)
1742 and (not gJustChatted
) and (not gConsoleShow
) and (not gChatShow
)
1743 and (g_ActiveWindow
= nil)
1751 if gState
= STATE_INTERTEXT
then
1752 if InterText
.counter
> 0 then
1753 InterText
.counter
:= InterText
.counter
- 1;
1756 STATE_FOLD
: // Çàòóõàíèå ýêðàíà
1758 if EndingGameCounter
= 0 then
1760 // Çàêîí÷èëñÿ óðîâåíü â Ñâîåé èãðå:
1761 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
1763 InterReadyTime
:= -1;
1764 if gLastMap
and (gGameSettings
.GameMode
= GM_COOP
) then
1766 g_Game_ExecuteEvent('onwadend');
1767 if not gMusic
.SetByName('MUSIC_endmus') then
1768 gMusic
.SetByName('MUSIC_STDENDMUS');
1771 gMusic
.SetByName('MUSIC_ROUNDMUS');
1774 gState
:= STATE_INTERCUSTOM
;
1777 else // Çàêîí÷èëàñü ïîñëåäíÿÿ êàðòà â Îäèíî÷íîé èãðå
1779 gMusic
.SetByName('MUSIC_INTERMUS');
1781 gState
:= STATE_INTERSINGLE
;
1784 g_Game_ExecuteEvent('oninter');
1787 DecMin(EndingGameCounter
, 6, 0);
1790 STATE_ENDPIC
: // Êàðòèíêà îêîí÷àíèÿ ìåãàÂàäà
1792 if gMapOnce
then // Ýòî áûë òåñò
1794 gExit
:= EXIT_SIMPLE
;
1800 g_Serverlist_Control(slCurrent
, slTable
);
1803 // Ñòàòèñòèêà ïî Tab:
1805 IsDrawStat
:= (not gConsoleShow
) and (not gChatShow
) and (gGameSettings
.GameType
<> GT_SINGLE
) and g_Console_Action(ACTION_SCORES
);
1808 if gGameOn
and not gPause
and (gState
<> STATE_FOLD
) then
1810 // Âðåìÿ += 28 ìèëëèñåêóíä:
1811 gTime
:= gTime
+ GAME_TICK
;
1813 // Ñîîáùåíèå ïîñåðåäèíå ýêðàíà:
1814 if MessageTime
= 0 then
1816 if MessageTime
> 0 then
1817 MessageTime
:= MessageTime
- 1;
1819 if (g_Game_IsServer
) then
1821 // Áûë çàäàí ëèìèò âðåìåíè:
1822 if (gGameSettings
.TimeLimit
> 0) then
1823 if (gTime
- gGameStartTime
) div 1000 >= gGameSettings
.TimeLimit
then
1824 begin // Îí ïðîøåë => êîíåö óðîâíÿ
1829 // Íàäî ðåñïàâíèòü èãðîêîâ â LMS:
1830 if (gLMSRespawn
> LMS_RESPAWN_NONE
) and (gLMSRespawnTime
< gTime
) then
1831 g_Game_RestartRound(gLMSSoftSpawn
);
1833 // Ïðîâåðèì ðåçóëüòàò ãîëîñîâàíèÿ, åñëè âðåìÿ ïðîøëî
1834 if gVoteInProgress
and (gVoteTimer
< gTime
) then
1836 else if gVotePassed
and (gVoteCmdTimer
< gTime
) then
1838 g_Console_Process(gVoteCommand
);
1840 gVotePassed
:= False;
1843 // Çàìåðÿåì âðåìÿ çàõâàòà ôëàãîâ
1844 if gFlags
[FLAG_RED
].State
= FLAG_STATE_CAPTURED
then
1845 gFlags
[FLAG_RED
].CaptureTime
:= gFlags
[FLAG_RED
].CaptureTime
+ GAME_TICK
;
1846 if gFlags
[FLAG_BLUE
].State
= FLAG_STATE_CAPTURED
then
1847 gFlags
[FLAG_BLUE
].CaptureTime
:= gFlags
[FLAG_BLUE
].CaptureTime
+ GAME_TICK
;
1849 // Áûë çàäàí ëèìèò ïîáåä:
1850 if (gGameSettings
.GoalLimit
> 0) then
1854 if gGameSettings
.GameMode
= GM_DM
then
1855 begin // Â DM èùåì èãðîêà ñ max ôðàãàìè
1856 for i
:= 0 to High(gPlayers
) do
1857 if gPlayers
[i
] <> nil then
1858 if gPlayers
[i
].Frags
> b
then
1859 b
:= gPlayers
[i
].Frags
;
1862 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
1863 begin //  CTF/TDM âûáèðàåì êîìàíäó ñ íàèáîëüøèì ñ÷åòîì
1864 b
:= Max(gTeamStat
[TEAM_RED
].Goals
, gTeamStat
[TEAM_BLUE
].Goals
);
1867 // Ëèìèò ïîáåä íàáðàí => êîíåö óðîâíÿ:
1868 if b
>= gGameSettings
.GoalLimit
then
1875 // Îáðàáàòûâàåì êëàâèøè èãðîêîâ:
1876 if gPlayer1
<> nil then gPlayer1
.ReleaseKeys();
1877 if gPlayer2
<> nil then gPlayer2
.ReleaseKeys();
1878 if (not gConsoleShow
) and (not gChatShow
) and (g_ActiveWindow
= nil) then
1880 ProcessPlayerControls(gPlayer1
, 0, P1MoveButton
);
1881 ProcessPlayerControls(gPlayer2
, 1, P2MoveButton
);
1882 end // if not console
1885 if g_Game_IsNet
and (gPlayer1
<> nil) then gPlayer1
.PressKey(KEY_CHAT
, 10000);
1887 // process weapon switch queue
1891 if (gPlayer1
= nil) and (gPlayer2
= nil) and
1892 (not gConsoleShow
) and (not gChatShow
) and (g_ActiveWindow
= nil) then
1894 if not gSpectKeyPress
then
1896 if gPlayerAction
[0, ACTION_JUMP
] and (not gSpectAuto
) then
1898 // switch spect mode
1900 SPECT_NONE
: ; // not spectator
1902 SPECT_MAPVIEW
: Inc(gSpectMode
);
1903 SPECT_PLAYERS
: gSpectMode
:= SPECT_STATS
; // reset to 1
1905 gSpectKeyPress
:= True;
1907 if (gSpectMode
= SPECT_MAPVIEW
)
1908 and (not gSpectAuto
) then
1910 if gPlayerAction
[0, ACTION_MOVELEFT
] then
1911 gSpectX
:= Max(gSpectX
- gSpectStep
, 0);
1912 if gPlayerAction
[0, ACTION_MOVERIGHT
] then
1913 gSpectX
:= Min(gSpectX
+ gSpectStep
, gMapInfo
.Width
- gScreenWidth
);
1914 if gPlayerAction
[0, ACTION_LOOKUP
] then
1915 gSpectY
:= Max(gSpectY
- gSpectStep
, 0);
1916 if gPlayerAction
[0, ACTION_LOOKDOWN
] then
1917 gSpectY
:= Min(gSpectY
+ gSpectStep
, gMapInfo
.Height
- gScreenHeight
);
1918 if gPlayerAction
[0, ACTION_WEAPPREV
] then
1921 if gSpectStep
> 4 then gSpectStep
:= gSpectStep
shr 1;
1922 gSpectKeyPress
:= True;
1924 if gPlayerAction
[0, ACTION_WEAPNEXT
] then
1927 if gSpectStep
< 64 then gSpectStep
:= gSpectStep
shl 1;
1928 gSpectKeyPress
:= True;
1931 if (gSpectMode
= SPECT_PLAYERS
)
1932 and (not gSpectAuto
) then
1934 if gPlayerAction
[0, ACTION_LOOKUP
] then
1937 gSpectViewTwo
:= True;
1938 gSpectKeyPress
:= True;
1940 if gPlayerAction
[0, ACTION_LOOKDOWN
] then
1942 // remove second view
1943 gSpectViewTwo
:= False;
1944 gSpectKeyPress
:= True;
1946 if gPlayerAction
[0, ACTION_MOVELEFT
] then
1948 // prev player (view 1)
1949 gSpectPID1
:= GetActivePlayerID_Prev(gSpectPID1
);
1950 gSpectKeyPress
:= True;
1952 if gPlayerAction
[0, ACTION_MOVERIGHT
] then
1954 // next player (view 1)
1955 gSpectPID1
:= GetActivePlayerID_Next(gSpectPID1
);
1956 gSpectKeyPress
:= True;
1958 if gPlayerAction
[0, ACTION_WEAPPREV
] then
1960 // prev player (view 2)
1961 gSpectPID2
:= GetActivePlayerID_Prev(gSpectPID2
);
1962 gSpectKeyPress
:= True;
1964 if gPlayerAction
[0, ACTION_WEAPNEXT
] then
1966 // next player (view 2)
1967 gSpectPID2
:= GetActivePlayerID_Next(gSpectPID2
);
1968 gSpectKeyPress
:= True;
1971 if gPlayerAction
[0, ACTION_ATTACK
] then
1973 if (gSpectMode
= SPECT_STATS
) and (not gSpectAuto
) then
1976 gSpectAutoNext
:= 0;
1977 gSpectViewTwo
:= False;
1978 gSpectKeyPress
:= True;
1983 gSpectMode
:= SPECT_STATS
;
1984 gSpectAuto
:= False;
1985 gSpectKeyPress
:= True;
1990 if (not gPlayerAction
[0, ACTION_JUMP
]) and
1991 (not gPlayerAction
[0, ACTION_ATTACK
]) and
1992 (not gPlayerAction
[0, ACTION_MOVELEFT
]) and
1993 (not gPlayerAction
[0, ACTION_MOVERIGHT
]) and
1994 (not gPlayerAction
[0, ACTION_LOOKUP
]) and
1995 (not gPlayerAction
[0, ACTION_LOOKDOWN
]) and
1996 (not gPlayerAction
[0, ACTION_WEAPPREV
]) and
1997 (not gPlayerAction
[0, ACTION_WEAPNEXT
]) then
1998 gSpectKeyPress
:= False;
2002 if gSpectMode
= SPECT_MAPVIEW
then
2004 i
:= Min(Max(gSpectX
+ gSpectAutoStepX
, 0), gMapInfo
.Width
- gScreenWidth
);
2006 gSpectAutoNext
:= gTime
2009 i
:= Min(Max(gSpectY
+ gSpectAutoStepY
, 0), gMapInfo
.Height
- gScreenHeight
);
2011 gSpectAutoNext
:= gTime
2015 if gSpectAutoNext
<= gTime
then
2017 if gSpectAutoNext
> 0 then
2019 gSpectMode
:= GetRandomSpectMode(gSpectMode
);
2023 gSpectX
:= Random(gMapInfo
.Width
- gScreenWidth
);
2024 gSpectY
:= Random(gMapInfo
.Height
- gScreenHeight
);
2025 gSpectAutoStepX
:= Random(9) - 4;
2026 gSpectAutoStepY
:= Random(9) - 4;
2027 if ((gSpectX
< 800) and (gSpectAutoStepX
< 0)) or
2028 ((gSpectX
> gMapInfo
.Width
- gScreenWidth
- 800) and (gSpectAutoStepX
> 0)) then
2029 gSpectAutoStepX
:= gSpectAutoStepX
* -1;
2030 if ((gSpectY
< 800) and (gSpectAutoStepY
< 0)) or
2031 ((gSpectY
> gMapInfo
.Height
- gScreenHeight
- 800) and (gSpectAutoStepY
> 0)) then
2032 gSpectAutoStepY
:= gSpectAutoStepY
* -1;
2036 gSpectPID1
:= GetActivePlayerID_Random(gSpectPID1
);
2041 SPECT_STATS
: gSpectAutoNext
:= gTime
+ (Random(3) + 5) * 1000;
2042 SPECT_MAPVIEW
: gSpectAutoNext
:= gTime
+ (Random(4) + 7) * 1000;
2043 SPECT_PLAYERS
: gSpectAutoNext
:= gTime
+ (Random(7) + 8) * 1000;
2049 // Îáíîâëÿåì âñå îñòàëüíîå:
2052 g_Triggers_Update();
2054 g_Monsters_Update();
2056 g_Player_UpdateAll();
2057 g_Player_UpdatePhysicalObjects();
2059 // server: send newly spawned monsters unconditionally
2060 if (gGameSettings
.GameType
= GT_SERVER
) then
2062 if (Length(gMonstersSpawned
) > 0) then
2064 for I
:= 0 to High(gMonstersSpawned
) do MH_SEND_MonsterSpawn(gMonstersSpawned
[I
]);
2065 SetLength(gMonstersSpawned
, 0);
2069 if (gSoundTriggerTime
> 8) then
2071 g_Game_UpdateTriggerSounds();
2072 gSoundTriggerTime
:= 0;
2076 Inc(gSoundTriggerTime
);
2079 if (NetMode
= NET_SERVER
) then
2081 Inc(NetTimeToUpdate
);
2082 Inc(NetTimeToReliable
);
2084 // send monster updates
2085 if (NetTimeToReliable
>= NetRelupdRate
) or (NetTimeToUpdate
>= NetUpdateRate
) then
2087 // send all monsters (periodic sync)
2088 reliableUpdate
:= (NetTimeToReliable
>= NetRelupdRate
);
2090 for I
:= 0 to High(gPlayers
) do
2092 if (gPlayers
[I
] <> nil) then MH_SEND_PlayerPos(reliableUpdate
, gPlayers
[I
].UID
);
2095 g_Mons_ForEach(sendMonsPos
);
2097 if reliableUpdate
then
2099 NetTimeToReliable
:= 0;
2100 NetTimeToUpdate
:= NetUpdateRate
;
2104 NetTimeToUpdate
:= 0;
2109 // send only mosters with some unexpected changes
2110 g_Mons_ForEach(sendMonsPosUnexpected
);
2113 // send unexpected platform changes
2114 g_Map_NetSendInterestingPanels();
2116 if NetUseMaster
then
2118 if gTime
>= NetTimeToMaster
then
2120 if (NetMHost
= nil) or (NetMPeer
= nil) then
2122 if not g_Net_Slist_Connect
then g_Console_Add(_lc
[I_NET_MSG_ERROR
] + _lc
[I_NET_SLIST_ERROR
]);
2126 NetTimeToMaster
:= gTime
+ NetMasterRate
;
2130 else if (NetMode
= NET_CLIENT
) then
2132 MC_SEND_PlayerPos();
2134 end; // if gameOn ...
2136 // Àêòèâíî îêíî èíòåðôåéñà - ïåðåäàåì êëàâèøè åìó:
2137 if g_ActiveWindow
<> nil then
2139 w
:= e_GetFirstKeyPressed();
2141 if (w
<> IK_INVALID
) then
2143 Msg
.Msg
:= MESSAGE_DIKEY
;
2145 g_ActiveWindow
.OnMessage(Msg
);
2148 // Åñëè îíî îò ýòîãî íå çàêðûëîñü, òî îáíîâëÿåì:
2149 if g_ActiveWindow
<> nil then
2150 g_ActiveWindow
.Update();
2152 // Íóæíî ñìåíèòü ðàçðåøåíèå:
2153 if gResolutionChange
then
2155 e_WriteLog('Changing resolution', TMsgType
.Notify
);
2156 g_Game_ChangeResolution(gRC_Width
, gRC_Height
, gRC_FullScreen
, gRC_Maximized
);
2157 gResolutionChange
:= False;
2158 g_ActiveWindow
:= nil;
2161 // Íóæíî ñìåíèòü ÿçûê:
2162 if gLanguageChange
then
2164 //e_WriteLog('Read language file', MSG_NOTIFY);
2165 //g_Language_Load(DataDir + gLanguage + '.txt');
2166 g_Language_Set(gLanguage
);
2168 gLanguageChange
:= False;
2172 // Ãîðÿ÷àÿ êëàâèøà äëÿ âûçîâà ìåíþ âûõîäà èç èãðû (F10):
2173 if e_KeyPressed(IK_F10
) and
2175 (not gConsoleShow
) and
2176 (g_ActiveWindow
= nil) then
2181 Time
:= GetTimer() {div 1000};
2183 // Îáðàáîòêà îòëîæåííûõ ñîáûòèé:
2184 if gDelayedEvents
<> nil then
2185 for a
:= 0 to High(gDelayedEvents
) do
2186 if gDelayedEvents
[a
].Pending
and
2188 ((gDelayedEvents
[a
].DEType
= DE_GLOBEVENT
) and (gDelayedEvents
[a
].Time
<= Time
)) or
2189 ((gDelayedEvents
[a
].DEType
> DE_GLOBEVENT
) and (gDelayedEvents
[a
].Time
<= gTime
))
2192 case gDelayedEvents
[a
].DEType
of
2194 g_Game_ExecuteEvent(gDelayedEvents
[a
].DEStr
);
2197 g_Game_Announce_GoodShot(gDelayedEvents
[a
].DENum
);
2201 g_Game_Announce_KillCombo(gDelayedEvents
[a
].DENum
);
2202 if g_Game_IsNet
and g_Game_IsServer
then
2203 MH_SEND_GameEvent(NET_EV_KILLCOMBO
, gDelayedEvents
[a
].DENum
);
2207 g_Game_Announce_BodyKill(gDelayedEvents
[a
].DENum
);
2209 gDelayedEvents
[a
].Pending
:= False;
2212 // Êàæäóþ ñåêóíäó îáíîâëÿåì ñ÷åò÷èê îáíîâëåíèé:
2213 UPSCounter
:= UPSCounter
+ 1;
2214 if Time
- UPSTime
>= 1000 then
2223 g_Weapon_AddDynLights();
2224 g_Items_AddDynLights();
2228 procedure g_Game_LoadChatSounds(Resource
: string);
2231 FileName
, Snd
: string;
2233 len
, cnt
, tags
, i
, j
: Integer;
2236 FileName
:= g_ExtractWadName(Resource
);
2238 WAD
:= TWADFile
.Create();
2239 WAD
.ReadFile(FileName
);
2241 if not WAD
.GetResource(g_ExtractFilePathName(Resource
), p
, len
) then
2248 cfg
:= TConfig
.CreateMem(p
, len
);
2249 cnt
:= cfg
.ReadInt('ChatSounds', 'Count', 0);
2251 SetLength(gChatSounds
, cnt
);
2252 for i
:= 0 to Length(gChatSounds
) - 1 do
2254 gChatSounds
[i
].Sound
:= nil;
2255 Snd
:= Trim(cfg
.ReadStr(IntToStr(i
), 'Sound', ''));
2256 tags
:= cfg
.ReadInt(IntToStr(i
), 'Tags', 0);
2257 if (Snd
= '') or (Tags
<= 0) then
2259 g_Sound_CreateWADEx('SOUND_CHAT_MACRO' + IntToStr(i
), GameWAD
+':'+Snd
);
2260 gChatSounds
[i
].Sound
:= TPlayableSound
.Create();
2261 gChatSounds
[i
].Sound
.SetByName('SOUND_CHAT_MACRO' + IntToStr(i
));
2262 SetLength(gChatSounds
[i
].Tags
, tags
);
2263 for j
:= 0 to tags
- 1 do
2264 gChatSounds
[i
].Tags
[j
] := toLowerCase1251(cfg
.ReadStr(IntToStr(i
), 'Tag' + IntToStr(j
), ''));
2265 gChatSounds
[i
].FullWord
:= cfg
.ReadBool(IntToStr(i
), 'FullWord', False);
2272 procedure g_Game_FreeChatSounds();
2276 for i
:= 0 to Length(gChatSounds
) - 1 do
2278 gChatSounds
[i
].Sound
.Free();
2279 g_Sound_Delete('SOUND_CHAT_MACRO' + IntToStr(i
));
2281 SetLength(gChatSounds
, 0);
2285 procedure g_Game_LoadData();
2292 if DataLoaded
then Exit
;
2294 e_WriteLog('Loading game data...', TMsgType
.Notify
);
2296 g_Texture_CreateWADEx('NOTEXTURE', GameWAD
+':TEXTURES\NOTEXTURE');
2297 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUD', GameWAD
+':TEXTURES\HUD');
2298 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDAIR', GameWAD
+':TEXTURES\AIRBAR');
2299 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDJET', GameWAD
+':TEXTURES\JETBAR');
2300 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDBG', GameWAD
+':TEXTURES\HUDBG');
2301 g_Texture_CreateWADEx('TEXTURE_PLAYER_ARMORHUD', GameWAD
+':TEXTURES\ARMORHUD');
2302 g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG', GameWAD
+':TEXTURES\FLAGHUD_R_BASE');
2303 g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG_S', GameWAD
+':TEXTURES\FLAGHUD_R_STOLEN');
2304 g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG_D', GameWAD
+':TEXTURES\FLAGHUD_R_DROP');
2305 g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG', GameWAD
+':TEXTURES\FLAGHUD_B_BASE');
2306 g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG_S', GameWAD
+':TEXTURES\FLAGHUD_B_STOLEN');
2307 g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG_D', GameWAD
+':TEXTURES\FLAGHUD_B_DROP');
2308 g_Texture_CreateWADEx('TEXTURE_PLAYER_TALKBUBBLE', GameWAD
+':TEXTURES\TALKBUBBLE');
2309 g_Texture_CreateWADEx('TEXTURE_PLAYER_INVULPENTA', GameWAD
+':TEXTURES\PENTA');
2310 g_Texture_CreateWADEx('TEXTURE_PLAYER_INDICATOR', GameWAD
+':TEXTURES\PLRIND');
2313 if not g_Texture_CreateWADEx('UI_GFX_PBAR_LEFT', GameWAD
+':TEXTURES\LLEFT') then hasPBarGfx
:= false;
2314 if not g_Texture_CreateWADEx('UI_GFX_PBAR_MARKER', GameWAD
+':TEXTURES\LMARKER') then hasPBarGfx
:= false;
2315 if not g_Texture_CreateWADEx('UI_GFX_PBAR_MIDDLE', GameWAD
+':TEXTURES\LMIDDLE') then hasPBarGfx
:= false;
2316 if not g_Texture_CreateWADEx('UI_GFX_PBAR_RIGHT', GameWAD
+':TEXTURES\LRIGHT') then hasPBarGfx
:= false;
2320 g_Texture_GetSize('UI_GFX_PBAR_LEFT', wl
, hl
);
2321 g_Texture_GetSize('UI_GFX_PBAR_RIGHT', wr
, hr
);
2322 g_Texture_GetSize('UI_GFX_PBAR_MIDDLE', wb
, hb
);
2323 g_Texture_GetSize('UI_GFX_PBAR_MARKER', wm
, hm
);
2324 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
2330 hasPBarGfx
:= false;
2334 g_Frames_CreateWAD(nil, 'FRAMES_TELEPORT', GameWAD
+':TEXTURES\TELEPORT', 64, 64, 10, False);
2335 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH', GameWAD
+':WEAPONS\PUNCH', 64, 64, 4, False);
2336 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_UP', GameWAD
+':WEAPONS\PUNCH_UP', 64, 64, 4, False);
2337 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_DN', GameWAD
+':WEAPONS\PUNCH_DN', 64, 64, 4, False);
2338 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_BERSERK', GameWAD
+':WEAPONS\PUNCHB', 64, 64, 4, False);
2339 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_BERSERK_UP', GameWAD
+':WEAPONS\PUNCHB_UP', 64, 64, 4, False);
2340 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_BERSERK_DN', GameWAD
+':WEAPONS\PUNCHB_DN', 64, 64, 4, False);
2341 g_Sound_CreateWADEx('SOUND_GAME_TELEPORT', GameWAD
+':SOUNDS\TELEPORT');
2342 g_Sound_CreateWADEx('SOUND_GAME_NOTELEPORT', GameWAD
+':SOUNDS\NOTELEPORT');
2343 g_Sound_CreateWADEx('SOUND_GAME_SECRET', GameWAD
+':SOUNDS\SECRET');
2344 g_Sound_CreateWADEx('SOUND_GAME_DOOROPEN', GameWAD
+':SOUNDS\DOOROPEN');
2345 g_Sound_CreateWADEx('SOUND_GAME_DOORCLOSE', GameWAD
+':SOUNDS\DOORCLOSE');
2346 g_Sound_CreateWADEx('SOUND_GAME_BULK1', GameWAD
+':SOUNDS\BULK1');
2347 g_Sound_CreateWADEx('SOUND_GAME_BULK2', GameWAD
+':SOUNDS\BULK2');
2348 g_Sound_CreateWADEx('SOUND_GAME_BUBBLE1', GameWAD
+':SOUNDS\BUBBLE1');
2349 g_Sound_CreateWADEx('SOUND_GAME_BUBBLE2', GameWAD
+':SOUNDS\BUBBLE2');
2350 g_Sound_CreateWADEx('SOUND_GAME_BURNING', GameWAD
+':SOUNDS\BURNING');
2351 g_Sound_CreateWADEx('SOUND_GAME_SWITCH1', GameWAD
+':SOUNDS\SWITCH1');
2352 g_Sound_CreateWADEx('SOUND_GAME_SWITCH0', GameWAD
+':SOUNDS\SWITCH0');
2353 g_Sound_CreateWADEx('SOUND_GAME_RADIO', GameWAD
+':SOUNDS\RADIO');
2354 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD1', GameWAD
+':SOUNDS\GOOD1');
2355 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD2', GameWAD
+':SOUNDS\GOOD2');
2356 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD3', GameWAD
+':SOUNDS\GOOD3');
2357 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD4', GameWAD
+':SOUNDS\GOOD4');
2358 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL2X', GameWAD
+':SOUNDS\KILL2X');
2359 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL3X', GameWAD
+':SOUNDS\KILL3X');
2360 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL4X', GameWAD
+':SOUNDS\KILL4X');
2361 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILLMX', GameWAD
+':SOUNDS\KILLMX');
2362 g_Sound_CreateWADEx('SOUND_ANNOUNCER_MUHAHA1', GameWAD
+':SOUNDS\MUHAHA1');
2363 g_Sound_CreateWADEx('SOUND_ANNOUNCER_MUHAHA2', GameWAD
+':SOUNDS\MUHAHA2');
2364 g_Sound_CreateWADEx('SOUND_ANNOUNCER_MUHAHA3', GameWAD
+':SOUNDS\MUHAHA3');
2365 g_Sound_CreateWADEx('SOUND_CTF_GET1', GameWAD
+':SOUNDS\GETFLAG1');
2366 g_Sound_CreateWADEx('SOUND_CTF_GET2', GameWAD
+':SOUNDS\GETFLAG2');
2367 g_Sound_CreateWADEx('SOUND_CTF_LOST1', GameWAD
+':SOUNDS\LOSTFLG1');
2368 g_Sound_CreateWADEx('SOUND_CTF_LOST2', GameWAD
+':SOUNDS\LOSTFLG2');
2369 g_Sound_CreateWADEx('SOUND_CTF_RETURN1', GameWAD
+':SOUNDS\RETFLAG1');
2370 g_Sound_CreateWADEx('SOUND_CTF_RETURN2', GameWAD
+':SOUNDS\RETFLAG2');
2371 g_Sound_CreateWADEx('SOUND_CTF_CAPTURE1', GameWAD
+':SOUNDS\CAPFLAG1');
2372 g_Sound_CreateWADEx('SOUND_CTF_CAPTURE2', GameWAD
+':SOUNDS\CAPFLAG2');
2374 goodsnd
[0] := TPlayableSound
.Create();
2375 goodsnd
[1] := TPlayableSound
.Create();
2376 goodsnd
[2] := TPlayableSound
.Create();
2377 goodsnd
[3] := TPlayableSound
.Create();
2379 goodsnd
[0].SetByName('SOUND_ANNOUNCER_GOOD1');
2380 goodsnd
[1].SetByName('SOUND_ANNOUNCER_GOOD2');
2381 goodsnd
[2].SetByName('SOUND_ANNOUNCER_GOOD3');
2382 goodsnd
[3].SetByName('SOUND_ANNOUNCER_GOOD4');
2384 killsnd
[0] := TPlayableSound
.Create();
2385 killsnd
[1] := TPlayableSound
.Create();
2386 killsnd
[2] := TPlayableSound
.Create();
2387 killsnd
[3] := TPlayableSound
.Create();
2389 killsnd
[0].SetByName('SOUND_ANNOUNCER_KILL2X');
2390 killsnd
[1].SetByName('SOUND_ANNOUNCER_KILL3X');
2391 killsnd
[2].SetByName('SOUND_ANNOUNCER_KILL4X');
2392 killsnd
[3].SetByName('SOUND_ANNOUNCER_KILLMX');
2394 hahasnd
[0] := TPlayableSound
.Create();
2395 hahasnd
[1] := TPlayableSound
.Create();
2396 hahasnd
[2] := TPlayableSound
.Create();
2398 hahasnd
[0].SetByName('SOUND_ANNOUNCER_MUHAHA1');
2399 hahasnd
[1].SetByName('SOUND_ANNOUNCER_MUHAHA2');
2400 hahasnd
[2].SetByName('SOUND_ANNOUNCER_MUHAHA3');
2402 sound_get_flag
[0] := TPlayableSound
.Create();
2403 sound_get_flag
[1] := TPlayableSound
.Create();
2404 sound_lost_flag
[0] := TPlayableSound
.Create();
2405 sound_lost_flag
[1] := TPlayableSound
.Create();
2406 sound_ret_flag
[0] := TPlayableSound
.Create();
2407 sound_ret_flag
[1] := TPlayableSound
.Create();
2408 sound_cap_flag
[0] := TPlayableSound
.Create();
2409 sound_cap_flag
[1] := TPlayableSound
.Create();
2411 sound_get_flag
[0].SetByName('SOUND_CTF_GET1');
2412 sound_get_flag
[1].SetByName('SOUND_CTF_GET2');
2413 sound_lost_flag
[0].SetByName('SOUND_CTF_LOST1');
2414 sound_lost_flag
[1].SetByName('SOUND_CTF_LOST2');
2415 sound_ret_flag
[0].SetByName('SOUND_CTF_RETURN1');
2416 sound_ret_flag
[1].SetByName('SOUND_CTF_RETURN2');
2417 sound_cap_flag
[0].SetByName('SOUND_CTF_CAPTURE1');
2418 sound_cap_flag
[1].SetByName('SOUND_CTF_CAPTURE2');
2420 g_Game_LoadChatSounds(GameWAD
+':CHATSND\SNDCFG');
2422 g_Game_SetLoadingText(_lc
[I_LOAD_ITEMS_DATA
], 0, False);
2425 g_Game_SetLoadingText(_lc
[I_LOAD_WEAPONS_DATA
], 0, False);
2426 g_Weapon_LoadData();
2428 g_Monsters_LoadData();
2433 procedure g_Game_FreeData();
2435 if not DataLoaded
then Exit
;
2438 g_Weapon_FreeData();
2439 g_Monsters_FreeData();
2441 e_WriteLog('Releasing game data...', TMsgType
.Notify
);
2443 g_Texture_Delete('NOTEXTURE');
2444 g_Texture_Delete('TEXTURE_PLAYER_HUD');
2445 g_Texture_Delete('TEXTURE_PLAYER_HUDBG');
2446 g_Texture_Delete('TEXTURE_PLAYER_ARMORHUD');
2447 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG');
2448 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG_S');
2449 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG_D');
2450 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG');
2451 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG_S');
2452 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG_D');
2453 g_Texture_Delete('TEXTURE_PLAYER_TALKBUBBLE');
2454 g_Texture_Delete('TEXTURE_PLAYER_INVULPENTA');
2455 g_Frames_DeleteByName('FRAMES_TELEPORT');
2456 g_Frames_DeleteByName('FRAMES_PUNCH');
2457 g_Frames_DeleteByName('FRAMES_PUNCH_UP');
2458 g_Frames_DeleteByName('FRAMES_PUNCH_DN');
2459 g_Frames_DeleteByName('FRAMES_PUNCH_BERSERK');
2460 g_Frames_DeleteByName('FRAMES_PUNCH_BERSERK_UP');
2461 g_Frames_DeleteByName('FRAMES_PUNCH_BERSERK_DN');
2462 g_Sound_Delete('SOUND_GAME_TELEPORT');
2463 g_Sound_Delete('SOUND_GAME_NOTELEPORT');
2464 g_Sound_Delete('SOUND_GAME_SECRET');
2465 g_Sound_Delete('SOUND_GAME_DOOROPEN');
2466 g_Sound_Delete('SOUND_GAME_DOORCLOSE');
2467 g_Sound_Delete('SOUND_GAME_BULK1');
2468 g_Sound_Delete('SOUND_GAME_BULK2');
2469 g_Sound_Delete('SOUND_GAME_BUBBLE1');
2470 g_Sound_Delete('SOUND_GAME_BUBBLE2');
2471 g_Sound_Delete('SOUND_GAME_BURNING');
2472 g_Sound_Delete('SOUND_GAME_SWITCH1');
2473 g_Sound_Delete('SOUND_GAME_SWITCH0');
2480 g_Sound_Delete('SOUND_ANNOUNCER_GOOD1');
2481 g_Sound_Delete('SOUND_ANNOUNCER_GOOD2');
2482 g_Sound_Delete('SOUND_ANNOUNCER_GOOD3');
2483 g_Sound_Delete('SOUND_ANNOUNCER_GOOD4');
2490 g_Sound_Delete('SOUND_ANNOUNCER_KILL2X');
2491 g_Sound_Delete('SOUND_ANNOUNCER_KILL3X');
2492 g_Sound_Delete('SOUND_ANNOUNCER_KILL4X');
2493 g_Sound_Delete('SOUND_ANNOUNCER_KILLMX');
2499 g_Sound_Delete('SOUND_ANNOUNCER_MUHAHA1');
2500 g_Sound_Delete('SOUND_ANNOUNCER_MUHAHA2');
2501 g_Sound_Delete('SOUND_ANNOUNCER_MUHAHA3');
2503 sound_get_flag
[0].Free();
2504 sound_get_flag
[1].Free();
2505 sound_lost_flag
[0].Free();
2506 sound_lost_flag
[1].Free();
2507 sound_ret_flag
[0].Free();
2508 sound_ret_flag
[1].Free();
2509 sound_cap_flag
[0].Free();
2510 sound_cap_flag
[1].Free();
2512 g_Sound_Delete('SOUND_CTF_GET1');
2513 g_Sound_Delete('SOUND_CTF_GET2');
2514 g_Sound_Delete('SOUND_CTF_LOST1');
2515 g_Sound_Delete('SOUND_CTF_LOST2');
2516 g_Sound_Delete('SOUND_CTF_RETURN1');
2517 g_Sound_Delete('SOUND_CTF_RETURN2');
2518 g_Sound_Delete('SOUND_CTF_CAPTURE1');
2519 g_Sound_Delete('SOUND_CTF_CAPTURE2');
2521 g_Game_FreeChatSounds();
2523 DataLoaded
:= False;
2526 procedure DrawCustomStat();
2532 ww2
, hh2
, r
, g
, b
, rr
, gg
, bb
: Byte;
2533 s1
, s2
, topstr
: String;
2535 e_TextureFontGetSize(gStdFont
, ww2
, hh2
);
2537 g_ProcessMessages();
2539 if g_Console_Action(ACTION_SCORES
) then
2541 if not gStatsPressed
then
2543 gStatsOff
:= not gStatsOff
;
2544 gStatsPressed
:= True;
2548 gStatsPressed
:= False;
2552 s1
:= _lc
[I_MENU_INTER_NOTICE_TAB
];
2553 w
:= (Length(s1
) * ww2
) div 2;
2554 x
:= gScreenWidth
div 2 - w
;
2556 e_TextureFontPrint(x
, y
, s1
, gStdFont
);
2560 if (gGameSettings
.GameMode
= GM_COOP
) then
2562 if gMissionFailed
then
2563 topstr
:= _lc
[I_MENU_INTER_MISSION_FAIL
]
2565 topstr
:= _lc
[I_MENU_INTER_LEVEL_COMPLETE
];
2568 topstr
:= _lc
[I_MENU_INTER_ROUND_OVER
];
2570 e_CharFont_GetSize(gMenuFont
, topstr
, ww1
, hh1
);
2571 e_CharFont_Print(gMenuFont
, (gScreenWidth
div 2)-(ww1
div 2), 16, topstr
);
2573 if g_Game_IsNet
then
2575 topstr
:= Format(_lc
[I_MENU_INTER_NOTICE_TIME
], [gServInterTime
]);
2576 if not gChatShow
then
2577 e_TextureFontPrintEx((gScreenWidth
div 2)-(Length(topstr
)*ww2
div 2),
2578 gScreenHeight
-(hh2
+4)*2, topstr
, gStdFont
, 255, 255, 255, 1);
2581 if g_Game_IsClient
then
2582 topstr
:= _lc
[I_MENU_INTER_NOTICE_MAP
]
2584 topstr
:= _lc
[I_MENU_INTER_NOTICE_SPACE
];
2585 if not gChatShow
then
2586 e_TextureFontPrintEx((gScreenWidth
div 2)-(Length(topstr
)*ww2
div 2),
2587 gScreenHeight
-(hh2
+4), topstr
, gStdFont
, 255, 255, 255, 1);
2592 w
:= gScreenWidth
-x
*2;
2598 e_DrawFillQuad(x
, y
, gScreenWidth
-x
-1, gScreenHeight
-y
-1, 64, 64, 64, 32);
2599 e_DrawQuad(x
, y
, gScreenWidth
-x
-1, gScreenHeight
-y
-1, 255, 127, 0);
2601 m
:= Max(Length(_lc
[I_MENU_MAP
])+1, Length(_lc
[I_GAME_GAME_TIME
])+1)*ww2
;
2603 case CustomStat
.GameMode
of
2606 if gGameSettings
.MaxLives
= 0 then
2607 s1
:= _lc
[I_GAME_DM
]
2609 s1
:= _lc
[I_GAME_LMS
];
2613 if gGameSettings
.MaxLives
= 0 then
2614 s1
:= _lc
[I_GAME_TDM
]
2616 s1
:= _lc
[I_GAME_TLMS
];
2618 GM_CTF
: s1
:= _lc
[I_GAME_CTF
];
2621 if gGameSettings
.MaxLives
= 0 then
2622 s1
:= _lc
[I_GAME_COOP
]
2624 s1
:= _lc
[I_GAME_SURV
];
2630 e_TextureFontPrintEx(x
+(w
div 2)-(Length(s1
)*ww2
div 2), _y
, s1
, gStdFont
, 255, 255, 255, 1);
2634 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_MENU_MAP
], gStdFont
, 255, 127, 0, 1);
2635 e_TextureFontPrint(x
+8+m
, _y
, Format('%s - %s', [CustomStat
.Map
, CustomStat
.MapName
]), gStdFont
);
2638 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_GAME_TIME
], gStdFont
, 255, 127, 0, 1);
2639 e_TextureFontPrint(x
+8+m
, _y
, Format('%d:%.2d:%.2d', [CustomStat
.GameTime
div 1000 div 3600,
2640 (CustomStat
.GameTime
div 1000 div 60) mod 60,
2641 CustomStat
.GameTime
div 1000 mod 60]), gStdFont
);
2643 pc
:= Length(CustomStat
.PlayerStat
);
2644 if pc
= 0 then Exit
;
2646 if CustomStat
.GameMode
= GM_COOP
then
2648 m
:= Max(Length(_lc
[I_GAME_MONSTERS
])+1, Length(_lc
[I_GAME_SECRETS
])+1)*ww2
;
2650 s2
:= _lc
[I_GAME_MONSTERS
];
2651 e_TextureFontPrintEx(x
+8, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2652 e_TextureFontPrintEx(x
+8+m
, _y
, IntToStr(gCoopMonstersKilled
) + '/' + IntToStr(gTotalMonsters
), gStdFont
, 255, 255, 255, 1);
2654 s2
:= _lc
[I_GAME_SECRETS
];
2655 e_TextureFontPrintEx(x
+8, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2656 e_TextureFontPrintEx(x
+8+m
, _y
, IntToStr(gCoopSecretsFound
) + '/' + IntToStr(gSecretsCount
), gStdFont
, 255, 255, 255, 1);
2659 m
:= Max(Length(_lc
[I_GAME_MONSTERS_TOTAL
])+1, Length(_lc
[I_GAME_SECRETS_TOTAL
])+1)*ww2
;
2661 s2
:= _lc
[I_GAME_MONSTERS_TOTAL
];
2662 e_TextureFontPrintEx(x
+250, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2663 e_TextureFontPrintEx(x
+250+m
, _y
, IntToStr(gCoopTotalMonstersKilled
) + '/' + IntToStr(gCoopTotalMonsters
), gStdFont
, 255, 255, 255, 1);
2665 s2
:= _lc
[I_GAME_SECRETS_TOTAL
];
2666 e_TextureFontPrintEx(x
+250, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2667 e_TextureFontPrintEx(x
+250+m
, _y
, IntToStr(gCoopTotalSecretsFound
) + '/' + IntToStr(gCoopTotalSecrets
), gStdFont
, 255, 255, 255, 1);
2671 if CustomStat
.GameMode
in [GM_TDM
, GM_CTF
] then
2676 if TeamStat
[TEAM_RED
].Goals
> TeamStat
[TEAM_BLUE
].Goals
then s1
:= _lc
[I_GAME_WIN_RED
]
2677 else if TeamStat
[TEAM_BLUE
].Goals
> TeamStat
[TEAM_RED
].Goals
then s1
:= _lc
[I_GAME_WIN_BLUE
]
2678 else s1
:= _lc
[I_GAME_WIN_DRAW
];
2680 e_TextureFontPrintEx(x
+8+(w
div 2)-(Length(s1
)*ww2
div 2), _y
, s1
, gStdFont
, 255, 255, 255, 1);
2683 for t
:= TEAM_RED
to TEAM_BLUE
do
2685 if t
= TEAM_RED
then
2687 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_TEAM_RED
],
2688 gStdFont
, 255, 0, 0, 1);
2689 e_TextureFontPrintEx(x
+w1
+8, _y
, IntToStr(CustomStat
.TeamStat
[TEAM_RED
].Goals
),
2690 gStdFont
, 255, 0, 0, 1);
2697 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_TEAM_BLUE
],
2698 gStdFont
, 0, 0, 255, 1);
2699 e_TextureFontPrintEx(x
+w1
+8, _y
, IntToStr(CustomStat
.TeamStat
[TEAM_BLUE
].Goals
),
2700 gStdFont
, 0, 0, 255, 1);
2706 e_DrawLine(1, x
+8, _y
+20, x
-8+w
, _y
+20, r
, g
, b
);
2709 for p
:= 0 to High(CustomStat
.PlayerStat
) do
2710 if CustomStat
.PlayerStat
[p
].Team
= t
then
2711 with CustomStat
.PlayerStat
[p
] do
2725 if (gPlayers
[Num
] <> nil) and (gPlayers
[Num
].FReady
) then
2726 e_TextureFontPrintEx(x
+16, _y
, Name
+ ' *', gStdFont
, rr
, gg
, bb
, 1)
2728 e_TextureFontPrintEx(x
+16, _y
, Name
, gStdFont
, rr
, gg
, bb
, 1);
2729 e_TextureFontPrintEx(x
+w1
+16, _y
, IntToStr(Frags
), gStdFont
, rr
, gg
, bb
, 1);
2730 e_TextureFontPrintEx(x
+w1
+w2
+16, _y
, IntToStr(Deaths
), gStdFont
, rr
, gg
, bb
, 1);
2737 else if CustomStat
.GameMode
in [GM_DM
, GM_COOP
] then
2740 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_PLAYER_NAME
], gStdFont
, 255, 127, 0, 1);
2741 e_TextureFontPrintEx(x
+8+w1
, _y
, _lc
[I_GAME_FRAGS
], gStdFont
, 255, 127, 0, 1);
2742 e_TextureFontPrintEx(x
+8+w1
+w2
, _y
, _lc
[I_GAME_DEATHS
], gStdFont
, 255, 127, 0, 1);
2745 for p
:= 0 to High(CustomStat
.PlayerStat
) do
2746 with CustomStat
.PlayerStat
[p
] do
2748 e_DrawFillQuad(x
+8, _y
+4, x
+24-1, _y
+16+4-1, Color
.R
, Color
.G
, Color
.B
, 0);
2755 if (gPlayers
[Num
] <> nil) and (gPlayers
[Num
].FReady
) then
2756 e_TextureFontPrintEx(x
+8+16+8, _y
+4, Name
+ ' *', gStdFont
, r
, r
, r
, 1, True)
2758 e_TextureFontPrintEx(x
+8+16+8, _y
+4, Name
, gStdFont
, r
, r
, r
, 1, True);
2759 e_TextureFontPrintEx(x
+w1
+8+16+8, _y
+4, IntToStr(Frags
), gStdFont
, r
, r
, r
, 1, True);
2760 e_TextureFontPrintEx(x
+w1
+w2
+8+16+8, _y
+4, IntToStr(Deaths
), gStdFont
, r
, r
, r
, 1, True);
2766 procedure DrawSingleStat();
2768 tm
, key_x
, val_x
, y
: Integer;
2772 procedure player_stat(n
: Integer);
2778 s1
:= Format(' %d ', [SingleStat
.PlayerStat
[n
].Kills
]);
2779 s2
:= Format(' %d', [gTotalMonsters
]);
2781 e_CharFont_Print(gMenuFont
, key_x
, y
, _lc
[I_MENU_INTER_KILLS
]);
2782 e_CharFont_PrintEx(gMenuFont
, val_x
, y
, s1
, _RGB(255, 0, 0));
2783 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2784 e_CharFont_Print(gMenuFont
, val_x
+w1
, y
, '/');
2786 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2787 e_CharFont_PrintEx(gMenuFont
, val_x
+w1
, y
, s2
, _RGB(255, 0, 0));
2789 // "Kills-per-minute: ##.#":
2790 s1
:= _lc
[I_MENU_INTER_KPM
];
2792 kpm
:= (SingleStat
.PlayerStat
[n
].Kills
/ tm
) * 60
2794 kpm
:= SingleStat
.PlayerStat
[n
].Kills
;
2795 s2
:= Format(' %.1f', [kpm
]);
2797 e_CharFont_Print(gMenuFont
, key_x
, y
+32, s1
);
2798 e_CharFont_PrintEx(gMenuFont
, val_x
, y
+32, s2
, _RGB(255, 0, 0));
2800 // "Secrets found: # / #":
2801 s1
:= Format(' %d ', [SingleStat
.PlayerStat
[n
].Secrets
]);
2802 s2
:= Format(' %d', [SingleStat
.TotalSecrets
]);
2804 e_CharFont_Print(gMenuFont
, key_x
, y
+64, _lc
[I_MENU_INTER_SECRETS
]);
2805 e_CharFont_PrintEx(gMenuFont
, val_x
, y
+64, s1
, _RGB(255, 0, 0));
2806 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2807 e_CharFont_Print(gMenuFont
, val_x
+w1
, y
+64, '/');
2809 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2810 e_CharFont_PrintEx(gMenuFont
, val_x
+w1
, y
+64, s2
, _RGB(255, 0, 0));
2814 // "Level Complete":
2815 e_CharFont_GetSize(gMenuFont
, _lc
[I_MENU_INTER_LEVEL_COMPLETE
], w1
, h
);
2816 e_CharFont_Print(gMenuFont
, (gScreenWidth
-w1
) div 2, 32, _lc
[I_MENU_INTER_LEVEL_COMPLETE
]);
2818 // Îïðåäåëÿåì êîîðäèíàòû âûðàâíèâàíèÿ ïî ñàìîé äëèííîé ñòðîêå:
2819 s1
:= _lc
[I_MENU_INTER_KPM
];
2820 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2823 e_CharFont_GetSize(gMenuFont
, s1
, w2
, h
);
2825 key_x
:= (gScreenWidth
-w1
-w2
) div 2;
2826 val_x
:= key_x
+ w1
;
2829 tm
:= SingleStat
.GameTime
div 1000;
2830 s1
:= _lc
[I_MENU_INTER_TIME
];
2831 s2
:= Format(' %d:%.2d:%.2d', [tm
div (60*60), (tm
mod (60*60)) div 60, tm
mod 60]);
2833 e_CharFont_Print(gMenuFont
, key_x
, 80, s1
);
2834 e_CharFont_PrintEx(gMenuFont
, val_x
, 80, s2
, _RGB(255, 0, 0));
2836 if SingleStat
.TwoPlayers
then
2839 s1
:= _lc
[I_MENU_PLAYER_1
];
2840 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2841 e_CharFont_Print(gMenuFont
, (gScreenWidth
-w1
) div 2, 128, s1
);
2843 // Ñòàòèñòèêà ïåðâîãî èãðîêà:
2848 s1
:= _lc
[I_MENU_PLAYER_2
];
2849 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2850 e_CharFont_Print(gMenuFont
, (gScreenWidth
-w1
) div 2, 288, s1
);
2852 // Ñòàòèñòèêà âòîðîãî èãðîêà:
2858 // Ñòàòèñòèêà ïåðâîãî èãðîêà:
2864 procedure DrawLoadingStat();
2865 procedure drawRect (x
, y
, w
, h
: Integer);
2867 if (w
< 1) or (h
< 1) then exit
;
2869 glVertex2f(x
+0.375, y
+0.375);
2870 glVertex2f(x
+w
+0.375, y
+0.375);
2871 glVertex2f(x
+w
+0.375, y
+h
+0.375);
2872 glVertex2f(x
+0.375, y
+h
+0.375);
2876 function drawPBar (cur
, total
: Integer; washere
: Boolean): Boolean;
2878 rectW
, rectH
: Integer;
2885 idl
, idr
, idb
, idm
: LongWord;
2889 if (total
< 1) then exit
;
2890 if (cur
< 1) then exit
; // don't blink
2891 if (not washere
) and (cur
>= total
) then exit
; // don't blink
2892 //if (cur < 0) then cur := 0;
2893 //if (cur > total) then cur := total;
2896 if (hasPBarGfx
) then
2898 g_Texture_Get('UI_GFX_PBAR_LEFT', idl
);
2899 g_Texture_GetSize('UI_GFX_PBAR_LEFT', wl
, hl
);
2900 g_Texture_Get('UI_GFX_PBAR_RIGHT', idr
);
2901 g_Texture_GetSize('UI_GFX_PBAR_RIGHT', wr
, hr
);
2902 g_Texture_Get('UI_GFX_PBAR_MIDDLE', idb
);
2903 g_Texture_GetSize('UI_GFX_PBAR_MIDDLE', wb
, hb
);
2904 g_Texture_Get('UI_GFX_PBAR_MARKER', idm
);
2905 g_Texture_GetSize('UI_GFX_PBAR_MARKER', wm
, hm
);
2907 //rectW := gScreenWidth-360;
2908 rectW
:= trunc(624.0*gScreenWidth
/1024.0);
2911 x0
:= (gScreenWidth
-rectW
) div 2;
2912 y0
:= gScreenHeight
-rectH
-64;
2913 if (y0
< 2) then y0
:= 2;
2915 glEnable(GL_SCISSOR_TEST
);
2918 glScissor(x0
, gScreenHeight
-y0
-rectH
, rectW
, rectH
);
2919 e_DrawSize(idl
, x0
, y0
, 0, true, false, wl
, hl
);
2920 e_DrawSize(idr
, x0
+rectW
-wr
, y0
, 0, true, false, wr
, hr
);
2923 glScissor(x0
+wl
, gScreenHeight
-y0
-rectH
, rectW
-wl
-wr
, rectH
);
2925 while (f
< x0
+rectW
) do
2927 e_DrawSize(idb
, f
, y0
, 0, true, false, wb
, hb
);
2932 wdt
:= (rectW
-wl
-wr
)*cur
div total
;
2933 if (wdt
> rectW
-wl
-wr
) then wdt
:= rectW
-wr
-wr
;
2936 my
:= y0
; // don't be so smart, ketmar: +(rectH-wm) div 2;
2937 glScissor(x0
+wl
, gScreenHeight
-my
-rectH
, wdt
, hm
);
2941 e_DrawSize(idm
, f
, y0
, 0, true, false, wm
, hm
);
2947 glScissor(0, 0, gScreenWidth
, gScreenHeight
);
2951 rectW
:= gScreenWidth
-64;
2954 x0
:= (gScreenWidth
-rectW
) div 2;
2955 y0
:= gScreenHeight
-rectH
-64;
2956 if (y0
< 2) then y0
:= 2;
2958 glDisable(GL_BLEND
);
2959 glDisable(GL_TEXTURE_2D
);
2961 //glClearColor(0, 0, 0, 0);
2962 //glClear(GL_COLOR_BUFFER_BIT);
2964 glColor4ub(127, 127, 127, 255);
2965 drawRect(x0
-2, y0
-2, rectW
+4, rectH
+4);
2967 glColor4ub(0, 0, 0, 255);
2968 drawRect(x0
-1, y0
-1, rectW
+2, rectH
+2);
2970 glColor4ub(127, 127, 127, 255);
2971 wdt
:= rectW
*cur
div total
;
2972 if (wdt
> rectW
) then wdt
:= rectW
;
2973 drawRect(x0
, y0
, wdt
, rectH
);
2982 if (Length(LoadingStat
.Msgs
) = 0) then exit
;
2984 e_CharFont_GetSize(gMenuFont
, _lc
[I_MENU_LOADING
], ww
, hh
);
2985 yy
:= (gScreenHeight
div 3);
2986 e_CharFont_Print(gMenuFont
, (gScreenWidth
div 2)-(ww
div 2), yy
-2*hh
, _lc
[I_MENU_LOADING
]);
2987 xx
:= (gScreenWidth
div 3);
2991 for i
:= 0 to NextMsg
-1 do
2993 if (i
= (NextMsg
-1)) and (MaxValue
> 0) then
2994 s
:= Format('%s: %d/%d', [Msgs
[i
], CurValue
, MaxValue
])
2998 e_CharFont_PrintEx(gMenuSmallFont
, xx
, yy
, s
, _RGB(255, 0, 0));
2999 yy
:= yy
+ LOADING_INTERLINE
;
3000 PBarWasHere
:= drawPBar(CurValue
, MaxValue
, PBarWasHere
);
3005 procedure DrawMinimap(p
: TPlayer
; RenderRect
: e_graphics
.TRect
);
3007 a
, aX
, aY
, aX2
, aY2
, Scale
, ScaleSz
: Integer;
3009 function monDraw (mon
: TMonster
): Boolean;
3011 result
:= false; // don't stop
3016 // Ëåâûé âåðõíèé óãîë
3017 aX
:= Obj
.X
div ScaleSz
+ 1;
3018 aY
:= Obj
.Y
div ScaleSz
+ 1;
3020 aX2
:= max(Obj
.Rect
.Width
div ScaleSz
, 1);
3021 aY2
:= max(Obj
.Rect
.Height
div ScaleSz
, 1);
3022 // Ïðàâûé íèæíèé óãîë
3023 aX2
:= aX
+ aX2
- 1;
3024 aY2
:= aY
+ aY2
- 1;
3025 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 255, 0, 0);
3031 if (gMapInfo
.Width
> RenderRect
.Right
- RenderRect
.Left
) or
3032 (gMapInfo
.Height
> RenderRect
.Bottom
- RenderRect
.Top
) then
3035 // Ñêîëüêî ïèêñåëîâ êàðòû â 1 ïèêñåëå ìèíè-êàðòû:
3036 ScaleSz
:= 16 div Scale
;
3037 // Ðàçìåðû ìèíè-êàðòû:
3038 aX
:= max(gMapInfo
.Width
div ScaleSz
, 1);
3039 aY
:= max(gMapInfo
.Height
div ScaleSz
, 1);
3041 e_DrawFillQuad(0, 0, aX
-1, aY
-1, 0, 0, 0, 0);
3043 if gWalls
<> nil then
3046 for a
:= 0 to High(gWalls
) do
3048 if PanelType
<> 0 then
3050 // Ëåâûé âåðõíèé óãîë:
3051 aX
:= X
div ScaleSz
;
3052 aY
:= Y
div ScaleSz
;
3054 aX2
:= max(Width
div ScaleSz
, 1);
3055 aY2
:= max(Height
div ScaleSz
, 1);
3056 // Ïðàâûé íèæíèé óãîë:
3057 aX2
:= aX
+ aX2
- 1;
3058 aY2
:= aY
+ aY2
- 1;
3061 PANEL_WALL
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 208, 208, 208, 0);
3062 PANEL_OPENDOOR
, PANEL_CLOSEDOOR
:
3063 if Enabled
then e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 160, 160, 160, 0);
3067 if gSteps
<> nil then
3070 for a
:= 0 to High(gSteps
) do
3072 if PanelType
<> 0 then
3074 // Ëåâûé âåðõíèé óãîë:
3075 aX
:= X
div ScaleSz
;
3076 aY
:= Y
div ScaleSz
;
3078 aX2
:= max(Width
div ScaleSz
, 1);
3079 aY2
:= max(Height
div ScaleSz
, 1);
3080 // Ïðàâûé íèæíèé óãîë:
3081 aX2
:= aX
+ aX2
- 1;
3082 aY2
:= aY
+ aY2
- 1;
3084 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 128, 128, 128, 0);
3087 if gLifts
<> nil then
3090 for a
:= 0 to High(gLifts
) do
3092 if PanelType
<> 0 then
3094 // Ëåâûé âåðõíèé óãîë:
3095 aX
:= X
div ScaleSz
;
3096 aY
:= Y
div ScaleSz
;
3098 aX2
:= max(Width
div ScaleSz
, 1);
3099 aY2
:= max(Height
div ScaleSz
, 1);
3100 // Ïðàâûé íèæíèé óãîë:
3101 aX2
:= aX
+ aX2
- 1;
3102 aY2
:= aY
+ aY2
- 1;
3105 LIFTTYPE_UP
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 116, 72, 36, 0);
3106 LIFTTYPE_DOWN
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 116, 124, 96, 0);
3107 LIFTTYPE_LEFT
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 200, 80, 4, 0);
3108 LIFTTYPE_RIGHT
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 252, 140, 56, 0);
3112 if gWater
<> nil then
3115 for a
:= 0 to High(gWater
) do
3117 if PanelType
<> 0 then
3119 // Ëåâûé âåðõíèé óãîë:
3120 aX
:= X
div ScaleSz
;
3121 aY
:= Y
div ScaleSz
;
3123 aX2
:= max(Width
div ScaleSz
, 1);
3124 aY2
:= max(Height
div ScaleSz
, 1);
3125 // Ïðàâûé íèæíèé óãîë:
3126 aX2
:= aX
+ aX2
- 1;
3127 aY2
:= aY
+ aY2
- 1;
3129 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 0, 192, 0);
3132 if gAcid1
<> nil then
3134 // Ðèñóåì êèñëîòó 1:
3135 for a
:= 0 to High(gAcid1
) do
3137 if PanelType
<> 0 then
3139 // Ëåâûé âåðõíèé óãîë:
3140 aX
:= X
div ScaleSz
;
3141 aY
:= Y
div ScaleSz
;
3143 aX2
:= max(Width
div ScaleSz
, 1);
3144 aY2
:= max(Height
div ScaleSz
, 1);
3145 // Ïðàâûé íèæíèé óãîë:
3146 aX2
:= aX
+ aX2
- 1;
3147 aY2
:= aY
+ aY2
- 1;
3149 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 176, 0, 0);
3152 if gAcid2
<> nil then
3154 // Ðèñóåì êèñëîòó 2:
3155 for a
:= 0 to High(gAcid2
) do
3157 if PanelType
<> 0 then
3159 // Ëåâûé âåðõíèé óãîë:
3160 aX
:= X
div ScaleSz
;
3161 aY
:= Y
div ScaleSz
;
3163 aX2
:= max(Width
div ScaleSz
, 1);
3164 aY2
:= max(Height
div ScaleSz
, 1);
3165 // Ïðàâûé íèæíèé óãîë:
3166 aX2
:= aX
+ aX2
- 1;
3167 aY2
:= aY
+ aY2
- 1;
3169 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 176, 0, 0, 0);
3172 if gPlayers
<> nil then
3175 for a
:= 0 to High(gPlayers
) do
3176 if gPlayers
[a
] <> nil then with gPlayers
[a
] do
3178 // Ëåâûé âåðõíèé óãîë:
3179 aX
:= Obj
.X
div ScaleSz
+ 1;
3180 aY
:= Obj
.Y
div ScaleSz
+ 1;
3182 aX2
:= max(Obj
.Rect
.Width
div ScaleSz
, 1);
3183 aY2
:= max(Obj
.Rect
.Height
div ScaleSz
, 1);
3184 // Ïðàâûé íèæíèé óãîë:
3185 aX2
:= aX
+ aX2
- 1;
3186 aY2
:= aY
+ aY2
- 1;
3188 if gPlayers
[a
] = p
then
3189 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 255, 0, 0)
3192 TEAM_RED
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 0, 0, 0);
3193 TEAM_BLUE
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 0, 255, 0);
3194 else e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 128, 0, 0);
3199 g_Mons_ForEach(monDraw
);
3204 procedure renderAmbientQuad (hasAmbient
: Boolean; constref ambColor
: TDFColor
);
3206 if not hasAmbient
then exit
;
3207 e_AmbientQuad(sX
, sY
, sWidth
, sHeight
, ambColor
.r
, ambColor
.g
, ambColor
.b
, ambColor
.a
);
3211 // setup sX, sY, sWidth, sHeight, and transformation matrix before calling this!
3212 //FIXME: broken for splitscreen mode
3213 procedure renderDynLightsInternal ();
3215 //hasAmbient: Boolean;
3216 //ambColor: TDFColor;
3218 lx
, ly
, lrad
: Integer;
3219 scxywh
: array[0..3] of GLint
;
3222 if e_NoGraphics
then exit
;
3224 //TODO: lights should be in separate grid, i think
3225 // but on the other side: grid may be slower for dynlights, as their lifetime is short
3226 if (not gwin_k8_enable_light_experiments
) or (not gwin_has_stencil
) or (g_dynLightCount
< 1) then exit
;
3229 //ambColor := gCurrentMap['light_ambient'].rgba;
3230 //hasAmbient := (not ambColor.isOpaque) or (not ambColor.isBlack);
3232 { // this will multiply incoming color to alpha from framebuffer
3234 glBlendFunc(GL_DST_ALPHA, GL_ONE);
3238 * light rendering: (INVALID!)
3239 * glStencilFunc(GL_EQUAL, 0, $ff);
3241 * glClear(GL_STENCIL_BUFFER_BIT);
3242 * glStencilOp(GL_KEEP, GL_KEEP, GL_INCR);
3243 * draw shadow volume into stencil buffer
3244 * glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); // modify color buffer
3245 * glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); // don't modify stencil buffer
3247 * draw color-less quad with light alpha (WARNING! don't touch color!)
3248 * glEnable(GL_BLEND);
3249 * glBlendFunc(GL_DST_ALPHA, GL_ONE);
3250 * draw all geometry up to and including walls (with alpha-testing, probably) -- this does lighting
3252 wassc
:= (glIsEnabled(GL_SCISSOR_TEST
) <> 0);
3253 if wassc
then glGetIntegerv(GL_SCISSOR_BOX
, @scxywh
[0]) else glGetIntegerv(GL_VIEWPORT
, @scxywh
[0]);
3255 // setup OpenGL parameters
3256 glStencilMask($FFFFFFFF);
3257 glStencilFunc(GL_ALWAYS
, 0, $FFFFFFFF);
3258 glEnable(GL_STENCIL_TEST
);
3259 glEnable(GL_SCISSOR_TEST
);
3260 glClear(GL_STENCIL_BUFFER_BIT
);
3261 glStencilFunc(GL_EQUAL
, 0, $ff);
3263 for lln
:= 0 to g_dynLightCount
-1 do
3265 lx
:= g_dynLights
[lln
].x
;
3266 ly
:= g_dynLights
[lln
].y
;
3267 lrad
:= g_dynLights
[lln
].radius
;
3268 if (lrad
< 3) then continue
;
3270 if (lx
-sX
+lrad
< 0) then continue
;
3271 if (ly
-sY
+lrad
< 0) then continue
;
3272 if (lx
-sX
-lrad
>= gPlayerScreenSize
.X
) then continue
;
3273 if (ly
-sY
-lrad
>= gPlayerScreenSize
.Y
) then continue
;
3275 // set scissor to optimize drawing
3276 if (g_dbg_scale
= 1.0) then
3278 glScissor((lx
-sX
)-lrad
+2, gPlayerScreenSize
.Y
-(ly
-sY
)-lrad
-1+2, lrad
*2-4, lrad
*2-4);
3282 glScissor(0, 0, gWinSizeX
, gWinSizeY
);
3284 // no need to clear stencil buffer, light blitting will do it for us... but only for normal scale
3285 if (g_dbg_scale
<> 1.0) then glClear(GL_STENCIL_BUFFER_BIT
);
3286 glStencilOp(GL_KEEP
, GL_KEEP
, GL_INCR
);
3287 // draw extruded panels
3288 glDisable(GL_TEXTURE_2D
);
3289 glDisable(GL_BLEND
);
3290 glColorMask(GL_FALSE
, GL_FALSE
, GL_FALSE
, GL_FALSE
); // no need to modify color buffer
3291 if (lrad
> 4) then g_Map_DrawPanelShadowVolumes(lx
, ly
, lrad
);
3292 // render light texture
3293 glColorMask(GL_TRUE
, GL_TRUE
, GL_TRUE
, GL_TRUE
); // modify color buffer
3294 glStencilOp(GL_ZERO
, GL_ZERO
, GL_ZERO
); // draw light, and clear stencil buffer
3297 glBlendFunc(GL_SRC_ALPHA
, GL_ONE_MINUS_SRC_ALPHA
);
3298 glEnable(GL_TEXTURE_2D
);
3299 // color and opacity
3300 glColor4f(g_dynLights
[lln
].r
, g_dynLights
[lln
].g
, g_dynLights
[lln
].b
, g_dynLights
[lln
].a
);
3301 glBindTexture(GL_TEXTURE_2D
, g_Texture_Light());
3303 glTexCoord2f(0.0, 0.0); glVertex2i(lx
-lrad
, ly
-lrad
); // top-left
3304 glTexCoord2f(1.0, 0.0); glVertex2i(lx
+lrad
, ly
-lrad
); // top-right
3305 glTexCoord2f(1.0, 1.0); glVertex2i(lx
+lrad
, ly
+lrad
); // bottom-right
3306 glTexCoord2f(0.0, 1.0); glVertex2i(lx
-lrad
, ly
+lrad
); // bottom-left
3311 glDisable(GL_STENCIL_TEST
);
3312 glDisable(GL_BLEND
);
3313 glDisable(GL_SCISSOR_TEST
);
3314 //glScissor(0, 0, sWidth, sHeight);
3316 glScissor(scxywh
[0], scxywh
[1], scxywh
[2], scxywh
[3]);
3317 if wassc
then glEnable(GL_SCISSOR_TEST
) else glDisable(GL_SCISSOR_TEST
);
3321 function fixViewportForScale (): Boolean;
3323 nx0
, ny0
, nw
, nh
: Integer;
3326 if (g_dbg_scale
<> 1.0) then
3329 nx0
:= round(sX
-(gPlayerScreenSize
.X
-(sWidth
*g_dbg_scale
))/2/g_dbg_scale
);
3330 ny0
:= round(sY
-(gPlayerScreenSize
.Y
-(sHeight
*g_dbg_scale
))/2/g_dbg_scale
);
3331 nw
:= round(sWidth
/g_dbg_scale
);
3332 nh
:= round(sHeight
/g_dbg_scale
);
3341 // setup sX, sY, sWidth, sHeight, and transformation matrix before calling this!
3342 // WARNING! this WILL CALL `glTranslatef()`, but won't restore matrices!
3343 procedure renderMapInternal (backXOfs
, backYOfs
: Integer; setTransMatrix
: Boolean);
3345 TDrawCB
= procedure ();
3348 hasAmbient
: Boolean;
3350 doAmbient
: Boolean = false;
3352 procedure drawPanelType (profname
: AnsiString; panType
: DWord
; doDraw
: Boolean);
3357 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin(profname
);
3358 if gdbg_map_use_accel_render
then
3360 tagmask
:= panelTypeToTag(panType
);
3361 while (gDrawPanelList
.count
> 0) do
3363 pan
:= TPanel(gDrawPanelList
.front());
3364 if ((pan
.tag
and tagmask
) = 0) then break
;
3365 if doDraw
then pan
.Draw(doAmbient
, ambColor
);
3366 gDrawPanelList
.popFront();
3371 if doDraw
then g_Map_DrawPanels(panType
, hasAmbient
, ambColor
);
3373 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
3376 procedure drawOther (profname
: AnsiString; cb
: TDrawCB
);
3378 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin(profname
);
3379 if assigned(cb
) then cb();
3380 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
3384 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin('total');
3386 // our accelerated renderer will collect all panels to gDrawPanelList
3387 // we can use panel tag to render level parts (see GridTagXXX in g_map.pas)
3388 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin('collect');
3389 if gdbg_map_use_accel_render
then
3391 g_Map_CollectDrawPanels(sX
, sY
, sWidth
, sHeight
);
3393 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
3395 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin('skyback');
3396 g_Map_DrawBack(backXOfs
, backYOfs
);
3397 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
3399 if setTransMatrix
then
3401 //if (g_dbg_scale <> 1.0) then glTranslatef(0.0, -0.375/2, 0);
3402 glScalef(g_dbg_scale
, g_dbg_scale
, 1.0);
3403 glTranslatef(-sX
, -sY
, 0);
3407 ambColor
:= gCurrentMap
['light_ambient'].rgba
;
3408 hasAmbient
:= (not ambColor
.isOpaque
) or (not ambColor
.isBlack
);
3413 //writeln('color: (', ambColor.r, ',', ambColor.g, ',', ambColor.b, ',', ambColor.a, ')');
3414 glColor4ub(ambColor.r, ambColor.g, ambColor.b, ambColor.a);
3415 glClear(GL_COLOR_BUFFER_BIT);
3418 //writeln('color: (', ambColor.r, ',', ambColor.g, ',', ambColor.b, ',', ambColor.a, ')');
3421 drawPanelType('*back', PANEL_BACK
, g_rlayer_back
);
3422 drawPanelType('*step', PANEL_STEP
, g_rlayer_step
);
3423 drawOther('items', @g_Items_Draw
);
3424 drawOther('weapons', @g_Weapon_Draw
);
3425 drawOther('shells', @g_Player_DrawShells
);
3426 drawOther('drawall', @g_Player_DrawAll
);
3427 drawOther('corpses', @g_Player_DrawCorpses
);
3428 drawPanelType('*wall', PANEL_WALL
, g_rlayer_wall
);
3429 drawOther('monsters', @g_Monsters_Draw
);
3430 drawOther('itemdrop', @g_Items_DrawDrop
);
3431 drawPanelType('*door', PANEL_CLOSEDOOR
, g_rlayer_door
);
3432 drawOther('gfx', @g_GFX_Draw
);
3433 drawOther('flags', @g_Map_DrawFlags
);
3434 drawPanelType('*acid1', PANEL_ACID1
, g_rlayer_acid1
);
3435 drawPanelType('*acid2', PANEL_ACID2
, g_rlayer_acid2
);
3436 drawPanelType('*water', PANEL_WATER
, g_rlayer_water
);
3437 drawOther('dynlights', @renderDynLightsInternal
);
3439 if hasAmbient
{and ((not g_playerLight) or (not gwin_has_stencil) or (g_dynLightCount < 1))} then
3441 renderAmbientQuad(hasAmbient
, ambColor
);
3445 drawPanelType('*fore', PANEL_FORE
, g_rlayer_fore
);
3448 if g_debug_HealthBar
then
3450 g_Monsters_DrawHealth();
3451 g_Player_DrawHealth();
3454 if (profileFrameDraw
<> nil) then profileFrameDraw
.mainEnd(); // map rendering
3458 procedure DrawMapView(x
, y
, w
, h
: Integer);
3465 bx
:= Round(x
/(gMapInfo
.Width
- w
)*(gBackSize
.X
- w
));
3466 by
:= Round(y
/(gMapInfo
.Height
- h
)*(gBackSize
.Y
- h
));
3473 fixViewportForScale();
3474 renderMapInternal(-bx
, -by
, true);
3480 procedure DrawPlayer(p
: TPlayer
);
3482 px
, py
, a
, b
, c
, d
: Integer;
3485 if (p
= nil) or (p
.FDummy
) then
3488 g_Map_DrawBack(0, 0);
3493 if (profileFrameDraw
= nil) then profileFrameDraw
:= TProfiler
.Create('RENDER', g_profile_history_size
);
3494 if (profileFrameDraw
<> nil) then profileFrameDraw
.mainBegin(g_profile_frame_draw
);
3500 px
:= p
.GameX
+ PLAYER_RECT_CX
;
3501 py
:= p
.GameY
+ PLAYER_RECT_CY
+p
.Obj
.slopeUpLeft
;
3503 if (g_dbg_scale
= 1.0) and (not g_dbg_ignore_bounds
) then
3505 if (px
> (gPlayerScreenSize
.X
div 2)) then a
:= -px
+(gPlayerScreenSize
.X
div 2) else a
:= 0;
3506 if (py
> (gPlayerScreenSize
.Y
div 2)) then b
:= -py
+(gPlayerScreenSize
.Y
div 2) else b
:= 0;
3508 if (px
> gMapInfo
.Width
-(gPlayerScreenSize
.X
div 2)) then a
:= -gMapInfo
.Width
+gPlayerScreenSize
.X
;
3509 if (py
> gMapInfo
.Height
-(gPlayerScreenSize
.Y
div 2)) then b
:= -gMapInfo
.Height
+gPlayerScreenSize
.Y
;
3511 if (gMapInfo
.Width
= gPlayerScreenSize
.X
) then a
:= 0
3512 else if (gMapInfo
.Width
< gPlayerScreenSize
.X
) then
3515 a
:= (gPlayerScreenSize
.X
-gMapInfo
.Width
) div 2;
3518 if (gMapInfo
.Height
= gPlayerScreenSize
.Y
) then b
:= 0
3519 else if (gMapInfo
.Height
< gPlayerScreenSize
.Y
) then
3522 b
:= (gPlayerScreenSize
.Y
-gMapInfo
.Height
) div 2;
3527 // scaled, ignore level bounds
3528 a
:= -px
+(gPlayerScreenSize
.X
div 2);
3529 b
:= -py
+(gPlayerScreenSize
.Y
div 2);
3532 if p
.IncCam
<> 0 then
3534 if py
> gMapInfo
.Height
-(gPlayerScreenSize
.Y
div 2) then
3536 if p
.IncCam
> 120-(py
-(gMapInfo
.Height
-(gPlayerScreenSize
.Y
div 2))) then
3538 p
.IncCam
:= 120-(py
-(gMapInfo
.Height
-(gPlayerScreenSize
.Y
div 2)));
3542 if py
< gPlayerScreenSize
.Y
div 2 then
3544 if p
.IncCam
< -120+((gPlayerScreenSize
.Y
div 2)-py
) then
3546 p
.IncCam
:= -120+((gPlayerScreenSize
.Y
div 2)-py
);
3550 if p
.IncCam
< 0 then
3552 while (py
+(gPlayerScreenSize
.Y
div 2)-p
.IncCam
> gMapInfo
.Height
) and (p
.IncCam
< 0) do p
.IncCam
:= p
.IncCam
+1; //Inc(p.IncCam);
3555 if p
.IncCam
> 0 then
3557 while (py
-(gPlayerScreenSize
.Y
div 2)-p
.IncCam
< 0) and (p
.IncCam
> 0) do p
.IncCam
:= p
.IncCam
-1; //Dec(p.IncCam);
3561 if (px
< gPlayerScreenSize
.X
div 2) or (gMapInfo
.Width
-gPlayerScreenSize
.X
<= 256) then c
:= 0
3562 else if (px
> gMapInfo
.Width
-(gPlayerScreenSize
.X
div 2)) then c
:= gBackSize
.X
-gPlayerScreenSize
.X
3563 else c
:= round((px
-(gPlayerScreenSize
.X
div 2))/(gMapInfo
.Width
-gPlayerScreenSize
.X
)*(gBackSize
.X
-gPlayerScreenSize
.X
));
3565 if (py
-p
.IncCam
<= gPlayerScreenSize
.Y
div 2) or (gMapInfo
.Height
-gPlayerScreenSize
.Y
<= 256) then d
:= 0
3566 else if (py
-p
.IncCam
>= gMapInfo
.Height
-(gPlayerScreenSize
.Y
div 2)) then d
:= gBackSize
.Y
-gPlayerScreenSize
.Y
3567 else d
:= round((py
-p
.IncCam
-(gPlayerScreenSize
.Y
div 2))/(gMapInfo
.Height
-gPlayerScreenSize
.Y
)*(gBackSize
.Y
-gPlayerScreenSize
.Y
));
3570 sY
:= -(b
+p
.IncCam
);
3571 sWidth
:= gPlayerScreenSize
.X
;
3572 sHeight
:= gPlayerScreenSize
.Y
;
3574 //glTranslatef(a, b+p.IncCam, 0);
3576 //if (p = gPlayer1) and (g_dbg_scale >= 1.0) then g_Holmes_plrViewSize(sWidth, sHeight);
3578 //conwritefln('OLD: (%s,%s)-(%s,%s)', [sX, sY, sWidth, sHeight]);
3579 fixViewportForScale();
3580 //conwritefln(' (%s,%s)-(%s,%s)', [sX, sY, sWidth, sHeight]);
3582 if (g_dbg_scale
<> 1.0) and (not g_dbg_ignore_bounds
) then
3584 if (sX
+sWidth
> gMapInfo
.Width
) then sX
:= gMapInfo
.Width
-sWidth
;
3585 if (sY
+sHeight
> gMapInfo
.Height
) then sY
:= gMapInfo
.Height
-sHeight
;
3586 if (sX
< 0) then sX
:= 0;
3587 if (sY
< 0) then sY
:= 0;
3589 if (gBackSize
.X
<= gPlayerScreenSize
.X
) or (gMapInfo
.Width
<= sWidth
) then c
:= 0 else c
:= trunc((gBackSize
.X
-gPlayerScreenSize
.X
)*sX
/(gMapInfo
.Width
-sWidth
));
3590 if (gBackSize
.Y
<= gPlayerScreenSize
.Y
) or (gMapInfo
.Height
<= sHeight
) then d
:= 0 else d
:= trunc((gBackSize
.Y
-gPlayerScreenSize
.Y
)*sY
/(gMapInfo
.Height
-sHeight
));
3593 //r_smallmap_h: 0: left; 1: center; 2: right
3594 //r_smallmap_v: 0: top; 1: center; 2: bottom
3596 if (gMapInfo
.Width
= sWidth
) then
3600 else if (gMapInfo
.Width
< sWidth
) then
3602 case r_smallmap_h
of
3603 1: sX
:= -((sWidth
-gMapInfo
.Width
) div 2); // center
3604 2: sX
:= -(sWidth
-gMapInfo
.Width
); // right
3605 else sX
:= 0; // left
3609 if (gMapInfo
.Height
= sHeight
) then
3613 else if (gMapInfo
.Height
< sHeight
) then
3615 case r_smallmap_v
of
3616 1: sY
:= -((sHeight
-gMapInfo
.Height
) div 2); // center
3617 2: sY
:= -(sHeight
-gMapInfo
.Height
); // bottom
3618 else sY
:= 0; // top
3624 p
.viewPortW
:= sWidth
;
3625 p
.viewPortH
:= sHeight
;
3627 {$IFDEF ENABLE_HOLMES}
3628 if (p
= gPlayer1
) then
3630 g_Holmes_plrViewPos(sX
, sY
);
3631 g_Holmes_plrViewSize(sWidth
, sHeight
);
3635 renderMapInternal(-c
, -d
, true);
3637 if (gGameSettings
.GameMode
<> GM_SINGLE
) and gPlayerIndicator
then
3639 if p
.FSpectator
then
3640 e_TextureFontPrintEx(p
.GameX
+ PLAYER_RECT_CX
- 4,
3641 p
.GameY
+ PLAYER_RECT_CY
- 4,
3642 'X', gStdFont
, 255, 255, 255, 1, True);
3644 for a := 0 to High(gCollideMap) do
3645 for b := 0 to High(gCollideMap[a]) do
3648 if ByteBool(gCollideMap[a, b] and MARK_WALL) then
3650 if ByteBool(gCollideMap[a, b] and MARK_DOOR) then
3654 1: e_DrawPoint(1, b, a, 200, 200, 200);
3655 2: e_DrawPoint(1, b, a, 64, 64, 255);
3656 3: e_DrawPoint(1, b, a, 255, 0, 255);
3666 if gShowMap
then DrawMinimap(p
, _TRect(0, 0, 128, 128));
3667 if g_Debug_Player
then
3668 g_Player_DrawDebug(p
);
3672 procedure drawProfilers ();
3677 if g_profile_frame_draw
and (profileFrameDraw
<> nil) then px
:= px
-drawProfiles(px
, py
, profileFrameDraw
);
3678 if g_profile_collision
and (profMapCollision
<> nil) then begin px
:= px
-drawProfiles(px
, py
, profMapCollision
); py
-= calcProfilesHeight(profMonsLOS
); end;
3679 if g_profile_los
and (profMonsLOS
<> nil) then begin px
:= px
-drawProfiles(px
, py
, profMonsLOS
); py
-= calcProfilesHeight(profMonsLOS
); end;
3682 procedure g_Game_Draw();
3689 plView1
, plView2
: TPlayer
;
3692 if gExit
= EXIT_QUIT
then Exit
;
3694 Time
:= GetTimer() {div 1000};
3695 FPSCounter
:= FPSCounter
+1;
3696 if Time
- FPSTime
>= 1000 then
3703 if gGameOn
or (gState
= STATE_FOLD
) then
3705 if (gPlayer1
<> nil) and (gPlayer2
<> nil) then
3707 gSpectMode
:= SPECT_NONE
;
3708 if not gRevertPlayers
then
3710 plView1
:= gPlayer1
;
3711 plView2
:= gPlayer2
;
3715 plView1
:= gPlayer2
;
3716 plView2
:= gPlayer1
;
3720 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
3722 gSpectMode
:= SPECT_NONE
;
3723 if gPlayer2
= nil then
3726 plView1
:= gPlayer2
;
3735 if (plView1
= nil) and (plView2
= nil) and (gSpectMode
= SPECT_NONE
) then
3736 gSpectMode
:= SPECT_STATS
;
3738 if gSpectMode
= SPECT_PLAYERS
then
3739 if gPlayers
<> nil then
3741 plView1
:= GetActivePlayer_ByID(gSpectPID1
);
3742 if plView1
= nil then
3744 gSpectPID1
:= GetActivePlayerID_Next();
3745 plView1
:= GetActivePlayer_ByID(gSpectPID1
);
3747 if gSpectViewTwo
then
3749 plView2
:= GetActivePlayer_ByID(gSpectPID2
);
3750 if plView2
= nil then
3752 gSpectPID2
:= GetActivePlayerID_Next();
3753 plView2
:= GetActivePlayer_ByID(gSpectPID2
);
3758 if gSpectMode
= SPECT_MAPVIEW
then
3760 // Ðåæèì ïðîñìîòðà êàðòû
3762 e_SetViewPort(0, 0, gScreenWidth
, gScreenHeight
);
3763 DrawMapView(gSpectX
, gSpectY
, gScreenWidth
, gScreenHeight
);
3764 gHearPoint1
.Active
:= True;
3765 gHearPoint1
.Coords
.X
:= gScreenWidth
div 2 + gSpectX
;
3766 gHearPoint1
.Coords
.Y
:= gScreenHeight
div 2 + gSpectY
;
3767 gHearPoint2
.Active
:= False;
3771 Split
:= (plView1
<> nil) and (plView2
<> nil);
3773 // Òî÷êè ñëóõà èãðîêîâ
3774 if plView1
<> nil then
3776 gHearPoint1
.Active
:= True;
3777 gHearPoint1
.Coords
.X
:= plView1
.GameX
;
3778 gHearPoint1
.Coords
.Y
:= plView1
.GameY
;
3780 gHearPoint1
.Active
:= False;
3781 if plView2
<> nil then
3783 gHearPoint2
.Active
:= True;
3784 gHearPoint2
.Coords
.X
:= plView2
.GameX
;
3785 gHearPoint2
.Coords
.Y
:= plView2
.GameY
;
3787 gHearPoint2
.Active
:= False;
3789 // Ðàçìåð ýêðàíîâ èãðîêîâ:
3790 gPlayerScreenSize
.X
:= gScreenWidth
-196;
3793 gPlayerScreenSize
.Y
:= gScreenHeight
div 2;
3794 if gScreenHeight
mod 2 = 0 then
3795 Dec(gPlayerScreenSize
.Y
);
3798 gPlayerScreenSize
.Y
:= gScreenHeight
;
3801 if gScreenHeight
mod 2 = 0 then
3802 e_SetViewPort(0, gPlayerScreenSize
.Y
+2, gPlayerScreenSize
.X
+196, gPlayerScreenSize
.Y
)
3804 e_SetViewPort(0, gPlayerScreenSize
.Y
+1, gPlayerScreenSize
.X
+196, gPlayerScreenSize
.Y
);
3806 DrawPlayer(plView1
);
3807 gPlayer1ScreenCoord
.X
:= sX
;
3808 gPlayer1ScreenCoord
.Y
:= sY
;
3812 e_SetViewPort(0, 0, gPlayerScreenSize
.X
+196, gPlayerScreenSize
.Y
);
3814 DrawPlayer(plView2
);
3815 gPlayer2ScreenCoord
.X
:= sX
;
3816 gPlayer2ScreenCoord
.Y
:= sY
;
3819 e_SetViewPort(0, 0, gScreenWidth
, gScreenHeight
);
3822 e_DrawLine(2, 0, gScreenHeight
div 2, gScreenWidth
, gScreenHeight
div 2, 0, 0, 0);
3825 {$IFDEF ENABLE_HOLMES}
3827 if (g_holmes_enabled
) then g_Holmes_Draw();
3830 if MessageText
<> '' then
3834 e_CharFont_GetSizeFmt(gMenuFont
, MessageText
, w
, h
);
3836 e_CharFont_PrintFmt(gMenuFont
, (gScreenWidth
div 2)-(w
div 2),
3837 (gScreenHeight
div 2)-(h
div 2), MessageText
)
3839 e_CharFont_PrintFmt(gMenuFont
, (gScreenWidth
div 2)-(w
div 2),
3840 Round(gScreenHeight
/ 2.75)-(h
div 2), MessageText
);
3843 if IsDrawStat
or (gSpectMode
= 1) then DrawStat();
3845 if gSpectHUD
and (not gChatShow
) and (gSpectMode
<> SPECT_NONE
) and (not gSpectAuto
) then
3847 // Draw spectator GUI
3850 e_TextureFontGetSize(gStdFont
, ww
, hh
);
3853 e_TextureFontPrintEx(0, gScreenHeight
- (hh
+2)*2, 'MODE: Stats', gStdFont
, 255, 255, 255, 1);
3855 e_TextureFontPrintEx(0, gScreenHeight
- (hh
+2)*2, 'MODE: Observe Map', gStdFont
, 255, 255, 255, 1);
3857 e_TextureFontPrintEx(0, gScreenHeight
- (hh
+2)*2, 'MODE: Watch Players', gStdFont
, 255, 255, 255, 1);
3859 e_TextureFontPrintEx(2*ww
, gScreenHeight
- (hh
+2), '< jump >', gStdFont
, 255, 255, 255, 1);
3860 if gSpectMode
= SPECT_STATS
then
3862 e_TextureFontPrintEx(16*ww
, gScreenHeight
- (hh
+2)*2, 'Autoview', gStdFont
, 255, 255, 255, 1);
3863 e_TextureFontPrintEx(16*ww
, gScreenHeight
- (hh
+2), '< fire >', gStdFont
, 255, 255, 255, 1);
3865 if gSpectMode
= SPECT_MAPVIEW
then
3867 e_TextureFontPrintEx(22*ww
, gScreenHeight
- (hh
+2)*2, '[-]', gStdFont
, 255, 255, 255, 1);
3868 e_TextureFontPrintEx(26*ww
, gScreenHeight
- (hh
+2)*2, 'Step ' + IntToStr(gSpectStep
), gStdFont
, 255, 255, 255, 1);
3869 e_TextureFontPrintEx(34*ww
, gScreenHeight
- (hh
+2)*2, '[+]', gStdFont
, 255, 255, 255, 1);
3870 e_TextureFontPrintEx(18*ww
, gScreenHeight
- (hh
+2), '<prev weap>', gStdFont
, 255, 255, 255, 1);
3871 e_TextureFontPrintEx(30*ww
, gScreenHeight
- (hh
+2), '<next weap>', gStdFont
, 255, 255, 255, 1);
3873 if gSpectMode
= SPECT_PLAYERS
then
3875 e_TextureFontPrintEx(22*ww
, gScreenHeight
- (hh
+2)*2, 'Player 1', gStdFont
, 255, 255, 255, 1);
3876 e_TextureFontPrintEx(20*ww
, gScreenHeight
- (hh
+2), '<left/right>', gStdFont
, 255, 255, 255, 1);
3877 if gSpectViewTwo
then
3879 e_TextureFontPrintEx(37*ww
, gScreenHeight
- (hh
+2)*2, 'Player 2', gStdFont
, 255, 255, 255, 1);
3880 e_TextureFontPrintEx(34*ww
, gScreenHeight
- (hh
+2), '<prev w/next w>', gStdFont
, 255, 255, 255, 1);
3881 e_TextureFontPrintEx(52*ww
, gScreenHeight
- (hh
+2)*2, '2x View', gStdFont
, 255, 255, 255, 1);
3882 e_TextureFontPrintEx(51*ww
, gScreenHeight
- (hh
+2), '<up/down>', gStdFont
, 255, 255, 255, 1);
3886 e_TextureFontPrintEx(35*ww
, gScreenHeight
- (hh
+2)*2, '2x View', gStdFont
, 255, 255, 255, 1);
3887 e_TextureFontPrintEx(34*ww
, gScreenHeight
- (hh
+2), '<up/down>', gStdFont
, 255, 255, 255, 1);
3893 if gPauseMain
and gGameOn
and (g_ActiveWindow
= nil) then
3895 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
3896 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
3898 e_CharFont_GetSize(gMenuFont
, _lc
[I_MENU_PAUSE
], w
, h
);
3899 e_CharFont_Print(gMenuFont
, (gScreenWidth
div 2)-(w
div 2),
3900 (gScreenHeight
div 2)-(h
div 2), _lc
[I_MENU_PAUSE
]);
3905 if (gState
= STATE_MENU
) then
3907 if (g_ActiveWindow
= nil) or (g_ActiveWindow
.BackTexture
= '') then
3909 if g_Texture_Get('MENU_BACKGROUND', ID
) then e_DrawSize(ID
, 0, 0, 0, False, False, gScreenWidth
, gScreenHeight
)
3910 else e_Clear(GL_COLOR_BUFFER_BIT
, 0, 0, 0);
3912 // F3 at menu will show game loading dialog
3913 if e_KeyPressed(IK_F3
) then g_Menu_Show_LoadMenu(true);
3914 if (g_ActiveWindow
<> nil) then
3916 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
3917 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
3921 // F3 at titlepic will show game loading dialog
3922 if e_KeyPressed(IK_F3
) then
3924 g_Menu_Show_LoadMenu(true);
3925 if (g_ActiveWindow
<> nil) then e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
3930 if gState
= STATE_FOLD
then
3932 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 0, 0, 0, EndingGameCounter
);
3935 if gState
= STATE_INTERCUSTOM
then
3937 if gLastMap
and (gGameSettings
.GameMode
= GM_COOP
) then
3939 back
:= 'TEXTURE_endpic';
3940 if not g_Texture_Get(back
, ID
) then
3941 back
:= _lc
[I_TEXTURE_ENDPIC
];
3946 if g_Texture_Get(back
, ID
) then
3947 e_DrawSize(ID
, 0, 0, 0, False, False, gScreenWidth
, gScreenHeight
)
3949 e_Clear(GL_COLOR_BUFFER_BIT
, 0, 0, 0);
3953 if g_ActiveWindow
<> nil then
3955 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
3956 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
3960 if gState
= STATE_INTERSINGLE
then
3962 if EndingGameCounter
> 0 then
3964 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 0, 0, 0, EndingGameCounter
);
3970 if g_Texture_Get(back
, ID
) then
3971 e_DrawSize(ID
, 0, 0, 0, False, False, gScreenWidth
, gScreenHeight
)
3973 e_Clear(GL_COLOR_BUFFER_BIT
, 0, 0, 0);
3977 if g_ActiveWindow
<> nil then
3979 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
3980 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
3985 if gState
= STATE_ENDPIC
then
3988 if not g_Texture_Get('TEXTURE_endpic', ID
) then
3989 g_Texture_Get(_lc
[I_TEXTURE_ENDPIC
], ID
);
3991 if ID
<> DWORD(-1) then
3992 e_DrawSize(ID
, 0, 0, 0, False, False, gScreenWidth
, gScreenHeight
)
3994 e_Clear(GL_COLOR_BUFFER_BIT
, 0, 0, 0);
3996 if g_ActiveWindow
<> nil then
3998 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
3999 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4003 if gState
= STATE_SLIST
then
4005 if g_Texture_Get('MENU_BACKGROUND', ID
) then
4007 e_DrawSize(ID
, 0, 0, 0, False, False, gScreenWidth
, gScreenHeight
);
4008 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4009 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4011 g_Serverlist_Draw(slCurrent
, slTable
);
4015 if g_ActiveWindow
<> nil then
4019 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4020 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4022 g_ActiveWindow
.Draw();
4027 if g_debug_Sounds
and gGameOn
then
4029 for w
:= 0 to High(e_SoundsArray
) do
4030 for h
:= 0 to e_SoundsArray
[w
].nRefs
do
4031 e_DrawPoint(1, w
+100, h
+100, 255, 0, 0);
4036 e_TextureFontPrint(0, 0, Format('FPS: %d', [FPS
]), gStdFont
);
4037 e_TextureFontPrint(0, 16, Format('UPS: %d', [UPS
]), gStdFont
);
4040 if gGameOn
and gShowTime
and (gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
]) then
4041 drawTime(gScreenWidth
-72, gScreenHeight
-16);
4043 if gGameOn
then drawProfilers();
4045 {$IFDEF ENABLE_HOLMES}
4052 procedure g_Game_Quit();
4054 g_Game_StopAllSounds(True);
4056 g_Game_SaveOptions();
4058 g_PlayerModel_FreeData();
4059 g_Texture_DeleteAll();
4060 g_Frames_DeleteAll();
4061 //g_Menu_Free(); //k8: this segfaults after resolution change; who cares?
4063 if NetInitDone
then g_Net_Free
;
4065 // Íàäî óäàëèòü êàðòó ïîñëå òåñòà:
4066 if gMapToDelete
<> '' then
4067 g_Game_DeleteTestMap();
4073 procedure g_FatalError(Text: String);
4075 g_Console_Add(Format(_lc
[I_FATAL_ERROR
], [Text]), True);
4076 e_WriteLog(Format(_lc
[I_FATAL_ERROR
], [Text]), TMsgType
.Warning
);
4078 gExit
:= EXIT_SIMPLE
;
4081 procedure g_SimpleError(Text: String);
4083 g_Console_Add(Format(_lc
[I_SIMPLE_ERROR
], [Text]), True);
4084 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], [Text]), TMsgType
.Warning
);
4087 procedure g_Game_SetupScreenSize();
4089 RES_FACTOR
= 4.0 / 3.0;
4095 // Ðàçìåð ýêðàíîâ èãðîêîâ:
4096 gPlayerScreenSize
.X
:= gScreenWidth
-196;
4097 if (gPlayer1
<> nil) and (gPlayer2
<> nil) then
4098 gPlayerScreenSize
.Y
:= gScreenHeight
div 2
4100 gPlayerScreenSize
.Y
:= gScreenHeight
;
4102 // Ðàçìåð çàäíåãî ïëàíà:
4103 if BackID
<> DWORD(-1) then
4106 if (gScreenWidth
*s
> gMapInfo
.Width
) or
4107 (gScreenHeight
*s
> gMapInfo
.Height
) then
4109 gBackSize
.X
:= gScreenWidth
;
4110 gBackSize
.Y
:= gScreenHeight
;
4114 e_GetTextureSize(BackID
, @bw
, @bh
);
4115 rf
:= Single(bw
) / Single(bh
);
4116 if (rf
> RES_FACTOR
) then bw
:= Round(Single(bh
) * RES_FACTOR
)
4117 else if (rf
< RES_FACTOR
) then bh
:= Round(Single(bw
) / RES_FACTOR
);
4118 s
:= Max(gScreenWidth
/ bw
, gScreenHeight
/ bh
);
4119 if (s
< 1.0) then s
:= 1.0;
4120 gBackSize
.X
:= Round(bw
*s
);
4121 gBackSize
.Y
:= Round(bh
*s
);
4126 procedure g_Game_ChangeResolution(newWidth
, newHeight
: Word; nowFull
, nowMax
: Boolean);
4128 g_Window_SetSize(newWidth
, newHeight
, nowFull
);
4131 procedure g_Game_AddPlayer(Team
: Byte = TEAM_NONE
);
4133 if ((not gGameOn
) and (gState
<> STATE_INTERCUSTOM
))
4134 or (not (gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
])) then
4136 if gPlayer1
= nil then
4138 if g_Game_IsClient
then
4140 if NetPlrUID1
> -1 then
4142 MC_SEND_CheatRequest(NET_CHEAT_SPECTATE
);
4143 gPlayer1
:= g_Player_Get(NetPlrUID1
);
4148 if not (Team
in [TEAM_RED
, TEAM_BLUE
]) then
4149 Team
:= gPlayer1Settings
.Team
;
4151 // Ñîçäàíèå ïåðâîãî èãðîêà:
4152 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4153 gPlayer1Settings
.Color
,
4155 if gPlayer1
= nil then
4156 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]))
4159 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4160 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [gPlayer1
.Name
]), True);
4161 if g_Game_IsServer
and g_Game_IsNet
then
4162 MH_SEND_PlayerCreate(gPlayer1
.UID
);
4163 gPlayer1
.Respawn(False, True);
4165 if g_Game_IsNet
and NetUseMaster
then
4171 if gPlayer2
= nil then
4173 if g_Game_IsClient
then
4175 if NetPlrUID2
> -1 then
4176 gPlayer2
:= g_Player_Get(NetPlrUID2
);
4180 if not (Team
in [TEAM_RED
, TEAM_BLUE
]) then
4181 Team
:= gPlayer2Settings
.Team
;
4183 // Ñîçäàíèå âòîðîãî èãðîêà:
4184 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
4185 gPlayer2Settings
.Color
,
4187 if gPlayer2
= nil then
4188 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]))
4191 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
4192 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [gPlayer2
.Name
]), True);
4193 if g_Game_IsServer
and g_Game_IsNet
then
4194 MH_SEND_PlayerCreate(gPlayer2
.UID
);
4195 gPlayer2
.Respawn(False, True);
4197 if g_Game_IsNet
and NetUseMaster
then
4205 procedure g_Game_RemovePlayer();
4209 if ((not gGameOn
) and (gState
<> STATE_INTERCUSTOM
))
4210 or (not (gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
])) then
4215 if g_Game_IsServer
then
4218 Pl
.Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
4219 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [Pl
.Name
]), True);
4220 g_Player_Remove(Pl
.UID
);
4222 if g_Game_IsNet
and NetUseMaster
then
4231 if g_Game_IsServer
then
4234 Pl
.Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
4235 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [Pl
.Name
]), True);
4236 g_Player_Remove(Pl
.UID
);
4238 if g_Game_IsNet
and NetUseMaster
then
4243 MC_SEND_CheatRequest(NET_CHEAT_SPECTATE
);
4249 procedure g_Game_Spectate();
4251 g_Game_RemovePlayer();
4252 if gPlayer1
<> nil then
4253 g_Game_RemovePlayer();
4256 procedure g_Game_SpectateCenterView();
4258 gSpectX
:= Max(gMapInfo
.Width
div 2 - gScreenWidth
div 2, 0);
4259 gSpectY
:= Max(gMapInfo
.Height
div 2 - gScreenHeight
div 2, 0);
4262 procedure g_Game_StartSingle(Map
: String; TwoPlayers
: Boolean; nPlayers
: Byte);
4269 e_WriteLog('Starting singleplayer game...', TMsgType
.Notify
);
4271 g_Game_ClearLoading();
4274 FillByte(gGameSettings
, SizeOf(TGameSettings
), 0);
4277 gGameSettings
.GameType
:= GT_SINGLE
;
4278 gGameSettings
.MaxLives
:= 0;
4279 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_ALLOWEXIT
;
4280 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_MONSTERS
;
4281 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_BOTVSMONSTER
;
4282 gSwitchGameMode
:= GM_SINGLE
;
4284 g_Game_ExecuteEvent('ongamestart');
4286 // Óñòàíîâêà ðàçìåðîâ îêîí èãðîêîâ:
4287 g_Game_SetupScreenSize();
4289 // Ñîçäàíèå ïåðâîãî èãðîêà:
4290 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4291 gPlayer1Settings
.Color
,
4292 gPlayer1Settings
.Team
, False));
4293 if gPlayer1
= nil then
4295 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
4299 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4302 // Ñîçäàíèå âòîðîãî èãðîêà, åñëè åñòü:
4305 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
4306 gPlayer2Settings
.Color
,
4307 gPlayer2Settings
.Team
, False));
4308 if gPlayer2
= nil then
4310 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
4314 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
4318 // Çàãðóçêà è çàïóñê êàðòû:
4319 if not g_Game_StartMap(MAP
, True) then
4321 if (Pos(':\', Map
) > 0) or (Pos(':/', Map
) > 0) then tmps
:= Map
else tmps
:= gGameSettings
.WAD
+ ':\' + MAP
;
4322 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [tmps
]));
4326 // Íàñòðîéêè èãðîêîâ è áîòîâ:
4330 for i
:= nPl
+1 to nPlayers
do
4331 g_Player_Create(STD_PLAYER_MODEL
, _RGB(0, 0, 0), 0, True);
4334 procedure g_Game_StartCustom(Map
: String; GameMode
: Byte;
4335 TimeLimit
, GoalLimit
: Word;
4337 Options
: LongWord; nPlayers
: Byte);
4343 e_WriteLog('Starting custom game...', TMsgType
.Notify
);
4345 g_Game_ClearLoading();
4348 gGameSettings
.GameType
:= GT_CUSTOM
;
4349 gGameSettings
.GameMode
:= GameMode
;
4350 gSwitchGameMode
:= GameMode
;
4351 gGameSettings
.TimeLimit
:= TimeLimit
;
4352 gGameSettings
.GoalLimit
:= GoalLimit
;
4353 gGameSettings
.MaxLives
:= IfThen(GameMode
= GM_CTF
, 0, MaxLives
);
4354 gGameSettings
.Options
:= Options
;
4356 gCoopTotalMonstersKilled
:= 0;
4357 gCoopTotalSecretsFound
:= 0;
4358 gCoopTotalMonsters
:= 0;
4359 gCoopTotalSecrets
:= 0;
4363 g_Game_ExecuteEvent('ongamestart');
4365 // Óñòàíîâêà ðàçìåðîâ îêîí èãðîêîâ:
4366 g_Game_SetupScreenSize();
4368 // Ðåæèì íàáëþäàòåëÿ:
4369 if nPlayers
= 0 then
4376 if nPlayers
>= 1 then
4378 // Ñîçäàíèå ïåðâîãî èãðîêà:
4379 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4380 gPlayer1Settings
.Color
,
4381 gPlayer1Settings
.Team
, False));
4382 if gPlayer1
= nil then
4384 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
4388 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4392 if nPlayers
>= 2 then
4394 // Ñîçäàíèå âòîðîãî èãðîêà:
4395 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
4396 gPlayer2Settings
.Color
,
4397 gPlayer2Settings
.Team
, False));
4398 if gPlayer2
= nil then
4400 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
4404 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
4408 // Çàãðóçêà è çàïóñê êàðòû:
4409 if not g_Game_StartMap(Map
, True) then
4411 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [Map
]));
4415 // Íåò òî÷åê ïîÿâëåíèÿ:
4416 if (g_Map_GetPointCount(RESPAWNPOINT_PLAYER1
) +
4417 g_Map_GetPointCount(RESPAWNPOINT_PLAYER2
) +
4418 g_Map_GetPointCount(RESPAWNPOINT_DM
) +
4419 g_Map_GetPointCount(RESPAWNPOINT_RED
)+
4420 g_Map_GetPointCount(RESPAWNPOINT_BLUE
)) < 1 then
4422 g_FatalError(_lc
[I_GAME_ERROR_GET_SPAWN
]);
4426 // Íàñòðîéêè èãðîêîâ è áîòîâ:
4430 for i
:= nPl
+1 to nPlayers
do
4431 g_Player_Create(STD_PLAYER_MODEL
, _RGB(0, 0, 0), 0, True);
4434 procedure g_Game_StartServer(Map
: String; GameMode
: Byte;
4435 TimeLimit
, GoalLimit
: Word; MaxLives
: Byte;
4436 Options
: LongWord; nPlayers
: Byte;
4437 IPAddr
: LongWord; Port
: Word);
4441 e_WriteLog('Starting net game (server)...', TMsgType
.Notify
);
4443 g_Game_ClearLoading();
4446 gGameSettings
.GameType
:= GT_SERVER
;
4447 gGameSettings
.GameMode
:= GameMode
;
4448 gSwitchGameMode
:= GameMode
;
4449 gGameSettings
.TimeLimit
:= TimeLimit
;
4450 gGameSettings
.GoalLimit
:= GoalLimit
;
4451 gGameSettings
.MaxLives
:= IfThen(GameMode
= GM_CTF
, 0, MaxLives
);
4452 gGameSettings
.Options
:= Options
;
4454 gCoopTotalMonstersKilled
:= 0;
4455 gCoopTotalSecretsFound
:= 0;
4456 gCoopTotalMonsters
:= 0;
4457 gCoopTotalSecrets
:= 0;
4461 g_Game_ExecuteEvent('ongamestart');
4463 // Óñòàíîâêà ðàçìåðîâ îêíà èãðîêà
4464 g_Game_SetupScreenSize();
4466 // Ðåæèì íàáëþäàòåëÿ:
4467 if nPlayers
= 0 then
4473 if nPlayers
>= 1 then
4475 // Ñîçäàíèå ïåðâîãî èãðîêà:
4476 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4477 gPlayer1Settings
.Color
,
4478 gPlayer1Settings
.Team
, False));
4479 if gPlayer1
= nil then
4481 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
4485 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4488 if nPlayers
>= 2 then
4490 // Ñîçäàíèå âòîðîãî èãðîêà:
4491 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
4492 gPlayer2Settings
.Color
,
4493 gPlayer2Settings
.Team
, False));
4494 if gPlayer2
= nil then
4496 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
4500 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
4503 g_Game_SetLoadingText(_lc
[I_LOAD_HOST
], 0, False);
4504 if NetForwardPorts
then
4505 g_Game_SetLoadingText(_lc
[I_LOAD_PORTS
], 0, False);
4508 if not g_Net_Host(IPAddr
, Port
, NetMaxClients
) then
4510 g_FatalError(_lc
[I_NET_MSG
] + _lc
[I_NET_ERR_HOST
]);
4514 g_Net_Slist_Set(NetSlistIP
, NetSlistPort
);
4516 // Çàãðóçêà è çàïóñê êàðòû:
4517 if not g_Game_StartMap(Map
, True) then
4519 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [Map
]));
4523 // Íåò òî÷åê ïîÿâëåíèÿ:
4524 if (g_Map_GetPointCount(RESPAWNPOINT_PLAYER1
) +
4525 g_Map_GetPointCount(RESPAWNPOINT_PLAYER2
) +
4526 g_Map_GetPointCount(RESPAWNPOINT_DM
) +
4527 g_Map_GetPointCount(RESPAWNPOINT_RED
)+
4528 g_Map_GetPointCount(RESPAWNPOINT_BLUE
)) < 1 then
4530 g_FatalError(_lc
[I_GAME_ERROR_GET_SPAWN
]);
4534 // Íàñòðîéêè èãðîêîâ è áîòîâ:
4537 NetState
:= NET_STATE_GAME
;
4540 procedure g_Game_StartClient(Addr
: String; Port
: Word; PW
: String);
4555 e_WriteLog('Starting net game (client)...', TMsgType
.Notify
);
4556 e_WriteLog('NET: Trying to connect to ' + Addr
+ ':' + IntToStr(Port
) + '...', TMsgType
.Notify
);
4558 g_Game_ClearLoading();
4561 gGameSettings
.GameType
:= GT_CLIENT
;
4563 gCoopTotalMonstersKilled
:= 0;
4564 gCoopTotalSecretsFound
:= 0;
4565 gCoopTotalMonsters
:= 0;
4566 gCoopTotalSecrets
:= 0;
4570 g_Game_ExecuteEvent('ongamestart');
4572 // Óñòàíîâêà ðàçìåðîâ îêîí èãðîêîâ:
4573 g_Game_SetupScreenSize();
4575 NetState
:= NET_STATE_AUTH
;
4577 g_Game_SetLoadingText(_lc
[I_LOAD_CONNECT
], 0, False);
4579 if not g_Net_Connect(Addr
, Port
) then
4581 g_FatalError(_lc
[I_NET_MSG
] + _lc
[I_NET_ERR_CONN
]);
4582 NetState
:= NET_STATE_NONE
;
4586 g_Game_SetLoadingText(_lc
[I_LOAD_SEND_INFO
], 0, False);
4588 g_Game_SetLoadingText(_lc
[I_LOAD_WAIT_INFO
], 0, False);
4593 while (enet_host_service(NetHost
, @NetEvent
, 0) > 0) do
4595 if (NetEvent
.kind
= ENET_EVENT_TYPE_RECEIVE
) then
4597 Ptr
:= NetEvent
.packet
^.data
;
4598 if not InMsg
.Init(Ptr
, NetEvent
.packet
^.dataLength
, True) then
4601 MID
:= InMsg
.ReadByte();
4603 if (MID
= NET_MSG_INFO
) and (State
= 0) then
4605 NetMyID
:= InMsg
.ReadByte();
4606 NetPlrUID1
:= InMsg
.ReadWord();
4608 WadName
:= InMsg
.ReadString();
4609 Map
:= InMsg
.ReadString();
4611 gWADHash
:= InMsg
.ReadMD5();
4613 gGameSettings
.GameMode
:= InMsg
.ReadByte();
4614 gSwitchGameMode
:= gGameSettings
.GameMode
;
4615 gGameSettings
.GoalLimit
:= InMsg
.ReadWord();
4616 gGameSettings
.TimeLimit
:= InMsg
.ReadWord();
4617 gGameSettings
.MaxLives
:= InMsg
.ReadByte();
4618 gGameSettings
.Options
:= InMsg
.ReadLongWord();
4619 T
:= InMsg
.ReadLongWord();
4621 newResPath
:= g_Res_SearchSameWAD(MapsDir
, WadName
, gWADHash
);
4622 if newResPath
= '' then
4624 g_Game_SetLoadingText(_lc
[I_LOAD_DL_RES
], 0, False);
4625 newResPath
:= g_Res_DownloadWAD(WadName
);
4626 if newResPath
= '' then
4628 g_FatalError(_lc
[I_NET_ERR_HASH
]);
4629 enet_packet_destroy(NetEvent
.packet
);
4630 NetState
:= NET_STATE_NONE
;
4634 newResPath
:= ExtractRelativePath(MapsDir
, newResPath
);
4636 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4637 gPlayer1Settings
.Color
,
4638 gPlayer1Settings
.Team
, False));
4640 if gPlayer1
= nil then
4642 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
4644 enet_packet_destroy(NetEvent
.packet
);
4645 NetState
:= NET_STATE_NONE
;
4649 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4650 gPlayer1
.UID
:= NetPlrUID1
;
4651 gPlayer1
.Reset(True);
4653 if not g_Game_StartMap(newResPath
+ ':\' + Map
, True) then
4655 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [WadName
+ ':\' + Map
]));
4657 enet_packet_destroy(NetEvent
.packet
);
4658 NetState
:= NET_STATE_NONE
;
4666 enet_packet_destroy(NetEvent
.packet
);
4670 enet_packet_destroy(NetEvent
.packet
);
4674 if (NetEvent
.kind
= ENET_EVENT_TYPE_DISCONNECT
) then
4677 if (NetEvent
.data
<= NET_DISC_MAX
) then
4678 g_Console_Add(_lc
[I_NET_MSG_ERROR
] + _lc
[I_NET_ERR_CONN
] + ' ' +
4679 _lc
[TStrings_Locale(Cardinal(I_NET_DISC_NONE
) + NetEvent
.data
)], True);
4686 ProcessLoading(true);
4688 if e_KeyPressed(IK_SPACE
) or e_KeyPressed(IK_ESCAPE
) or e_KeyPressed(VK_ESCAPE
) or
4689 e_KeyPressed(JOY0_JUMP
) or e_KeyPressed(JOY1_JUMP
) or e_KeyPressed(JOY2_JUMP
) or e_KeyPressed(JOY3_JUMP
) then
4698 g_FatalError(_lc
[I_NET_MSG
] + _lc
[I_NET_ERR_CONN
]);
4699 NetState
:= NET_STATE_NONE
;
4703 gLMSRespawn
:= LMS_RESPAWN_NONE
;
4704 gLMSRespawnTime
:= 0;
4707 NetState
:= NET_STATE_GAME
;
4708 MC_SEND_FullStateRequest
;
4709 e_WriteLog('NET: Connection successful.', TMsgType
.Notify
);
4712 procedure g_Game_SaveOptions();
4714 g_Options_Write_Video(GameDir
+'/'+CONFIG_FILENAME
);
4717 procedure g_Game_ChangeMap(const MapPath
: String);
4721 g_Game_ClearLoading();
4723 Force
:= gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
];
4724 // Åñëè óðîâåíü çàâåðøèëñÿ ïî òðèããåðó Âûõîä, íå î÷èùàòü èíâåíòàðü
4725 if gExitByTrigger
then
4728 gExitByTrigger
:= False;
4730 if not g_Game_StartMap(MapPath
, Force
) then
4731 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [MapPath
]));
4734 procedure g_Game_Restart();
4738 if g_Game_IsClient
then
4740 map
:= g_ExtractFileName(gMapInfo
.Map
);
4744 g_Game_ClearLoading();
4745 g_Game_StartMap(Map
, True, gCurrentMapFileName
);
4748 function g_Game_StartMap(Map
: String; Force
: Boolean = False; const oldMapPath
: AnsiString=''): Boolean;
4750 NewWAD
, ResName
: String;
4753 g_Map_Free((Map
<> gCurrentMapFileName
) and (oldMapPath
<> gCurrentMapFileName
));
4754 g_Player_RemoveAllCorpses();
4756 if (not g_Game_IsClient
) and
4757 (gSwitchGameMode
<> gGameSettings
.GameMode
) and
4758 (gGameSettings
.GameMode
<> GM_SINGLE
) then
4760 if gSwitchGameMode
= GM_CTF
then
4761 gGameSettings
.MaxLives
:= 0;
4762 gGameSettings
.GameMode
:= gSwitchGameMode
;
4765 gSwitchGameMode
:= gGameSettings
.GameMode
;
4767 g_Player_ResetTeams();
4769 if isWadPath(Map
) then
4771 NewWAD
:= g_ExtractWadName(Map
);
4772 ResName
:= g_ExtractFileName(Map
);
4773 if g_Game_IsServer
then
4775 gWADHash
:= MD5File(MapsDir
+ NewWAD
);
4776 g_Game_LoadWAD(NewWAD
);
4778 // hash received in MC_RECV_GameEvent -> NET_EV_MAPSTART
4779 g_Game_ClientWAD(NewWAD
, gWADHash
);
4783 Result
:= g_Map_Load(MapsDir
+ gGameSettings
.WAD
+ ':\' + ResName
);
4786 g_Player_ResetAll(Force
or gLastMap
, gGameSettings
.GameType
= GT_SINGLE
);
4788 gState
:= STATE_NONE
;
4789 g_ActiveWindow
:= nil;
4795 if gGameSettings
.GameMode
= GM_CTF
then
4797 g_Map_ResetFlag(FLAG_RED
);
4798 g_Map_ResetFlag(FLAG_BLUE
);
4799 // CTF, à ôëàãîâ íåò:
4800 if not g_Map_HaveFlagPoints() then
4801 g_SimpleError(_lc
[I_GAME_ERROR_CTF
]);
4806 gState
:= STATE_MENU
;
4811 gPauseMain
:= false;
4812 gPauseHolmes
:= false;
4814 NetTimeToUpdate
:= 1;
4815 NetTimeToReliable
:= 0;
4816 NetTimeToMaster
:= NetMasterRate
;
4817 gLMSRespawn
:= LMS_RESPAWN_NONE
;
4818 gLMSRespawnTime
:= 0;
4819 gMissionFailed
:= False;
4822 gCoopMonstersKilled
:= 0;
4823 gCoopSecretsFound
:= 0;
4825 gVoteInProgress
:= False;
4826 gVotePassed
:= False;
4832 if not gGameOn
then Exit
;
4834 g_Game_SpectateCenterView();
4836 if (gGameSettings
.MaxLives
> 0) and (gGameSettings
.WarmupTime
> 0) then
4838 gLMSRespawn
:= LMS_RESPAWN_WARMUP
;
4839 gLMSRespawnTime
:= gTime
+ gGameSettings
.WarmupTime
*1000;
4840 gLMSSoftSpawn
:= True;
4841 if NetMode
= NET_SERVER
then
4842 MH_SEND_GameEvent(NET_EV_LMS_WARMUP
, (gLMSRespawnTime
- gTime
) div 1000)
4844 g_Console_Add(Format(_lc
[I_MSG_WARMUP_START
], [(gLMSRespawnTime
- gTime
) div 1000]), True);
4847 if NetMode
= NET_SERVER
then
4849 MH_SEND_GameEvent(NET_EV_MAPSTART
, gGameSettings
.GameMode
, Map
);
4852 if NetUseMaster
then
4854 if (NetMHost
= nil) or (NetMPeer
= nil) then
4855 if not g_Net_Slist_Connect
then
4856 g_Console_Add(_lc
[I_NET_MSG_ERROR
] + _lc
[I_NET_SLIST_ERROR
]);
4861 if NetClients
<> nil then
4862 for I
:= 0 to High(NetClients
) do
4863 if NetClients
[I
].Used
then
4865 NetClients
[I
].Voted
:= False;
4866 if NetClients
[I
].RequestedFullUpdate
then
4868 MH_SEND_Everything((NetClients
[I
].State
= NET_STATE_AUTH
), I
);
4869 NetClients
[I
].RequestedFullUpdate
:= False;
4873 g_Net_UnbanNonPermHosts();
4878 gCoopTotalMonstersKilled
:= 0;
4879 gCoopTotalSecretsFound
:= 0;
4880 gCoopTotalMonsters
:= 0;
4881 gCoopTotalSecrets
:= 0;
4885 g_Game_ExecuteEvent('onmapstart');
4888 procedure SetFirstLevel();
4892 MapList
:= g_Map_GetMapsList(MapsDir
+ gGameSettings
.WAD
);
4893 if MapList
= nil then
4896 SortSArray(MapList
);
4897 gNextMap
:= MapList
[Low(MapList
)];
4902 procedure g_Game_ExitLevel(const Map
: AnsiString);
4906 gCoopTotalMonstersKilled
:= gCoopTotalMonstersKilled
+ gCoopMonstersKilled
;
4907 gCoopTotalSecretsFound
:= gCoopTotalSecretsFound
+ gCoopSecretsFound
;
4908 gCoopTotalMonsters
:= gCoopTotalMonsters
+ gTotalMonsters
;
4909 gCoopTotalSecrets
:= gCoopTotalSecrets
+ gSecretsCount
;
4911 // Âûøëè â âûõîä â Îäèíî÷íîé èãðå:
4912 if gGameSettings
.GameType
= GT_SINGLE
then
4913 gExit
:= EXIT_ENDLEVELSINGLE
4914 else // Âûøëè â âûõîä â Ñâîåé èãðå
4916 gExit
:= EXIT_ENDLEVELCUSTOM
;
4917 if gGameSettings
.GameMode
= GM_COOP
then
4918 g_Player_RememberAll
;
4920 if not g_Map_Exist(MapsDir
+ gGameSettings
.WAD
+ ':\' + gNextMap
) then
4923 if gGameSettings
.GameMode
= GM_COOP
then
4926 gStatsPressed
:= True;
4927 gNextMap
:= 'MAP01';
4929 if not g_Map_Exist(MapsDir
+ gGameSettings
.WAD
+ ':\' + gNextMap
) then
4932 if g_Game_IsNet
then
4934 MH_SEND_GameStats();
4935 MH_SEND_CoopStats();
4941 procedure g_Game_RestartLevel();
4945 if gGameSettings
.GameMode
= GM_SINGLE
then
4950 gExit
:= EXIT_ENDLEVELCUSTOM
;
4951 Map
:= g_ExtractFileName(gMapInfo
.Map
);
4955 procedure g_Game_ClientWAD(NewWAD
: String; WHash
: TMD5Digest
);
4959 if LowerCase(NewWAD
) = LowerCase(gGameSettings
.WAD
) then
4961 if not g_Game_IsClient
then
4963 gWAD
:= g_Res_SearchSameWAD(MapsDir
, ExtractFileName(NewWAD
), WHash
);
4966 g_Game_SetLoadingText(_lc
[I_LOAD_DL_RES
], 0, False);
4967 gWAD
:= g_Res_DownloadWAD(ExtractFileName(NewWAD
));
4971 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_WAD
], [ExtractFileName(NewWAD
)]));
4975 NewWAD
:= ExtractRelativePath(MapsDir
, gWAD
);
4976 g_Game_LoadWAD(NewWAD
);
4979 procedure g_Game_RestartRound(NoMapRestart
: Boolean = False);
4981 i
, n
, nb
, nr
: Integer;
4983 function monRespawn (mon
: TMonster
): Boolean;
4985 result
:= false; // don't stop
4986 if not mon
.FNoRespawn
then mon
.Respawn();
4990 if not g_Game_IsServer
then Exit
;
4991 if gLMSRespawn
= LMS_RESPAWN_NONE
then Exit
;
4992 gLMSRespawn
:= LMS_RESPAWN_NONE
;
4993 gLMSRespawnTime
:= 0;
4996 if (gGameSettings
.GameMode
= GM_COOP
) and not NoMapRestart
then
4998 gMissionFailed
:= True;
4999 g_Game_RestartLevel
;
5003 n
:= 0; nb
:= 0; nr
:= 0;
5004 for i
:= Low(gPlayers
) to High(gPlayers
) do
5005 if (gPlayers
[i
] <> nil) and
5006 ((not gPlayers
[i
].FSpectator
) or gPlayers
[i
].FWantsInGame
or
5007 (gPlayers
[i
] is TBot
)) then
5010 if gPlayers
[i
].Team
= TEAM_RED
then Inc(nr
)
5011 else if gPlayers
[i
].Team
= TEAM_BLUE
then Inc(nb
)
5014 if (n
< 2) or ((gGameSettings
.GameMode
= GM_TDM
) and ((nr
= 0) or (nb
= 0))) then
5016 // wait a second until the fuckers finally decide to join
5017 gLMSRespawn
:= LMS_RESPAWN_WARMUP
;
5018 gLMSRespawnTime
:= gTime
+ 1000;
5019 gLMSSoftSpawn
:= NoMapRestart
;
5023 g_Player_RemoveAllCorpses
;
5024 g_Game_Message(_lc
[I_MESSAGE_LMS_START
], 144);
5025 if g_Game_IsNet
then
5026 MH_SEND_GameEvent(NET_EV_LMS_START
);
5028 for i
:= Low(gPlayers
) to High(gPlayers
) do
5030 if gPlayers
[i
] = nil then continue
;
5031 if gPlayers
[i
] is TBot
then gPlayers
[i
].FWantsInGame
:= True;
5032 // don't touch normal spectators
5033 if gPlayers
[i
].FSpectator
and not gPlayers
[i
].FWantsInGame
then
5035 gPlayers
[i
].FNoRespawn
:= True;
5036 gPlayers
[i
].Lives
:= 0;
5037 if g_Game_IsNet
then
5038 MH_SEND_PlayerStats(gPlayers
[I
].UID
);
5041 gPlayers
[i
].FNoRespawn
:= False;
5042 gPlayers
[i
].Lives
:= gGameSettings
.MaxLives
;
5043 gPlayers
[i
].Respawn(False, True);
5044 if gGameSettings
.GameMode
= GM_COOP
then
5046 gPlayers
[i
].Frags
:= 0;
5047 gPlayers
[i
].RecallState
;
5049 if (gPlayer1
= nil) and (gLMSPID1
> 0) then
5050 gPlayer1
:= g_Player_Get(gLMSPID1
);
5051 if (gPlayer2
= nil) and (gLMSPID2
> 0) then
5052 gPlayer2
:= g_Player_Get(gLMSPID2
);
5055 g_Items_RestartRound();
5058 g_Mons_ForEach(monRespawn
);
5060 gLMSSoftSpawn
:= False;
5063 function g_Game_GetFirstMap(WAD
: String): String;
5067 MapList
:= g_Map_GetMapsList(WAD
);
5068 if MapList
= nil then
5071 SortSArray(MapList
);
5072 Result
:= MapList
[Low(MapList
)];
5074 if not g_Map_Exist(WAD
+ ':\' + Result
) then
5080 function g_Game_GetNextMap(): String;
5087 MapList
:= g_Map_GetMapsList(MapsDir
+ gGameSettings
.WAD
);
5088 if MapList
= nil then
5091 Map
:= g_ExtractFileName(gMapInfo
.Map
);
5093 SortSArray(MapList
);
5095 for I
:= Low(MapList
) to High(MapList
) do
5096 if Map
= MapList
[I
] then
5102 if MapIndex
<> -255 then
5104 if MapIndex
= High(MapList
) then
5105 Result
:= MapList
[Low(MapList
)]
5107 Result
:= MapList
[MapIndex
+ 1];
5109 if not g_Map_Exist(MapsDir
+ gGameSettings
.WAD
+ ':\' + Result
) then Result
:= Map
;
5115 procedure g_Game_NextLevel();
5117 if gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
, GM_COOP
] then
5118 gExit
:= EXIT_ENDLEVELCUSTOM
5121 gExit
:= EXIT_ENDLEVELSINGLE
;
5125 if gNextMap
<> '' then Exit
;
5126 gNextMap
:= g_Game_GetNextMap();
5129 function g_Game_IsTestMap(): Boolean;
5131 result
:= StrEquCI1251(TEST_MAP_NAME
, g_ExtractFileName(gMapInfo
.Map
));
5134 procedure g_Game_DeleteTestMap();
5137 //MapName: AnsiString;
5145 a
:= Pos('.wad:\', toLowerCase1251(gMapToDelete
));
5146 if (a
= 0) then a
:= Pos('.wad:/', toLowerCase1251(gMapToDelete
));
5147 if (a
= 0) then exit
;
5149 // Âûäåëÿåì èìÿ wad-ôàéëà è èìÿ êàðòû
5150 WadName
:= Copy(gMapToDelete
, 1, a
+3);
5151 Delete(gMapToDelete
, 1, a
+5);
5152 gMapToDelete
:= UpperCase(gMapToDelete
);
5154 //CopyMemory(@MapName[0], @gMapToDelete[1], Min(16, Length(gMapToDelete)));
5157 // Èìÿ êàðòû íå ñòàíäàðòíîå òåñòîâîå:
5158 if MapName <> TEST_MAP_NAME then
5161 if not gTempDelete then
5163 time := g_GetFileTime(WadName);
5164 WAD := TWADFile.Create();
5167 if not WAD.ReadFile(WadName) then
5168 begin // Íåò òàêîãî WAD-ôàéëà
5173 // Ñîñòàâëÿåì ñïèñîê êàðò è èùåì íóæíóþ:
5175 MapList := WAD.GetResourcesList('');
5177 if MapList <> nil then
5178 for a := 0 to High(MapList) do
5179 if MapList[a] = MapName then
5181 // Óäàëÿåì è ñîõðàíÿåì:
5182 WAD.RemoveResource('', MapName);
5183 WAD.SaveTo(WadName);
5188 g_SetFileTime(WadName, time);
5191 if gTempDelete
then DeleteFile(WadName
);
5194 procedure GameCVars(P
: SSArray
);
5197 stat
: TPlayerStatArray
;
5202 cmd
:= LowerCase(P
[0]);
5203 if (cmd
= 'g_friendlyfire') and not g_Game_IsClient
then
5205 with gGameSettings
do
5207 if (Length(P
) > 1) and
5208 ((P
[1] = '1') or (P
[1] = '0')) then
5210 if (P
[1][1] = '1') then
5211 Options
:= Options
or GAME_OPTION_TEAMDAMAGE
5213 Options
:= Options
and (not GAME_OPTION_TEAMDAMAGE
);
5216 if (LongBool(Options
and GAME_OPTION_TEAMDAMAGE
)) then
5217 g_Console_Add(_lc
[I_MSG_FRIENDLY_FIRE_ON
])
5219 g_Console_Add(_lc
[I_MSG_FRIENDLY_FIRE_OFF
]);
5221 if g_Game_IsNet
then MH_SEND_GameSettings
;
5224 else if (cmd
= 'g_weaponstay') and not g_Game_IsClient
then
5226 with gGameSettings
do
5228 if (Length(P
) > 1) and
5229 ((P
[1] = '1') or (P
[1] = '0')) then
5231 if (P
[1][1] = '1') then
5232 Options
:= Options
or GAME_OPTION_WEAPONSTAY
5234 Options
:= Options
and (not GAME_OPTION_WEAPONSTAY
);
5237 if (LongBool(Options
and GAME_OPTION_WEAPONSTAY
)) then
5238 g_Console_Add(_lc
[I_MSG_WEAPONSTAY_ON
])
5240 g_Console_Add(_lc
[I_MSG_WEAPONSTAY_OFF
]);
5242 if g_Game_IsNet
then MH_SEND_GameSettings
;
5245 else if cmd
= 'g_gamemode' then
5247 a
:= g_Game_TextToMode(P
[1]);
5248 if a
= GM_SINGLE
then a
:= GM_COOP
;
5249 if (Length(P
) > 1) and (a
<> GM_NONE
) and (not g_Game_IsClient
) then
5251 gSwitchGameMode
:= a
;
5252 if (gGameOn
and (gGameSettings
.GameMode
= GM_SINGLE
)) or
5253 (gState
= STATE_INTERSINGLE
) then
5254 gSwitchGameMode
:= GM_SINGLE
;
5256 gGameSettings
.GameMode
:= gSwitchGameMode
;
5258 if gSwitchGameMode
= gGameSettings
.GameMode
then
5259 g_Console_Add(Format(_lc
[I_MSG_GAMEMODE_CURRENT
],
5260 [g_Game_ModeToText(gGameSettings
.GameMode
)]))
5262 g_Console_Add(Format(_lc
[I_MSG_GAMEMODE_CHANGE
],
5263 [g_Game_ModeToText(gGameSettings
.GameMode
),
5264 g_Game_ModeToText(gSwitchGameMode
)]));
5266 else if (cmd
= 'g_allow_exit') and not g_Game_IsClient
then
5268 with gGameSettings
do
5270 if (Length(P
) > 1) and
5271 ((P
[1] = '1') or (P
[1] = '0')) then
5273 if (P
[1][1] = '1') then
5274 Options
:= Options
or GAME_OPTION_ALLOWEXIT
5276 Options
:= Options
and (not GAME_OPTION_ALLOWEXIT
);
5279 if (LongBool(Options
and GAME_OPTION_ALLOWEXIT
)) then
5280 g_Console_Add(_lc
[I_MSG_ALLOWEXIT_ON
])
5282 g_Console_Add(_lc
[I_MSG_ALLOWEXIT_OFF
]);
5283 g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
5285 if g_Game_IsNet
then MH_SEND_GameSettings
;
5288 else if (cmd
= 'g_allow_monsters') and not g_Game_IsClient
then
5290 with gGameSettings
do
5292 if (Length(P
) > 1) and
5293 ((P
[1] = '1') or (P
[1] = '0')) then
5295 if (P
[1][1] = '1') then
5296 Options
:= Options
or GAME_OPTION_MONSTERS
5298 Options
:= Options
and (not GAME_OPTION_MONSTERS
);
5301 if (LongBool(Options
and GAME_OPTION_MONSTERS
)) then
5302 g_Console_Add(_lc
[I_MSG_ALLOWMON_ON
])
5304 g_Console_Add(_lc
[I_MSG_ALLOWMON_OFF
]);
5305 g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
5307 if g_Game_IsNet
then MH_SEND_GameSettings
;
5310 else if (cmd
= 'g_bot_vsplayers') and not g_Game_IsClient
then
5312 with gGameSettings
do
5314 if (Length(P
) > 1) and
5315 ((P
[1] = '1') or (P
[1] = '0')) then
5317 if (P
[1][1] = '1') then
5318 Options
:= Options
or GAME_OPTION_BOTVSPLAYER
5320 Options
:= Options
and (not GAME_OPTION_BOTVSPLAYER
);
5323 if (LongBool(Options
and GAME_OPTION_BOTVSPLAYER
)) then
5324 g_Console_Add(_lc
[I_MSG_BOTSVSPLAYERS_ON
])
5326 g_Console_Add(_lc
[I_MSG_BOTSVSPLAYERS_OFF
]);
5328 if g_Game_IsNet
then MH_SEND_GameSettings
;
5331 else if (cmd
= 'g_bot_vsmonsters') and not g_Game_IsClient
then
5333 with gGameSettings
do
5335 if (Length(P
) > 1) and
5336 ((P
[1] = '1') or (P
[1] = '0')) then
5338 if (P
[1][1] = '1') then
5339 Options
:= Options
or GAME_OPTION_BOTVSMONSTER
5341 Options
:= Options
and (not GAME_OPTION_BOTVSMONSTER
);
5344 if (LongBool(Options
and GAME_OPTION_BOTVSMONSTER
)) then
5345 g_Console_Add(_lc
[I_MSG_BOTSVSMONSTERS_ON
])
5347 g_Console_Add(_lc
[I_MSG_BOTSVSMONSTERS_OFF
]);
5349 if g_Game_IsNet
then MH_SEND_GameSettings
;
5352 else if (cmd
= 'g_warmuptime') and not g_Game_IsClient
then
5354 if Length(P
) > 1 then
5356 if StrToIntDef(P
[1], gGameSettings
.WarmupTime
) = 0 then
5357 gGameSettings
.WarmupTime
:= 30
5359 gGameSettings
.WarmupTime
:= StrToIntDef(P
[1], gGameSettings
.WarmupTime
);
5362 g_Console_Add(Format(_lc
[I_MSG_WARMUP
],
5363 [gGameSettings
.WarmupTime
]));
5364 g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
5366 else if cmd
= 'net_interp' then
5368 if (Length(P
) > 1) then
5369 NetInterpLevel
:= StrToIntDef(P
[1], NetInterpLevel
);
5371 g_Console_Add('net_interp = ' + IntToStr(NetInterpLevel
));
5372 config
:= TConfig
.CreateFile(GameDir
+'/'+CONFIG_FILENAME
);
5373 config
.WriteInt('Client', 'InterpolationSteps', NetInterpLevel
);
5374 config
.SaveFile(GameDir
+'/'+CONFIG_FILENAME
);
5377 else if cmd
= 'net_forceplayerupdate' then
5379 if (Length(P
) > 1) and
5380 ((P
[1] = '1') or (P
[1] = '0')) then
5381 NetForcePlayerUpdate
:= (P
[1][1] = '1');
5383 if NetForcePlayerUpdate
then
5384 g_Console_Add('net_forceplayerupdate = 1')
5386 g_Console_Add('net_forceplayerupdate = 0');
5387 config
:= TConfig
.CreateFile(GameDir
+'/'+CONFIG_FILENAME
);
5388 config
.WriteBool('Client', 'ForcePlayerUpdate', NetForcePlayerUpdate
);
5389 config
.SaveFile(GameDir
+'/'+CONFIG_FILENAME
);
5392 else if cmd
= 'net_predictself' then
5394 if (Length(P
) > 1) and
5395 ((P
[1] = '1') or (P
[1] = '0')) then
5396 NetPredictSelf
:= (P
[1][1] = '1');
5398 if NetPredictSelf
then
5399 g_Console_Add('net_predictself = 1')
5401 g_Console_Add('net_predictself = 0');
5402 config
:= TConfig
.CreateFile(GameDir
+'/'+CONFIG_FILENAME
);
5403 config
.WriteBool('Client', 'PredictSelf', NetPredictSelf
);
5404 config
.SaveFile(GameDir
+'/'+CONFIG_FILENAME
);
5407 else if cmd
= 'sv_name' then
5409 if (Length(P
) > 1) and (Length(P
[1]) > 0) then
5411 NetServerName
:= P
[1];
5412 if Length(NetServerName
) > 64 then
5413 SetLength(NetServerName
, 64);
5414 if g_Game_IsServer
and g_Game_IsNet
and NetUseMaster
then
5418 g_Console_Add(cmd
+ ' = "' + NetServerName
+ '"');
5420 else if cmd
= 'sv_passwd' then
5422 if (Length(P
) > 1) and (Length(P
[1]) > 0) then
5424 NetPassword
:= P
[1];
5425 if Length(NetPassword
) > 24 then
5426 SetLength(NetPassword
, 24);
5427 if g_Game_IsServer
and g_Game_IsNet
and NetUseMaster
then
5431 g_Console_Add(cmd
+ ' = "' + AnsiLowerCase(NetPassword
) + '"');
5433 else if cmd
= 'sv_maxplrs' then
5435 if (Length(P
) > 1) then
5437 NetMaxClients
:= Min(Max(StrToIntDef(P
[1], NetMaxClients
), 1), NET_MAXCLIENTS
);
5438 if g_Game_IsServer
and g_Game_IsNet
then
5441 for a
:= 0 to High(NetClients
) do
5442 if NetClients
[a
].Used
then
5445 if b
> NetMaxClients
then
5447 s
:= g_Player_Get(NetClients
[a
].Player
).Name
;
5448 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_FULL
);
5449 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
5450 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
5453 if NetUseMaster
then
5458 g_Console_Add(cmd
+ ' = ' + IntToStr(NetMaxClients
));
5460 else if cmd
= 'sv_public' then
5462 if (Length(P
) > 1) then
5464 NetUseMaster
:= StrToIntDef(P
[1], Byte(NetUseMaster
)) > 0;
5465 if g_Game_IsServer
and g_Game_IsNet
then
5466 if NetUseMaster
then
5468 if NetMPeer
= nil then
5469 if not g_Net_Slist_Connect() then
5470 g_Console_Add(_lc
[I_NET_MSG_ERROR
] + _lc
[I_NET_SLIST_ERROR
]);
5471 g_Net_Slist_Update();
5474 if NetMPeer
<> nil then
5475 g_Net_Slist_Disconnect();
5478 g_Console_Add(cmd
+ ' = ' + IntToStr(Byte(NetUseMaster
)));
5480 else if cmd
= 'sv_intertime' then
5482 if (Length(P
) > 1) then
5483 gDefInterTime
:= Min(Max(StrToIntDef(P
[1], gDefInterTime
), -1), 120);
5485 g_Console_Add(cmd
+ ' = ' + IntToStr(gDefInterTime
));
5487 else if cmd
= 'p1_name' then
5489 if (Length(P
) > 1) and gGameOn
then
5491 if g_Game_IsClient
then
5493 gPlayer1Settings
.Name
:= b_Text_Unformat(P
[1]);
5494 MC_SEND_PlayerSettings
;
5497 if gPlayer1
<> nil then
5499 gPlayer1
.Name
:= b_Text_Unformat(P
[1]);
5500 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer1
.UID
);
5503 gPlayer1Settings
.Name
:= b_Text_Unformat(P
[1]);
5506 else if cmd
= 'p2_name' then
5508 if (Length(P
) > 1) and gGameOn
then
5510 if g_Game_IsClient
then
5512 gPlayer2Settings
.Name
:= b_Text_Unformat(P
[1]);
5513 MC_SEND_PlayerSettings
;
5516 if gPlayer2
<> nil then
5518 gPlayer2
.Name
:= b_Text_Unformat(P
[1]);
5519 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer2
.UID
);
5522 gPlayer2Settings
.Name
:= b_Text_Unformat(P
[1]);
5525 else if cmd
= 'p1_color' then
5527 if Length(P
) > 3 then
5528 if g_Game_IsClient
then
5530 gPlayer1Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
5531 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
5532 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
5533 MC_SEND_PlayerSettings
;
5536 if gPlayer1
<> nil then
5538 gPlayer1
.Model
.SetColor(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
5539 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
5540 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
5541 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer1
.UID
);
5544 gPlayer1Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
5545 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
5546 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
5548 else if (cmd
= 'p2_color') and not g_Game_IsNet
then
5550 if Length(P
) > 3 then
5551 if g_Game_IsClient
then
5553 gPlayer2Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
5554 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
5555 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
5556 MC_SEND_PlayerSettings
;
5559 if gPlayer2
<> nil then
5561 gPlayer2
.Model
.SetColor(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
5562 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
5563 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
5564 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer2
.UID
);
5567 gPlayer2Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
5568 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
5569 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
5571 else if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
5573 if cmd
= 'r_showtime' then
5575 if (Length(P
) > 1) and
5576 ((P
[1] = '1') or (P
[1] = '0')) then
5577 gShowTime
:= (P
[1][1] = '1');
5580 g_Console_Add(_lc
[I_MSG_TIME_ON
])
5582 g_Console_Add(_lc
[I_MSG_TIME_OFF
]);
5584 else if cmd
= 'r_showscore' then
5586 if (Length(P
) > 1) and
5587 ((P
[1] = '1') or (P
[1] = '0')) then
5588 gShowGoals
:= (P
[1][1] = '1');
5591 g_Console_Add(_lc
[I_MSG_SCORE_ON
])
5593 g_Console_Add(_lc
[I_MSG_SCORE_OFF
]);
5595 else if cmd
= 'r_showstat' then
5597 if (Length(P
) > 1) and
5598 ((P
[1] = '1') or (P
[1] = '0')) then
5599 gShowStat
:= (P
[1][1] = '1');
5602 g_Console_Add(_lc
[I_MSG_STATS_ON
])
5604 g_Console_Add(_lc
[I_MSG_STATS_OFF
]);
5606 else if cmd
= 'r_showkillmsg' then
5608 if (Length(P
) > 1) and
5609 ((P
[1] = '1') or (P
[1] = '0')) then
5610 gShowKillMsg
:= (P
[1][1] = '1');
5612 if gShowKillMsg
then
5613 g_Console_Add(_lc
[I_MSG_KILL_MSGS_ON
])
5615 g_Console_Add(_lc
[I_MSG_KILL_MSGS_OFF
]);
5617 else if cmd
= 'r_showlives' then
5619 if (Length(P
) > 1) and
5620 ((P
[1] = '1') or (P
[1] = '0')) then
5621 gShowLives
:= (P
[1][1] = '1');
5624 g_Console_Add(_lc
[I_MSG_LIVES_ON
])
5626 g_Console_Add(_lc
[I_MSG_LIVES_OFF
]);
5628 else if cmd
= 'r_showspect' then
5630 if (Length(P
) > 1) and
5631 ((P
[1] = '1') or (P
[1] = '0')) then
5632 gSpectHUD
:= (P
[1][1] = '1');
5635 g_Console_Add(_lc
[I_MSG_SPECT_HUD_ON
])
5637 g_Console_Add(_lc
[I_MSG_SPECT_HUD_OFF
]);
5639 else if cmd
= 'r_showping' then
5641 if (Length(P
) > 1) and
5642 ((P
[1] = '1') or (P
[1] = '0')) then
5643 gShowPing
:= (P
[1][1] = '1');
5646 g_Console_Add(_lc
[I_MSG_PING_ON
])
5648 g_Console_Add(_lc
[I_MSG_PING_OFF
]);
5650 else if (cmd
= 'g_scorelimit') and not g_Game_IsClient
then
5652 if Length(P
) > 1 then
5654 if StrToIntDef(P
[1], gGameSettings
.GoalLimit
) = 0 then
5655 gGameSettings
.GoalLimit
:= 0
5660 if gGameSettings
.GameMode
= GM_DM
then
5662 stat
:= g_Player_GetStats();
5664 for a
:= 0 to High(stat
) do
5665 if stat
[a
].Frags
> b
then
5669 b
:= Max(gTeamStat
[TEAM_RED
].Goals
, gTeamStat
[TEAM_BLUE
].Goals
);
5671 gGameSettings
.GoalLimit
:= Max(StrToIntDef(P
[1], gGameSettings
.GoalLimit
), b
);
5674 if g_Game_IsNet
then MH_SEND_GameSettings
;
5677 g_Console_Add(Format(_lc
[I_MSG_SCORE_LIMIT
], [gGameSettings
.GoalLimit
]));
5679 else if (cmd
= 'g_timelimit') and not g_Game_IsClient
then
5681 if (Length(P
) > 1) and (StrToIntDef(P
[1], -1) >= 0) then
5682 gGameSettings
.TimeLimit
:= StrToIntDef(P
[1], -1);
5684 g_Console_Add(Format(_lc
[I_MSG_TIME_LIMIT
],
5685 [gGameSettings
.TimeLimit
div 3600,
5686 (gGameSettings
.TimeLimit
div 60) mod 60,
5687 gGameSettings
.TimeLimit
mod 60]));
5688 if g_Game_IsNet
then MH_SEND_GameSettings
;
5690 else if (cmd
= 'g_maxlives') and not g_Game_IsClient
then
5692 if Length(P
) > 1 then
5694 if StrToIntDef(P
[1], gGameSettings
.MaxLives
) = 0 then
5695 gGameSettings
.MaxLives
:= 0
5699 stat
:= g_Player_GetStats();
5701 for a
:= 0 to High(stat
) do
5702 if stat
[a
].Lives
> b
then
5704 gGameSettings
.MaxLives
:=
5705 Max(StrToIntDef(P
[1], gGameSettings
.MaxLives
), b
);
5709 g_Console_Add(Format(_lc
[I_MSG_LIVES
],
5710 [gGameSettings
.MaxLives
]));
5711 if g_Game_IsNet
then MH_SEND_GameSettings
;
5716 procedure PrintHeapStats();
5720 hs
:= GetFPCHeapStatus();
5721 e_LogWriteLn ('v===== heap status =====v');
5722 e_LogWriteFln('max heap size = %d k', [hs
.MaxHeapSize
div 1024]);
5723 e_LogWriteFln('max heap used = %d k', [hs
.MaxHeapUsed
div 1024]);
5724 e_LogWriteFln('cur heap size = %d k', [hs
.CurrHeapSize
div 1024]);
5725 e_LogWriteFln('cur heap used = %d k', [hs
.CurrHeapUsed
div 1024]);
5726 e_LogWriteFln('cur heap free = %d k', [hs
.CurrHeapFree
div 1024]);
5727 e_LogWriteLn ('^=======================^');
5730 procedure DebugCommands(P
: SSArray
);
5737 // Êîìàíäû îòëàäî÷íîãî ðåæèìà:
5738 if {gDebugMode}conIsCheatsEnabled
then
5740 cmd
:= LowerCase(P
[0]);
5741 if cmd
= 'd_window' then
5743 g_Console_Add(Format('gWinPosX = %d, gWinPosY %d', [gWinPosX
, gWinPosY
]));
5744 g_Console_Add(Format('gWinRealPosX = %d, gWinRealPosY %d', [gWinRealPosX
, gWinRealPosY
]));
5745 g_Console_Add(Format('gScreenWidth = %d, gScreenHeight = %d', [gScreenWidth
, gScreenHeight
]));
5746 g_Console_Add(Format('gWinSizeX = %d, gWinSizeY = %d', [gWinSizeX
, gWinSizeY
]));
5747 g_Console_Add(Format('Frame X = %d, Y = %d, Caption Y = %d', [gWinFrameX
, gWinFrameY
, gWinCaption
]));
5749 else if cmd
= 'd_sounds' then
5751 if (Length(P
) > 1) and
5752 ((P
[1] = '1') or (P
[1] = '0')) then
5753 g_Debug_Sounds
:= (P
[1][1] = '1');
5755 g_Console_Add(Format('d_sounds is %d', [Byte(g_Debug_Sounds
)]));
5757 else if cmd
= 'd_frames' then
5759 if (Length(P
) > 1) and
5760 ((P
[1] = '1') or (P
[1] = '0')) then
5761 g_Debug_Frames
:= (P
[1][1] = '1');
5763 g_Console_Add(Format('d_frames is %d', [Byte(g_Debug_Frames
)]));
5765 else if cmd
= 'd_winmsg' then
5767 if (Length(P
) > 1) and
5768 ((P
[1] = '1') or (P
[1] = '0')) then
5769 g_Debug_WinMsgs
:= (P
[1][1] = '1');
5771 g_Console_Add(Format('d_winmsg is %d', [Byte(g_Debug_WinMsgs
)]));
5773 else if (cmd
= 'd_monoff') and not g_Game_IsNet
then
5775 if (Length(P
) > 1) and
5776 ((P
[1] = '1') or (P
[1] = '0')) then
5777 g_Debug_MonsterOff
:= (P
[1][1] = '1');
5779 g_Console_Add(Format('d_monoff is %d', [Byte(g_debug_MonsterOff
)]));
5781 else if (cmd
= 'd_botoff') and not g_Game_IsNet
then
5783 if Length(P
) > 1 then
5785 '0': g_debug_BotAIOff
:= 0;
5786 '1': g_debug_BotAIOff
:= 1;
5787 '2': g_debug_BotAIOff
:= 2;
5788 '3': g_debug_BotAIOff
:= 3;
5791 g_Console_Add(Format('d_botoff is %d', [g_debug_BotAIOff
]));
5793 else if cmd
= 'd_monster' then
5795 if gGameOn
and (gPlayer1
<> nil) and (gPlayer1
.alive
) and (not g_Game_IsNet
) then
5796 if Length(P
) < 2 then
5798 g_Console_Add(cmd
+ ' [ID | Name] [behaviour]');
5799 g_Console_Add('ID | Name');
5800 for b
:= MONSTER_DEMON
to MONSTER_MAN
do
5801 g_Console_Add(Format('%2d | %s', [b
, g_Mons_NameByTypeId(b
)]));
5802 conwriteln('behav. num'#10'normal 0'#10'killer 1'#10'maniac 2'#10'insane 3'#10'cannibal 4'#10'good 5');
5805 a
:= StrToIntDef(P
[1], 0);
5806 if (a
< MONSTER_DEMON
) or (a
> MONSTER_MAN
) then
5807 a
:= g_Mons_TypeIdByName(P
[1]);
5809 if (a
< MONSTER_DEMON
) or (a
> MONSTER_MAN
) then
5810 g_Console_Add(Format(_lc
[I_MSG_NO_MONSTER
], [P
[1]]))
5813 with gPlayer1
.Obj
do
5815 mon
:= g_Monsters_Create(a
,
5816 X
+ Rect
.X
+ (Rect
.Width
div 2),
5817 Y
+ Rect
.Y
+ Rect
.Height
,
5818 gPlayer1
.Direction
, True);
5820 if (Length(P
) > 2) and (mon
<> nil) then
5822 if (CompareText(P
[2], 'normal') = 0) then mon
.MonsterBehaviour
:= BH_NORMAL
5823 else if (CompareText(P
[2], 'killer') = 0) then mon
.MonsterBehaviour
:= BH_KILLER
5824 else if (CompareText(P
[2], 'maniac') = 0) then mon
.MonsterBehaviour
:= BH_MANIAC
5825 else if (CompareText(P
[2], 'insane') = 0) then mon
.MonsterBehaviour
:= BH_INSANE
5826 else if (CompareText(P
[2], 'cannibal') = 0) then mon
.MonsterBehaviour
:= BH_CANNIBAL
5827 else if (CompareText(P
[2], 'good') = 0) then mon
.MonsterBehaviour
:= BH_GOOD
5828 else if (CompareText(P
[2], 'friend') = 0) then mon
.MonsterBehaviour
:= BH_GOOD
5829 else if (CompareText(P
[2], 'friendly') = 0) then mon
.MonsterBehaviour
:= BH_GOOD
5830 else mon
.MonsterBehaviour
:= Min(Max(StrToIntDef(P
[2], BH_NORMAL
), BH_NORMAL
), BH_GOOD
);
5835 else if (cmd
= 'd_health') then
5837 if (Length(P
) > 1) and
5838 ((P
[1] = '1') or (P
[1] = '0')) then
5839 g_debug_HealthBar
:= (P
[1][1] = '1');
5841 g_Console_Add(Format('d_health is %d', [Byte(g_debug_HealthBar
)]));
5843 else if (cmd
= 'd_player') then
5845 if (Length(P
) > 1) and
5846 ((P
[1] = '1') or (P
[1] = '0')) then
5847 g_debug_Player
:= (P
[1][1] = '1');
5849 g_Console_Add(Format(cmd
+ ' is %d', [Byte(g_Debug_Player
)]));
5851 else if (cmd
= 'd_mem') then
5857 g_Console_Add(_lc
[I_MSG_NOT_DEBUG
]);
5861 procedure GameCheats(P
: SSArray
);
5867 if (not gGameOn
) or (not conIsCheatsEnabled
) then
5869 g_Console_Add('not available');
5875 g_Console_Add('where is the player?!');
5878 cmd
:= LowerCase(P
[0]);
5882 plr
.GodMode
:= not plr
.GodMode
;
5883 if plr
.GodMode
then g_Console_Add('player is godlike now') else g_Console_Add('player is mortal now');
5886 // give <health|exit|weapons|air|suit|jetpack|berserk|all>
5887 if cmd
= 'give' then
5889 if length(P
) < 2 then begin g_Console_Add('give what?!'); exit
; end;
5890 for f
:= 1 to High(P
) do
5892 cmd
:= LowerCase(P
[f
]);
5893 if cmd
= 'health' then begin plr
.RestoreHealthArmor(); g_Console_Add('player feels himself better'); continue
; end;
5894 if (cmd
= 'all') {or (cmd = 'weapons')} then begin plr
.AllRulez(False); g_Console_Add('player got the gifts'); continue
; end;
5895 if cmd
= 'exit' then
5897 if gTriggers
<> nil then
5899 for a
:= 0 to High(gTriggers
) do
5901 if gTriggers
[a
].TriggerType
= TRIGGER_EXIT
then
5903 g_Console_Add('player left the map');
5904 gExitByTrigger
:= True;
5905 //g_Game_ExitLevel(gTriggers[a].Data.MapName);
5906 g_Game_ExitLevel(gTriggers
[a
].tgcMap
);
5914 if cmd
= 'air' then begin plr
.GiveItem(ITEM_OXYGEN
); g_Console_Add('player got some air'); continue
; end;
5915 if cmd
= 'jetpack' then begin plr
.GiveItem(ITEM_JETPACK
); g_Console_Add('player got a jetpack'); continue
; end;
5916 if cmd
= 'suit' then begin plr
.GiveItem(ITEM_SUIT
); g_Console_Add('player got an envirosuit'); continue
; end;
5917 if cmd
= 'berserk' then begin plr
.GiveItem(ITEM_MEDKIT_BLACK
); g_Console_Add('player got a berserk pack'); continue
; end;
5918 if cmd
= 'backpack' then begin plr
.GiveItem(ITEM_AMMO_BACKPACK
); g_Console_Add('player got a backpack'); continue
; end;
5920 if cmd
= 'helmet' then begin plr
.GiveItem(ITEM_HELMET
); g_Console_Add('player got a helmet'); continue
; end;
5921 if cmd
= 'bottle' then begin plr
.GiveItem(ITEM_BOTTLE
); g_Console_Add('player got a bottle of health'); continue
; end;
5923 if cmd
= 'stimpack' then begin plr
.GiveItem(ITEM_MEDKIT_SMALL
); g_Console_Add('player got a stimpack'); continue
; end;
5924 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;
5926 if cmd
= 'greenarmor' then begin plr
.GiveItem(ITEM_ARMOR_GREEN
); g_Console_Add('player got a security armor'); continue
; end;
5927 if cmd
= 'bluearmor' then begin plr
.GiveItem(ITEM_ARMOR_BLUE
); g_Console_Add('player got a combat armor'); continue
; end;
5929 if (cmd
= 'megasphere') or (cmd
= 'mega') then begin plr
.GiveItem(ITEM_SPHERE_BLUE
); g_Console_Add('player got a megasphere'); continue
; end;
5930 if (cmd
= 'soulsphere') or (cmd
= 'soul')then begin plr
.GiveItem(ITEM_SPHERE_WHITE
); g_Console_Add('player got a soul sphere'); continue
; end;
5932 if (cmd
= 'invul') or (cmd
= 'invulnerability') then begin plr
.GiveItem(ITEM_INVUL
); g_Console_Add('player got invulnerability'); continue
; end;
5933 if (cmd
= 'invis') or (cmd
= 'invisibility') then begin plr
.GiveItem(ITEM_INVIS
); g_Console_Add('player got invisibility'); continue
; end;
5935 if cmd
= 'redkey' then begin plr
.GiveItem(ITEM_KEY_RED
); g_Console_Add('player got the red key'); continue
; end;
5936 if cmd
= 'greenkey' then begin plr
.GiveItem(ITEM_KEY_GREEN
); g_Console_Add('player got the green key'); continue
; end;
5937 if cmd
= 'bluekey' then begin plr
.GiveItem(ITEM_KEY_BLUE
); g_Console_Add('player got the blue key'); continue
; end;
5939 if (cmd
= 'shotgun') or (cmd
= 'sg') then begin plr
.GiveItem(ITEM_WEAPON_SHOTGUN1
); g_Console_Add('player got a shotgun'); continue
; end;
5940 if (cmd
= 'supershotgun') or (cmd
= 'ssg') then begin plr
.GiveItem(ITEM_WEAPON_SHOTGUN2
); g_Console_Add('player got a supershotgun'); continue
; end;
5941 if cmd
= 'chaingun' then begin plr
.GiveItem(ITEM_WEAPON_CHAINGUN
); g_Console_Add('player got a chaingun'); continue
; end;
5942 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;
5943 if cmd
= 'plasmagun' then begin plr
.GiveItem(ITEM_WEAPON_PLASMA
); g_Console_Add('player got a plasma gun'); continue
; end;
5944 if cmd
= 'bfg' then begin plr
.GiveItem(ITEM_WEAPON_BFG
); g_Console_Add('player got a BFG-9000'); continue
; end;
5946 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;
5947 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;
5948 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;
5949 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;
5950 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;
5951 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;
5953 if cmd
= 'superchaingun' then begin plr
.GiveItem(ITEM_WEAPON_SUPERPULEMET
); g_Console_Add('player got a superchaingun'); continue
; end;
5954 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;
5956 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;
5957 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;
5959 if cmd
= 'chainsaw' then begin plr
.GiveItem(ITEM_WEAPON_SAW
); g_Console_Add('player got a chainsaw'); continue
; end;
5961 if cmd
= 'ammo' then
5963 plr
.GiveItem(ITEM_AMMO_SHELLS_BOX
);
5964 plr
.GiveItem(ITEM_AMMO_BULLETS_BOX
);
5965 plr
.GiveItem(ITEM_AMMO_CELL_BIG
);
5966 plr
.GiveItem(ITEM_AMMO_ROCKET_BOX
);
5967 plr
.GiveItem(ITEM_AMMO_FUELCAN
);
5968 g_Console_Add('player got some ammo');
5972 if cmd
= 'clip' then begin plr
.GiveItem(ITEM_AMMO_BULLETS
); g_Console_Add('player got some bullets'); continue
; end;
5973 if cmd
= 'bullets' then begin plr
.GiveItem(ITEM_AMMO_BULLETS_BOX
); g_Console_Add('player got a box of bullets'); continue
; end;
5975 if cmd
= 'shells' then begin plr
.GiveItem(ITEM_AMMO_SHELLS
); g_Console_Add('player got some shells'); continue
; end;
5976 if cmd
= 'shellbox' then begin plr
.GiveItem(ITEM_AMMO_SHELLS_BOX
); g_Console_Add('player got a box of shells'); continue
; end;
5978 if cmd
= 'cells' then begin plr
.GiveItem(ITEM_AMMO_CELL
); g_Console_Add('player got some cells'); continue
; end;
5979 if cmd
= 'battery' then begin plr
.GiveItem(ITEM_AMMO_CELL_BIG
); g_Console_Add('player got cell battery'); continue
; end;
5981 if cmd
= 'rocket' then begin plr
.GiveItem(ITEM_AMMO_ROCKET
); g_Console_Add('player got a rocket'); continue
; end;
5982 if cmd
= 'rocketbox' then begin plr
.GiveItem(ITEM_AMMO_ROCKET_BOX
); g_Console_Add('player got some rockets'); continue
; end;
5984 if (cmd
= 'fuel') or (cmd
= 'fuelcan') then begin plr
.GiveItem(ITEM_AMMO_FUELCAN
); g_Console_Add('player got fuel canister'); continue
; end;
5986 if cmd
= 'weapons' then
5988 plr
.GiveItem(ITEM_WEAPON_SHOTGUN1
);
5989 plr
.GiveItem(ITEM_WEAPON_SHOTGUN2
);
5990 plr
.GiveItem(ITEM_WEAPON_CHAINGUN
);
5991 plr
.GiveItem(ITEM_WEAPON_ROCKETLAUNCHER
);
5992 plr
.GiveItem(ITEM_WEAPON_PLASMA
);
5993 plr
.GiveItem(ITEM_WEAPON_BFG
);
5994 g_Console_Add('player got weapons');
5998 if cmd
= 'keys' then
6000 plr
.GiveItem(ITEM_KEY_RED
);
6001 plr
.GiveItem(ITEM_KEY_GREEN
);
6002 plr
.GiveItem(ITEM_KEY_BLUE
);
6003 g_Console_Add('player got all keys');
6007 g_Console_Add('i don''t know how to give '''+cmd
+'''!');
6012 if cmd
= 'open' then
6014 g_Console_Add('player activated sesame');
6015 g_Triggers_OpenAll();
6022 if gFly
then g_Console_Add('player feels himself lighter') else g_Console_Add('player lost his wings');
6026 if cmd
= 'noclip' then
6029 g_Console_Add('wall hardeness adjusted');
6033 if cmd
= 'notarget' then
6035 plr
.NoTarget
:= not plr
.NoTarget
;
6036 if plr
.NoTarget
then g_Console_Add('player hides in shadows') else g_Console_Add('player is brave again');
6040 if cmd
= 'noreload' then
6042 plr
.NoReload
:= not plr
.NoReload
;
6043 if plr
.NoReload
then g_Console_Add('player is action hero now') else g_Console_Add('player is ordinary man now');
6047 if cmd
= 'speedy' then
6049 MAX_RUNVEL
:= 32-MAX_RUNVEL
;
6050 g_Console_Add('speed adjusted');
6054 if cmd
= 'jumpy' then
6056 VEL_JUMP
:= 30-VEL_JUMP
;
6057 g_Console_Add('jump height adjusted');
6061 if cmd
= 'automap' then
6063 gShowMap
:= not gShowMap
;
6064 if gShowMap
then g_Console_Add('player gains second sight') else g_Console_Add('player lost second sight');
6068 if cmd
= 'aimline' then
6070 gAimLine
:= not gAimLine
;
6071 if gAimLine
then g_Console_Add('player gains laser sight') else g_Console_Add('player lost laser sight');
6076 procedure GameCommands(P
: SSArray
);
6082 pl
: pTNetClient
= nil;
6089 cmd
:= LowerCase(P
[0]);
6091 if (cmd
= 'quit') or
6098 else if cmd
= 'pause' then
6100 if (g_ActiveWindow
= nil) then
6101 g_Game_Pause(not gPauseMain
);
6103 else if cmd
= 'endgame' then
6104 gExit
:= EXIT_SIMPLE
6105 else if cmd
= 'restart' then
6107 if gGameOn
or (gState
in [STATE_INTERSINGLE
, STATE_INTERCUSTOM
]) then
6109 if g_Game_IsClient
then
6111 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6116 g_Console_Add(_lc
[I_MSG_NOT_GAME
]);
6118 else if cmd
= 'kick' then
6120 if g_Game_IsServer
then
6122 if Length(P
) < 2 then
6124 g_Console_Add('kick <name>');
6129 g_Console_Add('kick <name>');
6133 if g_Game_IsNet
then
6134 pl
:= g_Net_Client_ByName(P
[1]);
6137 s
:= g_Net_ClientName_ByID(pl
^.ID
);
6138 enet_peer_disconnect(pl
^.Peer
, NET_DISC_KICK
);
6139 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
6140 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
6141 if NetUseMaster
then
6143 end else if gPlayers
<> nil then
6144 for a
:= Low(gPlayers
) to High(gPlayers
) do
6145 if gPlayers
[a
] <> nil then
6146 if Copy(LowerCase(gPlayers
[a
].Name
), 1, Length(P
[1])) = LowerCase(P
[1]) then
6148 // Íå îòêëþ÷àòü îñíîâíûõ èãðîêîâ â ñèíãëå
6149 if not(gPlayers
[a
] is TBot
) and (gGameSettings
.GameType
= GT_SINGLE
) then
6151 gPlayers
[a
].Lives
:= 0;
6152 gPlayers
[a
].Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
6153 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [gPlayers
[a
].Name
]), True);
6154 g_Player_Remove(gPlayers
[a
].UID
);
6155 if NetUseMaster
then
6157 // Åñëè íå ïåðåìåøàòü, ïðè äîáàâëåíèè íîâûõ áîòîâ ïîÿâÿòñÿ ñòàðûå
6161 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6163 else if cmd
= 'kick_id' then
6165 if g_Game_IsServer
and g_Game_IsNet
then
6167 if Length(P
) < 2 then
6169 g_Console_Add('kick_id <client ID>');
6174 g_Console_Add('kick_id <client ID>');
6178 a
:= StrToIntDef(P
[1], 0);
6179 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
6181 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
6183 s
:= g_Net_ClientName_ByID(NetClients
[a
].ID
);
6184 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_KICK
);
6185 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
6186 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
6187 if NetUseMaster
then
6192 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6194 else if cmd
= 'ban' then
6196 if g_Game_IsServer
and g_Game_IsNet
then
6198 if Length(P
) < 2 then
6200 g_Console_Add('ban <name>');
6205 g_Console_Add('ban <name>');
6209 pl
:= g_Net_Client_ByName(P
[1]);
6212 s
:= g_Net_ClientName_ByID(pl
^.ID
);
6213 g_Net_BanHost(pl
^.Peer
^.address
.host
, False);
6214 enet_peer_disconnect(pl
^.Peer
, NET_DISC_TEMPBAN
);
6215 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
6216 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
6217 if NetUseMaster
then
6220 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
6222 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6224 else if cmd
= 'ban_id' then
6226 if g_Game_IsServer
and g_Game_IsNet
then
6228 if Length(P
) < 2 then
6230 g_Console_Add('ban_id <client ID>');
6235 g_Console_Add('ban_id <client ID>');
6239 a
:= StrToIntDef(P
[1], 0);
6240 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
6241 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
6243 s
:= g_Net_ClientName_ByID(NetClients
[a
].ID
);
6244 g_Net_BanHost(NetClients
[a
].Peer
^.address
.host
, False);
6245 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_TEMPBAN
);
6246 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
6247 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
6248 if NetUseMaster
then
6252 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6254 else if cmd
= 'permban' then
6256 if g_Game_IsServer
and g_Game_IsNet
then
6258 if Length(P
) < 2 then
6260 g_Console_Add('permban <name>');
6265 g_Console_Add('permban <name>');
6269 pl
:= g_Net_Client_ByName(P
[1]);
6272 s
:= g_Net_ClientName_ByID(pl
^.ID
);
6273 g_Net_BanHost(pl
^.Peer
^.address
.host
);
6274 enet_peer_disconnect(pl
^.Peer
, NET_DISC_BAN
);
6275 g_Net_SaveBanList();
6276 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
6277 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
6278 if NetUseMaster
then
6281 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
6283 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6285 else if cmd
= 'permban_id' then
6287 if g_Game_IsServer
and g_Game_IsNet
then
6289 if Length(P
) < 2 then
6291 g_Console_Add('permban_id <client ID>');
6296 g_Console_Add('permban_id <client ID>');
6300 a
:= StrToIntDef(P
[1], 0);
6301 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
6302 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
6304 s
:= g_Net_ClientName_ByID(NetClients
[a
].ID
);
6305 g_Net_BanHost(NetClients
[a
].Peer
^.address
.host
);
6306 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_BAN
);
6307 g_Net_SaveBanList();
6308 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
6309 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
6310 if NetUseMaster
then
6314 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6316 else if cmd
= 'unban' then
6318 if g_Game_IsServer
and g_Game_IsNet
then
6320 if Length(P
) < 2 then
6322 g_Console_Add('unban <IP Address>');
6327 g_Console_Add('unban <IP Address>');
6331 if g_Net_UnbanHost(P
[1]) then
6333 g_Console_Add(Format(_lc
[I_MSG_UNBAN_OK
], [P
[1]]));
6334 g_Net_SaveBanList();
6336 g_Console_Add(Format(_lc
[I_MSG_UNBAN_FAIL
], [P
[1]]));
6338 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6340 else if cmd
= 'clientlist' then
6342 if g_Game_IsServer
and g_Game_IsNet
then
6345 if NetClients
<> nil then
6346 for a
:= Low(NetClients
) to High(NetClients
) do
6347 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
6349 plr
:= g_Player_Get(NetClients
[a
].Player
);
6350 if plr
= nil then continue
;
6352 g_Console_Add(Format('#%2d: %-15s | %s', [a
,
6353 IpToStr(NetClients
[a
].Peer
^.address
.host
), plr
.Name
]));
6356 g_Console_Add(_lc
[I_MSG_NOCLIENTS
]);
6358 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6360 else if cmd
= 'connect' then
6362 if (NetMode
= NET_NONE
) then
6364 if Length(P
) < 2 then
6366 g_Console_Add('connect <IP> [port] [password]');
6371 g_Console_Add('connect <IP> [port] [password]');
6375 if Length(P
) > 2 then
6376 prt
:= StrToIntDef(P
[2], 25666)
6380 if Length(P
) > 3 then
6385 g_Game_StartClient(P
[1], prt
, pw
);
6388 else if cmd
= 'disconnect' then
6390 if (NetMode
= NET_CLIENT
) then
6393 else if cmd
= 'reconnect' then
6395 if (NetMode
= NET_SERVER
) then
6398 if (NetMode
= NET_CLIENT
) then
6401 gExit
:= EXIT_SIMPLE
;
6405 //TODO: Use last successful password to reconnect, instead of ''
6406 g_Game_StartClient(NetClientIP
, NetClientPort
, '');
6408 else if (cmd
= 'addbot') or
6409 (cmd
= 'bot_add') then
6411 if Length(P
) > 1 then
6412 g_Bot_Add(TEAM_NONE
, StrToIntDef(P
[1], 2))
6414 g_Bot_Add(TEAM_NONE
, 2);
6416 else if cmd
= 'bot_addlist' then
6418 if Length(P
) > 1 then
6419 if Length(P
) = 2 then
6420 g_Bot_AddList(TEAM_NONE
, P
[1], StrToIntDef(P
[1], -1))
6422 g_Bot_AddList(IfThen(P
[2] = 'red', TEAM_RED
, TEAM_BLUE
), P
[1], StrToIntDef(P
[1], -1));
6424 else if cmd
= 'bot_removeall' then
6426 else if cmd
= 'chat' then
6428 if g_Game_IsNet
then
6430 if Length(P
) > 1 then
6432 for a
:= 1 to High(P
) do
6433 chstr
:= chstr
+ P
[a
] + ' ';
6435 if Length(chstr
) > 200 then SetLength(chstr
, 200);
6437 if Length(chstr
) < 1 then
6439 g_Console_Add('chat <text>');
6443 chstr
:= b_Text_Format(chstr
);
6444 if g_Game_IsClient
then
6445 MC_SEND_Chat(chstr
, NET_CHAT_PLAYER
)
6447 MH_SEND_Chat(gPlayer1Settings
.Name
+ ': ' + chstr
, NET_CHAT_PLAYER
);
6450 g_Console_Add('chat <text>');
6452 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6454 else if cmd
= 'teamchat' then
6456 if g_Game_IsNet
and (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
6458 if Length(P
) > 1 then
6460 for a
:= 1 to High(P
) do
6461 chstr
:= chstr
+ P
[a
] + ' ';
6463 if Length(chstr
) > 200 then SetLength(chstr
, 200);
6465 if Length(chstr
) < 1 then
6467 g_Console_Add('teamchat <text>');
6471 chstr
:= b_Text_Format(chstr
);
6472 if g_Game_IsClient
then
6473 MC_SEND_Chat(chstr
, NET_CHAT_TEAM
)
6475 MH_SEND_Chat(gPlayer1Settings
.Name
+ ': ' + chstr
, NET_CHAT_TEAM
,
6476 gPlayer1Settings
.Team
);
6479 g_Console_Add('teamchat <text>');
6481 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6483 else if cmd
= 'game' then
6485 if gGameSettings
.GameType
<> GT_NONE
then
6487 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6490 if Length(P
) = 1 then
6492 g_Console_Add(cmd
+ ' <WAD> [MAP] [# players]');
6495 // Èãðà åù¸ íå çàïóùåíà, ñíà÷àëà íàì íàäî çàãðóçèòü êàêîé-òî WAD
6496 P
[1] := addWadExtension(P
[1]);
6497 if FileExists(MapsDir
+ P
[1]) then
6499 // Åñëè êàðòà íå óêàçàíà, áåð¸ì ïåðâóþ êàðòó â ôàéëå
6500 if Length(P
) < 3 then
6503 P
[2] := g_Game_GetFirstMap(MapsDir
+ P
[1]);
6506 s
:= P
[1] + ':\' + UpperCase(P
[2]);
6508 if g_Map_Exist(MapsDir
+ s
) then
6510 // Çàïóñêàåì ñâîþ èãðó
6512 with gGameSettings
do
6514 GameMode
:= g_Game_TextToMode(gcGameMode
);
6515 if gSwitchGameMode
<> GM_NONE
then
6516 GameMode
:= gSwitchGameMode
;
6517 if GameMode
= GM_NONE
then GameMode
:= GM_DM
;
6518 if GameMode
= GM_SINGLE
then GameMode
:= GM_COOP
;
6520 if Length(P
) >= 4 then
6521 b
:= StrToIntDef(P
[3], 1);
6522 g_Game_StartCustom(s
, GameMode
, TimeLimit
,
6523 GoalLimit
, MaxLives
, Options
, b
);
6528 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
6530 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [UpperCase(P
[2]), P
[1]]));
6532 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]));
6534 else if cmd
= 'host' then
6536 if gGameSettings
.GameType
<> GT_NONE
then
6538 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6541 if Length(P
) < 4 then
6543 g_Console_Add(cmd
+ ' <listen IP> <port> <WAD> [MAP] [# players]');
6546 if not StrToIp(P
[1], listen
) then
6548 prt
:= StrToIntDef(P
[2], 25666);
6550 P
[3] := addWadExtension(P
[3]);
6551 if FileExists(MapsDir
+ P
[3]) then
6553 // Åñëè êàðòà íå óêàçàíà, áåð¸ì ïåðâóþ êàðòó â ôàéëå
6554 if Length(P
) < 5 then
6557 P
[4] := g_Game_GetFirstMap(MapsDir
+ P
[1]);
6560 s
:= P
[3] + ':\' + UpperCase(P
[4]);
6562 if g_Map_Exist(MapsDir
+ s
) then
6564 // Çàïóñêàåì ñâîþ èãðó
6566 with gGameSettings
do
6568 GameMode
:= g_Game_TextToMode(gcGameMode
);
6569 if gSwitchGameMode
<> GM_NONE
then
6570 GameMode
:= gSwitchGameMode
;
6571 if GameMode
= GM_NONE
then GameMode
:= GM_DM
;
6572 if GameMode
= GM_SINGLE
then GameMode
:= GM_COOP
;
6574 if Length(P
) >= 6 then
6575 b
:= StrToIntDef(P
[5], 0);
6576 g_Game_StartServer(s
, GameMode
, TimeLimit
,
6577 GoalLimit
, MaxLives
, Options
, b
, listen
, prt
);
6582 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[3]]))
6584 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [UpperCase(P
[4]), P
[3]]));
6586 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[3]]));
6588 else if cmd
= 'map' then
6590 if Length(P
) = 1 then
6592 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
6594 g_Console_Add(cmd
+ ' <MAP>');
6595 g_Console_Add(cmd
+ ' <WAD> [MAP]');
6597 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6599 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
6601 // Èä¸ò ñâîÿ èãðà èëè ñåðâåð
6602 if Length(P
) < 3 then
6604 // Ïåðâûé ïàðàìåòð - ëèáî êàðòà, ëèáî èìÿ WAD ôàéëà
6605 s
:= UpperCase(P
[1]);
6606 if g_Map_Exist(MapsDir
+ gGameSettings
.WAD
+ ':\' + s
) then
6607 begin // Êàðòà íàøëàñü
6608 gExitByTrigger
:= False;
6610 begin // Èä¸ò èãðà - çàâåðøàåì óðîâåíü
6612 gExit
:= EXIT_ENDLEVELCUSTOM
;
6614 else // Èíòåðìèññèÿ - ñðàçó çàãðóæàåì êàðòó
6615 g_Game_ChangeMap(s
);
6618 // Òàêîé êàðòû íåò, èùåì WAD ôàéë
6619 pw
:= findDiskWad(MapsDir
+ P
[1]);
6620 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [s
, 'WAD ' + P
[1]]));
6621 if FileExists(pw
) then
6623 // Ïàðàìåòðà êàðòû íåò, ïîýòîìó ñòàâèì ïåðâóþ èç ôàéëà
6625 P
[1] := ExtractRelativePath(MapsDir
, pw
);
6626 P
[2] := g_Game_GetFirstMap(MapsDir
+ P
[1]);
6628 s
:= P
[1] + ':\' + P
[2];
6630 if g_Map_Exist(MapsDir
+ s
) then
6632 gExitByTrigger
:= False;
6634 begin // Èä¸ò èãðà - çàâåðøàåì óðîâåíü
6636 gExit
:= EXIT_ENDLEVELCUSTOM
;
6638 else // Èíòåðìèññèÿ - ñðàçó çàãðóæàåì êàðòó
6639 g_Game_ChangeMap(s
);
6642 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
6644 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]));
6646 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]));
6650 // Óêàçàíî äâà ïàðàìåòðà, çíà÷èò ïåðâûé - WAD ôàéë, à âòîðîé - êàðòà
6651 P
[1] := addWadExtension(P
[1]);
6652 if FileExists(MapsDir
+ P
[1]) then
6655 P
[2] := UpperCase(P
[2]);
6656 s
:= P
[1] + ':\' + P
[2];
6658 if g_Map_Exist(MapsDir
+ s
) then
6659 begin // Íàøëè êàðòó
6660 gExitByTrigger
:= False;
6662 begin // Èä¸ò èãðà - çàâåðøàåì óðîâåíü
6664 gExit
:= EXIT_ENDLEVELCUSTOM
;
6666 else // Èíòåðìèññèÿ - ñðàçó çàãðóæàåì êàðòó
6667 g_Game_ChangeMap(s
);
6669 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]));
6671 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]));
6674 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6676 else if cmd
= 'nextmap' then
6678 if not(gGameOn
or (gState
= STATE_INTERCUSTOM
)) then
6679 g_Console_Add(_lc
[I_MSG_NOT_GAME
])
6682 if Length(P
) = 1 then
6684 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
6686 g_Console_Add(cmd
+ ' <MAP>');
6687 g_Console_Add(cmd
+ ' <WAD> [MAP]');
6690 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6695 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
6697 if Length(P
) < 3 then
6699 // Ïåðâûé ïàðàìåòð - ëèáî êàðòà, ëèáî èìÿ WAD ôàéëà
6700 s
:= UpperCase(P
[1]);
6701 if g_Map_Exist(MapsDir
+ gGameSettings
.WAD
+ ':\' + s
) then
6702 begin // Êàðòà íàøëàñü
6703 gExitByTrigger
:= False;
6708 // Òàêîé êàðòû íåò, èùåì WAD ôàéë
6709 P
[1] := addWadExtension(P
[1]);
6710 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [s
, P
[1]]));
6711 if FileExists(MapsDir
+ P
[1]) then
6713 // Ïàðàìåòðà êàðòû íåò, ïîýòîìó ñòàâèì ïåðâóþ èç ôàéëà
6715 P
[2] := g_Game_GetFirstMap(MapsDir
+ P
[1]);
6717 s
:= P
[1] + ':\' + P
[2];
6719 if g_Map_Exist(MapsDir
+ s
) then
6720 begin // Óñòàíàâëèâàåì êàðòó
6721 gExitByTrigger
:= False;
6726 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
6728 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]));
6730 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]));
6734 // Óêàçàíî äâà ïàðàìåòðà, çíà÷èò ïåðâûé - WAD ôàéë, à âòîðîé - êàðòà
6735 P
[1] := addWadExtension(P
[1]);
6736 if FileExists(MapsDir
+ P
[1]) then
6739 P
[2] := UpperCase(P
[2]);
6740 s
:= P
[1] + ':\' + P
[2];
6742 if g_Map_Exist(MapsDir
+ s
) then
6743 begin // Íàøëè êàðòó
6744 gExitByTrigger
:= False;
6748 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]));
6750 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]));
6753 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6756 if gNextMap
= '' then
6757 g_Console_Add(_lc
[I_MSG_NEXTMAP_UNSET
])
6759 g_Console_Add(Format(_lc
[I_MSG_NEXTMAP_SET
], [gNextMap
]));
6762 else if (cmd
= 'endmap') or (cmd
= 'goodbye') then
6765 g_Console_Add(_lc
[I_MSG_NOT_GAME
])
6767 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
6769 gExitByTrigger
:= False;
6770 // Ñëåäóþùàÿ êàðòà íå çàäàíà, ïðîáóåì íàéòè òðèããåð Âûõîä
6771 if (gNextMap
= '') and (gTriggers
<> nil) then
6772 for a
:= 0 to High(gTriggers
) do
6773 if gTriggers
[a
].TriggerType
= TRIGGER_EXIT
then
6775 gExitByTrigger
:= True;
6776 //gNextMap := gTriggers[a].Data.MapName;
6777 gNextMap
:= gTriggers
[a
].tgcMap
;
6780 // Èùåì ñëåäóþùóþ êàðòó â WAD ôàéëå
6781 if gNextMap
= '' then
6782 gNextMap
:= g_Game_GetNextMap();
6783 // Ïðîâåðÿåì, íå çàäàí ëè WAD ôàéë ðåñóðñíîé ñòðîêîé
6784 if not isWadPath(gNextMap
) then
6785 s
:= gGameSettings
.WAD
+ ':\' + gNextMap
6788 // Åñëè êàðòà íàéäåíà, âûõîäèì ñ óðîâíÿ
6789 if g_Map_Exist(MapsDir
+ s
) then
6790 gExit
:= EXIT_ENDLEVELCUSTOM
6792 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [gNextMap
]));
6794 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6796 else if (cmd
= 'event') then
6798 if (Length(P
) <= 1) then
6800 for a
:= 0 to High(gEvents
) do
6801 if gEvents
[a
].Command
= '' then
6802 g_Console_Add(gEvents
[a
].Name
+ ' <none>')
6804 g_Console_Add(gEvents
[a
].Name
+ ' "' + gEvents
[a
].Command
+ '"');
6807 if (Length(P
) = 2) then
6809 for a
:= 0 to High(gEvents
) do
6810 if gEvents
[a
].Name
= P
[1] then
6811 if gEvents
[a
].Command
= '' then
6812 g_Console_Add(gEvents
[a
].Name
+ ' <none>')
6814 g_Console_Add(gEvents
[a
].Name
+ ' "' + gEvents
[a
].Command
+ '"');
6817 for a
:= 0 to High(gEvents
) do
6818 if gEvents
[a
].Name
= P
[1] then
6820 gEvents
[a
].Command
:= '';
6821 for b
:= 2 to High(P
) do
6822 if Pos(' ', P
[b
]) = 0 then
6823 gEvents
[a
].Command
:= gEvents
[a
].Command
+ ' ' + P
[b
]
6825 gEvents
[a
].Command
:= gEvents
[a
].Command
+ ' "' + P
[b
] + '"';
6826 gEvents
[a
].Command
:= Trim(gEvents
[a
].Command
);
6830 else if cmd
= 'suicide' then
6834 if g_Game_IsClient
then
6835 MC_SEND_CheatRequest(NET_CHEAT_SUICIDE
)
6838 if gPlayer1
<> nil then
6839 gPlayer1
.Damage(SUICIDE_DAMAGE
, gPlayer1
.UID
, 0, 0, HIT_SELF
);
6840 if gPlayer2
<> nil then
6841 gPlayer2
.Damage(SUICIDE_DAMAGE
, gPlayer2
.UID
, 0, 0, HIT_SELF
);
6845 else if cmd
= 'screenshot' then
6849 else if cmd
= 'weapon' then
6851 if Length(p
) = 2 then
6853 a
:= WP_FIRST
+ StrToInt(p
[1]) - 1;
6854 if (a
>= WP_FIRST
) and (a
<= WP_LAST
) then
6855 gSelectWeapon
[0, a
] := True
6858 else if (cmd
= 'p1_weapon') or (cmd
= 'p2_weapon') then
6860 if Length(p
) = 2 then
6862 a
:= WP_FIRST
+ StrToInt(p
[1]) - 1;
6863 b
:= ord(cmd
[2]) - ord('1');
6864 if (a
>= WP_FIRST
) and (a
<= WP_LAST
) then
6865 gSelectWeapon
[b
, a
] := True
6868 // Êîìàíäû Ñâîåé èãðû:
6869 else if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
6871 if cmd
= 'bot_addred' then
6873 if Length(P
) > 1 then
6874 g_Bot_Add(TEAM_RED
, StrToIntDef(P
[1], 2))
6876 g_Bot_Add(TEAM_RED
, 2);
6878 else if cmd
= 'bot_addblue' then
6880 if Length(P
) > 1 then
6881 g_Bot_Add(TEAM_BLUE
, StrToIntDef(P
[1], 2))
6883 g_Bot_Add(TEAM_BLUE
, 2);
6885 else if cmd
= 'spectate' then
6891 else if cmd
= 'say' then
6893 if g_Game_IsServer
and g_Game_IsNet
then
6895 if Length(P
) > 1 then
6898 for a
:= 1 to High(P
) do
6899 chstr
:= chstr
+ P
[a
] + ' ';
6901 if Length(chstr
) > 200 then SetLength(chstr
, 200);
6903 if Length(chstr
) < 1 then
6905 g_Console_Add('say <text>');
6909 chstr
:= b_Text_Format(chstr
);
6910 MH_SEND_Chat(chstr
, NET_CHAT_PLAYER
);
6912 else g_Console_Add('say <text>');
6914 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6916 else if cmd
= 'tell' then
6918 if g_Game_IsServer
and g_Game_IsNet
then
6920 if (Length(P
) > 2) and (P
[1] <> '') then
6923 for a
:= 2 to High(P
) do
6924 chstr
:= chstr
+ P
[a
] + ' ';
6926 if Length(chstr
) > 200 then SetLength(chstr
, 200);
6928 if Length(chstr
) < 1 then
6930 g_Console_Add('tell <playername> <text>');
6934 pl
:= g_Net_Client_ByName(P
[1]);
6936 MH_SEND_Chat(b_Text_Format(chstr
), NET_CHAT_PLAYER
, pl
^.ID
)
6938 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
6940 else g_Console_Add('tell <playername> <text>');
6942 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6944 else if (cmd
= 'overtime') and not g_Game_IsClient
then
6946 if (Length(P
) = 1) or (StrToIntDef(P
[1], -1) <= 0) then
6948 // Äîïîëíèòåëüíîå âðåìÿ:
6949 gGameSettings
.TimeLimit
:= (gTime
- gGameStartTime
) div 1000 + Word(StrToIntDef(P
[1], 0));
6951 g_Console_Add(Format(_lc
[I_MSG_TIME_LIMIT
],
6952 [gGameSettings
.TimeLimit
div 3600,
6953 (gGameSettings
.TimeLimit
div 60) mod 60,
6954 gGameSettings
.TimeLimit
mod 60]));
6955 if g_Game_IsNet
then MH_SEND_GameSettings
;
6957 else if (cmd
= 'rcon_password') and g_Game_IsClient
then
6959 if (Length(P
) <= 1) then
6960 g_Console_Add('rcon_password <password>')
6962 MC_SEND_RCONPassword(P
[1]);
6964 else if cmd
= 'rcon' then
6966 if g_Game_IsClient
then
6968 if Length(P
) > 1 then
6971 for a
:= 1 to High(P
) do
6972 chstr
:= chstr
+ P
[a
] + ' ';
6974 if Length(chstr
) > 200 then SetLength(chstr
, 200);
6976 if Length(chstr
) < 1 then
6978 g_Console_Add('rcon <command>');
6982 MC_SEND_RCONCommand(chstr
);
6984 else g_Console_Add('rcon <command>');
6987 else if cmd
= 'ready' then
6989 if g_Game_IsServer
and (gLMSRespawn
= LMS_RESPAWN_WARMUP
) then
6990 gLMSRespawnTime
:= gTime
+ 100;
6992 else if (cmd
= 'callvote') and g_Game_IsNet
then
6994 if Length(P
) > 1 then
6997 for a
:= 1 to High(P
) do begin
6998 if a
> 1 then chstr
:= chstr
+ ' ';
6999 chstr
:= chstr
+ P
[a
];
7002 if Length(chstr
) > 200 then SetLength(chstr
, 200);
7004 if Length(chstr
) < 1 then
7006 g_Console_Add('callvote <command>');
7010 if g_Game_IsClient
then
7011 MC_SEND_Vote(True, chstr
)
7013 g_Game_StartVote(chstr
, gPlayer1Settings
.Name
);
7014 g_Console_Process('vote', True);
7017 g_Console_Add('callvote <command>');
7019 else if (cmd
= 'vote') and g_Game_IsNet
then
7021 if g_Game_IsClient
then
7023 else if gVoteInProgress
then
7025 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
7026 a
:= Floor((NetClientCount
+1)/2.0) + 1
7028 a
:= Floor(NetClientCount
/2.0) + 1;
7033 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_REVOKED
], [gPlayer1Settings
.Name
, gVoteCount
, a
]), True);
7034 MH_SEND_VoteEvent(NET_VE_REVOKE
, gPlayer1Settings
.Name
, 'a', gVoteCount
, a
);
7040 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_VOTE
], [gPlayer1Settings
.Name
, gVoteCount
, a
]), True);
7041 MH_SEND_VoteEvent(NET_VE_VOTE
, gPlayer1Settings
.Name
, 'a', gVoteCount
, a
);
7049 procedure g_TakeScreenShot();
7057 if e_NoGraphics
then Exit
;
7058 ssdir
:= GameDir
+'/screenshots';
7059 if not findFileCI(ssdir
, true) then
7061 // try to create dir
7066 if not findFileCI(ssdir
, true) then exit
; // alas
7069 for a
:= 1 to High(Word) do
7071 FileName
:= Format(ssdir
+'screenshot%.3d.png', [a
]);
7073 if findFileCI(t
, true) then continue
;
7074 if not findFileCI(FileName
) then
7077 st
:= createDiskFile(FileName
);
7079 e_MakeScreenshot(st
, gScreenWidth
, gScreenHeight
);
7084 if not ok
then try DeleteFile(FileName
); except end else g_Console_Add(Format(_lc
[I_CONSOLE_SCREENSHOT
], [ExtractFileName(FileName
)]));
7092 procedure g_Game_InGameMenu(Show
: Boolean);
7094 if (g_ActiveWindow
= nil) and Show
then
7096 if gGameSettings
.GameType
= GT_SINGLE
then
7097 g_GUI_ShowWindow('GameSingleMenu')
7100 if g_Game_IsClient
then
7101 g_GUI_ShowWindow('GameClientMenu')
7103 if g_Game_IsNet
then
7104 g_GUI_ShowWindow('GameServerMenu')
7106 g_GUI_ShowWindow('GameCustomMenu');
7108 g_Sound_PlayEx('MENU_OPEN');
7110 // Ïàóçà ïðè ìåíþ òîëüêî â îäèíî÷íîé èãðå:
7111 if (not g_Game_IsNet
) then
7115 if (g_ActiveWindow
<> nil) and (not Show
) then
7117 // Ïàóçà ïðè ìåíþ òîëüêî â îäèíî÷íîé èãðå:
7118 if (not g_Game_IsNet
) then
7119 g_Game_Pause(False);
7123 procedure g_Game_Pause (Enable
: Boolean);
7127 if not gGameOn
then exit
;
7129 if not (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
]) then exit
;
7132 gPauseMain
:= Enable
;
7134 if (gPause
<> oldPause
) then g_Game_PauseAllSounds(gPause
);
7137 procedure g_Game_HolmesPause (Enable
: Boolean);
7141 if not gGameOn
then exit
;
7142 if not (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
]) then exit
;
7145 gPauseHolmes
:= Enable
;
7147 if (gPause
<> oldPause
) then g_Game_PauseAllSounds(gPause
);
7150 procedure g_Game_PauseAllSounds(Enable
: Boolean);
7155 if gTriggers
<> nil then
7156 for i
:= 0 to High(gTriggers
) do
7157 with gTriggers
[i
] do
7158 if (TriggerType
= TRIGGER_SOUND
) and
7160 Sound
.IsPlaying() then
7162 Sound
.Pause(Enable
);
7166 if gPlayers
<> nil then
7167 for i
:= 0 to High(gPlayers
) do
7168 if gPlayers
[i
] <> nil then
7169 gPlayers
[i
].PauseSounds(Enable
);
7172 if gMusic
<> nil then
7173 gMusic
.Pause(Enable
);
7176 procedure g_Game_StopAllSounds(all
: Boolean);
7180 if gTriggers
<> nil then
7181 for i
:= 0 to High(gTriggers
) do
7182 with gTriggers
[i
] do
7183 if (TriggerType
= TRIGGER_SOUND
) and
7187 if gMusic
<> nil then
7194 procedure g_Game_UpdateTriggerSounds();
7198 if gTriggers
<> nil then
7199 for i
:= 0 to High(gTriggers
) do
7200 with gTriggers
[i
] do
7201 if (TriggerType
= TRIGGER_SOUND
) and
7204 Sound
.IsPlaying() then
7206 if ((gPlayer1
<> nil) and g_CollidePoint(gPlayer1
.GameX
, gPlayer1
.GameY
, X
, Y
, Width
, Height
)) or
7207 ((gPlayer2
<> nil) and g_CollidePoint(gPlayer2
.GameX
, gPlayer2
.GameY
, X
, Y
, Width
, Height
)) then
7209 Sound
.SetPan(0.5 - tgcPan
/255.0);
7210 Sound
.SetVolume(tgcVolume
/255.0);
7213 Sound
.SetCoords(X
+(Width
div 2), Y
+(Height
div 2), tgcVolume
/255.0);
7217 function g_Game_IsWatchedPlayer(UID
: Word): Boolean;
7220 if (gPlayer1
<> nil) and (gPlayer1
.UID
= UID
) then
7225 if (gPlayer2
<> nil) and (gPlayer2
.UID
= UID
) then
7230 if gSpectMode
<> SPECT_PLAYERS
then
7232 if gSpectPID1
= UID
then
7237 if gSpectViewTwo
and (gSpectPID2
= UID
) then
7244 function g_Game_IsWatchedTeam(Team
: Byte): Boolean;
7249 if (gPlayer1
<> nil) and (gPlayer1
.Team
= Team
) then
7254 if (gPlayer2
<> nil) and (gPlayer2
.Team
= Team
) then
7259 if gSpectMode
<> SPECT_PLAYERS
then
7261 Pl
:= g_Player_Get(gSpectPID1
);
7262 if (Pl
<> nil) and (Pl
.Team
= Team
) then
7267 if gSpectViewTwo
then
7269 Pl
:= g_Player_Get(gSpectPID2
);
7270 if (Pl
<> nil) and (Pl
.Team
= Team
) then
7278 procedure g_Game_Message(Msg
: string; Time
: Word);
7280 MessageLineLength
:= (gScreenWidth
- 204) div e_CharFont_GetMaxWidth(gMenuFont
);
7281 MessageText
:= b_Text_Wrap(b_Text_Format(Msg
), MessageLineLength
);
7282 MessageTime
:= Time
;
7285 procedure g_Game_ChatSound(Text: String; Taunt
: Boolean = True);
7287 punct
: Array[0..13] of String =
7288 ('.', ',', ':', ';', '!', '?', '(', ')', '''', '"', '/', '\', '*', '^');
7294 function IsPunctuation(S
: String): Boolean;
7299 if Length(S
) <> 1 then
7301 for i
:= Low(punct
) to High(punct
) do
7302 if S
= punct
[i
] then
7308 function FilterPunctuation(S
: String): String;
7312 for i
:= Low(punct
) to High(punct
) do
7313 S
:= StringReplace(S
, punct
[i
], ' ', [rfReplaceAll
]);
7319 if gUseChatSounds
and Taunt
and (gChatSounds
<> nil) and (Pos(': ', Text) > 0) then
7321 // remove player name
7322 Delete(Text, 1, Pos(': ', Text) + 2 - 1);
7323 // for FullWord check
7324 Text := toLowerCase1251(' ' + Text + ' ');
7325 fpText
:= FilterPunctuation(Text);
7327 for i
:= 0 to Length(gChatSounds
) - 1 do
7330 for j
:= 0 to Length(gChatSounds
[i
].Tags
) - 1 do
7332 if gChatSounds
[i
].FullWord
and (not IsPunctuation(gChatSounds
[i
].Tags
[j
])) then
7333 ok
:= Pos(' ' + gChatSounds
[i
].Tags
[j
] + ' ', fpText
) > 0
7335 ok
:= Pos(gChatSounds
[i
].Tags
[j
], Text) > 0;
7341 gChatSounds
[i
].Sound
.Play();
7347 g_Sound_PlayEx('SOUND_GAME_RADIO');
7350 procedure g_Game_Announce_GoodShot(SpawnerUID
: Word);
7359 if not g_Game_IsWatchedPlayer(SpawnerUID
) then
7363 if goodsnd
[a
].IsPlaying() then
7366 goodsnd
[Random(4)].Play();
7369 procedure g_Game_Announce_KillCombo(Param
: Integer);
7376 UID
:= Param
and $FFFF;
7381 Pl
:= g_Player_Get(UID
);
7390 g_Console_Add(Format(_lc
[I_PLAYER_KILL_2X
], [Name
]), True);
7394 g_Console_Add(Format(_lc
[I_PLAYER_KILL_3X
], [Name
]), True);
7398 g_Console_Add(Format(_lc
[I_PLAYER_KILL_4X
], [Name
]), True);
7402 g_Console_Add(Format(_lc
[I_PLAYER_KILL_MX
], [Name
]), True);
7410 if not g_Game_IsWatchedPlayer(UID
) then
7413 if (not g_Game_IsWatchedPlayer(UID
)) and (c
< 4) then
7417 if killsnd
[n
].IsPlaying() then
7422 procedure g_Game_Announce_BodyKill(SpawnerUID
: Word);
7431 if not g_Game_IsWatchedPlayer(SpawnerUID
) then
7435 if hahasnd
[a
].IsPlaying() then
7438 hahasnd
[Random(3)].Play();
7441 procedure g_Game_StartVote(Command
, Initiator
: string);
7445 if not gVotesEnabled
then Exit
;
7446 if gGameSettings
.GameType
<> GT_SERVER
then Exit
;
7447 if gVoteInProgress
or gVotePassed
then
7449 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_INPROGRESS
], [gVoteCommand
]), True);
7450 MH_SEND_VoteEvent(NET_VE_INPROGRESS
, gVoteCommand
);
7453 gVoteInProgress
:= True;
7454 gVotePassed
:= False;
7455 gVoteTimer
:= gTime
+ gVoteTimeout
* 1000;
7458 gVoteCommand
:= Command
;
7460 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
7461 Need
:= Floor((NetClientCount
+1)/2.0)+1
7463 Need
:= Floor(NetClientCount
/2.0)+1;
7464 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_STARTED
], [Initiator
, Command
, Need
]), True);
7465 MH_SEND_VoteEvent(NET_VE_STARTED
, Initiator
, Command
, Need
);
7468 procedure g_Game_CheckVote
;
7472 if gGameSettings
.GameType
<> GT_SERVER
then Exit
;
7473 if not gVoteInProgress
then Exit
;
7475 if (gTime
>= gVoteTimer
) then
7477 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
7478 Need
:= Floor((NetClientCount
+1)/2.0) + 1
7480 Need
:= Floor(NetClientCount
/2.0) + 1;
7481 if gVoteCount
>= Need
then
7483 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_PASSED
], [gVoteCommand
]), True);
7484 MH_SEND_VoteEvent(NET_VE_PASSED
, gVoteCommand
);
7485 gVotePassed
:= True;
7486 gVoteCmdTimer
:= gTime
+ 5000;
7490 g_Console_Add(_lc
[I_MESSAGE_VOTE_FAILED
], True);
7491 MH_SEND_VoteEvent(NET_VE_FAILED
);
7493 if NetClients
<> nil then
7494 for I
:= Low(NetClients
) to High(NetClients
) do
7495 if NetClients
[i
].Used
then
7496 NetClients
[i
].Voted
:= False;
7497 gVoteInProgress
:= False;
7503 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
7504 Need
:= Floor((NetClientCount
+1)/2.0) + 1
7506 Need
:= Floor(NetClientCount
/2.0) + 1;
7507 if gVoteCount
>= Need
then
7509 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_PASSED
], [gVoteCommand
]), True);
7510 MH_SEND_VoteEvent(NET_VE_PASSED
, gVoteCommand
);
7511 gVoteInProgress
:= False;
7512 gVotePassed
:= True;
7513 gVoteCmdTimer
:= gTime
+ 5000;
7516 if NetClients
<> nil then
7517 for I
:= Low(NetClients
) to High(NetClients
) do
7518 if NetClients
[i
].Used
then
7519 NetClients
[i
].Voted
:= False;
7524 procedure g_Game_LoadMapList(FileName
: string);
7532 if not FileExists(FileName
) then Exit
;
7534 AssignFile(ListFile
, FileName
);
7536 while not EOF(ListFile
) do
7538 ReadLn(ListFile
, s
);
7541 if s
= '' then Continue
;
7543 SetLength(MapList
, Length(MapList
)+1);
7544 MapList
[High(MapList
)] := s
;
7546 CloseFile(ListFile
);
7549 procedure g_Game_SetDebugMode();
7552 // ×èòû (äàæå â ñâîåé èãðå):
7556 procedure g_Game_SetLoadingText(Text: String; Max
: Integer; reWrite
: Boolean);
7560 if Length(LoadingStat
.Msgs
) = 0 then
7566 begin // Ïåðåõîäèì íà ñëåäóþùóþ ñòðîêó èëè ñêðîëëèðóåì:
7567 if NextMsg
= Length(Msgs
) then
7569 for i
:= 0 to High(Msgs
)-1 do
7570 Msgs
[i
] := Msgs
[i
+1];
7578 Msgs
[NextMsg
-1] := Text;
7582 PBarWasHere
:= false;
7585 g_ActiveWindow
:= nil;
7587 ProcessLoading(true);
7590 procedure g_Game_StepLoading(Value
: Integer = -1);
7601 if (ShowCount
> LOADING_SHOW_STEP
) or (Value
> -1) then
7609 procedure g_Game_ClearLoading();
7618 len
:= ((gScreenHeight
div 3)*2 - 50) div LOADING_INTERLINE
;
7619 if len
< 1 then len
:= 1;
7620 SetLength(Msgs
, len
);
7621 for len
:= Low(Msgs
) to High(Msgs
) do
7624 PBarWasHere
:= false;
7628 procedure Parse_Params(var pars
: TParamStrValues
);
7635 while i
<= ParamCount
do
7638 if (s
[1] = '-') and (Length(s
) > 1) then
7640 if (s
[2] = '-') and (Length(s
) > 2) then
7641 begin // Îäèíî÷íûé ïàðàìåòð
7642 SetLength(pars
, Length(pars
) + 1);
7643 with pars
[High(pars
)] do
7645 Name
:= LowerCase(s
);
7650 if (i
< ParamCount
) then
7651 begin // Ïàðàìåòð ñî çíà÷åíèåì
7653 SetLength(pars
, Length(pars
) + 1);
7654 with pars
[High(pars
)] do
7656 Name
:= LowerCase(s
);
7657 Value
:= LowerCase(ParamStr(i
));
7666 function Find_Param_Value(var pars
: TParamStrValues
; aName
: String): String;
7671 for i
:= 0 to High(pars
) do
7672 if pars
[i
].Name
= aName
then
7674 Result
:= pars
[i
].Value
;
7679 procedure g_Game_Process_Params();
7681 pars
: TParamStrValues
;
7684 LimT
, LimS
: Integer;
7695 s
:= Find_Param_Value(pars
, '--debug');
7698 g_Game_SetDebugMode();
7699 s
:= Find_Param_Value(pars
, '--netdump');
7704 // Connect when game loads
7705 ip
:= Find_Param_Value(pars
, '-connect');
7709 s
:= Find_Param_Value(pars
, '-port');
7710 if (s
= '') or not TryStrToInt(s
, Port
) then
7713 s
:= Find_Param_Value(pars
, '-pw');
7715 g_Game_StartClient(ip
, Port
, s
);
7719 s
:= LowerCase(Find_Param_Value(pars
, '-dbg-mainwad'));
7722 gDefaultMegawadStart
:= s
;
7725 if (Find_Param_Value(pars
, '--dbg-mainwad-restore') <> '') or
7726 (Find_Param_Value(pars
, '--dbg-mainwad-default') <> '') then
7728 gDefaultMegawadStart
:= DF_Default_Megawad_Start
;
7731 // Start map when game loads:
7732 map
:= LowerCase(Find_Param_Value(pars
, '-map'));
7733 if isWadPath(map
) then
7736 s
:= Find_Param_Value(pars
, '-gm');
7737 GMode
:= g_Game_TextToMode(s
);
7738 if GMode
= GM_NONE
then GMode
:= GM_DM
;
7739 if GMode
= GM_SINGLE
then GMode
:= GM_COOP
;
7742 s
:= Find_Param_Value(pars
, '-limt');
7743 if (s
= '') or (not TryStrToInt(s
, LimT
)) then
7749 s
:= Find_Param_Value(pars
, '-lims');
7750 if (s
= '') or (not TryStrToInt(s
, LimS
)) then
7756 s
:= Find_Param_Value(pars
, '-lives');
7757 if (s
= '') or (not TryStrToInt(s
, Lives
)) then
7763 s
:= Find_Param_Value(pars
, '-opt');
7765 Opt
:= GAME_OPTION_ALLOWEXIT
or GAME_OPTION_BOTVSPLAYER
or GAME_OPTION_BOTVSMONSTER
7767 Opt
:= StrToIntDef(s
, 0);
7769 Opt
:= GAME_OPTION_ALLOWEXIT
or GAME_OPTION_BOTVSPLAYER
or GAME_OPTION_BOTVSMONSTER
;
7772 s
:= Find_Param_Value(pars
, '--close');
7776 // Override map to test:
7777 s
:= LowerCase(Find_Param_Value(pars
, '-testmap'));
7779 gTestMap
:= MapsDir
+ s
;
7781 // Delete test map after play:
7782 s
:= Find_Param_Value(pars
, '--testdelete');
7785 gMapToDelete
:= MapsDir
+ map
;
7786 e_WriteLog('"--testdelete" is deprecated, use --tempdelete.', TMsgType
.Fatal
);
7790 // Delete temporary WAD after play:
7791 s
:= Find_Param_Value(pars
, '--tempdelete');
7792 if (s
<> '') and (gTestMap
<> '') then
7794 gMapToDelete
:= gTestMap
;
7795 gTempDelete
:= True;
7798 // Number of players:
7799 s
:= Find_Param_Value(pars
, '-pl');
7803 n
:= StrToIntDef(s
, 1);
7806 s
:= Find_Param_Value(pars
, '-port');
7807 if (s
= '') or not TryStrToInt(s
, Port
) then
7808 g_Game_StartCustom(map
, GMode
, LimT
, LimS
, Lives
, Opt
, n
)
7810 g_Game_StartServer(map
, GMode
, LimT
, LimS
, Lives
, Opt
, n
, 0, Port
);
7813 // Execute script when game loads:
7814 s
:= Find_Param_Value(pars
, '-exec');
7817 if not isWadPath(s
) then
7818 s
:= GameDir
+ '/' + s
;
7823 if IOResult
<> 0 then
7825 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], ['Failed to read file: ' + s
]), TMsgType
.Warning
);
7826 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_READ
], [s
]));
7830 e_WriteLog('Executing script: ' + s
, TMsgType
.Notify
);
7831 g_Console_Add(Format(_lc
[I_CONSOLE_EXEC
], [s
]));
7836 if IOResult
<> 0 then
7838 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], ['Failed to read file: ' + s
]), TMsgType
.Warning
);
7839 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_READ
], [s
]));
7843 if Pos('#', s
) <> 1 then // script comment
7844 g_Console_Process(s
, True);
7855 conRegVar('pf_draw_frame', @g_profile_frame_draw
, 'draw frame rendering profiles', 'render profiles');
7856 //conRegVar('pf_update_frame', @g_profile_frame_update, 'draw frame updating profiles', 'update profiles');
7857 conRegVar('pf_coldet', @g_profile_collision
, 'draw collision detection profiles', 'coldet profiles');
7858 conRegVar('pf_los', @g_profile_los
, 'draw monster LOS profiles', 'monster LOS profiles');
7860 conRegVar('r_sq_draw', @gdbg_map_use_accel_render
, 'accelerated spatial queries in rendering', 'accelerated rendering');
7861 conRegVar('cd_sq_enabled', @gdbg_map_use_accel_coldet
, 'accelerated spatial queries in map coldet', 'accelerated map coldet');
7862 conRegVar('mon_sq_enabled', @gmon_debug_use_sqaccel
, 'accelerated spatial queries for monsters', 'accelerated monster coldet');
7863 conRegVar('wtrace_sq_enabled', @gwep_debug_fast_trace
, 'accelerated spatial queries for weapon hitscan trace', 'accelerated weapon hitscan');
7865 conRegVar('pr_enabled', @gpart_dbg_enabled
, 'enable/disable particles', 'particles');
7866 conRegVar('pr_phys_enabled', @gpart_dbg_phys_enabled
, 'enable/disable particle physics', 'particle physics');
7868 conRegVar('los_enabled', @gmon_dbg_los_enabled
, 'enable/disable monster LOS calculations', 'monster LOS', true);
7869 conRegVar('mon_think', @gmon_debug_think
, 'enable/disable monster thinking', 'monster thinking', true);
7871 {$IFDEF ENABLE_HOLMES}
7872 conRegVar('dbg_holmes', @g_holmes_enabled
, 'enable/disable Holmes', 'Holmes', true);
7875 conRegVar('dbg_ignore_level_bounds', @g_dbg_ignore_bounds
, 'ignore level bounds', '', false);
7877 conRegVar('r_scale', @g_dbg_scale
, 0.01, 100.0, 'render scale', '', false);
7879 conRegVar('light_enabled', @gwin_k8_enable_light_experiments
, 'enable/disable dynamic lighting', 'lighting');
7880 conRegVar('light_player_halo', @g_playerLight
, 'enable/disable player halo', 'player light halo');
7882 conRegVar('r_smallmap_align_h', @r_smallmap_h
, 'halign: 0: left; 1: center; 2: right', 'horizontal aligning of small maps');
7883 conRegVar('r_smallmap_align_v', @r_smallmap_v
, 'valign: 0: top; 1: center; 2: bottom', 'vertial aligning of small maps');
7885 conRegVar('r_showfps', @gShowFPS
, 'draw fps counter', 'draw fps counter');