1 (* Copyright (C) Doom 2D: Forever Developers
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, version 3 of the License ONLY.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 {$INCLUDE ../shared/a_modes.inc}
23 g_basic
, g_player
, e_graphics
, g_res_downloader
,
24 g_sound
, g_gui
, utils
, md5
, mempool
, xprofiler
,
28 TGameSettings
= record
44 TDelayedEvent
= record
53 Sound
: TPlayableSound
;
54 Tags
: Array of String;
58 TPlayerSettings
= record
77 function g_Game_IsNet(): Boolean;
78 function g_Game_IsServer(): Boolean;
79 function g_Game_IsClient(): Boolean;
80 procedure g_Game_Init();
81 procedure g_Game_Free (freeTextures
: Boolean=true);
82 procedure g_Game_LoadData();
83 procedure g_Game_FreeData();
84 procedure g_Game_Update();
85 procedure g_Game_Draw();
86 procedure g_Game_Quit();
87 procedure g_Game_SetupScreenSize();
88 procedure g_Game_ChangeResolution(newWidth
, newHeight
: Word; nowFull
, nowMax
: Boolean);
89 function g_Game_ModeToText(Mode
: Byte): string;
90 function g_Game_TextToMode(Mode
: string): Byte;
91 procedure g_Game_ExecuteEvent(Name
: String);
92 function g_Game_DelayEvent(DEType
: Byte; Time
: LongWord; Num
: Integer = 0; Str
: String = ''): Integer;
93 procedure g_Game_AddPlayer(Team
: Byte = TEAM_NONE
);
94 procedure g_Game_RemovePlayer();
95 procedure g_Game_Spectate();
96 procedure g_Game_SpectateCenterView();
97 procedure g_Game_StartSingle(Map
: String; TwoPlayers
: Boolean; nPlayers
: Byte);
98 procedure g_Game_StartCustom(Map
: String; GameMode
: Byte; TimeLimit
, GoalLimit
: Word; MaxLives
: Byte; Options
: LongWord; nPlayers
: Byte);
99 procedure g_Game_StartServer(Map
: String; GameMode
: Byte; TimeLimit
, GoalLimit
: Word; MaxLives
: Byte; Options
: LongWord; nPlayers
: Byte; IPAddr
: LongWord; Port
: Word);
100 procedure g_Game_StartClient(Addr
: String; Port
: Word; PW
: String);
101 procedure g_Game_Restart();
102 procedure g_Game_RestartLevel();
103 procedure g_Game_RestartRound(NoMapRestart
: Boolean = False);
104 function g_Game_ClientWAD (NewWAD
: String; const WHash
: TMD5Digest
): AnsiString;
105 function g_Game_StartMap(asMegawad
: Boolean; Map
: String; Force
: Boolean = False; const oldMapPath
: AnsiString=''): Boolean;
106 procedure g_Game_ChangeMap(const MapPath
: String);
107 procedure g_Game_ExitLevel(const Map
: AnsiString);
108 function g_Game_GetFirstMap(WAD
: String): String;
109 function g_Game_GetNextMap(): String;
110 procedure g_Game_NextLevel();
111 procedure g_Game_Pause(Enable
: Boolean);
112 procedure g_Game_HolmesPause(Enable
: Boolean);
113 procedure g_Game_InGameMenu(Show
: Boolean);
114 function g_Game_IsWatchedPlayer(UID
: Word): Boolean;
115 function g_Game_IsWatchedTeam(Team
: Byte): Boolean;
116 procedure g_Game_Message(Msg
: String; Time
: Word);
117 procedure g_Game_LoadMapList(FileName
: String);
118 procedure g_Game_PauseAllSounds(Enable
: Boolean);
119 procedure g_Game_StopAllSounds(all
: Boolean);
120 procedure g_Game_UpdateTriggerSounds();
121 function g_Game_GetMegaWADInfo(WAD
: String): TMegaWADInfo
;
122 procedure g_Game_ChatSound(Text: String; Taunt
: Boolean = True);
123 procedure g_Game_Announce_GoodShot(SpawnerUID
: Word);
124 procedure g_Game_Announce_KillCombo(Param
: Integer);
125 procedure g_Game_Announce_BodyKill(SpawnerUID
: Word);
126 procedure g_Game_StartVote(Command
, Initiator
: string);
127 procedure g_Game_CheckVote
;
128 procedure g_TakeScreenShot();
129 procedure g_FatalError(Text: String);
130 procedure g_SimpleError(Text: String);
131 function g_Game_IsTestMap(): Boolean;
132 procedure g_Game_DeleteTestMap();
133 procedure GameCVars(P
: SSArray
);
134 procedure GameCommands(P
: SSArray
);
135 procedure GameCheats(P
: SSArray
);
136 procedure DebugCommands(P
: SSArray
);
137 procedure g_Game_Process_Params
;
138 procedure g_Game_SetLoadingText(Text: String; Max
: Integer; reWrite
: Boolean);
139 procedure g_Game_StepLoading(Value
: Integer = -1);
140 procedure g_Game_ClearLoading();
141 procedure g_Game_SetDebugMode();
142 procedure DrawLoadingStat();
143 procedure DrawMenuBackground(tex
: AnsiString);
145 { procedure SetWinPause(Enable: Boolean); }
150 LOADING_SHOW_STEP
= 100;
151 LOADING_INTERLINE
= 20;
166 MESSAGE_DIKEY
= WM_USER
+ 1;
171 EXIT_ENDLEVELSINGLE
= 4;
172 EXIT_ENDLEVELCUSTOM
= 5;
174 GAME_OPTION_RESERVED
= 1;
175 GAME_OPTION_TEAMDAMAGE
= 2;
176 GAME_OPTION_ALLOWEXIT
= 4;
177 GAME_OPTION_WEAPONSTAY
= 8;
178 GAME_OPTION_MONSTERS
= 16;
179 GAME_OPTION_BOTVSPLAYER
= 32;
180 GAME_OPTION_BOTVSMONSTER
= 64;
185 STATE_INTERCUSTOM
= 3;
186 STATE_INTERSINGLE
= 4;
192 LMS_RESPAWN_NONE
= 0;
193 LMS_RESPAWN_WARMUP
= 1;
194 LMS_RESPAWN_FINAL
= 2;
211 CONFIG_FILENAME
= 'Doom2DF.cfg';
213 TEST_MAP_NAME
= '$$$_TEST_$$$';
215 STD_PLAYER_MODEL
= 'Doomer';
225 gGameSettings
: TGameSettings
;
226 gPlayer1Settings
: TPlayerSettings
;
227 gPlayer2Settings
: TPlayerSettings
;
229 gPlayerScreenSize
: TDFPoint
;
230 gPlayer1ScreenCoord
: TDFPoint
;
231 gPlayer2ScreenCoord
: TDFPoint
;
232 gPlayer1
: TPlayer
= nil;
233 gPlayer2
: TPlayer
= nil;
234 gPlayerDrawn
: TPlayer
= nil;
236 gSwitchGameMode
: Byte = GM_DM
;
237 gHearPoint1
, gHearPoint2
: THearPoint
;
238 gSoundEffectsDF
: Boolean = False;
239 gSoundTriggerTime
: Word = 0;
240 gAnnouncer
: Integer = ANNOUNCE_NONE
;
241 goodsnd
: array[0..3] of TPlayableSound
;
242 killsnd
: array[0..3] of TPlayableSound
;
243 hahasnd
: array[0..2] of TPlayableSound
;
244 sound_get_flag
: array[0..1] of TPlayableSound
;
245 sound_lost_flag
: array[0..1] of TPlayableSound
;
246 sound_ret_flag
: array[0..1] of TPlayableSound
;
247 sound_cap_flag
: array[0..1] of TPlayableSound
;
248 gBodyKillEvent
: Integer = -1;
249 gDefInterTime
: ShortInt = -1;
250 gInterEndTime
: LongWord = 0;
251 gInterTime
: LongWord = 0;
252 gServInterTime
: Byte = 0;
253 gGameStartTime
: LongWord = 0;
254 gTotalMonsters
: Integer = 0;
255 gPauseMain
: Boolean = false;
256 gPauseHolmes
: Boolean = false;
257 gShowTime
: Boolean = False;
258 gShowFPS
: Boolean = False;
259 gShowGoals
: Boolean = True;
260 gShowStat
: Boolean = True;
261 gShowKillMsg
: Boolean = True;
262 gShowLives
: Boolean = True;
263 gShowPing
: Boolean = False;
264 gShowMap
: Boolean = False;
266 gState
: Byte = STATE_NONE
;
268 sWidth
, sHeight
: Word;
269 gSpectMode
: Byte = SPECT_NONE
;
270 gSpectHUD
: Boolean = True;
271 gSpectKeyPress
: Boolean = False;
272 gSpectX
: Integer = 0;
273 gSpectY
: Integer = 0;
274 gSpectStep
: Byte = 8;
275 gSpectViewTwo
: Boolean = False;
276 gSpectPID1
: Integer = -1;
277 gSpectPID2
: Integer = -1;
278 gSpectAuto
: Boolean = False;
279 gSpectAutoNext
: LongWord;
280 gSpectAutoStepX
: Integer;
281 gSpectAutoStepY
: Integer;
282 gMusic
: TMusic
= nil;
283 gLoadGameMode
: Boolean;
284 gCheats
: Boolean = False;
285 gMapOnce
: Boolean = False;
286 gMapToDelete
: String;
287 gTempDelete
: Boolean = False;
288 gLastMap
: Boolean = False;
289 gWinSizeX
, gWinSizeY
: Integer;
290 gResolutionChange
: Boolean = False;
291 gRC_Width
, gRC_Height
: Integer;
292 gRC_FullScreen
, gRC_Maximized
: Boolean;
293 gLanguageChange
: Boolean = False;
294 gDebugMode
: Boolean = False;
295 g_debug_Sounds
: Boolean = False;
296 g_debug_Frames
: Boolean = False;
297 g_debug_WinMsgs
: Boolean = False;
298 g_debug_MonsterOff
: Boolean = False;
299 g_debug_BotAIOff
: Byte = 0;
300 g_debug_HealthBar
: Boolean = False;
301 g_Debug_Player
: Boolean = False;
302 gCoopMonstersKilled
: Word = 0;
303 gCoopSecretsFound
: Word = 0;
304 gCoopTotalMonstersKilled
: Word = 0;
305 gCoopTotalSecretsFound
: Word = 0;
306 gCoopTotalMonsters
: Word = 0;
307 gCoopTotalSecrets
: Word = 0;
308 gStatsOff
: Boolean = False;
309 gStatsPressed
: Boolean = False;
310 gExitByTrigger
: Boolean = False;
311 gNextMap
: String = '';
312 gLMSRespawn
: Byte = LMS_RESPAWN_NONE
;
313 gLMSRespawnTime
: Cardinal = 0;
314 gLMSSoftSpawn
: Boolean = False;
315 gMissionFailed
: Boolean = False;
316 gVoteInProgress
: Boolean = False;
317 gVotePassed
: Boolean = False;
318 gVoteCommand
: string = '';
319 gVoteTimer
: Cardinal = 0;
320 gVoteCmdTimer
: Cardinal = 0;
321 gVoteCount
: Integer = 0;
322 gVoteTimeout
: Cardinal = 30;
323 gVoted
: Boolean = False;
324 gVotesEnabled
: Boolean = True;
325 gEvents
: Array of TGameEvent
;
326 gDelayedEvents
: Array of TDelayedEvent
;
327 gUseChatSounds
: Boolean = True;
328 gChatSounds
: Array of TChatSound
;
329 gSelectWeapon
: Array [0..1, WP_FIRST
..WP_LAST
] of Boolean; // [player, weapon]
330 gInterReadyCount
: Integer = 0;
332 g_dbg_ignore_bounds
: Boolean = false;
333 r_smallmap_h
: Integer = 0; // 0: left; 1: center; 2: right
334 r_smallmap_v
: Integer = 2; // 0: top; 1: center; 2: bottom
336 // move button values:
337 // bits 0-1: l/r state:
338 // 0: neither left, nor right pressed
341 // bits 4-5: l/r state when strafe was pressed
342 P1MoveButton
: Byte = 0;
343 P2MoveButton
: Byte = 0;
345 g_profile_frame_update
: Boolean = false;
346 g_profile_frame_draw
: Boolean = false;
347 g_profile_collision
: Boolean = false;
348 g_profile_los
: Boolean = false;
349 g_profile_history_size
: Integer = 1000;
351 g_rlayer_back
: Boolean = true;
352 g_rlayer_step
: Boolean = true;
353 g_rlayer_wall
: Boolean = true;
354 g_rlayer_door
: Boolean = true;
355 g_rlayer_acid1
: Boolean = true;
356 g_rlayer_acid2
: Boolean = true;
357 g_rlayer_water
: Boolean = true;
358 g_rlayer_fore
: Boolean = true;
361 procedure g_ResetDynlights ();
362 procedure g_AddDynLight (x
, y
, radius
: Integer; r
, g
, b
, a
: Single);
363 procedure g_DynLightExplosion (x
, y
, radius
: Integer; r
, g
, b
: Single);
365 function conIsCheatsEnabled (): Boolean; inline;
366 function gPause (): Boolean; inline;
372 {$INCLUDE ../nogl/noGLuses.inc}
373 {$IFDEF ENABLE_HOLMES}
376 e_texture
, e_res
, g_textures
, g_main
, g_window
, g_menu
,
377 e_input
, e_log
, g_console
, g_items
, g_map
, g_panel
,
378 g_playermodel
, g_gfx
, g_options
, Math
,
379 g_triggers
, g_monsters
, e_sound
, CONFIG
,
381 ENet
, e_msg
, g_netmsg
, g_netmaster
,
382 sfs
, wadreader
, g_system
;
386 hasPBarGfx
: Boolean = false;
389 // ////////////////////////////////////////////////////////////////////////// //
390 function gPause (): Boolean; inline; begin result
:= gPauseMain
or gPauseHolmes
; end;
393 // ////////////////////////////////////////////////////////////////////////// //
394 function conIsCheatsEnabled (): Boolean; inline;
397 if g_Game_IsNet
then exit
;
398 if not gDebugMode
then
400 //if not gCheats then exit;
401 if not (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
]) then exit
;
402 if not (gGameSettings
.GameMode
in [GM_COOP
, GM_SINGLE
]) then exit
;
408 // ////////////////////////////////////////////////////////////////////////// //
410 profileFrameDraw
: TProfiler
= nil;
413 // ////////////////////////////////////////////////////////////////////////// //
416 x
, y
, radius
: Integer;
419 exploRadius
: Integer;
423 g_dynLights
: array of TDynLight
= nil;
424 g_dynLightCount
: Integer = 0;
425 g_playerLight
: Boolean = false;
427 procedure g_ResetDynlights ();
431 if not gwin_has_stencil
then begin g_dynLightCount
:= 0; exit
; end;
433 for idx
:= 0 to g_dynLightCount
-1 do
435 if g_dynLights
[idx
].exploCount
= -666 then
442 Inc(g_dynLights
[idx
].exploCount
);
443 if (g_dynLights
[idx
].exploCount
< 10) then
445 g_dynLights
[idx
].radius
:= g_dynLights
[idx
].exploRadius
+g_dynLights
[idx
].exploCount
*8;
446 g_dynLights
[idx
].a
:= 0.4+g_dynLights
[idx
].exploCount
/10;
447 if (g_dynLights
[idx
].a
> 0.8) then g_dynLights
[idx
].a
:= 0.8;
448 if lnum
<> idx
then g_dynLights
[lnum
] := g_dynLights
[idx
];
453 g_dynLightCount
:= lnum
;
456 procedure g_AddDynLight (x
, y
, radius
: Integer; r
, g
, b
, a
: Single);
458 if not gwin_has_stencil
then exit
;
459 if g_dynLightCount
= length(g_dynLights
) then SetLength(g_dynLights
, g_dynLightCount
+1024);
460 g_dynLights
[g_dynLightCount
].x
:= x
;
461 g_dynLights
[g_dynLightCount
].y
:= y
;
462 g_dynLights
[g_dynLightCount
].radius
:= radius
;
463 g_dynLights
[g_dynLightCount
].r
:= r
;
464 g_dynLights
[g_dynLightCount
].g
:= g
;
465 g_dynLights
[g_dynLightCount
].b
:= b
;
466 g_dynLights
[g_dynLightCount
].a
:= a
;
467 g_dynLights
[g_dynLightCount
].exploCount
:= -666;
468 Inc(g_dynLightCount
);
471 procedure g_DynLightExplosion (x
, y
, radius
: Integer; r
, g
, b
: Single);
473 if not gwin_has_stencil
then exit
;
474 if g_dynLightCount
= length(g_dynLights
) then SetLength(g_dynLights
, g_dynLightCount
+1024);
475 g_dynLights
[g_dynLightCount
].x
:= x
;
476 g_dynLights
[g_dynLightCount
].y
:= y
;
477 g_dynLights
[g_dynLightCount
].radius
:= 0;
478 g_dynLights
[g_dynLightCount
].exploRadius
:= radius
;
479 g_dynLights
[g_dynLightCount
].r
:= r
;
480 g_dynLights
[g_dynLightCount
].g
:= g
;
481 g_dynLights
[g_dynLightCount
].b
:= b
;
482 g_dynLights
[g_dynLightCount
].a
:= 0;
483 g_dynLights
[g_dynLightCount
].exploCount
:= 0;
484 Inc(g_dynLightCount
);
488 // ////////////////////////////////////////////////////////////////////////// //
489 function calcProfilesHeight (prof
: TProfiler
): Integer;
492 if (prof
= nil) then exit
;
493 if (length(prof
.bars
) = 0) then exit
;
494 result
:= length(prof
.bars
)*(16+2);
498 function drawProfiles (x
, y
: Integer; prof
: TProfiler
): Integer;
505 if (prof
= nil) then exit
;
507 if (length(prof
.bars
) = 0) then exit
;
509 hgt
:= calcProfilesHeight(prof
);
510 if (x
< 0) then x
:= gScreenWidth
-(wdt
-1)+x
;
511 if (y
< 0) then y
:= gScreenHeight
-(hgt
-1)+y
;
513 //e_DrawFillQuad(x, y, x+wdt-1, y+hgt-1, 255, 255, 255, 200, B_BLEND);
514 //e_DrawFillQuad(x, y, x+wdt-1, y+hgt-1, 20, 20, 20, 0, B_NONE);
515 e_DarkenQuadWH(x
, y
, wdt
, hgt
, 150);
518 for ii
:= 0 to High(prof
.bars
) do
520 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);
527 // ////////////////////////////////////////////////////////////////////////// //
529 TEndCustomGameStat
= record
530 PlayerStat
: TPlayerStatArray
;
534 Map
, MapName
: String;
537 TEndSingleGameStat
= record
538 PlayerStat
: Array [0..1] of record
544 TotalSecrets
: Integer;
547 TLoadingStat
= record
551 Msgs
: Array of String;
553 PBarWasHere
: Boolean; // did we draw a progress bar for this message?
556 TParamStrValue
= record
561 TParamStrValues
= Array of TParamStrValue
;
564 INTER_ACTION_TEXT
= 1;
565 INTER_ACTION_PIC
= 2;
566 INTER_ACTION_MUSIC
= 3;
570 FPSCounter
, UPSCounter
: Word;
571 FPSTime
, UPSTime
: LongWord;
572 DataLoaded
: Boolean = False;
573 IsDrawStat
: Boolean = False;
574 CustomStat
: TEndCustomGameStat
;
575 SingleStat
: TEndSingleGameStat
;
576 LoadingStat
: TLoadingStat
;
577 EndingGameCounter
: Byte = 0;
580 MessageLineLength
: Integer = 80;
581 MapList
: SSArray
= nil;
582 MapIndex
: Integer = -1;
583 InterReadyTime
: Integer = -1;
589 text: Array of ShortString;
590 anim
: Array of ShortString;
591 pic
: Array of ShortString;
592 mus
: Array of ShortString;
594 triggers
: Array of record
596 actions
: Array of record
597 action
, p1
, p2
: Integer;
600 cur_trigger
: Integer;
613 function Compare(a
, b
: TPlayerStat
): Integer;
615 if a
.Spectator
then Result
:= 1
616 else if b
.Spectator
then Result
:= -1
617 else if a
.Frags
< b
.Frags
then Result
:= 1
618 else if a
.Frags
> b
.Frags
then Result
:= -1
619 else if a
.Deaths
< b
.Deaths
then Result
:= -1
620 else if a
.Deaths
> b
.Deaths
then Result
:= 1
621 else if a
.Kills
< b
.Kills
then Result
:= -1
625 procedure SortGameStat(var stat
: TPlayerStatArray
);
630 if stat
= nil then Exit
;
632 for I
:= High(stat
) downto Low(stat
) do
633 for J
:= Low(stat
) to High(stat
) - 1 do
634 if Compare(stat
[J
], stat
[J
+ 1]) = 1 then
637 stat
[J
] := stat
[J
+ 1];
642 function g_Game_ModeToText(Mode
: Byte): string;
646 GM_DM
: Result
:= _lc
[I_MENU_GAME_TYPE_DM
];
647 GM_TDM
: Result
:= _lc
[I_MENU_GAME_TYPE_TDM
];
648 GM_CTF
: Result
:= _lc
[I_MENU_GAME_TYPE_CTF
];
649 GM_COOP
: Result
:= _lc
[I_MENU_GAME_TYPE_COOP
];
650 GM_SINGLE
: Result
:= _lc
[I_MENU_GAME_TYPE_SINGLE
];
654 function g_Game_TextToMode(Mode
: string): Byte;
657 Mode
:= UpperCase(Mode
);
658 if Mode
= _lc
[I_MENU_GAME_TYPE_DM
] then
663 if Mode
= _lc
[I_MENU_GAME_TYPE_TDM
] then
668 if Mode
= _lc
[I_MENU_GAME_TYPE_CTF
] then
673 if Mode
= _lc
[I_MENU_GAME_TYPE_COOP
] then
678 if Mode
= _lc
[I_MENU_GAME_TYPE_SINGLE
] then
685 function g_Game_IsNet(): Boolean;
687 Result
:= (gGameSettings
.GameType
in [GT_SERVER
, GT_CLIENT
]);
690 function g_Game_IsServer(): Boolean;
692 Result
:= (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
, GT_SERVER
]);
695 function g_Game_IsClient(): Boolean;
697 Result
:= (gGameSettings
.GameType
= GT_CLIENT
);
700 function g_Game_GetMegaWADInfo(WAD
: String): TMegaWADInfo
;
707 Result
.name
:= ExtractFileName(WAD
);
708 Result
.description
:= '';
711 w
:= TWADFile
.Create();
714 if not w
.GetResource('INTERSCRIPT', p
, len
) then
720 cfg
:= TConfig
.CreateMem(p
, len
);
721 Result
.name
:= cfg
.ReadStr('megawad', 'name', ExtractFileName(WAD
));
722 Result
.description
:= cfg
.ReadStr('megawad', 'description', '');
723 Result
.author
:= cfg
.ReadStr('megawad', 'author', '');
724 Result
.pic
:= cfg
.ReadStr('megawad', 'pic', '');
730 procedure g_Game_FreeWAD();
734 for a
:= 0 to High(MegaWAD
.res
.pic
) do
735 if MegaWAD
.res
.pic
[a
] <> '' then
736 g_Texture_Delete(MegaWAD
.res
.pic
[a
]);
738 for a
:= 0 to High(MegaWAD
.res
.mus
) do
739 if MegaWAD
.res
.mus
[a
] <> '' then
740 g_Sound_Delete(MegaWAD
.res
.mus
[a
]);
742 MegaWAD
.res
.pic
:= nil;
743 MegaWAD
.res
.text := nil;
744 MegaWAD
.res
.anim
:= nil;
745 MegaWAD
.res
.mus
:= nil;
746 MegaWAD
.triggers
:= nil;
748 g_Texture_Delete('TEXTURE_endpic');
749 g_Sound_Delete('MUSIC_endmus');
751 ZeroMemory(@MegaWAD
, SizeOf(MegaWAD
));
752 gGameSettings
.WAD
:= '';
755 procedure g_Game_LoadWAD(WAD
: string);
764 gGameSettings
.WAD
:= WAD
;
765 if not (gGameSettings
.GameMode
in [GM_COOP
, GM_SINGLE
]) then
768 MegaWAD
.info
:= g_Game_GetMegaWADInfo(WAD
);
770 w
:= TWADFile
.Create();
773 if not w
.GetResource('INTERSCRIPT', p
, len
) then
779 cfg
:= TConfig
.CreateMem(p
, len
);
784 s := cfg.ReadStr('pic', 'pic'+IntToStr(b), '');
785 if s = '' then Break;
788 SetLength(MegaWAD.res.pic, Length(MegaWAD.res.pic)+1);
789 MegaWAD.res.pic[High(MegaWAD.res.pic)] := s;
791 g_Texture_CreateWADEx(s, s);
797 s := cfg.ReadStr('mus', 'mus'+IntToStr(b), '');
798 if s = '' then Break;
801 SetLength(MegaWAD.res.mus, Length(MegaWAD.res.mus)+1);
802 MegaWAD.res.mus[High(MegaWAD.res.mus)] := s;
804 g_Music_CreateWADEx(s, s);
807 MegaWAD
.endpic
:= cfg
.ReadStr('megawad', 'endpic', '');
808 if MegaWAD
.endpic
<> '' then
810 TEXTUREFILTER
:= GL_LINEAR
;
811 s
:= e_GetResourcePath(WadDirs
, MegaWAD
.endpic
, WAD
);
812 g_Texture_CreateWADEx('TEXTURE_endpic', s
);
813 TEXTUREFILTER
:= GL_NEAREST
;
815 MegaWAD
.endmus
:= cfg
.ReadStr('megawad', 'endmus', 'Standart.wad:D2DMUS\ÊÎÍÅÖ');
816 if MegaWAD
.endmus
<> '' then
818 s
:= e_GetResourcePath(WadDirs
, MegaWAD
.endmus
, WAD
);
819 g_Sound_CreateWADEx('MUSIC_endmus', s
, True);
827 {procedure start_trigger(t: string);
831 function next_trigger(): Boolean;
835 procedure DisableCheats();
841 if gPlayer1
<> nil then gPlayer1
.GodMode
:= False;
842 if gPlayer2
<> nil then gPlayer2
.GodMode
:= False;
843 if gPlayer1
<> nil then gPlayer1
.NoTarget
:= False;
844 if gPlayer2
<> nil then gPlayer2
.NoTarget
:= False;
846 {$IF DEFINED(D2F_DEBUG)}
847 if gPlayer1
<> nil then gPlayer1
.NoTarget
:= True;
848 gAimLine
:= g_dbg_aimline_on
;
852 procedure g_Game_ExecuteEvent(Name
: String);
858 if gEvents
= nil then
860 for a
:= 0 to High(gEvents
) do
861 if gEvents
[a
].Name
= Name
then
863 if gEvents
[a
].Command
<> '' then
864 g_Console_Process(gEvents
[a
].Command
, True);
869 function g_Game_DelayEvent(DEType
: Byte; Time
: LongWord; Num
: Integer = 0; Str
: String = ''): Integer;
874 if gDelayedEvents
<> nil then
875 for a
:= 0 to High(gDelayedEvents
) do
876 if not gDelayedEvents
[a
].Pending
then
883 SetLength(gDelayedEvents
, Length(gDelayedEvents
) + 1);
884 n
:= High(gDelayedEvents
);
886 gDelayedEvents
[n
].Pending
:= True;
887 gDelayedEvents
[n
].DEType
:= DEType
;
888 gDelayedEvents
[n
].DENum
:= Num
;
889 gDelayedEvents
[n
].DEStr
:= Str
;
890 if DEType
= DE_GLOBEVENT
then
891 gDelayedEvents
[n
].Time
:= (sys_GetTicks() {div 1000}) + Time
893 gDelayedEvents
[n
].Time
:= gTime
+ Time
;
902 if g_Game_IsNet
and g_Game_IsServer
then
903 MH_SEND_GameEvent(NET_EV_MAPEND
, Byte(gMissionFailed
));
907 gPauseHolmes
:= false;
910 g_Game_StopAllSounds(False);
915 EndingGameCounter
:= 0;
916 g_ActiveWindow
:= nil;
918 gLMSRespawn
:= LMS_RESPAWN_NONE
;
919 gLMSRespawnTime
:= 0;
922 EXIT_SIMPLE
: // Âûõîä ÷åðåç ìåíþ èëè êîíåö òåñòà
927 begin // Ýòî áûë òåñò
931 begin // Âûõîä â ãëàâíîå ìåíþ
932 gMusic
.SetByName('MUSIC_MENU');
934 if gState
<> STATE_SLIST
then
936 g_GUI_ShowWindow('MainMenu');
937 gState
:= STATE_MENU
;
940 // Îáíîâëÿåì ñïèñîê ñåðâåðîâ
941 slReturnPressed
:= True;
942 if g_Net_Slist_Fetch(slCurrent
) then
944 if slCurrent
= nil then
945 slWaitStr
:= _lc
[I_NET_SLIST_NOSERVERS
];
948 slWaitStr
:= _lc
[I_NET_SLIST_ERROR
];
949 g_Serverlist_GenerateTable(slCurrent
, slTable
);
952 g_Game_ExecuteEvent('ongameend');
956 EXIT_RESTART
: // Íà÷àòü óðîâåíü ñíà÷àëà
958 if not g_Game_IsClient
then g_Game_Restart();
961 EXIT_ENDLEVELCUSTOM
: // Çàêîí÷èëñÿ óðîâåíü â Ñâîåé èãðå
963 // Ñòàòèñòèêà Ñâîåé èãðû:
964 FileName
:= g_ExtractWadName(gMapInfo
.Map
);
966 CustomStat
.GameTime
:= gTime
;
967 CustomStat
.Map
:= ExtractFileName(FileName
)+':'+g_ExtractFileName(gMapInfo
.Map
); //ResName;
968 CustomStat
.MapName
:= gMapInfo
.Name
;
969 CustomStat
.GameMode
:= gGameSettings
.GameMode
;
970 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
971 CustomStat
.TeamStat
:= gTeamStat
;
973 CustomStat
.PlayerStat
:= nil;
975 // Ñòàòèñòèêà èãðîêîâ:
976 if gPlayers
<> nil then
978 for a
:= 0 to High(gPlayers
) do
979 if gPlayers
[a
] <> nil then
981 SetLength(CustomStat
.PlayerStat
, Length(CustomStat
.PlayerStat
)+1);
982 with CustomStat
.PlayerStat
[High(CustomStat
.PlayerStat
)] do
985 Name
:= gPlayers
[a
].Name
;
986 Frags
:= gPlayers
[a
].Frags
;
987 Deaths
:= gPlayers
[a
].Death
;
988 Kills
:= gPlayers
[a
].Kills
;
989 Team
:= gPlayers
[a
].Team
;
990 Color
:= gPlayers
[a
].Model
.Color
;
991 Spectator
:= gPlayers
[a
].FSpectator
;
995 SortGameStat(CustomStat
.PlayerStat
);
998 g_Game_ExecuteEvent('onmapend');
999 if not g_Game_IsClient
then g_Player_ResetReady
;
1000 gInterReadyCount
:= 0;
1002 // Çàòóõàþùèé ýêðàí:
1003 EndingGameCounter
:= 255;
1004 gState
:= STATE_FOLD
;
1006 if gDefInterTime
< 0 then
1007 gInterEndTime
:= IfThen((gGameSettings
.GameType
= GT_SERVER
) and (gPlayer1
= nil), 15000, 25000)
1009 gInterEndTime
:= gDefInterTime
* 1000;
1012 EXIT_ENDLEVELSINGLE
: // Çàêîí÷èëñÿ óðîâåíü â Îäèíî÷íîé èãðå
1014 // Ñòàòèñòèêà Îäèíî÷íîé èãðû:
1015 SingleStat
.GameTime
:= gTime
;
1016 SingleStat
.TwoPlayers
:= gPlayer2
<> nil;
1017 SingleStat
.TotalSecrets
:= gSecretsCount
;
1018 // Ñòàòèñòèêà ïåðâîãî èãðîêà:
1019 SingleStat
.PlayerStat
[0].Kills
:= gPlayer1
.MonsterKills
;
1020 SingleStat
.PlayerStat
[0].Secrets
:= gPlayer1
.Secrets
;
1021 // Ñòàòèñòèêà âòîðîãî èãðîêà (åñëè åñòü):
1022 if SingleStat
.TwoPlayers
then
1024 SingleStat
.PlayerStat
[1].Kills
:= gPlayer2
.MonsterKills
;
1025 SingleStat
.PlayerStat
[1].Secrets
:= gPlayer2
.Secrets
;
1028 g_Game_ExecuteEvent('onmapend');
1031 if gNextMap
<> '' then
1033 gMusic
.SetByName('MUSIC_INTERMUS');
1035 gState
:= STATE_INTERSINGLE
;
1038 g_Game_ExecuteEvent('oninter');
1040 else // Áîëüøå íåò êàðò
1042 // Çàòóõàþùèé ýêðàí:
1043 EndingGameCounter
:= 255;
1044 gState
:= STATE_FOLD
;
1049 // Îêîí÷àíèå îáðàáîòàíî:
1050 if gExit
<> EXIT_QUIT
then
1054 procedure drawTime(X
, Y
: Integer); inline;
1056 e_TextureFontPrint(x
, y
,
1057 Format('%d:%.2d:%.2d', [
1058 gTime
div 1000 div 3600,
1059 (gTime
div 1000 div 60) mod 60,
1060 gTime
div 1000 mod 60
1065 procedure DrawStat();
1067 pc
, x
, y
, w
, h
: Integer;
1068 w1
, w2
, w3
, w4
: Integer;
1070 cw
, ch
, r
, g
, b
, rr
, gg
, bb
: Byte;
1073 stat
: TPlayerStatArray
;
1080 pc
:= g_Player_GetCount
;
1081 e_TextureFontGetSize(gStdFont
, cw
, ch
);
1083 w
:= gScreenWidth
-(gScreenWidth
div 5);
1084 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
1087 h
:= 40+ch
*5+(ch
+8)*pc
;
1088 x
:= (gScreenWidth
div 2)-(w
div 2);
1089 y
:= (gScreenHeight
div 2)-(h
div 2);
1091 e_DrawFillQuad(x
, y
, x
+w
-1, y
+h
-1, 64, 64, 64, 32);
1092 e_DrawQuad(x
, y
, x
+w
-1, y
+h
-1, 255, 127, 0);
1094 drawTime(x
+w
-78, y
+8);
1096 wad
:= g_ExtractWadNameNoPath(gMapInfo
.Map
);
1097 map
:= g_ExtractFileName(gMapInfo
.Map
);
1098 mapstr
:= wad
+ ':\' + map
+ ' - ' + gMapInfo
.Name
;
1100 case gGameSettings
.GameMode
of
1103 if gGameSettings
.MaxLives
= 0 then
1104 s1
:= _lc
[I_GAME_DM
]
1106 s1
:= _lc
[I_GAME_LMS
];
1107 s2
:= Format(_lc
[I_GAME_FRAG_LIMIT
], [gGameSettings
.GoalLimit
]);
1108 s3
:= Format(_lc
[I_GAME_TIME_LIMIT
], [gGameSettings
.TimeLimit
div 3600, (gGameSettings
.TimeLimit
div 60) mod 60, gGameSettings
.TimeLimit
mod 60]);
1113 if gGameSettings
.MaxLives
= 0 then
1114 s1
:= _lc
[I_GAME_TDM
]
1116 s1
:= _lc
[I_GAME_TLMS
];
1117 s2
:= Format(_lc
[I_GAME_FRAG_LIMIT
], [gGameSettings
.GoalLimit
]);
1118 s3
:= Format(_lc
[I_GAME_TIME_LIMIT
], [gGameSettings
.TimeLimit
div 3600, (gGameSettings
.TimeLimit
div 60) mod 60, gGameSettings
.TimeLimit
mod 60]);
1123 s1
:= _lc
[I_GAME_CTF
];
1124 s2
:= Format(_lc
[I_GAME_SCORE_LIMIT
], [gGameSettings
.GoalLimit
]);
1125 s3
:= Format(_lc
[I_GAME_TIME_LIMIT
], [gGameSettings
.TimeLimit
div 3600, (gGameSettings
.TimeLimit
div 60) mod 60, gGameSettings
.TimeLimit
mod 60]);
1130 if gGameSettings
.MaxLives
= 0 then
1131 s1
:= _lc
[I_GAME_COOP
]
1133 s1
:= _lc
[I_GAME_SURV
];
1134 s2
:= _lc
[I_GAME_MONSTERS
] + ' ' + IntToStr(gCoopMonstersKilled
) + '/' + IntToStr(gTotalMonsters
);
1135 s3
:= _lc
[I_GAME_SECRETS
] + ' ' + IntToStr(gCoopSecretsFound
) + '/' + IntToStr(gSecretsCount
);
1146 e_TextureFontPrintEx(x
+(w
div 2)-(Length(s1
)*cw
div 2), _y
, s1
, gStdFont
, 255, 255, 255, 1);
1148 e_TextureFontPrintEx(x
+(w
div 2)-(Length(mapstr
)*cw
div 2), _y
, mapstr
, gStdFont
, 200, 200, 200, 1);
1150 e_TextureFontPrintEx(x
+16, _y
, s2
, gStdFont
, 200, 200, 200, 1);
1152 e_TextureFontPrintEx(x
+w
-16-(Length(s3
))*cw
, _y
, s3
,
1153 gStdFont
, 200, 200, 200, 1);
1155 if NetMode
= NET_SERVER
then
1156 e_TextureFontPrintEx(x
+8, y
+ 8, _lc
[I_NET_SERVER
], gStdFont
, 255, 255, 255, 1)
1158 if NetMode
= NET_CLIENT
then
1159 e_TextureFontPrintEx(x
+8, y
+ 8,
1160 NetClientIP
+ ':' + IntToStr(NetClientPort
), gStdFont
, 255, 255, 255, 1);
1164 stat
:= g_Player_GetStats();
1167 w2
:= (w
-16) div 6 + 48; // øèðèíà 2 ñòîëáöà
1168 w3
:= (w
-16) div 6; // øèðèíà 3 è 4 ñòîëáöîâ
1170 w1
:= w
-16-w2
-w3
-w4
; // îñòàâøååñÿ ïðîñòðàíñòâî - äëÿ öâåòà è èìåíè èãðîêà
1172 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
1176 for a
:= TEAM_RED
to TEAM_BLUE
do
1178 if a
= TEAM_RED
then
1180 s1
:= _lc
[I_GAME_TEAM_RED
];
1187 s1
:= _lc
[I_GAME_TEAM_BLUE
];
1193 e_TextureFontPrintEx(x
+16, _y
, s1
, gStdFont
, r
, g
, b
, 1);
1194 e_TextureFontPrintEx(x
+w1
+16, _y
, IntToStr(gTeamStat
[a
].Goals
),
1195 gStdFont
, r
, g
, b
, 1);
1197 _y
:= _y
+ch
+(ch
div 4);
1198 e_DrawLine(1, x
+16, _y
, x
+w
-16, _y
, r
, g
, b
);
1199 _y
:= _y
+(ch
div 4);
1201 for aa
:= 0 to High(stat
) do
1202 if stat
[aa
].Team
= a
then
1218 e_TextureFontPrintEx(x
+16, _y
, Name
, gStdFont
, rr
, gg
, bb
, 1);
1220 e_TextureFontPrintEx(x
+w1
+16, _y
, Format(_lc
[I_GAME_PING_MS
], [Ping
, Loss
]), gStdFont
, rr
, gg
, bb
, 1);
1222 e_TextureFontPrintEx(x
+w1
+w2
+16, _y
, IntToStr(Frags
), gStdFont
, rr
, gg
, bb
, 1);
1224 e_TextureFontPrintEx(x
+w1
+w2
+w3
+16, _y
, IntToStr(Deaths
), gStdFont
, rr
, gg
, bb
, 1);
1231 else if gGameSettings
.GameMode
in [GM_DM
, GM_COOP
] then
1234 e_TextureFontPrintEx(x
+16, _y
, _lc
[I_GAME_PLAYER_NAME
], gStdFont
, 255, 127, 0, 1);
1235 e_TextureFontPrintEx(x
+16+w1
, _y
, _lc
[I_GAME_PING
], gStdFont
, 255, 127, 0, 1);
1236 e_TextureFontPrintEx(x
+16+w1
+w2
, _y
, _lc
[I_GAME_FRAGS
], gStdFont
, 255, 127, 0, 1);
1237 e_TextureFontPrintEx(x
+16+w1
+w2
+w3
, _y
, _lc
[I_GAME_DEATHS
], gStdFont
, 255, 127, 0, 1);
1240 for aa
:= 0 to High(stat
) do
1254 e_DrawFillQuad(x
+16, _y
+4, x
+32-1, _y
+16+4-1, Color
.R
, Color
.G
, Color
.B
, 0);
1255 e_DrawQuad(x
+16, _y
+4, x
+32-1, _y
+16+4-1, 192, 192, 192);
1257 e_TextureFontPrintEx(x
+16+16+8, _y
+4, Name
, gStdFont
, r
, g
, 0, 1);
1259 e_TextureFontPrintEx(x
+w1
+16, _y
+4, Format(_lc
[I_GAME_PING_MS
], [Ping
, Loss
]), gStdFont
, r
, g
, 0, 1);
1261 e_TextureFontPrintEx(x
+w1
+w2
+16, _y
+4, IntToStr(Frags
), gStdFont
, r
, g
, 0, 1);
1263 e_TextureFontPrintEx(x
+w1
+w2
+w3
+16, _y
+4, IntToStr(Deaths
), gStdFont
, r
, g
, 0, 1);
1269 procedure g_Game_Init();
1272 knownFiles
: array of AnsiString = nil;
1274 wext
, s
: AnsiString;
1279 gTempDelete
:= False;
1281 sfsGCDisable(); // temporary disable removing of temporary volumes
1284 TEXTUREFILTER
:= GL_LINEAR
;
1285 g_Texture_CreateWADEx('MENU_BACKGROUND', GameWAD
+':TEXTURES\TITLE');
1286 g_Texture_CreateWADEx('INTER', GameWAD
+':TEXTURES\INTER');
1287 g_Texture_CreateWADEx('ENDGAME_EN', GameWAD
+':TEXTURES\ENDGAME_EN');
1288 g_Texture_CreateWADEx('ENDGAME_RU', GameWAD
+':TEXTURES\ENDGAME_RU');
1289 TEXTUREFILTER
:= GL_NEAREST
;
1291 LoadStdFont('STDTXT', 'STDFONT', gStdFont
);
1292 LoadFont('MENUTXT', 'MENUFONT', gMenuFont
);
1293 LoadFont('SMALLTXT', 'SMALLFONT', gMenuSmallFont
);
1295 g_Game_ClearLoading();
1296 g_Game_SetLoadingText(Format('Doom 2D: Forever %s', [GAME_VERSION
]), 0, False);
1297 g_Game_SetLoadingText('', 0, False);
1299 g_Game_SetLoadingText(_lc
[I_LOAD_CONSOLE
], 0, False);
1302 g_Game_SetLoadingText(_lc
[I_LOAD_MODELS
], 0, False);
1303 g_PlayerModel_LoadData();
1305 // load models from all possible wad types, in all known directories
1306 // this does a loosy job (linear search, ooph!), but meh
1307 for wext
in wadExtensions
do
1309 for f
:= High(ModelDirs
) downto Low(ModelDirs
) do
1311 if (FindFirst(ModelDirs
[f
]+DirectorySeparator
+'*'+wext
, faAnyFile
, SR
) = 0) then
1315 for s
in knownFiles
do
1317 if (strEquCI1251(forceFilenameExt(SR
.Name
, ''), forceFilenameExt(ExtractFileName(s
), ''))) then
1325 SetLength(knownFiles
, length(knownFiles
)+1);
1326 knownFiles
[High(knownFiles
)] := ModelDirs
[f
]+DirectorySeparator
+SR
.Name
;
1328 until (FindNext(SR
) <> 0);
1334 if (length(knownFiles
) = 0) then raise Exception
.Create('no player models found!');
1336 if (length(knownFiles
) = 1) then e_LogWriteln('1 player model found.', TMsgType
.Notify
) else e_LogWritefln('%d player models found.', [Integer(length(knownFiles
))], TMsgType
.Notify
);
1337 for s
in knownFiles
do
1339 if not g_PlayerModel_Load(s
) then e_LogWritefln('Error loading model "%s"', [s
], TMsgType
.Warning
);
1343 gPauseMain
:= false;
1344 gPauseHolmes
:= false;
1347 {e_MouseInfo.Accel := 1.0;}
1349 g_Game_SetLoadingText(_lc
[I_LOAD_GAME_DATA
], 0, False);
1352 g_Game_SetLoadingText(_lc
[I_LOAD_MUSIC
], 0, False);
1353 g_Sound_CreateWADEx('MUSIC_INTERMUS', GameWAD
+':MUSIC\INTERMUS', True);
1354 g_Sound_CreateWADEx('MUSIC_MENU', GameWAD
+':MUSIC\MENU', True);
1355 g_Sound_CreateWADEx('MUSIC_ROUNDMUS', GameWAD
+':MUSIC\ROUNDMUS', True, True);
1356 g_Sound_CreateWADEx('MUSIC_STDENDMUS', GameWAD
+':MUSIC\ENDMUS', True);
1359 g_Game_SetLoadingText(_lc
[I_LOAD_MENUS
], 0, False);
1363 gMusic
:= TMusic
.Create();
1364 gMusic
.SetByName('MUSIC_MENU');
1367 gGameSettings
.WarmupTime
:= 30;
1369 gState
:= STATE_MENU
;
1371 SetLength(gEvents
, 6);
1372 gEvents
[0].Name
:= 'ongamestart';
1373 gEvents
[1].Name
:= 'ongameend';
1374 gEvents
[2].Name
:= 'onmapstart';
1375 gEvents
[3].Name
:= 'onmapend';
1376 gEvents
[4].Name
:= 'oninter';
1377 gEvents
[5].Name
:= 'onwadend';
1379 sfsGCEnable(); // enable releasing unused volumes
1383 procedure g_Game_Free(freeTextures
: Boolean=true);
1385 if NetMode
= NET_CLIENT
then g_Net_Disconnect();
1386 if NetMode
= NET_SERVER
then g_Net_Host_Die();
1388 g_Map_Free(freeTextures
);
1390 g_Player_RemoveAllCorpses();
1392 gGameSettings
.GameType
:= GT_NONE
;
1393 if gGameSettings
.GameMode
= GM_SINGLE
then
1394 gGameSettings
.GameMode
:= GM_DM
;
1395 gSwitchGameMode
:= gGameSettings
.GameMode
;
1398 gExitByTrigger
:= False;
1401 function IsActivePlayer(p
: TPlayer
): Boolean;
1406 Result
:= (not p
.FDummy
) and (not p
.FSpectator
);
1409 function GetActivePlayer_ByID(ID
: Integer): TPlayer
;
1416 if gPlayers
= nil then
1418 for a
:= Low(gPlayers
) to High(gPlayers
) do
1419 if IsActivePlayer(gPlayers
[a
]) then
1421 if gPlayers
[a
].UID
<> ID
then
1423 Result
:= gPlayers
[a
];
1428 function GetActivePlayerID_Next(Skip
: Integer = -1): Integer;
1434 if gPlayers
= nil then
1438 for a
:= Low(gPlayers
) to High(gPlayers
) do
1439 if IsActivePlayer(gPlayers
[a
]) then
1441 SetLength(ids
, Length(ids
) + 1);
1442 ids
[High(ids
)] := gPlayers
[a
].UID
;
1443 if gPlayers
[a
].UID
= Skip
then
1446 if Length(ids
) = 0 then
1451 Result
:= ids
[(idx
+ 1) mod Length(ids
)];
1454 function GetActivePlayerID_Prev(Skip
: Integer = -1): Integer;
1460 if gPlayers
= nil then
1464 for a
:= Low(gPlayers
) to High(gPlayers
) do
1465 if IsActivePlayer(gPlayers
[a
]) then
1467 SetLength(ids
, Length(ids
) + 1);
1468 ids
[High(ids
)] := gPlayers
[a
].UID
;
1469 if gPlayers
[a
].UID
= Skip
then
1472 if Length(ids
) = 0 then
1475 Result
:= ids
[Length(ids
) - 1]
1477 Result
:= ids
[(Length(ids
) - 1 + idx
) mod Length(ids
)];
1480 function GetActivePlayerID_Random(Skip
: Integer = -1): Integer;
1486 if gPlayers
= nil then
1490 for a
:= Low(gPlayers
) to High(gPlayers
) do
1491 if IsActivePlayer(gPlayers
[a
]) then
1493 SetLength(ids
, Length(ids
) + 1);
1494 ids
[High(ids
)] := gPlayers
[a
].UID
;
1495 if gPlayers
[a
].UID
= Skip
then
1498 if Length(ids
) = 0 then
1500 if Length(ids
) = 1 then
1505 Result
:= ids
[Random(Length(ids
))];
1507 while (idx
<> -1) and (Result
= Skip
) and (a
> 0) do
1509 Result
:= ids
[Random(Length(ids
))];
1514 function GetRandomSpectMode(Current
: Byte): Byte;
1521 0: Result
:= SPECT_STATS
;
1522 1: Result
:= SPECT_MAPVIEW
;
1523 2: Result
:= SPECT_MAPVIEW
;
1524 3: Result
:= SPECT_PLAYERS
;
1525 4: Result
:= SPECT_PLAYERS
;
1526 5: Result
:= SPECT_PLAYERS
;
1527 6: Result
:= SPECT_PLAYERS
;
1529 if (Current
in [SPECT_STATS
, SPECT_MAPVIEW
]) and (Current
= Result
) then
1533 procedure ProcessPlayerControls (plr
: TPlayer
; p
: Integer; var MoveButton
: Byte);
1539 if (plr
= nil) then exit
;
1540 if (p
= 2) then time
:= 1000 else time
:= 1;
1541 strafeDir
:= MoveButton
shr 4;
1542 MoveButton
:= MoveButton
and $0F;
1544 if gPlayerAction
[p
, ACTION_MOVELEFT
] and (not gPlayerAction
[p
, ACTION_MOVERIGHT
]) then
1545 MoveButton
:= 1 // Íàæàòà òîëüêî "Âëåâî"
1546 else if (not gPlayerAction
[p
, ACTION_MOVELEFT
]) and gPlayerAction
[p
, ACTION_MOVERIGHT
] then
1547 MoveButton
:= 2 // Íàæàòà òîëüêî "Âïðàâî"
1548 else if (not gPlayerAction
[p
, ACTION_MOVELEFT
]) and (not gPlayerAction
[p
, ACTION_MOVERIGHT
]) then
1549 MoveButton
:= 0; // Íå íàæàòû íè "Âëåâî", íè "Âïðàâî"
1551 // Ñåé÷àñ èëè ðàíüøå áûëè íàæàòû "Âëåâî"/"Âïðàâî" => ïåðåäàåì èãðîêó:
1552 if MoveButton
= 1 then
1553 plr
.PressKey(KEY_LEFT
, time
)
1554 else if MoveButton
= 2 then
1555 plr
.PressKey(KEY_RIGHT
, time
);
1557 // if we have "strafe" key, turn off old strafe mechanics
1558 if gPlayerAction
[p
, ACTION_STRAFE
] then
1560 // new strafe mechanics
1561 if (strafeDir
= 0) then
1562 strafeDir
:= MoveButton
; // start strafing
1563 // now set direction according to strafe (reversed)
1564 if (strafeDir
= 2) then
1565 plr
.SetDirection(TDirection
.D_LEFT
)
1566 else if (strafeDir
= 1) then
1567 plr
.SetDirection(TDirection
.D_RIGHT
)
1571 strafeDir
:= 0; // not strafing anymore
1572 // Ðàíüøå áûëà íàæàòà "Âïðàâî", à ñåé÷àñ "Âëåâî" => áåæèì âïðàâî, ñìîòðèì âëåâî:
1573 if (MoveButton
= 2) and gPlayerAction
[p
, ACTION_MOVELEFT
] then
1574 plr
.SetDirection(TDirection
.D_LEFT
)
1575 // Ðàíüøå áûëà íàæàòà "Âëåâî", à ñåé÷àñ "Âïðàâî" => áåæèì âëåâî, ñìîòðèì âïðàâî:
1576 else if (MoveButton
= 1) and gPlayerAction
[p
, ACTION_MOVERIGHT
] then
1577 plr
.SetDirection(TDirection
.D_RIGHT
)
1578 // ×òî-òî áûëî íàæàòî è íå èçìåíèëîñü => êóäà áåæèì, òóäà è ñìîòðèì:
1579 else if MoveButton
<> 0 then
1580 plr
.SetDirection(TDirection(MoveButton
-1))
1583 // fix movebutton state
1584 MoveButton
:= MoveButton
or (strafeDir
shl 4);
1586 // Îñòàëüíûå êëàâèøè:
1587 if gPlayerAction
[p
, ACTION_JUMP
] then plr
.PressKey(KEY_JUMP
, time
);
1588 if gPlayerAction
[p
, ACTION_LOOKUP
] then plr
.PressKey(KEY_UP
, time
);
1589 if gPlayerAction
[p
, ACTION_LOOKDOWN
] then plr
.PressKey(KEY_DOWN
, time
);
1590 if gPlayerAction
[p
, ACTION_ATTACK
] then plr
.PressKey(KEY_FIRE
);
1591 if gPlayerAction
[p
, ACTION_WEAPNEXT
] then plr
.PressKey(KEY_NEXTWEAPON
);
1592 if gPlayerAction
[p
, ACTION_WEAPPREV
] then plr
.PressKey(KEY_PREVWEAPON
);
1593 if gPlayerAction
[p
, ACTION_ACTIVATE
] then plr
.PressKey(KEY_OPEN
);
1595 gPlayerAction
[p
, ACTION_WEAPNEXT
] := False; // HACK, remove after readyweaon&pendinweapon implementation
1596 gPlayerAction
[p
, ACTION_WEAPPREV
] := False; // HACK, remove after readyweaon&pendinweapon implementation
1598 for i
:= WP_FIRST
to WP_LAST
do
1600 if gSelectWeapon
[p
, i
] then
1602 plr
.QueueWeaponSwitch(i
); // all choices are passed there, and god will take the best
1603 gSelectWeapon
[p
, i
] := False
1607 // HACK: add dynlight here
1608 if gwin_k8_enable_light_experiments
then
1610 if e_KeyPressed(IK_F8
) and gGameOn
and (not gConsoleShow
) and (g_ActiveWindow
= nil) then
1612 g_playerLight
:= true;
1614 if e_KeyPressed(IK_F9
) and gGameOn
and (not gConsoleShow
) and (g_ActiveWindow
= nil) then
1616 g_playerLight
:= false;
1620 if gwin_has_stencil
and g_playerLight
then g_AddDynLight(plr
.GameX
+32, plr
.GameY
+40, 128, 1, 1, 0, 0.6);
1623 // HACK: don't have a "key was pressed" function
1624 procedure InterReady();
1626 if InterReadyTime
> gTime
then Exit
;
1627 InterReadyTime
:= gTime
+ 3000;
1628 MC_SEND_CheatRequest(NET_CHEAT_READY
);
1631 procedure g_Game_Update();
1633 Msg
: g_gui
.TMessage
;
1639 function sendMonsPos (mon
: TMonster
): Boolean;
1641 result
:= false; // don't stop
1642 // this will also reset "need-send" flag
1643 if mon
.gncNeedSend
then
1645 MH_SEND_MonsterPos(mon
.UID
);
1647 else if (mon
.MonsterType
= MONSTER_BARREL
) then
1649 if (mon
.GameVelX
<> 0) or (mon
.GameVelY
<> 0) then MH_SEND_MonsterPos(mon
.UID
);
1651 else if (mon
.MonsterState
<> MONSTATE_SLEEP
) then
1653 if (mon
.MonsterState
<> MONSTATE_DEAD
) or (mon
.GameVelX
<> 0) or (mon
.GameVelY
<> 0) then MH_SEND_MonsterPos(mon
.UID
);
1657 function sendMonsPosUnexpected (mon
: TMonster
): Boolean;
1659 result
:= false; // don't stop
1660 // this will also reset "need-send" flag
1661 if mon
.gncNeedSend
then MH_SEND_MonsterPos(mon
.UID
);
1665 reliableUpdate
: Boolean;
1670 // Ïîðà âûêëþ÷àòü èãðó:
1671 if gExit
= EXIT_QUIT
then
1673 // Èãðà çàêîí÷èëàñü - îáðàáàòûâàåì:
1677 if gExit
= EXIT_QUIT
then
1681 // ×èòàåì êëàâèàòóðó è äæîéñòèê, åñëè îêíî àêòèâíî
1682 // no need to, as we'll do it in event handler
1684 // Îáíîâëÿåì êîíñîëü (äâèæåíèå è ñîîáùåíèÿ):
1687 if (NetMode
= NET_NONE
) and (g_Game_IsNet
) and (gGameOn
or (gState
in [STATE_FOLD
, STATE_INTERCUSTOM
])) then
1689 gExit
:= EXIT_SIMPLE
;
1694 // process master server communications
1695 g_Net_Slist_Pulse();
1698 STATE_INTERSINGLE
, // Ñòàòèñòêà ïîñëå ïðîõîæäåíèÿ óðîâíÿ â Îäèíî÷íîé èãðå
1699 STATE_INTERCUSTOM
, // Ñòàòèñòêà ïîñëå ïðîõîæäåíèÿ óðîâíÿ â Ñâîåé èãðå
1700 STATE_INTERTEXT
, // Òåêñò ìåæäó óðîâíÿìè
1701 STATE_INTERPIC
: // Êàðòèíêà ìåæäó óðîâíÿìè
1703 if g_Game_IsNet
and g_Game_IsServer
then
1705 gInterTime
:= gInterTime
+ GAME_TICK
;
1706 a
:= Min((gInterEndTime
- gInterTime
) div 1000 + 1, 255);
1707 if a
<> gServInterTime
then
1709 gServInterTime
:= a
;
1710 MH_SEND_TimeSync(gServInterTime
);
1714 if (not g_Game_IsClient
) and
1718 e_KeyPressed(IK_RETURN
) or e_KeyPressed(IK_KPRETURN
) or e_KeyPressed(IK_SPACE
) or
1719 e_KeyPressed(VK_FIRE
) or e_KeyPressed(VK_OPEN
) or
1720 e_KeyPressed(JOY0_ATTACK
) or e_KeyPressed(JOY1_ATTACK
) or
1721 e_KeyPressed(JOY2_ATTACK
) or e_KeyPressed(JOY3_ATTACK
)
1723 and (not gJustChatted
) and (not gConsoleShow
) and (not gChatShow
)
1724 and (g_ActiveWindow
= nil)
1726 or (g_Game_IsNet
and ((gInterTime
> gInterEndTime
) or (gInterReadyCount
>= NetClientCount
)))
1729 begin // Íàæàëè <Enter>/<Ïðîáåë> èëè ïðîøëî äîñòàòî÷íî âðåìåíè:
1730 g_Game_StopAllSounds(True);
1732 if gMapOnce
then // Ýòî áûë òåñò
1733 gExit
:= EXIT_SIMPLE
1735 if gNextMap
<> '' then // Ïåðåõîäèì íà ñëåäóþùóþ êàðòó
1736 g_Game_ChangeMap(gNextMap
)
1737 else // Ñëåäóþùåé êàðòû íåò
1739 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
] then
1741 // Âûõîä â ãëàâíîå ìåíþ:
1743 g_GUI_ShowWindow('MainMenu');
1744 gMusic
.SetByName('MUSIC_MENU');
1746 gState
:= STATE_MENU
;
1749 // Ôèíàëüíàÿ êàðòèíêà:
1750 g_Game_ExecuteEvent('onwadend');
1752 if not gMusic
.SetByName('MUSIC_endmus') then
1753 gMusic
.SetByName('MUSIC_STDENDMUS');
1755 gState
:= STATE_ENDPIC
;
1757 g_Game_ExecuteEvent('ongameend');
1762 else if g_Game_IsClient
and
1765 e_KeyPressed(IK_RETURN
) or e_KeyPressed(IK_KPRETURN
) or e_KeyPressed(IK_SPACE
) or
1766 e_KeyPressed(VK_FIRE
) or e_KeyPressed(VK_OPEN
) or
1767 e_KeyPressed(JOY0_ATTACK
) or e_KeyPressed(JOY1_ATTACK
) or
1768 e_KeyPressed(JOY2_ATTACK
) or e_KeyPressed(JOY3_ATTACK
)
1770 and (not gJustChatted
) and (not gConsoleShow
) and (not gChatShow
)
1771 and (g_ActiveWindow
= nil)
1779 if gState
= STATE_INTERTEXT
then
1780 if InterText
.counter
> 0 then
1781 InterText
.counter
:= InterText
.counter
- 1;
1784 STATE_FOLD
: // Çàòóõàíèå ýêðàíà
1786 if EndingGameCounter
= 0 then
1788 // Çàêîí÷èëñÿ óðîâåíü â Ñâîåé èãðå:
1789 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
1791 InterReadyTime
:= -1;
1792 if gLastMap
and (gGameSettings
.GameMode
= GM_COOP
) then
1794 g_Game_ExecuteEvent('onwadend');
1795 if not gMusic
.SetByName('MUSIC_endmus') then
1796 gMusic
.SetByName('MUSIC_STDENDMUS');
1799 gMusic
.SetByName('MUSIC_ROUNDMUS');
1802 gState
:= STATE_INTERCUSTOM
;
1805 else // Çàêîí÷èëàñü ïîñëåäíÿÿ êàðòà â Îäèíî÷íîé èãðå
1807 gMusic
.SetByName('MUSIC_INTERMUS');
1809 gState
:= STATE_INTERSINGLE
;
1812 g_Game_ExecuteEvent('oninter');
1815 DecMin(EndingGameCounter
, 6, 0);
1818 STATE_ENDPIC
: // Êàðòèíêà îêîí÷àíèÿ ìåãàÂàäà
1820 if gMapOnce
then // Ýòî áûë òåñò
1822 gExit
:= EXIT_SIMPLE
;
1828 g_Serverlist_Control(slCurrent
, slTable
);
1831 // Ñòàòèñòèêà ïî Tab:
1833 IsDrawStat
:= (not gConsoleShow
) and (not gChatShow
) and (gGameSettings
.GameType
<> GT_SINGLE
) and g_Console_Action(ACTION_SCORES
);
1836 if gGameOn
and not gPause
and (gState
<> STATE_FOLD
) then
1838 // Âðåìÿ += 28 ìèëëèñåêóíä:
1839 gTime
:= gTime
+ GAME_TICK
;
1841 // Ñîîáùåíèå ïîñåðåäèíå ýêðàíà:
1842 if MessageTime
= 0 then
1844 if MessageTime
> 0 then
1845 MessageTime
:= MessageTime
- 1;
1847 if (g_Game_IsServer
) then
1849 // Áûë çàäàí ëèìèò âðåìåíè:
1850 if (gGameSettings
.TimeLimit
> 0) then
1851 if (gTime
- gGameStartTime
) div 1000 >= gGameSettings
.TimeLimit
then
1852 begin // Îí ïðîøåë => êîíåö óðîâíÿ
1857 // Íàäî ðåñïàâíèòü èãðîêîâ â LMS:
1858 if (gLMSRespawn
> LMS_RESPAWN_NONE
) and (gLMSRespawnTime
< gTime
) then
1859 g_Game_RestartRound(gLMSSoftSpawn
);
1861 // Ïðîâåðèì ðåçóëüòàò ãîëîñîâàíèÿ, åñëè âðåìÿ ïðîøëî
1862 if gVoteInProgress
and (gVoteTimer
< gTime
) then
1864 else if gVotePassed
and (gVoteCmdTimer
< gTime
) then
1866 g_Console_Process(gVoteCommand
);
1868 gVotePassed
:= False;
1871 // Çàìåðÿåì âðåìÿ çàõâàòà ôëàãîâ
1872 if gFlags
[FLAG_RED
].State
= FLAG_STATE_CAPTURED
then
1873 gFlags
[FLAG_RED
].CaptureTime
:= gFlags
[FLAG_RED
].CaptureTime
+ GAME_TICK
;
1874 if gFlags
[FLAG_BLUE
].State
= FLAG_STATE_CAPTURED
then
1875 gFlags
[FLAG_BLUE
].CaptureTime
:= gFlags
[FLAG_BLUE
].CaptureTime
+ GAME_TICK
;
1877 // Áûë çàäàí ëèìèò ïîáåä:
1878 if (gGameSettings
.GoalLimit
> 0) then
1882 if gGameSettings
.GameMode
= GM_DM
then
1883 begin // Â DM èùåì èãðîêà ñ max ôðàãàìè
1884 for i
:= 0 to High(gPlayers
) do
1885 if gPlayers
[i
] <> nil then
1886 if gPlayers
[i
].Frags
> b
then
1887 b
:= gPlayers
[i
].Frags
;
1890 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
1891 begin //  CTF/TDM âûáèðàåì êîìàíäó ñ íàèáîëüøèì ñ÷åòîì
1892 b
:= Max(gTeamStat
[TEAM_RED
].Goals
, gTeamStat
[TEAM_BLUE
].Goals
);
1895 // Ëèìèò ïîáåä íàáðàí => êîíåö óðîâíÿ:
1896 if b
>= gGameSettings
.GoalLimit
then
1903 // Îáðàáàòûâàåì êëàâèøè èãðîêîâ:
1904 if gPlayer1
<> nil then gPlayer1
.ReleaseKeys();
1905 if gPlayer2
<> nil then gPlayer2
.ReleaseKeys();
1906 if (not gConsoleShow
) and (not gChatShow
) and (g_ActiveWindow
= nil) then
1908 ProcessPlayerControls(gPlayer1
, 0, P1MoveButton
);
1909 ProcessPlayerControls(gPlayer2
, 1, P2MoveButton
);
1910 end // if not console
1913 if g_Game_IsNet
and (gPlayer1
<> nil) then gPlayer1
.PressKey(KEY_CHAT
, 10000);
1915 // process weapon switch queue
1919 if (gPlayer1
= nil) and (gPlayer2
= nil) and
1920 (not gConsoleShow
) and (not gChatShow
) and (g_ActiveWindow
= nil) then
1922 if not gSpectKeyPress
then
1924 if gPlayerAction
[0, ACTION_JUMP
] and (not gSpectAuto
) then
1926 // switch spect mode
1928 SPECT_NONE
: ; // not spectator
1930 SPECT_MAPVIEW
: Inc(gSpectMode
);
1931 SPECT_PLAYERS
: gSpectMode
:= SPECT_STATS
; // reset to 1
1933 gSpectKeyPress
:= True;
1935 if (gSpectMode
= SPECT_MAPVIEW
)
1936 and (not gSpectAuto
) then
1938 if gPlayerAction
[0, ACTION_MOVELEFT
] then
1939 gSpectX
:= Max(gSpectX
- gSpectStep
, 0);
1940 if gPlayerAction
[0, ACTION_MOVERIGHT
] then
1941 gSpectX
:= Min(gSpectX
+ gSpectStep
, gMapInfo
.Width
- gScreenWidth
);
1942 if gPlayerAction
[0, ACTION_LOOKUP
] then
1943 gSpectY
:= Max(gSpectY
- gSpectStep
, 0);
1944 if gPlayerAction
[0, ACTION_LOOKDOWN
] then
1945 gSpectY
:= Min(gSpectY
+ gSpectStep
, gMapInfo
.Height
- gScreenHeight
);
1946 if gPlayerAction
[0, ACTION_WEAPPREV
] then
1949 if gSpectStep
> 4 then gSpectStep
:= gSpectStep
shr 1;
1950 gSpectKeyPress
:= True;
1952 if gPlayerAction
[0, ACTION_WEAPNEXT
] then
1955 if gSpectStep
< 64 then gSpectStep
:= gSpectStep
shl 1;
1956 gSpectKeyPress
:= True;
1959 if (gSpectMode
= SPECT_PLAYERS
)
1960 and (not gSpectAuto
) then
1962 if gPlayerAction
[0, ACTION_LOOKUP
] then
1965 gSpectViewTwo
:= True;
1966 gSpectKeyPress
:= True;
1968 if gPlayerAction
[0, ACTION_LOOKDOWN
] then
1970 // remove second view
1971 gSpectViewTwo
:= False;
1972 gSpectKeyPress
:= True;
1974 if gPlayerAction
[0, ACTION_MOVELEFT
] then
1976 // prev player (view 1)
1977 gSpectPID1
:= GetActivePlayerID_Prev(gSpectPID1
);
1978 gSpectKeyPress
:= True;
1980 if gPlayerAction
[0, ACTION_MOVERIGHT
] then
1982 // next player (view 1)
1983 gSpectPID1
:= GetActivePlayerID_Next(gSpectPID1
);
1984 gSpectKeyPress
:= True;
1986 if gPlayerAction
[0, ACTION_WEAPPREV
] then
1988 // prev player (view 2)
1989 gSpectPID2
:= GetActivePlayerID_Prev(gSpectPID2
);
1990 gSpectKeyPress
:= True;
1992 if gPlayerAction
[0, ACTION_WEAPNEXT
] then
1994 // next player (view 2)
1995 gSpectPID2
:= GetActivePlayerID_Next(gSpectPID2
);
1996 gSpectKeyPress
:= True;
1999 if gPlayerAction
[0, ACTION_ATTACK
] then
2001 if (gSpectMode
= SPECT_STATS
) and (not gSpectAuto
) then
2004 gSpectAutoNext
:= 0;
2005 gSpectViewTwo
:= False;
2006 gSpectKeyPress
:= True;
2011 gSpectMode
:= SPECT_STATS
;
2012 gSpectAuto
:= False;
2013 gSpectKeyPress
:= True;
2018 if (not gPlayerAction
[0, ACTION_JUMP
]) and
2019 (not gPlayerAction
[0, ACTION_ATTACK
]) and
2020 (not gPlayerAction
[0, ACTION_MOVELEFT
]) and
2021 (not gPlayerAction
[0, ACTION_MOVERIGHT
]) and
2022 (not gPlayerAction
[0, ACTION_LOOKUP
]) and
2023 (not gPlayerAction
[0, ACTION_LOOKDOWN
]) and
2024 (not gPlayerAction
[0, ACTION_WEAPPREV
]) and
2025 (not gPlayerAction
[0, ACTION_WEAPNEXT
]) then
2026 gSpectKeyPress
:= False;
2030 if gSpectMode
= SPECT_MAPVIEW
then
2032 i
:= Min(Max(gSpectX
+ gSpectAutoStepX
, 0), gMapInfo
.Width
- gScreenWidth
);
2034 gSpectAutoNext
:= gTime
2037 i
:= Min(Max(gSpectY
+ gSpectAutoStepY
, 0), gMapInfo
.Height
- gScreenHeight
);
2039 gSpectAutoNext
:= gTime
2043 if gSpectAutoNext
<= gTime
then
2045 if gSpectAutoNext
> 0 then
2047 gSpectMode
:= GetRandomSpectMode(gSpectMode
);
2051 gSpectX
:= Random(gMapInfo
.Width
- gScreenWidth
);
2052 gSpectY
:= Random(gMapInfo
.Height
- gScreenHeight
);
2053 gSpectAutoStepX
:= Random(9) - 4;
2054 gSpectAutoStepY
:= Random(9) - 4;
2055 if ((gSpectX
< 800) and (gSpectAutoStepX
< 0)) or
2056 ((gSpectX
> gMapInfo
.Width
- gScreenWidth
- 800) and (gSpectAutoStepX
> 0)) then
2057 gSpectAutoStepX
:= gSpectAutoStepX
* -1;
2058 if ((gSpectY
< 800) and (gSpectAutoStepY
< 0)) or
2059 ((gSpectY
> gMapInfo
.Height
- gScreenHeight
- 800) and (gSpectAutoStepY
> 0)) then
2060 gSpectAutoStepY
:= gSpectAutoStepY
* -1;
2064 gSpectPID1
:= GetActivePlayerID_Random(gSpectPID1
);
2069 SPECT_STATS
: gSpectAutoNext
:= gTime
+ (Random(3) + 5) * 1000;
2070 SPECT_MAPVIEW
: gSpectAutoNext
:= gTime
+ (Random(4) + 7) * 1000;
2071 SPECT_PLAYERS
: gSpectAutoNext
:= gTime
+ (Random(7) + 8) * 1000;
2077 // Îáíîâëÿåì âñå îñòàëüíîå:
2080 g_Triggers_Update();
2082 g_Monsters_Update();
2084 g_Player_UpdateAll();
2085 g_Player_UpdatePhysicalObjects();
2087 // server: send newly spawned monsters unconditionally
2088 if (gGameSettings
.GameType
= GT_SERVER
) then
2090 if (Length(gMonstersSpawned
) > 0) then
2092 for I
:= 0 to High(gMonstersSpawned
) do MH_SEND_MonsterSpawn(gMonstersSpawned
[I
]);
2093 SetLength(gMonstersSpawned
, 0);
2097 if (gSoundTriggerTime
> 8) then
2099 g_Game_UpdateTriggerSounds();
2100 gSoundTriggerTime
:= 0;
2104 Inc(gSoundTriggerTime
);
2107 if (NetMode
= NET_SERVER
) then
2109 Inc(NetTimeToUpdate
);
2110 Inc(NetTimeToReliable
);
2112 // send monster updates
2113 if (NetTimeToReliable
>= NetRelupdRate
) or (NetTimeToUpdate
>= NetUpdateRate
) then
2115 // send all monsters (periodic sync)
2116 reliableUpdate
:= (NetTimeToReliable
>= NetRelupdRate
);
2118 for I
:= 0 to High(gPlayers
) do
2120 if (gPlayers
[I
] <> nil) then MH_SEND_PlayerPos(reliableUpdate
, gPlayers
[I
].UID
);
2123 g_Mons_ForEach(sendMonsPos
);
2125 if reliableUpdate
then
2127 NetTimeToReliable
:= 0;
2128 NetTimeToUpdate
:= NetUpdateRate
;
2132 NetTimeToUpdate
:= 0;
2137 // send only mosters with some unexpected changes
2138 g_Mons_ForEach(sendMonsPosUnexpected
);
2141 // send unexpected platform changes
2142 g_Map_NetSendInterestingPanels();
2144 g_Net_Slist_ServerUpdate();
2146 if NetUseMaster then
2148 if (gTime >= NetTimeToMaster) or g_Net_Slist_IsConnectionInProgress then
2150 if (not g_Net_Slist_IsConnectionActive) then g_Net_Slist_Connect(false); // non-blocking connection to the master
2152 NetTimeToMaster := gTime + NetMasterRate;
2157 else if (NetMode
= NET_CLIENT
) then
2159 MC_SEND_PlayerPos();
2161 end; // if gameOn ...
2163 // Àêòèâíî îêíî èíòåðôåéñà - ïåðåäàåì êëàâèøè åìó:
2164 if g_ActiveWindow
<> nil then
2166 w
:= e_GetFirstKeyPressed();
2168 if (w
<> IK_INVALID
) then
2170 Msg
.Msg
:= MESSAGE_DIKEY
;
2172 g_ActiveWindow
.OnMessage(Msg
);
2175 // Åñëè îíî îò ýòîãî íå çàêðûëîñü, òî îáíîâëÿåì:
2176 if g_ActiveWindow
<> nil then
2177 g_ActiveWindow
.Update();
2179 // Íóæíî ñìåíèòü ðàçðåøåíèå:
2180 if gResolutionChange
then
2182 e_WriteLog('Changing resolution', TMsgType
.Notify
);
2183 g_Game_ChangeResolution(gRC_Width
, gRC_Height
, gRC_FullScreen
, gRC_Maximized
);
2184 gResolutionChange
:= False;
2185 g_ActiveWindow
:= nil;
2188 // Íóæíî ñìåíèòü ÿçûê:
2189 if gLanguageChange
then
2191 //e_WriteLog('Read language file', MSG_NOTIFY);
2192 //g_Language_Load(DataDir + gLanguage + '.txt');
2193 g_Language_Set(gLanguage
);
2197 gLanguageChange
:= False;
2201 // Ãîðÿ÷àÿ êëàâèøà äëÿ âûçîâà ìåíþ âûõîäà èç èãðû (F10):
2202 if e_KeyPressed(IK_F10
) and
2204 (not gConsoleShow
) and
2205 (g_ActiveWindow
= nil) then
2210 Time
:= sys_GetTicks() {div 1000};
2212 // Îáðàáîòêà îòëîæåííûõ ñîáûòèé:
2213 if gDelayedEvents
<> nil then
2214 for a
:= 0 to High(gDelayedEvents
) do
2215 if gDelayedEvents
[a
].Pending
and
2217 ((gDelayedEvents
[a
].DEType
= DE_GLOBEVENT
) and (gDelayedEvents
[a
].Time
<= Time
)) or
2218 ((gDelayedEvents
[a
].DEType
> DE_GLOBEVENT
) and (gDelayedEvents
[a
].Time
<= gTime
))
2221 case gDelayedEvents
[a
].DEType
of
2223 g_Game_ExecuteEvent(gDelayedEvents
[a
].DEStr
);
2226 g_Game_Announce_GoodShot(gDelayedEvents
[a
].DENum
);
2230 g_Game_Announce_KillCombo(gDelayedEvents
[a
].DENum
);
2231 if g_Game_IsNet
and g_Game_IsServer
then
2232 MH_SEND_GameEvent(NET_EV_KILLCOMBO
, gDelayedEvents
[a
].DENum
);
2236 g_Game_Announce_BodyKill(gDelayedEvents
[a
].DENum
);
2238 gDelayedEvents
[a
].Pending
:= False;
2241 // Êàæäóþ ñåêóíäó îáíîâëÿåì ñ÷åò÷èê îáíîâëåíèé:
2242 UPSCounter
:= UPSCounter
+ 1;
2243 if Time
- UPSTime
>= 1000 then
2252 g_Weapon_AddDynLights();
2253 g_Items_AddDynLights();
2257 procedure g_Game_LoadChatSounds(Resource
: string);
2260 FileName
, Snd
: string;
2262 len
, cnt
, tags
, i
, j
: Integer;
2265 FileName
:= g_ExtractWadName(Resource
);
2267 WAD
:= TWADFile
.Create();
2268 WAD
.ReadFile(FileName
);
2270 if not WAD
.GetResource(g_ExtractFilePathName(Resource
), p
, len
) then
2277 cfg
:= TConfig
.CreateMem(p
, len
);
2278 cnt
:= cfg
.ReadInt('ChatSounds', 'Count', 0);
2280 SetLength(gChatSounds
, cnt
);
2281 for i
:= 0 to Length(gChatSounds
) - 1 do
2283 gChatSounds
[i
].Sound
:= nil;
2284 Snd
:= Trim(cfg
.ReadStr(IntToStr(i
), 'Sound', ''));
2285 tags
:= cfg
.ReadInt(IntToStr(i
), 'Tags', 0);
2286 if (Snd
= '') or (Tags
<= 0) then
2288 g_Sound_CreateWADEx('SOUND_CHAT_MACRO' + IntToStr(i
), GameWAD
+':'+Snd
);
2289 gChatSounds
[i
].Sound
:= TPlayableSound
.Create();
2290 gChatSounds
[i
].Sound
.SetByName('SOUND_CHAT_MACRO' + IntToStr(i
));
2291 SetLength(gChatSounds
[i
].Tags
, tags
);
2292 for j
:= 0 to tags
- 1 do
2293 gChatSounds
[i
].Tags
[j
] := toLowerCase1251(cfg
.ReadStr(IntToStr(i
), 'Tag' + IntToStr(j
), ''));
2294 gChatSounds
[i
].FullWord
:= cfg
.ReadBool(IntToStr(i
), 'FullWord', False);
2301 procedure g_Game_FreeChatSounds();
2305 for i
:= 0 to Length(gChatSounds
) - 1 do
2307 gChatSounds
[i
].Sound
.Free();
2308 g_Sound_Delete('SOUND_CHAT_MACRO' + IntToStr(i
));
2310 SetLength(gChatSounds
, 0);
2314 procedure g_Game_LoadData();
2321 if DataLoaded
then Exit
;
2323 e_WriteLog('Loading game data...', TMsgType
.Notify
);
2325 g_Texture_CreateWADEx('NOTEXTURE', GameWAD
+':TEXTURES\NOTEXTURE');
2326 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUD', GameWAD
+':TEXTURES\HUD');
2327 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDAIR', GameWAD
+':TEXTURES\AIRBAR');
2328 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDJET', GameWAD
+':TEXTURES\JETBAR');
2329 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDBG', GameWAD
+':TEXTURES\HUDBG');
2330 g_Texture_CreateWADEx('TEXTURE_PLAYER_ARMORHUD', GameWAD
+':TEXTURES\ARMORHUD');
2331 g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG', GameWAD
+':TEXTURES\FLAGHUD_R_BASE');
2332 g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG_S', GameWAD
+':TEXTURES\FLAGHUD_R_STOLEN');
2333 g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG_D', GameWAD
+':TEXTURES\FLAGHUD_R_DROP');
2334 g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG', GameWAD
+':TEXTURES\FLAGHUD_B_BASE');
2335 g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG_S', GameWAD
+':TEXTURES\FLAGHUD_B_STOLEN');
2336 g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG_D', GameWAD
+':TEXTURES\FLAGHUD_B_DROP');
2337 g_Texture_CreateWADEx('TEXTURE_PLAYER_TALKBUBBLE', GameWAD
+':TEXTURES\TALKBUBBLE');
2338 g_Texture_CreateWADEx('TEXTURE_PLAYER_INVULPENTA', GameWAD
+':TEXTURES\PENTA');
2339 g_Texture_CreateWADEx('TEXTURE_PLAYER_INDICATOR', GameWAD
+':TEXTURES\PLRIND');
2342 if not g_Texture_CreateWADEx('UI_GFX_PBAR_LEFT', GameWAD
+':TEXTURES\LLEFT') then hasPBarGfx
:= false;
2343 if not g_Texture_CreateWADEx('UI_GFX_PBAR_MARKER', GameWAD
+':TEXTURES\LMARKER') then hasPBarGfx
:= false;
2344 if not g_Texture_CreateWADEx('UI_GFX_PBAR_MIDDLE', GameWAD
+':TEXTURES\LMIDDLE') then hasPBarGfx
:= false;
2345 if not g_Texture_CreateWADEx('UI_GFX_PBAR_RIGHT', GameWAD
+':TEXTURES\LRIGHT') then hasPBarGfx
:= false;
2349 g_Texture_GetSize('UI_GFX_PBAR_LEFT', wl
, hl
);
2350 g_Texture_GetSize('UI_GFX_PBAR_RIGHT', wr
, hr
);
2351 g_Texture_GetSize('UI_GFX_PBAR_MIDDLE', wb
, hb
);
2352 g_Texture_GetSize('UI_GFX_PBAR_MARKER', wm
, hm
);
2353 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
2359 hasPBarGfx
:= false;
2363 g_Frames_CreateWAD(nil, 'FRAMES_TELEPORT', GameWAD
+':TEXTURES\TELEPORT', 64, 64, 10, False);
2364 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH', GameWAD
+':WEAPONS\PUNCH', 64, 64, 4, False);
2365 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_UP', GameWAD
+':WEAPONS\PUNCH_UP', 64, 64, 4, False);
2366 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_DN', GameWAD
+':WEAPONS\PUNCH_DN', 64, 64, 4, False);
2367 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_BERSERK', GameWAD
+':WEAPONS\PUNCHB', 64, 64, 4, False);
2368 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_BERSERK_UP', GameWAD
+':WEAPONS\PUNCHB_UP', 64, 64, 4, False);
2369 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_BERSERK_DN', GameWAD
+':WEAPONS\PUNCHB_DN', 64, 64, 4, False);
2370 g_Sound_CreateWADEx('SOUND_GAME_TELEPORT', GameWAD
+':SOUNDS\TELEPORT');
2371 g_Sound_CreateWADEx('SOUND_GAME_NOTELEPORT', GameWAD
+':SOUNDS\NOTELEPORT');
2372 g_Sound_CreateWADEx('SOUND_GAME_SECRET', GameWAD
+':SOUNDS\SECRET');
2373 g_Sound_CreateWADEx('SOUND_GAME_DOOROPEN', GameWAD
+':SOUNDS\DOOROPEN');
2374 g_Sound_CreateWADEx('SOUND_GAME_DOORCLOSE', GameWAD
+':SOUNDS\DOORCLOSE');
2375 g_Sound_CreateWADEx('SOUND_GAME_BULK1', GameWAD
+':SOUNDS\BULK1');
2376 g_Sound_CreateWADEx('SOUND_GAME_BULK2', GameWAD
+':SOUNDS\BULK2');
2377 g_Sound_CreateWADEx('SOUND_GAME_BUBBLE1', GameWAD
+':SOUNDS\BUBBLE1');
2378 g_Sound_CreateWADEx('SOUND_GAME_BUBBLE2', GameWAD
+':SOUNDS\BUBBLE2');
2379 g_Sound_CreateWADEx('SOUND_GAME_BURNING', GameWAD
+':SOUNDS\BURNING');
2380 g_Sound_CreateWADEx('SOUND_GAME_SWITCH1', GameWAD
+':SOUNDS\SWITCH1');
2381 g_Sound_CreateWADEx('SOUND_GAME_SWITCH0', GameWAD
+':SOUNDS\SWITCH0');
2382 g_Sound_CreateWADEx('SOUND_GAME_RADIO', GameWAD
+':SOUNDS\RADIO');
2383 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD1', GameWAD
+':SOUNDS\GOOD1');
2384 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD2', GameWAD
+':SOUNDS\GOOD2');
2385 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD3', GameWAD
+':SOUNDS\GOOD3');
2386 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD4', GameWAD
+':SOUNDS\GOOD4');
2387 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL2X', GameWAD
+':SOUNDS\KILL2X');
2388 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL3X', GameWAD
+':SOUNDS\KILL3X');
2389 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL4X', GameWAD
+':SOUNDS\KILL4X');
2390 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILLMX', GameWAD
+':SOUNDS\KILLMX');
2391 g_Sound_CreateWADEx('SOUND_ANNOUNCER_MUHAHA1', GameWAD
+':SOUNDS\MUHAHA1');
2392 g_Sound_CreateWADEx('SOUND_ANNOUNCER_MUHAHA2', GameWAD
+':SOUNDS\MUHAHA2');
2393 g_Sound_CreateWADEx('SOUND_ANNOUNCER_MUHAHA3', GameWAD
+':SOUNDS\MUHAHA3');
2394 g_Sound_CreateWADEx('SOUND_CTF_GET1', GameWAD
+':SOUNDS\GETFLAG1');
2395 g_Sound_CreateWADEx('SOUND_CTF_GET2', GameWAD
+':SOUNDS\GETFLAG2');
2396 g_Sound_CreateWADEx('SOUND_CTF_LOST1', GameWAD
+':SOUNDS\LOSTFLG1');
2397 g_Sound_CreateWADEx('SOUND_CTF_LOST2', GameWAD
+':SOUNDS\LOSTFLG2');
2398 g_Sound_CreateWADEx('SOUND_CTF_RETURN1', GameWAD
+':SOUNDS\RETFLAG1');
2399 g_Sound_CreateWADEx('SOUND_CTF_RETURN2', GameWAD
+':SOUNDS\RETFLAG2');
2400 g_Sound_CreateWADEx('SOUND_CTF_CAPTURE1', GameWAD
+':SOUNDS\CAPFLAG1');
2401 g_Sound_CreateWADEx('SOUND_CTF_CAPTURE2', GameWAD
+':SOUNDS\CAPFLAG2');
2403 goodsnd
[0] := TPlayableSound
.Create();
2404 goodsnd
[1] := TPlayableSound
.Create();
2405 goodsnd
[2] := TPlayableSound
.Create();
2406 goodsnd
[3] := TPlayableSound
.Create();
2408 goodsnd
[0].SetByName('SOUND_ANNOUNCER_GOOD1');
2409 goodsnd
[1].SetByName('SOUND_ANNOUNCER_GOOD2');
2410 goodsnd
[2].SetByName('SOUND_ANNOUNCER_GOOD3');
2411 goodsnd
[3].SetByName('SOUND_ANNOUNCER_GOOD4');
2413 killsnd
[0] := TPlayableSound
.Create();
2414 killsnd
[1] := TPlayableSound
.Create();
2415 killsnd
[2] := TPlayableSound
.Create();
2416 killsnd
[3] := TPlayableSound
.Create();
2418 killsnd
[0].SetByName('SOUND_ANNOUNCER_KILL2X');
2419 killsnd
[1].SetByName('SOUND_ANNOUNCER_KILL3X');
2420 killsnd
[2].SetByName('SOUND_ANNOUNCER_KILL4X');
2421 killsnd
[3].SetByName('SOUND_ANNOUNCER_KILLMX');
2423 hahasnd
[0] := TPlayableSound
.Create();
2424 hahasnd
[1] := TPlayableSound
.Create();
2425 hahasnd
[2] := TPlayableSound
.Create();
2427 hahasnd
[0].SetByName('SOUND_ANNOUNCER_MUHAHA1');
2428 hahasnd
[1].SetByName('SOUND_ANNOUNCER_MUHAHA2');
2429 hahasnd
[2].SetByName('SOUND_ANNOUNCER_MUHAHA3');
2431 sound_get_flag
[0] := TPlayableSound
.Create();
2432 sound_get_flag
[1] := TPlayableSound
.Create();
2433 sound_lost_flag
[0] := TPlayableSound
.Create();
2434 sound_lost_flag
[1] := TPlayableSound
.Create();
2435 sound_ret_flag
[0] := TPlayableSound
.Create();
2436 sound_ret_flag
[1] := TPlayableSound
.Create();
2437 sound_cap_flag
[0] := TPlayableSound
.Create();
2438 sound_cap_flag
[1] := TPlayableSound
.Create();
2440 sound_get_flag
[0].SetByName('SOUND_CTF_GET1');
2441 sound_get_flag
[1].SetByName('SOUND_CTF_GET2');
2442 sound_lost_flag
[0].SetByName('SOUND_CTF_LOST1');
2443 sound_lost_flag
[1].SetByName('SOUND_CTF_LOST2');
2444 sound_ret_flag
[0].SetByName('SOUND_CTF_RETURN1');
2445 sound_ret_flag
[1].SetByName('SOUND_CTF_RETURN2');
2446 sound_cap_flag
[0].SetByName('SOUND_CTF_CAPTURE1');
2447 sound_cap_flag
[1].SetByName('SOUND_CTF_CAPTURE2');
2449 g_Game_LoadChatSounds(GameWAD
+':CHATSND\SNDCFG');
2451 g_Game_SetLoadingText(_lc
[I_LOAD_ITEMS_DATA
], 0, False);
2454 g_Game_SetLoadingText(_lc
[I_LOAD_WEAPONS_DATA
], 0, False);
2455 g_Weapon_LoadData();
2457 g_Monsters_LoadData();
2462 procedure g_Game_FreeData();
2464 if not DataLoaded
then Exit
;
2467 g_Weapon_FreeData();
2468 g_Monsters_FreeData();
2470 e_WriteLog('Releasing game data...', TMsgType
.Notify
);
2472 g_Texture_Delete('NOTEXTURE');
2473 g_Texture_Delete('TEXTURE_PLAYER_HUD');
2474 g_Texture_Delete('TEXTURE_PLAYER_HUDBG');
2475 g_Texture_Delete('TEXTURE_PLAYER_ARMORHUD');
2476 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG');
2477 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG_S');
2478 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG_D');
2479 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG');
2480 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG_S');
2481 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG_D');
2482 g_Texture_Delete('TEXTURE_PLAYER_TALKBUBBLE');
2483 g_Texture_Delete('TEXTURE_PLAYER_INVULPENTA');
2484 g_Frames_DeleteByName('FRAMES_TELEPORT');
2485 g_Frames_DeleteByName('FRAMES_PUNCH');
2486 g_Frames_DeleteByName('FRAMES_PUNCH_UP');
2487 g_Frames_DeleteByName('FRAMES_PUNCH_DN');
2488 g_Frames_DeleteByName('FRAMES_PUNCH_BERSERK');
2489 g_Frames_DeleteByName('FRAMES_PUNCH_BERSERK_UP');
2490 g_Frames_DeleteByName('FRAMES_PUNCH_BERSERK_DN');
2491 g_Sound_Delete('SOUND_GAME_TELEPORT');
2492 g_Sound_Delete('SOUND_GAME_NOTELEPORT');
2493 g_Sound_Delete('SOUND_GAME_SECRET');
2494 g_Sound_Delete('SOUND_GAME_DOOROPEN');
2495 g_Sound_Delete('SOUND_GAME_DOORCLOSE');
2496 g_Sound_Delete('SOUND_GAME_BULK1');
2497 g_Sound_Delete('SOUND_GAME_BULK2');
2498 g_Sound_Delete('SOUND_GAME_BUBBLE1');
2499 g_Sound_Delete('SOUND_GAME_BUBBLE2');
2500 g_Sound_Delete('SOUND_GAME_BURNING');
2501 g_Sound_Delete('SOUND_GAME_SWITCH1');
2502 g_Sound_Delete('SOUND_GAME_SWITCH0');
2509 g_Sound_Delete('SOUND_ANNOUNCER_GOOD1');
2510 g_Sound_Delete('SOUND_ANNOUNCER_GOOD2');
2511 g_Sound_Delete('SOUND_ANNOUNCER_GOOD3');
2512 g_Sound_Delete('SOUND_ANNOUNCER_GOOD4');
2519 g_Sound_Delete('SOUND_ANNOUNCER_KILL2X');
2520 g_Sound_Delete('SOUND_ANNOUNCER_KILL3X');
2521 g_Sound_Delete('SOUND_ANNOUNCER_KILL4X');
2522 g_Sound_Delete('SOUND_ANNOUNCER_KILLMX');
2528 g_Sound_Delete('SOUND_ANNOUNCER_MUHAHA1');
2529 g_Sound_Delete('SOUND_ANNOUNCER_MUHAHA2');
2530 g_Sound_Delete('SOUND_ANNOUNCER_MUHAHA3');
2532 sound_get_flag
[0].Free();
2533 sound_get_flag
[1].Free();
2534 sound_lost_flag
[0].Free();
2535 sound_lost_flag
[1].Free();
2536 sound_ret_flag
[0].Free();
2537 sound_ret_flag
[1].Free();
2538 sound_cap_flag
[0].Free();
2539 sound_cap_flag
[1].Free();
2541 g_Sound_Delete('SOUND_CTF_GET1');
2542 g_Sound_Delete('SOUND_CTF_GET2');
2543 g_Sound_Delete('SOUND_CTF_LOST1');
2544 g_Sound_Delete('SOUND_CTF_LOST2');
2545 g_Sound_Delete('SOUND_CTF_RETURN1');
2546 g_Sound_Delete('SOUND_CTF_RETURN2');
2547 g_Sound_Delete('SOUND_CTF_CAPTURE1');
2548 g_Sound_Delete('SOUND_CTF_CAPTURE2');
2550 g_Game_FreeChatSounds();
2552 DataLoaded
:= False;
2555 procedure DrawCustomStat();
2561 ww2
, hh2
, r
, g
, b
, rr
, gg
, bb
: Byte;
2562 s1
, s2
, topstr
: String;
2564 e_TextureFontGetSize(gStdFont
, ww2
, hh2
);
2568 if g_Console_Action(ACTION_SCORES
) then
2570 if not gStatsPressed
then
2572 gStatsOff
:= not gStatsOff
;
2573 gStatsPressed
:= True;
2577 gStatsPressed
:= False;
2581 s1
:= _lc
[I_MENU_INTER_NOTICE_TAB
];
2582 w
:= (Length(s1
) * ww2
) div 2;
2583 x
:= gScreenWidth
div 2 - w
;
2585 e_TextureFontPrint(x
, y
, s1
, gStdFont
);
2589 if (gGameSettings
.GameMode
= GM_COOP
) then
2591 if gMissionFailed
then
2592 topstr
:= _lc
[I_MENU_INTER_MISSION_FAIL
]
2594 topstr
:= _lc
[I_MENU_INTER_LEVEL_COMPLETE
];
2597 topstr
:= _lc
[I_MENU_INTER_ROUND_OVER
];
2599 e_CharFont_GetSize(gMenuFont
, topstr
, ww1
, hh1
);
2600 e_CharFont_Print(gMenuFont
, (gScreenWidth
div 2)-(ww1
div 2), 16, topstr
);
2602 if g_Game_IsNet
then
2604 topstr
:= Format(_lc
[I_MENU_INTER_NOTICE_TIME
], [gServInterTime
]);
2605 if not gChatShow
then
2606 e_TextureFontPrintEx((gScreenWidth
div 2)-(Length(topstr
)*ww2
div 2),
2607 gScreenHeight
-(hh2
+4)*2, topstr
, gStdFont
, 255, 255, 255, 1);
2610 if g_Game_IsClient
then
2611 topstr
:= _lc
[I_MENU_INTER_NOTICE_MAP
]
2613 topstr
:= _lc
[I_MENU_INTER_NOTICE_SPACE
];
2614 if not gChatShow
then
2615 e_TextureFontPrintEx((gScreenWidth
div 2)-(Length(topstr
)*ww2
div 2),
2616 gScreenHeight
-(hh2
+4), topstr
, gStdFont
, 255, 255, 255, 1);
2621 w
:= gScreenWidth
-x
*2;
2627 e_DrawFillQuad(x
, y
, gScreenWidth
-x
-1, gScreenHeight
-y
-1, 64, 64, 64, 32);
2628 e_DrawQuad(x
, y
, gScreenWidth
-x
-1, gScreenHeight
-y
-1, 255, 127, 0);
2630 m
:= Max(Length(_lc
[I_MENU_MAP
])+1, Length(_lc
[I_GAME_GAME_TIME
])+1)*ww2
;
2632 case CustomStat
.GameMode
of
2635 if gGameSettings
.MaxLives
= 0 then
2636 s1
:= _lc
[I_GAME_DM
]
2638 s1
:= _lc
[I_GAME_LMS
];
2642 if gGameSettings
.MaxLives
= 0 then
2643 s1
:= _lc
[I_GAME_TDM
]
2645 s1
:= _lc
[I_GAME_TLMS
];
2647 GM_CTF
: s1
:= _lc
[I_GAME_CTF
];
2650 if gGameSettings
.MaxLives
= 0 then
2651 s1
:= _lc
[I_GAME_COOP
]
2653 s1
:= _lc
[I_GAME_SURV
];
2659 e_TextureFontPrintEx(x
+(w
div 2)-(Length(s1
)*ww2
div 2), _y
, s1
, gStdFont
, 255, 255, 255, 1);
2663 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_MENU_MAP
], gStdFont
, 255, 127, 0, 1);
2664 e_TextureFontPrint(x
+8+m
, _y
, Format('%s - %s', [CustomStat
.Map
, CustomStat
.MapName
]), gStdFont
);
2667 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_GAME_TIME
], gStdFont
, 255, 127, 0, 1);
2668 e_TextureFontPrint(x
+8+m
, _y
, Format('%d:%.2d:%.2d', [CustomStat
.GameTime
div 1000 div 3600,
2669 (CustomStat
.GameTime
div 1000 div 60) mod 60,
2670 CustomStat
.GameTime
div 1000 mod 60]), gStdFont
);
2672 pc
:= Length(CustomStat
.PlayerStat
);
2673 if pc
= 0 then Exit
;
2675 if CustomStat
.GameMode
= GM_COOP
then
2677 m
:= Max(Length(_lc
[I_GAME_MONSTERS
])+1, Length(_lc
[I_GAME_SECRETS
])+1)*ww2
;
2679 s2
:= _lc
[I_GAME_MONSTERS
];
2680 e_TextureFontPrintEx(x
+8, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2681 e_TextureFontPrintEx(x
+8+m
, _y
, IntToStr(gCoopMonstersKilled
) + '/' + IntToStr(gTotalMonsters
), gStdFont
, 255, 255, 255, 1);
2683 s2
:= _lc
[I_GAME_SECRETS
];
2684 e_TextureFontPrintEx(x
+8, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2685 e_TextureFontPrintEx(x
+8+m
, _y
, IntToStr(gCoopSecretsFound
) + '/' + IntToStr(gSecretsCount
), gStdFont
, 255, 255, 255, 1);
2688 m
:= Max(Length(_lc
[I_GAME_MONSTERS_TOTAL
])+1, Length(_lc
[I_GAME_SECRETS_TOTAL
])+1)*ww2
;
2690 s2
:= _lc
[I_GAME_MONSTERS_TOTAL
];
2691 e_TextureFontPrintEx(x
+250, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2692 e_TextureFontPrintEx(x
+250+m
, _y
, IntToStr(gCoopTotalMonstersKilled
) + '/' + IntToStr(gCoopTotalMonsters
), gStdFont
, 255, 255, 255, 1);
2694 s2
:= _lc
[I_GAME_SECRETS_TOTAL
];
2695 e_TextureFontPrintEx(x
+250, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2696 e_TextureFontPrintEx(x
+250+m
, _y
, IntToStr(gCoopTotalSecretsFound
) + '/' + IntToStr(gCoopTotalSecrets
), gStdFont
, 255, 255, 255, 1);
2700 if CustomStat
.GameMode
in [GM_TDM
, GM_CTF
] then
2705 if TeamStat
[TEAM_RED
].Goals
> TeamStat
[TEAM_BLUE
].Goals
then s1
:= _lc
[I_GAME_WIN_RED
]
2706 else if TeamStat
[TEAM_BLUE
].Goals
> TeamStat
[TEAM_RED
].Goals
then s1
:= _lc
[I_GAME_WIN_BLUE
]
2707 else s1
:= _lc
[I_GAME_WIN_DRAW
];
2709 e_TextureFontPrintEx(x
+8+(w
div 2)-(Length(s1
)*ww2
div 2), _y
, s1
, gStdFont
, 255, 255, 255, 1);
2712 for t
:= TEAM_RED
to TEAM_BLUE
do
2714 if t
= TEAM_RED
then
2716 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_TEAM_RED
],
2717 gStdFont
, 255, 0, 0, 1);
2718 e_TextureFontPrintEx(x
+w1
+8, _y
, IntToStr(CustomStat
.TeamStat
[TEAM_RED
].Goals
),
2719 gStdFont
, 255, 0, 0, 1);
2726 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_TEAM_BLUE
],
2727 gStdFont
, 0, 0, 255, 1);
2728 e_TextureFontPrintEx(x
+w1
+8, _y
, IntToStr(CustomStat
.TeamStat
[TEAM_BLUE
].Goals
),
2729 gStdFont
, 0, 0, 255, 1);
2735 e_DrawLine(1, x
+8, _y
+20, x
-8+w
, _y
+20, r
, g
, b
);
2738 for p
:= 0 to High(CustomStat
.PlayerStat
) do
2739 if CustomStat
.PlayerStat
[p
].Team
= t
then
2740 with CustomStat
.PlayerStat
[p
] do
2754 if (gPlayers
[Num
] <> nil) and (gPlayers
[Num
].FReady
) then
2755 e_TextureFontPrintEx(x
+16, _y
, Name
+ ' *', gStdFont
, rr
, gg
, bb
, 1)
2757 e_TextureFontPrintEx(x
+16, _y
, Name
, gStdFont
, rr
, gg
, bb
, 1);
2758 e_TextureFontPrintEx(x
+w1
+16, _y
, IntToStr(Frags
), gStdFont
, rr
, gg
, bb
, 1);
2759 e_TextureFontPrintEx(x
+w1
+w2
+16, _y
, IntToStr(Deaths
), gStdFont
, rr
, gg
, bb
, 1);
2766 else if CustomStat
.GameMode
in [GM_DM
, GM_COOP
] then
2769 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_PLAYER_NAME
], gStdFont
, 255, 127, 0, 1);
2770 e_TextureFontPrintEx(x
+8+w1
, _y
, _lc
[I_GAME_FRAGS
], gStdFont
, 255, 127, 0, 1);
2771 e_TextureFontPrintEx(x
+8+w1
+w2
, _y
, _lc
[I_GAME_DEATHS
], gStdFont
, 255, 127, 0, 1);
2774 for p
:= 0 to High(CustomStat
.PlayerStat
) do
2775 with CustomStat
.PlayerStat
[p
] do
2777 e_DrawFillQuad(x
+8, _y
+4, x
+24-1, _y
+16+4-1, Color
.R
, Color
.G
, Color
.B
, 0);
2784 if (gPlayers
[Num
] <> nil) and (gPlayers
[Num
].FReady
) then
2785 e_TextureFontPrintEx(x
+8+16+8, _y
+4, Name
+ ' *', gStdFont
, r
, r
, r
, 1, True)
2787 e_TextureFontPrintEx(x
+8+16+8, _y
+4, Name
, gStdFont
, r
, r
, r
, 1, True);
2788 e_TextureFontPrintEx(x
+w1
+8+16+8, _y
+4, IntToStr(Frags
), gStdFont
, r
, r
, r
, 1, True);
2789 e_TextureFontPrintEx(x
+w1
+w2
+8+16+8, _y
+4, IntToStr(Deaths
), gStdFont
, r
, r
, r
, 1, True);
2795 procedure DrawSingleStat();
2797 tm
, key_x
, val_x
, y
: Integer;
2801 procedure player_stat(n
: Integer);
2807 s1
:= Format(' %d ', [SingleStat
.PlayerStat
[n
].Kills
]);
2808 s2
:= Format(' %d', [gTotalMonsters
]);
2810 e_CharFont_Print(gMenuFont
, key_x
, y
, _lc
[I_MENU_INTER_KILLS
]);
2811 e_CharFont_PrintEx(gMenuFont
, val_x
, y
, s1
, _RGB(255, 0, 0));
2812 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2813 e_CharFont_Print(gMenuFont
, val_x
+w1
, y
, '/');
2815 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2816 e_CharFont_PrintEx(gMenuFont
, val_x
+w1
, y
, s2
, _RGB(255, 0, 0));
2818 // "Kills-per-minute: ##.#":
2819 s1
:= _lc
[I_MENU_INTER_KPM
];
2821 kpm
:= (SingleStat
.PlayerStat
[n
].Kills
/ tm
) * 60
2823 kpm
:= SingleStat
.PlayerStat
[n
].Kills
;
2824 s2
:= Format(' %.1f', [kpm
]);
2826 e_CharFont_Print(gMenuFont
, key_x
, y
+32, s1
);
2827 e_CharFont_PrintEx(gMenuFont
, val_x
, y
+32, s2
, _RGB(255, 0, 0));
2829 // "Secrets found: # / #":
2830 s1
:= Format(' %d ', [SingleStat
.PlayerStat
[n
].Secrets
]);
2831 s2
:= Format(' %d', [SingleStat
.TotalSecrets
]);
2833 e_CharFont_Print(gMenuFont
, key_x
, y
+64, _lc
[I_MENU_INTER_SECRETS
]);
2834 e_CharFont_PrintEx(gMenuFont
, val_x
, y
+64, s1
, _RGB(255, 0, 0));
2835 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2836 e_CharFont_Print(gMenuFont
, val_x
+w1
, y
+64, '/');
2838 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2839 e_CharFont_PrintEx(gMenuFont
, val_x
+w1
, y
+64, s2
, _RGB(255, 0, 0));
2843 // "Level Complete":
2844 e_CharFont_GetSize(gMenuFont
, _lc
[I_MENU_INTER_LEVEL_COMPLETE
], w1
, h
);
2845 e_CharFont_Print(gMenuFont
, (gScreenWidth
-w1
) div 2, 32, _lc
[I_MENU_INTER_LEVEL_COMPLETE
]);
2847 // Îïðåäåëÿåì êîîðäèíàòû âûðàâíèâàíèÿ ïî ñàìîé äëèííîé ñòðîêå:
2848 s1
:= _lc
[I_MENU_INTER_KPM
];
2849 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2852 e_CharFont_GetSize(gMenuFont
, s1
, w2
, h
);
2854 key_x
:= (gScreenWidth
-w1
-w2
) div 2;
2855 val_x
:= key_x
+ w1
;
2858 tm
:= SingleStat
.GameTime
div 1000;
2859 s1
:= _lc
[I_MENU_INTER_TIME
];
2860 s2
:= Format(' %d:%.2d:%.2d', [tm
div (60*60), (tm
mod (60*60)) div 60, tm
mod 60]);
2862 e_CharFont_Print(gMenuFont
, key_x
, 80, s1
);
2863 e_CharFont_PrintEx(gMenuFont
, val_x
, 80, s2
, _RGB(255, 0, 0));
2865 if SingleStat
.TwoPlayers
then
2868 s1
:= _lc
[I_MENU_PLAYER_1
];
2869 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2870 e_CharFont_Print(gMenuFont
, (gScreenWidth
-w1
) div 2, 128, s1
);
2872 // Ñòàòèñòèêà ïåðâîãî èãðîêà:
2877 s1
:= _lc
[I_MENU_PLAYER_2
];
2878 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2879 e_CharFont_Print(gMenuFont
, (gScreenWidth
-w1
) div 2, 288, s1
);
2881 // Ñòàòèñòèêà âòîðîãî èãðîêà:
2887 // Ñòàòèñòèêà ïåðâîãî èãðîêà:
2893 procedure DrawLoadingStat();
2894 procedure drawRect (x
, y
, w
, h
: Integer);
2896 if (w
< 1) or (h
< 1) then exit
;
2898 glVertex2f(x
+0.375, y
+0.375);
2899 glVertex2f(x
+w
+0.375, y
+0.375);
2900 glVertex2f(x
+w
+0.375, y
+h
+0.375);
2901 glVertex2f(x
+0.375, y
+h
+0.375);
2905 function drawPBar (cur
, total
: Integer; washere
: Boolean): Boolean;
2907 rectW
, rectH
: Integer;
2914 idl
, idr
, idb
, idm
: LongWord;
2918 if (total
< 1) then exit
;
2919 if (cur
< 1) then exit
; // don't blink
2920 if (not washere
) and (cur
>= total
) then exit
; // don't blink
2921 //if (cur < 0) then cur := 0;
2922 //if (cur > total) then cur := total;
2925 if (hasPBarGfx
) then
2927 g_Texture_Get('UI_GFX_PBAR_LEFT', idl
);
2928 g_Texture_GetSize('UI_GFX_PBAR_LEFT', wl
, hl
);
2929 g_Texture_Get('UI_GFX_PBAR_RIGHT', idr
);
2930 g_Texture_GetSize('UI_GFX_PBAR_RIGHT', wr
, hr
);
2931 g_Texture_Get('UI_GFX_PBAR_MIDDLE', idb
);
2932 g_Texture_GetSize('UI_GFX_PBAR_MIDDLE', wb
, hb
);
2933 g_Texture_Get('UI_GFX_PBAR_MARKER', idm
);
2934 g_Texture_GetSize('UI_GFX_PBAR_MARKER', wm
, hm
);
2936 //rectW := gScreenWidth-360;
2937 rectW
:= trunc(624.0*gScreenWidth
/1024.0);
2940 x0
:= (gScreenWidth
-rectW
) div 2;
2941 y0
:= gScreenHeight
-rectH
-64;
2942 if (y0
< 2) then y0
:= 2;
2944 glEnable(GL_SCISSOR_TEST
);
2947 glScissor(x0
, gScreenHeight
-y0
-rectH
, rectW
, rectH
);
2948 e_DrawSize(idl
, x0
, y0
, 0, true, false, wl
, hl
);
2949 e_DrawSize(idr
, x0
+rectW
-wr
, y0
, 0, true, false, wr
, hr
);
2952 glScissor(x0
+wl
, gScreenHeight
-y0
-rectH
, rectW
-wl
-wr
, rectH
);
2954 while (f
< x0
+rectW
) do
2956 e_DrawSize(idb
, f
, y0
, 0, true, false, wb
, hb
);
2961 wdt
:= (rectW
-wl
-wr
)*cur
div total
;
2962 if (wdt
> rectW
-wl
-wr
) then wdt
:= rectW
-wr
-wr
;
2965 my
:= y0
; // don't be so smart, ketmar: +(rectH-wm) div 2;
2966 glScissor(x0
+wl
, gScreenHeight
-my
-rectH
, wdt
, hm
);
2970 e_DrawSize(idm
, f
, y0
, 0, true, false, wm
, hm
);
2976 glScissor(0, 0, gScreenWidth
, gScreenHeight
);
2980 rectW
:= gScreenWidth
-64;
2983 x0
:= (gScreenWidth
-rectW
) div 2;
2984 y0
:= gScreenHeight
-rectH
-64;
2985 if (y0
< 2) then y0
:= 2;
2987 glDisable(GL_BLEND
);
2988 glDisable(GL_TEXTURE_2D
);
2990 //glClearColor(0, 0, 0, 0);
2991 //glClear(GL_COLOR_BUFFER_BIT);
2993 glColor4ub(127, 127, 127, 255);
2994 drawRect(x0
-2, y0
-2, rectW
+4, rectH
+4);
2996 glColor4ub(0, 0, 0, 255);
2997 drawRect(x0
-1, y0
-1, rectW
+2, rectH
+2);
2999 glColor4ub(127, 127, 127, 255);
3000 wdt
:= rectW
*cur
div total
;
3001 if (wdt
> rectW
) then wdt
:= rectW
;
3002 drawRect(x0
, y0
, wdt
, rectH
);
3011 if (Length(LoadingStat
.Msgs
) = 0) then exit
;
3013 e_CharFont_GetSize(gMenuFont
, _lc
[I_MENU_LOADING
], ww
, hh
);
3014 yy
:= (gScreenHeight
div 3);
3015 e_CharFont_Print(gMenuFont
, (gScreenWidth
div 2)-(ww
div 2), yy
-2*hh
, _lc
[I_MENU_LOADING
]);
3016 xx
:= (gScreenWidth
div 3);
3020 for i
:= 0 to NextMsg
-1 do
3022 if (i
= (NextMsg
-1)) and (MaxValue
> 0) then
3023 s
:= Format('%s: %d/%d', [Msgs
[i
], CurValue
, MaxValue
])
3027 e_CharFont_PrintEx(gMenuSmallFont
, xx
, yy
, s
, _RGB(255, 0, 0));
3028 yy
:= yy
+ LOADING_INTERLINE
;
3029 PBarWasHere
:= drawPBar(CurValue
, MaxValue
, PBarWasHere
);
3034 procedure DrawMenuBackground(tex
: AnsiString);
3040 if g_Texture_Get(tex
, ID
) then
3042 e_Clear(GL_COLOR_BUFFER_BIT
, 0, 0, 0);
3043 e_GetTextureSize(ID
, @w
, @h
);
3045 w
:= round(w
* 1.333 * (gScreenHeight
/ h
))
3047 w
:= trunc(w
* (gScreenHeight
/ h
));
3048 e_DrawSize(ID
, (gScreenWidth
- w
) div 2, 0, 0, False, False, w
, gScreenHeight
);
3050 else e_Clear(GL_COLOR_BUFFER_BIT
, 0, 0, 0);
3053 procedure DrawMinimap(p
: TPlayer
; RenderRect
: e_graphics
.TRect
);
3055 a
, aX
, aY
, aX2
, aY2
, Scale
, ScaleSz
: Integer;
3057 function monDraw (mon
: TMonster
): Boolean;
3059 result
:= false; // don't stop
3064 // Ëåâûé âåðõíèé óãîë
3065 aX
:= Obj
.X
div ScaleSz
+ 1;
3066 aY
:= Obj
.Y
div ScaleSz
+ 1;
3068 aX2
:= max(Obj
.Rect
.Width
div ScaleSz
, 1);
3069 aY2
:= max(Obj
.Rect
.Height
div ScaleSz
, 1);
3070 // Ïðàâûé íèæíèé óãîë
3071 aX2
:= aX
+ aX2
- 1;
3072 aY2
:= aY
+ aY2
- 1;
3073 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 255, 0, 0);
3079 if (gMapInfo
.Width
> RenderRect
.Right
- RenderRect
.Left
) or
3080 (gMapInfo
.Height
> RenderRect
.Bottom
- RenderRect
.Top
) then
3083 // Ñêîëüêî ïèêñåëîâ êàðòû â 1 ïèêñåëå ìèíè-êàðòû:
3084 ScaleSz
:= 16 div Scale
;
3085 // Ðàçìåðû ìèíè-êàðòû:
3086 aX
:= max(gMapInfo
.Width
div ScaleSz
, 1);
3087 aY
:= max(gMapInfo
.Height
div ScaleSz
, 1);
3089 e_DrawFillQuad(0, 0, aX
-1, aY
-1, 0, 0, 0, 0);
3091 if gWalls
<> nil then
3094 for a
:= 0 to High(gWalls
) do
3096 if PanelType
<> 0 then
3098 // Ëåâûé âåðõíèé óãîë:
3099 aX
:= X
div ScaleSz
;
3100 aY
:= Y
div ScaleSz
;
3102 aX2
:= max(Width
div ScaleSz
, 1);
3103 aY2
:= max(Height
div ScaleSz
, 1);
3104 // Ïðàâûé íèæíèé óãîë:
3105 aX2
:= aX
+ aX2
- 1;
3106 aY2
:= aY
+ aY2
- 1;
3109 PANEL_WALL
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 208, 208, 208, 0);
3110 PANEL_OPENDOOR
, PANEL_CLOSEDOOR
:
3111 if Enabled
then e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 160, 160, 160, 0);
3115 if gSteps
<> nil then
3118 for a
:= 0 to High(gSteps
) do
3120 if PanelType
<> 0 then
3122 // Ëåâûé âåðõíèé óãîë:
3123 aX
:= X
div ScaleSz
;
3124 aY
:= Y
div ScaleSz
;
3126 aX2
:= max(Width
div ScaleSz
, 1);
3127 aY2
:= max(Height
div ScaleSz
, 1);
3128 // Ïðàâûé íèæíèé óãîë:
3129 aX2
:= aX
+ aX2
- 1;
3130 aY2
:= aY
+ aY2
- 1;
3132 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 128, 128, 128, 0);
3135 if gLifts
<> nil then
3138 for a
:= 0 to High(gLifts
) do
3140 if PanelType
<> 0 then
3142 // Ëåâûé âåðõíèé óãîë:
3143 aX
:= X
div ScaleSz
;
3144 aY
:= Y
div ScaleSz
;
3146 aX2
:= max(Width
div ScaleSz
, 1);
3147 aY2
:= max(Height
div ScaleSz
, 1);
3148 // Ïðàâûé íèæíèé óãîë:
3149 aX2
:= aX
+ aX2
- 1;
3150 aY2
:= aY
+ aY2
- 1;
3153 LIFTTYPE_UP
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 116, 72, 36, 0);
3154 LIFTTYPE_DOWN
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 116, 124, 96, 0);
3155 LIFTTYPE_LEFT
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 200, 80, 4, 0);
3156 LIFTTYPE_RIGHT
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 252, 140, 56, 0);
3160 if gWater
<> nil then
3163 for a
:= 0 to High(gWater
) do
3165 if PanelType
<> 0 then
3167 // Ëåâûé âåðõíèé óãîë:
3168 aX
:= X
div ScaleSz
;
3169 aY
:= Y
div ScaleSz
;
3171 aX2
:= max(Width
div ScaleSz
, 1);
3172 aY2
:= max(Height
div ScaleSz
, 1);
3173 // Ïðàâûé íèæíèé óãîë:
3174 aX2
:= aX
+ aX2
- 1;
3175 aY2
:= aY
+ aY2
- 1;
3177 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 0, 192, 0);
3180 if gAcid1
<> nil then
3182 // Ðèñóåì êèñëîòó 1:
3183 for a
:= 0 to High(gAcid1
) do
3185 if PanelType
<> 0 then
3187 // Ëåâûé âåðõíèé óãîë:
3188 aX
:= X
div ScaleSz
;
3189 aY
:= Y
div ScaleSz
;
3191 aX2
:= max(Width
div ScaleSz
, 1);
3192 aY2
:= max(Height
div ScaleSz
, 1);
3193 // Ïðàâûé íèæíèé óãîë:
3194 aX2
:= aX
+ aX2
- 1;
3195 aY2
:= aY
+ aY2
- 1;
3197 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 176, 0, 0);
3200 if gAcid2
<> nil then
3202 // Ðèñóåì êèñëîòó 2:
3203 for a
:= 0 to High(gAcid2
) do
3205 if PanelType
<> 0 then
3207 // Ëåâûé âåðõíèé óãîë:
3208 aX
:= X
div ScaleSz
;
3209 aY
:= Y
div ScaleSz
;
3211 aX2
:= max(Width
div ScaleSz
, 1);
3212 aY2
:= max(Height
div ScaleSz
, 1);
3213 // Ïðàâûé íèæíèé óãîë:
3214 aX2
:= aX
+ aX2
- 1;
3215 aY2
:= aY
+ aY2
- 1;
3217 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 176, 0, 0, 0);
3220 if gPlayers
<> nil then
3223 for a
:= 0 to High(gPlayers
) do
3224 if gPlayers
[a
] <> nil then with gPlayers
[a
] do
3226 // Ëåâûé âåðõíèé óãîë:
3227 aX
:= Obj
.X
div ScaleSz
+ 1;
3228 aY
:= Obj
.Y
div ScaleSz
+ 1;
3230 aX2
:= max(Obj
.Rect
.Width
div ScaleSz
, 1);
3231 aY2
:= max(Obj
.Rect
.Height
div ScaleSz
, 1);
3232 // Ïðàâûé íèæíèé óãîë:
3233 aX2
:= aX
+ aX2
- 1;
3234 aY2
:= aY
+ aY2
- 1;
3236 if gPlayers
[a
] = p
then
3237 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 255, 0, 0)
3240 TEAM_RED
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 0, 0, 0);
3241 TEAM_BLUE
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 0, 255, 0);
3242 else e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 128, 0, 0);
3247 g_Mons_ForEach(monDraw
);
3252 procedure renderAmbientQuad (hasAmbient
: Boolean; constref ambColor
: TDFColor
);
3254 if not hasAmbient
then exit
;
3255 e_AmbientQuad(sX
, sY
, sWidth
, sHeight
, ambColor
.r
, ambColor
.g
, ambColor
.b
, ambColor
.a
);
3259 // setup sX, sY, sWidth, sHeight, and transformation matrix before calling this!
3260 //FIXME: broken for splitscreen mode
3261 procedure renderDynLightsInternal ();
3263 //hasAmbient: Boolean;
3264 //ambColor: TDFColor;
3266 lx
, ly
, lrad
: Integer;
3267 scxywh
: array[0..3] of GLint
;
3270 if e_NoGraphics
then exit
;
3272 //TODO: lights should be in separate grid, i think
3273 // but on the other side: grid may be slower for dynlights, as their lifetime is short
3274 if (not gwin_k8_enable_light_experiments
) or (not gwin_has_stencil
) or (g_dynLightCount
< 1) then exit
;
3277 //ambColor := gCurrentMap['light_ambient'].rgba;
3278 //hasAmbient := (not ambColor.isOpaque) or (not ambColor.isBlack);
3280 { // this will multiply incoming color to alpha from framebuffer
3282 glBlendFunc(GL_DST_ALPHA, GL_ONE);
3286 * light rendering: (INVALID!)
3287 * glStencilFunc(GL_EQUAL, 0, $ff);
3289 * glClear(GL_STENCIL_BUFFER_BIT);
3290 * glStencilOp(GL_KEEP, GL_KEEP, GL_INCR);
3291 * draw shadow volume into stencil buffer
3292 * glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); // modify color buffer
3293 * glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); // don't modify stencil buffer
3295 * draw color-less quad with light alpha (WARNING! don't touch color!)
3296 * glEnable(GL_BLEND);
3297 * glBlendFunc(GL_DST_ALPHA, GL_ONE);
3298 * draw all geometry up to and including walls (with alpha-testing, probably) -- this does lighting
3300 wassc
:= (glIsEnabled(GL_SCISSOR_TEST
) <> 0);
3301 if wassc
then glGetIntegerv(GL_SCISSOR_BOX
, @scxywh
[0]) else glGetIntegerv(GL_VIEWPORT
, @scxywh
[0]);
3303 // setup OpenGL parameters
3304 glStencilMask($FFFFFFFF);
3305 glStencilFunc(GL_ALWAYS
, 0, $FFFFFFFF);
3306 glEnable(GL_STENCIL_TEST
);
3307 glEnable(GL_SCISSOR_TEST
);
3308 glClear(GL_STENCIL_BUFFER_BIT
);
3309 glStencilFunc(GL_EQUAL
, 0, $ff);
3311 for lln
:= 0 to g_dynLightCount
-1 do
3313 lx
:= g_dynLights
[lln
].x
;
3314 ly
:= g_dynLights
[lln
].y
;
3315 lrad
:= g_dynLights
[lln
].radius
;
3316 if (lrad
< 3) then continue
;
3318 if (lx
-sX
+lrad
< 0) then continue
;
3319 if (ly
-sY
+lrad
< 0) then continue
;
3320 if (lx
-sX
-lrad
>= gPlayerScreenSize
.X
) then continue
;
3321 if (ly
-sY
-lrad
>= gPlayerScreenSize
.Y
) then continue
;
3323 // set scissor to optimize drawing
3324 if (g_dbg_scale
= 1.0) then
3326 glScissor((lx
-sX
)-lrad
+2, gPlayerScreenSize
.Y
-(ly
-sY
)-lrad
-1+2, lrad
*2-4, lrad
*2-4);
3330 glScissor(0, 0, gWinSizeX
, gWinSizeY
);
3332 // no need to clear stencil buffer, light blitting will do it for us... but only for normal scale
3333 if (g_dbg_scale
<> 1.0) then glClear(GL_STENCIL_BUFFER_BIT
);
3334 glStencilOp(GL_KEEP
, GL_KEEP
, GL_INCR
);
3335 // draw extruded panels
3336 glDisable(GL_TEXTURE_2D
);
3337 glDisable(GL_BLEND
);
3338 glColorMask(GL_FALSE
, GL_FALSE
, GL_FALSE
, GL_FALSE
); // no need to modify color buffer
3339 if (lrad
> 4) then g_Map_DrawPanelShadowVolumes(lx
, ly
, lrad
);
3340 // render light texture
3341 glColorMask(GL_TRUE
, GL_TRUE
, GL_TRUE
, GL_TRUE
); // modify color buffer
3342 glStencilOp(GL_ZERO
, GL_ZERO
, GL_ZERO
); // draw light, and clear stencil buffer
3345 glBlendFunc(GL_SRC_ALPHA
, GL_ONE_MINUS_SRC_ALPHA
);
3346 glEnable(GL_TEXTURE_2D
);
3347 // color and opacity
3348 glColor4f(g_dynLights
[lln
].r
, g_dynLights
[lln
].g
, g_dynLights
[lln
].b
, g_dynLights
[lln
].a
);
3349 glBindTexture(GL_TEXTURE_2D
, g_Texture_Light());
3351 glTexCoord2f(0.0, 0.0); glVertex2i(lx
-lrad
, ly
-lrad
); // top-left
3352 glTexCoord2f(1.0, 0.0); glVertex2i(lx
+lrad
, ly
-lrad
); // top-right
3353 glTexCoord2f(1.0, 1.0); glVertex2i(lx
+lrad
, ly
+lrad
); // bottom-right
3354 glTexCoord2f(0.0, 1.0); glVertex2i(lx
-lrad
, ly
+lrad
); // bottom-left
3359 glDisable(GL_STENCIL_TEST
);
3360 glDisable(GL_BLEND
);
3361 glDisable(GL_SCISSOR_TEST
);
3362 //glScissor(0, 0, sWidth, sHeight);
3364 glScissor(scxywh
[0], scxywh
[1], scxywh
[2], scxywh
[3]);
3365 if wassc
then glEnable(GL_SCISSOR_TEST
) else glDisable(GL_SCISSOR_TEST
);
3369 function fixViewportForScale (): Boolean;
3371 nx0
, ny0
, nw
, nh
: Integer;
3374 if (g_dbg_scale
<> 1.0) then
3377 nx0
:= round(sX
-(gPlayerScreenSize
.X
-(sWidth
*g_dbg_scale
))/2/g_dbg_scale
);
3378 ny0
:= round(sY
-(gPlayerScreenSize
.Y
-(sHeight
*g_dbg_scale
))/2/g_dbg_scale
);
3379 nw
:= round(sWidth
/g_dbg_scale
);
3380 nh
:= round(sHeight
/g_dbg_scale
);
3389 // setup sX, sY, sWidth, sHeight, and transformation matrix before calling this!
3390 // WARNING! this WILL CALL `glTranslatef()`, but won't restore matrices!
3391 procedure renderMapInternal (backXOfs
, backYOfs
: Integer; setTransMatrix
: Boolean);
3393 TDrawCB
= procedure ();
3396 hasAmbient
: Boolean;
3398 doAmbient
: Boolean = false;
3400 procedure drawPanelType (profname
: AnsiString; panType
: DWord
; doDraw
: Boolean);
3405 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin(profname
);
3406 if gdbg_map_use_accel_render
then
3408 tagmask
:= panelTypeToTag(panType
);
3409 while (gDrawPanelList
.count
> 0) do
3411 pan
:= TPanel(gDrawPanelList
.front());
3412 if ((pan
.tag
and tagmask
) = 0) then break
;
3413 if doDraw
then pan
.Draw(doAmbient
, ambColor
);
3414 gDrawPanelList
.popFront();
3419 if doDraw
then g_Map_DrawPanels(panType
, hasAmbient
, ambColor
);
3421 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
3424 procedure drawOther (profname
: AnsiString; cb
: TDrawCB
);
3426 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin(profname
);
3427 if assigned(cb
) then cb();
3428 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
3432 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin('total');
3434 // our accelerated renderer will collect all panels to gDrawPanelList
3435 // we can use panel tag to render level parts (see GridTagXXX in g_map.pas)
3436 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin('collect');
3437 if gdbg_map_use_accel_render
then
3439 g_Map_CollectDrawPanels(sX
, sY
, sWidth
, sHeight
);
3441 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
3443 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin('skyback');
3444 g_Map_DrawBack(backXOfs
, backYOfs
);
3445 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
3447 if setTransMatrix
then
3449 //if (g_dbg_scale <> 1.0) then glTranslatef(0.0, -0.375/2, 0);
3450 glScalef(g_dbg_scale
, g_dbg_scale
, 1.0);
3451 glTranslatef(-sX
, -sY
, 0);
3455 ambColor
:= gCurrentMap
['light_ambient'].rgba
;
3456 hasAmbient
:= (not ambColor
.isOpaque
) or (not ambColor
.isBlack
);
3461 //writeln('color: (', ambColor.r, ',', ambColor.g, ',', ambColor.b, ',', ambColor.a, ')');
3462 glColor4ub(ambColor.r, ambColor.g, ambColor.b, ambColor.a);
3463 glClear(GL_COLOR_BUFFER_BIT);
3466 //writeln('color: (', ambColor.r, ',', ambColor.g, ',', ambColor.b, ',', ambColor.a, ')');
3469 drawPanelType('*back', PANEL_BACK
, g_rlayer_back
);
3470 drawPanelType('*step', PANEL_STEP
, g_rlayer_step
);
3471 drawOther('items', @g_Items_Draw
);
3472 drawOther('weapons', @g_Weapon_Draw
);
3473 drawOther('shells', @g_Player_DrawShells
);
3474 drawOther('drawall', @g_Player_DrawAll
);
3475 drawOther('corpses', @g_Player_DrawCorpses
);
3476 drawPanelType('*wall', PANEL_WALL
, g_rlayer_wall
);
3477 drawOther('monsters', @g_Monsters_Draw
);
3478 drawOther('itemdrop', @g_Items_DrawDrop
);
3479 drawPanelType('*door', PANEL_CLOSEDOOR
, g_rlayer_door
);
3480 drawOther('gfx', @g_GFX_Draw
);
3481 drawOther('flags', @g_Map_DrawFlags
);
3482 drawPanelType('*acid1', PANEL_ACID1
, g_rlayer_acid1
);
3483 drawPanelType('*acid2', PANEL_ACID2
, g_rlayer_acid2
);
3484 drawPanelType('*water', PANEL_WATER
, g_rlayer_water
);
3485 drawOther('dynlights', @renderDynLightsInternal
);
3487 if hasAmbient
{and ((not g_playerLight) or (not gwin_has_stencil) or (g_dynLightCount < 1))} then
3489 renderAmbientQuad(hasAmbient
, ambColor
);
3493 drawPanelType('*fore', PANEL_FORE
, g_rlayer_fore
);
3496 if g_debug_HealthBar
then
3498 g_Monsters_DrawHealth();
3499 g_Player_DrawHealth();
3502 if (profileFrameDraw
<> nil) then profileFrameDraw
.mainEnd(); // map rendering
3506 procedure DrawMapView(x
, y
, w
, h
: Integer);
3513 bx
:= Round(x
/(gMapInfo
.Width
- w
)*(gBackSize
.X
- w
));
3514 by
:= Round(y
/(gMapInfo
.Height
- h
)*(gBackSize
.Y
- h
));
3521 fixViewportForScale();
3522 renderMapInternal(-bx
, -by
, true);
3528 procedure DrawPlayer(p
: TPlayer
);
3530 px
, py
, a
, b
, c
, d
, i
: Integer;
3533 if (p
= nil) or (p
.FDummy
) then
3536 g_Map_DrawBack(0, 0);
3541 if (profileFrameDraw
= nil) then profileFrameDraw
:= TProfiler
.Create('RENDER', g_profile_history_size
);
3542 if (profileFrameDraw
<> nil) then profileFrameDraw
.mainBegin(g_profile_frame_draw
);
3548 px
:= p
.GameX
+ PLAYER_RECT_CX
;
3549 py
:= p
.GameY
+ PLAYER_RECT_CY
+p
.Obj
.slopeUpLeft
;
3551 if (g_dbg_scale
= 1.0) and (not g_dbg_ignore_bounds
) then
3553 if (px
> (gPlayerScreenSize
.X
div 2)) then a
:= -px
+(gPlayerScreenSize
.X
div 2) else a
:= 0;
3554 if (py
> (gPlayerScreenSize
.Y
div 2)) then b
:= -py
+(gPlayerScreenSize
.Y
div 2) else b
:= 0;
3556 if (px
> gMapInfo
.Width
-(gPlayerScreenSize
.X
div 2)) then a
:= -gMapInfo
.Width
+gPlayerScreenSize
.X
;
3557 if (py
> gMapInfo
.Height
-(gPlayerScreenSize
.Y
div 2)) then b
:= -gMapInfo
.Height
+gPlayerScreenSize
.Y
;
3559 if (gMapInfo
.Width
= gPlayerScreenSize
.X
) then a
:= 0
3560 else if (gMapInfo
.Width
< gPlayerScreenSize
.X
) then
3563 a
:= (gPlayerScreenSize
.X
-gMapInfo
.Width
) div 2;
3566 if (gMapInfo
.Height
= gPlayerScreenSize
.Y
) then b
:= 0
3567 else if (gMapInfo
.Height
< gPlayerScreenSize
.Y
) then
3570 b
:= (gPlayerScreenSize
.Y
-gMapInfo
.Height
) div 2;
3575 // scaled, ignore level bounds
3576 a
:= -px
+(gPlayerScreenSize
.X
div 2);
3577 b
:= -py
+(gPlayerScreenSize
.Y
div 2);
3580 if p
.IncCam
<> 0 then
3582 if py
> gMapInfo
.Height
-(gPlayerScreenSize
.Y
div 2) then
3584 if p
.IncCam
> 120-(py
-(gMapInfo
.Height
-(gPlayerScreenSize
.Y
div 2))) then
3586 p
.IncCam
:= 120-(py
-(gMapInfo
.Height
-(gPlayerScreenSize
.Y
div 2)));
3590 if py
< gPlayerScreenSize
.Y
div 2 then
3592 if p
.IncCam
< -120+((gPlayerScreenSize
.Y
div 2)-py
) then
3594 p
.IncCam
:= -120+((gPlayerScreenSize
.Y
div 2)-py
);
3598 if p
.IncCam
< 0 then
3600 while (py
+(gPlayerScreenSize
.Y
div 2)-p
.IncCam
> gMapInfo
.Height
) and (p
.IncCam
< 0) do p
.IncCam
:= p
.IncCam
+1; //Inc(p.IncCam);
3603 if p
.IncCam
> 0 then
3605 while (py
-(gPlayerScreenSize
.Y
div 2)-p
.IncCam
< 0) and (p
.IncCam
> 0) do p
.IncCam
:= p
.IncCam
-1; //Dec(p.IncCam);
3609 if (px
< gPlayerScreenSize
.X
div 2) or (gMapInfo
.Width
-gPlayerScreenSize
.X
<= 256) then c
:= 0
3610 else if (px
> gMapInfo
.Width
-(gPlayerScreenSize
.X
div 2)) then c
:= gBackSize
.X
-gPlayerScreenSize
.X
3611 else c
:= round((px
-(gPlayerScreenSize
.X
div 2))/(gMapInfo
.Width
-gPlayerScreenSize
.X
)*(gBackSize
.X
-gPlayerScreenSize
.X
));
3613 if (py
-p
.IncCam
<= gPlayerScreenSize
.Y
div 2) or (gMapInfo
.Height
-gPlayerScreenSize
.Y
<= 256) then d
:= 0
3614 else if (py
-p
.IncCam
>= gMapInfo
.Height
-(gPlayerScreenSize
.Y
div 2)) then d
:= gBackSize
.Y
-gPlayerScreenSize
.Y
3615 else d
:= round((py
-p
.IncCam
-(gPlayerScreenSize
.Y
div 2))/(gMapInfo
.Height
-gPlayerScreenSize
.Y
)*(gBackSize
.Y
-gPlayerScreenSize
.Y
));
3618 sY
:= -(b
+p
.IncCam
);
3619 sWidth
:= gPlayerScreenSize
.X
;
3620 sHeight
:= gPlayerScreenSize
.Y
;
3622 //glTranslatef(a, b+p.IncCam, 0);
3624 //if (p = gPlayer1) and (g_dbg_scale >= 1.0) then g_Holmes_plrViewSize(sWidth, sHeight);
3626 //conwritefln('OLD: (%s,%s)-(%s,%s)', [sX, sY, sWidth, sHeight]);
3627 fixViewportForScale();
3628 //conwritefln(' (%s,%s)-(%s,%s)', [sX, sY, sWidth, sHeight]);
3630 if (g_dbg_scale
<> 1.0) and (not g_dbg_ignore_bounds
) then
3632 if (sX
+sWidth
> gMapInfo
.Width
) then sX
:= gMapInfo
.Width
-sWidth
;
3633 if (sY
+sHeight
> gMapInfo
.Height
) then sY
:= gMapInfo
.Height
-sHeight
;
3634 if (sX
< 0) then sX
:= 0;
3635 if (sY
< 0) then sY
:= 0;
3637 if (gBackSize
.X
<= gPlayerScreenSize
.X
) or (gMapInfo
.Width
<= sWidth
) then c
:= 0 else c
:= trunc((gBackSize
.X
-gPlayerScreenSize
.X
)*sX
/(gMapInfo
.Width
-sWidth
));
3638 if (gBackSize
.Y
<= gPlayerScreenSize
.Y
) or (gMapInfo
.Height
<= sHeight
) then d
:= 0 else d
:= trunc((gBackSize
.Y
-gPlayerScreenSize
.Y
)*sY
/(gMapInfo
.Height
-sHeight
));
3641 //r_smallmap_h: 0: left; 1: center; 2: right
3642 //r_smallmap_v: 0: top; 1: center; 2: bottom
3644 if (gMapInfo
.Width
= sWidth
) then
3648 else if (gMapInfo
.Width
< sWidth
) then
3650 case r_smallmap_h
of
3651 1: sX
:= -((sWidth
-gMapInfo
.Width
) div 2); // center
3652 2: sX
:= -(sWidth
-gMapInfo
.Width
); // right
3653 else sX
:= 0; // left
3657 if (gMapInfo
.Height
= sHeight
) then
3661 else if (gMapInfo
.Height
< sHeight
) then
3663 case r_smallmap_v
of
3664 1: sY
:= -((sHeight
-gMapInfo
.Height
) div 2); // center
3665 2: sY
:= -(sHeight
-gMapInfo
.Height
); // bottom
3666 else sY
:= 0; // top
3672 p
.viewPortW
:= sWidth
;
3673 p
.viewPortH
:= sHeight
;
3675 {$IFDEF ENABLE_HOLMES}
3676 if (p
= gPlayer1
) then
3678 g_Holmes_plrViewPos(sX
, sY
);
3679 g_Holmes_plrViewSize(sWidth
, sHeight
);
3683 renderMapInternal(-c
, -d
, true);
3685 if (gGameSettings
.GameMode
<> GM_SINGLE
) and (gPlayerIndicator
> 0) then
3686 case gPlayerIndicator
of
3688 p
.DrawIndicator(_RGB(255, 255, 255));
3691 for i
:= 0 to High(gPlayers
) do
3692 if gPlayers
[i
] <> nil then
3693 if gPlayers
[i
] = p
then p
.DrawIndicator(_RGB(255, 255, 255))
3694 else if (gPlayers
[i
].Team
= p
.Team
) and (gPlayers
[i
].Team
<> TEAM_NONE
) then
3695 if gPlayerIndicatorStyle
= 1 then
3696 gPlayers
[i
].DrawIndicator(_RGB(192, 192, 192))
3697 else gPlayers
[i
].DrawIndicator(gPlayers
[i
].GetColor
);
3700 if p
.FSpectator
then
3701 e_TextureFontPrintEx(p
.GameX
+ PLAYER_RECT_CX
- 4,
3702 p
.GameY
+ PLAYER_RECT_CY
- 4,
3703 'X', gStdFont
, 255, 255, 255, 1, True);
3705 for a := 0 to High(gCollideMap) do
3706 for b := 0 to High(gCollideMap[a]) do
3709 if ByteBool(gCollideMap[a, b] and MARK_WALL) then
3711 if ByteBool(gCollideMap[a, b] and MARK_DOOR) then
3715 1: e_DrawPoint(1, b, a, 200, 200, 200);
3716 2: e_DrawPoint(1, b, a, 64, 64, 255);
3717 3: e_DrawPoint(1, b, a, 255, 0, 255);
3727 if gShowMap
then DrawMinimap(p
, _TRect(0, 0, 128, 128));
3728 if g_Debug_Player
then
3729 g_Player_DrawDebug(p
);
3733 procedure drawProfilers ();
3738 if g_profile_frame_draw
and (profileFrameDraw
<> nil) then px
:= px
-drawProfiles(px
, py
, profileFrameDraw
);
3739 if g_profile_collision
and (profMapCollision
<> nil) then begin px
:= px
-drawProfiles(px
, py
, profMapCollision
); py
-= calcProfilesHeight(profMonsLOS
); end;
3740 if g_profile_los
and (profMonsLOS
<> nil) then begin px
:= px
-drawProfiles(px
, py
, profMonsLOS
); py
-= calcProfilesHeight(profMonsLOS
); end;
3743 procedure g_Game_Draw();
3750 plView1
, plView2
: TPlayer
;
3753 if gExit
= EXIT_QUIT
then Exit
;
3755 Time
:= sys_GetTicks() {div 1000};
3756 FPSCounter
:= FPSCounter
+1;
3757 if Time
- FPSTime
>= 1000 then
3764 if gGameOn
or (gState
= STATE_FOLD
) then
3766 if (gPlayer1
<> nil) and (gPlayer2
<> nil) then
3768 gSpectMode
:= SPECT_NONE
;
3769 if not gRevertPlayers
then
3771 plView1
:= gPlayer1
;
3772 plView2
:= gPlayer2
;
3776 plView1
:= gPlayer2
;
3777 plView2
:= gPlayer1
;
3781 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
3783 gSpectMode
:= SPECT_NONE
;
3784 if gPlayer2
= nil then
3787 plView1
:= gPlayer2
;
3796 if (plView1
= nil) and (plView2
= nil) and (gSpectMode
= SPECT_NONE
) then
3797 gSpectMode
:= SPECT_STATS
;
3799 if gSpectMode
= SPECT_PLAYERS
then
3800 if gPlayers
<> nil then
3802 plView1
:= GetActivePlayer_ByID(gSpectPID1
);
3803 if plView1
= nil then
3805 gSpectPID1
:= GetActivePlayerID_Next();
3806 plView1
:= GetActivePlayer_ByID(gSpectPID1
);
3808 if gSpectViewTwo
then
3810 plView2
:= GetActivePlayer_ByID(gSpectPID2
);
3811 if plView2
= nil then
3813 gSpectPID2
:= GetActivePlayerID_Next();
3814 plView2
:= GetActivePlayer_ByID(gSpectPID2
);
3819 if gSpectMode
= SPECT_MAPVIEW
then
3821 // Ðåæèì ïðîñìîòðà êàðòû
3823 e_SetViewPort(0, 0, gScreenWidth
, gScreenHeight
);
3824 DrawMapView(gSpectX
, gSpectY
, gScreenWidth
, gScreenHeight
);
3825 gHearPoint1
.Active
:= True;
3826 gHearPoint1
.Coords
.X
:= gScreenWidth
div 2 + gSpectX
;
3827 gHearPoint1
.Coords
.Y
:= gScreenHeight
div 2 + gSpectY
;
3828 gHearPoint2
.Active
:= False;
3832 Split
:= (plView1
<> nil) and (plView2
<> nil);
3834 // Òî÷êè ñëóõà èãðîêîâ
3835 if plView1
<> nil then
3837 gHearPoint1
.Active
:= True;
3838 gHearPoint1
.Coords
.X
:= plView1
.GameX
+ PLAYER_RECT
.Width
;
3839 gHearPoint1
.Coords
.Y
:= plView1
.GameY
+ PLAYER_RECT
.Height
DIV 2;
3841 gHearPoint1
.Active
:= False;
3842 if plView2
<> nil then
3844 gHearPoint2
.Active
:= True;
3845 gHearPoint2
.Coords
.X
:= plView2
.GameX
+ PLAYER_RECT
.Width
;
3846 gHearPoint2
.Coords
.Y
:= plView2
.GameY
+ PLAYER_RECT
.Height
DIV 2;
3848 gHearPoint2
.Active
:= False;
3850 // Ðàçìåð ýêðàíîâ èãðîêîâ:
3851 gPlayerScreenSize
.X
:= gScreenWidth
-196;
3854 gPlayerScreenSize
.Y
:= gScreenHeight
div 2;
3855 if gScreenHeight
mod 2 = 0 then
3856 Dec(gPlayerScreenSize
.Y
);
3859 gPlayerScreenSize
.Y
:= gScreenHeight
;
3862 if gScreenHeight
mod 2 = 0 then
3863 e_SetViewPort(0, gPlayerScreenSize
.Y
+2, gPlayerScreenSize
.X
+196, gPlayerScreenSize
.Y
)
3865 e_SetViewPort(0, gPlayerScreenSize
.Y
+1, gPlayerScreenSize
.X
+196, gPlayerScreenSize
.Y
);
3867 DrawPlayer(plView1
);
3868 gPlayer1ScreenCoord
.X
:= sX
;
3869 gPlayer1ScreenCoord
.Y
:= sY
;
3873 e_SetViewPort(0, 0, gPlayerScreenSize
.X
+196, gPlayerScreenSize
.Y
);
3875 DrawPlayer(plView2
);
3876 gPlayer2ScreenCoord
.X
:= sX
;
3877 gPlayer2ScreenCoord
.Y
:= sY
;
3880 e_SetViewPort(0, 0, gScreenWidth
, gScreenHeight
);
3883 e_DrawLine(2, 0, gScreenHeight
div 2, gScreenWidth
, gScreenHeight
div 2, 0, 0, 0);
3886 {$IFDEF ENABLE_HOLMES}
3888 if (g_holmes_enabled
) then g_Holmes_Draw();
3891 if MessageText
<> '' then
3895 e_CharFont_GetSizeFmt(gMenuFont
, MessageText
, w
, h
);
3897 e_CharFont_PrintFmt(gMenuFont
, (gScreenWidth
div 2)-(w
div 2),
3898 (gScreenHeight
div 2)-(h
div 2), MessageText
)
3900 e_CharFont_PrintFmt(gMenuFont
, (gScreenWidth
div 2)-(w
div 2),
3901 Round(gScreenHeight
/ 2.75)-(h
div 2), MessageText
);
3904 if IsDrawStat
or (gSpectMode
= 1) then DrawStat();
3906 if gSpectHUD
and (not gChatShow
) and (gSpectMode
<> SPECT_NONE
) and (not gSpectAuto
) then
3908 // Draw spectator GUI
3911 e_TextureFontGetSize(gStdFont
, ww
, hh
);
3914 e_TextureFontPrintEx(0, gScreenHeight
- (hh
+2)*2, 'MODE: Stats', gStdFont
, 255, 255, 255, 1);
3916 e_TextureFontPrintEx(0, gScreenHeight
- (hh
+2)*2, 'MODE: Observe Map', gStdFont
, 255, 255, 255, 1);
3918 e_TextureFontPrintEx(0, gScreenHeight
- (hh
+2)*2, 'MODE: Watch Players', gStdFont
, 255, 255, 255, 1);
3920 e_TextureFontPrintEx(2*ww
, gScreenHeight
- (hh
+2), '< jump >', gStdFont
, 255, 255, 255, 1);
3921 if gSpectMode
= SPECT_STATS
then
3923 e_TextureFontPrintEx(16*ww
, gScreenHeight
- (hh
+2)*2, 'Autoview', gStdFont
, 255, 255, 255, 1);
3924 e_TextureFontPrintEx(16*ww
, gScreenHeight
- (hh
+2), '< fire >', gStdFont
, 255, 255, 255, 1);
3926 if gSpectMode
= SPECT_MAPVIEW
then
3928 e_TextureFontPrintEx(22*ww
, gScreenHeight
- (hh
+2)*2, '[-]', gStdFont
, 255, 255, 255, 1);
3929 e_TextureFontPrintEx(26*ww
, gScreenHeight
- (hh
+2)*2, 'Step ' + IntToStr(gSpectStep
), gStdFont
, 255, 255, 255, 1);
3930 e_TextureFontPrintEx(34*ww
, gScreenHeight
- (hh
+2)*2, '[+]', gStdFont
, 255, 255, 255, 1);
3931 e_TextureFontPrintEx(18*ww
, gScreenHeight
- (hh
+2), '<prev weap>', gStdFont
, 255, 255, 255, 1);
3932 e_TextureFontPrintEx(30*ww
, gScreenHeight
- (hh
+2), '<next weap>', gStdFont
, 255, 255, 255, 1);
3934 if gSpectMode
= SPECT_PLAYERS
then
3936 e_TextureFontPrintEx(22*ww
, gScreenHeight
- (hh
+2)*2, 'Player 1', gStdFont
, 255, 255, 255, 1);
3937 e_TextureFontPrintEx(20*ww
, gScreenHeight
- (hh
+2), '<left/right>', gStdFont
, 255, 255, 255, 1);
3938 if gSpectViewTwo
then
3940 e_TextureFontPrintEx(37*ww
, gScreenHeight
- (hh
+2)*2, 'Player 2', gStdFont
, 255, 255, 255, 1);
3941 e_TextureFontPrintEx(34*ww
, gScreenHeight
- (hh
+2), '<prev w/next w>', gStdFont
, 255, 255, 255, 1);
3942 e_TextureFontPrintEx(52*ww
, gScreenHeight
- (hh
+2)*2, '2x View', gStdFont
, 255, 255, 255, 1);
3943 e_TextureFontPrintEx(51*ww
, gScreenHeight
- (hh
+2), '<up/down>', gStdFont
, 255, 255, 255, 1);
3947 e_TextureFontPrintEx(35*ww
, gScreenHeight
- (hh
+2)*2, '2x View', gStdFont
, 255, 255, 255, 1);
3948 e_TextureFontPrintEx(34*ww
, gScreenHeight
- (hh
+2), '<up/down>', gStdFont
, 255, 255, 255, 1);
3954 if gPauseMain
and gGameOn
and (g_ActiveWindow
= nil) then
3956 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
3957 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
3959 e_CharFont_GetSize(gMenuFont
, _lc
[I_MENU_PAUSE
], w
, h
);
3960 e_CharFont_Print(gMenuFont
, (gScreenWidth
div 2)-(w
div 2),
3961 (gScreenHeight
div 2)-(h
div 2), _lc
[I_MENU_PAUSE
]);
3966 if (gState
= STATE_MENU
) then
3968 if (g_ActiveWindow
= nil) or (g_ActiveWindow
.BackTexture
= '') then DrawMenuBackground('MENU_BACKGROUND');
3969 // F3 at menu will show game loading dialog
3970 if e_KeyPressed(IK_F3
) then g_Menu_Show_LoadMenu(true);
3971 if (g_ActiveWindow
<> nil) then
3973 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
3974 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
3978 // F3 at titlepic will show game loading dialog
3979 if e_KeyPressed(IK_F3
) then
3981 g_Menu_Show_LoadMenu(true);
3982 if (g_ActiveWindow
<> nil) then e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
3987 if gState
= STATE_FOLD
then
3989 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 0, 0, 0, EndingGameCounter
);
3992 if gState
= STATE_INTERCUSTOM
then
3994 if gLastMap
and (gGameSettings
.GameMode
= GM_COOP
) then
3996 back
:= 'TEXTURE_endpic';
3997 if not g_Texture_Get(back
, ID
) then
3998 back
:= _lc
[I_TEXTURE_ENDPIC
];
4003 DrawMenuBackground(back
);
4007 if g_ActiveWindow
<> nil then
4009 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4010 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4014 if gState
= STATE_INTERSINGLE
then
4016 if EndingGameCounter
> 0 then
4018 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 0, 0, 0, EndingGameCounter
);
4024 DrawMenuBackground(back
);
4028 if g_ActiveWindow
<> nil then
4030 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4031 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4036 if gState
= STATE_ENDPIC
then
4039 if g_Texture_Get('TEXTURE_endpic', ID
) then DrawMenuBackground('TEXTURE_endpic')
4040 else DrawMenuBackground(_lc
[I_TEXTURE_ENDPIC
]);
4042 if g_ActiveWindow
<> nil then
4044 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4045 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4049 if gState
= STATE_SLIST
then
4051 // if g_Texture_Get('MENU_BACKGROUND', ID) then
4053 // e_DrawSize(ID, 0, 0, 0, False, False, gScreenWidth, gScreenHeight);
4054 // //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4056 DrawMenuBackground('MENU_BACKGROUND');
4057 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4058 g_Serverlist_Draw(slCurrent
, slTable
);
4062 if g_ActiveWindow
<> nil then
4066 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4067 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4069 g_ActiveWindow
.Draw();
4076 if g_debug_Sounds
and gGameOn
then
4078 for w
:= 0 to High(e_SoundsArray
) do
4079 for h
:= 0 to e_SoundsArray
[w
].nRefs
do
4080 e_DrawPoint(1, w
+100, h
+100, 255, 0, 0);
4085 e_TextureFontPrint(0, 0, Format('FPS: %d', [FPS
]), gStdFont
);
4086 e_TextureFontPrint(0, 16, Format('UPS: %d', [UPS
]), gStdFont
);
4089 if gGameOn
and gShowTime
then
4090 drawTime(gScreenWidth
-72, gScreenHeight
-16);
4092 if gGameOn
then drawProfilers();
4094 {$IFDEF ENABLE_HOLMES}
4101 procedure g_Game_Quit();
4103 g_Game_StopAllSounds(True);
4106 g_PlayerModel_FreeData();
4107 g_Texture_DeleteAll();
4108 g_Frames_DeleteAll();
4110 //g_Menu_Free(); //k8: this segfaults after resolution change; who cares?
4113 if NetInitDone
then g_Net_Free
;
4115 // Íàäî óäàëèòü êàðòó ïîñëå òåñòà:
4116 if gMapToDelete
<> '' then
4117 g_Game_DeleteTestMap();
4123 procedure g_FatalError(Text: String);
4125 g_Console_Add(Format(_lc
[I_FATAL_ERROR
], [Text]), True);
4126 e_WriteLog(Format(_lc
[I_FATAL_ERROR
], [Text]), TMsgType
.Warning
);
4128 gExit
:= EXIT_SIMPLE
;
4131 procedure g_SimpleError(Text: String);
4133 g_Console_Add(Format(_lc
[I_SIMPLE_ERROR
], [Text]), True);
4134 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], [Text]), TMsgType
.Warning
);
4137 procedure g_Game_SetupScreenSize();
4139 RES_FACTOR
= 4.0 / 3.0;
4145 // Ðàçìåð ýêðàíîâ èãðîêîâ:
4146 gPlayerScreenSize
.X
:= gScreenWidth
-196;
4147 if (gPlayer1
<> nil) and (gPlayer2
<> nil) then
4148 gPlayerScreenSize
.Y
:= gScreenHeight
div 2
4150 gPlayerScreenSize
.Y
:= gScreenHeight
;
4152 // Ðàçìåð çàäíåãî ïëàíà:
4153 if BackID
<> DWORD(-1) then
4156 if (gScreenWidth
*s
> gMapInfo
.Width
) or
4157 (gScreenHeight
*s
> gMapInfo
.Height
) then
4159 gBackSize
.X
:= gScreenWidth
;
4160 gBackSize
.Y
:= gScreenHeight
;
4164 e_GetTextureSize(BackID
, @bw
, @bh
);
4165 rf
:= Single(bw
) / Single(bh
);
4166 if (rf
> RES_FACTOR
) then bw
:= Round(Single(bh
) * RES_FACTOR
)
4167 else if (rf
< RES_FACTOR
) then bh
:= Round(Single(bw
) / RES_FACTOR
);
4168 s
:= Max(gScreenWidth
/ bw
, gScreenHeight
/ bh
);
4169 if (s
< 1.0) then s
:= 1.0;
4170 gBackSize
.X
:= Round(bw
*s
);
4171 gBackSize
.Y
:= Round(bh
*s
);
4176 procedure g_Game_ChangeResolution(newWidth
, newHeight
: Word; nowFull
, nowMax
: Boolean);
4178 sys_SetDisplayMode(newWidth
, newHeight
, gBPP
, nowFull
, nowMax
);
4181 procedure g_Game_AddPlayer(Team
: Byte = TEAM_NONE
);
4183 if ((not gGameOn
) and (gState
<> STATE_INTERCUSTOM
))
4184 or (not (gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
])) then
4186 if gPlayer1
= nil then
4188 if g_Game_IsClient
then
4190 if NetPlrUID1
> -1 then
4192 MC_SEND_CheatRequest(NET_CHEAT_SPECTATE
);
4193 gPlayer1
:= g_Player_Get(NetPlrUID1
);
4198 if not (Team
in [TEAM_RED
, TEAM_BLUE
]) then
4199 Team
:= gPlayer1Settings
.Team
;
4201 // Ñîçäàíèå ïåðâîãî èãðîêà:
4202 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4203 gPlayer1Settings
.Color
,
4205 if gPlayer1
= nil then
4206 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]))
4209 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4210 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [gPlayer1
.Name
]), True);
4211 if g_Game_IsServer
and g_Game_IsNet
then
4212 MH_SEND_PlayerCreate(gPlayer1
.UID
);
4213 gPlayer1
.Respawn(False, True);
4214 g_Net_Slist_ServerPlayerComes();
4219 if gPlayer2
= nil then
4221 if g_Game_IsClient
then
4223 if NetPlrUID2
> -1 then
4224 gPlayer2
:= g_Player_Get(NetPlrUID2
);
4228 if not (Team
in [TEAM_RED
, TEAM_BLUE
]) then
4229 Team
:= gPlayer2Settings
.Team
;
4231 // Ñîçäàíèå âòîðîãî èãðîêà:
4232 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
4233 gPlayer2Settings
.Color
,
4235 if gPlayer2
= nil then
4236 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]))
4239 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
4240 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [gPlayer2
.Name
]), True);
4241 if g_Game_IsServer
and g_Game_IsNet
then
4242 MH_SEND_PlayerCreate(gPlayer2
.UID
);
4243 gPlayer2
.Respawn(False, True);
4244 g_Net_Slist_ServerPlayerComes();
4251 procedure g_Game_RemovePlayer();
4255 if ((not gGameOn
) and (gState
<> STATE_INTERCUSTOM
))
4256 or (not (gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
])) then
4261 if g_Game_IsServer
then
4264 Pl
.Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
4265 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [Pl
.Name
]), True);
4266 g_Player_Remove(Pl
.UID
);
4267 g_Net_Slist_ServerPlayerLeaves();
4275 if g_Game_IsServer
then
4278 Pl
.Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
4279 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [Pl
.Name
]), True);
4280 g_Player_Remove(Pl
.UID
);
4281 g_Net_Slist_ServerPlayerLeaves();
4285 MC_SEND_CheatRequest(NET_CHEAT_SPECTATE
);
4289 g_Net_Slist_ServerPlayerLeaves();
4292 procedure g_Game_Spectate();
4294 g_Game_RemovePlayer();
4295 if gPlayer1
<> nil then
4296 g_Game_RemovePlayer();
4299 procedure g_Game_SpectateCenterView();
4301 gSpectX
:= Max(gMapInfo
.Width
div 2 - gScreenWidth
div 2, 0);
4302 gSpectY
:= Max(gMapInfo
.Height
div 2 - gScreenHeight
div 2, 0);
4305 procedure g_Game_StartSingle(Map
: String; TwoPlayers
: Boolean; nPlayers
: Byte);
4312 e_WriteLog('Starting singleplayer game...', TMsgType
.Notify
);
4314 g_Game_ClearLoading();
4317 FillByte(gGameSettings
, SizeOf(TGameSettings
), 0);
4320 gGameSettings
.GameType
:= GT_SINGLE
;
4321 gGameSettings
.MaxLives
:= 0;
4322 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_ALLOWEXIT
;
4323 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_MONSTERS
;
4324 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_BOTVSMONSTER
;
4325 gSwitchGameMode
:= GM_SINGLE
;
4327 g_Game_ExecuteEvent('ongamestart');
4329 // Óñòàíîâêà ðàçìåðîâ îêîí èãðîêîâ:
4330 g_Game_SetupScreenSize();
4332 // Ñîçäàíèå ïåðâîãî èãðîêà:
4333 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4334 gPlayer1Settings
.Color
,
4335 gPlayer1Settings
.Team
, False));
4336 if gPlayer1
= nil then
4338 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
4342 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4345 // Ñîçäàíèå âòîðîãî èãðîêà, åñëè åñòü:
4348 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
4349 gPlayer2Settings
.Color
,
4350 gPlayer2Settings
.Team
, False));
4351 if gPlayer2
= nil then
4353 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
4357 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
4361 // Çàãðóçêà è çàïóñê êàðòû:
4362 if not g_Game_StartMap(false{asMegawad}, MAP
, True) then
4364 if (Pos(':\', Map
) > 0) or (Pos(':/', Map
) > 0) then tmps
:= Map
else tmps
:= gGameSettings
.WAD
+ ':\' + MAP
;
4365 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [tmps
]));
4369 // Íàñòðîéêè èãðîêîâ è áîòîâ:
4373 for i
:= nPl
+1 to nPlayers
do
4374 g_Player_Create(STD_PLAYER_MODEL
, _RGB(0, 0, 0), 0, True);
4377 procedure g_Game_StartCustom(Map
: String; GameMode
: Byte;
4378 TimeLimit
, GoalLimit
: Word;
4380 Options
: LongWord; nPlayers
: Byte);
4386 e_WriteLog('Starting custom game...', TMsgType
.Notify
);
4388 g_Game_ClearLoading();
4391 gGameSettings
.GameType
:= GT_CUSTOM
;
4392 gGameSettings
.GameMode
:= GameMode
;
4393 gSwitchGameMode
:= GameMode
;
4394 gGameSettings
.TimeLimit
:= TimeLimit
;
4395 gGameSettings
.GoalLimit
:= GoalLimit
;
4396 gGameSettings
.MaxLives
:= IfThen(GameMode
= GM_CTF
, 0, MaxLives
);
4397 gGameSettings
.Options
:= Options
;
4399 gCoopTotalMonstersKilled
:= 0;
4400 gCoopTotalSecretsFound
:= 0;
4401 gCoopTotalMonsters
:= 0;
4402 gCoopTotalSecrets
:= 0;
4406 g_Game_ExecuteEvent('ongamestart');
4408 // Óñòàíîâêà ðàçìåðîâ îêîí èãðîêîâ:
4409 g_Game_SetupScreenSize();
4411 // Ðåæèì íàáëþäàòåëÿ:
4412 if nPlayers
= 0 then
4419 if nPlayers
>= 1 then
4421 // Ñîçäàíèå ïåðâîãî èãðîêà:
4422 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4423 gPlayer1Settings
.Color
,
4424 gPlayer1Settings
.Team
, False));
4425 if gPlayer1
= nil then
4427 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
4431 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4435 if nPlayers
>= 2 then
4437 // Ñîçäàíèå âòîðîãî èãðîêà:
4438 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
4439 gPlayer2Settings
.Color
,
4440 gPlayer2Settings
.Team
, False));
4441 if gPlayer2
= nil then
4443 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
4447 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
4451 // Çàãðóçêà è çàïóñê êàðòû:
4452 if not g_Game_StartMap(true{asMegawad}, Map
, True) then
4454 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [Map
]));
4458 // Íåò òî÷åê ïîÿâëåíèÿ:
4459 if (g_Map_GetPointCount(RESPAWNPOINT_PLAYER1
) +
4460 g_Map_GetPointCount(RESPAWNPOINT_PLAYER2
) +
4461 g_Map_GetPointCount(RESPAWNPOINT_DM
) +
4462 g_Map_GetPointCount(RESPAWNPOINT_RED
)+
4463 g_Map_GetPointCount(RESPAWNPOINT_BLUE
)) < 1 then
4465 g_FatalError(_lc
[I_GAME_ERROR_GET_SPAWN
]);
4469 // Íàñòðîéêè èãðîêîâ è áîòîâ:
4473 for i
:= nPl
+1 to nPlayers
do
4474 g_Player_Create(STD_PLAYER_MODEL
, _RGB(0, 0, 0), 0, True);
4477 procedure g_Game_StartServer(Map
: String; GameMode
: Byte;
4478 TimeLimit
, GoalLimit
: Word; MaxLives
: Byte;
4479 Options
: LongWord; nPlayers
: Byte;
4480 IPAddr
: LongWord; Port
: Word);
4483 g_Net_Slist_ServerClosed();
4485 e_WriteLog('Starting net game (server)...', TMsgType
.Notify
);
4487 g_Game_ClearLoading();
4490 gGameSettings
.GameType
:= GT_SERVER
;
4491 gGameSettings
.GameMode
:= GameMode
;
4492 gSwitchGameMode
:= GameMode
;
4493 gGameSettings
.TimeLimit
:= TimeLimit
;
4494 gGameSettings
.GoalLimit
:= GoalLimit
;
4495 gGameSettings
.MaxLives
:= IfThen(GameMode
= GM_CTF
, 0, MaxLives
);
4496 gGameSettings
.Options
:= Options
;
4498 gCoopTotalMonstersKilled
:= 0;
4499 gCoopTotalSecretsFound
:= 0;
4500 gCoopTotalMonsters
:= 0;
4501 gCoopTotalSecrets
:= 0;
4505 g_Game_ExecuteEvent('ongamestart');
4507 // Óñòàíîâêà ðàçìåðîâ îêíà èãðîêà
4508 g_Game_SetupScreenSize();
4510 // Ðåæèì íàáëþäàòåëÿ:
4511 if nPlayers
= 0 then
4517 if nPlayers
>= 1 then
4519 // Ñîçäàíèå ïåðâîãî èãðîêà:
4520 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4521 gPlayer1Settings
.Color
,
4522 gPlayer1Settings
.Team
, False));
4523 if gPlayer1
= nil then
4525 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
4529 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4532 if nPlayers
>= 2 then
4534 // Ñîçäàíèå âòîðîãî èãðîêà:
4535 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
4536 gPlayer2Settings
.Color
,
4537 gPlayer2Settings
.Team
, False));
4538 if gPlayer2
= nil then
4540 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
4544 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
4547 g_Game_SetLoadingText(_lc
[I_LOAD_HOST
], 0, False);
4548 if NetForwardPorts
then
4549 g_Game_SetLoadingText(_lc
[I_LOAD_PORTS
], 0, False);
4552 if not g_Net_Host(IPAddr
, Port
, NetMaxClients
) then
4554 g_FatalError(_lc
[I_NET_MSG
] + _lc
[I_NET_ERR_HOST
]);
4558 g_Net_Slist_Set(NetSlistIP
, NetSlistPort
, NetSlistList
);
4560 g_Net_Slist_ServerStarted();
4562 // Çàãðóçêà è çàïóñê êàðòû:
4563 if not g_Game_StartMap(false{asMegawad}, Map
, True) then
4565 g_Net_Slist_ServerClosed();
4566 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [Map
]));
4570 // Íåò òî÷åê ïîÿâëåíèÿ:
4571 if (g_Map_GetPointCount(RESPAWNPOINT_PLAYER1
) +
4572 g_Map_GetPointCount(RESPAWNPOINT_PLAYER2
) +
4573 g_Map_GetPointCount(RESPAWNPOINT_DM
) +
4574 g_Map_GetPointCount(RESPAWNPOINT_RED
)+
4575 g_Map_GetPointCount(RESPAWNPOINT_BLUE
)) < 1 then
4577 g_Net_Slist_ServerClosed();
4578 g_FatalError(_lc
[I_GAME_ERROR_GET_SPAWN
]);
4582 // Íàñòðîéêè èãðîêîâ è áîòîâ:
4585 g_Net_Slist_ServerMapStarted();
4586 NetState
:= NET_STATE_GAME
;
4589 procedure g_Game_StartClient(Addr
: String; Port
: Word; PW
: String);
4604 e_WriteLog('Starting net game (client)...', TMsgType
.Notify
);
4605 e_WriteLog('NET: Trying to connect to ' + Addr
+ ':' + IntToStr(Port
) + '...', TMsgType
.Notify
);
4607 g_Game_ClearLoading();
4610 gGameSettings
.GameType
:= GT_CLIENT
;
4612 gCoopTotalMonstersKilled
:= 0;
4613 gCoopTotalSecretsFound
:= 0;
4614 gCoopTotalMonsters
:= 0;
4615 gCoopTotalSecrets
:= 0;
4619 g_Game_ExecuteEvent('ongamestart');
4621 // Óñòàíîâêà ðàçìåðîâ îêîí èãðîêîâ:
4622 g_Game_SetupScreenSize();
4624 NetState
:= NET_STATE_AUTH
;
4626 g_Game_SetLoadingText(_lc
[I_LOAD_CONNECT
], 0, False);
4628 // create (or update) map/resource databases
4629 g_Res_CreateDatabases(true);
4632 if not g_Net_Connect(Addr
, Port
) then
4634 g_FatalError(_lc
[I_NET_MSG
] + _lc
[I_NET_ERR_CONN
]);
4635 NetState
:= NET_STATE_NONE
;
4639 g_Game_SetLoadingText(_lc
[I_LOAD_SEND_INFO
], 0, False);
4641 g_Game_SetLoadingText(_lc
[I_LOAD_WAIT_INFO
], 0, False);
4646 // fuck! https://www.mail-archive.com/enet-discuss@cubik.org/msg00852.html
4647 // tl;dr: on shitdows, we can get -1 sometimes, and it is *NOT* a failure.
4648 // thank you, enet. let's ignore failures altogether then.
4649 while (enet_host_service(NetHost
, @NetEvent
, 50) > 0) do
4651 if (NetEvent
.kind
= ENET_EVENT_TYPE_RECEIVE
) then
4653 if (NetEvent
.channelID
= NET_CHAN_DOWNLOAD_EX
) then
4655 // ignore all download packets, they're processed by separate code
4656 enet_packet_destroy(NetEvent
.packet
);
4659 Ptr
:= NetEvent
.packet
^.data
;
4660 if not InMsg
.Init(Ptr
, NetEvent
.packet
^.dataLength
, True) then
4662 enet_packet_destroy(NetEvent
.packet
);
4666 InMsg
.ReadLongWord(); // skip size
4667 MID
:= InMsg
.ReadByte();
4669 if (MID
= NET_MSG_INFO
) and (State
= 0) then
4671 NetMyID
:= InMsg
.ReadByte();
4672 NetPlrUID1
:= InMsg
.ReadWord();
4674 WadName
:= InMsg
.ReadString();
4675 Map
:= InMsg
.ReadString();
4677 gWADHash
:= InMsg
.ReadMD5();
4679 gGameSettings
.GameMode
:= InMsg
.ReadByte();
4680 gSwitchGameMode
:= gGameSettings
.GameMode
;
4681 gGameSettings
.GoalLimit
:= InMsg
.ReadWord();
4682 gGameSettings
.TimeLimit
:= InMsg
.ReadWord();
4683 gGameSettings
.MaxLives
:= InMsg
.ReadByte();
4684 gGameSettings
.Options
:= InMsg
.ReadLongWord();
4685 T
:= InMsg
.ReadLongWord();
4687 //newResPath := g_Res_SearchSameWAD(MapsDir, WadName, gWADHash);
4688 //if newResPath = '' then
4690 //g_Game_SetLoadingText(_lc[I_LOAD_DL_RES], 0, False);
4691 newResPath
:= g_Res_DownloadMapWAD(ExtractFileName(WadName
), gWADHash
);
4692 if newResPath
= '' then
4694 g_FatalError(_lc
[I_NET_ERR_HASH
]);
4695 enet_packet_destroy(NetEvent
.packet
);
4696 NetState
:= NET_STATE_NONE
;
4699 e_LogWritefln('using downloaded map wad [%s] for [%s]`', [newResPath
, WadName
], TMsgType
.Notify
);
4701 //newResPath := ExtractRelativePath(MapsDir, newResPath);
4704 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4705 gPlayer1Settings
.Color
,
4706 gPlayer1Settings
.Team
, False));
4708 if gPlayer1
= nil then
4710 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
4712 enet_packet_destroy(NetEvent
.packet
);
4713 NetState
:= NET_STATE_NONE
;
4717 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4718 gPlayer1
.UID
:= NetPlrUID1
;
4719 gPlayer1
.Reset(True);
4721 if not g_Game_StartMap(false{asMegawad}, newResPath
+ ':\' + Map
, True) then
4723 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [WadName
+ ':\' + Map
]));
4725 enet_packet_destroy(NetEvent
.packet
);
4726 NetState
:= NET_STATE_NONE
;
4734 enet_packet_destroy(NetEvent
.packet
);
4738 enet_packet_destroy(NetEvent
.packet
);
4742 if (NetEvent
.kind
= ENET_EVENT_TYPE_DISCONNECT
) then
4745 if (NetEvent
.data
<= NET_DISC_MAX
) then
4746 g_Console_Add(_lc
[I_NET_MSG_ERROR
] + _lc
[I_NET_ERR_CONN
] + ' ' +
4747 _lc
[TStrings_Locale(Cardinal(I_NET_DISC_NONE
) + NetEvent
.data
)], True);
4754 ProcessLoading(true);
4756 if g_Net_UserRequestExit() then
4765 g_FatalError(_lc
[I_NET_MSG
] + _lc
[I_NET_ERR_CONN
]);
4766 NetState
:= NET_STATE_NONE
;
4770 gLMSRespawn
:= LMS_RESPAWN_NONE
;
4771 gLMSRespawnTime
:= 0;
4774 NetState
:= NET_STATE_GAME
;
4775 MC_SEND_FullStateRequest
;
4776 e_WriteLog('NET: Connection successful.', TMsgType
.Notify
);
4780 lastAsMegaWad
: Boolean = false;
4782 procedure g_Game_ChangeMap(const MapPath
: String);
4786 g_Game_ClearLoading();
4788 Force
:= gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
];
4789 // Åñëè óðîâåíü çàâåðøèëñÿ ïî òðèããåðó Âûõîä, íå î÷èùàòü èíâåíòàðü
4790 if gExitByTrigger
then
4793 gExitByTrigger
:= False;
4795 if not g_Game_StartMap(lastAsMegaWad
, MapPath
, Force
) then
4796 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [MapPath
]));
4799 procedure g_Game_Restart();
4803 if g_Game_IsClient
then
4805 map
:= g_ExtractFileName(gMapInfo
.Map
);
4806 e_LogWritefln('g_Game_Restart: map = "%s" gCurrentMapFileName = "%s"', [map
, gCurrentMapFileName
]);
4810 g_Game_ClearLoading();
4811 g_Game_StartMap(lastAsMegaWad
, Map
, True, gCurrentMapFileName
);
4814 function g_Game_StartMap (asMegawad
: Boolean; Map
: String; Force
: Boolean = False; const oldMapPath
: AnsiString=''): Boolean;
4816 NewWAD
, ResName
: String;
4820 g_Map_Free((Map
<> gCurrentMapFileName
) and (oldMapPath
<> gCurrentMapFileName
));
4821 g_Player_RemoveAllCorpses();
4823 if (not g_Game_IsClient
) and
4824 (gSwitchGameMode
<> gGameSettings
.GameMode
) and
4825 (gGameSettings
.GameMode
<> GM_SINGLE
) then
4827 if gSwitchGameMode
= GM_CTF
then
4828 gGameSettings
.MaxLives
:= 0;
4829 gGameSettings
.GameMode
:= gSwitchGameMode
;
4832 gSwitchGameMode
:= gGameSettings
.GameMode
;
4834 g_Player_ResetTeams();
4836 lastAsMegaWad
:= asMegawad
;
4837 if isWadPath(Map
) then
4839 NewWAD
:= g_ExtractWadName(Map
);
4840 ResName
:= g_ExtractFileName(Map
);
4841 if g_Game_IsServer
then
4843 nws
:= findDiskWad(NewWAD
);
4844 //writeln('000: Map=[', Map, ']; nws=[', nws, ']; NewWAD=[', NewWAD, ']');
4847 if (length(nws
) = 0) then nws
:= e_FindWad(MegawadDirs
, NewWAD
);
4848 if (length(nws
) = 0) then nws
:= e_FindWad(MapDirs
, NewWAD
);
4852 if (length(nws
) = 0) then nws
:= e_FindWad(MapDirs
, NewWAD
);
4853 if (length(nws
) = 0) then nws
:= e_FindWad(MegawadDirs
, NewWAD
);
4855 //if (length(nws) = 0) then nws := e_FindWad(MapDownloadDirs, NewWAD);
4856 //writeln('001: Map=[', Map, ']; nws=[', nws, ']; NewWAD=[', NewWAD, ']');
4858 if (length(nws
) = 0) then
4860 ResName
:= ''; // failed
4865 if (g_Game_IsNet
) then gWADHash
:= MD5File(nws
);
4866 //writeln('********: nws=', nws, ' : Map=', Map, ' : nw=', NewWAD, ' : resname=', ResName);
4867 g_Game_LoadWAD(NewWAD
);
4872 // hash received in MC_RECV_GameEvent -> NET_EV_MAPSTART
4873 NewWAD
:= g_Game_ClientWAD(NewWAD
, gWADHash
);
4878 NewWAD
:= gGameSettings
.WAD
;
4882 //writeln('********: gsw=', gGameSettings.WAD, '; rn=', ResName);
4884 if (ResName
<> '') and (NewWAD
<> '') then
4886 //result := g_Map_Load(gGameSettings.WAD + ':\' + ResName);
4887 result
:= g_Map_Load(NewWAD
+':\'+ResName
);
4891 g_Player_ResetAll(Force
or gLastMap
, gGameSettings
.GameType
= GT_SINGLE
);
4893 gState
:= STATE_NONE
;
4894 g_ActiveWindow
:= nil;
4900 if gGameSettings
.GameMode
= GM_CTF
then
4902 g_Map_ResetFlag(FLAG_RED
);
4903 g_Map_ResetFlag(FLAG_BLUE
);
4904 // CTF, à ôëàãîâ íåò:
4905 if not g_Map_HaveFlagPoints() then
4906 g_SimpleError(_lc
[I_GAME_ERROR_CTF
]);
4911 gState
:= STATE_MENU
;
4916 gPauseMain
:= false;
4917 gPauseHolmes
:= false;
4919 NetTimeToUpdate
:= 1;
4920 NetTimeToReliable
:= 0;
4921 NetTimeToMaster
:= NetMasterRate
;
4922 gLMSRespawn
:= LMS_RESPAWN_NONE
;
4923 gLMSRespawnTime
:= 0;
4924 gMissionFailed
:= False;
4927 gCoopMonstersKilled
:= 0;
4928 gCoopSecretsFound
:= 0;
4930 gVoteInProgress
:= False;
4931 gVotePassed
:= False;
4937 if not gGameOn
then Exit
;
4939 g_Game_SpectateCenterView();
4941 if (gGameSettings
.MaxLives
> 0) and (gGameSettings
.WarmupTime
> 0) then
4943 gLMSRespawn
:= LMS_RESPAWN_WARMUP
;
4944 gLMSRespawnTime
:= gTime
+ gGameSettings
.WarmupTime
*1000;
4945 gLMSSoftSpawn
:= True;
4946 if NetMode
= NET_SERVER
then
4947 MH_SEND_GameEvent(NET_EV_LMS_WARMUP
, (gLMSRespawnTime
- gTime
) div 1000)
4949 g_Console_Add(Format(_lc
[I_MSG_WARMUP_START
], [(gLMSRespawnTime
- gTime
) div 1000]), True);
4952 if NetMode
= NET_SERVER
then
4954 MH_SEND_GameEvent(NET_EV_MAPSTART
, gGameSettings
.GameMode
, Map
);
4957 g_Net_Slist_ServerMapStarted();
4959 if NetClients
<> nil then
4960 for I
:= 0 to High(NetClients
) do
4961 if NetClients
[I
].Used
then
4963 NetClients
[I
].Voted
:= False;
4964 if NetClients
[I
].RequestedFullUpdate
then
4966 MH_SEND_Everything((NetClients
[I
].State
= NET_STATE_AUTH
), I
);
4967 NetClients
[I
].RequestedFullUpdate
:= False;
4971 g_Net_UnbanNonPermHosts();
4976 gCoopTotalMonstersKilled
:= 0;
4977 gCoopTotalSecretsFound
:= 0;
4978 gCoopTotalMonsters
:= 0;
4979 gCoopTotalSecrets
:= 0;
4983 g_Game_ExecuteEvent('onmapstart');
4986 procedure SetFirstLevel
;
4990 MapList
:= g_Map_GetMapsList(gGameSettings
.WAD
);
4991 if MapList
= nil then
4994 SortSArray(MapList
);
4995 gNextMap
:= MapList
[Low(MapList
)];
5000 procedure g_Game_ExitLevel(const Map
: AnsiString);
5004 gCoopTotalMonstersKilled
:= gCoopTotalMonstersKilled
+ gCoopMonstersKilled
;
5005 gCoopTotalSecretsFound
:= gCoopTotalSecretsFound
+ gCoopSecretsFound
;
5006 gCoopTotalMonsters
:= gCoopTotalMonsters
+ gTotalMonsters
;
5007 gCoopTotalSecrets
:= gCoopTotalSecrets
+ gSecretsCount
;
5009 // Âûøëè â âûõîä â Îäèíî÷íîé èãðå:
5010 if gGameSettings
.GameType
= GT_SINGLE
then
5011 gExit
:= EXIT_ENDLEVELSINGLE
5012 else // Âûøëè â âûõîä â Ñâîåé èãðå
5014 gExit
:= EXIT_ENDLEVELCUSTOM
;
5015 if gGameSettings
.GameMode
= GM_COOP
then
5016 g_Player_RememberAll
;
5018 if not g_Map_Exist(gGameSettings
.WAD
+ ':\' + gNextMap
) then
5021 if gGameSettings
.GameMode
= GM_COOP
then
5024 gStatsPressed
:= True;
5025 gNextMap
:= 'MAP01';
5027 if not g_Map_Exist(gGameSettings
.WAD
+ ':\' + gNextMap
) then
5030 if g_Game_IsNet
then
5032 MH_SEND_GameStats();
5033 MH_SEND_CoopStats();
5039 procedure g_Game_RestartLevel();
5043 if gGameSettings
.GameMode
= GM_SINGLE
then
5048 gExit
:= EXIT_ENDLEVELCUSTOM
;
5049 Map
:= g_ExtractFileName(gMapInfo
.Map
);
5053 function g_Game_ClientWAD (NewWAD
: String; const WHash
: TMD5Digest
): AnsiString;
5055 gWAD
{, xwad}: String;
5058 if not g_Game_IsClient
then Exit
;
5059 //e_LogWritefln('*** g_Game_ClientWAD: `%s`', [NewWAD]);
5061 gWAD
:= g_Res_DownloadMapWAD(ExtractFileName(NewWAD
), WHash
);
5066 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_WAD
], [ExtractFileName(NewWAD
)]));
5070 e_LogWritefln('using downloaded client map wad [%s] for [%s]', [gWAD
, NewWAD
], TMsgType
.Notify
);
5073 g_Game_LoadWAD(NewWAD
);
5077 if LowerCase(NewWAD) = LowerCase(gGameSettings.WAD) then Exit;
5078 gWAD := g_Res_SearchSameWAD(MapsDir, ExtractFileName(NewWAD), WHash);
5081 g_Game_SetLoadingText(_lc[I_LOAD_DL_RES], 0, False);
5082 gWAD := g_Res_DownloadMapWAD(ExtractFileName(NewWAD), WHash);
5086 g_FatalError(Format(_lc[I_GAME_ERROR_MAP_WAD], [ExtractFileName(NewWAD)]));
5090 NewWAD := ExtractRelativePath(MapsDir, gWAD);
5091 g_Game_LoadWAD(NewWAD);
5095 procedure g_Game_RestartRound(NoMapRestart
: Boolean = False);
5097 i
, n
, nb
, nr
: Integer;
5099 function monRespawn (mon
: TMonster
): Boolean;
5101 result
:= false; // don't stop
5102 if not mon
.FNoRespawn
then mon
.Respawn();
5106 if not g_Game_IsServer
then Exit
;
5107 if gLMSRespawn
= LMS_RESPAWN_NONE
then Exit
;
5108 gLMSRespawn
:= LMS_RESPAWN_NONE
;
5109 gLMSRespawnTime
:= 0;
5112 if (gGameSettings
.GameMode
= GM_COOP
) and not NoMapRestart
then
5114 gMissionFailed
:= True;
5115 g_Game_RestartLevel
;
5119 n
:= 0; nb
:= 0; nr
:= 0;
5120 for i
:= Low(gPlayers
) to High(gPlayers
) do
5121 if (gPlayers
[i
] <> nil) and
5122 ((not gPlayers
[i
].FSpectator
) or gPlayers
[i
].FWantsInGame
or
5123 (gPlayers
[i
] is TBot
)) then
5126 if gPlayers
[i
].Team
= TEAM_RED
then Inc(nr
)
5127 else if gPlayers
[i
].Team
= TEAM_BLUE
then Inc(nb
)
5130 if (n
< 2) or ((gGameSettings
.GameMode
= GM_TDM
) and ((nr
= 0) or (nb
= 0))) then
5132 // wait a second until the fuckers finally decide to join
5133 gLMSRespawn
:= LMS_RESPAWN_WARMUP
;
5134 gLMSRespawnTime
:= gTime
+ 1000;
5135 gLMSSoftSpawn
:= NoMapRestart
;
5139 g_Player_RemoveAllCorpses
;
5140 g_Game_Message(_lc
[I_MESSAGE_LMS_START
], 144);
5141 if g_Game_IsNet
then
5142 MH_SEND_GameEvent(NET_EV_LMS_START
);
5144 for i
:= Low(gPlayers
) to High(gPlayers
) do
5146 if gPlayers
[i
] = nil then continue
;
5147 if gPlayers
[i
] is TBot
then gPlayers
[i
].FWantsInGame
:= True;
5148 // don't touch normal spectators
5149 if gPlayers
[i
].FSpectator
and not gPlayers
[i
].FWantsInGame
then
5151 gPlayers
[i
].FNoRespawn
:= True;
5152 gPlayers
[i
].Lives
:= 0;
5153 if g_Game_IsNet
then
5154 MH_SEND_PlayerStats(gPlayers
[I
].UID
);
5157 gPlayers
[i
].FNoRespawn
:= False;
5158 gPlayers
[i
].Lives
:= gGameSettings
.MaxLives
;
5159 gPlayers
[i
].Respawn(False, True);
5160 if gGameSettings
.GameMode
= GM_COOP
then
5162 gPlayers
[i
].Frags
:= 0;
5163 gPlayers
[i
].RecallState
;
5165 if (gPlayer1
= nil) and (gLMSPID1
> 0) then
5166 gPlayer1
:= g_Player_Get(gLMSPID1
);
5167 if (gPlayer2
= nil) and (gLMSPID2
> 0) then
5168 gPlayer2
:= g_Player_Get(gLMSPID2
);
5171 g_Items_RestartRound();
5174 g_Mons_ForEach(monRespawn
);
5176 gLMSSoftSpawn
:= False;
5179 function g_Game_GetFirstMap(WAD
: String): String;
5183 MapList
:= g_Map_GetMapsList(WAD
);
5184 if MapList
= nil then
5187 SortSArray(MapList
);
5188 Result
:= MapList
[Low(MapList
)];
5190 if not g_Map_Exist(WAD
+ ':\' + Result
) then
5196 function g_Game_GetNextMap(): String;
5203 MapList
:= g_Map_GetMapsList(gGameSettings
.WAD
);
5204 if MapList
= nil then
5207 Map
:= g_ExtractFileName(gMapInfo
.Map
);
5209 SortSArray(MapList
);
5211 for I
:= Low(MapList
) to High(MapList
) do
5212 if Map
= MapList
[I
] then
5218 if MapIndex
<> -255 then
5220 if MapIndex
= High(MapList
) then
5221 Result
:= MapList
[Low(MapList
)]
5223 Result
:= MapList
[MapIndex
+ 1];
5225 if not g_Map_Exist(gGameSettings
.WAD
+ ':\' + Result
) then Result
:= Map
;
5231 procedure g_Game_NextLevel();
5233 if gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
, GM_COOP
] then
5234 gExit
:= EXIT_ENDLEVELCUSTOM
5237 gExit
:= EXIT_ENDLEVELSINGLE
;
5241 if gNextMap
<> '' then Exit
;
5242 gNextMap
:= g_Game_GetNextMap();
5245 function g_Game_IsTestMap(): Boolean;
5247 result
:= StrEquCI1251(TEST_MAP_NAME
, g_ExtractFileName(gMapInfo
.Map
));
5250 procedure g_Game_DeleteTestMap();
5253 //MapName: AnsiString;
5261 a
:= Pos('.wad:\', toLowerCase1251(gMapToDelete
));
5262 if (a
= 0) then a
:= Pos('.wad:/', toLowerCase1251(gMapToDelete
));
5263 if (a
= 0) then exit
;
5265 // Âûäåëÿåì èìÿ wad-ôàéëà è èìÿ êàðòû
5266 WadName
:= Copy(gMapToDelete
, 1, a
+3);
5267 Delete(gMapToDelete
, 1, a
+5);
5268 gMapToDelete
:= UpperCase(gMapToDelete
);
5270 //CopyMemory(@MapName[0], @gMapToDelete[1], Min(16, Length(gMapToDelete)));
5273 // Èìÿ êàðòû íå ñòàíäàðòíîå òåñòîâîå:
5274 if MapName <> TEST_MAP_NAME then
5277 if not gTempDelete then
5279 time := g_GetFileTime(WadName);
5280 WAD := TWADFile.Create();
5283 if not WAD.ReadFile(WadName) then
5284 begin // Íåò òàêîãî WAD-ôàéëà
5289 // Ñîñòàâëÿåì ñïèñîê êàðò è èùåì íóæíóþ:
5291 MapList := WAD.GetResourcesList('');
5293 if MapList <> nil then
5294 for a := 0 to High(MapList) do
5295 if MapList[a] = MapName then
5297 // Óäàëÿåì è ñîõðàíÿåì:
5298 WAD.RemoveResource('', MapName);
5299 WAD.SaveTo(WadName);
5304 g_SetFileTime(WadName, time);
5307 if gTempDelete
then DeleteFile(WadName
);
5310 procedure GameCVars(P
: SSArray
);
5313 stat
: TPlayerStatArray
;
5318 cmd
:= LowerCase(P
[0]);
5319 if (cmd
= 'g_friendlyfire') and not g_Game_IsClient
then
5321 with gGameSettings
do
5323 if (Length(P
) > 1) and
5324 ((P
[1] = '1') or (P
[1] = '0')) then
5326 if (P
[1][1] = '1') then
5327 Options
:= Options
or GAME_OPTION_TEAMDAMAGE
5329 Options
:= Options
and (not GAME_OPTION_TEAMDAMAGE
);
5332 if (LongBool(Options
and GAME_OPTION_TEAMDAMAGE
)) then
5333 g_Console_Add(_lc
[I_MSG_FRIENDLY_FIRE_ON
])
5335 g_Console_Add(_lc
[I_MSG_FRIENDLY_FIRE_OFF
]);
5337 if g_Game_IsNet
then MH_SEND_GameSettings
;
5340 else if (cmd
= 'g_weaponstay') and not g_Game_IsClient
then
5342 with gGameSettings
do
5344 if (Length(P
) > 1) and
5345 ((P
[1] = '1') or (P
[1] = '0')) then
5347 if (P
[1][1] = '1') then
5348 Options
:= Options
or GAME_OPTION_WEAPONSTAY
5350 Options
:= Options
and (not GAME_OPTION_WEAPONSTAY
);
5353 if (LongBool(Options
and GAME_OPTION_WEAPONSTAY
)) then
5354 g_Console_Add(_lc
[I_MSG_WEAPONSTAY_ON
])
5356 g_Console_Add(_lc
[I_MSG_WEAPONSTAY_OFF
]);
5358 if g_Game_IsNet
then MH_SEND_GameSettings
;
5361 else if cmd
= 'g_gamemode' then
5363 a
:= g_Game_TextToMode(P
[1]);
5364 if a
= GM_SINGLE
then a
:= GM_COOP
;
5365 if (Length(P
) > 1) and (a
<> GM_NONE
) and (not g_Game_IsClient
) then
5367 gSwitchGameMode
:= a
;
5368 if (gGameOn
and (gGameSettings
.GameMode
= GM_SINGLE
)) or
5369 (gState
= STATE_INTERSINGLE
) then
5370 gSwitchGameMode
:= GM_SINGLE
;
5372 gGameSettings
.GameMode
:= gSwitchGameMode
;
5374 if gSwitchGameMode
= gGameSettings
.GameMode
then
5375 g_Console_Add(Format(_lc
[I_MSG_GAMEMODE_CURRENT
],
5376 [g_Game_ModeToText(gGameSettings
.GameMode
)]))
5378 g_Console_Add(Format(_lc
[I_MSG_GAMEMODE_CHANGE
],
5379 [g_Game_ModeToText(gGameSettings
.GameMode
),
5380 g_Game_ModeToText(gSwitchGameMode
)]));
5382 else if (cmd
= 'g_allow_exit') and not g_Game_IsClient
then
5384 with gGameSettings
do
5386 if (Length(P
) > 1) and
5387 ((P
[1] = '1') or (P
[1] = '0')) then
5389 if (P
[1][1] = '1') then
5390 Options
:= Options
or GAME_OPTION_ALLOWEXIT
5392 Options
:= Options
and (not GAME_OPTION_ALLOWEXIT
);
5395 if (LongBool(Options
and GAME_OPTION_ALLOWEXIT
)) then
5396 g_Console_Add(_lc
[I_MSG_ALLOWEXIT_ON
])
5398 g_Console_Add(_lc
[I_MSG_ALLOWEXIT_OFF
]);
5399 g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
5401 if g_Game_IsNet
then MH_SEND_GameSettings
;
5404 else if (cmd
= 'g_allow_monsters') and not g_Game_IsClient
then
5406 with gGameSettings
do
5408 if (Length(P
) > 1) and
5409 ((P
[1] = '1') or (P
[1] = '0')) then
5411 if (P
[1][1] = '1') then
5412 Options
:= Options
or GAME_OPTION_MONSTERS
5414 Options
:= Options
and (not GAME_OPTION_MONSTERS
);
5417 if (LongBool(Options
and GAME_OPTION_MONSTERS
)) then
5418 g_Console_Add(_lc
[I_MSG_ALLOWMON_ON
])
5420 g_Console_Add(_lc
[I_MSG_ALLOWMON_OFF
]);
5421 g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
5423 if g_Game_IsNet
then MH_SEND_GameSettings
;
5426 else if (cmd
= 'g_bot_vsplayers') and not g_Game_IsClient
then
5428 with gGameSettings
do
5430 if (Length(P
) > 1) and
5431 ((P
[1] = '1') or (P
[1] = '0')) then
5433 if (P
[1][1] = '1') then
5434 Options
:= Options
or GAME_OPTION_BOTVSPLAYER
5436 Options
:= Options
and (not GAME_OPTION_BOTVSPLAYER
);
5439 if (LongBool(Options
and GAME_OPTION_BOTVSPLAYER
)) then
5440 g_Console_Add(_lc
[I_MSG_BOTSVSPLAYERS_ON
])
5442 g_Console_Add(_lc
[I_MSG_BOTSVSPLAYERS_OFF
]);
5444 if g_Game_IsNet
then MH_SEND_GameSettings
;
5447 else if (cmd
= 'g_bot_vsmonsters') and not g_Game_IsClient
then
5449 with gGameSettings
do
5451 if (Length(P
) > 1) and
5452 ((P
[1] = '1') or (P
[1] = '0')) then
5454 if (P
[1][1] = '1') then
5455 Options
:= Options
or GAME_OPTION_BOTVSMONSTER
5457 Options
:= Options
and (not GAME_OPTION_BOTVSMONSTER
);
5460 if (LongBool(Options
and GAME_OPTION_BOTVSMONSTER
)) then
5461 g_Console_Add(_lc
[I_MSG_BOTSVSMONSTERS_ON
])
5463 g_Console_Add(_lc
[I_MSG_BOTSVSMONSTERS_OFF
]);
5465 if g_Game_IsNet
then MH_SEND_GameSettings
;
5468 else if (cmd
= 'g_warmuptime') and not g_Game_IsClient
then
5470 if Length(P
) > 1 then
5472 if StrToIntDef(P
[1], gGameSettings
.WarmupTime
) = 0 then
5473 gGameSettings
.WarmupTime
:= 30
5475 gGameSettings
.WarmupTime
:= StrToIntDef(P
[1], gGameSettings
.WarmupTime
);
5478 g_Console_Add(Format(_lc
[I_MSG_WARMUP
],
5479 [gGameSettings
.WarmupTime
]));
5480 g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
5482 else if cmd
= 'net_interp' then
5484 if (Length(P
) > 1) then
5485 NetInterpLevel
:= StrToIntDef(P
[1], NetInterpLevel
);
5486 g_Console_Add('net_interp = ' + IntToStr(NetInterpLevel
));
5487 s
:= e_GetWriteableDir(ConfigDirs
);
5490 config
:= TConfig
.CreateFile(s
+ '/' + CONFIG_FILENAME
);
5491 config
.WriteInt('Client', 'InterpolationSteps', NetInterpLevel
);
5492 config
.SaveFile(s
+ '/' + CONFIG_FILENAME
);
5496 else if cmd
= 'net_forceplayerupdate' then
5498 if (Length(P
) > 1) and ((P
[1] = '1') or (P
[1] = '0')) then
5499 NetForcePlayerUpdate
:= (P
[1][1] = '1');
5501 if NetForcePlayerUpdate
then
5502 g_Console_Add('net_forceplayerupdate = 1')
5504 g_Console_Add('net_forceplayerupdate = 0');
5506 s
:= e_GetWriteableDir(ConfigDirs
);
5509 config
:= TConfig
.CreateFile(s
+ '/' + CONFIG_FILENAME
);
5510 config
.WriteBool('Client', 'ForcePlayerUpdate', NetForcePlayerUpdate
);
5511 config
.SaveFile(s
+ '/' + CONFIG_FILENAME
);
5515 else if cmd
= 'net_predictself' then
5517 if (Length(P
) > 1) and
5518 ((P
[1] = '1') or (P
[1] = '0')) then
5519 NetPredictSelf
:= (P
[1][1] = '1');
5521 if NetPredictSelf
then
5522 g_Console_Add('net_predictself = 1')
5524 g_Console_Add('net_predictself = 0');
5526 s
:= e_GetWriteableDir(ConfigDirs
);
5529 config
:= TConfig
.CreateFile(s
+ '/' + CONFIG_FILENAME
);
5530 config
.WriteBool('Client', 'PredictSelf', NetPredictSelf
);
5531 config
.SaveFile(s
+ '/' + CONFIG_FILENAME
);
5535 else if cmd
= 'sv_name' then
5537 if (Length(P
) > 1) and (Length(P
[1]) > 0) then
5539 NetServerName
:= P
[1];
5540 if Length(NetServerName
) > 64 then
5541 SetLength(NetServerName
, 64);
5542 g_Net_Slist_ServerRenamed();
5545 g_Console_Add(cmd
+ ' = "' + NetServerName
+ '"');
5547 else if cmd
= 'sv_passwd' then
5549 if (Length(P
) > 1) and (Length(P
[1]) > 0) then
5551 NetPassword
:= P
[1];
5552 if Length(NetPassword
) > 24 then
5553 SetLength(NetPassword
, 24);
5554 g_Net_Slist_ServerRenamed();
5557 g_Console_Add(cmd
+ ' = "' + AnsiLowerCase(NetPassword
) + '"');
5559 else if cmd
= 'sv_maxplrs' then
5561 if (Length(P
) > 1) then
5563 NetMaxClients
:= Min(Max(StrToIntDef(P
[1], NetMaxClients
), 1), NET_MAXCLIENTS
);
5564 if g_Game_IsServer
and g_Game_IsNet
then
5567 for a
:= 0 to High(NetClients
) do
5569 if NetClients
[a
].Used
then
5572 if b
> NetMaxClients
then
5574 s
:= g_Player_Get(NetClients
[a
].Player
).Name
;
5575 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_FULL
);
5576 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
5577 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
5581 g_Net_Slist_ServerRenamed();
5585 g_Console_Add(cmd
+ ' = ' + IntToStr(NetMaxClients
));
5587 else if cmd
= 'sv_public' then
5589 if (Length(P
) > 1) then
5591 NetUseMaster
:= StrToIntDef(P
[1], Byte(NetUseMaster
)) > 0;
5592 if NetUseMaster
then g_Net_Slist_Public() else g_Net_Slist_Private();
5595 g_Console_Add(cmd
+ ' = ' + IntToStr(Byte(NetUseMaster
)));
5597 else if cmd
= 'sv_intertime' then
5599 if (Length(P
) > 1) then
5600 gDefInterTime
:= Min(Max(StrToIntDef(P
[1], gDefInterTime
), -1), 120);
5602 g_Console_Add(cmd
+ ' = ' + IntToStr(gDefInterTime
));
5604 else if cmd
= 'p1_name' then
5606 if (Length(P
) > 1) and gGameOn
then
5608 if g_Game_IsClient
then
5610 gPlayer1Settings
.Name
:= b_Text_Unformat(P
[1]);
5611 MC_SEND_PlayerSettings
;
5614 if gPlayer1
<> nil then
5616 gPlayer1
.Name
:= b_Text_Unformat(P
[1]);
5617 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer1
.UID
);
5620 gPlayer1Settings
.Name
:= b_Text_Unformat(P
[1]);
5623 else if cmd
= 'p2_name' then
5625 if (Length(P
) > 1) and gGameOn
then
5627 if g_Game_IsClient
then
5629 gPlayer2Settings
.Name
:= b_Text_Unformat(P
[1]);
5630 MC_SEND_PlayerSettings
;
5633 if gPlayer2
<> nil then
5635 gPlayer2
.Name
:= b_Text_Unformat(P
[1]);
5636 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer2
.UID
);
5639 gPlayer2Settings
.Name
:= b_Text_Unformat(P
[1]);
5642 else if cmd
= 'p1_color' then
5644 if Length(P
) > 3 then
5645 if g_Game_IsClient
then
5647 gPlayer1Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
5648 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
5649 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
5650 MC_SEND_PlayerSettings
;
5653 if gPlayer1
<> nil then
5655 gPlayer1
.Model
.SetColor(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
5656 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
5657 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
5658 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer1
.UID
);
5661 gPlayer1Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
5662 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
5663 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
5665 else if (cmd
= 'p2_color') and not g_Game_IsNet
then
5667 if Length(P
) > 3 then
5668 if g_Game_IsClient
then
5670 gPlayer2Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
5671 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
5672 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
5673 MC_SEND_PlayerSettings
;
5676 if gPlayer2
<> nil then
5678 gPlayer2
.Model
.SetColor(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
5679 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
5680 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
5681 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer2
.UID
);
5684 gPlayer2Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
5685 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
5686 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
5688 else if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
5690 if cmd
= 'r_showscore' then
5692 if (Length(P
) > 1) and
5693 ((P
[1] = '1') or (P
[1] = '0')) then
5694 gShowGoals
:= (P
[1][1] = '1');
5697 g_Console_Add(_lc
[I_MSG_SCORE_ON
])
5699 g_Console_Add(_lc
[I_MSG_SCORE_OFF
]);
5701 else if cmd
= 'r_showstat' then
5703 if (Length(P
) > 1) and
5704 ((P
[1] = '1') or (P
[1] = '0')) then
5705 gShowStat
:= (P
[1][1] = '1');
5708 g_Console_Add(_lc
[I_MSG_STATS_ON
])
5710 g_Console_Add(_lc
[I_MSG_STATS_OFF
]);
5712 else if cmd
= 'r_showkillmsg' then
5714 if (Length(P
) > 1) and
5715 ((P
[1] = '1') or (P
[1] = '0')) then
5716 gShowKillMsg
:= (P
[1][1] = '1');
5718 if gShowKillMsg
then
5719 g_Console_Add(_lc
[I_MSG_KILL_MSGS_ON
])
5721 g_Console_Add(_lc
[I_MSG_KILL_MSGS_OFF
]);
5723 else if cmd
= 'r_showlives' then
5725 if (Length(P
) > 1) and
5726 ((P
[1] = '1') or (P
[1] = '0')) then
5727 gShowLives
:= (P
[1][1] = '1');
5730 g_Console_Add(_lc
[I_MSG_LIVES_ON
])
5732 g_Console_Add(_lc
[I_MSG_LIVES_OFF
]);
5734 else if cmd
= 'r_showspect' then
5736 if (Length(P
) > 1) and
5737 ((P
[1] = '1') or (P
[1] = '0')) then
5738 gSpectHUD
:= (P
[1][1] = '1');
5741 g_Console_Add(_lc
[I_MSG_SPECT_HUD_ON
])
5743 g_Console_Add(_lc
[I_MSG_SPECT_HUD_OFF
]);
5745 else if cmd
= 'r_showping' then
5747 if (Length(P
) > 1) and
5748 ((P
[1] = '1') or (P
[1] = '0')) then
5749 gShowPing
:= (P
[1][1] = '1');
5752 g_Console_Add(_lc
[I_MSG_PING_ON
])
5754 g_Console_Add(_lc
[I_MSG_PING_OFF
]);
5756 else if (cmd
= 'g_scorelimit') and not g_Game_IsClient
then
5758 if Length(P
) > 1 then
5760 if StrToIntDef(P
[1], gGameSettings
.GoalLimit
) = 0 then
5761 gGameSettings
.GoalLimit
:= 0
5766 if gGameSettings
.GameMode
= GM_DM
then
5768 stat
:= g_Player_GetStats();
5770 for a
:= 0 to High(stat
) do
5771 if stat
[a
].Frags
> b
then
5775 b
:= Max(gTeamStat
[TEAM_RED
].Goals
, gTeamStat
[TEAM_BLUE
].Goals
);
5777 gGameSettings
.GoalLimit
:= Max(StrToIntDef(P
[1], gGameSettings
.GoalLimit
), b
);
5780 if g_Game_IsNet
then MH_SEND_GameSettings
;
5783 g_Console_Add(Format(_lc
[I_MSG_SCORE_LIMIT
], [gGameSettings
.GoalLimit
]));
5785 else if (cmd
= 'g_timelimit') and not g_Game_IsClient
then
5787 if (Length(P
) > 1) and (StrToIntDef(P
[1], -1) >= 0) then
5788 gGameSettings
.TimeLimit
:= StrToIntDef(P
[1], -1);
5790 g_Console_Add(Format(_lc
[I_MSG_TIME_LIMIT
],
5791 [gGameSettings
.TimeLimit
div 3600,
5792 (gGameSettings
.TimeLimit
div 60) mod 60,
5793 gGameSettings
.TimeLimit
mod 60]));
5794 if g_Game_IsNet
then MH_SEND_GameSettings
;
5796 else if (cmd
= 'g_maxlives') and not g_Game_IsClient
then
5798 if Length(P
) > 1 then
5800 if StrToIntDef(P
[1], gGameSettings
.MaxLives
) = 0 then
5801 gGameSettings
.MaxLives
:= 0
5805 stat
:= g_Player_GetStats();
5807 for a
:= 0 to High(stat
) do
5808 if stat
[a
].Lives
> b
then
5810 gGameSettings
.MaxLives
:=
5811 Max(StrToIntDef(P
[1], gGameSettings
.MaxLives
), b
);
5815 g_Console_Add(Format(_lc
[I_MSG_LIVES
],
5816 [gGameSettings
.MaxLives
]));
5817 if g_Game_IsNet
then MH_SEND_GameSettings
;
5822 procedure PrintHeapStats();
5826 hs
:= GetFPCHeapStatus();
5827 e_LogWriteLn ('v===== heap status =====v');
5828 e_LogWriteFln('max heap size = %d k', [hs
.MaxHeapSize
div 1024]);
5829 e_LogWriteFln('max heap used = %d k', [hs
.MaxHeapUsed
div 1024]);
5830 e_LogWriteFln('cur heap size = %d k', [hs
.CurrHeapSize
div 1024]);
5831 e_LogWriteFln('cur heap used = %d k', [hs
.CurrHeapUsed
div 1024]);
5832 e_LogWriteFln('cur heap free = %d k', [hs
.CurrHeapFree
div 1024]);
5833 e_LogWriteLn ('^=======================^');
5836 procedure DebugCommands(P
: SSArray
);
5843 // Êîìàíäû îòëàäî÷íîãî ðåæèìà:
5844 if {gDebugMode}conIsCheatsEnabled
then
5846 cmd
:= LowerCase(P
[0]);
5847 if cmd
= 'd_window' then
5849 g_Console_Add(Format('gScreenWidth = %d, gScreenHeight = %d', [gScreenWidth
, gScreenHeight
]));
5850 g_Console_Add(Format('gWinSizeX = %d, gWinSizeY = %d', [gWinSizeX
, gWinSizeY
]));
5852 else if cmd
= 'd_sounds' then
5854 if (Length(P
) > 1) and
5855 ((P
[1] = '1') or (P
[1] = '0')) then
5856 g_Debug_Sounds
:= (P
[1][1] = '1');
5858 g_Console_Add(Format('d_sounds is %d', [Byte(g_Debug_Sounds
)]));
5860 else if cmd
= 'd_frames' then
5862 if (Length(P
) > 1) and
5863 ((P
[1] = '1') or (P
[1] = '0')) then
5864 g_Debug_Frames
:= (P
[1][1] = '1');
5866 g_Console_Add(Format('d_frames is %d', [Byte(g_Debug_Frames
)]));
5868 else if cmd
= 'd_winmsg' then
5870 if (Length(P
) > 1) and
5871 ((P
[1] = '1') or (P
[1] = '0')) then
5872 g_Debug_WinMsgs
:= (P
[1][1] = '1');
5874 g_Console_Add(Format('d_winmsg is %d', [Byte(g_Debug_WinMsgs
)]));
5876 else if (cmd
= 'd_monoff') and not g_Game_IsNet
then
5878 if (Length(P
) > 1) and
5879 ((P
[1] = '1') or (P
[1] = '0')) then
5880 g_Debug_MonsterOff
:= (P
[1][1] = '1');
5882 g_Console_Add(Format('d_monoff is %d', [Byte(g_debug_MonsterOff
)]));
5884 else if (cmd
= 'd_botoff') and not g_Game_IsNet
then
5886 if Length(P
) > 1 then
5888 '0': g_debug_BotAIOff
:= 0;
5889 '1': g_debug_BotAIOff
:= 1;
5890 '2': g_debug_BotAIOff
:= 2;
5891 '3': g_debug_BotAIOff
:= 3;
5894 g_Console_Add(Format('d_botoff is %d', [g_debug_BotAIOff
]));
5896 else if cmd
= 'd_monster' then
5898 if gGameOn
and (gPlayer1
<> nil) and (gPlayer1
.alive
) and (not g_Game_IsNet
) then
5899 if Length(P
) < 2 then
5901 g_Console_Add(cmd
+ ' [ID | Name] [behaviour]');
5902 g_Console_Add('ID | Name');
5903 for b
:= MONSTER_DEMON
to MONSTER_MAN
do
5904 g_Console_Add(Format('%2d | %s', [b
, g_Mons_NameByTypeId(b
)]));
5905 conwriteln('behav. num'#10'normal 0'#10'killer 1'#10'maniac 2'#10'insane 3'#10'cannibal 4'#10'good 5');
5908 a
:= StrToIntDef(P
[1], 0);
5909 if (a
< MONSTER_DEMON
) or (a
> MONSTER_MAN
) then
5910 a
:= g_Mons_TypeIdByName(P
[1]);
5912 if (a
< MONSTER_DEMON
) or (a
> MONSTER_MAN
) then
5913 g_Console_Add(Format(_lc
[I_MSG_NO_MONSTER
], [P
[1]]))
5916 with gPlayer1
.Obj
do
5918 mon
:= g_Monsters_Create(a
,
5919 X
+ Rect
.X
+ (Rect
.Width
div 2),
5920 Y
+ Rect
.Y
+ Rect
.Height
,
5921 gPlayer1
.Direction
, True);
5923 if (Length(P
) > 2) and (mon
<> nil) then
5925 if (CompareText(P
[2], 'normal') = 0) then mon
.MonsterBehaviour
:= BH_NORMAL
5926 else if (CompareText(P
[2], 'killer') = 0) then mon
.MonsterBehaviour
:= BH_KILLER
5927 else if (CompareText(P
[2], 'maniac') = 0) then mon
.MonsterBehaviour
:= BH_MANIAC
5928 else if (CompareText(P
[2], 'insane') = 0) then mon
.MonsterBehaviour
:= BH_INSANE
5929 else if (CompareText(P
[2], 'cannibal') = 0) then mon
.MonsterBehaviour
:= BH_CANNIBAL
5930 else if (CompareText(P
[2], 'good') = 0) then mon
.MonsterBehaviour
:= BH_GOOD
5931 else if (CompareText(P
[2], 'friend') = 0) then mon
.MonsterBehaviour
:= BH_GOOD
5932 else if (CompareText(P
[2], 'friendly') = 0) then mon
.MonsterBehaviour
:= BH_GOOD
5933 else mon
.MonsterBehaviour
:= Min(Max(StrToIntDef(P
[2], BH_NORMAL
), BH_NORMAL
), BH_GOOD
);
5938 else if (cmd
= 'd_health') then
5940 if (Length(P
) > 1) and
5941 ((P
[1] = '1') or (P
[1] = '0')) then
5942 g_debug_HealthBar
:= (P
[1][1] = '1');
5944 g_Console_Add(Format('d_health is %d', [Byte(g_debug_HealthBar
)]));
5946 else if (cmd
= 'd_player') then
5948 if (Length(P
) > 1) and
5949 ((P
[1] = '1') or (P
[1] = '0')) then
5950 g_debug_Player
:= (P
[1][1] = '1');
5952 g_Console_Add(Format(cmd
+ ' is %d', [Byte(g_Debug_Player
)]));
5954 else if (cmd
= 'd_mem') then
5960 g_Console_Add(_lc
[I_MSG_NOT_DEBUG
]);
5964 procedure GameCheats(P
: SSArray
);
5970 if (not gGameOn
) or (not conIsCheatsEnabled
) then
5972 g_Console_Add('not available');
5978 g_Console_Add('where is the player?!');
5981 cmd
:= LowerCase(P
[0]);
5985 plr
.GodMode
:= not plr
.GodMode
;
5986 if plr
.GodMode
then g_Console_Add('player is godlike now') else g_Console_Add('player is mortal now');
5989 // give <health|exit|weapons|air|suit|jetpack|berserk|all>
5990 if cmd
= 'give' then
5992 if length(P
) < 2 then begin g_Console_Add('give what?!'); exit
; end;
5993 for f
:= 1 to High(P
) do
5995 cmd
:= LowerCase(P
[f
]);
5996 if cmd
= 'health' then begin plr
.RestoreHealthArmor(); g_Console_Add('player feels himself better'); continue
; end;
5997 if (cmd
= 'all') {or (cmd = 'weapons')} then begin plr
.AllRulez(False); g_Console_Add('player got the gifts'); continue
; end;
5998 if cmd
= 'exit' then
6000 if gTriggers
<> nil then
6002 for a
:= 0 to High(gTriggers
) do
6004 if gTriggers
[a
].TriggerType
= TRIGGER_EXIT
then
6006 g_Console_Add('player left the map');
6007 gExitByTrigger
:= True;
6008 //g_Game_ExitLevel(gTriggers[a].Data.MapName);
6009 g_Game_ExitLevel(gTriggers
[a
].tgcMap
);
6017 if cmd
= 'air' then begin plr
.GiveItem(ITEM_OXYGEN
); g_Console_Add('player got some air'); continue
; end;
6018 if cmd
= 'jetpack' then begin plr
.GiveItem(ITEM_JETPACK
); g_Console_Add('player got a jetpack'); continue
; end;
6019 if cmd
= 'suit' then begin plr
.GiveItem(ITEM_SUIT
); g_Console_Add('player got an envirosuit'); continue
; end;
6020 if cmd
= 'berserk' then begin plr
.GiveItem(ITEM_MEDKIT_BLACK
); g_Console_Add('player got a berserk pack'); continue
; end;
6021 if cmd
= 'backpack' then begin plr
.GiveItem(ITEM_AMMO_BACKPACK
); g_Console_Add('player got a backpack'); continue
; end;
6023 if cmd
= 'helmet' then begin plr
.GiveItem(ITEM_HELMET
); g_Console_Add('player got a helmet'); continue
; end;
6024 if cmd
= 'bottle' then begin plr
.GiveItem(ITEM_BOTTLE
); g_Console_Add('player got a bottle of health'); continue
; end;
6026 if cmd
= 'stimpack' then begin plr
.GiveItem(ITEM_MEDKIT_SMALL
); g_Console_Add('player got a stimpack'); continue
; end;
6027 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;
6029 if cmd
= 'greenarmor' then begin plr
.GiveItem(ITEM_ARMOR_GREEN
); g_Console_Add('player got a security armor'); continue
; end;
6030 if cmd
= 'bluearmor' then begin plr
.GiveItem(ITEM_ARMOR_BLUE
); g_Console_Add('player got a combat armor'); continue
; end;
6032 if (cmd
= 'megasphere') or (cmd
= 'mega') then begin plr
.GiveItem(ITEM_SPHERE_BLUE
); g_Console_Add('player got a megasphere'); continue
; end;
6033 if (cmd
= 'soulsphere') or (cmd
= 'soul')then begin plr
.GiveItem(ITEM_SPHERE_WHITE
); g_Console_Add('player got a soul sphere'); continue
; end;
6035 if (cmd
= 'invul') or (cmd
= 'invulnerability') then begin plr
.GiveItem(ITEM_INVUL
); g_Console_Add('player got invulnerability'); continue
; end;
6036 if (cmd
= 'invis') or (cmd
= 'invisibility') then begin plr
.GiveItem(ITEM_INVIS
); g_Console_Add('player got invisibility'); continue
; end;
6038 if cmd
= 'redkey' then begin plr
.GiveItem(ITEM_KEY_RED
); g_Console_Add('player got the red key'); continue
; end;
6039 if cmd
= 'greenkey' then begin plr
.GiveItem(ITEM_KEY_GREEN
); g_Console_Add('player got the green key'); continue
; end;
6040 if cmd
= 'bluekey' then begin plr
.GiveItem(ITEM_KEY_BLUE
); g_Console_Add('player got the blue key'); continue
; end;
6042 if (cmd
= 'shotgun') or (cmd
= 'sg') then begin plr
.GiveItem(ITEM_WEAPON_SHOTGUN1
); g_Console_Add('player got a shotgun'); continue
; end;
6043 if (cmd
= 'supershotgun') or (cmd
= 'ssg') then begin plr
.GiveItem(ITEM_WEAPON_SHOTGUN2
); g_Console_Add('player got a supershotgun'); continue
; end;
6044 if cmd
= 'chaingun' then begin plr
.GiveItem(ITEM_WEAPON_CHAINGUN
); g_Console_Add('player got a chaingun'); continue
; end;
6045 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;
6046 if cmd
= 'plasmagun' then begin plr
.GiveItem(ITEM_WEAPON_PLASMA
); g_Console_Add('player got a plasma gun'); continue
; end;
6047 if cmd
= 'bfg' then begin plr
.GiveItem(ITEM_WEAPON_BFG
); g_Console_Add('player got a BFG-9000'); continue
; end;
6049 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;
6050 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;
6051 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;
6052 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;
6053 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;
6054 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;
6056 if cmd
= 'superchaingun' then begin plr
.GiveItem(ITEM_WEAPON_SUPERPULEMET
); g_Console_Add('player got a superchaingun'); continue
; end;
6057 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;
6059 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;
6060 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;
6062 if cmd
= 'chainsaw' then begin plr
.GiveItem(ITEM_WEAPON_SAW
); g_Console_Add('player got a chainsaw'); continue
; end;
6064 if cmd
= 'ammo' then
6066 plr
.GiveItem(ITEM_AMMO_SHELLS_BOX
);
6067 plr
.GiveItem(ITEM_AMMO_BULLETS_BOX
);
6068 plr
.GiveItem(ITEM_AMMO_CELL_BIG
);
6069 plr
.GiveItem(ITEM_AMMO_ROCKET_BOX
);
6070 plr
.GiveItem(ITEM_AMMO_FUELCAN
);
6071 g_Console_Add('player got some ammo');
6075 if cmd
= 'clip' then begin plr
.GiveItem(ITEM_AMMO_BULLETS
); g_Console_Add('player got some bullets'); continue
; end;
6076 if cmd
= 'bullets' then begin plr
.GiveItem(ITEM_AMMO_BULLETS_BOX
); g_Console_Add('player got a box of bullets'); continue
; end;
6078 if cmd
= 'shells' then begin plr
.GiveItem(ITEM_AMMO_SHELLS
); g_Console_Add('player got some shells'); continue
; end;
6079 if cmd
= 'shellbox' then begin plr
.GiveItem(ITEM_AMMO_SHELLS_BOX
); g_Console_Add('player got a box of shells'); continue
; end;
6081 if cmd
= 'cells' then begin plr
.GiveItem(ITEM_AMMO_CELL
); g_Console_Add('player got some cells'); continue
; end;
6082 if cmd
= 'battery' then begin plr
.GiveItem(ITEM_AMMO_CELL_BIG
); g_Console_Add('player got cell battery'); continue
; end;
6084 if cmd
= 'rocket' then begin plr
.GiveItem(ITEM_AMMO_ROCKET
); g_Console_Add('player got a rocket'); continue
; end;
6085 if cmd
= 'rocketbox' then begin plr
.GiveItem(ITEM_AMMO_ROCKET_BOX
); g_Console_Add('player got some rockets'); continue
; end;
6087 if (cmd
= 'fuel') or (cmd
= 'fuelcan') then begin plr
.GiveItem(ITEM_AMMO_FUELCAN
); g_Console_Add('player got fuel canister'); continue
; end;
6089 if cmd
= 'weapons' then
6091 plr
.GiveItem(ITEM_WEAPON_SHOTGUN1
);
6092 plr
.GiveItem(ITEM_WEAPON_SHOTGUN2
);
6093 plr
.GiveItem(ITEM_WEAPON_CHAINGUN
);
6094 plr
.GiveItem(ITEM_WEAPON_ROCKETLAUNCHER
);
6095 plr
.GiveItem(ITEM_WEAPON_PLASMA
);
6096 plr
.GiveItem(ITEM_WEAPON_BFG
);
6097 g_Console_Add('player got weapons');
6101 if cmd
= 'keys' then
6103 plr
.GiveItem(ITEM_KEY_RED
);
6104 plr
.GiveItem(ITEM_KEY_GREEN
);
6105 plr
.GiveItem(ITEM_KEY_BLUE
);
6106 g_Console_Add('player got all keys');
6110 g_Console_Add('i don''t know how to give '''+cmd
+'''!');
6115 if cmd
= 'open' then
6117 g_Console_Add('player activated sesame');
6118 g_Triggers_OpenAll();
6125 if gFly
then g_Console_Add('player feels himself lighter') else g_Console_Add('player lost his wings');
6129 if cmd
= 'noclip' then
6132 g_Console_Add('wall hardeness adjusted');
6136 if cmd
= 'notarget' then
6138 plr
.NoTarget
:= not plr
.NoTarget
;
6139 if plr
.NoTarget
then g_Console_Add('player hides in shadows') else g_Console_Add('player is brave again');
6143 if cmd
= 'noreload' then
6145 plr
.NoReload
:= not plr
.NoReload
;
6146 if plr
.NoReload
then g_Console_Add('player is action hero now') else g_Console_Add('player is ordinary man now');
6150 if cmd
= 'speedy' then
6152 MAX_RUNVEL
:= 32-MAX_RUNVEL
;
6153 g_Console_Add('speed adjusted');
6157 if cmd
= 'jumpy' then
6159 VEL_JUMP
:= 30-VEL_JUMP
;
6160 g_Console_Add('jump height adjusted');
6164 if cmd
= 'automap' then
6166 gShowMap
:= not gShowMap
;
6167 if gShowMap
then g_Console_Add('player gains second sight') else g_Console_Add('player lost second sight');
6171 if cmd
= 'aimline' then
6173 gAimLine
:= not gAimLine
;
6174 if gAimLine
then g_Console_Add('player gains laser sight') else g_Console_Add('player lost laser sight');
6179 procedure GameCommands(P
: SSArray
);
6185 pl
: pTNetClient
= nil;
6193 cmd
:= LowerCase(P
[0]);
6195 if (cmd
= 'quit') or
6202 else if cmd
= 'pause' then
6204 if (g_ActiveWindow
= nil) then
6205 g_Game_Pause(not gPauseMain
);
6207 else if cmd
= 'endgame' then
6208 gExit
:= EXIT_SIMPLE
6209 else if cmd
= 'restart' then
6211 if gGameOn
or (gState
in [STATE_INTERSINGLE
, STATE_INTERCUSTOM
]) then
6213 if g_Game_IsClient
then
6215 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6220 g_Console_Add(_lc
[I_MSG_NOT_GAME
]);
6222 else if cmd
= 'kick' then
6224 if g_Game_IsServer
then
6226 if Length(P
) < 2 then
6228 g_Console_Add('kick <name>');
6233 g_Console_Add('kick <name>');
6237 if g_Game_IsNet
then
6238 pl
:= g_Net_Client_ByName(P
[1]);
6241 s
:= g_Net_ClientName_ByID(pl
^.ID
);
6242 enet_peer_disconnect(pl
^.Peer
, NET_DISC_KICK
);
6243 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
6244 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
6245 g_Net_Slist_ServerPlayerLeaves();
6246 end else if gPlayers
<> nil then
6247 for a
:= Low(gPlayers
) to High(gPlayers
) do
6248 if gPlayers
[a
] <> nil then
6249 if Copy(LowerCase(gPlayers
[a
].Name
), 1, Length(P
[1])) = LowerCase(P
[1]) then
6251 // Íå îòêëþ÷àòü îñíîâíûõ èãðîêîâ â ñèíãëå
6252 if not(gPlayers
[a
] is TBot
) and (gGameSettings
.GameType
= GT_SINGLE
) then
6254 gPlayers
[a
].Lives
:= 0;
6255 gPlayers
[a
].Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
6256 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [gPlayers
[a
].Name
]), True);
6257 g_Player_Remove(gPlayers
[a
].UID
);
6258 g_Net_Slist_ServerPlayerLeaves();
6259 // Åñëè íå ïåðåìåøàòü, ïðè äîáàâëåíèè íîâûõ áîòîâ ïîÿâÿòñÿ ñòàðûå
6263 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6265 else if cmd
= 'kick_id' then
6267 if g_Game_IsServer
and g_Game_IsNet
then
6269 if Length(P
) < 2 then
6271 g_Console_Add('kick_id <client ID>');
6276 g_Console_Add('kick_id <client ID>');
6280 a
:= StrToIntDef(P
[1], 0);
6281 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
6283 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
6285 s
:= g_Net_ClientName_ByID(NetClients
[a
].ID
);
6286 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_KICK
);
6287 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
6288 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
6289 g_Net_Slist_ServerPlayerLeaves();
6293 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6295 else if cmd
= 'ban' then
6297 if g_Game_IsServer
and g_Game_IsNet
then
6299 if Length(P
) < 2 then
6301 g_Console_Add('ban <name>');
6306 g_Console_Add('ban <name>');
6310 pl
:= g_Net_Client_ByName(P
[1]);
6313 s
:= g_Net_ClientName_ByID(pl
^.ID
);
6314 g_Net_BanHost(pl
^.Peer
^.address
.host
, False);
6315 enet_peer_disconnect(pl
^.Peer
, NET_DISC_TEMPBAN
);
6316 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
6317 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
6318 g_Net_Slist_ServerPlayerLeaves();
6320 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
6322 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6324 else if cmd
= 'ban_id' then
6326 if g_Game_IsServer
and g_Game_IsNet
then
6328 if Length(P
) < 2 then
6330 g_Console_Add('ban_id <client ID>');
6335 g_Console_Add('ban_id <client ID>');
6339 a
:= StrToIntDef(P
[1], 0);
6340 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
6341 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
6343 s
:= g_Net_ClientName_ByID(NetClients
[a
].ID
);
6344 g_Net_BanHost(NetClients
[a
].Peer
^.address
.host
, False);
6345 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_TEMPBAN
);
6346 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
6347 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
6348 g_Net_Slist_ServerPlayerLeaves();
6351 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6353 else if cmd
= 'permban' then
6355 if g_Game_IsServer
and g_Game_IsNet
then
6357 if Length(P
) < 2 then
6359 g_Console_Add('permban <name>');
6364 g_Console_Add('permban <name>');
6368 pl
:= g_Net_Client_ByName(P
[1]);
6371 s
:= g_Net_ClientName_ByID(pl
^.ID
);
6372 g_Net_BanHost(pl
^.Peer
^.address
.host
);
6373 enet_peer_disconnect(pl
^.Peer
, NET_DISC_BAN
);
6374 g_Net_SaveBanList();
6375 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
6376 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
6377 g_Net_Slist_ServerPlayerLeaves();
6379 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
6381 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6383 else if cmd
= 'permban_id' then
6385 if g_Game_IsServer
and g_Game_IsNet
then
6387 if Length(P
) < 2 then
6389 g_Console_Add('permban_id <client ID>');
6394 g_Console_Add('permban_id <client ID>');
6398 a
:= StrToIntDef(P
[1], 0);
6399 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
6400 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
6402 s
:= g_Net_ClientName_ByID(NetClients
[a
].ID
);
6403 g_Net_BanHost(NetClients
[a
].Peer
^.address
.host
);
6404 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_BAN
);
6405 g_Net_SaveBanList();
6406 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
6407 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
6408 g_Net_Slist_ServerPlayerLeaves();
6411 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6413 else if cmd
= 'unban' then
6415 if g_Game_IsServer
and g_Game_IsNet
then
6417 if Length(P
) < 2 then
6419 g_Console_Add('unban <IP Address>');
6424 g_Console_Add('unban <IP Address>');
6428 if g_Net_UnbanHost(P
[1]) then
6430 g_Console_Add(Format(_lc
[I_MSG_UNBAN_OK
], [P
[1]]));
6431 g_Net_SaveBanList();
6433 g_Console_Add(Format(_lc
[I_MSG_UNBAN_FAIL
], [P
[1]]));
6435 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6437 else if cmd
= 'clientlist' then
6439 if g_Game_IsServer
and g_Game_IsNet
then
6442 if NetClients
<> nil then
6443 for a
:= Low(NetClients
) to High(NetClients
) do
6444 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
6446 plr
:= g_Player_Get(NetClients
[a
].Player
);
6447 if plr
= nil then continue
;
6449 g_Console_Add(Format('#%2d: %-15s | %s', [a
,
6450 IpToStr(NetClients
[a
].Peer
^.address
.host
), plr
.Name
]));
6453 g_Console_Add(_lc
[I_MSG_NOCLIENTS
]);
6455 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6457 else if cmd
= 'connect' then
6459 if (NetMode
= NET_NONE
) then
6461 if Length(P
) < 2 then
6463 g_Console_Add('connect <IP> [port] [password]');
6468 g_Console_Add('connect <IP> [port] [password]');
6472 if Length(P
) > 2 then
6473 prt
:= StrToIntDef(P
[2], 25666)
6477 if Length(P
) > 3 then
6482 g_Game_StartClient(P
[1], prt
, pw
);
6485 else if cmd
= 'disconnect' then
6487 if (NetMode
= NET_CLIENT
) then
6490 else if cmd
= 'reconnect' then
6492 if (NetMode
= NET_SERVER
) then
6495 if (NetMode
= NET_CLIENT
) then
6498 gExit
:= EXIT_SIMPLE
;
6502 //TODO: Use last successful password to reconnect, instead of ''
6503 g_Game_StartClient(NetClientIP
, NetClientPort
, '');
6505 else if (cmd
= 'addbot') or
6506 (cmd
= 'bot_add') then
6508 if Length(P
) > 2 then
6509 g_Bot_Add(TEAM_NONE
, StrToIntDef(P
[1], 2), StrToIntDef(P
[2], 100))
6510 else if Length(P
) > 1 then
6511 g_Bot_Add(TEAM_NONE
, StrToIntDef(P
[1], 2))
6513 g_Bot_Add(TEAM_NONE
, 2);
6515 else if cmd
= 'bot_addlist' then
6517 if Length(P
) > 1 then
6519 if Length(P
) = 2 then
6520 g_Bot_AddList(TEAM_NONE
, P
[1], StrToIntDef(P
[1], -1))
6521 else if Length(P
) = 3 then
6522 g_Bot_AddList(TEAM_NONE
, P
[1], StrToIntDef(P
[1], -1), StrToIntDef(P
[2], 100))
6524 g_Bot_AddList(IfThen(P
[2] = 'red', TEAM_RED
, TEAM_BLUE
), P
[1], StrToIntDef(P
[1], -1));
6527 else if cmd
= 'bot_removeall' then
6529 else if cmd
= 'chat' then
6531 if g_Game_IsNet
then
6533 if Length(P
) > 1 then
6535 for a
:= 1 to High(P
) do
6536 chstr
:= chstr
+ P
[a
] + ' ';
6538 if Length(chstr
) > 200 then SetLength(chstr
, 200);
6540 if Length(chstr
) < 1 then
6542 g_Console_Add('chat <text>');
6546 chstr
:= b_Text_Format(chstr
);
6547 if g_Game_IsClient
then
6548 MC_SEND_Chat(chstr
, NET_CHAT_PLAYER
)
6550 MH_SEND_Chat(gPlayer1Settings
.Name
+ ': ' + chstr
, NET_CHAT_PLAYER
);
6553 g_Console_Add('chat <text>');
6555 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6557 else if cmd
= 'teamchat' then
6559 if g_Game_IsNet
and (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
6561 if Length(P
) > 1 then
6563 for a
:= 1 to High(P
) do
6564 chstr
:= chstr
+ P
[a
] + ' ';
6566 if Length(chstr
) > 200 then SetLength(chstr
, 200);
6568 if Length(chstr
) < 1 then
6570 g_Console_Add('teamchat <text>');
6574 chstr
:= b_Text_Format(chstr
);
6575 if g_Game_IsClient
then
6576 MC_SEND_Chat(chstr
, NET_CHAT_TEAM
)
6578 MH_SEND_Chat(gPlayer1Settings
.Name
+ ': ' + chstr
, NET_CHAT_TEAM
,
6579 gPlayer1Settings
.Team
);
6582 g_Console_Add('teamchat <text>');
6584 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6586 else if cmd
= 'game' then
6588 if gGameSettings
.GameType
<> GT_NONE
then
6590 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6593 if Length(P
) = 1 then
6595 g_Console_Add(cmd
+ ' <WAD> [MAP] [# players]');
6598 // game not started yet, load fist map from some wad
6600 s
:= addWadExtension(P
[1]);
6601 found
:= e_FindResource(AllMapDirs
, s
);
6605 P
[1] := ExpandFileName(P
[1]);
6606 // if map not choosed then set first map
6607 if Length(P
) < 3 then
6610 P
[2] := g_Game_GetFirstMap(P
[1]);
6613 s
:= P
[1] + ':\' + UpperCase(P
[2]);
6615 if g_Map_Exist(s
) then
6619 with gGameSettings
do
6621 GameMode
:= g_Game_TextToMode(gcGameMode
);
6622 if gSwitchGameMode
<> GM_NONE
then
6623 GameMode
:= gSwitchGameMode
;
6624 if GameMode
= GM_NONE
then GameMode
:= GM_DM
;
6625 if GameMode
= GM_SINGLE
then GameMode
:= GM_COOP
;
6627 if Length(P
) >= 4 then
6628 b
:= StrToIntDef(P
[3], 1);
6629 g_Game_StartCustom(s
, GameMode
, TimeLimit
,
6630 GoalLimit
, MaxLives
, Options
, b
);
6635 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
6637 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [UpperCase(P
[2]), P
[1]]));
6639 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]));
6641 else if cmd
= 'host' then
6643 if gGameSettings
.GameType
<> GT_NONE
then
6645 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6648 if Length(P
) < 4 then
6650 g_Console_Add(cmd
+ ' <listen IP> <port> <WAD> [MAP] [# players]');
6653 if not StrToIp(P
[1], listen
) then
6655 prt
:= StrToIntDef(P
[2], 25666);
6657 s
:= addWadExtension(P
[3]);
6658 found
:= e_FindResource(AllMapDirs
, s
);
6662 // get first map in wad, if not specified
6663 if Length(P
) < 5 then
6666 P
[4] := g_Game_GetFirstMap(P
[1]);
6668 s
:= P
[3] + ':\' + UpperCase(P
[4]);
6669 if g_Map_Exist(s
) then
6673 with gGameSettings
do
6675 GameMode
:= g_Game_TextToMode(gcGameMode
);
6676 if gSwitchGameMode
<> GM_NONE
then GameMode
:= gSwitchGameMode
;
6677 if GameMode
= GM_NONE
then GameMode
:= GM_DM
;
6678 if GameMode
= GM_SINGLE
then GameMode
:= GM_COOP
;
6680 if Length(P
) >= 6 then
6681 b
:= StrToIntDef(P
[5], 0);
6682 g_Game_StartServer(s
, GameMode
, TimeLimit
, GoalLimit
, MaxLives
, Options
, b
, listen
, prt
)
6688 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[3]]))
6690 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [UpperCase(P
[4]), P
[3]]))
6695 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[3]]))
6698 else if cmd
= 'map' then
6700 if Length(P
) = 1 then
6702 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
6704 g_Console_Add(cmd
+ ' <MAP>');
6705 g_Console_Add(cmd
+ ' <WAD> [MAP]')
6709 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
])
6714 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
6716 if Length(P
) < 3 then
6718 // first param is map or wad
6719 s
:= UpperCase(P
[1]);
6720 if g_Map_Exist(gGameSettings
.WAD
+ ':\' + s
) then
6722 gExitByTrigger
:= False;
6725 // already in game, finish current map
6727 gExit
:= EXIT_ENDLEVELCUSTOM
;
6731 // intermission, so change map immediately
6738 found
:= e_FindResource(AllMapDirs
, s
);
6740 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [s
, 'WAD ' + P
[1]]));
6743 // no such map, found wad
6746 P
[1] := ExpandFileName(pw
);
6747 P
[2] := g_Game_GetFirstMap(P
[1]);
6748 s
:= P
[1] + ':\' + P
[2];
6749 if g_Map_Exist(s
) then
6751 gExitByTrigger
:= False;
6754 // already in game, finish current map
6756 gExit
:= EXIT_ENDLEVELCUSTOM
6760 // intermission, so change map immediately
6767 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
6769 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]))
6774 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]))
6780 s
:= addWadExtension(P
[1]);
6781 found
:= e_FindResource(AllMapDirs
, s
);
6785 P
[2] := UpperCase(P
[2]);
6786 s
:= P
[1] + ':\' + P
[2];
6787 if g_Map_Exist(s
) then
6789 gExitByTrigger
:= False;
6793 gExit
:= EXIT_ENDLEVELCUSTOM
6802 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]))
6807 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]))
6813 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
])
6817 else if cmd
= 'nextmap' then
6819 if not(gGameOn
or (gState
= STATE_INTERCUSTOM
)) then
6821 g_Console_Add(_lc
[I_MSG_NOT_GAME
])
6826 if Length(P
) = 1 then
6828 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
6830 g_Console_Add(cmd
+ ' <MAP>');
6831 g_Console_Add(cmd
+ ' <WAD> [MAP]');
6836 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6842 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
6844 if Length(P
) < 3 then
6846 // first param is map or wad
6847 s
:= UpperCase(P
[1]);
6848 if g_Map_Exist(gGameSettings
.WAD
+ ':\' + s
) then
6851 gExitByTrigger
:= False;
6857 // no such map, found wad
6858 pw
:= addWadExtension(P
[1]);
6859 found
:= e_FindResource(MapDirs
, pw
);
6861 found
:= e_FindResource(WadDirs
, pw
);
6863 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [s
, P
[1]]));
6866 // map not specified, select first map
6868 P
[2] := g_Game_GetFirstMap(P
[1]);
6869 s
:= P
[1] + ':\' + P
[2];
6870 if g_Map_Exist(s
) then
6872 gExitByTrigger
:= False;
6879 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
6881 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]))
6886 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]))
6892 // specified two params wad + map
6893 pw
:= addWadExtension(P
[1]);
6894 found
:= e_FindResource(MapDirs
, pw
);
6896 found
:= e_FindResource(MapDirs
, pw
);
6900 P
[2] := UpperCase(P
[2]);
6901 s
:= P
[1] + ':\' + P
[2];
6902 if g_Map_Exist(s
) then
6904 gExitByTrigger
:= False;
6910 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]))
6915 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]))
6921 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
])
6926 if gNextMap
= '' then
6927 g_Console_Add(_lc
[I_MSG_NEXTMAP_UNSET
])
6929 g_Console_Add(Format(_lc
[I_MSG_NEXTMAP_SET
], [gNextMap
]))
6933 else if (cmd
= 'endmap') or (cmd
= 'goodbye') then
6937 g_Console_Add(_lc
[I_MSG_NOT_GAME
])
6941 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
6943 gExitByTrigger
:= False;
6944 // next map not specified, try to find trigger EXIT
6945 if (gNextMap
= '') and (gTriggers
<> nil) then
6947 for a
:= 0 to High(gTriggers
) do
6949 if gTriggers
[a
].TriggerType
= TRIGGER_EXIT
then
6951 gExitByTrigger
:= True;
6952 //gNextMap := gTriggers[a].Data.MapName;
6953 gNextMap
:= gTriggers
[a
].tgcMap
;
6958 if gNextMap
= '' then
6959 gNextMap
:= g_Game_GetNextMap();
6960 if not isWadPath(gNextMap
) then
6961 s
:= gGameSettings
.WAD
+ ':\' + gNextMap
6964 if g_Map_Exist(s
) then
6965 gExit
:= EXIT_ENDLEVELCUSTOM
6967 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [gNextMap
]))
6971 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
])
6975 else if (cmd
= 'event') then
6977 if (Length(P
) <= 1) then
6979 for a
:= 0 to High(gEvents
) do
6980 if gEvents
[a
].Command
= '' then
6981 g_Console_Add(gEvents
[a
].Name
+ ' <none>')
6983 g_Console_Add(gEvents
[a
].Name
+ ' "' + gEvents
[a
].Command
+ '"');
6986 if (Length(P
) = 2) then
6988 for a
:= 0 to High(gEvents
) do
6989 if gEvents
[a
].Name
= P
[1] then
6990 if gEvents
[a
].Command
= '' then
6991 g_Console_Add(gEvents
[a
].Name
+ ' <none>')
6993 g_Console_Add(gEvents
[a
].Name
+ ' "' + gEvents
[a
].Command
+ '"');
6996 for a
:= 0 to High(gEvents
) do
6997 if gEvents
[a
].Name
= P
[1] then
6999 gEvents
[a
].Command
:= '';
7000 for b
:= 2 to High(P
) do
7001 if Pos(' ', P
[b
]) = 0 then
7002 gEvents
[a
].Command
:= gEvents
[a
].Command
+ ' ' + P
[b
]
7004 gEvents
[a
].Command
:= gEvents
[a
].Command
+ ' "' + P
[b
] + '"';
7005 gEvents
[a
].Command
:= Trim(gEvents
[a
].Command
);
7009 else if cmd
= 'suicide' then
7013 if g_Game_IsClient
then
7014 MC_SEND_CheatRequest(NET_CHEAT_SUICIDE
)
7017 if gPlayer1
<> nil then
7018 gPlayer1
.Damage(SUICIDE_DAMAGE
, gPlayer1
.UID
, 0, 0, HIT_SELF
);
7019 if gPlayer2
<> nil then
7020 gPlayer2
.Damage(SUICIDE_DAMAGE
, gPlayer2
.UID
, 0, 0, HIT_SELF
);
7024 else if cmd
= 'screenshot' then
7028 else if cmd
= 'weapon' then
7030 if Length(p
) = 2 then
7032 a
:= WP_FIRST
+ StrToInt(p
[1]) - 1;
7033 if (a
>= WP_FIRST
) and (a
<= WP_LAST
) then
7034 gSelectWeapon
[0, a
] := True
7037 else if (cmd
= 'p1_weapon') or (cmd
= 'p2_weapon') then
7039 if Length(p
) = 2 then
7041 a
:= WP_FIRST
+ StrToInt(p
[1]) - 1;
7042 b
:= ord(cmd
[2]) - ord('1');
7043 if (a
>= WP_FIRST
) and (a
<= WP_LAST
) then
7044 gSelectWeapon
[b
, a
] := True
7047 // Êîìàíäû Ñâîåé èãðû:
7048 else if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
7050 if cmd
= 'bot_addred' then
7052 if Length(P
) > 1 then
7053 g_Bot_Add(TEAM_RED
, StrToIntDef(P
[1], 2))
7055 g_Bot_Add(TEAM_RED
, 2);
7057 else if cmd
= 'bot_addblue' then
7059 if Length(P
) > 1 then
7060 g_Bot_Add(TEAM_BLUE
, StrToIntDef(P
[1], 2))
7062 g_Bot_Add(TEAM_BLUE
, 2);
7064 else if cmd
= 'spectate' then
7070 else if cmd
= 'say' then
7072 if g_Game_IsServer
and g_Game_IsNet
then
7074 if Length(P
) > 1 then
7077 for a
:= 1 to High(P
) do
7078 chstr
:= chstr
+ P
[a
] + ' ';
7080 if Length(chstr
) > 200 then SetLength(chstr
, 200);
7082 if Length(chstr
) < 1 then
7084 g_Console_Add('say <text>');
7088 chstr
:= b_Text_Format(chstr
);
7089 MH_SEND_Chat(chstr
, NET_CHAT_PLAYER
);
7091 else g_Console_Add('say <text>');
7093 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
7095 else if cmd
= 'tell' then
7097 if g_Game_IsServer
and g_Game_IsNet
then
7099 if (Length(P
) > 2) and (P
[1] <> '') then
7102 for a
:= 2 to High(P
) do
7103 chstr
:= chstr
+ P
[a
] + ' ';
7105 if Length(chstr
) > 200 then SetLength(chstr
, 200);
7107 if Length(chstr
) < 1 then
7109 g_Console_Add('tell <playername> <text>');
7113 pl
:= g_Net_Client_ByName(P
[1]);
7115 MH_SEND_Chat(b_Text_Format(chstr
), NET_CHAT_PLAYER
, pl
^.ID
)
7117 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
7119 else g_Console_Add('tell <playername> <text>');
7121 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
7123 else if (cmd
= 'overtime') and not g_Game_IsClient
then
7125 if (Length(P
) = 1) or (StrToIntDef(P
[1], -1) <= 0) then
7127 // Äîïîëíèòåëüíîå âðåìÿ:
7128 gGameSettings
.TimeLimit
:= (gTime
- gGameStartTime
) div 1000 + Word(StrToIntDef(P
[1], 0));
7130 g_Console_Add(Format(_lc
[I_MSG_TIME_LIMIT
],
7131 [gGameSettings
.TimeLimit
div 3600,
7132 (gGameSettings
.TimeLimit
div 60) mod 60,
7133 gGameSettings
.TimeLimit
mod 60]));
7134 if g_Game_IsNet
then MH_SEND_GameSettings
;
7136 else if (cmd
= 'rcon_password') and g_Game_IsClient
then
7138 if (Length(P
) <= 1) then
7139 g_Console_Add('rcon_password <password>')
7141 MC_SEND_RCONPassword(P
[1]);
7143 else if cmd
= 'rcon' then
7145 if g_Game_IsClient
then
7147 if Length(P
) > 1 then
7150 for a
:= 1 to High(P
) do
7151 chstr
:= chstr
+ P
[a
] + ' ';
7153 if Length(chstr
) > 200 then SetLength(chstr
, 200);
7155 if Length(chstr
) < 1 then
7157 g_Console_Add('rcon <command>');
7161 MC_SEND_RCONCommand(chstr
);
7163 else g_Console_Add('rcon <command>');
7166 else if cmd
= 'ready' then
7168 if g_Game_IsServer
and (gLMSRespawn
= LMS_RESPAWN_WARMUP
) then
7169 gLMSRespawnTime
:= gTime
+ 100;
7171 else if (cmd
= 'callvote') and g_Game_IsNet
then
7173 if Length(P
) > 1 then
7176 for a
:= 1 to High(P
) do begin
7177 if a
> 1 then chstr
:= chstr
+ ' ';
7178 chstr
:= chstr
+ P
[a
];
7181 if Length(chstr
) > 200 then SetLength(chstr
, 200);
7183 if Length(chstr
) < 1 then
7185 g_Console_Add('callvote <command>');
7189 if g_Game_IsClient
then
7190 MC_SEND_Vote(True, chstr
)
7192 g_Game_StartVote(chstr
, gPlayer1Settings
.Name
);
7193 g_Console_Process('vote', True);
7196 g_Console_Add('callvote <command>');
7198 else if (cmd
= 'vote') and g_Game_IsNet
then
7200 if g_Game_IsClient
then
7202 else if gVoteInProgress
then
7204 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
7205 a
:= Floor((NetClientCount
+1)/2.0) + 1
7207 a
:= Floor(NetClientCount
/2.0) + 1;
7212 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_REVOKED
], [gPlayer1Settings
.Name
, gVoteCount
, a
]), True);
7213 MH_SEND_VoteEvent(NET_VE_REVOKE
, gPlayer1Settings
.Name
, 'a', gVoteCount
, a
);
7219 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_VOTE
], [gPlayer1Settings
.Name
, gVoteCount
, a
]), True);
7220 MH_SEND_VoteEvent(NET_VE_VOTE
, gPlayer1Settings
.Name
, 'a', gVoteCount
, a
);
7228 procedure g_TakeScreenShot
;
7229 var s
: TStream
; t
: TDateTime
; dir
, date
, name
: String;
7231 if e_NoGraphics
then Exit
;
7234 dir
:= e_GetWriteableDir(ScreenshotDirs
);
7235 DateTimeToString(date
, 'yyyy-mm-dd-hh-nn-ss', t
);
7236 name
:= e_CatPath(dir
, 'screenshot-' + date
+ '.png');
7237 s
:= createDiskFile(name
);
7239 e_MakeScreenshot(s
, gScreenWidth
, gScreenHeight
);
7241 g_Console_Add(Format(_lc
[I_CONSOLE_SCREENSHOT
], [name
]))
7243 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_WRITE
], [name
]));
7248 g_Console_Add('oh shit, i can''t create screenshot!')
7252 procedure g_Game_InGameMenu(Show
: Boolean);
7254 if (g_ActiveWindow
= nil) and Show
then
7256 if gGameSettings
.GameType
= GT_SINGLE
then
7257 g_GUI_ShowWindow('GameSingleMenu')
7260 if g_Game_IsClient
then
7261 g_GUI_ShowWindow('GameClientMenu')
7263 if g_Game_IsNet
then
7264 g_GUI_ShowWindow('GameServerMenu')
7266 g_GUI_ShowWindow('GameCustomMenu');
7268 g_Sound_PlayEx('MENU_OPEN');
7270 // Ïàóçà ïðè ìåíþ òîëüêî â îäèíî÷íîé èãðå:
7271 if (not g_Game_IsNet
) then
7275 if (g_ActiveWindow
<> nil) and (not Show
) then
7277 // Ïàóçà ïðè ìåíþ òîëüêî â îäèíî÷íîé èãðå:
7278 if (not g_Game_IsNet
) then
7279 g_Game_Pause(False);
7283 procedure g_Game_Pause (Enable
: Boolean);
7287 if not gGameOn
then exit
;
7289 if not (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
]) then exit
;
7292 gPauseMain
:= Enable
;
7294 if (gPause
<> oldPause
) then g_Game_PauseAllSounds(gPause
);
7297 procedure g_Game_HolmesPause (Enable
: Boolean);
7301 if not gGameOn
then exit
;
7302 if not (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
]) then exit
;
7305 gPauseHolmes
:= Enable
;
7307 if (gPause
<> oldPause
) then g_Game_PauseAllSounds(gPause
);
7310 procedure g_Game_PauseAllSounds(Enable
: Boolean);
7315 if gTriggers
<> nil then
7316 for i
:= 0 to High(gTriggers
) do
7317 with gTriggers
[i
] do
7318 if (TriggerType
= TRIGGER_SOUND
) and
7320 Sound
.IsPlaying() then
7322 Sound
.Pause(Enable
);
7326 if gPlayers
<> nil then
7327 for i
:= 0 to High(gPlayers
) do
7328 if gPlayers
[i
] <> nil then
7329 gPlayers
[i
].PauseSounds(Enable
);
7332 if gMusic
<> nil then
7333 gMusic
.Pause(Enable
);
7336 procedure g_Game_StopAllSounds(all
: Boolean);
7340 if gTriggers
<> nil then
7341 for i
:= 0 to High(gTriggers
) do
7342 with gTriggers
[i
] do
7343 if (TriggerType
= TRIGGER_SOUND
) and
7347 if gMusic
<> nil then
7354 procedure g_Game_UpdateTriggerSounds
;
7357 if gTriggers
<> nil then
7358 for i
:= 0 to High(gTriggers
) do
7359 with gTriggers
[i
] do
7360 if (TriggerType
= TRIGGER_SOUND
) and (Sound
<> nil) and tgcLocal
and Sound
.IsPlaying() then
7361 Sound
.SetCoordsRect(X
, Y
, Width
, Height
, tgcVolume
/ 255.0)
7364 function g_Game_IsWatchedPlayer(UID
: Word): Boolean;
7367 if (gPlayer1
<> nil) and (gPlayer1
.UID
= UID
) then
7372 if (gPlayer2
<> nil) and (gPlayer2
.UID
= UID
) then
7377 if gSpectMode
<> SPECT_PLAYERS
then
7379 if gSpectPID1
= UID
then
7384 if gSpectViewTwo
and (gSpectPID2
= UID
) then
7391 function g_Game_IsWatchedTeam(Team
: Byte): Boolean;
7396 if (gPlayer1
<> nil) and (gPlayer1
.Team
= Team
) then
7401 if (gPlayer2
<> nil) and (gPlayer2
.Team
= Team
) then
7406 if gSpectMode
<> SPECT_PLAYERS
then
7408 Pl
:= g_Player_Get(gSpectPID1
);
7409 if (Pl
<> nil) and (Pl
.Team
= Team
) then
7414 if gSpectViewTwo
then
7416 Pl
:= g_Player_Get(gSpectPID2
);
7417 if (Pl
<> nil) and (Pl
.Team
= Team
) then
7425 procedure g_Game_Message(Msg
: string; Time
: Word);
7427 MessageLineLength
:= (gScreenWidth
- 204) div e_CharFont_GetMaxWidth(gMenuFont
);
7428 MessageText
:= b_Text_Wrap(b_Text_Format(Msg
), MessageLineLength
);
7429 MessageTime
:= Time
;
7432 procedure g_Game_ChatSound(Text: String; Taunt
: Boolean = True);
7434 punct
: Array[0..13] of String =
7435 ('.', ',', ':', ';', '!', '?', '(', ')', '''', '"', '/', '\', '*', '^');
7441 function IsPunctuation(S
: String): Boolean;
7446 if Length(S
) <> 1 then
7448 for i
:= Low(punct
) to High(punct
) do
7449 if S
= punct
[i
] then
7455 function FilterPunctuation(S
: String): String;
7459 for i
:= Low(punct
) to High(punct
) do
7460 S
:= StringReplace(S
, punct
[i
], ' ', [rfReplaceAll
]);
7466 if gUseChatSounds
and Taunt
and (gChatSounds
<> nil) and (Pos(': ', Text) > 0) then
7468 // remove player name
7469 Delete(Text, 1, Pos(': ', Text) + 2 - 1);
7470 // for FullWord check
7471 Text := toLowerCase1251(' ' + Text + ' ');
7472 fpText
:= FilterPunctuation(Text);
7474 for i
:= 0 to Length(gChatSounds
) - 1 do
7477 for j
:= 0 to Length(gChatSounds
[i
].Tags
) - 1 do
7479 if gChatSounds
[i
].FullWord
and (not IsPunctuation(gChatSounds
[i
].Tags
[j
])) then
7480 ok
:= Pos(' ' + gChatSounds
[i
].Tags
[j
] + ' ', fpText
) > 0
7482 ok
:= Pos(gChatSounds
[i
].Tags
[j
], Text) > 0;
7488 gChatSounds
[i
].Sound
.Play();
7494 g_Sound_PlayEx('SOUND_GAME_RADIO');
7497 procedure g_Game_Announce_GoodShot(SpawnerUID
: Word);
7506 if not g_Game_IsWatchedPlayer(SpawnerUID
) then
7510 if goodsnd
[a
].IsPlaying() then
7513 goodsnd
[Random(4)].Play();
7516 procedure g_Game_Announce_KillCombo(Param
: Integer);
7523 UID
:= Param
and $FFFF;
7528 Pl
:= g_Player_Get(UID
);
7537 g_Console_Add(Format(_lc
[I_PLAYER_KILL_2X
], [Name
]), True);
7541 g_Console_Add(Format(_lc
[I_PLAYER_KILL_3X
], [Name
]), True);
7545 g_Console_Add(Format(_lc
[I_PLAYER_KILL_4X
], [Name
]), True);
7549 g_Console_Add(Format(_lc
[I_PLAYER_KILL_MX
], [Name
]), True);
7557 if not g_Game_IsWatchedPlayer(UID
) then
7560 if (not g_Game_IsWatchedPlayer(UID
)) and (c
< 4) then
7564 if killsnd
[n
].IsPlaying() then
7569 procedure g_Game_Announce_BodyKill(SpawnerUID
: Word);
7578 if not g_Game_IsWatchedPlayer(SpawnerUID
) then
7582 if hahasnd
[a
].IsPlaying() then
7585 hahasnd
[Random(3)].Play();
7588 procedure g_Game_StartVote(Command
, Initiator
: string);
7592 if not gVotesEnabled
then Exit
;
7593 if gGameSettings
.GameType
<> GT_SERVER
then Exit
;
7594 if gVoteInProgress
or gVotePassed
then
7596 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_INPROGRESS
], [gVoteCommand
]), True);
7597 MH_SEND_VoteEvent(NET_VE_INPROGRESS
, gVoteCommand
);
7600 gVoteInProgress
:= True;
7601 gVotePassed
:= False;
7602 gVoteTimer
:= gTime
+ gVoteTimeout
* 1000;
7605 gVoteCommand
:= Command
;
7607 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
7608 Need
:= Floor((NetClientCount
+1)/2.0)+1
7610 Need
:= Floor(NetClientCount
/2.0)+1;
7611 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_STARTED
], [Initiator
, Command
, Need
]), True);
7612 MH_SEND_VoteEvent(NET_VE_STARTED
, Initiator
, Command
, Need
);
7615 procedure g_Game_CheckVote
;
7619 if gGameSettings
.GameType
<> GT_SERVER
then Exit
;
7620 if not gVoteInProgress
then Exit
;
7622 if (gTime
>= gVoteTimer
) then
7624 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
7625 Need
:= Floor((NetClientCount
+1)/2.0) + 1
7627 Need
:= Floor(NetClientCount
/2.0) + 1;
7628 if gVoteCount
>= Need
then
7630 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_PASSED
], [gVoteCommand
]), True);
7631 MH_SEND_VoteEvent(NET_VE_PASSED
, gVoteCommand
);
7632 gVotePassed
:= True;
7633 gVoteCmdTimer
:= gTime
+ 5000;
7637 g_Console_Add(_lc
[I_MESSAGE_VOTE_FAILED
], True);
7638 MH_SEND_VoteEvent(NET_VE_FAILED
);
7640 if NetClients
<> nil then
7641 for I
:= Low(NetClients
) to High(NetClients
) do
7642 if NetClients
[i
].Used
then
7643 NetClients
[i
].Voted
:= False;
7644 gVoteInProgress
:= False;
7650 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
7651 Need
:= Floor((NetClientCount
+1)/2.0) + 1
7653 Need
:= Floor(NetClientCount
/2.0) + 1;
7654 if gVoteCount
>= Need
then
7656 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_PASSED
], [gVoteCommand
]), True);
7657 MH_SEND_VoteEvent(NET_VE_PASSED
, gVoteCommand
);
7658 gVoteInProgress
:= False;
7659 gVotePassed
:= True;
7660 gVoteCmdTimer
:= gTime
+ 5000;
7663 if NetClients
<> nil then
7664 for I
:= Low(NetClients
) to High(NetClients
) do
7665 if NetClients
[i
].Used
then
7666 NetClients
[i
].Voted
:= False;
7671 procedure g_Game_LoadMapList(FileName
: string);
7679 if not FileExists(FileName
) then Exit
;
7681 AssignFile(ListFile
, FileName
);
7683 while not EOF(ListFile
) do
7685 ReadLn(ListFile
, s
);
7688 if s
= '' then Continue
;
7690 SetLength(MapList
, Length(MapList
)+1);
7691 MapList
[High(MapList
)] := s
;
7693 CloseFile(ListFile
);
7696 procedure g_Game_SetDebugMode();
7699 // ×èòû (äàæå â ñâîåé èãðå):
7703 procedure g_Game_SetLoadingText(Text: String; Max
: Integer; reWrite
: Boolean);
7707 if Length(LoadingStat
.Msgs
) = 0 then
7713 begin // Ïåðåõîäèì íà ñëåäóþùóþ ñòðîêó èëè ñêðîëëèðóåì:
7714 if NextMsg
= Length(Msgs
) then
7716 for i
:= 0 to High(Msgs
)-1 do
7717 Msgs
[i
] := Msgs
[i
+1];
7725 Msgs
[NextMsg
-1] := Text;
7729 PBarWasHere
:= false;
7732 g_ActiveWindow
:= nil;
7734 ProcessLoading(true);
7737 procedure g_Game_StepLoading(Value
: Integer = -1);
7748 if (ShowCount
> LOADING_SHOW_STEP
) or (Value
> -1) then
7756 procedure g_Game_ClearLoading();
7765 len
:= ((gScreenHeight
div 3)*2 - 50) div LOADING_INTERLINE
;
7766 if len
< 1 then len
:= 1;
7767 SetLength(Msgs
, len
);
7768 for len
:= Low(Msgs
) to High(Msgs
) do
7771 PBarWasHere
:= false;
7775 procedure Parse_Params(var pars
: TParamStrValues
);
7782 while i
<= ParamCount
do
7785 if (s
[1] = '-') and (Length(s
) > 1) then
7787 if (s
[2] = '-') and (Length(s
) > 2) then
7788 begin // Îäèíî÷íûé ïàðàìåòð
7789 SetLength(pars
, Length(pars
) + 1);
7790 with pars
[High(pars
)] do
7792 Name
:= LowerCase(s
);
7797 if (i
< ParamCount
) then
7798 begin // Ïàðàìåòð ñî çíà÷åíèåì
7800 SetLength(pars
, Length(pars
) + 1);
7801 with pars
[High(pars
)] do
7803 Name
:= LowerCase(s
);
7804 Value
:= LowerCase(ParamStr(i
));
7813 function Find_Param_Value(var pars
: TParamStrValues
; aName
: String): String;
7818 for i
:= 0 to High(pars
) do
7819 if pars
[i
].Name
= aName
then
7821 Result
:= pars
[i
].Value
;
7826 procedure g_Game_Process_Params();
7828 pars
: TParamStrValues
;
7831 LimT
, LimS
: Integer;
7842 s
:= Find_Param_Value(pars
, '--debug');
7845 g_Game_SetDebugMode();
7846 s
:= Find_Param_Value(pars
, '--netdump');
7851 // Connect when game loads
7852 ip
:= Find_Param_Value(pars
, '-connect');
7856 s
:= Find_Param_Value(pars
, '-port');
7857 if (s
= '') or not TryStrToInt(s
, Port
) then
7860 s
:= Find_Param_Value(pars
, '-pw');
7862 g_Game_StartClient(ip
, Port
, s
);
7866 s
:= LowerCase(Find_Param_Value(pars
, '-dbg-mainwad'));
7869 gDefaultMegawadStart
:= s
;
7872 if (Find_Param_Value(pars
, '--dbg-mainwad-restore') <> '') or
7873 (Find_Param_Value(pars
, '--dbg-mainwad-default') <> '') then
7875 gDefaultMegawadStart
:= DF_Default_Megawad_Start
;
7878 // Start map when game loads:
7879 map
:= LowerCase(Find_Param_Value(pars
, '-map'));
7880 if isWadPath(map
) then
7883 s
:= Find_Param_Value(pars
, '-gm');
7884 GMode
:= g_Game_TextToMode(s
);
7885 if GMode
= GM_NONE
then GMode
:= GM_DM
;
7886 if GMode
= GM_SINGLE
then GMode
:= GM_COOP
;
7889 s
:= Find_Param_Value(pars
, '-limt');
7890 if (s
= '') or (not TryStrToInt(s
, LimT
)) then
7896 s
:= Find_Param_Value(pars
, '-lims');
7897 if (s
= '') or (not TryStrToInt(s
, LimS
)) then
7903 s
:= Find_Param_Value(pars
, '-lives');
7904 if (s
= '') or (not TryStrToInt(s
, Lives
)) then
7910 s
:= Find_Param_Value(pars
, '-opt');
7912 Opt
:= GAME_OPTION_ALLOWEXIT
or GAME_OPTION_BOTVSPLAYER
or GAME_OPTION_BOTVSMONSTER
7914 Opt
:= StrToIntDef(s
, 0);
7916 Opt
:= GAME_OPTION_ALLOWEXIT
or GAME_OPTION_BOTVSPLAYER
or GAME_OPTION_BOTVSMONSTER
;
7919 s
:= Find_Param_Value(pars
, '--close');
7923 // Override map to test:
7924 s
:= LowerCase(Find_Param_Value(pars
, '-testmap'));
7927 if e_IsValidResourceName(s
) then
7928 e_FindResource(AllMapDirs
, s
);
7929 gTestMap
:= ExpandFileName(s
);
7932 // Delete test map after play:
7933 s
:= Find_Param_Value(pars
, '--testdelete');
7936 //gMapToDelete := MapsDir + map;
7937 e_WriteLog('"--testdelete" is deprecated, use --tempdelete.', TMsgType
.Fatal
);
7941 // Delete temporary WAD after play:
7942 s
:= Find_Param_Value(pars
, '--tempdelete');
7943 if (s
<> '') and (gTestMap
<> '') then
7945 gMapToDelete
:= gTestMap
;
7946 gTempDelete
:= True;
7949 // Number of players:
7950 s
:= Find_Param_Value(pars
, '-pl');
7952 n
:= DEFAULT_PLAYERS
7954 n
:= StrToIntDef(s
, DEFAULT_PLAYERS
);
7957 s
:= Find_Param_Value(pars
, '-port');
7958 if (s
= '') or not TryStrToInt(s
, Port
) then
7959 g_Game_StartCustom(map
, GMode
, LimT
, LimS
, Lives
, Opt
, n
)
7961 g_Game_StartServer(map
, GMode
, LimT
, LimS
, Lives
, Opt
, n
, 0, Port
);
7964 // Execute script when game loads:
7965 s
:= Find_Param_Value(pars
, '-exec');
7968 // if not isWadPath(s) then
7969 // s := GameDir + '/' + s;
7974 if IOResult
<> 0 then
7976 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], ['Failed to read file: ' + s
]), TMsgType
.Warning
);
7977 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_READ
], [s
]));
7981 e_WriteLog('Executing script: ' + s
, TMsgType
.Notify
);
7982 g_Console_Add(Format(_lc
[I_CONSOLE_EXEC
], [s
]));
7987 if IOResult
<> 0 then
7989 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], ['Failed to read file: ' + s
]), TMsgType
.Warning
);
7990 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_READ
], [s
]));
7994 if Pos('#', s
) <> 1 then // script comment
7995 g_Console_Process(s
, True);
8006 conRegVar('pf_draw_frame', @g_profile_frame_draw
, 'draw frame rendering profiles', 'render profiles');
8007 //conRegVar('pf_update_frame', @g_profile_frame_update, 'draw frame updating profiles', 'update profiles');
8008 conRegVar('pf_coldet', @g_profile_collision
, 'draw collision detection profiles', 'coldet profiles');
8009 conRegVar('pf_los', @g_profile_los
, 'draw monster LOS profiles', 'monster LOS profiles');
8011 conRegVar('r_sq_draw', @gdbg_map_use_accel_render
, 'accelerated spatial queries in rendering', 'accelerated rendering');
8012 conRegVar('cd_sq_enabled', @gdbg_map_use_accel_coldet
, 'accelerated spatial queries in map coldet', 'accelerated map coldet');
8013 conRegVar('mon_sq_enabled', @gmon_debug_use_sqaccel
, 'accelerated spatial queries for monsters', 'accelerated monster coldet');
8014 conRegVar('wtrace_sq_enabled', @gwep_debug_fast_trace
, 'accelerated spatial queries for weapon hitscan trace', 'accelerated weapon hitscan');
8016 conRegVar('pr_enabled', @gpart_dbg_enabled
, 'enable/disable particles', 'particles');
8017 conRegVar('pr_phys_enabled', @gpart_dbg_phys_enabled
, 'enable/disable particle physics', 'particle physics');
8019 conRegVar('los_enabled', @gmon_dbg_los_enabled
, 'enable/disable monster LOS calculations', 'monster LOS', true);
8020 conRegVar('mon_think', @gmon_debug_think
, 'enable/disable monster thinking', 'monster thinking', true);
8022 {$IFDEF ENABLE_HOLMES}
8023 conRegVar('dbg_holmes', @g_holmes_enabled
, 'enable/disable Holmes', 'Holmes', true);
8026 conRegVar('dbg_ignore_level_bounds', @g_dbg_ignore_bounds
, 'ignore level bounds', '', false);
8028 conRegVar('r_scale', @g_dbg_scale
, 0.01, 100.0, 'render scale', '', false);
8030 conRegVar('light_enabled', @gwin_k8_enable_light_experiments
, 'enable/disable dynamic lighting', 'lighting');
8031 conRegVar('light_player_halo', @g_playerLight
, 'enable/disable player halo', 'player light halo');
8033 conRegVar('r_smallmap_align_h', @r_smallmap_h
, 'halign: 0: left; 1: center; 2: right', 'horizontal aligning of small maps');
8034 conRegVar('r_smallmap_align_v', @r_smallmap_v
, 'valign: 0: top; 1: center; 2: bottom', 'vertial aligning of small maps');
8036 conRegVar('r_showfps', @gShowFPS
, 'draw fps counter', 'draw fps counter');
8037 conRegVar('r_showtime', @gShowTime
, 'show game time', 'show game time');