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;
46 TDelayedEvent
= record
55 Sound
: TPlayableSound
;
56 Tags
: Array of String;
60 TPlayerSettings
= record
65 // ones below are sent only to the server
67 WeaponPreferences
: Array[WP_FIRST
..WP_LAST
+1] of Byte;
84 function g_Game_IsNet(): Boolean;
85 function g_Game_IsServer(): Boolean;
86 function g_Game_IsClient(): Boolean;
87 procedure g_Game_Init();
88 procedure g_Game_Free (freeTextures
: Boolean=true);
89 procedure g_Game_LoadData();
90 procedure g_Game_FreeData();
91 procedure g_Game_Update();
92 procedure g_Game_PreUpdate();
93 procedure g_Game_Draw();
94 procedure g_Game_Quit();
95 procedure g_Game_SetupScreenSize();
96 procedure g_Game_ChangeResolution(newWidth
, newHeight
: Word; nowFull
, nowMax
: Boolean);
97 function g_Game_ModeToText(Mode
: Byte): string;
98 function g_Game_TextToMode(Mode
: string): Byte;
99 procedure g_Game_ExecuteEvent(Name
: String);
100 function g_Game_DelayEvent(DEType
: Byte; Time
: LongWord; Num
: Integer = 0; Str
: String = ''): Integer;
101 procedure g_Game_AddPlayer(Team
: Byte = TEAM_NONE
);
102 procedure g_Game_RemovePlayer();
103 procedure g_Game_Spectate();
104 procedure g_Game_SpectateCenterView();
105 procedure g_Game_StartSingle(Map
: String; TwoPlayers
: Boolean; nPlayers
: Byte);
106 procedure g_Game_StartCustom(Map
: String; GameMode
: Byte; TimeLimit
, ScoreLimit
: Word; MaxLives
: Byte; Options
: LongWord; nPlayers
: Byte);
107 procedure g_Game_StartServer(Map
: String; GameMode
: Byte; TimeLimit
, ScoreLimit
: Word; MaxLives
: Byte; Options
: LongWord; nPlayers
: Byte; IPAddr
: LongWord; Port
: Word);
108 procedure g_Game_StartClient(Addr
: String; Port
: Word; PW
: String);
109 procedure g_Game_Restart();
110 procedure g_Game_RestartLevel();
111 procedure g_Game_RestartRound(NoMapRestart
: Boolean = False);
112 function g_Game_ClientWAD (NewWAD
: String; const WHash
: TMD5Digest
): AnsiString;
113 function g_Game_StartMap(asMegawad
: Boolean; Map
: String; Force
: Boolean = False; const oldMapPath
: AnsiString=''): Boolean;
114 procedure g_Game_ChangeMap(const MapPath
: String);
115 procedure g_Game_ExitLevel(const Map
: AnsiString);
116 function g_Game_GetFirstMap(WAD
: String): String;
117 function g_Game_GetNextMap(): String;
118 procedure g_Game_NextLevel();
119 procedure g_Game_Pause(Enable
: Boolean);
120 procedure g_Game_HolmesPause(Enable
: Boolean);
121 procedure g_Game_InGameMenu(Show
: Boolean);
122 function g_Game_IsWatchedPlayer(UID
: Word): Boolean;
123 function g_Game_IsWatchedTeam(Team
: Byte): Boolean;
124 procedure g_Game_Message(Msg
: String; Time
: Word);
125 procedure g_Game_LoadMapList(FileName
: String);
126 procedure g_Game_PauseAllSounds(Enable
: Boolean);
127 procedure g_Game_StopAllSounds(all
: Boolean);
128 procedure g_Game_UpdateTriggerSounds();
129 function g_Game_GetMegaWADInfo(WAD
: String): TMegaWADInfo
;
130 procedure g_Game_ChatSound(Text: String; Taunt
: Boolean = True);
131 procedure g_Game_Announce_GoodShot(SpawnerUID
: Word);
132 procedure g_Game_Announce_KillCombo(Param
: Integer);
133 procedure g_Game_Announce_BodyKill(SpawnerUID
: Word);
134 procedure g_Game_Effect_Bubbles(fX
, fY
: Integer; count
: Word; devX
, devY
: Byte; Silent
: Boolean = False);
135 procedure g_Game_StartVote(Command
, Initiator
: string);
136 procedure g_Game_CheckVote
;
137 procedure g_TakeScreenShot(Filename
: string = '');
138 procedure g_FatalError(Text: String);
139 procedure g_SimpleError(Text: String);
140 function g_Game_IsTestMap(): Boolean;
141 procedure g_Game_DeleteTestMap();
142 procedure GameCVars(P
: SSArray
);
143 procedure PlayerSettingsCVars(P
: SSArray
);
144 procedure SystemCommands(P
: SSArray
);
145 procedure GameCommands(P
: SSArray
);
146 procedure GameCheats(P
: SSArray
);
147 procedure DebugCommands(P
: SSArray
);
148 procedure g_Game_Process_Params
;
149 procedure g_Game_SetLoadingText(Text: String; Max
: Integer; reWrite
: Boolean);
150 procedure g_Game_StepLoading(Value
: Integer = -1);
151 procedure g_Game_ClearLoading();
152 procedure g_Game_SetDebugMode();
153 procedure DrawLoadingStat();
154 procedure DrawMenuBackground(tex
: AnsiString);
156 { procedure SetWinPause(Enable: Boolean); }
161 LOADING_SHOW_STEP
= 100;
162 LOADING_INTERLINE
= 20;
177 MESSAGE_DIKEY
= WM_USER
+ 1;
182 EXIT_ENDLEVELSINGLE
= 4;
183 EXIT_ENDLEVELCUSTOM
= 5;
185 GAME_OPTION_RESERVED
= 1;
186 GAME_OPTION_TEAMDAMAGE
= 2;
187 GAME_OPTION_ALLOWEXIT
= 4;
188 GAME_OPTION_WEAPONSTAY
= 8;
189 GAME_OPTION_MONSTERS
= 16;
190 GAME_OPTION_BOTVSPLAYER
= 32;
191 GAME_OPTION_BOTVSMONSTER
= 64;
192 GAME_OPTION_DMKEYS
= 128;
193 GAME_OPTION_TEAMHITTRACE
= 256;
194 GAME_OPTION_TEAMHITPROJECTILE
= 512;
195 GAME_OPTION_TEAMABSORBDAMAGE
= 1024;
196 GAME_OPTION_ALLOWDROPFLAG
= 2048;
197 GAME_OPTION_THROWFLAG
= 4096;
202 STATE_INTERCUSTOM
= 3;
203 STATE_INTERSINGLE
= 4;
209 LMS_RESPAWN_NONE
= 0;
210 LMS_RESPAWN_WARMUP
= 1;
211 LMS_RESPAWN_FINAL
= 2;
228 CONFIG_FILENAME
= 'Doom2DF.cfg';
230 TEST_MAP_NAME
= '$$$_TEST_$$$';
232 STD_PLAYER_MODEL
= 'Doomer';
240 STATFILE_VERSION
= $03;
244 gGameSettings
: TGameSettings
;
245 gPlayer1Settings
: TPlayerSettings
;
246 gPlayer2Settings
: TPlayerSettings
;
248 gPlayerScreenSize
: TDFPoint
;
249 gPlayer1ScreenCoord
: TDFPoint
;
250 gPlayer2ScreenCoord
: TDFPoint
;
251 gPlayer1
: TPlayer
= nil;
252 gPlayer2
: TPlayer
= nil;
253 gPlayerDrawn
: TPlayer
= nil;
255 gLerpFactor
: Single = 1.0;
256 gSwitchGameMode
: Byte = GM_DM
;
257 gHearPoint1
, gHearPoint2
: THearPoint
;
258 gSoundEffectsDF
: Boolean = False;
259 gSoundTriggerTime
: Word = 0;
260 gAnnouncer
: Integer = ANNOUNCE_NONE
;
261 goodsnd
: array[0..3] of TPlayableSound
;
262 killsnd
: array[0..3] of TPlayableSound
;
263 hahasnd
: array[0..2] of TPlayableSound
;
264 sound_get_flag
: array[0..1] of TPlayableSound
;
265 sound_lost_flag
: array[0..1] of TPlayableSound
;
266 sound_ret_flag
: array[0..1] of TPlayableSound
;
267 sound_cap_flag
: array[0..1] of TPlayableSound
;
268 gBodyKillEvent
: Integer = -1;
269 gDefInterTime
: ShortInt = -1;
270 gInterEndTime
: LongWord = 0;
271 gInterTime
: LongWord = 0;
272 gServInterTime
: Byte = 0;
273 gGameStartTime
: LongWord = 0;
274 gTotalMonsters
: Integer = 0;
275 gPauseMain
: Boolean = false;
276 gPauseHolmes
: Boolean = false;
277 gShowTime
: Boolean = False;
278 gShowFPS
: Boolean = False;
279 gShowScore
: Boolean = True;
280 gShowStat
: Boolean = True;
281 gShowPIDs
: Boolean = False;
282 gShowKillMsg
: Boolean = True;
283 gShowLives
: Boolean = True;
284 gShowPing
: Boolean = False;
285 gShowMap
: Boolean = False;
287 gState
: Byte = STATE_NONE
;
289 sWidth
, sHeight
: Word;
290 gSpectMode
: Byte = SPECT_NONE
;
291 gSpectHUD
: Boolean = True;
292 gSpectKeyPress
: Boolean = False;
293 gSpectX
: Integer = 0;
294 gSpectY
: Integer = 0;
295 gSpectStep
: Byte = 8;
296 gSpectViewTwo
: Boolean = False;
297 gSpectPID1
: Integer = -1;
298 gSpectPID2
: Integer = -1;
299 gSpectAuto
: Boolean = False;
300 gSpectAutoNext
: LongWord;
301 gSpectAutoStepX
: Integer;
302 gSpectAutoStepY
: Integer;
303 gMusic
: TMusic
= nil;
304 gLoadGameMode
: Boolean;
305 gCheats
: Boolean = False;
306 gMapOnce
: Boolean = False;
307 gMapToDelete
: String;
308 gTempDelete
: Boolean = False;
309 gLastMap
: Boolean = False;
312 gResolutionChange
: Boolean = False;
313 gRC_Width
, gRC_Height
: Integer;
314 gRC_FullScreen
, gRC_Maximized
: Boolean;
315 gLanguageChange
: Boolean = False;
316 gDebugMode
: Boolean = False;
317 g_debug_Sounds
: Boolean = False;
318 g_debug_Frames
: Boolean = False;
319 g_debug_WinMsgs
: Boolean = False;
320 g_debug_MonsterOff
: Boolean = False;
321 g_debug_BotAIOff
: Byte = 0;
322 g_debug_HealthBar
: Boolean = False;
323 g_Debug_Player
: Boolean = False;
324 gCoopMonstersKilled
: Word = 0;
325 gCoopSecretsFound
: Word = 0;
326 gCoopTotalMonstersKilled
: Word = 0;
327 gCoopTotalSecretsFound
: Word = 0;
328 gCoopTotalMonsters
: Word = 0;
329 gCoopTotalSecrets
: Word = 0;
330 gStatsOff
: Boolean = False;
331 gStatsPressed
: Boolean = False;
332 gExitByTrigger
: Boolean = False;
333 gNextMap
: String = '';
334 gLMSRespawn
: Byte = LMS_RESPAWN_NONE
;
335 gLMSRespawnTime
: Cardinal = 0;
336 gLMSSoftSpawn
: Boolean = False;
337 gMissionFailed
: Boolean = False;
338 gVoteInProgress
: Boolean = False;
339 gVotePassed
: Boolean = False;
340 gVoteCommand
: string = '';
341 gVoteTimer
: Cardinal = 0;
342 gVoteCmdTimer
: Cardinal = 0;
343 gVoteCount
: Integer = 0;
344 gVoteTimeout
: Cardinal = 30;
345 gVoted
: Boolean = False;
346 gVotesEnabled
: Boolean = True;
347 gEvents
: Array of TGameEvent
;
348 gDelayedEvents
: Array of TDelayedEvent
;
349 gUseChatSounds
: Boolean = True;
350 gChatSounds
: Array of TChatSound
;
351 gWeaponAction
: Array [0..1, WP_FACT
..WP_LACT
] of Boolean; // [player, weapon_action]
352 gSelectWeapon
: Array [0..1, WP_FIRST
..WP_LAST
] of Boolean; // [player, weapon]
353 gInterReadyCount
: Integer = 0;
354 gMaxBots
: Integer = 127;
356 g_dbg_ignore_bounds
: Boolean = false;
357 r_smallmap_h
: Integer = 0; // 0: left; 1: center; 2: right
358 r_smallmap_v
: Integer = 2; // 0: top; 1: center; 2: bottom
360 // move button values:
361 // bits 0-1: l/r state:
362 // 0: neither left, nor right pressed
365 // bits 4-5: l/r state when strafe was pressed
366 P1MoveButton
: Byte = 0;
367 P2MoveButton
: Byte = 0;
369 g_profile_frame_update
: Boolean = false;
370 g_profile_frame_draw
: Boolean = false;
371 g_profile_collision
: Boolean = false;
372 g_profile_los
: Boolean = false;
373 g_profile_history_size
: Integer = 1000;
375 g_rlayer_back
: Boolean = true;
376 g_rlayer_step
: Boolean = true;
377 g_rlayer_wall
: Boolean = true;
378 g_rlayer_door
: Boolean = true;
379 g_rlayer_acid1
: Boolean = true;
380 g_rlayer_acid2
: Boolean = true;
381 g_rlayer_water
: Boolean = true;
382 g_rlayer_fore
: Boolean = true;
385 procedure g_ResetDynlights ();
386 procedure g_AddDynLight (x
, y
, radius
: Integer; r
, g
, b
, a
: Single);
387 procedure g_DynLightExplosion (x
, y
, radius
: Integer; r
, g
, b
: Single);
389 function conIsCheatsEnabled (): Boolean; inline;
390 function gPause (): Boolean; inline;
396 {$INCLUDE ../nogl/noGLuses.inc}
397 {$IFDEF ENABLE_HOLMES}
400 e_texture
, e_res
, g_textures
, g_window
, g_menu
,
401 e_input
, e_log
, g_console
, g_items
, g_map
, g_panel
,
402 g_playermodel
, g_gfx
, g_options
, Math
,
403 g_triggers
, g_monsters
, e_sound
, CONFIG
,
404 g_language
, g_net
, g_main
, g_phys
,
405 ENet
, e_msg
, g_netmsg
, g_netmaster
,
406 sfs
, wadreader
, g_system
;
410 hasPBarGfx
: Boolean = false;
413 // ////////////////////////////////////////////////////////////////////////// //
414 function gPause (): Boolean; inline; begin result
:= gPauseMain
or gPauseHolmes
; end;
417 // ////////////////////////////////////////////////////////////////////////// //
418 function conIsCheatsEnabled (): Boolean; inline;
421 if g_Game_IsNet
then exit
;
422 if not gDebugMode
then
424 //if not gCheats then exit;
425 if not (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
]) then exit
;
426 if not (gGameSettings
.GameMode
in [GM_COOP
, GM_SINGLE
]) then exit
;
432 // ////////////////////////////////////////////////////////////////////////// //
434 profileFrameDraw
: TProfiler
= nil;
437 // ////////////////////////////////////////////////////////////////////////// //
440 x
, y
, radius
: Integer;
443 exploRadius
: Integer;
447 g_dynLights
: array of TDynLight
= nil;
448 g_dynLightCount
: Integer = 0;
449 g_playerLight
: Boolean = false;
451 procedure g_ResetDynlights ();
455 if not gwin_has_stencil
then begin g_dynLightCount
:= 0; exit
; end;
457 for idx
:= 0 to g_dynLightCount
-1 do
459 if g_dynLights
[idx
].exploCount
= -666 then
466 Inc(g_dynLights
[idx
].exploCount
);
467 if (g_dynLights
[idx
].exploCount
< 10) then
469 g_dynLights
[idx
].radius
:= g_dynLights
[idx
].exploRadius
+g_dynLights
[idx
].exploCount
*8;
470 g_dynLights
[idx
].a
:= 0.4+g_dynLights
[idx
].exploCount
/10;
471 if (g_dynLights
[idx
].a
> 0.8) then g_dynLights
[idx
].a
:= 0.8;
472 if lnum
<> idx
then g_dynLights
[lnum
] := g_dynLights
[idx
];
477 g_dynLightCount
:= lnum
;
480 procedure g_AddDynLight (x
, y
, radius
: Integer; r
, g
, b
, a
: Single);
482 if not gwin_has_stencil
then exit
;
483 if g_dynLightCount
= length(g_dynLights
) then SetLength(g_dynLights
, g_dynLightCount
+1024);
484 g_dynLights
[g_dynLightCount
].x
:= x
;
485 g_dynLights
[g_dynLightCount
].y
:= y
;
486 g_dynLights
[g_dynLightCount
].radius
:= radius
;
487 g_dynLights
[g_dynLightCount
].r
:= r
;
488 g_dynLights
[g_dynLightCount
].g
:= g
;
489 g_dynLights
[g_dynLightCount
].b
:= b
;
490 g_dynLights
[g_dynLightCount
].a
:= a
;
491 g_dynLights
[g_dynLightCount
].exploCount
:= -666;
492 Inc(g_dynLightCount
);
495 procedure g_DynLightExplosion (x
, y
, radius
: Integer; r
, g
, b
: Single);
497 if not gwin_has_stencil
then exit
;
498 if g_dynLightCount
= length(g_dynLights
) then SetLength(g_dynLights
, g_dynLightCount
+1024);
499 g_dynLights
[g_dynLightCount
].x
:= x
;
500 g_dynLights
[g_dynLightCount
].y
:= y
;
501 g_dynLights
[g_dynLightCount
].radius
:= 0;
502 g_dynLights
[g_dynLightCount
].exploRadius
:= radius
;
503 g_dynLights
[g_dynLightCount
].r
:= r
;
504 g_dynLights
[g_dynLightCount
].g
:= g
;
505 g_dynLights
[g_dynLightCount
].b
:= b
;
506 g_dynLights
[g_dynLightCount
].a
:= 0;
507 g_dynLights
[g_dynLightCount
].exploCount
:= 0;
508 Inc(g_dynLightCount
);
512 // ////////////////////////////////////////////////////////////////////////// //
513 function calcProfilesHeight (prof
: TProfiler
): Integer;
516 if (prof
= nil) then exit
;
517 if (length(prof
.bars
) = 0) then exit
;
518 result
:= length(prof
.bars
)*(16+2);
522 function drawProfiles (x
, y
: Integer; prof
: TProfiler
): Integer;
529 if (prof
= nil) then exit
;
531 if (length(prof
.bars
) = 0) then exit
;
533 hgt
:= calcProfilesHeight(prof
);
534 if (x
< 0) then x
:= gScreenWidth
-(wdt
-1)+x
;
535 if (y
< 0) then y
:= gScreenHeight
-(hgt
-1)+y
;
537 //e_DrawFillQuad(x, y, x+wdt-1, y+hgt-1, 255, 255, 255, 200, B_BLEND);
538 //e_DrawFillQuad(x, y, x+wdt-1, y+hgt-1, 20, 20, 20, 0, B_NONE);
539 e_DarkenQuadWH(x
, y
, wdt
, hgt
, 150);
542 for ii
:= 0 to High(prof
.bars
) do
544 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);
551 // ////////////////////////////////////////////////////////////////////////// //
553 TEndCustomGameStat
= record
554 PlayerStat
: TPlayerStatArray
;
558 Map
, MapName
: String;
561 TEndSingleGameStat
= record
562 PlayerStat
: Array [0..1] of record
568 TotalSecrets
: Integer;
571 TLoadingStat
= record
575 Msgs
: Array of String;
577 PBarWasHere
: Boolean; // did we draw a progress bar for this message?
580 TParamStrValue
= record
585 TParamStrValues
= Array of TParamStrValue
;
588 INTER_ACTION_TEXT
= 1;
589 INTER_ACTION_PIC
= 2;
590 INTER_ACTION_MUSIC
= 3;
594 FPSCounter
, UPSCounter
: Word;
595 FPSTime
, UPSTime
: LongWord;
596 DataLoaded
: Boolean = False;
597 IsDrawStat
: Boolean = False;
598 CustomStat
: TEndCustomGameStat
;
599 SingleStat
: TEndSingleGameStat
;
600 LoadingStat
: TLoadingStat
;
601 EndingGameCounter
: Byte = 0;
604 MessageLineLength
: Integer = 80;
605 MapList
: SSArray
= nil;
606 MapIndex
: Integer = -1;
607 InterReadyTime
: Integer = -1;
608 StatShotDone
: Boolean = False;
609 StatFilename
: string = ''; // used by stat screenshot to save with the same name as the csv
610 StatDate
: string = '';
616 text: Array of ShortString;
617 anim
: Array of ShortString;
618 pic
: Array of ShortString;
619 mus
: Array of ShortString;
621 triggers
: Array of record
623 actions
: Array of record
624 action
, p1
, p2
: Integer;
627 cur_trigger
: Integer;
640 function Compare(a
, b
: TPlayerStat
): Integer;
642 if a
.Spectator
then Result
:= 1
643 else if b
.Spectator
then Result
:= -1
644 else if a
.Assists
< b
.Assists
then Result
:= 1
645 else if a
.Assists
> b
.Assists
then Result
:= -1
646 else if a
.Frags
< b
.Frags
then Result
:= 1
647 else if a
.Frags
> b
.Frags
then Result
:= -1
648 else if a
.Deaths
< b
.Deaths
then Result
:= -1
649 else if a
.Deaths
> b
.Deaths
then Result
:= 1
650 else if a
.Kills
< b
.Kills
then Result
:= -1
654 procedure SortGameStat(var stat
: TPlayerStatArray
);
659 if stat
= nil then Exit
;
661 for I
:= High(stat
) downto Low(stat
) do
662 for J
:= Low(stat
) to High(stat
) - 1 do
663 if Compare(stat
[J
], stat
[J
+ 1]) = 1 then
666 stat
[J
] := stat
[J
+ 1];
671 // saves a shitty CSV containing the game stats passed to it
672 procedure SaveGameStat(Stat
: TEndCustomGameStat
; Path
: string);
675 dir
, fname
, map
, mode
, etime
: String;
679 dir
:= e_GetWriteableDir(StatsDirs
);
680 // stats are placed in stats/yy/mm/dd/*.csv
681 fname
:= e_CatPath(dir
, Path
);
682 ForceDirectories(fname
); // ensure yy/mm/dd exists within the stats dir
683 fname
:= e_CatPath(fname
, StatFilename
+ '.csv');
684 AssignFile(s
, fname
);
686 SetTextCodePage(s
, CP_UTF8
);
688 // line 1: stats ver, datetime, server name, map name, game mode, time limit, score limit, dmflags, game time, num players
689 if g_Game_IsNet
then fname
:= NetServerName
else fname
:= '';
690 map
:= g_ExtractWadNameNoPath(gMapInfo
.Map
) + ':/' + g_ExtractFileName(gMapInfo
.Map
);
691 mode
:= g_Game_ModeToText(Stat
.GameMode
);
692 etime
:= Format('%d:%.2d:%.2d', [
693 Stat
.GameTime
div 1000 div 3600,
694 (Stat
.GameTime
div 1000 div 60) mod 60,
695 Stat
.GameTime
div 1000 mod 60
697 WriteLn(s
, 'stats_ver,datetime,server,map,mode,timelimit,scorelimit,dmflags,time,num_players');
698 WriteLn(s
, Format('%d,%s,%s,%s,%s,%u,%u,%u,%s,%d', [
704 gGameSettings
.TimeLimit
,
705 gGameSettings
.ScoreLimit
,
706 gGameSettings
.Options
,
708 Length(Stat
.PlayerStat
)
710 // line 2: game specific shit
711 // if it's a team game: red score, blue score
712 // if it's a coop game: monsters killed, monsters total, secrets found, secrets total
714 if Stat
.GameMode
in [GM_TDM
, GM_CTF
] then
716 Format('red_score,blue_score' + LineEnding
+ '%d,%d', [Stat
.TeamStat
[TEAM_RED
].Score
, Stat
.TeamStat
[TEAM_BLUE
].Score
]))
717 else if Stat
.GameMode
in [GM_COOP
, GM_SINGLE
] then
719 Format('mon_killed,mon_total,secrets_found,secrets_total' + LineEnding
+ '%d,%d,%d,%d',[gCoopMonstersKilled
, gTotalMonsters
, gCoopSecretsFound
, gSecretsCount
]));
720 // lines 3-...: team, player name, frags, deaths
721 WriteLn(s
, 'team,name,frags,assists,deaths');
722 for I
:= Low(Stat
.PlayerStat
) to High(Stat
.PlayerStat
) do
723 with Stat
.PlayerStat
[I
] do
724 WriteLn(s
, Format('%d,%s,%d,%d', [Team
, dquoteStr(Name
), Frags
, Assists
, Deaths
]));
726 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_WRITE
], [fname
]));
729 g_Console_Add('could not create gamestats file "' + fname
+ '"');
734 procedure ClearDebugCvars();
736 g_debug_Sounds
:= False;
737 g_debug_Frames
:= False;
738 g_debug_WinMsgs
:= False;
739 g_debug_MonsterOff
:= False;
740 g_debug_BotAIOff
:= 0;
741 g_debug_HealthBar
:= False;
742 g_Debug_Player
:= False;
745 function g_Game_ModeToText(Mode
: Byte): string;
749 GM_DM
: Result
:= _lc
[I_MENU_GAME_TYPE_DM
];
750 GM_TDM
: Result
:= _lc
[I_MENU_GAME_TYPE_TDM
];
751 GM_CTF
: Result
:= _lc
[I_MENU_GAME_TYPE_CTF
];
752 GM_COOP
: Result
:= _lc
[I_MENU_GAME_TYPE_COOP
];
753 GM_SINGLE
: Result
:= _lc
[I_MENU_GAME_TYPE_SINGLE
];
757 function g_Game_TextToMode(Mode
: string): Byte;
760 Mode
:= UpperCase(Mode
);
761 if Mode
= _lc
[I_MENU_GAME_TYPE_DM
] then
766 if Mode
= _lc
[I_MENU_GAME_TYPE_TDM
] then
771 if Mode
= _lc
[I_MENU_GAME_TYPE_CTF
] then
776 if Mode
= _lc
[I_MENU_GAME_TYPE_COOP
] then
781 if Mode
= _lc
[I_MENU_GAME_TYPE_SINGLE
] then
788 function g_Game_IsNet(): Boolean;
790 Result
:= (gGameSettings
.GameType
in [GT_SERVER
, GT_CLIENT
]);
793 function g_Game_IsServer(): Boolean;
795 Result
:= (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
, GT_SERVER
]);
798 function g_Game_IsClient(): Boolean;
800 Result
:= (gGameSettings
.GameType
= GT_CLIENT
);
803 function g_Game_GetMegaWADInfo(WAD
: String): TMegaWADInfo
;
810 Result
.name
:= ExtractFileName(WAD
);
811 Result
.description
:= '';
814 w
:= TWADFile
.Create();
817 if not w
.GetResource('INTERSCRIPT', p
, len
) then
823 cfg
:= TConfig
.CreateMem(p
, len
);
824 Result
.name
:= cfg
.ReadStr('megawad', 'name', ExtractFileName(WAD
));
825 Result
.description
:= cfg
.ReadStr('megawad', 'description', '');
826 Result
.author
:= cfg
.ReadStr('megawad', 'author', '');
827 Result
.pic
:= cfg
.ReadStr('megawad', 'pic', '');
833 procedure g_Game_FreeWAD();
837 for a
:= 0 to High(MegaWAD
.res
.pic
) do
838 if MegaWAD
.res
.pic
[a
] <> '' then
839 g_Texture_Delete(MegaWAD
.res
.pic
[a
]);
841 for a
:= 0 to High(MegaWAD
.res
.mus
) do
842 if MegaWAD
.res
.mus
[a
] <> '' then
843 g_Sound_Delete(MegaWAD
.res
.mus
[a
]);
845 MegaWAD
.res
.pic
:= nil;
846 MegaWAD
.res
.text := nil;
847 MegaWAD
.res
.anim
:= nil;
848 MegaWAD
.res
.mus
:= nil;
849 MegaWAD
.triggers
:= nil;
851 g_Texture_Delete('TEXTURE_endpic');
852 g_Sound_Delete('MUSIC_endmus');
854 ZeroMemory(@MegaWAD
, SizeOf(MegaWAD
));
855 gGameSettings
.WAD
:= '';
858 procedure g_Game_LoadWAD(WAD
: string);
867 gGameSettings
.WAD
:= WAD
;
868 if not (gGameSettings
.GameMode
in [GM_COOP
, GM_SINGLE
]) then
871 MegaWAD
.info
:= g_Game_GetMegaWADInfo(WAD
);
873 w
:= TWADFile
.Create();
876 if not w
.GetResource('INTERSCRIPT', p
, len
) then
882 cfg
:= TConfig
.CreateMem(p
, len
);
887 s := cfg.ReadStr('pic', 'pic'+IntToStr(b), '');
888 if s = '' then Break;
891 SetLength(MegaWAD.res.pic, Length(MegaWAD.res.pic)+1);
892 MegaWAD.res.pic[High(MegaWAD.res.pic)] := s;
894 g_Texture_CreateWADEx(s, s);
900 s := cfg.ReadStr('mus', 'mus'+IntToStr(b), '');
901 if s = '' then Break;
904 SetLength(MegaWAD.res.mus, Length(MegaWAD.res.mus)+1);
905 MegaWAD.res.mus[High(MegaWAD.res.mus)] := s;
907 g_Music_CreateWADEx(s, s);
910 MegaWAD
.endpic
:= cfg
.ReadStr('megawad', 'endpic', '');
911 if MegaWAD
.endpic
<> '' then
913 TEXTUREFILTER
:= GL_LINEAR
;
914 s
:= e_GetResourcePath(WadDirs
, MegaWAD
.endpic
, WAD
);
915 g_Texture_CreateWADEx('TEXTURE_endpic', s
);
916 TEXTUREFILTER
:= GL_NEAREST
;
918 MegaWAD
.endmus
:= cfg
.ReadStr('megawad', 'endmus', 'Standart.wad:D2DMUS\ÊÎÍÅÖ');
919 if MegaWAD
.endmus
<> '' then
921 s
:= e_GetResourcePath(WadDirs
, MegaWAD
.endmus
, WAD
);
922 g_Sound_CreateWADEx('MUSIC_endmus', s
, True);
930 {procedure start_trigger(t: string);
934 function next_trigger(): Boolean;
938 procedure DisableCheats();
944 if gPlayer1
<> nil then gPlayer1
.GodMode
:= False;
945 if gPlayer2
<> nil then gPlayer2
.GodMode
:= False;
946 if gPlayer1
<> nil then gPlayer1
.NoTarget
:= False;
947 if gPlayer2
<> nil then gPlayer2
.NoTarget
:= False;
949 {$IF DEFINED(D2F_DEBUG)}
950 if gPlayer1
<> nil then gPlayer1
.NoTarget
:= True;
951 gAimLine
:= g_dbg_aimline_on
;
955 procedure g_Game_ExecuteEvent(Name
: String);
961 if gEvents
= nil then
963 for a
:= 0 to High(gEvents
) do
964 if gEvents
[a
].Name
= Name
then
966 if gEvents
[a
].Command
<> '' then
967 g_Console_Process(gEvents
[a
].Command
, True);
972 function g_Game_DelayEvent(DEType
: Byte; Time
: LongWord; Num
: Integer = 0; Str
: String = ''): Integer;
977 if gDelayedEvents
<> nil then
978 for a
:= 0 to High(gDelayedEvents
) do
979 if not gDelayedEvents
[a
].Pending
then
986 SetLength(gDelayedEvents
, Length(gDelayedEvents
) + 1);
987 n
:= High(gDelayedEvents
);
989 gDelayedEvents
[n
].Pending
:= True;
990 gDelayedEvents
[n
].DEType
:= DEType
;
991 gDelayedEvents
[n
].DENum
:= Num
;
992 gDelayedEvents
[n
].DEStr
:= Str
;
993 if DEType
= DE_GLOBEVENT
then
994 gDelayedEvents
[n
].Time
:= (sys_GetTicks() {div 1000}) + Time
996 gDelayedEvents
[n
].Time
:= gTime
+ Time
;
1000 procedure EndGame();
1006 if g_Game_IsNet
and g_Game_IsServer
then
1007 MH_SEND_GameEvent(NET_EV_MAPEND
, Byte(gMissionFailed
));
1010 gPauseMain
:= false;
1011 gPauseHolmes
:= false;
1014 g_Game_StopAllSounds(False);
1019 EndingGameCounter
:= 0;
1020 g_ActiveWindow
:= nil;
1022 gLMSRespawn
:= LMS_RESPAWN_NONE
;
1023 gLMSRespawnTime
:= 0;
1026 EXIT_SIMPLE
: // Âûõîä ÷åðåç ìåíþ èëè êîíåö òåñòà
1031 begin // Ýòî áûë òåñò
1035 begin // Âûõîä â ãëàâíîå ìåíþ
1036 gMusic
.SetByName('MUSIC_MENU');
1038 if gState
<> STATE_SLIST
then
1040 g_GUI_ShowWindow('MainMenu');
1041 gState
:= STATE_MENU
;
1044 // Îáíîâëÿåì ñïèñîê ñåðâåðîâ
1045 slReturnPressed
:= True;
1046 if g_Net_Slist_Fetch(slCurrent
) then
1048 if slCurrent
= nil then
1049 slWaitStr
:= _lc
[I_NET_SLIST_NOSERVERS
];
1052 slWaitStr
:= _lc
[I_NET_SLIST_ERROR
];
1053 g_Serverlist_GenerateTable(slCurrent
, slTable
);
1056 g_Game_ExecuteEvent('ongameend');
1060 EXIT_RESTART
: // Íà÷àòü óðîâåíü ñíà÷àëà
1062 if not g_Game_IsClient
then g_Game_Restart();
1065 EXIT_ENDLEVELCUSTOM
: // Çàêîí÷èëñÿ óðîâåíü â Ñâîåé èãðå
1067 // Ñòàòèñòèêà Ñâîåé èãðû:
1068 FileName
:= g_ExtractWadName(gMapInfo
.Map
);
1070 CustomStat
.GameTime
:= gTime
;
1071 CustomStat
.Map
:= ExtractFileName(FileName
)+':'+g_ExtractFileName(gMapInfo
.Map
); //ResName;
1072 CustomStat
.MapName
:= gMapInfo
.Name
;
1073 CustomStat
.GameMode
:= gGameSettings
.GameMode
;
1074 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
1075 CustomStat
.TeamStat
:= gTeamStat
;
1077 CustomStat
.PlayerStat
:= nil;
1079 // Ñòàòèñòèêà èãðîêîâ:
1080 if gPlayers
<> nil then
1082 for a
:= 0 to High(gPlayers
) do
1083 if gPlayers
[a
] <> nil then
1085 SetLength(CustomStat
.PlayerStat
, Length(CustomStat
.PlayerStat
)+1);
1086 with CustomStat
.PlayerStat
[High(CustomStat
.PlayerStat
)] do
1089 Name
:= gPlayers
[a
].Name
;
1090 Frags
:= gPlayers
[a
].Frags
;
1091 Assists
:= gPlayers
[a
].Assists
;
1092 Deaths
:= gPlayers
[a
].Death
;
1093 Kills
:= gPlayers
[a
].Kills
;
1094 Team
:= gPlayers
[a
].Team
;
1095 Color
:= gPlayers
[a
].Model
.Color
;
1096 Spectator
:= gPlayers
[a
].FSpectator
;
1100 SortGameStat(CustomStat
.PlayerStat
);
1102 if (gSaveStats
or gScreenshotStats
) and (Length(CustomStat
.PlayerStat
) > 1) then
1105 if g_Game_IsNet
then StatFilename
:= NetServerName
else StatFilename
:= 'local';
1106 StatDate
:= FormatDateTime('yymmdd_hhnnss', t
);
1107 StatFilename
:= StatFilename
+ '_' + CustomStat
.Map
+ '_' + g_Game_ModeToText(CustomStat
.GameMode
);
1108 StatFilename
:= sanitizeFilename(StatFilename
) + '_' + StatDate
;
1110 SaveGameStat(CustomStat
, FormatDateTime('yyyy"/"mm"/"dd', t
));
1113 StatShotDone
:= False;
1116 g_Game_ExecuteEvent('onmapend');
1117 if not g_Game_IsClient
then g_Player_ResetReady
;
1118 gInterReadyCount
:= 0;
1120 // Çàòóõàþùèé ýêðàí:
1121 EndingGameCounter
:= 255;
1122 gState
:= STATE_FOLD
;
1124 if gDefInterTime
< 0 then
1125 gInterEndTime
:= IfThen((gGameSettings
.GameType
= GT_SERVER
) and (gPlayer1
= nil), 15000, 25000)
1127 gInterEndTime
:= gDefInterTime
* 1000;
1130 EXIT_ENDLEVELSINGLE
: // Çàêîí÷èëñÿ óðîâåíü â Îäèíî÷íîé èãðå
1132 // Ñòàòèñòèêà Îäèíî÷íîé èãðû:
1133 SingleStat
.GameTime
:= gTime
;
1134 SingleStat
.TwoPlayers
:= gPlayer2
<> nil;
1135 SingleStat
.TotalSecrets
:= gSecretsCount
;
1136 // Ñòàòèñòèêà ïåðâîãî èãðîêà:
1137 SingleStat
.PlayerStat
[0].Kills
:= gPlayer1
.MonsterKills
;
1138 SingleStat
.PlayerStat
[0].Secrets
:= gPlayer1
.Secrets
;
1139 // Ñòàòèñòèêà âòîðîãî èãðîêà (åñëè åñòü):
1140 if SingleStat
.TwoPlayers
then
1142 SingleStat
.PlayerStat
[1].Kills
:= gPlayer2
.MonsterKills
;
1143 SingleStat
.PlayerStat
[1].Secrets
:= gPlayer2
.Secrets
;
1146 g_Game_ExecuteEvent('onmapend');
1149 if gNextMap
<> '' then
1151 gMusic
.SetByName('MUSIC_INTERMUS');
1153 gState
:= STATE_INTERSINGLE
;
1156 g_Game_ExecuteEvent('oninter');
1158 else // Áîëüøå íåò êàðò
1160 // Çàòóõàþùèé ýêðàí:
1161 EndingGameCounter
:= 255;
1162 gState
:= STATE_FOLD
;
1167 // Îêîí÷àíèå îáðàáîòàíî:
1168 if gExit
<> EXIT_QUIT
then
1172 procedure drawTime(X
, Y
: Integer); inline;
1174 e_TextureFontPrint(x
, y
,
1175 Format('%d:%.2d:%.2d', [
1176 gTime
div 1000 div 3600,
1177 (gTime
div 1000 div 60) mod 60,
1178 gTime
div 1000 mod 60
1183 procedure DrawStat();
1185 pc
, x
, y
, w
, h
: Integer;
1186 w1
, w2
, w3
, w4
: Integer;
1188 cw
, ch
, r
, g
, b
, rr
, gg
, bb
: Byte;
1191 stat
: TPlayerStatArray
;
1199 pc
:= g_Player_GetCount
;
1200 e_TextureFontGetSize(gStdFont
, cw
, ch
);
1202 w
:= gScreenWidth
-(gScreenWidth
div 5);
1203 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
1206 h
:= 40+ch
*5+(ch
+8)*pc
;
1207 x
:= (gScreenWidth
div 2)-(w
div 2);
1208 y
:= (gScreenHeight
div 2)-(h
div 2);
1210 e_DrawFillQuad(x
, y
, x
+w
-1, y
+h
-1, 64, 64, 64, 32);
1211 e_DrawQuad(x
, y
, x
+w
-1, y
+h
-1, 255, 127, 0);
1213 drawTime(x
+w
-78, y
+8);
1215 wad
:= g_ExtractWadNameNoPath(gMapInfo
.Map
);
1216 map
:= g_ExtractFileName(gMapInfo
.Map
);
1217 mapstr
:= wad
+ ':\' + map
+ ' - ' + gMapInfo
.Name
;
1219 case gGameSettings
.GameMode
of
1222 if gGameSettings
.MaxLives
= 0 then
1223 s1
:= _lc
[I_GAME_DM
]
1225 s1
:= _lc
[I_GAME_LMS
];
1226 s2
:= Format(_lc
[I_GAME_FRAG_LIMIT
], [gGameSettings
.ScoreLimit
]);
1227 s3
:= Format(_lc
[I_GAME_TIME_LIMIT
], [gGameSettings
.TimeLimit
div 3600, (gGameSettings
.TimeLimit
div 60) mod 60, gGameSettings
.TimeLimit
mod 60]);
1232 if gGameSettings
.MaxLives
= 0 then
1233 s1
:= _lc
[I_GAME_TDM
]
1235 s1
:= _lc
[I_GAME_TLMS
];
1236 s2
:= Format(_lc
[I_GAME_FRAG_LIMIT
], [gGameSettings
.ScoreLimit
]);
1237 s3
:= Format(_lc
[I_GAME_TIME_LIMIT
], [gGameSettings
.TimeLimit
div 3600, (gGameSettings
.TimeLimit
div 60) mod 60, gGameSettings
.TimeLimit
mod 60]);
1242 s1
:= _lc
[I_GAME_CTF
];
1243 s2
:= Format(_lc
[I_GAME_SCORE_LIMIT
], [gGameSettings
.ScoreLimit
]);
1244 s3
:= Format(_lc
[I_GAME_TIME_LIMIT
], [gGameSettings
.TimeLimit
div 3600, (gGameSettings
.TimeLimit
div 60) mod 60, gGameSettings
.TimeLimit
mod 60]);
1249 if gGameSettings
.MaxLives
= 0 then
1250 s1
:= _lc
[I_GAME_COOP
]
1252 s1
:= _lc
[I_GAME_SURV
];
1253 s2
:= _lc
[I_GAME_MONSTERS
] + ' ' + IntToStr(gCoopMonstersKilled
) + '/' + IntToStr(gTotalMonsters
);
1254 s3
:= _lc
[I_GAME_SECRETS
] + ' ' + IntToStr(gCoopSecretsFound
) + '/' + IntToStr(gSecretsCount
);
1265 e_TextureFontPrintEx(x
+(w
div 2)-(Length(s1
)*cw
div 2), _y
, s1
, gStdFont
, 255, 255, 255, 1);
1267 e_TextureFontPrintEx(x
+(w
div 2)-(Length(mapstr
)*cw
div 2), _y
, mapstr
, gStdFont
, 200, 200, 200, 1);
1269 e_TextureFontPrintEx(x
+16, _y
, s2
, gStdFont
, 200, 200, 200, 1);
1271 e_TextureFontPrintEx(x
+w
-16-(Length(s3
))*cw
, _y
, s3
,
1272 gStdFont
, 200, 200, 200, 1);
1274 if NetMode
= NET_SERVER
then
1275 e_TextureFontPrintEx(x
+8, y
+ 8, _lc
[I_NET_SERVER
], gStdFont
, 255, 255, 255, 1)
1277 if NetMode
= NET_CLIENT
then
1278 e_TextureFontPrintEx(x
+8, y
+ 8,
1279 NetClientIP
+ ':' + IntToStr(NetClientPort
), gStdFont
, 255, 255, 255, 1);
1283 stat
:= g_Player_GetStats();
1286 w2
:= (w
-16) div 6 + 48; // øèðèíà 2 ñòîëáöà
1287 w3
:= (w
-16) div 6; // øèðèíà 3 è 4 ñòîëáöîâ
1289 w1
:= w
-16-w2
-w3
-w4
; // îñòàâøååñÿ ïðîñòðàíñòâî - äëÿ öâåòà è èìåíè èãðîêà
1291 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
1295 for a
:= TEAM_RED
to TEAM_BLUE
do
1297 if a
= TEAM_RED
then
1299 s1
:= _lc
[I_GAME_TEAM_RED
];
1306 s1
:= _lc
[I_GAME_TEAM_BLUE
];
1312 e_TextureFontPrintEx(x
+16, _y
, s1
, gStdFont
, r
, g
, b
, 1);
1313 e_TextureFontPrintEx(x
+w1
+16, _y
, IntToStr(gTeamStat
[a
].Score
),
1314 gStdFont
, r
, g
, b
, 1);
1315 e_TextureFontPrintEx(x
+w1
+w2
+16, _y
, _lc
[I_GAME_FRAGS
],
1316 gStdFont
, r
, g
, b
, 1);
1317 e_TextureFontPrintEx(x
+w1
+w2
+72, _y
, _lc
[I_GAME_ASSISTS
],
1318 gStdFont
, r
, g
, b
, 1);
1320 _y
:= _y
+ch
+(ch
div 4);
1321 e_DrawLine(1, x
+16, _y
, x
+w
-16, _y
, r
, g
, b
);
1322 _y
:= _y
+(ch
div 4);
1324 for aa
:= 0 to High(stat
) do
1325 if stat
[aa
].Team
= a
then
1341 namestr
:= Format('[%5d] %s', [UID
, Name
])
1345 e_TextureFontPrintEx(x
+16, _y
, namestr
, gStdFont
, rr
, gg
, bb
, 1);
1347 e_TextureFontPrintEx(x
+w1
+16, _y
, Format(_lc
[I_GAME_PING_MS
], [Ping
, Loss
]), gStdFont
, rr
, gg
, bb
, 1);
1349 e_TextureFontPrintEx(x
+w1
+w2
+16, _y
, IntToStr(Frags
), gStdFont
, rr
, gg
, bb
, 1);
1351 e_TextureFontPrintEx(x
+w1
+w2
+72, _y
, IntToStr(Assists
), gStdFont
, rr
, gg
, bb
, 1);
1353 e_TextureFontPrintEx(x
+w1
+w2
+w3
+16, _y
, IntToStr(Deaths
), gStdFont
, rr
, gg
, bb
, 1);
1360 else if gGameSettings
.GameMode
in [GM_DM
, GM_COOP
] then
1363 e_TextureFontPrintEx(x
+16, _y
, _lc
[I_GAME_PLAYER_NAME
], gStdFont
, 255, 127, 0, 1);
1364 e_TextureFontPrintEx(x
+16+w1
, _y
, _lc
[I_GAME_PING
], gStdFont
, 255, 127, 0, 1);
1365 e_TextureFontPrintEx(x
+16+w1
+w2
, _y
, _lc
[I_GAME_FRAGS
], gStdFont
, 255, 127, 0, 1);
1366 e_TextureFontPrintEx(x
+16+w1
+w2
+w3
, _y
, _lc
[I_GAME_DEATHS
], gStdFont
, 255, 127, 0, 1);
1369 for aa
:= 0 to High(stat
) do
1383 namestr
:= Format('[%5d] %s', [UID
, Name
])
1387 e_DrawFillQuad(x
+16, _y
+4, x
+32-1, _y
+16+4-1, Color
.R
, Color
.G
, Color
.B
, 0);
1388 e_DrawQuad(x
+16, _y
+4, x
+32-1, _y
+16+4-1, 192, 192, 192);
1390 e_TextureFontPrintEx(x
+16+16+8, _y
+4, namestr
, gStdFont
, r
, g
, 0, 1);
1392 e_TextureFontPrintEx(x
+w1
+16, _y
+4, Format(_lc
[I_GAME_PING_MS
], [Ping
, Loss
]), gStdFont
, r
, g
, 0, 1);
1394 e_TextureFontPrintEx(x
+w1
+w2
+16, _y
+4, IntToStr(Frags
), gStdFont
, r
, g
, 0, 1);
1396 e_TextureFontPrintEx(x
+w1
+w2
+w3
+16, _y
+4, IntToStr(Deaths
), gStdFont
, r
, g
, 0, 1);
1402 procedure g_Game_Init();
1405 knownFiles
: array of AnsiString = nil;
1407 wext
, s
: AnsiString;
1412 gTempDelete
:= False;
1414 sfsGCDisable(); // temporary disable removing of temporary volumes
1417 TEXTUREFILTER
:= GL_LINEAR
;
1418 g_Texture_CreateWADEx('MENU_BACKGROUND', GameWAD
+':TEXTURES\TITLE');
1419 g_Texture_CreateWADEx('INTER', GameWAD
+':TEXTURES\INTER');
1420 g_Texture_CreateWADEx('ENDGAME_EN', GameWAD
+':TEXTURES\ENDGAME_EN');
1421 g_Texture_CreateWADEx('ENDGAME_RU', GameWAD
+':TEXTURES\ENDGAME_RU');
1422 TEXTUREFILTER
:= GL_NEAREST
;
1424 LoadStdFont('STDTXT', 'STDFONT', gStdFont
);
1425 LoadFont('MENUTXT', 'MENUFONT', gMenuFont
);
1426 LoadFont('SMALLTXT', 'SMALLFONT', gMenuSmallFont
);
1428 g_Game_ClearLoading();
1429 g_Game_SetLoadingText(Format('Doom 2D: Forever %s', [GAME_VERSION
]), 0, False);
1430 g_Game_SetLoadingText('', 0, False);
1432 g_Game_SetLoadingText(_lc
[I_LOAD_CONSOLE
], 0, False);
1435 g_Game_SetLoadingText(_lc
[I_LOAD_MODELS
], 0, False);
1436 g_PlayerModel_LoadData();
1438 // load models from all possible wad types, in all known directories
1439 // this does a loosy job (linear search, ooph!), but meh
1440 for wext
in wadExtensions
do
1442 for f
:= High(ModelDirs
) downto Low(ModelDirs
) do
1444 if (FindFirst(ModelDirs
[f
]+DirectorySeparator
+'*'+wext
, faAnyFile
, SR
) = 0) then
1448 for s
in knownFiles
do
1450 if (strEquCI1251(forceFilenameExt(SR
.Name
, ''), forceFilenameExt(ExtractFileName(s
), ''))) then
1458 SetLength(knownFiles
, length(knownFiles
)+1);
1459 knownFiles
[High(knownFiles
)] := ModelDirs
[f
]+DirectorySeparator
+SR
.Name
;
1461 until (FindNext(SR
) <> 0);
1467 if (length(knownFiles
) = 0) then raise Exception
.Create('no player models found!');
1469 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
);
1470 for s
in knownFiles
do
1472 if not g_PlayerModel_Load(s
) then e_LogWritefln('Error loading model "%s"', [s
], TMsgType
.Warning
);
1476 gPauseMain
:= false;
1477 gPauseHolmes
:= false;
1480 {e_MouseInfo.Accel := 1.0;}
1482 g_Game_SetLoadingText(_lc
[I_LOAD_GAME_DATA
], 0, False);
1485 g_Game_SetLoadingText(_lc
[I_LOAD_MUSIC
], 0, False);
1486 g_Sound_CreateWADEx('MUSIC_INTERMUS', GameWAD
+':MUSIC\INTERMUS', True);
1487 g_Sound_CreateWADEx('MUSIC_MENU', GameWAD
+':MUSIC\MENU', True);
1488 g_Sound_CreateWADEx('MUSIC_ROUNDMUS', GameWAD
+':MUSIC\ROUNDMUS', True, True);
1489 g_Sound_CreateWADEx('MUSIC_STDENDMUS', GameWAD
+':MUSIC\ENDMUS', True);
1492 g_Game_SetLoadingText(_lc
[I_LOAD_MENUS
], 0, False);
1496 gMusic
:= TMusic
.Create();
1497 gMusic
.SetByName('MUSIC_MENU');
1500 gGameSettings
.WarmupTime
:= 30;
1502 gState
:= STATE_MENU
;
1504 SetLength(gEvents
, 6);
1505 gEvents
[0].Name
:= 'ongamestart';
1506 gEvents
[1].Name
:= 'ongameend';
1507 gEvents
[2].Name
:= 'onmapstart';
1508 gEvents
[3].Name
:= 'onmapend';
1509 gEvents
[4].Name
:= 'oninter';
1510 gEvents
[5].Name
:= 'onwadend';
1512 sfsGCEnable(); // enable releasing unused volumes
1516 procedure g_Game_Free(freeTextures
: Boolean=true);
1518 if NetMode
= NET_CLIENT
then g_Net_Disconnect();
1519 if NetMode
= NET_SERVER
then g_Net_Host_Die();
1521 g_Map_Free(freeTextures
);
1523 g_Player_RemoveAllCorpses();
1525 gGameSettings
.GameType
:= GT_NONE
;
1526 if gGameSettings
.GameMode
= GM_SINGLE
then
1527 gGameSettings
.GameMode
:= GM_DM
;
1528 gSwitchGameMode
:= gGameSettings
.GameMode
;
1531 gExitByTrigger
:= False;
1534 function IsActivePlayer(p
: TPlayer
): Boolean;
1539 Result
:= (not p
.FDummy
) and (not p
.FSpectator
);
1542 function GetActivePlayer_ByID(ID
: Integer): TPlayer
;
1549 if gPlayers
= nil then
1551 for a
:= Low(gPlayers
) to High(gPlayers
) do
1552 if IsActivePlayer(gPlayers
[a
]) then
1554 if gPlayers
[a
].UID
<> ID
then
1556 Result
:= gPlayers
[a
];
1561 function GetActivePlayerID_Next(Skip
: Integer = -1): Integer;
1567 if gPlayers
= nil then
1571 for a
:= Low(gPlayers
) to High(gPlayers
) do
1572 if IsActivePlayer(gPlayers
[a
]) then
1574 SetLength(ids
, Length(ids
) + 1);
1575 ids
[High(ids
)] := gPlayers
[a
].UID
;
1576 if gPlayers
[a
].UID
= Skip
then
1579 if Length(ids
) = 0 then
1584 Result
:= ids
[(idx
+ 1) mod Length(ids
)];
1587 function GetActivePlayerID_Prev(Skip
: Integer = -1): Integer;
1593 if gPlayers
= nil then
1597 for a
:= Low(gPlayers
) to High(gPlayers
) do
1598 if IsActivePlayer(gPlayers
[a
]) then
1600 SetLength(ids
, Length(ids
) + 1);
1601 ids
[High(ids
)] := gPlayers
[a
].UID
;
1602 if gPlayers
[a
].UID
= Skip
then
1605 if Length(ids
) = 0 then
1608 Result
:= ids
[Length(ids
) - 1]
1610 Result
:= ids
[(Length(ids
) - 1 + idx
) mod Length(ids
)];
1613 function GetActivePlayerID_Random(Skip
: Integer = -1): Integer;
1619 if gPlayers
= nil then
1623 for a
:= Low(gPlayers
) to High(gPlayers
) do
1624 if IsActivePlayer(gPlayers
[a
]) then
1626 SetLength(ids
, Length(ids
) + 1);
1627 ids
[High(ids
)] := gPlayers
[a
].UID
;
1628 if gPlayers
[a
].UID
= Skip
then
1631 if Length(ids
) = 0 then
1633 if Length(ids
) = 1 then
1638 Result
:= ids
[Random(Length(ids
))];
1640 while (idx
<> -1) and (Result
= Skip
) and (a
> 0) do
1642 Result
:= ids
[Random(Length(ids
))];
1647 function GetRandomSpectMode(Current
: Byte): Byte;
1654 0: Result
:= SPECT_STATS
;
1655 1: Result
:= SPECT_MAPVIEW
;
1656 2: Result
:= SPECT_MAPVIEW
;
1657 3: Result
:= SPECT_PLAYERS
;
1658 4: Result
:= SPECT_PLAYERS
;
1659 5: Result
:= SPECT_PLAYERS
;
1660 6: Result
:= SPECT_PLAYERS
;
1662 if (Current
in [SPECT_STATS
, SPECT_MAPVIEW
]) and (Current
= Result
) then
1666 procedure ProcessPlayerControls (plr
: TPlayer
; p
: Integer; var MoveButton
: Byte);
1672 if (plr
= nil) then exit
;
1673 if (p
= 2) then time
:= 1000 else time
:= 1;
1674 strafeDir
:= MoveButton
shr 4;
1675 MoveButton
:= MoveButton
and $0F;
1677 if gPlayerAction
[p
, ACTION_MOVELEFT
] and (not gPlayerAction
[p
, ACTION_MOVERIGHT
]) then
1678 MoveButton
:= 1 // Íàæàòà òîëüêî "Âëåâî"
1679 else if (not gPlayerAction
[p
, ACTION_MOVELEFT
]) and gPlayerAction
[p
, ACTION_MOVERIGHT
] then
1680 MoveButton
:= 2 // Íàæàòà òîëüêî "Âïðàâî"
1681 else if (not gPlayerAction
[p
, ACTION_MOVELEFT
]) and (not gPlayerAction
[p
, ACTION_MOVERIGHT
]) then
1682 MoveButton
:= 0; // Íå íàæàòû íè "Âëåâî", íè "Âïðàâî"
1684 // Ñåé÷àñ èëè ðàíüøå áûëè íàæàòû "Âëåâî"/"Âïðàâî" => ïåðåäàåì èãðîêó:
1685 if MoveButton
= 1 then
1686 plr
.PressKey(KEY_LEFT
, time
)
1687 else if MoveButton
= 2 then
1688 plr
.PressKey(KEY_RIGHT
, time
);
1690 // if we have "strafe" key, turn off old strafe mechanics
1691 if gPlayerAction
[p
, ACTION_STRAFE
] then
1693 // new strafe mechanics
1694 if (strafeDir
= 0) then
1695 strafeDir
:= MoveButton
; // start strafing
1696 // now set direction according to strafe (reversed)
1697 if (strafeDir
= 2) then
1698 plr
.SetDirection(TDirection
.D_LEFT
)
1699 else if (strafeDir
= 1) then
1700 plr
.SetDirection(TDirection
.D_RIGHT
)
1704 strafeDir
:= 0; // not strafing anymore
1705 // Ðàíüøå áûëà íàæàòà "Âïðàâî", à ñåé÷àñ "Âëåâî" => áåæèì âïðàâî, ñìîòðèì âëåâî:
1706 if (MoveButton
= 2) and gPlayerAction
[p
, ACTION_MOVELEFT
] then
1707 plr
.SetDirection(TDirection
.D_LEFT
)
1708 // Ðàíüøå áûëà íàæàòà "Âëåâî", à ñåé÷àñ "Âïðàâî" => áåæèì âëåâî, ñìîòðèì âïðàâî:
1709 else if (MoveButton
= 1) and gPlayerAction
[p
, ACTION_MOVERIGHT
] then
1710 plr
.SetDirection(TDirection
.D_RIGHT
)
1711 // ×òî-òî áûëî íàæàòî è íå èçìåíèëîñü => êóäà áåæèì, òóäà è ñìîòðèì:
1712 else if MoveButton
<> 0 then
1713 plr
.SetDirection(TDirection(MoveButton
-1))
1716 // fix movebutton state
1717 MoveButton
:= MoveButton
or (strafeDir
shl 4);
1719 // Îñòàëüíûå êëàâèøè:
1720 if gPlayerAction
[p
, ACTION_JUMP
] then plr
.PressKey(KEY_JUMP
, time
);
1721 if gPlayerAction
[p
, ACTION_LOOKUP
] then plr
.PressKey(KEY_UP
, time
);
1722 if gPlayerAction
[p
, ACTION_LOOKDOWN
] then plr
.PressKey(KEY_DOWN
, time
);
1723 if gPlayerAction
[p
, ACTION_ATTACK
] then plr
.PressKey(KEY_FIRE
);
1724 if gPlayerAction
[p
, ACTION_ACTIVATE
] then plr
.PressKey(KEY_OPEN
);
1726 for i
:= WP_FACT
to WP_LACT
do
1728 if gWeaponAction
[p
, i
] then
1730 plr
.ProcessWeaponAction(i
);
1731 gWeaponAction
[p
, i
] := False
1735 for i
:= WP_FIRST
to WP_LAST
do
1737 if gSelectWeapon
[p
, i
] then
1739 plr
.QueueWeaponSwitch(i
); // all choices are passed there, and god will take the best
1740 gSelectWeapon
[p
, i
] := False
1744 // HACK: add dynlight here
1745 if gwin_k8_enable_light_experiments
then
1747 if e_KeyPressed(IK_F8
) and gGameOn
and (not gConsoleShow
) and (g_ActiveWindow
= nil) then
1749 g_playerLight
:= true;
1751 if e_KeyPressed(IK_F9
) and gGameOn
and (not gConsoleShow
) and (g_ActiveWindow
= nil) then
1753 g_playerLight
:= false;
1757 if gwin_has_stencil
and g_playerLight
then g_AddDynLight(plr
.GameX
+32, plr
.GameY
+40, 128, 1, 1, 0, 0.6);
1760 // HACK: don't have a "key was pressed" function
1761 procedure InterReady();
1763 if InterReadyTime
> gTime
then Exit
;
1764 InterReadyTime
:= gTime
+ 3000;
1765 MC_SEND_CheatRequest(NET_CHEAT_READY
);
1768 procedure g_Game_PreUpdate();
1770 // these are in separate PreUpdate functions because they can interact during Update()
1771 // and are synced over the net
1772 // we don't care that much about corpses and gibs
1773 g_Player_PreUpdate();
1774 g_Monsters_PreUpdate();
1775 g_Items_PreUpdate();
1776 g_Weapon_PreUpdate();
1779 procedure g_Game_Update();
1781 Msg
: g_gui
.TMessage
;
1787 function sendMonsPos (mon
: TMonster
): Boolean;
1789 result
:= false; // don't stop
1790 // this will also reset "need-send" flag
1791 if mon
.gncNeedSend
then
1793 MH_SEND_MonsterPos(mon
.UID
);
1795 else if (mon
.MonsterType
= MONSTER_BARREL
) then
1797 if (mon
.GameVelX
<> 0) or (mon
.GameVelY
<> 0) then MH_SEND_MonsterPos(mon
.UID
);
1799 else if (mon
.MonsterState
<> MONSTATE_SLEEP
) then
1801 if (mon
.MonsterState
<> MONSTATE_DEAD
) or (mon
.GameVelX
<> 0) or (mon
.GameVelY
<> 0) then MH_SEND_MonsterPos(mon
.UID
);
1805 function sendMonsPosUnexpected (mon
: TMonster
): Boolean;
1807 result
:= false; // don't stop
1808 // this will also reset "need-send" flag
1809 if mon
.gncNeedSend
then MH_SEND_MonsterPos(mon
.UID
);
1812 function sendItemPos (it
: PItem
): Boolean;
1814 result
:= false; // don't stop
1817 MH_SEND_ItemPos(it
.myId
);
1818 it
.needSend
:= False;
1823 reliableUpdate
: Boolean;
1828 // Ïîðà âûêëþ÷àòü èãðó:
1829 if gExit
= EXIT_QUIT
then
1831 // Èãðà çàêîí÷èëàñü - îáðàáàòûâàåì:
1835 if gExit
= EXIT_QUIT
then
1839 // ×èòàåì êëàâèàòóðó è äæîéñòèê, åñëè îêíî àêòèâíî
1840 // no need to, as we'll do it in event handler
1842 // Îáíîâëÿåì êîíñîëü (äâèæåíèå è ñîîáùåíèÿ):
1845 if (NetMode
= NET_NONE
) and (g_Game_IsNet
) and (gGameOn
or (gState
in [STATE_FOLD
, STATE_INTERCUSTOM
])) then
1847 gExit
:= EXIT_SIMPLE
;
1852 // process master server communications
1853 g_Net_Slist_Pulse();
1856 STATE_INTERSINGLE
, // Ñòàòèñòêà ïîñëå ïðîõîæäåíèÿ óðîâíÿ â Îäèíî÷íîé èãðå
1857 STATE_INTERCUSTOM
, // Ñòàòèñòêà ïîñëå ïðîõîæäåíèÿ óðîâíÿ â Ñâîåé èãðå
1858 STATE_INTERTEXT
, // Òåêñò ìåæäó óðîâíÿìè
1859 STATE_INTERPIC
: // Êàðòèíêà ìåæäó óðîâíÿìè
1861 if g_Game_IsNet
and g_Game_IsServer
then
1863 gInterTime
:= gInterTime
+ GAME_TICK
;
1864 a
:= Min((gInterEndTime
- gInterTime
) div 1000 + 1, 255);
1865 if a
<> gServInterTime
then
1867 gServInterTime
:= a
;
1868 MH_SEND_TimeSync(gServInterTime
);
1872 if (not g_Game_IsClient
) and
1876 e_KeyPressed(IK_RETURN
) or e_KeyPressed(IK_KPRETURN
) or e_KeyPressed(IK_SPACE
) or
1877 e_KeyPressed(VK_FIRE
) or e_KeyPressed(VK_OPEN
) or
1878 e_KeyPressed(JOY0_ATTACK
) or e_KeyPressed(JOY1_ATTACK
) or
1879 e_KeyPressed(JOY2_ATTACK
) or e_KeyPressed(JOY3_ATTACK
)
1881 and (not gJustChatted
) and (not gConsoleShow
) and (not gChatShow
)
1882 and (g_ActiveWindow
= nil)
1884 or (g_Game_IsNet
and ((gInterTime
> gInterEndTime
) or ((gInterReadyCount
>= NetClientCount
) and (NetClientCount
> 0))))
1887 begin // Íàæàëè <Enter>/<Ïðîáåë> èëè ïðîøëî äîñòàòî÷íî âðåìåíè:
1888 g_Game_StopAllSounds(True);
1890 if gMapOnce
then // Ýòî áûë òåñò
1891 gExit
:= EXIT_SIMPLE
1893 if gNextMap
<> '' then // Ïåðåõîäèì íà ñëåäóþùóþ êàðòó
1894 g_Game_ChangeMap(gNextMap
)
1895 else // Ñëåäóþùåé êàðòû íåò
1897 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
] then
1899 // Âûõîä â ãëàâíîå ìåíþ:
1901 g_GUI_ShowWindow('MainMenu');
1902 gMusic
.SetByName('MUSIC_MENU');
1904 gState
:= STATE_MENU
;
1907 // Ôèíàëüíàÿ êàðòèíêà:
1908 g_Game_ExecuteEvent('onwadend');
1910 if not gMusic
.SetByName('MUSIC_endmus') then
1911 gMusic
.SetByName('MUSIC_STDENDMUS');
1913 gState
:= STATE_ENDPIC
;
1915 g_Game_ExecuteEvent('ongameend');
1920 else if g_Game_IsClient
and
1923 e_KeyPressed(IK_RETURN
) or e_KeyPressed(IK_KPRETURN
) or e_KeyPressed(IK_SPACE
) or
1924 e_KeyPressed(VK_FIRE
) or e_KeyPressed(VK_OPEN
) or
1925 e_KeyPressed(JOY0_ATTACK
) or e_KeyPressed(JOY1_ATTACK
) or
1926 e_KeyPressed(JOY2_ATTACK
) or e_KeyPressed(JOY3_ATTACK
)
1928 and (not gJustChatted
) and (not gConsoleShow
) and (not gChatShow
)
1929 and (g_ActiveWindow
= nil)
1937 if gState
= STATE_INTERTEXT
then
1938 if InterText
.counter
> 0 then
1939 InterText
.counter
:= InterText
.counter
- 1;
1942 STATE_FOLD
: // Çàòóõàíèå ýêðàíà
1944 if EndingGameCounter
= 0 then
1946 // Çàêîí÷èëñÿ óðîâåíü â Ñâîåé èãðå:
1947 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
1949 gState
:= STATE_INTERCUSTOM
;
1950 InterReadyTime
:= -1;
1951 if gLastMap
and (gGameSettings
.GameMode
= GM_COOP
) then
1953 g_Game_ExecuteEvent('onwadend');
1954 if not gMusic
.SetByName('MUSIC_endmus') then
1955 gMusic
.SetByName('MUSIC_STDENDMUS');
1958 gMusic
.SetByName('MUSIC_ROUNDMUS');
1962 else // Çàêîí÷èëàñü ïîñëåäíÿÿ êàðòà â Îäèíî÷íîé èãðå
1964 gMusic
.SetByName('MUSIC_INTERMUS');
1966 gState
:= STATE_INTERSINGLE
;
1969 g_Game_ExecuteEvent('oninter');
1972 DecMin(EndingGameCounter
, 6, 0);
1975 STATE_ENDPIC
: // Êàðòèíêà îêîí÷àíèÿ ìåãàÂàäà
1977 if gMapOnce
then // Ýòî áûë òåñò
1979 gExit
:= EXIT_SIMPLE
;
1985 g_Serverlist_Control(slCurrent
, slTable
);
1988 // Ñòàòèñòèêà ïî Tab:
1990 IsDrawStat
:= (not gConsoleShow
) and (not gChatShow
) and (gGameSettings
.GameType
<> GT_SINGLE
) and g_Console_Action(ACTION_SCORES
);
1993 if gGameOn
and not gPause
and (gState
<> STATE_FOLD
) then
1995 // Âðåìÿ += 28 ìèëëèñåêóíä:
1996 gTime
:= gTime
+ GAME_TICK
;
1998 // Ñîîáùåíèå ïîñåðåäèíå ýêðàíà:
1999 if MessageTime
= 0 then
2001 if MessageTime
> 0 then
2002 MessageTime
:= MessageTime
- 1;
2004 if (g_Game_IsServer
) then
2006 // Áûë çàäàí ëèìèò âðåìåíè:
2007 if (gGameSettings
.TimeLimit
> 0) then
2008 if (gTime
- gGameStartTime
) div 1000 >= gGameSettings
.TimeLimit
then
2009 begin // Îí ïðîøåë => êîíåö óðîâíÿ
2014 // Íàäî ðåñïàâíèòü èãðîêîâ â LMS:
2015 if (gLMSRespawn
> LMS_RESPAWN_NONE
) and (gLMSRespawnTime
< gTime
) then
2016 g_Game_RestartRound(gLMSSoftSpawn
);
2018 // Ïðîâåðèì ðåçóëüòàò ãîëîñîâàíèÿ, åñëè âðåìÿ ïðîøëî
2019 if gVoteInProgress
and (gVoteTimer
< gTime
) then
2021 else if gVotePassed
and (gVoteCmdTimer
< gTime
) then
2023 g_Console_Process(gVoteCommand
);
2025 gVotePassed
:= False;
2028 // Çàìåðÿåì âðåìÿ çàõâàòà ôëàãîâ
2029 if gFlags
[FLAG_RED
].State
= FLAG_STATE_CAPTURED
then
2030 gFlags
[FLAG_RED
].CaptureTime
:= gFlags
[FLAG_RED
].CaptureTime
+ GAME_TICK
;
2031 if gFlags
[FLAG_BLUE
].State
= FLAG_STATE_CAPTURED
then
2032 gFlags
[FLAG_BLUE
].CaptureTime
:= gFlags
[FLAG_BLUE
].CaptureTime
+ GAME_TICK
;
2034 // Áûë çàäàí ëèìèò ïîáåä:
2035 if (gGameSettings
.ScoreLimit
> 0) then
2039 if gGameSettings
.GameMode
= GM_DM
then
2040 begin // Â DM èùåì èãðîêà ñ max ôðàãàìè
2041 for i
:= 0 to High(gPlayers
) do
2042 if gPlayers
[i
] <> nil then
2043 if gPlayers
[i
].Frags
> b
then
2044 b
:= gPlayers
[i
].Frags
;
2047 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
2048 begin //  CTF/TDM âûáèðàåì êîìàíäó ñ íàèáîëüøèì ñ÷åòîì
2049 b
:= Max(gTeamStat
[TEAM_RED
].Score
, gTeamStat
[TEAM_BLUE
].Score
);
2052 // Ëèìèò ïîáåä íàáðàí => êîíåö óðîâíÿ:
2053 if b
>= gGameSettings
.ScoreLimit
then
2060 // Îáðàáàòûâàåì êëàâèøè èãðîêîâ:
2061 if gPlayer1
<> nil then gPlayer1
.ReleaseKeys();
2062 if gPlayer2
<> nil then gPlayer2
.ReleaseKeys();
2063 if (not gConsoleShow
) and (not gChatShow
) and (g_ActiveWindow
= nil) then
2065 ProcessPlayerControls(gPlayer1
, 0, P1MoveButton
);
2066 ProcessPlayerControls(gPlayer2
, 1, P2MoveButton
);
2067 end // if not console
2070 if g_Game_IsNet
and (gPlayer1
<> nil) then gPlayer1
.PressKey(KEY_CHAT
, 10000);
2072 // process weapon switch queue
2076 if (gPlayer1
= nil) and (gPlayer2
= nil) and
2077 (not gConsoleShow
) and (not gChatShow
) and (g_ActiveWindow
= nil) then
2079 if not gSpectKeyPress
then
2081 if gPlayerAction
[0, ACTION_JUMP
] and (not gSpectAuto
) then
2083 // switch spect mode
2085 SPECT_NONE
: ; // not spectator
2087 SPECT_MAPVIEW
: Inc(gSpectMode
);
2088 SPECT_PLAYERS
: gSpectMode
:= SPECT_STATS
; // reset to 1
2090 gSpectKeyPress
:= True;
2092 if (gSpectMode
= SPECT_MAPVIEW
)
2093 and (not gSpectAuto
) then
2095 if gPlayerAction
[0, ACTION_MOVELEFT
] then
2096 gSpectX
:= Max(gSpectX
- gSpectStep
, 0);
2097 if gPlayerAction
[0, ACTION_MOVERIGHT
] then
2098 gSpectX
:= Min(gSpectX
+ gSpectStep
, gMapInfo
.Width
- gScreenWidth
);
2099 if gPlayerAction
[0, ACTION_LOOKUP
] then
2100 gSpectY
:= Max(gSpectY
- gSpectStep
, 0);
2101 if gPlayerAction
[0, ACTION_LOOKDOWN
] then
2102 gSpectY
:= Min(gSpectY
+ gSpectStep
, gMapInfo
.Height
- gScreenHeight
);
2103 if gWeaponAction
[0, WP_PREV
] then
2106 if gSpectStep
> 4 then gSpectStep
:= gSpectStep
shr 1;
2107 gWeaponAction
[0, WP_PREV
] := False;
2109 if gWeaponAction
[0, WP_NEXT
] then
2112 if gSpectStep
< 64 then gSpectStep
:= gSpectStep
shl 1;
2113 gWeaponAction
[0, WP_NEXT
] := False;
2116 if (gSpectMode
= SPECT_PLAYERS
)
2117 and (not gSpectAuto
) then
2119 if gPlayerAction
[0, ACTION_LOOKUP
] then
2122 gSpectViewTwo
:= True;
2123 gSpectKeyPress
:= True;
2125 if gPlayerAction
[0, ACTION_LOOKDOWN
] then
2127 // remove second view
2128 gSpectViewTwo
:= False;
2129 gSpectKeyPress
:= True;
2131 if gPlayerAction
[0, ACTION_MOVELEFT
] then
2133 // prev player (view 1)
2134 gSpectPID1
:= GetActivePlayerID_Prev(gSpectPID1
);
2135 gSpectKeyPress
:= True;
2137 if gPlayerAction
[0, ACTION_MOVERIGHT
] then
2139 // next player (view 1)
2140 gSpectPID1
:= GetActivePlayerID_Next(gSpectPID1
);
2141 gSpectKeyPress
:= True;
2143 if gWeaponAction
[0, WP_PREV
] then
2145 // prev player (view 2)
2146 gSpectPID2
:= GetActivePlayerID_Prev(gSpectPID2
);
2147 gWeaponAction
[0, WP_PREV
] := False;
2149 if gWeaponAction
[0, WP_NEXT
] then
2151 // next player (view 2)
2152 gSpectPID2
:= GetActivePlayerID_Next(gSpectPID2
);
2153 gWeaponAction
[0, WP_NEXT
] := False;
2156 if gPlayerAction
[0, ACTION_ATTACK
] then
2158 if (gSpectMode
= SPECT_STATS
) and (not gSpectAuto
) then
2161 gSpectAutoNext
:= 0;
2162 gSpectViewTwo
:= False;
2163 gSpectKeyPress
:= True;
2168 gSpectMode
:= SPECT_STATS
;
2169 gSpectAuto
:= False;
2170 gSpectKeyPress
:= True;
2175 if (not gPlayerAction
[0, ACTION_JUMP
]) and
2176 (not gPlayerAction
[0, ACTION_ATTACK
]) and
2177 (not gPlayerAction
[0, ACTION_MOVELEFT
]) and
2178 (not gPlayerAction
[0, ACTION_MOVERIGHT
]) and
2179 (not gPlayerAction
[0, ACTION_LOOKUP
]) and
2180 (not gPlayerAction
[0, ACTION_LOOKDOWN
]) then
2181 gSpectKeyPress
:= False;
2185 if gSpectMode
= SPECT_MAPVIEW
then
2187 i
:= Min(Max(gSpectX
+ gSpectAutoStepX
, 0), gMapInfo
.Width
- gScreenWidth
);
2189 gSpectAutoNext
:= gTime
2192 i
:= Min(Max(gSpectY
+ gSpectAutoStepY
, 0), gMapInfo
.Height
- gScreenHeight
);
2194 gSpectAutoNext
:= gTime
2198 if gSpectAutoNext
<= gTime
then
2200 if gSpectAutoNext
> 0 then
2202 gSpectMode
:= GetRandomSpectMode(gSpectMode
);
2206 gSpectX
:= Random(gMapInfo
.Width
- gScreenWidth
);
2207 gSpectY
:= Random(gMapInfo
.Height
- gScreenHeight
);
2208 gSpectAutoStepX
:= Random(9) - 4;
2209 gSpectAutoStepY
:= Random(9) - 4;
2210 if ((gSpectX
< 800) and (gSpectAutoStepX
< 0)) or
2211 ((gSpectX
> gMapInfo
.Width
- gScreenWidth
- 800) and (gSpectAutoStepX
> 0)) then
2212 gSpectAutoStepX
:= gSpectAutoStepX
* -1;
2213 if ((gSpectY
< 800) and (gSpectAutoStepY
< 0)) or
2214 ((gSpectY
> gMapInfo
.Height
- gScreenHeight
- 800) and (gSpectAutoStepY
> 0)) then
2215 gSpectAutoStepY
:= gSpectAutoStepY
* -1;
2219 gSpectPID1
:= GetActivePlayerID_Random(gSpectPID1
);
2224 SPECT_STATS
: gSpectAutoNext
:= gTime
+ (Random(3) + 5) * 1000;
2225 SPECT_MAPVIEW
: gSpectAutoNext
:= gTime
+ (Random(4) + 7) * 1000;
2226 SPECT_PLAYERS
: gSpectAutoNext
:= gTime
+ (Random(7) + 8) * 1000;
2232 // Îáíîâëÿåì âñå îñòàëüíîå:
2235 g_Triggers_Update();
2237 g_Monsters_Update();
2239 g_Player_UpdateAll();
2240 g_Player_UpdatePhysicalObjects();
2242 // server: send newly spawned monsters unconditionally
2243 if (gGameSettings
.GameType
= GT_SERVER
) then
2245 if (Length(gMonstersSpawned
) > 0) then
2247 for I
:= 0 to High(gMonstersSpawned
) do MH_SEND_MonsterSpawn(gMonstersSpawned
[I
]);
2248 SetLength(gMonstersSpawned
, 0);
2252 if (gSoundTriggerTime
> 8) then
2254 g_Game_UpdateTriggerSounds();
2255 gSoundTriggerTime
:= 0;
2259 Inc(gSoundTriggerTime
);
2262 if (NetMode
= NET_SERVER
) then
2264 Inc(NetTimeToUpdate
);
2265 Inc(NetTimeToReliable
);
2267 // send monster updates
2268 if (NetTimeToReliable
>= NetRelupdRate
) or (NetTimeToUpdate
>= NetUpdateRate
) then
2270 // send all monsters (periodic sync)
2271 reliableUpdate
:= (NetTimeToReliable
>= NetRelupdRate
);
2273 for I
:= 0 to High(gPlayers
) do
2275 if (gPlayers
[I
] <> nil) then MH_SEND_PlayerPos(reliableUpdate
, gPlayers
[I
].UID
);
2278 g_Mons_ForEach(sendMonsPos
);
2280 // update flags that aren't stationary
2281 if gGameSettings
.GameMode
= GM_CTF
then
2282 for I
:= FLAG_RED
to FLAG_BLUE
do
2283 if gFlags
[I
].NeedSend
then
2285 gFlags
[I
].NeedSend
:= False;
2289 // update items that aren't stationary
2290 g_Items_ForEachAlive(sendItemPos
);
2292 if reliableUpdate
then
2294 NetTimeToReliable
:= 0;
2295 NetTimeToUpdate
:= NetUpdateRate
;
2299 NetTimeToUpdate
:= 0;
2304 // send only mosters with some unexpected changes
2305 g_Mons_ForEach(sendMonsPosUnexpected
);
2308 // send unexpected platform changes
2309 g_Map_NetSendInterestingPanels();
2311 g_Net_Slist_ServerUpdate();
2313 if NetUseMaster then
2315 if (gTime >= NetTimeToMaster) or g_Net_Slist_IsConnectionInProgress then
2317 if (not g_Net_Slist_IsConnectionActive) then g_Net_Slist_Connect(false); // non-blocking connection to the master
2319 NetTimeToMaster := gTime + NetMasterRate;
2324 else if (NetMode
= NET_CLIENT
) then
2326 MC_SEND_PlayerPos();
2328 end; // if gameOn ...
2330 // Àêòèâíî îêíî èíòåðôåéñà - ïåðåäàåì êëàâèøè åìó:
2331 if g_ActiveWindow
<> nil then
2333 w
:= e_GetFirstKeyPressed();
2335 if (w
<> IK_INVALID
) then
2337 Msg
.Msg
:= MESSAGE_DIKEY
;
2339 g_ActiveWindow
.OnMessage(Msg
);
2342 // Åñëè îíî îò ýòîãî íå çàêðûëîñü, òî îáíîâëÿåì:
2343 if g_ActiveWindow
<> nil then
2344 g_ActiveWindow
.Update();
2346 // Íóæíî ñìåíèòü ðàçðåøåíèå:
2347 if gResolutionChange
then
2349 e_WriteLog('Changing resolution', TMsgType
.Notify
);
2350 g_Game_ChangeResolution(gRC_Width
, gRC_Height
, gRC_FullScreen
, gRC_Maximized
);
2351 gResolutionChange
:= False;
2352 g_ActiveWindow
:= nil;
2355 // Íóæíî ñìåíèòü ÿçûê:
2356 if gLanguageChange
then
2358 //e_WriteLog('Read language file', MSG_NOTIFY);
2359 //g_Language_Load(DataDir + gLanguage + '.txt');
2360 g_Language_Set(gLanguage
);
2364 gLanguageChange
:= False;
2368 // Ãîðÿ÷àÿ êëàâèøà äëÿ âûçîâà ìåíþ âûõîäà èç èãðû (F10):
2369 if e_KeyPressed(IK_F10
) and
2371 (not gConsoleShow
) and
2372 (g_ActiveWindow
= nil) then
2377 Time
:= sys_GetTicks() {div 1000};
2379 // Îáðàáîòêà îòëîæåííûõ ñîáûòèé:
2380 if gDelayedEvents
<> nil then
2381 for a
:= 0 to High(gDelayedEvents
) do
2382 if gDelayedEvents
[a
].Pending
and
2384 ((gDelayedEvents
[a
].DEType
= DE_GLOBEVENT
) and (gDelayedEvents
[a
].Time
<= Time
)) or
2385 ((gDelayedEvents
[a
].DEType
> DE_GLOBEVENT
) and (gDelayedEvents
[a
].Time
<= gTime
))
2388 case gDelayedEvents
[a
].DEType
of
2390 g_Game_ExecuteEvent(gDelayedEvents
[a
].DEStr
);
2393 g_Game_Announce_GoodShot(gDelayedEvents
[a
].DENum
);
2397 g_Game_Announce_KillCombo(gDelayedEvents
[a
].DENum
);
2398 if g_Game_IsNet
and g_Game_IsServer
then
2399 MH_SEND_GameEvent(NET_EV_KILLCOMBO
, gDelayedEvents
[a
].DENum
);
2403 g_Game_Announce_BodyKill(gDelayedEvents
[a
].DENum
);
2405 gDelayedEvents
[a
].Pending
:= False;
2408 // Êàæäóþ ñåêóíäó îáíîâëÿåì ñ÷åò÷èê îáíîâëåíèé:
2409 UPSCounter
:= UPSCounter
+ 1;
2410 if Time
- UPSTime
>= 1000 then
2419 g_Weapon_AddDynLights();
2420 g_Items_AddDynLights();
2424 procedure g_Game_LoadChatSounds(Resource
: string);
2427 FileName
, Snd
: string;
2429 len
, cnt
, tags
, i
, j
: Integer;
2432 FileName
:= g_ExtractWadName(Resource
);
2434 WAD
:= TWADFile
.Create();
2435 WAD
.ReadFile(FileName
);
2437 if not WAD
.GetResource(g_ExtractFilePathName(Resource
), p
, len
) then
2444 cfg
:= TConfig
.CreateMem(p
, len
);
2445 cnt
:= cfg
.ReadInt('ChatSounds', 'Count', 0);
2447 SetLength(gChatSounds
, cnt
);
2448 for i
:= 0 to Length(gChatSounds
) - 1 do
2450 gChatSounds
[i
].Sound
:= nil;
2451 Snd
:= Trim(cfg
.ReadStr(IntToStr(i
), 'Sound', ''));
2452 tags
:= cfg
.ReadInt(IntToStr(i
), 'Tags', 0);
2453 if (Snd
= '') or (Tags
<= 0) then
2455 g_Sound_CreateWADEx('SOUND_CHAT_MACRO' + IntToStr(i
), GameWAD
+':'+Snd
);
2456 gChatSounds
[i
].Sound
:= TPlayableSound
.Create();
2457 gChatSounds
[i
].Sound
.SetByName('SOUND_CHAT_MACRO' + IntToStr(i
));
2458 SetLength(gChatSounds
[i
].Tags
, tags
);
2459 for j
:= 0 to tags
- 1 do
2460 gChatSounds
[i
].Tags
[j
] := toLowerCase1251(cfg
.ReadStr(IntToStr(i
), 'Tag' + IntToStr(j
), ''));
2461 gChatSounds
[i
].FullWord
:= cfg
.ReadBool(IntToStr(i
), 'FullWord', False);
2468 procedure g_Game_FreeChatSounds();
2472 for i
:= 0 to Length(gChatSounds
) - 1 do
2474 gChatSounds
[i
].Sound
.Free();
2475 g_Sound_Delete('SOUND_CHAT_MACRO' + IntToStr(i
));
2477 SetLength(gChatSounds
, 0);
2481 procedure g_Game_LoadData();
2488 if DataLoaded
then Exit
;
2490 e_WriteLog('Loading game data...', TMsgType
.Notify
);
2492 g_Texture_CreateWADEx('NOTEXTURE', GameWAD
+':TEXTURES\NOTEXTURE');
2493 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUD', GameWAD
+':TEXTURES\HUD');
2494 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDAIR', GameWAD
+':TEXTURES\AIRBAR');
2495 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDJET', GameWAD
+':TEXTURES\JETBAR');
2496 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDBG', GameWAD
+':TEXTURES\HUDBG');
2497 g_Texture_CreateWADEx('TEXTURE_PLAYER_ARMORHUD', GameWAD
+':TEXTURES\ARMORHUD');
2498 g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG', GameWAD
+':TEXTURES\FLAGHUD_R_BASE');
2499 g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG_S', GameWAD
+':TEXTURES\FLAGHUD_R_STOLEN');
2500 g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG_D', GameWAD
+':TEXTURES\FLAGHUD_R_DROP');
2501 g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG', GameWAD
+':TEXTURES\FLAGHUD_B_BASE');
2502 g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG_S', GameWAD
+':TEXTURES\FLAGHUD_B_STOLEN');
2503 g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG_D', GameWAD
+':TEXTURES\FLAGHUD_B_DROP');
2504 g_Texture_CreateWADEx('TEXTURE_PLAYER_TALKBUBBLE', GameWAD
+':TEXTURES\TALKBUBBLE');
2505 g_Texture_CreateWADEx('TEXTURE_PLAYER_INVULPENTA', GameWAD
+':TEXTURES\PENTA');
2506 g_Texture_CreateWADEx('TEXTURE_PLAYER_INDICATOR', GameWAD
+':TEXTURES\PLRIND');
2509 if not g_Texture_CreateWADEx('UI_GFX_PBAR_LEFT', GameWAD
+':TEXTURES\LLEFT') then hasPBarGfx
:= false;
2510 if not g_Texture_CreateWADEx('UI_GFX_PBAR_MARKER', GameWAD
+':TEXTURES\LMARKER') then hasPBarGfx
:= false;
2511 if not g_Texture_CreateWADEx('UI_GFX_PBAR_MIDDLE', GameWAD
+':TEXTURES\LMIDDLE') then hasPBarGfx
:= false;
2512 if not g_Texture_CreateWADEx('UI_GFX_PBAR_RIGHT', GameWAD
+':TEXTURES\LRIGHT') then hasPBarGfx
:= false;
2516 g_Texture_GetSize('UI_GFX_PBAR_LEFT', wl
, hl
);
2517 g_Texture_GetSize('UI_GFX_PBAR_RIGHT', wr
, hr
);
2518 g_Texture_GetSize('UI_GFX_PBAR_MIDDLE', wb
, hb
);
2519 g_Texture_GetSize('UI_GFX_PBAR_MARKER', wm
, hm
);
2520 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
2526 hasPBarGfx
:= false;
2530 g_Frames_CreateWAD(nil, 'FRAMES_TELEPORT', GameWAD
+':TEXTURES\TELEPORT', 64, 64, 10, False);
2531 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH', GameWAD
+':WEAPONS\PUNCH', 64, 64, 4, False);
2532 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_UP', GameWAD
+':WEAPONS\PUNCH_UP', 64, 64, 4, False);
2533 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_DN', GameWAD
+':WEAPONS\PUNCH_DN', 64, 64, 4, False);
2534 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_BERSERK', GameWAD
+':WEAPONS\PUNCHB', 64, 64, 4, False);
2535 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_BERSERK_UP', GameWAD
+':WEAPONS\PUNCHB_UP', 64, 64, 4, False);
2536 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_BERSERK_DN', GameWAD
+':WEAPONS\PUNCHB_DN', 64, 64, 4, False);
2537 g_Sound_CreateWADEx('SOUND_GAME_TELEPORT', GameWAD
+':SOUNDS\TELEPORT');
2538 g_Sound_CreateWADEx('SOUND_GAME_NOTELEPORT', GameWAD
+':SOUNDS\NOTELEPORT');
2539 g_Sound_CreateWADEx('SOUND_GAME_SECRET', GameWAD
+':SOUNDS\SECRET');
2540 g_Sound_CreateWADEx('SOUND_GAME_DOOROPEN', GameWAD
+':SOUNDS\DOOROPEN');
2541 g_Sound_CreateWADEx('SOUND_GAME_DOORCLOSE', GameWAD
+':SOUNDS\DOORCLOSE');
2542 g_Sound_CreateWADEx('SOUND_GAME_BULK1', GameWAD
+':SOUNDS\BULK1');
2543 g_Sound_CreateWADEx('SOUND_GAME_BULK2', GameWAD
+':SOUNDS\BULK2');
2544 g_Sound_CreateWADEx('SOUND_GAME_BUBBLE1', GameWAD
+':SOUNDS\BUBBLE1');
2545 g_Sound_CreateWADEx('SOUND_GAME_BUBBLE2', GameWAD
+':SOUNDS\BUBBLE2');
2546 g_Sound_CreateWADEx('SOUND_GAME_BURNING', GameWAD
+':SOUNDS\BURNING');
2547 g_Sound_CreateWADEx('SOUND_GAME_SWITCH1', GameWAD
+':SOUNDS\SWITCH1');
2548 g_Sound_CreateWADEx('SOUND_GAME_SWITCH0', GameWAD
+':SOUNDS\SWITCH0');
2549 g_Sound_CreateWADEx('SOUND_GAME_RADIO', GameWAD
+':SOUNDS\RADIO');
2550 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD1', GameWAD
+':SOUNDS\GOOD1');
2551 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD2', GameWAD
+':SOUNDS\GOOD2');
2552 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD3', GameWAD
+':SOUNDS\GOOD3');
2553 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD4', GameWAD
+':SOUNDS\GOOD4');
2554 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL2X', GameWAD
+':SOUNDS\KILL2X');
2555 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL3X', GameWAD
+':SOUNDS\KILL3X');
2556 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL4X', GameWAD
+':SOUNDS\KILL4X');
2557 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILLMX', GameWAD
+':SOUNDS\KILLMX');
2558 g_Sound_CreateWADEx('SOUND_ANNOUNCER_MUHAHA1', GameWAD
+':SOUNDS\MUHAHA1');
2559 g_Sound_CreateWADEx('SOUND_ANNOUNCER_MUHAHA2', GameWAD
+':SOUNDS\MUHAHA2');
2560 g_Sound_CreateWADEx('SOUND_ANNOUNCER_MUHAHA3', GameWAD
+':SOUNDS\MUHAHA3');
2561 g_Sound_CreateWADEx('SOUND_CTF_GET1', GameWAD
+':SOUNDS\GETFLAG1');
2562 g_Sound_CreateWADEx('SOUND_CTF_GET2', GameWAD
+':SOUNDS\GETFLAG2');
2563 g_Sound_CreateWADEx('SOUND_CTF_LOST1', GameWAD
+':SOUNDS\LOSTFLG1');
2564 g_Sound_CreateWADEx('SOUND_CTF_LOST2', GameWAD
+':SOUNDS\LOSTFLG2');
2565 g_Sound_CreateWADEx('SOUND_CTF_RETURN1', GameWAD
+':SOUNDS\RETFLAG1');
2566 g_Sound_CreateWADEx('SOUND_CTF_RETURN2', GameWAD
+':SOUNDS\RETFLAG2');
2567 g_Sound_CreateWADEx('SOUND_CTF_CAPTURE1', GameWAD
+':SOUNDS\CAPFLAG1');
2568 g_Sound_CreateWADEx('SOUND_CTF_CAPTURE2', GameWAD
+':SOUNDS\CAPFLAG2');
2570 goodsnd
[0] := TPlayableSound
.Create();
2571 goodsnd
[1] := TPlayableSound
.Create();
2572 goodsnd
[2] := TPlayableSound
.Create();
2573 goodsnd
[3] := TPlayableSound
.Create();
2575 goodsnd
[0].SetByName('SOUND_ANNOUNCER_GOOD1');
2576 goodsnd
[1].SetByName('SOUND_ANNOUNCER_GOOD2');
2577 goodsnd
[2].SetByName('SOUND_ANNOUNCER_GOOD3');
2578 goodsnd
[3].SetByName('SOUND_ANNOUNCER_GOOD4');
2580 killsnd
[0] := TPlayableSound
.Create();
2581 killsnd
[1] := TPlayableSound
.Create();
2582 killsnd
[2] := TPlayableSound
.Create();
2583 killsnd
[3] := TPlayableSound
.Create();
2585 killsnd
[0].SetByName('SOUND_ANNOUNCER_KILL2X');
2586 killsnd
[1].SetByName('SOUND_ANNOUNCER_KILL3X');
2587 killsnd
[2].SetByName('SOUND_ANNOUNCER_KILL4X');
2588 killsnd
[3].SetByName('SOUND_ANNOUNCER_KILLMX');
2590 hahasnd
[0] := TPlayableSound
.Create();
2591 hahasnd
[1] := TPlayableSound
.Create();
2592 hahasnd
[2] := TPlayableSound
.Create();
2594 hahasnd
[0].SetByName('SOUND_ANNOUNCER_MUHAHA1');
2595 hahasnd
[1].SetByName('SOUND_ANNOUNCER_MUHAHA2');
2596 hahasnd
[2].SetByName('SOUND_ANNOUNCER_MUHAHA3');
2598 sound_get_flag
[0] := TPlayableSound
.Create();
2599 sound_get_flag
[1] := TPlayableSound
.Create();
2600 sound_lost_flag
[0] := TPlayableSound
.Create();
2601 sound_lost_flag
[1] := TPlayableSound
.Create();
2602 sound_ret_flag
[0] := TPlayableSound
.Create();
2603 sound_ret_flag
[1] := TPlayableSound
.Create();
2604 sound_cap_flag
[0] := TPlayableSound
.Create();
2605 sound_cap_flag
[1] := TPlayableSound
.Create();
2607 sound_get_flag
[0].SetByName('SOUND_CTF_GET1');
2608 sound_get_flag
[1].SetByName('SOUND_CTF_GET2');
2609 sound_lost_flag
[0].SetByName('SOUND_CTF_LOST1');
2610 sound_lost_flag
[1].SetByName('SOUND_CTF_LOST2');
2611 sound_ret_flag
[0].SetByName('SOUND_CTF_RETURN1');
2612 sound_ret_flag
[1].SetByName('SOUND_CTF_RETURN2');
2613 sound_cap_flag
[0].SetByName('SOUND_CTF_CAPTURE1');
2614 sound_cap_flag
[1].SetByName('SOUND_CTF_CAPTURE2');
2616 g_Game_LoadChatSounds(GameWAD
+':CHATSND\SNDCFG');
2618 g_Game_SetLoadingText(_lc
[I_LOAD_ITEMS_DATA
], 0, False);
2621 g_Game_SetLoadingText(_lc
[I_LOAD_WEAPONS_DATA
], 0, False);
2622 g_Weapon_LoadData();
2624 g_Monsters_LoadData();
2629 procedure g_Game_FreeData();
2631 if not DataLoaded
then Exit
;
2634 g_Weapon_FreeData();
2635 g_Monsters_FreeData();
2637 e_WriteLog('Releasing game data...', TMsgType
.Notify
);
2639 g_Texture_Delete('NOTEXTURE');
2640 g_Texture_Delete('TEXTURE_PLAYER_HUD');
2641 g_Texture_Delete('TEXTURE_PLAYER_HUDBG');
2642 g_Texture_Delete('TEXTURE_PLAYER_ARMORHUD');
2643 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG');
2644 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG_S');
2645 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG_D');
2646 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG');
2647 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG_S');
2648 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG_D');
2649 g_Texture_Delete('TEXTURE_PLAYER_TALKBUBBLE');
2650 g_Texture_Delete('TEXTURE_PLAYER_INVULPENTA');
2651 g_Frames_DeleteByName('FRAMES_TELEPORT');
2652 g_Frames_DeleteByName('FRAMES_PUNCH');
2653 g_Frames_DeleteByName('FRAMES_PUNCH_UP');
2654 g_Frames_DeleteByName('FRAMES_PUNCH_DN');
2655 g_Frames_DeleteByName('FRAMES_PUNCH_BERSERK');
2656 g_Frames_DeleteByName('FRAMES_PUNCH_BERSERK_UP');
2657 g_Frames_DeleteByName('FRAMES_PUNCH_BERSERK_DN');
2658 g_Sound_Delete('SOUND_GAME_TELEPORT');
2659 g_Sound_Delete('SOUND_GAME_NOTELEPORT');
2660 g_Sound_Delete('SOUND_GAME_SECRET');
2661 g_Sound_Delete('SOUND_GAME_DOOROPEN');
2662 g_Sound_Delete('SOUND_GAME_DOORCLOSE');
2663 g_Sound_Delete('SOUND_GAME_BULK1');
2664 g_Sound_Delete('SOUND_GAME_BULK2');
2665 g_Sound_Delete('SOUND_GAME_BUBBLE1');
2666 g_Sound_Delete('SOUND_GAME_BUBBLE2');
2667 g_Sound_Delete('SOUND_GAME_BURNING');
2668 g_Sound_Delete('SOUND_GAME_SWITCH1');
2669 g_Sound_Delete('SOUND_GAME_SWITCH0');
2676 g_Sound_Delete('SOUND_ANNOUNCER_GOOD1');
2677 g_Sound_Delete('SOUND_ANNOUNCER_GOOD2');
2678 g_Sound_Delete('SOUND_ANNOUNCER_GOOD3');
2679 g_Sound_Delete('SOUND_ANNOUNCER_GOOD4');
2686 g_Sound_Delete('SOUND_ANNOUNCER_KILL2X');
2687 g_Sound_Delete('SOUND_ANNOUNCER_KILL3X');
2688 g_Sound_Delete('SOUND_ANNOUNCER_KILL4X');
2689 g_Sound_Delete('SOUND_ANNOUNCER_KILLMX');
2695 g_Sound_Delete('SOUND_ANNOUNCER_MUHAHA1');
2696 g_Sound_Delete('SOUND_ANNOUNCER_MUHAHA2');
2697 g_Sound_Delete('SOUND_ANNOUNCER_MUHAHA3');
2699 sound_get_flag
[0].Free();
2700 sound_get_flag
[1].Free();
2701 sound_lost_flag
[0].Free();
2702 sound_lost_flag
[1].Free();
2703 sound_ret_flag
[0].Free();
2704 sound_ret_flag
[1].Free();
2705 sound_cap_flag
[0].Free();
2706 sound_cap_flag
[1].Free();
2708 g_Sound_Delete('SOUND_CTF_GET1');
2709 g_Sound_Delete('SOUND_CTF_GET2');
2710 g_Sound_Delete('SOUND_CTF_LOST1');
2711 g_Sound_Delete('SOUND_CTF_LOST2');
2712 g_Sound_Delete('SOUND_CTF_RETURN1');
2713 g_Sound_Delete('SOUND_CTF_RETURN2');
2714 g_Sound_Delete('SOUND_CTF_CAPTURE1');
2715 g_Sound_Delete('SOUND_CTF_CAPTURE2');
2717 g_Game_FreeChatSounds();
2719 DataLoaded
:= False;
2722 procedure DrawCustomStat();
2728 ww2
, hh2
, r
, g
, b
, rr
, gg
, bb
: Byte;
2729 s1
, s2
, topstr
: String;
2731 e_TextureFontGetSize(gStdFont
, ww2
, hh2
);
2735 if g_Console_Action(ACTION_SCORES
) then
2737 if not gStatsPressed
then
2739 gStatsOff
:= not gStatsOff
;
2740 gStatsPressed
:= True;
2744 gStatsPressed
:= False;
2748 s1
:= _lc
[I_MENU_INTER_NOTICE_TAB
];
2749 w
:= (Length(s1
) * ww2
) div 2;
2750 x
:= gScreenWidth
div 2 - w
;
2752 e_TextureFontPrint(x
, y
, s1
, gStdFont
);
2756 if (gGameSettings
.GameMode
= GM_COOP
) then
2758 if gMissionFailed
then
2759 topstr
:= _lc
[I_MENU_INTER_MISSION_FAIL
]
2761 topstr
:= _lc
[I_MENU_INTER_LEVEL_COMPLETE
];
2764 topstr
:= _lc
[I_MENU_INTER_ROUND_OVER
];
2766 e_CharFont_GetSize(gMenuFont
, topstr
, ww1
, hh1
);
2767 e_CharFont_Print(gMenuFont
, (gScreenWidth
div 2)-(ww1
div 2), 16, topstr
);
2769 if g_Game_IsNet
then
2771 topstr
:= Format(_lc
[I_MENU_INTER_NOTICE_TIME
], [gServInterTime
]);
2772 if not gChatShow
then
2773 e_TextureFontPrintEx((gScreenWidth
div 2)-(Length(topstr
)*ww2
div 2),
2774 gScreenHeight
-(hh2
+4)*2, topstr
, gStdFont
, 255, 255, 255, 1);
2777 if g_Game_IsClient
then
2778 topstr
:= _lc
[I_MENU_INTER_NOTICE_MAP
]
2780 topstr
:= _lc
[I_MENU_INTER_NOTICE_SPACE
];
2781 if not gChatShow
then
2782 e_TextureFontPrintEx((gScreenWidth
div 2)-(Length(topstr
)*ww2
div 2),
2783 gScreenHeight
-(hh2
+4), topstr
, gStdFont
, 255, 255, 255, 1);
2788 w
:= gScreenWidth
-x
*2;
2794 e_DrawFillQuad(x
, y
, gScreenWidth
-x
-1, gScreenHeight
-y
-1, 64, 64, 64, 32);
2795 e_DrawQuad(x
, y
, gScreenWidth
-x
-1, gScreenHeight
-y
-1, 255, 127, 0);
2797 m
:= Max(Length(_lc
[I_MENU_MAP
])+1, Length(_lc
[I_GAME_GAME_TIME
])+1)*ww2
;
2799 case CustomStat
.GameMode
of
2802 if gGameSettings
.MaxLives
= 0 then
2803 s1
:= _lc
[I_GAME_DM
]
2805 s1
:= _lc
[I_GAME_LMS
];
2809 if gGameSettings
.MaxLives
= 0 then
2810 s1
:= _lc
[I_GAME_TDM
]
2812 s1
:= _lc
[I_GAME_TLMS
];
2814 GM_CTF
: s1
:= _lc
[I_GAME_CTF
];
2817 if gGameSettings
.MaxLives
= 0 then
2818 s1
:= _lc
[I_GAME_COOP
]
2820 s1
:= _lc
[I_GAME_SURV
];
2826 e_TextureFontPrintEx(x
+(w
div 2)-(Length(s1
)*ww2
div 2), _y
, s1
, gStdFont
, 255, 255, 255, 1);
2830 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_MENU_MAP
], gStdFont
, 255, 127, 0, 1);
2831 e_TextureFontPrint(x
+8+m
, _y
, Format('%s - %s', [CustomStat
.Map
, CustomStat
.MapName
]), gStdFont
);
2834 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_GAME_TIME
], gStdFont
, 255, 127, 0, 1);
2835 e_TextureFontPrint(x
+8+m
, _y
, Format('%d:%.2d:%.2d', [CustomStat
.GameTime
div 1000 div 3600,
2836 (CustomStat
.GameTime
div 1000 div 60) mod 60,
2837 CustomStat
.GameTime
div 1000 mod 60]), gStdFont
);
2839 pc
:= Length(CustomStat
.PlayerStat
);
2840 if pc
= 0 then Exit
;
2842 if CustomStat
.GameMode
= GM_COOP
then
2844 m
:= Max(Length(_lc
[I_GAME_MONSTERS
])+1, Length(_lc
[I_GAME_SECRETS
])+1)*ww2
;
2846 s2
:= _lc
[I_GAME_MONSTERS
];
2847 e_TextureFontPrintEx(x
+8, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2848 e_TextureFontPrintEx(x
+8+m
, _y
, IntToStr(gCoopMonstersKilled
) + '/' + IntToStr(gTotalMonsters
), gStdFont
, 255, 255, 255, 1);
2850 s2
:= _lc
[I_GAME_SECRETS
];
2851 e_TextureFontPrintEx(x
+8, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2852 e_TextureFontPrintEx(x
+8+m
, _y
, IntToStr(gCoopSecretsFound
) + '/' + IntToStr(gSecretsCount
), gStdFont
, 255, 255, 255, 1);
2855 m
:= Max(Length(_lc
[I_GAME_MONSTERS_TOTAL
])+1, Length(_lc
[I_GAME_SECRETS_TOTAL
])+1)*ww2
;
2857 s2
:= _lc
[I_GAME_MONSTERS_TOTAL
];
2858 e_TextureFontPrintEx(x
+250, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2859 e_TextureFontPrintEx(x
+250+m
, _y
, IntToStr(gCoopTotalMonstersKilled
) + '/' + IntToStr(gCoopTotalMonsters
), gStdFont
, 255, 255, 255, 1);
2861 s2
:= _lc
[I_GAME_SECRETS_TOTAL
];
2862 e_TextureFontPrintEx(x
+250, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2863 e_TextureFontPrintEx(x
+250+m
, _y
, IntToStr(gCoopTotalSecretsFound
) + '/' + IntToStr(gCoopTotalSecrets
), gStdFont
, 255, 255, 255, 1);
2867 if CustomStat
.GameMode
in [GM_TDM
, GM_CTF
] then
2872 if TeamStat
[TEAM_RED
].Score
> TeamStat
[TEAM_BLUE
].Score
then s1
:= _lc
[I_GAME_WIN_RED
]
2873 else if TeamStat
[TEAM_BLUE
].Score
> TeamStat
[TEAM_RED
].Score
then s1
:= _lc
[I_GAME_WIN_BLUE
]
2874 else s1
:= _lc
[I_GAME_WIN_DRAW
];
2876 e_TextureFontPrintEx(x
+8+(w
div 2)-(Length(s1
)*ww2
div 2), _y
, s1
, gStdFont
, 255, 255, 255, 1);
2879 for t
:= TEAM_RED
to TEAM_BLUE
do
2881 if t
= TEAM_RED
then
2883 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_TEAM_RED
],
2884 gStdFont
, 255, 0, 0, 1);
2885 e_TextureFontPrintEx(x
+w1
+8, _y
, IntToStr(CustomStat
.TeamStat
[TEAM_RED
].Score
),
2886 gStdFont
, 255, 0, 0, 1);
2893 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_TEAM_BLUE
],
2894 gStdFont
, 0, 0, 255, 1);
2895 e_TextureFontPrintEx(x
+w1
+8, _y
, IntToStr(CustomStat
.TeamStat
[TEAM_BLUE
].Score
),
2896 gStdFont
, 0, 0, 255, 1);
2902 e_DrawLine(1, x
+8, _y
+20, x
-8+w
, _y
+20, r
, g
, b
);
2905 for p
:= 0 to High(CustomStat
.PlayerStat
) do
2906 if CustomStat
.PlayerStat
[p
].Team
= t
then
2907 with CustomStat
.PlayerStat
[p
] do
2921 if (gPlayers
[Num
] <> nil) and (gPlayers
[Num
].FReady
) then
2922 e_TextureFontPrintEx(x
+16, _y
, Name
+ ' *', gStdFont
, rr
, gg
, bb
, 1)
2924 e_TextureFontPrintEx(x
+16, _y
, Name
, gStdFont
, rr
, gg
, bb
, 1);
2925 e_TextureFontPrintEx(x
+w1
+16, _y
, IntToStr(Frags
), gStdFont
, rr
, gg
, bb
, 1);
2926 e_TextureFontPrintEx(x
+w1
+w2
+16, _y
, IntToStr(Assists
), gStdFont
, rr
, gg
, bb
, 1);
2927 e_TextureFontPrintEx(x
+w1
+w2
+w3
+16, _y
, IntToStr(Deaths
), gStdFont
, rr
, gg
, bb
, 1);
2934 else if CustomStat
.GameMode
in [GM_DM
, GM_COOP
] then
2937 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_PLAYER_NAME
], gStdFont
, 255, 127, 0, 1);
2938 e_TextureFontPrintEx(x
+8+w1
, _y
, _lc
[I_GAME_FRAGS
], gStdFont
, 255, 127, 0, 1);
2939 e_TextureFontPrintEx(x
+8+w1
+w2
, _y
, _lc
[I_GAME_DEATHS
], gStdFont
, 255, 127, 0, 1);
2942 for p
:= 0 to High(CustomStat
.PlayerStat
) do
2943 with CustomStat
.PlayerStat
[p
] do
2945 e_DrawFillQuad(x
+8, _y
+4, x
+24-1, _y
+16+4-1, Color
.R
, Color
.G
, Color
.B
, 0);
2952 if (gPlayers
[Num
] <> nil) and (gPlayers
[Num
].FReady
) then
2953 e_TextureFontPrintEx(x
+8+16+8, _y
+4, Name
+ ' *', gStdFont
, r
, r
, r
, 1, True)
2955 e_TextureFontPrintEx(x
+8+16+8, _y
+4, Name
, gStdFont
, r
, r
, r
, 1, True);
2956 e_TextureFontPrintEx(x
+w1
+8+16+8, _y
+4, IntToStr(Frags
), gStdFont
, r
, r
, r
, 1, True);
2957 e_TextureFontPrintEx(x
+w1
+w2
+8+16+8, _y
+4, IntToStr(Deaths
), gStdFont
, r
, r
, r
, 1, True);
2962 // HACK: take stats screenshot immediately after the first frame of the stats showing
2963 if gScreenshotStats
and (not StatShotDone
) and (Length(CustomStat
.PlayerStat
) > 1) then
2965 g_TakeScreenShot('stats/' + StatFilename
);
2966 StatShotDone
:= True;
2970 procedure DrawSingleStat();
2972 tm
, key_x
, val_x
, y
: Integer;
2976 procedure player_stat(n
: Integer);
2982 s1
:= Format(' %d ', [SingleStat
.PlayerStat
[n
].Kills
]);
2983 s2
:= Format(' %d', [gTotalMonsters
]);
2985 e_CharFont_Print(gMenuFont
, key_x
, y
, _lc
[I_MENU_INTER_KILLS
]);
2986 e_CharFont_PrintEx(gMenuFont
, val_x
, y
, s1
, _RGB(255, 0, 0));
2987 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2988 e_CharFont_Print(gMenuFont
, val_x
+w1
, y
, '/');
2990 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2991 e_CharFont_PrintEx(gMenuFont
, val_x
+w1
, y
, s2
, _RGB(255, 0, 0));
2993 // "Kills-per-minute: ##.#":
2994 s1
:= _lc
[I_MENU_INTER_KPM
];
2996 kpm
:= (SingleStat
.PlayerStat
[n
].Kills
/ tm
) * 60
2998 kpm
:= SingleStat
.PlayerStat
[n
].Kills
;
2999 s2
:= Format(' %.1f', [kpm
]);
3001 e_CharFont_Print(gMenuFont
, key_x
, y
+32, s1
);
3002 e_CharFont_PrintEx(gMenuFont
, val_x
, y
+32, s2
, _RGB(255, 0, 0));
3004 // "Secrets found: # / #":
3005 s1
:= Format(' %d ', [SingleStat
.PlayerStat
[n
].Secrets
]);
3006 s2
:= Format(' %d', [SingleStat
.TotalSecrets
]);
3008 e_CharFont_Print(gMenuFont
, key_x
, y
+64, _lc
[I_MENU_INTER_SECRETS
]);
3009 e_CharFont_PrintEx(gMenuFont
, val_x
, y
+64, s1
, _RGB(255, 0, 0));
3010 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
3011 e_CharFont_Print(gMenuFont
, val_x
+w1
, y
+64, '/');
3013 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
3014 e_CharFont_PrintEx(gMenuFont
, val_x
+w1
, y
+64, s2
, _RGB(255, 0, 0));
3018 // "Level Complete":
3019 e_CharFont_GetSize(gMenuFont
, _lc
[I_MENU_INTER_LEVEL_COMPLETE
], w1
, h
);
3020 e_CharFont_Print(gMenuFont
, (gScreenWidth
-w1
) div 2, 32, _lc
[I_MENU_INTER_LEVEL_COMPLETE
]);
3022 // Îïðåäåëÿåì êîîðäèíàòû âûðàâíèâàíèÿ ïî ñàìîé äëèííîé ñòðîêå:
3023 s1
:= _lc
[I_MENU_INTER_KPM
];
3024 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
3027 e_CharFont_GetSize(gMenuFont
, s1
, w2
, h
);
3029 key_x
:= (gScreenWidth
-w1
-w2
) div 2;
3030 val_x
:= key_x
+ w1
;
3033 tm
:= SingleStat
.GameTime
div 1000;
3034 s1
:= _lc
[I_MENU_INTER_TIME
];
3035 s2
:= Format(' %d:%.2d:%.2d', [tm
div (60*60), (tm
mod (60*60)) div 60, tm
mod 60]);
3037 e_CharFont_Print(gMenuFont
, key_x
, 80, s1
);
3038 e_CharFont_PrintEx(gMenuFont
, val_x
, 80, s2
, _RGB(255, 0, 0));
3040 if SingleStat
.TwoPlayers
then
3043 s1
:= _lc
[I_MENU_PLAYER_1
];
3044 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
3045 e_CharFont_Print(gMenuFont
, (gScreenWidth
-w1
) div 2, 128, s1
);
3047 // Ñòàòèñòèêà ïåðâîãî èãðîêà:
3052 s1
:= _lc
[I_MENU_PLAYER_2
];
3053 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
3054 e_CharFont_Print(gMenuFont
, (gScreenWidth
-w1
) div 2, 288, s1
);
3056 // Ñòàòèñòèêà âòîðîãî èãðîêà:
3062 // Ñòàòèñòèêà ïåðâîãî èãðîêà:
3068 procedure DrawLoadingStat();
3069 procedure drawRect (x
, y
, w
, h
: Integer);
3071 if (w
< 1) or (h
< 1) then exit
;
3073 glVertex2f(x
+0.375, y
+0.375);
3074 glVertex2f(x
+w
+0.375, y
+0.375);
3075 glVertex2f(x
+w
+0.375, y
+h
+0.375);
3076 glVertex2f(x
+0.375, y
+h
+0.375);
3080 function drawPBar (cur
, total
: Integer; washere
: Boolean): Boolean;
3082 rectW
, rectH
: Integer;
3089 idl
, idr
, idb
, idm
: LongWord;
3093 if (total
< 1) then exit
;
3094 if (cur
< 1) then exit
; // don't blink
3095 if (not washere
) and (cur
>= total
) then exit
; // don't blink
3096 //if (cur < 0) then cur := 0;
3097 //if (cur > total) then cur := total;
3100 if (hasPBarGfx
) then
3102 g_Texture_Get('UI_GFX_PBAR_LEFT', idl
);
3103 g_Texture_GetSize('UI_GFX_PBAR_LEFT', wl
, hl
);
3104 g_Texture_Get('UI_GFX_PBAR_RIGHT', idr
);
3105 g_Texture_GetSize('UI_GFX_PBAR_RIGHT', wr
, hr
);
3106 g_Texture_Get('UI_GFX_PBAR_MIDDLE', idb
);
3107 g_Texture_GetSize('UI_GFX_PBAR_MIDDLE', wb
, hb
);
3108 g_Texture_Get('UI_GFX_PBAR_MARKER', idm
);
3109 g_Texture_GetSize('UI_GFX_PBAR_MARKER', wm
, hm
);
3111 //rectW := gScreenWidth-360;
3112 rectW
:= trunc(624.0*gScreenWidth
/1024.0);
3115 x0
:= (gScreenWidth
-rectW
) div 2;
3116 y0
:= gScreenHeight
-rectH
-64;
3117 if (y0
< 2) then y0
:= 2;
3119 glEnable(GL_SCISSOR_TEST
);
3122 glScissor(x0
, gScreenHeight
-y0
-rectH
, rectW
, rectH
);
3123 e_DrawSize(idl
, x0
, y0
, 0, true, false, wl
, hl
);
3124 e_DrawSize(idr
, x0
+rectW
-wr
, y0
, 0, true, false, wr
, hr
);
3127 glScissor(x0
+wl
, gScreenHeight
-y0
-rectH
, rectW
-wl
-wr
, rectH
);
3129 while (f
< x0
+rectW
) do
3131 e_DrawSize(idb
, f
, y0
, 0, true, false, wb
, hb
);
3136 wdt
:= (rectW
-wl
-wr
)*cur
div total
;
3137 if (wdt
> rectW
-wl
-wr
) then wdt
:= rectW
-wr
-wr
;
3140 my
:= y0
; // don't be so smart, ketmar: +(rectH-wm) div 2;
3141 glScissor(x0
+wl
, gScreenHeight
-my
-rectH
, wdt
, hm
);
3145 e_DrawSize(idm
, f
, y0
, 0, true, false, wm
, hm
);
3151 glScissor(0, 0, gScreenWidth
, gScreenHeight
);
3155 rectW
:= gScreenWidth
-64;
3158 x0
:= (gScreenWidth
-rectW
) div 2;
3159 y0
:= gScreenHeight
-rectH
-64;
3160 if (y0
< 2) then y0
:= 2;
3162 glDisable(GL_BLEND
);
3163 glDisable(GL_TEXTURE_2D
);
3165 //glClearColor(0, 0, 0, 0);
3166 //glClear(GL_COLOR_BUFFER_BIT);
3168 glColor4ub(127, 127, 127, 255);
3169 drawRect(x0
-2, y0
-2, rectW
+4, rectH
+4);
3171 glColor4ub(0, 0, 0, 255);
3172 drawRect(x0
-1, y0
-1, rectW
+2, rectH
+2);
3174 glColor4ub(127, 127, 127, 255);
3175 wdt
:= rectW
*cur
div total
;
3176 if (wdt
> rectW
) then wdt
:= rectW
;
3177 drawRect(x0
, y0
, wdt
, rectH
);
3186 if (Length(LoadingStat
.Msgs
) = 0) then exit
;
3188 e_CharFont_GetSize(gMenuFont
, _lc
[I_MENU_LOADING
], ww
, hh
);
3189 yy
:= (gScreenHeight
div 3);
3190 e_CharFont_Print(gMenuFont
, (gScreenWidth
div 2)-(ww
div 2), yy
-2*hh
, _lc
[I_MENU_LOADING
]);
3191 xx
:= (gScreenWidth
div 3);
3195 for i
:= 0 to NextMsg
-1 do
3197 if (i
= (NextMsg
-1)) and (MaxValue
> 0) then
3198 s
:= Format('%s: %d/%d', [Msgs
[i
], CurValue
, MaxValue
])
3202 e_CharFont_PrintEx(gMenuSmallFont
, xx
, yy
, s
, _RGB(255, 0, 0));
3203 yy
:= yy
+ LOADING_INTERLINE
;
3204 PBarWasHere
:= drawPBar(CurValue
, MaxValue
, PBarWasHere
);
3209 procedure DrawMenuBackground(tex
: AnsiString);
3215 if g_Texture_Get(tex
, ID
) then
3217 e_Clear(GL_COLOR_BUFFER_BIT
, 0, 0, 0);
3218 e_GetTextureSize(ID
, @w
, @h
);
3220 w
:= round(w
* 1.333 * (gScreenHeight
/ h
))
3222 w
:= trunc(w
* (gScreenHeight
/ h
));
3223 e_DrawSize(ID
, (gScreenWidth
- w
) div 2, 0, 0, False, False, w
, gScreenHeight
);
3225 else e_Clear(GL_COLOR_BUFFER_BIT
, 0, 0, 0);
3228 procedure DrawMinimap(p
: TPlayer
; RenderRect
: e_graphics
.TRect
);
3230 a
, aX
, aY
, aX2
, aY2
, Scale
, ScaleSz
: Integer;
3232 function monDraw (mon
: TMonster
): Boolean;
3234 result
:= false; // don't stop
3239 // Ëåâûé âåðõíèé óãîë
3240 aX
:= Obj
.X
div ScaleSz
+ 1;
3241 aY
:= Obj
.Y
div ScaleSz
+ 1;
3243 aX2
:= max(Obj
.Rect
.Width
div ScaleSz
, 1);
3244 aY2
:= max(Obj
.Rect
.Height
div ScaleSz
, 1);
3245 // Ïðàâûé íèæíèé óãîë
3246 aX2
:= aX
+ aX2
- 1;
3247 aY2
:= aY
+ aY2
- 1;
3248 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 255, 0, 0);
3254 if (gMapInfo
.Width
> RenderRect
.Right
- RenderRect
.Left
) or
3255 (gMapInfo
.Height
> RenderRect
.Bottom
- RenderRect
.Top
) then
3258 // Ñêîëüêî ïèêñåëîâ êàðòû â 1 ïèêñåëå ìèíè-êàðòû:
3259 ScaleSz
:= 16 div Scale
;
3260 // Ðàçìåðû ìèíè-êàðòû:
3261 aX
:= max(gMapInfo
.Width
div ScaleSz
, 1);
3262 aY
:= max(gMapInfo
.Height
div ScaleSz
, 1);
3264 e_DrawFillQuad(0, 0, aX
-1, aY
-1, 0, 0, 0, 0);
3266 if gWalls
<> nil then
3269 for a
:= 0 to High(gWalls
) do
3271 if PanelType
<> 0 then
3273 // Ëåâûé âåðõíèé óãîë:
3274 aX
:= X
div ScaleSz
;
3275 aY
:= Y
div ScaleSz
;
3277 aX2
:= max(Width
div ScaleSz
, 1);
3278 aY2
:= max(Height
div ScaleSz
, 1);
3279 // Ïðàâûé íèæíèé óãîë:
3280 aX2
:= aX
+ aX2
- 1;
3281 aY2
:= aY
+ aY2
- 1;
3284 PANEL_WALL
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 208, 208, 208, 0);
3285 PANEL_OPENDOOR
, PANEL_CLOSEDOOR
:
3286 if Enabled
then e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 160, 160, 160, 0);
3290 if gSteps
<> nil then
3293 for a
:= 0 to High(gSteps
) do
3295 if PanelType
<> 0 then
3297 // Ëåâûé âåðõíèé óãîë:
3298 aX
:= X
div ScaleSz
;
3299 aY
:= Y
div ScaleSz
;
3301 aX2
:= max(Width
div ScaleSz
, 1);
3302 aY2
:= max(Height
div ScaleSz
, 1);
3303 // Ïðàâûé íèæíèé óãîë:
3304 aX2
:= aX
+ aX2
- 1;
3305 aY2
:= aY
+ aY2
- 1;
3307 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 128, 128, 128, 0);
3310 if gLifts
<> nil then
3313 for a
:= 0 to High(gLifts
) do
3315 if PanelType
<> 0 then
3317 // Ëåâûé âåðõíèé óãîë:
3318 aX
:= X
div ScaleSz
;
3319 aY
:= Y
div ScaleSz
;
3321 aX2
:= max(Width
div ScaleSz
, 1);
3322 aY2
:= max(Height
div ScaleSz
, 1);
3323 // Ïðàâûé íèæíèé óãîë:
3324 aX2
:= aX
+ aX2
- 1;
3325 aY2
:= aY
+ aY2
- 1;
3328 LIFTTYPE_UP
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 116, 72, 36, 0);
3329 LIFTTYPE_DOWN
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 116, 124, 96, 0);
3330 LIFTTYPE_LEFT
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 200, 80, 4, 0);
3331 LIFTTYPE_RIGHT
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 252, 140, 56, 0);
3335 if gWater
<> nil then
3338 for a
:= 0 to High(gWater
) do
3340 if PanelType
<> 0 then
3342 // Ëåâûé âåðõíèé óãîë:
3343 aX
:= X
div ScaleSz
;
3344 aY
:= Y
div ScaleSz
;
3346 aX2
:= max(Width
div ScaleSz
, 1);
3347 aY2
:= max(Height
div ScaleSz
, 1);
3348 // Ïðàâûé íèæíèé óãîë:
3349 aX2
:= aX
+ aX2
- 1;
3350 aY2
:= aY
+ aY2
- 1;
3352 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 0, 192, 0);
3355 if gAcid1
<> nil then
3357 // Ðèñóåì êèñëîòó 1:
3358 for a
:= 0 to High(gAcid1
) do
3360 if PanelType
<> 0 then
3362 // Ëåâûé âåðõíèé óãîë:
3363 aX
:= X
div ScaleSz
;
3364 aY
:= Y
div ScaleSz
;
3366 aX2
:= max(Width
div ScaleSz
, 1);
3367 aY2
:= max(Height
div ScaleSz
, 1);
3368 // Ïðàâûé íèæíèé óãîë:
3369 aX2
:= aX
+ aX2
- 1;
3370 aY2
:= aY
+ aY2
- 1;
3372 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 176, 0, 0);
3375 if gAcid2
<> nil then
3377 // Ðèñóåì êèñëîòó 2:
3378 for a
:= 0 to High(gAcid2
) do
3380 if PanelType
<> 0 then
3382 // Ëåâûé âåðõíèé óãîë:
3383 aX
:= X
div ScaleSz
;
3384 aY
:= Y
div ScaleSz
;
3386 aX2
:= max(Width
div ScaleSz
, 1);
3387 aY2
:= max(Height
div ScaleSz
, 1);
3388 // Ïðàâûé íèæíèé óãîë:
3389 aX2
:= aX
+ aX2
- 1;
3390 aY2
:= aY
+ aY2
- 1;
3392 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 176, 0, 0, 0);
3395 if gPlayers
<> nil then
3398 for a
:= 0 to High(gPlayers
) do
3399 if gPlayers
[a
] <> nil then with gPlayers
[a
] do
3401 // Ëåâûé âåðõíèé óãîë:
3402 aX
:= Obj
.X
div ScaleSz
+ 1;
3403 aY
:= Obj
.Y
div ScaleSz
+ 1;
3405 aX2
:= max(Obj
.Rect
.Width
div ScaleSz
, 1);
3406 aY2
:= max(Obj
.Rect
.Height
div ScaleSz
, 1);
3407 // Ïðàâûé íèæíèé óãîë:
3408 aX2
:= aX
+ aX2
- 1;
3409 aY2
:= aY
+ aY2
- 1;
3411 if gPlayers
[a
] = p
then
3412 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 255, 0, 0)
3415 TEAM_RED
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 0, 0, 0);
3416 TEAM_BLUE
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 0, 255, 0);
3417 else e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 128, 0, 0);
3422 g_Mons_ForEach(monDraw
);
3427 procedure renderAmbientQuad (hasAmbient
: Boolean; constref ambColor
: TDFColor
);
3429 if not hasAmbient
then exit
;
3430 e_AmbientQuad(sX
, sY
, sWidth
, sHeight
, ambColor
.r
, ambColor
.g
, ambColor
.b
, ambColor
.a
);
3434 // setup sX, sY, sWidth, sHeight, and transformation matrix before calling this!
3435 //FIXME: broken for splitscreen mode
3436 procedure renderDynLightsInternal ();
3438 //hasAmbient: Boolean;
3439 //ambColor: TDFColor;
3441 lx
, ly
, lrad
: Integer;
3442 scxywh
: array[0..3] of GLint
;
3445 if e_NoGraphics
then exit
;
3447 //TODO: lights should be in separate grid, i think
3448 // but on the other side: grid may be slower for dynlights, as their lifetime is short
3449 if (not gwin_k8_enable_light_experiments
) or (not gwin_has_stencil
) or (g_dynLightCount
< 1) then exit
;
3452 //ambColor := gCurrentMap['light_ambient'].rgba;
3453 //hasAmbient := (not ambColor.isOpaque) or (not ambColor.isBlack);
3455 { // this will multiply incoming color to alpha from framebuffer
3457 glBlendFunc(GL_DST_ALPHA, GL_ONE);
3461 * light rendering: (INVALID!)
3462 * glStencilFunc(GL_EQUAL, 0, $ff);
3464 * glClear(GL_STENCIL_BUFFER_BIT);
3465 * glStencilOp(GL_KEEP, GL_KEEP, GL_INCR);
3466 * draw shadow volume into stencil buffer
3467 * glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); // modify color buffer
3468 * glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); // don't modify stencil buffer
3470 * draw color-less quad with light alpha (WARNING! don't touch color!)
3471 * glEnable(GL_BLEND);
3472 * glBlendFunc(GL_DST_ALPHA, GL_ONE);
3473 * draw all geometry up to and including walls (with alpha-testing, probably) -- this does lighting
3475 wassc
:= (glIsEnabled(GL_SCISSOR_TEST
) <> 0);
3476 if wassc
then glGetIntegerv(GL_SCISSOR_BOX
, @scxywh
[0]) else glGetIntegerv(GL_VIEWPORT
, @scxywh
[0]);
3478 // setup OpenGL parameters
3479 glStencilMask($FFFFFFFF);
3480 glStencilFunc(GL_ALWAYS
, 0, $FFFFFFFF);
3481 glEnable(GL_STENCIL_TEST
);
3482 glEnable(GL_SCISSOR_TEST
);
3483 glClear(GL_STENCIL_BUFFER_BIT
);
3484 glStencilFunc(GL_EQUAL
, 0, $ff);
3486 for lln
:= 0 to g_dynLightCount
-1 do
3488 lx
:= g_dynLights
[lln
].x
;
3489 ly
:= g_dynLights
[lln
].y
;
3490 lrad
:= g_dynLights
[lln
].radius
;
3491 if (lrad
< 3) then continue
;
3493 if (lx
-sX
+lrad
< 0) then continue
;
3494 if (ly
-sY
+lrad
< 0) then continue
;
3495 if (lx
-sX
-lrad
>= gPlayerScreenSize
.X
) then continue
;
3496 if (ly
-sY
-lrad
>= gPlayerScreenSize
.Y
) then continue
;
3498 // set scissor to optimize drawing
3499 if (g_dbg_scale
= 1.0) then
3501 glScissor((lx
-sX
)-lrad
+2, gPlayerScreenSize
.Y
-(ly
-sY
)-lrad
-1+2, lrad
*2-4, lrad
*2-4);
3505 glScissor(0, 0, gScreenWidth
, gScreenHeight
);
3507 // no need to clear stencil buffer, light blitting will do it for us... but only for normal scale
3508 if (g_dbg_scale
<> 1.0) then glClear(GL_STENCIL_BUFFER_BIT
);
3509 glStencilOp(GL_KEEP
, GL_KEEP
, GL_INCR
);
3510 // draw extruded panels
3511 glDisable(GL_TEXTURE_2D
);
3512 glDisable(GL_BLEND
);
3513 glColorMask(GL_FALSE
, GL_FALSE
, GL_FALSE
, GL_FALSE
); // no need to modify color buffer
3514 if (lrad
> 4) then g_Map_DrawPanelShadowVolumes(lx
, ly
, lrad
);
3515 // render light texture
3516 glColorMask(GL_TRUE
, GL_TRUE
, GL_TRUE
, GL_TRUE
); // modify color buffer
3517 glStencilOp(GL_ZERO
, GL_ZERO
, GL_ZERO
); // draw light, and clear stencil buffer
3520 glBlendFunc(GL_SRC_ALPHA
, GL_ONE_MINUS_SRC_ALPHA
);
3521 glEnable(GL_TEXTURE_2D
);
3522 // color and opacity
3523 glColor4f(g_dynLights
[lln
].r
, g_dynLights
[lln
].g
, g_dynLights
[lln
].b
, g_dynLights
[lln
].a
);
3524 glBindTexture(GL_TEXTURE_2D
, g_Texture_Light());
3526 glTexCoord2f(0.0, 0.0); glVertex2i(lx
-lrad
, ly
-lrad
); // top-left
3527 glTexCoord2f(1.0, 0.0); glVertex2i(lx
+lrad
, ly
-lrad
); // top-right
3528 glTexCoord2f(1.0, 1.0); glVertex2i(lx
+lrad
, ly
+lrad
); // bottom-right
3529 glTexCoord2f(0.0, 1.0); glVertex2i(lx
-lrad
, ly
+lrad
); // bottom-left
3534 glDisable(GL_STENCIL_TEST
);
3535 glDisable(GL_BLEND
);
3536 glDisable(GL_SCISSOR_TEST
);
3537 //glScissor(0, 0, sWidth, sHeight);
3539 glScissor(scxywh
[0], scxywh
[1], scxywh
[2], scxywh
[3]);
3540 if wassc
then glEnable(GL_SCISSOR_TEST
) else glDisable(GL_SCISSOR_TEST
);
3544 function fixViewportForScale (): Boolean;
3546 nx0
, ny0
, nw
, nh
: Integer;
3549 if (g_dbg_scale
<> 1.0) then
3552 nx0
:= round(sX
-(gPlayerScreenSize
.X
-(sWidth
*g_dbg_scale
))/2/g_dbg_scale
);
3553 ny0
:= round(sY
-(gPlayerScreenSize
.Y
-(sHeight
*g_dbg_scale
))/2/g_dbg_scale
);
3554 nw
:= round(sWidth
/g_dbg_scale
);
3555 nh
:= round(sHeight
/g_dbg_scale
);
3564 // setup sX, sY, sWidth, sHeight, and transformation matrix before calling this!
3565 // WARNING! this WILL CALL `glTranslatef()`, but won't restore matrices!
3566 procedure renderMapInternal (backXOfs
, backYOfs
: Integer; setTransMatrix
: Boolean);
3568 TDrawCB
= procedure ();
3571 hasAmbient
: Boolean;
3573 doAmbient
: Boolean = false;
3575 procedure drawPanelType (profname
: AnsiString; panType
: DWord
; doDraw
: Boolean);
3580 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin(profname
);
3581 if gdbg_map_use_accel_render
then
3583 tagmask
:= panelTypeToTag(panType
);
3584 while (gDrawPanelList
.count
> 0) do
3586 pan
:= TPanel(gDrawPanelList
.front());
3587 if ((pan
.tag
and tagmask
) = 0) then break
;
3588 if doDraw
then pan
.Draw(doAmbient
, ambColor
);
3589 gDrawPanelList
.popFront();
3594 if doDraw
then g_Map_DrawPanels(panType
, hasAmbient
, ambColor
);
3596 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
3599 procedure drawOther (profname
: AnsiString; cb
: TDrawCB
);
3601 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin(profname
);
3602 if assigned(cb
) then cb();
3603 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
3607 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin('total');
3609 // our accelerated renderer will collect all panels to gDrawPanelList
3610 // we can use panel tag to render level parts (see GridTagXXX in g_map.pas)
3611 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin('collect');
3612 if gdbg_map_use_accel_render
then
3614 g_Map_CollectDrawPanels(sX
, sY
, sWidth
, sHeight
);
3616 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
3618 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin('skyback');
3619 g_Map_DrawBack(backXOfs
, backYOfs
);
3620 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
3622 if setTransMatrix
then
3624 //if (g_dbg_scale <> 1.0) then glTranslatef(0.0, -0.375/2, 0);
3625 glScalef(g_dbg_scale
, g_dbg_scale
, 1.0);
3626 glTranslatef(-sX
, -sY
, 0);
3630 ambColor
:= gCurrentMap
['light_ambient'].rgba
;
3631 hasAmbient
:= (not ambColor
.isOpaque
) or (not ambColor
.isBlack
);
3636 //writeln('color: (', ambColor.r, ',', ambColor.g, ',', ambColor.b, ',', ambColor.a, ')');
3637 glColor4ub(ambColor.r, ambColor.g, ambColor.b, ambColor.a);
3638 glClear(GL_COLOR_BUFFER_BIT);
3641 //writeln('color: (', ambColor.r, ',', ambColor.g, ',', ambColor.b, ',', ambColor.a, ')');
3644 drawPanelType('*back', PANEL_BACK
, g_rlayer_back
);
3645 drawPanelType('*step', PANEL_STEP
, g_rlayer_step
);
3646 drawOther('items', @g_Items_Draw
);
3647 drawOther('weapons', @g_Weapon_Draw
);
3648 drawOther('shells', @g_Player_DrawShells
);
3649 drawOther('drawall', @g_Player_DrawAll
);
3650 drawOther('corpses', @g_Player_DrawCorpses
);
3651 drawPanelType('*wall', PANEL_WALL
, g_rlayer_wall
);
3652 drawOther('monsters', @g_Monsters_Draw
);
3653 drawOther('itemdrop', @g_Items_DrawDrop
);
3654 drawPanelType('*door', PANEL_CLOSEDOOR
, g_rlayer_door
);
3655 drawOther('gfx', @g_GFX_Draw
);
3656 drawOther('flags', @g_Map_DrawFlags
);
3657 drawPanelType('*acid1', PANEL_ACID1
, g_rlayer_acid1
);
3658 drawPanelType('*acid2', PANEL_ACID2
, g_rlayer_acid2
);
3659 drawPanelType('*water', PANEL_WATER
, g_rlayer_water
);
3660 drawOther('dynlights', @renderDynLightsInternal
);
3662 if hasAmbient
{and ((not g_playerLight) or (not gwin_has_stencil) or (g_dynLightCount < 1))} then
3664 renderAmbientQuad(hasAmbient
, ambColor
);
3668 drawPanelType('*fore', PANEL_FORE
, g_rlayer_fore
);
3671 if g_debug_HealthBar
then
3673 g_Monsters_DrawHealth();
3674 g_Player_DrawHealth();
3677 if (profileFrameDraw
<> nil) then profileFrameDraw
.mainEnd(); // map rendering
3681 procedure DrawMapView(x
, y
, w
, h
: Integer);
3688 bx
:= Round(x
/(gMapInfo
.Width
- w
)*(gBackSize
.X
- w
));
3689 by
:= Round(y
/(gMapInfo
.Height
- h
)*(gBackSize
.Y
- h
));
3696 fixViewportForScale();
3697 renderMapInternal(-bx
, -by
, true);
3703 procedure DrawPlayer(p
: TPlayer
);
3705 px
, py
, a
, b
, c
, d
, i
, fX
, fY
: Integer;
3709 if (p
= nil) or (p
.FDummy
) then
3712 g_Map_DrawBack(0, 0);
3717 if (profileFrameDraw
= nil) then profileFrameDraw
:= TProfiler
.Create('RENDER', g_profile_history_size
);
3718 if (profileFrameDraw
<> nil) then profileFrameDraw
.mainBegin(g_profile_frame_draw
);
3724 camObj
:= p
.getCameraObj();
3725 camObj
.lerp(gLerpFactor
, fX
, fY
);
3726 px
:= fX
+ PLAYER_RECT_CX
;
3727 py
:= fY
+ PLAYER_RECT_CY
+nlerp(p
.SlopeOld
, camObj
.slopeUpLeft
, gLerpFactor
);
3729 if (g_dbg_scale
= 1.0) and (not g_dbg_ignore_bounds
) then
3731 if (px
> (gPlayerScreenSize
.X
div 2)) then a
:= -px
+(gPlayerScreenSize
.X
div 2) else a
:= 0;
3732 if (py
> (gPlayerScreenSize
.Y
div 2)) then b
:= -py
+(gPlayerScreenSize
.Y
div 2) else b
:= 0;
3734 if (px
> gMapInfo
.Width
-(gPlayerScreenSize
.X
div 2)) then a
:= -gMapInfo
.Width
+gPlayerScreenSize
.X
;
3735 if (py
> gMapInfo
.Height
-(gPlayerScreenSize
.Y
div 2)) then b
:= -gMapInfo
.Height
+gPlayerScreenSize
.Y
;
3737 if (gMapInfo
.Width
= gPlayerScreenSize
.X
) then a
:= 0
3738 else if (gMapInfo
.Width
< gPlayerScreenSize
.X
) then
3741 a
:= (gPlayerScreenSize
.X
-gMapInfo
.Width
) div 2;
3744 if (gMapInfo
.Height
= gPlayerScreenSize
.Y
) then b
:= 0
3745 else if (gMapInfo
.Height
< gPlayerScreenSize
.Y
) then
3748 b
:= (gPlayerScreenSize
.Y
-gMapInfo
.Height
) div 2;
3753 // scaled, ignore level bounds
3754 a
:= -px
+(gPlayerScreenSize
.X
div 2);
3755 b
:= -py
+(gPlayerScreenSize
.Y
div 2);
3760 sWidth
:= gPlayerScreenSize
.X
;
3761 sHeight
:= gPlayerScreenSize
.Y
;
3762 fixViewportForScale();
3764 i
:= py
- (sY
+ sHeight
div 2);
3765 if (p
.IncCam
> 0) then
3767 // clamp to level bounds
3768 if (sY
- p
.IncCam
< 0) then
3769 p
.IncCam
:= nclamp(sY
, 0, 120);
3770 // clamp around player position
3772 p
.IncCam
:= nclamp(p
.IncCam
, 0, max(0, 120 - i
));
3774 else if (p
.IncCam
< 0) then
3776 // clamp to level bounds
3777 if (sY
+ sHeight
- p
.IncCam
> gMapInfo
.Height
) then
3778 p
.IncCam
:= nclamp(sY
+ sHeight
- gMapInfo
.Height
, -120, 0);
3779 // clamp around player position
3781 p
.IncCam
:= nclamp(p
.IncCam
, min(0, -120 - i
), 0);
3784 sY
:= sY
- nlerp(p
.IncCamOld
, p
.IncCam
, gLerpFactor
);
3786 if (not g_dbg_ignore_bounds
) then
3788 if (sX
+sWidth
> gMapInfo
.Width
) then sX
:= gMapInfo
.Width
-sWidth
;
3789 if (sY
+sHeight
> gMapInfo
.Height
) then sY
:= gMapInfo
.Height
-sHeight
;
3790 if (sX
< 0) then sX
:= 0;
3791 if (sY
< 0) then sY
:= 0;
3794 if (gBackSize
.X
<= gPlayerScreenSize
.X
) or (gMapInfo
.Width
<= sWidth
) then c
:= 0 else c
:= trunc((gBackSize
.X
-gPlayerScreenSize
.X
)*sX
/(gMapInfo
.Width
-sWidth
));
3795 if (gBackSize
.Y
<= gPlayerScreenSize
.Y
) or (gMapInfo
.Height
<= sHeight
) then d
:= 0 else d
:= trunc((gBackSize
.Y
-gPlayerScreenSize
.Y
)*sY
/(gMapInfo
.Height
-sHeight
));
3797 //r_smallmap_h: 0: left; 1: center; 2: right
3798 //r_smallmap_v: 0: top; 1: center; 2: bottom
3800 if (gMapInfo
.Width
= sWidth
) then
3804 else if (gMapInfo
.Width
< sWidth
) then
3806 case r_smallmap_h
of
3807 1: sX
:= -((sWidth
-gMapInfo
.Width
) div 2); // center
3808 2: sX
:= -(sWidth
-gMapInfo
.Width
); // right
3809 else sX
:= 0; // left
3813 if (gMapInfo
.Height
= sHeight
) then
3817 else if (gMapInfo
.Height
< sHeight
) then
3819 case r_smallmap_v
of
3820 1: sY
:= -((sHeight
-gMapInfo
.Height
) div 2); // center
3821 2: sY
:= -(sHeight
-gMapInfo
.Height
); // bottom
3822 else sY
:= 0; // top
3828 p
.viewPortW
:= sWidth
;
3829 p
.viewPortH
:= sHeight
;
3831 {$IFDEF ENABLE_HOLMES}
3832 if (p
= gPlayer1
) then
3834 g_Holmes_plrViewPos(sX
, sY
);
3835 g_Holmes_plrViewSize(sWidth
, sHeight
);
3839 renderMapInternal(-c
, -d
, true);
3841 if (gGameSettings
.GameMode
<> GM_SINGLE
) and (gPlayerIndicator
> 0) then
3842 case gPlayerIndicator
of
3844 p
.DrawIndicator(_RGB(255, 255, 255));
3847 for i
:= 0 to High(gPlayers
) do
3848 if gPlayers
[i
] <> nil then
3849 if gPlayers
[i
] = p
then p
.DrawIndicator(_RGB(255, 255, 255))
3850 else if (gPlayers
[i
].Team
= p
.Team
) and (gPlayers
[i
].Team
<> TEAM_NONE
) then
3851 if gPlayerIndicatorStyle
= 1 then
3852 gPlayers
[i
].DrawIndicator(_RGB(192, 192, 192))
3853 else gPlayers
[i
].DrawIndicator(gPlayers
[i
].GetColor
);
3857 for a := 0 to High(gCollideMap) do
3858 for b := 0 to High(gCollideMap[a]) do
3861 if ByteBool(gCollideMap[a, b] and MARK_WALL) then
3863 if ByteBool(gCollideMap[a, b] and MARK_DOOR) then
3867 1: e_DrawPoint(1, b, a, 200, 200, 200);
3868 2: e_DrawPoint(1, b, a, 64, 64, 255);
3869 3: e_DrawPoint(1, b, a, 255, 0, 255);
3879 if gShowMap
then DrawMinimap(p
, _TRect(0, 0, 128, 128));
3880 if g_Debug_Player
then
3881 g_Player_DrawDebug(p
);
3885 procedure drawProfilers ();
3890 if g_profile_frame_draw
and (profileFrameDraw
<> nil) then px
:= px
-drawProfiles(px
, py
, profileFrameDraw
);
3891 if g_profile_collision
and (profMapCollision
<> nil) then begin px
:= px
-drawProfiles(px
, py
, profMapCollision
); py
-= calcProfilesHeight(profMonsLOS
); end;
3892 if g_profile_los
and (profMonsLOS
<> nil) then begin px
:= px
-drawProfiles(px
, py
, profMonsLOS
); py
-= calcProfilesHeight(profMonsLOS
); end;
3895 procedure g_Game_Draw();
3902 plView1
, plView2
: TPlayer
;
3905 if gExit
= EXIT_QUIT
then Exit
;
3907 Time
:= sys_GetTicks() {div 1000};
3908 FPSCounter
:= FPSCounter
+1;
3909 if Time
- FPSTime
>= 1000 then
3916 e_SetRendertarget(True);
3917 e_SetViewPort(0, 0, gScreenWidth
, gScreenHeight
);
3919 if gGameOn
or (gState
= STATE_FOLD
) then
3921 if (gPlayer1
<> nil) and (gPlayer2
<> nil) then
3923 gSpectMode
:= SPECT_NONE
;
3924 if not gRevertPlayers
then
3926 plView1
:= gPlayer1
;
3927 plView2
:= gPlayer2
;
3931 plView1
:= gPlayer2
;
3932 plView2
:= gPlayer1
;
3936 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
3938 gSpectMode
:= SPECT_NONE
;
3939 if gPlayer2
= nil then
3942 plView1
:= gPlayer2
;
3951 if (plView1
= nil) and (plView2
= nil) and (gSpectMode
= SPECT_NONE
) then
3952 gSpectMode
:= SPECT_STATS
;
3954 if gSpectMode
= SPECT_PLAYERS
then
3955 if gPlayers
<> nil then
3957 plView1
:= GetActivePlayer_ByID(gSpectPID1
);
3958 if plView1
= nil then
3960 gSpectPID1
:= GetActivePlayerID_Next();
3961 plView1
:= GetActivePlayer_ByID(gSpectPID1
);
3963 if gSpectViewTwo
then
3965 plView2
:= GetActivePlayer_ByID(gSpectPID2
);
3966 if plView2
= nil then
3968 gSpectPID2
:= GetActivePlayerID_Next();
3969 plView2
:= GetActivePlayer_ByID(gSpectPID2
);
3974 if gSpectMode
= SPECT_MAPVIEW
then
3976 // Ðåæèì ïðîñìîòðà êàðòû
3978 e_SetViewPort(0, 0, gScreenWidth
, gScreenHeight
);
3979 DrawMapView(gSpectX
, gSpectY
, gScreenWidth
, gScreenHeight
);
3980 gHearPoint1
.Active
:= True;
3981 gHearPoint1
.Coords
.X
:= gScreenWidth
div 2 + gSpectX
;
3982 gHearPoint1
.Coords
.Y
:= gScreenHeight
div 2 + gSpectY
;
3983 gHearPoint2
.Active
:= False;
3987 Split
:= (plView1
<> nil) and (plView2
<> nil);
3989 // Òî÷êè ñëóõà èãðîêîâ
3990 if plView1
<> nil then
3992 gHearPoint1
.Active
:= True;
3993 gHearPoint1
.Coords
.X
:= plView1
.GameX
+ PLAYER_RECT
.Width
;
3994 gHearPoint1
.Coords
.Y
:= plView1
.GameY
+ PLAYER_RECT
.Height
DIV 2;
3996 gHearPoint1
.Active
:= False;
3997 if plView2
<> nil then
3999 gHearPoint2
.Active
:= True;
4000 gHearPoint2
.Coords
.X
:= plView2
.GameX
+ PLAYER_RECT
.Width
;
4001 gHearPoint2
.Coords
.Y
:= plView2
.GameY
+ PLAYER_RECT
.Height
DIV 2;
4003 gHearPoint2
.Active
:= False;
4005 // Ðàçìåð ýêðàíîâ èãðîêîâ:
4006 gPlayerScreenSize
.X
:= gScreenWidth
-196;
4009 gPlayerScreenSize
.Y
:= gScreenHeight
div 2;
4010 if gScreenHeight
mod 2 = 0 then
4011 Dec(gPlayerScreenSize
.Y
);
4014 gPlayerScreenSize
.Y
:= gScreenHeight
;
4017 if gScreenHeight
mod 2 = 0 then
4018 e_SetViewPort(0, gPlayerScreenSize
.Y
+2, gPlayerScreenSize
.X
+196, gPlayerScreenSize
.Y
)
4020 e_SetViewPort(0, gPlayerScreenSize
.Y
+1, gPlayerScreenSize
.X
+196, gPlayerScreenSize
.Y
);
4022 DrawPlayer(plView1
);
4023 gPlayer1ScreenCoord
.X
:= sX
;
4024 gPlayer1ScreenCoord
.Y
:= sY
;
4028 e_SetViewPort(0, 0, gPlayerScreenSize
.X
+196, gPlayerScreenSize
.Y
);
4030 DrawPlayer(plView2
);
4031 gPlayer2ScreenCoord
.X
:= sX
;
4032 gPlayer2ScreenCoord
.Y
:= sY
;
4035 e_SetViewPort(0, 0, gScreenWidth
, gScreenHeight
);
4038 e_DrawLine(2, 0, gScreenHeight
div 2, gScreenWidth
, gScreenHeight
div 2, 0, 0, 0);
4041 {$IFDEF ENABLE_HOLMES}
4043 if (g_holmes_enabled
) then g_Holmes_Draw();
4046 if MessageText
<> '' then
4050 e_CharFont_GetSizeFmt(gMenuFont
, MessageText
, w
, h
);
4052 e_CharFont_PrintFmt(gMenuFont
, (gScreenWidth
div 2)-(w
div 2),
4053 (gScreenHeight
div 2)-(h
div 2), MessageText
)
4055 e_CharFont_PrintFmt(gMenuFont
, (gScreenWidth
div 2)-(w
div 2),
4056 Round(gScreenHeight
/ 2.75)-(h
div 2), MessageText
);
4059 if IsDrawStat
or (gSpectMode
= SPECT_STATS
) then
4062 if gSpectHUD
and (not gChatShow
) and (gSpectMode
<> SPECT_NONE
) and (not gSpectAuto
) then
4064 // Draw spectator GUI
4067 e_TextureFontGetSize(gStdFont
, ww
, hh
);
4070 e_TextureFontPrintEx(0, gScreenHeight
- (hh
+2)*2, 'MODE: Stats', gStdFont
, 255, 255, 255, 1);
4072 e_TextureFontPrintEx(0, gScreenHeight
- (hh
+2)*2, 'MODE: Observe Map', gStdFont
, 255, 255, 255, 1);
4074 e_TextureFontPrintEx(0, gScreenHeight
- (hh
+2)*2, 'MODE: Watch Players', gStdFont
, 255, 255, 255, 1);
4076 e_TextureFontPrintEx(2*ww
, gScreenHeight
- (hh
+2), '< jump >', gStdFont
, 255, 255, 255, 1);
4077 if gSpectMode
= SPECT_STATS
then
4079 e_TextureFontPrintEx(16*ww
, gScreenHeight
- (hh
+2)*2, 'Autoview', gStdFont
, 255, 255, 255, 1);
4080 e_TextureFontPrintEx(16*ww
, gScreenHeight
- (hh
+2), '< fire >', gStdFont
, 255, 255, 255, 1);
4082 if gSpectMode
= SPECT_MAPVIEW
then
4084 e_TextureFontPrintEx(22*ww
, gScreenHeight
- (hh
+2)*2, '[-]', gStdFont
, 255, 255, 255, 1);
4085 e_TextureFontPrintEx(26*ww
, gScreenHeight
- (hh
+2)*2, 'Step ' + IntToStr(gSpectStep
), gStdFont
, 255, 255, 255, 1);
4086 e_TextureFontPrintEx(34*ww
, gScreenHeight
- (hh
+2)*2, '[+]', gStdFont
, 255, 255, 255, 1);
4087 e_TextureFontPrintEx(18*ww
, gScreenHeight
- (hh
+2), '<prev weap>', gStdFont
, 255, 255, 255, 1);
4088 e_TextureFontPrintEx(30*ww
, gScreenHeight
- (hh
+2), '<next weap>', gStdFont
, 255, 255, 255, 1);
4090 if gSpectMode
= SPECT_PLAYERS
then
4092 e_TextureFontPrintEx(22*ww
, gScreenHeight
- (hh
+2)*2, 'Player 1', gStdFont
, 255, 255, 255, 1);
4093 e_TextureFontPrintEx(20*ww
, gScreenHeight
- (hh
+2), '<left/right>', gStdFont
, 255, 255, 255, 1);
4094 if gSpectViewTwo
then
4096 e_TextureFontPrintEx(37*ww
, gScreenHeight
- (hh
+2)*2, 'Player 2', gStdFont
, 255, 255, 255, 1);
4097 e_TextureFontPrintEx(34*ww
, gScreenHeight
- (hh
+2), '<prev w/next w>', gStdFont
, 255, 255, 255, 1);
4098 e_TextureFontPrintEx(52*ww
, gScreenHeight
- (hh
+2)*2, '2x View', gStdFont
, 255, 255, 255, 1);
4099 e_TextureFontPrintEx(51*ww
, gScreenHeight
- (hh
+2), '<up/down>', gStdFont
, 255, 255, 255, 1);
4103 e_TextureFontPrintEx(35*ww
, gScreenHeight
- (hh
+2)*2, '2x View', gStdFont
, 255, 255, 255, 1);
4104 e_TextureFontPrintEx(34*ww
, gScreenHeight
- (hh
+2), '<up/down>', gStdFont
, 255, 255, 255, 1);
4110 if gPauseMain
and gGameOn
and (g_ActiveWindow
= nil) then
4112 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4113 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4115 e_CharFont_GetSize(gMenuFont
, _lc
[I_MENU_PAUSE
], w
, h
);
4116 e_CharFont_Print(gMenuFont
, (gScreenWidth
div 2)-(w
div 2),
4117 (gScreenHeight
div 2)-(h
div 2), _lc
[I_MENU_PAUSE
]);
4122 if (gState
= STATE_MENU
) then
4124 if (g_ActiveWindow
= nil) or (g_ActiveWindow
.BackTexture
= '') then DrawMenuBackground('MENU_BACKGROUND');
4125 // F3 at menu will show game loading dialog
4126 if e_KeyPressed(IK_F3
) then g_Menu_Show_LoadMenu(true);
4127 if (g_ActiveWindow
<> nil) then
4129 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4130 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4134 // F3 at titlepic will show game loading dialog
4135 if e_KeyPressed(IK_F3
) then
4137 g_Menu_Show_LoadMenu(true);
4138 if (g_ActiveWindow
<> nil) then e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4143 if gState
= STATE_FOLD
then
4145 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 0, 0, 0, EndingGameCounter
);
4148 if gState
= STATE_INTERCUSTOM
then
4150 if gLastMap
and (gGameSettings
.GameMode
= GM_COOP
) then
4152 back
:= 'TEXTURE_endpic';
4153 if not g_Texture_Get(back
, ID
) then
4154 back
:= _lc
[I_TEXTURE_ENDPIC
];
4159 DrawMenuBackground(back
);
4163 if g_ActiveWindow
<> nil then
4165 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4166 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4170 if gState
= STATE_INTERSINGLE
then
4172 if EndingGameCounter
> 0 then
4174 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 0, 0, 0, EndingGameCounter
);
4180 DrawMenuBackground(back
);
4184 if g_ActiveWindow
<> nil then
4186 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4187 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4192 if gState
= STATE_ENDPIC
then
4195 if g_Texture_Get('TEXTURE_endpic', ID
) then DrawMenuBackground('TEXTURE_endpic')
4196 else DrawMenuBackground(_lc
[I_TEXTURE_ENDPIC
]);
4198 if g_ActiveWindow
<> nil then
4200 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4201 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4205 if gState
= STATE_SLIST
then
4207 // if g_Texture_Get('MENU_BACKGROUND', ID) then
4209 // e_DrawSize(ID, 0, 0, 0, False, False, gScreenWidth, gScreenHeight);
4210 // //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4212 DrawMenuBackground('MENU_BACKGROUND');
4213 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4214 g_Serverlist_Draw(slCurrent
, slTable
);
4218 if g_ActiveWindow
<> nil then
4222 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4223 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4225 g_ActiveWindow
.Draw();
4232 if g_debug_Sounds
and gGameOn
then
4234 for w
:= 0 to High(e_SoundsArray
) do
4235 for h
:= 0 to e_SoundsArray
[w
].nRefs
do
4236 e_DrawPoint(1, w
+100, h
+100, 255, 0, 0);
4241 e_TextureFontPrint(0, 0, Format('FPS: %d', [FPS
]), gStdFont
);
4242 e_TextureFontPrint(0, 16, Format('UPS: %d', [UPS
]), gStdFont
);
4245 if gGameOn
and gShowTime
then
4246 drawTime(gScreenWidth
-72, gScreenHeight
-16);
4248 if gGameOn
then drawProfilers();
4250 // TODO: draw this after the FBO and remap mouse click coordinates
4252 {$IFDEF ENABLE_HOLMES}
4256 // blit framebuffer to screen
4258 e_SetRendertarget(False);
4259 e_SetViewPort(0, 0, gWinSizeX
, gWinSizeY
);
4260 e_BlitFramebuffer(gWinSizeX
, gWinSizeY
);
4262 // draw the overlay stuff on top of it
4267 procedure g_Game_Quit();
4269 g_Game_StopAllSounds(True);
4272 g_PlayerModel_FreeData();
4273 g_Texture_DeleteAll();
4274 g_Frames_DeleteAll();
4276 //g_Menu_Free(); //k8: this segfaults after resolution change; who cares?
4279 if NetInitDone
then g_Net_Free
;
4281 // Íàäî óäàëèòü êàðòó ïîñëå òåñòà:
4282 if gMapToDelete
<> '' then
4283 g_Game_DeleteTestMap();
4289 procedure g_FatalError(Text: String);
4291 g_Console_Add(Format(_lc
[I_FATAL_ERROR
], [Text]), True);
4292 e_WriteLog(Format(_lc
[I_FATAL_ERROR
], [Text]), TMsgType
.Warning
);
4294 gExit
:= EXIT_SIMPLE
;
4295 if gGameOn
then EndGame
;
4298 procedure g_SimpleError(Text: String);
4300 g_Console_Add(Format(_lc
[I_SIMPLE_ERROR
], [Text]), True);
4301 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], [Text]), TMsgType
.Warning
);
4304 procedure g_Game_SetupScreenSize();
4306 RES_FACTOR
= 4.0 / 3.0;
4312 // Ðàçìåð ýêðàíîâ èãðîêîâ:
4313 gPlayerScreenSize
.X
:= gScreenWidth
-196;
4314 if (gPlayer1
<> nil) and (gPlayer2
<> nil) then
4315 gPlayerScreenSize
.Y
:= gScreenHeight
div 2
4317 gPlayerScreenSize
.Y
:= gScreenHeight
;
4319 // Ðàçìåð çàäíåãî ïëàíà:
4320 if BackID
<> DWORD(-1) then
4323 if (gScreenWidth
*s
> gMapInfo
.Width
) or
4324 (gScreenHeight
*s
> gMapInfo
.Height
) then
4326 gBackSize
.X
:= gScreenWidth
;
4327 gBackSize
.Y
:= gScreenHeight
;
4331 e_GetTextureSize(BackID
, @bw
, @bh
);
4332 rf
:= Single(bw
) / Single(bh
);
4333 if (rf
> RES_FACTOR
) then bw
:= Round(Single(bh
) * RES_FACTOR
)
4334 else if (rf
< RES_FACTOR
) then bh
:= Round(Single(bw
) / RES_FACTOR
);
4335 s
:= Max(gScreenWidth
/ bw
, gScreenHeight
/ bh
);
4336 if (s
< 1.0) then s
:= 1.0;
4337 gBackSize
.X
:= Round(bw
*s
);
4338 gBackSize
.Y
:= Round(bh
*s
);
4343 procedure g_Game_ChangeResolution(newWidth
, newHeight
: Word; nowFull
, nowMax
: Boolean);
4345 sys_SetDisplayMode(newWidth
, newHeight
, gBPP
, nowFull
, nowMax
);
4348 procedure g_Game_AddPlayer(Team
: Byte = TEAM_NONE
);
4350 if ((not gGameOn
) and (gState
<> STATE_INTERCUSTOM
))
4351 or (not (gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
])) then
4354 if (gGameSettings
.MaxLives
> 0) and (gLMSRespawn
= LMS_RESPAWN_NONE
) then
4357 if gPlayer1
= nil then
4359 if g_Game_IsClient
then
4361 if NetPlrUID1
> -1 then
4362 MC_SEND_CheatRequest(NET_CHEAT_SPECTATE
);
4366 if not (Team
in [TEAM_RED
, TEAM_BLUE
]) then
4367 Team
:= gPlayer1Settings
.Team
;
4369 // Ñîçäàíèå ïåðâîãî èãðîêà:
4370 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4371 gPlayer1Settings
.Color
,
4373 if gPlayer1
= nil then
4374 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]))
4377 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4378 gPlayer1
.WeapSwitchMode
:= gPlayer1Settings
.WeaponSwitch
;
4379 gPlayer1
.setWeaponPrefs(gPlayer1Settings
.WeaponPreferences
);
4380 gPlayer1
.SwitchToEmpty
:= gPlayer1Settings
.SwitchToEmpty
;
4381 gPlayer1
.SkipFist
:= gPlayer1Settings
.SkipFist
;
4382 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [gPlayer1
.Name
]), True);
4383 if g_Game_IsServer
and g_Game_IsNet
then
4384 MH_SEND_PlayerCreate(gPlayer1
.UID
);
4385 gPlayer1
.Respawn(False, True);
4386 g_Net_Slist_ServerPlayerComes();
4391 if gPlayer2
= nil then
4393 if g_Game_IsClient
then
4395 if NetPlrUID2
> -1 then
4396 gPlayer2
:= g_Player_Get(NetPlrUID2
);
4400 if not (Team
in [TEAM_RED
, TEAM_BLUE
]) then
4401 Team
:= gPlayer2Settings
.Team
;
4403 // Ñîçäàíèå âòîðîãî èãðîêà:
4404 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
4405 gPlayer2Settings
.Color
,
4407 if gPlayer2
= nil then
4408 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]))
4411 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
4412 gPlayer2
.WeapSwitchMode
:= gPlayer2Settings
.WeaponSwitch
;
4413 gPlayer2
.setWeaponPrefs(gPlayer2Settings
.WeaponPreferences
);
4414 gPlayer2
.SwitchToEmpty
:= gPlayer2Settings
.SwitchToEmpty
;
4415 gPlayer2
.SkipFist
:= gPlayer2Settings
.SkipFist
;
4416 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [gPlayer2
.Name
]), True);
4417 if g_Game_IsServer
and g_Game_IsNet
then
4418 MH_SEND_PlayerCreate(gPlayer2
.UID
);
4419 gPlayer2
.Respawn(False, True);
4420 g_Net_Slist_ServerPlayerComes();
4427 procedure g_Game_RemovePlayer();
4431 if ((not gGameOn
) and (gState
<> STATE_INTERCUSTOM
))
4432 or (not (gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
])) then
4437 if g_Game_IsServer
then
4440 Pl
.Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
4441 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [Pl
.Name
]), True);
4442 g_Player_Remove(Pl
.UID
);
4443 g_Net_Slist_ServerPlayerLeaves();
4447 gSpectLatchPID2
:= Pl
.UID
;
4455 if g_Game_IsServer
then
4458 Pl
.Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
4459 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [Pl
.Name
]), True);
4460 g_Player_Remove(Pl
.UID
);
4461 g_Net_Slist_ServerPlayerLeaves();
4464 gSpectLatchPID1
:= Pl
.UID
;
4466 MC_SEND_CheatRequest(NET_CHEAT_SPECTATE
);
4470 g_Net_Slist_ServerPlayerLeaves();
4473 procedure g_Game_Spectate();
4475 g_Game_RemovePlayer();
4476 if gPlayer1
<> nil then
4477 g_Game_RemovePlayer();
4480 procedure g_Game_SpectateCenterView();
4482 gSpectX
:= Max(gMapInfo
.Width
div 2 - gScreenWidth
div 2, 0);
4483 gSpectY
:= Max(gMapInfo
.Height
div 2 - gScreenHeight
div 2, 0);
4486 procedure g_Game_StartSingle(Map
: String; TwoPlayers
: Boolean; nPlayers
: Byte);
4493 e_WriteLog('Starting singleplayer game...', TMsgType
.Notify
);
4495 g_Game_ClearLoading();
4498 FillByte(gGameSettings
, SizeOf(TGameSettings
), 0);
4501 gGameSettings
.GameType
:= GT_SINGLE
;
4502 gGameSettings
.MaxLives
:= 0;
4503 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_ALLOWEXIT
;
4504 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_MONSTERS
;
4505 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_BOTVSMONSTER
;
4506 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_TEAMHITPROJECTILE
;
4507 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_TEAMHITTRACE
;
4508 gSwitchGameMode
:= GM_SINGLE
;
4510 gLMSRespawn
:= LMS_RESPAWN_NONE
;
4511 gLMSRespawnTime
:= 0;
4512 gSpectLatchPID1
:= 0;
4513 gSpectLatchPID2
:= 0;
4515 g_Game_ExecuteEvent('ongamestart');
4517 // Óñòàíîâêà ðàçìåðîâ îêîí èãðîêîâ:
4518 g_Game_SetupScreenSize();
4520 // Ñîçäàíèå ïåðâîãî èãðîêà:
4521 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4522 gPlayer1Settings
.Color
,
4523 gPlayer1Settings
.Team
, False));
4524 if gPlayer1
= nil then
4526 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
4530 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4531 gPlayer1
.WeapSwitchMode
:= gPlayer1Settings
.WeaponSwitch
;
4532 gPlayer1
.setWeaponPrefs(gPlayer1Settings
.WeaponPreferences
);
4533 gPlayer1
.SwitchToEmpty
:= gPlayer1Settings
.SwitchToEmpty
;
4534 gPlayer1
.SkipFist
:= gPlayer1Settings
.SkipFist
;
4537 // Ñîçäàíèå âòîðîãî èãðîêà, åñëè åñòü:
4540 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
4541 gPlayer2Settings
.Color
,
4542 gPlayer2Settings
.Team
, False));
4543 if gPlayer2
= nil then
4545 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
4549 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
4550 gPlayer2
.WeapSwitchMode
:= gPlayer2Settings
.WeaponSwitch
;
4551 gPlayer2
.setWeaponPrefs(gPlayer2Settings
.WeaponPreferences
);
4552 gPlayer2
.SwitchToEmpty
:= gPlayer2Settings
.SwitchToEmpty
;
4553 gPlayer2
.SkipFist
:= gPlayer2Settings
.SkipFist
;
4557 // Çàãðóçêà è çàïóñê êàðòû:
4558 if not g_Game_StartMap(false{asMegawad}, MAP
, True) then
4560 if (Pos(':\', Map
) > 0) or (Pos(':/', Map
) > 0) then tmps
:= Map
else tmps
:= gGameSettings
.WAD
+ ':\' + MAP
;
4561 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [tmps
]));
4565 // Íàñòðîéêè èãðîêîâ è áîòîâ:
4569 for i
:= nPl
+1 to nPlayers
do
4570 g_Player_Create(STD_PLAYER_MODEL
, _RGB(0, 0, 0), 0, True);
4573 procedure g_Game_StartCustom(Map
: String; GameMode
: Byte;
4574 TimeLimit
, ScoreLimit
: Word;
4576 Options
: LongWord; nPlayers
: Byte);
4582 e_WriteLog('Starting custom game...', TMsgType
.Notify
);
4584 g_Game_ClearLoading();
4587 gGameSettings
.GameType
:= GT_CUSTOM
;
4588 gGameSettings
.GameMode
:= GameMode
;
4589 gSwitchGameMode
:= GameMode
;
4590 gGameSettings
.TimeLimit
:= TimeLimit
;
4591 gGameSettings
.ScoreLimit
:= ScoreLimit
;
4592 gGameSettings
.MaxLives
:= IfThen(GameMode
= GM_CTF
, 0, MaxLives
);
4593 gGameSettings
.Options
:= Options
;
4595 gCoopTotalMonstersKilled
:= 0;
4596 gCoopTotalSecretsFound
:= 0;
4597 gCoopTotalMonsters
:= 0;
4598 gCoopTotalSecrets
:= 0;
4602 gLMSRespawn
:= LMS_RESPAWN_NONE
;
4603 gLMSRespawnTime
:= 0;
4604 gSpectLatchPID1
:= 0;
4605 gSpectLatchPID2
:= 0;
4607 g_Game_ExecuteEvent('ongamestart');
4609 // Óñòàíîâêà ðàçìåðîâ îêîí èãðîêîâ:
4610 g_Game_SetupScreenSize();
4612 // Ðåæèì íàáëþäàòåëÿ:
4613 if nPlayers
= 0 then
4620 if nPlayers
>= 1 then
4622 // Ñîçäàíèå ïåðâîãî èãðîêà:
4623 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4624 gPlayer1Settings
.Color
,
4625 gPlayer1Settings
.Team
, False));
4626 if gPlayer1
= nil then
4628 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
4632 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4633 gPlayer1
.WeapSwitchMode
:= gPlayer1Settings
.WeaponSwitch
;
4634 gPlayer1
.setWeaponPrefs(gPlayer1Settings
.WeaponPreferences
);
4635 gPlayer1
.SwitchToEmpty
:= gPlayer1Settings
.SwitchToEmpty
;
4636 gPlayer1
.SkipFist
:= gPlayer1Settings
.SkipFist
;
4640 if nPlayers
>= 2 then
4642 // Ñîçäàíèå âòîðîãî èãðîêà:
4643 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
4644 gPlayer2Settings
.Color
,
4645 gPlayer2Settings
.Team
, False));
4646 if gPlayer2
= nil then
4648 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
4652 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
4653 gPlayer2
.WeapSwitchMode
:= gPlayer2Settings
.WeaponSwitch
;
4654 gPlayer2
.setWeaponPrefs(gPlayer2Settings
.WeaponPreferences
);
4655 gPlayer2
.SwitchToEmpty
:= gPlayer2Settings
.SwitchToEmpty
;
4656 gPlayer2
.SkipFist
:= gPlayer2Settings
.SkipFist
;
4660 // Çàãðóçêà è çàïóñê êàðòû:
4661 if not g_Game_StartMap(true{asMegawad}, Map
, True) then
4663 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [Map
]));
4667 // Íåò òî÷åê ïîÿâëåíèÿ:
4668 if (g_Map_GetPointCount(RESPAWNPOINT_PLAYER1
) +
4669 g_Map_GetPointCount(RESPAWNPOINT_PLAYER2
) +
4670 g_Map_GetPointCount(RESPAWNPOINT_DM
) +
4671 g_Map_GetPointCount(RESPAWNPOINT_RED
)+
4672 g_Map_GetPointCount(RESPAWNPOINT_BLUE
)) < 1 then
4674 g_FatalError(_lc
[I_GAME_ERROR_GET_SPAWN
]);
4678 // Íàñòðîéêè èãðîêîâ è áîòîâ:
4682 for i
:= nPl
+1 to nPlayers
do
4683 g_Player_Create(STD_PLAYER_MODEL
, _RGB(0, 0, 0), 0, True);
4686 procedure g_Game_StartServer(Map
: String; GameMode
: Byte;
4687 TimeLimit
, ScoreLimit
: Word; MaxLives
: Byte;
4688 Options
: LongWord; nPlayers
: Byte;
4689 IPAddr
: LongWord; Port
: Word);
4692 g_Net_Slist_ServerClosed();
4694 e_WriteLog('Starting net game (server)...', TMsgType
.Notify
);
4696 g_Game_ClearLoading();
4701 gGameSettings
.GameType
:= GT_SERVER
;
4702 gGameSettings
.GameMode
:= GameMode
;
4703 gSwitchGameMode
:= GameMode
;
4704 gGameSettings
.TimeLimit
:= TimeLimit
;
4705 gGameSettings
.ScoreLimit
:= ScoreLimit
;
4706 gGameSettings
.MaxLives
:= IfThen(GameMode
= GM_CTF
, 0, MaxLives
);
4707 gGameSettings
.Options
:= Options
;
4709 gCoopTotalMonstersKilled
:= 0;
4710 gCoopTotalSecretsFound
:= 0;
4711 gCoopTotalMonsters
:= 0;
4712 gCoopTotalSecrets
:= 0;
4716 gLMSRespawn
:= LMS_RESPAWN_NONE
;
4717 gLMSRespawnTime
:= 0;
4718 gSpectLatchPID1
:= 0;
4719 gSpectLatchPID2
:= 0;
4721 g_Game_ExecuteEvent('ongamestart');
4723 // Óñòàíîâêà ðàçìåðîâ îêíà èãðîêà
4724 g_Game_SetupScreenSize();
4726 // Ðåæèì íàáëþäàòåëÿ:
4727 if nPlayers
= 0 then
4733 if nPlayers
>= 1 then
4735 // Ñîçäàíèå ïåðâîãî èãðîêà:
4736 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4737 gPlayer1Settings
.Color
,
4738 gPlayer1Settings
.Team
, False));
4739 if gPlayer1
= nil then
4741 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
4745 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4746 gPlayer1
.WeapSwitchMode
:= gPlayer1Settings
.WeaponSwitch
;
4747 gPlayer1
.setWeaponPrefs(gPlayer1Settings
.WeaponPreferences
);
4748 gPlayer1
.SwitchToEmpty
:= gPlayer1Settings
.SwitchToEmpty
;
4749 gPlayer1
.SkipFist
:= gPlayer1Settings
.SkipFist
;
4752 if nPlayers
>= 2 then
4754 // Ñîçäàíèå âòîðîãî èãðîêà:
4755 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
4756 gPlayer2Settings
.Color
,
4757 gPlayer2Settings
.Team
, False));
4758 if gPlayer2
= nil then
4760 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
4764 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
4765 gPlayer2
.WeapSwitchMode
:= gPlayer2Settings
.WeaponSwitch
;
4766 gPlayer2
.setWeaponPrefs(gPlayer2Settings
.WeaponPreferences
);
4767 gPlayer2
.SwitchToEmpty
:= gPlayer2Settings
.SwitchToEmpty
;
4768 gPlayer2
.SkipFist
:= gPlayer2Settings
.SkipFist
;
4771 g_Game_SetLoadingText(_lc
[I_LOAD_HOST
], 0, False);
4772 if NetForwardPorts
then
4773 g_Game_SetLoadingText(_lc
[I_LOAD_PORTS
], 0, False);
4776 if not g_Net_Host(IPAddr
, Port
, NetMaxClients
) then
4778 g_FatalError(_lc
[I_NET_MSG
] + Format(_lc
[I_NET_ERR_HOST
], [Port
]));
4782 g_Net_Slist_Set(NetMasterList
);
4784 g_Net_Slist_ServerStarted();
4786 // Çàãðóçêà è çàïóñê êàðòû:
4787 if not g_Game_StartMap(false{asMegawad}, Map
, True) then
4789 g_Net_Slist_ServerClosed();
4790 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [Map
]));
4794 // Íåò òî÷åê ïîÿâëåíèÿ:
4795 if (g_Map_GetPointCount(RESPAWNPOINT_PLAYER1
) +
4796 g_Map_GetPointCount(RESPAWNPOINT_PLAYER2
) +
4797 g_Map_GetPointCount(RESPAWNPOINT_DM
) +
4798 g_Map_GetPointCount(RESPAWNPOINT_RED
)+
4799 g_Map_GetPointCount(RESPAWNPOINT_BLUE
)) < 1 then
4801 g_Net_Slist_ServerClosed();
4802 g_FatalError(_lc
[I_GAME_ERROR_GET_SPAWN
]);
4806 // Íàñòðîéêè èãðîêîâ è áîòîâ:
4809 g_Net_Slist_ServerMapStarted();
4810 NetState
:= NET_STATE_GAME
;
4813 procedure g_Game_StartClient(Addr
: String; Port
: Word; PW
: String);
4828 e_WriteLog('Starting net game (client)...', TMsgType
.Notify
);
4829 e_WriteLog('NET: Trying to connect to ' + Addr
+ ':' + IntToStr(Port
) + '...', TMsgType
.Notify
);
4831 g_Game_ClearLoading();
4836 gGameSettings
.GameType
:= GT_CLIENT
;
4838 gCoopTotalMonstersKilled
:= 0;
4839 gCoopTotalSecretsFound
:= 0;
4840 gCoopTotalMonsters
:= 0;
4841 gCoopTotalSecrets
:= 0;
4845 g_Game_ExecuteEvent('ongamestart');
4847 // Óñòàíîâêà ðàçìåðîâ îêîí èãðîêîâ:
4848 g_Game_SetupScreenSize();
4850 NetState
:= NET_STATE_AUTH
;
4852 g_Game_SetLoadingText(_lc
[I_LOAD_CONNECT
], 0, False);
4854 // create (or update) map/resource databases
4855 g_Res_CreateDatabases(true);
4857 gLMSRespawn
:= LMS_RESPAWN_NONE
;
4858 gLMSRespawnTime
:= 0;
4859 gSpectLatchPID1
:= 0;
4860 gSpectLatchPID2
:= 0;
4863 if not g_Net_Connect(Addr
, Port
) then
4865 g_FatalError(_lc
[I_NET_MSG
] + _lc
[I_NET_ERR_CONN
]);
4866 NetState
:= NET_STATE_NONE
;
4870 g_Game_SetLoadingText(_lc
[I_LOAD_SEND_INFO
], 0, False);
4872 g_Game_SetLoadingText(_lc
[I_LOAD_WAIT_INFO
], 0, False);
4877 // fuck! https://www.mail-archive.com/enet-discuss@cubik.org/msg00852.html
4878 // tl;dr: on shitdows, we can get -1 sometimes, and it is *NOT* a failure.
4879 // thank you, enet. let's ignore failures altogether then.
4880 while (enet_host_service(NetHost
, @NetEvent
, 50) > 0) do
4882 if (NetEvent
.kind
= ENET_EVENT_TYPE_RECEIVE
) then
4884 Ptr
:= NetEvent
.packet
^.data
;
4885 if not InMsg
.Init(Ptr
, NetEvent
.packet
^.dataLength
, True) then
4887 enet_packet_destroy(NetEvent
.packet
);
4891 InMsg
.ReadLongWord(); // skip size
4892 MID
:= InMsg
.ReadByte();
4894 if (MID
= NET_MSG_INFO
) and (State
= 0) then
4896 NetMyID
:= InMsg
.ReadByte();
4897 NetPlrUID1
:= InMsg
.ReadWord();
4899 WadName
:= InMsg
.ReadString();
4900 Map
:= InMsg
.ReadString();
4902 gWADHash
:= InMsg
.ReadMD5();
4904 gGameSettings
.GameMode
:= InMsg
.ReadByte();
4905 gSwitchGameMode
:= gGameSettings
.GameMode
;
4906 gGameSettings
.ScoreLimit
:= InMsg
.ReadWord();
4907 gGameSettings
.TimeLimit
:= InMsg
.ReadWord();
4908 gGameSettings
.MaxLives
:= InMsg
.ReadByte();
4909 gGameSettings
.Options
:= InMsg
.ReadLongWord();
4910 T
:= InMsg
.ReadLongWord();
4912 //newResPath := g_Res_SearchSameWAD(MapsDir, WadName, gWADHash);
4913 //if newResPath = '' then
4915 //g_Game_SetLoadingText(_lc[I_LOAD_DL_RES], 0, False);
4916 newResPath
:= g_Res_DownloadMapWAD(ExtractFileName(WadName
), gWADHash
);
4917 if newResPath
= '' then
4919 g_FatalError(_lc
[I_NET_ERR_HASH
]);
4920 enet_packet_destroy(NetEvent
.packet
);
4921 NetState
:= NET_STATE_NONE
;
4924 e_LogWritefln('using downloaded map wad [%s] for [%s]`', [newResPath
, WadName
], TMsgType
.Notify
);
4926 //newResPath := ExtractRelativePath(MapsDir, newResPath);
4929 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4930 gPlayer1Settings
.Color
,
4931 gPlayer1Settings
.Team
, False));
4933 if gPlayer1
= nil then
4935 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
4937 enet_packet_destroy(NetEvent
.packet
);
4938 NetState
:= NET_STATE_NONE
;
4942 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4943 gPlayer1
.WeapSwitchMode
:= gPlayer1Settings
.WeaponSwitch
;
4944 gPlayer1
.setWeaponPrefs(gPlayer1Settings
.WeaponPreferences
);
4945 gPlayer1
.SwitchToEmpty
:= gPlayer1Settings
.SwitchToEmpty
;
4946 gPlayer1
.SkipFist
:= gPlayer1Settings
.SkipFist
;
4947 gPlayer1
.UID
:= NetPlrUID1
;
4948 gPlayer1
.Reset(True);
4950 if not g_Game_StartMap(false{asMegawad}, newResPath
+ ':\' + Map
, True) then
4952 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [WadName
+ ':\' + Map
]));
4954 enet_packet_destroy(NetEvent
.packet
);
4955 NetState
:= NET_STATE_NONE
;
4963 enet_packet_destroy(NetEvent
.packet
);
4967 enet_packet_destroy(NetEvent
.packet
);
4971 if (NetEvent
.kind
= ENET_EVENT_TYPE_DISCONNECT
) then
4974 if (NetEvent
.data
<= NET_DISC_MAX
) then
4975 g_Console_Add(_lc
[I_NET_MSG_ERROR
] + _lc
[I_NET_ERR_CONN
] + ' ' +
4976 _lc
[TStrings_Locale(Cardinal(I_NET_DISC_NONE
) + NetEvent
.data
)], True);
4983 ProcessLoading(True);
4984 if g_Net_UserRequestExit() then
4993 g_FatalError(_lc
[I_NET_MSG
] + _lc
[I_NET_ERR_CONN
]);
4994 NetState
:= NET_STATE_NONE
;
4999 NetState
:= NET_STATE_GAME
;
5000 MC_SEND_FullStateRequest
;
5001 e_WriteLog('NET: Connection successful.', TMsgType
.Notify
);
5005 lastAsMegaWad
: Boolean = false;
5007 procedure g_Game_ChangeMap(const MapPath
: String);
5011 g_Game_ClearLoading();
5013 Force
:= gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
];
5014 // Åñëè óðîâåíü çàâåðøèëñÿ ïî òðèããåðó Âûõîä, íå î÷èùàòü èíâåíòàðü
5015 if gExitByTrigger
then
5018 gExitByTrigger
:= False;
5020 if not g_Game_StartMap(lastAsMegaWad
, MapPath
, Force
) then
5021 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [MapPath
]));
5024 procedure g_Game_Restart();
5028 if g_Game_IsClient
then
5030 map
:= g_ExtractFileName(gMapInfo
.Map
);
5031 e_LogWritefln('g_Game_Restart: map = "%s" gCurrentMapFileName = "%s"', [map
, gCurrentMapFileName
]);
5035 g_Game_ClearLoading();
5036 g_Game_StartMap(lastAsMegaWad
, Map
, True, gCurrentMapFileName
);
5039 function g_Game_StartMap (asMegawad
: Boolean; Map
: String; Force
: Boolean = False; const oldMapPath
: AnsiString=''): Boolean;
5041 NewWAD
, ResName
: String;
5045 g_Map_Free((Map
<> gCurrentMapFileName
) and (oldMapPath
<> gCurrentMapFileName
));
5046 g_Player_RemoveAllCorpses();
5048 if (not g_Game_IsClient
) and
5049 (gSwitchGameMode
<> gGameSettings
.GameMode
) and
5050 (gGameSettings
.GameMode
<> GM_SINGLE
) then
5052 if gSwitchGameMode
= GM_CTF
then
5053 gGameSettings
.MaxLives
:= 0;
5054 gGameSettings
.GameMode
:= gSwitchGameMode
;
5057 gSwitchGameMode
:= gGameSettings
.GameMode
;
5059 g_Player_ResetTeams();
5061 lastAsMegaWad
:= asMegawad
;
5062 if isWadPath(Map
) then
5064 NewWAD
:= g_ExtractWadName(Map
);
5065 ResName
:= g_ExtractFileName(Map
);
5066 if g_Game_IsServer
then
5068 nws
:= findDiskWad(NewWAD
);
5069 //writeln('000: Map=[', Map, ']; nws=[', nws, ']; NewWAD=[', NewWAD, ']');
5072 if (length(nws
) = 0) then nws
:= e_FindWad(MegawadDirs
, NewWAD
);
5073 if (length(nws
) = 0) then nws
:= e_FindWad(MapDirs
, NewWAD
);
5077 if (length(nws
) = 0) then nws
:= e_FindWad(MapDirs
, NewWAD
);
5078 if (length(nws
) = 0) then nws
:= e_FindWad(MegawadDirs
, NewWAD
);
5080 //if (length(nws) = 0) then nws := e_FindWad(MapDownloadDirs, NewWAD);
5081 //writeln('001: Map=[', Map, ']; nws=[', nws, ']; NewWAD=[', NewWAD, ']');
5083 if (length(nws
) = 0) then
5085 ResName
:= ''; // failed
5090 if (g_Game_IsNet
) then gWADHash
:= MD5File(nws
);
5091 //writeln('********: nws=', nws, ' : Map=', Map, ' : nw=', NewWAD, ' : resname=', ResName);
5092 g_Game_LoadWAD(NewWAD
);
5097 // hash received in MC_RECV_GameEvent -> NET_EV_MAPSTART
5098 NewWAD
:= g_Game_ClientWAD(NewWAD
, gWADHash
);
5103 NewWAD
:= gGameSettings
.WAD
;
5109 //writeln('********: gsw=', gGameSettings.WAD, '; rn=', ResName);
5111 if (ResName
<> '') and (NewWAD
<> '') then
5113 //result := g_Map_Load(gGameSettings.WAD + ':\' + ResName);
5114 result
:= g_Map_Load(NewWAD
+':\'+ResName
);
5118 g_Player_ResetAll(Force
or gLastMap
, gGameSettings
.GameType
= GT_SINGLE
);
5120 gState
:= STATE_NONE
;
5121 g_ActiveWindow
:= nil;
5127 if gGameSettings
.GameMode
= GM_CTF
then
5129 g_Map_ResetFlag(FLAG_RED
);
5130 g_Map_ResetFlag(FLAG_BLUE
);
5131 // CTF, à ôëàãîâ íåò:
5132 if not g_Map_HaveFlagPoints() then
5133 g_SimpleError(_lc
[I_GAME_ERROR_CTF
]);
5138 gState
:= STATE_MENU
;
5143 gPauseMain
:= false;
5144 gPauseHolmes
:= false;
5145 NetTimeToUpdate
:= 1;
5146 NetTimeToReliable
:= 0;
5147 NetTimeToMaster
:= NetMasterRate
;
5148 gSpectLatchPID1
:= 0;
5149 gSpectLatchPID2
:= 0;
5150 gMissionFailed
:= False;
5153 gCoopMonstersKilled
:= 0;
5154 gCoopSecretsFound
:= 0;
5156 gVoteInProgress
:= False;
5157 gVotePassed
:= False;
5163 if not gGameOn
then Exit
;
5165 g_Game_SpectateCenterView();
5167 if g_Game_IsServer
then
5169 if (gGameSettings
.MaxLives
> 0) and (gGameSettings
.WarmupTime
> 0) then
5171 gLMSRespawn
:= LMS_RESPAWN_WARMUP
;
5172 gLMSRespawnTime
:= gTime
+ gGameSettings
.WarmupTime
*1000;
5173 gLMSSoftSpawn
:= True;
5174 if g_Game_IsNet
then
5175 MH_SEND_GameEvent(NET_EV_LMS_WARMUP
, gLMSRespawnTime
- gTime
);
5179 gLMSRespawn
:= LMS_RESPAWN_NONE
;
5180 gLMSRespawnTime
:= 0;
5184 if NetMode
= NET_SERVER
then
5186 // reset full state flags
5187 if NetClients
<> nil then
5188 for I
:= 0 to High(NetClients
) do
5189 NetClients
[I
].FullUpdateSent
:= False;
5191 MH_SEND_GameEvent(NET_EV_MAPSTART
, gGameSettings
.GameMode
, Map
);
5194 g_Net_Slist_ServerMapStarted();
5196 if NetClients
<> nil then
5197 for I
:= 0 to High(NetClients
) do
5198 if NetClients
[I
].Used
then
5200 NetClients
[I
].Voted
:= False;
5201 if NetClients
[I
].RequestedFullUpdate
then
5203 MH_SEND_Everything((NetClients
[I
].State
= NET_STATE_AUTH
), I
);
5204 NetClients
[I
].RequestedFullUpdate
:= False;
5208 g_Net_UnbanNonPerm();
5213 gCoopTotalMonstersKilled
:= 0;
5214 gCoopTotalSecretsFound
:= 0;
5215 gCoopTotalMonsters
:= 0;
5216 gCoopTotalSecrets
:= 0;
5220 g_Game_ExecuteEvent('onmapstart');
5223 procedure SetFirstLevel
;
5227 MapList
:= g_Map_GetMapsList(gGameSettings
.WAD
);
5228 if MapList
= nil then
5231 SortSArray(MapList
);
5232 gNextMap
:= MapList
[Low(MapList
)];
5237 procedure g_Game_ExitLevel(const Map
: AnsiString);
5241 gCoopTotalMonstersKilled
:= gCoopTotalMonstersKilled
+ gCoopMonstersKilled
;
5242 gCoopTotalSecretsFound
:= gCoopTotalSecretsFound
+ gCoopSecretsFound
;
5243 gCoopTotalMonsters
:= gCoopTotalMonsters
+ gTotalMonsters
;
5244 gCoopTotalSecrets
:= gCoopTotalSecrets
+ gSecretsCount
;
5246 // Âûøëè â âûõîä â Îäèíî÷íîé èãðå:
5247 if gGameSettings
.GameType
= GT_SINGLE
then
5248 gExit
:= EXIT_ENDLEVELSINGLE
5249 else // Âûøëè â âûõîä â Ñâîåé èãðå
5251 gExit
:= EXIT_ENDLEVELCUSTOM
;
5252 if gGameSettings
.GameMode
= GM_COOP
then
5253 g_Player_RememberAll
;
5255 if not g_Map_Exist(gGameSettings
.WAD
+ ':\' + gNextMap
) then
5258 if gGameSettings
.GameMode
= GM_COOP
then
5261 gStatsPressed
:= True;
5262 gNextMap
:= 'MAP01';
5264 if not g_Map_Exist(gGameSettings
.WAD
+ ':\' + gNextMap
) then
5267 if g_Game_IsNet
then
5269 MH_SEND_GameStats();
5270 MH_SEND_CoopStats();
5276 procedure g_Game_RestartLevel();
5280 if gGameSettings
.GameMode
= GM_SINGLE
then
5285 gExit
:= EXIT_ENDLEVELCUSTOM
;
5286 Map
:= g_ExtractFileName(gMapInfo
.Map
);
5290 function g_Game_ClientWAD (NewWAD
: String; const WHash
: TMD5Digest
): AnsiString;
5292 gWAD
{, xwad}: String;
5295 if not g_Game_IsClient
then Exit
;
5296 //e_LogWritefln('*** g_Game_ClientWAD: `%s`', [NewWAD]);
5298 gWAD
:= g_Res_DownloadMapWAD(ExtractFileName(NewWAD
), WHash
);
5303 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_WAD
], [ExtractFileName(NewWAD
)]));
5307 e_LogWritefln('using downloaded client map wad [%s] for [%s]', [gWAD
, NewWAD
], TMsgType
.Notify
);
5310 g_Game_LoadWAD(NewWAD
);
5314 if LowerCase(NewWAD) = LowerCase(gGameSettings.WAD) then Exit;
5315 gWAD := g_Res_SearchSameWAD(MapsDir, ExtractFileName(NewWAD), WHash);
5318 g_Game_SetLoadingText(_lc[I_LOAD_DL_RES], 0, False);
5319 gWAD := g_Res_DownloadMapWAD(ExtractFileName(NewWAD), WHash);
5323 g_FatalError(Format(_lc[I_GAME_ERROR_MAP_WAD], [ExtractFileName(NewWAD)]));
5327 NewWAD := ExtractRelativePath(MapsDir, gWAD);
5328 g_Game_LoadWAD(NewWAD);
5332 procedure g_Game_RestartRound(NoMapRestart
: Boolean = False);
5334 i
, n
, nb
, nr
: Integer;
5336 if not g_Game_IsServer
then Exit
;
5337 if gLMSRespawn
= LMS_RESPAWN_NONE
then Exit
;
5338 gLMSRespawn
:= LMS_RESPAWN_NONE
;
5339 gLMSRespawnTime
:= 0;
5342 if (gGameSettings
.GameMode
= GM_COOP
) and not NoMapRestart
then
5344 gMissionFailed
:= True;
5345 g_Game_RestartLevel
;
5349 n
:= 0; nb
:= 0; nr
:= 0;
5350 for i
:= Low(gPlayers
) to High(gPlayers
) do
5351 if (gPlayers
[i
] <> nil) and
5352 ((not gPlayers
[i
].FSpectator
) or gPlayers
[i
].FWantsInGame
or
5353 (gPlayers
[i
] is TBot
)) then
5356 if gPlayers
[i
].Team
= TEAM_RED
then Inc(nr
)
5357 else if gPlayers
[i
].Team
= TEAM_BLUE
then Inc(nb
)
5360 if (n
< 1) or ((gGameSettings
.GameMode
= GM_TDM
) and ((nr
= 0) or (nb
= 0))) then
5362 // wait a second until the fuckers finally decide to join
5363 gLMSRespawn
:= LMS_RESPAWN_WARMUP
;
5364 gLMSRespawnTime
:= gTime
+ gGameSettings
.WarmupTime
*1000;
5365 gLMSSoftSpawn
:= NoMapRestart
;
5366 if g_Game_IsNet
then
5367 MH_SEND_GameEvent(NET_EV_LMS_WARMUP
, gLMSRespawnTime
- gTime
);
5371 g_Player_RemoveAllCorpses
;
5372 g_Game_Message(_lc
[I_MESSAGE_LMS_START
], 144);
5373 if g_Game_IsNet
then
5374 MH_SEND_GameEvent(NET_EV_LMS_START
);
5376 for i
:= Low(gPlayers
) to High(gPlayers
) do
5378 if gPlayers
[i
] = nil then continue
;
5379 if gPlayers
[i
] is TBot
then gPlayers
[i
].FWantsInGame
:= True;
5380 // don't touch normal spectators
5381 if gPlayers
[i
].FSpectator
and not gPlayers
[i
].FWantsInGame
then
5383 gPlayers
[i
].FNoRespawn
:= True;
5384 gPlayers
[i
].Lives
:= 0;
5385 if g_Game_IsNet
then
5386 MH_SEND_PlayerStats(gPlayers
[I
].UID
);
5389 gPlayers
[i
].FNoRespawn
:= False;
5390 gPlayers
[i
].Lives
:= gGameSettings
.MaxLives
;
5391 gPlayers
[i
].Respawn(False, True);
5392 if gGameSettings
.GameMode
= GM_COOP
then
5394 gPlayers
[i
].Frags
:= 0;
5395 gPlayers
[i
].Assists
:= 0;
5396 gPlayers
[i
].RecallState
;
5398 if (gPlayer1
= nil) and (gSpectLatchPID1
> 0) then
5399 gPlayer1
:= g_Player_Get(gSpectLatchPID1
);
5400 if (gPlayer2
= nil) and (gSpectLatchPID2
> 0) then
5401 gPlayer2
:= g_Player_Get(gSpectLatchPID2
);
5404 g_Items_RestartRound();
5406 gLMSSoftSpawn
:= False;
5409 function g_Game_GetFirstMap(WAD
: String): String;
5413 MapList
:= g_Map_GetMapsList(WAD
);
5414 if MapList
= nil then
5417 SortSArray(MapList
);
5418 Result
:= MapList
[Low(MapList
)];
5420 if not g_Map_Exist(WAD
+ ':\' + Result
) then
5426 function g_Game_GetNextMap(): String;
5433 MapList
:= g_Map_GetMapsList(gGameSettings
.WAD
);
5434 if MapList
= nil then
5437 Map
:= g_ExtractFileName(gMapInfo
.Map
);
5439 SortSArray(MapList
);
5441 for I
:= Low(MapList
) to High(MapList
) do
5442 if Map
= MapList
[I
] then
5448 if MapIndex
<> -255 then
5450 if MapIndex
= High(MapList
) then
5451 Result
:= MapList
[Low(MapList
)]
5453 Result
:= MapList
[MapIndex
+ 1];
5455 if not g_Map_Exist(gGameSettings
.WAD
+ ':\' + Result
) then Result
:= Map
;
5461 procedure g_Game_NextLevel();
5463 if gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
, GM_COOP
] then
5464 gExit
:= EXIT_ENDLEVELCUSTOM
5467 gExit
:= EXIT_ENDLEVELSINGLE
;
5471 if gNextMap
<> '' then Exit
;
5472 gNextMap
:= g_Game_GetNextMap();
5475 function g_Game_IsTestMap(): Boolean;
5477 result
:= StrEquCI1251(TEST_MAP_NAME
, g_ExtractFileName(gMapInfo
.Map
));
5480 procedure g_Game_DeleteTestMap();
5483 //MapName: AnsiString;
5491 a
:= Pos('.wad:\', toLowerCase1251(gMapToDelete
));
5492 if (a
= 0) then a
:= Pos('.wad:/', toLowerCase1251(gMapToDelete
));
5493 if (a
= 0) then exit
;
5495 // Âûäåëÿåì èìÿ wad-ôàéëà è èìÿ êàðòû
5496 WadName
:= Copy(gMapToDelete
, 1, a
+3);
5497 Delete(gMapToDelete
, 1, a
+5);
5498 gMapToDelete
:= UpperCase(gMapToDelete
);
5500 //CopyMemory(@MapName[0], @gMapToDelete[1], Min(16, Length(gMapToDelete)));
5503 // Èìÿ êàðòû íå ñòàíäàðòíîå òåñòîâîå:
5504 if MapName <> TEST_MAP_NAME then
5507 if not gTempDelete then
5509 time := g_GetFileTime(WadName);
5510 WAD := TWADFile.Create();
5513 if not WAD.ReadFile(WadName) then
5514 begin // Íåò òàêîãî WAD-ôàéëà
5519 // Ñîñòàâëÿåì ñïèñîê êàðò è èùåì íóæíóþ:
5521 MapList := WAD.GetResourcesList('');
5523 if MapList <> nil then
5524 for a := 0 to High(MapList) do
5525 if MapList[a] = MapName then
5527 // Óäàëÿåì è ñîõðàíÿåì:
5528 WAD.RemoveResource('', MapName);
5529 WAD.SaveTo(WadName);
5534 g_SetFileTime(WadName, time);
5537 if gTempDelete
then DeleteFile(WadName
);
5540 procedure GameCVars(P
: SSArray
);
5543 stat
: TPlayerStatArray
;
5546 procedure ParseGameFlag(Flag
: LongWord; OffMsg
, OnMsg
: TStrings_Locale
; OnMapChange
: Boolean = False);
5550 if Length(P
) > 1 then
5555 gsGameFlags
:= gsGameFlags
or Flag
5557 gsGameFlags
:= gsGameFlags
and (not Flag
);
5559 if g_Game_IsServer
then
5562 gGameSettings
.Options
:= gGameSettings
.Options
or Flag
5564 gGameSettings
.Options
:= gGameSettings
.Options
and (not Flag
);
5565 if g_Game_IsNet
then MH_SEND_GameSettings
;
5569 if LongBool(gsGameFlags
and Flag
) then
5570 g_Console_Add(_lc
[OnMsg
])
5572 g_Console_Add(_lc
[OffMsg
]);
5574 if OnMapChange
and g_Game_IsServer
then
5575 g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
5580 cmd
:= LowerCase(P
[0]);
5582 if cmd
= 'g_gamemode' then
5584 if (Length(P
) > 1) then
5586 a
:= g_Game_TextToMode(P
[1]);
5587 if a
= GM_SINGLE
then a
:= GM_COOP
;
5588 gsGameMode
:= g_Game_ModeToText(a
);
5589 if g_Game_IsServer
then
5591 gSwitchGameMode
:= a
;
5592 if (gGameOn
and (gGameSettings
.GameMode
= GM_SINGLE
)) or
5593 (gState
= STATE_INTERSINGLE
) then
5594 gSwitchGameMode
:= GM_SINGLE
;
5596 gGameSettings
.GameMode
:= gSwitchGameMode
;
5600 if gSwitchGameMode
= gGameSettings
.GameMode
then
5601 g_Console_Add(Format(_lc
[I_MSG_GAMEMODE_CURRENT
],
5602 [g_Game_ModeToText(gGameSettings
.GameMode
)]))
5604 g_Console_Add(Format(_lc
[I_MSG_GAMEMODE_CHANGE
],
5605 [g_Game_ModeToText(gGameSettings
.GameMode
),
5606 g_Game_ModeToText(gSwitchGameMode
)]));
5608 else if cmd
= 'g_friendlyfire' then
5610 ParseGameFlag(GAME_OPTION_TEAMDAMAGE
, I_MSG_FRIENDLY_FIRE_OFF
, I_MSG_FRIENDLY_FIRE_ON
);
5612 else if cmd
= 'g_friendly_absorb_damage' then
5614 ParseGameFlag(GAME_OPTION_TEAMABSORBDAMAGE
, I_MSG_FRIENDLY_ABSORB_DAMAGE_OFF
, I_MSG_FRIENDLY_ABSORB_DAMAGE_ON
);
5616 else if cmd
= 'g_friendly_hit_trace' then
5618 ParseGameFlag(GAME_OPTION_TEAMHITTRACE
, I_MSG_FRIENDLY_HIT_TRACE_OFF
, I_MSG_FRIENDLY_HIT_TRACE_ON
);
5620 else if cmd
= 'g_friendly_hit_projectile' then
5622 ParseGameFlag(GAME_OPTION_TEAMHITPROJECTILE
, I_MSG_FRIENDLY_PROJECT_TRACE_OFF
, I_MSG_FRIENDLY_PROJECT_TRACE_ON
);
5624 else if cmd
= 'g_weaponstay' then
5626 ParseGameFlag(GAME_OPTION_WEAPONSTAY
, I_MSG_WEAPONSTAY_OFF
, I_MSG_WEAPONSTAY_ON
);
5628 else if cmd
= 'g_allow_exit' then
5630 ParseGameFlag(GAME_OPTION_ALLOWEXIT
, I_MSG_ALLOWEXIT_OFF
, I_MSG_ALLOWEXIT_ON
, True);
5632 else if cmd
= 'g_allow_monsters' then
5634 ParseGameFlag(GAME_OPTION_MONSTERS
, I_MSG_ALLOWMON_OFF
, I_MSG_ALLOWMON_ON
, True);
5636 else if cmd
= 'g_allow_dropflag' then
5638 ParseGameFlag(GAME_OPTION_ALLOWDROPFLAG
, I_MSG_ALLOWDROPFLAG_OFF
, I_MSG_ALLOWDROPFLAG_ON
);
5640 else if cmd
= 'g_throw_flag' then
5642 ParseGameFlag(GAME_OPTION_THROWFLAG
, I_MSG_THROWFLAG_OFF
, I_MSG_THROWFLAG_ON
);
5644 else if cmd
= 'g_bot_vsplayers' then
5646 ParseGameFlag(GAME_OPTION_BOTVSPLAYER
, I_MSG_BOTSVSPLAYERS_OFF
, I_MSG_BOTSVSPLAYERS_ON
);
5648 else if cmd
= 'g_bot_vsmonsters' then
5650 ParseGameFlag(GAME_OPTION_BOTVSMONSTER
, I_MSG_BOTSVSMONSTERS_OFF
, I_MSG_BOTSVSMONSTERS_ON
);
5652 else if cmd
= 'g_dm_keys' then
5654 ParseGameFlag(GAME_OPTION_DMKEYS
, I_MSG_DMKEYS_OFF
, I_MSG_DMKEYS_ON
, True);
5656 else if cmd
= 'g_gameflags' then
5658 if Length(P
) > 1 then
5660 gsGameFlags
:= StrToDWordDef(P
[1], gsGameFlags
);
5661 if g_Game_IsServer
then
5663 gGameSettings
.Options
:= gsGameFlags
;
5664 if g_Game_IsNet
then MH_SEND_GameSettings
;
5668 g_Console_Add(Format('%s %u', [cmd
, gsGameFlags
]));
5670 else if cmd
= 'g_warmup_time' then
5672 if Length(P
) > 1 then
5674 gsWarmupTime
:= nclamp(StrToIntDef(P
[1], gsWarmupTime
), 0, $FFFF);
5675 if g_Game_IsServer
then
5677 gGameSettings
.WarmupTime
:= gsWarmupTime
;
5678 // extend warmup if it's already going
5679 if gLMSRespawn
= LMS_RESPAWN_WARMUP
then
5681 gLMSRespawnTime
:= gTime
+ gsWarmupTime
* 1000;
5682 if g_Game_IsNet
then MH_SEND_GameEvent(NET_EV_LMS_WARMUP
, gLMSRespawnTime
- gTime
);
5684 if g_Game_IsNet
then MH_SEND_GameSettings
;
5688 g_Console_Add(Format(_lc
[I_MSG_WARMUP
], [Integer(gsWarmupTime
)]));
5689 if g_Game_IsServer
then g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
5691 else if cmd
= 'g_spawn_invul' then
5693 if Length(P
) > 1 then
5695 gsSpawnInvul
:= nclamp(StrToIntDef(P
[1], gsSpawnInvul
), 0, $FFFF);
5696 if g_Game_IsServer
then
5698 gGameSettings
.SpawnInvul
:= gsSpawnInvul
;
5699 if g_Game_IsNet
then MH_SEND_GameSettings
;
5703 g_Console_Add(Format('%s %d', [cmd
, Integer(gsSpawnInvul
)]));
5705 else if cmd
= 'g_item_respawn_time' then
5707 if Length(P
) > 1 then
5709 gsItemRespawnTime
:= nclamp(StrToIntDef(P
[1], gsItemRespawnTime
), 0, $FFFF);
5710 if g_Game_IsServer
then
5712 gGameSettings
.ItemRespawnTime
:= gsItemRespawnTime
;
5713 if g_Game_IsNet
then MH_SEND_GameSettings
;
5717 g_Console_Add(Format('%s %d', [cmd
, Integer(gsItemRespawnTime
)]));
5718 if g_Game_IsServer
then g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
5720 else if cmd
= 'sv_intertime' then
5722 if (Length(P
) > 1) then
5723 gDefInterTime
:= Min(Max(StrToIntDef(P
[1], gDefInterTime
), -1), 120);
5725 g_Console_Add(cmd
+ ' = ' + IntToStr(gDefInterTime
));
5727 else if cmd
= 'g_max_particles' then
5729 if Length(p
) = 2 then
5731 a
:= Max(0, StrToIntDef(p
[1], 0));
5734 else if Length(p
) = 1 then
5736 e_LogWritefln('%s', [g_GFX_GetMax()])
5740 e_LogWritefln('usage: %s <n>', [cmd
])
5743 else if cmd
= 'g_max_shells' then
5745 if Length(p
) = 2 then
5747 a
:= Max(0, StrToIntDef(p
[1], 0));
5750 else if Length(p
) = 1 then
5752 e_LogWritefln('%s', [g_Shells_GetMax()])
5756 e_LogWritefln('usage: %s <n>', [cmd
])
5759 else if cmd
= 'g_max_gibs' then
5761 if Length(p
) = 2 then
5763 a
:= Max(0, StrToIntDef(p
[1], 0));
5766 else if Length(p
) = 1 then
5768 e_LogWritefln('%s', [g_Gibs_GetMax()])
5772 e_LogWritefln('usage: %s <n>', [cmd
])
5775 else if cmd
= 'g_max_corpses' then
5777 if Length(p
) = 2 then
5779 a
:= Max(0, StrToIntDef(p
[1], 0));
5782 else if Length(p
) = 1 then
5784 e_LogWritefln('%s', [g_Corpses_GetMax()])
5788 e_LogWritefln('usage: %s <n>', [cmd
])
5791 else if cmd
= 'g_force_model' then
5793 if Length(p
) = 2 then
5795 a
:= StrToIntDef(p
[1], 0);
5796 g_Force_Model_Set(a
);
5797 if (g_Force_Model_Get() <> 0) and (gPlayers
<> nil) then
5799 for a
:= Low(gPlayers
) to High(gPlayers
) do
5801 if (gPlayers
[a
] <> nil) then
5803 if (gPlayers
[a
].UID
= gPlayer1
.UID
) then
5805 else if (gPlayer2
<> nil) and (gPlayers
[a
].UID
= gPlayer2
.UID
) then
5807 gPlayers
[a
].setModel(g_Forced_Model_GetName());
5811 else if (g_Force_Model_Get() = 0) and (gPlayers
<> nil) then
5813 for a
:= Low(gPlayers
) to High(gPlayers
) do
5815 if (gPlayers
[a
] <> nil) then
5817 if (gPlayers
[a
].UID
= gPlayer1
.UID
) then
5819 else if (gPlayer2
<> nil) and (gPlayers
[a
].UID
= gPlayer2
.UID
) then
5821 gPlayers
[a
].setModel(gPlayers
[a
].FActualModelName
);
5827 else if cmd
= 'g_force_model_name' then
5829 if (Length(P
) > 1) then
5831 cmd
:= b_Text_Unformat(P
[1]);
5832 g_Forced_Model_SetName(cmd
);
5833 if (g_Force_Model_Get() <> 0) and (gPlayers
<> nil) then
5835 for a
:= Low(gPlayers
) to High(gPlayers
) do
5837 if (gPlayers
[a
] <> nil) then
5839 if (gPlayers
[a
].UID
= gPlayer1
.UID
) then
5841 else if (gPlayer2
<> nil) and (gPlayers
[a
].UID
= gPlayer2
.UID
) then
5843 gPlayers
[a
].setModel(g_Forced_Model_GetName());
5849 else if cmd
= 'g_scorelimit' then
5851 if Length(P
) > 1 then
5853 gsScoreLimit
:= nclamp(StrToIntDef(P
[1], gsScoreLimit
), 0, $FFFF);
5855 if g_Game_IsServer
then
5858 if gGameSettings
.GameMode
= GM_DM
then
5860 stat
:= g_Player_GetStats();
5862 for a
:= 0 to High(stat
) do
5863 if stat
[a
].Frags
> b
then
5867 b
:= Max(gTeamStat
[TEAM_RED
].Score
, gTeamStat
[TEAM_BLUE
].Score
);
5869 // if someone has a higher score, set it to that instead
5870 gsScoreLimit
:= max(gsScoreLimit
, b
);
5871 gGameSettings
.ScoreLimit
:= gsScoreLimit
;
5873 if g_Game_IsNet
then MH_SEND_GameSettings
;
5877 g_Console_Add(Format(_lc
[I_MSG_SCORE_LIMIT
], [Integer(gsScoreLimit
)]));
5879 else if cmd
= 'g_timelimit' then
5881 if Length(P
) > 1 then
5883 gsTimeLimit
:= nclamp(StrToIntDef(P
[1], gsTimeLimit
), 0, $FFFF);
5884 if g_Game_IsServer
then
5886 gGameSettings
.TimeLimit
:= gsTimeLimit
;
5887 if g_Game_IsNet
then MH_SEND_GameSettings
;
5890 g_Console_Add(Format(_lc
[I_MSG_TIME_LIMIT
],
5891 [gsTimeLimit
div 3600,
5892 (gsTimeLimit
div 60) mod 60,
5893 gsTimeLimit
mod 60]));
5895 else if cmd
= 'g_max_bots' then
5897 if Length(P
) > 1 then
5898 gMaxBots
:= nclamp(StrToIntDef(P
[1], gMaxBots
), 0, 127);
5899 g_Console_Add('g_max_bots = ' + IntToStr(gMaxBots
));
5901 else if cmd
= 'g_maxlives' then
5903 if Length(P
) > 1 then
5905 gsMaxLives
:= nclamp(StrToIntDef(P
[1], gsMaxLives
), 0, $FFFF);
5906 if g_Game_IsServer
then
5908 gGameSettings
.MaxLives
:= gsMaxLives
;
5909 if g_Game_IsNet
then MH_SEND_GameSettings
;
5913 g_Console_Add(Format(_lc
[I_MSG_LIVES
], [Integer(gsMaxLives
)]));
5917 procedure PlayerSettingsCVars(P
: SSArray
);
5922 function ParseTeam(s
: string): Byte;
5926 'red', '1': result
:= TEAM_RED
;
5927 'blue', '2': result
:= TEAM_BLUE
;
5928 else result
:= TEAM_NONE
;
5932 cmd
:= LowerCase(P
[0]);
5936 if (Length(P
) > 1) then
5938 gPlayer1Settings
.Name
:= b_Text_Unformat(P
[1]);
5939 if g_Game_IsClient
then
5940 MC_SEND_PlayerSettings
5941 else if gGameOn
and (gPlayer1
<> nil) then
5943 gPlayer1
.Name
:= b_Text_Unformat(P
[1]);
5944 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer1
.UID
);
5950 if (Length(P
) > 1) then
5952 gPlayer2Settings
.Name
:= b_Text_Unformat(P
[1]);
5953 if g_Game_IsClient
then
5954 MC_SEND_PlayerSettings
5955 else if gGameOn
and (gPlayer2
<> nil) then
5957 gPlayer2
.Name
:= b_Text_Unformat(P
[1]);
5958 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer2
.UID
);
5964 if Length(P
) > 3 then
5966 gPlayer1Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
5967 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
5968 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
5969 if g_Game_IsClient
then
5970 MC_SEND_PlayerSettings
5971 else if gGameOn
and (gPlayer1
<> nil) then
5973 gPlayer1
.SetColor(gPlayer1Settings
.Color
);
5974 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer1
.UID
);
5980 if Length(P
) > 3 then
5982 gPlayer2Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
5983 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
5984 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
5985 if g_Game_IsClient
then
5986 MC_SEND_PlayerSettings
5987 else if gGameOn
and (gPlayer2
<> nil) then
5989 gPlayer2
.SetColor(gPlayer2Settings
.Color
);
5990 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer2
.UID
);
5996 if (Length(P
) > 1) then
5998 gPlayer1Settings
.Model
:= P
[1];
5999 if g_Game_IsClient
then
6000 MC_SEND_PlayerSettings
6001 else if gGameOn
and (gPlayer1
<> nil) then
6003 gPlayer1
.FActualModelName
:= gPlayer1Settings
.Model
;
6004 gPlayer1
.SetModel(gPlayer1Settings
.Model
);
6005 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer1
.UID
);
6011 if (Length(P
) > 1) then
6013 gPlayer2Settings
.Model
:= P
[1];
6014 if g_Game_IsClient
then
6015 MC_SEND_PlayerSettings
6016 else if gGameOn
and (gPlayer2
<> nil) then
6018 gPlayer2
.FActualModelName
:= gPlayer2Settings
.Model
;
6019 gPlayer2
.SetModel(gPlayer2Settings
.Model
);
6020 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer2
.UID
);
6026 // TODO: switch teams if in game or store this separately
6027 if (Length(P
) > 1) then
6029 team
:= ParseTeam(P
[1]);
6030 if team
= TEAM_NONE
then
6031 g_Console_Add('expected ''red'', ''blue'', 1 or 2')
6032 else if not gGameOn
and not g_Game_IsNet
then
6033 gPlayer1Settings
.Team
:= team
6035 g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
6040 // TODO: switch teams if in game or store this separately
6041 if (Length(P
) > 1) then
6043 team
:= ParseTeam(P
[1]);
6044 if team
= TEAM_NONE
then
6045 g_Console_Add('expected ''red'', ''blue'', 1 or 2')
6046 else if not gGameOn
and not g_Game_IsNet
then
6047 gPlayer2Settings
.Team
:= team
6049 g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
6054 if (Length(P
) = 2) then
6055 gPlayer1Settings
.WeaponSwitch
:= EnsureRange(StrTointDef(P
[1], 0), 0, 2);
6059 if (Length(P
) = 2) then
6060 gPlayer2Settings
.WeaponSwitch
:= EnsureRange(StrTointDef(P
[1], 0), 0, 2);
6064 if (Length(P
) = 2) then
6065 gPlayer1Settings
.SwitchToEmpty
:= EnsureRange(StrTointDef(P
[1], 0), 0, 1);
6069 if (Length(P
) = 2) then
6070 gPlayer2Settings
.SwitchToEmpty
:= EnsureRange(StrTointDef(P
[1], 0), 0, 1);
6074 if (Length(P
) = 2) then
6075 gPlayer1Settings
.SkipFist
:= EnsureRange(StrTointDef(P
[1], 0), 0, 1);
6079 if (Length(P
) = 2) then
6080 gPlayer2Settings
.SkipFist
:= EnsureRange(StrTointDef(P
[1], 0), 0, 1);
6082 'p1_priority_kastet':
6084 if (Length(P
) = 2) then
6085 gPlayer1Settings
.WeaponPreferences
[WEAPON_KASTET
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6087 'p2_priority_kastet':
6089 if (Length(P
) = 2) then
6090 gPlayer2Settings
.WeaponPreferences
[WEAPON_KASTET
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6094 if (Length(P
) = 2) then
6095 gPlayer1Settings
.WeaponPreferences
[WEAPON_SAW
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6099 if (Length(P
) = 2) then
6100 gPlayer2Settings
.WeaponPreferences
[WEAPON_SAW
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6102 'p1_priority_pistol':
6104 if (Length(P
) = 2) then
6105 gPlayer1Settings
.WeaponPreferences
[WEAPON_KASTET
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6107 'p2_priority_pistol':
6109 if (Length(P
) = 2) then
6110 gPlayer2Settings
.WeaponPreferences
[WEAPON_KASTET
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6112 'p1_priority_shotgun1':
6114 if (Length(P
) = 2) then
6115 gPlayer1Settings
.WeaponPreferences
[WEAPON_SHOTGUN1
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6117 'p2_priority_shotgun1':
6119 if (Length(P
) = 2) then
6120 gPlayer2Settings
.WeaponPreferences
[WEAPON_SHOTGUN1
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6122 'p1_priority_shotgun2':
6124 if (Length(P
) = 2) then
6125 gPlayer1Settings
.WeaponPreferences
[WEAPON_SHOTGUN2
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6127 'p2_priority_shotgun2':
6129 if (Length(P
) = 2) then
6130 gPlayer2Settings
.WeaponPreferences
[WEAPON_SHOTGUN2
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6132 'p1_priority_chaingun':
6134 if (Length(P
) = 2) then
6135 gPlayer1Settings
.WeaponPreferences
[WEAPON_CHAINGUN
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6137 'p2_priority_chaingun':
6139 if (Length(P
) = 2) then
6140 gPlayer2Settings
.WeaponPreferences
[WEAPON_CHAINGUN
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6142 'p1_priority_rocketlauncher':
6144 if (Length(P
) = 2) then
6145 gPlayer1Settings
.WeaponPreferences
[WEAPON_ROCKETLAUNCHER
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6147 'p2_priority_rocketlauncher':
6149 if (Length(P
) = 2) then
6150 gPlayer2Settings
.WeaponPreferences
[WEAPON_ROCKETLAUNCHER
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6152 'p1_priority_plasma':
6154 if (Length(P
) = 2) then
6155 gPlayer1Settings
.WeaponPreferences
[WEAPON_PLASMA
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6157 'p2_priority_plasma':
6159 if (Length(P
) = 2) then
6160 gPlayer2Settings
.WeaponPreferences
[WEAPON_PLASMA
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6164 if (Length(P
) = 2) then
6165 gPlayer1Settings
.WeaponPreferences
[WEAPON_BFG
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6169 if (Length(P
) = 2) then
6170 gPlayer2Settings
.WeaponPreferences
[WEAPON_BFG
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6172 'p1_priority_super':
6174 if (Length(P
) = 2) then
6175 gPlayer1Settings
.WeaponPreferences
[WEAPON_SUPERPULEMET
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6177 'p2_priority_super':
6179 if (Length(P
) = 2) then
6180 gPlayer2Settings
.WeaponPreferences
[WEAPON_SUPERPULEMET
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6182 'p1_priority_flamethrower':
6184 if (Length(P
) = 2) then
6185 gPlayer1Settings
.WeaponPreferences
[WEAPON_FLAMETHROWER
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6187 'p2_priority_flamethrower':
6189 if (Length(P
) = 2) then
6190 gPlayer2Settings
.WeaponPreferences
[WEAPON_FLAMETHROWER
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6192 'p1_priority_berserk':
6194 if (Length(P
) = 2) then
6195 gPlayer1Settings
.WeaponPreferences
[WP_LAST
+1] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6197 'p2_priority_berserk':
6199 if (Length(P
) = 2) then
6200 gPlayer2Settings
.WeaponPreferences
[WP_LAST
+1] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6205 procedure PrintHeapStats();
6209 hs
:= GetFPCHeapStatus();
6210 e_LogWriteLn ('v===== heap status =====v');
6211 e_LogWriteFln('max heap size = %d k', [hs
.MaxHeapSize
div 1024]);
6212 e_LogWriteFln('max heap used = %d k', [hs
.MaxHeapUsed
div 1024]);
6213 e_LogWriteFln('cur heap size = %d k', [hs
.CurrHeapSize
div 1024]);
6214 e_LogWriteFln('cur heap used = %d k', [hs
.CurrHeapUsed
div 1024]);
6215 e_LogWriteFln('cur heap free = %d k', [hs
.CurrHeapFree
div 1024]);
6216 e_LogWriteLn ('^=======================^');
6219 procedure DebugCommands(P
: SSArray
);
6226 // Êîìàíäû îòëàäî÷íîãî ðåæèìà:
6227 if {gDebugMode}conIsCheatsEnabled
then
6229 cmd
:= LowerCase(P
[0]);
6230 if cmd
= 'd_window' then
6232 g_Console_Add(Format('gScreenWidth = %d, gScreenHeight = %d', [gScreenWidth
, gScreenHeight
]));
6233 g_Console_Add(Format('gScreenWidth = %d, gScreenHeight = %d', [gScreenWidth
, gScreenHeight
]));
6235 else if cmd
= 'd_sounds' then
6237 if (Length(P
) > 1) and
6238 ((P
[1] = '1') or (P
[1] = '0')) then
6239 g_Debug_Sounds
:= (P
[1][1] = '1');
6241 g_Console_Add(Format('d_sounds is %d', [Byte(g_Debug_Sounds
)]));
6243 else if cmd
= 'd_frames' then
6245 if (Length(P
) > 1) and
6246 ((P
[1] = '1') or (P
[1] = '0')) then
6247 g_Debug_Frames
:= (P
[1][1] = '1');
6249 g_Console_Add(Format('d_frames is %d', [Byte(g_Debug_Frames
)]));
6251 else if cmd
= 'd_winmsg' then
6253 if (Length(P
) > 1) and
6254 ((P
[1] = '1') or (P
[1] = '0')) then
6255 g_Debug_WinMsgs
:= (P
[1][1] = '1');
6257 g_Console_Add(Format('d_winmsg is %d', [Byte(g_Debug_WinMsgs
)]));
6259 else if (cmd
= 'd_monoff') and not g_Game_IsNet
then
6261 if (Length(P
) > 1) and
6262 ((P
[1] = '1') or (P
[1] = '0')) then
6263 g_Debug_MonsterOff
:= (P
[1][1] = '1');
6265 g_Console_Add(Format('d_monoff is %d', [Byte(g_debug_MonsterOff
)]));
6267 else if (cmd
= 'd_botoff') and not g_Game_IsNet
then
6269 if Length(P
) > 1 then
6271 '0': g_debug_BotAIOff
:= 0;
6272 '1': g_debug_BotAIOff
:= 1;
6273 '2': g_debug_BotAIOff
:= 2;
6274 '3': g_debug_BotAIOff
:= 3;
6277 g_Console_Add(Format('d_botoff is %d', [g_debug_BotAIOff
]));
6279 else if cmd
= 'd_monster' then
6281 if gGameOn
and (gPlayer1
<> nil) and (gPlayer1
.alive
) and (not g_Game_IsNet
) then
6282 if Length(P
) < 2 then
6284 g_Console_Add(cmd
+ ' [ID | Name] [behaviour]');
6285 g_Console_Add('ID | Name');
6286 for b
:= MONSTER_DEMON
to MONSTER_MAN
do
6287 g_Console_Add(Format('%2d | %s', [b
, g_Mons_NameByTypeId(b
)]));
6288 conwriteln('behav. num'#10'normal 0'#10'killer 1'#10'maniac 2'#10'insane 3'#10'cannibal 4'#10'good 5');
6291 a
:= StrToIntDef(P
[1], 0);
6292 if (a
< MONSTER_DEMON
) or (a
> MONSTER_MAN
) then
6293 a
:= g_Mons_TypeIdByName(P
[1]);
6295 if (a
< MONSTER_DEMON
) or (a
> MONSTER_MAN
) then
6296 g_Console_Add(Format(_lc
[I_MSG_NO_MONSTER
], [P
[1]]))
6299 with gPlayer1
.Obj
do
6301 mon
:= g_Monsters_Create(a
,
6302 X
+ Rect
.X
+ (Rect
.Width
div 2),
6303 Y
+ Rect
.Y
+ Rect
.Height
,
6304 gPlayer1
.Direction
, True);
6306 if (Length(P
) > 2) and (mon
<> nil) then
6308 if (CompareText(P
[2], 'normal') = 0) then mon
.MonsterBehaviour
:= BH_NORMAL
6309 else if (CompareText(P
[2], 'killer') = 0) then mon
.MonsterBehaviour
:= BH_KILLER
6310 else if (CompareText(P
[2], 'maniac') = 0) then mon
.MonsterBehaviour
:= BH_MANIAC
6311 else if (CompareText(P
[2], 'insane') = 0) then mon
.MonsterBehaviour
:= BH_INSANE
6312 else if (CompareText(P
[2], 'cannibal') = 0) then mon
.MonsterBehaviour
:= BH_CANNIBAL
6313 else if (CompareText(P
[2], 'good') = 0) then mon
.MonsterBehaviour
:= BH_GOOD
6314 else if (CompareText(P
[2], 'friend') = 0) then mon
.MonsterBehaviour
:= BH_GOOD
6315 else if (CompareText(P
[2], 'friendly') = 0) then mon
.MonsterBehaviour
:= BH_GOOD
6316 else mon
.MonsterBehaviour
:= Min(Max(StrToIntDef(P
[2], BH_NORMAL
), BH_NORMAL
), BH_GOOD
);
6321 else if (cmd
= 'd_health') then
6323 if (Length(P
) > 1) and
6324 ((P
[1] = '1') or (P
[1] = '0')) then
6325 g_debug_HealthBar
:= (P
[1][1] = '1');
6327 g_Console_Add(Format('d_health is %d', [Byte(g_debug_HealthBar
)]));
6329 else if (cmd
= 'd_player') then
6331 if (Length(P
) > 1) and
6332 ((P
[1] = '1') or (P
[1] = '0')) then
6333 g_debug_Player
:= (P
[1][1] = '1');
6335 g_Console_Add(Format(cmd
+ ' is %d', [Byte(g_Debug_Player
)]));
6337 else if (cmd
= 'd_mem') then
6343 g_Console_Add(_lc
[I_MSG_NOT_DEBUG
]);
6347 procedure GameCheats(P
: SSArray
);
6353 if (not gGameOn
) or (not conIsCheatsEnabled
) then
6355 g_Console_Add('not available');
6361 g_Console_Add('where is the player?!');
6364 cmd
:= LowerCase(P
[0]);
6368 plr
.GodMode
:= not plr
.GodMode
;
6369 if plr
.GodMode
then g_Console_Add('player is godlike now') else g_Console_Add('player is mortal now');
6372 // give <health|exit|weapons|air|suit|jetpack|berserk|all>
6373 if cmd
= 'give' then
6375 if length(P
) < 2 then begin g_Console_Add('give what?!'); exit
; end;
6376 for f
:= 1 to High(P
) do
6378 cmd
:= LowerCase(P
[f
]);
6379 if cmd
= 'health' then begin plr
.RestoreHealthArmor(); g_Console_Add('player feels himself better'); continue
; end;
6380 if (cmd
= 'all') {or (cmd = 'weapons')} then begin plr
.AllRulez(False); g_Console_Add('player got the gifts'); continue
; end;
6381 if cmd
= 'exit' then
6383 if gTriggers
<> nil then
6385 for a
:= 0 to High(gTriggers
) do
6387 if gTriggers
[a
].TriggerType
= TRIGGER_EXIT
then
6389 g_Console_Add('player left the map');
6390 gExitByTrigger
:= True;
6391 //g_Game_ExitLevel(gTriggers[a].Data.MapName);
6392 g_Game_ExitLevel(gTriggers
[a
].tgcMap
);
6400 if cmd
= 'air' then begin plr
.GiveItem(ITEM_OXYGEN
); g_Console_Add('player got some air'); continue
; end;
6401 if cmd
= 'jetpack' then begin plr
.GiveItem(ITEM_JETPACK
); g_Console_Add('player got a jetpack'); continue
; end;
6402 if cmd
= 'suit' then begin plr
.GiveItem(ITEM_SUIT
); g_Console_Add('player got an envirosuit'); continue
; end;
6403 if cmd
= 'berserk' then begin plr
.GiveItem(ITEM_MEDKIT_BLACK
); g_Console_Add('player got a berserk pack'); continue
; end;
6404 if cmd
= 'backpack' then begin plr
.GiveItem(ITEM_AMMO_BACKPACK
); g_Console_Add('player got a backpack'); continue
; end;
6406 if cmd
= 'helmet' then begin plr
.GiveItem(ITEM_HELMET
); g_Console_Add('player got a helmet'); continue
; end;
6407 if cmd
= 'bottle' then begin plr
.GiveItem(ITEM_BOTTLE
); g_Console_Add('player got a bottle of health'); continue
; end;
6409 if cmd
= 'stimpack' then begin plr
.GiveItem(ITEM_MEDKIT_SMALL
); g_Console_Add('player got a stimpack'); continue
; end;
6410 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;
6412 if cmd
= 'greenarmor' then begin plr
.GiveItem(ITEM_ARMOR_GREEN
); g_Console_Add('player got a security armor'); continue
; end;
6413 if cmd
= 'bluearmor' then begin plr
.GiveItem(ITEM_ARMOR_BLUE
); g_Console_Add('player got a combat armor'); continue
; end;
6415 if (cmd
= 'megasphere') or (cmd
= 'mega') then begin plr
.GiveItem(ITEM_SPHERE_BLUE
); g_Console_Add('player got a megasphere'); continue
; end;
6416 if (cmd
= 'soulsphere') or (cmd
= 'soul')then begin plr
.GiveItem(ITEM_SPHERE_WHITE
); g_Console_Add('player got a soul sphere'); continue
; end;
6418 if (cmd
= 'invul') or (cmd
= 'invulnerability') then begin plr
.GiveItem(ITEM_INVUL
); g_Console_Add('player got invulnerability'); continue
; end;
6419 if (cmd
= 'invis') or (cmd
= 'invisibility') then begin plr
.GiveItem(ITEM_INVIS
); g_Console_Add('player got invisibility'); continue
; end;
6421 if cmd
= 'redkey' then begin plr
.GiveItem(ITEM_KEY_RED
); g_Console_Add('player got the red key'); continue
; end;
6422 if cmd
= 'greenkey' then begin plr
.GiveItem(ITEM_KEY_GREEN
); g_Console_Add('player got the green key'); continue
; end;
6423 if cmd
= 'bluekey' then begin plr
.GiveItem(ITEM_KEY_BLUE
); g_Console_Add('player got the blue key'); continue
; end;
6425 if (cmd
= 'shotgun') or (cmd
= 'sg') then begin plr
.GiveItem(ITEM_WEAPON_SHOTGUN1
); g_Console_Add('player got a shotgun'); continue
; end;
6426 if (cmd
= 'supershotgun') or (cmd
= 'ssg') then begin plr
.GiveItem(ITEM_WEAPON_SHOTGUN2
); g_Console_Add('player got a supershotgun'); continue
; end;
6427 if cmd
= 'chaingun' then begin plr
.GiveItem(ITEM_WEAPON_CHAINGUN
); g_Console_Add('player got a chaingun'); continue
; end;
6428 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;
6429 if cmd
= 'plasmagun' then begin plr
.GiveItem(ITEM_WEAPON_PLASMA
); g_Console_Add('player got a plasma gun'); continue
; end;
6430 if cmd
= 'bfg' then begin plr
.GiveItem(ITEM_WEAPON_BFG
); g_Console_Add('player got a BFG-9000'); continue
; end;
6432 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;
6433 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;
6434 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;
6435 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;
6436 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;
6437 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;
6439 if cmd
= 'superchaingun' then begin plr
.GiveItem(ITEM_WEAPON_SUPERPULEMET
); g_Console_Add('player got a superchaingun'); continue
; end;
6440 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;
6442 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;
6443 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;
6445 if cmd
= 'chainsaw' then begin plr
.GiveItem(ITEM_WEAPON_SAW
); g_Console_Add('player got a chainsaw'); continue
; end;
6447 if cmd
= 'ammo' then
6449 plr
.GiveItem(ITEM_AMMO_SHELLS_BOX
);
6450 plr
.GiveItem(ITEM_AMMO_BULLETS_BOX
);
6451 plr
.GiveItem(ITEM_AMMO_CELL_BIG
);
6452 plr
.GiveItem(ITEM_AMMO_ROCKET_BOX
);
6453 plr
.GiveItem(ITEM_AMMO_FUELCAN
);
6454 g_Console_Add('player got some ammo');
6458 if cmd
= 'clip' then begin plr
.GiveItem(ITEM_AMMO_BULLETS
); g_Console_Add('player got some bullets'); continue
; end;
6459 if cmd
= 'bullets' then begin plr
.GiveItem(ITEM_AMMO_BULLETS_BOX
); g_Console_Add('player got a box of bullets'); continue
; end;
6461 if cmd
= 'shells' then begin plr
.GiveItem(ITEM_AMMO_SHELLS
); g_Console_Add('player got some shells'); continue
; end;
6462 if cmd
= 'shellbox' then begin plr
.GiveItem(ITEM_AMMO_SHELLS_BOX
); g_Console_Add('player got a box of shells'); continue
; end;
6464 if cmd
= 'cells' then begin plr
.GiveItem(ITEM_AMMO_CELL
); g_Console_Add('player got some cells'); continue
; end;
6465 if cmd
= 'battery' then begin plr
.GiveItem(ITEM_AMMO_CELL_BIG
); g_Console_Add('player got cell battery'); continue
; end;
6467 if cmd
= 'rocket' then begin plr
.GiveItem(ITEM_AMMO_ROCKET
); g_Console_Add('player got a rocket'); continue
; end;
6468 if cmd
= 'rocketbox' then begin plr
.GiveItem(ITEM_AMMO_ROCKET_BOX
); g_Console_Add('player got some rockets'); continue
; end;
6470 if (cmd
= 'fuel') or (cmd
= 'fuelcan') then begin plr
.GiveItem(ITEM_AMMO_FUELCAN
); g_Console_Add('player got fuel canister'); continue
; end;
6472 if cmd
= 'weapons' then
6474 plr
.GiveItem(ITEM_WEAPON_SHOTGUN1
);
6475 plr
.GiveItem(ITEM_WEAPON_SHOTGUN2
);
6476 plr
.GiveItem(ITEM_WEAPON_CHAINGUN
);
6477 plr
.GiveItem(ITEM_WEAPON_ROCKETLAUNCHER
);
6478 plr
.GiveItem(ITEM_WEAPON_PLASMA
);
6479 plr
.GiveItem(ITEM_WEAPON_BFG
);
6480 g_Console_Add('player got weapons');
6484 if cmd
= 'keys' then
6486 plr
.GiveItem(ITEM_KEY_RED
);
6487 plr
.GiveItem(ITEM_KEY_GREEN
);
6488 plr
.GiveItem(ITEM_KEY_BLUE
);
6489 g_Console_Add('player got all keys');
6493 g_Console_Add('i don''t know how to give '''+cmd
+'''!');
6498 if cmd
= 'open' then
6500 g_Console_Add('player activated sesame');
6501 g_Triggers_OpenAll();
6508 if gFly
then g_Console_Add('player feels himself lighter') else g_Console_Add('player lost his wings');
6512 if cmd
= 'noclip' then
6515 g_Console_Add('wall hardeness adjusted');
6519 if cmd
= 'notarget' then
6521 plr
.NoTarget
:= not plr
.NoTarget
;
6522 if plr
.NoTarget
then g_Console_Add('player hides in shadows') else g_Console_Add('player is brave again');
6526 if cmd
= 'noreload' then
6528 plr
.NoReload
:= not plr
.NoReload
;
6529 if plr
.NoReload
then g_Console_Add('player is action hero now') else g_Console_Add('player is ordinary man now');
6533 if cmd
= 'speedy' then
6535 MAX_RUNVEL
:= 32-MAX_RUNVEL
;
6536 g_Console_Add('speed adjusted');
6540 if cmd
= 'jumpy' then
6542 VEL_JUMP
:= 30-VEL_JUMP
;
6543 g_Console_Add('jump height adjusted');
6547 if cmd
= 'automap' then
6549 gShowMap
:= not gShowMap
;
6550 if gShowMap
then g_Console_Add('player gains second sight') else g_Console_Add('player lost second sight');
6554 if cmd
= 'aimline' then
6556 gAimLine
:= not gAimLine
;
6557 if gAimLine
then g_Console_Add('player gains laser sight') else g_Console_Add('player lost laser sight');
6562 procedure GameCommands(P
: SSArray
);
6568 pl
: pTNetClient
= nil;
6577 cmd
:= LowerCase(P
[0]);
6579 if cmd
= 'pause' then
6581 if (g_ActiveWindow
= nil) then
6582 g_Game_Pause(not gPauseMain
);
6584 else if cmd
= 'endgame' then
6585 gExit
:= EXIT_SIMPLE
6586 else if cmd
= 'restart' then
6588 if gGameOn
or (gState
in [STATE_INTERSINGLE
, STATE_INTERCUSTOM
]) then
6590 if g_Game_IsClient
then
6592 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6597 g_Console_Add(_lc
[I_MSG_NOT_GAME
]);
6599 else if cmd
= 'kick' then
6601 if g_Game_IsServer
then
6603 if Length(P
) < 2 then
6605 g_Console_Add('kick <name>');
6610 g_Console_Add('kick <name>');
6614 if g_Game_IsNet
then
6615 pl
:= g_Net_Client_ByName(P
[1]);
6618 s
:= g_Net_ClientName_ByID(pl
^.ID
);
6619 g_Net_Host_Kick(pl
^.ID
, NET_DISC_KICK
);
6620 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
6621 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
6622 g_Net_Slist_ServerPlayerLeaves();
6623 end else if gPlayers
<> nil then
6624 for a
:= Low(gPlayers
) to High(gPlayers
) do
6625 if gPlayers
[a
] <> nil then
6626 if Copy(LowerCase(gPlayers
[a
].Name
), 1, Length(P
[1])) = LowerCase(P
[1]) then
6628 // Íå îòêëþ÷àòü îñíîâíûõ èãðîêîâ â ñèíãëå
6629 if not(gPlayers
[a
] is TBot
) and (gGameSettings
.GameType
= GT_SINGLE
) then
6631 gPlayers
[a
].Lives
:= 0;
6632 gPlayers
[a
].Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
6633 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [gPlayers
[a
].Name
]), True);
6634 g_Player_Remove(gPlayers
[a
].UID
);
6635 g_Net_Slist_ServerPlayerLeaves();
6636 // Åñëè íå ïåðåìåøàòü, ïðè äîáàâëåíèè íîâûõ áîòîâ ïîÿâÿòñÿ ñòàðûå
6640 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6642 else if cmd
= 'kick_id' then
6644 if g_Game_IsServer
and g_Game_IsNet
then
6646 if Length(P
) < 2 then
6648 g_Console_Add('kick_id <client ID>');
6653 g_Console_Add('kick_id <client ID>');
6657 a
:= StrToIntDef(P
[1], 0);
6658 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
6660 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
6662 s
:= g_Net_ClientName_ByID(NetClients
[a
].ID
);
6663 g_Net_Host_Kick(NetClients
[a
].ID
, NET_DISC_KICK
);
6664 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
6665 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
6666 g_Net_Slist_ServerPlayerLeaves();
6670 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6672 else if cmd
= 'kick_pid' then
6674 if g_Game_IsServer
and g_Game_IsNet
then
6676 if Length(P
) < 2 then
6678 g_Console_Add('kick_pid <player ID>');
6683 g_Console_Add('kick_pid <player ID>');
6687 a
:= StrToIntDef(P
[1], 0);
6688 pl
:= g_Net_Client_ByPlayer(a
);
6689 if (pl
<> nil) and pl
^.Used
and (pl
^.Peer
<> nil) then
6691 s
:= g_Net_ClientName_ByID(pl
^.ID
);
6692 g_Net_Host_Kick(pl
^.ID
, NET_DISC_KICK
);
6693 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
6694 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
6695 g_Net_Slist_ServerPlayerLeaves();
6698 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6700 else if cmd
= 'ban' then
6702 if g_Game_IsServer
and g_Game_IsNet
then
6704 if Length(P
) < 2 then
6706 g_Console_Add('ban <name>');
6711 g_Console_Add('ban <name>');
6715 pl
:= g_Net_Client_ByName(P
[1]);
6717 g_Net_Host_Ban(pl
, False)
6719 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
6721 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6723 else if cmd
= 'ban_id' then
6725 if g_Game_IsServer
and g_Game_IsNet
then
6727 if Length(P
) < 2 then
6729 g_Console_Add('ban_id <client ID>');
6734 g_Console_Add('ban_id <client ID>');
6738 a
:= StrToIntDef(P
[1], 0);
6739 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
6740 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
6741 g_Net_Host_Ban(pl
, False);
6743 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6745 else if cmd
= 'ban_pid' then
6747 if g_Game_IsServer
and g_Game_IsNet
then
6749 if Length(P
) < 2 then
6751 g_Console_Add('ban_pid <player ID>');
6756 g_Console_Add('ban_pid <player ID>');
6760 a
:= StrToIntDef(P
[1], 0);
6761 pl
:= g_Net_Client_ByPlayer(a
);
6762 if (pl
<> nil) and pl
^.Used
and (pl
^.Peer
<> nil) then
6763 g_Net_Host_Ban(pl
, False);
6765 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6767 else if cmd
= 'permban' then
6769 if g_Game_IsServer
and g_Game_IsNet
then
6771 if Length(P
) < 2 then
6773 g_Console_Add('permban <name>');
6778 g_Console_Add('permban <name>');
6782 pl
:= g_Net_Client_ByName(P
[1]);
6784 g_Net_Host_Ban(pl
, True)
6786 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
6788 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6790 else if cmd
= 'permban_id' then
6792 if g_Game_IsServer
and g_Game_IsNet
then
6794 if Length(P
) < 2 then
6796 g_Console_Add('permban_id <client ID>');
6801 g_Console_Add('permban_id <client ID>');
6805 a
:= StrToIntDef(P
[1], 0);
6806 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
6807 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
6808 g_Net_Host_Ban(@NetClients
[a
], True);
6810 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6812 else if cmd
= 'permban_pid' then
6814 if g_Game_IsServer
and g_Game_IsNet
then
6816 if Length(P
) < 2 then
6818 g_Console_Add('permban_pid <player ID>');
6823 g_Console_Add('permban_pid <player ID>');
6827 a
:= StrToIntDef(P
[1], 0);
6828 pl
:= g_Net_Client_ByPlayer(a
);
6829 if (pl
<> nil) and pl
^.Used
and (pl
^.Peer
<> nil) then
6830 g_Net_Host_Ban(pl
, True);
6832 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6834 else if cmd
= 'permban_ip' then
6836 if g_Game_IsServer
and g_Game_IsNet
then
6838 if Length(P
) < 2 then
6840 g_Console_Add('permban_ip <IP address>');
6845 g_Console_Add('permban_ip <IP address>');
6849 g_Net_BanAddress(P
[1]);
6850 g_Net_SaveBanList();
6851 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [P
[1]]));
6853 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6855 else if cmd
= 'unban' then
6857 if g_Game_IsServer
and g_Game_IsNet
then
6859 if Length(P
) < 2 then
6861 g_Console_Add('unban <IP Address>');
6866 g_Console_Add('unban <IP Address>');
6870 if g_Net_UnbanAddress(P
[1]) then
6872 g_Console_Add(Format(_lc
[I_MSG_UNBAN_OK
], [P
[1]]));
6873 g_Net_SaveBanList();
6875 g_Console_Add(Format(_lc
[I_MSG_UNBAN_FAIL
], [P
[1]]));
6877 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6879 else if cmd
= 'clientlist' then
6881 if g_Game_IsServer
and g_Game_IsNet
then
6884 if NetClients
<> nil then
6885 for a
:= Low(NetClients
) to High(NetClients
) do
6886 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
6888 plr
:= g_Player_Get(NetClients
[a
].Player
);
6889 if plr
= nil then continue
;
6891 g_Console_Add(Format('#%2d: %-15s | %s', [a
,
6892 IpToStr(NetClients
[a
].Peer
^.address
.host
), plr
.Name
]));
6895 g_Console_Add(_lc
[I_MSG_NOCLIENTS
]);
6897 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6899 else if cmd
= 'connect' then
6901 if (NetMode
= NET_NONE
) then
6903 if Length(P
) < 2 then
6905 g_Console_Add('connect <IP> [port] [password]');
6910 g_Console_Add('connect <IP> [port] [password]');
6914 if Length(P
) > 2 then
6915 prt
:= StrToIntDef(P
[2], 25666)
6919 if Length(P
) > 3 then
6924 g_Game_StartClient(P
[1], prt
, pw
);
6927 else if cmd
= 'disconnect' then
6929 if (NetMode
= NET_CLIENT
) then
6932 else if cmd
= 'reconnect' then
6934 if (NetMode
= NET_SERVER
) then
6937 if (NetMode
= NET_CLIENT
) then
6940 gExit
:= EXIT_SIMPLE
;
6944 //TODO: Use last successful password to reconnect, instead of ''
6945 g_Game_StartClient(NetClientIP
, NetClientPort
, '');
6947 else if (cmd
= 'addbot') or
6948 (cmd
= 'bot_add') then
6951 1: g_Bot_Add(TEAM_NONE
, 2);
6952 2: g_Bot_Add(TEAM_NONE
, StrToIntDef(P
[1], 2));
6954 g_Bot_Add(TEAM_NONE
, StrToIntDef(P
[1], 2), StrToIntDef(P
[2], 100));
6957 else if cmd
= 'bot_addlist' then
6960 1: g_Bot_AddList(TEAM_NONE
, '');
6961 2: g_Bot_AddList(TEAM_NONE
, P
[1], StrToIntDef(P
[1], -1));
6963 if P
[2] = 'red' then
6965 else if P
[2] = 'blue' then
6971 then g_Bot_AddList(t
, P
[1], StrToIntDef(P
[1], -1))
6972 else g_Bot_AddList(t
, P
[1], StrToIntDef(P
[1], -1), StrToIntDef(P
[3], 100));
6975 else if cmd
= 'bot_removeall' then
6977 else if cmd
= 'chat' then
6979 if g_Game_IsNet
then
6981 if Length(P
) > 1 then
6983 for a
:= 1 to High(P
) do
6984 chstr
:= chstr
+ P
[a
] + ' ';
6986 if Length(chstr
) > 200 then SetLength(chstr
, 200);
6988 if Length(chstr
) < 1 then
6990 g_Console_Add('chat <text>');
6994 chstr
:= b_Text_Format(chstr
);
6995 if g_Game_IsClient
then
6996 MC_SEND_Chat(chstr
, NET_CHAT_PLAYER
)
6998 MH_SEND_Chat(gPlayer1Settings
.Name
+ ': ' + chstr
, NET_CHAT_PLAYER
);
7001 g_Console_Add('chat <text>');
7003 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
7005 else if cmd
= 'teamchat' then
7007 if g_Game_IsNet
and (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
7009 if Length(P
) > 1 then
7011 for a
:= 1 to High(P
) do
7012 chstr
:= chstr
+ P
[a
] + ' ';
7014 if Length(chstr
) > 200 then SetLength(chstr
, 200);
7016 if Length(chstr
) < 1 then
7018 g_Console_Add('teamchat <text>');
7022 chstr
:= b_Text_Format(chstr
);
7023 if g_Game_IsClient
then
7024 MC_SEND_Chat(chstr
, NET_CHAT_TEAM
)
7026 MH_SEND_Chat(gPlayer1Settings
.Name
+ ': ' + chstr
, NET_CHAT_TEAM
,
7027 gPlayer1Settings
.Team
);
7030 g_Console_Add('teamchat <text>');
7032 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
7034 else if (cmd
= 'an') or (cmd
= 'announce') then
7036 if g_Game_IsNet
then
7038 if Length(P
) > 1 then
7040 for a
:= 1 to High(P
) do
7041 chstr
:= chstr
+ P
[a
] + ' ';
7043 if Length(chstr
) > 200 then SetLength(chstr
, 200);
7045 if Length(chstr
) < 1 then
7047 g_Console_Add('announce <text>');
7051 chstr
:= 'centerprint 100 ' + b_Text_Format(chstr
);
7052 if g_Game_IsClient
then
7053 MC_SEND_RCONCommand(chstr
)
7055 g_Console_Process(chstr
, True);
7058 g_Console_Add('announce <text>');
7060 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
7062 else if cmd
= 'game' then
7064 if gGameSettings
.GameType
<> GT_NONE
then
7066 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
7069 if Length(P
) = 1 then
7071 g_Console_Add(cmd
+ ' <WAD> [MAP] [# players]');
7074 // game not started yet, load fist map from some wad
7076 s
:= addWadExtension(P
[1]);
7077 found
:= e_FindResource(AllMapDirs
, s
);
7081 P
[1] := ExpandFileName(P
[1]);
7082 // if map not choosed then set first map
7083 if Length(P
) < 3 then
7086 P
[2] := g_Game_GetFirstMap(P
[1]);
7089 s
:= P
[1] + ':\' + UpperCase(P
[2]);
7091 if g_Map_Exist(s
) then
7095 with gGameSettings
do
7097 Options
:= gsGameFlags
;
7098 GameMode
:= g_Game_TextToMode(gsGameMode
);
7099 if gSwitchGameMode
<> GM_NONE
then
7100 GameMode
:= gSwitchGameMode
;
7101 if GameMode
= GM_NONE
then GameMode
:= GM_DM
;
7102 if GameMode
= GM_SINGLE
then GameMode
:= GM_COOP
;
7104 if Length(P
) >= 4 then
7105 b
:= StrToIntDef(P
[3], 1);
7106 g_Game_StartCustom(s
, GameMode
, TimeLimit
,
7107 ScoreLimit
, MaxLives
, Options
, b
);
7112 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
7114 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [UpperCase(P
[2]), P
[1]]));
7116 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]));
7118 else if cmd
= 'host' then
7120 if gGameSettings
.GameType
<> GT_NONE
then
7122 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
7125 if Length(P
) < 4 then
7127 g_Console_Add(cmd
+ ' <listen IP> <port> <WAD> [MAP] [# players]');
7130 if not StrToIp(P
[1], listen
) then
7132 prt
:= StrToIntDef(P
[2], 25666);
7134 s
:= addWadExtension(P
[3]);
7135 found
:= e_FindResource(AllMapDirs
, s
);
7139 // get first map in wad, if not specified
7140 if Length(P
) < 5 then
7143 P
[4] := g_Game_GetFirstMap(P
[1]);
7145 s
:= P
[3] + ':\' + UpperCase(P
[4]);
7146 if g_Map_Exist(s
) then
7150 with gGameSettings
do
7152 Options
:= gsGameFlags
;
7153 GameMode
:= g_Game_TextToMode(gsGameMode
);
7154 if gSwitchGameMode
<> GM_NONE
then GameMode
:= gSwitchGameMode
;
7155 if GameMode
= GM_NONE
then GameMode
:= GM_DM
;
7156 if GameMode
= GM_SINGLE
then GameMode
:= GM_COOP
;
7158 if Length(P
) >= 6 then
7159 b
:= StrToIntDef(P
[5], 0);
7160 g_Game_StartServer(s
, GameMode
, TimeLimit
, ScoreLimit
, MaxLives
, Options
, b
, listen
, prt
)
7166 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[3]]))
7168 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [UpperCase(P
[4]), P
[3]]))
7173 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[3]]))
7176 else if cmd
= 'map' then
7178 if Length(P
) = 1 then
7180 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
7182 g_Console_Add(cmd
+ ' <MAP>');
7183 g_Console_Add(cmd
+ ' <WAD> [MAP]')
7187 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
])
7190 else if not e_IsValidResourceName(P
[1]) then
7192 g_Console_Add('wad name must not be absolute or relative');
7196 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
7198 if Length(P
) < 3 then
7200 // first param is map or wad
7201 s
:= UpperCase(P
[1]);
7202 if g_Map_Exist(gGameSettings
.WAD
+ ':\' + s
) then
7204 gExitByTrigger
:= False;
7207 // already in game, finish current map
7209 gExit
:= EXIT_ENDLEVELCUSTOM
;
7213 // intermission, so change map immediately
7220 found
:= e_FindResource(AllMapDirs
, s
);
7222 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [s
, 'WAD ' + P
[1]]));
7225 // no such map, found wad
7228 P
[1] := ExpandFileName(pw
);
7229 P
[2] := g_Game_GetFirstMap(P
[1]);
7230 s
:= P
[1] + ':\' + P
[2];
7231 if g_Map_Exist(s
) then
7233 gExitByTrigger
:= False;
7236 // already in game, finish current map
7238 gExit
:= EXIT_ENDLEVELCUSTOM
7242 // intermission, so change map immediately
7249 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
7251 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]))
7256 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]))
7262 s
:= addWadExtension(P
[1]);
7263 found
:= e_FindResource(AllMapDirs
, s
);
7267 P
[2] := UpperCase(P
[2]);
7268 s
:= P
[1] + ':\' + P
[2];
7269 if g_Map_Exist(s
) then
7271 gExitByTrigger
:= False;
7275 gExit
:= EXIT_ENDLEVELCUSTOM
7284 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]))
7289 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]))
7295 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
])
7299 else if cmd
= 'nextmap' then
7301 if not(gGameOn
or (gState
= STATE_INTERCUSTOM
)) then
7303 g_Console_Add(_lc
[I_MSG_NOT_GAME
])
7308 if Length(P
) = 1 then
7310 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
7312 g_Console_Add(cmd
+ ' <MAP>');
7313 g_Console_Add(cmd
+ ' <WAD> [MAP]');
7318 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
7321 else if not e_IsValidResourceName(P
[1]) then
7323 g_Console_Add('wad name must not be absolute or relative');
7328 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
7330 if Length(P
) < 3 then
7332 // first param is map or wad
7333 s
:= UpperCase(P
[1]);
7334 if g_Map_Exist(gGameSettings
.WAD
+ ':\' + s
) then
7337 gExitByTrigger
:= False;
7343 // no such map, found wad
7344 pw
:= addWadExtension(P
[1]);
7345 found
:= e_FindResource(MapDirs
, pw
);
7347 found
:= e_FindResource(WadDirs
, pw
);
7349 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [s
, P
[1]]));
7352 // map not specified, select first map
7354 P
[2] := g_Game_GetFirstMap(P
[1]);
7355 s
:= P
[1] + ':\' + P
[2];
7356 if g_Map_Exist(s
) then
7358 gExitByTrigger
:= False;
7365 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
7367 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]))
7372 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]))
7378 // specified two params wad + map
7379 pw
:= addWadExtension(P
[1]);
7380 found
:= e_FindResource(MapDirs
, pw
);
7382 found
:= e_FindResource(MapDirs
, pw
);
7386 P
[2] := UpperCase(P
[2]);
7387 s
:= P
[1] + ':\' + P
[2];
7388 if g_Map_Exist(s
) then
7390 gExitByTrigger
:= False;
7396 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]))
7401 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]))
7407 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
])
7412 if gNextMap
= '' then
7413 g_Console_Add(_lc
[I_MSG_NEXTMAP_UNSET
])
7415 g_Console_Add(Format(_lc
[I_MSG_NEXTMAP_SET
], [gNextMap
]))
7419 else if (cmd
= 'endmap') or (cmd
= 'goodbye') then
7423 g_Console_Add(_lc
[I_MSG_NOT_GAME
])
7427 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
7429 gExitByTrigger
:= False;
7430 // next map not specified, try to find trigger EXIT
7431 if (gNextMap
= '') and (gTriggers
<> nil) then
7433 for a
:= 0 to High(gTriggers
) do
7435 if gTriggers
[a
].TriggerType
= TRIGGER_EXIT
then
7437 gExitByTrigger
:= True;
7438 //gNextMap := gTriggers[a].Data.MapName;
7439 gNextMap
:= gTriggers
[a
].tgcMap
;
7444 if gNextMap
= '' then
7445 gNextMap
:= g_Game_GetNextMap();
7446 if not isWadPath(gNextMap
) then
7447 s
:= gGameSettings
.WAD
+ ':\' + gNextMap
7450 if g_Map_Exist(s
) then
7451 gExit
:= EXIT_ENDLEVELCUSTOM
7453 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [gNextMap
]))
7457 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
])
7461 else if (cmd
= 'event') then
7463 if (Length(P
) <= 1) then
7465 for a
:= 0 to High(gEvents
) do
7466 if gEvents
[a
].Command
= '' then
7467 g_Console_Add(gEvents
[a
].Name
+ ' <none>')
7469 g_Console_Add(gEvents
[a
].Name
+ ' "' + gEvents
[a
].Command
+ '"');
7472 if (Length(P
) = 2) then
7474 for a
:= 0 to High(gEvents
) do
7475 if gEvents
[a
].Name
= P
[1] then
7476 if gEvents
[a
].Command
= '' then
7477 g_Console_Add(gEvents
[a
].Name
+ ' <none>')
7479 g_Console_Add(gEvents
[a
].Name
+ ' "' + gEvents
[a
].Command
+ '"');
7482 for a
:= 0 to High(gEvents
) do
7483 if gEvents
[a
].Name
= P
[1] then
7485 gEvents
[a
].Command
:= '';
7486 for b
:= 2 to High(P
) do
7487 if Pos(' ', P
[b
]) = 0 then
7488 gEvents
[a
].Command
:= gEvents
[a
].Command
+ ' ' + P
[b
]
7490 gEvents
[a
].Command
:= gEvents
[a
].Command
+ ' "' + P
[b
] + '"';
7491 gEvents
[a
].Command
:= Trim(gEvents
[a
].Command
);
7495 else if cmd
= 'suicide' then
7499 if g_Game_IsClient
then
7500 MC_SEND_CheatRequest(NET_CHEAT_SUICIDE
)
7503 if gPlayer1
<> nil then
7504 gPlayer1
.Damage(SUICIDE_DAMAGE
, gPlayer1
.UID
, 0, 0, HIT_SELF
);
7505 if gPlayer2
<> nil then
7506 gPlayer2
.Damage(SUICIDE_DAMAGE
, gPlayer2
.UID
, 0, 0, HIT_SELF
);
7510 else if cmd
= 'screenshot' then
7514 else if (cmd
= 'weapnext') or (cmd
= 'weapprev') then
7516 a
:= 1 - (ord(cmd
[5]) - ord('n'));
7518 gWeaponAction
[0, WP_PREV
] := True;
7520 gWeaponAction
[0, WP_NEXT
] := True;
7522 else if cmd
= 'weapon' then
7524 if Length(p
) = 2 then
7526 a
:= WP_FIRST
+ StrToIntDef(p
[1], 0) - 1;
7527 if (a
>= WP_FIRST
) and (a
<= WP_LAST
) then
7528 gSelectWeapon
[0, a
] := True
7531 else if (cmd
= 'p1_weapnext') or (cmd
= 'p1_weapprev')
7532 or (cmd
= 'p2_weapnext') or (cmd
= 'p2_weapprev') then
7534 a
:= 1 - (ord(cmd
[8]) - ord('n'));
7535 b
:= ord(cmd
[2]) - ord('1');
7537 gWeaponAction
[b
, WP_PREV
] := True;
7539 gWeaponAction
[b
, WP_NEXT
] := True;
7541 else if (cmd
= 'p1_weapon') or (cmd
= 'p2_weapon') then
7543 if Length(p
) = 2 then
7545 a
:= WP_FIRST
+ StrToIntDef(p
[1], 0) - 1;
7546 b
:= ord(cmd
[2]) - ord('1');
7547 if (a
>= WP_FIRST
) and (a
<= WP_LAST
) then
7548 gSelectWeapon
[b
, a
] := True
7551 else if (cmd
= 'p1_weapbest') or (cmd
= 'p2_weapbest') then
7553 b
:= ord(cmd
[2]) - ord('1');
7555 gSelectWeapon
[b
, gPlayer1
.GetMorePrefered()] := True
7557 gSelectWeapon
[b
, gPlayer2
.GetMorePrefered()] := True;
7559 else if (cmd
= 'dropflag') then
7561 if g_Game_IsServer
then
7563 if gPlayer2
<> nil then gPlayer2
.TryDropFlag();
7564 if gPlayer1
<> nil then gPlayer1
.TryDropFlag();
7567 MC_SEND_CheatRequest(NET_CHEAT_DROPFLAG
);
7569 else if (cmd
= 'p1_dropflag') or (cmd
= 'p2_dropflag') then
7571 b
:= ord(cmd
[2]) - ord('1');
7572 if g_Game_IsServer
then
7574 if (b
= 1) and (gPlayer2
<> nil) then gPlayer2
.TryDropFlag()
7575 else if (b
= 0) and (gPlayer1
<> nil) then gPlayer1
.TryDropFlag();
7578 MC_SEND_CheatRequest(NET_CHEAT_DROPFLAG
);
7580 // Êîìàíäû Ñâîåé èãðû:
7581 else if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
7583 if cmd
= 'bot_addred' then
7585 if Length(P
) > 1 then
7586 g_Bot_Add(TEAM_RED
, StrToIntDef(P
[1], 2))
7588 g_Bot_Add(TEAM_RED
, 2);
7590 else if cmd
= 'bot_addblue' then
7592 if Length(P
) > 1 then
7593 g_Bot_Add(TEAM_BLUE
, StrToIntDef(P
[1], 2))
7595 g_Bot_Add(TEAM_BLUE
, 2);
7597 else if cmd
= 'spectate' then
7603 else if cmd
= 'say' then
7605 if g_Game_IsServer
and g_Game_IsNet
then
7607 if Length(P
) > 1 then
7610 for a
:= 1 to High(P
) do
7611 chstr
:= chstr
+ P
[a
] + ' ';
7613 if Length(chstr
) > 200 then SetLength(chstr
, 200);
7615 if Length(chstr
) < 1 then
7617 g_Console_Add('say <text>');
7621 chstr
:= b_Text_Format(chstr
);
7622 MH_SEND_Chat(chstr
, NET_CHAT_PLAYER
);
7624 else g_Console_Add('say <text>');
7626 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
7628 else if cmd
= 'tell' then
7630 if g_Game_IsServer
and g_Game_IsNet
then
7632 if (Length(P
) > 2) and (P
[1] <> '') then
7635 for a
:= 2 to High(P
) do
7636 chstr
:= chstr
+ P
[a
] + ' ';
7638 if Length(chstr
) > 200 then SetLength(chstr
, 200);
7640 if Length(chstr
) < 1 then
7642 g_Console_Add('tell <playername> <text>');
7646 pl
:= g_Net_Client_ByName(P
[1]);
7648 MH_SEND_Chat(b_Text_Format(chstr
), NET_CHAT_PLAYER
, pl
^.ID
)
7650 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
7652 else g_Console_Add('tell <playername> <text>');
7654 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
7656 else if cmd
= 'centerprint' then
7658 if (Length(P
) > 2) and (P
[1] <> '') then
7661 for a
:= 2 to High(P
) do
7662 chstr
:= chstr
+ P
[a
] + ' ';
7664 if Length(chstr
) > 200 then SetLength(chstr
, 200);
7666 if Length(chstr
) < 1 then
7668 g_Console_Add('centerprint <timeout> <text>');
7672 a
:= StrToIntDef(P
[1], 100);
7673 chstr
:= b_Text_Format(chstr
);
7674 g_Game_Message(chstr
, a
);
7675 if g_Game_IsNet
and g_Game_IsServer
then
7676 MH_SEND_GameEvent(NET_EV_BIGTEXT
, a
, chstr
);
7678 else g_Console_Add('centerprint <timeout> <text>');
7680 else if (cmd
= 'overtime') and not g_Game_IsClient
then
7682 if (Length(P
) = 1) or (StrToIntDef(P
[1], -1) <= 0) then
7684 // Äîïîëíèòåëüíîå âðåìÿ:
7685 gGameSettings
.TimeLimit
:= (gTime
- gGameStartTime
) div 1000 + Word(StrToIntDef(P
[1], 0));
7687 g_Console_Add(Format(_lc
[I_MSG_TIME_LIMIT
],
7688 [gGameSettings
.TimeLimit
div 3600,
7689 (gGameSettings
.TimeLimit
div 60) mod 60,
7690 gGameSettings
.TimeLimit
mod 60]));
7691 if g_Game_IsNet
then MH_SEND_GameSettings
;
7693 else if (cmd
= 'rcon_password') and g_Game_IsClient
then
7695 if (Length(P
) <= 1) then
7696 g_Console_Add('rcon_password <password>')
7698 MC_SEND_RCONPassword(P
[1]);
7700 else if cmd
= 'rcon' then
7702 if g_Game_IsClient
then
7704 if Length(P
) > 1 then
7707 for a
:= 1 to High(P
) do
7708 chstr
:= chstr
+ P
[a
] + ' ';
7710 if Length(chstr
) > 200 then SetLength(chstr
, 200);
7712 if Length(chstr
) < 1 then
7714 g_Console_Add('rcon <command>');
7718 MC_SEND_RCONCommand(chstr
);
7720 else g_Console_Add('rcon <command>');
7723 else if cmd
= 'ready' then
7725 if g_Game_IsServer
and (gLMSRespawn
= LMS_RESPAWN_WARMUP
) then
7726 gLMSRespawnTime
:= gTime
+ 100;
7728 else if (cmd
= 'callvote') and g_Game_IsNet
then
7730 if Length(P
) > 1 then
7733 for a
:= 1 to High(P
) do begin
7734 if a
> 1 then chstr
:= chstr
+ ' ';
7735 chstr
:= chstr
+ P
[a
];
7738 if Length(chstr
) > 200 then SetLength(chstr
, 200);
7740 if Length(chstr
) < 1 then
7742 g_Console_Add('callvote <command>');
7746 if g_Game_IsClient
then
7747 MC_SEND_Vote(True, chstr
)
7749 g_Game_StartVote(chstr
, gPlayer1Settings
.Name
);
7750 g_Console_Process('vote', True);
7753 g_Console_Add('callvote <command>');
7755 else if (cmd
= 'vote') and g_Game_IsNet
then
7757 if g_Game_IsClient
then
7759 else if gVoteInProgress
then
7761 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
7762 a
:= Floor((NetClientCount
+1)/2.0) + 1
7764 a
:= Floor(NetClientCount
/2.0) + 1;
7769 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_REVOKED
], [gPlayer1Settings
.Name
, gVoteCount
, a
]), True);
7770 MH_SEND_VoteEvent(NET_VE_REVOKE
, gPlayer1Settings
.Name
, 'a', gVoteCount
, a
);
7776 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_VOTE
], [gPlayer1Settings
.Name
, gVoteCount
, a
]), True);
7777 MH_SEND_VoteEvent(NET_VE_VOTE
, gPlayer1Settings
.Name
, 'a', gVoteCount
, a
);
7785 procedure SystemCommands(P
: SSArray
);
7789 cmd
:= LowerCase(P
[0]);
7798 gRC_Width
:= Max(1, gRC_Width
);
7799 gRC_Height
:= Max(1, gRC_Height
);
7800 gBPP
:= Max(1, gBPP
);
7801 if sys_SetDisplayMode(gRC_Width
, gRC_Height
, gBPP
, gRC_FullScreen
, gRC_Maximized
) = True then
7802 e_LogWriteln('resolution changed')
7804 e_LogWriteln('resolution not changed');
7805 sys_EnableVSync(gVSync
);
7809 if Length(p
) = 2 then
7811 gMaxFPS
:= StrToIntDef(p
[1], gMaxFPS
);
7813 gFrameTime
:= 1000 div gMaxFPS
7817 e_LogWritefln('r_maxfps %d', [gMaxFPS
]);
7821 if Length(p
) = 2 then
7823 gAskLanguage
:= true;
7824 gLanguage
:= LANGUAGE_ENGLISH
;
7825 case LowerCase(p
[1]) of
7828 gAskLanguage
:= false;
7829 gLanguage
:= LANGUAGE_ENGLISH
;
7833 gAskLanguage
:= false;
7834 gLanguage
:= LANGUAGE_RUSSIAN
;
7838 gAskLanguage
:= true;
7839 gLanguage
:= LANGUAGE_ENGLISH
;
7842 g_Language_Set(gLanguage
);
7846 e_LogWritefln('usage: %s <English|Russian|Ask>', [cmd
]);
7852 procedure g_TakeScreenShot(Filename
: string = '');
7853 var s
: TStream
; t
: TDateTime
; dir
, date
, name
: String;
7855 if e_NoGraphics
then Exit
;
7857 dir
:= e_GetWriteableDir(ScreenshotDirs
);
7859 if Filename
= '' then
7862 DateTimeToString(date
, 'yyyy-mm-dd-hh-nn-ss', t
);
7863 Filename
:= 'screenshot-' + date
;
7866 name
:= e_CatPath(dir
, Filename
+ '.png');
7867 s
:= createDiskFile(name
);
7869 e_MakeScreenshot(s
, gWinSizeX
, gWinSizeY
);
7871 g_Console_Add(Format(_lc
[I_CONSOLE_SCREENSHOT
], [name
]))
7873 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_WRITE
], [name
]));
7878 g_Console_Add('oh shit, i can''t create screenshot!')
7882 procedure g_Game_InGameMenu(Show
: Boolean);
7884 if (g_ActiveWindow
= nil) and Show
then
7886 if gGameSettings
.GameType
= GT_SINGLE
then
7887 g_GUI_ShowWindow('GameSingleMenu')
7890 if g_Game_IsClient
then
7891 g_GUI_ShowWindow('GameClientMenu')
7893 if g_Game_IsNet
then
7894 g_GUI_ShowWindow('GameServerMenu')
7896 g_GUI_ShowWindow('GameCustomMenu');
7898 g_Sound_PlayEx('MENU_OPEN');
7900 // Ïàóçà ïðè ìåíþ òîëüêî â îäèíî÷íîé èãðå:
7901 if (not g_Game_IsNet
) then
7905 if (g_ActiveWindow
<> nil) and (not Show
) then
7907 // Ïàóçà ïðè ìåíþ òîëüêî â îäèíî÷íîé èãðå:
7908 if (not g_Game_IsNet
) then
7909 g_Game_Pause(False);
7913 procedure g_Game_Pause (Enable
: Boolean);
7917 if not gGameOn
then exit
;
7919 if not (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
]) then exit
;
7922 gPauseMain
:= Enable
;
7924 if (gPause
<> oldPause
) then g_Game_PauseAllSounds(gPause
);
7927 procedure g_Game_HolmesPause (Enable
: Boolean);
7931 if not gGameOn
then exit
;
7932 if not (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
]) then exit
;
7935 gPauseHolmes
:= Enable
;
7937 if (gPause
<> oldPause
) then g_Game_PauseAllSounds(gPause
);
7940 procedure g_Game_PauseAllSounds(Enable
: Boolean);
7945 if gTriggers
<> nil then
7946 for i
:= 0 to High(gTriggers
) do
7947 with gTriggers
[i
] do
7948 if (TriggerType
= TRIGGER_SOUND
) and
7950 Sound
.IsPlaying() then
7952 Sound
.Pause(Enable
);
7956 if gPlayers
<> nil then
7957 for i
:= 0 to High(gPlayers
) do
7958 if gPlayers
[i
] <> nil then
7959 gPlayers
[i
].PauseSounds(Enable
);
7962 if gMusic
<> nil then
7963 gMusic
.Pause(Enable
);
7966 procedure g_Game_StopAllSounds(all
: Boolean);
7970 if gTriggers
<> nil then
7971 for i
:= 0 to High(gTriggers
) do
7972 with gTriggers
[i
] do
7973 if (TriggerType
= TRIGGER_SOUND
) and
7977 if gMusic
<> nil then
7984 procedure g_Game_UpdateTriggerSounds
;
7987 if gTriggers
<> nil then
7988 for i
:= 0 to High(gTriggers
) do
7989 with gTriggers
[i
] do
7990 if (TriggerType
= TRIGGER_SOUND
) and (Sound
<> nil) and tgcLocal
and Sound
.IsPlaying() then
7991 Sound
.SetCoordsRect(X
, Y
, Width
, Height
, tgcVolume
/ 255.0)
7994 function g_Game_IsWatchedPlayer(UID
: Word): Boolean;
7997 if (gPlayer1
<> nil) and (gPlayer1
.UID
= UID
) then
8002 if (gPlayer2
<> nil) and (gPlayer2
.UID
= UID
) then
8007 if gSpectMode
<> SPECT_PLAYERS
then
8009 if gSpectPID1
= UID
then
8014 if gSpectViewTwo
and (gSpectPID2
= UID
) then
8021 function g_Game_IsWatchedTeam(Team
: Byte): Boolean;
8026 if (gPlayer1
<> nil) and (gPlayer1
.Team
= Team
) then
8031 if (gPlayer2
<> nil) and (gPlayer2
.Team
= Team
) then
8036 if gSpectMode
<> SPECT_PLAYERS
then
8038 Pl
:= g_Player_Get(gSpectPID1
);
8039 if (Pl
<> nil) and (Pl
.Team
= Team
) then
8044 if gSpectViewTwo
then
8046 Pl
:= g_Player_Get(gSpectPID2
);
8047 if (Pl
<> nil) and (Pl
.Team
= Team
) then
8055 procedure g_Game_Message(Msg
: string; Time
: Word);
8057 MessageLineLength
:= (gScreenWidth
- 204) div e_CharFont_GetMaxWidth(gMenuFont
);
8058 MessageText
:= b_Text_Wrap(b_Text_Format(Msg
), MessageLineLength
);
8059 MessageTime
:= Time
;
8062 procedure g_Game_ChatSound(Text: String; Taunt
: Boolean = True);
8064 punct
: Array[0..13] of String =
8065 ('.', ',', ':', ';', '!', '?', '(', ')', '''', '"', '/', '\', '*', '^');
8071 function IsPunctuation(S
: String): Boolean;
8076 if Length(S
) <> 1 then
8078 for i
:= Low(punct
) to High(punct
) do
8079 if S
= punct
[i
] then
8085 function FilterPunctuation(S
: String): String;
8089 for i
:= Low(punct
) to High(punct
) do
8090 S
:= StringReplace(S
, punct
[i
], ' ', [rfReplaceAll
]);
8096 if gUseChatSounds
and Taunt
and (gChatSounds
<> nil) and (Pos(': ', Text) > 0) then
8098 // remove player name
8099 Delete(Text, 1, Pos(': ', Text) + 2 - 1);
8100 // for FullWord check
8101 Text := toLowerCase1251(' ' + Text + ' ');
8102 fpText
:= FilterPunctuation(Text);
8104 for i
:= 0 to Length(gChatSounds
) - 1 do
8107 for j
:= 0 to Length(gChatSounds
[i
].Tags
) - 1 do
8109 if gChatSounds
[i
].FullWord
and (not IsPunctuation(gChatSounds
[i
].Tags
[j
])) then
8110 ok
:= Pos(' ' + gChatSounds
[i
].Tags
[j
] + ' ', fpText
) > 0
8112 ok
:= Pos(gChatSounds
[i
].Tags
[j
], Text) > 0;
8118 gChatSounds
[i
].Sound
.Play();
8124 g_Sound_PlayEx('SOUND_GAME_RADIO');
8127 procedure g_Game_Announce_GoodShot(SpawnerUID
: Word);
8136 if not g_Game_IsWatchedPlayer(SpawnerUID
) then
8140 if goodsnd
[a
].IsPlaying() then
8143 goodsnd
[Random(4)].Play();
8146 procedure g_Game_Announce_KillCombo(Param
: Integer);
8153 UID
:= Param
and $FFFF;
8158 Pl
:= g_Player_Get(UID
);
8167 g_Console_Add(Format(_lc
[I_PLAYER_KILL_2X
], [Name
]), True);
8171 g_Console_Add(Format(_lc
[I_PLAYER_KILL_3X
], [Name
]), True);
8175 g_Console_Add(Format(_lc
[I_PLAYER_KILL_4X
], [Name
]), True);
8179 g_Console_Add(Format(_lc
[I_PLAYER_KILL_MX
], [Name
]), True);
8187 if not g_Game_IsWatchedPlayer(UID
) then
8190 if (not g_Game_IsWatchedPlayer(UID
)) and (c
< 4) then
8194 if killsnd
[n
].IsPlaying() then
8199 procedure g_Game_Announce_BodyKill(SpawnerUID
: Word);
8207 if not g_Game_IsWatchedPlayer(SpawnerUID
) then
8211 if hahasnd
[a
].IsPlaying() then
8214 hahasnd
[Random(3)].Play();
8217 procedure g_Game_Effect_Bubbles (fX
, fY
: Integer; count
: Word; devX
, devY
: Byte; Silent
: Boolean);
8219 g_GFX_Bubbles(fX
, fY
, count
, devX
, devY
);
8220 if not Silent
then if Random(2) = 0
8221 then g_Sound_PlayExAt('SOUND_GAME_BUBBLE1', fX
, fY
)
8222 else g_Sound_PlayExAt('SOUND_GAME_BUBBLE2', fX
, fY
);
8225 procedure g_Game_StartVote(Command
, Initiator
: string);
8229 if not gVotesEnabled
then Exit
;
8230 if gGameSettings
.GameType
<> GT_SERVER
then Exit
;
8231 if gVoteInProgress
or gVotePassed
then
8233 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_INPROGRESS
], [gVoteCommand
]), True);
8234 MH_SEND_VoteEvent(NET_VE_INPROGRESS
, gVoteCommand
);
8237 gVoteInProgress
:= True;
8238 gVotePassed
:= False;
8239 gVoteTimer
:= gTime
+ gVoteTimeout
* 1000;
8242 gVoteCommand
:= Command
;
8244 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
8245 Need
:= Floor((NetClientCount
+1)/2.0)+1
8247 Need
:= Floor(NetClientCount
/2.0)+1;
8248 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_STARTED
], [Initiator
, Command
, Need
]), True);
8249 MH_SEND_VoteEvent(NET_VE_STARTED
, Initiator
, Command
, Need
);
8252 procedure g_Game_CheckVote
;
8256 if gGameSettings
.GameType
<> GT_SERVER
then Exit
;
8257 if not gVoteInProgress
then Exit
;
8259 if (gTime
>= gVoteTimer
) then
8261 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
8262 Need
:= Floor((NetClientCount
+1)/2.0) + 1
8264 Need
:= Floor(NetClientCount
/2.0) + 1;
8265 if gVoteCount
>= Need
then
8267 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_PASSED
], [gVoteCommand
]), True);
8268 MH_SEND_VoteEvent(NET_VE_PASSED
, gVoteCommand
);
8269 gVotePassed
:= True;
8270 gVoteCmdTimer
:= gTime
+ 5000;
8274 g_Console_Add(_lc
[I_MESSAGE_VOTE_FAILED
], True);
8275 MH_SEND_VoteEvent(NET_VE_FAILED
);
8277 if NetClients
<> nil then
8278 for I
:= Low(NetClients
) to High(NetClients
) do
8279 if NetClients
[i
].Used
then
8280 NetClients
[i
].Voted
:= False;
8281 gVoteInProgress
:= False;
8287 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
8288 Need
:= Floor((NetClientCount
+1)/2.0) + 1
8290 Need
:= Floor(NetClientCount
/2.0) + 1;
8291 if gVoteCount
>= Need
then
8293 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_PASSED
], [gVoteCommand
]), True);
8294 MH_SEND_VoteEvent(NET_VE_PASSED
, gVoteCommand
);
8295 gVoteInProgress
:= False;
8296 gVotePassed
:= True;
8297 gVoteCmdTimer
:= gTime
+ 5000;
8300 if NetClients
<> nil then
8301 for I
:= Low(NetClients
) to High(NetClients
) do
8302 if NetClients
[i
].Used
then
8303 NetClients
[i
].Voted
:= False;
8308 procedure g_Game_LoadMapList(FileName
: string);
8316 if not FileExists(FileName
) then Exit
;
8318 AssignFile(ListFile
, FileName
);
8320 while not EOF(ListFile
) do
8322 ReadLn(ListFile
, s
);
8325 if s
= '' then Continue
;
8327 SetLength(MapList
, Length(MapList
)+1);
8328 MapList
[High(MapList
)] := s
;
8330 CloseFile(ListFile
);
8333 procedure g_Game_SetDebugMode();
8336 // ×èòû (äàæå â ñâîåé èãðå):
8340 procedure g_Game_SetLoadingText(Text: String; Max
: Integer; reWrite
: Boolean);
8344 if Length(LoadingStat
.Msgs
) = 0 then
8350 begin // Ïåðåõîäèì íà ñëåäóþùóþ ñòðîêó èëè ñêðîëëèðóåì:
8351 if NextMsg
= Length(Msgs
) then
8353 for i
:= 0 to High(Msgs
)-1 do
8354 Msgs
[i
] := Msgs
[i
+1];
8362 Msgs
[NextMsg
-1] := Text;
8366 PBarWasHere
:= false;
8369 g_ActiveWindow
:= nil;
8370 ProcessLoading(True);
8373 procedure g_Game_StepLoading(Value
: Integer = -1);
8385 if (ShowCount
> LOADING_SHOW_STEP
) or (Value
> -1) then
8388 ProcessLoading(False);
8393 procedure g_Game_ClearLoading();
8402 len
:= ((gScreenHeight
div 3)*2 - 50) div LOADING_INTERLINE
;
8403 if len
< 1 then len
:= 1;
8404 SetLength(Msgs
, len
);
8405 for len
:= Low(Msgs
) to High(Msgs
) do
8408 PBarWasHere
:= false;
8412 procedure Parse_Params(var pars
: TParamStrValues
);
8419 while i
<= ParamCount
do
8422 if (Length(s
) > 1) and (s
[1] = '-') then
8424 if (Length(s
) > 2) and (s
[2] = '-') then
8425 begin // Îäèíî÷íûé ïàðàìåòð
8426 SetLength(pars
, Length(pars
) + 1);
8427 with pars
[High(pars
)] do
8429 Name
:= LowerCase(s
);
8434 if (i
< ParamCount
) then
8435 begin // Ïàðàìåòð ñî çíà÷åíèåì
8437 SetLength(pars
, Length(pars
) + 1);
8438 with pars
[High(pars
)] do
8440 Name
:= LowerCase(s
);
8441 Value
:= LowerCase(ParamStr(i
));
8450 function Find_Param_Value(var pars
: TParamStrValues
; aName
: String): String;
8455 for i
:= 0 to High(pars
) do
8456 if pars
[i
].Name
= aName
then
8458 Result
:= pars
[i
].Value
;
8463 procedure g_Game_Process_Params();
8465 pars
: TParamStrValues
;
8468 LimT
, LimS
: Integer;
8479 s
:= Find_Param_Value(pars
, '--debug');
8482 g_Game_SetDebugMode();
8483 s
:= Find_Param_Value(pars
, '--netdump');
8488 // Connect when game loads
8489 ip
:= Find_Param_Value(pars
, '-connect');
8493 s
:= Find_Param_Value(pars
, '-port');
8494 if (s
= '') or not TryStrToInt(s
, Port
) then
8497 s
:= Find_Param_Value(pars
, '-pw');
8499 g_Game_StartClient(ip
, Port
, s
);
8503 s
:= LowerCase(Find_Param_Value(pars
, '-dbg-mainwad'));
8506 gDefaultMegawadStart
:= s
;
8509 if (Find_Param_Value(pars
, '--dbg-mainwad-restore') <> '') or
8510 (Find_Param_Value(pars
, '--dbg-mainwad-default') <> '') then
8512 gDefaultMegawadStart
:= DF_Default_Megawad_Start
;
8515 // Start map when game loads:
8516 map
:= LowerCase(Find_Param_Value(pars
, '-map'));
8517 if isWadPath(map
) then
8520 s
:= Find_Param_Value(pars
, '-gm');
8521 GMode
:= g_Game_TextToMode(s
);
8522 if GMode
= GM_NONE
then GMode
:= GM_DM
;
8523 if GMode
= GM_SINGLE
then GMode
:= GM_COOP
;
8526 s
:= Find_Param_Value(pars
, '-limt');
8527 if (s
= '') or (not TryStrToInt(s
, LimT
)) then
8533 s
:= Find_Param_Value(pars
, '-lims');
8534 if (s
= '') or (not TryStrToInt(s
, LimS
)) then
8540 s
:= Find_Param_Value(pars
, '-lives');
8541 if (s
= '') or (not TryStrToInt(s
, Lives
)) then
8547 s
:= Find_Param_Value(pars
, '-opt');
8551 Opt
:= StrToIntDef(s
, 0);
8554 s
:= Find_Param_Value(pars
, '--close');
8558 // Override map to test:
8559 s
:= LowerCase(Find_Param_Value(pars
, '-testmap'));
8562 if e_IsValidResourceName(s
) then
8563 e_FindResource(AllMapDirs
, s
);
8564 gTestMap
:= ExpandFileName(s
);
8567 // Delete test map after play:
8568 s
:= Find_Param_Value(pars
, '--testdelete');
8571 //gMapToDelete := MapsDir + map;
8572 e_WriteLog('"--testdelete" is deprecated, use --tempdelete.', TMsgType
.Fatal
);
8576 // Delete temporary WAD after play:
8577 s
:= Find_Param_Value(pars
, '--tempdelete');
8578 if (s
<> '') and (gTestMap
<> '') then
8580 gMapToDelete
:= gTestMap
;
8581 gTempDelete
:= True;
8584 // Number of players:
8585 s
:= Find_Param_Value(pars
, '-pl');
8587 n
:= DEFAULT_PLAYERS
8589 n
:= StrToIntDef(s
, DEFAULT_PLAYERS
);
8592 s
:= Find_Param_Value(pars
, '-port');
8593 if (s
= '') or not TryStrToInt(s
, Port
) then
8594 g_Game_StartCustom(map
, GMode
, LimT
, LimS
, Lives
, Opt
, n
)
8596 g_Game_StartServer(map
, GMode
, LimT
, LimS
, Lives
, Opt
, n
, 0, Port
);
8599 // Execute script when game loads:
8600 s
:= Find_Param_Value(pars
, '-exec');
8603 // if not isWadPath(s) then
8604 // s := GameDir + '/' + s;
8609 if IOResult
<> 0 then
8611 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], ['Failed to read file: ' + s
]), TMsgType
.Warning
);
8612 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_READ
], [s
]));
8616 e_WriteLog('Executing script: ' + s
, TMsgType
.Notify
);
8617 g_Console_Add(Format(_lc
[I_CONSOLE_EXEC
], [s
]));
8622 if IOResult
<> 0 then
8624 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], ['Failed to read file: ' + s
]), TMsgType
.Warning
);
8625 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_READ
], [s
]));
8629 if Pos('#', s
) <> 1 then // script comment
8630 g_Console_Process(s
, True);
8641 conRegVar('pf_draw_frame', @g_profile_frame_draw
, 'draw frame rendering profiles', 'render profiles');
8642 //conRegVar('pf_update_frame', @g_profile_frame_update, 'draw frame updating profiles', 'update profiles');
8643 conRegVar('pf_coldet', @g_profile_collision
, 'draw collision detection profiles', 'coldet profiles');
8644 conRegVar('pf_los', @g_profile_los
, 'draw monster LOS profiles', 'monster LOS profiles');
8646 conRegVar('r_sq_draw', @gdbg_map_use_accel_render
, 'accelerated spatial queries in rendering', 'accelerated rendering');
8647 conRegVar('cd_sq_enabled', @gdbg_map_use_accel_coldet
, 'accelerated spatial queries in map coldet', 'accelerated map coldet');
8648 conRegVar('mon_sq_enabled', @gmon_debug_use_sqaccel
, 'accelerated spatial queries for monsters', 'accelerated monster coldet');
8649 conRegVar('wtrace_sq_enabled', @gwep_debug_fast_trace
, 'accelerated spatial queries for weapon hitscan trace', 'accelerated weapon hitscan');
8651 conRegVar('pr_enabled', @gpart_dbg_enabled
, 'enable/disable particles', 'particles');
8652 conRegVar('pr_phys_enabled', @gpart_dbg_phys_enabled
, 'enable/disable particle physics', 'particle physics');
8654 conRegVar('los_enabled', @gmon_dbg_los_enabled
, 'enable/disable monster LOS calculations', 'monster LOS', true);
8655 conRegVar('mon_think', @gmon_debug_think
, 'enable/disable monster thinking', 'monster thinking', true);
8657 {$IFDEF ENABLE_HOLMES}
8658 conRegVar('dbg_holmes', @g_holmes_enabled
, 'enable/disable Holmes', 'Holmes', true);
8661 conRegVar('dbg_ignore_level_bounds', @g_dbg_ignore_bounds
, 'ignore level bounds', '', false);
8663 conRegVar('r_scale', @g_dbg_scale
, 0.01, 100.0, 'render scale', '', false);
8664 conRegVar('r_resolution_scale', @r_pixel_scale
, 0.01, 100.0, 'upscale factor', '', false);
8666 conRegVar('light_enabled', @gwin_k8_enable_light_experiments
, 'enable/disable dynamic lighting', 'lighting');
8667 conRegVar('light_player_halo', @g_playerLight
, 'enable/disable player halo', 'player light halo');
8669 conRegVar('r_smallmap_align_h', @r_smallmap_h
, 'halign: 0: left; 1: center; 2: right', 'horizontal aligning of small maps');
8670 conRegVar('r_smallmap_align_v', @r_smallmap_v
, 'valign: 0: top; 1: center; 2: bottom', 'vertial aligning of small maps');
8672 conRegVar('r_showfps', @gShowFPS
, 'draw fps counter', 'draw fps counter');
8673 conRegVar('r_showtime', @gShowTime
, 'show game time', 'show game time');
8674 conRegVar('r_showping', @gShowPing
, 'show ping', 'show ping');
8675 conRegVar('r_showscore', @gShowScore
, 'show score', 'show score');
8676 conRegVar('r_showkillmsg', @gShowKillMsg
, 'show kill log', 'show kill log');
8677 conRegVar('r_showlives', @gShowLives
, 'show lives', 'show lives');
8678 conRegVar('r_showspect', @gSpectHUD
, 'show spectator hud', 'show spectator hud');
8679 conRegVar('r_showstat', @gShowStat
, 'show stats', 'show stats');
8680 conRegVar('r_showpids', @gShowPIDs
, 'show PIDs', 'show PIDs');