1 (* Copyright (C) Doom 2D: Forever Developers
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 {$INCLUDE ../shared/a_modes.inc}
24 g_basic
, g_player
, e_graphics
, g_res_downloader
,
25 g_sound
, g_gui
, utils
, md5
, mempool
, xprofiler
,
29 TGameSettings
= record
45 TDelayedEvent
= record
54 Sound
: TPlayableSound
;
55 Tags
: Array of String;
59 TPlayerSettings
= record
78 function g_Game_IsNet(): Boolean;
79 function g_Game_IsServer(): Boolean;
80 function g_Game_IsClient(): Boolean;
81 procedure g_Game_Init();
82 procedure g_Game_Free (freeTextures
: Boolean=true);
83 procedure g_Game_LoadData();
84 procedure g_Game_FreeData();
85 procedure g_Game_Update();
86 procedure g_Game_Draw();
87 procedure g_Game_Quit();
88 procedure g_Game_SetupScreenSize();
89 procedure g_Game_ChangeResolution(newWidth
, newHeight
: Word; nowFull
, nowMax
: Boolean);
90 function g_Game_ModeToText(Mode
: Byte): string;
91 function g_Game_TextToMode(Mode
: string): Byte;
92 procedure g_Game_ExecuteEvent(Name
: String);
93 function g_Game_DelayEvent(DEType
: Byte; Time
: LongWord; Num
: Integer = 0; Str
: String = ''): Integer;
94 procedure g_Game_AddPlayer(Team
: Byte = TEAM_NONE
);
95 procedure g_Game_RemovePlayer();
96 procedure g_Game_Spectate();
97 procedure g_Game_SpectateCenterView();
98 procedure g_Game_StartSingle(Map
: String; TwoPlayers
: Boolean; nPlayers
: Byte);
99 procedure g_Game_StartCustom(Map
: String; GameMode
: Byte; TimeLimit
, GoalLimit
: Word; MaxLives
: Byte; Options
: LongWord; nPlayers
: Byte);
100 procedure g_Game_StartServer(Map
: String; GameMode
: Byte; TimeLimit
, GoalLimit
: Word; MaxLives
: Byte; Options
: LongWord; nPlayers
: Byte; IPAddr
: LongWord; Port
: Word);
101 procedure g_Game_StartClient(Addr
: String; Port
: Word; PW
: String);
102 procedure g_Game_Restart();
103 procedure g_Game_RestartLevel();
104 procedure g_Game_RestartRound(NoMapRestart
: Boolean = False);
105 procedure g_Game_ClientWAD(NewWAD
: String; WHash
: TMD5Digest
);
106 procedure g_Game_SaveOptions();
107 function g_Game_StartMap(Map
: String; Force
: Boolean = False; const oldMapPath
: AnsiString=''): Boolean;
108 procedure g_Game_ChangeMap(const MapPath
: String);
109 procedure g_Game_ExitLevel(const Map
: AnsiString);
110 function g_Game_GetFirstMap(WAD
: String): String;
111 function g_Game_GetNextMap(): String;
112 procedure g_Game_NextLevel();
113 procedure g_Game_Pause(Enable
: Boolean);
114 procedure g_Game_HolmesPause(Enable
: Boolean);
115 procedure g_Game_InGameMenu(Show
: Boolean);
116 function g_Game_IsWatchedPlayer(UID
: Word): Boolean;
117 function g_Game_IsWatchedTeam(Team
: Byte): Boolean;
118 procedure g_Game_Message(Msg
: String; Time
: Word);
119 procedure g_Game_LoadMapList(FileName
: String);
120 procedure g_Game_PauseAllSounds(Enable
: Boolean);
121 procedure g_Game_StopAllSounds(all
: Boolean);
122 procedure g_Game_UpdateTriggerSounds();
123 function g_Game_GetMegaWADInfo(WAD
: String): TMegaWADInfo
;
124 procedure g_Game_ChatSound(Text: String; Taunt
: Boolean = True);
125 procedure g_Game_Announce_GoodShot(SpawnerUID
: Word);
126 procedure g_Game_Announce_KillCombo(Param
: Integer);
127 procedure g_Game_Announce_BodyKill(SpawnerUID
: Word);
128 procedure g_Game_StartVote(Command
, Initiator
: string);
129 procedure g_Game_CheckVote
;
130 procedure g_TakeScreenShot();
131 procedure g_FatalError(Text: String);
132 procedure g_SimpleError(Text: String);
133 function g_Game_IsTestMap(): Boolean;
134 procedure g_Game_DeleteTestMap();
135 procedure GameCVars(P
: SSArray
);
136 procedure GameCommands(P
: SSArray
);
137 procedure GameCheats(P
: SSArray
);
138 procedure DebugCommands(P
: SSArray
);
139 procedure g_Game_Process_Params
;
140 procedure g_Game_SetLoadingText(Text: String; Max
: Integer; reWrite
: Boolean);
141 procedure g_Game_StepLoading(Value
: Integer = -1);
142 procedure g_Game_ClearLoading();
143 procedure g_Game_SetDebugMode();
144 procedure DrawLoadingStat();
146 { procedure SetWinPause(Enable: Boolean); }
151 LOADING_SHOW_STEP
= 100;
152 LOADING_INTERLINE
= 20;
167 MESSAGE_DIKEY
= WM_USER
+ 1;
172 EXIT_ENDLEVELSINGLE
= 4;
173 EXIT_ENDLEVELCUSTOM
= 5;
175 GAME_OPTION_RESERVED
= 1;
176 GAME_OPTION_TEAMDAMAGE
= 2;
177 GAME_OPTION_ALLOWEXIT
= 4;
178 GAME_OPTION_WEAPONSTAY
= 8;
179 GAME_OPTION_MONSTERS
= 16;
180 GAME_OPTION_BOTVSPLAYER
= 32;
181 GAME_OPTION_BOTVSMONSTER
= 64;
186 STATE_INTERCUSTOM
= 3;
187 STATE_INTERSINGLE
= 4;
193 LMS_RESPAWN_NONE
= 0;
194 LMS_RESPAWN_WARMUP
= 1;
195 LMS_RESPAWN_FINAL
= 2;
212 CONFIG_FILENAME
= 'Doom2DF.cfg';
213 LOG_FILENAME
= 'Doom2DF.log';
215 TEST_MAP_NAME
= '$$$_TEST_$$$';
217 STD_PLAYER_MODEL
= 'Doomer';
221 gGameSettings
: TGameSettings
;
222 gPlayer1Settings
: TPlayerSettings
;
223 gPlayer2Settings
: TPlayerSettings
;
225 gPlayerScreenSize
: TDFPoint
;
226 gPlayer1ScreenCoord
: TDFPoint
;
227 gPlayer2ScreenCoord
: TDFPoint
;
228 gPlayer1
: TPlayer
= nil;
229 gPlayer2
: TPlayer
= nil;
230 gPlayerDrawn
: TPlayer
= nil;
232 gSwitchGameMode
: Byte = GM_DM
;
233 gHearPoint1
, gHearPoint2
: THearPoint
;
234 gSoundEffectsDF
: Boolean = False;
235 gSoundTriggerTime
: Word = 0;
236 gAnnouncer
: Byte = ANNOUNCE_NONE
;
237 goodsnd
: array[0..3] of TPlayableSound
;
238 killsnd
: array[0..3] of TPlayableSound
;
239 hahasnd
: array[0..2] of TPlayableSound
;
240 sound_get_flag
: array[0..1] of TPlayableSound
;
241 sound_lost_flag
: array[0..1] of TPlayableSound
;
242 sound_ret_flag
: array[0..1] of TPlayableSound
;
243 sound_cap_flag
: array[0..1] of TPlayableSound
;
244 gBodyKillEvent
: Integer = -1;
245 gDefInterTime
: ShortInt = -1;
246 gInterEndTime
: LongWord = 0;
247 gInterTime
: LongWord = 0;
248 gServInterTime
: Byte = 0;
249 gGameStartTime
: LongWord = 0;
250 gTotalMonsters
: Integer = 0;
251 gPauseMain
: Boolean = false;
252 gPauseHolmes
: Boolean = false;
253 gShowTime
: Boolean = True;
254 gShowFPS
: Boolean = False;
255 gShowGoals
: Boolean = True;
256 gShowStat
: Boolean = True;
257 gShowKillMsg
: Boolean = True;
258 gShowLives
: Boolean = True;
259 gShowPing
: Boolean = False;
260 gShowMap
: Boolean = False;
262 gState
: Byte = STATE_NONE
;
264 sWidth
, sHeight
: Word;
265 gSpectMode
: Byte = SPECT_NONE
;
266 gSpectHUD
: Boolean = True;
267 gSpectKeyPress
: Boolean = False;
268 gSpectX
: Integer = 0;
269 gSpectY
: Integer = 0;
270 gSpectStep
: Byte = 8;
271 gSpectViewTwo
: Boolean = False;
272 gSpectPID1
: Integer = -1;
273 gSpectPID2
: Integer = -1;
274 gSpectAuto
: Boolean = False;
275 gSpectAutoNext
: LongWord;
276 gSpectAutoStepX
: Integer;
277 gSpectAutoStepY
: Integer;
278 gMusic
: TMusic
= nil;
279 gLoadGameMode
: Boolean;
280 gCheats
: Boolean = False;
281 gMapOnce
: Boolean = False;
282 gMapToDelete
: String;
283 gTempDelete
: Boolean = False;
284 gLastMap
: Boolean = False;
285 gWinPosX
, gWinPosY
: Integer;
286 gWinSizeX
, gWinSizeY
: Integer;
287 gWinFrameX
, gWinFrameY
, gWinCaption
: Integer;
288 gWinActive
: Boolean = True; // by default window is active, lol
289 gResolutionChange
: Boolean = False;
290 gRC_Width
, gRC_Height
: Word;
291 gRC_FullScreen
, gRC_Maximized
: Boolean;
292 gLanguageChange
: Boolean = False;
293 gDebugMode
: Boolean = False;
294 g_debug_Sounds
: Boolean = False;
295 g_debug_Frames
: Boolean = False;
296 g_debug_WinMsgs
: Boolean = False;
297 g_debug_MonsterOff
: Boolean = False;
298 g_debug_BotAIOff
: Byte = 0;
299 g_debug_HealthBar
: Boolean = False;
300 g_Debug_Player
: Boolean = False;
301 gCoopMonstersKilled
: Word = 0;
302 gCoopSecretsFound
: Word = 0;
303 gCoopTotalMonstersKilled
: Word = 0;
304 gCoopTotalSecretsFound
: Word = 0;
305 gCoopTotalMonsters
: Word = 0;
306 gCoopTotalSecrets
: Word = 0;
307 gStatsOff
: Boolean = False;
308 gStatsPressed
: Boolean = False;
309 gExitByTrigger
: Boolean = False;
310 gNextMap
: String = '';
311 gLMSRespawn
: Byte = LMS_RESPAWN_NONE
;
312 gLMSRespawnTime
: Cardinal = 0;
313 gLMSSoftSpawn
: Boolean = False;
314 gMissionFailed
: Boolean = False;
315 gVoteInProgress
: Boolean = False;
316 gVotePassed
: Boolean = False;
317 gVoteCommand
: string = '';
318 gVoteTimer
: Cardinal = 0;
319 gVoteCmdTimer
: Cardinal = 0;
320 gVoteCount
: Integer = 0;
321 gVoteTimeout
: Cardinal = 30;
322 gVoted
: Boolean = False;
323 gVotesEnabled
: Boolean = True;
324 gEvents
: Array of TGameEvent
;
325 gDelayedEvents
: Array of TDelayedEvent
;
326 gUseChatSounds
: Boolean = True;
327 gChatSounds
: Array of TChatSound
;
329 g_dbg_ignore_bounds
: Boolean = false;
330 r_smallmap_h
: Integer = 0; // 0: left; 1: center; 2: right
331 r_smallmap_v
: Integer = 2; // 0: top; 1: center; 2: bottom
333 // move button values:
334 // bits 0-1: l/r state:
335 // 0: neither left, nor right pressed
338 // bits 4-5: l/r state when strafe was pressed
339 P1MoveButton
: Byte = 0;
340 P2MoveButton
: Byte = 0;
342 g_profile_frame_update
: Boolean = false;
343 g_profile_frame_draw
: Boolean = false;
344 g_profile_collision
: Boolean = false;
345 g_profile_los
: Boolean = false;
346 g_profile_history_size
: Integer = 1000;
348 g_rlayer_back
: Boolean = true;
349 g_rlayer_step
: Boolean = true;
350 g_rlayer_wall
: Boolean = true;
351 g_rlayer_door
: Boolean = true;
352 g_rlayer_acid1
: Boolean = true;
353 g_rlayer_acid2
: Boolean = true;
354 g_rlayer_water
: Boolean = true;
355 g_rlayer_fore
: Boolean = true;
358 procedure g_ResetDynlights ();
359 procedure g_AddDynLight (x
, y
, radius
: Integer; r
, g
, b
, a
: Single);
360 procedure g_DynLightExplosion (x
, y
, radius
: Integer; r
, g
, b
: Single);
362 function conIsCheatsEnabled (): Boolean; inline;
363 function gPause (): Boolean; inline;
369 {$INCLUDE ../nogl/noGLuses.inc}
370 {$IFDEF ENABLE_HOLMES}
373 e_texture
, g_textures
, g_main
, g_window
, g_menu
,
374 e_input
, e_log
, g_console
, g_items
, g_map
, g_panel
,
375 g_playermodel
, g_gfx
, g_options
, g_weapons
, Math
,
376 g_triggers
, g_monsters
, e_sound
, CONFIG
,
378 ENet
, e_msg
, g_netmsg
, g_netmaster
,
383 hasPBarGfx
: Boolean = false;
386 // ////////////////////////////////////////////////////////////////////////// //
387 function gPause (): Boolean; inline; begin result
:= gPauseMain
or gPauseHolmes
; end;
390 // ////////////////////////////////////////////////////////////////////////// //
391 function conIsCheatsEnabled (): Boolean; inline;
394 if g_Game_IsNet
then exit
;
395 if not gDebugMode
then
397 //if not gCheats then exit;
398 if not (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
]) then exit
;
399 if not (gGameSettings
.GameMode
in [GM_COOP
, GM_SINGLE
]) then exit
;
405 // ////////////////////////////////////////////////////////////////////////// //
407 profileFrameDraw
: TProfiler
= nil;
410 // ////////////////////////////////////////////////////////////////////////// //
413 x
, y
, radius
: Integer;
416 exploRadius
: Integer;
420 g_dynLights
: array of TDynLight
= nil;
421 g_dynLightCount
: Integer = 0;
422 g_playerLight
: Boolean = false;
424 procedure g_ResetDynlights ();
428 if not gwin_has_stencil
then begin g_dynLightCount
:= 0; exit
; end;
430 for idx
:= 0 to g_dynLightCount
-1 do
432 if g_dynLights
[idx
].exploCount
= -666 then
439 Inc(g_dynLights
[idx
].exploCount
);
440 if (g_dynLights
[idx
].exploCount
< 10) then
442 g_dynLights
[idx
].radius
:= g_dynLights
[idx
].exploRadius
+g_dynLights
[idx
].exploCount
*8;
443 g_dynLights
[idx
].a
:= 0.4+g_dynLights
[idx
].exploCount
/10;
444 if (g_dynLights
[idx
].a
> 0.8) then g_dynLights
[idx
].a
:= 0.8;
445 if lnum
<> idx
then g_dynLights
[lnum
] := g_dynLights
[idx
];
450 g_dynLightCount
:= lnum
;
453 procedure g_AddDynLight (x
, y
, radius
: Integer; r
, g
, b
, a
: Single);
455 if not gwin_has_stencil
then exit
;
456 if g_dynLightCount
= length(g_dynLights
) then SetLength(g_dynLights
, g_dynLightCount
+1024);
457 g_dynLights
[g_dynLightCount
].x
:= x
;
458 g_dynLights
[g_dynLightCount
].y
:= y
;
459 g_dynLights
[g_dynLightCount
].radius
:= radius
;
460 g_dynLights
[g_dynLightCount
].r
:= r
;
461 g_dynLights
[g_dynLightCount
].g
:= g
;
462 g_dynLights
[g_dynLightCount
].b
:= b
;
463 g_dynLights
[g_dynLightCount
].a
:= a
;
464 g_dynLights
[g_dynLightCount
].exploCount
:= -666;
465 Inc(g_dynLightCount
);
468 procedure g_DynLightExplosion (x
, y
, radius
: Integer; r
, g
, b
: Single);
470 if not gwin_has_stencil
then exit
;
471 if g_dynLightCount
= length(g_dynLights
) then SetLength(g_dynLights
, g_dynLightCount
+1024);
472 g_dynLights
[g_dynLightCount
].x
:= x
;
473 g_dynLights
[g_dynLightCount
].y
:= y
;
474 g_dynLights
[g_dynLightCount
].radius
:= 0;
475 g_dynLights
[g_dynLightCount
].exploRadius
:= radius
;
476 g_dynLights
[g_dynLightCount
].r
:= r
;
477 g_dynLights
[g_dynLightCount
].g
:= g
;
478 g_dynLights
[g_dynLightCount
].b
:= b
;
479 g_dynLights
[g_dynLightCount
].a
:= 0;
480 g_dynLights
[g_dynLightCount
].exploCount
:= 0;
481 Inc(g_dynLightCount
);
485 // ////////////////////////////////////////////////////////////////////////// //
486 function calcProfilesHeight (prof
: TProfiler
): Integer;
489 if (prof
= nil) then exit
;
490 if (length(prof
.bars
) = 0) then exit
;
491 result
:= length(prof
.bars
)*(16+2);
495 function drawProfiles (x
, y
: Integer; prof
: TProfiler
): Integer;
502 if (prof
= nil) then exit
;
504 if (length(prof
.bars
) = 0) then exit
;
506 hgt
:= calcProfilesHeight(prof
);
507 if (x
< 0) then x
:= gScreenWidth
-(wdt
-1)+x
;
508 if (y
< 0) then y
:= gScreenHeight
-(hgt
-1)+y
;
510 //e_DrawFillQuad(x, y, x+wdt-1, y+hgt-1, 255, 255, 255, 200, B_BLEND);
511 //e_DrawFillQuad(x, y, x+wdt-1, y+hgt-1, 20, 20, 20, 0, B_NONE);
512 e_DarkenQuadWH(x
, y
, wdt
, hgt
, 150);
515 for ii
:= 0 to High(prof
.bars
) do
517 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);
524 // ////////////////////////////////////////////////////////////////////////// //
526 TEndCustomGameStat
= record
527 PlayerStat
: TPlayerStatArray
;
531 Map
, MapName
: String;
534 TEndSingleGameStat
= record
535 PlayerStat
: Array [0..1] of record
541 TotalSecrets
: Integer;
544 TLoadingStat
= record
548 Msgs
: Array of String;
550 PBarWasHere
: Boolean; // did we draw a progress bar for this message?
553 TParamStrValue
= record
558 TParamStrValues
= Array of TParamStrValue
;
561 INTER_ACTION_TEXT
= 1;
562 INTER_ACTION_PIC
= 2;
563 INTER_ACTION_MUSIC
= 3;
567 FPSCounter
, UPSCounter
: Word;
568 FPSTime
, UPSTime
: LongWord;
569 DataLoaded
: Boolean = False;
570 LastScreenShot
: Int64;
571 IsDrawStat
: Boolean = False;
572 CustomStat
: TEndCustomGameStat
;
573 SingleStat
: TEndSingleGameStat
;
574 LoadingStat
: TLoadingStat
;
575 EndingGameCounter
: Byte = 0;
578 MessageLineLength
: Integer = 80;
579 MapList
: SSArray
= nil;
580 MapIndex
: Integer = -1;
586 text: Array of ShortString;
587 anim
: Array of ShortString;
588 pic
: Array of ShortString;
589 mus
: Array of ShortString;
591 triggers
: Array of record
593 actions
: Array of record
594 action
, p1
, p2
: Integer;
597 cur_trigger
: Integer;
610 function Compare(a
, b
: TPlayerStat
): Integer;
612 if a
.Spectator
then Result
:= 1
613 else if b
.Spectator
then Result
:= -1
614 else if a
.Frags
< b
.Frags
then Result
:= 1
615 else if a
.Frags
> b
.Frags
then Result
:= -1
616 else if a
.Deaths
< b
.Deaths
then Result
:= -1
617 else if a
.Deaths
> b
.Deaths
then Result
:= 1
618 else if a
.Kills
< b
.Kills
then Result
:= -1
622 procedure SortGameStat(var stat
: TPlayerStatArray
);
627 if stat
= nil then Exit
;
629 for I
:= High(stat
) downto Low(stat
) do
630 for J
:= Low(stat
) to High(stat
) - 1 do
631 if Compare(stat
[J
], stat
[J
+ 1]) = 1 then
634 stat
[J
] := stat
[J
+ 1];
639 function g_Game_ModeToText(Mode
: Byte): string;
643 GM_DM
: Result
:= _lc
[I_MENU_GAME_TYPE_DM
];
644 GM_TDM
: Result
:= _lc
[I_MENU_GAME_TYPE_TDM
];
645 GM_CTF
: Result
:= _lc
[I_MENU_GAME_TYPE_CTF
];
646 GM_COOP
: Result
:= _lc
[I_MENU_GAME_TYPE_COOP
];
647 GM_SINGLE
: Result
:= _lc
[I_MENU_GAME_TYPE_SINGLE
];
651 function g_Game_TextToMode(Mode
: string): Byte;
654 Mode
:= UpperCase(Mode
);
655 if Mode
= _lc
[I_MENU_GAME_TYPE_DM
] then
660 if Mode
= _lc
[I_MENU_GAME_TYPE_TDM
] then
665 if Mode
= _lc
[I_MENU_GAME_TYPE_CTF
] then
670 if Mode
= _lc
[I_MENU_GAME_TYPE_COOP
] then
675 if Mode
= _lc
[I_MENU_GAME_TYPE_SINGLE
] then
682 function g_Game_IsNet(): Boolean;
684 Result
:= (gGameSettings
.GameType
in [GT_SERVER
, GT_CLIENT
]);
687 function g_Game_IsServer(): Boolean;
689 Result
:= (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
, GT_SERVER
]);
692 function g_Game_IsClient(): Boolean;
694 Result
:= (gGameSettings
.GameType
= GT_CLIENT
);
697 function g_Game_GetMegaWADInfo(WAD
: String): TMegaWADInfo
;
704 Result
.name
:= ExtractFileName(WAD
);
705 Result
.description
:= '';
708 w
:= TWADFile
.Create();
711 if not w
.GetResource('INTERSCRIPT', p
, len
) then
717 cfg
:= TConfig
.CreateMem(p
, len
);
718 Result
.name
:= cfg
.ReadStr('megawad', 'name', ExtractFileName(WAD
));
719 Result
.description
:= cfg
.ReadStr('megawad', 'description', '');
720 Result
.author
:= cfg
.ReadStr('megawad', 'author', '');
721 Result
.pic
:= cfg
.ReadStr('megawad', 'pic', '');
727 procedure g_Game_FreeWAD();
731 for a
:= 0 to High(MegaWAD
.res
.pic
) do
732 if MegaWAD
.res
.pic
[a
] <> '' then
733 g_Texture_Delete(MegaWAD
.res
.pic
[a
]);
735 for a
:= 0 to High(MegaWAD
.res
.mus
) do
736 if MegaWAD
.res
.mus
[a
] <> '' then
737 g_Sound_Delete(MegaWAD
.res
.mus
[a
]);
739 MegaWAD
.res
.pic
:= nil;
740 MegaWAD
.res
.text := nil;
741 MegaWAD
.res
.anim
:= nil;
742 MegaWAD
.res
.mus
:= nil;
743 MegaWAD
.triggers
:= nil;
745 g_Texture_Delete('TEXTURE_endpic');
746 g_Sound_Delete('MUSIC_endmus');
748 ZeroMemory(@MegaWAD
, SizeOf(MegaWAD
));
749 gGameSettings
.WAD
:= '';
752 procedure g_Game_LoadWAD(WAD
: string);
761 gGameSettings
.WAD
:= WAD
;
762 if not (gGameSettings
.GameMode
in [GM_COOP
, GM_SINGLE
]) then
765 MegaWAD
.info
:= g_Game_GetMegaWADInfo(MapsDir
+ WAD
);
767 w
:= TWADFile
.Create();
768 w
.ReadFile(MapsDir
+ WAD
);
770 if not w
.GetResource('INTERSCRIPT', p
, len
) then
776 cfg
:= TConfig
.CreateMem(p
, len
);
781 s := cfg.ReadStr('pic', 'pic'+IntToStr(b), '');
782 if s = '' then Break;
785 SetLength(MegaWAD.res.pic, Length(MegaWAD.res.pic)+1);
786 MegaWAD.res.pic[High(MegaWAD.res.pic)] := s;
788 g_Texture_CreateWADEx(s, s);
794 s := cfg.ReadStr('mus', 'mus'+IntToStr(b), '');
795 if s = '' then Break;
798 SetLength(MegaWAD.res.mus, Length(MegaWAD.res.mus)+1);
799 MegaWAD.res.mus[High(MegaWAD.res.mus)] := s;
801 g_Music_CreateWADEx(s, s);
804 MegaWAD
.endpic
:= cfg
.ReadStr('megawad', 'endpic', '');
805 if MegaWAD
.endpic
<> '' then
807 s
:= g_ExtractWadName(MegaWAD
.endpic
);
808 if s
= '' then s
:= MapsDir
+WAD
else s
:= GameDir
+'/wads/';
809 g_Texture_CreateWADEx('TEXTURE_endpic', s
+MegaWAD
.endpic
);
811 MegaWAD
.endmus
:= cfg
.ReadStr('megawad', 'endmus', 'Standart.wad:D2DMUS\ÊÎÍÅÖ');
812 if MegaWAD
.endmus
<> '' then
814 s
:= g_ExtractWadName(MegaWAD
.endmus
);
815 if s
= '' then s
:= MapsDir
+WAD
else s
:= GameDir
+'/wads/';
816 g_Sound_CreateWADEx('MUSIC_endmus', s
+MegaWAD
.endmus
, True);
824 {procedure start_trigger(t: string);
828 function next_trigger(): Boolean;
832 procedure DisableCheats();
838 if gPlayer1
<> nil then gPlayer1
.GodMode
:= False;
839 if gPlayer2
<> nil then gPlayer2
.GodMode
:= False;
840 if gPlayer1
<> nil then gPlayer1
.NoTarget
:= False;
841 if gPlayer2
<> nil then gPlayer2
.NoTarget
:= False;
843 {$IF DEFINED(D2F_DEBUG)}
844 if gPlayer1
<> nil then gPlayer1
.NoTarget
:= True;
845 gAimLine
:= g_dbg_aimline_on
;
849 procedure g_Game_ExecuteEvent(Name
: String);
855 if gEvents
= nil then
857 for a
:= 0 to High(gEvents
) do
858 if gEvents
[a
].Name
= Name
then
860 if gEvents
[a
].Command
<> '' then
861 g_Console_Process(gEvents
[a
].Command
, True);
866 function g_Game_DelayEvent(DEType
: Byte; Time
: LongWord; Num
: Integer = 0; Str
: String = ''): Integer;
871 if gDelayedEvents
<> nil then
872 for a
:= 0 to High(gDelayedEvents
) do
873 if not gDelayedEvents
[a
].Pending
then
880 SetLength(gDelayedEvents
, Length(gDelayedEvents
) + 1);
881 n
:= High(gDelayedEvents
);
883 gDelayedEvents
[n
].Pending
:= True;
884 gDelayedEvents
[n
].DEType
:= DEType
;
885 gDelayedEvents
[n
].DENum
:= Num
;
886 gDelayedEvents
[n
].DEStr
:= Str
;
887 if DEType
= DE_GLOBEVENT
then
888 gDelayedEvents
[n
].Time
:= (GetTimer() {div 1000}) + Time
890 gDelayedEvents
[n
].Time
:= gTime
+ Time
;
899 if g_Game_IsNet
and g_Game_IsServer
then
900 MH_SEND_GameEvent(NET_EV_MAPEND
, Byte(gMissionFailed
));
904 gPauseHolmes
:= false;
907 g_Game_StopAllSounds(False);
912 EndingGameCounter
:= 0;
913 g_ActiveWindow
:= nil;
915 gLMSRespawn
:= LMS_RESPAWN_NONE
;
916 gLMSRespawnTime
:= 0;
919 EXIT_SIMPLE
: // Âûõîä ÷åðåç ìåíþ èëè êîíåö òåñòà
924 begin // Ýòî áûë òåñò
928 begin // Âûõîä â ãëàâíîå ìåíþ
929 gMusic
.SetByName('MUSIC_MENU');
931 if gState
<> STATE_SLIST
then
933 g_GUI_ShowWindow('MainMenu');
934 gState
:= STATE_MENU
;
937 // Îáíîâëÿåì ñïèñîê ñåðâåðîâ
938 slReturnPressed
:= True;
939 if g_Net_Slist_Fetch(slCurrent
) then
941 if slCurrent
= nil then
942 slWaitStr
:= _lc
[I_NET_SLIST_NOSERVERS
];
945 slWaitStr
:= _lc
[I_NET_SLIST_ERROR
];
946 g_Serverlist_GenerateTable(slCurrent
, slTable
);
949 g_Game_ExecuteEvent('ongameend');
953 EXIT_RESTART
: // Íà÷àòü óðîâåíü ñíà÷àëà
955 if not g_Game_IsClient
then g_Game_Restart();
958 EXIT_ENDLEVELCUSTOM
: // Çàêîí÷èëñÿ óðîâåíü â Ñâîåé èãðå
960 // Ñòàòèñòèêà Ñâîåé èãðû:
961 FileName
:= g_ExtractWadName(gMapInfo
.Map
);
963 CustomStat
.GameTime
:= gTime
;
964 CustomStat
.Map
:= ExtractFileName(FileName
)+':'+g_ExtractFileName(gMapInfo
.Map
); //ResName;
965 CustomStat
.MapName
:= gMapInfo
.Name
;
966 CustomStat
.GameMode
:= gGameSettings
.GameMode
;
967 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
968 CustomStat
.TeamStat
:= gTeamStat
;
970 CustomStat
.PlayerStat
:= nil;
972 // Ñòàòèñòèêà èãðîêîâ:
973 if gPlayers
<> nil then
975 for a
:= 0 to High(gPlayers
) do
976 if gPlayers
[a
] <> nil then
978 SetLength(CustomStat
.PlayerStat
, Length(CustomStat
.PlayerStat
)+1);
979 with CustomStat
.PlayerStat
[High(CustomStat
.PlayerStat
)] do
981 Name
:= gPlayers
[a
].Name
;
982 Frags
:= gPlayers
[a
].Frags
;
983 Deaths
:= gPlayers
[a
].Death
;
984 Kills
:= gPlayers
[a
].Kills
;
985 Team
:= gPlayers
[a
].Team
;
986 Color
:= gPlayers
[a
].Model
.Color
;
987 Spectator
:= gPlayers
[a
].FSpectator
;
991 SortGameStat(CustomStat
.PlayerStat
);
994 g_Game_ExecuteEvent('onmapend');
997 EndingGameCounter
:= 255;
998 gState
:= STATE_FOLD
;
1000 if gDefInterTime
< 0 then
1001 gInterEndTime
:= IfThen((gGameSettings
.GameType
= GT_SERVER
) and (gPlayer1
= nil), 15000, 25000)
1003 gInterEndTime
:= gDefInterTime
* 1000;
1006 EXIT_ENDLEVELSINGLE
: // Çàêîí÷èëñÿ óðîâåíü â Îäèíî÷íîé èãðå
1008 // Ñòàòèñòèêà Îäèíî÷íîé èãðû:
1009 SingleStat
.GameTime
:= gTime
;
1010 SingleStat
.TwoPlayers
:= gPlayer2
<> nil;
1011 SingleStat
.TotalSecrets
:= gSecretsCount
;
1012 // Ñòàòèñòèêà ïåðâîãî èãðîêà:
1013 SingleStat
.PlayerStat
[0].Kills
:= gPlayer1
.MonsterKills
;
1014 SingleStat
.PlayerStat
[0].Secrets
:= gPlayer1
.Secrets
;
1015 // Ñòàòèñòèêà âòîðîãî èãðîêà (åñëè åñòü):
1016 if SingleStat
.TwoPlayers
then
1018 SingleStat
.PlayerStat
[1].Kills
:= gPlayer2
.MonsterKills
;
1019 SingleStat
.PlayerStat
[1].Secrets
:= gPlayer2
.Secrets
;
1022 g_Game_ExecuteEvent('onmapend');
1025 if gNextMap
<> '' then
1027 gMusic
.SetByName('MUSIC_INTERMUS');
1029 gState
:= STATE_INTERSINGLE
;
1032 g_Game_ExecuteEvent('oninter');
1034 else // Áîëüøå íåò êàðò
1036 // Çàòóõàþùèé ýêðàí:
1037 EndingGameCounter
:= 255;
1038 gState
:= STATE_FOLD
;
1043 // Îêîí÷àíèå îáðàáîòàíî:
1044 if gExit
<> EXIT_QUIT
then
1048 procedure drawTime(X
, Y
: Integer); inline;
1050 e_TextureFontPrint(x
, y
,
1051 Format('%d:%.2d:%.2d', [
1052 gTime
div 1000 div 3600,
1053 (gTime
div 1000 div 60) mod 60,
1054 gTime
div 1000 mod 60
1059 procedure DrawStat();
1061 pc
, x
, y
, w
, h
: Integer;
1062 w1
, w2
, w3
, w4
: Integer;
1064 cw
, ch
, r
, g
, b
, rr
, gg
, bb
: Byte;
1067 stat
: TPlayerStatArray
;
1074 pc
:= g_Player_GetCount
;
1075 e_TextureFontGetSize(gStdFont
, cw
, ch
);
1077 w
:= gScreenWidth
-(gScreenWidth
div 5);
1078 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
1081 h
:= 40+ch
*5+(ch
+8)*pc
;
1082 x
:= (gScreenWidth
div 2)-(w
div 2);
1083 y
:= (gScreenHeight
div 2)-(h
div 2);
1085 e_DrawFillQuad(x
, y
, x
+w
-1, y
+h
-1, 64, 64, 64, 32);
1086 e_DrawQuad(x
, y
, x
+w
-1, y
+h
-1, 255, 127, 0);
1088 drawTime(x
+w
-78, y
+8);
1090 wad
:= g_ExtractWadNameNoPath(gMapInfo
.Map
);
1091 map
:= g_ExtractFileName(gMapInfo
.Map
);
1092 mapstr
:= wad
+ ':\' + map
+ ' - ' + gMapInfo
.Name
;
1094 case gGameSettings
.GameMode
of
1097 if gGameSettings
.MaxLives
= 0 then
1098 s1
:= _lc
[I_GAME_DM
]
1100 s1
:= _lc
[I_GAME_LMS
];
1101 s2
:= Format(_lc
[I_GAME_FRAG_LIMIT
], [gGameSettings
.GoalLimit
]);
1102 s3
:= Format(_lc
[I_GAME_TIME_LIMIT
], [gGameSettings
.TimeLimit
div 3600, (gGameSettings
.TimeLimit
div 60) mod 60, gGameSettings
.TimeLimit
mod 60]);
1107 if gGameSettings
.MaxLives
= 0 then
1108 s1
:= _lc
[I_GAME_TDM
]
1110 s1
:= _lc
[I_GAME_TLMS
];
1111 s2
:= Format(_lc
[I_GAME_FRAG_LIMIT
], [gGameSettings
.GoalLimit
]);
1112 s3
:= Format(_lc
[I_GAME_TIME_LIMIT
], [gGameSettings
.TimeLimit
div 3600, (gGameSettings
.TimeLimit
div 60) mod 60, gGameSettings
.TimeLimit
mod 60]);
1117 s1
:= _lc
[I_GAME_CTF
];
1118 s2
:= Format(_lc
[I_GAME_SCORE_LIMIT
], [gGameSettings
.GoalLimit
]);
1119 s3
:= Format(_lc
[I_GAME_TIME_LIMIT
], [gGameSettings
.TimeLimit
div 3600, (gGameSettings
.TimeLimit
div 60) mod 60, gGameSettings
.TimeLimit
mod 60]);
1124 if gGameSettings
.MaxLives
= 0 then
1125 s1
:= _lc
[I_GAME_COOP
]
1127 s1
:= _lc
[I_GAME_SURV
];
1128 s2
:= _lc
[I_GAME_MONSTERS
] + ' ' + IntToStr(gCoopMonstersKilled
) + '/' + IntToStr(gTotalMonsters
);
1129 s3
:= _lc
[I_GAME_SECRETS
] + ' ' + IntToStr(gCoopSecretsFound
) + '/' + IntToStr(gSecretsCount
);
1140 e_TextureFontPrintEx(x
+(w
div 2)-(Length(s1
)*cw
div 2), _y
, s1
, gStdFont
, 255, 255, 255, 1);
1142 e_TextureFontPrintEx(x
+(w
div 2)-(Length(mapstr
)*cw
div 2), _y
, mapstr
, gStdFont
, 200, 200, 200, 1);
1144 e_TextureFontPrintEx(x
+16, _y
, s2
, gStdFont
, 200, 200, 200, 1);
1146 e_TextureFontPrintEx(x
+w
-16-(Length(s3
))*cw
, _y
, s3
,
1147 gStdFont
, 200, 200, 200, 1);
1149 if NetMode
= NET_SERVER
then
1150 e_TextureFontPrintEx(x
+8, y
+ 8, _lc
[I_NET_SERVER
], gStdFont
, 255, 255, 255, 1)
1152 if NetMode
= NET_CLIENT
then
1153 e_TextureFontPrintEx(x
+8, y
+ 8,
1154 NetClientIP
+ ':' + IntToStr(NetClientPort
), gStdFont
, 255, 255, 255, 1);
1158 stat
:= g_Player_GetStats();
1161 w2
:= (w
-16) div 6 + 48; // øèðèíà 2 ñòîëáöà
1162 w3
:= (w
-16) div 6; // øèðèíà 3 è 4 ñòîëáöîâ
1164 w1
:= w
-16-w2
-w3
-w4
; // îñòàâøååñÿ ïðîñòðàíñòâî - äëÿ öâåòà è èìåíè èãðîêà
1166 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
1170 for a
:= TEAM_RED
to TEAM_BLUE
do
1172 if a
= TEAM_RED
then
1174 s1
:= _lc
[I_GAME_TEAM_RED
];
1181 s1
:= _lc
[I_GAME_TEAM_BLUE
];
1187 e_TextureFontPrintEx(x
+16, _y
, s1
, gStdFont
, r
, g
, b
, 1);
1188 e_TextureFontPrintEx(x
+w1
+16, _y
, IntToStr(gTeamStat
[a
].Goals
),
1189 gStdFont
, r
, g
, b
, 1);
1191 _y
:= _y
+ch
+(ch
div 4);
1192 e_DrawLine(1, x
+16, _y
, x
+w
-16, _y
, r
, g
, b
);
1193 _y
:= _y
+(ch
div 4);
1195 for aa
:= 0 to High(stat
) do
1196 if stat
[aa
].Team
= a
then
1212 e_TextureFontPrintEx(x
+16, _y
, Name
, gStdFont
, rr
, gg
, bb
, 1);
1214 e_TextureFontPrintEx(x
+w1
+16, _y
, Format(_lc
[I_GAME_PING_MS
], [Ping
, Loss
]), gStdFont
, rr
, gg
, bb
, 1);
1216 e_TextureFontPrintEx(x
+w1
+w2
+16, _y
, IntToStr(Frags
), gStdFont
, rr
, gg
, bb
, 1);
1218 e_TextureFontPrintEx(x
+w1
+w2
+w3
+16, _y
, IntToStr(Deaths
), gStdFont
, rr
, gg
, bb
, 1);
1225 else if gGameSettings
.GameMode
in [GM_DM
, GM_COOP
] then
1228 e_TextureFontPrintEx(x
+16, _y
, _lc
[I_GAME_PLAYER_NAME
], gStdFont
, 255, 127, 0, 1);
1229 e_TextureFontPrintEx(x
+16+w1
, _y
, _lc
[I_GAME_PING
], gStdFont
, 255, 127, 0, 1);
1230 e_TextureFontPrintEx(x
+16+w1
+w2
, _y
, _lc
[I_GAME_FRAGS
], gStdFont
, 255, 127, 0, 1);
1231 e_TextureFontPrintEx(x
+16+w1
+w2
+w3
, _y
, _lc
[I_GAME_DEATHS
], gStdFont
, 255, 127, 0, 1);
1234 for aa
:= 0 to High(stat
) do
1248 e_DrawFillQuad(x
+16, _y
+4, x
+32-1, _y
+16+4-1, Color
.R
, Color
.G
, Color
.B
, 0);
1249 e_DrawQuad(x
+16, _y
+4, x
+32-1, _y
+16+4-1, 192, 192, 192);
1251 e_TextureFontPrintEx(x
+16+16+8, _y
+4, Name
, gStdFont
, r
, g
, 0, 1);
1253 e_TextureFontPrintEx(x
+w1
+16, _y
+4, Format(_lc
[I_GAME_PING_MS
], [Ping
, Loss
]), gStdFont
, r
, g
, 0, 1);
1255 e_TextureFontPrintEx(x
+w1
+w2
+16, _y
+4, IntToStr(Frags
), gStdFont
, r
, g
, 0, 1);
1257 e_TextureFontPrintEx(x
+w1
+w2
+w3
+16, _y
+4, IntToStr(Deaths
), gStdFont
, r
, g
, 0, 1);
1263 procedure g_Game_Init();
1269 gTempDelete
:= False;
1271 sfsGCDisable(); // temporary disable removing of temporary volumes
1274 g_Texture_CreateWADEx('MENU_BACKGROUND', GameWAD
+':TEXTURES\TITLE');
1275 g_Texture_CreateWADEx('INTER', GameWAD
+':TEXTURES\INTER');
1276 g_Texture_CreateWADEx('ENDGAME_EN', GameWAD
+':TEXTURES\ENDGAME_EN');
1277 g_Texture_CreateWADEx('ENDGAME_RU', GameWAD
+':TEXTURES\ENDGAME_RU');
1279 LoadStdFont('STDTXT', 'STDFONT', gStdFont
);
1280 LoadFont('MENUTXT', 'MENUFONT', gMenuFont
);
1281 LoadFont('SMALLTXT', 'SMALLFONT', gMenuSmallFont
);
1283 g_Game_ClearLoading();
1284 g_Game_SetLoadingText(Format('Doom 2D: Forever %s', [GAME_VERSION
]), 0, False);
1285 g_Game_SetLoadingText('', 0, False);
1287 g_Game_SetLoadingText(_lc
[I_LOAD_CONSOLE
], 0, False);
1290 g_Game_SetLoadingText(_lc
[I_LOAD_MODELS
], 0, False);
1291 g_PlayerModel_LoadData();
1293 if FindFirst(ModelsDir
+'*.wad', faAnyFile
, SR
) = 0 then
1295 if not g_PlayerModel_Load(ModelsDir
+SR
.Name
) then
1296 e_WriteLog(Format('Error loading model %s', [SR
.Name
]), TMsgType
.Warning
);
1297 until FindNext(SR
) <> 0;
1300 if FindFirst(ModelsDir
+'*.pk3', faAnyFile
, SR
) = 0 then
1302 if not g_PlayerModel_Load(ModelsDir
+SR
.Name
) then
1303 e_WriteLog(Format('Error loading model %s', [SR
.Name
]), TMsgType
.Warning
);
1304 until FindNext(SR
) <> 0;
1307 if FindFirst(ModelsDir
+'*.zip', faAnyFile
, SR
) = 0 then
1309 if not g_PlayerModel_Load(ModelsDir
+SR
.Name
) then
1310 e_WriteLog(Format('Error loading model %s', [SR
.Name
]), TMsgType
.Warning
);
1311 until FindNext(SR
) <> 0;
1315 gPauseMain
:= false;
1316 gPauseHolmes
:= false;
1318 LastScreenShot
:= 0;
1320 {e_MouseInfo.Accel := 1.0;}
1322 g_Game_SetLoadingText(_lc
[I_LOAD_GAME_DATA
], 0, False);
1325 g_Game_SetLoadingText(_lc
[I_LOAD_MUSIC
], 0, False);
1326 g_Sound_CreateWADEx('MUSIC_INTERMUS', GameWAD
+':MUSIC\INTERMUS', True);
1327 g_Sound_CreateWADEx('MUSIC_MENU', GameWAD
+':MUSIC\MENU', True);
1328 g_Sound_CreateWADEx('MUSIC_ROUNDMUS', GameWAD
+':MUSIC\ROUNDMUS', True);
1329 g_Sound_CreateWADEx('MUSIC_STDENDMUS', GameWAD
+':MUSIC\ENDMUS', True);
1331 g_Game_SetLoadingText(_lc
[I_LOAD_MENUS
], 0, False);
1334 gMusic
:= TMusic
.Create();
1335 gMusic
.SetByName('MUSIC_MENU');
1338 gGameSettings
.WarmupTime
:= 30;
1340 gState
:= STATE_MENU
;
1342 SetLength(gEvents
, 6);
1343 gEvents
[0].Name
:= 'ongamestart';
1344 gEvents
[1].Name
:= 'ongameend';
1345 gEvents
[2].Name
:= 'onmapstart';
1346 gEvents
[3].Name
:= 'onmapend';
1347 gEvents
[4].Name
:= 'oninter';
1348 gEvents
[5].Name
:= 'onwadend';
1350 sfsGCEnable(); // enable releasing unused volumes
1354 procedure g_Game_Free(freeTextures
: Boolean=true);
1356 if NetMode
= NET_CLIENT
then g_Net_Disconnect();
1357 if NetMode
= NET_SERVER
then g_Net_Host_Die();
1359 g_Map_Free(freeTextures
);
1361 g_Player_RemoveAllCorpses();
1363 gGameSettings
.GameType
:= GT_NONE
;
1364 if gGameSettings
.GameMode
= GM_SINGLE
then
1365 gGameSettings
.GameMode
:= GM_DM
;
1366 gSwitchGameMode
:= gGameSettings
.GameMode
;
1369 gExitByTrigger
:= False;
1372 function IsActivePlayer(p
: TPlayer
): Boolean;
1377 Result
:= (not p
.FDummy
) and (not p
.FSpectator
);
1380 function GetActivePlayer_ByID(ID
: Integer): TPlayer
;
1387 if gPlayers
= nil then
1389 for a
:= Low(gPlayers
) to High(gPlayers
) do
1390 if IsActivePlayer(gPlayers
[a
]) then
1392 if gPlayers
[a
].UID
<> ID
then
1394 Result
:= gPlayers
[a
];
1399 function GetActivePlayerID_Next(Skip
: Integer = -1): Integer;
1405 if gPlayers
= nil then
1409 for a
:= Low(gPlayers
) to High(gPlayers
) do
1410 if IsActivePlayer(gPlayers
[a
]) then
1412 SetLength(ids
, Length(ids
) + 1);
1413 ids
[High(ids
)] := gPlayers
[a
].UID
;
1414 if gPlayers
[a
].UID
= Skip
then
1417 if Length(ids
) = 0 then
1422 Result
:= ids
[(idx
+ 1) mod Length(ids
)];
1425 function GetActivePlayerID_Prev(Skip
: Integer = -1): Integer;
1431 if gPlayers
= nil then
1435 for a
:= Low(gPlayers
) to High(gPlayers
) do
1436 if IsActivePlayer(gPlayers
[a
]) then
1438 SetLength(ids
, Length(ids
) + 1);
1439 ids
[High(ids
)] := gPlayers
[a
].UID
;
1440 if gPlayers
[a
].UID
= Skip
then
1443 if Length(ids
) = 0 then
1446 Result
:= ids
[Length(ids
) - 1]
1448 Result
:= ids
[(Length(ids
) - 1 + idx
) mod Length(ids
)];
1451 function GetActivePlayerID_Random(Skip
: Integer = -1): Integer;
1457 if gPlayers
= nil then
1461 for a
:= Low(gPlayers
) to High(gPlayers
) do
1462 if IsActivePlayer(gPlayers
[a
]) then
1464 SetLength(ids
, Length(ids
) + 1);
1465 ids
[High(ids
)] := gPlayers
[a
].UID
;
1466 if gPlayers
[a
].UID
= Skip
then
1469 if Length(ids
) = 0 then
1471 if Length(ids
) = 1 then
1476 Result
:= ids
[Random(Length(ids
))];
1478 while (idx
<> -1) and (Result
= Skip
) and (a
> 0) do
1480 Result
:= ids
[Random(Length(ids
))];
1485 function GetRandomSpectMode(Current
: Byte): Byte;
1492 0: Result
:= SPECT_STATS
;
1493 1: Result
:= SPECT_MAPVIEW
;
1494 2: Result
:= SPECT_MAPVIEW
;
1495 3: Result
:= SPECT_PLAYERS
;
1496 4: Result
:= SPECT_PLAYERS
;
1497 5: Result
:= SPECT_PLAYERS
;
1498 6: Result
:= SPECT_PLAYERS
;
1500 if (Current
in [SPECT_STATS
, SPECT_MAPVIEW
]) and (Current
= Result
) then
1504 function isKeyPressed (key1
: Word; key2
: Word): Boolean;
1506 if (key1
<> 0) and e_KeyPressed(key1
) then begin result
:= true; exit
; end;
1507 if (key2
<> 0) and e_KeyPressed(key2
) then begin result
:= true; exit
; end;
1511 procedure processPlayerControls (plr
: TPlayer
; var ctrl
: TPlayerControl
; var MoveButton
: Byte; p2hack
: Boolean=false);
1517 if (plr
= nil) then exit
;
1518 if (p2hack
) then time
:= 1000 else time
:= 1;
1519 strafeDir
:= MoveButton
shr 4;
1520 MoveButton
:= MoveButton
and $0F;
1523 if isKeyPressed(KeyLeft
, KeyLeft2
) and (not isKeyPressed(KeyRight
, KeyRight2
)) then MoveButton
:= 1 // Íàæàòà òîëüêî "Âëåâî"
1524 else if (not isKeyPressed(KeyLeft
, KeyLeft2
)) and isKeyPressed(KeyRight
, KeyRight2
) then MoveButton
:= 2 // Íàæàòà òîëüêî "Âïðàâî"
1525 else if (not isKeyPressed(KeyLeft
, KeyLeft2
)) and (not isKeyPressed(KeyRight
, KeyRight2
)) then MoveButton
:= 0; // Íå íàæàòû íè "Âëåâî", íè "Âïðàâî"
1527 // Ñåé÷àñ èëè ðàíüøå áûëè íàæàòû "Âëåâî"/"Âïðàâî" => ïåðåäàåì èãðîêó:
1528 if MoveButton
= 1 then plr
.PressKey(KEY_LEFT
, time
)
1529 else if MoveButton
= 2 then plr
.PressKey(KEY_RIGHT
, time
);
1531 // if we have "strafe" key, turn off old strafe mechanics
1532 if isKeyPressed(KeyStrafe
, KeyStrafe2
) then
1534 // new strafe mechanics
1535 if (strafeDir
= 0) then strafeDir
:= MoveButton
; // start strafing
1536 // now set direction according to strafe (reversed)
1537 if (strafeDir
= 2) then plr
.SetDirection(TDirection
.D_LEFT
)
1538 else if (strafeDir
= 1) then plr
.SetDirection(TDirection
.D_RIGHT
);
1542 strafeDir
:= 0; // not strafing anymore
1543 // Ðàíüøå áûëà íàæàòà "Âïðàâî", à ñåé÷àñ "Âëåâî" => áåæèì âïðàâî, ñìîòðèì âëåâî:
1544 if (MoveButton
= 2) and isKeyPressed(KeyLeft
, KeyLeft2
) then plr
.SetDirection(TDirection
.D_LEFT
)
1545 // Ðàíüøå áûëà íàæàòà "Âëåâî", à ñåé÷àñ "Âïðàâî" => áåæèì âëåâî, ñìîòðèì âïðàâî:
1546 else if (MoveButton
= 1) and isKeyPressed(KeyRight
, KeyRight2
) then plr
.SetDirection(TDirection
.D_RIGHT
)
1547 // ×òî-òî áûëî íàæàòî è íå èçìåíèëîñü => êóäà áåæèì, òóäà è ñìîòðèì:
1548 else if MoveButton
<> 0 then plr
.SetDirection(TDirection(MoveButton
-1));
1551 // fix movebutton state
1552 MoveButton
:= MoveButton
or (strafeDir
shl 4);
1554 // Îñòàëüíûå êëàâèøè:
1555 if isKeyPressed(KeyJump
, KeyJump2
) then plr
.PressKey(KEY_JUMP
, time
);
1556 if isKeyPressed(KeyUp
, KeyUp2
) then plr
.PressKey(KEY_UP
, time
);
1557 if isKeyPressed(KeyDown
, KeyDown2
) then plr
.PressKey(KEY_DOWN
, time
);
1558 if isKeyPressed(KeyFire
, KeyFire2
) then plr
.PressKey(KEY_FIRE
);
1559 if isKeyPressed(KeyNextWeapon
, KeyNextWeapon2
) then plr
.PressKey(KEY_NEXTWEAPON
);
1560 if isKeyPressed(KeyPrevWeapon
, KeyPrevWeapon2
) then plr
.PressKey(KEY_PREVWEAPON
);
1561 if isKeyPressed(KeyOpen
, KeyOpen2
) then plr
.PressKey(KEY_OPEN
);
1563 for i
:= 0 to High(KeyWeapon
) do
1564 if isKeyPressed(KeyWeapon
[i
], KeyWeapon2
[i
]) then
1565 plr
.QueueWeaponSwitch(i
); // all choices are passed there, and god will take the best
1568 // HACK: add dynlight here
1569 if gwin_k8_enable_light_experiments
then
1571 if e_KeyPressed(IK_F8
) and gGameOn
and (not gConsoleShow
) and (g_ActiveWindow
= nil) then
1573 g_playerLight
:= true;
1575 if e_KeyPressed(IK_F9
) and gGameOn
and (not gConsoleShow
) and (g_ActiveWindow
= nil) then
1577 g_playerLight
:= false;
1581 if gwin_has_stencil
and g_playerLight
then g_AddDynLight(plr
.GameX
+32, plr
.GameY
+40, 128, 1, 1, 0, 0.6);
1584 procedure g_Game_Update();
1586 Msg
: g_gui
.TMessage
;
1592 function sendMonsPos (mon
: TMonster
): Boolean;
1594 result
:= false; // don't stop
1595 // this will also reset "need-send" flag
1596 if mon
.gncNeedSend
then
1598 MH_SEND_MonsterPos(mon
.UID
);
1600 else if (mon
.MonsterType
= MONSTER_BARREL
) then
1602 if (mon
.GameVelX
<> 0) or (mon
.GameVelY
<> 0) then MH_SEND_MonsterPos(mon
.UID
);
1604 else if (mon
.MonsterState
<> MONSTATE_SLEEP
) then
1606 if (mon
.MonsterState
<> MONSTATE_DEAD
) or (mon
.GameVelX
<> 0) or (mon
.GameVelY
<> 0) then MH_SEND_MonsterPos(mon
.UID
);
1610 function sendMonsPosUnexpected (mon
: TMonster
): Boolean;
1612 result
:= false; // don't stop
1613 // this will also reset "need-send" flag
1614 if mon
.gncNeedSend
then MH_SEND_MonsterPos(mon
.UID
);
1618 reliableUpdate
: Boolean;
1623 // Ïîðà âûêëþ÷àòü èãðó:
1624 if gExit
= EXIT_QUIT
then
1626 // Èãðà çàêîí÷èëàñü - îáðàáàòûâàåì:
1630 if gExit
= EXIT_QUIT
then
1634 // ×èòàåì êëàâèàòóðó è äæîéñòèê, åñëè îêíî àêòèâíî
1635 // no need to, as we'll do it in event handler
1637 // Îáíîâëÿåì êîíñîëü (äâèæåíèå è ñîîáùåíèÿ):
1640 if (NetMode
= NET_NONE
) and (g_Game_IsNet
) and (gGameOn
or (gState
in [STATE_FOLD
, STATE_INTERCUSTOM
])) then
1642 gExit
:= EXIT_SIMPLE
;
1648 STATE_INTERSINGLE
, // Ñòàòèñòêà ïîñëå ïðîõîæäåíèÿ óðîâíÿ â Îäèíî÷íîé èãðå
1649 STATE_INTERCUSTOM
, // Ñòàòèñòêà ïîñëå ïðîõîæäåíèÿ óðîâíÿ â Ñâîåé èãðå
1650 STATE_INTERTEXT
, // Òåêñò ìåæäó óðîâíÿìè
1651 STATE_INTERPIC
: // Êàðòèíêà ìåæäó óðîâíÿìè
1653 if g_Game_IsNet
and g_Game_IsServer
then
1655 gInterTime
:= gInterTime
+ GAME_TICK
;
1656 a
:= Min((gInterEndTime
- gInterTime
) div 1000 + 1, 255);
1657 if a
<> gServInterTime
then
1659 gServInterTime
:= a
;
1660 MH_SEND_TimeSync(gServInterTime
);
1664 if (not g_Game_IsClient
) and
1668 e_KeyPressed(IK_RETURN
) or e_KeyPressed(IK_KPRETURN
) or e_KeyPressed(IK_SPACE
) or
1669 e_KeyPressed(VK_FIRE
) or e_KeyPressed(VK_OPEN
)
1671 and (not gJustChatted
) and (not gConsoleShow
) and (not gChatShow
)
1672 and (g_ActiveWindow
= nil)
1674 or (g_Game_IsNet
and (gInterTime
> gInterEndTime
))
1677 begin // Íàæàëè <Enter>/<Ïðîáåë> èëè ïðîøëî äîñòàòî÷íî âðåìåíè:
1678 g_Game_StopAllSounds(True);
1680 if gMapOnce
then // Ýòî áûë òåñò
1681 gExit
:= EXIT_SIMPLE
1683 if gNextMap
<> '' then // Ïåðåõîäèì íà ñëåäóþùóþ êàðòó
1684 g_Game_ChangeMap(gNextMap
)
1685 else // Ñëåäóþùåé êàðòû íåò
1687 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
] then
1689 // Âûõîä â ãëàâíîå ìåíþ:
1691 g_GUI_ShowWindow('MainMenu');
1692 gMusic
.SetByName('MUSIC_MENU');
1694 gState
:= STATE_MENU
;
1697 // Ôèíàëüíàÿ êàðòèíêà:
1698 g_Game_ExecuteEvent('onwadend');
1700 if not gMusic
.SetByName('MUSIC_endmus') then
1701 gMusic
.SetByName('MUSIC_STDENDMUS');
1703 gState
:= STATE_ENDPIC
;
1705 g_Game_ExecuteEvent('ongameend');
1711 if gState
= STATE_INTERTEXT
then
1712 if InterText
.counter
> 0 then
1713 InterText
.counter
:= InterText
.counter
- 1;
1716 STATE_FOLD
: // Çàòóõàíèå ýêðàíà
1718 if EndingGameCounter
= 0 then
1720 // Çàêîí÷èëñÿ óðîâåíü â Ñâîåé èãðå:
1721 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
1723 if gLastMap
and (gGameSettings
.GameMode
= GM_COOP
) then
1725 g_Game_ExecuteEvent('onwadend');
1726 if not gMusic
.SetByName('MUSIC_endmus') then
1727 gMusic
.SetByName('MUSIC_STDENDMUS');
1730 gMusic
.SetByName('MUSIC_ROUNDMUS');
1733 gState
:= STATE_INTERCUSTOM
;
1736 else // Çàêîí÷èëàñü ïîñëåäíÿÿ êàðòà â Îäèíî÷íîé èãðå
1738 gMusic
.SetByName('MUSIC_INTERMUS');
1740 gState
:= STATE_INTERSINGLE
;
1743 g_Game_ExecuteEvent('oninter');
1746 DecMin(EndingGameCounter
, 6, 0);
1749 STATE_ENDPIC
: // Êàðòèíêà îêîí÷àíèÿ ìåãàÂàäà
1751 if gMapOnce
then // Ýòî áûë òåñò
1753 gExit
:= EXIT_SIMPLE
;
1759 g_Serverlist_Control(slCurrent
, slTable
);
1762 if g_Game_IsNet
then
1763 if not gConsoleShow
then
1764 if not gChatShow
then
1766 if g_ActiveWindow
= nil then
1768 if e_KeyPressed(gGameControls
.GameControls
.Chat
) or e_KeyPressed(VK_CHAT
) then
1769 g_Console_Chat_Switch(False)
1770 else if (e_KeyPressed(gGameControls
.GameControls
.TeamChat
) or e_KeyPressed(VK_TEAM
)) and
1771 (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
1772 g_Console_Chat_Switch(True);
1775 if not gChatEnter
then
1776 if (not e_KeyPressed(gGameControls
.GameControls
.Chat
))
1777 and (not e_KeyPressed(gGameControls
.GameControls
.TeamChat
))
1778 and (not e_KeyPressed(VK_CHAT
))
1779 and (not e_KeyPressed(VK_TEAM
)) then
1782 // Ñòàòèñòèêà ïî Tab:
1784 IsDrawStat
:= (not gConsoleShow
) and (not gChatShow
) and
1785 (gGameSettings
.GameType
<> GT_SINGLE
) and
1786 (e_KeyPressed(gGameControls
.GameControls
.Stat
) or e_KeyPressed(VK_STATUS
));
1789 if gGameOn
and not gPause
and (gState
<> STATE_FOLD
) then
1791 // Âðåìÿ += 28 ìèëëèñåêóíä:
1792 gTime
:= gTime
+ GAME_TICK
;
1794 // Ñîîáùåíèå ïîñåðåäèíå ýêðàíà:
1795 if MessageTime
= 0 then
1797 if MessageTime
> 0 then
1798 MessageTime
:= MessageTime
- 1;
1800 if (g_Game_IsServer
) then
1802 // Áûë çàäàí ëèìèò âðåìåíè:
1803 if (gGameSettings
.TimeLimit
> 0) then
1804 if (gTime
- gGameStartTime
) div 1000 >= gGameSettings
.TimeLimit
then
1805 begin // Îí ïðîøåë => êîíåö óðîâíÿ
1810 // Íàäî ðåñïàâíèòü èãðîêîâ â LMS:
1811 if (gLMSRespawn
> LMS_RESPAWN_NONE
) and (gLMSRespawnTime
< gTime
) then
1812 g_Game_RestartRound(gLMSSoftSpawn
);
1814 // Ïðîâåðèì ðåçóëüòàò ãîëîñîâàíèÿ, åñëè âðåìÿ ïðîøëî
1815 if gVoteInProgress
and (gVoteTimer
< gTime
) then
1817 else if gVotePassed
and (gVoteCmdTimer
< gTime
) then
1819 g_Console_Process(gVoteCommand
);
1821 gVotePassed
:= False;
1824 // Çàìåðÿåì âðåìÿ çàõâàòà ôëàãîâ
1825 if gFlags
[FLAG_RED
].State
= FLAG_STATE_CAPTURED
then
1826 gFlags
[FLAG_RED
].CaptureTime
:= gFlags
[FLAG_RED
].CaptureTime
+ GAME_TICK
;
1827 if gFlags
[FLAG_BLUE
].State
= FLAG_STATE_CAPTURED
then
1828 gFlags
[FLAG_BLUE
].CaptureTime
:= gFlags
[FLAG_BLUE
].CaptureTime
+ GAME_TICK
;
1830 // Áûë çàäàí ëèìèò ïîáåä:
1831 if (gGameSettings
.GoalLimit
> 0) then
1835 if gGameSettings
.GameMode
= GM_DM
then
1836 begin // Â DM èùåì èãðîêà ñ max ôðàãàìè
1837 for i
:= 0 to High(gPlayers
) do
1838 if gPlayers
[i
] <> nil then
1839 if gPlayers
[i
].Frags
> b
then
1840 b
:= gPlayers
[i
].Frags
;
1843 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
1844 begin //  CTF/TDM âûáèðàåì êîìàíäó ñ íàèáîëüøèì ñ÷åòîì
1845 b
:= Max(gTeamStat
[TEAM_RED
].Goals
, gTeamStat
[TEAM_BLUE
].Goals
);
1848 // Ëèìèò ïîáåä íàáðàí => êîíåö óðîâíÿ:
1849 if b
>= gGameSettings
.GoalLimit
then
1856 // Îáðàáàòûâàåì êëàâèøè èãðîêîâ:
1857 if gPlayer1
<> nil then gPlayer1
.ReleaseKeys();
1858 if gPlayer2
<> nil then gPlayer2
.ReleaseKeys();
1859 if (not gConsoleShow
) and (not gChatShow
) and (g_ActiveWindow
= nil) then
1861 processPlayerControls(gPlayer1
, gGameControls
.P1Control
, P1MoveButton
);
1862 processPlayerControls(gPlayer2
, gGameControls
.P2Control
, P2MoveButton
, true);
1863 end // if not console
1866 if g_Game_IsNet
and (gPlayer1
<> nil) then gPlayer1
.PressKey(KEY_CHAT
, 10000);
1868 // process weapon switch queue
1872 if (gPlayer1
= nil) and (gPlayer2
= nil) and
1873 (not gConsoleShow
) and (not gChatShow
) and (g_ActiveWindow
= nil) then
1875 if not gSpectKeyPress
then
1877 if isKeyPressed(gGameControls
.P1Control
.KeyJump
, gGameControls
.P1Control
.KeyJump2
)
1878 and (not gSpectAuto
) then
1880 // switch spect mode
1882 SPECT_NONE
: ; // not spectator
1884 SPECT_MAPVIEW
: Inc(gSpectMode
);
1885 SPECT_PLAYERS
: gSpectMode
:= SPECT_STATS
; // reset to 1
1887 gSpectKeyPress
:= True;
1889 if (gSpectMode
= SPECT_MAPVIEW
)
1890 and (not gSpectAuto
) then
1892 if isKeyPressed(gGameControls
.P1Control
.KeyLeft
, gGameControls
.P1Control
.KeyLeft2
) then
1893 gSpectX
:= Max(gSpectX
- gSpectStep
, 0);
1894 if isKeyPressed(gGameControls
.P1Control
.KeyRight
, gGameControls
.P1Control
.KeyRight2
) then
1895 gSpectX
:= Min(gSpectX
+ gSpectStep
, gMapInfo
.Width
- gScreenWidth
);
1896 if isKeyPressed(gGameControls
.P1Control
.KeyUp
, gGameControls
.P1Control
.KeyUp2
) then
1897 gSpectY
:= Max(gSpectY
- gSpectStep
, 0);
1898 if isKeyPressed(gGameControls
.P1Control
.KeyDown
, gGameControls
.P1Control
.KeyDown2
) then
1899 gSpectY
:= Min(gSpectY
+ gSpectStep
, gMapInfo
.Height
- gScreenHeight
);
1900 if isKeyPressed(gGameControls
.P1Control
.KeyPrevWeapon
, gGameControls
.P1Control
.KeyPrevWeapon2
) then
1903 if gSpectStep
> 4 then gSpectStep
:= gSpectStep
shr 1;
1904 gSpectKeyPress
:= True;
1906 if isKeyPressed(gGameControls
.P1Control
.KeyNextWeapon
, gGameControls
.P1Control
.KeyNextWeapon2
) then
1909 if gSpectStep
< 64 then gSpectStep
:= gSpectStep
shl 1;
1910 gSpectKeyPress
:= True;
1913 if (gSpectMode
= SPECT_PLAYERS
)
1914 and (not gSpectAuto
) then
1916 if isKeyPressed(gGameControls
.P1Control
.KeyUp
, gGameControls
.P1Control
.KeyUp2
) then
1919 gSpectViewTwo
:= True;
1920 gSpectKeyPress
:= True;
1922 if isKeyPressed(gGameControls
.P1Control
.KeyDown
, gGameControls
.P1Control
.KeyDown2
) then
1924 // remove second view
1925 gSpectViewTwo
:= False;
1926 gSpectKeyPress
:= True;
1928 if isKeyPressed(gGameControls
.P1Control
.KeyLeft
, gGameControls
.P1Control
.KeyLeft2
) then
1930 // prev player (view 1)
1931 gSpectPID1
:= GetActivePlayerID_Prev(gSpectPID1
);
1932 gSpectKeyPress
:= True;
1934 if isKeyPressed(gGameControls
.P1Control
.KeyRight
, gGameControls
.P1Control
.KeyRight2
) then
1936 // next player (view 1)
1937 gSpectPID1
:= GetActivePlayerID_Next(gSpectPID1
);
1938 gSpectKeyPress
:= True;
1940 if isKeyPressed(gGameControls
.P1Control
.KeyPrevWeapon
, gGameControls
.P1Control
.KeyPrevWeapon2
) then
1942 // prev player (view 2)
1943 gSpectPID2
:= GetActivePlayerID_Prev(gSpectPID2
);
1944 gSpectKeyPress
:= True;
1946 if isKeyPressed(gGameControls
.P1Control
.KeyNextWeapon
, gGameControls
.P1Control
.KeyNextWeapon2
) then
1948 // next player (view 2)
1949 gSpectPID2
:= GetActivePlayerID_Next(gSpectPID2
);
1950 gSpectKeyPress
:= True;
1953 if isKeyPressed(gGameControls
.P1Control
.KeyFire
, gGameControls
.P1Control
.KeyFire2
) then
1955 if (gSpectMode
= SPECT_STATS
) and (not gSpectAuto
) then
1958 gSpectAutoNext
:= 0;
1959 gSpectViewTwo
:= False;
1960 gSpectKeyPress
:= True;
1965 gSpectMode
:= SPECT_STATS
;
1966 gSpectAuto
:= False;
1967 gSpectKeyPress
:= True;
1972 if (not isKeyPressed(gGameControls
.P1Control
.KeyJump
, gGameControls
.P1Control
.KeyJump2
)) and
1973 (not isKeyPressed(gGameControls
.P1Control
.KeyFire
, gGameControls
.P1Control
.KeyFire2
)) and
1974 (not isKeyPressed(gGameControls
.P1Control
.KeyLeft
, gGameControls
.P1Control
.KeyLeft2
)) and
1975 (not isKeyPressed(gGameControls
.P1Control
.KeyRight
, gGameControls
.P1Control
.KeyRight2
)) and
1976 (not isKeyPressed(gGameControls
.P1Control
.KeyUp
, gGameControls
.P1Control
.KeyUp2
)) and
1977 (not isKeyPressed(gGameControls
.P1Control
.KeyDown
, gGameControls
.P1Control
.KeyDown2
)) and
1978 (not isKeyPressed(gGameControls
.P1Control
.KeyPrevWeapon
, gGameControls
.P1Control
.KeyPrevWeapon2
)) and
1979 (not isKeyPressed(gGameControls
.P1Control
.KeyNextWeapon
, gGameControls
.P1Control
.KeyNextWeapon2
)) then
1980 gSpectKeyPress
:= False;
1984 if gSpectMode
= SPECT_MAPVIEW
then
1986 i
:= Min(Max(gSpectX
+ gSpectAutoStepX
, 0), gMapInfo
.Width
- gScreenWidth
);
1988 gSpectAutoNext
:= gTime
1991 i
:= Min(Max(gSpectY
+ gSpectAutoStepY
, 0), gMapInfo
.Height
- gScreenHeight
);
1993 gSpectAutoNext
:= gTime
1997 if gSpectAutoNext
<= gTime
then
1999 if gSpectAutoNext
> 0 then
2001 gSpectMode
:= GetRandomSpectMode(gSpectMode
);
2005 gSpectX
:= Random(gMapInfo
.Width
- gScreenWidth
);
2006 gSpectY
:= Random(gMapInfo
.Height
- gScreenHeight
);
2007 gSpectAutoStepX
:= Random(9) - 4;
2008 gSpectAutoStepY
:= Random(9) - 4;
2009 if ((gSpectX
< 800) and (gSpectAutoStepX
< 0)) or
2010 ((gSpectX
> gMapInfo
.Width
- gScreenWidth
- 800) and (gSpectAutoStepX
> 0)) then
2011 gSpectAutoStepX
:= gSpectAutoStepX
* -1;
2012 if ((gSpectY
< 800) and (gSpectAutoStepY
< 0)) or
2013 ((gSpectY
> gMapInfo
.Height
- gScreenHeight
- 800) and (gSpectAutoStepY
> 0)) then
2014 gSpectAutoStepY
:= gSpectAutoStepY
* -1;
2018 gSpectPID1
:= GetActivePlayerID_Random(gSpectPID1
);
2023 SPECT_STATS
: gSpectAutoNext
:= gTime
+ (Random(3) + 5) * 1000;
2024 SPECT_MAPVIEW
: gSpectAutoNext
:= gTime
+ (Random(4) + 7) * 1000;
2025 SPECT_PLAYERS
: gSpectAutoNext
:= gTime
+ (Random(7) + 8) * 1000;
2031 // Îáíîâëÿåì âñå îñòàëüíîå:
2034 g_Triggers_Update();
2036 g_Monsters_Update();
2038 g_Player_UpdateAll();
2039 g_Player_UpdatePhysicalObjects();
2041 // server: send newly spawned monsters unconditionally
2042 if (gGameSettings
.GameType
= GT_SERVER
) then
2044 if (Length(gMonstersSpawned
) > 0) then
2046 for I
:= 0 to High(gMonstersSpawned
) do MH_SEND_MonsterSpawn(gMonstersSpawned
[I
]);
2047 SetLength(gMonstersSpawned
, 0);
2051 if (gSoundTriggerTime
> 8) then
2053 g_Game_UpdateTriggerSounds();
2054 gSoundTriggerTime
:= 0;
2058 Inc(gSoundTriggerTime
);
2061 if (NetMode
= NET_SERVER
) then
2063 Inc(NetTimeToUpdate
);
2064 Inc(NetTimeToReliable
);
2066 // send monster updates
2067 if (NetTimeToReliable
>= NetRelupdRate
) or (NetTimeToUpdate
>= NetUpdateRate
) then
2069 // send all monsters (periodic sync)
2070 reliableUpdate
:= (NetTimeToReliable
>= NetRelupdRate
);
2072 for I
:= 0 to High(gPlayers
) do
2074 if (gPlayers
[I
] <> nil) then MH_SEND_PlayerPos(reliableUpdate
, gPlayers
[I
].UID
);
2077 g_Mons_ForEach(sendMonsPos
);
2079 if reliableUpdate
then
2081 NetTimeToReliable
:= 0;
2082 NetTimeToUpdate
:= NetUpdateRate
;
2086 NetTimeToUpdate
:= 0;
2091 // send only mosters with some unexpected changes
2092 g_Mons_ForEach(sendMonsPosUnexpected
);
2095 // send unexpected platform changes
2096 g_Map_NetSendInterestingPanels();
2098 if NetUseMaster
then
2100 if gTime
>= NetTimeToMaster
then
2102 if (NetMHost
= nil) or (NetMPeer
= nil) then
2104 if not g_Net_Slist_Connect
then g_Console_Add(_lc
[I_NET_MSG_ERROR
] + _lc
[I_NET_SLIST_ERROR
]);
2108 NetTimeToMaster
:= gTime
+ NetMasterRate
;
2112 else if (NetMode
= NET_CLIENT
) then
2114 MC_SEND_PlayerPos();
2116 end; // if gameOn ...
2118 // Àêòèâíî îêíî èíòåðôåéñà - ïåðåäàåì êëàâèøè åìó:
2119 if g_ActiveWindow
<> nil then
2121 w
:= e_GetFirstKeyPressed();
2123 if (w
<> IK_INVALID
) then
2125 Msg
.Msg
:= MESSAGE_DIKEY
;
2127 g_ActiveWindow
.OnMessage(Msg
);
2130 // Åñëè îíî îò ýòîãî íå çàêðûëîñü, òî îáíîâëÿåì:
2131 if g_ActiveWindow
<> nil then
2132 g_ActiveWindow
.Update();
2134 // Íóæíî ñìåíèòü ðàçðåøåíèå:
2135 if gResolutionChange
then
2137 e_WriteLog('Changing resolution', TMsgType
.Notify
);
2138 g_Game_ChangeResolution(gRC_Width
, gRC_Height
, gRC_FullScreen
, gRC_Maximized
);
2139 gResolutionChange
:= False;
2140 g_ActiveWindow
:= nil;
2143 // Íóæíî ñìåíèòü ÿçûê:
2144 if gLanguageChange
then
2146 //e_WriteLog('Read language file', MSG_NOTIFY);
2147 //g_Language_Load(DataDir + gLanguage + '.txt');
2148 g_Language_Set(gLanguage
);
2150 gLanguageChange
:= False;
2154 // Äåëàåì ñêðèíøîò (íå ÷àùå 200 ìèëëèñåêóíä):
2155 if e_KeyPressed(gGameControls
.GameControls
.TakeScreenshot
) or e_KeyPressed(VK_PRINTSCR
) then
2156 if (GetTimer()-LastScreenShot
) > 200000 div 1000 then
2159 LastScreenShot
:= GetTimer();
2162 // Ãîðÿ÷àÿ êëàâèøà äëÿ âûçîâà ìåíþ âûõîäà èç èãðû (F10):
2163 if e_KeyPressed(IK_F10
) and
2165 (not gConsoleShow
) and
2166 (g_ActiveWindow
= nil) then
2171 Time
:= GetTimer() {div 1000};
2173 // Îáðàáîòêà îòëîæåííûõ ñîáûòèé:
2174 if gDelayedEvents
<> nil then
2175 for a
:= 0 to High(gDelayedEvents
) do
2176 if gDelayedEvents
[a
].Pending
and
2178 ((gDelayedEvents
[a
].DEType
= DE_GLOBEVENT
) and (gDelayedEvents
[a
].Time
<= Time
)) or
2179 ((gDelayedEvents
[a
].DEType
> DE_GLOBEVENT
) and (gDelayedEvents
[a
].Time
<= gTime
))
2182 case gDelayedEvents
[a
].DEType
of
2184 g_Game_ExecuteEvent(gDelayedEvents
[a
].DEStr
);
2187 g_Game_Announce_GoodShot(gDelayedEvents
[a
].DENum
);
2191 g_Game_Announce_KillCombo(gDelayedEvents
[a
].DENum
);
2192 if g_Game_IsNet
and g_Game_IsServer
then
2193 MH_SEND_GameEvent(NET_EV_KILLCOMBO
, gDelayedEvents
[a
].DENum
);
2197 g_Game_Announce_BodyKill(gDelayedEvents
[a
].DENum
);
2199 gDelayedEvents
[a
].Pending
:= False;
2202 // Êàæäóþ ñåêóíäó îáíîâëÿåì ñ÷åò÷èê îáíîâëåíèé:
2203 UPSCounter
:= UPSCounter
+ 1;
2204 if Time
- UPSTime
>= 1000 then
2213 g_Weapon_AddDynLights();
2214 g_Items_AddDynLights();
2218 procedure g_Game_LoadChatSounds(Resource
: string);
2221 FileName
, Snd
: string;
2223 len
, cnt
, tags
, i
, j
: Integer;
2226 FileName
:= g_ExtractWadName(Resource
);
2228 WAD
:= TWADFile
.Create();
2229 WAD
.ReadFile(FileName
);
2231 if not WAD
.GetResource(g_ExtractFilePathName(Resource
), p
, len
) then
2238 cfg
:= TConfig
.CreateMem(p
, len
);
2239 cnt
:= cfg
.ReadInt('ChatSounds', 'Count', 0);
2241 SetLength(gChatSounds
, cnt
);
2242 for i
:= 0 to Length(gChatSounds
) - 1 do
2244 gChatSounds
[i
].Sound
:= nil;
2245 Snd
:= Trim(cfg
.ReadStr(IntToStr(i
), 'Sound', ''));
2246 tags
:= cfg
.ReadInt(IntToStr(i
), 'Tags', 0);
2247 if (Snd
= '') or (Tags
<= 0) then
2249 g_Sound_CreateWADEx('SOUND_CHAT_MACRO' + IntToStr(i
), GameWAD
+':'+Snd
);
2250 gChatSounds
[i
].Sound
:= TPlayableSound
.Create();
2251 gChatSounds
[i
].Sound
.SetByName('SOUND_CHAT_MACRO' + IntToStr(i
));
2252 SetLength(gChatSounds
[i
].Tags
, tags
);
2253 for j
:= 0 to tags
- 1 do
2254 gChatSounds
[i
].Tags
[j
] := toLowerCase1251(cfg
.ReadStr(IntToStr(i
), 'Tag' + IntToStr(j
), ''));
2255 gChatSounds
[i
].FullWord
:= cfg
.ReadBool(IntToStr(i
), 'FullWord', False);
2262 procedure g_Game_FreeChatSounds();
2266 for i
:= 0 to Length(gChatSounds
) - 1 do
2268 gChatSounds
[i
].Sound
.Free();
2269 g_Sound_Delete('SOUND_CHAT_MACRO' + IntToStr(i
));
2271 SetLength(gChatSounds
, 0);
2275 procedure g_Game_LoadData();
2282 if DataLoaded
then Exit
;
2284 e_WriteLog('Loading game data...', TMsgType
.Notify
);
2286 g_Texture_CreateWADEx('NOTEXTURE', GameWAD
+':TEXTURES\NOTEXTURE');
2287 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUD', GameWAD
+':TEXTURES\HUD');
2288 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDAIR', GameWAD
+':TEXTURES\AIRBAR');
2289 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDJET', GameWAD
+':TEXTURES\JETBAR');
2290 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDBG', GameWAD
+':TEXTURES\HUDBG');
2291 g_Texture_CreateWADEx('TEXTURE_PLAYER_ARMORHUD', GameWAD
+':TEXTURES\ARMORHUD');
2292 g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG', GameWAD
+':TEXTURES\FLAGHUD_R_BASE');
2293 g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG_S', GameWAD
+':TEXTURES\FLAGHUD_R_STOLEN');
2294 g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG_D', GameWAD
+':TEXTURES\FLAGHUD_R_DROP');
2295 g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG', GameWAD
+':TEXTURES\FLAGHUD_B_BASE');
2296 g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG_S', GameWAD
+':TEXTURES\FLAGHUD_B_STOLEN');
2297 g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG_D', GameWAD
+':TEXTURES\FLAGHUD_B_DROP');
2298 g_Texture_CreateWADEx('TEXTURE_PLAYER_TALKBUBBLE', GameWAD
+':TEXTURES\TALKBUBBLE');
2299 g_Texture_CreateWADEx('TEXTURE_PLAYER_INVULPENTA', GameWAD
+':TEXTURES\PENTA');
2300 g_Texture_CreateWADEx('TEXTURE_PLAYER_INDICATOR', GameWAD
+':TEXTURES\PLRIND');
2303 if not g_Texture_CreateWADEx('UI_GFX_PBAR_LEFT', GameWAD
+':TEXTURES\LLEFT') then hasPBarGfx
:= false;
2304 if not g_Texture_CreateWADEx('UI_GFX_PBAR_MARKER', GameWAD
+':TEXTURES\LMARKER') then hasPBarGfx
:= false;
2305 if not g_Texture_CreateWADEx('UI_GFX_PBAR_MIDDLE', GameWAD
+':TEXTURES\LMIDDLE') then hasPBarGfx
:= false;
2306 if not g_Texture_CreateWADEx('UI_GFX_PBAR_RIGHT', GameWAD
+':TEXTURES\LRIGHT') then hasPBarGfx
:= false;
2310 g_Texture_GetSize('UI_GFX_PBAR_LEFT', wl
, hl
);
2311 g_Texture_GetSize('UI_GFX_PBAR_RIGHT', wr
, hr
);
2312 g_Texture_GetSize('UI_GFX_PBAR_MIDDLE', wb
, hb
);
2313 g_Texture_GetSize('UI_GFX_PBAR_MARKER', wm
, hm
);
2314 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
2320 hasPBarGfx
:= false;
2324 g_Frames_CreateWAD(nil, 'FRAMES_TELEPORT', GameWAD
+':TEXTURES\TELEPORT', 64, 64, 10, False);
2325 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH', GameWAD
+':WEAPONS\PUNCH', 64, 64, 4, False);
2326 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_UP', GameWAD
+':WEAPONS\PUNCH_UP', 64, 64, 4, False);
2327 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_DN', GameWAD
+':WEAPONS\PUNCH_DN', 64, 64, 4, False);
2328 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_BERSERK', GameWAD
+':WEAPONS\PUNCHB', 64, 64, 4, False);
2329 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_BERSERK_UP', GameWAD
+':WEAPONS\PUNCHB_UP', 64, 64, 4, False);
2330 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_BERSERK_DN', GameWAD
+':WEAPONS\PUNCHB_DN', 64, 64, 4, False);
2331 g_Sound_CreateWADEx('SOUND_GAME_TELEPORT', GameWAD
+':SOUNDS\TELEPORT');
2332 g_Sound_CreateWADEx('SOUND_GAME_NOTELEPORT', GameWAD
+':SOUNDS\NOTELEPORT');
2333 g_Sound_CreateWADEx('SOUND_GAME_DOOROPEN', GameWAD
+':SOUNDS\DOOROPEN');
2334 g_Sound_CreateWADEx('SOUND_GAME_DOORCLOSE', GameWAD
+':SOUNDS\DOORCLOSE');
2335 g_Sound_CreateWADEx('SOUND_GAME_BULK1', GameWAD
+':SOUNDS\BULK1');
2336 g_Sound_CreateWADEx('SOUND_GAME_BULK2', GameWAD
+':SOUNDS\BULK2');
2337 g_Sound_CreateWADEx('SOUND_GAME_BUBBLE1', GameWAD
+':SOUNDS\BUBBLE1');
2338 g_Sound_CreateWADEx('SOUND_GAME_BUBBLE2', GameWAD
+':SOUNDS\BUBBLE2');
2339 g_Sound_CreateWADEx('SOUND_GAME_BURNING', GameWAD
+':SOUNDS\BURNING');
2340 g_Sound_CreateWADEx('SOUND_GAME_SWITCH1', GameWAD
+':SOUNDS\SWITCH1');
2341 g_Sound_CreateWADEx('SOUND_GAME_SWITCH0', GameWAD
+':SOUNDS\SWITCH0');
2342 g_Sound_CreateWADEx('SOUND_GAME_RADIO', GameWAD
+':SOUNDS\RADIO');
2343 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD1', GameWAD
+':SOUNDS\GOOD1');
2344 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD2', GameWAD
+':SOUNDS\GOOD2');
2345 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD3', GameWAD
+':SOUNDS\GOOD3');
2346 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD4', GameWAD
+':SOUNDS\GOOD4');
2347 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL2X', GameWAD
+':SOUNDS\KILL2X');
2348 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL3X', GameWAD
+':SOUNDS\KILL3X');
2349 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL4X', GameWAD
+':SOUNDS\KILL4X');
2350 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILLMX', GameWAD
+':SOUNDS\KILLMX');
2351 g_Sound_CreateWADEx('SOUND_ANNOUNCER_MUHAHA1', GameWAD
+':SOUNDS\MUHAHA1');
2352 g_Sound_CreateWADEx('SOUND_ANNOUNCER_MUHAHA2', GameWAD
+':SOUNDS\MUHAHA2');
2353 g_Sound_CreateWADEx('SOUND_ANNOUNCER_MUHAHA3', GameWAD
+':SOUNDS\MUHAHA3');
2354 g_Sound_CreateWADEx('SOUND_CTF_GET1', GameWAD
+':SOUNDS\GETFLAG1');
2355 g_Sound_CreateWADEx('SOUND_CTF_GET2', GameWAD
+':SOUNDS\GETFLAG2');
2356 g_Sound_CreateWADEx('SOUND_CTF_LOST1', GameWAD
+':SOUNDS\LOSTFLG1');
2357 g_Sound_CreateWADEx('SOUND_CTF_LOST2', GameWAD
+':SOUNDS\LOSTFLG2');
2358 g_Sound_CreateWADEx('SOUND_CTF_RETURN1', GameWAD
+':SOUNDS\RETFLAG1');
2359 g_Sound_CreateWADEx('SOUND_CTF_RETURN2', GameWAD
+':SOUNDS\RETFLAG2');
2360 g_Sound_CreateWADEx('SOUND_CTF_CAPTURE1', GameWAD
+':SOUNDS\CAPFLAG1');
2361 g_Sound_CreateWADEx('SOUND_CTF_CAPTURE2', GameWAD
+':SOUNDS\CAPFLAG2');
2363 goodsnd
[0] := TPlayableSound
.Create();
2364 goodsnd
[1] := TPlayableSound
.Create();
2365 goodsnd
[2] := TPlayableSound
.Create();
2366 goodsnd
[3] := TPlayableSound
.Create();
2368 goodsnd
[0].SetByName('SOUND_ANNOUNCER_GOOD1');
2369 goodsnd
[1].SetByName('SOUND_ANNOUNCER_GOOD2');
2370 goodsnd
[2].SetByName('SOUND_ANNOUNCER_GOOD3');
2371 goodsnd
[3].SetByName('SOUND_ANNOUNCER_GOOD4');
2373 killsnd
[0] := TPlayableSound
.Create();
2374 killsnd
[1] := TPlayableSound
.Create();
2375 killsnd
[2] := TPlayableSound
.Create();
2376 killsnd
[3] := TPlayableSound
.Create();
2378 killsnd
[0].SetByName('SOUND_ANNOUNCER_KILL2X');
2379 killsnd
[1].SetByName('SOUND_ANNOUNCER_KILL3X');
2380 killsnd
[2].SetByName('SOUND_ANNOUNCER_KILL4X');
2381 killsnd
[3].SetByName('SOUND_ANNOUNCER_KILLMX');
2383 hahasnd
[0] := TPlayableSound
.Create();
2384 hahasnd
[1] := TPlayableSound
.Create();
2385 hahasnd
[2] := TPlayableSound
.Create();
2387 hahasnd
[0].SetByName('SOUND_ANNOUNCER_MUHAHA1');
2388 hahasnd
[1].SetByName('SOUND_ANNOUNCER_MUHAHA2');
2389 hahasnd
[2].SetByName('SOUND_ANNOUNCER_MUHAHA3');
2391 sound_get_flag
[0] := TPlayableSound
.Create();
2392 sound_get_flag
[1] := TPlayableSound
.Create();
2393 sound_lost_flag
[0] := TPlayableSound
.Create();
2394 sound_lost_flag
[1] := TPlayableSound
.Create();
2395 sound_ret_flag
[0] := TPlayableSound
.Create();
2396 sound_ret_flag
[1] := TPlayableSound
.Create();
2397 sound_cap_flag
[0] := TPlayableSound
.Create();
2398 sound_cap_flag
[1] := TPlayableSound
.Create();
2400 sound_get_flag
[0].SetByName('SOUND_CTF_GET1');
2401 sound_get_flag
[1].SetByName('SOUND_CTF_GET2');
2402 sound_lost_flag
[0].SetByName('SOUND_CTF_LOST1');
2403 sound_lost_flag
[1].SetByName('SOUND_CTF_LOST2');
2404 sound_ret_flag
[0].SetByName('SOUND_CTF_RETURN1');
2405 sound_ret_flag
[1].SetByName('SOUND_CTF_RETURN2');
2406 sound_cap_flag
[0].SetByName('SOUND_CTF_CAPTURE1');
2407 sound_cap_flag
[1].SetByName('SOUND_CTF_CAPTURE2');
2409 g_Game_LoadChatSounds(GameWAD
+':CHATSND\SNDCFG');
2411 g_Game_SetLoadingText(_lc
[I_LOAD_ITEMS_DATA
], 0, False);
2414 g_Game_SetLoadingText(_lc
[I_LOAD_WEAPONS_DATA
], 0, False);
2415 g_Weapon_LoadData();
2417 g_Monsters_LoadData();
2422 procedure g_Game_FreeData();
2424 if not DataLoaded
then Exit
;
2427 g_Weapon_FreeData();
2428 g_Monsters_FreeData();
2430 e_WriteLog('Releasing game data...', TMsgType
.Notify
);
2432 g_Texture_Delete('NOTEXTURE');
2433 g_Texture_Delete('TEXTURE_PLAYER_HUD');
2434 g_Texture_Delete('TEXTURE_PLAYER_HUDBG');
2435 g_Texture_Delete('TEXTURE_PLAYER_ARMORHUD');
2436 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG');
2437 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG_S');
2438 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG_D');
2439 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG');
2440 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG_S');
2441 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG_D');
2442 g_Texture_Delete('TEXTURE_PLAYER_TALKBUBBLE');
2443 g_Texture_Delete('TEXTURE_PLAYER_INVULPENTA');
2444 g_Frames_DeleteByName('FRAMES_TELEPORT');
2445 g_Frames_DeleteByName('FRAMES_PUNCH');
2446 g_Frames_DeleteByName('FRAMES_PUNCH_UP');
2447 g_Frames_DeleteByName('FRAMES_PUNCH_DN');
2448 g_Frames_DeleteByName('FRAMES_PUNCH_BERSERK');
2449 g_Frames_DeleteByName('FRAMES_PUNCH_BERSERK_UP');
2450 g_Frames_DeleteByName('FRAMES_PUNCH_BERSERK_DN');
2451 g_Sound_Delete('SOUND_GAME_TELEPORT');
2452 g_Sound_Delete('SOUND_GAME_NOTELEPORT');
2453 g_Sound_Delete('SOUND_GAME_DOOROPEN');
2454 g_Sound_Delete('SOUND_GAME_DOORCLOSE');
2455 g_Sound_Delete('SOUND_GAME_BULK1');
2456 g_Sound_Delete('SOUND_GAME_BULK2');
2457 g_Sound_Delete('SOUND_GAME_BUBBLE1');
2458 g_Sound_Delete('SOUND_GAME_BUBBLE2');
2459 g_Sound_Delete('SOUND_GAME_BURNING');
2460 g_Sound_Delete('SOUND_GAME_SWITCH1');
2461 g_Sound_Delete('SOUND_GAME_SWITCH0');
2468 g_Sound_Delete('SOUND_ANNOUNCER_GOOD1');
2469 g_Sound_Delete('SOUND_ANNOUNCER_GOOD2');
2470 g_Sound_Delete('SOUND_ANNOUNCER_GOOD3');
2471 g_Sound_Delete('SOUND_ANNOUNCER_GOOD4');
2478 g_Sound_Delete('SOUND_ANNOUNCER_KILL2X');
2479 g_Sound_Delete('SOUND_ANNOUNCER_KILL3X');
2480 g_Sound_Delete('SOUND_ANNOUNCER_KILL4X');
2481 g_Sound_Delete('SOUND_ANNOUNCER_KILLMX');
2487 g_Sound_Delete('SOUND_ANNOUNCER_MUHAHA1');
2488 g_Sound_Delete('SOUND_ANNOUNCER_MUHAHA2');
2489 g_Sound_Delete('SOUND_ANNOUNCER_MUHAHA3');
2491 sound_get_flag
[0].Free();
2492 sound_get_flag
[1].Free();
2493 sound_lost_flag
[0].Free();
2494 sound_lost_flag
[1].Free();
2495 sound_ret_flag
[0].Free();
2496 sound_ret_flag
[1].Free();
2497 sound_cap_flag
[0].Free();
2498 sound_cap_flag
[1].Free();
2500 g_Sound_Delete('SOUND_CTF_GET1');
2501 g_Sound_Delete('SOUND_CTF_GET2');
2502 g_Sound_Delete('SOUND_CTF_LOST1');
2503 g_Sound_Delete('SOUND_CTF_LOST2');
2504 g_Sound_Delete('SOUND_CTF_RETURN1');
2505 g_Sound_Delete('SOUND_CTF_RETURN2');
2506 g_Sound_Delete('SOUND_CTF_CAPTURE1');
2507 g_Sound_Delete('SOUND_CTF_CAPTURE2');
2509 g_Game_FreeChatSounds();
2511 DataLoaded
:= False;
2514 procedure DrawCustomStat();
2520 ww2
, hh2
, r
, g
, b
, rr
, gg
, bb
: Byte;
2521 s1
, s2
, topstr
: String;
2523 e_TextureFontGetSize(gStdFont
, ww2
, hh2
);
2525 g_ProcessMessages();
2527 if e_KeyPressed(IK_TAB
) or e_KeyPressed(VK_STATUS
) then
2529 if not gStatsPressed
then
2531 gStatsOff
:= not gStatsOff
;
2532 gStatsPressed
:= True;
2536 gStatsPressed
:= False;
2540 s1
:= _lc
[I_MENU_INTER_NOTICE_TAB
];
2541 w
:= (Length(s1
) * ww2
) div 2;
2542 x
:= gScreenWidth
div 2 - w
;
2544 e_TextureFontPrint(x
, y
, s1
, gStdFont
);
2548 if (gGameSettings
.GameMode
= GM_COOP
) then
2550 if gMissionFailed
then
2551 topstr
:= _lc
[I_MENU_INTER_MISSION_FAIL
]
2553 topstr
:= _lc
[I_MENU_INTER_LEVEL_COMPLETE
];
2556 topstr
:= _lc
[I_MENU_INTER_ROUND_OVER
];
2558 e_CharFont_GetSize(gMenuFont
, topstr
, ww1
, hh1
);
2559 e_CharFont_Print(gMenuFont
, (gScreenWidth
div 2)-(ww1
div 2), 16, topstr
);
2561 if g_Game_IsNet
then
2563 topstr
:= Format(_lc
[I_MENU_INTER_NOTICE_TIME
], [gServInterTime
]);
2564 if not gChatShow
then
2565 e_TextureFontPrintEx((gScreenWidth
div 2)-(Length(topstr
)*ww2
div 2),
2566 gScreenHeight
-(hh2
+4)*2, topstr
, gStdFont
, 255, 255, 255, 1);
2569 if g_Game_IsClient
then
2570 topstr
:= _lc
[I_MENU_INTER_NOTICE_MAP
]
2572 topstr
:= _lc
[I_MENU_INTER_NOTICE_SPACE
];
2573 if not gChatShow
then
2574 e_TextureFontPrintEx((gScreenWidth
div 2)-(Length(topstr
)*ww2
div 2),
2575 gScreenHeight
-(hh2
+4), topstr
, gStdFont
, 255, 255, 255, 1);
2580 w
:= gScreenWidth
-x
*2;
2586 e_DrawFillQuad(x
, y
, gScreenWidth
-x
-1, gScreenHeight
-y
-1, 64, 64, 64, 32);
2587 e_DrawQuad(x
, y
, gScreenWidth
-x
-1, gScreenHeight
-y
-1, 255, 127, 0);
2589 m
:= Max(Length(_lc
[I_MENU_MAP
])+1, Length(_lc
[I_GAME_GAME_TIME
])+1)*ww2
;
2591 case CustomStat
.GameMode
of
2594 if gGameSettings
.MaxLives
= 0 then
2595 s1
:= _lc
[I_GAME_DM
]
2597 s1
:= _lc
[I_GAME_LMS
];
2601 if gGameSettings
.MaxLives
= 0 then
2602 s1
:= _lc
[I_GAME_TDM
]
2604 s1
:= _lc
[I_GAME_TLMS
];
2606 GM_CTF
: s1
:= _lc
[I_GAME_CTF
];
2609 if gGameSettings
.MaxLives
= 0 then
2610 s1
:= _lc
[I_GAME_COOP
]
2612 s1
:= _lc
[I_GAME_SURV
];
2618 e_TextureFontPrintEx(x
+(w
div 2)-(Length(s1
)*ww2
div 2), _y
, s1
, gStdFont
, 255, 255, 255, 1);
2622 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_MENU_MAP
], gStdFont
, 255, 127, 0, 1);
2623 e_TextureFontPrint(x
+8+m
, _y
, Format('%s - %s', [CustomStat
.Map
, CustomStat
.MapName
]), gStdFont
);
2626 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_GAME_TIME
], gStdFont
, 255, 127, 0, 1);
2627 e_TextureFontPrint(x
+8+m
, _y
, Format('%d:%.2d:%.2d', [CustomStat
.GameTime
div 1000 div 3600,
2628 (CustomStat
.GameTime
div 1000 div 60) mod 60,
2629 CustomStat
.GameTime
div 1000 mod 60]), gStdFont
);
2631 pc
:= Length(CustomStat
.PlayerStat
);
2632 if pc
= 0 then Exit
;
2634 if CustomStat
.GameMode
= GM_COOP
then
2636 m
:= Max(Length(_lc
[I_GAME_MONSTERS
])+1, Length(_lc
[I_GAME_SECRETS
])+1)*ww2
;
2638 s2
:= _lc
[I_GAME_MONSTERS
];
2639 e_TextureFontPrintEx(x
+8, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2640 e_TextureFontPrintEx(x
+8+m
, _y
, IntToStr(gCoopMonstersKilled
) + '/' + IntToStr(gTotalMonsters
), gStdFont
, 255, 255, 255, 1);
2642 s2
:= _lc
[I_GAME_SECRETS
];
2643 e_TextureFontPrintEx(x
+8, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2644 e_TextureFontPrintEx(x
+8+m
, _y
, IntToStr(gCoopSecretsFound
) + '/' + IntToStr(gSecretsCount
), gStdFont
, 255, 255, 255, 1);
2647 m
:= Max(Length(_lc
[I_GAME_MONSTERS_TOTAL
])+1, Length(_lc
[I_GAME_SECRETS_TOTAL
])+1)*ww2
;
2649 s2
:= _lc
[I_GAME_MONSTERS_TOTAL
];
2650 e_TextureFontPrintEx(x
+250, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2651 e_TextureFontPrintEx(x
+250+m
, _y
, IntToStr(gCoopTotalMonstersKilled
) + '/' + IntToStr(gCoopTotalMonsters
), gStdFont
, 255, 255, 255, 1);
2653 s2
:= _lc
[I_GAME_SECRETS_TOTAL
];
2654 e_TextureFontPrintEx(x
+250, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2655 e_TextureFontPrintEx(x
+250+m
, _y
, IntToStr(gCoopTotalSecretsFound
) + '/' + IntToStr(gCoopTotalSecrets
), gStdFont
, 255, 255, 255, 1);
2659 if CustomStat
.GameMode
in [GM_TDM
, GM_CTF
] then
2664 if TeamStat
[TEAM_RED
].Goals
> TeamStat
[TEAM_BLUE
].Goals
then s1
:= _lc
[I_GAME_WIN_RED
]
2665 else if TeamStat
[TEAM_BLUE
].Goals
> TeamStat
[TEAM_RED
].Goals
then s1
:= _lc
[I_GAME_WIN_BLUE
]
2666 else s1
:= _lc
[I_GAME_WIN_DRAW
];
2668 e_TextureFontPrintEx(x
+8+(w
div 2)-(Length(s1
)*ww2
div 2), _y
, s1
, gStdFont
, 255, 255, 255, 1);
2671 for t
:= TEAM_RED
to TEAM_BLUE
do
2673 if t
= TEAM_RED
then
2675 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_TEAM_RED
],
2676 gStdFont
, 255, 0, 0, 1);
2677 e_TextureFontPrintEx(x
+w1
+8, _y
, IntToStr(CustomStat
.TeamStat
[TEAM_RED
].Goals
),
2678 gStdFont
, 255, 0, 0, 1);
2685 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_TEAM_BLUE
],
2686 gStdFont
, 0, 0, 255, 1);
2687 e_TextureFontPrintEx(x
+w1
+8, _y
, IntToStr(CustomStat
.TeamStat
[TEAM_BLUE
].Goals
),
2688 gStdFont
, 0, 0, 255, 1);
2694 e_DrawLine(1, x
+8, _y
+20, x
-8+w
, _y
+20, r
, g
, b
);
2697 for p
:= 0 to High(CustomStat
.PlayerStat
) do
2698 if CustomStat
.PlayerStat
[p
].Team
= t
then
2699 with CustomStat
.PlayerStat
[p
] do
2713 e_TextureFontPrintEx(x
+8, _y
, Name
, gStdFont
, rr
, gg
, bb
, 1);
2714 e_TextureFontPrintEx(x
+w1
+8, _y
, IntToStr(Frags
), gStdFont
, rr
, gg
, bb
, 1);
2715 e_TextureFontPrintEx(x
+w1
+w2
+8, _y
, IntToStr(Deaths
), gStdFont
, rr
, gg
, bb
, 1);
2722 else if CustomStat
.GameMode
in [GM_DM
, GM_COOP
] then
2725 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_PLAYER_NAME
], gStdFont
, 255, 127, 0, 1);
2726 e_TextureFontPrintEx(x
+8+w1
, _y
, _lc
[I_GAME_FRAGS
], gStdFont
, 255, 127, 0, 1);
2727 e_TextureFontPrintEx(x
+8+w1
+w2
, _y
, _lc
[I_GAME_DEATHS
], gStdFont
, 255, 127, 0, 1);
2730 for p
:= 0 to High(CustomStat
.PlayerStat
) do
2731 with CustomStat
.PlayerStat
[p
] do
2733 e_DrawFillQuad(x
+8, _y
+4, x
+24-1, _y
+16+4-1, Color
.R
, Color
.G
, Color
.B
, 0);
2740 e_TextureFontPrintEx(x
+8+16+8, _y
+4, Name
, gStdFont
, r
, r
, r
, 1, True);
2741 e_TextureFontPrintEx(x
+w1
+8+16+8, _y
+4, IntToStr(Frags
), gStdFont
, r
, r
, r
, 1, True);
2742 e_TextureFontPrintEx(x
+w1
+w2
+8+16+8, _y
+4, IntToStr(Deaths
), gStdFont
, r
, r
, r
, 1, True);
2748 procedure DrawSingleStat();
2750 tm
, key_x
, val_x
, y
: Integer;
2754 procedure player_stat(n
: Integer);
2760 s1
:= Format(' %d ', [SingleStat
.PlayerStat
[n
].Kills
]);
2761 s2
:= Format(' %d', [gTotalMonsters
]);
2763 e_CharFont_Print(gMenuFont
, key_x
, y
, _lc
[I_MENU_INTER_KILLS
]);
2764 e_CharFont_PrintEx(gMenuFont
, val_x
, y
, s1
, _RGB(255, 0, 0));
2765 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2766 e_CharFont_Print(gMenuFont
, val_x
+w1
, y
, '/');
2768 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2769 e_CharFont_PrintEx(gMenuFont
, val_x
+w1
, y
, s2
, _RGB(255, 0, 0));
2771 // "Kills-per-minute: ##.#":
2772 s1
:= _lc
[I_MENU_INTER_KPM
];
2774 kpm
:= (SingleStat
.PlayerStat
[n
].Kills
/ tm
) * 60
2776 kpm
:= SingleStat
.PlayerStat
[n
].Kills
;
2777 s2
:= Format(' %.1f', [kpm
]);
2779 e_CharFont_Print(gMenuFont
, key_x
, y
+32, s1
);
2780 e_CharFont_PrintEx(gMenuFont
, val_x
, y
+32, s2
, _RGB(255, 0, 0));
2782 // "Secrets found: # / #":
2783 s1
:= Format(' %d ', [SingleStat
.PlayerStat
[n
].Secrets
]);
2784 s2
:= Format(' %d', [SingleStat
.TotalSecrets
]);
2786 e_CharFont_Print(gMenuFont
, key_x
, y
+64, _lc
[I_MENU_INTER_SECRETS
]);
2787 e_CharFont_PrintEx(gMenuFont
, val_x
, y
+64, s1
, _RGB(255, 0, 0));
2788 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2789 e_CharFont_Print(gMenuFont
, val_x
+w1
, y
+64, '/');
2791 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2792 e_CharFont_PrintEx(gMenuFont
, val_x
+w1
, y
+64, s2
, _RGB(255, 0, 0));
2796 // "Level Complete":
2797 e_CharFont_GetSize(gMenuFont
, _lc
[I_MENU_INTER_LEVEL_COMPLETE
], w1
, h
);
2798 e_CharFont_Print(gMenuFont
, (gScreenWidth
-w1
) div 2, 32, _lc
[I_MENU_INTER_LEVEL_COMPLETE
]);
2800 // Îïðåäåëÿåì êîîðäèíàòû âûðàâíèâàíèÿ ïî ñàìîé äëèííîé ñòðîêå:
2801 s1
:= _lc
[I_MENU_INTER_KPM
];
2802 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2805 e_CharFont_GetSize(gMenuFont
, s1
, w2
, h
);
2807 key_x
:= (gScreenWidth
-w1
-w2
) div 2;
2808 val_x
:= key_x
+ w1
;
2811 tm
:= SingleStat
.GameTime
div 1000;
2812 s1
:= _lc
[I_MENU_INTER_TIME
];
2813 s2
:= Format(' %d:%.2d:%.2d', [tm
div (60*60), (tm
mod (60*60)) div 60, tm
mod 60]);
2815 e_CharFont_Print(gMenuFont
, key_x
, 80, s1
);
2816 e_CharFont_PrintEx(gMenuFont
, val_x
, 80, s2
, _RGB(255, 0, 0));
2818 if SingleStat
.TwoPlayers
then
2821 s1
:= _lc
[I_MENU_PLAYER_1
];
2822 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2823 e_CharFont_Print(gMenuFont
, (gScreenWidth
-w1
) div 2, 128, s1
);
2825 // Ñòàòèñòèêà ïåðâîãî èãðîêà:
2830 s1
:= _lc
[I_MENU_PLAYER_2
];
2831 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2832 e_CharFont_Print(gMenuFont
, (gScreenWidth
-w1
) div 2, 288, s1
);
2834 // Ñòàòèñòèêà âòîðîãî èãðîêà:
2840 // Ñòàòèñòèêà ïåðâîãî èãðîêà:
2846 procedure DrawLoadingStat();
2847 procedure drawRect (x
, y
, w
, h
: Integer);
2849 if (w
< 1) or (h
< 1) then exit
;
2851 glVertex2f(x
+0.375, y
+0.375);
2852 glVertex2f(x
+w
+0.375, y
+0.375);
2853 glVertex2f(x
+w
+0.375, y
+h
+0.375);
2854 glVertex2f(x
+0.375, y
+h
+0.375);
2858 function drawPBar (cur
, total
: Integer; washere
: Boolean): Boolean;
2860 rectW
, rectH
: Integer;
2867 idl
, idr
, idb
, idm
: LongWord;
2871 if (total
< 1) then exit
;
2872 if (cur
< 1) then exit
; // don't blink
2873 if (not washere
) and (cur
>= total
) then exit
; // don't blink
2874 //if (cur < 0) then cur := 0;
2875 //if (cur > total) then cur := total;
2878 if (hasPBarGfx
) then
2880 g_Texture_Get('UI_GFX_PBAR_LEFT', idl
);
2881 g_Texture_GetSize('UI_GFX_PBAR_LEFT', wl
, hl
);
2882 g_Texture_Get('UI_GFX_PBAR_RIGHT', idr
);
2883 g_Texture_GetSize('UI_GFX_PBAR_RIGHT', wr
, hr
);
2884 g_Texture_Get('UI_GFX_PBAR_MIDDLE', idb
);
2885 g_Texture_GetSize('UI_GFX_PBAR_MIDDLE', wb
, hb
);
2886 g_Texture_Get('UI_GFX_PBAR_MARKER', idm
);
2887 g_Texture_GetSize('UI_GFX_PBAR_MARKER', wm
, hm
);
2889 //rectW := gScreenWidth-360;
2890 rectW
:= trunc(624.0*gScreenWidth
/1024.0);
2893 x0
:= (gScreenWidth
-rectW
) div 2;
2894 y0
:= gScreenHeight
-rectH
-64;
2895 if (y0
< 2) then y0
:= 2;
2897 glEnable(GL_SCISSOR_TEST
);
2900 glScissor(x0
, gScreenHeight
-y0
-rectH
, rectW
, rectH
);
2901 e_DrawSize(idl
, x0
, y0
, 0, true, false, wl
, hl
);
2902 e_DrawSize(idr
, x0
+rectW
-wr
, y0
, 0, true, false, wr
, hr
);
2905 glScissor(x0
+wl
, gScreenHeight
-y0
-rectH
, rectW
-wl
-wr
, rectH
);
2907 while (f
< x0
+rectW
) do
2909 e_DrawSize(idb
, f
, y0
, 0, true, false, wb
, hb
);
2914 wdt
:= (rectW
-wl
-wr
)*cur
div total
;
2915 if (wdt
> rectW
-wl
-wr
) then wdt
:= rectW
-wr
-wr
;
2918 my
:= y0
; // don't be so smart, ketmar: +(rectH-wm) div 2;
2919 glScissor(x0
+wl
, gScreenHeight
-my
-rectH
, wdt
, hm
);
2923 e_DrawSize(idm
, f
, y0
, 0, true, false, wm
, hm
);
2929 glScissor(0, 0, gScreenWidth
, gScreenHeight
);
2933 rectW
:= gScreenWidth
-64;
2936 x0
:= (gScreenWidth
-rectW
) div 2;
2937 y0
:= gScreenHeight
-rectH
-64;
2938 if (y0
< 2) then y0
:= 2;
2940 glDisable(GL_BLEND
);
2941 glDisable(GL_TEXTURE_2D
);
2943 //glClearColor(0, 0, 0, 0);
2944 //glClear(GL_COLOR_BUFFER_BIT);
2946 glColor4ub(127, 127, 127, 255);
2947 drawRect(x0
-2, y0
-2, rectW
+4, rectH
+4);
2949 glColor4ub(0, 0, 0, 255);
2950 drawRect(x0
-1, y0
-1, rectW
+2, rectH
+2);
2952 glColor4ub(127, 127, 127, 255);
2953 wdt
:= rectW
*cur
div total
;
2954 if (wdt
> rectW
) then wdt
:= rectW
;
2955 drawRect(x0
, y0
, wdt
, rectH
);
2964 if (Length(LoadingStat
.Msgs
) = 0) then exit
;
2966 e_CharFont_GetSize(gMenuFont
, _lc
[I_MENU_LOADING
], ww
, hh
);
2967 yy
:= (gScreenHeight
div 3);
2968 e_CharFont_Print(gMenuFont
, (gScreenWidth
div 2)-(ww
div 2), yy
-2*hh
, _lc
[I_MENU_LOADING
]);
2969 xx
:= (gScreenWidth
div 3);
2973 for i
:= 0 to NextMsg
-1 do
2975 if (i
= (NextMsg
-1)) and (MaxValue
> 0) then
2976 s
:= Format('%s: %d/%d', [Msgs
[i
], CurValue
, MaxValue
])
2980 e_CharFont_PrintEx(gMenuSmallFont
, xx
, yy
, s
, _RGB(255, 0, 0));
2981 yy
:= yy
+ LOADING_INTERLINE
;
2982 PBarWasHere
:= drawPBar(CurValue
, MaxValue
, PBarWasHere
);
2987 procedure DrawMinimap(p
: TPlayer
; RenderRect
: e_graphics
.TRect
);
2989 a
, aX
, aY
, aX2
, aY2
, Scale
, ScaleSz
: Integer;
2991 function monDraw (mon
: TMonster
): Boolean;
2993 result
:= false; // don't stop
2998 // Ëåâûé âåðõíèé óãîë
2999 aX
:= Obj
.X
div ScaleSz
+ 1;
3000 aY
:= Obj
.Y
div ScaleSz
+ 1;
3002 aX2
:= max(Obj
.Rect
.Width
div ScaleSz
, 1);
3003 aY2
:= max(Obj
.Rect
.Height
div ScaleSz
, 1);
3004 // Ïðàâûé íèæíèé óãîë
3005 aX2
:= aX
+ aX2
- 1;
3006 aY2
:= aY
+ aY2
- 1;
3007 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 255, 0, 0);
3013 if (gMapInfo
.Width
> RenderRect
.Right
- RenderRect
.Left
) or
3014 (gMapInfo
.Height
> RenderRect
.Bottom
- RenderRect
.Top
) then
3017 // Ñêîëüêî ïèêñåëîâ êàðòû â 1 ïèêñåëå ìèíè-êàðòû:
3018 ScaleSz
:= 16 div Scale
;
3019 // Ðàçìåðû ìèíè-êàðòû:
3020 aX
:= max(gMapInfo
.Width
div ScaleSz
, 1);
3021 aY
:= max(gMapInfo
.Height
div ScaleSz
, 1);
3023 e_DrawFillQuad(0, 0, aX
-1, aY
-1, 0, 0, 0, 0);
3025 if gWalls
<> nil then
3028 for a
:= 0 to High(gWalls
) do
3030 if PanelType
<> 0 then
3032 // Ëåâûé âåðõíèé óãîë:
3033 aX
:= X
div ScaleSz
;
3034 aY
:= Y
div ScaleSz
;
3036 aX2
:= max(Width
div ScaleSz
, 1);
3037 aY2
:= max(Height
div ScaleSz
, 1);
3038 // Ïðàâûé íèæíèé óãîë:
3039 aX2
:= aX
+ aX2
- 1;
3040 aY2
:= aY
+ aY2
- 1;
3043 PANEL_WALL
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 208, 208, 208, 0);
3044 PANEL_OPENDOOR
, PANEL_CLOSEDOOR
:
3045 if Enabled
then e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 160, 160, 160, 0);
3049 if gSteps
<> nil then
3052 for a
:= 0 to High(gSteps
) do
3054 if PanelType
<> 0 then
3056 // Ëåâûé âåðõíèé óãîë:
3057 aX
:= X
div ScaleSz
;
3058 aY
:= Y
div ScaleSz
;
3060 aX2
:= max(Width
div ScaleSz
, 1);
3061 aY2
:= max(Height
div ScaleSz
, 1);
3062 // Ïðàâûé íèæíèé óãîë:
3063 aX2
:= aX
+ aX2
- 1;
3064 aY2
:= aY
+ aY2
- 1;
3066 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 128, 128, 128, 0);
3069 if gLifts
<> nil then
3072 for a
:= 0 to High(gLifts
) do
3074 if PanelType
<> 0 then
3076 // Ëåâûé âåðõíèé óãîë:
3077 aX
:= X
div ScaleSz
;
3078 aY
:= Y
div ScaleSz
;
3080 aX2
:= max(Width
div ScaleSz
, 1);
3081 aY2
:= max(Height
div ScaleSz
, 1);
3082 // Ïðàâûé íèæíèé óãîë:
3083 aX2
:= aX
+ aX2
- 1;
3084 aY2
:= aY
+ aY2
- 1;
3087 LIFTTYPE_UP
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 116, 72, 36, 0);
3088 LIFTTYPE_DOWN
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 116, 124, 96, 0);
3089 LIFTTYPE_LEFT
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 200, 80, 4, 0);
3090 LIFTTYPE_RIGHT
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 252, 140, 56, 0);
3094 if gWater
<> nil then
3097 for a
:= 0 to High(gWater
) do
3099 if PanelType
<> 0 then
3101 // Ëåâûé âåðõíèé óãîë:
3102 aX
:= X
div ScaleSz
;
3103 aY
:= Y
div ScaleSz
;
3105 aX2
:= max(Width
div ScaleSz
, 1);
3106 aY2
:= max(Height
div ScaleSz
, 1);
3107 // Ïðàâûé íèæíèé óãîë:
3108 aX2
:= aX
+ aX2
- 1;
3109 aY2
:= aY
+ aY2
- 1;
3111 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 0, 192, 0);
3114 if gAcid1
<> nil then
3116 // Ðèñóåì êèñëîòó 1:
3117 for a
:= 0 to High(gAcid1
) do
3119 if PanelType
<> 0 then
3121 // Ëåâûé âåðõíèé óãîë:
3122 aX
:= X
div ScaleSz
;
3123 aY
:= Y
div ScaleSz
;
3125 aX2
:= max(Width
div ScaleSz
, 1);
3126 aY2
:= max(Height
div ScaleSz
, 1);
3127 // Ïðàâûé íèæíèé óãîë:
3128 aX2
:= aX
+ aX2
- 1;
3129 aY2
:= aY
+ aY2
- 1;
3131 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 176, 0, 0);
3134 if gAcid2
<> nil then
3136 // Ðèñóåì êèñëîòó 2:
3137 for a
:= 0 to High(gAcid2
) do
3139 if PanelType
<> 0 then
3141 // Ëåâûé âåðõíèé óãîë:
3142 aX
:= X
div ScaleSz
;
3143 aY
:= Y
div ScaleSz
;
3145 aX2
:= max(Width
div ScaleSz
, 1);
3146 aY2
:= max(Height
div ScaleSz
, 1);
3147 // Ïðàâûé íèæíèé óãîë:
3148 aX2
:= aX
+ aX2
- 1;
3149 aY2
:= aY
+ aY2
- 1;
3151 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 176, 0, 0, 0);
3154 if gPlayers
<> nil then
3157 for a
:= 0 to High(gPlayers
) do
3158 if gPlayers
[a
] <> nil then with gPlayers
[a
] do
3160 // Ëåâûé âåðõíèé óãîë:
3161 aX
:= Obj
.X
div ScaleSz
+ 1;
3162 aY
:= Obj
.Y
div ScaleSz
+ 1;
3164 aX2
:= max(Obj
.Rect
.Width
div ScaleSz
, 1);
3165 aY2
:= max(Obj
.Rect
.Height
div ScaleSz
, 1);
3166 // Ïðàâûé íèæíèé óãîë:
3167 aX2
:= aX
+ aX2
- 1;
3168 aY2
:= aY
+ aY2
- 1;
3170 if gPlayers
[a
] = p
then
3171 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 255, 0, 0)
3174 TEAM_RED
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 0, 0, 0);
3175 TEAM_BLUE
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 0, 255, 0);
3176 else e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 128, 0, 0);
3181 g_Mons_ForEach(monDraw
);
3186 procedure renderAmbientQuad (hasAmbient
: Boolean; constref ambColor
: TDFColor
);
3188 if not hasAmbient
then exit
;
3189 e_AmbientQuad(sX
, sY
, sWidth
, sHeight
, ambColor
.r
, ambColor
.g
, ambColor
.b
, ambColor
.a
);
3193 // setup sX, sY, sWidth, sHeight, and transformation matrix before calling this!
3194 //FIXME: broken for splitscreen mode
3195 procedure renderDynLightsInternal ();
3197 //hasAmbient: Boolean;
3198 //ambColor: TDFColor;
3200 lx
, ly
, lrad
: Integer;
3201 scxywh
: array[0..3] of GLint
;
3204 if e_NoGraphics
then exit
;
3206 //TODO: lights should be in separate grid, i think
3207 // but on the other side: grid may be slower for dynlights, as their lifetime is short
3208 if (not gwin_k8_enable_light_experiments
) or (not gwin_has_stencil
) or (g_dynLightCount
< 1) then exit
;
3211 //ambColor := gCurrentMap['light_ambient'].rgba;
3212 //hasAmbient := (not ambColor.isOpaque) or (not ambColor.isBlack);
3214 { // this will multiply incoming color to alpha from framebuffer
3216 glBlendFunc(GL_DST_ALPHA, GL_ONE);
3220 * light rendering: (INVALID!)
3221 * glStencilFunc(GL_EQUAL, 0, $ff);
3223 * glClear(GL_STENCIL_BUFFER_BIT);
3224 * glStencilOp(GL_KEEP, GL_KEEP, GL_INCR);
3225 * draw shadow volume into stencil buffer
3226 * glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); // modify color buffer
3227 * glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); // don't modify stencil buffer
3229 * draw color-less quad with light alpha (WARNING! don't touch color!)
3230 * glEnable(GL_BLEND);
3231 * glBlendFunc(GL_DST_ALPHA, GL_ONE);
3232 * draw all geometry up to and including walls (with alpha-testing, probably) -- this does lighting
3234 wassc
:= (glIsEnabled(GL_SCISSOR_TEST
) <> 0);
3235 if wassc
then glGetIntegerv(GL_SCISSOR_BOX
, @scxywh
[0]) else glGetIntegerv(GL_VIEWPORT
, @scxywh
[0]);
3237 // setup OpenGL parameters
3238 glStencilMask($FFFFFFFF);
3239 glStencilFunc(GL_ALWAYS
, 0, $FFFFFFFF);
3240 glEnable(GL_STENCIL_TEST
);
3241 glEnable(GL_SCISSOR_TEST
);
3242 glClear(GL_STENCIL_BUFFER_BIT
);
3243 glStencilFunc(GL_EQUAL
, 0, $ff);
3245 for lln
:= 0 to g_dynLightCount
-1 do
3247 lx
:= g_dynLights
[lln
].x
;
3248 ly
:= g_dynLights
[lln
].y
;
3249 lrad
:= g_dynLights
[lln
].radius
;
3250 if (lrad
< 3) then continue
;
3252 if (lx
-sX
+lrad
< 0) then continue
;
3253 if (ly
-sY
+lrad
< 0) then continue
;
3254 if (lx
-sX
-lrad
>= gPlayerScreenSize
.X
) then continue
;
3255 if (ly
-sY
-lrad
>= gPlayerScreenSize
.Y
) then continue
;
3257 // set scissor to optimize drawing
3258 if (g_dbg_scale
= 1.0) then
3260 glScissor((lx
-sX
)-lrad
+2, gPlayerScreenSize
.Y
-(ly
-sY
)-lrad
-1+2, lrad
*2-4, lrad
*2-4);
3264 glScissor(0, 0, gWinSizeX
, gWinSizeY
);
3266 // no need to clear stencil buffer, light blitting will do it for us... but only for normal scale
3267 if (g_dbg_scale
<> 1.0) then glClear(GL_STENCIL_BUFFER_BIT
);
3268 glStencilOp(GL_KEEP
, GL_KEEP
, GL_INCR
);
3269 // draw extruded panels
3270 glDisable(GL_TEXTURE_2D
);
3271 glDisable(GL_BLEND
);
3272 glColorMask(GL_FALSE
, GL_FALSE
, GL_FALSE
, GL_FALSE
); // no need to modify color buffer
3273 if (lrad
> 4) then g_Map_DrawPanelShadowVolumes(lx
, ly
, lrad
);
3274 // render light texture
3275 glColorMask(GL_TRUE
, GL_TRUE
, GL_TRUE
, GL_TRUE
); // modify color buffer
3276 glStencilOp(GL_ZERO
, GL_ZERO
, GL_ZERO
); // draw light, and clear stencil buffer
3279 glBlendFunc(GL_SRC_ALPHA
, GL_ONE_MINUS_SRC_ALPHA
);
3280 glEnable(GL_TEXTURE_2D
);
3281 // color and opacity
3282 glColor4f(g_dynLights
[lln
].r
, g_dynLights
[lln
].g
, g_dynLights
[lln
].b
, g_dynLights
[lln
].a
);
3283 glBindTexture(GL_TEXTURE_2D
, g_Texture_Light());
3285 glTexCoord2f(0.0, 0.0); glVertex2i(lx
-lrad
, ly
-lrad
); // top-left
3286 glTexCoord2f(1.0, 0.0); glVertex2i(lx
+lrad
, ly
-lrad
); // top-right
3287 glTexCoord2f(1.0, 1.0); glVertex2i(lx
+lrad
, ly
+lrad
); // bottom-right
3288 glTexCoord2f(0.0, 1.0); glVertex2i(lx
-lrad
, ly
+lrad
); // bottom-left
3293 glDisable(GL_STENCIL_TEST
);
3294 glDisable(GL_BLEND
);
3295 glDisable(GL_SCISSOR_TEST
);
3296 //glScissor(0, 0, sWidth, sHeight);
3298 glScissor(scxywh
[0], scxywh
[1], scxywh
[2], scxywh
[3]);
3299 if wassc
then glEnable(GL_SCISSOR_TEST
) else glDisable(GL_SCISSOR_TEST
);
3303 function fixViewportForScale (): Boolean;
3305 nx0
, ny0
, nw
, nh
: Integer;
3308 if (g_dbg_scale
<> 1.0) then
3311 nx0
:= round(sX
-(gPlayerScreenSize
.X
-(sWidth
*g_dbg_scale
))/2/g_dbg_scale
);
3312 ny0
:= round(sY
-(gPlayerScreenSize
.Y
-(sHeight
*g_dbg_scale
))/2/g_dbg_scale
);
3313 nw
:= round(sWidth
/g_dbg_scale
);
3314 nh
:= round(sHeight
/g_dbg_scale
);
3323 // setup sX, sY, sWidth, sHeight, and transformation matrix before calling this!
3324 // WARNING! this WILL CALL `glTranslatef()`, but won't restore matrices!
3325 procedure renderMapInternal (backXOfs
, backYOfs
: Integer; setTransMatrix
: Boolean);
3327 TDrawCB
= procedure ();
3330 hasAmbient
: Boolean;
3332 doAmbient
: Boolean = false;
3334 procedure drawPanelType (profname
: AnsiString; panType
: DWord
; doDraw
: Boolean);
3339 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin(profname
);
3340 if gdbg_map_use_accel_render
then
3342 tagmask
:= panelTypeToTag(panType
);
3343 while (gDrawPanelList
.count
> 0) do
3345 pan
:= TPanel(gDrawPanelList
.front());
3346 if ((pan
.tag
and tagmask
) = 0) then break
;
3347 if doDraw
then pan
.Draw(doAmbient
, ambColor
);
3348 gDrawPanelList
.popFront();
3353 if doDraw
then g_Map_DrawPanels(panType
, hasAmbient
, ambColor
);
3355 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
3358 procedure drawOther (profname
: AnsiString; cb
: TDrawCB
);
3360 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin(profname
);
3361 if assigned(cb
) then cb();
3362 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
3366 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin('total');
3368 // our accelerated renderer will collect all panels to gDrawPanelList
3369 // we can use panel tag to render level parts (see GridTagXXX in g_map.pas)
3370 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin('collect');
3371 if gdbg_map_use_accel_render
then
3373 g_Map_CollectDrawPanels(sX
, sY
, sWidth
, sHeight
);
3375 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
3377 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin('skyback');
3378 g_Map_DrawBack(backXOfs
, backYOfs
);
3379 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
3381 if setTransMatrix
then
3383 //if (g_dbg_scale <> 1.0) then glTranslatef(0.0, -0.375/2, 0);
3384 glScalef(g_dbg_scale
, g_dbg_scale
, 1.0);
3385 glTranslatef(-sX
, -sY
, 0);
3389 ambColor
:= gCurrentMap
['light_ambient'].rgba
;
3390 hasAmbient
:= (not ambColor
.isOpaque
) or (not ambColor
.isBlack
);
3395 //writeln('color: (', ambColor.r, ',', ambColor.g, ',', ambColor.b, ',', ambColor.a, ')');
3396 glColor4ub(ambColor.r, ambColor.g, ambColor.b, ambColor.a);
3397 glClear(GL_COLOR_BUFFER_BIT);
3400 //writeln('color: (', ambColor.r, ',', ambColor.g, ',', ambColor.b, ',', ambColor.a, ')');
3403 drawPanelType('*back', PANEL_BACK
, g_rlayer_back
);
3404 drawPanelType('*step', PANEL_STEP
, g_rlayer_step
);
3405 drawOther('items', @g_Items_Draw
);
3406 drawOther('weapons', @g_Weapon_Draw
);
3407 drawOther('shells', @g_Player_DrawShells
);
3408 drawOther('drawall', @g_Player_DrawAll
);
3409 drawOther('corpses', @g_Player_DrawCorpses
);
3410 drawPanelType('*wall', PANEL_WALL
, g_rlayer_wall
);
3411 drawOther('monsters', @g_Monsters_Draw
);
3412 drawOther('itemdrop', @g_Items_DrawDrop
);
3413 drawPanelType('*door', PANEL_CLOSEDOOR
, g_rlayer_door
);
3414 drawOther('gfx', @g_GFX_Draw
);
3415 drawOther('flags', @g_Map_DrawFlags
);
3416 drawPanelType('*acid1', PANEL_ACID1
, g_rlayer_acid1
);
3417 drawPanelType('*acid2', PANEL_ACID2
, g_rlayer_acid2
);
3418 drawPanelType('*water', PANEL_WATER
, g_rlayer_water
);
3419 drawOther('dynlights', @renderDynLightsInternal
);
3421 if hasAmbient
{and ((not g_playerLight) or (not gwin_has_stencil) or (g_dynLightCount < 1))} then
3423 renderAmbientQuad(hasAmbient
, ambColor
);
3427 drawPanelType('*fore', PANEL_FORE
, g_rlayer_fore
);
3430 if g_debug_HealthBar
then
3432 g_Monsters_DrawHealth();
3433 g_Player_DrawHealth();
3436 if (profileFrameDraw
<> nil) then profileFrameDraw
.mainEnd(); // map rendering
3440 procedure DrawMapView(x
, y
, w
, h
: Integer);
3447 bx
:= Round(x
/(gMapInfo
.Width
- w
)*(gBackSize
.X
- w
));
3448 by
:= Round(y
/(gMapInfo
.Height
- h
)*(gBackSize
.Y
- h
));
3455 fixViewportForScale();
3456 renderMapInternal(-bx
, -by
, true);
3462 procedure DrawPlayer(p
: TPlayer
);
3464 px
, py
, a
, b
, c
, d
: Integer;
3467 if (p
= nil) or (p
.FDummy
) then
3470 g_Map_DrawBack(0, 0);
3475 if (profileFrameDraw
= nil) then profileFrameDraw
:= TProfiler
.Create('RENDER', g_profile_history_size
);
3476 if (profileFrameDraw
<> nil) then profileFrameDraw
.mainBegin(g_profile_frame_draw
);
3482 px
:= p
.GameX
+ PLAYER_RECT_CX
;
3483 py
:= p
.GameY
+ PLAYER_RECT_CY
+p
.Obj
.slopeUpLeft
;
3485 if (g_dbg_scale
= 1.0) and (not g_dbg_ignore_bounds
) then
3487 if (px
> (gPlayerScreenSize
.X
div 2)) then a
:= -px
+(gPlayerScreenSize
.X
div 2) else a
:= 0;
3488 if (py
> (gPlayerScreenSize
.Y
div 2)) then b
:= -py
+(gPlayerScreenSize
.Y
div 2) else b
:= 0;
3490 if (px
> gMapInfo
.Width
-(gPlayerScreenSize
.X
div 2)) then a
:= -gMapInfo
.Width
+gPlayerScreenSize
.X
;
3491 if (py
> gMapInfo
.Height
-(gPlayerScreenSize
.Y
div 2)) then b
:= -gMapInfo
.Height
+gPlayerScreenSize
.Y
;
3493 if (gMapInfo
.Width
= gPlayerScreenSize
.X
) then a
:= 0
3494 else if (gMapInfo
.Width
< gPlayerScreenSize
.X
) then
3497 a
:= (gPlayerScreenSize
.X
-gMapInfo
.Width
) div 2;
3500 if (gMapInfo
.Height
= gPlayerScreenSize
.Y
) then b
:= 0
3501 else if (gMapInfo
.Height
< gPlayerScreenSize
.Y
) then
3504 b
:= (gPlayerScreenSize
.Y
-gMapInfo
.Height
) div 2;
3509 // scaled, ignore level bounds
3510 a
:= -px
+(gPlayerScreenSize
.X
div 2);
3511 b
:= -py
+(gPlayerScreenSize
.Y
div 2);
3514 if p
.IncCam
<> 0 then
3516 if py
> gMapInfo
.Height
-(gPlayerScreenSize
.Y
div 2) then
3518 if p
.IncCam
> 120-(py
-(gMapInfo
.Height
-(gPlayerScreenSize
.Y
div 2))) then
3520 p
.IncCam
:= 120-(py
-(gMapInfo
.Height
-(gPlayerScreenSize
.Y
div 2)));
3524 if py
< gPlayerScreenSize
.Y
div 2 then
3526 if p
.IncCam
< -120+((gPlayerScreenSize
.Y
div 2)-py
) then
3528 p
.IncCam
:= -120+((gPlayerScreenSize
.Y
div 2)-py
);
3532 if p
.IncCam
< 0 then
3534 while (py
+(gPlayerScreenSize
.Y
div 2)-p
.IncCam
> gMapInfo
.Height
) and (p
.IncCam
< 0) do p
.IncCam
:= p
.IncCam
+1; //Inc(p.IncCam);
3537 if p
.IncCam
> 0 then
3539 while (py
-(gPlayerScreenSize
.Y
div 2)-p
.IncCam
< 0) and (p
.IncCam
> 0) do p
.IncCam
:= p
.IncCam
-1; //Dec(p.IncCam);
3543 if (px
< gPlayerScreenSize
.X
div 2) or (gMapInfo
.Width
-gPlayerScreenSize
.X
<= 256) then c
:= 0
3544 else if (px
> gMapInfo
.Width
-(gPlayerScreenSize
.X
div 2)) then c
:= gBackSize
.X
-gPlayerScreenSize
.X
3545 else c
:= round((px
-(gPlayerScreenSize
.X
div 2))/(gMapInfo
.Width
-gPlayerScreenSize
.X
)*(gBackSize
.X
-gPlayerScreenSize
.X
));
3547 if (py
-p
.IncCam
<= gPlayerScreenSize
.Y
div 2) or (gMapInfo
.Height
-gPlayerScreenSize
.Y
<= 256) then d
:= 0
3548 else if (py
-p
.IncCam
>= gMapInfo
.Height
-(gPlayerScreenSize
.Y
div 2)) then d
:= gBackSize
.Y
-gPlayerScreenSize
.Y
3549 else d
:= round((py
-p
.IncCam
-(gPlayerScreenSize
.Y
div 2))/(gMapInfo
.Height
-gPlayerScreenSize
.Y
)*(gBackSize
.Y
-gPlayerScreenSize
.Y
));
3552 sY
:= -(b
+p
.IncCam
);
3553 sWidth
:= gPlayerScreenSize
.X
;
3554 sHeight
:= gPlayerScreenSize
.Y
;
3556 //glTranslatef(a, b+p.IncCam, 0);
3558 //if (p = gPlayer1) and (g_dbg_scale >= 1.0) then g_Holmes_plrViewSize(sWidth, sHeight);
3560 //conwritefln('OLD: (%s,%s)-(%s,%s)', [sX, sY, sWidth, sHeight]);
3561 fixViewportForScale();
3562 //conwritefln(' (%s,%s)-(%s,%s)', [sX, sY, sWidth, sHeight]);
3564 if (g_dbg_scale
<> 1.0) and (not g_dbg_ignore_bounds
) then
3566 if (sX
+sWidth
> gMapInfo
.Width
) then sX
:= gMapInfo
.Width
-sWidth
;
3567 if (sY
+sHeight
> gMapInfo
.Height
) then sY
:= gMapInfo
.Height
-sHeight
;
3568 if (sX
< 0) then sX
:= 0;
3569 if (sY
< 0) then sY
:= 0;
3571 if (gBackSize
.X
<= gPlayerScreenSize
.X
) or (gMapInfo
.Width
<= sWidth
) then c
:= 0 else c
:= trunc((gBackSize
.X
-gPlayerScreenSize
.X
)*sX
/(gMapInfo
.Width
-sWidth
));
3572 if (gBackSize
.Y
<= gPlayerScreenSize
.Y
) or (gMapInfo
.Height
<= sHeight
) then d
:= 0 else d
:= trunc((gBackSize
.Y
-gPlayerScreenSize
.Y
)*sY
/(gMapInfo
.Height
-sHeight
));
3575 //r_smallmap_h: 0: left; 1: center; 2: right
3576 //r_smallmap_v: 0: top; 1: center; 2: bottom
3578 if (gMapInfo
.Width
= sWidth
) then
3582 else if (gMapInfo
.Width
< sWidth
) then
3584 case r_smallmap_h
of
3585 1: sX
:= -((sWidth
-gMapInfo
.Width
) div 2); // center
3586 2: sX
:= -(sWidth
-gMapInfo
.Width
); // right
3587 else sX
:= 0; // left
3591 if (gMapInfo
.Height
= sHeight
) then
3595 else if (gMapInfo
.Height
< sHeight
) then
3597 case r_smallmap_v
of
3598 1: sY
:= -((sHeight
-gMapInfo
.Height
) div 2); // center
3599 2: sY
:= -(sHeight
-gMapInfo
.Height
); // bottom
3600 else sY
:= 0; // top
3606 p
.viewPortW
:= sWidth
;
3607 p
.viewPortH
:= sHeight
;
3609 {$IFDEF ENABLE_HOLMES}
3610 if (p
= gPlayer1
) then
3612 g_Holmes_plrViewPos(sX
, sY
);
3613 g_Holmes_plrViewSize(sWidth
, sHeight
);
3617 renderMapInternal(-c
, -d
, true);
3619 if (gGameSettings
.GameMode
<> GM_SINGLE
) and gPlayerIndicator
then
3621 if p
.FSpectator
then
3622 e_TextureFontPrintEx(p
.GameX
+ PLAYER_RECT_CX
- 4,
3623 p
.GameY
+ PLAYER_RECT_CY
- 4,
3624 'X', gStdFont
, 255, 255, 255, 1, True);
3626 for a := 0 to High(gCollideMap) do
3627 for b := 0 to High(gCollideMap[a]) do
3630 if ByteBool(gCollideMap[a, b] and MARK_WALL) then
3632 if ByteBool(gCollideMap[a, b] and MARK_DOOR) then
3636 1: e_DrawPoint(1, b, a, 200, 200, 200);
3637 2: e_DrawPoint(1, b, a, 64, 64, 255);
3638 3: e_DrawPoint(1, b, a, 255, 0, 255);
3648 if gShowMap
then DrawMinimap(p
, _TRect(0, 0, 128, 128));
3649 if g_Debug_Player
then
3650 g_Player_DrawDebug(p
);
3654 procedure drawProfilers ();
3659 if g_profile_frame_draw
and (profileFrameDraw
<> nil) then px
:= px
-drawProfiles(px
, py
, profileFrameDraw
);
3660 if g_profile_collision
and (profMapCollision
<> nil) then begin px
:= px
-drawProfiles(px
, py
, profMapCollision
); py
-= calcProfilesHeight(profMonsLOS
); end;
3661 if g_profile_los
and (profMonsLOS
<> nil) then begin px
:= px
-drawProfiles(px
, py
, profMonsLOS
); py
-= calcProfilesHeight(profMonsLOS
); end;
3664 procedure g_Game_Draw();
3671 plView1
, plView2
: TPlayer
;
3674 if gExit
= EXIT_QUIT
then Exit
;
3676 Time
:= GetTimer() {div 1000};
3677 FPSCounter
:= FPSCounter
+1;
3678 if Time
- FPSTime
>= 1000 then
3685 if gGameOn
or (gState
= STATE_FOLD
) then
3687 if (gPlayer1
<> nil) and (gPlayer2
<> nil) then
3689 gSpectMode
:= SPECT_NONE
;
3690 if not gRevertPlayers
then
3692 plView1
:= gPlayer1
;
3693 plView2
:= gPlayer2
;
3697 plView1
:= gPlayer2
;
3698 plView2
:= gPlayer1
;
3702 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
3704 gSpectMode
:= SPECT_NONE
;
3705 if gPlayer2
= nil then
3708 plView1
:= gPlayer2
;
3717 if (plView1
= nil) and (plView2
= nil) and (gSpectMode
= SPECT_NONE
) then
3718 gSpectMode
:= SPECT_STATS
;
3720 if gSpectMode
= SPECT_PLAYERS
then
3721 if gPlayers
<> nil then
3723 plView1
:= GetActivePlayer_ByID(gSpectPID1
);
3724 if plView1
= nil then
3726 gSpectPID1
:= GetActivePlayerID_Next();
3727 plView1
:= GetActivePlayer_ByID(gSpectPID1
);
3729 if gSpectViewTwo
then
3731 plView2
:= GetActivePlayer_ByID(gSpectPID2
);
3732 if plView2
= nil then
3734 gSpectPID2
:= GetActivePlayerID_Next();
3735 plView2
:= GetActivePlayer_ByID(gSpectPID2
);
3740 if gSpectMode
= SPECT_MAPVIEW
then
3742 // Ðåæèì ïðîñìîòðà êàðòû
3744 e_SetViewPort(0, 0, gScreenWidth
, gScreenHeight
);
3745 DrawMapView(gSpectX
, gSpectY
, gScreenWidth
, gScreenHeight
);
3746 gHearPoint1
.Active
:= True;
3747 gHearPoint1
.Coords
.X
:= gScreenWidth
div 2 + gSpectX
;
3748 gHearPoint1
.Coords
.Y
:= gScreenHeight
div 2 + gSpectY
;
3749 gHearPoint2
.Active
:= False;
3753 Split
:= (plView1
<> nil) and (plView2
<> nil);
3755 // Òî÷êè ñëóõà èãðîêîâ
3756 if plView1
<> nil then
3758 gHearPoint1
.Active
:= True;
3759 gHearPoint1
.Coords
.X
:= plView1
.GameX
;
3760 gHearPoint1
.Coords
.Y
:= plView1
.GameY
;
3762 gHearPoint1
.Active
:= False;
3763 if plView2
<> nil then
3765 gHearPoint2
.Active
:= True;
3766 gHearPoint2
.Coords
.X
:= plView2
.GameX
;
3767 gHearPoint2
.Coords
.Y
:= plView2
.GameY
;
3769 gHearPoint2
.Active
:= False;
3771 // Ðàçìåð ýêðàíîâ èãðîêîâ:
3772 gPlayerScreenSize
.X
:= gScreenWidth
-196;
3775 gPlayerScreenSize
.Y
:= gScreenHeight
div 2;
3776 if gScreenHeight
mod 2 = 0 then
3777 Dec(gPlayerScreenSize
.Y
);
3780 gPlayerScreenSize
.Y
:= gScreenHeight
;
3783 if gScreenHeight
mod 2 = 0 then
3784 e_SetViewPort(0, gPlayerScreenSize
.Y
+2, gPlayerScreenSize
.X
+196, gPlayerScreenSize
.Y
)
3786 e_SetViewPort(0, gPlayerScreenSize
.Y
+1, gPlayerScreenSize
.X
+196, gPlayerScreenSize
.Y
);
3788 DrawPlayer(plView1
);
3789 gPlayer1ScreenCoord
.X
:= sX
;
3790 gPlayer1ScreenCoord
.Y
:= sY
;
3794 e_SetViewPort(0, 0, gPlayerScreenSize
.X
+196, gPlayerScreenSize
.Y
);
3796 DrawPlayer(plView2
);
3797 gPlayer2ScreenCoord
.X
:= sX
;
3798 gPlayer2ScreenCoord
.Y
:= sY
;
3801 e_SetViewPort(0, 0, gScreenWidth
, gScreenHeight
);
3804 e_DrawLine(2, 0, gScreenHeight
div 2, gScreenWidth
, gScreenHeight
div 2, 0, 0, 0);
3807 {$IFDEF ENABLE_HOLMES}
3809 if (g_holmes_enabled
) then g_Holmes_Draw();
3812 if MessageText
<> '' then
3816 e_CharFont_GetSizeFmt(gMenuFont
, MessageText
, w
, h
);
3818 e_CharFont_PrintFmt(gMenuFont
, (gScreenWidth
div 2)-(w
div 2),
3819 (gScreenHeight
div 2)-(h
div 2), MessageText
)
3821 e_CharFont_PrintFmt(gMenuFont
, (gScreenWidth
div 2)-(w
div 2),
3822 Round(gScreenHeight
/ 2.75)-(h
div 2), MessageText
);
3825 if IsDrawStat
or (gSpectMode
= 1) then DrawStat();
3827 if gSpectHUD
and (not gChatShow
) and (gSpectMode
<> SPECT_NONE
) and (not gSpectAuto
) then
3829 // Draw spectator GUI
3832 e_TextureFontGetSize(gStdFont
, ww
, hh
);
3835 e_TextureFontPrintEx(0, gScreenHeight
- (hh
+2)*2, 'MODE: Stats', gStdFont
, 255, 255, 255, 1);
3837 e_TextureFontPrintEx(0, gScreenHeight
- (hh
+2)*2, 'MODE: Observe Map', gStdFont
, 255, 255, 255, 1);
3839 e_TextureFontPrintEx(0, gScreenHeight
- (hh
+2)*2, 'MODE: Watch Players', gStdFont
, 255, 255, 255, 1);
3841 e_TextureFontPrintEx(2*ww
, gScreenHeight
- (hh
+2), '< jump >', gStdFont
, 255, 255, 255, 1);
3842 if gSpectMode
= SPECT_STATS
then
3844 e_TextureFontPrintEx(16*ww
, gScreenHeight
- (hh
+2)*2, 'Autoview', gStdFont
, 255, 255, 255, 1);
3845 e_TextureFontPrintEx(16*ww
, gScreenHeight
- (hh
+2), '< fire >', gStdFont
, 255, 255, 255, 1);
3847 if gSpectMode
= SPECT_MAPVIEW
then
3849 e_TextureFontPrintEx(22*ww
, gScreenHeight
- (hh
+2)*2, '[-]', gStdFont
, 255, 255, 255, 1);
3850 e_TextureFontPrintEx(26*ww
, gScreenHeight
- (hh
+2)*2, 'Step ' + IntToStr(gSpectStep
), gStdFont
, 255, 255, 255, 1);
3851 e_TextureFontPrintEx(34*ww
, gScreenHeight
- (hh
+2)*2, '[+]', gStdFont
, 255, 255, 255, 1);
3852 e_TextureFontPrintEx(18*ww
, gScreenHeight
- (hh
+2), '<prev weap>', gStdFont
, 255, 255, 255, 1);
3853 e_TextureFontPrintEx(30*ww
, gScreenHeight
- (hh
+2), '<next weap>', gStdFont
, 255, 255, 255, 1);
3855 if gSpectMode
= SPECT_PLAYERS
then
3857 e_TextureFontPrintEx(22*ww
, gScreenHeight
- (hh
+2)*2, 'Player 1', gStdFont
, 255, 255, 255, 1);
3858 e_TextureFontPrintEx(20*ww
, gScreenHeight
- (hh
+2), '<left/right>', gStdFont
, 255, 255, 255, 1);
3859 if gSpectViewTwo
then
3861 e_TextureFontPrintEx(37*ww
, gScreenHeight
- (hh
+2)*2, 'Player 2', gStdFont
, 255, 255, 255, 1);
3862 e_TextureFontPrintEx(34*ww
, gScreenHeight
- (hh
+2), '<prev w/next w>', gStdFont
, 255, 255, 255, 1);
3863 e_TextureFontPrintEx(52*ww
, gScreenHeight
- (hh
+2)*2, '2x View', gStdFont
, 255, 255, 255, 1);
3864 e_TextureFontPrintEx(51*ww
, gScreenHeight
- (hh
+2), '<up/down>', gStdFont
, 255, 255, 255, 1);
3868 e_TextureFontPrintEx(35*ww
, gScreenHeight
- (hh
+2)*2, '2x View', gStdFont
, 255, 255, 255, 1);
3869 e_TextureFontPrintEx(34*ww
, gScreenHeight
- (hh
+2), '<up/down>', gStdFont
, 255, 255, 255, 1);
3875 if gPauseMain
and gGameOn
and (g_ActiveWindow
= nil) then
3877 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
3878 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
3880 e_CharFont_GetSize(gMenuFont
, _lc
[I_MENU_PAUSE
], w
, h
);
3881 e_CharFont_Print(gMenuFont
, (gScreenWidth
div 2)-(w
div 2),
3882 (gScreenHeight
div 2)-(h
div 2), _lc
[I_MENU_PAUSE
]);
3887 if (gState
= STATE_MENU
) then
3889 if (g_ActiveWindow
= nil) or (g_ActiveWindow
.BackTexture
= '') then
3891 if g_Texture_Get('MENU_BACKGROUND', ID
) then e_DrawSize(ID
, 0, 0, 0, False, False, gScreenWidth
, gScreenHeight
)
3892 else e_Clear(GL_COLOR_BUFFER_BIT
, 0, 0, 0);
3894 // F3 at menu will show game loading dialog
3895 if e_KeyPressed(IK_F3
) then g_Menu_Show_LoadMenu(true);
3896 if (g_ActiveWindow
<> nil) then
3898 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
3899 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
3903 // F3 at titlepic will show game loading dialog
3904 if e_KeyPressed(IK_F3
) then
3906 g_Menu_Show_LoadMenu(true);
3907 if (g_ActiveWindow
<> nil) then e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
3912 if gState
= STATE_FOLD
then
3914 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 0, 0, 0, EndingGameCounter
);
3917 if gState
= STATE_INTERCUSTOM
then
3919 if gLastMap
and (gGameSettings
.GameMode
= GM_COOP
) then
3921 back
:= 'TEXTURE_endpic';
3922 if not g_Texture_Get(back
, ID
) then
3923 back
:= _lc
[I_TEXTURE_ENDPIC
];
3928 if g_Texture_Get(back
, ID
) then
3929 e_DrawSize(ID
, 0, 0, 0, False, False, gScreenWidth
, gScreenHeight
)
3931 e_Clear(GL_COLOR_BUFFER_BIT
, 0, 0, 0);
3935 if g_ActiveWindow
<> nil then
3937 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
3938 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
3942 if gState
= STATE_INTERSINGLE
then
3944 if EndingGameCounter
> 0 then
3946 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 0, 0, 0, EndingGameCounter
);
3952 if g_Texture_Get(back
, ID
) then
3953 e_DrawSize(ID
, 0, 0, 0, False, False, gScreenWidth
, gScreenHeight
)
3955 e_Clear(GL_COLOR_BUFFER_BIT
, 0, 0, 0);
3959 if g_ActiveWindow
<> nil then
3961 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
3962 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
3967 if gState
= STATE_ENDPIC
then
3970 if not g_Texture_Get('TEXTURE_endpic', ID
) then
3971 g_Texture_Get(_lc
[I_TEXTURE_ENDPIC
], ID
);
3973 if ID
<> DWORD(-1) then
3974 e_DrawSize(ID
, 0, 0, 0, False, False, gScreenWidth
, gScreenHeight
)
3976 e_Clear(GL_COLOR_BUFFER_BIT
, 0, 0, 0);
3978 if g_ActiveWindow
<> nil then
3980 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
3981 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
3985 if gState
= STATE_SLIST
then
3987 if g_Texture_Get('MENU_BACKGROUND', ID
) then
3989 e_DrawSize(ID
, 0, 0, 0, False, False, gScreenWidth
, gScreenHeight
);
3990 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
3991 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
3993 g_Serverlist_Draw(slCurrent
, slTable
);
3997 if g_ActiveWindow
<> nil then
4001 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4002 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4004 g_ActiveWindow
.Draw();
4009 if g_debug_Sounds
and gGameOn
then
4011 for w
:= 0 to High(e_SoundsArray
) do
4012 for h
:= 0 to e_SoundsArray
[w
].nRefs
do
4013 e_DrawPoint(1, w
+100, h
+100, 255, 0, 0);
4018 e_TextureFontPrint(0, 0, Format('FPS: %d', [FPS
]), gStdFont
);
4019 e_TextureFontPrint(0, 16, Format('UPS: %d', [UPS
]), gStdFont
);
4022 if gGameOn
and gShowTime
and (gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
]) then
4023 drawTime(gScreenWidth
-72, gScreenHeight
-16);
4025 if gGameOn
then drawProfilers();
4027 {$IFDEF ENABLE_HOLMES}
4034 procedure g_Game_Quit();
4036 g_Game_StopAllSounds(True);
4038 g_Game_SaveOptions();
4040 g_PlayerModel_FreeData();
4041 g_Texture_DeleteAll();
4042 g_Frames_DeleteAll();
4043 //g_Menu_Free(); //k8: this segfaults after resolution change; who cares?
4045 if NetInitDone
then g_Net_Free
;
4047 // Íàäî óäàëèòü êàðòó ïîñëå òåñòà:
4048 if gMapToDelete
<> '' then
4049 g_Game_DeleteTestMap();
4055 procedure g_FatalError(Text: String);
4057 g_Console_Add(Format(_lc
[I_FATAL_ERROR
], [Text]), True);
4058 e_WriteLog(Format(_lc
[I_FATAL_ERROR
], [Text]), TMsgType
.Warning
);
4060 gExit
:= EXIT_SIMPLE
;
4063 procedure g_SimpleError(Text: String);
4065 g_Console_Add(Format(_lc
[I_SIMPLE_ERROR
], [Text]), True);
4066 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], [Text]), TMsgType
.Warning
);
4069 procedure g_Game_SetupScreenSize();
4071 RES_FACTOR
= 4.0 / 3.0;
4077 // Ðàçìåð ýêðàíîâ èãðîêîâ:
4078 gPlayerScreenSize
.X
:= gScreenWidth
-196;
4079 if (gPlayer1
<> nil) and (gPlayer2
<> nil) then
4080 gPlayerScreenSize
.Y
:= gScreenHeight
div 2
4082 gPlayerScreenSize
.Y
:= gScreenHeight
;
4084 // Ðàçìåð çàäíåãî ïëàíà:
4085 if BackID
<> DWORD(-1) then
4088 if (gScreenWidth
*s
> gMapInfo
.Width
) or
4089 (gScreenHeight
*s
> gMapInfo
.Height
) then
4091 gBackSize
.X
:= gScreenWidth
;
4092 gBackSize
.Y
:= gScreenHeight
;
4096 e_GetTextureSize(BackID
, @bw
, @bh
);
4097 rf
:= Single(bw
) / Single(bh
);
4098 if (rf
> RES_FACTOR
) then bw
:= Round(Single(bh
) * RES_FACTOR
)
4099 else if (rf
< RES_FACTOR
) then bh
:= Round(Single(bw
) / RES_FACTOR
);
4100 s
:= Max(gScreenWidth
/ bw
, gScreenHeight
/ bh
);
4101 if (s
< 1.0) then s
:= 1.0;
4102 gBackSize
.X
:= Round(bw
*s
);
4103 gBackSize
.Y
:= Round(bh
*s
);
4108 procedure g_Game_ChangeResolution(newWidth
, newHeight
: Word; nowFull
, nowMax
: Boolean);
4110 g_Window_SetSize(newWidth
, newHeight
, nowFull
);
4113 procedure g_Game_AddPlayer(Team
: Byte = TEAM_NONE
);
4115 if ((not gGameOn
) and (gState
<> STATE_INTERCUSTOM
))
4116 or (not (gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
])) then
4118 if gPlayer1
= nil then
4120 if g_Game_IsClient
then
4122 if NetPlrUID1
> -1 then
4124 MC_SEND_CheatRequest(NET_CHEAT_SPECTATE
);
4125 gPlayer1
:= g_Player_Get(NetPlrUID1
);
4130 if not (Team
in [TEAM_RED
, TEAM_BLUE
]) then
4131 Team
:= gPlayer1Settings
.Team
;
4133 // Ñîçäàíèå ïåðâîãî èãðîêà:
4134 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4135 gPlayer1Settings
.Color
,
4137 if gPlayer1
= nil then
4138 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]))
4141 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4142 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [gPlayer1
.Name
]), True);
4143 if g_Game_IsServer
and g_Game_IsNet
then
4144 MH_SEND_PlayerCreate(gPlayer1
.UID
);
4145 gPlayer1
.Respawn(False, True);
4147 if g_Game_IsNet
and NetUseMaster
then
4153 if gPlayer2
= nil then
4155 if g_Game_IsClient
then
4157 if NetPlrUID2
> -1 then
4158 gPlayer2
:= g_Player_Get(NetPlrUID2
);
4162 if not (Team
in [TEAM_RED
, TEAM_BLUE
]) then
4163 Team
:= gPlayer2Settings
.Team
;
4165 // Ñîçäàíèå âòîðîãî èãðîêà:
4166 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
4167 gPlayer2Settings
.Color
,
4169 if gPlayer2
= nil then
4170 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]))
4173 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
4174 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [gPlayer2
.Name
]), True);
4175 if g_Game_IsServer
and g_Game_IsNet
then
4176 MH_SEND_PlayerCreate(gPlayer2
.UID
);
4177 gPlayer2
.Respawn(False, True);
4179 if g_Game_IsNet
and NetUseMaster
then
4187 procedure g_Game_RemovePlayer();
4191 if ((not gGameOn
) and (gState
<> STATE_INTERCUSTOM
))
4192 or (not (gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
])) then
4197 if g_Game_IsServer
then
4200 Pl
.Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
4201 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [Pl
.Name
]), True);
4202 g_Player_Remove(Pl
.UID
);
4204 if g_Game_IsNet
and NetUseMaster
then
4213 if g_Game_IsServer
then
4216 Pl
.Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
4217 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [Pl
.Name
]), True);
4218 g_Player_Remove(Pl
.UID
);
4220 if g_Game_IsNet
and NetUseMaster
then
4225 MC_SEND_CheatRequest(NET_CHEAT_SPECTATE
);
4231 procedure g_Game_Spectate();
4233 g_Game_RemovePlayer();
4234 if gPlayer1
<> nil then
4235 g_Game_RemovePlayer();
4238 procedure g_Game_SpectateCenterView();
4240 gSpectX
:= Max(gMapInfo
.Width
div 2 - gScreenWidth
div 2, 0);
4241 gSpectY
:= Max(gMapInfo
.Height
div 2 - gScreenHeight
div 2, 0);
4244 procedure g_Game_StartSingle(Map
: String; TwoPlayers
: Boolean; nPlayers
: Byte);
4251 e_WriteLog('Starting singleplayer game...', TMsgType
.Notify
);
4253 g_Game_ClearLoading();
4256 FillByte(gGameSettings
, SizeOf(TGameSettings
), 0);
4259 gGameSettings
.GameType
:= GT_SINGLE
;
4260 gGameSettings
.MaxLives
:= 0;
4261 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_ALLOWEXIT
;
4262 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_MONSTERS
;
4263 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_BOTVSMONSTER
;
4264 gSwitchGameMode
:= GM_SINGLE
;
4266 g_Game_ExecuteEvent('ongamestart');
4268 // Óñòàíîâêà ðàçìåðîâ îêîí èãðîêîâ:
4269 g_Game_SetupScreenSize();
4271 // Ñîçäàíèå ïåðâîãî èãðîêà:
4272 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4273 gPlayer1Settings
.Color
,
4274 gPlayer1Settings
.Team
, False));
4275 if gPlayer1
= nil then
4277 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
4281 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4284 // Ñîçäàíèå âòîðîãî èãðîêà, åñëè åñòü:
4287 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
4288 gPlayer2Settings
.Color
,
4289 gPlayer2Settings
.Team
, False));
4290 if gPlayer2
= nil then
4292 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
4296 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
4300 // Çàãðóçêà è çàïóñê êàðòû:
4301 if not g_Game_StartMap(MAP
, True) then
4303 if (Pos(':\', Map
) > 0) or (Pos(':/', Map
) > 0) then tmps
:= Map
else tmps
:= gGameSettings
.WAD
+ ':\' + MAP
;
4304 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [tmps
]));
4308 // Íàñòðîéêè èãðîêîâ è áîòîâ:
4312 for i
:= nPl
+1 to nPlayers
do
4313 g_Player_Create(STD_PLAYER_MODEL
, _RGB(0, 0, 0), 0, True);
4316 procedure g_Game_StartCustom(Map
: String; GameMode
: Byte;
4317 TimeLimit
, GoalLimit
: Word;
4319 Options
: LongWord; nPlayers
: Byte);
4325 e_WriteLog('Starting custom game...', TMsgType
.Notify
);
4327 g_Game_ClearLoading();
4330 gGameSettings
.GameType
:= GT_CUSTOM
;
4331 gGameSettings
.GameMode
:= GameMode
;
4332 gSwitchGameMode
:= GameMode
;
4333 gGameSettings
.TimeLimit
:= TimeLimit
;
4334 gGameSettings
.GoalLimit
:= GoalLimit
;
4335 gGameSettings
.MaxLives
:= IfThen(GameMode
= GM_CTF
, 0, MaxLives
);
4336 gGameSettings
.Options
:= Options
;
4338 gCoopTotalMonstersKilled
:= 0;
4339 gCoopTotalSecretsFound
:= 0;
4340 gCoopTotalMonsters
:= 0;
4341 gCoopTotalSecrets
:= 0;
4345 g_Game_ExecuteEvent('ongamestart');
4347 // Óñòàíîâêà ðàçìåðîâ îêîí èãðîêîâ:
4348 g_Game_SetupScreenSize();
4350 // Ðåæèì íàáëþäàòåëÿ:
4351 if nPlayers
= 0 then
4358 if nPlayers
>= 1 then
4360 // Ñîçäàíèå ïåðâîãî èãðîêà:
4361 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4362 gPlayer1Settings
.Color
,
4363 gPlayer1Settings
.Team
, False));
4364 if gPlayer1
= nil then
4366 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
4370 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4374 if nPlayers
>= 2 then
4376 // Ñîçäàíèå âòîðîãî èãðîêà:
4377 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
4378 gPlayer2Settings
.Color
,
4379 gPlayer2Settings
.Team
, False));
4380 if gPlayer2
= nil then
4382 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
4386 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
4390 // Çàãðóçêà è çàïóñê êàðòû:
4391 if not g_Game_StartMap(Map
, True) then
4393 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [Map
]));
4397 // Íåò òî÷åê ïîÿâëåíèÿ:
4398 if (g_Map_GetPointCount(RESPAWNPOINT_PLAYER1
) +
4399 g_Map_GetPointCount(RESPAWNPOINT_PLAYER2
) +
4400 g_Map_GetPointCount(RESPAWNPOINT_DM
) +
4401 g_Map_GetPointCount(RESPAWNPOINT_RED
)+
4402 g_Map_GetPointCount(RESPAWNPOINT_BLUE
)) < 1 then
4404 g_FatalError(_lc
[I_GAME_ERROR_GET_SPAWN
]);
4408 // Íàñòðîéêè èãðîêîâ è áîòîâ:
4412 for i
:= nPl
+1 to nPlayers
do
4413 g_Player_Create(STD_PLAYER_MODEL
, _RGB(0, 0, 0), 0, True);
4416 procedure g_Game_StartServer(Map
: String; GameMode
: Byte;
4417 TimeLimit
, GoalLimit
: Word; MaxLives
: Byte;
4418 Options
: LongWord; nPlayers
: Byte;
4419 IPAddr
: LongWord; Port
: Word);
4423 e_WriteLog('Starting net game (server)...', TMsgType
.Notify
);
4425 g_Game_ClearLoading();
4428 gGameSettings
.GameType
:= GT_SERVER
;
4429 gGameSettings
.GameMode
:= GameMode
;
4430 gSwitchGameMode
:= GameMode
;
4431 gGameSettings
.TimeLimit
:= TimeLimit
;
4432 gGameSettings
.GoalLimit
:= GoalLimit
;
4433 gGameSettings
.MaxLives
:= IfThen(GameMode
= GM_CTF
, 0, MaxLives
);
4434 gGameSettings
.Options
:= Options
;
4436 gCoopTotalMonstersKilled
:= 0;
4437 gCoopTotalSecretsFound
:= 0;
4438 gCoopTotalMonsters
:= 0;
4439 gCoopTotalSecrets
:= 0;
4443 g_Game_ExecuteEvent('ongamestart');
4445 // Óñòàíîâêà ðàçìåðîâ îêíà èãðîêà
4446 g_Game_SetupScreenSize();
4448 // Ðåæèì íàáëþäàòåëÿ:
4449 if nPlayers
= 0 then
4455 if nPlayers
>= 1 then
4457 // Ñîçäàíèå ïåðâîãî èãðîêà:
4458 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4459 gPlayer1Settings
.Color
,
4460 gPlayer1Settings
.Team
, False));
4461 if gPlayer1
= nil then
4463 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
4467 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4470 if nPlayers
>= 2 then
4472 // Ñîçäàíèå âòîðîãî èãðîêà:
4473 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
4474 gPlayer2Settings
.Color
,
4475 gPlayer2Settings
.Team
, False));
4476 if gPlayer2
= nil then
4478 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
4482 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
4485 g_Game_SetLoadingText(_lc
[I_LOAD_HOST
], 0, False);
4486 if NetForwardPorts
then
4487 g_Game_SetLoadingText(_lc
[I_LOAD_PORTS
], 0, False);
4490 if not g_Net_Host(IPAddr
, Port
, NetMaxClients
) then
4492 g_FatalError(_lc
[I_NET_MSG
] + _lc
[I_NET_ERR_HOST
]);
4496 g_Net_Slist_Set(NetSlistIP
, NetSlistPort
);
4498 // Çàãðóçêà è çàïóñê êàðòû:
4499 if not g_Game_StartMap(Map
, True) then
4501 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [Map
]));
4505 // Íåò òî÷åê ïîÿâëåíèÿ:
4506 if (g_Map_GetPointCount(RESPAWNPOINT_PLAYER1
) +
4507 g_Map_GetPointCount(RESPAWNPOINT_PLAYER2
) +
4508 g_Map_GetPointCount(RESPAWNPOINT_DM
) +
4509 g_Map_GetPointCount(RESPAWNPOINT_RED
)+
4510 g_Map_GetPointCount(RESPAWNPOINT_BLUE
)) < 1 then
4512 g_FatalError(_lc
[I_GAME_ERROR_GET_SPAWN
]);
4516 // Íàñòðîéêè èãðîêîâ è áîòîâ:
4519 NetState
:= NET_STATE_GAME
;
4522 procedure g_Game_StartClient(Addr
: String; Port
: Word; PW
: String);
4537 e_WriteLog('Starting net game (client)...', TMsgType
.Notify
);
4538 e_WriteLog('NET: Trying to connect to ' + Addr
+ ':' + IntToStr(Port
) + '...', TMsgType
.Notify
);
4540 g_Game_ClearLoading();
4543 gGameSettings
.GameType
:= GT_CLIENT
;
4545 gCoopTotalMonstersKilled
:= 0;
4546 gCoopTotalSecretsFound
:= 0;
4547 gCoopTotalMonsters
:= 0;
4548 gCoopTotalSecrets
:= 0;
4552 g_Game_ExecuteEvent('ongamestart');
4554 // Óñòàíîâêà ðàçìåðîâ îêîí èãðîêîâ:
4555 g_Game_SetupScreenSize();
4557 NetState
:= NET_STATE_AUTH
;
4559 g_Game_SetLoadingText(_lc
[I_LOAD_CONNECT
], 0, False);
4561 if not g_Net_Connect(Addr
, Port
) then
4563 g_FatalError(_lc
[I_NET_MSG
] + _lc
[I_NET_ERR_CONN
]);
4564 NetState
:= NET_STATE_NONE
;
4568 g_Game_SetLoadingText(_lc
[I_LOAD_SEND_INFO
], 0, False);
4570 g_Game_SetLoadingText(_lc
[I_LOAD_WAIT_INFO
], 0, False);
4575 while (enet_host_service(NetHost
, @NetEvent
, 0) > 0) do
4577 if (NetEvent
.kind
= ENET_EVENT_TYPE_RECEIVE
) then
4579 Ptr
:= NetEvent
.packet
^.data
;
4580 if not InMsg
.Init(Ptr
, NetEvent
.packet
^.dataLength
, True) then
4583 MID
:= InMsg
.ReadByte();
4585 if (MID
= NET_MSG_INFO
) and (State
= 0) then
4587 NetMyID
:= InMsg
.ReadByte();
4588 NetPlrUID1
:= InMsg
.ReadWord();
4590 WadName
:= InMsg
.ReadString();
4591 Map
:= InMsg
.ReadString();
4593 gWADHash
:= InMsg
.ReadMD5();
4595 gGameSettings
.GameMode
:= InMsg
.ReadByte();
4596 gSwitchGameMode
:= gGameSettings
.GameMode
;
4597 gGameSettings
.GoalLimit
:= InMsg
.ReadWord();
4598 gGameSettings
.TimeLimit
:= InMsg
.ReadWord();
4599 gGameSettings
.MaxLives
:= InMsg
.ReadByte();
4600 gGameSettings
.Options
:= InMsg
.ReadLongWord();
4601 T
:= InMsg
.ReadLongWord();
4603 newResPath
:= g_Res_SearchSameWAD(MapsDir
, WadName
, gWADHash
);
4604 if newResPath
= '' then
4606 g_Game_SetLoadingText(_lc
[I_LOAD_DL_RES
], 0, False);
4607 newResPath
:= g_Res_DownloadWAD(WadName
);
4608 if newResPath
= '' then
4610 g_FatalError(_lc
[I_NET_ERR_HASH
]);
4611 enet_packet_destroy(NetEvent
.packet
);
4612 NetState
:= NET_STATE_NONE
;
4616 newResPath
:= ExtractRelativePath(MapsDir
, newResPath
);
4618 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4619 gPlayer1Settings
.Color
,
4620 gPlayer1Settings
.Team
, False));
4622 if gPlayer1
= nil then
4624 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
4626 enet_packet_destroy(NetEvent
.packet
);
4627 NetState
:= NET_STATE_NONE
;
4631 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4632 gPlayer1
.UID
:= NetPlrUID1
;
4633 gPlayer1
.Reset(True);
4635 if not g_Game_StartMap(newResPath
+ ':\' + Map
, True) then
4637 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [WadName
+ ':\' + Map
]));
4639 enet_packet_destroy(NetEvent
.packet
);
4640 NetState
:= NET_STATE_NONE
;
4648 enet_packet_destroy(NetEvent
.packet
);
4652 enet_packet_destroy(NetEvent
.packet
);
4656 if (NetEvent
.kind
= ENET_EVENT_TYPE_DISCONNECT
) then
4659 if (NetEvent
.data
<= NET_DISC_MAX
) then
4660 g_Console_Add(_lc
[I_NET_MSG_ERROR
] + _lc
[I_NET_ERR_CONN
] + ' ' +
4661 _lc
[TStrings_Locale(Cardinal(I_NET_DISC_NONE
) + NetEvent
.data
)], True);
4668 ProcessLoading(true);
4670 if e_KeyPressed(IK_ESCAPE
) or e_KeyPressed(IK_SPACE
) or e_KeyPressed(VK_ESCAPE
) then
4679 g_FatalError(_lc
[I_NET_MSG
] + _lc
[I_NET_ERR_CONN
]);
4680 NetState
:= NET_STATE_NONE
;
4684 gLMSRespawn
:= LMS_RESPAWN_NONE
;
4685 gLMSRespawnTime
:= 0;
4688 NetState
:= NET_STATE_GAME
;
4689 MC_SEND_FullStateRequest
;
4690 e_WriteLog('NET: Connection successful.', TMsgType
.Notify
);
4693 procedure g_Game_SaveOptions();
4695 g_Options_Write_Video(GameDir
+'/'+CONFIG_FILENAME
);
4698 procedure g_Game_ChangeMap(const MapPath
: String);
4702 g_Game_ClearLoading();
4704 Force
:= gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
];
4705 // Åñëè óðîâåíü çàâåðøèëñÿ ïî òðèããåðó Âûõîä, íå î÷èùàòü èíâåíòàðü
4706 if gExitByTrigger
then
4709 gExitByTrigger
:= False;
4711 if not g_Game_StartMap(MapPath
, Force
) then
4712 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [MapPath
]));
4715 procedure g_Game_Restart();
4719 if g_Game_IsClient
then
4721 map
:= g_ExtractFileName(gMapInfo
.Map
);
4725 g_Game_ClearLoading();
4726 g_Game_StartMap(Map
, True, gCurrentMapFileName
);
4729 function g_Game_StartMap(Map
: String; Force
: Boolean = False; const oldMapPath
: AnsiString=''): Boolean;
4731 NewWAD
, ResName
: String;
4734 g_Map_Free((Map
<> gCurrentMapFileName
) and (oldMapPath
<> gCurrentMapFileName
));
4735 g_Player_RemoveAllCorpses();
4737 if (not g_Game_IsClient
) and
4738 (gSwitchGameMode
<> gGameSettings
.GameMode
) and
4739 (gGameSettings
.GameMode
<> GM_SINGLE
) then
4741 if gSwitchGameMode
= GM_CTF
then
4742 gGameSettings
.MaxLives
:= 0;
4743 gGameSettings
.GameMode
:= gSwitchGameMode
;
4746 gSwitchGameMode
:= gGameSettings
.GameMode
;
4748 g_Player_ResetTeams();
4750 if isWadPath(Map
) then
4752 NewWAD
:= g_ExtractWadName(Map
);
4753 ResName
:= g_ExtractFileName(Map
);
4754 if g_Game_IsServer
then
4756 gWADHash
:= MD5File(MapsDir
+ NewWAD
);
4757 g_Game_LoadWAD(NewWAD
);
4759 // hash received in MC_RECV_GameEvent -> NET_EV_MAPSTART
4760 g_Game_ClientWAD(NewWAD
, gWADHash
);
4764 Result
:= g_Map_Load(MapsDir
+ gGameSettings
.WAD
+ ':\' + ResName
);
4767 g_Player_ResetAll(Force
or gLastMap
, gGameSettings
.GameType
= GT_SINGLE
);
4769 gState
:= STATE_NONE
;
4770 g_ActiveWindow
:= nil;
4776 if gGameSettings
.GameMode
= GM_CTF
then
4778 g_Map_ResetFlag(FLAG_RED
);
4779 g_Map_ResetFlag(FLAG_BLUE
);
4780 // CTF, à ôëàãîâ íåò:
4781 if not g_Map_HaveFlagPoints() then
4782 g_SimpleError(_lc
[I_GAME_ERROR_CTF
]);
4787 gState
:= STATE_MENU
;
4792 gPauseMain
:= false;
4793 gPauseHolmes
:= false;
4795 NetTimeToUpdate
:= 1;
4796 NetTimeToReliable
:= 0;
4797 NetTimeToMaster
:= NetMasterRate
;
4798 gLMSRespawn
:= LMS_RESPAWN_NONE
;
4799 gLMSRespawnTime
:= 0;
4800 gMissionFailed
:= False;
4803 gCoopMonstersKilled
:= 0;
4804 gCoopSecretsFound
:= 0;
4806 gVoteInProgress
:= False;
4807 gVotePassed
:= False;
4813 if not gGameOn
then Exit
;
4815 g_Game_SpectateCenterView();
4817 if (gGameSettings
.MaxLives
> 0) and (gGameSettings
.WarmupTime
> 0) then
4819 gLMSRespawn
:= LMS_RESPAWN_WARMUP
;
4820 gLMSRespawnTime
:= gTime
+ gGameSettings
.WarmupTime
*1000;
4821 gLMSSoftSpawn
:= True;
4822 if NetMode
= NET_SERVER
then
4823 MH_SEND_GameEvent(NET_EV_LMS_WARMUP
, (gLMSRespawnTime
- gTime
) div 1000)
4825 g_Console_Add(Format(_lc
[I_MSG_WARMUP_START
], [(gLMSRespawnTime
- gTime
) div 1000]), True);
4828 if NetMode
= NET_SERVER
then
4830 MH_SEND_GameEvent(NET_EV_MAPSTART
, gGameSettings
.GameMode
, Map
);
4833 if NetUseMaster
then
4835 if (NetMHost
= nil) or (NetMPeer
= nil) then
4836 if not g_Net_Slist_Connect
then
4837 g_Console_Add(_lc
[I_NET_MSG_ERROR
] + _lc
[I_NET_SLIST_ERROR
]);
4842 if NetClients
<> nil then
4843 for I
:= 0 to High(NetClients
) do
4844 if NetClients
[I
].Used
then
4846 NetClients
[I
].Voted
:= False;
4847 if NetClients
[I
].RequestedFullUpdate
then
4849 MH_SEND_Everything((NetClients
[I
].State
= NET_STATE_AUTH
), I
);
4850 NetClients
[I
].RequestedFullUpdate
:= False;
4854 g_Net_UnbanNonPermHosts();
4859 gCoopTotalMonstersKilled
:= 0;
4860 gCoopTotalSecretsFound
:= 0;
4861 gCoopTotalMonsters
:= 0;
4862 gCoopTotalSecrets
:= 0;
4866 g_Game_ExecuteEvent('onmapstart');
4869 procedure SetFirstLevel();
4873 MapList
:= g_Map_GetMapsList(MapsDir
+ gGameSettings
.WAD
);
4874 if MapList
= nil then
4877 SortSArray(MapList
);
4878 gNextMap
:= MapList
[Low(MapList
)];
4883 procedure g_Game_ExitLevel(const Map
: AnsiString);
4887 gCoopTotalMonstersKilled
:= gCoopTotalMonstersKilled
+ gCoopMonstersKilled
;
4888 gCoopTotalSecretsFound
:= gCoopTotalSecretsFound
+ gCoopSecretsFound
;
4889 gCoopTotalMonsters
:= gCoopTotalMonsters
+ gTotalMonsters
;
4890 gCoopTotalSecrets
:= gCoopTotalSecrets
+ gSecretsCount
;
4892 // Âûøëè â âûõîä â Îäèíî÷íîé èãðå:
4893 if gGameSettings
.GameType
= GT_SINGLE
then
4894 gExit
:= EXIT_ENDLEVELSINGLE
4895 else // Âûøëè â âûõîä â Ñâîåé èãðå
4897 gExit
:= EXIT_ENDLEVELCUSTOM
;
4898 if gGameSettings
.GameMode
= GM_COOP
then
4899 g_Player_RememberAll
;
4901 if not g_Map_Exist(MapsDir
+ gGameSettings
.WAD
+ ':\' + gNextMap
) then
4904 if gGameSettings
.GameMode
= GM_COOP
then
4907 gStatsPressed
:= True;
4908 gNextMap
:= 'MAP01';
4910 if not g_Map_Exist(MapsDir
+ gGameSettings
.WAD
+ ':\' + gNextMap
) then
4913 if g_Game_IsNet
then
4915 MH_SEND_GameStats();
4916 MH_SEND_CoopStats();
4922 procedure g_Game_RestartLevel();
4926 if gGameSettings
.GameMode
= GM_SINGLE
then
4931 gExit
:= EXIT_ENDLEVELCUSTOM
;
4932 Map
:= g_ExtractFileName(gMapInfo
.Map
);
4936 procedure g_Game_ClientWAD(NewWAD
: String; WHash
: TMD5Digest
);
4940 if LowerCase(NewWAD
) = LowerCase(gGameSettings
.WAD
) then
4942 if not g_Game_IsClient
then
4944 gWAD
:= g_Res_SearchSameWAD(MapsDir
, ExtractFileName(NewWAD
), WHash
);
4947 g_Game_SetLoadingText(_lc
[I_LOAD_DL_RES
], 0, False);
4948 gWAD
:= g_Res_DownloadWAD(ExtractFileName(NewWAD
));
4952 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_WAD
], [ExtractFileName(NewWAD
)]));
4956 NewWAD
:= ExtractRelativePath(MapsDir
, gWAD
);
4957 g_Game_LoadWAD(NewWAD
);
4960 procedure g_Game_RestartRound(NoMapRestart
: Boolean = False);
4962 i
, n
, nb
, nr
: Integer;
4964 function monRespawn (mon
: TMonster
): Boolean;
4966 result
:= false; // don't stop
4967 if not mon
.FNoRespawn
then mon
.Respawn();
4971 if not g_Game_IsServer
then Exit
;
4972 if gLMSRespawn
= LMS_RESPAWN_NONE
then Exit
;
4973 gLMSRespawn
:= LMS_RESPAWN_NONE
;
4974 gLMSRespawnTime
:= 0;
4977 if (gGameSettings
.GameMode
= GM_COOP
) and not NoMapRestart
then
4979 gMissionFailed
:= True;
4980 g_Game_RestartLevel
;
4984 n
:= 0; nb
:= 0; nr
:= 0;
4985 for i
:= Low(gPlayers
) to High(gPlayers
) do
4986 if (gPlayers
[i
] <> nil) and
4987 ((not gPlayers
[i
].FSpectator
) or gPlayers
[i
].FWantsInGame
or
4988 (gPlayers
[i
] is TBot
)) then
4991 if gPlayers
[i
].Team
= TEAM_RED
then Inc(nr
)
4992 else if gPlayers
[i
].Team
= TEAM_BLUE
then Inc(nb
)
4995 if (n
< 2) or ((gGameSettings
.GameMode
= GM_TDM
) and ((nr
= 0) or (nb
= 0))) then
4997 // wait a second until the fuckers finally decide to join
4998 gLMSRespawn
:= LMS_RESPAWN_WARMUP
;
4999 gLMSRespawnTime
:= gTime
+ 1000;
5000 gLMSSoftSpawn
:= NoMapRestart
;
5004 g_Player_RemoveAllCorpses
;
5005 g_Game_Message(_lc
[I_MESSAGE_LMS_START
], 144);
5006 if g_Game_IsNet
then
5007 MH_SEND_GameEvent(NET_EV_LMS_START
);
5009 for i
:= Low(gPlayers
) to High(gPlayers
) do
5011 if gPlayers
[i
] = nil then continue
;
5012 if gPlayers
[i
] is TBot
then gPlayers
[i
].FWantsInGame
:= True;
5013 // don't touch normal spectators
5014 if gPlayers
[i
].FSpectator
and not gPlayers
[i
].FWantsInGame
then
5016 gPlayers
[i
].FNoRespawn
:= True;
5017 gPlayers
[i
].Lives
:= 0;
5018 if g_Game_IsNet
then
5019 MH_SEND_PlayerStats(gPlayers
[I
].UID
);
5022 gPlayers
[i
].FNoRespawn
:= False;
5023 gPlayers
[i
].Lives
:= gGameSettings
.MaxLives
;
5024 gPlayers
[i
].Respawn(False, True);
5025 if gGameSettings
.GameMode
= GM_COOP
then
5027 gPlayers
[i
].Frags
:= 0;
5028 gPlayers
[i
].RecallState
;
5030 if (gPlayer1
= nil) and (gLMSPID1
> 0) then
5031 gPlayer1
:= g_Player_Get(gLMSPID1
);
5032 if (gPlayer2
= nil) and (gLMSPID2
> 0) then
5033 gPlayer2
:= g_Player_Get(gLMSPID2
);
5036 g_Items_RestartRound();
5039 g_Mons_ForEach(monRespawn
);
5041 gLMSSoftSpawn
:= False;
5044 function g_Game_GetFirstMap(WAD
: String): String;
5048 MapList
:= g_Map_GetMapsList(WAD
);
5049 if MapList
= nil then
5052 SortSArray(MapList
);
5053 Result
:= MapList
[Low(MapList
)];
5055 if not g_Map_Exist(WAD
+ ':\' + Result
) then
5061 function g_Game_GetNextMap(): String;
5068 MapList
:= g_Map_GetMapsList(MapsDir
+ gGameSettings
.WAD
);
5069 if MapList
= nil then
5072 Map
:= g_ExtractFileName(gMapInfo
.Map
);
5074 SortSArray(MapList
);
5076 for I
:= Low(MapList
) to High(MapList
) do
5077 if Map
= MapList
[I
] then
5083 if MapIndex
<> -255 then
5085 if MapIndex
= High(MapList
) then
5086 Result
:= MapList
[Low(MapList
)]
5088 Result
:= MapList
[MapIndex
+ 1];
5090 if not g_Map_Exist(MapsDir
+ gGameSettings
.WAD
+ ':\' + Result
) then Result
:= Map
;
5096 procedure g_Game_NextLevel();
5098 if gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
, GM_COOP
] then
5099 gExit
:= EXIT_ENDLEVELCUSTOM
5102 gExit
:= EXIT_ENDLEVELSINGLE
;
5106 if gNextMap
<> '' then Exit
;
5107 gNextMap
:= g_Game_GetNextMap();
5110 function g_Game_IsTestMap(): Boolean;
5112 result
:= StrEquCI1251(TEST_MAP_NAME
, g_ExtractFileName(gMapInfo
.Map
));
5115 procedure g_Game_DeleteTestMap();
5118 //MapName: AnsiString;
5126 a
:= Pos('.wad:\', toLowerCase1251(gMapToDelete
));
5127 if (a
= 0) then a
:= Pos('.wad:/', toLowerCase1251(gMapToDelete
));
5128 if (a
= 0) then exit
;
5130 // Âûäåëÿåì èìÿ wad-ôàéëà è èìÿ êàðòû
5131 WadName
:= Copy(gMapToDelete
, 1, a
+3);
5132 Delete(gMapToDelete
, 1, a
+5);
5133 gMapToDelete
:= UpperCase(gMapToDelete
);
5135 //CopyMemory(@MapName[0], @gMapToDelete[1], Min(16, Length(gMapToDelete)));
5138 // Èìÿ êàðòû íå ñòàíäàðòíîå òåñòîâîå:
5139 if MapName <> TEST_MAP_NAME then
5142 if not gTempDelete then
5144 time := g_GetFileTime(WadName);
5145 WAD := TWADFile.Create();
5148 if not WAD.ReadFile(WadName) then
5149 begin // Íåò òàêîãî WAD-ôàéëà
5154 // Ñîñòàâëÿåì ñïèñîê êàðò è èùåì íóæíóþ:
5156 MapList := WAD.GetResourcesList('');
5158 if MapList <> nil then
5159 for a := 0 to High(MapList) do
5160 if MapList[a] = MapName then
5162 // Óäàëÿåì è ñîõðàíÿåì:
5163 WAD.RemoveResource('', MapName);
5164 WAD.SaveTo(WadName);
5169 g_SetFileTime(WadName, time);
5172 if gTempDelete
then DeleteFile(WadName
);
5175 procedure GameCVars(P
: SSArray
);
5178 stat
: TPlayerStatArray
;
5183 cmd
:= LowerCase(P
[0]);
5184 if cmd
= 'r_showfps' then
5186 if (Length(P
) > 1) and
5187 ((P
[1] = '1') or (P
[1] = '0')) then
5188 gShowFPS
:= (P
[1][1] = '1');
5191 g_Console_Add(_lc
[I_MSG_SHOW_FPS_ON
])
5193 g_Console_Add(_lc
[I_MSG_SHOW_FPS_OFF
]);
5195 else if (cmd
= 'g_friendlyfire') and not g_Game_IsClient
then
5197 with gGameSettings
do
5199 if (Length(P
) > 1) and
5200 ((P
[1] = '1') or (P
[1] = '0')) then
5202 if (P
[1][1] = '1') then
5203 Options
:= Options
or GAME_OPTION_TEAMDAMAGE
5205 Options
:= Options
and (not GAME_OPTION_TEAMDAMAGE
);
5208 if (LongBool(Options
and GAME_OPTION_TEAMDAMAGE
)) then
5209 g_Console_Add(_lc
[I_MSG_FRIENDLY_FIRE_ON
])
5211 g_Console_Add(_lc
[I_MSG_FRIENDLY_FIRE_OFF
]);
5213 if g_Game_IsNet
then MH_SEND_GameSettings
;
5216 else if (cmd
= 'g_weaponstay') and not g_Game_IsClient
then
5218 with gGameSettings
do
5220 if (Length(P
) > 1) and
5221 ((P
[1] = '1') or (P
[1] = '0')) then
5223 if (P
[1][1] = '1') then
5224 Options
:= Options
or GAME_OPTION_WEAPONSTAY
5226 Options
:= Options
and (not GAME_OPTION_WEAPONSTAY
);
5229 if (LongBool(Options
and GAME_OPTION_WEAPONSTAY
)) then
5230 g_Console_Add(_lc
[I_MSG_WEAPONSTAY_ON
])
5232 g_Console_Add(_lc
[I_MSG_WEAPONSTAY_OFF
]);
5234 if g_Game_IsNet
then MH_SEND_GameSettings
;
5237 else if cmd
= 'g_gamemode' then
5239 a
:= g_Game_TextToMode(P
[1]);
5240 if a
= GM_SINGLE
then a
:= GM_COOP
;
5241 if (Length(P
) > 1) and (a
<> GM_NONE
) and (not g_Game_IsClient
) then
5243 gSwitchGameMode
:= a
;
5244 if (gGameOn
and (gGameSettings
.GameMode
= GM_SINGLE
)) or
5245 (gState
= STATE_INTERSINGLE
) then
5246 gSwitchGameMode
:= GM_SINGLE
;
5248 gGameSettings
.GameMode
:= gSwitchGameMode
;
5250 if gSwitchGameMode
= gGameSettings
.GameMode
then
5251 g_Console_Add(Format(_lc
[I_MSG_GAMEMODE_CURRENT
],
5252 [g_Game_ModeToText(gGameSettings
.GameMode
)]))
5254 g_Console_Add(Format(_lc
[I_MSG_GAMEMODE_CHANGE
],
5255 [g_Game_ModeToText(gGameSettings
.GameMode
),
5256 g_Game_ModeToText(gSwitchGameMode
)]));
5258 else if (cmd
= 'g_allow_exit') and not g_Game_IsClient
then
5260 with gGameSettings
do
5262 if (Length(P
) > 1) and
5263 ((P
[1] = '1') or (P
[1] = '0')) then
5265 if (P
[1][1] = '1') then
5266 Options
:= Options
or GAME_OPTION_ALLOWEXIT
5268 Options
:= Options
and (not GAME_OPTION_ALLOWEXIT
);
5271 if (LongBool(Options
and GAME_OPTION_ALLOWEXIT
)) then
5272 g_Console_Add(_lc
[I_MSG_ALLOWEXIT_ON
])
5274 g_Console_Add(_lc
[I_MSG_ALLOWEXIT_OFF
]);
5275 g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
5277 if g_Game_IsNet
then MH_SEND_GameSettings
;
5280 else if (cmd
= 'g_allow_monsters') and not g_Game_IsClient
then
5282 with gGameSettings
do
5284 if (Length(P
) > 1) and
5285 ((P
[1] = '1') or (P
[1] = '0')) then
5287 if (P
[1][1] = '1') then
5288 Options
:= Options
or GAME_OPTION_MONSTERS
5290 Options
:= Options
and (not GAME_OPTION_MONSTERS
);
5293 if (LongBool(Options
and GAME_OPTION_MONSTERS
)) then
5294 g_Console_Add(_lc
[I_MSG_ALLOWMON_ON
])
5296 g_Console_Add(_lc
[I_MSG_ALLOWMON_OFF
]);
5297 g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
5299 if g_Game_IsNet
then MH_SEND_GameSettings
;
5302 else if (cmd
= 'g_bot_vsplayers') and not g_Game_IsClient
then
5304 with gGameSettings
do
5306 if (Length(P
) > 1) and
5307 ((P
[1] = '1') or (P
[1] = '0')) then
5309 if (P
[1][1] = '1') then
5310 Options
:= Options
or GAME_OPTION_BOTVSPLAYER
5312 Options
:= Options
and (not GAME_OPTION_BOTVSPLAYER
);
5315 if (LongBool(Options
and GAME_OPTION_BOTVSPLAYER
)) then
5316 g_Console_Add(_lc
[I_MSG_BOTSVSPLAYERS_ON
])
5318 g_Console_Add(_lc
[I_MSG_BOTSVSPLAYERS_OFF
]);
5320 if g_Game_IsNet
then MH_SEND_GameSettings
;
5323 else if (cmd
= 'g_bot_vsmonsters') and not g_Game_IsClient
then
5325 with gGameSettings
do
5327 if (Length(P
) > 1) and
5328 ((P
[1] = '1') or (P
[1] = '0')) then
5330 if (P
[1][1] = '1') then
5331 Options
:= Options
or GAME_OPTION_BOTVSMONSTER
5333 Options
:= Options
and (not GAME_OPTION_BOTVSMONSTER
);
5336 if (LongBool(Options
and GAME_OPTION_BOTVSMONSTER
)) then
5337 g_Console_Add(_lc
[I_MSG_BOTSVSMONSTERS_ON
])
5339 g_Console_Add(_lc
[I_MSG_BOTSVSMONSTERS_OFF
]);
5341 if g_Game_IsNet
then MH_SEND_GameSettings
;
5344 else if (cmd
= 'g_warmuptime') and not g_Game_IsClient
then
5346 if Length(P
) > 1 then
5348 if StrToIntDef(P
[1], gGameSettings
.WarmupTime
) = 0 then
5349 gGameSettings
.WarmupTime
:= 30
5351 gGameSettings
.WarmupTime
:= StrToIntDef(P
[1], gGameSettings
.WarmupTime
);
5354 g_Console_Add(Format(_lc
[I_MSG_WARMUP
],
5355 [gGameSettings
.WarmupTime
]));
5356 g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
5358 else if cmd
= 'net_interp' then
5360 if (Length(P
) > 1) then
5361 NetInterpLevel
:= StrToIntDef(P
[1], NetInterpLevel
);
5363 g_Console_Add('net_interp = ' + IntToStr(NetInterpLevel
));
5364 config
:= TConfig
.CreateFile(GameDir
+'/'+CONFIG_FILENAME
);
5365 config
.WriteInt('Client', 'InterpolationSteps', NetInterpLevel
);
5366 config
.SaveFile(GameDir
+'/'+CONFIG_FILENAME
);
5369 else if cmd
= 'net_forceplayerupdate' then
5371 if (Length(P
) > 1) and
5372 ((P
[1] = '1') or (P
[1] = '0')) then
5373 NetForcePlayerUpdate
:= (P
[1][1] = '1');
5375 if NetForcePlayerUpdate
then
5376 g_Console_Add('net_forceplayerupdate = 1')
5378 g_Console_Add('net_forceplayerupdate = 0');
5379 config
:= TConfig
.CreateFile(GameDir
+'/'+CONFIG_FILENAME
);
5380 config
.WriteBool('Client', 'ForcePlayerUpdate', NetForcePlayerUpdate
);
5381 config
.SaveFile(GameDir
+'/'+CONFIG_FILENAME
);
5384 else if cmd
= 'net_predictself' then
5386 if (Length(P
) > 1) and
5387 ((P
[1] = '1') or (P
[1] = '0')) then
5388 NetPredictSelf
:= (P
[1][1] = '1');
5390 if NetPredictSelf
then
5391 g_Console_Add('net_predictself = 1')
5393 g_Console_Add('net_predictself = 0');
5394 config
:= TConfig
.CreateFile(GameDir
+'/'+CONFIG_FILENAME
);
5395 config
.WriteBool('Client', 'PredictSelf', NetPredictSelf
);
5396 config
.SaveFile(GameDir
+'/'+CONFIG_FILENAME
);
5399 else if cmd
= 'sv_name' then
5401 if (Length(P
) > 1) and (Length(P
[1]) > 0) then
5403 NetServerName
:= P
[1];
5404 if Length(NetServerName
) > 64 then
5405 SetLength(NetServerName
, 64);
5406 if g_Game_IsServer
and g_Game_IsNet
and NetUseMaster
then
5410 g_Console_Add(cmd
+ ' = "' + NetServerName
+ '"');
5412 else if cmd
= 'sv_passwd' then
5414 if (Length(P
) > 1) and (Length(P
[1]) > 0) then
5416 NetPassword
:= P
[1];
5417 if Length(NetPassword
) > 24 then
5418 SetLength(NetPassword
, 24);
5419 if g_Game_IsServer
and g_Game_IsNet
and NetUseMaster
then
5423 g_Console_Add(cmd
+ ' = "' + AnsiLowerCase(NetPassword
) + '"');
5425 else if cmd
= 'sv_maxplrs' then
5427 if (Length(P
) > 1) then
5429 NetMaxClients
:= Min(Max(StrToIntDef(P
[1], NetMaxClients
), 1), NET_MAXCLIENTS
);
5430 if g_Game_IsServer
and g_Game_IsNet
then
5433 for a
:= 0 to High(NetClients
) do
5434 if NetClients
[a
].Used
then
5437 if b
> NetMaxClients
then
5439 s
:= g_Player_Get(NetClients
[a
].Player
).Name
;
5440 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_FULL
);
5441 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
5442 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
5445 if NetUseMaster
then
5450 g_Console_Add(cmd
+ ' = ' + IntToStr(NetMaxClients
));
5452 else if cmd
= 'sv_public' then
5454 if (Length(P
) > 1) then
5456 NetUseMaster
:= StrToIntDef(P
[1], Byte(NetUseMaster
)) > 0;
5457 if g_Game_IsServer
and g_Game_IsNet
then
5458 if NetUseMaster
then
5460 if NetMPeer
= nil then
5461 if not g_Net_Slist_Connect() then
5462 g_Console_Add(_lc
[I_NET_MSG_ERROR
] + _lc
[I_NET_SLIST_ERROR
]);
5463 g_Net_Slist_Update();
5466 if NetMPeer
<> nil then
5467 g_Net_Slist_Disconnect();
5470 g_Console_Add(cmd
+ ' = ' + IntToStr(Byte(NetUseMaster
)));
5472 else if cmd
= 'sv_intertime' then
5474 if (Length(P
) > 1) then
5475 gDefInterTime
:= Min(Max(StrToIntDef(P
[1], gDefInterTime
), -1), 120);
5477 g_Console_Add(cmd
+ ' = ' + IntToStr(gDefInterTime
));
5479 else if cmd
= 'p1_name' then
5481 if (Length(P
) > 1) and gGameOn
then
5483 if g_Game_IsClient
then
5485 gPlayer1Settings
.Name
:= b_Text_Unformat(P
[1]);
5486 MC_SEND_PlayerSettings
;
5489 if gPlayer1
<> nil then
5491 gPlayer1
.Name
:= b_Text_Unformat(P
[1]);
5492 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer1
.UID
);
5495 gPlayer1Settings
.Name
:= b_Text_Unformat(P
[1]);
5498 else if cmd
= 'p2_name' then
5500 if (Length(P
) > 1) and gGameOn
then
5502 if g_Game_IsClient
then
5504 gPlayer2Settings
.Name
:= b_Text_Unformat(P
[1]);
5505 MC_SEND_PlayerSettings
;
5508 if gPlayer2
<> nil then
5510 gPlayer2
.Name
:= b_Text_Unformat(P
[1]);
5511 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer2
.UID
);
5514 gPlayer2Settings
.Name
:= b_Text_Unformat(P
[1]);
5517 else if cmd
= 'p1_color' then
5519 if Length(P
) > 3 then
5520 if g_Game_IsClient
then
5522 gPlayer1Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
5523 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
5524 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
5525 MC_SEND_PlayerSettings
;
5528 if gPlayer1
<> nil then
5530 gPlayer1
.Model
.SetColor(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
5531 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
5532 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
5533 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer1
.UID
);
5536 gPlayer1Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
5537 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
5538 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
5540 else if (cmd
= 'p2_color') and not g_Game_IsNet
then
5542 if Length(P
) > 3 then
5543 if g_Game_IsClient
then
5545 gPlayer2Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
5546 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
5547 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
5548 MC_SEND_PlayerSettings
;
5551 if gPlayer2
<> nil then
5553 gPlayer2
.Model
.SetColor(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
5554 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
5555 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
5556 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer2
.UID
);
5559 gPlayer2Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
5560 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
5561 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
5563 else if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
5565 if cmd
= 'r_showtime' then
5567 if (Length(P
) > 1) and
5568 ((P
[1] = '1') or (P
[1] = '0')) then
5569 gShowTime
:= (P
[1][1] = '1');
5572 g_Console_Add(_lc
[I_MSG_TIME_ON
])
5574 g_Console_Add(_lc
[I_MSG_TIME_OFF
]);
5576 else if cmd
= 'r_showscore' then
5578 if (Length(P
) > 1) and
5579 ((P
[1] = '1') or (P
[1] = '0')) then
5580 gShowGoals
:= (P
[1][1] = '1');
5583 g_Console_Add(_lc
[I_MSG_SCORE_ON
])
5585 g_Console_Add(_lc
[I_MSG_SCORE_OFF
]);
5587 else if cmd
= 'r_showstat' then
5589 if (Length(P
) > 1) and
5590 ((P
[1] = '1') or (P
[1] = '0')) then
5591 gShowStat
:= (P
[1][1] = '1');
5594 g_Console_Add(_lc
[I_MSG_STATS_ON
])
5596 g_Console_Add(_lc
[I_MSG_STATS_OFF
]);
5598 else if cmd
= 'r_showkillmsg' then
5600 if (Length(P
) > 1) and
5601 ((P
[1] = '1') or (P
[1] = '0')) then
5602 gShowKillMsg
:= (P
[1][1] = '1');
5604 if gShowKillMsg
then
5605 g_Console_Add(_lc
[I_MSG_KILL_MSGS_ON
])
5607 g_Console_Add(_lc
[I_MSG_KILL_MSGS_OFF
]);
5609 else if cmd
= 'r_showlives' then
5611 if (Length(P
) > 1) and
5612 ((P
[1] = '1') or (P
[1] = '0')) then
5613 gShowLives
:= (P
[1][1] = '1');
5616 g_Console_Add(_lc
[I_MSG_LIVES_ON
])
5618 g_Console_Add(_lc
[I_MSG_LIVES_OFF
]);
5620 else if cmd
= 'r_showspect' then
5622 if (Length(P
) > 1) and
5623 ((P
[1] = '1') or (P
[1] = '0')) then
5624 gSpectHUD
:= (P
[1][1] = '1');
5627 g_Console_Add(_lc
[I_MSG_SPECT_HUD_ON
])
5629 g_Console_Add(_lc
[I_MSG_SPECT_HUD_OFF
]);
5631 else if cmd
= 'r_showping' then
5633 if (Length(P
) > 1) and
5634 ((P
[1] = '1') or (P
[1] = '0')) then
5635 gShowPing
:= (P
[1][1] = '1');
5638 g_Console_Add(_lc
[I_MSG_PING_ON
])
5640 g_Console_Add(_lc
[I_MSG_PING_OFF
]);
5642 else if (cmd
= 'g_scorelimit') and not g_Game_IsClient
then
5644 if Length(P
) > 1 then
5646 if StrToIntDef(P
[1], gGameSettings
.GoalLimit
) = 0 then
5647 gGameSettings
.GoalLimit
:= 0
5652 if gGameSettings
.GameMode
= GM_DM
then
5654 stat
:= g_Player_GetStats();
5656 for a
:= 0 to High(stat
) do
5657 if stat
[a
].Frags
> b
then
5661 b
:= Max(gTeamStat
[TEAM_RED
].Goals
, gTeamStat
[TEAM_BLUE
].Goals
);
5663 gGameSettings
.GoalLimit
:= Max(StrToIntDef(P
[1], gGameSettings
.GoalLimit
), b
);
5666 if g_Game_IsNet
then MH_SEND_GameSettings
;
5669 g_Console_Add(Format(_lc
[I_MSG_SCORE_LIMIT
], [gGameSettings
.GoalLimit
]));
5671 else if (cmd
= 'g_timelimit') and not g_Game_IsClient
then
5673 if (Length(P
) > 1) and (StrToIntDef(P
[1], -1) >= 0) then
5674 gGameSettings
.TimeLimit
:= StrToIntDef(P
[1], -1);
5676 g_Console_Add(Format(_lc
[I_MSG_TIME_LIMIT
],
5677 [gGameSettings
.TimeLimit
div 3600,
5678 (gGameSettings
.TimeLimit
div 60) mod 60,
5679 gGameSettings
.TimeLimit
mod 60]));
5680 if g_Game_IsNet
then MH_SEND_GameSettings
;
5682 else if (cmd
= 'g_maxlives') and not g_Game_IsClient
then
5684 if Length(P
) > 1 then
5686 if StrToIntDef(P
[1], gGameSettings
.MaxLives
) = 0 then
5687 gGameSettings
.MaxLives
:= 0
5691 stat
:= g_Player_GetStats();
5693 for a
:= 0 to High(stat
) do
5694 if stat
[a
].Lives
> b
then
5696 gGameSettings
.MaxLives
:=
5697 Max(StrToIntDef(P
[1], gGameSettings
.MaxLives
), b
);
5701 g_Console_Add(Format(_lc
[I_MSG_LIVES
],
5702 [gGameSettings
.MaxLives
]));
5703 if g_Game_IsNet
then MH_SEND_GameSettings
;
5708 procedure PrintHeapStats();
5712 hs
:= GetFPCHeapStatus();
5713 e_LogWriteLn ('v===== heap status =====v');
5714 e_LogWriteFln('max heap size = %d k', [hs
.MaxHeapSize
div 1024]);
5715 e_LogWriteFln('max heap used = %d k', [hs
.MaxHeapUsed
div 1024]);
5716 e_LogWriteFln('cur heap size = %d k', [hs
.CurrHeapSize
div 1024]);
5717 e_LogWriteFln('cur heap used = %d k', [hs
.CurrHeapUsed
div 1024]);
5718 e_LogWriteFln('cur heap free = %d k', [hs
.CurrHeapFree
div 1024]);
5719 e_LogWriteLn ('^=======================^');
5722 procedure DebugCommands(P
: SSArray
);
5729 // Êîìàíäû îòëàäî÷íîãî ðåæèìà:
5730 if {gDebugMode}conIsCheatsEnabled
then
5732 cmd
:= LowerCase(P
[0]);
5733 if cmd
= 'd_window' then
5735 g_Console_Add(Format('gWinPosX = %d, gWinPosY %d', [gWinPosX
, gWinPosY
]));
5736 g_Console_Add(Format('gWinRealPosX = %d, gWinRealPosY %d', [gWinRealPosX
, gWinRealPosY
]));
5737 g_Console_Add(Format('gScreenWidth = %d, gScreenHeight = %d', [gScreenWidth
, gScreenHeight
]));
5738 g_Console_Add(Format('gWinSizeX = %d, gWinSizeY = %d', [gWinSizeX
, gWinSizeY
]));
5739 g_Console_Add(Format('Frame X = %d, Y = %d, Caption Y = %d', [gWinFrameX
, gWinFrameY
, gWinCaption
]));
5741 else if cmd
= 'd_sounds' then
5743 if (Length(P
) > 1) and
5744 ((P
[1] = '1') or (P
[1] = '0')) then
5745 g_Debug_Sounds
:= (P
[1][1] = '1');
5747 g_Console_Add(Format('d_sounds is %d', [Byte(g_Debug_Sounds
)]));
5749 else if cmd
= 'd_frames' then
5751 if (Length(P
) > 1) and
5752 ((P
[1] = '1') or (P
[1] = '0')) then
5753 g_Debug_Frames
:= (P
[1][1] = '1');
5755 g_Console_Add(Format('d_frames is %d', [Byte(g_Debug_Frames
)]));
5757 else if cmd
= 'd_winmsg' then
5759 if (Length(P
) > 1) and
5760 ((P
[1] = '1') or (P
[1] = '0')) then
5761 g_Debug_WinMsgs
:= (P
[1][1] = '1');
5763 g_Console_Add(Format('d_winmsg is %d', [Byte(g_Debug_WinMsgs
)]));
5765 else if (cmd
= 'd_monoff') and not g_Game_IsNet
then
5767 if (Length(P
) > 1) and
5768 ((P
[1] = '1') or (P
[1] = '0')) then
5769 g_Debug_MonsterOff
:= (P
[1][1] = '1');
5771 g_Console_Add(Format('d_monoff is %d', [Byte(g_debug_MonsterOff
)]));
5773 else if (cmd
= 'd_botoff') and not g_Game_IsNet
then
5775 if Length(P
) > 1 then
5777 '0': g_debug_BotAIOff
:= 0;
5778 '1': g_debug_BotAIOff
:= 1;
5779 '2': g_debug_BotAIOff
:= 2;
5780 '3': g_debug_BotAIOff
:= 3;
5783 g_Console_Add(Format('d_botoff is %d', [g_debug_BotAIOff
]));
5785 else if cmd
= 'd_monster' then
5787 if gGameOn
and (gPlayer1
<> nil) and (gPlayer1
.alive
) and (not g_Game_IsNet
) then
5788 if Length(P
) < 2 then
5790 g_Console_Add(cmd
+ ' [ID | Name] [behaviour]');
5791 g_Console_Add('ID | Name');
5792 for b
:= MONSTER_DEMON
to MONSTER_MAN
do
5793 g_Console_Add(Format('%2d | %s', [b
, g_Mons_NameByTypeId(b
)]));
5794 conwriteln('behav. num'#10'normal 0'#10'killer 1'#10'maniac 2'#10'insane 3'#10'cannibal 4'#10'good 5');
5797 a
:= StrToIntDef(P
[1], 0);
5798 if (a
< MONSTER_DEMON
) or (a
> MONSTER_MAN
) then
5799 a
:= g_Mons_TypeIdByName(P
[1]);
5801 if (a
< MONSTER_DEMON
) or (a
> MONSTER_MAN
) then
5802 g_Console_Add(Format(_lc
[I_MSG_NO_MONSTER
], [P
[1]]))
5805 with gPlayer1
.Obj
do
5807 mon
:= g_Monsters_Create(a
,
5808 X
+ Rect
.X
+ (Rect
.Width
div 2),
5809 Y
+ Rect
.Y
+ Rect
.Height
,
5810 gPlayer1
.Direction
, True);
5812 if (Length(P
) > 2) and (mon
<> nil) then
5814 if (CompareText(P
[2], 'normal') = 0) then mon
.MonsterBehaviour
:= BH_NORMAL
5815 else if (CompareText(P
[2], 'killer') = 0) then mon
.MonsterBehaviour
:= BH_KILLER
5816 else if (CompareText(P
[2], 'maniac') = 0) then mon
.MonsterBehaviour
:= BH_MANIAC
5817 else if (CompareText(P
[2], 'insane') = 0) then mon
.MonsterBehaviour
:= BH_INSANE
5818 else if (CompareText(P
[2], 'cannibal') = 0) then mon
.MonsterBehaviour
:= BH_CANNIBAL
5819 else if (CompareText(P
[2], 'good') = 0) then mon
.MonsterBehaviour
:= BH_GOOD
5820 else if (CompareText(P
[2], 'friend') = 0) then mon
.MonsterBehaviour
:= BH_GOOD
5821 else if (CompareText(P
[2], 'friendly') = 0) then mon
.MonsterBehaviour
:= BH_GOOD
5822 else mon
.MonsterBehaviour
:= Min(Max(StrToIntDef(P
[2], BH_NORMAL
), BH_NORMAL
), BH_GOOD
);
5827 else if (cmd
= 'd_health') then
5829 if (Length(P
) > 1) and
5830 ((P
[1] = '1') or (P
[1] = '0')) then
5831 g_debug_HealthBar
:= (P
[1][1] = '1');
5833 g_Console_Add(Format('d_health is %d', [Byte(g_debug_HealthBar
)]));
5835 else if (cmd
= 'd_player') then
5837 if (Length(P
) > 1) and
5838 ((P
[1] = '1') or (P
[1] = '0')) then
5839 g_debug_Player
:= (P
[1][1] = '1');
5841 g_Console_Add(Format(cmd
+ ' is %d', [Byte(g_Debug_Player
)]));
5843 else if (cmd
= 'd_joy') then
5846 g_Console_Add(e_JoystickStateToString(a
));
5848 else if (cmd
= 'd_mem') then
5854 g_Console_Add(_lc
[I_MSG_NOT_DEBUG
]);
5858 procedure GameCheats(P
: SSArray
);
5864 if (not gGameOn
) or (not conIsCheatsEnabled
) then
5866 g_Console_Add('not available');
5872 g_Console_Add('where is the player?!');
5875 cmd
:= LowerCase(P
[0]);
5879 plr
.GodMode
:= not plr
.GodMode
;
5880 if plr
.GodMode
then g_Console_Add('player is godlike now') else g_Console_Add('player is mortal now');
5883 // give <health|exit|weapons|air|suit|jetpack|berserk|all>
5884 if cmd
= 'give' then
5886 if length(P
) < 2 then begin g_Console_Add('give what?!'); exit
; end;
5887 for f
:= 1 to High(P
) do
5889 cmd
:= LowerCase(P
[f
]);
5890 if cmd
= 'health' then begin plr
.RestoreHealthArmor(); g_Console_Add('player feels himself better'); continue
; end;
5891 if (cmd
= 'all') {or (cmd = 'weapons')} then begin plr
.AllRulez(False); g_Console_Add('player got the gifts'); continue
; end;
5892 if cmd
= 'exit' then
5894 if gTriggers
<> nil then
5896 for a
:= 0 to High(gTriggers
) do
5898 if gTriggers
[a
].TriggerType
= TRIGGER_EXIT
then
5900 g_Console_Add('player left the map');
5901 gExitByTrigger
:= True;
5902 //g_Game_ExitLevel(gTriggers[a].Data.MapName);
5903 g_Game_ExitLevel(gTriggers
[a
].tgcMap
);
5911 if cmd
= 'air' then begin plr
.GiveItem(ITEM_OXYGEN
); g_Console_Add('player got some air'); continue
; end;
5912 if cmd
= 'jetpack' then begin plr
.GiveItem(ITEM_JETPACK
); g_Console_Add('player got a jetpack'); continue
; end;
5913 if cmd
= 'suit' then begin plr
.GiveItem(ITEM_SUIT
); g_Console_Add('player got an envirosuit'); continue
; end;
5914 if cmd
= 'berserk' then begin plr
.GiveItem(ITEM_MEDKIT_BLACK
); g_Console_Add('player got a berserk pack'); continue
; end;
5915 if cmd
= 'backpack' then begin plr
.GiveItem(ITEM_AMMO_BACKPACK
); g_Console_Add('player got a backpack'); continue
; end;
5917 if cmd
= 'helmet' then begin plr
.GiveItem(ITEM_HELMET
); g_Console_Add('player got a helmet'); continue
; end;
5918 if cmd
= 'bottle' then begin plr
.GiveItem(ITEM_BOTTLE
); g_Console_Add('player got a bottle of health'); continue
; end;
5920 if cmd
= 'stimpack' then begin plr
.GiveItem(ITEM_MEDKIT_SMALL
); g_Console_Add('player got a stimpack'); continue
; end;
5921 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;
5923 if cmd
= 'greenarmor' then begin plr
.GiveItem(ITEM_ARMOR_GREEN
); g_Console_Add('player got a security armor'); continue
; end;
5924 if cmd
= 'bluearmor' then begin plr
.GiveItem(ITEM_ARMOR_BLUE
); g_Console_Add('player got a combat armor'); continue
; end;
5926 if (cmd
= 'megasphere') or (cmd
= 'mega') then begin plr
.GiveItem(ITEM_SPHERE_BLUE
); g_Console_Add('player got a megasphere'); continue
; end;
5927 if (cmd
= 'soulsphere') or (cmd
= 'soul')then begin plr
.GiveItem(ITEM_SPHERE_WHITE
); g_Console_Add('player got a soul sphere'); continue
; end;
5929 if (cmd
= 'invul') or (cmd
= 'invulnerability') then begin plr
.GiveItem(ITEM_INVUL
); g_Console_Add('player got invulnerability'); continue
; end;
5930 if (cmd
= 'invis') or (cmd
= 'invisibility') then begin plr
.GiveItem(ITEM_INVIS
); g_Console_Add('player got invisibility'); continue
; end;
5932 if cmd
= 'redkey' then begin plr
.GiveItem(ITEM_KEY_RED
); g_Console_Add('player got the red key'); continue
; end;
5933 if cmd
= 'greenkey' then begin plr
.GiveItem(ITEM_KEY_GREEN
); g_Console_Add('player got the green key'); continue
; end;
5934 if cmd
= 'bluekey' then begin plr
.GiveItem(ITEM_KEY_BLUE
); g_Console_Add('player got the blue key'); continue
; end;
5936 if (cmd
= 'shotgun') or (cmd
= 'sg') then begin plr
.GiveItem(ITEM_WEAPON_SHOTGUN1
); g_Console_Add('player got a shotgun'); continue
; end;
5937 if (cmd
= 'supershotgun') or (cmd
= 'ssg') then begin plr
.GiveItem(ITEM_WEAPON_SHOTGUN2
); g_Console_Add('player got a supershotgun'); continue
; end;
5938 if cmd
= 'chaingun' then begin plr
.GiveItem(ITEM_WEAPON_CHAINGUN
); g_Console_Add('player got a chaingun'); continue
; end;
5939 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;
5940 if cmd
= 'plasmagun' then begin plr
.GiveItem(ITEM_WEAPON_PLASMA
); g_Console_Add('player got a plasma gun'); continue
; end;
5941 if cmd
= 'bfg' then begin plr
.GiveItem(ITEM_WEAPON_BFG
); g_Console_Add('player got a BFG-9000'); continue
; end;
5943 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;
5944 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;
5945 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;
5946 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;
5947 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;
5948 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;
5950 if cmd
= 'superchaingun' then begin plr
.GiveItem(ITEM_WEAPON_SUPERPULEMET
); g_Console_Add('player got a superchaingun'); continue
; end;
5951 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;
5953 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;
5954 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;
5956 if cmd
= 'chainsaw' then begin plr
.GiveItem(ITEM_WEAPON_SAW
); g_Console_Add('player got a chainsaw'); continue
; end;
5958 if cmd
= 'ammo' then
5960 plr
.GiveItem(ITEM_AMMO_SHELLS_BOX
);
5961 plr
.GiveItem(ITEM_AMMO_BULLETS_BOX
);
5962 plr
.GiveItem(ITEM_AMMO_CELL_BIG
);
5963 plr
.GiveItem(ITEM_AMMO_ROCKET_BOX
);
5964 plr
.GiveItem(ITEM_AMMO_FUELCAN
);
5965 g_Console_Add('player got some ammo');
5969 if cmd
= 'clip' then begin plr
.GiveItem(ITEM_AMMO_BULLETS
); g_Console_Add('player got some bullets'); continue
; end;
5970 if cmd
= 'bullets' then begin plr
.GiveItem(ITEM_AMMO_BULLETS_BOX
); g_Console_Add('player got a box of bullets'); continue
; end;
5972 if cmd
= 'shells' then begin plr
.GiveItem(ITEM_AMMO_SHELLS
); g_Console_Add('player got some shells'); continue
; end;
5973 if cmd
= 'shellbox' then begin plr
.GiveItem(ITEM_AMMO_SHELLS_BOX
); g_Console_Add('player got a box of shells'); continue
; end;
5975 if cmd
= 'cells' then begin plr
.GiveItem(ITEM_AMMO_CELL
); g_Console_Add('player got some cells'); continue
; end;
5976 if cmd
= 'battery' then begin plr
.GiveItem(ITEM_AMMO_CELL_BIG
); g_Console_Add('player got cell battery'); continue
; end;
5978 if cmd
= 'rocket' then begin plr
.GiveItem(ITEM_AMMO_ROCKET
); g_Console_Add('player got a rocket'); continue
; end;
5979 if cmd
= 'rocketbox' then begin plr
.GiveItem(ITEM_AMMO_ROCKET_BOX
); g_Console_Add('player got some rockets'); continue
; end;
5981 if (cmd
= 'fuel') or (cmd
= 'fuelcan') then begin plr
.GiveItem(ITEM_AMMO_FUELCAN
); g_Console_Add('player got fuel canister'); continue
; end;
5983 if cmd
= 'weapons' then
5985 plr
.GiveItem(ITEM_WEAPON_SHOTGUN1
);
5986 plr
.GiveItem(ITEM_WEAPON_SHOTGUN2
);
5987 plr
.GiveItem(ITEM_WEAPON_CHAINGUN
);
5988 plr
.GiveItem(ITEM_WEAPON_ROCKETLAUNCHER
);
5989 plr
.GiveItem(ITEM_WEAPON_PLASMA
);
5990 plr
.GiveItem(ITEM_WEAPON_BFG
);
5991 g_Console_Add('player got weapons');
5995 if cmd
= 'keys' then
5997 plr
.GiveItem(ITEM_KEY_RED
);
5998 plr
.GiveItem(ITEM_KEY_GREEN
);
5999 plr
.GiveItem(ITEM_KEY_BLUE
);
6000 g_Console_Add('player got all keys');
6004 g_Console_Add('i don''t know how to give '''+cmd
+'''!');
6009 if cmd
= 'open' then
6011 g_Console_Add('player activated sesame');
6012 g_Triggers_OpenAll();
6019 if gFly
then g_Console_Add('player feels himself lighter') else g_Console_Add('player lost his wings');
6023 if cmd
= 'noclip' then
6026 g_Console_Add('wall hardeness adjusted');
6030 if cmd
= 'notarget' then
6032 plr
.NoTarget
:= not plr
.NoTarget
;
6033 if plr
.NoTarget
then g_Console_Add('player hides in shadows') else g_Console_Add('player is brave again');
6037 if cmd
= 'noreload' then
6039 plr
.NoReload
:= not plr
.NoReload
;
6040 if plr
.NoReload
then g_Console_Add('player is action hero now') else g_Console_Add('player is ordinary man now');
6044 if cmd
= 'speedy' then
6046 MAX_RUNVEL
:= 32-MAX_RUNVEL
;
6047 g_Console_Add('speed adjusted');
6051 if cmd
= 'jumpy' then
6053 VEL_JUMP
:= 30-VEL_JUMP
;
6054 g_Console_Add('jump height adjusted');
6058 if cmd
= 'automap' then
6060 gShowMap
:= not gShowMap
;
6061 if gShowMap
then g_Console_Add('player gains second sight') else g_Console_Add('player lost second sight');
6065 if cmd
= 'aimline' then
6067 gAimLine
:= not gAimLine
;
6068 if gAimLine
then g_Console_Add('player gains laser sight') else g_Console_Add('player lost laser sight');
6073 procedure GameCommands(P
: SSArray
);
6079 pl
: pTNetClient
= nil;
6086 cmd
:= LowerCase(P
[0]);
6088 if (cmd
= 'quit') or
6095 else if cmd
= 'pause' then
6097 if (g_ActiveWindow
= nil) then
6098 g_Game_Pause(not gPauseMain
);
6100 else if cmd
= 'endgame' then
6101 gExit
:= EXIT_SIMPLE
6102 else if cmd
= 'restart' then
6104 if gGameOn
or (gState
in [STATE_INTERSINGLE
, STATE_INTERCUSTOM
]) then
6106 if g_Game_IsClient
then
6108 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6113 g_Console_Add(_lc
[I_MSG_NOT_GAME
]);
6115 else if cmd
= 'kick' then
6117 if g_Game_IsServer
then
6119 if Length(P
) < 2 then
6121 g_Console_Add('kick <name>');
6126 g_Console_Add('kick <name>');
6130 if g_Game_IsNet
then
6131 pl
:= g_Net_Client_ByName(P
[1]);
6134 s
:= g_Net_ClientName_ByID(pl
^.ID
);
6135 enet_peer_disconnect(pl
^.Peer
, NET_DISC_KICK
);
6136 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
6137 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
6138 if NetUseMaster
then
6140 end else if gPlayers
<> nil then
6141 for a
:= Low(gPlayers
) to High(gPlayers
) do
6142 if gPlayers
[a
] <> nil then
6143 if Copy(LowerCase(gPlayers
[a
].Name
), 1, Length(P
[1])) = LowerCase(P
[1]) then
6145 // Íå îòêëþ÷àòü îñíîâíûõ èãðîêîâ â ñèíãëå
6146 if not(gPlayers
[a
] is TBot
) and (gGameSettings
.GameType
= GT_SINGLE
) then
6148 gPlayers
[a
].Lives
:= 0;
6149 gPlayers
[a
].Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
6150 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [gPlayers
[a
].Name
]), True);
6151 g_Player_Remove(gPlayers
[a
].UID
);
6152 if NetUseMaster
then
6154 // Åñëè íå ïåðåìåøàòü, ïðè äîáàâëåíèè íîâûõ áîòîâ ïîÿâÿòñÿ ñòàðûå
6158 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6160 else if cmd
= 'kick_id' then
6162 if g_Game_IsServer
and g_Game_IsNet
then
6164 if Length(P
) < 2 then
6166 g_Console_Add('kick_id <client ID>');
6171 g_Console_Add('kick_id <client ID>');
6175 a
:= StrToIntDef(P
[1], 0);
6176 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
6178 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
6180 s
:= g_Net_ClientName_ByID(NetClients
[a
].ID
);
6181 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_KICK
);
6182 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
6183 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
6184 if NetUseMaster
then
6189 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6191 else if cmd
= 'ban' then
6193 if g_Game_IsServer
and g_Game_IsNet
then
6195 if Length(P
) < 2 then
6197 g_Console_Add('ban <name>');
6202 g_Console_Add('ban <name>');
6206 pl
:= g_Net_Client_ByName(P
[1]);
6209 s
:= g_Net_ClientName_ByID(pl
^.ID
);
6210 g_Net_BanHost(pl
^.Peer
^.address
.host
, False);
6211 enet_peer_disconnect(pl
^.Peer
, NET_DISC_TEMPBAN
);
6212 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
6213 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
6214 if NetUseMaster
then
6217 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
6219 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6221 else if cmd
= 'ban_id' then
6223 if g_Game_IsServer
and g_Game_IsNet
then
6225 if Length(P
) < 2 then
6227 g_Console_Add('ban_id <client ID>');
6232 g_Console_Add('ban_id <client ID>');
6236 a
:= StrToIntDef(P
[1], 0);
6237 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
6238 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
6240 s
:= g_Net_ClientName_ByID(NetClients
[a
].ID
);
6241 g_Net_BanHost(NetClients
[a
].Peer
^.address
.host
, False);
6242 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_TEMPBAN
);
6243 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
6244 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
6245 if NetUseMaster
then
6249 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6251 else if cmd
= 'permban' then
6253 if g_Game_IsServer
and g_Game_IsNet
then
6255 if Length(P
) < 2 then
6257 g_Console_Add('permban <name>');
6262 g_Console_Add('permban <name>');
6266 pl
:= g_Net_Client_ByName(P
[1]);
6269 s
:= g_Net_ClientName_ByID(pl
^.ID
);
6270 g_Net_BanHost(pl
^.Peer
^.address
.host
);
6271 enet_peer_disconnect(pl
^.Peer
, NET_DISC_BAN
);
6272 g_Net_SaveBanList();
6273 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
6274 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
6275 if NetUseMaster
then
6278 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
6280 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6282 else if cmd
= 'permban_id' then
6284 if g_Game_IsServer
and g_Game_IsNet
then
6286 if Length(P
) < 2 then
6288 g_Console_Add('permban_id <client ID>');
6293 g_Console_Add('permban_id <client ID>');
6297 a
:= StrToIntDef(P
[1], 0);
6298 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
6299 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
6301 s
:= g_Net_ClientName_ByID(NetClients
[a
].ID
);
6302 g_Net_BanHost(NetClients
[a
].Peer
^.address
.host
);
6303 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_BAN
);
6304 g_Net_SaveBanList();
6305 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
6306 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
6307 if NetUseMaster
then
6311 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6313 else if cmd
= 'unban' then
6315 if g_Game_IsServer
and g_Game_IsNet
then
6317 if Length(P
) < 2 then
6319 g_Console_Add('unban <IP Address>');
6324 g_Console_Add('unban <IP Address>');
6328 if g_Net_UnbanHost(P
[1]) then
6330 g_Console_Add(Format(_lc
[I_MSG_UNBAN_OK
], [P
[1]]));
6331 g_Net_SaveBanList();
6333 g_Console_Add(Format(_lc
[I_MSG_UNBAN_FAIL
], [P
[1]]));
6335 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6337 else if cmd
= 'clientlist' then
6339 if g_Game_IsServer
and g_Game_IsNet
then
6342 if NetClients
<> nil then
6343 for a
:= Low(NetClients
) to High(NetClients
) do
6344 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
6346 plr
:= g_Player_Get(NetClients
[a
].Player
);
6347 if plr
= nil then continue
;
6349 g_Console_Add(Format('#%2d: %-15s | %s', [a
,
6350 IpToStr(NetClients
[a
].Peer
^.address
.host
), plr
.Name
]));
6353 g_Console_Add(_lc
[I_MSG_NOCLIENTS
]);
6355 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6357 else if cmd
= 'connect' then
6359 if (NetMode
= NET_NONE
) then
6361 if Length(P
) < 2 then
6363 g_Console_Add('connect <IP> [port] [password]');
6368 g_Console_Add('connect <IP> [port] [password]');
6372 if Length(P
) > 2 then
6373 prt
:= StrToIntDef(P
[2], 25666)
6377 if Length(P
) > 3 then
6382 g_Game_StartClient(P
[1], prt
, pw
);
6385 else if cmd
= 'disconnect' then
6387 if (NetMode
= NET_CLIENT
) then
6390 else if cmd
= 'reconnect' then
6392 if (NetMode
= NET_SERVER
) then
6395 if (NetMode
= NET_CLIENT
) then
6398 gExit
:= EXIT_SIMPLE
;
6402 //TODO: Use last successful password to reconnect, instead of ''
6403 g_Game_StartClient(NetClientIP
, NetClientPort
, '');
6405 else if (cmd
= 'addbot') or
6406 (cmd
= 'bot_add') then
6408 if Length(P
) > 1 then
6409 g_Bot_Add(TEAM_NONE
, StrToIntDef(P
[1], 2))
6411 g_Bot_Add(TEAM_NONE
, 2);
6413 else if cmd
= 'bot_addlist' then
6415 if Length(P
) > 1 then
6416 if Length(P
) = 2 then
6417 g_Bot_AddList(TEAM_NONE
, P
[1], StrToIntDef(P
[1], -1))
6419 g_Bot_AddList(IfThen(P
[2] = 'red', TEAM_RED
, TEAM_BLUE
), P
[1], StrToIntDef(P
[1], -1));
6421 else if cmd
= 'bot_removeall' then
6423 else if cmd
= 'chat' then
6425 if g_Game_IsNet
then
6427 if Length(P
) > 1 then
6429 for a
:= 1 to High(P
) do
6430 chstr
:= chstr
+ P
[a
] + ' ';
6432 if Length(chstr
) > 200 then SetLength(chstr
, 200);
6434 if Length(chstr
) < 1 then
6436 g_Console_Add('chat <text>');
6440 chstr
:= b_Text_Format(chstr
);
6441 if g_Game_IsClient
then
6442 MC_SEND_Chat(chstr
, NET_CHAT_PLAYER
)
6444 MH_SEND_Chat(gPlayer1Settings
.Name
+ ': ' + chstr
, NET_CHAT_PLAYER
);
6447 g_Console_Add('chat <text>');
6449 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6451 else if cmd
= 'teamchat' then
6453 if g_Game_IsNet
and (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
6455 if Length(P
) > 1 then
6457 for a
:= 1 to High(P
) do
6458 chstr
:= chstr
+ P
[a
] + ' ';
6460 if Length(chstr
) > 200 then SetLength(chstr
, 200);
6462 if Length(chstr
) < 1 then
6464 g_Console_Add('teamchat <text>');
6468 chstr
:= b_Text_Format(chstr
);
6469 if g_Game_IsClient
then
6470 MC_SEND_Chat(chstr
, NET_CHAT_TEAM
)
6472 MH_SEND_Chat(gPlayer1Settings
.Name
+ ': ' + chstr
, NET_CHAT_TEAM
,
6473 gPlayer1Settings
.Team
);
6476 g_Console_Add('teamchat <text>');
6478 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6480 else if cmd
= 'game' then
6482 if gGameSettings
.GameType
<> GT_NONE
then
6484 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6487 if Length(P
) = 1 then
6489 g_Console_Add(cmd
+ ' <WAD> [MAP] [# players]');
6492 // Èãðà åù¸ íå çàïóùåíà, ñíà÷àëà íàì íàäî çàãðóçèòü êàêîé-òî WAD
6493 P
[1] := addWadExtension(P
[1]);
6494 if FileExists(MapsDir
+ P
[1]) then
6496 // Åñëè êàðòà íå óêàçàíà, áåð¸ì ïåðâóþ êàðòó â ôàéëå
6497 if Length(P
) < 3 then
6500 P
[2] := g_Game_GetFirstMap(MapsDir
+ P
[1]);
6503 s
:= P
[1] + ':\' + UpperCase(P
[2]);
6505 if g_Map_Exist(MapsDir
+ s
) then
6507 // Çàïóñêàåì ñâîþ èãðó
6509 with gGameSettings
do
6511 GameMode
:= g_Game_TextToMode(gcGameMode
);
6512 if gSwitchGameMode
<> GM_NONE
then
6513 GameMode
:= gSwitchGameMode
;
6514 if GameMode
= GM_NONE
then GameMode
:= GM_DM
;
6515 if GameMode
= GM_SINGLE
then GameMode
:= GM_COOP
;
6517 if Length(P
) >= 4 then
6518 b
:= StrToIntDef(P
[3], 1);
6519 g_Game_StartCustom(s
, GameMode
, TimeLimit
,
6520 GoalLimit
, MaxLives
, Options
, b
);
6525 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
6527 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [UpperCase(P
[2]), P
[1]]));
6529 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]));
6531 else if cmd
= 'host' then
6533 if gGameSettings
.GameType
<> GT_NONE
then
6535 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6538 if Length(P
) < 4 then
6540 g_Console_Add(cmd
+ ' <listen IP> <port> <WAD> [MAP] [# players]');
6543 if not StrToIp(P
[1], listen
) then
6545 prt
:= StrToIntDef(P
[2], 25666);
6547 P
[3] := addWadExtension(P
[3]);
6548 if FileExists(MapsDir
+ P
[3]) then
6550 // Åñëè êàðòà íå óêàçàíà, áåð¸ì ïåðâóþ êàðòó â ôàéëå
6551 if Length(P
) < 5 then
6554 P
[4] := g_Game_GetFirstMap(MapsDir
+ P
[1]);
6557 s
:= P
[3] + ':\' + UpperCase(P
[4]);
6559 if g_Map_Exist(MapsDir
+ s
) then
6561 // Çàïóñêàåì ñâîþ èãðó
6563 with gGameSettings
do
6565 GameMode
:= g_Game_TextToMode(gcGameMode
);
6566 if gSwitchGameMode
<> GM_NONE
then
6567 GameMode
:= gSwitchGameMode
;
6568 if GameMode
= GM_NONE
then GameMode
:= GM_DM
;
6569 if GameMode
= GM_SINGLE
then GameMode
:= GM_COOP
;
6571 if Length(P
) >= 6 then
6572 b
:= StrToIntDef(P
[5], 0);
6573 g_Game_StartServer(s
, GameMode
, TimeLimit
,
6574 GoalLimit
, MaxLives
, Options
, b
, listen
, prt
);
6579 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[3]]))
6581 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [UpperCase(P
[4]), P
[3]]));
6583 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[3]]));
6585 else if cmd
= 'map' then
6587 if Length(P
) = 1 then
6589 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
6591 g_Console_Add(cmd
+ ' <MAP>');
6592 g_Console_Add(cmd
+ ' <WAD> [MAP]');
6594 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6596 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
6598 // Èä¸ò ñâîÿ èãðà èëè ñåðâåð
6599 if Length(P
) < 3 then
6601 // Ïåðâûé ïàðàìåòð - ëèáî êàðòà, ëèáî èìÿ WAD ôàéëà
6602 s
:= UpperCase(P
[1]);
6603 if g_Map_Exist(MapsDir
+ gGameSettings
.WAD
+ ':\' + s
) then
6604 begin // Êàðòà íàøëàñü
6605 gExitByTrigger
:= False;
6607 begin // Èä¸ò èãðà - çàâåðøàåì óðîâåíü
6609 gExit
:= EXIT_ENDLEVELCUSTOM
;
6611 else // Èíòåðìèññèÿ - ñðàçó çàãðóæàåì êàðòó
6612 g_Game_ChangeMap(s
);
6615 // Òàêîé êàðòû íåò, èùåì WAD ôàéë
6616 P
[1] := addWadExtension(P
[1]);
6617 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [s
, P
[1]]));
6618 if FileExists(MapsDir
+ P
[1]) then
6620 // Ïàðàìåòðà êàðòû íåò, ïîýòîìó ñòàâèì ïåðâóþ èç ôàéëà
6622 P
[2] := g_Game_GetFirstMap(MapsDir
+ P
[1]);
6624 s
:= P
[1] + ':\' + P
[2];
6626 if g_Map_Exist(MapsDir
+ s
) then
6628 gExitByTrigger
:= False;
6630 begin // Èä¸ò èãðà - çàâåðøàåì óðîâåíü
6632 gExit
:= EXIT_ENDLEVELCUSTOM
;
6634 else // Èíòåðìèññèÿ - ñðàçó çàãðóæàåì êàðòó
6635 g_Game_ChangeMap(s
);
6638 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
6640 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]));
6642 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]));
6646 // Óêàçàíî äâà ïàðàìåòðà, çíà÷èò ïåðâûé - WAD ôàéë, à âòîðîé - êàðòà
6647 P
[1] := addWadExtension(P
[1]);
6648 if FileExists(MapsDir
+ P
[1]) then
6651 P
[2] := UpperCase(P
[2]);
6652 s
:= P
[1] + ':\' + P
[2];
6654 if g_Map_Exist(MapsDir
+ s
) then
6655 begin // Íàøëè êàðòó
6656 gExitByTrigger
:= False;
6658 begin // Èä¸ò èãðà - çàâåðøàåì óðîâåíü
6660 gExit
:= EXIT_ENDLEVELCUSTOM
;
6662 else // Èíòåðìèññèÿ - ñðàçó çàãðóæàåì êàðòó
6663 g_Game_ChangeMap(s
);
6665 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]));
6667 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]));
6670 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6672 else if cmd
= 'nextmap' then
6674 if not(gGameOn
or (gState
= STATE_INTERCUSTOM
)) then
6675 g_Console_Add(_lc
[I_MSG_NOT_GAME
])
6678 if Length(P
) = 1 then
6680 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
6682 g_Console_Add(cmd
+ ' <MAP>');
6683 g_Console_Add(cmd
+ ' <WAD> [MAP]');
6686 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6691 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
6693 if Length(P
) < 3 then
6695 // Ïåðâûé ïàðàìåòð - ëèáî êàðòà, ëèáî èìÿ WAD ôàéëà
6696 s
:= UpperCase(P
[1]);
6697 if g_Map_Exist(MapsDir
+ gGameSettings
.WAD
+ ':\' + s
) then
6698 begin // Êàðòà íàøëàñü
6699 gExitByTrigger
:= False;
6704 // Òàêîé êàðòû íåò, èùåì WAD ôàéë
6705 P
[1] := addWadExtension(P
[1]);
6706 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [s
, P
[1]]));
6707 if FileExists(MapsDir
+ P
[1]) then
6709 // Ïàðàìåòðà êàðòû íåò, ïîýòîìó ñòàâèì ïåðâóþ èç ôàéëà
6711 P
[2] := g_Game_GetFirstMap(MapsDir
+ P
[1]);
6713 s
:= P
[1] + ':\' + P
[2];
6715 if g_Map_Exist(MapsDir
+ s
) then
6716 begin // Óñòàíàâëèâàåì êàðòó
6717 gExitByTrigger
:= False;
6722 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
6724 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]));
6726 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]));
6730 // Óêàçàíî äâà ïàðàìåòðà, çíà÷èò ïåðâûé - WAD ôàéë, à âòîðîé - êàðòà
6731 P
[1] := addWadExtension(P
[1]);
6732 if FileExists(MapsDir
+ P
[1]) then
6735 P
[2] := UpperCase(P
[2]);
6736 s
:= P
[1] + ':\' + P
[2];
6738 if g_Map_Exist(MapsDir
+ s
) then
6739 begin // Íàøëè êàðòó
6740 gExitByTrigger
:= False;
6744 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]));
6746 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]));
6749 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6752 if gNextMap
= '' then
6753 g_Console_Add(_lc
[I_MSG_NEXTMAP_UNSET
])
6755 g_Console_Add(Format(_lc
[I_MSG_NEXTMAP_SET
], [gNextMap
]));
6758 else if (cmd
= 'endmap') or (cmd
= 'goodbye') then
6761 g_Console_Add(_lc
[I_MSG_NOT_GAME
])
6763 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
6765 gExitByTrigger
:= False;
6766 // Ñëåäóþùàÿ êàðòà íå çàäàíà, ïðîáóåì íàéòè òðèããåð Âûõîä
6767 if (gNextMap
= '') and (gTriggers
<> nil) then
6768 for a
:= 0 to High(gTriggers
) do
6769 if gTriggers
[a
].TriggerType
= TRIGGER_EXIT
then
6771 gExitByTrigger
:= True;
6772 //gNextMap := gTriggers[a].Data.MapName;
6773 gNextMap
:= gTriggers
[a
].tgcMap
;
6776 // Èùåì ñëåäóþùóþ êàðòó â WAD ôàéëå
6777 if gNextMap
= '' then
6778 gNextMap
:= g_Game_GetNextMap();
6779 // Ïðîâåðÿåì, íå çàäàí ëè WAD ôàéë ðåñóðñíîé ñòðîêîé
6780 if not isWadPath(gNextMap
) then
6781 s
:= gGameSettings
.WAD
+ ':\' + gNextMap
6784 // Åñëè êàðòà íàéäåíà, âûõîäèì ñ óðîâíÿ
6785 if g_Map_Exist(MapsDir
+ s
) then
6786 gExit
:= EXIT_ENDLEVELCUSTOM
6788 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [gNextMap
]));
6790 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6792 else if (cmd
= 'event') then
6794 if (Length(P
) <= 1) then
6796 for a
:= 0 to High(gEvents
) do
6797 if gEvents
[a
].Command
= '' then
6798 g_Console_Add(gEvents
[a
].Name
+ ' <none>')
6800 g_Console_Add(gEvents
[a
].Name
+ ' "' + gEvents
[a
].Command
+ '"');
6803 if (Length(P
) = 2) then
6805 for a
:= 0 to High(gEvents
) do
6806 if gEvents
[a
].Name
= P
[1] then
6807 if gEvents
[a
].Command
= '' then
6808 g_Console_Add(gEvents
[a
].Name
+ ' <none>')
6810 g_Console_Add(gEvents
[a
].Name
+ ' "' + gEvents
[a
].Command
+ '"');
6813 for a
:= 0 to High(gEvents
) do
6814 if gEvents
[a
].Name
= P
[1] then
6816 gEvents
[a
].Command
:= '';
6817 for b
:= 2 to High(P
) do
6818 if Pos(' ', P
[b
]) = 0 then
6819 gEvents
[a
].Command
:= gEvents
[a
].Command
+ ' ' + P
[b
]
6821 gEvents
[a
].Command
:= gEvents
[a
].Command
+ ' "' + P
[b
] + '"';
6822 gEvents
[a
].Command
:= Trim(gEvents
[a
].Command
);
6826 else if cmd
= 'suicide' then
6830 if g_Game_IsClient
then
6831 MC_SEND_CheatRequest(NET_CHEAT_SUICIDE
)
6834 if gPlayer1
<> nil then
6835 gPlayer1
.Damage(SUICIDE_DAMAGE
, gPlayer1
.UID
, 0, 0, HIT_SELF
);
6836 if gPlayer2
<> nil then
6837 gPlayer2
.Damage(SUICIDE_DAMAGE
, gPlayer2
.UID
, 0, 0, HIT_SELF
);
6841 // Êîìàíäû Ñâîåé èãðû:
6842 else if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
6844 if cmd
= 'bot_addred' then
6846 if Length(P
) > 1 then
6847 g_Bot_Add(TEAM_RED
, StrToIntDef(P
[1], 2))
6849 g_Bot_Add(TEAM_RED
, 2);
6851 else if cmd
= 'bot_addblue' then
6853 if Length(P
) > 1 then
6854 g_Bot_Add(TEAM_BLUE
, StrToIntDef(P
[1], 2))
6856 g_Bot_Add(TEAM_BLUE
, 2);
6858 else if cmd
= 'spectate' then
6864 else if cmd
= 'say' then
6866 if g_Game_IsServer
and g_Game_IsNet
then
6868 if Length(P
) > 1 then
6871 for a
:= 1 to High(P
) do
6872 chstr
:= chstr
+ P
[a
] + ' ';
6874 if Length(chstr
) > 200 then SetLength(chstr
, 200);
6876 if Length(chstr
) < 1 then
6878 g_Console_Add('say <text>');
6882 chstr
:= b_Text_Format(chstr
);
6883 MH_SEND_Chat(chstr
, NET_CHAT_PLAYER
);
6885 else g_Console_Add('say <text>');
6887 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6889 else if cmd
= 'tell' then
6891 if g_Game_IsServer
and g_Game_IsNet
then
6893 if (Length(P
) > 2) and (P
[1] <> '') then
6896 for a
:= 2 to High(P
) do
6897 chstr
:= chstr
+ P
[a
] + ' ';
6899 if Length(chstr
) > 200 then SetLength(chstr
, 200);
6901 if Length(chstr
) < 1 then
6903 g_Console_Add('tell <playername> <text>');
6907 pl
:= g_Net_Client_ByName(P
[1]);
6909 MH_SEND_Chat(b_Text_Format(chstr
), NET_CHAT_PLAYER
, pl
^.ID
)
6911 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
6913 else g_Console_Add('tell <playername> <text>');
6915 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6917 else if (cmd
= 'overtime') and not g_Game_IsClient
then
6919 if (Length(P
) = 1) or (StrToIntDef(P
[1], -1) <= 0) then
6921 // Äîïîëíèòåëüíîå âðåìÿ:
6922 gGameSettings
.TimeLimit
:= (gTime
- gGameStartTime
) div 1000 + Word(StrToIntDef(P
[1], 0));
6924 g_Console_Add(Format(_lc
[I_MSG_TIME_LIMIT
],
6925 [gGameSettings
.TimeLimit
div 3600,
6926 (gGameSettings
.TimeLimit
div 60) mod 60,
6927 gGameSettings
.TimeLimit
mod 60]));
6928 if g_Game_IsNet
then MH_SEND_GameSettings
;
6930 else if (cmd
= 'rcon_password') and g_Game_IsClient
then
6932 if (Length(P
) <= 1) then
6933 g_Console_Add('rcon_password <password>')
6935 MC_SEND_RCONPassword(P
[1]);
6937 else if cmd
= 'rcon' then
6939 if g_Game_IsClient
then
6941 if Length(P
) > 1 then
6944 for a
:= 1 to High(P
) do
6945 chstr
:= chstr
+ P
[a
] + ' ';
6947 if Length(chstr
) > 200 then SetLength(chstr
, 200);
6949 if Length(chstr
) < 1 then
6951 g_Console_Add('rcon <command>');
6955 MC_SEND_RCONCommand(chstr
);
6957 else g_Console_Add('rcon <command>');
6960 else if cmd
= 'ready' then
6962 if g_Game_IsServer
and (gLMSRespawn
= LMS_RESPAWN_WARMUP
) then
6963 gLMSRespawnTime
:= gTime
+ 100;
6965 else if (cmd
= 'callvote') and g_Game_IsNet
then
6967 if Length(P
) > 1 then
6970 for a
:= 1 to High(P
) do begin
6971 if a
> 1 then chstr
:= chstr
+ ' ';
6972 chstr
:= chstr
+ P
[a
];
6975 if Length(chstr
) > 200 then SetLength(chstr
, 200);
6977 if Length(chstr
) < 1 then
6979 g_Console_Add('callvote <command>');
6983 if g_Game_IsClient
then
6984 MC_SEND_Vote(True, chstr
)
6986 g_Game_StartVote(chstr
, gPlayer1Settings
.Name
);
6987 g_Console_Process('vote', True);
6990 g_Console_Add('callvote <command>');
6992 else if (cmd
= 'vote') and g_Game_IsNet
then
6994 if g_Game_IsClient
then
6996 else if gVoteInProgress
then
6998 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
6999 a
:= Floor((NetClientCount
+1)/2.0) + 1
7001 a
:= Floor(NetClientCount
/2.0) + 1;
7006 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_REVOKED
], [gPlayer1Settings
.Name
, gVoteCount
, a
]), True);
7007 MH_SEND_VoteEvent(NET_VE_REVOKE
, gPlayer1Settings
.Name
, 'a', gVoteCount
, a
);
7013 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_VOTE
], [gPlayer1Settings
.Name
, gVoteCount
, a
]), True);
7014 MH_SEND_VoteEvent(NET_VE_VOTE
, gPlayer1Settings
.Name
, 'a', gVoteCount
, a
);
7022 procedure g_TakeScreenShot();
7030 if e_NoGraphics
then Exit
;
7031 ssdir
:= GameDir
+'/screenshots';
7032 if not findFileCI(ssdir
, true) then
7034 // try to create dir
7039 if not findFileCI(ssdir
, true) then exit
; // alas
7042 for a
:= 1 to High(Word) do
7044 FileName
:= Format(ssdir
+'screenshot%.3d.png', [a
]);
7046 if findFileCI(t
, true) then continue
;
7047 if not findFileCI(FileName
) then
7050 st
:= createDiskFile(FileName
);
7052 e_MakeScreenshot(st
, gScreenWidth
, gScreenHeight
);
7057 if not ok
then try DeleteFile(FileName
); except end else g_Console_Add(Format(_lc
[I_CONSOLE_SCREENSHOT
], [ExtractFileName(FileName
)]));
7065 procedure g_Game_InGameMenu(Show
: Boolean);
7067 if (g_ActiveWindow
= nil) and Show
then
7069 if gGameSettings
.GameType
= GT_SINGLE
then
7070 g_GUI_ShowWindow('GameSingleMenu')
7073 if g_Game_IsClient
then
7074 g_GUI_ShowWindow('GameClientMenu')
7076 if g_Game_IsNet
then
7077 g_GUI_ShowWindow('GameServerMenu')
7079 g_GUI_ShowWindow('GameCustomMenu');
7081 g_Sound_PlayEx('MENU_OPEN');
7083 // Ïàóçà ïðè ìåíþ òîëüêî â îäèíî÷íîé èãðå:
7084 if (not g_Game_IsNet
) then
7088 if (g_ActiveWindow
<> nil) and (not Show
) then
7090 // Ïàóçà ïðè ìåíþ òîëüêî â îäèíî÷íîé èãðå:
7091 if (not g_Game_IsNet
) then
7092 g_Game_Pause(False);
7096 procedure g_Game_Pause (Enable
: Boolean);
7100 if not gGameOn
then exit
;
7102 if not (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
]) then exit
;
7105 gPauseMain
:= Enable
;
7107 if (gPause
<> oldPause
) then g_Game_PauseAllSounds(gPause
);
7110 procedure g_Game_HolmesPause (Enable
: Boolean);
7114 if not gGameOn
then exit
;
7115 if not (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
]) then exit
;
7118 gPauseHolmes
:= Enable
;
7120 if (gPause
<> oldPause
) then g_Game_PauseAllSounds(gPause
);
7123 procedure g_Game_PauseAllSounds(Enable
: Boolean);
7128 if gTriggers
<> nil then
7129 for i
:= 0 to High(gTriggers
) do
7130 with gTriggers
[i
] do
7131 if (TriggerType
= TRIGGER_SOUND
) and
7133 Sound
.IsPlaying() then
7135 Sound
.Pause(Enable
);
7139 if gPlayers
<> nil then
7140 for i
:= 0 to High(gPlayers
) do
7141 if gPlayers
[i
] <> nil then
7142 gPlayers
[i
].PauseSounds(Enable
);
7145 if gMusic
<> nil then
7146 gMusic
.Pause(Enable
);
7149 procedure g_Game_StopAllSounds(all
: Boolean);
7153 if gTriggers
<> nil then
7154 for i
:= 0 to High(gTriggers
) do
7155 with gTriggers
[i
] do
7156 if (TriggerType
= TRIGGER_SOUND
) and
7160 if gMusic
<> nil then
7167 procedure g_Game_UpdateTriggerSounds();
7171 if gTriggers
<> nil then
7172 for i
:= 0 to High(gTriggers
) do
7173 with gTriggers
[i
] do
7174 if (TriggerType
= TRIGGER_SOUND
) and
7177 Sound
.IsPlaying() then
7179 if ((gPlayer1
<> nil) and g_CollidePoint(gPlayer1
.GameX
, gPlayer1
.GameY
, X
, Y
, Width
, Height
)) or
7180 ((gPlayer2
<> nil) and g_CollidePoint(gPlayer2
.GameX
, gPlayer2
.GameY
, X
, Y
, Width
, Height
)) then
7182 Sound
.SetPan(0.5 - tgcPan
/255.0);
7183 Sound
.SetVolume(tgcVolume
/255.0);
7186 Sound
.SetCoords(X
+(Width
div 2), Y
+(Height
div 2), tgcVolume
/255.0);
7190 function g_Game_IsWatchedPlayer(UID
: Word): Boolean;
7193 if (gPlayer1
<> nil) and (gPlayer1
.UID
= UID
) then
7198 if (gPlayer2
<> nil) and (gPlayer2
.UID
= UID
) then
7203 if gSpectMode
<> SPECT_PLAYERS
then
7205 if gSpectPID1
= UID
then
7210 if gSpectViewTwo
and (gSpectPID2
= UID
) then
7217 function g_Game_IsWatchedTeam(Team
: Byte): Boolean;
7222 if (gPlayer1
<> nil) and (gPlayer1
.Team
= Team
) then
7227 if (gPlayer2
<> nil) and (gPlayer2
.Team
= Team
) then
7232 if gSpectMode
<> SPECT_PLAYERS
then
7234 Pl
:= g_Player_Get(gSpectPID1
);
7235 if (Pl
<> nil) and (Pl
.Team
= Team
) then
7240 if gSpectViewTwo
then
7242 Pl
:= g_Player_Get(gSpectPID2
);
7243 if (Pl
<> nil) and (Pl
.Team
= Team
) then
7251 procedure g_Game_Message(Msg
: string; Time
: Word);
7253 MessageLineLength
:= (gScreenWidth
- 204) div e_CharFont_GetMaxWidth(gMenuFont
);
7254 MessageText
:= b_Text_Wrap(b_Text_Format(Msg
), MessageLineLength
);
7255 MessageTime
:= Time
;
7258 procedure g_Game_ChatSound(Text: String; Taunt
: Boolean = True);
7260 punct
: Array[0..13] of String =
7261 ('.', ',', ':', ';', '!', '?', '(', ')', '''', '"', '/', '\', '*', '^');
7267 function IsPunctuation(S
: String): Boolean;
7272 if Length(S
) <> 1 then
7274 for i
:= Low(punct
) to High(punct
) do
7275 if S
= punct
[i
] then
7281 function FilterPunctuation(S
: String): String;
7285 for i
:= Low(punct
) to High(punct
) do
7286 S
:= StringReplace(S
, punct
[i
], ' ', [rfReplaceAll
]);
7292 if gUseChatSounds
and Taunt
and (gChatSounds
<> nil) and (Pos(': ', Text) > 0) then
7294 // remove player name
7295 Delete(Text, 1, Pos(': ', Text) + 2 - 1);
7296 // for FullWord check
7297 Text := toLowerCase1251(' ' + Text + ' ');
7298 fpText
:= FilterPunctuation(Text);
7300 for i
:= 0 to Length(gChatSounds
) - 1 do
7303 for j
:= 0 to Length(gChatSounds
[i
].Tags
) - 1 do
7305 if gChatSounds
[i
].FullWord
and (not IsPunctuation(gChatSounds
[i
].Tags
[j
])) then
7306 ok
:= Pos(' ' + gChatSounds
[i
].Tags
[j
] + ' ', fpText
) > 0
7308 ok
:= Pos(gChatSounds
[i
].Tags
[j
], Text) > 0;
7314 gChatSounds
[i
].Sound
.Play();
7320 g_Sound_PlayEx('SOUND_GAME_RADIO');
7323 procedure g_Game_Announce_GoodShot(SpawnerUID
: Word);
7332 if not g_Game_IsWatchedPlayer(SpawnerUID
) then
7336 if goodsnd
[a
].IsPlaying() then
7339 goodsnd
[Random(4)].Play();
7342 procedure g_Game_Announce_KillCombo(Param
: Integer);
7349 UID
:= Param
and $FFFF;
7354 Pl
:= g_Player_Get(UID
);
7363 g_Console_Add(Format(_lc
[I_PLAYER_KILL_2X
], [Name
]), True);
7367 g_Console_Add(Format(_lc
[I_PLAYER_KILL_3X
], [Name
]), True);
7371 g_Console_Add(Format(_lc
[I_PLAYER_KILL_4X
], [Name
]), True);
7375 g_Console_Add(Format(_lc
[I_PLAYER_KILL_MX
], [Name
]), True);
7383 if not g_Game_IsWatchedPlayer(UID
) then
7386 if (not g_Game_IsWatchedPlayer(UID
)) and (c
< 4) then
7390 if killsnd
[n
].IsPlaying() then
7395 procedure g_Game_Announce_BodyKill(SpawnerUID
: Word);
7404 if not g_Game_IsWatchedPlayer(SpawnerUID
) then
7408 if hahasnd
[a
].IsPlaying() then
7411 hahasnd
[Random(3)].Play();
7414 procedure g_Game_StartVote(Command
, Initiator
: string);
7418 if not gVotesEnabled
then Exit
;
7419 if gGameSettings
.GameType
<> GT_SERVER
then Exit
;
7420 if gVoteInProgress
or gVotePassed
then
7422 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_INPROGRESS
], [gVoteCommand
]), True);
7423 MH_SEND_VoteEvent(NET_VE_INPROGRESS
, gVoteCommand
);
7426 gVoteInProgress
:= True;
7427 gVotePassed
:= False;
7428 gVoteTimer
:= gTime
+ gVoteTimeout
* 1000;
7431 gVoteCommand
:= Command
;
7433 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
7434 Need
:= Floor((NetClientCount
+1)/2.0)+1
7436 Need
:= Floor(NetClientCount
/2.0)+1;
7437 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_STARTED
], [Initiator
, Command
, Need
]), True);
7438 MH_SEND_VoteEvent(NET_VE_STARTED
, Initiator
, Command
, Need
);
7441 procedure g_Game_CheckVote
;
7445 if gGameSettings
.GameType
<> GT_SERVER
then Exit
;
7446 if not gVoteInProgress
then Exit
;
7448 if (gTime
>= gVoteTimer
) then
7450 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
7451 Need
:= Floor((NetClientCount
+1)/2.0) + 1
7453 Need
:= Floor(NetClientCount
/2.0) + 1;
7454 if gVoteCount
>= Need
then
7456 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_PASSED
], [gVoteCommand
]), True);
7457 MH_SEND_VoteEvent(NET_VE_PASSED
, gVoteCommand
);
7458 gVotePassed
:= True;
7459 gVoteCmdTimer
:= gTime
+ 5000;
7463 g_Console_Add(_lc
[I_MESSAGE_VOTE_FAILED
], True);
7464 MH_SEND_VoteEvent(NET_VE_FAILED
);
7466 if NetClients
<> nil then
7467 for I
:= Low(NetClients
) to High(NetClients
) do
7468 if NetClients
[i
].Used
then
7469 NetClients
[i
].Voted
:= False;
7470 gVoteInProgress
:= False;
7476 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
7477 Need
:= Floor((NetClientCount
+1)/2.0) + 1
7479 Need
:= Floor(NetClientCount
/2.0) + 1;
7480 if gVoteCount
>= Need
then
7482 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_PASSED
], [gVoteCommand
]), True);
7483 MH_SEND_VoteEvent(NET_VE_PASSED
, gVoteCommand
);
7484 gVoteInProgress
:= False;
7485 gVotePassed
:= True;
7486 gVoteCmdTimer
:= gTime
+ 5000;
7489 if NetClients
<> nil then
7490 for I
:= Low(NetClients
) to High(NetClients
) do
7491 if NetClients
[i
].Used
then
7492 NetClients
[i
].Voted
:= False;
7497 procedure g_Game_LoadMapList(FileName
: string);
7505 if not FileExists(FileName
) then Exit
;
7507 AssignFile(ListFile
, FileName
);
7509 while not EOF(ListFile
) do
7511 ReadLn(ListFile
, s
);
7514 if s
= '' then Continue
;
7516 SetLength(MapList
, Length(MapList
)+1);
7517 MapList
[High(MapList
)] := s
;
7519 CloseFile(ListFile
);
7522 procedure g_Game_SetDebugMode();
7525 // ×èòû (äàæå â ñâîåé èãðå):
7529 procedure g_Game_SetLoadingText(Text: String; Max
: Integer; reWrite
: Boolean);
7533 if Length(LoadingStat
.Msgs
) = 0 then
7539 begin // Ïåðåõîäèì íà ñëåäóþùóþ ñòðîêó èëè ñêðîëëèðóåì:
7540 if NextMsg
= Length(Msgs
) then
7542 for i
:= 0 to High(Msgs
)-1 do
7543 Msgs
[i
] := Msgs
[i
+1];
7551 Msgs
[NextMsg
-1] := Text;
7555 PBarWasHere
:= false;
7558 g_ActiveWindow
:= nil;
7560 ProcessLoading(true);
7563 procedure g_Game_StepLoading(Value
: Integer = -1);
7574 if (ShowCount
> LOADING_SHOW_STEP
) or (Value
> -1) then
7582 procedure g_Game_ClearLoading();
7591 len
:= ((gScreenHeight
div 3)*2 - 50) div LOADING_INTERLINE
;
7592 if len
< 1 then len
:= 1;
7593 SetLength(Msgs
, len
);
7594 for len
:= Low(Msgs
) to High(Msgs
) do
7597 PBarWasHere
:= false;
7601 procedure Parse_Params(var pars
: TParamStrValues
);
7608 while i
<= ParamCount
do
7611 if (s
[1] = '-') and (Length(s
) > 1) then
7613 if (s
[2] = '-') and (Length(s
) > 2) then
7614 begin // Îäèíî÷íûé ïàðàìåòð
7615 SetLength(pars
, Length(pars
) + 1);
7616 with pars
[High(pars
)] do
7618 Name
:= LowerCase(s
);
7623 if (i
< ParamCount
) then
7624 begin // Ïàðàìåòð ñî çíà÷åíèåì
7626 SetLength(pars
, Length(pars
) + 1);
7627 with pars
[High(pars
)] do
7629 Name
:= LowerCase(s
);
7630 Value
:= LowerCase(ParamStr(i
));
7639 function Find_Param_Value(var pars
: TParamStrValues
; aName
: String): String;
7644 for i
:= 0 to High(pars
) do
7645 if pars
[i
].Name
= aName
then
7647 Result
:= pars
[i
].Value
;
7652 procedure g_Game_Process_Params();
7654 pars
: TParamStrValues
;
7657 LimT
, LimS
: Integer;
7668 s
:= Find_Param_Value(pars
, '--debug');
7671 g_Game_SetDebugMode();
7672 s
:= Find_Param_Value(pars
, '--netdump');
7677 // Connect when game loads
7678 ip
:= Find_Param_Value(pars
, '-connect');
7682 s
:= Find_Param_Value(pars
, '-port');
7683 if (s
= '') or not TryStrToInt(s
, Port
) then
7686 s
:= Find_Param_Value(pars
, '-pw');
7688 g_Game_StartClient(ip
, Port
, s
);
7692 s
:= LowerCase(Find_Param_Value(pars
, '-dbg-mainwad'));
7695 gDefaultMegawadStart
:= s
;
7698 if (Find_Param_Value(pars
, '--dbg-mainwad-restore') <> '') or
7699 (Find_Param_Value(pars
, '--dbg-mainwad-default') <> '') then
7701 gDefaultMegawadStart
:= DF_Default_Megawad_Start
;
7704 // Start map when game loads:
7705 map
:= LowerCase(Find_Param_Value(pars
, '-map'));
7706 if isWadPath(map
) then
7709 s
:= Find_Param_Value(pars
, '-gm');
7710 GMode
:= g_Game_TextToMode(s
);
7711 if GMode
= GM_NONE
then GMode
:= GM_DM
;
7712 if GMode
= GM_SINGLE
then GMode
:= GM_COOP
;
7715 s
:= Find_Param_Value(pars
, '-limt');
7716 if (s
= '') or (not TryStrToInt(s
, LimT
)) then
7722 s
:= Find_Param_Value(pars
, '-lims');
7723 if (s
= '') or (not TryStrToInt(s
, LimS
)) then
7729 s
:= Find_Param_Value(pars
, '-lives');
7730 if (s
= '') or (not TryStrToInt(s
, Lives
)) then
7736 s
:= Find_Param_Value(pars
, '-opt');
7738 Opt
:= GAME_OPTION_ALLOWEXIT
or GAME_OPTION_BOTVSPLAYER
or GAME_OPTION_BOTVSMONSTER
7740 Opt
:= StrToIntDef(s
, 0);
7742 Opt
:= GAME_OPTION_ALLOWEXIT
or GAME_OPTION_BOTVSPLAYER
or GAME_OPTION_BOTVSMONSTER
;
7745 s
:= Find_Param_Value(pars
, '--close');
7749 // Override map to test:
7750 s
:= LowerCase(Find_Param_Value(pars
, '-testmap'));
7752 gTestMap
:= MapsDir
+ s
;
7754 // Delete test map after play:
7755 s
:= Find_Param_Value(pars
, '--testdelete');
7758 gMapToDelete
:= MapsDir
+ map
;
7759 e_WriteLog('"--testdelete" is deprecated, use --tempdelete.', TMsgType
.Fatal
);
7763 // Delete temporary WAD after play:
7764 s
:= Find_Param_Value(pars
, '--tempdelete');
7765 if (s
<> '') and (gTestMap
<> '') then
7767 gMapToDelete
:= gTestMap
;
7768 gTempDelete
:= True;
7771 // Number of players:
7772 s
:= Find_Param_Value(pars
, '-pl');
7776 n
:= StrToIntDef(s
, 1);
7779 s
:= Find_Param_Value(pars
, '-port');
7780 if (s
= '') or not TryStrToInt(s
, Port
) then
7781 g_Game_StartCustom(map
, GMode
, LimT
, LimS
, Lives
, Opt
, n
)
7783 g_Game_StartServer(map
, GMode
, LimT
, LimS
, Lives
, Opt
, n
, 0, Port
);
7786 // Execute script when game loads:
7787 s
:= Find_Param_Value(pars
, '-exec');
7790 if not isWadPath(s
) then
7791 s
:= GameDir
+ '/' + s
;
7796 if IOResult
<> 0 then
7798 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], ['Failed to read file: ' + s
]), TMsgType
.Warning
);
7799 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_READ
], [s
]));
7803 e_WriteLog('Executing script: ' + s
, TMsgType
.Notify
);
7804 g_Console_Add(Format(_lc
[I_CONSOLE_EXEC
], [s
]));
7809 if IOResult
<> 0 then
7811 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], ['Failed to read file: ' + s
]), TMsgType
.Warning
);
7812 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_READ
], [s
]));
7816 if Pos('#', s
) <> 1 then // script comment
7817 g_Console_Process(s
, True);
7828 conRegVar('pf_draw_frame', @g_profile_frame_draw
, 'draw frame rendering profiles', 'render profiles');
7829 //conRegVar('pf_update_frame', @g_profile_frame_update, 'draw frame updating profiles', 'update profiles');
7830 conRegVar('pf_coldet', @g_profile_collision
, 'draw collision detection profiles', 'coldet profiles');
7831 conRegVar('pf_los', @g_profile_los
, 'draw monster LOS profiles', 'monster LOS profiles');
7833 conRegVar('r_sq_draw', @gdbg_map_use_accel_render
, 'accelerated spatial queries in rendering', 'accelerated rendering');
7834 conRegVar('cd_sq_enabled', @gdbg_map_use_accel_coldet
, 'accelerated spatial queries in map coldet', 'accelerated map coldet');
7835 conRegVar('mon_sq_enabled', @gmon_debug_use_sqaccel
, 'accelerated spatial queries for monsters', 'accelerated monster coldet');
7836 conRegVar('wtrace_sq_enabled', @gwep_debug_fast_trace
, 'accelerated spatial queries for weapon hitscan trace', 'accelerated weapon hitscan');
7838 conRegVar('pr_enabled', @gpart_dbg_enabled
, 'enable/disable particles', 'particles');
7839 conRegVar('pr_phys_enabled', @gpart_dbg_phys_enabled
, 'enable/disable particle physics', 'particle physics');
7841 conRegVar('los_enabled', @gmon_dbg_los_enabled
, 'enable/disable monster LOS calculations', 'monster LOS', true);
7842 conRegVar('mon_think', @gmon_debug_think
, 'enable/disable monster thinking', 'monster thinking', true);
7844 {$IFDEF ENABLE_HOLMES}
7845 conRegVar('dbg_holmes', @g_holmes_enabled
, 'enable/disable Holmes', 'Holmes', true);
7848 conRegVar('dbg_ignore_level_bounds', @g_dbg_ignore_bounds
, 'ignore level bounds', '', false);
7850 conRegVar('r_scale', @g_dbg_scale
, 0.01, 100.0, 'render scale', '', false);
7852 conRegVar('light_enabled', @gwin_k8_enable_light_experiments
, 'enable/disable dynamic lighting', 'lighting');
7853 conRegVar('light_player_halo', @g_playerLight
, 'enable/disable player halo', 'player light halo');
7855 conRegVar('r_smallmap_align_h', @r_smallmap_h
, 'halign: 0: left; 1: center; 2: right', 'horizontal aligning of small maps');
7856 conRegVar('r_smallmap_align_v', @r_smallmap_v
, 'valign: 0: top; 1: center; 2: bottom', 'vertial aligning of small maps');