1 (* Copyright (C) Doom 2D: Forever Developers
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, version 3 of the License ONLY.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 {$INCLUDE ../shared/a_modes.inc}
23 g_basic
, g_player
, e_graphics
, g_res_downloader
,
24 g_sound
, g_gui
, utils
, md5
, mempool
, xprofiler
,
28 TGameSettings
= record
35 ItemRespawnTime
: Word;
36 ItemRespawnRandom
: Word;
37 RulezRespawnTime
: Word;
38 RulezRespawnRandom
: Word;
49 TDelayedEvent
= record
58 Sound
: TPlayableSound
;
59 Tags
: Array of String;
63 TPlayerSettings
= record
68 // ones below are sent only to the server
70 WeaponPreferences
: Array[WP_FIRST
..WP_LAST
+1] of Byte;
87 function g_Game_IsNet(): Boolean;
88 function g_Game_IsServer(): Boolean;
89 function g_Game_IsClient(): Boolean;
90 procedure g_Game_Init();
91 procedure g_Game_Free (freeTextures
: Boolean=true);
92 procedure g_Game_LoadData();
93 procedure g_Game_FreeData();
94 procedure g_Game_Update();
95 procedure g_Game_PreUpdate();
96 procedure g_Game_Draw();
97 procedure g_Game_Quit();
98 procedure g_Game_SetupScreenSize();
99 procedure g_Game_ChangeResolution(newWidth
, newHeight
: Word; nowFull
, nowMax
: Boolean);
100 function g_Game_ModeToText(Mode
: Byte): string;
101 function g_Game_TextToMode(Mode
: string): Byte;
102 procedure g_Game_ExecuteEvent(Name
: String);
103 function g_Game_DelayEvent(DEType
: Byte; Time
: LongWord
; Num
: Integer = 0; Str
: String = ''): Integer;
104 procedure g_Game_AddPlayer(Team
: Byte = TEAM_NONE
);
105 procedure g_Game_RemovePlayer();
106 procedure g_Game_Spectate();
107 procedure g_Game_SpectateCenterView();
108 procedure g_Game_StartSingle(Map
: String; TwoPlayers
: Boolean; nPlayers
: Byte);
109 procedure g_Game_StartCustom(Map
: String; GameMode
: Byte; TimeLimit
, ScoreLimit
: Word; MaxLives
: Byte; Options
: LongWord
; nPlayers
: Byte);
110 procedure g_Game_StartServer(Map
: String; GameMode
: Byte; TimeLimit
, ScoreLimit
: Word; MaxLives
: Byte; Options
: LongWord
; nPlayers
: Byte; IPAddr
: LongWord
; Port
: Word);
111 procedure g_Game_StartClient(Addr
: String; Port
: Word; PW
: String);
112 procedure g_Game_Restart();
113 procedure g_Game_RestartLevel();
114 procedure g_Game_RestartRound(NoMapRestart
: Boolean = False);
115 function g_Game_ClientWAD (NewWAD
: String; const WHash
: TMD5Digest
): AnsiString
;
116 function g_Game_StartMap(asMegawad
: Boolean; Map
: String; Force
: Boolean = False; const oldMapPath
: AnsiString
=''): Boolean;
117 procedure g_Game_ChangeMap(const MapPath
: String);
118 procedure g_Game_ExitLevel(const Map
: AnsiString
);
119 function g_Game_GetFirstMap(WAD
: String): String;
120 function g_Game_GetNextMap(): String;
121 procedure g_Game_NextLevel();
122 procedure g_Game_Pause(Enable
: Boolean);
123 procedure g_Game_HolmesPause(Enable
: Boolean);
124 procedure g_Game_InGameMenu(Show
: Boolean);
125 function g_Game_IsWatchedPlayer(UID
: Word): Boolean;
126 function g_Game_IsWatchedTeam(Team
: Byte): Boolean;
127 procedure g_Game_Message(Msg
: String; Time
: Word);
128 procedure g_Game_LoadMapList(FileName
: String);
129 procedure g_Game_PauseAllSounds(Enable
: Boolean);
130 procedure g_Game_StopAllSounds(all
: Boolean);
131 procedure g_Game_UpdateTriggerSounds();
132 function g_Game_GetMegaWADInfo(WAD
: String): TMegaWADInfo
;
133 procedure g_Game_ChatSound(Text: String; Taunt
: Boolean = True);
134 procedure g_Game_Announce_GoodShot(SpawnerUID
: Word);
135 procedure g_Game_Announce_KillCombo(Param
: Integer);
136 procedure g_Game_Announce_BodyKill(SpawnerUID
: Word);
137 procedure g_Game_Effect_Bubbles(fX
, fY
: Integer; count
: Word; devX
, devY
: Byte; Silent
: Boolean = False);
138 procedure g_Game_StartVote(Command
, Initiator
: string);
139 procedure g_Game_CheckVote
;
140 procedure g_TakeScreenShot(Filename
: string = '');
141 procedure g_FatalError(Text: String);
142 procedure g_SimpleError(Text: String);
143 function g_Game_IsTestMap(): Boolean;
144 procedure g_Game_DeleteTestMap();
145 procedure GameCVars(P
: SSArray
);
146 procedure PlayerSettingsCVars(P
: SSArray
);
147 procedure SystemCommands(P
: SSArray
);
148 procedure GameCommands(P
: SSArray
);
149 procedure GameCheats(P
: SSArray
);
150 procedure DebugCommands(P
: SSArray
);
151 procedure g_Game_Process_Params
;
152 procedure g_Game_SetLoadingText(Text: String; Max
: Integer; reWrite
: Boolean);
153 procedure g_Game_StepLoading(Value
: Integer = -1);
154 procedure g_Game_ClearLoading();
155 procedure g_Game_SetDebugMode();
156 procedure DrawLoadingStat();
157 procedure DrawMenuBackground(tex
: AnsiString
);
159 { procedure SetWinPause(Enable: Boolean); }
164 LOADING_SHOW_STEP
= 100;
165 LOADING_INTERLINE
= 20;
180 MESSAGE_DIKEY
= WM_USER
+ 1;
185 EXIT_ENDLEVELSINGLE
= 4;
186 EXIT_ENDLEVELCUSTOM
= 5;
188 GAME_OPTION_RESERVED
= 1;
189 GAME_OPTION_TEAMDAMAGE
= 2;
190 GAME_OPTION_ALLOWEXIT
= 4;
191 GAME_OPTION_WEAPONSTAY
= 8;
192 GAME_OPTION_MONSTERS
= 16;
193 GAME_OPTION_BOTVSPLAYER
= 32;
194 GAME_OPTION_BOTVSMONSTER
= 64;
195 GAME_OPTION_DMKEYS
= 128;
196 GAME_OPTION_TEAMHITTRACE
= 256;
197 GAME_OPTION_TEAMHITPROJECTILE
= 512;
198 GAME_OPTION_TEAMABSORBDAMAGE
= 1024;
199 GAME_OPTION_ALLOWDROPFLAG
= 2048;
200 GAME_OPTION_THROWFLAG
= 4096;
201 GAME_OPTION_RULEZRANDOM
= 8192;
202 GAME_OPTION_ITEMALLRANDOM
= 16384;
203 GAME_OPTION_ITEMHELPRANDOM
= 32768;
204 GAME_OPTION_ITEMAMMORANDOM
= 65536;
205 GAME_OPTION_ITEMWEAPONRANDOM
= 131072;
210 STATE_INTERCUSTOM
= 3;
211 STATE_INTERSINGLE
= 4;
217 LMS_RESPAWN_NONE
= 0;
218 LMS_RESPAWN_WARMUP
= 1;
219 LMS_RESPAWN_FINAL
= 2;
236 CONFIG_FILENAME
= 'Doom2DF.cfg';
238 TEST_MAP_NAME
= '$$$_TEST_$$$';
240 STD_PLAYER_MODEL
= 'Doomer';
248 STATFILE_VERSION
= $03;
252 gGameSettings
: TGameSettings
;
253 gPlayer1Settings
: TPlayerSettings
;
254 gPlayer2Settings
: TPlayerSettings
;
256 gPlayerScreenSize
: TDFPoint
;
257 gPlayer1ScreenCoord
: TDFPoint
;
258 gPlayer2ScreenCoord
: TDFPoint
;
259 gPlayer1
: TPlayer
= nil;
260 gPlayer2
: TPlayer
= nil;
261 gPlayerDrawn
: TPlayer
= nil;
263 gLerpFactor
: Single = 1.0;
264 gSwitchGameMode
: Byte = GM_DM
;
265 gHearPoint1
, gHearPoint2
: THearPoint
;
266 gSoundEffectsDF
: Boolean = False;
267 gSoundTriggerTime
: Word = 0;
268 gAnnouncer
: Integer = ANNOUNCE_NONE
;
269 goodsnd
: array[0..3] of TPlayableSound
;
270 killsnd
: array[0..3] of TPlayableSound
;
271 hahasnd
: array[0..2] of TPlayableSound
;
272 sound_get_flag
: array[0..1] of TPlayableSound
;
273 sound_lost_flag
: array[0..1] of TPlayableSound
;
274 sound_ret_flag
: array[0..1] of TPlayableSound
;
275 sound_cap_flag
: array[0..1] of TPlayableSound
;
276 gBodyKillEvent
: Integer = -1;
277 gDefInterTime
: ShortInt
= -1;
278 gInterEndTime
: LongWord
= 0;
279 gInterTime
: LongWord
= 0;
280 gServInterTime
: Byte = 0;
281 gGameStartTime
: LongWord
= 0;
282 gTotalMonsters
: Integer = 0;
283 gPauseMain
: Boolean = false;
284 gPauseHolmes
: Boolean = false;
285 gShowTime
: Boolean = False;
286 gShowFPS
: Boolean = False;
287 gShowScore
: Boolean = True;
288 gShowStat
: Boolean = True;
289 gShowPIDs
: Boolean = False;
290 gShowKillMsg
: Boolean = True;
291 gShowLives
: Boolean = True;
292 gShowPing
: Boolean = False;
293 gShowMap
: Boolean = False;
295 gState
: Byte = STATE_NONE
;
297 sWidth
, sHeight
: Word;
298 gSpectMode
: Byte = SPECT_NONE
;
299 gSpectHUD
: Boolean = True;
300 gSpectKeyPress
: Boolean = False;
301 gSpectX
: Integer = 0;
302 gSpectY
: Integer = 0;
303 gSpectStep
: Byte = 8;
304 gSpectViewTwo
: Boolean = False;
305 gSpectPID1
: Integer = -1;
306 gSpectPID2
: Integer = -1;
307 gSpectAuto
: Boolean = False;
308 gSpectAutoNext
: LongWord
;
309 gSpectAutoStepX
: Integer;
310 gSpectAutoStepY
: Integer;
311 gMusic
: TMusic
= nil;
312 gLoadGameMode
: Boolean;
313 gCheats
: Boolean = False;
314 gMapOnce
: Boolean = False;
315 gMapToDelete
: String;
316 gTempDelete
: Boolean = False;
317 gLastMap
: Boolean = False;
320 gResolutionChange
: Boolean = False;
321 gRC_Width
, gRC_Height
: Integer;
322 gRC_FullScreen
, gRC_Maximized
: Boolean;
323 gLanguageChange
: Boolean = False;
324 gDebugMode
: Boolean = False;
325 g_debug_Sounds
: Boolean = False;
326 g_debug_Frames
: Boolean = False;
327 g_debug_WinMsgs
: Boolean = False;
328 g_debug_MonsterOff
: Boolean = False;
329 g_debug_BotAIOff
: Byte = 0;
330 g_debug_HealthBar
: Boolean = False;
331 g_Debug_Player
: Boolean = False;
332 gCoopMonstersKilled
: Word = 0;
333 gCoopSecretsFound
: Word = 0;
334 gCoopTotalMonstersKilled
: Word = 0;
335 gCoopTotalSecretsFound
: Word = 0;
336 gCoopTotalMonsters
: Word = 0;
337 gCoopTotalSecrets
: Word = 0;
338 gStatsOff
: Boolean = False;
339 gStatsPressed
: Boolean = False;
340 gExitByTrigger
: Boolean = False;
341 gNextMap
: String = '';
342 gLMSRespawn
: Byte = LMS_RESPAWN_NONE
;
343 gLMSRespawnTime
: Cardinal = 0;
344 gLMSSoftSpawn
: Boolean = False;
345 gMissionFailed
: Boolean = False;
346 gVoteInProgress
: Boolean = False;
347 gVotePassed
: Boolean = False;
348 gVoteCommand
: string = '';
349 gVoteTimer
: Cardinal = 0;
350 gVoteCmdTimer
: Cardinal = 0;
351 gVoteCount
: Integer = 0;
352 gVoteTimeout
: Cardinal = 30;
353 gVoted
: Boolean = False;
354 gVotesEnabled
: Boolean = True;
355 gEvents
: Array of TGameEvent
;
356 gDelayedEvents
: Array of TDelayedEvent
;
357 gUseChatSounds
: Boolean = True;
358 gChatSounds
: Array of TChatSound
;
359 gWeaponAction
: Array [0..1, WP_FACT
..WP_LACT
] of Boolean; // [player, weapon_action]
360 gSelectWeapon
: Array [0..1, WP_FIRST
..WP_LAST
] of Boolean; // [player, weapon]
361 gInterReadyCount
: Integer = 0;
362 gMaxBots
: Integer = 127;
364 g_dbg_ignore_bounds
: Boolean = false;
365 r_smallmap_h
: Integer = 0; // 0: left; 1: center; 2: right
366 r_smallmap_v
: Integer = 2; // 0: top; 1: center; 2: bottom
368 // move button values:
369 // bits 0-1: l/r state:
370 // 0: neither left, nor right pressed
373 // bits 4-5: l/r state when strafe was pressed
374 P1MoveButton
: Byte = 0;
375 P2MoveButton
: Byte = 0;
377 g_profile_frame_update
: Boolean = false;
378 g_profile_frame_draw
: Boolean = false;
379 g_profile_collision
: Boolean = false;
380 g_profile_los
: Boolean = false;
381 g_profile_history_size
: Integer = 1000;
383 g_rlayer_back
: Boolean = true;
384 g_rlayer_step
: Boolean = true;
385 g_rlayer_wall
: Boolean = true;
386 g_rlayer_door
: Boolean = true;
387 g_rlayer_acid1
: Boolean = true;
388 g_rlayer_acid2
: Boolean = true;
389 g_rlayer_water
: Boolean = true;
390 g_rlayer_fore
: Boolean = true;
393 procedure g_ResetDynlights ();
394 procedure g_AddDynLight (x
, y
, radius
: Integer; r
, g
, b
, a
: Single);
395 procedure g_DynLightExplosion (x
, y
, radius
: Integer; r
, g
, b
: Single);
397 function conIsCheatsEnabled (): Boolean; inline;
398 function gPause (): Boolean; inline;
404 {$INCLUDE ../nogl/noGLuses.inc}
405 {$IFDEF ENABLE_HOLMES}
408 e_texture
, e_res
, g_textures
, g_window
, g_menu
,
409 e_input
, e_log
, g_console
, g_items
, g_map
, g_panel
,
410 g_playermodel
, g_gfx
, g_options
, Math
,
411 g_triggers
, g_monsters
, e_sound
, CONFIG
,
412 g_language
, g_net
, g_main
, g_phys
,
413 ENet
, e_msg
, g_netmsg
, g_netmaster
,
414 sfs
, wadreader
, g_system
;
418 hasPBarGfx
: Boolean = false;
421 // ////////////////////////////////////////////////////////////////////////// //
422 function gPause (): Boolean; inline; begin result
:= gPauseMain
or gPauseHolmes
; end;
425 // ////////////////////////////////////////////////////////////////////////// //
426 function conIsCheatsEnabled (): Boolean; inline;
429 if g_Game_IsNet
then exit
;
430 if not gDebugMode
then
432 //if not gCheats then exit;
433 if not (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
]) then exit
;
434 if not (gGameSettings
.GameMode
in [GM_COOP
, GM_SINGLE
]) then exit
;
440 // ////////////////////////////////////////////////////////////////////////// //
442 profileFrameDraw
: TProfiler
= nil;
445 // ////////////////////////////////////////////////////////////////////////// //
448 x
, y
, radius
: Integer;
451 exploRadius
: Integer;
455 g_dynLights
: array of TDynLight
= nil;
456 g_dynLightCount
: Integer = 0;
457 g_playerLight
: Boolean = false;
459 procedure g_ResetDynlights ();
463 if not gwin_has_stencil
then begin g_dynLightCount
:= 0; exit
; end;
465 for idx
:= 0 to g_dynLightCount
-1 do
467 if g_dynLights
[idx
].exploCount
= -666 then
474 Inc(g_dynLights
[idx
].exploCount
);
475 if (g_dynLights
[idx
].exploCount
< 10) then
477 g_dynLights
[idx
].radius
:= g_dynLights
[idx
].exploRadius
+g_dynLights
[idx
].exploCount
*8;
478 g_dynLights
[idx
].a
:= 0.4+g_dynLights
[idx
].exploCount
/10;
479 if (g_dynLights
[idx
].a
> 0.8) then g_dynLights
[idx
].a
:= 0.8;
480 if lnum
<> idx
then g_dynLights
[lnum
] := g_dynLights
[idx
];
485 g_dynLightCount
:= lnum
;
488 procedure g_AddDynLight (x
, y
, radius
: Integer; r
, g
, b
, a
: Single);
490 if not gwin_has_stencil
then exit
;
491 if g_dynLightCount
= length(g_dynLights
) then SetLength(g_dynLights
, g_dynLightCount
+1024);
492 g_dynLights
[g_dynLightCount
].x
:= x
;
493 g_dynLights
[g_dynLightCount
].y
:= y
;
494 g_dynLights
[g_dynLightCount
].radius
:= radius
;
495 g_dynLights
[g_dynLightCount
].r
:= r
;
496 g_dynLights
[g_dynLightCount
].g
:= g
;
497 g_dynLights
[g_dynLightCount
].b
:= b
;
498 g_dynLights
[g_dynLightCount
].a
:= a
;
499 g_dynLights
[g_dynLightCount
].exploCount
:= -666;
500 Inc(g_dynLightCount
);
503 procedure g_DynLightExplosion (x
, y
, radius
: Integer; r
, g
, b
: Single);
505 if not gwin_has_stencil
then exit
;
506 if g_dynLightCount
= length(g_dynLights
) then SetLength(g_dynLights
, g_dynLightCount
+1024);
507 g_dynLights
[g_dynLightCount
].x
:= x
;
508 g_dynLights
[g_dynLightCount
].y
:= y
;
509 g_dynLights
[g_dynLightCount
].radius
:= 0;
510 g_dynLights
[g_dynLightCount
].exploRadius
:= radius
;
511 g_dynLights
[g_dynLightCount
].r
:= r
;
512 g_dynLights
[g_dynLightCount
].g
:= g
;
513 g_dynLights
[g_dynLightCount
].b
:= b
;
514 g_dynLights
[g_dynLightCount
].a
:= 0;
515 g_dynLights
[g_dynLightCount
].exploCount
:= 0;
516 Inc(g_dynLightCount
);
520 // ////////////////////////////////////////////////////////////////////////// //
521 function calcProfilesHeight (prof
: TProfiler
): Integer;
524 if (prof
= nil) then exit
;
525 if (length(prof
.bars
) = 0) then exit
;
526 result
:= length(prof
.bars
)*(16+2);
530 function drawProfiles (x
, y
: Integer; prof
: TProfiler
): Integer;
537 if (prof
= nil) then exit
;
539 if (length(prof
.bars
) = 0) then exit
;
541 hgt
:= calcProfilesHeight(prof
);
542 if (x
< 0) then x
:= gScreenWidth
-(wdt
-1)+x
;
543 if (y
< 0) then y
:= gScreenHeight
-(hgt
-1)+y
;
545 //e_DrawFillQuad(x, y, x+wdt-1, y+hgt-1, 255, 255, 255, 200, B_BLEND);
546 //e_DrawFillQuad(x, y, x+wdt-1, y+hgt-1, 20, 20, 20, 0, B_NONE);
547 e_DarkenQuadWH(x
, y
, wdt
, hgt
, 150);
550 for ii
:= 0 to High(prof
.bars
) do
552 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);
559 // ////////////////////////////////////////////////////////////////////////// //
561 TEndCustomGameStat
= record
562 PlayerStat
: TPlayerStatArray
;
566 Map
, MapName
: String;
569 TEndSingleGameStat
= record
570 PlayerStat
: Array [0..1] of record
576 TotalSecrets
: Integer;
579 TLoadingStat
= record
583 Msgs
: Array of String;
585 PBarWasHere
: Boolean; // did we draw a progress bar for this message?
588 TParamStrValue
= record
593 TParamStrValues
= Array of TParamStrValue
;
596 INTER_ACTION_TEXT
= 1;
597 INTER_ACTION_PIC
= 2;
598 INTER_ACTION_MUSIC
= 3;
602 FPSCounter
, UPSCounter
: Word;
603 FPSTime
, UPSTime
: LongWord
;
604 DataLoaded
: Boolean = False;
605 IsDrawStat
: Boolean = False;
606 CustomStat
: TEndCustomGameStat
;
607 SingleStat
: TEndSingleGameStat
;
608 LoadingStat
: TLoadingStat
;
609 EndingGameCounter
: Byte = 0;
612 MessageLineLength
: Integer = 80;
613 MapList
: SSArray
= nil;
614 MapIndex
: Integer = -1;
615 InterReadyTime
: Integer = -1;
616 StatShotDone
: Boolean = False;
617 StatFilename
: string = ''; // used by stat screenshot to save with the same name as the csv
618 StatDate
: string = '';
624 text: Array of ShortString
;
625 anim
: Array of ShortString
;
626 pic
: Array of ShortString
;
627 mus
: Array of ShortString
;
629 triggers
: Array of record
631 actions
: Array of record
632 action
, p1
, p2
: Integer;
635 cur_trigger
: Integer;
648 function Compare(a
, b
: TPlayerStat
): Integer;
650 if a
.Spectator
then Result
:= 1
651 else if b
.Spectator
then Result
:= -1
652 else if a
.Frags
< b
.Frags
then Result
:= 1
653 else if a
.Frags
> b
.Frags
then Result
:= -1
654 else if a
.Deaths
< b
.Deaths
then Result
:= -1
655 else if a
.Deaths
> b
.Deaths
then Result
:= 1
656 else if a
.Kills
< b
.Kills
then Result
:= -1
660 procedure SortGameStat(var stat
: TPlayerStatArray
);
665 if stat
= nil then Exit
;
667 for I
:= High(stat
) downto Low(stat
) do
668 for J
:= Low(stat
) to High(stat
) - 1 do
669 if Compare(stat
[J
], stat
[J
+ 1]) = 1 then
672 stat
[J
] := stat
[J
+ 1];
677 // saves a shitty CSV containing the game stats passed to it
678 procedure SaveGameStat(Stat
: TEndCustomGameStat
; Path
: string);
681 dir
, fname
, map
, mode
, etime
: String;
685 dir
:= e_GetWriteableDir(StatsDirs
);
686 // stats are placed in stats/yy/mm/dd/*.csv
687 fname
:= e_CatPath(dir
, Path
);
688 ForceDirectories(fname
); // ensure yy/mm/dd exists within the stats dir
689 fname
:= e_CatPath(fname
, StatFilename
+ '.csv');
690 AssignFile(s
, fname
);
692 SetTextCodePage(s
, CP_UTF8
);
694 // line 1: stats ver, datetime, server name, map name, game mode, time limit, score limit, dmflags, game time, num players
695 if g_Game_IsNet
then fname
:= NetServerName
else fname
:= '';
696 map
:= g_ExtractWadNameNoPath(gMapInfo
.Map
) + ':/' + g_ExtractFileName(gMapInfo
.Map
);
697 mode
:= g_Game_ModeToText(Stat
.GameMode
);
698 etime
:= Format('%d:%.2d:%.2d', [
699 Stat
.GameTime
div 1000 div 3600,
700 (Stat
.GameTime
div 1000 div 60) mod 60,
701 Stat
.GameTime
div 1000 mod 60
703 WriteLn(s
, 'stats_ver,datetime,server,map,mode,timelimit,scorelimit,dmflags,time,num_players');
704 WriteLn(s
, Format('%d,%s,%s,%s,%s,%u,%u,%u,%s,%d', [
710 gGameSettings
.TimeLimit
,
711 gGameSettings
.ScoreLimit
,
712 gGameSettings
.Options
,
714 Length(Stat
.PlayerStat
)
716 // line 2: game specific shit
717 // if it's a team game: red score, blue score
718 // if it's a coop game: monsters killed, monsters total, secrets found, secrets total
720 if Stat
.GameMode
in [GM_TDM
, GM_CTF
] then
722 Format('red_score,blue_score' + LineEnding
+ '%d,%d', [Stat
.TeamStat
[TEAM_RED
].Score
, Stat
.TeamStat
[TEAM_BLUE
].Score
]))
723 else if Stat
.GameMode
in [GM_COOP
, GM_SINGLE
] then
725 Format('mon_killed,mon_total,secrets_found,secrets_total' + LineEnding
+ '%d,%d,%d,%d',[gCoopMonstersKilled
, gTotalMonsters
, gCoopSecretsFound
, gSecretsCount
]));
726 // lines 3-...: team, player name, frags, deaths
727 WriteLn(s
, 'team,name,frags,deaths');
728 for I
:= Low(Stat
.PlayerStat
) to High(Stat
.PlayerStat
) do
729 with Stat
.PlayerStat
[I
] do
730 WriteLn(s
, Format('%d,%s,%d,%d', [Team
, dquoteStr(Name
), Frags
, Deaths
]));
732 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_WRITE
], [fname
]));
735 g_Console_Add('could not create gamestats file "' + fname
+ '"');
740 procedure ClearDebugCvars();
742 g_debug_Sounds
:= False;
743 g_debug_Frames
:= False;
744 g_debug_WinMsgs
:= False;
745 g_debug_MonsterOff
:= False;
746 g_debug_BotAIOff
:= 0;
747 g_debug_HealthBar
:= False;
748 g_Debug_Player
:= False;
751 function g_Game_ModeToText(Mode
: Byte): string;
755 GM_DM
: Result
:= _lc
[I_MENU_GAME_TYPE_DM
];
756 GM_TDM
: Result
:= _lc
[I_MENU_GAME_TYPE_TDM
];
757 GM_CTF
: Result
:= _lc
[I_MENU_GAME_TYPE_CTF
];
758 GM_COOP
: Result
:= _lc
[I_MENU_GAME_TYPE_COOP
];
759 GM_SINGLE
: Result
:= _lc
[I_MENU_GAME_TYPE_SINGLE
];
763 function g_Game_TextToMode(Mode
: string): Byte;
766 Mode
:= UpperCase(Mode
);
767 if Mode
= _lc
[I_MENU_GAME_TYPE_DM
] then
772 if Mode
= _lc
[I_MENU_GAME_TYPE_TDM
] then
777 if Mode
= _lc
[I_MENU_GAME_TYPE_CTF
] then
782 if Mode
= _lc
[I_MENU_GAME_TYPE_COOP
] then
787 if Mode
= _lc
[I_MENU_GAME_TYPE_SINGLE
] then
794 function g_Game_IsNet(): Boolean;
796 Result
:= (gGameSettings
.GameType
in [GT_SERVER
, GT_CLIENT
]);
799 function g_Game_IsServer(): Boolean;
801 Result
:= (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
, GT_SERVER
]);
804 function g_Game_IsClient(): Boolean;
806 Result
:= (gGameSettings
.GameType
= GT_CLIENT
);
809 function g_Game_GetMegaWADInfo(WAD
: String): TMegaWADInfo
;
816 Result
.name
:= ExtractFileName(WAD
);
817 Result
.description
:= '';
820 w
:= TWADFile
.Create();
823 if not w
.GetResource('INTERSCRIPT', p
, len
) then
829 cfg
:= TConfig
.CreateMem(p
, len
);
830 Result
.name
:= cfg
.ReadStr('megawad', 'name', ExtractFileName(WAD
));
831 Result
.description
:= cfg
.ReadStr('megawad', 'description', '');
832 Result
.author
:= cfg
.ReadStr('megawad', 'author', '');
833 Result
.pic
:= cfg
.ReadStr('megawad', 'pic', '');
839 procedure g_Game_FreeWAD();
843 for a
:= 0 to High(MegaWAD
.res
.pic
) do
844 if MegaWAD
.res
.pic
[a
] <> '' then
845 g_Texture_Delete(MegaWAD
.res
.pic
[a
]);
847 for a
:= 0 to High(MegaWAD
.res
.mus
) do
848 if MegaWAD
.res
.mus
[a
] <> '' then
849 g_Sound_Delete(MegaWAD
.res
.mus
[a
]);
851 MegaWAD
.res
.pic
:= nil;
852 MegaWAD
.res
.text := nil;
853 MegaWAD
.res
.anim
:= nil;
854 MegaWAD
.res
.mus
:= nil;
855 MegaWAD
.triggers
:= nil;
857 g_Texture_Delete('TEXTURE_endpic');
858 g_Sound_Delete('MUSIC_endmus');
860 ZeroMemory(@MegaWAD
, SizeOf(MegaWAD
));
861 gGameSettings
.WAD
:= '';
864 procedure g_Game_LoadWAD(WAD
: string);
873 gGameSettings
.WAD
:= WAD
;
874 if not (gGameSettings
.GameMode
in [GM_COOP
, GM_SINGLE
]) then
877 MegaWAD
.info
:= g_Game_GetMegaWADInfo(WAD
);
879 w
:= TWADFile
.Create();
882 if not w
.GetResource('INTERSCRIPT', p
, len
) then
888 cfg
:= TConfig
.CreateMem(p
, len
);
893 s := cfg.ReadStr('pic', 'pic'+IntToStr(b), '');
894 if s = '' then Break;
897 SetLength(MegaWAD.res.pic, Length(MegaWAD.res.pic)+1);
898 MegaWAD.res.pic[High(MegaWAD.res.pic)] := s;
900 g_Texture_CreateWADEx(s, s);
906 s := cfg.ReadStr('mus', 'mus'+IntToStr(b), '');
907 if s = '' then Break;
910 SetLength(MegaWAD.res.mus, Length(MegaWAD.res.mus)+1);
911 MegaWAD.res.mus[High(MegaWAD.res.mus)] := s;
913 g_Music_CreateWADEx(s, s);
916 MegaWAD
.endpic
:= cfg
.ReadStr('megawad', 'endpic', '');
917 if MegaWAD
.endpic
<> '' then
919 TEXTUREFILTER
:= GL_LINEAR
;
920 s
:= e_GetResourcePath(WadDirs
, MegaWAD
.endpic
, WAD
);
921 g_Texture_CreateWADEx('TEXTURE_endpic', s
);
922 TEXTUREFILTER
:= GL_NEAREST
;
924 MegaWAD
.endmus
:= cfg
.ReadStr('megawad', 'endmus', 'Standart.wad:D2DMUS\ÊÎÍÅÖ');
925 if MegaWAD
.endmus
<> '' then
927 s
:= e_GetResourcePath(WadDirs
, MegaWAD
.endmus
, WAD
);
928 g_Sound_CreateWADEx('MUSIC_endmus', s
, True);
936 {procedure start_trigger(t: string);
940 function next_trigger(): Boolean;
944 procedure DisableCheats();
950 if gPlayer1
<> nil then gPlayer1
.GodMode
:= False;
951 if gPlayer2
<> nil then gPlayer2
.GodMode
:= False;
952 if gPlayer1
<> nil then gPlayer1
.NoTarget
:= False;
953 if gPlayer2
<> nil then gPlayer2
.NoTarget
:= False;
955 {$IF DEFINED(D2F_DEBUG)}
956 if gPlayer1
<> nil then gPlayer1
.NoTarget
:= True;
957 gAimLine
:= g_dbg_aimline_on
;
961 procedure g_Game_ExecuteEvent(Name
: String);
967 if gEvents
= nil then
969 for a
:= 0 to High(gEvents
) do
970 if gEvents
[a
].Name
= Name
then
972 if gEvents
[a
].Command
<> '' then
973 g_Console_Process(gEvents
[a
].Command
, True);
978 function g_Game_DelayEvent(DEType
: Byte; Time
: LongWord
; Num
: Integer = 0; Str
: String = ''): Integer;
983 if gDelayedEvents
<> nil then
984 for a
:= 0 to High(gDelayedEvents
) do
985 if not gDelayedEvents
[a
].Pending
then
992 SetLength(gDelayedEvents
, Length(gDelayedEvents
) + 1);
993 n
:= High(gDelayedEvents
);
995 gDelayedEvents
[n
].Pending
:= True;
996 gDelayedEvents
[n
].DEType
:= DEType
;
997 gDelayedEvents
[n
].DENum
:= Num
;
998 gDelayedEvents
[n
].DEStr
:= Str
;
999 if DEType
= DE_GLOBEVENT
then
1000 gDelayedEvents
[n
].Time
:= (sys_GetTicks() {div 1000}) + Time
1002 gDelayedEvents
[n
].Time
:= gTime
+ Time
;
1006 procedure EndGame();
1012 if g_Game_IsNet
and g_Game_IsServer
then
1013 MH_SEND_GameEvent(NET_EV_MAPEND
, Byte(gMissionFailed
));
1016 gPauseMain
:= false;
1017 gPauseHolmes
:= false;
1020 g_Game_StopAllSounds(False);
1025 EndingGameCounter
:= 0;
1026 g_ActiveWindow
:= nil;
1028 gLMSRespawn
:= LMS_RESPAWN_NONE
;
1029 gLMSRespawnTime
:= 0;
1032 EXIT_SIMPLE
: // Âûõîä ÷åðåç ìåíþ èëè êîíåö òåñòà
1037 begin // Ýòî áûë òåñò
1041 begin // Âûõîä â ãëàâíîå ìåíþ
1042 gMusic
.SetByName('MUSIC_MENU');
1044 if gState
<> STATE_SLIST
then
1046 g_GUI_ShowWindow('MainMenu');
1047 gState
:= STATE_MENU
;
1050 // Îáíîâëÿåì ñïèñîê ñåðâåðîâ
1051 slReturnPressed
:= True;
1052 if g_Net_Slist_Fetch(slCurrent
) then
1054 if slCurrent
= nil then
1055 slWaitStr
:= _lc
[I_NET_SLIST_NOSERVERS
];
1058 slWaitStr
:= _lc
[I_NET_SLIST_ERROR
];
1059 g_Serverlist_GenerateTable(slCurrent
, slTable
);
1062 g_Game_ExecuteEvent('ongameend');
1066 EXIT_RESTART
: // Íà÷àòü óðîâåíü ñíà÷àëà
1068 if not g_Game_IsClient
then g_Game_Restart();
1071 EXIT_ENDLEVELCUSTOM
: // Çàêîí÷èëñÿ óðîâåíü â Ñâîåé èãðå
1073 // Ñòàòèñòèêà Ñâîåé èãðû:
1074 FileName
:= g_ExtractWadName(gMapInfo
.Map
);
1076 CustomStat
.GameTime
:= gTime
;
1077 CustomStat
.Map
:= ExtractFileName(FileName
)+':'+g_ExtractFileName(gMapInfo
.Map
); //ResName;
1078 CustomStat
.MapName
:= gMapInfo
.Name
;
1079 CustomStat
.GameMode
:= gGameSettings
.GameMode
;
1080 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
1081 CustomStat
.TeamStat
:= gTeamStat
;
1083 CustomStat
.PlayerStat
:= nil;
1085 // Ñòàòèñòèêà èãðîêîâ:
1086 if gPlayers
<> nil then
1088 for a
:= 0 to High(gPlayers
) do
1089 if gPlayers
[a
] <> nil then
1091 SetLength(CustomStat
.PlayerStat
, Length(CustomStat
.PlayerStat
)+1);
1092 with CustomStat
.PlayerStat
[High(CustomStat
.PlayerStat
)] do
1095 Name
:= gPlayers
[a
].Name
;
1096 Frags
:= gPlayers
[a
].Frags
;
1097 Deaths
:= gPlayers
[a
].Death
;
1098 Kills
:= gPlayers
[a
].Kills
;
1099 Team
:= gPlayers
[a
].Team
;
1100 Color
:= gPlayers
[a
].Model
.Color
;
1101 Spectator
:= gPlayers
[a
].FSpectator
;
1105 SortGameStat(CustomStat
.PlayerStat
);
1107 if (gSaveStats
or gScreenshotStats
) and (Length(CustomStat
.PlayerStat
) > 1) then
1110 if g_Game_IsNet
then StatFilename
:= NetServerName
else StatFilename
:= 'local';
1111 StatDate
:= FormatDateTime('yymmdd_hhnnss', t
);
1112 StatFilename
:= StatFilename
+ '_' + CustomStat
.Map
+ '_' + g_Game_ModeToText(CustomStat
.GameMode
);
1113 StatFilename
:= sanitizeFilename(StatFilename
) + '_' + StatDate
;
1115 SaveGameStat(CustomStat
, FormatDateTime('yyyy"/"mm"/"dd', t
));
1118 StatShotDone
:= False;
1121 g_Game_ExecuteEvent('onmapend');
1122 if not g_Game_IsClient
then g_Player_ResetReady
;
1123 gInterReadyCount
:= 0;
1125 // Çàòóõàþùèé ýêðàí:
1126 EndingGameCounter
:= 255;
1127 gState
:= STATE_FOLD
;
1129 if gDefInterTime
< 0 then
1130 gInterEndTime
:= IfThen((gGameSettings
.GameType
= GT_SERVER
) and (gPlayer1
= nil), 15000, 25000)
1132 gInterEndTime
:= gDefInterTime
* 1000;
1135 EXIT_ENDLEVELSINGLE
: // Çàêîí÷èëñÿ óðîâåíü â Îäèíî÷íîé èãðå
1137 // Ñòàòèñòèêà Îäèíî÷íîé èãðû:
1138 SingleStat
.GameTime
:= gTime
;
1139 SingleStat
.TwoPlayers
:= gPlayer2
<> nil;
1140 SingleStat
.TotalSecrets
:= gSecretsCount
;
1141 // Ñòàòèñòèêà ïåðâîãî èãðîêà:
1142 SingleStat
.PlayerStat
[0].Kills
:= gPlayer1
.MonsterKills
;
1143 SingleStat
.PlayerStat
[0].Secrets
:= gPlayer1
.Secrets
;
1144 // Ñòàòèñòèêà âòîðîãî èãðîêà (åñëè åñòü):
1145 if SingleStat
.TwoPlayers
then
1147 SingleStat
.PlayerStat
[1].Kills
:= gPlayer2
.MonsterKills
;
1148 SingleStat
.PlayerStat
[1].Secrets
:= gPlayer2
.Secrets
;
1151 g_Game_ExecuteEvent('onmapend');
1154 if gNextMap
<> '' then
1156 gMusic
.SetByName('MUSIC_INTERMUS');
1158 gState
:= STATE_INTERSINGLE
;
1161 g_Game_ExecuteEvent('oninter');
1163 else // Áîëüøå íåò êàðò
1165 // Çàòóõàþùèé ýêðàí:
1166 EndingGameCounter
:= 255;
1167 gState
:= STATE_FOLD
;
1172 // Îêîí÷àíèå îáðàáîòàíî:
1173 if gExit
<> EXIT_QUIT
then
1177 procedure drawTime(X
, Y
: Integer); inline;
1179 e_TextureFontPrint(x
, y
,
1180 Format('%d:%.2d:%.2d', [
1181 gTime
div 1000 div 3600,
1182 (gTime
div 1000 div 60) mod 60,
1183 gTime
div 1000 mod 60
1188 procedure DrawStat();
1190 pc
, x
, y
, w
, h
: Integer;
1191 w1
, w2
, w3
, w4
: Integer;
1193 cw
, ch
, r
, g
, b
, rr
, gg
, bb
: Byte;
1196 stat
: TPlayerStatArray
;
1204 pc
:= g_Player_GetCount
;
1205 e_TextureFontGetSize(gStdFont
, cw
, ch
);
1207 w
:= gScreenWidth
-(gScreenWidth
div 5);
1208 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
1211 h
:= 40+ch
*5+(ch
+8)*pc
;
1212 x
:= (gScreenWidth
div 2)-(w
div 2);
1213 y
:= (gScreenHeight
div 2)-(h
div 2);
1215 e_DrawFillQuad(x
, y
, x
+w
-1, y
+h
-1, 64, 64, 64, 32);
1216 e_DrawQuad(x
, y
, x
+w
-1, y
+h
-1, 255, 127, 0);
1218 drawTime(x
+w
-78, y
+8);
1220 wad
:= g_ExtractWadNameNoPath(gMapInfo
.Map
);
1221 map
:= g_ExtractFileName(gMapInfo
.Map
);
1222 mapstr
:= wad
+ ':\' + map
+ ' - ' + gMapInfo
.Name
;
1224 case gGameSettings
.GameMode
of
1227 if gGameSettings
.MaxLives
= 0 then
1228 s1
:= _lc
[I_GAME_DM
]
1230 s1
:= _lc
[I_GAME_LMS
];
1231 s2
:= Format(_lc
[I_GAME_FRAG_LIMIT
], [gGameSettings
.ScoreLimit
]);
1232 s3
:= Format(_lc
[I_GAME_TIME_LIMIT
], [gGameSettings
.TimeLimit
div 3600, (gGameSettings
.TimeLimit
div 60) mod 60, gGameSettings
.TimeLimit
mod 60]);
1237 if gGameSettings
.MaxLives
= 0 then
1238 s1
:= _lc
[I_GAME_TDM
]
1240 s1
:= _lc
[I_GAME_TLMS
];
1241 s2
:= Format(_lc
[I_GAME_FRAG_LIMIT
], [gGameSettings
.ScoreLimit
]);
1242 s3
:= Format(_lc
[I_GAME_TIME_LIMIT
], [gGameSettings
.TimeLimit
div 3600, (gGameSettings
.TimeLimit
div 60) mod 60, gGameSettings
.TimeLimit
mod 60]);
1247 s1
:= _lc
[I_GAME_CTF
];
1248 s2
:= Format(_lc
[I_GAME_SCORE_LIMIT
], [gGameSettings
.ScoreLimit
]);
1249 s3
:= Format(_lc
[I_GAME_TIME_LIMIT
], [gGameSettings
.TimeLimit
div 3600, (gGameSettings
.TimeLimit
div 60) mod 60, gGameSettings
.TimeLimit
mod 60]);
1254 if gGameSettings
.MaxLives
= 0 then
1255 s1
:= _lc
[I_GAME_COOP
]
1257 s1
:= _lc
[I_GAME_SURV
];
1258 s2
:= _lc
[I_GAME_MONSTERS
] + ' ' + IntToStr(gCoopMonstersKilled
) + '/' + IntToStr(gTotalMonsters
);
1259 s3
:= _lc
[I_GAME_SECRETS
] + ' ' + IntToStr(gCoopSecretsFound
) + '/' + IntToStr(gSecretsCount
);
1270 e_TextureFontPrintEx(x
+(w
div 2)-(Length(s1
)*cw
div 2), _y
, s1
, gStdFont
, 255, 255, 255, 1);
1272 e_TextureFontPrintEx(x
+(w
div 2)-(Length(mapstr
)*cw
div 2), _y
, mapstr
, gStdFont
, 200, 200, 200, 1);
1274 e_TextureFontPrintEx(x
+16, _y
, s2
, gStdFont
, 200, 200, 200, 1);
1276 e_TextureFontPrintEx(x
+w
-16-(Length(s3
))*cw
, _y
, s3
,
1277 gStdFont
, 200, 200, 200, 1);
1279 if NetMode
= NET_SERVER
then
1280 e_TextureFontPrintEx(x
+8, y
+ 8, _lc
[I_NET_SERVER
], gStdFont
, 255, 255, 255, 1)
1282 if NetMode
= NET_CLIENT
then
1283 e_TextureFontPrintEx(x
+8, y
+ 8,
1284 NetClientIP
+ ':' + IntToStr(NetClientPort
), gStdFont
, 255, 255, 255, 1);
1288 stat
:= g_Player_GetStats();
1291 w2
:= (w
-16) div 6 + 48; // øèðèíà 2 ñòîëáöà
1292 w3
:= (w
-16) div 6; // øèðèíà 3 è 4 ñòîëáöîâ
1294 w1
:= w
-16-w2
-w3
-w4
; // îñòàâøååñÿ ïðîñòðàíñòâî - äëÿ öâåòà è èìåíè èãðîêà
1296 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
1300 for a
:= TEAM_RED
to TEAM_BLUE
do
1302 if a
= TEAM_RED
then
1304 s1
:= _lc
[I_GAME_TEAM_RED
];
1311 s1
:= _lc
[I_GAME_TEAM_BLUE
];
1317 e_TextureFontPrintEx(x
+16, _y
, s1
, gStdFont
, r
, g
, b
, 1);
1318 e_TextureFontPrintEx(x
+w1
+16, _y
, IntToStr(gTeamStat
[a
].Score
),
1319 gStdFont
, r
, g
, b
, 1);
1321 _y
:= _y
+ch
+(ch
div 4);
1322 e_DrawLine(1, x
+16, _y
, x
+w
-16, _y
, r
, g
, b
);
1323 _y
:= _y
+(ch
div 4);
1325 for aa
:= 0 to High(stat
) do
1326 if stat
[aa
].Team
= a
then
1342 namestr
:= Format('[%5d] %s', [UID
, Name
])
1346 e_TextureFontPrintEx(x
+16, _y
, namestr
, gStdFont
, rr
, gg
, bb
, 1);
1348 e_TextureFontPrintEx(x
+w1
+16, _y
, Format(_lc
[I_GAME_PING_MS
], [Ping
, Loss
]), gStdFont
, rr
, gg
, bb
, 1);
1350 e_TextureFontPrintEx(x
+w1
+w2
+16, _y
, IntToStr(Frags
), gStdFont
, rr
, gg
, bb
, 1);
1352 e_TextureFontPrintEx(x
+w1
+w2
+w3
+16, _y
, IntToStr(Deaths
), gStdFont
, rr
, gg
, bb
, 1);
1359 else if gGameSettings
.GameMode
in [GM_DM
, GM_COOP
] then
1362 e_TextureFontPrintEx(x
+16, _y
, _lc
[I_GAME_PLAYER_NAME
], gStdFont
, 255, 127, 0, 1);
1363 e_TextureFontPrintEx(x
+16+w1
, _y
, _lc
[I_GAME_PING
], gStdFont
, 255, 127, 0, 1);
1364 e_TextureFontPrintEx(x
+16+w1
+w2
, _y
, _lc
[I_GAME_FRAGS
], gStdFont
, 255, 127, 0, 1);
1365 e_TextureFontPrintEx(x
+16+w1
+w2
+w3
, _y
, _lc
[I_GAME_DEATHS
], gStdFont
, 255, 127, 0, 1);
1368 for aa
:= 0 to High(stat
) do
1382 namestr
:= Format('[%5d] %s', [UID
, Name
])
1386 e_DrawFillQuad(x
+16, _y
+4, x
+32-1, _y
+16+4-1, Color
.R
, Color
.G
, Color
.B
, 0);
1387 e_DrawQuad(x
+16, _y
+4, x
+32-1, _y
+16+4-1, 192, 192, 192);
1389 e_TextureFontPrintEx(x
+16+16+8, _y
+4, namestr
, gStdFont
, r
, g
, 0, 1);
1391 e_TextureFontPrintEx(x
+w1
+16, _y
+4, Format(_lc
[I_GAME_PING_MS
], [Ping
, Loss
]), gStdFont
, r
, g
, 0, 1);
1393 e_TextureFontPrintEx(x
+w1
+w2
+16, _y
+4, IntToStr(Frags
), gStdFont
, r
, g
, 0, 1);
1395 e_TextureFontPrintEx(x
+w1
+w2
+w3
+16, _y
+4, IntToStr(Deaths
), gStdFont
, r
, g
, 0, 1);
1401 procedure g_Game_Init();
1404 knownFiles
: array of AnsiString
= nil;
1406 wext
, s
: AnsiString
;
1411 gTempDelete
:= False;
1413 sfsGCDisable(); // temporary disable removing of temporary volumes
1416 TEXTUREFILTER
:= GL_LINEAR
;
1417 g_Texture_CreateWADEx('MENU_BACKGROUND', GameWAD
+':TEXTURES\TITLE');
1418 g_Texture_CreateWADEx('INTER', GameWAD
+':TEXTURES\INTER');
1419 g_Texture_CreateWADEx('ENDGAME_EN', GameWAD
+':TEXTURES\ENDGAME_EN');
1420 g_Texture_CreateWADEx('ENDGAME_RU', GameWAD
+':TEXTURES\ENDGAME_RU');
1421 TEXTUREFILTER
:= GL_NEAREST
;
1423 LoadStdFont('STDTXT', 'STDFONT', gStdFont
);
1424 LoadFont('MENUTXT', 'MENUFONT', gMenuFont
);
1425 LoadFont('SMALLTXT', 'SMALLFONT', gMenuSmallFont
);
1427 g_Game_ClearLoading();
1428 g_Game_SetLoadingText(Format('Doom 2D: Forever %s', [GAME_VERSION
]), 0, False);
1429 g_Game_SetLoadingText('', 0, False);
1431 g_Game_SetLoadingText(_lc
[I_LOAD_CONSOLE
], 0, False);
1434 g_Game_SetLoadingText(_lc
[I_LOAD_MODELS
], 0, False);
1435 g_PlayerModel_LoadData();
1437 // load models from all possible wad types, in all known directories
1438 // this does a loosy job (linear search, ooph!), but meh
1439 for wext
in wadExtensions
do
1441 for f
:= High(ModelDirs
) downto Low(ModelDirs
) do
1443 if (FindFirst(ModelDirs
[f
]+DirectorySeparator
+'*'+wext
, faAnyFile
, SR
) = 0) then
1447 for s
in knownFiles
do
1449 if (strEquCI1251(forceFilenameExt(SR
.Name
, ''), forceFilenameExt(ExtractFileName(s
), ''))) then
1457 SetLength(knownFiles
, length(knownFiles
)+1);
1458 knownFiles
[High(knownFiles
)] := ModelDirs
[f
]+DirectorySeparator
+SR
.Name
;
1460 until (FindNext(SR
) <> 0);
1466 if (length(knownFiles
) = 0) then raise Exception
.Create('no player models found!');
1468 if (length(knownFiles
) = 1) then e_LogWriteln('1 player model found.', TMsgType
.Notify
) else e_LogWritefln('%d player models found.', [Integer(length(knownFiles
))], TMsgType
.Notify
);
1469 for s
in knownFiles
do
1471 if not g_PlayerModel_Load(s
) then e_LogWritefln('Error loading model "%s"', [s
], TMsgType
.Warning
);
1475 gPauseMain
:= false;
1476 gPauseHolmes
:= false;
1479 {e_MouseInfo.Accel := 1.0;}
1481 g_Game_SetLoadingText(_lc
[I_LOAD_GAME_DATA
], 0, False);
1484 g_Game_SetLoadingText(_lc
[I_LOAD_MUSIC
], 0, False);
1485 g_Sound_CreateWADEx('MUSIC_INTERMUS', GameWAD
+':MUSIC\INTERMUS', True);
1486 g_Sound_CreateWADEx('MUSIC_MENU', GameWAD
+':MUSIC\MENU', True);
1487 g_Sound_CreateWADEx('MUSIC_ROUNDMUS', GameWAD
+':MUSIC\ROUNDMUS', True, True);
1488 g_Sound_CreateWADEx('MUSIC_STDENDMUS', GameWAD
+':MUSIC\ENDMUS', True);
1491 g_Game_SetLoadingText(_lc
[I_LOAD_MENUS
], 0, False);
1495 gMusic
:= TMusic
.Create();
1496 gMusic
.SetByName('MUSIC_MENU');
1499 gGameSettings
.WarmupTime
:= 30;
1501 gState
:= STATE_MENU
;
1503 SetLength(gEvents
, 6);
1504 gEvents
[0].Name
:= 'ongamestart';
1505 gEvents
[1].Name
:= 'ongameend';
1506 gEvents
[2].Name
:= 'onmapstart';
1507 gEvents
[3].Name
:= 'onmapend';
1508 gEvents
[4].Name
:= 'oninter';
1509 gEvents
[5].Name
:= 'onwadend';
1511 sfsGCEnable(); // enable releasing unused volumes
1515 procedure g_Game_Free(freeTextures
: Boolean=true);
1517 if NetMode
= NET_CLIENT
then g_Net_Disconnect();
1518 if NetMode
= NET_SERVER
then g_Net_Host_Die();
1520 g_Map_Free(freeTextures
);
1522 g_Player_RemoveAllCorpses();
1524 gGameSettings
.GameType
:= GT_NONE
;
1525 if gGameSettings
.GameMode
= GM_SINGLE
then
1526 gGameSettings
.GameMode
:= GM_DM
;
1527 gSwitchGameMode
:= gGameSettings
.GameMode
;
1530 gExitByTrigger
:= False;
1533 function IsActivePlayer(p
: TPlayer
): Boolean;
1538 Result
:= (not p
.FDummy
) and (not p
.FSpectator
);
1541 function GetActivePlayer_ByID(ID
: Integer): TPlayer
;
1548 if gPlayers
= nil then
1550 for a
:= Low(gPlayers
) to High(gPlayers
) do
1551 if IsActivePlayer(gPlayers
[a
]) then
1553 if gPlayers
[a
].UID
<> ID
then
1555 Result
:= gPlayers
[a
];
1560 function GetActivePlayerID_Next(Skip
: Integer = -1): Integer;
1566 if gPlayers
= nil then
1570 for a
:= Low(gPlayers
) to High(gPlayers
) do
1571 if IsActivePlayer(gPlayers
[a
]) then
1573 SetLength(ids
, Length(ids
) + 1);
1574 ids
[High(ids
)] := gPlayers
[a
].UID
;
1575 if gPlayers
[a
].UID
= Skip
then
1578 if Length(ids
) = 0 then
1583 Result
:= ids
[(idx
+ 1) mod Length(ids
)];
1586 function GetActivePlayerID_Prev(Skip
: Integer = -1): Integer;
1592 if gPlayers
= nil then
1596 for a
:= Low(gPlayers
) to High(gPlayers
) do
1597 if IsActivePlayer(gPlayers
[a
]) then
1599 SetLength(ids
, Length(ids
) + 1);
1600 ids
[High(ids
)] := gPlayers
[a
].UID
;
1601 if gPlayers
[a
].UID
= Skip
then
1604 if Length(ids
) = 0 then
1607 Result
:= ids
[Length(ids
) - 1]
1609 Result
:= ids
[(Length(ids
) - 1 + idx
) mod Length(ids
)];
1612 function GetActivePlayerID_Random(Skip
: Integer = -1): Integer;
1618 if gPlayers
= nil then
1622 for a
:= Low(gPlayers
) to High(gPlayers
) do
1623 if IsActivePlayer(gPlayers
[a
]) then
1625 SetLength(ids
, Length(ids
) + 1);
1626 ids
[High(ids
)] := gPlayers
[a
].UID
;
1627 if gPlayers
[a
].UID
= Skip
then
1630 if Length(ids
) = 0 then
1632 if Length(ids
) = 1 then
1637 Result
:= ids
[Random(Length(ids
))];
1639 while (idx
<> -1) and (Result
= Skip
) and (a
> 0) do
1641 Result
:= ids
[Random(Length(ids
))];
1646 function GetRandomSpectMode(Current
: Byte): Byte;
1653 0: Result
:= SPECT_STATS
;
1654 1: Result
:= SPECT_MAPVIEW
;
1655 2: Result
:= SPECT_MAPVIEW
;
1656 3: Result
:= SPECT_PLAYERS
;
1657 4: Result
:= SPECT_PLAYERS
;
1658 5: Result
:= SPECT_PLAYERS
;
1659 6: Result
:= SPECT_PLAYERS
;
1661 if (Current
in [SPECT_STATS
, SPECT_MAPVIEW
]) and (Current
= Result
) then
1665 procedure ProcessPlayerControls (plr
: TPlayer
; p
: Integer; var MoveButton
: Byte);
1671 if (plr
= nil) then exit
;
1672 if (p
= 2) then time
:= 1000 else time
:= 1;
1673 strafeDir
:= MoveButton
shr 4;
1674 MoveButton
:= MoveButton
and $0F;
1676 if gPlayerAction
[p
, ACTION_MOVELEFT
] and (not gPlayerAction
[p
, ACTION_MOVERIGHT
]) then
1677 MoveButton
:= 1 // Íàæàòà òîëüêî "Âëåâî"
1678 else if (not gPlayerAction
[p
, ACTION_MOVELEFT
]) and gPlayerAction
[p
, ACTION_MOVERIGHT
] then
1679 MoveButton
:= 2 // Íàæàòà òîëüêî "Âïðàâî"
1680 else if (not gPlayerAction
[p
, ACTION_MOVELEFT
]) and (not gPlayerAction
[p
, ACTION_MOVERIGHT
]) then
1681 MoveButton
:= 0; // Íå íàæàòû íè "Âëåâî", íè "Âïðàâî"
1683 // Ñåé÷àñ èëè ðàíüøå áûëè íàæàòû "Âëåâî"/"Âïðàâî" => ïåðåäàåì èãðîêó:
1684 if MoveButton
= 1 then
1685 plr
.PressKey(KEY_LEFT
, time
)
1686 else if MoveButton
= 2 then
1687 plr
.PressKey(KEY_RIGHT
, time
);
1689 // if we have "strafe" key, turn off old strafe mechanics
1690 if gPlayerAction
[p
, ACTION_STRAFE
] then
1692 // new strafe mechanics
1693 if (strafeDir
= 0) then
1694 strafeDir
:= MoveButton
; // start strafing
1695 // now set direction according to strafe (reversed)
1696 if (strafeDir
= 2) then
1697 plr
.SetDirection(TDirection
.D_LEFT
)
1698 else if (strafeDir
= 1) then
1699 plr
.SetDirection(TDirection
.D_RIGHT
)
1703 strafeDir
:= 0; // not strafing anymore
1704 // Ðàíüøå áûëà íàæàòà "Âïðàâî", à ñåé÷àñ "Âëåâî" => áåæèì âïðàâî, ñìîòðèì âëåâî:
1705 if (MoveButton
= 2) and gPlayerAction
[p
, ACTION_MOVELEFT
] then
1706 plr
.SetDirection(TDirection
.D_LEFT
)
1707 // Ðàíüøå áûëà íàæàòà "Âëåâî", à ñåé÷àñ "Âïðàâî" => áåæèì âëåâî, ñìîòðèì âïðàâî:
1708 else if (MoveButton
= 1) and gPlayerAction
[p
, ACTION_MOVERIGHT
] then
1709 plr
.SetDirection(TDirection
.D_RIGHT
)
1710 // ×òî-òî áûëî íàæàòî è íå èçìåíèëîñü => êóäà áåæèì, òóäà è ñìîòðèì:
1711 else if MoveButton
<> 0 then
1712 plr
.SetDirection(TDirection(MoveButton
-1))
1715 // fix movebutton state
1716 MoveButton
:= MoveButton
or (strafeDir
shl 4);
1718 // Îñòàëüíûå êëàâèøè:
1719 if gPlayerAction
[p
, ACTION_JUMP
] then plr
.PressKey(KEY_JUMP
, time
);
1720 if gPlayerAction
[p
, ACTION_LOOKUP
] then plr
.PressKey(KEY_UP
, time
);
1721 if gPlayerAction
[p
, ACTION_LOOKDOWN
] then plr
.PressKey(KEY_DOWN
, time
);
1722 if gPlayerAction
[p
, ACTION_ATTACK
] then plr
.PressKey(KEY_FIRE
);
1723 if gPlayerAction
[p
, ACTION_ACTIVATE
] then plr
.PressKey(KEY_OPEN
);
1725 for i
:= WP_FACT
to WP_LACT
do
1727 if gWeaponAction
[p
, i
] then
1729 plr
.ProcessWeaponAction(i
);
1730 gWeaponAction
[p
, i
] := False
1734 for i
:= WP_FIRST
to WP_LAST
do
1736 if gSelectWeapon
[p
, i
] then
1738 plr
.QueueWeaponSwitch(i
); // all choices are passed there, and god will take the best
1739 gSelectWeapon
[p
, i
] := False
1743 // HACK: add dynlight here
1744 if gwin_k8_enable_light_experiments
then
1746 if e_KeyPressed(IK_F8
) and gGameOn
and (not gConsoleShow
) and (g_ActiveWindow
= nil) then
1748 g_playerLight
:= true;
1750 if e_KeyPressed(IK_F9
) and gGameOn
and (not gConsoleShow
) and (g_ActiveWindow
= nil) then
1752 g_playerLight
:= false;
1756 if gwin_has_stencil
and g_playerLight
then g_AddDynLight(plr
.GameX
+32, plr
.GameY
+40, 128, 1, 1, 0, 0.6);
1759 // HACK: don't have a "key was pressed" function
1760 procedure InterReady();
1762 if InterReadyTime
> gTime
then Exit
;
1763 InterReadyTime
:= gTime
+ 3000;
1764 MC_SEND_CheatRequest(NET_CHEAT_READY
);
1767 procedure g_Game_PreUpdate();
1769 // these are in separate PreUpdate functions because they can interact during Update()
1770 // and are synced over the net
1771 // we don't care that much about corpses and gibs
1772 g_Player_PreUpdate();
1773 g_Monsters_PreUpdate();
1774 g_Items_PreUpdate();
1775 g_Weapon_PreUpdate();
1778 procedure g_Game_Update();
1780 Msg
: g_gui
.TMessage
;
1786 function sendMonsPos (mon
: TMonster
): Boolean;
1788 result
:= false; // don't stop
1789 // this will also reset "need-send" flag
1790 if mon
.gncNeedSend
then
1792 MH_SEND_MonsterPos(mon
.UID
);
1794 else if (mon
.MonsterType
= MONSTER_BARREL
) then
1796 if (mon
.GameVelX
<> 0) or (mon
.GameVelY
<> 0) then MH_SEND_MonsterPos(mon
.UID
);
1798 else if (mon
.MonsterState
<> MONSTATE_SLEEP
) then
1800 if (mon
.MonsterState
<> MONSTATE_DEAD
) or (mon
.GameVelX
<> 0) or (mon
.GameVelY
<> 0) then MH_SEND_MonsterPos(mon
.UID
);
1804 function sendMonsPosUnexpected (mon
: TMonster
): Boolean;
1806 result
:= false; // don't stop
1807 // this will also reset "need-send" flag
1808 if mon
.gncNeedSend
then MH_SEND_MonsterPos(mon
.UID
);
1811 function sendItemPos (it
: PItem
): Boolean;
1813 result
:= false; // don't stop
1816 MH_SEND_ItemPos(it
.myId
);
1817 it
.needSend
:= False;
1822 reliableUpdate
: Boolean;
1827 // Ïîðà âûêëþ÷àòü èãðó:
1828 if gExit
= EXIT_QUIT
then
1830 // Èãðà çàêîí÷èëàñü - îáðàáàòûâàåì:
1834 if gExit
= EXIT_QUIT
then
1838 // ×èòàåì êëàâèàòóðó è äæîéñòèê, åñëè îêíî àêòèâíî
1839 // no need to, as we'll do it in event handler
1841 // Îáíîâëÿåì êîíñîëü (äâèæåíèå è ñîîáùåíèÿ):
1844 if (NetMode
= NET_NONE
) and (g_Game_IsNet
) and (gGameOn
or (gState
in [STATE_FOLD
, STATE_INTERCUSTOM
])) then
1846 gExit
:= EXIT_SIMPLE
;
1851 // process master server communications
1852 g_Net_Slist_Pulse();
1855 STATE_INTERSINGLE
, // Ñòàòèñòêà ïîñëå ïðîõîæäåíèÿ óðîâíÿ â Îäèíî÷íîé èãðå
1856 STATE_INTERCUSTOM
, // Ñòàòèñòêà ïîñëå ïðîõîæäåíèÿ óðîâíÿ â Ñâîåé èãðå
1857 STATE_INTERTEXT
, // Òåêñò ìåæäó óðîâíÿìè
1858 STATE_INTERPIC
: // Êàðòèíêà ìåæäó óðîâíÿìè
1860 if g_Game_IsNet
and g_Game_IsServer
then
1862 gInterTime
:= gInterTime
+ GAME_TICK
;
1863 a
:= Min((gInterEndTime
- gInterTime
) div 1000 + 1, 255);
1864 if a
<> gServInterTime
then
1866 gServInterTime
:= a
;
1867 MH_SEND_TimeSync(gServInterTime
);
1871 if (not g_Game_IsClient
) and
1875 e_KeyPressed(IK_RETURN
) or e_KeyPressed(IK_KPRETURN
) or e_KeyPressed(IK_SPACE
) or
1876 e_KeyPressed(VK_FIRE
) or e_KeyPressed(VK_OPEN
) or
1877 e_KeyPressed(JOY0_ATTACK
) or e_KeyPressed(JOY1_ATTACK
) or
1878 e_KeyPressed(JOY2_ATTACK
) or e_KeyPressed(JOY3_ATTACK
)
1880 and (not gJustChatted
) and (not gConsoleShow
) and (not gChatShow
)
1881 and (g_ActiveWindow
= nil)
1883 or (g_Game_IsNet
and ((gInterTime
> gInterEndTime
) or ((gInterReadyCount
>= NetClientCount
) and (NetClientCount
> 0))))
1886 begin // Íàæàëè <Enter>/<Ïðîáåë> èëè ïðîøëî äîñòàòî÷íî âðåìåíè:
1887 g_Game_StopAllSounds(True);
1889 if gMapOnce
then // Ýòî áûë òåñò
1890 gExit
:= EXIT_SIMPLE
1892 if gNextMap
<> '' then // Ïåðåõîäèì íà ñëåäóþùóþ êàðòó
1893 g_Game_ChangeMap(gNextMap
)
1894 else // Ñëåäóþùåé êàðòû íåò
1896 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
] then
1898 // Âûõîä â ãëàâíîå ìåíþ:
1900 g_GUI_ShowWindow('MainMenu');
1901 gMusic
.SetByName('MUSIC_MENU');
1903 gState
:= STATE_MENU
;
1906 // Ôèíàëüíàÿ êàðòèíêà:
1907 g_Game_ExecuteEvent('onwadend');
1909 if not gMusic
.SetByName('MUSIC_endmus') then
1910 gMusic
.SetByName('MUSIC_STDENDMUS');
1912 gState
:= STATE_ENDPIC
;
1914 g_Game_ExecuteEvent('ongameend');
1919 else if g_Game_IsClient
and
1922 e_KeyPressed(IK_RETURN
) or e_KeyPressed(IK_KPRETURN
) or e_KeyPressed(IK_SPACE
) or
1923 e_KeyPressed(VK_FIRE
) or e_KeyPressed(VK_OPEN
) or
1924 e_KeyPressed(JOY0_ATTACK
) or e_KeyPressed(JOY1_ATTACK
) or
1925 e_KeyPressed(JOY2_ATTACK
) or e_KeyPressed(JOY3_ATTACK
)
1927 and (not gJustChatted
) and (not gConsoleShow
) and (not gChatShow
)
1928 and (g_ActiveWindow
= nil)
1936 if gState
= STATE_INTERTEXT
then
1937 if InterText
.counter
> 0 then
1938 InterText
.counter
:= InterText
.counter
- 1;
1941 STATE_FOLD
: // Çàòóõàíèå ýêðàíà
1943 if EndingGameCounter
= 0 then
1945 // Çàêîí÷èëñÿ óðîâåíü â Ñâîåé èãðå:
1946 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
1948 gState
:= STATE_INTERCUSTOM
;
1949 InterReadyTime
:= -1;
1950 if gLastMap
and (gGameSettings
.GameMode
= GM_COOP
) then
1952 g_Game_ExecuteEvent('onwadend');
1953 if not gMusic
.SetByName('MUSIC_endmus') then
1954 gMusic
.SetByName('MUSIC_STDENDMUS');
1957 gMusic
.SetByName('MUSIC_ROUNDMUS');
1961 else // Çàêîí÷èëàñü ïîñëåäíÿÿ êàðòà â Îäèíî÷íîé èãðå
1963 gMusic
.SetByName('MUSIC_INTERMUS');
1965 gState
:= STATE_INTERSINGLE
;
1968 g_Game_ExecuteEvent('oninter');
1971 DecMin(EndingGameCounter
, 6, 0);
1974 STATE_ENDPIC
: // Êàðòèíêà îêîí÷àíèÿ ìåãàÂàäà
1976 if gMapOnce
then // Ýòî áûë òåñò
1978 gExit
:= EXIT_SIMPLE
;
1984 g_Serverlist_Control(slCurrent
, slTable
);
1987 // Ñòàòèñòèêà ïî Tab:
1989 IsDrawStat
:= (not gConsoleShow
) and (not gChatShow
) and (gGameSettings
.GameType
<> GT_SINGLE
) and g_Console_Action(ACTION_SCORES
);
1992 if gGameOn
and not gPause
and (gState
<> STATE_FOLD
) then
1994 // Âðåìÿ += 28 ìèëëèñåêóíä:
1995 gTime
:= gTime
+ GAME_TICK
;
1997 // Ñîîáùåíèå ïîñåðåäèíå ýêðàíà:
1998 if MessageTime
= 0 then
2000 if MessageTime
> 0 then
2001 MessageTime
:= MessageTime
- 1;
2003 if (g_Game_IsServer
) then
2005 // Áûë çàäàí ëèìèò âðåìåíè:
2006 if (gGameSettings
.TimeLimit
> 0) then
2007 if (gTime
- gGameStartTime
) div 1000 >= gGameSettings
.TimeLimit
then
2008 begin // Îí ïðîøåë => êîíåö óðîâíÿ
2013 // Íàäî ðåñïàâíèòü èãðîêîâ â LMS:
2014 if (gLMSRespawn
> LMS_RESPAWN_NONE
) and (gLMSRespawnTime
< gTime
) then
2015 g_Game_RestartRound(gLMSSoftSpawn
);
2017 // Ïðîâåðèì ðåçóëüòàò ãîëîñîâàíèÿ, åñëè âðåìÿ ïðîøëî
2018 if gVoteInProgress
and (gVoteTimer
< gTime
) then
2020 else if gVotePassed
and (gVoteCmdTimer
< gTime
) then
2022 g_Console_Process(gVoteCommand
);
2024 gVotePassed
:= False;
2027 // Çàìåðÿåì âðåìÿ çàõâàòà ôëàãîâ
2028 if gFlags
[FLAG_RED
].State
= FLAG_STATE_CAPTURED
then
2029 gFlags
[FLAG_RED
].CaptureTime
:= gFlags
[FLAG_RED
].CaptureTime
+ GAME_TICK
;
2030 if gFlags
[FLAG_BLUE
].State
= FLAG_STATE_CAPTURED
then
2031 gFlags
[FLAG_BLUE
].CaptureTime
:= gFlags
[FLAG_BLUE
].CaptureTime
+ GAME_TICK
;
2033 // Áûë çàäàí ëèìèò ïîáåä:
2034 if (gGameSettings
.ScoreLimit
> 0) then
2038 if gGameSettings
.GameMode
= GM_DM
then
2039 begin // Â DM èùåì èãðîêà ñ max ôðàãàìè
2040 for i
:= 0 to High(gPlayers
) do
2041 if gPlayers
[i
] <> nil then
2042 if gPlayers
[i
].Frags
> b
then
2043 b
:= gPlayers
[i
].Frags
;
2046 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
2047 begin //  CTF/TDM âûáèðàåì êîìàíäó ñ íàèáîëüøèì ñ÷åòîì
2048 b
:= Max(gTeamStat
[TEAM_RED
].Score
, gTeamStat
[TEAM_BLUE
].Score
);
2051 // Ëèìèò ïîáåä íàáðàí => êîíåö óðîâíÿ:
2052 if b
>= gGameSettings
.ScoreLimit
then
2059 // Îáðàáàòûâàåì êëàâèøè èãðîêîâ:
2060 if gPlayer1
<> nil then gPlayer1
.ReleaseKeys();
2061 if gPlayer2
<> nil then gPlayer2
.ReleaseKeys();
2062 if (not gConsoleShow
) and (not gChatShow
) and (g_ActiveWindow
= nil) then
2064 ProcessPlayerControls(gPlayer1
, 0, P1MoveButton
);
2065 ProcessPlayerControls(gPlayer2
, 1, P2MoveButton
);
2066 end // if not console
2069 if g_Game_IsNet
and (gPlayer1
<> nil) then gPlayer1
.PressKey(KEY_CHAT
, 10000);
2071 // process weapon switch queue
2075 if (gPlayer1
= nil) and (gPlayer2
= nil) and
2076 (not gConsoleShow
) and (not gChatShow
) and (g_ActiveWindow
= nil) then
2078 if not gSpectKeyPress
then
2080 if gPlayerAction
[0, ACTION_JUMP
] and (not gSpectAuto
) then
2082 // switch spect mode
2084 SPECT_NONE
: ; // not spectator
2086 SPECT_MAPVIEW
: Inc(gSpectMode
);
2087 SPECT_PLAYERS
: gSpectMode
:= SPECT_STATS
; // reset to 1
2089 gSpectKeyPress
:= True;
2091 if (gSpectMode
= SPECT_MAPVIEW
)
2092 and (not gSpectAuto
) then
2094 if gPlayerAction
[0, ACTION_MOVELEFT
] then
2095 gSpectX
:= Max(gSpectX
- gSpectStep
, 0);
2096 if gPlayerAction
[0, ACTION_MOVERIGHT
] then
2097 gSpectX
:= Min(gSpectX
+ gSpectStep
, gMapInfo
.Width
- gScreenWidth
);
2098 if gPlayerAction
[0, ACTION_LOOKUP
] then
2099 gSpectY
:= Max(gSpectY
- gSpectStep
, 0);
2100 if gPlayerAction
[0, ACTION_LOOKDOWN
] then
2101 gSpectY
:= Min(gSpectY
+ gSpectStep
, gMapInfo
.Height
- gScreenHeight
);
2102 if gWeaponAction
[0, WP_PREV
] then
2105 if gSpectStep
> 4 then gSpectStep
:= gSpectStep
shr 1;
2106 gWeaponAction
[0, WP_PREV
] := False;
2108 if gWeaponAction
[0, WP_NEXT
] then
2111 if gSpectStep
< 64 then gSpectStep
:= gSpectStep
shl 1;
2112 gWeaponAction
[0, WP_NEXT
] := False;
2115 if (gSpectMode
= SPECT_PLAYERS
)
2116 and (not gSpectAuto
) then
2118 if gPlayerAction
[0, ACTION_LOOKUP
] then
2121 gSpectViewTwo
:= True;
2122 gSpectKeyPress
:= True;
2124 if gPlayerAction
[0, ACTION_LOOKDOWN
] then
2126 // remove second view
2127 gSpectViewTwo
:= False;
2128 gSpectKeyPress
:= True;
2130 if gPlayerAction
[0, ACTION_MOVELEFT
] then
2132 // prev player (view 1)
2133 gSpectPID1
:= GetActivePlayerID_Prev(gSpectPID1
);
2134 gSpectKeyPress
:= True;
2136 if gPlayerAction
[0, ACTION_MOVERIGHT
] then
2138 // next player (view 1)
2139 gSpectPID1
:= GetActivePlayerID_Next(gSpectPID1
);
2140 gSpectKeyPress
:= True;
2142 if gWeaponAction
[0, WP_PREV
] then
2144 // prev player (view 2)
2145 gSpectPID2
:= GetActivePlayerID_Prev(gSpectPID2
);
2146 gWeaponAction
[0, WP_PREV
] := False;
2148 if gWeaponAction
[0, WP_NEXT
] then
2150 // next player (view 2)
2151 gSpectPID2
:= GetActivePlayerID_Next(gSpectPID2
);
2152 gWeaponAction
[0, WP_NEXT
] := False;
2155 if gPlayerAction
[0, ACTION_ATTACK
] then
2157 if (gSpectMode
= SPECT_STATS
) and (not gSpectAuto
) then
2160 gSpectAutoNext
:= 0;
2161 gSpectViewTwo
:= False;
2162 gSpectKeyPress
:= True;
2167 gSpectMode
:= SPECT_STATS
;
2168 gSpectAuto
:= False;
2169 gSpectKeyPress
:= True;
2174 if (not gPlayerAction
[0, ACTION_JUMP
]) and
2175 (not gPlayerAction
[0, ACTION_ATTACK
]) and
2176 (not gPlayerAction
[0, ACTION_MOVELEFT
]) and
2177 (not gPlayerAction
[0, ACTION_MOVERIGHT
]) and
2178 (not gPlayerAction
[0, ACTION_LOOKUP
]) and
2179 (not gPlayerAction
[0, ACTION_LOOKDOWN
]) then
2180 gSpectKeyPress
:= False;
2184 if gSpectMode
= SPECT_MAPVIEW
then
2186 i
:= Min(Max(gSpectX
+ gSpectAutoStepX
, 0), gMapInfo
.Width
- gScreenWidth
);
2188 gSpectAutoNext
:= gTime
2191 i
:= Min(Max(gSpectY
+ gSpectAutoStepY
, 0), gMapInfo
.Height
- gScreenHeight
);
2193 gSpectAutoNext
:= gTime
2197 if gSpectAutoNext
<= gTime
then
2199 if gSpectAutoNext
> 0 then
2201 gSpectMode
:= GetRandomSpectMode(gSpectMode
);
2205 gSpectX
:= Random(gMapInfo
.Width
- gScreenWidth
);
2206 gSpectY
:= Random(gMapInfo
.Height
- gScreenHeight
);
2207 gSpectAutoStepX
:= Random(9) - 4;
2208 gSpectAutoStepY
:= Random(9) - 4;
2209 if ((gSpectX
< 800) and (gSpectAutoStepX
< 0)) or
2210 ((gSpectX
> gMapInfo
.Width
- gScreenWidth
- 800) and (gSpectAutoStepX
> 0)) then
2211 gSpectAutoStepX
:= gSpectAutoStepX
* -1;
2212 if ((gSpectY
< 800) and (gSpectAutoStepY
< 0)) or
2213 ((gSpectY
> gMapInfo
.Height
- gScreenHeight
- 800) and (gSpectAutoStepY
> 0)) then
2214 gSpectAutoStepY
:= gSpectAutoStepY
* -1;
2218 gSpectPID1
:= GetActivePlayerID_Random(gSpectPID1
);
2223 SPECT_STATS
: gSpectAutoNext
:= gTime
+ (Random(3) + 5) * 1000;
2224 SPECT_MAPVIEW
: gSpectAutoNext
:= gTime
+ (Random(4) + 7) * 1000;
2225 SPECT_PLAYERS
: gSpectAutoNext
:= gTime
+ (Random(7) + 8) * 1000;
2231 // Îáíîâëÿåì âñå îñòàëüíîå:
2234 g_Triggers_Update();
2236 g_Monsters_Update();
2238 g_Player_UpdateAll();
2239 g_Player_UpdatePhysicalObjects();
2241 // server: send newly spawned monsters unconditionally
2242 if (gGameSettings
.GameType
= GT_SERVER
) then
2244 if (Length(gMonstersSpawned
) > 0) then
2246 for I
:= 0 to High(gMonstersSpawned
) do MH_SEND_MonsterSpawn(gMonstersSpawned
[I
]);
2247 SetLength(gMonstersSpawned
, 0);
2251 if (gSoundTriggerTime
> 8) then
2253 g_Game_UpdateTriggerSounds();
2254 gSoundTriggerTime
:= 0;
2258 Inc(gSoundTriggerTime
);
2261 if (NetMode
= NET_SERVER
) then
2263 Inc(NetTimeToUpdate
);
2264 Inc(NetTimeToReliable
);
2266 // send monster updates
2267 if (NetTimeToReliable
>= NetRelupdRate
) or (NetTimeToUpdate
>= NetUpdateRate
) then
2269 // send all monsters (periodic sync)
2270 reliableUpdate
:= (NetTimeToReliable
>= NetRelupdRate
);
2272 for I
:= 0 to High(gPlayers
) do
2274 if (gPlayers
[I
] <> nil) then MH_SEND_PlayerPos(reliableUpdate
, gPlayers
[I
].UID
);
2277 g_Mons_ForEach(sendMonsPos
);
2279 // update flags that aren't stationary
2280 if gGameSettings
.GameMode
= GM_CTF
then
2281 for I
:= FLAG_RED
to FLAG_BLUE
do
2282 if gFlags
[I
].NeedSend
then
2284 gFlags
[I
].NeedSend
:= False;
2288 // update items that aren't stationary
2289 g_Items_ForEachAlive(sendItemPos
);
2291 if reliableUpdate
then
2293 NetTimeToReliable
:= 0;
2294 NetTimeToUpdate
:= NetUpdateRate
;
2298 NetTimeToUpdate
:= 0;
2303 // send only mosters with some unexpected changes
2304 g_Mons_ForEach(sendMonsPosUnexpected
);
2307 // send unexpected platform changes
2308 g_Map_NetSendInterestingPanels();
2310 g_Net_Slist_ServerUpdate();
2312 if NetUseMaster then
2314 if (gTime >= NetTimeToMaster) or g_Net_Slist_IsConnectionInProgress then
2316 if (not g_Net_Slist_IsConnectionActive) then g_Net_Slist_Connect(false); // non-blocking connection to the master
2318 NetTimeToMaster := gTime + NetMasterRate;
2323 else if (NetMode
= NET_CLIENT
) then
2325 MC_SEND_PlayerPos();
2327 end; // if gameOn ...
2329 // Àêòèâíî îêíî èíòåðôåéñà - ïåðåäàåì êëàâèøè åìó:
2330 if g_ActiveWindow
<> nil then
2332 w
:= e_GetFirstKeyPressed();
2334 if (w
<> IK_INVALID
) then
2336 Msg
.Msg
:= MESSAGE_DIKEY
;
2338 g_ActiveWindow
.OnMessage(Msg
);
2341 // Åñëè îíî îò ýòîãî íå çàêðûëîñü, òî îáíîâëÿåì:
2342 if g_ActiveWindow
<> nil then
2343 g_ActiveWindow
.Update();
2345 // Íóæíî ñìåíèòü ðàçðåøåíèå:
2346 if gResolutionChange
then
2348 e_WriteLog('Changing resolution', TMsgType
.Notify
);
2349 g_Game_ChangeResolution(gRC_Width
, gRC_Height
, gRC_FullScreen
, gRC_Maximized
);
2350 gResolutionChange
:= False;
2351 g_ActiveWindow
:= nil;
2354 // Íóæíî ñìåíèòü ÿçûê:
2355 if gLanguageChange
then
2357 //e_WriteLog('Read language file', MSG_NOTIFY);
2358 //g_Language_Load(DataDir + gLanguage + '.txt');
2359 g_Language_Set(gLanguage
);
2363 gLanguageChange
:= False;
2367 // Ãîðÿ÷àÿ êëàâèøà äëÿ âûçîâà ìåíþ âûõîäà èç èãðû (F10):
2368 if e_KeyPressed(IK_F10
) and
2370 (not gConsoleShow
) and
2371 (g_ActiveWindow
= nil) then
2376 Time
:= sys_GetTicks() {div 1000};
2378 // Îáðàáîòêà îòëîæåííûõ ñîáûòèé:
2379 if gDelayedEvents
<> nil then
2380 for a
:= 0 to High(gDelayedEvents
) do
2381 if gDelayedEvents
[a
].Pending
and
2383 ((gDelayedEvents
[a
].DEType
= DE_GLOBEVENT
) and (gDelayedEvents
[a
].Time
<= Time
)) or
2384 ((gDelayedEvents
[a
].DEType
> DE_GLOBEVENT
) and (gDelayedEvents
[a
].Time
<= gTime
))
2387 case gDelayedEvents
[a
].DEType
of
2389 g_Game_ExecuteEvent(gDelayedEvents
[a
].DEStr
);
2392 g_Game_Announce_GoodShot(gDelayedEvents
[a
].DENum
);
2396 g_Game_Announce_KillCombo(gDelayedEvents
[a
].DENum
);
2397 if g_Game_IsNet
and g_Game_IsServer
then
2398 MH_SEND_GameEvent(NET_EV_KILLCOMBO
, gDelayedEvents
[a
].DENum
);
2402 g_Game_Announce_BodyKill(gDelayedEvents
[a
].DENum
);
2404 gDelayedEvents
[a
].Pending
:= False;
2407 // Êàæäóþ ñåêóíäó îáíîâëÿåì ñ÷åò÷èê îáíîâëåíèé:
2408 UPSCounter
:= UPSCounter
+ 1;
2409 if Time
- UPSTime
>= 1000 then
2418 g_Weapon_AddDynLights();
2419 g_Items_AddDynLights();
2423 procedure g_Game_LoadChatSounds(Resource
: string);
2426 FileName
, Snd
: string;
2428 len
, cnt
, tags
, i
, j
: Integer;
2431 FileName
:= g_ExtractWadName(Resource
);
2433 WAD
:= TWADFile
.Create();
2434 WAD
.ReadFile(FileName
);
2436 if not WAD
.GetResource(g_ExtractFilePathName(Resource
), p
, len
) then
2443 cfg
:= TConfig
.CreateMem(p
, len
);
2444 cnt
:= cfg
.ReadInt('ChatSounds', 'Count', 0);
2446 SetLength(gChatSounds
, cnt
);
2447 for i
:= 0 to Length(gChatSounds
) - 1 do
2449 gChatSounds
[i
].Sound
:= nil;
2450 Snd
:= Trim(cfg
.ReadStr(IntToStr(i
), 'Sound', ''));
2451 tags
:= cfg
.ReadInt(IntToStr(i
), 'Tags', 0);
2452 if (Snd
= '') or (Tags
<= 0) then
2454 g_Sound_CreateWADEx('SOUND_CHAT_MACRO' + IntToStr(i
), GameWAD
+':'+Snd
);
2455 gChatSounds
[i
].Sound
:= TPlayableSound
.Create();
2456 gChatSounds
[i
].Sound
.SetByName('SOUND_CHAT_MACRO' + IntToStr(i
));
2457 SetLength(gChatSounds
[i
].Tags
, tags
);
2458 for j
:= 0 to tags
- 1 do
2459 gChatSounds
[i
].Tags
[j
] := toLowerCase1251(cfg
.ReadStr(IntToStr(i
), 'Tag' + IntToStr(j
), ''));
2460 gChatSounds
[i
].FullWord
:= cfg
.ReadBool(IntToStr(i
), 'FullWord', False);
2467 procedure g_Game_FreeChatSounds();
2471 for i
:= 0 to Length(gChatSounds
) - 1 do
2473 gChatSounds
[i
].Sound
.Free();
2474 g_Sound_Delete('SOUND_CHAT_MACRO' + IntToStr(i
));
2476 SetLength(gChatSounds
, 0);
2480 procedure g_Game_LoadData();
2487 if DataLoaded
then Exit
;
2489 e_WriteLog('Loading game data...', TMsgType
.Notify
);
2491 g_Texture_CreateWADEx('NOTEXTURE', GameWAD
+':TEXTURES\NOTEXTURE');
2492 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUD', GameWAD
+':TEXTURES\HUD');
2493 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDAIR', GameWAD
+':TEXTURES\AIRBAR');
2494 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDJET', GameWAD
+':TEXTURES\JETBAR');
2495 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDBG', GameWAD
+':TEXTURES\HUDBG');
2496 g_Texture_CreateWADEx('TEXTURE_PLAYER_ARMORHUD', GameWAD
+':TEXTURES\ARMORHUD');
2497 g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG', GameWAD
+':TEXTURES\FLAGHUD_R_BASE');
2498 g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG_S', GameWAD
+':TEXTURES\FLAGHUD_R_STOLEN');
2499 g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG_D', GameWAD
+':TEXTURES\FLAGHUD_R_DROP');
2500 g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG', GameWAD
+':TEXTURES\FLAGHUD_B_BASE');
2501 g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG_S', GameWAD
+':TEXTURES\FLAGHUD_B_STOLEN');
2502 g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG_D', GameWAD
+':TEXTURES\FLAGHUD_B_DROP');
2503 g_Texture_CreateWADEx('TEXTURE_PLAYER_TALKBUBBLE', GameWAD
+':TEXTURES\TALKBUBBLE');
2504 g_Texture_CreateWADEx('TEXTURE_PLAYER_INVULPENTA', GameWAD
+':TEXTURES\PENTA');
2505 g_Texture_CreateWADEx('TEXTURE_PLAYER_INDICATOR', GameWAD
+':TEXTURES\PLRIND');
2508 if not g_Texture_CreateWADEx('UI_GFX_PBAR_LEFT', GameWAD
+':TEXTURES\LLEFT') then hasPBarGfx
:= false;
2509 if not g_Texture_CreateWADEx('UI_GFX_PBAR_MARKER', GameWAD
+':TEXTURES\LMARKER') then hasPBarGfx
:= false;
2510 if not g_Texture_CreateWADEx('UI_GFX_PBAR_MIDDLE', GameWAD
+':TEXTURES\LMIDDLE') then hasPBarGfx
:= false;
2511 if not g_Texture_CreateWADEx('UI_GFX_PBAR_RIGHT', GameWAD
+':TEXTURES\LRIGHT') then hasPBarGfx
:= false;
2515 g_Texture_GetSize('UI_GFX_PBAR_LEFT', wl
, hl
);
2516 g_Texture_GetSize('UI_GFX_PBAR_RIGHT', wr
, hr
);
2517 g_Texture_GetSize('UI_GFX_PBAR_MIDDLE', wb
, hb
);
2518 g_Texture_GetSize('UI_GFX_PBAR_MARKER', wm
, hm
);
2519 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
2525 hasPBarGfx
:= false;
2529 g_Frames_CreateWAD(nil, 'FRAMES_TELEPORT', GameWAD
+':TEXTURES\TELEPORT', 64, 64, 10, False);
2530 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH', GameWAD
+':WEAPONS\PUNCH', 64, 64, 4, False);
2531 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_UP', GameWAD
+':WEAPONS\PUNCH_UP', 64, 64, 4, False);
2532 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_DN', GameWAD
+':WEAPONS\PUNCH_DN', 64, 64, 4, False);
2533 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_BERSERK', GameWAD
+':WEAPONS\PUNCHB', 64, 64, 4, False);
2534 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_BERSERK_UP', GameWAD
+':WEAPONS\PUNCHB_UP', 64, 64, 4, False);
2535 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_BERSERK_DN', GameWAD
+':WEAPONS\PUNCHB_DN', 64, 64, 4, False);
2536 g_Sound_CreateWADEx('SOUND_GAME_TELEPORT', GameWAD
+':SOUNDS\TELEPORT');
2537 g_Sound_CreateWADEx('SOUND_GAME_NOTELEPORT', GameWAD
+':SOUNDS\NOTELEPORT');
2538 g_Sound_CreateWADEx('SOUND_GAME_SECRET', GameWAD
+':SOUNDS\SECRET');
2539 g_Sound_CreateWADEx('SOUND_GAME_DOOROPEN', GameWAD
+':SOUNDS\DOOROPEN');
2540 g_Sound_CreateWADEx('SOUND_GAME_DOORCLOSE', GameWAD
+':SOUNDS\DOORCLOSE');
2541 g_Sound_CreateWADEx('SOUND_GAME_BULK1', GameWAD
+':SOUNDS\BULK1');
2542 g_Sound_CreateWADEx('SOUND_GAME_BULK2', GameWAD
+':SOUNDS\BULK2');
2543 g_Sound_CreateWADEx('SOUND_GAME_BUBBLE1', GameWAD
+':SOUNDS\BUBBLE1');
2544 g_Sound_CreateWADEx('SOUND_GAME_BUBBLE2', GameWAD
+':SOUNDS\BUBBLE2');
2545 g_Sound_CreateWADEx('SOUND_GAME_BURNING', GameWAD
+':SOUNDS\BURNING');
2546 g_Sound_CreateWADEx('SOUND_GAME_SWITCH1', GameWAD
+':SOUNDS\SWITCH1');
2547 g_Sound_CreateWADEx('SOUND_GAME_SWITCH0', GameWAD
+':SOUNDS\SWITCH0');
2548 g_Sound_CreateWADEx('SOUND_GAME_RADIO', GameWAD
+':SOUNDS\RADIO');
2549 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD1', GameWAD
+':SOUNDS\GOOD1');
2550 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD2', GameWAD
+':SOUNDS\GOOD2');
2551 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD3', GameWAD
+':SOUNDS\GOOD3');
2552 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD4', GameWAD
+':SOUNDS\GOOD4');
2553 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL2X', GameWAD
+':SOUNDS\KILL2X');
2554 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL3X', GameWAD
+':SOUNDS\KILL3X');
2555 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL4X', GameWAD
+':SOUNDS\KILL4X');
2556 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILLMX', GameWAD
+':SOUNDS\KILLMX');
2557 g_Sound_CreateWADEx('SOUND_ANNOUNCER_MUHAHA1', GameWAD
+':SOUNDS\MUHAHA1');
2558 g_Sound_CreateWADEx('SOUND_ANNOUNCER_MUHAHA2', GameWAD
+':SOUNDS\MUHAHA2');
2559 g_Sound_CreateWADEx('SOUND_ANNOUNCER_MUHAHA3', GameWAD
+':SOUNDS\MUHAHA3');
2560 g_Sound_CreateWADEx('SOUND_CTF_GET1', GameWAD
+':SOUNDS\GETFLAG1');
2561 g_Sound_CreateWADEx('SOUND_CTF_GET2', GameWAD
+':SOUNDS\GETFLAG2');
2562 g_Sound_CreateWADEx('SOUND_CTF_LOST1', GameWAD
+':SOUNDS\LOSTFLG1');
2563 g_Sound_CreateWADEx('SOUND_CTF_LOST2', GameWAD
+':SOUNDS\LOSTFLG2');
2564 g_Sound_CreateWADEx('SOUND_CTF_RETURN1', GameWAD
+':SOUNDS\RETFLAG1');
2565 g_Sound_CreateWADEx('SOUND_CTF_RETURN2', GameWAD
+':SOUNDS\RETFLAG2');
2566 g_Sound_CreateWADEx('SOUND_CTF_CAPTURE1', GameWAD
+':SOUNDS\CAPFLAG1');
2567 g_Sound_CreateWADEx('SOUND_CTF_CAPTURE2', GameWAD
+':SOUNDS\CAPFLAG2');
2569 goodsnd
[0] := TPlayableSound
.Create();
2570 goodsnd
[1] := TPlayableSound
.Create();
2571 goodsnd
[2] := TPlayableSound
.Create();
2572 goodsnd
[3] := TPlayableSound
.Create();
2574 goodsnd
[0].SetByName('SOUND_ANNOUNCER_GOOD1');
2575 goodsnd
[1].SetByName('SOUND_ANNOUNCER_GOOD2');
2576 goodsnd
[2].SetByName('SOUND_ANNOUNCER_GOOD3');
2577 goodsnd
[3].SetByName('SOUND_ANNOUNCER_GOOD4');
2579 killsnd
[0] := TPlayableSound
.Create();
2580 killsnd
[1] := TPlayableSound
.Create();
2581 killsnd
[2] := TPlayableSound
.Create();
2582 killsnd
[3] := TPlayableSound
.Create();
2584 killsnd
[0].SetByName('SOUND_ANNOUNCER_KILL2X');
2585 killsnd
[1].SetByName('SOUND_ANNOUNCER_KILL3X');
2586 killsnd
[2].SetByName('SOUND_ANNOUNCER_KILL4X');
2587 killsnd
[3].SetByName('SOUND_ANNOUNCER_KILLMX');
2589 hahasnd
[0] := TPlayableSound
.Create();
2590 hahasnd
[1] := TPlayableSound
.Create();
2591 hahasnd
[2] := TPlayableSound
.Create();
2593 hahasnd
[0].SetByName('SOUND_ANNOUNCER_MUHAHA1');
2594 hahasnd
[1].SetByName('SOUND_ANNOUNCER_MUHAHA2');
2595 hahasnd
[2].SetByName('SOUND_ANNOUNCER_MUHAHA3');
2597 sound_get_flag
[0] := TPlayableSound
.Create();
2598 sound_get_flag
[1] := TPlayableSound
.Create();
2599 sound_lost_flag
[0] := TPlayableSound
.Create();
2600 sound_lost_flag
[1] := TPlayableSound
.Create();
2601 sound_ret_flag
[0] := TPlayableSound
.Create();
2602 sound_ret_flag
[1] := TPlayableSound
.Create();
2603 sound_cap_flag
[0] := TPlayableSound
.Create();
2604 sound_cap_flag
[1] := TPlayableSound
.Create();
2606 sound_get_flag
[0].SetByName('SOUND_CTF_GET1');
2607 sound_get_flag
[1].SetByName('SOUND_CTF_GET2');
2608 sound_lost_flag
[0].SetByName('SOUND_CTF_LOST1');
2609 sound_lost_flag
[1].SetByName('SOUND_CTF_LOST2');
2610 sound_ret_flag
[0].SetByName('SOUND_CTF_RETURN1');
2611 sound_ret_flag
[1].SetByName('SOUND_CTF_RETURN2');
2612 sound_cap_flag
[0].SetByName('SOUND_CTF_CAPTURE1');
2613 sound_cap_flag
[1].SetByName('SOUND_CTF_CAPTURE2');
2615 g_Game_LoadChatSounds(GameWAD
+':CHATSND\SNDCFG');
2617 g_Game_SetLoadingText(_lc
[I_LOAD_ITEMS_DATA
], 0, False);
2620 g_Game_SetLoadingText(_lc
[I_LOAD_WEAPONS_DATA
], 0, False);
2621 g_Weapon_LoadData();
2623 g_Monsters_LoadData();
2628 procedure g_Game_FreeData();
2630 if not DataLoaded
then Exit
;
2633 g_Weapon_FreeData();
2634 g_Monsters_FreeData();
2636 e_WriteLog('Releasing game data...', TMsgType
.Notify
);
2638 g_Texture_Delete('NOTEXTURE');
2639 g_Texture_Delete('TEXTURE_PLAYER_HUD');
2640 g_Texture_Delete('TEXTURE_PLAYER_HUDBG');
2641 g_Texture_Delete('TEXTURE_PLAYER_ARMORHUD');
2642 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG');
2643 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG_S');
2644 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG_D');
2645 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG');
2646 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG_S');
2647 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG_D');
2648 g_Texture_Delete('TEXTURE_PLAYER_TALKBUBBLE');
2649 g_Texture_Delete('TEXTURE_PLAYER_INVULPENTA');
2650 g_Frames_DeleteByName('FRAMES_TELEPORT');
2651 g_Frames_DeleteByName('FRAMES_PUNCH');
2652 g_Frames_DeleteByName('FRAMES_PUNCH_UP');
2653 g_Frames_DeleteByName('FRAMES_PUNCH_DN');
2654 g_Frames_DeleteByName('FRAMES_PUNCH_BERSERK');
2655 g_Frames_DeleteByName('FRAMES_PUNCH_BERSERK_UP');
2656 g_Frames_DeleteByName('FRAMES_PUNCH_BERSERK_DN');
2657 g_Sound_Delete('SOUND_GAME_TELEPORT');
2658 g_Sound_Delete('SOUND_GAME_NOTELEPORT');
2659 g_Sound_Delete('SOUND_GAME_SECRET');
2660 g_Sound_Delete('SOUND_GAME_DOOROPEN');
2661 g_Sound_Delete('SOUND_GAME_DOORCLOSE');
2662 g_Sound_Delete('SOUND_GAME_BULK1');
2663 g_Sound_Delete('SOUND_GAME_BULK2');
2664 g_Sound_Delete('SOUND_GAME_BUBBLE1');
2665 g_Sound_Delete('SOUND_GAME_BUBBLE2');
2666 g_Sound_Delete('SOUND_GAME_BURNING');
2667 g_Sound_Delete('SOUND_GAME_SWITCH1');
2668 g_Sound_Delete('SOUND_GAME_SWITCH0');
2675 g_Sound_Delete('SOUND_ANNOUNCER_GOOD1');
2676 g_Sound_Delete('SOUND_ANNOUNCER_GOOD2');
2677 g_Sound_Delete('SOUND_ANNOUNCER_GOOD3');
2678 g_Sound_Delete('SOUND_ANNOUNCER_GOOD4');
2685 g_Sound_Delete('SOUND_ANNOUNCER_KILL2X');
2686 g_Sound_Delete('SOUND_ANNOUNCER_KILL3X');
2687 g_Sound_Delete('SOUND_ANNOUNCER_KILL4X');
2688 g_Sound_Delete('SOUND_ANNOUNCER_KILLMX');
2694 g_Sound_Delete('SOUND_ANNOUNCER_MUHAHA1');
2695 g_Sound_Delete('SOUND_ANNOUNCER_MUHAHA2');
2696 g_Sound_Delete('SOUND_ANNOUNCER_MUHAHA3');
2698 sound_get_flag
[0].Free();
2699 sound_get_flag
[1].Free();
2700 sound_lost_flag
[0].Free();
2701 sound_lost_flag
[1].Free();
2702 sound_ret_flag
[0].Free();
2703 sound_ret_flag
[1].Free();
2704 sound_cap_flag
[0].Free();
2705 sound_cap_flag
[1].Free();
2707 g_Sound_Delete('SOUND_CTF_GET1');
2708 g_Sound_Delete('SOUND_CTF_GET2');
2709 g_Sound_Delete('SOUND_CTF_LOST1');
2710 g_Sound_Delete('SOUND_CTF_LOST2');
2711 g_Sound_Delete('SOUND_CTF_RETURN1');
2712 g_Sound_Delete('SOUND_CTF_RETURN2');
2713 g_Sound_Delete('SOUND_CTF_CAPTURE1');
2714 g_Sound_Delete('SOUND_CTF_CAPTURE2');
2716 g_Game_FreeChatSounds();
2718 DataLoaded
:= False;
2721 procedure DrawCustomStat();
2727 ww2
, hh2
, r
, g
, b
, rr
, gg
, bb
: Byte;
2728 s1
, s2
, topstr
: String;
2730 e_TextureFontGetSize(gStdFont
, ww2
, hh2
);
2734 if g_Console_Action(ACTION_SCORES
) then
2736 if not gStatsPressed
then
2738 gStatsOff
:= not gStatsOff
;
2739 gStatsPressed
:= True;
2743 gStatsPressed
:= False;
2747 s1
:= _lc
[I_MENU_INTER_NOTICE_TAB
];
2748 w
:= (Length(s1
) * ww2
) div 2;
2749 x
:= gScreenWidth
div 2 - w
;
2751 e_TextureFontPrint(x
, y
, s1
, gStdFont
);
2755 if (gGameSettings
.GameMode
= GM_COOP
) then
2757 if gMissionFailed
then
2758 topstr
:= _lc
[I_MENU_INTER_MISSION_FAIL
]
2760 topstr
:= _lc
[I_MENU_INTER_LEVEL_COMPLETE
];
2763 topstr
:= _lc
[I_MENU_INTER_ROUND_OVER
];
2765 e_CharFont_GetSize(gMenuFont
, topstr
, ww1
, hh1
);
2766 e_CharFont_Print(gMenuFont
, (gScreenWidth
div 2)-(ww1
div 2), 16, topstr
);
2768 if g_Game_IsNet
then
2770 topstr
:= Format(_lc
[I_MENU_INTER_NOTICE_TIME
], [gServInterTime
]);
2771 if not gChatShow
then
2772 e_TextureFontPrintEx((gScreenWidth
div 2)-(Length(topstr
)*ww2
div 2),
2773 gScreenHeight
-(hh2
+4)*2, topstr
, gStdFont
, 255, 255, 255, 1);
2776 if g_Game_IsClient
then
2777 topstr
:= _lc
[I_MENU_INTER_NOTICE_MAP
]
2779 topstr
:= _lc
[I_MENU_INTER_NOTICE_SPACE
];
2780 if not gChatShow
then
2781 e_TextureFontPrintEx((gScreenWidth
div 2)-(Length(topstr
)*ww2
div 2),
2782 gScreenHeight
-(hh2
+4), topstr
, gStdFont
, 255, 255, 255, 1);
2787 w
:= gScreenWidth
-x
*2;
2793 e_DrawFillQuad(x
, y
, gScreenWidth
-x
-1, gScreenHeight
-y
-1, 64, 64, 64, 32);
2794 e_DrawQuad(x
, y
, gScreenWidth
-x
-1, gScreenHeight
-y
-1, 255, 127, 0);
2796 m
:= Max(Length(_lc
[I_MENU_MAP
])+1, Length(_lc
[I_GAME_GAME_TIME
])+1)*ww2
;
2798 case CustomStat
.GameMode
of
2801 if gGameSettings
.MaxLives
= 0 then
2802 s1
:= _lc
[I_GAME_DM
]
2804 s1
:= _lc
[I_GAME_LMS
];
2808 if gGameSettings
.MaxLives
= 0 then
2809 s1
:= _lc
[I_GAME_TDM
]
2811 s1
:= _lc
[I_GAME_TLMS
];
2813 GM_CTF
: s1
:= _lc
[I_GAME_CTF
];
2816 if gGameSettings
.MaxLives
= 0 then
2817 s1
:= _lc
[I_GAME_COOP
]
2819 s1
:= _lc
[I_GAME_SURV
];
2825 e_TextureFontPrintEx(x
+(w
div 2)-(Length(s1
)*ww2
div 2), _y
, s1
, gStdFont
, 255, 255, 255, 1);
2829 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_MENU_MAP
], gStdFont
, 255, 127, 0, 1);
2830 e_TextureFontPrint(x
+8+m
, _y
, Format('%s - %s', [CustomStat
.Map
, CustomStat
.MapName
]), gStdFont
);
2833 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_GAME_TIME
], gStdFont
, 255, 127, 0, 1);
2834 e_TextureFontPrint(x
+8+m
, _y
, Format('%d:%.2d:%.2d', [CustomStat
.GameTime
div 1000 div 3600,
2835 (CustomStat
.GameTime
div 1000 div 60) mod 60,
2836 CustomStat
.GameTime
div 1000 mod 60]), gStdFont
);
2838 pc
:= Length(CustomStat
.PlayerStat
);
2839 if pc
= 0 then Exit
;
2841 if CustomStat
.GameMode
= GM_COOP
then
2843 m
:= Max(Length(_lc
[I_GAME_MONSTERS
])+1, Length(_lc
[I_GAME_SECRETS
])+1)*ww2
;
2845 s2
:= _lc
[I_GAME_MONSTERS
];
2846 e_TextureFontPrintEx(x
+8, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2847 e_TextureFontPrintEx(x
+8+m
, _y
, IntToStr(gCoopMonstersKilled
) + '/' + IntToStr(gTotalMonsters
), gStdFont
, 255, 255, 255, 1);
2849 s2
:= _lc
[I_GAME_SECRETS
];
2850 e_TextureFontPrintEx(x
+8, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2851 e_TextureFontPrintEx(x
+8+m
, _y
, IntToStr(gCoopSecretsFound
) + '/' + IntToStr(gSecretsCount
), gStdFont
, 255, 255, 255, 1);
2854 m
:= Max(Length(_lc
[I_GAME_MONSTERS_TOTAL
])+1, Length(_lc
[I_GAME_SECRETS_TOTAL
])+1)*ww2
;
2856 s2
:= _lc
[I_GAME_MONSTERS_TOTAL
];
2857 e_TextureFontPrintEx(x
+250, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2858 e_TextureFontPrintEx(x
+250+m
, _y
, IntToStr(gCoopTotalMonstersKilled
) + '/' + IntToStr(gCoopTotalMonsters
), gStdFont
, 255, 255, 255, 1);
2860 s2
:= _lc
[I_GAME_SECRETS_TOTAL
];
2861 e_TextureFontPrintEx(x
+250, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2862 e_TextureFontPrintEx(x
+250+m
, _y
, IntToStr(gCoopTotalSecretsFound
) + '/' + IntToStr(gCoopTotalSecrets
), gStdFont
, 255, 255, 255, 1);
2866 if CustomStat
.GameMode
in [GM_TDM
, GM_CTF
] then
2871 if TeamStat
[TEAM_RED
].Score
> TeamStat
[TEAM_BLUE
].Score
then s1
:= _lc
[I_GAME_WIN_RED
]
2872 else if TeamStat
[TEAM_BLUE
].Score
> TeamStat
[TEAM_RED
].Score
then s1
:= _lc
[I_GAME_WIN_BLUE
]
2873 else s1
:= _lc
[I_GAME_WIN_DRAW
];
2875 e_TextureFontPrintEx(x
+8+(w
div 2)-(Length(s1
)*ww2
div 2), _y
, s1
, gStdFont
, 255, 255, 255, 1);
2878 for t
:= TEAM_RED
to TEAM_BLUE
do
2880 if t
= TEAM_RED
then
2882 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_TEAM_RED
],
2883 gStdFont
, 255, 0, 0, 1);
2884 e_TextureFontPrintEx(x
+w1
+8, _y
, IntToStr(CustomStat
.TeamStat
[TEAM_RED
].Score
),
2885 gStdFont
, 255, 0, 0, 1);
2892 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_TEAM_BLUE
],
2893 gStdFont
, 0, 0, 255, 1);
2894 e_TextureFontPrintEx(x
+w1
+8, _y
, IntToStr(CustomStat
.TeamStat
[TEAM_BLUE
].Score
),
2895 gStdFont
, 0, 0, 255, 1);
2901 e_DrawLine(1, x
+8, _y
+20, x
-8+w
, _y
+20, r
, g
, b
);
2904 for p
:= 0 to High(CustomStat
.PlayerStat
) do
2905 if CustomStat
.PlayerStat
[p
].Team
= t
then
2906 with CustomStat
.PlayerStat
[p
] do
2920 if (gPlayers
[Num
] <> nil) and (gPlayers
[Num
].FReady
) then
2921 e_TextureFontPrintEx(x
+16, _y
, Name
+ ' *', gStdFont
, rr
, gg
, bb
, 1)
2923 e_TextureFontPrintEx(x
+16, _y
, Name
, gStdFont
, rr
, gg
, bb
, 1);
2924 e_TextureFontPrintEx(x
+w1
+16, _y
, IntToStr(Frags
), gStdFont
, rr
, gg
, bb
, 1);
2925 e_TextureFontPrintEx(x
+w1
+w2
+16, _y
, IntToStr(Deaths
), gStdFont
, rr
, gg
, bb
, 1);
2932 else if CustomStat
.GameMode
in [GM_DM
, GM_COOP
] then
2935 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_PLAYER_NAME
], gStdFont
, 255, 127, 0, 1);
2936 e_TextureFontPrintEx(x
+8+w1
, _y
, _lc
[I_GAME_FRAGS
], gStdFont
, 255, 127, 0, 1);
2937 e_TextureFontPrintEx(x
+8+w1
+w2
, _y
, _lc
[I_GAME_DEATHS
], gStdFont
, 255, 127, 0, 1);
2940 for p
:= 0 to High(CustomStat
.PlayerStat
) do
2941 with CustomStat
.PlayerStat
[p
] do
2943 e_DrawFillQuad(x
+8, _y
+4, x
+24-1, _y
+16+4-1, Color
.R
, Color
.G
, Color
.B
, 0);
2950 if (gPlayers
[Num
] <> nil) and (gPlayers
[Num
].FReady
) then
2951 e_TextureFontPrintEx(x
+8+16+8, _y
+4, Name
+ ' *', gStdFont
, r
, r
, r
, 1, True)
2953 e_TextureFontPrintEx(x
+8+16+8, _y
+4, Name
, gStdFont
, r
, r
, r
, 1, True);
2954 e_TextureFontPrintEx(x
+w1
+8+16+8, _y
+4, IntToStr(Frags
), gStdFont
, r
, r
, r
, 1, True);
2955 e_TextureFontPrintEx(x
+w1
+w2
+8+16+8, _y
+4, IntToStr(Deaths
), gStdFont
, r
, r
, r
, 1, True);
2960 // HACK: take stats screenshot immediately after the first frame of the stats showing
2961 if gScreenshotStats
and (not StatShotDone
) and (Length(CustomStat
.PlayerStat
) > 1) then
2963 g_TakeScreenShot('stats/' + StatFilename
);
2964 StatShotDone
:= True;
2968 procedure DrawSingleStat();
2970 tm
, key_x
, val_x
, y
: Integer;
2974 procedure player_stat(n
: Integer);
2980 s1
:= Format(' %d ', [SingleStat
.PlayerStat
[n
].Kills
]);
2981 s2
:= Format(' %d', [gTotalMonsters
]);
2983 e_CharFont_Print(gMenuFont
, key_x
, y
, _lc
[I_MENU_INTER_KILLS
]);
2984 e_CharFont_PrintEx(gMenuFont
, val_x
, y
, s1
, _RGB(255, 0, 0));
2985 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2986 e_CharFont_Print(gMenuFont
, val_x
+w1
, y
, '/');
2988 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2989 e_CharFont_PrintEx(gMenuFont
, val_x
+w1
, y
, s2
, _RGB(255, 0, 0));
2991 // "Kills-per-minute: ##.#":
2992 s1
:= _lc
[I_MENU_INTER_KPM
];
2994 kpm
:= (SingleStat
.PlayerStat
[n
].Kills
/ tm
) * 60
2996 kpm
:= SingleStat
.PlayerStat
[n
].Kills
;
2997 s2
:= Format(' %.1f', [kpm
]);
2999 e_CharFont_Print(gMenuFont
, key_x
, y
+32, s1
);
3000 e_CharFont_PrintEx(gMenuFont
, val_x
, y
+32, s2
, _RGB(255, 0, 0));
3002 // "Secrets found: # / #":
3003 s1
:= Format(' %d ', [SingleStat
.PlayerStat
[n
].Secrets
]);
3004 s2
:= Format(' %d', [SingleStat
.TotalSecrets
]);
3006 e_CharFont_Print(gMenuFont
, key_x
, y
+64, _lc
[I_MENU_INTER_SECRETS
]);
3007 e_CharFont_PrintEx(gMenuFont
, val_x
, y
+64, s1
, _RGB(255, 0, 0));
3008 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
3009 e_CharFont_Print(gMenuFont
, val_x
+w1
, y
+64, '/');
3011 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
3012 e_CharFont_PrintEx(gMenuFont
, val_x
+w1
, y
+64, s2
, _RGB(255, 0, 0));
3016 // "Level Complete":
3017 e_CharFont_GetSize(gMenuFont
, _lc
[I_MENU_INTER_LEVEL_COMPLETE
], w1
, h
);
3018 e_CharFont_Print(gMenuFont
, (gScreenWidth
-w1
) div 2, 32, _lc
[I_MENU_INTER_LEVEL_COMPLETE
]);
3020 // Îïðåäåëÿåì êîîðäèíàòû âûðàâíèâàíèÿ ïî ñàìîé äëèííîé ñòðîêå:
3021 s1
:= _lc
[I_MENU_INTER_KPM
];
3022 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
3025 e_CharFont_GetSize(gMenuFont
, s1
, w2
, h
);
3027 key_x
:= (gScreenWidth
-w1
-w2
) div 2;
3028 val_x
:= key_x
+ w1
;
3031 tm
:= SingleStat
.GameTime
div 1000;
3032 s1
:= _lc
[I_MENU_INTER_TIME
];
3033 s2
:= Format(' %d:%.2d:%.2d', [tm
div (60*60), (tm
mod (60*60)) div 60, tm
mod 60]);
3035 e_CharFont_Print(gMenuFont
, key_x
, 80, s1
);
3036 e_CharFont_PrintEx(gMenuFont
, val_x
, 80, s2
, _RGB(255, 0, 0));
3038 if SingleStat
.TwoPlayers
then
3041 s1
:= _lc
[I_MENU_PLAYER_1
];
3042 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
3043 e_CharFont_Print(gMenuFont
, (gScreenWidth
-w1
) div 2, 128, s1
);
3045 // Ñòàòèñòèêà ïåðâîãî èãðîêà:
3050 s1
:= _lc
[I_MENU_PLAYER_2
];
3051 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
3052 e_CharFont_Print(gMenuFont
, (gScreenWidth
-w1
) div 2, 288, s1
);
3054 // Ñòàòèñòèêà âòîðîãî èãðîêà:
3060 // Ñòàòèñòèêà ïåðâîãî èãðîêà:
3066 procedure DrawLoadingStat();
3067 procedure drawRect (x
, y
, w
, h
: Integer);
3069 if (w
< 1) or (h
< 1) then exit
;
3071 glVertex2f(x
+0.375, y
+0.375);
3072 glVertex2f(x
+w
+0.375, y
+0.375);
3073 glVertex2f(x
+w
+0.375, y
+h
+0.375);
3074 glVertex2f(x
+0.375, y
+h
+0.375);
3078 function drawPBar (cur
, total
: Integer; washere
: Boolean): Boolean;
3080 rectW
, rectH
: Integer;
3087 idl
, idr
, idb
, idm
: LongWord
;
3091 if (total
< 1) then exit
;
3092 if (cur
< 1) then exit
; // don't blink
3093 if (not washere
) and (cur
>= total
) then exit
; // don't blink
3094 //if (cur < 0) then cur := 0;
3095 //if (cur > total) then cur := total;
3098 if (hasPBarGfx
) then
3100 g_Texture_Get('UI_GFX_PBAR_LEFT', idl
);
3101 g_Texture_GetSize('UI_GFX_PBAR_LEFT', wl
, hl
);
3102 g_Texture_Get('UI_GFX_PBAR_RIGHT', idr
);
3103 g_Texture_GetSize('UI_GFX_PBAR_RIGHT', wr
, hr
);
3104 g_Texture_Get('UI_GFX_PBAR_MIDDLE', idb
);
3105 g_Texture_GetSize('UI_GFX_PBAR_MIDDLE', wb
, hb
);
3106 g_Texture_Get('UI_GFX_PBAR_MARKER', idm
);
3107 g_Texture_GetSize('UI_GFX_PBAR_MARKER', wm
, hm
);
3109 //rectW := gScreenWidth-360;
3110 rectW
:= trunc(624.0*gScreenWidth
/1024.0);
3113 x0
:= (gScreenWidth
-rectW
) div 2;
3114 y0
:= gScreenHeight
-rectH
-64;
3115 if (y0
< 2) then y0
:= 2;
3117 glEnable(GL_SCISSOR_TEST
);
3120 glScissor(x0
, gScreenHeight
-y0
-rectH
, rectW
, rectH
);
3121 e_DrawSize(idl
, x0
, y0
, 0, true, false, wl
, hl
);
3122 e_DrawSize(idr
, x0
+rectW
-wr
, y0
, 0, true, false, wr
, hr
);
3125 glScissor(x0
+wl
, gScreenHeight
-y0
-rectH
, rectW
-wl
-wr
, rectH
);
3127 while (f
< x0
+rectW
) do
3129 e_DrawSize(idb
, f
, y0
, 0, true, false, wb
, hb
);
3134 wdt
:= (rectW
-wl
-wr
)*cur
div total
;
3135 if (wdt
> rectW
-wl
-wr
) then wdt
:= rectW
-wr
-wr
;
3138 my
:= y0
; // don't be so smart, ketmar: +(rectH-wm) div 2;
3139 glScissor(x0
+wl
, gScreenHeight
-my
-rectH
, wdt
, hm
);
3143 e_DrawSize(idm
, f
, y0
, 0, true, false, wm
, hm
);
3149 glScissor(0, 0, gScreenWidth
, gScreenHeight
);
3153 rectW
:= gScreenWidth
-64;
3156 x0
:= (gScreenWidth
-rectW
) div 2;
3157 y0
:= gScreenHeight
-rectH
-64;
3158 if (y0
< 2) then y0
:= 2;
3160 glDisable(GL_BLEND
);
3161 glDisable(GL_TEXTURE_2D
);
3163 //glClearColor(0, 0, 0, 0);
3164 //glClear(GL_COLOR_BUFFER_BIT);
3166 glColor4ub(127, 127, 127, 255);
3167 drawRect(x0
-2, y0
-2, rectW
+4, rectH
+4);
3169 glColor4ub(0, 0, 0, 255);
3170 drawRect(x0
-1, y0
-1, rectW
+2, rectH
+2);
3172 glColor4ub(127, 127, 127, 255);
3173 wdt
:= rectW
*cur
div total
;
3174 if (wdt
> rectW
) then wdt
:= rectW
;
3175 drawRect(x0
, y0
, wdt
, rectH
);
3184 if (Length(LoadingStat
.Msgs
) = 0) then exit
;
3186 e_CharFont_GetSize(gMenuFont
, _lc
[I_MENU_LOADING
], ww
, hh
);
3187 yy
:= (gScreenHeight
div 3);
3188 e_CharFont_Print(gMenuFont
, (gScreenWidth
div 2)-(ww
div 2), yy
-2*hh
, _lc
[I_MENU_LOADING
]);
3189 xx
:= (gScreenWidth
div 3);
3193 for i
:= 0 to NextMsg
-1 do
3195 if (i
= (NextMsg
-1)) and (MaxValue
> 0) then
3196 s
:= Format('%s: %d/%d', [Msgs
[i
], CurValue
, MaxValue
])
3200 e_CharFont_PrintEx(gMenuSmallFont
, xx
, yy
, s
, _RGB(255, 0, 0));
3201 yy
:= yy
+ LOADING_INTERLINE
;
3202 PBarWasHere
:= drawPBar(CurValue
, MaxValue
, PBarWasHere
);
3207 procedure DrawMenuBackground(tex
: AnsiString
);
3213 if g_Texture_Get(tex
, ID
) then
3215 e_Clear(GL_COLOR_BUFFER_BIT
, 0, 0, 0);
3216 e_GetTextureSize(ID
, @w
, @h
);
3218 w
:= round(w
* 1.333 * (gScreenHeight
/ h
))
3220 w
:= trunc(w
* (gScreenHeight
/ h
));
3221 e_DrawSize(ID
, (gScreenWidth
- w
) div 2, 0, 0, False, False, w
, gScreenHeight
);
3223 else e_Clear(GL_COLOR_BUFFER_BIT
, 0, 0, 0);
3226 procedure DrawMinimap(p
: TPlayer
; RenderRect
: e_graphics
.TRect
);
3228 a
, aX
, aY
, aX2
, aY2
, Scale
, ScaleSz
: Integer;
3230 function monDraw (mon
: TMonster
): Boolean;
3232 result
:= false; // don't stop
3237 // Ëåâûé âåðõíèé óãîë
3238 aX
:= Obj
.X
div ScaleSz
+ 1;
3239 aY
:= Obj
.Y
div ScaleSz
+ 1;
3241 aX2
:= max(Obj
.Rect
.Width
div ScaleSz
, 1);
3242 aY2
:= max(Obj
.Rect
.Height
div ScaleSz
, 1);
3243 // Ïðàâûé íèæíèé óãîë
3244 aX2
:= aX
+ aX2
- 1;
3245 aY2
:= aY
+ aY2
- 1;
3246 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 255, 0, 0);
3252 if (gMapInfo
.Width
> RenderRect
.Right
- RenderRect
.Left
) or
3253 (gMapInfo
.Height
> RenderRect
.Bottom
- RenderRect
.Top
) then
3256 // Ñêîëüêî ïèêñåëîâ êàðòû â 1 ïèêñåëå ìèíè-êàðòû:
3257 ScaleSz
:= 16 div Scale
;
3258 // Ðàçìåðû ìèíè-êàðòû:
3259 aX
:= max(gMapInfo
.Width
div ScaleSz
, 1);
3260 aY
:= max(gMapInfo
.Height
div ScaleSz
, 1);
3262 e_DrawFillQuad(0, 0, aX
-1, aY
-1, 0, 0, 0, 0);
3264 if gWalls
<> nil then
3267 for a
:= 0 to High(gWalls
) do
3269 if PanelType
<> 0 then
3271 // Ëåâûé âåðõíèé óãîë:
3272 aX
:= X
div ScaleSz
;
3273 aY
:= Y
div ScaleSz
;
3275 aX2
:= max(Width
div ScaleSz
, 1);
3276 aY2
:= max(Height
div ScaleSz
, 1);
3277 // Ïðàâûé íèæíèé óãîë:
3278 aX2
:= aX
+ aX2
- 1;
3279 aY2
:= aY
+ aY2
- 1;
3282 PANEL_WALL
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 208, 208, 208, 0);
3283 PANEL_OPENDOOR
, PANEL_CLOSEDOOR
:
3284 if Enabled
then e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 160, 160, 160, 0);
3288 if gSteps
<> nil then
3291 for a
:= 0 to High(gSteps
) do
3293 if PanelType
<> 0 then
3295 // Ëåâûé âåðõíèé óãîë:
3296 aX
:= X
div ScaleSz
;
3297 aY
:= Y
div ScaleSz
;
3299 aX2
:= max(Width
div ScaleSz
, 1);
3300 aY2
:= max(Height
div ScaleSz
, 1);
3301 // Ïðàâûé íèæíèé óãîë:
3302 aX2
:= aX
+ aX2
- 1;
3303 aY2
:= aY
+ aY2
- 1;
3305 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 128, 128, 128, 0);
3308 if gLifts
<> nil then
3311 for a
:= 0 to High(gLifts
) do
3313 if PanelType
<> 0 then
3315 // Ëåâûé âåðõíèé óãîë:
3316 aX
:= X
div ScaleSz
;
3317 aY
:= Y
div ScaleSz
;
3319 aX2
:= max(Width
div ScaleSz
, 1);
3320 aY2
:= max(Height
div ScaleSz
, 1);
3321 // Ïðàâûé íèæíèé óãîë:
3322 aX2
:= aX
+ aX2
- 1;
3323 aY2
:= aY
+ aY2
- 1;
3326 LIFTTYPE_UP
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 116, 72, 36, 0);
3327 LIFTTYPE_DOWN
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 116, 124, 96, 0);
3328 LIFTTYPE_LEFT
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 200, 80, 4, 0);
3329 LIFTTYPE_RIGHT
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 252, 140, 56, 0);
3333 if gWater
<> nil then
3336 for a
:= 0 to High(gWater
) do
3338 if PanelType
<> 0 then
3340 // Ëåâûé âåðõíèé óãîë:
3341 aX
:= X
div ScaleSz
;
3342 aY
:= Y
div ScaleSz
;
3344 aX2
:= max(Width
div ScaleSz
, 1);
3345 aY2
:= max(Height
div ScaleSz
, 1);
3346 // Ïðàâûé íèæíèé óãîë:
3347 aX2
:= aX
+ aX2
- 1;
3348 aY2
:= aY
+ aY2
- 1;
3350 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 0, 192, 0);
3353 if gAcid1
<> nil then
3355 // Ðèñóåì êèñëîòó 1:
3356 for a
:= 0 to High(gAcid1
) do
3358 if PanelType
<> 0 then
3360 // Ëåâûé âåðõíèé óãîë:
3361 aX
:= X
div ScaleSz
;
3362 aY
:= Y
div ScaleSz
;
3364 aX2
:= max(Width
div ScaleSz
, 1);
3365 aY2
:= max(Height
div ScaleSz
, 1);
3366 // Ïðàâûé íèæíèé óãîë:
3367 aX2
:= aX
+ aX2
- 1;
3368 aY2
:= aY
+ aY2
- 1;
3370 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 176, 0, 0);
3373 if gAcid2
<> nil then
3375 // Ðèñóåì êèñëîòó 2:
3376 for a
:= 0 to High(gAcid2
) do
3378 if PanelType
<> 0 then
3380 // Ëåâûé âåðõíèé óãîë:
3381 aX
:= X
div ScaleSz
;
3382 aY
:= Y
div ScaleSz
;
3384 aX2
:= max(Width
div ScaleSz
, 1);
3385 aY2
:= max(Height
div ScaleSz
, 1);
3386 // Ïðàâûé íèæíèé óãîë:
3387 aX2
:= aX
+ aX2
- 1;
3388 aY2
:= aY
+ aY2
- 1;
3390 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 176, 0, 0, 0);
3393 if gPlayers
<> nil then
3396 for a
:= 0 to High(gPlayers
) do
3397 if gPlayers
[a
] <> nil then with gPlayers
[a
] do
3399 // Ëåâûé âåðõíèé óãîë:
3400 aX
:= Obj
.X
div ScaleSz
+ 1;
3401 aY
:= Obj
.Y
div ScaleSz
+ 1;
3403 aX2
:= max(Obj
.Rect
.Width
div ScaleSz
, 1);
3404 aY2
:= max(Obj
.Rect
.Height
div ScaleSz
, 1);
3405 // Ïðàâûé íèæíèé óãîë:
3406 aX2
:= aX
+ aX2
- 1;
3407 aY2
:= aY
+ aY2
- 1;
3409 if gPlayers
[a
] = p
then
3410 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 255, 0, 0)
3413 TEAM_RED
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 0, 0, 0);
3414 TEAM_BLUE
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 0, 255, 0);
3415 else e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 128, 0, 0);
3420 g_Mons_ForEach(monDraw
);
3425 procedure renderAmbientQuad (hasAmbient
: Boolean; constref ambColor
: TDFColor
);
3427 if not hasAmbient
then exit
;
3428 e_AmbientQuad(sX
, sY
, sWidth
, sHeight
, ambColor
.r
, ambColor
.g
, ambColor
.b
, ambColor
.a
);
3432 // setup sX, sY, sWidth, sHeight, and transformation matrix before calling this!
3433 //FIXME: broken for splitscreen mode
3434 procedure renderDynLightsInternal ();
3436 //hasAmbient: Boolean;
3437 //ambColor: TDFColor;
3439 lx
, ly
, lrad
: Integer;
3440 scxywh
: array[0..3] of GLint
;
3443 if e_NoGraphics
then exit
;
3445 //TODO: lights should be in separate grid, i think
3446 // but on the other side: grid may be slower for dynlights, as their lifetime is short
3447 if (not gwin_k8_enable_light_experiments
) or (not gwin_has_stencil
) or (g_dynLightCount
< 1) then exit
;
3450 //ambColor := gCurrentMap['light_ambient'].rgba;
3451 //hasAmbient := (not ambColor.isOpaque) or (not ambColor.isBlack);
3453 { // this will multiply incoming color to alpha from framebuffer
3455 glBlendFunc(GL_DST_ALPHA, GL_ONE);
3459 * light rendering: (INVALID!)
3460 * glStencilFunc(GL_EQUAL, 0, $ff);
3462 * glClear(GL_STENCIL_BUFFER_BIT);
3463 * glStencilOp(GL_KEEP, GL_KEEP, GL_INCR);
3464 * draw shadow volume into stencil buffer
3465 * glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); // modify color buffer
3466 * glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); // don't modify stencil buffer
3468 * draw color-less quad with light alpha (WARNING! don't touch color!)
3469 * glEnable(GL_BLEND);
3470 * glBlendFunc(GL_DST_ALPHA, GL_ONE);
3471 * draw all geometry up to and including walls (with alpha-testing, probably) -- this does lighting
3473 wassc
:= (glIsEnabled(GL_SCISSOR_TEST
) <> 0);
3474 if wassc
then glGetIntegerv(GL_SCISSOR_BOX
, @scxywh
[0]) else glGetIntegerv(GL_VIEWPORT
, @scxywh
[0]);
3476 // setup OpenGL parameters
3477 glStencilMask($FFFFFFFF);
3478 glStencilFunc(GL_ALWAYS
, 0, $FFFFFFFF);
3479 glEnable(GL_STENCIL_TEST
);
3480 glEnable(GL_SCISSOR_TEST
);
3481 glClear(GL_STENCIL_BUFFER_BIT
);
3482 glStencilFunc(GL_EQUAL
, 0, $ff);
3484 for lln
:= 0 to g_dynLightCount
-1 do
3486 lx
:= g_dynLights
[lln
].x
;
3487 ly
:= g_dynLights
[lln
].y
;
3488 lrad
:= g_dynLights
[lln
].radius
;
3489 if (lrad
< 3) then continue
;
3491 if (lx
-sX
+lrad
< 0) then continue
;
3492 if (ly
-sY
+lrad
< 0) then continue
;
3493 if (lx
-sX
-lrad
>= gPlayerScreenSize
.X
) then continue
;
3494 if (ly
-sY
-lrad
>= gPlayerScreenSize
.Y
) then continue
;
3496 // set scissor to optimize drawing
3497 if (g_dbg_scale
= 1.0) then
3499 glScissor((lx
-sX
)-lrad
+2, gPlayerScreenSize
.Y
-(ly
-sY
)-lrad
-1+2, lrad
*2-4, lrad
*2-4);
3503 glScissor(0, 0, gScreenWidth
, gScreenHeight
);
3505 // no need to clear stencil buffer, light blitting will do it for us... but only for normal scale
3506 if (g_dbg_scale
<> 1.0) then glClear(GL_STENCIL_BUFFER_BIT
);
3507 glStencilOp(GL_KEEP
, GL_KEEP
, GL_INCR
);
3508 // draw extruded panels
3509 glDisable(GL_TEXTURE_2D
);
3510 glDisable(GL_BLEND
);
3511 glColorMask(GL_FALSE
, GL_FALSE
, GL_FALSE
, GL_FALSE
); // no need to modify color buffer
3512 if (lrad
> 4) then g_Map_DrawPanelShadowVolumes(lx
, ly
, lrad
);
3513 // render light texture
3514 glColorMask(GL_TRUE
, GL_TRUE
, GL_TRUE
, GL_TRUE
); // modify color buffer
3515 glStencilOp(GL_ZERO
, GL_ZERO
, GL_ZERO
); // draw light, and clear stencil buffer
3518 glBlendFunc(GL_SRC_ALPHA
, GL_ONE_MINUS_SRC_ALPHA
);
3519 glEnable(GL_TEXTURE_2D
);
3520 // color and opacity
3521 glColor4f(g_dynLights
[lln
].r
, g_dynLights
[lln
].g
, g_dynLights
[lln
].b
, g_dynLights
[lln
].a
);
3522 glBindTexture(GL_TEXTURE_2D
, g_Texture_Light());
3524 glTexCoord2f(0.0, 0.0); glVertex2i(lx
-lrad
, ly
-lrad
); // top-left
3525 glTexCoord2f(1.0, 0.0); glVertex2i(lx
+lrad
, ly
-lrad
); // top-right
3526 glTexCoord2f(1.0, 1.0); glVertex2i(lx
+lrad
, ly
+lrad
); // bottom-right
3527 glTexCoord2f(0.0, 1.0); glVertex2i(lx
-lrad
, ly
+lrad
); // bottom-left
3532 glDisable(GL_STENCIL_TEST
);
3533 glDisable(GL_BLEND
);
3534 glDisable(GL_SCISSOR_TEST
);
3535 //glScissor(0, 0, sWidth, sHeight);
3537 glScissor(scxywh
[0], scxywh
[1], scxywh
[2], scxywh
[3]);
3538 if wassc
then glEnable(GL_SCISSOR_TEST
) else glDisable(GL_SCISSOR_TEST
);
3542 function fixViewportForScale (): Boolean;
3544 nx0
, ny0
, nw
, nh
: Integer;
3547 if (g_dbg_scale
<> 1.0) then
3550 nx0
:= round(sX
-(gPlayerScreenSize
.X
-(sWidth
*g_dbg_scale
))/2/g_dbg_scale
);
3551 ny0
:= round(sY
-(gPlayerScreenSize
.Y
-(sHeight
*g_dbg_scale
))/2/g_dbg_scale
);
3552 nw
:= round(sWidth
/g_dbg_scale
);
3553 nh
:= round(sHeight
/g_dbg_scale
);
3562 // setup sX, sY, sWidth, sHeight, and transformation matrix before calling this!
3563 // WARNING! this WILL CALL `glTranslatef()`, but won't restore matrices!
3564 procedure renderMapInternal (backXOfs
, backYOfs
: Integer; setTransMatrix
: Boolean);
3566 TDrawCB
= procedure ();
3569 hasAmbient
: Boolean;
3571 doAmbient
: Boolean = false;
3573 procedure drawPanelType (profname
: AnsiString
; panType
: DWord
; doDraw
: Boolean);
3578 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin(profname
);
3579 if gdbg_map_use_accel_render
then
3581 tagmask
:= panelTypeToTag(panType
);
3582 while (gDrawPanelList
.count
> 0) do
3584 pan
:= TPanel(gDrawPanelList
.front());
3585 if ((pan
.tag
and tagmask
) = 0) then break
;
3586 if doDraw
then pan
.Draw(doAmbient
, ambColor
);
3587 gDrawPanelList
.popFront();
3592 if doDraw
then g_Map_DrawPanels(panType
, hasAmbient
, ambColor
);
3594 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
3597 procedure drawOther (profname
: AnsiString
; cb
: TDrawCB
);
3599 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin(profname
);
3600 if assigned(cb
) then cb();
3601 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
3605 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin('total');
3607 // our accelerated renderer will collect all panels to gDrawPanelList
3608 // we can use panel tag to render level parts (see GridTagXXX in g_map.pas)
3609 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin('collect');
3610 if gdbg_map_use_accel_render
then
3612 g_Map_CollectDrawPanels(sX
, sY
, sWidth
, sHeight
);
3614 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
3616 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin('skyback');
3617 g_Map_DrawBack(backXOfs
, backYOfs
);
3618 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
3620 if setTransMatrix
then
3622 //if (g_dbg_scale <> 1.0) then glTranslatef(0.0, -0.375/2, 0);
3623 glScalef(g_dbg_scale
, g_dbg_scale
, 1.0);
3624 glTranslatef(-sX
, -sY
, 0);
3628 ambColor
:= gCurrentMap
['light_ambient'].rgba
;
3629 hasAmbient
:= (not ambColor
.isOpaque
) or (not ambColor
.isBlack
);
3634 //writeln('color: (', ambColor.r, ',', ambColor.g, ',', ambColor.b, ',', ambColor.a, ')');
3635 glColor4ub(ambColor.r, ambColor.g, ambColor.b, ambColor.a);
3636 glClear(GL_COLOR_BUFFER_BIT);
3639 //writeln('color: (', ambColor.r, ',', ambColor.g, ',', ambColor.b, ',', ambColor.a, ')');
3642 drawPanelType('*back', PANEL_BACK
, g_rlayer_back
);
3643 drawPanelType('*step', PANEL_STEP
, g_rlayer_step
);
3644 drawOther('items', @g_Items_Draw
);
3645 drawOther('weapons', @g_Weapon_Draw
);
3646 drawOther('shells', @g_Player_DrawShells
);
3647 drawOther('drawall', @g_Player_DrawAll
);
3648 drawOther('corpses', @g_Player_DrawCorpses
);
3649 drawPanelType('*wall', PANEL_WALL
, g_rlayer_wall
);
3650 drawOther('monsters', @g_Monsters_Draw
);
3651 drawOther('itemdrop', @g_Items_DrawDrop
);
3652 drawPanelType('*door', PANEL_CLOSEDOOR
, g_rlayer_door
);
3653 drawOther('gfx', @g_GFX_Draw
);
3654 drawOther('flags', @g_Map_DrawFlags
);
3655 drawPanelType('*acid1', PANEL_ACID1
, g_rlayer_acid1
);
3656 drawPanelType('*acid2', PANEL_ACID2
, g_rlayer_acid2
);
3657 drawPanelType('*water', PANEL_WATER
, g_rlayer_water
);
3658 drawOther('dynlights', @renderDynLightsInternal
);
3660 if hasAmbient
{and ((not g_playerLight) or (not gwin_has_stencil) or (g_dynLightCount < 1))} then
3662 renderAmbientQuad(hasAmbient
, ambColor
);
3666 drawPanelType('*fore', PANEL_FORE
, g_rlayer_fore
);
3669 if g_debug_HealthBar
then
3671 g_Monsters_DrawHealth();
3672 g_Player_DrawHealth();
3675 if (profileFrameDraw
<> nil) then profileFrameDraw
.mainEnd(); // map rendering
3679 procedure DrawMapView(x
, y
, w
, h
: Integer);
3686 bx
:= Round(x
/(gMapInfo
.Width
- w
)*(gBackSize
.X
- w
));
3687 by
:= Round(y
/(gMapInfo
.Height
- h
)*(gBackSize
.Y
- h
));
3694 fixViewportForScale();
3695 renderMapInternal(-bx
, -by
, true);
3701 procedure DrawPlayer(p
: TPlayer
);
3703 px
, py
, a
, b
, c
, d
, i
, fX
, fY
: Integer;
3707 if (p
= nil) or (p
.FDummy
) then
3710 g_Map_DrawBack(0, 0);
3715 if (profileFrameDraw
= nil) then profileFrameDraw
:= TProfiler
.Create('RENDER', g_profile_history_size
);
3716 if (profileFrameDraw
<> nil) then profileFrameDraw
.mainBegin(g_profile_frame_draw
);
3722 camObj
:= p
.getCameraObj();
3723 camObj
.lerp(gLerpFactor
, fX
, fY
);
3724 px
:= fX
+ PLAYER_RECT_CX
;
3725 py
:= fY
+ PLAYER_RECT_CY
+nlerp(p
.SlopeOld
, camObj
.slopeUpLeft
, gLerpFactor
);
3727 if (g_dbg_scale
= 1.0) and (not g_dbg_ignore_bounds
) then
3729 if (px
> (gPlayerScreenSize
.X
div 2)) then a
:= -px
+(gPlayerScreenSize
.X
div 2) else a
:= 0;
3730 if (py
> (gPlayerScreenSize
.Y
div 2)) then b
:= -py
+(gPlayerScreenSize
.Y
div 2) else b
:= 0;
3732 if (px
> gMapInfo
.Width
-(gPlayerScreenSize
.X
div 2)) then a
:= -gMapInfo
.Width
+gPlayerScreenSize
.X
;
3733 if (py
> gMapInfo
.Height
-(gPlayerScreenSize
.Y
div 2)) then b
:= -gMapInfo
.Height
+gPlayerScreenSize
.Y
;
3735 if (gMapInfo
.Width
= gPlayerScreenSize
.X
) then a
:= 0
3736 else if (gMapInfo
.Width
< gPlayerScreenSize
.X
) then
3739 a
:= (gPlayerScreenSize
.X
-gMapInfo
.Width
) div 2;
3742 if (gMapInfo
.Height
= gPlayerScreenSize
.Y
) then b
:= 0
3743 else if (gMapInfo
.Height
< gPlayerScreenSize
.Y
) then
3746 b
:= (gPlayerScreenSize
.Y
-gMapInfo
.Height
) div 2;
3751 // scaled, ignore level bounds
3752 a
:= -px
+(gPlayerScreenSize
.X
div 2);
3753 b
:= -py
+(gPlayerScreenSize
.Y
div 2);
3758 sWidth
:= gPlayerScreenSize
.X
;
3759 sHeight
:= gPlayerScreenSize
.Y
;
3760 fixViewportForScale();
3762 i
:= py
- (sY
+ sHeight
div 2);
3763 if (p
.IncCam
> 0) then
3765 // clamp to level bounds
3766 if (sY
- p
.IncCam
< 0) then
3767 p
.IncCam
:= nclamp(sY
, 0, 120);
3768 // clamp around player position
3770 p
.IncCam
:= nclamp(p
.IncCam
, 0, max(0, 120 - i
));
3772 else if (p
.IncCam
< 0) then
3774 // clamp to level bounds
3775 if (sY
+ sHeight
- p
.IncCam
> gMapInfo
.Height
) then
3776 p
.IncCam
:= nclamp(sY
+ sHeight
- gMapInfo
.Height
, -120, 0);
3777 // clamp around player position
3779 p
.IncCam
:= nclamp(p
.IncCam
, min(0, -120 - i
), 0);
3782 sY
:= sY
- nlerp(p
.IncCamOld
, p
.IncCam
, gLerpFactor
);
3784 if (not g_dbg_ignore_bounds
) then
3786 if (sX
+sWidth
> gMapInfo
.Width
) then sX
:= gMapInfo
.Width
-sWidth
;
3787 if (sY
+sHeight
> gMapInfo
.Height
) then sY
:= gMapInfo
.Height
-sHeight
;
3788 if (sX
< 0) then sX
:= 0;
3789 if (sY
< 0) then sY
:= 0;
3792 if (gBackSize
.X
<= gPlayerScreenSize
.X
) or (gMapInfo
.Width
<= sWidth
) then c
:= 0 else c
:= trunc((gBackSize
.X
-gPlayerScreenSize
.X
)*sX
/(gMapInfo
.Width
-sWidth
));
3793 if (gBackSize
.Y
<= gPlayerScreenSize
.Y
) or (gMapInfo
.Height
<= sHeight
) then d
:= 0 else d
:= trunc((gBackSize
.Y
-gPlayerScreenSize
.Y
)*sY
/(gMapInfo
.Height
-sHeight
));
3795 //r_smallmap_h: 0: left; 1: center; 2: right
3796 //r_smallmap_v: 0: top; 1: center; 2: bottom
3798 if (gMapInfo
.Width
= sWidth
) then
3802 else if (gMapInfo
.Width
< sWidth
) then
3804 case r_smallmap_h
of
3805 1: sX
:= -((sWidth
-gMapInfo
.Width
) div 2); // center
3806 2: sX
:= -(sWidth
-gMapInfo
.Width
); // right
3807 else sX
:= 0; // left
3811 if (gMapInfo
.Height
= sHeight
) then
3815 else if (gMapInfo
.Height
< sHeight
) then
3817 case r_smallmap_v
of
3818 1: sY
:= -((sHeight
-gMapInfo
.Height
) div 2); // center
3819 2: sY
:= -(sHeight
-gMapInfo
.Height
); // bottom
3820 else sY
:= 0; // top
3826 p
.viewPortW
:= sWidth
;
3827 p
.viewPortH
:= sHeight
;
3829 {$IFDEF ENABLE_HOLMES}
3830 if (p
= gPlayer1
) then
3832 g_Holmes_plrViewPos(sX
, sY
);
3833 g_Holmes_plrViewSize(sWidth
, sHeight
);
3837 renderMapInternal(-c
, -d
, true);
3839 if (gGameSettings
.GameMode
<> GM_SINGLE
) and (gPlayerIndicator
> 0) then
3840 case gPlayerIndicator
of
3842 p
.DrawIndicator(_RGB(255, 255, 255));
3845 for i
:= 0 to High(gPlayers
) do
3846 if gPlayers
[i
] <> nil then
3847 if gPlayers
[i
] = p
then p
.DrawIndicator(_RGB(255, 255, 255))
3848 else if (gPlayers
[i
].Team
= p
.Team
) and (gPlayers
[i
].Team
<> TEAM_NONE
) then
3849 if gPlayerIndicatorStyle
= 1 then
3850 gPlayers
[i
].DrawIndicator(_RGB(192, 192, 192))
3851 else gPlayers
[i
].DrawIndicator(gPlayers
[i
].GetColor
);
3855 for a := 0 to High(gCollideMap) do
3856 for b := 0 to High(gCollideMap[a]) do
3859 if ByteBool(gCollideMap[a, b] and MARK_WALL) then
3861 if ByteBool(gCollideMap[a, b] and MARK_DOOR) then
3865 1: e_DrawPoint(1, b, a, 200, 200, 200);
3866 2: e_DrawPoint(1, b, a, 64, 64, 255);
3867 3: e_DrawPoint(1, b, a, 255, 0, 255);
3877 if gShowMap
then DrawMinimap(p
, _TRect(0, 0, 128, 128));
3878 if g_Debug_Player
then
3879 g_Player_DrawDebug(p
);
3883 procedure drawProfilers ();
3888 if g_profile_frame_draw
and (profileFrameDraw
<> nil) then px
:= px
-drawProfiles(px
, py
, profileFrameDraw
);
3889 if g_profile_collision
and (profMapCollision
<> nil) then begin px
:= px
-drawProfiles(px
, py
, profMapCollision
); py
-= calcProfilesHeight(profMonsLOS
); end;
3890 if g_profile_los
and (profMonsLOS
<> nil) then begin px
:= px
-drawProfiles(px
, py
, profMonsLOS
); py
-= calcProfilesHeight(profMonsLOS
); end;
3893 procedure g_Game_Draw();
3900 plView1
, plView2
: TPlayer
;
3903 if gExit
= EXIT_QUIT
then Exit
;
3905 Time
:= sys_GetTicks() {div 1000};
3906 FPSCounter
:= FPSCounter
+1;
3907 if Time
- FPSTime
>= 1000 then
3914 e_SetRendertarget(True);
3915 e_SetViewPort(0, 0, gScreenWidth
, gScreenHeight
);
3917 if gGameOn
or (gState
= STATE_FOLD
) then
3919 if (gPlayer1
<> nil) and (gPlayer2
<> nil) then
3921 gSpectMode
:= SPECT_NONE
;
3922 if not gRevertPlayers
then
3924 plView1
:= gPlayer1
;
3925 plView2
:= gPlayer2
;
3929 plView1
:= gPlayer2
;
3930 plView2
:= gPlayer1
;
3934 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
3936 gSpectMode
:= SPECT_NONE
;
3937 if gPlayer2
= nil then
3940 plView1
:= gPlayer2
;
3949 if (plView1
= nil) and (plView2
= nil) and (gSpectMode
= SPECT_NONE
) then
3950 gSpectMode
:= SPECT_STATS
;
3952 if gSpectMode
= SPECT_PLAYERS
then
3953 if gPlayers
<> nil then
3955 plView1
:= GetActivePlayer_ByID(gSpectPID1
);
3956 if plView1
= nil then
3958 gSpectPID1
:= GetActivePlayerID_Next();
3959 plView1
:= GetActivePlayer_ByID(gSpectPID1
);
3961 if gSpectViewTwo
then
3963 plView2
:= GetActivePlayer_ByID(gSpectPID2
);
3964 if plView2
= nil then
3966 gSpectPID2
:= GetActivePlayerID_Next();
3967 plView2
:= GetActivePlayer_ByID(gSpectPID2
);
3972 if gSpectMode
= SPECT_MAPVIEW
then
3974 // Ðåæèì ïðîñìîòðà êàðòû
3976 e_SetViewPort(0, 0, gScreenWidth
, gScreenHeight
);
3977 DrawMapView(gSpectX
, gSpectY
, gScreenWidth
, gScreenHeight
);
3978 gHearPoint1
.Active
:= True;
3979 gHearPoint1
.Coords
.X
:= gScreenWidth
div 2 + gSpectX
;
3980 gHearPoint1
.Coords
.Y
:= gScreenHeight
div 2 + gSpectY
;
3981 gHearPoint2
.Active
:= False;
3985 Split
:= (plView1
<> nil) and (plView2
<> nil);
3987 // Òî÷êè ñëóõà èãðîêîâ
3988 if plView1
<> nil then
3990 gHearPoint1
.Active
:= True;
3991 gHearPoint1
.Coords
.X
:= plView1
.GameX
+ PLAYER_RECT
.Width
;
3992 gHearPoint1
.Coords
.Y
:= plView1
.GameY
+ PLAYER_RECT
.Height
DIV 2;
3994 gHearPoint1
.Active
:= False;
3995 if plView2
<> nil then
3997 gHearPoint2
.Active
:= True;
3998 gHearPoint2
.Coords
.X
:= plView2
.GameX
+ PLAYER_RECT
.Width
;
3999 gHearPoint2
.Coords
.Y
:= plView2
.GameY
+ PLAYER_RECT
.Height
DIV 2;
4001 gHearPoint2
.Active
:= False;
4003 // Ðàçìåð ýêðàíîâ èãðîêîâ:
4004 gPlayerScreenSize
.X
:= gScreenWidth
-196;
4007 gPlayerScreenSize
.Y
:= gScreenHeight
div 2;
4008 if gScreenHeight
mod 2 = 0 then
4009 Dec(gPlayerScreenSize
.Y
);
4012 gPlayerScreenSize
.Y
:= gScreenHeight
;
4015 if gScreenHeight
mod 2 = 0 then
4016 e_SetViewPort(0, gPlayerScreenSize
.Y
+2, gPlayerScreenSize
.X
+196, gPlayerScreenSize
.Y
)
4018 e_SetViewPort(0, gPlayerScreenSize
.Y
+1, gPlayerScreenSize
.X
+196, gPlayerScreenSize
.Y
);
4020 DrawPlayer(plView1
);
4021 gPlayer1ScreenCoord
.X
:= sX
;
4022 gPlayer1ScreenCoord
.Y
:= sY
;
4026 e_SetViewPort(0, 0, gPlayerScreenSize
.X
+196, gPlayerScreenSize
.Y
);
4028 DrawPlayer(plView2
);
4029 gPlayer2ScreenCoord
.X
:= sX
;
4030 gPlayer2ScreenCoord
.Y
:= sY
;
4033 e_SetViewPort(0, 0, gScreenWidth
, gScreenHeight
);
4036 e_DrawLine(2, 0, gScreenHeight
div 2, gScreenWidth
, gScreenHeight
div 2, 0, 0, 0);
4039 {$IFDEF ENABLE_HOLMES}
4041 if (g_holmes_enabled
) then g_Holmes_Draw();
4044 if MessageText
<> '' then
4048 e_CharFont_GetSizeFmt(gMenuFont
, MessageText
, w
, h
);
4050 e_CharFont_PrintFmt(gMenuFont
, (gScreenWidth
div 2)-(w
div 2),
4051 (gScreenHeight
div 2)-(h
div 2), MessageText
)
4053 e_CharFont_PrintFmt(gMenuFont
, (gScreenWidth
div 2)-(w
div 2),
4054 Round(gScreenHeight
/ 2.75)-(h
div 2), MessageText
);
4057 if IsDrawStat
or (gSpectMode
= SPECT_STATS
) then
4060 if gSpectHUD
and (not gChatShow
) and (gSpectMode
<> SPECT_NONE
) and (not gSpectAuto
) then
4062 // Draw spectator GUI
4065 e_TextureFontGetSize(gStdFont
, ww
, hh
);
4068 e_TextureFontPrintEx(0, gScreenHeight
- (hh
+2)*2, 'MODE: Stats', gStdFont
, 255, 255, 255, 1);
4070 e_TextureFontPrintEx(0, gScreenHeight
- (hh
+2)*2, 'MODE: Observe Map', gStdFont
, 255, 255, 255, 1);
4072 e_TextureFontPrintEx(0, gScreenHeight
- (hh
+2)*2, 'MODE: Watch Players', gStdFont
, 255, 255, 255, 1);
4074 e_TextureFontPrintEx(2*ww
, gScreenHeight
- (hh
+2), '< jump >', gStdFont
, 255, 255, 255, 1);
4075 if gSpectMode
= SPECT_STATS
then
4077 e_TextureFontPrintEx(16*ww
, gScreenHeight
- (hh
+2)*2, 'Autoview', gStdFont
, 255, 255, 255, 1);
4078 e_TextureFontPrintEx(16*ww
, gScreenHeight
- (hh
+2), '< fire >', gStdFont
, 255, 255, 255, 1);
4080 if gSpectMode
= SPECT_MAPVIEW
then
4082 e_TextureFontPrintEx(22*ww
, gScreenHeight
- (hh
+2)*2, '[-]', gStdFont
, 255, 255, 255, 1);
4083 e_TextureFontPrintEx(26*ww
, gScreenHeight
- (hh
+2)*2, 'Step ' + IntToStr(gSpectStep
), gStdFont
, 255, 255, 255, 1);
4084 e_TextureFontPrintEx(34*ww
, gScreenHeight
- (hh
+2)*2, '[+]', gStdFont
, 255, 255, 255, 1);
4085 e_TextureFontPrintEx(18*ww
, gScreenHeight
- (hh
+2), '<prev weap>', gStdFont
, 255, 255, 255, 1);
4086 e_TextureFontPrintEx(30*ww
, gScreenHeight
- (hh
+2), '<next weap>', gStdFont
, 255, 255, 255, 1);
4088 if gSpectMode
= SPECT_PLAYERS
then
4090 e_TextureFontPrintEx(22*ww
, gScreenHeight
- (hh
+2)*2, 'Player 1', gStdFont
, 255, 255, 255, 1);
4091 e_TextureFontPrintEx(20*ww
, gScreenHeight
- (hh
+2), '<left/right>', gStdFont
, 255, 255, 255, 1);
4092 if gSpectViewTwo
then
4094 e_TextureFontPrintEx(37*ww
, gScreenHeight
- (hh
+2)*2, 'Player 2', gStdFont
, 255, 255, 255, 1);
4095 e_TextureFontPrintEx(34*ww
, gScreenHeight
- (hh
+2), '<prev w/next w>', gStdFont
, 255, 255, 255, 1);
4096 e_TextureFontPrintEx(52*ww
, gScreenHeight
- (hh
+2)*2, '2x View', gStdFont
, 255, 255, 255, 1);
4097 e_TextureFontPrintEx(51*ww
, gScreenHeight
- (hh
+2), '<up/down>', gStdFont
, 255, 255, 255, 1);
4101 e_TextureFontPrintEx(35*ww
, gScreenHeight
- (hh
+2)*2, '2x View', gStdFont
, 255, 255, 255, 1);
4102 e_TextureFontPrintEx(34*ww
, gScreenHeight
- (hh
+2), '<up/down>', gStdFont
, 255, 255, 255, 1);
4108 if gPauseMain
and gGameOn
and (g_ActiveWindow
= nil) then
4110 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4111 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4113 e_CharFont_GetSize(gMenuFont
, _lc
[I_MENU_PAUSE
], w
, h
);
4114 e_CharFont_Print(gMenuFont
, (gScreenWidth
div 2)-(w
div 2),
4115 (gScreenHeight
div 2)-(h
div 2), _lc
[I_MENU_PAUSE
]);
4120 if (gState
= STATE_MENU
) then
4122 if (g_ActiveWindow
= nil) or (g_ActiveWindow
.BackTexture
= '') then DrawMenuBackground('MENU_BACKGROUND');
4123 // F3 at menu will show game loading dialog
4124 if e_KeyPressed(IK_F3
) then g_Menu_Show_LoadMenu(true);
4125 if (g_ActiveWindow
<> nil) then
4127 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4128 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4132 // F3 at titlepic will show game loading dialog
4133 if e_KeyPressed(IK_F3
) then
4135 g_Menu_Show_LoadMenu(true);
4136 if (g_ActiveWindow
<> nil) then e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4141 if gState
= STATE_FOLD
then
4143 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 0, 0, 0, EndingGameCounter
);
4146 if gState
= STATE_INTERCUSTOM
then
4148 if gLastMap
and (gGameSettings
.GameMode
= GM_COOP
) then
4150 back
:= 'TEXTURE_endpic';
4151 if not g_Texture_Get(back
, ID
) then
4152 back
:= _lc
[I_TEXTURE_ENDPIC
];
4157 DrawMenuBackground(back
);
4161 if g_ActiveWindow
<> nil then
4163 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4164 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4168 if gState
= STATE_INTERSINGLE
then
4170 if EndingGameCounter
> 0 then
4172 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 0, 0, 0, EndingGameCounter
);
4178 DrawMenuBackground(back
);
4182 if g_ActiveWindow
<> nil then
4184 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4185 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4190 if gState
= STATE_ENDPIC
then
4193 if g_Texture_Get('TEXTURE_endpic', ID
) then DrawMenuBackground('TEXTURE_endpic')
4194 else DrawMenuBackground(_lc
[I_TEXTURE_ENDPIC
]);
4196 if g_ActiveWindow
<> nil then
4198 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4199 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4203 if gState
= STATE_SLIST
then
4205 // if g_Texture_Get('MENU_BACKGROUND', ID) then
4207 // e_DrawSize(ID, 0, 0, 0, False, False, gScreenWidth, gScreenHeight);
4208 // //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4210 DrawMenuBackground('MENU_BACKGROUND');
4211 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4212 g_Serverlist_Draw(slCurrent
, slTable
);
4216 if g_ActiveWindow
<> nil then
4220 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4221 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4223 g_ActiveWindow
.Draw();
4230 if g_debug_Sounds
and gGameOn
then
4232 for w
:= 0 to High(e_SoundsArray
) do
4233 for h
:= 0 to e_SoundsArray
[w
].nRefs
do
4234 e_DrawPoint(1, w
+100, h
+100, 255, 0, 0);
4239 e_TextureFontPrint(0, 0, Format('FPS: %d', [FPS
]), gStdFont
);
4240 e_TextureFontPrint(0, 16, Format('UPS: %d', [UPS
]), gStdFont
);
4243 if gGameOn
and gShowTime
then
4244 drawTime(gScreenWidth
-72, gScreenHeight
-16);
4246 if gGameOn
then drawProfilers();
4248 // TODO: draw this after the FBO and remap mouse click coordinates
4250 {$IFDEF ENABLE_HOLMES}
4254 // blit framebuffer to screen
4256 e_SetRendertarget(False);
4257 e_SetViewPort(0, 0, gWinSizeX
, gWinSizeY
);
4258 e_BlitFramebuffer(gWinSizeX
, gWinSizeY
);
4260 // draw the overlay stuff on top of it
4265 procedure g_Game_Quit();
4267 g_Game_StopAllSounds(True);
4270 g_PlayerModel_FreeData();
4271 g_Texture_DeleteAll();
4272 g_Frames_DeleteAll();
4274 //g_Menu_Free(); //k8: this segfaults after resolution change; who cares?
4277 if NetInitDone
then g_Net_Free
;
4279 // Íàäî óäàëèòü êàðòó ïîñëå òåñòà:
4280 if gMapToDelete
<> '' then
4281 g_Game_DeleteTestMap();
4287 procedure g_FatalError(Text: String);
4289 g_Console_Add(Format(_lc
[I_FATAL_ERROR
], [Text]), True);
4290 e_WriteLog(Format(_lc
[I_FATAL_ERROR
], [Text]), TMsgType
.Warning
);
4292 gExit
:= EXIT_SIMPLE
;
4293 if gGameOn
then EndGame
;
4296 procedure g_SimpleError(Text: String);
4298 g_Console_Add(Format(_lc
[I_SIMPLE_ERROR
], [Text]), True);
4299 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], [Text]), TMsgType
.Warning
);
4302 procedure g_Game_SetupScreenSize();
4304 RES_FACTOR
= 4.0 / 3.0;
4310 // Ðàçìåð ýêðàíîâ èãðîêîâ:
4311 gPlayerScreenSize
.X
:= gScreenWidth
-196;
4312 if (gPlayer1
<> nil) and (gPlayer2
<> nil) then
4313 gPlayerScreenSize
.Y
:= gScreenHeight
div 2
4315 gPlayerScreenSize
.Y
:= gScreenHeight
;
4317 // Ðàçìåð çàäíåãî ïëàíà:
4318 if BackID
<> DWORD(-1) then
4321 if (gScreenWidth
*s
> gMapInfo
.Width
) or
4322 (gScreenHeight
*s
> gMapInfo
.Height
) then
4324 gBackSize
.X
:= gScreenWidth
;
4325 gBackSize
.Y
:= gScreenHeight
;
4329 e_GetTextureSize(BackID
, @bw
, @bh
);
4330 rf
:= Single(bw
) / Single(bh
);
4331 if (rf
> RES_FACTOR
) then bw
:= Round(Single(bh
) * RES_FACTOR
)
4332 else if (rf
< RES_FACTOR
) then bh
:= Round(Single(bw
) / RES_FACTOR
);
4333 s
:= Max(gScreenWidth
/ bw
, gScreenHeight
/ bh
);
4334 if (s
< 1.0) then s
:= 1.0;
4335 gBackSize
.X
:= Round(bw
*s
);
4336 gBackSize
.Y
:= Round(bh
*s
);
4341 procedure g_Game_ChangeResolution(newWidth
, newHeight
: Word; nowFull
, nowMax
: Boolean);
4343 sys_SetDisplayMode(newWidth
, newHeight
, gBPP
, nowFull
, nowMax
);
4346 procedure g_Game_AddPlayer(Team
: Byte = TEAM_NONE
);
4348 if ((not gGameOn
) and (gState
<> STATE_INTERCUSTOM
))
4349 or (not (gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
])) then
4352 if (gGameSettings
.MaxLives
> 0) and (gLMSRespawn
= LMS_RESPAWN_NONE
) then
4355 if gPlayer1
= nil then
4357 if g_Game_IsClient
then
4359 if NetPlrUID1
> -1 then
4360 MC_SEND_CheatRequest(NET_CHEAT_SPECTATE
);
4364 if not (Team
in [TEAM_RED
, TEAM_BLUE
]) then
4365 Team
:= gPlayer1Settings
.Team
;
4367 // Ñîçäàíèå ïåðâîãî èãðîêà:
4368 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4369 gPlayer1Settings
.Color
,
4371 if gPlayer1
= nil then
4372 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]))
4375 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4376 gPlayer1
.WeapSwitchMode
:= gPlayer1Settings
.WeaponSwitch
;
4377 gPlayer1
.setWeaponPrefs(gPlayer1Settings
.WeaponPreferences
);
4378 gPlayer1
.SwitchToEmpty
:= gPlayer1Settings
.SwitchToEmpty
;
4379 gPlayer1
.SkipFist
:= gPlayer1Settings
.SkipFist
;
4380 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [gPlayer1
.Name
]), True);
4381 if g_Game_IsServer
and g_Game_IsNet
then
4382 MH_SEND_PlayerCreate(gPlayer1
.UID
);
4383 gPlayer1
.Respawn(False, True);
4384 g_Net_Slist_ServerPlayerComes();
4389 if gPlayer2
= nil then
4391 if g_Game_IsClient
then
4393 if NetPlrUID2
> -1 then
4394 gPlayer2
:= g_Player_Get(NetPlrUID2
);
4398 if not (Team
in [TEAM_RED
, TEAM_BLUE
]) then
4399 Team
:= gPlayer2Settings
.Team
;
4401 // Ñîçäàíèå âòîðîãî èãðîêà:
4402 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
4403 gPlayer2Settings
.Color
,
4405 if gPlayer2
= nil then
4406 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]))
4409 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
4410 gPlayer2
.WeapSwitchMode
:= gPlayer2Settings
.WeaponSwitch
;
4411 gPlayer2
.setWeaponPrefs(gPlayer2Settings
.WeaponPreferences
);
4412 gPlayer2
.SwitchToEmpty
:= gPlayer2Settings
.SwitchToEmpty
;
4413 gPlayer2
.SkipFist
:= gPlayer2Settings
.SkipFist
;
4414 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [gPlayer2
.Name
]), True);
4415 if g_Game_IsServer
and g_Game_IsNet
then
4416 MH_SEND_PlayerCreate(gPlayer2
.UID
);
4417 gPlayer2
.Respawn(False, True);
4418 g_Net_Slist_ServerPlayerComes();
4425 procedure g_Game_RemovePlayer();
4429 if ((not gGameOn
) and (gState
<> STATE_INTERCUSTOM
))
4430 or (not (gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
])) then
4435 if g_Game_IsServer
then
4438 Pl
.Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
4439 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [Pl
.Name
]), True);
4440 g_Player_Remove(Pl
.UID
);
4441 g_Net_Slist_ServerPlayerLeaves();
4445 gSpectLatchPID2
:= Pl
.UID
;
4453 if g_Game_IsServer
then
4456 Pl
.Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
4457 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [Pl
.Name
]), True);
4458 g_Player_Remove(Pl
.UID
);
4459 g_Net_Slist_ServerPlayerLeaves();
4462 gSpectLatchPID1
:= Pl
.UID
;
4464 MC_SEND_CheatRequest(NET_CHEAT_SPECTATE
);
4468 g_Net_Slist_ServerPlayerLeaves();
4471 procedure g_Game_Spectate();
4473 g_Game_RemovePlayer();
4474 if gPlayer1
<> nil then
4475 g_Game_RemovePlayer();
4478 procedure g_Game_SpectateCenterView();
4480 gSpectX
:= Max(gMapInfo
.Width
div 2 - gScreenWidth
div 2, 0);
4481 gSpectY
:= Max(gMapInfo
.Height
div 2 - gScreenHeight
div 2, 0);
4484 procedure g_Game_StartSingle(Map
: String; TwoPlayers
: Boolean; nPlayers
: Byte);
4491 e_WriteLog('Starting singleplayer game...', TMsgType
.Notify
);
4493 g_Game_ClearLoading();
4496 FillByte(gGameSettings
, SizeOf(TGameSettings
), 0);
4499 gGameSettings
.GameType
:= GT_SINGLE
;
4500 gGameSettings
.MaxLives
:= 0;
4501 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_ALLOWEXIT
;
4502 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_MONSTERS
;
4503 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_BOTVSMONSTER
;
4504 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_TEAMHITPROJECTILE
;
4505 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_TEAMHITTRACE
;
4506 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_RULEZRANDOM
;
4507 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_ITEMALLRANDOM
;
4508 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_ITEMHELPRANDOM
;
4509 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_ITEMAMMORANDOM
;
4510 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_ITEMWEAPONRANDOM
;
4511 gSwitchGameMode
:= GM_SINGLE
;
4513 gLMSRespawn
:= LMS_RESPAWN_NONE
;
4514 gLMSRespawnTime
:= 0;
4515 gSpectLatchPID1
:= 0;
4516 gSpectLatchPID2
:= 0;
4518 g_Game_ExecuteEvent('ongamestart');
4520 // Óñòàíîâêà ðàçìåðîâ îêîí èãðîêîâ:
4521 g_Game_SetupScreenSize();
4523 // Ñîçäàíèå ïåðâîãî èãðîêà:
4524 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4525 gPlayer1Settings
.Color
,
4526 gPlayer1Settings
.Team
, False));
4527 if gPlayer1
= nil then
4529 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
4533 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4534 gPlayer1
.WeapSwitchMode
:= gPlayer1Settings
.WeaponSwitch
;
4535 gPlayer1
.setWeaponPrefs(gPlayer1Settings
.WeaponPreferences
);
4536 gPlayer1
.SwitchToEmpty
:= gPlayer1Settings
.SwitchToEmpty
;
4537 gPlayer1
.SkipFist
:= gPlayer1Settings
.SkipFist
;
4540 // Ñîçäàíèå âòîðîãî èãðîêà, åñëè åñòü:
4543 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
4544 gPlayer2Settings
.Color
,
4545 gPlayer2Settings
.Team
, False));
4546 if gPlayer2
= nil then
4548 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
4552 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
4553 gPlayer2
.WeapSwitchMode
:= gPlayer2Settings
.WeaponSwitch
;
4554 gPlayer2
.setWeaponPrefs(gPlayer2Settings
.WeaponPreferences
);
4555 gPlayer2
.SwitchToEmpty
:= gPlayer2Settings
.SwitchToEmpty
;
4556 gPlayer2
.SkipFist
:= gPlayer2Settings
.SkipFist
;
4560 // Çàãðóçêà è çàïóñê êàðòû:
4561 if not g_Game_StartMap(false{asMegawad}, MAP
, True) then
4563 if (Pos(':\', Map
) > 0) or (Pos(':/', Map
) > 0) then tmps
:= Map
else tmps
:= gGameSettings
.WAD
+ ':\' + MAP
;
4564 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [tmps
]));
4568 // Íàñòðîéêè èãðîêîâ è áîòîâ:
4572 for i
:= nPl
+1 to nPlayers
do
4573 g_Player_Create(STD_PLAYER_MODEL
, _RGB(0, 0, 0), 0, True);
4576 procedure g_Game_StartCustom(Map
: String; GameMode
: Byte;
4577 TimeLimit
, ScoreLimit
: Word;
4579 Options
: LongWord
; nPlayers
: Byte);
4585 e_WriteLog('Starting custom game...', TMsgType
.Notify
);
4587 g_Game_ClearLoading();
4590 gGameSettings
.GameType
:= GT_CUSTOM
;
4591 gGameSettings
.GameMode
:= GameMode
;
4592 gSwitchGameMode
:= GameMode
;
4593 gGameSettings
.TimeLimit
:= TimeLimit
;
4594 gGameSettings
.ScoreLimit
:= ScoreLimit
;
4595 gGameSettings
.MaxLives
:= IfThen(GameMode
= GM_CTF
, 0, MaxLives
);
4596 gGameSettings
.Options
:= Options
;
4598 gCoopTotalMonstersKilled
:= 0;
4599 gCoopTotalSecretsFound
:= 0;
4600 gCoopTotalMonsters
:= 0;
4601 gCoopTotalSecrets
:= 0;
4605 gLMSRespawn
:= LMS_RESPAWN_NONE
;
4606 gLMSRespawnTime
:= 0;
4607 gSpectLatchPID1
:= 0;
4608 gSpectLatchPID2
:= 0;
4610 g_Game_ExecuteEvent('ongamestart');
4612 // Óñòàíîâêà ðàçìåðîâ îêîí èãðîêîâ:
4613 g_Game_SetupScreenSize();
4615 // Ðåæèì íàáëþäàòåëÿ:
4616 if nPlayers
= 0 then
4623 if nPlayers
>= 1 then
4625 // Ñîçäàíèå ïåðâîãî èãðîêà:
4626 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4627 gPlayer1Settings
.Color
,
4628 gPlayer1Settings
.Team
, False));
4629 if gPlayer1
= nil then
4631 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
4635 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4636 gPlayer1
.WeapSwitchMode
:= gPlayer1Settings
.WeaponSwitch
;
4637 gPlayer1
.setWeaponPrefs(gPlayer1Settings
.WeaponPreferences
);
4638 gPlayer1
.SwitchToEmpty
:= gPlayer1Settings
.SwitchToEmpty
;
4639 gPlayer1
.SkipFist
:= gPlayer1Settings
.SkipFist
;
4643 if nPlayers
>= 2 then
4645 // Ñîçäàíèå âòîðîãî èãðîêà:
4646 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
4647 gPlayer2Settings
.Color
,
4648 gPlayer2Settings
.Team
, False));
4649 if gPlayer2
= nil then
4651 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
4655 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
4656 gPlayer2
.WeapSwitchMode
:= gPlayer2Settings
.WeaponSwitch
;
4657 gPlayer2
.setWeaponPrefs(gPlayer2Settings
.WeaponPreferences
);
4658 gPlayer2
.SwitchToEmpty
:= gPlayer2Settings
.SwitchToEmpty
;
4659 gPlayer2
.SkipFist
:= gPlayer2Settings
.SkipFist
;
4663 // Çàãðóçêà è çàïóñê êàðòû:
4664 if not g_Game_StartMap(true{asMegawad}, Map
, True) then
4666 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [Map
]));
4670 // Íåò òî÷åê ïîÿâëåíèÿ:
4671 if (g_Map_GetPointCount(RESPAWNPOINT_PLAYER1
) +
4672 g_Map_GetPointCount(RESPAWNPOINT_PLAYER2
) +
4673 g_Map_GetPointCount(RESPAWNPOINT_DM
) +
4674 g_Map_GetPointCount(RESPAWNPOINT_RED
)+
4675 g_Map_GetPointCount(RESPAWNPOINT_BLUE
)) < 1 then
4677 g_FatalError(_lc
[I_GAME_ERROR_GET_SPAWN
]);
4681 // Íàñòðîéêè èãðîêîâ è áîòîâ:
4685 for i
:= nPl
+1 to nPlayers
do
4686 g_Player_Create(STD_PLAYER_MODEL
, _RGB(0, 0, 0), 0, True);
4689 procedure g_Game_StartServer(Map
: String; GameMode
: Byte;
4690 TimeLimit
, ScoreLimit
: Word; MaxLives
: Byte;
4691 Options
: LongWord
; nPlayers
: Byte;
4692 IPAddr
: LongWord
; Port
: Word);
4695 g_Net_Slist_ServerClosed();
4697 e_WriteLog('Starting net game (server)...', TMsgType
.Notify
);
4699 g_Game_ClearLoading();
4704 gGameSettings
.GameType
:= GT_SERVER
;
4705 gGameSettings
.GameMode
:= GameMode
;
4706 gSwitchGameMode
:= GameMode
;
4707 gGameSettings
.TimeLimit
:= TimeLimit
;
4708 gGameSettings
.ScoreLimit
:= ScoreLimit
;
4709 gGameSettings
.MaxLives
:= IfThen(GameMode
= GM_CTF
, 0, MaxLives
);
4710 gGameSettings
.Options
:= Options
;
4712 gCoopTotalMonstersKilled
:= 0;
4713 gCoopTotalSecretsFound
:= 0;
4714 gCoopTotalMonsters
:= 0;
4715 gCoopTotalSecrets
:= 0;
4719 gLMSRespawn
:= LMS_RESPAWN_NONE
;
4720 gLMSRespawnTime
:= 0;
4721 gSpectLatchPID1
:= 0;
4722 gSpectLatchPID2
:= 0;
4724 g_Game_ExecuteEvent('ongamestart');
4726 // Óñòàíîâêà ðàçìåðîâ îêíà èãðîêà
4727 g_Game_SetupScreenSize();
4729 // Ðåæèì íàáëþäàòåëÿ:
4730 if nPlayers
= 0 then
4736 if nPlayers
>= 1 then
4738 // Ñîçäàíèå ïåðâîãî èãðîêà:
4739 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4740 gPlayer1Settings
.Color
,
4741 gPlayer1Settings
.Team
, False));
4742 if gPlayer1
= nil then
4744 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
4748 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4749 gPlayer1
.WeapSwitchMode
:= gPlayer1Settings
.WeaponSwitch
;
4750 gPlayer1
.setWeaponPrefs(gPlayer1Settings
.WeaponPreferences
);
4751 gPlayer1
.SwitchToEmpty
:= gPlayer1Settings
.SwitchToEmpty
;
4752 gPlayer1
.SkipFist
:= gPlayer1Settings
.SkipFist
;
4755 if nPlayers
>= 2 then
4757 // Ñîçäàíèå âòîðîãî èãðîêà:
4758 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
4759 gPlayer2Settings
.Color
,
4760 gPlayer2Settings
.Team
, False));
4761 if gPlayer2
= nil then
4763 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
4767 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
4768 gPlayer2
.WeapSwitchMode
:= gPlayer2Settings
.WeaponSwitch
;
4769 gPlayer2
.setWeaponPrefs(gPlayer2Settings
.WeaponPreferences
);
4770 gPlayer2
.SwitchToEmpty
:= gPlayer2Settings
.SwitchToEmpty
;
4771 gPlayer2
.SkipFist
:= gPlayer2Settings
.SkipFist
;
4774 g_Game_SetLoadingText(_lc
[I_LOAD_HOST
], 0, False);
4775 if NetForwardPorts
then
4776 g_Game_SetLoadingText(_lc
[I_LOAD_PORTS
], 0, False);
4779 if not g_Net_Host(IPAddr
, Port
, NetMaxClients
) then
4781 g_FatalError(_lc
[I_NET_MSG
] + Format(_lc
[I_NET_ERR_HOST
], [Port
]));
4785 g_Net_Slist_Set(NetMasterList
);
4787 g_Net_Slist_ServerStarted();
4789 // Çàãðóçêà è çàïóñê êàðòû:
4790 if not g_Game_StartMap(false{asMegawad}, Map
, True) then
4792 g_Net_Slist_ServerClosed();
4793 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [Map
]));
4797 // Íåò òî÷åê ïîÿâëåíèÿ:
4798 if (g_Map_GetPointCount(RESPAWNPOINT_PLAYER1
) +
4799 g_Map_GetPointCount(RESPAWNPOINT_PLAYER2
) +
4800 g_Map_GetPointCount(RESPAWNPOINT_DM
) +
4801 g_Map_GetPointCount(RESPAWNPOINT_RED
)+
4802 g_Map_GetPointCount(RESPAWNPOINT_BLUE
)) < 1 then
4804 g_Net_Slist_ServerClosed();
4805 g_FatalError(_lc
[I_GAME_ERROR_GET_SPAWN
]);
4809 // Íàñòðîéêè èãðîêîâ è áîòîâ:
4812 g_Net_Slist_ServerMapStarted();
4813 NetState
:= NET_STATE_GAME
;
4816 procedure g_Game_StartClient(Addr
: String; Port
: Word; PW
: String);
4831 e_WriteLog('Starting net game (client)...', TMsgType
.Notify
);
4832 e_WriteLog('NET: Trying to connect to ' + Addr
+ ':' + IntToStr(Port
) + '...', TMsgType
.Notify
);
4834 g_Game_ClearLoading();
4839 gGameSettings
.GameType
:= GT_CLIENT
;
4841 gCoopTotalMonstersKilled
:= 0;
4842 gCoopTotalSecretsFound
:= 0;
4843 gCoopTotalMonsters
:= 0;
4844 gCoopTotalSecrets
:= 0;
4848 g_Game_ExecuteEvent('ongamestart');
4850 // Óñòàíîâêà ðàçìåðîâ îêîí èãðîêîâ:
4851 g_Game_SetupScreenSize();
4853 NetState
:= NET_STATE_AUTH
;
4855 g_Game_SetLoadingText(_lc
[I_LOAD_CONNECT
], 0, False);
4857 // create (or update) map/resource databases
4858 g_Res_CreateDatabases(true);
4860 gLMSRespawn
:= LMS_RESPAWN_NONE
;
4861 gLMSRespawnTime
:= 0;
4862 gSpectLatchPID1
:= 0;
4863 gSpectLatchPID2
:= 0;
4866 if not g_Net_Connect(Addr
, Port
) then
4868 g_FatalError(_lc
[I_NET_MSG
] + _lc
[I_NET_ERR_CONN
]);
4869 NetState
:= NET_STATE_NONE
;
4873 g_Game_SetLoadingText(_lc
[I_LOAD_SEND_INFO
], 0, False);
4875 g_Game_SetLoadingText(_lc
[I_LOAD_WAIT_INFO
], 0, False);
4880 // fuck! https://www.mail-archive.com/enet-discuss@cubik.org/msg00852.html
4881 // tl;dr: on shitdows, we can get -1 sometimes, and it is *NOT* a failure.
4882 // thank you, enet. let's ignore failures altogether then.
4883 while (enet_host_service(NetHost
, @NetEvent
, 50) > 0) do
4885 if (NetEvent
.kind
= ENET_EVENT_TYPE_RECEIVE
) then
4887 Ptr
:= NetEvent
.packet
^.data
;
4888 if not InMsg
.Init(Ptr
, NetEvent
.packet
^.dataLength
, True) then
4890 enet_packet_destroy(NetEvent
.packet
);
4894 InMsg
.ReadLongWord(); // skip size
4895 MID
:= InMsg
.ReadByte();
4897 if (MID
= NET_MSG_INFO
) and (State
= 0) then
4899 NetMyID
:= InMsg
.ReadByte();
4900 NetPlrUID1
:= InMsg
.ReadWord();
4902 WadName
:= InMsg
.ReadString();
4903 Map
:= InMsg
.ReadString();
4905 gWADHash
:= InMsg
.ReadMD5();
4907 gGameSettings
.GameMode
:= InMsg
.ReadByte();
4908 gSwitchGameMode
:= gGameSettings
.GameMode
;
4909 gGameSettings
.ScoreLimit
:= InMsg
.ReadWord();
4910 gGameSettings
.TimeLimit
:= InMsg
.ReadWord();
4911 gGameSettings
.MaxLives
:= InMsg
.ReadByte();
4912 gGameSettings
.Options
:= InMsg
.ReadLongWord();
4913 T
:= InMsg
.ReadLongWord();
4915 //newResPath := g_Res_SearchSameWAD(MapsDir, WadName, gWADHash);
4916 //if newResPath = '' then
4918 //g_Game_SetLoadingText(_lc[I_LOAD_DL_RES], 0, False);
4919 newResPath
:= g_Res_DownloadMapWAD(ExtractFileName(WadName
), gWADHash
);
4920 if newResPath
= '' then
4922 g_FatalError(_lc
[I_NET_ERR_HASH
]);
4923 enet_packet_destroy(NetEvent
.packet
);
4924 NetState
:= NET_STATE_NONE
;
4927 e_LogWritefln('using downloaded map wad [%s] for [%s]`', [newResPath
, WadName
], TMsgType
.Notify
);
4929 //newResPath := ExtractRelativePath(MapsDir, newResPath);
4932 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4933 gPlayer1Settings
.Color
,
4934 gPlayer1Settings
.Team
, False));
4936 if gPlayer1
= nil then
4938 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
4940 enet_packet_destroy(NetEvent
.packet
);
4941 NetState
:= NET_STATE_NONE
;
4945 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4946 gPlayer1
.WeapSwitchMode
:= gPlayer1Settings
.WeaponSwitch
;
4947 gPlayer1
.setWeaponPrefs(gPlayer1Settings
.WeaponPreferences
);
4948 gPlayer1
.SwitchToEmpty
:= gPlayer1Settings
.SwitchToEmpty
;
4949 gPlayer1
.SkipFist
:= gPlayer1Settings
.SkipFist
;
4950 gPlayer1
.UID
:= NetPlrUID1
;
4951 gPlayer1
.Reset(True);
4953 if not g_Game_StartMap(false{asMegawad}, newResPath
+ ':\' + Map
, True) then
4955 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [WadName
+ ':\' + Map
]));
4957 enet_packet_destroy(NetEvent
.packet
);
4958 NetState
:= NET_STATE_NONE
;
4966 enet_packet_destroy(NetEvent
.packet
);
4970 enet_packet_destroy(NetEvent
.packet
);
4974 if (NetEvent
.kind
= ENET_EVENT_TYPE_DISCONNECT
) then
4977 if (NetEvent
.data
<= NET_DISC_MAX
) then
4978 g_Console_Add(_lc
[I_NET_MSG_ERROR
] + _lc
[I_NET_ERR_CONN
] + ' ' +
4979 _lc
[TStrings_Locale(Cardinal(I_NET_DISC_NONE
) + NetEvent
.data
)], True);
4986 ProcessLoading(True);
4987 if g_Net_UserRequestExit() then
4996 g_FatalError(_lc
[I_NET_MSG
] + _lc
[I_NET_ERR_CONN
]);
4997 NetState
:= NET_STATE_NONE
;
5002 NetState
:= NET_STATE_GAME
;
5003 MC_SEND_FullStateRequest
;
5004 e_WriteLog('NET: Connection successful.', TMsgType
.Notify
);
5008 lastAsMegaWad
: Boolean = false;
5010 procedure g_Game_ChangeMap(const MapPath
: String);
5014 g_Game_ClearLoading();
5016 Force
:= gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
];
5017 // Åñëè óðîâåíü çàâåðøèëñÿ ïî òðèããåðó Âûõîä, íå î÷èùàòü èíâåíòàðü
5018 if gExitByTrigger
then
5021 gExitByTrigger
:= False;
5023 if not g_Game_StartMap(lastAsMegaWad
, MapPath
, Force
) then
5024 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [MapPath
]));
5027 procedure g_Game_Restart();
5031 if g_Game_IsClient
then
5033 map
:= g_ExtractFileName(gMapInfo
.Map
);
5034 e_LogWritefln('g_Game_Restart: map = "%s" gCurrentMapFileName = "%s"', [map
, gCurrentMapFileName
]);
5038 g_Game_ClearLoading();
5039 g_Game_StartMap(lastAsMegaWad
, Map
, True, gCurrentMapFileName
);
5042 function g_Game_StartMap (asMegawad
: Boolean; Map
: String; Force
: Boolean = False; const oldMapPath
: AnsiString
=''): Boolean;
5044 NewWAD
, ResName
: String;
5048 g_Map_Free((Map
<> gCurrentMapFileName
) and (oldMapPath
<> gCurrentMapFileName
));
5049 g_Player_RemoveAllCorpses();
5051 if (not g_Game_IsClient
) and
5052 (gSwitchGameMode
<> gGameSettings
.GameMode
) and
5053 (gGameSettings
.GameMode
<> GM_SINGLE
) then
5055 if gSwitchGameMode
= GM_CTF
then
5056 gGameSettings
.MaxLives
:= 0;
5057 gGameSettings
.GameMode
:= gSwitchGameMode
;
5060 gSwitchGameMode
:= gGameSettings
.GameMode
;
5062 g_Player_ResetTeams();
5064 lastAsMegaWad
:= asMegawad
;
5065 if isWadPath(Map
) then
5067 NewWAD
:= g_ExtractWadName(Map
);
5068 ResName
:= g_ExtractFileName(Map
);
5069 if g_Game_IsServer
then
5071 nws
:= findDiskWad(NewWAD
);
5072 //writeln('000: Map=[', Map, ']; nws=[', nws, ']; NewWAD=[', NewWAD, ']');
5075 if (length(nws
) = 0) then nws
:= e_FindWad(MegawadDirs
, NewWAD
);
5076 if (length(nws
) = 0) then nws
:= e_FindWad(MapDirs
, NewWAD
);
5080 if (length(nws
) = 0) then nws
:= e_FindWad(MapDirs
, NewWAD
);
5081 if (length(nws
) = 0) then nws
:= e_FindWad(MegawadDirs
, NewWAD
);
5083 //if (length(nws) = 0) then nws := e_FindWad(MapDownloadDirs, NewWAD);
5084 //writeln('001: Map=[', Map, ']; nws=[', nws, ']; NewWAD=[', NewWAD, ']');
5086 if (length(nws
) = 0) then
5088 ResName
:= ''; // failed
5093 if (g_Game_IsNet
) then gWADHash
:= MD5File(nws
);
5094 //writeln('********: nws=', nws, ' : Map=', Map, ' : nw=', NewWAD, ' : resname=', ResName);
5095 g_Game_LoadWAD(NewWAD
);
5100 // hash received in MC_RECV_GameEvent -> NET_EV_MAPSTART
5101 NewWAD
:= g_Game_ClientWAD(NewWAD
, gWADHash
);
5106 NewWAD
:= gGameSettings
.WAD
;
5112 //writeln('********: gsw=', gGameSettings.WAD, '; rn=', ResName);
5114 if (ResName
<> '') and (NewWAD
<> '') then
5116 //result := g_Map_Load(gGameSettings.WAD + ':\' + ResName);
5117 result
:= g_Map_Load(NewWAD
+':\'+ResName
);
5121 g_Player_ResetAll(Force
or gLastMap
, gGameSettings
.GameType
= GT_SINGLE
);
5123 gState
:= STATE_NONE
;
5124 g_ActiveWindow
:= nil;
5130 if gGameSettings
.GameMode
= GM_CTF
then
5132 g_Map_ResetFlag(FLAG_RED
);
5133 g_Map_ResetFlag(FLAG_BLUE
);
5134 // CTF, à ôëàãîâ íåò:
5135 if not g_Map_HaveFlagPoints() then
5136 g_SimpleError(_lc
[I_GAME_ERROR_CTF
]);
5141 gState
:= STATE_MENU
;
5146 gPauseMain
:= false;
5147 gPauseHolmes
:= false;
5148 NetTimeToUpdate
:= 1;
5149 NetTimeToReliable
:= 0;
5150 NetTimeToMaster
:= NetMasterRate
;
5151 gSpectLatchPID1
:= 0;
5152 gSpectLatchPID2
:= 0;
5153 gMissionFailed
:= False;
5156 gCoopMonstersKilled
:= 0;
5157 gCoopSecretsFound
:= 0;
5159 gVoteInProgress
:= False;
5160 gVotePassed
:= False;
5166 if not gGameOn
then Exit
;
5168 g_Game_SpectateCenterView();
5170 if g_Game_IsServer
then
5172 if (gGameSettings
.MaxLives
> 0) and (gGameSettings
.WarmupTime
> 0) then
5174 gLMSRespawn
:= LMS_RESPAWN_WARMUP
;
5175 gLMSRespawnTime
:= gTime
+ gGameSettings
.WarmupTime
*1000;
5176 gLMSSoftSpawn
:= True;
5177 if g_Game_IsNet
then
5178 MH_SEND_GameEvent(NET_EV_LMS_WARMUP
, gLMSRespawnTime
- gTime
);
5182 gLMSRespawn
:= LMS_RESPAWN_NONE
;
5183 gLMSRespawnTime
:= 0;
5187 if NetMode
= NET_SERVER
then
5189 // reset full state flags
5190 if NetClients
<> nil then
5191 for I
:= 0 to High(NetClients
) do
5192 NetClients
[I
].FullUpdateSent
:= False;
5194 MH_SEND_GameEvent(NET_EV_MAPSTART
, gGameSettings
.GameMode
, Map
);
5197 g_Net_Slist_ServerMapStarted();
5199 if NetClients
<> nil then
5200 for I
:= 0 to High(NetClients
) do
5201 if NetClients
[I
].Used
then
5203 NetClients
[I
].Voted
:= False;
5204 if NetClients
[I
].RequestedFullUpdate
then
5206 MH_SEND_Everything((NetClients
[I
].State
= NET_STATE_AUTH
), I
);
5207 NetClients
[I
].RequestedFullUpdate
:= False;
5211 g_Net_UnbanNonPerm();
5216 gCoopTotalMonstersKilled
:= 0;
5217 gCoopTotalSecretsFound
:= 0;
5218 gCoopTotalMonsters
:= 0;
5219 gCoopTotalSecrets
:= 0;
5223 g_Game_ExecuteEvent('onmapstart');
5226 procedure SetFirstLevel
;
5230 MapList
:= g_Map_GetMapsList(gGameSettings
.WAD
);
5231 if MapList
= nil then
5234 SortSArray(MapList
);
5235 gNextMap
:= MapList
[Low(MapList
)];
5240 procedure g_Game_ExitLevel(const Map
: AnsiString
);
5244 gCoopTotalMonstersKilled
:= gCoopTotalMonstersKilled
+ gCoopMonstersKilled
;
5245 gCoopTotalSecretsFound
:= gCoopTotalSecretsFound
+ gCoopSecretsFound
;
5246 gCoopTotalMonsters
:= gCoopTotalMonsters
+ gTotalMonsters
;
5247 gCoopTotalSecrets
:= gCoopTotalSecrets
+ gSecretsCount
;
5249 // Âûøëè â âûõîä â Îäèíî÷íîé èãðå:
5250 if gGameSettings
.GameType
= GT_SINGLE
then
5251 gExit
:= EXIT_ENDLEVELSINGLE
5252 else // Âûøëè â âûõîä â Ñâîåé èãðå
5254 gExit
:= EXIT_ENDLEVELCUSTOM
;
5255 if gGameSettings
.GameMode
= GM_COOP
then
5256 g_Player_RememberAll
;
5258 if not g_Map_Exist(gGameSettings
.WAD
+ ':\' + gNextMap
) then
5261 if gGameSettings
.GameMode
= GM_COOP
then
5264 gStatsPressed
:= True;
5265 gNextMap
:= 'MAP01';
5267 if not g_Map_Exist(gGameSettings
.WAD
+ ':\' + gNextMap
) then
5270 if g_Game_IsNet
then
5272 MH_SEND_GameStats();
5273 MH_SEND_CoopStats();
5279 procedure g_Game_RestartLevel();
5283 if gGameSettings
.GameMode
= GM_SINGLE
then
5288 gExit
:= EXIT_ENDLEVELCUSTOM
;
5289 Map
:= g_ExtractFileName(gMapInfo
.Map
);
5293 function g_Game_ClientWAD (NewWAD
: String; const WHash
: TMD5Digest
): AnsiString
;
5295 gWAD
{, xwad}: String;
5298 if not g_Game_IsClient
then Exit
;
5299 //e_LogWritefln('*** g_Game_ClientWAD: `%s`', [NewWAD]);
5301 gWAD
:= g_Res_DownloadMapWAD(ExtractFileName(NewWAD
), WHash
);
5306 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_WAD
], [ExtractFileName(NewWAD
)]));
5310 e_LogWritefln('using downloaded client map wad [%s] for [%s]', [gWAD
, NewWAD
], TMsgType
.Notify
);
5313 g_Game_LoadWAD(NewWAD
);
5317 if LowerCase(NewWAD) = LowerCase(gGameSettings.WAD) then Exit;
5318 gWAD := g_Res_SearchSameWAD(MapsDir, ExtractFileName(NewWAD), WHash);
5321 g_Game_SetLoadingText(_lc[I_LOAD_DL_RES], 0, False);
5322 gWAD := g_Res_DownloadMapWAD(ExtractFileName(NewWAD), WHash);
5326 g_FatalError(Format(_lc[I_GAME_ERROR_MAP_WAD], [ExtractFileName(NewWAD)]));
5330 NewWAD := ExtractRelativePath(MapsDir, gWAD);
5331 g_Game_LoadWAD(NewWAD);
5335 procedure g_Game_RestartRound(NoMapRestart
: Boolean = False);
5337 i
, n
, nb
, nr
: Integer;
5339 if not g_Game_IsServer
then Exit
;
5340 if gLMSRespawn
= LMS_RESPAWN_NONE
then Exit
;
5341 gLMSRespawn
:= LMS_RESPAWN_NONE
;
5342 gLMSRespawnTime
:= 0;
5345 if (gGameSettings
.GameMode
= GM_COOP
) and not NoMapRestart
then
5347 gMissionFailed
:= True;
5348 g_Game_RestartLevel
;
5352 n
:= 0; nb
:= 0; nr
:= 0;
5353 for i
:= Low(gPlayers
) to High(gPlayers
) do
5354 if (gPlayers
[i
] <> nil) and
5355 ((not gPlayers
[i
].FSpectator
) or gPlayers
[i
].FWantsInGame
or
5356 (gPlayers
[i
] is TBot
)) then
5359 if gPlayers
[i
].Team
= TEAM_RED
then Inc(nr
)
5360 else if gPlayers
[i
].Team
= TEAM_BLUE
then Inc(nb
)
5363 if (n
< 1) or ((gGameSettings
.GameMode
= GM_TDM
) and ((nr
= 0) or (nb
= 0))) then
5365 // wait a second until the fuckers finally decide to join
5366 gLMSRespawn
:= LMS_RESPAWN_WARMUP
;
5367 gLMSRespawnTime
:= gTime
+ gGameSettings
.WarmupTime
*1000;
5368 gLMSSoftSpawn
:= NoMapRestart
;
5369 if g_Game_IsNet
then
5370 MH_SEND_GameEvent(NET_EV_LMS_WARMUP
, gLMSRespawnTime
- gTime
);
5374 g_Player_RemoveAllCorpses
;
5375 g_Game_Message(_lc
[I_MESSAGE_LMS_START
], 144);
5376 if g_Game_IsNet
then
5377 MH_SEND_GameEvent(NET_EV_LMS_START
);
5379 for i
:= Low(gPlayers
) to High(gPlayers
) do
5381 if gPlayers
[i
] = nil then continue
;
5382 if gPlayers
[i
] is TBot
then gPlayers
[i
].FWantsInGame
:= True;
5383 // don't touch normal spectators
5384 if gPlayers
[i
].FSpectator
and not gPlayers
[i
].FWantsInGame
then
5386 gPlayers
[i
].FNoRespawn
:= True;
5387 gPlayers
[i
].Lives
:= 0;
5388 if g_Game_IsNet
then
5389 MH_SEND_PlayerStats(gPlayers
[I
].UID
);
5392 gPlayers
[i
].FNoRespawn
:= False;
5393 gPlayers
[i
].Lives
:= gGameSettings
.MaxLives
;
5394 gPlayers
[i
].Respawn(False, True);
5395 if gGameSettings
.GameMode
= GM_COOP
then
5397 gPlayers
[i
].Frags
:= 0;
5398 gPlayers
[i
].RecallState
;
5400 if (gPlayer1
= nil) and (gSpectLatchPID1
> 0) then
5401 gPlayer1
:= g_Player_Get(gSpectLatchPID1
);
5402 if (gPlayer2
= nil) and (gSpectLatchPID2
> 0) then
5403 gPlayer2
:= g_Player_Get(gSpectLatchPID2
);
5406 g_Items_RestartRound();
5408 gLMSSoftSpawn
:= False;
5411 function g_Game_GetFirstMap(WAD
: String): String;
5415 MapList
:= g_Map_GetMapsList(WAD
);
5416 if MapList
= nil then
5419 SortSArray(MapList
);
5420 Result
:= MapList
[Low(MapList
)];
5422 if not g_Map_Exist(WAD
+ ':\' + Result
) then
5428 function g_Game_GetNextMap(): String;
5435 MapList
:= g_Map_GetMapsList(gGameSettings
.WAD
);
5436 if MapList
= nil then
5439 Map
:= g_ExtractFileName(gMapInfo
.Map
);
5441 SortSArray(MapList
);
5443 for I
:= Low(MapList
) to High(MapList
) do
5444 if Map
= MapList
[I
] then
5450 if MapIndex
<> -255 then
5452 if MapIndex
= High(MapList
) then
5453 Result
:= MapList
[Low(MapList
)]
5455 Result
:= MapList
[MapIndex
+ 1];
5457 if not g_Map_Exist(gGameSettings
.WAD
+ ':\' + Result
) then Result
:= Map
;
5463 procedure g_Game_NextLevel();
5465 if gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
, GM_COOP
] then
5466 gExit
:= EXIT_ENDLEVELCUSTOM
5469 gExit
:= EXIT_ENDLEVELSINGLE
;
5473 if gNextMap
<> '' then Exit
;
5474 gNextMap
:= g_Game_GetNextMap();
5477 function g_Game_IsTestMap(): Boolean;
5479 result
:= StrEquCI1251(TEST_MAP_NAME
, g_ExtractFileName(gMapInfo
.Map
));
5482 procedure g_Game_DeleteTestMap();
5485 //MapName: AnsiString;
5493 a
:= Pos('.wad:\', toLowerCase1251(gMapToDelete
));
5494 if (a
= 0) then a
:= Pos('.wad:/', toLowerCase1251(gMapToDelete
));
5495 if (a
= 0) then exit
;
5497 // Âûäåëÿåì èìÿ wad-ôàéëà è èìÿ êàðòû
5498 WadName
:= Copy(gMapToDelete
, 1, a
+3);
5499 Delete(gMapToDelete
, 1, a
+5);
5500 gMapToDelete
:= UpperCase(gMapToDelete
);
5502 //CopyMemory(@MapName[0], @gMapToDelete[1], Min(16, Length(gMapToDelete)));
5505 // Èìÿ êàðòû íå ñòàíäàðòíîå òåñòîâîå:
5506 if MapName <> TEST_MAP_NAME then
5509 if not gTempDelete then
5511 time := g_GetFileTime(WadName);
5512 WAD := TWADFile.Create();
5515 if not WAD.ReadFile(WadName) then
5516 begin // Íåò òàêîãî WAD-ôàéëà
5521 // Ñîñòàâëÿåì ñïèñîê êàðò è èùåì íóæíóþ:
5523 MapList := WAD.GetResourcesList('');
5525 if MapList <> nil then
5526 for a := 0 to High(MapList) do
5527 if MapList[a] = MapName then
5529 // Óäàëÿåì è ñîõðàíÿåì:
5530 WAD.RemoveResource('', MapName);
5531 WAD.SaveTo(WadName);
5536 g_SetFileTime(WadName, time);
5539 if gTempDelete
then DeleteFile(WadName
);
5542 procedure GameCVars(P
: SSArray
);
5545 stat
: TPlayerStatArray
;
5549 procedure ParseGameFlag(Flag
: LongWord
; OffMsg
, OnMsg
: TStrings_Locale
; OnMapChange
: Boolean = False);
5553 if Length(P
) > 1 then
5558 gsGameFlags
:= gsGameFlags
or Flag
5560 gsGameFlags
:= gsGameFlags
and (not Flag
);
5562 if g_Game_IsServer
then
5565 gGameSettings
.Options
:= gGameSettings
.Options
or Flag
5567 gGameSettings
.Options
:= gGameSettings
.Options
and (not Flag
);
5568 if g_Game_IsNet
then MH_SEND_GameSettings
;
5572 if LongBool(gsGameFlags
and Flag
) then
5573 g_Console_Add(_lc
[OnMsg
])
5575 g_Console_Add(_lc
[OffMsg
]);
5577 if OnMapChange
and g_Game_IsServer
then
5578 g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
5583 cmd
:= LowerCase(P
[0]);
5585 if cmd
= 'g_gamemode' then
5587 if (Length(P
) > 1) then
5589 a
:= g_Game_TextToMode(P
[1]);
5590 if a
= GM_SINGLE
then a
:= GM_COOP
;
5591 gsGameMode
:= g_Game_ModeToText(a
);
5592 if g_Game_IsServer
then
5594 gSwitchGameMode
:= a
;
5595 if (gGameOn
and (gGameSettings
.GameMode
= GM_SINGLE
)) or
5596 (gState
= STATE_INTERSINGLE
) then
5597 gSwitchGameMode
:= GM_SINGLE
;
5599 gGameSettings
.GameMode
:= gSwitchGameMode
;
5603 if gSwitchGameMode
= gGameSettings
.GameMode
then
5604 g_Console_Add(Format(_lc
[I_MSG_GAMEMODE_CURRENT
],
5605 [g_Game_ModeToText(gGameSettings
.GameMode
)]))
5607 g_Console_Add(Format(_lc
[I_MSG_GAMEMODE_CHANGE
],
5608 [g_Game_ModeToText(gGameSettings
.GameMode
),
5609 g_Game_ModeToText(gSwitchGameMode
)]));
5611 else if cmd
= 'g_friendlyfire' then
5613 ParseGameFlag(GAME_OPTION_TEAMDAMAGE
, I_MSG_FRIENDLY_FIRE_OFF
, I_MSG_FRIENDLY_FIRE_ON
);
5615 else if cmd
= 'g_friendly_absorb_damage' then
5617 ParseGameFlag(GAME_OPTION_TEAMABSORBDAMAGE
, I_MSG_FRIENDLY_ABSORB_DAMAGE_OFF
, I_MSG_FRIENDLY_ABSORB_DAMAGE_ON
);
5619 else if cmd
= 'g_friendly_hit_trace' then
5621 ParseGameFlag(GAME_OPTION_TEAMHITTRACE
, I_MSG_FRIENDLY_HIT_TRACE_OFF
, I_MSG_FRIENDLY_HIT_TRACE_ON
);
5623 else if cmd
= 'g_friendly_hit_projectile' then
5625 ParseGameFlag(GAME_OPTION_TEAMHITPROJECTILE
, I_MSG_FRIENDLY_PROJECT_TRACE_OFF
, I_MSG_FRIENDLY_PROJECT_TRACE_ON
);
5627 else if cmd
= 'g_items_all_respawn_random' then
5629 ParseGameFlag(GAME_OPTION_ITEMALLRANDOM
, I_MSG_ITEM_ALL_RANDOM_OFF
, I_MSG_ITEM_ALL_RANDOM_ON
, False);
5631 else if cmd
= 'g_items_help_respawn_random' then
5633 ParseGameFlag(GAME_OPTION_ITEMHELPRANDOM
, I_MSG_ITEM_HELP_RANDOM_OFF
, I_MSG_ITEM_HELP_RANDOM_ON
, False);
5635 else if cmd
= 'g_items_ammo_respawn_random' then
5637 ParseGameFlag(GAME_OPTION_ITEMAMMORANDOM
, I_MSG_ITEM_AMMO_RANDOM_OFF
, I_MSG_ITEM_AMMO_RANDOM_ON
, False);
5639 else if cmd
= 'g_items_weapon_respawn_random' then
5641 ParseGameFlag(GAME_OPTION_ITEMWEAPONRANDOM
, I_MSG_ITEM_WEAPON_RANDOM_OFF
, I_MSG_ITEM_WEAPON_RANDOM_ON
);
5643 else if cmd
= 'g_powerup_randomize_respawn' then
5645 ParseGameFlag(GAME_OPTION_RULEZRANDOM
, I_MSG_RULEZ_RANDOM_OFF
, I_MSG_RULEZ_RANDOM_ON
, False);
5647 else if cmd
= 'g_weaponstay' then
5649 ParseGameFlag(GAME_OPTION_WEAPONSTAY
, I_MSG_WEAPONSTAY_OFF
, I_MSG_WEAPONSTAY_ON
);
5651 else if cmd
= 'g_allow_exit' then
5653 ParseGameFlag(GAME_OPTION_ALLOWEXIT
, I_MSG_ALLOWEXIT_OFF
, I_MSG_ALLOWEXIT_ON
, True);
5655 else if cmd
= 'g_allow_monsters' then
5657 ParseGameFlag(GAME_OPTION_MONSTERS
, I_MSG_ALLOWMON_OFF
, I_MSG_ALLOWMON_ON
, True);
5659 else if cmd
= 'g_allow_dropflag' then
5661 ParseGameFlag(GAME_OPTION_ALLOWDROPFLAG
, I_MSG_ALLOWDROPFLAG_OFF
, I_MSG_ALLOWDROPFLAG_ON
);
5663 else if cmd
= 'g_throw_flag' then
5665 ParseGameFlag(GAME_OPTION_THROWFLAG
, I_MSG_THROWFLAG_OFF
, I_MSG_THROWFLAG_ON
);
5667 else if cmd
= 'g_bot_vsplayers' then
5669 ParseGameFlag(GAME_OPTION_BOTVSPLAYER
, I_MSG_BOTSVSPLAYERS_OFF
, I_MSG_BOTSVSPLAYERS_ON
);
5671 else if cmd
= 'g_bot_vsmonsters' then
5673 ParseGameFlag(GAME_OPTION_BOTVSMONSTER
, I_MSG_BOTSVSMONSTERS_OFF
, I_MSG_BOTSVSMONSTERS_ON
);
5675 else if cmd
= 'g_dm_keys' then
5677 ParseGameFlag(GAME_OPTION_DMKEYS
, I_MSG_DMKEYS_OFF
, I_MSG_DMKEYS_ON
, True);
5679 else if cmd
= 'g_gameflags' then
5681 if Length(P
) > 1 then
5683 gsGameFlags
:= StrToDWordDef(P
[1], gsGameFlags
);
5684 if g_Game_IsServer
then
5686 gGameSettings
.Options
:= gsGameFlags
;
5687 if g_Game_IsNet
then MH_SEND_GameSettings
;
5691 g_Console_Add(Format('%s %u', [cmd
, gsGameFlags
]));
5693 else if cmd
= 'g_warmup_time' then
5695 if Length(P
) > 1 then
5697 gsWarmupTime
:= nclamp(StrToIntDef(P
[1], gsWarmupTime
), 0, $FFFF);
5698 if g_Game_IsServer
then
5700 gGameSettings
.WarmupTime
:= gsWarmupTime
;
5701 // extend warmup if it's already going
5702 if gLMSRespawn
= LMS_RESPAWN_WARMUP
then
5704 gLMSRespawnTime
:= gTime
+ gsWarmupTime
* 1000;
5705 if g_Game_IsNet
then MH_SEND_GameEvent(NET_EV_LMS_WARMUP
, gLMSRespawnTime
- gTime
);
5707 if g_Game_IsNet
then MH_SEND_GameSettings
;
5711 g_Console_Add(Format(_lc
[I_MSG_WARMUP
], [Integer(gsWarmupTime
)]));
5712 if g_Game_IsServer
then g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
5714 else if cmd
= 'g_spawn_invul' then
5716 if Length(P
) > 1 then
5718 gsSpawnInvul
:= nclamp(StrToIntDef(P
[1], gsSpawnInvul
), 0, $FFFF);
5719 if g_Game_IsServer
then
5721 gGameSettings
.SpawnInvul
:= gsSpawnInvul
;
5722 if g_Game_IsNet
then MH_SEND_GameSettings
;
5726 g_Console_Add(Format('%s %d', [cmd
, Integer(gsSpawnInvul
)]));
5728 else if cmd
= 'g_item_respawn_time' then
5730 if Length(P
) > 1 then
5732 gsItemRespawnTime
:= nclamp(StrToIntDef(P
[1], gsItemRespawnTime
), 0, $FFFF);
5733 if g_Game_IsServer
then
5735 gGameSettings
.ItemRespawnTime
:= gsItemRespawnTime
;
5736 if g_Game_IsNet
then MH_SEND_GameSettings
;
5740 g_Console_Add(Format('%s %d', [cmd
, Integer(gsItemRespawnTime
)]));
5741 if g_Game_IsServer
then g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
5743 else if cmd
= 'g_item_time_random' then
5745 if Length(P
) > 1 then
5747 gsItemRespawnRandom
:= nclamp(StrToIntDef(P
[1], gsItemRespawnRandom
), 0, $FFFF);
5748 if g_Game_IsServer
then
5750 gGameSettings
.ItemRespawnRandom
:= gsItemRespawnRandom
;
5751 if g_Game_IsNet
then MH_SEND_GameSettings
;
5755 g_Console_Add(Format('%s %d', [cmd
, Integer(gsItemRespawnRandom
)]));
5756 if g_Game_IsServer
then g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
5758 else if cmd
= 'g_powerup_respawn_time' then
5760 if Length(P
) > 1 then
5762 gsRulezRespawnTime
:= nclamp(StrToIntDef(P
[1], gsRulezRespawnTime
), 0, $FFFF);
5763 if g_Game_IsServer
then
5765 gGameSettings
.RulezRespawnTime
:= gsRulezRespawnTime
;
5766 if g_Game_IsNet
then MH_SEND_GameSettings
;
5770 g_Console_Add(Format('%s %d', [cmd
, Integer(gsRulezRespawnTime
)]));
5771 if g_Game_IsServer
then g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
5773 else if cmd
= 'g_powerup_time_random' then
5775 if Length(P
) > 1 then
5777 gsRulezRespawnRandom
:= nclamp(StrToIntDef(P
[1], gsRulezRespawnRandom
), 0, $FFFF);
5778 if g_Game_IsServer
then
5780 gGameSettings
.RulezRespawnRandom
:= gsRulezRespawnRandom
;
5781 if g_Game_IsNet
then MH_SEND_GameSettings
;
5785 g_Console_Add(Format('%s %d', [cmd
, Integer(gsRulezRespawnRandom
)]));
5786 if g_Game_IsServer
then g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
5788 else if cmd
= 'sv_intertime' then
5790 if (Length(P
) > 1) then
5791 gDefInterTime
:= Min(Max(StrToIntDef(P
[1], gDefInterTime
), -1), 120);
5793 g_Console_Add(cmd
+ ' = ' + IntToStr(gDefInterTime
));
5795 else if cmd
= 'g_max_particles' then
5797 if Length(p
) = 2 then
5799 a
:= Max(0, StrToIntDef(p
[1], 0));
5802 else if Length(p
) = 1 then
5804 e_LogWritefln('%s', [g_GFX_GetMax()])
5808 e_LogWritefln('usage: %s <n>', [cmd
])
5811 else if cmd
= 'g_max_shells' then
5813 if Length(p
) = 2 then
5815 a
:= Max(0, StrToIntDef(p
[1], 0));
5818 else if Length(p
) = 1 then
5820 e_LogWritefln('%s', [g_Shells_GetMax()])
5824 e_LogWritefln('usage: %s <n>', [cmd
])
5827 else if cmd
= 'g_max_gibs' then
5829 if Length(p
) = 2 then
5831 a
:= Max(0, StrToIntDef(p
[1], 0));
5834 else if Length(p
) = 1 then
5836 e_LogWritefln('%s', [g_Gibs_GetMax()])
5840 e_LogWritefln('usage: %s <n>', [cmd
])
5843 else if cmd
= 'g_max_corpses' then
5845 if Length(p
) = 2 then
5847 a
:= Max(0, StrToIntDef(p
[1], 0));
5850 else if Length(p
) = 1 then
5852 e_LogWritefln('%s', [g_Corpses_GetMax()])
5856 e_LogWritefln('usage: %s <n>', [cmd
])
5859 else if cmd
= 'g_force_model' then
5861 if Length(p
) = 2 then
5863 a
:= StrToIntDef(p
[1], 0);
5864 g_Force_Model_Set(a
);
5865 if (g_Force_Model_Get() <> 0) and (gPlayers
<> nil) then
5867 for a
:= Low(gPlayers
) to High(gPlayers
) do
5869 if (gPlayers
[a
] <> nil) then
5871 if (gPlayers
[a
].UID
= gPlayer1
.UID
) then
5873 else if (gPlayer2
<> nil) and (gPlayers
[a
].UID
= gPlayer2
.UID
) then
5875 gPlayers
[a
].setModel(g_Forced_Model_GetName());
5879 else if (g_Force_Model_Get() = 0) and (gPlayers
<> nil) then
5881 for a
:= Low(gPlayers
) to High(gPlayers
) do
5883 if (gPlayers
[a
] <> nil) then
5885 if (gPlayers
[a
].UID
= gPlayer1
.UID
) then
5887 else if (gPlayer2
<> nil) and (gPlayers
[a
].UID
= gPlayer2
.UID
) then
5889 gPlayers
[a
].setModel(gPlayers
[a
].FActualModelName
);
5895 else if cmd
= 'g_force_model_name' then
5897 if (Length(P
) > 1) then
5899 cmd
:= b_Text_Unformat(P
[1]);
5900 g_Forced_Model_SetName(cmd
);
5901 if (g_Force_Model_Get() <> 0) and (gPlayers
<> nil) then
5903 for a
:= Low(gPlayers
) to High(gPlayers
) do
5905 if (gPlayers
[a
] <> nil) then
5907 if (gPlayers
[a
].UID
= gPlayer1
.UID
) then
5909 else if (gPlayer2
<> nil) and (gPlayers
[a
].UID
= gPlayer2
.UID
) then
5911 gPlayers
[a
].setModel(g_Forced_Model_GetName());
5917 else if cmd
= 'g_scorelimit' then
5919 if Length(P
) > 1 then
5921 gsScoreLimit
:= nclamp(StrToIntDef(P
[1], gsScoreLimit
), 0, $FFFF);
5923 if g_Game_IsServer
then
5926 if gGameSettings
.GameMode
= GM_DM
then
5928 stat
:= g_Player_GetStats();
5930 for a
:= 0 to High(stat
) do
5931 if stat
[a
].Frags
> b
then
5935 b
:= Max(gTeamStat
[TEAM_RED
].Score
, gTeamStat
[TEAM_BLUE
].Score
);
5937 // if someone has a higher score, set it to that instead
5938 gsScoreLimit
:= max(gsScoreLimit
, b
);
5939 gGameSettings
.ScoreLimit
:= gsScoreLimit
;
5941 if g_Game_IsNet
then MH_SEND_GameSettings
;
5945 g_Console_Add(Format(_lc
[I_MSG_SCORE_LIMIT
], [Integer(gsScoreLimit
)]));
5947 else if cmd
= 'g_timelimit' then
5949 if Length(P
) > 1 then
5951 gsTimeLimit
:= nclamp(StrToIntDef(P
[1], gsTimeLimit
), 0, $FFFF);
5952 if g_Game_IsServer
then
5954 gGameSettings
.TimeLimit
:= gsTimeLimit
;
5955 if g_Game_IsNet
then MH_SEND_GameSettings
;
5958 g_Console_Add(Format(_lc
[I_MSG_TIME_LIMIT
],
5959 [gsTimeLimit
div 3600,
5960 (gsTimeLimit
div 60) mod 60,
5961 gsTimeLimit
mod 60]));
5963 else if cmd
= 'g_max_bots' then
5965 if Length(P
) > 1 then
5966 gMaxBots
:= nclamp(StrToIntDef(P
[1], gMaxBots
), 0, 127);
5967 g_Console_Add('g_max_bots = ' + IntToStr(gMaxBots
));
5969 else if cmd
= 'g_maxlives' then
5971 if Length(P
) > 1 then
5973 gsMaxLives
:= nclamp(StrToIntDef(P
[1], gsMaxLives
), 0, $FFFF);
5974 if g_Game_IsServer
then
5976 gGameSettings
.MaxLives
:= gsMaxLives
;
5977 if g_Game_IsNet
then MH_SEND_GameSettings
;
5981 g_Console_Add(Format(_lc
[I_MSG_LIVES
], [Integer(gsMaxLives
)]));
5985 procedure PlayerSettingsCVars(P
: SSArray
);
5990 function ParseTeam(s
: string): Byte;
5994 'red', '1': result
:= TEAM_RED
;
5995 'blue', '2': result
:= TEAM_BLUE
;
5996 else result
:= TEAM_NONE
;
6000 cmd
:= LowerCase(P
[0]);
6004 if (Length(P
) > 1) then
6006 gPlayer1Settings
.Name
:= b_Text_Unformat(P
[1]);
6007 if g_Game_IsClient
then
6008 MC_SEND_PlayerSettings
6009 else if gGameOn
and (gPlayer1
<> nil) then
6011 gPlayer1
.Name
:= b_Text_Unformat(P
[1]);
6012 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer1
.UID
);
6018 if (Length(P
) > 1) then
6020 gPlayer2Settings
.Name
:= b_Text_Unformat(P
[1]);
6021 if g_Game_IsClient
then
6022 MC_SEND_PlayerSettings
6023 else if gGameOn
and (gPlayer2
<> nil) then
6025 gPlayer2
.Name
:= b_Text_Unformat(P
[1]);
6026 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer2
.UID
);
6032 if Length(P
) > 3 then
6034 gPlayer1Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
6035 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
6036 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
6037 if g_Game_IsClient
then
6038 MC_SEND_PlayerSettings
6039 else if gGameOn
and (gPlayer1
<> nil) then
6041 gPlayer1
.SetColor(gPlayer1Settings
.Color
);
6042 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer1
.UID
);
6048 if Length(P
) > 3 then
6050 gPlayer2Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
6051 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
6052 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
6053 if g_Game_IsClient
then
6054 MC_SEND_PlayerSettings
6055 else if gGameOn
and (gPlayer2
<> nil) then
6057 gPlayer2
.SetColor(gPlayer2Settings
.Color
);
6058 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer2
.UID
);
6064 if (Length(P
) > 1) then
6066 gPlayer1Settings
.Model
:= P
[1];
6067 if g_Game_IsClient
then
6068 MC_SEND_PlayerSettings
6069 else if gGameOn
and (gPlayer1
<> nil) then
6071 gPlayer1
.FActualModelName
:= gPlayer1Settings
.Model
;
6072 gPlayer1
.SetModel(gPlayer1Settings
.Model
);
6073 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer1
.UID
);
6079 if (Length(P
) > 1) then
6081 gPlayer2Settings
.Model
:= P
[1];
6082 if g_Game_IsClient
then
6083 MC_SEND_PlayerSettings
6084 else if gGameOn
and (gPlayer2
<> nil) then
6086 gPlayer2
.FActualModelName
:= gPlayer2Settings
.Model
;
6087 gPlayer2
.SetModel(gPlayer2Settings
.Model
);
6088 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer2
.UID
);
6094 // TODO: switch teams if in game or store this separately
6095 if (Length(P
) > 1) then
6097 team
:= ParseTeam(P
[1]);
6098 if team
= TEAM_NONE
then
6099 g_Console_Add('expected ''red'', ''blue'', 1 or 2')
6100 else if not gGameOn
and not g_Game_IsNet
then
6101 gPlayer1Settings
.Team
:= team
6103 g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
6108 // TODO: switch teams if in game or store this separately
6109 if (Length(P
) > 1) then
6111 team
:= ParseTeam(P
[1]);
6112 if team
= TEAM_NONE
then
6113 g_Console_Add('expected ''red'', ''blue'', 1 or 2')
6114 else if not gGameOn
and not g_Game_IsNet
then
6115 gPlayer2Settings
.Team
:= team
6117 g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
6122 if (Length(P
) = 2) then
6123 gPlayer1Settings
.WeaponSwitch
:= EnsureRange(StrTointDef(P
[1], 0), 0, 2);
6127 if (Length(P
) = 2) then
6128 gPlayer2Settings
.WeaponSwitch
:= EnsureRange(StrTointDef(P
[1], 0), 0, 2);
6132 if (Length(P
) = 2) then
6133 gPlayer1Settings
.SwitchToEmpty
:= EnsureRange(StrTointDef(P
[1], 0), 0, 1);
6137 if (Length(P
) = 2) then
6138 gPlayer2Settings
.SwitchToEmpty
:= EnsureRange(StrTointDef(P
[1], 0), 0, 1);
6142 if (Length(P
) = 2) then
6143 gPlayer1Settings
.SkipFist
:= EnsureRange(StrTointDef(P
[1], 0), 0, 1);
6147 if (Length(P
) = 2) then
6148 gPlayer2Settings
.SkipFist
:= EnsureRange(StrTointDef(P
[1], 0), 0, 1);
6150 'p1_priority_kastet':
6152 if (Length(P
) = 2) then
6153 gPlayer1Settings
.WeaponPreferences
[WEAPON_KASTET
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6155 'p2_priority_kastet':
6157 if (Length(P
) = 2) then
6158 gPlayer2Settings
.WeaponPreferences
[WEAPON_KASTET
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6162 if (Length(P
) = 2) then
6163 gPlayer1Settings
.WeaponPreferences
[WEAPON_SAW
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6167 if (Length(P
) = 2) then
6168 gPlayer2Settings
.WeaponPreferences
[WEAPON_SAW
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6170 'p1_priority_pistol':
6172 if (Length(P
) = 2) then
6173 gPlayer1Settings
.WeaponPreferences
[WEAPON_KASTET
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6175 'p2_priority_pistol':
6177 if (Length(P
) = 2) then
6178 gPlayer2Settings
.WeaponPreferences
[WEAPON_KASTET
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6180 'p1_priority_shotgun1':
6182 if (Length(P
) = 2) then
6183 gPlayer1Settings
.WeaponPreferences
[WEAPON_SHOTGUN1
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6185 'p2_priority_shotgun1':
6187 if (Length(P
) = 2) then
6188 gPlayer2Settings
.WeaponPreferences
[WEAPON_SHOTGUN1
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6190 'p1_priority_shotgun2':
6192 if (Length(P
) = 2) then
6193 gPlayer1Settings
.WeaponPreferences
[WEAPON_SHOTGUN2
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6195 'p2_priority_shotgun2':
6197 if (Length(P
) = 2) then
6198 gPlayer2Settings
.WeaponPreferences
[WEAPON_SHOTGUN2
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6200 'p1_priority_chaingun':
6202 if (Length(P
) = 2) then
6203 gPlayer1Settings
.WeaponPreferences
[WEAPON_CHAINGUN
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6205 'p2_priority_chaingun':
6207 if (Length(P
) = 2) then
6208 gPlayer2Settings
.WeaponPreferences
[WEAPON_CHAINGUN
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6210 'p1_priority_rocketlauncher':
6212 if (Length(P
) = 2) then
6213 gPlayer1Settings
.WeaponPreferences
[WEAPON_ROCKETLAUNCHER
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6215 'p2_priority_rocketlauncher':
6217 if (Length(P
) = 2) then
6218 gPlayer2Settings
.WeaponPreferences
[WEAPON_ROCKETLAUNCHER
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6220 'p1_priority_plasma':
6222 if (Length(P
) = 2) then
6223 gPlayer1Settings
.WeaponPreferences
[WEAPON_PLASMA
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6225 'p2_priority_plasma':
6227 if (Length(P
) = 2) then
6228 gPlayer2Settings
.WeaponPreferences
[WEAPON_PLASMA
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6232 if (Length(P
) = 2) then
6233 gPlayer1Settings
.WeaponPreferences
[WEAPON_BFG
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6237 if (Length(P
) = 2) then
6238 gPlayer2Settings
.WeaponPreferences
[WEAPON_BFG
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6240 'p1_priority_super':
6242 if (Length(P
) = 2) then
6243 gPlayer1Settings
.WeaponPreferences
[WEAPON_SUPERPULEMET
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6245 'p2_priority_super':
6247 if (Length(P
) = 2) then
6248 gPlayer2Settings
.WeaponPreferences
[WEAPON_SUPERPULEMET
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6250 'p1_priority_flamethrower':
6252 if (Length(P
) = 2) then
6253 gPlayer1Settings
.WeaponPreferences
[WEAPON_FLAMETHROWER
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6255 'p2_priority_flamethrower':
6257 if (Length(P
) = 2) then
6258 gPlayer2Settings
.WeaponPreferences
[WEAPON_FLAMETHROWER
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6260 'p1_priority_berserk':
6262 if (Length(P
) = 2) then
6263 gPlayer1Settings
.WeaponPreferences
[WP_LAST
+1] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6265 'p2_priority_berserk':
6267 if (Length(P
) = 2) then
6268 gPlayer2Settings
.WeaponPreferences
[WP_LAST
+1] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6273 procedure PrintHeapStats();
6277 hs
:= GetFPCHeapStatus();
6278 e_LogWriteLn ('v===== heap status =====v');
6279 e_LogWriteFln('max heap size = %d k', [hs
.MaxHeapSize
div 1024]);
6280 e_LogWriteFln('max heap used = %d k', [hs
.MaxHeapUsed
div 1024]);
6281 e_LogWriteFln('cur heap size = %d k', [hs
.CurrHeapSize
div 1024]);
6282 e_LogWriteFln('cur heap used = %d k', [hs
.CurrHeapUsed
div 1024]);
6283 e_LogWriteFln('cur heap free = %d k', [hs
.CurrHeapFree
div 1024]);
6284 e_LogWriteLn ('^=======================^');
6287 procedure DebugCommands(P
: SSArray
);
6294 // Êîìàíäû îòëàäî÷íîãî ðåæèìà:
6295 if {gDebugMode}conIsCheatsEnabled
then
6297 cmd
:= LowerCase(P
[0]);
6298 if cmd
= 'd_window' then
6300 g_Console_Add(Format('gScreenWidth = %d, gScreenHeight = %d', [gScreenWidth
, gScreenHeight
]));
6301 g_Console_Add(Format('gScreenWidth = %d, gScreenHeight = %d', [gScreenWidth
, gScreenHeight
]));
6303 else if cmd
= 'd_sounds' then
6305 if (Length(P
) > 1) and
6306 ((P
[1] = '1') or (P
[1] = '0')) then
6307 g_Debug_Sounds
:= (P
[1][1] = '1');
6309 g_Console_Add(Format('d_sounds is %d', [Byte(g_Debug_Sounds
)]));
6311 else if cmd
= 'd_frames' then
6313 if (Length(P
) > 1) and
6314 ((P
[1] = '1') or (P
[1] = '0')) then
6315 g_Debug_Frames
:= (P
[1][1] = '1');
6317 g_Console_Add(Format('d_frames is %d', [Byte(g_Debug_Frames
)]));
6319 else if cmd
= 'd_winmsg' then
6321 if (Length(P
) > 1) and
6322 ((P
[1] = '1') or (P
[1] = '0')) then
6323 g_Debug_WinMsgs
:= (P
[1][1] = '1');
6325 g_Console_Add(Format('d_winmsg is %d', [Byte(g_Debug_WinMsgs
)]));
6327 else if (cmd
= 'd_monoff') and not g_Game_IsNet
then
6329 if (Length(P
) > 1) and
6330 ((P
[1] = '1') or (P
[1] = '0')) then
6331 g_Debug_MonsterOff
:= (P
[1][1] = '1');
6333 g_Console_Add(Format('d_monoff is %d', [Byte(g_debug_MonsterOff
)]));
6335 else if (cmd
= 'd_botoff') and not g_Game_IsNet
then
6337 if Length(P
) > 1 then
6339 '0': g_debug_BotAIOff
:= 0;
6340 '1': g_debug_BotAIOff
:= 1;
6341 '2': g_debug_BotAIOff
:= 2;
6342 '3': g_debug_BotAIOff
:= 3;
6345 g_Console_Add(Format('d_botoff is %d', [g_debug_BotAIOff
]));
6347 else if cmd
= 'd_monster' then
6349 if gGameOn
and (gPlayer1
<> nil) and (gPlayer1
.alive
) and (not g_Game_IsNet
) then
6350 if Length(P
) < 2 then
6352 g_Console_Add(cmd
+ ' [ID | Name] [behaviour]');
6353 g_Console_Add('ID | Name');
6354 for b
:= MONSTER_DEMON
to MONSTER_MAN
do
6355 g_Console_Add(Format('%2d | %s', [b
, g_Mons_NameByTypeId(b
)]));
6356 conwriteln('behav. num'#10'normal 0'#10'killer 1'#10'maniac 2'#10'insane 3'#10'cannibal 4'#10'good 5');
6359 a
:= StrToIntDef(P
[1], 0);
6360 if (a
< MONSTER_DEMON
) or (a
> MONSTER_MAN
) then
6361 a
:= g_Mons_TypeIdByName(P
[1]);
6363 if (a
< MONSTER_DEMON
) or (a
> MONSTER_MAN
) then
6364 g_Console_Add(Format(_lc
[I_MSG_NO_MONSTER
], [P
[1]]))
6367 with gPlayer1
.Obj
do
6369 mon
:= g_Monsters_Create(a
,
6370 X
+ Rect
.X
+ (Rect
.Width
div 2),
6371 Y
+ Rect
.Y
+ Rect
.Height
,
6372 gPlayer1
.Direction
, True);
6374 if (Length(P
) > 2) and (mon
<> nil) then
6376 if (CompareText(P
[2], 'normal') = 0) then mon
.MonsterBehaviour
:= BH_NORMAL
6377 else if (CompareText(P
[2], 'killer') = 0) then mon
.MonsterBehaviour
:= BH_KILLER
6378 else if (CompareText(P
[2], 'maniac') = 0) then mon
.MonsterBehaviour
:= BH_MANIAC
6379 else if (CompareText(P
[2], 'insane') = 0) then mon
.MonsterBehaviour
:= BH_INSANE
6380 else if (CompareText(P
[2], 'cannibal') = 0) then mon
.MonsterBehaviour
:= BH_CANNIBAL
6381 else if (CompareText(P
[2], 'good') = 0) then mon
.MonsterBehaviour
:= BH_GOOD
6382 else if (CompareText(P
[2], 'friend') = 0) then mon
.MonsterBehaviour
:= BH_GOOD
6383 else if (CompareText(P
[2], 'friendly') = 0) then mon
.MonsterBehaviour
:= BH_GOOD
6384 else mon
.MonsterBehaviour
:= Min(Max(StrToIntDef(P
[2], BH_NORMAL
), BH_NORMAL
), BH_GOOD
);
6389 else if (cmd
= 'd_health') then
6391 if (Length(P
) > 1) and
6392 ((P
[1] = '1') or (P
[1] = '0')) then
6393 g_debug_HealthBar
:= (P
[1][1] = '1');
6395 g_Console_Add(Format('d_health is %d', [Byte(g_debug_HealthBar
)]));
6397 else if (cmd
= 'd_player') then
6399 if (Length(P
) > 1) and
6400 ((P
[1] = '1') or (P
[1] = '0')) then
6401 g_debug_Player
:= (P
[1][1] = '1');
6403 g_Console_Add(Format(cmd
+ ' is %d', [Byte(g_Debug_Player
)]));
6405 else if (cmd
= 'd_mem') then
6411 g_Console_Add(_lc
[I_MSG_NOT_DEBUG
]);
6415 procedure GameCheats(P
: SSArray
);
6421 if (not gGameOn
) or (not conIsCheatsEnabled
) then
6423 g_Console_Add('not available');
6429 g_Console_Add('where is the player?!');
6432 cmd
:= LowerCase(P
[0]);
6436 plr
.GodMode
:= not plr
.GodMode
;
6437 if plr
.GodMode
then g_Console_Add('player is godlike now') else g_Console_Add('player is mortal now');
6440 // give <health|exit|weapons|air|suit|jetpack|berserk|all>
6441 if cmd
= 'give' then
6443 if length(P
) < 2 then begin g_Console_Add('give what?!'); exit
; end;
6444 for f
:= 1 to High(P
) do
6446 cmd
:= LowerCase(P
[f
]);
6447 if cmd
= 'health' then begin plr
.RestoreHealthArmor(); g_Console_Add('player feels himself better'); continue
; end;
6448 if (cmd
= 'all') {or (cmd = 'weapons')} then begin plr
.AllRulez(False); g_Console_Add('player got the gifts'); continue
; end;
6449 if cmd
= 'exit' then
6451 if gTriggers
<> nil then
6453 for a
:= 0 to High(gTriggers
) do
6455 if gTriggers
[a
].TriggerType
= TRIGGER_EXIT
then
6457 g_Console_Add('player left the map');
6458 gExitByTrigger
:= True;
6459 //g_Game_ExitLevel(gTriggers[a].Data.MapName);
6460 g_Game_ExitLevel(gTriggers
[a
].tgcMap
);
6468 if cmd
= 'air' then begin plr
.GiveItem(ITEM_OXYGEN
); g_Console_Add('player got some air'); continue
; end;
6469 if cmd
= 'jetpack' then begin plr
.GiveItem(ITEM_JETPACK
); g_Console_Add('player got a jetpack'); continue
; end;
6470 if cmd
= 'suit' then begin plr
.GiveItem(ITEM_SUIT
); g_Console_Add('player got an envirosuit'); continue
; end;
6471 if cmd
= 'berserk' then begin plr
.GiveItem(ITEM_MEDKIT_BLACK
); g_Console_Add('player got a berserk pack'); continue
; end;
6472 if cmd
= 'backpack' then begin plr
.GiveItem(ITEM_AMMO_BACKPACK
); g_Console_Add('player got a backpack'); continue
; end;
6474 if cmd
= 'helmet' then begin plr
.GiveItem(ITEM_HELMET
); g_Console_Add('player got a helmet'); continue
; end;
6475 if cmd
= 'bottle' then begin plr
.GiveItem(ITEM_BOTTLE
); g_Console_Add('player got a bottle of health'); continue
; end;
6477 if cmd
= 'stimpack' then begin plr
.GiveItem(ITEM_MEDKIT_SMALL
); g_Console_Add('player got a stimpack'); continue
; end;
6478 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;
6480 if cmd
= 'greenarmor' then begin plr
.GiveItem(ITEM_ARMOR_GREEN
); g_Console_Add('player got a security armor'); continue
; end;
6481 if cmd
= 'bluearmor' then begin plr
.GiveItem(ITEM_ARMOR_BLUE
); g_Console_Add('player got a combat armor'); continue
; end;
6483 if (cmd
= 'soulsphere') or (cmd
= 'soul') then begin plr
.GiveItem(ITEM_SPHERE_BLUE
); g_Console_Add('player got a soul sphere'); continue
; end;
6484 if (cmd
= 'megasphere') or (cmd
= 'mega') then begin plr
.GiveItem(ITEM_SPHERE_WHITE
); g_Console_Add('player got a megasphere'); continue
; end;
6486 if (cmd
= 'invul') or (cmd
= 'invulnerability') then begin plr
.GiveItem(ITEM_INVUL
); g_Console_Add('player got invulnerability'); continue
; end;
6487 if (cmd
= 'invis') or (cmd
= 'invisibility') then begin plr
.GiveItem(ITEM_INVIS
); g_Console_Add('player got invisibility'); continue
; end;
6489 if cmd
= 'redkey' then begin plr
.GiveItem(ITEM_KEY_RED
); g_Console_Add('player got the red key'); continue
; end;
6490 if cmd
= 'greenkey' then begin plr
.GiveItem(ITEM_KEY_GREEN
); g_Console_Add('player got the green key'); continue
; end;
6491 if cmd
= 'bluekey' then begin plr
.GiveItem(ITEM_KEY_BLUE
); g_Console_Add('player got the blue key'); continue
; end;
6493 if (cmd
= 'shotgun') or (cmd
= 'sg') then begin plr
.GiveItem(ITEM_WEAPON_SHOTGUN1
); g_Console_Add('player got a shotgun'); continue
; end;
6494 if (cmd
= 'supershotgun') or (cmd
= 'ssg') then begin plr
.GiveItem(ITEM_WEAPON_SHOTGUN2
); g_Console_Add('player got a supershotgun'); continue
; end;
6495 if cmd
= 'chaingun' then begin plr
.GiveItem(ITEM_WEAPON_CHAINGUN
); g_Console_Add('player got a chaingun'); continue
; end;
6496 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;
6497 if cmd
= 'plasmagun' then begin plr
.GiveItem(ITEM_WEAPON_PLASMA
); g_Console_Add('player got a plasma gun'); continue
; end;
6498 if cmd
= 'bfg' then begin plr
.GiveItem(ITEM_WEAPON_BFG
); g_Console_Add('player got a BFG-9000'); continue
; end;
6500 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;
6501 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;
6502 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;
6503 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;
6504 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;
6505 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;
6507 if cmd
= 'superchaingun' then begin plr
.GiveItem(ITEM_WEAPON_SUPERPULEMET
); g_Console_Add('player got a superchaingun'); continue
; end;
6508 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;
6510 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;
6511 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;
6513 if cmd
= 'chainsaw' then begin plr
.GiveItem(ITEM_WEAPON_SAW
); g_Console_Add('player got a chainsaw'); continue
; end;
6515 if cmd
= 'ammo' then
6517 plr
.GiveItem(ITEM_AMMO_SHELLS_BOX
);
6518 plr
.GiveItem(ITEM_AMMO_BULLETS_BOX
);
6519 plr
.GiveItem(ITEM_AMMO_CELL_BIG
);
6520 plr
.GiveItem(ITEM_AMMO_ROCKET_BOX
);
6521 plr
.GiveItem(ITEM_AMMO_FUELCAN
);
6522 g_Console_Add('player got some ammo');
6526 if cmd
= 'clip' then begin plr
.GiveItem(ITEM_AMMO_BULLETS
); g_Console_Add('player got some bullets'); continue
; end;
6527 if cmd
= 'bullets' then begin plr
.GiveItem(ITEM_AMMO_BULLETS_BOX
); g_Console_Add('player got a box of bullets'); continue
; end;
6529 if cmd
= 'shells' then begin plr
.GiveItem(ITEM_AMMO_SHELLS
); g_Console_Add('player got some shells'); continue
; end;
6530 if cmd
= 'shellbox' then begin plr
.GiveItem(ITEM_AMMO_SHELLS_BOX
); g_Console_Add('player got a box of shells'); continue
; end;
6532 if cmd
= 'cells' then begin plr
.GiveItem(ITEM_AMMO_CELL
); g_Console_Add('player got some cells'); continue
; end;
6533 if cmd
= 'battery' then begin plr
.GiveItem(ITEM_AMMO_CELL_BIG
); g_Console_Add('player got cell battery'); continue
; end;
6535 if cmd
= 'rocket' then begin plr
.GiveItem(ITEM_AMMO_ROCKET
); g_Console_Add('player got a rocket'); continue
; end;
6536 if cmd
= 'rocketbox' then begin plr
.GiveItem(ITEM_AMMO_ROCKET_BOX
); g_Console_Add('player got some rockets'); continue
; end;
6538 if (cmd
= 'fuel') or (cmd
= 'fuelcan') then begin plr
.GiveItem(ITEM_AMMO_FUELCAN
); g_Console_Add('player got fuel canister'); continue
; end;
6540 if cmd
= 'weapons' then
6542 plr
.GiveItem(ITEM_WEAPON_SHOTGUN1
);
6543 plr
.GiveItem(ITEM_WEAPON_SHOTGUN2
);
6544 plr
.GiveItem(ITEM_WEAPON_CHAINGUN
);
6545 plr
.GiveItem(ITEM_WEAPON_ROCKETLAUNCHER
);
6546 plr
.GiveItem(ITEM_WEAPON_PLASMA
);
6547 plr
.GiveItem(ITEM_WEAPON_BFG
);
6548 g_Console_Add('player got weapons');
6552 if cmd
= 'keys' then
6554 plr
.GiveItem(ITEM_KEY_RED
);
6555 plr
.GiveItem(ITEM_KEY_GREEN
);
6556 plr
.GiveItem(ITEM_KEY_BLUE
);
6557 g_Console_Add('player got all keys');
6561 g_Console_Add('i don''t know how to give '''+cmd
+'''!');
6566 if cmd
= 'open' then
6568 g_Console_Add('player activated sesame');
6569 g_Triggers_OpenAll();
6576 if gFly
then g_Console_Add('player feels himself lighter') else g_Console_Add('player lost his wings');
6580 if cmd
= 'noclip' then
6583 g_Console_Add('wall hardeness adjusted');
6587 if cmd
= 'notarget' then
6589 plr
.NoTarget
:= not plr
.NoTarget
;
6590 if plr
.NoTarget
then g_Console_Add('player hides in shadows') else g_Console_Add('player is brave again');
6594 if cmd
= 'noreload' then
6596 plr
.NoReload
:= not plr
.NoReload
;
6597 if plr
.NoReload
then g_Console_Add('player is action hero now') else g_Console_Add('player is ordinary man now');
6601 if cmd
= 'speedy' then
6603 MAX_RUNVEL
:= 32-MAX_RUNVEL
;
6604 g_Console_Add('speed adjusted');
6608 if cmd
= 'jumpy' then
6610 VEL_JUMP
:= 30-VEL_JUMP
;
6611 g_Console_Add('jump height adjusted');
6615 if cmd
= 'automap' then
6617 gShowMap
:= not gShowMap
;
6618 if gShowMap
then g_Console_Add('player gains second sight') else g_Console_Add('player lost second sight');
6622 if cmd
= 'aimline' then
6624 gAimLine
:= not gAimLine
;
6625 if gAimLine
then g_Console_Add('player gains laser sight') else g_Console_Add('player lost laser sight');
6630 procedure GameCommands(P
: SSArray
);
6636 pl
: pTNetClient
= nil;
6645 cmd
:= LowerCase(P
[0]);
6647 if cmd
= 'pause' then
6649 if (g_ActiveWindow
= nil) then
6650 g_Game_Pause(not gPauseMain
);
6652 else if cmd
= 'endgame' then
6653 gExit
:= EXIT_SIMPLE
6654 else if cmd
= 'restart' then
6656 if gGameOn
or (gState
in [STATE_INTERSINGLE
, STATE_INTERCUSTOM
]) then
6658 if g_Game_IsClient
then
6660 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6665 g_Console_Add(_lc
[I_MSG_NOT_GAME
]);
6667 else if cmd
= 'kick' then
6669 if g_Game_IsServer
then
6671 if Length(P
) < 2 then
6673 g_Console_Add('kick <name>');
6678 g_Console_Add('kick <name>');
6682 if g_Game_IsNet
then
6683 pl
:= g_Net_Client_ByName(P
[1]);
6686 s
:= g_Net_ClientName_ByID(pl
^.ID
);
6687 g_Net_Host_Kick(pl
^.ID
, NET_DISC_KICK
);
6688 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
6689 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
6690 g_Net_Slist_ServerPlayerLeaves();
6691 end else if gPlayers
<> nil then
6692 for a
:= Low(gPlayers
) to High(gPlayers
) do
6693 if gPlayers
[a
] <> nil then
6694 if Copy(LowerCase(gPlayers
[a
].Name
), 1, Length(P
[1])) = LowerCase(P
[1]) then
6696 // Íå îòêëþ÷àòü îñíîâíûõ èãðîêîâ â ñèíãëå
6697 if not(gPlayers
[a
] is TBot
) and (gGameSettings
.GameType
= GT_SINGLE
) then
6699 gPlayers
[a
].Lives
:= 0;
6700 gPlayers
[a
].Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
6701 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [gPlayers
[a
].Name
]), True);
6702 g_Player_Remove(gPlayers
[a
].UID
);
6703 g_Net_Slist_ServerPlayerLeaves();
6704 // Åñëè íå ïåðåìåøàòü, ïðè äîáàâëåíèè íîâûõ áîòîâ ïîÿâÿòñÿ ñòàðûå
6708 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6710 else if cmd
= 'kick_id' then
6712 if g_Game_IsServer
and g_Game_IsNet
then
6714 if Length(P
) < 2 then
6716 g_Console_Add('kick_id <client ID>');
6721 g_Console_Add('kick_id <client ID>');
6725 a
:= StrToIntDef(P
[1], 0);
6726 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
6728 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
6730 s
:= g_Net_ClientName_ByID(NetClients
[a
].ID
);
6731 g_Net_Host_Kick(NetClients
[a
].ID
, NET_DISC_KICK
);
6732 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
6733 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
6734 g_Net_Slist_ServerPlayerLeaves();
6738 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6740 else if cmd
= 'kick_pid' then
6742 if g_Game_IsServer
and g_Game_IsNet
then
6744 if Length(P
) < 2 then
6746 g_Console_Add('kick_pid <player ID>');
6751 g_Console_Add('kick_pid <player ID>');
6755 a
:= StrToIntDef(P
[1], 0);
6756 pl
:= g_Net_Client_ByPlayer(a
);
6757 if (pl
<> nil) and pl
^.Used
and (pl
^.Peer
<> nil) then
6759 s
:= g_Net_ClientName_ByID(pl
^.ID
);
6760 g_Net_Host_Kick(pl
^.ID
, NET_DISC_KICK
);
6761 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
6762 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
6763 g_Net_Slist_ServerPlayerLeaves();
6766 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6768 else if cmd
= 'ban' then
6770 if g_Game_IsServer
and g_Game_IsNet
then
6772 if Length(P
) < 2 then
6774 g_Console_Add('ban <name>');
6779 g_Console_Add('ban <name>');
6783 pl
:= g_Net_Client_ByName(P
[1]);
6785 g_Net_Host_Ban(pl
, False)
6787 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
6789 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6791 else if cmd
= 'ban_id' then
6793 if g_Game_IsServer
and g_Game_IsNet
then
6795 if Length(P
) < 2 then
6797 g_Console_Add('ban_id <client ID>');
6802 g_Console_Add('ban_id <client ID>');
6806 a
:= StrToIntDef(P
[1], 0);
6807 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
6808 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
6809 g_Net_Host_Ban(pl
, False);
6811 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6813 else if cmd
= 'ban_pid' then
6815 if g_Game_IsServer
and g_Game_IsNet
then
6817 if Length(P
) < 2 then
6819 g_Console_Add('ban_pid <player ID>');
6824 g_Console_Add('ban_pid <player ID>');
6828 a
:= StrToIntDef(P
[1], 0);
6829 pl
:= g_Net_Client_ByPlayer(a
);
6830 if (pl
<> nil) and pl
^.Used
and (pl
^.Peer
<> nil) then
6831 g_Net_Host_Ban(pl
, False);
6833 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6835 else if cmd
= 'permban' then
6837 if g_Game_IsServer
and g_Game_IsNet
then
6839 if Length(P
) < 2 then
6841 g_Console_Add('permban <name>');
6846 g_Console_Add('permban <name>');
6850 pl
:= g_Net_Client_ByName(P
[1]);
6852 g_Net_Host_Ban(pl
, True)
6854 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
6856 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6858 else if cmd
= 'permban_id' then
6860 if g_Game_IsServer
and g_Game_IsNet
then
6862 if Length(P
) < 2 then
6864 g_Console_Add('permban_id <client ID>');
6869 g_Console_Add('permban_id <client ID>');
6873 a
:= StrToIntDef(P
[1], 0);
6874 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
6875 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
6876 g_Net_Host_Ban(@NetClients
[a
], True);
6878 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6880 else if cmd
= 'permban_pid' then
6882 if g_Game_IsServer
and g_Game_IsNet
then
6884 if Length(P
) < 2 then
6886 g_Console_Add('permban_pid <player ID>');
6891 g_Console_Add('permban_pid <player ID>');
6895 a
:= StrToIntDef(P
[1], 0);
6896 pl
:= g_Net_Client_ByPlayer(a
);
6897 if (pl
<> nil) and pl
^.Used
and (pl
^.Peer
<> nil) then
6898 g_Net_Host_Ban(pl
, True);
6900 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6902 else if cmd
= 'permban_ip' then
6904 if g_Game_IsServer
and g_Game_IsNet
then
6906 if Length(P
) < 2 then
6908 g_Console_Add('permban_ip <IP address>');
6913 g_Console_Add('permban_ip <IP address>');
6917 g_Net_BanAddress(P
[1]);
6918 g_Net_SaveBanList();
6919 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [P
[1]]));
6921 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6923 else if cmd
= 'unban' then
6925 if g_Game_IsServer
and g_Game_IsNet
then
6927 if Length(P
) < 2 then
6929 g_Console_Add('unban <IP Address>');
6934 g_Console_Add('unban <IP Address>');
6938 if g_Net_UnbanAddress(P
[1]) then
6940 g_Console_Add(Format(_lc
[I_MSG_UNBAN_OK
], [P
[1]]));
6941 g_Net_SaveBanList();
6943 g_Console_Add(Format(_lc
[I_MSG_UNBAN_FAIL
], [P
[1]]));
6945 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6947 else if cmd
= 'clientlist' then
6949 if g_Game_IsServer
and g_Game_IsNet
then
6952 if NetClients
<> nil then
6953 for a
:= Low(NetClients
) to High(NetClients
) do
6954 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
6956 plr
:= g_Player_Get(NetClients
[a
].Player
);
6957 if plr
= nil then continue
;
6959 g_Console_Add(Format('#%2d: %-15s | %s', [a
,
6960 IpToStr(NetClients
[a
].Peer
^.address
.host
), plr
.Name
]));
6963 g_Console_Add(_lc
[I_MSG_NOCLIENTS
]);
6965 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6967 else if cmd
= 'connect' then
6969 if (NetMode
= NET_NONE
) then
6971 if Length(P
) < 2 then
6973 g_Console_Add('connect <IP> [port] [password]');
6978 g_Console_Add('connect <IP> [port] [password]');
6982 if Length(P
) > 2 then
6983 prt
:= StrToIntDef(P
[2], 25666)
6987 if Length(P
) > 3 then
6992 g_Game_StartClient(P
[1], prt
, pw
);
6995 else if cmd
= 'disconnect' then
6997 if (NetMode
= NET_CLIENT
) then
7000 else if cmd
= 'reconnect' then
7002 if (NetMode
= NET_SERVER
) then
7005 if (NetMode
= NET_CLIENT
) then
7008 gExit
:= EXIT_SIMPLE
;
7012 //TODO: Use last successful password to reconnect, instead of ''
7013 g_Game_StartClient(NetClientIP
, NetClientPort
, '');
7015 else if (cmd
= 'addbot') or
7016 (cmd
= 'bot_add') then
7019 1: g_Bot_Add(TEAM_NONE
, 2);
7020 2: g_Bot_Add(TEAM_NONE
, StrToIntDef(P
[1], 2));
7022 g_Bot_Add(TEAM_NONE
, StrToIntDef(P
[1], 2), StrToIntDef(P
[2], 100));
7025 else if cmd
= 'bot_addlist' then
7028 1: g_Bot_AddList(TEAM_NONE
, '');
7029 2: g_Bot_AddList(TEAM_NONE
, P
[1], StrToIntDef(P
[1], -1));
7031 if P
[2] = 'red' then
7033 else if P
[2] = 'blue' then
7039 then g_Bot_AddList(t
, P
[1], StrToIntDef(P
[1], -1))
7040 else g_Bot_AddList(t
, P
[1], StrToIntDef(P
[1], -1), StrToIntDef(P
[3], 100));
7043 else if cmd
= 'bot_removeall' then
7045 else if cmd
= 'chat' then
7047 if g_Game_IsNet
then
7049 if Length(P
) > 1 then
7051 for a
:= 1 to High(P
) do
7052 chstr
:= chstr
+ P
[a
] + ' ';
7054 if Length(chstr
) > 200 then SetLength(chstr
, 200);
7056 if Length(chstr
) < 1 then
7058 g_Console_Add('chat <text>');
7062 chstr
:= b_Text_Format(chstr
);
7063 if g_Game_IsClient
then
7064 MC_SEND_Chat(chstr
, NET_CHAT_PLAYER
)
7066 MH_SEND_Chat(gPlayer1Settings
.Name
+ ': ' + chstr
, NET_CHAT_PLAYER
);
7069 g_Console_Add('chat <text>');
7071 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
7073 else if cmd
= 'teamchat' then
7075 if g_Game_IsNet
and (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
7077 if Length(P
) > 1 then
7079 for a
:= 1 to High(P
) do
7080 chstr
:= chstr
+ P
[a
] + ' ';
7082 if Length(chstr
) > 200 then SetLength(chstr
, 200);
7084 if Length(chstr
) < 1 then
7086 g_Console_Add('teamchat <text>');
7090 chstr
:= b_Text_Format(chstr
);
7091 if g_Game_IsClient
then
7092 MC_SEND_Chat(chstr
, NET_CHAT_TEAM
)
7094 MH_SEND_Chat(gPlayer1Settings
.Name
+ ': ' + chstr
, NET_CHAT_TEAM
,
7095 gPlayer1Settings
.Team
);
7098 g_Console_Add('teamchat <text>');
7100 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
7102 else if (cmd
= 'an') or (cmd
= 'announce') then
7104 if g_Game_IsNet
then
7106 if Length(P
) > 1 then
7108 for a
:= 1 to High(P
) do
7109 chstr
:= chstr
+ P
[a
] + ' ';
7111 if Length(chstr
) > 200 then SetLength(chstr
, 200);
7113 if Length(chstr
) < 1 then
7115 g_Console_Add('announce <text>');
7119 chstr
:= 'centerprint 100 ' + b_Text_Format(chstr
);
7120 if g_Game_IsClient
then
7121 MC_SEND_RCONCommand(chstr
)
7123 g_Console_Process(chstr
, True);
7126 g_Console_Add('announce <text>');
7128 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
7130 else if cmd
= 'game' then
7132 if gGameSettings
.GameType
<> GT_NONE
then
7134 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
7137 if Length(P
) = 1 then
7139 g_Console_Add(cmd
+ ' <WAD> [MAP] [# players]');
7142 // game not started yet, load fist map from some wad
7144 s
:= addWadExtension(P
[1]);
7145 found
:= e_FindResource(AllMapDirs
, s
);
7149 P
[1] := ExpandFileName(P
[1]);
7150 // if map not choosed then set first map
7151 if Length(P
) < 3 then
7154 P
[2] := g_Game_GetFirstMap(P
[1]);
7157 s
:= P
[1] + ':\' + UpperCase(P
[2]);
7159 if g_Map_Exist(s
) then
7163 with gGameSettings
do
7165 Options
:= gsGameFlags
;
7166 GameMode
:= g_Game_TextToMode(gsGameMode
);
7167 if gSwitchGameMode
<> GM_NONE
then
7168 GameMode
:= gSwitchGameMode
;
7169 if GameMode
= GM_NONE
then GameMode
:= GM_DM
;
7170 if GameMode
= GM_SINGLE
then GameMode
:= GM_COOP
;
7172 if Length(P
) >= 4 then
7173 b
:= StrToIntDef(P
[3], 1);
7174 g_Game_StartCustom(s
, GameMode
, TimeLimit
,
7175 ScoreLimit
, MaxLives
, Options
, b
);
7180 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
7182 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [UpperCase(P
[2]), P
[1]]));
7184 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]));
7186 else if cmd
= 'host' then
7188 if gGameSettings
.GameType
<> GT_NONE
then
7190 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
7193 if Length(P
) < 4 then
7195 g_Console_Add(cmd
+ ' <listen IP> <port> <WAD> [MAP] [# players]');
7198 if not StrToIp(P
[1], listen
) then
7200 prt
:= StrToIntDef(P
[2], 25666);
7202 s
:= addWadExtension(P
[3]);
7203 found
:= e_FindResource(AllMapDirs
, s
);
7207 // get first map in wad, if not specified
7208 if Length(P
) < 5 then
7211 P
[4] := g_Game_GetFirstMap(P
[1]);
7213 s
:= P
[3] + ':\' + UpperCase(P
[4]);
7214 if g_Map_Exist(s
) then
7218 with gGameSettings
do
7220 Options
:= gsGameFlags
;
7221 GameMode
:= g_Game_TextToMode(gsGameMode
);
7222 if gSwitchGameMode
<> GM_NONE
then GameMode
:= gSwitchGameMode
;
7223 if GameMode
= GM_NONE
then GameMode
:= GM_DM
;
7224 if GameMode
= GM_SINGLE
then GameMode
:= GM_COOP
;
7226 if Length(P
) >= 6 then
7227 b
:= StrToIntDef(P
[5], 0);
7228 g_Game_StartServer(s
, GameMode
, TimeLimit
, ScoreLimit
, MaxLives
, Options
, b
, listen
, prt
)
7234 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[3]]))
7236 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [UpperCase(P
[4]), P
[3]]))
7241 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[3]]))
7244 else if cmd
= 'map' then
7246 if Length(P
) = 1 then
7248 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
7250 g_Console_Add(cmd
+ ' <MAP>');
7251 g_Console_Add(cmd
+ ' <WAD> [MAP]')
7255 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
])
7258 else if not e_IsValidResourceName(P
[1]) then
7260 g_Console_Add('wad name must not be absolute or relative');
7264 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
7266 if Length(P
) < 3 then
7268 // first param is map or wad
7269 s
:= UpperCase(P
[1]);
7270 if g_Map_Exist(gGameSettings
.WAD
+ ':\' + s
) then
7272 gExitByTrigger
:= False;
7275 // already in game, finish current map
7277 gExit
:= EXIT_ENDLEVELCUSTOM
;
7281 // intermission, so change map immediately
7288 found
:= e_FindResource(AllMapDirs
, s
);
7290 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [s
, 'WAD ' + P
[1]]));
7293 // no such map, found wad
7296 P
[1] := ExpandFileName(pw
);
7297 P
[2] := g_Game_GetFirstMap(P
[1]);
7298 s
:= P
[1] + ':\' + P
[2];
7299 if g_Map_Exist(s
) then
7301 gExitByTrigger
:= False;
7304 // already in game, finish current map
7306 gExit
:= EXIT_ENDLEVELCUSTOM
7310 // intermission, so change map immediately
7317 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
7319 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]))
7324 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]))
7330 s
:= addWadExtension(P
[1]);
7331 found
:= e_FindResource(AllMapDirs
, s
);
7335 P
[2] := UpperCase(P
[2]);
7336 s
:= P
[1] + ':\' + P
[2];
7337 if g_Map_Exist(s
) then
7339 gExitByTrigger
:= False;
7343 gExit
:= EXIT_ENDLEVELCUSTOM
7352 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]))
7357 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]))
7363 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
])
7367 else if cmd
= 'nextmap' then
7369 if not(gGameOn
or (gState
= STATE_INTERCUSTOM
)) then
7371 g_Console_Add(_lc
[I_MSG_NOT_GAME
])
7376 if Length(P
) = 1 then
7378 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
7380 g_Console_Add(cmd
+ ' <MAP>');
7381 g_Console_Add(cmd
+ ' <WAD> [MAP]');
7386 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
7389 else if not e_IsValidResourceName(P
[1]) then
7391 g_Console_Add('wad name must not be absolute or relative');
7396 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
7398 if Length(P
) < 3 then
7400 // first param is map or wad
7401 s
:= UpperCase(P
[1]);
7402 if g_Map_Exist(gGameSettings
.WAD
+ ':\' + s
) then
7405 gExitByTrigger
:= False;
7411 // no such map, found wad
7412 pw
:= addWadExtension(P
[1]);
7413 found
:= e_FindResource(MapDirs
, pw
);
7415 found
:= e_FindResource(WadDirs
, pw
);
7417 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [s
, P
[1]]));
7420 // map not specified, select first map
7422 P
[2] := g_Game_GetFirstMap(P
[1]);
7423 s
:= P
[1] + ':\' + P
[2];
7424 if g_Map_Exist(s
) then
7426 gExitByTrigger
:= False;
7433 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
7435 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]))
7440 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]))
7446 // specified two params wad + map
7447 pw
:= addWadExtension(P
[1]);
7448 found
:= e_FindResource(MapDirs
, pw
);
7450 found
:= e_FindResource(MapDirs
, pw
);
7454 P
[2] := UpperCase(P
[2]);
7455 s
:= P
[1] + ':\' + P
[2];
7456 if g_Map_Exist(s
) then
7458 gExitByTrigger
:= False;
7464 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]))
7469 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]))
7475 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
])
7480 if gNextMap
= '' then
7481 g_Console_Add(_lc
[I_MSG_NEXTMAP_UNSET
])
7483 g_Console_Add(Format(_lc
[I_MSG_NEXTMAP_SET
], [gNextMap
]))
7487 else if (cmd
= 'endmap') or (cmd
= 'goodbye') then
7491 g_Console_Add(_lc
[I_MSG_NOT_GAME
])
7495 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
7497 gExitByTrigger
:= False;
7498 // next map not specified, try to find trigger EXIT
7499 if (gNextMap
= '') and (gTriggers
<> nil) then
7501 for a
:= 0 to High(gTriggers
) do
7503 if gTriggers
[a
].TriggerType
= TRIGGER_EXIT
then
7505 gExitByTrigger
:= True;
7506 //gNextMap := gTriggers[a].Data.MapName;
7507 gNextMap
:= gTriggers
[a
].tgcMap
;
7512 if gNextMap
= '' then
7513 gNextMap
:= g_Game_GetNextMap();
7514 if not isWadPath(gNextMap
) then
7515 s
:= gGameSettings
.WAD
+ ':\' + gNextMap
7518 if g_Map_Exist(s
) then
7519 gExit
:= EXIT_ENDLEVELCUSTOM
7521 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [gNextMap
]))
7525 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
])
7529 else if (cmd
= 'event') then
7531 if (Length(P
) <= 1) then
7533 for a
:= 0 to High(gEvents
) do
7534 if gEvents
[a
].Command
= '' then
7535 g_Console_Add(gEvents
[a
].Name
+ ' <none>')
7537 g_Console_Add(gEvents
[a
].Name
+ ' "' + gEvents
[a
].Command
+ '"');
7540 if (Length(P
) = 2) then
7542 for a
:= 0 to High(gEvents
) do
7543 if gEvents
[a
].Name
= P
[1] then
7544 if gEvents
[a
].Command
= '' then
7545 g_Console_Add(gEvents
[a
].Name
+ ' <none>')
7547 g_Console_Add(gEvents
[a
].Name
+ ' "' + gEvents
[a
].Command
+ '"');
7550 for a
:= 0 to High(gEvents
) do
7551 if gEvents
[a
].Name
= P
[1] then
7553 gEvents
[a
].Command
:= '';
7554 for b
:= 2 to High(P
) do
7555 if Pos(' ', P
[b
]) = 0 then
7556 gEvents
[a
].Command
:= gEvents
[a
].Command
+ ' ' + P
[b
]
7558 gEvents
[a
].Command
:= gEvents
[a
].Command
+ ' "' + P
[b
] + '"';
7559 gEvents
[a
].Command
:= Trim(gEvents
[a
].Command
);
7563 else if cmd
= 'suicide' then
7567 if g_Game_IsClient
then
7568 MC_SEND_CheatRequest(NET_CHEAT_SUICIDE
)
7571 if gPlayer1
<> nil then
7572 gPlayer1
.Damage(SUICIDE_DAMAGE
, gPlayer1
.UID
, 0, 0, HIT_SELF
);
7573 if gPlayer2
<> nil then
7574 gPlayer2
.Damage(SUICIDE_DAMAGE
, gPlayer2
.UID
, 0, 0, HIT_SELF
);
7578 else if cmd
= 'screenshot' then
7582 else if (cmd
= 'weapnext') or (cmd
= 'weapprev') then
7584 a
:= 1 - (ord(cmd
[5]) - ord('n'));
7586 gWeaponAction
[0, WP_PREV
] := True;
7588 gWeaponAction
[0, WP_NEXT
] := True;
7590 else if cmd
= 'weapon' then
7592 if Length(p
) = 2 then
7594 a
:= WP_FIRST
+ StrToIntDef(p
[1], 0) - 1;
7595 if (a
>= WP_FIRST
) and (a
<= WP_LAST
) then
7596 gSelectWeapon
[0, a
] := True
7599 else if (cmd
= 'p1_weapnext') or (cmd
= 'p1_weapprev')
7600 or (cmd
= 'p2_weapnext') or (cmd
= 'p2_weapprev') then
7602 a
:= 1 - (ord(cmd
[8]) - ord('n'));
7603 b
:= ord(cmd
[2]) - ord('1');
7605 gWeaponAction
[b
, WP_PREV
] := True;
7607 gWeaponAction
[b
, WP_NEXT
] := True;
7609 else if (cmd
= 'p1_weapon') or (cmd
= 'p2_weapon') then
7611 if Length(p
) = 2 then
7613 a
:= WP_FIRST
+ StrToIntDef(p
[1], 0) - 1;
7614 b
:= ord(cmd
[2]) - ord('1');
7615 if (a
>= WP_FIRST
) and (a
<= WP_LAST
) then
7616 gSelectWeapon
[b
, a
] := True
7619 else if (cmd
= 'p1_weapbest') or (cmd
= 'p2_weapbest') then
7621 b
:= ord(cmd
[2]) - ord('1');
7623 gSelectWeapon
[b
, gPlayer1
.GetMorePrefered()] := True
7625 gSelectWeapon
[b
, gPlayer2
.GetMorePrefered()] := True;
7627 else if (cmd
= 'dropflag') then
7629 if g_Game_IsServer
then
7631 if gPlayer2
<> nil then gPlayer2
.TryDropFlag();
7632 if gPlayer1
<> nil then gPlayer1
.TryDropFlag();
7635 MC_SEND_CheatRequest(NET_CHEAT_DROPFLAG
);
7637 else if (cmd
= 'p1_dropflag') or (cmd
= 'p2_dropflag') then
7639 b
:= ord(cmd
[2]) - ord('1');
7640 if g_Game_IsServer
then
7642 if (b
= 1) and (gPlayer2
<> nil) then gPlayer2
.TryDropFlag()
7643 else if (b
= 0) and (gPlayer1
<> nil) then gPlayer1
.TryDropFlag();
7646 MC_SEND_CheatRequest(NET_CHEAT_DROPFLAG
);
7648 // Êîìàíäû Ñâîåé èãðû:
7649 else if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
7651 if cmd
= 'bot_addred' then
7653 if Length(P
) > 1 then
7654 g_Bot_Add(TEAM_RED
, StrToIntDef(P
[1], 2))
7656 g_Bot_Add(TEAM_RED
, 2);
7658 else if cmd
= 'bot_addblue' then
7660 if Length(P
) > 1 then
7661 g_Bot_Add(TEAM_BLUE
, StrToIntDef(P
[1], 2))
7663 g_Bot_Add(TEAM_BLUE
, 2);
7665 else if cmd
= 'spectate' then
7671 else if cmd
= 'say' then
7673 if g_Game_IsServer
and g_Game_IsNet
then
7675 if Length(P
) > 1 then
7678 for a
:= 1 to High(P
) do
7679 chstr
:= chstr
+ P
[a
] + ' ';
7681 if Length(chstr
) > 200 then SetLength(chstr
, 200);
7683 if Length(chstr
) < 1 then
7685 g_Console_Add('say <text>');
7689 chstr
:= b_Text_Format(chstr
);
7690 MH_SEND_Chat(chstr
, NET_CHAT_PLAYER
);
7692 else g_Console_Add('say <text>');
7694 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
7696 else if cmd
= 'tell' then
7698 if g_Game_IsServer
and g_Game_IsNet
then
7700 if (Length(P
) > 2) and (P
[1] <> '') then
7703 for a
:= 2 to High(P
) do
7704 chstr
:= chstr
+ P
[a
] + ' ';
7706 if Length(chstr
) > 200 then SetLength(chstr
, 200);
7708 if Length(chstr
) < 1 then
7710 g_Console_Add('tell <playername> <text>');
7714 pl
:= g_Net_Client_ByName(P
[1]);
7716 MH_SEND_Chat(b_Text_Format(chstr
), NET_CHAT_PLAYER
, pl
^.ID
)
7718 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
7720 else g_Console_Add('tell <playername> <text>');
7722 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
7724 else if cmd
= 'centerprint' then
7726 if (Length(P
) > 2) and (P
[1] <> '') then
7729 for a
:= 2 to High(P
) do
7730 chstr
:= chstr
+ P
[a
] + ' ';
7732 if Length(chstr
) > 200 then SetLength(chstr
, 200);
7734 if Length(chstr
) < 1 then
7736 g_Console_Add('centerprint <timeout> <text>');
7740 a
:= StrToIntDef(P
[1], 100);
7741 chstr
:= b_Text_Format(chstr
);
7742 g_Game_Message(chstr
, a
);
7743 if g_Game_IsNet
and g_Game_IsServer
then
7744 MH_SEND_GameEvent(NET_EV_BIGTEXT
, a
, chstr
);
7746 else g_Console_Add('centerprint <timeout> <text>');
7748 else if (cmd
= 'overtime') and not g_Game_IsClient
then
7750 if (Length(P
) = 1) or (StrToIntDef(P
[1], -1) <= 0) then
7752 // Äîïîëíèòåëüíîå âðåìÿ:
7753 gGameSettings
.TimeLimit
:= (gTime
- gGameStartTime
) div 1000 + Word(StrToIntDef(P
[1], 0));
7755 g_Console_Add(Format(_lc
[I_MSG_TIME_LIMIT
],
7756 [gGameSettings
.TimeLimit
div 3600,
7757 (gGameSettings
.TimeLimit
div 60) mod 60,
7758 gGameSettings
.TimeLimit
mod 60]));
7759 if g_Game_IsNet
then MH_SEND_GameSettings
;
7761 else if (cmd
= 'rcon_password') and g_Game_IsClient
then
7763 if (Length(P
) <= 1) then
7764 g_Console_Add('rcon_password <password>')
7766 MC_SEND_RCONPassword(P
[1]);
7768 else if cmd
= 'rcon' then
7770 if g_Game_IsClient
then
7772 if Length(P
) > 1 then
7775 for a
:= 1 to High(P
) do
7776 chstr
:= chstr
+ P
[a
] + ' ';
7778 if Length(chstr
) > 200 then SetLength(chstr
, 200);
7780 if Length(chstr
) < 1 then
7782 g_Console_Add('rcon <command>');
7786 MC_SEND_RCONCommand(chstr
);
7788 else g_Console_Add('rcon <command>');
7791 else if cmd
= 'ready' then
7793 if g_Game_IsServer
and (gLMSRespawn
= LMS_RESPAWN_WARMUP
) then
7794 gLMSRespawnTime
:= gTime
+ 100;
7796 else if (cmd
= 'callvote') and g_Game_IsNet
then
7798 if Length(P
) > 1 then
7801 for a
:= 1 to High(P
) do begin
7802 if a
> 1 then chstr
:= chstr
+ ' ';
7803 chstr
:= chstr
+ P
[a
];
7806 if Length(chstr
) > 200 then SetLength(chstr
, 200);
7808 if Length(chstr
) < 1 then
7810 g_Console_Add('callvote <command>');
7814 if g_Game_IsClient
then
7815 MC_SEND_Vote(True, chstr
)
7817 g_Game_StartVote(chstr
, gPlayer1Settings
.Name
);
7818 g_Console_Process('vote', True);
7821 g_Console_Add('callvote <command>');
7823 else if (cmd
= 'vote') and g_Game_IsNet
then
7825 if g_Game_IsClient
then
7827 else if gVoteInProgress
then
7829 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
7830 a
:= Floor((NetClientCount
+1)/2.0) + 1
7832 a
:= Floor(NetClientCount
/2.0) + 1;
7837 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_REVOKED
], [gPlayer1Settings
.Name
, gVoteCount
, a
]), True);
7838 MH_SEND_VoteEvent(NET_VE_REVOKE
, gPlayer1Settings
.Name
, 'a', gVoteCount
, a
);
7844 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_VOTE
], [gPlayer1Settings
.Name
, gVoteCount
, a
]), True);
7845 MH_SEND_VoteEvent(NET_VE_VOTE
, gPlayer1Settings
.Name
, 'a', gVoteCount
, a
);
7853 procedure SystemCommands(P
: SSArray
);
7857 cmd
:= LowerCase(P
[0]);
7866 gRC_Width
:= Max(1, gRC_Width
);
7867 gRC_Height
:= Max(1, gRC_Height
);
7868 gBPP
:= Max(1, gBPP
);
7869 if sys_SetDisplayMode(gRC_Width
, gRC_Height
, gBPP
, gRC_FullScreen
, gRC_Maximized
) = True then
7870 e_LogWriteln('resolution changed')
7872 e_LogWriteln('resolution not changed');
7873 sys_EnableVSync(gVSync
);
7877 if Length(p
) = 2 then
7879 gMaxFPS
:= StrToIntDef(p
[1], gMaxFPS
);
7881 gFrameTime
:= 1000 div gMaxFPS
7885 e_LogWritefln('r_maxfps %d', [gMaxFPS
]);
7889 if Length(p
) = 2 then
7891 gAskLanguage
:= true;
7892 gLanguage
:= LANGUAGE_ENGLISH
;
7893 case LowerCase(p
[1]) of
7896 gAskLanguage
:= false;
7897 gLanguage
:= LANGUAGE_ENGLISH
;
7901 gAskLanguage
:= false;
7902 gLanguage
:= LANGUAGE_RUSSIAN
;
7906 gAskLanguage
:= true;
7907 gLanguage
:= LANGUAGE_ENGLISH
;
7910 g_Language_Set(gLanguage
);
7914 e_LogWritefln('usage: %s <English|Russian|Ask>', [cmd
]);
7920 procedure g_TakeScreenShot(Filename
: string = '');
7921 var s
: TStream
; t
: TDateTime
; dir
, date
, name
: String;
7923 if e_NoGraphics
then Exit
;
7925 dir
:= e_GetWriteableDir(ScreenshotDirs
);
7927 if Filename
= '' then
7930 DateTimeToString(date
, 'yyyy-mm-dd-hh-nn-ss', t
);
7931 Filename
:= 'screenshot-' + date
;
7934 name
:= e_CatPath(dir
, Filename
+ '.png');
7935 s
:= createDiskFile(name
);
7937 e_MakeScreenshot(s
, gWinSizeX
, gWinSizeY
);
7939 g_Console_Add(Format(_lc
[I_CONSOLE_SCREENSHOT
], [name
]))
7941 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_WRITE
], [name
]));
7946 g_Console_Add('oh shit, i can''t create screenshot!')
7950 procedure g_Game_InGameMenu(Show
: Boolean);
7952 if (g_ActiveWindow
= nil) and Show
then
7954 if gGameSettings
.GameType
= GT_SINGLE
then
7955 g_GUI_ShowWindow('GameSingleMenu')
7958 if g_Game_IsClient
then
7959 g_GUI_ShowWindow('GameClientMenu')
7961 if g_Game_IsNet
then
7962 g_GUI_ShowWindow('GameServerMenu')
7964 g_GUI_ShowWindow('GameCustomMenu');
7966 g_Sound_PlayEx('MENU_OPEN');
7968 // Ïàóçà ïðè ìåíþ òîëüêî â îäèíî÷íîé èãðå:
7969 if (not g_Game_IsNet
) then
7973 if (g_ActiveWindow
<> nil) and (not Show
) then
7975 // Ïàóçà ïðè ìåíþ òîëüêî â îäèíî÷íîé èãðå:
7976 if (not g_Game_IsNet
) then
7977 g_Game_Pause(False);
7981 procedure g_Game_Pause (Enable
: Boolean);
7985 if not gGameOn
then exit
;
7987 if not (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
]) then exit
;
7990 gPauseMain
:= Enable
;
7992 if (gPause
<> oldPause
) then g_Game_PauseAllSounds(gPause
);
7995 procedure g_Game_HolmesPause (Enable
: Boolean);
7999 if not gGameOn
then exit
;
8000 if not (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
]) then exit
;
8003 gPauseHolmes
:= Enable
;
8005 if (gPause
<> oldPause
) then g_Game_PauseAllSounds(gPause
);
8008 procedure g_Game_PauseAllSounds(Enable
: Boolean);
8013 if gTriggers
<> nil then
8014 for i
:= 0 to High(gTriggers
) do
8015 with gTriggers
[i
] do
8016 if (TriggerType
= TRIGGER_SOUND
) and
8018 Sound
.IsPlaying() then
8020 Sound
.Pause(Enable
);
8024 if gPlayers
<> nil then
8025 for i
:= 0 to High(gPlayers
) do
8026 if gPlayers
[i
] <> nil then
8027 gPlayers
[i
].PauseSounds(Enable
);
8030 if gMusic
<> nil then
8031 gMusic
.Pause(Enable
);
8034 procedure g_Game_StopAllSounds(all
: Boolean);
8038 if gTriggers
<> nil then
8039 for i
:= 0 to High(gTriggers
) do
8040 with gTriggers
[i
] do
8041 if (TriggerType
= TRIGGER_SOUND
) and
8045 if gMusic
<> nil then
8052 procedure g_Game_UpdateTriggerSounds
;
8055 if gTriggers
<> nil then
8056 for i
:= 0 to High(gTriggers
) do
8057 with gTriggers
[i
] do
8058 if (TriggerType
= TRIGGER_SOUND
) and (Sound
<> nil) and tgcLocal
and Sound
.IsPlaying() then
8059 Sound
.SetCoordsRect(X
, Y
, Width
, Height
, tgcVolume
/ 255.0)
8062 function g_Game_IsWatchedPlayer(UID
: Word): Boolean;
8065 if (gPlayer1
<> nil) and (gPlayer1
.UID
= UID
) then
8070 if (gPlayer2
<> nil) and (gPlayer2
.UID
= UID
) then
8075 if gSpectMode
<> SPECT_PLAYERS
then
8077 if gSpectPID1
= UID
then
8082 if gSpectViewTwo
and (gSpectPID2
= UID
) then
8089 function g_Game_IsWatchedTeam(Team
: Byte): Boolean;
8094 if (gPlayer1
<> nil) and (gPlayer1
.Team
= Team
) then
8099 if (gPlayer2
<> nil) and (gPlayer2
.Team
= Team
) then
8104 if gSpectMode
<> SPECT_PLAYERS
then
8106 Pl
:= g_Player_Get(gSpectPID1
);
8107 if (Pl
<> nil) and (Pl
.Team
= Team
) then
8112 if gSpectViewTwo
then
8114 Pl
:= g_Player_Get(gSpectPID2
);
8115 if (Pl
<> nil) and (Pl
.Team
= Team
) then
8123 procedure g_Game_Message(Msg
: string; Time
: Word);
8125 MessageLineLength
:= (gScreenWidth
- 204) div e_CharFont_GetMaxWidth(gMenuFont
);
8126 MessageText
:= b_Text_Wrap(b_Text_Format(Msg
), MessageLineLength
);
8127 MessageTime
:= Time
;
8130 procedure g_Game_ChatSound(Text: String; Taunt
: Boolean = True);
8132 punct
: Array[0..13] of String =
8133 ('.', ',', ':', ';', '!', '?', '(', ')', '''', '"', '/', '\', '*', '^');
8139 function IsPunctuation(S
: String): Boolean;
8144 if Length(S
) <> 1 then
8146 for i
:= Low(punct
) to High(punct
) do
8147 if S
= punct
[i
] then
8153 function FilterPunctuation(S
: String): String;
8157 for i
:= Low(punct
) to High(punct
) do
8158 S
:= StringReplace(S
, punct
[i
], ' ', [rfReplaceAll
]);
8164 if gUseChatSounds
and Taunt
and (gChatSounds
<> nil) and (Pos(': ', Text) > 0) then
8166 // remove player name
8167 Delete(Text, 1, Pos(': ', Text) + 2 - 1);
8168 // for FullWord check
8169 Text := toLowerCase1251(' ' + Text + ' ');
8170 fpText
:= FilterPunctuation(Text);
8172 for i
:= 0 to Length(gChatSounds
) - 1 do
8175 for j
:= 0 to Length(gChatSounds
[i
].Tags
) - 1 do
8177 if gChatSounds
[i
].FullWord
and (not IsPunctuation(gChatSounds
[i
].Tags
[j
])) then
8178 ok
:= Pos(' ' + gChatSounds
[i
].Tags
[j
] + ' ', fpText
) > 0
8180 ok
:= Pos(gChatSounds
[i
].Tags
[j
], Text) > 0;
8186 gChatSounds
[i
].Sound
.Play();
8192 g_Sound_PlayEx('SOUND_GAME_RADIO');
8195 procedure g_Game_Announce_GoodShot(SpawnerUID
: Word);
8204 if not g_Game_IsWatchedPlayer(SpawnerUID
) then
8208 if goodsnd
[a
].IsPlaying() then
8211 goodsnd
[Random(4)].Play();
8214 procedure g_Game_Announce_KillCombo(Param
: Integer);
8221 UID
:= Param
and $FFFF;
8226 Pl
:= g_Player_Get(UID
);
8235 g_Console_Add(Format(_lc
[I_PLAYER_KILL_2X
], [Name
]), True);
8239 g_Console_Add(Format(_lc
[I_PLAYER_KILL_3X
], [Name
]), True);
8243 g_Console_Add(Format(_lc
[I_PLAYER_KILL_4X
], [Name
]), True);
8247 g_Console_Add(Format(_lc
[I_PLAYER_KILL_MX
], [Name
]), True);
8255 if not g_Game_IsWatchedPlayer(UID
) then
8258 if (not g_Game_IsWatchedPlayer(UID
)) and (c
< 4) then
8262 if killsnd
[n
].IsPlaying() then
8267 procedure g_Game_Announce_BodyKill(SpawnerUID
: Word);
8275 if not g_Game_IsWatchedPlayer(SpawnerUID
) then
8279 if hahasnd
[a
].IsPlaying() then
8282 hahasnd
[Random(3)].Play();
8285 procedure g_Game_Effect_Bubbles (fX
, fY
: Integer; count
: Word; devX
, devY
: Byte; Silent
: Boolean);
8287 g_GFX_Bubbles(fX
, fY
, count
, devX
, devY
);
8288 if not Silent
then if Random(2) = 0
8289 then g_Sound_PlayExAt('SOUND_GAME_BUBBLE1', fX
, fY
)
8290 else g_Sound_PlayExAt('SOUND_GAME_BUBBLE2', fX
, fY
);
8293 procedure g_Game_StartVote(Command
, Initiator
: string);
8297 if not gVotesEnabled
then Exit
;
8298 if gGameSettings
.GameType
<> GT_SERVER
then Exit
;
8299 if gVoteInProgress
or gVotePassed
then
8301 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_INPROGRESS
], [gVoteCommand
]), True);
8302 MH_SEND_VoteEvent(NET_VE_INPROGRESS
, gVoteCommand
);
8305 gVoteInProgress
:= True;
8306 gVotePassed
:= False;
8307 gVoteTimer
:= gTime
+ gVoteTimeout
* 1000;
8310 gVoteCommand
:= Command
;
8312 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
8313 Need
:= Floor((NetClientCount
+1)/2.0)+1
8315 Need
:= Floor(NetClientCount
/2.0)+1;
8316 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_STARTED
], [Initiator
, Command
, Need
]), True);
8317 MH_SEND_VoteEvent(NET_VE_STARTED
, Initiator
, Command
, Need
);
8320 procedure g_Game_CheckVote
;
8324 if gGameSettings
.GameType
<> GT_SERVER
then Exit
;
8325 if not gVoteInProgress
then Exit
;
8327 if (gTime
>= gVoteTimer
) then
8329 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
8330 Need
:= Floor((NetClientCount
+1)/2.0) + 1
8332 Need
:= Floor(NetClientCount
/2.0) + 1;
8333 if gVoteCount
>= Need
then
8335 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_PASSED
], [gVoteCommand
]), True);
8336 MH_SEND_VoteEvent(NET_VE_PASSED
, gVoteCommand
);
8337 gVotePassed
:= True;
8338 gVoteCmdTimer
:= gTime
+ 5000;
8342 g_Console_Add(_lc
[I_MESSAGE_VOTE_FAILED
], True);
8343 MH_SEND_VoteEvent(NET_VE_FAILED
);
8345 if NetClients
<> nil then
8346 for I
:= Low(NetClients
) to High(NetClients
) do
8347 if NetClients
[i
].Used
then
8348 NetClients
[i
].Voted
:= False;
8349 gVoteInProgress
:= False;
8355 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
8356 Need
:= Floor((NetClientCount
+1)/2.0) + 1
8358 Need
:= Floor(NetClientCount
/2.0) + 1;
8359 if gVoteCount
>= Need
then
8361 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_PASSED
], [gVoteCommand
]), True);
8362 MH_SEND_VoteEvent(NET_VE_PASSED
, gVoteCommand
);
8363 gVoteInProgress
:= False;
8364 gVotePassed
:= True;
8365 gVoteCmdTimer
:= gTime
+ 5000;
8368 if NetClients
<> nil then
8369 for I
:= Low(NetClients
) to High(NetClients
) do
8370 if NetClients
[i
].Used
then
8371 NetClients
[i
].Voted
:= False;
8376 procedure g_Game_LoadMapList(FileName
: string);
8384 if not FileExists(FileName
) then Exit
;
8386 AssignFile(ListFile
, FileName
);
8388 while not EOF(ListFile
) do
8390 ReadLn(ListFile
, s
);
8393 if s
= '' then Continue
;
8395 SetLength(MapList
, Length(MapList
)+1);
8396 MapList
[High(MapList
)] := s
;
8398 CloseFile(ListFile
);
8401 procedure g_Game_SetDebugMode();
8404 // ×èòû (äàæå â ñâîåé èãðå):
8408 procedure g_Game_SetLoadingText(Text: String; Max
: Integer; reWrite
: Boolean);
8412 if Length(LoadingStat
.Msgs
) = 0 then
8418 begin // Ïåðåõîäèì íà ñëåäóþùóþ ñòðîêó èëè ñêðîëëèðóåì:
8419 if NextMsg
= Length(Msgs
) then
8421 for i
:= 0 to High(Msgs
)-1 do
8422 Msgs
[i
] := Msgs
[i
+1];
8430 Msgs
[NextMsg
-1] := Text;
8434 PBarWasHere
:= false;
8437 g_ActiveWindow
:= nil;
8438 ProcessLoading(True);
8441 procedure g_Game_StepLoading(Value
: Integer = -1);
8453 if (ShowCount
> LOADING_SHOW_STEP
) or (Value
> -1) then
8456 ProcessLoading(False);
8461 procedure g_Game_ClearLoading();
8470 len
:= ((gScreenHeight
div 3)*2 - 50) div LOADING_INTERLINE
;
8471 if len
< 1 then len
:= 1;
8472 SetLength(Msgs
, len
);
8473 for len
:= Low(Msgs
) to High(Msgs
) do
8476 PBarWasHere
:= false;
8480 procedure Parse_Params(var pars
: TParamStrValues
);
8487 while i
<= ParamCount
do
8490 if (Length(s
) > 1) and (s
[1] = '-') then
8492 if (Length(s
) > 2) and (s
[2] = '-') then
8493 begin // Îäèíî÷íûé ïàðàìåòð
8494 SetLength(pars
, Length(pars
) + 1);
8495 with pars
[High(pars
)] do
8497 Name
:= LowerCase(s
);
8502 if (i
< ParamCount
) then
8503 begin // Ïàðàìåòð ñî çíà÷åíèåì
8505 SetLength(pars
, Length(pars
) + 1);
8506 with pars
[High(pars
)] do
8508 Name
:= LowerCase(s
);
8509 Value
:= LowerCase(ParamStr(i
));
8518 function Find_Param_Value(var pars
: TParamStrValues
; aName
: String): String;
8523 for i
:= 0 to High(pars
) do
8524 if pars
[i
].Name
= aName
then
8526 Result
:= pars
[i
].Value
;
8531 procedure g_Game_Process_Params();
8533 pars
: TParamStrValues
;
8536 LimT
, LimS
: Integer;
8547 s
:= Find_Param_Value(pars
, '--debug');
8550 g_Game_SetDebugMode();
8551 s
:= Find_Param_Value(pars
, '--netdump');
8556 // Connect when game loads
8557 ip
:= Find_Param_Value(pars
, '-connect');
8561 s
:= Find_Param_Value(pars
, '-port');
8562 if (s
= '') or not TryStrToInt(s
, Port
) then
8565 s
:= Find_Param_Value(pars
, '-pw');
8567 g_Game_StartClient(ip
, Port
, s
);
8571 s
:= LowerCase(Find_Param_Value(pars
, '-dbg-mainwad'));
8574 gDefaultMegawadStart
:= s
;
8577 if (Find_Param_Value(pars
, '--dbg-mainwad-restore') <> '') or
8578 (Find_Param_Value(pars
, '--dbg-mainwad-default') <> '') then
8580 gDefaultMegawadStart
:= DF_Default_Megawad_Start
;
8583 // Start map when game loads:
8584 map
:= LowerCase(Find_Param_Value(pars
, '-map'));
8585 if isWadPath(map
) then
8588 s
:= Find_Param_Value(pars
, '-gm');
8589 GMode
:= g_Game_TextToMode(s
);
8590 if GMode
= GM_NONE
then GMode
:= GM_DM
;
8591 if GMode
= GM_SINGLE
then GMode
:= GM_COOP
;
8594 s
:= Find_Param_Value(pars
, '-limt');
8595 if (s
= '') or (not TryStrToInt(s
, LimT
)) then
8601 s
:= Find_Param_Value(pars
, '-lims');
8602 if (s
= '') or (not TryStrToInt(s
, LimS
)) then
8608 s
:= Find_Param_Value(pars
, '-lives');
8609 if (s
= '') or (not TryStrToInt(s
, Lives
)) then
8615 s
:= Find_Param_Value(pars
, '-opt');
8619 Opt
:= StrToIntDef(s
, 0);
8622 s
:= Find_Param_Value(pars
, '--close');
8626 // Override map to test:
8627 s
:= LowerCase(Find_Param_Value(pars
, '-testmap'));
8630 if e_IsValidResourceName(s
) then
8631 e_FindResource(AllMapDirs
, s
);
8632 gTestMap
:= ExpandFileName(s
);
8635 // Delete test map after play:
8636 s
:= Find_Param_Value(pars
, '--testdelete');
8639 //gMapToDelete := MapsDir + map;
8640 e_WriteLog('"--testdelete" is deprecated, use --tempdelete.', TMsgType
.Fatal
);
8644 // Delete temporary WAD after play:
8645 s
:= Find_Param_Value(pars
, '--tempdelete');
8646 if (s
<> '') and (gTestMap
<> '') then
8648 gMapToDelete
:= gTestMap
;
8649 gTempDelete
:= True;
8652 // Number of players:
8653 s
:= Find_Param_Value(pars
, '-pl');
8655 n
:= DEFAULT_PLAYERS
8657 n
:= StrToIntDef(s
, DEFAULT_PLAYERS
);
8660 s
:= Find_Param_Value(pars
, '-port');
8661 if (s
= '') or not TryStrToInt(s
, Port
) then
8662 g_Game_StartCustom(map
, GMode
, LimT
, LimS
, Lives
, Opt
, n
)
8664 g_Game_StartServer(map
, GMode
, LimT
, LimS
, Lives
, Opt
, n
, 0, Port
);
8667 // Execute script when game loads:
8668 s
:= Find_Param_Value(pars
, '-exec');
8671 // if not isWadPath(s) then
8672 // s := GameDir + '/' + s;
8677 if IOResult
<> 0 then
8679 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], ['Failed to read file: ' + s
]), TMsgType
.Warning
);
8680 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_READ
], [s
]));
8684 e_WriteLog('Executing script: ' + s
, TMsgType
.Notify
);
8685 g_Console_Add(Format(_lc
[I_CONSOLE_EXEC
], [s
]));
8690 if IOResult
<> 0 then
8692 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], ['Failed to read file: ' + s
]), TMsgType
.Warning
);
8693 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_READ
], [s
]));
8697 if Pos('#', s
) <> 1 then // script comment
8698 g_Console_Process(s
, True);
8709 conRegVar('pf_draw_frame', @g_profile_frame_draw
, 'draw frame rendering profiles', 'render profiles');
8710 //conRegVar('pf_update_frame', @g_profile_frame_update, 'draw frame updating profiles', 'update profiles');
8711 conRegVar('pf_coldet', @g_profile_collision
, 'draw collision detection profiles', 'coldet profiles');
8712 conRegVar('pf_los', @g_profile_los
, 'draw monster LOS profiles', 'monster LOS profiles');
8714 conRegVar('r_sq_draw', @gdbg_map_use_accel_render
, 'accelerated spatial queries in rendering', 'accelerated rendering');
8715 conRegVar('cd_sq_enabled', @gdbg_map_use_accel_coldet
, 'accelerated spatial queries in map coldet', 'accelerated map coldet');
8716 conRegVar('mon_sq_enabled', @gmon_debug_use_sqaccel
, 'accelerated spatial queries for monsters', 'accelerated monster coldet');
8717 conRegVar('wtrace_sq_enabled', @gwep_debug_fast_trace
, 'accelerated spatial queries for weapon hitscan trace', 'accelerated weapon hitscan');
8719 conRegVar('pr_enabled', @gpart_dbg_enabled
, 'enable/disable particles', 'particles');
8720 conRegVar('pr_phys_enabled', @gpart_dbg_phys_enabled
, 'enable/disable particle physics', 'particle physics');
8722 conRegVar('los_enabled', @gmon_dbg_los_enabled
, 'enable/disable monster LOS calculations', 'monster LOS', true);
8723 conRegVar('mon_think', @gmon_debug_think
, 'enable/disable monster thinking', 'monster thinking', true);
8725 {$IFDEF ENABLE_HOLMES}
8726 conRegVar('dbg_holmes', @g_holmes_enabled
, 'enable/disable Holmes', 'Holmes', true);
8729 conRegVar('dbg_ignore_level_bounds', @g_dbg_ignore_bounds
, 'ignore level bounds', '', false);
8731 conRegVar('r_scale', @g_dbg_scale
, 0.01, 100.0, 'render scale', '', false);
8732 conRegVar('r_resolution_scale', @r_pixel_scale
, 0.01, 100.0, 'upscale factor', '', false);
8734 conRegVar('light_enabled', @gwin_k8_enable_light_experiments
, 'enable/disable dynamic lighting', 'lighting');
8735 conRegVar('light_player_halo', @g_playerLight
, 'enable/disable player halo', 'player light halo');
8737 conRegVar('r_smallmap_align_h', @r_smallmap_h
, 'halign: 0: left; 1: center; 2: right', 'horizontal aligning of small maps');
8738 conRegVar('r_smallmap_align_v', @r_smallmap_v
, 'valign: 0: top; 1: center; 2: bottom', 'vertial aligning of small maps');
8740 conRegVar('r_showfps', @gShowFPS
, 'draw fps counter', 'draw fps counter');
8741 conRegVar('r_showtime', @gShowTime
, 'show game time', 'show game time');
8742 conRegVar('r_showping', @gShowPing
, 'show ping', 'show ping');
8743 conRegVar('r_showscore', @gShowScore
, 'show score', 'show score');
8744 conRegVar('r_showkillmsg', @gShowKillMsg
, 'show kill log', 'show kill log');
8745 conRegVar('r_showlives', @gShowLives
, 'show lives', 'show lives');
8746 conRegVar('r_showspect', @gSpectHUD
, 'show spectator hud', 'show spectator hud');
8747 conRegVar('r_showstat', @gShowStat
, 'show stats', 'show stats');
8748 conRegVar('r_showpids', @gShowPIDs
, 'show PIDs', 'show PIDs');