1 (* Copyright (C) Doom 2D: Forever Developers
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, version 3 of the License ONLY.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 {$INCLUDE ../shared/a_modes.inc}
23 g_basic
, g_player
, e_graphics
, g_res_downloader
,
24 g_sound
, g_gui
, utils
, md5
, mempool
, xprofiler
,
28 TGameSettings
= record
35 ItemRespawnTime
: Word;
36 RulezTimeMultiplier
: Word;
47 TDelayedEvent
= record
56 Sound
: TPlayableSound
;
57 Tags
: Array of String;
61 TPlayerSettings
= record
66 // ones below are sent only to the server
68 WeaponPreferences
: Array[WP_FIRST
..WP_LAST
+1] of Byte;
85 function g_Game_IsNet(): Boolean;
86 function g_Game_IsServer(): Boolean;
87 function g_Game_IsClient(): Boolean;
88 procedure g_Game_Init();
89 procedure g_Game_Free (freeTextures
: Boolean=true);
90 procedure g_Game_LoadData();
91 procedure g_Game_FreeData();
92 procedure g_Game_Update();
93 procedure g_Game_PreUpdate();
94 procedure g_Game_Draw();
95 procedure g_Game_Quit();
96 procedure g_Game_SetupScreenSize();
97 procedure g_Game_ChangeResolution(newWidth
, newHeight
: Word; nowFull
, nowMax
: Boolean);
98 function g_Game_ModeToText(Mode
: Byte): string;
99 function g_Game_TextToMode(Mode
: string): Byte;
100 procedure g_Game_ExecuteEvent(Name
: String);
101 function g_Game_DelayEvent(DEType
: Byte; Time
: LongWord; Num
: Integer = 0; Str
: String = ''): Integer;
102 procedure g_Game_AddPlayer(Team
: Byte = TEAM_NONE
);
103 procedure g_Game_RemovePlayer();
104 procedure g_Game_Spectate();
105 procedure g_Game_SpectateCenterView();
106 procedure g_Game_StartSingle(Map
: String; TwoPlayers
: Boolean; nPlayers
: Byte);
107 procedure g_Game_StartCustom(Map
: String; GameMode
: Byte; TimeLimit
, ScoreLimit
: Word; MaxLives
: Byte; Options
: LongWord; nPlayers
: Byte);
108 procedure g_Game_StartServer(Map
: String; GameMode
: Byte; TimeLimit
, ScoreLimit
: Word; MaxLives
: Byte; Options
: LongWord; nPlayers
: Byte; IPAddr
: LongWord; Port
: Word);
109 procedure g_Game_StartClient(Addr
: String; Port
: Word; PW
: String);
110 procedure g_Game_Restart();
111 procedure g_Game_RestartLevel();
112 procedure g_Game_RestartRound(NoMapRestart
: Boolean = False);
113 function g_Game_ClientWAD (NewWAD
: String; const WHash
: TMD5Digest
): AnsiString;
114 function g_Game_StartMap(asMegawad
: Boolean; Map
: String; Force
: Boolean = False; const oldMapPath
: AnsiString=''): Boolean;
115 procedure g_Game_ChangeMap(const MapPath
: String);
116 procedure g_Game_ExitLevel(const Map
: AnsiString);
117 function g_Game_GetFirstMap(WAD
: String): String;
118 function g_Game_GetNextMap(): String;
119 procedure g_Game_NextLevel();
120 procedure g_Game_Pause(Enable
: Boolean);
121 procedure g_Game_HolmesPause(Enable
: Boolean);
122 procedure g_Game_InGameMenu(Show
: Boolean);
123 function g_Game_IsWatchedPlayer(UID
: Word): Boolean;
124 function g_Game_IsWatchedTeam(Team
: Byte): Boolean;
125 procedure g_Game_Message(Msg
: String; Time
: Word);
126 procedure g_Game_LoadMapList(FileName
: String);
127 procedure g_Game_PauseAllSounds(Enable
: Boolean);
128 procedure g_Game_StopAllSounds(all
: Boolean);
129 procedure g_Game_UpdateTriggerSounds();
130 function g_Game_GetMegaWADInfo(WAD
: String): TMegaWADInfo
;
131 procedure g_Game_ChatSound(Text: String; Taunt
: Boolean = True);
132 procedure g_Game_Announce_GoodShot(SpawnerUID
: Word);
133 procedure g_Game_Announce_KillCombo(Param
: Integer);
134 procedure g_Game_Announce_BodyKill(SpawnerUID
: Word);
135 procedure g_Game_Effect_Bubbles(fX
, fY
: Integer; count
: Word; devX
, devY
: Byte; Silent
: Boolean = False);
136 procedure g_Game_StartVote(Command
, Initiator
: string);
137 procedure g_Game_CheckVote
;
138 procedure g_TakeScreenShot(Filename
: string = '');
139 procedure g_FatalError(Text: String);
140 procedure g_SimpleError(Text: String);
141 function g_Game_IsTestMap(): Boolean;
142 procedure g_Game_DeleteTestMap();
143 procedure GameCVars(P
: SSArray
);
144 procedure PlayerSettingsCVars(P
: SSArray
);
145 procedure SystemCommands(P
: SSArray
);
146 procedure GameCommands(P
: SSArray
);
147 procedure GameCheats(P
: SSArray
);
148 procedure DebugCommands(P
: SSArray
);
149 procedure g_Game_Process_Params
;
150 procedure g_Game_SetLoadingText(Text: String; Max
: Integer; reWrite
: Boolean);
151 procedure g_Game_StepLoading(Value
: Integer = -1);
152 procedure g_Game_ClearLoading();
153 procedure g_Game_SetDebugMode();
154 procedure DrawLoadingStat();
155 procedure DrawMenuBackground(tex
: AnsiString);
157 { procedure SetWinPause(Enable: Boolean); }
162 LOADING_SHOW_STEP
= 100;
163 LOADING_INTERLINE
= 20;
178 MESSAGE_DIKEY
= WM_USER
+ 1;
183 EXIT_ENDLEVELSINGLE
= 4;
184 EXIT_ENDLEVELCUSTOM
= 5;
186 GAME_OPTION_RESERVED
= 1;
187 GAME_OPTION_TEAMDAMAGE
= 2;
188 GAME_OPTION_ALLOWEXIT
= 4;
189 GAME_OPTION_WEAPONSTAY
= 8;
190 GAME_OPTION_MONSTERS
= 16;
191 GAME_OPTION_BOTVSPLAYER
= 32;
192 GAME_OPTION_BOTVSMONSTER
= 64;
193 GAME_OPTION_DMKEYS
= 128;
194 GAME_OPTION_TEAMHITTRACE
= 256;
195 GAME_OPTION_TEAMHITPROJECTILE
= 512;
196 GAME_OPTION_TEAMABSORBDAMAGE
= 1024;
197 GAME_OPTION_ALLOWDROPFLAG
= 2048;
198 GAME_OPTION_THROWFLAG
= 4096;
199 GAME_OPTION_RULEZRANDOM
= 8192;
204 STATE_INTERCUSTOM
= 3;
205 STATE_INTERSINGLE
= 4;
211 LMS_RESPAWN_NONE
= 0;
212 LMS_RESPAWN_WARMUP
= 1;
213 LMS_RESPAWN_FINAL
= 2;
230 CONFIG_FILENAME
= 'Doom2DF.cfg';
232 TEST_MAP_NAME
= '$$$_TEST_$$$';
234 STD_PLAYER_MODEL
= 'Doomer';
242 STATFILE_VERSION
= $03;
246 gGameSettings
: TGameSettings
;
247 gPlayer1Settings
: TPlayerSettings
;
248 gPlayer2Settings
: TPlayerSettings
;
250 gPlayerScreenSize
: TDFPoint
;
251 gPlayer1ScreenCoord
: TDFPoint
;
252 gPlayer2ScreenCoord
: TDFPoint
;
253 gPlayer1
: TPlayer
= nil;
254 gPlayer2
: TPlayer
= nil;
255 gPlayerDrawn
: TPlayer
= nil;
257 gLerpFactor
: Single = 1.0;
258 gSwitchGameMode
: Byte = GM_DM
;
259 gHearPoint1
, gHearPoint2
: THearPoint
;
260 gSoundEffectsDF
: Boolean = False;
261 gSoundTriggerTime
: Word = 0;
262 gAnnouncer
: Integer = ANNOUNCE_NONE
;
263 goodsnd
: array[0..3] of TPlayableSound
;
264 killsnd
: array[0..3] of TPlayableSound
;
265 hahasnd
: array[0..2] of TPlayableSound
;
266 sound_get_flag
: array[0..1] of TPlayableSound
;
267 sound_lost_flag
: array[0..1] of TPlayableSound
;
268 sound_ret_flag
: array[0..1] of TPlayableSound
;
269 sound_cap_flag
: array[0..1] of TPlayableSound
;
270 gBodyKillEvent
: Integer = -1;
271 gDefInterTime
: ShortInt = -1;
272 gInterEndTime
: LongWord = 0;
273 gInterTime
: LongWord = 0;
274 gServInterTime
: Byte = 0;
275 gGameStartTime
: LongWord = 0;
276 gTotalMonsters
: Integer = 0;
277 gPauseMain
: Boolean = false;
278 gPauseHolmes
: Boolean = false;
279 gShowTime
: Boolean = False;
280 gShowFPS
: Boolean = False;
281 gShowScore
: Boolean = True;
282 gShowStat
: Boolean = True;
283 gShowPIDs
: Boolean = False;
284 gShowKillMsg
: Boolean = True;
285 gShowLives
: Boolean = True;
286 gShowPing
: Boolean = False;
287 gShowMap
: Boolean = False;
289 gState
: Byte = STATE_NONE
;
291 sWidth
, sHeight
: Word;
292 gSpectMode
: Byte = SPECT_NONE
;
293 gSpectHUD
: Boolean = True;
294 gSpectKeyPress
: Boolean = False;
295 gSpectX
: Integer = 0;
296 gSpectY
: Integer = 0;
297 gSpectStep
: Byte = 8;
298 gSpectViewTwo
: Boolean = False;
299 gSpectPID1
: Integer = -1;
300 gSpectPID2
: Integer = -1;
301 gSpectAuto
: Boolean = False;
302 gSpectAutoNext
: LongWord;
303 gSpectAutoStepX
: Integer;
304 gSpectAutoStepY
: Integer;
305 gMusic
: TMusic
= nil;
306 gLoadGameMode
: Boolean;
307 gCheats
: Boolean = False;
308 gMapOnce
: Boolean = False;
309 gMapToDelete
: String;
310 gTempDelete
: Boolean = False;
311 gLastMap
: Boolean = False;
314 gResolutionChange
: Boolean = False;
315 gRC_Width
, gRC_Height
: Integer;
316 gRC_FullScreen
, gRC_Maximized
: Boolean;
317 gLanguageChange
: Boolean = False;
318 gDebugMode
: Boolean = False;
319 g_debug_Sounds
: Boolean = False;
320 g_debug_Frames
: Boolean = False;
321 g_debug_WinMsgs
: Boolean = False;
322 g_debug_MonsterOff
: Boolean = False;
323 g_debug_BotAIOff
: Byte = 0;
324 g_debug_HealthBar
: Boolean = False;
325 g_Debug_Player
: Boolean = False;
326 gCoopMonstersKilled
: Word = 0;
327 gCoopSecretsFound
: Word = 0;
328 gCoopTotalMonstersKilled
: Word = 0;
329 gCoopTotalSecretsFound
: Word = 0;
330 gCoopTotalMonsters
: Word = 0;
331 gCoopTotalSecrets
: Word = 0;
332 gStatsOff
: Boolean = False;
333 gStatsPressed
: Boolean = False;
334 gExitByTrigger
: Boolean = False;
335 gNextMap
: String = '';
336 gLMSRespawn
: Byte = LMS_RESPAWN_NONE
;
337 gLMSRespawnTime
: Cardinal = 0;
338 gLMSSoftSpawn
: Boolean = False;
339 gMissionFailed
: Boolean = False;
340 gVoteInProgress
: Boolean = False;
341 gVotePassed
: Boolean = False;
342 gVoteCommand
: string = '';
343 gVoteTimer
: Cardinal = 0;
344 gVoteCmdTimer
: Cardinal = 0;
345 gVoteCount
: Integer = 0;
346 gVoteTimeout
: Cardinal = 30;
347 gVoted
: Boolean = False;
348 gVotesEnabled
: Boolean = True;
349 gEvents
: Array of TGameEvent
;
350 gDelayedEvents
: Array of TDelayedEvent
;
351 gUseChatSounds
: Boolean = True;
352 gChatSounds
: Array of TChatSound
;
353 gWeaponAction
: Array [0..1, WP_FACT
..WP_LACT
] of Boolean; // [player, weapon_action]
354 gSelectWeapon
: Array [0..1, WP_FIRST
..WP_LAST
] of Boolean; // [player, weapon]
355 gInterReadyCount
: Integer = 0;
356 gMaxBots
: Integer = 127;
358 g_dbg_ignore_bounds
: Boolean = false;
359 r_smallmap_h
: Integer = 0; // 0: left; 1: center; 2: right
360 r_smallmap_v
: Integer = 2; // 0: top; 1: center; 2: bottom
362 // move button values:
363 // bits 0-1: l/r state:
364 // 0: neither left, nor right pressed
367 // bits 4-5: l/r state when strafe was pressed
368 P1MoveButton
: Byte = 0;
369 P2MoveButton
: Byte = 0;
371 g_profile_frame_update
: Boolean = false;
372 g_profile_frame_draw
: Boolean = false;
373 g_profile_collision
: Boolean = false;
374 g_profile_los
: Boolean = false;
375 g_profile_history_size
: Integer = 1000;
377 g_rlayer_back
: Boolean = true;
378 g_rlayer_step
: Boolean = true;
379 g_rlayer_wall
: Boolean = true;
380 g_rlayer_door
: Boolean = true;
381 g_rlayer_acid1
: Boolean = true;
382 g_rlayer_acid2
: Boolean = true;
383 g_rlayer_water
: Boolean = true;
384 g_rlayer_fore
: Boolean = true;
387 procedure g_ResetDynlights ();
388 procedure g_AddDynLight (x
, y
, radius
: Integer; r
, g
, b
, a
: Single);
389 procedure g_DynLightExplosion (x
, y
, radius
: Integer; r
, g
, b
: Single);
391 function conIsCheatsEnabled (): Boolean; inline;
392 function gPause (): Boolean; inline;
398 {$INCLUDE ../nogl/noGLuses.inc}
399 {$IFDEF ENABLE_HOLMES}
402 e_texture
, e_res
, g_textures
, g_window
, g_menu
,
403 e_input
, e_log
, g_console
, g_items
, g_map
, g_panel
,
404 g_playermodel
, g_gfx
, g_options
, Math
,
405 g_triggers
, g_monsters
, e_sound
, CONFIG
,
406 g_language
, g_net
, g_main
, g_phys
,
407 ENet
, e_msg
, g_netmsg
, g_netmaster
,
408 sfs
, wadreader
, g_system
;
412 hasPBarGfx
: Boolean = false;
415 // ////////////////////////////////////////////////////////////////////////// //
416 function gPause (): Boolean; inline; begin result
:= gPauseMain
or gPauseHolmes
; end;
419 // ////////////////////////////////////////////////////////////////////////// //
420 function conIsCheatsEnabled (): Boolean; inline;
423 if g_Game_IsNet
then exit
;
424 if not gDebugMode
then
426 //if not gCheats then exit;
427 if not (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
]) then exit
;
428 if not (gGameSettings
.GameMode
in [GM_COOP
, GM_SINGLE
]) then exit
;
434 // ////////////////////////////////////////////////////////////////////////// //
436 profileFrameDraw
: TProfiler
= nil;
439 // ////////////////////////////////////////////////////////////////////////// //
442 x
, y
, radius
: Integer;
445 exploRadius
: Integer;
449 g_dynLights
: array of TDynLight
= nil;
450 g_dynLightCount
: Integer = 0;
451 g_playerLight
: Boolean = false;
453 procedure g_ResetDynlights ();
457 if not gwin_has_stencil
then begin g_dynLightCount
:= 0; exit
; end;
459 for idx
:= 0 to g_dynLightCount
-1 do
461 if g_dynLights
[idx
].exploCount
= -666 then
468 Inc(g_dynLights
[idx
].exploCount
);
469 if (g_dynLights
[idx
].exploCount
< 10) then
471 g_dynLights
[idx
].radius
:= g_dynLights
[idx
].exploRadius
+g_dynLights
[idx
].exploCount
*8;
472 g_dynLights
[idx
].a
:= 0.4+g_dynLights
[idx
].exploCount
/10;
473 if (g_dynLights
[idx
].a
> 0.8) then g_dynLights
[idx
].a
:= 0.8;
474 if lnum
<> idx
then g_dynLights
[lnum
] := g_dynLights
[idx
];
479 g_dynLightCount
:= lnum
;
482 procedure g_AddDynLight (x
, y
, radius
: Integer; r
, g
, b
, a
: Single);
484 if not gwin_has_stencil
then exit
;
485 if g_dynLightCount
= length(g_dynLights
) then SetLength(g_dynLights
, g_dynLightCount
+1024);
486 g_dynLights
[g_dynLightCount
].x
:= x
;
487 g_dynLights
[g_dynLightCount
].y
:= y
;
488 g_dynLights
[g_dynLightCount
].radius
:= radius
;
489 g_dynLights
[g_dynLightCount
].r
:= r
;
490 g_dynLights
[g_dynLightCount
].g
:= g
;
491 g_dynLights
[g_dynLightCount
].b
:= b
;
492 g_dynLights
[g_dynLightCount
].a
:= a
;
493 g_dynLights
[g_dynLightCount
].exploCount
:= -666;
494 Inc(g_dynLightCount
);
497 procedure g_DynLightExplosion (x
, y
, radius
: Integer; r
, g
, b
: Single);
499 if not gwin_has_stencil
then exit
;
500 if g_dynLightCount
= length(g_dynLights
) then SetLength(g_dynLights
, g_dynLightCount
+1024);
501 g_dynLights
[g_dynLightCount
].x
:= x
;
502 g_dynLights
[g_dynLightCount
].y
:= y
;
503 g_dynLights
[g_dynLightCount
].radius
:= 0;
504 g_dynLights
[g_dynLightCount
].exploRadius
:= radius
;
505 g_dynLights
[g_dynLightCount
].r
:= r
;
506 g_dynLights
[g_dynLightCount
].g
:= g
;
507 g_dynLights
[g_dynLightCount
].b
:= b
;
508 g_dynLights
[g_dynLightCount
].a
:= 0;
509 g_dynLights
[g_dynLightCount
].exploCount
:= 0;
510 Inc(g_dynLightCount
);
514 // ////////////////////////////////////////////////////////////////////////// //
515 function calcProfilesHeight (prof
: TProfiler
): Integer;
518 if (prof
= nil) then exit
;
519 if (length(prof
.bars
) = 0) then exit
;
520 result
:= length(prof
.bars
)*(16+2);
524 function drawProfiles (x
, y
: Integer; prof
: TProfiler
): Integer;
531 if (prof
= nil) then exit
;
533 if (length(prof
.bars
) = 0) then exit
;
535 hgt
:= calcProfilesHeight(prof
);
536 if (x
< 0) then x
:= gScreenWidth
-(wdt
-1)+x
;
537 if (y
< 0) then y
:= gScreenHeight
-(hgt
-1)+y
;
539 //e_DrawFillQuad(x, y, x+wdt-1, y+hgt-1, 255, 255, 255, 200, B_BLEND);
540 //e_DrawFillQuad(x, y, x+wdt-1, y+hgt-1, 20, 20, 20, 0, B_NONE);
541 e_DarkenQuadWH(x
, y
, wdt
, hgt
, 150);
544 for ii
:= 0 to High(prof
.bars
) do
546 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);
553 // ////////////////////////////////////////////////////////////////////////// //
555 TEndCustomGameStat
= record
556 PlayerStat
: TPlayerStatArray
;
560 Map
, MapName
: String;
563 TEndSingleGameStat
= record
564 PlayerStat
: Array [0..1] of record
570 TotalSecrets
: Integer;
573 TLoadingStat
= record
577 Msgs
: Array of String;
579 PBarWasHere
: Boolean; // did we draw a progress bar for this message?
582 TParamStrValue
= record
587 TParamStrValues
= Array of TParamStrValue
;
590 INTER_ACTION_TEXT
= 1;
591 INTER_ACTION_PIC
= 2;
592 INTER_ACTION_MUSIC
= 3;
596 FPSCounter
, UPSCounter
: Word;
597 FPSTime
, UPSTime
: LongWord;
598 DataLoaded
: Boolean = False;
599 IsDrawStat
: Boolean = False;
600 CustomStat
: TEndCustomGameStat
;
601 SingleStat
: TEndSingleGameStat
;
602 LoadingStat
: TLoadingStat
;
603 EndingGameCounter
: Byte = 0;
606 MessageLineLength
: Integer = 80;
607 MapList
: SSArray
= nil;
608 MapIndex
: Integer = -1;
609 InterReadyTime
: Integer = -1;
610 StatShotDone
: Boolean = False;
611 StatFilename
: string = ''; // used by stat screenshot to save with the same name as the csv
612 StatDate
: string = '';
618 text: Array of ShortString;
619 anim
: Array of ShortString;
620 pic
: Array of ShortString;
621 mus
: Array of ShortString;
623 triggers
: Array of record
625 actions
: Array of record
626 action
, p1
, p2
: Integer;
629 cur_trigger
: Integer;
642 function Compare(a
, b
: TPlayerStat
): Integer;
644 if a
.Spectator
then Result
:= 1
645 else if b
.Spectator
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,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
, 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 Deaths
:= gPlayers
[a
].Death
;
1092 Kills
:= gPlayers
[a
].Kills
;
1093 Team
:= gPlayers
[a
].Team
;
1094 Color
:= gPlayers
[a
].Model
.Color
;
1095 Spectator
:= gPlayers
[a
].FSpectator
;
1099 SortGameStat(CustomStat
.PlayerStat
);
1101 if (gSaveStats
or gScreenshotStats
) and (Length(CustomStat
.PlayerStat
) > 1) then
1104 if g_Game_IsNet
then StatFilename
:= NetServerName
else StatFilename
:= 'local';
1105 StatDate
:= FormatDateTime('yymmdd_hhnnss', t
);
1106 StatFilename
:= StatFilename
+ '_' + CustomStat
.Map
+ '_' + g_Game_ModeToText(CustomStat
.GameMode
);
1107 StatFilename
:= sanitizeFilename(StatFilename
) + '_' + StatDate
;
1109 SaveGameStat(CustomStat
, FormatDateTime('yyyy"/"mm"/"dd', t
));
1112 StatShotDone
:= False;
1115 g_Game_ExecuteEvent('onmapend');
1116 if not g_Game_IsClient
then g_Player_ResetReady
;
1117 gInterReadyCount
:= 0;
1119 // Çàòóõàþùèé ýêðàí:
1120 EndingGameCounter
:= 255;
1121 gState
:= STATE_FOLD
;
1123 if gDefInterTime
< 0 then
1124 gInterEndTime
:= IfThen((gGameSettings
.GameType
= GT_SERVER
) and (gPlayer1
= nil), 15000, 25000)
1126 gInterEndTime
:= gDefInterTime
* 1000;
1129 EXIT_ENDLEVELSINGLE
: // Çàêîí÷èëñÿ óðîâåíü â Îäèíî÷íîé èãðå
1131 // Ñòàòèñòèêà Îäèíî÷íîé èãðû:
1132 SingleStat
.GameTime
:= gTime
;
1133 SingleStat
.TwoPlayers
:= gPlayer2
<> nil;
1134 SingleStat
.TotalSecrets
:= gSecretsCount
;
1135 // Ñòàòèñòèêà ïåðâîãî èãðîêà:
1136 SingleStat
.PlayerStat
[0].Kills
:= gPlayer1
.MonsterKills
;
1137 SingleStat
.PlayerStat
[0].Secrets
:= gPlayer1
.Secrets
;
1138 // Ñòàòèñòèêà âòîðîãî èãðîêà (åñëè åñòü):
1139 if SingleStat
.TwoPlayers
then
1141 SingleStat
.PlayerStat
[1].Kills
:= gPlayer2
.MonsterKills
;
1142 SingleStat
.PlayerStat
[1].Secrets
:= gPlayer2
.Secrets
;
1145 g_Game_ExecuteEvent('onmapend');
1148 if gNextMap
<> '' then
1150 gMusic
.SetByName('MUSIC_INTERMUS');
1152 gState
:= STATE_INTERSINGLE
;
1155 g_Game_ExecuteEvent('oninter');
1157 else // Áîëüøå íåò êàðò
1159 // Çàòóõàþùèé ýêðàí:
1160 EndingGameCounter
:= 255;
1161 gState
:= STATE_FOLD
;
1166 // Îêîí÷àíèå îáðàáîòàíî:
1167 if gExit
<> EXIT_QUIT
then
1171 procedure drawTime(X
, Y
: Integer); inline;
1173 e_TextureFontPrint(x
, y
,
1174 Format('%d:%.2d:%.2d', [
1175 gTime
div 1000 div 3600,
1176 (gTime
div 1000 div 60) mod 60,
1177 gTime
div 1000 mod 60
1182 procedure DrawStat();
1184 pc
, x
, y
, w
, h
: Integer;
1185 w1
, w2
, w3
, w4
: Integer;
1187 cw
, ch
, r
, g
, b
, rr
, gg
, bb
: Byte;
1190 stat
: TPlayerStatArray
;
1198 pc
:= g_Player_GetCount
;
1199 e_TextureFontGetSize(gStdFont
, cw
, ch
);
1201 w
:= gScreenWidth
-(gScreenWidth
div 5);
1202 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
1205 h
:= 40+ch
*5+(ch
+8)*pc
;
1206 x
:= (gScreenWidth
div 2)-(w
div 2);
1207 y
:= (gScreenHeight
div 2)-(h
div 2);
1209 e_DrawFillQuad(x
, y
, x
+w
-1, y
+h
-1, 64, 64, 64, 32);
1210 e_DrawQuad(x
, y
, x
+w
-1, y
+h
-1, 255, 127, 0);
1212 drawTime(x
+w
-78, y
+8);
1214 wad
:= g_ExtractWadNameNoPath(gMapInfo
.Map
);
1215 map
:= g_ExtractFileName(gMapInfo
.Map
);
1216 mapstr
:= wad
+ ':\' + map
+ ' - ' + gMapInfo
.Name
;
1218 case gGameSettings
.GameMode
of
1221 if gGameSettings
.MaxLives
= 0 then
1222 s1
:= _lc
[I_GAME_DM
]
1224 s1
:= _lc
[I_GAME_LMS
];
1225 s2
:= Format(_lc
[I_GAME_FRAG_LIMIT
], [gGameSettings
.ScoreLimit
]);
1226 s3
:= Format(_lc
[I_GAME_TIME_LIMIT
], [gGameSettings
.TimeLimit
div 3600, (gGameSettings
.TimeLimit
div 60) mod 60, gGameSettings
.TimeLimit
mod 60]);
1231 if gGameSettings
.MaxLives
= 0 then
1232 s1
:= _lc
[I_GAME_TDM
]
1234 s1
:= _lc
[I_GAME_TLMS
];
1235 s2
:= Format(_lc
[I_GAME_FRAG_LIMIT
], [gGameSettings
.ScoreLimit
]);
1236 s3
:= Format(_lc
[I_GAME_TIME_LIMIT
], [gGameSettings
.TimeLimit
div 3600, (gGameSettings
.TimeLimit
div 60) mod 60, gGameSettings
.TimeLimit
mod 60]);
1241 s1
:= _lc
[I_GAME_CTF
];
1242 s2
:= Format(_lc
[I_GAME_SCORE_LIMIT
], [gGameSettings
.ScoreLimit
]);
1243 s3
:= Format(_lc
[I_GAME_TIME_LIMIT
], [gGameSettings
.TimeLimit
div 3600, (gGameSettings
.TimeLimit
div 60) mod 60, gGameSettings
.TimeLimit
mod 60]);
1248 if gGameSettings
.MaxLives
= 0 then
1249 s1
:= _lc
[I_GAME_COOP
]
1251 s1
:= _lc
[I_GAME_SURV
];
1252 s2
:= _lc
[I_GAME_MONSTERS
] + ' ' + IntToStr(gCoopMonstersKilled
) + '/' + IntToStr(gTotalMonsters
);
1253 s3
:= _lc
[I_GAME_SECRETS
] + ' ' + IntToStr(gCoopSecretsFound
) + '/' + IntToStr(gSecretsCount
);
1264 e_TextureFontPrintEx(x
+(w
div 2)-(Length(s1
)*cw
div 2), _y
, s1
, gStdFont
, 255, 255, 255, 1);
1266 e_TextureFontPrintEx(x
+(w
div 2)-(Length(mapstr
)*cw
div 2), _y
, mapstr
, gStdFont
, 200, 200, 200, 1);
1268 e_TextureFontPrintEx(x
+16, _y
, s2
, gStdFont
, 200, 200, 200, 1);
1270 e_TextureFontPrintEx(x
+w
-16-(Length(s3
))*cw
, _y
, s3
,
1271 gStdFont
, 200, 200, 200, 1);
1273 if NetMode
= NET_SERVER
then
1274 e_TextureFontPrintEx(x
+8, y
+ 8, _lc
[I_NET_SERVER
], gStdFont
, 255, 255, 255, 1)
1276 if NetMode
= NET_CLIENT
then
1277 e_TextureFontPrintEx(x
+8, y
+ 8,
1278 NetClientIP
+ ':' + IntToStr(NetClientPort
), gStdFont
, 255, 255, 255, 1);
1282 stat
:= g_Player_GetStats();
1285 w2
:= (w
-16) div 6 + 48; // øèðèíà 2 ñòîëáöà
1286 w3
:= (w
-16) div 6; // øèðèíà 3 è 4 ñòîëáöîâ
1288 w1
:= w
-16-w2
-w3
-w4
; // îñòàâøååñÿ ïðîñòðàíñòâî - äëÿ öâåòà è èìåíè èãðîêà
1290 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
1294 for a
:= TEAM_RED
to TEAM_BLUE
do
1296 if a
= TEAM_RED
then
1298 s1
:= _lc
[I_GAME_TEAM_RED
];
1305 s1
:= _lc
[I_GAME_TEAM_BLUE
];
1311 e_TextureFontPrintEx(x
+16, _y
, s1
, gStdFont
, r
, g
, b
, 1);
1312 e_TextureFontPrintEx(x
+w1
+16, _y
, IntToStr(gTeamStat
[a
].Score
),
1313 gStdFont
, r
, g
, b
, 1);
1315 _y
:= _y
+ch
+(ch
div 4);
1316 e_DrawLine(1, x
+16, _y
, x
+w
-16, _y
, r
, g
, b
);
1317 _y
:= _y
+(ch
div 4);
1319 for aa
:= 0 to High(stat
) do
1320 if stat
[aa
].Team
= a
then
1336 namestr
:= Format('[%5d] %s', [UID
, Name
])
1340 e_TextureFontPrintEx(x
+16, _y
, namestr
, gStdFont
, rr
, gg
, bb
, 1);
1342 e_TextureFontPrintEx(x
+w1
+16, _y
, Format(_lc
[I_GAME_PING_MS
], [Ping
, Loss
]), gStdFont
, rr
, gg
, bb
, 1);
1344 e_TextureFontPrintEx(x
+w1
+w2
+16, _y
, IntToStr(Frags
), gStdFont
, rr
, gg
, bb
, 1);
1346 e_TextureFontPrintEx(x
+w1
+w2
+w3
+16, _y
, IntToStr(Deaths
), gStdFont
, rr
, gg
, bb
, 1);
1353 else if gGameSettings
.GameMode
in [GM_DM
, GM_COOP
] then
1356 e_TextureFontPrintEx(x
+16, _y
, _lc
[I_GAME_PLAYER_NAME
], gStdFont
, 255, 127, 0, 1);
1357 e_TextureFontPrintEx(x
+16+w1
, _y
, _lc
[I_GAME_PING
], gStdFont
, 255, 127, 0, 1);
1358 e_TextureFontPrintEx(x
+16+w1
+w2
, _y
, _lc
[I_GAME_FRAGS
], gStdFont
, 255, 127, 0, 1);
1359 e_TextureFontPrintEx(x
+16+w1
+w2
+w3
, _y
, _lc
[I_GAME_DEATHS
], gStdFont
, 255, 127, 0, 1);
1362 for aa
:= 0 to High(stat
) do
1376 namestr
:= Format('[%5d] %s', [UID
, Name
])
1380 e_DrawFillQuad(x
+16, _y
+4, x
+32-1, _y
+16+4-1, Color
.R
, Color
.G
, Color
.B
, 0);
1381 e_DrawQuad(x
+16, _y
+4, x
+32-1, _y
+16+4-1, 192, 192, 192);
1383 e_TextureFontPrintEx(x
+16+16+8, _y
+4, namestr
, gStdFont
, r
, g
, 0, 1);
1385 e_TextureFontPrintEx(x
+w1
+16, _y
+4, Format(_lc
[I_GAME_PING_MS
], [Ping
, Loss
]), gStdFont
, r
, g
, 0, 1);
1387 e_TextureFontPrintEx(x
+w1
+w2
+16, _y
+4, IntToStr(Frags
), gStdFont
, r
, g
, 0, 1);
1389 e_TextureFontPrintEx(x
+w1
+w2
+w3
+16, _y
+4, IntToStr(Deaths
), gStdFont
, r
, g
, 0, 1);
1395 procedure g_Game_Init();
1398 knownFiles
: array of AnsiString = nil;
1400 wext
, s
: AnsiString;
1405 gTempDelete
:= False;
1407 sfsGCDisable(); // temporary disable removing of temporary volumes
1410 TEXTUREFILTER
:= GL_LINEAR
;
1411 g_Texture_CreateWADEx('MENU_BACKGROUND', GameWAD
+':TEXTURES\TITLE');
1412 g_Texture_CreateWADEx('INTER', GameWAD
+':TEXTURES\INTER');
1413 g_Texture_CreateWADEx('ENDGAME_EN', GameWAD
+':TEXTURES\ENDGAME_EN');
1414 g_Texture_CreateWADEx('ENDGAME_RU', GameWAD
+':TEXTURES\ENDGAME_RU');
1415 TEXTUREFILTER
:= GL_NEAREST
;
1417 LoadStdFont('STDTXT', 'STDFONT', gStdFont
);
1418 LoadFont('MENUTXT', 'MENUFONT', gMenuFont
);
1419 LoadFont('SMALLTXT', 'SMALLFONT', gMenuSmallFont
);
1421 g_Game_ClearLoading();
1422 g_Game_SetLoadingText(Format('Doom 2D: Forever %s', [GAME_VERSION
]), 0, False);
1423 g_Game_SetLoadingText('', 0, False);
1425 g_Game_SetLoadingText(_lc
[I_LOAD_CONSOLE
], 0, False);
1428 g_Game_SetLoadingText(_lc
[I_LOAD_MODELS
], 0, False);
1429 g_PlayerModel_LoadData();
1431 // load models from all possible wad types, in all known directories
1432 // this does a loosy job (linear search, ooph!), but meh
1433 for wext
in wadExtensions
do
1435 for f
:= High(ModelDirs
) downto Low(ModelDirs
) do
1437 if (FindFirst(ModelDirs
[f
]+DirectorySeparator
+'*'+wext
, faAnyFile
, SR
) = 0) then
1441 for s
in knownFiles
do
1443 if (strEquCI1251(forceFilenameExt(SR
.Name
, ''), forceFilenameExt(ExtractFileName(s
), ''))) then
1451 SetLength(knownFiles
, length(knownFiles
)+1);
1452 knownFiles
[High(knownFiles
)] := ModelDirs
[f
]+DirectorySeparator
+SR
.Name
;
1454 until (FindNext(SR
) <> 0);
1460 if (length(knownFiles
) = 0) then raise Exception
.Create('no player models found!');
1462 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
);
1463 for s
in knownFiles
do
1465 if not g_PlayerModel_Load(s
) then e_LogWritefln('Error loading model "%s"', [s
], TMsgType
.Warning
);
1469 gPauseMain
:= false;
1470 gPauseHolmes
:= false;
1473 {e_MouseInfo.Accel := 1.0;}
1475 g_Game_SetLoadingText(_lc
[I_LOAD_GAME_DATA
], 0, False);
1478 g_Game_SetLoadingText(_lc
[I_LOAD_MUSIC
], 0, False);
1479 g_Sound_CreateWADEx('MUSIC_INTERMUS', GameWAD
+':MUSIC\INTERMUS', True);
1480 g_Sound_CreateWADEx('MUSIC_MENU', GameWAD
+':MUSIC\MENU', True);
1481 g_Sound_CreateWADEx('MUSIC_ROUNDMUS', GameWAD
+':MUSIC\ROUNDMUS', True, True);
1482 g_Sound_CreateWADEx('MUSIC_STDENDMUS', GameWAD
+':MUSIC\ENDMUS', True);
1485 g_Game_SetLoadingText(_lc
[I_LOAD_MENUS
], 0, False);
1489 gMusic
:= TMusic
.Create();
1490 gMusic
.SetByName('MUSIC_MENU');
1493 gGameSettings
.WarmupTime
:= 30;
1495 gState
:= STATE_MENU
;
1497 SetLength(gEvents
, 6);
1498 gEvents
[0].Name
:= 'ongamestart';
1499 gEvents
[1].Name
:= 'ongameend';
1500 gEvents
[2].Name
:= 'onmapstart';
1501 gEvents
[3].Name
:= 'onmapend';
1502 gEvents
[4].Name
:= 'oninter';
1503 gEvents
[5].Name
:= 'onwadend';
1505 sfsGCEnable(); // enable releasing unused volumes
1509 procedure g_Game_Free(freeTextures
: Boolean=true);
1511 if NetMode
= NET_CLIENT
then g_Net_Disconnect();
1512 if NetMode
= NET_SERVER
then g_Net_Host_Die();
1514 g_Map_Free(freeTextures
);
1516 g_Player_RemoveAllCorpses();
1518 gGameSettings
.GameType
:= GT_NONE
;
1519 if gGameSettings
.GameMode
= GM_SINGLE
then
1520 gGameSettings
.GameMode
:= GM_DM
;
1521 gSwitchGameMode
:= gGameSettings
.GameMode
;
1524 gExitByTrigger
:= False;
1527 function IsActivePlayer(p
: TPlayer
): Boolean;
1532 Result
:= (not p
.FDummy
) and (not p
.FSpectator
);
1535 function GetActivePlayer_ByID(ID
: Integer): TPlayer
;
1542 if gPlayers
= nil then
1544 for a
:= Low(gPlayers
) to High(gPlayers
) do
1545 if IsActivePlayer(gPlayers
[a
]) then
1547 if gPlayers
[a
].UID
<> ID
then
1549 Result
:= gPlayers
[a
];
1554 function GetActivePlayerID_Next(Skip
: Integer = -1): Integer;
1560 if gPlayers
= nil then
1564 for a
:= Low(gPlayers
) to High(gPlayers
) do
1565 if IsActivePlayer(gPlayers
[a
]) then
1567 SetLength(ids
, Length(ids
) + 1);
1568 ids
[High(ids
)] := gPlayers
[a
].UID
;
1569 if gPlayers
[a
].UID
= Skip
then
1572 if Length(ids
) = 0 then
1577 Result
:= ids
[(idx
+ 1) mod Length(ids
)];
1580 function GetActivePlayerID_Prev(Skip
: Integer = -1): Integer;
1586 if gPlayers
= nil then
1590 for a
:= Low(gPlayers
) to High(gPlayers
) do
1591 if IsActivePlayer(gPlayers
[a
]) then
1593 SetLength(ids
, Length(ids
) + 1);
1594 ids
[High(ids
)] := gPlayers
[a
].UID
;
1595 if gPlayers
[a
].UID
= Skip
then
1598 if Length(ids
) = 0 then
1601 Result
:= ids
[Length(ids
) - 1]
1603 Result
:= ids
[(Length(ids
) - 1 + idx
) mod Length(ids
)];
1606 function GetActivePlayerID_Random(Skip
: Integer = -1): Integer;
1612 if gPlayers
= nil then
1616 for a
:= Low(gPlayers
) to High(gPlayers
) do
1617 if IsActivePlayer(gPlayers
[a
]) then
1619 SetLength(ids
, Length(ids
) + 1);
1620 ids
[High(ids
)] := gPlayers
[a
].UID
;
1621 if gPlayers
[a
].UID
= Skip
then
1624 if Length(ids
) = 0 then
1626 if Length(ids
) = 1 then
1631 Result
:= ids
[Random(Length(ids
))];
1633 while (idx
<> -1) and (Result
= Skip
) and (a
> 0) do
1635 Result
:= ids
[Random(Length(ids
))];
1640 function GetRandomSpectMode(Current
: Byte): Byte;
1647 0: Result
:= SPECT_STATS
;
1648 1: Result
:= SPECT_MAPVIEW
;
1649 2: Result
:= SPECT_MAPVIEW
;
1650 3: Result
:= SPECT_PLAYERS
;
1651 4: Result
:= SPECT_PLAYERS
;
1652 5: Result
:= SPECT_PLAYERS
;
1653 6: Result
:= SPECT_PLAYERS
;
1655 if (Current
in [SPECT_STATS
, SPECT_MAPVIEW
]) and (Current
= Result
) then
1659 procedure ProcessPlayerControls (plr
: TPlayer
; p
: Integer; var MoveButton
: Byte);
1665 if (plr
= nil) then exit
;
1666 if (p
= 2) then time
:= 1000 else time
:= 1;
1667 strafeDir
:= MoveButton
shr 4;
1668 MoveButton
:= MoveButton
and $0F;
1670 if gPlayerAction
[p
, ACTION_MOVELEFT
] and (not gPlayerAction
[p
, ACTION_MOVERIGHT
]) then
1671 MoveButton
:= 1 // Íàæàòà òîëüêî "Âëåâî"
1672 else if (not gPlayerAction
[p
, ACTION_MOVELEFT
]) and gPlayerAction
[p
, ACTION_MOVERIGHT
] then
1673 MoveButton
:= 2 // Íàæàòà òîëüêî "Âïðàâî"
1674 else if (not gPlayerAction
[p
, ACTION_MOVELEFT
]) and (not gPlayerAction
[p
, ACTION_MOVERIGHT
]) then
1675 MoveButton
:= 0; // Íå íàæàòû íè "Âëåâî", íè "Âïðàâî"
1677 // Ñåé÷àñ èëè ðàíüøå áûëè íàæàòû "Âëåâî"/"Âïðàâî" => ïåðåäàåì èãðîêó:
1678 if MoveButton
= 1 then
1679 plr
.PressKey(KEY_LEFT
, time
)
1680 else if MoveButton
= 2 then
1681 plr
.PressKey(KEY_RIGHT
, time
);
1683 // if we have "strafe" key, turn off old strafe mechanics
1684 if gPlayerAction
[p
, ACTION_STRAFE
] then
1686 // new strafe mechanics
1687 if (strafeDir
= 0) then
1688 strafeDir
:= MoveButton
; // start strafing
1689 // now set direction according to strafe (reversed)
1690 if (strafeDir
= 2) then
1691 plr
.SetDirection(TDirection
.D_LEFT
)
1692 else if (strafeDir
= 1) then
1693 plr
.SetDirection(TDirection
.D_RIGHT
)
1697 strafeDir
:= 0; // not strafing anymore
1698 // Ðàíüøå áûëà íàæàòà "Âïðàâî", à ñåé÷àñ "Âëåâî" => áåæèì âïðàâî, ñìîòðèì âëåâî:
1699 if (MoveButton
= 2) and gPlayerAction
[p
, ACTION_MOVELEFT
] then
1700 plr
.SetDirection(TDirection
.D_LEFT
)
1701 // Ðàíüøå áûëà íàæàòà "Âëåâî", à ñåé÷àñ "Âïðàâî" => áåæèì âëåâî, ñìîòðèì âïðàâî:
1702 else if (MoveButton
= 1) and gPlayerAction
[p
, ACTION_MOVERIGHT
] then
1703 plr
.SetDirection(TDirection
.D_RIGHT
)
1704 // ×òî-òî áûëî íàæàòî è íå èçìåíèëîñü => êóäà áåæèì, òóäà è ñìîòðèì:
1705 else if MoveButton
<> 0 then
1706 plr
.SetDirection(TDirection(MoveButton
-1))
1709 // fix movebutton state
1710 MoveButton
:= MoveButton
or (strafeDir
shl 4);
1712 // Îñòàëüíûå êëàâèøè:
1713 if gPlayerAction
[p
, ACTION_JUMP
] then plr
.PressKey(KEY_JUMP
, time
);
1714 if gPlayerAction
[p
, ACTION_LOOKUP
] then plr
.PressKey(KEY_UP
, time
);
1715 if gPlayerAction
[p
, ACTION_LOOKDOWN
] then plr
.PressKey(KEY_DOWN
, time
);
1716 if gPlayerAction
[p
, ACTION_ATTACK
] then plr
.PressKey(KEY_FIRE
);
1717 if gPlayerAction
[p
, ACTION_ACTIVATE
] then plr
.PressKey(KEY_OPEN
);
1719 for i
:= WP_FACT
to WP_LACT
do
1721 if gWeaponAction
[p
, i
] then
1723 plr
.ProcessWeaponAction(i
);
1724 gWeaponAction
[p
, i
] := False
1728 for i
:= WP_FIRST
to WP_LAST
do
1730 if gSelectWeapon
[p
, i
] then
1732 plr
.QueueWeaponSwitch(i
); // all choices are passed there, and god will take the best
1733 gSelectWeapon
[p
, i
] := False
1737 // HACK: add dynlight here
1738 if gwin_k8_enable_light_experiments
then
1740 if e_KeyPressed(IK_F8
) and gGameOn
and (not gConsoleShow
) and (g_ActiveWindow
= nil) then
1742 g_playerLight
:= true;
1744 if e_KeyPressed(IK_F9
) and gGameOn
and (not gConsoleShow
) and (g_ActiveWindow
= nil) then
1746 g_playerLight
:= false;
1750 if gwin_has_stencil
and g_playerLight
then g_AddDynLight(plr
.GameX
+32, plr
.GameY
+40, 128, 1, 1, 0, 0.6);
1753 // HACK: don't have a "key was pressed" function
1754 procedure InterReady();
1756 if InterReadyTime
> gTime
then Exit
;
1757 InterReadyTime
:= gTime
+ 3000;
1758 MC_SEND_CheatRequest(NET_CHEAT_READY
);
1761 procedure g_Game_PreUpdate();
1763 // these are in separate PreUpdate functions because they can interact during Update()
1764 // and are synced over the net
1765 // we don't care that much about corpses and gibs
1766 g_Player_PreUpdate();
1767 g_Monsters_PreUpdate();
1768 g_Items_PreUpdate();
1769 g_Weapon_PreUpdate();
1772 procedure g_Game_Update();
1774 Msg
: g_gui
.TMessage
;
1780 function sendMonsPos (mon
: TMonster
): Boolean;
1782 result
:= false; // don't stop
1783 // this will also reset "need-send" flag
1784 if mon
.gncNeedSend
then
1786 MH_SEND_MonsterPos(mon
.UID
);
1788 else if (mon
.MonsterType
= MONSTER_BARREL
) then
1790 if (mon
.GameVelX
<> 0) or (mon
.GameVelY
<> 0) then MH_SEND_MonsterPos(mon
.UID
);
1792 else if (mon
.MonsterState
<> MONSTATE_SLEEP
) then
1794 if (mon
.MonsterState
<> MONSTATE_DEAD
) or (mon
.GameVelX
<> 0) or (mon
.GameVelY
<> 0) then MH_SEND_MonsterPos(mon
.UID
);
1798 function sendMonsPosUnexpected (mon
: TMonster
): Boolean;
1800 result
:= false; // don't stop
1801 // this will also reset "need-send" flag
1802 if mon
.gncNeedSend
then MH_SEND_MonsterPos(mon
.UID
);
1805 function sendItemPos (it
: PItem
): Boolean;
1807 result
:= false; // don't stop
1810 MH_SEND_ItemPos(it
.myId
);
1811 it
.needSend
:= False;
1816 reliableUpdate
: Boolean;
1821 // Ïîðà âûêëþ÷àòü èãðó:
1822 if gExit
= EXIT_QUIT
then
1824 // Èãðà çàêîí÷èëàñü - îáðàáàòûâàåì:
1828 if gExit
= EXIT_QUIT
then
1832 // ×èòàåì êëàâèàòóðó è äæîéñòèê, åñëè îêíî àêòèâíî
1833 // no need to, as we'll do it in event handler
1835 // Îáíîâëÿåì êîíñîëü (äâèæåíèå è ñîîáùåíèÿ):
1838 if (NetMode
= NET_NONE
) and (g_Game_IsNet
) and (gGameOn
or (gState
in [STATE_FOLD
, STATE_INTERCUSTOM
])) then
1840 gExit
:= EXIT_SIMPLE
;
1845 // process master server communications
1846 g_Net_Slist_Pulse();
1849 STATE_INTERSINGLE
, // Ñòàòèñòêà ïîñëå ïðîõîæäåíèÿ óðîâíÿ â Îäèíî÷íîé èãðå
1850 STATE_INTERCUSTOM
, // Ñòàòèñòêà ïîñëå ïðîõîæäåíèÿ óðîâíÿ â Ñâîåé èãðå
1851 STATE_INTERTEXT
, // Òåêñò ìåæäó óðîâíÿìè
1852 STATE_INTERPIC
: // Êàðòèíêà ìåæäó óðîâíÿìè
1854 if g_Game_IsNet
and g_Game_IsServer
then
1856 gInterTime
:= gInterTime
+ GAME_TICK
;
1857 a
:= Min((gInterEndTime
- gInterTime
) div 1000 + 1, 255);
1858 if a
<> gServInterTime
then
1860 gServInterTime
:= a
;
1861 MH_SEND_TimeSync(gServInterTime
);
1865 if (not g_Game_IsClient
) and
1869 e_KeyPressed(IK_RETURN
) or e_KeyPressed(IK_KPRETURN
) or e_KeyPressed(IK_SPACE
) or
1870 e_KeyPressed(VK_FIRE
) or e_KeyPressed(VK_OPEN
) or
1871 e_KeyPressed(JOY0_ATTACK
) or e_KeyPressed(JOY1_ATTACK
) or
1872 e_KeyPressed(JOY2_ATTACK
) or e_KeyPressed(JOY3_ATTACK
)
1874 and (not gJustChatted
) and (not gConsoleShow
) and (not gChatShow
)
1875 and (g_ActiveWindow
= nil)
1877 or (g_Game_IsNet
and ((gInterTime
> gInterEndTime
) or ((gInterReadyCount
>= NetClientCount
) and (NetClientCount
> 0))))
1880 begin // Íàæàëè <Enter>/<Ïðîáåë> èëè ïðîøëî äîñòàòî÷íî âðåìåíè:
1881 g_Game_StopAllSounds(True);
1883 if gMapOnce
then // Ýòî áûë òåñò
1884 gExit
:= EXIT_SIMPLE
1886 if gNextMap
<> '' then // Ïåðåõîäèì íà ñëåäóþùóþ êàðòó
1887 g_Game_ChangeMap(gNextMap
)
1888 else // Ñëåäóþùåé êàðòû íåò
1890 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
] then
1892 // Âûõîä â ãëàâíîå ìåíþ:
1894 g_GUI_ShowWindow('MainMenu');
1895 gMusic
.SetByName('MUSIC_MENU');
1897 gState
:= STATE_MENU
;
1900 // Ôèíàëüíàÿ êàðòèíêà:
1901 g_Game_ExecuteEvent('onwadend');
1903 if not gMusic
.SetByName('MUSIC_endmus') then
1904 gMusic
.SetByName('MUSIC_STDENDMUS');
1906 gState
:= STATE_ENDPIC
;
1908 g_Game_ExecuteEvent('ongameend');
1913 else if g_Game_IsClient
and
1916 e_KeyPressed(IK_RETURN
) or e_KeyPressed(IK_KPRETURN
) or e_KeyPressed(IK_SPACE
) or
1917 e_KeyPressed(VK_FIRE
) or e_KeyPressed(VK_OPEN
) or
1918 e_KeyPressed(JOY0_ATTACK
) or e_KeyPressed(JOY1_ATTACK
) or
1919 e_KeyPressed(JOY2_ATTACK
) or e_KeyPressed(JOY3_ATTACK
)
1921 and (not gJustChatted
) and (not gConsoleShow
) and (not gChatShow
)
1922 and (g_ActiveWindow
= nil)
1930 if gState
= STATE_INTERTEXT
then
1931 if InterText
.counter
> 0 then
1932 InterText
.counter
:= InterText
.counter
- 1;
1935 STATE_FOLD
: // Çàòóõàíèå ýêðàíà
1937 if EndingGameCounter
= 0 then
1939 // Çàêîí÷èëñÿ óðîâåíü â Ñâîåé èãðå:
1940 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
1942 gState
:= STATE_INTERCUSTOM
;
1943 InterReadyTime
:= -1;
1944 if gLastMap
and (gGameSettings
.GameMode
= GM_COOP
) then
1946 g_Game_ExecuteEvent('onwadend');
1947 if not gMusic
.SetByName('MUSIC_endmus') then
1948 gMusic
.SetByName('MUSIC_STDENDMUS');
1951 gMusic
.SetByName('MUSIC_ROUNDMUS');
1955 else // Çàêîí÷èëàñü ïîñëåäíÿÿ êàðòà â Îäèíî÷íîé èãðå
1957 gMusic
.SetByName('MUSIC_INTERMUS');
1959 gState
:= STATE_INTERSINGLE
;
1962 g_Game_ExecuteEvent('oninter');
1965 DecMin(EndingGameCounter
, 6, 0);
1968 STATE_ENDPIC
: // Êàðòèíêà îêîí÷àíèÿ ìåãàÂàäà
1970 if gMapOnce
then // Ýòî áûë òåñò
1972 gExit
:= EXIT_SIMPLE
;
1978 g_Serverlist_Control(slCurrent
, slTable
);
1981 // Ñòàòèñòèêà ïî Tab:
1983 IsDrawStat
:= (not gConsoleShow
) and (not gChatShow
) and (gGameSettings
.GameType
<> GT_SINGLE
) and g_Console_Action(ACTION_SCORES
);
1986 if gGameOn
and not gPause
and (gState
<> STATE_FOLD
) then
1988 // Âðåìÿ += 28 ìèëëèñåêóíä:
1989 gTime
:= gTime
+ GAME_TICK
;
1991 // Ñîîáùåíèå ïîñåðåäèíå ýêðàíà:
1992 if MessageTime
= 0 then
1994 if MessageTime
> 0 then
1995 MessageTime
:= MessageTime
- 1;
1997 if (g_Game_IsServer
) then
1999 // Áûë çàäàí ëèìèò âðåìåíè:
2000 if (gGameSettings
.TimeLimit
> 0) then
2001 if (gTime
- gGameStartTime
) div 1000 >= gGameSettings
.TimeLimit
then
2002 begin // Îí ïðîøåë => êîíåö óðîâíÿ
2007 // Íàäî ðåñïàâíèòü èãðîêîâ â LMS:
2008 if (gLMSRespawn
> LMS_RESPAWN_NONE
) and (gLMSRespawnTime
< gTime
) then
2009 g_Game_RestartRound(gLMSSoftSpawn
);
2011 // Ïðîâåðèì ðåçóëüòàò ãîëîñîâàíèÿ, åñëè âðåìÿ ïðîøëî
2012 if gVoteInProgress
and (gVoteTimer
< gTime
) then
2014 else if gVotePassed
and (gVoteCmdTimer
< gTime
) then
2016 g_Console_Process(gVoteCommand
);
2018 gVotePassed
:= False;
2021 // Çàìåðÿåì âðåìÿ çàõâàòà ôëàãîâ
2022 if gFlags
[FLAG_RED
].State
= FLAG_STATE_CAPTURED
then
2023 gFlags
[FLAG_RED
].CaptureTime
:= gFlags
[FLAG_RED
].CaptureTime
+ GAME_TICK
;
2024 if gFlags
[FLAG_BLUE
].State
= FLAG_STATE_CAPTURED
then
2025 gFlags
[FLAG_BLUE
].CaptureTime
:= gFlags
[FLAG_BLUE
].CaptureTime
+ GAME_TICK
;
2027 // Áûë çàäàí ëèìèò ïîáåä:
2028 if (gGameSettings
.ScoreLimit
> 0) then
2032 if gGameSettings
.GameMode
= GM_DM
then
2033 begin // Â DM èùåì èãðîêà ñ max ôðàãàìè
2034 for i
:= 0 to High(gPlayers
) do
2035 if gPlayers
[i
] <> nil then
2036 if gPlayers
[i
].Frags
> b
then
2037 b
:= gPlayers
[i
].Frags
;
2040 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
2041 begin //  CTF/TDM âûáèðàåì êîìàíäó ñ íàèáîëüøèì ñ÷åòîì
2042 b
:= Max(gTeamStat
[TEAM_RED
].Score
, gTeamStat
[TEAM_BLUE
].Score
);
2045 // Ëèìèò ïîáåä íàáðàí => êîíåö óðîâíÿ:
2046 if b
>= gGameSettings
.ScoreLimit
then
2053 // Îáðàáàòûâàåì êëàâèøè èãðîêîâ:
2054 if gPlayer1
<> nil then gPlayer1
.ReleaseKeys();
2055 if gPlayer2
<> nil then gPlayer2
.ReleaseKeys();
2056 if (not gConsoleShow
) and (not gChatShow
) and (g_ActiveWindow
= nil) then
2058 ProcessPlayerControls(gPlayer1
, 0, P1MoveButton
);
2059 ProcessPlayerControls(gPlayer2
, 1, P2MoveButton
);
2060 end // if not console
2063 if g_Game_IsNet
and (gPlayer1
<> nil) then gPlayer1
.PressKey(KEY_CHAT
, 10000);
2065 // process weapon switch queue
2069 if (gPlayer1
= nil) and (gPlayer2
= nil) and
2070 (not gConsoleShow
) and (not gChatShow
) and (g_ActiveWindow
= nil) then
2072 if not gSpectKeyPress
then
2074 if gPlayerAction
[0, ACTION_JUMP
] and (not gSpectAuto
) then
2076 // switch spect mode
2078 SPECT_NONE
: ; // not spectator
2080 SPECT_MAPVIEW
: Inc(gSpectMode
);
2081 SPECT_PLAYERS
: gSpectMode
:= SPECT_STATS
; // reset to 1
2083 gSpectKeyPress
:= True;
2085 if (gSpectMode
= SPECT_MAPVIEW
)
2086 and (not gSpectAuto
) then
2088 if gPlayerAction
[0, ACTION_MOVELEFT
] then
2089 gSpectX
:= Max(gSpectX
- gSpectStep
, 0);
2090 if gPlayerAction
[0, ACTION_MOVERIGHT
] then
2091 gSpectX
:= Min(gSpectX
+ gSpectStep
, gMapInfo
.Width
- gScreenWidth
);
2092 if gPlayerAction
[0, ACTION_LOOKUP
] then
2093 gSpectY
:= Max(gSpectY
- gSpectStep
, 0);
2094 if gPlayerAction
[0, ACTION_LOOKDOWN
] then
2095 gSpectY
:= Min(gSpectY
+ gSpectStep
, gMapInfo
.Height
- gScreenHeight
);
2096 if gWeaponAction
[0, WP_PREV
] then
2099 if gSpectStep
> 4 then gSpectStep
:= gSpectStep
shr 1;
2100 gWeaponAction
[0, WP_PREV
] := False;
2102 if gWeaponAction
[0, WP_NEXT
] then
2105 if gSpectStep
< 64 then gSpectStep
:= gSpectStep
shl 1;
2106 gWeaponAction
[0, WP_NEXT
] := False;
2109 if (gSpectMode
= SPECT_PLAYERS
)
2110 and (not gSpectAuto
) then
2112 if gPlayerAction
[0, ACTION_LOOKUP
] then
2115 gSpectViewTwo
:= True;
2116 gSpectKeyPress
:= True;
2118 if gPlayerAction
[0, ACTION_LOOKDOWN
] then
2120 // remove second view
2121 gSpectViewTwo
:= False;
2122 gSpectKeyPress
:= True;
2124 if gPlayerAction
[0, ACTION_MOVELEFT
] then
2126 // prev player (view 1)
2127 gSpectPID1
:= GetActivePlayerID_Prev(gSpectPID1
);
2128 gSpectKeyPress
:= True;
2130 if gPlayerAction
[0, ACTION_MOVERIGHT
] then
2132 // next player (view 1)
2133 gSpectPID1
:= GetActivePlayerID_Next(gSpectPID1
);
2134 gSpectKeyPress
:= True;
2136 if gWeaponAction
[0, WP_PREV
] then
2138 // prev player (view 2)
2139 gSpectPID2
:= GetActivePlayerID_Prev(gSpectPID2
);
2140 gWeaponAction
[0, WP_PREV
] := False;
2142 if gWeaponAction
[0, WP_NEXT
] then
2144 // next player (view 2)
2145 gSpectPID2
:= GetActivePlayerID_Next(gSpectPID2
);
2146 gWeaponAction
[0, WP_NEXT
] := False;
2149 if gPlayerAction
[0, ACTION_ATTACK
] then
2151 if (gSpectMode
= SPECT_STATS
) and (not gSpectAuto
) then
2154 gSpectAutoNext
:= 0;
2155 gSpectViewTwo
:= False;
2156 gSpectKeyPress
:= True;
2161 gSpectMode
:= SPECT_STATS
;
2162 gSpectAuto
:= False;
2163 gSpectKeyPress
:= True;
2168 if (not gPlayerAction
[0, ACTION_JUMP
]) and
2169 (not gPlayerAction
[0, ACTION_ATTACK
]) and
2170 (not gPlayerAction
[0, ACTION_MOVELEFT
]) and
2171 (not gPlayerAction
[0, ACTION_MOVERIGHT
]) and
2172 (not gPlayerAction
[0, ACTION_LOOKUP
]) and
2173 (not gPlayerAction
[0, ACTION_LOOKDOWN
]) then
2174 gSpectKeyPress
:= False;
2178 if gSpectMode
= SPECT_MAPVIEW
then
2180 i
:= Min(Max(gSpectX
+ gSpectAutoStepX
, 0), gMapInfo
.Width
- gScreenWidth
);
2182 gSpectAutoNext
:= gTime
2185 i
:= Min(Max(gSpectY
+ gSpectAutoStepY
, 0), gMapInfo
.Height
- gScreenHeight
);
2187 gSpectAutoNext
:= gTime
2191 if gSpectAutoNext
<= gTime
then
2193 if gSpectAutoNext
> 0 then
2195 gSpectMode
:= GetRandomSpectMode(gSpectMode
);
2199 gSpectX
:= Random(gMapInfo
.Width
- gScreenWidth
);
2200 gSpectY
:= Random(gMapInfo
.Height
- gScreenHeight
);
2201 gSpectAutoStepX
:= Random(9) - 4;
2202 gSpectAutoStepY
:= Random(9) - 4;
2203 if ((gSpectX
< 800) and (gSpectAutoStepX
< 0)) or
2204 ((gSpectX
> gMapInfo
.Width
- gScreenWidth
- 800) and (gSpectAutoStepX
> 0)) then
2205 gSpectAutoStepX
:= gSpectAutoStepX
* -1;
2206 if ((gSpectY
< 800) and (gSpectAutoStepY
< 0)) or
2207 ((gSpectY
> gMapInfo
.Height
- gScreenHeight
- 800) and (gSpectAutoStepY
> 0)) then
2208 gSpectAutoStepY
:= gSpectAutoStepY
* -1;
2212 gSpectPID1
:= GetActivePlayerID_Random(gSpectPID1
);
2217 SPECT_STATS
: gSpectAutoNext
:= gTime
+ (Random(3) + 5) * 1000;
2218 SPECT_MAPVIEW
: gSpectAutoNext
:= gTime
+ (Random(4) + 7) * 1000;
2219 SPECT_PLAYERS
: gSpectAutoNext
:= gTime
+ (Random(7) + 8) * 1000;
2225 // Îáíîâëÿåì âñå îñòàëüíîå:
2228 g_Triggers_Update();
2230 g_Monsters_Update();
2232 g_Player_UpdateAll();
2233 g_Player_UpdatePhysicalObjects();
2235 // server: send newly spawned monsters unconditionally
2236 if (gGameSettings
.GameType
= GT_SERVER
) then
2238 if (Length(gMonstersSpawned
) > 0) then
2240 for I
:= 0 to High(gMonstersSpawned
) do MH_SEND_MonsterSpawn(gMonstersSpawned
[I
]);
2241 SetLength(gMonstersSpawned
, 0);
2245 if (gSoundTriggerTime
> 8) then
2247 g_Game_UpdateTriggerSounds();
2248 gSoundTriggerTime
:= 0;
2252 Inc(gSoundTriggerTime
);
2255 if (NetMode
= NET_SERVER
) then
2257 Inc(NetTimeToUpdate
);
2258 Inc(NetTimeToReliable
);
2260 // send monster updates
2261 if (NetTimeToReliable
>= NetRelupdRate
) or (NetTimeToUpdate
>= NetUpdateRate
) then
2263 // send all monsters (periodic sync)
2264 reliableUpdate
:= (NetTimeToReliable
>= NetRelupdRate
);
2266 for I
:= 0 to High(gPlayers
) do
2268 if (gPlayers
[I
] <> nil) then MH_SEND_PlayerPos(reliableUpdate
, gPlayers
[I
].UID
);
2271 g_Mons_ForEach(sendMonsPos
);
2273 // update flags that aren't stationary
2274 if gGameSettings
.GameMode
= GM_CTF
then
2275 for I
:= FLAG_RED
to FLAG_BLUE
do
2276 if gFlags
[I
].NeedSend
then
2278 gFlags
[I
].NeedSend
:= False;
2282 // update items that aren't stationary
2283 g_Items_ForEachAlive(sendItemPos
);
2285 if reliableUpdate
then
2287 NetTimeToReliable
:= 0;
2288 NetTimeToUpdate
:= NetUpdateRate
;
2292 NetTimeToUpdate
:= 0;
2297 // send only mosters with some unexpected changes
2298 g_Mons_ForEach(sendMonsPosUnexpected
);
2301 // send unexpected platform changes
2302 g_Map_NetSendInterestingPanels();
2304 g_Net_Slist_ServerUpdate();
2306 if NetUseMaster then
2308 if (gTime >= NetTimeToMaster) or g_Net_Slist_IsConnectionInProgress then
2310 if (not g_Net_Slist_IsConnectionActive) then g_Net_Slist_Connect(false); // non-blocking connection to the master
2312 NetTimeToMaster := gTime + NetMasterRate;
2317 else if (NetMode
= NET_CLIENT
) then
2319 MC_SEND_PlayerPos();
2321 end; // if gameOn ...
2323 // Àêòèâíî îêíî èíòåðôåéñà - ïåðåäàåì êëàâèøè åìó:
2324 if g_ActiveWindow
<> nil then
2326 w
:= e_GetFirstKeyPressed();
2328 if (w
<> IK_INVALID
) then
2330 Msg
.Msg
:= MESSAGE_DIKEY
;
2332 g_ActiveWindow
.OnMessage(Msg
);
2335 // Åñëè îíî îò ýòîãî íå çàêðûëîñü, òî îáíîâëÿåì:
2336 if g_ActiveWindow
<> nil then
2337 g_ActiveWindow
.Update();
2339 // Íóæíî ñìåíèòü ðàçðåøåíèå:
2340 if gResolutionChange
then
2342 e_WriteLog('Changing resolution', TMsgType
.Notify
);
2343 g_Game_ChangeResolution(gRC_Width
, gRC_Height
, gRC_FullScreen
, gRC_Maximized
);
2344 gResolutionChange
:= False;
2345 g_ActiveWindow
:= nil;
2348 // Íóæíî ñìåíèòü ÿçûê:
2349 if gLanguageChange
then
2351 //e_WriteLog('Read language file', MSG_NOTIFY);
2352 //g_Language_Load(DataDir + gLanguage + '.txt');
2353 g_Language_Set(gLanguage
);
2357 gLanguageChange
:= False;
2361 // Ãîðÿ÷àÿ êëàâèøà äëÿ âûçîâà ìåíþ âûõîäà èç èãðû (F10):
2362 if e_KeyPressed(IK_F10
) and
2364 (not gConsoleShow
) and
2365 (g_ActiveWindow
= nil) then
2370 Time
:= sys_GetTicks() {div 1000};
2372 // Îáðàáîòêà îòëîæåííûõ ñîáûòèé:
2373 if gDelayedEvents
<> nil then
2374 for a
:= 0 to High(gDelayedEvents
) do
2375 if gDelayedEvents
[a
].Pending
and
2377 ((gDelayedEvents
[a
].DEType
= DE_GLOBEVENT
) and (gDelayedEvents
[a
].Time
<= Time
)) or
2378 ((gDelayedEvents
[a
].DEType
> DE_GLOBEVENT
) and (gDelayedEvents
[a
].Time
<= gTime
))
2381 case gDelayedEvents
[a
].DEType
of
2383 g_Game_ExecuteEvent(gDelayedEvents
[a
].DEStr
);
2386 g_Game_Announce_GoodShot(gDelayedEvents
[a
].DENum
);
2390 g_Game_Announce_KillCombo(gDelayedEvents
[a
].DENum
);
2391 if g_Game_IsNet
and g_Game_IsServer
then
2392 MH_SEND_GameEvent(NET_EV_KILLCOMBO
, gDelayedEvents
[a
].DENum
);
2396 g_Game_Announce_BodyKill(gDelayedEvents
[a
].DENum
);
2398 gDelayedEvents
[a
].Pending
:= False;
2401 // Êàæäóþ ñåêóíäó îáíîâëÿåì ñ÷åò÷èê îáíîâëåíèé:
2402 UPSCounter
:= UPSCounter
+ 1;
2403 if Time
- UPSTime
>= 1000 then
2412 g_Weapon_AddDynLights();
2413 g_Items_AddDynLights();
2417 procedure g_Game_LoadChatSounds(Resource
: string);
2420 FileName
, Snd
: string;
2422 len
, cnt
, tags
, i
, j
: Integer;
2425 FileName
:= g_ExtractWadName(Resource
);
2427 WAD
:= TWADFile
.Create();
2428 WAD
.ReadFile(FileName
);
2430 if not WAD
.GetResource(g_ExtractFilePathName(Resource
), p
, len
) then
2437 cfg
:= TConfig
.CreateMem(p
, len
);
2438 cnt
:= cfg
.ReadInt('ChatSounds', 'Count', 0);
2440 SetLength(gChatSounds
, cnt
);
2441 for i
:= 0 to Length(gChatSounds
) - 1 do
2443 gChatSounds
[i
].Sound
:= nil;
2444 Snd
:= Trim(cfg
.ReadStr(IntToStr(i
), 'Sound', ''));
2445 tags
:= cfg
.ReadInt(IntToStr(i
), 'Tags', 0);
2446 if (Snd
= '') or (Tags
<= 0) then
2448 g_Sound_CreateWADEx('SOUND_CHAT_MACRO' + IntToStr(i
), GameWAD
+':'+Snd
);
2449 gChatSounds
[i
].Sound
:= TPlayableSound
.Create();
2450 gChatSounds
[i
].Sound
.SetByName('SOUND_CHAT_MACRO' + IntToStr(i
));
2451 SetLength(gChatSounds
[i
].Tags
, tags
);
2452 for j
:= 0 to tags
- 1 do
2453 gChatSounds
[i
].Tags
[j
] := toLowerCase1251(cfg
.ReadStr(IntToStr(i
), 'Tag' + IntToStr(j
), ''));
2454 gChatSounds
[i
].FullWord
:= cfg
.ReadBool(IntToStr(i
), 'FullWord', False);
2461 procedure g_Game_FreeChatSounds();
2465 for i
:= 0 to Length(gChatSounds
) - 1 do
2467 gChatSounds
[i
].Sound
.Free();
2468 g_Sound_Delete('SOUND_CHAT_MACRO' + IntToStr(i
));
2470 SetLength(gChatSounds
, 0);
2474 procedure g_Game_LoadData();
2481 if DataLoaded
then Exit
;
2483 e_WriteLog('Loading game data...', TMsgType
.Notify
);
2485 g_Texture_CreateWADEx('NOTEXTURE', GameWAD
+':TEXTURES\NOTEXTURE');
2486 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUD', GameWAD
+':TEXTURES\HUD');
2487 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDAIR', GameWAD
+':TEXTURES\AIRBAR');
2488 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDJET', GameWAD
+':TEXTURES\JETBAR');
2489 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDBG', GameWAD
+':TEXTURES\HUDBG');
2490 g_Texture_CreateWADEx('TEXTURE_PLAYER_ARMORHUD', GameWAD
+':TEXTURES\ARMORHUD');
2491 g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG', GameWAD
+':TEXTURES\FLAGHUD_R_BASE');
2492 g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG_S', GameWAD
+':TEXTURES\FLAGHUD_R_STOLEN');
2493 g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG_D', GameWAD
+':TEXTURES\FLAGHUD_R_DROP');
2494 g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG', GameWAD
+':TEXTURES\FLAGHUD_B_BASE');
2495 g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG_S', GameWAD
+':TEXTURES\FLAGHUD_B_STOLEN');
2496 g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG_D', GameWAD
+':TEXTURES\FLAGHUD_B_DROP');
2497 g_Texture_CreateWADEx('TEXTURE_PLAYER_TALKBUBBLE', GameWAD
+':TEXTURES\TALKBUBBLE');
2498 g_Texture_CreateWADEx('TEXTURE_PLAYER_INVULPENTA', GameWAD
+':TEXTURES\PENTA');
2499 g_Texture_CreateWADEx('TEXTURE_PLAYER_INDICATOR', GameWAD
+':TEXTURES\PLRIND');
2502 if not g_Texture_CreateWADEx('UI_GFX_PBAR_LEFT', GameWAD
+':TEXTURES\LLEFT') then hasPBarGfx
:= false;
2503 if not g_Texture_CreateWADEx('UI_GFX_PBAR_MARKER', GameWAD
+':TEXTURES\LMARKER') then hasPBarGfx
:= false;
2504 if not g_Texture_CreateWADEx('UI_GFX_PBAR_MIDDLE', GameWAD
+':TEXTURES\LMIDDLE') then hasPBarGfx
:= false;
2505 if not g_Texture_CreateWADEx('UI_GFX_PBAR_RIGHT', GameWAD
+':TEXTURES\LRIGHT') then hasPBarGfx
:= false;
2509 g_Texture_GetSize('UI_GFX_PBAR_LEFT', wl
, hl
);
2510 g_Texture_GetSize('UI_GFX_PBAR_RIGHT', wr
, hr
);
2511 g_Texture_GetSize('UI_GFX_PBAR_MIDDLE', wb
, hb
);
2512 g_Texture_GetSize('UI_GFX_PBAR_MARKER', wm
, hm
);
2513 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
2519 hasPBarGfx
:= false;
2523 g_Frames_CreateWAD(nil, 'FRAMES_TELEPORT', GameWAD
+':TEXTURES\TELEPORT', 64, 64, 10, False);
2524 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH', GameWAD
+':WEAPONS\PUNCH', 64, 64, 4, False);
2525 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_UP', GameWAD
+':WEAPONS\PUNCH_UP', 64, 64, 4, False);
2526 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_DN', GameWAD
+':WEAPONS\PUNCH_DN', 64, 64, 4, False);
2527 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_BERSERK', GameWAD
+':WEAPONS\PUNCHB', 64, 64, 4, False);
2528 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_BERSERK_UP', GameWAD
+':WEAPONS\PUNCHB_UP', 64, 64, 4, False);
2529 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_BERSERK_DN', GameWAD
+':WEAPONS\PUNCHB_DN', 64, 64, 4, False);
2530 g_Sound_CreateWADEx('SOUND_GAME_TELEPORT', GameWAD
+':SOUNDS\TELEPORT');
2531 g_Sound_CreateWADEx('SOUND_GAME_NOTELEPORT', GameWAD
+':SOUNDS\NOTELEPORT');
2532 g_Sound_CreateWADEx('SOUND_GAME_SECRET', GameWAD
+':SOUNDS\SECRET');
2533 g_Sound_CreateWADEx('SOUND_GAME_DOOROPEN', GameWAD
+':SOUNDS\DOOROPEN');
2534 g_Sound_CreateWADEx('SOUND_GAME_DOORCLOSE', GameWAD
+':SOUNDS\DOORCLOSE');
2535 g_Sound_CreateWADEx('SOUND_GAME_BULK1', GameWAD
+':SOUNDS\BULK1');
2536 g_Sound_CreateWADEx('SOUND_GAME_BULK2', GameWAD
+':SOUNDS\BULK2');
2537 g_Sound_CreateWADEx('SOUND_GAME_BUBBLE1', GameWAD
+':SOUNDS\BUBBLE1');
2538 g_Sound_CreateWADEx('SOUND_GAME_BUBBLE2', GameWAD
+':SOUNDS\BUBBLE2');
2539 g_Sound_CreateWADEx('SOUND_GAME_BURNING', GameWAD
+':SOUNDS\BURNING');
2540 g_Sound_CreateWADEx('SOUND_GAME_SWITCH1', GameWAD
+':SOUNDS\SWITCH1');
2541 g_Sound_CreateWADEx('SOUND_GAME_SWITCH0', GameWAD
+':SOUNDS\SWITCH0');
2542 g_Sound_CreateWADEx('SOUND_GAME_RADIO', GameWAD
+':SOUNDS\RADIO');
2543 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD1', GameWAD
+':SOUNDS\GOOD1');
2544 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD2', GameWAD
+':SOUNDS\GOOD2');
2545 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD3', GameWAD
+':SOUNDS\GOOD3');
2546 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD4', GameWAD
+':SOUNDS\GOOD4');
2547 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL2X', GameWAD
+':SOUNDS\KILL2X');
2548 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL3X', GameWAD
+':SOUNDS\KILL3X');
2549 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL4X', GameWAD
+':SOUNDS\KILL4X');
2550 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILLMX', GameWAD
+':SOUNDS\KILLMX');
2551 g_Sound_CreateWADEx('SOUND_ANNOUNCER_MUHAHA1', GameWAD
+':SOUNDS\MUHAHA1');
2552 g_Sound_CreateWADEx('SOUND_ANNOUNCER_MUHAHA2', GameWAD
+':SOUNDS\MUHAHA2');
2553 g_Sound_CreateWADEx('SOUND_ANNOUNCER_MUHAHA3', GameWAD
+':SOUNDS\MUHAHA3');
2554 g_Sound_CreateWADEx('SOUND_CTF_GET1', GameWAD
+':SOUNDS\GETFLAG1');
2555 g_Sound_CreateWADEx('SOUND_CTF_GET2', GameWAD
+':SOUNDS\GETFLAG2');
2556 g_Sound_CreateWADEx('SOUND_CTF_LOST1', GameWAD
+':SOUNDS\LOSTFLG1');
2557 g_Sound_CreateWADEx('SOUND_CTF_LOST2', GameWAD
+':SOUNDS\LOSTFLG2');
2558 g_Sound_CreateWADEx('SOUND_CTF_RETURN1', GameWAD
+':SOUNDS\RETFLAG1');
2559 g_Sound_CreateWADEx('SOUND_CTF_RETURN2', GameWAD
+':SOUNDS\RETFLAG2');
2560 g_Sound_CreateWADEx('SOUND_CTF_CAPTURE1', GameWAD
+':SOUNDS\CAPFLAG1');
2561 g_Sound_CreateWADEx('SOUND_CTF_CAPTURE2', GameWAD
+':SOUNDS\CAPFLAG2');
2563 goodsnd
[0] := TPlayableSound
.Create();
2564 goodsnd
[1] := TPlayableSound
.Create();
2565 goodsnd
[2] := TPlayableSound
.Create();
2566 goodsnd
[3] := TPlayableSound
.Create();
2568 goodsnd
[0].SetByName('SOUND_ANNOUNCER_GOOD1');
2569 goodsnd
[1].SetByName('SOUND_ANNOUNCER_GOOD2');
2570 goodsnd
[2].SetByName('SOUND_ANNOUNCER_GOOD3');
2571 goodsnd
[3].SetByName('SOUND_ANNOUNCER_GOOD4');
2573 killsnd
[0] := TPlayableSound
.Create();
2574 killsnd
[1] := TPlayableSound
.Create();
2575 killsnd
[2] := TPlayableSound
.Create();
2576 killsnd
[3] := TPlayableSound
.Create();
2578 killsnd
[0].SetByName('SOUND_ANNOUNCER_KILL2X');
2579 killsnd
[1].SetByName('SOUND_ANNOUNCER_KILL3X');
2580 killsnd
[2].SetByName('SOUND_ANNOUNCER_KILL4X');
2581 killsnd
[3].SetByName('SOUND_ANNOUNCER_KILLMX');
2583 hahasnd
[0] := TPlayableSound
.Create();
2584 hahasnd
[1] := TPlayableSound
.Create();
2585 hahasnd
[2] := TPlayableSound
.Create();
2587 hahasnd
[0].SetByName('SOUND_ANNOUNCER_MUHAHA1');
2588 hahasnd
[1].SetByName('SOUND_ANNOUNCER_MUHAHA2');
2589 hahasnd
[2].SetByName('SOUND_ANNOUNCER_MUHAHA3');
2591 sound_get_flag
[0] := TPlayableSound
.Create();
2592 sound_get_flag
[1] := TPlayableSound
.Create();
2593 sound_lost_flag
[0] := TPlayableSound
.Create();
2594 sound_lost_flag
[1] := TPlayableSound
.Create();
2595 sound_ret_flag
[0] := TPlayableSound
.Create();
2596 sound_ret_flag
[1] := TPlayableSound
.Create();
2597 sound_cap_flag
[0] := TPlayableSound
.Create();
2598 sound_cap_flag
[1] := TPlayableSound
.Create();
2600 sound_get_flag
[0].SetByName('SOUND_CTF_GET1');
2601 sound_get_flag
[1].SetByName('SOUND_CTF_GET2');
2602 sound_lost_flag
[0].SetByName('SOUND_CTF_LOST1');
2603 sound_lost_flag
[1].SetByName('SOUND_CTF_LOST2');
2604 sound_ret_flag
[0].SetByName('SOUND_CTF_RETURN1');
2605 sound_ret_flag
[1].SetByName('SOUND_CTF_RETURN2');
2606 sound_cap_flag
[0].SetByName('SOUND_CTF_CAPTURE1');
2607 sound_cap_flag
[1].SetByName('SOUND_CTF_CAPTURE2');
2609 g_Game_LoadChatSounds(GameWAD
+':CHATSND\SNDCFG');
2611 g_Game_SetLoadingText(_lc
[I_LOAD_ITEMS_DATA
], 0, False);
2614 g_Game_SetLoadingText(_lc
[I_LOAD_WEAPONS_DATA
], 0, False);
2615 g_Weapon_LoadData();
2617 g_Monsters_LoadData();
2622 procedure g_Game_FreeData();
2624 if not DataLoaded
then Exit
;
2627 g_Weapon_FreeData();
2628 g_Monsters_FreeData();
2630 e_WriteLog('Releasing game data...', TMsgType
.Notify
);
2632 g_Texture_Delete('NOTEXTURE');
2633 g_Texture_Delete('TEXTURE_PLAYER_HUD');
2634 g_Texture_Delete('TEXTURE_PLAYER_HUDBG');
2635 g_Texture_Delete('TEXTURE_PLAYER_ARMORHUD');
2636 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG');
2637 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG_S');
2638 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG_D');
2639 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG');
2640 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG_S');
2641 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG_D');
2642 g_Texture_Delete('TEXTURE_PLAYER_TALKBUBBLE');
2643 g_Texture_Delete('TEXTURE_PLAYER_INVULPENTA');
2644 g_Frames_DeleteByName('FRAMES_TELEPORT');
2645 g_Frames_DeleteByName('FRAMES_PUNCH');
2646 g_Frames_DeleteByName('FRAMES_PUNCH_UP');
2647 g_Frames_DeleteByName('FRAMES_PUNCH_DN');
2648 g_Frames_DeleteByName('FRAMES_PUNCH_BERSERK');
2649 g_Frames_DeleteByName('FRAMES_PUNCH_BERSERK_UP');
2650 g_Frames_DeleteByName('FRAMES_PUNCH_BERSERK_DN');
2651 g_Sound_Delete('SOUND_GAME_TELEPORT');
2652 g_Sound_Delete('SOUND_GAME_NOTELEPORT');
2653 g_Sound_Delete('SOUND_GAME_SECRET');
2654 g_Sound_Delete('SOUND_GAME_DOOROPEN');
2655 g_Sound_Delete('SOUND_GAME_DOORCLOSE');
2656 g_Sound_Delete('SOUND_GAME_BULK1');
2657 g_Sound_Delete('SOUND_GAME_BULK2');
2658 g_Sound_Delete('SOUND_GAME_BUBBLE1');
2659 g_Sound_Delete('SOUND_GAME_BUBBLE2');
2660 g_Sound_Delete('SOUND_GAME_BURNING');
2661 g_Sound_Delete('SOUND_GAME_SWITCH1');
2662 g_Sound_Delete('SOUND_GAME_SWITCH0');
2669 g_Sound_Delete('SOUND_ANNOUNCER_GOOD1');
2670 g_Sound_Delete('SOUND_ANNOUNCER_GOOD2');
2671 g_Sound_Delete('SOUND_ANNOUNCER_GOOD3');
2672 g_Sound_Delete('SOUND_ANNOUNCER_GOOD4');
2679 g_Sound_Delete('SOUND_ANNOUNCER_KILL2X');
2680 g_Sound_Delete('SOUND_ANNOUNCER_KILL3X');
2681 g_Sound_Delete('SOUND_ANNOUNCER_KILL4X');
2682 g_Sound_Delete('SOUND_ANNOUNCER_KILLMX');
2688 g_Sound_Delete('SOUND_ANNOUNCER_MUHAHA1');
2689 g_Sound_Delete('SOUND_ANNOUNCER_MUHAHA2');
2690 g_Sound_Delete('SOUND_ANNOUNCER_MUHAHA3');
2692 sound_get_flag
[0].Free();
2693 sound_get_flag
[1].Free();
2694 sound_lost_flag
[0].Free();
2695 sound_lost_flag
[1].Free();
2696 sound_ret_flag
[0].Free();
2697 sound_ret_flag
[1].Free();
2698 sound_cap_flag
[0].Free();
2699 sound_cap_flag
[1].Free();
2701 g_Sound_Delete('SOUND_CTF_GET1');
2702 g_Sound_Delete('SOUND_CTF_GET2');
2703 g_Sound_Delete('SOUND_CTF_LOST1');
2704 g_Sound_Delete('SOUND_CTF_LOST2');
2705 g_Sound_Delete('SOUND_CTF_RETURN1');
2706 g_Sound_Delete('SOUND_CTF_RETURN2');
2707 g_Sound_Delete('SOUND_CTF_CAPTURE1');
2708 g_Sound_Delete('SOUND_CTF_CAPTURE2');
2710 g_Game_FreeChatSounds();
2712 DataLoaded
:= False;
2715 procedure DrawCustomStat();
2721 ww2
, hh2
, r
, g
, b
, rr
, gg
, bb
: Byte;
2722 s1
, s2
, topstr
: String;
2724 e_TextureFontGetSize(gStdFont
, ww2
, hh2
);
2728 if g_Console_Action(ACTION_SCORES
) then
2730 if not gStatsPressed
then
2732 gStatsOff
:= not gStatsOff
;
2733 gStatsPressed
:= True;
2737 gStatsPressed
:= False;
2741 s1
:= _lc
[I_MENU_INTER_NOTICE_TAB
];
2742 w
:= (Length(s1
) * ww2
) div 2;
2743 x
:= gScreenWidth
div 2 - w
;
2745 e_TextureFontPrint(x
, y
, s1
, gStdFont
);
2749 if (gGameSettings
.GameMode
= GM_COOP
) then
2751 if gMissionFailed
then
2752 topstr
:= _lc
[I_MENU_INTER_MISSION_FAIL
]
2754 topstr
:= _lc
[I_MENU_INTER_LEVEL_COMPLETE
];
2757 topstr
:= _lc
[I_MENU_INTER_ROUND_OVER
];
2759 e_CharFont_GetSize(gMenuFont
, topstr
, ww1
, hh1
);
2760 e_CharFont_Print(gMenuFont
, (gScreenWidth
div 2)-(ww1
div 2), 16, topstr
);
2762 if g_Game_IsNet
then
2764 topstr
:= Format(_lc
[I_MENU_INTER_NOTICE_TIME
], [gServInterTime
]);
2765 if not gChatShow
then
2766 e_TextureFontPrintEx((gScreenWidth
div 2)-(Length(topstr
)*ww2
div 2),
2767 gScreenHeight
-(hh2
+4)*2, topstr
, gStdFont
, 255, 255, 255, 1);
2770 if g_Game_IsClient
then
2771 topstr
:= _lc
[I_MENU_INTER_NOTICE_MAP
]
2773 topstr
:= _lc
[I_MENU_INTER_NOTICE_SPACE
];
2774 if not gChatShow
then
2775 e_TextureFontPrintEx((gScreenWidth
div 2)-(Length(topstr
)*ww2
div 2),
2776 gScreenHeight
-(hh2
+4), topstr
, gStdFont
, 255, 255, 255, 1);
2781 w
:= gScreenWidth
-x
*2;
2787 e_DrawFillQuad(x
, y
, gScreenWidth
-x
-1, gScreenHeight
-y
-1, 64, 64, 64, 32);
2788 e_DrawQuad(x
, y
, gScreenWidth
-x
-1, gScreenHeight
-y
-1, 255, 127, 0);
2790 m
:= Max(Length(_lc
[I_MENU_MAP
])+1, Length(_lc
[I_GAME_GAME_TIME
])+1)*ww2
;
2792 case CustomStat
.GameMode
of
2795 if gGameSettings
.MaxLives
= 0 then
2796 s1
:= _lc
[I_GAME_DM
]
2798 s1
:= _lc
[I_GAME_LMS
];
2802 if gGameSettings
.MaxLives
= 0 then
2803 s1
:= _lc
[I_GAME_TDM
]
2805 s1
:= _lc
[I_GAME_TLMS
];
2807 GM_CTF
: s1
:= _lc
[I_GAME_CTF
];
2810 if gGameSettings
.MaxLives
= 0 then
2811 s1
:= _lc
[I_GAME_COOP
]
2813 s1
:= _lc
[I_GAME_SURV
];
2819 e_TextureFontPrintEx(x
+(w
div 2)-(Length(s1
)*ww2
div 2), _y
, s1
, gStdFont
, 255, 255, 255, 1);
2823 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_MENU_MAP
], gStdFont
, 255, 127, 0, 1);
2824 e_TextureFontPrint(x
+8+m
, _y
, Format('%s - %s', [CustomStat
.Map
, CustomStat
.MapName
]), gStdFont
);
2827 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_GAME_TIME
], gStdFont
, 255, 127, 0, 1);
2828 e_TextureFontPrint(x
+8+m
, _y
, Format('%d:%.2d:%.2d', [CustomStat
.GameTime
div 1000 div 3600,
2829 (CustomStat
.GameTime
div 1000 div 60) mod 60,
2830 CustomStat
.GameTime
div 1000 mod 60]), gStdFont
);
2832 pc
:= Length(CustomStat
.PlayerStat
);
2833 if pc
= 0 then Exit
;
2835 if CustomStat
.GameMode
= GM_COOP
then
2837 m
:= Max(Length(_lc
[I_GAME_MONSTERS
])+1, Length(_lc
[I_GAME_SECRETS
])+1)*ww2
;
2839 s2
:= _lc
[I_GAME_MONSTERS
];
2840 e_TextureFontPrintEx(x
+8, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2841 e_TextureFontPrintEx(x
+8+m
, _y
, IntToStr(gCoopMonstersKilled
) + '/' + IntToStr(gTotalMonsters
), gStdFont
, 255, 255, 255, 1);
2843 s2
:= _lc
[I_GAME_SECRETS
];
2844 e_TextureFontPrintEx(x
+8, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2845 e_TextureFontPrintEx(x
+8+m
, _y
, IntToStr(gCoopSecretsFound
) + '/' + IntToStr(gSecretsCount
), gStdFont
, 255, 255, 255, 1);
2848 m
:= Max(Length(_lc
[I_GAME_MONSTERS_TOTAL
])+1, Length(_lc
[I_GAME_SECRETS_TOTAL
])+1)*ww2
;
2850 s2
:= _lc
[I_GAME_MONSTERS_TOTAL
];
2851 e_TextureFontPrintEx(x
+250, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2852 e_TextureFontPrintEx(x
+250+m
, _y
, IntToStr(gCoopTotalMonstersKilled
) + '/' + IntToStr(gCoopTotalMonsters
), gStdFont
, 255, 255, 255, 1);
2854 s2
:= _lc
[I_GAME_SECRETS_TOTAL
];
2855 e_TextureFontPrintEx(x
+250, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2856 e_TextureFontPrintEx(x
+250+m
, _y
, IntToStr(gCoopTotalSecretsFound
) + '/' + IntToStr(gCoopTotalSecrets
), gStdFont
, 255, 255, 255, 1);
2860 if CustomStat
.GameMode
in [GM_TDM
, GM_CTF
] then
2865 if TeamStat
[TEAM_RED
].Score
> TeamStat
[TEAM_BLUE
].Score
then s1
:= _lc
[I_GAME_WIN_RED
]
2866 else if TeamStat
[TEAM_BLUE
].Score
> TeamStat
[TEAM_RED
].Score
then s1
:= _lc
[I_GAME_WIN_BLUE
]
2867 else s1
:= _lc
[I_GAME_WIN_DRAW
];
2869 e_TextureFontPrintEx(x
+8+(w
div 2)-(Length(s1
)*ww2
div 2), _y
, s1
, gStdFont
, 255, 255, 255, 1);
2872 for t
:= TEAM_RED
to TEAM_BLUE
do
2874 if t
= TEAM_RED
then
2876 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_TEAM_RED
],
2877 gStdFont
, 255, 0, 0, 1);
2878 e_TextureFontPrintEx(x
+w1
+8, _y
, IntToStr(CustomStat
.TeamStat
[TEAM_RED
].Score
),
2879 gStdFont
, 255, 0, 0, 1);
2886 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_TEAM_BLUE
],
2887 gStdFont
, 0, 0, 255, 1);
2888 e_TextureFontPrintEx(x
+w1
+8, _y
, IntToStr(CustomStat
.TeamStat
[TEAM_BLUE
].Score
),
2889 gStdFont
, 0, 0, 255, 1);
2895 e_DrawLine(1, x
+8, _y
+20, x
-8+w
, _y
+20, r
, g
, b
);
2898 for p
:= 0 to High(CustomStat
.PlayerStat
) do
2899 if CustomStat
.PlayerStat
[p
].Team
= t
then
2900 with CustomStat
.PlayerStat
[p
] do
2914 if (gPlayers
[Num
] <> nil) and (gPlayers
[Num
].FReady
) then
2915 e_TextureFontPrintEx(x
+16, _y
, Name
+ ' *', gStdFont
, rr
, gg
, bb
, 1)
2917 e_TextureFontPrintEx(x
+16, _y
, Name
, gStdFont
, rr
, gg
, bb
, 1);
2918 e_TextureFontPrintEx(x
+w1
+16, _y
, IntToStr(Frags
), gStdFont
, rr
, gg
, bb
, 1);
2919 e_TextureFontPrintEx(x
+w1
+w2
+16, _y
, IntToStr(Deaths
), gStdFont
, rr
, gg
, bb
, 1);
2926 else if CustomStat
.GameMode
in [GM_DM
, GM_COOP
] then
2929 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_PLAYER_NAME
], gStdFont
, 255, 127, 0, 1);
2930 e_TextureFontPrintEx(x
+8+w1
, _y
, _lc
[I_GAME_FRAGS
], gStdFont
, 255, 127, 0, 1);
2931 e_TextureFontPrintEx(x
+8+w1
+w2
, _y
, _lc
[I_GAME_DEATHS
], gStdFont
, 255, 127, 0, 1);
2934 for p
:= 0 to High(CustomStat
.PlayerStat
) do
2935 with CustomStat
.PlayerStat
[p
] do
2937 e_DrawFillQuad(x
+8, _y
+4, x
+24-1, _y
+16+4-1, Color
.R
, Color
.G
, Color
.B
, 0);
2944 if (gPlayers
[Num
] <> nil) and (gPlayers
[Num
].FReady
) then
2945 e_TextureFontPrintEx(x
+8+16+8, _y
+4, Name
+ ' *', gStdFont
, r
, r
, r
, 1, True)
2947 e_TextureFontPrintEx(x
+8+16+8, _y
+4, Name
, gStdFont
, r
, r
, r
, 1, True);
2948 e_TextureFontPrintEx(x
+w1
+8+16+8, _y
+4, IntToStr(Frags
), gStdFont
, r
, r
, r
, 1, True);
2949 e_TextureFontPrintEx(x
+w1
+w2
+8+16+8, _y
+4, IntToStr(Deaths
), gStdFont
, r
, r
, r
, 1, True);
2954 // HACK: take stats screenshot immediately after the first frame of the stats showing
2955 if gScreenshotStats
and (not StatShotDone
) and (Length(CustomStat
.PlayerStat
) > 1) then
2957 g_TakeScreenShot('stats/' + StatFilename
);
2958 StatShotDone
:= True;
2962 procedure DrawSingleStat();
2964 tm
, key_x
, val_x
, y
: Integer;
2968 procedure player_stat(n
: Integer);
2974 s1
:= Format(' %d ', [SingleStat
.PlayerStat
[n
].Kills
]);
2975 s2
:= Format(' %d', [gTotalMonsters
]);
2977 e_CharFont_Print(gMenuFont
, key_x
, y
, _lc
[I_MENU_INTER_KILLS
]);
2978 e_CharFont_PrintEx(gMenuFont
, val_x
, y
, s1
, _RGB(255, 0, 0));
2979 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2980 e_CharFont_Print(gMenuFont
, val_x
+w1
, y
, '/');
2982 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2983 e_CharFont_PrintEx(gMenuFont
, val_x
+w1
, y
, s2
, _RGB(255, 0, 0));
2985 // "Kills-per-minute: ##.#":
2986 s1
:= _lc
[I_MENU_INTER_KPM
];
2988 kpm
:= (SingleStat
.PlayerStat
[n
].Kills
/ tm
) * 60
2990 kpm
:= SingleStat
.PlayerStat
[n
].Kills
;
2991 s2
:= Format(' %.1f', [kpm
]);
2993 e_CharFont_Print(gMenuFont
, key_x
, y
+32, s1
);
2994 e_CharFont_PrintEx(gMenuFont
, val_x
, y
+32, s2
, _RGB(255, 0, 0));
2996 // "Secrets found: # / #":
2997 s1
:= Format(' %d ', [SingleStat
.PlayerStat
[n
].Secrets
]);
2998 s2
:= Format(' %d', [SingleStat
.TotalSecrets
]);
3000 e_CharFont_Print(gMenuFont
, key_x
, y
+64, _lc
[I_MENU_INTER_SECRETS
]);
3001 e_CharFont_PrintEx(gMenuFont
, val_x
, y
+64, s1
, _RGB(255, 0, 0));
3002 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
3003 e_CharFont_Print(gMenuFont
, val_x
+w1
, y
+64, '/');
3005 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
3006 e_CharFont_PrintEx(gMenuFont
, val_x
+w1
, y
+64, s2
, _RGB(255, 0, 0));
3010 // "Level Complete":
3011 e_CharFont_GetSize(gMenuFont
, _lc
[I_MENU_INTER_LEVEL_COMPLETE
], w1
, h
);
3012 e_CharFont_Print(gMenuFont
, (gScreenWidth
-w1
) div 2, 32, _lc
[I_MENU_INTER_LEVEL_COMPLETE
]);
3014 // Îïðåäåëÿåì êîîðäèíàòû âûðàâíèâàíèÿ ïî ñàìîé äëèííîé ñòðîêå:
3015 s1
:= _lc
[I_MENU_INTER_KPM
];
3016 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
3019 e_CharFont_GetSize(gMenuFont
, s1
, w2
, h
);
3021 key_x
:= (gScreenWidth
-w1
-w2
) div 2;
3022 val_x
:= key_x
+ w1
;
3025 tm
:= SingleStat
.GameTime
div 1000;
3026 s1
:= _lc
[I_MENU_INTER_TIME
];
3027 s2
:= Format(' %d:%.2d:%.2d', [tm
div (60*60), (tm
mod (60*60)) div 60, tm
mod 60]);
3029 e_CharFont_Print(gMenuFont
, key_x
, 80, s1
);
3030 e_CharFont_PrintEx(gMenuFont
, val_x
, 80, s2
, _RGB(255, 0, 0));
3032 if SingleStat
.TwoPlayers
then
3035 s1
:= _lc
[I_MENU_PLAYER_1
];
3036 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
3037 e_CharFont_Print(gMenuFont
, (gScreenWidth
-w1
) div 2, 128, s1
);
3039 // Ñòàòèñòèêà ïåðâîãî èãðîêà:
3044 s1
:= _lc
[I_MENU_PLAYER_2
];
3045 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
3046 e_CharFont_Print(gMenuFont
, (gScreenWidth
-w1
) div 2, 288, s1
);
3048 // Ñòàòèñòèêà âòîðîãî èãðîêà:
3054 // Ñòàòèñòèêà ïåðâîãî èãðîêà:
3060 procedure DrawLoadingStat();
3061 procedure drawRect (x
, y
, w
, h
: Integer);
3063 if (w
< 1) or (h
< 1) then exit
;
3065 glVertex2f(x
+0.375, y
+0.375);
3066 glVertex2f(x
+w
+0.375, y
+0.375);
3067 glVertex2f(x
+w
+0.375, y
+h
+0.375);
3068 glVertex2f(x
+0.375, y
+h
+0.375);
3072 function drawPBar (cur
, total
: Integer; washere
: Boolean): Boolean;
3074 rectW
, rectH
: Integer;
3081 idl
, idr
, idb
, idm
: LongWord;
3085 if (total
< 1) then exit
;
3086 if (cur
< 1) then exit
; // don't blink
3087 if (not washere
) and (cur
>= total
) then exit
; // don't blink
3088 //if (cur < 0) then cur := 0;
3089 //if (cur > total) then cur := total;
3092 if (hasPBarGfx
) then
3094 g_Texture_Get('UI_GFX_PBAR_LEFT', idl
);
3095 g_Texture_GetSize('UI_GFX_PBAR_LEFT', wl
, hl
);
3096 g_Texture_Get('UI_GFX_PBAR_RIGHT', idr
);
3097 g_Texture_GetSize('UI_GFX_PBAR_RIGHT', wr
, hr
);
3098 g_Texture_Get('UI_GFX_PBAR_MIDDLE', idb
);
3099 g_Texture_GetSize('UI_GFX_PBAR_MIDDLE', wb
, hb
);
3100 g_Texture_Get('UI_GFX_PBAR_MARKER', idm
);
3101 g_Texture_GetSize('UI_GFX_PBAR_MARKER', wm
, hm
);
3103 //rectW := gScreenWidth-360;
3104 rectW
:= trunc(624.0*gScreenWidth
/1024.0);
3107 x0
:= (gScreenWidth
-rectW
) div 2;
3108 y0
:= gScreenHeight
-rectH
-64;
3109 if (y0
< 2) then y0
:= 2;
3111 glEnable(GL_SCISSOR_TEST
);
3114 glScissor(x0
, gScreenHeight
-y0
-rectH
, rectW
, rectH
);
3115 e_DrawSize(idl
, x0
, y0
, 0, true, false, wl
, hl
);
3116 e_DrawSize(idr
, x0
+rectW
-wr
, y0
, 0, true, false, wr
, hr
);
3119 glScissor(x0
+wl
, gScreenHeight
-y0
-rectH
, rectW
-wl
-wr
, rectH
);
3121 while (f
< x0
+rectW
) do
3123 e_DrawSize(idb
, f
, y0
, 0, true, false, wb
, hb
);
3128 wdt
:= (rectW
-wl
-wr
)*cur
div total
;
3129 if (wdt
> rectW
-wl
-wr
) then wdt
:= rectW
-wr
-wr
;
3132 my
:= y0
; // don't be so smart, ketmar: +(rectH-wm) div 2;
3133 glScissor(x0
+wl
, gScreenHeight
-my
-rectH
, wdt
, hm
);
3137 e_DrawSize(idm
, f
, y0
, 0, true, false, wm
, hm
);
3143 glScissor(0, 0, gScreenWidth
, gScreenHeight
);
3147 rectW
:= gScreenWidth
-64;
3150 x0
:= (gScreenWidth
-rectW
) div 2;
3151 y0
:= gScreenHeight
-rectH
-64;
3152 if (y0
< 2) then y0
:= 2;
3154 glDisable(GL_BLEND
);
3155 glDisable(GL_TEXTURE_2D
);
3157 //glClearColor(0, 0, 0, 0);
3158 //glClear(GL_COLOR_BUFFER_BIT);
3160 glColor4ub(127, 127, 127, 255);
3161 drawRect(x0
-2, y0
-2, rectW
+4, rectH
+4);
3163 glColor4ub(0, 0, 0, 255);
3164 drawRect(x0
-1, y0
-1, rectW
+2, rectH
+2);
3166 glColor4ub(127, 127, 127, 255);
3167 wdt
:= rectW
*cur
div total
;
3168 if (wdt
> rectW
) then wdt
:= rectW
;
3169 drawRect(x0
, y0
, wdt
, rectH
);
3178 if (Length(LoadingStat
.Msgs
) = 0) then exit
;
3180 e_CharFont_GetSize(gMenuFont
, _lc
[I_MENU_LOADING
], ww
, hh
);
3181 yy
:= (gScreenHeight
div 3);
3182 e_CharFont_Print(gMenuFont
, (gScreenWidth
div 2)-(ww
div 2), yy
-2*hh
, _lc
[I_MENU_LOADING
]);
3183 xx
:= (gScreenWidth
div 3);
3187 for i
:= 0 to NextMsg
-1 do
3189 if (i
= (NextMsg
-1)) and (MaxValue
> 0) then
3190 s
:= Format('%s: %d/%d', [Msgs
[i
], CurValue
, MaxValue
])
3194 e_CharFont_PrintEx(gMenuSmallFont
, xx
, yy
, s
, _RGB(255, 0, 0));
3195 yy
:= yy
+ LOADING_INTERLINE
;
3196 PBarWasHere
:= drawPBar(CurValue
, MaxValue
, PBarWasHere
);
3201 procedure DrawMenuBackground(tex
: AnsiString);
3207 if g_Texture_Get(tex
, ID
) then
3209 e_Clear(GL_COLOR_BUFFER_BIT
, 0, 0, 0);
3210 e_GetTextureSize(ID
, @w
, @h
);
3212 w
:= round(w
* 1.333 * (gScreenHeight
/ h
))
3214 w
:= trunc(w
* (gScreenHeight
/ h
));
3215 e_DrawSize(ID
, (gScreenWidth
- w
) div 2, 0, 0, False, False, w
, gScreenHeight
);
3217 else e_Clear(GL_COLOR_BUFFER_BIT
, 0, 0, 0);
3220 procedure DrawMinimap(p
: TPlayer
; RenderRect
: e_graphics
.TRect
);
3222 a
, aX
, aY
, aX2
, aY2
, Scale
, ScaleSz
: Integer;
3224 function monDraw (mon
: TMonster
): Boolean;
3226 result
:= false; // don't stop
3231 // Ëåâûé âåðõíèé óãîë
3232 aX
:= Obj
.X
div ScaleSz
+ 1;
3233 aY
:= Obj
.Y
div ScaleSz
+ 1;
3235 aX2
:= max(Obj
.Rect
.Width
div ScaleSz
, 1);
3236 aY2
:= max(Obj
.Rect
.Height
div ScaleSz
, 1);
3237 // Ïðàâûé íèæíèé óãîë
3238 aX2
:= aX
+ aX2
- 1;
3239 aY2
:= aY
+ aY2
- 1;
3240 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 255, 0, 0);
3246 if (gMapInfo
.Width
> RenderRect
.Right
- RenderRect
.Left
) or
3247 (gMapInfo
.Height
> RenderRect
.Bottom
- RenderRect
.Top
) then
3250 // Ñêîëüêî ïèêñåëîâ êàðòû â 1 ïèêñåëå ìèíè-êàðòû:
3251 ScaleSz
:= 16 div Scale
;
3252 // Ðàçìåðû ìèíè-êàðòû:
3253 aX
:= max(gMapInfo
.Width
div ScaleSz
, 1);
3254 aY
:= max(gMapInfo
.Height
div ScaleSz
, 1);
3256 e_DrawFillQuad(0, 0, aX
-1, aY
-1, 0, 0, 0, 0);
3258 if gWalls
<> nil then
3261 for a
:= 0 to High(gWalls
) do
3263 if PanelType
<> 0 then
3265 // Ëåâûé âåðõíèé óãîë:
3266 aX
:= X
div ScaleSz
;
3267 aY
:= Y
div ScaleSz
;
3269 aX2
:= max(Width
div ScaleSz
, 1);
3270 aY2
:= max(Height
div ScaleSz
, 1);
3271 // Ïðàâûé íèæíèé óãîë:
3272 aX2
:= aX
+ aX2
- 1;
3273 aY2
:= aY
+ aY2
- 1;
3276 PANEL_WALL
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 208, 208, 208, 0);
3277 PANEL_OPENDOOR
, PANEL_CLOSEDOOR
:
3278 if Enabled
then e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 160, 160, 160, 0);
3282 if gSteps
<> nil then
3285 for a
:= 0 to High(gSteps
) do
3287 if PanelType
<> 0 then
3289 // Ëåâûé âåðõíèé óãîë:
3290 aX
:= X
div ScaleSz
;
3291 aY
:= Y
div ScaleSz
;
3293 aX2
:= max(Width
div ScaleSz
, 1);
3294 aY2
:= max(Height
div ScaleSz
, 1);
3295 // Ïðàâûé íèæíèé óãîë:
3296 aX2
:= aX
+ aX2
- 1;
3297 aY2
:= aY
+ aY2
- 1;
3299 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 128, 128, 128, 0);
3302 if gLifts
<> nil then
3305 for a
:= 0 to High(gLifts
) do
3307 if PanelType
<> 0 then
3309 // Ëåâûé âåðõíèé óãîë:
3310 aX
:= X
div ScaleSz
;
3311 aY
:= Y
div ScaleSz
;
3313 aX2
:= max(Width
div ScaleSz
, 1);
3314 aY2
:= max(Height
div ScaleSz
, 1);
3315 // Ïðàâûé íèæíèé óãîë:
3316 aX2
:= aX
+ aX2
- 1;
3317 aY2
:= aY
+ aY2
- 1;
3320 LIFTTYPE_UP
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 116, 72, 36, 0);
3321 LIFTTYPE_DOWN
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 116, 124, 96, 0);
3322 LIFTTYPE_LEFT
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 200, 80, 4, 0);
3323 LIFTTYPE_RIGHT
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 252, 140, 56, 0);
3327 if gWater
<> nil then
3330 for a
:= 0 to High(gWater
) do
3332 if PanelType
<> 0 then
3334 // Ëåâûé âåðõíèé óãîë:
3335 aX
:= X
div ScaleSz
;
3336 aY
:= Y
div ScaleSz
;
3338 aX2
:= max(Width
div ScaleSz
, 1);
3339 aY2
:= max(Height
div ScaleSz
, 1);
3340 // Ïðàâûé íèæíèé óãîë:
3341 aX2
:= aX
+ aX2
- 1;
3342 aY2
:= aY
+ aY2
- 1;
3344 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 0, 192, 0);
3347 if gAcid1
<> nil then
3349 // Ðèñóåì êèñëîòó 1:
3350 for a
:= 0 to High(gAcid1
) do
3352 if PanelType
<> 0 then
3354 // Ëåâûé âåðõíèé óãîë:
3355 aX
:= X
div ScaleSz
;
3356 aY
:= Y
div ScaleSz
;
3358 aX2
:= max(Width
div ScaleSz
, 1);
3359 aY2
:= max(Height
div ScaleSz
, 1);
3360 // Ïðàâûé íèæíèé óãîë:
3361 aX2
:= aX
+ aX2
- 1;
3362 aY2
:= aY
+ aY2
- 1;
3364 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 176, 0, 0);
3367 if gAcid2
<> nil then
3369 // Ðèñóåì êèñëîòó 2:
3370 for a
:= 0 to High(gAcid2
) do
3372 if PanelType
<> 0 then
3374 // Ëåâûé âåðõíèé óãîë:
3375 aX
:= X
div ScaleSz
;
3376 aY
:= Y
div ScaleSz
;
3378 aX2
:= max(Width
div ScaleSz
, 1);
3379 aY2
:= max(Height
div ScaleSz
, 1);
3380 // Ïðàâûé íèæíèé óãîë:
3381 aX2
:= aX
+ aX2
- 1;
3382 aY2
:= aY
+ aY2
- 1;
3384 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 176, 0, 0, 0);
3387 if gPlayers
<> nil then
3390 for a
:= 0 to High(gPlayers
) do
3391 if gPlayers
[a
] <> nil then with gPlayers
[a
] do
3393 // Ëåâûé âåðõíèé óãîë:
3394 aX
:= Obj
.X
div ScaleSz
+ 1;
3395 aY
:= Obj
.Y
div ScaleSz
+ 1;
3397 aX2
:= max(Obj
.Rect
.Width
div ScaleSz
, 1);
3398 aY2
:= max(Obj
.Rect
.Height
div ScaleSz
, 1);
3399 // Ïðàâûé íèæíèé óãîë:
3400 aX2
:= aX
+ aX2
- 1;
3401 aY2
:= aY
+ aY2
- 1;
3403 if gPlayers
[a
] = p
then
3404 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 255, 0, 0)
3407 TEAM_RED
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 0, 0, 0);
3408 TEAM_BLUE
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 0, 255, 0);
3409 else e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 128, 0, 0);
3414 g_Mons_ForEach(monDraw
);
3419 procedure renderAmbientQuad (hasAmbient
: Boolean; constref ambColor
: TDFColor
);
3421 if not hasAmbient
then exit
;
3422 e_AmbientQuad(sX
, sY
, sWidth
, sHeight
, ambColor
.r
, ambColor
.g
, ambColor
.b
, ambColor
.a
);
3426 // setup sX, sY, sWidth, sHeight, and transformation matrix before calling this!
3427 //FIXME: broken for splitscreen mode
3428 procedure renderDynLightsInternal ();
3430 //hasAmbient: Boolean;
3431 //ambColor: TDFColor;
3433 lx
, ly
, lrad
: Integer;
3434 scxywh
: array[0..3] of GLint
;
3437 if e_NoGraphics
then exit
;
3439 //TODO: lights should be in separate grid, i think
3440 // but on the other side: grid may be slower for dynlights, as their lifetime is short
3441 if (not gwin_k8_enable_light_experiments
) or (not gwin_has_stencil
) or (g_dynLightCount
< 1) then exit
;
3444 //ambColor := gCurrentMap['light_ambient'].rgba;
3445 //hasAmbient := (not ambColor.isOpaque) or (not ambColor.isBlack);
3447 { // this will multiply incoming color to alpha from framebuffer
3449 glBlendFunc(GL_DST_ALPHA, GL_ONE);
3453 * light rendering: (INVALID!)
3454 * glStencilFunc(GL_EQUAL, 0, $ff);
3456 * glClear(GL_STENCIL_BUFFER_BIT);
3457 * glStencilOp(GL_KEEP, GL_KEEP, GL_INCR);
3458 * draw shadow volume into stencil buffer
3459 * glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); // modify color buffer
3460 * glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); // don't modify stencil buffer
3462 * draw color-less quad with light alpha (WARNING! don't touch color!)
3463 * glEnable(GL_BLEND);
3464 * glBlendFunc(GL_DST_ALPHA, GL_ONE);
3465 * draw all geometry up to and including walls (with alpha-testing, probably) -- this does lighting
3467 wassc
:= (glIsEnabled(GL_SCISSOR_TEST
) <> 0);
3468 if wassc
then glGetIntegerv(GL_SCISSOR_BOX
, @scxywh
[0]) else glGetIntegerv(GL_VIEWPORT
, @scxywh
[0]);
3470 // setup OpenGL parameters
3471 glStencilMask($FFFFFFFF);
3472 glStencilFunc(GL_ALWAYS
, 0, $FFFFFFFF);
3473 glEnable(GL_STENCIL_TEST
);
3474 glEnable(GL_SCISSOR_TEST
);
3475 glClear(GL_STENCIL_BUFFER_BIT
);
3476 glStencilFunc(GL_EQUAL
, 0, $ff);
3478 for lln
:= 0 to g_dynLightCount
-1 do
3480 lx
:= g_dynLights
[lln
].x
;
3481 ly
:= g_dynLights
[lln
].y
;
3482 lrad
:= g_dynLights
[lln
].radius
;
3483 if (lrad
< 3) then continue
;
3485 if (lx
-sX
+lrad
< 0) then continue
;
3486 if (ly
-sY
+lrad
< 0) then continue
;
3487 if (lx
-sX
-lrad
>= gPlayerScreenSize
.X
) then continue
;
3488 if (ly
-sY
-lrad
>= gPlayerScreenSize
.Y
) then continue
;
3490 // set scissor to optimize drawing
3491 if (g_dbg_scale
= 1.0) then
3493 glScissor((lx
-sX
)-lrad
+2, gPlayerScreenSize
.Y
-(ly
-sY
)-lrad
-1+2, lrad
*2-4, lrad
*2-4);
3497 glScissor(0, 0, gScreenWidth
, gScreenHeight
);
3499 // no need to clear stencil buffer, light blitting will do it for us... but only for normal scale
3500 if (g_dbg_scale
<> 1.0) then glClear(GL_STENCIL_BUFFER_BIT
);
3501 glStencilOp(GL_KEEP
, GL_KEEP
, GL_INCR
);
3502 // draw extruded panels
3503 glDisable(GL_TEXTURE_2D
);
3504 glDisable(GL_BLEND
);
3505 glColorMask(GL_FALSE
, GL_FALSE
, GL_FALSE
, GL_FALSE
); // no need to modify color buffer
3506 if (lrad
> 4) then g_Map_DrawPanelShadowVolumes(lx
, ly
, lrad
);
3507 // render light texture
3508 glColorMask(GL_TRUE
, GL_TRUE
, GL_TRUE
, GL_TRUE
); // modify color buffer
3509 glStencilOp(GL_ZERO
, GL_ZERO
, GL_ZERO
); // draw light, and clear stencil buffer
3512 glBlendFunc(GL_SRC_ALPHA
, GL_ONE_MINUS_SRC_ALPHA
);
3513 glEnable(GL_TEXTURE_2D
);
3514 // color and opacity
3515 glColor4f(g_dynLights
[lln
].r
, g_dynLights
[lln
].g
, g_dynLights
[lln
].b
, g_dynLights
[lln
].a
);
3516 glBindTexture(GL_TEXTURE_2D
, g_Texture_Light());
3518 glTexCoord2f(0.0, 0.0); glVertex2i(lx
-lrad
, ly
-lrad
); // top-left
3519 glTexCoord2f(1.0, 0.0); glVertex2i(lx
+lrad
, ly
-lrad
); // top-right
3520 glTexCoord2f(1.0, 1.0); glVertex2i(lx
+lrad
, ly
+lrad
); // bottom-right
3521 glTexCoord2f(0.0, 1.0); glVertex2i(lx
-lrad
, ly
+lrad
); // bottom-left
3526 glDisable(GL_STENCIL_TEST
);
3527 glDisable(GL_BLEND
);
3528 glDisable(GL_SCISSOR_TEST
);
3529 //glScissor(0, 0, sWidth, sHeight);
3531 glScissor(scxywh
[0], scxywh
[1], scxywh
[2], scxywh
[3]);
3532 if wassc
then glEnable(GL_SCISSOR_TEST
) else glDisable(GL_SCISSOR_TEST
);
3536 function fixViewportForScale (): Boolean;
3538 nx0
, ny0
, nw
, nh
: Integer;
3541 if (g_dbg_scale
<> 1.0) then
3544 nx0
:= round(sX
-(gPlayerScreenSize
.X
-(sWidth
*g_dbg_scale
))/2/g_dbg_scale
);
3545 ny0
:= round(sY
-(gPlayerScreenSize
.Y
-(sHeight
*g_dbg_scale
))/2/g_dbg_scale
);
3546 nw
:= round(sWidth
/g_dbg_scale
);
3547 nh
:= round(sHeight
/g_dbg_scale
);
3556 // setup sX, sY, sWidth, sHeight, and transformation matrix before calling this!
3557 // WARNING! this WILL CALL `glTranslatef()`, but won't restore matrices!
3558 procedure renderMapInternal (backXOfs
, backYOfs
: Integer; setTransMatrix
: Boolean);
3560 TDrawCB
= procedure ();
3563 hasAmbient
: Boolean;
3565 doAmbient
: Boolean = false;
3567 procedure drawPanelType (profname
: AnsiString; panType
: DWord
; doDraw
: Boolean);
3572 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin(profname
);
3573 if gdbg_map_use_accel_render
then
3575 tagmask
:= panelTypeToTag(panType
);
3576 while (gDrawPanelList
.count
> 0) do
3578 pan
:= TPanel(gDrawPanelList
.front());
3579 if ((pan
.tag
and tagmask
) = 0) then break
;
3580 if doDraw
then pan
.Draw(doAmbient
, ambColor
);
3581 gDrawPanelList
.popFront();
3586 if doDraw
then g_Map_DrawPanels(panType
, hasAmbient
, ambColor
);
3588 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
3591 procedure drawOther (profname
: AnsiString; cb
: TDrawCB
);
3593 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin(profname
);
3594 if assigned(cb
) then cb();
3595 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
3599 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin('total');
3601 // our accelerated renderer will collect all panels to gDrawPanelList
3602 // we can use panel tag to render level parts (see GridTagXXX in g_map.pas)
3603 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin('collect');
3604 if gdbg_map_use_accel_render
then
3606 g_Map_CollectDrawPanels(sX
, sY
, sWidth
, sHeight
);
3608 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
3610 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin('skyback');
3611 g_Map_DrawBack(backXOfs
, backYOfs
);
3612 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
3614 if setTransMatrix
then
3616 //if (g_dbg_scale <> 1.0) then glTranslatef(0.0, -0.375/2, 0);
3617 glScalef(g_dbg_scale
, g_dbg_scale
, 1.0);
3618 glTranslatef(-sX
, -sY
, 0);
3622 ambColor
:= gCurrentMap
['light_ambient'].rgba
;
3623 hasAmbient
:= (not ambColor
.isOpaque
) or (not ambColor
.isBlack
);
3628 //writeln('color: (', ambColor.r, ',', ambColor.g, ',', ambColor.b, ',', ambColor.a, ')');
3629 glColor4ub(ambColor.r, ambColor.g, ambColor.b, ambColor.a);
3630 glClear(GL_COLOR_BUFFER_BIT);
3633 //writeln('color: (', ambColor.r, ',', ambColor.g, ',', ambColor.b, ',', ambColor.a, ')');
3636 drawPanelType('*back', PANEL_BACK
, g_rlayer_back
);
3637 drawPanelType('*step', PANEL_STEP
, g_rlayer_step
);
3638 drawOther('items', @g_Items_Draw
);
3639 drawOther('weapons', @g_Weapon_Draw
);
3640 drawOther('shells', @g_Player_DrawShells
);
3641 drawOther('drawall', @g_Player_DrawAll
);
3642 drawOther('corpses', @g_Player_DrawCorpses
);
3643 drawPanelType('*wall', PANEL_WALL
, g_rlayer_wall
);
3644 drawOther('monsters', @g_Monsters_Draw
);
3645 drawOther('itemdrop', @g_Items_DrawDrop
);
3646 drawPanelType('*door', PANEL_CLOSEDOOR
, g_rlayer_door
);
3647 drawOther('gfx', @g_GFX_Draw
);
3648 drawOther('flags', @g_Map_DrawFlags
);
3649 drawPanelType('*acid1', PANEL_ACID1
, g_rlayer_acid1
);
3650 drawPanelType('*acid2', PANEL_ACID2
, g_rlayer_acid2
);
3651 drawPanelType('*water', PANEL_WATER
, g_rlayer_water
);
3652 drawOther('dynlights', @renderDynLightsInternal
);
3654 if hasAmbient
{and ((not g_playerLight) or (not gwin_has_stencil) or (g_dynLightCount < 1))} then
3656 renderAmbientQuad(hasAmbient
, ambColor
);
3660 drawPanelType('*fore', PANEL_FORE
, g_rlayer_fore
);
3663 if g_debug_HealthBar
then
3665 g_Monsters_DrawHealth();
3666 g_Player_DrawHealth();
3669 if (profileFrameDraw
<> nil) then profileFrameDraw
.mainEnd(); // map rendering
3673 procedure DrawMapView(x
, y
, w
, h
: Integer);
3680 bx
:= Round(x
/(gMapInfo
.Width
- w
)*(gBackSize
.X
- w
));
3681 by
:= Round(y
/(gMapInfo
.Height
- h
)*(gBackSize
.Y
- h
));
3688 fixViewportForScale();
3689 renderMapInternal(-bx
, -by
, true);
3695 procedure DrawPlayer(p
: TPlayer
);
3697 px
, py
, a
, b
, c
, d
, i
, fX
, fY
: Integer;
3701 if (p
= nil) or (p
.FDummy
) then
3704 g_Map_DrawBack(0, 0);
3709 if (profileFrameDraw
= nil) then profileFrameDraw
:= TProfiler
.Create('RENDER', g_profile_history_size
);
3710 if (profileFrameDraw
<> nil) then profileFrameDraw
.mainBegin(g_profile_frame_draw
);
3716 camObj
:= p
.getCameraObj();
3717 camObj
.lerp(gLerpFactor
, fX
, fY
);
3718 px
:= fX
+ PLAYER_RECT_CX
;
3719 py
:= fY
+ PLAYER_RECT_CY
+nlerp(p
.SlopeOld
, camObj
.slopeUpLeft
, gLerpFactor
);
3721 if (g_dbg_scale
= 1.0) and (not g_dbg_ignore_bounds
) then
3723 if (px
> (gPlayerScreenSize
.X
div 2)) then a
:= -px
+(gPlayerScreenSize
.X
div 2) else a
:= 0;
3724 if (py
> (gPlayerScreenSize
.Y
div 2)) then b
:= -py
+(gPlayerScreenSize
.Y
div 2) else b
:= 0;
3726 if (px
> gMapInfo
.Width
-(gPlayerScreenSize
.X
div 2)) then a
:= -gMapInfo
.Width
+gPlayerScreenSize
.X
;
3727 if (py
> gMapInfo
.Height
-(gPlayerScreenSize
.Y
div 2)) then b
:= -gMapInfo
.Height
+gPlayerScreenSize
.Y
;
3729 if (gMapInfo
.Width
= gPlayerScreenSize
.X
) then a
:= 0
3730 else if (gMapInfo
.Width
< gPlayerScreenSize
.X
) then
3733 a
:= (gPlayerScreenSize
.X
-gMapInfo
.Width
) div 2;
3736 if (gMapInfo
.Height
= gPlayerScreenSize
.Y
) then b
:= 0
3737 else if (gMapInfo
.Height
< gPlayerScreenSize
.Y
) then
3740 b
:= (gPlayerScreenSize
.Y
-gMapInfo
.Height
) div 2;
3745 // scaled, ignore level bounds
3746 a
:= -px
+(gPlayerScreenSize
.X
div 2);
3747 b
:= -py
+(gPlayerScreenSize
.Y
div 2);
3752 sWidth
:= gPlayerScreenSize
.X
;
3753 sHeight
:= gPlayerScreenSize
.Y
;
3754 fixViewportForScale();
3756 i
:= py
- (sY
+ sHeight
div 2);
3757 if (p
.IncCam
> 0) then
3759 // clamp to level bounds
3760 if (sY
- p
.IncCam
< 0) then
3761 p
.IncCam
:= nclamp(sY
, 0, 120);
3762 // clamp around player position
3764 p
.IncCam
:= nclamp(p
.IncCam
, 0, max(0, 120 - i
));
3766 else if (p
.IncCam
< 0) then
3768 // clamp to level bounds
3769 if (sY
+ sHeight
- p
.IncCam
> gMapInfo
.Height
) then
3770 p
.IncCam
:= nclamp(sY
+ sHeight
- gMapInfo
.Height
, -120, 0);
3771 // clamp around player position
3773 p
.IncCam
:= nclamp(p
.IncCam
, min(0, -120 - i
), 0);
3776 sY
:= sY
- nlerp(p
.IncCamOld
, p
.IncCam
, gLerpFactor
);
3778 if (not g_dbg_ignore_bounds
) then
3780 if (sX
+sWidth
> gMapInfo
.Width
) then sX
:= gMapInfo
.Width
-sWidth
;
3781 if (sY
+sHeight
> gMapInfo
.Height
) then sY
:= gMapInfo
.Height
-sHeight
;
3782 if (sX
< 0) then sX
:= 0;
3783 if (sY
< 0) then sY
:= 0;
3786 if (gBackSize
.X
<= gPlayerScreenSize
.X
) or (gMapInfo
.Width
<= sWidth
) then c
:= 0 else c
:= trunc((gBackSize
.X
-gPlayerScreenSize
.X
)*sX
/(gMapInfo
.Width
-sWidth
));
3787 if (gBackSize
.Y
<= gPlayerScreenSize
.Y
) or (gMapInfo
.Height
<= sHeight
) then d
:= 0 else d
:= trunc((gBackSize
.Y
-gPlayerScreenSize
.Y
)*sY
/(gMapInfo
.Height
-sHeight
));
3789 //r_smallmap_h: 0: left; 1: center; 2: right
3790 //r_smallmap_v: 0: top; 1: center; 2: bottom
3792 if (gMapInfo
.Width
= sWidth
) then
3796 else if (gMapInfo
.Width
< sWidth
) then
3798 case r_smallmap_h
of
3799 1: sX
:= -((sWidth
-gMapInfo
.Width
) div 2); // center
3800 2: sX
:= -(sWidth
-gMapInfo
.Width
); // right
3801 else sX
:= 0; // left
3805 if (gMapInfo
.Height
= sHeight
) then
3809 else if (gMapInfo
.Height
< sHeight
) then
3811 case r_smallmap_v
of
3812 1: sY
:= -((sHeight
-gMapInfo
.Height
) div 2); // center
3813 2: sY
:= -(sHeight
-gMapInfo
.Height
); // bottom
3814 else sY
:= 0; // top
3820 p
.viewPortW
:= sWidth
;
3821 p
.viewPortH
:= sHeight
;
3823 {$IFDEF ENABLE_HOLMES}
3824 if (p
= gPlayer1
) then
3826 g_Holmes_plrViewPos(sX
, sY
);
3827 g_Holmes_plrViewSize(sWidth
, sHeight
);
3831 renderMapInternal(-c
, -d
, true);
3833 if (gGameSettings
.GameMode
<> GM_SINGLE
) and (gPlayerIndicator
> 0) then
3834 case gPlayerIndicator
of
3836 p
.DrawIndicator(_RGB(255, 255, 255));
3839 for i
:= 0 to High(gPlayers
) do
3840 if gPlayers
[i
] <> nil then
3841 if gPlayers
[i
] = p
then p
.DrawIndicator(_RGB(255, 255, 255))
3842 else if (gPlayers
[i
].Team
= p
.Team
) and (gPlayers
[i
].Team
<> TEAM_NONE
) then
3843 if gPlayerIndicatorStyle
= 1 then
3844 gPlayers
[i
].DrawIndicator(_RGB(192, 192, 192))
3845 else gPlayers
[i
].DrawIndicator(gPlayers
[i
].GetColor
);
3849 for a := 0 to High(gCollideMap) do
3850 for b := 0 to High(gCollideMap[a]) do
3853 if ByteBool(gCollideMap[a, b] and MARK_WALL) then
3855 if ByteBool(gCollideMap[a, b] and MARK_DOOR) then
3859 1: e_DrawPoint(1, b, a, 200, 200, 200);
3860 2: e_DrawPoint(1, b, a, 64, 64, 255);
3861 3: e_DrawPoint(1, b, a, 255, 0, 255);
3871 if gShowMap
then DrawMinimap(p
, _TRect(0, 0, 128, 128));
3872 if g_Debug_Player
then
3873 g_Player_DrawDebug(p
);
3877 procedure drawProfilers ();
3882 if g_profile_frame_draw
and (profileFrameDraw
<> nil) then px
:= px
-drawProfiles(px
, py
, profileFrameDraw
);
3883 if g_profile_collision
and (profMapCollision
<> nil) then begin px
:= px
-drawProfiles(px
, py
, profMapCollision
); py
-= calcProfilesHeight(profMonsLOS
); end;
3884 if g_profile_los
and (profMonsLOS
<> nil) then begin px
:= px
-drawProfiles(px
, py
, profMonsLOS
); py
-= calcProfilesHeight(profMonsLOS
); end;
3887 procedure g_Game_Draw();
3894 plView1
, plView2
: TPlayer
;
3897 if gExit
= EXIT_QUIT
then Exit
;
3899 Time
:= sys_GetTicks() {div 1000};
3900 FPSCounter
:= FPSCounter
+1;
3901 if Time
- FPSTime
>= 1000 then
3908 e_SetRendertarget(True);
3909 e_SetViewPort(0, 0, gScreenWidth
, gScreenHeight
);
3911 if gGameOn
or (gState
= STATE_FOLD
) then
3913 if (gPlayer1
<> nil) and (gPlayer2
<> nil) then
3915 gSpectMode
:= SPECT_NONE
;
3916 if not gRevertPlayers
then
3918 plView1
:= gPlayer1
;
3919 plView2
:= gPlayer2
;
3923 plView1
:= gPlayer2
;
3924 plView2
:= gPlayer1
;
3928 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
3930 gSpectMode
:= SPECT_NONE
;
3931 if gPlayer2
= nil then
3934 plView1
:= gPlayer2
;
3943 if (plView1
= nil) and (plView2
= nil) and (gSpectMode
= SPECT_NONE
) then
3944 gSpectMode
:= SPECT_STATS
;
3946 if gSpectMode
= SPECT_PLAYERS
then
3947 if gPlayers
<> nil then
3949 plView1
:= GetActivePlayer_ByID(gSpectPID1
);
3950 if plView1
= nil then
3952 gSpectPID1
:= GetActivePlayerID_Next();
3953 plView1
:= GetActivePlayer_ByID(gSpectPID1
);
3955 if gSpectViewTwo
then
3957 plView2
:= GetActivePlayer_ByID(gSpectPID2
);
3958 if plView2
= nil then
3960 gSpectPID2
:= GetActivePlayerID_Next();
3961 plView2
:= GetActivePlayer_ByID(gSpectPID2
);
3966 if gSpectMode
= SPECT_MAPVIEW
then
3968 // Ðåæèì ïðîñìîòðà êàðòû
3970 e_SetViewPort(0, 0, gScreenWidth
, gScreenHeight
);
3971 DrawMapView(gSpectX
, gSpectY
, gScreenWidth
, gScreenHeight
);
3972 gHearPoint1
.Active
:= True;
3973 gHearPoint1
.Coords
.X
:= gScreenWidth
div 2 + gSpectX
;
3974 gHearPoint1
.Coords
.Y
:= gScreenHeight
div 2 + gSpectY
;
3975 gHearPoint2
.Active
:= False;
3979 Split
:= (plView1
<> nil) and (plView2
<> nil);
3981 // Òî÷êè ñëóõà èãðîêîâ
3982 if plView1
<> nil then
3984 gHearPoint1
.Active
:= True;
3985 gHearPoint1
.Coords
.X
:= plView1
.GameX
+ PLAYER_RECT
.Width
;
3986 gHearPoint1
.Coords
.Y
:= plView1
.GameY
+ PLAYER_RECT
.Height
DIV 2;
3988 gHearPoint1
.Active
:= False;
3989 if plView2
<> nil then
3991 gHearPoint2
.Active
:= True;
3992 gHearPoint2
.Coords
.X
:= plView2
.GameX
+ PLAYER_RECT
.Width
;
3993 gHearPoint2
.Coords
.Y
:= plView2
.GameY
+ PLAYER_RECT
.Height
DIV 2;
3995 gHearPoint2
.Active
:= False;
3997 // Ðàçìåð ýêðàíîâ èãðîêîâ:
3998 gPlayerScreenSize
.X
:= gScreenWidth
-196;
4001 gPlayerScreenSize
.Y
:= gScreenHeight
div 2;
4002 if gScreenHeight
mod 2 = 0 then
4003 Dec(gPlayerScreenSize
.Y
);
4006 gPlayerScreenSize
.Y
:= gScreenHeight
;
4009 if gScreenHeight
mod 2 = 0 then
4010 e_SetViewPort(0, gPlayerScreenSize
.Y
+2, gPlayerScreenSize
.X
+196, gPlayerScreenSize
.Y
)
4012 e_SetViewPort(0, gPlayerScreenSize
.Y
+1, gPlayerScreenSize
.X
+196, gPlayerScreenSize
.Y
);
4014 DrawPlayer(plView1
);
4015 gPlayer1ScreenCoord
.X
:= sX
;
4016 gPlayer1ScreenCoord
.Y
:= sY
;
4020 e_SetViewPort(0, 0, gPlayerScreenSize
.X
+196, gPlayerScreenSize
.Y
);
4022 DrawPlayer(plView2
);
4023 gPlayer2ScreenCoord
.X
:= sX
;
4024 gPlayer2ScreenCoord
.Y
:= sY
;
4027 e_SetViewPort(0, 0, gScreenWidth
, gScreenHeight
);
4030 e_DrawLine(2, 0, gScreenHeight
div 2, gScreenWidth
, gScreenHeight
div 2, 0, 0, 0);
4033 {$IFDEF ENABLE_HOLMES}
4035 if (g_holmes_enabled
) then g_Holmes_Draw();
4038 if MessageText
<> '' then
4042 e_CharFont_GetSizeFmt(gMenuFont
, MessageText
, w
, h
);
4044 e_CharFont_PrintFmt(gMenuFont
, (gScreenWidth
div 2)-(w
div 2),
4045 (gScreenHeight
div 2)-(h
div 2), MessageText
)
4047 e_CharFont_PrintFmt(gMenuFont
, (gScreenWidth
div 2)-(w
div 2),
4048 Round(gScreenHeight
/ 2.75)-(h
div 2), MessageText
);
4051 if IsDrawStat
or (gSpectMode
= SPECT_STATS
) then
4054 if gSpectHUD
and (not gChatShow
) and (gSpectMode
<> SPECT_NONE
) and (not gSpectAuto
) then
4056 // Draw spectator GUI
4059 e_TextureFontGetSize(gStdFont
, ww
, hh
);
4062 e_TextureFontPrintEx(0, gScreenHeight
- (hh
+2)*2, 'MODE: Stats', gStdFont
, 255, 255, 255, 1);
4064 e_TextureFontPrintEx(0, gScreenHeight
- (hh
+2)*2, 'MODE: Observe Map', gStdFont
, 255, 255, 255, 1);
4066 e_TextureFontPrintEx(0, gScreenHeight
- (hh
+2)*2, 'MODE: Watch Players', gStdFont
, 255, 255, 255, 1);
4068 e_TextureFontPrintEx(2*ww
, gScreenHeight
- (hh
+2), '< jump >', gStdFont
, 255, 255, 255, 1);
4069 if gSpectMode
= SPECT_STATS
then
4071 e_TextureFontPrintEx(16*ww
, gScreenHeight
- (hh
+2)*2, 'Autoview', gStdFont
, 255, 255, 255, 1);
4072 e_TextureFontPrintEx(16*ww
, gScreenHeight
- (hh
+2), '< fire >', gStdFont
, 255, 255, 255, 1);
4074 if gSpectMode
= SPECT_MAPVIEW
then
4076 e_TextureFontPrintEx(22*ww
, gScreenHeight
- (hh
+2)*2, '[-]', gStdFont
, 255, 255, 255, 1);
4077 e_TextureFontPrintEx(26*ww
, gScreenHeight
- (hh
+2)*2, 'Step ' + IntToStr(gSpectStep
), gStdFont
, 255, 255, 255, 1);
4078 e_TextureFontPrintEx(34*ww
, gScreenHeight
- (hh
+2)*2, '[+]', gStdFont
, 255, 255, 255, 1);
4079 e_TextureFontPrintEx(18*ww
, gScreenHeight
- (hh
+2), '<prev weap>', gStdFont
, 255, 255, 255, 1);
4080 e_TextureFontPrintEx(30*ww
, gScreenHeight
- (hh
+2), '<next weap>', gStdFont
, 255, 255, 255, 1);
4082 if gSpectMode
= SPECT_PLAYERS
then
4084 e_TextureFontPrintEx(22*ww
, gScreenHeight
- (hh
+2)*2, 'Player 1', gStdFont
, 255, 255, 255, 1);
4085 e_TextureFontPrintEx(20*ww
, gScreenHeight
- (hh
+2), '<left/right>', gStdFont
, 255, 255, 255, 1);
4086 if gSpectViewTwo
then
4088 e_TextureFontPrintEx(37*ww
, gScreenHeight
- (hh
+2)*2, 'Player 2', gStdFont
, 255, 255, 255, 1);
4089 e_TextureFontPrintEx(34*ww
, gScreenHeight
- (hh
+2), '<prev w/next w>', gStdFont
, 255, 255, 255, 1);
4090 e_TextureFontPrintEx(52*ww
, gScreenHeight
- (hh
+2)*2, '2x View', gStdFont
, 255, 255, 255, 1);
4091 e_TextureFontPrintEx(51*ww
, gScreenHeight
- (hh
+2), '<up/down>', gStdFont
, 255, 255, 255, 1);
4095 e_TextureFontPrintEx(35*ww
, gScreenHeight
- (hh
+2)*2, '2x View', gStdFont
, 255, 255, 255, 1);
4096 e_TextureFontPrintEx(34*ww
, gScreenHeight
- (hh
+2), '<up/down>', gStdFont
, 255, 255, 255, 1);
4102 if gPauseMain
and gGameOn
and (g_ActiveWindow
= nil) then
4104 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4105 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4107 e_CharFont_GetSize(gMenuFont
, _lc
[I_MENU_PAUSE
], w
, h
);
4108 e_CharFont_Print(gMenuFont
, (gScreenWidth
div 2)-(w
div 2),
4109 (gScreenHeight
div 2)-(h
div 2), _lc
[I_MENU_PAUSE
]);
4114 if (gState
= STATE_MENU
) then
4116 if (g_ActiveWindow
= nil) or (g_ActiveWindow
.BackTexture
= '') then DrawMenuBackground('MENU_BACKGROUND');
4117 // F3 at menu will show game loading dialog
4118 if e_KeyPressed(IK_F3
) then g_Menu_Show_LoadMenu(true);
4119 if (g_ActiveWindow
<> nil) then
4121 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4122 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4126 // F3 at titlepic will show game loading dialog
4127 if e_KeyPressed(IK_F3
) then
4129 g_Menu_Show_LoadMenu(true);
4130 if (g_ActiveWindow
<> nil) then e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4135 if gState
= STATE_FOLD
then
4137 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 0, 0, 0, EndingGameCounter
);
4140 if gState
= STATE_INTERCUSTOM
then
4142 if gLastMap
and (gGameSettings
.GameMode
= GM_COOP
) then
4144 back
:= 'TEXTURE_endpic';
4145 if not g_Texture_Get(back
, ID
) then
4146 back
:= _lc
[I_TEXTURE_ENDPIC
];
4151 DrawMenuBackground(back
);
4155 if g_ActiveWindow
<> nil then
4157 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4158 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4162 if gState
= STATE_INTERSINGLE
then
4164 if EndingGameCounter
> 0 then
4166 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 0, 0, 0, EndingGameCounter
);
4172 DrawMenuBackground(back
);
4176 if g_ActiveWindow
<> nil then
4178 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4179 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4184 if gState
= STATE_ENDPIC
then
4187 if g_Texture_Get('TEXTURE_endpic', ID
) then DrawMenuBackground('TEXTURE_endpic')
4188 else DrawMenuBackground(_lc
[I_TEXTURE_ENDPIC
]);
4190 if g_ActiveWindow
<> nil then
4192 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4193 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4197 if gState
= STATE_SLIST
then
4199 // if g_Texture_Get('MENU_BACKGROUND', ID) then
4201 // e_DrawSize(ID, 0, 0, 0, False, False, gScreenWidth, gScreenHeight);
4202 // //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4204 DrawMenuBackground('MENU_BACKGROUND');
4205 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4206 g_Serverlist_Draw(slCurrent
, slTable
);
4210 if g_ActiveWindow
<> nil then
4214 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4215 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4217 g_ActiveWindow
.Draw();
4224 if g_debug_Sounds
and gGameOn
then
4226 for w
:= 0 to High(e_SoundsArray
) do
4227 for h
:= 0 to e_SoundsArray
[w
].nRefs
do
4228 e_DrawPoint(1, w
+100, h
+100, 255, 0, 0);
4233 e_TextureFontPrint(0, 0, Format('FPS: %d', [FPS
]), gStdFont
);
4234 e_TextureFontPrint(0, 16, Format('UPS: %d', [UPS
]), gStdFont
);
4237 if gGameOn
and gShowTime
then
4238 drawTime(gScreenWidth
-72, gScreenHeight
-16);
4240 if gGameOn
then drawProfilers();
4242 // TODO: draw this after the FBO and remap mouse click coordinates
4244 {$IFDEF ENABLE_HOLMES}
4248 // blit framebuffer to screen
4250 e_SetRendertarget(False);
4251 e_SetViewPort(0, 0, gWinSizeX
, gWinSizeY
);
4252 e_BlitFramebuffer(gWinSizeX
, gWinSizeY
);
4254 // draw the overlay stuff on top of it
4259 procedure g_Game_Quit();
4261 g_Game_StopAllSounds(True);
4264 g_PlayerModel_FreeData();
4265 g_Texture_DeleteAll();
4266 g_Frames_DeleteAll();
4268 //g_Menu_Free(); //k8: this segfaults after resolution change; who cares?
4271 if NetInitDone
then g_Net_Free
;
4273 // Íàäî óäàëèòü êàðòó ïîñëå òåñòà:
4274 if gMapToDelete
<> '' then
4275 g_Game_DeleteTestMap();
4281 procedure g_FatalError(Text: String);
4283 g_Console_Add(Format(_lc
[I_FATAL_ERROR
], [Text]), True);
4284 e_WriteLog(Format(_lc
[I_FATAL_ERROR
], [Text]), TMsgType
.Warning
);
4286 gExit
:= EXIT_SIMPLE
;
4287 if gGameOn
then EndGame
;
4290 procedure g_SimpleError(Text: String);
4292 g_Console_Add(Format(_lc
[I_SIMPLE_ERROR
], [Text]), True);
4293 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], [Text]), TMsgType
.Warning
);
4296 procedure g_Game_SetupScreenSize();
4298 RES_FACTOR
= 4.0 / 3.0;
4304 // Ðàçìåð ýêðàíîâ èãðîêîâ:
4305 gPlayerScreenSize
.X
:= gScreenWidth
-196;
4306 if (gPlayer1
<> nil) and (gPlayer2
<> nil) then
4307 gPlayerScreenSize
.Y
:= gScreenHeight
div 2
4309 gPlayerScreenSize
.Y
:= gScreenHeight
;
4311 // Ðàçìåð çàäíåãî ïëàíà:
4312 if BackID
<> DWORD(-1) then
4315 if (gScreenWidth
*s
> gMapInfo
.Width
) or
4316 (gScreenHeight
*s
> gMapInfo
.Height
) then
4318 gBackSize
.X
:= gScreenWidth
;
4319 gBackSize
.Y
:= gScreenHeight
;
4323 e_GetTextureSize(BackID
, @bw
, @bh
);
4324 rf
:= Single(bw
) / Single(bh
);
4325 if (rf
> RES_FACTOR
) then bw
:= Round(Single(bh
) * RES_FACTOR
)
4326 else if (rf
< RES_FACTOR
) then bh
:= Round(Single(bw
) / RES_FACTOR
);
4327 s
:= Max(gScreenWidth
/ bw
, gScreenHeight
/ bh
);
4328 if (s
< 1.0) then s
:= 1.0;
4329 gBackSize
.X
:= Round(bw
*s
);
4330 gBackSize
.Y
:= Round(bh
*s
);
4335 procedure g_Game_ChangeResolution(newWidth
, newHeight
: Word; nowFull
, nowMax
: Boolean);
4337 sys_SetDisplayMode(newWidth
, newHeight
, gBPP
, nowFull
, nowMax
);
4340 procedure g_Game_AddPlayer(Team
: Byte = TEAM_NONE
);
4342 if ((not gGameOn
) and (gState
<> STATE_INTERCUSTOM
))
4343 or (not (gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
])) then
4346 if (gGameSettings
.MaxLives
> 0) and (gLMSRespawn
= LMS_RESPAWN_NONE
) then
4349 if gPlayer1
= nil then
4351 if g_Game_IsClient
then
4353 if NetPlrUID1
> -1 then
4354 MC_SEND_CheatRequest(NET_CHEAT_SPECTATE
);
4358 if not (Team
in [TEAM_RED
, TEAM_BLUE
]) then
4359 Team
:= gPlayer1Settings
.Team
;
4361 // Ñîçäàíèå ïåðâîãî èãðîêà:
4362 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4363 gPlayer1Settings
.Color
,
4365 if gPlayer1
= nil then
4366 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]))
4369 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4370 gPlayer1
.WeapSwitchMode
:= gPlayer1Settings
.WeaponSwitch
;
4371 gPlayer1
.setWeaponPrefs(gPlayer1Settings
.WeaponPreferences
);
4372 gPlayer1
.SwitchToEmpty
:= gPlayer1Settings
.SwitchToEmpty
;
4373 gPlayer1
.SkipFist
:= gPlayer1Settings
.SkipFist
;
4374 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [gPlayer1
.Name
]), True);
4375 if g_Game_IsServer
and g_Game_IsNet
then
4376 MH_SEND_PlayerCreate(gPlayer1
.UID
);
4377 gPlayer1
.Respawn(False, True);
4378 g_Net_Slist_ServerPlayerComes();
4383 if gPlayer2
= nil then
4385 if g_Game_IsClient
then
4387 if NetPlrUID2
> -1 then
4388 gPlayer2
:= g_Player_Get(NetPlrUID2
);
4392 if not (Team
in [TEAM_RED
, TEAM_BLUE
]) then
4393 Team
:= gPlayer2Settings
.Team
;
4395 // Ñîçäàíèå âòîðîãî èãðîêà:
4396 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
4397 gPlayer2Settings
.Color
,
4399 if gPlayer2
= nil then
4400 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]))
4403 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
4404 gPlayer2
.WeapSwitchMode
:= gPlayer2Settings
.WeaponSwitch
;
4405 gPlayer2
.setWeaponPrefs(gPlayer2Settings
.WeaponPreferences
);
4406 gPlayer2
.SwitchToEmpty
:= gPlayer2Settings
.SwitchToEmpty
;
4407 gPlayer2
.SkipFist
:= gPlayer2Settings
.SkipFist
;
4408 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [gPlayer2
.Name
]), True);
4409 if g_Game_IsServer
and g_Game_IsNet
then
4410 MH_SEND_PlayerCreate(gPlayer2
.UID
);
4411 gPlayer2
.Respawn(False, True);
4412 g_Net_Slist_ServerPlayerComes();
4419 procedure g_Game_RemovePlayer();
4423 if ((not gGameOn
) and (gState
<> STATE_INTERCUSTOM
))
4424 or (not (gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
])) then
4429 if g_Game_IsServer
then
4432 Pl
.Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
4433 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [Pl
.Name
]), True);
4434 g_Player_Remove(Pl
.UID
);
4435 g_Net_Slist_ServerPlayerLeaves();
4439 gSpectLatchPID2
:= Pl
.UID
;
4447 if g_Game_IsServer
then
4450 Pl
.Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
4451 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [Pl
.Name
]), True);
4452 g_Player_Remove(Pl
.UID
);
4453 g_Net_Slist_ServerPlayerLeaves();
4456 gSpectLatchPID1
:= Pl
.UID
;
4458 MC_SEND_CheatRequest(NET_CHEAT_SPECTATE
);
4462 g_Net_Slist_ServerPlayerLeaves();
4465 procedure g_Game_Spectate();
4467 g_Game_RemovePlayer();
4468 if gPlayer1
<> nil then
4469 g_Game_RemovePlayer();
4472 procedure g_Game_SpectateCenterView();
4474 gSpectX
:= Max(gMapInfo
.Width
div 2 - gScreenWidth
div 2, 0);
4475 gSpectY
:= Max(gMapInfo
.Height
div 2 - gScreenHeight
div 2, 0);
4478 procedure g_Game_StartSingle(Map
: String; TwoPlayers
: Boolean; nPlayers
: Byte);
4485 e_WriteLog('Starting singleplayer game...', TMsgType
.Notify
);
4487 g_Game_ClearLoading();
4490 FillByte(gGameSettings
, SizeOf(TGameSettings
), 0);
4493 gGameSettings
.GameType
:= GT_SINGLE
;
4494 gGameSettings
.MaxLives
:= 0;
4495 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_ALLOWEXIT
;
4496 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_MONSTERS
;
4497 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_BOTVSMONSTER
;
4498 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_TEAMHITPROJECTILE
;
4499 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_TEAMHITTRACE
;
4500 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_RULEZRANDOM
;
4501 gSwitchGameMode
:= GM_SINGLE
;
4503 gLMSRespawn
:= LMS_RESPAWN_NONE
;
4504 gLMSRespawnTime
:= 0;
4505 gSpectLatchPID1
:= 0;
4506 gSpectLatchPID2
:= 0;
4508 g_Game_ExecuteEvent('ongamestart');
4510 // Óñòàíîâêà ðàçìåðîâ îêîí èãðîêîâ:
4511 g_Game_SetupScreenSize();
4513 // Ñîçäàíèå ïåðâîãî èãðîêà:
4514 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4515 gPlayer1Settings
.Color
,
4516 gPlayer1Settings
.Team
, False));
4517 if gPlayer1
= nil then
4519 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
4523 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4524 gPlayer1
.WeapSwitchMode
:= gPlayer1Settings
.WeaponSwitch
;
4525 gPlayer1
.setWeaponPrefs(gPlayer1Settings
.WeaponPreferences
);
4526 gPlayer1
.SwitchToEmpty
:= gPlayer1Settings
.SwitchToEmpty
;
4527 gPlayer1
.SkipFist
:= gPlayer1Settings
.SkipFist
;
4530 // Ñîçäàíèå âòîðîãî èãðîêà, åñëè åñòü:
4533 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
4534 gPlayer2Settings
.Color
,
4535 gPlayer2Settings
.Team
, False));
4536 if gPlayer2
= nil then
4538 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
4542 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
4543 gPlayer2
.WeapSwitchMode
:= gPlayer2Settings
.WeaponSwitch
;
4544 gPlayer2
.setWeaponPrefs(gPlayer2Settings
.WeaponPreferences
);
4545 gPlayer2
.SwitchToEmpty
:= gPlayer2Settings
.SwitchToEmpty
;
4546 gPlayer2
.SkipFist
:= gPlayer2Settings
.SkipFist
;
4550 // Çàãðóçêà è çàïóñê êàðòû:
4551 if not g_Game_StartMap(false{asMegawad}, MAP
, True) then
4553 if (Pos(':\', Map
) > 0) or (Pos(':/', Map
) > 0) then tmps
:= Map
else tmps
:= gGameSettings
.WAD
+ ':\' + MAP
;
4554 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [tmps
]));
4558 // Íàñòðîéêè èãðîêîâ è áîòîâ:
4562 for i
:= nPl
+1 to nPlayers
do
4563 g_Player_Create(STD_PLAYER_MODEL
, _RGB(0, 0, 0), 0, True);
4566 procedure g_Game_StartCustom(Map
: String; GameMode
: Byte;
4567 TimeLimit
, ScoreLimit
: Word;
4569 Options
: LongWord; nPlayers
: Byte);
4575 e_WriteLog('Starting custom game...', TMsgType
.Notify
);
4577 g_Game_ClearLoading();
4580 gGameSettings
.GameType
:= GT_CUSTOM
;
4581 gGameSettings
.GameMode
:= GameMode
;
4582 gSwitchGameMode
:= GameMode
;
4583 gGameSettings
.TimeLimit
:= TimeLimit
;
4584 gGameSettings
.ScoreLimit
:= ScoreLimit
;
4585 gGameSettings
.MaxLives
:= IfThen(GameMode
= GM_CTF
, 0, MaxLives
);
4586 gGameSettings
.Options
:= Options
;
4588 gCoopTotalMonstersKilled
:= 0;
4589 gCoopTotalSecretsFound
:= 0;
4590 gCoopTotalMonsters
:= 0;
4591 gCoopTotalSecrets
:= 0;
4595 gLMSRespawn
:= LMS_RESPAWN_NONE
;
4596 gLMSRespawnTime
:= 0;
4597 gSpectLatchPID1
:= 0;
4598 gSpectLatchPID2
:= 0;
4600 g_Game_ExecuteEvent('ongamestart');
4602 // Óñòàíîâêà ðàçìåðîâ îêîí èãðîêîâ:
4603 g_Game_SetupScreenSize();
4605 // Ðåæèì íàáëþäàòåëÿ:
4606 if nPlayers
= 0 then
4613 if nPlayers
>= 1 then
4615 // Ñîçäàíèå ïåðâîãî èãðîêà:
4616 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4617 gPlayer1Settings
.Color
,
4618 gPlayer1Settings
.Team
, False));
4619 if gPlayer1
= nil then
4621 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
4625 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4626 gPlayer1
.WeapSwitchMode
:= gPlayer1Settings
.WeaponSwitch
;
4627 gPlayer1
.setWeaponPrefs(gPlayer1Settings
.WeaponPreferences
);
4628 gPlayer1
.SwitchToEmpty
:= gPlayer1Settings
.SwitchToEmpty
;
4629 gPlayer1
.SkipFist
:= gPlayer1Settings
.SkipFist
;
4633 if nPlayers
>= 2 then
4635 // Ñîçäàíèå âòîðîãî èãðîêà:
4636 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
4637 gPlayer2Settings
.Color
,
4638 gPlayer2Settings
.Team
, False));
4639 if gPlayer2
= nil then
4641 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
4645 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
4646 gPlayer2
.WeapSwitchMode
:= gPlayer2Settings
.WeaponSwitch
;
4647 gPlayer2
.setWeaponPrefs(gPlayer2Settings
.WeaponPreferences
);
4648 gPlayer2
.SwitchToEmpty
:= gPlayer2Settings
.SwitchToEmpty
;
4649 gPlayer2
.SkipFist
:= gPlayer2Settings
.SkipFist
;
4653 // Çàãðóçêà è çàïóñê êàðòû:
4654 if not g_Game_StartMap(true{asMegawad}, Map
, True) then
4656 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [Map
]));
4660 // Íåò òî÷åê ïîÿâëåíèÿ:
4661 if (g_Map_GetPointCount(RESPAWNPOINT_PLAYER1
) +
4662 g_Map_GetPointCount(RESPAWNPOINT_PLAYER2
) +
4663 g_Map_GetPointCount(RESPAWNPOINT_DM
) +
4664 g_Map_GetPointCount(RESPAWNPOINT_RED
)+
4665 g_Map_GetPointCount(RESPAWNPOINT_BLUE
)) < 1 then
4667 g_FatalError(_lc
[I_GAME_ERROR_GET_SPAWN
]);
4671 // Íàñòðîéêè èãðîêîâ è áîòîâ:
4675 for i
:= nPl
+1 to nPlayers
do
4676 g_Player_Create(STD_PLAYER_MODEL
, _RGB(0, 0, 0), 0, True);
4679 procedure g_Game_StartServer(Map
: String; GameMode
: Byte;
4680 TimeLimit
, ScoreLimit
: Word; MaxLives
: Byte;
4681 Options
: LongWord; nPlayers
: Byte;
4682 IPAddr
: LongWord; Port
: Word);
4685 g_Net_Slist_ServerClosed();
4687 e_WriteLog('Starting net game (server)...', TMsgType
.Notify
);
4689 g_Game_ClearLoading();
4694 gGameSettings
.GameType
:= GT_SERVER
;
4695 gGameSettings
.GameMode
:= GameMode
;
4696 gSwitchGameMode
:= GameMode
;
4697 gGameSettings
.TimeLimit
:= TimeLimit
;
4698 gGameSettings
.ScoreLimit
:= ScoreLimit
;
4699 gGameSettings
.MaxLives
:= IfThen(GameMode
= GM_CTF
, 0, MaxLives
);
4700 gGameSettings
.Options
:= Options
;
4702 gCoopTotalMonstersKilled
:= 0;
4703 gCoopTotalSecretsFound
:= 0;
4704 gCoopTotalMonsters
:= 0;
4705 gCoopTotalSecrets
:= 0;
4709 gLMSRespawn
:= LMS_RESPAWN_NONE
;
4710 gLMSRespawnTime
:= 0;
4711 gSpectLatchPID1
:= 0;
4712 gSpectLatchPID2
:= 0;
4714 g_Game_ExecuteEvent('ongamestart');
4716 // Óñòàíîâêà ðàçìåðîâ îêíà èãðîêà
4717 g_Game_SetupScreenSize();
4719 // Ðåæèì íàáëþäàòåëÿ:
4720 if nPlayers
= 0 then
4726 if nPlayers
>= 1 then
4728 // Ñîçäàíèå ïåðâîãî èãðîêà:
4729 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4730 gPlayer1Settings
.Color
,
4731 gPlayer1Settings
.Team
, False));
4732 if gPlayer1
= nil then
4734 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
4738 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4739 gPlayer1
.WeapSwitchMode
:= gPlayer1Settings
.WeaponSwitch
;
4740 gPlayer1
.setWeaponPrefs(gPlayer1Settings
.WeaponPreferences
);
4741 gPlayer1
.SwitchToEmpty
:= gPlayer1Settings
.SwitchToEmpty
;
4742 gPlayer1
.SkipFist
:= gPlayer1Settings
.SkipFist
;
4745 if nPlayers
>= 2 then
4747 // Ñîçäàíèå âòîðîãî èãðîêà:
4748 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
4749 gPlayer2Settings
.Color
,
4750 gPlayer2Settings
.Team
, False));
4751 if gPlayer2
= nil then
4753 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
4757 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
4758 gPlayer2
.WeapSwitchMode
:= gPlayer2Settings
.WeaponSwitch
;
4759 gPlayer2
.setWeaponPrefs(gPlayer2Settings
.WeaponPreferences
);
4760 gPlayer2
.SwitchToEmpty
:= gPlayer2Settings
.SwitchToEmpty
;
4761 gPlayer2
.SkipFist
:= gPlayer2Settings
.SkipFist
;
4764 g_Game_SetLoadingText(_lc
[I_LOAD_HOST
], 0, False);
4765 if NetForwardPorts
then
4766 g_Game_SetLoadingText(_lc
[I_LOAD_PORTS
], 0, False);
4769 if not g_Net_Host(IPAddr
, Port
, NetMaxClients
) then
4771 g_FatalError(_lc
[I_NET_MSG
] + Format(_lc
[I_NET_ERR_HOST
], [Port
]));
4775 g_Net_Slist_Set(NetMasterList
);
4777 g_Net_Slist_ServerStarted();
4779 // Çàãðóçêà è çàïóñê êàðòû:
4780 if not g_Game_StartMap(false{asMegawad}, Map
, True) then
4782 g_Net_Slist_ServerClosed();
4783 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [Map
]));
4787 // Íåò òî÷åê ïîÿâëåíèÿ:
4788 if (g_Map_GetPointCount(RESPAWNPOINT_PLAYER1
) +
4789 g_Map_GetPointCount(RESPAWNPOINT_PLAYER2
) +
4790 g_Map_GetPointCount(RESPAWNPOINT_DM
) +
4791 g_Map_GetPointCount(RESPAWNPOINT_RED
)+
4792 g_Map_GetPointCount(RESPAWNPOINT_BLUE
)) < 1 then
4794 g_Net_Slist_ServerClosed();
4795 g_FatalError(_lc
[I_GAME_ERROR_GET_SPAWN
]);
4799 // Íàñòðîéêè èãðîêîâ è áîòîâ:
4802 g_Net_Slist_ServerMapStarted();
4803 NetState
:= NET_STATE_GAME
;
4806 procedure g_Game_StartClient(Addr
: String; Port
: Word; PW
: String);
4821 e_WriteLog('Starting net game (client)...', TMsgType
.Notify
);
4822 e_WriteLog('NET: Trying to connect to ' + Addr
+ ':' + IntToStr(Port
) + '...', TMsgType
.Notify
);
4824 g_Game_ClearLoading();
4829 gGameSettings
.GameType
:= GT_CLIENT
;
4831 gCoopTotalMonstersKilled
:= 0;
4832 gCoopTotalSecretsFound
:= 0;
4833 gCoopTotalMonsters
:= 0;
4834 gCoopTotalSecrets
:= 0;
4838 g_Game_ExecuteEvent('ongamestart');
4840 // Óñòàíîâêà ðàçìåðîâ îêîí èãðîêîâ:
4841 g_Game_SetupScreenSize();
4843 NetState
:= NET_STATE_AUTH
;
4845 g_Game_SetLoadingText(_lc
[I_LOAD_CONNECT
], 0, False);
4847 // create (or update) map/resource databases
4848 g_Res_CreateDatabases(true);
4850 gLMSRespawn
:= LMS_RESPAWN_NONE
;
4851 gLMSRespawnTime
:= 0;
4852 gSpectLatchPID1
:= 0;
4853 gSpectLatchPID2
:= 0;
4856 if not g_Net_Connect(Addr
, Port
) then
4858 g_FatalError(_lc
[I_NET_MSG
] + _lc
[I_NET_ERR_CONN
]);
4859 NetState
:= NET_STATE_NONE
;
4863 g_Game_SetLoadingText(_lc
[I_LOAD_SEND_INFO
], 0, False);
4865 g_Game_SetLoadingText(_lc
[I_LOAD_WAIT_INFO
], 0, False);
4870 // fuck! https://www.mail-archive.com/enet-discuss@cubik.org/msg00852.html
4871 // tl;dr: on shitdows, we can get -1 sometimes, and it is *NOT* a failure.
4872 // thank you, enet. let's ignore failures altogether then.
4873 while (enet_host_service(NetHost
, @NetEvent
, 50) > 0) do
4875 if (NetEvent
.kind
= ENET_EVENT_TYPE_RECEIVE
) then
4877 Ptr
:= NetEvent
.packet
^.data
;
4878 if not InMsg
.Init(Ptr
, NetEvent
.packet
^.dataLength
, True) then
4880 enet_packet_destroy(NetEvent
.packet
);
4884 InMsg
.ReadLongWord(); // skip size
4885 MID
:= InMsg
.ReadByte();
4887 if (MID
= NET_MSG_INFO
) and (State
= 0) then
4889 NetMyID
:= InMsg
.ReadByte();
4890 NetPlrUID1
:= InMsg
.ReadWord();
4892 WadName
:= InMsg
.ReadString();
4893 Map
:= InMsg
.ReadString();
4895 gWADHash
:= InMsg
.ReadMD5();
4897 gGameSettings
.GameMode
:= InMsg
.ReadByte();
4898 gSwitchGameMode
:= gGameSettings
.GameMode
;
4899 gGameSettings
.ScoreLimit
:= InMsg
.ReadWord();
4900 gGameSettings
.TimeLimit
:= InMsg
.ReadWord();
4901 gGameSettings
.MaxLives
:= InMsg
.ReadByte();
4902 gGameSettings
.Options
:= InMsg
.ReadLongWord();
4903 T
:= InMsg
.ReadLongWord();
4905 //newResPath := g_Res_SearchSameWAD(MapsDir, WadName, gWADHash);
4906 //if newResPath = '' then
4908 //g_Game_SetLoadingText(_lc[I_LOAD_DL_RES], 0, False);
4909 newResPath
:= g_Res_DownloadMapWAD(ExtractFileName(WadName
), gWADHash
);
4910 if newResPath
= '' then
4912 g_FatalError(_lc
[I_NET_ERR_HASH
]);
4913 enet_packet_destroy(NetEvent
.packet
);
4914 NetState
:= NET_STATE_NONE
;
4917 e_LogWritefln('using downloaded map wad [%s] for [%s]`', [newResPath
, WadName
], TMsgType
.Notify
);
4919 //newResPath := ExtractRelativePath(MapsDir, newResPath);
4922 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4923 gPlayer1Settings
.Color
,
4924 gPlayer1Settings
.Team
, False));
4926 if gPlayer1
= nil then
4928 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
4930 enet_packet_destroy(NetEvent
.packet
);
4931 NetState
:= NET_STATE_NONE
;
4935 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4936 gPlayer1
.WeapSwitchMode
:= gPlayer1Settings
.WeaponSwitch
;
4937 gPlayer1
.setWeaponPrefs(gPlayer1Settings
.WeaponPreferences
);
4938 gPlayer1
.SwitchToEmpty
:= gPlayer1Settings
.SwitchToEmpty
;
4939 gPlayer1
.SkipFist
:= gPlayer1Settings
.SkipFist
;
4940 gPlayer1
.UID
:= NetPlrUID1
;
4941 gPlayer1
.Reset(True);
4943 if not g_Game_StartMap(false{asMegawad}, newResPath
+ ':\' + Map
, True) then
4945 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [WadName
+ ':\' + Map
]));
4947 enet_packet_destroy(NetEvent
.packet
);
4948 NetState
:= NET_STATE_NONE
;
4956 enet_packet_destroy(NetEvent
.packet
);
4960 enet_packet_destroy(NetEvent
.packet
);
4964 if (NetEvent
.kind
= ENET_EVENT_TYPE_DISCONNECT
) then
4967 if (NetEvent
.data
<= NET_DISC_MAX
) then
4968 g_Console_Add(_lc
[I_NET_MSG_ERROR
] + _lc
[I_NET_ERR_CONN
] + ' ' +
4969 _lc
[TStrings_Locale(Cardinal(I_NET_DISC_NONE
) + NetEvent
.data
)], True);
4976 ProcessLoading(True);
4977 if g_Net_UserRequestExit() then
4986 g_FatalError(_lc
[I_NET_MSG
] + _lc
[I_NET_ERR_CONN
]);
4987 NetState
:= NET_STATE_NONE
;
4992 NetState
:= NET_STATE_GAME
;
4993 MC_SEND_FullStateRequest
;
4994 e_WriteLog('NET: Connection successful.', TMsgType
.Notify
);
4998 lastAsMegaWad
: Boolean = false;
5000 procedure g_Game_ChangeMap(const MapPath
: String);
5004 g_Game_ClearLoading();
5006 Force
:= gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
];
5007 // Åñëè óðîâåíü çàâåðøèëñÿ ïî òðèããåðó Âûõîä, íå î÷èùàòü èíâåíòàðü
5008 if gExitByTrigger
then
5011 gExitByTrigger
:= False;
5013 if not g_Game_StartMap(lastAsMegaWad
, MapPath
, Force
) then
5014 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [MapPath
]));
5017 procedure g_Game_Restart();
5021 if g_Game_IsClient
then
5023 map
:= g_ExtractFileName(gMapInfo
.Map
);
5024 e_LogWritefln('g_Game_Restart: map = "%s" gCurrentMapFileName = "%s"', [map
, gCurrentMapFileName
]);
5028 g_Game_ClearLoading();
5029 g_Game_StartMap(lastAsMegaWad
, Map
, True, gCurrentMapFileName
);
5032 function g_Game_StartMap (asMegawad
: Boolean; Map
: String; Force
: Boolean = False; const oldMapPath
: AnsiString=''): Boolean;
5034 NewWAD
, ResName
: String;
5038 g_Map_Free((Map
<> gCurrentMapFileName
) and (oldMapPath
<> gCurrentMapFileName
));
5039 g_Player_RemoveAllCorpses();
5041 if (not g_Game_IsClient
) and
5042 (gSwitchGameMode
<> gGameSettings
.GameMode
) and
5043 (gGameSettings
.GameMode
<> GM_SINGLE
) then
5045 if gSwitchGameMode
= GM_CTF
then
5046 gGameSettings
.MaxLives
:= 0;
5047 gGameSettings
.GameMode
:= gSwitchGameMode
;
5050 gSwitchGameMode
:= gGameSettings
.GameMode
;
5052 g_Player_ResetTeams();
5054 lastAsMegaWad
:= asMegawad
;
5055 if isWadPath(Map
) then
5057 NewWAD
:= g_ExtractWadName(Map
);
5058 ResName
:= g_ExtractFileName(Map
);
5059 if g_Game_IsServer
then
5061 nws
:= findDiskWad(NewWAD
);
5062 //writeln('000: Map=[', Map, ']; nws=[', nws, ']; NewWAD=[', NewWAD, ']');
5065 if (length(nws
) = 0) then nws
:= e_FindWad(MegawadDirs
, NewWAD
);
5066 if (length(nws
) = 0) then nws
:= e_FindWad(MapDirs
, NewWAD
);
5070 if (length(nws
) = 0) then nws
:= e_FindWad(MapDirs
, NewWAD
);
5071 if (length(nws
) = 0) then nws
:= e_FindWad(MegawadDirs
, NewWAD
);
5073 //if (length(nws) = 0) then nws := e_FindWad(MapDownloadDirs, NewWAD);
5074 //writeln('001: Map=[', Map, ']; nws=[', nws, ']; NewWAD=[', NewWAD, ']');
5076 if (length(nws
) = 0) then
5078 ResName
:= ''; // failed
5083 if (g_Game_IsNet
) then gWADHash
:= MD5File(nws
);
5084 //writeln('********: nws=', nws, ' : Map=', Map, ' : nw=', NewWAD, ' : resname=', ResName);
5085 g_Game_LoadWAD(NewWAD
);
5090 // hash received in MC_RECV_GameEvent -> NET_EV_MAPSTART
5091 NewWAD
:= g_Game_ClientWAD(NewWAD
, gWADHash
);
5096 NewWAD
:= gGameSettings
.WAD
;
5102 //writeln('********: gsw=', gGameSettings.WAD, '; rn=', ResName);
5104 if (ResName
<> '') and (NewWAD
<> '') then
5106 //result := g_Map_Load(gGameSettings.WAD + ':\' + ResName);
5107 result
:= g_Map_Load(NewWAD
+':\'+ResName
);
5111 g_Player_ResetAll(Force
or gLastMap
, gGameSettings
.GameType
= GT_SINGLE
);
5113 gState
:= STATE_NONE
;
5114 g_ActiveWindow
:= nil;
5120 if gGameSettings
.GameMode
= GM_CTF
then
5122 g_Map_ResetFlag(FLAG_RED
);
5123 g_Map_ResetFlag(FLAG_BLUE
);
5124 // CTF, à ôëàãîâ íåò:
5125 if not g_Map_HaveFlagPoints() then
5126 g_SimpleError(_lc
[I_GAME_ERROR_CTF
]);
5131 gState
:= STATE_MENU
;
5136 gPauseMain
:= false;
5137 gPauseHolmes
:= false;
5138 NetTimeToUpdate
:= 1;
5139 NetTimeToReliable
:= 0;
5140 NetTimeToMaster
:= NetMasterRate
;
5141 gSpectLatchPID1
:= 0;
5142 gSpectLatchPID2
:= 0;
5143 gMissionFailed
:= False;
5146 gCoopMonstersKilled
:= 0;
5147 gCoopSecretsFound
:= 0;
5149 gVoteInProgress
:= False;
5150 gVotePassed
:= False;
5156 if not gGameOn
then Exit
;
5158 g_Game_SpectateCenterView();
5160 if g_Game_IsServer
then
5162 if (gGameSettings
.MaxLives
> 0) and (gGameSettings
.WarmupTime
> 0) then
5164 gLMSRespawn
:= LMS_RESPAWN_WARMUP
;
5165 gLMSRespawnTime
:= gTime
+ gGameSettings
.WarmupTime
*1000;
5166 gLMSSoftSpawn
:= True;
5167 if g_Game_IsNet
then
5168 MH_SEND_GameEvent(NET_EV_LMS_WARMUP
, gLMSRespawnTime
- gTime
);
5172 gLMSRespawn
:= LMS_RESPAWN_NONE
;
5173 gLMSRespawnTime
:= 0;
5177 if NetMode
= NET_SERVER
then
5179 // reset full state flags
5180 if NetClients
<> nil then
5181 for I
:= 0 to High(NetClients
) do
5182 NetClients
[I
].FullUpdateSent
:= False;
5184 MH_SEND_GameEvent(NET_EV_MAPSTART
, gGameSettings
.GameMode
, Map
);
5187 g_Net_Slist_ServerMapStarted();
5189 if NetClients
<> nil then
5190 for I
:= 0 to High(NetClients
) do
5191 if NetClients
[I
].Used
then
5193 NetClients
[I
].Voted
:= False;
5194 if NetClients
[I
].RequestedFullUpdate
then
5196 MH_SEND_Everything((NetClients
[I
].State
= NET_STATE_AUTH
), I
);
5197 NetClients
[I
].RequestedFullUpdate
:= False;
5201 g_Net_UnbanNonPerm();
5206 gCoopTotalMonstersKilled
:= 0;
5207 gCoopTotalSecretsFound
:= 0;
5208 gCoopTotalMonsters
:= 0;
5209 gCoopTotalSecrets
:= 0;
5213 g_Game_ExecuteEvent('onmapstart');
5216 procedure SetFirstLevel
;
5220 MapList
:= g_Map_GetMapsList(gGameSettings
.WAD
);
5221 if MapList
= nil then
5224 SortSArray(MapList
);
5225 gNextMap
:= MapList
[Low(MapList
)];
5230 procedure g_Game_ExitLevel(const Map
: AnsiString);
5234 gCoopTotalMonstersKilled
:= gCoopTotalMonstersKilled
+ gCoopMonstersKilled
;
5235 gCoopTotalSecretsFound
:= gCoopTotalSecretsFound
+ gCoopSecretsFound
;
5236 gCoopTotalMonsters
:= gCoopTotalMonsters
+ gTotalMonsters
;
5237 gCoopTotalSecrets
:= gCoopTotalSecrets
+ gSecretsCount
;
5239 // Âûøëè â âûõîä â Îäèíî÷íîé èãðå:
5240 if gGameSettings
.GameType
= GT_SINGLE
then
5241 gExit
:= EXIT_ENDLEVELSINGLE
5242 else // Âûøëè â âûõîä â Ñâîåé èãðå
5244 gExit
:= EXIT_ENDLEVELCUSTOM
;
5245 if gGameSettings
.GameMode
= GM_COOP
then
5246 g_Player_RememberAll
;
5248 if not g_Map_Exist(gGameSettings
.WAD
+ ':\' + gNextMap
) then
5251 if gGameSettings
.GameMode
= GM_COOP
then
5254 gStatsPressed
:= True;
5255 gNextMap
:= 'MAP01';
5257 if not g_Map_Exist(gGameSettings
.WAD
+ ':\' + gNextMap
) then
5260 if g_Game_IsNet
then
5262 MH_SEND_GameStats();
5263 MH_SEND_CoopStats();
5269 procedure g_Game_RestartLevel();
5273 if gGameSettings
.GameMode
= GM_SINGLE
then
5278 gExit
:= EXIT_ENDLEVELCUSTOM
;
5279 Map
:= g_ExtractFileName(gMapInfo
.Map
);
5283 function g_Game_ClientWAD (NewWAD
: String; const WHash
: TMD5Digest
): AnsiString;
5285 gWAD
{, xwad}: String;
5288 if not g_Game_IsClient
then Exit
;
5289 //e_LogWritefln('*** g_Game_ClientWAD: `%s`', [NewWAD]);
5291 gWAD
:= g_Res_DownloadMapWAD(ExtractFileName(NewWAD
), WHash
);
5296 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_WAD
], [ExtractFileName(NewWAD
)]));
5300 e_LogWritefln('using downloaded client map wad [%s] for [%s]', [gWAD
, NewWAD
], TMsgType
.Notify
);
5303 g_Game_LoadWAD(NewWAD
);
5307 if LowerCase(NewWAD) = LowerCase(gGameSettings.WAD) then Exit;
5308 gWAD := g_Res_SearchSameWAD(MapsDir, ExtractFileName(NewWAD), WHash);
5311 g_Game_SetLoadingText(_lc[I_LOAD_DL_RES], 0, False);
5312 gWAD := g_Res_DownloadMapWAD(ExtractFileName(NewWAD), WHash);
5316 g_FatalError(Format(_lc[I_GAME_ERROR_MAP_WAD], [ExtractFileName(NewWAD)]));
5320 NewWAD := ExtractRelativePath(MapsDir, gWAD);
5321 g_Game_LoadWAD(NewWAD);
5325 procedure g_Game_RestartRound(NoMapRestart
: Boolean = False);
5327 i
, n
, nb
, nr
: Integer;
5329 if not g_Game_IsServer
then Exit
;
5330 if gLMSRespawn
= LMS_RESPAWN_NONE
then Exit
;
5331 gLMSRespawn
:= LMS_RESPAWN_NONE
;
5332 gLMSRespawnTime
:= 0;
5335 if (gGameSettings
.GameMode
= GM_COOP
) and not NoMapRestart
then
5337 gMissionFailed
:= True;
5338 g_Game_RestartLevel
;
5342 n
:= 0; nb
:= 0; nr
:= 0;
5343 for i
:= Low(gPlayers
) to High(gPlayers
) do
5344 if (gPlayers
[i
] <> nil) and
5345 ((not gPlayers
[i
].FSpectator
) or gPlayers
[i
].FWantsInGame
or
5346 (gPlayers
[i
] is TBot
)) then
5349 if gPlayers
[i
].Team
= TEAM_RED
then Inc(nr
)
5350 else if gPlayers
[i
].Team
= TEAM_BLUE
then Inc(nb
)
5353 if (n
< 1) or ((gGameSettings
.GameMode
= GM_TDM
) and ((nr
= 0) or (nb
= 0))) then
5355 // wait a second until the fuckers finally decide to join
5356 gLMSRespawn
:= LMS_RESPAWN_WARMUP
;
5357 gLMSRespawnTime
:= gTime
+ gGameSettings
.WarmupTime
*1000;
5358 gLMSSoftSpawn
:= NoMapRestart
;
5359 if g_Game_IsNet
then
5360 MH_SEND_GameEvent(NET_EV_LMS_WARMUP
, gLMSRespawnTime
- gTime
);
5364 g_Player_RemoveAllCorpses
;
5365 g_Game_Message(_lc
[I_MESSAGE_LMS_START
], 144);
5366 if g_Game_IsNet
then
5367 MH_SEND_GameEvent(NET_EV_LMS_START
);
5369 for i
:= Low(gPlayers
) to High(gPlayers
) do
5371 if gPlayers
[i
] = nil then continue
;
5372 if gPlayers
[i
] is TBot
then gPlayers
[i
].FWantsInGame
:= True;
5373 // don't touch normal spectators
5374 if gPlayers
[i
].FSpectator
and not gPlayers
[i
].FWantsInGame
then
5376 gPlayers
[i
].FNoRespawn
:= True;
5377 gPlayers
[i
].Lives
:= 0;
5378 if g_Game_IsNet
then
5379 MH_SEND_PlayerStats(gPlayers
[I
].UID
);
5382 gPlayers
[i
].FNoRespawn
:= False;
5383 gPlayers
[i
].Lives
:= gGameSettings
.MaxLives
;
5384 gPlayers
[i
].Respawn(False, True);
5385 if gGameSettings
.GameMode
= GM_COOP
then
5387 gPlayers
[i
].Frags
:= 0;
5388 gPlayers
[i
].RecallState
;
5390 if (gPlayer1
= nil) and (gSpectLatchPID1
> 0) then
5391 gPlayer1
:= g_Player_Get(gSpectLatchPID1
);
5392 if (gPlayer2
= nil) and (gSpectLatchPID2
> 0) then
5393 gPlayer2
:= g_Player_Get(gSpectLatchPID2
);
5396 g_Items_RestartRound();
5398 gLMSSoftSpawn
:= False;
5401 function g_Game_GetFirstMap(WAD
: String): String;
5405 MapList
:= g_Map_GetMapsList(WAD
);
5406 if MapList
= nil then
5409 SortSArray(MapList
);
5410 Result
:= MapList
[Low(MapList
)];
5412 if not g_Map_Exist(WAD
+ ':\' + Result
) then
5418 function g_Game_GetNextMap(): String;
5425 MapList
:= g_Map_GetMapsList(gGameSettings
.WAD
);
5426 if MapList
= nil then
5429 Map
:= g_ExtractFileName(gMapInfo
.Map
);
5431 SortSArray(MapList
);
5433 for I
:= Low(MapList
) to High(MapList
) do
5434 if Map
= MapList
[I
] then
5440 if MapIndex
<> -255 then
5442 if MapIndex
= High(MapList
) then
5443 Result
:= MapList
[Low(MapList
)]
5445 Result
:= MapList
[MapIndex
+ 1];
5447 if not g_Map_Exist(gGameSettings
.WAD
+ ':\' + Result
) then Result
:= Map
;
5453 procedure g_Game_NextLevel();
5455 if gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
, GM_COOP
] then
5456 gExit
:= EXIT_ENDLEVELCUSTOM
5459 gExit
:= EXIT_ENDLEVELSINGLE
;
5463 if gNextMap
<> '' then Exit
;
5464 gNextMap
:= g_Game_GetNextMap();
5467 function g_Game_IsTestMap(): Boolean;
5469 result
:= StrEquCI1251(TEST_MAP_NAME
, g_ExtractFileName(gMapInfo
.Map
));
5472 procedure g_Game_DeleteTestMap();
5475 //MapName: AnsiString;
5483 a
:= Pos('.wad:\', toLowerCase1251(gMapToDelete
));
5484 if (a
= 0) then a
:= Pos('.wad:/', toLowerCase1251(gMapToDelete
));
5485 if (a
= 0) then exit
;
5487 // Âûäåëÿåì èìÿ wad-ôàéëà è èìÿ êàðòû
5488 WadName
:= Copy(gMapToDelete
, 1, a
+3);
5489 Delete(gMapToDelete
, 1, a
+5);
5490 gMapToDelete
:= UpperCase(gMapToDelete
);
5492 //CopyMemory(@MapName[0], @gMapToDelete[1], Min(16, Length(gMapToDelete)));
5495 // Èìÿ êàðòû íå ñòàíäàðòíîå òåñòîâîå:
5496 if MapName <> TEST_MAP_NAME then
5499 if not gTempDelete then
5501 time := g_GetFileTime(WadName);
5502 WAD := TWADFile.Create();
5505 if not WAD.ReadFile(WadName) then
5506 begin // Íåò òàêîãî WAD-ôàéëà
5511 // Ñîñòàâëÿåì ñïèñîê êàðò è èùåì íóæíóþ:
5513 MapList := WAD.GetResourcesList('');
5515 if MapList <> nil then
5516 for a := 0 to High(MapList) do
5517 if MapList[a] = MapName then
5519 // Óäàëÿåì è ñîõðàíÿåì:
5520 WAD.RemoveResource('', MapName);
5521 WAD.SaveTo(WadName);
5526 g_SetFileTime(WadName, time);
5529 if gTempDelete
then DeleteFile(WadName
);
5532 procedure GameCVars(P
: SSArray
);
5535 stat
: TPlayerStatArray
;
5539 procedure ParseGameFlag(Flag
: LongWord; OffMsg
, OnMsg
: TStrings_Locale
; OnMapChange
: Boolean = False);
5543 if Length(P
) > 1 then
5548 gsGameFlags
:= gsGameFlags
or Flag
5550 gsGameFlags
:= gsGameFlags
and (not Flag
);
5552 if g_Game_IsServer
then
5555 gGameSettings
.Options
:= gGameSettings
.Options
or Flag
5557 gGameSettings
.Options
:= gGameSettings
.Options
and (not Flag
);
5558 if g_Game_IsNet
then MH_SEND_GameSettings
;
5562 if LongBool(gsGameFlags
and Flag
) then
5563 g_Console_Add(_lc
[OnMsg
])
5565 g_Console_Add(_lc
[OffMsg
]);
5567 if OnMapChange
and g_Game_IsServer
then
5568 g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
5573 cmd
:= LowerCase(P
[0]);
5575 if cmd
= 'g_gamemode' then
5577 if (Length(P
) > 1) then
5579 a
:= g_Game_TextToMode(P
[1]);
5580 if a
= GM_SINGLE
then a
:= GM_COOP
;
5581 gsGameMode
:= g_Game_ModeToText(a
);
5582 if g_Game_IsServer
then
5584 gSwitchGameMode
:= a
;
5585 if (gGameOn
and (gGameSettings
.GameMode
= GM_SINGLE
)) or
5586 (gState
= STATE_INTERSINGLE
) then
5587 gSwitchGameMode
:= GM_SINGLE
;
5589 gGameSettings
.GameMode
:= gSwitchGameMode
;
5593 if gSwitchGameMode
= gGameSettings
.GameMode
then
5594 g_Console_Add(Format(_lc
[I_MSG_GAMEMODE_CURRENT
],
5595 [g_Game_ModeToText(gGameSettings
.GameMode
)]))
5597 g_Console_Add(Format(_lc
[I_MSG_GAMEMODE_CHANGE
],
5598 [g_Game_ModeToText(gGameSettings
.GameMode
),
5599 g_Game_ModeToText(gSwitchGameMode
)]));
5601 else if cmd
= 'g_friendlyfire' then
5603 ParseGameFlag(GAME_OPTION_TEAMDAMAGE
, I_MSG_FRIENDLY_FIRE_OFF
, I_MSG_FRIENDLY_FIRE_ON
);
5605 else if cmd
= 'g_friendly_absorb_damage' then
5607 ParseGameFlag(GAME_OPTION_TEAMABSORBDAMAGE
, I_MSG_FRIENDLY_ABSORB_DAMAGE_OFF
, I_MSG_FRIENDLY_ABSORB_DAMAGE_ON
);
5609 else if cmd
= 'g_friendly_hit_trace' then
5611 ParseGameFlag(GAME_OPTION_TEAMHITTRACE
, I_MSG_FRIENDLY_HIT_TRACE_OFF
, I_MSG_FRIENDLY_HIT_TRACE_ON
);
5613 else if cmd
= 'g_friendly_hit_projectile' then
5615 ParseGameFlag(GAME_OPTION_TEAMHITPROJECTILE
, I_MSG_FRIENDLY_PROJECT_TRACE_OFF
, I_MSG_FRIENDLY_PROJECT_TRACE_ON
);
5617 else if cmd
= 'g_rulez_randomize_respawn' then
5619 ParseGameFlag(GAME_OPTION_RULEZRANDOM
, I_MSG_RULEZ_RANDOM_ON
, I_MSG_RULEZ_RANDOM_OFF
);
5621 else if cmd
= 'g_weaponstay' then
5623 ParseGameFlag(GAME_OPTION_WEAPONSTAY
, I_MSG_WEAPONSTAY_OFF
, I_MSG_WEAPONSTAY_ON
);
5625 else if cmd
= 'g_allow_exit' then
5627 ParseGameFlag(GAME_OPTION_ALLOWEXIT
, I_MSG_ALLOWEXIT_OFF
, I_MSG_ALLOWEXIT_ON
, True);
5629 else if cmd
= 'g_allow_monsters' then
5631 ParseGameFlag(GAME_OPTION_MONSTERS
, I_MSG_ALLOWMON_OFF
, I_MSG_ALLOWMON_ON
, True);
5633 else if cmd
= 'g_allow_dropflag' then
5635 ParseGameFlag(GAME_OPTION_ALLOWDROPFLAG
, I_MSG_ALLOWDROPFLAG_OFF
, I_MSG_ALLOWDROPFLAG_ON
);
5637 else if cmd
= 'g_throw_flag' then
5639 ParseGameFlag(GAME_OPTION_THROWFLAG
, I_MSG_THROWFLAG_OFF
, I_MSG_THROWFLAG_ON
);
5641 else if cmd
= 'g_bot_vsplayers' then
5643 ParseGameFlag(GAME_OPTION_BOTVSPLAYER
, I_MSG_BOTSVSPLAYERS_OFF
, I_MSG_BOTSVSPLAYERS_ON
);
5645 else if cmd
= 'g_bot_vsmonsters' then
5647 ParseGameFlag(GAME_OPTION_BOTVSMONSTER
, I_MSG_BOTSVSMONSTERS_OFF
, I_MSG_BOTSVSMONSTERS_ON
);
5649 else if cmd
= 'g_dm_keys' then
5651 ParseGameFlag(GAME_OPTION_DMKEYS
, I_MSG_DMKEYS_OFF
, I_MSG_DMKEYS_ON
, True);
5653 else if cmd
= 'g_gameflags' then
5655 if Length(P
) > 1 then
5657 gsGameFlags
:= StrToDWordDef(P
[1], gsGameFlags
);
5658 if g_Game_IsServer
then
5660 gGameSettings
.Options
:= gsGameFlags
;
5661 if g_Game_IsNet
then MH_SEND_GameSettings
;
5665 g_Console_Add(Format('%s %u', [cmd
, gsGameFlags
]));
5667 else if cmd
= 'g_warmup_time' then
5669 if Length(P
) > 1 then
5671 gsWarmupTime
:= nclamp(StrToIntDef(P
[1], gsWarmupTime
), 0, $FFFF);
5672 if g_Game_IsServer
then
5674 gGameSettings
.WarmupTime
:= gsWarmupTime
;
5675 // extend warmup if it's already going
5676 if gLMSRespawn
= LMS_RESPAWN_WARMUP
then
5678 gLMSRespawnTime
:= gTime
+ gsWarmupTime
* 1000;
5679 if g_Game_IsNet
then MH_SEND_GameEvent(NET_EV_LMS_WARMUP
, gLMSRespawnTime
- gTime
);
5681 if g_Game_IsNet
then MH_SEND_GameSettings
;
5685 g_Console_Add(Format(_lc
[I_MSG_WARMUP
], [Integer(gsWarmupTime
)]));
5686 if g_Game_IsServer
then g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
5688 else if cmd
= 'g_spawn_invul' then
5690 if Length(P
) > 1 then
5692 gsSpawnInvul
:= nclamp(StrToIntDef(P
[1], gsSpawnInvul
), 0, $FFFF);
5693 if g_Game_IsServer
then
5695 gGameSettings
.SpawnInvul
:= gsSpawnInvul
;
5696 if g_Game_IsNet
then MH_SEND_GameSettings
;
5700 g_Console_Add(Format('%s %d', [cmd
, Integer(gsSpawnInvul
)]));
5702 else if cmd
= 'g_item_respawn_time' then
5704 if Length(P
) > 1 then
5706 gsItemRespawnTime
:= nclamp(StrToIntDef(P
[1], gsItemRespawnTime
), 0, $FFFF);
5707 if g_Game_IsServer
then
5709 gGameSettings
.ItemRespawnTime
:= gsItemRespawnTime
;
5710 if g_Game_IsNet
then MH_SEND_GameSettings
;
5714 g_Console_Add(Format('%s %d', [cmd
, Integer(gsItemRespawnTime
)]));
5715 if g_Game_IsServer
then g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
5717 else if cmd
= 'g_rulez_time_multiplier' then
5719 if Length(P
) > 1 then
5721 gsRulezTimeMultiplier
:= nclamp(StrToIntDef(P
[1], gsRulezTimeMultiplier
), 0, $FFFF);
5722 if g_Game_IsServer
then
5724 gGameSettings
.RulezTimeMultiplier
:= gsRulezTimeMultiplier
;
5725 if g_Game_IsNet
then MH_SEND_GameSettings
;
5729 g_Console_Add(Format('%s %d', [cmd
, Integer(gsRulezTimeMultiplier
)]));
5730 if g_Game_IsServer
then g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
5732 else if cmd
= 'sv_intertime' then
5734 if (Length(P
) > 1) then
5735 gDefInterTime
:= Min(Max(StrToIntDef(P
[1], gDefInterTime
), -1), 120);
5737 g_Console_Add(cmd
+ ' = ' + IntToStr(gDefInterTime
));
5739 else if cmd
= 'g_max_particles' then
5741 if Length(p
) = 2 then
5743 a
:= Max(0, StrToIntDef(p
[1], 0));
5746 else if Length(p
) = 1 then
5748 e_LogWritefln('%s', [g_GFX_GetMax()])
5752 e_LogWritefln('usage: %s <n>', [cmd
])
5755 else if cmd
= 'g_max_shells' then
5757 if Length(p
) = 2 then
5759 a
:= Max(0, StrToIntDef(p
[1], 0));
5762 else if Length(p
) = 1 then
5764 e_LogWritefln('%s', [g_Shells_GetMax()])
5768 e_LogWritefln('usage: %s <n>', [cmd
])
5771 else if cmd
= 'g_max_gibs' then
5773 if Length(p
) = 2 then
5775 a
:= Max(0, StrToIntDef(p
[1], 0));
5778 else if Length(p
) = 1 then
5780 e_LogWritefln('%s', [g_Gibs_GetMax()])
5784 e_LogWritefln('usage: %s <n>', [cmd
])
5787 else if cmd
= 'g_max_corpses' then
5789 if Length(p
) = 2 then
5791 a
:= Max(0, StrToIntDef(p
[1], 0));
5794 else if Length(p
) = 1 then
5796 e_LogWritefln('%s', [g_Corpses_GetMax()])
5800 e_LogWritefln('usage: %s <n>', [cmd
])
5803 else if cmd
= 'g_force_model' then
5805 if Length(p
) = 2 then
5807 a
:= StrToIntDef(p
[1], 0);
5808 g_Force_Model_Set(a
);
5809 if (g_Force_Model_Get() <> 0) and (gPlayers
<> nil) then
5811 for a
:= Low(gPlayers
) to High(gPlayers
) do
5813 if (gPlayers
[a
] <> nil) then
5815 if (gPlayers
[a
].UID
= gPlayer1
.UID
) then
5817 else if (gPlayer2
<> nil) and (gPlayers
[a
].UID
= gPlayer2
.UID
) then
5819 gPlayers
[a
].setModel(g_Forced_Model_GetName());
5823 else if (g_Force_Model_Get() = 0) and (gPlayers
<> nil) then
5825 for a
:= Low(gPlayers
) to High(gPlayers
) do
5827 if (gPlayers
[a
] <> nil) then
5829 if (gPlayers
[a
].UID
= gPlayer1
.UID
) then
5831 else if (gPlayer2
<> nil) and (gPlayers
[a
].UID
= gPlayer2
.UID
) then
5833 gPlayers
[a
].setModel(gPlayers
[a
].FActualModelName
);
5839 else if cmd
= 'g_force_model_name' then
5841 if (Length(P
) > 1) then
5843 cmd
:= b_Text_Unformat(P
[1]);
5844 g_Forced_Model_SetName(cmd
);
5845 if (g_Force_Model_Get() <> 0) and (gPlayers
<> nil) then
5847 for a
:= Low(gPlayers
) to High(gPlayers
) do
5849 if (gPlayers
[a
] <> nil) then
5851 if (gPlayers
[a
].UID
= gPlayer1
.UID
) then
5853 else if (gPlayer2
<> nil) and (gPlayers
[a
].UID
= gPlayer2
.UID
) then
5855 gPlayers
[a
].setModel(g_Forced_Model_GetName());
5861 else if cmd
= 'g_scorelimit' then
5863 if Length(P
) > 1 then
5865 gsScoreLimit
:= nclamp(StrToIntDef(P
[1], gsScoreLimit
), 0, $FFFF);
5867 if g_Game_IsServer
then
5870 if gGameSettings
.GameMode
= GM_DM
then
5872 stat
:= g_Player_GetStats();
5874 for a
:= 0 to High(stat
) do
5875 if stat
[a
].Frags
> b
then
5879 b
:= Max(gTeamStat
[TEAM_RED
].Score
, gTeamStat
[TEAM_BLUE
].Score
);
5881 // if someone has a higher score, set it to that instead
5882 gsScoreLimit
:= max(gsScoreLimit
, b
);
5883 gGameSettings
.ScoreLimit
:= gsScoreLimit
;
5885 if g_Game_IsNet
then MH_SEND_GameSettings
;
5889 g_Console_Add(Format(_lc
[I_MSG_SCORE_LIMIT
], [Integer(gsScoreLimit
)]));
5891 else if cmd
= 'g_timelimit' then
5893 if Length(P
) > 1 then
5895 gsTimeLimit
:= nclamp(StrToIntDef(P
[1], gsTimeLimit
), 0, $FFFF);
5896 if g_Game_IsServer
then
5898 gGameSettings
.TimeLimit
:= gsTimeLimit
;
5899 if g_Game_IsNet
then MH_SEND_GameSettings
;
5902 g_Console_Add(Format(_lc
[I_MSG_TIME_LIMIT
],
5903 [gsTimeLimit
div 3600,
5904 (gsTimeLimit
div 60) mod 60,
5905 gsTimeLimit
mod 60]));
5907 else if cmd
= 'g_max_bots' then
5909 if Length(P
) > 1 then
5910 gMaxBots
:= nclamp(StrToIntDef(P
[1], gMaxBots
), 0, 127);
5911 g_Console_Add('g_max_bots = ' + IntToStr(gMaxBots
));
5913 else if cmd
= 'g_maxlives' then
5915 if Length(P
) > 1 then
5917 gsMaxLives
:= nclamp(StrToIntDef(P
[1], gsMaxLives
), 0, $FFFF);
5918 if g_Game_IsServer
then
5920 gGameSettings
.MaxLives
:= gsMaxLives
;
5921 if g_Game_IsNet
then MH_SEND_GameSettings
;
5925 g_Console_Add(Format(_lc
[I_MSG_LIVES
], [Integer(gsMaxLives
)]));
5929 procedure PlayerSettingsCVars(P
: SSArray
);
5934 function ParseTeam(s
: string): Byte;
5938 'red', '1': result
:= TEAM_RED
;
5939 'blue', '2': result
:= TEAM_BLUE
;
5940 else result
:= TEAM_NONE
;
5944 cmd
:= LowerCase(P
[0]);
5948 if (Length(P
) > 1) then
5950 gPlayer1Settings
.Name
:= b_Text_Unformat(P
[1]);
5951 if g_Game_IsClient
then
5952 MC_SEND_PlayerSettings
5953 else if gGameOn
and (gPlayer1
<> nil) then
5955 gPlayer1
.Name
:= b_Text_Unformat(P
[1]);
5956 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer1
.UID
);
5962 if (Length(P
) > 1) then
5964 gPlayer2Settings
.Name
:= b_Text_Unformat(P
[1]);
5965 if g_Game_IsClient
then
5966 MC_SEND_PlayerSettings
5967 else if gGameOn
and (gPlayer2
<> nil) then
5969 gPlayer2
.Name
:= b_Text_Unformat(P
[1]);
5970 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer2
.UID
);
5976 if Length(P
) > 3 then
5978 gPlayer1Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
5979 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
5980 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
5981 if g_Game_IsClient
then
5982 MC_SEND_PlayerSettings
5983 else if gGameOn
and (gPlayer1
<> nil) then
5985 gPlayer1
.SetColor(gPlayer1Settings
.Color
);
5986 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer1
.UID
);
5992 if Length(P
) > 3 then
5994 gPlayer2Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
5995 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
5996 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
5997 if g_Game_IsClient
then
5998 MC_SEND_PlayerSettings
5999 else if gGameOn
and (gPlayer2
<> nil) then
6001 gPlayer2
.SetColor(gPlayer2Settings
.Color
);
6002 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer2
.UID
);
6008 if (Length(P
) > 1) then
6010 gPlayer1Settings
.Model
:= P
[1];
6011 if g_Game_IsClient
then
6012 MC_SEND_PlayerSettings
6013 else if gGameOn
and (gPlayer1
<> nil) then
6015 gPlayer1
.FActualModelName
:= gPlayer1Settings
.Model
;
6016 gPlayer1
.SetModel(gPlayer1Settings
.Model
);
6017 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer1
.UID
);
6023 if (Length(P
) > 1) then
6025 gPlayer2Settings
.Model
:= P
[1];
6026 if g_Game_IsClient
then
6027 MC_SEND_PlayerSettings
6028 else if gGameOn
and (gPlayer2
<> nil) then
6030 gPlayer2
.FActualModelName
:= gPlayer2Settings
.Model
;
6031 gPlayer2
.SetModel(gPlayer2Settings
.Model
);
6032 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer2
.UID
);
6038 // TODO: switch teams if in game or store this separately
6039 if (Length(P
) > 1) then
6041 team
:= ParseTeam(P
[1]);
6042 if team
= TEAM_NONE
then
6043 g_Console_Add('expected ''red'', ''blue'', 1 or 2')
6044 else if not gGameOn
and not g_Game_IsNet
then
6045 gPlayer1Settings
.Team
:= team
6047 g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
6052 // TODO: switch teams if in game or store this separately
6053 if (Length(P
) > 1) then
6055 team
:= ParseTeam(P
[1]);
6056 if team
= TEAM_NONE
then
6057 g_Console_Add('expected ''red'', ''blue'', 1 or 2')
6058 else if not gGameOn
and not g_Game_IsNet
then
6059 gPlayer2Settings
.Team
:= team
6061 g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
6066 if (Length(P
) = 2) then
6067 gPlayer1Settings
.WeaponSwitch
:= EnsureRange(StrTointDef(P
[1], 0), 0, 2);
6071 if (Length(P
) = 2) then
6072 gPlayer2Settings
.WeaponSwitch
:= EnsureRange(StrTointDef(P
[1], 0), 0, 2);
6076 if (Length(P
) = 2) then
6077 gPlayer1Settings
.SwitchToEmpty
:= EnsureRange(StrTointDef(P
[1], 0), 0, 1);
6081 if (Length(P
) = 2) then
6082 gPlayer2Settings
.SwitchToEmpty
:= EnsureRange(StrTointDef(P
[1], 0), 0, 1);
6086 if (Length(P
) = 2) then
6087 gPlayer1Settings
.SkipFist
:= EnsureRange(StrTointDef(P
[1], 0), 0, 1);
6091 if (Length(P
) = 2) then
6092 gPlayer2Settings
.SkipFist
:= EnsureRange(StrTointDef(P
[1], 0), 0, 1);
6094 'p1_priority_kastet':
6096 if (Length(P
) = 2) then
6097 gPlayer1Settings
.WeaponPreferences
[WEAPON_KASTET
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6099 'p2_priority_kastet':
6101 if (Length(P
) = 2) then
6102 gPlayer2Settings
.WeaponPreferences
[WEAPON_KASTET
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6106 if (Length(P
) = 2) then
6107 gPlayer1Settings
.WeaponPreferences
[WEAPON_SAW
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6111 if (Length(P
) = 2) then
6112 gPlayer2Settings
.WeaponPreferences
[WEAPON_SAW
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6114 'p1_priority_pistol':
6116 if (Length(P
) = 2) then
6117 gPlayer1Settings
.WeaponPreferences
[WEAPON_KASTET
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6119 'p2_priority_pistol':
6121 if (Length(P
) = 2) then
6122 gPlayer2Settings
.WeaponPreferences
[WEAPON_KASTET
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6124 'p1_priority_shotgun1':
6126 if (Length(P
) = 2) then
6127 gPlayer1Settings
.WeaponPreferences
[WEAPON_SHOTGUN1
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6129 'p2_priority_shotgun1':
6131 if (Length(P
) = 2) then
6132 gPlayer2Settings
.WeaponPreferences
[WEAPON_SHOTGUN1
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6134 'p1_priority_shotgun2':
6136 if (Length(P
) = 2) then
6137 gPlayer1Settings
.WeaponPreferences
[WEAPON_SHOTGUN2
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6139 'p2_priority_shotgun2':
6141 if (Length(P
) = 2) then
6142 gPlayer2Settings
.WeaponPreferences
[WEAPON_SHOTGUN2
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6144 'p1_priority_chaingun':
6146 if (Length(P
) = 2) then
6147 gPlayer1Settings
.WeaponPreferences
[WEAPON_CHAINGUN
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6149 'p2_priority_chaingun':
6151 if (Length(P
) = 2) then
6152 gPlayer2Settings
.WeaponPreferences
[WEAPON_CHAINGUN
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6154 'p1_priority_rocketlauncher':
6156 if (Length(P
) = 2) then
6157 gPlayer1Settings
.WeaponPreferences
[WEAPON_ROCKETLAUNCHER
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6159 'p2_priority_rocketlauncher':
6161 if (Length(P
) = 2) then
6162 gPlayer2Settings
.WeaponPreferences
[WEAPON_ROCKETLAUNCHER
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6164 'p1_priority_plasma':
6166 if (Length(P
) = 2) then
6167 gPlayer1Settings
.WeaponPreferences
[WEAPON_PLASMA
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6169 'p2_priority_plasma':
6171 if (Length(P
) = 2) then
6172 gPlayer2Settings
.WeaponPreferences
[WEAPON_PLASMA
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6176 if (Length(P
) = 2) then
6177 gPlayer1Settings
.WeaponPreferences
[WEAPON_BFG
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6181 if (Length(P
) = 2) then
6182 gPlayer2Settings
.WeaponPreferences
[WEAPON_BFG
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6184 'p1_priority_super':
6186 if (Length(P
) = 2) then
6187 gPlayer1Settings
.WeaponPreferences
[WEAPON_SUPERPULEMET
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6189 'p2_priority_super':
6191 if (Length(P
) = 2) then
6192 gPlayer2Settings
.WeaponPreferences
[WEAPON_SUPERPULEMET
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6194 'p1_priority_flamethrower':
6196 if (Length(P
) = 2) then
6197 gPlayer1Settings
.WeaponPreferences
[WEAPON_FLAMETHROWER
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6199 'p2_priority_flamethrower':
6201 if (Length(P
) = 2) then
6202 gPlayer2Settings
.WeaponPreferences
[WEAPON_FLAMETHROWER
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6204 'p1_priority_berserk':
6206 if (Length(P
) = 2) then
6207 gPlayer1Settings
.WeaponPreferences
[WP_LAST
+1] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6209 'p2_priority_berserk':
6211 if (Length(P
) = 2) then
6212 gPlayer2Settings
.WeaponPreferences
[WP_LAST
+1] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6217 procedure PrintHeapStats();
6221 hs
:= GetFPCHeapStatus();
6222 e_LogWriteLn ('v===== heap status =====v');
6223 e_LogWriteFln('max heap size = %d k', [hs
.MaxHeapSize
div 1024]);
6224 e_LogWriteFln('max heap used = %d k', [hs
.MaxHeapUsed
div 1024]);
6225 e_LogWriteFln('cur heap size = %d k', [hs
.CurrHeapSize
div 1024]);
6226 e_LogWriteFln('cur heap used = %d k', [hs
.CurrHeapUsed
div 1024]);
6227 e_LogWriteFln('cur heap free = %d k', [hs
.CurrHeapFree
div 1024]);
6228 e_LogWriteLn ('^=======================^');
6231 procedure DebugCommands(P
: SSArray
);
6238 // Êîìàíäû îòëàäî÷íîãî ðåæèìà:
6239 if {gDebugMode}conIsCheatsEnabled
then
6241 cmd
:= LowerCase(P
[0]);
6242 if cmd
= 'd_window' then
6244 g_Console_Add(Format('gScreenWidth = %d, gScreenHeight = %d', [gScreenWidth
, gScreenHeight
]));
6245 g_Console_Add(Format('gScreenWidth = %d, gScreenHeight = %d', [gScreenWidth
, gScreenHeight
]));
6247 else if cmd
= 'd_sounds' then
6249 if (Length(P
) > 1) and
6250 ((P
[1] = '1') or (P
[1] = '0')) then
6251 g_Debug_Sounds
:= (P
[1][1] = '1');
6253 g_Console_Add(Format('d_sounds is %d', [Byte(g_Debug_Sounds
)]));
6255 else if cmd
= 'd_frames' then
6257 if (Length(P
) > 1) and
6258 ((P
[1] = '1') or (P
[1] = '0')) then
6259 g_Debug_Frames
:= (P
[1][1] = '1');
6261 g_Console_Add(Format('d_frames is %d', [Byte(g_Debug_Frames
)]));
6263 else if cmd
= 'd_winmsg' then
6265 if (Length(P
) > 1) and
6266 ((P
[1] = '1') or (P
[1] = '0')) then
6267 g_Debug_WinMsgs
:= (P
[1][1] = '1');
6269 g_Console_Add(Format('d_winmsg is %d', [Byte(g_Debug_WinMsgs
)]));
6271 else if (cmd
= 'd_monoff') and not g_Game_IsNet
then
6273 if (Length(P
) > 1) and
6274 ((P
[1] = '1') or (P
[1] = '0')) then
6275 g_Debug_MonsterOff
:= (P
[1][1] = '1');
6277 g_Console_Add(Format('d_monoff is %d', [Byte(g_debug_MonsterOff
)]));
6279 else if (cmd
= 'd_botoff') and not g_Game_IsNet
then
6281 if Length(P
) > 1 then
6283 '0': g_debug_BotAIOff
:= 0;
6284 '1': g_debug_BotAIOff
:= 1;
6285 '2': g_debug_BotAIOff
:= 2;
6286 '3': g_debug_BotAIOff
:= 3;
6289 g_Console_Add(Format('d_botoff is %d', [g_debug_BotAIOff
]));
6291 else if cmd
= 'd_monster' then
6293 if gGameOn
and (gPlayer1
<> nil) and (gPlayer1
.alive
) and (not g_Game_IsNet
) then
6294 if Length(P
) < 2 then
6296 g_Console_Add(cmd
+ ' [ID | Name] [behaviour]');
6297 g_Console_Add('ID | Name');
6298 for b
:= MONSTER_DEMON
to MONSTER_MAN
do
6299 g_Console_Add(Format('%2d | %s', [b
, g_Mons_NameByTypeId(b
)]));
6300 conwriteln('behav. num'#10'normal 0'#10'killer 1'#10'maniac 2'#10'insane 3'#10'cannibal 4'#10'good 5');
6303 a
:= StrToIntDef(P
[1], 0);
6304 if (a
< MONSTER_DEMON
) or (a
> MONSTER_MAN
) then
6305 a
:= g_Mons_TypeIdByName(P
[1]);
6307 if (a
< MONSTER_DEMON
) or (a
> MONSTER_MAN
) then
6308 g_Console_Add(Format(_lc
[I_MSG_NO_MONSTER
], [P
[1]]))
6311 with gPlayer1
.Obj
do
6313 mon
:= g_Monsters_Create(a
,
6314 X
+ Rect
.X
+ (Rect
.Width
div 2),
6315 Y
+ Rect
.Y
+ Rect
.Height
,
6316 gPlayer1
.Direction
, True);
6318 if (Length(P
) > 2) and (mon
<> nil) then
6320 if (CompareText(P
[2], 'normal') = 0) then mon
.MonsterBehaviour
:= BH_NORMAL
6321 else if (CompareText(P
[2], 'killer') = 0) then mon
.MonsterBehaviour
:= BH_KILLER
6322 else if (CompareText(P
[2], 'maniac') = 0) then mon
.MonsterBehaviour
:= BH_MANIAC
6323 else if (CompareText(P
[2], 'insane') = 0) then mon
.MonsterBehaviour
:= BH_INSANE
6324 else if (CompareText(P
[2], 'cannibal') = 0) then mon
.MonsterBehaviour
:= BH_CANNIBAL
6325 else if (CompareText(P
[2], 'good') = 0) then mon
.MonsterBehaviour
:= BH_GOOD
6326 else if (CompareText(P
[2], 'friend') = 0) then mon
.MonsterBehaviour
:= BH_GOOD
6327 else if (CompareText(P
[2], 'friendly') = 0) then mon
.MonsterBehaviour
:= BH_GOOD
6328 else mon
.MonsterBehaviour
:= Min(Max(StrToIntDef(P
[2], BH_NORMAL
), BH_NORMAL
), BH_GOOD
);
6333 else if (cmd
= 'd_health') then
6335 if (Length(P
) > 1) and
6336 ((P
[1] = '1') or (P
[1] = '0')) then
6337 g_debug_HealthBar
:= (P
[1][1] = '1');
6339 g_Console_Add(Format('d_health is %d', [Byte(g_debug_HealthBar
)]));
6341 else if (cmd
= 'd_player') then
6343 if (Length(P
) > 1) and
6344 ((P
[1] = '1') or (P
[1] = '0')) then
6345 g_debug_Player
:= (P
[1][1] = '1');
6347 g_Console_Add(Format(cmd
+ ' is %d', [Byte(g_Debug_Player
)]));
6349 else if (cmd
= 'd_mem') then
6355 g_Console_Add(_lc
[I_MSG_NOT_DEBUG
]);
6359 procedure GameCheats(P
: SSArray
);
6365 if (not gGameOn
) or (not conIsCheatsEnabled
) then
6367 g_Console_Add('not available');
6373 g_Console_Add('where is the player?!');
6376 cmd
:= LowerCase(P
[0]);
6380 plr
.GodMode
:= not plr
.GodMode
;
6381 if plr
.GodMode
then g_Console_Add('player is godlike now') else g_Console_Add('player is mortal now');
6384 // give <health|exit|weapons|air|suit|jetpack|berserk|all>
6385 if cmd
= 'give' then
6387 if length(P
) < 2 then begin g_Console_Add('give what?!'); exit
; end;
6388 for f
:= 1 to High(P
) do
6390 cmd
:= LowerCase(P
[f
]);
6391 if cmd
= 'health' then begin plr
.RestoreHealthArmor(); g_Console_Add('player feels himself better'); continue
; end;
6392 if (cmd
= 'all') {or (cmd = 'weapons')} then begin plr
.AllRulez(False); g_Console_Add('player got the gifts'); continue
; end;
6393 if cmd
= 'exit' then
6395 if gTriggers
<> nil then
6397 for a
:= 0 to High(gTriggers
) do
6399 if gTriggers
[a
].TriggerType
= TRIGGER_EXIT
then
6401 g_Console_Add('player left the map');
6402 gExitByTrigger
:= True;
6403 //g_Game_ExitLevel(gTriggers[a].Data.MapName);
6404 g_Game_ExitLevel(gTriggers
[a
].tgcMap
);
6412 if cmd
= 'air' then begin plr
.GiveItem(ITEM_OXYGEN
); g_Console_Add('player got some air'); continue
; end;
6413 if cmd
= 'jetpack' then begin plr
.GiveItem(ITEM_JETPACK
); g_Console_Add('player got a jetpack'); continue
; end;
6414 if cmd
= 'suit' then begin plr
.GiveItem(ITEM_SUIT
); g_Console_Add('player got an envirosuit'); continue
; end;
6415 if cmd
= 'berserk' then begin plr
.GiveItem(ITEM_MEDKIT_BLACK
); g_Console_Add('player got a berserk pack'); continue
; end;
6416 if cmd
= 'backpack' then begin plr
.GiveItem(ITEM_AMMO_BACKPACK
); g_Console_Add('player got a backpack'); continue
; end;
6418 if cmd
= 'helmet' then begin plr
.GiveItem(ITEM_HELMET
); g_Console_Add('player got a helmet'); continue
; end;
6419 if cmd
= 'bottle' then begin plr
.GiveItem(ITEM_BOTTLE
); g_Console_Add('player got a bottle of health'); continue
; end;
6421 if cmd
= 'stimpack' then begin plr
.GiveItem(ITEM_MEDKIT_SMALL
); g_Console_Add('player got a stimpack'); continue
; end;
6422 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;
6424 if cmd
= 'greenarmor' then begin plr
.GiveItem(ITEM_ARMOR_GREEN
); g_Console_Add('player got a security armor'); continue
; end;
6425 if cmd
= 'bluearmor' then begin plr
.GiveItem(ITEM_ARMOR_BLUE
); g_Console_Add('player got a combat armor'); continue
; end;
6427 if (cmd
= 'megasphere') or (cmd
= 'mega') then begin plr
.GiveItem(ITEM_SPHERE_BLUE
); g_Console_Add('player got a megasphere'); continue
; end;
6428 if (cmd
= 'soulsphere') or (cmd
= 'soul')then begin plr
.GiveItem(ITEM_SPHERE_WHITE
); g_Console_Add('player got a soul sphere'); continue
; end;
6430 if (cmd
= 'invul') or (cmd
= 'invulnerability') then begin plr
.GiveItem(ITEM_INVUL
); g_Console_Add('player got invulnerability'); continue
; end;
6431 if (cmd
= 'invis') or (cmd
= 'invisibility') then begin plr
.GiveItem(ITEM_INVIS
); g_Console_Add('player got invisibility'); continue
; end;
6433 if cmd
= 'redkey' then begin plr
.GiveItem(ITEM_KEY_RED
); g_Console_Add('player got the red key'); continue
; end;
6434 if cmd
= 'greenkey' then begin plr
.GiveItem(ITEM_KEY_GREEN
); g_Console_Add('player got the green key'); continue
; end;
6435 if cmd
= 'bluekey' then begin plr
.GiveItem(ITEM_KEY_BLUE
); g_Console_Add('player got the blue key'); continue
; end;
6437 if (cmd
= 'shotgun') or (cmd
= 'sg') then begin plr
.GiveItem(ITEM_WEAPON_SHOTGUN1
); g_Console_Add('player got a shotgun'); continue
; end;
6438 if (cmd
= 'supershotgun') or (cmd
= 'ssg') then begin plr
.GiveItem(ITEM_WEAPON_SHOTGUN2
); g_Console_Add('player got a supershotgun'); continue
; end;
6439 if cmd
= 'chaingun' then begin plr
.GiveItem(ITEM_WEAPON_CHAINGUN
); g_Console_Add('player got a chaingun'); continue
; end;
6440 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;
6441 if cmd
= 'plasmagun' then begin plr
.GiveItem(ITEM_WEAPON_PLASMA
); g_Console_Add('player got a plasma gun'); continue
; end;
6442 if cmd
= 'bfg' then begin plr
.GiveItem(ITEM_WEAPON_BFG
); g_Console_Add('player got a BFG-9000'); continue
; end;
6444 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;
6445 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;
6446 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;
6447 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;
6448 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;
6449 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;
6451 if cmd
= 'superchaingun' then begin plr
.GiveItem(ITEM_WEAPON_SUPERPULEMET
); g_Console_Add('player got a superchaingun'); continue
; end;
6452 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;
6454 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;
6455 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;
6457 if cmd
= 'chainsaw' then begin plr
.GiveItem(ITEM_WEAPON_SAW
); g_Console_Add('player got a chainsaw'); continue
; end;
6459 if cmd
= 'ammo' then
6461 plr
.GiveItem(ITEM_AMMO_SHELLS_BOX
);
6462 plr
.GiveItem(ITEM_AMMO_BULLETS_BOX
);
6463 plr
.GiveItem(ITEM_AMMO_CELL_BIG
);
6464 plr
.GiveItem(ITEM_AMMO_ROCKET_BOX
);
6465 plr
.GiveItem(ITEM_AMMO_FUELCAN
);
6466 g_Console_Add('player got some ammo');
6470 if cmd
= 'clip' then begin plr
.GiveItem(ITEM_AMMO_BULLETS
); g_Console_Add('player got some bullets'); continue
; end;
6471 if cmd
= 'bullets' then begin plr
.GiveItem(ITEM_AMMO_BULLETS_BOX
); g_Console_Add('player got a box of bullets'); continue
; end;
6473 if cmd
= 'shells' then begin plr
.GiveItem(ITEM_AMMO_SHELLS
); g_Console_Add('player got some shells'); continue
; end;
6474 if cmd
= 'shellbox' then begin plr
.GiveItem(ITEM_AMMO_SHELLS_BOX
); g_Console_Add('player got a box of shells'); continue
; end;
6476 if cmd
= 'cells' then begin plr
.GiveItem(ITEM_AMMO_CELL
); g_Console_Add('player got some cells'); continue
; end;
6477 if cmd
= 'battery' then begin plr
.GiveItem(ITEM_AMMO_CELL_BIG
); g_Console_Add('player got cell battery'); continue
; end;
6479 if cmd
= 'rocket' then begin plr
.GiveItem(ITEM_AMMO_ROCKET
); g_Console_Add('player got a rocket'); continue
; end;
6480 if cmd
= 'rocketbox' then begin plr
.GiveItem(ITEM_AMMO_ROCKET_BOX
); g_Console_Add('player got some rockets'); continue
; end;
6482 if (cmd
= 'fuel') or (cmd
= 'fuelcan') then begin plr
.GiveItem(ITEM_AMMO_FUELCAN
); g_Console_Add('player got fuel canister'); continue
; end;
6484 if cmd
= 'weapons' then
6486 plr
.GiveItem(ITEM_WEAPON_SHOTGUN1
);
6487 plr
.GiveItem(ITEM_WEAPON_SHOTGUN2
);
6488 plr
.GiveItem(ITEM_WEAPON_CHAINGUN
);
6489 plr
.GiveItem(ITEM_WEAPON_ROCKETLAUNCHER
);
6490 plr
.GiveItem(ITEM_WEAPON_PLASMA
);
6491 plr
.GiveItem(ITEM_WEAPON_BFG
);
6492 g_Console_Add('player got weapons');
6496 if cmd
= 'keys' then
6498 plr
.GiveItem(ITEM_KEY_RED
);
6499 plr
.GiveItem(ITEM_KEY_GREEN
);
6500 plr
.GiveItem(ITEM_KEY_BLUE
);
6501 g_Console_Add('player got all keys');
6505 g_Console_Add('i don''t know how to give '''+cmd
+'''!');
6510 if cmd
= 'open' then
6512 g_Console_Add('player activated sesame');
6513 g_Triggers_OpenAll();
6520 if gFly
then g_Console_Add('player feels himself lighter') else g_Console_Add('player lost his wings');
6524 if cmd
= 'noclip' then
6527 g_Console_Add('wall hardeness adjusted');
6531 if cmd
= 'notarget' then
6533 plr
.NoTarget
:= not plr
.NoTarget
;
6534 if plr
.NoTarget
then g_Console_Add('player hides in shadows') else g_Console_Add('player is brave again');
6538 if cmd
= 'noreload' then
6540 plr
.NoReload
:= not plr
.NoReload
;
6541 if plr
.NoReload
then g_Console_Add('player is action hero now') else g_Console_Add('player is ordinary man now');
6545 if cmd
= 'speedy' then
6547 MAX_RUNVEL
:= 32-MAX_RUNVEL
;
6548 g_Console_Add('speed adjusted');
6552 if cmd
= 'jumpy' then
6554 VEL_JUMP
:= 30-VEL_JUMP
;
6555 g_Console_Add('jump height adjusted');
6559 if cmd
= 'automap' then
6561 gShowMap
:= not gShowMap
;
6562 if gShowMap
then g_Console_Add('player gains second sight') else g_Console_Add('player lost second sight');
6566 if cmd
= 'aimline' then
6568 gAimLine
:= not gAimLine
;
6569 if gAimLine
then g_Console_Add('player gains laser sight') else g_Console_Add('player lost laser sight');
6574 procedure GameCommands(P
: SSArray
);
6580 pl
: pTNetClient
= nil;
6589 cmd
:= LowerCase(P
[0]);
6591 if cmd
= 'pause' then
6593 if (g_ActiveWindow
= nil) then
6594 g_Game_Pause(not gPauseMain
);
6596 else if cmd
= 'endgame' then
6597 gExit
:= EXIT_SIMPLE
6598 else if cmd
= 'restart' then
6600 if gGameOn
or (gState
in [STATE_INTERSINGLE
, STATE_INTERCUSTOM
]) then
6602 if g_Game_IsClient
then
6604 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6609 g_Console_Add(_lc
[I_MSG_NOT_GAME
]);
6611 else if cmd
= 'kick' then
6613 if g_Game_IsServer
then
6615 if Length(P
) < 2 then
6617 g_Console_Add('kick <name>');
6622 g_Console_Add('kick <name>');
6626 if g_Game_IsNet
then
6627 pl
:= g_Net_Client_ByName(P
[1]);
6630 s
:= g_Net_ClientName_ByID(pl
^.ID
);
6631 g_Net_Host_Kick(pl
^.ID
, NET_DISC_KICK
);
6632 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
6633 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
6634 g_Net_Slist_ServerPlayerLeaves();
6635 end else if gPlayers
<> nil then
6636 for a
:= Low(gPlayers
) to High(gPlayers
) do
6637 if gPlayers
[a
] <> nil then
6638 if Copy(LowerCase(gPlayers
[a
].Name
), 1, Length(P
[1])) = LowerCase(P
[1]) then
6640 // Íå îòêëþ÷àòü îñíîâíûõ èãðîêîâ â ñèíãëå
6641 if not(gPlayers
[a
] is TBot
) and (gGameSettings
.GameType
= GT_SINGLE
) then
6643 gPlayers
[a
].Lives
:= 0;
6644 gPlayers
[a
].Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
6645 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [gPlayers
[a
].Name
]), True);
6646 g_Player_Remove(gPlayers
[a
].UID
);
6647 g_Net_Slist_ServerPlayerLeaves();
6648 // Åñëè íå ïåðåìåøàòü, ïðè äîáàâëåíèè íîâûõ áîòîâ ïîÿâÿòñÿ ñòàðûå
6652 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6654 else if cmd
= 'kick_id' then
6656 if g_Game_IsServer
and g_Game_IsNet
then
6658 if Length(P
) < 2 then
6660 g_Console_Add('kick_id <client ID>');
6665 g_Console_Add('kick_id <client ID>');
6669 a
:= StrToIntDef(P
[1], 0);
6670 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
6672 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
6674 s
:= g_Net_ClientName_ByID(NetClients
[a
].ID
);
6675 g_Net_Host_Kick(NetClients
[a
].ID
, NET_DISC_KICK
);
6676 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
6677 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
6678 g_Net_Slist_ServerPlayerLeaves();
6682 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6684 else if cmd
= 'kick_pid' then
6686 if g_Game_IsServer
and g_Game_IsNet
then
6688 if Length(P
) < 2 then
6690 g_Console_Add('kick_pid <player ID>');
6695 g_Console_Add('kick_pid <player ID>');
6699 a
:= StrToIntDef(P
[1], 0);
6700 pl
:= g_Net_Client_ByPlayer(a
);
6701 if (pl
<> nil) and pl
^.Used
and (pl
^.Peer
<> nil) then
6703 s
:= g_Net_ClientName_ByID(pl
^.ID
);
6704 g_Net_Host_Kick(pl
^.ID
, NET_DISC_KICK
);
6705 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
6706 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
6707 g_Net_Slist_ServerPlayerLeaves();
6710 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6712 else if cmd
= 'ban' then
6714 if g_Game_IsServer
and g_Game_IsNet
then
6716 if Length(P
) < 2 then
6718 g_Console_Add('ban <name>');
6723 g_Console_Add('ban <name>');
6727 pl
:= g_Net_Client_ByName(P
[1]);
6729 g_Net_Host_Ban(pl
, False)
6731 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
6733 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6735 else if cmd
= 'ban_id' then
6737 if g_Game_IsServer
and g_Game_IsNet
then
6739 if Length(P
) < 2 then
6741 g_Console_Add('ban_id <client ID>');
6746 g_Console_Add('ban_id <client ID>');
6750 a
:= StrToIntDef(P
[1], 0);
6751 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
6752 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
6753 g_Net_Host_Ban(pl
, False);
6755 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6757 else if cmd
= 'ban_pid' then
6759 if g_Game_IsServer
and g_Game_IsNet
then
6761 if Length(P
) < 2 then
6763 g_Console_Add('ban_pid <player ID>');
6768 g_Console_Add('ban_pid <player ID>');
6772 a
:= StrToIntDef(P
[1], 0);
6773 pl
:= g_Net_Client_ByPlayer(a
);
6774 if (pl
<> nil) and pl
^.Used
and (pl
^.Peer
<> nil) then
6775 g_Net_Host_Ban(pl
, False);
6777 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6779 else if cmd
= 'permban' then
6781 if g_Game_IsServer
and g_Game_IsNet
then
6783 if Length(P
) < 2 then
6785 g_Console_Add('permban <name>');
6790 g_Console_Add('permban <name>');
6794 pl
:= g_Net_Client_ByName(P
[1]);
6796 g_Net_Host_Ban(pl
, True)
6798 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
6800 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6802 else if cmd
= 'permban_id' then
6804 if g_Game_IsServer
and g_Game_IsNet
then
6806 if Length(P
) < 2 then
6808 g_Console_Add('permban_id <client ID>');
6813 g_Console_Add('permban_id <client ID>');
6817 a
:= StrToIntDef(P
[1], 0);
6818 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
6819 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
6820 g_Net_Host_Ban(@NetClients
[a
], True);
6822 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6824 else if cmd
= 'permban_pid' then
6826 if g_Game_IsServer
and g_Game_IsNet
then
6828 if Length(P
) < 2 then
6830 g_Console_Add('permban_pid <player ID>');
6835 g_Console_Add('permban_pid <player ID>');
6839 a
:= StrToIntDef(P
[1], 0);
6840 pl
:= g_Net_Client_ByPlayer(a
);
6841 if (pl
<> nil) and pl
^.Used
and (pl
^.Peer
<> nil) then
6842 g_Net_Host_Ban(pl
, True);
6844 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6846 else if cmd
= 'permban_ip' then
6848 if g_Game_IsServer
and g_Game_IsNet
then
6850 if Length(P
) < 2 then
6852 g_Console_Add('permban_ip <IP address>');
6857 g_Console_Add('permban_ip <IP address>');
6861 g_Net_BanAddress(P
[1]);
6862 g_Net_SaveBanList();
6863 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [P
[1]]));
6865 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6867 else if cmd
= 'unban' then
6869 if g_Game_IsServer
and g_Game_IsNet
then
6871 if Length(P
) < 2 then
6873 g_Console_Add('unban <IP Address>');
6878 g_Console_Add('unban <IP Address>');
6882 if g_Net_UnbanAddress(P
[1]) then
6884 g_Console_Add(Format(_lc
[I_MSG_UNBAN_OK
], [P
[1]]));
6885 g_Net_SaveBanList();
6887 g_Console_Add(Format(_lc
[I_MSG_UNBAN_FAIL
], [P
[1]]));
6889 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6891 else if cmd
= 'clientlist' then
6893 if g_Game_IsServer
and g_Game_IsNet
then
6896 if NetClients
<> nil then
6897 for a
:= Low(NetClients
) to High(NetClients
) do
6898 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
6900 plr
:= g_Player_Get(NetClients
[a
].Player
);
6901 if plr
= nil then continue
;
6903 g_Console_Add(Format('#%2d: %-15s | %s', [a
,
6904 IpToStr(NetClients
[a
].Peer
^.address
.host
), plr
.Name
]));
6907 g_Console_Add(_lc
[I_MSG_NOCLIENTS
]);
6909 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6911 else if cmd
= 'connect' then
6913 if (NetMode
= NET_NONE
) then
6915 if Length(P
) < 2 then
6917 g_Console_Add('connect <IP> [port] [password]');
6922 g_Console_Add('connect <IP> [port] [password]');
6926 if Length(P
) > 2 then
6927 prt
:= StrToIntDef(P
[2], 25666)
6931 if Length(P
) > 3 then
6936 g_Game_StartClient(P
[1], prt
, pw
);
6939 else if cmd
= 'disconnect' then
6941 if (NetMode
= NET_CLIENT
) then
6944 else if cmd
= 'reconnect' then
6946 if (NetMode
= NET_SERVER
) then
6949 if (NetMode
= NET_CLIENT
) then
6952 gExit
:= EXIT_SIMPLE
;
6956 //TODO: Use last successful password to reconnect, instead of ''
6957 g_Game_StartClient(NetClientIP
, NetClientPort
, '');
6959 else if (cmd
= 'addbot') or
6960 (cmd
= 'bot_add') then
6963 1: g_Bot_Add(TEAM_NONE
, 2);
6964 2: g_Bot_Add(TEAM_NONE
, StrToIntDef(P
[1], 2));
6966 g_Bot_Add(TEAM_NONE
, StrToIntDef(P
[1], 2), StrToIntDef(P
[2], 100));
6969 else if cmd
= 'bot_addlist' then
6972 1: g_Bot_AddList(TEAM_NONE
, '');
6973 2: g_Bot_AddList(TEAM_NONE
, P
[1], StrToIntDef(P
[1], -1));
6975 if P
[2] = 'red' then
6977 else if P
[2] = 'blue' then
6983 then g_Bot_AddList(t
, P
[1], StrToIntDef(P
[1], -1))
6984 else g_Bot_AddList(t
, P
[1], StrToIntDef(P
[1], -1), StrToIntDef(P
[3], 100));
6987 else if cmd
= 'bot_removeall' then
6989 else if cmd
= 'chat' then
6991 if g_Game_IsNet
then
6993 if Length(P
) > 1 then
6995 for a
:= 1 to High(P
) do
6996 chstr
:= chstr
+ P
[a
] + ' ';
6998 if Length(chstr
) > 200 then SetLength(chstr
, 200);
7000 if Length(chstr
) < 1 then
7002 g_Console_Add('chat <text>');
7006 chstr
:= b_Text_Format(chstr
);
7007 if g_Game_IsClient
then
7008 MC_SEND_Chat(chstr
, NET_CHAT_PLAYER
)
7010 MH_SEND_Chat(gPlayer1Settings
.Name
+ ': ' + chstr
, NET_CHAT_PLAYER
);
7013 g_Console_Add('chat <text>');
7015 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
7017 else if cmd
= 'teamchat' then
7019 if g_Game_IsNet
and (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
7021 if Length(P
) > 1 then
7023 for a
:= 1 to High(P
) do
7024 chstr
:= chstr
+ P
[a
] + ' ';
7026 if Length(chstr
) > 200 then SetLength(chstr
, 200);
7028 if Length(chstr
) < 1 then
7030 g_Console_Add('teamchat <text>');
7034 chstr
:= b_Text_Format(chstr
);
7035 if g_Game_IsClient
then
7036 MC_SEND_Chat(chstr
, NET_CHAT_TEAM
)
7038 MH_SEND_Chat(gPlayer1Settings
.Name
+ ': ' + chstr
, NET_CHAT_TEAM
,
7039 gPlayer1Settings
.Team
);
7042 g_Console_Add('teamchat <text>');
7044 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
7046 else if (cmd
= 'an') or (cmd
= 'announce') then
7048 if g_Game_IsNet
then
7050 if Length(P
) > 1 then
7052 for a
:= 1 to High(P
) do
7053 chstr
:= chstr
+ P
[a
] + ' ';
7055 if Length(chstr
) > 200 then SetLength(chstr
, 200);
7057 if Length(chstr
) < 1 then
7059 g_Console_Add('announce <text>');
7063 chstr
:= 'centerprint 100 ' + b_Text_Format(chstr
);
7064 if g_Game_IsClient
then
7065 MC_SEND_RCONCommand(chstr
)
7067 g_Console_Process(chstr
, True);
7070 g_Console_Add('announce <text>');
7072 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
7074 else if cmd
= 'game' then
7076 if gGameSettings
.GameType
<> GT_NONE
then
7078 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
7081 if Length(P
) = 1 then
7083 g_Console_Add(cmd
+ ' <WAD> [MAP] [# players]');
7086 // game not started yet, load fist map from some wad
7088 s
:= addWadExtension(P
[1]);
7089 found
:= e_FindResource(AllMapDirs
, s
);
7093 P
[1] := ExpandFileName(P
[1]);
7094 // if map not choosed then set first map
7095 if Length(P
) < 3 then
7098 P
[2] := g_Game_GetFirstMap(P
[1]);
7101 s
:= P
[1] + ':\' + UpperCase(P
[2]);
7103 if g_Map_Exist(s
) then
7107 with gGameSettings
do
7109 Options
:= gsGameFlags
;
7110 GameMode
:= g_Game_TextToMode(gsGameMode
);
7111 if gSwitchGameMode
<> GM_NONE
then
7112 GameMode
:= gSwitchGameMode
;
7113 if GameMode
= GM_NONE
then GameMode
:= GM_DM
;
7114 if GameMode
= GM_SINGLE
then GameMode
:= GM_COOP
;
7116 if Length(P
) >= 4 then
7117 b
:= StrToIntDef(P
[3], 1);
7118 g_Game_StartCustom(s
, GameMode
, TimeLimit
,
7119 ScoreLimit
, MaxLives
, Options
, b
);
7124 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
7126 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [UpperCase(P
[2]), P
[1]]));
7128 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]));
7130 else if cmd
= 'host' then
7132 if gGameSettings
.GameType
<> GT_NONE
then
7134 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
7137 if Length(P
) < 4 then
7139 g_Console_Add(cmd
+ ' <listen IP> <port> <WAD> [MAP] [# players]');
7142 if not StrToIp(P
[1], listen
) then
7144 prt
:= StrToIntDef(P
[2], 25666);
7146 s
:= addWadExtension(P
[3]);
7147 found
:= e_FindResource(AllMapDirs
, s
);
7151 // get first map in wad, if not specified
7152 if Length(P
) < 5 then
7155 P
[4] := g_Game_GetFirstMap(P
[1]);
7157 s
:= P
[3] + ':\' + UpperCase(P
[4]);
7158 if g_Map_Exist(s
) then
7162 with gGameSettings
do
7164 Options
:= gsGameFlags
;
7165 GameMode
:= g_Game_TextToMode(gsGameMode
);
7166 if gSwitchGameMode
<> GM_NONE
then GameMode
:= gSwitchGameMode
;
7167 if GameMode
= GM_NONE
then GameMode
:= GM_DM
;
7168 if GameMode
= GM_SINGLE
then GameMode
:= GM_COOP
;
7170 if Length(P
) >= 6 then
7171 b
:= StrToIntDef(P
[5], 0);
7172 g_Game_StartServer(s
, GameMode
, TimeLimit
, ScoreLimit
, MaxLives
, Options
, b
, listen
, prt
)
7178 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[3]]))
7180 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [UpperCase(P
[4]), P
[3]]))
7185 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[3]]))
7188 else if cmd
= 'map' then
7190 if Length(P
) = 1 then
7192 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
7194 g_Console_Add(cmd
+ ' <MAP>');
7195 g_Console_Add(cmd
+ ' <WAD> [MAP]')
7199 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
])
7202 else if not e_IsValidResourceName(P
[1]) then
7204 g_Console_Add('wad name must not be absolute or relative');
7208 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
7210 if Length(P
) < 3 then
7212 // first param is map or wad
7213 s
:= UpperCase(P
[1]);
7214 if g_Map_Exist(gGameSettings
.WAD
+ ':\' + s
) then
7216 gExitByTrigger
:= False;
7219 // already in game, finish current map
7221 gExit
:= EXIT_ENDLEVELCUSTOM
;
7225 // intermission, so change map immediately
7232 found
:= e_FindResource(AllMapDirs
, s
);
7234 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [s
, 'WAD ' + P
[1]]));
7237 // no such map, found wad
7240 P
[1] := ExpandFileName(pw
);
7241 P
[2] := g_Game_GetFirstMap(P
[1]);
7242 s
:= P
[1] + ':\' + P
[2];
7243 if g_Map_Exist(s
) then
7245 gExitByTrigger
:= False;
7248 // already in game, finish current map
7250 gExit
:= EXIT_ENDLEVELCUSTOM
7254 // intermission, so change map immediately
7261 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
7263 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]))
7268 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]))
7274 s
:= addWadExtension(P
[1]);
7275 found
:= e_FindResource(AllMapDirs
, s
);
7279 P
[2] := UpperCase(P
[2]);
7280 s
:= P
[1] + ':\' + P
[2];
7281 if g_Map_Exist(s
) then
7283 gExitByTrigger
:= False;
7287 gExit
:= EXIT_ENDLEVELCUSTOM
7296 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]))
7301 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]))
7307 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
])
7311 else if cmd
= 'nextmap' then
7313 if not(gGameOn
or (gState
= STATE_INTERCUSTOM
)) then
7315 g_Console_Add(_lc
[I_MSG_NOT_GAME
])
7320 if Length(P
) = 1 then
7322 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
7324 g_Console_Add(cmd
+ ' <MAP>');
7325 g_Console_Add(cmd
+ ' <WAD> [MAP]');
7330 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
7333 else if not e_IsValidResourceName(P
[1]) then
7335 g_Console_Add('wad name must not be absolute or relative');
7340 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
7342 if Length(P
) < 3 then
7344 // first param is map or wad
7345 s
:= UpperCase(P
[1]);
7346 if g_Map_Exist(gGameSettings
.WAD
+ ':\' + s
) then
7349 gExitByTrigger
:= False;
7355 // no such map, found wad
7356 pw
:= addWadExtension(P
[1]);
7357 found
:= e_FindResource(MapDirs
, pw
);
7359 found
:= e_FindResource(WadDirs
, pw
);
7361 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [s
, P
[1]]));
7364 // map not specified, select first map
7366 P
[2] := g_Game_GetFirstMap(P
[1]);
7367 s
:= P
[1] + ':\' + P
[2];
7368 if g_Map_Exist(s
) then
7370 gExitByTrigger
:= False;
7377 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
7379 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]))
7384 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]))
7390 // specified two params wad + map
7391 pw
:= addWadExtension(P
[1]);
7392 found
:= e_FindResource(MapDirs
, pw
);
7394 found
:= e_FindResource(MapDirs
, pw
);
7398 P
[2] := UpperCase(P
[2]);
7399 s
:= P
[1] + ':\' + P
[2];
7400 if g_Map_Exist(s
) then
7402 gExitByTrigger
:= False;
7408 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]))
7413 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]))
7419 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
])
7424 if gNextMap
= '' then
7425 g_Console_Add(_lc
[I_MSG_NEXTMAP_UNSET
])
7427 g_Console_Add(Format(_lc
[I_MSG_NEXTMAP_SET
], [gNextMap
]))
7431 else if (cmd
= 'endmap') or (cmd
= 'goodbye') then
7435 g_Console_Add(_lc
[I_MSG_NOT_GAME
])
7439 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
7441 gExitByTrigger
:= False;
7442 // next map not specified, try to find trigger EXIT
7443 if (gNextMap
= '') and (gTriggers
<> nil) then
7445 for a
:= 0 to High(gTriggers
) do
7447 if gTriggers
[a
].TriggerType
= TRIGGER_EXIT
then
7449 gExitByTrigger
:= True;
7450 //gNextMap := gTriggers[a].Data.MapName;
7451 gNextMap
:= gTriggers
[a
].tgcMap
;
7456 if gNextMap
= '' then
7457 gNextMap
:= g_Game_GetNextMap();
7458 if not isWadPath(gNextMap
) then
7459 s
:= gGameSettings
.WAD
+ ':\' + gNextMap
7462 if g_Map_Exist(s
) then
7463 gExit
:= EXIT_ENDLEVELCUSTOM
7465 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [gNextMap
]))
7469 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
])
7473 else if (cmd
= 'event') then
7475 if (Length(P
) <= 1) then
7477 for a
:= 0 to High(gEvents
) do
7478 if gEvents
[a
].Command
= '' then
7479 g_Console_Add(gEvents
[a
].Name
+ ' <none>')
7481 g_Console_Add(gEvents
[a
].Name
+ ' "' + gEvents
[a
].Command
+ '"');
7484 if (Length(P
) = 2) then
7486 for a
:= 0 to High(gEvents
) do
7487 if gEvents
[a
].Name
= P
[1] then
7488 if gEvents
[a
].Command
= '' then
7489 g_Console_Add(gEvents
[a
].Name
+ ' <none>')
7491 g_Console_Add(gEvents
[a
].Name
+ ' "' + gEvents
[a
].Command
+ '"');
7494 for a
:= 0 to High(gEvents
) do
7495 if gEvents
[a
].Name
= P
[1] then
7497 gEvents
[a
].Command
:= '';
7498 for b
:= 2 to High(P
) do
7499 if Pos(' ', P
[b
]) = 0 then
7500 gEvents
[a
].Command
:= gEvents
[a
].Command
+ ' ' + P
[b
]
7502 gEvents
[a
].Command
:= gEvents
[a
].Command
+ ' "' + P
[b
] + '"';
7503 gEvents
[a
].Command
:= Trim(gEvents
[a
].Command
);
7507 else if cmd
= 'suicide' then
7511 if g_Game_IsClient
then
7512 MC_SEND_CheatRequest(NET_CHEAT_SUICIDE
)
7515 if gPlayer1
<> nil then
7516 gPlayer1
.Damage(SUICIDE_DAMAGE
, gPlayer1
.UID
, 0, 0, HIT_SELF
);
7517 if gPlayer2
<> nil then
7518 gPlayer2
.Damage(SUICIDE_DAMAGE
, gPlayer2
.UID
, 0, 0, HIT_SELF
);
7522 else if cmd
= 'screenshot' then
7526 else if (cmd
= 'weapnext') or (cmd
= 'weapprev') then
7528 a
:= 1 - (ord(cmd
[5]) - ord('n'));
7530 gWeaponAction
[0, WP_PREV
] := True;
7532 gWeaponAction
[0, WP_NEXT
] := True;
7534 else if cmd
= 'weapon' then
7536 if Length(p
) = 2 then
7538 a
:= WP_FIRST
+ StrToIntDef(p
[1], 0) - 1;
7539 if (a
>= WP_FIRST
) and (a
<= WP_LAST
) then
7540 gSelectWeapon
[0, a
] := True
7543 else if (cmd
= 'p1_weapnext') or (cmd
= 'p1_weapprev')
7544 or (cmd
= 'p2_weapnext') or (cmd
= 'p2_weapprev') then
7546 a
:= 1 - (ord(cmd
[8]) - ord('n'));
7547 b
:= ord(cmd
[2]) - ord('1');
7549 gWeaponAction
[b
, WP_PREV
] := True;
7551 gWeaponAction
[b
, WP_NEXT
] := True;
7553 else if (cmd
= 'p1_weapon') or (cmd
= 'p2_weapon') then
7555 if Length(p
) = 2 then
7557 a
:= WP_FIRST
+ StrToIntDef(p
[1], 0) - 1;
7558 b
:= ord(cmd
[2]) - ord('1');
7559 if (a
>= WP_FIRST
) and (a
<= WP_LAST
) then
7560 gSelectWeapon
[b
, a
] := True
7563 else if (cmd
= 'p1_weapbest') or (cmd
= 'p2_weapbest') then
7565 b
:= ord(cmd
[2]) - ord('1');
7567 gSelectWeapon
[b
, gPlayer1
.GetMorePrefered()] := True
7569 gSelectWeapon
[b
, gPlayer2
.GetMorePrefered()] := True;
7571 else if (cmd
= 'dropflag') then
7573 if g_Game_IsServer
then
7575 if gPlayer2
<> nil then gPlayer2
.TryDropFlag();
7576 if gPlayer1
<> nil then gPlayer1
.TryDropFlag();
7579 MC_SEND_CheatRequest(NET_CHEAT_DROPFLAG
);
7581 else if (cmd
= 'p1_dropflag') or (cmd
= 'p2_dropflag') then
7583 b
:= ord(cmd
[2]) - ord('1');
7584 if g_Game_IsServer
then
7586 if (b
= 1) and (gPlayer2
<> nil) then gPlayer2
.TryDropFlag()
7587 else if (b
= 0) and (gPlayer1
<> nil) then gPlayer1
.TryDropFlag();
7590 MC_SEND_CheatRequest(NET_CHEAT_DROPFLAG
);
7592 // Êîìàíäû Ñâîåé èãðû:
7593 else if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
7595 if cmd
= 'bot_addred' then
7597 if Length(P
) > 1 then
7598 g_Bot_Add(TEAM_RED
, StrToIntDef(P
[1], 2))
7600 g_Bot_Add(TEAM_RED
, 2);
7602 else if cmd
= 'bot_addblue' then
7604 if Length(P
) > 1 then
7605 g_Bot_Add(TEAM_BLUE
, StrToIntDef(P
[1], 2))
7607 g_Bot_Add(TEAM_BLUE
, 2);
7609 else if cmd
= 'spectate' then
7615 else if cmd
= 'say' then
7617 if g_Game_IsServer
and g_Game_IsNet
then
7619 if Length(P
) > 1 then
7622 for a
:= 1 to High(P
) do
7623 chstr
:= chstr
+ P
[a
] + ' ';
7625 if Length(chstr
) > 200 then SetLength(chstr
, 200);
7627 if Length(chstr
) < 1 then
7629 g_Console_Add('say <text>');
7633 chstr
:= b_Text_Format(chstr
);
7634 MH_SEND_Chat(chstr
, NET_CHAT_PLAYER
);
7636 else g_Console_Add('say <text>');
7638 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
7640 else if cmd
= 'tell' then
7642 if g_Game_IsServer
and g_Game_IsNet
then
7644 if (Length(P
) > 2) and (P
[1] <> '') then
7647 for a
:= 2 to High(P
) do
7648 chstr
:= chstr
+ P
[a
] + ' ';
7650 if Length(chstr
) > 200 then SetLength(chstr
, 200);
7652 if Length(chstr
) < 1 then
7654 g_Console_Add('tell <playername> <text>');
7658 pl
:= g_Net_Client_ByName(P
[1]);
7660 MH_SEND_Chat(b_Text_Format(chstr
), NET_CHAT_PLAYER
, pl
^.ID
)
7662 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
7664 else g_Console_Add('tell <playername> <text>');
7666 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
7668 else if cmd
= 'centerprint' then
7670 if (Length(P
) > 2) and (P
[1] <> '') then
7673 for a
:= 2 to High(P
) do
7674 chstr
:= chstr
+ P
[a
] + ' ';
7676 if Length(chstr
) > 200 then SetLength(chstr
, 200);
7678 if Length(chstr
) < 1 then
7680 g_Console_Add('centerprint <timeout> <text>');
7684 a
:= StrToIntDef(P
[1], 100);
7685 chstr
:= b_Text_Format(chstr
);
7686 g_Game_Message(chstr
, a
);
7687 if g_Game_IsNet
and g_Game_IsServer
then
7688 MH_SEND_GameEvent(NET_EV_BIGTEXT
, a
, chstr
);
7690 else g_Console_Add('centerprint <timeout> <text>');
7692 else if (cmd
= 'overtime') and not g_Game_IsClient
then
7694 if (Length(P
) = 1) or (StrToIntDef(P
[1], -1) <= 0) then
7696 // Äîïîëíèòåëüíîå âðåìÿ:
7697 gGameSettings
.TimeLimit
:= (gTime
- gGameStartTime
) div 1000 + Word(StrToIntDef(P
[1], 0));
7699 g_Console_Add(Format(_lc
[I_MSG_TIME_LIMIT
],
7700 [gGameSettings
.TimeLimit
div 3600,
7701 (gGameSettings
.TimeLimit
div 60) mod 60,
7702 gGameSettings
.TimeLimit
mod 60]));
7703 if g_Game_IsNet
then MH_SEND_GameSettings
;
7705 else if (cmd
= 'rcon_password') and g_Game_IsClient
then
7707 if (Length(P
) <= 1) then
7708 g_Console_Add('rcon_password <password>')
7710 MC_SEND_RCONPassword(P
[1]);
7712 else if cmd
= 'rcon' then
7714 if g_Game_IsClient
then
7716 if Length(P
) > 1 then
7719 for a
:= 1 to High(P
) do
7720 chstr
:= chstr
+ P
[a
] + ' ';
7722 if Length(chstr
) > 200 then SetLength(chstr
, 200);
7724 if Length(chstr
) < 1 then
7726 g_Console_Add('rcon <command>');
7730 MC_SEND_RCONCommand(chstr
);
7732 else g_Console_Add('rcon <command>');
7735 else if cmd
= 'ready' then
7737 if g_Game_IsServer
and (gLMSRespawn
= LMS_RESPAWN_WARMUP
) then
7738 gLMSRespawnTime
:= gTime
+ 100;
7740 else if (cmd
= 'callvote') and g_Game_IsNet
then
7742 if Length(P
) > 1 then
7745 for a
:= 1 to High(P
) do begin
7746 if a
> 1 then chstr
:= chstr
+ ' ';
7747 chstr
:= chstr
+ P
[a
];
7750 if Length(chstr
) > 200 then SetLength(chstr
, 200);
7752 if Length(chstr
) < 1 then
7754 g_Console_Add('callvote <command>');
7758 if g_Game_IsClient
then
7759 MC_SEND_Vote(True, chstr
)
7761 g_Game_StartVote(chstr
, gPlayer1Settings
.Name
);
7762 g_Console_Process('vote', True);
7765 g_Console_Add('callvote <command>');
7767 else if (cmd
= 'vote') and g_Game_IsNet
then
7769 if g_Game_IsClient
then
7771 else if gVoteInProgress
then
7773 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
7774 a
:= Floor((NetClientCount
+1)/2.0) + 1
7776 a
:= Floor(NetClientCount
/2.0) + 1;
7781 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_REVOKED
], [gPlayer1Settings
.Name
, gVoteCount
, a
]), True);
7782 MH_SEND_VoteEvent(NET_VE_REVOKE
, gPlayer1Settings
.Name
, 'a', gVoteCount
, a
);
7788 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_VOTE
], [gPlayer1Settings
.Name
, gVoteCount
, a
]), True);
7789 MH_SEND_VoteEvent(NET_VE_VOTE
, gPlayer1Settings
.Name
, 'a', gVoteCount
, a
);
7797 procedure SystemCommands(P
: SSArray
);
7801 cmd
:= LowerCase(P
[0]);
7810 gRC_Width
:= Max(1, gRC_Width
);
7811 gRC_Height
:= Max(1, gRC_Height
);
7812 gBPP
:= Max(1, gBPP
);
7813 if sys_SetDisplayMode(gRC_Width
, gRC_Height
, gBPP
, gRC_FullScreen
, gRC_Maximized
) = True then
7814 e_LogWriteln('resolution changed')
7816 e_LogWriteln('resolution not changed');
7817 sys_EnableVSync(gVSync
);
7821 if Length(p
) = 2 then
7823 gMaxFPS
:= StrToIntDef(p
[1], gMaxFPS
);
7825 gFrameTime
:= 1000 div gMaxFPS
7829 e_LogWritefln('r_maxfps %d', [gMaxFPS
]);
7833 if Length(p
) = 2 then
7835 gAskLanguage
:= true;
7836 gLanguage
:= LANGUAGE_ENGLISH
;
7837 case LowerCase(p
[1]) of
7840 gAskLanguage
:= false;
7841 gLanguage
:= LANGUAGE_ENGLISH
;
7845 gAskLanguage
:= false;
7846 gLanguage
:= LANGUAGE_RUSSIAN
;
7850 gAskLanguage
:= true;
7851 gLanguage
:= LANGUAGE_ENGLISH
;
7854 g_Language_Set(gLanguage
);
7858 e_LogWritefln('usage: %s <English|Russian|Ask>', [cmd
]);
7864 procedure g_TakeScreenShot(Filename
: string = '');
7865 var s
: TStream
; t
: TDateTime
; dir
, date
, name
: String;
7867 if e_NoGraphics
then Exit
;
7869 dir
:= e_GetWriteableDir(ScreenshotDirs
);
7871 if Filename
= '' then
7874 DateTimeToString(date
, 'yyyy-mm-dd-hh-nn-ss', t
);
7875 Filename
:= 'screenshot-' + date
;
7878 name
:= e_CatPath(dir
, Filename
+ '.png');
7879 s
:= createDiskFile(name
);
7881 e_MakeScreenshot(s
, gWinSizeX
, gWinSizeY
);
7883 g_Console_Add(Format(_lc
[I_CONSOLE_SCREENSHOT
], [name
]))
7885 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_WRITE
], [name
]));
7890 g_Console_Add('oh shit, i can''t create screenshot!')
7894 procedure g_Game_InGameMenu(Show
: Boolean);
7896 if (g_ActiveWindow
= nil) and Show
then
7898 if gGameSettings
.GameType
= GT_SINGLE
then
7899 g_GUI_ShowWindow('GameSingleMenu')
7902 if g_Game_IsClient
then
7903 g_GUI_ShowWindow('GameClientMenu')
7905 if g_Game_IsNet
then
7906 g_GUI_ShowWindow('GameServerMenu')
7908 g_GUI_ShowWindow('GameCustomMenu');
7910 g_Sound_PlayEx('MENU_OPEN');
7912 // Ïàóçà ïðè ìåíþ òîëüêî â îäèíî÷íîé èãðå:
7913 if (not g_Game_IsNet
) then
7917 if (g_ActiveWindow
<> nil) and (not Show
) then
7919 // Ïàóçà ïðè ìåíþ òîëüêî â îäèíî÷íîé èãðå:
7920 if (not g_Game_IsNet
) then
7921 g_Game_Pause(False);
7925 procedure g_Game_Pause (Enable
: Boolean);
7929 if not gGameOn
then exit
;
7931 if not (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
]) then exit
;
7934 gPauseMain
:= Enable
;
7936 if (gPause
<> oldPause
) then g_Game_PauseAllSounds(gPause
);
7939 procedure g_Game_HolmesPause (Enable
: Boolean);
7943 if not gGameOn
then exit
;
7944 if not (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
]) then exit
;
7947 gPauseHolmes
:= Enable
;
7949 if (gPause
<> oldPause
) then g_Game_PauseAllSounds(gPause
);
7952 procedure g_Game_PauseAllSounds(Enable
: Boolean);
7957 if gTriggers
<> nil then
7958 for i
:= 0 to High(gTriggers
) do
7959 with gTriggers
[i
] do
7960 if (TriggerType
= TRIGGER_SOUND
) and
7962 Sound
.IsPlaying() then
7964 Sound
.Pause(Enable
);
7968 if gPlayers
<> nil then
7969 for i
:= 0 to High(gPlayers
) do
7970 if gPlayers
[i
] <> nil then
7971 gPlayers
[i
].PauseSounds(Enable
);
7974 if gMusic
<> nil then
7975 gMusic
.Pause(Enable
);
7978 procedure g_Game_StopAllSounds(all
: Boolean);
7982 if gTriggers
<> nil then
7983 for i
:= 0 to High(gTriggers
) do
7984 with gTriggers
[i
] do
7985 if (TriggerType
= TRIGGER_SOUND
) and
7989 if gMusic
<> nil then
7996 procedure g_Game_UpdateTriggerSounds
;
7999 if gTriggers
<> nil then
8000 for i
:= 0 to High(gTriggers
) do
8001 with gTriggers
[i
] do
8002 if (TriggerType
= TRIGGER_SOUND
) and (Sound
<> nil) and tgcLocal
and Sound
.IsPlaying() then
8003 Sound
.SetCoordsRect(X
, Y
, Width
, Height
, tgcVolume
/ 255.0)
8006 function g_Game_IsWatchedPlayer(UID
: Word): Boolean;
8009 if (gPlayer1
<> nil) and (gPlayer1
.UID
= UID
) then
8014 if (gPlayer2
<> nil) and (gPlayer2
.UID
= UID
) then
8019 if gSpectMode
<> SPECT_PLAYERS
then
8021 if gSpectPID1
= UID
then
8026 if gSpectViewTwo
and (gSpectPID2
= UID
) then
8033 function g_Game_IsWatchedTeam(Team
: Byte): Boolean;
8038 if (gPlayer1
<> nil) and (gPlayer1
.Team
= Team
) then
8043 if (gPlayer2
<> nil) and (gPlayer2
.Team
= Team
) then
8048 if gSpectMode
<> SPECT_PLAYERS
then
8050 Pl
:= g_Player_Get(gSpectPID1
);
8051 if (Pl
<> nil) and (Pl
.Team
= Team
) then
8056 if gSpectViewTwo
then
8058 Pl
:= g_Player_Get(gSpectPID2
);
8059 if (Pl
<> nil) and (Pl
.Team
= Team
) then
8067 procedure g_Game_Message(Msg
: string; Time
: Word);
8069 MessageLineLength
:= (gScreenWidth
- 204) div e_CharFont_GetMaxWidth(gMenuFont
);
8070 MessageText
:= b_Text_Wrap(b_Text_Format(Msg
), MessageLineLength
);
8071 MessageTime
:= Time
;
8074 procedure g_Game_ChatSound(Text: String; Taunt
: Boolean = True);
8076 punct
: Array[0..13] of String =
8077 ('.', ',', ':', ';', '!', '?', '(', ')', '''', '"', '/', '\', '*', '^');
8083 function IsPunctuation(S
: String): Boolean;
8088 if Length(S
) <> 1 then
8090 for i
:= Low(punct
) to High(punct
) do
8091 if S
= punct
[i
] then
8097 function FilterPunctuation(S
: String): String;
8101 for i
:= Low(punct
) to High(punct
) do
8102 S
:= StringReplace(S
, punct
[i
], ' ', [rfReplaceAll
]);
8108 if gUseChatSounds
and Taunt
and (gChatSounds
<> nil) and (Pos(': ', Text) > 0) then
8110 // remove player name
8111 Delete(Text, 1, Pos(': ', Text) + 2 - 1);
8112 // for FullWord check
8113 Text := toLowerCase1251(' ' + Text + ' ');
8114 fpText
:= FilterPunctuation(Text);
8116 for i
:= 0 to Length(gChatSounds
) - 1 do
8119 for j
:= 0 to Length(gChatSounds
[i
].Tags
) - 1 do
8121 if gChatSounds
[i
].FullWord
and (not IsPunctuation(gChatSounds
[i
].Tags
[j
])) then
8122 ok
:= Pos(' ' + gChatSounds
[i
].Tags
[j
] + ' ', fpText
) > 0
8124 ok
:= Pos(gChatSounds
[i
].Tags
[j
], Text) > 0;
8130 gChatSounds
[i
].Sound
.Play();
8136 g_Sound_PlayEx('SOUND_GAME_RADIO');
8139 procedure g_Game_Announce_GoodShot(SpawnerUID
: Word);
8148 if not g_Game_IsWatchedPlayer(SpawnerUID
) then
8152 if goodsnd
[a
].IsPlaying() then
8155 goodsnd
[Random(4)].Play();
8158 procedure g_Game_Announce_KillCombo(Param
: Integer);
8165 UID
:= Param
and $FFFF;
8170 Pl
:= g_Player_Get(UID
);
8179 g_Console_Add(Format(_lc
[I_PLAYER_KILL_2X
], [Name
]), True);
8183 g_Console_Add(Format(_lc
[I_PLAYER_KILL_3X
], [Name
]), True);
8187 g_Console_Add(Format(_lc
[I_PLAYER_KILL_4X
], [Name
]), True);
8191 g_Console_Add(Format(_lc
[I_PLAYER_KILL_MX
], [Name
]), True);
8199 if not g_Game_IsWatchedPlayer(UID
) then
8202 if (not g_Game_IsWatchedPlayer(UID
)) and (c
< 4) then
8206 if killsnd
[n
].IsPlaying() then
8211 procedure g_Game_Announce_BodyKill(SpawnerUID
: Word);
8219 if not g_Game_IsWatchedPlayer(SpawnerUID
) then
8223 if hahasnd
[a
].IsPlaying() then
8226 hahasnd
[Random(3)].Play();
8229 procedure g_Game_Effect_Bubbles (fX
, fY
: Integer; count
: Word; devX
, devY
: Byte; Silent
: Boolean);
8231 g_GFX_Bubbles(fX
, fY
, count
, devX
, devY
);
8232 if not Silent
then if Random(2) = 0
8233 then g_Sound_PlayExAt('SOUND_GAME_BUBBLE1', fX
, fY
)
8234 else g_Sound_PlayExAt('SOUND_GAME_BUBBLE2', fX
, fY
);
8237 procedure g_Game_StartVote(Command
, Initiator
: string);
8241 if not gVotesEnabled
then Exit
;
8242 if gGameSettings
.GameType
<> GT_SERVER
then Exit
;
8243 if gVoteInProgress
or gVotePassed
then
8245 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_INPROGRESS
], [gVoteCommand
]), True);
8246 MH_SEND_VoteEvent(NET_VE_INPROGRESS
, gVoteCommand
);
8249 gVoteInProgress
:= True;
8250 gVotePassed
:= False;
8251 gVoteTimer
:= gTime
+ gVoteTimeout
* 1000;
8254 gVoteCommand
:= Command
;
8256 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
8257 Need
:= Floor((NetClientCount
+1)/2.0)+1
8259 Need
:= Floor(NetClientCount
/2.0)+1;
8260 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_STARTED
], [Initiator
, Command
, Need
]), True);
8261 MH_SEND_VoteEvent(NET_VE_STARTED
, Initiator
, Command
, Need
);
8264 procedure g_Game_CheckVote
;
8268 if gGameSettings
.GameType
<> GT_SERVER
then Exit
;
8269 if not gVoteInProgress
then Exit
;
8271 if (gTime
>= gVoteTimer
) then
8273 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
8274 Need
:= Floor((NetClientCount
+1)/2.0) + 1
8276 Need
:= Floor(NetClientCount
/2.0) + 1;
8277 if gVoteCount
>= Need
then
8279 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_PASSED
], [gVoteCommand
]), True);
8280 MH_SEND_VoteEvent(NET_VE_PASSED
, gVoteCommand
);
8281 gVotePassed
:= True;
8282 gVoteCmdTimer
:= gTime
+ 5000;
8286 g_Console_Add(_lc
[I_MESSAGE_VOTE_FAILED
], True);
8287 MH_SEND_VoteEvent(NET_VE_FAILED
);
8289 if NetClients
<> nil then
8290 for I
:= Low(NetClients
) to High(NetClients
) do
8291 if NetClients
[i
].Used
then
8292 NetClients
[i
].Voted
:= False;
8293 gVoteInProgress
:= False;
8299 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
8300 Need
:= Floor((NetClientCount
+1)/2.0) + 1
8302 Need
:= Floor(NetClientCount
/2.0) + 1;
8303 if gVoteCount
>= Need
then
8305 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_PASSED
], [gVoteCommand
]), True);
8306 MH_SEND_VoteEvent(NET_VE_PASSED
, gVoteCommand
);
8307 gVoteInProgress
:= False;
8308 gVotePassed
:= True;
8309 gVoteCmdTimer
:= gTime
+ 5000;
8312 if NetClients
<> nil then
8313 for I
:= Low(NetClients
) to High(NetClients
) do
8314 if NetClients
[i
].Used
then
8315 NetClients
[i
].Voted
:= False;
8320 procedure g_Game_LoadMapList(FileName
: string);
8328 if not FileExists(FileName
) then Exit
;
8330 AssignFile(ListFile
, FileName
);
8332 while not EOF(ListFile
) do
8334 ReadLn(ListFile
, s
);
8337 if s
= '' then Continue
;
8339 SetLength(MapList
, Length(MapList
)+1);
8340 MapList
[High(MapList
)] := s
;
8342 CloseFile(ListFile
);
8345 procedure g_Game_SetDebugMode();
8348 // ×èòû (äàæå â ñâîåé èãðå):
8352 procedure g_Game_SetLoadingText(Text: String; Max
: Integer; reWrite
: Boolean);
8356 if Length(LoadingStat
.Msgs
) = 0 then
8362 begin // Ïåðåõîäèì íà ñëåäóþùóþ ñòðîêó èëè ñêðîëëèðóåì:
8363 if NextMsg
= Length(Msgs
) then
8365 for i
:= 0 to High(Msgs
)-1 do
8366 Msgs
[i
] := Msgs
[i
+1];
8374 Msgs
[NextMsg
-1] := Text;
8378 PBarWasHere
:= false;
8381 g_ActiveWindow
:= nil;
8382 ProcessLoading(True);
8385 procedure g_Game_StepLoading(Value
: Integer = -1);
8397 if (ShowCount
> LOADING_SHOW_STEP
) or (Value
> -1) then
8400 ProcessLoading(False);
8405 procedure g_Game_ClearLoading();
8414 len
:= ((gScreenHeight
div 3)*2 - 50) div LOADING_INTERLINE
;
8415 if len
< 1 then len
:= 1;
8416 SetLength(Msgs
, len
);
8417 for len
:= Low(Msgs
) to High(Msgs
) do
8420 PBarWasHere
:= false;
8424 procedure Parse_Params(var pars
: TParamStrValues
);
8431 while i
<= ParamCount
do
8434 if (Length(s
) > 1) and (s
[1] = '-') then
8436 if (Length(s
) > 2) and (s
[2] = '-') then
8437 begin // Îäèíî÷íûé ïàðàìåòð
8438 SetLength(pars
, Length(pars
) + 1);
8439 with pars
[High(pars
)] do
8441 Name
:= LowerCase(s
);
8446 if (i
< ParamCount
) then
8447 begin // Ïàðàìåòð ñî çíà÷åíèåì
8449 SetLength(pars
, Length(pars
) + 1);
8450 with pars
[High(pars
)] do
8452 Name
:= LowerCase(s
);
8453 Value
:= LowerCase(ParamStr(i
));
8462 function Find_Param_Value(var pars
: TParamStrValues
; aName
: String): String;
8467 for i
:= 0 to High(pars
) do
8468 if pars
[i
].Name
= aName
then
8470 Result
:= pars
[i
].Value
;
8475 procedure g_Game_Process_Params();
8477 pars
: TParamStrValues
;
8480 LimT
, LimS
: Integer;
8491 s
:= Find_Param_Value(pars
, '--debug');
8494 g_Game_SetDebugMode();
8495 s
:= Find_Param_Value(pars
, '--netdump');
8500 // Connect when game loads
8501 ip
:= Find_Param_Value(pars
, '-connect');
8505 s
:= Find_Param_Value(pars
, '-port');
8506 if (s
= '') or not TryStrToInt(s
, Port
) then
8509 s
:= Find_Param_Value(pars
, '-pw');
8511 g_Game_StartClient(ip
, Port
, s
);
8515 s
:= LowerCase(Find_Param_Value(pars
, '-dbg-mainwad'));
8518 gDefaultMegawadStart
:= s
;
8521 if (Find_Param_Value(pars
, '--dbg-mainwad-restore') <> '') or
8522 (Find_Param_Value(pars
, '--dbg-mainwad-default') <> '') then
8524 gDefaultMegawadStart
:= DF_Default_Megawad_Start
;
8527 // Start map when game loads:
8528 map
:= LowerCase(Find_Param_Value(pars
, '-map'));
8529 if isWadPath(map
) then
8532 s
:= Find_Param_Value(pars
, '-gm');
8533 GMode
:= g_Game_TextToMode(s
);
8534 if GMode
= GM_NONE
then GMode
:= GM_DM
;
8535 if GMode
= GM_SINGLE
then GMode
:= GM_COOP
;
8538 s
:= Find_Param_Value(pars
, '-limt');
8539 if (s
= '') or (not TryStrToInt(s
, LimT
)) then
8545 s
:= Find_Param_Value(pars
, '-lims');
8546 if (s
= '') or (not TryStrToInt(s
, LimS
)) then
8552 s
:= Find_Param_Value(pars
, '-lives');
8553 if (s
= '') or (not TryStrToInt(s
, Lives
)) then
8559 s
:= Find_Param_Value(pars
, '-opt');
8563 Opt
:= StrToIntDef(s
, 0);
8566 s
:= Find_Param_Value(pars
, '--close');
8570 // Override map to test:
8571 s
:= LowerCase(Find_Param_Value(pars
, '-testmap'));
8574 if e_IsValidResourceName(s
) then
8575 e_FindResource(AllMapDirs
, s
);
8576 gTestMap
:= ExpandFileName(s
);
8579 // Delete test map after play:
8580 s
:= Find_Param_Value(pars
, '--testdelete');
8583 //gMapToDelete := MapsDir + map;
8584 e_WriteLog('"--testdelete" is deprecated, use --tempdelete.', TMsgType
.Fatal
);
8588 // Delete temporary WAD after play:
8589 s
:= Find_Param_Value(pars
, '--tempdelete');
8590 if (s
<> '') and (gTestMap
<> '') then
8592 gMapToDelete
:= gTestMap
;
8593 gTempDelete
:= True;
8596 // Number of players:
8597 s
:= Find_Param_Value(pars
, '-pl');
8599 n
:= DEFAULT_PLAYERS
8601 n
:= StrToIntDef(s
, DEFAULT_PLAYERS
);
8604 s
:= Find_Param_Value(pars
, '-port');
8605 if (s
= '') or not TryStrToInt(s
, Port
) then
8606 g_Game_StartCustom(map
, GMode
, LimT
, LimS
, Lives
, Opt
, n
)
8608 g_Game_StartServer(map
, GMode
, LimT
, LimS
, Lives
, Opt
, n
, 0, Port
);
8611 // Execute script when game loads:
8612 s
:= Find_Param_Value(pars
, '-exec');
8615 // if not isWadPath(s) then
8616 // s := GameDir + '/' + s;
8621 if IOResult
<> 0 then
8623 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], ['Failed to read file: ' + s
]), TMsgType
.Warning
);
8624 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_READ
], [s
]));
8628 e_WriteLog('Executing script: ' + s
, TMsgType
.Notify
);
8629 g_Console_Add(Format(_lc
[I_CONSOLE_EXEC
], [s
]));
8634 if IOResult
<> 0 then
8636 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], ['Failed to read file: ' + s
]), TMsgType
.Warning
);
8637 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_READ
], [s
]));
8641 if Pos('#', s
) <> 1 then // script comment
8642 g_Console_Process(s
, True);
8653 conRegVar('pf_draw_frame', @g_profile_frame_draw
, 'draw frame rendering profiles', 'render profiles');
8654 //conRegVar('pf_update_frame', @g_profile_frame_update, 'draw frame updating profiles', 'update profiles');
8655 conRegVar('pf_coldet', @g_profile_collision
, 'draw collision detection profiles', 'coldet profiles');
8656 conRegVar('pf_los', @g_profile_los
, 'draw monster LOS profiles', 'monster LOS profiles');
8658 conRegVar('r_sq_draw', @gdbg_map_use_accel_render
, 'accelerated spatial queries in rendering', 'accelerated rendering');
8659 conRegVar('cd_sq_enabled', @gdbg_map_use_accel_coldet
, 'accelerated spatial queries in map coldet', 'accelerated map coldet');
8660 conRegVar('mon_sq_enabled', @gmon_debug_use_sqaccel
, 'accelerated spatial queries for monsters', 'accelerated monster coldet');
8661 conRegVar('wtrace_sq_enabled', @gwep_debug_fast_trace
, 'accelerated spatial queries for weapon hitscan trace', 'accelerated weapon hitscan');
8663 conRegVar('pr_enabled', @gpart_dbg_enabled
, 'enable/disable particles', 'particles');
8664 conRegVar('pr_phys_enabled', @gpart_dbg_phys_enabled
, 'enable/disable particle physics', 'particle physics');
8666 conRegVar('los_enabled', @gmon_dbg_los_enabled
, 'enable/disable monster LOS calculations', 'monster LOS', true);
8667 conRegVar('mon_think', @gmon_debug_think
, 'enable/disable monster thinking', 'monster thinking', true);
8669 {$IFDEF ENABLE_HOLMES}
8670 conRegVar('dbg_holmes', @g_holmes_enabled
, 'enable/disable Holmes', 'Holmes', true);
8673 conRegVar('dbg_ignore_level_bounds', @g_dbg_ignore_bounds
, 'ignore level bounds', '', false);
8675 conRegVar('r_scale', @g_dbg_scale
, 0.01, 100.0, 'render scale', '', false);
8676 conRegVar('r_resolution_scale', @r_pixel_scale
, 0.01, 100.0, 'upscale factor', '', false);
8678 conRegVar('light_enabled', @gwin_k8_enable_light_experiments
, 'enable/disable dynamic lighting', 'lighting');
8679 conRegVar('light_player_halo', @g_playerLight
, 'enable/disable player halo', 'player light halo');
8681 conRegVar('r_smallmap_align_h', @r_smallmap_h
, 'halign: 0: left; 1: center; 2: right', 'horizontal aligning of small maps');
8682 conRegVar('r_smallmap_align_v', @r_smallmap_v
, 'valign: 0: top; 1: center; 2: bottom', 'vertial aligning of small maps');
8684 conRegVar('r_showfps', @gShowFPS
, 'draw fps counter', 'draw fps counter');
8685 conRegVar('r_showtime', @gShowTime
, 'show game time', 'show game time');
8686 conRegVar('r_showping', @gShowPing
, 'show ping', 'show ping');
8687 conRegVar('r_showscore', @gShowScore
, 'show score', 'show score');
8688 conRegVar('r_showkillmsg', @gShowKillMsg
, 'show kill log', 'show kill log');
8689 conRegVar('r_showlives', @gShowLives
, 'show lives', 'show lives');
8690 conRegVar('r_showspect', @gSpectHUD
, 'show spectator hud', 'show spectator hud');
8691 conRegVar('r_showstat', @gShowStat
, 'show stats', 'show stats');
8692 conRegVar('r_showpids', @gShowPIDs
, 'show PIDs', 'show PIDs');