1 (* Copyright (C) Doom 2D: Forever Developers
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, version 3 of the License ONLY.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 {$INCLUDE ../shared/a_modes.inc}
23 g_basic
, g_player
, e_graphics
, g_res_downloader
,
24 g_sound
, g_gui
, utils
, md5
, mempool
, xprofiler
,
28 TGameSettings
= record
35 ItemRespawnTime
: Word;
46 TDelayedEvent
= record
55 Sound
: TPlayableSound
;
56 Tags
: Array of String;
60 TPlayerSettings
= record
65 // ones below are sent only to the server
67 WeaponPreferences
: Array[WP_FIRST
..WP_LAST
+1] of Byte;
84 function g_Game_IsNet(): Boolean;
85 function g_Game_IsServer(): Boolean;
86 function g_Game_IsClient(): Boolean;
87 procedure g_Game_Init();
88 procedure g_Game_Free (freeTextures
: Boolean=true);
89 procedure g_Game_LoadData();
90 procedure g_Game_FreeData();
91 procedure g_Game_Update();
92 procedure g_Game_PreUpdate();
93 procedure g_Game_Draw();
94 procedure g_Game_Quit();
95 procedure g_Game_SetupScreenSize();
96 procedure g_Game_ChangeResolution(newWidth
, newHeight
: Word; nowFull
, nowMax
: Boolean);
97 function g_Game_ModeToText(Mode
: Byte): string;
98 function g_Game_TextToMode(Mode
: string): Byte;
99 procedure g_Game_ExecuteEvent(Name
: String);
100 function g_Game_DelayEvent(DEType
: Byte; Time
: LongWord
; Num
: Integer = 0; Str
: String = ''): Integer;
101 procedure g_Game_AddPlayer(Team
: Byte = TEAM_NONE
);
102 procedure g_Game_RemovePlayer();
103 procedure g_Game_Spectate();
104 procedure g_Game_SpectateCenterView();
105 procedure g_Game_StartSingle(Map
: String; TwoPlayers
: Boolean; nPlayers
: Byte);
106 procedure g_Game_StartCustom(Map
: String; GameMode
: Byte; TimeLimit
, ScoreLimit
: Word; MaxLives
: Byte; Options
: LongWord
; nPlayers
: Byte);
107 procedure g_Game_StartServer(Map
: String; GameMode
: Byte; TimeLimit
, ScoreLimit
: Word; MaxLives
: Byte; Options
: LongWord
; nPlayers
: Byte; IPAddr
: LongWord
; Port
: Word);
108 procedure g_Game_StartClient(Addr
: String; Port
: Word; PW
: String);
109 procedure g_Game_Restart();
110 procedure g_Game_RestartLevel();
111 procedure g_Game_RestartRound(NoMapRestart
: Boolean = False);
112 function g_Game_ClientWAD (NewWAD
: String; const WHash
: TMD5Digest
): AnsiString
;
113 function g_Game_StartMap(asMegawad
: Boolean; Map
: String; Force
: Boolean = False; const oldMapPath
: AnsiString
=''): Boolean;
114 procedure g_Game_ChangeMap(const MapPath
: String);
115 procedure g_Game_ExitLevel(const Map
: AnsiString
);
116 function g_Game_GetFirstMap(WAD
: String): String;
117 function g_Game_GetNextMap(): String;
118 procedure g_Game_NextLevel();
119 procedure g_Game_Pause(Enable
: Boolean);
120 procedure g_Game_HolmesPause(Enable
: Boolean);
121 procedure g_Game_InGameMenu(Show
: Boolean);
122 function g_Game_IsWatchedPlayer(UID
: Word): Boolean;
123 function g_Game_IsWatchedTeam(Team
: Byte): Boolean;
124 procedure g_Game_Message(Msg
: String; Time
: Word);
125 procedure g_Game_LoadMapList(FileName
: String);
126 procedure g_Game_PauseAllSounds(Enable
: Boolean);
127 procedure g_Game_StopAllSounds(all
: Boolean);
128 procedure g_Game_UpdateTriggerSounds();
129 function g_Game_GetMegaWADInfo(WAD
: String): TMegaWADInfo
;
130 procedure g_Game_ChatSound(Text: String; Taunt
: Boolean = True);
131 procedure g_Game_Announce_GoodShot(SpawnerUID
: Word);
132 procedure g_Game_Announce_KillCombo(Param
: Integer);
133 procedure g_Game_Announce_BodyKill(SpawnerUID
: Word);
134 procedure g_Game_StartVote(Command
, Initiator
: string);
135 procedure g_Game_CheckVote
;
136 procedure g_TakeScreenShot(Filename
: string = '');
137 procedure g_FatalError(Text: String);
138 procedure g_SimpleError(Text: String);
139 function g_Game_IsTestMap(): Boolean;
140 procedure g_Game_DeleteTestMap();
141 procedure GameCVars(P
: SSArray
);
142 procedure PlayerSettingsCVars(P
: SSArray
);
143 procedure SystemCommands(P
: SSArray
);
144 procedure GameCommands(P
: SSArray
);
145 procedure GameCheats(P
: SSArray
);
146 procedure DebugCommands(P
: SSArray
);
147 procedure g_Game_Process_Params
;
148 procedure g_Game_SetLoadingText(Text: String; Max
: Integer; reWrite
: Boolean);
149 procedure g_Game_StepLoading(Value
: Integer = -1);
150 procedure g_Game_ClearLoading();
151 procedure g_Game_SetDebugMode();
152 procedure DrawLoadingStat();
153 procedure DrawMenuBackground(tex
: AnsiString
);
155 { procedure SetWinPause(Enable: Boolean); }
160 LOADING_SHOW_STEP
= 100;
161 LOADING_INTERLINE
= 20;
176 MESSAGE_DIKEY
= WM_USER
+ 1;
181 EXIT_ENDLEVELSINGLE
= 4;
182 EXIT_ENDLEVELCUSTOM
= 5;
184 GAME_OPTION_RESERVED
= 1;
185 GAME_OPTION_TEAMDAMAGE
= 2;
186 GAME_OPTION_ALLOWEXIT
= 4;
187 GAME_OPTION_WEAPONSTAY
= 8;
188 GAME_OPTION_MONSTERS
= 16;
189 GAME_OPTION_BOTVSPLAYER
= 32;
190 GAME_OPTION_BOTVSMONSTER
= 64;
191 GAME_OPTION_DMKEYS
= 128;
192 GAME_OPTION_TEAMHITTRACE
= 256;
193 GAME_OPTION_TEAMHITPROJECTILE
= 512;
194 GAME_OPTION_TEAMABSORBDAMAGE
= 1024;
195 GAME_OPTION_ALLOWDROPFLAG
= 2048;
196 GAME_OPTION_THROWFLAG
= 4096;
201 STATE_INTERCUSTOM
= 3;
202 STATE_INTERSINGLE
= 4;
208 LMS_RESPAWN_NONE
= 0;
209 LMS_RESPAWN_WARMUP
= 1;
210 LMS_RESPAWN_FINAL
= 2;
227 CONFIG_FILENAME
= 'Doom2DF.cfg';
229 TEST_MAP_NAME
= '$$$_TEST_$$$';
231 STD_PLAYER_MODEL
= 'Doomer';
239 STATFILE_VERSION
= $03;
243 gGameSettings
: TGameSettings
;
244 gPlayer1Settings
: TPlayerSettings
;
245 gPlayer2Settings
: TPlayerSettings
;
247 gPlayerScreenSize
: TDFPoint
;
248 gPlayer1ScreenCoord
: TDFPoint
;
249 gPlayer2ScreenCoord
: TDFPoint
;
250 gPlayer1
: TPlayer
= nil;
251 gPlayer2
: TPlayer
= nil;
252 gPlayerDrawn
: TPlayer
= nil;
254 gLerpFactor
: Single = 1.0;
255 gSwitchGameMode
: Byte = GM_DM
;
256 gHearPoint1
, gHearPoint2
: THearPoint
;
257 gSoundEffectsDF
: Boolean = False;
258 gSoundTriggerTime
: Word = 0;
259 gAnnouncer
: Integer = ANNOUNCE_NONE
;
260 goodsnd
: array[0..3] of TPlayableSound
;
261 killsnd
: array[0..3] of TPlayableSound
;
262 hahasnd
: array[0..2] of TPlayableSound
;
263 sound_get_flag
: array[0..1] of TPlayableSound
;
264 sound_lost_flag
: array[0..1] of TPlayableSound
;
265 sound_ret_flag
: array[0..1] of TPlayableSound
;
266 sound_cap_flag
: array[0..1] of TPlayableSound
;
267 gBodyKillEvent
: Integer = -1;
268 gDefInterTime
: ShortInt
= -1;
269 gInterEndTime
: LongWord
= 0;
270 gInterTime
: LongWord
= 0;
271 gServInterTime
: Byte = 0;
272 gGameStartTime
: LongWord
= 0;
273 gTotalMonsters
: Integer = 0;
274 gPauseMain
: Boolean = false;
275 gPauseHolmes
: Boolean = false;
276 gShowTime
: Boolean = False;
277 gShowFPS
: Boolean = False;
278 gShowScore
: Boolean = True;
279 gShowStat
: Boolean = True;
280 gShowPIDs
: Boolean = False;
281 gShowKillMsg
: Boolean = True;
282 gShowLives
: Boolean = True;
283 gShowPing
: Boolean = False;
284 gShowMap
: Boolean = False;
286 gState
: Byte = STATE_NONE
;
288 sWidth
, sHeight
: Word;
289 gSpectMode
: Byte = SPECT_NONE
;
290 gSpectHUD
: Boolean = True;
291 gSpectKeyPress
: Boolean = False;
292 gSpectX
: Integer = 0;
293 gSpectY
: Integer = 0;
294 gSpectStep
: Byte = 8;
295 gSpectViewTwo
: Boolean = False;
296 gSpectPID1
: Integer = -1;
297 gSpectPID2
: Integer = -1;
298 gSpectAuto
: Boolean = False;
299 gSpectAutoNext
: LongWord
;
300 gSpectAutoStepX
: Integer;
301 gSpectAutoStepY
: Integer;
302 gMusic
: TMusic
= nil;
303 gLoadGameMode
: Boolean;
304 gCheats
: Boolean = False;
305 gMapOnce
: Boolean = False;
306 gMapToDelete
: String;
307 gTempDelete
: Boolean = False;
308 gLastMap
: Boolean = False;
311 gResolutionChange
: Boolean = False;
312 gRC_Width
, gRC_Height
: Integer;
313 gRC_FullScreen
, gRC_Maximized
: Boolean;
314 gLanguageChange
: Boolean = False;
315 gDebugMode
: Boolean = False;
316 g_debug_Sounds
: Boolean = False;
317 g_debug_Frames
: Boolean = False;
318 g_debug_WinMsgs
: Boolean = False;
319 g_debug_MonsterOff
: Boolean = False;
320 g_debug_BotAIOff
: Byte = 0;
321 g_debug_HealthBar
: Boolean = False;
322 g_Debug_Player
: Boolean = False;
323 gCoopMonstersKilled
: Word = 0;
324 gCoopSecretsFound
: Word = 0;
325 gCoopTotalMonstersKilled
: Word = 0;
326 gCoopTotalSecretsFound
: Word = 0;
327 gCoopTotalMonsters
: Word = 0;
328 gCoopTotalSecrets
: Word = 0;
329 gStatsOff
: Boolean = False;
330 gStatsPressed
: Boolean = False;
331 gExitByTrigger
: Boolean = False;
332 gNextMap
: String = '';
333 gLMSRespawn
: Byte = LMS_RESPAWN_NONE
;
334 gLMSRespawnTime
: Cardinal = 0;
335 gLMSSoftSpawn
: Boolean = False;
336 gMissionFailed
: Boolean = False;
337 gVoteInProgress
: Boolean = False;
338 gVotePassed
: Boolean = False;
339 gVoteCommand
: string = '';
340 gVoteTimer
: Cardinal = 0;
341 gVoteCmdTimer
: Cardinal = 0;
342 gVoteCount
: Integer = 0;
343 gVoteTimeout
: Cardinal = 30;
344 gVoted
: Boolean = False;
345 gVotesEnabled
: Boolean = True;
346 gEvents
: Array of TGameEvent
;
347 gDelayedEvents
: Array of TDelayedEvent
;
348 gUseChatSounds
: Boolean = True;
349 gChatSounds
: Array of TChatSound
;
350 gWeaponAction
: Array [0..1, WP_FACT
..WP_LACT
] of Boolean; // [player, weapon_action]
351 gSelectWeapon
: Array [0..1, WP_FIRST
..WP_LAST
] of Boolean; // [player, weapon]
352 gInterReadyCount
: Integer = 0;
353 gMaxBots
: Integer = 127;
355 g_dbg_ignore_bounds
: Boolean = false;
356 r_smallmap_h
: Integer = 0; // 0: left; 1: center; 2: right
357 r_smallmap_v
: Integer = 2; // 0: top; 1: center; 2: bottom
359 // move button values:
360 // bits 0-1: l/r state:
361 // 0: neither left, nor right pressed
364 // bits 4-5: l/r state when strafe was pressed
365 P1MoveButton
: Byte = 0;
366 P2MoveButton
: Byte = 0;
368 g_profile_frame_update
: Boolean = false;
369 g_profile_frame_draw
: Boolean = false;
370 g_profile_collision
: Boolean = false;
371 g_profile_los
: Boolean = false;
372 g_profile_history_size
: Integer = 1000;
374 g_rlayer_back
: Boolean = true;
375 g_rlayer_step
: Boolean = true;
376 g_rlayer_wall
: Boolean = true;
377 g_rlayer_door
: Boolean = true;
378 g_rlayer_acid1
: Boolean = true;
379 g_rlayer_acid2
: Boolean = true;
380 g_rlayer_water
: Boolean = true;
381 g_rlayer_fore
: Boolean = true;
384 procedure g_ResetDynlights ();
385 procedure g_AddDynLight (x
, y
, radius
: Integer; r
, g
, b
, a
: Single);
386 procedure g_DynLightExplosion (x
, y
, radius
: Integer; r
, g
, b
: Single);
388 function conIsCheatsEnabled (): Boolean; inline;
389 function gPause (): Boolean; inline;
395 {$INCLUDE ../nogl/noGLuses.inc}
396 {$IFDEF ENABLE_HOLMES}
399 e_texture
, e_res
, g_textures
, g_window
, g_menu
,
400 e_input
, e_log
, g_console
, g_items
, g_map
, g_panel
,
401 g_playermodel
, g_gfx
, g_options
, Math
,
402 g_triggers
, g_monsters
, e_sound
, CONFIG
,
403 g_language
, g_net
, g_main
, g_phys
,
404 ENet
, e_msg
, g_netmsg
, g_netmaster
,
405 sfs
, wadreader
, g_system
;
409 hasPBarGfx
: Boolean = false;
412 // ////////////////////////////////////////////////////////////////////////// //
413 function gPause (): Boolean; inline; begin result
:= gPauseMain
or gPauseHolmes
; end;
416 // ////////////////////////////////////////////////////////////////////////// //
417 function conIsCheatsEnabled (): Boolean; inline;
420 if g_Game_IsNet
then exit
;
421 if not gDebugMode
then
423 //if not gCheats then exit;
424 if not (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
]) then exit
;
425 if not (gGameSettings
.GameMode
in [GM_COOP
, GM_SINGLE
]) then exit
;
431 // ////////////////////////////////////////////////////////////////////////// //
433 profileFrameDraw
: TProfiler
= nil;
436 // ////////////////////////////////////////////////////////////////////////// //
439 x
, y
, radius
: Integer;
442 exploRadius
: Integer;
446 g_dynLights
: array of TDynLight
= nil;
447 g_dynLightCount
: Integer = 0;
448 g_playerLight
: Boolean = false;
450 procedure g_ResetDynlights ();
454 if not gwin_has_stencil
then begin g_dynLightCount
:= 0; exit
; end;
456 for idx
:= 0 to g_dynLightCount
-1 do
458 if g_dynLights
[idx
].exploCount
= -666 then
465 Inc(g_dynLights
[idx
].exploCount
);
466 if (g_dynLights
[idx
].exploCount
< 10) then
468 g_dynLights
[idx
].radius
:= g_dynLights
[idx
].exploRadius
+g_dynLights
[idx
].exploCount
*8;
469 g_dynLights
[idx
].a
:= 0.4+g_dynLights
[idx
].exploCount
/10;
470 if (g_dynLights
[idx
].a
> 0.8) then g_dynLights
[idx
].a
:= 0.8;
471 if lnum
<> idx
then g_dynLights
[lnum
] := g_dynLights
[idx
];
476 g_dynLightCount
:= lnum
;
479 procedure g_AddDynLight (x
, y
, radius
: Integer; r
, g
, b
, a
: Single);
481 if not gwin_has_stencil
then exit
;
482 if g_dynLightCount
= length(g_dynLights
) then SetLength(g_dynLights
, g_dynLightCount
+1024);
483 g_dynLights
[g_dynLightCount
].x
:= x
;
484 g_dynLights
[g_dynLightCount
].y
:= y
;
485 g_dynLights
[g_dynLightCount
].radius
:= radius
;
486 g_dynLights
[g_dynLightCount
].r
:= r
;
487 g_dynLights
[g_dynLightCount
].g
:= g
;
488 g_dynLights
[g_dynLightCount
].b
:= b
;
489 g_dynLights
[g_dynLightCount
].a
:= a
;
490 g_dynLights
[g_dynLightCount
].exploCount
:= -666;
491 Inc(g_dynLightCount
);
494 procedure g_DynLightExplosion (x
, y
, radius
: Integer; r
, g
, b
: Single);
496 if not gwin_has_stencil
then exit
;
497 if g_dynLightCount
= length(g_dynLights
) then SetLength(g_dynLights
, g_dynLightCount
+1024);
498 g_dynLights
[g_dynLightCount
].x
:= x
;
499 g_dynLights
[g_dynLightCount
].y
:= y
;
500 g_dynLights
[g_dynLightCount
].radius
:= 0;
501 g_dynLights
[g_dynLightCount
].exploRadius
:= radius
;
502 g_dynLights
[g_dynLightCount
].r
:= r
;
503 g_dynLights
[g_dynLightCount
].g
:= g
;
504 g_dynLights
[g_dynLightCount
].b
:= b
;
505 g_dynLights
[g_dynLightCount
].a
:= 0;
506 g_dynLights
[g_dynLightCount
].exploCount
:= 0;
507 Inc(g_dynLightCount
);
511 // ////////////////////////////////////////////////////////////////////////// //
512 function calcProfilesHeight (prof
: TProfiler
): Integer;
515 if (prof
= nil) then exit
;
516 if (length(prof
.bars
) = 0) then exit
;
517 result
:= length(prof
.bars
)*(16+2);
521 function drawProfiles (x
, y
: Integer; prof
: TProfiler
): Integer;
528 if (prof
= nil) then exit
;
530 if (length(prof
.bars
) = 0) then exit
;
532 hgt
:= calcProfilesHeight(prof
);
533 if (x
< 0) then x
:= gScreenWidth
-(wdt
-1)+x
;
534 if (y
< 0) then y
:= gScreenHeight
-(hgt
-1)+y
;
536 //e_DrawFillQuad(x, y, x+wdt-1, y+hgt-1, 255, 255, 255, 200, B_BLEND);
537 //e_DrawFillQuad(x, y, x+wdt-1, y+hgt-1, 20, 20, 20, 0, B_NONE);
538 e_DarkenQuadWH(x
, y
, wdt
, hgt
, 150);
541 for ii
:= 0 to High(prof
.bars
) do
543 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);
550 // ////////////////////////////////////////////////////////////////////////// //
552 TEndCustomGameStat
= record
553 PlayerStat
: TPlayerStatArray
;
557 Map
, MapName
: String;
560 TEndSingleGameStat
= record
561 PlayerStat
: Array [0..1] of record
567 TotalSecrets
: Integer;
570 TLoadingStat
= record
574 Msgs
: Array of String;
576 PBarWasHere
: Boolean; // did we draw a progress bar for this message?
579 TParamStrValue
= record
584 TParamStrValues
= Array of TParamStrValue
;
587 INTER_ACTION_TEXT
= 1;
588 INTER_ACTION_PIC
= 2;
589 INTER_ACTION_MUSIC
= 3;
593 FPSCounter
, UPSCounter
: Word;
594 FPSTime
, UPSTime
: LongWord
;
595 DataLoaded
: Boolean = False;
596 IsDrawStat
: Boolean = False;
597 CustomStat
: TEndCustomGameStat
;
598 SingleStat
: TEndSingleGameStat
;
599 LoadingStat
: TLoadingStat
;
600 EndingGameCounter
: Byte = 0;
603 MessageLineLength
: Integer = 80;
604 MapList
: SSArray
= nil;
605 MapIndex
: Integer = -1;
606 InterReadyTime
: Integer = -1;
607 StatShotDone
: Boolean = False;
608 StatFilename
: string = ''; // used by stat screenshot to save with the same name as the csv
609 StatDate
: string = '';
615 text: Array of ShortString
;
616 anim
: Array of ShortString
;
617 pic
: Array of ShortString
;
618 mus
: Array of ShortString
;
620 triggers
: Array of record
622 actions
: Array of record
623 action
, p1
, p2
: Integer;
626 cur_trigger
: Integer;
639 function Compare(a
, b
: TPlayerStat
): Integer;
641 if a
.Spectator
then Result
:= 1
642 else if b
.Spectator
then Result
:= -1
643 else if a
.Frags
< b
.Frags
then Result
:= 1
644 else if a
.Frags
> b
.Frags
then Result
:= -1
645 else if a
.Deaths
< b
.Deaths
then Result
:= -1
646 else if a
.Deaths
> b
.Deaths
then Result
:= 1
647 else if a
.Kills
< b
.Kills
then Result
:= -1
651 procedure SortGameStat(var stat
: TPlayerStatArray
);
656 if stat
= nil then Exit
;
658 for I
:= High(stat
) downto Low(stat
) do
659 for J
:= Low(stat
) to High(stat
) - 1 do
660 if Compare(stat
[J
], stat
[J
+ 1]) = 1 then
663 stat
[J
] := stat
[J
+ 1];
668 // saves a shitty CSV containing the game stats passed to it
669 procedure SaveGameStat(Stat
: TEndCustomGameStat
; Path
: string);
672 dir
, fname
, map
, mode
, etime
: String;
676 dir
:= e_GetWriteableDir(StatsDirs
);
677 // stats are placed in stats/yy/mm/dd/*.csv
678 fname
:= e_CatPath(dir
, Path
);
679 ForceDirectories(fname
); // ensure yy/mm/dd exists within the stats dir
680 fname
:= e_CatPath(fname
, StatFilename
+ '.csv');
681 AssignFile(s
, fname
);
683 SetTextCodePage(s
, CP_UTF8
);
685 // line 1: stats ver, datetime, server name, map name, game mode, time limit, score limit, dmflags, game time, num players
686 if g_Game_IsNet
then fname
:= NetServerName
else fname
:= '';
687 map
:= g_ExtractWadNameNoPath(gMapInfo
.Map
) + ':/' + g_ExtractFileName(gMapInfo
.Map
);
688 mode
:= g_Game_ModeToText(Stat
.GameMode
);
689 etime
:= Format('%d:%.2d:%.2d', [
690 Stat
.GameTime
div 1000 div 3600,
691 (Stat
.GameTime
div 1000 div 60) mod 60,
692 Stat
.GameTime
div 1000 mod 60
694 WriteLn(s
, 'stats_ver,datetime,server,map,mode,timelimit,scorelimit,dmflags,time,num_players');
695 WriteLn(s
, Format('%d,%s,%s,%s,%s,%u,%u,%u,%s,%d', [
701 gGameSettings
.TimeLimit
,
702 gGameSettings
.ScoreLimit
,
703 gGameSettings
.Options
,
705 Length(Stat
.PlayerStat
)
707 // line 2: game specific shit
708 // if it's a team game: red score, blue score
709 // if it's a coop game: monsters killed, monsters total, secrets found, secrets total
711 if Stat
.GameMode
in [GM_TDM
, GM_CTF
] then
713 Format('red_score,blue_score' + LineEnding
+ '%d,%d', [Stat
.TeamStat
[TEAM_RED
].Score
, Stat
.TeamStat
[TEAM_BLUE
].Score
]))
714 else if Stat
.GameMode
in [GM_COOP
, GM_SINGLE
] then
716 Format('mon_killed,mon_total,secrets_found,secrets_total' + LineEnding
+ '%d,%d,%d,%d',[gCoopMonstersKilled
, gTotalMonsters
, gCoopSecretsFound
, gSecretsCount
]));
717 // lines 3-...: team, player name, frags, deaths
718 WriteLn(s
, 'team,name,frags,deaths');
719 for I
:= Low(Stat
.PlayerStat
) to High(Stat
.PlayerStat
) do
720 with Stat
.PlayerStat
[I
] do
721 WriteLn(s
, Format('%d,%s,%d,%d', [Team
, dquoteStr(Name
), Frags
, Deaths
]));
723 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_WRITE
], [fname
]));
726 g_Console_Add('could not create gamestats file "' + fname
+ '"');
731 function g_Game_ModeToText(Mode
: Byte): string;
735 GM_DM
: Result
:= _lc
[I_MENU_GAME_TYPE_DM
];
736 GM_TDM
: Result
:= _lc
[I_MENU_GAME_TYPE_TDM
];
737 GM_CTF
: Result
:= _lc
[I_MENU_GAME_TYPE_CTF
];
738 GM_COOP
: Result
:= _lc
[I_MENU_GAME_TYPE_COOP
];
739 GM_SINGLE
: Result
:= _lc
[I_MENU_GAME_TYPE_SINGLE
];
743 function g_Game_TextToMode(Mode
: string): Byte;
746 Mode
:= UpperCase(Mode
);
747 if Mode
= _lc
[I_MENU_GAME_TYPE_DM
] then
752 if Mode
= _lc
[I_MENU_GAME_TYPE_TDM
] then
757 if Mode
= _lc
[I_MENU_GAME_TYPE_CTF
] then
762 if Mode
= _lc
[I_MENU_GAME_TYPE_COOP
] then
767 if Mode
= _lc
[I_MENU_GAME_TYPE_SINGLE
] then
774 function g_Game_IsNet(): Boolean;
776 Result
:= (gGameSettings
.GameType
in [GT_SERVER
, GT_CLIENT
]);
778 if gGameSettings
.GameType
in [GT_SERVER
, GT_CLIENT
] then
780 // set debug options to false to avoid cheaters
781 g_debug_Sounds
:= False;
782 g_debug_Frames
:= False;
783 g_debug_WinMsgs
:= False;
784 g_debug_MonsterOff
:= False;
785 g_debug_BotAIOff
:= 0;
786 g_debug_HealthBar
:= False;
787 g_Debug_Player
:= False;
792 function g_Game_IsServer(): Boolean;
794 Result
:= (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
, GT_SERVER
]);
797 function g_Game_IsClient(): Boolean;
799 Result
:= (gGameSettings
.GameType
= GT_CLIENT
);
802 function g_Game_GetMegaWADInfo(WAD
: String): TMegaWADInfo
;
809 Result
.name
:= ExtractFileName(WAD
);
810 Result
.description
:= '';
813 w
:= TWADFile
.Create();
816 if not w
.GetResource('INTERSCRIPT', p
, len
) then
822 cfg
:= TConfig
.CreateMem(p
, len
);
823 Result
.name
:= cfg
.ReadStr('megawad', 'name', ExtractFileName(WAD
));
824 Result
.description
:= cfg
.ReadStr('megawad', 'description', '');
825 Result
.author
:= cfg
.ReadStr('megawad', 'author', '');
826 Result
.pic
:= cfg
.ReadStr('megawad', 'pic', '');
832 procedure g_Game_FreeWAD();
836 for a
:= 0 to High(MegaWAD
.res
.pic
) do
837 if MegaWAD
.res
.pic
[a
] <> '' then
838 g_Texture_Delete(MegaWAD
.res
.pic
[a
]);
840 for a
:= 0 to High(MegaWAD
.res
.mus
) do
841 if MegaWAD
.res
.mus
[a
] <> '' then
842 g_Sound_Delete(MegaWAD
.res
.mus
[a
]);
844 MegaWAD
.res
.pic
:= nil;
845 MegaWAD
.res
.text := nil;
846 MegaWAD
.res
.anim
:= nil;
847 MegaWAD
.res
.mus
:= nil;
848 MegaWAD
.triggers
:= nil;
850 g_Texture_Delete('TEXTURE_endpic');
851 g_Sound_Delete('MUSIC_endmus');
853 ZeroMemory(@MegaWAD
, SizeOf(MegaWAD
));
854 gGameSettings
.WAD
:= '';
857 procedure g_Game_LoadWAD(WAD
: string);
866 gGameSettings
.WAD
:= WAD
;
867 if not (gGameSettings
.GameMode
in [GM_COOP
, GM_SINGLE
]) then
870 MegaWAD
.info
:= g_Game_GetMegaWADInfo(WAD
);
872 w
:= TWADFile
.Create();
875 if not w
.GetResource('INTERSCRIPT', p
, len
) then
881 cfg
:= TConfig
.CreateMem(p
, len
);
886 s := cfg.ReadStr('pic', 'pic'+IntToStr(b), '');
887 if s = '' then Break;
890 SetLength(MegaWAD.res.pic, Length(MegaWAD.res.pic)+1);
891 MegaWAD.res.pic[High(MegaWAD.res.pic)] := s;
893 g_Texture_CreateWADEx(s, s);
899 s := cfg.ReadStr('mus', 'mus'+IntToStr(b), '');
900 if s = '' then Break;
903 SetLength(MegaWAD.res.mus, Length(MegaWAD.res.mus)+1);
904 MegaWAD.res.mus[High(MegaWAD.res.mus)] := s;
906 g_Music_CreateWADEx(s, s);
909 MegaWAD
.endpic
:= cfg
.ReadStr('megawad', 'endpic', '');
910 if MegaWAD
.endpic
<> '' then
912 TEXTUREFILTER
:= GL_LINEAR
;
913 s
:= e_GetResourcePath(WadDirs
, MegaWAD
.endpic
, WAD
);
914 g_Texture_CreateWADEx('TEXTURE_endpic', s
);
915 TEXTUREFILTER
:= GL_NEAREST
;
917 MegaWAD
.endmus
:= cfg
.ReadStr('megawad', 'endmus', 'Standart.wad:D2DMUS\ÊÎÍÅÖ');
918 if MegaWAD
.endmus
<> '' then
920 s
:= e_GetResourcePath(WadDirs
, MegaWAD
.endmus
, WAD
);
921 g_Sound_CreateWADEx('MUSIC_endmus', s
, True);
929 {procedure start_trigger(t: string);
933 function next_trigger(): Boolean;
937 procedure DisableCheats();
943 if gPlayer1
<> nil then gPlayer1
.GodMode
:= False;
944 if gPlayer2
<> nil then gPlayer2
.GodMode
:= False;
945 if gPlayer1
<> nil then gPlayer1
.NoTarget
:= False;
946 if gPlayer2
<> nil then gPlayer2
.NoTarget
:= False;
948 {$IF DEFINED(D2F_DEBUG)}
949 if gPlayer1
<> nil then gPlayer1
.NoTarget
:= True;
950 gAimLine
:= g_dbg_aimline_on
;
954 procedure g_Game_ExecuteEvent(Name
: String);
960 if gEvents
= nil then
962 for a
:= 0 to High(gEvents
) do
963 if gEvents
[a
].Name
= Name
then
965 if gEvents
[a
].Command
<> '' then
966 g_Console_Process(gEvents
[a
].Command
, True);
971 function g_Game_DelayEvent(DEType
: Byte; Time
: LongWord
; Num
: Integer = 0; Str
: String = ''): Integer;
976 if gDelayedEvents
<> nil then
977 for a
:= 0 to High(gDelayedEvents
) do
978 if not gDelayedEvents
[a
].Pending
then
985 SetLength(gDelayedEvents
, Length(gDelayedEvents
) + 1);
986 n
:= High(gDelayedEvents
);
988 gDelayedEvents
[n
].Pending
:= True;
989 gDelayedEvents
[n
].DEType
:= DEType
;
990 gDelayedEvents
[n
].DENum
:= Num
;
991 gDelayedEvents
[n
].DEStr
:= Str
;
992 if DEType
= DE_GLOBEVENT
then
993 gDelayedEvents
[n
].Time
:= (sys_GetTicks() {div 1000}) + Time
995 gDelayedEvents
[n
].Time
:= gTime
+ Time
;
1005 if g_Game_IsNet
and g_Game_IsServer
then
1006 MH_SEND_GameEvent(NET_EV_MAPEND
, Byte(gMissionFailed
));
1009 gPauseMain
:= false;
1010 gPauseHolmes
:= false;
1013 g_Game_StopAllSounds(False);
1018 EndingGameCounter
:= 0;
1019 g_ActiveWindow
:= nil;
1021 gLMSRespawn
:= LMS_RESPAWN_NONE
;
1022 gLMSRespawnTime
:= 0;
1025 EXIT_SIMPLE
: // Âûõîä ÷åðåç ìåíþ èëè êîíåö òåñòà
1030 begin // Ýòî áûë òåñò
1034 begin // Âûõîä â ãëàâíîå ìåíþ
1035 gMusic
.SetByName('MUSIC_MENU');
1037 if gState
<> STATE_SLIST
then
1039 g_GUI_ShowWindow('MainMenu');
1040 gState
:= STATE_MENU
;
1043 // Îáíîâëÿåì ñïèñîê ñåðâåðîâ
1044 slReturnPressed
:= True;
1045 if g_Net_Slist_Fetch(slCurrent
) then
1047 if slCurrent
= nil then
1048 slWaitStr
:= _lc
[I_NET_SLIST_NOSERVERS
];
1051 slWaitStr
:= _lc
[I_NET_SLIST_ERROR
];
1052 g_Serverlist_GenerateTable(slCurrent
, slTable
);
1055 g_Game_ExecuteEvent('ongameend');
1059 EXIT_RESTART
: // Íà÷àòü óðîâåíü ñíà÷àëà
1061 if not g_Game_IsClient
then g_Game_Restart();
1064 EXIT_ENDLEVELCUSTOM
: // Çàêîí÷èëñÿ óðîâåíü â Ñâîåé èãðå
1066 // Ñòàòèñòèêà Ñâîåé èãðû:
1067 FileName
:= g_ExtractWadName(gMapInfo
.Map
);
1069 CustomStat
.GameTime
:= gTime
;
1070 CustomStat
.Map
:= ExtractFileName(FileName
)+':'+g_ExtractFileName(gMapInfo
.Map
); //ResName;
1071 CustomStat
.MapName
:= gMapInfo
.Name
;
1072 CustomStat
.GameMode
:= gGameSettings
.GameMode
;
1073 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
1074 CustomStat
.TeamStat
:= gTeamStat
;
1076 CustomStat
.PlayerStat
:= nil;
1078 // Ñòàòèñòèêà èãðîêîâ:
1079 if gPlayers
<> nil then
1081 for a
:= 0 to High(gPlayers
) do
1082 if gPlayers
[a
] <> nil then
1084 SetLength(CustomStat
.PlayerStat
, Length(CustomStat
.PlayerStat
)+1);
1085 with CustomStat
.PlayerStat
[High(CustomStat
.PlayerStat
)] do
1088 Name
:= gPlayers
[a
].Name
;
1089 Frags
:= gPlayers
[a
].Frags
;
1090 Deaths
:= gPlayers
[a
].Death
;
1091 Kills
:= gPlayers
[a
].Kills
;
1092 Team
:= gPlayers
[a
].Team
;
1093 Color
:= gPlayers
[a
].Model
.Color
;
1094 Spectator
:= gPlayers
[a
].FSpectator
;
1098 SortGameStat(CustomStat
.PlayerStat
);
1100 if (gSaveStats
or gScreenshotStats
) and (Length(CustomStat
.PlayerStat
) > 1) then
1103 if g_Game_IsNet
then StatFilename
:= NetServerName
else StatFilename
:= 'local';
1104 StatDate
:= FormatDateTime('yymmdd_hhnnss', t
);
1105 StatFilename
:= StatFilename
+ '_' + CustomStat
.Map
+ '_' + g_Game_ModeToText(CustomStat
.GameMode
);
1106 StatFilename
:= sanitizeFilename(StatFilename
) + '_' + StatDate
;
1108 SaveGameStat(CustomStat
, FormatDateTime('yyyy"/"mm"/"dd', t
));
1111 StatShotDone
:= False;
1114 g_Game_ExecuteEvent('onmapend');
1115 if not g_Game_IsClient
then g_Player_ResetReady
;
1116 gInterReadyCount
:= 0;
1118 // Çàòóõàþùèé ýêðàí:
1119 EndingGameCounter
:= 255;
1120 gState
:= STATE_FOLD
;
1122 if gDefInterTime
< 0 then
1123 gInterEndTime
:= IfThen((gGameSettings
.GameType
= GT_SERVER
) and (gPlayer1
= nil), 15000, 25000)
1125 gInterEndTime
:= gDefInterTime
* 1000;
1128 EXIT_ENDLEVELSINGLE
: // Çàêîí÷èëñÿ óðîâåíü â Îäèíî÷íîé èãðå
1130 // Ñòàòèñòèêà Îäèíî÷íîé èãðû:
1131 SingleStat
.GameTime
:= gTime
;
1132 SingleStat
.TwoPlayers
:= gPlayer2
<> nil;
1133 SingleStat
.TotalSecrets
:= gSecretsCount
;
1134 // Ñòàòèñòèêà ïåðâîãî èãðîêà:
1135 SingleStat
.PlayerStat
[0].Kills
:= gPlayer1
.MonsterKills
;
1136 SingleStat
.PlayerStat
[0].Secrets
:= gPlayer1
.Secrets
;
1137 // Ñòàòèñòèêà âòîðîãî èãðîêà (åñëè åñòü):
1138 if SingleStat
.TwoPlayers
then
1140 SingleStat
.PlayerStat
[1].Kills
:= gPlayer2
.MonsterKills
;
1141 SingleStat
.PlayerStat
[1].Secrets
:= gPlayer2
.Secrets
;
1144 g_Game_ExecuteEvent('onmapend');
1147 if gNextMap
<> '' then
1149 gMusic
.SetByName('MUSIC_INTERMUS');
1151 gState
:= STATE_INTERSINGLE
;
1154 g_Game_ExecuteEvent('oninter');
1156 else // Áîëüøå íåò êàðò
1158 // Çàòóõàþùèé ýêðàí:
1159 EndingGameCounter
:= 255;
1160 gState
:= STATE_FOLD
;
1165 // Îêîí÷àíèå îáðàáîòàíî:
1166 if gExit
<> EXIT_QUIT
then
1170 procedure drawTime(X
, Y
: Integer); inline;
1172 e_TextureFontPrint(x
, y
,
1173 Format('%d:%.2d:%.2d', [
1174 gTime
div 1000 div 3600,
1175 (gTime
div 1000 div 60) mod 60,
1176 gTime
div 1000 mod 60
1181 procedure DrawStat();
1183 pc
, x
, y
, w
, h
: Integer;
1184 w1
, w2
, w3
, w4
: Integer;
1186 cw
, ch
, r
, g
, b
, rr
, gg
, bb
: Byte;
1189 stat
: TPlayerStatArray
;
1197 pc
:= g_Player_GetCount
;
1198 e_TextureFontGetSize(gStdFont
, cw
, ch
);
1200 w
:= gScreenWidth
-(gScreenWidth
div 5);
1201 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
1204 h
:= 40+ch
*5+(ch
+8)*pc
;
1205 x
:= (gScreenWidth
div 2)-(w
div 2);
1206 y
:= (gScreenHeight
div 2)-(h
div 2);
1208 e_DrawFillQuad(x
, y
, x
+w
-1, y
+h
-1, 64, 64, 64, 32);
1209 e_DrawQuad(x
, y
, x
+w
-1, y
+h
-1, 255, 127, 0);
1211 drawTime(x
+w
-78, y
+8);
1213 wad
:= g_ExtractWadNameNoPath(gMapInfo
.Map
);
1214 map
:= g_ExtractFileName(gMapInfo
.Map
);
1215 mapstr
:= wad
+ ':\' + map
+ ' - ' + gMapInfo
.Name
;
1217 case gGameSettings
.GameMode
of
1220 if gGameSettings
.MaxLives
= 0 then
1221 s1
:= _lc
[I_GAME_DM
]
1223 s1
:= _lc
[I_GAME_LMS
];
1224 s2
:= Format(_lc
[I_GAME_FRAG_LIMIT
], [gGameSettings
.ScoreLimit
]);
1225 s3
:= Format(_lc
[I_GAME_TIME_LIMIT
], [gGameSettings
.TimeLimit
div 3600, (gGameSettings
.TimeLimit
div 60) mod 60, gGameSettings
.TimeLimit
mod 60]);
1230 if gGameSettings
.MaxLives
= 0 then
1231 s1
:= _lc
[I_GAME_TDM
]
1233 s1
:= _lc
[I_GAME_TLMS
];
1234 s2
:= Format(_lc
[I_GAME_FRAG_LIMIT
], [gGameSettings
.ScoreLimit
]);
1235 s3
:= Format(_lc
[I_GAME_TIME_LIMIT
], [gGameSettings
.TimeLimit
div 3600, (gGameSettings
.TimeLimit
div 60) mod 60, gGameSettings
.TimeLimit
mod 60]);
1240 s1
:= _lc
[I_GAME_CTF
];
1241 s2
:= Format(_lc
[I_GAME_SCORE_LIMIT
], [gGameSettings
.ScoreLimit
]);
1242 s3
:= Format(_lc
[I_GAME_TIME_LIMIT
], [gGameSettings
.TimeLimit
div 3600, (gGameSettings
.TimeLimit
div 60) mod 60, gGameSettings
.TimeLimit
mod 60]);
1247 if gGameSettings
.MaxLives
= 0 then
1248 s1
:= _lc
[I_GAME_COOP
]
1250 s1
:= _lc
[I_GAME_SURV
];
1251 s2
:= _lc
[I_GAME_MONSTERS
] + ' ' + IntToStr(gCoopMonstersKilled
) + '/' + IntToStr(gTotalMonsters
);
1252 s3
:= _lc
[I_GAME_SECRETS
] + ' ' + IntToStr(gCoopSecretsFound
) + '/' + IntToStr(gSecretsCount
);
1263 e_TextureFontPrintEx(x
+(w
div 2)-(Length(s1
)*cw
div 2), _y
, s1
, gStdFont
, 255, 255, 255, 1);
1265 e_TextureFontPrintEx(x
+(w
div 2)-(Length(mapstr
)*cw
div 2), _y
, mapstr
, gStdFont
, 200, 200, 200, 1);
1267 e_TextureFontPrintEx(x
+16, _y
, s2
, gStdFont
, 200, 200, 200, 1);
1269 e_TextureFontPrintEx(x
+w
-16-(Length(s3
))*cw
, _y
, s3
,
1270 gStdFont
, 200, 200, 200, 1);
1272 if NetMode
= NET_SERVER
then
1273 e_TextureFontPrintEx(x
+8, y
+ 8, _lc
[I_NET_SERVER
], gStdFont
, 255, 255, 255, 1)
1275 if NetMode
= NET_CLIENT
then
1276 e_TextureFontPrintEx(x
+8, y
+ 8,
1277 NetClientIP
+ ':' + IntToStr(NetClientPort
), gStdFont
, 255, 255, 255, 1);
1281 stat
:= g_Player_GetStats();
1284 w2
:= (w
-16) div 6 + 48; // øèðèíà 2 ñòîëáöà
1285 w3
:= (w
-16) div 6; // øèðèíà 3 è 4 ñòîëáöîâ
1287 w1
:= w
-16-w2
-w3
-w4
; // îñòàâøååñÿ ïðîñòðàíñòâî - äëÿ öâåòà è èìåíè èãðîêà
1289 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
1293 for a
:= TEAM_RED
to TEAM_BLUE
do
1295 if a
= TEAM_RED
then
1297 s1
:= _lc
[I_GAME_TEAM_RED
];
1304 s1
:= _lc
[I_GAME_TEAM_BLUE
];
1310 e_TextureFontPrintEx(x
+16, _y
, s1
, gStdFont
, r
, g
, b
, 1);
1311 e_TextureFontPrintEx(x
+w1
+16, _y
, IntToStr(gTeamStat
[a
].Score
),
1312 gStdFont
, r
, g
, b
, 1);
1314 _y
:= _y
+ch
+(ch
div 4);
1315 e_DrawLine(1, x
+16, _y
, x
+w
-16, _y
, r
, g
, b
);
1316 _y
:= _y
+(ch
div 4);
1318 for aa
:= 0 to High(stat
) do
1319 if stat
[aa
].Team
= a
then
1335 namestr
:= Format('[%5d] %s', [UID
, Name
])
1339 e_TextureFontPrintEx(x
+16, _y
, namestr
, gStdFont
, rr
, gg
, bb
, 1);
1341 e_TextureFontPrintEx(x
+w1
+16, _y
, Format(_lc
[I_GAME_PING_MS
], [Ping
, Loss
]), gStdFont
, rr
, gg
, bb
, 1);
1343 e_TextureFontPrintEx(x
+w1
+w2
+16, _y
, IntToStr(Frags
), gStdFont
, rr
, gg
, bb
, 1);
1345 e_TextureFontPrintEx(x
+w1
+w2
+w3
+16, _y
, IntToStr(Deaths
), gStdFont
, rr
, gg
, bb
, 1);
1352 else if gGameSettings
.GameMode
in [GM_DM
, GM_COOP
] then
1355 e_TextureFontPrintEx(x
+16, _y
, _lc
[I_GAME_PLAYER_NAME
], gStdFont
, 255, 127, 0, 1);
1356 e_TextureFontPrintEx(x
+16+w1
, _y
, _lc
[I_GAME_PING
], gStdFont
, 255, 127, 0, 1);
1357 e_TextureFontPrintEx(x
+16+w1
+w2
, _y
, _lc
[I_GAME_FRAGS
], gStdFont
, 255, 127, 0, 1);
1358 e_TextureFontPrintEx(x
+16+w1
+w2
+w3
, _y
, _lc
[I_GAME_DEATHS
], gStdFont
, 255, 127, 0, 1);
1361 for aa
:= 0 to High(stat
) do
1375 namestr
:= Format('[%5d] %s', [UID
, Name
])
1379 e_DrawFillQuad(x
+16, _y
+4, x
+32-1, _y
+16+4-1, Color
.R
, Color
.G
, Color
.B
, 0);
1380 e_DrawQuad(x
+16, _y
+4, x
+32-1, _y
+16+4-1, 192, 192, 192);
1382 e_TextureFontPrintEx(x
+16+16+8, _y
+4, namestr
, gStdFont
, r
, g
, 0, 1);
1384 e_TextureFontPrintEx(x
+w1
+16, _y
+4, Format(_lc
[I_GAME_PING_MS
], [Ping
, Loss
]), gStdFont
, r
, g
, 0, 1);
1386 e_TextureFontPrintEx(x
+w1
+w2
+16, _y
+4, IntToStr(Frags
), gStdFont
, r
, g
, 0, 1);
1388 e_TextureFontPrintEx(x
+w1
+w2
+w3
+16, _y
+4, IntToStr(Deaths
), gStdFont
, r
, g
, 0, 1);
1394 procedure g_Game_Init();
1397 knownFiles
: array of AnsiString
= nil;
1399 wext
, s
: AnsiString
;
1404 gTempDelete
:= False;
1406 sfsGCDisable(); // temporary disable removing of temporary volumes
1409 TEXTUREFILTER
:= GL_LINEAR
;
1410 g_Texture_CreateWADEx('MENU_BACKGROUND', GameWAD
+':TEXTURES\TITLE');
1411 g_Texture_CreateWADEx('INTER', GameWAD
+':TEXTURES\INTER');
1412 g_Texture_CreateWADEx('ENDGAME_EN', GameWAD
+':TEXTURES\ENDGAME_EN');
1413 g_Texture_CreateWADEx('ENDGAME_RU', GameWAD
+':TEXTURES\ENDGAME_RU');
1414 TEXTUREFILTER
:= GL_NEAREST
;
1416 LoadStdFont('STDTXT', 'STDFONT', gStdFont
);
1417 LoadFont('MENUTXT', 'MENUFONT', gMenuFont
);
1418 LoadFont('SMALLTXT', 'SMALLFONT', gMenuSmallFont
);
1420 g_Game_ClearLoading();
1421 g_Game_SetLoadingText(Format('Doom 2D: Forever %s', [GAME_VERSION
]), 0, False);
1422 g_Game_SetLoadingText('', 0, False);
1424 g_Game_SetLoadingText(_lc
[I_LOAD_CONSOLE
], 0, False);
1427 g_Game_SetLoadingText(_lc
[I_LOAD_MODELS
], 0, False);
1428 g_PlayerModel_LoadData();
1430 // load models from all possible wad types, in all known directories
1431 // this does a loosy job (linear search, ooph!), but meh
1432 for wext
in wadExtensions
do
1434 for f
:= High(ModelDirs
) downto Low(ModelDirs
) do
1436 if (FindFirst(ModelDirs
[f
]+DirectorySeparator
+'*'+wext
, faAnyFile
, SR
) = 0) then
1440 for s
in knownFiles
do
1442 if (strEquCI1251(forceFilenameExt(SR
.Name
, ''), forceFilenameExt(ExtractFileName(s
), ''))) then
1450 SetLength(knownFiles
, length(knownFiles
)+1);
1451 knownFiles
[High(knownFiles
)] := ModelDirs
[f
]+DirectorySeparator
+SR
.Name
;
1453 until (FindNext(SR
) <> 0);
1459 if (length(knownFiles
) = 0) then raise Exception
.Create('no player models found!');
1461 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
);
1462 for s
in knownFiles
do
1464 if not g_PlayerModel_Load(s
) then e_LogWritefln('Error loading model "%s"', [s
], TMsgType
.Warning
);
1468 gPauseMain
:= false;
1469 gPauseHolmes
:= false;
1472 {e_MouseInfo.Accel := 1.0;}
1474 g_Game_SetLoadingText(_lc
[I_LOAD_GAME_DATA
], 0, False);
1477 g_Game_SetLoadingText(_lc
[I_LOAD_MUSIC
], 0, False);
1478 g_Sound_CreateWADEx('MUSIC_INTERMUS', GameWAD
+':MUSIC\INTERMUS', True);
1479 g_Sound_CreateWADEx('MUSIC_MENU', GameWAD
+':MUSIC\MENU', True);
1480 g_Sound_CreateWADEx('MUSIC_ROUNDMUS', GameWAD
+':MUSIC\ROUNDMUS', True, True);
1481 g_Sound_CreateWADEx('MUSIC_STDENDMUS', GameWAD
+':MUSIC\ENDMUS', True);
1484 g_Game_SetLoadingText(_lc
[I_LOAD_MENUS
], 0, False);
1488 gMusic
:= TMusic
.Create();
1489 gMusic
.SetByName('MUSIC_MENU');
1492 gGameSettings
.WarmupTime
:= 30;
1494 gState
:= STATE_MENU
;
1496 SetLength(gEvents
, 6);
1497 gEvents
[0].Name
:= 'ongamestart';
1498 gEvents
[1].Name
:= 'ongameend';
1499 gEvents
[2].Name
:= 'onmapstart';
1500 gEvents
[3].Name
:= 'onmapend';
1501 gEvents
[4].Name
:= 'oninter';
1502 gEvents
[5].Name
:= 'onwadend';
1504 sfsGCEnable(); // enable releasing unused volumes
1508 procedure g_Game_Free(freeTextures
: Boolean=true);
1510 if NetMode
= NET_CLIENT
then g_Net_Disconnect();
1511 if NetMode
= NET_SERVER
then g_Net_Host_Die();
1513 g_Map_Free(freeTextures
);
1515 g_Player_RemoveAllCorpses();
1517 gGameSettings
.GameType
:= GT_NONE
;
1518 if gGameSettings
.GameMode
= GM_SINGLE
then
1519 gGameSettings
.GameMode
:= GM_DM
;
1520 gSwitchGameMode
:= gGameSettings
.GameMode
;
1523 gExitByTrigger
:= False;
1526 function IsActivePlayer(p
: TPlayer
): Boolean;
1531 Result
:= (not p
.FDummy
) and (not p
.FSpectator
);
1534 function GetActivePlayer_ByID(ID
: Integer): TPlayer
;
1541 if gPlayers
= nil then
1543 for a
:= Low(gPlayers
) to High(gPlayers
) do
1544 if IsActivePlayer(gPlayers
[a
]) then
1546 if gPlayers
[a
].UID
<> ID
then
1548 Result
:= gPlayers
[a
];
1553 function GetActivePlayerID_Next(Skip
: Integer = -1): Integer;
1559 if gPlayers
= nil then
1563 for a
:= Low(gPlayers
) to High(gPlayers
) do
1564 if IsActivePlayer(gPlayers
[a
]) then
1566 SetLength(ids
, Length(ids
) + 1);
1567 ids
[High(ids
)] := gPlayers
[a
].UID
;
1568 if gPlayers
[a
].UID
= Skip
then
1571 if Length(ids
) = 0 then
1576 Result
:= ids
[(idx
+ 1) mod Length(ids
)];
1579 function GetActivePlayerID_Prev(Skip
: Integer = -1): Integer;
1585 if gPlayers
= nil then
1589 for a
:= Low(gPlayers
) to High(gPlayers
) do
1590 if IsActivePlayer(gPlayers
[a
]) then
1592 SetLength(ids
, Length(ids
) + 1);
1593 ids
[High(ids
)] := gPlayers
[a
].UID
;
1594 if gPlayers
[a
].UID
= Skip
then
1597 if Length(ids
) = 0 then
1600 Result
:= ids
[Length(ids
) - 1]
1602 Result
:= ids
[(Length(ids
) - 1 + idx
) mod Length(ids
)];
1605 function GetActivePlayerID_Random(Skip
: Integer = -1): Integer;
1611 if gPlayers
= nil then
1615 for a
:= Low(gPlayers
) to High(gPlayers
) do
1616 if IsActivePlayer(gPlayers
[a
]) then
1618 SetLength(ids
, Length(ids
) + 1);
1619 ids
[High(ids
)] := gPlayers
[a
].UID
;
1620 if gPlayers
[a
].UID
= Skip
then
1623 if Length(ids
) = 0 then
1625 if Length(ids
) = 1 then
1630 Result
:= ids
[Random(Length(ids
))];
1632 while (idx
<> -1) and (Result
= Skip
) and (a
> 0) do
1634 Result
:= ids
[Random(Length(ids
))];
1639 function GetRandomSpectMode(Current
: Byte): Byte;
1646 0: Result
:= SPECT_STATS
;
1647 1: Result
:= SPECT_MAPVIEW
;
1648 2: Result
:= SPECT_MAPVIEW
;
1649 3: Result
:= SPECT_PLAYERS
;
1650 4: Result
:= SPECT_PLAYERS
;
1651 5: Result
:= SPECT_PLAYERS
;
1652 6: Result
:= SPECT_PLAYERS
;
1654 if (Current
in [SPECT_STATS
, SPECT_MAPVIEW
]) and (Current
= Result
) then
1658 procedure ProcessPlayerControls (plr
: TPlayer
; p
: Integer; var MoveButton
: Byte);
1664 if (plr
= nil) then exit
;
1665 if (p
= 2) then time
:= 1000 else time
:= 1;
1666 strafeDir
:= MoveButton
shr 4;
1667 MoveButton
:= MoveButton
and $0F;
1669 if gPlayerAction
[p
, ACTION_MOVELEFT
] and (not gPlayerAction
[p
, ACTION_MOVERIGHT
]) then
1670 MoveButton
:= 1 // Íàæàòà òîëüêî "Âëåâî"
1671 else if (not gPlayerAction
[p
, ACTION_MOVELEFT
]) and gPlayerAction
[p
, ACTION_MOVERIGHT
] then
1672 MoveButton
:= 2 // Íàæàòà òîëüêî "Âïðàâî"
1673 else if (not gPlayerAction
[p
, ACTION_MOVELEFT
]) and (not gPlayerAction
[p
, ACTION_MOVERIGHT
]) then
1674 MoveButton
:= 0; // Íå íàæàòû íè "Âëåâî", íè "Âïðàâî"
1676 // Ñåé÷àñ èëè ðàíüøå áûëè íàæàòû "Âëåâî"/"Âïðàâî" => ïåðåäàåì èãðîêó:
1677 if MoveButton
= 1 then
1678 plr
.PressKey(KEY_LEFT
, time
)
1679 else if MoveButton
= 2 then
1680 plr
.PressKey(KEY_RIGHT
, time
);
1682 // if we have "strafe" key, turn off old strafe mechanics
1683 if gPlayerAction
[p
, ACTION_STRAFE
] then
1685 // new strafe mechanics
1686 if (strafeDir
= 0) then
1687 strafeDir
:= MoveButton
; // start strafing
1688 // now set direction according to strafe (reversed)
1689 if (strafeDir
= 2) then
1690 plr
.SetDirection(TDirection
.D_LEFT
)
1691 else if (strafeDir
= 1) then
1692 plr
.SetDirection(TDirection
.D_RIGHT
)
1696 strafeDir
:= 0; // not strafing anymore
1697 // Ðàíüøå áûëà íàæàòà "Âïðàâî", à ñåé÷àñ "Âëåâî" => áåæèì âïðàâî, ñìîòðèì âëåâî:
1698 if (MoveButton
= 2) and gPlayerAction
[p
, ACTION_MOVELEFT
] then
1699 plr
.SetDirection(TDirection
.D_LEFT
)
1700 // Ðàíüøå áûëà íàæàòà "Âëåâî", à ñåé÷àñ "Âïðàâî" => áåæèì âëåâî, ñìîòðèì âïðàâî:
1701 else if (MoveButton
= 1) and gPlayerAction
[p
, ACTION_MOVERIGHT
] then
1702 plr
.SetDirection(TDirection
.D_RIGHT
)
1703 // ×òî-òî áûëî íàæàòî è íå èçìåíèëîñü => êóäà áåæèì, òóäà è ñìîòðèì:
1704 else if MoveButton
<> 0 then
1705 plr
.SetDirection(TDirection(MoveButton
-1))
1708 // fix movebutton state
1709 MoveButton
:= MoveButton
or (strafeDir
shl 4);
1711 // Îñòàëüíûå êëàâèøè:
1712 if gPlayerAction
[p
, ACTION_JUMP
] then plr
.PressKey(KEY_JUMP
, time
);
1713 if gPlayerAction
[p
, ACTION_LOOKUP
] then plr
.PressKey(KEY_UP
, time
);
1714 if gPlayerAction
[p
, ACTION_LOOKDOWN
] then plr
.PressKey(KEY_DOWN
, time
);
1715 if gPlayerAction
[p
, ACTION_ATTACK
] then plr
.PressKey(KEY_FIRE
);
1716 if gPlayerAction
[p
, ACTION_ACTIVATE
] then plr
.PressKey(KEY_OPEN
);
1718 for i
:= WP_FACT
to WP_LACT
do
1720 if gWeaponAction
[p
, i
] then
1722 plr
.ProcessWeaponAction(i
);
1723 gWeaponAction
[p
, i
] := False
1727 for i
:= WP_FIRST
to WP_LAST
do
1729 if gSelectWeapon
[p
, i
] then
1731 plr
.QueueWeaponSwitch(i
); // all choices are passed there, and god will take the best
1732 gSelectWeapon
[p
, i
] := False
1736 // HACK: add dynlight here
1737 if gwin_k8_enable_light_experiments
then
1739 if e_KeyPressed(IK_F8
) and gGameOn
and (not gConsoleShow
) and (g_ActiveWindow
= nil) then
1741 g_playerLight
:= true;
1743 if e_KeyPressed(IK_F9
) and gGameOn
and (not gConsoleShow
) and (g_ActiveWindow
= nil) then
1745 g_playerLight
:= false;
1749 if gwin_has_stencil
and g_playerLight
then g_AddDynLight(plr
.GameX
+32, plr
.GameY
+40, 128, 1, 1, 0, 0.6);
1752 // HACK: don't have a "key was pressed" function
1753 procedure InterReady();
1755 if InterReadyTime
> gTime
then Exit
;
1756 InterReadyTime
:= gTime
+ 3000;
1757 MC_SEND_CheatRequest(NET_CHEAT_READY
);
1760 procedure g_Game_PreUpdate();
1762 // these are in separate PreUpdate functions because they can interact during Update()
1763 // and are synced over the net
1764 // we don't care that much about corpses and gibs
1765 g_Player_PreUpdate();
1766 g_Monsters_PreUpdate();
1767 g_Items_PreUpdate();
1768 g_Weapon_PreUpdate();
1771 procedure g_Game_Update();
1773 Msg
: g_gui
.TMessage
;
1779 function sendMonsPos (mon
: TMonster
): Boolean;
1781 result
:= false; // don't stop
1782 // this will also reset "need-send" flag
1783 if mon
.gncNeedSend
then
1785 MH_SEND_MonsterPos(mon
.UID
);
1787 else if (mon
.MonsterType
= MONSTER_BARREL
) then
1789 if (mon
.GameVelX
<> 0) or (mon
.GameVelY
<> 0) then MH_SEND_MonsterPos(mon
.UID
);
1791 else if (mon
.MonsterState
<> MONSTATE_SLEEP
) then
1793 if (mon
.MonsterState
<> MONSTATE_DEAD
) or (mon
.GameVelX
<> 0) or (mon
.GameVelY
<> 0) then MH_SEND_MonsterPos(mon
.UID
);
1797 function sendMonsPosUnexpected (mon
: TMonster
): Boolean;
1799 result
:= false; // don't stop
1800 // this will also reset "need-send" flag
1801 if mon
.gncNeedSend
then MH_SEND_MonsterPos(mon
.UID
);
1804 function sendItemPos (it
: PItem
): Boolean;
1806 result
:= false; // don't stop
1809 MH_SEND_ItemPos(it
.myId
);
1810 it
.needSend
:= False;
1815 reliableUpdate
: Boolean;
1820 // Ïîðà âûêëþ÷àòü èãðó:
1821 if gExit
= EXIT_QUIT
then
1823 // Èãðà çàêîí÷èëàñü - îáðàáàòûâàåì:
1827 if gExit
= EXIT_QUIT
then
1831 // ×èòàåì êëàâèàòóðó è äæîéñòèê, åñëè îêíî àêòèâíî
1832 // no need to, as we'll do it in event handler
1834 // Îáíîâëÿåì êîíñîëü (äâèæåíèå è ñîîáùåíèÿ):
1837 if (NetMode
= NET_NONE
) and (g_Game_IsNet
) and (gGameOn
or (gState
in [STATE_FOLD
, STATE_INTERCUSTOM
])) then
1839 gExit
:= EXIT_SIMPLE
;
1844 // process master server communications
1845 g_Net_Slist_Pulse();
1848 STATE_INTERSINGLE
, // Ñòàòèñòêà ïîñëå ïðîõîæäåíèÿ óðîâíÿ â Îäèíî÷íîé èãðå
1849 STATE_INTERCUSTOM
, // Ñòàòèñòêà ïîñëå ïðîõîæäåíèÿ óðîâíÿ â Ñâîåé èãðå
1850 STATE_INTERTEXT
, // Òåêñò ìåæäó óðîâíÿìè
1851 STATE_INTERPIC
: // Êàðòèíêà ìåæäó óðîâíÿìè
1853 if g_Game_IsNet
and g_Game_IsServer
then
1855 gInterTime
:= gInterTime
+ GAME_TICK
;
1856 a
:= Min((gInterEndTime
- gInterTime
) div 1000 + 1, 255);
1857 if a
<> gServInterTime
then
1859 gServInterTime
:= a
;
1860 MH_SEND_TimeSync(gServInterTime
);
1864 if (not g_Game_IsClient
) and
1868 e_KeyPressed(IK_RETURN
) or e_KeyPressed(IK_KPRETURN
) or e_KeyPressed(IK_SPACE
) or
1869 e_KeyPressed(VK_FIRE
) or e_KeyPressed(VK_OPEN
) or
1870 e_KeyPressed(JOY0_ATTACK
) or e_KeyPressed(JOY1_ATTACK
) or
1871 e_KeyPressed(JOY2_ATTACK
) or e_KeyPressed(JOY3_ATTACK
)
1873 and (not gJustChatted
) and (not gConsoleShow
) and (not gChatShow
)
1874 and (g_ActiveWindow
= nil)
1876 or (g_Game_IsNet
and ((gInterTime
> gInterEndTime
) or ((gInterReadyCount
>= NetClientCount
) and (NetClientCount
> 0))))
1879 begin // Íàæàëè <Enter>/<Ïðîáåë> èëè ïðîøëî äîñòàòî÷íî âðåìåíè:
1880 g_Game_StopAllSounds(True);
1882 if gMapOnce
then // Ýòî áûë òåñò
1883 gExit
:= EXIT_SIMPLE
1885 if gNextMap
<> '' then // Ïåðåõîäèì íà ñëåäóþùóþ êàðòó
1886 g_Game_ChangeMap(gNextMap
)
1887 else // Ñëåäóþùåé êàðòû íåò
1889 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
] then
1891 // Âûõîä â ãëàâíîå ìåíþ:
1893 g_GUI_ShowWindow('MainMenu');
1894 gMusic
.SetByName('MUSIC_MENU');
1896 gState
:= STATE_MENU
;
1899 // Ôèíàëüíàÿ êàðòèíêà:
1900 g_Game_ExecuteEvent('onwadend');
1902 if not gMusic
.SetByName('MUSIC_endmus') then
1903 gMusic
.SetByName('MUSIC_STDENDMUS');
1905 gState
:= STATE_ENDPIC
;
1907 g_Game_ExecuteEvent('ongameend');
1912 else if g_Game_IsClient
and
1915 e_KeyPressed(IK_RETURN
) or e_KeyPressed(IK_KPRETURN
) or e_KeyPressed(IK_SPACE
) or
1916 e_KeyPressed(VK_FIRE
) or e_KeyPressed(VK_OPEN
) or
1917 e_KeyPressed(JOY0_ATTACK
) or e_KeyPressed(JOY1_ATTACK
) or
1918 e_KeyPressed(JOY2_ATTACK
) or e_KeyPressed(JOY3_ATTACK
)
1920 and (not gJustChatted
) and (not gConsoleShow
) and (not gChatShow
)
1921 and (g_ActiveWindow
= nil)
1929 if gState
= STATE_INTERTEXT
then
1930 if InterText
.counter
> 0 then
1931 InterText
.counter
:= InterText
.counter
- 1;
1934 STATE_FOLD
: // Çàòóõàíèå ýêðàíà
1936 if EndingGameCounter
= 0 then
1938 // Çàêîí÷èëñÿ óðîâåíü â Ñâîåé èãðå:
1939 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
1941 gState
:= STATE_INTERCUSTOM
;
1942 InterReadyTime
:= -1;
1943 if gLastMap
and (gGameSettings
.GameMode
= GM_COOP
) then
1945 g_Game_ExecuteEvent('onwadend');
1946 if not gMusic
.SetByName('MUSIC_endmus') then
1947 gMusic
.SetByName('MUSIC_STDENDMUS');
1950 gMusic
.SetByName('MUSIC_ROUNDMUS');
1954 else // Çàêîí÷èëàñü ïîñëåäíÿÿ êàðòà â Îäèíî÷íîé èãðå
1956 gMusic
.SetByName('MUSIC_INTERMUS');
1958 gState
:= STATE_INTERSINGLE
;
1961 g_Game_ExecuteEvent('oninter');
1964 DecMin(EndingGameCounter
, 6, 0);
1967 STATE_ENDPIC
: // Êàðòèíêà îêîí÷àíèÿ ìåãàÂàäà
1969 if gMapOnce
then // Ýòî áûë òåñò
1971 gExit
:= EXIT_SIMPLE
;
1977 g_Serverlist_Control(slCurrent
, slTable
);
1980 // Ñòàòèñòèêà ïî Tab:
1982 IsDrawStat
:= (not gConsoleShow
) and (not gChatShow
) and (gGameSettings
.GameType
<> GT_SINGLE
) and g_Console_Action(ACTION_SCORES
);
1985 if gGameOn
and not gPause
and (gState
<> STATE_FOLD
) then
1987 // Âðåìÿ += 28 ìèëëèñåêóíä:
1988 gTime
:= gTime
+ GAME_TICK
;
1990 // Ñîîáùåíèå ïîñåðåäèíå ýêðàíà:
1991 if MessageTime
= 0 then
1993 if MessageTime
> 0 then
1994 MessageTime
:= MessageTime
- 1;
1996 if (g_Game_IsServer
) then
1998 // Áûë çàäàí ëèìèò âðåìåíè:
1999 if (gGameSettings
.TimeLimit
> 0) then
2000 if (gTime
- gGameStartTime
) div 1000 >= gGameSettings
.TimeLimit
then
2001 begin // Îí ïðîøåë => êîíåö óðîâíÿ
2006 // Íàäî ðåñïàâíèòü èãðîêîâ â LMS:
2007 if (gLMSRespawn
> LMS_RESPAWN_NONE
) and (gLMSRespawnTime
< gTime
) then
2008 g_Game_RestartRound(gLMSSoftSpawn
);
2010 // Ïðîâåðèì ðåçóëüòàò ãîëîñîâàíèÿ, åñëè âðåìÿ ïðîøëî
2011 if gVoteInProgress
and (gVoteTimer
< gTime
) then
2013 else if gVotePassed
and (gVoteCmdTimer
< gTime
) then
2015 g_Console_Process(gVoteCommand
);
2017 gVotePassed
:= False;
2020 // Çàìåðÿåì âðåìÿ çàõâàòà ôëàãîâ
2021 if gFlags
[FLAG_RED
].State
= FLAG_STATE_CAPTURED
then
2022 gFlags
[FLAG_RED
].CaptureTime
:= gFlags
[FLAG_RED
].CaptureTime
+ GAME_TICK
;
2023 if gFlags
[FLAG_BLUE
].State
= FLAG_STATE_CAPTURED
then
2024 gFlags
[FLAG_BLUE
].CaptureTime
:= gFlags
[FLAG_BLUE
].CaptureTime
+ GAME_TICK
;
2026 // Áûë çàäàí ëèìèò ïîáåä:
2027 if (gGameSettings
.ScoreLimit
> 0) then
2031 if gGameSettings
.GameMode
= GM_DM
then
2032 begin // Â DM èùåì èãðîêà ñ max ôðàãàìè
2033 for i
:= 0 to High(gPlayers
) do
2034 if gPlayers
[i
] <> nil then
2035 if gPlayers
[i
].Frags
> b
then
2036 b
:= gPlayers
[i
].Frags
;
2039 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
2040 begin //  CTF/TDM âûáèðàåì êîìàíäó ñ íàèáîëüøèì ñ÷åòîì
2041 b
:= Max(gTeamStat
[TEAM_RED
].Score
, gTeamStat
[TEAM_BLUE
].Score
);
2044 // Ëèìèò ïîáåä íàáðàí => êîíåö óðîâíÿ:
2045 if b
>= gGameSettings
.ScoreLimit
then
2052 // Îáðàáàòûâàåì êëàâèøè èãðîêîâ:
2053 if gPlayer1
<> nil then gPlayer1
.ReleaseKeys();
2054 if gPlayer2
<> nil then gPlayer2
.ReleaseKeys();
2055 if (not gConsoleShow
) and (not gChatShow
) and (g_ActiveWindow
= nil) then
2057 ProcessPlayerControls(gPlayer1
, 0, P1MoveButton
);
2058 ProcessPlayerControls(gPlayer2
, 1, P2MoveButton
);
2059 end // if not console
2062 if g_Game_IsNet
and (gPlayer1
<> nil) then gPlayer1
.PressKey(KEY_CHAT
, 10000);
2064 // process weapon switch queue
2068 if (gPlayer1
= nil) and (gPlayer2
= nil) and
2069 (not gConsoleShow
) and (not gChatShow
) and (g_ActiveWindow
= nil) then
2071 if not gSpectKeyPress
then
2073 if gPlayerAction
[0, ACTION_JUMP
] and (not gSpectAuto
) then
2075 // switch spect mode
2077 SPECT_NONE
: ; // not spectator
2079 SPECT_MAPVIEW
: Inc(gSpectMode
);
2080 SPECT_PLAYERS
: gSpectMode
:= SPECT_STATS
; // reset to 1
2082 gSpectKeyPress
:= True;
2084 if (gSpectMode
= SPECT_MAPVIEW
)
2085 and (not gSpectAuto
) then
2087 if gPlayerAction
[0, ACTION_MOVELEFT
] then
2088 gSpectX
:= Max(gSpectX
- gSpectStep
, 0);
2089 if gPlayerAction
[0, ACTION_MOVERIGHT
] then
2090 gSpectX
:= Min(gSpectX
+ gSpectStep
, gMapInfo
.Width
- gScreenWidth
);
2091 if gPlayerAction
[0, ACTION_LOOKUP
] then
2092 gSpectY
:= Max(gSpectY
- gSpectStep
, 0);
2093 if gPlayerAction
[0, ACTION_LOOKDOWN
] then
2094 gSpectY
:= Min(gSpectY
+ gSpectStep
, gMapInfo
.Height
- gScreenHeight
);
2095 if gWeaponAction
[0, WP_PREV
] then
2098 if gSpectStep
> 4 then gSpectStep
:= gSpectStep
shr 1;
2099 gWeaponAction
[0, WP_PREV
] := False;
2101 if gWeaponAction
[0, WP_NEXT
] then
2104 if gSpectStep
< 64 then gSpectStep
:= gSpectStep
shl 1;
2105 gWeaponAction
[0, WP_NEXT
] := False;
2108 if (gSpectMode
= SPECT_PLAYERS
)
2109 and (not gSpectAuto
) then
2111 if gPlayerAction
[0, ACTION_LOOKUP
] then
2114 gSpectViewTwo
:= True;
2115 gSpectKeyPress
:= True;
2117 if gPlayerAction
[0, ACTION_LOOKDOWN
] then
2119 // remove second view
2120 gSpectViewTwo
:= False;
2121 gSpectKeyPress
:= True;
2123 if gPlayerAction
[0, ACTION_MOVELEFT
] then
2125 // prev player (view 1)
2126 gSpectPID1
:= GetActivePlayerID_Prev(gSpectPID1
);
2127 gSpectKeyPress
:= True;
2129 if gPlayerAction
[0, ACTION_MOVERIGHT
] then
2131 // next player (view 1)
2132 gSpectPID1
:= GetActivePlayerID_Next(gSpectPID1
);
2133 gSpectKeyPress
:= True;
2135 if gWeaponAction
[0, WP_PREV
] then
2137 // prev player (view 2)
2138 gSpectPID2
:= GetActivePlayerID_Prev(gSpectPID2
);
2139 gWeaponAction
[0, WP_PREV
] := False;
2141 if gWeaponAction
[0, WP_NEXT
] then
2143 // next player (view 2)
2144 gSpectPID2
:= GetActivePlayerID_Next(gSpectPID2
);
2145 gWeaponAction
[0, WP_NEXT
] := False;
2148 if gPlayerAction
[0, ACTION_ATTACK
] then
2150 if (gSpectMode
= SPECT_STATS
) and (not gSpectAuto
) then
2153 gSpectAutoNext
:= 0;
2154 gSpectViewTwo
:= False;
2155 gSpectKeyPress
:= True;
2160 gSpectMode
:= SPECT_STATS
;
2161 gSpectAuto
:= False;
2162 gSpectKeyPress
:= True;
2167 if (not gPlayerAction
[0, ACTION_JUMP
]) and
2168 (not gPlayerAction
[0, ACTION_ATTACK
]) and
2169 (not gPlayerAction
[0, ACTION_MOVELEFT
]) and
2170 (not gPlayerAction
[0, ACTION_MOVERIGHT
]) and
2171 (not gPlayerAction
[0, ACTION_LOOKUP
]) and
2172 (not gPlayerAction
[0, ACTION_LOOKDOWN
]) then
2173 gSpectKeyPress
:= False;
2177 if gSpectMode
= SPECT_MAPVIEW
then
2179 i
:= Min(Max(gSpectX
+ gSpectAutoStepX
, 0), gMapInfo
.Width
- gScreenWidth
);
2181 gSpectAutoNext
:= gTime
2184 i
:= Min(Max(gSpectY
+ gSpectAutoStepY
, 0), gMapInfo
.Height
- gScreenHeight
);
2186 gSpectAutoNext
:= gTime
2190 if gSpectAutoNext
<= gTime
then
2192 if gSpectAutoNext
> 0 then
2194 gSpectMode
:= GetRandomSpectMode(gSpectMode
);
2198 gSpectX
:= Random(gMapInfo
.Width
- gScreenWidth
);
2199 gSpectY
:= Random(gMapInfo
.Height
- gScreenHeight
);
2200 gSpectAutoStepX
:= Random(9) - 4;
2201 gSpectAutoStepY
:= Random(9) - 4;
2202 if ((gSpectX
< 800) and (gSpectAutoStepX
< 0)) or
2203 ((gSpectX
> gMapInfo
.Width
- gScreenWidth
- 800) and (gSpectAutoStepX
> 0)) then
2204 gSpectAutoStepX
:= gSpectAutoStepX
* -1;
2205 if ((gSpectY
< 800) and (gSpectAutoStepY
< 0)) or
2206 ((gSpectY
> gMapInfo
.Height
- gScreenHeight
- 800) and (gSpectAutoStepY
> 0)) then
2207 gSpectAutoStepY
:= gSpectAutoStepY
* -1;
2211 gSpectPID1
:= GetActivePlayerID_Random(gSpectPID1
);
2216 SPECT_STATS
: gSpectAutoNext
:= gTime
+ (Random(3) + 5) * 1000;
2217 SPECT_MAPVIEW
: gSpectAutoNext
:= gTime
+ (Random(4) + 7) * 1000;
2218 SPECT_PLAYERS
: gSpectAutoNext
:= gTime
+ (Random(7) + 8) * 1000;
2224 // Îáíîâëÿåì âñå îñòàëüíîå:
2227 g_Triggers_Update();
2229 g_Monsters_Update();
2231 g_Player_UpdateAll();
2232 g_Player_UpdatePhysicalObjects();
2234 // server: send newly spawned monsters unconditionally
2235 if (gGameSettings
.GameType
= GT_SERVER
) then
2237 if (Length(gMonstersSpawned
) > 0) then
2239 for I
:= 0 to High(gMonstersSpawned
) do MH_SEND_MonsterSpawn(gMonstersSpawned
[I
]);
2240 SetLength(gMonstersSpawned
, 0);
2244 if (gSoundTriggerTime
> 8) then
2246 g_Game_UpdateTriggerSounds();
2247 gSoundTriggerTime
:= 0;
2251 Inc(gSoundTriggerTime
);
2254 if (NetMode
= NET_SERVER
) then
2256 Inc(NetTimeToUpdate
);
2257 Inc(NetTimeToReliable
);
2259 // send monster updates
2260 if (NetTimeToReliable
>= NetRelupdRate
) or (NetTimeToUpdate
>= NetUpdateRate
) then
2262 // send all monsters (periodic sync)
2263 reliableUpdate
:= (NetTimeToReliable
>= NetRelupdRate
);
2265 for I
:= 0 to High(gPlayers
) do
2267 if (gPlayers
[I
] <> nil) then MH_SEND_PlayerPos(reliableUpdate
, gPlayers
[I
].UID
);
2270 g_Mons_ForEach(sendMonsPos
);
2272 // update flags that aren't stationary
2273 if gGameSettings
.GameMode
= GM_CTF
then
2274 for I
:= FLAG_RED
to FLAG_BLUE
do
2275 if gFlags
[I
].NeedSend
then
2277 gFlags
[I
].NeedSend
:= False;
2281 // update items that aren't stationary
2282 g_Items_ForEachAlive(sendItemPos
);
2284 if reliableUpdate
then
2286 NetTimeToReliable
:= 0;
2287 NetTimeToUpdate
:= NetUpdateRate
;
2291 NetTimeToUpdate
:= 0;
2296 // send only mosters with some unexpected changes
2297 g_Mons_ForEach(sendMonsPosUnexpected
);
2300 // send unexpected platform changes
2301 g_Map_NetSendInterestingPanels();
2303 g_Net_Slist_ServerUpdate();
2305 if NetUseMaster then
2307 if (gTime >= NetTimeToMaster) or g_Net_Slist_IsConnectionInProgress then
2309 if (not g_Net_Slist_IsConnectionActive) then g_Net_Slist_Connect(false); // non-blocking connection to the master
2311 NetTimeToMaster := gTime + NetMasterRate;
2316 else if (NetMode
= NET_CLIENT
) then
2318 MC_SEND_PlayerPos();
2320 end; // if gameOn ...
2322 // Àêòèâíî îêíî èíòåðôåéñà - ïåðåäàåì êëàâèøè åìó:
2323 if g_ActiveWindow
<> nil then
2325 w
:= e_GetFirstKeyPressed();
2327 if (w
<> IK_INVALID
) then
2329 Msg
.Msg
:= MESSAGE_DIKEY
;
2331 g_ActiveWindow
.OnMessage(Msg
);
2334 // Åñëè îíî îò ýòîãî íå çàêðûëîñü, òî îáíîâëÿåì:
2335 if g_ActiveWindow
<> nil then
2336 g_ActiveWindow
.Update();
2338 // Íóæíî ñìåíèòü ðàçðåøåíèå:
2339 if gResolutionChange
then
2341 e_WriteLog('Changing resolution', TMsgType
.Notify
);
2342 g_Game_ChangeResolution(gRC_Width
, gRC_Height
, gRC_FullScreen
, gRC_Maximized
);
2343 gResolutionChange
:= False;
2344 g_ActiveWindow
:= nil;
2347 // Íóæíî ñìåíèòü ÿçûê:
2348 if gLanguageChange
then
2350 //e_WriteLog('Read language file', MSG_NOTIFY);
2351 //g_Language_Load(DataDir + gLanguage + '.txt');
2352 g_Language_Set(gLanguage
);
2356 gLanguageChange
:= False;
2360 // Ãîðÿ÷àÿ êëàâèøà äëÿ âûçîâà ìåíþ âûõîäà èç èãðû (F10):
2361 if e_KeyPressed(IK_F10
) and
2363 (not gConsoleShow
) and
2364 (g_ActiveWindow
= nil) then
2369 Time
:= sys_GetTicks() {div 1000};
2371 // Îáðàáîòêà îòëîæåííûõ ñîáûòèé:
2372 if gDelayedEvents
<> nil then
2373 for a
:= 0 to High(gDelayedEvents
) do
2374 if gDelayedEvents
[a
].Pending
and
2376 ((gDelayedEvents
[a
].DEType
= DE_GLOBEVENT
) and (gDelayedEvents
[a
].Time
<= Time
)) or
2377 ((gDelayedEvents
[a
].DEType
> DE_GLOBEVENT
) and (gDelayedEvents
[a
].Time
<= gTime
))
2380 case gDelayedEvents
[a
].DEType
of
2382 g_Game_ExecuteEvent(gDelayedEvents
[a
].DEStr
);
2385 g_Game_Announce_GoodShot(gDelayedEvents
[a
].DENum
);
2389 g_Game_Announce_KillCombo(gDelayedEvents
[a
].DENum
);
2390 if g_Game_IsNet
and g_Game_IsServer
then
2391 MH_SEND_GameEvent(NET_EV_KILLCOMBO
, gDelayedEvents
[a
].DENum
);
2395 g_Game_Announce_BodyKill(gDelayedEvents
[a
].DENum
);
2397 gDelayedEvents
[a
].Pending
:= False;
2400 // Êàæäóþ ñåêóíäó îáíîâëÿåì ñ÷åò÷èê îáíîâëåíèé:
2401 UPSCounter
:= UPSCounter
+ 1;
2402 if Time
- UPSTime
>= 1000 then
2411 g_Weapon_AddDynLights();
2412 g_Items_AddDynLights();
2416 procedure g_Game_LoadChatSounds(Resource
: string);
2419 FileName
, Snd
: string;
2421 len
, cnt
, tags
, i
, j
: Integer;
2424 FileName
:= g_ExtractWadName(Resource
);
2426 WAD
:= TWADFile
.Create();
2427 WAD
.ReadFile(FileName
);
2429 if not WAD
.GetResource(g_ExtractFilePathName(Resource
), p
, len
) then
2436 cfg
:= TConfig
.CreateMem(p
, len
);
2437 cnt
:= cfg
.ReadInt('ChatSounds', 'Count', 0);
2439 SetLength(gChatSounds
, cnt
);
2440 for i
:= 0 to Length(gChatSounds
) - 1 do
2442 gChatSounds
[i
].Sound
:= nil;
2443 Snd
:= Trim(cfg
.ReadStr(IntToStr(i
), 'Sound', ''));
2444 tags
:= cfg
.ReadInt(IntToStr(i
), 'Tags', 0);
2445 if (Snd
= '') or (Tags
<= 0) then
2447 g_Sound_CreateWADEx('SOUND_CHAT_MACRO' + IntToStr(i
), GameWAD
+':'+Snd
);
2448 gChatSounds
[i
].Sound
:= TPlayableSound
.Create();
2449 gChatSounds
[i
].Sound
.SetByName('SOUND_CHAT_MACRO' + IntToStr(i
));
2450 SetLength(gChatSounds
[i
].Tags
, tags
);
2451 for j
:= 0 to tags
- 1 do
2452 gChatSounds
[i
].Tags
[j
] := toLowerCase1251(cfg
.ReadStr(IntToStr(i
), 'Tag' + IntToStr(j
), ''));
2453 gChatSounds
[i
].FullWord
:= cfg
.ReadBool(IntToStr(i
), 'FullWord', False);
2460 procedure g_Game_FreeChatSounds();
2464 for i
:= 0 to Length(gChatSounds
) - 1 do
2466 gChatSounds
[i
].Sound
.Free();
2467 g_Sound_Delete('SOUND_CHAT_MACRO' + IntToStr(i
));
2469 SetLength(gChatSounds
, 0);
2473 procedure g_Game_LoadData();
2480 if DataLoaded
then Exit
;
2482 e_WriteLog('Loading game data...', TMsgType
.Notify
);
2484 g_Texture_CreateWADEx('NOTEXTURE', GameWAD
+':TEXTURES\NOTEXTURE');
2485 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUD', GameWAD
+':TEXTURES\HUD');
2486 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDAIR', GameWAD
+':TEXTURES\AIRBAR');
2487 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDJET', GameWAD
+':TEXTURES\JETBAR');
2488 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDBG', GameWAD
+':TEXTURES\HUDBG');
2489 g_Texture_CreateWADEx('TEXTURE_PLAYER_ARMORHUD', GameWAD
+':TEXTURES\ARMORHUD');
2490 g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG', GameWAD
+':TEXTURES\FLAGHUD_R_BASE');
2491 g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG_S', GameWAD
+':TEXTURES\FLAGHUD_R_STOLEN');
2492 g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG_D', GameWAD
+':TEXTURES\FLAGHUD_R_DROP');
2493 g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG', GameWAD
+':TEXTURES\FLAGHUD_B_BASE');
2494 g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG_S', GameWAD
+':TEXTURES\FLAGHUD_B_STOLEN');
2495 g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG_D', GameWAD
+':TEXTURES\FLAGHUD_B_DROP');
2496 g_Texture_CreateWADEx('TEXTURE_PLAYER_TALKBUBBLE', GameWAD
+':TEXTURES\TALKBUBBLE');
2497 g_Texture_CreateWADEx('TEXTURE_PLAYER_INVULPENTA', GameWAD
+':TEXTURES\PENTA');
2498 g_Texture_CreateWADEx('TEXTURE_PLAYER_INDICATOR', GameWAD
+':TEXTURES\PLRIND');
2501 if not g_Texture_CreateWADEx('UI_GFX_PBAR_LEFT', GameWAD
+':TEXTURES\LLEFT') then hasPBarGfx
:= false;
2502 if not g_Texture_CreateWADEx('UI_GFX_PBAR_MARKER', GameWAD
+':TEXTURES\LMARKER') then hasPBarGfx
:= false;
2503 if not g_Texture_CreateWADEx('UI_GFX_PBAR_MIDDLE', GameWAD
+':TEXTURES\LMIDDLE') then hasPBarGfx
:= false;
2504 if not g_Texture_CreateWADEx('UI_GFX_PBAR_RIGHT', GameWAD
+':TEXTURES\LRIGHT') then hasPBarGfx
:= false;
2508 g_Texture_GetSize('UI_GFX_PBAR_LEFT', wl
, hl
);
2509 g_Texture_GetSize('UI_GFX_PBAR_RIGHT', wr
, hr
);
2510 g_Texture_GetSize('UI_GFX_PBAR_MIDDLE', wb
, hb
);
2511 g_Texture_GetSize('UI_GFX_PBAR_MARKER', wm
, hm
);
2512 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
2518 hasPBarGfx
:= false;
2522 g_Frames_CreateWAD(nil, 'FRAMES_TELEPORT', GameWAD
+':TEXTURES\TELEPORT', 64, 64, 10, False);
2523 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH', GameWAD
+':WEAPONS\PUNCH', 64, 64, 4, False);
2524 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_UP', GameWAD
+':WEAPONS\PUNCH_UP', 64, 64, 4, False);
2525 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_DN', GameWAD
+':WEAPONS\PUNCH_DN', 64, 64, 4, False);
2526 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_BERSERK', GameWAD
+':WEAPONS\PUNCHB', 64, 64, 4, False);
2527 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_BERSERK_UP', GameWAD
+':WEAPONS\PUNCHB_UP', 64, 64, 4, False);
2528 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_BERSERK_DN', GameWAD
+':WEAPONS\PUNCHB_DN', 64, 64, 4, False);
2529 g_Sound_CreateWADEx('SOUND_GAME_TELEPORT', GameWAD
+':SOUNDS\TELEPORT');
2530 g_Sound_CreateWADEx('SOUND_GAME_NOTELEPORT', GameWAD
+':SOUNDS\NOTELEPORT');
2531 g_Sound_CreateWADEx('SOUND_GAME_SECRET', GameWAD
+':SOUNDS\SECRET');
2532 g_Sound_CreateWADEx('SOUND_GAME_DOOROPEN', GameWAD
+':SOUNDS\DOOROPEN');
2533 g_Sound_CreateWADEx('SOUND_GAME_DOORCLOSE', GameWAD
+':SOUNDS\DOORCLOSE');
2534 g_Sound_CreateWADEx('SOUND_GAME_BULK1', GameWAD
+':SOUNDS\BULK1');
2535 g_Sound_CreateWADEx('SOUND_GAME_BULK2', GameWAD
+':SOUNDS\BULK2');
2536 g_Sound_CreateWADEx('SOUND_GAME_BUBBLE1', GameWAD
+':SOUNDS\BUBBLE1');
2537 g_Sound_CreateWADEx('SOUND_GAME_BUBBLE2', GameWAD
+':SOUNDS\BUBBLE2');
2538 g_Sound_CreateWADEx('SOUND_GAME_BURNING', GameWAD
+':SOUNDS\BURNING');
2539 g_Sound_CreateWADEx('SOUND_GAME_SWITCH1', GameWAD
+':SOUNDS\SWITCH1');
2540 g_Sound_CreateWADEx('SOUND_GAME_SWITCH0', GameWAD
+':SOUNDS\SWITCH0');
2541 g_Sound_CreateWADEx('SOUND_GAME_RADIO', GameWAD
+':SOUNDS\RADIO');
2542 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD1', GameWAD
+':SOUNDS\GOOD1');
2543 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD2', GameWAD
+':SOUNDS\GOOD2');
2544 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD3', GameWAD
+':SOUNDS\GOOD3');
2545 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD4', GameWAD
+':SOUNDS\GOOD4');
2546 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL2X', GameWAD
+':SOUNDS\KILL2X');
2547 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL3X', GameWAD
+':SOUNDS\KILL3X');
2548 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL4X', GameWAD
+':SOUNDS\KILL4X');
2549 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILLMX', GameWAD
+':SOUNDS\KILLMX');
2550 g_Sound_CreateWADEx('SOUND_ANNOUNCER_MUHAHA1', GameWAD
+':SOUNDS\MUHAHA1');
2551 g_Sound_CreateWADEx('SOUND_ANNOUNCER_MUHAHA2', GameWAD
+':SOUNDS\MUHAHA2');
2552 g_Sound_CreateWADEx('SOUND_ANNOUNCER_MUHAHA3', GameWAD
+':SOUNDS\MUHAHA3');
2553 g_Sound_CreateWADEx('SOUND_CTF_GET1', GameWAD
+':SOUNDS\GETFLAG1');
2554 g_Sound_CreateWADEx('SOUND_CTF_GET2', GameWAD
+':SOUNDS\GETFLAG2');
2555 g_Sound_CreateWADEx('SOUND_CTF_LOST1', GameWAD
+':SOUNDS\LOSTFLG1');
2556 g_Sound_CreateWADEx('SOUND_CTF_LOST2', GameWAD
+':SOUNDS\LOSTFLG2');
2557 g_Sound_CreateWADEx('SOUND_CTF_RETURN1', GameWAD
+':SOUNDS\RETFLAG1');
2558 g_Sound_CreateWADEx('SOUND_CTF_RETURN2', GameWAD
+':SOUNDS\RETFLAG2');
2559 g_Sound_CreateWADEx('SOUND_CTF_CAPTURE1', GameWAD
+':SOUNDS\CAPFLAG1');
2560 g_Sound_CreateWADEx('SOUND_CTF_CAPTURE2', GameWAD
+':SOUNDS\CAPFLAG2');
2562 goodsnd
[0] := TPlayableSound
.Create();
2563 goodsnd
[1] := TPlayableSound
.Create();
2564 goodsnd
[2] := TPlayableSound
.Create();
2565 goodsnd
[3] := TPlayableSound
.Create();
2567 goodsnd
[0].SetByName('SOUND_ANNOUNCER_GOOD1');
2568 goodsnd
[1].SetByName('SOUND_ANNOUNCER_GOOD2');
2569 goodsnd
[2].SetByName('SOUND_ANNOUNCER_GOOD3');
2570 goodsnd
[3].SetByName('SOUND_ANNOUNCER_GOOD4');
2572 killsnd
[0] := TPlayableSound
.Create();
2573 killsnd
[1] := TPlayableSound
.Create();
2574 killsnd
[2] := TPlayableSound
.Create();
2575 killsnd
[3] := TPlayableSound
.Create();
2577 killsnd
[0].SetByName('SOUND_ANNOUNCER_KILL2X');
2578 killsnd
[1].SetByName('SOUND_ANNOUNCER_KILL3X');
2579 killsnd
[2].SetByName('SOUND_ANNOUNCER_KILL4X');
2580 killsnd
[3].SetByName('SOUND_ANNOUNCER_KILLMX');
2582 hahasnd
[0] := TPlayableSound
.Create();
2583 hahasnd
[1] := TPlayableSound
.Create();
2584 hahasnd
[2] := TPlayableSound
.Create();
2586 hahasnd
[0].SetByName('SOUND_ANNOUNCER_MUHAHA1');
2587 hahasnd
[1].SetByName('SOUND_ANNOUNCER_MUHAHA2');
2588 hahasnd
[2].SetByName('SOUND_ANNOUNCER_MUHAHA3');
2590 sound_get_flag
[0] := TPlayableSound
.Create();
2591 sound_get_flag
[1] := TPlayableSound
.Create();
2592 sound_lost_flag
[0] := TPlayableSound
.Create();
2593 sound_lost_flag
[1] := TPlayableSound
.Create();
2594 sound_ret_flag
[0] := TPlayableSound
.Create();
2595 sound_ret_flag
[1] := TPlayableSound
.Create();
2596 sound_cap_flag
[0] := TPlayableSound
.Create();
2597 sound_cap_flag
[1] := TPlayableSound
.Create();
2599 sound_get_flag
[0].SetByName('SOUND_CTF_GET1');
2600 sound_get_flag
[1].SetByName('SOUND_CTF_GET2');
2601 sound_lost_flag
[0].SetByName('SOUND_CTF_LOST1');
2602 sound_lost_flag
[1].SetByName('SOUND_CTF_LOST2');
2603 sound_ret_flag
[0].SetByName('SOUND_CTF_RETURN1');
2604 sound_ret_flag
[1].SetByName('SOUND_CTF_RETURN2');
2605 sound_cap_flag
[0].SetByName('SOUND_CTF_CAPTURE1');
2606 sound_cap_flag
[1].SetByName('SOUND_CTF_CAPTURE2');
2608 g_Game_LoadChatSounds(GameWAD
+':CHATSND\SNDCFG');
2610 g_Game_SetLoadingText(_lc
[I_LOAD_ITEMS_DATA
], 0, False);
2613 g_Game_SetLoadingText(_lc
[I_LOAD_WEAPONS_DATA
], 0, False);
2614 g_Weapon_LoadData();
2616 g_Monsters_LoadData();
2621 procedure g_Game_FreeData();
2623 if not DataLoaded
then Exit
;
2626 g_Weapon_FreeData();
2627 g_Monsters_FreeData();
2629 e_WriteLog('Releasing game data...', TMsgType
.Notify
);
2631 g_Texture_Delete('NOTEXTURE');
2632 g_Texture_Delete('TEXTURE_PLAYER_HUD');
2633 g_Texture_Delete('TEXTURE_PLAYER_HUDBG');
2634 g_Texture_Delete('TEXTURE_PLAYER_ARMORHUD');
2635 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG');
2636 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG_S');
2637 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG_D');
2638 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG');
2639 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG_S');
2640 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG_D');
2641 g_Texture_Delete('TEXTURE_PLAYER_TALKBUBBLE');
2642 g_Texture_Delete('TEXTURE_PLAYER_INVULPENTA');
2643 g_Frames_DeleteByName('FRAMES_TELEPORT');
2644 g_Frames_DeleteByName('FRAMES_PUNCH');
2645 g_Frames_DeleteByName('FRAMES_PUNCH_UP');
2646 g_Frames_DeleteByName('FRAMES_PUNCH_DN');
2647 g_Frames_DeleteByName('FRAMES_PUNCH_BERSERK');
2648 g_Frames_DeleteByName('FRAMES_PUNCH_BERSERK_UP');
2649 g_Frames_DeleteByName('FRAMES_PUNCH_BERSERK_DN');
2650 g_Sound_Delete('SOUND_GAME_TELEPORT');
2651 g_Sound_Delete('SOUND_GAME_NOTELEPORT');
2652 g_Sound_Delete('SOUND_GAME_SECRET');
2653 g_Sound_Delete('SOUND_GAME_DOOROPEN');
2654 g_Sound_Delete('SOUND_GAME_DOORCLOSE');
2655 g_Sound_Delete('SOUND_GAME_BULK1');
2656 g_Sound_Delete('SOUND_GAME_BULK2');
2657 g_Sound_Delete('SOUND_GAME_BUBBLE1');
2658 g_Sound_Delete('SOUND_GAME_BUBBLE2');
2659 g_Sound_Delete('SOUND_GAME_BURNING');
2660 g_Sound_Delete('SOUND_GAME_SWITCH1');
2661 g_Sound_Delete('SOUND_GAME_SWITCH0');
2668 g_Sound_Delete('SOUND_ANNOUNCER_GOOD1');
2669 g_Sound_Delete('SOUND_ANNOUNCER_GOOD2');
2670 g_Sound_Delete('SOUND_ANNOUNCER_GOOD3');
2671 g_Sound_Delete('SOUND_ANNOUNCER_GOOD4');
2678 g_Sound_Delete('SOUND_ANNOUNCER_KILL2X');
2679 g_Sound_Delete('SOUND_ANNOUNCER_KILL3X');
2680 g_Sound_Delete('SOUND_ANNOUNCER_KILL4X');
2681 g_Sound_Delete('SOUND_ANNOUNCER_KILLMX');
2687 g_Sound_Delete('SOUND_ANNOUNCER_MUHAHA1');
2688 g_Sound_Delete('SOUND_ANNOUNCER_MUHAHA2');
2689 g_Sound_Delete('SOUND_ANNOUNCER_MUHAHA3');
2691 sound_get_flag
[0].Free();
2692 sound_get_flag
[1].Free();
2693 sound_lost_flag
[0].Free();
2694 sound_lost_flag
[1].Free();
2695 sound_ret_flag
[0].Free();
2696 sound_ret_flag
[1].Free();
2697 sound_cap_flag
[0].Free();
2698 sound_cap_flag
[1].Free();
2700 g_Sound_Delete('SOUND_CTF_GET1');
2701 g_Sound_Delete('SOUND_CTF_GET2');
2702 g_Sound_Delete('SOUND_CTF_LOST1');
2703 g_Sound_Delete('SOUND_CTF_LOST2');
2704 g_Sound_Delete('SOUND_CTF_RETURN1');
2705 g_Sound_Delete('SOUND_CTF_RETURN2');
2706 g_Sound_Delete('SOUND_CTF_CAPTURE1');
2707 g_Sound_Delete('SOUND_CTF_CAPTURE2');
2709 g_Game_FreeChatSounds();
2711 DataLoaded
:= False;
2714 procedure DrawCustomStat();
2720 ww2
, hh2
, r
, g
, b
, rr
, gg
, bb
: Byte;
2721 s1
, s2
, topstr
: String;
2723 e_TextureFontGetSize(gStdFont
, ww2
, hh2
);
2727 if g_Console_Action(ACTION_SCORES
) then
2729 if not gStatsPressed
then
2731 gStatsOff
:= not gStatsOff
;
2732 gStatsPressed
:= True;
2736 gStatsPressed
:= False;
2740 s1
:= _lc
[I_MENU_INTER_NOTICE_TAB
];
2741 w
:= (Length(s1
) * ww2
) div 2;
2742 x
:= gScreenWidth
div 2 - w
;
2744 e_TextureFontPrint(x
, y
, s1
, gStdFont
);
2748 if (gGameSettings
.GameMode
= GM_COOP
) then
2750 if gMissionFailed
then
2751 topstr
:= _lc
[I_MENU_INTER_MISSION_FAIL
]
2753 topstr
:= _lc
[I_MENU_INTER_LEVEL_COMPLETE
];
2756 topstr
:= _lc
[I_MENU_INTER_ROUND_OVER
];
2758 e_CharFont_GetSize(gMenuFont
, topstr
, ww1
, hh1
);
2759 e_CharFont_Print(gMenuFont
, (gScreenWidth
div 2)-(ww1
div 2), 16, topstr
);
2761 if g_Game_IsNet
then
2763 topstr
:= Format(_lc
[I_MENU_INTER_NOTICE_TIME
], [gServInterTime
]);
2764 if not gChatShow
then
2765 e_TextureFontPrintEx((gScreenWidth
div 2)-(Length(topstr
)*ww2
div 2),
2766 gScreenHeight
-(hh2
+4)*2, topstr
, gStdFont
, 255, 255, 255, 1);
2769 if g_Game_IsClient
then
2770 topstr
:= _lc
[I_MENU_INTER_NOTICE_MAP
]
2772 topstr
:= _lc
[I_MENU_INTER_NOTICE_SPACE
];
2773 if not gChatShow
then
2774 e_TextureFontPrintEx((gScreenWidth
div 2)-(Length(topstr
)*ww2
div 2),
2775 gScreenHeight
-(hh2
+4), topstr
, gStdFont
, 255, 255, 255, 1);
2780 w
:= gScreenWidth
-x
*2;
2786 e_DrawFillQuad(x
, y
, gScreenWidth
-x
-1, gScreenHeight
-y
-1, 64, 64, 64, 32);
2787 e_DrawQuad(x
, y
, gScreenWidth
-x
-1, gScreenHeight
-y
-1, 255, 127, 0);
2789 m
:= Max(Length(_lc
[I_MENU_MAP
])+1, Length(_lc
[I_GAME_GAME_TIME
])+1)*ww2
;
2791 case CustomStat
.GameMode
of
2794 if gGameSettings
.MaxLives
= 0 then
2795 s1
:= _lc
[I_GAME_DM
]
2797 s1
:= _lc
[I_GAME_LMS
];
2801 if gGameSettings
.MaxLives
= 0 then
2802 s1
:= _lc
[I_GAME_TDM
]
2804 s1
:= _lc
[I_GAME_TLMS
];
2806 GM_CTF
: s1
:= _lc
[I_GAME_CTF
];
2809 if gGameSettings
.MaxLives
= 0 then
2810 s1
:= _lc
[I_GAME_COOP
]
2812 s1
:= _lc
[I_GAME_SURV
];
2818 e_TextureFontPrintEx(x
+(w
div 2)-(Length(s1
)*ww2
div 2), _y
, s1
, gStdFont
, 255, 255, 255, 1);
2822 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_MENU_MAP
], gStdFont
, 255, 127, 0, 1);
2823 e_TextureFontPrint(x
+8+m
, _y
, Format('%s - %s', [CustomStat
.Map
, CustomStat
.MapName
]), gStdFont
);
2826 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_GAME_TIME
], gStdFont
, 255, 127, 0, 1);
2827 e_TextureFontPrint(x
+8+m
, _y
, Format('%d:%.2d:%.2d', [CustomStat
.GameTime
div 1000 div 3600,
2828 (CustomStat
.GameTime
div 1000 div 60) mod 60,
2829 CustomStat
.GameTime
div 1000 mod 60]), gStdFont
);
2831 pc
:= Length(CustomStat
.PlayerStat
);
2832 if pc
= 0 then Exit
;
2834 if CustomStat
.GameMode
= GM_COOP
then
2836 m
:= Max(Length(_lc
[I_GAME_MONSTERS
])+1, Length(_lc
[I_GAME_SECRETS
])+1)*ww2
;
2838 s2
:= _lc
[I_GAME_MONSTERS
];
2839 e_TextureFontPrintEx(x
+8, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2840 e_TextureFontPrintEx(x
+8+m
, _y
, IntToStr(gCoopMonstersKilled
) + '/' + IntToStr(gTotalMonsters
), gStdFont
, 255, 255, 255, 1);
2842 s2
:= _lc
[I_GAME_SECRETS
];
2843 e_TextureFontPrintEx(x
+8, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2844 e_TextureFontPrintEx(x
+8+m
, _y
, IntToStr(gCoopSecretsFound
) + '/' + IntToStr(gSecretsCount
), gStdFont
, 255, 255, 255, 1);
2847 m
:= Max(Length(_lc
[I_GAME_MONSTERS_TOTAL
])+1, Length(_lc
[I_GAME_SECRETS_TOTAL
])+1)*ww2
;
2849 s2
:= _lc
[I_GAME_MONSTERS_TOTAL
];
2850 e_TextureFontPrintEx(x
+250, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2851 e_TextureFontPrintEx(x
+250+m
, _y
, IntToStr(gCoopTotalMonstersKilled
) + '/' + IntToStr(gCoopTotalMonsters
), gStdFont
, 255, 255, 255, 1);
2853 s2
:= _lc
[I_GAME_SECRETS_TOTAL
];
2854 e_TextureFontPrintEx(x
+250, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2855 e_TextureFontPrintEx(x
+250+m
, _y
, IntToStr(gCoopTotalSecretsFound
) + '/' + IntToStr(gCoopTotalSecrets
), gStdFont
, 255, 255, 255, 1);
2859 if CustomStat
.GameMode
in [GM_TDM
, GM_CTF
] then
2864 if TeamStat
[TEAM_RED
].Score
> TeamStat
[TEAM_BLUE
].Score
then s1
:= _lc
[I_GAME_WIN_RED
]
2865 else if TeamStat
[TEAM_BLUE
].Score
> TeamStat
[TEAM_RED
].Score
then s1
:= _lc
[I_GAME_WIN_BLUE
]
2866 else s1
:= _lc
[I_GAME_WIN_DRAW
];
2868 e_TextureFontPrintEx(x
+8+(w
div 2)-(Length(s1
)*ww2
div 2), _y
, s1
, gStdFont
, 255, 255, 255, 1);
2871 for t
:= TEAM_RED
to TEAM_BLUE
do
2873 if t
= TEAM_RED
then
2875 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_TEAM_RED
],
2876 gStdFont
, 255, 0, 0, 1);
2877 e_TextureFontPrintEx(x
+w1
+8, _y
, IntToStr(CustomStat
.TeamStat
[TEAM_RED
].Score
),
2878 gStdFont
, 255, 0, 0, 1);
2885 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_TEAM_BLUE
],
2886 gStdFont
, 0, 0, 255, 1);
2887 e_TextureFontPrintEx(x
+w1
+8, _y
, IntToStr(CustomStat
.TeamStat
[TEAM_BLUE
].Score
),
2888 gStdFont
, 0, 0, 255, 1);
2894 e_DrawLine(1, x
+8, _y
+20, x
-8+w
, _y
+20, r
, g
, b
);
2897 for p
:= 0 to High(CustomStat
.PlayerStat
) do
2898 if CustomStat
.PlayerStat
[p
].Team
= t
then
2899 with CustomStat
.PlayerStat
[p
] do
2913 if (gPlayers
[Num
] <> nil) and (gPlayers
[Num
].FReady
) then
2914 e_TextureFontPrintEx(x
+16, _y
, Name
+ ' *', gStdFont
, rr
, gg
, bb
, 1)
2916 e_TextureFontPrintEx(x
+16, _y
, Name
, gStdFont
, rr
, gg
, bb
, 1);
2917 e_TextureFontPrintEx(x
+w1
+16, _y
, IntToStr(Frags
), gStdFont
, rr
, gg
, bb
, 1);
2918 e_TextureFontPrintEx(x
+w1
+w2
+16, _y
, IntToStr(Deaths
), gStdFont
, rr
, gg
, bb
, 1);
2925 else if CustomStat
.GameMode
in [GM_DM
, GM_COOP
] then
2928 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_PLAYER_NAME
], gStdFont
, 255, 127, 0, 1);
2929 e_TextureFontPrintEx(x
+8+w1
, _y
, _lc
[I_GAME_FRAGS
], gStdFont
, 255, 127, 0, 1);
2930 e_TextureFontPrintEx(x
+8+w1
+w2
, _y
, _lc
[I_GAME_DEATHS
], gStdFont
, 255, 127, 0, 1);
2933 for p
:= 0 to High(CustomStat
.PlayerStat
) do
2934 with CustomStat
.PlayerStat
[p
] do
2936 e_DrawFillQuad(x
+8, _y
+4, x
+24-1, _y
+16+4-1, Color
.R
, Color
.G
, Color
.B
, 0);
2943 if (gPlayers
[Num
] <> nil) and (gPlayers
[Num
].FReady
) then
2944 e_TextureFontPrintEx(x
+8+16+8, _y
+4, Name
+ ' *', gStdFont
, r
, r
, r
, 1, True)
2946 e_TextureFontPrintEx(x
+8+16+8, _y
+4, Name
, gStdFont
, r
, r
, r
, 1, True);
2947 e_TextureFontPrintEx(x
+w1
+8+16+8, _y
+4, IntToStr(Frags
), gStdFont
, r
, r
, r
, 1, True);
2948 e_TextureFontPrintEx(x
+w1
+w2
+8+16+8, _y
+4, IntToStr(Deaths
), gStdFont
, r
, r
, r
, 1, True);
2953 // HACK: take stats screenshot immediately after the first frame of the stats showing
2954 if gScreenshotStats
and (not StatShotDone
) and (Length(CustomStat
.PlayerStat
) > 1) then
2956 g_TakeScreenShot('stats/' + StatFilename
);
2957 StatShotDone
:= True;
2961 procedure DrawSingleStat();
2963 tm
, key_x
, val_x
, y
: Integer;
2967 procedure player_stat(n
: Integer);
2973 s1
:= Format(' %d ', [SingleStat
.PlayerStat
[n
].Kills
]);
2974 s2
:= Format(' %d', [gTotalMonsters
]);
2976 e_CharFont_Print(gMenuFont
, key_x
, y
, _lc
[I_MENU_INTER_KILLS
]);
2977 e_CharFont_PrintEx(gMenuFont
, val_x
, y
, s1
, _RGB(255, 0, 0));
2978 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2979 e_CharFont_Print(gMenuFont
, val_x
+w1
, y
, '/');
2981 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2982 e_CharFont_PrintEx(gMenuFont
, val_x
+w1
, y
, s2
, _RGB(255, 0, 0));
2984 // "Kills-per-minute: ##.#":
2985 s1
:= _lc
[I_MENU_INTER_KPM
];
2987 kpm
:= (SingleStat
.PlayerStat
[n
].Kills
/ tm
) * 60
2989 kpm
:= SingleStat
.PlayerStat
[n
].Kills
;
2990 s2
:= Format(' %.1f', [kpm
]);
2992 e_CharFont_Print(gMenuFont
, key_x
, y
+32, s1
);
2993 e_CharFont_PrintEx(gMenuFont
, val_x
, y
+32, s2
, _RGB(255, 0, 0));
2995 // "Secrets found: # / #":
2996 s1
:= Format(' %d ', [SingleStat
.PlayerStat
[n
].Secrets
]);
2997 s2
:= Format(' %d', [SingleStat
.TotalSecrets
]);
2999 e_CharFont_Print(gMenuFont
, key_x
, y
+64, _lc
[I_MENU_INTER_SECRETS
]);
3000 e_CharFont_PrintEx(gMenuFont
, val_x
, y
+64, s1
, _RGB(255, 0, 0));
3001 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
3002 e_CharFont_Print(gMenuFont
, val_x
+w1
, y
+64, '/');
3004 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
3005 e_CharFont_PrintEx(gMenuFont
, val_x
+w1
, y
+64, s2
, _RGB(255, 0, 0));
3009 // "Level Complete":
3010 e_CharFont_GetSize(gMenuFont
, _lc
[I_MENU_INTER_LEVEL_COMPLETE
], w1
, h
);
3011 e_CharFont_Print(gMenuFont
, (gScreenWidth
-w1
) div 2, 32, _lc
[I_MENU_INTER_LEVEL_COMPLETE
]);
3013 // Îïðåäåëÿåì êîîðäèíàòû âûðàâíèâàíèÿ ïî ñàìîé äëèííîé ñòðîêå:
3014 s1
:= _lc
[I_MENU_INTER_KPM
];
3015 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
3018 e_CharFont_GetSize(gMenuFont
, s1
, w2
, h
);
3020 key_x
:= (gScreenWidth
-w1
-w2
) div 2;
3021 val_x
:= key_x
+ w1
;
3024 tm
:= SingleStat
.GameTime
div 1000;
3025 s1
:= _lc
[I_MENU_INTER_TIME
];
3026 s2
:= Format(' %d:%.2d:%.2d', [tm
div (60*60), (tm
mod (60*60)) div 60, tm
mod 60]);
3028 e_CharFont_Print(gMenuFont
, key_x
, 80, s1
);
3029 e_CharFont_PrintEx(gMenuFont
, val_x
, 80, s2
, _RGB(255, 0, 0));
3031 if SingleStat
.TwoPlayers
then
3034 s1
:= _lc
[I_MENU_PLAYER_1
];
3035 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
3036 e_CharFont_Print(gMenuFont
, (gScreenWidth
-w1
) div 2, 128, s1
);
3038 // Ñòàòèñòèêà ïåðâîãî èãðîêà:
3043 s1
:= _lc
[I_MENU_PLAYER_2
];
3044 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
3045 e_CharFont_Print(gMenuFont
, (gScreenWidth
-w1
) div 2, 288, s1
);
3047 // Ñòàòèñòèêà âòîðîãî èãðîêà:
3053 // Ñòàòèñòèêà ïåðâîãî èãðîêà:
3059 procedure DrawLoadingStat();
3060 procedure drawRect (x
, y
, w
, h
: Integer);
3062 if (w
< 1) or (h
< 1) then exit
;
3064 glVertex2f(x
+0.375, y
+0.375);
3065 glVertex2f(x
+w
+0.375, y
+0.375);
3066 glVertex2f(x
+w
+0.375, y
+h
+0.375);
3067 glVertex2f(x
+0.375, y
+h
+0.375);
3071 function drawPBar (cur
, total
: Integer; washere
: Boolean): Boolean;
3073 rectW
, rectH
: Integer;
3080 idl
, idr
, idb
, idm
: LongWord
;
3084 if (total
< 1) then exit
;
3085 if (cur
< 1) then exit
; // don't blink
3086 if (not washere
) and (cur
>= total
) then exit
; // don't blink
3087 //if (cur < 0) then cur := 0;
3088 //if (cur > total) then cur := total;
3091 if (hasPBarGfx
) then
3093 g_Texture_Get('UI_GFX_PBAR_LEFT', idl
);
3094 g_Texture_GetSize('UI_GFX_PBAR_LEFT', wl
, hl
);
3095 g_Texture_Get('UI_GFX_PBAR_RIGHT', idr
);
3096 g_Texture_GetSize('UI_GFX_PBAR_RIGHT', wr
, hr
);
3097 g_Texture_Get('UI_GFX_PBAR_MIDDLE', idb
);
3098 g_Texture_GetSize('UI_GFX_PBAR_MIDDLE', wb
, hb
);
3099 g_Texture_Get('UI_GFX_PBAR_MARKER', idm
);
3100 g_Texture_GetSize('UI_GFX_PBAR_MARKER', wm
, hm
);
3102 //rectW := gScreenWidth-360;
3103 rectW
:= trunc(624.0*gScreenWidth
/1024.0);
3106 x0
:= (gScreenWidth
-rectW
) div 2;
3107 y0
:= gScreenHeight
-rectH
-64;
3108 if (y0
< 2) then y0
:= 2;
3110 glEnable(GL_SCISSOR_TEST
);
3113 glScissor(x0
, gScreenHeight
-y0
-rectH
, rectW
, rectH
);
3114 e_DrawSize(idl
, x0
, y0
, 0, true, false, wl
, hl
);
3115 e_DrawSize(idr
, x0
+rectW
-wr
, y0
, 0, true, false, wr
, hr
);
3118 glScissor(x0
+wl
, gScreenHeight
-y0
-rectH
, rectW
-wl
-wr
, rectH
);
3120 while (f
< x0
+rectW
) do
3122 e_DrawSize(idb
, f
, y0
, 0, true, false, wb
, hb
);
3127 wdt
:= (rectW
-wl
-wr
)*cur
div total
;
3128 if (wdt
> rectW
-wl
-wr
) then wdt
:= rectW
-wr
-wr
;
3131 my
:= y0
; // don't be so smart, ketmar: +(rectH-wm) div 2;
3132 glScissor(x0
+wl
, gScreenHeight
-my
-rectH
, wdt
, hm
);
3136 e_DrawSize(idm
, f
, y0
, 0, true, false, wm
, hm
);
3142 glScissor(0, 0, gScreenWidth
, gScreenHeight
);
3146 rectW
:= gScreenWidth
-64;
3149 x0
:= (gScreenWidth
-rectW
) div 2;
3150 y0
:= gScreenHeight
-rectH
-64;
3151 if (y0
< 2) then y0
:= 2;
3153 glDisable(GL_BLEND
);
3154 glDisable(GL_TEXTURE_2D
);
3156 //glClearColor(0, 0, 0, 0);
3157 //glClear(GL_COLOR_BUFFER_BIT);
3159 glColor4ub(127, 127, 127, 255);
3160 drawRect(x0
-2, y0
-2, rectW
+4, rectH
+4);
3162 glColor4ub(0, 0, 0, 255);
3163 drawRect(x0
-1, y0
-1, rectW
+2, rectH
+2);
3165 glColor4ub(127, 127, 127, 255);
3166 wdt
:= rectW
*cur
div total
;
3167 if (wdt
> rectW
) then wdt
:= rectW
;
3168 drawRect(x0
, y0
, wdt
, rectH
);
3177 if (Length(LoadingStat
.Msgs
) = 0) then exit
;
3179 e_CharFont_GetSize(gMenuFont
, _lc
[I_MENU_LOADING
], ww
, hh
);
3180 yy
:= (gScreenHeight
div 3);
3181 e_CharFont_Print(gMenuFont
, (gScreenWidth
div 2)-(ww
div 2), yy
-2*hh
, _lc
[I_MENU_LOADING
]);
3182 xx
:= (gScreenWidth
div 3);
3186 for i
:= 0 to NextMsg
-1 do
3188 if (i
= (NextMsg
-1)) and (MaxValue
> 0) then
3189 s
:= Format('%s: %d/%d', [Msgs
[i
], CurValue
, MaxValue
])
3193 e_CharFont_PrintEx(gMenuSmallFont
, xx
, yy
, s
, _RGB(255, 0, 0));
3194 yy
:= yy
+ LOADING_INTERLINE
;
3195 PBarWasHere
:= drawPBar(CurValue
, MaxValue
, PBarWasHere
);
3200 procedure DrawMenuBackground(tex
: AnsiString
);
3206 if g_Texture_Get(tex
, ID
) then
3208 e_Clear(GL_COLOR_BUFFER_BIT
, 0, 0, 0);
3209 e_GetTextureSize(ID
, @w
, @h
);
3211 w
:= round(w
* 1.333 * (gScreenHeight
/ h
))
3213 w
:= trunc(w
* (gScreenHeight
/ h
));
3214 e_DrawSize(ID
, (gScreenWidth
- w
) div 2, 0, 0, False, False, w
, gScreenHeight
);
3216 else e_Clear(GL_COLOR_BUFFER_BIT
, 0, 0, 0);
3219 procedure DrawMinimap(p
: TPlayer
; RenderRect
: e_graphics
.TRect
);
3221 a
, aX
, aY
, aX2
, aY2
, Scale
, ScaleSz
: Integer;
3223 function monDraw (mon
: TMonster
): Boolean;
3225 result
:= false; // don't stop
3230 // Ëåâûé âåðõíèé óãîë
3231 aX
:= Obj
.X
div ScaleSz
+ 1;
3232 aY
:= Obj
.Y
div ScaleSz
+ 1;
3234 aX2
:= max(Obj
.Rect
.Width
div ScaleSz
, 1);
3235 aY2
:= max(Obj
.Rect
.Height
div ScaleSz
, 1);
3236 // Ïðàâûé íèæíèé óãîë
3237 aX2
:= aX
+ aX2
- 1;
3238 aY2
:= aY
+ aY2
- 1;
3239 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 255, 0, 0);
3245 if (gMapInfo
.Width
> RenderRect
.Right
- RenderRect
.Left
) or
3246 (gMapInfo
.Height
> RenderRect
.Bottom
- RenderRect
.Top
) then
3249 // Ñêîëüêî ïèêñåëîâ êàðòû â 1 ïèêñåëå ìèíè-êàðòû:
3250 ScaleSz
:= 16 div Scale
;
3251 // Ðàçìåðû ìèíè-êàðòû:
3252 aX
:= max(gMapInfo
.Width
div ScaleSz
, 1);
3253 aY
:= max(gMapInfo
.Height
div ScaleSz
, 1);
3255 e_DrawFillQuad(0, 0, aX
-1, aY
-1, 0, 0, 0, 0);
3257 if gWalls
<> nil then
3260 for a
:= 0 to High(gWalls
) do
3262 if PanelType
<> 0 then
3264 // Ëåâûé âåðõíèé óãîë:
3265 aX
:= X
div ScaleSz
;
3266 aY
:= Y
div ScaleSz
;
3268 aX2
:= max(Width
div ScaleSz
, 1);
3269 aY2
:= max(Height
div ScaleSz
, 1);
3270 // Ïðàâûé íèæíèé óãîë:
3271 aX2
:= aX
+ aX2
- 1;
3272 aY2
:= aY
+ aY2
- 1;
3275 PANEL_WALL
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 208, 208, 208, 0);
3276 PANEL_OPENDOOR
, PANEL_CLOSEDOOR
:
3277 if Enabled
then e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 160, 160, 160, 0);
3281 if gSteps
<> nil then
3284 for a
:= 0 to High(gSteps
) do
3286 if PanelType
<> 0 then
3288 // Ëåâûé âåðõíèé óãîë:
3289 aX
:= X
div ScaleSz
;
3290 aY
:= Y
div ScaleSz
;
3292 aX2
:= max(Width
div ScaleSz
, 1);
3293 aY2
:= max(Height
div ScaleSz
, 1);
3294 // Ïðàâûé íèæíèé óãîë:
3295 aX2
:= aX
+ aX2
- 1;
3296 aY2
:= aY
+ aY2
- 1;
3298 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 128, 128, 128, 0);
3301 if gLifts
<> nil then
3304 for a
:= 0 to High(gLifts
) do
3306 if PanelType
<> 0 then
3308 // Ëåâûé âåðõíèé óãîë:
3309 aX
:= X
div ScaleSz
;
3310 aY
:= Y
div ScaleSz
;
3312 aX2
:= max(Width
div ScaleSz
, 1);
3313 aY2
:= max(Height
div ScaleSz
, 1);
3314 // Ïðàâûé íèæíèé óãîë:
3315 aX2
:= aX
+ aX2
- 1;
3316 aY2
:= aY
+ aY2
- 1;
3319 LIFTTYPE_UP
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 116, 72, 36, 0);
3320 LIFTTYPE_DOWN
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 116, 124, 96, 0);
3321 LIFTTYPE_LEFT
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 200, 80, 4, 0);
3322 LIFTTYPE_RIGHT
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 252, 140, 56, 0);
3326 if gWater
<> nil then
3329 for a
:= 0 to High(gWater
) do
3331 if PanelType
<> 0 then
3333 // Ëåâûé âåðõíèé óãîë:
3334 aX
:= X
div ScaleSz
;
3335 aY
:= Y
div ScaleSz
;
3337 aX2
:= max(Width
div ScaleSz
, 1);
3338 aY2
:= max(Height
div ScaleSz
, 1);
3339 // Ïðàâûé íèæíèé óãîë:
3340 aX2
:= aX
+ aX2
- 1;
3341 aY2
:= aY
+ aY2
- 1;
3343 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 0, 192, 0);
3346 if gAcid1
<> nil then
3348 // Ðèñóåì êèñëîòó 1:
3349 for a
:= 0 to High(gAcid1
) do
3351 if PanelType
<> 0 then
3353 // Ëåâûé âåðõíèé óãîë:
3354 aX
:= X
div ScaleSz
;
3355 aY
:= Y
div ScaleSz
;
3357 aX2
:= max(Width
div ScaleSz
, 1);
3358 aY2
:= max(Height
div ScaleSz
, 1);
3359 // Ïðàâûé íèæíèé óãîë:
3360 aX2
:= aX
+ aX2
- 1;
3361 aY2
:= aY
+ aY2
- 1;
3363 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 176, 0, 0);
3366 if gAcid2
<> nil then
3368 // Ðèñóåì êèñëîòó 2:
3369 for a
:= 0 to High(gAcid2
) do
3371 if PanelType
<> 0 then
3373 // Ëåâûé âåðõíèé óãîë:
3374 aX
:= X
div ScaleSz
;
3375 aY
:= Y
div ScaleSz
;
3377 aX2
:= max(Width
div ScaleSz
, 1);
3378 aY2
:= max(Height
div ScaleSz
, 1);
3379 // Ïðàâûé íèæíèé óãîë:
3380 aX2
:= aX
+ aX2
- 1;
3381 aY2
:= aY
+ aY2
- 1;
3383 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 176, 0, 0, 0);
3386 if gPlayers
<> nil then
3389 for a
:= 0 to High(gPlayers
) do
3390 if gPlayers
[a
] <> nil then with gPlayers
[a
] do
3392 // Ëåâûé âåðõíèé óãîë:
3393 aX
:= Obj
.X
div ScaleSz
+ 1;
3394 aY
:= Obj
.Y
div ScaleSz
+ 1;
3396 aX2
:= max(Obj
.Rect
.Width
div ScaleSz
, 1);
3397 aY2
:= max(Obj
.Rect
.Height
div ScaleSz
, 1);
3398 // Ïðàâûé íèæíèé óãîë:
3399 aX2
:= aX
+ aX2
- 1;
3400 aY2
:= aY
+ aY2
- 1;
3402 if gPlayers
[a
] = p
then
3403 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 255, 0, 0)
3406 TEAM_RED
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 0, 0, 0);
3407 TEAM_BLUE
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 0, 255, 0);
3408 else e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 128, 0, 0);
3413 g_Mons_ForEach(monDraw
);
3418 procedure renderAmbientQuad (hasAmbient
: Boolean; constref ambColor
: TDFColor
);
3420 if not hasAmbient
then exit
;
3421 e_AmbientQuad(sX
, sY
, sWidth
, sHeight
, ambColor
.r
, ambColor
.g
, ambColor
.b
, ambColor
.a
);
3425 // setup sX, sY, sWidth, sHeight, and transformation matrix before calling this!
3426 //FIXME: broken for splitscreen mode
3427 procedure renderDynLightsInternal ();
3429 //hasAmbient: Boolean;
3430 //ambColor: TDFColor;
3432 lx
, ly
, lrad
: Integer;
3433 scxywh
: array[0..3] of GLint
;
3436 if e_NoGraphics
then exit
;
3438 //TODO: lights should be in separate grid, i think
3439 // but on the other side: grid may be slower for dynlights, as their lifetime is short
3440 if (not gwin_k8_enable_light_experiments
) or (not gwin_has_stencil
) or (g_dynLightCount
< 1) then exit
;
3443 //ambColor := gCurrentMap['light_ambient'].rgba;
3444 //hasAmbient := (not ambColor.isOpaque) or (not ambColor.isBlack);
3446 { // this will multiply incoming color to alpha from framebuffer
3448 glBlendFunc(GL_DST_ALPHA, GL_ONE);
3452 * light rendering: (INVALID!)
3453 * glStencilFunc(GL_EQUAL, 0, $ff);
3455 * glClear(GL_STENCIL_BUFFER_BIT);
3456 * glStencilOp(GL_KEEP, GL_KEEP, GL_INCR);
3457 * draw shadow volume into stencil buffer
3458 * glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); // modify color buffer
3459 * glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); // don't modify stencil buffer
3461 * draw color-less quad with light alpha (WARNING! don't touch color!)
3462 * glEnable(GL_BLEND);
3463 * glBlendFunc(GL_DST_ALPHA, GL_ONE);
3464 * draw all geometry up to and including walls (with alpha-testing, probably) -- this does lighting
3466 wassc
:= (glIsEnabled(GL_SCISSOR_TEST
) <> 0);
3467 if wassc
then glGetIntegerv(GL_SCISSOR_BOX
, @scxywh
[0]) else glGetIntegerv(GL_VIEWPORT
, @scxywh
[0]);
3469 // setup OpenGL parameters
3470 glStencilMask($FFFFFFFF);
3471 glStencilFunc(GL_ALWAYS
, 0, $FFFFFFFF);
3472 glEnable(GL_STENCIL_TEST
);
3473 glEnable(GL_SCISSOR_TEST
);
3474 glClear(GL_STENCIL_BUFFER_BIT
);
3475 glStencilFunc(GL_EQUAL
, 0, $ff);
3477 for lln
:= 0 to g_dynLightCount
-1 do
3479 lx
:= g_dynLights
[lln
].x
;
3480 ly
:= g_dynLights
[lln
].y
;
3481 lrad
:= g_dynLights
[lln
].radius
;
3482 if (lrad
< 3) then continue
;
3484 if (lx
-sX
+lrad
< 0) then continue
;
3485 if (ly
-sY
+lrad
< 0) then continue
;
3486 if (lx
-sX
-lrad
>= gPlayerScreenSize
.X
) then continue
;
3487 if (ly
-sY
-lrad
>= gPlayerScreenSize
.Y
) then continue
;
3489 // set scissor to optimize drawing
3490 if (g_dbg_scale
= 1.0) then
3492 glScissor((lx
-sX
)-lrad
+2, gPlayerScreenSize
.Y
-(ly
-sY
)-lrad
-1+2, lrad
*2-4, lrad
*2-4);
3496 glScissor(0, 0, gScreenWidth
, gScreenHeight
);
3498 // no need to clear stencil buffer, light blitting will do it for us... but only for normal scale
3499 if (g_dbg_scale
<> 1.0) then glClear(GL_STENCIL_BUFFER_BIT
);
3500 glStencilOp(GL_KEEP
, GL_KEEP
, GL_INCR
);
3501 // draw extruded panels
3502 glDisable(GL_TEXTURE_2D
);
3503 glDisable(GL_BLEND
);
3504 glColorMask(GL_FALSE
, GL_FALSE
, GL_FALSE
, GL_FALSE
); // no need to modify color buffer
3505 if (lrad
> 4) then g_Map_DrawPanelShadowVolumes(lx
, ly
, lrad
);
3506 // render light texture
3507 glColorMask(GL_TRUE
, GL_TRUE
, GL_TRUE
, GL_TRUE
); // modify color buffer
3508 glStencilOp(GL_ZERO
, GL_ZERO
, GL_ZERO
); // draw light, and clear stencil buffer
3511 glBlendFunc(GL_SRC_ALPHA
, GL_ONE_MINUS_SRC_ALPHA
);
3512 glEnable(GL_TEXTURE_2D
);
3513 // color and opacity
3514 glColor4f(g_dynLights
[lln
].r
, g_dynLights
[lln
].g
, g_dynLights
[lln
].b
, g_dynLights
[lln
].a
);
3515 glBindTexture(GL_TEXTURE_2D
, g_Texture_Light());
3517 glTexCoord2f(0.0, 0.0); glVertex2i(lx
-lrad
, ly
-lrad
); // top-left
3518 glTexCoord2f(1.0, 0.0); glVertex2i(lx
+lrad
, ly
-lrad
); // top-right
3519 glTexCoord2f(1.0, 1.0); glVertex2i(lx
+lrad
, ly
+lrad
); // bottom-right
3520 glTexCoord2f(0.0, 1.0); glVertex2i(lx
-lrad
, ly
+lrad
); // bottom-left
3525 glDisable(GL_STENCIL_TEST
);
3526 glDisable(GL_BLEND
);
3527 glDisable(GL_SCISSOR_TEST
);
3528 //glScissor(0, 0, sWidth, sHeight);
3530 glScissor(scxywh
[0], scxywh
[1], scxywh
[2], scxywh
[3]);
3531 if wassc
then glEnable(GL_SCISSOR_TEST
) else glDisable(GL_SCISSOR_TEST
);
3535 function fixViewportForScale (): Boolean;
3537 nx0
, ny0
, nw
, nh
: Integer;
3540 if (g_dbg_scale
<> 1.0) then
3543 nx0
:= round(sX
-(gPlayerScreenSize
.X
-(sWidth
*g_dbg_scale
))/2/g_dbg_scale
);
3544 ny0
:= round(sY
-(gPlayerScreenSize
.Y
-(sHeight
*g_dbg_scale
))/2/g_dbg_scale
);
3545 nw
:= round(sWidth
/g_dbg_scale
);
3546 nh
:= round(sHeight
/g_dbg_scale
);
3555 // setup sX, sY, sWidth, sHeight, and transformation matrix before calling this!
3556 // WARNING! this WILL CALL `glTranslatef()`, but won't restore matrices!
3557 procedure renderMapInternal (backXOfs
, backYOfs
: Integer; setTransMatrix
: Boolean);
3559 TDrawCB
= procedure ();
3562 hasAmbient
: Boolean;
3564 doAmbient
: Boolean = false;
3566 procedure drawPanelType (profname
: AnsiString
; panType
: DWord
; doDraw
: Boolean);
3571 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin(profname
);
3572 if gdbg_map_use_accel_render
then
3574 tagmask
:= panelTypeToTag(panType
);
3575 while (gDrawPanelList
.count
> 0) do
3577 pan
:= TPanel(gDrawPanelList
.front());
3578 if ((pan
.tag
and tagmask
) = 0) then break
;
3579 if doDraw
then pan
.Draw(doAmbient
, ambColor
);
3580 gDrawPanelList
.popFront();
3585 if doDraw
then g_Map_DrawPanels(panType
, hasAmbient
, ambColor
);
3587 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
3590 procedure drawOther (profname
: AnsiString
; cb
: TDrawCB
);
3592 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin(profname
);
3593 if assigned(cb
) then cb();
3594 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
3598 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin('total');
3600 // our accelerated renderer will collect all panels to gDrawPanelList
3601 // we can use panel tag to render level parts (see GridTagXXX in g_map.pas)
3602 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin('collect');
3603 if gdbg_map_use_accel_render
then
3605 g_Map_CollectDrawPanels(sX
, sY
, sWidth
, sHeight
);
3607 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
3609 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin('skyback');
3610 g_Map_DrawBack(backXOfs
, backYOfs
);
3611 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
3613 if setTransMatrix
then
3615 //if (g_dbg_scale <> 1.0) then glTranslatef(0.0, -0.375/2, 0);
3616 glScalef(g_dbg_scale
, g_dbg_scale
, 1.0);
3617 glTranslatef(-sX
, -sY
, 0);
3621 ambColor
:= gCurrentMap
['light_ambient'].rgba
;
3622 hasAmbient
:= (not ambColor
.isOpaque
) or (not ambColor
.isBlack
);
3627 //writeln('color: (', ambColor.r, ',', ambColor.g, ',', ambColor.b, ',', ambColor.a, ')');
3628 glColor4ub(ambColor.r, ambColor.g, ambColor.b, ambColor.a);
3629 glClear(GL_COLOR_BUFFER_BIT);
3632 //writeln('color: (', ambColor.r, ',', ambColor.g, ',', ambColor.b, ',', ambColor.a, ')');
3635 drawPanelType('*back', PANEL_BACK
, g_rlayer_back
);
3636 drawPanelType('*step', PANEL_STEP
, g_rlayer_step
);
3637 drawOther('items', @g_Items_Draw
);
3638 drawOther('weapons', @g_Weapon_Draw
);
3639 drawOther('shells', @g_Player_DrawShells
);
3640 drawOther('drawall', @g_Player_DrawAll
);
3641 drawOther('corpses', @g_Player_DrawCorpses
);
3642 drawPanelType('*wall', PANEL_WALL
, g_rlayer_wall
);
3643 drawOther('monsters', @g_Monsters_Draw
);
3644 drawOther('itemdrop', @g_Items_DrawDrop
);
3645 drawPanelType('*door', PANEL_CLOSEDOOR
, g_rlayer_door
);
3646 drawOther('gfx', @g_GFX_Draw
);
3647 drawOther('flags', @g_Map_DrawFlags
);
3648 drawPanelType('*acid1', PANEL_ACID1
, g_rlayer_acid1
);
3649 drawPanelType('*acid2', PANEL_ACID2
, g_rlayer_acid2
);
3650 drawPanelType('*water', PANEL_WATER
, g_rlayer_water
);
3651 drawOther('dynlights', @renderDynLightsInternal
);
3653 if hasAmbient
{and ((not g_playerLight) or (not gwin_has_stencil) or (g_dynLightCount < 1))} then
3655 renderAmbientQuad(hasAmbient
, ambColor
);
3659 drawPanelType('*fore', PANEL_FORE
, g_rlayer_fore
);
3662 if g_debug_HealthBar
then
3664 g_Monsters_DrawHealth();
3665 g_Player_DrawHealth();
3668 if (profileFrameDraw
<> nil) then profileFrameDraw
.mainEnd(); // map rendering
3672 procedure DrawMapView(x
, y
, w
, h
: Integer);
3679 bx
:= Round(x
/(gMapInfo
.Width
- w
)*(gBackSize
.X
- w
));
3680 by
:= Round(y
/(gMapInfo
.Height
- h
)*(gBackSize
.Y
- h
));
3687 fixViewportForScale();
3688 renderMapInternal(-bx
, -by
, true);
3694 procedure DrawPlayer(p
: TPlayer
);
3696 px
, py
, a
, b
, c
, d
, i
, fX
, fY
: Integer;
3700 if (p
= nil) or (p
.FDummy
) then
3703 g_Map_DrawBack(0, 0);
3708 if (profileFrameDraw
= nil) then profileFrameDraw
:= TProfiler
.Create('RENDER', g_profile_history_size
);
3709 if (profileFrameDraw
<> nil) then profileFrameDraw
.mainBegin(g_profile_frame_draw
);
3715 camObj
:= p
.getCameraObj();
3716 camObj
.lerp(gLerpFactor
, fX
, fY
);
3717 px
:= fX
+ PLAYER_RECT_CX
;
3718 py
:= fY
+ PLAYER_RECT_CY
+nlerp(p
.SlopeOld
, camObj
.slopeUpLeft
, gLerpFactor
);
3720 if (g_dbg_scale
= 1.0) and (not g_dbg_ignore_bounds
) then
3722 if (px
> (gPlayerScreenSize
.X
div 2)) then a
:= -px
+(gPlayerScreenSize
.X
div 2) else a
:= 0;
3723 if (py
> (gPlayerScreenSize
.Y
div 2)) then b
:= -py
+(gPlayerScreenSize
.Y
div 2) else b
:= 0;
3725 if (px
> gMapInfo
.Width
-(gPlayerScreenSize
.X
div 2)) then a
:= -gMapInfo
.Width
+gPlayerScreenSize
.X
;
3726 if (py
> gMapInfo
.Height
-(gPlayerScreenSize
.Y
div 2)) then b
:= -gMapInfo
.Height
+gPlayerScreenSize
.Y
;
3728 if (gMapInfo
.Width
= gPlayerScreenSize
.X
) then a
:= 0
3729 else if (gMapInfo
.Width
< gPlayerScreenSize
.X
) then
3732 a
:= (gPlayerScreenSize
.X
-gMapInfo
.Width
) div 2;
3735 if (gMapInfo
.Height
= gPlayerScreenSize
.Y
) then b
:= 0
3736 else if (gMapInfo
.Height
< gPlayerScreenSize
.Y
) then
3739 b
:= (gPlayerScreenSize
.Y
-gMapInfo
.Height
) div 2;
3744 // scaled, ignore level bounds
3745 a
:= -px
+(gPlayerScreenSize
.X
div 2);
3746 b
:= -py
+(gPlayerScreenSize
.Y
div 2);
3751 sWidth
:= gPlayerScreenSize
.X
;
3752 sHeight
:= gPlayerScreenSize
.Y
;
3753 fixViewportForScale();
3755 i
:= py
- (sY
+ sHeight
div 2);
3756 if (p
.IncCam
> 0) then
3758 // clamp to level bounds
3759 if (sY
- p
.IncCam
< 0) then
3760 p
.IncCam
:= nclamp(sY
, 0, 120);
3761 // clamp around player position
3763 p
.IncCam
:= nclamp(p
.IncCam
, 0, max(0, 120 - i
));
3765 else if (p
.IncCam
< 0) then
3767 // clamp to level bounds
3768 if (sY
+ sHeight
- p
.IncCam
> gMapInfo
.Height
) then
3769 p
.IncCam
:= nclamp(sY
+ sHeight
- gMapInfo
.Height
, -120, 0);
3770 // clamp around player position
3772 p
.IncCam
:= nclamp(p
.IncCam
, min(0, -120 - i
), 0);
3775 sY
:= sY
- nlerp(p
.IncCamOld
, p
.IncCam
, gLerpFactor
);
3777 if (not g_dbg_ignore_bounds
) then
3779 if (sX
+sWidth
> gMapInfo
.Width
) then sX
:= gMapInfo
.Width
-sWidth
;
3780 if (sY
+sHeight
> gMapInfo
.Height
) then sY
:= gMapInfo
.Height
-sHeight
;
3781 if (sX
< 0) then sX
:= 0;
3782 if (sY
< 0) then sY
:= 0;
3785 if (gBackSize
.X
<= gPlayerScreenSize
.X
) or (gMapInfo
.Width
<= sWidth
) then c
:= 0 else c
:= trunc((gBackSize
.X
-gPlayerScreenSize
.X
)*sX
/(gMapInfo
.Width
-sWidth
));
3786 if (gBackSize
.Y
<= gPlayerScreenSize
.Y
) or (gMapInfo
.Height
<= sHeight
) then d
:= 0 else d
:= trunc((gBackSize
.Y
-gPlayerScreenSize
.Y
)*sY
/(gMapInfo
.Height
-sHeight
));
3788 //r_smallmap_h: 0: left; 1: center; 2: right
3789 //r_smallmap_v: 0: top; 1: center; 2: bottom
3791 if (gMapInfo
.Width
= sWidth
) then
3795 else if (gMapInfo
.Width
< sWidth
) then
3797 case r_smallmap_h
of
3798 1: sX
:= -((sWidth
-gMapInfo
.Width
) div 2); // center
3799 2: sX
:= -(sWidth
-gMapInfo
.Width
); // right
3800 else sX
:= 0; // left
3804 if (gMapInfo
.Height
= sHeight
) then
3808 else if (gMapInfo
.Height
< sHeight
) then
3810 case r_smallmap_v
of
3811 1: sY
:= -((sHeight
-gMapInfo
.Height
) div 2); // center
3812 2: sY
:= -(sHeight
-gMapInfo
.Height
); // bottom
3813 else sY
:= 0; // top
3819 p
.viewPortW
:= sWidth
;
3820 p
.viewPortH
:= sHeight
;
3822 {$IFDEF ENABLE_HOLMES}
3823 if (p
= gPlayer1
) then
3825 g_Holmes_plrViewPos(sX
, sY
);
3826 g_Holmes_plrViewSize(sWidth
, sHeight
);
3830 renderMapInternal(-c
, -d
, true);
3832 if (gGameSettings
.GameMode
<> GM_SINGLE
) and (gPlayerIndicator
> 0) then
3833 case gPlayerIndicator
of
3835 p
.DrawIndicator(_RGB(255, 255, 255));
3838 for i
:= 0 to High(gPlayers
) do
3839 if gPlayers
[i
] <> nil then
3840 if gPlayers
[i
] = p
then p
.DrawIndicator(_RGB(255, 255, 255))
3841 else if (gPlayers
[i
].Team
= p
.Team
) and (gPlayers
[i
].Team
<> TEAM_NONE
) then
3842 if gPlayerIndicatorStyle
= 1 then
3843 gPlayers
[i
].DrawIndicator(_RGB(192, 192, 192))
3844 else gPlayers
[i
].DrawIndicator(gPlayers
[i
].GetColor
);
3848 for a := 0 to High(gCollideMap) do
3849 for b := 0 to High(gCollideMap[a]) do
3852 if ByteBool(gCollideMap[a, b] and MARK_WALL) then
3854 if ByteBool(gCollideMap[a, b] and MARK_DOOR) then
3858 1: e_DrawPoint(1, b, a, 200, 200, 200);
3859 2: e_DrawPoint(1, b, a, 64, 64, 255);
3860 3: e_DrawPoint(1, b, a, 255, 0, 255);
3870 if gShowMap
then DrawMinimap(p
, _TRect(0, 0, 128, 128));
3871 if g_Debug_Player
then
3872 g_Player_DrawDebug(p
);
3876 procedure drawProfilers ();
3881 if g_profile_frame_draw
and (profileFrameDraw
<> nil) then px
:= px
-drawProfiles(px
, py
, profileFrameDraw
);
3882 if g_profile_collision
and (profMapCollision
<> nil) then begin px
:= px
-drawProfiles(px
, py
, profMapCollision
); py
-= calcProfilesHeight(profMonsLOS
); end;
3883 if g_profile_los
and (profMonsLOS
<> nil) then begin px
:= px
-drawProfiles(px
, py
, profMonsLOS
); py
-= calcProfilesHeight(profMonsLOS
); end;
3886 procedure g_Game_Draw();
3893 plView1
, plView2
: TPlayer
;
3896 if gExit
= EXIT_QUIT
then Exit
;
3898 Time
:= sys_GetTicks() {div 1000};
3899 FPSCounter
:= FPSCounter
+1;
3900 if Time
- FPSTime
>= 1000 then
3907 e_SetRendertarget(True);
3908 e_SetViewPort(0, 0, gScreenWidth
, gScreenHeight
);
3910 if gGameOn
or (gState
= STATE_FOLD
) then
3912 if (gPlayer1
<> nil) and (gPlayer2
<> nil) then
3914 gSpectMode
:= SPECT_NONE
;
3915 if not gRevertPlayers
then
3917 plView1
:= gPlayer1
;
3918 plView2
:= gPlayer2
;
3922 plView1
:= gPlayer2
;
3923 plView2
:= gPlayer1
;
3927 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
3929 gSpectMode
:= SPECT_NONE
;
3930 if gPlayer2
= nil then
3933 plView1
:= gPlayer2
;
3942 if (plView1
= nil) and (plView2
= nil) and (gSpectMode
= SPECT_NONE
) then
3943 gSpectMode
:= SPECT_STATS
;
3945 if gSpectMode
= SPECT_PLAYERS
then
3946 if gPlayers
<> nil then
3948 plView1
:= GetActivePlayer_ByID(gSpectPID1
);
3949 if plView1
= nil then
3951 gSpectPID1
:= GetActivePlayerID_Next();
3952 plView1
:= GetActivePlayer_ByID(gSpectPID1
);
3954 if gSpectViewTwo
then
3956 plView2
:= GetActivePlayer_ByID(gSpectPID2
);
3957 if plView2
= nil then
3959 gSpectPID2
:= GetActivePlayerID_Next();
3960 plView2
:= GetActivePlayer_ByID(gSpectPID2
);
3965 if gSpectMode
= SPECT_MAPVIEW
then
3967 // Ðåæèì ïðîñìîòðà êàðòû
3969 e_SetViewPort(0, 0, gScreenWidth
, gScreenHeight
);
3970 DrawMapView(gSpectX
, gSpectY
, gScreenWidth
, gScreenHeight
);
3971 gHearPoint1
.Active
:= True;
3972 gHearPoint1
.Coords
.X
:= gScreenWidth
div 2 + gSpectX
;
3973 gHearPoint1
.Coords
.Y
:= gScreenHeight
div 2 + gSpectY
;
3974 gHearPoint2
.Active
:= False;
3978 Split
:= (plView1
<> nil) and (plView2
<> nil);
3980 // Òî÷êè ñëóõà èãðîêîâ
3981 if plView1
<> nil then
3983 gHearPoint1
.Active
:= True;
3984 gHearPoint1
.Coords
.X
:= plView1
.GameX
+ PLAYER_RECT
.Width
;
3985 gHearPoint1
.Coords
.Y
:= plView1
.GameY
+ PLAYER_RECT
.Height
DIV 2;
3987 gHearPoint1
.Active
:= False;
3988 if plView2
<> nil then
3990 gHearPoint2
.Active
:= True;
3991 gHearPoint2
.Coords
.X
:= plView2
.GameX
+ PLAYER_RECT
.Width
;
3992 gHearPoint2
.Coords
.Y
:= plView2
.GameY
+ PLAYER_RECT
.Height
DIV 2;
3994 gHearPoint2
.Active
:= False;
3996 // Ðàçìåð ýêðàíîâ èãðîêîâ:
3997 gPlayerScreenSize
.X
:= gScreenWidth
-196;
4000 gPlayerScreenSize
.Y
:= gScreenHeight
div 2;
4001 if gScreenHeight
mod 2 = 0 then
4002 Dec(gPlayerScreenSize
.Y
);
4005 gPlayerScreenSize
.Y
:= gScreenHeight
;
4008 if gScreenHeight
mod 2 = 0 then
4009 e_SetViewPort(0, gPlayerScreenSize
.Y
+2, gPlayerScreenSize
.X
+196, gPlayerScreenSize
.Y
)
4011 e_SetViewPort(0, gPlayerScreenSize
.Y
+1, gPlayerScreenSize
.X
+196, gPlayerScreenSize
.Y
);
4013 DrawPlayer(plView1
);
4014 gPlayer1ScreenCoord
.X
:= sX
;
4015 gPlayer1ScreenCoord
.Y
:= sY
;
4019 e_SetViewPort(0, 0, gPlayerScreenSize
.X
+196, gPlayerScreenSize
.Y
);
4021 DrawPlayer(plView2
);
4022 gPlayer2ScreenCoord
.X
:= sX
;
4023 gPlayer2ScreenCoord
.Y
:= sY
;
4026 e_SetViewPort(0, 0, gScreenWidth
, gScreenHeight
);
4029 e_DrawLine(2, 0, gScreenHeight
div 2, gScreenWidth
, gScreenHeight
div 2, 0, 0, 0);
4032 {$IFDEF ENABLE_HOLMES}
4034 if (g_holmes_enabled
) then g_Holmes_Draw();
4037 if MessageText
<> '' then
4041 e_CharFont_GetSizeFmt(gMenuFont
, MessageText
, w
, h
);
4043 e_CharFont_PrintFmt(gMenuFont
, (gScreenWidth
div 2)-(w
div 2),
4044 (gScreenHeight
div 2)-(h
div 2), MessageText
)
4046 e_CharFont_PrintFmt(gMenuFont
, (gScreenWidth
div 2)-(w
div 2),
4047 Round(gScreenHeight
/ 2.75)-(h
div 2), MessageText
);
4050 if IsDrawStat
or (gSpectMode
= SPECT_STATS
) then
4053 if gSpectHUD
and (not gChatShow
) and (gSpectMode
<> SPECT_NONE
) and (not gSpectAuto
) then
4055 // Draw spectator GUI
4058 e_TextureFontGetSize(gStdFont
, ww
, hh
);
4061 e_TextureFontPrintEx(0, gScreenHeight
- (hh
+2)*2, 'MODE: Stats', gStdFont
, 255, 255, 255, 1);
4063 e_TextureFontPrintEx(0, gScreenHeight
- (hh
+2)*2, 'MODE: Observe Map', gStdFont
, 255, 255, 255, 1);
4065 e_TextureFontPrintEx(0, gScreenHeight
- (hh
+2)*2, 'MODE: Watch Players', gStdFont
, 255, 255, 255, 1);
4067 e_TextureFontPrintEx(2*ww
, gScreenHeight
- (hh
+2), '< jump >', gStdFont
, 255, 255, 255, 1);
4068 if gSpectMode
= SPECT_STATS
then
4070 e_TextureFontPrintEx(16*ww
, gScreenHeight
- (hh
+2)*2, 'Autoview', gStdFont
, 255, 255, 255, 1);
4071 e_TextureFontPrintEx(16*ww
, gScreenHeight
- (hh
+2), '< fire >', gStdFont
, 255, 255, 255, 1);
4073 if gSpectMode
= SPECT_MAPVIEW
then
4075 e_TextureFontPrintEx(22*ww
, gScreenHeight
- (hh
+2)*2, '[-]', gStdFont
, 255, 255, 255, 1);
4076 e_TextureFontPrintEx(26*ww
, gScreenHeight
- (hh
+2)*2, 'Step ' + IntToStr(gSpectStep
), gStdFont
, 255, 255, 255, 1);
4077 e_TextureFontPrintEx(34*ww
, gScreenHeight
- (hh
+2)*2, '[+]', gStdFont
, 255, 255, 255, 1);
4078 e_TextureFontPrintEx(18*ww
, gScreenHeight
- (hh
+2), '<prev weap>', gStdFont
, 255, 255, 255, 1);
4079 e_TextureFontPrintEx(30*ww
, gScreenHeight
- (hh
+2), '<next weap>', gStdFont
, 255, 255, 255, 1);
4081 if gSpectMode
= SPECT_PLAYERS
then
4083 e_TextureFontPrintEx(22*ww
, gScreenHeight
- (hh
+2)*2, 'Player 1', gStdFont
, 255, 255, 255, 1);
4084 e_TextureFontPrintEx(20*ww
, gScreenHeight
- (hh
+2), '<left/right>', gStdFont
, 255, 255, 255, 1);
4085 if gSpectViewTwo
then
4087 e_TextureFontPrintEx(37*ww
, gScreenHeight
- (hh
+2)*2, 'Player 2', gStdFont
, 255, 255, 255, 1);
4088 e_TextureFontPrintEx(34*ww
, gScreenHeight
- (hh
+2), '<prev w/next w>', gStdFont
, 255, 255, 255, 1);
4089 e_TextureFontPrintEx(52*ww
, gScreenHeight
- (hh
+2)*2, '2x View', gStdFont
, 255, 255, 255, 1);
4090 e_TextureFontPrintEx(51*ww
, gScreenHeight
- (hh
+2), '<up/down>', gStdFont
, 255, 255, 255, 1);
4094 e_TextureFontPrintEx(35*ww
, gScreenHeight
- (hh
+2)*2, '2x View', gStdFont
, 255, 255, 255, 1);
4095 e_TextureFontPrintEx(34*ww
, gScreenHeight
- (hh
+2), '<up/down>', gStdFont
, 255, 255, 255, 1);
4101 if gPauseMain
and gGameOn
and (g_ActiveWindow
= nil) then
4103 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4104 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4106 e_CharFont_GetSize(gMenuFont
, _lc
[I_MENU_PAUSE
], w
, h
);
4107 e_CharFont_Print(gMenuFont
, (gScreenWidth
div 2)-(w
div 2),
4108 (gScreenHeight
div 2)-(h
div 2), _lc
[I_MENU_PAUSE
]);
4113 if (gState
= STATE_MENU
) then
4115 if (g_ActiveWindow
= nil) or (g_ActiveWindow
.BackTexture
= '') then DrawMenuBackground('MENU_BACKGROUND');
4116 // F3 at menu will show game loading dialog
4117 if e_KeyPressed(IK_F3
) then g_Menu_Show_LoadMenu(true);
4118 if (g_ActiveWindow
<> nil) then
4120 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4121 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4125 // F3 at titlepic will show game loading dialog
4126 if e_KeyPressed(IK_F3
) then
4128 g_Menu_Show_LoadMenu(true);
4129 if (g_ActiveWindow
<> nil) then e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4134 if gState
= STATE_FOLD
then
4136 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 0, 0, 0, EndingGameCounter
);
4139 if gState
= STATE_INTERCUSTOM
then
4141 if gLastMap
and (gGameSettings
.GameMode
= GM_COOP
) then
4143 back
:= 'TEXTURE_endpic';
4144 if not g_Texture_Get(back
, ID
) then
4145 back
:= _lc
[I_TEXTURE_ENDPIC
];
4150 DrawMenuBackground(back
);
4154 if g_ActiveWindow
<> nil then
4156 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4157 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4161 if gState
= STATE_INTERSINGLE
then
4163 if EndingGameCounter
> 0 then
4165 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 0, 0, 0, EndingGameCounter
);
4171 DrawMenuBackground(back
);
4175 if g_ActiveWindow
<> nil then
4177 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4178 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4183 if gState
= STATE_ENDPIC
then
4186 if g_Texture_Get('TEXTURE_endpic', ID
) then DrawMenuBackground('TEXTURE_endpic')
4187 else DrawMenuBackground(_lc
[I_TEXTURE_ENDPIC
]);
4189 if g_ActiveWindow
<> nil then
4191 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4192 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4196 if gState
= STATE_SLIST
then
4198 // if g_Texture_Get('MENU_BACKGROUND', ID) then
4200 // e_DrawSize(ID, 0, 0, 0, False, False, gScreenWidth, gScreenHeight);
4201 // //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4203 DrawMenuBackground('MENU_BACKGROUND');
4204 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4205 g_Serverlist_Draw(slCurrent
, slTable
);
4209 if g_ActiveWindow
<> nil then
4213 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4214 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4216 g_ActiveWindow
.Draw();
4223 if g_debug_Sounds
and gGameOn
then
4225 for w
:= 0 to High(e_SoundsArray
) do
4226 for h
:= 0 to e_SoundsArray
[w
].nRefs
do
4227 e_DrawPoint(1, w
+100, h
+100, 255, 0, 0);
4232 e_TextureFontPrint(0, 0, Format('FPS: %d', [FPS
]), gStdFont
);
4233 e_TextureFontPrint(0, 16, Format('UPS: %d', [UPS
]), gStdFont
);
4236 if gGameOn
and gShowTime
then
4237 drawTime(gScreenWidth
-72, gScreenHeight
-16);
4239 if gGameOn
then drawProfilers();
4241 // TODO: draw this after the FBO and remap mouse click coordinates
4243 {$IFDEF ENABLE_HOLMES}
4247 // blit framebuffer to screen
4249 e_SetRendertarget(False);
4250 e_SetViewPort(0, 0, gWinSizeX
, gWinSizeY
);
4251 e_BlitFramebuffer(gWinSizeX
, gWinSizeY
);
4253 // draw the overlay stuff on top of it
4258 procedure g_Game_Quit();
4260 g_Game_StopAllSounds(True);
4263 g_PlayerModel_FreeData();
4264 g_Texture_DeleteAll();
4265 g_Frames_DeleteAll();
4267 //g_Menu_Free(); //k8: this segfaults after resolution change; who cares?
4270 if NetInitDone
then g_Net_Free
;
4272 // Íàäî óäàëèòü êàðòó ïîñëå òåñòà:
4273 if gMapToDelete
<> '' then
4274 g_Game_DeleteTestMap();
4280 procedure g_FatalError(Text: String);
4282 g_Console_Add(Format(_lc
[I_FATAL_ERROR
], [Text]), True);
4283 e_WriteLog(Format(_lc
[I_FATAL_ERROR
], [Text]), TMsgType
.Warning
);
4285 gExit
:= EXIT_SIMPLE
;
4286 if gGameOn
then EndGame
;
4289 procedure g_SimpleError(Text: String);
4291 g_Console_Add(Format(_lc
[I_SIMPLE_ERROR
], [Text]), True);
4292 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], [Text]), TMsgType
.Warning
);
4295 procedure g_Game_SetupScreenSize();
4297 RES_FACTOR
= 4.0 / 3.0;
4303 // Ðàçìåð ýêðàíîâ èãðîêîâ:
4304 gPlayerScreenSize
.X
:= gScreenWidth
-196;
4305 if (gPlayer1
<> nil) and (gPlayer2
<> nil) then
4306 gPlayerScreenSize
.Y
:= gScreenHeight
div 2
4308 gPlayerScreenSize
.Y
:= gScreenHeight
;
4310 // Ðàçìåð çàäíåãî ïëàíà:
4311 if BackID
<> DWORD(-1) then
4314 if (gScreenWidth
*s
> gMapInfo
.Width
) or
4315 (gScreenHeight
*s
> gMapInfo
.Height
) then
4317 gBackSize
.X
:= gScreenWidth
;
4318 gBackSize
.Y
:= gScreenHeight
;
4322 e_GetTextureSize(BackID
, @bw
, @bh
);
4323 rf
:= Single(bw
) / Single(bh
);
4324 if (rf
> RES_FACTOR
) then bw
:= Round(Single(bh
) * RES_FACTOR
)
4325 else if (rf
< RES_FACTOR
) then bh
:= Round(Single(bw
) / RES_FACTOR
);
4326 s
:= Max(gScreenWidth
/ bw
, gScreenHeight
/ bh
);
4327 if (s
< 1.0) then s
:= 1.0;
4328 gBackSize
.X
:= Round(bw
*s
);
4329 gBackSize
.Y
:= Round(bh
*s
);
4334 procedure g_Game_ChangeResolution(newWidth
, newHeight
: Word; nowFull
, nowMax
: Boolean);
4336 sys_SetDisplayMode(newWidth
, newHeight
, gBPP
, nowFull
, nowMax
);
4339 procedure g_Game_AddPlayer(Team
: Byte = TEAM_NONE
);
4341 if ((not gGameOn
) and (gState
<> STATE_INTERCUSTOM
))
4342 or (not (gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
])) then
4345 if (gGameSettings
.MaxLives
> 0) and (gLMSRespawn
= LMS_RESPAWN_NONE
) then
4348 if gPlayer1
= nil then
4350 if g_Game_IsClient
then
4352 if NetPlrUID1
> -1 then
4353 MC_SEND_CheatRequest(NET_CHEAT_SPECTATE
);
4357 if not (Team
in [TEAM_RED
, TEAM_BLUE
]) then
4358 Team
:= gPlayer1Settings
.Team
;
4360 // Ñîçäàíèå ïåðâîãî èãðîêà:
4361 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4362 gPlayer1Settings
.Color
,
4364 if gPlayer1
= nil then
4365 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]))
4368 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4369 gPlayer1
.WeapSwitchMode
:= gPlayer1Settings
.WeaponSwitch
;
4370 gPlayer1
.setWeaponPrefs(gPlayer1Settings
.WeaponPreferences
);
4371 gPlayer1
.SwitchToEmpty
:= gPlayer1Settings
.SwitchToEmpty
;
4372 gPlayer1
.SkipFist
:= gPlayer1Settings
.SkipFist
;
4373 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [gPlayer1
.Name
]), True);
4374 if g_Game_IsServer
and g_Game_IsNet
then
4375 MH_SEND_PlayerCreate(gPlayer1
.UID
);
4376 gPlayer1
.Respawn(False, True);
4377 g_Net_Slist_ServerPlayerComes();
4382 if gPlayer2
= nil then
4384 if g_Game_IsClient
then
4386 if NetPlrUID2
> -1 then
4387 gPlayer2
:= g_Player_Get(NetPlrUID2
);
4391 if not (Team
in [TEAM_RED
, TEAM_BLUE
]) then
4392 Team
:= gPlayer2Settings
.Team
;
4394 // Ñîçäàíèå âòîðîãî èãðîêà:
4395 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
4396 gPlayer2Settings
.Color
,
4398 if gPlayer2
= nil then
4399 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]))
4402 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
4403 gPlayer2
.WeapSwitchMode
:= gPlayer2Settings
.WeaponSwitch
;
4404 gPlayer2
.setWeaponPrefs(gPlayer2Settings
.WeaponPreferences
);
4405 gPlayer2
.SwitchToEmpty
:= gPlayer2Settings
.SwitchToEmpty
;
4406 gPlayer2
.SkipFist
:= gPlayer2Settings
.SkipFist
;
4407 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [gPlayer2
.Name
]), True);
4408 if g_Game_IsServer
and g_Game_IsNet
then
4409 MH_SEND_PlayerCreate(gPlayer2
.UID
);
4410 gPlayer2
.Respawn(False, True);
4411 g_Net_Slist_ServerPlayerComes();
4418 procedure g_Game_RemovePlayer();
4422 if ((not gGameOn
) and (gState
<> STATE_INTERCUSTOM
))
4423 or (not (gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
])) then
4428 if g_Game_IsServer
then
4431 Pl
.Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
4432 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [Pl
.Name
]), True);
4433 g_Player_Remove(Pl
.UID
);
4434 g_Net_Slist_ServerPlayerLeaves();
4438 gSpectLatchPID2
:= Pl
.UID
;
4446 if g_Game_IsServer
then
4449 Pl
.Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
4450 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [Pl
.Name
]), True);
4451 g_Player_Remove(Pl
.UID
);
4452 g_Net_Slist_ServerPlayerLeaves();
4455 gSpectLatchPID1
:= Pl
.UID
;
4457 MC_SEND_CheatRequest(NET_CHEAT_SPECTATE
);
4461 g_Net_Slist_ServerPlayerLeaves();
4464 procedure g_Game_Spectate();
4466 g_Game_RemovePlayer();
4467 if gPlayer1
<> nil then
4468 g_Game_RemovePlayer();
4471 procedure g_Game_SpectateCenterView();
4473 gSpectX
:= Max(gMapInfo
.Width
div 2 - gScreenWidth
div 2, 0);
4474 gSpectY
:= Max(gMapInfo
.Height
div 2 - gScreenHeight
div 2, 0);
4477 procedure g_Game_StartSingle(Map
: String; TwoPlayers
: Boolean; nPlayers
: Byte);
4484 e_WriteLog('Starting singleplayer game...', TMsgType
.Notify
);
4486 g_Game_ClearLoading();
4489 FillByte(gGameSettings
, SizeOf(TGameSettings
), 0);
4492 gGameSettings
.GameType
:= GT_SINGLE
;
4493 gGameSettings
.MaxLives
:= 0;
4494 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_ALLOWEXIT
;
4495 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_MONSTERS
;
4496 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_BOTVSMONSTER
;
4497 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_TEAMHITPROJECTILE
;
4498 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_TEAMHITTRACE
;
4499 gSwitchGameMode
:= GM_SINGLE
;
4501 gLMSRespawn
:= LMS_RESPAWN_NONE
;
4502 gLMSRespawnTime
:= 0;
4503 gSpectLatchPID1
:= 0;
4504 gSpectLatchPID2
:= 0;
4506 g_Game_ExecuteEvent('ongamestart');
4508 // Óñòàíîâêà ðàçìåðîâ îêîí èãðîêîâ:
4509 g_Game_SetupScreenSize();
4511 // Ñîçäàíèå ïåðâîãî èãðîêà:
4512 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4513 gPlayer1Settings
.Color
,
4514 gPlayer1Settings
.Team
, False));
4515 if gPlayer1
= nil then
4517 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
4521 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4522 gPlayer1
.WeapSwitchMode
:= gPlayer1Settings
.WeaponSwitch
;
4523 gPlayer1
.setWeaponPrefs(gPlayer1Settings
.WeaponPreferences
);
4524 gPlayer1
.SwitchToEmpty
:= gPlayer1Settings
.SwitchToEmpty
;
4525 gPlayer1
.SkipFist
:= gPlayer1Settings
.SkipFist
;
4528 // Ñîçäàíèå âòîðîãî èãðîêà, åñëè åñòü:
4531 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
4532 gPlayer2Settings
.Color
,
4533 gPlayer2Settings
.Team
, False));
4534 if gPlayer2
= nil then
4536 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
4540 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
4541 gPlayer2
.WeapSwitchMode
:= gPlayer2Settings
.WeaponSwitch
;
4542 gPlayer2
.setWeaponPrefs(gPlayer2Settings
.WeaponPreferences
);
4543 gPlayer2
.SwitchToEmpty
:= gPlayer2Settings
.SwitchToEmpty
;
4544 gPlayer2
.SkipFist
:= gPlayer2Settings
.SkipFist
;
4548 // Çàãðóçêà è çàïóñê êàðòû:
4549 if not g_Game_StartMap(false{asMegawad}, MAP
, True) then
4551 if (Pos(':\', Map
) > 0) or (Pos(':/', Map
) > 0) then tmps
:= Map
else tmps
:= gGameSettings
.WAD
+ ':\' + MAP
;
4552 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [tmps
]));
4556 // Íàñòðîéêè èãðîêîâ è áîòîâ:
4560 for i
:= nPl
+1 to nPlayers
do
4561 g_Player_Create(STD_PLAYER_MODEL
, _RGB(0, 0, 0), 0, True);
4564 procedure g_Game_StartCustom(Map
: String; GameMode
: Byte;
4565 TimeLimit
, ScoreLimit
: Word;
4567 Options
: LongWord
; nPlayers
: Byte);
4573 e_WriteLog('Starting custom game...', TMsgType
.Notify
);
4575 g_Game_ClearLoading();
4578 gGameSettings
.GameType
:= GT_CUSTOM
;
4579 gGameSettings
.GameMode
:= GameMode
;
4580 gSwitchGameMode
:= GameMode
;
4581 gGameSettings
.TimeLimit
:= TimeLimit
;
4582 gGameSettings
.ScoreLimit
:= ScoreLimit
;
4583 gGameSettings
.MaxLives
:= IfThen(GameMode
= GM_CTF
, 0, MaxLives
);
4584 gGameSettings
.Options
:= Options
;
4586 gCoopTotalMonstersKilled
:= 0;
4587 gCoopTotalSecretsFound
:= 0;
4588 gCoopTotalMonsters
:= 0;
4589 gCoopTotalSecrets
:= 0;
4593 gLMSRespawn
:= LMS_RESPAWN_NONE
;
4594 gLMSRespawnTime
:= 0;
4595 gSpectLatchPID1
:= 0;
4596 gSpectLatchPID2
:= 0;
4598 g_Game_ExecuteEvent('ongamestart');
4600 // Óñòàíîâêà ðàçìåðîâ îêîí èãðîêîâ:
4601 g_Game_SetupScreenSize();
4603 // Ðåæèì íàáëþäàòåëÿ:
4604 if nPlayers
= 0 then
4611 if nPlayers
>= 1 then
4613 // Ñîçäàíèå ïåðâîãî èãðîêà:
4614 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4615 gPlayer1Settings
.Color
,
4616 gPlayer1Settings
.Team
, False));
4617 if gPlayer1
= nil then
4619 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
4623 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4624 gPlayer1
.WeapSwitchMode
:= gPlayer1Settings
.WeaponSwitch
;
4625 gPlayer1
.setWeaponPrefs(gPlayer1Settings
.WeaponPreferences
);
4626 gPlayer1
.SwitchToEmpty
:= gPlayer1Settings
.SwitchToEmpty
;
4627 gPlayer1
.SkipFist
:= gPlayer1Settings
.SkipFist
;
4631 if nPlayers
>= 2 then
4633 // Ñîçäàíèå âòîðîãî èãðîêà:
4634 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
4635 gPlayer2Settings
.Color
,
4636 gPlayer2Settings
.Team
, False));
4637 if gPlayer2
= nil then
4639 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
4643 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
4644 gPlayer2
.WeapSwitchMode
:= gPlayer2Settings
.WeaponSwitch
;
4645 gPlayer2
.setWeaponPrefs(gPlayer2Settings
.WeaponPreferences
);
4646 gPlayer2
.SwitchToEmpty
:= gPlayer2Settings
.SwitchToEmpty
;
4647 gPlayer2
.SkipFist
:= gPlayer2Settings
.SkipFist
;
4651 // Çàãðóçêà è çàïóñê êàðòû:
4652 if not g_Game_StartMap(true{asMegawad}, Map
, True) then
4654 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [Map
]));
4658 // Íåò òî÷åê ïîÿâëåíèÿ:
4659 if (g_Map_GetPointCount(RESPAWNPOINT_PLAYER1
) +
4660 g_Map_GetPointCount(RESPAWNPOINT_PLAYER2
) +
4661 g_Map_GetPointCount(RESPAWNPOINT_DM
) +
4662 g_Map_GetPointCount(RESPAWNPOINT_RED
)+
4663 g_Map_GetPointCount(RESPAWNPOINT_BLUE
)) < 1 then
4665 g_FatalError(_lc
[I_GAME_ERROR_GET_SPAWN
]);
4669 // Íàñòðîéêè èãðîêîâ è áîòîâ:
4673 for i
:= nPl
+1 to nPlayers
do
4674 g_Player_Create(STD_PLAYER_MODEL
, _RGB(0, 0, 0), 0, True);
4677 procedure g_Game_StartServer(Map
: String; GameMode
: Byte;
4678 TimeLimit
, ScoreLimit
: Word; MaxLives
: Byte;
4679 Options
: LongWord
; nPlayers
: Byte;
4680 IPAddr
: LongWord
; Port
: Word);
4683 g_Net_Slist_ServerClosed();
4685 e_WriteLog('Starting net game (server)...', TMsgType
.Notify
);
4687 g_Game_ClearLoading();
4690 gGameSettings
.GameType
:= GT_SERVER
;
4691 gGameSettings
.GameMode
:= GameMode
;
4692 gSwitchGameMode
:= GameMode
;
4693 gGameSettings
.TimeLimit
:= TimeLimit
;
4694 gGameSettings
.ScoreLimit
:= ScoreLimit
;
4695 gGameSettings
.MaxLives
:= IfThen(GameMode
= GM_CTF
, 0, MaxLives
);
4696 gGameSettings
.Options
:= Options
;
4698 gCoopTotalMonstersKilled
:= 0;
4699 gCoopTotalSecretsFound
:= 0;
4700 gCoopTotalMonsters
:= 0;
4701 gCoopTotalSecrets
:= 0;
4705 gLMSRespawn
:= LMS_RESPAWN_NONE
;
4706 gLMSRespawnTime
:= 0;
4707 gSpectLatchPID1
:= 0;
4708 gSpectLatchPID2
:= 0;
4710 g_Game_ExecuteEvent('ongamestart');
4712 // Óñòàíîâêà ðàçìåðîâ îêíà èãðîêà
4713 g_Game_SetupScreenSize();
4715 // Ðåæèì íàáëþäàòåëÿ:
4716 if nPlayers
= 0 then
4722 if nPlayers
>= 1 then
4724 // Ñîçäàíèå ïåðâîãî èãðîêà:
4725 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4726 gPlayer1Settings
.Color
,
4727 gPlayer1Settings
.Team
, False));
4728 if gPlayer1
= nil then
4730 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
4734 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4735 gPlayer1
.WeapSwitchMode
:= gPlayer1Settings
.WeaponSwitch
;
4736 gPlayer1
.setWeaponPrefs(gPlayer1Settings
.WeaponPreferences
);
4737 gPlayer1
.SwitchToEmpty
:= gPlayer1Settings
.SwitchToEmpty
;
4738 gPlayer1
.SkipFist
:= gPlayer1Settings
.SkipFist
;
4741 if nPlayers
>= 2 then
4743 // Ñîçäàíèå âòîðîãî èãðîêà:
4744 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
4745 gPlayer2Settings
.Color
,
4746 gPlayer2Settings
.Team
, False));
4747 if gPlayer2
= nil then
4749 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
4753 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
4754 gPlayer2
.WeapSwitchMode
:= gPlayer2Settings
.WeaponSwitch
;
4755 gPlayer2
.setWeaponPrefs(gPlayer2Settings
.WeaponPreferences
);
4756 gPlayer2
.SwitchToEmpty
:= gPlayer2Settings
.SwitchToEmpty
;
4757 gPlayer2
.SkipFist
:= gPlayer2Settings
.SkipFist
;
4760 g_Game_SetLoadingText(_lc
[I_LOAD_HOST
], 0, False);
4761 if NetForwardPorts
then
4762 g_Game_SetLoadingText(_lc
[I_LOAD_PORTS
], 0, False);
4765 if not g_Net_Host(IPAddr
, Port
, NetMaxClients
) then
4767 g_FatalError(_lc
[I_NET_MSG
] + Format(_lc
[I_NET_ERR_HOST
], [Port
]));
4771 g_Net_Slist_Set(NetMasterList
);
4773 g_Net_Slist_ServerStarted();
4775 // Çàãðóçêà è çàïóñê êàðòû:
4776 if not g_Game_StartMap(false{asMegawad}, Map
, True) then
4778 g_Net_Slist_ServerClosed();
4779 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [Map
]));
4783 // Íåò òî÷åê ïîÿâëåíèÿ:
4784 if (g_Map_GetPointCount(RESPAWNPOINT_PLAYER1
) +
4785 g_Map_GetPointCount(RESPAWNPOINT_PLAYER2
) +
4786 g_Map_GetPointCount(RESPAWNPOINT_DM
) +
4787 g_Map_GetPointCount(RESPAWNPOINT_RED
)+
4788 g_Map_GetPointCount(RESPAWNPOINT_BLUE
)) < 1 then
4790 g_Net_Slist_ServerClosed();
4791 g_FatalError(_lc
[I_GAME_ERROR_GET_SPAWN
]);
4795 // Íàñòðîéêè èãðîêîâ è áîòîâ:
4798 g_Net_Slist_ServerMapStarted();
4799 NetState
:= NET_STATE_GAME
;
4802 procedure g_Game_StartClient(Addr
: String; Port
: Word; PW
: String);
4817 e_WriteLog('Starting net game (client)...', TMsgType
.Notify
);
4818 e_WriteLog('NET: Trying to connect to ' + Addr
+ ':' + IntToStr(Port
) + '...', TMsgType
.Notify
);
4820 g_Game_ClearLoading();
4823 gGameSettings
.GameType
:= GT_CLIENT
;
4825 gCoopTotalMonstersKilled
:= 0;
4826 gCoopTotalSecretsFound
:= 0;
4827 gCoopTotalMonsters
:= 0;
4828 gCoopTotalSecrets
:= 0;
4832 g_Game_ExecuteEvent('ongamestart');
4834 // Óñòàíîâêà ðàçìåðîâ îêîí èãðîêîâ:
4835 g_Game_SetupScreenSize();
4837 NetState
:= NET_STATE_AUTH
;
4839 g_Game_SetLoadingText(_lc
[I_LOAD_CONNECT
], 0, False);
4841 // create (or update) map/resource databases
4842 g_Res_CreateDatabases(true);
4844 gLMSRespawn
:= LMS_RESPAWN_NONE
;
4845 gLMSRespawnTime
:= 0;
4846 gSpectLatchPID1
:= 0;
4847 gSpectLatchPID2
:= 0;
4850 if not g_Net_Connect(Addr
, Port
) then
4852 g_FatalError(_lc
[I_NET_MSG
] + _lc
[I_NET_ERR_CONN
]);
4853 NetState
:= NET_STATE_NONE
;
4857 g_Game_SetLoadingText(_lc
[I_LOAD_SEND_INFO
], 0, False);
4859 g_Game_SetLoadingText(_lc
[I_LOAD_WAIT_INFO
], 0, False);
4864 // fuck! https://www.mail-archive.com/enet-discuss@cubik.org/msg00852.html
4865 // tl;dr: on shitdows, we can get -1 sometimes, and it is *NOT* a failure.
4866 // thank you, enet. let's ignore failures altogether then.
4867 while (enet_host_service(NetHost
, @NetEvent
, 50) > 0) do
4869 if (NetEvent
.kind
= ENET_EVENT_TYPE_RECEIVE
) then
4871 Ptr
:= NetEvent
.packet
^.data
;
4872 if not InMsg
.Init(Ptr
, NetEvent
.packet
^.dataLength
, True) then
4874 enet_packet_destroy(NetEvent
.packet
);
4878 InMsg
.ReadLongWord(); // skip size
4879 MID
:= InMsg
.ReadByte();
4881 if (MID
= NET_MSG_INFO
) and (State
= 0) then
4883 NetMyID
:= InMsg
.ReadByte();
4884 NetPlrUID1
:= InMsg
.ReadWord();
4886 WadName
:= InMsg
.ReadString();
4887 Map
:= InMsg
.ReadString();
4889 gWADHash
:= InMsg
.ReadMD5();
4891 gGameSettings
.GameMode
:= InMsg
.ReadByte();
4892 gSwitchGameMode
:= gGameSettings
.GameMode
;
4893 gGameSettings
.ScoreLimit
:= InMsg
.ReadWord();
4894 gGameSettings
.TimeLimit
:= InMsg
.ReadWord();
4895 gGameSettings
.MaxLives
:= InMsg
.ReadByte();
4896 gGameSettings
.Options
:= InMsg
.ReadLongWord();
4897 T
:= InMsg
.ReadLongWord();
4899 //newResPath := g_Res_SearchSameWAD(MapsDir, WadName, gWADHash);
4900 //if newResPath = '' then
4902 //g_Game_SetLoadingText(_lc[I_LOAD_DL_RES], 0, False);
4903 newResPath
:= g_Res_DownloadMapWAD(ExtractFileName(WadName
), gWADHash
);
4904 if newResPath
= '' then
4906 g_FatalError(_lc
[I_NET_ERR_HASH
]);
4907 enet_packet_destroy(NetEvent
.packet
);
4908 NetState
:= NET_STATE_NONE
;
4911 e_LogWritefln('using downloaded map wad [%s] for [%s]`', [newResPath
, WadName
], TMsgType
.Notify
);
4913 //newResPath := ExtractRelativePath(MapsDir, newResPath);
4916 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4917 gPlayer1Settings
.Color
,
4918 gPlayer1Settings
.Team
, False));
4920 if gPlayer1
= nil then
4922 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
4924 enet_packet_destroy(NetEvent
.packet
);
4925 NetState
:= NET_STATE_NONE
;
4929 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4930 gPlayer1
.WeapSwitchMode
:= gPlayer1Settings
.WeaponSwitch
;
4931 gPlayer1
.setWeaponPrefs(gPlayer1Settings
.WeaponPreferences
);
4932 gPlayer1
.SwitchToEmpty
:= gPlayer1Settings
.SwitchToEmpty
;
4933 gPlayer1
.SkipFist
:= gPlayer1Settings
.SkipFist
;
4934 gPlayer1
.UID
:= NetPlrUID1
;
4935 gPlayer1
.Reset(True);
4937 if not g_Game_StartMap(false{asMegawad}, newResPath
+ ':\' + Map
, True) then
4939 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [WadName
+ ':\' + Map
]));
4941 enet_packet_destroy(NetEvent
.packet
);
4942 NetState
:= NET_STATE_NONE
;
4950 enet_packet_destroy(NetEvent
.packet
);
4954 enet_packet_destroy(NetEvent
.packet
);
4958 if (NetEvent
.kind
= ENET_EVENT_TYPE_DISCONNECT
) then
4961 if (NetEvent
.data
<= NET_DISC_MAX
) then
4962 g_Console_Add(_lc
[I_NET_MSG_ERROR
] + _lc
[I_NET_ERR_CONN
] + ' ' +
4963 _lc
[TStrings_Locale(Cardinal(I_NET_DISC_NONE
) + NetEvent
.data
)], True);
4970 ProcessLoading(True);
4971 if g_Net_UserRequestExit() then
4980 g_FatalError(_lc
[I_NET_MSG
] + _lc
[I_NET_ERR_CONN
]);
4981 NetState
:= NET_STATE_NONE
;
4986 NetState
:= NET_STATE_GAME
;
4987 MC_SEND_FullStateRequest
;
4988 e_WriteLog('NET: Connection successful.', TMsgType
.Notify
);
4992 lastAsMegaWad
: Boolean = false;
4994 procedure g_Game_ChangeMap(const MapPath
: String);
4998 g_Game_ClearLoading();
5000 Force
:= gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
];
5001 // Åñëè óðîâåíü çàâåðøèëñÿ ïî òðèããåðó Âûõîä, íå î÷èùàòü èíâåíòàðü
5002 if gExitByTrigger
then
5005 gExitByTrigger
:= False;
5007 if not g_Game_StartMap(lastAsMegaWad
, MapPath
, Force
) then
5008 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [MapPath
]));
5011 procedure g_Game_Restart();
5015 if g_Game_IsClient
then
5017 map
:= g_ExtractFileName(gMapInfo
.Map
);
5018 e_LogWritefln('g_Game_Restart: map = "%s" gCurrentMapFileName = "%s"', [map
, gCurrentMapFileName
]);
5022 g_Game_ClearLoading();
5023 g_Game_StartMap(lastAsMegaWad
, Map
, True, gCurrentMapFileName
);
5026 function g_Game_StartMap (asMegawad
: Boolean; Map
: String; Force
: Boolean = False; const oldMapPath
: AnsiString
=''): Boolean;
5028 NewWAD
, ResName
: String;
5032 g_Map_Free((Map
<> gCurrentMapFileName
) and (oldMapPath
<> gCurrentMapFileName
));
5033 g_Player_RemoveAllCorpses();
5035 if (not g_Game_IsClient
) and
5036 (gSwitchGameMode
<> gGameSettings
.GameMode
) and
5037 (gGameSettings
.GameMode
<> GM_SINGLE
) then
5039 if gSwitchGameMode
= GM_CTF
then
5040 gGameSettings
.MaxLives
:= 0;
5041 gGameSettings
.GameMode
:= gSwitchGameMode
;
5044 gSwitchGameMode
:= gGameSettings
.GameMode
;
5046 g_Player_ResetTeams();
5048 lastAsMegaWad
:= asMegawad
;
5049 if isWadPath(Map
) then
5051 NewWAD
:= g_ExtractWadName(Map
);
5052 ResName
:= g_ExtractFileName(Map
);
5053 if g_Game_IsServer
then
5055 nws
:= findDiskWad(NewWAD
);
5056 //writeln('000: Map=[', Map, ']; nws=[', nws, ']; NewWAD=[', NewWAD, ']');
5059 if (length(nws
) = 0) then nws
:= e_FindWad(MegawadDirs
, NewWAD
);
5060 if (length(nws
) = 0) then nws
:= e_FindWad(MapDirs
, NewWAD
);
5064 if (length(nws
) = 0) then nws
:= e_FindWad(MapDirs
, NewWAD
);
5065 if (length(nws
) = 0) then nws
:= e_FindWad(MegawadDirs
, NewWAD
);
5067 //if (length(nws) = 0) then nws := e_FindWad(MapDownloadDirs, NewWAD);
5068 //writeln('001: Map=[', Map, ']; nws=[', nws, ']; NewWAD=[', NewWAD, ']');
5070 if (length(nws
) = 0) then
5072 ResName
:= ''; // failed
5077 if (g_Game_IsNet
) then gWADHash
:= MD5File(nws
);
5078 //writeln('********: nws=', nws, ' : Map=', Map, ' : nw=', NewWAD, ' : resname=', ResName);
5079 g_Game_LoadWAD(NewWAD
);
5084 // hash received in MC_RECV_GameEvent -> NET_EV_MAPSTART
5085 NewWAD
:= g_Game_ClientWAD(NewWAD
, gWADHash
);
5090 NewWAD
:= gGameSettings
.WAD
;
5096 //writeln('********: gsw=', gGameSettings.WAD, '; rn=', ResName);
5098 if (ResName
<> '') and (NewWAD
<> '') then
5100 //result := g_Map_Load(gGameSettings.WAD + ':\' + ResName);
5101 result
:= g_Map_Load(NewWAD
+':\'+ResName
);
5105 g_Player_ResetAll(Force
or gLastMap
, gGameSettings
.GameType
= GT_SINGLE
);
5107 gState
:= STATE_NONE
;
5108 g_ActiveWindow
:= nil;
5114 if gGameSettings
.GameMode
= GM_CTF
then
5116 g_Map_ResetFlag(FLAG_RED
);
5117 g_Map_ResetFlag(FLAG_BLUE
);
5118 // CTF, à ôëàãîâ íåò:
5119 if not g_Map_HaveFlagPoints() then
5120 g_SimpleError(_lc
[I_GAME_ERROR_CTF
]);
5125 gState
:= STATE_MENU
;
5130 gPauseMain
:= false;
5131 gPauseHolmes
:= false;
5132 NetTimeToUpdate
:= 1;
5133 NetTimeToReliable
:= 0;
5134 NetTimeToMaster
:= NetMasterRate
;
5135 gSpectLatchPID1
:= 0;
5136 gSpectLatchPID2
:= 0;
5137 gMissionFailed
:= False;
5140 gCoopMonstersKilled
:= 0;
5141 gCoopSecretsFound
:= 0;
5143 gVoteInProgress
:= False;
5144 gVotePassed
:= False;
5150 if not gGameOn
then Exit
;
5152 g_Game_SpectateCenterView();
5154 if g_Game_IsServer
then
5156 if (gGameSettings
.MaxLives
> 0) and (gGameSettings
.WarmupTime
> 0) then
5158 gLMSRespawn
:= LMS_RESPAWN_WARMUP
;
5159 gLMSRespawnTime
:= gTime
+ gGameSettings
.WarmupTime
*1000;
5160 gLMSSoftSpawn
:= True;
5161 if g_Game_IsNet
then
5162 MH_SEND_GameEvent(NET_EV_LMS_WARMUP
, gLMSRespawnTime
- gTime
);
5166 gLMSRespawn
:= LMS_RESPAWN_NONE
;
5167 gLMSRespawnTime
:= 0;
5171 if NetMode
= NET_SERVER
then
5173 // reset full state flags
5174 if NetClients
<> nil then
5175 for I
:= 0 to High(NetClients
) do
5176 NetClients
[I
].FullUpdateSent
:= False;
5178 MH_SEND_GameEvent(NET_EV_MAPSTART
, gGameSettings
.GameMode
, Map
);
5181 g_Net_Slist_ServerMapStarted();
5183 if NetClients
<> nil then
5184 for I
:= 0 to High(NetClients
) do
5185 if NetClients
[I
].Used
then
5187 NetClients
[I
].Voted
:= False;
5188 if NetClients
[I
].RequestedFullUpdate
then
5190 MH_SEND_Everything((NetClients
[I
].State
= NET_STATE_AUTH
), I
);
5191 NetClients
[I
].RequestedFullUpdate
:= False;
5195 g_Net_UnbanNonPermHosts();
5200 gCoopTotalMonstersKilled
:= 0;
5201 gCoopTotalSecretsFound
:= 0;
5202 gCoopTotalMonsters
:= 0;
5203 gCoopTotalSecrets
:= 0;
5207 g_Game_ExecuteEvent('onmapstart');
5210 procedure SetFirstLevel
;
5214 MapList
:= g_Map_GetMapsList(gGameSettings
.WAD
);
5215 if MapList
= nil then
5218 SortSArray(MapList
);
5219 gNextMap
:= MapList
[Low(MapList
)];
5224 procedure g_Game_ExitLevel(const Map
: AnsiString
);
5228 gCoopTotalMonstersKilled
:= gCoopTotalMonstersKilled
+ gCoopMonstersKilled
;
5229 gCoopTotalSecretsFound
:= gCoopTotalSecretsFound
+ gCoopSecretsFound
;
5230 gCoopTotalMonsters
:= gCoopTotalMonsters
+ gTotalMonsters
;
5231 gCoopTotalSecrets
:= gCoopTotalSecrets
+ gSecretsCount
;
5233 // Âûøëè â âûõîä â Îäèíî÷íîé èãðå:
5234 if gGameSettings
.GameType
= GT_SINGLE
then
5235 gExit
:= EXIT_ENDLEVELSINGLE
5236 else // Âûøëè â âûõîä â Ñâîåé èãðå
5238 gExit
:= EXIT_ENDLEVELCUSTOM
;
5239 if gGameSettings
.GameMode
= GM_COOP
then
5240 g_Player_RememberAll
;
5242 if not g_Map_Exist(gGameSettings
.WAD
+ ':\' + gNextMap
) then
5245 if gGameSettings
.GameMode
= GM_COOP
then
5248 gStatsPressed
:= True;
5249 gNextMap
:= 'MAP01';
5251 if not g_Map_Exist(gGameSettings
.WAD
+ ':\' + gNextMap
) then
5254 if g_Game_IsNet
then
5256 MH_SEND_GameStats();
5257 MH_SEND_CoopStats();
5263 procedure g_Game_RestartLevel();
5267 if gGameSettings
.GameMode
= GM_SINGLE
then
5272 gExit
:= EXIT_ENDLEVELCUSTOM
;
5273 Map
:= g_ExtractFileName(gMapInfo
.Map
);
5277 function g_Game_ClientWAD (NewWAD
: String; const WHash
: TMD5Digest
): AnsiString
;
5279 gWAD
{, xwad}: String;
5282 if not g_Game_IsClient
then Exit
;
5283 //e_LogWritefln('*** g_Game_ClientWAD: `%s`', [NewWAD]);
5285 gWAD
:= g_Res_DownloadMapWAD(ExtractFileName(NewWAD
), WHash
);
5290 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_WAD
], [ExtractFileName(NewWAD
)]));
5294 e_LogWritefln('using downloaded client map wad [%s] for [%s]', [gWAD
, NewWAD
], TMsgType
.Notify
);
5297 g_Game_LoadWAD(NewWAD
);
5301 if LowerCase(NewWAD) = LowerCase(gGameSettings.WAD) then Exit;
5302 gWAD := g_Res_SearchSameWAD(MapsDir, ExtractFileName(NewWAD), WHash);
5305 g_Game_SetLoadingText(_lc[I_LOAD_DL_RES], 0, False);
5306 gWAD := g_Res_DownloadMapWAD(ExtractFileName(NewWAD), WHash);
5310 g_FatalError(Format(_lc[I_GAME_ERROR_MAP_WAD], [ExtractFileName(NewWAD)]));
5314 NewWAD := ExtractRelativePath(MapsDir, gWAD);
5315 g_Game_LoadWAD(NewWAD);
5319 procedure g_Game_RestartRound(NoMapRestart
: Boolean = False);
5321 i
, n
, nb
, nr
: Integer;
5323 if not g_Game_IsServer
then Exit
;
5324 if gLMSRespawn
= LMS_RESPAWN_NONE
then Exit
;
5325 gLMSRespawn
:= LMS_RESPAWN_NONE
;
5326 gLMSRespawnTime
:= 0;
5329 if (gGameSettings
.GameMode
= GM_COOP
) and not NoMapRestart
then
5331 gMissionFailed
:= True;
5332 g_Game_RestartLevel
;
5336 n
:= 0; nb
:= 0; nr
:= 0;
5337 for i
:= Low(gPlayers
) to High(gPlayers
) do
5338 if (gPlayers
[i
] <> nil) and
5339 ((not gPlayers
[i
].FSpectator
) or gPlayers
[i
].FWantsInGame
or
5340 (gPlayers
[i
] is TBot
)) then
5343 if gPlayers
[i
].Team
= TEAM_RED
then Inc(nr
)
5344 else if gPlayers
[i
].Team
= TEAM_BLUE
then Inc(nb
)
5347 if (n
< 1) or ((gGameSettings
.GameMode
= GM_TDM
) and ((nr
= 0) or (nb
= 0))) then
5349 // wait a second until the fuckers finally decide to join
5350 gLMSRespawn
:= LMS_RESPAWN_WARMUP
;
5351 gLMSRespawnTime
:= gTime
+ gGameSettings
.WarmupTime
*1000;
5352 gLMSSoftSpawn
:= NoMapRestart
;
5353 if g_Game_IsNet
then
5354 MH_SEND_GameEvent(NET_EV_LMS_WARMUP
, gLMSRespawnTime
- gTime
);
5358 g_Player_RemoveAllCorpses
;
5359 g_Game_Message(_lc
[I_MESSAGE_LMS_START
], 144);
5360 if g_Game_IsNet
then
5361 MH_SEND_GameEvent(NET_EV_LMS_START
);
5363 for i
:= Low(gPlayers
) to High(gPlayers
) do
5365 if gPlayers
[i
] = nil then continue
;
5366 if gPlayers
[i
] is TBot
then gPlayers
[i
].FWantsInGame
:= True;
5367 // don't touch normal spectators
5368 if gPlayers
[i
].FSpectator
and not gPlayers
[i
].FWantsInGame
then
5370 gPlayers
[i
].FNoRespawn
:= True;
5371 gPlayers
[i
].Lives
:= 0;
5372 if g_Game_IsNet
then
5373 MH_SEND_PlayerStats(gPlayers
[I
].UID
);
5376 gPlayers
[i
].FNoRespawn
:= False;
5377 gPlayers
[i
].Lives
:= gGameSettings
.MaxLives
;
5378 gPlayers
[i
].Respawn(False, True);
5379 if gGameSettings
.GameMode
= GM_COOP
then
5381 gPlayers
[i
].Frags
:= 0;
5382 gPlayers
[i
].RecallState
;
5384 if (gPlayer1
= nil) and (gSpectLatchPID1
> 0) then
5385 gPlayer1
:= g_Player_Get(gSpectLatchPID1
);
5386 if (gPlayer2
= nil) and (gSpectLatchPID2
> 0) then
5387 gPlayer2
:= g_Player_Get(gSpectLatchPID2
);
5390 g_Items_RestartRound();
5392 gLMSSoftSpawn
:= False;
5395 function g_Game_GetFirstMap(WAD
: String): String;
5399 MapList
:= g_Map_GetMapsList(WAD
);
5400 if MapList
= nil then
5403 SortSArray(MapList
);
5404 Result
:= MapList
[Low(MapList
)];
5406 if not g_Map_Exist(WAD
+ ':\' + Result
) then
5412 function g_Game_GetNextMap(): String;
5419 MapList
:= g_Map_GetMapsList(gGameSettings
.WAD
);
5420 if MapList
= nil then
5423 Map
:= g_ExtractFileName(gMapInfo
.Map
);
5425 SortSArray(MapList
);
5427 for I
:= Low(MapList
) to High(MapList
) do
5428 if Map
= MapList
[I
] then
5434 if MapIndex
<> -255 then
5436 if MapIndex
= High(MapList
) then
5437 Result
:= MapList
[Low(MapList
)]
5439 Result
:= MapList
[MapIndex
+ 1];
5441 if not g_Map_Exist(gGameSettings
.WAD
+ ':\' + Result
) then Result
:= Map
;
5447 procedure g_Game_NextLevel();
5449 if gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
, GM_COOP
] then
5450 gExit
:= EXIT_ENDLEVELCUSTOM
5453 gExit
:= EXIT_ENDLEVELSINGLE
;
5457 if gNextMap
<> '' then Exit
;
5458 gNextMap
:= g_Game_GetNextMap();
5461 function g_Game_IsTestMap(): Boolean;
5463 result
:= StrEquCI1251(TEST_MAP_NAME
, g_ExtractFileName(gMapInfo
.Map
));
5466 procedure g_Game_DeleteTestMap();
5469 //MapName: AnsiString;
5477 a
:= Pos('.wad:\', toLowerCase1251(gMapToDelete
));
5478 if (a
= 0) then a
:= Pos('.wad:/', toLowerCase1251(gMapToDelete
));
5479 if (a
= 0) then exit
;
5481 // Âûäåëÿåì èìÿ wad-ôàéëà è èìÿ êàðòû
5482 WadName
:= Copy(gMapToDelete
, 1, a
+3);
5483 Delete(gMapToDelete
, 1, a
+5);
5484 gMapToDelete
:= UpperCase(gMapToDelete
);
5486 //CopyMemory(@MapName[0], @gMapToDelete[1], Min(16, Length(gMapToDelete)));
5489 // Èìÿ êàðòû íå ñòàíäàðòíîå òåñòîâîå:
5490 if MapName <> TEST_MAP_NAME then
5493 if not gTempDelete then
5495 time := g_GetFileTime(WadName);
5496 WAD := TWADFile.Create();
5499 if not WAD.ReadFile(WadName) then
5500 begin // Íåò òàêîãî WAD-ôàéëà
5505 // Ñîñòàâëÿåì ñïèñîê êàðò è èùåì íóæíóþ:
5507 MapList := WAD.GetResourcesList('');
5509 if MapList <> nil then
5510 for a := 0 to High(MapList) do
5511 if MapList[a] = MapName then
5513 // Óäàëÿåì è ñîõðàíÿåì:
5514 WAD.RemoveResource('', MapName);
5515 WAD.SaveTo(WadName);
5520 g_SetFileTime(WadName, time);
5523 if gTempDelete
then DeleteFile(WadName
);
5526 procedure GameCVars(P
: SSArray
);
5529 stat
: TPlayerStatArray
;
5532 procedure ParseGameFlag(Flag
: LongWord
; OffMsg
, OnMsg
: TStrings_Locale
; OnMapChange
: Boolean = False);
5536 if Length(P
) > 1 then
5541 gsGameFlags
:= gsGameFlags
or Flag
5543 gsGameFlags
:= gsGameFlags
and (not Flag
);
5545 if g_Game_IsServer
then
5548 gGameSettings
.Options
:= gGameSettings
.Options
or Flag
5550 gGameSettings
.Options
:= gGameSettings
.Options
and (not Flag
);
5551 if g_Game_IsNet
then MH_SEND_GameSettings
;
5555 if LongBool(gsGameFlags
and Flag
) then
5556 g_Console_Add(_lc
[OnMsg
])
5558 g_Console_Add(_lc
[OffMsg
]);
5560 if OnMapChange
and g_Game_IsServer
then
5561 g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
5566 cmd
:= LowerCase(P
[0]);
5568 if cmd
= 'g_gamemode' then
5570 if (Length(P
) > 1) then
5572 a
:= g_Game_TextToMode(P
[1]);
5573 if a
= GM_SINGLE
then a
:= GM_COOP
;
5574 gsGameMode
:= g_Game_ModeToText(a
);
5575 if g_Game_IsServer
then
5577 gSwitchGameMode
:= a
;
5578 if (gGameOn
and (gGameSettings
.GameMode
= GM_SINGLE
)) or
5579 (gState
= STATE_INTERSINGLE
) then
5580 gSwitchGameMode
:= GM_SINGLE
;
5582 gGameSettings
.GameMode
:= gSwitchGameMode
;
5586 if gSwitchGameMode
= gGameSettings
.GameMode
then
5587 g_Console_Add(Format(_lc
[I_MSG_GAMEMODE_CURRENT
],
5588 [g_Game_ModeToText(gGameSettings
.GameMode
)]))
5590 g_Console_Add(Format(_lc
[I_MSG_GAMEMODE_CHANGE
],
5591 [g_Game_ModeToText(gGameSettings
.GameMode
),
5592 g_Game_ModeToText(gSwitchGameMode
)]));
5594 else if cmd
= 'g_friendlyfire' then
5596 ParseGameFlag(GAME_OPTION_TEAMDAMAGE
, I_MSG_FRIENDLY_FIRE_OFF
, I_MSG_FRIENDLY_FIRE_ON
);
5598 else if cmd
= 'g_friendly_absorb_damage' then
5600 ParseGameFlag(GAME_OPTION_TEAMABSORBDAMAGE
, I_MSG_FRIENDLY_ABSORB_DAMAGE_OFF
, I_MSG_FRIENDLY_ABSORB_DAMAGE_ON
);
5602 else if cmd
= 'g_friendly_hit_trace' then
5604 ParseGameFlag(GAME_OPTION_TEAMHITTRACE
, I_MSG_FRIENDLY_HIT_TRACE_OFF
, I_MSG_FRIENDLY_HIT_TRACE_ON
);
5606 else if cmd
= 'g_friendly_hit_projectile' then
5608 ParseGameFlag(GAME_OPTION_TEAMHITPROJECTILE
, I_MSG_FRIENDLY_PROJECT_TRACE_OFF
, I_MSG_FRIENDLY_PROJECT_TRACE_ON
);
5610 else if cmd
= 'g_weaponstay' then
5612 ParseGameFlag(GAME_OPTION_WEAPONSTAY
, I_MSG_WEAPONSTAY_OFF
, I_MSG_WEAPONSTAY_ON
);
5614 else if cmd
= 'g_allow_exit' then
5616 ParseGameFlag(GAME_OPTION_ALLOWEXIT
, I_MSG_ALLOWEXIT_OFF
, I_MSG_ALLOWEXIT_ON
, True);
5618 else if cmd
= 'g_allow_monsters' then
5620 ParseGameFlag(GAME_OPTION_MONSTERS
, I_MSG_ALLOWMON_OFF
, I_MSG_ALLOWMON_ON
, True);
5622 else if cmd
= 'g_allow_dropflag' then
5624 ParseGameFlag(GAME_OPTION_ALLOWDROPFLAG
, I_MSG_ALLOWDROPFLAG_OFF
, I_MSG_ALLOWDROPFLAG_ON
);
5626 else if cmd
= 'g_throw_flag' then
5628 ParseGameFlag(GAME_OPTION_THROWFLAG
, I_MSG_THROWFLAG_OFF
, I_MSG_THROWFLAG_ON
);
5630 else if cmd
= 'g_bot_vsplayers' then
5632 ParseGameFlag(GAME_OPTION_BOTVSPLAYER
, I_MSG_BOTSVSPLAYERS_OFF
, I_MSG_BOTSVSPLAYERS_ON
);
5634 else if cmd
= 'g_bot_vsmonsters' then
5636 ParseGameFlag(GAME_OPTION_BOTVSMONSTER
, I_MSG_BOTSVSMONSTERS_OFF
, I_MSG_BOTSVSMONSTERS_ON
);
5638 else if cmd
= 'g_dm_keys' then
5640 ParseGameFlag(GAME_OPTION_DMKEYS
, I_MSG_DMKEYS_OFF
, I_MSG_DMKEYS_ON
, True);
5642 else if cmd
= 'g_gameflags' then
5644 if Length(P
) > 1 then
5646 gsGameFlags
:= StrToDWordDef(P
[1], gsGameFlags
);
5647 if g_Game_IsServer
then
5649 gGameSettings
.Options
:= gsGameFlags
;
5650 if g_Game_IsNet
then MH_SEND_GameSettings
;
5654 g_Console_Add(Format('%s %u', [cmd
, gsGameFlags
]));
5656 else if cmd
= 'g_warmup_time' then
5658 if Length(P
) > 1 then
5660 gsWarmupTime
:= nclamp(StrToIntDef(P
[1], gsWarmupTime
), 0, $FFFF);
5661 if g_Game_IsServer
then
5663 gGameSettings
.WarmupTime
:= gsWarmupTime
;
5664 // extend warmup if it's already going
5665 if gLMSRespawn
= LMS_RESPAWN_WARMUP
then
5667 gLMSRespawnTime
:= gTime
+ gsWarmupTime
* 1000;
5668 if g_Game_IsNet
then MH_SEND_GameEvent(NET_EV_LMS_WARMUP
, gLMSRespawnTime
- gTime
);
5670 if g_Game_IsNet
then MH_SEND_GameSettings
;
5674 g_Console_Add(Format(_lc
[I_MSG_WARMUP
], [Integer(gsWarmupTime
)]));
5675 if g_Game_IsServer
then g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
5677 else if cmd
= 'g_spawn_invul' then
5679 if Length(P
) > 1 then
5681 gsSpawnInvul
:= nclamp(StrToIntDef(P
[1], gsSpawnInvul
), 0, $FFFF);
5682 if g_Game_IsServer
then
5684 gGameSettings
.SpawnInvul
:= gsSpawnInvul
;
5685 if g_Game_IsNet
then MH_SEND_GameSettings
;
5689 g_Console_Add(Format('%s %d', [cmd
, Integer(gsSpawnInvul
)]));
5691 else if cmd
= 'g_item_respawn_time' then
5693 if Length(P
) > 1 then
5695 gsItemRespawnTime
:= nclamp(StrToIntDef(P
[1], gsItemRespawnTime
), 0, $FFFF);
5696 if g_Game_IsServer
then
5698 gGameSettings
.ItemRespawnTime
:= gsItemRespawnTime
;
5699 if g_Game_IsNet
then MH_SEND_GameSettings
;
5703 g_Console_Add(Format('%s %d', [cmd
, Integer(gsItemRespawnTime
)]));
5704 if g_Game_IsServer
then g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
5706 else if cmd
= 'sv_intertime' then
5708 if (Length(P
) > 1) then
5709 gDefInterTime
:= Min(Max(StrToIntDef(P
[1], gDefInterTime
), -1), 120);
5711 g_Console_Add(cmd
+ ' = ' + IntToStr(gDefInterTime
));
5713 else if cmd
= 'g_max_particles' then
5715 if Length(p
) = 2 then
5717 a
:= Max(0, StrToIntDef(p
[1], 0));
5720 else if Length(p
) = 1 then
5722 e_LogWritefln('%s', [g_GFX_GetMax()])
5726 e_LogWritefln('usage: %s <n>', [cmd
])
5729 else if cmd
= 'g_max_shells' then
5731 if Length(p
) = 2 then
5733 a
:= Max(0, StrToIntDef(p
[1], 0));
5736 else if Length(p
) = 1 then
5738 e_LogWritefln('%s', [g_Shells_GetMax()])
5742 e_LogWritefln('usage: %s <n>', [cmd
])
5745 else if cmd
= 'g_max_gibs' then
5747 if Length(p
) = 2 then
5749 a
:= Max(0, StrToIntDef(p
[1], 0));
5752 else if Length(p
) = 1 then
5754 e_LogWritefln('%s', [g_Gibs_GetMax()])
5758 e_LogWritefln('usage: %s <n>', [cmd
])
5761 else if cmd
= 'g_max_corpses' then
5763 if Length(p
) = 2 then
5765 a
:= Max(0, StrToIntDef(p
[1], 0));
5768 else if Length(p
) = 1 then
5770 e_LogWritefln('%s', [g_Corpses_GetMax()])
5774 e_LogWritefln('usage: %s <n>', [cmd
])
5777 else if cmd
= 'g_force_model' then
5779 if Length(p
) = 2 then
5781 a
:= StrToIntDef(p
[1], 0);
5782 g_Force_Model_Set(a
);
5785 else if cmd
= 'g_force_model_name' then
5787 if (Length(P
) > 1) then
5789 cmd
:= b_Text_Unformat(P
[1]);
5790 g_Forced_Model_SetName(cmd
);
5791 if (gGameSettings
.GameType
<> GT_SINGLE
) and (g_Force_Model_Get() <> 0) and (gPlayers
<> nil) then
5793 for a
:= Low(gPlayers
) to High(gPlayers
) do
5795 if (gPlayers
[a
] <> nil) then
5797 if (gPlayers
[a
].UID
= gPlayer1
.UID
) then
5799 else if (gPlayer2
<> nil) and (gPlayers
[a
].UID
= gPlayer2
.UID
) then
5801 gPlayers
[a
].setModel(g_Forced_Model_GetName());
5807 else if cmd
= 'g_scorelimit' then
5809 if Length(P
) > 1 then
5811 gsScoreLimit
:= nclamp(StrToIntDef(P
[1], gsScoreLimit
), 0, $FFFF);
5813 if g_Game_IsServer
then
5816 if gGameSettings
.GameMode
= GM_DM
then
5818 stat
:= g_Player_GetStats();
5820 for a
:= 0 to High(stat
) do
5821 if stat
[a
].Frags
> b
then
5825 b
:= Max(gTeamStat
[TEAM_RED
].Score
, gTeamStat
[TEAM_BLUE
].Score
);
5827 // if someone has a higher score, set it to that instead
5828 gsScoreLimit
:= max(gsScoreLimit
, b
);
5829 gGameSettings
.ScoreLimit
:= gsScoreLimit
;
5831 if g_Game_IsNet
then MH_SEND_GameSettings
;
5835 g_Console_Add(Format(_lc
[I_MSG_SCORE_LIMIT
], [Integer(gsScoreLimit
)]));
5837 else if cmd
= 'g_timelimit' then
5839 if Length(P
) > 1 then
5841 gsTimeLimit
:= nclamp(StrToIntDef(P
[1], gsTimeLimit
), 0, $FFFF);
5842 if g_Game_IsServer
then
5844 gGameSettings
.TimeLimit
:= gsTimeLimit
;
5845 if g_Game_IsNet
then MH_SEND_GameSettings
;
5848 g_Console_Add(Format(_lc
[I_MSG_TIME_LIMIT
],
5849 [gsTimeLimit
div 3600,
5850 (gsTimeLimit
div 60) mod 60,
5851 gsTimeLimit
mod 60]));
5853 else if cmd
= 'g_max_bots' then
5855 if Length(P
) > 1 then
5856 gMaxBots
:= nclamp(StrToIntDef(P
[1], gMaxBots
), 0, 127);
5857 g_Console_Add('g_max_bots = ' + IntToStr(gMaxBots
));
5859 else if cmd
= 'g_maxlives' then
5861 if Length(P
) > 1 then
5863 gsMaxLives
:= nclamp(StrToIntDef(P
[1], gsMaxLives
), 0, $FFFF);
5864 if g_Game_IsServer
then
5866 gGameSettings
.MaxLives
:= gsMaxLives
;
5867 if g_Game_IsNet
then MH_SEND_GameSettings
;
5871 g_Console_Add(Format(_lc
[I_MSG_LIVES
], [Integer(gsMaxLives
)]));
5875 procedure PlayerSettingsCVars(P
: SSArray
);
5880 function ParseTeam(s
: string): Byte;
5884 'red', '1': result
:= TEAM_RED
;
5885 'blue', '2': result
:= TEAM_BLUE
;
5886 else result
:= TEAM_NONE
;
5890 cmd
:= LowerCase(P
[0]);
5894 if (Length(P
) > 1) then
5896 gPlayer1Settings
.Name
:= b_Text_Unformat(P
[1]);
5897 if g_Game_IsClient
then
5898 MC_SEND_PlayerSettings
5899 else if gGameOn
and (gPlayer1
<> nil) then
5901 gPlayer1
.Name
:= b_Text_Unformat(P
[1]);
5902 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer1
.UID
);
5908 if (Length(P
) > 1) then
5910 gPlayer2Settings
.Name
:= b_Text_Unformat(P
[1]);
5911 if g_Game_IsClient
then
5912 MC_SEND_PlayerSettings
5913 else if gGameOn
and (gPlayer2
<> nil) then
5915 gPlayer2
.Name
:= b_Text_Unformat(P
[1]);
5916 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer2
.UID
);
5922 if Length(P
) > 3 then
5924 gPlayer1Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
5925 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
5926 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
5927 if g_Game_IsClient
then
5928 MC_SEND_PlayerSettings
5929 else if gGameOn
and (gPlayer1
<> nil) then
5931 gPlayer1
.SetColor(gPlayer1Settings
.Color
);
5932 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer1
.UID
);
5938 if Length(P
) > 3 then
5940 gPlayer2Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
5941 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
5942 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
5943 if g_Game_IsClient
then
5944 MC_SEND_PlayerSettings
5945 else if gGameOn
and (gPlayer2
<> nil) then
5947 gPlayer2
.SetColor(gPlayer2Settings
.Color
);
5948 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer2
.UID
);
5954 if (Length(P
) > 1) then
5956 gPlayer1Settings
.Model
:= P
[1];
5957 if g_Game_IsClient
then
5958 MC_SEND_PlayerSettings
5959 else if gGameOn
and (gPlayer1
<> nil) then
5961 gPlayer1
.FActualModelName
:= gPlayer1Settings
.Model
;
5962 gPlayer1
.SetModel(gPlayer1Settings
.Model
);
5963 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer1
.UID
);
5969 if (Length(P
) > 1) then
5971 gPlayer2Settings
.Model
:= P
[1];
5972 if g_Game_IsClient
then
5973 MC_SEND_PlayerSettings
5974 else if gGameOn
and (gPlayer2
<> nil) then
5976 gPlayer2
.FActualModelName
:= gPlayer2Settings
.Model
;
5977 gPlayer2
.SetModel(gPlayer2Settings
.Model
);
5978 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer2
.UID
);
5984 // TODO: switch teams if in game or store this separately
5985 if (Length(P
) > 1) then
5987 team
:= ParseTeam(P
[1]);
5988 if team
= TEAM_NONE
then
5989 g_Console_Add('expected ''red'', ''blue'', 1 or 2')
5990 else if not gGameOn
and not g_Game_IsNet
then
5991 gPlayer1Settings
.Team
:= team
5993 g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
5998 // TODO: switch teams if in game or store this separately
5999 if (Length(P
) > 1) then
6001 team
:= ParseTeam(P
[1]);
6002 if team
= TEAM_NONE
then
6003 g_Console_Add('expected ''red'', ''blue'', 1 or 2')
6004 else if not gGameOn
and not g_Game_IsNet
then
6005 gPlayer2Settings
.Team
:= team
6007 g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
6012 if (Length(P
) = 2) then
6013 gPlayer1Settings
.WeaponSwitch
:= EnsureRange(StrTointDef(P
[1], 0), 0, 2);
6017 if (Length(P
) = 2) then
6018 gPlayer2Settings
.WeaponSwitch
:= EnsureRange(StrTointDef(P
[1], 0), 0, 2);
6022 if (Length(P
) = 2) then
6023 gPlayer1Settings
.SwitchToEmpty
:= EnsureRange(StrTointDef(P
[1], 0), 0, 1);
6027 if (Length(P
) = 2) then
6028 gPlayer2Settings
.SwitchToEmpty
:= EnsureRange(StrTointDef(P
[1], 0), 0, 1);
6032 if (Length(P
) = 2) then
6033 gPlayer1Settings
.SkipFist
:= EnsureRange(StrTointDef(P
[1], 0), 0, 1);
6037 if (Length(P
) = 2) then
6038 gPlayer2Settings
.SkipFist
:= EnsureRange(StrTointDef(P
[1], 0), 0, 1);
6040 'p1_priority_kastet':
6042 if (Length(P
) = 2) then
6043 gPlayer1Settings
.WeaponPreferences
[WEAPON_KASTET
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6045 'p2_priority_kastet':
6047 if (Length(P
) = 2) then
6048 gPlayer2Settings
.WeaponPreferences
[WEAPON_KASTET
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6052 if (Length(P
) = 2) then
6053 gPlayer1Settings
.WeaponPreferences
[WEAPON_SAW
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6057 if (Length(P
) = 2) then
6058 gPlayer2Settings
.WeaponPreferences
[WEAPON_SAW
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6060 'p1_priority_pistol':
6062 if (Length(P
) = 2) then
6063 gPlayer1Settings
.WeaponPreferences
[WEAPON_KASTET
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6065 'p2_priority_pistol':
6067 if (Length(P
) = 2) then
6068 gPlayer2Settings
.WeaponPreferences
[WEAPON_KASTET
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6070 'p1_priority_shotgun1':
6072 if (Length(P
) = 2) then
6073 gPlayer1Settings
.WeaponPreferences
[WEAPON_SHOTGUN1
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6075 'p2_priority_shotgun1':
6077 if (Length(P
) = 2) then
6078 gPlayer2Settings
.WeaponPreferences
[WEAPON_SHOTGUN1
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6080 'p1_priority_shotgun2':
6082 if (Length(P
) = 2) then
6083 gPlayer1Settings
.WeaponPreferences
[WEAPON_SHOTGUN2
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6085 'p2_priority_shotgun2':
6087 if (Length(P
) = 2) then
6088 gPlayer2Settings
.WeaponPreferences
[WEAPON_SHOTGUN2
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6090 'p1_priority_chaingun':
6092 if (Length(P
) = 2) then
6093 gPlayer1Settings
.WeaponPreferences
[WEAPON_CHAINGUN
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6095 'p2_priority_chaingun':
6097 if (Length(P
) = 2) then
6098 gPlayer2Settings
.WeaponPreferences
[WEAPON_CHAINGUN
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6100 'p1_priority_rocketlauncher':
6102 if (Length(P
) = 2) then
6103 gPlayer1Settings
.WeaponPreferences
[WEAPON_ROCKETLAUNCHER
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6105 'p2_priority_rocketlauncher':
6107 if (Length(P
) = 2) then
6108 gPlayer2Settings
.WeaponPreferences
[WEAPON_ROCKETLAUNCHER
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6110 'p1_priority_plasma':
6112 if (Length(P
) = 2) then
6113 gPlayer1Settings
.WeaponPreferences
[WEAPON_PLASMA
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6115 'p2_priority_plasma':
6117 if (Length(P
) = 2) then
6118 gPlayer2Settings
.WeaponPreferences
[WEAPON_PLASMA
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6122 if (Length(P
) = 2) then
6123 gPlayer1Settings
.WeaponPreferences
[WEAPON_BFG
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6127 if (Length(P
) = 2) then
6128 gPlayer2Settings
.WeaponPreferences
[WEAPON_BFG
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6130 'p1_priority_super':
6132 if (Length(P
) = 2) then
6133 gPlayer1Settings
.WeaponPreferences
[WEAPON_SUPERPULEMET
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6135 'p2_priority_super':
6137 if (Length(P
) = 2) then
6138 gPlayer2Settings
.WeaponPreferences
[WEAPON_SUPERPULEMET
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6140 'p1_priority_flamethrower':
6142 if (Length(P
) = 2) then
6143 gPlayer1Settings
.WeaponPreferences
[WEAPON_FLAMETHROWER
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6145 'p2_priority_flamethrower':
6147 if (Length(P
) = 2) then
6148 gPlayer2Settings
.WeaponPreferences
[WEAPON_FLAMETHROWER
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6150 'p1_priority_berserk':
6152 if (Length(P
) = 2) then
6153 gPlayer1Settings
.WeaponPreferences
[WP_LAST
+1] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6155 'p2_priority_berserk':
6157 if (Length(P
) = 2) then
6158 gPlayer2Settings
.WeaponPreferences
[WP_LAST
+1] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6163 procedure PrintHeapStats();
6167 hs
:= GetFPCHeapStatus();
6168 e_LogWriteLn ('v===== heap status =====v');
6169 e_LogWriteFln('max heap size = %d k', [hs
.MaxHeapSize
div 1024]);
6170 e_LogWriteFln('max heap used = %d k', [hs
.MaxHeapUsed
div 1024]);
6171 e_LogWriteFln('cur heap size = %d k', [hs
.CurrHeapSize
div 1024]);
6172 e_LogWriteFln('cur heap used = %d k', [hs
.CurrHeapUsed
div 1024]);
6173 e_LogWriteFln('cur heap free = %d k', [hs
.CurrHeapFree
div 1024]);
6174 e_LogWriteLn ('^=======================^');
6177 procedure DebugCommands(P
: SSArray
);
6184 // Êîìàíäû îòëàäî÷íîãî ðåæèìà:
6185 if {gDebugMode}conIsCheatsEnabled
then
6187 cmd
:= LowerCase(P
[0]);
6188 if cmd
= 'd_window' then
6190 g_Console_Add(Format('gScreenWidth = %d, gScreenHeight = %d', [gScreenWidth
, gScreenHeight
]));
6191 g_Console_Add(Format('gScreenWidth = %d, gScreenHeight = %d', [gScreenWidth
, gScreenHeight
]));
6193 else if cmd
= 'd_sounds' then
6195 if (Length(P
) > 1) and
6196 ((P
[1] = '1') or (P
[1] = '0')) then
6197 g_Debug_Sounds
:= (P
[1][1] = '1');
6199 g_Console_Add(Format('d_sounds is %d', [Byte(g_Debug_Sounds
)]));
6201 else if cmd
= 'd_frames' then
6203 if (Length(P
) > 1) and
6204 ((P
[1] = '1') or (P
[1] = '0')) then
6205 g_Debug_Frames
:= (P
[1][1] = '1');
6207 g_Console_Add(Format('d_frames is %d', [Byte(g_Debug_Frames
)]));
6209 else if cmd
= 'd_winmsg' then
6211 if (Length(P
) > 1) and
6212 ((P
[1] = '1') or (P
[1] = '0')) then
6213 g_Debug_WinMsgs
:= (P
[1][1] = '1');
6215 g_Console_Add(Format('d_winmsg is %d', [Byte(g_Debug_WinMsgs
)]));
6217 else if (cmd
= 'd_monoff') and not g_Game_IsNet
then
6219 if (Length(P
) > 1) and
6220 ((P
[1] = '1') or (P
[1] = '0')) then
6221 g_Debug_MonsterOff
:= (P
[1][1] = '1');
6223 g_Console_Add(Format('d_monoff is %d', [Byte(g_debug_MonsterOff
)]));
6225 else if (cmd
= 'd_botoff') and not g_Game_IsNet
then
6227 if Length(P
) > 1 then
6229 '0': g_debug_BotAIOff
:= 0;
6230 '1': g_debug_BotAIOff
:= 1;
6231 '2': g_debug_BotAIOff
:= 2;
6232 '3': g_debug_BotAIOff
:= 3;
6235 g_Console_Add(Format('d_botoff is %d', [g_debug_BotAIOff
]));
6237 else if cmd
= 'd_monster' then
6239 if gGameOn
and (gPlayer1
<> nil) and (gPlayer1
.alive
) and (not g_Game_IsNet
) then
6240 if Length(P
) < 2 then
6242 g_Console_Add(cmd
+ ' [ID | Name] [behaviour]');
6243 g_Console_Add('ID | Name');
6244 for b
:= MONSTER_DEMON
to MONSTER_MAN
do
6245 g_Console_Add(Format('%2d | %s', [b
, g_Mons_NameByTypeId(b
)]));
6246 conwriteln('behav. num'#10'normal 0'#10'killer 1'#10'maniac 2'#10'insane 3'#10'cannibal 4'#10'good 5');
6249 a
:= StrToIntDef(P
[1], 0);
6250 if (a
< MONSTER_DEMON
) or (a
> MONSTER_MAN
) then
6251 a
:= g_Mons_TypeIdByName(P
[1]);
6253 if (a
< MONSTER_DEMON
) or (a
> MONSTER_MAN
) then
6254 g_Console_Add(Format(_lc
[I_MSG_NO_MONSTER
], [P
[1]]))
6257 with gPlayer1
.Obj
do
6259 mon
:= g_Monsters_Create(a
,
6260 X
+ Rect
.X
+ (Rect
.Width
div 2),
6261 Y
+ Rect
.Y
+ Rect
.Height
,
6262 gPlayer1
.Direction
, True);
6264 if (Length(P
) > 2) and (mon
<> nil) then
6266 if (CompareText(P
[2], 'normal') = 0) then mon
.MonsterBehaviour
:= BH_NORMAL
6267 else if (CompareText(P
[2], 'killer') = 0) then mon
.MonsterBehaviour
:= BH_KILLER
6268 else if (CompareText(P
[2], 'maniac') = 0) then mon
.MonsterBehaviour
:= BH_MANIAC
6269 else if (CompareText(P
[2], 'insane') = 0) then mon
.MonsterBehaviour
:= BH_INSANE
6270 else if (CompareText(P
[2], 'cannibal') = 0) then mon
.MonsterBehaviour
:= BH_CANNIBAL
6271 else if (CompareText(P
[2], 'good') = 0) then mon
.MonsterBehaviour
:= BH_GOOD
6272 else if (CompareText(P
[2], 'friend') = 0) then mon
.MonsterBehaviour
:= BH_GOOD
6273 else if (CompareText(P
[2], 'friendly') = 0) then mon
.MonsterBehaviour
:= BH_GOOD
6274 else mon
.MonsterBehaviour
:= Min(Max(StrToIntDef(P
[2], BH_NORMAL
), BH_NORMAL
), BH_GOOD
);
6279 else if (cmd
= 'd_health') then
6281 if (Length(P
) > 1) and
6282 ((P
[1] = '1') or (P
[1] = '0')) then
6283 g_debug_HealthBar
:= (P
[1][1] = '1');
6285 g_Console_Add(Format('d_health is %d', [Byte(g_debug_HealthBar
)]));
6287 else if (cmd
= 'd_player') then
6289 if (Length(P
) > 1) and
6290 ((P
[1] = '1') or (P
[1] = '0')) then
6291 g_debug_Player
:= (P
[1][1] = '1');
6293 g_Console_Add(Format(cmd
+ ' is %d', [Byte(g_Debug_Player
)]));
6295 else if (cmd
= 'd_mem') then
6301 g_Console_Add(_lc
[I_MSG_NOT_DEBUG
]);
6305 procedure GameCheats(P
: SSArray
);
6311 if (not gGameOn
) or (not conIsCheatsEnabled
) then
6313 g_Console_Add('not available');
6319 g_Console_Add('where is the player?!');
6322 cmd
:= LowerCase(P
[0]);
6326 plr
.GodMode
:= not plr
.GodMode
;
6327 if plr
.GodMode
then g_Console_Add('player is godlike now') else g_Console_Add('player is mortal now');
6330 // give <health|exit|weapons|air|suit|jetpack|berserk|all>
6331 if cmd
= 'give' then
6333 if length(P
) < 2 then begin g_Console_Add('give what?!'); exit
; end;
6334 for f
:= 1 to High(P
) do
6336 cmd
:= LowerCase(P
[f
]);
6337 if cmd
= 'health' then begin plr
.RestoreHealthArmor(); g_Console_Add('player feels himself better'); continue
; end;
6338 if (cmd
= 'all') {or (cmd = 'weapons')} then begin plr
.AllRulez(False); g_Console_Add('player got the gifts'); continue
; end;
6339 if cmd
= 'exit' then
6341 if gTriggers
<> nil then
6343 for a
:= 0 to High(gTriggers
) do
6345 if gTriggers
[a
].TriggerType
= TRIGGER_EXIT
then
6347 g_Console_Add('player left the map');
6348 gExitByTrigger
:= True;
6349 //g_Game_ExitLevel(gTriggers[a].Data.MapName);
6350 g_Game_ExitLevel(gTriggers
[a
].tgcMap
);
6358 if cmd
= 'air' then begin plr
.GiveItem(ITEM_OXYGEN
); g_Console_Add('player got some air'); continue
; end;
6359 if cmd
= 'jetpack' then begin plr
.GiveItem(ITEM_JETPACK
); g_Console_Add('player got a jetpack'); continue
; end;
6360 if cmd
= 'suit' then begin plr
.GiveItem(ITEM_SUIT
); g_Console_Add('player got an envirosuit'); continue
; end;
6361 if cmd
= 'berserk' then begin plr
.GiveItem(ITEM_MEDKIT_BLACK
); g_Console_Add('player got a berserk pack'); continue
; end;
6362 if cmd
= 'backpack' then begin plr
.GiveItem(ITEM_AMMO_BACKPACK
); g_Console_Add('player got a backpack'); continue
; end;
6364 if cmd
= 'helmet' then begin plr
.GiveItem(ITEM_HELMET
); g_Console_Add('player got a helmet'); continue
; end;
6365 if cmd
= 'bottle' then begin plr
.GiveItem(ITEM_BOTTLE
); g_Console_Add('player got a bottle of health'); continue
; end;
6367 if cmd
= 'stimpack' then begin plr
.GiveItem(ITEM_MEDKIT_SMALL
); g_Console_Add('player got a stimpack'); continue
; end;
6368 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;
6370 if cmd
= 'greenarmor' then begin plr
.GiveItem(ITEM_ARMOR_GREEN
); g_Console_Add('player got a security armor'); continue
; end;
6371 if cmd
= 'bluearmor' then begin plr
.GiveItem(ITEM_ARMOR_BLUE
); g_Console_Add('player got a combat armor'); continue
; end;
6373 if (cmd
= 'megasphere') or (cmd
= 'mega') then begin plr
.GiveItem(ITEM_SPHERE_BLUE
); g_Console_Add('player got a megasphere'); continue
; end;
6374 if (cmd
= 'soulsphere') or (cmd
= 'soul')then begin plr
.GiveItem(ITEM_SPHERE_WHITE
); g_Console_Add('player got a soul sphere'); continue
; end;
6376 if (cmd
= 'invul') or (cmd
= 'invulnerability') then begin plr
.GiveItem(ITEM_INVUL
); g_Console_Add('player got invulnerability'); continue
; end;
6377 if (cmd
= 'invis') or (cmd
= 'invisibility') then begin plr
.GiveItem(ITEM_INVIS
); g_Console_Add('player got invisibility'); continue
; end;
6379 if cmd
= 'redkey' then begin plr
.GiveItem(ITEM_KEY_RED
); g_Console_Add('player got the red key'); continue
; end;
6380 if cmd
= 'greenkey' then begin plr
.GiveItem(ITEM_KEY_GREEN
); g_Console_Add('player got the green key'); continue
; end;
6381 if cmd
= 'bluekey' then begin plr
.GiveItem(ITEM_KEY_BLUE
); g_Console_Add('player got the blue key'); continue
; end;
6383 if (cmd
= 'shotgun') or (cmd
= 'sg') then begin plr
.GiveItem(ITEM_WEAPON_SHOTGUN1
); g_Console_Add('player got a shotgun'); continue
; end;
6384 if (cmd
= 'supershotgun') or (cmd
= 'ssg') then begin plr
.GiveItem(ITEM_WEAPON_SHOTGUN2
); g_Console_Add('player got a supershotgun'); continue
; end;
6385 if cmd
= 'chaingun' then begin plr
.GiveItem(ITEM_WEAPON_CHAINGUN
); g_Console_Add('player got a chaingun'); continue
; end;
6386 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;
6387 if cmd
= 'plasmagun' then begin plr
.GiveItem(ITEM_WEAPON_PLASMA
); g_Console_Add('player got a plasma gun'); continue
; end;
6388 if cmd
= 'bfg' then begin plr
.GiveItem(ITEM_WEAPON_BFG
); g_Console_Add('player got a BFG-9000'); continue
; end;
6390 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;
6391 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;
6392 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;
6393 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;
6394 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;
6395 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;
6397 if cmd
= 'superchaingun' then begin plr
.GiveItem(ITEM_WEAPON_SUPERPULEMET
); g_Console_Add('player got a superchaingun'); continue
; end;
6398 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;
6400 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;
6401 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;
6403 if cmd
= 'chainsaw' then begin plr
.GiveItem(ITEM_WEAPON_SAW
); g_Console_Add('player got a chainsaw'); continue
; end;
6405 if cmd
= 'ammo' then
6407 plr
.GiveItem(ITEM_AMMO_SHELLS_BOX
);
6408 plr
.GiveItem(ITEM_AMMO_BULLETS_BOX
);
6409 plr
.GiveItem(ITEM_AMMO_CELL_BIG
);
6410 plr
.GiveItem(ITEM_AMMO_ROCKET_BOX
);
6411 plr
.GiveItem(ITEM_AMMO_FUELCAN
);
6412 g_Console_Add('player got some ammo');
6416 if cmd
= 'clip' then begin plr
.GiveItem(ITEM_AMMO_BULLETS
); g_Console_Add('player got some bullets'); continue
; end;
6417 if cmd
= 'bullets' then begin plr
.GiveItem(ITEM_AMMO_BULLETS_BOX
); g_Console_Add('player got a box of bullets'); continue
; end;
6419 if cmd
= 'shells' then begin plr
.GiveItem(ITEM_AMMO_SHELLS
); g_Console_Add('player got some shells'); continue
; end;
6420 if cmd
= 'shellbox' then begin plr
.GiveItem(ITEM_AMMO_SHELLS_BOX
); g_Console_Add('player got a box of shells'); continue
; end;
6422 if cmd
= 'cells' then begin plr
.GiveItem(ITEM_AMMO_CELL
); g_Console_Add('player got some cells'); continue
; end;
6423 if cmd
= 'battery' then begin plr
.GiveItem(ITEM_AMMO_CELL_BIG
); g_Console_Add('player got cell battery'); continue
; end;
6425 if cmd
= 'rocket' then begin plr
.GiveItem(ITEM_AMMO_ROCKET
); g_Console_Add('player got a rocket'); continue
; end;
6426 if cmd
= 'rocketbox' then begin plr
.GiveItem(ITEM_AMMO_ROCKET_BOX
); g_Console_Add('player got some rockets'); continue
; end;
6428 if (cmd
= 'fuel') or (cmd
= 'fuelcan') then begin plr
.GiveItem(ITEM_AMMO_FUELCAN
); g_Console_Add('player got fuel canister'); continue
; end;
6430 if cmd
= 'weapons' then
6432 plr
.GiveItem(ITEM_WEAPON_SHOTGUN1
);
6433 plr
.GiveItem(ITEM_WEAPON_SHOTGUN2
);
6434 plr
.GiveItem(ITEM_WEAPON_CHAINGUN
);
6435 plr
.GiveItem(ITEM_WEAPON_ROCKETLAUNCHER
);
6436 plr
.GiveItem(ITEM_WEAPON_PLASMA
);
6437 plr
.GiveItem(ITEM_WEAPON_BFG
);
6438 g_Console_Add('player got weapons');
6442 if cmd
= 'keys' then
6444 plr
.GiveItem(ITEM_KEY_RED
);
6445 plr
.GiveItem(ITEM_KEY_GREEN
);
6446 plr
.GiveItem(ITEM_KEY_BLUE
);
6447 g_Console_Add('player got all keys');
6451 g_Console_Add('i don''t know how to give '''+cmd
+'''!');
6456 if cmd
= 'open' then
6458 g_Console_Add('player activated sesame');
6459 g_Triggers_OpenAll();
6466 if gFly
then g_Console_Add('player feels himself lighter') else g_Console_Add('player lost his wings');
6470 if cmd
= 'noclip' then
6473 g_Console_Add('wall hardeness adjusted');
6477 if cmd
= 'notarget' then
6479 plr
.NoTarget
:= not plr
.NoTarget
;
6480 if plr
.NoTarget
then g_Console_Add('player hides in shadows') else g_Console_Add('player is brave again');
6484 if cmd
= 'noreload' then
6486 plr
.NoReload
:= not plr
.NoReload
;
6487 if plr
.NoReload
then g_Console_Add('player is action hero now') else g_Console_Add('player is ordinary man now');
6491 if cmd
= 'speedy' then
6493 MAX_RUNVEL
:= 32-MAX_RUNVEL
;
6494 g_Console_Add('speed adjusted');
6498 if cmd
= 'jumpy' then
6500 VEL_JUMP
:= 30-VEL_JUMP
;
6501 g_Console_Add('jump height adjusted');
6505 if cmd
= 'automap' then
6507 gShowMap
:= not gShowMap
;
6508 if gShowMap
then g_Console_Add('player gains second sight') else g_Console_Add('player lost second sight');
6512 if cmd
= 'aimline' then
6514 gAimLine
:= not gAimLine
;
6515 if gAimLine
then g_Console_Add('player gains laser sight') else g_Console_Add('player lost laser sight');
6520 procedure GameCommands(P
: SSArray
);
6526 pl
: pTNetClient
= nil;
6534 cmd
:= LowerCase(P
[0]);
6536 if cmd
= 'pause' then
6538 if (g_ActiveWindow
= nil) then
6539 g_Game_Pause(not gPauseMain
);
6541 else if cmd
= 'endgame' then
6542 gExit
:= EXIT_SIMPLE
6543 else if cmd
= 'restart' then
6545 if gGameOn
or (gState
in [STATE_INTERSINGLE
, STATE_INTERCUSTOM
]) then
6547 if g_Game_IsClient
then
6549 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6554 g_Console_Add(_lc
[I_MSG_NOT_GAME
]);
6556 else if cmd
= 'kick' then
6558 if g_Game_IsServer
then
6560 if Length(P
) < 2 then
6562 g_Console_Add('kick <name>');
6567 g_Console_Add('kick <name>');
6571 if g_Game_IsNet
then
6572 pl
:= g_Net_Client_ByName(P
[1]);
6575 s
:= g_Net_ClientName_ByID(pl
^.ID
);
6576 enet_peer_disconnect(pl
^.Peer
, NET_DISC_KICK
);
6577 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
6578 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
6579 g_Net_Slist_ServerPlayerLeaves();
6580 end else if gPlayers
<> nil then
6581 for a
:= Low(gPlayers
) to High(gPlayers
) do
6582 if gPlayers
[a
] <> nil then
6583 if Copy(LowerCase(gPlayers
[a
].Name
), 1, Length(P
[1])) = LowerCase(P
[1]) then
6585 // Íå îòêëþ÷àòü îñíîâíûõ èãðîêîâ â ñèíãëå
6586 if not(gPlayers
[a
] is TBot
) and (gGameSettings
.GameType
= GT_SINGLE
) then
6588 gPlayers
[a
].Lives
:= 0;
6589 gPlayers
[a
].Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
6590 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [gPlayers
[a
].Name
]), True);
6591 g_Player_Remove(gPlayers
[a
].UID
);
6592 g_Net_Slist_ServerPlayerLeaves();
6593 // Åñëè íå ïåðåìåøàòü, ïðè äîáàâëåíèè íîâûõ áîòîâ ïîÿâÿòñÿ ñòàðûå
6597 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6599 else if cmd
= 'kick_id' then
6601 if g_Game_IsServer
and g_Game_IsNet
then
6603 if Length(P
) < 2 then
6605 g_Console_Add('kick_id <client ID>');
6610 g_Console_Add('kick_id <client ID>');
6614 a
:= StrToIntDef(P
[1], 0);
6615 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
6617 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
6619 s
:= g_Net_ClientName_ByID(NetClients
[a
].ID
);
6620 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_KICK
);
6621 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
6622 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
6623 g_Net_Slist_ServerPlayerLeaves();
6627 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6629 else if cmd
= 'kick_pid' then
6631 if g_Game_IsServer
and g_Game_IsNet
then
6633 if Length(P
) < 2 then
6635 g_Console_Add('kick_pid <player ID>');
6640 g_Console_Add('kick_pid <player ID>');
6644 a
:= StrToIntDef(P
[1], 0);
6645 pl
:= g_Net_Client_ByPlayer(a
);
6646 if (pl
<> nil) and pl
^.Used
and (pl
^.Peer
<> nil) then
6648 s
:= g_Net_ClientName_ByID(pl
^.ID
);
6649 enet_peer_disconnect(pl
^.Peer
, NET_DISC_KICK
);
6650 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
6651 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
6652 g_Net_Slist_ServerPlayerLeaves();
6655 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6657 else if cmd
= 'ban' then
6659 if g_Game_IsServer
and g_Game_IsNet
then
6661 if Length(P
) < 2 then
6663 g_Console_Add('ban <name>');
6668 g_Console_Add('ban <name>');
6672 pl
:= g_Net_Client_ByName(P
[1]);
6675 s
:= g_Net_ClientName_ByID(pl
^.ID
);
6676 g_Net_BanHost(pl
^.Peer
^.address
.host
, False);
6677 enet_peer_disconnect(pl
^.Peer
, NET_DISC_TEMPBAN
);
6678 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
6679 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
6680 g_Net_Slist_ServerPlayerLeaves();
6682 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
6684 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6686 else if cmd
= 'ban_id' then
6688 if g_Game_IsServer
and g_Game_IsNet
then
6690 if Length(P
) < 2 then
6692 g_Console_Add('ban_id <client ID>');
6697 g_Console_Add('ban_id <client ID>');
6701 a
:= StrToIntDef(P
[1], 0);
6702 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
6703 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
6705 s
:= g_Net_ClientName_ByID(NetClients
[a
].ID
);
6706 g_Net_BanHost(NetClients
[a
].Peer
^.address
.host
, False);
6707 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_TEMPBAN
);
6708 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
6709 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
6710 g_Net_Slist_ServerPlayerLeaves();
6713 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6715 else if cmd
= 'ban_pid' then
6717 if g_Game_IsServer
and g_Game_IsNet
then
6719 if Length(P
) < 2 then
6721 g_Console_Add('ban_pid <player ID>');
6726 g_Console_Add('ban_pid <player ID>');
6730 a
:= StrToIntDef(P
[1], 0);
6731 pl
:= g_Net_Client_ByPlayer(a
);
6732 if (pl
<> nil) and pl
^.Used
and (pl
^.Peer
<> nil) then
6734 s
:= g_Net_ClientName_ByID(pl
^.ID
);
6735 g_Net_BanHost(pl
^.Peer
^.address
.host
, False);
6736 enet_peer_disconnect(pl
^.Peer
, NET_DISC_TEMPBAN
);
6737 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
6738 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
6739 g_Net_Slist_ServerPlayerLeaves();
6742 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6744 else if cmd
= 'permban' then
6746 if g_Game_IsServer
and g_Game_IsNet
then
6748 if Length(P
) < 2 then
6750 g_Console_Add('permban <name>');
6755 g_Console_Add('permban <name>');
6759 pl
:= g_Net_Client_ByName(P
[1]);
6762 s
:= g_Net_ClientName_ByID(pl
^.ID
);
6763 g_Net_BanHost(pl
^.Peer
^.address
.host
);
6764 enet_peer_disconnect(pl
^.Peer
, NET_DISC_BAN
);
6765 g_Net_SaveBanList();
6766 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
6767 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
6768 g_Net_Slist_ServerPlayerLeaves();
6770 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
6772 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6774 else if cmd
= 'permban_id' then
6776 if g_Game_IsServer
and g_Game_IsNet
then
6778 if Length(P
) < 2 then
6780 g_Console_Add('permban_id <client ID>');
6785 g_Console_Add('permban_id <client ID>');
6789 a
:= StrToIntDef(P
[1], 0);
6790 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
6791 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
6793 s
:= g_Net_ClientName_ByID(NetClients
[a
].ID
);
6794 g_Net_BanHost(NetClients
[a
].Peer
^.address
.host
);
6795 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_BAN
);
6796 g_Net_SaveBanList();
6797 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
6798 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
6799 g_Net_Slist_ServerPlayerLeaves();
6802 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6804 else if cmd
= 'permban_pid' then
6806 if g_Game_IsServer
and g_Game_IsNet
then
6808 if Length(P
) < 2 then
6810 g_Console_Add('permban_pid <player ID>');
6815 g_Console_Add('permban_pid <player ID>');
6819 a
:= StrToIntDef(P
[1], 0);
6820 pl
:= g_Net_Client_ByPlayer(a
);
6821 if (pl
<> nil) and pl
^.Used
and (pl
^.Peer
<> nil) then
6823 s
:= g_Net_ClientName_ByID(pl
^.ID
);
6824 g_Net_BanHost(pl
^.Peer
^.address
.host
);
6825 enet_peer_disconnect(pl
^.Peer
, NET_DISC_BAN
);
6826 g_Net_SaveBanList();
6827 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
6828 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
6829 g_Net_Slist_ServerPlayerLeaves();
6832 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6834 else if cmd
= 'permban_ip' then
6836 if g_Game_IsServer
and g_Game_IsNet
then
6838 if Length(P
) < 2 then
6840 g_Console_Add('permban_ip <IP address>');
6845 g_Console_Add('permban_ip <IP address>');
6849 g_Net_BanHost(P
[1]);
6850 g_Net_SaveBanList();
6851 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [P
[1]]));
6853 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6855 else if cmd
= 'unban' then
6857 if g_Game_IsServer
and g_Game_IsNet
then
6859 if Length(P
) < 2 then
6861 g_Console_Add('unban <IP Address>');
6866 g_Console_Add('unban <IP Address>');
6870 if g_Net_UnbanHost(P
[1]) then
6872 g_Console_Add(Format(_lc
[I_MSG_UNBAN_OK
], [P
[1]]));
6873 g_Net_SaveBanList();
6875 g_Console_Add(Format(_lc
[I_MSG_UNBAN_FAIL
], [P
[1]]));
6877 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6879 else if cmd
= 'clientlist' then
6881 if g_Game_IsServer
and g_Game_IsNet
then
6884 if NetClients
<> nil then
6885 for a
:= Low(NetClients
) to High(NetClients
) do
6886 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
6888 plr
:= g_Player_Get(NetClients
[a
].Player
);
6889 if plr
= nil then continue
;
6891 g_Console_Add(Format('#%2d: %-15s | %s', [a
,
6892 IpToStr(NetClients
[a
].Peer
^.address
.host
), plr
.Name
]));
6895 g_Console_Add(_lc
[I_MSG_NOCLIENTS
]);
6897 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6899 else if cmd
= 'connect' then
6901 if (NetMode
= NET_NONE
) then
6903 if Length(P
) < 2 then
6905 g_Console_Add('connect <IP> [port] [password]');
6910 g_Console_Add('connect <IP> [port] [password]');
6914 if Length(P
) > 2 then
6915 prt
:= StrToIntDef(P
[2], 25666)
6919 if Length(P
) > 3 then
6924 g_Game_StartClient(P
[1], prt
, pw
);
6927 else if cmd
= 'disconnect' then
6929 if (NetMode
= NET_CLIENT
) then
6932 else if cmd
= 'reconnect' then
6934 if (NetMode
= NET_SERVER
) then
6937 if (NetMode
= NET_CLIENT
) then
6940 gExit
:= EXIT_SIMPLE
;
6944 //TODO: Use last successful password to reconnect, instead of ''
6945 g_Game_StartClient(NetClientIP
, NetClientPort
, '');
6947 else if (cmd
= 'addbot') or
6948 (cmd
= 'bot_add') then
6950 if Length(P
) > 2 then
6951 g_Bot_Add(TEAM_NONE
, StrToIntDef(P
[1], 2), StrToIntDef(P
[2], 100))
6952 else if Length(P
) > 1 then
6953 g_Bot_Add(TEAM_NONE
, StrToIntDef(P
[1], 2))
6955 g_Bot_Add(TEAM_NONE
, 2);
6957 else if cmd
= 'bot_addlist' then
6959 if Length(P
) > 1 then
6961 if Length(P
) = 2 then
6962 g_Bot_AddList(TEAM_NONE
, P
[1], StrToIntDef(P
[1], -1))
6963 else if Length(P
) = 3 then
6964 g_Bot_AddList(TEAM_NONE
, P
[1], StrToIntDef(P
[1], -1), StrToIntDef(P
[2], 100))
6966 g_Bot_AddList(IfThen(P
[2] = 'red', TEAM_RED
, TEAM_BLUE
), P
[1], StrToIntDef(P
[1], -1));
6969 else if cmd
= 'bot_removeall' then
6971 else if cmd
= 'chat' then
6973 if g_Game_IsNet
then
6975 if Length(P
) > 1 then
6977 for a
:= 1 to High(P
) do
6978 chstr
:= chstr
+ P
[a
] + ' ';
6980 if Length(chstr
) > 200 then SetLength(chstr
, 200);
6982 if Length(chstr
) < 1 then
6984 g_Console_Add('chat <text>');
6988 chstr
:= b_Text_Format(chstr
);
6989 if g_Game_IsClient
then
6990 MC_SEND_Chat(chstr
, NET_CHAT_PLAYER
)
6992 MH_SEND_Chat(gPlayer1Settings
.Name
+ ': ' + chstr
, NET_CHAT_PLAYER
);
6995 g_Console_Add('chat <text>');
6997 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6999 else if cmd
= 'teamchat' then
7001 if g_Game_IsNet
and (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
7003 if Length(P
) > 1 then
7005 for a
:= 1 to High(P
) do
7006 chstr
:= chstr
+ P
[a
] + ' ';
7008 if Length(chstr
) > 200 then SetLength(chstr
, 200);
7010 if Length(chstr
) < 1 then
7012 g_Console_Add('teamchat <text>');
7016 chstr
:= b_Text_Format(chstr
);
7017 if g_Game_IsClient
then
7018 MC_SEND_Chat(chstr
, NET_CHAT_TEAM
)
7020 MH_SEND_Chat(gPlayer1Settings
.Name
+ ': ' + chstr
, NET_CHAT_TEAM
,
7021 gPlayer1Settings
.Team
);
7024 g_Console_Add('teamchat <text>');
7026 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
7028 else if (cmd
= 'an') or (cmd
= 'announce') then
7030 if g_Game_IsNet
then
7032 if Length(P
) > 1 then
7034 for a
:= 1 to High(P
) do
7035 chstr
:= chstr
+ P
[a
] + ' ';
7037 if Length(chstr
) > 200 then SetLength(chstr
, 200);
7039 if Length(chstr
) < 1 then
7041 g_Console_Add('announce <text>');
7045 chstr
:= 'centerprint 100 ' + b_Text_Format(chstr
);
7046 if g_Game_IsClient
then
7047 MC_SEND_RCONCommand(chstr
)
7049 g_Console_Process(chstr
, True);
7052 g_Console_Add('announce <text>');
7054 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
7056 else if cmd
= 'game' then
7058 if gGameSettings
.GameType
<> GT_NONE
then
7060 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
7063 if Length(P
) = 1 then
7065 g_Console_Add(cmd
+ ' <WAD> [MAP] [# players]');
7068 // game not started yet, load fist map from some wad
7070 s
:= addWadExtension(P
[1]);
7071 found
:= e_FindResource(AllMapDirs
, s
);
7075 P
[1] := ExpandFileName(P
[1]);
7076 // if map not choosed then set first map
7077 if Length(P
) < 3 then
7080 P
[2] := g_Game_GetFirstMap(P
[1]);
7083 s
:= P
[1] + ':\' + UpperCase(P
[2]);
7085 if g_Map_Exist(s
) then
7089 with gGameSettings
do
7091 Options
:= gsGameFlags
;
7092 GameMode
:= g_Game_TextToMode(gsGameMode
);
7093 if gSwitchGameMode
<> GM_NONE
then
7094 GameMode
:= gSwitchGameMode
;
7095 if GameMode
= GM_NONE
then GameMode
:= GM_DM
;
7096 if GameMode
= GM_SINGLE
then GameMode
:= GM_COOP
;
7098 if Length(P
) >= 4 then
7099 b
:= StrToIntDef(P
[3], 1);
7100 g_Game_StartCustom(s
, GameMode
, TimeLimit
,
7101 ScoreLimit
, MaxLives
, Options
, b
);
7106 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
7108 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [UpperCase(P
[2]), P
[1]]));
7110 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]));
7112 else if cmd
= 'host' then
7114 if gGameSettings
.GameType
<> GT_NONE
then
7116 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
7119 if Length(P
) < 4 then
7121 g_Console_Add(cmd
+ ' <listen IP> <port> <WAD> [MAP] [# players]');
7124 if not StrToIp(P
[1], listen
) then
7126 prt
:= StrToIntDef(P
[2], 25666);
7128 s
:= addWadExtension(P
[3]);
7129 found
:= e_FindResource(AllMapDirs
, s
);
7133 // get first map in wad, if not specified
7134 if Length(P
) < 5 then
7137 P
[4] := g_Game_GetFirstMap(P
[1]);
7139 s
:= P
[3] + ':\' + UpperCase(P
[4]);
7140 if g_Map_Exist(s
) then
7144 with gGameSettings
do
7146 Options
:= gsGameFlags
;
7147 GameMode
:= g_Game_TextToMode(gsGameMode
);
7148 if gSwitchGameMode
<> GM_NONE
then GameMode
:= gSwitchGameMode
;
7149 if GameMode
= GM_NONE
then GameMode
:= GM_DM
;
7150 if GameMode
= GM_SINGLE
then GameMode
:= GM_COOP
;
7152 if Length(P
) >= 6 then
7153 b
:= StrToIntDef(P
[5], 0);
7154 g_Game_StartServer(s
, GameMode
, TimeLimit
, ScoreLimit
, MaxLives
, Options
, b
, listen
, prt
)
7160 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[3]]))
7162 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [UpperCase(P
[4]), P
[3]]))
7167 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[3]]))
7170 else if cmd
= 'map' then
7172 if Length(P
) = 1 then
7174 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
7176 g_Console_Add(cmd
+ ' <MAP>');
7177 g_Console_Add(cmd
+ ' <WAD> [MAP]')
7181 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
])
7186 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
7188 if Length(P
) < 3 then
7190 // first param is map or wad
7191 s
:= UpperCase(P
[1]);
7192 if g_Map_Exist(gGameSettings
.WAD
+ ':\' + s
) then
7194 gExitByTrigger
:= False;
7197 // already in game, finish current map
7199 gExit
:= EXIT_ENDLEVELCUSTOM
;
7203 // intermission, so change map immediately
7210 found
:= e_FindResource(AllMapDirs
, s
);
7212 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [s
, 'WAD ' + P
[1]]));
7215 // no such map, found wad
7218 P
[1] := ExpandFileName(pw
);
7219 P
[2] := g_Game_GetFirstMap(P
[1]);
7220 s
:= P
[1] + ':\' + P
[2];
7221 if g_Map_Exist(s
) then
7223 gExitByTrigger
:= False;
7226 // already in game, finish current map
7228 gExit
:= EXIT_ENDLEVELCUSTOM
7232 // intermission, so change map immediately
7239 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
7241 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]))
7246 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]))
7252 s
:= addWadExtension(P
[1]);
7253 found
:= e_FindResource(AllMapDirs
, s
);
7257 P
[2] := UpperCase(P
[2]);
7258 s
:= P
[1] + ':\' + P
[2];
7259 if g_Map_Exist(s
) then
7261 gExitByTrigger
:= False;
7265 gExit
:= EXIT_ENDLEVELCUSTOM
7274 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]))
7279 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]))
7285 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
])
7289 else if cmd
= 'nextmap' then
7291 if not(gGameOn
or (gState
= STATE_INTERCUSTOM
)) then
7293 g_Console_Add(_lc
[I_MSG_NOT_GAME
])
7298 if Length(P
) = 1 then
7300 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
7302 g_Console_Add(cmd
+ ' <MAP>');
7303 g_Console_Add(cmd
+ ' <WAD> [MAP]');
7308 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
7314 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
7316 if Length(P
) < 3 then
7318 // first param is map or wad
7319 s
:= UpperCase(P
[1]);
7320 if g_Map_Exist(gGameSettings
.WAD
+ ':\' + s
) then
7323 gExitByTrigger
:= False;
7329 // no such map, found wad
7330 pw
:= addWadExtension(P
[1]);
7331 found
:= e_FindResource(MapDirs
, pw
);
7333 found
:= e_FindResource(WadDirs
, pw
);
7335 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [s
, P
[1]]));
7338 // map not specified, select first map
7340 P
[2] := g_Game_GetFirstMap(P
[1]);
7341 s
:= P
[1] + ':\' + P
[2];
7342 if g_Map_Exist(s
) then
7344 gExitByTrigger
:= False;
7351 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
7353 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]))
7358 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]))
7364 // specified two params wad + map
7365 pw
:= addWadExtension(P
[1]);
7366 found
:= e_FindResource(MapDirs
, pw
);
7368 found
:= e_FindResource(MapDirs
, pw
);
7372 P
[2] := UpperCase(P
[2]);
7373 s
:= P
[1] + ':\' + P
[2];
7374 if g_Map_Exist(s
) then
7376 gExitByTrigger
:= False;
7382 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]))
7387 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]))
7393 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
])
7398 if gNextMap
= '' then
7399 g_Console_Add(_lc
[I_MSG_NEXTMAP_UNSET
])
7401 g_Console_Add(Format(_lc
[I_MSG_NEXTMAP_SET
], [gNextMap
]))
7405 else if (cmd
= 'endmap') or (cmd
= 'goodbye') then
7409 g_Console_Add(_lc
[I_MSG_NOT_GAME
])
7413 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
7415 gExitByTrigger
:= False;
7416 // next map not specified, try to find trigger EXIT
7417 if (gNextMap
= '') and (gTriggers
<> nil) then
7419 for a
:= 0 to High(gTriggers
) do
7421 if gTriggers
[a
].TriggerType
= TRIGGER_EXIT
then
7423 gExitByTrigger
:= True;
7424 //gNextMap := gTriggers[a].Data.MapName;
7425 gNextMap
:= gTriggers
[a
].tgcMap
;
7430 if gNextMap
= '' then
7431 gNextMap
:= g_Game_GetNextMap();
7432 if not isWadPath(gNextMap
) then
7433 s
:= gGameSettings
.WAD
+ ':\' + gNextMap
7436 if g_Map_Exist(s
) then
7437 gExit
:= EXIT_ENDLEVELCUSTOM
7439 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [gNextMap
]))
7443 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
])
7447 else if (cmd
= 'event') then
7449 if (Length(P
) <= 1) then
7451 for a
:= 0 to High(gEvents
) do
7452 if gEvents
[a
].Command
= '' then
7453 g_Console_Add(gEvents
[a
].Name
+ ' <none>')
7455 g_Console_Add(gEvents
[a
].Name
+ ' "' + gEvents
[a
].Command
+ '"');
7458 if (Length(P
) = 2) then
7460 for a
:= 0 to High(gEvents
) do
7461 if gEvents
[a
].Name
= P
[1] then
7462 if gEvents
[a
].Command
= '' then
7463 g_Console_Add(gEvents
[a
].Name
+ ' <none>')
7465 g_Console_Add(gEvents
[a
].Name
+ ' "' + gEvents
[a
].Command
+ '"');
7468 for a
:= 0 to High(gEvents
) do
7469 if gEvents
[a
].Name
= P
[1] then
7471 gEvents
[a
].Command
:= '';
7472 for b
:= 2 to High(P
) do
7473 if Pos(' ', P
[b
]) = 0 then
7474 gEvents
[a
].Command
:= gEvents
[a
].Command
+ ' ' + P
[b
]
7476 gEvents
[a
].Command
:= gEvents
[a
].Command
+ ' "' + P
[b
] + '"';
7477 gEvents
[a
].Command
:= Trim(gEvents
[a
].Command
);
7481 else if cmd
= 'suicide' then
7485 if g_Game_IsClient
then
7486 MC_SEND_CheatRequest(NET_CHEAT_SUICIDE
)
7489 if gPlayer1
<> nil then
7490 gPlayer1
.Damage(SUICIDE_DAMAGE
, gPlayer1
.UID
, 0, 0, HIT_SELF
);
7491 if gPlayer2
<> nil then
7492 gPlayer2
.Damage(SUICIDE_DAMAGE
, gPlayer2
.UID
, 0, 0, HIT_SELF
);
7496 else if cmd
= 'screenshot' then
7500 else if (cmd
= 'weapnext') or (cmd
= 'weapprev') then
7502 a
:= 1 - (ord(cmd
[5]) - ord('n'));
7504 gWeaponAction
[0, WP_PREV
] := True;
7506 gWeaponAction
[0, WP_NEXT
] := True;
7508 else if cmd
= 'weapon' then
7510 if Length(p
) = 2 then
7512 a
:= WP_FIRST
+ StrToIntDef(p
[1], 0) - 1;
7513 if (a
>= WP_FIRST
) and (a
<= WP_LAST
) then
7514 gSelectWeapon
[0, a
] := True
7517 else if (cmd
= 'p1_weapnext') or (cmd
= 'p1_weapprev')
7518 or (cmd
= 'p2_weapnext') or (cmd
= 'p2_weapprev') then
7520 a
:= 1 - (ord(cmd
[8]) - ord('n'));
7521 b
:= ord(cmd
[2]) - ord('1');
7523 gWeaponAction
[b
, WP_PREV
] := True;
7525 gWeaponAction
[b
, WP_NEXT
] := True;
7527 else if (cmd
= 'p1_weapon') or (cmd
= 'p2_weapon') then
7529 if Length(p
) = 2 then
7531 a
:= WP_FIRST
+ StrToIntDef(p
[1], 0) - 1;
7532 b
:= ord(cmd
[2]) - ord('1');
7533 if (a
>= WP_FIRST
) and (a
<= WP_LAST
) then
7534 gSelectWeapon
[b
, a
] := True
7537 else if (cmd
= 'p1_weapbest') or (cmd
= 'p2_weapbest') then
7539 b
:= ord(cmd
[2]) - ord('1');
7541 gSelectWeapon
[b
, gPlayer1
.GetMorePrefered()] := True
7543 gSelectWeapon
[b
, gPlayer2
.GetMorePrefered()] := True;
7545 else if (cmd
= 'dropflag') then
7547 if g_Game_IsServer
then
7549 if gPlayer2
<> nil then gPlayer2
.TryDropFlag();
7550 if gPlayer1
<> nil then gPlayer1
.TryDropFlag();
7553 MC_SEND_CheatRequest(NET_CHEAT_DROPFLAG
);
7555 else if (cmd
= 'p1_dropflag') or (cmd
= 'p2_dropflag') then
7557 b
:= ord(cmd
[2]) - ord('1');
7558 if g_Game_IsServer
then
7560 if (b
= 1) and (gPlayer2
<> nil) then gPlayer2
.TryDropFlag()
7561 else if (b
= 0) and (gPlayer1
<> nil) then gPlayer1
.TryDropFlag();
7564 MC_SEND_CheatRequest(NET_CHEAT_DROPFLAG
);
7566 // Êîìàíäû Ñâîåé èãðû:
7567 else if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
7569 if cmd
= 'bot_addred' then
7571 if Length(P
) > 1 then
7572 g_Bot_Add(TEAM_RED
, StrToIntDef(P
[1], 2))
7574 g_Bot_Add(TEAM_RED
, 2);
7576 else if cmd
= 'bot_addblue' then
7578 if Length(P
) > 1 then
7579 g_Bot_Add(TEAM_BLUE
, StrToIntDef(P
[1], 2))
7581 g_Bot_Add(TEAM_BLUE
, 2);
7583 else if cmd
= 'spectate' then
7589 else if cmd
= 'say' then
7591 if g_Game_IsServer
and g_Game_IsNet
then
7593 if Length(P
) > 1 then
7596 for a
:= 1 to High(P
) do
7597 chstr
:= chstr
+ P
[a
] + ' ';
7599 if Length(chstr
) > 200 then SetLength(chstr
, 200);
7601 if Length(chstr
) < 1 then
7603 g_Console_Add('say <text>');
7607 chstr
:= b_Text_Format(chstr
);
7608 MH_SEND_Chat(chstr
, NET_CHAT_PLAYER
);
7610 else g_Console_Add('say <text>');
7612 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
7614 else if cmd
= 'tell' then
7616 if g_Game_IsServer
and g_Game_IsNet
then
7618 if (Length(P
) > 2) and (P
[1] <> '') then
7621 for a
:= 2 to High(P
) do
7622 chstr
:= chstr
+ P
[a
] + ' ';
7624 if Length(chstr
) > 200 then SetLength(chstr
, 200);
7626 if Length(chstr
) < 1 then
7628 g_Console_Add('tell <playername> <text>');
7632 pl
:= g_Net_Client_ByName(P
[1]);
7634 MH_SEND_Chat(b_Text_Format(chstr
), NET_CHAT_PLAYER
, pl
^.ID
)
7636 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
7638 else g_Console_Add('tell <playername> <text>');
7640 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
7642 else if cmd
= 'centerprint' 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('centerprint <timeout> <text>');
7658 a
:= StrToIntDef(P
[1], 100);
7659 chstr
:= b_Text_Format(chstr
);
7660 g_Game_Message(chstr
, a
);
7661 if g_Game_IsNet
and g_Game_IsServer
then
7662 MH_SEND_GameEvent(NET_EV_BIGTEXT
, a
, chstr
);
7664 else g_Console_Add('centerprint <timeout> <text>');
7666 else if (cmd
= 'overtime') and not g_Game_IsClient
then
7668 if (Length(P
) = 1) or (StrToIntDef(P
[1], -1) <= 0) then
7670 // Äîïîëíèòåëüíîå âðåìÿ:
7671 gGameSettings
.TimeLimit
:= (gTime
- gGameStartTime
) div 1000 + Word(StrToIntDef(P
[1], 0));
7673 g_Console_Add(Format(_lc
[I_MSG_TIME_LIMIT
],
7674 [gGameSettings
.TimeLimit
div 3600,
7675 (gGameSettings
.TimeLimit
div 60) mod 60,
7676 gGameSettings
.TimeLimit
mod 60]));
7677 if g_Game_IsNet
then MH_SEND_GameSettings
;
7679 else if (cmd
= 'rcon_password') and g_Game_IsClient
then
7681 if (Length(P
) <= 1) then
7682 g_Console_Add('rcon_password <password>')
7684 MC_SEND_RCONPassword(P
[1]);
7686 else if cmd
= 'rcon' then
7688 if g_Game_IsClient
then
7690 if Length(P
) > 1 then
7693 for a
:= 1 to High(P
) do
7694 chstr
:= chstr
+ P
[a
] + ' ';
7696 if Length(chstr
) > 200 then SetLength(chstr
, 200);
7698 if Length(chstr
) < 1 then
7700 g_Console_Add('rcon <command>');
7704 MC_SEND_RCONCommand(chstr
);
7706 else g_Console_Add('rcon <command>');
7709 else if cmd
= 'ready' then
7711 if g_Game_IsServer
and (gLMSRespawn
= LMS_RESPAWN_WARMUP
) then
7712 gLMSRespawnTime
:= gTime
+ 100;
7714 else if (cmd
= 'callvote') and g_Game_IsNet
then
7716 if Length(P
) > 1 then
7719 for a
:= 1 to High(P
) do begin
7720 if a
> 1 then chstr
:= chstr
+ ' ';
7721 chstr
:= chstr
+ P
[a
];
7724 if Length(chstr
) > 200 then SetLength(chstr
, 200);
7726 if Length(chstr
) < 1 then
7728 g_Console_Add('callvote <command>');
7732 if g_Game_IsClient
then
7733 MC_SEND_Vote(True, chstr
)
7735 g_Game_StartVote(chstr
, gPlayer1Settings
.Name
);
7736 g_Console_Process('vote', True);
7739 g_Console_Add('callvote <command>');
7741 else if (cmd
= 'vote') and g_Game_IsNet
then
7743 if g_Game_IsClient
then
7745 else if gVoteInProgress
then
7747 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
7748 a
:= Floor((NetClientCount
+1)/2.0) + 1
7750 a
:= Floor(NetClientCount
/2.0) + 1;
7755 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_REVOKED
], [gPlayer1Settings
.Name
, gVoteCount
, a
]), True);
7756 MH_SEND_VoteEvent(NET_VE_REVOKE
, gPlayer1Settings
.Name
, 'a', gVoteCount
, a
);
7762 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_VOTE
], [gPlayer1Settings
.Name
, gVoteCount
, a
]), True);
7763 MH_SEND_VoteEvent(NET_VE_VOTE
, gPlayer1Settings
.Name
, 'a', gVoteCount
, a
);
7771 procedure SystemCommands(P
: SSArray
);
7775 cmd
:= LowerCase(P
[0]);
7784 gRC_Width
:= Max(1, gRC_Width
);
7785 gRC_Height
:= Max(1, gRC_Height
);
7786 gBPP
:= Max(1, gBPP
);
7787 if sys_SetDisplayMode(gRC_Width
, gRC_Height
, gBPP
, gRC_FullScreen
, gRC_Maximized
) = True then
7788 e_LogWriteln('resolution changed')
7790 e_LogWriteln('resolution not changed');
7791 sys_EnableVSync(gVSync
);
7795 if Length(p
) = 2 then
7797 gMaxFPS
:= StrToIntDef(p
[1], gMaxFPS
);
7799 gFrameTime
:= 1000 div gMaxFPS
7803 e_LogWritefln('r_maxfps %d', [gMaxFPS
]);
7807 if Length(p
) = 2 then
7809 gAskLanguage
:= true;
7810 gLanguage
:= LANGUAGE_ENGLISH
;
7811 case LowerCase(p
[1]) of
7814 gAskLanguage
:= false;
7815 gLanguage
:= LANGUAGE_ENGLISH
;
7819 gAskLanguage
:= false;
7820 gLanguage
:= LANGUAGE_RUSSIAN
;
7824 gAskLanguage
:= true;
7825 gLanguage
:= LANGUAGE_ENGLISH
;
7828 g_Language_Set(gLanguage
);
7832 e_LogWritefln('usage: %s <English|Russian|Ask>', [cmd
]);
7838 procedure g_TakeScreenShot(Filename
: string = '');
7839 var s
: TStream
; t
: TDateTime
; dir
, date
, name
: String;
7841 if e_NoGraphics
then Exit
;
7843 dir
:= e_GetWriteableDir(ScreenshotDirs
);
7845 if Filename
= '' then
7848 DateTimeToString(date
, 'yyyy-mm-dd-hh-nn-ss', t
);
7849 Filename
:= 'screenshot-' + date
;
7852 name
:= e_CatPath(dir
, Filename
+ '.png');
7853 s
:= createDiskFile(name
);
7855 e_MakeScreenshot(s
, gWinSizeX
, gWinSizeY
);
7857 g_Console_Add(Format(_lc
[I_CONSOLE_SCREENSHOT
], [name
]))
7859 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_WRITE
], [name
]));
7864 g_Console_Add('oh shit, i can''t create screenshot!')
7868 procedure g_Game_InGameMenu(Show
: Boolean);
7870 if (g_ActiveWindow
= nil) and Show
then
7872 if gGameSettings
.GameType
= GT_SINGLE
then
7873 g_GUI_ShowWindow('GameSingleMenu')
7876 if g_Game_IsClient
then
7877 g_GUI_ShowWindow('GameClientMenu')
7879 if g_Game_IsNet
then
7880 g_GUI_ShowWindow('GameServerMenu')
7882 g_GUI_ShowWindow('GameCustomMenu');
7884 g_Sound_PlayEx('MENU_OPEN');
7886 // Ïàóçà ïðè ìåíþ òîëüêî â îäèíî÷íîé èãðå:
7887 if (not g_Game_IsNet
) then
7891 if (g_ActiveWindow
<> nil) and (not Show
) then
7893 // Ïàóçà ïðè ìåíþ òîëüêî â îäèíî÷íîé èãðå:
7894 if (not g_Game_IsNet
) then
7895 g_Game_Pause(False);
7899 procedure g_Game_Pause (Enable
: Boolean);
7903 if not gGameOn
then exit
;
7905 if not (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
]) then exit
;
7908 gPauseMain
:= Enable
;
7910 if (gPause
<> oldPause
) then g_Game_PauseAllSounds(gPause
);
7913 procedure g_Game_HolmesPause (Enable
: Boolean);
7917 if not gGameOn
then exit
;
7918 if not (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
]) then exit
;
7921 gPauseHolmes
:= Enable
;
7923 if (gPause
<> oldPause
) then g_Game_PauseAllSounds(gPause
);
7926 procedure g_Game_PauseAllSounds(Enable
: Boolean);
7931 if gTriggers
<> nil then
7932 for i
:= 0 to High(gTriggers
) do
7933 with gTriggers
[i
] do
7934 if (TriggerType
= TRIGGER_SOUND
) and
7936 Sound
.IsPlaying() then
7938 Sound
.Pause(Enable
);
7942 if gPlayers
<> nil then
7943 for i
:= 0 to High(gPlayers
) do
7944 if gPlayers
[i
] <> nil then
7945 gPlayers
[i
].PauseSounds(Enable
);
7948 if gMusic
<> nil then
7949 gMusic
.Pause(Enable
);
7952 procedure g_Game_StopAllSounds(all
: Boolean);
7956 if gTriggers
<> nil then
7957 for i
:= 0 to High(gTriggers
) do
7958 with gTriggers
[i
] do
7959 if (TriggerType
= TRIGGER_SOUND
) and
7963 if gMusic
<> nil then
7970 procedure g_Game_UpdateTriggerSounds
;
7973 if gTriggers
<> nil then
7974 for i
:= 0 to High(gTriggers
) do
7975 with gTriggers
[i
] do
7976 if (TriggerType
= TRIGGER_SOUND
) and (Sound
<> nil) and tgcLocal
and Sound
.IsPlaying() then
7977 Sound
.SetCoordsRect(X
, Y
, Width
, Height
, tgcVolume
/ 255.0)
7980 function g_Game_IsWatchedPlayer(UID
: Word): Boolean;
7983 if (gPlayer1
<> nil) and (gPlayer1
.UID
= UID
) then
7988 if (gPlayer2
<> nil) and (gPlayer2
.UID
= UID
) then
7993 if gSpectMode
<> SPECT_PLAYERS
then
7995 if gSpectPID1
= UID
then
8000 if gSpectViewTwo
and (gSpectPID2
= UID
) then
8007 function g_Game_IsWatchedTeam(Team
: Byte): Boolean;
8012 if (gPlayer1
<> nil) and (gPlayer1
.Team
= Team
) then
8017 if (gPlayer2
<> nil) and (gPlayer2
.Team
= Team
) then
8022 if gSpectMode
<> SPECT_PLAYERS
then
8024 Pl
:= g_Player_Get(gSpectPID1
);
8025 if (Pl
<> nil) and (Pl
.Team
= Team
) then
8030 if gSpectViewTwo
then
8032 Pl
:= g_Player_Get(gSpectPID2
);
8033 if (Pl
<> nil) and (Pl
.Team
= Team
) then
8041 procedure g_Game_Message(Msg
: string; Time
: Word);
8043 MessageLineLength
:= (gScreenWidth
- 204) div e_CharFont_GetMaxWidth(gMenuFont
);
8044 MessageText
:= b_Text_Wrap(b_Text_Format(Msg
), MessageLineLength
);
8045 MessageTime
:= Time
;
8048 procedure g_Game_ChatSound(Text: String; Taunt
: Boolean = True);
8050 punct
: Array[0..13] of String =
8051 ('.', ',', ':', ';', '!', '?', '(', ')', '''', '"', '/', '\', '*', '^');
8057 function IsPunctuation(S
: String): Boolean;
8062 if Length(S
) <> 1 then
8064 for i
:= Low(punct
) to High(punct
) do
8065 if S
= punct
[i
] then
8071 function FilterPunctuation(S
: String): String;
8075 for i
:= Low(punct
) to High(punct
) do
8076 S
:= StringReplace(S
, punct
[i
], ' ', [rfReplaceAll
]);
8082 if gUseChatSounds
and Taunt
and (gChatSounds
<> nil) and (Pos(': ', Text) > 0) then
8084 // remove player name
8085 Delete(Text, 1, Pos(': ', Text) + 2 - 1);
8086 // for FullWord check
8087 Text := toLowerCase1251(' ' + Text + ' ');
8088 fpText
:= FilterPunctuation(Text);
8090 for i
:= 0 to Length(gChatSounds
) - 1 do
8093 for j
:= 0 to Length(gChatSounds
[i
].Tags
) - 1 do
8095 if gChatSounds
[i
].FullWord
and (not IsPunctuation(gChatSounds
[i
].Tags
[j
])) then
8096 ok
:= Pos(' ' + gChatSounds
[i
].Tags
[j
] + ' ', fpText
) > 0
8098 ok
:= Pos(gChatSounds
[i
].Tags
[j
], Text) > 0;
8104 gChatSounds
[i
].Sound
.Play();
8110 g_Sound_PlayEx('SOUND_GAME_RADIO');
8113 procedure g_Game_Announce_GoodShot(SpawnerUID
: Word);
8122 if not g_Game_IsWatchedPlayer(SpawnerUID
) then
8126 if goodsnd
[a
].IsPlaying() then
8129 goodsnd
[Random(4)].Play();
8132 procedure g_Game_Announce_KillCombo(Param
: Integer);
8139 UID
:= Param
and $FFFF;
8144 Pl
:= g_Player_Get(UID
);
8153 g_Console_Add(Format(_lc
[I_PLAYER_KILL_2X
], [Name
]), True);
8157 g_Console_Add(Format(_lc
[I_PLAYER_KILL_3X
], [Name
]), True);
8161 g_Console_Add(Format(_lc
[I_PLAYER_KILL_4X
], [Name
]), True);
8165 g_Console_Add(Format(_lc
[I_PLAYER_KILL_MX
], [Name
]), True);
8173 if not g_Game_IsWatchedPlayer(UID
) then
8176 if (not g_Game_IsWatchedPlayer(UID
)) and (c
< 4) then
8180 if killsnd
[n
].IsPlaying() then
8185 procedure g_Game_Announce_BodyKill(SpawnerUID
: Word);
8193 if not g_Game_IsWatchedPlayer(SpawnerUID
) then
8197 if hahasnd
[a
].IsPlaying() then
8200 hahasnd
[Random(3)].Play();
8203 procedure g_Game_StartVote(Command
, Initiator
: string);
8207 if not gVotesEnabled
then Exit
;
8208 if gGameSettings
.GameType
<> GT_SERVER
then Exit
;
8209 if gVoteInProgress
or gVotePassed
then
8211 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_INPROGRESS
], [gVoteCommand
]), True);
8212 MH_SEND_VoteEvent(NET_VE_INPROGRESS
, gVoteCommand
);
8215 gVoteInProgress
:= True;
8216 gVotePassed
:= False;
8217 gVoteTimer
:= gTime
+ gVoteTimeout
* 1000;
8220 gVoteCommand
:= Command
;
8222 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
8223 Need
:= Floor((NetClientCount
+1)/2.0)+1
8225 Need
:= Floor(NetClientCount
/2.0)+1;
8226 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_STARTED
], [Initiator
, Command
, Need
]), True);
8227 MH_SEND_VoteEvent(NET_VE_STARTED
, Initiator
, Command
, Need
);
8230 procedure g_Game_CheckVote
;
8234 if gGameSettings
.GameType
<> GT_SERVER
then Exit
;
8235 if not gVoteInProgress
then Exit
;
8237 if (gTime
>= gVoteTimer
) then
8239 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
8240 Need
:= Floor((NetClientCount
+1)/2.0) + 1
8242 Need
:= Floor(NetClientCount
/2.0) + 1;
8243 if gVoteCount
>= Need
then
8245 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_PASSED
], [gVoteCommand
]), True);
8246 MH_SEND_VoteEvent(NET_VE_PASSED
, gVoteCommand
);
8247 gVotePassed
:= True;
8248 gVoteCmdTimer
:= gTime
+ 5000;
8252 g_Console_Add(_lc
[I_MESSAGE_VOTE_FAILED
], True);
8253 MH_SEND_VoteEvent(NET_VE_FAILED
);
8255 if NetClients
<> nil then
8256 for I
:= Low(NetClients
) to High(NetClients
) do
8257 if NetClients
[i
].Used
then
8258 NetClients
[i
].Voted
:= False;
8259 gVoteInProgress
:= False;
8265 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
8266 Need
:= Floor((NetClientCount
+1)/2.0) + 1
8268 Need
:= Floor(NetClientCount
/2.0) + 1;
8269 if gVoteCount
>= Need
then
8271 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_PASSED
], [gVoteCommand
]), True);
8272 MH_SEND_VoteEvent(NET_VE_PASSED
, gVoteCommand
);
8273 gVoteInProgress
:= False;
8274 gVotePassed
:= True;
8275 gVoteCmdTimer
:= gTime
+ 5000;
8278 if NetClients
<> nil then
8279 for I
:= Low(NetClients
) to High(NetClients
) do
8280 if NetClients
[i
].Used
then
8281 NetClients
[i
].Voted
:= False;
8286 procedure g_Game_LoadMapList(FileName
: string);
8294 if not FileExists(FileName
) then Exit
;
8296 AssignFile(ListFile
, FileName
);
8298 while not EOF(ListFile
) do
8300 ReadLn(ListFile
, s
);
8303 if s
= '' then Continue
;
8305 SetLength(MapList
, Length(MapList
)+1);
8306 MapList
[High(MapList
)] := s
;
8308 CloseFile(ListFile
);
8311 procedure g_Game_SetDebugMode();
8314 // ×èòû (äàæå â ñâîåé èãðå):
8318 procedure g_Game_SetLoadingText(Text: String; Max
: Integer; reWrite
: Boolean);
8322 if Length(LoadingStat
.Msgs
) = 0 then
8328 begin // Ïåðåõîäèì íà ñëåäóþùóþ ñòðîêó èëè ñêðîëëèðóåì:
8329 if NextMsg
= Length(Msgs
) then
8331 for i
:= 0 to High(Msgs
)-1 do
8332 Msgs
[i
] := Msgs
[i
+1];
8340 Msgs
[NextMsg
-1] := Text;
8344 PBarWasHere
:= false;
8347 g_ActiveWindow
:= nil;
8348 ProcessLoading(True);
8351 procedure g_Game_StepLoading(Value
: Integer = -1);
8363 if (ShowCount
> LOADING_SHOW_STEP
) or (Value
> -1) then
8366 ProcessLoading(False);
8371 procedure g_Game_ClearLoading();
8380 len
:= ((gScreenHeight
div 3)*2 - 50) div LOADING_INTERLINE
;
8381 if len
< 1 then len
:= 1;
8382 SetLength(Msgs
, len
);
8383 for len
:= Low(Msgs
) to High(Msgs
) do
8386 PBarWasHere
:= false;
8390 procedure Parse_Params(var pars
: TParamStrValues
);
8397 while i
<= ParamCount
do
8400 if (Length(s
) > 1) and (s
[1] = '-') then
8402 if (Length(s
) > 2) and (s
[2] = '-') then
8403 begin // Îäèíî÷íûé ïàðàìåòð
8404 SetLength(pars
, Length(pars
) + 1);
8405 with pars
[High(pars
)] do
8407 Name
:= LowerCase(s
);
8412 if (i
< ParamCount
) then
8413 begin // Ïàðàìåòð ñî çíà÷åíèåì
8415 SetLength(pars
, Length(pars
) + 1);
8416 with pars
[High(pars
)] do
8418 Name
:= LowerCase(s
);
8419 Value
:= LowerCase(ParamStr(i
));
8428 function Find_Param_Value(var pars
: TParamStrValues
; aName
: String): String;
8433 for i
:= 0 to High(pars
) do
8434 if pars
[i
].Name
= aName
then
8436 Result
:= pars
[i
].Value
;
8441 procedure g_Game_Process_Params();
8443 pars
: TParamStrValues
;
8446 LimT
, LimS
: Integer;
8457 s
:= Find_Param_Value(pars
, '--debug');
8460 g_Game_SetDebugMode();
8461 s
:= Find_Param_Value(pars
, '--netdump');
8466 // Connect when game loads
8467 ip
:= Find_Param_Value(pars
, '-connect');
8471 s
:= Find_Param_Value(pars
, '-port');
8472 if (s
= '') or not TryStrToInt(s
, Port
) then
8475 s
:= Find_Param_Value(pars
, '-pw');
8477 g_Game_StartClient(ip
, Port
, s
);
8481 s
:= LowerCase(Find_Param_Value(pars
, '-dbg-mainwad'));
8484 gDefaultMegawadStart
:= s
;
8487 if (Find_Param_Value(pars
, '--dbg-mainwad-restore') <> '') or
8488 (Find_Param_Value(pars
, '--dbg-mainwad-default') <> '') then
8490 gDefaultMegawadStart
:= DF_Default_Megawad_Start
;
8493 // Start map when game loads:
8494 map
:= LowerCase(Find_Param_Value(pars
, '-map'));
8495 if isWadPath(map
) then
8498 s
:= Find_Param_Value(pars
, '-gm');
8499 GMode
:= g_Game_TextToMode(s
);
8500 if GMode
= GM_NONE
then GMode
:= GM_DM
;
8501 if GMode
= GM_SINGLE
then GMode
:= GM_COOP
;
8504 s
:= Find_Param_Value(pars
, '-limt');
8505 if (s
= '') or (not TryStrToInt(s
, LimT
)) then
8511 s
:= Find_Param_Value(pars
, '-lims');
8512 if (s
= '') or (not TryStrToInt(s
, LimS
)) then
8518 s
:= Find_Param_Value(pars
, '-lives');
8519 if (s
= '') or (not TryStrToInt(s
, Lives
)) then
8525 s
:= Find_Param_Value(pars
, '-opt');
8529 Opt
:= StrToIntDef(s
, 0);
8532 s
:= Find_Param_Value(pars
, '--close');
8536 // Override map to test:
8537 s
:= LowerCase(Find_Param_Value(pars
, '-testmap'));
8540 if e_IsValidResourceName(s
) then
8541 e_FindResource(AllMapDirs
, s
);
8542 gTestMap
:= ExpandFileName(s
);
8545 // Delete test map after play:
8546 s
:= Find_Param_Value(pars
, '--testdelete');
8549 //gMapToDelete := MapsDir + map;
8550 e_WriteLog('"--testdelete" is deprecated, use --tempdelete.', TMsgType
.Fatal
);
8554 // Delete temporary WAD after play:
8555 s
:= Find_Param_Value(pars
, '--tempdelete');
8556 if (s
<> '') and (gTestMap
<> '') then
8558 gMapToDelete
:= gTestMap
;
8559 gTempDelete
:= True;
8562 // Number of players:
8563 s
:= Find_Param_Value(pars
, '-pl');
8565 n
:= DEFAULT_PLAYERS
8567 n
:= StrToIntDef(s
, DEFAULT_PLAYERS
);
8570 s
:= Find_Param_Value(pars
, '-port');
8571 if (s
= '') or not TryStrToInt(s
, Port
) then
8572 g_Game_StartCustom(map
, GMode
, LimT
, LimS
, Lives
, Opt
, n
)
8574 g_Game_StartServer(map
, GMode
, LimT
, LimS
, Lives
, Opt
, n
, 0, Port
);
8577 // Execute script when game loads:
8578 s
:= Find_Param_Value(pars
, '-exec');
8581 // if not isWadPath(s) then
8582 // s := GameDir + '/' + s;
8587 if IOResult
<> 0 then
8589 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], ['Failed to read file: ' + s
]), TMsgType
.Warning
);
8590 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_READ
], [s
]));
8594 e_WriteLog('Executing script: ' + s
, TMsgType
.Notify
);
8595 g_Console_Add(Format(_lc
[I_CONSOLE_EXEC
], [s
]));
8600 if IOResult
<> 0 then
8602 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], ['Failed to read file: ' + s
]), TMsgType
.Warning
);
8603 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_READ
], [s
]));
8607 if Pos('#', s
) <> 1 then // script comment
8608 g_Console_Process(s
, True);
8619 conRegVar('pf_draw_frame', @g_profile_frame_draw
, 'draw frame rendering profiles', 'render profiles');
8620 //conRegVar('pf_update_frame', @g_profile_frame_update, 'draw frame updating profiles', 'update profiles');
8621 conRegVar('pf_coldet', @g_profile_collision
, 'draw collision detection profiles', 'coldet profiles');
8622 conRegVar('pf_los', @g_profile_los
, 'draw monster LOS profiles', 'monster LOS profiles');
8624 conRegVar('r_sq_draw', @gdbg_map_use_accel_render
, 'accelerated spatial queries in rendering', 'accelerated rendering');
8625 conRegVar('cd_sq_enabled', @gdbg_map_use_accel_coldet
, 'accelerated spatial queries in map coldet', 'accelerated map coldet');
8626 conRegVar('mon_sq_enabled', @gmon_debug_use_sqaccel
, 'accelerated spatial queries for monsters', 'accelerated monster coldet');
8627 conRegVar('wtrace_sq_enabled', @gwep_debug_fast_trace
, 'accelerated spatial queries for weapon hitscan trace', 'accelerated weapon hitscan');
8629 conRegVar('pr_enabled', @gpart_dbg_enabled
, 'enable/disable particles', 'particles');
8630 conRegVar('pr_phys_enabled', @gpart_dbg_phys_enabled
, 'enable/disable particle physics', 'particle physics');
8632 conRegVar('los_enabled', @gmon_dbg_los_enabled
, 'enable/disable monster LOS calculations', 'monster LOS', true);
8633 conRegVar('mon_think', @gmon_debug_think
, 'enable/disable monster thinking', 'monster thinking', true);
8635 {$IFDEF ENABLE_HOLMES}
8636 conRegVar('dbg_holmes', @g_holmes_enabled
, 'enable/disable Holmes', 'Holmes', true);
8639 conRegVar('dbg_ignore_level_bounds', @g_dbg_ignore_bounds
, 'ignore level bounds', '', false);
8641 conRegVar('r_scale', @g_dbg_scale
, 0.01, 100.0, 'render scale', '', false);
8642 conRegVar('r_resolution_scale', @r_pixel_scale
, 0.01, 100.0, 'upscale factor', '', false);
8644 conRegVar('light_enabled', @gwin_k8_enable_light_experiments
, 'enable/disable dynamic lighting', 'lighting');
8645 conRegVar('light_player_halo', @g_playerLight
, 'enable/disable player halo', 'player light halo');
8647 conRegVar('r_smallmap_align_h', @r_smallmap_h
, 'halign: 0: left; 1: center; 2: right', 'horizontal aligning of small maps');
8648 conRegVar('r_smallmap_align_v', @r_smallmap_v
, 'valign: 0: top; 1: center; 2: bottom', 'vertial aligning of small maps');
8650 conRegVar('r_showfps', @gShowFPS
, 'draw fps counter', 'draw fps counter');
8651 conRegVar('r_showtime', @gShowTime
, 'show game time', 'show game time');
8652 conRegVar('r_showping', @gShowPing
, 'show ping', 'show ping');
8653 conRegVar('r_showscore', @gShowScore
, 'show score', 'show score');
8654 conRegVar('r_showkillmsg', @gShowKillMsg
, 'show kill log', 'show kill log');
8655 conRegVar('r_showlives', @gShowLives
, 'show lives', 'show lives');
8656 conRegVar('r_showspect', @gSpectHUD
, 'show spectator hud', 'show spectator hud');
8657 conRegVar('r_showstat', @gShowStat
, 'show stats', 'show stats');
8658 conRegVar('r_showpids', @gShowPIDs
, 'show PIDs', 'show PIDs');