1 (* Copyright (C) Doom 2D: Forever Developers
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 {$INCLUDE ../shared/a_modes.inc}
24 g_basic
, g_player
, e_graphics
, g_res_downloader
,
25 g_sound
, g_gui
, utils
, md5
, mempool
, xprofiler
,
29 TGameSettings
= record
45 TDelayedEvent
= record
54 Sound
: TPlayableSound
;
55 Tags
: Array of String;
59 TPlayerSettings
= record
78 function g_Game_IsNet(): Boolean;
79 function g_Game_IsServer(): Boolean;
80 function g_Game_IsClient(): Boolean;
81 procedure g_Game_Init();
82 procedure g_Game_Free (freeTextures
: Boolean=true);
83 procedure g_Game_LoadData();
84 procedure g_Game_FreeData();
85 procedure g_Game_Update();
86 procedure g_Game_Draw();
87 procedure g_Game_Quit();
88 procedure g_Game_SetupScreenSize();
89 procedure g_Game_ChangeResolution(newWidth
, newHeight
: Word; nowFull
, nowMax
: Boolean);
90 function g_Game_ModeToText(Mode
: Byte): string;
91 function g_Game_TextToMode(Mode
: string): Byte;
92 procedure g_Game_ExecuteEvent(Name
: String);
93 function g_Game_DelayEvent(DEType
: Byte; Time
: LongWord; Num
: Integer = 0; Str
: String = ''): Integer;
94 procedure g_Game_AddPlayer(Team
: Byte = TEAM_NONE
);
95 procedure g_Game_RemovePlayer();
96 procedure g_Game_Spectate();
97 procedure g_Game_SpectateCenterView();
98 procedure g_Game_StartSingle(Map
: String; TwoPlayers
: Boolean; nPlayers
: Byte);
99 procedure g_Game_StartCustom(Map
: String; GameMode
: Byte; TimeLimit
, GoalLimit
: Word; MaxLives
: Byte; Options
: LongWord; nPlayers
: Byte);
100 procedure g_Game_StartServer(Map
: String; GameMode
: Byte; TimeLimit
, GoalLimit
: Word; MaxLives
: Byte; Options
: LongWord; nPlayers
: Byte; IPAddr
: LongWord; Port
: Word);
101 procedure g_Game_StartClient(Addr
: String; Port
: Word; PW
: String);
102 procedure g_Game_Restart();
103 procedure g_Game_RestartLevel();
104 procedure g_Game_RestartRound(NoMapRestart
: Boolean = False);
105 procedure g_Game_ClientWAD(NewWAD
: String; WHash
: TMD5Digest
);
106 procedure g_Game_SaveOptions();
107 function g_Game_StartMap(Map
: String; Force
: Boolean = False; const oldMapPath
: AnsiString=''): Boolean;
108 procedure g_Game_ChangeMap(const MapPath
: String);
109 procedure g_Game_ExitLevel(const Map
: AnsiString);
110 function g_Game_GetFirstMap(WAD
: String): String;
111 function g_Game_GetNextMap(): String;
112 procedure g_Game_NextLevel();
113 procedure g_Game_Pause(Enable
: Boolean);
114 procedure g_Game_HolmesPause(Enable
: Boolean);
115 procedure g_Game_InGameMenu(Show
: Boolean);
116 function g_Game_IsWatchedPlayer(UID
: Word): Boolean;
117 function g_Game_IsWatchedTeam(Team
: Byte): Boolean;
118 procedure g_Game_Message(Msg
: String; Time
: Word);
119 procedure g_Game_LoadMapList(FileName
: String);
120 procedure g_Game_PauseAllSounds(Enable
: Boolean);
121 procedure g_Game_StopAllSounds(all
: Boolean);
122 procedure g_Game_UpdateTriggerSounds();
123 function g_Game_GetMegaWADInfo(WAD
: String): TMegaWADInfo
;
124 procedure g_Game_ChatSound(Text: String; Taunt
: Boolean = True);
125 procedure g_Game_Announce_GoodShot(SpawnerUID
: Word);
126 procedure g_Game_Announce_KillCombo(Param
: Integer);
127 procedure g_Game_Announce_BodyKill(SpawnerUID
: Word);
128 procedure g_Game_StartVote(Command
, Initiator
: string);
129 procedure g_Game_CheckVote
;
130 procedure g_TakeScreenShot();
131 procedure g_FatalError(Text: String);
132 procedure g_SimpleError(Text: String);
133 function g_Game_IsTestMap(): Boolean;
134 procedure g_Game_DeleteTestMap();
135 procedure GameCVars(P
: SSArray
);
136 procedure GameCommands(P
: SSArray
);
137 procedure GameCheats(P
: SSArray
);
138 procedure DebugCommands(P
: SSArray
);
139 procedure g_Game_Process_Params
;
140 procedure g_Game_SetLoadingText(Text: String; Max
: Integer; reWrite
: Boolean);
141 procedure g_Game_StepLoading(Value
: Integer = -1);
142 procedure g_Game_ClearLoading();
143 procedure g_Game_SetDebugMode();
144 procedure DrawLoadingStat();
145 procedure DrawMenuBackground(tex
: AnsiString);
147 { procedure SetWinPause(Enable: Boolean); }
152 LOADING_SHOW_STEP
= 100;
153 LOADING_INTERLINE
= 20;
168 MESSAGE_DIKEY
= WM_USER
+ 1;
173 EXIT_ENDLEVELSINGLE
= 4;
174 EXIT_ENDLEVELCUSTOM
= 5;
176 GAME_OPTION_RESERVED
= 1;
177 GAME_OPTION_TEAMDAMAGE
= 2;
178 GAME_OPTION_ALLOWEXIT
= 4;
179 GAME_OPTION_WEAPONSTAY
= 8;
180 GAME_OPTION_MONSTERS
= 16;
181 GAME_OPTION_BOTVSPLAYER
= 32;
182 GAME_OPTION_BOTVSMONSTER
= 64;
187 STATE_INTERCUSTOM
= 3;
188 STATE_INTERSINGLE
= 4;
194 LMS_RESPAWN_NONE
= 0;
195 LMS_RESPAWN_WARMUP
= 1;
196 LMS_RESPAWN_FINAL
= 2;
213 CONFIG_FILENAME
= 'Doom2DF.cfg';
214 LOG_FILENAME
= 'Doom2DF.log';
216 TEST_MAP_NAME
= '$$$_TEST_$$$';
218 STD_PLAYER_MODEL
= 'Doomer';
228 gGameSettings
: TGameSettings
;
229 gPlayer1Settings
: TPlayerSettings
;
230 gPlayer2Settings
: TPlayerSettings
;
232 gPlayerScreenSize
: TDFPoint
;
233 gPlayer1ScreenCoord
: TDFPoint
;
234 gPlayer2ScreenCoord
: TDFPoint
;
235 gPlayer1
: TPlayer
= nil;
236 gPlayer2
: TPlayer
= nil;
237 gPlayerDrawn
: TPlayer
= nil;
239 gSwitchGameMode
: Byte = GM_DM
;
240 gHearPoint1
, gHearPoint2
: THearPoint
;
241 gSoundEffectsDF
: Boolean = False;
242 gSoundTriggerTime
: Word = 0;
243 gAnnouncer
: Byte = ANNOUNCE_NONE
;
244 goodsnd
: array[0..3] of TPlayableSound
;
245 killsnd
: array[0..3] of TPlayableSound
;
246 hahasnd
: array[0..2] of TPlayableSound
;
247 sound_get_flag
: array[0..1] of TPlayableSound
;
248 sound_lost_flag
: array[0..1] of TPlayableSound
;
249 sound_ret_flag
: array[0..1] of TPlayableSound
;
250 sound_cap_flag
: array[0..1] of TPlayableSound
;
251 gBodyKillEvent
: Integer = -1;
252 gDefInterTime
: ShortInt = -1;
253 gInterEndTime
: LongWord = 0;
254 gInterTime
: LongWord = 0;
255 gServInterTime
: Byte = 0;
256 gGameStartTime
: LongWord = 0;
257 gTotalMonsters
: Integer = 0;
258 gPauseMain
: Boolean = false;
259 gPauseHolmes
: Boolean = false;
260 gShowTime
: Boolean = False;
261 gShowFPS
: Boolean = False;
262 gShowGoals
: Boolean = True;
263 gShowStat
: Boolean = True;
264 gShowKillMsg
: Boolean = True;
265 gShowLives
: Boolean = True;
266 gShowPing
: Boolean = False;
267 gShowMap
: Boolean = False;
269 gState
: Byte = STATE_NONE
;
271 sWidth
, sHeight
: Word;
272 gSpectMode
: Byte = SPECT_NONE
;
273 gSpectHUD
: Boolean = True;
274 gSpectKeyPress
: Boolean = False;
275 gSpectX
: Integer = 0;
276 gSpectY
: Integer = 0;
277 gSpectStep
: Byte = 8;
278 gSpectViewTwo
: Boolean = False;
279 gSpectPID1
: Integer = -1;
280 gSpectPID2
: Integer = -1;
281 gSpectAuto
: Boolean = False;
282 gSpectAutoNext
: LongWord;
283 gSpectAutoStepX
: Integer;
284 gSpectAutoStepY
: Integer;
285 gMusic
: TMusic
= nil;
286 gLoadGameMode
: Boolean;
287 gCheats
: Boolean = False;
288 gMapOnce
: Boolean = False;
289 gMapToDelete
: String;
290 gTempDelete
: Boolean = False;
291 gLastMap
: Boolean = False;
292 gWinPosX
, gWinPosY
: Integer;
293 gWinSizeX
, gWinSizeY
: Integer;
294 gWinFrameX
, gWinFrameY
, gWinCaption
: Integer;
295 gWinActive
: Boolean = True; // by default window is active, lol
296 gResolutionChange
: Boolean = False;
297 gRC_Width
, gRC_Height
: Word;
298 gRC_FullScreen
, gRC_Maximized
: Boolean;
299 gLanguageChange
: Boolean = False;
300 gDebugMode
: Boolean = False;
301 g_debug_Sounds
: Boolean = False;
302 g_debug_Frames
: Boolean = False;
303 g_debug_WinMsgs
: Boolean = False;
304 g_debug_MonsterOff
: Boolean = False;
305 g_debug_BotAIOff
: Byte = 0;
306 g_debug_HealthBar
: Boolean = False;
307 g_Debug_Player
: Boolean = False;
308 gCoopMonstersKilled
: Word = 0;
309 gCoopSecretsFound
: Word = 0;
310 gCoopTotalMonstersKilled
: Word = 0;
311 gCoopTotalSecretsFound
: Word = 0;
312 gCoopTotalMonsters
: Word = 0;
313 gCoopTotalSecrets
: Word = 0;
314 gStatsOff
: Boolean = False;
315 gStatsPressed
: Boolean = False;
316 gExitByTrigger
: Boolean = False;
317 gNextMap
: String = '';
318 gLMSRespawn
: Byte = LMS_RESPAWN_NONE
;
319 gLMSRespawnTime
: Cardinal = 0;
320 gLMSSoftSpawn
: Boolean = False;
321 gMissionFailed
: Boolean = False;
322 gVoteInProgress
: Boolean = False;
323 gVotePassed
: Boolean = False;
324 gVoteCommand
: string = '';
325 gVoteTimer
: Cardinal = 0;
326 gVoteCmdTimer
: Cardinal = 0;
327 gVoteCount
: Integer = 0;
328 gVoteTimeout
: Cardinal = 30;
329 gVoted
: Boolean = False;
330 gVotesEnabled
: Boolean = True;
331 gEvents
: Array of TGameEvent
;
332 gDelayedEvents
: Array of TDelayedEvent
;
333 gUseChatSounds
: Boolean = True;
334 gChatSounds
: Array of TChatSound
;
335 gSelectWeapon
: Array [0..1, WP_FIRST
..WP_LAST
] of Boolean; // [player, weapon]
336 gInterReadyCount
: Integer = 0;
338 g_dbg_ignore_bounds
: Boolean = false;
339 r_smallmap_h
: Integer = 0; // 0: left; 1: center; 2: right
340 r_smallmap_v
: Integer = 2; // 0: top; 1: center; 2: bottom
342 // move button values:
343 // bits 0-1: l/r state:
344 // 0: neither left, nor right pressed
347 // bits 4-5: l/r state when strafe was pressed
348 P1MoveButton
: Byte = 0;
349 P2MoveButton
: Byte = 0;
351 g_profile_frame_update
: Boolean = false;
352 g_profile_frame_draw
: Boolean = false;
353 g_profile_collision
: Boolean = false;
354 g_profile_los
: Boolean = false;
355 g_profile_history_size
: Integer = 1000;
357 g_rlayer_back
: Boolean = true;
358 g_rlayer_step
: Boolean = true;
359 g_rlayer_wall
: Boolean = true;
360 g_rlayer_door
: Boolean = true;
361 g_rlayer_acid1
: Boolean = true;
362 g_rlayer_acid2
: Boolean = true;
363 g_rlayer_water
: Boolean = true;
364 g_rlayer_fore
: Boolean = true;
367 procedure g_ResetDynlights ();
368 procedure g_AddDynLight (x
, y
, radius
: Integer; r
, g
, b
, a
: Single);
369 procedure g_DynLightExplosion (x
, y
, radius
: Integer; r
, g
, b
: Single);
371 function conIsCheatsEnabled (): Boolean; inline;
372 function gPause (): Boolean; inline;
378 {$INCLUDE ../nogl/noGLuses.inc}
379 {$IFDEF ENABLE_HOLMES}
382 e_texture
, g_textures
, g_main
, g_window
, g_menu
,
383 e_input
, e_log
, g_console
, g_items
, g_map
, g_panel
,
384 g_playermodel
, g_gfx
, g_options
, Math
,
385 g_triggers
, g_monsters
, e_sound
, CONFIG
,
387 ENet
, e_msg
, g_netmsg
, g_netmaster
,
392 hasPBarGfx
: Boolean = false;
395 // ////////////////////////////////////////////////////////////////////////// //
396 function gPause (): Boolean; inline; begin result
:= gPauseMain
or gPauseHolmes
; end;
399 // ////////////////////////////////////////////////////////////////////////// //
400 function conIsCheatsEnabled (): Boolean; inline;
403 if g_Game_IsNet
then exit
;
404 if not gDebugMode
then
406 //if not gCheats then exit;
407 if not (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
]) then exit
;
408 if not (gGameSettings
.GameMode
in [GM_COOP
, GM_SINGLE
]) then exit
;
414 // ////////////////////////////////////////////////////////////////////////// //
416 profileFrameDraw
: TProfiler
= nil;
419 // ////////////////////////////////////////////////////////////////////////// //
422 x
, y
, radius
: Integer;
425 exploRadius
: Integer;
429 g_dynLights
: array of TDynLight
= nil;
430 g_dynLightCount
: Integer = 0;
431 g_playerLight
: Boolean = false;
433 procedure g_ResetDynlights ();
437 if not gwin_has_stencil
then begin g_dynLightCount
:= 0; exit
; end;
439 for idx
:= 0 to g_dynLightCount
-1 do
441 if g_dynLights
[idx
].exploCount
= -666 then
448 Inc(g_dynLights
[idx
].exploCount
);
449 if (g_dynLights
[idx
].exploCount
< 10) then
451 g_dynLights
[idx
].radius
:= g_dynLights
[idx
].exploRadius
+g_dynLights
[idx
].exploCount
*8;
452 g_dynLights
[idx
].a
:= 0.4+g_dynLights
[idx
].exploCount
/10;
453 if (g_dynLights
[idx
].a
> 0.8) then g_dynLights
[idx
].a
:= 0.8;
454 if lnum
<> idx
then g_dynLights
[lnum
] := g_dynLights
[idx
];
459 g_dynLightCount
:= lnum
;
462 procedure g_AddDynLight (x
, y
, radius
: Integer; r
, g
, b
, a
: Single);
464 if not gwin_has_stencil
then exit
;
465 if g_dynLightCount
= length(g_dynLights
) then SetLength(g_dynLights
, g_dynLightCount
+1024);
466 g_dynLights
[g_dynLightCount
].x
:= x
;
467 g_dynLights
[g_dynLightCount
].y
:= y
;
468 g_dynLights
[g_dynLightCount
].radius
:= radius
;
469 g_dynLights
[g_dynLightCount
].r
:= r
;
470 g_dynLights
[g_dynLightCount
].g
:= g
;
471 g_dynLights
[g_dynLightCount
].b
:= b
;
472 g_dynLights
[g_dynLightCount
].a
:= a
;
473 g_dynLights
[g_dynLightCount
].exploCount
:= -666;
474 Inc(g_dynLightCount
);
477 procedure g_DynLightExplosion (x
, y
, radius
: Integer; r
, g
, b
: Single);
479 if not gwin_has_stencil
then exit
;
480 if g_dynLightCount
= length(g_dynLights
) then SetLength(g_dynLights
, g_dynLightCount
+1024);
481 g_dynLights
[g_dynLightCount
].x
:= x
;
482 g_dynLights
[g_dynLightCount
].y
:= y
;
483 g_dynLights
[g_dynLightCount
].radius
:= 0;
484 g_dynLights
[g_dynLightCount
].exploRadius
:= radius
;
485 g_dynLights
[g_dynLightCount
].r
:= r
;
486 g_dynLights
[g_dynLightCount
].g
:= g
;
487 g_dynLights
[g_dynLightCount
].b
:= b
;
488 g_dynLights
[g_dynLightCount
].a
:= 0;
489 g_dynLights
[g_dynLightCount
].exploCount
:= 0;
490 Inc(g_dynLightCount
);
494 // ////////////////////////////////////////////////////////////////////////// //
495 function calcProfilesHeight (prof
: TProfiler
): Integer;
498 if (prof
= nil) then exit
;
499 if (length(prof
.bars
) = 0) then exit
;
500 result
:= length(prof
.bars
)*(16+2);
504 function drawProfiles (x
, y
: Integer; prof
: TProfiler
): Integer;
511 if (prof
= nil) then exit
;
513 if (length(prof
.bars
) = 0) then exit
;
515 hgt
:= calcProfilesHeight(prof
);
516 if (x
< 0) then x
:= gScreenWidth
-(wdt
-1)+x
;
517 if (y
< 0) then y
:= gScreenHeight
-(hgt
-1)+y
;
519 //e_DrawFillQuad(x, y, x+wdt-1, y+hgt-1, 255, 255, 255, 200, B_BLEND);
520 //e_DrawFillQuad(x, y, x+wdt-1, y+hgt-1, 20, 20, 20, 0, B_NONE);
521 e_DarkenQuadWH(x
, y
, wdt
, hgt
, 150);
524 for ii
:= 0 to High(prof
.bars
) do
526 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);
533 // ////////////////////////////////////////////////////////////////////////// //
535 TEndCustomGameStat
= record
536 PlayerStat
: TPlayerStatArray
;
540 Map
, MapName
: String;
543 TEndSingleGameStat
= record
544 PlayerStat
: Array [0..1] of record
550 TotalSecrets
: Integer;
553 TLoadingStat
= record
557 Msgs
: Array of String;
559 PBarWasHere
: Boolean; // did we draw a progress bar for this message?
562 TParamStrValue
= record
567 TParamStrValues
= Array of TParamStrValue
;
570 INTER_ACTION_TEXT
= 1;
571 INTER_ACTION_PIC
= 2;
572 INTER_ACTION_MUSIC
= 3;
576 FPSCounter
, UPSCounter
: Word;
577 FPSTime
, UPSTime
: LongWord;
578 DataLoaded
: Boolean = False;
579 IsDrawStat
: Boolean = False;
580 CustomStat
: TEndCustomGameStat
;
581 SingleStat
: TEndSingleGameStat
;
582 LoadingStat
: TLoadingStat
;
583 EndingGameCounter
: Byte = 0;
586 MessageLineLength
: Integer = 80;
587 MapList
: SSArray
= nil;
588 MapIndex
: Integer = -1;
589 InterReadyTime
: Integer = -1;
595 text: Array of ShortString;
596 anim
: Array of ShortString;
597 pic
: Array of ShortString;
598 mus
: Array of ShortString;
600 triggers
: Array of record
602 actions
: Array of record
603 action
, p1
, p2
: Integer;
606 cur_trigger
: Integer;
619 function Compare(a
, b
: TPlayerStat
): Integer;
621 if a
.Spectator
then Result
:= 1
622 else if b
.Spectator
then Result
:= -1
623 else if a
.Frags
< b
.Frags
then Result
:= 1
624 else if a
.Frags
> b
.Frags
then Result
:= -1
625 else if a
.Deaths
< b
.Deaths
then Result
:= -1
626 else if a
.Deaths
> b
.Deaths
then Result
:= 1
627 else if a
.Kills
< b
.Kills
then Result
:= -1
631 procedure SortGameStat(var stat
: TPlayerStatArray
);
636 if stat
= nil then Exit
;
638 for I
:= High(stat
) downto Low(stat
) do
639 for J
:= Low(stat
) to High(stat
) - 1 do
640 if Compare(stat
[J
], stat
[J
+ 1]) = 1 then
643 stat
[J
] := stat
[J
+ 1];
648 function g_Game_ModeToText(Mode
: Byte): string;
652 GM_DM
: Result
:= _lc
[I_MENU_GAME_TYPE_DM
];
653 GM_TDM
: Result
:= _lc
[I_MENU_GAME_TYPE_TDM
];
654 GM_CTF
: Result
:= _lc
[I_MENU_GAME_TYPE_CTF
];
655 GM_COOP
: Result
:= _lc
[I_MENU_GAME_TYPE_COOP
];
656 GM_SINGLE
: Result
:= _lc
[I_MENU_GAME_TYPE_SINGLE
];
660 function g_Game_TextToMode(Mode
: string): Byte;
663 Mode
:= UpperCase(Mode
);
664 if Mode
= _lc
[I_MENU_GAME_TYPE_DM
] then
669 if Mode
= _lc
[I_MENU_GAME_TYPE_TDM
] then
674 if Mode
= _lc
[I_MENU_GAME_TYPE_CTF
] then
679 if Mode
= _lc
[I_MENU_GAME_TYPE_COOP
] then
684 if Mode
= _lc
[I_MENU_GAME_TYPE_SINGLE
] then
691 function g_Game_IsNet(): Boolean;
693 Result
:= (gGameSettings
.GameType
in [GT_SERVER
, GT_CLIENT
]);
696 function g_Game_IsServer(): Boolean;
698 Result
:= (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
, GT_SERVER
]);
701 function g_Game_IsClient(): Boolean;
703 Result
:= (gGameSettings
.GameType
= GT_CLIENT
);
706 function g_Game_GetMegaWADInfo(WAD
: String): TMegaWADInfo
;
713 Result
.name
:= ExtractFileName(WAD
);
714 Result
.description
:= '';
717 w
:= TWADFile
.Create();
720 if not w
.GetResource('INTERSCRIPT', p
, len
) then
726 cfg
:= TConfig
.CreateMem(p
, len
);
727 Result
.name
:= cfg
.ReadStr('megawad', 'name', ExtractFileName(WAD
));
728 Result
.description
:= cfg
.ReadStr('megawad', 'description', '');
729 Result
.author
:= cfg
.ReadStr('megawad', 'author', '');
730 Result
.pic
:= cfg
.ReadStr('megawad', 'pic', '');
736 procedure g_Game_FreeWAD();
740 for a
:= 0 to High(MegaWAD
.res
.pic
) do
741 if MegaWAD
.res
.pic
[a
] <> '' then
742 g_Texture_Delete(MegaWAD
.res
.pic
[a
]);
744 for a
:= 0 to High(MegaWAD
.res
.mus
) do
745 if MegaWAD
.res
.mus
[a
] <> '' then
746 g_Sound_Delete(MegaWAD
.res
.mus
[a
]);
748 MegaWAD
.res
.pic
:= nil;
749 MegaWAD
.res
.text := nil;
750 MegaWAD
.res
.anim
:= nil;
751 MegaWAD
.res
.mus
:= nil;
752 MegaWAD
.triggers
:= nil;
754 g_Texture_Delete('TEXTURE_endpic');
755 g_Sound_Delete('MUSIC_endmus');
757 ZeroMemory(@MegaWAD
, SizeOf(MegaWAD
));
758 gGameSettings
.WAD
:= '';
761 procedure g_Game_LoadWAD(WAD
: string);
770 gGameSettings
.WAD
:= WAD
;
771 if not (gGameSettings
.GameMode
in [GM_COOP
, GM_SINGLE
]) then
774 MegaWAD
.info
:= g_Game_GetMegaWADInfo(MapsDir
+ WAD
);
776 w
:= TWADFile
.Create();
777 w
.ReadFile(MapsDir
+ WAD
);
779 if not w
.GetResource('INTERSCRIPT', p
, len
) then
785 cfg
:= TConfig
.CreateMem(p
, len
);
790 s := cfg.ReadStr('pic', 'pic'+IntToStr(b), '');
791 if s = '' then Break;
794 SetLength(MegaWAD.res.pic, Length(MegaWAD.res.pic)+1);
795 MegaWAD.res.pic[High(MegaWAD.res.pic)] := s;
797 g_Texture_CreateWADEx(s, s);
803 s := cfg.ReadStr('mus', 'mus'+IntToStr(b), '');
804 if s = '' then Break;
807 SetLength(MegaWAD.res.mus, Length(MegaWAD.res.mus)+1);
808 MegaWAD.res.mus[High(MegaWAD.res.mus)] := s;
810 g_Music_CreateWADEx(s, s);
813 MegaWAD
.endpic
:= cfg
.ReadStr('megawad', 'endpic', '');
814 if MegaWAD
.endpic
<> '' then
816 s
:= g_ExtractWadName(MegaWAD
.endpic
);
817 if s
= '' then s
:= MapsDir
+WAD
else s
:= GameDir
+'/wads/';
818 g_Texture_CreateWADEx('TEXTURE_endpic', s
+MegaWAD
.endpic
);
820 MegaWAD
.endmus
:= cfg
.ReadStr('megawad', 'endmus', 'Standart.wad:D2DMUS\ÊÎÍÅÖ');
821 if MegaWAD
.endmus
<> '' then
823 s
:= g_ExtractWadName(MegaWAD
.endmus
);
824 if s
= '' then s
:= MapsDir
+WAD
else s
:= GameDir
+'/wads/';
825 g_Sound_CreateWADEx('MUSIC_endmus', s
+MegaWAD
.endmus
, True);
833 {procedure start_trigger(t: string);
837 function next_trigger(): Boolean;
841 procedure DisableCheats();
847 if gPlayer1
<> nil then gPlayer1
.GodMode
:= False;
848 if gPlayer2
<> nil then gPlayer2
.GodMode
:= False;
849 if gPlayer1
<> nil then gPlayer1
.NoTarget
:= False;
850 if gPlayer2
<> nil then gPlayer2
.NoTarget
:= False;
852 {$IF DEFINED(D2F_DEBUG)}
853 if gPlayer1
<> nil then gPlayer1
.NoTarget
:= True;
854 gAimLine
:= g_dbg_aimline_on
;
858 procedure g_Game_ExecuteEvent(Name
: String);
864 if gEvents
= nil then
866 for a
:= 0 to High(gEvents
) do
867 if gEvents
[a
].Name
= Name
then
869 if gEvents
[a
].Command
<> '' then
870 g_Console_Process(gEvents
[a
].Command
, True);
875 function g_Game_DelayEvent(DEType
: Byte; Time
: LongWord; Num
: Integer = 0; Str
: String = ''): Integer;
880 if gDelayedEvents
<> nil then
881 for a
:= 0 to High(gDelayedEvents
) do
882 if not gDelayedEvents
[a
].Pending
then
889 SetLength(gDelayedEvents
, Length(gDelayedEvents
) + 1);
890 n
:= High(gDelayedEvents
);
892 gDelayedEvents
[n
].Pending
:= True;
893 gDelayedEvents
[n
].DEType
:= DEType
;
894 gDelayedEvents
[n
].DENum
:= Num
;
895 gDelayedEvents
[n
].DEStr
:= Str
;
896 if DEType
= DE_GLOBEVENT
then
897 gDelayedEvents
[n
].Time
:= (GetTimer() {div 1000}) + Time
899 gDelayedEvents
[n
].Time
:= gTime
+ Time
;
908 if g_Game_IsNet
and g_Game_IsServer
then
909 MH_SEND_GameEvent(NET_EV_MAPEND
, Byte(gMissionFailed
));
913 gPauseHolmes
:= false;
916 g_Game_StopAllSounds(False);
921 EndingGameCounter
:= 0;
922 g_ActiveWindow
:= nil;
924 gLMSRespawn
:= LMS_RESPAWN_NONE
;
925 gLMSRespawnTime
:= 0;
928 EXIT_SIMPLE
: // Âûõîä ÷åðåç ìåíþ èëè êîíåö òåñòà
933 begin // Ýòî áûë òåñò
937 begin // Âûõîä â ãëàâíîå ìåíþ
938 gMusic
.SetByName('MUSIC_MENU');
940 if gState
<> STATE_SLIST
then
942 g_GUI_ShowWindow('MainMenu');
943 gState
:= STATE_MENU
;
946 // Îáíîâëÿåì ñïèñîê ñåðâåðîâ
947 slReturnPressed
:= True;
948 if g_Net_Slist_Fetch(slCurrent
) then
950 if slCurrent
= nil then
951 slWaitStr
:= _lc
[I_NET_SLIST_NOSERVERS
];
954 slWaitStr
:= _lc
[I_NET_SLIST_ERROR
];
955 g_Serverlist_GenerateTable(slCurrent
, slTable
);
958 g_Game_ExecuteEvent('ongameend');
962 EXIT_RESTART
: // Íà÷àòü óðîâåíü ñíà÷àëà
964 if not g_Game_IsClient
then g_Game_Restart();
967 EXIT_ENDLEVELCUSTOM
: // Çàêîí÷èëñÿ óðîâåíü â Ñâîåé èãðå
969 // Ñòàòèñòèêà Ñâîåé èãðû:
970 FileName
:= g_ExtractWadName(gMapInfo
.Map
);
972 CustomStat
.GameTime
:= gTime
;
973 CustomStat
.Map
:= ExtractFileName(FileName
)+':'+g_ExtractFileName(gMapInfo
.Map
); //ResName;
974 CustomStat
.MapName
:= gMapInfo
.Name
;
975 CustomStat
.GameMode
:= gGameSettings
.GameMode
;
976 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
977 CustomStat
.TeamStat
:= gTeamStat
;
979 CustomStat
.PlayerStat
:= nil;
981 // Ñòàòèñòèêà èãðîêîâ:
982 if gPlayers
<> nil then
984 for a
:= 0 to High(gPlayers
) do
985 if gPlayers
[a
] <> nil then
987 SetLength(CustomStat
.PlayerStat
, Length(CustomStat
.PlayerStat
)+1);
988 with CustomStat
.PlayerStat
[High(CustomStat
.PlayerStat
)] do
991 Name
:= gPlayers
[a
].Name
;
992 Frags
:= gPlayers
[a
].Frags
;
993 Deaths
:= gPlayers
[a
].Death
;
994 Kills
:= gPlayers
[a
].Kills
;
995 Team
:= gPlayers
[a
].Team
;
996 Color
:= gPlayers
[a
].Model
.Color
;
997 Spectator
:= gPlayers
[a
].FSpectator
;
1001 SortGameStat(CustomStat
.PlayerStat
);
1004 g_Game_ExecuteEvent('onmapend');
1005 if not g_Game_IsClient
then g_Player_ResetReady
;
1006 gInterReadyCount
:= 0;
1008 // Çàòóõàþùèé ýêðàí:
1009 EndingGameCounter
:= 255;
1010 gState
:= STATE_FOLD
;
1012 if gDefInterTime
< 0 then
1013 gInterEndTime
:= IfThen((gGameSettings
.GameType
= GT_SERVER
) and (gPlayer1
= nil), 15000, 25000)
1015 gInterEndTime
:= gDefInterTime
* 1000;
1018 EXIT_ENDLEVELSINGLE
: // Çàêîí÷èëñÿ óðîâåíü â Îäèíî÷íîé èãðå
1020 // Ñòàòèñòèêà Îäèíî÷íîé èãðû:
1021 SingleStat
.GameTime
:= gTime
;
1022 SingleStat
.TwoPlayers
:= gPlayer2
<> nil;
1023 SingleStat
.TotalSecrets
:= gSecretsCount
;
1024 // Ñòàòèñòèêà ïåðâîãî èãðîêà:
1025 SingleStat
.PlayerStat
[0].Kills
:= gPlayer1
.MonsterKills
;
1026 SingleStat
.PlayerStat
[0].Secrets
:= gPlayer1
.Secrets
;
1027 // Ñòàòèñòèêà âòîðîãî èãðîêà (åñëè åñòü):
1028 if SingleStat
.TwoPlayers
then
1030 SingleStat
.PlayerStat
[1].Kills
:= gPlayer2
.MonsterKills
;
1031 SingleStat
.PlayerStat
[1].Secrets
:= gPlayer2
.Secrets
;
1034 g_Game_ExecuteEvent('onmapend');
1037 if gNextMap
<> '' then
1039 gMusic
.SetByName('MUSIC_INTERMUS');
1041 gState
:= STATE_INTERSINGLE
;
1044 g_Game_ExecuteEvent('oninter');
1046 else // Áîëüøå íåò êàðò
1048 // Çàòóõàþùèé ýêðàí:
1049 EndingGameCounter
:= 255;
1050 gState
:= STATE_FOLD
;
1055 // Îêîí÷àíèå îáðàáîòàíî:
1056 if gExit
<> EXIT_QUIT
then
1060 procedure drawTime(X
, Y
: Integer); inline;
1062 e_TextureFontPrint(x
, y
,
1063 Format('%d:%.2d:%.2d', [
1064 gTime
div 1000 div 3600,
1065 (gTime
div 1000 div 60) mod 60,
1066 gTime
div 1000 mod 60
1071 procedure DrawStat();
1073 pc
, x
, y
, w
, h
: Integer;
1074 w1
, w2
, w3
, w4
: Integer;
1076 cw
, ch
, r
, g
, b
, rr
, gg
, bb
: Byte;
1079 stat
: TPlayerStatArray
;
1086 pc
:= g_Player_GetCount
;
1087 e_TextureFontGetSize(gStdFont
, cw
, ch
);
1089 w
:= gScreenWidth
-(gScreenWidth
div 5);
1090 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
1093 h
:= 40+ch
*5+(ch
+8)*pc
;
1094 x
:= (gScreenWidth
div 2)-(w
div 2);
1095 y
:= (gScreenHeight
div 2)-(h
div 2);
1097 e_DrawFillQuad(x
, y
, x
+w
-1, y
+h
-1, 64, 64, 64, 32);
1098 e_DrawQuad(x
, y
, x
+w
-1, y
+h
-1, 255, 127, 0);
1100 drawTime(x
+w
-78, y
+8);
1102 wad
:= g_ExtractWadNameNoPath(gMapInfo
.Map
);
1103 map
:= g_ExtractFileName(gMapInfo
.Map
);
1104 mapstr
:= wad
+ ':\' + map
+ ' - ' + gMapInfo
.Name
;
1106 case gGameSettings
.GameMode
of
1109 if gGameSettings
.MaxLives
= 0 then
1110 s1
:= _lc
[I_GAME_DM
]
1112 s1
:= _lc
[I_GAME_LMS
];
1113 s2
:= Format(_lc
[I_GAME_FRAG_LIMIT
], [gGameSettings
.GoalLimit
]);
1114 s3
:= Format(_lc
[I_GAME_TIME_LIMIT
], [gGameSettings
.TimeLimit
div 3600, (gGameSettings
.TimeLimit
div 60) mod 60, gGameSettings
.TimeLimit
mod 60]);
1119 if gGameSettings
.MaxLives
= 0 then
1120 s1
:= _lc
[I_GAME_TDM
]
1122 s1
:= _lc
[I_GAME_TLMS
];
1123 s2
:= Format(_lc
[I_GAME_FRAG_LIMIT
], [gGameSettings
.GoalLimit
]);
1124 s3
:= Format(_lc
[I_GAME_TIME_LIMIT
], [gGameSettings
.TimeLimit
div 3600, (gGameSettings
.TimeLimit
div 60) mod 60, gGameSettings
.TimeLimit
mod 60]);
1129 s1
:= _lc
[I_GAME_CTF
];
1130 s2
:= Format(_lc
[I_GAME_SCORE_LIMIT
], [gGameSettings
.GoalLimit
]);
1131 s3
:= Format(_lc
[I_GAME_TIME_LIMIT
], [gGameSettings
.TimeLimit
div 3600, (gGameSettings
.TimeLimit
div 60) mod 60, gGameSettings
.TimeLimit
mod 60]);
1136 if gGameSettings
.MaxLives
= 0 then
1137 s1
:= _lc
[I_GAME_COOP
]
1139 s1
:= _lc
[I_GAME_SURV
];
1140 s2
:= _lc
[I_GAME_MONSTERS
] + ' ' + IntToStr(gCoopMonstersKilled
) + '/' + IntToStr(gTotalMonsters
);
1141 s3
:= _lc
[I_GAME_SECRETS
] + ' ' + IntToStr(gCoopSecretsFound
) + '/' + IntToStr(gSecretsCount
);
1152 e_TextureFontPrintEx(x
+(w
div 2)-(Length(s1
)*cw
div 2), _y
, s1
, gStdFont
, 255, 255, 255, 1);
1154 e_TextureFontPrintEx(x
+(w
div 2)-(Length(mapstr
)*cw
div 2), _y
, mapstr
, gStdFont
, 200, 200, 200, 1);
1156 e_TextureFontPrintEx(x
+16, _y
, s2
, gStdFont
, 200, 200, 200, 1);
1158 e_TextureFontPrintEx(x
+w
-16-(Length(s3
))*cw
, _y
, s3
,
1159 gStdFont
, 200, 200, 200, 1);
1161 if NetMode
= NET_SERVER
then
1162 e_TextureFontPrintEx(x
+8, y
+ 8, _lc
[I_NET_SERVER
], gStdFont
, 255, 255, 255, 1)
1164 if NetMode
= NET_CLIENT
then
1165 e_TextureFontPrintEx(x
+8, y
+ 8,
1166 NetClientIP
+ ':' + IntToStr(NetClientPort
), gStdFont
, 255, 255, 255, 1);
1170 stat
:= g_Player_GetStats();
1173 w2
:= (w
-16) div 6 + 48; // øèðèíà 2 ñòîëáöà
1174 w3
:= (w
-16) div 6; // øèðèíà 3 è 4 ñòîëáöîâ
1176 w1
:= w
-16-w2
-w3
-w4
; // îñòàâøååñÿ ïðîñòðàíñòâî - äëÿ öâåòà è èìåíè èãðîêà
1178 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
1182 for a
:= TEAM_RED
to TEAM_BLUE
do
1184 if a
= TEAM_RED
then
1186 s1
:= _lc
[I_GAME_TEAM_RED
];
1193 s1
:= _lc
[I_GAME_TEAM_BLUE
];
1199 e_TextureFontPrintEx(x
+16, _y
, s1
, gStdFont
, r
, g
, b
, 1);
1200 e_TextureFontPrintEx(x
+w1
+16, _y
, IntToStr(gTeamStat
[a
].Goals
),
1201 gStdFont
, r
, g
, b
, 1);
1203 _y
:= _y
+ch
+(ch
div 4);
1204 e_DrawLine(1, x
+16, _y
, x
+w
-16, _y
, r
, g
, b
);
1205 _y
:= _y
+(ch
div 4);
1207 for aa
:= 0 to High(stat
) do
1208 if stat
[aa
].Team
= a
then
1224 e_TextureFontPrintEx(x
+16, _y
, Name
, gStdFont
, rr
, gg
, bb
, 1);
1226 e_TextureFontPrintEx(x
+w1
+16, _y
, Format(_lc
[I_GAME_PING_MS
], [Ping
, Loss
]), gStdFont
, rr
, gg
, bb
, 1);
1228 e_TextureFontPrintEx(x
+w1
+w2
+16, _y
, IntToStr(Frags
), gStdFont
, rr
, gg
, bb
, 1);
1230 e_TextureFontPrintEx(x
+w1
+w2
+w3
+16, _y
, IntToStr(Deaths
), gStdFont
, rr
, gg
, bb
, 1);
1237 else if gGameSettings
.GameMode
in [GM_DM
, GM_COOP
] then
1240 e_TextureFontPrintEx(x
+16, _y
, _lc
[I_GAME_PLAYER_NAME
], gStdFont
, 255, 127, 0, 1);
1241 e_TextureFontPrintEx(x
+16+w1
, _y
, _lc
[I_GAME_PING
], gStdFont
, 255, 127, 0, 1);
1242 e_TextureFontPrintEx(x
+16+w1
+w2
, _y
, _lc
[I_GAME_FRAGS
], gStdFont
, 255, 127, 0, 1);
1243 e_TextureFontPrintEx(x
+16+w1
+w2
+w3
, _y
, _lc
[I_GAME_DEATHS
], gStdFont
, 255, 127, 0, 1);
1246 for aa
:= 0 to High(stat
) do
1260 e_DrawFillQuad(x
+16, _y
+4, x
+32-1, _y
+16+4-1, Color
.R
, Color
.G
, Color
.B
, 0);
1261 e_DrawQuad(x
+16, _y
+4, x
+32-1, _y
+16+4-1, 192, 192, 192);
1263 e_TextureFontPrintEx(x
+16+16+8, _y
+4, Name
, gStdFont
, r
, g
, 0, 1);
1265 e_TextureFontPrintEx(x
+w1
+16, _y
+4, Format(_lc
[I_GAME_PING_MS
], [Ping
, Loss
]), gStdFont
, r
, g
, 0, 1);
1267 e_TextureFontPrintEx(x
+w1
+w2
+16, _y
+4, IntToStr(Frags
), gStdFont
, r
, g
, 0, 1);
1269 e_TextureFontPrintEx(x
+w1
+w2
+w3
+16, _y
+4, IntToStr(Deaths
), gStdFont
, r
, g
, 0, 1);
1275 procedure g_Game_Init();
1281 gTempDelete
:= False;
1283 sfsGCDisable(); // temporary disable removing of temporary volumes
1286 TEXTUREFILTER
:= GL_LINEAR
;
1287 g_Texture_CreateWADEx('MENU_BACKGROUND', GameWAD
+':TEXTURES\TITLE');
1288 g_Texture_CreateWADEx('INTER', GameWAD
+':TEXTURES\INTER');
1289 g_Texture_CreateWADEx('ENDGAME_EN', GameWAD
+':TEXTURES\ENDGAME_EN');
1290 g_Texture_CreateWADEx('ENDGAME_RU', GameWAD
+':TEXTURES\ENDGAME_RU');
1291 TEXTUREFILTER
:= GL_NEAREST
;
1293 LoadStdFont('STDTXT', 'STDFONT', gStdFont
);
1294 LoadFont('MENUTXT', 'MENUFONT', gMenuFont
);
1295 LoadFont('SMALLTXT', 'SMALLFONT', gMenuSmallFont
);
1297 g_Game_ClearLoading();
1298 g_Game_SetLoadingText(Format('Doom 2D: Forever %s', [GAME_VERSION
]), 0, False);
1299 g_Game_SetLoadingText('', 0, False);
1301 g_Game_SetLoadingText(_lc
[I_LOAD_CONSOLE
], 0, False);
1304 g_Game_SetLoadingText(_lc
[I_LOAD_MODELS
], 0, False);
1305 g_PlayerModel_LoadData();
1307 if FindFirst(ModelsDir
+'*.wad', faAnyFile
, SR
) = 0 then
1309 if not g_PlayerModel_Load(ModelsDir
+SR
.Name
) then
1310 e_WriteLog(Format('Error loading model %s', [SR
.Name
]), TMsgType
.Warning
);
1311 until FindNext(SR
) <> 0;
1314 if FindFirst(ModelsDir
+'*.pk3', faAnyFile
, SR
) = 0 then
1316 if not g_PlayerModel_Load(ModelsDir
+SR
.Name
) then
1317 e_WriteLog(Format('Error loading model %s', [SR
.Name
]), TMsgType
.Warning
);
1318 until FindNext(SR
) <> 0;
1321 if FindFirst(ModelsDir
+'*.zip', faAnyFile
, SR
) = 0 then
1323 if not g_PlayerModel_Load(ModelsDir
+SR
.Name
) then
1324 e_WriteLog(Format('Error loading model %s', [SR
.Name
]), TMsgType
.Warning
);
1325 until FindNext(SR
) <> 0;
1329 gPauseMain
:= false;
1330 gPauseHolmes
:= false;
1333 {e_MouseInfo.Accel := 1.0;}
1335 g_Game_SetLoadingText(_lc
[I_LOAD_GAME_DATA
], 0, False);
1338 g_Game_SetLoadingText(_lc
[I_LOAD_MUSIC
], 0, False);
1339 g_Sound_CreateWADEx('MUSIC_INTERMUS', GameWAD
+':MUSIC\INTERMUS', True);
1340 g_Sound_CreateWADEx('MUSIC_MENU', GameWAD
+':MUSIC\MENU', True);
1341 g_Sound_CreateWADEx('MUSIC_ROUNDMUS', GameWAD
+':MUSIC\ROUNDMUS', True, True);
1342 g_Sound_CreateWADEx('MUSIC_STDENDMUS', GameWAD
+':MUSIC\ENDMUS', True);
1344 g_Game_SetLoadingText(_lc
[I_LOAD_MENUS
], 0, False);
1347 gMusic
:= TMusic
.Create();
1348 gMusic
.SetByName('MUSIC_MENU');
1351 gGameSettings
.WarmupTime
:= 30;
1353 gState
:= STATE_MENU
;
1355 SetLength(gEvents
, 6);
1356 gEvents
[0].Name
:= 'ongamestart';
1357 gEvents
[1].Name
:= 'ongameend';
1358 gEvents
[2].Name
:= 'onmapstart';
1359 gEvents
[3].Name
:= 'onmapend';
1360 gEvents
[4].Name
:= 'oninter';
1361 gEvents
[5].Name
:= 'onwadend';
1363 sfsGCEnable(); // enable releasing unused volumes
1367 procedure g_Game_Free(freeTextures
: Boolean=true);
1369 if NetMode
= NET_CLIENT
then g_Net_Disconnect();
1370 if NetMode
= NET_SERVER
then g_Net_Host_Die();
1372 g_Map_Free(freeTextures
);
1374 g_Player_RemoveAllCorpses();
1376 gGameSettings
.GameType
:= GT_NONE
;
1377 if gGameSettings
.GameMode
= GM_SINGLE
then
1378 gGameSettings
.GameMode
:= GM_DM
;
1379 gSwitchGameMode
:= gGameSettings
.GameMode
;
1382 gExitByTrigger
:= False;
1385 function IsActivePlayer(p
: TPlayer
): Boolean;
1390 Result
:= (not p
.FDummy
) and (not p
.FSpectator
);
1393 function GetActivePlayer_ByID(ID
: Integer): TPlayer
;
1400 if gPlayers
= nil then
1402 for a
:= Low(gPlayers
) to High(gPlayers
) do
1403 if IsActivePlayer(gPlayers
[a
]) then
1405 if gPlayers
[a
].UID
<> ID
then
1407 Result
:= gPlayers
[a
];
1412 function GetActivePlayerID_Next(Skip
: Integer = -1): Integer;
1418 if gPlayers
= nil then
1422 for a
:= Low(gPlayers
) to High(gPlayers
) do
1423 if IsActivePlayer(gPlayers
[a
]) then
1425 SetLength(ids
, Length(ids
) + 1);
1426 ids
[High(ids
)] := gPlayers
[a
].UID
;
1427 if gPlayers
[a
].UID
= Skip
then
1430 if Length(ids
) = 0 then
1435 Result
:= ids
[(idx
+ 1) mod Length(ids
)];
1438 function GetActivePlayerID_Prev(Skip
: Integer = -1): Integer;
1444 if gPlayers
= nil then
1448 for a
:= Low(gPlayers
) to High(gPlayers
) do
1449 if IsActivePlayer(gPlayers
[a
]) then
1451 SetLength(ids
, Length(ids
) + 1);
1452 ids
[High(ids
)] := gPlayers
[a
].UID
;
1453 if gPlayers
[a
].UID
= Skip
then
1456 if Length(ids
) = 0 then
1459 Result
:= ids
[Length(ids
) - 1]
1461 Result
:= ids
[(Length(ids
) - 1 + idx
) mod Length(ids
)];
1464 function GetActivePlayerID_Random(Skip
: Integer = -1): Integer;
1470 if gPlayers
= nil then
1474 for a
:= Low(gPlayers
) to High(gPlayers
) do
1475 if IsActivePlayer(gPlayers
[a
]) then
1477 SetLength(ids
, Length(ids
) + 1);
1478 ids
[High(ids
)] := gPlayers
[a
].UID
;
1479 if gPlayers
[a
].UID
= Skip
then
1482 if Length(ids
) = 0 then
1484 if Length(ids
) = 1 then
1489 Result
:= ids
[Random(Length(ids
))];
1491 while (idx
<> -1) and (Result
= Skip
) and (a
> 0) do
1493 Result
:= ids
[Random(Length(ids
))];
1498 function GetRandomSpectMode(Current
: Byte): Byte;
1505 0: Result
:= SPECT_STATS
;
1506 1: Result
:= SPECT_MAPVIEW
;
1507 2: Result
:= SPECT_MAPVIEW
;
1508 3: Result
:= SPECT_PLAYERS
;
1509 4: Result
:= SPECT_PLAYERS
;
1510 5: Result
:= SPECT_PLAYERS
;
1511 6: Result
:= SPECT_PLAYERS
;
1513 if (Current
in [SPECT_STATS
, SPECT_MAPVIEW
]) and (Current
= Result
) then
1517 procedure ProcessPlayerControls (plr
: TPlayer
; p
: Integer; var MoveButton
: Byte);
1523 if (plr
= nil) then exit
;
1524 if (p
= 2) then time
:= 1000 else time
:= 1;
1525 strafeDir
:= MoveButton
shr 4;
1526 MoveButton
:= MoveButton
and $0F;
1528 if gPlayerAction
[p
, ACTION_MOVELEFT
] and (not gPlayerAction
[p
, ACTION_MOVERIGHT
]) then
1529 MoveButton
:= 1 // Íàæàòà òîëüêî "Âëåâî"
1530 else if (not gPlayerAction
[p
, ACTION_MOVELEFT
]) and gPlayerAction
[p
, ACTION_MOVERIGHT
] then
1531 MoveButton
:= 2 // Íàæàòà òîëüêî "Âïðàâî"
1532 else if (not gPlayerAction
[p
, ACTION_MOVELEFT
]) and (not gPlayerAction
[p
, ACTION_MOVERIGHT
]) then
1533 MoveButton
:= 0; // Íå íàæàòû íè "Âëåâî", íè "Âïðàâî"
1535 // Ñåé÷àñ èëè ðàíüøå áûëè íàæàòû "Âëåâî"/"Âïðàâî" => ïåðåäàåì èãðîêó:
1536 if MoveButton
= 1 then
1537 plr
.PressKey(KEY_LEFT
, time
)
1538 else if MoveButton
= 2 then
1539 plr
.PressKey(KEY_RIGHT
, time
);
1541 // if we have "strafe" key, turn off old strafe mechanics
1542 if gPlayerAction
[p
, ACTION_STRAFE
] then
1544 // new strafe mechanics
1545 if (strafeDir
= 0) then
1546 strafeDir
:= MoveButton
; // start strafing
1547 // now set direction according to strafe (reversed)
1548 if (strafeDir
= 2) then
1549 plr
.SetDirection(TDirection
.D_LEFT
)
1550 else if (strafeDir
= 1) then
1551 plr
.SetDirection(TDirection
.D_RIGHT
)
1555 strafeDir
:= 0; // not strafing anymore
1556 // Ðàíüøå áûëà íàæàòà "Âïðàâî", à ñåé÷àñ "Âëåâî" => áåæèì âïðàâî, ñìîòðèì âëåâî:
1557 if (MoveButton
= 2) and gPlayerAction
[p
, ACTION_MOVELEFT
] then
1558 plr
.SetDirection(TDirection
.D_LEFT
)
1559 // Ðàíüøå áûëà íàæàòà "Âëåâî", à ñåé÷àñ "Âïðàâî" => áåæèì âëåâî, ñìîòðèì âïðàâî:
1560 else if (MoveButton
= 1) and gPlayerAction
[p
, ACTION_MOVERIGHT
] then
1561 plr
.SetDirection(TDirection
.D_RIGHT
)
1562 // ×òî-òî áûëî íàæàòî è íå èçìåíèëîñü => êóäà áåæèì, òóäà è ñìîòðèì:
1563 else if MoveButton
<> 0 then
1564 plr
.SetDirection(TDirection(MoveButton
-1))
1567 // fix movebutton state
1568 MoveButton
:= MoveButton
or (strafeDir
shl 4);
1570 // Îñòàëüíûå êëàâèøè:
1571 if gPlayerAction
[p
, ACTION_JUMP
] then plr
.PressKey(KEY_JUMP
, time
);
1572 if gPlayerAction
[p
, ACTION_LOOKUP
] then plr
.PressKey(KEY_UP
, time
);
1573 if gPlayerAction
[p
, ACTION_LOOKDOWN
] then plr
.PressKey(KEY_DOWN
, time
);
1574 if gPlayerAction
[p
, ACTION_ATTACK
] then plr
.PressKey(KEY_FIRE
);
1575 if gPlayerAction
[p
, ACTION_WEAPNEXT
] then plr
.PressKey(KEY_NEXTWEAPON
);
1576 if gPlayerAction
[p
, ACTION_WEAPPREV
] then plr
.PressKey(KEY_PREVWEAPON
);
1577 if gPlayerAction
[p
, ACTION_ACTIVATE
] then plr
.PressKey(KEY_OPEN
);
1579 gPlayerAction
[p
, ACTION_WEAPNEXT
] := False; // HACK, remove after readyweaon&pendinweapon implementation
1580 gPlayerAction
[p
, ACTION_WEAPPREV
] := False; // HACK, remove after readyweaon&pendinweapon implementation
1582 for i
:= WP_FIRST
to WP_LAST
do
1584 if gSelectWeapon
[p
, i
] then
1586 plr
.QueueWeaponSwitch(i
); // all choices are passed there, and god will take the best
1587 gSelectWeapon
[p
, i
] := False
1591 // HACK: add dynlight here
1592 if gwin_k8_enable_light_experiments
then
1594 if e_KeyPressed(IK_F8
) and gGameOn
and (not gConsoleShow
) and (g_ActiveWindow
= nil) then
1596 g_playerLight
:= true;
1598 if e_KeyPressed(IK_F9
) and gGameOn
and (not gConsoleShow
) and (g_ActiveWindow
= nil) then
1600 g_playerLight
:= false;
1604 if gwin_has_stencil
and g_playerLight
then g_AddDynLight(plr
.GameX
+32, plr
.GameY
+40, 128, 1, 1, 0, 0.6);
1607 // HACK: don't have a "key was pressed" function
1608 procedure InterReady();
1610 if InterReadyTime
> gTime
then Exit
;
1611 InterReadyTime
:= gTime
+ 3000;
1612 MC_SEND_CheatRequest(NET_CHEAT_READY
);
1615 procedure g_Game_Update();
1617 Msg
: g_gui
.TMessage
;
1623 function sendMonsPos (mon
: TMonster
): Boolean;
1625 result
:= false; // don't stop
1626 // this will also reset "need-send" flag
1627 if mon
.gncNeedSend
then
1629 MH_SEND_MonsterPos(mon
.UID
);
1631 else if (mon
.MonsterType
= MONSTER_BARREL
) then
1633 if (mon
.GameVelX
<> 0) or (mon
.GameVelY
<> 0) then MH_SEND_MonsterPos(mon
.UID
);
1635 else if (mon
.MonsterState
<> MONSTATE_SLEEP
) then
1637 if (mon
.MonsterState
<> MONSTATE_DEAD
) or (mon
.GameVelX
<> 0) or (mon
.GameVelY
<> 0) then MH_SEND_MonsterPos(mon
.UID
);
1641 function sendMonsPosUnexpected (mon
: TMonster
): Boolean;
1643 result
:= false; // don't stop
1644 // this will also reset "need-send" flag
1645 if mon
.gncNeedSend
then MH_SEND_MonsterPos(mon
.UID
);
1649 reliableUpdate
: Boolean;
1654 // Ïîðà âûêëþ÷àòü èãðó:
1655 if gExit
= EXIT_QUIT
then
1657 // Èãðà çàêîí÷èëàñü - îáðàáàòûâàåì:
1661 if gExit
= EXIT_QUIT
then
1665 // ×èòàåì êëàâèàòóðó è äæîéñòèê, åñëè îêíî àêòèâíî
1666 // no need to, as we'll do it in event handler
1668 // Îáíîâëÿåì êîíñîëü (äâèæåíèå è ñîîáùåíèÿ):
1671 if (NetMode
= NET_NONE
) and (g_Game_IsNet
) and (gGameOn
or (gState
in [STATE_FOLD
, STATE_INTERCUSTOM
])) then
1673 gExit
:= EXIT_SIMPLE
;
1679 STATE_INTERSINGLE
, // Ñòàòèñòêà ïîñëå ïðîõîæäåíèÿ óðîâíÿ â Îäèíî÷íîé èãðå
1680 STATE_INTERCUSTOM
, // Ñòàòèñòêà ïîñëå ïðîõîæäåíèÿ óðîâíÿ â Ñâîåé èãðå
1681 STATE_INTERTEXT
, // Òåêñò ìåæäó óðîâíÿìè
1682 STATE_INTERPIC
: // Êàðòèíêà ìåæäó óðîâíÿìè
1684 if g_Game_IsNet
and g_Game_IsServer
then
1686 gInterTime
:= gInterTime
+ GAME_TICK
;
1687 a
:= Min((gInterEndTime
- gInterTime
) div 1000 + 1, 255);
1688 if a
<> gServInterTime
then
1690 gServInterTime
:= a
;
1691 MH_SEND_TimeSync(gServInterTime
);
1695 if (not g_Game_IsClient
) and
1699 e_KeyPressed(IK_RETURN
) or e_KeyPressed(IK_KPRETURN
) or e_KeyPressed(IK_SPACE
) or
1700 e_KeyPressed(VK_FIRE
) or e_KeyPressed(VK_OPEN
) or
1701 e_KeyPressed(JOY0_ATTACK
) or e_KeyPressed(JOY1_ATTACK
) or
1702 e_KeyPressed(JOY2_ATTACK
) or e_KeyPressed(JOY3_ATTACK
)
1704 and (not gJustChatted
) and (not gConsoleShow
) and (not gChatShow
)
1705 and (g_ActiveWindow
= nil)
1707 or (g_Game_IsNet
and ((gInterTime
> gInterEndTime
) or (gInterReadyCount
>= NetClientCount
)))
1710 begin // Íàæàëè <Enter>/<Ïðîáåë> èëè ïðîøëî äîñòàòî÷íî âðåìåíè:
1711 g_Game_StopAllSounds(True);
1713 if gMapOnce
then // Ýòî áûë òåñò
1714 gExit
:= EXIT_SIMPLE
1716 if gNextMap
<> '' then // Ïåðåõîäèì íà ñëåäóþùóþ êàðòó
1717 g_Game_ChangeMap(gNextMap
)
1718 else // Ñëåäóþùåé êàðòû íåò
1720 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
] then
1722 // Âûõîä â ãëàâíîå ìåíþ:
1724 g_GUI_ShowWindow('MainMenu');
1725 gMusic
.SetByName('MUSIC_MENU');
1727 gState
:= STATE_MENU
;
1730 // Ôèíàëüíàÿ êàðòèíêà:
1731 g_Game_ExecuteEvent('onwadend');
1733 if not gMusic
.SetByName('MUSIC_endmus') then
1734 gMusic
.SetByName('MUSIC_STDENDMUS');
1736 gState
:= STATE_ENDPIC
;
1738 g_Game_ExecuteEvent('ongameend');
1743 else if g_Game_IsClient
and
1746 e_KeyPressed(IK_RETURN
) or e_KeyPressed(IK_KPRETURN
) or e_KeyPressed(IK_SPACE
) or
1747 e_KeyPressed(VK_FIRE
) or e_KeyPressed(VK_OPEN
) or
1748 e_KeyPressed(JOY0_ATTACK
) or e_KeyPressed(JOY1_ATTACK
) or
1749 e_KeyPressed(JOY2_ATTACK
) or e_KeyPressed(JOY3_ATTACK
)
1751 and (not gJustChatted
) and (not gConsoleShow
) and (not gChatShow
)
1752 and (g_ActiveWindow
= nil)
1760 if gState
= STATE_INTERTEXT
then
1761 if InterText
.counter
> 0 then
1762 InterText
.counter
:= InterText
.counter
- 1;
1765 STATE_FOLD
: // Çàòóõàíèå ýêðàíà
1767 if EndingGameCounter
= 0 then
1769 // Çàêîí÷èëñÿ óðîâåíü â Ñâîåé èãðå:
1770 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
1772 InterReadyTime
:= -1;
1773 if gLastMap
and (gGameSettings
.GameMode
= GM_COOP
) then
1775 g_Game_ExecuteEvent('onwadend');
1776 if not gMusic
.SetByName('MUSIC_endmus') then
1777 gMusic
.SetByName('MUSIC_STDENDMUS');
1780 gMusic
.SetByName('MUSIC_ROUNDMUS');
1783 gState
:= STATE_INTERCUSTOM
;
1786 else // Çàêîí÷èëàñü ïîñëåäíÿÿ êàðòà â Îäèíî÷íîé èãðå
1788 gMusic
.SetByName('MUSIC_INTERMUS');
1790 gState
:= STATE_INTERSINGLE
;
1793 g_Game_ExecuteEvent('oninter');
1796 DecMin(EndingGameCounter
, 6, 0);
1799 STATE_ENDPIC
: // Êàðòèíêà îêîí÷àíèÿ ìåãàÂàäà
1801 if gMapOnce
then // Ýòî áûë òåñò
1803 gExit
:= EXIT_SIMPLE
;
1809 g_Serverlist_Control(slCurrent
, slTable
);
1812 // Ñòàòèñòèêà ïî Tab:
1814 IsDrawStat
:= (not gConsoleShow
) and (not gChatShow
) and (gGameSettings
.GameType
<> GT_SINGLE
) and g_Console_Action(ACTION_SCORES
);
1817 if gGameOn
and not gPause
and (gState
<> STATE_FOLD
) then
1819 // Âðåìÿ += 28 ìèëëèñåêóíä:
1820 gTime
:= gTime
+ GAME_TICK
;
1822 // Ñîîáùåíèå ïîñåðåäèíå ýêðàíà:
1823 if MessageTime
= 0 then
1825 if MessageTime
> 0 then
1826 MessageTime
:= MessageTime
- 1;
1828 if (g_Game_IsServer
) then
1830 // Áûë çàäàí ëèìèò âðåìåíè:
1831 if (gGameSettings
.TimeLimit
> 0) then
1832 if (gTime
- gGameStartTime
) div 1000 >= gGameSettings
.TimeLimit
then
1833 begin // Îí ïðîøåë => êîíåö óðîâíÿ
1838 // Íàäî ðåñïàâíèòü èãðîêîâ â LMS:
1839 if (gLMSRespawn
> LMS_RESPAWN_NONE
) and (gLMSRespawnTime
< gTime
) then
1840 g_Game_RestartRound(gLMSSoftSpawn
);
1842 // Ïðîâåðèì ðåçóëüòàò ãîëîñîâàíèÿ, åñëè âðåìÿ ïðîøëî
1843 if gVoteInProgress
and (gVoteTimer
< gTime
) then
1845 else if gVotePassed
and (gVoteCmdTimer
< gTime
) then
1847 g_Console_Process(gVoteCommand
);
1849 gVotePassed
:= False;
1852 // Çàìåðÿåì âðåìÿ çàõâàòà ôëàãîâ
1853 if gFlags
[FLAG_RED
].State
= FLAG_STATE_CAPTURED
then
1854 gFlags
[FLAG_RED
].CaptureTime
:= gFlags
[FLAG_RED
].CaptureTime
+ GAME_TICK
;
1855 if gFlags
[FLAG_BLUE
].State
= FLAG_STATE_CAPTURED
then
1856 gFlags
[FLAG_BLUE
].CaptureTime
:= gFlags
[FLAG_BLUE
].CaptureTime
+ GAME_TICK
;
1858 // Áûë çàäàí ëèìèò ïîáåä:
1859 if (gGameSettings
.GoalLimit
> 0) then
1863 if gGameSettings
.GameMode
= GM_DM
then
1864 begin // Â DM èùåì èãðîêà ñ max ôðàãàìè
1865 for i
:= 0 to High(gPlayers
) do
1866 if gPlayers
[i
] <> nil then
1867 if gPlayers
[i
].Frags
> b
then
1868 b
:= gPlayers
[i
].Frags
;
1871 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
1872 begin //  CTF/TDM âûáèðàåì êîìàíäó ñ íàèáîëüøèì ñ÷åòîì
1873 b
:= Max(gTeamStat
[TEAM_RED
].Goals
, gTeamStat
[TEAM_BLUE
].Goals
);
1876 // Ëèìèò ïîáåä íàáðàí => êîíåö óðîâíÿ:
1877 if b
>= gGameSettings
.GoalLimit
then
1884 // Îáðàáàòûâàåì êëàâèøè èãðîêîâ:
1885 if gPlayer1
<> nil then gPlayer1
.ReleaseKeys();
1886 if gPlayer2
<> nil then gPlayer2
.ReleaseKeys();
1887 if (not gConsoleShow
) and (not gChatShow
) and (g_ActiveWindow
= nil) then
1889 ProcessPlayerControls(gPlayer1
, 0, P1MoveButton
);
1890 ProcessPlayerControls(gPlayer2
, 1, P2MoveButton
);
1891 end // if not console
1894 if g_Game_IsNet
and (gPlayer1
<> nil) then gPlayer1
.PressKey(KEY_CHAT
, 10000);
1896 // process weapon switch queue
1900 if (gPlayer1
= nil) and (gPlayer2
= nil) and
1901 (not gConsoleShow
) and (not gChatShow
) and (g_ActiveWindow
= nil) then
1903 if not gSpectKeyPress
then
1905 if gPlayerAction
[0, ACTION_JUMP
] and (not gSpectAuto
) then
1907 // switch spect mode
1909 SPECT_NONE
: ; // not spectator
1911 SPECT_MAPVIEW
: Inc(gSpectMode
);
1912 SPECT_PLAYERS
: gSpectMode
:= SPECT_STATS
; // reset to 1
1914 gSpectKeyPress
:= True;
1916 if (gSpectMode
= SPECT_MAPVIEW
)
1917 and (not gSpectAuto
) then
1919 if gPlayerAction
[0, ACTION_MOVELEFT
] then
1920 gSpectX
:= Max(gSpectX
- gSpectStep
, 0);
1921 if gPlayerAction
[0, ACTION_MOVERIGHT
] then
1922 gSpectX
:= Min(gSpectX
+ gSpectStep
, gMapInfo
.Width
- gScreenWidth
);
1923 if gPlayerAction
[0, ACTION_LOOKUP
] then
1924 gSpectY
:= Max(gSpectY
- gSpectStep
, 0);
1925 if gPlayerAction
[0, ACTION_LOOKDOWN
] then
1926 gSpectY
:= Min(gSpectY
+ gSpectStep
, gMapInfo
.Height
- gScreenHeight
);
1927 if gPlayerAction
[0, ACTION_WEAPPREV
] then
1930 if gSpectStep
> 4 then gSpectStep
:= gSpectStep
shr 1;
1931 gSpectKeyPress
:= True;
1933 if gPlayerAction
[0, ACTION_WEAPNEXT
] then
1936 if gSpectStep
< 64 then gSpectStep
:= gSpectStep
shl 1;
1937 gSpectKeyPress
:= True;
1940 if (gSpectMode
= SPECT_PLAYERS
)
1941 and (not gSpectAuto
) then
1943 if gPlayerAction
[0, ACTION_LOOKUP
] then
1946 gSpectViewTwo
:= True;
1947 gSpectKeyPress
:= True;
1949 if gPlayerAction
[0, ACTION_LOOKDOWN
] then
1951 // remove second view
1952 gSpectViewTwo
:= False;
1953 gSpectKeyPress
:= True;
1955 if gPlayerAction
[0, ACTION_MOVELEFT
] then
1957 // prev player (view 1)
1958 gSpectPID1
:= GetActivePlayerID_Prev(gSpectPID1
);
1959 gSpectKeyPress
:= True;
1961 if gPlayerAction
[0, ACTION_MOVERIGHT
] then
1963 // next player (view 1)
1964 gSpectPID1
:= GetActivePlayerID_Next(gSpectPID1
);
1965 gSpectKeyPress
:= True;
1967 if gPlayerAction
[0, ACTION_WEAPPREV
] then
1969 // prev player (view 2)
1970 gSpectPID2
:= GetActivePlayerID_Prev(gSpectPID2
);
1971 gSpectKeyPress
:= True;
1973 if gPlayerAction
[0, ACTION_WEAPNEXT
] then
1975 // next player (view 2)
1976 gSpectPID2
:= GetActivePlayerID_Next(gSpectPID2
);
1977 gSpectKeyPress
:= True;
1980 if gPlayerAction
[0, ACTION_ATTACK
] then
1982 if (gSpectMode
= SPECT_STATS
) and (not gSpectAuto
) then
1985 gSpectAutoNext
:= 0;
1986 gSpectViewTwo
:= False;
1987 gSpectKeyPress
:= True;
1992 gSpectMode
:= SPECT_STATS
;
1993 gSpectAuto
:= False;
1994 gSpectKeyPress
:= True;
1999 if (not gPlayerAction
[0, ACTION_JUMP
]) and
2000 (not gPlayerAction
[0, ACTION_ATTACK
]) and
2001 (not gPlayerAction
[0, ACTION_MOVELEFT
]) and
2002 (not gPlayerAction
[0, ACTION_MOVERIGHT
]) and
2003 (not gPlayerAction
[0, ACTION_LOOKUP
]) and
2004 (not gPlayerAction
[0, ACTION_LOOKDOWN
]) and
2005 (not gPlayerAction
[0, ACTION_WEAPPREV
]) and
2006 (not gPlayerAction
[0, ACTION_WEAPNEXT
]) then
2007 gSpectKeyPress
:= False;
2011 if gSpectMode
= SPECT_MAPVIEW
then
2013 i
:= Min(Max(gSpectX
+ gSpectAutoStepX
, 0), gMapInfo
.Width
- gScreenWidth
);
2015 gSpectAutoNext
:= gTime
2018 i
:= Min(Max(gSpectY
+ gSpectAutoStepY
, 0), gMapInfo
.Height
- gScreenHeight
);
2020 gSpectAutoNext
:= gTime
2024 if gSpectAutoNext
<= gTime
then
2026 if gSpectAutoNext
> 0 then
2028 gSpectMode
:= GetRandomSpectMode(gSpectMode
);
2032 gSpectX
:= Random(gMapInfo
.Width
- gScreenWidth
);
2033 gSpectY
:= Random(gMapInfo
.Height
- gScreenHeight
);
2034 gSpectAutoStepX
:= Random(9) - 4;
2035 gSpectAutoStepY
:= Random(9) - 4;
2036 if ((gSpectX
< 800) and (gSpectAutoStepX
< 0)) or
2037 ((gSpectX
> gMapInfo
.Width
- gScreenWidth
- 800) and (gSpectAutoStepX
> 0)) then
2038 gSpectAutoStepX
:= gSpectAutoStepX
* -1;
2039 if ((gSpectY
< 800) and (gSpectAutoStepY
< 0)) or
2040 ((gSpectY
> gMapInfo
.Height
- gScreenHeight
- 800) and (gSpectAutoStepY
> 0)) then
2041 gSpectAutoStepY
:= gSpectAutoStepY
* -1;
2045 gSpectPID1
:= GetActivePlayerID_Random(gSpectPID1
);
2050 SPECT_STATS
: gSpectAutoNext
:= gTime
+ (Random(3) + 5) * 1000;
2051 SPECT_MAPVIEW
: gSpectAutoNext
:= gTime
+ (Random(4) + 7) * 1000;
2052 SPECT_PLAYERS
: gSpectAutoNext
:= gTime
+ (Random(7) + 8) * 1000;
2058 // Îáíîâëÿåì âñå îñòàëüíîå:
2061 g_Triggers_Update();
2063 g_Monsters_Update();
2065 g_Player_UpdateAll();
2066 g_Player_UpdatePhysicalObjects();
2068 // server: send newly spawned monsters unconditionally
2069 if (gGameSettings
.GameType
= GT_SERVER
) then
2071 if (Length(gMonstersSpawned
) > 0) then
2073 for I
:= 0 to High(gMonstersSpawned
) do MH_SEND_MonsterSpawn(gMonstersSpawned
[I
]);
2074 SetLength(gMonstersSpawned
, 0);
2078 if (gSoundTriggerTime
> 8) then
2080 g_Game_UpdateTriggerSounds();
2081 gSoundTriggerTime
:= 0;
2085 Inc(gSoundTriggerTime
);
2088 if (NetMode
= NET_SERVER
) then
2090 Inc(NetTimeToUpdate
);
2091 Inc(NetTimeToReliable
);
2093 // send monster updates
2094 if (NetTimeToReliable
>= NetRelupdRate
) or (NetTimeToUpdate
>= NetUpdateRate
) then
2096 // send all monsters (periodic sync)
2097 reliableUpdate
:= (NetTimeToReliable
>= NetRelupdRate
);
2099 for I
:= 0 to High(gPlayers
) do
2101 if (gPlayers
[I
] <> nil) then MH_SEND_PlayerPos(reliableUpdate
, gPlayers
[I
].UID
);
2104 g_Mons_ForEach(sendMonsPos
);
2106 if reliableUpdate
then
2108 NetTimeToReliable
:= 0;
2109 NetTimeToUpdate
:= NetUpdateRate
;
2113 NetTimeToUpdate
:= 0;
2118 // send only mosters with some unexpected changes
2119 g_Mons_ForEach(sendMonsPosUnexpected
);
2122 // send unexpected platform changes
2123 g_Map_NetSendInterestingPanels();
2125 if NetUseMaster
then
2127 if gTime
>= NetTimeToMaster
then
2129 if (NetMHost
= nil) or (NetMPeer
= nil) then
2131 if not g_Net_Slist_Connect
then g_Console_Add(_lc
[I_NET_MSG_ERROR
] + _lc
[I_NET_SLIST_ERROR
]);
2135 NetTimeToMaster
:= gTime
+ NetMasterRate
;
2139 else if (NetMode
= NET_CLIENT
) then
2141 MC_SEND_PlayerPos();
2143 end; // if gameOn ...
2145 // Àêòèâíî îêíî èíòåðôåéñà - ïåðåäàåì êëàâèøè åìó:
2146 if g_ActiveWindow
<> nil then
2148 w
:= e_GetFirstKeyPressed();
2150 if (w
<> IK_INVALID
) then
2152 Msg
.Msg
:= MESSAGE_DIKEY
;
2154 g_ActiveWindow
.OnMessage(Msg
);
2157 // Åñëè îíî îò ýòîãî íå çàêðûëîñü, òî îáíîâëÿåì:
2158 if g_ActiveWindow
<> nil then
2159 g_ActiveWindow
.Update();
2161 // Íóæíî ñìåíèòü ðàçðåøåíèå:
2162 if gResolutionChange
then
2164 e_WriteLog('Changing resolution', TMsgType
.Notify
);
2165 g_Game_ChangeResolution(gRC_Width
, gRC_Height
, gRC_FullScreen
, gRC_Maximized
);
2166 gResolutionChange
:= False;
2167 g_ActiveWindow
:= nil;
2170 // Íóæíî ñìåíèòü ÿçûê:
2171 if gLanguageChange
then
2173 //e_WriteLog('Read language file', MSG_NOTIFY);
2174 //g_Language_Load(DataDir + gLanguage + '.txt');
2175 g_Language_Set(gLanguage
);
2177 gLanguageChange
:= False;
2181 // Ãîðÿ÷àÿ êëàâèøà äëÿ âûçîâà ìåíþ âûõîäà èç èãðû (F10):
2182 if e_KeyPressed(IK_F10
) and
2184 (not gConsoleShow
) and
2185 (g_ActiveWindow
= nil) then
2190 Time
:= GetTimer() {div 1000};
2192 // Îáðàáîòêà îòëîæåííûõ ñîáûòèé:
2193 if gDelayedEvents
<> nil then
2194 for a
:= 0 to High(gDelayedEvents
) do
2195 if gDelayedEvents
[a
].Pending
and
2197 ((gDelayedEvents
[a
].DEType
= DE_GLOBEVENT
) and (gDelayedEvents
[a
].Time
<= Time
)) or
2198 ((gDelayedEvents
[a
].DEType
> DE_GLOBEVENT
) and (gDelayedEvents
[a
].Time
<= gTime
))
2201 case gDelayedEvents
[a
].DEType
of
2203 g_Game_ExecuteEvent(gDelayedEvents
[a
].DEStr
);
2206 g_Game_Announce_GoodShot(gDelayedEvents
[a
].DENum
);
2210 g_Game_Announce_KillCombo(gDelayedEvents
[a
].DENum
);
2211 if g_Game_IsNet
and g_Game_IsServer
then
2212 MH_SEND_GameEvent(NET_EV_KILLCOMBO
, gDelayedEvents
[a
].DENum
);
2216 g_Game_Announce_BodyKill(gDelayedEvents
[a
].DENum
);
2218 gDelayedEvents
[a
].Pending
:= False;
2221 // Êàæäóþ ñåêóíäó îáíîâëÿåì ñ÷åò÷èê îáíîâëåíèé:
2222 UPSCounter
:= UPSCounter
+ 1;
2223 if Time
- UPSTime
>= 1000 then
2232 g_Weapon_AddDynLights();
2233 g_Items_AddDynLights();
2237 procedure g_Game_LoadChatSounds(Resource
: string);
2240 FileName
, Snd
: string;
2242 len
, cnt
, tags
, i
, j
: Integer;
2245 FileName
:= g_ExtractWadName(Resource
);
2247 WAD
:= TWADFile
.Create();
2248 WAD
.ReadFile(FileName
);
2250 if not WAD
.GetResource(g_ExtractFilePathName(Resource
), p
, len
) then
2257 cfg
:= TConfig
.CreateMem(p
, len
);
2258 cnt
:= cfg
.ReadInt('ChatSounds', 'Count', 0);
2260 SetLength(gChatSounds
, cnt
);
2261 for i
:= 0 to Length(gChatSounds
) - 1 do
2263 gChatSounds
[i
].Sound
:= nil;
2264 Snd
:= Trim(cfg
.ReadStr(IntToStr(i
), 'Sound', ''));
2265 tags
:= cfg
.ReadInt(IntToStr(i
), 'Tags', 0);
2266 if (Snd
= '') or (Tags
<= 0) then
2268 g_Sound_CreateWADEx('SOUND_CHAT_MACRO' + IntToStr(i
), GameWAD
+':'+Snd
);
2269 gChatSounds
[i
].Sound
:= TPlayableSound
.Create();
2270 gChatSounds
[i
].Sound
.SetByName('SOUND_CHAT_MACRO' + IntToStr(i
));
2271 SetLength(gChatSounds
[i
].Tags
, tags
);
2272 for j
:= 0 to tags
- 1 do
2273 gChatSounds
[i
].Tags
[j
] := toLowerCase1251(cfg
.ReadStr(IntToStr(i
), 'Tag' + IntToStr(j
), ''));
2274 gChatSounds
[i
].FullWord
:= cfg
.ReadBool(IntToStr(i
), 'FullWord', False);
2281 procedure g_Game_FreeChatSounds();
2285 for i
:= 0 to Length(gChatSounds
) - 1 do
2287 gChatSounds
[i
].Sound
.Free();
2288 g_Sound_Delete('SOUND_CHAT_MACRO' + IntToStr(i
));
2290 SetLength(gChatSounds
, 0);
2294 procedure g_Game_LoadData();
2301 if DataLoaded
then Exit
;
2303 e_WriteLog('Loading game data...', TMsgType
.Notify
);
2305 g_Texture_CreateWADEx('NOTEXTURE', GameWAD
+':TEXTURES\NOTEXTURE');
2306 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUD', GameWAD
+':TEXTURES\HUD');
2307 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDAIR', GameWAD
+':TEXTURES\AIRBAR');
2308 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDJET', GameWAD
+':TEXTURES\JETBAR');
2309 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDBG', GameWAD
+':TEXTURES\HUDBG');
2310 g_Texture_CreateWADEx('TEXTURE_PLAYER_ARMORHUD', GameWAD
+':TEXTURES\ARMORHUD');
2311 g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG', GameWAD
+':TEXTURES\FLAGHUD_R_BASE');
2312 g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG_S', GameWAD
+':TEXTURES\FLAGHUD_R_STOLEN');
2313 g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG_D', GameWAD
+':TEXTURES\FLAGHUD_R_DROP');
2314 g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG', GameWAD
+':TEXTURES\FLAGHUD_B_BASE');
2315 g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG_S', GameWAD
+':TEXTURES\FLAGHUD_B_STOLEN');
2316 g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG_D', GameWAD
+':TEXTURES\FLAGHUD_B_DROP');
2317 g_Texture_CreateWADEx('TEXTURE_PLAYER_TALKBUBBLE', GameWAD
+':TEXTURES\TALKBUBBLE');
2318 g_Texture_CreateWADEx('TEXTURE_PLAYER_INVULPENTA', GameWAD
+':TEXTURES\PENTA');
2319 g_Texture_CreateWADEx('TEXTURE_PLAYER_INDICATOR', GameWAD
+':TEXTURES\PLRIND');
2322 if not g_Texture_CreateWADEx('UI_GFX_PBAR_LEFT', GameWAD
+':TEXTURES\LLEFT') then hasPBarGfx
:= false;
2323 if not g_Texture_CreateWADEx('UI_GFX_PBAR_MARKER', GameWAD
+':TEXTURES\LMARKER') then hasPBarGfx
:= false;
2324 if not g_Texture_CreateWADEx('UI_GFX_PBAR_MIDDLE', GameWAD
+':TEXTURES\LMIDDLE') then hasPBarGfx
:= false;
2325 if not g_Texture_CreateWADEx('UI_GFX_PBAR_RIGHT', GameWAD
+':TEXTURES\LRIGHT') then hasPBarGfx
:= false;
2329 g_Texture_GetSize('UI_GFX_PBAR_LEFT', wl
, hl
);
2330 g_Texture_GetSize('UI_GFX_PBAR_RIGHT', wr
, hr
);
2331 g_Texture_GetSize('UI_GFX_PBAR_MIDDLE', wb
, hb
);
2332 g_Texture_GetSize('UI_GFX_PBAR_MARKER', wm
, hm
);
2333 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
2339 hasPBarGfx
:= false;
2343 g_Frames_CreateWAD(nil, 'FRAMES_TELEPORT', GameWAD
+':TEXTURES\TELEPORT', 64, 64, 10, False);
2344 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH', GameWAD
+':WEAPONS\PUNCH', 64, 64, 4, False);
2345 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_UP', GameWAD
+':WEAPONS\PUNCH_UP', 64, 64, 4, False);
2346 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_DN', GameWAD
+':WEAPONS\PUNCH_DN', 64, 64, 4, False);
2347 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_BERSERK', GameWAD
+':WEAPONS\PUNCHB', 64, 64, 4, False);
2348 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_BERSERK_UP', GameWAD
+':WEAPONS\PUNCHB_UP', 64, 64, 4, False);
2349 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_BERSERK_DN', GameWAD
+':WEAPONS\PUNCHB_DN', 64, 64, 4, False);
2350 g_Sound_CreateWADEx('SOUND_GAME_TELEPORT', GameWAD
+':SOUNDS\TELEPORT');
2351 g_Sound_CreateWADEx('SOUND_GAME_NOTELEPORT', GameWAD
+':SOUNDS\NOTELEPORT');
2352 g_Sound_CreateWADEx('SOUND_GAME_SECRET', GameWAD
+':SOUNDS\SECRET');
2353 g_Sound_CreateWADEx('SOUND_GAME_DOOROPEN', GameWAD
+':SOUNDS\DOOROPEN');
2354 g_Sound_CreateWADEx('SOUND_GAME_DOORCLOSE', GameWAD
+':SOUNDS\DOORCLOSE');
2355 g_Sound_CreateWADEx('SOUND_GAME_BULK1', GameWAD
+':SOUNDS\BULK1');
2356 g_Sound_CreateWADEx('SOUND_GAME_BULK2', GameWAD
+':SOUNDS\BULK2');
2357 g_Sound_CreateWADEx('SOUND_GAME_BUBBLE1', GameWAD
+':SOUNDS\BUBBLE1');
2358 g_Sound_CreateWADEx('SOUND_GAME_BUBBLE2', GameWAD
+':SOUNDS\BUBBLE2');
2359 g_Sound_CreateWADEx('SOUND_GAME_BURNING', GameWAD
+':SOUNDS\BURNING');
2360 g_Sound_CreateWADEx('SOUND_GAME_SWITCH1', GameWAD
+':SOUNDS\SWITCH1');
2361 g_Sound_CreateWADEx('SOUND_GAME_SWITCH0', GameWAD
+':SOUNDS\SWITCH0');
2362 g_Sound_CreateWADEx('SOUND_GAME_RADIO', GameWAD
+':SOUNDS\RADIO');
2363 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD1', GameWAD
+':SOUNDS\GOOD1');
2364 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD2', GameWAD
+':SOUNDS\GOOD2');
2365 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD3', GameWAD
+':SOUNDS\GOOD3');
2366 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD4', GameWAD
+':SOUNDS\GOOD4');
2367 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL2X', GameWAD
+':SOUNDS\KILL2X');
2368 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL3X', GameWAD
+':SOUNDS\KILL3X');
2369 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL4X', GameWAD
+':SOUNDS\KILL4X');
2370 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILLMX', GameWAD
+':SOUNDS\KILLMX');
2371 g_Sound_CreateWADEx('SOUND_ANNOUNCER_MUHAHA1', GameWAD
+':SOUNDS\MUHAHA1');
2372 g_Sound_CreateWADEx('SOUND_ANNOUNCER_MUHAHA2', GameWAD
+':SOUNDS\MUHAHA2');
2373 g_Sound_CreateWADEx('SOUND_ANNOUNCER_MUHAHA3', GameWAD
+':SOUNDS\MUHAHA3');
2374 g_Sound_CreateWADEx('SOUND_CTF_GET1', GameWAD
+':SOUNDS\GETFLAG1');
2375 g_Sound_CreateWADEx('SOUND_CTF_GET2', GameWAD
+':SOUNDS\GETFLAG2');
2376 g_Sound_CreateWADEx('SOUND_CTF_LOST1', GameWAD
+':SOUNDS\LOSTFLG1');
2377 g_Sound_CreateWADEx('SOUND_CTF_LOST2', GameWAD
+':SOUNDS\LOSTFLG2');
2378 g_Sound_CreateWADEx('SOUND_CTF_RETURN1', GameWAD
+':SOUNDS\RETFLAG1');
2379 g_Sound_CreateWADEx('SOUND_CTF_RETURN2', GameWAD
+':SOUNDS\RETFLAG2');
2380 g_Sound_CreateWADEx('SOUND_CTF_CAPTURE1', GameWAD
+':SOUNDS\CAPFLAG1');
2381 g_Sound_CreateWADEx('SOUND_CTF_CAPTURE2', GameWAD
+':SOUNDS\CAPFLAG2');
2383 goodsnd
[0] := TPlayableSound
.Create();
2384 goodsnd
[1] := TPlayableSound
.Create();
2385 goodsnd
[2] := TPlayableSound
.Create();
2386 goodsnd
[3] := TPlayableSound
.Create();
2388 goodsnd
[0].SetByName('SOUND_ANNOUNCER_GOOD1');
2389 goodsnd
[1].SetByName('SOUND_ANNOUNCER_GOOD2');
2390 goodsnd
[2].SetByName('SOUND_ANNOUNCER_GOOD3');
2391 goodsnd
[3].SetByName('SOUND_ANNOUNCER_GOOD4');
2393 killsnd
[0] := TPlayableSound
.Create();
2394 killsnd
[1] := TPlayableSound
.Create();
2395 killsnd
[2] := TPlayableSound
.Create();
2396 killsnd
[3] := TPlayableSound
.Create();
2398 killsnd
[0].SetByName('SOUND_ANNOUNCER_KILL2X');
2399 killsnd
[1].SetByName('SOUND_ANNOUNCER_KILL3X');
2400 killsnd
[2].SetByName('SOUND_ANNOUNCER_KILL4X');
2401 killsnd
[3].SetByName('SOUND_ANNOUNCER_KILLMX');
2403 hahasnd
[0] := TPlayableSound
.Create();
2404 hahasnd
[1] := TPlayableSound
.Create();
2405 hahasnd
[2] := TPlayableSound
.Create();
2407 hahasnd
[0].SetByName('SOUND_ANNOUNCER_MUHAHA1');
2408 hahasnd
[1].SetByName('SOUND_ANNOUNCER_MUHAHA2');
2409 hahasnd
[2].SetByName('SOUND_ANNOUNCER_MUHAHA3');
2411 sound_get_flag
[0] := TPlayableSound
.Create();
2412 sound_get_flag
[1] := TPlayableSound
.Create();
2413 sound_lost_flag
[0] := TPlayableSound
.Create();
2414 sound_lost_flag
[1] := TPlayableSound
.Create();
2415 sound_ret_flag
[0] := TPlayableSound
.Create();
2416 sound_ret_flag
[1] := TPlayableSound
.Create();
2417 sound_cap_flag
[0] := TPlayableSound
.Create();
2418 sound_cap_flag
[1] := TPlayableSound
.Create();
2420 sound_get_flag
[0].SetByName('SOUND_CTF_GET1');
2421 sound_get_flag
[1].SetByName('SOUND_CTF_GET2');
2422 sound_lost_flag
[0].SetByName('SOUND_CTF_LOST1');
2423 sound_lost_flag
[1].SetByName('SOUND_CTF_LOST2');
2424 sound_ret_flag
[0].SetByName('SOUND_CTF_RETURN1');
2425 sound_ret_flag
[1].SetByName('SOUND_CTF_RETURN2');
2426 sound_cap_flag
[0].SetByName('SOUND_CTF_CAPTURE1');
2427 sound_cap_flag
[1].SetByName('SOUND_CTF_CAPTURE2');
2429 g_Game_LoadChatSounds(GameWAD
+':CHATSND\SNDCFG');
2431 g_Game_SetLoadingText(_lc
[I_LOAD_ITEMS_DATA
], 0, False);
2434 g_Game_SetLoadingText(_lc
[I_LOAD_WEAPONS_DATA
], 0, False);
2435 g_Weapon_LoadData();
2437 g_Monsters_LoadData();
2442 procedure g_Game_FreeData();
2444 if not DataLoaded
then Exit
;
2447 g_Weapon_FreeData();
2448 g_Monsters_FreeData();
2450 e_WriteLog('Releasing game data...', TMsgType
.Notify
);
2452 g_Texture_Delete('NOTEXTURE');
2453 g_Texture_Delete('TEXTURE_PLAYER_HUD');
2454 g_Texture_Delete('TEXTURE_PLAYER_HUDBG');
2455 g_Texture_Delete('TEXTURE_PLAYER_ARMORHUD');
2456 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG');
2457 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG_S');
2458 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG_D');
2459 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG');
2460 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG_S');
2461 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG_D');
2462 g_Texture_Delete('TEXTURE_PLAYER_TALKBUBBLE');
2463 g_Texture_Delete('TEXTURE_PLAYER_INVULPENTA');
2464 g_Frames_DeleteByName('FRAMES_TELEPORT');
2465 g_Frames_DeleteByName('FRAMES_PUNCH');
2466 g_Frames_DeleteByName('FRAMES_PUNCH_UP');
2467 g_Frames_DeleteByName('FRAMES_PUNCH_DN');
2468 g_Frames_DeleteByName('FRAMES_PUNCH_BERSERK');
2469 g_Frames_DeleteByName('FRAMES_PUNCH_BERSERK_UP');
2470 g_Frames_DeleteByName('FRAMES_PUNCH_BERSERK_DN');
2471 g_Sound_Delete('SOUND_GAME_TELEPORT');
2472 g_Sound_Delete('SOUND_GAME_NOTELEPORT');
2473 g_Sound_Delete('SOUND_GAME_SECRET');
2474 g_Sound_Delete('SOUND_GAME_DOOROPEN');
2475 g_Sound_Delete('SOUND_GAME_DOORCLOSE');
2476 g_Sound_Delete('SOUND_GAME_BULK1');
2477 g_Sound_Delete('SOUND_GAME_BULK2');
2478 g_Sound_Delete('SOUND_GAME_BUBBLE1');
2479 g_Sound_Delete('SOUND_GAME_BUBBLE2');
2480 g_Sound_Delete('SOUND_GAME_BURNING');
2481 g_Sound_Delete('SOUND_GAME_SWITCH1');
2482 g_Sound_Delete('SOUND_GAME_SWITCH0');
2489 g_Sound_Delete('SOUND_ANNOUNCER_GOOD1');
2490 g_Sound_Delete('SOUND_ANNOUNCER_GOOD2');
2491 g_Sound_Delete('SOUND_ANNOUNCER_GOOD3');
2492 g_Sound_Delete('SOUND_ANNOUNCER_GOOD4');
2499 g_Sound_Delete('SOUND_ANNOUNCER_KILL2X');
2500 g_Sound_Delete('SOUND_ANNOUNCER_KILL3X');
2501 g_Sound_Delete('SOUND_ANNOUNCER_KILL4X');
2502 g_Sound_Delete('SOUND_ANNOUNCER_KILLMX');
2508 g_Sound_Delete('SOUND_ANNOUNCER_MUHAHA1');
2509 g_Sound_Delete('SOUND_ANNOUNCER_MUHAHA2');
2510 g_Sound_Delete('SOUND_ANNOUNCER_MUHAHA3');
2512 sound_get_flag
[0].Free();
2513 sound_get_flag
[1].Free();
2514 sound_lost_flag
[0].Free();
2515 sound_lost_flag
[1].Free();
2516 sound_ret_flag
[0].Free();
2517 sound_ret_flag
[1].Free();
2518 sound_cap_flag
[0].Free();
2519 sound_cap_flag
[1].Free();
2521 g_Sound_Delete('SOUND_CTF_GET1');
2522 g_Sound_Delete('SOUND_CTF_GET2');
2523 g_Sound_Delete('SOUND_CTF_LOST1');
2524 g_Sound_Delete('SOUND_CTF_LOST2');
2525 g_Sound_Delete('SOUND_CTF_RETURN1');
2526 g_Sound_Delete('SOUND_CTF_RETURN2');
2527 g_Sound_Delete('SOUND_CTF_CAPTURE1');
2528 g_Sound_Delete('SOUND_CTF_CAPTURE2');
2530 g_Game_FreeChatSounds();
2532 DataLoaded
:= False;
2535 procedure DrawCustomStat();
2541 ww2
, hh2
, r
, g
, b
, rr
, gg
, bb
: Byte;
2542 s1
, s2
, topstr
: String;
2544 e_TextureFontGetSize(gStdFont
, ww2
, hh2
);
2546 g_ProcessMessages();
2548 if g_Console_Action(ACTION_SCORES
) then
2550 if not gStatsPressed
then
2552 gStatsOff
:= not gStatsOff
;
2553 gStatsPressed
:= True;
2557 gStatsPressed
:= False;
2561 s1
:= _lc
[I_MENU_INTER_NOTICE_TAB
];
2562 w
:= (Length(s1
) * ww2
) div 2;
2563 x
:= gScreenWidth
div 2 - w
;
2565 e_TextureFontPrint(x
, y
, s1
, gStdFont
);
2569 if (gGameSettings
.GameMode
= GM_COOP
) then
2571 if gMissionFailed
then
2572 topstr
:= _lc
[I_MENU_INTER_MISSION_FAIL
]
2574 topstr
:= _lc
[I_MENU_INTER_LEVEL_COMPLETE
];
2577 topstr
:= _lc
[I_MENU_INTER_ROUND_OVER
];
2579 e_CharFont_GetSize(gMenuFont
, topstr
, ww1
, hh1
);
2580 e_CharFont_Print(gMenuFont
, (gScreenWidth
div 2)-(ww1
div 2), 16, topstr
);
2582 if g_Game_IsNet
then
2584 topstr
:= Format(_lc
[I_MENU_INTER_NOTICE_TIME
], [gServInterTime
]);
2585 if not gChatShow
then
2586 e_TextureFontPrintEx((gScreenWidth
div 2)-(Length(topstr
)*ww2
div 2),
2587 gScreenHeight
-(hh2
+4)*2, topstr
, gStdFont
, 255, 255, 255, 1);
2590 if g_Game_IsClient
then
2591 topstr
:= _lc
[I_MENU_INTER_NOTICE_MAP
]
2593 topstr
:= _lc
[I_MENU_INTER_NOTICE_SPACE
];
2594 if not gChatShow
then
2595 e_TextureFontPrintEx((gScreenWidth
div 2)-(Length(topstr
)*ww2
div 2),
2596 gScreenHeight
-(hh2
+4), topstr
, gStdFont
, 255, 255, 255, 1);
2601 w
:= gScreenWidth
-x
*2;
2607 e_DrawFillQuad(x
, y
, gScreenWidth
-x
-1, gScreenHeight
-y
-1, 64, 64, 64, 32);
2608 e_DrawQuad(x
, y
, gScreenWidth
-x
-1, gScreenHeight
-y
-1, 255, 127, 0);
2610 m
:= Max(Length(_lc
[I_MENU_MAP
])+1, Length(_lc
[I_GAME_GAME_TIME
])+1)*ww2
;
2612 case CustomStat
.GameMode
of
2615 if gGameSettings
.MaxLives
= 0 then
2616 s1
:= _lc
[I_GAME_DM
]
2618 s1
:= _lc
[I_GAME_LMS
];
2622 if gGameSettings
.MaxLives
= 0 then
2623 s1
:= _lc
[I_GAME_TDM
]
2625 s1
:= _lc
[I_GAME_TLMS
];
2627 GM_CTF
: s1
:= _lc
[I_GAME_CTF
];
2630 if gGameSettings
.MaxLives
= 0 then
2631 s1
:= _lc
[I_GAME_COOP
]
2633 s1
:= _lc
[I_GAME_SURV
];
2639 e_TextureFontPrintEx(x
+(w
div 2)-(Length(s1
)*ww2
div 2), _y
, s1
, gStdFont
, 255, 255, 255, 1);
2643 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_MENU_MAP
], gStdFont
, 255, 127, 0, 1);
2644 e_TextureFontPrint(x
+8+m
, _y
, Format('%s - %s', [CustomStat
.Map
, CustomStat
.MapName
]), gStdFont
);
2647 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_GAME_TIME
], gStdFont
, 255, 127, 0, 1);
2648 e_TextureFontPrint(x
+8+m
, _y
, Format('%d:%.2d:%.2d', [CustomStat
.GameTime
div 1000 div 3600,
2649 (CustomStat
.GameTime
div 1000 div 60) mod 60,
2650 CustomStat
.GameTime
div 1000 mod 60]), gStdFont
);
2652 pc
:= Length(CustomStat
.PlayerStat
);
2653 if pc
= 0 then Exit
;
2655 if CustomStat
.GameMode
= GM_COOP
then
2657 m
:= Max(Length(_lc
[I_GAME_MONSTERS
])+1, Length(_lc
[I_GAME_SECRETS
])+1)*ww2
;
2659 s2
:= _lc
[I_GAME_MONSTERS
];
2660 e_TextureFontPrintEx(x
+8, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2661 e_TextureFontPrintEx(x
+8+m
, _y
, IntToStr(gCoopMonstersKilled
) + '/' + IntToStr(gTotalMonsters
), gStdFont
, 255, 255, 255, 1);
2663 s2
:= _lc
[I_GAME_SECRETS
];
2664 e_TextureFontPrintEx(x
+8, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2665 e_TextureFontPrintEx(x
+8+m
, _y
, IntToStr(gCoopSecretsFound
) + '/' + IntToStr(gSecretsCount
), gStdFont
, 255, 255, 255, 1);
2668 m
:= Max(Length(_lc
[I_GAME_MONSTERS_TOTAL
])+1, Length(_lc
[I_GAME_SECRETS_TOTAL
])+1)*ww2
;
2670 s2
:= _lc
[I_GAME_MONSTERS_TOTAL
];
2671 e_TextureFontPrintEx(x
+250, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2672 e_TextureFontPrintEx(x
+250+m
, _y
, IntToStr(gCoopTotalMonstersKilled
) + '/' + IntToStr(gCoopTotalMonsters
), gStdFont
, 255, 255, 255, 1);
2674 s2
:= _lc
[I_GAME_SECRETS_TOTAL
];
2675 e_TextureFontPrintEx(x
+250, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2676 e_TextureFontPrintEx(x
+250+m
, _y
, IntToStr(gCoopTotalSecretsFound
) + '/' + IntToStr(gCoopTotalSecrets
), gStdFont
, 255, 255, 255, 1);
2680 if CustomStat
.GameMode
in [GM_TDM
, GM_CTF
] then
2685 if TeamStat
[TEAM_RED
].Goals
> TeamStat
[TEAM_BLUE
].Goals
then s1
:= _lc
[I_GAME_WIN_RED
]
2686 else if TeamStat
[TEAM_BLUE
].Goals
> TeamStat
[TEAM_RED
].Goals
then s1
:= _lc
[I_GAME_WIN_BLUE
]
2687 else s1
:= _lc
[I_GAME_WIN_DRAW
];
2689 e_TextureFontPrintEx(x
+8+(w
div 2)-(Length(s1
)*ww2
div 2), _y
, s1
, gStdFont
, 255, 255, 255, 1);
2692 for t
:= TEAM_RED
to TEAM_BLUE
do
2694 if t
= TEAM_RED
then
2696 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_TEAM_RED
],
2697 gStdFont
, 255, 0, 0, 1);
2698 e_TextureFontPrintEx(x
+w1
+8, _y
, IntToStr(CustomStat
.TeamStat
[TEAM_RED
].Goals
),
2699 gStdFont
, 255, 0, 0, 1);
2706 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_TEAM_BLUE
],
2707 gStdFont
, 0, 0, 255, 1);
2708 e_TextureFontPrintEx(x
+w1
+8, _y
, IntToStr(CustomStat
.TeamStat
[TEAM_BLUE
].Goals
),
2709 gStdFont
, 0, 0, 255, 1);
2715 e_DrawLine(1, x
+8, _y
+20, x
-8+w
, _y
+20, r
, g
, b
);
2718 for p
:= 0 to High(CustomStat
.PlayerStat
) do
2719 if CustomStat
.PlayerStat
[p
].Team
= t
then
2720 with CustomStat
.PlayerStat
[p
] do
2734 if (gPlayers
[Num
] <> nil) and (gPlayers
[Num
].FReady
) then
2735 e_TextureFontPrintEx(x
+16, _y
, Name
+ ' *', gStdFont
, rr
, gg
, bb
, 1)
2737 e_TextureFontPrintEx(x
+16, _y
, Name
, gStdFont
, rr
, gg
, bb
, 1);
2738 e_TextureFontPrintEx(x
+w1
+16, _y
, IntToStr(Frags
), gStdFont
, rr
, gg
, bb
, 1);
2739 e_TextureFontPrintEx(x
+w1
+w2
+16, _y
, IntToStr(Deaths
), gStdFont
, rr
, gg
, bb
, 1);
2746 else if CustomStat
.GameMode
in [GM_DM
, GM_COOP
] then
2749 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_PLAYER_NAME
], gStdFont
, 255, 127, 0, 1);
2750 e_TextureFontPrintEx(x
+8+w1
, _y
, _lc
[I_GAME_FRAGS
], gStdFont
, 255, 127, 0, 1);
2751 e_TextureFontPrintEx(x
+8+w1
+w2
, _y
, _lc
[I_GAME_DEATHS
], gStdFont
, 255, 127, 0, 1);
2754 for p
:= 0 to High(CustomStat
.PlayerStat
) do
2755 with CustomStat
.PlayerStat
[p
] do
2757 e_DrawFillQuad(x
+8, _y
+4, x
+24-1, _y
+16+4-1, Color
.R
, Color
.G
, Color
.B
, 0);
2764 if (gPlayers
[Num
] <> nil) and (gPlayers
[Num
].FReady
) then
2765 e_TextureFontPrintEx(x
+8+16+8, _y
+4, Name
+ ' *', gStdFont
, r
, r
, r
, 1, True)
2767 e_TextureFontPrintEx(x
+8+16+8, _y
+4, Name
, gStdFont
, r
, r
, r
, 1, True);
2768 e_TextureFontPrintEx(x
+w1
+8+16+8, _y
+4, IntToStr(Frags
), gStdFont
, r
, r
, r
, 1, True);
2769 e_TextureFontPrintEx(x
+w1
+w2
+8+16+8, _y
+4, IntToStr(Deaths
), gStdFont
, r
, r
, r
, 1, True);
2775 procedure DrawSingleStat();
2777 tm
, key_x
, val_x
, y
: Integer;
2781 procedure player_stat(n
: Integer);
2787 s1
:= Format(' %d ', [SingleStat
.PlayerStat
[n
].Kills
]);
2788 s2
:= Format(' %d', [gTotalMonsters
]);
2790 e_CharFont_Print(gMenuFont
, key_x
, y
, _lc
[I_MENU_INTER_KILLS
]);
2791 e_CharFont_PrintEx(gMenuFont
, val_x
, y
, s1
, _RGB(255, 0, 0));
2792 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2793 e_CharFont_Print(gMenuFont
, val_x
+w1
, y
, '/');
2795 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2796 e_CharFont_PrintEx(gMenuFont
, val_x
+w1
, y
, s2
, _RGB(255, 0, 0));
2798 // "Kills-per-minute: ##.#":
2799 s1
:= _lc
[I_MENU_INTER_KPM
];
2801 kpm
:= (SingleStat
.PlayerStat
[n
].Kills
/ tm
) * 60
2803 kpm
:= SingleStat
.PlayerStat
[n
].Kills
;
2804 s2
:= Format(' %.1f', [kpm
]);
2806 e_CharFont_Print(gMenuFont
, key_x
, y
+32, s1
);
2807 e_CharFont_PrintEx(gMenuFont
, val_x
, y
+32, s2
, _RGB(255, 0, 0));
2809 // "Secrets found: # / #":
2810 s1
:= Format(' %d ', [SingleStat
.PlayerStat
[n
].Secrets
]);
2811 s2
:= Format(' %d', [SingleStat
.TotalSecrets
]);
2813 e_CharFont_Print(gMenuFont
, key_x
, y
+64, _lc
[I_MENU_INTER_SECRETS
]);
2814 e_CharFont_PrintEx(gMenuFont
, val_x
, y
+64, s1
, _RGB(255, 0, 0));
2815 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2816 e_CharFont_Print(gMenuFont
, val_x
+w1
, y
+64, '/');
2818 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2819 e_CharFont_PrintEx(gMenuFont
, val_x
+w1
, y
+64, s2
, _RGB(255, 0, 0));
2823 // "Level Complete":
2824 e_CharFont_GetSize(gMenuFont
, _lc
[I_MENU_INTER_LEVEL_COMPLETE
], w1
, h
);
2825 e_CharFont_Print(gMenuFont
, (gScreenWidth
-w1
) div 2, 32, _lc
[I_MENU_INTER_LEVEL_COMPLETE
]);
2827 // Îïðåäåëÿåì êîîðäèíàòû âûðàâíèâàíèÿ ïî ñàìîé äëèííîé ñòðîêå:
2828 s1
:= _lc
[I_MENU_INTER_KPM
];
2829 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2832 e_CharFont_GetSize(gMenuFont
, s1
, w2
, h
);
2834 key_x
:= (gScreenWidth
-w1
-w2
) div 2;
2835 val_x
:= key_x
+ w1
;
2838 tm
:= SingleStat
.GameTime
div 1000;
2839 s1
:= _lc
[I_MENU_INTER_TIME
];
2840 s2
:= Format(' %d:%.2d:%.2d', [tm
div (60*60), (tm
mod (60*60)) div 60, tm
mod 60]);
2842 e_CharFont_Print(gMenuFont
, key_x
, 80, s1
);
2843 e_CharFont_PrintEx(gMenuFont
, val_x
, 80, s2
, _RGB(255, 0, 0));
2845 if SingleStat
.TwoPlayers
then
2848 s1
:= _lc
[I_MENU_PLAYER_1
];
2849 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2850 e_CharFont_Print(gMenuFont
, (gScreenWidth
-w1
) div 2, 128, s1
);
2852 // Ñòàòèñòèêà ïåðâîãî èãðîêà:
2857 s1
:= _lc
[I_MENU_PLAYER_2
];
2858 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2859 e_CharFont_Print(gMenuFont
, (gScreenWidth
-w1
) div 2, 288, s1
);
2861 // Ñòàòèñòèêà âòîðîãî èãðîêà:
2867 // Ñòàòèñòèêà ïåðâîãî èãðîêà:
2873 procedure DrawLoadingStat();
2874 procedure drawRect (x
, y
, w
, h
: Integer);
2876 if (w
< 1) or (h
< 1) then exit
;
2878 glVertex2f(x
+0.375, y
+0.375);
2879 glVertex2f(x
+w
+0.375, y
+0.375);
2880 glVertex2f(x
+w
+0.375, y
+h
+0.375);
2881 glVertex2f(x
+0.375, y
+h
+0.375);
2885 function drawPBar (cur
, total
: Integer; washere
: Boolean): Boolean;
2887 rectW
, rectH
: Integer;
2894 idl
, idr
, idb
, idm
: LongWord;
2898 if (total
< 1) then exit
;
2899 if (cur
< 1) then exit
; // don't blink
2900 if (not washere
) and (cur
>= total
) then exit
; // don't blink
2901 //if (cur < 0) then cur := 0;
2902 //if (cur > total) then cur := total;
2905 if (hasPBarGfx
) then
2907 g_Texture_Get('UI_GFX_PBAR_LEFT', idl
);
2908 g_Texture_GetSize('UI_GFX_PBAR_LEFT', wl
, hl
);
2909 g_Texture_Get('UI_GFX_PBAR_RIGHT', idr
);
2910 g_Texture_GetSize('UI_GFX_PBAR_RIGHT', wr
, hr
);
2911 g_Texture_Get('UI_GFX_PBAR_MIDDLE', idb
);
2912 g_Texture_GetSize('UI_GFX_PBAR_MIDDLE', wb
, hb
);
2913 g_Texture_Get('UI_GFX_PBAR_MARKER', idm
);
2914 g_Texture_GetSize('UI_GFX_PBAR_MARKER', wm
, hm
);
2916 //rectW := gScreenWidth-360;
2917 rectW
:= trunc(624.0*gScreenWidth
/1024.0);
2920 x0
:= (gScreenWidth
-rectW
) div 2;
2921 y0
:= gScreenHeight
-rectH
-64;
2922 if (y0
< 2) then y0
:= 2;
2924 glEnable(GL_SCISSOR_TEST
);
2927 glScissor(x0
, gScreenHeight
-y0
-rectH
, rectW
, rectH
);
2928 e_DrawSize(idl
, x0
, y0
, 0, true, false, wl
, hl
);
2929 e_DrawSize(idr
, x0
+rectW
-wr
, y0
, 0, true, false, wr
, hr
);
2932 glScissor(x0
+wl
, gScreenHeight
-y0
-rectH
, rectW
-wl
-wr
, rectH
);
2934 while (f
< x0
+rectW
) do
2936 e_DrawSize(idb
, f
, y0
, 0, true, false, wb
, hb
);
2941 wdt
:= (rectW
-wl
-wr
)*cur
div total
;
2942 if (wdt
> rectW
-wl
-wr
) then wdt
:= rectW
-wr
-wr
;
2945 my
:= y0
; // don't be so smart, ketmar: +(rectH-wm) div 2;
2946 glScissor(x0
+wl
, gScreenHeight
-my
-rectH
, wdt
, hm
);
2950 e_DrawSize(idm
, f
, y0
, 0, true, false, wm
, hm
);
2956 glScissor(0, 0, gScreenWidth
, gScreenHeight
);
2960 rectW
:= gScreenWidth
-64;
2963 x0
:= (gScreenWidth
-rectW
) div 2;
2964 y0
:= gScreenHeight
-rectH
-64;
2965 if (y0
< 2) then y0
:= 2;
2967 glDisable(GL_BLEND
);
2968 glDisable(GL_TEXTURE_2D
);
2970 //glClearColor(0, 0, 0, 0);
2971 //glClear(GL_COLOR_BUFFER_BIT);
2973 glColor4ub(127, 127, 127, 255);
2974 drawRect(x0
-2, y0
-2, rectW
+4, rectH
+4);
2976 glColor4ub(0, 0, 0, 255);
2977 drawRect(x0
-1, y0
-1, rectW
+2, rectH
+2);
2979 glColor4ub(127, 127, 127, 255);
2980 wdt
:= rectW
*cur
div total
;
2981 if (wdt
> rectW
) then wdt
:= rectW
;
2982 drawRect(x0
, y0
, wdt
, rectH
);
2991 if (Length(LoadingStat
.Msgs
) = 0) then exit
;
2993 e_CharFont_GetSize(gMenuFont
, _lc
[I_MENU_LOADING
], ww
, hh
);
2994 yy
:= (gScreenHeight
div 3);
2995 e_CharFont_Print(gMenuFont
, (gScreenWidth
div 2)-(ww
div 2), yy
-2*hh
, _lc
[I_MENU_LOADING
]);
2996 xx
:= (gScreenWidth
div 3);
3000 for i
:= 0 to NextMsg
-1 do
3002 if (i
= (NextMsg
-1)) and (MaxValue
> 0) then
3003 s
:= Format('%s: %d/%d', [Msgs
[i
], CurValue
, MaxValue
])
3007 e_CharFont_PrintEx(gMenuSmallFont
, xx
, yy
, s
, _RGB(255, 0, 0));
3008 yy
:= yy
+ LOADING_INTERLINE
;
3009 PBarWasHere
:= drawPBar(CurValue
, MaxValue
, PBarWasHere
);
3014 procedure DrawMenuBackground(tex
: AnsiString);
3020 if g_Texture_Get(tex
, ID
) then
3022 e_Clear(GL_COLOR_BUFFER_BIT
, 0, 0, 0);
3023 e_GetTextureSize(ID
, @w
, @h
);
3025 w
:= round(w
* 1.333 * (gScreenHeight
/ h
))
3027 w
:= trunc(w
* (gScreenHeight
/ h
));
3028 e_DrawSize(ID
, (gScreenWidth
- w
) div 2, 0, 0, False, False, w
, gScreenHeight
);
3030 else e_Clear(GL_COLOR_BUFFER_BIT
, 0, 0, 0);
3033 procedure DrawMinimap(p
: TPlayer
; RenderRect
: e_graphics
.TRect
);
3035 a
, aX
, aY
, aX2
, aY2
, Scale
, ScaleSz
: Integer;
3037 function monDraw (mon
: TMonster
): Boolean;
3039 result
:= false; // don't stop
3044 // Ëåâûé âåðõíèé óãîë
3045 aX
:= Obj
.X
div ScaleSz
+ 1;
3046 aY
:= Obj
.Y
div ScaleSz
+ 1;
3048 aX2
:= max(Obj
.Rect
.Width
div ScaleSz
, 1);
3049 aY2
:= max(Obj
.Rect
.Height
div ScaleSz
, 1);
3050 // Ïðàâûé íèæíèé óãîë
3051 aX2
:= aX
+ aX2
- 1;
3052 aY2
:= aY
+ aY2
- 1;
3053 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 255, 0, 0);
3059 if (gMapInfo
.Width
> RenderRect
.Right
- RenderRect
.Left
) or
3060 (gMapInfo
.Height
> RenderRect
.Bottom
- RenderRect
.Top
) then
3063 // Ñêîëüêî ïèêñåëîâ êàðòû â 1 ïèêñåëå ìèíè-êàðòû:
3064 ScaleSz
:= 16 div Scale
;
3065 // Ðàçìåðû ìèíè-êàðòû:
3066 aX
:= max(gMapInfo
.Width
div ScaleSz
, 1);
3067 aY
:= max(gMapInfo
.Height
div ScaleSz
, 1);
3069 e_DrawFillQuad(0, 0, aX
-1, aY
-1, 0, 0, 0, 0);
3071 if gWalls
<> nil then
3074 for a
:= 0 to High(gWalls
) do
3076 if PanelType
<> 0 then
3078 // Ëåâûé âåðõíèé óãîë:
3079 aX
:= X
div ScaleSz
;
3080 aY
:= Y
div ScaleSz
;
3082 aX2
:= max(Width
div ScaleSz
, 1);
3083 aY2
:= max(Height
div ScaleSz
, 1);
3084 // Ïðàâûé íèæíèé óãîë:
3085 aX2
:= aX
+ aX2
- 1;
3086 aY2
:= aY
+ aY2
- 1;
3089 PANEL_WALL
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 208, 208, 208, 0);
3090 PANEL_OPENDOOR
, PANEL_CLOSEDOOR
:
3091 if Enabled
then e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 160, 160, 160, 0);
3095 if gSteps
<> nil then
3098 for a
:= 0 to High(gSteps
) do
3100 if PanelType
<> 0 then
3102 // Ëåâûé âåðõíèé óãîë:
3103 aX
:= X
div ScaleSz
;
3104 aY
:= Y
div ScaleSz
;
3106 aX2
:= max(Width
div ScaleSz
, 1);
3107 aY2
:= max(Height
div ScaleSz
, 1);
3108 // Ïðàâûé íèæíèé óãîë:
3109 aX2
:= aX
+ aX2
- 1;
3110 aY2
:= aY
+ aY2
- 1;
3112 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 128, 128, 128, 0);
3115 if gLifts
<> nil then
3118 for a
:= 0 to High(gLifts
) 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;
3133 LIFTTYPE_UP
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 116, 72, 36, 0);
3134 LIFTTYPE_DOWN
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 116, 124, 96, 0);
3135 LIFTTYPE_LEFT
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 200, 80, 4, 0);
3136 LIFTTYPE_RIGHT
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 252, 140, 56, 0);
3140 if gWater
<> nil then
3143 for a
:= 0 to High(gWater
) do
3145 if PanelType
<> 0 then
3147 // Ëåâûé âåðõíèé óãîë:
3148 aX
:= X
div ScaleSz
;
3149 aY
:= Y
div ScaleSz
;
3151 aX2
:= max(Width
div ScaleSz
, 1);
3152 aY2
:= max(Height
div ScaleSz
, 1);
3153 // Ïðàâûé íèæíèé óãîë:
3154 aX2
:= aX
+ aX2
- 1;
3155 aY2
:= aY
+ aY2
- 1;
3157 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 0, 192, 0);
3160 if gAcid1
<> nil then
3162 // Ðèñóåì êèñëîòó 1:
3163 for a
:= 0 to High(gAcid1
) 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, 176, 0, 0);
3180 if gAcid2
<> nil then
3182 // Ðèñóåì êèñëîòó 2:
3183 for a
:= 0 to High(gAcid2
) 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
, 176, 0, 0, 0);
3200 if gPlayers
<> nil then
3203 for a
:= 0 to High(gPlayers
) do
3204 if gPlayers
[a
] <> nil then with gPlayers
[a
] do
3206 // Ëåâûé âåðõíèé óãîë:
3207 aX
:= Obj
.X
div ScaleSz
+ 1;
3208 aY
:= Obj
.Y
div ScaleSz
+ 1;
3210 aX2
:= max(Obj
.Rect
.Width
div ScaleSz
, 1);
3211 aY2
:= max(Obj
.Rect
.Height
div ScaleSz
, 1);
3212 // Ïðàâûé íèæíèé óãîë:
3213 aX2
:= aX
+ aX2
- 1;
3214 aY2
:= aY
+ aY2
- 1;
3216 if gPlayers
[a
] = p
then
3217 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 255, 0, 0)
3220 TEAM_RED
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 0, 0, 0);
3221 TEAM_BLUE
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 0, 255, 0);
3222 else e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 128, 0, 0);
3227 g_Mons_ForEach(monDraw
);
3232 procedure renderAmbientQuad (hasAmbient
: Boolean; constref ambColor
: TDFColor
);
3234 if not hasAmbient
then exit
;
3235 e_AmbientQuad(sX
, sY
, sWidth
, sHeight
, ambColor
.r
, ambColor
.g
, ambColor
.b
, ambColor
.a
);
3239 // setup sX, sY, sWidth, sHeight, and transformation matrix before calling this!
3240 //FIXME: broken for splitscreen mode
3241 procedure renderDynLightsInternal ();
3243 //hasAmbient: Boolean;
3244 //ambColor: TDFColor;
3246 lx
, ly
, lrad
: Integer;
3247 scxywh
: array[0..3] of GLint
;
3250 if e_NoGraphics
then exit
;
3252 //TODO: lights should be in separate grid, i think
3253 // but on the other side: grid may be slower for dynlights, as their lifetime is short
3254 if (not gwin_k8_enable_light_experiments
) or (not gwin_has_stencil
) or (g_dynLightCount
< 1) then exit
;
3257 //ambColor := gCurrentMap['light_ambient'].rgba;
3258 //hasAmbient := (not ambColor.isOpaque) or (not ambColor.isBlack);
3260 { // this will multiply incoming color to alpha from framebuffer
3262 glBlendFunc(GL_DST_ALPHA, GL_ONE);
3266 * light rendering: (INVALID!)
3267 * glStencilFunc(GL_EQUAL, 0, $ff);
3269 * glClear(GL_STENCIL_BUFFER_BIT);
3270 * glStencilOp(GL_KEEP, GL_KEEP, GL_INCR);
3271 * draw shadow volume into stencil buffer
3272 * glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); // modify color buffer
3273 * glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); // don't modify stencil buffer
3275 * draw color-less quad with light alpha (WARNING! don't touch color!)
3276 * glEnable(GL_BLEND);
3277 * glBlendFunc(GL_DST_ALPHA, GL_ONE);
3278 * draw all geometry up to and including walls (with alpha-testing, probably) -- this does lighting
3280 wassc
:= (glIsEnabled(GL_SCISSOR_TEST
) <> 0);
3281 if wassc
then glGetIntegerv(GL_SCISSOR_BOX
, @scxywh
[0]) else glGetIntegerv(GL_VIEWPORT
, @scxywh
[0]);
3283 // setup OpenGL parameters
3284 glStencilMask($FFFFFFFF);
3285 glStencilFunc(GL_ALWAYS
, 0, $FFFFFFFF);
3286 glEnable(GL_STENCIL_TEST
);
3287 glEnable(GL_SCISSOR_TEST
);
3288 glClear(GL_STENCIL_BUFFER_BIT
);
3289 glStencilFunc(GL_EQUAL
, 0, $ff);
3291 for lln
:= 0 to g_dynLightCount
-1 do
3293 lx
:= g_dynLights
[lln
].x
;
3294 ly
:= g_dynLights
[lln
].y
;
3295 lrad
:= g_dynLights
[lln
].radius
;
3296 if (lrad
< 3) then continue
;
3298 if (lx
-sX
+lrad
< 0) then continue
;
3299 if (ly
-sY
+lrad
< 0) then continue
;
3300 if (lx
-sX
-lrad
>= gPlayerScreenSize
.X
) then continue
;
3301 if (ly
-sY
-lrad
>= gPlayerScreenSize
.Y
) then continue
;
3303 // set scissor to optimize drawing
3304 if (g_dbg_scale
= 1.0) then
3306 glScissor((lx
-sX
)-lrad
+2, gPlayerScreenSize
.Y
-(ly
-sY
)-lrad
-1+2, lrad
*2-4, lrad
*2-4);
3310 glScissor(0, 0, gWinSizeX
, gWinSizeY
);
3312 // no need to clear stencil buffer, light blitting will do it for us... but only for normal scale
3313 if (g_dbg_scale
<> 1.0) then glClear(GL_STENCIL_BUFFER_BIT
);
3314 glStencilOp(GL_KEEP
, GL_KEEP
, GL_INCR
);
3315 // draw extruded panels
3316 glDisable(GL_TEXTURE_2D
);
3317 glDisable(GL_BLEND
);
3318 glColorMask(GL_FALSE
, GL_FALSE
, GL_FALSE
, GL_FALSE
); // no need to modify color buffer
3319 if (lrad
> 4) then g_Map_DrawPanelShadowVolumes(lx
, ly
, lrad
);
3320 // render light texture
3321 glColorMask(GL_TRUE
, GL_TRUE
, GL_TRUE
, GL_TRUE
); // modify color buffer
3322 glStencilOp(GL_ZERO
, GL_ZERO
, GL_ZERO
); // draw light, and clear stencil buffer
3325 glBlendFunc(GL_SRC_ALPHA
, GL_ONE_MINUS_SRC_ALPHA
);
3326 glEnable(GL_TEXTURE_2D
);
3327 // color and opacity
3328 glColor4f(g_dynLights
[lln
].r
, g_dynLights
[lln
].g
, g_dynLights
[lln
].b
, g_dynLights
[lln
].a
);
3329 glBindTexture(GL_TEXTURE_2D
, g_Texture_Light());
3331 glTexCoord2f(0.0, 0.0); glVertex2i(lx
-lrad
, ly
-lrad
); // top-left
3332 glTexCoord2f(1.0, 0.0); glVertex2i(lx
+lrad
, ly
-lrad
); // top-right
3333 glTexCoord2f(1.0, 1.0); glVertex2i(lx
+lrad
, ly
+lrad
); // bottom-right
3334 glTexCoord2f(0.0, 1.0); glVertex2i(lx
-lrad
, ly
+lrad
); // bottom-left
3339 glDisable(GL_STENCIL_TEST
);
3340 glDisable(GL_BLEND
);
3341 glDisable(GL_SCISSOR_TEST
);
3342 //glScissor(0, 0, sWidth, sHeight);
3344 glScissor(scxywh
[0], scxywh
[1], scxywh
[2], scxywh
[3]);
3345 if wassc
then glEnable(GL_SCISSOR_TEST
) else glDisable(GL_SCISSOR_TEST
);
3349 function fixViewportForScale (): Boolean;
3351 nx0
, ny0
, nw
, nh
: Integer;
3354 if (g_dbg_scale
<> 1.0) then
3357 nx0
:= round(sX
-(gPlayerScreenSize
.X
-(sWidth
*g_dbg_scale
))/2/g_dbg_scale
);
3358 ny0
:= round(sY
-(gPlayerScreenSize
.Y
-(sHeight
*g_dbg_scale
))/2/g_dbg_scale
);
3359 nw
:= round(sWidth
/g_dbg_scale
);
3360 nh
:= round(sHeight
/g_dbg_scale
);
3369 // setup sX, sY, sWidth, sHeight, and transformation matrix before calling this!
3370 // WARNING! this WILL CALL `glTranslatef()`, but won't restore matrices!
3371 procedure renderMapInternal (backXOfs
, backYOfs
: Integer; setTransMatrix
: Boolean);
3373 TDrawCB
= procedure ();
3376 hasAmbient
: Boolean;
3378 doAmbient
: Boolean = false;
3380 procedure drawPanelType (profname
: AnsiString; panType
: DWord
; doDraw
: Boolean);
3385 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin(profname
);
3386 if gdbg_map_use_accel_render
then
3388 tagmask
:= panelTypeToTag(panType
);
3389 while (gDrawPanelList
.count
> 0) do
3391 pan
:= TPanel(gDrawPanelList
.front());
3392 if ((pan
.tag
and tagmask
) = 0) then break
;
3393 if doDraw
then pan
.Draw(doAmbient
, ambColor
);
3394 gDrawPanelList
.popFront();
3399 if doDraw
then g_Map_DrawPanels(panType
, hasAmbient
, ambColor
);
3401 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
3404 procedure drawOther (profname
: AnsiString; cb
: TDrawCB
);
3406 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin(profname
);
3407 if assigned(cb
) then cb();
3408 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
3412 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin('total');
3414 // our accelerated renderer will collect all panels to gDrawPanelList
3415 // we can use panel tag to render level parts (see GridTagXXX in g_map.pas)
3416 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin('collect');
3417 if gdbg_map_use_accel_render
then
3419 g_Map_CollectDrawPanels(sX
, sY
, sWidth
, sHeight
);
3421 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
3423 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin('skyback');
3424 g_Map_DrawBack(backXOfs
, backYOfs
);
3425 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
3427 if setTransMatrix
then
3429 //if (g_dbg_scale <> 1.0) then glTranslatef(0.0, -0.375/2, 0);
3430 glScalef(g_dbg_scale
, g_dbg_scale
, 1.0);
3431 glTranslatef(-sX
, -sY
, 0);
3435 ambColor
:= gCurrentMap
['light_ambient'].rgba
;
3436 hasAmbient
:= (not ambColor
.isOpaque
) or (not ambColor
.isBlack
);
3441 //writeln('color: (', ambColor.r, ',', ambColor.g, ',', ambColor.b, ',', ambColor.a, ')');
3442 glColor4ub(ambColor.r, ambColor.g, ambColor.b, ambColor.a);
3443 glClear(GL_COLOR_BUFFER_BIT);
3446 //writeln('color: (', ambColor.r, ',', ambColor.g, ',', ambColor.b, ',', ambColor.a, ')');
3449 drawPanelType('*back', PANEL_BACK
, g_rlayer_back
);
3450 drawPanelType('*step', PANEL_STEP
, g_rlayer_step
);
3451 drawOther('items', @g_Items_Draw
);
3452 drawOther('weapons', @g_Weapon_Draw
);
3453 drawOther('shells', @g_Player_DrawShells
);
3454 drawOther('drawall', @g_Player_DrawAll
);
3455 drawOther('corpses', @g_Player_DrawCorpses
);
3456 drawPanelType('*wall', PANEL_WALL
, g_rlayer_wall
);
3457 drawOther('monsters', @g_Monsters_Draw
);
3458 drawOther('itemdrop', @g_Items_DrawDrop
);
3459 drawPanelType('*door', PANEL_CLOSEDOOR
, g_rlayer_door
);
3460 drawOther('gfx', @g_GFX_Draw
);
3461 drawOther('flags', @g_Map_DrawFlags
);
3462 drawPanelType('*acid1', PANEL_ACID1
, g_rlayer_acid1
);
3463 drawPanelType('*acid2', PANEL_ACID2
, g_rlayer_acid2
);
3464 drawPanelType('*water', PANEL_WATER
, g_rlayer_water
);
3465 drawOther('dynlights', @renderDynLightsInternal
);
3467 if hasAmbient
{and ((not g_playerLight) or (not gwin_has_stencil) or (g_dynLightCount < 1))} then
3469 renderAmbientQuad(hasAmbient
, ambColor
);
3473 drawPanelType('*fore', PANEL_FORE
, g_rlayer_fore
);
3476 if g_debug_HealthBar
then
3478 g_Monsters_DrawHealth();
3479 g_Player_DrawHealth();
3482 if (profileFrameDraw
<> nil) then profileFrameDraw
.mainEnd(); // map rendering
3486 procedure DrawMapView(x
, y
, w
, h
: Integer);
3493 bx
:= Round(x
/(gMapInfo
.Width
- w
)*(gBackSize
.X
- w
));
3494 by
:= Round(y
/(gMapInfo
.Height
- h
)*(gBackSize
.Y
- h
));
3501 fixViewportForScale();
3502 renderMapInternal(-bx
, -by
, true);
3508 procedure DrawPlayer(p
: TPlayer
);
3510 px
, py
, a
, b
, c
, d
: Integer;
3513 if (p
= nil) or (p
.FDummy
) then
3516 g_Map_DrawBack(0, 0);
3521 if (profileFrameDraw
= nil) then profileFrameDraw
:= TProfiler
.Create('RENDER', g_profile_history_size
);
3522 if (profileFrameDraw
<> nil) then profileFrameDraw
.mainBegin(g_profile_frame_draw
);
3528 px
:= p
.GameX
+ PLAYER_RECT_CX
;
3529 py
:= p
.GameY
+ PLAYER_RECT_CY
+p
.Obj
.slopeUpLeft
;
3531 if (g_dbg_scale
= 1.0) and (not g_dbg_ignore_bounds
) then
3533 if (px
> (gPlayerScreenSize
.X
div 2)) then a
:= -px
+(gPlayerScreenSize
.X
div 2) else a
:= 0;
3534 if (py
> (gPlayerScreenSize
.Y
div 2)) then b
:= -py
+(gPlayerScreenSize
.Y
div 2) else b
:= 0;
3536 if (px
> gMapInfo
.Width
-(gPlayerScreenSize
.X
div 2)) then a
:= -gMapInfo
.Width
+gPlayerScreenSize
.X
;
3537 if (py
> gMapInfo
.Height
-(gPlayerScreenSize
.Y
div 2)) then b
:= -gMapInfo
.Height
+gPlayerScreenSize
.Y
;
3539 if (gMapInfo
.Width
= gPlayerScreenSize
.X
) then a
:= 0
3540 else if (gMapInfo
.Width
< gPlayerScreenSize
.X
) then
3543 a
:= (gPlayerScreenSize
.X
-gMapInfo
.Width
) div 2;
3546 if (gMapInfo
.Height
= gPlayerScreenSize
.Y
) then b
:= 0
3547 else if (gMapInfo
.Height
< gPlayerScreenSize
.Y
) then
3550 b
:= (gPlayerScreenSize
.Y
-gMapInfo
.Height
) div 2;
3555 // scaled, ignore level bounds
3556 a
:= -px
+(gPlayerScreenSize
.X
div 2);
3557 b
:= -py
+(gPlayerScreenSize
.Y
div 2);
3560 if p
.IncCam
<> 0 then
3562 if py
> gMapInfo
.Height
-(gPlayerScreenSize
.Y
div 2) then
3564 if p
.IncCam
> 120-(py
-(gMapInfo
.Height
-(gPlayerScreenSize
.Y
div 2))) then
3566 p
.IncCam
:= 120-(py
-(gMapInfo
.Height
-(gPlayerScreenSize
.Y
div 2)));
3570 if py
< gPlayerScreenSize
.Y
div 2 then
3572 if p
.IncCam
< -120+((gPlayerScreenSize
.Y
div 2)-py
) then
3574 p
.IncCam
:= -120+((gPlayerScreenSize
.Y
div 2)-py
);
3578 if p
.IncCam
< 0 then
3580 while (py
+(gPlayerScreenSize
.Y
div 2)-p
.IncCam
> gMapInfo
.Height
) and (p
.IncCam
< 0) do p
.IncCam
:= p
.IncCam
+1; //Inc(p.IncCam);
3583 if p
.IncCam
> 0 then
3585 while (py
-(gPlayerScreenSize
.Y
div 2)-p
.IncCam
< 0) and (p
.IncCam
> 0) do p
.IncCam
:= p
.IncCam
-1; //Dec(p.IncCam);
3589 if (px
< gPlayerScreenSize
.X
div 2) or (gMapInfo
.Width
-gPlayerScreenSize
.X
<= 256) then c
:= 0
3590 else if (px
> gMapInfo
.Width
-(gPlayerScreenSize
.X
div 2)) then c
:= gBackSize
.X
-gPlayerScreenSize
.X
3591 else c
:= round((px
-(gPlayerScreenSize
.X
div 2))/(gMapInfo
.Width
-gPlayerScreenSize
.X
)*(gBackSize
.X
-gPlayerScreenSize
.X
));
3593 if (py
-p
.IncCam
<= gPlayerScreenSize
.Y
div 2) or (gMapInfo
.Height
-gPlayerScreenSize
.Y
<= 256) then d
:= 0
3594 else if (py
-p
.IncCam
>= gMapInfo
.Height
-(gPlayerScreenSize
.Y
div 2)) then d
:= gBackSize
.Y
-gPlayerScreenSize
.Y
3595 else d
:= round((py
-p
.IncCam
-(gPlayerScreenSize
.Y
div 2))/(gMapInfo
.Height
-gPlayerScreenSize
.Y
)*(gBackSize
.Y
-gPlayerScreenSize
.Y
));
3598 sY
:= -(b
+p
.IncCam
);
3599 sWidth
:= gPlayerScreenSize
.X
;
3600 sHeight
:= gPlayerScreenSize
.Y
;
3602 //glTranslatef(a, b+p.IncCam, 0);
3604 //if (p = gPlayer1) and (g_dbg_scale >= 1.0) then g_Holmes_plrViewSize(sWidth, sHeight);
3606 //conwritefln('OLD: (%s,%s)-(%s,%s)', [sX, sY, sWidth, sHeight]);
3607 fixViewportForScale();
3608 //conwritefln(' (%s,%s)-(%s,%s)', [sX, sY, sWidth, sHeight]);
3610 if (g_dbg_scale
<> 1.0) and (not g_dbg_ignore_bounds
) then
3612 if (sX
+sWidth
> gMapInfo
.Width
) then sX
:= gMapInfo
.Width
-sWidth
;
3613 if (sY
+sHeight
> gMapInfo
.Height
) then sY
:= gMapInfo
.Height
-sHeight
;
3614 if (sX
< 0) then sX
:= 0;
3615 if (sY
< 0) then sY
:= 0;
3617 if (gBackSize
.X
<= gPlayerScreenSize
.X
) or (gMapInfo
.Width
<= sWidth
) then c
:= 0 else c
:= trunc((gBackSize
.X
-gPlayerScreenSize
.X
)*sX
/(gMapInfo
.Width
-sWidth
));
3618 if (gBackSize
.Y
<= gPlayerScreenSize
.Y
) or (gMapInfo
.Height
<= sHeight
) then d
:= 0 else d
:= trunc((gBackSize
.Y
-gPlayerScreenSize
.Y
)*sY
/(gMapInfo
.Height
-sHeight
));
3621 //r_smallmap_h: 0: left; 1: center; 2: right
3622 //r_smallmap_v: 0: top; 1: center; 2: bottom
3624 if (gMapInfo
.Width
= sWidth
) then
3628 else if (gMapInfo
.Width
< sWidth
) then
3630 case r_smallmap_h
of
3631 1: sX
:= -((sWidth
-gMapInfo
.Width
) div 2); // center
3632 2: sX
:= -(sWidth
-gMapInfo
.Width
); // right
3633 else sX
:= 0; // left
3637 if (gMapInfo
.Height
= sHeight
) then
3641 else if (gMapInfo
.Height
< sHeight
) then
3643 case r_smallmap_v
of
3644 1: sY
:= -((sHeight
-gMapInfo
.Height
) div 2); // center
3645 2: sY
:= -(sHeight
-gMapInfo
.Height
); // bottom
3646 else sY
:= 0; // top
3652 p
.viewPortW
:= sWidth
;
3653 p
.viewPortH
:= sHeight
;
3655 {$IFDEF ENABLE_HOLMES}
3656 if (p
= gPlayer1
) then
3658 g_Holmes_plrViewPos(sX
, sY
);
3659 g_Holmes_plrViewSize(sWidth
, sHeight
);
3663 renderMapInternal(-c
, -d
, true);
3665 if (gGameSettings
.GameMode
<> GM_SINGLE
) and gPlayerIndicator
then
3667 if p
.FSpectator
then
3668 e_TextureFontPrintEx(p
.GameX
+ PLAYER_RECT_CX
- 4,
3669 p
.GameY
+ PLAYER_RECT_CY
- 4,
3670 'X', gStdFont
, 255, 255, 255, 1, True);
3672 for a := 0 to High(gCollideMap) do
3673 for b := 0 to High(gCollideMap[a]) do
3676 if ByteBool(gCollideMap[a, b] and MARK_WALL) then
3678 if ByteBool(gCollideMap[a, b] and MARK_DOOR) then
3682 1: e_DrawPoint(1, b, a, 200, 200, 200);
3683 2: e_DrawPoint(1, b, a, 64, 64, 255);
3684 3: e_DrawPoint(1, b, a, 255, 0, 255);
3694 if gShowMap
then DrawMinimap(p
, _TRect(0, 0, 128, 128));
3695 if g_Debug_Player
then
3696 g_Player_DrawDebug(p
);
3700 procedure drawProfilers ();
3705 if g_profile_frame_draw
and (profileFrameDraw
<> nil) then px
:= px
-drawProfiles(px
, py
, profileFrameDraw
);
3706 if g_profile_collision
and (profMapCollision
<> nil) then begin px
:= px
-drawProfiles(px
, py
, profMapCollision
); py
-= calcProfilesHeight(profMonsLOS
); end;
3707 if g_profile_los
and (profMonsLOS
<> nil) then begin px
:= px
-drawProfiles(px
, py
, profMonsLOS
); py
-= calcProfilesHeight(profMonsLOS
); end;
3710 procedure g_Game_Draw();
3717 plView1
, plView2
: TPlayer
;
3720 if gExit
= EXIT_QUIT
then Exit
;
3722 Time
:= GetTimer() {div 1000};
3723 FPSCounter
:= FPSCounter
+1;
3724 if Time
- FPSTime
>= 1000 then
3731 if gGameOn
or (gState
= STATE_FOLD
) then
3733 if (gPlayer1
<> nil) and (gPlayer2
<> nil) then
3735 gSpectMode
:= SPECT_NONE
;
3736 if not gRevertPlayers
then
3738 plView1
:= gPlayer1
;
3739 plView2
:= gPlayer2
;
3743 plView1
:= gPlayer2
;
3744 plView2
:= gPlayer1
;
3748 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
3750 gSpectMode
:= SPECT_NONE
;
3751 if gPlayer2
= nil then
3754 plView1
:= gPlayer2
;
3763 if (plView1
= nil) and (plView2
= nil) and (gSpectMode
= SPECT_NONE
) then
3764 gSpectMode
:= SPECT_STATS
;
3766 if gSpectMode
= SPECT_PLAYERS
then
3767 if gPlayers
<> nil then
3769 plView1
:= GetActivePlayer_ByID(gSpectPID1
);
3770 if plView1
= nil then
3772 gSpectPID1
:= GetActivePlayerID_Next();
3773 plView1
:= GetActivePlayer_ByID(gSpectPID1
);
3775 if gSpectViewTwo
then
3777 plView2
:= GetActivePlayer_ByID(gSpectPID2
);
3778 if plView2
= nil then
3780 gSpectPID2
:= GetActivePlayerID_Next();
3781 plView2
:= GetActivePlayer_ByID(gSpectPID2
);
3786 if gSpectMode
= SPECT_MAPVIEW
then
3788 // Ðåæèì ïðîñìîòðà êàðòû
3790 e_SetViewPort(0, 0, gScreenWidth
, gScreenHeight
);
3791 DrawMapView(gSpectX
, gSpectY
, gScreenWidth
, gScreenHeight
);
3792 gHearPoint1
.Active
:= True;
3793 gHearPoint1
.Coords
.X
:= gScreenWidth
div 2 + gSpectX
;
3794 gHearPoint1
.Coords
.Y
:= gScreenHeight
div 2 + gSpectY
;
3795 gHearPoint2
.Active
:= False;
3799 Split
:= (plView1
<> nil) and (plView2
<> nil);
3801 // Òî÷êè ñëóõà èãðîêîâ
3802 if plView1
<> nil then
3804 gHearPoint1
.Active
:= True;
3805 gHearPoint1
.Coords
.X
:= plView1
.GameX
;
3806 gHearPoint1
.Coords
.Y
:= plView1
.GameY
;
3808 gHearPoint1
.Active
:= False;
3809 if plView2
<> nil then
3811 gHearPoint2
.Active
:= True;
3812 gHearPoint2
.Coords
.X
:= plView2
.GameX
;
3813 gHearPoint2
.Coords
.Y
:= plView2
.GameY
;
3815 gHearPoint2
.Active
:= False;
3817 // Ðàçìåð ýêðàíîâ èãðîêîâ:
3818 gPlayerScreenSize
.X
:= gScreenWidth
-196;
3821 gPlayerScreenSize
.Y
:= gScreenHeight
div 2;
3822 if gScreenHeight
mod 2 = 0 then
3823 Dec(gPlayerScreenSize
.Y
);
3826 gPlayerScreenSize
.Y
:= gScreenHeight
;
3829 if gScreenHeight
mod 2 = 0 then
3830 e_SetViewPort(0, gPlayerScreenSize
.Y
+2, gPlayerScreenSize
.X
+196, gPlayerScreenSize
.Y
)
3832 e_SetViewPort(0, gPlayerScreenSize
.Y
+1, gPlayerScreenSize
.X
+196, gPlayerScreenSize
.Y
);
3834 DrawPlayer(plView1
);
3835 gPlayer1ScreenCoord
.X
:= sX
;
3836 gPlayer1ScreenCoord
.Y
:= sY
;
3840 e_SetViewPort(0, 0, gPlayerScreenSize
.X
+196, gPlayerScreenSize
.Y
);
3842 DrawPlayer(plView2
);
3843 gPlayer2ScreenCoord
.X
:= sX
;
3844 gPlayer2ScreenCoord
.Y
:= sY
;
3847 e_SetViewPort(0, 0, gScreenWidth
, gScreenHeight
);
3850 e_DrawLine(2, 0, gScreenHeight
div 2, gScreenWidth
, gScreenHeight
div 2, 0, 0, 0);
3853 {$IFDEF ENABLE_HOLMES}
3855 if (g_holmes_enabled
) then g_Holmes_Draw();
3858 if MessageText
<> '' then
3862 e_CharFont_GetSizeFmt(gMenuFont
, MessageText
, w
, h
);
3864 e_CharFont_PrintFmt(gMenuFont
, (gScreenWidth
div 2)-(w
div 2),
3865 (gScreenHeight
div 2)-(h
div 2), MessageText
)
3867 e_CharFont_PrintFmt(gMenuFont
, (gScreenWidth
div 2)-(w
div 2),
3868 Round(gScreenHeight
/ 2.75)-(h
div 2), MessageText
);
3871 if IsDrawStat
or (gSpectMode
= 1) then DrawStat();
3873 if gSpectHUD
and (not gChatShow
) and (gSpectMode
<> SPECT_NONE
) and (not gSpectAuto
) then
3875 // Draw spectator GUI
3878 e_TextureFontGetSize(gStdFont
, ww
, hh
);
3881 e_TextureFontPrintEx(0, gScreenHeight
- (hh
+2)*2, 'MODE: Stats', gStdFont
, 255, 255, 255, 1);
3883 e_TextureFontPrintEx(0, gScreenHeight
- (hh
+2)*2, 'MODE: Observe Map', gStdFont
, 255, 255, 255, 1);
3885 e_TextureFontPrintEx(0, gScreenHeight
- (hh
+2)*2, 'MODE: Watch Players', gStdFont
, 255, 255, 255, 1);
3887 e_TextureFontPrintEx(2*ww
, gScreenHeight
- (hh
+2), '< jump >', gStdFont
, 255, 255, 255, 1);
3888 if gSpectMode
= SPECT_STATS
then
3890 e_TextureFontPrintEx(16*ww
, gScreenHeight
- (hh
+2)*2, 'Autoview', gStdFont
, 255, 255, 255, 1);
3891 e_TextureFontPrintEx(16*ww
, gScreenHeight
- (hh
+2), '< fire >', gStdFont
, 255, 255, 255, 1);
3893 if gSpectMode
= SPECT_MAPVIEW
then
3895 e_TextureFontPrintEx(22*ww
, gScreenHeight
- (hh
+2)*2, '[-]', gStdFont
, 255, 255, 255, 1);
3896 e_TextureFontPrintEx(26*ww
, gScreenHeight
- (hh
+2)*2, 'Step ' + IntToStr(gSpectStep
), gStdFont
, 255, 255, 255, 1);
3897 e_TextureFontPrintEx(34*ww
, gScreenHeight
- (hh
+2)*2, '[+]', gStdFont
, 255, 255, 255, 1);
3898 e_TextureFontPrintEx(18*ww
, gScreenHeight
- (hh
+2), '<prev weap>', gStdFont
, 255, 255, 255, 1);
3899 e_TextureFontPrintEx(30*ww
, gScreenHeight
- (hh
+2), '<next weap>', gStdFont
, 255, 255, 255, 1);
3901 if gSpectMode
= SPECT_PLAYERS
then
3903 e_TextureFontPrintEx(22*ww
, gScreenHeight
- (hh
+2)*2, 'Player 1', gStdFont
, 255, 255, 255, 1);
3904 e_TextureFontPrintEx(20*ww
, gScreenHeight
- (hh
+2), '<left/right>', gStdFont
, 255, 255, 255, 1);
3905 if gSpectViewTwo
then
3907 e_TextureFontPrintEx(37*ww
, gScreenHeight
- (hh
+2)*2, 'Player 2', gStdFont
, 255, 255, 255, 1);
3908 e_TextureFontPrintEx(34*ww
, gScreenHeight
- (hh
+2), '<prev w/next w>', gStdFont
, 255, 255, 255, 1);
3909 e_TextureFontPrintEx(52*ww
, gScreenHeight
- (hh
+2)*2, '2x View', gStdFont
, 255, 255, 255, 1);
3910 e_TextureFontPrintEx(51*ww
, gScreenHeight
- (hh
+2), '<up/down>', gStdFont
, 255, 255, 255, 1);
3914 e_TextureFontPrintEx(35*ww
, gScreenHeight
- (hh
+2)*2, '2x View', gStdFont
, 255, 255, 255, 1);
3915 e_TextureFontPrintEx(34*ww
, gScreenHeight
- (hh
+2), '<up/down>', gStdFont
, 255, 255, 255, 1);
3921 if gPauseMain
and gGameOn
and (g_ActiveWindow
= nil) then
3923 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
3924 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
3926 e_CharFont_GetSize(gMenuFont
, _lc
[I_MENU_PAUSE
], w
, h
);
3927 e_CharFont_Print(gMenuFont
, (gScreenWidth
div 2)-(w
div 2),
3928 (gScreenHeight
div 2)-(h
div 2), _lc
[I_MENU_PAUSE
]);
3933 if (gState
= STATE_MENU
) then
3935 if (g_ActiveWindow
= nil) or (g_ActiveWindow
.BackTexture
= '') then DrawMenuBackground('MENU_BACKGROUND');
3936 // F3 at menu will show game loading dialog
3937 if e_KeyPressed(IK_F3
) then g_Menu_Show_LoadMenu(true);
3938 if (g_ActiveWindow
<> nil) then
3940 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
3941 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
3945 // F3 at titlepic will show game loading dialog
3946 if e_KeyPressed(IK_F3
) then
3948 g_Menu_Show_LoadMenu(true);
3949 if (g_ActiveWindow
<> nil) then e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
3954 if gState
= STATE_FOLD
then
3956 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 0, 0, 0, EndingGameCounter
);
3959 if gState
= STATE_INTERCUSTOM
then
3961 if gLastMap
and (gGameSettings
.GameMode
= GM_COOP
) then
3963 back
:= 'TEXTURE_endpic';
3964 if not g_Texture_Get(back
, ID
) then
3965 back
:= _lc
[I_TEXTURE_ENDPIC
];
3970 DrawMenuBackground(back
);
3974 if g_ActiveWindow
<> nil then
3976 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
3977 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
3981 if gState
= STATE_INTERSINGLE
then
3983 if EndingGameCounter
> 0 then
3985 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 0, 0, 0, EndingGameCounter
);
3991 DrawMenuBackground(back
);
3995 if g_ActiveWindow
<> nil then
3997 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
3998 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4003 if gState
= STATE_ENDPIC
then
4006 if not g_Texture_Get('TEXTURE_endpic', ID
) then
4007 g_Texture_Get(_lc
[I_TEXTURE_ENDPIC
], ID
);
4009 if ID
<> DWORD(-1) then
4010 e_DrawSize(ID
, 0, 0, 0, False, False, gScreenWidth
, gScreenHeight
)
4012 e_Clear(GL_COLOR_BUFFER_BIT
, 0, 0, 0);
4014 if g_ActiveWindow
<> nil then
4016 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4017 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4021 if gState
= STATE_SLIST
then
4023 // if g_Texture_Get('MENU_BACKGROUND', ID) then
4025 // e_DrawSize(ID, 0, 0, 0, False, False, gScreenWidth, gScreenHeight);
4026 // //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4028 DrawMenuBackground('MENU_BACKGROUND');
4029 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4030 g_Serverlist_Draw(slCurrent
, slTable
);
4034 if g_ActiveWindow
<> nil then
4038 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4039 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4041 g_ActiveWindow
.Draw();
4046 if g_debug_Sounds
and gGameOn
then
4048 for w
:= 0 to High(e_SoundsArray
) do
4049 for h
:= 0 to e_SoundsArray
[w
].nRefs
do
4050 e_DrawPoint(1, w
+100, h
+100, 255, 0, 0);
4055 e_TextureFontPrint(0, 0, Format('FPS: %d', [FPS
]), gStdFont
);
4056 e_TextureFontPrint(0, 16, Format('UPS: %d', [UPS
]), gStdFont
);
4059 if gGameOn
and gShowTime
then
4060 drawTime(gScreenWidth
-72, gScreenHeight
-16);
4062 if gGameOn
then drawProfilers();
4064 {$IFDEF ENABLE_HOLMES}
4071 procedure g_Game_Quit();
4073 g_Game_StopAllSounds(True);
4075 g_Game_SaveOptions();
4077 g_PlayerModel_FreeData();
4078 g_Texture_DeleteAll();
4079 g_Frames_DeleteAll();
4080 //g_Menu_Free(); //k8: this segfaults after resolution change; who cares?
4082 if NetInitDone
then g_Net_Free
;
4084 // Íàäî óäàëèòü êàðòó ïîñëå òåñòà:
4085 if gMapToDelete
<> '' then
4086 g_Game_DeleteTestMap();
4092 procedure g_FatalError(Text: String);
4094 g_Console_Add(Format(_lc
[I_FATAL_ERROR
], [Text]), True);
4095 e_WriteLog(Format(_lc
[I_FATAL_ERROR
], [Text]), TMsgType
.Warning
);
4097 gExit
:= EXIT_SIMPLE
;
4100 procedure g_SimpleError(Text: String);
4102 g_Console_Add(Format(_lc
[I_SIMPLE_ERROR
], [Text]), True);
4103 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], [Text]), TMsgType
.Warning
);
4106 procedure g_Game_SetupScreenSize();
4108 RES_FACTOR
= 4.0 / 3.0;
4114 // Ðàçìåð ýêðàíîâ èãðîêîâ:
4115 gPlayerScreenSize
.X
:= gScreenWidth
-196;
4116 if (gPlayer1
<> nil) and (gPlayer2
<> nil) then
4117 gPlayerScreenSize
.Y
:= gScreenHeight
div 2
4119 gPlayerScreenSize
.Y
:= gScreenHeight
;
4121 // Ðàçìåð çàäíåãî ïëàíà:
4122 if BackID
<> DWORD(-1) then
4125 if (gScreenWidth
*s
> gMapInfo
.Width
) or
4126 (gScreenHeight
*s
> gMapInfo
.Height
) then
4128 gBackSize
.X
:= gScreenWidth
;
4129 gBackSize
.Y
:= gScreenHeight
;
4133 e_GetTextureSize(BackID
, @bw
, @bh
);
4134 rf
:= Single(bw
) / Single(bh
);
4135 if (rf
> RES_FACTOR
) then bw
:= Round(Single(bh
) * RES_FACTOR
)
4136 else if (rf
< RES_FACTOR
) then bh
:= Round(Single(bw
) / RES_FACTOR
);
4137 s
:= Max(gScreenWidth
/ bw
, gScreenHeight
/ bh
);
4138 if (s
< 1.0) then s
:= 1.0;
4139 gBackSize
.X
:= Round(bw
*s
);
4140 gBackSize
.Y
:= Round(bh
*s
);
4145 procedure g_Game_ChangeResolution(newWidth
, newHeight
: Word; nowFull
, nowMax
: Boolean);
4147 g_Window_SetSize(newWidth
, newHeight
, nowFull
);
4150 procedure g_Game_AddPlayer(Team
: Byte = TEAM_NONE
);
4152 if ((not gGameOn
) and (gState
<> STATE_INTERCUSTOM
))
4153 or (not (gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
])) then
4155 if gPlayer1
= nil then
4157 if g_Game_IsClient
then
4159 if NetPlrUID1
> -1 then
4161 MC_SEND_CheatRequest(NET_CHEAT_SPECTATE
);
4162 gPlayer1
:= g_Player_Get(NetPlrUID1
);
4167 if not (Team
in [TEAM_RED
, TEAM_BLUE
]) then
4168 Team
:= gPlayer1Settings
.Team
;
4170 // Ñîçäàíèå ïåðâîãî èãðîêà:
4171 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4172 gPlayer1Settings
.Color
,
4174 if gPlayer1
= nil then
4175 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]))
4178 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4179 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [gPlayer1
.Name
]), True);
4180 if g_Game_IsServer
and g_Game_IsNet
then
4181 MH_SEND_PlayerCreate(gPlayer1
.UID
);
4182 gPlayer1
.Respawn(False, True);
4184 if g_Game_IsNet
and NetUseMaster
then
4190 if gPlayer2
= nil then
4192 if g_Game_IsClient
then
4194 if NetPlrUID2
> -1 then
4195 gPlayer2
:= g_Player_Get(NetPlrUID2
);
4199 if not (Team
in [TEAM_RED
, TEAM_BLUE
]) then
4200 Team
:= gPlayer2Settings
.Team
;
4202 // Ñîçäàíèå âòîðîãî èãðîêà:
4203 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
4204 gPlayer2Settings
.Color
,
4206 if gPlayer2
= nil then
4207 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]))
4210 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
4211 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [gPlayer2
.Name
]), True);
4212 if g_Game_IsServer
and g_Game_IsNet
then
4213 MH_SEND_PlayerCreate(gPlayer2
.UID
);
4214 gPlayer2
.Respawn(False, True);
4216 if g_Game_IsNet
and NetUseMaster
then
4224 procedure g_Game_RemovePlayer();
4228 if ((not gGameOn
) and (gState
<> STATE_INTERCUSTOM
))
4229 or (not (gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
])) then
4234 if g_Game_IsServer
then
4237 Pl
.Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
4238 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [Pl
.Name
]), True);
4239 g_Player_Remove(Pl
.UID
);
4241 if g_Game_IsNet
and NetUseMaster
then
4250 if g_Game_IsServer
then
4253 Pl
.Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
4254 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [Pl
.Name
]), True);
4255 g_Player_Remove(Pl
.UID
);
4257 if g_Game_IsNet
and NetUseMaster
then
4262 MC_SEND_CheatRequest(NET_CHEAT_SPECTATE
);
4268 procedure g_Game_Spectate();
4270 g_Game_RemovePlayer();
4271 if gPlayer1
<> nil then
4272 g_Game_RemovePlayer();
4275 procedure g_Game_SpectateCenterView();
4277 gSpectX
:= Max(gMapInfo
.Width
div 2 - gScreenWidth
div 2, 0);
4278 gSpectY
:= Max(gMapInfo
.Height
div 2 - gScreenHeight
div 2, 0);
4281 procedure g_Game_StartSingle(Map
: String; TwoPlayers
: Boolean; nPlayers
: Byte);
4288 e_WriteLog('Starting singleplayer game...', TMsgType
.Notify
);
4290 g_Game_ClearLoading();
4293 FillByte(gGameSettings
, SizeOf(TGameSettings
), 0);
4296 gGameSettings
.GameType
:= GT_SINGLE
;
4297 gGameSettings
.MaxLives
:= 0;
4298 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_ALLOWEXIT
;
4299 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_MONSTERS
;
4300 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_BOTVSMONSTER
;
4301 gSwitchGameMode
:= GM_SINGLE
;
4303 g_Game_ExecuteEvent('ongamestart');
4305 // Óñòàíîâêà ðàçìåðîâ îêîí èãðîêîâ:
4306 g_Game_SetupScreenSize();
4308 // Ñîçäàíèå ïåðâîãî èãðîêà:
4309 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4310 gPlayer1Settings
.Color
,
4311 gPlayer1Settings
.Team
, False));
4312 if gPlayer1
= nil then
4314 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
4318 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4321 // Ñîçäàíèå âòîðîãî èãðîêà, åñëè åñòü:
4324 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
4325 gPlayer2Settings
.Color
,
4326 gPlayer2Settings
.Team
, False));
4327 if gPlayer2
= nil then
4329 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
4333 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
4337 // Çàãðóçêà è çàïóñê êàðòû:
4338 if not g_Game_StartMap(MAP
, True) then
4340 if (Pos(':\', Map
) > 0) or (Pos(':/', Map
) > 0) then tmps
:= Map
else tmps
:= gGameSettings
.WAD
+ ':\' + MAP
;
4341 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [tmps
]));
4345 // Íàñòðîéêè èãðîêîâ è áîòîâ:
4349 for i
:= nPl
+1 to nPlayers
do
4350 g_Player_Create(STD_PLAYER_MODEL
, _RGB(0, 0, 0), 0, True);
4353 procedure g_Game_StartCustom(Map
: String; GameMode
: Byte;
4354 TimeLimit
, GoalLimit
: Word;
4356 Options
: LongWord; nPlayers
: Byte);
4362 e_WriteLog('Starting custom game...', TMsgType
.Notify
);
4364 g_Game_ClearLoading();
4367 gGameSettings
.GameType
:= GT_CUSTOM
;
4368 gGameSettings
.GameMode
:= GameMode
;
4369 gSwitchGameMode
:= GameMode
;
4370 gGameSettings
.TimeLimit
:= TimeLimit
;
4371 gGameSettings
.GoalLimit
:= GoalLimit
;
4372 gGameSettings
.MaxLives
:= IfThen(GameMode
= GM_CTF
, 0, MaxLives
);
4373 gGameSettings
.Options
:= Options
;
4375 gCoopTotalMonstersKilled
:= 0;
4376 gCoopTotalSecretsFound
:= 0;
4377 gCoopTotalMonsters
:= 0;
4378 gCoopTotalSecrets
:= 0;
4382 g_Game_ExecuteEvent('ongamestart');
4384 // Óñòàíîâêà ðàçìåðîâ îêîí èãðîêîâ:
4385 g_Game_SetupScreenSize();
4387 // Ðåæèì íàáëþäàòåëÿ:
4388 if nPlayers
= 0 then
4395 if nPlayers
>= 1 then
4397 // Ñîçäàíèå ïåðâîãî èãðîêà:
4398 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4399 gPlayer1Settings
.Color
,
4400 gPlayer1Settings
.Team
, False));
4401 if gPlayer1
= nil then
4403 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
4407 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4411 if nPlayers
>= 2 then
4413 // Ñîçäàíèå âòîðîãî èãðîêà:
4414 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
4415 gPlayer2Settings
.Color
,
4416 gPlayer2Settings
.Team
, False));
4417 if gPlayer2
= nil then
4419 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
4423 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
4427 // Çàãðóçêà è çàïóñê êàðòû:
4428 if not g_Game_StartMap(Map
, True) then
4430 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [Map
]));
4434 // Íåò òî÷åê ïîÿâëåíèÿ:
4435 if (g_Map_GetPointCount(RESPAWNPOINT_PLAYER1
) +
4436 g_Map_GetPointCount(RESPAWNPOINT_PLAYER2
) +
4437 g_Map_GetPointCount(RESPAWNPOINT_DM
) +
4438 g_Map_GetPointCount(RESPAWNPOINT_RED
)+
4439 g_Map_GetPointCount(RESPAWNPOINT_BLUE
)) < 1 then
4441 g_FatalError(_lc
[I_GAME_ERROR_GET_SPAWN
]);
4445 // Íàñòðîéêè èãðîêîâ è áîòîâ:
4449 for i
:= nPl
+1 to nPlayers
do
4450 g_Player_Create(STD_PLAYER_MODEL
, _RGB(0, 0, 0), 0, True);
4453 procedure g_Game_StartServer(Map
: String; GameMode
: Byte;
4454 TimeLimit
, GoalLimit
: Word; MaxLives
: Byte;
4455 Options
: LongWord; nPlayers
: Byte;
4456 IPAddr
: LongWord; Port
: Word);
4460 e_WriteLog('Starting net game (server)...', TMsgType
.Notify
);
4462 g_Game_ClearLoading();
4465 gGameSettings
.GameType
:= GT_SERVER
;
4466 gGameSettings
.GameMode
:= GameMode
;
4467 gSwitchGameMode
:= GameMode
;
4468 gGameSettings
.TimeLimit
:= TimeLimit
;
4469 gGameSettings
.GoalLimit
:= GoalLimit
;
4470 gGameSettings
.MaxLives
:= IfThen(GameMode
= GM_CTF
, 0, MaxLives
);
4471 gGameSettings
.Options
:= Options
;
4473 gCoopTotalMonstersKilled
:= 0;
4474 gCoopTotalSecretsFound
:= 0;
4475 gCoopTotalMonsters
:= 0;
4476 gCoopTotalSecrets
:= 0;
4480 g_Game_ExecuteEvent('ongamestart');
4482 // Óñòàíîâêà ðàçìåðîâ îêíà èãðîêà
4483 g_Game_SetupScreenSize();
4485 // Ðåæèì íàáëþäàòåëÿ:
4486 if nPlayers
= 0 then
4492 if nPlayers
>= 1 then
4494 // Ñîçäàíèå ïåðâîãî èãðîêà:
4495 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4496 gPlayer1Settings
.Color
,
4497 gPlayer1Settings
.Team
, False));
4498 if gPlayer1
= nil then
4500 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
4504 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4507 if nPlayers
>= 2 then
4509 // Ñîçäàíèå âòîðîãî èãðîêà:
4510 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
4511 gPlayer2Settings
.Color
,
4512 gPlayer2Settings
.Team
, False));
4513 if gPlayer2
= nil then
4515 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
4519 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
4522 g_Game_SetLoadingText(_lc
[I_LOAD_HOST
], 0, False);
4523 if NetForwardPorts
then
4524 g_Game_SetLoadingText(_lc
[I_LOAD_PORTS
], 0, False);
4527 if not g_Net_Host(IPAddr
, Port
, NetMaxClients
) then
4529 g_FatalError(_lc
[I_NET_MSG
] + _lc
[I_NET_ERR_HOST
]);
4533 g_Net_Slist_Set(NetSlistIP
, NetSlistPort
);
4535 // Çàãðóçêà è çàïóñê êàðòû:
4536 if not g_Game_StartMap(Map
, True) then
4538 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [Map
]));
4542 // Íåò òî÷åê ïîÿâëåíèÿ:
4543 if (g_Map_GetPointCount(RESPAWNPOINT_PLAYER1
) +
4544 g_Map_GetPointCount(RESPAWNPOINT_PLAYER2
) +
4545 g_Map_GetPointCount(RESPAWNPOINT_DM
) +
4546 g_Map_GetPointCount(RESPAWNPOINT_RED
)+
4547 g_Map_GetPointCount(RESPAWNPOINT_BLUE
)) < 1 then
4549 g_FatalError(_lc
[I_GAME_ERROR_GET_SPAWN
]);
4553 // Íàñòðîéêè èãðîêîâ è áîòîâ:
4556 NetState
:= NET_STATE_GAME
;
4559 procedure g_Game_StartClient(Addr
: String; Port
: Word; PW
: String);
4574 e_WriteLog('Starting net game (client)...', TMsgType
.Notify
);
4575 e_WriteLog('NET: Trying to connect to ' + Addr
+ ':' + IntToStr(Port
) + '...', TMsgType
.Notify
);
4577 g_Game_ClearLoading();
4580 gGameSettings
.GameType
:= GT_CLIENT
;
4582 gCoopTotalMonstersKilled
:= 0;
4583 gCoopTotalSecretsFound
:= 0;
4584 gCoopTotalMonsters
:= 0;
4585 gCoopTotalSecrets
:= 0;
4589 g_Game_ExecuteEvent('ongamestart');
4591 // Óñòàíîâêà ðàçìåðîâ îêîí èãðîêîâ:
4592 g_Game_SetupScreenSize();
4594 NetState
:= NET_STATE_AUTH
;
4596 g_Game_SetLoadingText(_lc
[I_LOAD_CONNECT
], 0, False);
4598 if not g_Net_Connect(Addr
, Port
) then
4600 g_FatalError(_lc
[I_NET_MSG
] + _lc
[I_NET_ERR_CONN
]);
4601 NetState
:= NET_STATE_NONE
;
4605 g_Game_SetLoadingText(_lc
[I_LOAD_SEND_INFO
], 0, False);
4607 g_Game_SetLoadingText(_lc
[I_LOAD_WAIT_INFO
], 0, False);
4612 while (enet_host_service(NetHost
, @NetEvent
, 0) > 0) do
4614 if (NetEvent
.kind
= ENET_EVENT_TYPE_RECEIVE
) then
4616 Ptr
:= NetEvent
.packet
^.data
;
4617 if not InMsg
.Init(Ptr
, NetEvent
.packet
^.dataLength
, True) then
4620 MID
:= InMsg
.ReadByte();
4622 if (MID
= NET_MSG_INFO
) and (State
= 0) then
4624 NetMyID
:= InMsg
.ReadByte();
4625 NetPlrUID1
:= InMsg
.ReadWord();
4627 WadName
:= InMsg
.ReadString();
4628 Map
:= InMsg
.ReadString();
4630 gWADHash
:= InMsg
.ReadMD5();
4632 gGameSettings
.GameMode
:= InMsg
.ReadByte();
4633 gSwitchGameMode
:= gGameSettings
.GameMode
;
4634 gGameSettings
.GoalLimit
:= InMsg
.ReadWord();
4635 gGameSettings
.TimeLimit
:= InMsg
.ReadWord();
4636 gGameSettings
.MaxLives
:= InMsg
.ReadByte();
4637 gGameSettings
.Options
:= InMsg
.ReadLongWord();
4638 T
:= InMsg
.ReadLongWord();
4640 newResPath
:= g_Res_SearchSameWAD(MapsDir
, WadName
, gWADHash
);
4641 if newResPath
= '' then
4643 g_Game_SetLoadingText(_lc
[I_LOAD_DL_RES
], 0, False);
4644 newResPath
:= g_Res_DownloadWAD(WadName
);
4645 if newResPath
= '' then
4647 g_FatalError(_lc
[I_NET_ERR_HASH
]);
4648 enet_packet_destroy(NetEvent
.packet
);
4649 NetState
:= NET_STATE_NONE
;
4653 newResPath
:= ExtractRelativePath(MapsDir
, newResPath
);
4655 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4656 gPlayer1Settings
.Color
,
4657 gPlayer1Settings
.Team
, False));
4659 if gPlayer1
= nil then
4661 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
4663 enet_packet_destroy(NetEvent
.packet
);
4664 NetState
:= NET_STATE_NONE
;
4668 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4669 gPlayer1
.UID
:= NetPlrUID1
;
4670 gPlayer1
.Reset(True);
4672 if not g_Game_StartMap(newResPath
+ ':\' + Map
, True) then
4674 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [WadName
+ ':\' + Map
]));
4676 enet_packet_destroy(NetEvent
.packet
);
4677 NetState
:= NET_STATE_NONE
;
4685 enet_packet_destroy(NetEvent
.packet
);
4689 enet_packet_destroy(NetEvent
.packet
);
4693 if (NetEvent
.kind
= ENET_EVENT_TYPE_DISCONNECT
) then
4696 if (NetEvent
.data
<= NET_DISC_MAX
) then
4697 g_Console_Add(_lc
[I_NET_MSG_ERROR
] + _lc
[I_NET_ERR_CONN
] + ' ' +
4698 _lc
[TStrings_Locale(Cardinal(I_NET_DISC_NONE
) + NetEvent
.data
)], True);
4705 ProcessLoading(true);
4707 if e_KeyPressed(IK_SPACE
) or e_KeyPressed(IK_ESCAPE
) or e_KeyPressed(VK_ESCAPE
) or
4708 e_KeyPressed(JOY0_JUMP
) or e_KeyPressed(JOY1_JUMP
) or e_KeyPressed(JOY2_JUMP
) or e_KeyPressed(JOY3_JUMP
) then
4717 g_FatalError(_lc
[I_NET_MSG
] + _lc
[I_NET_ERR_CONN
]);
4718 NetState
:= NET_STATE_NONE
;
4722 gLMSRespawn
:= LMS_RESPAWN_NONE
;
4723 gLMSRespawnTime
:= 0;
4726 NetState
:= NET_STATE_GAME
;
4727 MC_SEND_FullStateRequest
;
4728 e_WriteLog('NET: Connection successful.', TMsgType
.Notify
);
4731 procedure g_Game_SaveOptions();
4733 g_Options_Write_Video(GameDir
+'/'+CONFIG_FILENAME
);
4736 procedure g_Game_ChangeMap(const MapPath
: String);
4740 g_Game_ClearLoading();
4742 Force
:= gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
];
4743 // Åñëè óðîâåíü çàâåðøèëñÿ ïî òðèããåðó Âûõîä, íå î÷èùàòü èíâåíòàðü
4744 if gExitByTrigger
then
4747 gExitByTrigger
:= False;
4749 if not g_Game_StartMap(MapPath
, Force
) then
4750 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [MapPath
]));
4753 procedure g_Game_Restart();
4757 if g_Game_IsClient
then
4759 map
:= g_ExtractFileName(gMapInfo
.Map
);
4763 g_Game_ClearLoading();
4764 g_Game_StartMap(Map
, True, gCurrentMapFileName
);
4767 function g_Game_StartMap(Map
: String; Force
: Boolean = False; const oldMapPath
: AnsiString=''): Boolean;
4769 NewWAD
, ResName
: String;
4772 g_Map_Free((Map
<> gCurrentMapFileName
) and (oldMapPath
<> gCurrentMapFileName
));
4773 g_Player_RemoveAllCorpses();
4775 if (not g_Game_IsClient
) and
4776 (gSwitchGameMode
<> gGameSettings
.GameMode
) and
4777 (gGameSettings
.GameMode
<> GM_SINGLE
) then
4779 if gSwitchGameMode
= GM_CTF
then
4780 gGameSettings
.MaxLives
:= 0;
4781 gGameSettings
.GameMode
:= gSwitchGameMode
;
4784 gSwitchGameMode
:= gGameSettings
.GameMode
;
4786 g_Player_ResetTeams();
4788 if isWadPath(Map
) then
4790 NewWAD
:= g_ExtractWadName(Map
);
4791 ResName
:= g_ExtractFileName(Map
);
4792 if g_Game_IsServer
then
4794 gWADHash
:= MD5File(MapsDir
+ NewWAD
);
4795 g_Game_LoadWAD(NewWAD
);
4797 // hash received in MC_RECV_GameEvent -> NET_EV_MAPSTART
4798 g_Game_ClientWAD(NewWAD
, gWADHash
);
4802 Result
:= g_Map_Load(MapsDir
+ gGameSettings
.WAD
+ ':\' + ResName
);
4805 g_Player_ResetAll(Force
or gLastMap
, gGameSettings
.GameType
= GT_SINGLE
);
4807 gState
:= STATE_NONE
;
4808 g_ActiveWindow
:= nil;
4814 if gGameSettings
.GameMode
= GM_CTF
then
4816 g_Map_ResetFlag(FLAG_RED
);
4817 g_Map_ResetFlag(FLAG_BLUE
);
4818 // CTF, à ôëàãîâ íåò:
4819 if not g_Map_HaveFlagPoints() then
4820 g_SimpleError(_lc
[I_GAME_ERROR_CTF
]);
4825 gState
:= STATE_MENU
;
4830 gPauseMain
:= false;
4831 gPauseHolmes
:= false;
4833 NetTimeToUpdate
:= 1;
4834 NetTimeToReliable
:= 0;
4835 NetTimeToMaster
:= NetMasterRate
;
4836 gLMSRespawn
:= LMS_RESPAWN_NONE
;
4837 gLMSRespawnTime
:= 0;
4838 gMissionFailed
:= False;
4841 gCoopMonstersKilled
:= 0;
4842 gCoopSecretsFound
:= 0;
4844 gVoteInProgress
:= False;
4845 gVotePassed
:= False;
4851 if not gGameOn
then Exit
;
4853 g_Game_SpectateCenterView();
4855 if (gGameSettings
.MaxLives
> 0) and (gGameSettings
.WarmupTime
> 0) then
4857 gLMSRespawn
:= LMS_RESPAWN_WARMUP
;
4858 gLMSRespawnTime
:= gTime
+ gGameSettings
.WarmupTime
*1000;
4859 gLMSSoftSpawn
:= True;
4860 if NetMode
= NET_SERVER
then
4861 MH_SEND_GameEvent(NET_EV_LMS_WARMUP
, (gLMSRespawnTime
- gTime
) div 1000)
4863 g_Console_Add(Format(_lc
[I_MSG_WARMUP_START
], [(gLMSRespawnTime
- gTime
) div 1000]), True);
4866 if NetMode
= NET_SERVER
then
4868 MH_SEND_GameEvent(NET_EV_MAPSTART
, gGameSettings
.GameMode
, Map
);
4871 if NetUseMaster
then
4873 if (NetMHost
= nil) or (NetMPeer
= nil) then
4874 if not g_Net_Slist_Connect
then
4875 g_Console_Add(_lc
[I_NET_MSG_ERROR
] + _lc
[I_NET_SLIST_ERROR
]);
4880 if NetClients
<> nil then
4881 for I
:= 0 to High(NetClients
) do
4882 if NetClients
[I
].Used
then
4884 NetClients
[I
].Voted
:= False;
4885 if NetClients
[I
].RequestedFullUpdate
then
4887 MH_SEND_Everything((NetClients
[I
].State
= NET_STATE_AUTH
), I
);
4888 NetClients
[I
].RequestedFullUpdate
:= False;
4892 g_Net_UnbanNonPermHosts();
4897 gCoopTotalMonstersKilled
:= 0;
4898 gCoopTotalSecretsFound
:= 0;
4899 gCoopTotalMonsters
:= 0;
4900 gCoopTotalSecrets
:= 0;
4904 g_Game_ExecuteEvent('onmapstart');
4907 procedure SetFirstLevel();
4911 MapList
:= g_Map_GetMapsList(MapsDir
+ gGameSettings
.WAD
);
4912 if MapList
= nil then
4915 SortSArray(MapList
);
4916 gNextMap
:= MapList
[Low(MapList
)];
4921 procedure g_Game_ExitLevel(const Map
: AnsiString);
4925 gCoopTotalMonstersKilled
:= gCoopTotalMonstersKilled
+ gCoopMonstersKilled
;
4926 gCoopTotalSecretsFound
:= gCoopTotalSecretsFound
+ gCoopSecretsFound
;
4927 gCoopTotalMonsters
:= gCoopTotalMonsters
+ gTotalMonsters
;
4928 gCoopTotalSecrets
:= gCoopTotalSecrets
+ gSecretsCount
;
4930 // Âûøëè â âûõîä â Îäèíî÷íîé èãðå:
4931 if gGameSettings
.GameType
= GT_SINGLE
then
4932 gExit
:= EXIT_ENDLEVELSINGLE
4933 else // Âûøëè â âûõîä â Ñâîåé èãðå
4935 gExit
:= EXIT_ENDLEVELCUSTOM
;
4936 if gGameSettings
.GameMode
= GM_COOP
then
4937 g_Player_RememberAll
;
4939 if not g_Map_Exist(MapsDir
+ gGameSettings
.WAD
+ ':\' + gNextMap
) then
4942 if gGameSettings
.GameMode
= GM_COOP
then
4945 gStatsPressed
:= True;
4946 gNextMap
:= 'MAP01';
4948 if not g_Map_Exist(MapsDir
+ gGameSettings
.WAD
+ ':\' + gNextMap
) then
4951 if g_Game_IsNet
then
4953 MH_SEND_GameStats();
4954 MH_SEND_CoopStats();
4960 procedure g_Game_RestartLevel();
4964 if gGameSettings
.GameMode
= GM_SINGLE
then
4969 gExit
:= EXIT_ENDLEVELCUSTOM
;
4970 Map
:= g_ExtractFileName(gMapInfo
.Map
);
4974 procedure g_Game_ClientWAD(NewWAD
: String; WHash
: TMD5Digest
);
4978 if LowerCase(NewWAD
) = LowerCase(gGameSettings
.WAD
) then
4980 if not g_Game_IsClient
then
4982 gWAD
:= g_Res_SearchSameWAD(MapsDir
, ExtractFileName(NewWAD
), WHash
);
4985 g_Game_SetLoadingText(_lc
[I_LOAD_DL_RES
], 0, False);
4986 gWAD
:= g_Res_DownloadWAD(ExtractFileName(NewWAD
));
4990 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_WAD
], [ExtractFileName(NewWAD
)]));
4994 NewWAD
:= ExtractRelativePath(MapsDir
, gWAD
);
4995 g_Game_LoadWAD(NewWAD
);
4998 procedure g_Game_RestartRound(NoMapRestart
: Boolean = False);
5000 i
, n
, nb
, nr
: Integer;
5002 function monRespawn (mon
: TMonster
): Boolean;
5004 result
:= false; // don't stop
5005 if not mon
.FNoRespawn
then mon
.Respawn();
5009 if not g_Game_IsServer
then Exit
;
5010 if gLMSRespawn
= LMS_RESPAWN_NONE
then Exit
;
5011 gLMSRespawn
:= LMS_RESPAWN_NONE
;
5012 gLMSRespawnTime
:= 0;
5015 if (gGameSettings
.GameMode
= GM_COOP
) and not NoMapRestart
then
5017 gMissionFailed
:= True;
5018 g_Game_RestartLevel
;
5022 n
:= 0; nb
:= 0; nr
:= 0;
5023 for i
:= Low(gPlayers
) to High(gPlayers
) do
5024 if (gPlayers
[i
] <> nil) and
5025 ((not gPlayers
[i
].FSpectator
) or gPlayers
[i
].FWantsInGame
or
5026 (gPlayers
[i
] is TBot
)) then
5029 if gPlayers
[i
].Team
= TEAM_RED
then Inc(nr
)
5030 else if gPlayers
[i
].Team
= TEAM_BLUE
then Inc(nb
)
5033 if (n
< 2) or ((gGameSettings
.GameMode
= GM_TDM
) and ((nr
= 0) or (nb
= 0))) then
5035 // wait a second until the fuckers finally decide to join
5036 gLMSRespawn
:= LMS_RESPAWN_WARMUP
;
5037 gLMSRespawnTime
:= gTime
+ 1000;
5038 gLMSSoftSpawn
:= NoMapRestart
;
5042 g_Player_RemoveAllCorpses
;
5043 g_Game_Message(_lc
[I_MESSAGE_LMS_START
], 144);
5044 if g_Game_IsNet
then
5045 MH_SEND_GameEvent(NET_EV_LMS_START
);
5047 for i
:= Low(gPlayers
) to High(gPlayers
) do
5049 if gPlayers
[i
] = nil then continue
;
5050 if gPlayers
[i
] is TBot
then gPlayers
[i
].FWantsInGame
:= True;
5051 // don't touch normal spectators
5052 if gPlayers
[i
].FSpectator
and not gPlayers
[i
].FWantsInGame
then
5054 gPlayers
[i
].FNoRespawn
:= True;
5055 gPlayers
[i
].Lives
:= 0;
5056 if g_Game_IsNet
then
5057 MH_SEND_PlayerStats(gPlayers
[I
].UID
);
5060 gPlayers
[i
].FNoRespawn
:= False;
5061 gPlayers
[i
].Lives
:= gGameSettings
.MaxLives
;
5062 gPlayers
[i
].Respawn(False, True);
5063 if gGameSettings
.GameMode
= GM_COOP
then
5065 gPlayers
[i
].Frags
:= 0;
5066 gPlayers
[i
].RecallState
;
5068 if (gPlayer1
= nil) and (gLMSPID1
> 0) then
5069 gPlayer1
:= g_Player_Get(gLMSPID1
);
5070 if (gPlayer2
= nil) and (gLMSPID2
> 0) then
5071 gPlayer2
:= g_Player_Get(gLMSPID2
);
5074 g_Items_RestartRound();
5077 g_Mons_ForEach(monRespawn
);
5079 gLMSSoftSpawn
:= False;
5082 function g_Game_GetFirstMap(WAD
: String): String;
5086 MapList
:= g_Map_GetMapsList(WAD
);
5087 if MapList
= nil then
5090 SortSArray(MapList
);
5091 Result
:= MapList
[Low(MapList
)];
5093 if not g_Map_Exist(WAD
+ ':\' + Result
) then
5099 function g_Game_GetNextMap(): String;
5106 MapList
:= g_Map_GetMapsList(MapsDir
+ gGameSettings
.WAD
);
5107 if MapList
= nil then
5110 Map
:= g_ExtractFileName(gMapInfo
.Map
);
5112 SortSArray(MapList
);
5114 for I
:= Low(MapList
) to High(MapList
) do
5115 if Map
= MapList
[I
] then
5121 if MapIndex
<> -255 then
5123 if MapIndex
= High(MapList
) then
5124 Result
:= MapList
[Low(MapList
)]
5126 Result
:= MapList
[MapIndex
+ 1];
5128 if not g_Map_Exist(MapsDir
+ gGameSettings
.WAD
+ ':\' + Result
) then Result
:= Map
;
5134 procedure g_Game_NextLevel();
5136 if gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
, GM_COOP
] then
5137 gExit
:= EXIT_ENDLEVELCUSTOM
5140 gExit
:= EXIT_ENDLEVELSINGLE
;
5144 if gNextMap
<> '' then Exit
;
5145 gNextMap
:= g_Game_GetNextMap();
5148 function g_Game_IsTestMap(): Boolean;
5150 result
:= StrEquCI1251(TEST_MAP_NAME
, g_ExtractFileName(gMapInfo
.Map
));
5153 procedure g_Game_DeleteTestMap();
5156 //MapName: AnsiString;
5164 a
:= Pos('.wad:\', toLowerCase1251(gMapToDelete
));
5165 if (a
= 0) then a
:= Pos('.wad:/', toLowerCase1251(gMapToDelete
));
5166 if (a
= 0) then exit
;
5168 // Âûäåëÿåì èìÿ wad-ôàéëà è èìÿ êàðòû
5169 WadName
:= Copy(gMapToDelete
, 1, a
+3);
5170 Delete(gMapToDelete
, 1, a
+5);
5171 gMapToDelete
:= UpperCase(gMapToDelete
);
5173 //CopyMemory(@MapName[0], @gMapToDelete[1], Min(16, Length(gMapToDelete)));
5176 // Èìÿ êàðòû íå ñòàíäàðòíîå òåñòîâîå:
5177 if MapName <> TEST_MAP_NAME then
5180 if not gTempDelete then
5182 time := g_GetFileTime(WadName);
5183 WAD := TWADFile.Create();
5186 if not WAD.ReadFile(WadName) then
5187 begin // Íåò òàêîãî WAD-ôàéëà
5192 // Ñîñòàâëÿåì ñïèñîê êàðò è èùåì íóæíóþ:
5194 MapList := WAD.GetResourcesList('');
5196 if MapList <> nil then
5197 for a := 0 to High(MapList) do
5198 if MapList[a] = MapName then
5200 // Óäàëÿåì è ñîõðàíÿåì:
5201 WAD.RemoveResource('', MapName);
5202 WAD.SaveTo(WadName);
5207 g_SetFileTime(WadName, time);
5210 if gTempDelete
then DeleteFile(WadName
);
5213 procedure GameCVars(P
: SSArray
);
5216 stat
: TPlayerStatArray
;
5221 cmd
:= LowerCase(P
[0]);
5222 if (cmd
= 'g_friendlyfire') and not g_Game_IsClient
then
5224 with gGameSettings
do
5226 if (Length(P
) > 1) and
5227 ((P
[1] = '1') or (P
[1] = '0')) then
5229 if (P
[1][1] = '1') then
5230 Options
:= Options
or GAME_OPTION_TEAMDAMAGE
5232 Options
:= Options
and (not GAME_OPTION_TEAMDAMAGE
);
5235 if (LongBool(Options
and GAME_OPTION_TEAMDAMAGE
)) then
5236 g_Console_Add(_lc
[I_MSG_FRIENDLY_FIRE_ON
])
5238 g_Console_Add(_lc
[I_MSG_FRIENDLY_FIRE_OFF
]);
5240 if g_Game_IsNet
then MH_SEND_GameSettings
;
5243 else if (cmd
= 'g_weaponstay') and not g_Game_IsClient
then
5245 with gGameSettings
do
5247 if (Length(P
) > 1) and
5248 ((P
[1] = '1') or (P
[1] = '0')) then
5250 if (P
[1][1] = '1') then
5251 Options
:= Options
or GAME_OPTION_WEAPONSTAY
5253 Options
:= Options
and (not GAME_OPTION_WEAPONSTAY
);
5256 if (LongBool(Options
and GAME_OPTION_WEAPONSTAY
)) then
5257 g_Console_Add(_lc
[I_MSG_WEAPONSTAY_ON
])
5259 g_Console_Add(_lc
[I_MSG_WEAPONSTAY_OFF
]);
5261 if g_Game_IsNet
then MH_SEND_GameSettings
;
5264 else if cmd
= 'g_gamemode' then
5266 a
:= g_Game_TextToMode(P
[1]);
5267 if a
= GM_SINGLE
then a
:= GM_COOP
;
5268 if (Length(P
) > 1) and (a
<> GM_NONE
) and (not g_Game_IsClient
) then
5270 gSwitchGameMode
:= a
;
5271 if (gGameOn
and (gGameSettings
.GameMode
= GM_SINGLE
)) or
5272 (gState
= STATE_INTERSINGLE
) then
5273 gSwitchGameMode
:= GM_SINGLE
;
5275 gGameSettings
.GameMode
:= gSwitchGameMode
;
5277 if gSwitchGameMode
= gGameSettings
.GameMode
then
5278 g_Console_Add(Format(_lc
[I_MSG_GAMEMODE_CURRENT
],
5279 [g_Game_ModeToText(gGameSettings
.GameMode
)]))
5281 g_Console_Add(Format(_lc
[I_MSG_GAMEMODE_CHANGE
],
5282 [g_Game_ModeToText(gGameSettings
.GameMode
),
5283 g_Game_ModeToText(gSwitchGameMode
)]));
5285 else if (cmd
= 'g_allow_exit') and not g_Game_IsClient
then
5287 with gGameSettings
do
5289 if (Length(P
) > 1) and
5290 ((P
[1] = '1') or (P
[1] = '0')) then
5292 if (P
[1][1] = '1') then
5293 Options
:= Options
or GAME_OPTION_ALLOWEXIT
5295 Options
:= Options
and (not GAME_OPTION_ALLOWEXIT
);
5298 if (LongBool(Options
and GAME_OPTION_ALLOWEXIT
)) then
5299 g_Console_Add(_lc
[I_MSG_ALLOWEXIT_ON
])
5301 g_Console_Add(_lc
[I_MSG_ALLOWEXIT_OFF
]);
5302 g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
5304 if g_Game_IsNet
then MH_SEND_GameSettings
;
5307 else if (cmd
= 'g_allow_monsters') and not g_Game_IsClient
then
5309 with gGameSettings
do
5311 if (Length(P
) > 1) and
5312 ((P
[1] = '1') or (P
[1] = '0')) then
5314 if (P
[1][1] = '1') then
5315 Options
:= Options
or GAME_OPTION_MONSTERS
5317 Options
:= Options
and (not GAME_OPTION_MONSTERS
);
5320 if (LongBool(Options
and GAME_OPTION_MONSTERS
)) then
5321 g_Console_Add(_lc
[I_MSG_ALLOWMON_ON
])
5323 g_Console_Add(_lc
[I_MSG_ALLOWMON_OFF
]);
5324 g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
5326 if g_Game_IsNet
then MH_SEND_GameSettings
;
5329 else if (cmd
= 'g_bot_vsplayers') and not g_Game_IsClient
then
5331 with gGameSettings
do
5333 if (Length(P
) > 1) and
5334 ((P
[1] = '1') or (P
[1] = '0')) then
5336 if (P
[1][1] = '1') then
5337 Options
:= Options
or GAME_OPTION_BOTVSPLAYER
5339 Options
:= Options
and (not GAME_OPTION_BOTVSPLAYER
);
5342 if (LongBool(Options
and GAME_OPTION_BOTVSPLAYER
)) then
5343 g_Console_Add(_lc
[I_MSG_BOTSVSPLAYERS_ON
])
5345 g_Console_Add(_lc
[I_MSG_BOTSVSPLAYERS_OFF
]);
5347 if g_Game_IsNet
then MH_SEND_GameSettings
;
5350 else if (cmd
= 'g_bot_vsmonsters') and not g_Game_IsClient
then
5352 with gGameSettings
do
5354 if (Length(P
) > 1) and
5355 ((P
[1] = '1') or (P
[1] = '0')) then
5357 if (P
[1][1] = '1') then
5358 Options
:= Options
or GAME_OPTION_BOTVSMONSTER
5360 Options
:= Options
and (not GAME_OPTION_BOTVSMONSTER
);
5363 if (LongBool(Options
and GAME_OPTION_BOTVSMONSTER
)) then
5364 g_Console_Add(_lc
[I_MSG_BOTSVSMONSTERS_ON
])
5366 g_Console_Add(_lc
[I_MSG_BOTSVSMONSTERS_OFF
]);
5368 if g_Game_IsNet
then MH_SEND_GameSettings
;
5371 else if (cmd
= 'g_warmuptime') and not g_Game_IsClient
then
5373 if Length(P
) > 1 then
5375 if StrToIntDef(P
[1], gGameSettings
.WarmupTime
) = 0 then
5376 gGameSettings
.WarmupTime
:= 30
5378 gGameSettings
.WarmupTime
:= StrToIntDef(P
[1], gGameSettings
.WarmupTime
);
5381 g_Console_Add(Format(_lc
[I_MSG_WARMUP
],
5382 [gGameSettings
.WarmupTime
]));
5383 g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
5385 else if cmd
= 'net_interp' then
5387 if (Length(P
) > 1) then
5388 NetInterpLevel
:= StrToIntDef(P
[1], NetInterpLevel
);
5390 g_Console_Add('net_interp = ' + IntToStr(NetInterpLevel
));
5391 config
:= TConfig
.CreateFile(GameDir
+'/'+CONFIG_FILENAME
);
5392 config
.WriteInt('Client', 'InterpolationSteps', NetInterpLevel
);
5393 config
.SaveFile(GameDir
+'/'+CONFIG_FILENAME
);
5396 else if cmd
= 'net_forceplayerupdate' then
5398 if (Length(P
) > 1) and
5399 ((P
[1] = '1') or (P
[1] = '0')) then
5400 NetForcePlayerUpdate
:= (P
[1][1] = '1');
5402 if NetForcePlayerUpdate
then
5403 g_Console_Add('net_forceplayerupdate = 1')
5405 g_Console_Add('net_forceplayerupdate = 0');
5406 config
:= TConfig
.CreateFile(GameDir
+'/'+CONFIG_FILENAME
);
5407 config
.WriteBool('Client', 'ForcePlayerUpdate', NetForcePlayerUpdate
);
5408 config
.SaveFile(GameDir
+'/'+CONFIG_FILENAME
);
5411 else if cmd
= 'net_predictself' then
5413 if (Length(P
) > 1) and
5414 ((P
[1] = '1') or (P
[1] = '0')) then
5415 NetPredictSelf
:= (P
[1][1] = '1');
5417 if NetPredictSelf
then
5418 g_Console_Add('net_predictself = 1')
5420 g_Console_Add('net_predictself = 0');
5421 config
:= TConfig
.CreateFile(GameDir
+'/'+CONFIG_FILENAME
);
5422 config
.WriteBool('Client', 'PredictSelf', NetPredictSelf
);
5423 config
.SaveFile(GameDir
+'/'+CONFIG_FILENAME
);
5426 else if cmd
= 'sv_name' then
5428 if (Length(P
) > 1) and (Length(P
[1]) > 0) then
5430 NetServerName
:= P
[1];
5431 if Length(NetServerName
) > 64 then
5432 SetLength(NetServerName
, 64);
5433 if g_Game_IsServer
and g_Game_IsNet
and NetUseMaster
then
5437 g_Console_Add(cmd
+ ' = "' + NetServerName
+ '"');
5439 else if cmd
= 'sv_passwd' then
5441 if (Length(P
) > 1) and (Length(P
[1]) > 0) then
5443 NetPassword
:= P
[1];
5444 if Length(NetPassword
) > 24 then
5445 SetLength(NetPassword
, 24);
5446 if g_Game_IsServer
and g_Game_IsNet
and NetUseMaster
then
5450 g_Console_Add(cmd
+ ' = "' + AnsiLowerCase(NetPassword
) + '"');
5452 else if cmd
= 'sv_maxplrs' then
5454 if (Length(P
) > 1) then
5456 NetMaxClients
:= Min(Max(StrToIntDef(P
[1], NetMaxClients
), 1), NET_MAXCLIENTS
);
5457 if g_Game_IsServer
and g_Game_IsNet
then
5460 for a
:= 0 to High(NetClients
) do
5461 if NetClients
[a
].Used
then
5464 if b
> NetMaxClients
then
5466 s
:= g_Player_Get(NetClients
[a
].Player
).Name
;
5467 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_FULL
);
5468 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
5469 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
5472 if NetUseMaster
then
5477 g_Console_Add(cmd
+ ' = ' + IntToStr(NetMaxClients
));
5479 else if cmd
= 'sv_public' then
5481 if (Length(P
) > 1) then
5483 NetUseMaster
:= StrToIntDef(P
[1], Byte(NetUseMaster
)) > 0;
5484 if g_Game_IsServer
and g_Game_IsNet
then
5485 if NetUseMaster
then
5487 if NetMPeer
= nil then
5488 if not g_Net_Slist_Connect() then
5489 g_Console_Add(_lc
[I_NET_MSG_ERROR
] + _lc
[I_NET_SLIST_ERROR
]);
5490 g_Net_Slist_Update();
5493 if NetMPeer
<> nil then
5494 g_Net_Slist_Disconnect();
5497 g_Console_Add(cmd
+ ' = ' + IntToStr(Byte(NetUseMaster
)));
5499 else if cmd
= 'sv_intertime' then
5501 if (Length(P
) > 1) then
5502 gDefInterTime
:= Min(Max(StrToIntDef(P
[1], gDefInterTime
), -1), 120);
5504 g_Console_Add(cmd
+ ' = ' + IntToStr(gDefInterTime
));
5506 else if cmd
= 'p1_name' then
5508 if (Length(P
) > 1) and gGameOn
then
5510 if g_Game_IsClient
then
5512 gPlayer1Settings
.Name
:= b_Text_Unformat(P
[1]);
5513 MC_SEND_PlayerSettings
;
5516 if gPlayer1
<> nil then
5518 gPlayer1
.Name
:= b_Text_Unformat(P
[1]);
5519 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer1
.UID
);
5522 gPlayer1Settings
.Name
:= b_Text_Unformat(P
[1]);
5525 else if cmd
= 'p2_name' then
5527 if (Length(P
) > 1) and gGameOn
then
5529 if g_Game_IsClient
then
5531 gPlayer2Settings
.Name
:= b_Text_Unformat(P
[1]);
5532 MC_SEND_PlayerSettings
;
5535 if gPlayer2
<> nil then
5537 gPlayer2
.Name
:= b_Text_Unformat(P
[1]);
5538 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer2
.UID
);
5541 gPlayer2Settings
.Name
:= b_Text_Unformat(P
[1]);
5544 else if cmd
= 'p1_color' then
5546 if Length(P
) > 3 then
5547 if g_Game_IsClient
then
5549 gPlayer1Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
5550 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
5551 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
5552 MC_SEND_PlayerSettings
;
5555 if gPlayer1
<> nil then
5557 gPlayer1
.Model
.SetColor(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
5558 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
5559 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
5560 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer1
.UID
);
5563 gPlayer1Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
5564 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
5565 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
5567 else if (cmd
= 'p2_color') and not g_Game_IsNet
then
5569 if Length(P
) > 3 then
5570 if g_Game_IsClient
then
5572 gPlayer2Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
5573 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
5574 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
5575 MC_SEND_PlayerSettings
;
5578 if gPlayer2
<> nil then
5580 gPlayer2
.Model
.SetColor(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
5581 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
5582 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
5583 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer2
.UID
);
5586 gPlayer2Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
5587 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
5588 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
5590 else if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
5592 if cmd
= 'r_showscore' then
5594 if (Length(P
) > 1) and
5595 ((P
[1] = '1') or (P
[1] = '0')) then
5596 gShowGoals
:= (P
[1][1] = '1');
5599 g_Console_Add(_lc
[I_MSG_SCORE_ON
])
5601 g_Console_Add(_lc
[I_MSG_SCORE_OFF
]);
5603 else if cmd
= 'r_showstat' then
5605 if (Length(P
) > 1) and
5606 ((P
[1] = '1') or (P
[1] = '0')) then
5607 gShowStat
:= (P
[1][1] = '1');
5610 g_Console_Add(_lc
[I_MSG_STATS_ON
])
5612 g_Console_Add(_lc
[I_MSG_STATS_OFF
]);
5614 else if cmd
= 'r_showkillmsg' then
5616 if (Length(P
) > 1) and
5617 ((P
[1] = '1') or (P
[1] = '0')) then
5618 gShowKillMsg
:= (P
[1][1] = '1');
5620 if gShowKillMsg
then
5621 g_Console_Add(_lc
[I_MSG_KILL_MSGS_ON
])
5623 g_Console_Add(_lc
[I_MSG_KILL_MSGS_OFF
]);
5625 else if cmd
= 'r_showlives' then
5627 if (Length(P
) > 1) and
5628 ((P
[1] = '1') or (P
[1] = '0')) then
5629 gShowLives
:= (P
[1][1] = '1');
5632 g_Console_Add(_lc
[I_MSG_LIVES_ON
])
5634 g_Console_Add(_lc
[I_MSG_LIVES_OFF
]);
5636 else if cmd
= 'r_showspect' then
5638 if (Length(P
) > 1) and
5639 ((P
[1] = '1') or (P
[1] = '0')) then
5640 gSpectHUD
:= (P
[1][1] = '1');
5643 g_Console_Add(_lc
[I_MSG_SPECT_HUD_ON
])
5645 g_Console_Add(_lc
[I_MSG_SPECT_HUD_OFF
]);
5647 else if cmd
= 'r_showping' then
5649 if (Length(P
) > 1) and
5650 ((P
[1] = '1') or (P
[1] = '0')) then
5651 gShowPing
:= (P
[1][1] = '1');
5654 g_Console_Add(_lc
[I_MSG_PING_ON
])
5656 g_Console_Add(_lc
[I_MSG_PING_OFF
]);
5658 else if (cmd
= 'g_scorelimit') and not g_Game_IsClient
then
5660 if Length(P
) > 1 then
5662 if StrToIntDef(P
[1], gGameSettings
.GoalLimit
) = 0 then
5663 gGameSettings
.GoalLimit
:= 0
5668 if gGameSettings
.GameMode
= GM_DM
then
5670 stat
:= g_Player_GetStats();
5672 for a
:= 0 to High(stat
) do
5673 if stat
[a
].Frags
> b
then
5677 b
:= Max(gTeamStat
[TEAM_RED
].Goals
, gTeamStat
[TEAM_BLUE
].Goals
);
5679 gGameSettings
.GoalLimit
:= Max(StrToIntDef(P
[1], gGameSettings
.GoalLimit
), b
);
5682 if g_Game_IsNet
then MH_SEND_GameSettings
;
5685 g_Console_Add(Format(_lc
[I_MSG_SCORE_LIMIT
], [gGameSettings
.GoalLimit
]));
5687 else if (cmd
= 'g_timelimit') and not g_Game_IsClient
then
5689 if (Length(P
) > 1) and (StrToIntDef(P
[1], -1) >= 0) then
5690 gGameSettings
.TimeLimit
:= StrToIntDef(P
[1], -1);
5692 g_Console_Add(Format(_lc
[I_MSG_TIME_LIMIT
],
5693 [gGameSettings
.TimeLimit
div 3600,
5694 (gGameSettings
.TimeLimit
div 60) mod 60,
5695 gGameSettings
.TimeLimit
mod 60]));
5696 if g_Game_IsNet
then MH_SEND_GameSettings
;
5698 else if (cmd
= 'g_maxlives') and not g_Game_IsClient
then
5700 if Length(P
) > 1 then
5702 if StrToIntDef(P
[1], gGameSettings
.MaxLives
) = 0 then
5703 gGameSettings
.MaxLives
:= 0
5707 stat
:= g_Player_GetStats();
5709 for a
:= 0 to High(stat
) do
5710 if stat
[a
].Lives
> b
then
5712 gGameSettings
.MaxLives
:=
5713 Max(StrToIntDef(P
[1], gGameSettings
.MaxLives
), b
);
5717 g_Console_Add(Format(_lc
[I_MSG_LIVES
],
5718 [gGameSettings
.MaxLives
]));
5719 if g_Game_IsNet
then MH_SEND_GameSettings
;
5724 procedure PrintHeapStats();
5728 hs
:= GetFPCHeapStatus();
5729 e_LogWriteLn ('v===== heap status =====v');
5730 e_LogWriteFln('max heap size = %d k', [hs
.MaxHeapSize
div 1024]);
5731 e_LogWriteFln('max heap used = %d k', [hs
.MaxHeapUsed
div 1024]);
5732 e_LogWriteFln('cur heap size = %d k', [hs
.CurrHeapSize
div 1024]);
5733 e_LogWriteFln('cur heap used = %d k', [hs
.CurrHeapUsed
div 1024]);
5734 e_LogWriteFln('cur heap free = %d k', [hs
.CurrHeapFree
div 1024]);
5735 e_LogWriteLn ('^=======================^');
5738 procedure DebugCommands(P
: SSArray
);
5745 // Êîìàíäû îòëàäî÷íîãî ðåæèìà:
5746 if {gDebugMode}conIsCheatsEnabled
then
5748 cmd
:= LowerCase(P
[0]);
5749 if cmd
= 'd_window' then
5751 g_Console_Add(Format('gWinPosX = %d, gWinPosY %d', [gWinPosX
, gWinPosY
]));
5752 g_Console_Add(Format('gWinRealPosX = %d, gWinRealPosY %d', [gWinRealPosX
, gWinRealPosY
]));
5753 g_Console_Add(Format('gScreenWidth = %d, gScreenHeight = %d', [gScreenWidth
, gScreenHeight
]));
5754 g_Console_Add(Format('gWinSizeX = %d, gWinSizeY = %d', [gWinSizeX
, gWinSizeY
]));
5755 g_Console_Add(Format('Frame X = %d, Y = %d, Caption Y = %d', [gWinFrameX
, gWinFrameY
, gWinCaption
]));
5757 else if cmd
= 'd_sounds' then
5759 if (Length(P
) > 1) and
5760 ((P
[1] = '1') or (P
[1] = '0')) then
5761 g_Debug_Sounds
:= (P
[1][1] = '1');
5763 g_Console_Add(Format('d_sounds is %d', [Byte(g_Debug_Sounds
)]));
5765 else if cmd
= 'd_frames' then
5767 if (Length(P
) > 1) and
5768 ((P
[1] = '1') or (P
[1] = '0')) then
5769 g_Debug_Frames
:= (P
[1][1] = '1');
5771 g_Console_Add(Format('d_frames is %d', [Byte(g_Debug_Frames
)]));
5773 else if cmd
= 'd_winmsg' then
5775 if (Length(P
) > 1) and
5776 ((P
[1] = '1') or (P
[1] = '0')) then
5777 g_Debug_WinMsgs
:= (P
[1][1] = '1');
5779 g_Console_Add(Format('d_winmsg is %d', [Byte(g_Debug_WinMsgs
)]));
5781 else if (cmd
= 'd_monoff') and not g_Game_IsNet
then
5783 if (Length(P
) > 1) and
5784 ((P
[1] = '1') or (P
[1] = '0')) then
5785 g_Debug_MonsterOff
:= (P
[1][1] = '1');
5787 g_Console_Add(Format('d_monoff is %d', [Byte(g_debug_MonsterOff
)]));
5789 else if (cmd
= 'd_botoff') and not g_Game_IsNet
then
5791 if Length(P
) > 1 then
5793 '0': g_debug_BotAIOff
:= 0;
5794 '1': g_debug_BotAIOff
:= 1;
5795 '2': g_debug_BotAIOff
:= 2;
5796 '3': g_debug_BotAIOff
:= 3;
5799 g_Console_Add(Format('d_botoff is %d', [g_debug_BotAIOff
]));
5801 else if cmd
= 'd_monster' then
5803 if gGameOn
and (gPlayer1
<> nil) and (gPlayer1
.alive
) and (not g_Game_IsNet
) then
5804 if Length(P
) < 2 then
5806 g_Console_Add(cmd
+ ' [ID | Name] [behaviour]');
5807 g_Console_Add('ID | Name');
5808 for b
:= MONSTER_DEMON
to MONSTER_MAN
do
5809 g_Console_Add(Format('%2d | %s', [b
, g_Mons_NameByTypeId(b
)]));
5810 conwriteln('behav. num'#10'normal 0'#10'killer 1'#10'maniac 2'#10'insane 3'#10'cannibal 4'#10'good 5');
5813 a
:= StrToIntDef(P
[1], 0);
5814 if (a
< MONSTER_DEMON
) or (a
> MONSTER_MAN
) then
5815 a
:= g_Mons_TypeIdByName(P
[1]);
5817 if (a
< MONSTER_DEMON
) or (a
> MONSTER_MAN
) then
5818 g_Console_Add(Format(_lc
[I_MSG_NO_MONSTER
], [P
[1]]))
5821 with gPlayer1
.Obj
do
5823 mon
:= g_Monsters_Create(a
,
5824 X
+ Rect
.X
+ (Rect
.Width
div 2),
5825 Y
+ Rect
.Y
+ Rect
.Height
,
5826 gPlayer1
.Direction
, True);
5828 if (Length(P
) > 2) and (mon
<> nil) then
5830 if (CompareText(P
[2], 'normal') = 0) then mon
.MonsterBehaviour
:= BH_NORMAL
5831 else if (CompareText(P
[2], 'killer') = 0) then mon
.MonsterBehaviour
:= BH_KILLER
5832 else if (CompareText(P
[2], 'maniac') = 0) then mon
.MonsterBehaviour
:= BH_MANIAC
5833 else if (CompareText(P
[2], 'insane') = 0) then mon
.MonsterBehaviour
:= BH_INSANE
5834 else if (CompareText(P
[2], 'cannibal') = 0) then mon
.MonsterBehaviour
:= BH_CANNIBAL
5835 else if (CompareText(P
[2], 'good') = 0) then mon
.MonsterBehaviour
:= BH_GOOD
5836 else if (CompareText(P
[2], 'friend') = 0) then mon
.MonsterBehaviour
:= BH_GOOD
5837 else if (CompareText(P
[2], 'friendly') = 0) then mon
.MonsterBehaviour
:= BH_GOOD
5838 else mon
.MonsterBehaviour
:= Min(Max(StrToIntDef(P
[2], BH_NORMAL
), BH_NORMAL
), BH_GOOD
);
5843 else if (cmd
= 'd_health') then
5845 if (Length(P
) > 1) and
5846 ((P
[1] = '1') or (P
[1] = '0')) then
5847 g_debug_HealthBar
:= (P
[1][1] = '1');
5849 g_Console_Add(Format('d_health is %d', [Byte(g_debug_HealthBar
)]));
5851 else if (cmd
= 'd_player') then
5853 if (Length(P
) > 1) and
5854 ((P
[1] = '1') or (P
[1] = '0')) then
5855 g_debug_Player
:= (P
[1][1] = '1');
5857 g_Console_Add(Format(cmd
+ ' is %d', [Byte(g_Debug_Player
)]));
5859 else if (cmd
= 'd_mem') then
5865 g_Console_Add(_lc
[I_MSG_NOT_DEBUG
]);
5869 procedure GameCheats(P
: SSArray
);
5875 if (not gGameOn
) or (not conIsCheatsEnabled
) then
5877 g_Console_Add('not available');
5883 g_Console_Add('where is the player?!');
5886 cmd
:= LowerCase(P
[0]);
5890 plr
.GodMode
:= not plr
.GodMode
;
5891 if plr
.GodMode
then g_Console_Add('player is godlike now') else g_Console_Add('player is mortal now');
5894 // give <health|exit|weapons|air|suit|jetpack|berserk|all>
5895 if cmd
= 'give' then
5897 if length(P
) < 2 then begin g_Console_Add('give what?!'); exit
; end;
5898 for f
:= 1 to High(P
) do
5900 cmd
:= LowerCase(P
[f
]);
5901 if cmd
= 'health' then begin plr
.RestoreHealthArmor(); g_Console_Add('player feels himself better'); continue
; end;
5902 if (cmd
= 'all') {or (cmd = 'weapons')} then begin plr
.AllRulez(False); g_Console_Add('player got the gifts'); continue
; end;
5903 if cmd
= 'exit' then
5905 if gTriggers
<> nil then
5907 for a
:= 0 to High(gTriggers
) do
5909 if gTriggers
[a
].TriggerType
= TRIGGER_EXIT
then
5911 g_Console_Add('player left the map');
5912 gExitByTrigger
:= True;
5913 //g_Game_ExitLevel(gTriggers[a].Data.MapName);
5914 g_Game_ExitLevel(gTriggers
[a
].tgcMap
);
5922 if cmd
= 'air' then begin plr
.GiveItem(ITEM_OXYGEN
); g_Console_Add('player got some air'); continue
; end;
5923 if cmd
= 'jetpack' then begin plr
.GiveItem(ITEM_JETPACK
); g_Console_Add('player got a jetpack'); continue
; end;
5924 if cmd
= 'suit' then begin plr
.GiveItem(ITEM_SUIT
); g_Console_Add('player got an envirosuit'); continue
; end;
5925 if cmd
= 'berserk' then begin plr
.GiveItem(ITEM_MEDKIT_BLACK
); g_Console_Add('player got a berserk pack'); continue
; end;
5926 if cmd
= 'backpack' then begin plr
.GiveItem(ITEM_AMMO_BACKPACK
); g_Console_Add('player got a backpack'); continue
; end;
5928 if cmd
= 'helmet' then begin plr
.GiveItem(ITEM_HELMET
); g_Console_Add('player got a helmet'); continue
; end;
5929 if cmd
= 'bottle' then begin plr
.GiveItem(ITEM_BOTTLE
); g_Console_Add('player got a bottle of health'); continue
; end;
5931 if cmd
= 'stimpack' then begin plr
.GiveItem(ITEM_MEDKIT_SMALL
); g_Console_Add('player got a stimpack'); continue
; end;
5932 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;
5934 if cmd
= 'greenarmor' then begin plr
.GiveItem(ITEM_ARMOR_GREEN
); g_Console_Add('player got a security armor'); continue
; end;
5935 if cmd
= 'bluearmor' then begin plr
.GiveItem(ITEM_ARMOR_BLUE
); g_Console_Add('player got a combat armor'); continue
; end;
5937 if (cmd
= 'megasphere') or (cmd
= 'mega') then begin plr
.GiveItem(ITEM_SPHERE_BLUE
); g_Console_Add('player got a megasphere'); continue
; end;
5938 if (cmd
= 'soulsphere') or (cmd
= 'soul')then begin plr
.GiveItem(ITEM_SPHERE_WHITE
); g_Console_Add('player got a soul sphere'); continue
; end;
5940 if (cmd
= 'invul') or (cmd
= 'invulnerability') then begin plr
.GiveItem(ITEM_INVUL
); g_Console_Add('player got invulnerability'); continue
; end;
5941 if (cmd
= 'invis') or (cmd
= 'invisibility') then begin plr
.GiveItem(ITEM_INVIS
); g_Console_Add('player got invisibility'); continue
; end;
5943 if cmd
= 'redkey' then begin plr
.GiveItem(ITEM_KEY_RED
); g_Console_Add('player got the red key'); continue
; end;
5944 if cmd
= 'greenkey' then begin plr
.GiveItem(ITEM_KEY_GREEN
); g_Console_Add('player got the green key'); continue
; end;
5945 if cmd
= 'bluekey' then begin plr
.GiveItem(ITEM_KEY_BLUE
); g_Console_Add('player got the blue key'); continue
; end;
5947 if (cmd
= 'shotgun') or (cmd
= 'sg') then begin plr
.GiveItem(ITEM_WEAPON_SHOTGUN1
); g_Console_Add('player got a shotgun'); continue
; end;
5948 if (cmd
= 'supershotgun') or (cmd
= 'ssg') then begin plr
.GiveItem(ITEM_WEAPON_SHOTGUN2
); g_Console_Add('player got a supershotgun'); continue
; end;
5949 if cmd
= 'chaingun' then begin plr
.GiveItem(ITEM_WEAPON_CHAINGUN
); g_Console_Add('player got a chaingun'); continue
; end;
5950 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;
5951 if cmd
= 'plasmagun' then begin plr
.GiveItem(ITEM_WEAPON_PLASMA
); g_Console_Add('player got a plasma gun'); continue
; end;
5952 if cmd
= 'bfg' then begin plr
.GiveItem(ITEM_WEAPON_BFG
); g_Console_Add('player got a BFG-9000'); continue
; end;
5954 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;
5955 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;
5956 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;
5957 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;
5958 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;
5959 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;
5961 if cmd
= 'superchaingun' then begin plr
.GiveItem(ITEM_WEAPON_SUPERPULEMET
); g_Console_Add('player got a superchaingun'); continue
; end;
5962 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;
5964 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;
5965 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;
5967 if cmd
= 'chainsaw' then begin plr
.GiveItem(ITEM_WEAPON_SAW
); g_Console_Add('player got a chainsaw'); continue
; end;
5969 if cmd
= 'ammo' then
5971 plr
.GiveItem(ITEM_AMMO_SHELLS_BOX
);
5972 plr
.GiveItem(ITEM_AMMO_BULLETS_BOX
);
5973 plr
.GiveItem(ITEM_AMMO_CELL_BIG
);
5974 plr
.GiveItem(ITEM_AMMO_ROCKET_BOX
);
5975 plr
.GiveItem(ITEM_AMMO_FUELCAN
);
5976 g_Console_Add('player got some ammo');
5980 if cmd
= 'clip' then begin plr
.GiveItem(ITEM_AMMO_BULLETS
); g_Console_Add('player got some bullets'); continue
; end;
5981 if cmd
= 'bullets' then begin plr
.GiveItem(ITEM_AMMO_BULLETS_BOX
); g_Console_Add('player got a box of bullets'); continue
; end;
5983 if cmd
= 'shells' then begin plr
.GiveItem(ITEM_AMMO_SHELLS
); g_Console_Add('player got some shells'); continue
; end;
5984 if cmd
= 'shellbox' then begin plr
.GiveItem(ITEM_AMMO_SHELLS_BOX
); g_Console_Add('player got a box of shells'); continue
; end;
5986 if cmd
= 'cells' then begin plr
.GiveItem(ITEM_AMMO_CELL
); g_Console_Add('player got some cells'); continue
; end;
5987 if cmd
= 'battery' then begin plr
.GiveItem(ITEM_AMMO_CELL_BIG
); g_Console_Add('player got cell battery'); continue
; end;
5989 if cmd
= 'rocket' then begin plr
.GiveItem(ITEM_AMMO_ROCKET
); g_Console_Add('player got a rocket'); continue
; end;
5990 if cmd
= 'rocketbox' then begin plr
.GiveItem(ITEM_AMMO_ROCKET_BOX
); g_Console_Add('player got some rockets'); continue
; end;
5992 if (cmd
= 'fuel') or (cmd
= 'fuelcan') then begin plr
.GiveItem(ITEM_AMMO_FUELCAN
); g_Console_Add('player got fuel canister'); continue
; end;
5994 if cmd
= 'weapons' then
5996 plr
.GiveItem(ITEM_WEAPON_SHOTGUN1
);
5997 plr
.GiveItem(ITEM_WEAPON_SHOTGUN2
);
5998 plr
.GiveItem(ITEM_WEAPON_CHAINGUN
);
5999 plr
.GiveItem(ITEM_WEAPON_ROCKETLAUNCHER
);
6000 plr
.GiveItem(ITEM_WEAPON_PLASMA
);
6001 plr
.GiveItem(ITEM_WEAPON_BFG
);
6002 g_Console_Add('player got weapons');
6006 if cmd
= 'keys' then
6008 plr
.GiveItem(ITEM_KEY_RED
);
6009 plr
.GiveItem(ITEM_KEY_GREEN
);
6010 plr
.GiveItem(ITEM_KEY_BLUE
);
6011 g_Console_Add('player got all keys');
6015 g_Console_Add('i don''t know how to give '''+cmd
+'''!');
6020 if cmd
= 'open' then
6022 g_Console_Add('player activated sesame');
6023 g_Triggers_OpenAll();
6030 if gFly
then g_Console_Add('player feels himself lighter') else g_Console_Add('player lost his wings');
6034 if cmd
= 'noclip' then
6037 g_Console_Add('wall hardeness adjusted');
6041 if cmd
= 'notarget' then
6043 plr
.NoTarget
:= not plr
.NoTarget
;
6044 if plr
.NoTarget
then g_Console_Add('player hides in shadows') else g_Console_Add('player is brave again');
6048 if cmd
= 'noreload' then
6050 plr
.NoReload
:= not plr
.NoReload
;
6051 if plr
.NoReload
then g_Console_Add('player is action hero now') else g_Console_Add('player is ordinary man now');
6055 if cmd
= 'speedy' then
6057 MAX_RUNVEL
:= 32-MAX_RUNVEL
;
6058 g_Console_Add('speed adjusted');
6062 if cmd
= 'jumpy' then
6064 VEL_JUMP
:= 30-VEL_JUMP
;
6065 g_Console_Add('jump height adjusted');
6069 if cmd
= 'automap' then
6071 gShowMap
:= not gShowMap
;
6072 if gShowMap
then g_Console_Add('player gains second sight') else g_Console_Add('player lost second sight');
6076 if cmd
= 'aimline' then
6078 gAimLine
:= not gAimLine
;
6079 if gAimLine
then g_Console_Add('player gains laser sight') else g_Console_Add('player lost laser sight');
6084 procedure GameCommands(P
: SSArray
);
6090 pl
: pTNetClient
= nil;
6097 cmd
:= LowerCase(P
[0]);
6099 if (cmd
= 'quit') or
6106 else if cmd
= 'pause' then
6108 if (g_ActiveWindow
= nil) then
6109 g_Game_Pause(not gPauseMain
);
6111 else if cmd
= 'endgame' then
6112 gExit
:= EXIT_SIMPLE
6113 else if cmd
= 'restart' then
6115 if gGameOn
or (gState
in [STATE_INTERSINGLE
, STATE_INTERCUSTOM
]) then
6117 if g_Game_IsClient
then
6119 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6124 g_Console_Add(_lc
[I_MSG_NOT_GAME
]);
6126 else if cmd
= 'kick' then
6128 if g_Game_IsServer
then
6130 if Length(P
) < 2 then
6132 g_Console_Add('kick <name>');
6137 g_Console_Add('kick <name>');
6141 if g_Game_IsNet
then
6142 pl
:= g_Net_Client_ByName(P
[1]);
6145 s
:= g_Net_ClientName_ByID(pl
^.ID
);
6146 enet_peer_disconnect(pl
^.Peer
, NET_DISC_KICK
);
6147 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
6148 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
6149 if NetUseMaster
then
6151 end else if gPlayers
<> nil then
6152 for a
:= Low(gPlayers
) to High(gPlayers
) do
6153 if gPlayers
[a
] <> nil then
6154 if Copy(LowerCase(gPlayers
[a
].Name
), 1, Length(P
[1])) = LowerCase(P
[1]) then
6156 // Íå îòêëþ÷àòü îñíîâíûõ èãðîêîâ â ñèíãëå
6157 if not(gPlayers
[a
] is TBot
) and (gGameSettings
.GameType
= GT_SINGLE
) then
6159 gPlayers
[a
].Lives
:= 0;
6160 gPlayers
[a
].Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
6161 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [gPlayers
[a
].Name
]), True);
6162 g_Player_Remove(gPlayers
[a
].UID
);
6163 if NetUseMaster
then
6165 // Åñëè íå ïåðåìåøàòü, ïðè äîáàâëåíèè íîâûõ áîòîâ ïîÿâÿòñÿ ñòàðûå
6169 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6171 else if cmd
= 'kick_id' then
6173 if g_Game_IsServer
and g_Game_IsNet
then
6175 if Length(P
) < 2 then
6177 g_Console_Add('kick_id <client ID>');
6182 g_Console_Add('kick_id <client ID>');
6186 a
:= StrToIntDef(P
[1], 0);
6187 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
6189 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
6191 s
:= g_Net_ClientName_ByID(NetClients
[a
].ID
);
6192 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_KICK
);
6193 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
6194 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
6195 if NetUseMaster
then
6200 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6202 else if cmd
= 'ban' then
6204 if g_Game_IsServer
and g_Game_IsNet
then
6206 if Length(P
) < 2 then
6208 g_Console_Add('ban <name>');
6213 g_Console_Add('ban <name>');
6217 pl
:= g_Net_Client_ByName(P
[1]);
6220 s
:= g_Net_ClientName_ByID(pl
^.ID
);
6221 g_Net_BanHost(pl
^.Peer
^.address
.host
, False);
6222 enet_peer_disconnect(pl
^.Peer
, NET_DISC_TEMPBAN
);
6223 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
6224 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
6225 if NetUseMaster
then
6228 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
6230 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6232 else if cmd
= 'ban_id' then
6234 if g_Game_IsServer
and g_Game_IsNet
then
6236 if Length(P
) < 2 then
6238 g_Console_Add('ban_id <client ID>');
6243 g_Console_Add('ban_id <client ID>');
6247 a
:= StrToIntDef(P
[1], 0);
6248 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
6249 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
6251 s
:= g_Net_ClientName_ByID(NetClients
[a
].ID
);
6252 g_Net_BanHost(NetClients
[a
].Peer
^.address
.host
, False);
6253 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_TEMPBAN
);
6254 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
6255 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
6256 if NetUseMaster
then
6260 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6262 else if cmd
= 'permban' then
6264 if g_Game_IsServer
and g_Game_IsNet
then
6266 if Length(P
) < 2 then
6268 g_Console_Add('permban <name>');
6273 g_Console_Add('permban <name>');
6277 pl
:= g_Net_Client_ByName(P
[1]);
6280 s
:= g_Net_ClientName_ByID(pl
^.ID
);
6281 g_Net_BanHost(pl
^.Peer
^.address
.host
);
6282 enet_peer_disconnect(pl
^.Peer
, NET_DISC_BAN
);
6283 g_Net_SaveBanList();
6284 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
6285 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
6286 if NetUseMaster
then
6289 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
6291 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6293 else if cmd
= 'permban_id' then
6295 if g_Game_IsServer
and g_Game_IsNet
then
6297 if Length(P
) < 2 then
6299 g_Console_Add('permban_id <client ID>');
6304 g_Console_Add('permban_id <client ID>');
6308 a
:= StrToIntDef(P
[1], 0);
6309 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
6310 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
6312 s
:= g_Net_ClientName_ByID(NetClients
[a
].ID
);
6313 g_Net_BanHost(NetClients
[a
].Peer
^.address
.host
);
6314 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_BAN
);
6315 g_Net_SaveBanList();
6316 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
6317 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
6318 if NetUseMaster
then
6322 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6324 else if cmd
= 'unban' then
6326 if g_Game_IsServer
and g_Game_IsNet
then
6328 if Length(P
) < 2 then
6330 g_Console_Add('unban <IP Address>');
6335 g_Console_Add('unban <IP Address>');
6339 if g_Net_UnbanHost(P
[1]) then
6341 g_Console_Add(Format(_lc
[I_MSG_UNBAN_OK
], [P
[1]]));
6342 g_Net_SaveBanList();
6344 g_Console_Add(Format(_lc
[I_MSG_UNBAN_FAIL
], [P
[1]]));
6346 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6348 else if cmd
= 'clientlist' then
6350 if g_Game_IsServer
and g_Game_IsNet
then
6353 if NetClients
<> nil then
6354 for a
:= Low(NetClients
) to High(NetClients
) do
6355 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
6357 plr
:= g_Player_Get(NetClients
[a
].Player
);
6358 if plr
= nil then continue
;
6360 g_Console_Add(Format('#%2d: %-15s | %s', [a
,
6361 IpToStr(NetClients
[a
].Peer
^.address
.host
), plr
.Name
]));
6364 g_Console_Add(_lc
[I_MSG_NOCLIENTS
]);
6366 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6368 else if cmd
= 'connect' then
6370 if (NetMode
= NET_NONE
) then
6372 if Length(P
) < 2 then
6374 g_Console_Add('connect <IP> [port] [password]');
6379 g_Console_Add('connect <IP> [port] [password]');
6383 if Length(P
) > 2 then
6384 prt
:= StrToIntDef(P
[2], 25666)
6388 if Length(P
) > 3 then
6393 g_Game_StartClient(P
[1], prt
, pw
);
6396 else if cmd
= 'disconnect' then
6398 if (NetMode
= NET_CLIENT
) then
6401 else if cmd
= 'reconnect' then
6403 if (NetMode
= NET_SERVER
) then
6406 if (NetMode
= NET_CLIENT
) then
6409 gExit
:= EXIT_SIMPLE
;
6413 //TODO: Use last successful password to reconnect, instead of ''
6414 g_Game_StartClient(NetClientIP
, NetClientPort
, '');
6416 else if (cmd
= 'addbot') or
6417 (cmd
= 'bot_add') then
6419 if Length(P
) > 2 then
6420 g_Bot_Add(TEAM_NONE
, StrToIntDef(P
[1], 2), StrToIntDef(P
[2], 100))
6421 else if Length(P
) > 1 then
6422 g_Bot_Add(TEAM_NONE
, StrToIntDef(P
[1], 2))
6424 g_Bot_Add(TEAM_NONE
, 2);
6426 else if cmd
= 'bot_addlist' then
6428 if Length(P
) > 1 then
6430 if Length(P
) = 2 then
6431 g_Bot_AddList(TEAM_NONE
, P
[1], StrToIntDef(P
[1], -1))
6432 else if Length(P
) = 3 then
6433 g_Bot_AddList(TEAM_NONE
, P
[1], StrToIntDef(P
[1], -1), StrToIntDef(P
[2], 100))
6435 g_Bot_AddList(IfThen(P
[2] = 'red', TEAM_RED
, TEAM_BLUE
), P
[1], StrToIntDef(P
[1], -1));
6438 else if cmd
= 'bot_removeall' then
6440 else if cmd
= 'chat' then
6442 if g_Game_IsNet
then
6444 if Length(P
) > 1 then
6446 for a
:= 1 to High(P
) do
6447 chstr
:= chstr
+ P
[a
] + ' ';
6449 if Length(chstr
) > 200 then SetLength(chstr
, 200);
6451 if Length(chstr
) < 1 then
6453 g_Console_Add('chat <text>');
6457 chstr
:= b_Text_Format(chstr
);
6458 if g_Game_IsClient
then
6459 MC_SEND_Chat(chstr
, NET_CHAT_PLAYER
)
6461 MH_SEND_Chat(gPlayer1Settings
.Name
+ ': ' + chstr
, NET_CHAT_PLAYER
);
6464 g_Console_Add('chat <text>');
6466 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6468 else if cmd
= 'teamchat' then
6470 if g_Game_IsNet
and (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
6472 if Length(P
) > 1 then
6474 for a
:= 1 to High(P
) do
6475 chstr
:= chstr
+ P
[a
] + ' ';
6477 if Length(chstr
) > 200 then SetLength(chstr
, 200);
6479 if Length(chstr
) < 1 then
6481 g_Console_Add('teamchat <text>');
6485 chstr
:= b_Text_Format(chstr
);
6486 if g_Game_IsClient
then
6487 MC_SEND_Chat(chstr
, NET_CHAT_TEAM
)
6489 MH_SEND_Chat(gPlayer1Settings
.Name
+ ': ' + chstr
, NET_CHAT_TEAM
,
6490 gPlayer1Settings
.Team
);
6493 g_Console_Add('teamchat <text>');
6495 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6497 else if cmd
= 'game' then
6499 if gGameSettings
.GameType
<> GT_NONE
then
6501 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6504 if Length(P
) = 1 then
6506 g_Console_Add(cmd
+ ' <WAD> [MAP] [# players]');
6509 // Èãðà åù¸ íå çàïóùåíà, ñíà÷àëà íàì íàäî çàãðóçèòü êàêîé-òî WAD
6510 P
[1] := addWadExtension(P
[1]);
6511 if FileExists(MapsDir
+ P
[1]) then
6513 // Åñëè êàðòà íå óêàçàíà, áåð¸ì ïåðâóþ êàðòó â ôàéëå
6514 if Length(P
) < 3 then
6517 P
[2] := g_Game_GetFirstMap(MapsDir
+ P
[1]);
6520 s
:= P
[1] + ':\' + UpperCase(P
[2]);
6522 if g_Map_Exist(MapsDir
+ s
) then
6524 // Çàïóñêàåì ñâîþ èãðó
6526 with gGameSettings
do
6528 GameMode
:= g_Game_TextToMode(gcGameMode
);
6529 if gSwitchGameMode
<> GM_NONE
then
6530 GameMode
:= gSwitchGameMode
;
6531 if GameMode
= GM_NONE
then GameMode
:= GM_DM
;
6532 if GameMode
= GM_SINGLE
then GameMode
:= GM_COOP
;
6534 if Length(P
) >= 4 then
6535 b
:= StrToIntDef(P
[3], 1);
6536 g_Game_StartCustom(s
, GameMode
, TimeLimit
,
6537 GoalLimit
, MaxLives
, Options
, b
);
6542 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
6544 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [UpperCase(P
[2]), P
[1]]));
6546 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]));
6548 else if cmd
= 'host' then
6550 if gGameSettings
.GameType
<> GT_NONE
then
6552 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6555 if Length(P
) < 4 then
6557 g_Console_Add(cmd
+ ' <listen IP> <port> <WAD> [MAP] [# players]');
6560 if not StrToIp(P
[1], listen
) then
6562 prt
:= StrToIntDef(P
[2], 25666);
6564 P
[3] := addWadExtension(P
[3]);
6565 if FileExists(MapsDir
+ P
[3]) then
6567 // Åñëè êàðòà íå óêàçàíà, áåð¸ì ïåðâóþ êàðòó â ôàéëå
6568 if Length(P
) < 5 then
6571 P
[4] := g_Game_GetFirstMap(MapsDir
+ P
[1]);
6574 s
:= P
[3] + ':\' + UpperCase(P
[4]);
6576 if g_Map_Exist(MapsDir
+ s
) then
6578 // Çàïóñêàåì ñâîþ èãðó
6580 with gGameSettings
do
6582 GameMode
:= g_Game_TextToMode(gcGameMode
);
6583 if gSwitchGameMode
<> GM_NONE
then
6584 GameMode
:= gSwitchGameMode
;
6585 if GameMode
= GM_NONE
then GameMode
:= GM_DM
;
6586 if GameMode
= GM_SINGLE
then GameMode
:= GM_COOP
;
6588 if Length(P
) >= 6 then
6589 b
:= StrToIntDef(P
[5], 0);
6590 g_Game_StartServer(s
, GameMode
, TimeLimit
,
6591 GoalLimit
, MaxLives
, Options
, b
, listen
, prt
);
6596 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[3]]))
6598 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [UpperCase(P
[4]), P
[3]]));
6600 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[3]]));
6602 else if cmd
= 'map' then
6604 if Length(P
) = 1 then
6606 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
6608 g_Console_Add(cmd
+ ' <MAP>');
6609 g_Console_Add(cmd
+ ' <WAD> [MAP]');
6611 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6613 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
6615 // Èä¸ò ñâîÿ èãðà èëè ñåðâåð
6616 if Length(P
) < 3 then
6618 // Ïåðâûé ïàðàìåòð - ëèáî êàðòà, ëèáî èìÿ WAD ôàéëà
6619 s
:= UpperCase(P
[1]);
6620 if g_Map_Exist(MapsDir
+ gGameSettings
.WAD
+ ':\' + s
) then
6621 begin // Êàðòà íàøëàñü
6622 gExitByTrigger
:= False;
6624 begin // Èä¸ò èãðà - çàâåðøàåì óðîâåíü
6626 gExit
:= EXIT_ENDLEVELCUSTOM
;
6628 else // Èíòåðìèññèÿ - ñðàçó çàãðóæàåì êàðòó
6629 g_Game_ChangeMap(s
);
6632 // Òàêîé êàðòû íåò, èùåì WAD ôàéë
6633 pw
:= findDiskWad(MapsDir
+ P
[1]);
6634 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [s
, 'WAD ' + P
[1]]));
6635 if FileExists(pw
) then
6637 // Ïàðàìåòðà êàðòû íåò, ïîýòîìó ñòàâèì ïåðâóþ èç ôàéëà
6639 P
[1] := ExtractRelativePath(MapsDir
, pw
);
6640 P
[2] := g_Game_GetFirstMap(MapsDir
+ P
[1]);
6642 s
:= P
[1] + ':\' + P
[2];
6644 if g_Map_Exist(MapsDir
+ s
) then
6646 gExitByTrigger
:= False;
6648 begin // Èä¸ò èãðà - çàâåðøàåì óðîâåíü
6650 gExit
:= EXIT_ENDLEVELCUSTOM
;
6652 else // Èíòåðìèññèÿ - ñðàçó çàãðóæàåì êàðòó
6653 g_Game_ChangeMap(s
);
6656 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
6658 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]));
6660 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]));
6664 // Óêàçàíî äâà ïàðàìåòðà, çíà÷èò ïåðâûé - WAD ôàéë, à âòîðîé - êàðòà
6665 P
[1] := addWadExtension(P
[1]);
6666 if FileExists(MapsDir
+ P
[1]) then
6669 P
[2] := UpperCase(P
[2]);
6670 s
:= P
[1] + ':\' + P
[2];
6672 if g_Map_Exist(MapsDir
+ s
) then
6673 begin // Íàøëè êàðòó
6674 gExitByTrigger
:= False;
6676 begin // Èä¸ò èãðà - çàâåðøàåì óðîâåíü
6678 gExit
:= EXIT_ENDLEVELCUSTOM
;
6680 else // Èíòåðìèññèÿ - ñðàçó çàãðóæàåì êàðòó
6681 g_Game_ChangeMap(s
);
6683 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]));
6685 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]));
6688 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6690 else if cmd
= 'nextmap' then
6692 if not(gGameOn
or (gState
= STATE_INTERCUSTOM
)) then
6693 g_Console_Add(_lc
[I_MSG_NOT_GAME
])
6696 if Length(P
) = 1 then
6698 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
6700 g_Console_Add(cmd
+ ' <MAP>');
6701 g_Console_Add(cmd
+ ' <WAD> [MAP]');
6704 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6709 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
6711 if Length(P
) < 3 then
6713 // Ïåðâûé ïàðàìåòð - ëèáî êàðòà, ëèáî èìÿ WAD ôàéëà
6714 s
:= UpperCase(P
[1]);
6715 if g_Map_Exist(MapsDir
+ gGameSettings
.WAD
+ ':\' + s
) then
6716 begin // Êàðòà íàøëàñü
6717 gExitByTrigger
:= False;
6722 // Òàêîé êàðòû íåò, èùåì WAD ôàéë
6723 P
[1] := addWadExtension(P
[1]);
6724 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [s
, P
[1]]));
6725 if FileExists(MapsDir
+ P
[1]) then
6727 // Ïàðàìåòðà êàðòû íåò, ïîýòîìó ñòàâèì ïåðâóþ èç ôàéëà
6729 P
[2] := g_Game_GetFirstMap(MapsDir
+ P
[1]);
6731 s
:= P
[1] + ':\' + P
[2];
6733 if g_Map_Exist(MapsDir
+ s
) then
6734 begin // Óñòàíàâëèâàåì êàðòó
6735 gExitByTrigger
:= False;
6740 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
6742 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]));
6744 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]));
6748 // Óêàçàíî äâà ïàðàìåòðà, çíà÷èò ïåðâûé - WAD ôàéë, à âòîðîé - êàðòà
6749 P
[1] := addWadExtension(P
[1]);
6750 if FileExists(MapsDir
+ P
[1]) then
6753 P
[2] := UpperCase(P
[2]);
6754 s
:= P
[1] + ':\' + P
[2];
6756 if g_Map_Exist(MapsDir
+ s
) then
6757 begin // Íàøëè êàðòó
6758 gExitByTrigger
:= False;
6762 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]));
6764 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]));
6767 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6770 if gNextMap
= '' then
6771 g_Console_Add(_lc
[I_MSG_NEXTMAP_UNSET
])
6773 g_Console_Add(Format(_lc
[I_MSG_NEXTMAP_SET
], [gNextMap
]));
6776 else if (cmd
= 'endmap') or (cmd
= 'goodbye') then
6779 g_Console_Add(_lc
[I_MSG_NOT_GAME
])
6781 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
6783 gExitByTrigger
:= False;
6784 // Ñëåäóþùàÿ êàðòà íå çàäàíà, ïðîáóåì íàéòè òðèããåð Âûõîä
6785 if (gNextMap
= '') and (gTriggers
<> nil) then
6786 for a
:= 0 to High(gTriggers
) do
6787 if gTriggers
[a
].TriggerType
= TRIGGER_EXIT
then
6789 gExitByTrigger
:= True;
6790 //gNextMap := gTriggers[a].Data.MapName;
6791 gNextMap
:= gTriggers
[a
].tgcMap
;
6794 // Èùåì ñëåäóþùóþ êàðòó â WAD ôàéëå
6795 if gNextMap
= '' then
6796 gNextMap
:= g_Game_GetNextMap();
6797 // Ïðîâåðÿåì, íå çàäàí ëè WAD ôàéë ðåñóðñíîé ñòðîêîé
6798 if not isWadPath(gNextMap
) then
6799 s
:= gGameSettings
.WAD
+ ':\' + gNextMap
6802 // Åñëè êàðòà íàéäåíà, âûõîäèì ñ óðîâíÿ
6803 if g_Map_Exist(MapsDir
+ s
) then
6804 gExit
:= EXIT_ENDLEVELCUSTOM
6806 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [gNextMap
]));
6808 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6810 else if (cmd
= 'event') then
6812 if (Length(P
) <= 1) then
6814 for a
:= 0 to High(gEvents
) do
6815 if gEvents
[a
].Command
= '' then
6816 g_Console_Add(gEvents
[a
].Name
+ ' <none>')
6818 g_Console_Add(gEvents
[a
].Name
+ ' "' + gEvents
[a
].Command
+ '"');
6821 if (Length(P
) = 2) then
6823 for a
:= 0 to High(gEvents
) do
6824 if gEvents
[a
].Name
= P
[1] then
6825 if gEvents
[a
].Command
= '' then
6826 g_Console_Add(gEvents
[a
].Name
+ ' <none>')
6828 g_Console_Add(gEvents
[a
].Name
+ ' "' + gEvents
[a
].Command
+ '"');
6831 for a
:= 0 to High(gEvents
) do
6832 if gEvents
[a
].Name
= P
[1] then
6834 gEvents
[a
].Command
:= '';
6835 for b
:= 2 to High(P
) do
6836 if Pos(' ', P
[b
]) = 0 then
6837 gEvents
[a
].Command
:= gEvents
[a
].Command
+ ' ' + P
[b
]
6839 gEvents
[a
].Command
:= gEvents
[a
].Command
+ ' "' + P
[b
] + '"';
6840 gEvents
[a
].Command
:= Trim(gEvents
[a
].Command
);
6844 else if cmd
= 'suicide' then
6848 if g_Game_IsClient
then
6849 MC_SEND_CheatRequest(NET_CHEAT_SUICIDE
)
6852 if gPlayer1
<> nil then
6853 gPlayer1
.Damage(SUICIDE_DAMAGE
, gPlayer1
.UID
, 0, 0, HIT_SELF
);
6854 if gPlayer2
<> nil then
6855 gPlayer2
.Damage(SUICIDE_DAMAGE
, gPlayer2
.UID
, 0, 0, HIT_SELF
);
6859 else if cmd
= 'screenshot' then
6863 else if cmd
= 'weapon' then
6865 if Length(p
) = 2 then
6867 a
:= WP_FIRST
+ StrToInt(p
[1]) - 1;
6868 if (a
>= WP_FIRST
) and (a
<= WP_LAST
) then
6869 gSelectWeapon
[0, a
] := True
6872 else if (cmd
= 'p1_weapon') or (cmd
= 'p2_weapon') then
6874 if Length(p
) = 2 then
6876 a
:= WP_FIRST
+ StrToInt(p
[1]) - 1;
6877 b
:= ord(cmd
[2]) - ord('1');
6878 if (a
>= WP_FIRST
) and (a
<= WP_LAST
) then
6879 gSelectWeapon
[b
, a
] := True
6882 // Êîìàíäû Ñâîåé èãðû:
6883 else if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
6885 if cmd
= 'bot_addred' then
6887 if Length(P
) > 1 then
6888 g_Bot_Add(TEAM_RED
, StrToIntDef(P
[1], 2))
6890 g_Bot_Add(TEAM_RED
, 2);
6892 else if cmd
= 'bot_addblue' then
6894 if Length(P
) > 1 then
6895 g_Bot_Add(TEAM_BLUE
, StrToIntDef(P
[1], 2))
6897 g_Bot_Add(TEAM_BLUE
, 2);
6899 else if cmd
= 'spectate' then
6905 else if cmd
= 'say' then
6907 if g_Game_IsServer
and g_Game_IsNet
then
6909 if Length(P
) > 1 then
6912 for a
:= 1 to High(P
) do
6913 chstr
:= chstr
+ P
[a
] + ' ';
6915 if Length(chstr
) > 200 then SetLength(chstr
, 200);
6917 if Length(chstr
) < 1 then
6919 g_Console_Add('say <text>');
6923 chstr
:= b_Text_Format(chstr
);
6924 MH_SEND_Chat(chstr
, NET_CHAT_PLAYER
);
6926 else g_Console_Add('say <text>');
6928 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6930 else if cmd
= 'tell' then
6932 if g_Game_IsServer
and g_Game_IsNet
then
6934 if (Length(P
) > 2) and (P
[1] <> '') then
6937 for a
:= 2 to High(P
) do
6938 chstr
:= chstr
+ P
[a
] + ' ';
6940 if Length(chstr
) > 200 then SetLength(chstr
, 200);
6942 if Length(chstr
) < 1 then
6944 g_Console_Add('tell <playername> <text>');
6948 pl
:= g_Net_Client_ByName(P
[1]);
6950 MH_SEND_Chat(b_Text_Format(chstr
), NET_CHAT_PLAYER
, pl
^.ID
)
6952 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
6954 else g_Console_Add('tell <playername> <text>');
6956 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6958 else if (cmd
= 'overtime') and not g_Game_IsClient
then
6960 if (Length(P
) = 1) or (StrToIntDef(P
[1], -1) <= 0) then
6962 // Äîïîëíèòåëüíîå âðåìÿ:
6963 gGameSettings
.TimeLimit
:= (gTime
- gGameStartTime
) div 1000 + Word(StrToIntDef(P
[1], 0));
6965 g_Console_Add(Format(_lc
[I_MSG_TIME_LIMIT
],
6966 [gGameSettings
.TimeLimit
div 3600,
6967 (gGameSettings
.TimeLimit
div 60) mod 60,
6968 gGameSettings
.TimeLimit
mod 60]));
6969 if g_Game_IsNet
then MH_SEND_GameSettings
;
6971 else if (cmd
= 'rcon_password') and g_Game_IsClient
then
6973 if (Length(P
) <= 1) then
6974 g_Console_Add('rcon_password <password>')
6976 MC_SEND_RCONPassword(P
[1]);
6978 else if cmd
= 'rcon' then
6980 if g_Game_IsClient
then
6982 if Length(P
) > 1 then
6985 for a
:= 1 to High(P
) do
6986 chstr
:= chstr
+ P
[a
] + ' ';
6988 if Length(chstr
) > 200 then SetLength(chstr
, 200);
6990 if Length(chstr
) < 1 then
6992 g_Console_Add('rcon <command>');
6996 MC_SEND_RCONCommand(chstr
);
6998 else g_Console_Add('rcon <command>');
7001 else if cmd
= 'ready' then
7003 if g_Game_IsServer
and (gLMSRespawn
= LMS_RESPAWN_WARMUP
) then
7004 gLMSRespawnTime
:= gTime
+ 100;
7006 else if (cmd
= 'callvote') and g_Game_IsNet
then
7008 if Length(P
) > 1 then
7011 for a
:= 1 to High(P
) do begin
7012 if a
> 1 then chstr
:= chstr
+ ' ';
7013 chstr
:= chstr
+ P
[a
];
7016 if Length(chstr
) > 200 then SetLength(chstr
, 200);
7018 if Length(chstr
) < 1 then
7020 g_Console_Add('callvote <command>');
7024 if g_Game_IsClient
then
7025 MC_SEND_Vote(True, chstr
)
7027 g_Game_StartVote(chstr
, gPlayer1Settings
.Name
);
7028 g_Console_Process('vote', True);
7031 g_Console_Add('callvote <command>');
7033 else if (cmd
= 'vote') and g_Game_IsNet
then
7035 if g_Game_IsClient
then
7037 else if gVoteInProgress
then
7039 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
7040 a
:= Floor((NetClientCount
+1)/2.0) + 1
7042 a
:= Floor(NetClientCount
/2.0) + 1;
7047 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_REVOKED
], [gPlayer1Settings
.Name
, gVoteCount
, a
]), True);
7048 MH_SEND_VoteEvent(NET_VE_REVOKE
, gPlayer1Settings
.Name
, 'a', gVoteCount
, a
);
7054 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_VOTE
], [gPlayer1Settings
.Name
, gVoteCount
, a
]), True);
7055 MH_SEND_VoteEvent(NET_VE_VOTE
, gPlayer1Settings
.Name
, 'a', gVoteCount
, a
);
7063 procedure g_TakeScreenShot();
7071 if e_NoGraphics
then Exit
;
7072 ssdir
:= GameDir
+'/screenshots';
7073 if not findFileCI(ssdir
, true) then
7075 // try to create dir
7080 if not findFileCI(ssdir
, true) then exit
; // alas
7083 for a
:= 1 to High(Word) do
7085 FileName
:= Format(ssdir
+'screenshot%.3d.png', [a
]);
7087 if findFileCI(t
, true) then continue
;
7088 if not findFileCI(FileName
) then
7091 st
:= createDiskFile(FileName
);
7093 e_MakeScreenshot(st
, gScreenWidth
, gScreenHeight
);
7098 if not ok
then try DeleteFile(FileName
); except end else g_Console_Add(Format(_lc
[I_CONSOLE_SCREENSHOT
], [ExtractFileName(FileName
)]));
7106 procedure g_Game_InGameMenu(Show
: Boolean);
7108 if (g_ActiveWindow
= nil) and Show
then
7110 if gGameSettings
.GameType
= GT_SINGLE
then
7111 g_GUI_ShowWindow('GameSingleMenu')
7114 if g_Game_IsClient
then
7115 g_GUI_ShowWindow('GameClientMenu')
7117 if g_Game_IsNet
then
7118 g_GUI_ShowWindow('GameServerMenu')
7120 g_GUI_ShowWindow('GameCustomMenu');
7122 g_Sound_PlayEx('MENU_OPEN');
7124 // Ïàóçà ïðè ìåíþ òîëüêî â îäèíî÷íîé èãðå:
7125 if (not g_Game_IsNet
) then
7129 if (g_ActiveWindow
<> nil) and (not Show
) then
7131 // Ïàóçà ïðè ìåíþ òîëüêî â îäèíî÷íîé èãðå:
7132 if (not g_Game_IsNet
) then
7133 g_Game_Pause(False);
7137 procedure g_Game_Pause (Enable
: Boolean);
7141 if not gGameOn
then exit
;
7143 if not (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
]) then exit
;
7146 gPauseMain
:= Enable
;
7148 if (gPause
<> oldPause
) then g_Game_PauseAllSounds(gPause
);
7151 procedure g_Game_HolmesPause (Enable
: Boolean);
7155 if not gGameOn
then exit
;
7156 if not (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
]) then exit
;
7159 gPauseHolmes
:= Enable
;
7161 if (gPause
<> oldPause
) then g_Game_PauseAllSounds(gPause
);
7164 procedure g_Game_PauseAllSounds(Enable
: Boolean);
7169 if gTriggers
<> nil then
7170 for i
:= 0 to High(gTriggers
) do
7171 with gTriggers
[i
] do
7172 if (TriggerType
= TRIGGER_SOUND
) and
7174 Sound
.IsPlaying() then
7176 Sound
.Pause(Enable
);
7180 if gPlayers
<> nil then
7181 for i
:= 0 to High(gPlayers
) do
7182 if gPlayers
[i
] <> nil then
7183 gPlayers
[i
].PauseSounds(Enable
);
7186 if gMusic
<> nil then
7187 gMusic
.Pause(Enable
);
7190 procedure g_Game_StopAllSounds(all
: Boolean);
7194 if gTriggers
<> nil then
7195 for i
:= 0 to High(gTriggers
) do
7196 with gTriggers
[i
] do
7197 if (TriggerType
= TRIGGER_SOUND
) and
7201 if gMusic
<> nil then
7208 procedure g_Game_UpdateTriggerSounds();
7212 if gTriggers
<> nil then
7213 for i
:= 0 to High(gTriggers
) do
7214 with gTriggers
[i
] do
7215 if (TriggerType
= TRIGGER_SOUND
) and
7218 Sound
.IsPlaying() then
7220 if ((gPlayer1
<> nil) and g_CollidePoint(gPlayer1
.GameX
, gPlayer1
.GameY
, X
, Y
, Width
, Height
)) or
7221 ((gPlayer2
<> nil) and g_CollidePoint(gPlayer2
.GameX
, gPlayer2
.GameY
, X
, Y
, Width
, Height
)) then
7223 Sound
.SetPan(0.5 - tgcPan
/255.0);
7224 Sound
.SetVolume(tgcVolume
/255.0);
7227 Sound
.SetCoords(X
+(Width
div 2), Y
+(Height
div 2), tgcVolume
/255.0);
7231 function g_Game_IsWatchedPlayer(UID
: Word): Boolean;
7234 if (gPlayer1
<> nil) and (gPlayer1
.UID
= UID
) then
7239 if (gPlayer2
<> nil) and (gPlayer2
.UID
= UID
) then
7244 if gSpectMode
<> SPECT_PLAYERS
then
7246 if gSpectPID1
= UID
then
7251 if gSpectViewTwo
and (gSpectPID2
= UID
) then
7258 function g_Game_IsWatchedTeam(Team
: Byte): Boolean;
7263 if (gPlayer1
<> nil) and (gPlayer1
.Team
= Team
) then
7268 if (gPlayer2
<> nil) and (gPlayer2
.Team
= Team
) then
7273 if gSpectMode
<> SPECT_PLAYERS
then
7275 Pl
:= g_Player_Get(gSpectPID1
);
7276 if (Pl
<> nil) and (Pl
.Team
= Team
) then
7281 if gSpectViewTwo
then
7283 Pl
:= g_Player_Get(gSpectPID2
);
7284 if (Pl
<> nil) and (Pl
.Team
= Team
) then
7292 procedure g_Game_Message(Msg
: string; Time
: Word);
7294 MessageLineLength
:= (gScreenWidth
- 204) div e_CharFont_GetMaxWidth(gMenuFont
);
7295 MessageText
:= b_Text_Wrap(b_Text_Format(Msg
), MessageLineLength
);
7296 MessageTime
:= Time
;
7299 procedure g_Game_ChatSound(Text: String; Taunt
: Boolean = True);
7301 punct
: Array[0..13] of String =
7302 ('.', ',', ':', ';', '!', '?', '(', ')', '''', '"', '/', '\', '*', '^');
7308 function IsPunctuation(S
: String): Boolean;
7313 if Length(S
) <> 1 then
7315 for i
:= Low(punct
) to High(punct
) do
7316 if S
= punct
[i
] then
7322 function FilterPunctuation(S
: String): String;
7326 for i
:= Low(punct
) to High(punct
) do
7327 S
:= StringReplace(S
, punct
[i
], ' ', [rfReplaceAll
]);
7333 if gUseChatSounds
and Taunt
and (gChatSounds
<> nil) and (Pos(': ', Text) > 0) then
7335 // remove player name
7336 Delete(Text, 1, Pos(': ', Text) + 2 - 1);
7337 // for FullWord check
7338 Text := toLowerCase1251(' ' + Text + ' ');
7339 fpText
:= FilterPunctuation(Text);
7341 for i
:= 0 to Length(gChatSounds
) - 1 do
7344 for j
:= 0 to Length(gChatSounds
[i
].Tags
) - 1 do
7346 if gChatSounds
[i
].FullWord
and (not IsPunctuation(gChatSounds
[i
].Tags
[j
])) then
7347 ok
:= Pos(' ' + gChatSounds
[i
].Tags
[j
] + ' ', fpText
) > 0
7349 ok
:= Pos(gChatSounds
[i
].Tags
[j
], Text) > 0;
7355 gChatSounds
[i
].Sound
.Play();
7361 g_Sound_PlayEx('SOUND_GAME_RADIO');
7364 procedure g_Game_Announce_GoodShot(SpawnerUID
: Word);
7373 if not g_Game_IsWatchedPlayer(SpawnerUID
) then
7377 if goodsnd
[a
].IsPlaying() then
7380 goodsnd
[Random(4)].Play();
7383 procedure g_Game_Announce_KillCombo(Param
: Integer);
7390 UID
:= Param
and $FFFF;
7395 Pl
:= g_Player_Get(UID
);
7404 g_Console_Add(Format(_lc
[I_PLAYER_KILL_2X
], [Name
]), True);
7408 g_Console_Add(Format(_lc
[I_PLAYER_KILL_3X
], [Name
]), True);
7412 g_Console_Add(Format(_lc
[I_PLAYER_KILL_4X
], [Name
]), True);
7416 g_Console_Add(Format(_lc
[I_PLAYER_KILL_MX
], [Name
]), True);
7424 if not g_Game_IsWatchedPlayer(UID
) then
7427 if (not g_Game_IsWatchedPlayer(UID
)) and (c
< 4) then
7431 if killsnd
[n
].IsPlaying() then
7436 procedure g_Game_Announce_BodyKill(SpawnerUID
: Word);
7445 if not g_Game_IsWatchedPlayer(SpawnerUID
) then
7449 if hahasnd
[a
].IsPlaying() then
7452 hahasnd
[Random(3)].Play();
7455 procedure g_Game_StartVote(Command
, Initiator
: string);
7459 if not gVotesEnabled
then Exit
;
7460 if gGameSettings
.GameType
<> GT_SERVER
then Exit
;
7461 if gVoteInProgress
or gVotePassed
then
7463 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_INPROGRESS
], [gVoteCommand
]), True);
7464 MH_SEND_VoteEvent(NET_VE_INPROGRESS
, gVoteCommand
);
7467 gVoteInProgress
:= True;
7468 gVotePassed
:= False;
7469 gVoteTimer
:= gTime
+ gVoteTimeout
* 1000;
7472 gVoteCommand
:= Command
;
7474 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
7475 Need
:= Floor((NetClientCount
+1)/2.0)+1
7477 Need
:= Floor(NetClientCount
/2.0)+1;
7478 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_STARTED
], [Initiator
, Command
, Need
]), True);
7479 MH_SEND_VoteEvent(NET_VE_STARTED
, Initiator
, Command
, Need
);
7482 procedure g_Game_CheckVote
;
7486 if gGameSettings
.GameType
<> GT_SERVER
then Exit
;
7487 if not gVoteInProgress
then Exit
;
7489 if (gTime
>= gVoteTimer
) then
7491 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
7492 Need
:= Floor((NetClientCount
+1)/2.0) + 1
7494 Need
:= Floor(NetClientCount
/2.0) + 1;
7495 if gVoteCount
>= Need
then
7497 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_PASSED
], [gVoteCommand
]), True);
7498 MH_SEND_VoteEvent(NET_VE_PASSED
, gVoteCommand
);
7499 gVotePassed
:= True;
7500 gVoteCmdTimer
:= gTime
+ 5000;
7504 g_Console_Add(_lc
[I_MESSAGE_VOTE_FAILED
], True);
7505 MH_SEND_VoteEvent(NET_VE_FAILED
);
7507 if NetClients
<> nil then
7508 for I
:= Low(NetClients
) to High(NetClients
) do
7509 if NetClients
[i
].Used
then
7510 NetClients
[i
].Voted
:= False;
7511 gVoteInProgress
:= False;
7517 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
7518 Need
:= Floor((NetClientCount
+1)/2.0) + 1
7520 Need
:= Floor(NetClientCount
/2.0) + 1;
7521 if gVoteCount
>= Need
then
7523 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_PASSED
], [gVoteCommand
]), True);
7524 MH_SEND_VoteEvent(NET_VE_PASSED
, gVoteCommand
);
7525 gVoteInProgress
:= False;
7526 gVotePassed
:= True;
7527 gVoteCmdTimer
:= gTime
+ 5000;
7530 if NetClients
<> nil then
7531 for I
:= Low(NetClients
) to High(NetClients
) do
7532 if NetClients
[i
].Used
then
7533 NetClients
[i
].Voted
:= False;
7538 procedure g_Game_LoadMapList(FileName
: string);
7546 if not FileExists(FileName
) then Exit
;
7548 AssignFile(ListFile
, FileName
);
7550 while not EOF(ListFile
) do
7552 ReadLn(ListFile
, s
);
7555 if s
= '' then Continue
;
7557 SetLength(MapList
, Length(MapList
)+1);
7558 MapList
[High(MapList
)] := s
;
7560 CloseFile(ListFile
);
7563 procedure g_Game_SetDebugMode();
7566 // ×èòû (äàæå â ñâîåé èãðå):
7570 procedure g_Game_SetLoadingText(Text: String; Max
: Integer; reWrite
: Boolean);
7574 if Length(LoadingStat
.Msgs
) = 0 then
7580 begin // Ïåðåõîäèì íà ñëåäóþùóþ ñòðîêó èëè ñêðîëëèðóåì:
7581 if NextMsg
= Length(Msgs
) then
7583 for i
:= 0 to High(Msgs
)-1 do
7584 Msgs
[i
] := Msgs
[i
+1];
7592 Msgs
[NextMsg
-1] := Text;
7596 PBarWasHere
:= false;
7599 g_ActiveWindow
:= nil;
7601 ProcessLoading(true);
7604 procedure g_Game_StepLoading(Value
: Integer = -1);
7615 if (ShowCount
> LOADING_SHOW_STEP
) or (Value
> -1) then
7623 procedure g_Game_ClearLoading();
7632 len
:= ((gScreenHeight
div 3)*2 - 50) div LOADING_INTERLINE
;
7633 if len
< 1 then len
:= 1;
7634 SetLength(Msgs
, len
);
7635 for len
:= Low(Msgs
) to High(Msgs
) do
7638 PBarWasHere
:= false;
7642 procedure Parse_Params(var pars
: TParamStrValues
);
7649 while i
<= ParamCount
do
7652 if (s
[1] = '-') and (Length(s
) > 1) then
7654 if (s
[2] = '-') and (Length(s
) > 2) then
7655 begin // Îäèíî÷íûé ïàðàìåòð
7656 SetLength(pars
, Length(pars
) + 1);
7657 with pars
[High(pars
)] do
7659 Name
:= LowerCase(s
);
7664 if (i
< ParamCount
) then
7665 begin // Ïàðàìåòð ñî çíà÷åíèåì
7667 SetLength(pars
, Length(pars
) + 1);
7668 with pars
[High(pars
)] do
7670 Name
:= LowerCase(s
);
7671 Value
:= LowerCase(ParamStr(i
));
7680 function Find_Param_Value(var pars
: TParamStrValues
; aName
: String): String;
7685 for i
:= 0 to High(pars
) do
7686 if pars
[i
].Name
= aName
then
7688 Result
:= pars
[i
].Value
;
7693 procedure g_Game_Process_Params();
7695 pars
: TParamStrValues
;
7698 LimT
, LimS
: Integer;
7709 s
:= Find_Param_Value(pars
, '--debug');
7712 g_Game_SetDebugMode();
7713 s
:= Find_Param_Value(pars
, '--netdump');
7718 // Connect when game loads
7719 ip
:= Find_Param_Value(pars
, '-connect');
7723 s
:= Find_Param_Value(pars
, '-port');
7724 if (s
= '') or not TryStrToInt(s
, Port
) then
7727 s
:= Find_Param_Value(pars
, '-pw');
7729 g_Game_StartClient(ip
, Port
, s
);
7733 s
:= LowerCase(Find_Param_Value(pars
, '-dbg-mainwad'));
7736 gDefaultMegawadStart
:= s
;
7739 if (Find_Param_Value(pars
, '--dbg-mainwad-restore') <> '') or
7740 (Find_Param_Value(pars
, '--dbg-mainwad-default') <> '') then
7742 gDefaultMegawadStart
:= DF_Default_Megawad_Start
;
7745 // Start map when game loads:
7746 map
:= LowerCase(Find_Param_Value(pars
, '-map'));
7747 if isWadPath(map
) then
7750 s
:= Find_Param_Value(pars
, '-gm');
7751 GMode
:= g_Game_TextToMode(s
);
7752 if GMode
= GM_NONE
then GMode
:= GM_DM
;
7753 if GMode
= GM_SINGLE
then GMode
:= GM_COOP
;
7756 s
:= Find_Param_Value(pars
, '-limt');
7757 if (s
= '') or (not TryStrToInt(s
, LimT
)) then
7763 s
:= Find_Param_Value(pars
, '-lims');
7764 if (s
= '') or (not TryStrToInt(s
, LimS
)) then
7770 s
:= Find_Param_Value(pars
, '-lives');
7771 if (s
= '') or (not TryStrToInt(s
, Lives
)) then
7777 s
:= Find_Param_Value(pars
, '-opt');
7779 Opt
:= GAME_OPTION_ALLOWEXIT
or GAME_OPTION_BOTVSPLAYER
or GAME_OPTION_BOTVSMONSTER
7781 Opt
:= StrToIntDef(s
, 0);
7783 Opt
:= GAME_OPTION_ALLOWEXIT
or GAME_OPTION_BOTVSPLAYER
or GAME_OPTION_BOTVSMONSTER
;
7786 s
:= Find_Param_Value(pars
, '--close');
7790 // Override map to test:
7791 s
:= LowerCase(Find_Param_Value(pars
, '-testmap'));
7793 gTestMap
:= MapsDir
+ s
;
7795 // Delete test map after play:
7796 s
:= Find_Param_Value(pars
, '--testdelete');
7799 gMapToDelete
:= MapsDir
+ map
;
7800 e_WriteLog('"--testdelete" is deprecated, use --tempdelete.', TMsgType
.Fatal
);
7804 // Delete temporary WAD after play:
7805 s
:= Find_Param_Value(pars
, '--tempdelete');
7806 if (s
<> '') and (gTestMap
<> '') then
7808 gMapToDelete
:= gTestMap
;
7809 gTempDelete
:= True;
7812 // Number of players:
7813 s
:= Find_Param_Value(pars
, '-pl');
7815 n
:= DEFAULT_PLAYERS
7817 n
:= StrToIntDef(s
, DEFAULT_PLAYERS
);
7820 s
:= Find_Param_Value(pars
, '-port');
7821 if (s
= '') or not TryStrToInt(s
, Port
) then
7822 g_Game_StartCustom(map
, GMode
, LimT
, LimS
, Lives
, Opt
, n
)
7824 g_Game_StartServer(map
, GMode
, LimT
, LimS
, Lives
, Opt
, n
, 0, Port
);
7827 // Execute script when game loads:
7828 s
:= Find_Param_Value(pars
, '-exec');
7831 if not isWadPath(s
) then
7832 s
:= GameDir
+ '/' + s
;
7837 if IOResult
<> 0 then
7839 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], ['Failed to read file: ' + s
]), TMsgType
.Warning
);
7840 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_READ
], [s
]));
7844 e_WriteLog('Executing script: ' + s
, TMsgType
.Notify
);
7845 g_Console_Add(Format(_lc
[I_CONSOLE_EXEC
], [s
]));
7850 if IOResult
<> 0 then
7852 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], ['Failed to read file: ' + s
]), TMsgType
.Warning
);
7853 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_READ
], [s
]));
7857 if Pos('#', s
) <> 1 then // script comment
7858 g_Console_Process(s
, True);
7869 conRegVar('pf_draw_frame', @g_profile_frame_draw
, 'draw frame rendering profiles', 'render profiles');
7870 //conRegVar('pf_update_frame', @g_profile_frame_update, 'draw frame updating profiles', 'update profiles');
7871 conRegVar('pf_coldet', @g_profile_collision
, 'draw collision detection profiles', 'coldet profiles');
7872 conRegVar('pf_los', @g_profile_los
, 'draw monster LOS profiles', 'monster LOS profiles');
7874 conRegVar('r_sq_draw', @gdbg_map_use_accel_render
, 'accelerated spatial queries in rendering', 'accelerated rendering');
7875 conRegVar('cd_sq_enabled', @gdbg_map_use_accel_coldet
, 'accelerated spatial queries in map coldet', 'accelerated map coldet');
7876 conRegVar('mon_sq_enabled', @gmon_debug_use_sqaccel
, 'accelerated spatial queries for monsters', 'accelerated monster coldet');
7877 conRegVar('wtrace_sq_enabled', @gwep_debug_fast_trace
, 'accelerated spatial queries for weapon hitscan trace', 'accelerated weapon hitscan');
7879 conRegVar('pr_enabled', @gpart_dbg_enabled
, 'enable/disable particles', 'particles');
7880 conRegVar('pr_phys_enabled', @gpart_dbg_phys_enabled
, 'enable/disable particle physics', 'particle physics');
7882 conRegVar('los_enabled', @gmon_dbg_los_enabled
, 'enable/disable monster LOS calculations', 'monster LOS', true);
7883 conRegVar('mon_think', @gmon_debug_think
, 'enable/disable monster thinking', 'monster thinking', true);
7885 {$IFDEF ENABLE_HOLMES}
7886 conRegVar('dbg_holmes', @g_holmes_enabled
, 'enable/disable Holmes', 'Holmes', true);
7889 conRegVar('dbg_ignore_level_bounds', @g_dbg_ignore_bounds
, 'ignore level bounds', '', false);
7891 conRegVar('r_scale', @g_dbg_scale
, 0.01, 100.0, 'render scale', '', false);
7893 conRegVar('light_enabled', @gwin_k8_enable_light_experiments
, 'enable/disable dynamic lighting', 'lighting');
7894 conRegVar('light_player_halo', @g_playerLight
, 'enable/disable player halo', 'player light halo');
7896 conRegVar('r_smallmap_align_h', @r_smallmap_h
, 'halign: 0: left; 1: center; 2: right', 'horizontal aligning of small maps');
7897 conRegVar('r_smallmap_align_v', @r_smallmap_v
, 'valign: 0: top; 1: center; 2: bottom', 'vertial aligning of small maps');
7899 conRegVar('r_showfps', @gShowFPS
, 'draw fps counter', 'draw fps counter');
7900 conRegVar('r_showtime', @gShowTime
, 'show game time', 'show game time');