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);
1346 g_Game_SetLoadingText(_lc
[I_LOAD_MENUS
], 0, False);
1350 gMusic
:= TMusic
.Create();
1351 gMusic
.SetByName('MUSIC_MENU');
1354 gGameSettings
.WarmupTime
:= 30;
1356 gState
:= STATE_MENU
;
1358 SetLength(gEvents
, 6);
1359 gEvents
[0].Name
:= 'ongamestart';
1360 gEvents
[1].Name
:= 'ongameend';
1361 gEvents
[2].Name
:= 'onmapstart';
1362 gEvents
[3].Name
:= 'onmapend';
1363 gEvents
[4].Name
:= 'oninter';
1364 gEvents
[5].Name
:= 'onwadend';
1366 sfsGCEnable(); // enable releasing unused volumes
1370 procedure g_Game_Free(freeTextures
: Boolean=true);
1372 if NetMode
= NET_CLIENT
then g_Net_Disconnect();
1373 if NetMode
= NET_SERVER
then g_Net_Host_Die();
1375 g_Map_Free(freeTextures
);
1377 g_Player_RemoveAllCorpses();
1379 gGameSettings
.GameType
:= GT_NONE
;
1380 if gGameSettings
.GameMode
= GM_SINGLE
then
1381 gGameSettings
.GameMode
:= GM_DM
;
1382 gSwitchGameMode
:= gGameSettings
.GameMode
;
1385 gExitByTrigger
:= False;
1388 function IsActivePlayer(p
: TPlayer
): Boolean;
1393 Result
:= (not p
.FDummy
) and (not p
.FSpectator
);
1396 function GetActivePlayer_ByID(ID
: Integer): TPlayer
;
1403 if gPlayers
= nil then
1405 for a
:= Low(gPlayers
) to High(gPlayers
) do
1406 if IsActivePlayer(gPlayers
[a
]) then
1408 if gPlayers
[a
].UID
<> ID
then
1410 Result
:= gPlayers
[a
];
1415 function GetActivePlayerID_Next(Skip
: Integer = -1): Integer;
1421 if gPlayers
= nil then
1425 for a
:= Low(gPlayers
) to High(gPlayers
) do
1426 if IsActivePlayer(gPlayers
[a
]) then
1428 SetLength(ids
, Length(ids
) + 1);
1429 ids
[High(ids
)] := gPlayers
[a
].UID
;
1430 if gPlayers
[a
].UID
= Skip
then
1433 if Length(ids
) = 0 then
1438 Result
:= ids
[(idx
+ 1) mod Length(ids
)];
1441 function GetActivePlayerID_Prev(Skip
: Integer = -1): Integer;
1447 if gPlayers
= nil then
1451 for a
:= Low(gPlayers
) to High(gPlayers
) do
1452 if IsActivePlayer(gPlayers
[a
]) then
1454 SetLength(ids
, Length(ids
) + 1);
1455 ids
[High(ids
)] := gPlayers
[a
].UID
;
1456 if gPlayers
[a
].UID
= Skip
then
1459 if Length(ids
) = 0 then
1462 Result
:= ids
[Length(ids
) - 1]
1464 Result
:= ids
[(Length(ids
) - 1 + idx
) mod Length(ids
)];
1467 function GetActivePlayerID_Random(Skip
: Integer = -1): Integer;
1473 if gPlayers
= nil then
1477 for a
:= Low(gPlayers
) to High(gPlayers
) do
1478 if IsActivePlayer(gPlayers
[a
]) then
1480 SetLength(ids
, Length(ids
) + 1);
1481 ids
[High(ids
)] := gPlayers
[a
].UID
;
1482 if gPlayers
[a
].UID
= Skip
then
1485 if Length(ids
) = 0 then
1487 if Length(ids
) = 1 then
1492 Result
:= ids
[Random(Length(ids
))];
1494 while (idx
<> -1) and (Result
= Skip
) and (a
> 0) do
1496 Result
:= ids
[Random(Length(ids
))];
1501 function GetRandomSpectMode(Current
: Byte): Byte;
1508 0: Result
:= SPECT_STATS
;
1509 1: Result
:= SPECT_MAPVIEW
;
1510 2: Result
:= SPECT_MAPVIEW
;
1511 3: Result
:= SPECT_PLAYERS
;
1512 4: Result
:= SPECT_PLAYERS
;
1513 5: Result
:= SPECT_PLAYERS
;
1514 6: Result
:= SPECT_PLAYERS
;
1516 if (Current
in [SPECT_STATS
, SPECT_MAPVIEW
]) and (Current
= Result
) then
1520 procedure ProcessPlayerControls (plr
: TPlayer
; p
: Integer; var MoveButton
: Byte);
1526 if (plr
= nil) then exit
;
1527 if (p
= 2) then time
:= 1000 else time
:= 1;
1528 strafeDir
:= MoveButton
shr 4;
1529 MoveButton
:= MoveButton
and $0F;
1531 if gPlayerAction
[p
, ACTION_MOVELEFT
] and (not gPlayerAction
[p
, ACTION_MOVERIGHT
]) then
1532 MoveButton
:= 1 // Íàæàòà òîëüêî "Âëåâî"
1533 else if (not gPlayerAction
[p
, ACTION_MOVELEFT
]) and gPlayerAction
[p
, ACTION_MOVERIGHT
] then
1534 MoveButton
:= 2 // Íàæàòà òîëüêî "Âïðàâî"
1535 else if (not gPlayerAction
[p
, ACTION_MOVELEFT
]) and (not gPlayerAction
[p
, ACTION_MOVERIGHT
]) then
1536 MoveButton
:= 0; // Íå íàæàòû íè "Âëåâî", íè "Âïðàâî"
1538 // Ñåé÷àñ èëè ðàíüøå áûëè íàæàòû "Âëåâî"/"Âïðàâî" => ïåðåäàåì èãðîêó:
1539 if MoveButton
= 1 then
1540 plr
.PressKey(KEY_LEFT
, time
)
1541 else if MoveButton
= 2 then
1542 plr
.PressKey(KEY_RIGHT
, time
);
1544 // if we have "strafe" key, turn off old strafe mechanics
1545 if gPlayerAction
[p
, ACTION_STRAFE
] then
1547 // new strafe mechanics
1548 if (strafeDir
= 0) then
1549 strafeDir
:= MoveButton
; // start strafing
1550 // now set direction according to strafe (reversed)
1551 if (strafeDir
= 2) then
1552 plr
.SetDirection(TDirection
.D_LEFT
)
1553 else if (strafeDir
= 1) then
1554 plr
.SetDirection(TDirection
.D_RIGHT
)
1558 strafeDir
:= 0; // not strafing anymore
1559 // Ðàíüøå áûëà íàæàòà "Âïðàâî", à ñåé÷àñ "Âëåâî" => áåæèì âïðàâî, ñìîòðèì âëåâî:
1560 if (MoveButton
= 2) and gPlayerAction
[p
, ACTION_MOVELEFT
] then
1561 plr
.SetDirection(TDirection
.D_LEFT
)
1562 // Ðàíüøå áûëà íàæàòà "Âëåâî", à ñåé÷àñ "Âïðàâî" => áåæèì âëåâî, ñìîòðèì âïðàâî:
1563 else if (MoveButton
= 1) and gPlayerAction
[p
, ACTION_MOVERIGHT
] then
1564 plr
.SetDirection(TDirection
.D_RIGHT
)
1565 // ×òî-òî áûëî íàæàòî è íå èçìåíèëîñü => êóäà áåæèì, òóäà è ñìîòðèì:
1566 else if MoveButton
<> 0 then
1567 plr
.SetDirection(TDirection(MoveButton
-1))
1570 // fix movebutton state
1571 MoveButton
:= MoveButton
or (strafeDir
shl 4);
1573 // Îñòàëüíûå êëàâèøè:
1574 if gPlayerAction
[p
, ACTION_JUMP
] then plr
.PressKey(KEY_JUMP
, time
);
1575 if gPlayerAction
[p
, ACTION_LOOKUP
] then plr
.PressKey(KEY_UP
, time
);
1576 if gPlayerAction
[p
, ACTION_LOOKDOWN
] then plr
.PressKey(KEY_DOWN
, time
);
1577 if gPlayerAction
[p
, ACTION_ATTACK
] then plr
.PressKey(KEY_FIRE
);
1578 if gPlayerAction
[p
, ACTION_WEAPNEXT
] then plr
.PressKey(KEY_NEXTWEAPON
);
1579 if gPlayerAction
[p
, ACTION_WEAPPREV
] then plr
.PressKey(KEY_PREVWEAPON
);
1580 if gPlayerAction
[p
, ACTION_ACTIVATE
] then plr
.PressKey(KEY_OPEN
);
1582 gPlayerAction
[p
, ACTION_WEAPNEXT
] := False; // HACK, remove after readyweaon&pendinweapon implementation
1583 gPlayerAction
[p
, ACTION_WEAPPREV
] := False; // HACK, remove after readyweaon&pendinweapon implementation
1585 for i
:= WP_FIRST
to WP_LAST
do
1587 if gSelectWeapon
[p
, i
] then
1589 plr
.QueueWeaponSwitch(i
); // all choices are passed there, and god will take the best
1590 gSelectWeapon
[p
, i
] := False
1594 // HACK: add dynlight here
1595 if gwin_k8_enable_light_experiments
then
1597 if e_KeyPressed(IK_F8
) and gGameOn
and (not gConsoleShow
) and (g_ActiveWindow
= nil) then
1599 g_playerLight
:= true;
1601 if e_KeyPressed(IK_F9
) and gGameOn
and (not gConsoleShow
) and (g_ActiveWindow
= nil) then
1603 g_playerLight
:= false;
1607 if gwin_has_stencil
and g_playerLight
then g_AddDynLight(plr
.GameX
+32, plr
.GameY
+40, 128, 1, 1, 0, 0.6);
1610 // HACK: don't have a "key was pressed" function
1611 procedure InterReady();
1613 if InterReadyTime
> gTime
then Exit
;
1614 InterReadyTime
:= gTime
+ 3000;
1615 MC_SEND_CheatRequest(NET_CHEAT_READY
);
1618 procedure g_Game_Update();
1620 Msg
: g_gui
.TMessage
;
1626 function sendMonsPos (mon
: TMonster
): Boolean;
1628 result
:= false; // don't stop
1629 // this will also reset "need-send" flag
1630 if mon
.gncNeedSend
then
1632 MH_SEND_MonsterPos(mon
.UID
);
1634 else if (mon
.MonsterType
= MONSTER_BARREL
) then
1636 if (mon
.GameVelX
<> 0) or (mon
.GameVelY
<> 0) then MH_SEND_MonsterPos(mon
.UID
);
1638 else if (mon
.MonsterState
<> MONSTATE_SLEEP
) then
1640 if (mon
.MonsterState
<> MONSTATE_DEAD
) or (mon
.GameVelX
<> 0) or (mon
.GameVelY
<> 0) then MH_SEND_MonsterPos(mon
.UID
);
1644 function sendMonsPosUnexpected (mon
: TMonster
): Boolean;
1646 result
:= false; // don't stop
1647 // this will also reset "need-send" flag
1648 if mon
.gncNeedSend
then MH_SEND_MonsterPos(mon
.UID
);
1652 reliableUpdate
: Boolean;
1657 // Ïîðà âûêëþ÷àòü èãðó:
1658 if gExit
= EXIT_QUIT
then
1660 // Èãðà çàêîí÷èëàñü - îáðàáàòûâàåì:
1664 if gExit
= EXIT_QUIT
then
1668 // ×èòàåì êëàâèàòóðó è äæîéñòèê, åñëè îêíî àêòèâíî
1669 // no need to, as we'll do it in event handler
1671 // Îáíîâëÿåì êîíñîëü (äâèæåíèå è ñîîáùåíèÿ):
1674 if (NetMode
= NET_NONE
) and (g_Game_IsNet
) and (gGameOn
or (gState
in [STATE_FOLD
, STATE_INTERCUSTOM
])) then
1676 gExit
:= EXIT_SIMPLE
;
1682 STATE_INTERSINGLE
, // Ñòàòèñòêà ïîñëå ïðîõîæäåíèÿ óðîâíÿ â Îäèíî÷íîé èãðå
1683 STATE_INTERCUSTOM
, // Ñòàòèñòêà ïîñëå ïðîõîæäåíèÿ óðîâíÿ â Ñâîåé èãðå
1684 STATE_INTERTEXT
, // Òåêñò ìåæäó óðîâíÿìè
1685 STATE_INTERPIC
: // Êàðòèíêà ìåæäó óðîâíÿìè
1687 if g_Game_IsNet
and g_Game_IsServer
then
1689 gInterTime
:= gInterTime
+ GAME_TICK
;
1690 a
:= Min((gInterEndTime
- gInterTime
) div 1000 + 1, 255);
1691 if a
<> gServInterTime
then
1693 gServInterTime
:= a
;
1694 MH_SEND_TimeSync(gServInterTime
);
1698 if (not g_Game_IsClient
) and
1702 e_KeyPressed(IK_RETURN
) or e_KeyPressed(IK_KPRETURN
) or e_KeyPressed(IK_SPACE
) or
1703 e_KeyPressed(VK_FIRE
) or e_KeyPressed(VK_OPEN
) or
1704 e_KeyPressed(JOY0_ATTACK
) or e_KeyPressed(JOY1_ATTACK
) or
1705 e_KeyPressed(JOY2_ATTACK
) or e_KeyPressed(JOY3_ATTACK
)
1707 and (not gJustChatted
) and (not gConsoleShow
) and (not gChatShow
)
1708 and (g_ActiveWindow
= nil)
1710 or (g_Game_IsNet
and ((gInterTime
> gInterEndTime
) or (gInterReadyCount
>= NetClientCount
)))
1713 begin // Íàæàëè <Enter>/<Ïðîáåë> èëè ïðîøëî äîñòàòî÷íî âðåìåíè:
1714 g_Game_StopAllSounds(True);
1716 if gMapOnce
then // Ýòî áûë òåñò
1717 gExit
:= EXIT_SIMPLE
1719 if gNextMap
<> '' then // Ïåðåõîäèì íà ñëåäóþùóþ êàðòó
1720 g_Game_ChangeMap(gNextMap
)
1721 else // Ñëåäóþùåé êàðòû íåò
1723 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
] then
1725 // Âûõîä â ãëàâíîå ìåíþ:
1727 g_GUI_ShowWindow('MainMenu');
1728 gMusic
.SetByName('MUSIC_MENU');
1730 gState
:= STATE_MENU
;
1733 // Ôèíàëüíàÿ êàðòèíêà:
1734 g_Game_ExecuteEvent('onwadend');
1736 if not gMusic
.SetByName('MUSIC_endmus') then
1737 gMusic
.SetByName('MUSIC_STDENDMUS');
1739 gState
:= STATE_ENDPIC
;
1741 g_Game_ExecuteEvent('ongameend');
1746 else if g_Game_IsClient
and
1749 e_KeyPressed(IK_RETURN
) or e_KeyPressed(IK_KPRETURN
) or e_KeyPressed(IK_SPACE
) or
1750 e_KeyPressed(VK_FIRE
) or e_KeyPressed(VK_OPEN
) or
1751 e_KeyPressed(JOY0_ATTACK
) or e_KeyPressed(JOY1_ATTACK
) or
1752 e_KeyPressed(JOY2_ATTACK
) or e_KeyPressed(JOY3_ATTACK
)
1754 and (not gJustChatted
) and (not gConsoleShow
) and (not gChatShow
)
1755 and (g_ActiveWindow
= nil)
1763 if gState
= STATE_INTERTEXT
then
1764 if InterText
.counter
> 0 then
1765 InterText
.counter
:= InterText
.counter
- 1;
1768 STATE_FOLD
: // Çàòóõàíèå ýêðàíà
1770 if EndingGameCounter
= 0 then
1772 // Çàêîí÷èëñÿ óðîâåíü â Ñâîåé èãðå:
1773 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
1775 InterReadyTime
:= -1;
1776 if gLastMap
and (gGameSettings
.GameMode
= GM_COOP
) then
1778 g_Game_ExecuteEvent('onwadend');
1779 if not gMusic
.SetByName('MUSIC_endmus') then
1780 gMusic
.SetByName('MUSIC_STDENDMUS');
1783 gMusic
.SetByName('MUSIC_ROUNDMUS');
1786 gState
:= STATE_INTERCUSTOM
;
1789 else // Çàêîí÷èëàñü ïîñëåäíÿÿ êàðòà â Îäèíî÷íîé èãðå
1791 gMusic
.SetByName('MUSIC_INTERMUS');
1793 gState
:= STATE_INTERSINGLE
;
1796 g_Game_ExecuteEvent('oninter');
1799 DecMin(EndingGameCounter
, 6, 0);
1802 STATE_ENDPIC
: // Êàðòèíêà îêîí÷àíèÿ ìåãàÂàäà
1804 if gMapOnce
then // Ýòî áûë òåñò
1806 gExit
:= EXIT_SIMPLE
;
1812 g_Serverlist_Control(slCurrent
, slTable
);
1815 // Ñòàòèñòèêà ïî Tab:
1817 IsDrawStat
:= (not gConsoleShow
) and (not gChatShow
) and (gGameSettings
.GameType
<> GT_SINGLE
) and g_Console_Action(ACTION_SCORES
);
1820 if gGameOn
and not gPause
and (gState
<> STATE_FOLD
) then
1822 // Âðåìÿ += 28 ìèëëèñåêóíä:
1823 gTime
:= gTime
+ GAME_TICK
;
1825 // Ñîîáùåíèå ïîñåðåäèíå ýêðàíà:
1826 if MessageTime
= 0 then
1828 if MessageTime
> 0 then
1829 MessageTime
:= MessageTime
- 1;
1831 if (g_Game_IsServer
) then
1833 // Áûë çàäàí ëèìèò âðåìåíè:
1834 if (gGameSettings
.TimeLimit
> 0) then
1835 if (gTime
- gGameStartTime
) div 1000 >= gGameSettings
.TimeLimit
then
1836 begin // Îí ïðîøåë => êîíåö óðîâíÿ
1841 // Íàäî ðåñïàâíèòü èãðîêîâ â LMS:
1842 if (gLMSRespawn
> LMS_RESPAWN_NONE
) and (gLMSRespawnTime
< gTime
) then
1843 g_Game_RestartRound(gLMSSoftSpawn
);
1845 // Ïðîâåðèì ðåçóëüòàò ãîëîñîâàíèÿ, åñëè âðåìÿ ïðîøëî
1846 if gVoteInProgress
and (gVoteTimer
< gTime
) then
1848 else if gVotePassed
and (gVoteCmdTimer
< gTime
) then
1850 g_Console_Process(gVoteCommand
);
1852 gVotePassed
:= False;
1855 // Çàìåðÿåì âðåìÿ çàõâàòà ôëàãîâ
1856 if gFlags
[FLAG_RED
].State
= FLAG_STATE_CAPTURED
then
1857 gFlags
[FLAG_RED
].CaptureTime
:= gFlags
[FLAG_RED
].CaptureTime
+ GAME_TICK
;
1858 if gFlags
[FLAG_BLUE
].State
= FLAG_STATE_CAPTURED
then
1859 gFlags
[FLAG_BLUE
].CaptureTime
:= gFlags
[FLAG_BLUE
].CaptureTime
+ GAME_TICK
;
1861 // Áûë çàäàí ëèìèò ïîáåä:
1862 if (gGameSettings
.GoalLimit
> 0) then
1866 if gGameSettings
.GameMode
= GM_DM
then
1867 begin // Â DM èùåì èãðîêà ñ max ôðàãàìè
1868 for i
:= 0 to High(gPlayers
) do
1869 if gPlayers
[i
] <> nil then
1870 if gPlayers
[i
].Frags
> b
then
1871 b
:= gPlayers
[i
].Frags
;
1874 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
1875 begin //  CTF/TDM âûáèðàåì êîìàíäó ñ íàèáîëüøèì ñ÷åòîì
1876 b
:= Max(gTeamStat
[TEAM_RED
].Goals
, gTeamStat
[TEAM_BLUE
].Goals
);
1879 // Ëèìèò ïîáåä íàáðàí => êîíåö óðîâíÿ:
1880 if b
>= gGameSettings
.GoalLimit
then
1887 // Îáðàáàòûâàåì êëàâèøè èãðîêîâ:
1888 if gPlayer1
<> nil then gPlayer1
.ReleaseKeys();
1889 if gPlayer2
<> nil then gPlayer2
.ReleaseKeys();
1890 if (not gConsoleShow
) and (not gChatShow
) and (g_ActiveWindow
= nil) then
1892 ProcessPlayerControls(gPlayer1
, 0, P1MoveButton
);
1893 ProcessPlayerControls(gPlayer2
, 1, P2MoveButton
);
1894 end // if not console
1897 if g_Game_IsNet
and (gPlayer1
<> nil) then gPlayer1
.PressKey(KEY_CHAT
, 10000);
1899 // process weapon switch queue
1903 if (gPlayer1
= nil) and (gPlayer2
= nil) and
1904 (not gConsoleShow
) and (not gChatShow
) and (g_ActiveWindow
= nil) then
1906 if not gSpectKeyPress
then
1908 if gPlayerAction
[0, ACTION_JUMP
] and (not gSpectAuto
) then
1910 // switch spect mode
1912 SPECT_NONE
: ; // not spectator
1914 SPECT_MAPVIEW
: Inc(gSpectMode
);
1915 SPECT_PLAYERS
: gSpectMode
:= SPECT_STATS
; // reset to 1
1917 gSpectKeyPress
:= True;
1919 if (gSpectMode
= SPECT_MAPVIEW
)
1920 and (not gSpectAuto
) then
1922 if gPlayerAction
[0, ACTION_MOVELEFT
] then
1923 gSpectX
:= Max(gSpectX
- gSpectStep
, 0);
1924 if gPlayerAction
[0, ACTION_MOVERIGHT
] then
1925 gSpectX
:= Min(gSpectX
+ gSpectStep
, gMapInfo
.Width
- gScreenWidth
);
1926 if gPlayerAction
[0, ACTION_LOOKUP
] then
1927 gSpectY
:= Max(gSpectY
- gSpectStep
, 0);
1928 if gPlayerAction
[0, ACTION_LOOKDOWN
] then
1929 gSpectY
:= Min(gSpectY
+ gSpectStep
, gMapInfo
.Height
- gScreenHeight
);
1930 if gPlayerAction
[0, ACTION_WEAPPREV
] then
1933 if gSpectStep
> 4 then gSpectStep
:= gSpectStep
shr 1;
1934 gSpectKeyPress
:= True;
1936 if gPlayerAction
[0, ACTION_WEAPNEXT
] then
1939 if gSpectStep
< 64 then gSpectStep
:= gSpectStep
shl 1;
1940 gSpectKeyPress
:= True;
1943 if (gSpectMode
= SPECT_PLAYERS
)
1944 and (not gSpectAuto
) then
1946 if gPlayerAction
[0, ACTION_LOOKUP
] then
1949 gSpectViewTwo
:= True;
1950 gSpectKeyPress
:= True;
1952 if gPlayerAction
[0, ACTION_LOOKDOWN
] then
1954 // remove second view
1955 gSpectViewTwo
:= False;
1956 gSpectKeyPress
:= True;
1958 if gPlayerAction
[0, ACTION_MOVELEFT
] then
1960 // prev player (view 1)
1961 gSpectPID1
:= GetActivePlayerID_Prev(gSpectPID1
);
1962 gSpectKeyPress
:= True;
1964 if gPlayerAction
[0, ACTION_MOVERIGHT
] then
1966 // next player (view 1)
1967 gSpectPID1
:= GetActivePlayerID_Next(gSpectPID1
);
1968 gSpectKeyPress
:= True;
1970 if gPlayerAction
[0, ACTION_WEAPPREV
] then
1972 // prev player (view 2)
1973 gSpectPID2
:= GetActivePlayerID_Prev(gSpectPID2
);
1974 gSpectKeyPress
:= True;
1976 if gPlayerAction
[0, ACTION_WEAPNEXT
] then
1978 // next player (view 2)
1979 gSpectPID2
:= GetActivePlayerID_Next(gSpectPID2
);
1980 gSpectKeyPress
:= True;
1983 if gPlayerAction
[0, ACTION_ATTACK
] then
1985 if (gSpectMode
= SPECT_STATS
) and (not gSpectAuto
) then
1988 gSpectAutoNext
:= 0;
1989 gSpectViewTwo
:= False;
1990 gSpectKeyPress
:= True;
1995 gSpectMode
:= SPECT_STATS
;
1996 gSpectAuto
:= False;
1997 gSpectKeyPress
:= True;
2002 if (not gPlayerAction
[0, ACTION_JUMP
]) and
2003 (not gPlayerAction
[0, ACTION_ATTACK
]) and
2004 (not gPlayerAction
[0, ACTION_MOVELEFT
]) and
2005 (not gPlayerAction
[0, ACTION_MOVERIGHT
]) and
2006 (not gPlayerAction
[0, ACTION_LOOKUP
]) and
2007 (not gPlayerAction
[0, ACTION_LOOKDOWN
]) and
2008 (not gPlayerAction
[0, ACTION_WEAPPREV
]) and
2009 (not gPlayerAction
[0, ACTION_WEAPNEXT
]) then
2010 gSpectKeyPress
:= False;
2014 if gSpectMode
= SPECT_MAPVIEW
then
2016 i
:= Min(Max(gSpectX
+ gSpectAutoStepX
, 0), gMapInfo
.Width
- gScreenWidth
);
2018 gSpectAutoNext
:= gTime
2021 i
:= Min(Max(gSpectY
+ gSpectAutoStepY
, 0), gMapInfo
.Height
- gScreenHeight
);
2023 gSpectAutoNext
:= gTime
2027 if gSpectAutoNext
<= gTime
then
2029 if gSpectAutoNext
> 0 then
2031 gSpectMode
:= GetRandomSpectMode(gSpectMode
);
2035 gSpectX
:= Random(gMapInfo
.Width
- gScreenWidth
);
2036 gSpectY
:= Random(gMapInfo
.Height
- gScreenHeight
);
2037 gSpectAutoStepX
:= Random(9) - 4;
2038 gSpectAutoStepY
:= Random(9) - 4;
2039 if ((gSpectX
< 800) and (gSpectAutoStepX
< 0)) or
2040 ((gSpectX
> gMapInfo
.Width
- gScreenWidth
- 800) and (gSpectAutoStepX
> 0)) then
2041 gSpectAutoStepX
:= gSpectAutoStepX
* -1;
2042 if ((gSpectY
< 800) and (gSpectAutoStepY
< 0)) or
2043 ((gSpectY
> gMapInfo
.Height
- gScreenHeight
- 800) and (gSpectAutoStepY
> 0)) then
2044 gSpectAutoStepY
:= gSpectAutoStepY
* -1;
2048 gSpectPID1
:= GetActivePlayerID_Random(gSpectPID1
);
2053 SPECT_STATS
: gSpectAutoNext
:= gTime
+ (Random(3) + 5) * 1000;
2054 SPECT_MAPVIEW
: gSpectAutoNext
:= gTime
+ (Random(4) + 7) * 1000;
2055 SPECT_PLAYERS
: gSpectAutoNext
:= gTime
+ (Random(7) + 8) * 1000;
2061 // Îáíîâëÿåì âñå îñòàëüíîå:
2064 g_Triggers_Update();
2066 g_Monsters_Update();
2068 g_Player_UpdateAll();
2069 g_Player_UpdatePhysicalObjects();
2071 // server: send newly spawned monsters unconditionally
2072 if (gGameSettings
.GameType
= GT_SERVER
) then
2074 if (Length(gMonstersSpawned
) > 0) then
2076 for I
:= 0 to High(gMonstersSpawned
) do MH_SEND_MonsterSpawn(gMonstersSpawned
[I
]);
2077 SetLength(gMonstersSpawned
, 0);
2081 if (gSoundTriggerTime
> 8) then
2083 g_Game_UpdateTriggerSounds();
2084 gSoundTriggerTime
:= 0;
2088 Inc(gSoundTriggerTime
);
2091 if (NetMode
= NET_SERVER
) then
2093 Inc(NetTimeToUpdate
);
2094 Inc(NetTimeToReliable
);
2096 // send monster updates
2097 if (NetTimeToReliable
>= NetRelupdRate
) or (NetTimeToUpdate
>= NetUpdateRate
) then
2099 // send all monsters (periodic sync)
2100 reliableUpdate
:= (NetTimeToReliable
>= NetRelupdRate
);
2102 for I
:= 0 to High(gPlayers
) do
2104 if (gPlayers
[I
] <> nil) then MH_SEND_PlayerPos(reliableUpdate
, gPlayers
[I
].UID
);
2107 g_Mons_ForEach(sendMonsPos
);
2109 if reliableUpdate
then
2111 NetTimeToReliable
:= 0;
2112 NetTimeToUpdate
:= NetUpdateRate
;
2116 NetTimeToUpdate
:= 0;
2121 // send only mosters with some unexpected changes
2122 g_Mons_ForEach(sendMonsPosUnexpected
);
2125 // send unexpected platform changes
2126 g_Map_NetSendInterestingPanels();
2128 if NetUseMaster
then
2130 if gTime
>= NetTimeToMaster
then
2132 if (NetMHost
= nil) or (NetMPeer
= nil) then
2134 if not g_Net_Slist_Connect
then g_Console_Add(_lc
[I_NET_MSG_ERROR
] + _lc
[I_NET_SLIST_ERROR
]);
2138 NetTimeToMaster
:= gTime
+ NetMasterRate
;
2142 else if (NetMode
= NET_CLIENT
) then
2144 MC_SEND_PlayerPos();
2146 end; // if gameOn ...
2148 // Àêòèâíî îêíî èíòåðôåéñà - ïåðåäàåì êëàâèøè åìó:
2149 if g_ActiveWindow
<> nil then
2151 w
:= e_GetFirstKeyPressed();
2153 if (w
<> IK_INVALID
) then
2155 Msg
.Msg
:= MESSAGE_DIKEY
;
2157 g_ActiveWindow
.OnMessage(Msg
);
2160 // Åñëè îíî îò ýòîãî íå çàêðûëîñü, òî îáíîâëÿåì:
2161 if g_ActiveWindow
<> nil then
2162 g_ActiveWindow
.Update();
2164 // Íóæíî ñìåíèòü ðàçðåøåíèå:
2165 if gResolutionChange
then
2167 e_WriteLog('Changing resolution', TMsgType
.Notify
);
2168 g_Game_ChangeResolution(gRC_Width
, gRC_Height
, gRC_FullScreen
, gRC_Maximized
);
2169 gResolutionChange
:= False;
2170 g_ActiveWindow
:= nil;
2173 // Íóæíî ñìåíèòü ÿçûê:
2174 if gLanguageChange
then
2176 //e_WriteLog('Read language file', MSG_NOTIFY);
2177 //g_Language_Load(DataDir + gLanguage + '.txt');
2178 g_Language_Set(gLanguage
);
2182 gLanguageChange
:= False;
2186 // Ãîðÿ÷àÿ êëàâèøà äëÿ âûçîâà ìåíþ âûõîäà èç èãðû (F10):
2187 if e_KeyPressed(IK_F10
) and
2189 (not gConsoleShow
) and
2190 (g_ActiveWindow
= nil) then
2195 Time
:= GetTimer() {div 1000};
2197 // Îáðàáîòêà îòëîæåííûõ ñîáûòèé:
2198 if gDelayedEvents
<> nil then
2199 for a
:= 0 to High(gDelayedEvents
) do
2200 if gDelayedEvents
[a
].Pending
and
2202 ((gDelayedEvents
[a
].DEType
= DE_GLOBEVENT
) and (gDelayedEvents
[a
].Time
<= Time
)) or
2203 ((gDelayedEvents
[a
].DEType
> DE_GLOBEVENT
) and (gDelayedEvents
[a
].Time
<= gTime
))
2206 case gDelayedEvents
[a
].DEType
of
2208 g_Game_ExecuteEvent(gDelayedEvents
[a
].DEStr
);
2211 g_Game_Announce_GoodShot(gDelayedEvents
[a
].DENum
);
2215 g_Game_Announce_KillCombo(gDelayedEvents
[a
].DENum
);
2216 if g_Game_IsNet
and g_Game_IsServer
then
2217 MH_SEND_GameEvent(NET_EV_KILLCOMBO
, gDelayedEvents
[a
].DENum
);
2221 g_Game_Announce_BodyKill(gDelayedEvents
[a
].DENum
);
2223 gDelayedEvents
[a
].Pending
:= False;
2226 // Êàæäóþ ñåêóíäó îáíîâëÿåì ñ÷åò÷èê îáíîâëåíèé:
2227 UPSCounter
:= UPSCounter
+ 1;
2228 if Time
- UPSTime
>= 1000 then
2237 g_Weapon_AddDynLights();
2238 g_Items_AddDynLights();
2242 procedure g_Game_LoadChatSounds(Resource
: string);
2245 FileName
, Snd
: string;
2247 len
, cnt
, tags
, i
, j
: Integer;
2250 FileName
:= g_ExtractWadName(Resource
);
2252 WAD
:= TWADFile
.Create();
2253 WAD
.ReadFile(FileName
);
2255 if not WAD
.GetResource(g_ExtractFilePathName(Resource
), p
, len
) then
2262 cfg
:= TConfig
.CreateMem(p
, len
);
2263 cnt
:= cfg
.ReadInt('ChatSounds', 'Count', 0);
2265 SetLength(gChatSounds
, cnt
);
2266 for i
:= 0 to Length(gChatSounds
) - 1 do
2268 gChatSounds
[i
].Sound
:= nil;
2269 Snd
:= Trim(cfg
.ReadStr(IntToStr(i
), 'Sound', ''));
2270 tags
:= cfg
.ReadInt(IntToStr(i
), 'Tags', 0);
2271 if (Snd
= '') or (Tags
<= 0) then
2273 g_Sound_CreateWADEx('SOUND_CHAT_MACRO' + IntToStr(i
), GameWAD
+':'+Snd
);
2274 gChatSounds
[i
].Sound
:= TPlayableSound
.Create();
2275 gChatSounds
[i
].Sound
.SetByName('SOUND_CHAT_MACRO' + IntToStr(i
));
2276 SetLength(gChatSounds
[i
].Tags
, tags
);
2277 for j
:= 0 to tags
- 1 do
2278 gChatSounds
[i
].Tags
[j
] := toLowerCase1251(cfg
.ReadStr(IntToStr(i
), 'Tag' + IntToStr(j
), ''));
2279 gChatSounds
[i
].FullWord
:= cfg
.ReadBool(IntToStr(i
), 'FullWord', False);
2286 procedure g_Game_FreeChatSounds();
2290 for i
:= 0 to Length(gChatSounds
) - 1 do
2292 gChatSounds
[i
].Sound
.Free();
2293 g_Sound_Delete('SOUND_CHAT_MACRO' + IntToStr(i
));
2295 SetLength(gChatSounds
, 0);
2299 procedure g_Game_LoadData();
2306 if DataLoaded
then Exit
;
2308 e_WriteLog('Loading game data...', TMsgType
.Notify
);
2310 g_Texture_CreateWADEx('NOTEXTURE', GameWAD
+':TEXTURES\NOTEXTURE');
2311 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUD', GameWAD
+':TEXTURES\HUD');
2312 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDAIR', GameWAD
+':TEXTURES\AIRBAR');
2313 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDJET', GameWAD
+':TEXTURES\JETBAR');
2314 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDBG', GameWAD
+':TEXTURES\HUDBG');
2315 g_Texture_CreateWADEx('TEXTURE_PLAYER_ARMORHUD', GameWAD
+':TEXTURES\ARMORHUD');
2316 g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG', GameWAD
+':TEXTURES\FLAGHUD_R_BASE');
2317 g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG_S', GameWAD
+':TEXTURES\FLAGHUD_R_STOLEN');
2318 g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG_D', GameWAD
+':TEXTURES\FLAGHUD_R_DROP');
2319 g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG', GameWAD
+':TEXTURES\FLAGHUD_B_BASE');
2320 g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG_S', GameWAD
+':TEXTURES\FLAGHUD_B_STOLEN');
2321 g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG_D', GameWAD
+':TEXTURES\FLAGHUD_B_DROP');
2322 g_Texture_CreateWADEx('TEXTURE_PLAYER_TALKBUBBLE', GameWAD
+':TEXTURES\TALKBUBBLE');
2323 g_Texture_CreateWADEx('TEXTURE_PLAYER_INVULPENTA', GameWAD
+':TEXTURES\PENTA');
2324 g_Texture_CreateWADEx('TEXTURE_PLAYER_INDICATOR', GameWAD
+':TEXTURES\PLRIND');
2327 if not g_Texture_CreateWADEx('UI_GFX_PBAR_LEFT', GameWAD
+':TEXTURES\LLEFT') then hasPBarGfx
:= false;
2328 if not g_Texture_CreateWADEx('UI_GFX_PBAR_MARKER', GameWAD
+':TEXTURES\LMARKER') then hasPBarGfx
:= false;
2329 if not g_Texture_CreateWADEx('UI_GFX_PBAR_MIDDLE', GameWAD
+':TEXTURES\LMIDDLE') then hasPBarGfx
:= false;
2330 if not g_Texture_CreateWADEx('UI_GFX_PBAR_RIGHT', GameWAD
+':TEXTURES\LRIGHT') then hasPBarGfx
:= false;
2334 g_Texture_GetSize('UI_GFX_PBAR_LEFT', wl
, hl
);
2335 g_Texture_GetSize('UI_GFX_PBAR_RIGHT', wr
, hr
);
2336 g_Texture_GetSize('UI_GFX_PBAR_MIDDLE', wb
, hb
);
2337 g_Texture_GetSize('UI_GFX_PBAR_MARKER', wm
, hm
);
2338 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
2344 hasPBarGfx
:= false;
2348 g_Frames_CreateWAD(nil, 'FRAMES_TELEPORT', GameWAD
+':TEXTURES\TELEPORT', 64, 64, 10, False);
2349 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH', GameWAD
+':WEAPONS\PUNCH', 64, 64, 4, False);
2350 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_UP', GameWAD
+':WEAPONS\PUNCH_UP', 64, 64, 4, False);
2351 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_DN', GameWAD
+':WEAPONS\PUNCH_DN', 64, 64, 4, False);
2352 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_BERSERK', GameWAD
+':WEAPONS\PUNCHB', 64, 64, 4, False);
2353 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_BERSERK_UP', GameWAD
+':WEAPONS\PUNCHB_UP', 64, 64, 4, False);
2354 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_BERSERK_DN', GameWAD
+':WEAPONS\PUNCHB_DN', 64, 64, 4, False);
2355 g_Sound_CreateWADEx('SOUND_GAME_TELEPORT', GameWAD
+':SOUNDS\TELEPORT');
2356 g_Sound_CreateWADEx('SOUND_GAME_NOTELEPORT', GameWAD
+':SOUNDS\NOTELEPORT');
2357 g_Sound_CreateWADEx('SOUND_GAME_SECRET', GameWAD
+':SOUNDS\SECRET');
2358 g_Sound_CreateWADEx('SOUND_GAME_DOOROPEN', GameWAD
+':SOUNDS\DOOROPEN');
2359 g_Sound_CreateWADEx('SOUND_GAME_DOORCLOSE', GameWAD
+':SOUNDS\DOORCLOSE');
2360 g_Sound_CreateWADEx('SOUND_GAME_BULK1', GameWAD
+':SOUNDS\BULK1');
2361 g_Sound_CreateWADEx('SOUND_GAME_BULK2', GameWAD
+':SOUNDS\BULK2');
2362 g_Sound_CreateWADEx('SOUND_GAME_BUBBLE1', GameWAD
+':SOUNDS\BUBBLE1');
2363 g_Sound_CreateWADEx('SOUND_GAME_BUBBLE2', GameWAD
+':SOUNDS\BUBBLE2');
2364 g_Sound_CreateWADEx('SOUND_GAME_BURNING', GameWAD
+':SOUNDS\BURNING');
2365 g_Sound_CreateWADEx('SOUND_GAME_SWITCH1', GameWAD
+':SOUNDS\SWITCH1');
2366 g_Sound_CreateWADEx('SOUND_GAME_SWITCH0', GameWAD
+':SOUNDS\SWITCH0');
2367 g_Sound_CreateWADEx('SOUND_GAME_RADIO', GameWAD
+':SOUNDS\RADIO');
2368 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD1', GameWAD
+':SOUNDS\GOOD1');
2369 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD2', GameWAD
+':SOUNDS\GOOD2');
2370 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD3', GameWAD
+':SOUNDS\GOOD3');
2371 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD4', GameWAD
+':SOUNDS\GOOD4');
2372 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL2X', GameWAD
+':SOUNDS\KILL2X');
2373 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL3X', GameWAD
+':SOUNDS\KILL3X');
2374 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL4X', GameWAD
+':SOUNDS\KILL4X');
2375 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILLMX', GameWAD
+':SOUNDS\KILLMX');
2376 g_Sound_CreateWADEx('SOUND_ANNOUNCER_MUHAHA1', GameWAD
+':SOUNDS\MUHAHA1');
2377 g_Sound_CreateWADEx('SOUND_ANNOUNCER_MUHAHA2', GameWAD
+':SOUNDS\MUHAHA2');
2378 g_Sound_CreateWADEx('SOUND_ANNOUNCER_MUHAHA3', GameWAD
+':SOUNDS\MUHAHA3');
2379 g_Sound_CreateWADEx('SOUND_CTF_GET1', GameWAD
+':SOUNDS\GETFLAG1');
2380 g_Sound_CreateWADEx('SOUND_CTF_GET2', GameWAD
+':SOUNDS\GETFLAG2');
2381 g_Sound_CreateWADEx('SOUND_CTF_LOST1', GameWAD
+':SOUNDS\LOSTFLG1');
2382 g_Sound_CreateWADEx('SOUND_CTF_LOST2', GameWAD
+':SOUNDS\LOSTFLG2');
2383 g_Sound_CreateWADEx('SOUND_CTF_RETURN1', GameWAD
+':SOUNDS\RETFLAG1');
2384 g_Sound_CreateWADEx('SOUND_CTF_RETURN2', GameWAD
+':SOUNDS\RETFLAG2');
2385 g_Sound_CreateWADEx('SOUND_CTF_CAPTURE1', GameWAD
+':SOUNDS\CAPFLAG1');
2386 g_Sound_CreateWADEx('SOUND_CTF_CAPTURE2', GameWAD
+':SOUNDS\CAPFLAG2');
2388 goodsnd
[0] := TPlayableSound
.Create();
2389 goodsnd
[1] := TPlayableSound
.Create();
2390 goodsnd
[2] := TPlayableSound
.Create();
2391 goodsnd
[3] := TPlayableSound
.Create();
2393 goodsnd
[0].SetByName('SOUND_ANNOUNCER_GOOD1');
2394 goodsnd
[1].SetByName('SOUND_ANNOUNCER_GOOD2');
2395 goodsnd
[2].SetByName('SOUND_ANNOUNCER_GOOD3');
2396 goodsnd
[3].SetByName('SOUND_ANNOUNCER_GOOD4');
2398 killsnd
[0] := TPlayableSound
.Create();
2399 killsnd
[1] := TPlayableSound
.Create();
2400 killsnd
[2] := TPlayableSound
.Create();
2401 killsnd
[3] := TPlayableSound
.Create();
2403 killsnd
[0].SetByName('SOUND_ANNOUNCER_KILL2X');
2404 killsnd
[1].SetByName('SOUND_ANNOUNCER_KILL3X');
2405 killsnd
[2].SetByName('SOUND_ANNOUNCER_KILL4X');
2406 killsnd
[3].SetByName('SOUND_ANNOUNCER_KILLMX');
2408 hahasnd
[0] := TPlayableSound
.Create();
2409 hahasnd
[1] := TPlayableSound
.Create();
2410 hahasnd
[2] := TPlayableSound
.Create();
2412 hahasnd
[0].SetByName('SOUND_ANNOUNCER_MUHAHA1');
2413 hahasnd
[1].SetByName('SOUND_ANNOUNCER_MUHAHA2');
2414 hahasnd
[2].SetByName('SOUND_ANNOUNCER_MUHAHA3');
2416 sound_get_flag
[0] := TPlayableSound
.Create();
2417 sound_get_flag
[1] := TPlayableSound
.Create();
2418 sound_lost_flag
[0] := TPlayableSound
.Create();
2419 sound_lost_flag
[1] := TPlayableSound
.Create();
2420 sound_ret_flag
[0] := TPlayableSound
.Create();
2421 sound_ret_flag
[1] := TPlayableSound
.Create();
2422 sound_cap_flag
[0] := TPlayableSound
.Create();
2423 sound_cap_flag
[1] := TPlayableSound
.Create();
2425 sound_get_flag
[0].SetByName('SOUND_CTF_GET1');
2426 sound_get_flag
[1].SetByName('SOUND_CTF_GET2');
2427 sound_lost_flag
[0].SetByName('SOUND_CTF_LOST1');
2428 sound_lost_flag
[1].SetByName('SOUND_CTF_LOST2');
2429 sound_ret_flag
[0].SetByName('SOUND_CTF_RETURN1');
2430 sound_ret_flag
[1].SetByName('SOUND_CTF_RETURN2');
2431 sound_cap_flag
[0].SetByName('SOUND_CTF_CAPTURE1');
2432 sound_cap_flag
[1].SetByName('SOUND_CTF_CAPTURE2');
2434 g_Game_LoadChatSounds(GameWAD
+':CHATSND\SNDCFG');
2436 g_Game_SetLoadingText(_lc
[I_LOAD_ITEMS_DATA
], 0, False);
2439 g_Game_SetLoadingText(_lc
[I_LOAD_WEAPONS_DATA
], 0, False);
2440 g_Weapon_LoadData();
2442 g_Monsters_LoadData();
2447 procedure g_Game_FreeData();
2449 if not DataLoaded
then Exit
;
2452 g_Weapon_FreeData();
2453 g_Monsters_FreeData();
2455 e_WriteLog('Releasing game data...', TMsgType
.Notify
);
2457 g_Texture_Delete('NOTEXTURE');
2458 g_Texture_Delete('TEXTURE_PLAYER_HUD');
2459 g_Texture_Delete('TEXTURE_PLAYER_HUDBG');
2460 g_Texture_Delete('TEXTURE_PLAYER_ARMORHUD');
2461 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG');
2462 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG_S');
2463 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG_D');
2464 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG');
2465 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG_S');
2466 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG_D');
2467 g_Texture_Delete('TEXTURE_PLAYER_TALKBUBBLE');
2468 g_Texture_Delete('TEXTURE_PLAYER_INVULPENTA');
2469 g_Frames_DeleteByName('FRAMES_TELEPORT');
2470 g_Frames_DeleteByName('FRAMES_PUNCH');
2471 g_Frames_DeleteByName('FRAMES_PUNCH_UP');
2472 g_Frames_DeleteByName('FRAMES_PUNCH_DN');
2473 g_Frames_DeleteByName('FRAMES_PUNCH_BERSERK');
2474 g_Frames_DeleteByName('FRAMES_PUNCH_BERSERK_UP');
2475 g_Frames_DeleteByName('FRAMES_PUNCH_BERSERK_DN');
2476 g_Sound_Delete('SOUND_GAME_TELEPORT');
2477 g_Sound_Delete('SOUND_GAME_NOTELEPORT');
2478 g_Sound_Delete('SOUND_GAME_SECRET');
2479 g_Sound_Delete('SOUND_GAME_DOOROPEN');
2480 g_Sound_Delete('SOUND_GAME_DOORCLOSE');
2481 g_Sound_Delete('SOUND_GAME_BULK1');
2482 g_Sound_Delete('SOUND_GAME_BULK2');
2483 g_Sound_Delete('SOUND_GAME_BUBBLE1');
2484 g_Sound_Delete('SOUND_GAME_BUBBLE2');
2485 g_Sound_Delete('SOUND_GAME_BURNING');
2486 g_Sound_Delete('SOUND_GAME_SWITCH1');
2487 g_Sound_Delete('SOUND_GAME_SWITCH0');
2494 g_Sound_Delete('SOUND_ANNOUNCER_GOOD1');
2495 g_Sound_Delete('SOUND_ANNOUNCER_GOOD2');
2496 g_Sound_Delete('SOUND_ANNOUNCER_GOOD3');
2497 g_Sound_Delete('SOUND_ANNOUNCER_GOOD4');
2504 g_Sound_Delete('SOUND_ANNOUNCER_KILL2X');
2505 g_Sound_Delete('SOUND_ANNOUNCER_KILL3X');
2506 g_Sound_Delete('SOUND_ANNOUNCER_KILL4X');
2507 g_Sound_Delete('SOUND_ANNOUNCER_KILLMX');
2513 g_Sound_Delete('SOUND_ANNOUNCER_MUHAHA1');
2514 g_Sound_Delete('SOUND_ANNOUNCER_MUHAHA2');
2515 g_Sound_Delete('SOUND_ANNOUNCER_MUHAHA3');
2517 sound_get_flag
[0].Free();
2518 sound_get_flag
[1].Free();
2519 sound_lost_flag
[0].Free();
2520 sound_lost_flag
[1].Free();
2521 sound_ret_flag
[0].Free();
2522 sound_ret_flag
[1].Free();
2523 sound_cap_flag
[0].Free();
2524 sound_cap_flag
[1].Free();
2526 g_Sound_Delete('SOUND_CTF_GET1');
2527 g_Sound_Delete('SOUND_CTF_GET2');
2528 g_Sound_Delete('SOUND_CTF_LOST1');
2529 g_Sound_Delete('SOUND_CTF_LOST2');
2530 g_Sound_Delete('SOUND_CTF_RETURN1');
2531 g_Sound_Delete('SOUND_CTF_RETURN2');
2532 g_Sound_Delete('SOUND_CTF_CAPTURE1');
2533 g_Sound_Delete('SOUND_CTF_CAPTURE2');
2535 g_Game_FreeChatSounds();
2537 DataLoaded
:= False;
2540 procedure DrawCustomStat();
2546 ww2
, hh2
, r
, g
, b
, rr
, gg
, bb
: Byte;
2547 s1
, s2
, topstr
: String;
2549 e_TextureFontGetSize(gStdFont
, ww2
, hh2
);
2551 g_ProcessMessages();
2553 if g_Console_Action(ACTION_SCORES
) then
2555 if not gStatsPressed
then
2557 gStatsOff
:= not gStatsOff
;
2558 gStatsPressed
:= True;
2562 gStatsPressed
:= False;
2566 s1
:= _lc
[I_MENU_INTER_NOTICE_TAB
];
2567 w
:= (Length(s1
) * ww2
) div 2;
2568 x
:= gScreenWidth
div 2 - w
;
2570 e_TextureFontPrint(x
, y
, s1
, gStdFont
);
2574 if (gGameSettings
.GameMode
= GM_COOP
) then
2576 if gMissionFailed
then
2577 topstr
:= _lc
[I_MENU_INTER_MISSION_FAIL
]
2579 topstr
:= _lc
[I_MENU_INTER_LEVEL_COMPLETE
];
2582 topstr
:= _lc
[I_MENU_INTER_ROUND_OVER
];
2584 e_CharFont_GetSize(gMenuFont
, topstr
, ww1
, hh1
);
2585 e_CharFont_Print(gMenuFont
, (gScreenWidth
div 2)-(ww1
div 2), 16, topstr
);
2587 if g_Game_IsNet
then
2589 topstr
:= Format(_lc
[I_MENU_INTER_NOTICE_TIME
], [gServInterTime
]);
2590 if not gChatShow
then
2591 e_TextureFontPrintEx((gScreenWidth
div 2)-(Length(topstr
)*ww2
div 2),
2592 gScreenHeight
-(hh2
+4)*2, topstr
, gStdFont
, 255, 255, 255, 1);
2595 if g_Game_IsClient
then
2596 topstr
:= _lc
[I_MENU_INTER_NOTICE_MAP
]
2598 topstr
:= _lc
[I_MENU_INTER_NOTICE_SPACE
];
2599 if not gChatShow
then
2600 e_TextureFontPrintEx((gScreenWidth
div 2)-(Length(topstr
)*ww2
div 2),
2601 gScreenHeight
-(hh2
+4), topstr
, gStdFont
, 255, 255, 255, 1);
2606 w
:= gScreenWidth
-x
*2;
2612 e_DrawFillQuad(x
, y
, gScreenWidth
-x
-1, gScreenHeight
-y
-1, 64, 64, 64, 32);
2613 e_DrawQuad(x
, y
, gScreenWidth
-x
-1, gScreenHeight
-y
-1, 255, 127, 0);
2615 m
:= Max(Length(_lc
[I_MENU_MAP
])+1, Length(_lc
[I_GAME_GAME_TIME
])+1)*ww2
;
2617 case CustomStat
.GameMode
of
2620 if gGameSettings
.MaxLives
= 0 then
2621 s1
:= _lc
[I_GAME_DM
]
2623 s1
:= _lc
[I_GAME_LMS
];
2627 if gGameSettings
.MaxLives
= 0 then
2628 s1
:= _lc
[I_GAME_TDM
]
2630 s1
:= _lc
[I_GAME_TLMS
];
2632 GM_CTF
: s1
:= _lc
[I_GAME_CTF
];
2635 if gGameSettings
.MaxLives
= 0 then
2636 s1
:= _lc
[I_GAME_COOP
]
2638 s1
:= _lc
[I_GAME_SURV
];
2644 e_TextureFontPrintEx(x
+(w
div 2)-(Length(s1
)*ww2
div 2), _y
, s1
, gStdFont
, 255, 255, 255, 1);
2648 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_MENU_MAP
], gStdFont
, 255, 127, 0, 1);
2649 e_TextureFontPrint(x
+8+m
, _y
, Format('%s - %s', [CustomStat
.Map
, CustomStat
.MapName
]), gStdFont
);
2652 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_GAME_TIME
], gStdFont
, 255, 127, 0, 1);
2653 e_TextureFontPrint(x
+8+m
, _y
, Format('%d:%.2d:%.2d', [CustomStat
.GameTime
div 1000 div 3600,
2654 (CustomStat
.GameTime
div 1000 div 60) mod 60,
2655 CustomStat
.GameTime
div 1000 mod 60]), gStdFont
);
2657 pc
:= Length(CustomStat
.PlayerStat
);
2658 if pc
= 0 then Exit
;
2660 if CustomStat
.GameMode
= GM_COOP
then
2662 m
:= Max(Length(_lc
[I_GAME_MONSTERS
])+1, Length(_lc
[I_GAME_SECRETS
])+1)*ww2
;
2664 s2
:= _lc
[I_GAME_MONSTERS
];
2665 e_TextureFontPrintEx(x
+8, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2666 e_TextureFontPrintEx(x
+8+m
, _y
, IntToStr(gCoopMonstersKilled
) + '/' + IntToStr(gTotalMonsters
), gStdFont
, 255, 255, 255, 1);
2668 s2
:= _lc
[I_GAME_SECRETS
];
2669 e_TextureFontPrintEx(x
+8, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2670 e_TextureFontPrintEx(x
+8+m
, _y
, IntToStr(gCoopSecretsFound
) + '/' + IntToStr(gSecretsCount
), gStdFont
, 255, 255, 255, 1);
2673 m
:= Max(Length(_lc
[I_GAME_MONSTERS_TOTAL
])+1, Length(_lc
[I_GAME_SECRETS_TOTAL
])+1)*ww2
;
2675 s2
:= _lc
[I_GAME_MONSTERS_TOTAL
];
2676 e_TextureFontPrintEx(x
+250, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2677 e_TextureFontPrintEx(x
+250+m
, _y
, IntToStr(gCoopTotalMonstersKilled
) + '/' + IntToStr(gCoopTotalMonsters
), gStdFont
, 255, 255, 255, 1);
2679 s2
:= _lc
[I_GAME_SECRETS_TOTAL
];
2680 e_TextureFontPrintEx(x
+250, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2681 e_TextureFontPrintEx(x
+250+m
, _y
, IntToStr(gCoopTotalSecretsFound
) + '/' + IntToStr(gCoopTotalSecrets
), gStdFont
, 255, 255, 255, 1);
2685 if CustomStat
.GameMode
in [GM_TDM
, GM_CTF
] then
2690 if TeamStat
[TEAM_RED
].Goals
> TeamStat
[TEAM_BLUE
].Goals
then s1
:= _lc
[I_GAME_WIN_RED
]
2691 else if TeamStat
[TEAM_BLUE
].Goals
> TeamStat
[TEAM_RED
].Goals
then s1
:= _lc
[I_GAME_WIN_BLUE
]
2692 else s1
:= _lc
[I_GAME_WIN_DRAW
];
2694 e_TextureFontPrintEx(x
+8+(w
div 2)-(Length(s1
)*ww2
div 2), _y
, s1
, gStdFont
, 255, 255, 255, 1);
2697 for t
:= TEAM_RED
to TEAM_BLUE
do
2699 if t
= TEAM_RED
then
2701 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_TEAM_RED
],
2702 gStdFont
, 255, 0, 0, 1);
2703 e_TextureFontPrintEx(x
+w1
+8, _y
, IntToStr(CustomStat
.TeamStat
[TEAM_RED
].Goals
),
2704 gStdFont
, 255, 0, 0, 1);
2711 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_TEAM_BLUE
],
2712 gStdFont
, 0, 0, 255, 1);
2713 e_TextureFontPrintEx(x
+w1
+8, _y
, IntToStr(CustomStat
.TeamStat
[TEAM_BLUE
].Goals
),
2714 gStdFont
, 0, 0, 255, 1);
2720 e_DrawLine(1, x
+8, _y
+20, x
-8+w
, _y
+20, r
, g
, b
);
2723 for p
:= 0 to High(CustomStat
.PlayerStat
) do
2724 if CustomStat
.PlayerStat
[p
].Team
= t
then
2725 with CustomStat
.PlayerStat
[p
] do
2739 if (gPlayers
[Num
] <> nil) and (gPlayers
[Num
].FReady
) then
2740 e_TextureFontPrintEx(x
+16, _y
, Name
+ ' *', gStdFont
, rr
, gg
, bb
, 1)
2742 e_TextureFontPrintEx(x
+16, _y
, Name
, gStdFont
, rr
, gg
, bb
, 1);
2743 e_TextureFontPrintEx(x
+w1
+16, _y
, IntToStr(Frags
), gStdFont
, rr
, gg
, bb
, 1);
2744 e_TextureFontPrintEx(x
+w1
+w2
+16, _y
, IntToStr(Deaths
), gStdFont
, rr
, gg
, bb
, 1);
2751 else if CustomStat
.GameMode
in [GM_DM
, GM_COOP
] then
2754 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_PLAYER_NAME
], gStdFont
, 255, 127, 0, 1);
2755 e_TextureFontPrintEx(x
+8+w1
, _y
, _lc
[I_GAME_FRAGS
], gStdFont
, 255, 127, 0, 1);
2756 e_TextureFontPrintEx(x
+8+w1
+w2
, _y
, _lc
[I_GAME_DEATHS
], gStdFont
, 255, 127, 0, 1);
2759 for p
:= 0 to High(CustomStat
.PlayerStat
) do
2760 with CustomStat
.PlayerStat
[p
] do
2762 e_DrawFillQuad(x
+8, _y
+4, x
+24-1, _y
+16+4-1, Color
.R
, Color
.G
, Color
.B
, 0);
2769 if (gPlayers
[Num
] <> nil) and (gPlayers
[Num
].FReady
) then
2770 e_TextureFontPrintEx(x
+8+16+8, _y
+4, Name
+ ' *', gStdFont
, r
, r
, r
, 1, True)
2772 e_TextureFontPrintEx(x
+8+16+8, _y
+4, Name
, gStdFont
, r
, r
, r
, 1, True);
2773 e_TextureFontPrintEx(x
+w1
+8+16+8, _y
+4, IntToStr(Frags
), gStdFont
, r
, r
, r
, 1, True);
2774 e_TextureFontPrintEx(x
+w1
+w2
+8+16+8, _y
+4, IntToStr(Deaths
), gStdFont
, r
, r
, r
, 1, True);
2780 procedure DrawSingleStat();
2782 tm
, key_x
, val_x
, y
: Integer;
2786 procedure player_stat(n
: Integer);
2792 s1
:= Format(' %d ', [SingleStat
.PlayerStat
[n
].Kills
]);
2793 s2
:= Format(' %d', [gTotalMonsters
]);
2795 e_CharFont_Print(gMenuFont
, key_x
, y
, _lc
[I_MENU_INTER_KILLS
]);
2796 e_CharFont_PrintEx(gMenuFont
, val_x
, y
, s1
, _RGB(255, 0, 0));
2797 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2798 e_CharFont_Print(gMenuFont
, val_x
+w1
, y
, '/');
2800 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2801 e_CharFont_PrintEx(gMenuFont
, val_x
+w1
, y
, s2
, _RGB(255, 0, 0));
2803 // "Kills-per-minute: ##.#":
2804 s1
:= _lc
[I_MENU_INTER_KPM
];
2806 kpm
:= (SingleStat
.PlayerStat
[n
].Kills
/ tm
) * 60
2808 kpm
:= SingleStat
.PlayerStat
[n
].Kills
;
2809 s2
:= Format(' %.1f', [kpm
]);
2811 e_CharFont_Print(gMenuFont
, key_x
, y
+32, s1
);
2812 e_CharFont_PrintEx(gMenuFont
, val_x
, y
+32, s2
, _RGB(255, 0, 0));
2814 // "Secrets found: # / #":
2815 s1
:= Format(' %d ', [SingleStat
.PlayerStat
[n
].Secrets
]);
2816 s2
:= Format(' %d', [SingleStat
.TotalSecrets
]);
2818 e_CharFont_Print(gMenuFont
, key_x
, y
+64, _lc
[I_MENU_INTER_SECRETS
]);
2819 e_CharFont_PrintEx(gMenuFont
, val_x
, y
+64, s1
, _RGB(255, 0, 0));
2820 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2821 e_CharFont_Print(gMenuFont
, val_x
+w1
, y
+64, '/');
2823 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2824 e_CharFont_PrintEx(gMenuFont
, val_x
+w1
, y
+64, s2
, _RGB(255, 0, 0));
2828 // "Level Complete":
2829 e_CharFont_GetSize(gMenuFont
, _lc
[I_MENU_INTER_LEVEL_COMPLETE
], w1
, h
);
2830 e_CharFont_Print(gMenuFont
, (gScreenWidth
-w1
) div 2, 32, _lc
[I_MENU_INTER_LEVEL_COMPLETE
]);
2832 // Îïðåäåëÿåì êîîðäèíàòû âûðàâíèâàíèÿ ïî ñàìîé äëèííîé ñòðîêå:
2833 s1
:= _lc
[I_MENU_INTER_KPM
];
2834 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2837 e_CharFont_GetSize(gMenuFont
, s1
, w2
, h
);
2839 key_x
:= (gScreenWidth
-w1
-w2
) div 2;
2840 val_x
:= key_x
+ w1
;
2843 tm
:= SingleStat
.GameTime
div 1000;
2844 s1
:= _lc
[I_MENU_INTER_TIME
];
2845 s2
:= Format(' %d:%.2d:%.2d', [tm
div (60*60), (tm
mod (60*60)) div 60, tm
mod 60]);
2847 e_CharFont_Print(gMenuFont
, key_x
, 80, s1
);
2848 e_CharFont_PrintEx(gMenuFont
, val_x
, 80, s2
, _RGB(255, 0, 0));
2850 if SingleStat
.TwoPlayers
then
2853 s1
:= _lc
[I_MENU_PLAYER_1
];
2854 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2855 e_CharFont_Print(gMenuFont
, (gScreenWidth
-w1
) div 2, 128, s1
);
2857 // Ñòàòèñòèêà ïåðâîãî èãðîêà:
2862 s1
:= _lc
[I_MENU_PLAYER_2
];
2863 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2864 e_CharFont_Print(gMenuFont
, (gScreenWidth
-w1
) div 2, 288, s1
);
2866 // Ñòàòèñòèêà âòîðîãî èãðîêà:
2872 // Ñòàòèñòèêà ïåðâîãî èãðîêà:
2878 procedure DrawLoadingStat();
2879 procedure drawRect (x
, y
, w
, h
: Integer);
2881 if (w
< 1) or (h
< 1) then exit
;
2883 glVertex2f(x
+0.375, y
+0.375);
2884 glVertex2f(x
+w
+0.375, y
+0.375);
2885 glVertex2f(x
+w
+0.375, y
+h
+0.375);
2886 glVertex2f(x
+0.375, y
+h
+0.375);
2890 function drawPBar (cur
, total
: Integer; washere
: Boolean): Boolean;
2892 rectW
, rectH
: Integer;
2899 idl
, idr
, idb
, idm
: LongWord;
2903 if (total
< 1) then exit
;
2904 if (cur
< 1) then exit
; // don't blink
2905 if (not washere
) and (cur
>= total
) then exit
; // don't blink
2906 //if (cur < 0) then cur := 0;
2907 //if (cur > total) then cur := total;
2910 if (hasPBarGfx
) then
2912 g_Texture_Get('UI_GFX_PBAR_LEFT', idl
);
2913 g_Texture_GetSize('UI_GFX_PBAR_LEFT', wl
, hl
);
2914 g_Texture_Get('UI_GFX_PBAR_RIGHT', idr
);
2915 g_Texture_GetSize('UI_GFX_PBAR_RIGHT', wr
, hr
);
2916 g_Texture_Get('UI_GFX_PBAR_MIDDLE', idb
);
2917 g_Texture_GetSize('UI_GFX_PBAR_MIDDLE', wb
, hb
);
2918 g_Texture_Get('UI_GFX_PBAR_MARKER', idm
);
2919 g_Texture_GetSize('UI_GFX_PBAR_MARKER', wm
, hm
);
2921 //rectW := gScreenWidth-360;
2922 rectW
:= trunc(624.0*gScreenWidth
/1024.0);
2925 x0
:= (gScreenWidth
-rectW
) div 2;
2926 y0
:= gScreenHeight
-rectH
-64;
2927 if (y0
< 2) then y0
:= 2;
2929 glEnable(GL_SCISSOR_TEST
);
2932 glScissor(x0
, gScreenHeight
-y0
-rectH
, rectW
, rectH
);
2933 e_DrawSize(idl
, x0
, y0
, 0, true, false, wl
, hl
);
2934 e_DrawSize(idr
, x0
+rectW
-wr
, y0
, 0, true, false, wr
, hr
);
2937 glScissor(x0
+wl
, gScreenHeight
-y0
-rectH
, rectW
-wl
-wr
, rectH
);
2939 while (f
< x0
+rectW
) do
2941 e_DrawSize(idb
, f
, y0
, 0, true, false, wb
, hb
);
2946 wdt
:= (rectW
-wl
-wr
)*cur
div total
;
2947 if (wdt
> rectW
-wl
-wr
) then wdt
:= rectW
-wr
-wr
;
2950 my
:= y0
; // don't be so smart, ketmar: +(rectH-wm) div 2;
2951 glScissor(x0
+wl
, gScreenHeight
-my
-rectH
, wdt
, hm
);
2955 e_DrawSize(idm
, f
, y0
, 0, true, false, wm
, hm
);
2961 glScissor(0, 0, gScreenWidth
, gScreenHeight
);
2965 rectW
:= gScreenWidth
-64;
2968 x0
:= (gScreenWidth
-rectW
) div 2;
2969 y0
:= gScreenHeight
-rectH
-64;
2970 if (y0
< 2) then y0
:= 2;
2972 glDisable(GL_BLEND
);
2973 glDisable(GL_TEXTURE_2D
);
2975 //glClearColor(0, 0, 0, 0);
2976 //glClear(GL_COLOR_BUFFER_BIT);
2978 glColor4ub(127, 127, 127, 255);
2979 drawRect(x0
-2, y0
-2, rectW
+4, rectH
+4);
2981 glColor4ub(0, 0, 0, 255);
2982 drawRect(x0
-1, y0
-1, rectW
+2, rectH
+2);
2984 glColor4ub(127, 127, 127, 255);
2985 wdt
:= rectW
*cur
div total
;
2986 if (wdt
> rectW
) then wdt
:= rectW
;
2987 drawRect(x0
, y0
, wdt
, rectH
);
2996 if (Length(LoadingStat
.Msgs
) = 0) then exit
;
2998 e_CharFont_GetSize(gMenuFont
, _lc
[I_MENU_LOADING
], ww
, hh
);
2999 yy
:= (gScreenHeight
div 3);
3000 e_CharFont_Print(gMenuFont
, (gScreenWidth
div 2)-(ww
div 2), yy
-2*hh
, _lc
[I_MENU_LOADING
]);
3001 xx
:= (gScreenWidth
div 3);
3005 for i
:= 0 to NextMsg
-1 do
3007 if (i
= (NextMsg
-1)) and (MaxValue
> 0) then
3008 s
:= Format('%s: %d/%d', [Msgs
[i
], CurValue
, MaxValue
])
3012 e_CharFont_PrintEx(gMenuSmallFont
, xx
, yy
, s
, _RGB(255, 0, 0));
3013 yy
:= yy
+ LOADING_INTERLINE
;
3014 PBarWasHere
:= drawPBar(CurValue
, MaxValue
, PBarWasHere
);
3019 procedure DrawMenuBackground(tex
: AnsiString);
3025 if g_Texture_Get(tex
, ID
) then
3027 e_Clear(GL_COLOR_BUFFER_BIT
, 0, 0, 0);
3028 e_GetTextureSize(ID
, @w
, @h
);
3030 w
:= round(w
* 1.333 * (gScreenHeight
/ h
))
3032 w
:= trunc(w
* (gScreenHeight
/ h
));
3033 e_DrawSize(ID
, (gScreenWidth
- w
) div 2, 0, 0, False, False, w
, gScreenHeight
);
3035 else e_Clear(GL_COLOR_BUFFER_BIT
, 0, 0, 0);
3038 procedure DrawMinimap(p
: TPlayer
; RenderRect
: e_graphics
.TRect
);
3040 a
, aX
, aY
, aX2
, aY2
, Scale
, ScaleSz
: Integer;
3042 function monDraw (mon
: TMonster
): Boolean;
3044 result
:= false; // don't stop
3049 // Ëåâûé âåðõíèé óãîë
3050 aX
:= Obj
.X
div ScaleSz
+ 1;
3051 aY
:= Obj
.Y
div ScaleSz
+ 1;
3053 aX2
:= max(Obj
.Rect
.Width
div ScaleSz
, 1);
3054 aY2
:= max(Obj
.Rect
.Height
div ScaleSz
, 1);
3055 // Ïðàâûé íèæíèé óãîë
3056 aX2
:= aX
+ aX2
- 1;
3057 aY2
:= aY
+ aY2
- 1;
3058 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 255, 0, 0);
3064 if (gMapInfo
.Width
> RenderRect
.Right
- RenderRect
.Left
) or
3065 (gMapInfo
.Height
> RenderRect
.Bottom
- RenderRect
.Top
) then
3068 // Ñêîëüêî ïèêñåëîâ êàðòû â 1 ïèêñåëå ìèíè-êàðòû:
3069 ScaleSz
:= 16 div Scale
;
3070 // Ðàçìåðû ìèíè-êàðòû:
3071 aX
:= max(gMapInfo
.Width
div ScaleSz
, 1);
3072 aY
:= max(gMapInfo
.Height
div ScaleSz
, 1);
3074 e_DrawFillQuad(0, 0, aX
-1, aY
-1, 0, 0, 0, 0);
3076 if gWalls
<> nil then
3079 for a
:= 0 to High(gWalls
) do
3081 if PanelType
<> 0 then
3083 // Ëåâûé âåðõíèé óãîë:
3084 aX
:= X
div ScaleSz
;
3085 aY
:= Y
div ScaleSz
;
3087 aX2
:= max(Width
div ScaleSz
, 1);
3088 aY2
:= max(Height
div ScaleSz
, 1);
3089 // Ïðàâûé íèæíèé óãîë:
3090 aX2
:= aX
+ aX2
- 1;
3091 aY2
:= aY
+ aY2
- 1;
3094 PANEL_WALL
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 208, 208, 208, 0);
3095 PANEL_OPENDOOR
, PANEL_CLOSEDOOR
:
3096 if Enabled
then e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 160, 160, 160, 0);
3100 if gSteps
<> nil then
3103 for a
:= 0 to High(gSteps
) do
3105 if PanelType
<> 0 then
3107 // Ëåâûé âåðõíèé óãîë:
3108 aX
:= X
div ScaleSz
;
3109 aY
:= Y
div ScaleSz
;
3111 aX2
:= max(Width
div ScaleSz
, 1);
3112 aY2
:= max(Height
div ScaleSz
, 1);
3113 // Ïðàâûé íèæíèé óãîë:
3114 aX2
:= aX
+ aX2
- 1;
3115 aY2
:= aY
+ aY2
- 1;
3117 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 128, 128, 128, 0);
3120 if gLifts
<> nil then
3123 for a
:= 0 to High(gLifts
) do
3125 if PanelType
<> 0 then
3127 // Ëåâûé âåðõíèé óãîë:
3128 aX
:= X
div ScaleSz
;
3129 aY
:= Y
div ScaleSz
;
3131 aX2
:= max(Width
div ScaleSz
, 1);
3132 aY2
:= max(Height
div ScaleSz
, 1);
3133 // Ïðàâûé íèæíèé óãîë:
3134 aX2
:= aX
+ aX2
- 1;
3135 aY2
:= aY
+ aY2
- 1;
3138 LIFTTYPE_UP
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 116, 72, 36, 0);
3139 LIFTTYPE_DOWN
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 116, 124, 96, 0);
3140 LIFTTYPE_LEFT
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 200, 80, 4, 0);
3141 LIFTTYPE_RIGHT
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 252, 140, 56, 0);
3145 if gWater
<> nil then
3148 for a
:= 0 to High(gWater
) do
3150 if PanelType
<> 0 then
3152 // Ëåâûé âåðõíèé óãîë:
3153 aX
:= X
div ScaleSz
;
3154 aY
:= Y
div ScaleSz
;
3156 aX2
:= max(Width
div ScaleSz
, 1);
3157 aY2
:= max(Height
div ScaleSz
, 1);
3158 // Ïðàâûé íèæíèé óãîë:
3159 aX2
:= aX
+ aX2
- 1;
3160 aY2
:= aY
+ aY2
- 1;
3162 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 0, 192, 0);
3165 if gAcid1
<> nil then
3167 // Ðèñóåì êèñëîòó 1:
3168 for a
:= 0 to High(gAcid1
) do
3170 if PanelType
<> 0 then
3172 // Ëåâûé âåðõíèé óãîë:
3173 aX
:= X
div ScaleSz
;
3174 aY
:= Y
div ScaleSz
;
3176 aX2
:= max(Width
div ScaleSz
, 1);
3177 aY2
:= max(Height
div ScaleSz
, 1);
3178 // Ïðàâûé íèæíèé óãîë:
3179 aX2
:= aX
+ aX2
- 1;
3180 aY2
:= aY
+ aY2
- 1;
3182 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 176, 0, 0);
3185 if gAcid2
<> nil then
3187 // Ðèñóåì êèñëîòó 2:
3188 for a
:= 0 to High(gAcid2
) do
3190 if PanelType
<> 0 then
3192 // Ëåâûé âåðõíèé óãîë:
3193 aX
:= X
div ScaleSz
;
3194 aY
:= Y
div ScaleSz
;
3196 aX2
:= max(Width
div ScaleSz
, 1);
3197 aY2
:= max(Height
div ScaleSz
, 1);
3198 // Ïðàâûé íèæíèé óãîë:
3199 aX2
:= aX
+ aX2
- 1;
3200 aY2
:= aY
+ aY2
- 1;
3202 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 176, 0, 0, 0);
3205 if gPlayers
<> nil then
3208 for a
:= 0 to High(gPlayers
) do
3209 if gPlayers
[a
] <> nil then with gPlayers
[a
] do
3211 // Ëåâûé âåðõíèé óãîë:
3212 aX
:= Obj
.X
div ScaleSz
+ 1;
3213 aY
:= Obj
.Y
div ScaleSz
+ 1;
3215 aX2
:= max(Obj
.Rect
.Width
div ScaleSz
, 1);
3216 aY2
:= max(Obj
.Rect
.Height
div ScaleSz
, 1);
3217 // Ïðàâûé íèæíèé óãîë:
3218 aX2
:= aX
+ aX2
- 1;
3219 aY2
:= aY
+ aY2
- 1;
3221 if gPlayers
[a
] = p
then
3222 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 255, 0, 0)
3225 TEAM_RED
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 0, 0, 0);
3226 TEAM_BLUE
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 0, 255, 0);
3227 else e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 128, 0, 0);
3232 g_Mons_ForEach(monDraw
);
3237 procedure renderAmbientQuad (hasAmbient
: Boolean; constref ambColor
: TDFColor
);
3239 if not hasAmbient
then exit
;
3240 e_AmbientQuad(sX
, sY
, sWidth
, sHeight
, ambColor
.r
, ambColor
.g
, ambColor
.b
, ambColor
.a
);
3244 // setup sX, sY, sWidth, sHeight, and transformation matrix before calling this!
3245 //FIXME: broken for splitscreen mode
3246 procedure renderDynLightsInternal ();
3248 //hasAmbient: Boolean;
3249 //ambColor: TDFColor;
3251 lx
, ly
, lrad
: Integer;
3252 scxywh
: array[0..3] of GLint
;
3255 if e_NoGraphics
then exit
;
3257 //TODO: lights should be in separate grid, i think
3258 // but on the other side: grid may be slower for dynlights, as their lifetime is short
3259 if (not gwin_k8_enable_light_experiments
) or (not gwin_has_stencil
) or (g_dynLightCount
< 1) then exit
;
3262 //ambColor := gCurrentMap['light_ambient'].rgba;
3263 //hasAmbient := (not ambColor.isOpaque) or (not ambColor.isBlack);
3265 { // this will multiply incoming color to alpha from framebuffer
3267 glBlendFunc(GL_DST_ALPHA, GL_ONE);
3271 * light rendering: (INVALID!)
3272 * glStencilFunc(GL_EQUAL, 0, $ff);
3274 * glClear(GL_STENCIL_BUFFER_BIT);
3275 * glStencilOp(GL_KEEP, GL_KEEP, GL_INCR);
3276 * draw shadow volume into stencil buffer
3277 * glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); // modify color buffer
3278 * glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); // don't modify stencil buffer
3280 * draw color-less quad with light alpha (WARNING! don't touch color!)
3281 * glEnable(GL_BLEND);
3282 * glBlendFunc(GL_DST_ALPHA, GL_ONE);
3283 * draw all geometry up to and including walls (with alpha-testing, probably) -- this does lighting
3285 wassc
:= (glIsEnabled(GL_SCISSOR_TEST
) <> 0);
3286 if wassc
then glGetIntegerv(GL_SCISSOR_BOX
, @scxywh
[0]) else glGetIntegerv(GL_VIEWPORT
, @scxywh
[0]);
3288 // setup OpenGL parameters
3289 glStencilMask($FFFFFFFF);
3290 glStencilFunc(GL_ALWAYS
, 0, $FFFFFFFF);
3291 glEnable(GL_STENCIL_TEST
);
3292 glEnable(GL_SCISSOR_TEST
);
3293 glClear(GL_STENCIL_BUFFER_BIT
);
3294 glStencilFunc(GL_EQUAL
, 0, $ff);
3296 for lln
:= 0 to g_dynLightCount
-1 do
3298 lx
:= g_dynLights
[lln
].x
;
3299 ly
:= g_dynLights
[lln
].y
;
3300 lrad
:= g_dynLights
[lln
].radius
;
3301 if (lrad
< 3) then continue
;
3303 if (lx
-sX
+lrad
< 0) then continue
;
3304 if (ly
-sY
+lrad
< 0) then continue
;
3305 if (lx
-sX
-lrad
>= gPlayerScreenSize
.X
) then continue
;
3306 if (ly
-sY
-lrad
>= gPlayerScreenSize
.Y
) then continue
;
3308 // set scissor to optimize drawing
3309 if (g_dbg_scale
= 1.0) then
3311 glScissor((lx
-sX
)-lrad
+2, gPlayerScreenSize
.Y
-(ly
-sY
)-lrad
-1+2, lrad
*2-4, lrad
*2-4);
3315 glScissor(0, 0, gWinSizeX
, gWinSizeY
);
3317 // no need to clear stencil buffer, light blitting will do it for us... but only for normal scale
3318 if (g_dbg_scale
<> 1.0) then glClear(GL_STENCIL_BUFFER_BIT
);
3319 glStencilOp(GL_KEEP
, GL_KEEP
, GL_INCR
);
3320 // draw extruded panels
3321 glDisable(GL_TEXTURE_2D
);
3322 glDisable(GL_BLEND
);
3323 glColorMask(GL_FALSE
, GL_FALSE
, GL_FALSE
, GL_FALSE
); // no need to modify color buffer
3324 if (lrad
> 4) then g_Map_DrawPanelShadowVolumes(lx
, ly
, lrad
);
3325 // render light texture
3326 glColorMask(GL_TRUE
, GL_TRUE
, GL_TRUE
, GL_TRUE
); // modify color buffer
3327 glStencilOp(GL_ZERO
, GL_ZERO
, GL_ZERO
); // draw light, and clear stencil buffer
3330 glBlendFunc(GL_SRC_ALPHA
, GL_ONE_MINUS_SRC_ALPHA
);
3331 glEnable(GL_TEXTURE_2D
);
3332 // color and opacity
3333 glColor4f(g_dynLights
[lln
].r
, g_dynLights
[lln
].g
, g_dynLights
[lln
].b
, g_dynLights
[lln
].a
);
3334 glBindTexture(GL_TEXTURE_2D
, g_Texture_Light());
3336 glTexCoord2f(0.0, 0.0); glVertex2i(lx
-lrad
, ly
-lrad
); // top-left
3337 glTexCoord2f(1.0, 0.0); glVertex2i(lx
+lrad
, ly
-lrad
); // top-right
3338 glTexCoord2f(1.0, 1.0); glVertex2i(lx
+lrad
, ly
+lrad
); // bottom-right
3339 glTexCoord2f(0.0, 1.0); glVertex2i(lx
-lrad
, ly
+lrad
); // bottom-left
3344 glDisable(GL_STENCIL_TEST
);
3345 glDisable(GL_BLEND
);
3346 glDisable(GL_SCISSOR_TEST
);
3347 //glScissor(0, 0, sWidth, sHeight);
3349 glScissor(scxywh
[0], scxywh
[1], scxywh
[2], scxywh
[3]);
3350 if wassc
then glEnable(GL_SCISSOR_TEST
) else glDisable(GL_SCISSOR_TEST
);
3354 function fixViewportForScale (): Boolean;
3356 nx0
, ny0
, nw
, nh
: Integer;
3359 if (g_dbg_scale
<> 1.0) then
3362 nx0
:= round(sX
-(gPlayerScreenSize
.X
-(sWidth
*g_dbg_scale
))/2/g_dbg_scale
);
3363 ny0
:= round(sY
-(gPlayerScreenSize
.Y
-(sHeight
*g_dbg_scale
))/2/g_dbg_scale
);
3364 nw
:= round(sWidth
/g_dbg_scale
);
3365 nh
:= round(sHeight
/g_dbg_scale
);
3374 // setup sX, sY, sWidth, sHeight, and transformation matrix before calling this!
3375 // WARNING! this WILL CALL `glTranslatef()`, but won't restore matrices!
3376 procedure renderMapInternal (backXOfs
, backYOfs
: Integer; setTransMatrix
: Boolean);
3378 TDrawCB
= procedure ();
3381 hasAmbient
: Boolean;
3383 doAmbient
: Boolean = false;
3385 procedure drawPanelType (profname
: AnsiString; panType
: DWord
; doDraw
: Boolean);
3390 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin(profname
);
3391 if gdbg_map_use_accel_render
then
3393 tagmask
:= panelTypeToTag(panType
);
3394 while (gDrawPanelList
.count
> 0) do
3396 pan
:= TPanel(gDrawPanelList
.front());
3397 if ((pan
.tag
and tagmask
) = 0) then break
;
3398 if doDraw
then pan
.Draw(doAmbient
, ambColor
);
3399 gDrawPanelList
.popFront();
3404 if doDraw
then g_Map_DrawPanels(panType
, hasAmbient
, ambColor
);
3406 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
3409 procedure drawOther (profname
: AnsiString; cb
: TDrawCB
);
3411 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin(profname
);
3412 if assigned(cb
) then cb();
3413 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
3417 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin('total');
3419 // our accelerated renderer will collect all panels to gDrawPanelList
3420 // we can use panel tag to render level parts (see GridTagXXX in g_map.pas)
3421 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin('collect');
3422 if gdbg_map_use_accel_render
then
3424 g_Map_CollectDrawPanels(sX
, sY
, sWidth
, sHeight
);
3426 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
3428 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin('skyback');
3429 g_Map_DrawBack(backXOfs
, backYOfs
);
3430 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
3432 if setTransMatrix
then
3434 //if (g_dbg_scale <> 1.0) then glTranslatef(0.0, -0.375/2, 0);
3435 glScalef(g_dbg_scale
, g_dbg_scale
, 1.0);
3436 glTranslatef(-sX
, -sY
, 0);
3440 ambColor
:= gCurrentMap
['light_ambient'].rgba
;
3441 hasAmbient
:= (not ambColor
.isOpaque
) or (not ambColor
.isBlack
);
3446 //writeln('color: (', ambColor.r, ',', ambColor.g, ',', ambColor.b, ',', ambColor.a, ')');
3447 glColor4ub(ambColor.r, ambColor.g, ambColor.b, ambColor.a);
3448 glClear(GL_COLOR_BUFFER_BIT);
3451 //writeln('color: (', ambColor.r, ',', ambColor.g, ',', ambColor.b, ',', ambColor.a, ')');
3454 drawPanelType('*back', PANEL_BACK
, g_rlayer_back
);
3455 drawPanelType('*step', PANEL_STEP
, g_rlayer_step
);
3456 drawOther('items', @g_Items_Draw
);
3457 drawOther('weapons', @g_Weapon_Draw
);
3458 drawOther('shells', @g_Player_DrawShells
);
3459 drawOther('drawall', @g_Player_DrawAll
);
3460 drawOther('corpses', @g_Player_DrawCorpses
);
3461 drawPanelType('*wall', PANEL_WALL
, g_rlayer_wall
);
3462 drawOther('monsters', @g_Monsters_Draw
);
3463 drawOther('itemdrop', @g_Items_DrawDrop
);
3464 drawPanelType('*door', PANEL_CLOSEDOOR
, g_rlayer_door
);
3465 drawOther('gfx', @g_GFX_Draw
);
3466 drawOther('flags', @g_Map_DrawFlags
);
3467 drawPanelType('*acid1', PANEL_ACID1
, g_rlayer_acid1
);
3468 drawPanelType('*acid2', PANEL_ACID2
, g_rlayer_acid2
);
3469 drawPanelType('*water', PANEL_WATER
, g_rlayer_water
);
3470 drawOther('dynlights', @renderDynLightsInternal
);
3472 if hasAmbient
{and ((not g_playerLight) or (not gwin_has_stencil) or (g_dynLightCount < 1))} then
3474 renderAmbientQuad(hasAmbient
, ambColor
);
3478 drawPanelType('*fore', PANEL_FORE
, g_rlayer_fore
);
3481 if g_debug_HealthBar
then
3483 g_Monsters_DrawHealth();
3484 g_Player_DrawHealth();
3487 if (profileFrameDraw
<> nil) then profileFrameDraw
.mainEnd(); // map rendering
3491 procedure DrawMapView(x
, y
, w
, h
: Integer);
3498 bx
:= Round(x
/(gMapInfo
.Width
- w
)*(gBackSize
.X
- w
));
3499 by
:= Round(y
/(gMapInfo
.Height
- h
)*(gBackSize
.Y
- h
));
3506 fixViewportForScale();
3507 renderMapInternal(-bx
, -by
, true);
3513 procedure DrawPlayer(p
: TPlayer
);
3515 px
, py
, a
, b
, c
, d
: Integer;
3518 if (p
= nil) or (p
.FDummy
) then
3521 g_Map_DrawBack(0, 0);
3526 if (profileFrameDraw
= nil) then profileFrameDraw
:= TProfiler
.Create('RENDER', g_profile_history_size
);
3527 if (profileFrameDraw
<> nil) then profileFrameDraw
.mainBegin(g_profile_frame_draw
);
3533 px
:= p
.GameX
+ PLAYER_RECT_CX
;
3534 py
:= p
.GameY
+ PLAYER_RECT_CY
+p
.Obj
.slopeUpLeft
;
3536 if (g_dbg_scale
= 1.0) and (not g_dbg_ignore_bounds
) then
3538 if (px
> (gPlayerScreenSize
.X
div 2)) then a
:= -px
+(gPlayerScreenSize
.X
div 2) else a
:= 0;
3539 if (py
> (gPlayerScreenSize
.Y
div 2)) then b
:= -py
+(gPlayerScreenSize
.Y
div 2) else b
:= 0;
3541 if (px
> gMapInfo
.Width
-(gPlayerScreenSize
.X
div 2)) then a
:= -gMapInfo
.Width
+gPlayerScreenSize
.X
;
3542 if (py
> gMapInfo
.Height
-(gPlayerScreenSize
.Y
div 2)) then b
:= -gMapInfo
.Height
+gPlayerScreenSize
.Y
;
3544 if (gMapInfo
.Width
= gPlayerScreenSize
.X
) then a
:= 0
3545 else if (gMapInfo
.Width
< gPlayerScreenSize
.X
) then
3548 a
:= (gPlayerScreenSize
.X
-gMapInfo
.Width
) div 2;
3551 if (gMapInfo
.Height
= gPlayerScreenSize
.Y
) then b
:= 0
3552 else if (gMapInfo
.Height
< gPlayerScreenSize
.Y
) then
3555 b
:= (gPlayerScreenSize
.Y
-gMapInfo
.Height
) div 2;
3560 // scaled, ignore level bounds
3561 a
:= -px
+(gPlayerScreenSize
.X
div 2);
3562 b
:= -py
+(gPlayerScreenSize
.Y
div 2);
3565 if p
.IncCam
<> 0 then
3567 if py
> gMapInfo
.Height
-(gPlayerScreenSize
.Y
div 2) then
3569 if p
.IncCam
> 120-(py
-(gMapInfo
.Height
-(gPlayerScreenSize
.Y
div 2))) then
3571 p
.IncCam
:= 120-(py
-(gMapInfo
.Height
-(gPlayerScreenSize
.Y
div 2)));
3575 if py
< gPlayerScreenSize
.Y
div 2 then
3577 if p
.IncCam
< -120+((gPlayerScreenSize
.Y
div 2)-py
) then
3579 p
.IncCam
:= -120+((gPlayerScreenSize
.Y
div 2)-py
);
3583 if p
.IncCam
< 0 then
3585 while (py
+(gPlayerScreenSize
.Y
div 2)-p
.IncCam
> gMapInfo
.Height
) and (p
.IncCam
< 0) do p
.IncCam
:= p
.IncCam
+1; //Inc(p.IncCam);
3588 if p
.IncCam
> 0 then
3590 while (py
-(gPlayerScreenSize
.Y
div 2)-p
.IncCam
< 0) and (p
.IncCam
> 0) do p
.IncCam
:= p
.IncCam
-1; //Dec(p.IncCam);
3594 if (px
< gPlayerScreenSize
.X
div 2) or (gMapInfo
.Width
-gPlayerScreenSize
.X
<= 256) then c
:= 0
3595 else if (px
> gMapInfo
.Width
-(gPlayerScreenSize
.X
div 2)) then c
:= gBackSize
.X
-gPlayerScreenSize
.X
3596 else c
:= round((px
-(gPlayerScreenSize
.X
div 2))/(gMapInfo
.Width
-gPlayerScreenSize
.X
)*(gBackSize
.X
-gPlayerScreenSize
.X
));
3598 if (py
-p
.IncCam
<= gPlayerScreenSize
.Y
div 2) or (gMapInfo
.Height
-gPlayerScreenSize
.Y
<= 256) then d
:= 0
3599 else if (py
-p
.IncCam
>= gMapInfo
.Height
-(gPlayerScreenSize
.Y
div 2)) then d
:= gBackSize
.Y
-gPlayerScreenSize
.Y
3600 else d
:= round((py
-p
.IncCam
-(gPlayerScreenSize
.Y
div 2))/(gMapInfo
.Height
-gPlayerScreenSize
.Y
)*(gBackSize
.Y
-gPlayerScreenSize
.Y
));
3603 sY
:= -(b
+p
.IncCam
);
3604 sWidth
:= gPlayerScreenSize
.X
;
3605 sHeight
:= gPlayerScreenSize
.Y
;
3607 //glTranslatef(a, b+p.IncCam, 0);
3609 //if (p = gPlayer1) and (g_dbg_scale >= 1.0) then g_Holmes_plrViewSize(sWidth, sHeight);
3611 //conwritefln('OLD: (%s,%s)-(%s,%s)', [sX, sY, sWidth, sHeight]);
3612 fixViewportForScale();
3613 //conwritefln(' (%s,%s)-(%s,%s)', [sX, sY, sWidth, sHeight]);
3615 if (g_dbg_scale
<> 1.0) and (not g_dbg_ignore_bounds
) then
3617 if (sX
+sWidth
> gMapInfo
.Width
) then sX
:= gMapInfo
.Width
-sWidth
;
3618 if (sY
+sHeight
> gMapInfo
.Height
) then sY
:= gMapInfo
.Height
-sHeight
;
3619 if (sX
< 0) then sX
:= 0;
3620 if (sY
< 0) then sY
:= 0;
3622 if (gBackSize
.X
<= gPlayerScreenSize
.X
) or (gMapInfo
.Width
<= sWidth
) then c
:= 0 else c
:= trunc((gBackSize
.X
-gPlayerScreenSize
.X
)*sX
/(gMapInfo
.Width
-sWidth
));
3623 if (gBackSize
.Y
<= gPlayerScreenSize
.Y
) or (gMapInfo
.Height
<= sHeight
) then d
:= 0 else d
:= trunc((gBackSize
.Y
-gPlayerScreenSize
.Y
)*sY
/(gMapInfo
.Height
-sHeight
));
3626 //r_smallmap_h: 0: left; 1: center; 2: right
3627 //r_smallmap_v: 0: top; 1: center; 2: bottom
3629 if (gMapInfo
.Width
= sWidth
) then
3633 else if (gMapInfo
.Width
< sWidth
) then
3635 case r_smallmap_h
of
3636 1: sX
:= -((sWidth
-gMapInfo
.Width
) div 2); // center
3637 2: sX
:= -(sWidth
-gMapInfo
.Width
); // right
3638 else sX
:= 0; // left
3642 if (gMapInfo
.Height
= sHeight
) then
3646 else if (gMapInfo
.Height
< sHeight
) then
3648 case r_smallmap_v
of
3649 1: sY
:= -((sHeight
-gMapInfo
.Height
) div 2); // center
3650 2: sY
:= -(sHeight
-gMapInfo
.Height
); // bottom
3651 else sY
:= 0; // top
3657 p
.viewPortW
:= sWidth
;
3658 p
.viewPortH
:= sHeight
;
3660 {$IFDEF ENABLE_HOLMES}
3661 if (p
= gPlayer1
) then
3663 g_Holmes_plrViewPos(sX
, sY
);
3664 g_Holmes_plrViewSize(sWidth
, sHeight
);
3668 renderMapInternal(-c
, -d
, true);
3670 if (gGameSettings
.GameMode
<> GM_SINGLE
) and gPlayerIndicator
then
3672 if p
.FSpectator
then
3673 e_TextureFontPrintEx(p
.GameX
+ PLAYER_RECT_CX
- 4,
3674 p
.GameY
+ PLAYER_RECT_CY
- 4,
3675 'X', gStdFont
, 255, 255, 255, 1, True);
3677 for a := 0 to High(gCollideMap) do
3678 for b := 0 to High(gCollideMap[a]) do
3681 if ByteBool(gCollideMap[a, b] and MARK_WALL) then
3683 if ByteBool(gCollideMap[a, b] and MARK_DOOR) then
3687 1: e_DrawPoint(1, b, a, 200, 200, 200);
3688 2: e_DrawPoint(1, b, a, 64, 64, 255);
3689 3: e_DrawPoint(1, b, a, 255, 0, 255);
3699 if gShowMap
then DrawMinimap(p
, _TRect(0, 0, 128, 128));
3700 if g_Debug_Player
then
3701 g_Player_DrawDebug(p
);
3705 procedure drawProfilers ();
3710 if g_profile_frame_draw
and (profileFrameDraw
<> nil) then px
:= px
-drawProfiles(px
, py
, profileFrameDraw
);
3711 if g_profile_collision
and (profMapCollision
<> nil) then begin px
:= px
-drawProfiles(px
, py
, profMapCollision
); py
-= calcProfilesHeight(profMonsLOS
); end;
3712 if g_profile_los
and (profMonsLOS
<> nil) then begin px
:= px
-drawProfiles(px
, py
, profMonsLOS
); py
-= calcProfilesHeight(profMonsLOS
); end;
3715 procedure g_Game_Draw();
3722 plView1
, plView2
: TPlayer
;
3725 if gExit
= EXIT_QUIT
then Exit
;
3727 Time
:= GetTimer() {div 1000};
3728 FPSCounter
:= FPSCounter
+1;
3729 if Time
- FPSTime
>= 1000 then
3736 if gGameOn
or (gState
= STATE_FOLD
) then
3738 if (gPlayer1
<> nil) and (gPlayer2
<> nil) then
3740 gSpectMode
:= SPECT_NONE
;
3741 if not gRevertPlayers
then
3743 plView1
:= gPlayer1
;
3744 plView2
:= gPlayer2
;
3748 plView1
:= gPlayer2
;
3749 plView2
:= gPlayer1
;
3753 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
3755 gSpectMode
:= SPECT_NONE
;
3756 if gPlayer2
= nil then
3759 plView1
:= gPlayer2
;
3768 if (plView1
= nil) and (plView2
= nil) and (gSpectMode
= SPECT_NONE
) then
3769 gSpectMode
:= SPECT_STATS
;
3771 if gSpectMode
= SPECT_PLAYERS
then
3772 if gPlayers
<> nil then
3774 plView1
:= GetActivePlayer_ByID(gSpectPID1
);
3775 if plView1
= nil then
3777 gSpectPID1
:= GetActivePlayerID_Next();
3778 plView1
:= GetActivePlayer_ByID(gSpectPID1
);
3780 if gSpectViewTwo
then
3782 plView2
:= GetActivePlayer_ByID(gSpectPID2
);
3783 if plView2
= nil then
3785 gSpectPID2
:= GetActivePlayerID_Next();
3786 plView2
:= GetActivePlayer_ByID(gSpectPID2
);
3791 if gSpectMode
= SPECT_MAPVIEW
then
3793 // Ðåæèì ïðîñìîòðà êàðòû
3795 e_SetViewPort(0, 0, gScreenWidth
, gScreenHeight
);
3796 DrawMapView(gSpectX
, gSpectY
, gScreenWidth
, gScreenHeight
);
3797 gHearPoint1
.Active
:= True;
3798 gHearPoint1
.Coords
.X
:= gScreenWidth
div 2 + gSpectX
;
3799 gHearPoint1
.Coords
.Y
:= gScreenHeight
div 2 + gSpectY
;
3800 gHearPoint2
.Active
:= False;
3804 Split
:= (plView1
<> nil) and (plView2
<> nil);
3806 // Òî÷êè ñëóõà èãðîêîâ
3807 if plView1
<> nil then
3809 gHearPoint1
.Active
:= True;
3810 gHearPoint1
.Coords
.X
:= plView1
.GameX
+ PLAYER_RECT
.Width
;
3811 gHearPoint1
.Coords
.Y
:= plView1
.GameY
+ PLAYER_RECT
.Height
DIV 2;
3813 gHearPoint1
.Active
:= False;
3814 if plView2
<> nil then
3816 gHearPoint2
.Active
:= True;
3817 gHearPoint2
.Coords
.X
:= plView2
.GameX
+ PLAYER_RECT
.Width
;
3818 gHearPoint2
.Coords
.Y
:= plView2
.GameY
+ PLAYER_RECT
.Height
DIV 2;
3820 gHearPoint2
.Active
:= False;
3822 // Ðàçìåð ýêðàíîâ èãðîêîâ:
3823 gPlayerScreenSize
.X
:= gScreenWidth
-196;
3826 gPlayerScreenSize
.Y
:= gScreenHeight
div 2;
3827 if gScreenHeight
mod 2 = 0 then
3828 Dec(gPlayerScreenSize
.Y
);
3831 gPlayerScreenSize
.Y
:= gScreenHeight
;
3834 if gScreenHeight
mod 2 = 0 then
3835 e_SetViewPort(0, gPlayerScreenSize
.Y
+2, gPlayerScreenSize
.X
+196, gPlayerScreenSize
.Y
)
3837 e_SetViewPort(0, gPlayerScreenSize
.Y
+1, gPlayerScreenSize
.X
+196, gPlayerScreenSize
.Y
);
3839 DrawPlayer(plView1
);
3840 gPlayer1ScreenCoord
.X
:= sX
;
3841 gPlayer1ScreenCoord
.Y
:= sY
;
3845 e_SetViewPort(0, 0, gPlayerScreenSize
.X
+196, gPlayerScreenSize
.Y
);
3847 DrawPlayer(plView2
);
3848 gPlayer2ScreenCoord
.X
:= sX
;
3849 gPlayer2ScreenCoord
.Y
:= sY
;
3852 e_SetViewPort(0, 0, gScreenWidth
, gScreenHeight
);
3855 e_DrawLine(2, 0, gScreenHeight
div 2, gScreenWidth
, gScreenHeight
div 2, 0, 0, 0);
3858 {$IFDEF ENABLE_HOLMES}
3860 if (g_holmes_enabled
) then g_Holmes_Draw();
3863 if MessageText
<> '' then
3867 e_CharFont_GetSizeFmt(gMenuFont
, MessageText
, w
, h
);
3869 e_CharFont_PrintFmt(gMenuFont
, (gScreenWidth
div 2)-(w
div 2),
3870 (gScreenHeight
div 2)-(h
div 2), MessageText
)
3872 e_CharFont_PrintFmt(gMenuFont
, (gScreenWidth
div 2)-(w
div 2),
3873 Round(gScreenHeight
/ 2.75)-(h
div 2), MessageText
);
3876 if IsDrawStat
or (gSpectMode
= 1) then DrawStat();
3878 if gSpectHUD
and (not gChatShow
) and (gSpectMode
<> SPECT_NONE
) and (not gSpectAuto
) then
3880 // Draw spectator GUI
3883 e_TextureFontGetSize(gStdFont
, ww
, hh
);
3886 e_TextureFontPrintEx(0, gScreenHeight
- (hh
+2)*2, 'MODE: Stats', gStdFont
, 255, 255, 255, 1);
3888 e_TextureFontPrintEx(0, gScreenHeight
- (hh
+2)*2, 'MODE: Observe Map', gStdFont
, 255, 255, 255, 1);
3890 e_TextureFontPrintEx(0, gScreenHeight
- (hh
+2)*2, 'MODE: Watch Players', gStdFont
, 255, 255, 255, 1);
3892 e_TextureFontPrintEx(2*ww
, gScreenHeight
- (hh
+2), '< jump >', gStdFont
, 255, 255, 255, 1);
3893 if gSpectMode
= SPECT_STATS
then
3895 e_TextureFontPrintEx(16*ww
, gScreenHeight
- (hh
+2)*2, 'Autoview', gStdFont
, 255, 255, 255, 1);
3896 e_TextureFontPrintEx(16*ww
, gScreenHeight
- (hh
+2), '< fire >', gStdFont
, 255, 255, 255, 1);
3898 if gSpectMode
= SPECT_MAPVIEW
then
3900 e_TextureFontPrintEx(22*ww
, gScreenHeight
- (hh
+2)*2, '[-]', gStdFont
, 255, 255, 255, 1);
3901 e_TextureFontPrintEx(26*ww
, gScreenHeight
- (hh
+2)*2, 'Step ' + IntToStr(gSpectStep
), gStdFont
, 255, 255, 255, 1);
3902 e_TextureFontPrintEx(34*ww
, gScreenHeight
- (hh
+2)*2, '[+]', gStdFont
, 255, 255, 255, 1);
3903 e_TextureFontPrintEx(18*ww
, gScreenHeight
- (hh
+2), '<prev weap>', gStdFont
, 255, 255, 255, 1);
3904 e_TextureFontPrintEx(30*ww
, gScreenHeight
- (hh
+2), '<next weap>', gStdFont
, 255, 255, 255, 1);
3906 if gSpectMode
= SPECT_PLAYERS
then
3908 e_TextureFontPrintEx(22*ww
, gScreenHeight
- (hh
+2)*2, 'Player 1', gStdFont
, 255, 255, 255, 1);
3909 e_TextureFontPrintEx(20*ww
, gScreenHeight
- (hh
+2), '<left/right>', gStdFont
, 255, 255, 255, 1);
3910 if gSpectViewTwo
then
3912 e_TextureFontPrintEx(37*ww
, gScreenHeight
- (hh
+2)*2, 'Player 2', gStdFont
, 255, 255, 255, 1);
3913 e_TextureFontPrintEx(34*ww
, gScreenHeight
- (hh
+2), '<prev w/next w>', gStdFont
, 255, 255, 255, 1);
3914 e_TextureFontPrintEx(52*ww
, gScreenHeight
- (hh
+2)*2, '2x View', gStdFont
, 255, 255, 255, 1);
3915 e_TextureFontPrintEx(51*ww
, gScreenHeight
- (hh
+2), '<up/down>', gStdFont
, 255, 255, 255, 1);
3919 e_TextureFontPrintEx(35*ww
, gScreenHeight
- (hh
+2)*2, '2x View', gStdFont
, 255, 255, 255, 1);
3920 e_TextureFontPrintEx(34*ww
, gScreenHeight
- (hh
+2), '<up/down>', gStdFont
, 255, 255, 255, 1);
3926 if gPauseMain
and gGameOn
and (g_ActiveWindow
= nil) then
3928 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
3929 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
3931 e_CharFont_GetSize(gMenuFont
, _lc
[I_MENU_PAUSE
], w
, h
);
3932 e_CharFont_Print(gMenuFont
, (gScreenWidth
div 2)-(w
div 2),
3933 (gScreenHeight
div 2)-(h
div 2), _lc
[I_MENU_PAUSE
]);
3938 if (gState
= STATE_MENU
) then
3940 if (g_ActiveWindow
= nil) or (g_ActiveWindow
.BackTexture
= '') then DrawMenuBackground('MENU_BACKGROUND');
3941 // F3 at menu will show game loading dialog
3942 if e_KeyPressed(IK_F3
) then g_Menu_Show_LoadMenu(true);
3943 if (g_ActiveWindow
<> nil) then
3945 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
3946 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
3950 // F3 at titlepic will show game loading dialog
3951 if e_KeyPressed(IK_F3
) then
3953 g_Menu_Show_LoadMenu(true);
3954 if (g_ActiveWindow
<> nil) then e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
3959 if gState
= STATE_FOLD
then
3961 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 0, 0, 0, EndingGameCounter
);
3964 if gState
= STATE_INTERCUSTOM
then
3966 if gLastMap
and (gGameSettings
.GameMode
= GM_COOP
) then
3968 back
:= 'TEXTURE_endpic';
3969 if not g_Texture_Get(back
, ID
) then
3970 back
:= _lc
[I_TEXTURE_ENDPIC
];
3975 DrawMenuBackground(back
);
3979 if g_ActiveWindow
<> nil then
3981 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
3982 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
3986 if gState
= STATE_INTERSINGLE
then
3988 if EndingGameCounter
> 0 then
3990 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 0, 0, 0, EndingGameCounter
);
3996 DrawMenuBackground(back
);
4000 if g_ActiveWindow
<> nil then
4002 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4003 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4008 if gState
= STATE_ENDPIC
then
4011 if g_Texture_Get('TEXTURE_endpic', ID
) then DrawMenuBackground('TEXTURE_endpic')
4012 else DrawMenuBackground(_lc
[I_TEXTURE_ENDPIC
]);
4014 if g_ActiveWindow
<> nil then
4016 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4017 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4021 if gState
= STATE_SLIST
then
4023 // if g_Texture_Get('MENU_BACKGROUND', ID) then
4025 // e_DrawSize(ID, 0, 0, 0, False, False, gScreenWidth, gScreenHeight);
4026 // //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4028 DrawMenuBackground('MENU_BACKGROUND');
4029 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4030 g_Serverlist_Draw(slCurrent
, slTable
);
4034 if g_ActiveWindow
<> nil then
4038 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4039 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4041 g_ActiveWindow
.Draw();
4048 if g_debug_Sounds
and gGameOn
then
4050 for w
:= 0 to High(e_SoundsArray
) do
4051 for h
:= 0 to e_SoundsArray
[w
].nRefs
do
4052 e_DrawPoint(1, w
+100, h
+100, 255, 0, 0);
4057 e_TextureFontPrint(0, 0, Format('FPS: %d', [FPS
]), gStdFont
);
4058 e_TextureFontPrint(0, 16, Format('UPS: %d', [UPS
]), gStdFont
);
4061 if gGameOn
and gShowTime
then
4062 drawTime(gScreenWidth
-72, gScreenHeight
-16);
4064 if gGameOn
then drawProfilers();
4066 {$IFDEF ENABLE_HOLMES}
4073 procedure g_Game_Quit();
4075 g_Game_StopAllSounds(True);
4077 g_Game_SaveOptions();
4079 g_PlayerModel_FreeData();
4080 g_Texture_DeleteAll();
4081 g_Frames_DeleteAll();
4083 //g_Menu_Free(); //k8: this segfaults after resolution change; who cares?
4086 if NetInitDone
then g_Net_Free
;
4088 // Íàäî óäàëèòü êàðòó ïîñëå òåñòà:
4089 if gMapToDelete
<> '' then
4090 g_Game_DeleteTestMap();
4096 procedure g_FatalError(Text: String);
4098 g_Console_Add(Format(_lc
[I_FATAL_ERROR
], [Text]), True);
4099 e_WriteLog(Format(_lc
[I_FATAL_ERROR
], [Text]), TMsgType
.Warning
);
4101 gExit
:= EXIT_SIMPLE
;
4104 procedure g_SimpleError(Text: String);
4106 g_Console_Add(Format(_lc
[I_SIMPLE_ERROR
], [Text]), True);
4107 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], [Text]), TMsgType
.Warning
);
4110 procedure g_Game_SetupScreenSize();
4112 RES_FACTOR
= 4.0 / 3.0;
4118 // Ðàçìåð ýêðàíîâ èãðîêîâ:
4119 gPlayerScreenSize
.X
:= gScreenWidth
-196;
4120 if (gPlayer1
<> nil) and (gPlayer2
<> nil) then
4121 gPlayerScreenSize
.Y
:= gScreenHeight
div 2
4123 gPlayerScreenSize
.Y
:= gScreenHeight
;
4125 // Ðàçìåð çàäíåãî ïëàíà:
4126 if BackID
<> DWORD(-1) then
4129 if (gScreenWidth
*s
> gMapInfo
.Width
) or
4130 (gScreenHeight
*s
> gMapInfo
.Height
) then
4132 gBackSize
.X
:= gScreenWidth
;
4133 gBackSize
.Y
:= gScreenHeight
;
4137 e_GetTextureSize(BackID
, @bw
, @bh
);
4138 rf
:= Single(bw
) / Single(bh
);
4139 if (rf
> RES_FACTOR
) then bw
:= Round(Single(bh
) * RES_FACTOR
)
4140 else if (rf
< RES_FACTOR
) then bh
:= Round(Single(bw
) / RES_FACTOR
);
4141 s
:= Max(gScreenWidth
/ bw
, gScreenHeight
/ bh
);
4142 if (s
< 1.0) then s
:= 1.0;
4143 gBackSize
.X
:= Round(bw
*s
);
4144 gBackSize
.Y
:= Round(bh
*s
);
4149 procedure g_Game_ChangeResolution(newWidth
, newHeight
: Word; nowFull
, nowMax
: Boolean);
4151 g_Window_SetSize(newWidth
, newHeight
, nowFull
);
4154 procedure g_Game_AddPlayer(Team
: Byte = TEAM_NONE
);
4156 if ((not gGameOn
) and (gState
<> STATE_INTERCUSTOM
))
4157 or (not (gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
])) then
4159 if gPlayer1
= nil then
4161 if g_Game_IsClient
then
4163 if NetPlrUID1
> -1 then
4165 MC_SEND_CheatRequest(NET_CHEAT_SPECTATE
);
4166 gPlayer1
:= g_Player_Get(NetPlrUID1
);
4171 if not (Team
in [TEAM_RED
, TEAM_BLUE
]) then
4172 Team
:= gPlayer1Settings
.Team
;
4174 // Ñîçäàíèå ïåðâîãî èãðîêà:
4175 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4176 gPlayer1Settings
.Color
,
4178 if gPlayer1
= nil then
4179 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]))
4182 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4183 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [gPlayer1
.Name
]), True);
4184 if g_Game_IsServer
and g_Game_IsNet
then
4185 MH_SEND_PlayerCreate(gPlayer1
.UID
);
4186 gPlayer1
.Respawn(False, True);
4188 if g_Game_IsNet
and NetUseMaster
then
4194 if gPlayer2
= nil then
4196 if g_Game_IsClient
then
4198 if NetPlrUID2
> -1 then
4199 gPlayer2
:= g_Player_Get(NetPlrUID2
);
4203 if not (Team
in [TEAM_RED
, TEAM_BLUE
]) then
4204 Team
:= gPlayer2Settings
.Team
;
4206 // Ñîçäàíèå âòîðîãî èãðîêà:
4207 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
4208 gPlayer2Settings
.Color
,
4210 if gPlayer2
= nil then
4211 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]))
4214 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
4215 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [gPlayer2
.Name
]), True);
4216 if g_Game_IsServer
and g_Game_IsNet
then
4217 MH_SEND_PlayerCreate(gPlayer2
.UID
);
4218 gPlayer2
.Respawn(False, True);
4220 if g_Game_IsNet
and NetUseMaster
then
4228 procedure g_Game_RemovePlayer();
4232 if ((not gGameOn
) and (gState
<> STATE_INTERCUSTOM
))
4233 or (not (gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
])) then
4238 if g_Game_IsServer
then
4241 Pl
.Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
4242 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [Pl
.Name
]), True);
4243 g_Player_Remove(Pl
.UID
);
4245 if g_Game_IsNet
and NetUseMaster
then
4254 if g_Game_IsServer
then
4257 Pl
.Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
4258 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [Pl
.Name
]), True);
4259 g_Player_Remove(Pl
.UID
);
4261 if g_Game_IsNet
and NetUseMaster
then
4266 MC_SEND_CheatRequest(NET_CHEAT_SPECTATE
);
4272 procedure g_Game_Spectate();
4274 g_Game_RemovePlayer();
4275 if gPlayer1
<> nil then
4276 g_Game_RemovePlayer();
4279 procedure g_Game_SpectateCenterView();
4281 gSpectX
:= Max(gMapInfo
.Width
div 2 - gScreenWidth
div 2, 0);
4282 gSpectY
:= Max(gMapInfo
.Height
div 2 - gScreenHeight
div 2, 0);
4285 procedure g_Game_StartSingle(Map
: String; TwoPlayers
: Boolean; nPlayers
: Byte);
4292 e_WriteLog('Starting singleplayer game...', TMsgType
.Notify
);
4294 g_Game_ClearLoading();
4297 FillByte(gGameSettings
, SizeOf(TGameSettings
), 0);
4300 gGameSettings
.GameType
:= GT_SINGLE
;
4301 gGameSettings
.MaxLives
:= 0;
4302 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_ALLOWEXIT
;
4303 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_MONSTERS
;
4304 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_BOTVSMONSTER
;
4305 gSwitchGameMode
:= GM_SINGLE
;
4307 g_Game_ExecuteEvent('ongamestart');
4309 // Óñòàíîâêà ðàçìåðîâ îêîí èãðîêîâ:
4310 g_Game_SetupScreenSize();
4312 // Ñîçäàíèå ïåðâîãî èãðîêà:
4313 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4314 gPlayer1Settings
.Color
,
4315 gPlayer1Settings
.Team
, False));
4316 if gPlayer1
= nil then
4318 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
4322 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4325 // Ñîçäàíèå âòîðîãî èãðîêà, åñëè åñòü:
4328 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
4329 gPlayer2Settings
.Color
,
4330 gPlayer2Settings
.Team
, False));
4331 if gPlayer2
= nil then
4333 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
4337 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
4341 // Çàãðóçêà è çàïóñê êàðòû:
4342 if not g_Game_StartMap(MAP
, True) then
4344 if (Pos(':\', Map
) > 0) or (Pos(':/', Map
) > 0) then tmps
:= Map
else tmps
:= gGameSettings
.WAD
+ ':\' + MAP
;
4345 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [tmps
]));
4349 // Íàñòðîéêè èãðîêîâ è áîòîâ:
4353 for i
:= nPl
+1 to nPlayers
do
4354 g_Player_Create(STD_PLAYER_MODEL
, _RGB(0, 0, 0), 0, True);
4357 procedure g_Game_StartCustom(Map
: String; GameMode
: Byte;
4358 TimeLimit
, GoalLimit
: Word;
4360 Options
: LongWord; nPlayers
: Byte);
4366 e_WriteLog('Starting custom game...', TMsgType
.Notify
);
4368 g_Game_ClearLoading();
4371 gGameSettings
.GameType
:= GT_CUSTOM
;
4372 gGameSettings
.GameMode
:= GameMode
;
4373 gSwitchGameMode
:= GameMode
;
4374 gGameSettings
.TimeLimit
:= TimeLimit
;
4375 gGameSettings
.GoalLimit
:= GoalLimit
;
4376 gGameSettings
.MaxLives
:= IfThen(GameMode
= GM_CTF
, 0, MaxLives
);
4377 gGameSettings
.Options
:= Options
;
4379 gCoopTotalMonstersKilled
:= 0;
4380 gCoopTotalSecretsFound
:= 0;
4381 gCoopTotalMonsters
:= 0;
4382 gCoopTotalSecrets
:= 0;
4386 g_Game_ExecuteEvent('ongamestart');
4388 // Óñòàíîâêà ðàçìåðîâ îêîí èãðîêîâ:
4389 g_Game_SetupScreenSize();
4391 // Ðåæèì íàáëþäàòåëÿ:
4392 if nPlayers
= 0 then
4399 if nPlayers
>= 1 then
4401 // Ñîçäàíèå ïåðâîãî èãðîêà:
4402 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4403 gPlayer1Settings
.Color
,
4404 gPlayer1Settings
.Team
, False));
4405 if gPlayer1
= nil then
4407 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
4411 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4415 if nPlayers
>= 2 then
4417 // Ñîçäàíèå âòîðîãî èãðîêà:
4418 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
4419 gPlayer2Settings
.Color
,
4420 gPlayer2Settings
.Team
, False));
4421 if gPlayer2
= nil then
4423 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
4427 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
4431 // Çàãðóçêà è çàïóñê êàðòû:
4432 if not g_Game_StartMap(Map
, True) then
4434 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [Map
]));
4438 // Íåò òî÷åê ïîÿâëåíèÿ:
4439 if (g_Map_GetPointCount(RESPAWNPOINT_PLAYER1
) +
4440 g_Map_GetPointCount(RESPAWNPOINT_PLAYER2
) +
4441 g_Map_GetPointCount(RESPAWNPOINT_DM
) +
4442 g_Map_GetPointCount(RESPAWNPOINT_RED
)+
4443 g_Map_GetPointCount(RESPAWNPOINT_BLUE
)) < 1 then
4445 g_FatalError(_lc
[I_GAME_ERROR_GET_SPAWN
]);
4449 // Íàñòðîéêè èãðîêîâ è áîòîâ:
4453 for i
:= nPl
+1 to nPlayers
do
4454 g_Player_Create(STD_PLAYER_MODEL
, _RGB(0, 0, 0), 0, True);
4457 procedure g_Game_StartServer(Map
: String; GameMode
: Byte;
4458 TimeLimit
, GoalLimit
: Word; MaxLives
: Byte;
4459 Options
: LongWord; nPlayers
: Byte;
4460 IPAddr
: LongWord; Port
: Word);
4464 e_WriteLog('Starting net game (server)...', TMsgType
.Notify
);
4466 g_Game_ClearLoading();
4469 gGameSettings
.GameType
:= GT_SERVER
;
4470 gGameSettings
.GameMode
:= GameMode
;
4471 gSwitchGameMode
:= GameMode
;
4472 gGameSettings
.TimeLimit
:= TimeLimit
;
4473 gGameSettings
.GoalLimit
:= GoalLimit
;
4474 gGameSettings
.MaxLives
:= IfThen(GameMode
= GM_CTF
, 0, MaxLives
);
4475 gGameSettings
.Options
:= Options
;
4477 gCoopTotalMonstersKilled
:= 0;
4478 gCoopTotalSecretsFound
:= 0;
4479 gCoopTotalMonsters
:= 0;
4480 gCoopTotalSecrets
:= 0;
4484 g_Game_ExecuteEvent('ongamestart');
4486 // Óñòàíîâêà ðàçìåðîâ îêíà èãðîêà
4487 g_Game_SetupScreenSize();
4489 // Ðåæèì íàáëþäàòåëÿ:
4490 if nPlayers
= 0 then
4496 if nPlayers
>= 1 then
4498 // Ñîçäàíèå ïåðâîãî èãðîêà:
4499 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4500 gPlayer1Settings
.Color
,
4501 gPlayer1Settings
.Team
, False));
4502 if gPlayer1
= nil then
4504 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
4508 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4511 if nPlayers
>= 2 then
4513 // Ñîçäàíèå âòîðîãî èãðîêà:
4514 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
4515 gPlayer2Settings
.Color
,
4516 gPlayer2Settings
.Team
, False));
4517 if gPlayer2
= nil then
4519 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
4523 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
4526 g_Game_SetLoadingText(_lc
[I_LOAD_HOST
], 0, False);
4527 if NetForwardPorts
then
4528 g_Game_SetLoadingText(_lc
[I_LOAD_PORTS
], 0, False);
4531 if not g_Net_Host(IPAddr
, Port
, NetMaxClients
) then
4533 g_FatalError(_lc
[I_NET_MSG
] + _lc
[I_NET_ERR_HOST
]);
4537 g_Net_Slist_Set(NetSlistIP
, NetSlistPort
);
4539 // Çàãðóçêà è çàïóñê êàðòû:
4540 if not g_Game_StartMap(Map
, True) then
4542 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [Map
]));
4546 // Íåò òî÷åê ïîÿâëåíèÿ:
4547 if (g_Map_GetPointCount(RESPAWNPOINT_PLAYER1
) +
4548 g_Map_GetPointCount(RESPAWNPOINT_PLAYER2
) +
4549 g_Map_GetPointCount(RESPAWNPOINT_DM
) +
4550 g_Map_GetPointCount(RESPAWNPOINT_RED
)+
4551 g_Map_GetPointCount(RESPAWNPOINT_BLUE
)) < 1 then
4553 g_FatalError(_lc
[I_GAME_ERROR_GET_SPAWN
]);
4557 // Íàñòðîéêè èãðîêîâ è áîòîâ:
4560 NetState
:= NET_STATE_GAME
;
4563 procedure g_Game_StartClient(Addr
: String; Port
: Word; PW
: String);
4578 e_WriteLog('Starting net game (client)...', TMsgType
.Notify
);
4579 e_WriteLog('NET: Trying to connect to ' + Addr
+ ':' + IntToStr(Port
) + '...', TMsgType
.Notify
);
4581 g_Game_ClearLoading();
4584 gGameSettings
.GameType
:= GT_CLIENT
;
4586 gCoopTotalMonstersKilled
:= 0;
4587 gCoopTotalSecretsFound
:= 0;
4588 gCoopTotalMonsters
:= 0;
4589 gCoopTotalSecrets
:= 0;
4593 g_Game_ExecuteEvent('ongamestart');
4595 // Óñòàíîâêà ðàçìåðîâ îêîí èãðîêîâ:
4596 g_Game_SetupScreenSize();
4598 NetState
:= NET_STATE_AUTH
;
4600 g_Game_SetLoadingText(_lc
[I_LOAD_CONNECT
], 0, False);
4602 if not g_Net_Connect(Addr
, Port
) then
4604 g_FatalError(_lc
[I_NET_MSG
] + _lc
[I_NET_ERR_CONN
]);
4605 NetState
:= NET_STATE_NONE
;
4609 g_Game_SetLoadingText(_lc
[I_LOAD_SEND_INFO
], 0, False);
4611 g_Game_SetLoadingText(_lc
[I_LOAD_WAIT_INFO
], 0, False);
4616 while (enet_host_service(NetHost
, @NetEvent
, 0) > 0) do
4618 if (NetEvent
.kind
= ENET_EVENT_TYPE_RECEIVE
) then
4620 Ptr
:= NetEvent
.packet
^.data
;
4621 if not InMsg
.Init(Ptr
, NetEvent
.packet
^.dataLength
, True) then
4624 InMsg
.ReadLongWord(); // skip size
4625 MID
:= InMsg
.ReadByte();
4627 if (MID
= NET_MSG_INFO
) and (State
= 0) then
4629 NetMyID
:= InMsg
.ReadByte();
4630 NetPlrUID1
:= InMsg
.ReadWord();
4632 WadName
:= InMsg
.ReadString();
4633 Map
:= InMsg
.ReadString();
4635 gWADHash
:= InMsg
.ReadMD5();
4637 gGameSettings
.GameMode
:= InMsg
.ReadByte();
4638 gSwitchGameMode
:= gGameSettings
.GameMode
;
4639 gGameSettings
.GoalLimit
:= InMsg
.ReadWord();
4640 gGameSettings
.TimeLimit
:= InMsg
.ReadWord();
4641 gGameSettings
.MaxLives
:= InMsg
.ReadByte();
4642 gGameSettings
.Options
:= InMsg
.ReadLongWord();
4643 T
:= InMsg
.ReadLongWord();
4645 newResPath
:= g_Res_SearchSameWAD(MapsDir
, WadName
, gWADHash
);
4646 if newResPath
= '' then
4648 g_Game_SetLoadingText(_lc
[I_LOAD_DL_RES
], 0, False);
4649 newResPath
:= g_Res_DownloadWAD(WadName
);
4650 if newResPath
= '' then
4652 g_FatalError(_lc
[I_NET_ERR_HASH
]);
4653 enet_packet_destroy(NetEvent
.packet
);
4654 NetState
:= NET_STATE_NONE
;
4658 newResPath
:= ExtractRelativePath(MapsDir
, newResPath
);
4660 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4661 gPlayer1Settings
.Color
,
4662 gPlayer1Settings
.Team
, False));
4664 if gPlayer1
= nil then
4666 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
4668 enet_packet_destroy(NetEvent
.packet
);
4669 NetState
:= NET_STATE_NONE
;
4673 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4674 gPlayer1
.UID
:= NetPlrUID1
;
4675 gPlayer1
.Reset(True);
4677 if not g_Game_StartMap(newResPath
+ ':\' + Map
, True) then
4679 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [WadName
+ ':\' + Map
]));
4681 enet_packet_destroy(NetEvent
.packet
);
4682 NetState
:= NET_STATE_NONE
;
4690 enet_packet_destroy(NetEvent
.packet
);
4694 enet_packet_destroy(NetEvent
.packet
);
4698 if (NetEvent
.kind
= ENET_EVENT_TYPE_DISCONNECT
) then
4701 if (NetEvent
.data
<= NET_DISC_MAX
) then
4702 g_Console_Add(_lc
[I_NET_MSG_ERROR
] + _lc
[I_NET_ERR_CONN
] + ' ' +
4703 _lc
[TStrings_Locale(Cardinal(I_NET_DISC_NONE
) + NetEvent
.data
)], True);
4710 ProcessLoading(true);
4712 if e_KeyPressed(IK_SPACE
) or e_KeyPressed(IK_ESCAPE
) or e_KeyPressed(VK_ESCAPE
) or
4713 e_KeyPressed(JOY0_JUMP
) or e_KeyPressed(JOY1_JUMP
) or e_KeyPressed(JOY2_JUMP
) or e_KeyPressed(JOY3_JUMP
) then
4722 g_FatalError(_lc
[I_NET_MSG
] + _lc
[I_NET_ERR_CONN
]);
4723 NetState
:= NET_STATE_NONE
;
4727 gLMSRespawn
:= LMS_RESPAWN_NONE
;
4728 gLMSRespawnTime
:= 0;
4731 NetState
:= NET_STATE_GAME
;
4732 MC_SEND_FullStateRequest
;
4733 e_WriteLog('NET: Connection successful.', TMsgType
.Notify
);
4736 procedure g_Game_SaveOptions();
4738 g_Options_Write_Video(GameDir
+'/'+CONFIG_FILENAME
);
4741 procedure g_Game_ChangeMap(const MapPath
: String);
4745 g_Game_ClearLoading();
4747 Force
:= gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
];
4748 // Åñëè óðîâåíü çàâåðøèëñÿ ïî òðèããåðó Âûõîä, íå î÷èùàòü èíâåíòàðü
4749 if gExitByTrigger
then
4752 gExitByTrigger
:= False;
4754 if not g_Game_StartMap(MapPath
, Force
) then
4755 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [MapPath
]));
4758 procedure g_Game_Restart();
4762 if g_Game_IsClient
then
4764 map
:= g_ExtractFileName(gMapInfo
.Map
);
4768 g_Game_ClearLoading();
4769 g_Game_StartMap(Map
, True, gCurrentMapFileName
);
4772 function g_Game_StartMap(Map
: String; Force
: Boolean = False; const oldMapPath
: AnsiString=''): Boolean;
4774 NewWAD
, ResName
: String;
4777 g_Map_Free((Map
<> gCurrentMapFileName
) and (oldMapPath
<> gCurrentMapFileName
));
4778 g_Player_RemoveAllCorpses();
4780 if (not g_Game_IsClient
) and
4781 (gSwitchGameMode
<> gGameSettings
.GameMode
) and
4782 (gGameSettings
.GameMode
<> GM_SINGLE
) then
4784 if gSwitchGameMode
= GM_CTF
then
4785 gGameSettings
.MaxLives
:= 0;
4786 gGameSettings
.GameMode
:= gSwitchGameMode
;
4789 gSwitchGameMode
:= gGameSettings
.GameMode
;
4791 g_Player_ResetTeams();
4793 if isWadPath(Map
) then
4795 NewWAD
:= g_ExtractWadName(Map
);
4796 ResName
:= g_ExtractFileName(Map
);
4797 if g_Game_IsServer
then
4799 gWADHash
:= MD5File(MapsDir
+ NewWAD
);
4800 g_Game_LoadWAD(NewWAD
);
4802 // hash received in MC_RECV_GameEvent -> NET_EV_MAPSTART
4803 g_Game_ClientWAD(NewWAD
, gWADHash
);
4807 Result
:= g_Map_Load(MapsDir
+ gGameSettings
.WAD
+ ':\' + ResName
);
4810 g_Player_ResetAll(Force
or gLastMap
, gGameSettings
.GameType
= GT_SINGLE
);
4812 gState
:= STATE_NONE
;
4813 g_ActiveWindow
:= nil;
4819 if gGameSettings
.GameMode
= GM_CTF
then
4821 g_Map_ResetFlag(FLAG_RED
);
4822 g_Map_ResetFlag(FLAG_BLUE
);
4823 // CTF, à ôëàãîâ íåò:
4824 if not g_Map_HaveFlagPoints() then
4825 g_SimpleError(_lc
[I_GAME_ERROR_CTF
]);
4830 gState
:= STATE_MENU
;
4835 gPauseMain
:= false;
4836 gPauseHolmes
:= false;
4838 NetTimeToUpdate
:= 1;
4839 NetTimeToReliable
:= 0;
4840 NetTimeToMaster
:= NetMasterRate
;
4841 gLMSRespawn
:= LMS_RESPAWN_NONE
;
4842 gLMSRespawnTime
:= 0;
4843 gMissionFailed
:= False;
4846 gCoopMonstersKilled
:= 0;
4847 gCoopSecretsFound
:= 0;
4849 gVoteInProgress
:= False;
4850 gVotePassed
:= False;
4856 if not gGameOn
then Exit
;
4858 g_Game_SpectateCenterView();
4860 if (gGameSettings
.MaxLives
> 0) and (gGameSettings
.WarmupTime
> 0) then
4862 gLMSRespawn
:= LMS_RESPAWN_WARMUP
;
4863 gLMSRespawnTime
:= gTime
+ gGameSettings
.WarmupTime
*1000;
4864 gLMSSoftSpawn
:= True;
4865 if NetMode
= NET_SERVER
then
4866 MH_SEND_GameEvent(NET_EV_LMS_WARMUP
, (gLMSRespawnTime
- gTime
) div 1000)
4868 g_Console_Add(Format(_lc
[I_MSG_WARMUP_START
], [(gLMSRespawnTime
- gTime
) div 1000]), True);
4871 if NetMode
= NET_SERVER
then
4873 MH_SEND_GameEvent(NET_EV_MAPSTART
, gGameSettings
.GameMode
, Map
);
4876 if NetUseMaster
then
4878 if (NetMHost
= nil) or (NetMPeer
= nil) then
4879 if not g_Net_Slist_Connect
then
4880 g_Console_Add(_lc
[I_NET_MSG_ERROR
] + _lc
[I_NET_SLIST_ERROR
]);
4885 if NetClients
<> nil then
4886 for I
:= 0 to High(NetClients
) do
4887 if NetClients
[I
].Used
then
4889 NetClients
[I
].Voted
:= False;
4890 if NetClients
[I
].RequestedFullUpdate
then
4892 MH_SEND_Everything((NetClients
[I
].State
= NET_STATE_AUTH
), I
);
4893 NetClients
[I
].RequestedFullUpdate
:= False;
4897 g_Net_UnbanNonPermHosts();
4902 gCoopTotalMonstersKilled
:= 0;
4903 gCoopTotalSecretsFound
:= 0;
4904 gCoopTotalMonsters
:= 0;
4905 gCoopTotalSecrets
:= 0;
4909 g_Game_ExecuteEvent('onmapstart');
4912 procedure SetFirstLevel();
4916 MapList
:= g_Map_GetMapsList(MapsDir
+ gGameSettings
.WAD
);
4917 if MapList
= nil then
4920 SortSArray(MapList
);
4921 gNextMap
:= MapList
[Low(MapList
)];
4926 procedure g_Game_ExitLevel(const Map
: AnsiString);
4930 gCoopTotalMonstersKilled
:= gCoopTotalMonstersKilled
+ gCoopMonstersKilled
;
4931 gCoopTotalSecretsFound
:= gCoopTotalSecretsFound
+ gCoopSecretsFound
;
4932 gCoopTotalMonsters
:= gCoopTotalMonsters
+ gTotalMonsters
;
4933 gCoopTotalSecrets
:= gCoopTotalSecrets
+ gSecretsCount
;
4935 // Âûøëè â âûõîä â Îäèíî÷íîé èãðå:
4936 if gGameSettings
.GameType
= GT_SINGLE
then
4937 gExit
:= EXIT_ENDLEVELSINGLE
4938 else // Âûøëè â âûõîä â Ñâîåé èãðå
4940 gExit
:= EXIT_ENDLEVELCUSTOM
;
4941 if gGameSettings
.GameMode
= GM_COOP
then
4942 g_Player_RememberAll
;
4944 if not g_Map_Exist(MapsDir
+ gGameSettings
.WAD
+ ':\' + gNextMap
) then
4947 if gGameSettings
.GameMode
= GM_COOP
then
4950 gStatsPressed
:= True;
4951 gNextMap
:= 'MAP01';
4953 if not g_Map_Exist(MapsDir
+ gGameSettings
.WAD
+ ':\' + gNextMap
) then
4956 if g_Game_IsNet
then
4958 MH_SEND_GameStats();
4959 MH_SEND_CoopStats();
4965 procedure g_Game_RestartLevel();
4969 if gGameSettings
.GameMode
= GM_SINGLE
then
4974 gExit
:= EXIT_ENDLEVELCUSTOM
;
4975 Map
:= g_ExtractFileName(gMapInfo
.Map
);
4979 procedure g_Game_ClientWAD(NewWAD
: String; WHash
: TMD5Digest
);
4983 if LowerCase(NewWAD
) = LowerCase(gGameSettings
.WAD
) then
4985 if not g_Game_IsClient
then
4987 gWAD
:= g_Res_SearchSameWAD(MapsDir
, ExtractFileName(NewWAD
), WHash
);
4990 g_Game_SetLoadingText(_lc
[I_LOAD_DL_RES
], 0, False);
4991 gWAD
:= g_Res_DownloadWAD(ExtractFileName(NewWAD
));
4995 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_WAD
], [ExtractFileName(NewWAD
)]));
4999 NewWAD
:= ExtractRelativePath(MapsDir
, gWAD
);
5000 g_Game_LoadWAD(NewWAD
);
5003 procedure g_Game_RestartRound(NoMapRestart
: Boolean = False);
5005 i
, n
, nb
, nr
: Integer;
5007 function monRespawn (mon
: TMonster
): Boolean;
5009 result
:= false; // don't stop
5010 if not mon
.FNoRespawn
then mon
.Respawn();
5014 if not g_Game_IsServer
then Exit
;
5015 if gLMSRespawn
= LMS_RESPAWN_NONE
then Exit
;
5016 gLMSRespawn
:= LMS_RESPAWN_NONE
;
5017 gLMSRespawnTime
:= 0;
5020 if (gGameSettings
.GameMode
= GM_COOP
) and not NoMapRestart
then
5022 gMissionFailed
:= True;
5023 g_Game_RestartLevel
;
5027 n
:= 0; nb
:= 0; nr
:= 0;
5028 for i
:= Low(gPlayers
) to High(gPlayers
) do
5029 if (gPlayers
[i
] <> nil) and
5030 ((not gPlayers
[i
].FSpectator
) or gPlayers
[i
].FWantsInGame
or
5031 (gPlayers
[i
] is TBot
)) then
5034 if gPlayers
[i
].Team
= TEAM_RED
then Inc(nr
)
5035 else if gPlayers
[i
].Team
= TEAM_BLUE
then Inc(nb
)
5038 if (n
< 2) or ((gGameSettings
.GameMode
= GM_TDM
) and ((nr
= 0) or (nb
= 0))) then
5040 // wait a second until the fuckers finally decide to join
5041 gLMSRespawn
:= LMS_RESPAWN_WARMUP
;
5042 gLMSRespawnTime
:= gTime
+ 1000;
5043 gLMSSoftSpawn
:= NoMapRestart
;
5047 g_Player_RemoveAllCorpses
;
5048 g_Game_Message(_lc
[I_MESSAGE_LMS_START
], 144);
5049 if g_Game_IsNet
then
5050 MH_SEND_GameEvent(NET_EV_LMS_START
);
5052 for i
:= Low(gPlayers
) to High(gPlayers
) do
5054 if gPlayers
[i
] = nil then continue
;
5055 if gPlayers
[i
] is TBot
then gPlayers
[i
].FWantsInGame
:= True;
5056 // don't touch normal spectators
5057 if gPlayers
[i
].FSpectator
and not gPlayers
[i
].FWantsInGame
then
5059 gPlayers
[i
].FNoRespawn
:= True;
5060 gPlayers
[i
].Lives
:= 0;
5061 if g_Game_IsNet
then
5062 MH_SEND_PlayerStats(gPlayers
[I
].UID
);
5065 gPlayers
[i
].FNoRespawn
:= False;
5066 gPlayers
[i
].Lives
:= gGameSettings
.MaxLives
;
5067 gPlayers
[i
].Respawn(False, True);
5068 if gGameSettings
.GameMode
= GM_COOP
then
5070 gPlayers
[i
].Frags
:= 0;
5071 gPlayers
[i
].RecallState
;
5073 if (gPlayer1
= nil) and (gLMSPID1
> 0) then
5074 gPlayer1
:= g_Player_Get(gLMSPID1
);
5075 if (gPlayer2
= nil) and (gLMSPID2
> 0) then
5076 gPlayer2
:= g_Player_Get(gLMSPID2
);
5079 g_Items_RestartRound();
5082 g_Mons_ForEach(monRespawn
);
5084 gLMSSoftSpawn
:= False;
5087 function g_Game_GetFirstMap(WAD
: String): String;
5091 MapList
:= g_Map_GetMapsList(WAD
);
5092 if MapList
= nil then
5095 SortSArray(MapList
);
5096 Result
:= MapList
[Low(MapList
)];
5098 if not g_Map_Exist(WAD
+ ':\' + Result
) then
5104 function g_Game_GetNextMap(): String;
5111 MapList
:= g_Map_GetMapsList(MapsDir
+ gGameSettings
.WAD
);
5112 if MapList
= nil then
5115 Map
:= g_ExtractFileName(gMapInfo
.Map
);
5117 SortSArray(MapList
);
5119 for I
:= Low(MapList
) to High(MapList
) do
5120 if Map
= MapList
[I
] then
5126 if MapIndex
<> -255 then
5128 if MapIndex
= High(MapList
) then
5129 Result
:= MapList
[Low(MapList
)]
5131 Result
:= MapList
[MapIndex
+ 1];
5133 if not g_Map_Exist(MapsDir
+ gGameSettings
.WAD
+ ':\' + Result
) then Result
:= Map
;
5139 procedure g_Game_NextLevel();
5141 if gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
, GM_COOP
] then
5142 gExit
:= EXIT_ENDLEVELCUSTOM
5145 gExit
:= EXIT_ENDLEVELSINGLE
;
5149 if gNextMap
<> '' then Exit
;
5150 gNextMap
:= g_Game_GetNextMap();
5153 function g_Game_IsTestMap(): Boolean;
5155 result
:= StrEquCI1251(TEST_MAP_NAME
, g_ExtractFileName(gMapInfo
.Map
));
5158 procedure g_Game_DeleteTestMap();
5161 //MapName: AnsiString;
5169 a
:= Pos('.wad:\', toLowerCase1251(gMapToDelete
));
5170 if (a
= 0) then a
:= Pos('.wad:/', toLowerCase1251(gMapToDelete
));
5171 if (a
= 0) then exit
;
5173 // Âûäåëÿåì èìÿ wad-ôàéëà è èìÿ êàðòû
5174 WadName
:= Copy(gMapToDelete
, 1, a
+3);
5175 Delete(gMapToDelete
, 1, a
+5);
5176 gMapToDelete
:= UpperCase(gMapToDelete
);
5178 //CopyMemory(@MapName[0], @gMapToDelete[1], Min(16, Length(gMapToDelete)));
5181 // Èìÿ êàðòû íå ñòàíäàðòíîå òåñòîâîå:
5182 if MapName <> TEST_MAP_NAME then
5185 if not gTempDelete then
5187 time := g_GetFileTime(WadName);
5188 WAD := TWADFile.Create();
5191 if not WAD.ReadFile(WadName) then
5192 begin // Íåò òàêîãî WAD-ôàéëà
5197 // Ñîñòàâëÿåì ñïèñîê êàðò è èùåì íóæíóþ:
5199 MapList := WAD.GetResourcesList('');
5201 if MapList <> nil then
5202 for a := 0 to High(MapList) do
5203 if MapList[a] = MapName then
5205 // Óäàëÿåì è ñîõðàíÿåì:
5206 WAD.RemoveResource('', MapName);
5207 WAD.SaveTo(WadName);
5212 g_SetFileTime(WadName, time);
5215 if gTempDelete
then DeleteFile(WadName
);
5218 procedure GameCVars(P
: SSArray
);
5221 stat
: TPlayerStatArray
;
5226 cmd
:= LowerCase(P
[0]);
5227 if (cmd
= 'g_friendlyfire') and not g_Game_IsClient
then
5229 with gGameSettings
do
5231 if (Length(P
) > 1) and
5232 ((P
[1] = '1') or (P
[1] = '0')) then
5234 if (P
[1][1] = '1') then
5235 Options
:= Options
or GAME_OPTION_TEAMDAMAGE
5237 Options
:= Options
and (not GAME_OPTION_TEAMDAMAGE
);
5240 if (LongBool(Options
and GAME_OPTION_TEAMDAMAGE
)) then
5241 g_Console_Add(_lc
[I_MSG_FRIENDLY_FIRE_ON
])
5243 g_Console_Add(_lc
[I_MSG_FRIENDLY_FIRE_OFF
]);
5245 if g_Game_IsNet
then MH_SEND_GameSettings
;
5248 else if (cmd
= 'g_weaponstay') and not g_Game_IsClient
then
5250 with gGameSettings
do
5252 if (Length(P
) > 1) and
5253 ((P
[1] = '1') or (P
[1] = '0')) then
5255 if (P
[1][1] = '1') then
5256 Options
:= Options
or GAME_OPTION_WEAPONSTAY
5258 Options
:= Options
and (not GAME_OPTION_WEAPONSTAY
);
5261 if (LongBool(Options
and GAME_OPTION_WEAPONSTAY
)) then
5262 g_Console_Add(_lc
[I_MSG_WEAPONSTAY_ON
])
5264 g_Console_Add(_lc
[I_MSG_WEAPONSTAY_OFF
]);
5266 if g_Game_IsNet
then MH_SEND_GameSettings
;
5269 else if cmd
= 'g_gamemode' then
5271 a
:= g_Game_TextToMode(P
[1]);
5272 if a
= GM_SINGLE
then a
:= GM_COOP
;
5273 if (Length(P
) > 1) and (a
<> GM_NONE
) and (not g_Game_IsClient
) then
5275 gSwitchGameMode
:= a
;
5276 if (gGameOn
and (gGameSettings
.GameMode
= GM_SINGLE
)) or
5277 (gState
= STATE_INTERSINGLE
) then
5278 gSwitchGameMode
:= GM_SINGLE
;
5280 gGameSettings
.GameMode
:= gSwitchGameMode
;
5282 if gSwitchGameMode
= gGameSettings
.GameMode
then
5283 g_Console_Add(Format(_lc
[I_MSG_GAMEMODE_CURRENT
],
5284 [g_Game_ModeToText(gGameSettings
.GameMode
)]))
5286 g_Console_Add(Format(_lc
[I_MSG_GAMEMODE_CHANGE
],
5287 [g_Game_ModeToText(gGameSettings
.GameMode
),
5288 g_Game_ModeToText(gSwitchGameMode
)]));
5290 else if (cmd
= 'g_allow_exit') and not g_Game_IsClient
then
5292 with gGameSettings
do
5294 if (Length(P
) > 1) and
5295 ((P
[1] = '1') or (P
[1] = '0')) then
5297 if (P
[1][1] = '1') then
5298 Options
:= Options
or GAME_OPTION_ALLOWEXIT
5300 Options
:= Options
and (not GAME_OPTION_ALLOWEXIT
);
5303 if (LongBool(Options
and GAME_OPTION_ALLOWEXIT
)) then
5304 g_Console_Add(_lc
[I_MSG_ALLOWEXIT_ON
])
5306 g_Console_Add(_lc
[I_MSG_ALLOWEXIT_OFF
]);
5307 g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
5309 if g_Game_IsNet
then MH_SEND_GameSettings
;
5312 else if (cmd
= 'g_allow_monsters') and not g_Game_IsClient
then
5314 with gGameSettings
do
5316 if (Length(P
) > 1) and
5317 ((P
[1] = '1') or (P
[1] = '0')) then
5319 if (P
[1][1] = '1') then
5320 Options
:= Options
or GAME_OPTION_MONSTERS
5322 Options
:= Options
and (not GAME_OPTION_MONSTERS
);
5325 if (LongBool(Options
and GAME_OPTION_MONSTERS
)) then
5326 g_Console_Add(_lc
[I_MSG_ALLOWMON_ON
])
5328 g_Console_Add(_lc
[I_MSG_ALLOWMON_OFF
]);
5329 g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
5331 if g_Game_IsNet
then MH_SEND_GameSettings
;
5334 else if (cmd
= 'g_bot_vsplayers') and not g_Game_IsClient
then
5336 with gGameSettings
do
5338 if (Length(P
) > 1) and
5339 ((P
[1] = '1') or (P
[1] = '0')) then
5341 if (P
[1][1] = '1') then
5342 Options
:= Options
or GAME_OPTION_BOTVSPLAYER
5344 Options
:= Options
and (not GAME_OPTION_BOTVSPLAYER
);
5347 if (LongBool(Options
and GAME_OPTION_BOTVSPLAYER
)) then
5348 g_Console_Add(_lc
[I_MSG_BOTSVSPLAYERS_ON
])
5350 g_Console_Add(_lc
[I_MSG_BOTSVSPLAYERS_OFF
]);
5352 if g_Game_IsNet
then MH_SEND_GameSettings
;
5355 else if (cmd
= 'g_bot_vsmonsters') and not g_Game_IsClient
then
5357 with gGameSettings
do
5359 if (Length(P
) > 1) and
5360 ((P
[1] = '1') or (P
[1] = '0')) then
5362 if (P
[1][1] = '1') then
5363 Options
:= Options
or GAME_OPTION_BOTVSMONSTER
5365 Options
:= Options
and (not GAME_OPTION_BOTVSMONSTER
);
5368 if (LongBool(Options
and GAME_OPTION_BOTVSMONSTER
)) then
5369 g_Console_Add(_lc
[I_MSG_BOTSVSMONSTERS_ON
])
5371 g_Console_Add(_lc
[I_MSG_BOTSVSMONSTERS_OFF
]);
5373 if g_Game_IsNet
then MH_SEND_GameSettings
;
5376 else if (cmd
= 'g_warmuptime') and not g_Game_IsClient
then
5378 if Length(P
) > 1 then
5380 if StrToIntDef(P
[1], gGameSettings
.WarmupTime
) = 0 then
5381 gGameSettings
.WarmupTime
:= 30
5383 gGameSettings
.WarmupTime
:= StrToIntDef(P
[1], gGameSettings
.WarmupTime
);
5386 g_Console_Add(Format(_lc
[I_MSG_WARMUP
],
5387 [gGameSettings
.WarmupTime
]));
5388 g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
5390 else if cmd
= 'net_interp' then
5392 if (Length(P
) > 1) then
5393 NetInterpLevel
:= StrToIntDef(P
[1], NetInterpLevel
);
5395 g_Console_Add('net_interp = ' + IntToStr(NetInterpLevel
));
5396 config
:= TConfig
.CreateFile(GameDir
+'/'+CONFIG_FILENAME
);
5397 config
.WriteInt('Client', 'InterpolationSteps', NetInterpLevel
);
5398 config
.SaveFile(GameDir
+'/'+CONFIG_FILENAME
);
5401 else if cmd
= 'net_forceplayerupdate' then
5403 if (Length(P
) > 1) and
5404 ((P
[1] = '1') or (P
[1] = '0')) then
5405 NetForcePlayerUpdate
:= (P
[1][1] = '1');
5407 if NetForcePlayerUpdate
then
5408 g_Console_Add('net_forceplayerupdate = 1')
5410 g_Console_Add('net_forceplayerupdate = 0');
5411 config
:= TConfig
.CreateFile(GameDir
+'/'+CONFIG_FILENAME
);
5412 config
.WriteBool('Client', 'ForcePlayerUpdate', NetForcePlayerUpdate
);
5413 config
.SaveFile(GameDir
+'/'+CONFIG_FILENAME
);
5416 else if cmd
= 'net_predictself' then
5418 if (Length(P
) > 1) and
5419 ((P
[1] = '1') or (P
[1] = '0')) then
5420 NetPredictSelf
:= (P
[1][1] = '1');
5422 if NetPredictSelf
then
5423 g_Console_Add('net_predictself = 1')
5425 g_Console_Add('net_predictself = 0');
5426 config
:= TConfig
.CreateFile(GameDir
+'/'+CONFIG_FILENAME
);
5427 config
.WriteBool('Client', 'PredictSelf', NetPredictSelf
);
5428 config
.SaveFile(GameDir
+'/'+CONFIG_FILENAME
);
5431 else if cmd
= 'sv_name' then
5433 if (Length(P
) > 1) and (Length(P
[1]) > 0) then
5435 NetServerName
:= P
[1];
5436 if Length(NetServerName
) > 64 then
5437 SetLength(NetServerName
, 64);
5438 if g_Game_IsServer
and g_Game_IsNet
and NetUseMaster
then
5442 g_Console_Add(cmd
+ ' = "' + NetServerName
+ '"');
5444 else if cmd
= 'sv_passwd' then
5446 if (Length(P
) > 1) and (Length(P
[1]) > 0) then
5448 NetPassword
:= P
[1];
5449 if Length(NetPassword
) > 24 then
5450 SetLength(NetPassword
, 24);
5451 if g_Game_IsServer
and g_Game_IsNet
and NetUseMaster
then
5455 g_Console_Add(cmd
+ ' = "' + AnsiLowerCase(NetPassword
) + '"');
5457 else if cmd
= 'sv_maxplrs' then
5459 if (Length(P
) > 1) then
5461 NetMaxClients
:= Min(Max(StrToIntDef(P
[1], NetMaxClients
), 1), NET_MAXCLIENTS
);
5462 if g_Game_IsServer
and g_Game_IsNet
then
5465 for a
:= 0 to High(NetClients
) do
5466 if NetClients
[a
].Used
then
5469 if b
> NetMaxClients
then
5471 s
:= g_Player_Get(NetClients
[a
].Player
).Name
;
5472 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_FULL
);
5473 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
5474 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
5477 if NetUseMaster
then
5482 g_Console_Add(cmd
+ ' = ' + IntToStr(NetMaxClients
));
5484 else if cmd
= 'sv_public' then
5486 if (Length(P
) > 1) then
5488 NetUseMaster
:= StrToIntDef(P
[1], Byte(NetUseMaster
)) > 0;
5489 if g_Game_IsServer
and g_Game_IsNet
then
5490 if NetUseMaster
then
5492 if NetMPeer
= nil then
5493 if not g_Net_Slist_Connect() then
5494 g_Console_Add(_lc
[I_NET_MSG_ERROR
] + _lc
[I_NET_SLIST_ERROR
]);
5495 g_Net_Slist_Update();
5498 if NetMPeer
<> nil then
5499 g_Net_Slist_Disconnect();
5502 g_Console_Add(cmd
+ ' = ' + IntToStr(Byte(NetUseMaster
)));
5504 else if cmd
= 'sv_intertime' then
5506 if (Length(P
) > 1) then
5507 gDefInterTime
:= Min(Max(StrToIntDef(P
[1], gDefInterTime
), -1), 120);
5509 g_Console_Add(cmd
+ ' = ' + IntToStr(gDefInterTime
));
5511 else if cmd
= 'p1_name' then
5513 if (Length(P
) > 1) and gGameOn
then
5515 if g_Game_IsClient
then
5517 gPlayer1Settings
.Name
:= b_Text_Unformat(P
[1]);
5518 MC_SEND_PlayerSettings
;
5521 if gPlayer1
<> nil then
5523 gPlayer1
.Name
:= b_Text_Unformat(P
[1]);
5524 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer1
.UID
);
5527 gPlayer1Settings
.Name
:= b_Text_Unformat(P
[1]);
5530 else if cmd
= 'p2_name' then
5532 if (Length(P
) > 1) and gGameOn
then
5534 if g_Game_IsClient
then
5536 gPlayer2Settings
.Name
:= b_Text_Unformat(P
[1]);
5537 MC_SEND_PlayerSettings
;
5540 if gPlayer2
<> nil then
5542 gPlayer2
.Name
:= b_Text_Unformat(P
[1]);
5543 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer2
.UID
);
5546 gPlayer2Settings
.Name
:= b_Text_Unformat(P
[1]);
5549 else if cmd
= 'p1_color' then
5551 if Length(P
) > 3 then
5552 if g_Game_IsClient
then
5554 gPlayer1Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
5555 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
5556 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
5557 MC_SEND_PlayerSettings
;
5560 if gPlayer1
<> nil then
5562 gPlayer1
.Model
.SetColor(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
5563 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
5564 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
5565 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer1
.UID
);
5568 gPlayer1Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
5569 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
5570 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
5572 else if (cmd
= 'p2_color') and not g_Game_IsNet
then
5574 if Length(P
) > 3 then
5575 if g_Game_IsClient
then
5577 gPlayer2Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
5578 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
5579 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
5580 MC_SEND_PlayerSettings
;
5583 if gPlayer2
<> nil then
5585 gPlayer2
.Model
.SetColor(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
5586 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
5587 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
5588 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer2
.UID
);
5591 gPlayer2Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
5592 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
5593 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
5595 else if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
5597 if cmd
= 'r_showscore' then
5599 if (Length(P
) > 1) and
5600 ((P
[1] = '1') or (P
[1] = '0')) then
5601 gShowGoals
:= (P
[1][1] = '1');
5604 g_Console_Add(_lc
[I_MSG_SCORE_ON
])
5606 g_Console_Add(_lc
[I_MSG_SCORE_OFF
]);
5608 else if cmd
= 'r_showstat' then
5610 if (Length(P
) > 1) and
5611 ((P
[1] = '1') or (P
[1] = '0')) then
5612 gShowStat
:= (P
[1][1] = '1');
5615 g_Console_Add(_lc
[I_MSG_STATS_ON
])
5617 g_Console_Add(_lc
[I_MSG_STATS_OFF
]);
5619 else if cmd
= 'r_showkillmsg' then
5621 if (Length(P
) > 1) and
5622 ((P
[1] = '1') or (P
[1] = '0')) then
5623 gShowKillMsg
:= (P
[1][1] = '1');
5625 if gShowKillMsg
then
5626 g_Console_Add(_lc
[I_MSG_KILL_MSGS_ON
])
5628 g_Console_Add(_lc
[I_MSG_KILL_MSGS_OFF
]);
5630 else if cmd
= 'r_showlives' then
5632 if (Length(P
) > 1) and
5633 ((P
[1] = '1') or (P
[1] = '0')) then
5634 gShowLives
:= (P
[1][1] = '1');
5637 g_Console_Add(_lc
[I_MSG_LIVES_ON
])
5639 g_Console_Add(_lc
[I_MSG_LIVES_OFF
]);
5641 else if cmd
= 'r_showspect' then
5643 if (Length(P
) > 1) and
5644 ((P
[1] = '1') or (P
[1] = '0')) then
5645 gSpectHUD
:= (P
[1][1] = '1');
5648 g_Console_Add(_lc
[I_MSG_SPECT_HUD_ON
])
5650 g_Console_Add(_lc
[I_MSG_SPECT_HUD_OFF
]);
5652 else if cmd
= 'r_showping' then
5654 if (Length(P
) > 1) and
5655 ((P
[1] = '1') or (P
[1] = '0')) then
5656 gShowPing
:= (P
[1][1] = '1');
5659 g_Console_Add(_lc
[I_MSG_PING_ON
])
5661 g_Console_Add(_lc
[I_MSG_PING_OFF
]);
5663 else if (cmd
= 'g_scorelimit') and not g_Game_IsClient
then
5665 if Length(P
) > 1 then
5667 if StrToIntDef(P
[1], gGameSettings
.GoalLimit
) = 0 then
5668 gGameSettings
.GoalLimit
:= 0
5673 if gGameSettings
.GameMode
= GM_DM
then
5675 stat
:= g_Player_GetStats();
5677 for a
:= 0 to High(stat
) do
5678 if stat
[a
].Frags
> b
then
5682 b
:= Max(gTeamStat
[TEAM_RED
].Goals
, gTeamStat
[TEAM_BLUE
].Goals
);
5684 gGameSettings
.GoalLimit
:= Max(StrToIntDef(P
[1], gGameSettings
.GoalLimit
), b
);
5687 if g_Game_IsNet
then MH_SEND_GameSettings
;
5690 g_Console_Add(Format(_lc
[I_MSG_SCORE_LIMIT
], [gGameSettings
.GoalLimit
]));
5692 else if (cmd
= 'g_timelimit') and not g_Game_IsClient
then
5694 if (Length(P
) > 1) and (StrToIntDef(P
[1], -1) >= 0) then
5695 gGameSettings
.TimeLimit
:= StrToIntDef(P
[1], -1);
5697 g_Console_Add(Format(_lc
[I_MSG_TIME_LIMIT
],
5698 [gGameSettings
.TimeLimit
div 3600,
5699 (gGameSettings
.TimeLimit
div 60) mod 60,
5700 gGameSettings
.TimeLimit
mod 60]));
5701 if g_Game_IsNet
then MH_SEND_GameSettings
;
5703 else if (cmd
= 'g_maxlives') and not g_Game_IsClient
then
5705 if Length(P
) > 1 then
5707 if StrToIntDef(P
[1], gGameSettings
.MaxLives
) = 0 then
5708 gGameSettings
.MaxLives
:= 0
5712 stat
:= g_Player_GetStats();
5714 for a
:= 0 to High(stat
) do
5715 if stat
[a
].Lives
> b
then
5717 gGameSettings
.MaxLives
:=
5718 Max(StrToIntDef(P
[1], gGameSettings
.MaxLives
), b
);
5722 g_Console_Add(Format(_lc
[I_MSG_LIVES
],
5723 [gGameSettings
.MaxLives
]));
5724 if g_Game_IsNet
then MH_SEND_GameSettings
;
5729 procedure PrintHeapStats();
5733 hs
:= GetFPCHeapStatus();
5734 e_LogWriteLn ('v===== heap status =====v');
5735 e_LogWriteFln('max heap size = %d k', [hs
.MaxHeapSize
div 1024]);
5736 e_LogWriteFln('max heap used = %d k', [hs
.MaxHeapUsed
div 1024]);
5737 e_LogWriteFln('cur heap size = %d k', [hs
.CurrHeapSize
div 1024]);
5738 e_LogWriteFln('cur heap used = %d k', [hs
.CurrHeapUsed
div 1024]);
5739 e_LogWriteFln('cur heap free = %d k', [hs
.CurrHeapFree
div 1024]);
5740 e_LogWriteLn ('^=======================^');
5743 procedure DebugCommands(P
: SSArray
);
5750 // Êîìàíäû îòëàäî÷íîãî ðåæèìà:
5751 if {gDebugMode}conIsCheatsEnabled
then
5753 cmd
:= LowerCase(P
[0]);
5754 if cmd
= 'd_window' then
5756 g_Console_Add(Format('gWinPosX = %d, gWinPosY %d', [gWinPosX
, gWinPosY
]));
5757 g_Console_Add(Format('gWinRealPosX = %d, gWinRealPosY %d', [gWinRealPosX
, gWinRealPosY
]));
5758 g_Console_Add(Format('gScreenWidth = %d, gScreenHeight = %d', [gScreenWidth
, gScreenHeight
]));
5759 g_Console_Add(Format('gWinSizeX = %d, gWinSizeY = %d', [gWinSizeX
, gWinSizeY
]));
5760 g_Console_Add(Format('Frame X = %d, Y = %d, Caption Y = %d', [gWinFrameX
, gWinFrameY
, gWinCaption
]));
5762 else if cmd
= 'd_sounds' then
5764 if (Length(P
) > 1) and
5765 ((P
[1] = '1') or (P
[1] = '0')) then
5766 g_Debug_Sounds
:= (P
[1][1] = '1');
5768 g_Console_Add(Format('d_sounds is %d', [Byte(g_Debug_Sounds
)]));
5770 else if cmd
= 'd_frames' then
5772 if (Length(P
) > 1) and
5773 ((P
[1] = '1') or (P
[1] = '0')) then
5774 g_Debug_Frames
:= (P
[1][1] = '1');
5776 g_Console_Add(Format('d_frames is %d', [Byte(g_Debug_Frames
)]));
5778 else if cmd
= 'd_winmsg' then
5780 if (Length(P
) > 1) and
5781 ((P
[1] = '1') or (P
[1] = '0')) then
5782 g_Debug_WinMsgs
:= (P
[1][1] = '1');
5784 g_Console_Add(Format('d_winmsg is %d', [Byte(g_Debug_WinMsgs
)]));
5786 else if (cmd
= 'd_monoff') and not g_Game_IsNet
then
5788 if (Length(P
) > 1) and
5789 ((P
[1] = '1') or (P
[1] = '0')) then
5790 g_Debug_MonsterOff
:= (P
[1][1] = '1');
5792 g_Console_Add(Format('d_monoff is %d', [Byte(g_debug_MonsterOff
)]));
5794 else if (cmd
= 'd_botoff') and not g_Game_IsNet
then
5796 if Length(P
) > 1 then
5798 '0': g_debug_BotAIOff
:= 0;
5799 '1': g_debug_BotAIOff
:= 1;
5800 '2': g_debug_BotAIOff
:= 2;
5801 '3': g_debug_BotAIOff
:= 3;
5804 g_Console_Add(Format('d_botoff is %d', [g_debug_BotAIOff
]));
5806 else if cmd
= 'd_monster' then
5808 if gGameOn
and (gPlayer1
<> nil) and (gPlayer1
.alive
) and (not g_Game_IsNet
) then
5809 if Length(P
) < 2 then
5811 g_Console_Add(cmd
+ ' [ID | Name] [behaviour]');
5812 g_Console_Add('ID | Name');
5813 for b
:= MONSTER_DEMON
to MONSTER_MAN
do
5814 g_Console_Add(Format('%2d | %s', [b
, g_Mons_NameByTypeId(b
)]));
5815 conwriteln('behav. num'#10'normal 0'#10'killer 1'#10'maniac 2'#10'insane 3'#10'cannibal 4'#10'good 5');
5818 a
:= StrToIntDef(P
[1], 0);
5819 if (a
< MONSTER_DEMON
) or (a
> MONSTER_MAN
) then
5820 a
:= g_Mons_TypeIdByName(P
[1]);
5822 if (a
< MONSTER_DEMON
) or (a
> MONSTER_MAN
) then
5823 g_Console_Add(Format(_lc
[I_MSG_NO_MONSTER
], [P
[1]]))
5826 with gPlayer1
.Obj
do
5828 mon
:= g_Monsters_Create(a
,
5829 X
+ Rect
.X
+ (Rect
.Width
div 2),
5830 Y
+ Rect
.Y
+ Rect
.Height
,
5831 gPlayer1
.Direction
, True);
5833 if (Length(P
) > 2) and (mon
<> nil) then
5835 if (CompareText(P
[2], 'normal') = 0) then mon
.MonsterBehaviour
:= BH_NORMAL
5836 else if (CompareText(P
[2], 'killer') = 0) then mon
.MonsterBehaviour
:= BH_KILLER
5837 else if (CompareText(P
[2], 'maniac') = 0) then mon
.MonsterBehaviour
:= BH_MANIAC
5838 else if (CompareText(P
[2], 'insane') = 0) then mon
.MonsterBehaviour
:= BH_INSANE
5839 else if (CompareText(P
[2], 'cannibal') = 0) then mon
.MonsterBehaviour
:= BH_CANNIBAL
5840 else if (CompareText(P
[2], 'good') = 0) then mon
.MonsterBehaviour
:= BH_GOOD
5841 else if (CompareText(P
[2], 'friend') = 0) then mon
.MonsterBehaviour
:= BH_GOOD
5842 else if (CompareText(P
[2], 'friendly') = 0) then mon
.MonsterBehaviour
:= BH_GOOD
5843 else mon
.MonsterBehaviour
:= Min(Max(StrToIntDef(P
[2], BH_NORMAL
), BH_NORMAL
), BH_GOOD
);
5848 else if (cmd
= 'd_health') then
5850 if (Length(P
) > 1) and
5851 ((P
[1] = '1') or (P
[1] = '0')) then
5852 g_debug_HealthBar
:= (P
[1][1] = '1');
5854 g_Console_Add(Format('d_health is %d', [Byte(g_debug_HealthBar
)]));
5856 else if (cmd
= 'd_player') then
5858 if (Length(P
) > 1) and
5859 ((P
[1] = '1') or (P
[1] = '0')) then
5860 g_debug_Player
:= (P
[1][1] = '1');
5862 g_Console_Add(Format(cmd
+ ' is %d', [Byte(g_Debug_Player
)]));
5864 else if (cmd
= 'd_mem') then
5870 g_Console_Add(_lc
[I_MSG_NOT_DEBUG
]);
5874 procedure GameCheats(P
: SSArray
);
5880 if (not gGameOn
) or (not conIsCheatsEnabled
) then
5882 g_Console_Add('not available');
5888 g_Console_Add('where is the player?!');
5891 cmd
:= LowerCase(P
[0]);
5895 plr
.GodMode
:= not plr
.GodMode
;
5896 if plr
.GodMode
then g_Console_Add('player is godlike now') else g_Console_Add('player is mortal now');
5899 // give <health|exit|weapons|air|suit|jetpack|berserk|all>
5900 if cmd
= 'give' then
5902 if length(P
) < 2 then begin g_Console_Add('give what?!'); exit
; end;
5903 for f
:= 1 to High(P
) do
5905 cmd
:= LowerCase(P
[f
]);
5906 if cmd
= 'health' then begin plr
.RestoreHealthArmor(); g_Console_Add('player feels himself better'); continue
; end;
5907 if (cmd
= 'all') {or (cmd = 'weapons')} then begin plr
.AllRulez(False); g_Console_Add('player got the gifts'); continue
; end;
5908 if cmd
= 'exit' then
5910 if gTriggers
<> nil then
5912 for a
:= 0 to High(gTriggers
) do
5914 if gTriggers
[a
].TriggerType
= TRIGGER_EXIT
then
5916 g_Console_Add('player left the map');
5917 gExitByTrigger
:= True;
5918 //g_Game_ExitLevel(gTriggers[a].Data.MapName);
5919 g_Game_ExitLevel(gTriggers
[a
].tgcMap
);
5927 if cmd
= 'air' then begin plr
.GiveItem(ITEM_OXYGEN
); g_Console_Add('player got some air'); continue
; end;
5928 if cmd
= 'jetpack' then begin plr
.GiveItem(ITEM_JETPACK
); g_Console_Add('player got a jetpack'); continue
; end;
5929 if cmd
= 'suit' then begin plr
.GiveItem(ITEM_SUIT
); g_Console_Add('player got an envirosuit'); continue
; end;
5930 if cmd
= 'berserk' then begin plr
.GiveItem(ITEM_MEDKIT_BLACK
); g_Console_Add('player got a berserk pack'); continue
; end;
5931 if cmd
= 'backpack' then begin plr
.GiveItem(ITEM_AMMO_BACKPACK
); g_Console_Add('player got a backpack'); continue
; end;
5933 if cmd
= 'helmet' then begin plr
.GiveItem(ITEM_HELMET
); g_Console_Add('player got a helmet'); continue
; end;
5934 if cmd
= 'bottle' then begin plr
.GiveItem(ITEM_BOTTLE
); g_Console_Add('player got a bottle of health'); continue
; end;
5936 if cmd
= 'stimpack' then begin plr
.GiveItem(ITEM_MEDKIT_SMALL
); g_Console_Add('player got a stimpack'); continue
; end;
5937 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;
5939 if cmd
= 'greenarmor' then begin plr
.GiveItem(ITEM_ARMOR_GREEN
); g_Console_Add('player got a security armor'); continue
; end;
5940 if cmd
= 'bluearmor' then begin plr
.GiveItem(ITEM_ARMOR_BLUE
); g_Console_Add('player got a combat armor'); continue
; end;
5942 if (cmd
= 'megasphere') or (cmd
= 'mega') then begin plr
.GiveItem(ITEM_SPHERE_BLUE
); g_Console_Add('player got a megasphere'); continue
; end;
5943 if (cmd
= 'soulsphere') or (cmd
= 'soul')then begin plr
.GiveItem(ITEM_SPHERE_WHITE
); g_Console_Add('player got a soul sphere'); continue
; end;
5945 if (cmd
= 'invul') or (cmd
= 'invulnerability') then begin plr
.GiveItem(ITEM_INVUL
); g_Console_Add('player got invulnerability'); continue
; end;
5946 if (cmd
= 'invis') or (cmd
= 'invisibility') then begin plr
.GiveItem(ITEM_INVIS
); g_Console_Add('player got invisibility'); continue
; end;
5948 if cmd
= 'redkey' then begin plr
.GiveItem(ITEM_KEY_RED
); g_Console_Add('player got the red key'); continue
; end;
5949 if cmd
= 'greenkey' then begin plr
.GiveItem(ITEM_KEY_GREEN
); g_Console_Add('player got the green key'); continue
; end;
5950 if cmd
= 'bluekey' then begin plr
.GiveItem(ITEM_KEY_BLUE
); g_Console_Add('player got the blue key'); continue
; end;
5952 if (cmd
= 'shotgun') or (cmd
= 'sg') then begin plr
.GiveItem(ITEM_WEAPON_SHOTGUN1
); g_Console_Add('player got a shotgun'); continue
; end;
5953 if (cmd
= 'supershotgun') or (cmd
= 'ssg') then begin plr
.GiveItem(ITEM_WEAPON_SHOTGUN2
); g_Console_Add('player got a supershotgun'); continue
; end;
5954 if cmd
= 'chaingun' then begin plr
.GiveItem(ITEM_WEAPON_CHAINGUN
); g_Console_Add('player got a chaingun'); continue
; end;
5955 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;
5956 if cmd
= 'plasmagun' then begin plr
.GiveItem(ITEM_WEAPON_PLASMA
); g_Console_Add('player got a plasma gun'); continue
; end;
5957 if cmd
= 'bfg' then begin plr
.GiveItem(ITEM_WEAPON_BFG
); g_Console_Add('player got a BFG-9000'); continue
; end;
5959 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;
5960 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;
5961 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;
5962 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;
5963 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;
5964 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;
5966 if cmd
= 'superchaingun' then begin plr
.GiveItem(ITEM_WEAPON_SUPERPULEMET
); g_Console_Add('player got a superchaingun'); continue
; end;
5967 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;
5969 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;
5970 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;
5972 if cmd
= 'chainsaw' then begin plr
.GiveItem(ITEM_WEAPON_SAW
); g_Console_Add('player got a chainsaw'); continue
; end;
5974 if cmd
= 'ammo' then
5976 plr
.GiveItem(ITEM_AMMO_SHELLS_BOX
);
5977 plr
.GiveItem(ITEM_AMMO_BULLETS_BOX
);
5978 plr
.GiveItem(ITEM_AMMO_CELL_BIG
);
5979 plr
.GiveItem(ITEM_AMMO_ROCKET_BOX
);
5980 plr
.GiveItem(ITEM_AMMO_FUELCAN
);
5981 g_Console_Add('player got some ammo');
5985 if cmd
= 'clip' then begin plr
.GiveItem(ITEM_AMMO_BULLETS
); g_Console_Add('player got some bullets'); continue
; end;
5986 if cmd
= 'bullets' then begin plr
.GiveItem(ITEM_AMMO_BULLETS_BOX
); g_Console_Add('player got a box of bullets'); continue
; end;
5988 if cmd
= 'shells' then begin plr
.GiveItem(ITEM_AMMO_SHELLS
); g_Console_Add('player got some shells'); continue
; end;
5989 if cmd
= 'shellbox' then begin plr
.GiveItem(ITEM_AMMO_SHELLS_BOX
); g_Console_Add('player got a box of shells'); continue
; end;
5991 if cmd
= 'cells' then begin plr
.GiveItem(ITEM_AMMO_CELL
); g_Console_Add('player got some cells'); continue
; end;
5992 if cmd
= 'battery' then begin plr
.GiveItem(ITEM_AMMO_CELL_BIG
); g_Console_Add('player got cell battery'); continue
; end;
5994 if cmd
= 'rocket' then begin plr
.GiveItem(ITEM_AMMO_ROCKET
); g_Console_Add('player got a rocket'); continue
; end;
5995 if cmd
= 'rocketbox' then begin plr
.GiveItem(ITEM_AMMO_ROCKET_BOX
); g_Console_Add('player got some rockets'); continue
; end;
5997 if (cmd
= 'fuel') or (cmd
= 'fuelcan') then begin plr
.GiveItem(ITEM_AMMO_FUELCAN
); g_Console_Add('player got fuel canister'); continue
; end;
5999 if cmd
= 'weapons' then
6001 plr
.GiveItem(ITEM_WEAPON_SHOTGUN1
);
6002 plr
.GiveItem(ITEM_WEAPON_SHOTGUN2
);
6003 plr
.GiveItem(ITEM_WEAPON_CHAINGUN
);
6004 plr
.GiveItem(ITEM_WEAPON_ROCKETLAUNCHER
);
6005 plr
.GiveItem(ITEM_WEAPON_PLASMA
);
6006 plr
.GiveItem(ITEM_WEAPON_BFG
);
6007 g_Console_Add('player got weapons');
6011 if cmd
= 'keys' then
6013 plr
.GiveItem(ITEM_KEY_RED
);
6014 plr
.GiveItem(ITEM_KEY_GREEN
);
6015 plr
.GiveItem(ITEM_KEY_BLUE
);
6016 g_Console_Add('player got all keys');
6020 g_Console_Add('i don''t know how to give '''+cmd
+'''!');
6025 if cmd
= 'open' then
6027 g_Console_Add('player activated sesame');
6028 g_Triggers_OpenAll();
6035 if gFly
then g_Console_Add('player feels himself lighter') else g_Console_Add('player lost his wings');
6039 if cmd
= 'noclip' then
6042 g_Console_Add('wall hardeness adjusted');
6046 if cmd
= 'notarget' then
6048 plr
.NoTarget
:= not plr
.NoTarget
;
6049 if plr
.NoTarget
then g_Console_Add('player hides in shadows') else g_Console_Add('player is brave again');
6053 if cmd
= 'noreload' then
6055 plr
.NoReload
:= not plr
.NoReload
;
6056 if plr
.NoReload
then g_Console_Add('player is action hero now') else g_Console_Add('player is ordinary man now');
6060 if cmd
= 'speedy' then
6062 MAX_RUNVEL
:= 32-MAX_RUNVEL
;
6063 g_Console_Add('speed adjusted');
6067 if cmd
= 'jumpy' then
6069 VEL_JUMP
:= 30-VEL_JUMP
;
6070 g_Console_Add('jump height adjusted');
6074 if cmd
= 'automap' then
6076 gShowMap
:= not gShowMap
;
6077 if gShowMap
then g_Console_Add('player gains second sight') else g_Console_Add('player lost second sight');
6081 if cmd
= 'aimline' then
6083 gAimLine
:= not gAimLine
;
6084 if gAimLine
then g_Console_Add('player gains laser sight') else g_Console_Add('player lost laser sight');
6089 procedure GameCommands(P
: SSArray
);
6095 pl
: pTNetClient
= nil;
6102 cmd
:= LowerCase(P
[0]);
6104 if (cmd
= 'quit') or
6111 else if cmd
= 'pause' then
6113 if (g_ActiveWindow
= nil) then
6114 g_Game_Pause(not gPauseMain
);
6116 else if cmd
= 'endgame' then
6117 gExit
:= EXIT_SIMPLE
6118 else if cmd
= 'restart' then
6120 if gGameOn
or (gState
in [STATE_INTERSINGLE
, STATE_INTERCUSTOM
]) then
6122 if g_Game_IsClient
then
6124 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6129 g_Console_Add(_lc
[I_MSG_NOT_GAME
]);
6131 else if cmd
= 'kick' then
6133 if g_Game_IsServer
then
6135 if Length(P
) < 2 then
6137 g_Console_Add('kick <name>');
6142 g_Console_Add('kick <name>');
6146 if g_Game_IsNet
then
6147 pl
:= g_Net_Client_ByName(P
[1]);
6150 s
:= g_Net_ClientName_ByID(pl
^.ID
);
6151 enet_peer_disconnect(pl
^.Peer
, NET_DISC_KICK
);
6152 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
6153 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
6154 if NetUseMaster
then
6156 end else if gPlayers
<> nil then
6157 for a
:= Low(gPlayers
) to High(gPlayers
) do
6158 if gPlayers
[a
] <> nil then
6159 if Copy(LowerCase(gPlayers
[a
].Name
), 1, Length(P
[1])) = LowerCase(P
[1]) then
6161 // Íå îòêëþ÷àòü îñíîâíûõ èãðîêîâ â ñèíãëå
6162 if not(gPlayers
[a
] is TBot
) and (gGameSettings
.GameType
= GT_SINGLE
) then
6164 gPlayers
[a
].Lives
:= 0;
6165 gPlayers
[a
].Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
6166 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [gPlayers
[a
].Name
]), True);
6167 g_Player_Remove(gPlayers
[a
].UID
);
6168 if NetUseMaster
then
6170 // Åñëè íå ïåðåìåøàòü, ïðè äîáàâëåíèè íîâûõ áîòîâ ïîÿâÿòñÿ ñòàðûå
6174 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6176 else if cmd
= 'kick_id' then
6178 if g_Game_IsServer
and g_Game_IsNet
then
6180 if Length(P
) < 2 then
6182 g_Console_Add('kick_id <client ID>');
6187 g_Console_Add('kick_id <client ID>');
6191 a
:= StrToIntDef(P
[1], 0);
6192 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
6194 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
6196 s
:= g_Net_ClientName_ByID(NetClients
[a
].ID
);
6197 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_KICK
);
6198 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
6199 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
6200 if NetUseMaster
then
6205 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6207 else if cmd
= 'ban' then
6209 if g_Game_IsServer
and g_Game_IsNet
then
6211 if Length(P
) < 2 then
6213 g_Console_Add('ban <name>');
6218 g_Console_Add('ban <name>');
6222 pl
:= g_Net_Client_ByName(P
[1]);
6225 s
:= g_Net_ClientName_ByID(pl
^.ID
);
6226 g_Net_BanHost(pl
^.Peer
^.address
.host
, False);
6227 enet_peer_disconnect(pl
^.Peer
, NET_DISC_TEMPBAN
);
6228 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
6229 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
6230 if NetUseMaster
then
6233 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
6235 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6237 else if cmd
= 'ban_id' then
6239 if g_Game_IsServer
and g_Game_IsNet
then
6241 if Length(P
) < 2 then
6243 g_Console_Add('ban_id <client ID>');
6248 g_Console_Add('ban_id <client ID>');
6252 a
:= StrToIntDef(P
[1], 0);
6253 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
6254 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
6256 s
:= g_Net_ClientName_ByID(NetClients
[a
].ID
);
6257 g_Net_BanHost(NetClients
[a
].Peer
^.address
.host
, False);
6258 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_TEMPBAN
);
6259 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
6260 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
6261 if NetUseMaster
then
6265 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6267 else if cmd
= 'permban' then
6269 if g_Game_IsServer
and g_Game_IsNet
then
6271 if Length(P
) < 2 then
6273 g_Console_Add('permban <name>');
6278 g_Console_Add('permban <name>');
6282 pl
:= g_Net_Client_ByName(P
[1]);
6285 s
:= g_Net_ClientName_ByID(pl
^.ID
);
6286 g_Net_BanHost(pl
^.Peer
^.address
.host
);
6287 enet_peer_disconnect(pl
^.Peer
, NET_DISC_BAN
);
6288 g_Net_SaveBanList();
6289 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
6290 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
6291 if NetUseMaster
then
6294 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
6296 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6298 else if cmd
= 'permban_id' then
6300 if g_Game_IsServer
and g_Game_IsNet
then
6302 if Length(P
) < 2 then
6304 g_Console_Add('permban_id <client ID>');
6309 g_Console_Add('permban_id <client ID>');
6313 a
:= StrToIntDef(P
[1], 0);
6314 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
6315 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
6317 s
:= g_Net_ClientName_ByID(NetClients
[a
].ID
);
6318 g_Net_BanHost(NetClients
[a
].Peer
^.address
.host
);
6319 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_BAN
);
6320 g_Net_SaveBanList();
6321 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
6322 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
6323 if NetUseMaster
then
6327 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6329 else if cmd
= 'unban' then
6331 if g_Game_IsServer
and g_Game_IsNet
then
6333 if Length(P
) < 2 then
6335 g_Console_Add('unban <IP Address>');
6340 g_Console_Add('unban <IP Address>');
6344 if g_Net_UnbanHost(P
[1]) then
6346 g_Console_Add(Format(_lc
[I_MSG_UNBAN_OK
], [P
[1]]));
6347 g_Net_SaveBanList();
6349 g_Console_Add(Format(_lc
[I_MSG_UNBAN_FAIL
], [P
[1]]));
6351 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6353 else if cmd
= 'clientlist' then
6355 if g_Game_IsServer
and g_Game_IsNet
then
6358 if NetClients
<> nil then
6359 for a
:= Low(NetClients
) to High(NetClients
) do
6360 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
6362 plr
:= g_Player_Get(NetClients
[a
].Player
);
6363 if plr
= nil then continue
;
6365 g_Console_Add(Format('#%2d: %-15s | %s', [a
,
6366 IpToStr(NetClients
[a
].Peer
^.address
.host
), plr
.Name
]));
6369 g_Console_Add(_lc
[I_MSG_NOCLIENTS
]);
6371 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6373 else if cmd
= 'connect' then
6375 if (NetMode
= NET_NONE
) then
6377 if Length(P
) < 2 then
6379 g_Console_Add('connect <IP> [port] [password]');
6384 g_Console_Add('connect <IP> [port] [password]');
6388 if Length(P
) > 2 then
6389 prt
:= StrToIntDef(P
[2], 25666)
6393 if Length(P
) > 3 then
6398 g_Game_StartClient(P
[1], prt
, pw
);
6401 else if cmd
= 'disconnect' then
6403 if (NetMode
= NET_CLIENT
) then
6406 else if cmd
= 'reconnect' then
6408 if (NetMode
= NET_SERVER
) then
6411 if (NetMode
= NET_CLIENT
) then
6414 gExit
:= EXIT_SIMPLE
;
6418 //TODO: Use last successful password to reconnect, instead of ''
6419 g_Game_StartClient(NetClientIP
, NetClientPort
, '');
6421 else if (cmd
= 'addbot') or
6422 (cmd
= 'bot_add') then
6424 if Length(P
) > 2 then
6425 g_Bot_Add(TEAM_NONE
, StrToIntDef(P
[1], 2), StrToIntDef(P
[2], 100))
6426 else if Length(P
) > 1 then
6427 g_Bot_Add(TEAM_NONE
, StrToIntDef(P
[1], 2))
6429 g_Bot_Add(TEAM_NONE
, 2);
6431 else if cmd
= 'bot_addlist' then
6433 if Length(P
) > 1 then
6435 if Length(P
) = 2 then
6436 g_Bot_AddList(TEAM_NONE
, P
[1], StrToIntDef(P
[1], -1))
6437 else if Length(P
) = 3 then
6438 g_Bot_AddList(TEAM_NONE
, P
[1], StrToIntDef(P
[1], -1), StrToIntDef(P
[2], 100))
6440 g_Bot_AddList(IfThen(P
[2] = 'red', TEAM_RED
, TEAM_BLUE
), P
[1], StrToIntDef(P
[1], -1));
6443 else if cmd
= 'bot_removeall' then
6445 else if cmd
= 'chat' then
6447 if g_Game_IsNet
then
6449 if Length(P
) > 1 then
6451 for a
:= 1 to High(P
) do
6452 chstr
:= chstr
+ P
[a
] + ' ';
6454 if Length(chstr
) > 200 then SetLength(chstr
, 200);
6456 if Length(chstr
) < 1 then
6458 g_Console_Add('chat <text>');
6462 chstr
:= b_Text_Format(chstr
);
6463 if g_Game_IsClient
then
6464 MC_SEND_Chat(chstr
, NET_CHAT_PLAYER
)
6466 MH_SEND_Chat(gPlayer1Settings
.Name
+ ': ' + chstr
, NET_CHAT_PLAYER
);
6469 g_Console_Add('chat <text>');
6471 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6473 else if cmd
= 'teamchat' then
6475 if g_Game_IsNet
and (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
6477 if Length(P
) > 1 then
6479 for a
:= 1 to High(P
) do
6480 chstr
:= chstr
+ P
[a
] + ' ';
6482 if Length(chstr
) > 200 then SetLength(chstr
, 200);
6484 if Length(chstr
) < 1 then
6486 g_Console_Add('teamchat <text>');
6490 chstr
:= b_Text_Format(chstr
);
6491 if g_Game_IsClient
then
6492 MC_SEND_Chat(chstr
, NET_CHAT_TEAM
)
6494 MH_SEND_Chat(gPlayer1Settings
.Name
+ ': ' + chstr
, NET_CHAT_TEAM
,
6495 gPlayer1Settings
.Team
);
6498 g_Console_Add('teamchat <text>');
6500 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6502 else if cmd
= 'game' then
6504 if gGameSettings
.GameType
<> GT_NONE
then
6506 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6509 if Length(P
) = 1 then
6511 g_Console_Add(cmd
+ ' <WAD> [MAP] [# players]');
6514 // Èãðà åù¸ íå çàïóùåíà, ñíà÷àëà íàì íàäî çàãðóçèòü êàêîé-òî WAD
6515 P
[1] := addWadExtension(P
[1]);
6516 if FileExists(MapsDir
+ P
[1]) then
6518 // Åñëè êàðòà íå óêàçàíà, áåð¸ì ïåðâóþ êàðòó â ôàéëå
6519 if Length(P
) < 3 then
6522 P
[2] := g_Game_GetFirstMap(MapsDir
+ P
[1]);
6525 s
:= P
[1] + ':\' + UpperCase(P
[2]);
6527 if g_Map_Exist(MapsDir
+ s
) then
6529 // Çàïóñêàåì ñâîþ èãðó
6531 with gGameSettings
do
6533 GameMode
:= g_Game_TextToMode(gcGameMode
);
6534 if gSwitchGameMode
<> GM_NONE
then
6535 GameMode
:= gSwitchGameMode
;
6536 if GameMode
= GM_NONE
then GameMode
:= GM_DM
;
6537 if GameMode
= GM_SINGLE
then GameMode
:= GM_COOP
;
6539 if Length(P
) >= 4 then
6540 b
:= StrToIntDef(P
[3], 1);
6541 g_Game_StartCustom(s
, GameMode
, TimeLimit
,
6542 GoalLimit
, MaxLives
, Options
, b
);
6547 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
6549 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [UpperCase(P
[2]), P
[1]]));
6551 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]));
6553 else if cmd
= 'host' then
6555 if gGameSettings
.GameType
<> GT_NONE
then
6557 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6560 if Length(P
) < 4 then
6562 g_Console_Add(cmd
+ ' <listen IP> <port> <WAD> [MAP] [# players]');
6565 if not StrToIp(P
[1], listen
) then
6567 prt
:= StrToIntDef(P
[2], 25666);
6569 P
[3] := addWadExtension(P
[3]);
6570 if FileExists(MapsDir
+ P
[3]) then
6572 // Åñëè êàðòà íå óêàçàíà, áåð¸ì ïåðâóþ êàðòó â ôàéëå
6573 if Length(P
) < 5 then
6576 P
[4] := g_Game_GetFirstMap(MapsDir
+ P
[1]);
6579 s
:= P
[3] + ':\' + UpperCase(P
[4]);
6581 if g_Map_Exist(MapsDir
+ s
) then
6583 // Çàïóñêàåì ñâîþ èãðó
6585 with gGameSettings
do
6587 GameMode
:= g_Game_TextToMode(gcGameMode
);
6588 if gSwitchGameMode
<> GM_NONE
then
6589 GameMode
:= gSwitchGameMode
;
6590 if GameMode
= GM_NONE
then GameMode
:= GM_DM
;
6591 if GameMode
= GM_SINGLE
then GameMode
:= GM_COOP
;
6593 if Length(P
) >= 6 then
6594 b
:= StrToIntDef(P
[5], 0);
6595 g_Game_StartServer(s
, GameMode
, TimeLimit
,
6596 GoalLimit
, MaxLives
, Options
, b
, listen
, prt
);
6601 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[3]]))
6603 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [UpperCase(P
[4]), P
[3]]));
6605 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[3]]));
6607 else if cmd
= 'map' then
6609 if Length(P
) = 1 then
6611 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
6613 g_Console_Add(cmd
+ ' <MAP>');
6614 g_Console_Add(cmd
+ ' <WAD> [MAP]');
6616 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6618 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
6620 // Èä¸ò ñâîÿ èãðà èëè ñåðâåð
6621 if Length(P
) < 3 then
6623 // Ïåðâûé ïàðàìåòð - ëèáî êàðòà, ëèáî èìÿ WAD ôàéëà
6624 s
:= UpperCase(P
[1]);
6625 if g_Map_Exist(MapsDir
+ gGameSettings
.WAD
+ ':\' + s
) then
6626 begin // Êàðòà íàøëàñü
6627 gExitByTrigger
:= False;
6629 begin // Èä¸ò èãðà - çàâåðøàåì óðîâåíü
6631 gExit
:= EXIT_ENDLEVELCUSTOM
;
6633 else // Èíòåðìèññèÿ - ñðàçó çàãðóæàåì êàðòó
6634 g_Game_ChangeMap(s
);
6637 // Òàêîé êàðòû íåò, èùåì WAD ôàéë
6638 pw
:= findDiskWad(MapsDir
+ P
[1]);
6639 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [s
, 'WAD ' + P
[1]]));
6640 if FileExists(pw
) then
6642 // Ïàðàìåòðà êàðòû íåò, ïîýòîìó ñòàâèì ïåðâóþ èç ôàéëà
6644 P
[1] := ExtractRelativePath(MapsDir
, pw
);
6645 P
[2] := g_Game_GetFirstMap(MapsDir
+ P
[1]);
6647 s
:= P
[1] + ':\' + P
[2];
6649 if g_Map_Exist(MapsDir
+ s
) then
6651 gExitByTrigger
:= False;
6653 begin // Èä¸ò èãðà - çàâåðøàåì óðîâåíü
6655 gExit
:= EXIT_ENDLEVELCUSTOM
;
6657 else // Èíòåðìèññèÿ - ñðàçó çàãðóæàåì êàðòó
6658 g_Game_ChangeMap(s
);
6661 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
6663 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]));
6665 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]));
6669 // Óêàçàíî äâà ïàðàìåòðà, çíà÷èò ïåðâûé - WAD ôàéë, à âòîðîé - êàðòà
6670 P
[1] := addWadExtension(P
[1]);
6671 if FileExists(MapsDir
+ P
[1]) then
6674 P
[2] := UpperCase(P
[2]);
6675 s
:= P
[1] + ':\' + P
[2];
6677 if g_Map_Exist(MapsDir
+ s
) then
6678 begin // Íàøëè êàðòó
6679 gExitByTrigger
:= False;
6681 begin // Èä¸ò èãðà - çàâåðøàåì óðîâåíü
6683 gExit
:= EXIT_ENDLEVELCUSTOM
;
6685 else // Èíòåðìèññèÿ - ñðàçó çàãðóæàåì êàðòó
6686 g_Game_ChangeMap(s
);
6688 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]));
6690 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]));
6693 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6695 else if cmd
= 'nextmap' then
6697 if not(gGameOn
or (gState
= STATE_INTERCUSTOM
)) then
6698 g_Console_Add(_lc
[I_MSG_NOT_GAME
])
6701 if Length(P
) = 1 then
6703 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
6705 g_Console_Add(cmd
+ ' <MAP>');
6706 g_Console_Add(cmd
+ ' <WAD> [MAP]');
6709 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6714 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
6716 if Length(P
) < 3 then
6718 // Ïåðâûé ïàðàìåòð - ëèáî êàðòà, ëèáî èìÿ WAD ôàéëà
6719 s
:= UpperCase(P
[1]);
6720 if g_Map_Exist(MapsDir
+ gGameSettings
.WAD
+ ':\' + s
) then
6721 begin // Êàðòà íàøëàñü
6722 gExitByTrigger
:= False;
6727 // Òàêîé êàðòû íåò, èùåì WAD ôàéë
6728 P
[1] := addWadExtension(P
[1]);
6729 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [s
, P
[1]]));
6730 if FileExists(MapsDir
+ P
[1]) then
6732 // Ïàðàìåòðà êàðòû íåò, ïîýòîìó ñòàâèì ïåðâóþ èç ôàéëà
6734 P
[2] := g_Game_GetFirstMap(MapsDir
+ P
[1]);
6736 s
:= P
[1] + ':\' + P
[2];
6738 if g_Map_Exist(MapsDir
+ s
) then
6739 begin // Óñòàíàâëèâàåì êàðòó
6740 gExitByTrigger
:= False;
6745 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
6747 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]));
6749 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]));
6753 // Óêàçàíî äâà ïàðàìåòðà, çíà÷èò ïåðâûé - WAD ôàéë, à âòîðîé - êàðòà
6754 P
[1] := addWadExtension(P
[1]);
6755 if FileExists(MapsDir
+ P
[1]) then
6758 P
[2] := UpperCase(P
[2]);
6759 s
:= P
[1] + ':\' + P
[2];
6761 if g_Map_Exist(MapsDir
+ s
) then
6762 begin // Íàøëè êàðòó
6763 gExitByTrigger
:= False;
6767 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]));
6769 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]));
6772 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6775 if gNextMap
= '' then
6776 g_Console_Add(_lc
[I_MSG_NEXTMAP_UNSET
])
6778 g_Console_Add(Format(_lc
[I_MSG_NEXTMAP_SET
], [gNextMap
]));
6781 else if (cmd
= 'endmap') or (cmd
= 'goodbye') then
6784 g_Console_Add(_lc
[I_MSG_NOT_GAME
])
6786 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
6788 gExitByTrigger
:= False;
6789 // Ñëåäóþùàÿ êàðòà íå çàäàíà, ïðîáóåì íàéòè òðèããåð Âûõîä
6790 if (gNextMap
= '') and (gTriggers
<> nil) then
6791 for a
:= 0 to High(gTriggers
) do
6792 if gTriggers
[a
].TriggerType
= TRIGGER_EXIT
then
6794 gExitByTrigger
:= True;
6795 //gNextMap := gTriggers[a].Data.MapName;
6796 gNextMap
:= gTriggers
[a
].tgcMap
;
6799 // Èùåì ñëåäóþùóþ êàðòó â WAD ôàéëå
6800 if gNextMap
= '' then
6801 gNextMap
:= g_Game_GetNextMap();
6802 // Ïðîâåðÿåì, íå çàäàí ëè WAD ôàéë ðåñóðñíîé ñòðîêîé
6803 if not isWadPath(gNextMap
) then
6804 s
:= gGameSettings
.WAD
+ ':\' + gNextMap
6807 // Åñëè êàðòà íàéäåíà, âûõîäèì ñ óðîâíÿ
6808 if g_Map_Exist(MapsDir
+ s
) then
6809 gExit
:= EXIT_ENDLEVELCUSTOM
6811 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [gNextMap
]));
6813 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6815 else if (cmd
= 'event') then
6817 if (Length(P
) <= 1) then
6819 for a
:= 0 to High(gEvents
) do
6820 if gEvents
[a
].Command
= '' then
6821 g_Console_Add(gEvents
[a
].Name
+ ' <none>')
6823 g_Console_Add(gEvents
[a
].Name
+ ' "' + gEvents
[a
].Command
+ '"');
6826 if (Length(P
) = 2) then
6828 for a
:= 0 to High(gEvents
) do
6829 if gEvents
[a
].Name
= P
[1] then
6830 if gEvents
[a
].Command
= '' then
6831 g_Console_Add(gEvents
[a
].Name
+ ' <none>')
6833 g_Console_Add(gEvents
[a
].Name
+ ' "' + gEvents
[a
].Command
+ '"');
6836 for a
:= 0 to High(gEvents
) do
6837 if gEvents
[a
].Name
= P
[1] then
6839 gEvents
[a
].Command
:= '';
6840 for b
:= 2 to High(P
) do
6841 if Pos(' ', P
[b
]) = 0 then
6842 gEvents
[a
].Command
:= gEvents
[a
].Command
+ ' ' + P
[b
]
6844 gEvents
[a
].Command
:= gEvents
[a
].Command
+ ' "' + P
[b
] + '"';
6845 gEvents
[a
].Command
:= Trim(gEvents
[a
].Command
);
6849 else if cmd
= 'suicide' then
6853 if g_Game_IsClient
then
6854 MC_SEND_CheatRequest(NET_CHEAT_SUICIDE
)
6857 if gPlayer1
<> nil then
6858 gPlayer1
.Damage(SUICIDE_DAMAGE
, gPlayer1
.UID
, 0, 0, HIT_SELF
);
6859 if gPlayer2
<> nil then
6860 gPlayer2
.Damage(SUICIDE_DAMAGE
, gPlayer2
.UID
, 0, 0, HIT_SELF
);
6864 else if cmd
= 'screenshot' then
6868 else if cmd
= 'weapon' then
6870 if Length(p
) = 2 then
6872 a
:= WP_FIRST
+ StrToInt(p
[1]) - 1;
6873 if (a
>= WP_FIRST
) and (a
<= WP_LAST
) then
6874 gSelectWeapon
[0, a
] := True
6877 else if (cmd
= 'p1_weapon') or (cmd
= 'p2_weapon') then
6879 if Length(p
) = 2 then
6881 a
:= WP_FIRST
+ StrToInt(p
[1]) - 1;
6882 b
:= ord(cmd
[2]) - ord('1');
6883 if (a
>= WP_FIRST
) and (a
<= WP_LAST
) then
6884 gSelectWeapon
[b
, a
] := True
6887 // Êîìàíäû Ñâîåé èãðû:
6888 else if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
6890 if cmd
= 'bot_addred' then
6892 if Length(P
) > 1 then
6893 g_Bot_Add(TEAM_RED
, StrToIntDef(P
[1], 2))
6895 g_Bot_Add(TEAM_RED
, 2);
6897 else if cmd
= 'bot_addblue' then
6899 if Length(P
) > 1 then
6900 g_Bot_Add(TEAM_BLUE
, StrToIntDef(P
[1], 2))
6902 g_Bot_Add(TEAM_BLUE
, 2);
6904 else if cmd
= 'spectate' then
6910 else if cmd
= 'say' then
6912 if g_Game_IsServer
and g_Game_IsNet
then
6914 if Length(P
) > 1 then
6917 for a
:= 1 to High(P
) do
6918 chstr
:= chstr
+ P
[a
] + ' ';
6920 if Length(chstr
) > 200 then SetLength(chstr
, 200);
6922 if Length(chstr
) < 1 then
6924 g_Console_Add('say <text>');
6928 chstr
:= b_Text_Format(chstr
);
6929 MH_SEND_Chat(chstr
, NET_CHAT_PLAYER
);
6931 else g_Console_Add('say <text>');
6933 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6935 else if cmd
= 'tell' then
6937 if g_Game_IsServer
and g_Game_IsNet
then
6939 if (Length(P
) > 2) and (P
[1] <> '') then
6942 for a
:= 2 to High(P
) do
6943 chstr
:= chstr
+ P
[a
] + ' ';
6945 if Length(chstr
) > 200 then SetLength(chstr
, 200);
6947 if Length(chstr
) < 1 then
6949 g_Console_Add('tell <playername> <text>');
6953 pl
:= g_Net_Client_ByName(P
[1]);
6955 MH_SEND_Chat(b_Text_Format(chstr
), NET_CHAT_PLAYER
, pl
^.ID
)
6957 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
6959 else g_Console_Add('tell <playername> <text>');
6961 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6963 else if (cmd
= 'overtime') and not g_Game_IsClient
then
6965 if (Length(P
) = 1) or (StrToIntDef(P
[1], -1) <= 0) then
6967 // Äîïîëíèòåëüíîå âðåìÿ:
6968 gGameSettings
.TimeLimit
:= (gTime
- gGameStartTime
) div 1000 + Word(StrToIntDef(P
[1], 0));
6970 g_Console_Add(Format(_lc
[I_MSG_TIME_LIMIT
],
6971 [gGameSettings
.TimeLimit
div 3600,
6972 (gGameSettings
.TimeLimit
div 60) mod 60,
6973 gGameSettings
.TimeLimit
mod 60]));
6974 if g_Game_IsNet
then MH_SEND_GameSettings
;
6976 else if (cmd
= 'rcon_password') and g_Game_IsClient
then
6978 if (Length(P
) <= 1) then
6979 g_Console_Add('rcon_password <password>')
6981 MC_SEND_RCONPassword(P
[1]);
6983 else if cmd
= 'rcon' then
6985 if g_Game_IsClient
then
6987 if Length(P
) > 1 then
6990 for a
:= 1 to High(P
) do
6991 chstr
:= chstr
+ P
[a
] + ' ';
6993 if Length(chstr
) > 200 then SetLength(chstr
, 200);
6995 if Length(chstr
) < 1 then
6997 g_Console_Add('rcon <command>');
7001 MC_SEND_RCONCommand(chstr
);
7003 else g_Console_Add('rcon <command>');
7006 else if cmd
= 'ready' then
7008 if g_Game_IsServer
and (gLMSRespawn
= LMS_RESPAWN_WARMUP
) then
7009 gLMSRespawnTime
:= gTime
+ 100;
7011 else if (cmd
= 'callvote') and g_Game_IsNet
then
7013 if Length(P
) > 1 then
7016 for a
:= 1 to High(P
) do begin
7017 if a
> 1 then chstr
:= chstr
+ ' ';
7018 chstr
:= chstr
+ P
[a
];
7021 if Length(chstr
) > 200 then SetLength(chstr
, 200);
7023 if Length(chstr
) < 1 then
7025 g_Console_Add('callvote <command>');
7029 if g_Game_IsClient
then
7030 MC_SEND_Vote(True, chstr
)
7032 g_Game_StartVote(chstr
, gPlayer1Settings
.Name
);
7033 g_Console_Process('vote', True);
7036 g_Console_Add('callvote <command>');
7038 else if (cmd
= 'vote') and g_Game_IsNet
then
7040 if g_Game_IsClient
then
7042 else if gVoteInProgress
then
7044 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
7045 a
:= Floor((NetClientCount
+1)/2.0) + 1
7047 a
:= Floor(NetClientCount
/2.0) + 1;
7052 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_REVOKED
], [gPlayer1Settings
.Name
, gVoteCount
, a
]), True);
7053 MH_SEND_VoteEvent(NET_VE_REVOKE
, gPlayer1Settings
.Name
, 'a', gVoteCount
, a
);
7059 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_VOTE
], [gPlayer1Settings
.Name
, gVoteCount
, a
]), True);
7060 MH_SEND_VoteEvent(NET_VE_VOTE
, gPlayer1Settings
.Name
, 'a', gVoteCount
, a
);
7068 procedure g_TakeScreenShot();
7076 if e_NoGraphics
then Exit
;
7077 ssdir
:= GameDir
+'/screenshots';
7078 if not findFileCI(ssdir
, true) then
7080 // try to create dir
7085 if not findFileCI(ssdir
, true) then exit
; // alas
7088 for a
:= 1 to High(Word) do
7090 FileName
:= Format(ssdir
+'screenshot%.3d.png', [a
]);
7092 if findFileCI(t
, true) then continue
;
7093 if not findFileCI(FileName
) then
7096 st
:= createDiskFile(FileName
);
7098 e_MakeScreenshot(st
, gScreenWidth
, gScreenHeight
);
7103 if not ok
then try DeleteFile(FileName
); except end else g_Console_Add(Format(_lc
[I_CONSOLE_SCREENSHOT
], [ExtractFileName(FileName
)]));
7111 procedure g_Game_InGameMenu(Show
: Boolean);
7113 if (g_ActiveWindow
= nil) and Show
then
7115 if gGameSettings
.GameType
= GT_SINGLE
then
7116 g_GUI_ShowWindow('GameSingleMenu')
7119 if g_Game_IsClient
then
7120 g_GUI_ShowWindow('GameClientMenu')
7122 if g_Game_IsNet
then
7123 g_GUI_ShowWindow('GameServerMenu')
7125 g_GUI_ShowWindow('GameCustomMenu');
7127 g_Sound_PlayEx('MENU_OPEN');
7129 // Ïàóçà ïðè ìåíþ òîëüêî â îäèíî÷íîé èãðå:
7130 if (not g_Game_IsNet
) then
7134 if (g_ActiveWindow
<> nil) and (not Show
) then
7136 // Ïàóçà ïðè ìåíþ òîëüêî â îäèíî÷íîé èãðå:
7137 if (not g_Game_IsNet
) then
7138 g_Game_Pause(False);
7142 procedure g_Game_Pause (Enable
: Boolean);
7146 if not gGameOn
then exit
;
7148 if not (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
]) then exit
;
7151 gPauseMain
:= Enable
;
7153 if (gPause
<> oldPause
) then g_Game_PauseAllSounds(gPause
);
7156 procedure g_Game_HolmesPause (Enable
: Boolean);
7160 if not gGameOn
then exit
;
7161 if not (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
]) then exit
;
7164 gPauseHolmes
:= Enable
;
7166 if (gPause
<> oldPause
) then g_Game_PauseAllSounds(gPause
);
7169 procedure g_Game_PauseAllSounds(Enable
: Boolean);
7174 if gTriggers
<> nil then
7175 for i
:= 0 to High(gTriggers
) do
7176 with gTriggers
[i
] do
7177 if (TriggerType
= TRIGGER_SOUND
) and
7179 Sound
.IsPlaying() then
7181 Sound
.Pause(Enable
);
7185 if gPlayers
<> nil then
7186 for i
:= 0 to High(gPlayers
) do
7187 if gPlayers
[i
] <> nil then
7188 gPlayers
[i
].PauseSounds(Enable
);
7191 if gMusic
<> nil then
7192 gMusic
.Pause(Enable
);
7195 procedure g_Game_StopAllSounds(all
: Boolean);
7199 if gTriggers
<> nil then
7200 for i
:= 0 to High(gTriggers
) do
7201 with gTriggers
[i
] do
7202 if (TriggerType
= TRIGGER_SOUND
) and
7206 if gMusic
<> nil then
7213 procedure g_Game_UpdateTriggerSounds
;
7216 if gTriggers
<> nil then
7217 for i
:= 0 to High(gTriggers
) do
7218 with gTriggers
[i
] do
7219 if (TriggerType
= TRIGGER_SOUND
) and (Sound
<> nil) and tgcLocal
and Sound
.IsPlaying() then
7220 Sound
.SetCoordsRect(X
, Y
, Width
, Height
, tgcVolume
/ 255.0)
7223 function g_Game_IsWatchedPlayer(UID
: Word): Boolean;
7226 if (gPlayer1
<> nil) and (gPlayer1
.UID
= UID
) then
7231 if (gPlayer2
<> nil) and (gPlayer2
.UID
= UID
) then
7236 if gSpectMode
<> SPECT_PLAYERS
then
7238 if gSpectPID1
= UID
then
7243 if gSpectViewTwo
and (gSpectPID2
= UID
) then
7250 function g_Game_IsWatchedTeam(Team
: Byte): Boolean;
7255 if (gPlayer1
<> nil) and (gPlayer1
.Team
= Team
) then
7260 if (gPlayer2
<> nil) and (gPlayer2
.Team
= Team
) then
7265 if gSpectMode
<> SPECT_PLAYERS
then
7267 Pl
:= g_Player_Get(gSpectPID1
);
7268 if (Pl
<> nil) and (Pl
.Team
= Team
) then
7273 if gSpectViewTwo
then
7275 Pl
:= g_Player_Get(gSpectPID2
);
7276 if (Pl
<> nil) and (Pl
.Team
= Team
) then
7284 procedure g_Game_Message(Msg
: string; Time
: Word);
7286 MessageLineLength
:= (gScreenWidth
- 204) div e_CharFont_GetMaxWidth(gMenuFont
);
7287 MessageText
:= b_Text_Wrap(b_Text_Format(Msg
), MessageLineLength
);
7288 MessageTime
:= Time
;
7291 procedure g_Game_ChatSound(Text: String; Taunt
: Boolean = True);
7293 punct
: Array[0..13] of String =
7294 ('.', ',', ':', ';', '!', '?', '(', ')', '''', '"', '/', '\', '*', '^');
7300 function IsPunctuation(S
: String): Boolean;
7305 if Length(S
) <> 1 then
7307 for i
:= Low(punct
) to High(punct
) do
7308 if S
= punct
[i
] then
7314 function FilterPunctuation(S
: String): String;
7318 for i
:= Low(punct
) to High(punct
) do
7319 S
:= StringReplace(S
, punct
[i
], ' ', [rfReplaceAll
]);
7325 if gUseChatSounds
and Taunt
and (gChatSounds
<> nil) and (Pos(': ', Text) > 0) then
7327 // remove player name
7328 Delete(Text, 1, Pos(': ', Text) + 2 - 1);
7329 // for FullWord check
7330 Text := toLowerCase1251(' ' + Text + ' ');
7331 fpText
:= FilterPunctuation(Text);
7333 for i
:= 0 to Length(gChatSounds
) - 1 do
7336 for j
:= 0 to Length(gChatSounds
[i
].Tags
) - 1 do
7338 if gChatSounds
[i
].FullWord
and (not IsPunctuation(gChatSounds
[i
].Tags
[j
])) then
7339 ok
:= Pos(' ' + gChatSounds
[i
].Tags
[j
] + ' ', fpText
) > 0
7341 ok
:= Pos(gChatSounds
[i
].Tags
[j
], Text) > 0;
7347 gChatSounds
[i
].Sound
.Play();
7353 g_Sound_PlayEx('SOUND_GAME_RADIO');
7356 procedure g_Game_Announce_GoodShot(SpawnerUID
: Word);
7365 if not g_Game_IsWatchedPlayer(SpawnerUID
) then
7369 if goodsnd
[a
].IsPlaying() then
7372 goodsnd
[Random(4)].Play();
7375 procedure g_Game_Announce_KillCombo(Param
: Integer);
7382 UID
:= Param
and $FFFF;
7387 Pl
:= g_Player_Get(UID
);
7396 g_Console_Add(Format(_lc
[I_PLAYER_KILL_2X
], [Name
]), True);
7400 g_Console_Add(Format(_lc
[I_PLAYER_KILL_3X
], [Name
]), True);
7404 g_Console_Add(Format(_lc
[I_PLAYER_KILL_4X
], [Name
]), True);
7408 g_Console_Add(Format(_lc
[I_PLAYER_KILL_MX
], [Name
]), True);
7416 if not g_Game_IsWatchedPlayer(UID
) then
7419 if (not g_Game_IsWatchedPlayer(UID
)) and (c
< 4) then
7423 if killsnd
[n
].IsPlaying() then
7428 procedure g_Game_Announce_BodyKill(SpawnerUID
: Word);
7437 if not g_Game_IsWatchedPlayer(SpawnerUID
) then
7441 if hahasnd
[a
].IsPlaying() then
7444 hahasnd
[Random(3)].Play();
7447 procedure g_Game_StartVote(Command
, Initiator
: string);
7451 if not gVotesEnabled
then Exit
;
7452 if gGameSettings
.GameType
<> GT_SERVER
then Exit
;
7453 if gVoteInProgress
or gVotePassed
then
7455 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_INPROGRESS
], [gVoteCommand
]), True);
7456 MH_SEND_VoteEvent(NET_VE_INPROGRESS
, gVoteCommand
);
7459 gVoteInProgress
:= True;
7460 gVotePassed
:= False;
7461 gVoteTimer
:= gTime
+ gVoteTimeout
* 1000;
7464 gVoteCommand
:= Command
;
7466 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
7467 Need
:= Floor((NetClientCount
+1)/2.0)+1
7469 Need
:= Floor(NetClientCount
/2.0)+1;
7470 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_STARTED
], [Initiator
, Command
, Need
]), True);
7471 MH_SEND_VoteEvent(NET_VE_STARTED
, Initiator
, Command
, Need
);
7474 procedure g_Game_CheckVote
;
7478 if gGameSettings
.GameType
<> GT_SERVER
then Exit
;
7479 if not gVoteInProgress
then Exit
;
7481 if (gTime
>= gVoteTimer
) then
7483 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
7484 Need
:= Floor((NetClientCount
+1)/2.0) + 1
7486 Need
:= Floor(NetClientCount
/2.0) + 1;
7487 if gVoteCount
>= Need
then
7489 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_PASSED
], [gVoteCommand
]), True);
7490 MH_SEND_VoteEvent(NET_VE_PASSED
, gVoteCommand
);
7491 gVotePassed
:= True;
7492 gVoteCmdTimer
:= gTime
+ 5000;
7496 g_Console_Add(_lc
[I_MESSAGE_VOTE_FAILED
], True);
7497 MH_SEND_VoteEvent(NET_VE_FAILED
);
7499 if NetClients
<> nil then
7500 for I
:= Low(NetClients
) to High(NetClients
) do
7501 if NetClients
[i
].Used
then
7502 NetClients
[i
].Voted
:= False;
7503 gVoteInProgress
:= False;
7509 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
7510 Need
:= Floor((NetClientCount
+1)/2.0) + 1
7512 Need
:= Floor(NetClientCount
/2.0) + 1;
7513 if gVoteCount
>= Need
then
7515 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_PASSED
], [gVoteCommand
]), True);
7516 MH_SEND_VoteEvent(NET_VE_PASSED
, gVoteCommand
);
7517 gVoteInProgress
:= False;
7518 gVotePassed
:= True;
7519 gVoteCmdTimer
:= gTime
+ 5000;
7522 if NetClients
<> nil then
7523 for I
:= Low(NetClients
) to High(NetClients
) do
7524 if NetClients
[i
].Used
then
7525 NetClients
[i
].Voted
:= False;
7530 procedure g_Game_LoadMapList(FileName
: string);
7538 if not FileExists(FileName
) then Exit
;
7540 AssignFile(ListFile
, FileName
);
7542 while not EOF(ListFile
) do
7544 ReadLn(ListFile
, s
);
7547 if s
= '' then Continue
;
7549 SetLength(MapList
, Length(MapList
)+1);
7550 MapList
[High(MapList
)] := s
;
7552 CloseFile(ListFile
);
7555 procedure g_Game_SetDebugMode();
7558 // ×èòû (äàæå â ñâîåé èãðå):
7562 procedure g_Game_SetLoadingText(Text: String; Max
: Integer; reWrite
: Boolean);
7566 if Length(LoadingStat
.Msgs
) = 0 then
7572 begin // Ïåðåõîäèì íà ñëåäóþùóþ ñòðîêó èëè ñêðîëëèðóåì:
7573 if NextMsg
= Length(Msgs
) then
7575 for i
:= 0 to High(Msgs
)-1 do
7576 Msgs
[i
] := Msgs
[i
+1];
7584 Msgs
[NextMsg
-1] := Text;
7588 PBarWasHere
:= false;
7591 g_ActiveWindow
:= nil;
7593 ProcessLoading(true);
7596 procedure g_Game_StepLoading(Value
: Integer = -1);
7607 if (ShowCount
> LOADING_SHOW_STEP
) or (Value
> -1) then
7615 procedure g_Game_ClearLoading();
7624 len
:= ((gScreenHeight
div 3)*2 - 50) div LOADING_INTERLINE
;
7625 if len
< 1 then len
:= 1;
7626 SetLength(Msgs
, len
);
7627 for len
:= Low(Msgs
) to High(Msgs
) do
7630 PBarWasHere
:= false;
7634 procedure Parse_Params(var pars
: TParamStrValues
);
7641 while i
<= ParamCount
do
7644 if (s
[1] = '-') and (Length(s
) > 1) then
7646 if (s
[2] = '-') and (Length(s
) > 2) then
7647 begin // Îäèíî÷íûé ïàðàìåòð
7648 SetLength(pars
, Length(pars
) + 1);
7649 with pars
[High(pars
)] do
7651 Name
:= LowerCase(s
);
7656 if (i
< ParamCount
) then
7657 begin // Ïàðàìåòð ñî çíà÷åíèåì
7659 SetLength(pars
, Length(pars
) + 1);
7660 with pars
[High(pars
)] do
7662 Name
:= LowerCase(s
);
7663 Value
:= LowerCase(ParamStr(i
));
7672 function Find_Param_Value(var pars
: TParamStrValues
; aName
: String): String;
7677 for i
:= 0 to High(pars
) do
7678 if pars
[i
].Name
= aName
then
7680 Result
:= pars
[i
].Value
;
7685 procedure g_Game_Process_Params();
7687 pars
: TParamStrValues
;
7690 LimT
, LimS
: Integer;
7701 s
:= Find_Param_Value(pars
, '--debug');
7704 g_Game_SetDebugMode();
7705 s
:= Find_Param_Value(pars
, '--netdump');
7710 // Connect when game loads
7711 ip
:= Find_Param_Value(pars
, '-connect');
7715 s
:= Find_Param_Value(pars
, '-port');
7716 if (s
= '') or not TryStrToInt(s
, Port
) then
7719 s
:= Find_Param_Value(pars
, '-pw');
7721 g_Game_StartClient(ip
, Port
, s
);
7725 s
:= LowerCase(Find_Param_Value(pars
, '-dbg-mainwad'));
7728 gDefaultMegawadStart
:= s
;
7731 if (Find_Param_Value(pars
, '--dbg-mainwad-restore') <> '') or
7732 (Find_Param_Value(pars
, '--dbg-mainwad-default') <> '') then
7734 gDefaultMegawadStart
:= DF_Default_Megawad_Start
;
7737 // Start map when game loads:
7738 map
:= LowerCase(Find_Param_Value(pars
, '-map'));
7739 if isWadPath(map
) then
7742 s
:= Find_Param_Value(pars
, '-gm');
7743 GMode
:= g_Game_TextToMode(s
);
7744 if GMode
= GM_NONE
then GMode
:= GM_DM
;
7745 if GMode
= GM_SINGLE
then GMode
:= GM_COOP
;
7748 s
:= Find_Param_Value(pars
, '-limt');
7749 if (s
= '') or (not TryStrToInt(s
, LimT
)) then
7755 s
:= Find_Param_Value(pars
, '-lims');
7756 if (s
= '') or (not TryStrToInt(s
, LimS
)) then
7762 s
:= Find_Param_Value(pars
, '-lives');
7763 if (s
= '') or (not TryStrToInt(s
, Lives
)) then
7769 s
:= Find_Param_Value(pars
, '-opt');
7771 Opt
:= GAME_OPTION_ALLOWEXIT
or GAME_OPTION_BOTVSPLAYER
or GAME_OPTION_BOTVSMONSTER
7773 Opt
:= StrToIntDef(s
, 0);
7775 Opt
:= GAME_OPTION_ALLOWEXIT
or GAME_OPTION_BOTVSPLAYER
or GAME_OPTION_BOTVSMONSTER
;
7778 s
:= Find_Param_Value(pars
, '--close');
7782 // Override map to test:
7783 s
:= LowerCase(Find_Param_Value(pars
, '-testmap'));
7785 gTestMap
:= MapsDir
+ s
;
7787 // Delete test map after play:
7788 s
:= Find_Param_Value(pars
, '--testdelete');
7791 gMapToDelete
:= MapsDir
+ map
;
7792 e_WriteLog('"--testdelete" is deprecated, use --tempdelete.', TMsgType
.Fatal
);
7796 // Delete temporary WAD after play:
7797 s
:= Find_Param_Value(pars
, '--tempdelete');
7798 if (s
<> '') and (gTestMap
<> '') then
7800 gMapToDelete
:= gTestMap
;
7801 gTempDelete
:= True;
7804 // Number of players:
7805 s
:= Find_Param_Value(pars
, '-pl');
7807 n
:= DEFAULT_PLAYERS
7809 n
:= StrToIntDef(s
, DEFAULT_PLAYERS
);
7812 s
:= Find_Param_Value(pars
, '-port');
7813 if (s
= '') or not TryStrToInt(s
, Port
) then
7814 g_Game_StartCustom(map
, GMode
, LimT
, LimS
, Lives
, Opt
, n
)
7816 g_Game_StartServer(map
, GMode
, LimT
, LimS
, Lives
, Opt
, n
, 0, Port
);
7819 // Execute script when game loads:
7820 s
:= Find_Param_Value(pars
, '-exec');
7823 if not isWadPath(s
) then
7824 s
:= GameDir
+ '/' + s
;
7829 if IOResult
<> 0 then
7831 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], ['Failed to read file: ' + s
]), TMsgType
.Warning
);
7832 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_READ
], [s
]));
7836 e_WriteLog('Executing script: ' + s
, TMsgType
.Notify
);
7837 g_Console_Add(Format(_lc
[I_CONSOLE_EXEC
], [s
]));
7842 if IOResult
<> 0 then
7844 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], ['Failed to read file: ' + s
]), TMsgType
.Warning
);
7845 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_READ
], [s
]));
7849 if Pos('#', s
) <> 1 then // script comment
7850 g_Console_Process(s
, True);
7861 conRegVar('pf_draw_frame', @g_profile_frame_draw
, 'draw frame rendering profiles', 'render profiles');
7862 //conRegVar('pf_update_frame', @g_profile_frame_update, 'draw frame updating profiles', 'update profiles');
7863 conRegVar('pf_coldet', @g_profile_collision
, 'draw collision detection profiles', 'coldet profiles');
7864 conRegVar('pf_los', @g_profile_los
, 'draw monster LOS profiles', 'monster LOS profiles');
7866 conRegVar('r_sq_draw', @gdbg_map_use_accel_render
, 'accelerated spatial queries in rendering', 'accelerated rendering');
7867 conRegVar('cd_sq_enabled', @gdbg_map_use_accel_coldet
, 'accelerated spatial queries in map coldet', 'accelerated map coldet');
7868 conRegVar('mon_sq_enabled', @gmon_debug_use_sqaccel
, 'accelerated spatial queries for monsters', 'accelerated monster coldet');
7869 conRegVar('wtrace_sq_enabled', @gwep_debug_fast_trace
, 'accelerated spatial queries for weapon hitscan trace', 'accelerated weapon hitscan');
7871 conRegVar('pr_enabled', @gpart_dbg_enabled
, 'enable/disable particles', 'particles');
7872 conRegVar('pr_phys_enabled', @gpart_dbg_phys_enabled
, 'enable/disable particle physics', 'particle physics');
7874 conRegVar('los_enabled', @gmon_dbg_los_enabled
, 'enable/disable monster LOS calculations', 'monster LOS', true);
7875 conRegVar('mon_think', @gmon_debug_think
, 'enable/disable monster thinking', 'monster thinking', true);
7877 {$IFDEF ENABLE_HOLMES}
7878 conRegVar('dbg_holmes', @g_holmes_enabled
, 'enable/disable Holmes', 'Holmes', true);
7881 conRegVar('dbg_ignore_level_bounds', @g_dbg_ignore_bounds
, 'ignore level bounds', '', false);
7883 conRegVar('r_scale', @g_dbg_scale
, 0.01, 100.0, 'render scale', '', false);
7885 conRegVar('light_enabled', @gwin_k8_enable_light_experiments
, 'enable/disable dynamic lighting', 'lighting');
7886 conRegVar('light_player_halo', @g_playerLight
, 'enable/disable player halo', 'player light halo');
7888 conRegVar('r_smallmap_align_h', @r_smallmap_h
, 'halign: 0: left; 1: center; 2: right', 'horizontal aligning of small maps');
7889 conRegVar('r_smallmap_align_v', @r_smallmap_v
, 'valign: 0: top; 1: center; 2: bottom', 'vertial aligning of small maps');
7891 conRegVar('r_showfps', @gShowFPS
, 'draw fps counter', 'draw fps counter');
7892 conRegVar('r_showtime', @gShowTime
, 'show game time', 'show game time');