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();
145 procedure DrawMenuBackground(tex
: AnsiString);
147 { procedure SetWinPause(Enable: Boolean); }
152 LOADING_SHOW_STEP
= 100;
153 LOADING_INTERLINE
= 20;
168 MESSAGE_DIKEY
= WM_USER
+ 1;
173 EXIT_ENDLEVELSINGLE
= 4;
174 EXIT_ENDLEVELCUSTOM
= 5;
176 GAME_OPTION_RESERVED
= 1;
177 GAME_OPTION_TEAMDAMAGE
= 2;
178 GAME_OPTION_ALLOWEXIT
= 4;
179 GAME_OPTION_WEAPONSTAY
= 8;
180 GAME_OPTION_MONSTERS
= 16;
181 GAME_OPTION_BOTVSPLAYER
= 32;
182 GAME_OPTION_BOTVSMONSTER
= 64;
187 STATE_INTERCUSTOM
= 3;
188 STATE_INTERSINGLE
= 4;
194 LMS_RESPAWN_NONE
= 0;
195 LMS_RESPAWN_WARMUP
= 1;
196 LMS_RESPAWN_FINAL
= 2;
213 CONFIG_FILENAME
= 'Doom2DF.cfg';
215 TEST_MAP_NAME
= '$$$_TEST_$$$';
217 STD_PLAYER_MODEL
= 'Doomer';
227 gGameSettings
: TGameSettings
;
228 gPlayer1Settings
: TPlayerSettings
;
229 gPlayer2Settings
: TPlayerSettings
;
231 gPlayerScreenSize
: TDFPoint
;
232 gPlayer1ScreenCoord
: TDFPoint
;
233 gPlayer2ScreenCoord
: TDFPoint
;
234 gPlayer1
: TPlayer
= nil;
235 gPlayer2
: TPlayer
= nil;
236 gPlayerDrawn
: TPlayer
= nil;
238 gSwitchGameMode
: Byte = GM_DM
;
239 gHearPoint1
, gHearPoint2
: THearPoint
;
240 gSoundEffectsDF
: Boolean = False;
241 gSoundTriggerTime
: Word = 0;
242 gAnnouncer
: Byte = ANNOUNCE_NONE
;
243 goodsnd
: array[0..3] of TPlayableSound
;
244 killsnd
: array[0..3] of TPlayableSound
;
245 hahasnd
: array[0..2] of TPlayableSound
;
246 sound_get_flag
: array[0..1] of TPlayableSound
;
247 sound_lost_flag
: array[0..1] of TPlayableSound
;
248 sound_ret_flag
: array[0..1] of TPlayableSound
;
249 sound_cap_flag
: array[0..1] of TPlayableSound
;
250 gBodyKillEvent
: Integer = -1;
251 gDefInterTime
: ShortInt = -1;
252 gInterEndTime
: LongWord = 0;
253 gInterTime
: LongWord = 0;
254 gServInterTime
: Byte = 0;
255 gGameStartTime
: LongWord = 0;
256 gTotalMonsters
: Integer = 0;
257 gPauseMain
: Boolean = false;
258 gPauseHolmes
: Boolean = false;
259 gShowTime
: Boolean = False;
260 gShowFPS
: Boolean = False;
261 gShowGoals
: Boolean = True;
262 gShowStat
: Boolean = True;
263 gShowKillMsg
: Boolean = True;
264 gShowLives
: Boolean = True;
265 gShowPing
: Boolean = False;
266 gShowMap
: Boolean = False;
268 gState
: Byte = STATE_NONE
;
270 sWidth
, sHeight
: Word;
271 gSpectMode
: Byte = SPECT_NONE
;
272 gSpectHUD
: Boolean = True;
273 gSpectKeyPress
: Boolean = False;
274 gSpectX
: Integer = 0;
275 gSpectY
: Integer = 0;
276 gSpectStep
: Byte = 8;
277 gSpectViewTwo
: Boolean = False;
278 gSpectPID1
: Integer = -1;
279 gSpectPID2
: Integer = -1;
280 gSpectAuto
: Boolean = False;
281 gSpectAutoNext
: LongWord;
282 gSpectAutoStepX
: Integer;
283 gSpectAutoStepY
: Integer;
284 gMusic
: TMusic
= nil;
285 gLoadGameMode
: Boolean;
286 gCheats
: Boolean = False;
287 gMapOnce
: Boolean = False;
288 gMapToDelete
: String;
289 gTempDelete
: Boolean = False;
290 gLastMap
: Boolean = False;
291 gWinPosX
, gWinPosY
: Integer;
292 gWinSizeX
, gWinSizeY
: Integer;
293 gWinFrameX
, gWinFrameY
, gWinCaption
: Integer;
294 gWinActive
: Boolean = True; // by default window is active, lol
295 gResolutionChange
: Boolean = False;
296 gRC_Width
, gRC_Height
: Word;
297 gRC_FullScreen
, gRC_Maximized
: Boolean;
298 gLanguageChange
: Boolean = False;
299 gDebugMode
: Boolean = False;
300 g_debug_Sounds
: Boolean = False;
301 g_debug_Frames
: Boolean = False;
302 g_debug_WinMsgs
: Boolean = False;
303 g_debug_MonsterOff
: Boolean = False;
304 g_debug_BotAIOff
: Byte = 0;
305 g_debug_HealthBar
: Boolean = False;
306 g_Debug_Player
: Boolean = False;
307 gCoopMonstersKilled
: Word = 0;
308 gCoopSecretsFound
: Word = 0;
309 gCoopTotalMonstersKilled
: Word = 0;
310 gCoopTotalSecretsFound
: Word = 0;
311 gCoopTotalMonsters
: Word = 0;
312 gCoopTotalSecrets
: Word = 0;
313 gStatsOff
: Boolean = False;
314 gStatsPressed
: Boolean = False;
315 gExitByTrigger
: Boolean = False;
316 gNextMap
: String = '';
317 gLMSRespawn
: Byte = LMS_RESPAWN_NONE
;
318 gLMSRespawnTime
: Cardinal = 0;
319 gLMSSoftSpawn
: Boolean = False;
320 gMissionFailed
: Boolean = False;
321 gVoteInProgress
: Boolean = False;
322 gVotePassed
: Boolean = False;
323 gVoteCommand
: string = '';
324 gVoteTimer
: Cardinal = 0;
325 gVoteCmdTimer
: Cardinal = 0;
326 gVoteCount
: Integer = 0;
327 gVoteTimeout
: Cardinal = 30;
328 gVoted
: Boolean = False;
329 gVotesEnabled
: Boolean = True;
330 gEvents
: Array of TGameEvent
;
331 gDelayedEvents
: Array of TDelayedEvent
;
332 gUseChatSounds
: Boolean = True;
333 gChatSounds
: Array of TChatSound
;
334 gSelectWeapon
: Array [0..1, WP_FIRST
..WP_LAST
] of Boolean; // [player, weapon]
335 gInterReadyCount
: Integer = 0;
337 g_dbg_ignore_bounds
: Boolean = false;
338 r_smallmap_h
: Integer = 0; // 0: left; 1: center; 2: right
339 r_smallmap_v
: Integer = 2; // 0: top; 1: center; 2: bottom
341 // move button values:
342 // bits 0-1: l/r state:
343 // 0: neither left, nor right pressed
346 // bits 4-5: l/r state when strafe was pressed
347 P1MoveButton
: Byte = 0;
348 P2MoveButton
: Byte = 0;
350 g_profile_frame_update
: Boolean = false;
351 g_profile_frame_draw
: Boolean = false;
352 g_profile_collision
: Boolean = false;
353 g_profile_los
: Boolean = false;
354 g_profile_history_size
: Integer = 1000;
356 g_rlayer_back
: Boolean = true;
357 g_rlayer_step
: Boolean = true;
358 g_rlayer_wall
: Boolean = true;
359 g_rlayer_door
: Boolean = true;
360 g_rlayer_acid1
: Boolean = true;
361 g_rlayer_acid2
: Boolean = true;
362 g_rlayer_water
: Boolean = true;
363 g_rlayer_fore
: Boolean = true;
366 procedure g_ResetDynlights ();
367 procedure g_AddDynLight (x
, y
, radius
: Integer; r
, g
, b
, a
: Single);
368 procedure g_DynLightExplosion (x
, y
, radius
: Integer; r
, g
, b
: Single);
370 function conIsCheatsEnabled (): Boolean; inline;
371 function gPause (): Boolean; inline;
377 {$INCLUDE ../nogl/noGLuses.inc}
378 {$IFDEF ENABLE_HOLMES}
381 e_texture
, g_textures
, g_main
, g_window
, g_menu
,
382 e_input
, e_log
, g_console
, g_items
, g_map
, g_panel
,
383 g_playermodel
, g_gfx
, g_options
, Math
,
384 g_triggers
, g_monsters
, e_sound
, CONFIG
,
386 ENet
, e_msg
, g_netmsg
, g_netmaster
,
391 hasPBarGfx
: Boolean = false;
394 // ////////////////////////////////////////////////////////////////////////// //
395 function gPause (): Boolean; inline; begin result
:= gPauseMain
or gPauseHolmes
; end;
398 // ////////////////////////////////////////////////////////////////////////// //
399 function conIsCheatsEnabled (): Boolean; inline;
402 if g_Game_IsNet
then exit
;
403 if not gDebugMode
then
405 //if not gCheats then exit;
406 if not (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
]) then exit
;
407 if not (gGameSettings
.GameMode
in [GM_COOP
, GM_SINGLE
]) then exit
;
413 // ////////////////////////////////////////////////////////////////////////// //
415 profileFrameDraw
: TProfiler
= nil;
418 // ////////////////////////////////////////////////////////////////////////// //
421 x
, y
, radius
: Integer;
424 exploRadius
: Integer;
428 g_dynLights
: array of TDynLight
= nil;
429 g_dynLightCount
: Integer = 0;
430 g_playerLight
: Boolean = false;
432 procedure g_ResetDynlights ();
436 if not gwin_has_stencil
then begin g_dynLightCount
:= 0; exit
; end;
438 for idx
:= 0 to g_dynLightCount
-1 do
440 if g_dynLights
[idx
].exploCount
= -666 then
447 Inc(g_dynLights
[idx
].exploCount
);
448 if (g_dynLights
[idx
].exploCount
< 10) then
450 g_dynLights
[idx
].radius
:= g_dynLights
[idx
].exploRadius
+g_dynLights
[idx
].exploCount
*8;
451 g_dynLights
[idx
].a
:= 0.4+g_dynLights
[idx
].exploCount
/10;
452 if (g_dynLights
[idx
].a
> 0.8) then g_dynLights
[idx
].a
:= 0.8;
453 if lnum
<> idx
then g_dynLights
[lnum
] := g_dynLights
[idx
];
458 g_dynLightCount
:= lnum
;
461 procedure g_AddDynLight (x
, y
, radius
: Integer; r
, g
, b
, a
: Single);
463 if not gwin_has_stencil
then exit
;
464 if g_dynLightCount
= length(g_dynLights
) then SetLength(g_dynLights
, g_dynLightCount
+1024);
465 g_dynLights
[g_dynLightCount
].x
:= x
;
466 g_dynLights
[g_dynLightCount
].y
:= y
;
467 g_dynLights
[g_dynLightCount
].radius
:= radius
;
468 g_dynLights
[g_dynLightCount
].r
:= r
;
469 g_dynLights
[g_dynLightCount
].g
:= g
;
470 g_dynLights
[g_dynLightCount
].b
:= b
;
471 g_dynLights
[g_dynLightCount
].a
:= a
;
472 g_dynLights
[g_dynLightCount
].exploCount
:= -666;
473 Inc(g_dynLightCount
);
476 procedure g_DynLightExplosion (x
, y
, radius
: Integer; r
, g
, b
: Single);
478 if not gwin_has_stencil
then exit
;
479 if g_dynLightCount
= length(g_dynLights
) then SetLength(g_dynLights
, g_dynLightCount
+1024);
480 g_dynLights
[g_dynLightCount
].x
:= x
;
481 g_dynLights
[g_dynLightCount
].y
:= y
;
482 g_dynLights
[g_dynLightCount
].radius
:= 0;
483 g_dynLights
[g_dynLightCount
].exploRadius
:= radius
;
484 g_dynLights
[g_dynLightCount
].r
:= r
;
485 g_dynLights
[g_dynLightCount
].g
:= g
;
486 g_dynLights
[g_dynLightCount
].b
:= b
;
487 g_dynLights
[g_dynLightCount
].a
:= 0;
488 g_dynLights
[g_dynLightCount
].exploCount
:= 0;
489 Inc(g_dynLightCount
);
493 // ////////////////////////////////////////////////////////////////////////// //
494 function calcProfilesHeight (prof
: TProfiler
): Integer;
497 if (prof
= nil) then exit
;
498 if (length(prof
.bars
) = 0) then exit
;
499 result
:= length(prof
.bars
)*(16+2);
503 function drawProfiles (x
, y
: Integer; prof
: TProfiler
): Integer;
510 if (prof
= nil) then exit
;
512 if (length(prof
.bars
) = 0) then exit
;
514 hgt
:= calcProfilesHeight(prof
);
515 if (x
< 0) then x
:= gScreenWidth
-(wdt
-1)+x
;
516 if (y
< 0) then y
:= gScreenHeight
-(hgt
-1)+y
;
518 //e_DrawFillQuad(x, y, x+wdt-1, y+hgt-1, 255, 255, 255, 200, B_BLEND);
519 //e_DrawFillQuad(x, y, x+wdt-1, y+hgt-1, 20, 20, 20, 0, B_NONE);
520 e_DarkenQuadWH(x
, y
, wdt
, hgt
, 150);
523 for ii
:= 0 to High(prof
.bars
) do
525 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);
532 // ////////////////////////////////////////////////////////////////////////// //
534 TEndCustomGameStat
= record
535 PlayerStat
: TPlayerStatArray
;
539 Map
, MapName
: String;
542 TEndSingleGameStat
= record
543 PlayerStat
: Array [0..1] of record
549 TotalSecrets
: Integer;
552 TLoadingStat
= record
556 Msgs
: Array of String;
558 PBarWasHere
: Boolean; // did we draw a progress bar for this message?
561 TParamStrValue
= record
566 TParamStrValues
= Array of TParamStrValue
;
569 INTER_ACTION_TEXT
= 1;
570 INTER_ACTION_PIC
= 2;
571 INTER_ACTION_MUSIC
= 3;
575 FPSCounter
, UPSCounter
: Word;
576 FPSTime
, UPSTime
: LongWord;
577 DataLoaded
: Boolean = False;
578 IsDrawStat
: Boolean = False;
579 CustomStat
: TEndCustomGameStat
;
580 SingleStat
: TEndSingleGameStat
;
581 LoadingStat
: TLoadingStat
;
582 EndingGameCounter
: Byte = 0;
585 MessageLineLength
: Integer = 80;
586 MapList
: SSArray
= nil;
587 MapIndex
: Integer = -1;
588 InterReadyTime
: Integer = -1;
594 text: Array of ShortString;
595 anim
: Array of ShortString;
596 pic
: Array of ShortString;
597 mus
: Array of ShortString;
599 triggers
: Array of record
601 actions
: Array of record
602 action
, p1
, p2
: Integer;
605 cur_trigger
: Integer;
618 function Compare(a
, b
: TPlayerStat
): Integer;
620 if a
.Spectator
then Result
:= 1
621 else if b
.Spectator
then Result
:= -1
622 else if a
.Frags
< b
.Frags
then Result
:= 1
623 else if a
.Frags
> b
.Frags
then Result
:= -1
624 else if a
.Deaths
< b
.Deaths
then Result
:= -1
625 else if a
.Deaths
> b
.Deaths
then Result
:= 1
626 else if a
.Kills
< b
.Kills
then Result
:= -1
630 procedure SortGameStat(var stat
: TPlayerStatArray
);
635 if stat
= nil then Exit
;
637 for I
:= High(stat
) downto Low(stat
) do
638 for J
:= Low(stat
) to High(stat
) - 1 do
639 if Compare(stat
[J
], stat
[J
+ 1]) = 1 then
642 stat
[J
] := stat
[J
+ 1];
647 function g_Game_ModeToText(Mode
: Byte): string;
651 GM_DM
: Result
:= _lc
[I_MENU_GAME_TYPE_DM
];
652 GM_TDM
: Result
:= _lc
[I_MENU_GAME_TYPE_TDM
];
653 GM_CTF
: Result
:= _lc
[I_MENU_GAME_TYPE_CTF
];
654 GM_COOP
: Result
:= _lc
[I_MENU_GAME_TYPE_COOP
];
655 GM_SINGLE
: Result
:= _lc
[I_MENU_GAME_TYPE_SINGLE
];
659 function g_Game_TextToMode(Mode
: string): Byte;
662 Mode
:= UpperCase(Mode
);
663 if Mode
= _lc
[I_MENU_GAME_TYPE_DM
] then
668 if Mode
= _lc
[I_MENU_GAME_TYPE_TDM
] then
673 if Mode
= _lc
[I_MENU_GAME_TYPE_CTF
] then
678 if Mode
= _lc
[I_MENU_GAME_TYPE_COOP
] then
683 if Mode
= _lc
[I_MENU_GAME_TYPE_SINGLE
] then
690 function g_Game_IsNet(): Boolean;
692 Result
:= (gGameSettings
.GameType
in [GT_SERVER
, GT_CLIENT
]);
695 function g_Game_IsServer(): Boolean;
697 Result
:= (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
, GT_SERVER
]);
700 function g_Game_IsClient(): Boolean;
702 Result
:= (gGameSettings
.GameType
= GT_CLIENT
);
705 function g_Game_GetMegaWADInfo(WAD
: String): TMegaWADInfo
;
712 Result
.name
:= ExtractFileName(WAD
);
713 Result
.description
:= '';
716 w
:= TWADFile
.Create();
719 if not w
.GetResource('INTERSCRIPT', p
, len
) then
725 cfg
:= TConfig
.CreateMem(p
, len
);
726 Result
.name
:= cfg
.ReadStr('megawad', 'name', ExtractFileName(WAD
));
727 Result
.description
:= cfg
.ReadStr('megawad', 'description', '');
728 Result
.author
:= cfg
.ReadStr('megawad', 'author', '');
729 Result
.pic
:= cfg
.ReadStr('megawad', 'pic', '');
735 procedure g_Game_FreeWAD();
739 for a
:= 0 to High(MegaWAD
.res
.pic
) do
740 if MegaWAD
.res
.pic
[a
] <> '' then
741 g_Texture_Delete(MegaWAD
.res
.pic
[a
]);
743 for a
:= 0 to High(MegaWAD
.res
.mus
) do
744 if MegaWAD
.res
.mus
[a
] <> '' then
745 g_Sound_Delete(MegaWAD
.res
.mus
[a
]);
747 MegaWAD
.res
.pic
:= nil;
748 MegaWAD
.res
.text := nil;
749 MegaWAD
.res
.anim
:= nil;
750 MegaWAD
.res
.mus
:= nil;
751 MegaWAD
.triggers
:= nil;
753 g_Texture_Delete('TEXTURE_endpic');
754 g_Sound_Delete('MUSIC_endmus');
756 ZeroMemory(@MegaWAD
, SizeOf(MegaWAD
));
757 gGameSettings
.WAD
:= '';
760 procedure g_Game_LoadWAD(WAD
: string);
769 gGameSettings
.WAD
:= WAD
;
770 if not (gGameSettings
.GameMode
in [GM_COOP
, GM_SINGLE
]) then
773 MegaWAD
.info
:= g_Game_GetMegaWADInfo(MapsDir
+ WAD
);
775 w
:= TWADFile
.Create();
776 w
.ReadFile(MapsDir
+ WAD
);
778 if not w
.GetResource('INTERSCRIPT', p
, len
) then
784 cfg
:= TConfig
.CreateMem(p
, len
);
789 s := cfg.ReadStr('pic', 'pic'+IntToStr(b), '');
790 if s = '' then Break;
793 SetLength(MegaWAD.res.pic, Length(MegaWAD.res.pic)+1);
794 MegaWAD.res.pic[High(MegaWAD.res.pic)] := s;
796 g_Texture_CreateWADEx(s, s);
802 s := cfg.ReadStr('mus', 'mus'+IntToStr(b), '');
803 if s = '' then Break;
806 SetLength(MegaWAD.res.mus, Length(MegaWAD.res.mus)+1);
807 MegaWAD.res.mus[High(MegaWAD.res.mus)] := s;
809 g_Music_CreateWADEx(s, s);
812 MegaWAD
.endpic
:= cfg
.ReadStr('megawad', 'endpic', '');
813 if MegaWAD
.endpic
<> '' then
815 s
:= g_ExtractWadName(MegaWAD
.endpic
);
816 if s
= '' then s
:= MapsDir
+WAD
else s
:= GameDir
+'/wads/';
817 TEXTUREFILTER
:= GL_LINEAR
;
818 g_Texture_CreateWADEx('TEXTURE_endpic', s
+MegaWAD
.endpic
);
819 TEXTUREFILTER
:= GL_NEAREST
;
821 MegaWAD
.endmus
:= cfg
.ReadStr('megawad', 'endmus', 'Standart.wad:D2DMUS\ÊÎÍÅÖ');
822 if MegaWAD
.endmus
<> '' then
824 s
:= g_ExtractWadName(MegaWAD
.endmus
);
825 if s
= '' then s
:= MapsDir
+WAD
else s
:= GameDir
+'/wads/';
826 g_Sound_CreateWADEx('MUSIC_endmus', s
+MegaWAD
.endmus
, True);
834 {procedure start_trigger(t: string);
838 function next_trigger(): Boolean;
842 procedure DisableCheats();
848 if gPlayer1
<> nil then gPlayer1
.GodMode
:= False;
849 if gPlayer2
<> nil then gPlayer2
.GodMode
:= False;
850 if gPlayer1
<> nil then gPlayer1
.NoTarget
:= False;
851 if gPlayer2
<> nil then gPlayer2
.NoTarget
:= False;
853 {$IF DEFINED(D2F_DEBUG)}
854 if gPlayer1
<> nil then gPlayer1
.NoTarget
:= True;
855 gAimLine
:= g_dbg_aimline_on
;
859 procedure g_Game_ExecuteEvent(Name
: String);
865 if gEvents
= nil then
867 for a
:= 0 to High(gEvents
) do
868 if gEvents
[a
].Name
= Name
then
870 if gEvents
[a
].Command
<> '' then
871 g_Console_Process(gEvents
[a
].Command
, True);
876 function g_Game_DelayEvent(DEType
: Byte; Time
: LongWord; Num
: Integer = 0; Str
: String = ''): Integer;
881 if gDelayedEvents
<> nil then
882 for a
:= 0 to High(gDelayedEvents
) do
883 if not gDelayedEvents
[a
].Pending
then
890 SetLength(gDelayedEvents
, Length(gDelayedEvents
) + 1);
891 n
:= High(gDelayedEvents
);
893 gDelayedEvents
[n
].Pending
:= True;
894 gDelayedEvents
[n
].DEType
:= DEType
;
895 gDelayedEvents
[n
].DENum
:= Num
;
896 gDelayedEvents
[n
].DEStr
:= Str
;
897 if DEType
= DE_GLOBEVENT
then
898 gDelayedEvents
[n
].Time
:= (GetTimer() {div 1000}) + Time
900 gDelayedEvents
[n
].Time
:= gTime
+ Time
;
909 if g_Game_IsNet
and g_Game_IsServer
then
910 MH_SEND_GameEvent(NET_EV_MAPEND
, Byte(gMissionFailed
));
914 gPauseHolmes
:= false;
917 g_Game_StopAllSounds(False);
922 EndingGameCounter
:= 0;
923 g_ActiveWindow
:= nil;
925 gLMSRespawn
:= LMS_RESPAWN_NONE
;
926 gLMSRespawnTime
:= 0;
929 EXIT_SIMPLE
: // Âûõîä ÷åðåç ìåíþ èëè êîíåö òåñòà
934 begin // Ýòî áûë òåñò
938 begin // Âûõîä â ãëàâíîå ìåíþ
939 gMusic
.SetByName('MUSIC_MENU');
941 if gState
<> STATE_SLIST
then
943 g_GUI_ShowWindow('MainMenu');
944 gState
:= STATE_MENU
;
947 // Îáíîâëÿåì ñïèñîê ñåðâåðîâ
948 slReturnPressed
:= True;
949 if g_Net_Slist_Fetch(slCurrent
) then
951 if slCurrent
= nil then
952 slWaitStr
:= _lc
[I_NET_SLIST_NOSERVERS
];
955 slWaitStr
:= _lc
[I_NET_SLIST_ERROR
];
956 g_Serverlist_GenerateTable(slCurrent
, slTable
);
959 g_Game_ExecuteEvent('ongameend');
963 EXIT_RESTART
: // Íà÷àòü óðîâåíü ñíà÷àëà
965 if not g_Game_IsClient
then g_Game_Restart();
968 EXIT_ENDLEVELCUSTOM
: // Çàêîí÷èëñÿ óðîâåíü â Ñâîåé èãðå
970 // Ñòàòèñòèêà Ñâîåé èãðû:
971 FileName
:= g_ExtractWadName(gMapInfo
.Map
);
973 CustomStat
.GameTime
:= gTime
;
974 CustomStat
.Map
:= ExtractFileName(FileName
)+':'+g_ExtractFileName(gMapInfo
.Map
); //ResName;
975 CustomStat
.MapName
:= gMapInfo
.Name
;
976 CustomStat
.GameMode
:= gGameSettings
.GameMode
;
977 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
978 CustomStat
.TeamStat
:= gTeamStat
;
980 CustomStat
.PlayerStat
:= nil;
982 // Ñòàòèñòèêà èãðîêîâ:
983 if gPlayers
<> nil then
985 for a
:= 0 to High(gPlayers
) do
986 if gPlayers
[a
] <> nil then
988 SetLength(CustomStat
.PlayerStat
, Length(CustomStat
.PlayerStat
)+1);
989 with CustomStat
.PlayerStat
[High(CustomStat
.PlayerStat
)] do
992 Name
:= gPlayers
[a
].Name
;
993 Frags
:= gPlayers
[a
].Frags
;
994 Deaths
:= gPlayers
[a
].Death
;
995 Kills
:= gPlayers
[a
].Kills
;
996 Team
:= gPlayers
[a
].Team
;
997 Color
:= gPlayers
[a
].Model
.Color
;
998 Spectator
:= gPlayers
[a
].FSpectator
;
1002 SortGameStat(CustomStat
.PlayerStat
);
1005 g_Game_ExecuteEvent('onmapend');
1006 if not g_Game_IsClient
then g_Player_ResetReady
;
1007 gInterReadyCount
:= 0;
1009 // Çàòóõàþùèé ýêðàí:
1010 EndingGameCounter
:= 255;
1011 gState
:= STATE_FOLD
;
1013 if gDefInterTime
< 0 then
1014 gInterEndTime
:= IfThen((gGameSettings
.GameType
= GT_SERVER
) and (gPlayer1
= nil), 15000, 25000)
1016 gInterEndTime
:= gDefInterTime
* 1000;
1019 EXIT_ENDLEVELSINGLE
: // Çàêîí÷èëñÿ óðîâåíü â Îäèíî÷íîé èãðå
1021 // Ñòàòèñòèêà Îäèíî÷íîé èãðû:
1022 SingleStat
.GameTime
:= gTime
;
1023 SingleStat
.TwoPlayers
:= gPlayer2
<> nil;
1024 SingleStat
.TotalSecrets
:= gSecretsCount
;
1025 // Ñòàòèñòèêà ïåðâîãî èãðîêà:
1026 SingleStat
.PlayerStat
[0].Kills
:= gPlayer1
.MonsterKills
;
1027 SingleStat
.PlayerStat
[0].Secrets
:= gPlayer1
.Secrets
;
1028 // Ñòàòèñòèêà âòîðîãî èãðîêà (åñëè åñòü):
1029 if SingleStat
.TwoPlayers
then
1031 SingleStat
.PlayerStat
[1].Kills
:= gPlayer2
.MonsterKills
;
1032 SingleStat
.PlayerStat
[1].Secrets
:= gPlayer2
.Secrets
;
1035 g_Game_ExecuteEvent('onmapend');
1038 if gNextMap
<> '' then
1040 gMusic
.SetByName('MUSIC_INTERMUS');
1042 gState
:= STATE_INTERSINGLE
;
1045 g_Game_ExecuteEvent('oninter');
1047 else // Áîëüøå íåò êàðò
1049 // Çàòóõàþùèé ýêðàí:
1050 EndingGameCounter
:= 255;
1051 gState
:= STATE_FOLD
;
1056 // Îêîí÷àíèå îáðàáîòàíî:
1057 if gExit
<> EXIT_QUIT
then
1061 procedure drawTime(X
, Y
: Integer); inline;
1063 e_TextureFontPrint(x
, y
,
1064 Format('%d:%.2d:%.2d', [
1065 gTime
div 1000 div 3600,
1066 (gTime
div 1000 div 60) mod 60,
1067 gTime
div 1000 mod 60
1072 procedure DrawStat();
1074 pc
, x
, y
, w
, h
: Integer;
1075 w1
, w2
, w3
, w4
: Integer;
1077 cw
, ch
, r
, g
, b
, rr
, gg
, bb
: Byte;
1080 stat
: TPlayerStatArray
;
1087 pc
:= g_Player_GetCount
;
1088 e_TextureFontGetSize(gStdFont
, cw
, ch
);
1090 w
:= gScreenWidth
-(gScreenWidth
div 5);
1091 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
1094 h
:= 40+ch
*5+(ch
+8)*pc
;
1095 x
:= (gScreenWidth
div 2)-(w
div 2);
1096 y
:= (gScreenHeight
div 2)-(h
div 2);
1098 e_DrawFillQuad(x
, y
, x
+w
-1, y
+h
-1, 64, 64, 64, 32);
1099 e_DrawQuad(x
, y
, x
+w
-1, y
+h
-1, 255, 127, 0);
1101 drawTime(x
+w
-78, y
+8);
1103 wad
:= g_ExtractWadNameNoPath(gMapInfo
.Map
);
1104 map
:= g_ExtractFileName(gMapInfo
.Map
);
1105 mapstr
:= wad
+ ':\' + map
+ ' - ' + gMapInfo
.Name
;
1107 case gGameSettings
.GameMode
of
1110 if gGameSettings
.MaxLives
= 0 then
1111 s1
:= _lc
[I_GAME_DM
]
1113 s1
:= _lc
[I_GAME_LMS
];
1114 s2
:= Format(_lc
[I_GAME_FRAG_LIMIT
], [gGameSettings
.GoalLimit
]);
1115 s3
:= Format(_lc
[I_GAME_TIME_LIMIT
], [gGameSettings
.TimeLimit
div 3600, (gGameSettings
.TimeLimit
div 60) mod 60, gGameSettings
.TimeLimit
mod 60]);
1120 if gGameSettings
.MaxLives
= 0 then
1121 s1
:= _lc
[I_GAME_TDM
]
1123 s1
:= _lc
[I_GAME_TLMS
];
1124 s2
:= Format(_lc
[I_GAME_FRAG_LIMIT
], [gGameSettings
.GoalLimit
]);
1125 s3
:= Format(_lc
[I_GAME_TIME_LIMIT
], [gGameSettings
.TimeLimit
div 3600, (gGameSettings
.TimeLimit
div 60) mod 60, gGameSettings
.TimeLimit
mod 60]);
1130 s1
:= _lc
[I_GAME_CTF
];
1131 s2
:= Format(_lc
[I_GAME_SCORE_LIMIT
], [gGameSettings
.GoalLimit
]);
1132 s3
:= Format(_lc
[I_GAME_TIME_LIMIT
], [gGameSettings
.TimeLimit
div 3600, (gGameSettings
.TimeLimit
div 60) mod 60, gGameSettings
.TimeLimit
mod 60]);
1137 if gGameSettings
.MaxLives
= 0 then
1138 s1
:= _lc
[I_GAME_COOP
]
1140 s1
:= _lc
[I_GAME_SURV
];
1141 s2
:= _lc
[I_GAME_MONSTERS
] + ' ' + IntToStr(gCoopMonstersKilled
) + '/' + IntToStr(gTotalMonsters
);
1142 s3
:= _lc
[I_GAME_SECRETS
] + ' ' + IntToStr(gCoopSecretsFound
) + '/' + IntToStr(gSecretsCount
);
1153 e_TextureFontPrintEx(x
+(w
div 2)-(Length(s1
)*cw
div 2), _y
, s1
, gStdFont
, 255, 255, 255, 1);
1155 e_TextureFontPrintEx(x
+(w
div 2)-(Length(mapstr
)*cw
div 2), _y
, mapstr
, gStdFont
, 200, 200, 200, 1);
1157 e_TextureFontPrintEx(x
+16, _y
, s2
, gStdFont
, 200, 200, 200, 1);
1159 e_TextureFontPrintEx(x
+w
-16-(Length(s3
))*cw
, _y
, s3
,
1160 gStdFont
, 200, 200, 200, 1);
1162 if NetMode
= NET_SERVER
then
1163 e_TextureFontPrintEx(x
+8, y
+ 8, _lc
[I_NET_SERVER
], gStdFont
, 255, 255, 255, 1)
1165 if NetMode
= NET_CLIENT
then
1166 e_TextureFontPrintEx(x
+8, y
+ 8,
1167 NetClientIP
+ ':' + IntToStr(NetClientPort
), gStdFont
, 255, 255, 255, 1);
1171 stat
:= g_Player_GetStats();
1174 w2
:= (w
-16) div 6 + 48; // øèðèíà 2 ñòîëáöà
1175 w3
:= (w
-16) div 6; // øèðèíà 3 è 4 ñòîëáöîâ
1177 w1
:= w
-16-w2
-w3
-w4
; // îñòàâøååñÿ ïðîñòðàíñòâî - äëÿ öâåòà è èìåíè èãðîêà
1179 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
1183 for a
:= TEAM_RED
to TEAM_BLUE
do
1185 if a
= TEAM_RED
then
1187 s1
:= _lc
[I_GAME_TEAM_RED
];
1194 s1
:= _lc
[I_GAME_TEAM_BLUE
];
1200 e_TextureFontPrintEx(x
+16, _y
, s1
, gStdFont
, r
, g
, b
, 1);
1201 e_TextureFontPrintEx(x
+w1
+16, _y
, IntToStr(gTeamStat
[a
].Goals
),
1202 gStdFont
, r
, g
, b
, 1);
1204 _y
:= _y
+ch
+(ch
div 4);
1205 e_DrawLine(1, x
+16, _y
, x
+w
-16, _y
, r
, g
, b
);
1206 _y
:= _y
+(ch
div 4);
1208 for aa
:= 0 to High(stat
) do
1209 if stat
[aa
].Team
= a
then
1225 e_TextureFontPrintEx(x
+16, _y
, Name
, gStdFont
, rr
, gg
, bb
, 1);
1227 e_TextureFontPrintEx(x
+w1
+16, _y
, Format(_lc
[I_GAME_PING_MS
], [Ping
, Loss
]), gStdFont
, rr
, gg
, bb
, 1);
1229 e_TextureFontPrintEx(x
+w1
+w2
+16, _y
, IntToStr(Frags
), gStdFont
, rr
, gg
, bb
, 1);
1231 e_TextureFontPrintEx(x
+w1
+w2
+w3
+16, _y
, IntToStr(Deaths
), gStdFont
, rr
, gg
, bb
, 1);
1238 else if gGameSettings
.GameMode
in [GM_DM
, GM_COOP
] then
1241 e_TextureFontPrintEx(x
+16, _y
, _lc
[I_GAME_PLAYER_NAME
], gStdFont
, 255, 127, 0, 1);
1242 e_TextureFontPrintEx(x
+16+w1
, _y
, _lc
[I_GAME_PING
], gStdFont
, 255, 127, 0, 1);
1243 e_TextureFontPrintEx(x
+16+w1
+w2
, _y
, _lc
[I_GAME_FRAGS
], gStdFont
, 255, 127, 0, 1);
1244 e_TextureFontPrintEx(x
+16+w1
+w2
+w3
, _y
, _lc
[I_GAME_DEATHS
], gStdFont
, 255, 127, 0, 1);
1247 for aa
:= 0 to High(stat
) do
1261 e_DrawFillQuad(x
+16, _y
+4, x
+32-1, _y
+16+4-1, Color
.R
, Color
.G
, Color
.B
, 0);
1262 e_DrawQuad(x
+16, _y
+4, x
+32-1, _y
+16+4-1, 192, 192, 192);
1264 e_TextureFontPrintEx(x
+16+16+8, _y
+4, Name
, gStdFont
, r
, g
, 0, 1);
1266 e_TextureFontPrintEx(x
+w1
+16, _y
+4, Format(_lc
[I_GAME_PING_MS
], [Ping
, Loss
]), gStdFont
, r
, g
, 0, 1);
1268 e_TextureFontPrintEx(x
+w1
+w2
+16, _y
+4, IntToStr(Frags
), gStdFont
, r
, g
, 0, 1);
1270 e_TextureFontPrintEx(x
+w1
+w2
+w3
+16, _y
+4, IntToStr(Deaths
), gStdFont
, r
, g
, 0, 1);
1276 procedure g_Game_Init();
1282 gTempDelete
:= False;
1284 sfsGCDisable(); // temporary disable removing of temporary volumes
1287 TEXTUREFILTER
:= GL_LINEAR
;
1288 g_Texture_CreateWADEx('MENU_BACKGROUND', GameWAD
+':TEXTURES\TITLE');
1289 g_Texture_CreateWADEx('INTER', GameWAD
+':TEXTURES\INTER');
1290 g_Texture_CreateWADEx('ENDGAME_EN', GameWAD
+':TEXTURES\ENDGAME_EN');
1291 g_Texture_CreateWADEx('ENDGAME_RU', GameWAD
+':TEXTURES\ENDGAME_RU');
1292 TEXTUREFILTER
:= GL_NEAREST
;
1294 LoadStdFont('STDTXT', 'STDFONT', gStdFont
);
1295 LoadFont('MENUTXT', 'MENUFONT', gMenuFont
);
1296 LoadFont('SMALLTXT', 'SMALLFONT', gMenuSmallFont
);
1298 g_Game_ClearLoading();
1299 g_Game_SetLoadingText(Format('Doom 2D: Forever %s', [GAME_VERSION
]), 0, False);
1300 g_Game_SetLoadingText('', 0, False);
1302 g_Game_SetLoadingText(_lc
[I_LOAD_CONSOLE
], 0, False);
1305 g_Game_SetLoadingText(_lc
[I_LOAD_MODELS
], 0, False);
1306 g_PlayerModel_LoadData();
1308 if FindFirst(ModelsDir
+'*.wad', faAnyFile
, SR
) = 0 then
1310 if not g_PlayerModel_Load(ModelsDir
+SR
.Name
) then
1311 e_WriteLog(Format('Error loading model %s', [SR
.Name
]), TMsgType
.Warning
);
1312 until FindNext(SR
) <> 0;
1315 if FindFirst(ModelsDir
+'*.pk3', faAnyFile
, SR
) = 0 then
1317 if not g_PlayerModel_Load(ModelsDir
+SR
.Name
) then
1318 e_WriteLog(Format('Error loading model %s', [SR
.Name
]), TMsgType
.Warning
);
1319 until FindNext(SR
) <> 0;
1322 if FindFirst(ModelsDir
+'*.zip', faAnyFile
, SR
) = 0 then
1324 if not g_PlayerModel_Load(ModelsDir
+SR
.Name
) then
1325 e_WriteLog(Format('Error loading model %s', [SR
.Name
]), TMsgType
.Warning
);
1326 until FindNext(SR
) <> 0;
1330 gPauseMain
:= false;
1331 gPauseHolmes
:= false;
1334 {e_MouseInfo.Accel := 1.0;}
1336 g_Game_SetLoadingText(_lc
[I_LOAD_GAME_DATA
], 0, False);
1339 g_Game_SetLoadingText(_lc
[I_LOAD_MUSIC
], 0, False);
1340 g_Sound_CreateWADEx('MUSIC_INTERMUS', GameWAD
+':MUSIC\INTERMUS', True);
1341 g_Sound_CreateWADEx('MUSIC_MENU', GameWAD
+':MUSIC\MENU', True);
1342 g_Sound_CreateWADEx('MUSIC_ROUNDMUS', GameWAD
+':MUSIC\ROUNDMUS', True, True);
1343 g_Sound_CreateWADEx('MUSIC_STDENDMUS', GameWAD
+':MUSIC\ENDMUS', True);
1345 g_Game_SetLoadingText(_lc
[I_LOAD_MENUS
], 0, False);
1348 gMusic
:= TMusic
.Create();
1349 gMusic
.SetByName('MUSIC_MENU');
1352 gGameSettings
.WarmupTime
:= 30;
1354 gState
:= STATE_MENU
;
1356 SetLength(gEvents
, 6);
1357 gEvents
[0].Name
:= 'ongamestart';
1358 gEvents
[1].Name
:= 'ongameend';
1359 gEvents
[2].Name
:= 'onmapstart';
1360 gEvents
[3].Name
:= 'onmapend';
1361 gEvents
[4].Name
:= 'oninter';
1362 gEvents
[5].Name
:= 'onwadend';
1364 sfsGCEnable(); // enable releasing unused volumes
1368 procedure g_Game_Free(freeTextures
: Boolean=true);
1370 if NetMode
= NET_CLIENT
then g_Net_Disconnect();
1371 if NetMode
= NET_SERVER
then g_Net_Host_Die();
1373 g_Map_Free(freeTextures
);
1375 g_Player_RemoveAllCorpses();
1377 gGameSettings
.GameType
:= GT_NONE
;
1378 if gGameSettings
.GameMode
= GM_SINGLE
then
1379 gGameSettings
.GameMode
:= GM_DM
;
1380 gSwitchGameMode
:= gGameSettings
.GameMode
;
1383 gExitByTrigger
:= False;
1386 function IsActivePlayer(p
: TPlayer
): Boolean;
1391 Result
:= (not p
.FDummy
) and (not p
.FSpectator
);
1394 function GetActivePlayer_ByID(ID
: Integer): TPlayer
;
1401 if gPlayers
= nil then
1403 for a
:= Low(gPlayers
) to High(gPlayers
) do
1404 if IsActivePlayer(gPlayers
[a
]) then
1406 if gPlayers
[a
].UID
<> ID
then
1408 Result
:= gPlayers
[a
];
1413 function GetActivePlayerID_Next(Skip
: Integer = -1): Integer;
1419 if gPlayers
= nil then
1423 for a
:= Low(gPlayers
) to High(gPlayers
) do
1424 if IsActivePlayer(gPlayers
[a
]) then
1426 SetLength(ids
, Length(ids
) + 1);
1427 ids
[High(ids
)] := gPlayers
[a
].UID
;
1428 if gPlayers
[a
].UID
= Skip
then
1431 if Length(ids
) = 0 then
1436 Result
:= ids
[(idx
+ 1) mod Length(ids
)];
1439 function GetActivePlayerID_Prev(Skip
: Integer = -1): Integer;
1445 if gPlayers
= nil then
1449 for a
:= Low(gPlayers
) to High(gPlayers
) do
1450 if IsActivePlayer(gPlayers
[a
]) then
1452 SetLength(ids
, Length(ids
) + 1);
1453 ids
[High(ids
)] := gPlayers
[a
].UID
;
1454 if gPlayers
[a
].UID
= Skip
then
1457 if Length(ids
) = 0 then
1460 Result
:= ids
[Length(ids
) - 1]
1462 Result
:= ids
[(Length(ids
) - 1 + idx
) mod Length(ids
)];
1465 function GetActivePlayerID_Random(Skip
: Integer = -1): Integer;
1471 if gPlayers
= nil then
1475 for a
:= Low(gPlayers
) to High(gPlayers
) do
1476 if IsActivePlayer(gPlayers
[a
]) then
1478 SetLength(ids
, Length(ids
) + 1);
1479 ids
[High(ids
)] := gPlayers
[a
].UID
;
1480 if gPlayers
[a
].UID
= Skip
then
1483 if Length(ids
) = 0 then
1485 if Length(ids
) = 1 then
1490 Result
:= ids
[Random(Length(ids
))];
1492 while (idx
<> -1) and (Result
= Skip
) and (a
> 0) do
1494 Result
:= ids
[Random(Length(ids
))];
1499 function GetRandomSpectMode(Current
: Byte): Byte;
1506 0: Result
:= SPECT_STATS
;
1507 1: Result
:= SPECT_MAPVIEW
;
1508 2: Result
:= SPECT_MAPVIEW
;
1509 3: Result
:= SPECT_PLAYERS
;
1510 4: Result
:= SPECT_PLAYERS
;
1511 5: Result
:= SPECT_PLAYERS
;
1512 6: Result
:= SPECT_PLAYERS
;
1514 if (Current
in [SPECT_STATS
, SPECT_MAPVIEW
]) and (Current
= Result
) then
1518 procedure ProcessPlayerControls (plr
: TPlayer
; p
: Integer; var MoveButton
: Byte);
1524 if (plr
= nil) then exit
;
1525 if (p
= 2) then time
:= 1000 else time
:= 1;
1526 strafeDir
:= MoveButton
shr 4;
1527 MoveButton
:= MoveButton
and $0F;
1529 if gPlayerAction
[p
, ACTION_MOVELEFT
] and (not gPlayerAction
[p
, ACTION_MOVERIGHT
]) then
1530 MoveButton
:= 1 // Íàæàòà òîëüêî "Âëåâî"
1531 else if (not gPlayerAction
[p
, ACTION_MOVELEFT
]) and gPlayerAction
[p
, ACTION_MOVERIGHT
] then
1532 MoveButton
:= 2 // Íàæàòà òîëüêî "Âïðàâî"
1533 else if (not gPlayerAction
[p
, ACTION_MOVELEFT
]) and (not gPlayerAction
[p
, ACTION_MOVERIGHT
]) then
1534 MoveButton
:= 0; // Íå íàæàòû íè "Âëåâî", íè "Âïðàâî"
1536 // Ñåé÷àñ èëè ðàíüøå áûëè íàæàòû "Âëåâî"/"Âïðàâî" => ïåðåäàåì èãðîêó:
1537 if MoveButton
= 1 then
1538 plr
.PressKey(KEY_LEFT
, time
)
1539 else if MoveButton
= 2 then
1540 plr
.PressKey(KEY_RIGHT
, time
);
1542 // if we have "strafe" key, turn off old strafe mechanics
1543 if gPlayerAction
[p
, ACTION_STRAFE
] then
1545 // new strafe mechanics
1546 if (strafeDir
= 0) then
1547 strafeDir
:= MoveButton
; // start strafing
1548 // now set direction according to strafe (reversed)
1549 if (strafeDir
= 2) then
1550 plr
.SetDirection(TDirection
.D_LEFT
)
1551 else if (strafeDir
= 1) then
1552 plr
.SetDirection(TDirection
.D_RIGHT
)
1556 strafeDir
:= 0; // not strafing anymore
1557 // Ðàíüøå áûëà íàæàòà "Âïðàâî", à ñåé÷àñ "Âëåâî" => áåæèì âïðàâî, ñìîòðèì âëåâî:
1558 if (MoveButton
= 2) and gPlayerAction
[p
, ACTION_MOVELEFT
] then
1559 plr
.SetDirection(TDirection
.D_LEFT
)
1560 // Ðàíüøå áûëà íàæàòà "Âëåâî", à ñåé÷àñ "Âïðàâî" => áåæèì âëåâî, ñìîòðèì âïðàâî:
1561 else if (MoveButton
= 1) and gPlayerAction
[p
, ACTION_MOVERIGHT
] then
1562 plr
.SetDirection(TDirection
.D_RIGHT
)
1563 // ×òî-òî áûëî íàæàòî è íå èçìåíèëîñü => êóäà áåæèì, òóäà è ñìîòðèì:
1564 else if MoveButton
<> 0 then
1565 plr
.SetDirection(TDirection(MoveButton
-1))
1568 // fix movebutton state
1569 MoveButton
:= MoveButton
or (strafeDir
shl 4);
1571 // Îñòàëüíûå êëàâèøè:
1572 if gPlayerAction
[p
, ACTION_JUMP
] then plr
.PressKey(KEY_JUMP
, time
);
1573 if gPlayerAction
[p
, ACTION_LOOKUP
] then plr
.PressKey(KEY_UP
, time
);
1574 if gPlayerAction
[p
, ACTION_LOOKDOWN
] then plr
.PressKey(KEY_DOWN
, time
);
1575 if gPlayerAction
[p
, ACTION_ATTACK
] then plr
.PressKey(KEY_FIRE
);
1576 if gPlayerAction
[p
, ACTION_WEAPNEXT
] then plr
.PressKey(KEY_NEXTWEAPON
);
1577 if gPlayerAction
[p
, ACTION_WEAPPREV
] then plr
.PressKey(KEY_PREVWEAPON
);
1578 if gPlayerAction
[p
, ACTION_ACTIVATE
] then plr
.PressKey(KEY_OPEN
);
1580 gPlayerAction
[p
, ACTION_WEAPNEXT
] := False; // HACK, remove after readyweaon&pendinweapon implementation
1581 gPlayerAction
[p
, ACTION_WEAPPREV
] := False; // HACK, remove after readyweaon&pendinweapon implementation
1583 for i
:= WP_FIRST
to WP_LAST
do
1585 if gSelectWeapon
[p
, i
] then
1587 plr
.QueueWeaponSwitch(i
); // all choices are passed there, and god will take the best
1588 gSelectWeapon
[p
, i
] := False
1592 // HACK: add dynlight here
1593 if gwin_k8_enable_light_experiments
then
1595 if e_KeyPressed(IK_F8
) and gGameOn
and (not gConsoleShow
) and (g_ActiveWindow
= nil) then
1597 g_playerLight
:= true;
1599 if e_KeyPressed(IK_F9
) and gGameOn
and (not gConsoleShow
) and (g_ActiveWindow
= nil) then
1601 g_playerLight
:= false;
1605 if gwin_has_stencil
and g_playerLight
then g_AddDynLight(plr
.GameX
+32, plr
.GameY
+40, 128, 1, 1, 0, 0.6);
1608 // HACK: don't have a "key was pressed" function
1609 procedure InterReady();
1611 if InterReadyTime
> gTime
then Exit
;
1612 InterReadyTime
:= gTime
+ 3000;
1613 MC_SEND_CheatRequest(NET_CHEAT_READY
);
1616 procedure g_Game_Update();
1618 Msg
: g_gui
.TMessage
;
1624 function sendMonsPos (mon
: TMonster
): Boolean;
1626 result
:= false; // don't stop
1627 // this will also reset "need-send" flag
1628 if mon
.gncNeedSend
then
1630 MH_SEND_MonsterPos(mon
.UID
);
1632 else if (mon
.MonsterType
= MONSTER_BARREL
) then
1634 if (mon
.GameVelX
<> 0) or (mon
.GameVelY
<> 0) then MH_SEND_MonsterPos(mon
.UID
);
1636 else if (mon
.MonsterState
<> MONSTATE_SLEEP
) then
1638 if (mon
.MonsterState
<> MONSTATE_DEAD
) or (mon
.GameVelX
<> 0) or (mon
.GameVelY
<> 0) then MH_SEND_MonsterPos(mon
.UID
);
1642 function sendMonsPosUnexpected (mon
: TMonster
): Boolean;
1644 result
:= false; // don't stop
1645 // this will also reset "need-send" flag
1646 if mon
.gncNeedSend
then MH_SEND_MonsterPos(mon
.UID
);
1650 reliableUpdate
: Boolean;
1655 // Ïîðà âûêëþ÷àòü èãðó:
1656 if gExit
= EXIT_QUIT
then
1658 // Èãðà çàêîí÷èëàñü - îáðàáàòûâàåì:
1662 if gExit
= EXIT_QUIT
then
1666 // ×èòàåì êëàâèàòóðó è äæîéñòèê, åñëè îêíî àêòèâíî
1667 // no need to, as we'll do it in event handler
1669 // Îáíîâëÿåì êîíñîëü (äâèæåíèå è ñîîáùåíèÿ):
1672 if (NetMode
= NET_NONE
) and (g_Game_IsNet
) and (gGameOn
or (gState
in [STATE_FOLD
, STATE_INTERCUSTOM
])) then
1674 gExit
:= EXIT_SIMPLE
;
1680 STATE_INTERSINGLE
, // Ñòàòèñòêà ïîñëå ïðîõîæäåíèÿ óðîâíÿ â Îäèíî÷íîé èãðå
1681 STATE_INTERCUSTOM
, // Ñòàòèñòêà ïîñëå ïðîõîæäåíèÿ óðîâíÿ â Ñâîåé èãðå
1682 STATE_INTERTEXT
, // Òåêñò ìåæäó óðîâíÿìè
1683 STATE_INTERPIC
: // Êàðòèíêà ìåæäó óðîâíÿìè
1685 if g_Game_IsNet
and g_Game_IsServer
then
1687 gInterTime
:= gInterTime
+ GAME_TICK
;
1688 a
:= Min((gInterEndTime
- gInterTime
) div 1000 + 1, 255);
1689 if a
<> gServInterTime
then
1691 gServInterTime
:= a
;
1692 MH_SEND_TimeSync(gServInterTime
);
1696 if (not g_Game_IsClient
) and
1700 e_KeyPressed(IK_RETURN
) or e_KeyPressed(IK_KPRETURN
) or e_KeyPressed(IK_SPACE
) or
1701 e_KeyPressed(VK_FIRE
) or e_KeyPressed(VK_OPEN
) or
1702 e_KeyPressed(JOY0_ATTACK
) or e_KeyPressed(JOY1_ATTACK
) or
1703 e_KeyPressed(JOY2_ATTACK
) or e_KeyPressed(JOY3_ATTACK
)
1705 and (not gJustChatted
) and (not gConsoleShow
) and (not gChatShow
)
1706 and (g_ActiveWindow
= nil)
1708 or (g_Game_IsNet
and ((gInterTime
> gInterEndTime
) or (gInterReadyCount
>= NetClientCount
)))
1711 begin // Íàæàëè <Enter>/<Ïðîáåë> èëè ïðîøëî äîñòàòî÷íî âðåìåíè:
1712 g_Game_StopAllSounds(True);
1714 if gMapOnce
then // Ýòî áûë òåñò
1715 gExit
:= EXIT_SIMPLE
1717 if gNextMap
<> '' then // Ïåðåõîäèì íà ñëåäóþùóþ êàðòó
1718 g_Game_ChangeMap(gNextMap
)
1719 else // Ñëåäóþùåé êàðòû íåò
1721 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
] then
1723 // Âûõîä â ãëàâíîå ìåíþ:
1725 g_GUI_ShowWindow('MainMenu');
1726 gMusic
.SetByName('MUSIC_MENU');
1728 gState
:= STATE_MENU
;
1731 // Ôèíàëüíàÿ êàðòèíêà:
1732 g_Game_ExecuteEvent('onwadend');
1734 if not gMusic
.SetByName('MUSIC_endmus') then
1735 gMusic
.SetByName('MUSIC_STDENDMUS');
1737 gState
:= STATE_ENDPIC
;
1739 g_Game_ExecuteEvent('ongameend');
1744 else if g_Game_IsClient
and
1747 e_KeyPressed(IK_RETURN
) or e_KeyPressed(IK_KPRETURN
) or e_KeyPressed(IK_SPACE
) or
1748 e_KeyPressed(VK_FIRE
) or e_KeyPressed(VK_OPEN
) or
1749 e_KeyPressed(JOY0_ATTACK
) or e_KeyPressed(JOY1_ATTACK
) or
1750 e_KeyPressed(JOY2_ATTACK
) or e_KeyPressed(JOY3_ATTACK
)
1752 and (not gJustChatted
) and (not gConsoleShow
) and (not gChatShow
)
1753 and (g_ActiveWindow
= nil)
1761 if gState
= STATE_INTERTEXT
then
1762 if InterText
.counter
> 0 then
1763 InterText
.counter
:= InterText
.counter
- 1;
1766 STATE_FOLD
: // Çàòóõàíèå ýêðàíà
1768 if EndingGameCounter
= 0 then
1770 // Çàêîí÷èëñÿ óðîâåíü â Ñâîåé èãðå:
1771 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
1773 InterReadyTime
:= -1;
1774 if gLastMap
and (gGameSettings
.GameMode
= GM_COOP
) then
1776 g_Game_ExecuteEvent('onwadend');
1777 if not gMusic
.SetByName('MUSIC_endmus') then
1778 gMusic
.SetByName('MUSIC_STDENDMUS');
1781 gMusic
.SetByName('MUSIC_ROUNDMUS');
1784 gState
:= STATE_INTERCUSTOM
;
1787 else // Çàêîí÷èëàñü ïîñëåäíÿÿ êàðòà â Îäèíî÷íîé èãðå
1789 gMusic
.SetByName('MUSIC_INTERMUS');
1791 gState
:= STATE_INTERSINGLE
;
1794 g_Game_ExecuteEvent('oninter');
1797 DecMin(EndingGameCounter
, 6, 0);
1800 STATE_ENDPIC
: // Êàðòèíêà îêîí÷àíèÿ ìåãàÂàäà
1802 if gMapOnce
then // Ýòî áûë òåñò
1804 gExit
:= EXIT_SIMPLE
;
1810 g_Serverlist_Control(slCurrent
, slTable
);
1813 // Ñòàòèñòèêà ïî Tab:
1815 IsDrawStat
:= (not gConsoleShow
) and (not gChatShow
) and (gGameSettings
.GameType
<> GT_SINGLE
) and g_Console_Action(ACTION_SCORES
);
1818 if gGameOn
and not gPause
and (gState
<> STATE_FOLD
) then
1820 // Âðåìÿ += 28 ìèëëèñåêóíä:
1821 gTime
:= gTime
+ GAME_TICK
;
1823 // Ñîîáùåíèå ïîñåðåäèíå ýêðàíà:
1824 if MessageTime
= 0 then
1826 if MessageTime
> 0 then
1827 MessageTime
:= MessageTime
- 1;
1829 if (g_Game_IsServer
) then
1831 // Áûë çàäàí ëèìèò âðåìåíè:
1832 if (gGameSettings
.TimeLimit
> 0) then
1833 if (gTime
- gGameStartTime
) div 1000 >= gGameSettings
.TimeLimit
then
1834 begin // Îí ïðîøåë => êîíåö óðîâíÿ
1839 // Íàäî ðåñïàâíèòü èãðîêîâ â LMS:
1840 if (gLMSRespawn
> LMS_RESPAWN_NONE
) and (gLMSRespawnTime
< gTime
) then
1841 g_Game_RestartRound(gLMSSoftSpawn
);
1843 // Ïðîâåðèì ðåçóëüòàò ãîëîñîâàíèÿ, åñëè âðåìÿ ïðîøëî
1844 if gVoteInProgress
and (gVoteTimer
< gTime
) then
1846 else if gVotePassed
and (gVoteCmdTimer
< gTime
) then
1848 g_Console_Process(gVoteCommand
);
1850 gVotePassed
:= False;
1853 // Çàìåðÿåì âðåìÿ çàõâàòà ôëàãîâ
1854 if gFlags
[FLAG_RED
].State
= FLAG_STATE_CAPTURED
then
1855 gFlags
[FLAG_RED
].CaptureTime
:= gFlags
[FLAG_RED
].CaptureTime
+ GAME_TICK
;
1856 if gFlags
[FLAG_BLUE
].State
= FLAG_STATE_CAPTURED
then
1857 gFlags
[FLAG_BLUE
].CaptureTime
:= gFlags
[FLAG_BLUE
].CaptureTime
+ GAME_TICK
;
1859 // Áûë çàäàí ëèìèò ïîáåä:
1860 if (gGameSettings
.GoalLimit
> 0) then
1864 if gGameSettings
.GameMode
= GM_DM
then
1865 begin // Â DM èùåì èãðîêà ñ max ôðàãàìè
1866 for i
:= 0 to High(gPlayers
) do
1867 if gPlayers
[i
] <> nil then
1868 if gPlayers
[i
].Frags
> b
then
1869 b
:= gPlayers
[i
].Frags
;
1872 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
1873 begin //  CTF/TDM âûáèðàåì êîìàíäó ñ íàèáîëüøèì ñ÷åòîì
1874 b
:= Max(gTeamStat
[TEAM_RED
].Goals
, gTeamStat
[TEAM_BLUE
].Goals
);
1877 // Ëèìèò ïîáåä íàáðàí => êîíåö óðîâíÿ:
1878 if b
>= gGameSettings
.GoalLimit
then
1885 // Îáðàáàòûâàåì êëàâèøè èãðîêîâ:
1886 if gPlayer1
<> nil then gPlayer1
.ReleaseKeys();
1887 if gPlayer2
<> nil then gPlayer2
.ReleaseKeys();
1888 if (not gConsoleShow
) and (not gChatShow
) and (g_ActiveWindow
= nil) then
1890 ProcessPlayerControls(gPlayer1
, 0, P1MoveButton
);
1891 ProcessPlayerControls(gPlayer2
, 1, P2MoveButton
);
1892 end // if not console
1895 if g_Game_IsNet
and (gPlayer1
<> nil) then gPlayer1
.PressKey(KEY_CHAT
, 10000);
1897 // process weapon switch queue
1901 if (gPlayer1
= nil) and (gPlayer2
= nil) and
1902 (not gConsoleShow
) and (not gChatShow
) and (g_ActiveWindow
= nil) then
1904 if not gSpectKeyPress
then
1906 if gPlayerAction
[0, ACTION_JUMP
] and (not gSpectAuto
) then
1908 // switch spect mode
1910 SPECT_NONE
: ; // not spectator
1912 SPECT_MAPVIEW
: Inc(gSpectMode
);
1913 SPECT_PLAYERS
: gSpectMode
:= SPECT_STATS
; // reset to 1
1915 gSpectKeyPress
:= True;
1917 if (gSpectMode
= SPECT_MAPVIEW
)
1918 and (not gSpectAuto
) then
1920 if gPlayerAction
[0, ACTION_MOVELEFT
] then
1921 gSpectX
:= Max(gSpectX
- gSpectStep
, 0);
1922 if gPlayerAction
[0, ACTION_MOVERIGHT
] then
1923 gSpectX
:= Min(gSpectX
+ gSpectStep
, gMapInfo
.Width
- gScreenWidth
);
1924 if gPlayerAction
[0, ACTION_LOOKUP
] then
1925 gSpectY
:= Max(gSpectY
- gSpectStep
, 0);
1926 if gPlayerAction
[0, ACTION_LOOKDOWN
] then
1927 gSpectY
:= Min(gSpectY
+ gSpectStep
, gMapInfo
.Height
- gScreenHeight
);
1928 if gPlayerAction
[0, ACTION_WEAPPREV
] then
1931 if gSpectStep
> 4 then gSpectStep
:= gSpectStep
shr 1;
1932 gSpectKeyPress
:= True;
1934 if gPlayerAction
[0, ACTION_WEAPNEXT
] then
1937 if gSpectStep
< 64 then gSpectStep
:= gSpectStep
shl 1;
1938 gSpectKeyPress
:= True;
1941 if (gSpectMode
= SPECT_PLAYERS
)
1942 and (not gSpectAuto
) then
1944 if gPlayerAction
[0, ACTION_LOOKUP
] then
1947 gSpectViewTwo
:= True;
1948 gSpectKeyPress
:= True;
1950 if gPlayerAction
[0, ACTION_LOOKDOWN
] then
1952 // remove second view
1953 gSpectViewTwo
:= False;
1954 gSpectKeyPress
:= True;
1956 if gPlayerAction
[0, ACTION_MOVELEFT
] then
1958 // prev player (view 1)
1959 gSpectPID1
:= GetActivePlayerID_Prev(gSpectPID1
);
1960 gSpectKeyPress
:= True;
1962 if gPlayerAction
[0, ACTION_MOVERIGHT
] then
1964 // next player (view 1)
1965 gSpectPID1
:= GetActivePlayerID_Next(gSpectPID1
);
1966 gSpectKeyPress
:= True;
1968 if gPlayerAction
[0, ACTION_WEAPPREV
] then
1970 // prev player (view 2)
1971 gSpectPID2
:= GetActivePlayerID_Prev(gSpectPID2
);
1972 gSpectKeyPress
:= True;
1974 if gPlayerAction
[0, ACTION_WEAPNEXT
] then
1976 // next player (view 2)
1977 gSpectPID2
:= GetActivePlayerID_Next(gSpectPID2
);
1978 gSpectKeyPress
:= True;
1981 if gPlayerAction
[0, ACTION_ATTACK
] then
1983 if (gSpectMode
= SPECT_STATS
) and (not gSpectAuto
) then
1986 gSpectAutoNext
:= 0;
1987 gSpectViewTwo
:= False;
1988 gSpectKeyPress
:= True;
1993 gSpectMode
:= SPECT_STATS
;
1994 gSpectAuto
:= False;
1995 gSpectKeyPress
:= True;
2000 if (not gPlayerAction
[0, ACTION_JUMP
]) and
2001 (not gPlayerAction
[0, ACTION_ATTACK
]) and
2002 (not gPlayerAction
[0, ACTION_MOVELEFT
]) and
2003 (not gPlayerAction
[0, ACTION_MOVERIGHT
]) and
2004 (not gPlayerAction
[0, ACTION_LOOKUP
]) and
2005 (not gPlayerAction
[0, ACTION_LOOKDOWN
]) and
2006 (not gPlayerAction
[0, ACTION_WEAPPREV
]) and
2007 (not gPlayerAction
[0, ACTION_WEAPNEXT
]) then
2008 gSpectKeyPress
:= False;
2012 if gSpectMode
= SPECT_MAPVIEW
then
2014 i
:= Min(Max(gSpectX
+ gSpectAutoStepX
, 0), gMapInfo
.Width
- gScreenWidth
);
2016 gSpectAutoNext
:= gTime
2019 i
:= Min(Max(gSpectY
+ gSpectAutoStepY
, 0), gMapInfo
.Height
- gScreenHeight
);
2021 gSpectAutoNext
:= gTime
2025 if gSpectAutoNext
<= gTime
then
2027 if gSpectAutoNext
> 0 then
2029 gSpectMode
:= GetRandomSpectMode(gSpectMode
);
2033 gSpectX
:= Random(gMapInfo
.Width
- gScreenWidth
);
2034 gSpectY
:= Random(gMapInfo
.Height
- gScreenHeight
);
2035 gSpectAutoStepX
:= Random(9) - 4;
2036 gSpectAutoStepY
:= Random(9) - 4;
2037 if ((gSpectX
< 800) and (gSpectAutoStepX
< 0)) or
2038 ((gSpectX
> gMapInfo
.Width
- gScreenWidth
- 800) and (gSpectAutoStepX
> 0)) then
2039 gSpectAutoStepX
:= gSpectAutoStepX
* -1;
2040 if ((gSpectY
< 800) and (gSpectAutoStepY
< 0)) or
2041 ((gSpectY
> gMapInfo
.Height
- gScreenHeight
- 800) and (gSpectAutoStepY
> 0)) then
2042 gSpectAutoStepY
:= gSpectAutoStepY
* -1;
2046 gSpectPID1
:= GetActivePlayerID_Random(gSpectPID1
);
2051 SPECT_STATS
: gSpectAutoNext
:= gTime
+ (Random(3) + 5) * 1000;
2052 SPECT_MAPVIEW
: gSpectAutoNext
:= gTime
+ (Random(4) + 7) * 1000;
2053 SPECT_PLAYERS
: gSpectAutoNext
:= gTime
+ (Random(7) + 8) * 1000;
2059 // Îáíîâëÿåì âñå îñòàëüíîå:
2062 g_Triggers_Update();
2064 g_Monsters_Update();
2066 g_Player_UpdateAll();
2067 g_Player_UpdatePhysicalObjects();
2069 // server: send newly spawned monsters unconditionally
2070 if (gGameSettings
.GameType
= GT_SERVER
) then
2072 if (Length(gMonstersSpawned
) > 0) then
2074 for I
:= 0 to High(gMonstersSpawned
) do MH_SEND_MonsterSpawn(gMonstersSpawned
[I
]);
2075 SetLength(gMonstersSpawned
, 0);
2079 if (gSoundTriggerTime
> 8) then
2081 g_Game_UpdateTriggerSounds();
2082 gSoundTriggerTime
:= 0;
2086 Inc(gSoundTriggerTime
);
2089 if (NetMode
= NET_SERVER
) then
2091 Inc(NetTimeToUpdate
);
2092 Inc(NetTimeToReliable
);
2094 // send monster updates
2095 if (NetTimeToReliable
>= NetRelupdRate
) or (NetTimeToUpdate
>= NetUpdateRate
) then
2097 // send all monsters (periodic sync)
2098 reliableUpdate
:= (NetTimeToReliable
>= NetRelupdRate
);
2100 for I
:= 0 to High(gPlayers
) do
2102 if (gPlayers
[I
] <> nil) then MH_SEND_PlayerPos(reliableUpdate
, gPlayers
[I
].UID
);
2105 g_Mons_ForEach(sendMonsPos
);
2107 if reliableUpdate
then
2109 NetTimeToReliable
:= 0;
2110 NetTimeToUpdate
:= NetUpdateRate
;
2114 NetTimeToUpdate
:= 0;
2119 // send only mosters with some unexpected changes
2120 g_Mons_ForEach(sendMonsPosUnexpected
);
2123 // send unexpected platform changes
2124 g_Map_NetSendInterestingPanels();
2126 if NetUseMaster
then
2128 if gTime
>= NetTimeToMaster
then
2130 if (NetMHost
= nil) or (NetMPeer
= nil) then
2132 if not g_Net_Slist_Connect
then g_Console_Add(_lc
[I_NET_MSG_ERROR
] + _lc
[I_NET_SLIST_ERROR
]);
2136 NetTimeToMaster
:= gTime
+ NetMasterRate
;
2140 else if (NetMode
= NET_CLIENT
) then
2142 MC_SEND_PlayerPos();
2144 end; // if gameOn ...
2146 // Àêòèâíî îêíî èíòåðôåéñà - ïåðåäàåì êëàâèøè åìó:
2147 if g_ActiveWindow
<> nil then
2149 w
:= e_GetFirstKeyPressed();
2151 if (w
<> IK_INVALID
) then
2153 Msg
.Msg
:= MESSAGE_DIKEY
;
2155 g_ActiveWindow
.OnMessage(Msg
);
2158 // Åñëè îíî îò ýòîãî íå çàêðûëîñü, òî îáíîâëÿåì:
2159 if g_ActiveWindow
<> nil then
2160 g_ActiveWindow
.Update();
2162 // Íóæíî ñìåíèòü ðàçðåøåíèå:
2163 if gResolutionChange
then
2165 e_WriteLog('Changing resolution', TMsgType
.Notify
);
2166 g_Game_ChangeResolution(gRC_Width
, gRC_Height
, gRC_FullScreen
, gRC_Maximized
);
2167 gResolutionChange
:= False;
2168 g_ActiveWindow
:= nil;
2171 // Íóæíî ñìåíèòü ÿçûê:
2172 if gLanguageChange
then
2174 //e_WriteLog('Read language file', MSG_NOTIFY);
2175 //g_Language_Load(DataDir + gLanguage + '.txt');
2176 g_Language_Set(gLanguage
);
2178 gLanguageChange
:= False;
2182 // Ãîðÿ÷àÿ êëàâèøà äëÿ âûçîâà ìåíþ âûõîäà èç èãðû (F10):
2183 if e_KeyPressed(IK_F10
) and
2185 (not gConsoleShow
) and
2186 (g_ActiveWindow
= nil) then
2191 Time
:= GetTimer() {div 1000};
2193 // Îáðàáîòêà îòëîæåííûõ ñîáûòèé:
2194 if gDelayedEvents
<> nil then
2195 for a
:= 0 to High(gDelayedEvents
) do
2196 if gDelayedEvents
[a
].Pending
and
2198 ((gDelayedEvents
[a
].DEType
= DE_GLOBEVENT
) and (gDelayedEvents
[a
].Time
<= Time
)) or
2199 ((gDelayedEvents
[a
].DEType
> DE_GLOBEVENT
) and (gDelayedEvents
[a
].Time
<= gTime
))
2202 case gDelayedEvents
[a
].DEType
of
2204 g_Game_ExecuteEvent(gDelayedEvents
[a
].DEStr
);
2207 g_Game_Announce_GoodShot(gDelayedEvents
[a
].DENum
);
2211 g_Game_Announce_KillCombo(gDelayedEvents
[a
].DENum
);
2212 if g_Game_IsNet
and g_Game_IsServer
then
2213 MH_SEND_GameEvent(NET_EV_KILLCOMBO
, gDelayedEvents
[a
].DENum
);
2217 g_Game_Announce_BodyKill(gDelayedEvents
[a
].DENum
);
2219 gDelayedEvents
[a
].Pending
:= False;
2222 // Êàæäóþ ñåêóíäó îáíîâëÿåì ñ÷åò÷èê îáíîâëåíèé:
2223 UPSCounter
:= UPSCounter
+ 1;
2224 if Time
- UPSTime
>= 1000 then
2233 g_Weapon_AddDynLights();
2234 g_Items_AddDynLights();
2238 procedure g_Game_LoadChatSounds(Resource
: string);
2241 FileName
, Snd
: string;
2243 len
, cnt
, tags
, i
, j
: Integer;
2246 FileName
:= g_ExtractWadName(Resource
);
2248 WAD
:= TWADFile
.Create();
2249 WAD
.ReadFile(FileName
);
2251 if not WAD
.GetResource(g_ExtractFilePathName(Resource
), p
, len
) then
2258 cfg
:= TConfig
.CreateMem(p
, len
);
2259 cnt
:= cfg
.ReadInt('ChatSounds', 'Count', 0);
2261 SetLength(gChatSounds
, cnt
);
2262 for i
:= 0 to Length(gChatSounds
) - 1 do
2264 gChatSounds
[i
].Sound
:= nil;
2265 Snd
:= Trim(cfg
.ReadStr(IntToStr(i
), 'Sound', ''));
2266 tags
:= cfg
.ReadInt(IntToStr(i
), 'Tags', 0);
2267 if (Snd
= '') or (Tags
<= 0) then
2269 g_Sound_CreateWADEx('SOUND_CHAT_MACRO' + IntToStr(i
), GameWAD
+':'+Snd
);
2270 gChatSounds
[i
].Sound
:= TPlayableSound
.Create();
2271 gChatSounds
[i
].Sound
.SetByName('SOUND_CHAT_MACRO' + IntToStr(i
));
2272 SetLength(gChatSounds
[i
].Tags
, tags
);
2273 for j
:= 0 to tags
- 1 do
2274 gChatSounds
[i
].Tags
[j
] := toLowerCase1251(cfg
.ReadStr(IntToStr(i
), 'Tag' + IntToStr(j
), ''));
2275 gChatSounds
[i
].FullWord
:= cfg
.ReadBool(IntToStr(i
), 'FullWord', False);
2282 procedure g_Game_FreeChatSounds();
2286 for i
:= 0 to Length(gChatSounds
) - 1 do
2288 gChatSounds
[i
].Sound
.Free();
2289 g_Sound_Delete('SOUND_CHAT_MACRO' + IntToStr(i
));
2291 SetLength(gChatSounds
, 0);
2295 procedure g_Game_LoadData();
2302 if DataLoaded
then Exit
;
2304 e_WriteLog('Loading game data...', TMsgType
.Notify
);
2306 g_Texture_CreateWADEx('NOTEXTURE', GameWAD
+':TEXTURES\NOTEXTURE');
2307 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUD', GameWAD
+':TEXTURES\HUD');
2308 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDAIR', GameWAD
+':TEXTURES\AIRBAR');
2309 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDJET', GameWAD
+':TEXTURES\JETBAR');
2310 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDBG', GameWAD
+':TEXTURES\HUDBG');
2311 g_Texture_CreateWADEx('TEXTURE_PLAYER_ARMORHUD', GameWAD
+':TEXTURES\ARMORHUD');
2312 g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG', GameWAD
+':TEXTURES\FLAGHUD_R_BASE');
2313 g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG_S', GameWAD
+':TEXTURES\FLAGHUD_R_STOLEN');
2314 g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG_D', GameWAD
+':TEXTURES\FLAGHUD_R_DROP');
2315 g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG', GameWAD
+':TEXTURES\FLAGHUD_B_BASE');
2316 g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG_S', GameWAD
+':TEXTURES\FLAGHUD_B_STOLEN');
2317 g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG_D', GameWAD
+':TEXTURES\FLAGHUD_B_DROP');
2318 g_Texture_CreateWADEx('TEXTURE_PLAYER_TALKBUBBLE', GameWAD
+':TEXTURES\TALKBUBBLE');
2319 g_Texture_CreateWADEx('TEXTURE_PLAYER_INVULPENTA', GameWAD
+':TEXTURES\PENTA');
2320 g_Texture_CreateWADEx('TEXTURE_PLAYER_INDICATOR', GameWAD
+':TEXTURES\PLRIND');
2323 if not g_Texture_CreateWADEx('UI_GFX_PBAR_LEFT', GameWAD
+':TEXTURES\LLEFT') then hasPBarGfx
:= false;
2324 if not g_Texture_CreateWADEx('UI_GFX_PBAR_MARKER', GameWAD
+':TEXTURES\LMARKER') then hasPBarGfx
:= false;
2325 if not g_Texture_CreateWADEx('UI_GFX_PBAR_MIDDLE', GameWAD
+':TEXTURES\LMIDDLE') then hasPBarGfx
:= false;
2326 if not g_Texture_CreateWADEx('UI_GFX_PBAR_RIGHT', GameWAD
+':TEXTURES\LRIGHT') then hasPBarGfx
:= false;
2330 g_Texture_GetSize('UI_GFX_PBAR_LEFT', wl
, hl
);
2331 g_Texture_GetSize('UI_GFX_PBAR_RIGHT', wr
, hr
);
2332 g_Texture_GetSize('UI_GFX_PBAR_MIDDLE', wb
, hb
);
2333 g_Texture_GetSize('UI_GFX_PBAR_MARKER', wm
, hm
);
2334 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
2340 hasPBarGfx
:= false;
2344 g_Frames_CreateWAD(nil, 'FRAMES_TELEPORT', GameWAD
+':TEXTURES\TELEPORT', 64, 64, 10, False);
2345 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH', GameWAD
+':WEAPONS\PUNCH', 64, 64, 4, False);
2346 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_UP', GameWAD
+':WEAPONS\PUNCH_UP', 64, 64, 4, False);
2347 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_DN', GameWAD
+':WEAPONS\PUNCH_DN', 64, 64, 4, False);
2348 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_BERSERK', GameWAD
+':WEAPONS\PUNCHB', 64, 64, 4, False);
2349 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_BERSERK_UP', GameWAD
+':WEAPONS\PUNCHB_UP', 64, 64, 4, False);
2350 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_BERSERK_DN', GameWAD
+':WEAPONS\PUNCHB_DN', 64, 64, 4, False);
2351 g_Sound_CreateWADEx('SOUND_GAME_TELEPORT', GameWAD
+':SOUNDS\TELEPORT');
2352 g_Sound_CreateWADEx('SOUND_GAME_NOTELEPORT', GameWAD
+':SOUNDS\NOTELEPORT');
2353 g_Sound_CreateWADEx('SOUND_GAME_SECRET', GameWAD
+':SOUNDS\SECRET');
2354 g_Sound_CreateWADEx('SOUND_GAME_DOOROPEN', GameWAD
+':SOUNDS\DOOROPEN');
2355 g_Sound_CreateWADEx('SOUND_GAME_DOORCLOSE', GameWAD
+':SOUNDS\DOORCLOSE');
2356 g_Sound_CreateWADEx('SOUND_GAME_BULK1', GameWAD
+':SOUNDS\BULK1');
2357 g_Sound_CreateWADEx('SOUND_GAME_BULK2', GameWAD
+':SOUNDS\BULK2');
2358 g_Sound_CreateWADEx('SOUND_GAME_BUBBLE1', GameWAD
+':SOUNDS\BUBBLE1');
2359 g_Sound_CreateWADEx('SOUND_GAME_BUBBLE2', GameWAD
+':SOUNDS\BUBBLE2');
2360 g_Sound_CreateWADEx('SOUND_GAME_BURNING', GameWAD
+':SOUNDS\BURNING');
2361 g_Sound_CreateWADEx('SOUND_GAME_SWITCH1', GameWAD
+':SOUNDS\SWITCH1');
2362 g_Sound_CreateWADEx('SOUND_GAME_SWITCH0', GameWAD
+':SOUNDS\SWITCH0');
2363 g_Sound_CreateWADEx('SOUND_GAME_RADIO', GameWAD
+':SOUNDS\RADIO');
2364 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD1', GameWAD
+':SOUNDS\GOOD1');
2365 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD2', GameWAD
+':SOUNDS\GOOD2');
2366 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD3', GameWAD
+':SOUNDS\GOOD3');
2367 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD4', GameWAD
+':SOUNDS\GOOD4');
2368 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL2X', GameWAD
+':SOUNDS\KILL2X');
2369 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL3X', GameWAD
+':SOUNDS\KILL3X');
2370 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL4X', GameWAD
+':SOUNDS\KILL4X');
2371 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILLMX', GameWAD
+':SOUNDS\KILLMX');
2372 g_Sound_CreateWADEx('SOUND_ANNOUNCER_MUHAHA1', GameWAD
+':SOUNDS\MUHAHA1');
2373 g_Sound_CreateWADEx('SOUND_ANNOUNCER_MUHAHA2', GameWAD
+':SOUNDS\MUHAHA2');
2374 g_Sound_CreateWADEx('SOUND_ANNOUNCER_MUHAHA3', GameWAD
+':SOUNDS\MUHAHA3');
2375 g_Sound_CreateWADEx('SOUND_CTF_GET1', GameWAD
+':SOUNDS\GETFLAG1');
2376 g_Sound_CreateWADEx('SOUND_CTF_GET2', GameWAD
+':SOUNDS\GETFLAG2');
2377 g_Sound_CreateWADEx('SOUND_CTF_LOST1', GameWAD
+':SOUNDS\LOSTFLG1');
2378 g_Sound_CreateWADEx('SOUND_CTF_LOST2', GameWAD
+':SOUNDS\LOSTFLG2');
2379 g_Sound_CreateWADEx('SOUND_CTF_RETURN1', GameWAD
+':SOUNDS\RETFLAG1');
2380 g_Sound_CreateWADEx('SOUND_CTF_RETURN2', GameWAD
+':SOUNDS\RETFLAG2');
2381 g_Sound_CreateWADEx('SOUND_CTF_CAPTURE1', GameWAD
+':SOUNDS\CAPFLAG1');
2382 g_Sound_CreateWADEx('SOUND_CTF_CAPTURE2', GameWAD
+':SOUNDS\CAPFLAG2');
2384 goodsnd
[0] := TPlayableSound
.Create();
2385 goodsnd
[1] := TPlayableSound
.Create();
2386 goodsnd
[2] := TPlayableSound
.Create();
2387 goodsnd
[3] := TPlayableSound
.Create();
2389 goodsnd
[0].SetByName('SOUND_ANNOUNCER_GOOD1');
2390 goodsnd
[1].SetByName('SOUND_ANNOUNCER_GOOD2');
2391 goodsnd
[2].SetByName('SOUND_ANNOUNCER_GOOD3');
2392 goodsnd
[3].SetByName('SOUND_ANNOUNCER_GOOD4');
2394 killsnd
[0] := TPlayableSound
.Create();
2395 killsnd
[1] := TPlayableSound
.Create();
2396 killsnd
[2] := TPlayableSound
.Create();
2397 killsnd
[3] := TPlayableSound
.Create();
2399 killsnd
[0].SetByName('SOUND_ANNOUNCER_KILL2X');
2400 killsnd
[1].SetByName('SOUND_ANNOUNCER_KILL3X');
2401 killsnd
[2].SetByName('SOUND_ANNOUNCER_KILL4X');
2402 killsnd
[3].SetByName('SOUND_ANNOUNCER_KILLMX');
2404 hahasnd
[0] := TPlayableSound
.Create();
2405 hahasnd
[1] := TPlayableSound
.Create();
2406 hahasnd
[2] := TPlayableSound
.Create();
2408 hahasnd
[0].SetByName('SOUND_ANNOUNCER_MUHAHA1');
2409 hahasnd
[1].SetByName('SOUND_ANNOUNCER_MUHAHA2');
2410 hahasnd
[2].SetByName('SOUND_ANNOUNCER_MUHAHA3');
2412 sound_get_flag
[0] := TPlayableSound
.Create();
2413 sound_get_flag
[1] := TPlayableSound
.Create();
2414 sound_lost_flag
[0] := TPlayableSound
.Create();
2415 sound_lost_flag
[1] := TPlayableSound
.Create();
2416 sound_ret_flag
[0] := TPlayableSound
.Create();
2417 sound_ret_flag
[1] := TPlayableSound
.Create();
2418 sound_cap_flag
[0] := TPlayableSound
.Create();
2419 sound_cap_flag
[1] := TPlayableSound
.Create();
2421 sound_get_flag
[0].SetByName('SOUND_CTF_GET1');
2422 sound_get_flag
[1].SetByName('SOUND_CTF_GET2');
2423 sound_lost_flag
[0].SetByName('SOUND_CTF_LOST1');
2424 sound_lost_flag
[1].SetByName('SOUND_CTF_LOST2');
2425 sound_ret_flag
[0].SetByName('SOUND_CTF_RETURN1');
2426 sound_ret_flag
[1].SetByName('SOUND_CTF_RETURN2');
2427 sound_cap_flag
[0].SetByName('SOUND_CTF_CAPTURE1');
2428 sound_cap_flag
[1].SetByName('SOUND_CTF_CAPTURE2');
2430 g_Game_LoadChatSounds(GameWAD
+':CHATSND\SNDCFG');
2432 g_Game_SetLoadingText(_lc
[I_LOAD_ITEMS_DATA
], 0, False);
2435 g_Game_SetLoadingText(_lc
[I_LOAD_WEAPONS_DATA
], 0, False);
2436 g_Weapon_LoadData();
2438 g_Monsters_LoadData();
2443 procedure g_Game_FreeData();
2445 if not DataLoaded
then Exit
;
2448 g_Weapon_FreeData();
2449 g_Monsters_FreeData();
2451 e_WriteLog('Releasing game data...', TMsgType
.Notify
);
2453 g_Texture_Delete('NOTEXTURE');
2454 g_Texture_Delete('TEXTURE_PLAYER_HUD');
2455 g_Texture_Delete('TEXTURE_PLAYER_HUDBG');
2456 g_Texture_Delete('TEXTURE_PLAYER_ARMORHUD');
2457 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG');
2458 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG_S');
2459 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG_D');
2460 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG');
2461 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG_S');
2462 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG_D');
2463 g_Texture_Delete('TEXTURE_PLAYER_TALKBUBBLE');
2464 g_Texture_Delete('TEXTURE_PLAYER_INVULPENTA');
2465 g_Frames_DeleteByName('FRAMES_TELEPORT');
2466 g_Frames_DeleteByName('FRAMES_PUNCH');
2467 g_Frames_DeleteByName('FRAMES_PUNCH_UP');
2468 g_Frames_DeleteByName('FRAMES_PUNCH_DN');
2469 g_Frames_DeleteByName('FRAMES_PUNCH_BERSERK');
2470 g_Frames_DeleteByName('FRAMES_PUNCH_BERSERK_UP');
2471 g_Frames_DeleteByName('FRAMES_PUNCH_BERSERK_DN');
2472 g_Sound_Delete('SOUND_GAME_TELEPORT');
2473 g_Sound_Delete('SOUND_GAME_NOTELEPORT');
2474 g_Sound_Delete('SOUND_GAME_SECRET');
2475 g_Sound_Delete('SOUND_GAME_DOOROPEN');
2476 g_Sound_Delete('SOUND_GAME_DOORCLOSE');
2477 g_Sound_Delete('SOUND_GAME_BULK1');
2478 g_Sound_Delete('SOUND_GAME_BULK2');
2479 g_Sound_Delete('SOUND_GAME_BUBBLE1');
2480 g_Sound_Delete('SOUND_GAME_BUBBLE2');
2481 g_Sound_Delete('SOUND_GAME_BURNING');
2482 g_Sound_Delete('SOUND_GAME_SWITCH1');
2483 g_Sound_Delete('SOUND_GAME_SWITCH0');
2490 g_Sound_Delete('SOUND_ANNOUNCER_GOOD1');
2491 g_Sound_Delete('SOUND_ANNOUNCER_GOOD2');
2492 g_Sound_Delete('SOUND_ANNOUNCER_GOOD3');
2493 g_Sound_Delete('SOUND_ANNOUNCER_GOOD4');
2500 g_Sound_Delete('SOUND_ANNOUNCER_KILL2X');
2501 g_Sound_Delete('SOUND_ANNOUNCER_KILL3X');
2502 g_Sound_Delete('SOUND_ANNOUNCER_KILL4X');
2503 g_Sound_Delete('SOUND_ANNOUNCER_KILLMX');
2509 g_Sound_Delete('SOUND_ANNOUNCER_MUHAHA1');
2510 g_Sound_Delete('SOUND_ANNOUNCER_MUHAHA2');
2511 g_Sound_Delete('SOUND_ANNOUNCER_MUHAHA3');
2513 sound_get_flag
[0].Free();
2514 sound_get_flag
[1].Free();
2515 sound_lost_flag
[0].Free();
2516 sound_lost_flag
[1].Free();
2517 sound_ret_flag
[0].Free();
2518 sound_ret_flag
[1].Free();
2519 sound_cap_flag
[0].Free();
2520 sound_cap_flag
[1].Free();
2522 g_Sound_Delete('SOUND_CTF_GET1');
2523 g_Sound_Delete('SOUND_CTF_GET2');
2524 g_Sound_Delete('SOUND_CTF_LOST1');
2525 g_Sound_Delete('SOUND_CTF_LOST2');
2526 g_Sound_Delete('SOUND_CTF_RETURN1');
2527 g_Sound_Delete('SOUND_CTF_RETURN2');
2528 g_Sound_Delete('SOUND_CTF_CAPTURE1');
2529 g_Sound_Delete('SOUND_CTF_CAPTURE2');
2531 g_Game_FreeChatSounds();
2533 DataLoaded
:= False;
2536 procedure DrawCustomStat();
2542 ww2
, hh2
, r
, g
, b
, rr
, gg
, bb
: Byte;
2543 s1
, s2
, topstr
: String;
2545 e_TextureFontGetSize(gStdFont
, ww2
, hh2
);
2547 g_ProcessMessages();
2549 if g_Console_Action(ACTION_SCORES
) then
2551 if not gStatsPressed
then
2553 gStatsOff
:= not gStatsOff
;
2554 gStatsPressed
:= True;
2558 gStatsPressed
:= False;
2562 s1
:= _lc
[I_MENU_INTER_NOTICE_TAB
];
2563 w
:= (Length(s1
) * ww2
) div 2;
2564 x
:= gScreenWidth
div 2 - w
;
2566 e_TextureFontPrint(x
, y
, s1
, gStdFont
);
2570 if (gGameSettings
.GameMode
= GM_COOP
) then
2572 if gMissionFailed
then
2573 topstr
:= _lc
[I_MENU_INTER_MISSION_FAIL
]
2575 topstr
:= _lc
[I_MENU_INTER_LEVEL_COMPLETE
];
2578 topstr
:= _lc
[I_MENU_INTER_ROUND_OVER
];
2580 e_CharFont_GetSize(gMenuFont
, topstr
, ww1
, hh1
);
2581 e_CharFont_Print(gMenuFont
, (gScreenWidth
div 2)-(ww1
div 2), 16, topstr
);
2583 if g_Game_IsNet
then
2585 topstr
:= Format(_lc
[I_MENU_INTER_NOTICE_TIME
], [gServInterTime
]);
2586 if not gChatShow
then
2587 e_TextureFontPrintEx((gScreenWidth
div 2)-(Length(topstr
)*ww2
div 2),
2588 gScreenHeight
-(hh2
+4)*2, topstr
, gStdFont
, 255, 255, 255, 1);
2591 if g_Game_IsClient
then
2592 topstr
:= _lc
[I_MENU_INTER_NOTICE_MAP
]
2594 topstr
:= _lc
[I_MENU_INTER_NOTICE_SPACE
];
2595 if not gChatShow
then
2596 e_TextureFontPrintEx((gScreenWidth
div 2)-(Length(topstr
)*ww2
div 2),
2597 gScreenHeight
-(hh2
+4), topstr
, gStdFont
, 255, 255, 255, 1);
2602 w
:= gScreenWidth
-x
*2;
2608 e_DrawFillQuad(x
, y
, gScreenWidth
-x
-1, gScreenHeight
-y
-1, 64, 64, 64, 32);
2609 e_DrawQuad(x
, y
, gScreenWidth
-x
-1, gScreenHeight
-y
-1, 255, 127, 0);
2611 m
:= Max(Length(_lc
[I_MENU_MAP
])+1, Length(_lc
[I_GAME_GAME_TIME
])+1)*ww2
;
2613 case CustomStat
.GameMode
of
2616 if gGameSettings
.MaxLives
= 0 then
2617 s1
:= _lc
[I_GAME_DM
]
2619 s1
:= _lc
[I_GAME_LMS
];
2623 if gGameSettings
.MaxLives
= 0 then
2624 s1
:= _lc
[I_GAME_TDM
]
2626 s1
:= _lc
[I_GAME_TLMS
];
2628 GM_CTF
: s1
:= _lc
[I_GAME_CTF
];
2631 if gGameSettings
.MaxLives
= 0 then
2632 s1
:= _lc
[I_GAME_COOP
]
2634 s1
:= _lc
[I_GAME_SURV
];
2640 e_TextureFontPrintEx(x
+(w
div 2)-(Length(s1
)*ww2
div 2), _y
, s1
, gStdFont
, 255, 255, 255, 1);
2644 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_MENU_MAP
], gStdFont
, 255, 127, 0, 1);
2645 e_TextureFontPrint(x
+8+m
, _y
, Format('%s - %s', [CustomStat
.Map
, CustomStat
.MapName
]), gStdFont
);
2648 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_GAME_TIME
], gStdFont
, 255, 127, 0, 1);
2649 e_TextureFontPrint(x
+8+m
, _y
, Format('%d:%.2d:%.2d', [CustomStat
.GameTime
div 1000 div 3600,
2650 (CustomStat
.GameTime
div 1000 div 60) mod 60,
2651 CustomStat
.GameTime
div 1000 mod 60]), gStdFont
);
2653 pc
:= Length(CustomStat
.PlayerStat
);
2654 if pc
= 0 then Exit
;
2656 if CustomStat
.GameMode
= GM_COOP
then
2658 m
:= Max(Length(_lc
[I_GAME_MONSTERS
])+1, Length(_lc
[I_GAME_SECRETS
])+1)*ww2
;
2660 s2
:= _lc
[I_GAME_MONSTERS
];
2661 e_TextureFontPrintEx(x
+8, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2662 e_TextureFontPrintEx(x
+8+m
, _y
, IntToStr(gCoopMonstersKilled
) + '/' + IntToStr(gTotalMonsters
), gStdFont
, 255, 255, 255, 1);
2664 s2
:= _lc
[I_GAME_SECRETS
];
2665 e_TextureFontPrintEx(x
+8, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2666 e_TextureFontPrintEx(x
+8+m
, _y
, IntToStr(gCoopSecretsFound
) + '/' + IntToStr(gSecretsCount
), gStdFont
, 255, 255, 255, 1);
2669 m
:= Max(Length(_lc
[I_GAME_MONSTERS_TOTAL
])+1, Length(_lc
[I_GAME_SECRETS_TOTAL
])+1)*ww2
;
2671 s2
:= _lc
[I_GAME_MONSTERS_TOTAL
];
2672 e_TextureFontPrintEx(x
+250, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2673 e_TextureFontPrintEx(x
+250+m
, _y
, IntToStr(gCoopTotalMonstersKilled
) + '/' + IntToStr(gCoopTotalMonsters
), gStdFont
, 255, 255, 255, 1);
2675 s2
:= _lc
[I_GAME_SECRETS_TOTAL
];
2676 e_TextureFontPrintEx(x
+250, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2677 e_TextureFontPrintEx(x
+250+m
, _y
, IntToStr(gCoopTotalSecretsFound
) + '/' + IntToStr(gCoopTotalSecrets
), gStdFont
, 255, 255, 255, 1);
2681 if CustomStat
.GameMode
in [GM_TDM
, GM_CTF
] then
2686 if TeamStat
[TEAM_RED
].Goals
> TeamStat
[TEAM_BLUE
].Goals
then s1
:= _lc
[I_GAME_WIN_RED
]
2687 else if TeamStat
[TEAM_BLUE
].Goals
> TeamStat
[TEAM_RED
].Goals
then s1
:= _lc
[I_GAME_WIN_BLUE
]
2688 else s1
:= _lc
[I_GAME_WIN_DRAW
];
2690 e_TextureFontPrintEx(x
+8+(w
div 2)-(Length(s1
)*ww2
div 2), _y
, s1
, gStdFont
, 255, 255, 255, 1);
2693 for t
:= TEAM_RED
to TEAM_BLUE
do
2695 if t
= TEAM_RED
then
2697 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_TEAM_RED
],
2698 gStdFont
, 255, 0, 0, 1);
2699 e_TextureFontPrintEx(x
+w1
+8, _y
, IntToStr(CustomStat
.TeamStat
[TEAM_RED
].Goals
),
2700 gStdFont
, 255, 0, 0, 1);
2707 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_TEAM_BLUE
],
2708 gStdFont
, 0, 0, 255, 1);
2709 e_TextureFontPrintEx(x
+w1
+8, _y
, IntToStr(CustomStat
.TeamStat
[TEAM_BLUE
].Goals
),
2710 gStdFont
, 0, 0, 255, 1);
2716 e_DrawLine(1, x
+8, _y
+20, x
-8+w
, _y
+20, r
, g
, b
);
2719 for p
:= 0 to High(CustomStat
.PlayerStat
) do
2720 if CustomStat
.PlayerStat
[p
].Team
= t
then
2721 with CustomStat
.PlayerStat
[p
] do
2735 if (gPlayers
[Num
] <> nil) and (gPlayers
[Num
].FReady
) then
2736 e_TextureFontPrintEx(x
+16, _y
, Name
+ ' *', gStdFont
, rr
, gg
, bb
, 1)
2738 e_TextureFontPrintEx(x
+16, _y
, Name
, gStdFont
, rr
, gg
, bb
, 1);
2739 e_TextureFontPrintEx(x
+w1
+16, _y
, IntToStr(Frags
), gStdFont
, rr
, gg
, bb
, 1);
2740 e_TextureFontPrintEx(x
+w1
+w2
+16, _y
, IntToStr(Deaths
), gStdFont
, rr
, gg
, bb
, 1);
2747 else if CustomStat
.GameMode
in [GM_DM
, GM_COOP
] then
2750 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_PLAYER_NAME
], gStdFont
, 255, 127, 0, 1);
2751 e_TextureFontPrintEx(x
+8+w1
, _y
, _lc
[I_GAME_FRAGS
], gStdFont
, 255, 127, 0, 1);
2752 e_TextureFontPrintEx(x
+8+w1
+w2
, _y
, _lc
[I_GAME_DEATHS
], gStdFont
, 255, 127, 0, 1);
2755 for p
:= 0 to High(CustomStat
.PlayerStat
) do
2756 with CustomStat
.PlayerStat
[p
] do
2758 e_DrawFillQuad(x
+8, _y
+4, x
+24-1, _y
+16+4-1, Color
.R
, Color
.G
, Color
.B
, 0);
2765 if (gPlayers
[Num
] <> nil) and (gPlayers
[Num
].FReady
) then
2766 e_TextureFontPrintEx(x
+8+16+8, _y
+4, Name
+ ' *', gStdFont
, r
, r
, r
, 1, True)
2768 e_TextureFontPrintEx(x
+8+16+8, _y
+4, Name
, gStdFont
, r
, r
, r
, 1, True);
2769 e_TextureFontPrintEx(x
+w1
+8+16+8, _y
+4, IntToStr(Frags
), gStdFont
, r
, r
, r
, 1, True);
2770 e_TextureFontPrintEx(x
+w1
+w2
+8+16+8, _y
+4, IntToStr(Deaths
), gStdFont
, r
, r
, r
, 1, True);
2776 procedure DrawSingleStat();
2778 tm
, key_x
, val_x
, y
: Integer;
2782 procedure player_stat(n
: Integer);
2788 s1
:= Format(' %d ', [SingleStat
.PlayerStat
[n
].Kills
]);
2789 s2
:= Format(' %d', [gTotalMonsters
]);
2791 e_CharFont_Print(gMenuFont
, key_x
, y
, _lc
[I_MENU_INTER_KILLS
]);
2792 e_CharFont_PrintEx(gMenuFont
, val_x
, y
, s1
, _RGB(255, 0, 0));
2793 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2794 e_CharFont_Print(gMenuFont
, val_x
+w1
, y
, '/');
2796 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2797 e_CharFont_PrintEx(gMenuFont
, val_x
+w1
, y
, s2
, _RGB(255, 0, 0));
2799 // "Kills-per-minute: ##.#":
2800 s1
:= _lc
[I_MENU_INTER_KPM
];
2802 kpm
:= (SingleStat
.PlayerStat
[n
].Kills
/ tm
) * 60
2804 kpm
:= SingleStat
.PlayerStat
[n
].Kills
;
2805 s2
:= Format(' %.1f', [kpm
]);
2807 e_CharFont_Print(gMenuFont
, key_x
, y
+32, s1
);
2808 e_CharFont_PrintEx(gMenuFont
, val_x
, y
+32, s2
, _RGB(255, 0, 0));
2810 // "Secrets found: # / #":
2811 s1
:= Format(' %d ', [SingleStat
.PlayerStat
[n
].Secrets
]);
2812 s2
:= Format(' %d', [SingleStat
.TotalSecrets
]);
2814 e_CharFont_Print(gMenuFont
, key_x
, y
+64, _lc
[I_MENU_INTER_SECRETS
]);
2815 e_CharFont_PrintEx(gMenuFont
, val_x
, y
+64, s1
, _RGB(255, 0, 0));
2816 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2817 e_CharFont_Print(gMenuFont
, val_x
+w1
, y
+64, '/');
2819 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2820 e_CharFont_PrintEx(gMenuFont
, val_x
+w1
, y
+64, s2
, _RGB(255, 0, 0));
2824 // "Level Complete":
2825 e_CharFont_GetSize(gMenuFont
, _lc
[I_MENU_INTER_LEVEL_COMPLETE
], w1
, h
);
2826 e_CharFont_Print(gMenuFont
, (gScreenWidth
-w1
) div 2, 32, _lc
[I_MENU_INTER_LEVEL_COMPLETE
]);
2828 // Îïðåäåëÿåì êîîðäèíàòû âûðàâíèâàíèÿ ïî ñàìîé äëèííîé ñòðîêå:
2829 s1
:= _lc
[I_MENU_INTER_KPM
];
2830 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2833 e_CharFont_GetSize(gMenuFont
, s1
, w2
, h
);
2835 key_x
:= (gScreenWidth
-w1
-w2
) div 2;
2836 val_x
:= key_x
+ w1
;
2839 tm
:= SingleStat
.GameTime
div 1000;
2840 s1
:= _lc
[I_MENU_INTER_TIME
];
2841 s2
:= Format(' %d:%.2d:%.2d', [tm
div (60*60), (tm
mod (60*60)) div 60, tm
mod 60]);
2843 e_CharFont_Print(gMenuFont
, key_x
, 80, s1
);
2844 e_CharFont_PrintEx(gMenuFont
, val_x
, 80, s2
, _RGB(255, 0, 0));
2846 if SingleStat
.TwoPlayers
then
2849 s1
:= _lc
[I_MENU_PLAYER_1
];
2850 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2851 e_CharFont_Print(gMenuFont
, (gScreenWidth
-w1
) div 2, 128, s1
);
2853 // Ñòàòèñòèêà ïåðâîãî èãðîêà:
2858 s1
:= _lc
[I_MENU_PLAYER_2
];
2859 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2860 e_CharFont_Print(gMenuFont
, (gScreenWidth
-w1
) div 2, 288, s1
);
2862 // Ñòàòèñòèêà âòîðîãî èãðîêà:
2868 // Ñòàòèñòèêà ïåðâîãî èãðîêà:
2874 procedure DrawLoadingStat();
2875 procedure drawRect (x
, y
, w
, h
: Integer);
2877 if (w
< 1) or (h
< 1) then exit
;
2879 glVertex2f(x
+0.375, y
+0.375);
2880 glVertex2f(x
+w
+0.375, y
+0.375);
2881 glVertex2f(x
+w
+0.375, y
+h
+0.375);
2882 glVertex2f(x
+0.375, y
+h
+0.375);
2886 function drawPBar (cur
, total
: Integer; washere
: Boolean): Boolean;
2888 rectW
, rectH
: Integer;
2895 idl
, idr
, idb
, idm
: LongWord;
2899 if (total
< 1) then exit
;
2900 if (cur
< 1) then exit
; // don't blink
2901 if (not washere
) and (cur
>= total
) then exit
; // don't blink
2902 //if (cur < 0) then cur := 0;
2903 //if (cur > total) then cur := total;
2906 if (hasPBarGfx
) then
2908 g_Texture_Get('UI_GFX_PBAR_LEFT', idl
);
2909 g_Texture_GetSize('UI_GFX_PBAR_LEFT', wl
, hl
);
2910 g_Texture_Get('UI_GFX_PBAR_RIGHT', idr
);
2911 g_Texture_GetSize('UI_GFX_PBAR_RIGHT', wr
, hr
);
2912 g_Texture_Get('UI_GFX_PBAR_MIDDLE', idb
);
2913 g_Texture_GetSize('UI_GFX_PBAR_MIDDLE', wb
, hb
);
2914 g_Texture_Get('UI_GFX_PBAR_MARKER', idm
);
2915 g_Texture_GetSize('UI_GFX_PBAR_MARKER', wm
, hm
);
2917 //rectW := gScreenWidth-360;
2918 rectW
:= trunc(624.0*gScreenWidth
/1024.0);
2921 x0
:= (gScreenWidth
-rectW
) div 2;
2922 y0
:= gScreenHeight
-rectH
-64;
2923 if (y0
< 2) then y0
:= 2;
2925 glEnable(GL_SCISSOR_TEST
);
2928 glScissor(x0
, gScreenHeight
-y0
-rectH
, rectW
, rectH
);
2929 e_DrawSize(idl
, x0
, y0
, 0, true, false, wl
, hl
);
2930 e_DrawSize(idr
, x0
+rectW
-wr
, y0
, 0, true, false, wr
, hr
);
2933 glScissor(x0
+wl
, gScreenHeight
-y0
-rectH
, rectW
-wl
-wr
, rectH
);
2935 while (f
< x0
+rectW
) do
2937 e_DrawSize(idb
, f
, y0
, 0, true, false, wb
, hb
);
2942 wdt
:= (rectW
-wl
-wr
)*cur
div total
;
2943 if (wdt
> rectW
-wl
-wr
) then wdt
:= rectW
-wr
-wr
;
2946 my
:= y0
; // don't be so smart, ketmar: +(rectH-wm) div 2;
2947 glScissor(x0
+wl
, gScreenHeight
-my
-rectH
, wdt
, hm
);
2951 e_DrawSize(idm
, f
, y0
, 0, true, false, wm
, hm
);
2957 glScissor(0, 0, gScreenWidth
, gScreenHeight
);
2961 rectW
:= gScreenWidth
-64;
2964 x0
:= (gScreenWidth
-rectW
) div 2;
2965 y0
:= gScreenHeight
-rectH
-64;
2966 if (y0
< 2) then y0
:= 2;
2968 glDisable(GL_BLEND
);
2969 glDisable(GL_TEXTURE_2D
);
2971 //glClearColor(0, 0, 0, 0);
2972 //glClear(GL_COLOR_BUFFER_BIT);
2974 glColor4ub(127, 127, 127, 255);
2975 drawRect(x0
-2, y0
-2, rectW
+4, rectH
+4);
2977 glColor4ub(0, 0, 0, 255);
2978 drawRect(x0
-1, y0
-1, rectW
+2, rectH
+2);
2980 glColor4ub(127, 127, 127, 255);
2981 wdt
:= rectW
*cur
div total
;
2982 if (wdt
> rectW
) then wdt
:= rectW
;
2983 drawRect(x0
, y0
, wdt
, rectH
);
2992 if (Length(LoadingStat
.Msgs
) = 0) then exit
;
2994 e_CharFont_GetSize(gMenuFont
, _lc
[I_MENU_LOADING
], ww
, hh
);
2995 yy
:= (gScreenHeight
div 3);
2996 e_CharFont_Print(gMenuFont
, (gScreenWidth
div 2)-(ww
div 2), yy
-2*hh
, _lc
[I_MENU_LOADING
]);
2997 xx
:= (gScreenWidth
div 3);
3001 for i
:= 0 to NextMsg
-1 do
3003 if (i
= (NextMsg
-1)) and (MaxValue
> 0) then
3004 s
:= Format('%s: %d/%d', [Msgs
[i
], CurValue
, MaxValue
])
3008 e_CharFont_PrintEx(gMenuSmallFont
, xx
, yy
, s
, _RGB(255, 0, 0));
3009 yy
:= yy
+ LOADING_INTERLINE
;
3010 PBarWasHere
:= drawPBar(CurValue
, MaxValue
, PBarWasHere
);
3015 procedure DrawMenuBackground(tex
: AnsiString);
3021 if g_Texture_Get(tex
, ID
) then
3023 e_Clear(GL_COLOR_BUFFER_BIT
, 0, 0, 0);
3024 e_GetTextureSize(ID
, @w
, @h
);
3026 w
:= round(w
* 1.333 * (gScreenHeight
/ h
))
3028 w
:= trunc(w
* (gScreenHeight
/ h
));
3029 e_DrawSize(ID
, (gScreenWidth
- w
) div 2, 0, 0, False, False, w
, gScreenHeight
);
3031 else e_Clear(GL_COLOR_BUFFER_BIT
, 0, 0, 0);
3034 procedure DrawMinimap(p
: TPlayer
; RenderRect
: e_graphics
.TRect
);
3036 a
, aX
, aY
, aX2
, aY2
, Scale
, ScaleSz
: Integer;
3038 function monDraw (mon
: TMonster
): Boolean;
3040 result
:= false; // don't stop
3045 // Ëåâûé âåðõíèé óãîë
3046 aX
:= Obj
.X
div ScaleSz
+ 1;
3047 aY
:= Obj
.Y
div ScaleSz
+ 1;
3049 aX2
:= max(Obj
.Rect
.Width
div ScaleSz
, 1);
3050 aY2
:= max(Obj
.Rect
.Height
div ScaleSz
, 1);
3051 // Ïðàâûé íèæíèé óãîë
3052 aX2
:= aX
+ aX2
- 1;
3053 aY2
:= aY
+ aY2
- 1;
3054 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 255, 0, 0);
3060 if (gMapInfo
.Width
> RenderRect
.Right
- RenderRect
.Left
) or
3061 (gMapInfo
.Height
> RenderRect
.Bottom
- RenderRect
.Top
) then
3064 // Ñêîëüêî ïèêñåëîâ êàðòû â 1 ïèêñåëå ìèíè-êàðòû:
3065 ScaleSz
:= 16 div Scale
;
3066 // Ðàçìåðû ìèíè-êàðòû:
3067 aX
:= max(gMapInfo
.Width
div ScaleSz
, 1);
3068 aY
:= max(gMapInfo
.Height
div ScaleSz
, 1);
3070 e_DrawFillQuad(0, 0, aX
-1, aY
-1, 0, 0, 0, 0);
3072 if gWalls
<> nil then
3075 for a
:= 0 to High(gWalls
) do
3077 if PanelType
<> 0 then
3079 // Ëåâûé âåðõíèé óãîë:
3080 aX
:= X
div ScaleSz
;
3081 aY
:= Y
div ScaleSz
;
3083 aX2
:= max(Width
div ScaleSz
, 1);
3084 aY2
:= max(Height
div ScaleSz
, 1);
3085 // Ïðàâûé íèæíèé óãîë:
3086 aX2
:= aX
+ aX2
- 1;
3087 aY2
:= aY
+ aY2
- 1;
3090 PANEL_WALL
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 208, 208, 208, 0);
3091 PANEL_OPENDOOR
, PANEL_CLOSEDOOR
:
3092 if Enabled
then e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 160, 160, 160, 0);
3096 if gSteps
<> nil then
3099 for a
:= 0 to High(gSteps
) do
3101 if PanelType
<> 0 then
3103 // Ëåâûé âåðõíèé óãîë:
3104 aX
:= X
div ScaleSz
;
3105 aY
:= Y
div ScaleSz
;
3107 aX2
:= max(Width
div ScaleSz
, 1);
3108 aY2
:= max(Height
div ScaleSz
, 1);
3109 // Ïðàâûé íèæíèé óãîë:
3110 aX2
:= aX
+ aX2
- 1;
3111 aY2
:= aY
+ aY2
- 1;
3113 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 128, 128, 128, 0);
3116 if gLifts
<> nil then
3119 for a
:= 0 to High(gLifts
) do
3121 if PanelType
<> 0 then
3123 // Ëåâûé âåðõíèé óãîë:
3124 aX
:= X
div ScaleSz
;
3125 aY
:= Y
div ScaleSz
;
3127 aX2
:= max(Width
div ScaleSz
, 1);
3128 aY2
:= max(Height
div ScaleSz
, 1);
3129 // Ïðàâûé íèæíèé óãîë:
3130 aX2
:= aX
+ aX2
- 1;
3131 aY2
:= aY
+ aY2
- 1;
3134 LIFTTYPE_UP
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 116, 72, 36, 0);
3135 LIFTTYPE_DOWN
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 116, 124, 96, 0);
3136 LIFTTYPE_LEFT
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 200, 80, 4, 0);
3137 LIFTTYPE_RIGHT
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 252, 140, 56, 0);
3141 if gWater
<> nil then
3144 for a
:= 0 to High(gWater
) do
3146 if PanelType
<> 0 then
3148 // Ëåâûé âåðõíèé óãîë:
3149 aX
:= X
div ScaleSz
;
3150 aY
:= Y
div ScaleSz
;
3152 aX2
:= max(Width
div ScaleSz
, 1);
3153 aY2
:= max(Height
div ScaleSz
, 1);
3154 // Ïðàâûé íèæíèé óãîë:
3155 aX2
:= aX
+ aX2
- 1;
3156 aY2
:= aY
+ aY2
- 1;
3158 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 0, 192, 0);
3161 if gAcid1
<> nil then
3163 // Ðèñóåì êèñëîòó 1:
3164 for a
:= 0 to High(gAcid1
) do
3166 if PanelType
<> 0 then
3168 // Ëåâûé âåðõíèé óãîë:
3169 aX
:= X
div ScaleSz
;
3170 aY
:= Y
div ScaleSz
;
3172 aX2
:= max(Width
div ScaleSz
, 1);
3173 aY2
:= max(Height
div ScaleSz
, 1);
3174 // Ïðàâûé íèæíèé óãîë:
3175 aX2
:= aX
+ aX2
- 1;
3176 aY2
:= aY
+ aY2
- 1;
3178 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 176, 0, 0);
3181 if gAcid2
<> nil then
3183 // Ðèñóåì êèñëîòó 2:
3184 for a
:= 0 to High(gAcid2
) do
3186 if PanelType
<> 0 then
3188 // Ëåâûé âåðõíèé óãîë:
3189 aX
:= X
div ScaleSz
;
3190 aY
:= Y
div ScaleSz
;
3192 aX2
:= max(Width
div ScaleSz
, 1);
3193 aY2
:= max(Height
div ScaleSz
, 1);
3194 // Ïðàâûé íèæíèé óãîë:
3195 aX2
:= aX
+ aX2
- 1;
3196 aY2
:= aY
+ aY2
- 1;
3198 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 176, 0, 0, 0);
3201 if gPlayers
<> nil then
3204 for a
:= 0 to High(gPlayers
) do
3205 if gPlayers
[a
] <> nil then with gPlayers
[a
] do
3207 // Ëåâûé âåðõíèé óãîë:
3208 aX
:= Obj
.X
div ScaleSz
+ 1;
3209 aY
:= Obj
.Y
div ScaleSz
+ 1;
3211 aX2
:= max(Obj
.Rect
.Width
div ScaleSz
, 1);
3212 aY2
:= max(Obj
.Rect
.Height
div ScaleSz
, 1);
3213 // Ïðàâûé íèæíèé óãîë:
3214 aX2
:= aX
+ aX2
- 1;
3215 aY2
:= aY
+ aY2
- 1;
3217 if gPlayers
[a
] = p
then
3218 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 255, 0, 0)
3221 TEAM_RED
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 0, 0, 0);
3222 TEAM_BLUE
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 0, 255, 0);
3223 else e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 128, 0, 0);
3228 g_Mons_ForEach(monDraw
);
3233 procedure renderAmbientQuad (hasAmbient
: Boolean; constref ambColor
: TDFColor
);
3235 if not hasAmbient
then exit
;
3236 e_AmbientQuad(sX
, sY
, sWidth
, sHeight
, ambColor
.r
, ambColor
.g
, ambColor
.b
, ambColor
.a
);
3240 // setup sX, sY, sWidth, sHeight, and transformation matrix before calling this!
3241 //FIXME: broken for splitscreen mode
3242 procedure renderDynLightsInternal ();
3244 //hasAmbient: Boolean;
3245 //ambColor: TDFColor;
3247 lx
, ly
, lrad
: Integer;
3248 scxywh
: array[0..3] of GLint
;
3251 if e_NoGraphics
then exit
;
3253 //TODO: lights should be in separate grid, i think
3254 // but on the other side: grid may be slower for dynlights, as their lifetime is short
3255 if (not gwin_k8_enable_light_experiments
) or (not gwin_has_stencil
) or (g_dynLightCount
< 1) then exit
;
3258 //ambColor := gCurrentMap['light_ambient'].rgba;
3259 //hasAmbient := (not ambColor.isOpaque) or (not ambColor.isBlack);
3261 { // this will multiply incoming color to alpha from framebuffer
3263 glBlendFunc(GL_DST_ALPHA, GL_ONE);
3267 * light rendering: (INVALID!)
3268 * glStencilFunc(GL_EQUAL, 0, $ff);
3270 * glClear(GL_STENCIL_BUFFER_BIT);
3271 * glStencilOp(GL_KEEP, GL_KEEP, GL_INCR);
3272 * draw shadow volume into stencil buffer
3273 * glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); // modify color buffer
3274 * glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); // don't modify stencil buffer
3276 * draw color-less quad with light alpha (WARNING! don't touch color!)
3277 * glEnable(GL_BLEND);
3278 * glBlendFunc(GL_DST_ALPHA, GL_ONE);
3279 * draw all geometry up to and including walls (with alpha-testing, probably) -- this does lighting
3281 wassc
:= (glIsEnabled(GL_SCISSOR_TEST
) <> 0);
3282 if wassc
then glGetIntegerv(GL_SCISSOR_BOX
, @scxywh
[0]) else glGetIntegerv(GL_VIEWPORT
, @scxywh
[0]);
3284 // setup OpenGL parameters
3285 glStencilMask($FFFFFFFF);
3286 glStencilFunc(GL_ALWAYS
, 0, $FFFFFFFF);
3287 glEnable(GL_STENCIL_TEST
);
3288 glEnable(GL_SCISSOR_TEST
);
3289 glClear(GL_STENCIL_BUFFER_BIT
);
3290 glStencilFunc(GL_EQUAL
, 0, $ff);
3292 for lln
:= 0 to g_dynLightCount
-1 do
3294 lx
:= g_dynLights
[lln
].x
;
3295 ly
:= g_dynLights
[lln
].y
;
3296 lrad
:= g_dynLights
[lln
].radius
;
3297 if (lrad
< 3) then continue
;
3299 if (lx
-sX
+lrad
< 0) then continue
;
3300 if (ly
-sY
+lrad
< 0) then continue
;
3301 if (lx
-sX
-lrad
>= gPlayerScreenSize
.X
) then continue
;
3302 if (ly
-sY
-lrad
>= gPlayerScreenSize
.Y
) then continue
;
3304 // set scissor to optimize drawing
3305 if (g_dbg_scale
= 1.0) then
3307 glScissor((lx
-sX
)-lrad
+2, gPlayerScreenSize
.Y
-(ly
-sY
)-lrad
-1+2, lrad
*2-4, lrad
*2-4);
3311 glScissor(0, 0, gWinSizeX
, gWinSizeY
);
3313 // no need to clear stencil buffer, light blitting will do it for us... but only for normal scale
3314 if (g_dbg_scale
<> 1.0) then glClear(GL_STENCIL_BUFFER_BIT
);
3315 glStencilOp(GL_KEEP
, GL_KEEP
, GL_INCR
);
3316 // draw extruded panels
3317 glDisable(GL_TEXTURE_2D
);
3318 glDisable(GL_BLEND
);
3319 glColorMask(GL_FALSE
, GL_FALSE
, GL_FALSE
, GL_FALSE
); // no need to modify color buffer
3320 if (lrad
> 4) then g_Map_DrawPanelShadowVolumes(lx
, ly
, lrad
);
3321 // render light texture
3322 glColorMask(GL_TRUE
, GL_TRUE
, GL_TRUE
, GL_TRUE
); // modify color buffer
3323 glStencilOp(GL_ZERO
, GL_ZERO
, GL_ZERO
); // draw light, and clear stencil buffer
3326 glBlendFunc(GL_SRC_ALPHA
, GL_ONE_MINUS_SRC_ALPHA
);
3327 glEnable(GL_TEXTURE_2D
);
3328 // color and opacity
3329 glColor4f(g_dynLights
[lln
].r
, g_dynLights
[lln
].g
, g_dynLights
[lln
].b
, g_dynLights
[lln
].a
);
3330 glBindTexture(GL_TEXTURE_2D
, g_Texture_Light());
3332 glTexCoord2f(0.0, 0.0); glVertex2i(lx
-lrad
, ly
-lrad
); // top-left
3333 glTexCoord2f(1.0, 0.0); glVertex2i(lx
+lrad
, ly
-lrad
); // top-right
3334 glTexCoord2f(1.0, 1.0); glVertex2i(lx
+lrad
, ly
+lrad
); // bottom-right
3335 glTexCoord2f(0.0, 1.0); glVertex2i(lx
-lrad
, ly
+lrad
); // bottom-left
3340 glDisable(GL_STENCIL_TEST
);
3341 glDisable(GL_BLEND
);
3342 glDisable(GL_SCISSOR_TEST
);
3343 //glScissor(0, 0, sWidth, sHeight);
3345 glScissor(scxywh
[0], scxywh
[1], scxywh
[2], scxywh
[3]);
3346 if wassc
then glEnable(GL_SCISSOR_TEST
) else glDisable(GL_SCISSOR_TEST
);
3350 function fixViewportForScale (): Boolean;
3352 nx0
, ny0
, nw
, nh
: Integer;
3355 if (g_dbg_scale
<> 1.0) then
3358 nx0
:= round(sX
-(gPlayerScreenSize
.X
-(sWidth
*g_dbg_scale
))/2/g_dbg_scale
);
3359 ny0
:= round(sY
-(gPlayerScreenSize
.Y
-(sHeight
*g_dbg_scale
))/2/g_dbg_scale
);
3360 nw
:= round(sWidth
/g_dbg_scale
);
3361 nh
:= round(sHeight
/g_dbg_scale
);
3370 // setup sX, sY, sWidth, sHeight, and transformation matrix before calling this!
3371 // WARNING! this WILL CALL `glTranslatef()`, but won't restore matrices!
3372 procedure renderMapInternal (backXOfs
, backYOfs
: Integer; setTransMatrix
: Boolean);
3374 TDrawCB
= procedure ();
3377 hasAmbient
: Boolean;
3379 doAmbient
: Boolean = false;
3381 procedure drawPanelType (profname
: AnsiString; panType
: DWord
; doDraw
: Boolean);
3386 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin(profname
);
3387 if gdbg_map_use_accel_render
then
3389 tagmask
:= panelTypeToTag(panType
);
3390 while (gDrawPanelList
.count
> 0) do
3392 pan
:= TPanel(gDrawPanelList
.front());
3393 if ((pan
.tag
and tagmask
) = 0) then break
;
3394 if doDraw
then pan
.Draw(doAmbient
, ambColor
);
3395 gDrawPanelList
.popFront();
3400 if doDraw
then g_Map_DrawPanels(panType
, hasAmbient
, ambColor
);
3402 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
3405 procedure drawOther (profname
: AnsiString; cb
: TDrawCB
);
3407 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin(profname
);
3408 if assigned(cb
) then cb();
3409 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
3413 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin('total');
3415 // our accelerated renderer will collect all panels to gDrawPanelList
3416 // we can use panel tag to render level parts (see GridTagXXX in g_map.pas)
3417 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin('collect');
3418 if gdbg_map_use_accel_render
then
3420 g_Map_CollectDrawPanels(sX
, sY
, sWidth
, sHeight
);
3422 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
3424 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin('skyback');
3425 g_Map_DrawBack(backXOfs
, backYOfs
);
3426 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
3428 if setTransMatrix
then
3430 //if (g_dbg_scale <> 1.0) then glTranslatef(0.0, -0.375/2, 0);
3431 glScalef(g_dbg_scale
, g_dbg_scale
, 1.0);
3432 glTranslatef(-sX
, -sY
, 0);
3436 ambColor
:= gCurrentMap
['light_ambient'].rgba
;
3437 hasAmbient
:= (not ambColor
.isOpaque
) or (not ambColor
.isBlack
);
3442 //writeln('color: (', ambColor.r, ',', ambColor.g, ',', ambColor.b, ',', ambColor.a, ')');
3443 glColor4ub(ambColor.r, ambColor.g, ambColor.b, ambColor.a);
3444 glClear(GL_COLOR_BUFFER_BIT);
3447 //writeln('color: (', ambColor.r, ',', ambColor.g, ',', ambColor.b, ',', ambColor.a, ')');
3450 drawPanelType('*back', PANEL_BACK
, g_rlayer_back
);
3451 drawPanelType('*step', PANEL_STEP
, g_rlayer_step
);
3452 drawOther('items', @g_Items_Draw
);
3453 drawOther('weapons', @g_Weapon_Draw
);
3454 drawOther('shells', @g_Player_DrawShells
);
3455 drawOther('drawall', @g_Player_DrawAll
);
3456 drawOther('corpses', @g_Player_DrawCorpses
);
3457 drawPanelType('*wall', PANEL_WALL
, g_rlayer_wall
);
3458 drawOther('monsters', @g_Monsters_Draw
);
3459 drawOther('itemdrop', @g_Items_DrawDrop
);
3460 drawPanelType('*door', PANEL_CLOSEDOOR
, g_rlayer_door
);
3461 drawOther('gfx', @g_GFX_Draw
);
3462 drawOther('flags', @g_Map_DrawFlags
);
3463 drawPanelType('*acid1', PANEL_ACID1
, g_rlayer_acid1
);
3464 drawPanelType('*acid2', PANEL_ACID2
, g_rlayer_acid2
);
3465 drawPanelType('*water', PANEL_WATER
, g_rlayer_water
);
3466 drawOther('dynlights', @renderDynLightsInternal
);
3468 if hasAmbient
{and ((not g_playerLight) or (not gwin_has_stencil) or (g_dynLightCount < 1))} then
3470 renderAmbientQuad(hasAmbient
, ambColor
);
3474 drawPanelType('*fore', PANEL_FORE
, g_rlayer_fore
);
3477 if g_debug_HealthBar
then
3479 g_Monsters_DrawHealth();
3480 g_Player_DrawHealth();
3483 if (profileFrameDraw
<> nil) then profileFrameDraw
.mainEnd(); // map rendering
3487 procedure DrawMapView(x
, y
, w
, h
: Integer);
3494 bx
:= Round(x
/(gMapInfo
.Width
- w
)*(gBackSize
.X
- w
));
3495 by
:= Round(y
/(gMapInfo
.Height
- h
)*(gBackSize
.Y
- h
));
3502 fixViewportForScale();
3503 renderMapInternal(-bx
, -by
, true);
3509 procedure DrawPlayer(p
: TPlayer
);
3511 px
, py
, a
, b
, c
, d
: Integer;
3514 if (p
= nil) or (p
.FDummy
) then
3517 g_Map_DrawBack(0, 0);
3522 if (profileFrameDraw
= nil) then profileFrameDraw
:= TProfiler
.Create('RENDER', g_profile_history_size
);
3523 if (profileFrameDraw
<> nil) then profileFrameDraw
.mainBegin(g_profile_frame_draw
);
3529 px
:= p
.GameX
+ PLAYER_RECT_CX
;
3530 py
:= p
.GameY
+ PLAYER_RECT_CY
+p
.Obj
.slopeUpLeft
;
3532 if (g_dbg_scale
= 1.0) and (not g_dbg_ignore_bounds
) then
3534 if (px
> (gPlayerScreenSize
.X
div 2)) then a
:= -px
+(gPlayerScreenSize
.X
div 2) else a
:= 0;
3535 if (py
> (gPlayerScreenSize
.Y
div 2)) then b
:= -py
+(gPlayerScreenSize
.Y
div 2) else b
:= 0;
3537 if (px
> gMapInfo
.Width
-(gPlayerScreenSize
.X
div 2)) then a
:= -gMapInfo
.Width
+gPlayerScreenSize
.X
;
3538 if (py
> gMapInfo
.Height
-(gPlayerScreenSize
.Y
div 2)) then b
:= -gMapInfo
.Height
+gPlayerScreenSize
.Y
;
3540 if (gMapInfo
.Width
= gPlayerScreenSize
.X
) then a
:= 0
3541 else if (gMapInfo
.Width
< gPlayerScreenSize
.X
) then
3544 a
:= (gPlayerScreenSize
.X
-gMapInfo
.Width
) div 2;
3547 if (gMapInfo
.Height
= gPlayerScreenSize
.Y
) then b
:= 0
3548 else if (gMapInfo
.Height
< gPlayerScreenSize
.Y
) then
3551 b
:= (gPlayerScreenSize
.Y
-gMapInfo
.Height
) div 2;
3556 // scaled, ignore level bounds
3557 a
:= -px
+(gPlayerScreenSize
.X
div 2);
3558 b
:= -py
+(gPlayerScreenSize
.Y
div 2);
3561 if p
.IncCam
<> 0 then
3563 if py
> gMapInfo
.Height
-(gPlayerScreenSize
.Y
div 2) then
3565 if p
.IncCam
> 120-(py
-(gMapInfo
.Height
-(gPlayerScreenSize
.Y
div 2))) then
3567 p
.IncCam
:= 120-(py
-(gMapInfo
.Height
-(gPlayerScreenSize
.Y
div 2)));
3571 if py
< gPlayerScreenSize
.Y
div 2 then
3573 if p
.IncCam
< -120+((gPlayerScreenSize
.Y
div 2)-py
) then
3575 p
.IncCam
:= -120+((gPlayerScreenSize
.Y
div 2)-py
);
3579 if p
.IncCam
< 0 then
3581 while (py
+(gPlayerScreenSize
.Y
div 2)-p
.IncCam
> gMapInfo
.Height
) and (p
.IncCam
< 0) do p
.IncCam
:= p
.IncCam
+1; //Inc(p.IncCam);
3584 if p
.IncCam
> 0 then
3586 while (py
-(gPlayerScreenSize
.Y
div 2)-p
.IncCam
< 0) and (p
.IncCam
> 0) do p
.IncCam
:= p
.IncCam
-1; //Dec(p.IncCam);
3590 if (px
< gPlayerScreenSize
.X
div 2) or (gMapInfo
.Width
-gPlayerScreenSize
.X
<= 256) then c
:= 0
3591 else if (px
> gMapInfo
.Width
-(gPlayerScreenSize
.X
div 2)) then c
:= gBackSize
.X
-gPlayerScreenSize
.X
3592 else c
:= round((px
-(gPlayerScreenSize
.X
div 2))/(gMapInfo
.Width
-gPlayerScreenSize
.X
)*(gBackSize
.X
-gPlayerScreenSize
.X
));
3594 if (py
-p
.IncCam
<= gPlayerScreenSize
.Y
div 2) or (gMapInfo
.Height
-gPlayerScreenSize
.Y
<= 256) then d
:= 0
3595 else if (py
-p
.IncCam
>= gMapInfo
.Height
-(gPlayerScreenSize
.Y
div 2)) then d
:= gBackSize
.Y
-gPlayerScreenSize
.Y
3596 else d
:= round((py
-p
.IncCam
-(gPlayerScreenSize
.Y
div 2))/(gMapInfo
.Height
-gPlayerScreenSize
.Y
)*(gBackSize
.Y
-gPlayerScreenSize
.Y
));
3599 sY
:= -(b
+p
.IncCam
);
3600 sWidth
:= gPlayerScreenSize
.X
;
3601 sHeight
:= gPlayerScreenSize
.Y
;
3603 //glTranslatef(a, b+p.IncCam, 0);
3605 //if (p = gPlayer1) and (g_dbg_scale >= 1.0) then g_Holmes_plrViewSize(sWidth, sHeight);
3607 //conwritefln('OLD: (%s,%s)-(%s,%s)', [sX, sY, sWidth, sHeight]);
3608 fixViewportForScale();
3609 //conwritefln(' (%s,%s)-(%s,%s)', [sX, sY, sWidth, sHeight]);
3611 if (g_dbg_scale
<> 1.0) and (not g_dbg_ignore_bounds
) then
3613 if (sX
+sWidth
> gMapInfo
.Width
) then sX
:= gMapInfo
.Width
-sWidth
;
3614 if (sY
+sHeight
> gMapInfo
.Height
) then sY
:= gMapInfo
.Height
-sHeight
;
3615 if (sX
< 0) then sX
:= 0;
3616 if (sY
< 0) then sY
:= 0;
3618 if (gBackSize
.X
<= gPlayerScreenSize
.X
) or (gMapInfo
.Width
<= sWidth
) then c
:= 0 else c
:= trunc((gBackSize
.X
-gPlayerScreenSize
.X
)*sX
/(gMapInfo
.Width
-sWidth
));
3619 if (gBackSize
.Y
<= gPlayerScreenSize
.Y
) or (gMapInfo
.Height
<= sHeight
) then d
:= 0 else d
:= trunc((gBackSize
.Y
-gPlayerScreenSize
.Y
)*sY
/(gMapInfo
.Height
-sHeight
));
3622 //r_smallmap_h: 0: left; 1: center; 2: right
3623 //r_smallmap_v: 0: top; 1: center; 2: bottom
3625 if (gMapInfo
.Width
= sWidth
) then
3629 else if (gMapInfo
.Width
< sWidth
) then
3631 case r_smallmap_h
of
3632 1: sX
:= -((sWidth
-gMapInfo
.Width
) div 2); // center
3633 2: sX
:= -(sWidth
-gMapInfo
.Width
); // right
3634 else sX
:= 0; // left
3638 if (gMapInfo
.Height
= sHeight
) then
3642 else if (gMapInfo
.Height
< sHeight
) then
3644 case r_smallmap_v
of
3645 1: sY
:= -((sHeight
-gMapInfo
.Height
) div 2); // center
3646 2: sY
:= -(sHeight
-gMapInfo
.Height
); // bottom
3647 else sY
:= 0; // top
3653 p
.viewPortW
:= sWidth
;
3654 p
.viewPortH
:= sHeight
;
3656 {$IFDEF ENABLE_HOLMES}
3657 if (p
= gPlayer1
) then
3659 g_Holmes_plrViewPos(sX
, sY
);
3660 g_Holmes_plrViewSize(sWidth
, sHeight
);
3664 renderMapInternal(-c
, -d
, true);
3666 if (gGameSettings
.GameMode
<> GM_SINGLE
) and gPlayerIndicator
then
3668 if p
.FSpectator
then
3669 e_TextureFontPrintEx(p
.GameX
+ PLAYER_RECT_CX
- 4,
3670 p
.GameY
+ PLAYER_RECT_CY
- 4,
3671 'X', gStdFont
, 255, 255, 255, 1, True);
3673 for a := 0 to High(gCollideMap) do
3674 for b := 0 to High(gCollideMap[a]) do
3677 if ByteBool(gCollideMap[a, b] and MARK_WALL) then
3679 if ByteBool(gCollideMap[a, b] and MARK_DOOR) then
3683 1: e_DrawPoint(1, b, a, 200, 200, 200);
3684 2: e_DrawPoint(1, b, a, 64, 64, 255);
3685 3: e_DrawPoint(1, b, a, 255, 0, 255);
3695 if gShowMap
then DrawMinimap(p
, _TRect(0, 0, 128, 128));
3696 if g_Debug_Player
then
3697 g_Player_DrawDebug(p
);
3701 procedure drawProfilers ();
3706 if g_profile_frame_draw
and (profileFrameDraw
<> nil) then px
:= px
-drawProfiles(px
, py
, profileFrameDraw
);
3707 if g_profile_collision
and (profMapCollision
<> nil) then begin px
:= px
-drawProfiles(px
, py
, profMapCollision
); py
-= calcProfilesHeight(profMonsLOS
); end;
3708 if g_profile_los
and (profMonsLOS
<> nil) then begin px
:= px
-drawProfiles(px
, py
, profMonsLOS
); py
-= calcProfilesHeight(profMonsLOS
); end;
3711 procedure g_Game_Draw();
3718 plView1
, plView2
: TPlayer
;
3721 if gExit
= EXIT_QUIT
then Exit
;
3723 Time
:= GetTimer() {div 1000};
3724 FPSCounter
:= FPSCounter
+1;
3725 if Time
- FPSTime
>= 1000 then
3732 if gGameOn
or (gState
= STATE_FOLD
) then
3734 if (gPlayer1
<> nil) and (gPlayer2
<> nil) then
3736 gSpectMode
:= SPECT_NONE
;
3737 if not gRevertPlayers
then
3739 plView1
:= gPlayer1
;
3740 plView2
:= gPlayer2
;
3744 plView1
:= gPlayer2
;
3745 plView2
:= gPlayer1
;
3749 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
3751 gSpectMode
:= SPECT_NONE
;
3752 if gPlayer2
= nil then
3755 plView1
:= gPlayer2
;
3764 if (plView1
= nil) and (plView2
= nil) and (gSpectMode
= SPECT_NONE
) then
3765 gSpectMode
:= SPECT_STATS
;
3767 if gSpectMode
= SPECT_PLAYERS
then
3768 if gPlayers
<> nil then
3770 plView1
:= GetActivePlayer_ByID(gSpectPID1
);
3771 if plView1
= nil then
3773 gSpectPID1
:= GetActivePlayerID_Next();
3774 plView1
:= GetActivePlayer_ByID(gSpectPID1
);
3776 if gSpectViewTwo
then
3778 plView2
:= GetActivePlayer_ByID(gSpectPID2
);
3779 if plView2
= nil then
3781 gSpectPID2
:= GetActivePlayerID_Next();
3782 plView2
:= GetActivePlayer_ByID(gSpectPID2
);
3787 if gSpectMode
= SPECT_MAPVIEW
then
3789 // Ðåæèì ïðîñìîòðà êàðòû
3791 e_SetViewPort(0, 0, gScreenWidth
, gScreenHeight
);
3792 DrawMapView(gSpectX
, gSpectY
, gScreenWidth
, gScreenHeight
);
3793 gHearPoint1
.Active
:= True;
3794 gHearPoint1
.Coords
.X
:= gScreenWidth
div 2 + gSpectX
;
3795 gHearPoint1
.Coords
.Y
:= gScreenHeight
div 2 + gSpectY
;
3796 gHearPoint2
.Active
:= False;
3800 Split
:= (plView1
<> nil) and (plView2
<> nil);
3802 // Òî÷êè ñëóõà èãðîêîâ
3803 if plView1
<> nil then
3805 gHearPoint1
.Active
:= True;
3806 gHearPoint1
.Coords
.X
:= plView1
.GameX
+ PLAYER_RECT
.Width
;
3807 gHearPoint1
.Coords
.Y
:= plView1
.GameY
+ PLAYER_RECT
.Height
DIV 2;
3809 gHearPoint1
.Active
:= False;
3810 if plView2
<> nil then
3812 gHearPoint2
.Active
:= True;
3813 gHearPoint2
.Coords
.X
:= plView2
.GameX
+ PLAYER_RECT
.Width
;
3814 gHearPoint2
.Coords
.Y
:= plView2
.GameY
+ PLAYER_RECT
.Height
DIV 2;
3816 gHearPoint2
.Active
:= False;
3818 // Ðàçìåð ýêðàíîâ èãðîêîâ:
3819 gPlayerScreenSize
.X
:= gScreenWidth
-196;
3822 gPlayerScreenSize
.Y
:= gScreenHeight
div 2;
3823 if gScreenHeight
mod 2 = 0 then
3824 Dec(gPlayerScreenSize
.Y
);
3827 gPlayerScreenSize
.Y
:= gScreenHeight
;
3830 if gScreenHeight
mod 2 = 0 then
3831 e_SetViewPort(0, gPlayerScreenSize
.Y
+2, gPlayerScreenSize
.X
+196, gPlayerScreenSize
.Y
)
3833 e_SetViewPort(0, gPlayerScreenSize
.Y
+1, gPlayerScreenSize
.X
+196, gPlayerScreenSize
.Y
);
3835 DrawPlayer(plView1
);
3836 gPlayer1ScreenCoord
.X
:= sX
;
3837 gPlayer1ScreenCoord
.Y
:= sY
;
3841 e_SetViewPort(0, 0, gPlayerScreenSize
.X
+196, gPlayerScreenSize
.Y
);
3843 DrawPlayer(plView2
);
3844 gPlayer2ScreenCoord
.X
:= sX
;
3845 gPlayer2ScreenCoord
.Y
:= sY
;
3848 e_SetViewPort(0, 0, gScreenWidth
, gScreenHeight
);
3851 e_DrawLine(2, 0, gScreenHeight
div 2, gScreenWidth
, gScreenHeight
div 2, 0, 0, 0);
3854 {$IFDEF ENABLE_HOLMES}
3856 if (g_holmes_enabled
) then g_Holmes_Draw();
3859 if MessageText
<> '' then
3863 e_CharFont_GetSizeFmt(gMenuFont
, MessageText
, w
, h
);
3865 e_CharFont_PrintFmt(gMenuFont
, (gScreenWidth
div 2)-(w
div 2),
3866 (gScreenHeight
div 2)-(h
div 2), MessageText
)
3868 e_CharFont_PrintFmt(gMenuFont
, (gScreenWidth
div 2)-(w
div 2),
3869 Round(gScreenHeight
/ 2.75)-(h
div 2), MessageText
);
3872 if IsDrawStat
or (gSpectMode
= 1) then DrawStat();
3874 if gSpectHUD
and (not gChatShow
) and (gSpectMode
<> SPECT_NONE
) and (not gSpectAuto
) then
3876 // Draw spectator GUI
3879 e_TextureFontGetSize(gStdFont
, ww
, hh
);
3882 e_TextureFontPrintEx(0, gScreenHeight
- (hh
+2)*2, 'MODE: Stats', gStdFont
, 255, 255, 255, 1);
3884 e_TextureFontPrintEx(0, gScreenHeight
- (hh
+2)*2, 'MODE: Observe Map', gStdFont
, 255, 255, 255, 1);
3886 e_TextureFontPrintEx(0, gScreenHeight
- (hh
+2)*2, 'MODE: Watch Players', gStdFont
, 255, 255, 255, 1);
3888 e_TextureFontPrintEx(2*ww
, gScreenHeight
- (hh
+2), '< jump >', gStdFont
, 255, 255, 255, 1);
3889 if gSpectMode
= SPECT_STATS
then
3891 e_TextureFontPrintEx(16*ww
, gScreenHeight
- (hh
+2)*2, 'Autoview', gStdFont
, 255, 255, 255, 1);
3892 e_TextureFontPrintEx(16*ww
, gScreenHeight
- (hh
+2), '< fire >', gStdFont
, 255, 255, 255, 1);
3894 if gSpectMode
= SPECT_MAPVIEW
then
3896 e_TextureFontPrintEx(22*ww
, gScreenHeight
- (hh
+2)*2, '[-]', gStdFont
, 255, 255, 255, 1);
3897 e_TextureFontPrintEx(26*ww
, gScreenHeight
- (hh
+2)*2, 'Step ' + IntToStr(gSpectStep
), gStdFont
, 255, 255, 255, 1);
3898 e_TextureFontPrintEx(34*ww
, gScreenHeight
- (hh
+2)*2, '[+]', gStdFont
, 255, 255, 255, 1);
3899 e_TextureFontPrintEx(18*ww
, gScreenHeight
- (hh
+2), '<prev weap>', gStdFont
, 255, 255, 255, 1);
3900 e_TextureFontPrintEx(30*ww
, gScreenHeight
- (hh
+2), '<next weap>', gStdFont
, 255, 255, 255, 1);
3902 if gSpectMode
= SPECT_PLAYERS
then
3904 e_TextureFontPrintEx(22*ww
, gScreenHeight
- (hh
+2)*2, 'Player 1', gStdFont
, 255, 255, 255, 1);
3905 e_TextureFontPrintEx(20*ww
, gScreenHeight
- (hh
+2), '<left/right>', gStdFont
, 255, 255, 255, 1);
3906 if gSpectViewTwo
then
3908 e_TextureFontPrintEx(37*ww
, gScreenHeight
- (hh
+2)*2, 'Player 2', gStdFont
, 255, 255, 255, 1);
3909 e_TextureFontPrintEx(34*ww
, gScreenHeight
- (hh
+2), '<prev w/next w>', gStdFont
, 255, 255, 255, 1);
3910 e_TextureFontPrintEx(52*ww
, gScreenHeight
- (hh
+2)*2, '2x View', gStdFont
, 255, 255, 255, 1);
3911 e_TextureFontPrintEx(51*ww
, gScreenHeight
- (hh
+2), '<up/down>', gStdFont
, 255, 255, 255, 1);
3915 e_TextureFontPrintEx(35*ww
, gScreenHeight
- (hh
+2)*2, '2x View', gStdFont
, 255, 255, 255, 1);
3916 e_TextureFontPrintEx(34*ww
, gScreenHeight
- (hh
+2), '<up/down>', gStdFont
, 255, 255, 255, 1);
3922 if gPauseMain
and gGameOn
and (g_ActiveWindow
= nil) then
3924 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
3925 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
3927 e_CharFont_GetSize(gMenuFont
, _lc
[I_MENU_PAUSE
], w
, h
);
3928 e_CharFont_Print(gMenuFont
, (gScreenWidth
div 2)-(w
div 2),
3929 (gScreenHeight
div 2)-(h
div 2), _lc
[I_MENU_PAUSE
]);
3934 if (gState
= STATE_MENU
) then
3936 if (g_ActiveWindow
= nil) or (g_ActiveWindow
.BackTexture
= '') then DrawMenuBackground('MENU_BACKGROUND');
3937 // F3 at menu will show game loading dialog
3938 if e_KeyPressed(IK_F3
) then g_Menu_Show_LoadMenu(true);
3939 if (g_ActiveWindow
<> nil) then
3941 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
3942 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
3946 // F3 at titlepic will show game loading dialog
3947 if e_KeyPressed(IK_F3
) then
3949 g_Menu_Show_LoadMenu(true);
3950 if (g_ActiveWindow
<> nil) then e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
3955 if gState
= STATE_FOLD
then
3957 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 0, 0, 0, EndingGameCounter
);
3960 if gState
= STATE_INTERCUSTOM
then
3962 if gLastMap
and (gGameSettings
.GameMode
= GM_COOP
) then
3964 back
:= 'TEXTURE_endpic';
3965 if not g_Texture_Get(back
, ID
) then
3966 back
:= _lc
[I_TEXTURE_ENDPIC
];
3971 DrawMenuBackground(back
);
3975 if g_ActiveWindow
<> nil then
3977 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
3978 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
3982 if gState
= STATE_INTERSINGLE
then
3984 if EndingGameCounter
> 0 then
3986 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 0, 0, 0, EndingGameCounter
);
3992 DrawMenuBackground(back
);
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);
4004 if gState
= STATE_ENDPIC
then
4007 if g_Texture_Get('TEXTURE_endpic', ID
) then DrawMenuBackground('TEXTURE_endpic')
4008 else DrawMenuBackground(_lc
[I_TEXTURE_ENDPIC
]);
4010 if g_ActiveWindow
<> nil then
4012 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4013 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4017 if gState
= STATE_SLIST
then
4019 // if g_Texture_Get('MENU_BACKGROUND', ID) then
4021 // e_DrawSize(ID, 0, 0, 0, False, False, gScreenWidth, gScreenHeight);
4022 // //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4024 DrawMenuBackground('MENU_BACKGROUND');
4025 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4026 g_Serverlist_Draw(slCurrent
, slTable
);
4030 if g_ActiveWindow
<> nil then
4034 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4035 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4037 g_ActiveWindow
.Draw();
4042 if g_debug_Sounds
and gGameOn
then
4044 for w
:= 0 to High(e_SoundsArray
) do
4045 for h
:= 0 to e_SoundsArray
[w
].nRefs
do
4046 e_DrawPoint(1, w
+100, h
+100, 255, 0, 0);
4051 e_TextureFontPrint(0, 0, Format('FPS: %d', [FPS
]), gStdFont
);
4052 e_TextureFontPrint(0, 16, Format('UPS: %d', [UPS
]), gStdFont
);
4055 if gGameOn
and gShowTime
then
4056 drawTime(gScreenWidth
-72, gScreenHeight
-16);
4058 if gGameOn
then drawProfilers();
4060 {$IFDEF ENABLE_HOLMES}
4067 procedure g_Game_Quit();
4069 g_Game_StopAllSounds(True);
4071 g_Game_SaveOptions();
4073 g_PlayerModel_FreeData();
4074 g_Texture_DeleteAll();
4075 g_Frames_DeleteAll();
4076 //g_Menu_Free(); //k8: this segfaults after resolution change; who cares?
4078 if NetInitDone
then g_Net_Free
;
4080 // Íàäî óäàëèòü êàðòó ïîñëå òåñòà:
4081 if gMapToDelete
<> '' then
4082 g_Game_DeleteTestMap();
4088 procedure g_FatalError(Text: String);
4090 g_Console_Add(Format(_lc
[I_FATAL_ERROR
], [Text]), True);
4091 e_WriteLog(Format(_lc
[I_FATAL_ERROR
], [Text]), TMsgType
.Warning
);
4093 gExit
:= EXIT_SIMPLE
;
4096 procedure g_SimpleError(Text: String);
4098 g_Console_Add(Format(_lc
[I_SIMPLE_ERROR
], [Text]), True);
4099 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], [Text]), TMsgType
.Warning
);
4102 procedure g_Game_SetupScreenSize();
4104 RES_FACTOR
= 4.0 / 3.0;
4110 // Ðàçìåð ýêðàíîâ èãðîêîâ:
4111 gPlayerScreenSize
.X
:= gScreenWidth
-196;
4112 if (gPlayer1
<> nil) and (gPlayer2
<> nil) then
4113 gPlayerScreenSize
.Y
:= gScreenHeight
div 2
4115 gPlayerScreenSize
.Y
:= gScreenHeight
;
4117 // Ðàçìåð çàäíåãî ïëàíà:
4118 if BackID
<> DWORD(-1) then
4121 if (gScreenWidth
*s
> gMapInfo
.Width
) or
4122 (gScreenHeight
*s
> gMapInfo
.Height
) then
4124 gBackSize
.X
:= gScreenWidth
;
4125 gBackSize
.Y
:= gScreenHeight
;
4129 e_GetTextureSize(BackID
, @bw
, @bh
);
4130 rf
:= Single(bw
) / Single(bh
);
4131 if (rf
> RES_FACTOR
) then bw
:= Round(Single(bh
) * RES_FACTOR
)
4132 else if (rf
< RES_FACTOR
) then bh
:= Round(Single(bw
) / RES_FACTOR
);
4133 s
:= Max(gScreenWidth
/ bw
, gScreenHeight
/ bh
);
4134 if (s
< 1.0) then s
:= 1.0;
4135 gBackSize
.X
:= Round(bw
*s
);
4136 gBackSize
.Y
:= Round(bh
*s
);
4141 procedure g_Game_ChangeResolution(newWidth
, newHeight
: Word; nowFull
, nowMax
: Boolean);
4143 g_Window_SetSize(newWidth
, newHeight
, nowFull
);
4146 procedure g_Game_AddPlayer(Team
: Byte = TEAM_NONE
);
4148 if ((not gGameOn
) and (gState
<> STATE_INTERCUSTOM
))
4149 or (not (gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
])) then
4151 if gPlayer1
= nil then
4153 if g_Game_IsClient
then
4155 if NetPlrUID1
> -1 then
4157 MC_SEND_CheatRequest(NET_CHEAT_SPECTATE
);
4158 gPlayer1
:= g_Player_Get(NetPlrUID1
);
4163 if not (Team
in [TEAM_RED
, TEAM_BLUE
]) then
4164 Team
:= gPlayer1Settings
.Team
;
4166 // Ñîçäàíèå ïåðâîãî èãðîêà:
4167 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4168 gPlayer1Settings
.Color
,
4170 if gPlayer1
= nil then
4171 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]))
4174 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4175 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [gPlayer1
.Name
]), True);
4176 if g_Game_IsServer
and g_Game_IsNet
then
4177 MH_SEND_PlayerCreate(gPlayer1
.UID
);
4178 gPlayer1
.Respawn(False, True);
4180 if g_Game_IsNet
and NetUseMaster
then
4186 if gPlayer2
= nil then
4188 if g_Game_IsClient
then
4190 if NetPlrUID2
> -1 then
4191 gPlayer2
:= g_Player_Get(NetPlrUID2
);
4195 if not (Team
in [TEAM_RED
, TEAM_BLUE
]) then
4196 Team
:= gPlayer2Settings
.Team
;
4198 // Ñîçäàíèå âòîðîãî èãðîêà:
4199 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
4200 gPlayer2Settings
.Color
,
4202 if gPlayer2
= nil then
4203 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]))
4206 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
4207 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [gPlayer2
.Name
]), True);
4208 if g_Game_IsServer
and g_Game_IsNet
then
4209 MH_SEND_PlayerCreate(gPlayer2
.UID
);
4210 gPlayer2
.Respawn(False, True);
4212 if g_Game_IsNet
and NetUseMaster
then
4220 procedure g_Game_RemovePlayer();
4224 if ((not gGameOn
) and (gState
<> STATE_INTERCUSTOM
))
4225 or (not (gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
])) then
4230 if g_Game_IsServer
then
4233 Pl
.Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
4234 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [Pl
.Name
]), True);
4235 g_Player_Remove(Pl
.UID
);
4237 if g_Game_IsNet
and NetUseMaster
then
4246 if g_Game_IsServer
then
4249 Pl
.Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
4250 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [Pl
.Name
]), True);
4251 g_Player_Remove(Pl
.UID
);
4253 if g_Game_IsNet
and NetUseMaster
then
4258 MC_SEND_CheatRequest(NET_CHEAT_SPECTATE
);
4264 procedure g_Game_Spectate();
4266 g_Game_RemovePlayer();
4267 if gPlayer1
<> nil then
4268 g_Game_RemovePlayer();
4271 procedure g_Game_SpectateCenterView();
4273 gSpectX
:= Max(gMapInfo
.Width
div 2 - gScreenWidth
div 2, 0);
4274 gSpectY
:= Max(gMapInfo
.Height
div 2 - gScreenHeight
div 2, 0);
4277 procedure g_Game_StartSingle(Map
: String; TwoPlayers
: Boolean; nPlayers
: Byte);
4284 e_WriteLog('Starting singleplayer game...', TMsgType
.Notify
);
4286 g_Game_ClearLoading();
4289 FillByte(gGameSettings
, SizeOf(TGameSettings
), 0);
4292 gGameSettings
.GameType
:= GT_SINGLE
;
4293 gGameSettings
.MaxLives
:= 0;
4294 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_ALLOWEXIT
;
4295 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_MONSTERS
;
4296 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_BOTVSMONSTER
;
4297 gSwitchGameMode
:= GM_SINGLE
;
4299 g_Game_ExecuteEvent('ongamestart');
4301 // Óñòàíîâêà ðàçìåðîâ îêîí èãðîêîâ:
4302 g_Game_SetupScreenSize();
4304 // Ñîçäàíèå ïåðâîãî èãðîêà:
4305 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4306 gPlayer1Settings
.Color
,
4307 gPlayer1Settings
.Team
, False));
4308 if gPlayer1
= nil then
4310 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
4314 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4317 // Ñîçäàíèå âòîðîãî èãðîêà, åñëè åñòü:
4320 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
4321 gPlayer2Settings
.Color
,
4322 gPlayer2Settings
.Team
, False));
4323 if gPlayer2
= nil then
4325 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
4329 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
4333 // Çàãðóçêà è çàïóñê êàðòû:
4334 if not g_Game_StartMap(MAP
, True) then
4336 if (Pos(':\', Map
) > 0) or (Pos(':/', Map
) > 0) then tmps
:= Map
else tmps
:= gGameSettings
.WAD
+ ':\' + MAP
;
4337 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [tmps
]));
4341 // Íàñòðîéêè èãðîêîâ è áîòîâ:
4345 for i
:= nPl
+1 to nPlayers
do
4346 g_Player_Create(STD_PLAYER_MODEL
, _RGB(0, 0, 0), 0, True);
4349 procedure g_Game_StartCustom(Map
: String; GameMode
: Byte;
4350 TimeLimit
, GoalLimit
: Word;
4352 Options
: LongWord; nPlayers
: Byte);
4358 e_WriteLog('Starting custom game...', TMsgType
.Notify
);
4360 g_Game_ClearLoading();
4363 gGameSettings
.GameType
:= GT_CUSTOM
;
4364 gGameSettings
.GameMode
:= GameMode
;
4365 gSwitchGameMode
:= GameMode
;
4366 gGameSettings
.TimeLimit
:= TimeLimit
;
4367 gGameSettings
.GoalLimit
:= GoalLimit
;
4368 gGameSettings
.MaxLives
:= IfThen(GameMode
= GM_CTF
, 0, MaxLives
);
4369 gGameSettings
.Options
:= Options
;
4371 gCoopTotalMonstersKilled
:= 0;
4372 gCoopTotalSecretsFound
:= 0;
4373 gCoopTotalMonsters
:= 0;
4374 gCoopTotalSecrets
:= 0;
4378 g_Game_ExecuteEvent('ongamestart');
4380 // Óñòàíîâêà ðàçìåðîâ îêîí èãðîêîâ:
4381 g_Game_SetupScreenSize();
4383 // Ðåæèì íàáëþäàòåëÿ:
4384 if nPlayers
= 0 then
4391 if nPlayers
>= 1 then
4393 // Ñîçäàíèå ïåðâîãî èãðîêà:
4394 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4395 gPlayer1Settings
.Color
,
4396 gPlayer1Settings
.Team
, False));
4397 if gPlayer1
= nil then
4399 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
4403 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4407 if nPlayers
>= 2 then
4409 // Ñîçäàíèå âòîðîãî èãðîêà:
4410 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
4411 gPlayer2Settings
.Color
,
4412 gPlayer2Settings
.Team
, False));
4413 if gPlayer2
= nil then
4415 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
4419 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
4423 // Çàãðóçêà è çàïóñê êàðòû:
4424 if not g_Game_StartMap(Map
, True) then
4426 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [Map
]));
4430 // Íåò òî÷åê ïîÿâëåíèÿ:
4431 if (g_Map_GetPointCount(RESPAWNPOINT_PLAYER1
) +
4432 g_Map_GetPointCount(RESPAWNPOINT_PLAYER2
) +
4433 g_Map_GetPointCount(RESPAWNPOINT_DM
) +
4434 g_Map_GetPointCount(RESPAWNPOINT_RED
)+
4435 g_Map_GetPointCount(RESPAWNPOINT_BLUE
)) < 1 then
4437 g_FatalError(_lc
[I_GAME_ERROR_GET_SPAWN
]);
4441 // Íàñòðîéêè èãðîêîâ è áîòîâ:
4445 for i
:= nPl
+1 to nPlayers
do
4446 g_Player_Create(STD_PLAYER_MODEL
, _RGB(0, 0, 0), 0, True);
4449 procedure g_Game_StartServer(Map
: String; GameMode
: Byte;
4450 TimeLimit
, GoalLimit
: Word; MaxLives
: Byte;
4451 Options
: LongWord; nPlayers
: Byte;
4452 IPAddr
: LongWord; Port
: Word);
4456 e_WriteLog('Starting net game (server)...', TMsgType
.Notify
);
4458 g_Game_ClearLoading();
4461 gGameSettings
.GameType
:= GT_SERVER
;
4462 gGameSettings
.GameMode
:= GameMode
;
4463 gSwitchGameMode
:= GameMode
;
4464 gGameSettings
.TimeLimit
:= TimeLimit
;
4465 gGameSettings
.GoalLimit
:= GoalLimit
;
4466 gGameSettings
.MaxLives
:= IfThen(GameMode
= GM_CTF
, 0, MaxLives
);
4467 gGameSettings
.Options
:= Options
;
4469 gCoopTotalMonstersKilled
:= 0;
4470 gCoopTotalSecretsFound
:= 0;
4471 gCoopTotalMonsters
:= 0;
4472 gCoopTotalSecrets
:= 0;
4476 g_Game_ExecuteEvent('ongamestart');
4478 // Óñòàíîâêà ðàçìåðîâ îêíà èãðîêà
4479 g_Game_SetupScreenSize();
4481 // Ðåæèì íàáëþäàòåëÿ:
4482 if nPlayers
= 0 then
4488 if nPlayers
>= 1 then
4490 // Ñîçäàíèå ïåðâîãî èãðîêà:
4491 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4492 gPlayer1Settings
.Color
,
4493 gPlayer1Settings
.Team
, False));
4494 if gPlayer1
= nil then
4496 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
4500 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4503 if nPlayers
>= 2 then
4505 // Ñîçäàíèå âòîðîãî èãðîêà:
4506 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
4507 gPlayer2Settings
.Color
,
4508 gPlayer2Settings
.Team
, False));
4509 if gPlayer2
= nil then
4511 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
4515 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
4518 g_Game_SetLoadingText(_lc
[I_LOAD_HOST
], 0, False);
4519 if NetForwardPorts
then
4520 g_Game_SetLoadingText(_lc
[I_LOAD_PORTS
], 0, False);
4523 if not g_Net_Host(IPAddr
, Port
, NetMaxClients
) then
4525 g_FatalError(_lc
[I_NET_MSG
] + _lc
[I_NET_ERR_HOST
]);
4529 g_Net_Slist_Set(NetSlistIP
, NetSlistPort
);
4531 // Çàãðóçêà è çàïóñê êàðòû:
4532 if not g_Game_StartMap(Map
, True) then
4534 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [Map
]));
4538 // Íåò òî÷åê ïîÿâëåíèÿ:
4539 if (g_Map_GetPointCount(RESPAWNPOINT_PLAYER1
) +
4540 g_Map_GetPointCount(RESPAWNPOINT_PLAYER2
) +
4541 g_Map_GetPointCount(RESPAWNPOINT_DM
) +
4542 g_Map_GetPointCount(RESPAWNPOINT_RED
)+
4543 g_Map_GetPointCount(RESPAWNPOINT_BLUE
)) < 1 then
4545 g_FatalError(_lc
[I_GAME_ERROR_GET_SPAWN
]);
4549 // Íàñòðîéêè èãðîêîâ è áîòîâ:
4552 NetState
:= NET_STATE_GAME
;
4555 procedure g_Game_StartClient(Addr
: String; Port
: Word; PW
: String);
4570 e_WriteLog('Starting net game (client)...', TMsgType
.Notify
);
4571 e_WriteLog('NET: Trying to connect to ' + Addr
+ ':' + IntToStr(Port
) + '...', TMsgType
.Notify
);
4573 g_Game_ClearLoading();
4576 gGameSettings
.GameType
:= GT_CLIENT
;
4578 gCoopTotalMonstersKilled
:= 0;
4579 gCoopTotalSecretsFound
:= 0;
4580 gCoopTotalMonsters
:= 0;
4581 gCoopTotalSecrets
:= 0;
4585 g_Game_ExecuteEvent('ongamestart');
4587 // Óñòàíîâêà ðàçìåðîâ îêîí èãðîêîâ:
4588 g_Game_SetupScreenSize();
4590 NetState
:= NET_STATE_AUTH
;
4592 g_Game_SetLoadingText(_lc
[I_LOAD_CONNECT
], 0, False);
4594 if not g_Net_Connect(Addr
, Port
) then
4596 g_FatalError(_lc
[I_NET_MSG
] + _lc
[I_NET_ERR_CONN
]);
4597 NetState
:= NET_STATE_NONE
;
4601 g_Game_SetLoadingText(_lc
[I_LOAD_SEND_INFO
], 0, False);
4603 g_Game_SetLoadingText(_lc
[I_LOAD_WAIT_INFO
], 0, False);
4608 while (enet_host_service(NetHost
, @NetEvent
, 0) > 0) do
4610 if (NetEvent
.kind
= ENET_EVENT_TYPE_RECEIVE
) then
4612 Ptr
:= NetEvent
.packet
^.data
;
4613 if not InMsg
.Init(Ptr
, NetEvent
.packet
^.dataLength
, True) then
4616 InMsg
.ReadLongWord(); // skip size
4617 MID
:= InMsg
.ReadByte();
4619 if (MID
= NET_MSG_INFO
) and (State
= 0) then
4621 NetMyID
:= InMsg
.ReadByte();
4622 NetPlrUID1
:= InMsg
.ReadWord();
4624 WadName
:= InMsg
.ReadString();
4625 Map
:= InMsg
.ReadString();
4627 gWADHash
:= InMsg
.ReadMD5();
4629 gGameSettings
.GameMode
:= InMsg
.ReadByte();
4630 gSwitchGameMode
:= gGameSettings
.GameMode
;
4631 gGameSettings
.GoalLimit
:= InMsg
.ReadWord();
4632 gGameSettings
.TimeLimit
:= InMsg
.ReadWord();
4633 gGameSettings
.MaxLives
:= InMsg
.ReadByte();
4634 gGameSettings
.Options
:= InMsg
.ReadLongWord();
4635 T
:= InMsg
.ReadLongWord();
4637 newResPath
:= g_Res_SearchSameWAD(MapsDir
, WadName
, gWADHash
);
4638 if newResPath
= '' then
4640 g_Game_SetLoadingText(_lc
[I_LOAD_DL_RES
], 0, False);
4641 newResPath
:= g_Res_DownloadWAD(WadName
);
4642 if newResPath
= '' then
4644 g_FatalError(_lc
[I_NET_ERR_HASH
]);
4645 enet_packet_destroy(NetEvent
.packet
);
4646 NetState
:= NET_STATE_NONE
;
4650 newResPath
:= ExtractRelativePath(MapsDir
, newResPath
);
4652 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4653 gPlayer1Settings
.Color
,
4654 gPlayer1Settings
.Team
, False));
4656 if gPlayer1
= nil then
4658 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
4660 enet_packet_destroy(NetEvent
.packet
);
4661 NetState
:= NET_STATE_NONE
;
4665 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4666 gPlayer1
.UID
:= NetPlrUID1
;
4667 gPlayer1
.Reset(True);
4669 if not g_Game_StartMap(newResPath
+ ':\' + Map
, True) then
4671 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [WadName
+ ':\' + Map
]));
4673 enet_packet_destroy(NetEvent
.packet
);
4674 NetState
:= NET_STATE_NONE
;
4682 enet_packet_destroy(NetEvent
.packet
);
4686 enet_packet_destroy(NetEvent
.packet
);
4690 if (NetEvent
.kind
= ENET_EVENT_TYPE_DISCONNECT
) then
4693 if (NetEvent
.data
<= NET_DISC_MAX
) then
4694 g_Console_Add(_lc
[I_NET_MSG_ERROR
] + _lc
[I_NET_ERR_CONN
] + ' ' +
4695 _lc
[TStrings_Locale(Cardinal(I_NET_DISC_NONE
) + NetEvent
.data
)], True);
4702 ProcessLoading(true);
4704 if e_KeyPressed(IK_SPACE
) or e_KeyPressed(IK_ESCAPE
) or e_KeyPressed(VK_ESCAPE
) or
4705 e_KeyPressed(JOY0_JUMP
) or e_KeyPressed(JOY1_JUMP
) or e_KeyPressed(JOY2_JUMP
) or e_KeyPressed(JOY3_JUMP
) then
4714 g_FatalError(_lc
[I_NET_MSG
] + _lc
[I_NET_ERR_CONN
]);
4715 NetState
:= NET_STATE_NONE
;
4719 gLMSRespawn
:= LMS_RESPAWN_NONE
;
4720 gLMSRespawnTime
:= 0;
4723 NetState
:= NET_STATE_GAME
;
4724 MC_SEND_FullStateRequest
;
4725 e_WriteLog('NET: Connection successful.', TMsgType
.Notify
);
4728 procedure g_Game_SaveOptions();
4730 g_Options_Write_Video(GameDir
+'/'+CONFIG_FILENAME
);
4733 procedure g_Game_ChangeMap(const MapPath
: String);
4737 g_Game_ClearLoading();
4739 Force
:= gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
];
4740 // Åñëè óðîâåíü çàâåðøèëñÿ ïî òðèããåðó Âûõîä, íå î÷èùàòü èíâåíòàðü
4741 if gExitByTrigger
then
4744 gExitByTrigger
:= False;
4746 if not g_Game_StartMap(MapPath
, Force
) then
4747 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [MapPath
]));
4750 procedure g_Game_Restart();
4754 if g_Game_IsClient
then
4756 map
:= g_ExtractFileName(gMapInfo
.Map
);
4760 g_Game_ClearLoading();
4761 g_Game_StartMap(Map
, True, gCurrentMapFileName
);
4764 function g_Game_StartMap(Map
: String; Force
: Boolean = False; const oldMapPath
: AnsiString=''): Boolean;
4766 NewWAD
, ResName
: String;
4769 g_Map_Free((Map
<> gCurrentMapFileName
) and (oldMapPath
<> gCurrentMapFileName
));
4770 g_Player_RemoveAllCorpses();
4772 if (not g_Game_IsClient
) and
4773 (gSwitchGameMode
<> gGameSettings
.GameMode
) and
4774 (gGameSettings
.GameMode
<> GM_SINGLE
) then
4776 if gSwitchGameMode
= GM_CTF
then
4777 gGameSettings
.MaxLives
:= 0;
4778 gGameSettings
.GameMode
:= gSwitchGameMode
;
4781 gSwitchGameMode
:= gGameSettings
.GameMode
;
4783 g_Player_ResetTeams();
4785 if isWadPath(Map
) then
4787 NewWAD
:= g_ExtractWadName(Map
);
4788 ResName
:= g_ExtractFileName(Map
);
4789 if g_Game_IsServer
then
4791 gWADHash
:= MD5File(MapsDir
+ NewWAD
);
4792 g_Game_LoadWAD(NewWAD
);
4794 // hash received in MC_RECV_GameEvent -> NET_EV_MAPSTART
4795 g_Game_ClientWAD(NewWAD
, gWADHash
);
4799 Result
:= g_Map_Load(MapsDir
+ gGameSettings
.WAD
+ ':\' + ResName
);
4802 g_Player_ResetAll(Force
or gLastMap
, gGameSettings
.GameType
= GT_SINGLE
);
4804 gState
:= STATE_NONE
;
4805 g_ActiveWindow
:= nil;
4811 if gGameSettings
.GameMode
= GM_CTF
then
4813 g_Map_ResetFlag(FLAG_RED
);
4814 g_Map_ResetFlag(FLAG_BLUE
);
4815 // CTF, à ôëàãîâ íåò:
4816 if not g_Map_HaveFlagPoints() then
4817 g_SimpleError(_lc
[I_GAME_ERROR_CTF
]);
4822 gState
:= STATE_MENU
;
4827 gPauseMain
:= false;
4828 gPauseHolmes
:= false;
4830 NetTimeToUpdate
:= 1;
4831 NetTimeToReliable
:= 0;
4832 NetTimeToMaster
:= NetMasterRate
;
4833 gLMSRespawn
:= LMS_RESPAWN_NONE
;
4834 gLMSRespawnTime
:= 0;
4835 gMissionFailed
:= False;
4838 gCoopMonstersKilled
:= 0;
4839 gCoopSecretsFound
:= 0;
4841 gVoteInProgress
:= False;
4842 gVotePassed
:= False;
4848 if not gGameOn
then Exit
;
4850 g_Game_SpectateCenterView();
4852 if (gGameSettings
.MaxLives
> 0) and (gGameSettings
.WarmupTime
> 0) then
4854 gLMSRespawn
:= LMS_RESPAWN_WARMUP
;
4855 gLMSRespawnTime
:= gTime
+ gGameSettings
.WarmupTime
*1000;
4856 gLMSSoftSpawn
:= True;
4857 if NetMode
= NET_SERVER
then
4858 MH_SEND_GameEvent(NET_EV_LMS_WARMUP
, (gLMSRespawnTime
- gTime
) div 1000)
4860 g_Console_Add(Format(_lc
[I_MSG_WARMUP_START
], [(gLMSRespawnTime
- gTime
) div 1000]), True);
4863 if NetMode
= NET_SERVER
then
4865 MH_SEND_GameEvent(NET_EV_MAPSTART
, gGameSettings
.GameMode
, Map
);
4868 if NetUseMaster
then
4870 if (NetMHost
= nil) or (NetMPeer
= nil) then
4871 if not g_Net_Slist_Connect
then
4872 g_Console_Add(_lc
[I_NET_MSG_ERROR
] + _lc
[I_NET_SLIST_ERROR
]);
4877 if NetClients
<> nil then
4878 for I
:= 0 to High(NetClients
) do
4879 if NetClients
[I
].Used
then
4881 NetClients
[I
].Voted
:= False;
4882 if NetClients
[I
].RequestedFullUpdate
then
4884 MH_SEND_Everything((NetClients
[I
].State
= NET_STATE_AUTH
), I
);
4885 NetClients
[I
].RequestedFullUpdate
:= False;
4889 g_Net_UnbanNonPermHosts();
4894 gCoopTotalMonstersKilled
:= 0;
4895 gCoopTotalSecretsFound
:= 0;
4896 gCoopTotalMonsters
:= 0;
4897 gCoopTotalSecrets
:= 0;
4901 g_Game_ExecuteEvent('onmapstart');
4904 procedure SetFirstLevel();
4908 MapList
:= g_Map_GetMapsList(MapsDir
+ gGameSettings
.WAD
);
4909 if MapList
= nil then
4912 SortSArray(MapList
);
4913 gNextMap
:= MapList
[Low(MapList
)];
4918 procedure g_Game_ExitLevel(const Map
: AnsiString);
4922 gCoopTotalMonstersKilled
:= gCoopTotalMonstersKilled
+ gCoopMonstersKilled
;
4923 gCoopTotalSecretsFound
:= gCoopTotalSecretsFound
+ gCoopSecretsFound
;
4924 gCoopTotalMonsters
:= gCoopTotalMonsters
+ gTotalMonsters
;
4925 gCoopTotalSecrets
:= gCoopTotalSecrets
+ gSecretsCount
;
4927 // Âûøëè â âûõîä â Îäèíî÷íîé èãðå:
4928 if gGameSettings
.GameType
= GT_SINGLE
then
4929 gExit
:= EXIT_ENDLEVELSINGLE
4930 else // Âûøëè â âûõîä â Ñâîåé èãðå
4932 gExit
:= EXIT_ENDLEVELCUSTOM
;
4933 if gGameSettings
.GameMode
= GM_COOP
then
4934 g_Player_RememberAll
;
4936 if not g_Map_Exist(MapsDir
+ gGameSettings
.WAD
+ ':\' + gNextMap
) then
4939 if gGameSettings
.GameMode
= GM_COOP
then
4942 gStatsPressed
:= True;
4943 gNextMap
:= 'MAP01';
4945 if not g_Map_Exist(MapsDir
+ gGameSettings
.WAD
+ ':\' + gNextMap
) then
4948 if g_Game_IsNet
then
4950 MH_SEND_GameStats();
4951 MH_SEND_CoopStats();
4957 procedure g_Game_RestartLevel();
4961 if gGameSettings
.GameMode
= GM_SINGLE
then
4966 gExit
:= EXIT_ENDLEVELCUSTOM
;
4967 Map
:= g_ExtractFileName(gMapInfo
.Map
);
4971 procedure g_Game_ClientWAD(NewWAD
: String; WHash
: TMD5Digest
);
4975 if LowerCase(NewWAD
) = LowerCase(gGameSettings
.WAD
) then
4977 if not g_Game_IsClient
then
4979 gWAD
:= g_Res_SearchSameWAD(MapsDir
, ExtractFileName(NewWAD
), WHash
);
4982 g_Game_SetLoadingText(_lc
[I_LOAD_DL_RES
], 0, False);
4983 gWAD
:= g_Res_DownloadWAD(ExtractFileName(NewWAD
));
4987 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_WAD
], [ExtractFileName(NewWAD
)]));
4991 NewWAD
:= ExtractRelativePath(MapsDir
, gWAD
);
4992 g_Game_LoadWAD(NewWAD
);
4995 procedure g_Game_RestartRound(NoMapRestart
: Boolean = False);
4997 i
, n
, nb
, nr
: Integer;
4999 function monRespawn (mon
: TMonster
): Boolean;
5001 result
:= false; // don't stop
5002 if not mon
.FNoRespawn
then mon
.Respawn();
5006 if not g_Game_IsServer
then Exit
;
5007 if gLMSRespawn
= LMS_RESPAWN_NONE
then Exit
;
5008 gLMSRespawn
:= LMS_RESPAWN_NONE
;
5009 gLMSRespawnTime
:= 0;
5012 if (gGameSettings
.GameMode
= GM_COOP
) and not NoMapRestart
then
5014 gMissionFailed
:= True;
5015 g_Game_RestartLevel
;
5019 n
:= 0; nb
:= 0; nr
:= 0;
5020 for i
:= Low(gPlayers
) to High(gPlayers
) do
5021 if (gPlayers
[i
] <> nil) and
5022 ((not gPlayers
[i
].FSpectator
) or gPlayers
[i
].FWantsInGame
or
5023 (gPlayers
[i
] is TBot
)) then
5026 if gPlayers
[i
].Team
= TEAM_RED
then Inc(nr
)
5027 else if gPlayers
[i
].Team
= TEAM_BLUE
then Inc(nb
)
5030 if (n
< 2) or ((gGameSettings
.GameMode
= GM_TDM
) and ((nr
= 0) or (nb
= 0))) then
5032 // wait a second until the fuckers finally decide to join
5033 gLMSRespawn
:= LMS_RESPAWN_WARMUP
;
5034 gLMSRespawnTime
:= gTime
+ 1000;
5035 gLMSSoftSpawn
:= NoMapRestart
;
5039 g_Player_RemoveAllCorpses
;
5040 g_Game_Message(_lc
[I_MESSAGE_LMS_START
], 144);
5041 if g_Game_IsNet
then
5042 MH_SEND_GameEvent(NET_EV_LMS_START
);
5044 for i
:= Low(gPlayers
) to High(gPlayers
) do
5046 if gPlayers
[i
] = nil then continue
;
5047 if gPlayers
[i
] is TBot
then gPlayers
[i
].FWantsInGame
:= True;
5048 // don't touch normal spectators
5049 if gPlayers
[i
].FSpectator
and not gPlayers
[i
].FWantsInGame
then
5051 gPlayers
[i
].FNoRespawn
:= True;
5052 gPlayers
[i
].Lives
:= 0;
5053 if g_Game_IsNet
then
5054 MH_SEND_PlayerStats(gPlayers
[I
].UID
);
5057 gPlayers
[i
].FNoRespawn
:= False;
5058 gPlayers
[i
].Lives
:= gGameSettings
.MaxLives
;
5059 gPlayers
[i
].Respawn(False, True);
5060 if gGameSettings
.GameMode
= GM_COOP
then
5062 gPlayers
[i
].Frags
:= 0;
5063 gPlayers
[i
].RecallState
;
5065 if (gPlayer1
= nil) and (gLMSPID1
> 0) then
5066 gPlayer1
:= g_Player_Get(gLMSPID1
);
5067 if (gPlayer2
= nil) and (gLMSPID2
> 0) then
5068 gPlayer2
:= g_Player_Get(gLMSPID2
);
5071 g_Items_RestartRound();
5074 g_Mons_ForEach(monRespawn
);
5076 gLMSSoftSpawn
:= False;
5079 function g_Game_GetFirstMap(WAD
: String): String;
5083 MapList
:= g_Map_GetMapsList(WAD
);
5084 if MapList
= nil then
5087 SortSArray(MapList
);
5088 Result
:= MapList
[Low(MapList
)];
5090 if not g_Map_Exist(WAD
+ ':\' + Result
) then
5096 function g_Game_GetNextMap(): String;
5103 MapList
:= g_Map_GetMapsList(MapsDir
+ gGameSettings
.WAD
);
5104 if MapList
= nil then
5107 Map
:= g_ExtractFileName(gMapInfo
.Map
);
5109 SortSArray(MapList
);
5111 for I
:= Low(MapList
) to High(MapList
) do
5112 if Map
= MapList
[I
] then
5118 if MapIndex
<> -255 then
5120 if MapIndex
= High(MapList
) then
5121 Result
:= MapList
[Low(MapList
)]
5123 Result
:= MapList
[MapIndex
+ 1];
5125 if not g_Map_Exist(MapsDir
+ gGameSettings
.WAD
+ ':\' + Result
) then Result
:= Map
;
5131 procedure g_Game_NextLevel();
5133 if gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
, GM_COOP
] then
5134 gExit
:= EXIT_ENDLEVELCUSTOM
5137 gExit
:= EXIT_ENDLEVELSINGLE
;
5141 if gNextMap
<> '' then Exit
;
5142 gNextMap
:= g_Game_GetNextMap();
5145 function g_Game_IsTestMap(): Boolean;
5147 result
:= StrEquCI1251(TEST_MAP_NAME
, g_ExtractFileName(gMapInfo
.Map
));
5150 procedure g_Game_DeleteTestMap();
5153 //MapName: AnsiString;
5161 a
:= Pos('.wad:\', toLowerCase1251(gMapToDelete
));
5162 if (a
= 0) then a
:= Pos('.wad:/', toLowerCase1251(gMapToDelete
));
5163 if (a
= 0) then exit
;
5165 // Âûäåëÿåì èìÿ wad-ôàéëà è èìÿ êàðòû
5166 WadName
:= Copy(gMapToDelete
, 1, a
+3);
5167 Delete(gMapToDelete
, 1, a
+5);
5168 gMapToDelete
:= UpperCase(gMapToDelete
);
5170 //CopyMemory(@MapName[0], @gMapToDelete[1], Min(16, Length(gMapToDelete)));
5173 // Èìÿ êàðòû íå ñòàíäàðòíîå òåñòîâîå:
5174 if MapName <> TEST_MAP_NAME then
5177 if not gTempDelete then
5179 time := g_GetFileTime(WadName);
5180 WAD := TWADFile.Create();
5183 if not WAD.ReadFile(WadName) then
5184 begin // Íåò òàêîãî WAD-ôàéëà
5189 // Ñîñòàâëÿåì ñïèñîê êàðò è èùåì íóæíóþ:
5191 MapList := WAD.GetResourcesList('');
5193 if MapList <> nil then
5194 for a := 0 to High(MapList) do
5195 if MapList[a] = MapName then
5197 // Óäàëÿåì è ñîõðàíÿåì:
5198 WAD.RemoveResource('', MapName);
5199 WAD.SaveTo(WadName);
5204 g_SetFileTime(WadName, time);
5207 if gTempDelete
then DeleteFile(WadName
);
5210 procedure GameCVars(P
: SSArray
);
5213 stat
: TPlayerStatArray
;
5218 cmd
:= LowerCase(P
[0]);
5219 if (cmd
= 'g_friendlyfire') and not g_Game_IsClient
then
5221 with gGameSettings
do
5223 if (Length(P
) > 1) and
5224 ((P
[1] = '1') or (P
[1] = '0')) then
5226 if (P
[1][1] = '1') then
5227 Options
:= Options
or GAME_OPTION_TEAMDAMAGE
5229 Options
:= Options
and (not GAME_OPTION_TEAMDAMAGE
);
5232 if (LongBool(Options
and GAME_OPTION_TEAMDAMAGE
)) then
5233 g_Console_Add(_lc
[I_MSG_FRIENDLY_FIRE_ON
])
5235 g_Console_Add(_lc
[I_MSG_FRIENDLY_FIRE_OFF
]);
5237 if g_Game_IsNet
then MH_SEND_GameSettings
;
5240 else if (cmd
= 'g_weaponstay') and not g_Game_IsClient
then
5242 with gGameSettings
do
5244 if (Length(P
) > 1) and
5245 ((P
[1] = '1') or (P
[1] = '0')) then
5247 if (P
[1][1] = '1') then
5248 Options
:= Options
or GAME_OPTION_WEAPONSTAY
5250 Options
:= Options
and (not GAME_OPTION_WEAPONSTAY
);
5253 if (LongBool(Options
and GAME_OPTION_WEAPONSTAY
)) then
5254 g_Console_Add(_lc
[I_MSG_WEAPONSTAY_ON
])
5256 g_Console_Add(_lc
[I_MSG_WEAPONSTAY_OFF
]);
5258 if g_Game_IsNet
then MH_SEND_GameSettings
;
5261 else if cmd
= 'g_gamemode' then
5263 a
:= g_Game_TextToMode(P
[1]);
5264 if a
= GM_SINGLE
then a
:= GM_COOP
;
5265 if (Length(P
) > 1) and (a
<> GM_NONE
) and (not g_Game_IsClient
) then
5267 gSwitchGameMode
:= a
;
5268 if (gGameOn
and (gGameSettings
.GameMode
= GM_SINGLE
)) or
5269 (gState
= STATE_INTERSINGLE
) then
5270 gSwitchGameMode
:= GM_SINGLE
;
5272 gGameSettings
.GameMode
:= gSwitchGameMode
;
5274 if gSwitchGameMode
= gGameSettings
.GameMode
then
5275 g_Console_Add(Format(_lc
[I_MSG_GAMEMODE_CURRENT
],
5276 [g_Game_ModeToText(gGameSettings
.GameMode
)]))
5278 g_Console_Add(Format(_lc
[I_MSG_GAMEMODE_CHANGE
],
5279 [g_Game_ModeToText(gGameSettings
.GameMode
),
5280 g_Game_ModeToText(gSwitchGameMode
)]));
5282 else if (cmd
= 'g_allow_exit') and not g_Game_IsClient
then
5284 with gGameSettings
do
5286 if (Length(P
) > 1) and
5287 ((P
[1] = '1') or (P
[1] = '0')) then
5289 if (P
[1][1] = '1') then
5290 Options
:= Options
or GAME_OPTION_ALLOWEXIT
5292 Options
:= Options
and (not GAME_OPTION_ALLOWEXIT
);
5295 if (LongBool(Options
and GAME_OPTION_ALLOWEXIT
)) then
5296 g_Console_Add(_lc
[I_MSG_ALLOWEXIT_ON
])
5298 g_Console_Add(_lc
[I_MSG_ALLOWEXIT_OFF
]);
5299 g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
5301 if g_Game_IsNet
then MH_SEND_GameSettings
;
5304 else if (cmd
= 'g_allow_monsters') and not g_Game_IsClient
then
5306 with gGameSettings
do
5308 if (Length(P
) > 1) and
5309 ((P
[1] = '1') or (P
[1] = '0')) then
5311 if (P
[1][1] = '1') then
5312 Options
:= Options
or GAME_OPTION_MONSTERS
5314 Options
:= Options
and (not GAME_OPTION_MONSTERS
);
5317 if (LongBool(Options
and GAME_OPTION_MONSTERS
)) then
5318 g_Console_Add(_lc
[I_MSG_ALLOWMON_ON
])
5320 g_Console_Add(_lc
[I_MSG_ALLOWMON_OFF
]);
5321 g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
5323 if g_Game_IsNet
then MH_SEND_GameSettings
;
5326 else if (cmd
= 'g_bot_vsplayers') and not g_Game_IsClient
then
5328 with gGameSettings
do
5330 if (Length(P
) > 1) and
5331 ((P
[1] = '1') or (P
[1] = '0')) then
5333 if (P
[1][1] = '1') then
5334 Options
:= Options
or GAME_OPTION_BOTVSPLAYER
5336 Options
:= Options
and (not GAME_OPTION_BOTVSPLAYER
);
5339 if (LongBool(Options
and GAME_OPTION_BOTVSPLAYER
)) then
5340 g_Console_Add(_lc
[I_MSG_BOTSVSPLAYERS_ON
])
5342 g_Console_Add(_lc
[I_MSG_BOTSVSPLAYERS_OFF
]);
5344 if g_Game_IsNet
then MH_SEND_GameSettings
;
5347 else if (cmd
= 'g_bot_vsmonsters') and not g_Game_IsClient
then
5349 with gGameSettings
do
5351 if (Length(P
) > 1) and
5352 ((P
[1] = '1') or (P
[1] = '0')) then
5354 if (P
[1][1] = '1') then
5355 Options
:= Options
or GAME_OPTION_BOTVSMONSTER
5357 Options
:= Options
and (not GAME_OPTION_BOTVSMONSTER
);
5360 if (LongBool(Options
and GAME_OPTION_BOTVSMONSTER
)) then
5361 g_Console_Add(_lc
[I_MSG_BOTSVSMONSTERS_ON
])
5363 g_Console_Add(_lc
[I_MSG_BOTSVSMONSTERS_OFF
]);
5365 if g_Game_IsNet
then MH_SEND_GameSettings
;
5368 else if (cmd
= 'g_warmuptime') and not g_Game_IsClient
then
5370 if Length(P
) > 1 then
5372 if StrToIntDef(P
[1], gGameSettings
.WarmupTime
) = 0 then
5373 gGameSettings
.WarmupTime
:= 30
5375 gGameSettings
.WarmupTime
:= StrToIntDef(P
[1], gGameSettings
.WarmupTime
);
5378 g_Console_Add(Format(_lc
[I_MSG_WARMUP
],
5379 [gGameSettings
.WarmupTime
]));
5380 g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
5382 else if cmd
= 'net_interp' then
5384 if (Length(P
) > 1) then
5385 NetInterpLevel
:= StrToIntDef(P
[1], NetInterpLevel
);
5387 g_Console_Add('net_interp = ' + IntToStr(NetInterpLevel
));
5388 config
:= TConfig
.CreateFile(GameDir
+'/'+CONFIG_FILENAME
);
5389 config
.WriteInt('Client', 'InterpolationSteps', NetInterpLevel
);
5390 config
.SaveFile(GameDir
+'/'+CONFIG_FILENAME
);
5393 else if cmd
= 'net_forceplayerupdate' then
5395 if (Length(P
) > 1) and
5396 ((P
[1] = '1') or (P
[1] = '0')) then
5397 NetForcePlayerUpdate
:= (P
[1][1] = '1');
5399 if NetForcePlayerUpdate
then
5400 g_Console_Add('net_forceplayerupdate = 1')
5402 g_Console_Add('net_forceplayerupdate = 0');
5403 config
:= TConfig
.CreateFile(GameDir
+'/'+CONFIG_FILENAME
);
5404 config
.WriteBool('Client', 'ForcePlayerUpdate', NetForcePlayerUpdate
);
5405 config
.SaveFile(GameDir
+'/'+CONFIG_FILENAME
);
5408 else if cmd
= 'net_predictself' then
5410 if (Length(P
) > 1) and
5411 ((P
[1] = '1') or (P
[1] = '0')) then
5412 NetPredictSelf
:= (P
[1][1] = '1');
5414 if NetPredictSelf
then
5415 g_Console_Add('net_predictself = 1')
5417 g_Console_Add('net_predictself = 0');
5418 config
:= TConfig
.CreateFile(GameDir
+'/'+CONFIG_FILENAME
);
5419 config
.WriteBool('Client', 'PredictSelf', NetPredictSelf
);
5420 config
.SaveFile(GameDir
+'/'+CONFIG_FILENAME
);
5423 else if cmd
= 'sv_name' then
5425 if (Length(P
) > 1) and (Length(P
[1]) > 0) then
5427 NetServerName
:= P
[1];
5428 if Length(NetServerName
) > 64 then
5429 SetLength(NetServerName
, 64);
5430 if g_Game_IsServer
and g_Game_IsNet
and NetUseMaster
then
5434 g_Console_Add(cmd
+ ' = "' + NetServerName
+ '"');
5436 else if cmd
= 'sv_passwd' then
5438 if (Length(P
) > 1) and (Length(P
[1]) > 0) then
5440 NetPassword
:= P
[1];
5441 if Length(NetPassword
) > 24 then
5442 SetLength(NetPassword
, 24);
5443 if g_Game_IsServer
and g_Game_IsNet
and NetUseMaster
then
5447 g_Console_Add(cmd
+ ' = "' + AnsiLowerCase(NetPassword
) + '"');
5449 else if cmd
= 'sv_maxplrs' then
5451 if (Length(P
) > 1) then
5453 NetMaxClients
:= Min(Max(StrToIntDef(P
[1], NetMaxClients
), 1), NET_MAXCLIENTS
);
5454 if g_Game_IsServer
and g_Game_IsNet
then
5457 for a
:= 0 to High(NetClients
) do
5458 if NetClients
[a
].Used
then
5461 if b
> NetMaxClients
then
5463 s
:= g_Player_Get(NetClients
[a
].Player
).Name
;
5464 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_FULL
);
5465 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
5466 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
5469 if NetUseMaster
then
5474 g_Console_Add(cmd
+ ' = ' + IntToStr(NetMaxClients
));
5476 else if cmd
= 'sv_public' then
5478 if (Length(P
) > 1) then
5480 NetUseMaster
:= StrToIntDef(P
[1], Byte(NetUseMaster
)) > 0;
5481 if g_Game_IsServer
and g_Game_IsNet
then
5482 if NetUseMaster
then
5484 if NetMPeer
= nil then
5485 if not g_Net_Slist_Connect() then
5486 g_Console_Add(_lc
[I_NET_MSG_ERROR
] + _lc
[I_NET_SLIST_ERROR
]);
5487 g_Net_Slist_Update();
5490 if NetMPeer
<> nil then
5491 g_Net_Slist_Disconnect();
5494 g_Console_Add(cmd
+ ' = ' + IntToStr(Byte(NetUseMaster
)));
5496 else if cmd
= 'sv_intertime' then
5498 if (Length(P
) > 1) then
5499 gDefInterTime
:= Min(Max(StrToIntDef(P
[1], gDefInterTime
), -1), 120);
5501 g_Console_Add(cmd
+ ' = ' + IntToStr(gDefInterTime
));
5503 else if cmd
= 'p1_name' then
5505 if (Length(P
) > 1) and gGameOn
then
5507 if g_Game_IsClient
then
5509 gPlayer1Settings
.Name
:= b_Text_Unformat(P
[1]);
5510 MC_SEND_PlayerSettings
;
5513 if gPlayer1
<> nil then
5515 gPlayer1
.Name
:= b_Text_Unformat(P
[1]);
5516 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer1
.UID
);
5519 gPlayer1Settings
.Name
:= b_Text_Unformat(P
[1]);
5522 else if cmd
= 'p2_name' then
5524 if (Length(P
) > 1) and gGameOn
then
5526 if g_Game_IsClient
then
5528 gPlayer2Settings
.Name
:= b_Text_Unformat(P
[1]);
5529 MC_SEND_PlayerSettings
;
5532 if gPlayer2
<> nil then
5534 gPlayer2
.Name
:= b_Text_Unformat(P
[1]);
5535 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer2
.UID
);
5538 gPlayer2Settings
.Name
:= b_Text_Unformat(P
[1]);
5541 else if cmd
= 'p1_color' then
5543 if Length(P
) > 3 then
5544 if g_Game_IsClient
then
5546 gPlayer1Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
5547 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
5548 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
5549 MC_SEND_PlayerSettings
;
5552 if gPlayer1
<> nil then
5554 gPlayer1
.Model
.SetColor(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
5555 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
5556 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
5557 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer1
.UID
);
5560 gPlayer1Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
5561 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
5562 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
5564 else if (cmd
= 'p2_color') and not g_Game_IsNet
then
5566 if Length(P
) > 3 then
5567 if g_Game_IsClient
then
5569 gPlayer2Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
5570 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
5571 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
5572 MC_SEND_PlayerSettings
;
5575 if gPlayer2
<> nil then
5577 gPlayer2
.Model
.SetColor(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
5578 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
5579 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
5580 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer2
.UID
);
5583 gPlayer2Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
5584 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
5585 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
5587 else if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
5589 if cmd
= 'r_showscore' then
5591 if (Length(P
) > 1) and
5592 ((P
[1] = '1') or (P
[1] = '0')) then
5593 gShowGoals
:= (P
[1][1] = '1');
5596 g_Console_Add(_lc
[I_MSG_SCORE_ON
])
5598 g_Console_Add(_lc
[I_MSG_SCORE_OFF
]);
5600 else if cmd
= 'r_showstat' then
5602 if (Length(P
) > 1) and
5603 ((P
[1] = '1') or (P
[1] = '0')) then
5604 gShowStat
:= (P
[1][1] = '1');
5607 g_Console_Add(_lc
[I_MSG_STATS_ON
])
5609 g_Console_Add(_lc
[I_MSG_STATS_OFF
]);
5611 else if cmd
= 'r_showkillmsg' then
5613 if (Length(P
) > 1) and
5614 ((P
[1] = '1') or (P
[1] = '0')) then
5615 gShowKillMsg
:= (P
[1][1] = '1');
5617 if gShowKillMsg
then
5618 g_Console_Add(_lc
[I_MSG_KILL_MSGS_ON
])
5620 g_Console_Add(_lc
[I_MSG_KILL_MSGS_OFF
]);
5622 else if cmd
= 'r_showlives' then
5624 if (Length(P
) > 1) and
5625 ((P
[1] = '1') or (P
[1] = '0')) then
5626 gShowLives
:= (P
[1][1] = '1');
5629 g_Console_Add(_lc
[I_MSG_LIVES_ON
])
5631 g_Console_Add(_lc
[I_MSG_LIVES_OFF
]);
5633 else if cmd
= 'r_showspect' then
5635 if (Length(P
) > 1) and
5636 ((P
[1] = '1') or (P
[1] = '0')) then
5637 gSpectHUD
:= (P
[1][1] = '1');
5640 g_Console_Add(_lc
[I_MSG_SPECT_HUD_ON
])
5642 g_Console_Add(_lc
[I_MSG_SPECT_HUD_OFF
]);
5644 else if cmd
= 'r_showping' then
5646 if (Length(P
) > 1) and
5647 ((P
[1] = '1') or (P
[1] = '0')) then
5648 gShowPing
:= (P
[1][1] = '1');
5651 g_Console_Add(_lc
[I_MSG_PING_ON
])
5653 g_Console_Add(_lc
[I_MSG_PING_OFF
]);
5655 else if (cmd
= 'g_scorelimit') and not g_Game_IsClient
then
5657 if Length(P
) > 1 then
5659 if StrToIntDef(P
[1], gGameSettings
.GoalLimit
) = 0 then
5660 gGameSettings
.GoalLimit
:= 0
5665 if gGameSettings
.GameMode
= GM_DM
then
5667 stat
:= g_Player_GetStats();
5669 for a
:= 0 to High(stat
) do
5670 if stat
[a
].Frags
> b
then
5674 b
:= Max(gTeamStat
[TEAM_RED
].Goals
, gTeamStat
[TEAM_BLUE
].Goals
);
5676 gGameSettings
.GoalLimit
:= Max(StrToIntDef(P
[1], gGameSettings
.GoalLimit
), b
);
5679 if g_Game_IsNet
then MH_SEND_GameSettings
;
5682 g_Console_Add(Format(_lc
[I_MSG_SCORE_LIMIT
], [gGameSettings
.GoalLimit
]));
5684 else if (cmd
= 'g_timelimit') and not g_Game_IsClient
then
5686 if (Length(P
) > 1) and (StrToIntDef(P
[1], -1) >= 0) then
5687 gGameSettings
.TimeLimit
:= StrToIntDef(P
[1], -1);
5689 g_Console_Add(Format(_lc
[I_MSG_TIME_LIMIT
],
5690 [gGameSettings
.TimeLimit
div 3600,
5691 (gGameSettings
.TimeLimit
div 60) mod 60,
5692 gGameSettings
.TimeLimit
mod 60]));
5693 if g_Game_IsNet
then MH_SEND_GameSettings
;
5695 else if (cmd
= 'g_maxlives') and not g_Game_IsClient
then
5697 if Length(P
) > 1 then
5699 if StrToIntDef(P
[1], gGameSettings
.MaxLives
) = 0 then
5700 gGameSettings
.MaxLives
:= 0
5704 stat
:= g_Player_GetStats();
5706 for a
:= 0 to High(stat
) do
5707 if stat
[a
].Lives
> b
then
5709 gGameSettings
.MaxLives
:=
5710 Max(StrToIntDef(P
[1], gGameSettings
.MaxLives
), b
);
5714 g_Console_Add(Format(_lc
[I_MSG_LIVES
],
5715 [gGameSettings
.MaxLives
]));
5716 if g_Game_IsNet
then MH_SEND_GameSettings
;
5721 procedure PrintHeapStats();
5725 hs
:= GetFPCHeapStatus();
5726 e_LogWriteLn ('v===== heap status =====v');
5727 e_LogWriteFln('max heap size = %d k', [hs
.MaxHeapSize
div 1024]);
5728 e_LogWriteFln('max heap used = %d k', [hs
.MaxHeapUsed
div 1024]);
5729 e_LogWriteFln('cur heap size = %d k', [hs
.CurrHeapSize
div 1024]);
5730 e_LogWriteFln('cur heap used = %d k', [hs
.CurrHeapUsed
div 1024]);
5731 e_LogWriteFln('cur heap free = %d k', [hs
.CurrHeapFree
div 1024]);
5732 e_LogWriteLn ('^=======================^');
5735 procedure DebugCommands(P
: SSArray
);
5742 // Êîìàíäû îòëàäî÷íîãî ðåæèìà:
5743 if {gDebugMode}conIsCheatsEnabled
then
5745 cmd
:= LowerCase(P
[0]);
5746 if cmd
= 'd_window' then
5748 g_Console_Add(Format('gWinPosX = %d, gWinPosY %d', [gWinPosX
, gWinPosY
]));
5749 g_Console_Add(Format('gWinRealPosX = %d, gWinRealPosY %d', [gWinRealPosX
, gWinRealPosY
]));
5750 g_Console_Add(Format('gScreenWidth = %d, gScreenHeight = %d', [gScreenWidth
, gScreenHeight
]));
5751 g_Console_Add(Format('gWinSizeX = %d, gWinSizeY = %d', [gWinSizeX
, gWinSizeY
]));
5752 g_Console_Add(Format('Frame X = %d, Y = %d, Caption Y = %d', [gWinFrameX
, gWinFrameY
, gWinCaption
]));
5754 else if cmd
= 'd_sounds' then
5756 if (Length(P
) > 1) and
5757 ((P
[1] = '1') or (P
[1] = '0')) then
5758 g_Debug_Sounds
:= (P
[1][1] = '1');
5760 g_Console_Add(Format('d_sounds is %d', [Byte(g_Debug_Sounds
)]));
5762 else if cmd
= 'd_frames' then
5764 if (Length(P
) > 1) and
5765 ((P
[1] = '1') or (P
[1] = '0')) then
5766 g_Debug_Frames
:= (P
[1][1] = '1');
5768 g_Console_Add(Format('d_frames is %d', [Byte(g_Debug_Frames
)]));
5770 else if cmd
= 'd_winmsg' then
5772 if (Length(P
) > 1) and
5773 ((P
[1] = '1') or (P
[1] = '0')) then
5774 g_Debug_WinMsgs
:= (P
[1][1] = '1');
5776 g_Console_Add(Format('d_winmsg is %d', [Byte(g_Debug_WinMsgs
)]));
5778 else if (cmd
= 'd_monoff') and not g_Game_IsNet
then
5780 if (Length(P
) > 1) and
5781 ((P
[1] = '1') or (P
[1] = '0')) then
5782 g_Debug_MonsterOff
:= (P
[1][1] = '1');
5784 g_Console_Add(Format('d_monoff is %d', [Byte(g_debug_MonsterOff
)]));
5786 else if (cmd
= 'd_botoff') and not g_Game_IsNet
then
5788 if Length(P
) > 1 then
5790 '0': g_debug_BotAIOff
:= 0;
5791 '1': g_debug_BotAIOff
:= 1;
5792 '2': g_debug_BotAIOff
:= 2;
5793 '3': g_debug_BotAIOff
:= 3;
5796 g_Console_Add(Format('d_botoff is %d', [g_debug_BotAIOff
]));
5798 else if cmd
= 'd_monster' then
5800 if gGameOn
and (gPlayer1
<> nil) and (gPlayer1
.alive
) and (not g_Game_IsNet
) then
5801 if Length(P
) < 2 then
5803 g_Console_Add(cmd
+ ' [ID | Name] [behaviour]');
5804 g_Console_Add('ID | Name');
5805 for b
:= MONSTER_DEMON
to MONSTER_MAN
do
5806 g_Console_Add(Format('%2d | %s', [b
, g_Mons_NameByTypeId(b
)]));
5807 conwriteln('behav. num'#10'normal 0'#10'killer 1'#10'maniac 2'#10'insane 3'#10'cannibal 4'#10'good 5');
5810 a
:= StrToIntDef(P
[1], 0);
5811 if (a
< MONSTER_DEMON
) or (a
> MONSTER_MAN
) then
5812 a
:= g_Mons_TypeIdByName(P
[1]);
5814 if (a
< MONSTER_DEMON
) or (a
> MONSTER_MAN
) then
5815 g_Console_Add(Format(_lc
[I_MSG_NO_MONSTER
], [P
[1]]))
5818 with gPlayer1
.Obj
do
5820 mon
:= g_Monsters_Create(a
,
5821 X
+ Rect
.X
+ (Rect
.Width
div 2),
5822 Y
+ Rect
.Y
+ Rect
.Height
,
5823 gPlayer1
.Direction
, True);
5825 if (Length(P
) > 2) and (mon
<> nil) then
5827 if (CompareText(P
[2], 'normal') = 0) then mon
.MonsterBehaviour
:= BH_NORMAL
5828 else if (CompareText(P
[2], 'killer') = 0) then mon
.MonsterBehaviour
:= BH_KILLER
5829 else if (CompareText(P
[2], 'maniac') = 0) then mon
.MonsterBehaviour
:= BH_MANIAC
5830 else if (CompareText(P
[2], 'insane') = 0) then mon
.MonsterBehaviour
:= BH_INSANE
5831 else if (CompareText(P
[2], 'cannibal') = 0) then mon
.MonsterBehaviour
:= BH_CANNIBAL
5832 else if (CompareText(P
[2], 'good') = 0) then mon
.MonsterBehaviour
:= BH_GOOD
5833 else if (CompareText(P
[2], 'friend') = 0) then mon
.MonsterBehaviour
:= BH_GOOD
5834 else if (CompareText(P
[2], 'friendly') = 0) then mon
.MonsterBehaviour
:= BH_GOOD
5835 else mon
.MonsterBehaviour
:= Min(Max(StrToIntDef(P
[2], BH_NORMAL
), BH_NORMAL
), BH_GOOD
);
5840 else if (cmd
= 'd_health') then
5842 if (Length(P
) > 1) and
5843 ((P
[1] = '1') or (P
[1] = '0')) then
5844 g_debug_HealthBar
:= (P
[1][1] = '1');
5846 g_Console_Add(Format('d_health is %d', [Byte(g_debug_HealthBar
)]));
5848 else if (cmd
= 'd_player') then
5850 if (Length(P
) > 1) and
5851 ((P
[1] = '1') or (P
[1] = '0')) then
5852 g_debug_Player
:= (P
[1][1] = '1');
5854 g_Console_Add(Format(cmd
+ ' is %d', [Byte(g_Debug_Player
)]));
5856 else if (cmd
= 'd_mem') then
5862 g_Console_Add(_lc
[I_MSG_NOT_DEBUG
]);
5866 procedure GameCheats(P
: SSArray
);
5872 if (not gGameOn
) or (not conIsCheatsEnabled
) then
5874 g_Console_Add('not available');
5880 g_Console_Add('where is the player?!');
5883 cmd
:= LowerCase(P
[0]);
5887 plr
.GodMode
:= not plr
.GodMode
;
5888 if plr
.GodMode
then g_Console_Add('player is godlike now') else g_Console_Add('player is mortal now');
5891 // give <health|exit|weapons|air|suit|jetpack|berserk|all>
5892 if cmd
= 'give' then
5894 if length(P
) < 2 then begin g_Console_Add('give what?!'); exit
; end;
5895 for f
:= 1 to High(P
) do
5897 cmd
:= LowerCase(P
[f
]);
5898 if cmd
= 'health' then begin plr
.RestoreHealthArmor(); g_Console_Add('player feels himself better'); continue
; end;
5899 if (cmd
= 'all') {or (cmd = 'weapons')} then begin plr
.AllRulez(False); g_Console_Add('player got the gifts'); continue
; end;
5900 if cmd
= 'exit' then
5902 if gTriggers
<> nil then
5904 for a
:= 0 to High(gTriggers
) do
5906 if gTriggers
[a
].TriggerType
= TRIGGER_EXIT
then
5908 g_Console_Add('player left the map');
5909 gExitByTrigger
:= True;
5910 //g_Game_ExitLevel(gTriggers[a].Data.MapName);
5911 g_Game_ExitLevel(gTriggers
[a
].tgcMap
);
5919 if cmd
= 'air' then begin plr
.GiveItem(ITEM_OXYGEN
); g_Console_Add('player got some air'); continue
; end;
5920 if cmd
= 'jetpack' then begin plr
.GiveItem(ITEM_JETPACK
); g_Console_Add('player got a jetpack'); continue
; end;
5921 if cmd
= 'suit' then begin plr
.GiveItem(ITEM_SUIT
); g_Console_Add('player got an envirosuit'); continue
; end;
5922 if cmd
= 'berserk' then begin plr
.GiveItem(ITEM_MEDKIT_BLACK
); g_Console_Add('player got a berserk pack'); continue
; end;
5923 if cmd
= 'backpack' then begin plr
.GiveItem(ITEM_AMMO_BACKPACK
); g_Console_Add('player got a backpack'); continue
; end;
5925 if cmd
= 'helmet' then begin plr
.GiveItem(ITEM_HELMET
); g_Console_Add('player got a helmet'); continue
; end;
5926 if cmd
= 'bottle' then begin plr
.GiveItem(ITEM_BOTTLE
); g_Console_Add('player got a bottle of health'); continue
; end;
5928 if cmd
= 'stimpack' then begin plr
.GiveItem(ITEM_MEDKIT_SMALL
); g_Console_Add('player got a stimpack'); continue
; end;
5929 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;
5931 if cmd
= 'greenarmor' then begin plr
.GiveItem(ITEM_ARMOR_GREEN
); g_Console_Add('player got a security armor'); continue
; end;
5932 if cmd
= 'bluearmor' then begin plr
.GiveItem(ITEM_ARMOR_BLUE
); g_Console_Add('player got a combat armor'); continue
; end;
5934 if (cmd
= 'megasphere') or (cmd
= 'mega') then begin plr
.GiveItem(ITEM_SPHERE_BLUE
); g_Console_Add('player got a megasphere'); continue
; end;
5935 if (cmd
= 'soulsphere') or (cmd
= 'soul')then begin plr
.GiveItem(ITEM_SPHERE_WHITE
); g_Console_Add('player got a soul sphere'); continue
; end;
5937 if (cmd
= 'invul') or (cmd
= 'invulnerability') then begin plr
.GiveItem(ITEM_INVUL
); g_Console_Add('player got invulnerability'); continue
; end;
5938 if (cmd
= 'invis') or (cmd
= 'invisibility') then begin plr
.GiveItem(ITEM_INVIS
); g_Console_Add('player got invisibility'); continue
; end;
5940 if cmd
= 'redkey' then begin plr
.GiveItem(ITEM_KEY_RED
); g_Console_Add('player got the red key'); continue
; end;
5941 if cmd
= 'greenkey' then begin plr
.GiveItem(ITEM_KEY_GREEN
); g_Console_Add('player got the green key'); continue
; end;
5942 if cmd
= 'bluekey' then begin plr
.GiveItem(ITEM_KEY_BLUE
); g_Console_Add('player got the blue key'); continue
; end;
5944 if (cmd
= 'shotgun') or (cmd
= 'sg') then begin plr
.GiveItem(ITEM_WEAPON_SHOTGUN1
); g_Console_Add('player got a shotgun'); continue
; end;
5945 if (cmd
= 'supershotgun') or (cmd
= 'ssg') then begin plr
.GiveItem(ITEM_WEAPON_SHOTGUN2
); g_Console_Add('player got a supershotgun'); continue
; end;
5946 if cmd
= 'chaingun' then begin plr
.GiveItem(ITEM_WEAPON_CHAINGUN
); g_Console_Add('player got a chaingun'); continue
; end;
5947 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;
5948 if cmd
= 'plasmagun' then begin plr
.GiveItem(ITEM_WEAPON_PLASMA
); g_Console_Add('player got a plasma gun'); continue
; end;
5949 if cmd
= 'bfg' then begin plr
.GiveItem(ITEM_WEAPON_BFG
); g_Console_Add('player got a BFG-9000'); continue
; end;
5951 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;
5952 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;
5953 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;
5954 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;
5955 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;
5956 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;
5958 if cmd
= 'superchaingun' then begin plr
.GiveItem(ITEM_WEAPON_SUPERPULEMET
); g_Console_Add('player got a superchaingun'); continue
; end;
5959 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;
5961 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;
5962 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;
5964 if cmd
= 'chainsaw' then begin plr
.GiveItem(ITEM_WEAPON_SAW
); g_Console_Add('player got a chainsaw'); continue
; end;
5966 if cmd
= 'ammo' then
5968 plr
.GiveItem(ITEM_AMMO_SHELLS_BOX
);
5969 plr
.GiveItem(ITEM_AMMO_BULLETS_BOX
);
5970 plr
.GiveItem(ITEM_AMMO_CELL_BIG
);
5971 plr
.GiveItem(ITEM_AMMO_ROCKET_BOX
);
5972 plr
.GiveItem(ITEM_AMMO_FUELCAN
);
5973 g_Console_Add('player got some ammo');
5977 if cmd
= 'clip' then begin plr
.GiveItem(ITEM_AMMO_BULLETS
); g_Console_Add('player got some bullets'); continue
; end;
5978 if cmd
= 'bullets' then begin plr
.GiveItem(ITEM_AMMO_BULLETS_BOX
); g_Console_Add('player got a box of bullets'); continue
; end;
5980 if cmd
= 'shells' then begin plr
.GiveItem(ITEM_AMMO_SHELLS
); g_Console_Add('player got some shells'); continue
; end;
5981 if cmd
= 'shellbox' then begin plr
.GiveItem(ITEM_AMMO_SHELLS_BOX
); g_Console_Add('player got a box of shells'); continue
; end;
5983 if cmd
= 'cells' then begin plr
.GiveItem(ITEM_AMMO_CELL
); g_Console_Add('player got some cells'); continue
; end;
5984 if cmd
= 'battery' then begin plr
.GiveItem(ITEM_AMMO_CELL_BIG
); g_Console_Add('player got cell battery'); continue
; end;
5986 if cmd
= 'rocket' then begin plr
.GiveItem(ITEM_AMMO_ROCKET
); g_Console_Add('player got a rocket'); continue
; end;
5987 if cmd
= 'rocketbox' then begin plr
.GiveItem(ITEM_AMMO_ROCKET_BOX
); g_Console_Add('player got some rockets'); continue
; end;
5989 if (cmd
= 'fuel') or (cmd
= 'fuelcan') then begin plr
.GiveItem(ITEM_AMMO_FUELCAN
); g_Console_Add('player got fuel canister'); continue
; end;
5991 if cmd
= 'weapons' then
5993 plr
.GiveItem(ITEM_WEAPON_SHOTGUN1
);
5994 plr
.GiveItem(ITEM_WEAPON_SHOTGUN2
);
5995 plr
.GiveItem(ITEM_WEAPON_CHAINGUN
);
5996 plr
.GiveItem(ITEM_WEAPON_ROCKETLAUNCHER
);
5997 plr
.GiveItem(ITEM_WEAPON_PLASMA
);
5998 plr
.GiveItem(ITEM_WEAPON_BFG
);
5999 g_Console_Add('player got weapons');
6003 if cmd
= 'keys' then
6005 plr
.GiveItem(ITEM_KEY_RED
);
6006 plr
.GiveItem(ITEM_KEY_GREEN
);
6007 plr
.GiveItem(ITEM_KEY_BLUE
);
6008 g_Console_Add('player got all keys');
6012 g_Console_Add('i don''t know how to give '''+cmd
+'''!');
6017 if cmd
= 'open' then
6019 g_Console_Add('player activated sesame');
6020 g_Triggers_OpenAll();
6027 if gFly
then g_Console_Add('player feels himself lighter') else g_Console_Add('player lost his wings');
6031 if cmd
= 'noclip' then
6034 g_Console_Add('wall hardeness adjusted');
6038 if cmd
= 'notarget' then
6040 plr
.NoTarget
:= not plr
.NoTarget
;
6041 if plr
.NoTarget
then g_Console_Add('player hides in shadows') else g_Console_Add('player is brave again');
6045 if cmd
= 'noreload' then
6047 plr
.NoReload
:= not plr
.NoReload
;
6048 if plr
.NoReload
then g_Console_Add('player is action hero now') else g_Console_Add('player is ordinary man now');
6052 if cmd
= 'speedy' then
6054 MAX_RUNVEL
:= 32-MAX_RUNVEL
;
6055 g_Console_Add('speed adjusted');
6059 if cmd
= 'jumpy' then
6061 VEL_JUMP
:= 30-VEL_JUMP
;
6062 g_Console_Add('jump height adjusted');
6066 if cmd
= 'automap' then
6068 gShowMap
:= not gShowMap
;
6069 if gShowMap
then g_Console_Add('player gains second sight') else g_Console_Add('player lost second sight');
6073 if cmd
= 'aimline' then
6075 gAimLine
:= not gAimLine
;
6076 if gAimLine
then g_Console_Add('player gains laser sight') else g_Console_Add('player lost laser sight');
6081 procedure GameCommands(P
: SSArray
);
6087 pl
: pTNetClient
= nil;
6094 cmd
:= LowerCase(P
[0]);
6096 if (cmd
= 'quit') or
6103 else if cmd
= 'pause' then
6105 if (g_ActiveWindow
= nil) then
6106 g_Game_Pause(not gPauseMain
);
6108 else if cmd
= 'endgame' then
6109 gExit
:= EXIT_SIMPLE
6110 else if cmd
= 'restart' then
6112 if gGameOn
or (gState
in [STATE_INTERSINGLE
, STATE_INTERCUSTOM
]) then
6114 if g_Game_IsClient
then
6116 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6121 g_Console_Add(_lc
[I_MSG_NOT_GAME
]);
6123 else if cmd
= 'kick' then
6125 if g_Game_IsServer
then
6127 if Length(P
) < 2 then
6129 g_Console_Add('kick <name>');
6134 g_Console_Add('kick <name>');
6138 if g_Game_IsNet
then
6139 pl
:= g_Net_Client_ByName(P
[1]);
6142 s
:= g_Net_ClientName_ByID(pl
^.ID
);
6143 enet_peer_disconnect(pl
^.Peer
, NET_DISC_KICK
);
6144 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
6145 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
6146 if NetUseMaster
then
6148 end else if gPlayers
<> nil then
6149 for a
:= Low(gPlayers
) to High(gPlayers
) do
6150 if gPlayers
[a
] <> nil then
6151 if Copy(LowerCase(gPlayers
[a
].Name
), 1, Length(P
[1])) = LowerCase(P
[1]) then
6153 // Íå îòêëþ÷àòü îñíîâíûõ èãðîêîâ â ñèíãëå
6154 if not(gPlayers
[a
] is TBot
) and (gGameSettings
.GameType
= GT_SINGLE
) then
6156 gPlayers
[a
].Lives
:= 0;
6157 gPlayers
[a
].Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
6158 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [gPlayers
[a
].Name
]), True);
6159 g_Player_Remove(gPlayers
[a
].UID
);
6160 if NetUseMaster
then
6162 // Åñëè íå ïåðåìåøàòü, ïðè äîáàâëåíèè íîâûõ áîòîâ ïîÿâÿòñÿ ñòàðûå
6166 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6168 else if cmd
= 'kick_id' then
6170 if g_Game_IsServer
and g_Game_IsNet
then
6172 if Length(P
) < 2 then
6174 g_Console_Add('kick_id <client ID>');
6179 g_Console_Add('kick_id <client ID>');
6183 a
:= StrToIntDef(P
[1], 0);
6184 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
6186 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
6188 s
:= g_Net_ClientName_ByID(NetClients
[a
].ID
);
6189 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_KICK
);
6190 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
6191 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
6192 if NetUseMaster
then
6197 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6199 else if cmd
= 'ban' then
6201 if g_Game_IsServer
and g_Game_IsNet
then
6203 if Length(P
) < 2 then
6205 g_Console_Add('ban <name>');
6210 g_Console_Add('ban <name>');
6214 pl
:= g_Net_Client_ByName(P
[1]);
6217 s
:= g_Net_ClientName_ByID(pl
^.ID
);
6218 g_Net_BanHost(pl
^.Peer
^.address
.host
, False);
6219 enet_peer_disconnect(pl
^.Peer
, NET_DISC_TEMPBAN
);
6220 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
6221 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
6222 if NetUseMaster
then
6225 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
6227 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6229 else if cmd
= 'ban_id' then
6231 if g_Game_IsServer
and g_Game_IsNet
then
6233 if Length(P
) < 2 then
6235 g_Console_Add('ban_id <client ID>');
6240 g_Console_Add('ban_id <client ID>');
6244 a
:= StrToIntDef(P
[1], 0);
6245 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
6246 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
6248 s
:= g_Net_ClientName_ByID(NetClients
[a
].ID
);
6249 g_Net_BanHost(NetClients
[a
].Peer
^.address
.host
, False);
6250 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_TEMPBAN
);
6251 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
6252 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
6253 if NetUseMaster
then
6257 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6259 else if cmd
= 'permban' then
6261 if g_Game_IsServer
and g_Game_IsNet
then
6263 if Length(P
) < 2 then
6265 g_Console_Add('permban <name>');
6270 g_Console_Add('permban <name>');
6274 pl
:= g_Net_Client_ByName(P
[1]);
6277 s
:= g_Net_ClientName_ByID(pl
^.ID
);
6278 g_Net_BanHost(pl
^.Peer
^.address
.host
);
6279 enet_peer_disconnect(pl
^.Peer
, NET_DISC_BAN
);
6280 g_Net_SaveBanList();
6281 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
6282 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
6283 if NetUseMaster
then
6286 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
6288 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6290 else if cmd
= 'permban_id' then
6292 if g_Game_IsServer
and g_Game_IsNet
then
6294 if Length(P
) < 2 then
6296 g_Console_Add('permban_id <client ID>');
6301 g_Console_Add('permban_id <client ID>');
6305 a
:= StrToIntDef(P
[1], 0);
6306 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
6307 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
6309 s
:= g_Net_ClientName_ByID(NetClients
[a
].ID
);
6310 g_Net_BanHost(NetClients
[a
].Peer
^.address
.host
);
6311 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_BAN
);
6312 g_Net_SaveBanList();
6313 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
6314 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
6315 if NetUseMaster
then
6319 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6321 else if cmd
= 'unban' then
6323 if g_Game_IsServer
and g_Game_IsNet
then
6325 if Length(P
) < 2 then
6327 g_Console_Add('unban <IP Address>');
6332 g_Console_Add('unban <IP Address>');
6336 if g_Net_UnbanHost(P
[1]) then
6338 g_Console_Add(Format(_lc
[I_MSG_UNBAN_OK
], [P
[1]]));
6339 g_Net_SaveBanList();
6341 g_Console_Add(Format(_lc
[I_MSG_UNBAN_FAIL
], [P
[1]]));
6343 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6345 else if cmd
= 'clientlist' then
6347 if g_Game_IsServer
and g_Game_IsNet
then
6350 if NetClients
<> nil then
6351 for a
:= Low(NetClients
) to High(NetClients
) do
6352 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
6354 plr
:= g_Player_Get(NetClients
[a
].Player
);
6355 if plr
= nil then continue
;
6357 g_Console_Add(Format('#%2d: %-15s | %s', [a
,
6358 IpToStr(NetClients
[a
].Peer
^.address
.host
), plr
.Name
]));
6361 g_Console_Add(_lc
[I_MSG_NOCLIENTS
]);
6363 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6365 else if cmd
= 'connect' then
6367 if (NetMode
= NET_NONE
) then
6369 if Length(P
) < 2 then
6371 g_Console_Add('connect <IP> [port] [password]');
6376 g_Console_Add('connect <IP> [port] [password]');
6380 if Length(P
) > 2 then
6381 prt
:= StrToIntDef(P
[2], 25666)
6385 if Length(P
) > 3 then
6390 g_Game_StartClient(P
[1], prt
, pw
);
6393 else if cmd
= 'disconnect' then
6395 if (NetMode
= NET_CLIENT
) then
6398 else if cmd
= 'reconnect' then
6400 if (NetMode
= NET_SERVER
) then
6403 if (NetMode
= NET_CLIENT
) then
6406 gExit
:= EXIT_SIMPLE
;
6410 //TODO: Use last successful password to reconnect, instead of ''
6411 g_Game_StartClient(NetClientIP
, NetClientPort
, '');
6413 else if (cmd
= 'addbot') or
6414 (cmd
= 'bot_add') then
6416 if Length(P
) > 2 then
6417 g_Bot_Add(TEAM_NONE
, StrToIntDef(P
[1], 2), StrToIntDef(P
[2], 100))
6418 else if Length(P
) > 1 then
6419 g_Bot_Add(TEAM_NONE
, StrToIntDef(P
[1], 2))
6421 g_Bot_Add(TEAM_NONE
, 2);
6423 else if cmd
= 'bot_addlist' then
6425 if Length(P
) > 1 then
6427 if Length(P
) = 2 then
6428 g_Bot_AddList(TEAM_NONE
, P
[1], StrToIntDef(P
[1], -1))
6429 else if Length(P
) = 3 then
6430 g_Bot_AddList(TEAM_NONE
, P
[1], StrToIntDef(P
[1], -1), StrToIntDef(P
[2], 100))
6432 g_Bot_AddList(IfThen(P
[2] = 'red', TEAM_RED
, TEAM_BLUE
), P
[1], StrToIntDef(P
[1], -1));
6435 else if cmd
= 'bot_removeall' then
6437 else if cmd
= 'chat' then
6439 if g_Game_IsNet
then
6441 if Length(P
) > 1 then
6443 for a
:= 1 to High(P
) do
6444 chstr
:= chstr
+ P
[a
] + ' ';
6446 if Length(chstr
) > 200 then SetLength(chstr
, 200);
6448 if Length(chstr
) < 1 then
6450 g_Console_Add('chat <text>');
6454 chstr
:= b_Text_Format(chstr
);
6455 if g_Game_IsClient
then
6456 MC_SEND_Chat(chstr
, NET_CHAT_PLAYER
)
6458 MH_SEND_Chat(gPlayer1Settings
.Name
+ ': ' + chstr
, NET_CHAT_PLAYER
);
6461 g_Console_Add('chat <text>');
6463 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6465 else if cmd
= 'teamchat' then
6467 if g_Game_IsNet
and (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
6469 if Length(P
) > 1 then
6471 for a
:= 1 to High(P
) do
6472 chstr
:= chstr
+ P
[a
] + ' ';
6474 if Length(chstr
) > 200 then SetLength(chstr
, 200);
6476 if Length(chstr
) < 1 then
6478 g_Console_Add('teamchat <text>');
6482 chstr
:= b_Text_Format(chstr
);
6483 if g_Game_IsClient
then
6484 MC_SEND_Chat(chstr
, NET_CHAT_TEAM
)
6486 MH_SEND_Chat(gPlayer1Settings
.Name
+ ': ' + chstr
, NET_CHAT_TEAM
,
6487 gPlayer1Settings
.Team
);
6490 g_Console_Add('teamchat <text>');
6492 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6494 else if cmd
= 'game' then
6496 if gGameSettings
.GameType
<> GT_NONE
then
6498 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6501 if Length(P
) = 1 then
6503 g_Console_Add(cmd
+ ' <WAD> [MAP] [# players]');
6506 // Èãðà åù¸ íå çàïóùåíà, ñíà÷àëà íàì íàäî çàãðóçèòü êàêîé-òî WAD
6507 P
[1] := addWadExtension(P
[1]);
6508 if FileExists(MapsDir
+ P
[1]) then
6510 // Åñëè êàðòà íå óêàçàíà, áåð¸ì ïåðâóþ êàðòó â ôàéëå
6511 if Length(P
) < 3 then
6514 P
[2] := g_Game_GetFirstMap(MapsDir
+ P
[1]);
6517 s
:= P
[1] + ':\' + UpperCase(P
[2]);
6519 if g_Map_Exist(MapsDir
+ s
) then
6521 // Çàïóñêàåì ñâîþ èãðó
6523 with gGameSettings
do
6525 GameMode
:= g_Game_TextToMode(gcGameMode
);
6526 if gSwitchGameMode
<> GM_NONE
then
6527 GameMode
:= gSwitchGameMode
;
6528 if GameMode
= GM_NONE
then GameMode
:= GM_DM
;
6529 if GameMode
= GM_SINGLE
then GameMode
:= GM_COOP
;
6531 if Length(P
) >= 4 then
6532 b
:= StrToIntDef(P
[3], 1);
6533 g_Game_StartCustom(s
, GameMode
, TimeLimit
,
6534 GoalLimit
, MaxLives
, Options
, b
);
6539 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
6541 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [UpperCase(P
[2]), P
[1]]));
6543 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]));
6545 else if cmd
= 'host' then
6547 if gGameSettings
.GameType
<> GT_NONE
then
6549 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6552 if Length(P
) < 4 then
6554 g_Console_Add(cmd
+ ' <listen IP> <port> <WAD> [MAP] [# players]');
6557 if not StrToIp(P
[1], listen
) then
6559 prt
:= StrToIntDef(P
[2], 25666);
6561 P
[3] := addWadExtension(P
[3]);
6562 if FileExists(MapsDir
+ P
[3]) then
6564 // Åñëè êàðòà íå óêàçàíà, áåð¸ì ïåðâóþ êàðòó â ôàéëå
6565 if Length(P
) < 5 then
6568 P
[4] := g_Game_GetFirstMap(MapsDir
+ P
[1]);
6571 s
:= P
[3] + ':\' + UpperCase(P
[4]);
6573 if g_Map_Exist(MapsDir
+ s
) then
6575 // Çàïóñêàåì ñâîþ èãðó
6577 with gGameSettings
do
6579 GameMode
:= g_Game_TextToMode(gcGameMode
);
6580 if gSwitchGameMode
<> GM_NONE
then
6581 GameMode
:= gSwitchGameMode
;
6582 if GameMode
= GM_NONE
then GameMode
:= GM_DM
;
6583 if GameMode
= GM_SINGLE
then GameMode
:= GM_COOP
;
6585 if Length(P
) >= 6 then
6586 b
:= StrToIntDef(P
[5], 0);
6587 g_Game_StartServer(s
, GameMode
, TimeLimit
,
6588 GoalLimit
, MaxLives
, Options
, b
, listen
, prt
);
6593 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[3]]))
6595 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [UpperCase(P
[4]), P
[3]]));
6597 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[3]]));
6599 else if cmd
= 'map' then
6601 if Length(P
) = 1 then
6603 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
6605 g_Console_Add(cmd
+ ' <MAP>');
6606 g_Console_Add(cmd
+ ' <WAD> [MAP]');
6608 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6610 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
6612 // Èä¸ò ñâîÿ èãðà èëè ñåðâåð
6613 if Length(P
) < 3 then
6615 // Ïåðâûé ïàðàìåòð - ëèáî êàðòà, ëèáî èìÿ WAD ôàéëà
6616 s
:= UpperCase(P
[1]);
6617 if g_Map_Exist(MapsDir
+ gGameSettings
.WAD
+ ':\' + s
) then
6618 begin // Êàðòà íàøëàñü
6619 gExitByTrigger
:= False;
6621 begin // Èä¸ò èãðà - çàâåðøàåì óðîâåíü
6623 gExit
:= EXIT_ENDLEVELCUSTOM
;
6625 else // Èíòåðìèññèÿ - ñðàçó çàãðóæàåì êàðòó
6626 g_Game_ChangeMap(s
);
6629 // Òàêîé êàðòû íåò, èùåì WAD ôàéë
6630 pw
:= findDiskWad(MapsDir
+ P
[1]);
6631 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [s
, 'WAD ' + P
[1]]));
6632 if FileExists(pw
) then
6634 // Ïàðàìåòðà êàðòû íåò, ïîýòîìó ñòàâèì ïåðâóþ èç ôàéëà
6636 P
[1] := ExtractRelativePath(MapsDir
, pw
);
6637 P
[2] := g_Game_GetFirstMap(MapsDir
+ P
[1]);
6639 s
:= P
[1] + ':\' + P
[2];
6641 if g_Map_Exist(MapsDir
+ s
) then
6643 gExitByTrigger
:= False;
6645 begin // Èä¸ò èãðà - çàâåðøàåì óðîâåíü
6647 gExit
:= EXIT_ENDLEVELCUSTOM
;
6649 else // Èíòåðìèññèÿ - ñðàçó çàãðóæàåì êàðòó
6650 g_Game_ChangeMap(s
);
6653 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
6655 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]));
6657 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]));
6661 // Óêàçàíî äâà ïàðàìåòðà, çíà÷èò ïåðâûé - WAD ôàéë, à âòîðîé - êàðòà
6662 P
[1] := addWadExtension(P
[1]);
6663 if FileExists(MapsDir
+ P
[1]) then
6666 P
[2] := UpperCase(P
[2]);
6667 s
:= P
[1] + ':\' + P
[2];
6669 if g_Map_Exist(MapsDir
+ s
) then
6670 begin // Íàøëè êàðòó
6671 gExitByTrigger
:= False;
6673 begin // Èä¸ò èãðà - çàâåðøàåì óðîâåíü
6675 gExit
:= EXIT_ENDLEVELCUSTOM
;
6677 else // Èíòåðìèññèÿ - ñðàçó çàãðóæàåì êàðòó
6678 g_Game_ChangeMap(s
);
6680 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]));
6682 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]));
6685 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6687 else if cmd
= 'nextmap' then
6689 if not(gGameOn
or (gState
= STATE_INTERCUSTOM
)) then
6690 g_Console_Add(_lc
[I_MSG_NOT_GAME
])
6693 if Length(P
) = 1 then
6695 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
6697 g_Console_Add(cmd
+ ' <MAP>');
6698 g_Console_Add(cmd
+ ' <WAD> [MAP]');
6701 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6706 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
6708 if Length(P
) < 3 then
6710 // Ïåðâûé ïàðàìåòð - ëèáî êàðòà, ëèáî èìÿ WAD ôàéëà
6711 s
:= UpperCase(P
[1]);
6712 if g_Map_Exist(MapsDir
+ gGameSettings
.WAD
+ ':\' + s
) then
6713 begin // Êàðòà íàøëàñü
6714 gExitByTrigger
:= False;
6719 // Òàêîé êàðòû íåò, èùåì WAD ôàéë
6720 P
[1] := addWadExtension(P
[1]);
6721 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [s
, P
[1]]));
6722 if FileExists(MapsDir
+ P
[1]) then
6724 // Ïàðàìåòðà êàðòû íåò, ïîýòîìó ñòàâèì ïåðâóþ èç ôàéëà
6726 P
[2] := g_Game_GetFirstMap(MapsDir
+ P
[1]);
6728 s
:= P
[1] + ':\' + P
[2];
6730 if g_Map_Exist(MapsDir
+ s
) then
6731 begin // Óñòàíàâëèâàåì êàðòó
6732 gExitByTrigger
:= False;
6737 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
6739 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]));
6741 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]));
6745 // Óêàçàíî äâà ïàðàìåòðà, çíà÷èò ïåðâûé - WAD ôàéë, à âòîðîé - êàðòà
6746 P
[1] := addWadExtension(P
[1]);
6747 if FileExists(MapsDir
+ P
[1]) then
6750 P
[2] := UpperCase(P
[2]);
6751 s
:= P
[1] + ':\' + P
[2];
6753 if g_Map_Exist(MapsDir
+ s
) then
6754 begin // Íàøëè êàðòó
6755 gExitByTrigger
:= False;
6759 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]));
6761 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]));
6764 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6767 if gNextMap
= '' then
6768 g_Console_Add(_lc
[I_MSG_NEXTMAP_UNSET
])
6770 g_Console_Add(Format(_lc
[I_MSG_NEXTMAP_SET
], [gNextMap
]));
6773 else if (cmd
= 'endmap') or (cmd
= 'goodbye') then
6776 g_Console_Add(_lc
[I_MSG_NOT_GAME
])
6778 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
6780 gExitByTrigger
:= False;
6781 // Ñëåäóþùàÿ êàðòà íå çàäàíà, ïðîáóåì íàéòè òðèããåð Âûõîä
6782 if (gNextMap
= '') and (gTriggers
<> nil) then
6783 for a
:= 0 to High(gTriggers
) do
6784 if gTriggers
[a
].TriggerType
= TRIGGER_EXIT
then
6786 gExitByTrigger
:= True;
6787 //gNextMap := gTriggers[a].Data.MapName;
6788 gNextMap
:= gTriggers
[a
].tgcMap
;
6791 // Èùåì ñëåäóþùóþ êàðòó â WAD ôàéëå
6792 if gNextMap
= '' then
6793 gNextMap
:= g_Game_GetNextMap();
6794 // Ïðîâåðÿåì, íå çàäàí ëè WAD ôàéë ðåñóðñíîé ñòðîêîé
6795 if not isWadPath(gNextMap
) then
6796 s
:= gGameSettings
.WAD
+ ':\' + gNextMap
6799 // Åñëè êàðòà íàéäåíà, âûõîäèì ñ óðîâíÿ
6800 if g_Map_Exist(MapsDir
+ s
) then
6801 gExit
:= EXIT_ENDLEVELCUSTOM
6803 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [gNextMap
]));
6805 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6807 else if (cmd
= 'event') then
6809 if (Length(P
) <= 1) then
6811 for a
:= 0 to High(gEvents
) do
6812 if gEvents
[a
].Command
= '' then
6813 g_Console_Add(gEvents
[a
].Name
+ ' <none>')
6815 g_Console_Add(gEvents
[a
].Name
+ ' "' + gEvents
[a
].Command
+ '"');
6818 if (Length(P
) = 2) then
6820 for a
:= 0 to High(gEvents
) do
6821 if gEvents
[a
].Name
= P
[1] then
6822 if gEvents
[a
].Command
= '' then
6823 g_Console_Add(gEvents
[a
].Name
+ ' <none>')
6825 g_Console_Add(gEvents
[a
].Name
+ ' "' + gEvents
[a
].Command
+ '"');
6828 for a
:= 0 to High(gEvents
) do
6829 if gEvents
[a
].Name
= P
[1] then
6831 gEvents
[a
].Command
:= '';
6832 for b
:= 2 to High(P
) do
6833 if Pos(' ', P
[b
]) = 0 then
6834 gEvents
[a
].Command
:= gEvents
[a
].Command
+ ' ' + P
[b
]
6836 gEvents
[a
].Command
:= gEvents
[a
].Command
+ ' "' + P
[b
] + '"';
6837 gEvents
[a
].Command
:= Trim(gEvents
[a
].Command
);
6841 else if cmd
= 'suicide' then
6845 if g_Game_IsClient
then
6846 MC_SEND_CheatRequest(NET_CHEAT_SUICIDE
)
6849 if gPlayer1
<> nil then
6850 gPlayer1
.Damage(SUICIDE_DAMAGE
, gPlayer1
.UID
, 0, 0, HIT_SELF
);
6851 if gPlayer2
<> nil then
6852 gPlayer2
.Damage(SUICIDE_DAMAGE
, gPlayer2
.UID
, 0, 0, HIT_SELF
);
6856 else if cmd
= 'screenshot' then
6860 else if cmd
= 'weapon' then
6862 if Length(p
) = 2 then
6864 a
:= WP_FIRST
+ StrToInt(p
[1]) - 1;
6865 if (a
>= WP_FIRST
) and (a
<= WP_LAST
) then
6866 gSelectWeapon
[0, a
] := True
6869 else if (cmd
= 'p1_weapon') or (cmd
= 'p2_weapon') then
6871 if Length(p
) = 2 then
6873 a
:= WP_FIRST
+ StrToInt(p
[1]) - 1;
6874 b
:= ord(cmd
[2]) - ord('1');
6875 if (a
>= WP_FIRST
) and (a
<= WP_LAST
) then
6876 gSelectWeapon
[b
, a
] := True
6879 // Êîìàíäû Ñâîåé èãðû:
6880 else if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
6882 if cmd
= 'bot_addred' then
6884 if Length(P
) > 1 then
6885 g_Bot_Add(TEAM_RED
, StrToIntDef(P
[1], 2))
6887 g_Bot_Add(TEAM_RED
, 2);
6889 else if cmd
= 'bot_addblue' then
6891 if Length(P
) > 1 then
6892 g_Bot_Add(TEAM_BLUE
, StrToIntDef(P
[1], 2))
6894 g_Bot_Add(TEAM_BLUE
, 2);
6896 else if cmd
= 'spectate' then
6902 else if cmd
= 'say' then
6904 if g_Game_IsServer
and g_Game_IsNet
then
6906 if Length(P
) > 1 then
6909 for a
:= 1 to High(P
) do
6910 chstr
:= chstr
+ P
[a
] + ' ';
6912 if Length(chstr
) > 200 then SetLength(chstr
, 200);
6914 if Length(chstr
) < 1 then
6916 g_Console_Add('say <text>');
6920 chstr
:= b_Text_Format(chstr
);
6921 MH_SEND_Chat(chstr
, NET_CHAT_PLAYER
);
6923 else g_Console_Add('say <text>');
6925 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6927 else if cmd
= 'tell' then
6929 if g_Game_IsServer
and g_Game_IsNet
then
6931 if (Length(P
) > 2) and (P
[1] <> '') then
6934 for a
:= 2 to High(P
) do
6935 chstr
:= chstr
+ P
[a
] + ' ';
6937 if Length(chstr
) > 200 then SetLength(chstr
, 200);
6939 if Length(chstr
) < 1 then
6941 g_Console_Add('tell <playername> <text>');
6945 pl
:= g_Net_Client_ByName(P
[1]);
6947 MH_SEND_Chat(b_Text_Format(chstr
), NET_CHAT_PLAYER
, pl
^.ID
)
6949 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
6951 else g_Console_Add('tell <playername> <text>');
6953 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6955 else if (cmd
= 'overtime') and not g_Game_IsClient
then
6957 if (Length(P
) = 1) or (StrToIntDef(P
[1], -1) <= 0) then
6959 // Äîïîëíèòåëüíîå âðåìÿ:
6960 gGameSettings
.TimeLimit
:= (gTime
- gGameStartTime
) div 1000 + Word(StrToIntDef(P
[1], 0));
6962 g_Console_Add(Format(_lc
[I_MSG_TIME_LIMIT
],
6963 [gGameSettings
.TimeLimit
div 3600,
6964 (gGameSettings
.TimeLimit
div 60) mod 60,
6965 gGameSettings
.TimeLimit
mod 60]));
6966 if g_Game_IsNet
then MH_SEND_GameSettings
;
6968 else if (cmd
= 'rcon_password') and g_Game_IsClient
then
6970 if (Length(P
) <= 1) then
6971 g_Console_Add('rcon_password <password>')
6973 MC_SEND_RCONPassword(P
[1]);
6975 else if cmd
= 'rcon' then
6977 if g_Game_IsClient
then
6979 if Length(P
) > 1 then
6982 for a
:= 1 to High(P
) do
6983 chstr
:= chstr
+ P
[a
] + ' ';
6985 if Length(chstr
) > 200 then SetLength(chstr
, 200);
6987 if Length(chstr
) < 1 then
6989 g_Console_Add('rcon <command>');
6993 MC_SEND_RCONCommand(chstr
);
6995 else g_Console_Add('rcon <command>');
6998 else if cmd
= 'ready' then
7000 if g_Game_IsServer
and (gLMSRespawn
= LMS_RESPAWN_WARMUP
) then
7001 gLMSRespawnTime
:= gTime
+ 100;
7003 else if (cmd
= 'callvote') and g_Game_IsNet
then
7005 if Length(P
) > 1 then
7008 for a
:= 1 to High(P
) do begin
7009 if a
> 1 then chstr
:= chstr
+ ' ';
7010 chstr
:= chstr
+ P
[a
];
7013 if Length(chstr
) > 200 then SetLength(chstr
, 200);
7015 if Length(chstr
) < 1 then
7017 g_Console_Add('callvote <command>');
7021 if g_Game_IsClient
then
7022 MC_SEND_Vote(True, chstr
)
7024 g_Game_StartVote(chstr
, gPlayer1Settings
.Name
);
7025 g_Console_Process('vote', True);
7028 g_Console_Add('callvote <command>');
7030 else if (cmd
= 'vote') and g_Game_IsNet
then
7032 if g_Game_IsClient
then
7034 else if gVoteInProgress
then
7036 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
7037 a
:= Floor((NetClientCount
+1)/2.0) + 1
7039 a
:= Floor(NetClientCount
/2.0) + 1;
7044 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_REVOKED
], [gPlayer1Settings
.Name
, gVoteCount
, a
]), True);
7045 MH_SEND_VoteEvent(NET_VE_REVOKE
, gPlayer1Settings
.Name
, 'a', gVoteCount
, a
);
7051 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_VOTE
], [gPlayer1Settings
.Name
, gVoteCount
, a
]), True);
7052 MH_SEND_VoteEvent(NET_VE_VOTE
, gPlayer1Settings
.Name
, 'a', gVoteCount
, a
);
7060 procedure g_TakeScreenShot();
7068 if e_NoGraphics
then Exit
;
7069 ssdir
:= GameDir
+'/screenshots';
7070 if not findFileCI(ssdir
, true) then
7072 // try to create dir
7077 if not findFileCI(ssdir
, true) then exit
; // alas
7080 for a
:= 1 to High(Word) do
7082 FileName
:= Format(ssdir
+'screenshot%.3d.png', [a
]);
7084 if findFileCI(t
, true) then continue
;
7085 if not findFileCI(FileName
) then
7088 st
:= createDiskFile(FileName
);
7090 e_MakeScreenshot(st
, gScreenWidth
, gScreenHeight
);
7095 if not ok
then try DeleteFile(FileName
); except end else g_Console_Add(Format(_lc
[I_CONSOLE_SCREENSHOT
], [ExtractFileName(FileName
)]));
7103 procedure g_Game_InGameMenu(Show
: Boolean);
7105 if (g_ActiveWindow
= nil) and Show
then
7107 if gGameSettings
.GameType
= GT_SINGLE
then
7108 g_GUI_ShowWindow('GameSingleMenu')
7111 if g_Game_IsClient
then
7112 g_GUI_ShowWindow('GameClientMenu')
7114 if g_Game_IsNet
then
7115 g_GUI_ShowWindow('GameServerMenu')
7117 g_GUI_ShowWindow('GameCustomMenu');
7119 g_Sound_PlayEx('MENU_OPEN');
7121 // Ïàóçà ïðè ìåíþ òîëüêî â îäèíî÷íîé èãðå:
7122 if (not g_Game_IsNet
) then
7126 if (g_ActiveWindow
<> nil) and (not Show
) then
7128 // Ïàóçà ïðè ìåíþ òîëüêî â îäèíî÷íîé èãðå:
7129 if (not g_Game_IsNet
) then
7130 g_Game_Pause(False);
7134 procedure g_Game_Pause (Enable
: Boolean);
7138 if not gGameOn
then exit
;
7140 if not (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
]) then exit
;
7143 gPauseMain
:= Enable
;
7145 if (gPause
<> oldPause
) then g_Game_PauseAllSounds(gPause
);
7148 procedure g_Game_HolmesPause (Enable
: Boolean);
7152 if not gGameOn
then exit
;
7153 if not (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
]) then exit
;
7156 gPauseHolmes
:= Enable
;
7158 if (gPause
<> oldPause
) then g_Game_PauseAllSounds(gPause
);
7161 procedure g_Game_PauseAllSounds(Enable
: Boolean);
7166 if gTriggers
<> nil then
7167 for i
:= 0 to High(gTriggers
) do
7168 with gTriggers
[i
] do
7169 if (TriggerType
= TRIGGER_SOUND
) and
7171 Sound
.IsPlaying() then
7173 Sound
.Pause(Enable
);
7177 if gPlayers
<> nil then
7178 for i
:= 0 to High(gPlayers
) do
7179 if gPlayers
[i
] <> nil then
7180 gPlayers
[i
].PauseSounds(Enable
);
7183 if gMusic
<> nil then
7184 gMusic
.Pause(Enable
);
7187 procedure g_Game_StopAllSounds(all
: Boolean);
7191 if gTriggers
<> nil then
7192 for i
:= 0 to High(gTriggers
) do
7193 with gTriggers
[i
] do
7194 if (TriggerType
= TRIGGER_SOUND
) and
7198 if gMusic
<> nil then
7205 procedure g_Game_UpdateTriggerSounds
;
7208 if gTriggers
<> nil then
7209 for i
:= 0 to High(gTriggers
) do
7210 with gTriggers
[i
] do
7211 if (TriggerType
= TRIGGER_SOUND
) and (Sound
<> nil) and tgcLocal
and Sound
.IsPlaying() then
7212 Sound
.SetCoordsRect(X
, Y
, Width
, Height
, tgcVolume
/ 255.0)
7215 function g_Game_IsWatchedPlayer(UID
: Word): Boolean;
7218 if (gPlayer1
<> nil) and (gPlayer1
.UID
= UID
) then
7223 if (gPlayer2
<> nil) and (gPlayer2
.UID
= UID
) then
7228 if gSpectMode
<> SPECT_PLAYERS
then
7230 if gSpectPID1
= UID
then
7235 if gSpectViewTwo
and (gSpectPID2
= UID
) then
7242 function g_Game_IsWatchedTeam(Team
: Byte): Boolean;
7247 if (gPlayer1
<> nil) and (gPlayer1
.Team
= Team
) then
7252 if (gPlayer2
<> nil) and (gPlayer2
.Team
= Team
) then
7257 if gSpectMode
<> SPECT_PLAYERS
then
7259 Pl
:= g_Player_Get(gSpectPID1
);
7260 if (Pl
<> nil) and (Pl
.Team
= Team
) then
7265 if gSpectViewTwo
then
7267 Pl
:= g_Player_Get(gSpectPID2
);
7268 if (Pl
<> nil) and (Pl
.Team
= Team
) then
7276 procedure g_Game_Message(Msg
: string; Time
: Word);
7278 MessageLineLength
:= (gScreenWidth
- 204) div e_CharFont_GetMaxWidth(gMenuFont
);
7279 MessageText
:= b_Text_Wrap(b_Text_Format(Msg
), MessageLineLength
);
7280 MessageTime
:= Time
;
7283 procedure g_Game_ChatSound(Text: String; Taunt
: Boolean = True);
7285 punct
: Array[0..13] of String =
7286 ('.', ',', ':', ';', '!', '?', '(', ')', '''', '"', '/', '\', '*', '^');
7292 function IsPunctuation(S
: String): Boolean;
7297 if Length(S
) <> 1 then
7299 for i
:= Low(punct
) to High(punct
) do
7300 if S
= punct
[i
] then
7306 function FilterPunctuation(S
: String): String;
7310 for i
:= Low(punct
) to High(punct
) do
7311 S
:= StringReplace(S
, punct
[i
], ' ', [rfReplaceAll
]);
7317 if gUseChatSounds
and Taunt
and (gChatSounds
<> nil) and (Pos(': ', Text) > 0) then
7319 // remove player name
7320 Delete(Text, 1, Pos(': ', Text) + 2 - 1);
7321 // for FullWord check
7322 Text := toLowerCase1251(' ' + Text + ' ');
7323 fpText
:= FilterPunctuation(Text);
7325 for i
:= 0 to Length(gChatSounds
) - 1 do
7328 for j
:= 0 to Length(gChatSounds
[i
].Tags
) - 1 do
7330 if gChatSounds
[i
].FullWord
and (not IsPunctuation(gChatSounds
[i
].Tags
[j
])) then
7331 ok
:= Pos(' ' + gChatSounds
[i
].Tags
[j
] + ' ', fpText
) > 0
7333 ok
:= Pos(gChatSounds
[i
].Tags
[j
], Text) > 0;
7339 gChatSounds
[i
].Sound
.Play();
7345 g_Sound_PlayEx('SOUND_GAME_RADIO');
7348 procedure g_Game_Announce_GoodShot(SpawnerUID
: Word);
7357 if not g_Game_IsWatchedPlayer(SpawnerUID
) then
7361 if goodsnd
[a
].IsPlaying() then
7364 goodsnd
[Random(4)].Play();
7367 procedure g_Game_Announce_KillCombo(Param
: Integer);
7374 UID
:= Param
and $FFFF;
7379 Pl
:= g_Player_Get(UID
);
7388 g_Console_Add(Format(_lc
[I_PLAYER_KILL_2X
], [Name
]), True);
7392 g_Console_Add(Format(_lc
[I_PLAYER_KILL_3X
], [Name
]), True);
7396 g_Console_Add(Format(_lc
[I_PLAYER_KILL_4X
], [Name
]), True);
7400 g_Console_Add(Format(_lc
[I_PLAYER_KILL_MX
], [Name
]), True);
7408 if not g_Game_IsWatchedPlayer(UID
) then
7411 if (not g_Game_IsWatchedPlayer(UID
)) and (c
< 4) then
7415 if killsnd
[n
].IsPlaying() then
7420 procedure g_Game_Announce_BodyKill(SpawnerUID
: Word);
7429 if not g_Game_IsWatchedPlayer(SpawnerUID
) then
7433 if hahasnd
[a
].IsPlaying() then
7436 hahasnd
[Random(3)].Play();
7439 procedure g_Game_StartVote(Command
, Initiator
: string);
7443 if not gVotesEnabled
then Exit
;
7444 if gGameSettings
.GameType
<> GT_SERVER
then Exit
;
7445 if gVoteInProgress
or gVotePassed
then
7447 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_INPROGRESS
], [gVoteCommand
]), True);
7448 MH_SEND_VoteEvent(NET_VE_INPROGRESS
, gVoteCommand
);
7451 gVoteInProgress
:= True;
7452 gVotePassed
:= False;
7453 gVoteTimer
:= gTime
+ gVoteTimeout
* 1000;
7456 gVoteCommand
:= Command
;
7458 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
7459 Need
:= Floor((NetClientCount
+1)/2.0)+1
7461 Need
:= Floor(NetClientCount
/2.0)+1;
7462 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_STARTED
], [Initiator
, Command
, Need
]), True);
7463 MH_SEND_VoteEvent(NET_VE_STARTED
, Initiator
, Command
, Need
);
7466 procedure g_Game_CheckVote
;
7470 if gGameSettings
.GameType
<> GT_SERVER
then Exit
;
7471 if not gVoteInProgress
then Exit
;
7473 if (gTime
>= gVoteTimer
) then
7475 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
7476 Need
:= Floor((NetClientCount
+1)/2.0) + 1
7478 Need
:= Floor(NetClientCount
/2.0) + 1;
7479 if gVoteCount
>= Need
then
7481 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_PASSED
], [gVoteCommand
]), True);
7482 MH_SEND_VoteEvent(NET_VE_PASSED
, gVoteCommand
);
7483 gVotePassed
:= True;
7484 gVoteCmdTimer
:= gTime
+ 5000;
7488 g_Console_Add(_lc
[I_MESSAGE_VOTE_FAILED
], True);
7489 MH_SEND_VoteEvent(NET_VE_FAILED
);
7491 if NetClients
<> nil then
7492 for I
:= Low(NetClients
) to High(NetClients
) do
7493 if NetClients
[i
].Used
then
7494 NetClients
[i
].Voted
:= False;
7495 gVoteInProgress
:= False;
7501 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
7502 Need
:= Floor((NetClientCount
+1)/2.0) + 1
7504 Need
:= Floor(NetClientCount
/2.0) + 1;
7505 if gVoteCount
>= Need
then
7507 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_PASSED
], [gVoteCommand
]), True);
7508 MH_SEND_VoteEvent(NET_VE_PASSED
, gVoteCommand
);
7509 gVoteInProgress
:= False;
7510 gVotePassed
:= True;
7511 gVoteCmdTimer
:= gTime
+ 5000;
7514 if NetClients
<> nil then
7515 for I
:= Low(NetClients
) to High(NetClients
) do
7516 if NetClients
[i
].Used
then
7517 NetClients
[i
].Voted
:= False;
7522 procedure g_Game_LoadMapList(FileName
: string);
7530 if not FileExists(FileName
) then Exit
;
7532 AssignFile(ListFile
, FileName
);
7534 while not EOF(ListFile
) do
7536 ReadLn(ListFile
, s
);
7539 if s
= '' then Continue
;
7541 SetLength(MapList
, Length(MapList
)+1);
7542 MapList
[High(MapList
)] := s
;
7544 CloseFile(ListFile
);
7547 procedure g_Game_SetDebugMode();
7550 // ×èòû (äàæå â ñâîåé èãðå):
7554 procedure g_Game_SetLoadingText(Text: String; Max
: Integer; reWrite
: Boolean);
7558 if Length(LoadingStat
.Msgs
) = 0 then
7564 begin // Ïåðåõîäèì íà ñëåäóþùóþ ñòðîêó èëè ñêðîëëèðóåì:
7565 if NextMsg
= Length(Msgs
) then
7567 for i
:= 0 to High(Msgs
)-1 do
7568 Msgs
[i
] := Msgs
[i
+1];
7576 Msgs
[NextMsg
-1] := Text;
7580 PBarWasHere
:= false;
7583 g_ActiveWindow
:= nil;
7585 ProcessLoading(true);
7588 procedure g_Game_StepLoading(Value
: Integer = -1);
7599 if (ShowCount
> LOADING_SHOW_STEP
) or (Value
> -1) then
7607 procedure g_Game_ClearLoading();
7616 len
:= ((gScreenHeight
div 3)*2 - 50) div LOADING_INTERLINE
;
7617 if len
< 1 then len
:= 1;
7618 SetLength(Msgs
, len
);
7619 for len
:= Low(Msgs
) to High(Msgs
) do
7622 PBarWasHere
:= false;
7626 procedure Parse_Params(var pars
: TParamStrValues
);
7633 while i
<= ParamCount
do
7636 if (s
[1] = '-') and (Length(s
) > 1) then
7638 if (s
[2] = '-') and (Length(s
) > 2) then
7639 begin // Îäèíî÷íûé ïàðàìåòð
7640 SetLength(pars
, Length(pars
) + 1);
7641 with pars
[High(pars
)] do
7643 Name
:= LowerCase(s
);
7648 if (i
< ParamCount
) then
7649 begin // Ïàðàìåòð ñî çíà÷åíèåì
7651 SetLength(pars
, Length(pars
) + 1);
7652 with pars
[High(pars
)] do
7654 Name
:= LowerCase(s
);
7655 Value
:= LowerCase(ParamStr(i
));
7664 function Find_Param_Value(var pars
: TParamStrValues
; aName
: String): String;
7669 for i
:= 0 to High(pars
) do
7670 if pars
[i
].Name
= aName
then
7672 Result
:= pars
[i
].Value
;
7677 procedure g_Game_Process_Params();
7679 pars
: TParamStrValues
;
7682 LimT
, LimS
: Integer;
7693 s
:= Find_Param_Value(pars
, '--debug');
7696 g_Game_SetDebugMode();
7697 s
:= Find_Param_Value(pars
, '--netdump');
7702 // Connect when game loads
7703 ip
:= Find_Param_Value(pars
, '-connect');
7707 s
:= Find_Param_Value(pars
, '-port');
7708 if (s
= '') or not TryStrToInt(s
, Port
) then
7711 s
:= Find_Param_Value(pars
, '-pw');
7713 g_Game_StartClient(ip
, Port
, s
);
7717 s
:= LowerCase(Find_Param_Value(pars
, '-dbg-mainwad'));
7720 gDefaultMegawadStart
:= s
;
7723 if (Find_Param_Value(pars
, '--dbg-mainwad-restore') <> '') or
7724 (Find_Param_Value(pars
, '--dbg-mainwad-default') <> '') then
7726 gDefaultMegawadStart
:= DF_Default_Megawad_Start
;
7729 // Start map when game loads:
7730 map
:= LowerCase(Find_Param_Value(pars
, '-map'));
7731 if isWadPath(map
) then
7734 s
:= Find_Param_Value(pars
, '-gm');
7735 GMode
:= g_Game_TextToMode(s
);
7736 if GMode
= GM_NONE
then GMode
:= GM_DM
;
7737 if GMode
= GM_SINGLE
then GMode
:= GM_COOP
;
7740 s
:= Find_Param_Value(pars
, '-limt');
7741 if (s
= '') or (not TryStrToInt(s
, LimT
)) then
7747 s
:= Find_Param_Value(pars
, '-lims');
7748 if (s
= '') or (not TryStrToInt(s
, LimS
)) then
7754 s
:= Find_Param_Value(pars
, '-lives');
7755 if (s
= '') or (not TryStrToInt(s
, Lives
)) then
7761 s
:= Find_Param_Value(pars
, '-opt');
7763 Opt
:= GAME_OPTION_ALLOWEXIT
or GAME_OPTION_BOTVSPLAYER
or GAME_OPTION_BOTVSMONSTER
7765 Opt
:= StrToIntDef(s
, 0);
7767 Opt
:= GAME_OPTION_ALLOWEXIT
or GAME_OPTION_BOTVSPLAYER
or GAME_OPTION_BOTVSMONSTER
;
7770 s
:= Find_Param_Value(pars
, '--close');
7774 // Override map to test:
7775 s
:= LowerCase(Find_Param_Value(pars
, '-testmap'));
7777 gTestMap
:= MapsDir
+ s
;
7779 // Delete test map after play:
7780 s
:= Find_Param_Value(pars
, '--testdelete');
7783 gMapToDelete
:= MapsDir
+ map
;
7784 e_WriteLog('"--testdelete" is deprecated, use --tempdelete.', TMsgType
.Fatal
);
7788 // Delete temporary WAD after play:
7789 s
:= Find_Param_Value(pars
, '--tempdelete');
7790 if (s
<> '') and (gTestMap
<> '') then
7792 gMapToDelete
:= gTestMap
;
7793 gTempDelete
:= True;
7796 // Number of players:
7797 s
:= Find_Param_Value(pars
, '-pl');
7799 n
:= DEFAULT_PLAYERS
7801 n
:= StrToIntDef(s
, DEFAULT_PLAYERS
);
7804 s
:= Find_Param_Value(pars
, '-port');
7805 if (s
= '') or not TryStrToInt(s
, Port
) then
7806 g_Game_StartCustom(map
, GMode
, LimT
, LimS
, Lives
, Opt
, n
)
7808 g_Game_StartServer(map
, GMode
, LimT
, LimS
, Lives
, Opt
, n
, 0, Port
);
7811 // Execute script when game loads:
7812 s
:= Find_Param_Value(pars
, '-exec');
7815 if not isWadPath(s
) then
7816 s
:= GameDir
+ '/' + s
;
7821 if IOResult
<> 0 then
7823 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], ['Failed to read file: ' + s
]), TMsgType
.Warning
);
7824 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_READ
], [s
]));
7828 e_WriteLog('Executing script: ' + s
, TMsgType
.Notify
);
7829 g_Console_Add(Format(_lc
[I_CONSOLE_EXEC
], [s
]));
7834 if IOResult
<> 0 then
7836 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], ['Failed to read file: ' + s
]), TMsgType
.Warning
);
7837 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_READ
], [s
]));
7841 if Pos('#', s
) <> 1 then // script comment
7842 g_Console_Process(s
, True);
7853 conRegVar('pf_draw_frame', @g_profile_frame_draw
, 'draw frame rendering profiles', 'render profiles');
7854 //conRegVar('pf_update_frame', @g_profile_frame_update, 'draw frame updating profiles', 'update profiles');
7855 conRegVar('pf_coldet', @g_profile_collision
, 'draw collision detection profiles', 'coldet profiles');
7856 conRegVar('pf_los', @g_profile_los
, 'draw monster LOS profiles', 'monster LOS profiles');
7858 conRegVar('r_sq_draw', @gdbg_map_use_accel_render
, 'accelerated spatial queries in rendering', 'accelerated rendering');
7859 conRegVar('cd_sq_enabled', @gdbg_map_use_accel_coldet
, 'accelerated spatial queries in map coldet', 'accelerated map coldet');
7860 conRegVar('mon_sq_enabled', @gmon_debug_use_sqaccel
, 'accelerated spatial queries for monsters', 'accelerated monster coldet');
7861 conRegVar('wtrace_sq_enabled', @gwep_debug_fast_trace
, 'accelerated spatial queries for weapon hitscan trace', 'accelerated weapon hitscan');
7863 conRegVar('pr_enabled', @gpart_dbg_enabled
, 'enable/disable particles', 'particles');
7864 conRegVar('pr_phys_enabled', @gpart_dbg_phys_enabled
, 'enable/disable particle physics', 'particle physics');
7866 conRegVar('los_enabled', @gmon_dbg_los_enabled
, 'enable/disable monster LOS calculations', 'monster LOS', true);
7867 conRegVar('mon_think', @gmon_debug_think
, 'enable/disable monster thinking', 'monster thinking', true);
7869 {$IFDEF ENABLE_HOLMES}
7870 conRegVar('dbg_holmes', @g_holmes_enabled
, 'enable/disable Holmes', 'Holmes', true);
7873 conRegVar('dbg_ignore_level_bounds', @g_dbg_ignore_bounds
, 'ignore level bounds', '', false);
7875 conRegVar('r_scale', @g_dbg_scale
, 0.01, 100.0, 'render scale', '', false);
7877 conRegVar('light_enabled', @gwin_k8_enable_light_experiments
, 'enable/disable dynamic lighting', 'lighting');
7878 conRegVar('light_player_halo', @g_playerLight
, 'enable/disable player halo', 'player light halo');
7880 conRegVar('r_smallmap_align_h', @r_smallmap_h
, 'halign: 0: left; 1: center; 2: right', 'horizontal aligning of small maps');
7881 conRegVar('r_smallmap_align_v', @r_smallmap_v
, 'valign: 0: top; 1: center; 2: bottom', 'vertial aligning of small maps');
7883 conRegVar('r_showfps', @gShowFPS
, 'draw fps counter', 'draw fps counter');
7884 conRegVar('r_showtime', @gShowTime
, 'show game time', 'show game time');