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 TEXTUREFILTER
:= GL_LINEAR
;
819 g_Texture_CreateWADEx('TEXTURE_endpic', s
+MegaWAD
.endpic
);
820 TEXTUREFILTER
:= GL_NEAREST
;
822 MegaWAD
.endmus
:= cfg
.ReadStr('megawad', 'endmus', 'Standart.wad:D2DMUS\ÊÎÍÅÖ');
823 if MegaWAD
.endmus
<> '' then
825 s
:= g_ExtractWadName(MegaWAD
.endmus
);
826 if s
= '' then s
:= MapsDir
+WAD
else s
:= GameDir
+'/wads/';
827 g_Sound_CreateWADEx('MUSIC_endmus', s
+MegaWAD
.endmus
, True);
835 {procedure start_trigger(t: string);
839 function next_trigger(): Boolean;
843 procedure DisableCheats();
849 if gPlayer1
<> nil then gPlayer1
.GodMode
:= False;
850 if gPlayer2
<> nil then gPlayer2
.GodMode
:= False;
851 if gPlayer1
<> nil then gPlayer1
.NoTarget
:= False;
852 if gPlayer2
<> nil then gPlayer2
.NoTarget
:= False;
854 {$IF DEFINED(D2F_DEBUG)}
855 if gPlayer1
<> nil then gPlayer1
.NoTarget
:= True;
856 gAimLine
:= g_dbg_aimline_on
;
860 procedure g_Game_ExecuteEvent(Name
: String);
866 if gEvents
= nil then
868 for a
:= 0 to High(gEvents
) do
869 if gEvents
[a
].Name
= Name
then
871 if gEvents
[a
].Command
<> '' then
872 g_Console_Process(gEvents
[a
].Command
, True);
877 function g_Game_DelayEvent(DEType
: Byte; Time
: LongWord; Num
: Integer = 0; Str
: String = ''): Integer;
882 if gDelayedEvents
<> nil then
883 for a
:= 0 to High(gDelayedEvents
) do
884 if not gDelayedEvents
[a
].Pending
then
891 SetLength(gDelayedEvents
, Length(gDelayedEvents
) + 1);
892 n
:= High(gDelayedEvents
);
894 gDelayedEvents
[n
].Pending
:= True;
895 gDelayedEvents
[n
].DEType
:= DEType
;
896 gDelayedEvents
[n
].DENum
:= Num
;
897 gDelayedEvents
[n
].DEStr
:= Str
;
898 if DEType
= DE_GLOBEVENT
then
899 gDelayedEvents
[n
].Time
:= (GetTimer() {div 1000}) + Time
901 gDelayedEvents
[n
].Time
:= gTime
+ Time
;
910 if g_Game_IsNet
and g_Game_IsServer
then
911 MH_SEND_GameEvent(NET_EV_MAPEND
, Byte(gMissionFailed
));
915 gPauseHolmes
:= false;
918 g_Game_StopAllSounds(False);
923 EndingGameCounter
:= 0;
924 g_ActiveWindow
:= nil;
926 gLMSRespawn
:= LMS_RESPAWN_NONE
;
927 gLMSRespawnTime
:= 0;
930 EXIT_SIMPLE
: // Âûõîä ÷åðåç ìåíþ èëè êîíåö òåñòà
935 begin // Ýòî áûë òåñò
939 begin // Âûõîä â ãëàâíîå ìåíþ
940 gMusic
.SetByName('MUSIC_MENU');
942 if gState
<> STATE_SLIST
then
944 g_GUI_ShowWindow('MainMenu');
945 gState
:= STATE_MENU
;
948 // Îáíîâëÿåì ñïèñîê ñåðâåðîâ
949 slReturnPressed
:= True;
950 if g_Net_Slist_Fetch(slCurrent
) then
952 if slCurrent
= nil then
953 slWaitStr
:= _lc
[I_NET_SLIST_NOSERVERS
];
956 slWaitStr
:= _lc
[I_NET_SLIST_ERROR
];
957 g_Serverlist_GenerateTable(slCurrent
, slTable
);
960 g_Game_ExecuteEvent('ongameend');
964 EXIT_RESTART
: // Íà÷àòü óðîâåíü ñíà÷àëà
966 if not g_Game_IsClient
then g_Game_Restart();
969 EXIT_ENDLEVELCUSTOM
: // Çàêîí÷èëñÿ óðîâåíü â Ñâîåé èãðå
971 // Ñòàòèñòèêà Ñâîåé èãðû:
972 FileName
:= g_ExtractWadName(gMapInfo
.Map
);
974 CustomStat
.GameTime
:= gTime
;
975 CustomStat
.Map
:= ExtractFileName(FileName
)+':'+g_ExtractFileName(gMapInfo
.Map
); //ResName;
976 CustomStat
.MapName
:= gMapInfo
.Name
;
977 CustomStat
.GameMode
:= gGameSettings
.GameMode
;
978 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
979 CustomStat
.TeamStat
:= gTeamStat
;
981 CustomStat
.PlayerStat
:= nil;
983 // Ñòàòèñòèêà èãðîêîâ:
984 if gPlayers
<> nil then
986 for a
:= 0 to High(gPlayers
) do
987 if gPlayers
[a
] <> nil then
989 SetLength(CustomStat
.PlayerStat
, Length(CustomStat
.PlayerStat
)+1);
990 with CustomStat
.PlayerStat
[High(CustomStat
.PlayerStat
)] do
993 Name
:= gPlayers
[a
].Name
;
994 Frags
:= gPlayers
[a
].Frags
;
995 Deaths
:= gPlayers
[a
].Death
;
996 Kills
:= gPlayers
[a
].Kills
;
997 Team
:= gPlayers
[a
].Team
;
998 Color
:= gPlayers
[a
].Model
.Color
;
999 Spectator
:= gPlayers
[a
].FSpectator
;
1003 SortGameStat(CustomStat
.PlayerStat
);
1006 g_Game_ExecuteEvent('onmapend');
1007 if not g_Game_IsClient
then g_Player_ResetReady
;
1008 gInterReadyCount
:= 0;
1010 // Çàòóõàþùèé ýêðàí:
1011 EndingGameCounter
:= 255;
1012 gState
:= STATE_FOLD
;
1014 if gDefInterTime
< 0 then
1015 gInterEndTime
:= IfThen((gGameSettings
.GameType
= GT_SERVER
) and (gPlayer1
= nil), 15000, 25000)
1017 gInterEndTime
:= gDefInterTime
* 1000;
1020 EXIT_ENDLEVELSINGLE
: // Çàêîí÷èëñÿ óðîâåíü â Îäèíî÷íîé èãðå
1022 // Ñòàòèñòèêà Îäèíî÷íîé èãðû:
1023 SingleStat
.GameTime
:= gTime
;
1024 SingleStat
.TwoPlayers
:= gPlayer2
<> nil;
1025 SingleStat
.TotalSecrets
:= gSecretsCount
;
1026 // Ñòàòèñòèêà ïåðâîãî èãðîêà:
1027 SingleStat
.PlayerStat
[0].Kills
:= gPlayer1
.MonsterKills
;
1028 SingleStat
.PlayerStat
[0].Secrets
:= gPlayer1
.Secrets
;
1029 // Ñòàòèñòèêà âòîðîãî èãðîêà (åñëè åñòü):
1030 if SingleStat
.TwoPlayers
then
1032 SingleStat
.PlayerStat
[1].Kills
:= gPlayer2
.MonsterKills
;
1033 SingleStat
.PlayerStat
[1].Secrets
:= gPlayer2
.Secrets
;
1036 g_Game_ExecuteEvent('onmapend');
1039 if gNextMap
<> '' then
1041 gMusic
.SetByName('MUSIC_INTERMUS');
1043 gState
:= STATE_INTERSINGLE
;
1046 g_Game_ExecuteEvent('oninter');
1048 else // Áîëüøå íåò êàðò
1050 // Çàòóõàþùèé ýêðàí:
1051 EndingGameCounter
:= 255;
1052 gState
:= STATE_FOLD
;
1057 // Îêîí÷àíèå îáðàáîòàíî:
1058 if gExit
<> EXIT_QUIT
then
1062 procedure drawTime(X
, Y
: Integer); inline;
1064 e_TextureFontPrint(x
, y
,
1065 Format('%d:%.2d:%.2d', [
1066 gTime
div 1000 div 3600,
1067 (gTime
div 1000 div 60) mod 60,
1068 gTime
div 1000 mod 60
1073 procedure DrawStat();
1075 pc
, x
, y
, w
, h
: Integer;
1076 w1
, w2
, w3
, w4
: Integer;
1078 cw
, ch
, r
, g
, b
, rr
, gg
, bb
: Byte;
1081 stat
: TPlayerStatArray
;
1088 pc
:= g_Player_GetCount
;
1089 e_TextureFontGetSize(gStdFont
, cw
, ch
);
1091 w
:= gScreenWidth
-(gScreenWidth
div 5);
1092 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
1095 h
:= 40+ch
*5+(ch
+8)*pc
;
1096 x
:= (gScreenWidth
div 2)-(w
div 2);
1097 y
:= (gScreenHeight
div 2)-(h
div 2);
1099 e_DrawFillQuad(x
, y
, x
+w
-1, y
+h
-1, 64, 64, 64, 32);
1100 e_DrawQuad(x
, y
, x
+w
-1, y
+h
-1, 255, 127, 0);
1102 drawTime(x
+w
-78, y
+8);
1104 wad
:= g_ExtractWadNameNoPath(gMapInfo
.Map
);
1105 map
:= g_ExtractFileName(gMapInfo
.Map
);
1106 mapstr
:= wad
+ ':\' + map
+ ' - ' + gMapInfo
.Name
;
1108 case gGameSettings
.GameMode
of
1111 if gGameSettings
.MaxLives
= 0 then
1112 s1
:= _lc
[I_GAME_DM
]
1114 s1
:= _lc
[I_GAME_LMS
];
1115 s2
:= Format(_lc
[I_GAME_FRAG_LIMIT
], [gGameSettings
.GoalLimit
]);
1116 s3
:= Format(_lc
[I_GAME_TIME_LIMIT
], [gGameSettings
.TimeLimit
div 3600, (gGameSettings
.TimeLimit
div 60) mod 60, gGameSettings
.TimeLimit
mod 60]);
1121 if gGameSettings
.MaxLives
= 0 then
1122 s1
:= _lc
[I_GAME_TDM
]
1124 s1
:= _lc
[I_GAME_TLMS
];
1125 s2
:= Format(_lc
[I_GAME_FRAG_LIMIT
], [gGameSettings
.GoalLimit
]);
1126 s3
:= Format(_lc
[I_GAME_TIME_LIMIT
], [gGameSettings
.TimeLimit
div 3600, (gGameSettings
.TimeLimit
div 60) mod 60, gGameSettings
.TimeLimit
mod 60]);
1131 s1
:= _lc
[I_GAME_CTF
];
1132 s2
:= Format(_lc
[I_GAME_SCORE_LIMIT
], [gGameSettings
.GoalLimit
]);
1133 s3
:= Format(_lc
[I_GAME_TIME_LIMIT
], [gGameSettings
.TimeLimit
div 3600, (gGameSettings
.TimeLimit
div 60) mod 60, gGameSettings
.TimeLimit
mod 60]);
1138 if gGameSettings
.MaxLives
= 0 then
1139 s1
:= _lc
[I_GAME_COOP
]
1141 s1
:= _lc
[I_GAME_SURV
];
1142 s2
:= _lc
[I_GAME_MONSTERS
] + ' ' + IntToStr(gCoopMonstersKilled
) + '/' + IntToStr(gTotalMonsters
);
1143 s3
:= _lc
[I_GAME_SECRETS
] + ' ' + IntToStr(gCoopSecretsFound
) + '/' + IntToStr(gSecretsCount
);
1154 e_TextureFontPrintEx(x
+(w
div 2)-(Length(s1
)*cw
div 2), _y
, s1
, gStdFont
, 255, 255, 255, 1);
1156 e_TextureFontPrintEx(x
+(w
div 2)-(Length(mapstr
)*cw
div 2), _y
, mapstr
, gStdFont
, 200, 200, 200, 1);
1158 e_TextureFontPrintEx(x
+16, _y
, s2
, gStdFont
, 200, 200, 200, 1);
1160 e_TextureFontPrintEx(x
+w
-16-(Length(s3
))*cw
, _y
, s3
,
1161 gStdFont
, 200, 200, 200, 1);
1163 if NetMode
= NET_SERVER
then
1164 e_TextureFontPrintEx(x
+8, y
+ 8, _lc
[I_NET_SERVER
], gStdFont
, 255, 255, 255, 1)
1166 if NetMode
= NET_CLIENT
then
1167 e_TextureFontPrintEx(x
+8, y
+ 8,
1168 NetClientIP
+ ':' + IntToStr(NetClientPort
), gStdFont
, 255, 255, 255, 1);
1172 stat
:= g_Player_GetStats();
1175 w2
:= (w
-16) div 6 + 48; // øèðèíà 2 ñòîëáöà
1176 w3
:= (w
-16) div 6; // øèðèíà 3 è 4 ñòîëáöîâ
1178 w1
:= w
-16-w2
-w3
-w4
; // îñòàâøååñÿ ïðîñòðàíñòâî - äëÿ öâåòà è èìåíè èãðîêà
1180 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
1184 for a
:= TEAM_RED
to TEAM_BLUE
do
1186 if a
= TEAM_RED
then
1188 s1
:= _lc
[I_GAME_TEAM_RED
];
1195 s1
:= _lc
[I_GAME_TEAM_BLUE
];
1201 e_TextureFontPrintEx(x
+16, _y
, s1
, gStdFont
, r
, g
, b
, 1);
1202 e_TextureFontPrintEx(x
+w1
+16, _y
, IntToStr(gTeamStat
[a
].Goals
),
1203 gStdFont
, r
, g
, b
, 1);
1205 _y
:= _y
+ch
+(ch
div 4);
1206 e_DrawLine(1, x
+16, _y
, x
+w
-16, _y
, r
, g
, b
);
1207 _y
:= _y
+(ch
div 4);
1209 for aa
:= 0 to High(stat
) do
1210 if stat
[aa
].Team
= a
then
1226 e_TextureFontPrintEx(x
+16, _y
, Name
, gStdFont
, rr
, gg
, bb
, 1);
1228 e_TextureFontPrintEx(x
+w1
+16, _y
, Format(_lc
[I_GAME_PING_MS
], [Ping
, Loss
]), gStdFont
, rr
, gg
, bb
, 1);
1230 e_TextureFontPrintEx(x
+w1
+w2
+16, _y
, IntToStr(Frags
), gStdFont
, rr
, gg
, bb
, 1);
1232 e_TextureFontPrintEx(x
+w1
+w2
+w3
+16, _y
, IntToStr(Deaths
), gStdFont
, rr
, gg
, bb
, 1);
1239 else if gGameSettings
.GameMode
in [GM_DM
, GM_COOP
] then
1242 e_TextureFontPrintEx(x
+16, _y
, _lc
[I_GAME_PLAYER_NAME
], gStdFont
, 255, 127, 0, 1);
1243 e_TextureFontPrintEx(x
+16+w1
, _y
, _lc
[I_GAME_PING
], gStdFont
, 255, 127, 0, 1);
1244 e_TextureFontPrintEx(x
+16+w1
+w2
, _y
, _lc
[I_GAME_FRAGS
], gStdFont
, 255, 127, 0, 1);
1245 e_TextureFontPrintEx(x
+16+w1
+w2
+w3
, _y
, _lc
[I_GAME_DEATHS
], gStdFont
, 255, 127, 0, 1);
1248 for aa
:= 0 to High(stat
) do
1262 e_DrawFillQuad(x
+16, _y
+4, x
+32-1, _y
+16+4-1, Color
.R
, Color
.G
, Color
.B
, 0);
1263 e_DrawQuad(x
+16, _y
+4, x
+32-1, _y
+16+4-1, 192, 192, 192);
1265 e_TextureFontPrintEx(x
+16+16+8, _y
+4, Name
, gStdFont
, r
, g
, 0, 1);
1267 e_TextureFontPrintEx(x
+w1
+16, _y
+4, Format(_lc
[I_GAME_PING_MS
], [Ping
, Loss
]), gStdFont
, r
, g
, 0, 1);
1269 e_TextureFontPrintEx(x
+w1
+w2
+16, _y
+4, IntToStr(Frags
), gStdFont
, r
, g
, 0, 1);
1271 e_TextureFontPrintEx(x
+w1
+w2
+w3
+16, _y
+4, IntToStr(Deaths
), gStdFont
, r
, g
, 0, 1);
1277 procedure g_Game_Init();
1283 gTempDelete
:= False;
1285 sfsGCDisable(); // temporary disable removing of temporary volumes
1288 TEXTUREFILTER
:= GL_LINEAR
;
1289 g_Texture_CreateWADEx('MENU_BACKGROUND', GameWAD
+':TEXTURES\TITLE');
1290 g_Texture_CreateWADEx('INTER', GameWAD
+':TEXTURES\INTER');
1291 g_Texture_CreateWADEx('ENDGAME_EN', GameWAD
+':TEXTURES\ENDGAME_EN');
1292 g_Texture_CreateWADEx('ENDGAME_RU', GameWAD
+':TEXTURES\ENDGAME_RU');
1293 TEXTUREFILTER
:= GL_NEAREST
;
1295 LoadStdFont('STDTXT', 'STDFONT', gStdFont
);
1296 LoadFont('MENUTXT', 'MENUFONT', gMenuFont
);
1297 LoadFont('SMALLTXT', 'SMALLFONT', gMenuSmallFont
);
1299 g_Game_ClearLoading();
1300 g_Game_SetLoadingText(Format('Doom 2D: Forever %s', [GAME_VERSION
]), 0, False);
1301 g_Game_SetLoadingText('', 0, False);
1303 g_Game_SetLoadingText(_lc
[I_LOAD_CONSOLE
], 0, False);
1306 g_Game_SetLoadingText(_lc
[I_LOAD_MODELS
], 0, False);
1307 g_PlayerModel_LoadData();
1309 if FindFirst(ModelsDir
+'*.wad', faAnyFile
, SR
) = 0 then
1311 if not g_PlayerModel_Load(ModelsDir
+SR
.Name
) then
1312 e_WriteLog(Format('Error loading model %s', [SR
.Name
]), TMsgType
.Warning
);
1313 until FindNext(SR
) <> 0;
1316 if FindFirst(ModelsDir
+'*.pk3', faAnyFile
, SR
) = 0 then
1318 if not g_PlayerModel_Load(ModelsDir
+SR
.Name
) then
1319 e_WriteLog(Format('Error loading model %s', [SR
.Name
]), TMsgType
.Warning
);
1320 until FindNext(SR
) <> 0;
1323 if FindFirst(ModelsDir
+'*.zip', faAnyFile
, SR
) = 0 then
1325 if not g_PlayerModel_Load(ModelsDir
+SR
.Name
) then
1326 e_WriteLog(Format('Error loading model %s', [SR
.Name
]), TMsgType
.Warning
);
1327 until FindNext(SR
) <> 0;
1331 gPauseMain
:= false;
1332 gPauseHolmes
:= false;
1335 {e_MouseInfo.Accel := 1.0;}
1337 g_Game_SetLoadingText(_lc
[I_LOAD_GAME_DATA
], 0, False);
1340 g_Game_SetLoadingText(_lc
[I_LOAD_MUSIC
], 0, False);
1341 g_Sound_CreateWADEx('MUSIC_INTERMUS', GameWAD
+':MUSIC\INTERMUS', True);
1342 g_Sound_CreateWADEx('MUSIC_MENU', GameWAD
+':MUSIC\MENU', True);
1343 g_Sound_CreateWADEx('MUSIC_ROUNDMUS', GameWAD
+':MUSIC\ROUNDMUS', True, True);
1344 g_Sound_CreateWADEx('MUSIC_STDENDMUS', GameWAD
+':MUSIC\ENDMUS', True);
1346 g_Game_SetLoadingText(_lc
[I_LOAD_MENUS
], 0, False);
1349 gMusic
:= TMusic
.Create();
1350 gMusic
.SetByName('MUSIC_MENU');
1353 gGameSettings
.WarmupTime
:= 30;
1355 gState
:= STATE_MENU
;
1357 SetLength(gEvents
, 6);
1358 gEvents
[0].Name
:= 'ongamestart';
1359 gEvents
[1].Name
:= 'ongameend';
1360 gEvents
[2].Name
:= 'onmapstart';
1361 gEvents
[3].Name
:= 'onmapend';
1362 gEvents
[4].Name
:= 'oninter';
1363 gEvents
[5].Name
:= 'onwadend';
1365 sfsGCEnable(); // enable releasing unused volumes
1369 procedure g_Game_Free(freeTextures
: Boolean=true);
1371 if NetMode
= NET_CLIENT
then g_Net_Disconnect();
1372 if NetMode
= NET_SERVER
then g_Net_Host_Die();
1374 g_Map_Free(freeTextures
);
1376 g_Player_RemoveAllCorpses();
1378 gGameSettings
.GameType
:= GT_NONE
;
1379 if gGameSettings
.GameMode
= GM_SINGLE
then
1380 gGameSettings
.GameMode
:= GM_DM
;
1381 gSwitchGameMode
:= gGameSettings
.GameMode
;
1384 gExitByTrigger
:= False;
1387 function IsActivePlayer(p
: TPlayer
): Boolean;
1392 Result
:= (not p
.FDummy
) and (not p
.FSpectator
);
1395 function GetActivePlayer_ByID(ID
: Integer): TPlayer
;
1402 if gPlayers
= nil then
1404 for a
:= Low(gPlayers
) to High(gPlayers
) do
1405 if IsActivePlayer(gPlayers
[a
]) then
1407 if gPlayers
[a
].UID
<> ID
then
1409 Result
:= gPlayers
[a
];
1414 function GetActivePlayerID_Next(Skip
: Integer = -1): Integer;
1420 if gPlayers
= nil then
1424 for a
:= Low(gPlayers
) to High(gPlayers
) do
1425 if IsActivePlayer(gPlayers
[a
]) then
1427 SetLength(ids
, Length(ids
) + 1);
1428 ids
[High(ids
)] := gPlayers
[a
].UID
;
1429 if gPlayers
[a
].UID
= Skip
then
1432 if Length(ids
) = 0 then
1437 Result
:= ids
[(idx
+ 1) mod Length(ids
)];
1440 function GetActivePlayerID_Prev(Skip
: Integer = -1): Integer;
1446 if gPlayers
= nil then
1450 for a
:= Low(gPlayers
) to High(gPlayers
) do
1451 if IsActivePlayer(gPlayers
[a
]) then
1453 SetLength(ids
, Length(ids
) + 1);
1454 ids
[High(ids
)] := gPlayers
[a
].UID
;
1455 if gPlayers
[a
].UID
= Skip
then
1458 if Length(ids
) = 0 then
1461 Result
:= ids
[Length(ids
) - 1]
1463 Result
:= ids
[(Length(ids
) - 1 + idx
) mod Length(ids
)];
1466 function GetActivePlayerID_Random(Skip
: Integer = -1): Integer;
1472 if gPlayers
= nil then
1476 for a
:= Low(gPlayers
) to High(gPlayers
) do
1477 if IsActivePlayer(gPlayers
[a
]) then
1479 SetLength(ids
, Length(ids
) + 1);
1480 ids
[High(ids
)] := gPlayers
[a
].UID
;
1481 if gPlayers
[a
].UID
= Skip
then
1484 if Length(ids
) = 0 then
1486 if Length(ids
) = 1 then
1491 Result
:= ids
[Random(Length(ids
))];
1493 while (idx
<> -1) and (Result
= Skip
) and (a
> 0) do
1495 Result
:= ids
[Random(Length(ids
))];
1500 function GetRandomSpectMode(Current
: Byte): Byte;
1507 0: Result
:= SPECT_STATS
;
1508 1: Result
:= SPECT_MAPVIEW
;
1509 2: Result
:= SPECT_MAPVIEW
;
1510 3: Result
:= SPECT_PLAYERS
;
1511 4: Result
:= SPECT_PLAYERS
;
1512 5: Result
:= SPECT_PLAYERS
;
1513 6: Result
:= SPECT_PLAYERS
;
1515 if (Current
in [SPECT_STATS
, SPECT_MAPVIEW
]) and (Current
= Result
) then
1519 procedure ProcessPlayerControls (plr
: TPlayer
; p
: Integer; var MoveButton
: Byte);
1525 if (plr
= nil) then exit
;
1526 if (p
= 2) then time
:= 1000 else time
:= 1;
1527 strafeDir
:= MoveButton
shr 4;
1528 MoveButton
:= MoveButton
and $0F;
1530 if gPlayerAction
[p
, ACTION_MOVELEFT
] and (not gPlayerAction
[p
, ACTION_MOVERIGHT
]) then
1531 MoveButton
:= 1 // Íàæàòà òîëüêî "Âëåâî"
1532 else if (not gPlayerAction
[p
, ACTION_MOVELEFT
]) and gPlayerAction
[p
, ACTION_MOVERIGHT
] then
1533 MoveButton
:= 2 // Íàæàòà òîëüêî "Âïðàâî"
1534 else if (not gPlayerAction
[p
, ACTION_MOVELEFT
]) and (not gPlayerAction
[p
, ACTION_MOVERIGHT
]) then
1535 MoveButton
:= 0; // Íå íàæàòû íè "Âëåâî", íè "Âïðàâî"
1537 // Ñåé÷àñ èëè ðàíüøå áûëè íàæàòû "Âëåâî"/"Âïðàâî" => ïåðåäàåì èãðîêó:
1538 if MoveButton
= 1 then
1539 plr
.PressKey(KEY_LEFT
, time
)
1540 else if MoveButton
= 2 then
1541 plr
.PressKey(KEY_RIGHT
, time
);
1543 // if we have "strafe" key, turn off old strafe mechanics
1544 if gPlayerAction
[p
, ACTION_STRAFE
] then
1546 // new strafe mechanics
1547 if (strafeDir
= 0) then
1548 strafeDir
:= MoveButton
; // start strafing
1549 // now set direction according to strafe (reversed)
1550 if (strafeDir
= 2) then
1551 plr
.SetDirection(TDirection
.D_LEFT
)
1552 else if (strafeDir
= 1) then
1553 plr
.SetDirection(TDirection
.D_RIGHT
)
1557 strafeDir
:= 0; // not strafing anymore
1558 // Ðàíüøå áûëà íàæàòà "Âïðàâî", à ñåé÷àñ "Âëåâî" => áåæèì âïðàâî, ñìîòðèì âëåâî:
1559 if (MoveButton
= 2) and gPlayerAction
[p
, ACTION_MOVELEFT
] then
1560 plr
.SetDirection(TDirection
.D_LEFT
)
1561 // Ðàíüøå áûëà íàæàòà "Âëåâî", à ñåé÷àñ "Âïðàâî" => áåæèì âëåâî, ñìîòðèì âïðàâî:
1562 else if (MoveButton
= 1) and gPlayerAction
[p
, ACTION_MOVERIGHT
] then
1563 plr
.SetDirection(TDirection
.D_RIGHT
)
1564 // ×òî-òî áûëî íàæàòî è íå èçìåíèëîñü => êóäà áåæèì, òóäà è ñìîòðèì:
1565 else if MoveButton
<> 0 then
1566 plr
.SetDirection(TDirection(MoveButton
-1))
1569 // fix movebutton state
1570 MoveButton
:= MoveButton
or (strafeDir
shl 4);
1572 // Îñòàëüíûå êëàâèøè:
1573 if gPlayerAction
[p
, ACTION_JUMP
] then plr
.PressKey(KEY_JUMP
, time
);
1574 if gPlayerAction
[p
, ACTION_LOOKUP
] then plr
.PressKey(KEY_UP
, time
);
1575 if gPlayerAction
[p
, ACTION_LOOKDOWN
] then plr
.PressKey(KEY_DOWN
, time
);
1576 if gPlayerAction
[p
, ACTION_ATTACK
] then plr
.PressKey(KEY_FIRE
);
1577 if gPlayerAction
[p
, ACTION_WEAPNEXT
] then plr
.PressKey(KEY_NEXTWEAPON
);
1578 if gPlayerAction
[p
, ACTION_WEAPPREV
] then plr
.PressKey(KEY_PREVWEAPON
);
1579 if gPlayerAction
[p
, ACTION_ACTIVATE
] then plr
.PressKey(KEY_OPEN
);
1581 gPlayerAction
[p
, ACTION_WEAPNEXT
] := False; // HACK, remove after readyweaon&pendinweapon implementation
1582 gPlayerAction
[p
, ACTION_WEAPPREV
] := False; // HACK, remove after readyweaon&pendinweapon implementation
1584 for i
:= WP_FIRST
to WP_LAST
do
1586 if gSelectWeapon
[p
, i
] then
1588 plr
.QueueWeaponSwitch(i
); // all choices are passed there, and god will take the best
1589 gSelectWeapon
[p
, i
] := False
1593 // HACK: add dynlight here
1594 if gwin_k8_enable_light_experiments
then
1596 if e_KeyPressed(IK_F8
) and gGameOn
and (not gConsoleShow
) and (g_ActiveWindow
= nil) then
1598 g_playerLight
:= true;
1600 if e_KeyPressed(IK_F9
) and gGameOn
and (not gConsoleShow
) and (g_ActiveWindow
= nil) then
1602 g_playerLight
:= false;
1606 if gwin_has_stencil
and g_playerLight
then g_AddDynLight(plr
.GameX
+32, plr
.GameY
+40, 128, 1, 1, 0, 0.6);
1609 // HACK: don't have a "key was pressed" function
1610 procedure InterReady();
1612 if InterReadyTime
> gTime
then Exit
;
1613 InterReadyTime
:= gTime
+ 3000;
1614 MC_SEND_CheatRequest(NET_CHEAT_READY
);
1617 procedure g_Game_Update();
1619 Msg
: g_gui
.TMessage
;
1625 function sendMonsPos (mon
: TMonster
): Boolean;
1627 result
:= false; // don't stop
1628 // this will also reset "need-send" flag
1629 if mon
.gncNeedSend
then
1631 MH_SEND_MonsterPos(mon
.UID
);
1633 else if (mon
.MonsterType
= MONSTER_BARREL
) then
1635 if (mon
.GameVelX
<> 0) or (mon
.GameVelY
<> 0) then MH_SEND_MonsterPos(mon
.UID
);
1637 else if (mon
.MonsterState
<> MONSTATE_SLEEP
) then
1639 if (mon
.MonsterState
<> MONSTATE_DEAD
) or (mon
.GameVelX
<> 0) or (mon
.GameVelY
<> 0) then MH_SEND_MonsterPos(mon
.UID
);
1643 function sendMonsPosUnexpected (mon
: TMonster
): Boolean;
1645 result
:= false; // don't stop
1646 // this will also reset "need-send" flag
1647 if mon
.gncNeedSend
then MH_SEND_MonsterPos(mon
.UID
);
1651 reliableUpdate
: Boolean;
1656 // Ïîðà âûêëþ÷àòü èãðó:
1657 if gExit
= EXIT_QUIT
then
1659 // Èãðà çàêîí÷èëàñü - îáðàáàòûâàåì:
1663 if gExit
= EXIT_QUIT
then
1667 // ×èòàåì êëàâèàòóðó è äæîéñòèê, åñëè îêíî àêòèâíî
1668 // no need to, as we'll do it in event handler
1670 // Îáíîâëÿåì êîíñîëü (äâèæåíèå è ñîîáùåíèÿ):
1673 if (NetMode
= NET_NONE
) and (g_Game_IsNet
) and (gGameOn
or (gState
in [STATE_FOLD
, STATE_INTERCUSTOM
])) then
1675 gExit
:= EXIT_SIMPLE
;
1681 STATE_INTERSINGLE
, // Ñòàòèñòêà ïîñëå ïðîõîæäåíèÿ óðîâíÿ â Îäèíî÷íîé èãðå
1682 STATE_INTERCUSTOM
, // Ñòàòèñòêà ïîñëå ïðîõîæäåíèÿ óðîâíÿ â Ñâîåé èãðå
1683 STATE_INTERTEXT
, // Òåêñò ìåæäó óðîâíÿìè
1684 STATE_INTERPIC
: // Êàðòèíêà ìåæäó óðîâíÿìè
1686 if g_Game_IsNet
and g_Game_IsServer
then
1688 gInterTime
:= gInterTime
+ GAME_TICK
;
1689 a
:= Min((gInterEndTime
- gInterTime
) div 1000 + 1, 255);
1690 if a
<> gServInterTime
then
1692 gServInterTime
:= a
;
1693 MH_SEND_TimeSync(gServInterTime
);
1697 if (not g_Game_IsClient
) and
1701 e_KeyPressed(IK_RETURN
) or e_KeyPressed(IK_KPRETURN
) or e_KeyPressed(IK_SPACE
) or
1702 e_KeyPressed(VK_FIRE
) or e_KeyPressed(VK_OPEN
) or
1703 e_KeyPressed(JOY0_ATTACK
) or e_KeyPressed(JOY1_ATTACK
) or
1704 e_KeyPressed(JOY2_ATTACK
) or e_KeyPressed(JOY3_ATTACK
)
1706 and (not gJustChatted
) and (not gConsoleShow
) and (not gChatShow
)
1707 and (g_ActiveWindow
= nil)
1709 or (g_Game_IsNet
and ((gInterTime
> gInterEndTime
) or (gInterReadyCount
>= NetClientCount
)))
1712 begin // Íàæàëè <Enter>/<Ïðîáåë> èëè ïðîøëî äîñòàòî÷íî âðåìåíè:
1713 g_Game_StopAllSounds(True);
1715 if gMapOnce
then // Ýòî áûë òåñò
1716 gExit
:= EXIT_SIMPLE
1718 if gNextMap
<> '' then // Ïåðåõîäèì íà ñëåäóþùóþ êàðòó
1719 g_Game_ChangeMap(gNextMap
)
1720 else // Ñëåäóþùåé êàðòû íåò
1722 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
] then
1724 // Âûõîä â ãëàâíîå ìåíþ:
1726 g_GUI_ShowWindow('MainMenu');
1727 gMusic
.SetByName('MUSIC_MENU');
1729 gState
:= STATE_MENU
;
1732 // Ôèíàëüíàÿ êàðòèíêà:
1733 g_Game_ExecuteEvent('onwadend');
1735 if not gMusic
.SetByName('MUSIC_endmus') then
1736 gMusic
.SetByName('MUSIC_STDENDMUS');
1738 gState
:= STATE_ENDPIC
;
1740 g_Game_ExecuteEvent('ongameend');
1745 else if g_Game_IsClient
and
1748 e_KeyPressed(IK_RETURN
) or e_KeyPressed(IK_KPRETURN
) or e_KeyPressed(IK_SPACE
) or
1749 e_KeyPressed(VK_FIRE
) or e_KeyPressed(VK_OPEN
) or
1750 e_KeyPressed(JOY0_ATTACK
) or e_KeyPressed(JOY1_ATTACK
) or
1751 e_KeyPressed(JOY2_ATTACK
) or e_KeyPressed(JOY3_ATTACK
)
1753 and (not gJustChatted
) and (not gConsoleShow
) and (not gChatShow
)
1754 and (g_ActiveWindow
= nil)
1762 if gState
= STATE_INTERTEXT
then
1763 if InterText
.counter
> 0 then
1764 InterText
.counter
:= InterText
.counter
- 1;
1767 STATE_FOLD
: // Çàòóõàíèå ýêðàíà
1769 if EndingGameCounter
= 0 then
1771 // Çàêîí÷èëñÿ óðîâåíü â Ñâîåé èãðå:
1772 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
1774 InterReadyTime
:= -1;
1775 if gLastMap
and (gGameSettings
.GameMode
= GM_COOP
) then
1777 g_Game_ExecuteEvent('onwadend');
1778 if not gMusic
.SetByName('MUSIC_endmus') then
1779 gMusic
.SetByName('MUSIC_STDENDMUS');
1782 gMusic
.SetByName('MUSIC_ROUNDMUS');
1785 gState
:= STATE_INTERCUSTOM
;
1788 else // Çàêîí÷èëàñü ïîñëåäíÿÿ êàðòà â Îäèíî÷íîé èãðå
1790 gMusic
.SetByName('MUSIC_INTERMUS');
1792 gState
:= STATE_INTERSINGLE
;
1795 g_Game_ExecuteEvent('oninter');
1798 DecMin(EndingGameCounter
, 6, 0);
1801 STATE_ENDPIC
: // Êàðòèíêà îêîí÷àíèÿ ìåãàÂàäà
1803 if gMapOnce
then // Ýòî áûë òåñò
1805 gExit
:= EXIT_SIMPLE
;
1811 g_Serverlist_Control(slCurrent
, slTable
);
1814 // Ñòàòèñòèêà ïî Tab:
1816 IsDrawStat
:= (not gConsoleShow
) and (not gChatShow
) and (gGameSettings
.GameType
<> GT_SINGLE
) and g_Console_Action(ACTION_SCORES
);
1819 if gGameOn
and not gPause
and (gState
<> STATE_FOLD
) then
1821 // Âðåìÿ += 28 ìèëëèñåêóíä:
1822 gTime
:= gTime
+ GAME_TICK
;
1824 // Ñîîáùåíèå ïîñåðåäèíå ýêðàíà:
1825 if MessageTime
= 0 then
1827 if MessageTime
> 0 then
1828 MessageTime
:= MessageTime
- 1;
1830 if (g_Game_IsServer
) then
1832 // Áûë çàäàí ëèìèò âðåìåíè:
1833 if (gGameSettings
.TimeLimit
> 0) then
1834 if (gTime
- gGameStartTime
) div 1000 >= gGameSettings
.TimeLimit
then
1835 begin // Îí ïðîøåë => êîíåö óðîâíÿ
1840 // Íàäî ðåñïàâíèòü èãðîêîâ â LMS:
1841 if (gLMSRespawn
> LMS_RESPAWN_NONE
) and (gLMSRespawnTime
< gTime
) then
1842 g_Game_RestartRound(gLMSSoftSpawn
);
1844 // Ïðîâåðèì ðåçóëüòàò ãîëîñîâàíèÿ, åñëè âðåìÿ ïðîøëî
1845 if gVoteInProgress
and (gVoteTimer
< gTime
) then
1847 else if gVotePassed
and (gVoteCmdTimer
< gTime
) then
1849 g_Console_Process(gVoteCommand
);
1851 gVotePassed
:= False;
1854 // Çàìåðÿåì âðåìÿ çàõâàòà ôëàãîâ
1855 if gFlags
[FLAG_RED
].State
= FLAG_STATE_CAPTURED
then
1856 gFlags
[FLAG_RED
].CaptureTime
:= gFlags
[FLAG_RED
].CaptureTime
+ GAME_TICK
;
1857 if gFlags
[FLAG_BLUE
].State
= FLAG_STATE_CAPTURED
then
1858 gFlags
[FLAG_BLUE
].CaptureTime
:= gFlags
[FLAG_BLUE
].CaptureTime
+ GAME_TICK
;
1860 // Áûë çàäàí ëèìèò ïîáåä:
1861 if (gGameSettings
.GoalLimit
> 0) then
1865 if gGameSettings
.GameMode
= GM_DM
then
1866 begin // Â DM èùåì èãðîêà ñ max ôðàãàìè
1867 for i
:= 0 to High(gPlayers
) do
1868 if gPlayers
[i
] <> nil then
1869 if gPlayers
[i
].Frags
> b
then
1870 b
:= gPlayers
[i
].Frags
;
1873 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
1874 begin //  CTF/TDM âûáèðàåì êîìàíäó ñ íàèáîëüøèì ñ÷åòîì
1875 b
:= Max(gTeamStat
[TEAM_RED
].Goals
, gTeamStat
[TEAM_BLUE
].Goals
);
1878 // Ëèìèò ïîáåä íàáðàí => êîíåö óðîâíÿ:
1879 if b
>= gGameSettings
.GoalLimit
then
1886 // Îáðàáàòûâàåì êëàâèøè èãðîêîâ:
1887 if gPlayer1
<> nil then gPlayer1
.ReleaseKeys();
1888 if gPlayer2
<> nil then gPlayer2
.ReleaseKeys();
1889 if (not gConsoleShow
) and (not gChatShow
) and (g_ActiveWindow
= nil) then
1891 ProcessPlayerControls(gPlayer1
, 0, P1MoveButton
);
1892 ProcessPlayerControls(gPlayer2
, 1, P2MoveButton
);
1893 end // if not console
1896 if g_Game_IsNet
and (gPlayer1
<> nil) then gPlayer1
.PressKey(KEY_CHAT
, 10000);
1898 // process weapon switch queue
1902 if (gPlayer1
= nil) and (gPlayer2
= nil) and
1903 (not gConsoleShow
) and (not gChatShow
) and (g_ActiveWindow
= nil) then
1905 if not gSpectKeyPress
then
1907 if gPlayerAction
[0, ACTION_JUMP
] and (not gSpectAuto
) then
1909 // switch spect mode
1911 SPECT_NONE
: ; // not spectator
1913 SPECT_MAPVIEW
: Inc(gSpectMode
);
1914 SPECT_PLAYERS
: gSpectMode
:= SPECT_STATS
; // reset to 1
1916 gSpectKeyPress
:= True;
1918 if (gSpectMode
= SPECT_MAPVIEW
)
1919 and (not gSpectAuto
) then
1921 if gPlayerAction
[0, ACTION_MOVELEFT
] then
1922 gSpectX
:= Max(gSpectX
- gSpectStep
, 0);
1923 if gPlayerAction
[0, ACTION_MOVERIGHT
] then
1924 gSpectX
:= Min(gSpectX
+ gSpectStep
, gMapInfo
.Width
- gScreenWidth
);
1925 if gPlayerAction
[0, ACTION_LOOKUP
] then
1926 gSpectY
:= Max(gSpectY
- gSpectStep
, 0);
1927 if gPlayerAction
[0, ACTION_LOOKDOWN
] then
1928 gSpectY
:= Min(gSpectY
+ gSpectStep
, gMapInfo
.Height
- gScreenHeight
);
1929 if gPlayerAction
[0, ACTION_WEAPPREV
] then
1932 if gSpectStep
> 4 then gSpectStep
:= gSpectStep
shr 1;
1933 gSpectKeyPress
:= True;
1935 if gPlayerAction
[0, ACTION_WEAPNEXT
] then
1938 if gSpectStep
< 64 then gSpectStep
:= gSpectStep
shl 1;
1939 gSpectKeyPress
:= True;
1942 if (gSpectMode
= SPECT_PLAYERS
)
1943 and (not gSpectAuto
) then
1945 if gPlayerAction
[0, ACTION_LOOKUP
] then
1948 gSpectViewTwo
:= True;
1949 gSpectKeyPress
:= True;
1951 if gPlayerAction
[0, ACTION_LOOKDOWN
] then
1953 // remove second view
1954 gSpectViewTwo
:= False;
1955 gSpectKeyPress
:= True;
1957 if gPlayerAction
[0, ACTION_MOVELEFT
] then
1959 // prev player (view 1)
1960 gSpectPID1
:= GetActivePlayerID_Prev(gSpectPID1
);
1961 gSpectKeyPress
:= True;
1963 if gPlayerAction
[0, ACTION_MOVERIGHT
] then
1965 // next player (view 1)
1966 gSpectPID1
:= GetActivePlayerID_Next(gSpectPID1
);
1967 gSpectKeyPress
:= True;
1969 if gPlayerAction
[0, ACTION_WEAPPREV
] then
1971 // prev player (view 2)
1972 gSpectPID2
:= GetActivePlayerID_Prev(gSpectPID2
);
1973 gSpectKeyPress
:= True;
1975 if gPlayerAction
[0, ACTION_WEAPNEXT
] then
1977 // next player (view 2)
1978 gSpectPID2
:= GetActivePlayerID_Next(gSpectPID2
);
1979 gSpectKeyPress
:= True;
1982 if gPlayerAction
[0, ACTION_ATTACK
] then
1984 if (gSpectMode
= SPECT_STATS
) and (not gSpectAuto
) then
1987 gSpectAutoNext
:= 0;
1988 gSpectViewTwo
:= False;
1989 gSpectKeyPress
:= True;
1994 gSpectMode
:= SPECT_STATS
;
1995 gSpectAuto
:= False;
1996 gSpectKeyPress
:= True;
2001 if (not gPlayerAction
[0, ACTION_JUMP
]) and
2002 (not gPlayerAction
[0, ACTION_ATTACK
]) and
2003 (not gPlayerAction
[0, ACTION_MOVELEFT
]) and
2004 (not gPlayerAction
[0, ACTION_MOVERIGHT
]) and
2005 (not gPlayerAction
[0, ACTION_LOOKUP
]) and
2006 (not gPlayerAction
[0, ACTION_LOOKDOWN
]) and
2007 (not gPlayerAction
[0, ACTION_WEAPPREV
]) and
2008 (not gPlayerAction
[0, ACTION_WEAPNEXT
]) then
2009 gSpectKeyPress
:= False;
2013 if gSpectMode
= SPECT_MAPVIEW
then
2015 i
:= Min(Max(gSpectX
+ gSpectAutoStepX
, 0), gMapInfo
.Width
- gScreenWidth
);
2017 gSpectAutoNext
:= gTime
2020 i
:= Min(Max(gSpectY
+ gSpectAutoStepY
, 0), gMapInfo
.Height
- gScreenHeight
);
2022 gSpectAutoNext
:= gTime
2026 if gSpectAutoNext
<= gTime
then
2028 if gSpectAutoNext
> 0 then
2030 gSpectMode
:= GetRandomSpectMode(gSpectMode
);
2034 gSpectX
:= Random(gMapInfo
.Width
- gScreenWidth
);
2035 gSpectY
:= Random(gMapInfo
.Height
- gScreenHeight
);
2036 gSpectAutoStepX
:= Random(9) - 4;
2037 gSpectAutoStepY
:= Random(9) - 4;
2038 if ((gSpectX
< 800) and (gSpectAutoStepX
< 0)) or
2039 ((gSpectX
> gMapInfo
.Width
- gScreenWidth
- 800) and (gSpectAutoStepX
> 0)) then
2040 gSpectAutoStepX
:= gSpectAutoStepX
* -1;
2041 if ((gSpectY
< 800) and (gSpectAutoStepY
< 0)) or
2042 ((gSpectY
> gMapInfo
.Height
- gScreenHeight
- 800) and (gSpectAutoStepY
> 0)) then
2043 gSpectAutoStepY
:= gSpectAutoStepY
* -1;
2047 gSpectPID1
:= GetActivePlayerID_Random(gSpectPID1
);
2052 SPECT_STATS
: gSpectAutoNext
:= gTime
+ (Random(3) + 5) * 1000;
2053 SPECT_MAPVIEW
: gSpectAutoNext
:= gTime
+ (Random(4) + 7) * 1000;
2054 SPECT_PLAYERS
: gSpectAutoNext
:= gTime
+ (Random(7) + 8) * 1000;
2060 // Îáíîâëÿåì âñå îñòàëüíîå:
2063 g_Triggers_Update();
2065 g_Monsters_Update();
2067 g_Player_UpdateAll();
2068 g_Player_UpdatePhysicalObjects();
2070 // server: send newly spawned monsters unconditionally
2071 if (gGameSettings
.GameType
= GT_SERVER
) then
2073 if (Length(gMonstersSpawned
) > 0) then
2075 for I
:= 0 to High(gMonstersSpawned
) do MH_SEND_MonsterSpawn(gMonstersSpawned
[I
]);
2076 SetLength(gMonstersSpawned
, 0);
2080 if (gSoundTriggerTime
> 8) then
2082 g_Game_UpdateTriggerSounds();
2083 gSoundTriggerTime
:= 0;
2087 Inc(gSoundTriggerTime
);
2090 if (NetMode
= NET_SERVER
) then
2092 Inc(NetTimeToUpdate
);
2093 Inc(NetTimeToReliable
);
2095 // send monster updates
2096 if (NetTimeToReliable
>= NetRelupdRate
) or (NetTimeToUpdate
>= NetUpdateRate
) then
2098 // send all monsters (periodic sync)
2099 reliableUpdate
:= (NetTimeToReliable
>= NetRelupdRate
);
2101 for I
:= 0 to High(gPlayers
) do
2103 if (gPlayers
[I
] <> nil) then MH_SEND_PlayerPos(reliableUpdate
, gPlayers
[I
].UID
);
2106 g_Mons_ForEach(sendMonsPos
);
2108 if reliableUpdate
then
2110 NetTimeToReliable
:= 0;
2111 NetTimeToUpdate
:= NetUpdateRate
;
2115 NetTimeToUpdate
:= 0;
2120 // send only mosters with some unexpected changes
2121 g_Mons_ForEach(sendMonsPosUnexpected
);
2124 // send unexpected platform changes
2125 g_Map_NetSendInterestingPanels();
2127 if NetUseMaster
then
2129 if gTime
>= NetTimeToMaster
then
2131 if (NetMHost
= nil) or (NetMPeer
= nil) then
2133 if not g_Net_Slist_Connect
then g_Console_Add(_lc
[I_NET_MSG_ERROR
] + _lc
[I_NET_SLIST_ERROR
]);
2137 NetTimeToMaster
:= gTime
+ NetMasterRate
;
2141 else if (NetMode
= NET_CLIENT
) then
2143 MC_SEND_PlayerPos();
2145 end; // if gameOn ...
2147 // Àêòèâíî îêíî èíòåðôåéñà - ïåðåäàåì êëàâèøè åìó:
2148 if g_ActiveWindow
<> nil then
2150 w
:= e_GetFirstKeyPressed();
2152 if (w
<> IK_INVALID
) then
2154 Msg
.Msg
:= MESSAGE_DIKEY
;
2156 g_ActiveWindow
.OnMessage(Msg
);
2159 // Åñëè îíî îò ýòîãî íå çàêðûëîñü, òî îáíîâëÿåì:
2160 if g_ActiveWindow
<> nil then
2161 g_ActiveWindow
.Update();
2163 // Íóæíî ñìåíèòü ðàçðåøåíèå:
2164 if gResolutionChange
then
2166 e_WriteLog('Changing resolution', TMsgType
.Notify
);
2167 g_Game_ChangeResolution(gRC_Width
, gRC_Height
, gRC_FullScreen
, gRC_Maximized
);
2168 gResolutionChange
:= False;
2169 g_ActiveWindow
:= nil;
2172 // Íóæíî ñìåíèòü ÿçûê:
2173 if gLanguageChange
then
2175 //e_WriteLog('Read language file', MSG_NOTIFY);
2176 //g_Language_Load(DataDir + gLanguage + '.txt');
2177 g_Language_Set(gLanguage
);
2179 gLanguageChange
:= False;
2183 // Ãîðÿ÷àÿ êëàâèøà äëÿ âûçîâà ìåíþ âûõîäà èç èãðû (F10):
2184 if e_KeyPressed(IK_F10
) and
2186 (not gConsoleShow
) and
2187 (g_ActiveWindow
= nil) then
2192 Time
:= GetTimer() {div 1000};
2194 // Îáðàáîòêà îòëîæåííûõ ñîáûòèé:
2195 if gDelayedEvents
<> nil then
2196 for a
:= 0 to High(gDelayedEvents
) do
2197 if gDelayedEvents
[a
].Pending
and
2199 ((gDelayedEvents
[a
].DEType
= DE_GLOBEVENT
) and (gDelayedEvents
[a
].Time
<= Time
)) or
2200 ((gDelayedEvents
[a
].DEType
> DE_GLOBEVENT
) and (gDelayedEvents
[a
].Time
<= gTime
))
2203 case gDelayedEvents
[a
].DEType
of
2205 g_Game_ExecuteEvent(gDelayedEvents
[a
].DEStr
);
2208 g_Game_Announce_GoodShot(gDelayedEvents
[a
].DENum
);
2212 g_Game_Announce_KillCombo(gDelayedEvents
[a
].DENum
);
2213 if g_Game_IsNet
and g_Game_IsServer
then
2214 MH_SEND_GameEvent(NET_EV_KILLCOMBO
, gDelayedEvents
[a
].DENum
);
2218 g_Game_Announce_BodyKill(gDelayedEvents
[a
].DENum
);
2220 gDelayedEvents
[a
].Pending
:= False;
2223 // Êàæäóþ ñåêóíäó îáíîâëÿåì ñ÷åò÷èê îáíîâëåíèé:
2224 UPSCounter
:= UPSCounter
+ 1;
2225 if Time
- UPSTime
>= 1000 then
2234 g_Weapon_AddDynLights();
2235 g_Items_AddDynLights();
2239 procedure g_Game_LoadChatSounds(Resource
: string);
2242 FileName
, Snd
: string;
2244 len
, cnt
, tags
, i
, j
: Integer;
2247 FileName
:= g_ExtractWadName(Resource
);
2249 WAD
:= TWADFile
.Create();
2250 WAD
.ReadFile(FileName
);
2252 if not WAD
.GetResource(g_ExtractFilePathName(Resource
), p
, len
) then
2259 cfg
:= TConfig
.CreateMem(p
, len
);
2260 cnt
:= cfg
.ReadInt('ChatSounds', 'Count', 0);
2262 SetLength(gChatSounds
, cnt
);
2263 for i
:= 0 to Length(gChatSounds
) - 1 do
2265 gChatSounds
[i
].Sound
:= nil;
2266 Snd
:= Trim(cfg
.ReadStr(IntToStr(i
), 'Sound', ''));
2267 tags
:= cfg
.ReadInt(IntToStr(i
), 'Tags', 0);
2268 if (Snd
= '') or (Tags
<= 0) then
2270 g_Sound_CreateWADEx('SOUND_CHAT_MACRO' + IntToStr(i
), GameWAD
+':'+Snd
);
2271 gChatSounds
[i
].Sound
:= TPlayableSound
.Create();
2272 gChatSounds
[i
].Sound
.SetByName('SOUND_CHAT_MACRO' + IntToStr(i
));
2273 SetLength(gChatSounds
[i
].Tags
, tags
);
2274 for j
:= 0 to tags
- 1 do
2275 gChatSounds
[i
].Tags
[j
] := toLowerCase1251(cfg
.ReadStr(IntToStr(i
), 'Tag' + IntToStr(j
), ''));
2276 gChatSounds
[i
].FullWord
:= cfg
.ReadBool(IntToStr(i
), 'FullWord', False);
2283 procedure g_Game_FreeChatSounds();
2287 for i
:= 0 to Length(gChatSounds
) - 1 do
2289 gChatSounds
[i
].Sound
.Free();
2290 g_Sound_Delete('SOUND_CHAT_MACRO' + IntToStr(i
));
2292 SetLength(gChatSounds
, 0);
2296 procedure g_Game_LoadData();
2303 if DataLoaded
then Exit
;
2305 e_WriteLog('Loading game data...', TMsgType
.Notify
);
2307 g_Texture_CreateWADEx('NOTEXTURE', GameWAD
+':TEXTURES\NOTEXTURE');
2308 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUD', GameWAD
+':TEXTURES\HUD');
2309 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDAIR', GameWAD
+':TEXTURES\AIRBAR');
2310 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDJET', GameWAD
+':TEXTURES\JETBAR');
2311 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDBG', GameWAD
+':TEXTURES\HUDBG');
2312 g_Texture_CreateWADEx('TEXTURE_PLAYER_ARMORHUD', GameWAD
+':TEXTURES\ARMORHUD');
2313 g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG', GameWAD
+':TEXTURES\FLAGHUD_R_BASE');
2314 g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG_S', GameWAD
+':TEXTURES\FLAGHUD_R_STOLEN');
2315 g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG_D', GameWAD
+':TEXTURES\FLAGHUD_R_DROP');
2316 g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG', GameWAD
+':TEXTURES\FLAGHUD_B_BASE');
2317 g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG_S', GameWAD
+':TEXTURES\FLAGHUD_B_STOLEN');
2318 g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG_D', GameWAD
+':TEXTURES\FLAGHUD_B_DROP');
2319 g_Texture_CreateWADEx('TEXTURE_PLAYER_TALKBUBBLE', GameWAD
+':TEXTURES\TALKBUBBLE');
2320 g_Texture_CreateWADEx('TEXTURE_PLAYER_INVULPENTA', GameWAD
+':TEXTURES\PENTA');
2321 g_Texture_CreateWADEx('TEXTURE_PLAYER_INDICATOR', GameWAD
+':TEXTURES\PLRIND');
2324 if not g_Texture_CreateWADEx('UI_GFX_PBAR_LEFT', GameWAD
+':TEXTURES\LLEFT') then hasPBarGfx
:= false;
2325 if not g_Texture_CreateWADEx('UI_GFX_PBAR_MARKER', GameWAD
+':TEXTURES\LMARKER') then hasPBarGfx
:= false;
2326 if not g_Texture_CreateWADEx('UI_GFX_PBAR_MIDDLE', GameWAD
+':TEXTURES\LMIDDLE') then hasPBarGfx
:= false;
2327 if not g_Texture_CreateWADEx('UI_GFX_PBAR_RIGHT', GameWAD
+':TEXTURES\LRIGHT') then hasPBarGfx
:= false;
2331 g_Texture_GetSize('UI_GFX_PBAR_LEFT', wl
, hl
);
2332 g_Texture_GetSize('UI_GFX_PBAR_RIGHT', wr
, hr
);
2333 g_Texture_GetSize('UI_GFX_PBAR_MIDDLE', wb
, hb
);
2334 g_Texture_GetSize('UI_GFX_PBAR_MARKER', wm
, hm
);
2335 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
2341 hasPBarGfx
:= false;
2345 g_Frames_CreateWAD(nil, 'FRAMES_TELEPORT', GameWAD
+':TEXTURES\TELEPORT', 64, 64, 10, False);
2346 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH', GameWAD
+':WEAPONS\PUNCH', 64, 64, 4, False);
2347 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_UP', GameWAD
+':WEAPONS\PUNCH_UP', 64, 64, 4, False);
2348 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_DN', GameWAD
+':WEAPONS\PUNCH_DN', 64, 64, 4, False);
2349 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_BERSERK', GameWAD
+':WEAPONS\PUNCHB', 64, 64, 4, False);
2350 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_BERSERK_UP', GameWAD
+':WEAPONS\PUNCHB_UP', 64, 64, 4, False);
2351 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_BERSERK_DN', GameWAD
+':WEAPONS\PUNCHB_DN', 64, 64, 4, False);
2352 g_Sound_CreateWADEx('SOUND_GAME_TELEPORT', GameWAD
+':SOUNDS\TELEPORT');
2353 g_Sound_CreateWADEx('SOUND_GAME_NOTELEPORT', GameWAD
+':SOUNDS\NOTELEPORT');
2354 g_Sound_CreateWADEx('SOUND_GAME_SECRET', GameWAD
+':SOUNDS\SECRET');
2355 g_Sound_CreateWADEx('SOUND_GAME_DOOROPEN', GameWAD
+':SOUNDS\DOOROPEN');
2356 g_Sound_CreateWADEx('SOUND_GAME_DOORCLOSE', GameWAD
+':SOUNDS\DOORCLOSE');
2357 g_Sound_CreateWADEx('SOUND_GAME_BULK1', GameWAD
+':SOUNDS\BULK1');
2358 g_Sound_CreateWADEx('SOUND_GAME_BULK2', GameWAD
+':SOUNDS\BULK2');
2359 g_Sound_CreateWADEx('SOUND_GAME_BUBBLE1', GameWAD
+':SOUNDS\BUBBLE1');
2360 g_Sound_CreateWADEx('SOUND_GAME_BUBBLE2', GameWAD
+':SOUNDS\BUBBLE2');
2361 g_Sound_CreateWADEx('SOUND_GAME_BURNING', GameWAD
+':SOUNDS\BURNING');
2362 g_Sound_CreateWADEx('SOUND_GAME_SWITCH1', GameWAD
+':SOUNDS\SWITCH1');
2363 g_Sound_CreateWADEx('SOUND_GAME_SWITCH0', GameWAD
+':SOUNDS\SWITCH0');
2364 g_Sound_CreateWADEx('SOUND_GAME_RADIO', GameWAD
+':SOUNDS\RADIO');
2365 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD1', GameWAD
+':SOUNDS\GOOD1');
2366 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD2', GameWAD
+':SOUNDS\GOOD2');
2367 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD3', GameWAD
+':SOUNDS\GOOD3');
2368 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD4', GameWAD
+':SOUNDS\GOOD4');
2369 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL2X', GameWAD
+':SOUNDS\KILL2X');
2370 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL3X', GameWAD
+':SOUNDS\KILL3X');
2371 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL4X', GameWAD
+':SOUNDS\KILL4X');
2372 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILLMX', GameWAD
+':SOUNDS\KILLMX');
2373 g_Sound_CreateWADEx('SOUND_ANNOUNCER_MUHAHA1', GameWAD
+':SOUNDS\MUHAHA1');
2374 g_Sound_CreateWADEx('SOUND_ANNOUNCER_MUHAHA2', GameWAD
+':SOUNDS\MUHAHA2');
2375 g_Sound_CreateWADEx('SOUND_ANNOUNCER_MUHAHA3', GameWAD
+':SOUNDS\MUHAHA3');
2376 g_Sound_CreateWADEx('SOUND_CTF_GET1', GameWAD
+':SOUNDS\GETFLAG1');
2377 g_Sound_CreateWADEx('SOUND_CTF_GET2', GameWAD
+':SOUNDS\GETFLAG2');
2378 g_Sound_CreateWADEx('SOUND_CTF_LOST1', GameWAD
+':SOUNDS\LOSTFLG1');
2379 g_Sound_CreateWADEx('SOUND_CTF_LOST2', GameWAD
+':SOUNDS\LOSTFLG2');
2380 g_Sound_CreateWADEx('SOUND_CTF_RETURN1', GameWAD
+':SOUNDS\RETFLAG1');
2381 g_Sound_CreateWADEx('SOUND_CTF_RETURN2', GameWAD
+':SOUNDS\RETFLAG2');
2382 g_Sound_CreateWADEx('SOUND_CTF_CAPTURE1', GameWAD
+':SOUNDS\CAPFLAG1');
2383 g_Sound_CreateWADEx('SOUND_CTF_CAPTURE2', GameWAD
+':SOUNDS\CAPFLAG2');
2385 goodsnd
[0] := TPlayableSound
.Create();
2386 goodsnd
[1] := TPlayableSound
.Create();
2387 goodsnd
[2] := TPlayableSound
.Create();
2388 goodsnd
[3] := TPlayableSound
.Create();
2390 goodsnd
[0].SetByName('SOUND_ANNOUNCER_GOOD1');
2391 goodsnd
[1].SetByName('SOUND_ANNOUNCER_GOOD2');
2392 goodsnd
[2].SetByName('SOUND_ANNOUNCER_GOOD3');
2393 goodsnd
[3].SetByName('SOUND_ANNOUNCER_GOOD4');
2395 killsnd
[0] := TPlayableSound
.Create();
2396 killsnd
[1] := TPlayableSound
.Create();
2397 killsnd
[2] := TPlayableSound
.Create();
2398 killsnd
[3] := TPlayableSound
.Create();
2400 killsnd
[0].SetByName('SOUND_ANNOUNCER_KILL2X');
2401 killsnd
[1].SetByName('SOUND_ANNOUNCER_KILL3X');
2402 killsnd
[2].SetByName('SOUND_ANNOUNCER_KILL4X');
2403 killsnd
[3].SetByName('SOUND_ANNOUNCER_KILLMX');
2405 hahasnd
[0] := TPlayableSound
.Create();
2406 hahasnd
[1] := TPlayableSound
.Create();
2407 hahasnd
[2] := TPlayableSound
.Create();
2409 hahasnd
[0].SetByName('SOUND_ANNOUNCER_MUHAHA1');
2410 hahasnd
[1].SetByName('SOUND_ANNOUNCER_MUHAHA2');
2411 hahasnd
[2].SetByName('SOUND_ANNOUNCER_MUHAHA3');
2413 sound_get_flag
[0] := TPlayableSound
.Create();
2414 sound_get_flag
[1] := TPlayableSound
.Create();
2415 sound_lost_flag
[0] := TPlayableSound
.Create();
2416 sound_lost_flag
[1] := TPlayableSound
.Create();
2417 sound_ret_flag
[0] := TPlayableSound
.Create();
2418 sound_ret_flag
[1] := TPlayableSound
.Create();
2419 sound_cap_flag
[0] := TPlayableSound
.Create();
2420 sound_cap_flag
[1] := TPlayableSound
.Create();
2422 sound_get_flag
[0].SetByName('SOUND_CTF_GET1');
2423 sound_get_flag
[1].SetByName('SOUND_CTF_GET2');
2424 sound_lost_flag
[0].SetByName('SOUND_CTF_LOST1');
2425 sound_lost_flag
[1].SetByName('SOUND_CTF_LOST2');
2426 sound_ret_flag
[0].SetByName('SOUND_CTF_RETURN1');
2427 sound_ret_flag
[1].SetByName('SOUND_CTF_RETURN2');
2428 sound_cap_flag
[0].SetByName('SOUND_CTF_CAPTURE1');
2429 sound_cap_flag
[1].SetByName('SOUND_CTF_CAPTURE2');
2431 g_Game_LoadChatSounds(GameWAD
+':CHATSND\SNDCFG');
2433 g_Game_SetLoadingText(_lc
[I_LOAD_ITEMS_DATA
], 0, False);
2436 g_Game_SetLoadingText(_lc
[I_LOAD_WEAPONS_DATA
], 0, False);
2437 g_Weapon_LoadData();
2439 g_Monsters_LoadData();
2444 procedure g_Game_FreeData();
2446 if not DataLoaded
then Exit
;
2449 g_Weapon_FreeData();
2450 g_Monsters_FreeData();
2452 e_WriteLog('Releasing game data...', TMsgType
.Notify
);
2454 g_Texture_Delete('NOTEXTURE');
2455 g_Texture_Delete('TEXTURE_PLAYER_HUD');
2456 g_Texture_Delete('TEXTURE_PLAYER_HUDBG');
2457 g_Texture_Delete('TEXTURE_PLAYER_ARMORHUD');
2458 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG');
2459 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG_S');
2460 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG_D');
2461 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG');
2462 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG_S');
2463 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG_D');
2464 g_Texture_Delete('TEXTURE_PLAYER_TALKBUBBLE');
2465 g_Texture_Delete('TEXTURE_PLAYER_INVULPENTA');
2466 g_Frames_DeleteByName('FRAMES_TELEPORT');
2467 g_Frames_DeleteByName('FRAMES_PUNCH');
2468 g_Frames_DeleteByName('FRAMES_PUNCH_UP');
2469 g_Frames_DeleteByName('FRAMES_PUNCH_DN');
2470 g_Frames_DeleteByName('FRAMES_PUNCH_BERSERK');
2471 g_Frames_DeleteByName('FRAMES_PUNCH_BERSERK_UP');
2472 g_Frames_DeleteByName('FRAMES_PUNCH_BERSERK_DN');
2473 g_Sound_Delete('SOUND_GAME_TELEPORT');
2474 g_Sound_Delete('SOUND_GAME_NOTELEPORT');
2475 g_Sound_Delete('SOUND_GAME_SECRET');
2476 g_Sound_Delete('SOUND_GAME_DOOROPEN');
2477 g_Sound_Delete('SOUND_GAME_DOORCLOSE');
2478 g_Sound_Delete('SOUND_GAME_BULK1');
2479 g_Sound_Delete('SOUND_GAME_BULK2');
2480 g_Sound_Delete('SOUND_GAME_BUBBLE1');
2481 g_Sound_Delete('SOUND_GAME_BUBBLE2');
2482 g_Sound_Delete('SOUND_GAME_BURNING');
2483 g_Sound_Delete('SOUND_GAME_SWITCH1');
2484 g_Sound_Delete('SOUND_GAME_SWITCH0');
2491 g_Sound_Delete('SOUND_ANNOUNCER_GOOD1');
2492 g_Sound_Delete('SOUND_ANNOUNCER_GOOD2');
2493 g_Sound_Delete('SOUND_ANNOUNCER_GOOD3');
2494 g_Sound_Delete('SOUND_ANNOUNCER_GOOD4');
2501 g_Sound_Delete('SOUND_ANNOUNCER_KILL2X');
2502 g_Sound_Delete('SOUND_ANNOUNCER_KILL3X');
2503 g_Sound_Delete('SOUND_ANNOUNCER_KILL4X');
2504 g_Sound_Delete('SOUND_ANNOUNCER_KILLMX');
2510 g_Sound_Delete('SOUND_ANNOUNCER_MUHAHA1');
2511 g_Sound_Delete('SOUND_ANNOUNCER_MUHAHA2');
2512 g_Sound_Delete('SOUND_ANNOUNCER_MUHAHA3');
2514 sound_get_flag
[0].Free();
2515 sound_get_flag
[1].Free();
2516 sound_lost_flag
[0].Free();
2517 sound_lost_flag
[1].Free();
2518 sound_ret_flag
[0].Free();
2519 sound_ret_flag
[1].Free();
2520 sound_cap_flag
[0].Free();
2521 sound_cap_flag
[1].Free();
2523 g_Sound_Delete('SOUND_CTF_GET1');
2524 g_Sound_Delete('SOUND_CTF_GET2');
2525 g_Sound_Delete('SOUND_CTF_LOST1');
2526 g_Sound_Delete('SOUND_CTF_LOST2');
2527 g_Sound_Delete('SOUND_CTF_RETURN1');
2528 g_Sound_Delete('SOUND_CTF_RETURN2');
2529 g_Sound_Delete('SOUND_CTF_CAPTURE1');
2530 g_Sound_Delete('SOUND_CTF_CAPTURE2');
2532 g_Game_FreeChatSounds();
2534 DataLoaded
:= False;
2537 procedure DrawCustomStat();
2543 ww2
, hh2
, r
, g
, b
, rr
, gg
, bb
: Byte;
2544 s1
, s2
, topstr
: String;
2546 e_TextureFontGetSize(gStdFont
, ww2
, hh2
);
2548 g_ProcessMessages();
2550 if g_Console_Action(ACTION_SCORES
) then
2552 if not gStatsPressed
then
2554 gStatsOff
:= not gStatsOff
;
2555 gStatsPressed
:= True;
2559 gStatsPressed
:= False;
2563 s1
:= _lc
[I_MENU_INTER_NOTICE_TAB
];
2564 w
:= (Length(s1
) * ww2
) div 2;
2565 x
:= gScreenWidth
div 2 - w
;
2567 e_TextureFontPrint(x
, y
, s1
, gStdFont
);
2571 if (gGameSettings
.GameMode
= GM_COOP
) then
2573 if gMissionFailed
then
2574 topstr
:= _lc
[I_MENU_INTER_MISSION_FAIL
]
2576 topstr
:= _lc
[I_MENU_INTER_LEVEL_COMPLETE
];
2579 topstr
:= _lc
[I_MENU_INTER_ROUND_OVER
];
2581 e_CharFont_GetSize(gMenuFont
, topstr
, ww1
, hh1
);
2582 e_CharFont_Print(gMenuFont
, (gScreenWidth
div 2)-(ww1
div 2), 16, topstr
);
2584 if g_Game_IsNet
then
2586 topstr
:= Format(_lc
[I_MENU_INTER_NOTICE_TIME
], [gServInterTime
]);
2587 if not gChatShow
then
2588 e_TextureFontPrintEx((gScreenWidth
div 2)-(Length(topstr
)*ww2
div 2),
2589 gScreenHeight
-(hh2
+4)*2, topstr
, gStdFont
, 255, 255, 255, 1);
2592 if g_Game_IsClient
then
2593 topstr
:= _lc
[I_MENU_INTER_NOTICE_MAP
]
2595 topstr
:= _lc
[I_MENU_INTER_NOTICE_SPACE
];
2596 if not gChatShow
then
2597 e_TextureFontPrintEx((gScreenWidth
div 2)-(Length(topstr
)*ww2
div 2),
2598 gScreenHeight
-(hh2
+4), topstr
, gStdFont
, 255, 255, 255, 1);
2603 w
:= gScreenWidth
-x
*2;
2609 e_DrawFillQuad(x
, y
, gScreenWidth
-x
-1, gScreenHeight
-y
-1, 64, 64, 64, 32);
2610 e_DrawQuad(x
, y
, gScreenWidth
-x
-1, gScreenHeight
-y
-1, 255, 127, 0);
2612 m
:= Max(Length(_lc
[I_MENU_MAP
])+1, Length(_lc
[I_GAME_GAME_TIME
])+1)*ww2
;
2614 case CustomStat
.GameMode
of
2617 if gGameSettings
.MaxLives
= 0 then
2618 s1
:= _lc
[I_GAME_DM
]
2620 s1
:= _lc
[I_GAME_LMS
];
2624 if gGameSettings
.MaxLives
= 0 then
2625 s1
:= _lc
[I_GAME_TDM
]
2627 s1
:= _lc
[I_GAME_TLMS
];
2629 GM_CTF
: s1
:= _lc
[I_GAME_CTF
];
2632 if gGameSettings
.MaxLives
= 0 then
2633 s1
:= _lc
[I_GAME_COOP
]
2635 s1
:= _lc
[I_GAME_SURV
];
2641 e_TextureFontPrintEx(x
+(w
div 2)-(Length(s1
)*ww2
div 2), _y
, s1
, gStdFont
, 255, 255, 255, 1);
2645 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_MENU_MAP
], gStdFont
, 255, 127, 0, 1);
2646 e_TextureFontPrint(x
+8+m
, _y
, Format('%s - %s', [CustomStat
.Map
, CustomStat
.MapName
]), gStdFont
);
2649 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_GAME_TIME
], gStdFont
, 255, 127, 0, 1);
2650 e_TextureFontPrint(x
+8+m
, _y
, Format('%d:%.2d:%.2d', [CustomStat
.GameTime
div 1000 div 3600,
2651 (CustomStat
.GameTime
div 1000 div 60) mod 60,
2652 CustomStat
.GameTime
div 1000 mod 60]), gStdFont
);
2654 pc
:= Length(CustomStat
.PlayerStat
);
2655 if pc
= 0 then Exit
;
2657 if CustomStat
.GameMode
= GM_COOP
then
2659 m
:= Max(Length(_lc
[I_GAME_MONSTERS
])+1, Length(_lc
[I_GAME_SECRETS
])+1)*ww2
;
2661 s2
:= _lc
[I_GAME_MONSTERS
];
2662 e_TextureFontPrintEx(x
+8, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2663 e_TextureFontPrintEx(x
+8+m
, _y
, IntToStr(gCoopMonstersKilled
) + '/' + IntToStr(gTotalMonsters
), gStdFont
, 255, 255, 255, 1);
2665 s2
:= _lc
[I_GAME_SECRETS
];
2666 e_TextureFontPrintEx(x
+8, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2667 e_TextureFontPrintEx(x
+8+m
, _y
, IntToStr(gCoopSecretsFound
) + '/' + IntToStr(gSecretsCount
), gStdFont
, 255, 255, 255, 1);
2670 m
:= Max(Length(_lc
[I_GAME_MONSTERS_TOTAL
])+1, Length(_lc
[I_GAME_SECRETS_TOTAL
])+1)*ww2
;
2672 s2
:= _lc
[I_GAME_MONSTERS_TOTAL
];
2673 e_TextureFontPrintEx(x
+250, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2674 e_TextureFontPrintEx(x
+250+m
, _y
, IntToStr(gCoopTotalMonstersKilled
) + '/' + IntToStr(gCoopTotalMonsters
), gStdFont
, 255, 255, 255, 1);
2676 s2
:= _lc
[I_GAME_SECRETS_TOTAL
];
2677 e_TextureFontPrintEx(x
+250, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2678 e_TextureFontPrintEx(x
+250+m
, _y
, IntToStr(gCoopTotalSecretsFound
) + '/' + IntToStr(gCoopTotalSecrets
), gStdFont
, 255, 255, 255, 1);
2682 if CustomStat
.GameMode
in [GM_TDM
, GM_CTF
] then
2687 if TeamStat
[TEAM_RED
].Goals
> TeamStat
[TEAM_BLUE
].Goals
then s1
:= _lc
[I_GAME_WIN_RED
]
2688 else if TeamStat
[TEAM_BLUE
].Goals
> TeamStat
[TEAM_RED
].Goals
then s1
:= _lc
[I_GAME_WIN_BLUE
]
2689 else s1
:= _lc
[I_GAME_WIN_DRAW
];
2691 e_TextureFontPrintEx(x
+8+(w
div 2)-(Length(s1
)*ww2
div 2), _y
, s1
, gStdFont
, 255, 255, 255, 1);
2694 for t
:= TEAM_RED
to TEAM_BLUE
do
2696 if t
= TEAM_RED
then
2698 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_TEAM_RED
],
2699 gStdFont
, 255, 0, 0, 1);
2700 e_TextureFontPrintEx(x
+w1
+8, _y
, IntToStr(CustomStat
.TeamStat
[TEAM_RED
].Goals
),
2701 gStdFont
, 255, 0, 0, 1);
2708 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_TEAM_BLUE
],
2709 gStdFont
, 0, 0, 255, 1);
2710 e_TextureFontPrintEx(x
+w1
+8, _y
, IntToStr(CustomStat
.TeamStat
[TEAM_BLUE
].Goals
),
2711 gStdFont
, 0, 0, 255, 1);
2717 e_DrawLine(1, x
+8, _y
+20, x
-8+w
, _y
+20, r
, g
, b
);
2720 for p
:= 0 to High(CustomStat
.PlayerStat
) do
2721 if CustomStat
.PlayerStat
[p
].Team
= t
then
2722 with CustomStat
.PlayerStat
[p
] do
2736 if (gPlayers
[Num
] <> nil) and (gPlayers
[Num
].FReady
) then
2737 e_TextureFontPrintEx(x
+16, _y
, Name
+ ' *', gStdFont
, rr
, gg
, bb
, 1)
2739 e_TextureFontPrintEx(x
+16, _y
, Name
, gStdFont
, rr
, gg
, bb
, 1);
2740 e_TextureFontPrintEx(x
+w1
+16, _y
, IntToStr(Frags
), gStdFont
, rr
, gg
, bb
, 1);
2741 e_TextureFontPrintEx(x
+w1
+w2
+16, _y
, IntToStr(Deaths
), gStdFont
, rr
, gg
, bb
, 1);
2748 else if CustomStat
.GameMode
in [GM_DM
, GM_COOP
] then
2751 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_PLAYER_NAME
], gStdFont
, 255, 127, 0, 1);
2752 e_TextureFontPrintEx(x
+8+w1
, _y
, _lc
[I_GAME_FRAGS
], gStdFont
, 255, 127, 0, 1);
2753 e_TextureFontPrintEx(x
+8+w1
+w2
, _y
, _lc
[I_GAME_DEATHS
], gStdFont
, 255, 127, 0, 1);
2756 for p
:= 0 to High(CustomStat
.PlayerStat
) do
2757 with CustomStat
.PlayerStat
[p
] do
2759 e_DrawFillQuad(x
+8, _y
+4, x
+24-1, _y
+16+4-1, Color
.R
, Color
.G
, Color
.B
, 0);
2766 if (gPlayers
[Num
] <> nil) and (gPlayers
[Num
].FReady
) then
2767 e_TextureFontPrintEx(x
+8+16+8, _y
+4, Name
+ ' *', gStdFont
, r
, r
, r
, 1, True)
2769 e_TextureFontPrintEx(x
+8+16+8, _y
+4, Name
, gStdFont
, r
, r
, r
, 1, True);
2770 e_TextureFontPrintEx(x
+w1
+8+16+8, _y
+4, IntToStr(Frags
), gStdFont
, r
, r
, r
, 1, True);
2771 e_TextureFontPrintEx(x
+w1
+w2
+8+16+8, _y
+4, IntToStr(Deaths
), gStdFont
, r
, r
, r
, 1, True);
2777 procedure DrawSingleStat();
2779 tm
, key_x
, val_x
, y
: Integer;
2783 procedure player_stat(n
: Integer);
2789 s1
:= Format(' %d ', [SingleStat
.PlayerStat
[n
].Kills
]);
2790 s2
:= Format(' %d', [gTotalMonsters
]);
2792 e_CharFont_Print(gMenuFont
, key_x
, y
, _lc
[I_MENU_INTER_KILLS
]);
2793 e_CharFont_PrintEx(gMenuFont
, val_x
, y
, s1
, _RGB(255, 0, 0));
2794 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2795 e_CharFont_Print(gMenuFont
, val_x
+w1
, y
, '/');
2797 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2798 e_CharFont_PrintEx(gMenuFont
, val_x
+w1
, y
, s2
, _RGB(255, 0, 0));
2800 // "Kills-per-minute: ##.#":
2801 s1
:= _lc
[I_MENU_INTER_KPM
];
2803 kpm
:= (SingleStat
.PlayerStat
[n
].Kills
/ tm
) * 60
2805 kpm
:= SingleStat
.PlayerStat
[n
].Kills
;
2806 s2
:= Format(' %.1f', [kpm
]);
2808 e_CharFont_Print(gMenuFont
, key_x
, y
+32, s1
);
2809 e_CharFont_PrintEx(gMenuFont
, val_x
, y
+32, s2
, _RGB(255, 0, 0));
2811 // "Secrets found: # / #":
2812 s1
:= Format(' %d ', [SingleStat
.PlayerStat
[n
].Secrets
]);
2813 s2
:= Format(' %d', [SingleStat
.TotalSecrets
]);
2815 e_CharFont_Print(gMenuFont
, key_x
, y
+64, _lc
[I_MENU_INTER_SECRETS
]);
2816 e_CharFont_PrintEx(gMenuFont
, val_x
, y
+64, s1
, _RGB(255, 0, 0));
2817 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2818 e_CharFont_Print(gMenuFont
, val_x
+w1
, y
+64, '/');
2820 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2821 e_CharFont_PrintEx(gMenuFont
, val_x
+w1
, y
+64, s2
, _RGB(255, 0, 0));
2825 // "Level Complete":
2826 e_CharFont_GetSize(gMenuFont
, _lc
[I_MENU_INTER_LEVEL_COMPLETE
], w1
, h
);
2827 e_CharFont_Print(gMenuFont
, (gScreenWidth
-w1
) div 2, 32, _lc
[I_MENU_INTER_LEVEL_COMPLETE
]);
2829 // Îïðåäåëÿåì êîîðäèíàòû âûðàâíèâàíèÿ ïî ñàìîé äëèííîé ñòðîêå:
2830 s1
:= _lc
[I_MENU_INTER_KPM
];
2831 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2834 e_CharFont_GetSize(gMenuFont
, s1
, w2
, h
);
2836 key_x
:= (gScreenWidth
-w1
-w2
) div 2;
2837 val_x
:= key_x
+ w1
;
2840 tm
:= SingleStat
.GameTime
div 1000;
2841 s1
:= _lc
[I_MENU_INTER_TIME
];
2842 s2
:= Format(' %d:%.2d:%.2d', [tm
div (60*60), (tm
mod (60*60)) div 60, tm
mod 60]);
2844 e_CharFont_Print(gMenuFont
, key_x
, 80, s1
);
2845 e_CharFont_PrintEx(gMenuFont
, val_x
, 80, s2
, _RGB(255, 0, 0));
2847 if SingleStat
.TwoPlayers
then
2850 s1
:= _lc
[I_MENU_PLAYER_1
];
2851 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2852 e_CharFont_Print(gMenuFont
, (gScreenWidth
-w1
) div 2, 128, s1
);
2854 // Ñòàòèñòèêà ïåðâîãî èãðîêà:
2859 s1
:= _lc
[I_MENU_PLAYER_2
];
2860 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2861 e_CharFont_Print(gMenuFont
, (gScreenWidth
-w1
) div 2, 288, s1
);
2863 // Ñòàòèñòèêà âòîðîãî èãðîêà:
2869 // Ñòàòèñòèêà ïåðâîãî èãðîêà:
2875 procedure DrawLoadingStat();
2876 procedure drawRect (x
, y
, w
, h
: Integer);
2878 if (w
< 1) or (h
< 1) then exit
;
2880 glVertex2f(x
+0.375, y
+0.375);
2881 glVertex2f(x
+w
+0.375, y
+0.375);
2882 glVertex2f(x
+w
+0.375, y
+h
+0.375);
2883 glVertex2f(x
+0.375, y
+h
+0.375);
2887 function drawPBar (cur
, total
: Integer; washere
: Boolean): Boolean;
2889 rectW
, rectH
: Integer;
2896 idl
, idr
, idb
, idm
: LongWord;
2900 if (total
< 1) then exit
;
2901 if (cur
< 1) then exit
; // don't blink
2902 if (not washere
) and (cur
>= total
) then exit
; // don't blink
2903 //if (cur < 0) then cur := 0;
2904 //if (cur > total) then cur := total;
2907 if (hasPBarGfx
) then
2909 g_Texture_Get('UI_GFX_PBAR_LEFT', idl
);
2910 g_Texture_GetSize('UI_GFX_PBAR_LEFT', wl
, hl
);
2911 g_Texture_Get('UI_GFX_PBAR_RIGHT', idr
);
2912 g_Texture_GetSize('UI_GFX_PBAR_RIGHT', wr
, hr
);
2913 g_Texture_Get('UI_GFX_PBAR_MIDDLE', idb
);
2914 g_Texture_GetSize('UI_GFX_PBAR_MIDDLE', wb
, hb
);
2915 g_Texture_Get('UI_GFX_PBAR_MARKER', idm
);
2916 g_Texture_GetSize('UI_GFX_PBAR_MARKER', wm
, hm
);
2918 //rectW := gScreenWidth-360;
2919 rectW
:= trunc(624.0*gScreenWidth
/1024.0);
2922 x0
:= (gScreenWidth
-rectW
) div 2;
2923 y0
:= gScreenHeight
-rectH
-64;
2924 if (y0
< 2) then y0
:= 2;
2926 glEnable(GL_SCISSOR_TEST
);
2929 glScissor(x0
, gScreenHeight
-y0
-rectH
, rectW
, rectH
);
2930 e_DrawSize(idl
, x0
, y0
, 0, true, false, wl
, hl
);
2931 e_DrawSize(idr
, x0
+rectW
-wr
, y0
, 0, true, false, wr
, hr
);
2934 glScissor(x0
+wl
, gScreenHeight
-y0
-rectH
, rectW
-wl
-wr
, rectH
);
2936 while (f
< x0
+rectW
) do
2938 e_DrawSize(idb
, f
, y0
, 0, true, false, wb
, hb
);
2943 wdt
:= (rectW
-wl
-wr
)*cur
div total
;
2944 if (wdt
> rectW
-wl
-wr
) then wdt
:= rectW
-wr
-wr
;
2947 my
:= y0
; // don't be so smart, ketmar: +(rectH-wm) div 2;
2948 glScissor(x0
+wl
, gScreenHeight
-my
-rectH
, wdt
, hm
);
2952 e_DrawSize(idm
, f
, y0
, 0, true, false, wm
, hm
);
2958 glScissor(0, 0, gScreenWidth
, gScreenHeight
);
2962 rectW
:= gScreenWidth
-64;
2965 x0
:= (gScreenWidth
-rectW
) div 2;
2966 y0
:= gScreenHeight
-rectH
-64;
2967 if (y0
< 2) then y0
:= 2;
2969 glDisable(GL_BLEND
);
2970 glDisable(GL_TEXTURE_2D
);
2972 //glClearColor(0, 0, 0, 0);
2973 //glClear(GL_COLOR_BUFFER_BIT);
2975 glColor4ub(127, 127, 127, 255);
2976 drawRect(x0
-2, y0
-2, rectW
+4, rectH
+4);
2978 glColor4ub(0, 0, 0, 255);
2979 drawRect(x0
-1, y0
-1, rectW
+2, rectH
+2);
2981 glColor4ub(127, 127, 127, 255);
2982 wdt
:= rectW
*cur
div total
;
2983 if (wdt
> rectW
) then wdt
:= rectW
;
2984 drawRect(x0
, y0
, wdt
, rectH
);
2993 if (Length(LoadingStat
.Msgs
) = 0) then exit
;
2995 e_CharFont_GetSize(gMenuFont
, _lc
[I_MENU_LOADING
], ww
, hh
);
2996 yy
:= (gScreenHeight
div 3);
2997 e_CharFont_Print(gMenuFont
, (gScreenWidth
div 2)-(ww
div 2), yy
-2*hh
, _lc
[I_MENU_LOADING
]);
2998 xx
:= (gScreenWidth
div 3);
3002 for i
:= 0 to NextMsg
-1 do
3004 if (i
= (NextMsg
-1)) and (MaxValue
> 0) then
3005 s
:= Format('%s: %d/%d', [Msgs
[i
], CurValue
, MaxValue
])
3009 e_CharFont_PrintEx(gMenuSmallFont
, xx
, yy
, s
, _RGB(255, 0, 0));
3010 yy
:= yy
+ LOADING_INTERLINE
;
3011 PBarWasHere
:= drawPBar(CurValue
, MaxValue
, PBarWasHere
);
3016 procedure DrawMenuBackground(tex
: AnsiString);
3022 if g_Texture_Get(tex
, ID
) then
3024 e_Clear(GL_COLOR_BUFFER_BIT
, 0, 0, 0);
3025 e_GetTextureSize(ID
, @w
, @h
);
3027 w
:= round(w
* 1.333 * (gScreenHeight
/ h
))
3029 w
:= trunc(w
* (gScreenHeight
/ h
));
3030 e_DrawSize(ID
, (gScreenWidth
- w
) div 2, 0, 0, False, False, w
, gScreenHeight
);
3032 else e_Clear(GL_COLOR_BUFFER_BIT
, 0, 0, 0);
3035 procedure DrawMinimap(p
: TPlayer
; RenderRect
: e_graphics
.TRect
);
3037 a
, aX
, aY
, aX2
, aY2
, Scale
, ScaleSz
: Integer;
3039 function monDraw (mon
: TMonster
): Boolean;
3041 result
:= false; // don't stop
3046 // Ëåâûé âåðõíèé óãîë
3047 aX
:= Obj
.X
div ScaleSz
+ 1;
3048 aY
:= Obj
.Y
div ScaleSz
+ 1;
3050 aX2
:= max(Obj
.Rect
.Width
div ScaleSz
, 1);
3051 aY2
:= max(Obj
.Rect
.Height
div ScaleSz
, 1);
3052 // Ïðàâûé íèæíèé óãîë
3053 aX2
:= aX
+ aX2
- 1;
3054 aY2
:= aY
+ aY2
- 1;
3055 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 255, 0, 0);
3061 if (gMapInfo
.Width
> RenderRect
.Right
- RenderRect
.Left
) or
3062 (gMapInfo
.Height
> RenderRect
.Bottom
- RenderRect
.Top
) then
3065 // Ñêîëüêî ïèêñåëîâ êàðòû â 1 ïèêñåëå ìèíè-êàðòû:
3066 ScaleSz
:= 16 div Scale
;
3067 // Ðàçìåðû ìèíè-êàðòû:
3068 aX
:= max(gMapInfo
.Width
div ScaleSz
, 1);
3069 aY
:= max(gMapInfo
.Height
div ScaleSz
, 1);
3071 e_DrawFillQuad(0, 0, aX
-1, aY
-1, 0, 0, 0, 0);
3073 if gWalls
<> nil then
3076 for a
:= 0 to High(gWalls
) do
3078 if PanelType
<> 0 then
3080 // Ëåâûé âåðõíèé óãîë:
3081 aX
:= X
div ScaleSz
;
3082 aY
:= Y
div ScaleSz
;
3084 aX2
:= max(Width
div ScaleSz
, 1);
3085 aY2
:= max(Height
div ScaleSz
, 1);
3086 // Ïðàâûé íèæíèé óãîë:
3087 aX2
:= aX
+ aX2
- 1;
3088 aY2
:= aY
+ aY2
- 1;
3091 PANEL_WALL
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 208, 208, 208, 0);
3092 PANEL_OPENDOOR
, PANEL_CLOSEDOOR
:
3093 if Enabled
then e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 160, 160, 160, 0);
3097 if gSteps
<> nil then
3100 for a
:= 0 to High(gSteps
) do
3102 if PanelType
<> 0 then
3104 // Ëåâûé âåðõíèé óãîë:
3105 aX
:= X
div ScaleSz
;
3106 aY
:= Y
div ScaleSz
;
3108 aX2
:= max(Width
div ScaleSz
, 1);
3109 aY2
:= max(Height
div ScaleSz
, 1);
3110 // Ïðàâûé íèæíèé óãîë:
3111 aX2
:= aX
+ aX2
- 1;
3112 aY2
:= aY
+ aY2
- 1;
3114 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 128, 128, 128, 0);
3117 if gLifts
<> nil then
3120 for a
:= 0 to High(gLifts
) do
3122 if PanelType
<> 0 then
3124 // Ëåâûé âåðõíèé óãîë:
3125 aX
:= X
div ScaleSz
;
3126 aY
:= Y
div ScaleSz
;
3128 aX2
:= max(Width
div ScaleSz
, 1);
3129 aY2
:= max(Height
div ScaleSz
, 1);
3130 // Ïðàâûé íèæíèé óãîë:
3131 aX2
:= aX
+ aX2
- 1;
3132 aY2
:= aY
+ aY2
- 1;
3135 LIFTTYPE_UP
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 116, 72, 36, 0);
3136 LIFTTYPE_DOWN
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 116, 124, 96, 0);
3137 LIFTTYPE_LEFT
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 200, 80, 4, 0);
3138 LIFTTYPE_RIGHT
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 252, 140, 56, 0);
3142 if gWater
<> nil then
3145 for a
:= 0 to High(gWater
) do
3147 if PanelType
<> 0 then
3149 // Ëåâûé âåðõíèé óãîë:
3150 aX
:= X
div ScaleSz
;
3151 aY
:= Y
div ScaleSz
;
3153 aX2
:= max(Width
div ScaleSz
, 1);
3154 aY2
:= max(Height
div ScaleSz
, 1);
3155 // Ïðàâûé íèæíèé óãîë:
3156 aX2
:= aX
+ aX2
- 1;
3157 aY2
:= aY
+ aY2
- 1;
3159 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 0, 192, 0);
3162 if gAcid1
<> nil then
3164 // Ðèñóåì êèñëîòó 1:
3165 for a
:= 0 to High(gAcid1
) do
3167 if PanelType
<> 0 then
3169 // Ëåâûé âåðõíèé óãîë:
3170 aX
:= X
div ScaleSz
;
3171 aY
:= Y
div ScaleSz
;
3173 aX2
:= max(Width
div ScaleSz
, 1);
3174 aY2
:= max(Height
div ScaleSz
, 1);
3175 // Ïðàâûé íèæíèé óãîë:
3176 aX2
:= aX
+ aX2
- 1;
3177 aY2
:= aY
+ aY2
- 1;
3179 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 176, 0, 0);
3182 if gAcid2
<> nil then
3184 // Ðèñóåì êèñëîòó 2:
3185 for a
:= 0 to High(gAcid2
) do
3187 if PanelType
<> 0 then
3189 // Ëåâûé âåðõíèé óãîë:
3190 aX
:= X
div ScaleSz
;
3191 aY
:= Y
div ScaleSz
;
3193 aX2
:= max(Width
div ScaleSz
, 1);
3194 aY2
:= max(Height
div ScaleSz
, 1);
3195 // Ïðàâûé íèæíèé óãîë:
3196 aX2
:= aX
+ aX2
- 1;
3197 aY2
:= aY
+ aY2
- 1;
3199 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 176, 0, 0, 0);
3202 if gPlayers
<> nil then
3205 for a
:= 0 to High(gPlayers
) do
3206 if gPlayers
[a
] <> nil then with gPlayers
[a
] do
3208 // Ëåâûé âåðõíèé óãîë:
3209 aX
:= Obj
.X
div ScaleSz
+ 1;
3210 aY
:= Obj
.Y
div ScaleSz
+ 1;
3212 aX2
:= max(Obj
.Rect
.Width
div ScaleSz
, 1);
3213 aY2
:= max(Obj
.Rect
.Height
div ScaleSz
, 1);
3214 // Ïðàâûé íèæíèé óãîë:
3215 aX2
:= aX
+ aX2
- 1;
3216 aY2
:= aY
+ aY2
- 1;
3218 if gPlayers
[a
] = p
then
3219 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 255, 0, 0)
3222 TEAM_RED
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 0, 0, 0);
3223 TEAM_BLUE
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 0, 255, 0);
3224 else e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 128, 0, 0);
3229 g_Mons_ForEach(monDraw
);
3234 procedure renderAmbientQuad (hasAmbient
: Boolean; constref ambColor
: TDFColor
);
3236 if not hasAmbient
then exit
;
3237 e_AmbientQuad(sX
, sY
, sWidth
, sHeight
, ambColor
.r
, ambColor
.g
, ambColor
.b
, ambColor
.a
);
3241 // setup sX, sY, sWidth, sHeight, and transformation matrix before calling this!
3242 //FIXME: broken for splitscreen mode
3243 procedure renderDynLightsInternal ();
3245 //hasAmbient: Boolean;
3246 //ambColor: TDFColor;
3248 lx
, ly
, lrad
: Integer;
3249 scxywh
: array[0..3] of GLint
;
3252 if e_NoGraphics
then exit
;
3254 //TODO: lights should be in separate grid, i think
3255 // but on the other side: grid may be slower for dynlights, as their lifetime is short
3256 if (not gwin_k8_enable_light_experiments
) or (not gwin_has_stencil
) or (g_dynLightCount
< 1) then exit
;
3259 //ambColor := gCurrentMap['light_ambient'].rgba;
3260 //hasAmbient := (not ambColor.isOpaque) or (not ambColor.isBlack);
3262 { // this will multiply incoming color to alpha from framebuffer
3264 glBlendFunc(GL_DST_ALPHA, GL_ONE);
3268 * light rendering: (INVALID!)
3269 * glStencilFunc(GL_EQUAL, 0, $ff);
3271 * glClear(GL_STENCIL_BUFFER_BIT);
3272 * glStencilOp(GL_KEEP, GL_KEEP, GL_INCR);
3273 * draw shadow volume into stencil buffer
3274 * glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); // modify color buffer
3275 * glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); // don't modify stencil buffer
3277 * draw color-less quad with light alpha (WARNING! don't touch color!)
3278 * glEnable(GL_BLEND);
3279 * glBlendFunc(GL_DST_ALPHA, GL_ONE);
3280 * draw all geometry up to and including walls (with alpha-testing, probably) -- this does lighting
3282 wassc
:= (glIsEnabled(GL_SCISSOR_TEST
) <> 0);
3283 if wassc
then glGetIntegerv(GL_SCISSOR_BOX
, @scxywh
[0]) else glGetIntegerv(GL_VIEWPORT
, @scxywh
[0]);
3285 // setup OpenGL parameters
3286 glStencilMask($FFFFFFFF);
3287 glStencilFunc(GL_ALWAYS
, 0, $FFFFFFFF);
3288 glEnable(GL_STENCIL_TEST
);
3289 glEnable(GL_SCISSOR_TEST
);
3290 glClear(GL_STENCIL_BUFFER_BIT
);
3291 glStencilFunc(GL_EQUAL
, 0, $ff);
3293 for lln
:= 0 to g_dynLightCount
-1 do
3295 lx
:= g_dynLights
[lln
].x
;
3296 ly
:= g_dynLights
[lln
].y
;
3297 lrad
:= g_dynLights
[lln
].radius
;
3298 if (lrad
< 3) then continue
;
3300 if (lx
-sX
+lrad
< 0) then continue
;
3301 if (ly
-sY
+lrad
< 0) then continue
;
3302 if (lx
-sX
-lrad
>= gPlayerScreenSize
.X
) then continue
;
3303 if (ly
-sY
-lrad
>= gPlayerScreenSize
.Y
) then continue
;
3305 // set scissor to optimize drawing
3306 if (g_dbg_scale
= 1.0) then
3308 glScissor((lx
-sX
)-lrad
+2, gPlayerScreenSize
.Y
-(ly
-sY
)-lrad
-1+2, lrad
*2-4, lrad
*2-4);
3312 glScissor(0, 0, gWinSizeX
, gWinSizeY
);
3314 // no need to clear stencil buffer, light blitting will do it for us... but only for normal scale
3315 if (g_dbg_scale
<> 1.0) then glClear(GL_STENCIL_BUFFER_BIT
);
3316 glStencilOp(GL_KEEP
, GL_KEEP
, GL_INCR
);
3317 // draw extruded panels
3318 glDisable(GL_TEXTURE_2D
);
3319 glDisable(GL_BLEND
);
3320 glColorMask(GL_FALSE
, GL_FALSE
, GL_FALSE
, GL_FALSE
); // no need to modify color buffer
3321 if (lrad
> 4) then g_Map_DrawPanelShadowVolumes(lx
, ly
, lrad
);
3322 // render light texture
3323 glColorMask(GL_TRUE
, GL_TRUE
, GL_TRUE
, GL_TRUE
); // modify color buffer
3324 glStencilOp(GL_ZERO
, GL_ZERO
, GL_ZERO
); // draw light, and clear stencil buffer
3327 glBlendFunc(GL_SRC_ALPHA
, GL_ONE_MINUS_SRC_ALPHA
);
3328 glEnable(GL_TEXTURE_2D
);
3329 // color and opacity
3330 glColor4f(g_dynLights
[lln
].r
, g_dynLights
[lln
].g
, g_dynLights
[lln
].b
, g_dynLights
[lln
].a
);
3331 glBindTexture(GL_TEXTURE_2D
, g_Texture_Light());
3333 glTexCoord2f(0.0, 0.0); glVertex2i(lx
-lrad
, ly
-lrad
); // top-left
3334 glTexCoord2f(1.0, 0.0); glVertex2i(lx
+lrad
, ly
-lrad
); // top-right
3335 glTexCoord2f(1.0, 1.0); glVertex2i(lx
+lrad
, ly
+lrad
); // bottom-right
3336 glTexCoord2f(0.0, 1.0); glVertex2i(lx
-lrad
, ly
+lrad
); // bottom-left
3341 glDisable(GL_STENCIL_TEST
);
3342 glDisable(GL_BLEND
);
3343 glDisable(GL_SCISSOR_TEST
);
3344 //glScissor(0, 0, sWidth, sHeight);
3346 glScissor(scxywh
[0], scxywh
[1], scxywh
[2], scxywh
[3]);
3347 if wassc
then glEnable(GL_SCISSOR_TEST
) else glDisable(GL_SCISSOR_TEST
);
3351 function fixViewportForScale (): Boolean;
3353 nx0
, ny0
, nw
, nh
: Integer;
3356 if (g_dbg_scale
<> 1.0) then
3359 nx0
:= round(sX
-(gPlayerScreenSize
.X
-(sWidth
*g_dbg_scale
))/2/g_dbg_scale
);
3360 ny0
:= round(sY
-(gPlayerScreenSize
.Y
-(sHeight
*g_dbg_scale
))/2/g_dbg_scale
);
3361 nw
:= round(sWidth
/g_dbg_scale
);
3362 nh
:= round(sHeight
/g_dbg_scale
);
3371 // setup sX, sY, sWidth, sHeight, and transformation matrix before calling this!
3372 // WARNING! this WILL CALL `glTranslatef()`, but won't restore matrices!
3373 procedure renderMapInternal (backXOfs
, backYOfs
: Integer; setTransMatrix
: Boolean);
3375 TDrawCB
= procedure ();
3378 hasAmbient
: Boolean;
3380 doAmbient
: Boolean = false;
3382 procedure drawPanelType (profname
: AnsiString; panType
: DWord
; doDraw
: Boolean);
3387 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin(profname
);
3388 if gdbg_map_use_accel_render
then
3390 tagmask
:= panelTypeToTag(panType
);
3391 while (gDrawPanelList
.count
> 0) do
3393 pan
:= TPanel(gDrawPanelList
.front());
3394 if ((pan
.tag
and tagmask
) = 0) then break
;
3395 if doDraw
then pan
.Draw(doAmbient
, ambColor
);
3396 gDrawPanelList
.popFront();
3401 if doDraw
then g_Map_DrawPanels(panType
, hasAmbient
, ambColor
);
3403 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
3406 procedure drawOther (profname
: AnsiString; cb
: TDrawCB
);
3408 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin(profname
);
3409 if assigned(cb
) then cb();
3410 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
3414 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin('total');
3416 // our accelerated renderer will collect all panels to gDrawPanelList
3417 // we can use panel tag to render level parts (see GridTagXXX in g_map.pas)
3418 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin('collect');
3419 if gdbg_map_use_accel_render
then
3421 g_Map_CollectDrawPanels(sX
, sY
, sWidth
, sHeight
);
3423 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
3425 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin('skyback');
3426 g_Map_DrawBack(backXOfs
, backYOfs
);
3427 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
3429 if setTransMatrix
then
3431 //if (g_dbg_scale <> 1.0) then glTranslatef(0.0, -0.375/2, 0);
3432 glScalef(g_dbg_scale
, g_dbg_scale
, 1.0);
3433 glTranslatef(-sX
, -sY
, 0);
3437 ambColor
:= gCurrentMap
['light_ambient'].rgba
;
3438 hasAmbient
:= (not ambColor
.isOpaque
) or (not ambColor
.isBlack
);
3443 //writeln('color: (', ambColor.r, ',', ambColor.g, ',', ambColor.b, ',', ambColor.a, ')');
3444 glColor4ub(ambColor.r, ambColor.g, ambColor.b, ambColor.a);
3445 glClear(GL_COLOR_BUFFER_BIT);
3448 //writeln('color: (', ambColor.r, ',', ambColor.g, ',', ambColor.b, ',', ambColor.a, ')');
3451 drawPanelType('*back', PANEL_BACK
, g_rlayer_back
);
3452 drawPanelType('*step', PANEL_STEP
, g_rlayer_step
);
3453 drawOther('items', @g_Items_Draw
);
3454 drawOther('weapons', @g_Weapon_Draw
);
3455 drawOther('shells', @g_Player_DrawShells
);
3456 drawOther('drawall', @g_Player_DrawAll
);
3457 drawOther('corpses', @g_Player_DrawCorpses
);
3458 drawPanelType('*wall', PANEL_WALL
, g_rlayer_wall
);
3459 drawOther('monsters', @g_Monsters_Draw
);
3460 drawOther('itemdrop', @g_Items_DrawDrop
);
3461 drawPanelType('*door', PANEL_CLOSEDOOR
, g_rlayer_door
);
3462 drawOther('gfx', @g_GFX_Draw
);
3463 drawOther('flags', @g_Map_DrawFlags
);
3464 drawPanelType('*acid1', PANEL_ACID1
, g_rlayer_acid1
);
3465 drawPanelType('*acid2', PANEL_ACID2
, g_rlayer_acid2
);
3466 drawPanelType('*water', PANEL_WATER
, g_rlayer_water
);
3467 drawOther('dynlights', @renderDynLightsInternal
);
3469 if hasAmbient
{and ((not g_playerLight) or (not gwin_has_stencil) or (g_dynLightCount < 1))} then
3471 renderAmbientQuad(hasAmbient
, ambColor
);
3475 drawPanelType('*fore', PANEL_FORE
, g_rlayer_fore
);
3478 if g_debug_HealthBar
then
3480 g_Monsters_DrawHealth();
3481 g_Player_DrawHealth();
3484 if (profileFrameDraw
<> nil) then profileFrameDraw
.mainEnd(); // map rendering
3488 procedure DrawMapView(x
, y
, w
, h
: Integer);
3495 bx
:= Round(x
/(gMapInfo
.Width
- w
)*(gBackSize
.X
- w
));
3496 by
:= Round(y
/(gMapInfo
.Height
- h
)*(gBackSize
.Y
- h
));
3503 fixViewportForScale();
3504 renderMapInternal(-bx
, -by
, true);
3510 procedure DrawPlayer(p
: TPlayer
);
3512 px
, py
, a
, b
, c
, d
: Integer;
3515 if (p
= nil) or (p
.FDummy
) then
3518 g_Map_DrawBack(0, 0);
3523 if (profileFrameDraw
= nil) then profileFrameDraw
:= TProfiler
.Create('RENDER', g_profile_history_size
);
3524 if (profileFrameDraw
<> nil) then profileFrameDraw
.mainBegin(g_profile_frame_draw
);
3530 px
:= p
.GameX
+ PLAYER_RECT_CX
;
3531 py
:= p
.GameY
+ PLAYER_RECT_CY
+p
.Obj
.slopeUpLeft
;
3533 if (g_dbg_scale
= 1.0) and (not g_dbg_ignore_bounds
) then
3535 if (px
> (gPlayerScreenSize
.X
div 2)) then a
:= -px
+(gPlayerScreenSize
.X
div 2) else a
:= 0;
3536 if (py
> (gPlayerScreenSize
.Y
div 2)) then b
:= -py
+(gPlayerScreenSize
.Y
div 2) else b
:= 0;
3538 if (px
> gMapInfo
.Width
-(gPlayerScreenSize
.X
div 2)) then a
:= -gMapInfo
.Width
+gPlayerScreenSize
.X
;
3539 if (py
> gMapInfo
.Height
-(gPlayerScreenSize
.Y
div 2)) then b
:= -gMapInfo
.Height
+gPlayerScreenSize
.Y
;
3541 if (gMapInfo
.Width
= gPlayerScreenSize
.X
) then a
:= 0
3542 else if (gMapInfo
.Width
< gPlayerScreenSize
.X
) then
3545 a
:= (gPlayerScreenSize
.X
-gMapInfo
.Width
) div 2;
3548 if (gMapInfo
.Height
= gPlayerScreenSize
.Y
) then b
:= 0
3549 else if (gMapInfo
.Height
< gPlayerScreenSize
.Y
) then
3552 b
:= (gPlayerScreenSize
.Y
-gMapInfo
.Height
) div 2;
3557 // scaled, ignore level bounds
3558 a
:= -px
+(gPlayerScreenSize
.X
div 2);
3559 b
:= -py
+(gPlayerScreenSize
.Y
div 2);
3562 if p
.IncCam
<> 0 then
3564 if py
> gMapInfo
.Height
-(gPlayerScreenSize
.Y
div 2) then
3566 if p
.IncCam
> 120-(py
-(gMapInfo
.Height
-(gPlayerScreenSize
.Y
div 2))) then
3568 p
.IncCam
:= 120-(py
-(gMapInfo
.Height
-(gPlayerScreenSize
.Y
div 2)));
3572 if py
< gPlayerScreenSize
.Y
div 2 then
3574 if p
.IncCam
< -120+((gPlayerScreenSize
.Y
div 2)-py
) then
3576 p
.IncCam
:= -120+((gPlayerScreenSize
.Y
div 2)-py
);
3580 if p
.IncCam
< 0 then
3582 while (py
+(gPlayerScreenSize
.Y
div 2)-p
.IncCam
> gMapInfo
.Height
) and (p
.IncCam
< 0) do p
.IncCam
:= p
.IncCam
+1; //Inc(p.IncCam);
3585 if p
.IncCam
> 0 then
3587 while (py
-(gPlayerScreenSize
.Y
div 2)-p
.IncCam
< 0) and (p
.IncCam
> 0) do p
.IncCam
:= p
.IncCam
-1; //Dec(p.IncCam);
3591 if (px
< gPlayerScreenSize
.X
div 2) or (gMapInfo
.Width
-gPlayerScreenSize
.X
<= 256) then c
:= 0
3592 else if (px
> gMapInfo
.Width
-(gPlayerScreenSize
.X
div 2)) then c
:= gBackSize
.X
-gPlayerScreenSize
.X
3593 else c
:= round((px
-(gPlayerScreenSize
.X
div 2))/(gMapInfo
.Width
-gPlayerScreenSize
.X
)*(gBackSize
.X
-gPlayerScreenSize
.X
));
3595 if (py
-p
.IncCam
<= gPlayerScreenSize
.Y
div 2) or (gMapInfo
.Height
-gPlayerScreenSize
.Y
<= 256) then d
:= 0
3596 else if (py
-p
.IncCam
>= gMapInfo
.Height
-(gPlayerScreenSize
.Y
div 2)) then d
:= gBackSize
.Y
-gPlayerScreenSize
.Y
3597 else d
:= round((py
-p
.IncCam
-(gPlayerScreenSize
.Y
div 2))/(gMapInfo
.Height
-gPlayerScreenSize
.Y
)*(gBackSize
.Y
-gPlayerScreenSize
.Y
));
3600 sY
:= -(b
+p
.IncCam
);
3601 sWidth
:= gPlayerScreenSize
.X
;
3602 sHeight
:= gPlayerScreenSize
.Y
;
3604 //glTranslatef(a, b+p.IncCam, 0);
3606 //if (p = gPlayer1) and (g_dbg_scale >= 1.0) then g_Holmes_plrViewSize(sWidth, sHeight);
3608 //conwritefln('OLD: (%s,%s)-(%s,%s)', [sX, sY, sWidth, sHeight]);
3609 fixViewportForScale();
3610 //conwritefln(' (%s,%s)-(%s,%s)', [sX, sY, sWidth, sHeight]);
3612 if (g_dbg_scale
<> 1.0) and (not g_dbg_ignore_bounds
) then
3614 if (sX
+sWidth
> gMapInfo
.Width
) then sX
:= gMapInfo
.Width
-sWidth
;
3615 if (sY
+sHeight
> gMapInfo
.Height
) then sY
:= gMapInfo
.Height
-sHeight
;
3616 if (sX
< 0) then sX
:= 0;
3617 if (sY
< 0) then sY
:= 0;
3619 if (gBackSize
.X
<= gPlayerScreenSize
.X
) or (gMapInfo
.Width
<= sWidth
) then c
:= 0 else c
:= trunc((gBackSize
.X
-gPlayerScreenSize
.X
)*sX
/(gMapInfo
.Width
-sWidth
));
3620 if (gBackSize
.Y
<= gPlayerScreenSize
.Y
) or (gMapInfo
.Height
<= sHeight
) then d
:= 0 else d
:= trunc((gBackSize
.Y
-gPlayerScreenSize
.Y
)*sY
/(gMapInfo
.Height
-sHeight
));
3623 //r_smallmap_h: 0: left; 1: center; 2: right
3624 //r_smallmap_v: 0: top; 1: center; 2: bottom
3626 if (gMapInfo
.Width
= sWidth
) then
3630 else if (gMapInfo
.Width
< sWidth
) then
3632 case r_smallmap_h
of
3633 1: sX
:= -((sWidth
-gMapInfo
.Width
) div 2); // center
3634 2: sX
:= -(sWidth
-gMapInfo
.Width
); // right
3635 else sX
:= 0; // left
3639 if (gMapInfo
.Height
= sHeight
) then
3643 else if (gMapInfo
.Height
< sHeight
) then
3645 case r_smallmap_v
of
3646 1: sY
:= -((sHeight
-gMapInfo
.Height
) div 2); // center
3647 2: sY
:= -(sHeight
-gMapInfo
.Height
); // bottom
3648 else sY
:= 0; // top
3654 p
.viewPortW
:= sWidth
;
3655 p
.viewPortH
:= sHeight
;
3657 {$IFDEF ENABLE_HOLMES}
3658 if (p
= gPlayer1
) then
3660 g_Holmes_plrViewPos(sX
, sY
);
3661 g_Holmes_plrViewSize(sWidth
, sHeight
);
3665 renderMapInternal(-c
, -d
, true);
3667 if (gGameSettings
.GameMode
<> GM_SINGLE
) and gPlayerIndicator
then
3669 if p
.FSpectator
then
3670 e_TextureFontPrintEx(p
.GameX
+ PLAYER_RECT_CX
- 4,
3671 p
.GameY
+ PLAYER_RECT_CY
- 4,
3672 'X', gStdFont
, 255, 255, 255, 1, True);
3674 for a := 0 to High(gCollideMap) do
3675 for b := 0 to High(gCollideMap[a]) do
3678 if ByteBool(gCollideMap[a, b] and MARK_WALL) then
3680 if ByteBool(gCollideMap[a, b] and MARK_DOOR) then
3684 1: e_DrawPoint(1, b, a, 200, 200, 200);
3685 2: e_DrawPoint(1, b, a, 64, 64, 255);
3686 3: e_DrawPoint(1, b, a, 255, 0, 255);
3696 if gShowMap
then DrawMinimap(p
, _TRect(0, 0, 128, 128));
3697 if g_Debug_Player
then
3698 g_Player_DrawDebug(p
);
3702 procedure drawProfilers ();
3707 if g_profile_frame_draw
and (profileFrameDraw
<> nil) then px
:= px
-drawProfiles(px
, py
, profileFrameDraw
);
3708 if g_profile_collision
and (profMapCollision
<> nil) then begin px
:= px
-drawProfiles(px
, py
, profMapCollision
); py
-= calcProfilesHeight(profMonsLOS
); end;
3709 if g_profile_los
and (profMonsLOS
<> nil) then begin px
:= px
-drawProfiles(px
, py
, profMonsLOS
); py
-= calcProfilesHeight(profMonsLOS
); end;
3712 procedure g_Game_Draw();
3719 plView1
, plView2
: TPlayer
;
3722 if gExit
= EXIT_QUIT
then Exit
;
3724 Time
:= GetTimer() {div 1000};
3725 FPSCounter
:= FPSCounter
+1;
3726 if Time
- FPSTime
>= 1000 then
3733 if gGameOn
or (gState
= STATE_FOLD
) then
3735 if (gPlayer1
<> nil) and (gPlayer2
<> nil) then
3737 gSpectMode
:= SPECT_NONE
;
3738 if not gRevertPlayers
then
3740 plView1
:= gPlayer1
;
3741 plView2
:= gPlayer2
;
3745 plView1
:= gPlayer2
;
3746 plView2
:= gPlayer1
;
3750 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
3752 gSpectMode
:= SPECT_NONE
;
3753 if gPlayer2
= nil then
3756 plView1
:= gPlayer2
;
3765 if (plView1
= nil) and (plView2
= nil) and (gSpectMode
= SPECT_NONE
) then
3766 gSpectMode
:= SPECT_STATS
;
3768 if gSpectMode
= SPECT_PLAYERS
then
3769 if gPlayers
<> nil then
3771 plView1
:= GetActivePlayer_ByID(gSpectPID1
);
3772 if plView1
= nil then
3774 gSpectPID1
:= GetActivePlayerID_Next();
3775 plView1
:= GetActivePlayer_ByID(gSpectPID1
);
3777 if gSpectViewTwo
then
3779 plView2
:= GetActivePlayer_ByID(gSpectPID2
);
3780 if plView2
= nil then
3782 gSpectPID2
:= GetActivePlayerID_Next();
3783 plView2
:= GetActivePlayer_ByID(gSpectPID2
);
3788 if gSpectMode
= SPECT_MAPVIEW
then
3790 // Ðåæèì ïðîñìîòðà êàðòû
3792 e_SetViewPort(0, 0, gScreenWidth
, gScreenHeight
);
3793 DrawMapView(gSpectX
, gSpectY
, gScreenWidth
, gScreenHeight
);
3794 gHearPoint1
.Active
:= True;
3795 gHearPoint1
.Coords
.X
:= gScreenWidth
div 2 + gSpectX
;
3796 gHearPoint1
.Coords
.Y
:= gScreenHeight
div 2 + gSpectY
;
3797 gHearPoint2
.Active
:= False;
3801 Split
:= (plView1
<> nil) and (plView2
<> nil);
3803 // Òî÷êè ñëóõà èãðîêîâ
3804 if plView1
<> nil then
3806 gHearPoint1
.Active
:= True;
3807 gHearPoint1
.Coords
.X
:= plView1
.GameX
;
3808 gHearPoint1
.Coords
.Y
:= plView1
.GameY
;
3810 gHearPoint1
.Active
:= False;
3811 if plView2
<> nil then
3813 gHearPoint2
.Active
:= True;
3814 gHearPoint2
.Coords
.X
:= plView2
.GameX
;
3815 gHearPoint2
.Coords
.Y
:= plView2
.GameY
;
3817 gHearPoint2
.Active
:= False;
3819 // Ðàçìåð ýêðàíîâ èãðîêîâ:
3820 gPlayerScreenSize
.X
:= gScreenWidth
-196;
3823 gPlayerScreenSize
.Y
:= gScreenHeight
div 2;
3824 if gScreenHeight
mod 2 = 0 then
3825 Dec(gPlayerScreenSize
.Y
);
3828 gPlayerScreenSize
.Y
:= gScreenHeight
;
3831 if gScreenHeight
mod 2 = 0 then
3832 e_SetViewPort(0, gPlayerScreenSize
.Y
+2, gPlayerScreenSize
.X
+196, gPlayerScreenSize
.Y
)
3834 e_SetViewPort(0, gPlayerScreenSize
.Y
+1, gPlayerScreenSize
.X
+196, gPlayerScreenSize
.Y
);
3836 DrawPlayer(plView1
);
3837 gPlayer1ScreenCoord
.X
:= sX
;
3838 gPlayer1ScreenCoord
.Y
:= sY
;
3842 e_SetViewPort(0, 0, gPlayerScreenSize
.X
+196, gPlayerScreenSize
.Y
);
3844 DrawPlayer(plView2
);
3845 gPlayer2ScreenCoord
.X
:= sX
;
3846 gPlayer2ScreenCoord
.Y
:= sY
;
3849 e_SetViewPort(0, 0, gScreenWidth
, gScreenHeight
);
3852 e_DrawLine(2, 0, gScreenHeight
div 2, gScreenWidth
, gScreenHeight
div 2, 0, 0, 0);
3855 {$IFDEF ENABLE_HOLMES}
3857 if (g_holmes_enabled
) then g_Holmes_Draw();
3860 if MessageText
<> '' then
3864 e_CharFont_GetSizeFmt(gMenuFont
, MessageText
, w
, h
);
3866 e_CharFont_PrintFmt(gMenuFont
, (gScreenWidth
div 2)-(w
div 2),
3867 (gScreenHeight
div 2)-(h
div 2), MessageText
)
3869 e_CharFont_PrintFmt(gMenuFont
, (gScreenWidth
div 2)-(w
div 2),
3870 Round(gScreenHeight
/ 2.75)-(h
div 2), MessageText
);
3873 if IsDrawStat
or (gSpectMode
= 1) then DrawStat();
3875 if gSpectHUD
and (not gChatShow
) and (gSpectMode
<> SPECT_NONE
) and (not gSpectAuto
) then
3877 // Draw spectator GUI
3880 e_TextureFontGetSize(gStdFont
, ww
, hh
);
3883 e_TextureFontPrintEx(0, gScreenHeight
- (hh
+2)*2, 'MODE: Stats', gStdFont
, 255, 255, 255, 1);
3885 e_TextureFontPrintEx(0, gScreenHeight
- (hh
+2)*2, 'MODE: Observe Map', gStdFont
, 255, 255, 255, 1);
3887 e_TextureFontPrintEx(0, gScreenHeight
- (hh
+2)*2, 'MODE: Watch Players', gStdFont
, 255, 255, 255, 1);
3889 e_TextureFontPrintEx(2*ww
, gScreenHeight
- (hh
+2), '< jump >', gStdFont
, 255, 255, 255, 1);
3890 if gSpectMode
= SPECT_STATS
then
3892 e_TextureFontPrintEx(16*ww
, gScreenHeight
- (hh
+2)*2, 'Autoview', gStdFont
, 255, 255, 255, 1);
3893 e_TextureFontPrintEx(16*ww
, gScreenHeight
- (hh
+2), '< fire >', gStdFont
, 255, 255, 255, 1);
3895 if gSpectMode
= SPECT_MAPVIEW
then
3897 e_TextureFontPrintEx(22*ww
, gScreenHeight
- (hh
+2)*2, '[-]', gStdFont
, 255, 255, 255, 1);
3898 e_TextureFontPrintEx(26*ww
, gScreenHeight
- (hh
+2)*2, 'Step ' + IntToStr(gSpectStep
), gStdFont
, 255, 255, 255, 1);
3899 e_TextureFontPrintEx(34*ww
, gScreenHeight
- (hh
+2)*2, '[+]', gStdFont
, 255, 255, 255, 1);
3900 e_TextureFontPrintEx(18*ww
, gScreenHeight
- (hh
+2), '<prev weap>', gStdFont
, 255, 255, 255, 1);
3901 e_TextureFontPrintEx(30*ww
, gScreenHeight
- (hh
+2), '<next weap>', gStdFont
, 255, 255, 255, 1);
3903 if gSpectMode
= SPECT_PLAYERS
then
3905 e_TextureFontPrintEx(22*ww
, gScreenHeight
- (hh
+2)*2, 'Player 1', gStdFont
, 255, 255, 255, 1);
3906 e_TextureFontPrintEx(20*ww
, gScreenHeight
- (hh
+2), '<left/right>', gStdFont
, 255, 255, 255, 1);
3907 if gSpectViewTwo
then
3909 e_TextureFontPrintEx(37*ww
, gScreenHeight
- (hh
+2)*2, 'Player 2', gStdFont
, 255, 255, 255, 1);
3910 e_TextureFontPrintEx(34*ww
, gScreenHeight
- (hh
+2), '<prev w/next w>', gStdFont
, 255, 255, 255, 1);
3911 e_TextureFontPrintEx(52*ww
, gScreenHeight
- (hh
+2)*2, '2x View', gStdFont
, 255, 255, 255, 1);
3912 e_TextureFontPrintEx(51*ww
, gScreenHeight
- (hh
+2), '<up/down>', gStdFont
, 255, 255, 255, 1);
3916 e_TextureFontPrintEx(35*ww
, gScreenHeight
- (hh
+2)*2, '2x View', gStdFont
, 255, 255, 255, 1);
3917 e_TextureFontPrintEx(34*ww
, gScreenHeight
- (hh
+2), '<up/down>', gStdFont
, 255, 255, 255, 1);
3923 if gPauseMain
and gGameOn
and (g_ActiveWindow
= nil) then
3925 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
3926 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
3928 e_CharFont_GetSize(gMenuFont
, _lc
[I_MENU_PAUSE
], w
, h
);
3929 e_CharFont_Print(gMenuFont
, (gScreenWidth
div 2)-(w
div 2),
3930 (gScreenHeight
div 2)-(h
div 2), _lc
[I_MENU_PAUSE
]);
3935 if (gState
= STATE_MENU
) then
3937 if (g_ActiveWindow
= nil) or (g_ActiveWindow
.BackTexture
= '') then DrawMenuBackground('MENU_BACKGROUND');
3938 // F3 at menu will show game loading dialog
3939 if e_KeyPressed(IK_F3
) then g_Menu_Show_LoadMenu(true);
3940 if (g_ActiveWindow
<> nil) then
3942 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
3943 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
3947 // F3 at titlepic will show game loading dialog
3948 if e_KeyPressed(IK_F3
) then
3950 g_Menu_Show_LoadMenu(true);
3951 if (g_ActiveWindow
<> nil) then e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
3956 if gState
= STATE_FOLD
then
3958 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 0, 0, 0, EndingGameCounter
);
3961 if gState
= STATE_INTERCUSTOM
then
3963 if gLastMap
and (gGameSettings
.GameMode
= GM_COOP
) then
3965 back
:= 'TEXTURE_endpic';
3966 if not g_Texture_Get(back
, ID
) then
3967 back
:= _lc
[I_TEXTURE_ENDPIC
];
3972 DrawMenuBackground(back
);
3976 if g_ActiveWindow
<> nil then
3978 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
3979 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
3983 if gState
= STATE_INTERSINGLE
then
3985 if EndingGameCounter
> 0 then
3987 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 0, 0, 0, EndingGameCounter
);
3993 DrawMenuBackground(back
);
3997 if g_ActiveWindow
<> nil then
3999 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4000 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4005 if gState
= STATE_ENDPIC
then
4008 if not g_Texture_Get('TEXTURE_endpic', ID
) then
4009 g_Texture_Get(_lc
[I_TEXTURE_ENDPIC
], ID
);
4011 if ID
<> DWORD(-1) then
4012 e_DrawSize(ID
, 0, 0, 0, False, False, gScreenWidth
, gScreenHeight
)
4014 e_Clear(GL_COLOR_BUFFER_BIT
, 0, 0, 0);
4016 if g_ActiveWindow
<> nil then
4018 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4019 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4023 if gState
= STATE_SLIST
then
4025 // if g_Texture_Get('MENU_BACKGROUND', ID) then
4027 // e_DrawSize(ID, 0, 0, 0, False, False, gScreenWidth, gScreenHeight);
4028 // //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4030 DrawMenuBackground('MENU_BACKGROUND');
4031 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4032 g_Serverlist_Draw(slCurrent
, slTable
);
4036 if g_ActiveWindow
<> nil then
4040 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4041 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4043 g_ActiveWindow
.Draw();
4048 if g_debug_Sounds
and gGameOn
then
4050 for w
:= 0 to High(e_SoundsArray
) do
4051 for h
:= 0 to e_SoundsArray
[w
].nRefs
do
4052 e_DrawPoint(1, w
+100, h
+100, 255, 0, 0);
4057 e_TextureFontPrint(0, 0, Format('FPS: %d', [FPS
]), gStdFont
);
4058 e_TextureFontPrint(0, 16, Format('UPS: %d', [UPS
]), gStdFont
);
4061 if gGameOn
and gShowTime
then
4062 drawTime(gScreenWidth
-72, gScreenHeight
-16);
4064 if gGameOn
then drawProfilers();
4066 {$IFDEF ENABLE_HOLMES}
4073 procedure g_Game_Quit();
4075 g_Game_StopAllSounds(True);
4077 g_Game_SaveOptions();
4079 g_PlayerModel_FreeData();
4080 g_Texture_DeleteAll();
4081 g_Frames_DeleteAll();
4082 //g_Menu_Free(); //k8: this segfaults after resolution change; who cares?
4084 if NetInitDone
then g_Net_Free
;
4086 // Íàäî óäàëèòü êàðòó ïîñëå òåñòà:
4087 if gMapToDelete
<> '' then
4088 g_Game_DeleteTestMap();
4094 procedure g_FatalError(Text: String);
4096 g_Console_Add(Format(_lc
[I_FATAL_ERROR
], [Text]), True);
4097 e_WriteLog(Format(_lc
[I_FATAL_ERROR
], [Text]), TMsgType
.Warning
);
4099 gExit
:= EXIT_SIMPLE
;
4102 procedure g_SimpleError(Text: String);
4104 g_Console_Add(Format(_lc
[I_SIMPLE_ERROR
], [Text]), True);
4105 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], [Text]), TMsgType
.Warning
);
4108 procedure g_Game_SetupScreenSize();
4110 RES_FACTOR
= 4.0 / 3.0;
4116 // Ðàçìåð ýêðàíîâ èãðîêîâ:
4117 gPlayerScreenSize
.X
:= gScreenWidth
-196;
4118 if (gPlayer1
<> nil) and (gPlayer2
<> nil) then
4119 gPlayerScreenSize
.Y
:= gScreenHeight
div 2
4121 gPlayerScreenSize
.Y
:= gScreenHeight
;
4123 // Ðàçìåð çàäíåãî ïëàíà:
4124 if BackID
<> DWORD(-1) then
4127 if (gScreenWidth
*s
> gMapInfo
.Width
) or
4128 (gScreenHeight
*s
> gMapInfo
.Height
) then
4130 gBackSize
.X
:= gScreenWidth
;
4131 gBackSize
.Y
:= gScreenHeight
;
4135 e_GetTextureSize(BackID
, @bw
, @bh
);
4136 rf
:= Single(bw
) / Single(bh
);
4137 if (rf
> RES_FACTOR
) then bw
:= Round(Single(bh
) * RES_FACTOR
)
4138 else if (rf
< RES_FACTOR
) then bh
:= Round(Single(bw
) / RES_FACTOR
);
4139 s
:= Max(gScreenWidth
/ bw
, gScreenHeight
/ bh
);
4140 if (s
< 1.0) then s
:= 1.0;
4141 gBackSize
.X
:= Round(bw
*s
);
4142 gBackSize
.Y
:= Round(bh
*s
);
4147 procedure g_Game_ChangeResolution(newWidth
, newHeight
: Word; nowFull
, nowMax
: Boolean);
4149 g_Window_SetSize(newWidth
, newHeight
, nowFull
);
4152 procedure g_Game_AddPlayer(Team
: Byte = TEAM_NONE
);
4154 if ((not gGameOn
) and (gState
<> STATE_INTERCUSTOM
))
4155 or (not (gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
])) then
4157 if gPlayer1
= nil then
4159 if g_Game_IsClient
then
4161 if NetPlrUID1
> -1 then
4163 MC_SEND_CheatRequest(NET_CHEAT_SPECTATE
);
4164 gPlayer1
:= g_Player_Get(NetPlrUID1
);
4169 if not (Team
in [TEAM_RED
, TEAM_BLUE
]) then
4170 Team
:= gPlayer1Settings
.Team
;
4172 // Ñîçäàíèå ïåðâîãî èãðîêà:
4173 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4174 gPlayer1Settings
.Color
,
4176 if gPlayer1
= nil then
4177 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]))
4180 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4181 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [gPlayer1
.Name
]), True);
4182 if g_Game_IsServer
and g_Game_IsNet
then
4183 MH_SEND_PlayerCreate(gPlayer1
.UID
);
4184 gPlayer1
.Respawn(False, True);
4186 if g_Game_IsNet
and NetUseMaster
then
4192 if gPlayer2
= nil then
4194 if g_Game_IsClient
then
4196 if NetPlrUID2
> -1 then
4197 gPlayer2
:= g_Player_Get(NetPlrUID2
);
4201 if not (Team
in [TEAM_RED
, TEAM_BLUE
]) then
4202 Team
:= gPlayer2Settings
.Team
;
4204 // Ñîçäàíèå âòîðîãî èãðîêà:
4205 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
4206 gPlayer2Settings
.Color
,
4208 if gPlayer2
= nil then
4209 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]))
4212 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
4213 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [gPlayer2
.Name
]), True);
4214 if g_Game_IsServer
and g_Game_IsNet
then
4215 MH_SEND_PlayerCreate(gPlayer2
.UID
);
4216 gPlayer2
.Respawn(False, True);
4218 if g_Game_IsNet
and NetUseMaster
then
4226 procedure g_Game_RemovePlayer();
4230 if ((not gGameOn
) and (gState
<> STATE_INTERCUSTOM
))
4231 or (not (gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
])) then
4236 if g_Game_IsServer
then
4239 Pl
.Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
4240 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [Pl
.Name
]), True);
4241 g_Player_Remove(Pl
.UID
);
4243 if g_Game_IsNet
and NetUseMaster
then
4252 if g_Game_IsServer
then
4255 Pl
.Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
4256 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [Pl
.Name
]), True);
4257 g_Player_Remove(Pl
.UID
);
4259 if g_Game_IsNet
and NetUseMaster
then
4264 MC_SEND_CheatRequest(NET_CHEAT_SPECTATE
);
4270 procedure g_Game_Spectate();
4272 g_Game_RemovePlayer();
4273 if gPlayer1
<> nil then
4274 g_Game_RemovePlayer();
4277 procedure g_Game_SpectateCenterView();
4279 gSpectX
:= Max(gMapInfo
.Width
div 2 - gScreenWidth
div 2, 0);
4280 gSpectY
:= Max(gMapInfo
.Height
div 2 - gScreenHeight
div 2, 0);
4283 procedure g_Game_StartSingle(Map
: String; TwoPlayers
: Boolean; nPlayers
: Byte);
4290 e_WriteLog('Starting singleplayer game...', TMsgType
.Notify
);
4292 g_Game_ClearLoading();
4295 FillByte(gGameSettings
, SizeOf(TGameSettings
), 0);
4298 gGameSettings
.GameType
:= GT_SINGLE
;
4299 gGameSettings
.MaxLives
:= 0;
4300 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_ALLOWEXIT
;
4301 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_MONSTERS
;
4302 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_BOTVSMONSTER
;
4303 gSwitchGameMode
:= GM_SINGLE
;
4305 g_Game_ExecuteEvent('ongamestart');
4307 // Óñòàíîâêà ðàçìåðîâ îêîí èãðîêîâ:
4308 g_Game_SetupScreenSize();
4310 // Ñîçäàíèå ïåðâîãî èãðîêà:
4311 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4312 gPlayer1Settings
.Color
,
4313 gPlayer1Settings
.Team
, False));
4314 if gPlayer1
= nil then
4316 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
4320 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4323 // Ñîçäàíèå âòîðîãî èãðîêà, åñëè åñòü:
4326 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
4327 gPlayer2Settings
.Color
,
4328 gPlayer2Settings
.Team
, False));
4329 if gPlayer2
= nil then
4331 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
4335 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
4339 // Çàãðóçêà è çàïóñê êàðòû:
4340 if not g_Game_StartMap(MAP
, True) then
4342 if (Pos(':\', Map
) > 0) or (Pos(':/', Map
) > 0) then tmps
:= Map
else tmps
:= gGameSettings
.WAD
+ ':\' + MAP
;
4343 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [tmps
]));
4347 // Íàñòðîéêè èãðîêîâ è áîòîâ:
4351 for i
:= nPl
+1 to nPlayers
do
4352 g_Player_Create(STD_PLAYER_MODEL
, _RGB(0, 0, 0), 0, True);
4355 procedure g_Game_StartCustom(Map
: String; GameMode
: Byte;
4356 TimeLimit
, GoalLimit
: Word;
4358 Options
: LongWord; nPlayers
: Byte);
4364 e_WriteLog('Starting custom game...', TMsgType
.Notify
);
4366 g_Game_ClearLoading();
4369 gGameSettings
.GameType
:= GT_CUSTOM
;
4370 gGameSettings
.GameMode
:= GameMode
;
4371 gSwitchGameMode
:= GameMode
;
4372 gGameSettings
.TimeLimit
:= TimeLimit
;
4373 gGameSettings
.GoalLimit
:= GoalLimit
;
4374 gGameSettings
.MaxLives
:= IfThen(GameMode
= GM_CTF
, 0, MaxLives
);
4375 gGameSettings
.Options
:= Options
;
4377 gCoopTotalMonstersKilled
:= 0;
4378 gCoopTotalSecretsFound
:= 0;
4379 gCoopTotalMonsters
:= 0;
4380 gCoopTotalSecrets
:= 0;
4384 g_Game_ExecuteEvent('ongamestart');
4386 // Óñòàíîâêà ðàçìåðîâ îêîí èãðîêîâ:
4387 g_Game_SetupScreenSize();
4389 // Ðåæèì íàáëþäàòåëÿ:
4390 if nPlayers
= 0 then
4397 if nPlayers
>= 1 then
4399 // Ñîçäàíèå ïåðâîãî èãðîêà:
4400 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4401 gPlayer1Settings
.Color
,
4402 gPlayer1Settings
.Team
, False));
4403 if gPlayer1
= nil then
4405 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
4409 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4413 if nPlayers
>= 2 then
4415 // Ñîçäàíèå âòîðîãî èãðîêà:
4416 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
4417 gPlayer2Settings
.Color
,
4418 gPlayer2Settings
.Team
, False));
4419 if gPlayer2
= nil then
4421 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
4425 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
4429 // Çàãðóçêà è çàïóñê êàðòû:
4430 if not g_Game_StartMap(Map
, True) then
4432 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [Map
]));
4436 // Íåò òî÷åê ïîÿâëåíèÿ:
4437 if (g_Map_GetPointCount(RESPAWNPOINT_PLAYER1
) +
4438 g_Map_GetPointCount(RESPAWNPOINT_PLAYER2
) +
4439 g_Map_GetPointCount(RESPAWNPOINT_DM
) +
4440 g_Map_GetPointCount(RESPAWNPOINT_RED
)+
4441 g_Map_GetPointCount(RESPAWNPOINT_BLUE
)) < 1 then
4443 g_FatalError(_lc
[I_GAME_ERROR_GET_SPAWN
]);
4447 // Íàñòðîéêè èãðîêîâ è áîòîâ:
4451 for i
:= nPl
+1 to nPlayers
do
4452 g_Player_Create(STD_PLAYER_MODEL
, _RGB(0, 0, 0), 0, True);
4455 procedure g_Game_StartServer(Map
: String; GameMode
: Byte;
4456 TimeLimit
, GoalLimit
: Word; MaxLives
: Byte;
4457 Options
: LongWord; nPlayers
: Byte;
4458 IPAddr
: LongWord; Port
: Word);
4462 e_WriteLog('Starting net game (server)...', TMsgType
.Notify
);
4464 g_Game_ClearLoading();
4467 gGameSettings
.GameType
:= GT_SERVER
;
4468 gGameSettings
.GameMode
:= GameMode
;
4469 gSwitchGameMode
:= GameMode
;
4470 gGameSettings
.TimeLimit
:= TimeLimit
;
4471 gGameSettings
.GoalLimit
:= GoalLimit
;
4472 gGameSettings
.MaxLives
:= IfThen(GameMode
= GM_CTF
, 0, MaxLives
);
4473 gGameSettings
.Options
:= Options
;
4475 gCoopTotalMonstersKilled
:= 0;
4476 gCoopTotalSecretsFound
:= 0;
4477 gCoopTotalMonsters
:= 0;
4478 gCoopTotalSecrets
:= 0;
4482 g_Game_ExecuteEvent('ongamestart');
4484 // Óñòàíîâêà ðàçìåðîâ îêíà èãðîêà
4485 g_Game_SetupScreenSize();
4487 // Ðåæèì íàáëþäàòåëÿ:
4488 if nPlayers
= 0 then
4494 if nPlayers
>= 1 then
4496 // Ñîçäàíèå ïåðâîãî èãðîêà:
4497 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4498 gPlayer1Settings
.Color
,
4499 gPlayer1Settings
.Team
, False));
4500 if gPlayer1
= nil then
4502 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
4506 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4509 if nPlayers
>= 2 then
4511 // Ñîçäàíèå âòîðîãî èãðîêà:
4512 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
4513 gPlayer2Settings
.Color
,
4514 gPlayer2Settings
.Team
, False));
4515 if gPlayer2
= nil then
4517 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
4521 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
4524 g_Game_SetLoadingText(_lc
[I_LOAD_HOST
], 0, False);
4525 if NetForwardPorts
then
4526 g_Game_SetLoadingText(_lc
[I_LOAD_PORTS
], 0, False);
4529 if not g_Net_Host(IPAddr
, Port
, NetMaxClients
) then
4531 g_FatalError(_lc
[I_NET_MSG
] + _lc
[I_NET_ERR_HOST
]);
4535 g_Net_Slist_Set(NetSlistIP
, NetSlistPort
);
4537 // Çàãðóçêà è çàïóñê êàðòû:
4538 if not g_Game_StartMap(Map
, True) then
4540 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [Map
]));
4544 // Íåò òî÷åê ïîÿâëåíèÿ:
4545 if (g_Map_GetPointCount(RESPAWNPOINT_PLAYER1
) +
4546 g_Map_GetPointCount(RESPAWNPOINT_PLAYER2
) +
4547 g_Map_GetPointCount(RESPAWNPOINT_DM
) +
4548 g_Map_GetPointCount(RESPAWNPOINT_RED
)+
4549 g_Map_GetPointCount(RESPAWNPOINT_BLUE
)) < 1 then
4551 g_FatalError(_lc
[I_GAME_ERROR_GET_SPAWN
]);
4555 // Íàñòðîéêè èãðîêîâ è áîòîâ:
4558 NetState
:= NET_STATE_GAME
;
4561 procedure g_Game_StartClient(Addr
: String; Port
: Word; PW
: String);
4576 e_WriteLog('Starting net game (client)...', TMsgType
.Notify
);
4577 e_WriteLog('NET: Trying to connect to ' + Addr
+ ':' + IntToStr(Port
) + '...', TMsgType
.Notify
);
4579 g_Game_ClearLoading();
4582 gGameSettings
.GameType
:= GT_CLIENT
;
4584 gCoopTotalMonstersKilled
:= 0;
4585 gCoopTotalSecretsFound
:= 0;
4586 gCoopTotalMonsters
:= 0;
4587 gCoopTotalSecrets
:= 0;
4591 g_Game_ExecuteEvent('ongamestart');
4593 // Óñòàíîâêà ðàçìåðîâ îêîí èãðîêîâ:
4594 g_Game_SetupScreenSize();
4596 NetState
:= NET_STATE_AUTH
;
4598 g_Game_SetLoadingText(_lc
[I_LOAD_CONNECT
], 0, False);
4600 if not g_Net_Connect(Addr
, Port
) then
4602 g_FatalError(_lc
[I_NET_MSG
] + _lc
[I_NET_ERR_CONN
]);
4603 NetState
:= NET_STATE_NONE
;
4607 g_Game_SetLoadingText(_lc
[I_LOAD_SEND_INFO
], 0, False);
4609 g_Game_SetLoadingText(_lc
[I_LOAD_WAIT_INFO
], 0, False);
4614 while (enet_host_service(NetHost
, @NetEvent
, 0) > 0) do
4616 if (NetEvent
.kind
= ENET_EVENT_TYPE_RECEIVE
) then
4618 Ptr
:= NetEvent
.packet
^.data
;
4619 if not InMsg
.Init(Ptr
, NetEvent
.packet
^.dataLength
, True) then
4622 MID
:= InMsg
.ReadByte();
4624 if (MID
= NET_MSG_INFO
) and (State
= 0) then
4626 NetMyID
:= InMsg
.ReadByte();
4627 NetPlrUID1
:= InMsg
.ReadWord();
4629 WadName
:= InMsg
.ReadString();
4630 Map
:= InMsg
.ReadString();
4632 gWADHash
:= InMsg
.ReadMD5();
4634 gGameSettings
.GameMode
:= InMsg
.ReadByte();
4635 gSwitchGameMode
:= gGameSettings
.GameMode
;
4636 gGameSettings
.GoalLimit
:= InMsg
.ReadWord();
4637 gGameSettings
.TimeLimit
:= InMsg
.ReadWord();
4638 gGameSettings
.MaxLives
:= InMsg
.ReadByte();
4639 gGameSettings
.Options
:= InMsg
.ReadLongWord();
4640 T
:= InMsg
.ReadLongWord();
4642 newResPath
:= g_Res_SearchSameWAD(MapsDir
, WadName
, gWADHash
);
4643 if newResPath
= '' then
4645 g_Game_SetLoadingText(_lc
[I_LOAD_DL_RES
], 0, False);
4646 newResPath
:= g_Res_DownloadWAD(WadName
);
4647 if newResPath
= '' then
4649 g_FatalError(_lc
[I_NET_ERR_HASH
]);
4650 enet_packet_destroy(NetEvent
.packet
);
4651 NetState
:= NET_STATE_NONE
;
4655 newResPath
:= ExtractRelativePath(MapsDir
, newResPath
);
4657 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4658 gPlayer1Settings
.Color
,
4659 gPlayer1Settings
.Team
, False));
4661 if gPlayer1
= nil then
4663 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
4665 enet_packet_destroy(NetEvent
.packet
);
4666 NetState
:= NET_STATE_NONE
;
4670 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4671 gPlayer1
.UID
:= NetPlrUID1
;
4672 gPlayer1
.Reset(True);
4674 if not g_Game_StartMap(newResPath
+ ':\' + Map
, True) then
4676 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [WadName
+ ':\' + Map
]));
4678 enet_packet_destroy(NetEvent
.packet
);
4679 NetState
:= NET_STATE_NONE
;
4687 enet_packet_destroy(NetEvent
.packet
);
4691 enet_packet_destroy(NetEvent
.packet
);
4695 if (NetEvent
.kind
= ENET_EVENT_TYPE_DISCONNECT
) then
4698 if (NetEvent
.data
<= NET_DISC_MAX
) then
4699 g_Console_Add(_lc
[I_NET_MSG_ERROR
] + _lc
[I_NET_ERR_CONN
] + ' ' +
4700 _lc
[TStrings_Locale(Cardinal(I_NET_DISC_NONE
) + NetEvent
.data
)], True);
4707 ProcessLoading(true);
4709 if e_KeyPressed(IK_SPACE
) or e_KeyPressed(IK_ESCAPE
) or e_KeyPressed(VK_ESCAPE
) or
4710 e_KeyPressed(JOY0_JUMP
) or e_KeyPressed(JOY1_JUMP
) or e_KeyPressed(JOY2_JUMP
) or e_KeyPressed(JOY3_JUMP
) then
4719 g_FatalError(_lc
[I_NET_MSG
] + _lc
[I_NET_ERR_CONN
]);
4720 NetState
:= NET_STATE_NONE
;
4724 gLMSRespawn
:= LMS_RESPAWN_NONE
;
4725 gLMSRespawnTime
:= 0;
4728 NetState
:= NET_STATE_GAME
;
4729 MC_SEND_FullStateRequest
;
4730 e_WriteLog('NET: Connection successful.', TMsgType
.Notify
);
4733 procedure g_Game_SaveOptions();
4735 g_Options_Write_Video(GameDir
+'/'+CONFIG_FILENAME
);
4738 procedure g_Game_ChangeMap(const MapPath
: String);
4742 g_Game_ClearLoading();
4744 Force
:= gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
];
4745 // Åñëè óðîâåíü çàâåðøèëñÿ ïî òðèããåðó Âûõîä, íå î÷èùàòü èíâåíòàðü
4746 if gExitByTrigger
then
4749 gExitByTrigger
:= False;
4751 if not g_Game_StartMap(MapPath
, Force
) then
4752 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [MapPath
]));
4755 procedure g_Game_Restart();
4759 if g_Game_IsClient
then
4761 map
:= g_ExtractFileName(gMapInfo
.Map
);
4765 g_Game_ClearLoading();
4766 g_Game_StartMap(Map
, True, gCurrentMapFileName
);
4769 function g_Game_StartMap(Map
: String; Force
: Boolean = False; const oldMapPath
: AnsiString=''): Boolean;
4771 NewWAD
, ResName
: String;
4774 g_Map_Free((Map
<> gCurrentMapFileName
) and (oldMapPath
<> gCurrentMapFileName
));
4775 g_Player_RemoveAllCorpses();
4777 if (not g_Game_IsClient
) and
4778 (gSwitchGameMode
<> gGameSettings
.GameMode
) and
4779 (gGameSettings
.GameMode
<> GM_SINGLE
) then
4781 if gSwitchGameMode
= GM_CTF
then
4782 gGameSettings
.MaxLives
:= 0;
4783 gGameSettings
.GameMode
:= gSwitchGameMode
;
4786 gSwitchGameMode
:= gGameSettings
.GameMode
;
4788 g_Player_ResetTeams();
4790 if isWadPath(Map
) then
4792 NewWAD
:= g_ExtractWadName(Map
);
4793 ResName
:= g_ExtractFileName(Map
);
4794 if g_Game_IsServer
then
4796 gWADHash
:= MD5File(MapsDir
+ NewWAD
);
4797 g_Game_LoadWAD(NewWAD
);
4799 // hash received in MC_RECV_GameEvent -> NET_EV_MAPSTART
4800 g_Game_ClientWAD(NewWAD
, gWADHash
);
4804 Result
:= g_Map_Load(MapsDir
+ gGameSettings
.WAD
+ ':\' + ResName
);
4807 g_Player_ResetAll(Force
or gLastMap
, gGameSettings
.GameType
= GT_SINGLE
);
4809 gState
:= STATE_NONE
;
4810 g_ActiveWindow
:= nil;
4816 if gGameSettings
.GameMode
= GM_CTF
then
4818 g_Map_ResetFlag(FLAG_RED
);
4819 g_Map_ResetFlag(FLAG_BLUE
);
4820 // CTF, à ôëàãîâ íåò:
4821 if not g_Map_HaveFlagPoints() then
4822 g_SimpleError(_lc
[I_GAME_ERROR_CTF
]);
4827 gState
:= STATE_MENU
;
4832 gPauseMain
:= false;
4833 gPauseHolmes
:= false;
4835 NetTimeToUpdate
:= 1;
4836 NetTimeToReliable
:= 0;
4837 NetTimeToMaster
:= NetMasterRate
;
4838 gLMSRespawn
:= LMS_RESPAWN_NONE
;
4839 gLMSRespawnTime
:= 0;
4840 gMissionFailed
:= False;
4843 gCoopMonstersKilled
:= 0;
4844 gCoopSecretsFound
:= 0;
4846 gVoteInProgress
:= False;
4847 gVotePassed
:= False;
4853 if not gGameOn
then Exit
;
4855 g_Game_SpectateCenterView();
4857 if (gGameSettings
.MaxLives
> 0) and (gGameSettings
.WarmupTime
> 0) then
4859 gLMSRespawn
:= LMS_RESPAWN_WARMUP
;
4860 gLMSRespawnTime
:= gTime
+ gGameSettings
.WarmupTime
*1000;
4861 gLMSSoftSpawn
:= True;
4862 if NetMode
= NET_SERVER
then
4863 MH_SEND_GameEvent(NET_EV_LMS_WARMUP
, (gLMSRespawnTime
- gTime
) div 1000)
4865 g_Console_Add(Format(_lc
[I_MSG_WARMUP_START
], [(gLMSRespawnTime
- gTime
) div 1000]), True);
4868 if NetMode
= NET_SERVER
then
4870 MH_SEND_GameEvent(NET_EV_MAPSTART
, gGameSettings
.GameMode
, Map
);
4873 if NetUseMaster
then
4875 if (NetMHost
= nil) or (NetMPeer
= nil) then
4876 if not g_Net_Slist_Connect
then
4877 g_Console_Add(_lc
[I_NET_MSG_ERROR
] + _lc
[I_NET_SLIST_ERROR
]);
4882 if NetClients
<> nil then
4883 for I
:= 0 to High(NetClients
) do
4884 if NetClients
[I
].Used
then
4886 NetClients
[I
].Voted
:= False;
4887 if NetClients
[I
].RequestedFullUpdate
then
4889 MH_SEND_Everything((NetClients
[I
].State
= NET_STATE_AUTH
), I
);
4890 NetClients
[I
].RequestedFullUpdate
:= False;
4894 g_Net_UnbanNonPermHosts();
4899 gCoopTotalMonstersKilled
:= 0;
4900 gCoopTotalSecretsFound
:= 0;
4901 gCoopTotalMonsters
:= 0;
4902 gCoopTotalSecrets
:= 0;
4906 g_Game_ExecuteEvent('onmapstart');
4909 procedure SetFirstLevel();
4913 MapList
:= g_Map_GetMapsList(MapsDir
+ gGameSettings
.WAD
);
4914 if MapList
= nil then
4917 SortSArray(MapList
);
4918 gNextMap
:= MapList
[Low(MapList
)];
4923 procedure g_Game_ExitLevel(const Map
: AnsiString);
4927 gCoopTotalMonstersKilled
:= gCoopTotalMonstersKilled
+ gCoopMonstersKilled
;
4928 gCoopTotalSecretsFound
:= gCoopTotalSecretsFound
+ gCoopSecretsFound
;
4929 gCoopTotalMonsters
:= gCoopTotalMonsters
+ gTotalMonsters
;
4930 gCoopTotalSecrets
:= gCoopTotalSecrets
+ gSecretsCount
;
4932 // Âûøëè â âûõîä â Îäèíî÷íîé èãðå:
4933 if gGameSettings
.GameType
= GT_SINGLE
then
4934 gExit
:= EXIT_ENDLEVELSINGLE
4935 else // Âûøëè â âûõîä â Ñâîåé èãðå
4937 gExit
:= EXIT_ENDLEVELCUSTOM
;
4938 if gGameSettings
.GameMode
= GM_COOP
then
4939 g_Player_RememberAll
;
4941 if not g_Map_Exist(MapsDir
+ gGameSettings
.WAD
+ ':\' + gNextMap
) then
4944 if gGameSettings
.GameMode
= GM_COOP
then
4947 gStatsPressed
:= True;
4948 gNextMap
:= 'MAP01';
4950 if not g_Map_Exist(MapsDir
+ gGameSettings
.WAD
+ ':\' + gNextMap
) then
4953 if g_Game_IsNet
then
4955 MH_SEND_GameStats();
4956 MH_SEND_CoopStats();
4962 procedure g_Game_RestartLevel();
4966 if gGameSettings
.GameMode
= GM_SINGLE
then
4971 gExit
:= EXIT_ENDLEVELCUSTOM
;
4972 Map
:= g_ExtractFileName(gMapInfo
.Map
);
4976 procedure g_Game_ClientWAD(NewWAD
: String; WHash
: TMD5Digest
);
4980 if LowerCase(NewWAD
) = LowerCase(gGameSettings
.WAD
) then
4982 if not g_Game_IsClient
then
4984 gWAD
:= g_Res_SearchSameWAD(MapsDir
, ExtractFileName(NewWAD
), WHash
);
4987 g_Game_SetLoadingText(_lc
[I_LOAD_DL_RES
], 0, False);
4988 gWAD
:= g_Res_DownloadWAD(ExtractFileName(NewWAD
));
4992 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_WAD
], [ExtractFileName(NewWAD
)]));
4996 NewWAD
:= ExtractRelativePath(MapsDir
, gWAD
);
4997 g_Game_LoadWAD(NewWAD
);
5000 procedure g_Game_RestartRound(NoMapRestart
: Boolean = False);
5002 i
, n
, nb
, nr
: Integer;
5004 function monRespawn (mon
: TMonster
): Boolean;
5006 result
:= false; // don't stop
5007 if not mon
.FNoRespawn
then mon
.Respawn();
5011 if not g_Game_IsServer
then Exit
;
5012 if gLMSRespawn
= LMS_RESPAWN_NONE
then Exit
;
5013 gLMSRespawn
:= LMS_RESPAWN_NONE
;
5014 gLMSRespawnTime
:= 0;
5017 if (gGameSettings
.GameMode
= GM_COOP
) and not NoMapRestart
then
5019 gMissionFailed
:= True;
5020 g_Game_RestartLevel
;
5024 n
:= 0; nb
:= 0; nr
:= 0;
5025 for i
:= Low(gPlayers
) to High(gPlayers
) do
5026 if (gPlayers
[i
] <> nil) and
5027 ((not gPlayers
[i
].FSpectator
) or gPlayers
[i
].FWantsInGame
or
5028 (gPlayers
[i
] is TBot
)) then
5031 if gPlayers
[i
].Team
= TEAM_RED
then Inc(nr
)
5032 else if gPlayers
[i
].Team
= TEAM_BLUE
then Inc(nb
)
5035 if (n
< 2) or ((gGameSettings
.GameMode
= GM_TDM
) and ((nr
= 0) or (nb
= 0))) then
5037 // wait a second until the fuckers finally decide to join
5038 gLMSRespawn
:= LMS_RESPAWN_WARMUP
;
5039 gLMSRespawnTime
:= gTime
+ 1000;
5040 gLMSSoftSpawn
:= NoMapRestart
;
5044 g_Player_RemoveAllCorpses
;
5045 g_Game_Message(_lc
[I_MESSAGE_LMS_START
], 144);
5046 if g_Game_IsNet
then
5047 MH_SEND_GameEvent(NET_EV_LMS_START
);
5049 for i
:= Low(gPlayers
) to High(gPlayers
) do
5051 if gPlayers
[i
] = nil then continue
;
5052 if gPlayers
[i
] is TBot
then gPlayers
[i
].FWantsInGame
:= True;
5053 // don't touch normal spectators
5054 if gPlayers
[i
].FSpectator
and not gPlayers
[i
].FWantsInGame
then
5056 gPlayers
[i
].FNoRespawn
:= True;
5057 gPlayers
[i
].Lives
:= 0;
5058 if g_Game_IsNet
then
5059 MH_SEND_PlayerStats(gPlayers
[I
].UID
);
5062 gPlayers
[i
].FNoRespawn
:= False;
5063 gPlayers
[i
].Lives
:= gGameSettings
.MaxLives
;
5064 gPlayers
[i
].Respawn(False, True);
5065 if gGameSettings
.GameMode
= GM_COOP
then
5067 gPlayers
[i
].Frags
:= 0;
5068 gPlayers
[i
].RecallState
;
5070 if (gPlayer1
= nil) and (gLMSPID1
> 0) then
5071 gPlayer1
:= g_Player_Get(gLMSPID1
);
5072 if (gPlayer2
= nil) and (gLMSPID2
> 0) then
5073 gPlayer2
:= g_Player_Get(gLMSPID2
);
5076 g_Items_RestartRound();
5079 g_Mons_ForEach(monRespawn
);
5081 gLMSSoftSpawn
:= False;
5084 function g_Game_GetFirstMap(WAD
: String): String;
5088 MapList
:= g_Map_GetMapsList(WAD
);
5089 if MapList
= nil then
5092 SortSArray(MapList
);
5093 Result
:= MapList
[Low(MapList
)];
5095 if not g_Map_Exist(WAD
+ ':\' + Result
) then
5101 function g_Game_GetNextMap(): String;
5108 MapList
:= g_Map_GetMapsList(MapsDir
+ gGameSettings
.WAD
);
5109 if MapList
= nil then
5112 Map
:= g_ExtractFileName(gMapInfo
.Map
);
5114 SortSArray(MapList
);
5116 for I
:= Low(MapList
) to High(MapList
) do
5117 if Map
= MapList
[I
] then
5123 if MapIndex
<> -255 then
5125 if MapIndex
= High(MapList
) then
5126 Result
:= MapList
[Low(MapList
)]
5128 Result
:= MapList
[MapIndex
+ 1];
5130 if not g_Map_Exist(MapsDir
+ gGameSettings
.WAD
+ ':\' + Result
) then Result
:= Map
;
5136 procedure g_Game_NextLevel();
5138 if gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
, GM_COOP
] then
5139 gExit
:= EXIT_ENDLEVELCUSTOM
5142 gExit
:= EXIT_ENDLEVELSINGLE
;
5146 if gNextMap
<> '' then Exit
;
5147 gNextMap
:= g_Game_GetNextMap();
5150 function g_Game_IsTestMap(): Boolean;
5152 result
:= StrEquCI1251(TEST_MAP_NAME
, g_ExtractFileName(gMapInfo
.Map
));
5155 procedure g_Game_DeleteTestMap();
5158 //MapName: AnsiString;
5166 a
:= Pos('.wad:\', toLowerCase1251(gMapToDelete
));
5167 if (a
= 0) then a
:= Pos('.wad:/', toLowerCase1251(gMapToDelete
));
5168 if (a
= 0) then exit
;
5170 // Âûäåëÿåì èìÿ wad-ôàéëà è èìÿ êàðòû
5171 WadName
:= Copy(gMapToDelete
, 1, a
+3);
5172 Delete(gMapToDelete
, 1, a
+5);
5173 gMapToDelete
:= UpperCase(gMapToDelete
);
5175 //CopyMemory(@MapName[0], @gMapToDelete[1], Min(16, Length(gMapToDelete)));
5178 // Èìÿ êàðòû íå ñòàíäàðòíîå òåñòîâîå:
5179 if MapName <> TEST_MAP_NAME then
5182 if not gTempDelete then
5184 time := g_GetFileTime(WadName);
5185 WAD := TWADFile.Create();
5188 if not WAD.ReadFile(WadName) then
5189 begin // Íåò òàêîãî WAD-ôàéëà
5194 // Ñîñòàâëÿåì ñïèñîê êàðò è èùåì íóæíóþ:
5196 MapList := WAD.GetResourcesList('');
5198 if MapList <> nil then
5199 for a := 0 to High(MapList) do
5200 if MapList[a] = MapName then
5202 // Óäàëÿåì è ñîõðàíÿåì:
5203 WAD.RemoveResource('', MapName);
5204 WAD.SaveTo(WadName);
5209 g_SetFileTime(WadName, time);
5212 if gTempDelete
then DeleteFile(WadName
);
5215 procedure GameCVars(P
: SSArray
);
5218 stat
: TPlayerStatArray
;
5223 cmd
:= LowerCase(P
[0]);
5224 if (cmd
= 'g_friendlyfire') and not g_Game_IsClient
then
5226 with gGameSettings
do
5228 if (Length(P
) > 1) and
5229 ((P
[1] = '1') or (P
[1] = '0')) then
5231 if (P
[1][1] = '1') then
5232 Options
:= Options
or GAME_OPTION_TEAMDAMAGE
5234 Options
:= Options
and (not GAME_OPTION_TEAMDAMAGE
);
5237 if (LongBool(Options
and GAME_OPTION_TEAMDAMAGE
)) then
5238 g_Console_Add(_lc
[I_MSG_FRIENDLY_FIRE_ON
])
5240 g_Console_Add(_lc
[I_MSG_FRIENDLY_FIRE_OFF
]);
5242 if g_Game_IsNet
then MH_SEND_GameSettings
;
5245 else if (cmd
= 'g_weaponstay') and not g_Game_IsClient
then
5247 with gGameSettings
do
5249 if (Length(P
) > 1) and
5250 ((P
[1] = '1') or (P
[1] = '0')) then
5252 if (P
[1][1] = '1') then
5253 Options
:= Options
or GAME_OPTION_WEAPONSTAY
5255 Options
:= Options
and (not GAME_OPTION_WEAPONSTAY
);
5258 if (LongBool(Options
and GAME_OPTION_WEAPONSTAY
)) then
5259 g_Console_Add(_lc
[I_MSG_WEAPONSTAY_ON
])
5261 g_Console_Add(_lc
[I_MSG_WEAPONSTAY_OFF
]);
5263 if g_Game_IsNet
then MH_SEND_GameSettings
;
5266 else if cmd
= 'g_gamemode' then
5268 a
:= g_Game_TextToMode(P
[1]);
5269 if a
= GM_SINGLE
then a
:= GM_COOP
;
5270 if (Length(P
) > 1) and (a
<> GM_NONE
) and (not g_Game_IsClient
) then
5272 gSwitchGameMode
:= a
;
5273 if (gGameOn
and (gGameSettings
.GameMode
= GM_SINGLE
)) or
5274 (gState
= STATE_INTERSINGLE
) then
5275 gSwitchGameMode
:= GM_SINGLE
;
5277 gGameSettings
.GameMode
:= gSwitchGameMode
;
5279 if gSwitchGameMode
= gGameSettings
.GameMode
then
5280 g_Console_Add(Format(_lc
[I_MSG_GAMEMODE_CURRENT
],
5281 [g_Game_ModeToText(gGameSettings
.GameMode
)]))
5283 g_Console_Add(Format(_lc
[I_MSG_GAMEMODE_CHANGE
],
5284 [g_Game_ModeToText(gGameSettings
.GameMode
),
5285 g_Game_ModeToText(gSwitchGameMode
)]));
5287 else if (cmd
= 'g_allow_exit') and not g_Game_IsClient
then
5289 with gGameSettings
do
5291 if (Length(P
) > 1) and
5292 ((P
[1] = '1') or (P
[1] = '0')) then
5294 if (P
[1][1] = '1') then
5295 Options
:= Options
or GAME_OPTION_ALLOWEXIT
5297 Options
:= Options
and (not GAME_OPTION_ALLOWEXIT
);
5300 if (LongBool(Options
and GAME_OPTION_ALLOWEXIT
)) then
5301 g_Console_Add(_lc
[I_MSG_ALLOWEXIT_ON
])
5303 g_Console_Add(_lc
[I_MSG_ALLOWEXIT_OFF
]);
5304 g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
5306 if g_Game_IsNet
then MH_SEND_GameSettings
;
5309 else if (cmd
= 'g_allow_monsters') and not g_Game_IsClient
then
5311 with gGameSettings
do
5313 if (Length(P
) > 1) and
5314 ((P
[1] = '1') or (P
[1] = '0')) then
5316 if (P
[1][1] = '1') then
5317 Options
:= Options
or GAME_OPTION_MONSTERS
5319 Options
:= Options
and (not GAME_OPTION_MONSTERS
);
5322 if (LongBool(Options
and GAME_OPTION_MONSTERS
)) then
5323 g_Console_Add(_lc
[I_MSG_ALLOWMON_ON
])
5325 g_Console_Add(_lc
[I_MSG_ALLOWMON_OFF
]);
5326 g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
5328 if g_Game_IsNet
then MH_SEND_GameSettings
;
5331 else if (cmd
= 'g_bot_vsplayers') and not g_Game_IsClient
then
5333 with gGameSettings
do
5335 if (Length(P
) > 1) and
5336 ((P
[1] = '1') or (P
[1] = '0')) then
5338 if (P
[1][1] = '1') then
5339 Options
:= Options
or GAME_OPTION_BOTVSPLAYER
5341 Options
:= Options
and (not GAME_OPTION_BOTVSPLAYER
);
5344 if (LongBool(Options
and GAME_OPTION_BOTVSPLAYER
)) then
5345 g_Console_Add(_lc
[I_MSG_BOTSVSPLAYERS_ON
])
5347 g_Console_Add(_lc
[I_MSG_BOTSVSPLAYERS_OFF
]);
5349 if g_Game_IsNet
then MH_SEND_GameSettings
;
5352 else if (cmd
= 'g_bot_vsmonsters') and not g_Game_IsClient
then
5354 with gGameSettings
do
5356 if (Length(P
) > 1) and
5357 ((P
[1] = '1') or (P
[1] = '0')) then
5359 if (P
[1][1] = '1') then
5360 Options
:= Options
or GAME_OPTION_BOTVSMONSTER
5362 Options
:= Options
and (not GAME_OPTION_BOTVSMONSTER
);
5365 if (LongBool(Options
and GAME_OPTION_BOTVSMONSTER
)) then
5366 g_Console_Add(_lc
[I_MSG_BOTSVSMONSTERS_ON
])
5368 g_Console_Add(_lc
[I_MSG_BOTSVSMONSTERS_OFF
]);
5370 if g_Game_IsNet
then MH_SEND_GameSettings
;
5373 else if (cmd
= 'g_warmuptime') and not g_Game_IsClient
then
5375 if Length(P
) > 1 then
5377 if StrToIntDef(P
[1], gGameSettings
.WarmupTime
) = 0 then
5378 gGameSettings
.WarmupTime
:= 30
5380 gGameSettings
.WarmupTime
:= StrToIntDef(P
[1], gGameSettings
.WarmupTime
);
5383 g_Console_Add(Format(_lc
[I_MSG_WARMUP
],
5384 [gGameSettings
.WarmupTime
]));
5385 g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
5387 else if cmd
= 'net_interp' then
5389 if (Length(P
) > 1) then
5390 NetInterpLevel
:= StrToIntDef(P
[1], NetInterpLevel
);
5392 g_Console_Add('net_interp = ' + IntToStr(NetInterpLevel
));
5393 config
:= TConfig
.CreateFile(GameDir
+'/'+CONFIG_FILENAME
);
5394 config
.WriteInt('Client', 'InterpolationSteps', NetInterpLevel
);
5395 config
.SaveFile(GameDir
+'/'+CONFIG_FILENAME
);
5398 else if cmd
= 'net_forceplayerupdate' then
5400 if (Length(P
) > 1) and
5401 ((P
[1] = '1') or (P
[1] = '0')) then
5402 NetForcePlayerUpdate
:= (P
[1][1] = '1');
5404 if NetForcePlayerUpdate
then
5405 g_Console_Add('net_forceplayerupdate = 1')
5407 g_Console_Add('net_forceplayerupdate = 0');
5408 config
:= TConfig
.CreateFile(GameDir
+'/'+CONFIG_FILENAME
);
5409 config
.WriteBool('Client', 'ForcePlayerUpdate', NetForcePlayerUpdate
);
5410 config
.SaveFile(GameDir
+'/'+CONFIG_FILENAME
);
5413 else if cmd
= 'net_predictself' then
5415 if (Length(P
) > 1) and
5416 ((P
[1] = '1') or (P
[1] = '0')) then
5417 NetPredictSelf
:= (P
[1][1] = '1');
5419 if NetPredictSelf
then
5420 g_Console_Add('net_predictself = 1')
5422 g_Console_Add('net_predictself = 0');
5423 config
:= TConfig
.CreateFile(GameDir
+'/'+CONFIG_FILENAME
);
5424 config
.WriteBool('Client', 'PredictSelf', NetPredictSelf
);
5425 config
.SaveFile(GameDir
+'/'+CONFIG_FILENAME
);
5428 else if cmd
= 'sv_name' then
5430 if (Length(P
) > 1) and (Length(P
[1]) > 0) then
5432 NetServerName
:= P
[1];
5433 if Length(NetServerName
) > 64 then
5434 SetLength(NetServerName
, 64);
5435 if g_Game_IsServer
and g_Game_IsNet
and NetUseMaster
then
5439 g_Console_Add(cmd
+ ' = "' + NetServerName
+ '"');
5441 else if cmd
= 'sv_passwd' then
5443 if (Length(P
) > 1) and (Length(P
[1]) > 0) then
5445 NetPassword
:= P
[1];
5446 if Length(NetPassword
) > 24 then
5447 SetLength(NetPassword
, 24);
5448 if g_Game_IsServer
and g_Game_IsNet
and NetUseMaster
then
5452 g_Console_Add(cmd
+ ' = "' + AnsiLowerCase(NetPassword
) + '"');
5454 else if cmd
= 'sv_maxplrs' then
5456 if (Length(P
) > 1) then
5458 NetMaxClients
:= Min(Max(StrToIntDef(P
[1], NetMaxClients
), 1), NET_MAXCLIENTS
);
5459 if g_Game_IsServer
and g_Game_IsNet
then
5462 for a
:= 0 to High(NetClients
) do
5463 if NetClients
[a
].Used
then
5466 if b
> NetMaxClients
then
5468 s
:= g_Player_Get(NetClients
[a
].Player
).Name
;
5469 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_FULL
);
5470 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
5471 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
5474 if NetUseMaster
then
5479 g_Console_Add(cmd
+ ' = ' + IntToStr(NetMaxClients
));
5481 else if cmd
= 'sv_public' then
5483 if (Length(P
) > 1) then
5485 NetUseMaster
:= StrToIntDef(P
[1], Byte(NetUseMaster
)) > 0;
5486 if g_Game_IsServer
and g_Game_IsNet
then
5487 if NetUseMaster
then
5489 if NetMPeer
= nil then
5490 if not g_Net_Slist_Connect() then
5491 g_Console_Add(_lc
[I_NET_MSG_ERROR
] + _lc
[I_NET_SLIST_ERROR
]);
5492 g_Net_Slist_Update();
5495 if NetMPeer
<> nil then
5496 g_Net_Slist_Disconnect();
5499 g_Console_Add(cmd
+ ' = ' + IntToStr(Byte(NetUseMaster
)));
5501 else if cmd
= 'sv_intertime' then
5503 if (Length(P
) > 1) then
5504 gDefInterTime
:= Min(Max(StrToIntDef(P
[1], gDefInterTime
), -1), 120);
5506 g_Console_Add(cmd
+ ' = ' + IntToStr(gDefInterTime
));
5508 else if cmd
= 'p1_name' then
5510 if (Length(P
) > 1) and gGameOn
then
5512 if g_Game_IsClient
then
5514 gPlayer1Settings
.Name
:= b_Text_Unformat(P
[1]);
5515 MC_SEND_PlayerSettings
;
5518 if gPlayer1
<> nil then
5520 gPlayer1
.Name
:= b_Text_Unformat(P
[1]);
5521 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer1
.UID
);
5524 gPlayer1Settings
.Name
:= b_Text_Unformat(P
[1]);
5527 else if cmd
= 'p2_name' then
5529 if (Length(P
) > 1) and gGameOn
then
5531 if g_Game_IsClient
then
5533 gPlayer2Settings
.Name
:= b_Text_Unformat(P
[1]);
5534 MC_SEND_PlayerSettings
;
5537 if gPlayer2
<> nil then
5539 gPlayer2
.Name
:= b_Text_Unformat(P
[1]);
5540 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer2
.UID
);
5543 gPlayer2Settings
.Name
:= b_Text_Unformat(P
[1]);
5546 else if cmd
= 'p1_color' then
5548 if Length(P
) > 3 then
5549 if g_Game_IsClient
then
5551 gPlayer1Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
5552 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
5553 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
5554 MC_SEND_PlayerSettings
;
5557 if gPlayer1
<> nil then
5559 gPlayer1
.Model
.SetColor(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
5560 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
5561 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
5562 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer1
.UID
);
5565 gPlayer1Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
5566 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
5567 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
5569 else if (cmd
= 'p2_color') and not g_Game_IsNet
then
5571 if Length(P
) > 3 then
5572 if g_Game_IsClient
then
5574 gPlayer2Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
5575 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
5576 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
5577 MC_SEND_PlayerSettings
;
5580 if gPlayer2
<> nil then
5582 gPlayer2
.Model
.SetColor(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
5583 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
5584 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
5585 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer2
.UID
);
5588 gPlayer2Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
5589 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
5590 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
5592 else if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
5594 if cmd
= 'r_showscore' then
5596 if (Length(P
) > 1) and
5597 ((P
[1] = '1') or (P
[1] = '0')) then
5598 gShowGoals
:= (P
[1][1] = '1');
5601 g_Console_Add(_lc
[I_MSG_SCORE_ON
])
5603 g_Console_Add(_lc
[I_MSG_SCORE_OFF
]);
5605 else if cmd
= 'r_showstat' then
5607 if (Length(P
) > 1) and
5608 ((P
[1] = '1') or (P
[1] = '0')) then
5609 gShowStat
:= (P
[1][1] = '1');
5612 g_Console_Add(_lc
[I_MSG_STATS_ON
])
5614 g_Console_Add(_lc
[I_MSG_STATS_OFF
]);
5616 else if cmd
= 'r_showkillmsg' then
5618 if (Length(P
) > 1) and
5619 ((P
[1] = '1') or (P
[1] = '0')) then
5620 gShowKillMsg
:= (P
[1][1] = '1');
5622 if gShowKillMsg
then
5623 g_Console_Add(_lc
[I_MSG_KILL_MSGS_ON
])
5625 g_Console_Add(_lc
[I_MSG_KILL_MSGS_OFF
]);
5627 else if cmd
= 'r_showlives' then
5629 if (Length(P
) > 1) and
5630 ((P
[1] = '1') or (P
[1] = '0')) then
5631 gShowLives
:= (P
[1][1] = '1');
5634 g_Console_Add(_lc
[I_MSG_LIVES_ON
])
5636 g_Console_Add(_lc
[I_MSG_LIVES_OFF
]);
5638 else if cmd
= 'r_showspect' then
5640 if (Length(P
) > 1) and
5641 ((P
[1] = '1') or (P
[1] = '0')) then
5642 gSpectHUD
:= (P
[1][1] = '1');
5645 g_Console_Add(_lc
[I_MSG_SPECT_HUD_ON
])
5647 g_Console_Add(_lc
[I_MSG_SPECT_HUD_OFF
]);
5649 else if cmd
= 'r_showping' then
5651 if (Length(P
) > 1) and
5652 ((P
[1] = '1') or (P
[1] = '0')) then
5653 gShowPing
:= (P
[1][1] = '1');
5656 g_Console_Add(_lc
[I_MSG_PING_ON
])
5658 g_Console_Add(_lc
[I_MSG_PING_OFF
]);
5660 else if (cmd
= 'g_scorelimit') and not g_Game_IsClient
then
5662 if Length(P
) > 1 then
5664 if StrToIntDef(P
[1], gGameSettings
.GoalLimit
) = 0 then
5665 gGameSettings
.GoalLimit
:= 0
5670 if gGameSettings
.GameMode
= GM_DM
then
5672 stat
:= g_Player_GetStats();
5674 for a
:= 0 to High(stat
) do
5675 if stat
[a
].Frags
> b
then
5679 b
:= Max(gTeamStat
[TEAM_RED
].Goals
, gTeamStat
[TEAM_BLUE
].Goals
);
5681 gGameSettings
.GoalLimit
:= Max(StrToIntDef(P
[1], gGameSettings
.GoalLimit
), b
);
5684 if g_Game_IsNet
then MH_SEND_GameSettings
;
5687 g_Console_Add(Format(_lc
[I_MSG_SCORE_LIMIT
], [gGameSettings
.GoalLimit
]));
5689 else if (cmd
= 'g_timelimit') and not g_Game_IsClient
then
5691 if (Length(P
) > 1) and (StrToIntDef(P
[1], -1) >= 0) then
5692 gGameSettings
.TimeLimit
:= StrToIntDef(P
[1], -1);
5694 g_Console_Add(Format(_lc
[I_MSG_TIME_LIMIT
],
5695 [gGameSettings
.TimeLimit
div 3600,
5696 (gGameSettings
.TimeLimit
div 60) mod 60,
5697 gGameSettings
.TimeLimit
mod 60]));
5698 if g_Game_IsNet
then MH_SEND_GameSettings
;
5700 else if (cmd
= 'g_maxlives') and not g_Game_IsClient
then
5702 if Length(P
) > 1 then
5704 if StrToIntDef(P
[1], gGameSettings
.MaxLives
) = 0 then
5705 gGameSettings
.MaxLives
:= 0
5709 stat
:= g_Player_GetStats();
5711 for a
:= 0 to High(stat
) do
5712 if stat
[a
].Lives
> b
then
5714 gGameSettings
.MaxLives
:=
5715 Max(StrToIntDef(P
[1], gGameSettings
.MaxLives
), b
);
5719 g_Console_Add(Format(_lc
[I_MSG_LIVES
],
5720 [gGameSettings
.MaxLives
]));
5721 if g_Game_IsNet
then MH_SEND_GameSettings
;
5726 procedure PrintHeapStats();
5730 hs
:= GetFPCHeapStatus();
5731 e_LogWriteLn ('v===== heap status =====v');
5732 e_LogWriteFln('max heap size = %d k', [hs
.MaxHeapSize
div 1024]);
5733 e_LogWriteFln('max heap used = %d k', [hs
.MaxHeapUsed
div 1024]);
5734 e_LogWriteFln('cur heap size = %d k', [hs
.CurrHeapSize
div 1024]);
5735 e_LogWriteFln('cur heap used = %d k', [hs
.CurrHeapUsed
div 1024]);
5736 e_LogWriteFln('cur heap free = %d k', [hs
.CurrHeapFree
div 1024]);
5737 e_LogWriteLn ('^=======================^');
5740 procedure DebugCommands(P
: SSArray
);
5747 // Êîìàíäû îòëàäî÷íîãî ðåæèìà:
5748 if {gDebugMode}conIsCheatsEnabled
then
5750 cmd
:= LowerCase(P
[0]);
5751 if cmd
= 'd_window' then
5753 g_Console_Add(Format('gWinPosX = %d, gWinPosY %d', [gWinPosX
, gWinPosY
]));
5754 g_Console_Add(Format('gWinRealPosX = %d, gWinRealPosY %d', [gWinRealPosX
, gWinRealPosY
]));
5755 g_Console_Add(Format('gScreenWidth = %d, gScreenHeight = %d', [gScreenWidth
, gScreenHeight
]));
5756 g_Console_Add(Format('gWinSizeX = %d, gWinSizeY = %d', [gWinSizeX
, gWinSizeY
]));
5757 g_Console_Add(Format('Frame X = %d, Y = %d, Caption Y = %d', [gWinFrameX
, gWinFrameY
, gWinCaption
]));
5759 else if cmd
= 'd_sounds' then
5761 if (Length(P
) > 1) and
5762 ((P
[1] = '1') or (P
[1] = '0')) then
5763 g_Debug_Sounds
:= (P
[1][1] = '1');
5765 g_Console_Add(Format('d_sounds is %d', [Byte(g_Debug_Sounds
)]));
5767 else if cmd
= 'd_frames' then
5769 if (Length(P
) > 1) and
5770 ((P
[1] = '1') or (P
[1] = '0')) then
5771 g_Debug_Frames
:= (P
[1][1] = '1');
5773 g_Console_Add(Format('d_frames is %d', [Byte(g_Debug_Frames
)]));
5775 else if cmd
= 'd_winmsg' then
5777 if (Length(P
) > 1) and
5778 ((P
[1] = '1') or (P
[1] = '0')) then
5779 g_Debug_WinMsgs
:= (P
[1][1] = '1');
5781 g_Console_Add(Format('d_winmsg is %d', [Byte(g_Debug_WinMsgs
)]));
5783 else if (cmd
= 'd_monoff') and not g_Game_IsNet
then
5785 if (Length(P
) > 1) and
5786 ((P
[1] = '1') or (P
[1] = '0')) then
5787 g_Debug_MonsterOff
:= (P
[1][1] = '1');
5789 g_Console_Add(Format('d_monoff is %d', [Byte(g_debug_MonsterOff
)]));
5791 else if (cmd
= 'd_botoff') and not g_Game_IsNet
then
5793 if Length(P
) > 1 then
5795 '0': g_debug_BotAIOff
:= 0;
5796 '1': g_debug_BotAIOff
:= 1;
5797 '2': g_debug_BotAIOff
:= 2;
5798 '3': g_debug_BotAIOff
:= 3;
5801 g_Console_Add(Format('d_botoff is %d', [g_debug_BotAIOff
]));
5803 else if cmd
= 'd_monster' then
5805 if gGameOn
and (gPlayer1
<> nil) and (gPlayer1
.alive
) and (not g_Game_IsNet
) then
5806 if Length(P
) < 2 then
5808 g_Console_Add(cmd
+ ' [ID | Name] [behaviour]');
5809 g_Console_Add('ID | Name');
5810 for b
:= MONSTER_DEMON
to MONSTER_MAN
do
5811 g_Console_Add(Format('%2d | %s', [b
, g_Mons_NameByTypeId(b
)]));
5812 conwriteln('behav. num'#10'normal 0'#10'killer 1'#10'maniac 2'#10'insane 3'#10'cannibal 4'#10'good 5');
5815 a
:= StrToIntDef(P
[1], 0);
5816 if (a
< MONSTER_DEMON
) or (a
> MONSTER_MAN
) then
5817 a
:= g_Mons_TypeIdByName(P
[1]);
5819 if (a
< MONSTER_DEMON
) or (a
> MONSTER_MAN
) then
5820 g_Console_Add(Format(_lc
[I_MSG_NO_MONSTER
], [P
[1]]))
5823 with gPlayer1
.Obj
do
5825 mon
:= g_Monsters_Create(a
,
5826 X
+ Rect
.X
+ (Rect
.Width
div 2),
5827 Y
+ Rect
.Y
+ Rect
.Height
,
5828 gPlayer1
.Direction
, True);
5830 if (Length(P
) > 2) and (mon
<> nil) then
5832 if (CompareText(P
[2], 'normal') = 0) then mon
.MonsterBehaviour
:= BH_NORMAL
5833 else if (CompareText(P
[2], 'killer') = 0) then mon
.MonsterBehaviour
:= BH_KILLER
5834 else if (CompareText(P
[2], 'maniac') = 0) then mon
.MonsterBehaviour
:= BH_MANIAC
5835 else if (CompareText(P
[2], 'insane') = 0) then mon
.MonsterBehaviour
:= BH_INSANE
5836 else if (CompareText(P
[2], 'cannibal') = 0) then mon
.MonsterBehaviour
:= BH_CANNIBAL
5837 else if (CompareText(P
[2], 'good') = 0) then mon
.MonsterBehaviour
:= BH_GOOD
5838 else if (CompareText(P
[2], 'friend') = 0) then mon
.MonsterBehaviour
:= BH_GOOD
5839 else if (CompareText(P
[2], 'friendly') = 0) then mon
.MonsterBehaviour
:= BH_GOOD
5840 else mon
.MonsterBehaviour
:= Min(Max(StrToIntDef(P
[2], BH_NORMAL
), BH_NORMAL
), BH_GOOD
);
5845 else if (cmd
= 'd_health') then
5847 if (Length(P
) > 1) and
5848 ((P
[1] = '1') or (P
[1] = '0')) then
5849 g_debug_HealthBar
:= (P
[1][1] = '1');
5851 g_Console_Add(Format('d_health is %d', [Byte(g_debug_HealthBar
)]));
5853 else if (cmd
= 'd_player') then
5855 if (Length(P
) > 1) and
5856 ((P
[1] = '1') or (P
[1] = '0')) then
5857 g_debug_Player
:= (P
[1][1] = '1');
5859 g_Console_Add(Format(cmd
+ ' is %d', [Byte(g_Debug_Player
)]));
5861 else if (cmd
= 'd_mem') then
5867 g_Console_Add(_lc
[I_MSG_NOT_DEBUG
]);
5871 procedure GameCheats(P
: SSArray
);
5877 if (not gGameOn
) or (not conIsCheatsEnabled
) then
5879 g_Console_Add('not available');
5885 g_Console_Add('where is the player?!');
5888 cmd
:= LowerCase(P
[0]);
5892 plr
.GodMode
:= not plr
.GodMode
;
5893 if plr
.GodMode
then g_Console_Add('player is godlike now') else g_Console_Add('player is mortal now');
5896 // give <health|exit|weapons|air|suit|jetpack|berserk|all>
5897 if cmd
= 'give' then
5899 if length(P
) < 2 then begin g_Console_Add('give what?!'); exit
; end;
5900 for f
:= 1 to High(P
) do
5902 cmd
:= LowerCase(P
[f
]);
5903 if cmd
= 'health' then begin plr
.RestoreHealthArmor(); g_Console_Add('player feels himself better'); continue
; end;
5904 if (cmd
= 'all') {or (cmd = 'weapons')} then begin plr
.AllRulez(False); g_Console_Add('player got the gifts'); continue
; end;
5905 if cmd
= 'exit' then
5907 if gTriggers
<> nil then
5909 for a
:= 0 to High(gTriggers
) do
5911 if gTriggers
[a
].TriggerType
= TRIGGER_EXIT
then
5913 g_Console_Add('player left the map');
5914 gExitByTrigger
:= True;
5915 //g_Game_ExitLevel(gTriggers[a].Data.MapName);
5916 g_Game_ExitLevel(gTriggers
[a
].tgcMap
);
5924 if cmd
= 'air' then begin plr
.GiveItem(ITEM_OXYGEN
); g_Console_Add('player got some air'); continue
; end;
5925 if cmd
= 'jetpack' then begin plr
.GiveItem(ITEM_JETPACK
); g_Console_Add('player got a jetpack'); continue
; end;
5926 if cmd
= 'suit' then begin plr
.GiveItem(ITEM_SUIT
); g_Console_Add('player got an envirosuit'); continue
; end;
5927 if cmd
= 'berserk' then begin plr
.GiveItem(ITEM_MEDKIT_BLACK
); g_Console_Add('player got a berserk pack'); continue
; end;
5928 if cmd
= 'backpack' then begin plr
.GiveItem(ITEM_AMMO_BACKPACK
); g_Console_Add('player got a backpack'); continue
; end;
5930 if cmd
= 'helmet' then begin plr
.GiveItem(ITEM_HELMET
); g_Console_Add('player got a helmet'); continue
; end;
5931 if cmd
= 'bottle' then begin plr
.GiveItem(ITEM_BOTTLE
); g_Console_Add('player got a bottle of health'); continue
; end;
5933 if cmd
= 'stimpack' then begin plr
.GiveItem(ITEM_MEDKIT_SMALL
); g_Console_Add('player got a stimpack'); continue
; end;
5934 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;
5936 if cmd
= 'greenarmor' then begin plr
.GiveItem(ITEM_ARMOR_GREEN
); g_Console_Add('player got a security armor'); continue
; end;
5937 if cmd
= 'bluearmor' then begin plr
.GiveItem(ITEM_ARMOR_BLUE
); g_Console_Add('player got a combat armor'); continue
; end;
5939 if (cmd
= 'megasphere') or (cmd
= 'mega') then begin plr
.GiveItem(ITEM_SPHERE_BLUE
); g_Console_Add('player got a megasphere'); continue
; end;
5940 if (cmd
= 'soulsphere') or (cmd
= 'soul')then begin plr
.GiveItem(ITEM_SPHERE_WHITE
); g_Console_Add('player got a soul sphere'); continue
; end;
5942 if (cmd
= 'invul') or (cmd
= 'invulnerability') then begin plr
.GiveItem(ITEM_INVUL
); g_Console_Add('player got invulnerability'); continue
; end;
5943 if (cmd
= 'invis') or (cmd
= 'invisibility') then begin plr
.GiveItem(ITEM_INVIS
); g_Console_Add('player got invisibility'); continue
; end;
5945 if cmd
= 'redkey' then begin plr
.GiveItem(ITEM_KEY_RED
); g_Console_Add('player got the red key'); continue
; end;
5946 if cmd
= 'greenkey' then begin plr
.GiveItem(ITEM_KEY_GREEN
); g_Console_Add('player got the green key'); continue
; end;
5947 if cmd
= 'bluekey' then begin plr
.GiveItem(ITEM_KEY_BLUE
); g_Console_Add('player got the blue key'); continue
; end;
5949 if (cmd
= 'shotgun') or (cmd
= 'sg') then begin plr
.GiveItem(ITEM_WEAPON_SHOTGUN1
); g_Console_Add('player got a shotgun'); continue
; end;
5950 if (cmd
= 'supershotgun') or (cmd
= 'ssg') then begin plr
.GiveItem(ITEM_WEAPON_SHOTGUN2
); g_Console_Add('player got a supershotgun'); continue
; end;
5951 if cmd
= 'chaingun' then begin plr
.GiveItem(ITEM_WEAPON_CHAINGUN
); g_Console_Add('player got a chaingun'); continue
; end;
5952 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;
5953 if cmd
= 'plasmagun' then begin plr
.GiveItem(ITEM_WEAPON_PLASMA
); g_Console_Add('player got a plasma gun'); continue
; end;
5954 if cmd
= 'bfg' then begin plr
.GiveItem(ITEM_WEAPON_BFG
); g_Console_Add('player got a BFG-9000'); continue
; end;
5956 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;
5957 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;
5958 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;
5959 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;
5960 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;
5961 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;
5963 if cmd
= 'superchaingun' then begin plr
.GiveItem(ITEM_WEAPON_SUPERPULEMET
); g_Console_Add('player got a superchaingun'); continue
; end;
5964 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;
5966 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;
5967 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;
5969 if cmd
= 'chainsaw' then begin plr
.GiveItem(ITEM_WEAPON_SAW
); g_Console_Add('player got a chainsaw'); continue
; end;
5971 if cmd
= 'ammo' then
5973 plr
.GiveItem(ITEM_AMMO_SHELLS_BOX
);
5974 plr
.GiveItem(ITEM_AMMO_BULLETS_BOX
);
5975 plr
.GiveItem(ITEM_AMMO_CELL_BIG
);
5976 plr
.GiveItem(ITEM_AMMO_ROCKET_BOX
);
5977 plr
.GiveItem(ITEM_AMMO_FUELCAN
);
5978 g_Console_Add('player got some ammo');
5982 if cmd
= 'clip' then begin plr
.GiveItem(ITEM_AMMO_BULLETS
); g_Console_Add('player got some bullets'); continue
; end;
5983 if cmd
= 'bullets' then begin plr
.GiveItem(ITEM_AMMO_BULLETS_BOX
); g_Console_Add('player got a box of bullets'); continue
; end;
5985 if cmd
= 'shells' then begin plr
.GiveItem(ITEM_AMMO_SHELLS
); g_Console_Add('player got some shells'); continue
; end;
5986 if cmd
= 'shellbox' then begin plr
.GiveItem(ITEM_AMMO_SHELLS_BOX
); g_Console_Add('player got a box of shells'); continue
; end;
5988 if cmd
= 'cells' then begin plr
.GiveItem(ITEM_AMMO_CELL
); g_Console_Add('player got some cells'); continue
; end;
5989 if cmd
= 'battery' then begin plr
.GiveItem(ITEM_AMMO_CELL_BIG
); g_Console_Add('player got cell battery'); continue
; end;
5991 if cmd
= 'rocket' then begin plr
.GiveItem(ITEM_AMMO_ROCKET
); g_Console_Add('player got a rocket'); continue
; end;
5992 if cmd
= 'rocketbox' then begin plr
.GiveItem(ITEM_AMMO_ROCKET_BOX
); g_Console_Add('player got some rockets'); continue
; end;
5994 if (cmd
= 'fuel') or (cmd
= 'fuelcan') then begin plr
.GiveItem(ITEM_AMMO_FUELCAN
); g_Console_Add('player got fuel canister'); continue
; end;
5996 if cmd
= 'weapons' then
5998 plr
.GiveItem(ITEM_WEAPON_SHOTGUN1
);
5999 plr
.GiveItem(ITEM_WEAPON_SHOTGUN2
);
6000 plr
.GiveItem(ITEM_WEAPON_CHAINGUN
);
6001 plr
.GiveItem(ITEM_WEAPON_ROCKETLAUNCHER
);
6002 plr
.GiveItem(ITEM_WEAPON_PLASMA
);
6003 plr
.GiveItem(ITEM_WEAPON_BFG
);
6004 g_Console_Add('player got weapons');
6008 if cmd
= 'keys' then
6010 plr
.GiveItem(ITEM_KEY_RED
);
6011 plr
.GiveItem(ITEM_KEY_GREEN
);
6012 plr
.GiveItem(ITEM_KEY_BLUE
);
6013 g_Console_Add('player got all keys');
6017 g_Console_Add('i don''t know how to give '''+cmd
+'''!');
6022 if cmd
= 'open' then
6024 g_Console_Add('player activated sesame');
6025 g_Triggers_OpenAll();
6032 if gFly
then g_Console_Add('player feels himself lighter') else g_Console_Add('player lost his wings');
6036 if cmd
= 'noclip' then
6039 g_Console_Add('wall hardeness adjusted');
6043 if cmd
= 'notarget' then
6045 plr
.NoTarget
:= not plr
.NoTarget
;
6046 if plr
.NoTarget
then g_Console_Add('player hides in shadows') else g_Console_Add('player is brave again');
6050 if cmd
= 'noreload' then
6052 plr
.NoReload
:= not plr
.NoReload
;
6053 if plr
.NoReload
then g_Console_Add('player is action hero now') else g_Console_Add('player is ordinary man now');
6057 if cmd
= 'speedy' then
6059 MAX_RUNVEL
:= 32-MAX_RUNVEL
;
6060 g_Console_Add('speed adjusted');
6064 if cmd
= 'jumpy' then
6066 VEL_JUMP
:= 30-VEL_JUMP
;
6067 g_Console_Add('jump height adjusted');
6071 if cmd
= 'automap' then
6073 gShowMap
:= not gShowMap
;
6074 if gShowMap
then g_Console_Add('player gains second sight') else g_Console_Add('player lost second sight');
6078 if cmd
= 'aimline' then
6080 gAimLine
:= not gAimLine
;
6081 if gAimLine
then g_Console_Add('player gains laser sight') else g_Console_Add('player lost laser sight');
6086 procedure GameCommands(P
: SSArray
);
6092 pl
: pTNetClient
= nil;
6099 cmd
:= LowerCase(P
[0]);
6101 if (cmd
= 'quit') or
6108 else if cmd
= 'pause' then
6110 if (g_ActiveWindow
= nil) then
6111 g_Game_Pause(not gPauseMain
);
6113 else if cmd
= 'endgame' then
6114 gExit
:= EXIT_SIMPLE
6115 else if cmd
= 'restart' then
6117 if gGameOn
or (gState
in [STATE_INTERSINGLE
, STATE_INTERCUSTOM
]) then
6119 if g_Game_IsClient
then
6121 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6126 g_Console_Add(_lc
[I_MSG_NOT_GAME
]);
6128 else if cmd
= 'kick' then
6130 if g_Game_IsServer
then
6132 if Length(P
) < 2 then
6134 g_Console_Add('kick <name>');
6139 g_Console_Add('kick <name>');
6143 if g_Game_IsNet
then
6144 pl
:= g_Net_Client_ByName(P
[1]);
6147 s
:= g_Net_ClientName_ByID(pl
^.ID
);
6148 enet_peer_disconnect(pl
^.Peer
, NET_DISC_KICK
);
6149 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
6150 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
6151 if NetUseMaster
then
6153 end else if gPlayers
<> nil then
6154 for a
:= Low(gPlayers
) to High(gPlayers
) do
6155 if gPlayers
[a
] <> nil then
6156 if Copy(LowerCase(gPlayers
[a
].Name
), 1, Length(P
[1])) = LowerCase(P
[1]) then
6158 // Íå îòêëþ÷àòü îñíîâíûõ èãðîêîâ â ñèíãëå
6159 if not(gPlayers
[a
] is TBot
) and (gGameSettings
.GameType
= GT_SINGLE
) then
6161 gPlayers
[a
].Lives
:= 0;
6162 gPlayers
[a
].Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
6163 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [gPlayers
[a
].Name
]), True);
6164 g_Player_Remove(gPlayers
[a
].UID
);
6165 if NetUseMaster
then
6167 // Åñëè íå ïåðåìåøàòü, ïðè äîáàâëåíèè íîâûõ áîòîâ ïîÿâÿòñÿ ñòàðûå
6171 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6173 else if cmd
= 'kick_id' then
6175 if g_Game_IsServer
and g_Game_IsNet
then
6177 if Length(P
) < 2 then
6179 g_Console_Add('kick_id <client ID>');
6184 g_Console_Add('kick_id <client ID>');
6188 a
:= StrToIntDef(P
[1], 0);
6189 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
6191 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
6193 s
:= g_Net_ClientName_ByID(NetClients
[a
].ID
);
6194 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_KICK
);
6195 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
6196 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
6197 if NetUseMaster
then
6202 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6204 else if cmd
= 'ban' then
6206 if g_Game_IsServer
and g_Game_IsNet
then
6208 if Length(P
) < 2 then
6210 g_Console_Add('ban <name>');
6215 g_Console_Add('ban <name>');
6219 pl
:= g_Net_Client_ByName(P
[1]);
6222 s
:= g_Net_ClientName_ByID(pl
^.ID
);
6223 g_Net_BanHost(pl
^.Peer
^.address
.host
, False);
6224 enet_peer_disconnect(pl
^.Peer
, NET_DISC_TEMPBAN
);
6225 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
6226 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
6227 if NetUseMaster
then
6230 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
6232 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6234 else if cmd
= 'ban_id' then
6236 if g_Game_IsServer
and g_Game_IsNet
then
6238 if Length(P
) < 2 then
6240 g_Console_Add('ban_id <client ID>');
6245 g_Console_Add('ban_id <client ID>');
6249 a
:= StrToIntDef(P
[1], 0);
6250 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
6251 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
6253 s
:= g_Net_ClientName_ByID(NetClients
[a
].ID
);
6254 g_Net_BanHost(NetClients
[a
].Peer
^.address
.host
, False);
6255 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_TEMPBAN
);
6256 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
6257 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
6258 if NetUseMaster
then
6262 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6264 else if cmd
= 'permban' then
6266 if g_Game_IsServer
and g_Game_IsNet
then
6268 if Length(P
) < 2 then
6270 g_Console_Add('permban <name>');
6275 g_Console_Add('permban <name>');
6279 pl
:= g_Net_Client_ByName(P
[1]);
6282 s
:= g_Net_ClientName_ByID(pl
^.ID
);
6283 g_Net_BanHost(pl
^.Peer
^.address
.host
);
6284 enet_peer_disconnect(pl
^.Peer
, NET_DISC_BAN
);
6285 g_Net_SaveBanList();
6286 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
6287 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
6288 if NetUseMaster
then
6291 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
6293 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6295 else if cmd
= 'permban_id' then
6297 if g_Game_IsServer
and g_Game_IsNet
then
6299 if Length(P
) < 2 then
6301 g_Console_Add('permban_id <client ID>');
6306 g_Console_Add('permban_id <client ID>');
6310 a
:= StrToIntDef(P
[1], 0);
6311 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
6312 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
6314 s
:= g_Net_ClientName_ByID(NetClients
[a
].ID
);
6315 g_Net_BanHost(NetClients
[a
].Peer
^.address
.host
);
6316 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_BAN
);
6317 g_Net_SaveBanList();
6318 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
6319 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
6320 if NetUseMaster
then
6324 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6326 else if cmd
= 'unban' then
6328 if g_Game_IsServer
and g_Game_IsNet
then
6330 if Length(P
) < 2 then
6332 g_Console_Add('unban <IP Address>');
6337 g_Console_Add('unban <IP Address>');
6341 if g_Net_UnbanHost(P
[1]) then
6343 g_Console_Add(Format(_lc
[I_MSG_UNBAN_OK
], [P
[1]]));
6344 g_Net_SaveBanList();
6346 g_Console_Add(Format(_lc
[I_MSG_UNBAN_FAIL
], [P
[1]]));
6348 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6350 else if cmd
= 'clientlist' then
6352 if g_Game_IsServer
and g_Game_IsNet
then
6355 if NetClients
<> nil then
6356 for a
:= Low(NetClients
) to High(NetClients
) do
6357 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
6359 plr
:= g_Player_Get(NetClients
[a
].Player
);
6360 if plr
= nil then continue
;
6362 g_Console_Add(Format('#%2d: %-15s | %s', [a
,
6363 IpToStr(NetClients
[a
].Peer
^.address
.host
), plr
.Name
]));
6366 g_Console_Add(_lc
[I_MSG_NOCLIENTS
]);
6368 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6370 else if cmd
= 'connect' then
6372 if (NetMode
= NET_NONE
) then
6374 if Length(P
) < 2 then
6376 g_Console_Add('connect <IP> [port] [password]');
6381 g_Console_Add('connect <IP> [port] [password]');
6385 if Length(P
) > 2 then
6386 prt
:= StrToIntDef(P
[2], 25666)
6390 if Length(P
) > 3 then
6395 g_Game_StartClient(P
[1], prt
, pw
);
6398 else if cmd
= 'disconnect' then
6400 if (NetMode
= NET_CLIENT
) then
6403 else if cmd
= 'reconnect' then
6405 if (NetMode
= NET_SERVER
) then
6408 if (NetMode
= NET_CLIENT
) then
6411 gExit
:= EXIT_SIMPLE
;
6415 //TODO: Use last successful password to reconnect, instead of ''
6416 g_Game_StartClient(NetClientIP
, NetClientPort
, '');
6418 else if (cmd
= 'addbot') or
6419 (cmd
= 'bot_add') then
6421 if Length(P
) > 2 then
6422 g_Bot_Add(TEAM_NONE
, StrToIntDef(P
[1], 2), StrToIntDef(P
[2], 100))
6423 else if Length(P
) > 1 then
6424 g_Bot_Add(TEAM_NONE
, StrToIntDef(P
[1], 2))
6426 g_Bot_Add(TEAM_NONE
, 2);
6428 else if cmd
= 'bot_addlist' then
6430 if Length(P
) > 1 then
6432 if Length(P
) = 2 then
6433 g_Bot_AddList(TEAM_NONE
, P
[1], StrToIntDef(P
[1], -1))
6434 else if Length(P
) = 3 then
6435 g_Bot_AddList(TEAM_NONE
, P
[1], StrToIntDef(P
[1], -1), StrToIntDef(P
[2], 100))
6437 g_Bot_AddList(IfThen(P
[2] = 'red', TEAM_RED
, TEAM_BLUE
), P
[1], StrToIntDef(P
[1], -1));
6440 else if cmd
= 'bot_removeall' then
6442 else if cmd
= 'chat' then
6444 if g_Game_IsNet
then
6446 if Length(P
) > 1 then
6448 for a
:= 1 to High(P
) do
6449 chstr
:= chstr
+ P
[a
] + ' ';
6451 if Length(chstr
) > 200 then SetLength(chstr
, 200);
6453 if Length(chstr
) < 1 then
6455 g_Console_Add('chat <text>');
6459 chstr
:= b_Text_Format(chstr
);
6460 if g_Game_IsClient
then
6461 MC_SEND_Chat(chstr
, NET_CHAT_PLAYER
)
6463 MH_SEND_Chat(gPlayer1Settings
.Name
+ ': ' + chstr
, NET_CHAT_PLAYER
);
6466 g_Console_Add('chat <text>');
6468 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6470 else if cmd
= 'teamchat' then
6472 if g_Game_IsNet
and (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
6474 if Length(P
) > 1 then
6476 for a
:= 1 to High(P
) do
6477 chstr
:= chstr
+ P
[a
] + ' ';
6479 if Length(chstr
) > 200 then SetLength(chstr
, 200);
6481 if Length(chstr
) < 1 then
6483 g_Console_Add('teamchat <text>');
6487 chstr
:= b_Text_Format(chstr
);
6488 if g_Game_IsClient
then
6489 MC_SEND_Chat(chstr
, NET_CHAT_TEAM
)
6491 MH_SEND_Chat(gPlayer1Settings
.Name
+ ': ' + chstr
, NET_CHAT_TEAM
,
6492 gPlayer1Settings
.Team
);
6495 g_Console_Add('teamchat <text>');
6497 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6499 else if cmd
= 'game' then
6501 if gGameSettings
.GameType
<> GT_NONE
then
6503 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6506 if Length(P
) = 1 then
6508 g_Console_Add(cmd
+ ' <WAD> [MAP] [# players]');
6511 // Èãðà åù¸ íå çàïóùåíà, ñíà÷àëà íàì íàäî çàãðóçèòü êàêîé-òî WAD
6512 P
[1] := addWadExtension(P
[1]);
6513 if FileExists(MapsDir
+ P
[1]) then
6515 // Åñëè êàðòà íå óêàçàíà, áåð¸ì ïåðâóþ êàðòó â ôàéëå
6516 if Length(P
) < 3 then
6519 P
[2] := g_Game_GetFirstMap(MapsDir
+ P
[1]);
6522 s
:= P
[1] + ':\' + UpperCase(P
[2]);
6524 if g_Map_Exist(MapsDir
+ s
) then
6526 // Çàïóñêàåì ñâîþ èãðó
6528 with gGameSettings
do
6530 GameMode
:= g_Game_TextToMode(gcGameMode
);
6531 if gSwitchGameMode
<> GM_NONE
then
6532 GameMode
:= gSwitchGameMode
;
6533 if GameMode
= GM_NONE
then GameMode
:= GM_DM
;
6534 if GameMode
= GM_SINGLE
then GameMode
:= GM_COOP
;
6536 if Length(P
) >= 4 then
6537 b
:= StrToIntDef(P
[3], 1);
6538 g_Game_StartCustom(s
, GameMode
, TimeLimit
,
6539 GoalLimit
, MaxLives
, Options
, b
);
6544 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
6546 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [UpperCase(P
[2]), P
[1]]));
6548 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]));
6550 else if cmd
= 'host' then
6552 if gGameSettings
.GameType
<> GT_NONE
then
6554 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6557 if Length(P
) < 4 then
6559 g_Console_Add(cmd
+ ' <listen IP> <port> <WAD> [MAP] [# players]');
6562 if not StrToIp(P
[1], listen
) then
6564 prt
:= StrToIntDef(P
[2], 25666);
6566 P
[3] := addWadExtension(P
[3]);
6567 if FileExists(MapsDir
+ P
[3]) then
6569 // Åñëè êàðòà íå óêàçàíà, áåð¸ì ïåðâóþ êàðòó â ôàéëå
6570 if Length(P
) < 5 then
6573 P
[4] := g_Game_GetFirstMap(MapsDir
+ P
[1]);
6576 s
:= P
[3] + ':\' + UpperCase(P
[4]);
6578 if g_Map_Exist(MapsDir
+ s
) then
6580 // Çàïóñêàåì ñâîþ èãðó
6582 with gGameSettings
do
6584 GameMode
:= g_Game_TextToMode(gcGameMode
);
6585 if gSwitchGameMode
<> GM_NONE
then
6586 GameMode
:= gSwitchGameMode
;
6587 if GameMode
= GM_NONE
then GameMode
:= GM_DM
;
6588 if GameMode
= GM_SINGLE
then GameMode
:= GM_COOP
;
6590 if Length(P
) >= 6 then
6591 b
:= StrToIntDef(P
[5], 0);
6592 g_Game_StartServer(s
, GameMode
, TimeLimit
,
6593 GoalLimit
, MaxLives
, Options
, b
, listen
, prt
);
6598 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[3]]))
6600 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [UpperCase(P
[4]), P
[3]]));
6602 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[3]]));
6604 else if cmd
= 'map' then
6606 if Length(P
) = 1 then
6608 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
6610 g_Console_Add(cmd
+ ' <MAP>');
6611 g_Console_Add(cmd
+ ' <WAD> [MAP]');
6613 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6615 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
6617 // Èä¸ò ñâîÿ èãðà èëè ñåðâåð
6618 if Length(P
) < 3 then
6620 // Ïåðâûé ïàðàìåòð - ëèáî êàðòà, ëèáî èìÿ WAD ôàéëà
6621 s
:= UpperCase(P
[1]);
6622 if g_Map_Exist(MapsDir
+ gGameSettings
.WAD
+ ':\' + s
) then
6623 begin // Êàðòà íàøëàñü
6624 gExitByTrigger
:= False;
6626 begin // Èä¸ò èãðà - çàâåðøàåì óðîâåíü
6628 gExit
:= EXIT_ENDLEVELCUSTOM
;
6630 else // Èíòåðìèññèÿ - ñðàçó çàãðóæàåì êàðòó
6631 g_Game_ChangeMap(s
);
6634 // Òàêîé êàðòû íåò, èùåì WAD ôàéë
6635 pw
:= findDiskWad(MapsDir
+ P
[1]);
6636 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [s
, 'WAD ' + P
[1]]));
6637 if FileExists(pw
) then
6639 // Ïàðàìåòðà êàðòû íåò, ïîýòîìó ñòàâèì ïåðâóþ èç ôàéëà
6641 P
[1] := ExtractRelativePath(MapsDir
, pw
);
6642 P
[2] := g_Game_GetFirstMap(MapsDir
+ P
[1]);
6644 s
:= P
[1] + ':\' + P
[2];
6646 if g_Map_Exist(MapsDir
+ s
) then
6648 gExitByTrigger
:= False;
6650 begin // Èä¸ò èãðà - çàâåðøàåì óðîâåíü
6652 gExit
:= EXIT_ENDLEVELCUSTOM
;
6654 else // Èíòåðìèññèÿ - ñðàçó çàãðóæàåì êàðòó
6655 g_Game_ChangeMap(s
);
6658 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
6660 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]));
6662 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]));
6666 // Óêàçàíî äâà ïàðàìåòðà, çíà÷èò ïåðâûé - WAD ôàéë, à âòîðîé - êàðòà
6667 P
[1] := addWadExtension(P
[1]);
6668 if FileExists(MapsDir
+ P
[1]) then
6671 P
[2] := UpperCase(P
[2]);
6672 s
:= P
[1] + ':\' + P
[2];
6674 if g_Map_Exist(MapsDir
+ s
) then
6675 begin // Íàøëè êàðòó
6676 gExitByTrigger
:= False;
6678 begin // Èä¸ò èãðà - çàâåðøàåì óðîâåíü
6680 gExit
:= EXIT_ENDLEVELCUSTOM
;
6682 else // Èíòåðìèññèÿ - ñðàçó çàãðóæàåì êàðòó
6683 g_Game_ChangeMap(s
);
6685 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]));
6687 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]));
6690 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6692 else if cmd
= 'nextmap' then
6694 if not(gGameOn
or (gState
= STATE_INTERCUSTOM
)) then
6695 g_Console_Add(_lc
[I_MSG_NOT_GAME
])
6698 if Length(P
) = 1 then
6700 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
6702 g_Console_Add(cmd
+ ' <MAP>');
6703 g_Console_Add(cmd
+ ' <WAD> [MAP]');
6706 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6711 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
6713 if Length(P
) < 3 then
6715 // Ïåðâûé ïàðàìåòð - ëèáî êàðòà, ëèáî èìÿ WAD ôàéëà
6716 s
:= UpperCase(P
[1]);
6717 if g_Map_Exist(MapsDir
+ gGameSettings
.WAD
+ ':\' + s
) then
6718 begin // Êàðòà íàøëàñü
6719 gExitByTrigger
:= False;
6724 // Òàêîé êàðòû íåò, èùåì WAD ôàéë
6725 P
[1] := addWadExtension(P
[1]);
6726 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [s
, P
[1]]));
6727 if FileExists(MapsDir
+ P
[1]) then
6729 // Ïàðàìåòðà êàðòû íåò, ïîýòîìó ñòàâèì ïåðâóþ èç ôàéëà
6731 P
[2] := g_Game_GetFirstMap(MapsDir
+ P
[1]);
6733 s
:= P
[1] + ':\' + P
[2];
6735 if g_Map_Exist(MapsDir
+ s
) then
6736 begin // Óñòàíàâëèâàåì êàðòó
6737 gExitByTrigger
:= False;
6742 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
6744 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]));
6746 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]));
6750 // Óêàçàíî äâà ïàðàìåòðà, çíà÷èò ïåðâûé - WAD ôàéë, à âòîðîé - êàðòà
6751 P
[1] := addWadExtension(P
[1]);
6752 if FileExists(MapsDir
+ P
[1]) then
6755 P
[2] := UpperCase(P
[2]);
6756 s
:= P
[1] + ':\' + P
[2];
6758 if g_Map_Exist(MapsDir
+ s
) then
6759 begin // Íàøëè êàðòó
6760 gExitByTrigger
:= False;
6764 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]));
6766 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]));
6769 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6772 if gNextMap
= '' then
6773 g_Console_Add(_lc
[I_MSG_NEXTMAP_UNSET
])
6775 g_Console_Add(Format(_lc
[I_MSG_NEXTMAP_SET
], [gNextMap
]));
6778 else if (cmd
= 'endmap') or (cmd
= 'goodbye') then
6781 g_Console_Add(_lc
[I_MSG_NOT_GAME
])
6783 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
6785 gExitByTrigger
:= False;
6786 // Ñëåäóþùàÿ êàðòà íå çàäàíà, ïðîáóåì íàéòè òðèããåð Âûõîä
6787 if (gNextMap
= '') and (gTriggers
<> nil) then
6788 for a
:= 0 to High(gTriggers
) do
6789 if gTriggers
[a
].TriggerType
= TRIGGER_EXIT
then
6791 gExitByTrigger
:= True;
6792 //gNextMap := gTriggers[a].Data.MapName;
6793 gNextMap
:= gTriggers
[a
].tgcMap
;
6796 // Èùåì ñëåäóþùóþ êàðòó â WAD ôàéëå
6797 if gNextMap
= '' then
6798 gNextMap
:= g_Game_GetNextMap();
6799 // Ïðîâåðÿåì, íå çàäàí ëè WAD ôàéë ðåñóðñíîé ñòðîêîé
6800 if not isWadPath(gNextMap
) then
6801 s
:= gGameSettings
.WAD
+ ':\' + gNextMap
6804 // Åñëè êàðòà íàéäåíà, âûõîäèì ñ óðîâíÿ
6805 if g_Map_Exist(MapsDir
+ s
) then
6806 gExit
:= EXIT_ENDLEVELCUSTOM
6808 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [gNextMap
]));
6810 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6812 else if (cmd
= 'event') then
6814 if (Length(P
) <= 1) then
6816 for a
:= 0 to High(gEvents
) do
6817 if gEvents
[a
].Command
= '' then
6818 g_Console_Add(gEvents
[a
].Name
+ ' <none>')
6820 g_Console_Add(gEvents
[a
].Name
+ ' "' + gEvents
[a
].Command
+ '"');
6823 if (Length(P
) = 2) then
6825 for a
:= 0 to High(gEvents
) do
6826 if gEvents
[a
].Name
= P
[1] then
6827 if gEvents
[a
].Command
= '' then
6828 g_Console_Add(gEvents
[a
].Name
+ ' <none>')
6830 g_Console_Add(gEvents
[a
].Name
+ ' "' + gEvents
[a
].Command
+ '"');
6833 for a
:= 0 to High(gEvents
) do
6834 if gEvents
[a
].Name
= P
[1] then
6836 gEvents
[a
].Command
:= '';
6837 for b
:= 2 to High(P
) do
6838 if Pos(' ', P
[b
]) = 0 then
6839 gEvents
[a
].Command
:= gEvents
[a
].Command
+ ' ' + P
[b
]
6841 gEvents
[a
].Command
:= gEvents
[a
].Command
+ ' "' + P
[b
] + '"';
6842 gEvents
[a
].Command
:= Trim(gEvents
[a
].Command
);
6846 else if cmd
= 'suicide' then
6850 if g_Game_IsClient
then
6851 MC_SEND_CheatRequest(NET_CHEAT_SUICIDE
)
6854 if gPlayer1
<> nil then
6855 gPlayer1
.Damage(SUICIDE_DAMAGE
, gPlayer1
.UID
, 0, 0, HIT_SELF
);
6856 if gPlayer2
<> nil then
6857 gPlayer2
.Damage(SUICIDE_DAMAGE
, gPlayer2
.UID
, 0, 0, HIT_SELF
);
6861 else if cmd
= 'screenshot' then
6865 else if cmd
= 'weapon' then
6867 if Length(p
) = 2 then
6869 a
:= WP_FIRST
+ StrToInt(p
[1]) - 1;
6870 if (a
>= WP_FIRST
) and (a
<= WP_LAST
) then
6871 gSelectWeapon
[0, a
] := True
6874 else if (cmd
= 'p1_weapon') or (cmd
= 'p2_weapon') then
6876 if Length(p
) = 2 then
6878 a
:= WP_FIRST
+ StrToInt(p
[1]) - 1;
6879 b
:= ord(cmd
[2]) - ord('1');
6880 if (a
>= WP_FIRST
) and (a
<= WP_LAST
) then
6881 gSelectWeapon
[b
, a
] := True
6884 // Êîìàíäû Ñâîåé èãðû:
6885 else if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
6887 if cmd
= 'bot_addred' then
6889 if Length(P
) > 1 then
6890 g_Bot_Add(TEAM_RED
, StrToIntDef(P
[1], 2))
6892 g_Bot_Add(TEAM_RED
, 2);
6894 else if cmd
= 'bot_addblue' then
6896 if Length(P
) > 1 then
6897 g_Bot_Add(TEAM_BLUE
, StrToIntDef(P
[1], 2))
6899 g_Bot_Add(TEAM_BLUE
, 2);
6901 else if cmd
= 'spectate' then
6907 else if cmd
= 'say' then
6909 if g_Game_IsServer
and g_Game_IsNet
then
6911 if Length(P
) > 1 then
6914 for a
:= 1 to High(P
) do
6915 chstr
:= chstr
+ P
[a
] + ' ';
6917 if Length(chstr
) > 200 then SetLength(chstr
, 200);
6919 if Length(chstr
) < 1 then
6921 g_Console_Add('say <text>');
6925 chstr
:= b_Text_Format(chstr
);
6926 MH_SEND_Chat(chstr
, NET_CHAT_PLAYER
);
6928 else g_Console_Add('say <text>');
6930 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6932 else if cmd
= 'tell' then
6934 if g_Game_IsServer
and g_Game_IsNet
then
6936 if (Length(P
) > 2) and (P
[1] <> '') then
6939 for a
:= 2 to High(P
) do
6940 chstr
:= chstr
+ P
[a
] + ' ';
6942 if Length(chstr
) > 200 then SetLength(chstr
, 200);
6944 if Length(chstr
) < 1 then
6946 g_Console_Add('tell <playername> <text>');
6950 pl
:= g_Net_Client_ByName(P
[1]);
6952 MH_SEND_Chat(b_Text_Format(chstr
), NET_CHAT_PLAYER
, pl
^.ID
)
6954 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
6956 else g_Console_Add('tell <playername> <text>');
6958 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6960 else if (cmd
= 'overtime') and not g_Game_IsClient
then
6962 if (Length(P
) = 1) or (StrToIntDef(P
[1], -1) <= 0) then
6964 // Äîïîëíèòåëüíîå âðåìÿ:
6965 gGameSettings
.TimeLimit
:= (gTime
- gGameStartTime
) div 1000 + Word(StrToIntDef(P
[1], 0));
6967 g_Console_Add(Format(_lc
[I_MSG_TIME_LIMIT
],
6968 [gGameSettings
.TimeLimit
div 3600,
6969 (gGameSettings
.TimeLimit
div 60) mod 60,
6970 gGameSettings
.TimeLimit
mod 60]));
6971 if g_Game_IsNet
then MH_SEND_GameSettings
;
6973 else if (cmd
= 'rcon_password') and g_Game_IsClient
then
6975 if (Length(P
) <= 1) then
6976 g_Console_Add('rcon_password <password>')
6978 MC_SEND_RCONPassword(P
[1]);
6980 else if cmd
= 'rcon' then
6982 if g_Game_IsClient
then
6984 if Length(P
) > 1 then
6987 for a
:= 1 to High(P
) do
6988 chstr
:= chstr
+ P
[a
] + ' ';
6990 if Length(chstr
) > 200 then SetLength(chstr
, 200);
6992 if Length(chstr
) < 1 then
6994 g_Console_Add('rcon <command>');
6998 MC_SEND_RCONCommand(chstr
);
7000 else g_Console_Add('rcon <command>');
7003 else if cmd
= 'ready' then
7005 if g_Game_IsServer
and (gLMSRespawn
= LMS_RESPAWN_WARMUP
) then
7006 gLMSRespawnTime
:= gTime
+ 100;
7008 else if (cmd
= 'callvote') and g_Game_IsNet
then
7010 if Length(P
) > 1 then
7013 for a
:= 1 to High(P
) do begin
7014 if a
> 1 then chstr
:= chstr
+ ' ';
7015 chstr
:= chstr
+ P
[a
];
7018 if Length(chstr
) > 200 then SetLength(chstr
, 200);
7020 if Length(chstr
) < 1 then
7022 g_Console_Add('callvote <command>');
7026 if g_Game_IsClient
then
7027 MC_SEND_Vote(True, chstr
)
7029 g_Game_StartVote(chstr
, gPlayer1Settings
.Name
);
7030 g_Console_Process('vote', True);
7033 g_Console_Add('callvote <command>');
7035 else if (cmd
= 'vote') and g_Game_IsNet
then
7037 if g_Game_IsClient
then
7039 else if gVoteInProgress
then
7041 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
7042 a
:= Floor((NetClientCount
+1)/2.0) + 1
7044 a
:= Floor(NetClientCount
/2.0) + 1;
7049 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_REVOKED
], [gPlayer1Settings
.Name
, gVoteCount
, a
]), True);
7050 MH_SEND_VoteEvent(NET_VE_REVOKE
, gPlayer1Settings
.Name
, 'a', gVoteCount
, a
);
7056 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_VOTE
], [gPlayer1Settings
.Name
, gVoteCount
, a
]), True);
7057 MH_SEND_VoteEvent(NET_VE_VOTE
, gPlayer1Settings
.Name
, 'a', gVoteCount
, a
);
7065 procedure g_TakeScreenShot();
7073 if e_NoGraphics
then Exit
;
7074 ssdir
:= GameDir
+'/screenshots';
7075 if not findFileCI(ssdir
, true) then
7077 // try to create dir
7082 if not findFileCI(ssdir
, true) then exit
; // alas
7085 for a
:= 1 to High(Word) do
7087 FileName
:= Format(ssdir
+'screenshot%.3d.png', [a
]);
7089 if findFileCI(t
, true) then continue
;
7090 if not findFileCI(FileName
) then
7093 st
:= createDiskFile(FileName
);
7095 e_MakeScreenshot(st
, gScreenWidth
, gScreenHeight
);
7100 if not ok
then try DeleteFile(FileName
); except end else g_Console_Add(Format(_lc
[I_CONSOLE_SCREENSHOT
], [ExtractFileName(FileName
)]));
7108 procedure g_Game_InGameMenu(Show
: Boolean);
7110 if (g_ActiveWindow
= nil) and Show
then
7112 if gGameSettings
.GameType
= GT_SINGLE
then
7113 g_GUI_ShowWindow('GameSingleMenu')
7116 if g_Game_IsClient
then
7117 g_GUI_ShowWindow('GameClientMenu')
7119 if g_Game_IsNet
then
7120 g_GUI_ShowWindow('GameServerMenu')
7122 g_GUI_ShowWindow('GameCustomMenu');
7124 g_Sound_PlayEx('MENU_OPEN');
7126 // Ïàóçà ïðè ìåíþ òîëüêî â îäèíî÷íîé èãðå:
7127 if (not g_Game_IsNet
) then
7131 if (g_ActiveWindow
<> nil) and (not Show
) then
7133 // Ïàóçà ïðè ìåíþ òîëüêî â îäèíî÷íîé èãðå:
7134 if (not g_Game_IsNet
) then
7135 g_Game_Pause(False);
7139 procedure g_Game_Pause (Enable
: Boolean);
7143 if not gGameOn
then exit
;
7145 if not (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
]) then exit
;
7148 gPauseMain
:= Enable
;
7150 if (gPause
<> oldPause
) then g_Game_PauseAllSounds(gPause
);
7153 procedure g_Game_HolmesPause (Enable
: Boolean);
7157 if not gGameOn
then exit
;
7158 if not (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
]) then exit
;
7161 gPauseHolmes
:= Enable
;
7163 if (gPause
<> oldPause
) then g_Game_PauseAllSounds(gPause
);
7166 procedure g_Game_PauseAllSounds(Enable
: Boolean);
7171 if gTriggers
<> nil then
7172 for i
:= 0 to High(gTriggers
) do
7173 with gTriggers
[i
] do
7174 if (TriggerType
= TRIGGER_SOUND
) and
7176 Sound
.IsPlaying() then
7178 Sound
.Pause(Enable
);
7182 if gPlayers
<> nil then
7183 for i
:= 0 to High(gPlayers
) do
7184 if gPlayers
[i
] <> nil then
7185 gPlayers
[i
].PauseSounds(Enable
);
7188 if gMusic
<> nil then
7189 gMusic
.Pause(Enable
);
7192 procedure g_Game_StopAllSounds(all
: Boolean);
7196 if gTriggers
<> nil then
7197 for i
:= 0 to High(gTriggers
) do
7198 with gTriggers
[i
] do
7199 if (TriggerType
= TRIGGER_SOUND
) and
7203 if gMusic
<> nil then
7210 procedure g_Game_UpdateTriggerSounds();
7214 if gTriggers
<> nil then
7215 for i
:= 0 to High(gTriggers
) do
7216 with gTriggers
[i
] do
7217 if (TriggerType
= TRIGGER_SOUND
) and
7220 Sound
.IsPlaying() then
7222 if ((gPlayer1
<> nil) and g_CollidePoint(gPlayer1
.GameX
, gPlayer1
.GameY
, X
, Y
, Width
, Height
)) or
7223 ((gPlayer2
<> nil) and g_CollidePoint(gPlayer2
.GameX
, gPlayer2
.GameY
, X
, Y
, Width
, Height
)) then
7225 Sound
.SetPan(0.5 - tgcPan
/255.0);
7226 Sound
.SetVolume(tgcVolume
/255.0);
7229 Sound
.SetCoords(X
+(Width
div 2), Y
+(Height
div 2), tgcVolume
/255.0);
7233 function g_Game_IsWatchedPlayer(UID
: Word): Boolean;
7236 if (gPlayer1
<> nil) and (gPlayer1
.UID
= UID
) then
7241 if (gPlayer2
<> nil) and (gPlayer2
.UID
= UID
) then
7246 if gSpectMode
<> SPECT_PLAYERS
then
7248 if gSpectPID1
= UID
then
7253 if gSpectViewTwo
and (gSpectPID2
= UID
) then
7260 function g_Game_IsWatchedTeam(Team
: Byte): Boolean;
7265 if (gPlayer1
<> nil) and (gPlayer1
.Team
= Team
) then
7270 if (gPlayer2
<> nil) and (gPlayer2
.Team
= Team
) then
7275 if gSpectMode
<> SPECT_PLAYERS
then
7277 Pl
:= g_Player_Get(gSpectPID1
);
7278 if (Pl
<> nil) and (Pl
.Team
= Team
) then
7283 if gSpectViewTwo
then
7285 Pl
:= g_Player_Get(gSpectPID2
);
7286 if (Pl
<> nil) and (Pl
.Team
= Team
) then
7294 procedure g_Game_Message(Msg
: string; Time
: Word);
7296 MessageLineLength
:= (gScreenWidth
- 204) div e_CharFont_GetMaxWidth(gMenuFont
);
7297 MessageText
:= b_Text_Wrap(b_Text_Format(Msg
), MessageLineLength
);
7298 MessageTime
:= Time
;
7301 procedure g_Game_ChatSound(Text: String; Taunt
: Boolean = True);
7303 punct
: Array[0..13] of String =
7304 ('.', ',', ':', ';', '!', '?', '(', ')', '''', '"', '/', '\', '*', '^');
7310 function IsPunctuation(S
: String): Boolean;
7315 if Length(S
) <> 1 then
7317 for i
:= Low(punct
) to High(punct
) do
7318 if S
= punct
[i
] then
7324 function FilterPunctuation(S
: String): String;
7328 for i
:= Low(punct
) to High(punct
) do
7329 S
:= StringReplace(S
, punct
[i
], ' ', [rfReplaceAll
]);
7335 if gUseChatSounds
and Taunt
and (gChatSounds
<> nil) and (Pos(': ', Text) > 0) then
7337 // remove player name
7338 Delete(Text, 1, Pos(': ', Text) + 2 - 1);
7339 // for FullWord check
7340 Text := toLowerCase1251(' ' + Text + ' ');
7341 fpText
:= FilterPunctuation(Text);
7343 for i
:= 0 to Length(gChatSounds
) - 1 do
7346 for j
:= 0 to Length(gChatSounds
[i
].Tags
) - 1 do
7348 if gChatSounds
[i
].FullWord
and (not IsPunctuation(gChatSounds
[i
].Tags
[j
])) then
7349 ok
:= Pos(' ' + gChatSounds
[i
].Tags
[j
] + ' ', fpText
) > 0
7351 ok
:= Pos(gChatSounds
[i
].Tags
[j
], Text) > 0;
7357 gChatSounds
[i
].Sound
.Play();
7363 g_Sound_PlayEx('SOUND_GAME_RADIO');
7366 procedure g_Game_Announce_GoodShot(SpawnerUID
: Word);
7375 if not g_Game_IsWatchedPlayer(SpawnerUID
) then
7379 if goodsnd
[a
].IsPlaying() then
7382 goodsnd
[Random(4)].Play();
7385 procedure g_Game_Announce_KillCombo(Param
: Integer);
7392 UID
:= Param
and $FFFF;
7397 Pl
:= g_Player_Get(UID
);
7406 g_Console_Add(Format(_lc
[I_PLAYER_KILL_2X
], [Name
]), True);
7410 g_Console_Add(Format(_lc
[I_PLAYER_KILL_3X
], [Name
]), True);
7414 g_Console_Add(Format(_lc
[I_PLAYER_KILL_4X
], [Name
]), True);
7418 g_Console_Add(Format(_lc
[I_PLAYER_KILL_MX
], [Name
]), True);
7426 if not g_Game_IsWatchedPlayer(UID
) then
7429 if (not g_Game_IsWatchedPlayer(UID
)) and (c
< 4) then
7433 if killsnd
[n
].IsPlaying() then
7438 procedure g_Game_Announce_BodyKill(SpawnerUID
: Word);
7447 if not g_Game_IsWatchedPlayer(SpawnerUID
) then
7451 if hahasnd
[a
].IsPlaying() then
7454 hahasnd
[Random(3)].Play();
7457 procedure g_Game_StartVote(Command
, Initiator
: string);
7461 if not gVotesEnabled
then Exit
;
7462 if gGameSettings
.GameType
<> GT_SERVER
then Exit
;
7463 if gVoteInProgress
or gVotePassed
then
7465 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_INPROGRESS
], [gVoteCommand
]), True);
7466 MH_SEND_VoteEvent(NET_VE_INPROGRESS
, gVoteCommand
);
7469 gVoteInProgress
:= True;
7470 gVotePassed
:= False;
7471 gVoteTimer
:= gTime
+ gVoteTimeout
* 1000;
7474 gVoteCommand
:= Command
;
7476 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
7477 Need
:= Floor((NetClientCount
+1)/2.0)+1
7479 Need
:= Floor(NetClientCount
/2.0)+1;
7480 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_STARTED
], [Initiator
, Command
, Need
]), True);
7481 MH_SEND_VoteEvent(NET_VE_STARTED
, Initiator
, Command
, Need
);
7484 procedure g_Game_CheckVote
;
7488 if gGameSettings
.GameType
<> GT_SERVER
then Exit
;
7489 if not gVoteInProgress
then Exit
;
7491 if (gTime
>= gVoteTimer
) then
7493 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
7494 Need
:= Floor((NetClientCount
+1)/2.0) + 1
7496 Need
:= Floor(NetClientCount
/2.0) + 1;
7497 if gVoteCount
>= Need
then
7499 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_PASSED
], [gVoteCommand
]), True);
7500 MH_SEND_VoteEvent(NET_VE_PASSED
, gVoteCommand
);
7501 gVotePassed
:= True;
7502 gVoteCmdTimer
:= gTime
+ 5000;
7506 g_Console_Add(_lc
[I_MESSAGE_VOTE_FAILED
], True);
7507 MH_SEND_VoteEvent(NET_VE_FAILED
);
7509 if NetClients
<> nil then
7510 for I
:= Low(NetClients
) to High(NetClients
) do
7511 if NetClients
[i
].Used
then
7512 NetClients
[i
].Voted
:= False;
7513 gVoteInProgress
:= False;
7519 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
7520 Need
:= Floor((NetClientCount
+1)/2.0) + 1
7522 Need
:= Floor(NetClientCount
/2.0) + 1;
7523 if gVoteCount
>= Need
then
7525 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_PASSED
], [gVoteCommand
]), True);
7526 MH_SEND_VoteEvent(NET_VE_PASSED
, gVoteCommand
);
7527 gVoteInProgress
:= False;
7528 gVotePassed
:= True;
7529 gVoteCmdTimer
:= gTime
+ 5000;
7532 if NetClients
<> nil then
7533 for I
:= Low(NetClients
) to High(NetClients
) do
7534 if NetClients
[i
].Used
then
7535 NetClients
[i
].Voted
:= False;
7540 procedure g_Game_LoadMapList(FileName
: string);
7548 if not FileExists(FileName
) then Exit
;
7550 AssignFile(ListFile
, FileName
);
7552 while not EOF(ListFile
) do
7554 ReadLn(ListFile
, s
);
7557 if s
= '' then Continue
;
7559 SetLength(MapList
, Length(MapList
)+1);
7560 MapList
[High(MapList
)] := s
;
7562 CloseFile(ListFile
);
7565 procedure g_Game_SetDebugMode();
7568 // ×èòû (äàæå â ñâîåé èãðå):
7572 procedure g_Game_SetLoadingText(Text: String; Max
: Integer; reWrite
: Boolean);
7576 if Length(LoadingStat
.Msgs
) = 0 then
7582 begin // Ïåðåõîäèì íà ñëåäóþùóþ ñòðîêó èëè ñêðîëëèðóåì:
7583 if NextMsg
= Length(Msgs
) then
7585 for i
:= 0 to High(Msgs
)-1 do
7586 Msgs
[i
] := Msgs
[i
+1];
7594 Msgs
[NextMsg
-1] := Text;
7598 PBarWasHere
:= false;
7601 g_ActiveWindow
:= nil;
7603 ProcessLoading(true);
7606 procedure g_Game_StepLoading(Value
: Integer = -1);
7617 if (ShowCount
> LOADING_SHOW_STEP
) or (Value
> -1) then
7625 procedure g_Game_ClearLoading();
7634 len
:= ((gScreenHeight
div 3)*2 - 50) div LOADING_INTERLINE
;
7635 if len
< 1 then len
:= 1;
7636 SetLength(Msgs
, len
);
7637 for len
:= Low(Msgs
) to High(Msgs
) do
7640 PBarWasHere
:= false;
7644 procedure Parse_Params(var pars
: TParamStrValues
);
7651 while i
<= ParamCount
do
7654 if (s
[1] = '-') and (Length(s
) > 1) then
7656 if (s
[2] = '-') and (Length(s
) > 2) then
7657 begin // Îäèíî÷íûé ïàðàìåòð
7658 SetLength(pars
, Length(pars
) + 1);
7659 with pars
[High(pars
)] do
7661 Name
:= LowerCase(s
);
7666 if (i
< ParamCount
) then
7667 begin // Ïàðàìåòð ñî çíà÷åíèåì
7669 SetLength(pars
, Length(pars
) + 1);
7670 with pars
[High(pars
)] do
7672 Name
:= LowerCase(s
);
7673 Value
:= LowerCase(ParamStr(i
));
7682 function Find_Param_Value(var pars
: TParamStrValues
; aName
: String): String;
7687 for i
:= 0 to High(pars
) do
7688 if pars
[i
].Name
= aName
then
7690 Result
:= pars
[i
].Value
;
7695 procedure g_Game_Process_Params();
7697 pars
: TParamStrValues
;
7700 LimT
, LimS
: Integer;
7711 s
:= Find_Param_Value(pars
, '--debug');
7714 g_Game_SetDebugMode();
7715 s
:= Find_Param_Value(pars
, '--netdump');
7720 // Connect when game loads
7721 ip
:= Find_Param_Value(pars
, '-connect');
7725 s
:= Find_Param_Value(pars
, '-port');
7726 if (s
= '') or not TryStrToInt(s
, Port
) then
7729 s
:= Find_Param_Value(pars
, '-pw');
7731 g_Game_StartClient(ip
, Port
, s
);
7735 s
:= LowerCase(Find_Param_Value(pars
, '-dbg-mainwad'));
7738 gDefaultMegawadStart
:= s
;
7741 if (Find_Param_Value(pars
, '--dbg-mainwad-restore') <> '') or
7742 (Find_Param_Value(pars
, '--dbg-mainwad-default') <> '') then
7744 gDefaultMegawadStart
:= DF_Default_Megawad_Start
;
7747 // Start map when game loads:
7748 map
:= LowerCase(Find_Param_Value(pars
, '-map'));
7749 if isWadPath(map
) then
7752 s
:= Find_Param_Value(pars
, '-gm');
7753 GMode
:= g_Game_TextToMode(s
);
7754 if GMode
= GM_NONE
then GMode
:= GM_DM
;
7755 if GMode
= GM_SINGLE
then GMode
:= GM_COOP
;
7758 s
:= Find_Param_Value(pars
, '-limt');
7759 if (s
= '') or (not TryStrToInt(s
, LimT
)) then
7765 s
:= Find_Param_Value(pars
, '-lims');
7766 if (s
= '') or (not TryStrToInt(s
, LimS
)) then
7772 s
:= Find_Param_Value(pars
, '-lives');
7773 if (s
= '') or (not TryStrToInt(s
, Lives
)) then
7779 s
:= Find_Param_Value(pars
, '-opt');
7781 Opt
:= GAME_OPTION_ALLOWEXIT
or GAME_OPTION_BOTVSPLAYER
or GAME_OPTION_BOTVSMONSTER
7783 Opt
:= StrToIntDef(s
, 0);
7785 Opt
:= GAME_OPTION_ALLOWEXIT
or GAME_OPTION_BOTVSPLAYER
or GAME_OPTION_BOTVSMONSTER
;
7788 s
:= Find_Param_Value(pars
, '--close');
7792 // Override map to test:
7793 s
:= LowerCase(Find_Param_Value(pars
, '-testmap'));
7795 gTestMap
:= MapsDir
+ s
;
7797 // Delete test map after play:
7798 s
:= Find_Param_Value(pars
, '--testdelete');
7801 gMapToDelete
:= MapsDir
+ map
;
7802 e_WriteLog('"--testdelete" is deprecated, use --tempdelete.', TMsgType
.Fatal
);
7806 // Delete temporary WAD after play:
7807 s
:= Find_Param_Value(pars
, '--tempdelete');
7808 if (s
<> '') and (gTestMap
<> '') then
7810 gMapToDelete
:= gTestMap
;
7811 gTempDelete
:= True;
7814 // Number of players:
7815 s
:= Find_Param_Value(pars
, '-pl');
7817 n
:= DEFAULT_PLAYERS
7819 n
:= StrToIntDef(s
, DEFAULT_PLAYERS
);
7822 s
:= Find_Param_Value(pars
, '-port');
7823 if (s
= '') or not TryStrToInt(s
, Port
) then
7824 g_Game_StartCustom(map
, GMode
, LimT
, LimS
, Lives
, Opt
, n
)
7826 g_Game_StartServer(map
, GMode
, LimT
, LimS
, Lives
, Opt
, n
, 0, Port
);
7829 // Execute script when game loads:
7830 s
:= Find_Param_Value(pars
, '-exec');
7833 if not isWadPath(s
) then
7834 s
:= GameDir
+ '/' + s
;
7839 if IOResult
<> 0 then
7841 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], ['Failed to read file: ' + s
]), TMsgType
.Warning
);
7842 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_READ
], [s
]));
7846 e_WriteLog('Executing script: ' + s
, TMsgType
.Notify
);
7847 g_Console_Add(Format(_lc
[I_CONSOLE_EXEC
], [s
]));
7852 if IOResult
<> 0 then
7854 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], ['Failed to read file: ' + s
]), TMsgType
.Warning
);
7855 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_READ
], [s
]));
7859 if Pos('#', s
) <> 1 then // script comment
7860 g_Console_Process(s
, True);
7871 conRegVar('pf_draw_frame', @g_profile_frame_draw
, 'draw frame rendering profiles', 'render profiles');
7872 //conRegVar('pf_update_frame', @g_profile_frame_update, 'draw frame updating profiles', 'update profiles');
7873 conRegVar('pf_coldet', @g_profile_collision
, 'draw collision detection profiles', 'coldet profiles');
7874 conRegVar('pf_los', @g_profile_los
, 'draw monster LOS profiles', 'monster LOS profiles');
7876 conRegVar('r_sq_draw', @gdbg_map_use_accel_render
, 'accelerated spatial queries in rendering', 'accelerated rendering');
7877 conRegVar('cd_sq_enabled', @gdbg_map_use_accel_coldet
, 'accelerated spatial queries in map coldet', 'accelerated map coldet');
7878 conRegVar('mon_sq_enabled', @gmon_debug_use_sqaccel
, 'accelerated spatial queries for monsters', 'accelerated monster coldet');
7879 conRegVar('wtrace_sq_enabled', @gwep_debug_fast_trace
, 'accelerated spatial queries for weapon hitscan trace', 'accelerated weapon hitscan');
7881 conRegVar('pr_enabled', @gpart_dbg_enabled
, 'enable/disable particles', 'particles');
7882 conRegVar('pr_phys_enabled', @gpart_dbg_phys_enabled
, 'enable/disable particle physics', 'particle physics');
7884 conRegVar('los_enabled', @gmon_dbg_los_enabled
, 'enable/disable monster LOS calculations', 'monster LOS', true);
7885 conRegVar('mon_think', @gmon_debug_think
, 'enable/disable monster thinking', 'monster thinking', true);
7887 {$IFDEF ENABLE_HOLMES}
7888 conRegVar('dbg_holmes', @g_holmes_enabled
, 'enable/disable Holmes', 'Holmes', true);
7891 conRegVar('dbg_ignore_level_bounds', @g_dbg_ignore_bounds
, 'ignore level bounds', '', false);
7893 conRegVar('r_scale', @g_dbg_scale
, 0.01, 100.0, 'render scale', '', false);
7895 conRegVar('light_enabled', @gwin_k8_enable_light_experiments
, 'enable/disable dynamic lighting', 'lighting');
7896 conRegVar('light_player_halo', @g_playerLight
, 'enable/disable player halo', 'player light halo');
7898 conRegVar('r_smallmap_align_h', @r_smallmap_h
, 'halign: 0: left; 1: center; 2: right', 'horizontal aligning of small maps');
7899 conRegVar('r_smallmap_align_v', @r_smallmap_v
, 'valign: 0: top; 1: center; 2: bottom', 'vertial aligning of small maps');
7901 conRegVar('r_showfps', @gShowFPS
, 'draw fps counter', 'draw fps counter');
7902 conRegVar('r_showtime', @gShowTime
, 'show game time', 'show game time');