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
79 function g_Game_IsNet(): Boolean;
80 function g_Game_IsServer(): Boolean;
81 function g_Game_IsClient(): Boolean;
82 procedure g_Game_Init();
83 procedure g_Game_Free (freeTextures
: Boolean=true);
84 procedure g_Game_LoadData();
85 procedure g_Game_FreeData();
86 procedure g_Game_Update();
87 procedure g_Game_PreUpdate();
88 procedure g_Game_Draw();
89 procedure g_Game_Quit();
90 procedure g_Game_SetupScreenSize();
91 procedure g_Game_ChangeResolution(newWidth
, newHeight
: Word; nowFull
, nowMax
: Boolean);
92 function g_Game_ModeToText(Mode
: Byte): string;
93 function g_Game_TextToMode(Mode
: string): Byte;
94 procedure g_Game_ExecuteEvent(Name
: String);
95 function g_Game_DelayEvent(DEType
: Byte; Time
: LongWord; Num
: Integer = 0; Str
: String = ''): Integer;
96 procedure g_Game_AddPlayer(Team
: Byte = TEAM_NONE
);
97 procedure g_Game_RemovePlayer();
98 procedure g_Game_Spectate();
99 procedure g_Game_SpectateCenterView();
100 procedure g_Game_StartSingle(Map
: String; TwoPlayers
: Boolean; nPlayers
: Byte);
101 procedure g_Game_StartCustom(Map
: String; GameMode
: Byte; TimeLimit
, GoalLimit
: Word; MaxLives
: Byte; Options
: LongWord; nPlayers
: Byte);
102 procedure g_Game_StartServer(Map
: String; GameMode
: Byte; TimeLimit
, GoalLimit
: Word; MaxLives
: Byte; Options
: LongWord; nPlayers
: Byte; IPAddr
: LongWord; Port
: Word);
103 procedure g_Game_StartClient(Addr
: String; Port
: Word; PW
: String);
104 procedure g_Game_Restart();
105 procedure g_Game_RestartLevel();
106 procedure g_Game_RestartRound(NoMapRestart
: Boolean = False);
107 function g_Game_ClientWAD (NewWAD
: String; const WHash
: TMD5Digest
): AnsiString;
108 function g_Game_StartMap(asMegawad
: Boolean; Map
: String; Force
: Boolean = False; const oldMapPath
: AnsiString=''): Boolean;
109 procedure g_Game_ChangeMap(const MapPath
: String);
110 procedure g_Game_ExitLevel(const Map
: AnsiString);
111 function g_Game_GetFirstMap(WAD
: String): String;
112 function g_Game_GetNextMap(): String;
113 procedure g_Game_NextLevel();
114 procedure g_Game_Pause(Enable
: Boolean);
115 procedure g_Game_HolmesPause(Enable
: Boolean);
116 procedure g_Game_InGameMenu(Show
: Boolean);
117 function g_Game_IsWatchedPlayer(UID
: Word): Boolean;
118 function g_Game_IsWatchedTeam(Team
: Byte): Boolean;
119 procedure g_Game_Message(Msg
: String; Time
: Word);
120 procedure g_Game_LoadMapList(FileName
: String);
121 procedure g_Game_PauseAllSounds(Enable
: Boolean);
122 procedure g_Game_StopAllSounds(all
: Boolean);
123 procedure g_Game_UpdateTriggerSounds();
124 function g_Game_GetMegaWADInfo(WAD
: String): TMegaWADInfo
;
125 procedure g_Game_ChatSound(Text: String; Taunt
: Boolean = True);
126 procedure g_Game_Announce_GoodShot(SpawnerUID
: Word);
127 procedure g_Game_Announce_KillCombo(Param
: Integer);
128 procedure g_Game_Announce_BodyKill(SpawnerUID
: Word);
129 procedure g_Game_StartVote(Command
, Initiator
: string);
130 procedure g_Game_CheckVote
;
131 procedure g_TakeScreenShot(Filename
: string = '');
132 procedure g_FatalError(Text: String);
133 procedure g_SimpleError(Text: String);
134 function g_Game_IsTestMap(): Boolean;
135 procedure g_Game_DeleteTestMap();
136 procedure GameCVars(P
: SSArray
);
137 procedure PlayerSettingsCVars(P
: SSArray
);
138 procedure SystemCommands(P
: SSArray
);
139 procedure GameCommands(P
: SSArray
);
140 procedure GameCheats(P
: SSArray
);
141 procedure DebugCommands(P
: SSArray
);
142 procedure g_Game_Process_Params
;
143 procedure g_Game_SetLoadingText(Text: String; Max
: Integer; reWrite
: Boolean);
144 procedure g_Game_StepLoading(Value
: Integer = -1);
145 procedure g_Game_ClearLoading();
146 procedure g_Game_SetDebugMode();
147 procedure DrawLoadingStat();
148 procedure DrawMenuBackground(tex
: AnsiString);
150 { procedure SetWinPause(Enable: Boolean); }
155 LOADING_SHOW_STEP
= 100;
156 LOADING_INTERLINE
= 20;
171 MESSAGE_DIKEY
= WM_USER
+ 1;
176 EXIT_ENDLEVELSINGLE
= 4;
177 EXIT_ENDLEVELCUSTOM
= 5;
179 GAME_OPTION_RESERVED
= 1;
180 GAME_OPTION_TEAMDAMAGE
= 2;
181 GAME_OPTION_ALLOWEXIT
= 4;
182 GAME_OPTION_WEAPONSTAY
= 8;
183 GAME_OPTION_MONSTERS
= 16;
184 GAME_OPTION_BOTVSPLAYER
= 32;
185 GAME_OPTION_BOTVSMONSTER
= 64;
186 GAME_OPTION_DMKEYS
= 128;
191 STATE_INTERCUSTOM
= 3;
192 STATE_INTERSINGLE
= 4;
198 LMS_RESPAWN_NONE
= 0;
199 LMS_RESPAWN_WARMUP
= 1;
200 LMS_RESPAWN_FINAL
= 2;
217 CONFIG_FILENAME
= 'Doom2DF.cfg';
219 TEST_MAP_NAME
= '$$$_TEST_$$$';
221 STD_PLAYER_MODEL
= 'Doomer';
229 STATFILE_VERSION
= $03;
233 gGameSettings
: TGameSettings
;
234 gPlayer1Settings
: TPlayerSettings
;
235 gPlayer2Settings
: TPlayerSettings
;
237 gPlayerScreenSize
: TDFPoint
;
238 gPlayer1ScreenCoord
: TDFPoint
;
239 gPlayer2ScreenCoord
: TDFPoint
;
240 gPlayer1
: TPlayer
= nil;
241 gPlayer2
: TPlayer
= nil;
242 gPlayerDrawn
: TPlayer
= nil;
244 gLerpFactor
: Single = 1.0;
245 gSwitchGameMode
: Byte = GM_DM
;
246 gHearPoint1
, gHearPoint2
: THearPoint
;
247 gSoundEffectsDF
: Boolean = False;
248 gSoundTriggerTime
: Word = 0;
249 gAnnouncer
: Integer = ANNOUNCE_NONE
;
250 goodsnd
: array[0..3] of TPlayableSound
;
251 killsnd
: array[0..3] of TPlayableSound
;
252 hahasnd
: array[0..2] of TPlayableSound
;
253 sound_get_flag
: array[0..1] of TPlayableSound
;
254 sound_lost_flag
: array[0..1] of TPlayableSound
;
255 sound_ret_flag
: array[0..1] of TPlayableSound
;
256 sound_cap_flag
: array[0..1] of TPlayableSound
;
257 gBodyKillEvent
: Integer = -1;
258 gDefInterTime
: ShortInt = -1;
259 gInterEndTime
: LongWord = 0;
260 gInterTime
: LongWord = 0;
261 gServInterTime
: Byte = 0;
262 gGameStartTime
: LongWord = 0;
263 gTotalMonsters
: Integer = 0;
264 gPauseMain
: Boolean = false;
265 gPauseHolmes
: Boolean = false;
266 gShowTime
: Boolean = False;
267 gShowFPS
: Boolean = False;
268 gShowGoals
: Boolean = True;
269 gShowStat
: Boolean = True;
270 gShowKillMsg
: Boolean = True;
271 gShowLives
: Boolean = True;
272 gShowPing
: Boolean = False;
273 gShowMap
: Boolean = False;
275 gState
: Byte = STATE_NONE
;
277 sWidth
, sHeight
: Word;
278 gSpectMode
: Byte = SPECT_NONE
;
279 gSpectHUD
: Boolean = True;
280 gSpectKeyPress
: Boolean = False;
281 gSpectX
: Integer = 0;
282 gSpectY
: Integer = 0;
283 gSpectStep
: Byte = 8;
284 gSpectViewTwo
: Boolean = False;
285 gSpectPID1
: Integer = -1;
286 gSpectPID2
: Integer = -1;
287 gSpectAuto
: Boolean = False;
288 gSpectAutoNext
: LongWord;
289 gSpectAutoStepX
: Integer;
290 gSpectAutoStepY
: Integer;
291 gMusic
: TMusic
= nil;
292 gLoadGameMode
: Boolean;
293 gCheats
: Boolean = False;
294 gMapOnce
: Boolean = False;
295 gMapToDelete
: String;
296 gTempDelete
: Boolean = False;
297 gLastMap
: Boolean = False;
300 gResolutionChange
: Boolean = False;
301 gRC_Width
, gRC_Height
: Integer;
302 gRC_FullScreen
, gRC_Maximized
: Boolean;
303 gLanguageChange
: Boolean = False;
304 gDebugMode
: Boolean = False;
305 g_debug_Sounds
: Boolean = False;
306 g_debug_Frames
: Boolean = False;
307 g_debug_WinMsgs
: Boolean = False;
308 g_debug_MonsterOff
: Boolean = False;
309 g_debug_BotAIOff
: Byte = 0;
310 g_debug_HealthBar
: Boolean = False;
311 g_Debug_Player
: Boolean = False;
312 gCoopMonstersKilled
: Word = 0;
313 gCoopSecretsFound
: Word = 0;
314 gCoopTotalMonstersKilled
: Word = 0;
315 gCoopTotalSecretsFound
: Word = 0;
316 gCoopTotalMonsters
: Word = 0;
317 gCoopTotalSecrets
: Word = 0;
318 gStatsOff
: Boolean = False;
319 gStatsPressed
: Boolean = False;
320 gExitByTrigger
: Boolean = False;
321 gNextMap
: String = '';
322 gLMSRespawn
: Byte = LMS_RESPAWN_NONE
;
323 gLMSRespawnTime
: Cardinal = 0;
324 gLMSSoftSpawn
: Boolean = False;
325 gMissionFailed
: Boolean = False;
326 gVoteInProgress
: Boolean = False;
327 gVotePassed
: Boolean = False;
328 gVoteCommand
: string = '';
329 gVoteTimer
: Cardinal = 0;
330 gVoteCmdTimer
: Cardinal = 0;
331 gVoteCount
: Integer = 0;
332 gVoteTimeout
: Cardinal = 30;
333 gVoted
: Boolean = False;
334 gVotesEnabled
: Boolean = True;
335 gEvents
: Array of TGameEvent
;
336 gDelayedEvents
: Array of TDelayedEvent
;
337 gUseChatSounds
: Boolean = True;
338 gChatSounds
: Array of TChatSound
;
339 gSelectWeapon
: Array [0..1, WP_FIRST
..WP_LAST
] of Boolean; // [player, weapon]
340 gInterReadyCount
: Integer = 0;
342 g_dbg_ignore_bounds
: Boolean = false;
343 r_smallmap_h
: Integer = 0; // 0: left; 1: center; 2: right
344 r_smallmap_v
: Integer = 2; // 0: top; 1: center; 2: bottom
346 // move button values:
347 // bits 0-1: l/r state:
348 // 0: neither left, nor right pressed
351 // bits 4-5: l/r state when strafe was pressed
352 P1MoveButton
: Byte = 0;
353 P2MoveButton
: Byte = 0;
355 g_profile_frame_update
: Boolean = false;
356 g_profile_frame_draw
: Boolean = false;
357 g_profile_collision
: Boolean = false;
358 g_profile_los
: Boolean = false;
359 g_profile_history_size
: Integer = 1000;
361 g_rlayer_back
: Boolean = true;
362 g_rlayer_step
: Boolean = true;
363 g_rlayer_wall
: Boolean = true;
364 g_rlayer_door
: Boolean = true;
365 g_rlayer_acid1
: Boolean = true;
366 g_rlayer_acid2
: Boolean = true;
367 g_rlayer_water
: Boolean = true;
368 g_rlayer_fore
: Boolean = true;
371 procedure g_ResetDynlights ();
372 procedure g_AddDynLight (x
, y
, radius
: Integer; r
, g
, b
, a
: Single);
373 procedure g_DynLightExplosion (x
, y
, radius
: Integer; r
, g
, b
: Single);
375 function conIsCheatsEnabled (): Boolean; inline;
376 function gPause (): Boolean; inline;
382 {$INCLUDE ../nogl/noGLuses.inc}
383 {$IFDEF ENABLE_HOLMES}
386 e_texture
, e_res
, g_textures
, g_window
, g_menu
,
387 e_input
, e_log
, g_console
, g_items
, g_map
, g_panel
,
388 g_playermodel
, g_gfx
, g_options
, Math
,
389 g_triggers
, g_monsters
, e_sound
, CONFIG
,
390 g_language
, g_net
, g_main
, g_phys
,
391 ENet
, e_msg
, g_netmsg
, g_netmaster
,
392 sfs
, wadreader
, g_system
;
396 hasPBarGfx
: Boolean = false;
399 // ////////////////////////////////////////////////////////////////////////// //
400 function gPause (): Boolean; inline; begin result
:= gPauseMain
or gPauseHolmes
; end;
403 // ////////////////////////////////////////////////////////////////////////// //
404 function conIsCheatsEnabled (): Boolean; inline;
407 if g_Game_IsNet
then exit
;
408 if not gDebugMode
then
410 //if not gCheats then exit;
411 if not (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
]) then exit
;
412 if not (gGameSettings
.GameMode
in [GM_COOP
, GM_SINGLE
]) then exit
;
418 // ////////////////////////////////////////////////////////////////////////// //
420 profileFrameDraw
: TProfiler
= nil;
423 // ////////////////////////////////////////////////////////////////////////// //
426 x
, y
, radius
: Integer;
429 exploRadius
: Integer;
433 g_dynLights
: array of TDynLight
= nil;
434 g_dynLightCount
: Integer = 0;
435 g_playerLight
: Boolean = false;
437 procedure g_ResetDynlights ();
441 if not gwin_has_stencil
then begin g_dynLightCount
:= 0; exit
; end;
443 for idx
:= 0 to g_dynLightCount
-1 do
445 if g_dynLights
[idx
].exploCount
= -666 then
452 Inc(g_dynLights
[idx
].exploCount
);
453 if (g_dynLights
[idx
].exploCount
< 10) then
455 g_dynLights
[idx
].radius
:= g_dynLights
[idx
].exploRadius
+g_dynLights
[idx
].exploCount
*8;
456 g_dynLights
[idx
].a
:= 0.4+g_dynLights
[idx
].exploCount
/10;
457 if (g_dynLights
[idx
].a
> 0.8) then g_dynLights
[idx
].a
:= 0.8;
458 if lnum
<> idx
then g_dynLights
[lnum
] := g_dynLights
[idx
];
463 g_dynLightCount
:= lnum
;
466 procedure g_AddDynLight (x
, y
, radius
: Integer; r
, g
, b
, a
: Single);
468 if not gwin_has_stencil
then exit
;
469 if g_dynLightCount
= length(g_dynLights
) then SetLength(g_dynLights
, g_dynLightCount
+1024);
470 g_dynLights
[g_dynLightCount
].x
:= x
;
471 g_dynLights
[g_dynLightCount
].y
:= y
;
472 g_dynLights
[g_dynLightCount
].radius
:= radius
;
473 g_dynLights
[g_dynLightCount
].r
:= r
;
474 g_dynLights
[g_dynLightCount
].g
:= g
;
475 g_dynLights
[g_dynLightCount
].b
:= b
;
476 g_dynLights
[g_dynLightCount
].a
:= a
;
477 g_dynLights
[g_dynLightCount
].exploCount
:= -666;
478 Inc(g_dynLightCount
);
481 procedure g_DynLightExplosion (x
, y
, radius
: Integer; r
, g
, b
: Single);
483 if not gwin_has_stencil
then exit
;
484 if g_dynLightCount
= length(g_dynLights
) then SetLength(g_dynLights
, g_dynLightCount
+1024);
485 g_dynLights
[g_dynLightCount
].x
:= x
;
486 g_dynLights
[g_dynLightCount
].y
:= y
;
487 g_dynLights
[g_dynLightCount
].radius
:= 0;
488 g_dynLights
[g_dynLightCount
].exploRadius
:= radius
;
489 g_dynLights
[g_dynLightCount
].r
:= r
;
490 g_dynLights
[g_dynLightCount
].g
:= g
;
491 g_dynLights
[g_dynLightCount
].b
:= b
;
492 g_dynLights
[g_dynLightCount
].a
:= 0;
493 g_dynLights
[g_dynLightCount
].exploCount
:= 0;
494 Inc(g_dynLightCount
);
498 // ////////////////////////////////////////////////////////////////////////// //
499 function calcProfilesHeight (prof
: TProfiler
): Integer;
502 if (prof
= nil) then exit
;
503 if (length(prof
.bars
) = 0) then exit
;
504 result
:= length(prof
.bars
)*(16+2);
508 function drawProfiles (x
, y
: Integer; prof
: TProfiler
): Integer;
515 if (prof
= nil) then exit
;
517 if (length(prof
.bars
) = 0) then exit
;
519 hgt
:= calcProfilesHeight(prof
);
520 if (x
< 0) then x
:= gScreenWidth
-(wdt
-1)+x
;
521 if (y
< 0) then y
:= gScreenHeight
-(hgt
-1)+y
;
523 //e_DrawFillQuad(x, y, x+wdt-1, y+hgt-1, 255, 255, 255, 200, B_BLEND);
524 //e_DrawFillQuad(x, y, x+wdt-1, y+hgt-1, 20, 20, 20, 0, B_NONE);
525 e_DarkenQuadWH(x
, y
, wdt
, hgt
, 150);
528 for ii
:= 0 to High(prof
.bars
) do
530 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);
537 // ////////////////////////////////////////////////////////////////////////// //
539 TEndCustomGameStat
= record
540 PlayerStat
: TPlayerStatArray
;
544 Map
, MapName
: String;
547 TEndSingleGameStat
= record
548 PlayerStat
: Array [0..1] of record
554 TotalSecrets
: Integer;
557 TLoadingStat
= record
561 Msgs
: Array of String;
563 PBarWasHere
: Boolean; // did we draw a progress bar for this message?
566 TParamStrValue
= record
571 TParamStrValues
= Array of TParamStrValue
;
574 INTER_ACTION_TEXT
= 1;
575 INTER_ACTION_PIC
= 2;
576 INTER_ACTION_MUSIC
= 3;
580 FPSCounter
, UPSCounter
: Word;
581 FPSTime
, UPSTime
: LongWord;
582 DataLoaded
: Boolean = False;
583 IsDrawStat
: Boolean = False;
584 CustomStat
: TEndCustomGameStat
;
585 SingleStat
: TEndSingleGameStat
;
586 LoadingStat
: TLoadingStat
;
587 EndingGameCounter
: Byte = 0;
590 MessageLineLength
: Integer = 80;
591 MapList
: SSArray
= nil;
592 MapIndex
: Integer = -1;
593 InterReadyTime
: Integer = -1;
594 StatShotDone
: Boolean = False;
595 StatFilename
: string = ''; // used by stat screenshot to save with the same name as the csv
596 StatDate
: string = '';
602 text: Array of ShortString;
603 anim
: Array of ShortString;
604 pic
: Array of ShortString;
605 mus
: Array of ShortString;
607 triggers
: Array of record
609 actions
: Array of record
610 action
, p1
, p2
: Integer;
613 cur_trigger
: Integer;
626 function Compare(a
, b
: TPlayerStat
): Integer;
628 if a
.Spectator
then Result
:= 1
629 else if b
.Spectator
then Result
:= -1
630 else if a
.Frags
< b
.Frags
then Result
:= 1
631 else if a
.Frags
> b
.Frags
then Result
:= -1
632 else if a
.Deaths
< b
.Deaths
then Result
:= -1
633 else if a
.Deaths
> b
.Deaths
then Result
:= 1
634 else if a
.Kills
< b
.Kills
then Result
:= -1
638 procedure SortGameStat(var stat
: TPlayerStatArray
);
643 if stat
= nil then Exit
;
645 for I
:= High(stat
) downto Low(stat
) do
646 for J
:= Low(stat
) to High(stat
) - 1 do
647 if Compare(stat
[J
], stat
[J
+ 1]) = 1 then
650 stat
[J
] := stat
[J
+ 1];
655 // saves a shitty CSV containing the game stats passed to it
656 procedure SaveGameStat(Stat
: TEndCustomGameStat
; Path
: string);
659 dir
, fname
, map
, mode
, etime
: String;
663 dir
:= e_GetWriteableDir(StatsDirs
);
664 // stats are placed in stats/yy/mm/dd/*.csv
665 fname
:= e_CatPath(dir
, Path
);
666 ForceDirectories(fname
); // ensure yy/mm/dd exists within the stats dir
667 fname
:= e_CatPath(fname
, StatFilename
+ '.csv');
668 AssignFile(s
, fname
);
671 // line 1: stats ver, datetime, server name, map name, game mode, time limit, score limit, dmflags, game time, num players
672 if g_Game_IsNet
then fname
:= NetServerName
else fname
:= '';
673 map
:= g_ExtractWadNameNoPath(gMapInfo
.Map
) + ':/' + g_ExtractFileName(gMapInfo
.Map
);
674 mode
:= g_Game_ModeToText(Stat
.GameMode
);
675 etime
:= Format('%d:%.2d:%.2d', [
676 Stat
.GameTime
div 1000 div 3600,
677 (Stat
.GameTime
div 1000 div 60) mod 60,
678 Stat
.GameTime
div 1000 mod 60
680 WriteLn(s
, 'stats_ver,datetime,server,map,mode,timelimit,scorelimit,dmflags,time,num_players');
681 WriteLn(s
, Format('%d,%s,%s,%s,%s,%u,%u,%u,%s,%d', [
687 gGameSettings
.TimeLimit
,
688 gGameSettings
.GoalLimit
,
689 gGameSettings
.Options
,
691 Length(Stat
.PlayerStat
)
693 // line 2: game specific shit
694 // if it's a team game: red score, blue score
695 // if it's a coop game: monsters killed, monsters total, secrets found, secrets total
697 if Stat
.GameMode
in [GM_TDM
, GM_CTF
] then
699 Format('red_score,blue_score' + LineEnding
+ '%d,%d', [Stat
.TeamStat
[TEAM_RED
].Goals
, Stat
.TeamStat
[TEAM_BLUE
].Goals
]))
700 else if Stat
.GameMode
in [GM_COOP
, GM_SINGLE
] then
702 Format('mon_killed,mon_total,secrets_found,secrets_total' + LineEnding
+ '%d,%d,%d,%d',[gCoopMonstersKilled
, gTotalMonsters
, gCoopSecretsFound
, gSecretsCount
]));
703 // lines 3-...: team, player name, frags, deaths
704 WriteLn(s
, 'team,name,frags,deaths');
705 for I
:= Low(Stat
.PlayerStat
) to High(Stat
.PlayerStat
) do
706 with Stat
.PlayerStat
[I
] do
707 WriteLn(s
, Format('%d,%s,%d,%d', [Team
, dquoteStr(Name
), Frags
, Deaths
]));
709 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_WRITE
], [fname
]));
712 g_Console_Add('could not create gamestats file "' + fname
+ '"');
717 function g_Game_ModeToText(Mode
: Byte): string;
721 GM_DM
: Result
:= _lc
[I_MENU_GAME_TYPE_DM
];
722 GM_TDM
: Result
:= _lc
[I_MENU_GAME_TYPE_TDM
];
723 GM_CTF
: Result
:= _lc
[I_MENU_GAME_TYPE_CTF
];
724 GM_COOP
: Result
:= _lc
[I_MENU_GAME_TYPE_COOP
];
725 GM_SINGLE
: Result
:= _lc
[I_MENU_GAME_TYPE_SINGLE
];
729 function g_Game_TextToMode(Mode
: string): Byte;
732 Mode
:= UpperCase(Mode
);
733 if Mode
= _lc
[I_MENU_GAME_TYPE_DM
] then
738 if Mode
= _lc
[I_MENU_GAME_TYPE_TDM
] then
743 if Mode
= _lc
[I_MENU_GAME_TYPE_CTF
] then
748 if Mode
= _lc
[I_MENU_GAME_TYPE_COOP
] then
753 if Mode
= _lc
[I_MENU_GAME_TYPE_SINGLE
] then
760 function g_Game_IsNet(): Boolean;
762 Result
:= (gGameSettings
.GameType
in [GT_SERVER
, GT_CLIENT
]);
765 function g_Game_IsServer(): Boolean;
767 Result
:= (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
, GT_SERVER
]);
770 function g_Game_IsClient(): Boolean;
772 Result
:= (gGameSettings
.GameType
= GT_CLIENT
);
775 function g_Game_GetMegaWADInfo(WAD
: String): TMegaWADInfo
;
782 Result
.name
:= ExtractFileName(WAD
);
783 Result
.description
:= '';
786 w
:= TWADFile
.Create();
789 if not w
.GetResource('INTERSCRIPT', p
, len
) then
795 cfg
:= TConfig
.CreateMem(p
, len
);
796 Result
.name
:= cfg
.ReadStr('megawad', 'name', ExtractFileName(WAD
));
797 Result
.description
:= cfg
.ReadStr('megawad', 'description', '');
798 Result
.author
:= cfg
.ReadStr('megawad', 'author', '');
799 Result
.pic
:= cfg
.ReadStr('megawad', 'pic', '');
805 procedure g_Game_FreeWAD();
809 for a
:= 0 to High(MegaWAD
.res
.pic
) do
810 if MegaWAD
.res
.pic
[a
] <> '' then
811 g_Texture_Delete(MegaWAD
.res
.pic
[a
]);
813 for a
:= 0 to High(MegaWAD
.res
.mus
) do
814 if MegaWAD
.res
.mus
[a
] <> '' then
815 g_Sound_Delete(MegaWAD
.res
.mus
[a
]);
817 MegaWAD
.res
.pic
:= nil;
818 MegaWAD
.res
.text := nil;
819 MegaWAD
.res
.anim
:= nil;
820 MegaWAD
.res
.mus
:= nil;
821 MegaWAD
.triggers
:= nil;
823 g_Texture_Delete('TEXTURE_endpic');
824 g_Sound_Delete('MUSIC_endmus');
826 ZeroMemory(@MegaWAD
, SizeOf(MegaWAD
));
827 gGameSettings
.WAD
:= '';
830 procedure g_Game_LoadWAD(WAD
: string);
839 gGameSettings
.WAD
:= WAD
;
840 if not (gGameSettings
.GameMode
in [GM_COOP
, GM_SINGLE
]) then
843 MegaWAD
.info
:= g_Game_GetMegaWADInfo(WAD
);
845 w
:= TWADFile
.Create();
848 if not w
.GetResource('INTERSCRIPT', p
, len
) then
854 cfg
:= TConfig
.CreateMem(p
, len
);
859 s := cfg.ReadStr('pic', 'pic'+IntToStr(b), '');
860 if s = '' then Break;
863 SetLength(MegaWAD.res.pic, Length(MegaWAD.res.pic)+1);
864 MegaWAD.res.pic[High(MegaWAD.res.pic)] := s;
866 g_Texture_CreateWADEx(s, s);
872 s := cfg.ReadStr('mus', 'mus'+IntToStr(b), '');
873 if s = '' then Break;
876 SetLength(MegaWAD.res.mus, Length(MegaWAD.res.mus)+1);
877 MegaWAD.res.mus[High(MegaWAD.res.mus)] := s;
879 g_Music_CreateWADEx(s, s);
882 MegaWAD
.endpic
:= cfg
.ReadStr('megawad', 'endpic', '');
883 if MegaWAD
.endpic
<> '' then
885 TEXTUREFILTER
:= GL_LINEAR
;
886 s
:= e_GetResourcePath(WadDirs
, MegaWAD
.endpic
, WAD
);
887 g_Texture_CreateWADEx('TEXTURE_endpic', s
);
888 TEXTUREFILTER
:= GL_NEAREST
;
890 MegaWAD
.endmus
:= cfg
.ReadStr('megawad', 'endmus', 'Standart.wad:D2DMUS\ÊÎÍÅÖ');
891 if MegaWAD
.endmus
<> '' then
893 s
:= e_GetResourcePath(WadDirs
, MegaWAD
.endmus
, WAD
);
894 g_Sound_CreateWADEx('MUSIC_endmus', s
, True);
902 {procedure start_trigger(t: string);
906 function next_trigger(): Boolean;
910 procedure DisableCheats();
916 if gPlayer1
<> nil then gPlayer1
.GodMode
:= False;
917 if gPlayer2
<> nil then gPlayer2
.GodMode
:= False;
918 if gPlayer1
<> nil then gPlayer1
.NoTarget
:= False;
919 if gPlayer2
<> nil then gPlayer2
.NoTarget
:= False;
921 {$IF DEFINED(D2F_DEBUG)}
922 if gPlayer1
<> nil then gPlayer1
.NoTarget
:= True;
923 gAimLine
:= g_dbg_aimline_on
;
927 procedure g_Game_ExecuteEvent(Name
: String);
933 if gEvents
= nil then
935 for a
:= 0 to High(gEvents
) do
936 if gEvents
[a
].Name
= Name
then
938 if gEvents
[a
].Command
<> '' then
939 g_Console_Process(gEvents
[a
].Command
, True);
944 function g_Game_DelayEvent(DEType
: Byte; Time
: LongWord; Num
: Integer = 0; Str
: String = ''): Integer;
949 if gDelayedEvents
<> nil then
950 for a
:= 0 to High(gDelayedEvents
) do
951 if not gDelayedEvents
[a
].Pending
then
958 SetLength(gDelayedEvents
, Length(gDelayedEvents
) + 1);
959 n
:= High(gDelayedEvents
);
961 gDelayedEvents
[n
].Pending
:= True;
962 gDelayedEvents
[n
].DEType
:= DEType
;
963 gDelayedEvents
[n
].DENum
:= Num
;
964 gDelayedEvents
[n
].DEStr
:= Str
;
965 if DEType
= DE_GLOBEVENT
then
966 gDelayedEvents
[n
].Time
:= (sys_GetTicks() {div 1000}) + Time
968 gDelayedEvents
[n
].Time
:= gTime
+ Time
;
978 if g_Game_IsNet
and g_Game_IsServer
then
979 MH_SEND_GameEvent(NET_EV_MAPEND
, Byte(gMissionFailed
));
983 gPauseHolmes
:= false;
986 g_Game_StopAllSounds(False);
991 EndingGameCounter
:= 0;
992 g_ActiveWindow
:= nil;
994 gLMSRespawn
:= LMS_RESPAWN_NONE
;
995 gLMSRespawnTime
:= 0;
998 EXIT_SIMPLE
: // Âûõîä ÷åðåç ìåíþ èëè êîíåö òåñòà
1003 begin // Ýòî áûë òåñò
1007 begin // Âûõîä â ãëàâíîå ìåíþ
1008 gMusic
.SetByName('MUSIC_MENU');
1010 if gState
<> STATE_SLIST
then
1012 g_GUI_ShowWindow('MainMenu');
1013 gState
:= STATE_MENU
;
1016 // Îáíîâëÿåì ñïèñîê ñåðâåðîâ
1017 slReturnPressed
:= True;
1018 if g_Net_Slist_Fetch(slCurrent
) then
1020 if slCurrent
= nil then
1021 slWaitStr
:= _lc
[I_NET_SLIST_NOSERVERS
];
1024 slWaitStr
:= _lc
[I_NET_SLIST_ERROR
];
1025 g_Serverlist_GenerateTable(slCurrent
, slTable
);
1028 g_Game_ExecuteEvent('ongameend');
1032 EXIT_RESTART
: // Íà÷àòü óðîâåíü ñíà÷àëà
1034 if not g_Game_IsClient
then g_Game_Restart();
1037 EXIT_ENDLEVELCUSTOM
: // Çàêîí÷èëñÿ óðîâåíü â Ñâîåé èãðå
1039 // Ñòàòèñòèêà Ñâîåé èãðû:
1040 FileName
:= g_ExtractWadName(gMapInfo
.Map
);
1042 CustomStat
.GameTime
:= gTime
;
1043 CustomStat
.Map
:= ExtractFileName(FileName
)+':'+g_ExtractFileName(gMapInfo
.Map
); //ResName;
1044 CustomStat
.MapName
:= gMapInfo
.Name
;
1045 CustomStat
.GameMode
:= gGameSettings
.GameMode
;
1046 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
1047 CustomStat
.TeamStat
:= gTeamStat
;
1049 CustomStat
.PlayerStat
:= nil;
1051 // Ñòàòèñòèêà èãðîêîâ:
1052 if gPlayers
<> nil then
1054 for a
:= 0 to High(gPlayers
) do
1055 if gPlayers
[a
] <> nil then
1057 SetLength(CustomStat
.PlayerStat
, Length(CustomStat
.PlayerStat
)+1);
1058 with CustomStat
.PlayerStat
[High(CustomStat
.PlayerStat
)] do
1061 Name
:= gPlayers
[a
].Name
;
1062 Frags
:= gPlayers
[a
].Frags
;
1063 Deaths
:= gPlayers
[a
].Death
;
1064 Kills
:= gPlayers
[a
].Kills
;
1065 Team
:= gPlayers
[a
].Team
;
1066 Color
:= gPlayers
[a
].Model
.Color
;
1067 Spectator
:= gPlayers
[a
].FSpectator
;
1071 SortGameStat(CustomStat
.PlayerStat
);
1073 if (gSaveStats
or gScreenshotStats
) and (Length(CustomStat
.PlayerStat
) > 1) then
1076 if g_Game_IsNet
then StatFilename
:= NetServerName
else StatFilename
:= 'local';
1077 StatDate
:= FormatDateTime('yymmdd_hhnnss', t
);
1078 StatFilename
:= StatFilename
+ '_' + CustomStat
.Map
+ '_' + g_Game_ModeToText(CustomStat
.GameMode
);
1079 StatFilename
:= sanitizeFilename(StatFilename
) + '_' + StatDate
;
1081 SaveGameStat(CustomStat
, FormatDateTime('yyyy"/"mm"/"dd', t
));
1084 StatShotDone
:= False;
1087 g_Game_ExecuteEvent('onmapend');
1088 if not g_Game_IsClient
then g_Player_ResetReady
;
1089 gInterReadyCount
:= 0;
1091 // Çàòóõàþùèé ýêðàí:
1092 EndingGameCounter
:= 255;
1093 gState
:= STATE_FOLD
;
1095 if gDefInterTime
< 0 then
1096 gInterEndTime
:= IfThen((gGameSettings
.GameType
= GT_SERVER
) and (gPlayer1
= nil), 15000, 25000)
1098 gInterEndTime
:= gDefInterTime
* 1000;
1101 EXIT_ENDLEVELSINGLE
: // Çàêîí÷èëñÿ óðîâåíü â Îäèíî÷íîé èãðå
1103 // Ñòàòèñòèêà Îäèíî÷íîé èãðû:
1104 SingleStat
.GameTime
:= gTime
;
1105 SingleStat
.TwoPlayers
:= gPlayer2
<> nil;
1106 SingleStat
.TotalSecrets
:= gSecretsCount
;
1107 // Ñòàòèñòèêà ïåðâîãî èãðîêà:
1108 SingleStat
.PlayerStat
[0].Kills
:= gPlayer1
.MonsterKills
;
1109 SingleStat
.PlayerStat
[0].Secrets
:= gPlayer1
.Secrets
;
1110 // Ñòàòèñòèêà âòîðîãî èãðîêà (åñëè åñòü):
1111 if SingleStat
.TwoPlayers
then
1113 SingleStat
.PlayerStat
[1].Kills
:= gPlayer2
.MonsterKills
;
1114 SingleStat
.PlayerStat
[1].Secrets
:= gPlayer2
.Secrets
;
1117 g_Game_ExecuteEvent('onmapend');
1120 if gNextMap
<> '' then
1122 gMusic
.SetByName('MUSIC_INTERMUS');
1124 gState
:= STATE_INTERSINGLE
;
1127 g_Game_ExecuteEvent('oninter');
1129 else // Áîëüøå íåò êàðò
1131 // Çàòóõàþùèé ýêðàí:
1132 EndingGameCounter
:= 255;
1133 gState
:= STATE_FOLD
;
1138 // Îêîí÷àíèå îáðàáîòàíî:
1139 if gExit
<> EXIT_QUIT
then
1143 procedure drawTime(X
, Y
: Integer); inline;
1145 e_TextureFontPrint(x
, y
,
1146 Format('%d:%.2d:%.2d', [
1147 gTime
div 1000 div 3600,
1148 (gTime
div 1000 div 60) mod 60,
1149 gTime
div 1000 mod 60
1154 procedure DrawStat();
1156 pc
, x
, y
, w
, h
: Integer;
1157 w1
, w2
, w3
, w4
: Integer;
1159 cw
, ch
, r
, g
, b
, rr
, gg
, bb
: Byte;
1162 stat
: TPlayerStatArray
;
1169 pc
:= g_Player_GetCount
;
1170 e_TextureFontGetSize(gStdFont
, cw
, ch
);
1172 w
:= gScreenWidth
-(gScreenWidth
div 5);
1173 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
1176 h
:= 40+ch
*5+(ch
+8)*pc
;
1177 x
:= (gScreenWidth
div 2)-(w
div 2);
1178 y
:= (gScreenHeight
div 2)-(h
div 2);
1180 e_DrawFillQuad(x
, y
, x
+w
-1, y
+h
-1, 64, 64, 64, 32);
1181 e_DrawQuad(x
, y
, x
+w
-1, y
+h
-1, 255, 127, 0);
1183 drawTime(x
+w
-78, y
+8);
1185 wad
:= g_ExtractWadNameNoPath(gMapInfo
.Map
);
1186 map
:= g_ExtractFileName(gMapInfo
.Map
);
1187 mapstr
:= wad
+ ':\' + map
+ ' - ' + gMapInfo
.Name
;
1189 case gGameSettings
.GameMode
of
1192 if gGameSettings
.MaxLives
= 0 then
1193 s1
:= _lc
[I_GAME_DM
]
1195 s1
:= _lc
[I_GAME_LMS
];
1196 s2
:= Format(_lc
[I_GAME_FRAG_LIMIT
], [gGameSettings
.GoalLimit
]);
1197 s3
:= Format(_lc
[I_GAME_TIME_LIMIT
], [gGameSettings
.TimeLimit
div 3600, (gGameSettings
.TimeLimit
div 60) mod 60, gGameSettings
.TimeLimit
mod 60]);
1202 if gGameSettings
.MaxLives
= 0 then
1203 s1
:= _lc
[I_GAME_TDM
]
1205 s1
:= _lc
[I_GAME_TLMS
];
1206 s2
:= Format(_lc
[I_GAME_FRAG_LIMIT
], [gGameSettings
.GoalLimit
]);
1207 s3
:= Format(_lc
[I_GAME_TIME_LIMIT
], [gGameSettings
.TimeLimit
div 3600, (gGameSettings
.TimeLimit
div 60) mod 60, gGameSettings
.TimeLimit
mod 60]);
1212 s1
:= _lc
[I_GAME_CTF
];
1213 s2
:= Format(_lc
[I_GAME_SCORE_LIMIT
], [gGameSettings
.GoalLimit
]);
1214 s3
:= Format(_lc
[I_GAME_TIME_LIMIT
], [gGameSettings
.TimeLimit
div 3600, (gGameSettings
.TimeLimit
div 60) mod 60, gGameSettings
.TimeLimit
mod 60]);
1219 if gGameSettings
.MaxLives
= 0 then
1220 s1
:= _lc
[I_GAME_COOP
]
1222 s1
:= _lc
[I_GAME_SURV
];
1223 s2
:= _lc
[I_GAME_MONSTERS
] + ' ' + IntToStr(gCoopMonstersKilled
) + '/' + IntToStr(gTotalMonsters
);
1224 s3
:= _lc
[I_GAME_SECRETS
] + ' ' + IntToStr(gCoopSecretsFound
) + '/' + IntToStr(gSecretsCount
);
1235 e_TextureFontPrintEx(x
+(w
div 2)-(Length(s1
)*cw
div 2), _y
, s1
, gStdFont
, 255, 255, 255, 1);
1237 e_TextureFontPrintEx(x
+(w
div 2)-(Length(mapstr
)*cw
div 2), _y
, mapstr
, gStdFont
, 200, 200, 200, 1);
1239 e_TextureFontPrintEx(x
+16, _y
, s2
, gStdFont
, 200, 200, 200, 1);
1241 e_TextureFontPrintEx(x
+w
-16-(Length(s3
))*cw
, _y
, s3
,
1242 gStdFont
, 200, 200, 200, 1);
1244 if NetMode
= NET_SERVER
then
1245 e_TextureFontPrintEx(x
+8, y
+ 8, _lc
[I_NET_SERVER
], gStdFont
, 255, 255, 255, 1)
1247 if NetMode
= NET_CLIENT
then
1248 e_TextureFontPrintEx(x
+8, y
+ 8,
1249 NetClientIP
+ ':' + IntToStr(NetClientPort
), gStdFont
, 255, 255, 255, 1);
1253 stat
:= g_Player_GetStats();
1256 w2
:= (w
-16) div 6 + 48; // øèðèíà 2 ñòîëáöà
1257 w3
:= (w
-16) div 6; // øèðèíà 3 è 4 ñòîëáöîâ
1259 w1
:= w
-16-w2
-w3
-w4
; // îñòàâøååñÿ ïðîñòðàíñòâî - äëÿ öâåòà è èìåíè èãðîêà
1261 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
1265 for a
:= TEAM_RED
to TEAM_BLUE
do
1267 if a
= TEAM_RED
then
1269 s1
:= _lc
[I_GAME_TEAM_RED
];
1276 s1
:= _lc
[I_GAME_TEAM_BLUE
];
1282 e_TextureFontPrintEx(x
+16, _y
, s1
, gStdFont
, r
, g
, b
, 1);
1283 e_TextureFontPrintEx(x
+w1
+16, _y
, IntToStr(gTeamStat
[a
].Goals
),
1284 gStdFont
, r
, g
, b
, 1);
1286 _y
:= _y
+ch
+(ch
div 4);
1287 e_DrawLine(1, x
+16, _y
, x
+w
-16, _y
, r
, g
, b
);
1288 _y
:= _y
+(ch
div 4);
1290 for aa
:= 0 to High(stat
) do
1291 if stat
[aa
].Team
= a
then
1307 e_TextureFontPrintEx(x
+16, _y
, Name
, gStdFont
, rr
, gg
, bb
, 1);
1309 e_TextureFontPrintEx(x
+w1
+16, _y
, Format(_lc
[I_GAME_PING_MS
], [Ping
, Loss
]), gStdFont
, rr
, gg
, bb
, 1);
1311 e_TextureFontPrintEx(x
+w1
+w2
+16, _y
, IntToStr(Frags
), gStdFont
, rr
, gg
, bb
, 1);
1313 e_TextureFontPrintEx(x
+w1
+w2
+w3
+16, _y
, IntToStr(Deaths
), gStdFont
, rr
, gg
, bb
, 1);
1320 else if gGameSettings
.GameMode
in [GM_DM
, GM_COOP
] then
1323 e_TextureFontPrintEx(x
+16, _y
, _lc
[I_GAME_PLAYER_NAME
], gStdFont
, 255, 127, 0, 1);
1324 e_TextureFontPrintEx(x
+16+w1
, _y
, _lc
[I_GAME_PING
], gStdFont
, 255, 127, 0, 1);
1325 e_TextureFontPrintEx(x
+16+w1
+w2
, _y
, _lc
[I_GAME_FRAGS
], gStdFont
, 255, 127, 0, 1);
1326 e_TextureFontPrintEx(x
+16+w1
+w2
+w3
, _y
, _lc
[I_GAME_DEATHS
], gStdFont
, 255, 127, 0, 1);
1329 for aa
:= 0 to High(stat
) do
1343 e_DrawFillQuad(x
+16, _y
+4, x
+32-1, _y
+16+4-1, Color
.R
, Color
.G
, Color
.B
, 0);
1344 e_DrawQuad(x
+16, _y
+4, x
+32-1, _y
+16+4-1, 192, 192, 192);
1346 e_TextureFontPrintEx(x
+16+16+8, _y
+4, Name
, gStdFont
, r
, g
, 0, 1);
1348 e_TextureFontPrintEx(x
+w1
+16, _y
+4, Format(_lc
[I_GAME_PING_MS
], [Ping
, Loss
]), gStdFont
, r
, g
, 0, 1);
1350 e_TextureFontPrintEx(x
+w1
+w2
+16, _y
+4, IntToStr(Frags
), gStdFont
, r
, g
, 0, 1);
1352 e_TextureFontPrintEx(x
+w1
+w2
+w3
+16, _y
+4, IntToStr(Deaths
), gStdFont
, r
, g
, 0, 1);
1358 procedure g_Game_Init();
1361 knownFiles
: array of AnsiString = nil;
1363 wext
, s
: AnsiString;
1368 gTempDelete
:= False;
1370 sfsGCDisable(); // temporary disable removing of temporary volumes
1373 TEXTUREFILTER
:= GL_LINEAR
;
1374 g_Texture_CreateWADEx('MENU_BACKGROUND', GameWAD
+':TEXTURES\TITLE');
1375 g_Texture_CreateWADEx('INTER', GameWAD
+':TEXTURES\INTER');
1376 g_Texture_CreateWADEx('ENDGAME_EN', GameWAD
+':TEXTURES\ENDGAME_EN');
1377 g_Texture_CreateWADEx('ENDGAME_RU', GameWAD
+':TEXTURES\ENDGAME_RU');
1378 TEXTUREFILTER
:= GL_NEAREST
;
1380 LoadStdFont('STDTXT', 'STDFONT', gStdFont
);
1381 LoadFont('MENUTXT', 'MENUFONT', gMenuFont
);
1382 LoadFont('SMALLTXT', 'SMALLFONT', gMenuSmallFont
);
1384 g_Game_ClearLoading();
1385 g_Game_SetLoadingText(Format('Doom 2D: Forever %s', [GAME_VERSION
]), 0, False);
1386 g_Game_SetLoadingText('', 0, False);
1388 g_Game_SetLoadingText(_lc
[I_LOAD_CONSOLE
], 0, False);
1391 g_Game_SetLoadingText(_lc
[I_LOAD_MODELS
], 0, False);
1392 g_PlayerModel_LoadData();
1394 // load models from all possible wad types, in all known directories
1395 // this does a loosy job (linear search, ooph!), but meh
1396 for wext
in wadExtensions
do
1398 for f
:= High(ModelDirs
) downto Low(ModelDirs
) do
1400 if (FindFirst(ModelDirs
[f
]+DirectorySeparator
+'*'+wext
, faAnyFile
, SR
) = 0) then
1404 for s
in knownFiles
do
1406 if (strEquCI1251(forceFilenameExt(SR
.Name
, ''), forceFilenameExt(ExtractFileName(s
), ''))) then
1414 SetLength(knownFiles
, length(knownFiles
)+1);
1415 knownFiles
[High(knownFiles
)] := ModelDirs
[f
]+DirectorySeparator
+SR
.Name
;
1417 until (FindNext(SR
) <> 0);
1423 if (length(knownFiles
) = 0) then raise Exception
.Create('no player models found!');
1425 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
);
1426 for s
in knownFiles
do
1428 if not g_PlayerModel_Load(s
) then e_LogWritefln('Error loading model "%s"', [s
], TMsgType
.Warning
);
1432 gPauseMain
:= false;
1433 gPauseHolmes
:= false;
1436 {e_MouseInfo.Accel := 1.0;}
1438 g_Game_SetLoadingText(_lc
[I_LOAD_GAME_DATA
], 0, False);
1441 g_Game_SetLoadingText(_lc
[I_LOAD_MUSIC
], 0, False);
1442 g_Sound_CreateWADEx('MUSIC_INTERMUS', GameWAD
+':MUSIC\INTERMUS', True);
1443 g_Sound_CreateWADEx('MUSIC_MENU', GameWAD
+':MUSIC\MENU', True);
1444 g_Sound_CreateWADEx('MUSIC_ROUNDMUS', GameWAD
+':MUSIC\ROUNDMUS', True, True);
1445 g_Sound_CreateWADEx('MUSIC_STDENDMUS', GameWAD
+':MUSIC\ENDMUS', True);
1448 g_Game_SetLoadingText(_lc
[I_LOAD_MENUS
], 0, False);
1452 gMusic
:= TMusic
.Create();
1453 gMusic
.SetByName('MUSIC_MENU');
1456 gGameSettings
.WarmupTime
:= 30;
1458 gState
:= STATE_MENU
;
1460 SetLength(gEvents
, 6);
1461 gEvents
[0].Name
:= 'ongamestart';
1462 gEvents
[1].Name
:= 'ongameend';
1463 gEvents
[2].Name
:= 'onmapstart';
1464 gEvents
[3].Name
:= 'onmapend';
1465 gEvents
[4].Name
:= 'oninter';
1466 gEvents
[5].Name
:= 'onwadend';
1468 sfsGCEnable(); // enable releasing unused volumes
1472 procedure g_Game_Free(freeTextures
: Boolean=true);
1474 if NetMode
= NET_CLIENT
then g_Net_Disconnect();
1475 if NetMode
= NET_SERVER
then g_Net_Host_Die();
1477 g_Map_Free(freeTextures
);
1479 g_Player_RemoveAllCorpses();
1481 gGameSettings
.GameType
:= GT_NONE
;
1482 if gGameSettings
.GameMode
= GM_SINGLE
then
1483 gGameSettings
.GameMode
:= GM_DM
;
1484 gSwitchGameMode
:= gGameSettings
.GameMode
;
1487 gExitByTrigger
:= False;
1490 function IsActivePlayer(p
: TPlayer
): Boolean;
1495 Result
:= (not p
.FDummy
) and (not p
.FSpectator
);
1498 function GetActivePlayer_ByID(ID
: Integer): TPlayer
;
1505 if gPlayers
= nil then
1507 for a
:= Low(gPlayers
) to High(gPlayers
) do
1508 if IsActivePlayer(gPlayers
[a
]) then
1510 if gPlayers
[a
].UID
<> ID
then
1512 Result
:= gPlayers
[a
];
1517 function GetActivePlayerID_Next(Skip
: Integer = -1): Integer;
1523 if gPlayers
= nil then
1527 for a
:= Low(gPlayers
) to High(gPlayers
) do
1528 if IsActivePlayer(gPlayers
[a
]) then
1530 SetLength(ids
, Length(ids
) + 1);
1531 ids
[High(ids
)] := gPlayers
[a
].UID
;
1532 if gPlayers
[a
].UID
= Skip
then
1535 if Length(ids
) = 0 then
1540 Result
:= ids
[(idx
+ 1) mod Length(ids
)];
1543 function GetActivePlayerID_Prev(Skip
: Integer = -1): Integer;
1549 if gPlayers
= nil then
1553 for a
:= Low(gPlayers
) to High(gPlayers
) do
1554 if IsActivePlayer(gPlayers
[a
]) then
1556 SetLength(ids
, Length(ids
) + 1);
1557 ids
[High(ids
)] := gPlayers
[a
].UID
;
1558 if gPlayers
[a
].UID
= Skip
then
1561 if Length(ids
) = 0 then
1564 Result
:= ids
[Length(ids
) - 1]
1566 Result
:= ids
[(Length(ids
) - 1 + idx
) mod Length(ids
)];
1569 function GetActivePlayerID_Random(Skip
: Integer = -1): Integer;
1575 if gPlayers
= nil then
1579 for a
:= Low(gPlayers
) to High(gPlayers
) do
1580 if IsActivePlayer(gPlayers
[a
]) then
1582 SetLength(ids
, Length(ids
) + 1);
1583 ids
[High(ids
)] := gPlayers
[a
].UID
;
1584 if gPlayers
[a
].UID
= Skip
then
1587 if Length(ids
) = 0 then
1589 if Length(ids
) = 1 then
1594 Result
:= ids
[Random(Length(ids
))];
1596 while (idx
<> -1) and (Result
= Skip
) and (a
> 0) do
1598 Result
:= ids
[Random(Length(ids
))];
1603 function GetRandomSpectMode(Current
: Byte): Byte;
1610 0: Result
:= SPECT_STATS
;
1611 1: Result
:= SPECT_MAPVIEW
;
1612 2: Result
:= SPECT_MAPVIEW
;
1613 3: Result
:= SPECT_PLAYERS
;
1614 4: Result
:= SPECT_PLAYERS
;
1615 5: Result
:= SPECT_PLAYERS
;
1616 6: Result
:= SPECT_PLAYERS
;
1618 if (Current
in [SPECT_STATS
, SPECT_MAPVIEW
]) and (Current
= Result
) then
1622 procedure ProcessPlayerControls (plr
: TPlayer
; p
: Integer; var MoveButton
: Byte);
1628 if (plr
= nil) then exit
;
1629 if (p
= 2) then time
:= 1000 else time
:= 1;
1630 strafeDir
:= MoveButton
shr 4;
1631 MoveButton
:= MoveButton
and $0F;
1633 if gPlayerAction
[p
, ACTION_MOVELEFT
] and (not gPlayerAction
[p
, ACTION_MOVERIGHT
]) then
1634 MoveButton
:= 1 // Íàæàòà òîëüêî "Âëåâî"
1635 else if (not gPlayerAction
[p
, ACTION_MOVELEFT
]) and gPlayerAction
[p
, ACTION_MOVERIGHT
] then
1636 MoveButton
:= 2 // Íàæàòà òîëüêî "Âïðàâî"
1637 else if (not gPlayerAction
[p
, ACTION_MOVELEFT
]) and (not gPlayerAction
[p
, ACTION_MOVERIGHT
]) then
1638 MoveButton
:= 0; // Íå íàæàòû íè "Âëåâî", íè "Âïðàâî"
1640 // Ñåé÷àñ èëè ðàíüøå áûëè íàæàòû "Âëåâî"/"Âïðàâî" => ïåðåäàåì èãðîêó:
1641 if MoveButton
= 1 then
1642 plr
.PressKey(KEY_LEFT
, time
)
1643 else if MoveButton
= 2 then
1644 plr
.PressKey(KEY_RIGHT
, time
);
1646 // if we have "strafe" key, turn off old strafe mechanics
1647 if gPlayerAction
[p
, ACTION_STRAFE
] then
1649 // new strafe mechanics
1650 if (strafeDir
= 0) then
1651 strafeDir
:= MoveButton
; // start strafing
1652 // now set direction according to strafe (reversed)
1653 if (strafeDir
= 2) then
1654 plr
.SetDirection(TDirection
.D_LEFT
)
1655 else if (strafeDir
= 1) then
1656 plr
.SetDirection(TDirection
.D_RIGHT
)
1660 strafeDir
:= 0; // not strafing anymore
1661 // Ðàíüøå áûëà íàæàòà "Âïðàâî", à ñåé÷àñ "Âëåâî" => áåæèì âïðàâî, ñìîòðèì âëåâî:
1662 if (MoveButton
= 2) and gPlayerAction
[p
, ACTION_MOVELEFT
] then
1663 plr
.SetDirection(TDirection
.D_LEFT
)
1664 // Ðàíüøå áûëà íàæàòà "Âëåâî", à ñåé÷àñ "Âïðàâî" => áåæèì âëåâî, ñìîòðèì âïðàâî:
1665 else if (MoveButton
= 1) and gPlayerAction
[p
, ACTION_MOVERIGHT
] then
1666 plr
.SetDirection(TDirection
.D_RIGHT
)
1667 // ×òî-òî áûëî íàæàòî è íå èçìåíèëîñü => êóäà áåæèì, òóäà è ñìîòðèì:
1668 else if MoveButton
<> 0 then
1669 plr
.SetDirection(TDirection(MoveButton
-1))
1672 // fix movebutton state
1673 MoveButton
:= MoveButton
or (strafeDir
shl 4);
1675 // Îñòàëüíûå êëàâèøè:
1676 if gPlayerAction
[p
, ACTION_JUMP
] then plr
.PressKey(KEY_JUMP
, time
);
1677 if gPlayerAction
[p
, ACTION_LOOKUP
] then plr
.PressKey(KEY_UP
, time
);
1678 if gPlayerAction
[p
, ACTION_LOOKDOWN
] then plr
.PressKey(KEY_DOWN
, time
);
1679 if gPlayerAction
[p
, ACTION_ATTACK
] then plr
.PressKey(KEY_FIRE
);
1680 if gPlayerAction
[p
, ACTION_WEAPNEXT
] then plr
.PressKey(KEY_NEXTWEAPON
);
1681 if gPlayerAction
[p
, ACTION_WEAPPREV
] then plr
.PressKey(KEY_PREVWEAPON
);
1682 if gPlayerAction
[p
, ACTION_ACTIVATE
] then plr
.PressKey(KEY_OPEN
);
1684 gPlayerAction
[p
, ACTION_WEAPNEXT
] := False; // HACK, remove after readyweaon&pendinweapon implementation
1685 gPlayerAction
[p
, ACTION_WEAPPREV
] := False; // HACK, remove after readyweaon&pendinweapon implementation
1687 for i
:= WP_FIRST
to WP_LAST
do
1689 if gSelectWeapon
[p
, i
] then
1691 plr
.QueueWeaponSwitch(i
); // all choices are passed there, and god will take the best
1692 gSelectWeapon
[p
, i
] := False
1696 // HACK: add dynlight here
1697 if gwin_k8_enable_light_experiments
then
1699 if e_KeyPressed(IK_F8
) and gGameOn
and (not gConsoleShow
) and (g_ActiveWindow
= nil) then
1701 g_playerLight
:= true;
1703 if e_KeyPressed(IK_F9
) and gGameOn
and (not gConsoleShow
) and (g_ActiveWindow
= nil) then
1705 g_playerLight
:= false;
1709 if gwin_has_stencil
and g_playerLight
then g_AddDynLight(plr
.GameX
+32, plr
.GameY
+40, 128, 1, 1, 0, 0.6);
1712 // HACK: don't have a "key was pressed" function
1713 procedure InterReady();
1715 if InterReadyTime
> gTime
then Exit
;
1716 InterReadyTime
:= gTime
+ 3000;
1717 MC_SEND_CheatRequest(NET_CHEAT_READY
);
1720 procedure g_Game_PreUpdate();
1722 // these are in separate PreUpdate functions because they can interact during Update()
1723 // and are synced over the net
1724 // we don't care that much about corpses and gibs
1725 g_Player_PreUpdate();
1726 g_Monsters_PreUpdate();
1727 g_Items_PreUpdate();
1728 g_Weapon_PreUpdate();
1731 procedure g_Game_Update();
1733 Msg
: g_gui
.TMessage
;
1739 function sendMonsPos (mon
: TMonster
): Boolean;
1741 result
:= false; // don't stop
1742 // this will also reset "need-send" flag
1743 if mon
.gncNeedSend
then
1745 MH_SEND_MonsterPos(mon
.UID
);
1747 else if (mon
.MonsterType
= MONSTER_BARREL
) then
1749 if (mon
.GameVelX
<> 0) or (mon
.GameVelY
<> 0) then MH_SEND_MonsterPos(mon
.UID
);
1751 else if (mon
.MonsterState
<> MONSTATE_SLEEP
) then
1753 if (mon
.MonsterState
<> MONSTATE_DEAD
) or (mon
.GameVelX
<> 0) or (mon
.GameVelY
<> 0) then MH_SEND_MonsterPos(mon
.UID
);
1757 function sendMonsPosUnexpected (mon
: TMonster
): Boolean;
1759 result
:= false; // don't stop
1760 // this will also reset "need-send" flag
1761 if mon
.gncNeedSend
then MH_SEND_MonsterPos(mon
.UID
);
1765 reliableUpdate
: Boolean;
1770 // Ïîðà âûêëþ÷àòü èãðó:
1771 if gExit
= EXIT_QUIT
then
1773 // Èãðà çàêîí÷èëàñü - îáðàáàòûâàåì:
1777 if gExit
= EXIT_QUIT
then
1781 // ×èòàåì êëàâèàòóðó è äæîéñòèê, åñëè îêíî àêòèâíî
1782 // no need to, as we'll do it in event handler
1784 // Îáíîâëÿåì êîíñîëü (äâèæåíèå è ñîîáùåíèÿ):
1787 if (NetMode
= NET_NONE
) and (g_Game_IsNet
) and (gGameOn
or (gState
in [STATE_FOLD
, STATE_INTERCUSTOM
])) then
1789 gExit
:= EXIT_SIMPLE
;
1794 // process master server communications
1795 g_Net_Slist_Pulse();
1798 STATE_INTERSINGLE
, // Ñòàòèñòêà ïîñëå ïðîõîæäåíèÿ óðîâíÿ â Îäèíî÷íîé èãðå
1799 STATE_INTERCUSTOM
, // Ñòàòèñòêà ïîñëå ïðîõîæäåíèÿ óðîâíÿ â Ñâîåé èãðå
1800 STATE_INTERTEXT
, // Òåêñò ìåæäó óðîâíÿìè
1801 STATE_INTERPIC
: // Êàðòèíêà ìåæäó óðîâíÿìè
1803 if g_Game_IsNet
and g_Game_IsServer
then
1805 gInterTime
:= gInterTime
+ GAME_TICK
;
1806 a
:= Min((gInterEndTime
- gInterTime
) div 1000 + 1, 255);
1807 if a
<> gServInterTime
then
1809 gServInterTime
:= a
;
1810 MH_SEND_TimeSync(gServInterTime
);
1814 if (not g_Game_IsClient
) and
1818 e_KeyPressed(IK_RETURN
) or e_KeyPressed(IK_KPRETURN
) or e_KeyPressed(IK_SPACE
) or
1819 e_KeyPressed(VK_FIRE
) or e_KeyPressed(VK_OPEN
) or
1820 e_KeyPressed(JOY0_ATTACK
) or e_KeyPressed(JOY1_ATTACK
) or
1821 e_KeyPressed(JOY2_ATTACK
) or e_KeyPressed(JOY3_ATTACK
)
1823 and (not gJustChatted
) and (not gConsoleShow
) and (not gChatShow
)
1824 and (g_ActiveWindow
= nil)
1826 or (g_Game_IsNet
and ((gInterTime
> gInterEndTime
) or ((gInterReadyCount
>= NetClientCount
) and (NetClientCount
> 0))))
1829 begin // Íàæàëè <Enter>/<Ïðîáåë> èëè ïðîøëî äîñòàòî÷íî âðåìåíè:
1830 g_Game_StopAllSounds(True);
1832 if gMapOnce
then // Ýòî áûë òåñò
1833 gExit
:= EXIT_SIMPLE
1835 if gNextMap
<> '' then // Ïåðåõîäèì íà ñëåäóþùóþ êàðòó
1836 g_Game_ChangeMap(gNextMap
)
1837 else // Ñëåäóþùåé êàðòû íåò
1839 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
] then
1841 // Âûõîä â ãëàâíîå ìåíþ:
1843 g_GUI_ShowWindow('MainMenu');
1844 gMusic
.SetByName('MUSIC_MENU');
1846 gState
:= STATE_MENU
;
1849 // Ôèíàëüíàÿ êàðòèíêà:
1850 g_Game_ExecuteEvent('onwadend');
1852 if not gMusic
.SetByName('MUSIC_endmus') then
1853 gMusic
.SetByName('MUSIC_STDENDMUS');
1855 gState
:= STATE_ENDPIC
;
1857 g_Game_ExecuteEvent('ongameend');
1862 else if g_Game_IsClient
and
1865 e_KeyPressed(IK_RETURN
) or e_KeyPressed(IK_KPRETURN
) or e_KeyPressed(IK_SPACE
) or
1866 e_KeyPressed(VK_FIRE
) or e_KeyPressed(VK_OPEN
) or
1867 e_KeyPressed(JOY0_ATTACK
) or e_KeyPressed(JOY1_ATTACK
) or
1868 e_KeyPressed(JOY2_ATTACK
) or e_KeyPressed(JOY3_ATTACK
)
1870 and (not gJustChatted
) and (not gConsoleShow
) and (not gChatShow
)
1871 and (g_ActiveWindow
= nil)
1879 if gState
= STATE_INTERTEXT
then
1880 if InterText
.counter
> 0 then
1881 InterText
.counter
:= InterText
.counter
- 1;
1884 STATE_FOLD
: // Çàòóõàíèå ýêðàíà
1886 if EndingGameCounter
= 0 then
1888 // Çàêîí÷èëñÿ óðîâåíü â Ñâîåé èãðå:
1889 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
1891 InterReadyTime
:= -1;
1892 if gLastMap
and (gGameSettings
.GameMode
= GM_COOP
) then
1894 g_Game_ExecuteEvent('onwadend');
1895 if not gMusic
.SetByName('MUSIC_endmus') then
1896 gMusic
.SetByName('MUSIC_STDENDMUS');
1899 gMusic
.SetByName('MUSIC_ROUNDMUS');
1902 gState
:= STATE_INTERCUSTOM
;
1905 else // Çàêîí÷èëàñü ïîñëåäíÿÿ êàðòà â Îäèíî÷íîé èãðå
1907 gMusic
.SetByName('MUSIC_INTERMUS');
1909 gState
:= STATE_INTERSINGLE
;
1912 g_Game_ExecuteEvent('oninter');
1915 DecMin(EndingGameCounter
, 6, 0);
1918 STATE_ENDPIC
: // Êàðòèíêà îêîí÷àíèÿ ìåãàÂàäà
1920 if gMapOnce
then // Ýòî áûë òåñò
1922 gExit
:= EXIT_SIMPLE
;
1928 g_Serverlist_Control(slCurrent
, slTable
);
1931 // Ñòàòèñòèêà ïî Tab:
1933 IsDrawStat
:= (not gConsoleShow
) and (not gChatShow
) and (gGameSettings
.GameType
<> GT_SINGLE
) and g_Console_Action(ACTION_SCORES
);
1936 if gGameOn
and not gPause
and (gState
<> STATE_FOLD
) then
1938 // Âðåìÿ += 28 ìèëëèñåêóíä:
1939 gTime
:= gTime
+ GAME_TICK
;
1941 // Ñîîáùåíèå ïîñåðåäèíå ýêðàíà:
1942 if MessageTime
= 0 then
1944 if MessageTime
> 0 then
1945 MessageTime
:= MessageTime
- 1;
1947 if (g_Game_IsServer
) then
1949 // Áûë çàäàí ëèìèò âðåìåíè:
1950 if (gGameSettings
.TimeLimit
> 0) then
1951 if (gTime
- gGameStartTime
) div 1000 >= gGameSettings
.TimeLimit
then
1952 begin // Îí ïðîøåë => êîíåö óðîâíÿ
1957 // Íàäî ðåñïàâíèòü èãðîêîâ â LMS:
1958 if (gLMSRespawn
> LMS_RESPAWN_NONE
) and (gLMSRespawnTime
< gTime
) then
1959 g_Game_RestartRound(gLMSSoftSpawn
);
1961 // Ïðîâåðèì ðåçóëüòàò ãîëîñîâàíèÿ, åñëè âðåìÿ ïðîøëî
1962 if gVoteInProgress
and (gVoteTimer
< gTime
) then
1964 else if gVotePassed
and (gVoteCmdTimer
< gTime
) then
1966 g_Console_Process(gVoteCommand
);
1968 gVotePassed
:= False;
1971 // Çàìåðÿåì âðåìÿ çàõâàòà ôëàãîâ
1972 if gFlags
[FLAG_RED
].State
= FLAG_STATE_CAPTURED
then
1973 gFlags
[FLAG_RED
].CaptureTime
:= gFlags
[FLAG_RED
].CaptureTime
+ GAME_TICK
;
1974 if gFlags
[FLAG_BLUE
].State
= FLAG_STATE_CAPTURED
then
1975 gFlags
[FLAG_BLUE
].CaptureTime
:= gFlags
[FLAG_BLUE
].CaptureTime
+ GAME_TICK
;
1977 // Áûë çàäàí ëèìèò ïîáåä:
1978 if (gGameSettings
.GoalLimit
> 0) then
1982 if gGameSettings
.GameMode
= GM_DM
then
1983 begin // Â DM èùåì èãðîêà ñ max ôðàãàìè
1984 for i
:= 0 to High(gPlayers
) do
1985 if gPlayers
[i
] <> nil then
1986 if gPlayers
[i
].Frags
> b
then
1987 b
:= gPlayers
[i
].Frags
;
1990 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
1991 begin //  CTF/TDM âûáèðàåì êîìàíäó ñ íàèáîëüøèì ñ÷åòîì
1992 b
:= Max(gTeamStat
[TEAM_RED
].Goals
, gTeamStat
[TEAM_BLUE
].Goals
);
1995 // Ëèìèò ïîáåä íàáðàí => êîíåö óðîâíÿ:
1996 if b
>= gGameSettings
.GoalLimit
then
2003 // Îáðàáàòûâàåì êëàâèøè èãðîêîâ:
2004 if gPlayer1
<> nil then gPlayer1
.ReleaseKeys();
2005 if gPlayer2
<> nil then gPlayer2
.ReleaseKeys();
2006 if (not gConsoleShow
) and (not gChatShow
) and (g_ActiveWindow
= nil) then
2008 ProcessPlayerControls(gPlayer1
, 0, P1MoveButton
);
2009 ProcessPlayerControls(gPlayer2
, 1, P2MoveButton
);
2010 end // if not console
2013 if g_Game_IsNet
and (gPlayer1
<> nil) then gPlayer1
.PressKey(KEY_CHAT
, 10000);
2015 // process weapon switch queue
2019 if (gPlayer1
= nil) and (gPlayer2
= nil) and
2020 (not gConsoleShow
) and (not gChatShow
) and (g_ActiveWindow
= nil) then
2022 if not gSpectKeyPress
then
2024 if gPlayerAction
[0, ACTION_JUMP
] and (not gSpectAuto
) then
2026 // switch spect mode
2028 SPECT_NONE
: ; // not spectator
2030 SPECT_MAPVIEW
: Inc(gSpectMode
);
2031 SPECT_PLAYERS
: gSpectMode
:= SPECT_STATS
; // reset to 1
2033 gSpectKeyPress
:= True;
2035 if (gSpectMode
= SPECT_MAPVIEW
)
2036 and (not gSpectAuto
) then
2038 if gPlayerAction
[0, ACTION_MOVELEFT
] then
2039 gSpectX
:= Max(gSpectX
- gSpectStep
, 0);
2040 if gPlayerAction
[0, ACTION_MOVERIGHT
] then
2041 gSpectX
:= Min(gSpectX
+ gSpectStep
, gMapInfo
.Width
- gScreenWidth
);
2042 if gPlayerAction
[0, ACTION_LOOKUP
] then
2043 gSpectY
:= Max(gSpectY
- gSpectStep
, 0);
2044 if gPlayerAction
[0, ACTION_LOOKDOWN
] then
2045 gSpectY
:= Min(gSpectY
+ gSpectStep
, gMapInfo
.Height
- gScreenHeight
);
2046 if gPlayerAction
[0, ACTION_WEAPPREV
] then
2049 if gSpectStep
> 4 then gSpectStep
:= gSpectStep
shr 1;
2050 gSpectKeyPress
:= True;
2052 if gPlayerAction
[0, ACTION_WEAPNEXT
] then
2055 if gSpectStep
< 64 then gSpectStep
:= gSpectStep
shl 1;
2056 gSpectKeyPress
:= True;
2059 if (gSpectMode
= SPECT_PLAYERS
)
2060 and (not gSpectAuto
) then
2062 if gPlayerAction
[0, ACTION_LOOKUP
] then
2065 gSpectViewTwo
:= True;
2066 gSpectKeyPress
:= True;
2068 if gPlayerAction
[0, ACTION_LOOKDOWN
] then
2070 // remove second view
2071 gSpectViewTwo
:= False;
2072 gSpectKeyPress
:= True;
2074 if gPlayerAction
[0, ACTION_MOVELEFT
] then
2076 // prev player (view 1)
2077 gSpectPID1
:= GetActivePlayerID_Prev(gSpectPID1
);
2078 gSpectKeyPress
:= True;
2080 if gPlayerAction
[0, ACTION_MOVERIGHT
] then
2082 // next player (view 1)
2083 gSpectPID1
:= GetActivePlayerID_Next(gSpectPID1
);
2084 gSpectKeyPress
:= True;
2086 if gPlayerAction
[0, ACTION_WEAPPREV
] then
2088 // prev player (view 2)
2089 gSpectPID2
:= GetActivePlayerID_Prev(gSpectPID2
);
2090 gSpectKeyPress
:= True;
2092 if gPlayerAction
[0, ACTION_WEAPNEXT
] then
2094 // next player (view 2)
2095 gSpectPID2
:= GetActivePlayerID_Next(gSpectPID2
);
2096 gSpectKeyPress
:= True;
2099 if gPlayerAction
[0, ACTION_ATTACK
] then
2101 if (gSpectMode
= SPECT_STATS
) and (not gSpectAuto
) then
2104 gSpectAutoNext
:= 0;
2105 gSpectViewTwo
:= False;
2106 gSpectKeyPress
:= True;
2111 gSpectMode
:= SPECT_STATS
;
2112 gSpectAuto
:= False;
2113 gSpectKeyPress
:= True;
2118 if (not gPlayerAction
[0, ACTION_JUMP
]) and
2119 (not gPlayerAction
[0, ACTION_ATTACK
]) and
2120 (not gPlayerAction
[0, ACTION_MOVELEFT
]) and
2121 (not gPlayerAction
[0, ACTION_MOVERIGHT
]) and
2122 (not gPlayerAction
[0, ACTION_LOOKUP
]) and
2123 (not gPlayerAction
[0, ACTION_LOOKDOWN
]) and
2124 (not gPlayerAction
[0, ACTION_WEAPPREV
]) and
2125 (not gPlayerAction
[0, ACTION_WEAPNEXT
]) then
2126 gSpectKeyPress
:= False;
2130 if gSpectMode
= SPECT_MAPVIEW
then
2132 i
:= Min(Max(gSpectX
+ gSpectAutoStepX
, 0), gMapInfo
.Width
- gScreenWidth
);
2134 gSpectAutoNext
:= gTime
2137 i
:= Min(Max(gSpectY
+ gSpectAutoStepY
, 0), gMapInfo
.Height
- gScreenHeight
);
2139 gSpectAutoNext
:= gTime
2143 if gSpectAutoNext
<= gTime
then
2145 if gSpectAutoNext
> 0 then
2147 gSpectMode
:= GetRandomSpectMode(gSpectMode
);
2151 gSpectX
:= Random(gMapInfo
.Width
- gScreenWidth
);
2152 gSpectY
:= Random(gMapInfo
.Height
- gScreenHeight
);
2153 gSpectAutoStepX
:= Random(9) - 4;
2154 gSpectAutoStepY
:= Random(9) - 4;
2155 if ((gSpectX
< 800) and (gSpectAutoStepX
< 0)) or
2156 ((gSpectX
> gMapInfo
.Width
- gScreenWidth
- 800) and (gSpectAutoStepX
> 0)) then
2157 gSpectAutoStepX
:= gSpectAutoStepX
* -1;
2158 if ((gSpectY
< 800) and (gSpectAutoStepY
< 0)) or
2159 ((gSpectY
> gMapInfo
.Height
- gScreenHeight
- 800) and (gSpectAutoStepY
> 0)) then
2160 gSpectAutoStepY
:= gSpectAutoStepY
* -1;
2164 gSpectPID1
:= GetActivePlayerID_Random(gSpectPID1
);
2169 SPECT_STATS
: gSpectAutoNext
:= gTime
+ (Random(3) + 5) * 1000;
2170 SPECT_MAPVIEW
: gSpectAutoNext
:= gTime
+ (Random(4) + 7) * 1000;
2171 SPECT_PLAYERS
: gSpectAutoNext
:= gTime
+ (Random(7) + 8) * 1000;
2177 // Îáíîâëÿåì âñå îñòàëüíîå:
2180 g_Triggers_Update();
2182 g_Monsters_Update();
2184 g_Player_UpdateAll();
2185 g_Player_UpdatePhysicalObjects();
2187 // server: send newly spawned monsters unconditionally
2188 if (gGameSettings
.GameType
= GT_SERVER
) then
2190 if (Length(gMonstersSpawned
) > 0) then
2192 for I
:= 0 to High(gMonstersSpawned
) do MH_SEND_MonsterSpawn(gMonstersSpawned
[I
]);
2193 SetLength(gMonstersSpawned
, 0);
2197 if (gSoundTriggerTime
> 8) then
2199 g_Game_UpdateTriggerSounds();
2200 gSoundTriggerTime
:= 0;
2204 Inc(gSoundTriggerTime
);
2207 if (NetMode
= NET_SERVER
) then
2209 Inc(NetTimeToUpdate
);
2210 Inc(NetTimeToReliable
);
2212 // send monster updates
2213 if (NetTimeToReliable
>= NetRelupdRate
) or (NetTimeToUpdate
>= NetUpdateRate
) then
2215 // send all monsters (periodic sync)
2216 reliableUpdate
:= (NetTimeToReliable
>= NetRelupdRate
);
2218 for I
:= 0 to High(gPlayers
) do
2220 if (gPlayers
[I
] <> nil) then MH_SEND_PlayerPos(reliableUpdate
, gPlayers
[I
].UID
);
2223 g_Mons_ForEach(sendMonsPos
);
2225 if reliableUpdate
then
2227 NetTimeToReliable
:= 0;
2228 NetTimeToUpdate
:= NetUpdateRate
;
2232 NetTimeToUpdate
:= 0;
2237 // send only mosters with some unexpected changes
2238 g_Mons_ForEach(sendMonsPosUnexpected
);
2241 // send unexpected platform changes
2242 g_Map_NetSendInterestingPanels();
2244 g_Net_Slist_ServerUpdate();
2246 if NetUseMaster then
2248 if (gTime >= NetTimeToMaster) or g_Net_Slist_IsConnectionInProgress then
2250 if (not g_Net_Slist_IsConnectionActive) then g_Net_Slist_Connect(false); // non-blocking connection to the master
2252 NetTimeToMaster := gTime + NetMasterRate;
2257 else if (NetMode
= NET_CLIENT
) then
2259 MC_SEND_PlayerPos();
2261 end; // if gameOn ...
2263 // Àêòèâíî îêíî èíòåðôåéñà - ïåðåäàåì êëàâèøè åìó:
2264 if g_ActiveWindow
<> nil then
2266 w
:= e_GetFirstKeyPressed();
2268 if (w
<> IK_INVALID
) then
2270 Msg
.Msg
:= MESSAGE_DIKEY
;
2272 g_ActiveWindow
.OnMessage(Msg
);
2275 // Åñëè îíî îò ýòîãî íå çàêðûëîñü, òî îáíîâëÿåì:
2276 if g_ActiveWindow
<> nil then
2277 g_ActiveWindow
.Update();
2279 // Íóæíî ñìåíèòü ðàçðåøåíèå:
2280 if gResolutionChange
then
2282 e_WriteLog('Changing resolution', TMsgType
.Notify
);
2283 g_Game_ChangeResolution(gRC_Width
, gRC_Height
, gRC_FullScreen
, gRC_Maximized
);
2284 gResolutionChange
:= False;
2285 g_ActiveWindow
:= nil;
2288 // Íóæíî ñìåíèòü ÿçûê:
2289 if gLanguageChange
then
2291 //e_WriteLog('Read language file', MSG_NOTIFY);
2292 //g_Language_Load(DataDir + gLanguage + '.txt');
2293 g_Language_Set(gLanguage
);
2297 gLanguageChange
:= False;
2301 // Ãîðÿ÷àÿ êëàâèøà äëÿ âûçîâà ìåíþ âûõîäà èç èãðû (F10):
2302 if e_KeyPressed(IK_F10
) and
2304 (not gConsoleShow
) and
2305 (g_ActiveWindow
= nil) then
2310 Time
:= sys_GetTicks() {div 1000};
2312 // Îáðàáîòêà îòëîæåííûõ ñîáûòèé:
2313 if gDelayedEvents
<> nil then
2314 for a
:= 0 to High(gDelayedEvents
) do
2315 if gDelayedEvents
[a
].Pending
and
2317 ((gDelayedEvents
[a
].DEType
= DE_GLOBEVENT
) and (gDelayedEvents
[a
].Time
<= Time
)) or
2318 ((gDelayedEvents
[a
].DEType
> DE_GLOBEVENT
) and (gDelayedEvents
[a
].Time
<= gTime
))
2321 case gDelayedEvents
[a
].DEType
of
2323 g_Game_ExecuteEvent(gDelayedEvents
[a
].DEStr
);
2326 g_Game_Announce_GoodShot(gDelayedEvents
[a
].DENum
);
2330 g_Game_Announce_KillCombo(gDelayedEvents
[a
].DENum
);
2331 if g_Game_IsNet
and g_Game_IsServer
then
2332 MH_SEND_GameEvent(NET_EV_KILLCOMBO
, gDelayedEvents
[a
].DENum
);
2336 g_Game_Announce_BodyKill(gDelayedEvents
[a
].DENum
);
2338 gDelayedEvents
[a
].Pending
:= False;
2341 // Êàæäóþ ñåêóíäó îáíîâëÿåì ñ÷åò÷èê îáíîâëåíèé:
2342 UPSCounter
:= UPSCounter
+ 1;
2343 if Time
- UPSTime
>= 1000 then
2352 g_Weapon_AddDynLights();
2353 g_Items_AddDynLights();
2357 procedure g_Game_LoadChatSounds(Resource
: string);
2360 FileName
, Snd
: string;
2362 len
, cnt
, tags
, i
, j
: Integer;
2365 FileName
:= g_ExtractWadName(Resource
);
2367 WAD
:= TWADFile
.Create();
2368 WAD
.ReadFile(FileName
);
2370 if not WAD
.GetResource(g_ExtractFilePathName(Resource
), p
, len
) then
2377 cfg
:= TConfig
.CreateMem(p
, len
);
2378 cnt
:= cfg
.ReadInt('ChatSounds', 'Count', 0);
2380 SetLength(gChatSounds
, cnt
);
2381 for i
:= 0 to Length(gChatSounds
) - 1 do
2383 gChatSounds
[i
].Sound
:= nil;
2384 Snd
:= Trim(cfg
.ReadStr(IntToStr(i
), 'Sound', ''));
2385 tags
:= cfg
.ReadInt(IntToStr(i
), 'Tags', 0);
2386 if (Snd
= '') or (Tags
<= 0) then
2388 g_Sound_CreateWADEx('SOUND_CHAT_MACRO' + IntToStr(i
), GameWAD
+':'+Snd
);
2389 gChatSounds
[i
].Sound
:= TPlayableSound
.Create();
2390 gChatSounds
[i
].Sound
.SetByName('SOUND_CHAT_MACRO' + IntToStr(i
));
2391 SetLength(gChatSounds
[i
].Tags
, tags
);
2392 for j
:= 0 to tags
- 1 do
2393 gChatSounds
[i
].Tags
[j
] := toLowerCase1251(cfg
.ReadStr(IntToStr(i
), 'Tag' + IntToStr(j
), ''));
2394 gChatSounds
[i
].FullWord
:= cfg
.ReadBool(IntToStr(i
), 'FullWord', False);
2401 procedure g_Game_FreeChatSounds();
2405 for i
:= 0 to Length(gChatSounds
) - 1 do
2407 gChatSounds
[i
].Sound
.Free();
2408 g_Sound_Delete('SOUND_CHAT_MACRO' + IntToStr(i
));
2410 SetLength(gChatSounds
, 0);
2414 procedure g_Game_LoadData();
2421 if DataLoaded
then Exit
;
2423 e_WriteLog('Loading game data...', TMsgType
.Notify
);
2425 g_Texture_CreateWADEx('NOTEXTURE', GameWAD
+':TEXTURES\NOTEXTURE');
2426 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUD', GameWAD
+':TEXTURES\HUD');
2427 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDAIR', GameWAD
+':TEXTURES\AIRBAR');
2428 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDJET', GameWAD
+':TEXTURES\JETBAR');
2429 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDBG', GameWAD
+':TEXTURES\HUDBG');
2430 g_Texture_CreateWADEx('TEXTURE_PLAYER_ARMORHUD', GameWAD
+':TEXTURES\ARMORHUD');
2431 g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG', GameWAD
+':TEXTURES\FLAGHUD_R_BASE');
2432 g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG_S', GameWAD
+':TEXTURES\FLAGHUD_R_STOLEN');
2433 g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG_D', GameWAD
+':TEXTURES\FLAGHUD_R_DROP');
2434 g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG', GameWAD
+':TEXTURES\FLAGHUD_B_BASE');
2435 g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG_S', GameWAD
+':TEXTURES\FLAGHUD_B_STOLEN');
2436 g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG_D', GameWAD
+':TEXTURES\FLAGHUD_B_DROP');
2437 g_Texture_CreateWADEx('TEXTURE_PLAYER_TALKBUBBLE', GameWAD
+':TEXTURES\TALKBUBBLE');
2438 g_Texture_CreateWADEx('TEXTURE_PLAYER_INVULPENTA', GameWAD
+':TEXTURES\PENTA');
2439 g_Texture_CreateWADEx('TEXTURE_PLAYER_INDICATOR', GameWAD
+':TEXTURES\PLRIND');
2442 if not g_Texture_CreateWADEx('UI_GFX_PBAR_LEFT', GameWAD
+':TEXTURES\LLEFT') then hasPBarGfx
:= false;
2443 if not g_Texture_CreateWADEx('UI_GFX_PBAR_MARKER', GameWAD
+':TEXTURES\LMARKER') then hasPBarGfx
:= false;
2444 if not g_Texture_CreateWADEx('UI_GFX_PBAR_MIDDLE', GameWAD
+':TEXTURES\LMIDDLE') then hasPBarGfx
:= false;
2445 if not g_Texture_CreateWADEx('UI_GFX_PBAR_RIGHT', GameWAD
+':TEXTURES\LRIGHT') then hasPBarGfx
:= false;
2449 g_Texture_GetSize('UI_GFX_PBAR_LEFT', wl
, hl
);
2450 g_Texture_GetSize('UI_GFX_PBAR_RIGHT', wr
, hr
);
2451 g_Texture_GetSize('UI_GFX_PBAR_MIDDLE', wb
, hb
);
2452 g_Texture_GetSize('UI_GFX_PBAR_MARKER', wm
, hm
);
2453 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
2459 hasPBarGfx
:= false;
2463 g_Frames_CreateWAD(nil, 'FRAMES_TELEPORT', GameWAD
+':TEXTURES\TELEPORT', 64, 64, 10, False);
2464 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH', GameWAD
+':WEAPONS\PUNCH', 64, 64, 4, False);
2465 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_UP', GameWAD
+':WEAPONS\PUNCH_UP', 64, 64, 4, False);
2466 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_DN', GameWAD
+':WEAPONS\PUNCH_DN', 64, 64, 4, False);
2467 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_BERSERK', GameWAD
+':WEAPONS\PUNCHB', 64, 64, 4, False);
2468 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_BERSERK_UP', GameWAD
+':WEAPONS\PUNCHB_UP', 64, 64, 4, False);
2469 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_BERSERK_DN', GameWAD
+':WEAPONS\PUNCHB_DN', 64, 64, 4, False);
2470 g_Sound_CreateWADEx('SOUND_GAME_TELEPORT', GameWAD
+':SOUNDS\TELEPORT');
2471 g_Sound_CreateWADEx('SOUND_GAME_NOTELEPORT', GameWAD
+':SOUNDS\NOTELEPORT');
2472 g_Sound_CreateWADEx('SOUND_GAME_SECRET', GameWAD
+':SOUNDS\SECRET');
2473 g_Sound_CreateWADEx('SOUND_GAME_DOOROPEN', GameWAD
+':SOUNDS\DOOROPEN');
2474 g_Sound_CreateWADEx('SOUND_GAME_DOORCLOSE', GameWAD
+':SOUNDS\DOORCLOSE');
2475 g_Sound_CreateWADEx('SOUND_GAME_BULK1', GameWAD
+':SOUNDS\BULK1');
2476 g_Sound_CreateWADEx('SOUND_GAME_BULK2', GameWAD
+':SOUNDS\BULK2');
2477 g_Sound_CreateWADEx('SOUND_GAME_BUBBLE1', GameWAD
+':SOUNDS\BUBBLE1');
2478 g_Sound_CreateWADEx('SOUND_GAME_BUBBLE2', GameWAD
+':SOUNDS\BUBBLE2');
2479 g_Sound_CreateWADEx('SOUND_GAME_BURNING', GameWAD
+':SOUNDS\BURNING');
2480 g_Sound_CreateWADEx('SOUND_GAME_SWITCH1', GameWAD
+':SOUNDS\SWITCH1');
2481 g_Sound_CreateWADEx('SOUND_GAME_SWITCH0', GameWAD
+':SOUNDS\SWITCH0');
2482 g_Sound_CreateWADEx('SOUND_GAME_RADIO', GameWAD
+':SOUNDS\RADIO');
2483 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD1', GameWAD
+':SOUNDS\GOOD1');
2484 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD2', GameWAD
+':SOUNDS\GOOD2');
2485 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD3', GameWAD
+':SOUNDS\GOOD3');
2486 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD4', GameWAD
+':SOUNDS\GOOD4');
2487 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL2X', GameWAD
+':SOUNDS\KILL2X');
2488 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL3X', GameWAD
+':SOUNDS\KILL3X');
2489 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL4X', GameWAD
+':SOUNDS\KILL4X');
2490 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILLMX', GameWAD
+':SOUNDS\KILLMX');
2491 g_Sound_CreateWADEx('SOUND_ANNOUNCER_MUHAHA1', GameWAD
+':SOUNDS\MUHAHA1');
2492 g_Sound_CreateWADEx('SOUND_ANNOUNCER_MUHAHA2', GameWAD
+':SOUNDS\MUHAHA2');
2493 g_Sound_CreateWADEx('SOUND_ANNOUNCER_MUHAHA3', GameWAD
+':SOUNDS\MUHAHA3');
2494 g_Sound_CreateWADEx('SOUND_CTF_GET1', GameWAD
+':SOUNDS\GETFLAG1');
2495 g_Sound_CreateWADEx('SOUND_CTF_GET2', GameWAD
+':SOUNDS\GETFLAG2');
2496 g_Sound_CreateWADEx('SOUND_CTF_LOST1', GameWAD
+':SOUNDS\LOSTFLG1');
2497 g_Sound_CreateWADEx('SOUND_CTF_LOST2', GameWAD
+':SOUNDS\LOSTFLG2');
2498 g_Sound_CreateWADEx('SOUND_CTF_RETURN1', GameWAD
+':SOUNDS\RETFLAG1');
2499 g_Sound_CreateWADEx('SOUND_CTF_RETURN2', GameWAD
+':SOUNDS\RETFLAG2');
2500 g_Sound_CreateWADEx('SOUND_CTF_CAPTURE1', GameWAD
+':SOUNDS\CAPFLAG1');
2501 g_Sound_CreateWADEx('SOUND_CTF_CAPTURE2', GameWAD
+':SOUNDS\CAPFLAG2');
2503 goodsnd
[0] := TPlayableSound
.Create();
2504 goodsnd
[1] := TPlayableSound
.Create();
2505 goodsnd
[2] := TPlayableSound
.Create();
2506 goodsnd
[3] := TPlayableSound
.Create();
2508 goodsnd
[0].SetByName('SOUND_ANNOUNCER_GOOD1');
2509 goodsnd
[1].SetByName('SOUND_ANNOUNCER_GOOD2');
2510 goodsnd
[2].SetByName('SOUND_ANNOUNCER_GOOD3');
2511 goodsnd
[3].SetByName('SOUND_ANNOUNCER_GOOD4');
2513 killsnd
[0] := TPlayableSound
.Create();
2514 killsnd
[1] := TPlayableSound
.Create();
2515 killsnd
[2] := TPlayableSound
.Create();
2516 killsnd
[3] := TPlayableSound
.Create();
2518 killsnd
[0].SetByName('SOUND_ANNOUNCER_KILL2X');
2519 killsnd
[1].SetByName('SOUND_ANNOUNCER_KILL3X');
2520 killsnd
[2].SetByName('SOUND_ANNOUNCER_KILL4X');
2521 killsnd
[3].SetByName('SOUND_ANNOUNCER_KILLMX');
2523 hahasnd
[0] := TPlayableSound
.Create();
2524 hahasnd
[1] := TPlayableSound
.Create();
2525 hahasnd
[2] := TPlayableSound
.Create();
2527 hahasnd
[0].SetByName('SOUND_ANNOUNCER_MUHAHA1');
2528 hahasnd
[1].SetByName('SOUND_ANNOUNCER_MUHAHA2');
2529 hahasnd
[2].SetByName('SOUND_ANNOUNCER_MUHAHA3');
2531 sound_get_flag
[0] := TPlayableSound
.Create();
2532 sound_get_flag
[1] := TPlayableSound
.Create();
2533 sound_lost_flag
[0] := TPlayableSound
.Create();
2534 sound_lost_flag
[1] := TPlayableSound
.Create();
2535 sound_ret_flag
[0] := TPlayableSound
.Create();
2536 sound_ret_flag
[1] := TPlayableSound
.Create();
2537 sound_cap_flag
[0] := TPlayableSound
.Create();
2538 sound_cap_flag
[1] := TPlayableSound
.Create();
2540 sound_get_flag
[0].SetByName('SOUND_CTF_GET1');
2541 sound_get_flag
[1].SetByName('SOUND_CTF_GET2');
2542 sound_lost_flag
[0].SetByName('SOUND_CTF_LOST1');
2543 sound_lost_flag
[1].SetByName('SOUND_CTF_LOST2');
2544 sound_ret_flag
[0].SetByName('SOUND_CTF_RETURN1');
2545 sound_ret_flag
[1].SetByName('SOUND_CTF_RETURN2');
2546 sound_cap_flag
[0].SetByName('SOUND_CTF_CAPTURE1');
2547 sound_cap_flag
[1].SetByName('SOUND_CTF_CAPTURE2');
2549 g_Game_LoadChatSounds(GameWAD
+':CHATSND\SNDCFG');
2551 g_Game_SetLoadingText(_lc
[I_LOAD_ITEMS_DATA
], 0, False);
2554 g_Game_SetLoadingText(_lc
[I_LOAD_WEAPONS_DATA
], 0, False);
2555 g_Weapon_LoadData();
2557 g_Monsters_LoadData();
2562 procedure g_Game_FreeData();
2564 if not DataLoaded
then Exit
;
2567 g_Weapon_FreeData();
2568 g_Monsters_FreeData();
2570 e_WriteLog('Releasing game data...', TMsgType
.Notify
);
2572 g_Texture_Delete('NOTEXTURE');
2573 g_Texture_Delete('TEXTURE_PLAYER_HUD');
2574 g_Texture_Delete('TEXTURE_PLAYER_HUDBG');
2575 g_Texture_Delete('TEXTURE_PLAYER_ARMORHUD');
2576 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG');
2577 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG_S');
2578 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG_D');
2579 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG');
2580 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG_S');
2581 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG_D');
2582 g_Texture_Delete('TEXTURE_PLAYER_TALKBUBBLE');
2583 g_Texture_Delete('TEXTURE_PLAYER_INVULPENTA');
2584 g_Frames_DeleteByName('FRAMES_TELEPORT');
2585 g_Frames_DeleteByName('FRAMES_PUNCH');
2586 g_Frames_DeleteByName('FRAMES_PUNCH_UP');
2587 g_Frames_DeleteByName('FRAMES_PUNCH_DN');
2588 g_Frames_DeleteByName('FRAMES_PUNCH_BERSERK');
2589 g_Frames_DeleteByName('FRAMES_PUNCH_BERSERK_UP');
2590 g_Frames_DeleteByName('FRAMES_PUNCH_BERSERK_DN');
2591 g_Sound_Delete('SOUND_GAME_TELEPORT');
2592 g_Sound_Delete('SOUND_GAME_NOTELEPORT');
2593 g_Sound_Delete('SOUND_GAME_SECRET');
2594 g_Sound_Delete('SOUND_GAME_DOOROPEN');
2595 g_Sound_Delete('SOUND_GAME_DOORCLOSE');
2596 g_Sound_Delete('SOUND_GAME_BULK1');
2597 g_Sound_Delete('SOUND_GAME_BULK2');
2598 g_Sound_Delete('SOUND_GAME_BUBBLE1');
2599 g_Sound_Delete('SOUND_GAME_BUBBLE2');
2600 g_Sound_Delete('SOUND_GAME_BURNING');
2601 g_Sound_Delete('SOUND_GAME_SWITCH1');
2602 g_Sound_Delete('SOUND_GAME_SWITCH0');
2609 g_Sound_Delete('SOUND_ANNOUNCER_GOOD1');
2610 g_Sound_Delete('SOUND_ANNOUNCER_GOOD2');
2611 g_Sound_Delete('SOUND_ANNOUNCER_GOOD3');
2612 g_Sound_Delete('SOUND_ANNOUNCER_GOOD4');
2619 g_Sound_Delete('SOUND_ANNOUNCER_KILL2X');
2620 g_Sound_Delete('SOUND_ANNOUNCER_KILL3X');
2621 g_Sound_Delete('SOUND_ANNOUNCER_KILL4X');
2622 g_Sound_Delete('SOUND_ANNOUNCER_KILLMX');
2628 g_Sound_Delete('SOUND_ANNOUNCER_MUHAHA1');
2629 g_Sound_Delete('SOUND_ANNOUNCER_MUHAHA2');
2630 g_Sound_Delete('SOUND_ANNOUNCER_MUHAHA3');
2632 sound_get_flag
[0].Free();
2633 sound_get_flag
[1].Free();
2634 sound_lost_flag
[0].Free();
2635 sound_lost_flag
[1].Free();
2636 sound_ret_flag
[0].Free();
2637 sound_ret_flag
[1].Free();
2638 sound_cap_flag
[0].Free();
2639 sound_cap_flag
[1].Free();
2641 g_Sound_Delete('SOUND_CTF_GET1');
2642 g_Sound_Delete('SOUND_CTF_GET2');
2643 g_Sound_Delete('SOUND_CTF_LOST1');
2644 g_Sound_Delete('SOUND_CTF_LOST2');
2645 g_Sound_Delete('SOUND_CTF_RETURN1');
2646 g_Sound_Delete('SOUND_CTF_RETURN2');
2647 g_Sound_Delete('SOUND_CTF_CAPTURE1');
2648 g_Sound_Delete('SOUND_CTF_CAPTURE2');
2650 g_Game_FreeChatSounds();
2652 DataLoaded
:= False;
2655 procedure DrawCustomStat();
2661 ww2
, hh2
, r
, g
, b
, rr
, gg
, bb
: Byte;
2662 s1
, s2
, topstr
: String;
2664 e_TextureFontGetSize(gStdFont
, ww2
, hh2
);
2668 if g_Console_Action(ACTION_SCORES
) then
2670 if not gStatsPressed
then
2672 gStatsOff
:= not gStatsOff
;
2673 gStatsPressed
:= True;
2677 gStatsPressed
:= False;
2681 s1
:= _lc
[I_MENU_INTER_NOTICE_TAB
];
2682 w
:= (Length(s1
) * ww2
) div 2;
2683 x
:= gScreenWidth
div 2 - w
;
2685 e_TextureFontPrint(x
, y
, s1
, gStdFont
);
2689 if (gGameSettings
.GameMode
= GM_COOP
) then
2691 if gMissionFailed
then
2692 topstr
:= _lc
[I_MENU_INTER_MISSION_FAIL
]
2694 topstr
:= _lc
[I_MENU_INTER_LEVEL_COMPLETE
];
2697 topstr
:= _lc
[I_MENU_INTER_ROUND_OVER
];
2699 e_CharFont_GetSize(gMenuFont
, topstr
, ww1
, hh1
);
2700 e_CharFont_Print(gMenuFont
, (gScreenWidth
div 2)-(ww1
div 2), 16, topstr
);
2702 if g_Game_IsNet
then
2704 topstr
:= Format(_lc
[I_MENU_INTER_NOTICE_TIME
], [gServInterTime
]);
2705 if not gChatShow
then
2706 e_TextureFontPrintEx((gScreenWidth
div 2)-(Length(topstr
)*ww2
div 2),
2707 gScreenHeight
-(hh2
+4)*2, topstr
, gStdFont
, 255, 255, 255, 1);
2710 if g_Game_IsClient
then
2711 topstr
:= _lc
[I_MENU_INTER_NOTICE_MAP
]
2713 topstr
:= _lc
[I_MENU_INTER_NOTICE_SPACE
];
2714 if not gChatShow
then
2715 e_TextureFontPrintEx((gScreenWidth
div 2)-(Length(topstr
)*ww2
div 2),
2716 gScreenHeight
-(hh2
+4), topstr
, gStdFont
, 255, 255, 255, 1);
2721 w
:= gScreenWidth
-x
*2;
2727 e_DrawFillQuad(x
, y
, gScreenWidth
-x
-1, gScreenHeight
-y
-1, 64, 64, 64, 32);
2728 e_DrawQuad(x
, y
, gScreenWidth
-x
-1, gScreenHeight
-y
-1, 255, 127, 0);
2730 m
:= Max(Length(_lc
[I_MENU_MAP
])+1, Length(_lc
[I_GAME_GAME_TIME
])+1)*ww2
;
2732 case CustomStat
.GameMode
of
2735 if gGameSettings
.MaxLives
= 0 then
2736 s1
:= _lc
[I_GAME_DM
]
2738 s1
:= _lc
[I_GAME_LMS
];
2742 if gGameSettings
.MaxLives
= 0 then
2743 s1
:= _lc
[I_GAME_TDM
]
2745 s1
:= _lc
[I_GAME_TLMS
];
2747 GM_CTF
: s1
:= _lc
[I_GAME_CTF
];
2750 if gGameSettings
.MaxLives
= 0 then
2751 s1
:= _lc
[I_GAME_COOP
]
2753 s1
:= _lc
[I_GAME_SURV
];
2759 e_TextureFontPrintEx(x
+(w
div 2)-(Length(s1
)*ww2
div 2), _y
, s1
, gStdFont
, 255, 255, 255, 1);
2763 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_MENU_MAP
], gStdFont
, 255, 127, 0, 1);
2764 e_TextureFontPrint(x
+8+m
, _y
, Format('%s - %s', [CustomStat
.Map
, CustomStat
.MapName
]), gStdFont
);
2767 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_GAME_TIME
], gStdFont
, 255, 127, 0, 1);
2768 e_TextureFontPrint(x
+8+m
, _y
, Format('%d:%.2d:%.2d', [CustomStat
.GameTime
div 1000 div 3600,
2769 (CustomStat
.GameTime
div 1000 div 60) mod 60,
2770 CustomStat
.GameTime
div 1000 mod 60]), gStdFont
);
2772 pc
:= Length(CustomStat
.PlayerStat
);
2773 if pc
= 0 then Exit
;
2775 if CustomStat
.GameMode
= GM_COOP
then
2777 m
:= Max(Length(_lc
[I_GAME_MONSTERS
])+1, Length(_lc
[I_GAME_SECRETS
])+1)*ww2
;
2779 s2
:= _lc
[I_GAME_MONSTERS
];
2780 e_TextureFontPrintEx(x
+8, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2781 e_TextureFontPrintEx(x
+8+m
, _y
, IntToStr(gCoopMonstersKilled
) + '/' + IntToStr(gTotalMonsters
), gStdFont
, 255, 255, 255, 1);
2783 s2
:= _lc
[I_GAME_SECRETS
];
2784 e_TextureFontPrintEx(x
+8, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2785 e_TextureFontPrintEx(x
+8+m
, _y
, IntToStr(gCoopSecretsFound
) + '/' + IntToStr(gSecretsCount
), gStdFont
, 255, 255, 255, 1);
2788 m
:= Max(Length(_lc
[I_GAME_MONSTERS_TOTAL
])+1, Length(_lc
[I_GAME_SECRETS_TOTAL
])+1)*ww2
;
2790 s2
:= _lc
[I_GAME_MONSTERS_TOTAL
];
2791 e_TextureFontPrintEx(x
+250, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2792 e_TextureFontPrintEx(x
+250+m
, _y
, IntToStr(gCoopTotalMonstersKilled
) + '/' + IntToStr(gCoopTotalMonsters
), gStdFont
, 255, 255, 255, 1);
2794 s2
:= _lc
[I_GAME_SECRETS_TOTAL
];
2795 e_TextureFontPrintEx(x
+250, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2796 e_TextureFontPrintEx(x
+250+m
, _y
, IntToStr(gCoopTotalSecretsFound
) + '/' + IntToStr(gCoopTotalSecrets
), gStdFont
, 255, 255, 255, 1);
2800 if CustomStat
.GameMode
in [GM_TDM
, GM_CTF
] then
2805 if TeamStat
[TEAM_RED
].Goals
> TeamStat
[TEAM_BLUE
].Goals
then s1
:= _lc
[I_GAME_WIN_RED
]
2806 else if TeamStat
[TEAM_BLUE
].Goals
> TeamStat
[TEAM_RED
].Goals
then s1
:= _lc
[I_GAME_WIN_BLUE
]
2807 else s1
:= _lc
[I_GAME_WIN_DRAW
];
2809 e_TextureFontPrintEx(x
+8+(w
div 2)-(Length(s1
)*ww2
div 2), _y
, s1
, gStdFont
, 255, 255, 255, 1);
2812 for t
:= TEAM_RED
to TEAM_BLUE
do
2814 if t
= TEAM_RED
then
2816 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_TEAM_RED
],
2817 gStdFont
, 255, 0, 0, 1);
2818 e_TextureFontPrintEx(x
+w1
+8, _y
, IntToStr(CustomStat
.TeamStat
[TEAM_RED
].Goals
),
2819 gStdFont
, 255, 0, 0, 1);
2826 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_TEAM_BLUE
],
2827 gStdFont
, 0, 0, 255, 1);
2828 e_TextureFontPrintEx(x
+w1
+8, _y
, IntToStr(CustomStat
.TeamStat
[TEAM_BLUE
].Goals
),
2829 gStdFont
, 0, 0, 255, 1);
2835 e_DrawLine(1, x
+8, _y
+20, x
-8+w
, _y
+20, r
, g
, b
);
2838 for p
:= 0 to High(CustomStat
.PlayerStat
) do
2839 if CustomStat
.PlayerStat
[p
].Team
= t
then
2840 with CustomStat
.PlayerStat
[p
] do
2854 if (gPlayers
[Num
] <> nil) and (gPlayers
[Num
].FReady
) then
2855 e_TextureFontPrintEx(x
+16, _y
, Name
+ ' *', gStdFont
, rr
, gg
, bb
, 1)
2857 e_TextureFontPrintEx(x
+16, _y
, Name
, gStdFont
, rr
, gg
, bb
, 1);
2858 e_TextureFontPrintEx(x
+w1
+16, _y
, IntToStr(Frags
), gStdFont
, rr
, gg
, bb
, 1);
2859 e_TextureFontPrintEx(x
+w1
+w2
+16, _y
, IntToStr(Deaths
), gStdFont
, rr
, gg
, bb
, 1);
2866 else if CustomStat
.GameMode
in [GM_DM
, GM_COOP
] then
2869 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_PLAYER_NAME
], gStdFont
, 255, 127, 0, 1);
2870 e_TextureFontPrintEx(x
+8+w1
, _y
, _lc
[I_GAME_FRAGS
], gStdFont
, 255, 127, 0, 1);
2871 e_TextureFontPrintEx(x
+8+w1
+w2
, _y
, _lc
[I_GAME_DEATHS
], gStdFont
, 255, 127, 0, 1);
2874 for p
:= 0 to High(CustomStat
.PlayerStat
) do
2875 with CustomStat
.PlayerStat
[p
] do
2877 e_DrawFillQuad(x
+8, _y
+4, x
+24-1, _y
+16+4-1, Color
.R
, Color
.G
, Color
.B
, 0);
2884 if (gPlayers
[Num
] <> nil) and (gPlayers
[Num
].FReady
) then
2885 e_TextureFontPrintEx(x
+8+16+8, _y
+4, Name
+ ' *', gStdFont
, r
, r
, r
, 1, True)
2887 e_TextureFontPrintEx(x
+8+16+8, _y
+4, Name
, gStdFont
, r
, r
, r
, 1, True);
2888 e_TextureFontPrintEx(x
+w1
+8+16+8, _y
+4, IntToStr(Frags
), gStdFont
, r
, r
, r
, 1, True);
2889 e_TextureFontPrintEx(x
+w1
+w2
+8+16+8, _y
+4, IntToStr(Deaths
), gStdFont
, r
, r
, r
, 1, True);
2894 // HACK: take stats screenshot immediately after the first frame of the stats showing
2895 if gScreenshotStats
and (not StatShotDone
) and (Length(CustomStat
.PlayerStat
) > 1) then
2897 g_TakeScreenShot('stats/' + StatFilename
);
2898 StatShotDone
:= True;
2902 procedure DrawSingleStat();
2904 tm
, key_x
, val_x
, y
: Integer;
2908 procedure player_stat(n
: Integer);
2914 s1
:= Format(' %d ', [SingleStat
.PlayerStat
[n
].Kills
]);
2915 s2
:= Format(' %d', [gTotalMonsters
]);
2917 e_CharFont_Print(gMenuFont
, key_x
, y
, _lc
[I_MENU_INTER_KILLS
]);
2918 e_CharFont_PrintEx(gMenuFont
, val_x
, y
, s1
, _RGB(255, 0, 0));
2919 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2920 e_CharFont_Print(gMenuFont
, val_x
+w1
, y
, '/');
2922 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2923 e_CharFont_PrintEx(gMenuFont
, val_x
+w1
, y
, s2
, _RGB(255, 0, 0));
2925 // "Kills-per-minute: ##.#":
2926 s1
:= _lc
[I_MENU_INTER_KPM
];
2928 kpm
:= (SingleStat
.PlayerStat
[n
].Kills
/ tm
) * 60
2930 kpm
:= SingleStat
.PlayerStat
[n
].Kills
;
2931 s2
:= Format(' %.1f', [kpm
]);
2933 e_CharFont_Print(gMenuFont
, key_x
, y
+32, s1
);
2934 e_CharFont_PrintEx(gMenuFont
, val_x
, y
+32, s2
, _RGB(255, 0, 0));
2936 // "Secrets found: # / #":
2937 s1
:= Format(' %d ', [SingleStat
.PlayerStat
[n
].Secrets
]);
2938 s2
:= Format(' %d', [SingleStat
.TotalSecrets
]);
2940 e_CharFont_Print(gMenuFont
, key_x
, y
+64, _lc
[I_MENU_INTER_SECRETS
]);
2941 e_CharFont_PrintEx(gMenuFont
, val_x
, y
+64, s1
, _RGB(255, 0, 0));
2942 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2943 e_CharFont_Print(gMenuFont
, val_x
+w1
, y
+64, '/');
2945 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2946 e_CharFont_PrintEx(gMenuFont
, val_x
+w1
, y
+64, s2
, _RGB(255, 0, 0));
2950 // "Level Complete":
2951 e_CharFont_GetSize(gMenuFont
, _lc
[I_MENU_INTER_LEVEL_COMPLETE
], w1
, h
);
2952 e_CharFont_Print(gMenuFont
, (gScreenWidth
-w1
) div 2, 32, _lc
[I_MENU_INTER_LEVEL_COMPLETE
]);
2954 // Îïðåäåëÿåì êîîðäèíàòû âûðàâíèâàíèÿ ïî ñàìîé äëèííîé ñòðîêå:
2955 s1
:= _lc
[I_MENU_INTER_KPM
];
2956 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2959 e_CharFont_GetSize(gMenuFont
, s1
, w2
, h
);
2961 key_x
:= (gScreenWidth
-w1
-w2
) div 2;
2962 val_x
:= key_x
+ w1
;
2965 tm
:= SingleStat
.GameTime
div 1000;
2966 s1
:= _lc
[I_MENU_INTER_TIME
];
2967 s2
:= Format(' %d:%.2d:%.2d', [tm
div (60*60), (tm
mod (60*60)) div 60, tm
mod 60]);
2969 e_CharFont_Print(gMenuFont
, key_x
, 80, s1
);
2970 e_CharFont_PrintEx(gMenuFont
, val_x
, 80, s2
, _RGB(255, 0, 0));
2972 if SingleStat
.TwoPlayers
then
2975 s1
:= _lc
[I_MENU_PLAYER_1
];
2976 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2977 e_CharFont_Print(gMenuFont
, (gScreenWidth
-w1
) div 2, 128, s1
);
2979 // Ñòàòèñòèêà ïåðâîãî èãðîêà:
2984 s1
:= _lc
[I_MENU_PLAYER_2
];
2985 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2986 e_CharFont_Print(gMenuFont
, (gScreenWidth
-w1
) div 2, 288, s1
);
2988 // Ñòàòèñòèêà âòîðîãî èãðîêà:
2994 // Ñòàòèñòèêà ïåðâîãî èãðîêà:
3000 procedure DrawLoadingStat();
3001 procedure drawRect (x
, y
, w
, h
: Integer);
3003 if (w
< 1) or (h
< 1) then exit
;
3005 glVertex2f(x
+0.375, y
+0.375);
3006 glVertex2f(x
+w
+0.375, y
+0.375);
3007 glVertex2f(x
+w
+0.375, y
+h
+0.375);
3008 glVertex2f(x
+0.375, y
+h
+0.375);
3012 function drawPBar (cur
, total
: Integer; washere
: Boolean): Boolean;
3014 rectW
, rectH
: Integer;
3021 idl
, idr
, idb
, idm
: LongWord;
3025 if (total
< 1) then exit
;
3026 if (cur
< 1) then exit
; // don't blink
3027 if (not washere
) and (cur
>= total
) then exit
; // don't blink
3028 //if (cur < 0) then cur := 0;
3029 //if (cur > total) then cur := total;
3032 if (hasPBarGfx
) then
3034 g_Texture_Get('UI_GFX_PBAR_LEFT', idl
);
3035 g_Texture_GetSize('UI_GFX_PBAR_LEFT', wl
, hl
);
3036 g_Texture_Get('UI_GFX_PBAR_RIGHT', idr
);
3037 g_Texture_GetSize('UI_GFX_PBAR_RIGHT', wr
, hr
);
3038 g_Texture_Get('UI_GFX_PBAR_MIDDLE', idb
);
3039 g_Texture_GetSize('UI_GFX_PBAR_MIDDLE', wb
, hb
);
3040 g_Texture_Get('UI_GFX_PBAR_MARKER', idm
);
3041 g_Texture_GetSize('UI_GFX_PBAR_MARKER', wm
, hm
);
3043 //rectW := gScreenWidth-360;
3044 rectW
:= trunc(624.0*gScreenWidth
/1024.0);
3047 x0
:= (gScreenWidth
-rectW
) div 2;
3048 y0
:= gScreenHeight
-rectH
-64;
3049 if (y0
< 2) then y0
:= 2;
3051 glEnable(GL_SCISSOR_TEST
);
3054 glScissor(x0
, gScreenHeight
-y0
-rectH
, rectW
, rectH
);
3055 e_DrawSize(idl
, x0
, y0
, 0, true, false, wl
, hl
);
3056 e_DrawSize(idr
, x0
+rectW
-wr
, y0
, 0, true, false, wr
, hr
);
3059 glScissor(x0
+wl
, gScreenHeight
-y0
-rectH
, rectW
-wl
-wr
, rectH
);
3061 while (f
< x0
+rectW
) do
3063 e_DrawSize(idb
, f
, y0
, 0, true, false, wb
, hb
);
3068 wdt
:= (rectW
-wl
-wr
)*cur
div total
;
3069 if (wdt
> rectW
-wl
-wr
) then wdt
:= rectW
-wr
-wr
;
3072 my
:= y0
; // don't be so smart, ketmar: +(rectH-wm) div 2;
3073 glScissor(x0
+wl
, gScreenHeight
-my
-rectH
, wdt
, hm
);
3077 e_DrawSize(idm
, f
, y0
, 0, true, false, wm
, hm
);
3083 glScissor(0, 0, gScreenWidth
, gScreenHeight
);
3087 rectW
:= gScreenWidth
-64;
3090 x0
:= (gScreenWidth
-rectW
) div 2;
3091 y0
:= gScreenHeight
-rectH
-64;
3092 if (y0
< 2) then y0
:= 2;
3094 glDisable(GL_BLEND
);
3095 glDisable(GL_TEXTURE_2D
);
3097 //glClearColor(0, 0, 0, 0);
3098 //glClear(GL_COLOR_BUFFER_BIT);
3100 glColor4ub(127, 127, 127, 255);
3101 drawRect(x0
-2, y0
-2, rectW
+4, rectH
+4);
3103 glColor4ub(0, 0, 0, 255);
3104 drawRect(x0
-1, y0
-1, rectW
+2, rectH
+2);
3106 glColor4ub(127, 127, 127, 255);
3107 wdt
:= rectW
*cur
div total
;
3108 if (wdt
> rectW
) then wdt
:= rectW
;
3109 drawRect(x0
, y0
, wdt
, rectH
);
3118 if (Length(LoadingStat
.Msgs
) = 0) then exit
;
3120 e_CharFont_GetSize(gMenuFont
, _lc
[I_MENU_LOADING
], ww
, hh
);
3121 yy
:= (gScreenHeight
div 3);
3122 e_CharFont_Print(gMenuFont
, (gScreenWidth
div 2)-(ww
div 2), yy
-2*hh
, _lc
[I_MENU_LOADING
]);
3123 xx
:= (gScreenWidth
div 3);
3127 for i
:= 0 to NextMsg
-1 do
3129 if (i
= (NextMsg
-1)) and (MaxValue
> 0) then
3130 s
:= Format('%s: %d/%d', [Msgs
[i
], CurValue
, MaxValue
])
3134 e_CharFont_PrintEx(gMenuSmallFont
, xx
, yy
, s
, _RGB(255, 0, 0));
3135 yy
:= yy
+ LOADING_INTERLINE
;
3136 PBarWasHere
:= drawPBar(CurValue
, MaxValue
, PBarWasHere
);
3141 procedure DrawMenuBackground(tex
: AnsiString);
3147 if g_Texture_Get(tex
, ID
) then
3149 e_Clear(GL_COLOR_BUFFER_BIT
, 0, 0, 0);
3150 e_GetTextureSize(ID
, @w
, @h
);
3152 w
:= round(w
* 1.333 * (gScreenHeight
/ h
))
3154 w
:= trunc(w
* (gScreenHeight
/ h
));
3155 e_DrawSize(ID
, (gScreenWidth
- w
) div 2, 0, 0, False, False, w
, gScreenHeight
);
3157 else e_Clear(GL_COLOR_BUFFER_BIT
, 0, 0, 0);
3160 procedure DrawMinimap(p
: TPlayer
; RenderRect
: e_graphics
.TRect
);
3162 a
, aX
, aY
, aX2
, aY2
, Scale
, ScaleSz
: Integer;
3164 function monDraw (mon
: TMonster
): Boolean;
3166 result
:= false; // don't stop
3171 // Ëåâûé âåðõíèé óãîë
3172 aX
:= Obj
.X
div ScaleSz
+ 1;
3173 aY
:= Obj
.Y
div ScaleSz
+ 1;
3175 aX2
:= max(Obj
.Rect
.Width
div ScaleSz
, 1);
3176 aY2
:= max(Obj
.Rect
.Height
div ScaleSz
, 1);
3177 // Ïðàâûé íèæíèé óãîë
3178 aX2
:= aX
+ aX2
- 1;
3179 aY2
:= aY
+ aY2
- 1;
3180 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 255, 0, 0);
3186 if (gMapInfo
.Width
> RenderRect
.Right
- RenderRect
.Left
) or
3187 (gMapInfo
.Height
> RenderRect
.Bottom
- RenderRect
.Top
) then
3190 // Ñêîëüêî ïèêñåëîâ êàðòû â 1 ïèêñåëå ìèíè-êàðòû:
3191 ScaleSz
:= 16 div Scale
;
3192 // Ðàçìåðû ìèíè-êàðòû:
3193 aX
:= max(gMapInfo
.Width
div ScaleSz
, 1);
3194 aY
:= max(gMapInfo
.Height
div ScaleSz
, 1);
3196 e_DrawFillQuad(0, 0, aX
-1, aY
-1, 0, 0, 0, 0);
3198 if gWalls
<> nil then
3201 for a
:= 0 to High(gWalls
) do
3203 if PanelType
<> 0 then
3205 // Ëåâûé âåðõíèé óãîë:
3206 aX
:= X
div ScaleSz
;
3207 aY
:= Y
div ScaleSz
;
3209 aX2
:= max(Width
div ScaleSz
, 1);
3210 aY2
:= max(Height
div ScaleSz
, 1);
3211 // Ïðàâûé íèæíèé óãîë:
3212 aX2
:= aX
+ aX2
- 1;
3213 aY2
:= aY
+ aY2
- 1;
3216 PANEL_WALL
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 208, 208, 208, 0);
3217 PANEL_OPENDOOR
, PANEL_CLOSEDOOR
:
3218 if Enabled
then e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 160, 160, 160, 0);
3222 if gSteps
<> nil then
3225 for a
:= 0 to High(gSteps
) do
3227 if PanelType
<> 0 then
3229 // Ëåâûé âåðõíèé óãîë:
3230 aX
:= X
div ScaleSz
;
3231 aY
:= Y
div ScaleSz
;
3233 aX2
:= max(Width
div ScaleSz
, 1);
3234 aY2
:= max(Height
div ScaleSz
, 1);
3235 // Ïðàâûé íèæíèé óãîë:
3236 aX2
:= aX
+ aX2
- 1;
3237 aY2
:= aY
+ aY2
- 1;
3239 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 128, 128, 128, 0);
3242 if gLifts
<> nil then
3245 for a
:= 0 to High(gLifts
) do
3247 if PanelType
<> 0 then
3249 // Ëåâûé âåðõíèé óãîë:
3250 aX
:= X
div ScaleSz
;
3251 aY
:= Y
div ScaleSz
;
3253 aX2
:= max(Width
div ScaleSz
, 1);
3254 aY2
:= max(Height
div ScaleSz
, 1);
3255 // Ïðàâûé íèæíèé óãîë:
3256 aX2
:= aX
+ aX2
- 1;
3257 aY2
:= aY
+ aY2
- 1;
3260 LIFTTYPE_UP
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 116, 72, 36, 0);
3261 LIFTTYPE_DOWN
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 116, 124, 96, 0);
3262 LIFTTYPE_LEFT
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 200, 80, 4, 0);
3263 LIFTTYPE_RIGHT
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 252, 140, 56, 0);
3267 if gWater
<> nil then
3270 for a
:= 0 to High(gWater
) do
3272 if PanelType
<> 0 then
3274 // Ëåâûé âåðõíèé óãîë:
3275 aX
:= X
div ScaleSz
;
3276 aY
:= Y
div ScaleSz
;
3278 aX2
:= max(Width
div ScaleSz
, 1);
3279 aY2
:= max(Height
div ScaleSz
, 1);
3280 // Ïðàâûé íèæíèé óãîë:
3281 aX2
:= aX
+ aX2
- 1;
3282 aY2
:= aY
+ aY2
- 1;
3284 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 0, 192, 0);
3287 if gAcid1
<> nil then
3289 // Ðèñóåì êèñëîòó 1:
3290 for a
:= 0 to High(gAcid1
) do
3292 if PanelType
<> 0 then
3294 // Ëåâûé âåðõíèé óãîë:
3295 aX
:= X
div ScaleSz
;
3296 aY
:= Y
div ScaleSz
;
3298 aX2
:= max(Width
div ScaleSz
, 1);
3299 aY2
:= max(Height
div ScaleSz
, 1);
3300 // Ïðàâûé íèæíèé óãîë:
3301 aX2
:= aX
+ aX2
- 1;
3302 aY2
:= aY
+ aY2
- 1;
3304 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 176, 0, 0);
3307 if gAcid2
<> nil then
3309 // Ðèñóåì êèñëîòó 2:
3310 for a
:= 0 to High(gAcid2
) do
3312 if PanelType
<> 0 then
3314 // Ëåâûé âåðõíèé óãîë:
3315 aX
:= X
div ScaleSz
;
3316 aY
:= Y
div ScaleSz
;
3318 aX2
:= max(Width
div ScaleSz
, 1);
3319 aY2
:= max(Height
div ScaleSz
, 1);
3320 // Ïðàâûé íèæíèé óãîë:
3321 aX2
:= aX
+ aX2
- 1;
3322 aY2
:= aY
+ aY2
- 1;
3324 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 176, 0, 0, 0);
3327 if gPlayers
<> nil then
3330 for a
:= 0 to High(gPlayers
) do
3331 if gPlayers
[a
] <> nil then with gPlayers
[a
] do
3333 // Ëåâûé âåðõíèé óãîë:
3334 aX
:= Obj
.X
div ScaleSz
+ 1;
3335 aY
:= Obj
.Y
div ScaleSz
+ 1;
3337 aX2
:= max(Obj
.Rect
.Width
div ScaleSz
, 1);
3338 aY2
:= max(Obj
.Rect
.Height
div ScaleSz
, 1);
3339 // Ïðàâûé íèæíèé óãîë:
3340 aX2
:= aX
+ aX2
- 1;
3341 aY2
:= aY
+ aY2
- 1;
3343 if gPlayers
[a
] = p
then
3344 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 255, 0, 0)
3347 TEAM_RED
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 0, 0, 0);
3348 TEAM_BLUE
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 0, 255, 0);
3349 else e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 128, 0, 0);
3354 g_Mons_ForEach(monDraw
);
3359 procedure renderAmbientQuad (hasAmbient
: Boolean; constref ambColor
: TDFColor
);
3361 if not hasAmbient
then exit
;
3362 e_AmbientQuad(sX
, sY
, sWidth
, sHeight
, ambColor
.r
, ambColor
.g
, ambColor
.b
, ambColor
.a
);
3366 // setup sX, sY, sWidth, sHeight, and transformation matrix before calling this!
3367 //FIXME: broken for splitscreen mode
3368 procedure renderDynLightsInternal ();
3370 //hasAmbient: Boolean;
3371 //ambColor: TDFColor;
3373 lx
, ly
, lrad
: Integer;
3374 scxywh
: array[0..3] of GLint
;
3377 if e_NoGraphics
then exit
;
3379 //TODO: lights should be in separate grid, i think
3380 // but on the other side: grid may be slower for dynlights, as their lifetime is short
3381 if (not gwin_k8_enable_light_experiments
) or (not gwin_has_stencil
) or (g_dynLightCount
< 1) then exit
;
3384 //ambColor := gCurrentMap['light_ambient'].rgba;
3385 //hasAmbient := (not ambColor.isOpaque) or (not ambColor.isBlack);
3387 { // this will multiply incoming color to alpha from framebuffer
3389 glBlendFunc(GL_DST_ALPHA, GL_ONE);
3393 * light rendering: (INVALID!)
3394 * glStencilFunc(GL_EQUAL, 0, $ff);
3396 * glClear(GL_STENCIL_BUFFER_BIT);
3397 * glStencilOp(GL_KEEP, GL_KEEP, GL_INCR);
3398 * draw shadow volume into stencil buffer
3399 * glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); // modify color buffer
3400 * glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); // don't modify stencil buffer
3402 * draw color-less quad with light alpha (WARNING! don't touch color!)
3403 * glEnable(GL_BLEND);
3404 * glBlendFunc(GL_DST_ALPHA, GL_ONE);
3405 * draw all geometry up to and including walls (with alpha-testing, probably) -- this does lighting
3407 wassc
:= (glIsEnabled(GL_SCISSOR_TEST
) <> 0);
3408 if wassc
then glGetIntegerv(GL_SCISSOR_BOX
, @scxywh
[0]) else glGetIntegerv(GL_VIEWPORT
, @scxywh
[0]);
3410 // setup OpenGL parameters
3411 glStencilMask($FFFFFFFF);
3412 glStencilFunc(GL_ALWAYS
, 0, $FFFFFFFF);
3413 glEnable(GL_STENCIL_TEST
);
3414 glEnable(GL_SCISSOR_TEST
);
3415 glClear(GL_STENCIL_BUFFER_BIT
);
3416 glStencilFunc(GL_EQUAL
, 0, $ff);
3418 for lln
:= 0 to g_dynLightCount
-1 do
3420 lx
:= g_dynLights
[lln
].x
;
3421 ly
:= g_dynLights
[lln
].y
;
3422 lrad
:= g_dynLights
[lln
].radius
;
3423 if (lrad
< 3) then continue
;
3425 if (lx
-sX
+lrad
< 0) then continue
;
3426 if (ly
-sY
+lrad
< 0) then continue
;
3427 if (lx
-sX
-lrad
>= gPlayerScreenSize
.X
) then continue
;
3428 if (ly
-sY
-lrad
>= gPlayerScreenSize
.Y
) then continue
;
3430 // set scissor to optimize drawing
3431 if (g_dbg_scale
= 1.0) then
3433 glScissor((lx
-sX
)-lrad
+2, gPlayerScreenSize
.Y
-(ly
-sY
)-lrad
-1+2, lrad
*2-4, lrad
*2-4);
3437 glScissor(0, 0, gScreenWidth
, gScreenHeight
);
3439 // no need to clear stencil buffer, light blitting will do it for us... but only for normal scale
3440 if (g_dbg_scale
<> 1.0) then glClear(GL_STENCIL_BUFFER_BIT
);
3441 glStencilOp(GL_KEEP
, GL_KEEP
, GL_INCR
);
3442 // draw extruded panels
3443 glDisable(GL_TEXTURE_2D
);
3444 glDisable(GL_BLEND
);
3445 glColorMask(GL_FALSE
, GL_FALSE
, GL_FALSE
, GL_FALSE
); // no need to modify color buffer
3446 if (lrad
> 4) then g_Map_DrawPanelShadowVolumes(lx
, ly
, lrad
);
3447 // render light texture
3448 glColorMask(GL_TRUE
, GL_TRUE
, GL_TRUE
, GL_TRUE
); // modify color buffer
3449 glStencilOp(GL_ZERO
, GL_ZERO
, GL_ZERO
); // draw light, and clear stencil buffer
3452 glBlendFunc(GL_SRC_ALPHA
, GL_ONE_MINUS_SRC_ALPHA
);
3453 glEnable(GL_TEXTURE_2D
);
3454 // color and opacity
3455 glColor4f(g_dynLights
[lln
].r
, g_dynLights
[lln
].g
, g_dynLights
[lln
].b
, g_dynLights
[lln
].a
);
3456 glBindTexture(GL_TEXTURE_2D
, g_Texture_Light());
3458 glTexCoord2f(0.0, 0.0); glVertex2i(lx
-lrad
, ly
-lrad
); // top-left
3459 glTexCoord2f(1.0, 0.0); glVertex2i(lx
+lrad
, ly
-lrad
); // top-right
3460 glTexCoord2f(1.0, 1.0); glVertex2i(lx
+lrad
, ly
+lrad
); // bottom-right
3461 glTexCoord2f(0.0, 1.0); glVertex2i(lx
-lrad
, ly
+lrad
); // bottom-left
3466 glDisable(GL_STENCIL_TEST
);
3467 glDisable(GL_BLEND
);
3468 glDisable(GL_SCISSOR_TEST
);
3469 //glScissor(0, 0, sWidth, sHeight);
3471 glScissor(scxywh
[0], scxywh
[1], scxywh
[2], scxywh
[3]);
3472 if wassc
then glEnable(GL_SCISSOR_TEST
) else glDisable(GL_SCISSOR_TEST
);
3476 function fixViewportForScale (): Boolean;
3478 nx0
, ny0
, nw
, nh
: Integer;
3481 if (g_dbg_scale
<> 1.0) then
3484 nx0
:= round(sX
-(gPlayerScreenSize
.X
-(sWidth
*g_dbg_scale
))/2/g_dbg_scale
);
3485 ny0
:= round(sY
-(gPlayerScreenSize
.Y
-(sHeight
*g_dbg_scale
))/2/g_dbg_scale
);
3486 nw
:= round(sWidth
/g_dbg_scale
);
3487 nh
:= round(sHeight
/g_dbg_scale
);
3496 // setup sX, sY, sWidth, sHeight, and transformation matrix before calling this!
3497 // WARNING! this WILL CALL `glTranslatef()`, but won't restore matrices!
3498 procedure renderMapInternal (backXOfs
, backYOfs
: Integer; setTransMatrix
: Boolean);
3500 TDrawCB
= procedure ();
3503 hasAmbient
: Boolean;
3505 doAmbient
: Boolean = false;
3507 procedure drawPanelType (profname
: AnsiString; panType
: DWord
; doDraw
: Boolean);
3512 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin(profname
);
3513 if gdbg_map_use_accel_render
then
3515 tagmask
:= panelTypeToTag(panType
);
3516 while (gDrawPanelList
.count
> 0) do
3518 pan
:= TPanel(gDrawPanelList
.front());
3519 if ((pan
.tag
and tagmask
) = 0) then break
;
3520 if doDraw
then pan
.Draw(doAmbient
, ambColor
);
3521 gDrawPanelList
.popFront();
3526 if doDraw
then g_Map_DrawPanels(panType
, hasAmbient
, ambColor
);
3528 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
3531 procedure drawOther (profname
: AnsiString; cb
: TDrawCB
);
3533 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin(profname
);
3534 if assigned(cb
) then cb();
3535 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
3539 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin('total');
3541 // our accelerated renderer will collect all panels to gDrawPanelList
3542 // we can use panel tag to render level parts (see GridTagXXX in g_map.pas)
3543 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin('collect');
3544 if gdbg_map_use_accel_render
then
3546 g_Map_CollectDrawPanels(sX
, sY
, sWidth
, sHeight
);
3548 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
3550 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin('skyback');
3551 g_Map_DrawBack(backXOfs
, backYOfs
);
3552 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
3554 if setTransMatrix
then
3556 //if (g_dbg_scale <> 1.0) then glTranslatef(0.0, -0.375/2, 0);
3557 glScalef(g_dbg_scale
, g_dbg_scale
, 1.0);
3558 glTranslatef(-sX
, -sY
, 0);
3562 ambColor
:= gCurrentMap
['light_ambient'].rgba
;
3563 hasAmbient
:= (not ambColor
.isOpaque
) or (not ambColor
.isBlack
);
3568 //writeln('color: (', ambColor.r, ',', ambColor.g, ',', ambColor.b, ',', ambColor.a, ')');
3569 glColor4ub(ambColor.r, ambColor.g, ambColor.b, ambColor.a);
3570 glClear(GL_COLOR_BUFFER_BIT);
3573 //writeln('color: (', ambColor.r, ',', ambColor.g, ',', ambColor.b, ',', ambColor.a, ')');
3576 drawPanelType('*back', PANEL_BACK
, g_rlayer_back
);
3577 drawPanelType('*step', PANEL_STEP
, g_rlayer_step
);
3578 drawOther('items', @g_Items_Draw
);
3579 drawOther('weapons', @g_Weapon_Draw
);
3580 drawOther('shells', @g_Player_DrawShells
);
3581 drawOther('drawall', @g_Player_DrawAll
);
3582 drawOther('corpses', @g_Player_DrawCorpses
);
3583 drawPanelType('*wall', PANEL_WALL
, g_rlayer_wall
);
3584 drawOther('monsters', @g_Monsters_Draw
);
3585 drawOther('itemdrop', @g_Items_DrawDrop
);
3586 drawPanelType('*door', PANEL_CLOSEDOOR
, g_rlayer_door
);
3587 drawOther('gfx', @g_GFX_Draw
);
3588 drawOther('flags', @g_Map_DrawFlags
);
3589 drawPanelType('*acid1', PANEL_ACID1
, g_rlayer_acid1
);
3590 drawPanelType('*acid2', PANEL_ACID2
, g_rlayer_acid2
);
3591 drawPanelType('*water', PANEL_WATER
, g_rlayer_water
);
3592 drawOther('dynlights', @renderDynLightsInternal
);
3594 if hasAmbient
{and ((not g_playerLight) or (not gwin_has_stencil) or (g_dynLightCount < 1))} then
3596 renderAmbientQuad(hasAmbient
, ambColor
);
3600 drawPanelType('*fore', PANEL_FORE
, g_rlayer_fore
);
3603 if g_debug_HealthBar
then
3605 g_Monsters_DrawHealth();
3606 g_Player_DrawHealth();
3609 if (profileFrameDraw
<> nil) then profileFrameDraw
.mainEnd(); // map rendering
3613 procedure DrawMapView(x
, y
, w
, h
: Integer);
3620 bx
:= Round(x
/(gMapInfo
.Width
- w
)*(gBackSize
.X
- w
));
3621 by
:= Round(y
/(gMapInfo
.Height
- h
)*(gBackSize
.Y
- h
));
3628 fixViewportForScale();
3629 renderMapInternal(-bx
, -by
, true);
3635 procedure DrawPlayer(p
: TPlayer
);
3637 px
, py
, a
, b
, c
, d
, i
, fX
, fY
: Integer;
3641 if (p
= nil) or (p
.FDummy
) then
3644 g_Map_DrawBack(0, 0);
3649 if (profileFrameDraw
= nil) then profileFrameDraw
:= TProfiler
.Create('RENDER', g_profile_history_size
);
3650 if (profileFrameDraw
<> nil) then profileFrameDraw
.mainBegin(g_profile_frame_draw
);
3656 camObj
:= p
.getCameraObj();
3657 camObj
.lerp(gLerpFactor
, fX
, fY
);
3658 px
:= fX
+ PLAYER_RECT_CX
;
3659 py
:= fY
+ PLAYER_RECT_CY
+nlerp(p
.SlopeOld
, camObj
.slopeUpLeft
, gLerpFactor
);
3661 if (g_dbg_scale
= 1.0) and (not g_dbg_ignore_bounds
) then
3663 if (px
> (gPlayerScreenSize
.X
div 2)) then a
:= -px
+(gPlayerScreenSize
.X
div 2) else a
:= 0;
3664 if (py
> (gPlayerScreenSize
.Y
div 2)) then b
:= -py
+(gPlayerScreenSize
.Y
div 2) else b
:= 0;
3666 if (px
> gMapInfo
.Width
-(gPlayerScreenSize
.X
div 2)) then a
:= -gMapInfo
.Width
+gPlayerScreenSize
.X
;
3667 if (py
> gMapInfo
.Height
-(gPlayerScreenSize
.Y
div 2)) then b
:= -gMapInfo
.Height
+gPlayerScreenSize
.Y
;
3669 if (gMapInfo
.Width
= gPlayerScreenSize
.X
) then a
:= 0
3670 else if (gMapInfo
.Width
< gPlayerScreenSize
.X
) then
3673 a
:= (gPlayerScreenSize
.X
-gMapInfo
.Width
) div 2;
3676 if (gMapInfo
.Height
= gPlayerScreenSize
.Y
) then b
:= 0
3677 else if (gMapInfo
.Height
< gPlayerScreenSize
.Y
) then
3680 b
:= (gPlayerScreenSize
.Y
-gMapInfo
.Height
) div 2;
3685 // scaled, ignore level bounds
3686 a
:= -px
+(gPlayerScreenSize
.X
div 2);
3687 b
:= -py
+(gPlayerScreenSize
.Y
div 2);
3692 sWidth
:= gPlayerScreenSize
.X
;
3693 sHeight
:= gPlayerScreenSize
.Y
;
3694 fixViewportForScale();
3696 i
:= py
- (sY
+ sHeight
div 2);
3697 if (p
.IncCam
> 0) then
3699 // clamp to level bounds
3700 if (sY
- p
.IncCam
< 0) then
3701 p
.IncCam
:= nclamp(sY
, 0, 120);
3702 // clamp around player position
3704 p
.IncCam
:= nclamp(p
.IncCam
, 0, max(0, 120 - i
));
3706 else if (p
.IncCam
< 0) then
3708 // clamp to level bounds
3709 if (sY
+ sHeight
- p
.IncCam
> gMapInfo
.Height
) then
3710 p
.IncCam
:= nclamp(sY
+ sHeight
- gMapInfo
.Height
, -120, 0);
3711 // clamp around player position
3713 p
.IncCam
:= nclamp(p
.IncCam
, min(0, -120 - i
), 0);
3716 sY
:= sY
- nlerp(p
.IncCamOld
, p
.IncCam
, gLerpFactor
);
3718 if (not g_dbg_ignore_bounds
) then
3720 if (sX
+sWidth
> gMapInfo
.Width
) then sX
:= gMapInfo
.Width
-sWidth
;
3721 if (sY
+sHeight
> gMapInfo
.Height
) then sY
:= gMapInfo
.Height
-sHeight
;
3722 if (sX
< 0) then sX
:= 0;
3723 if (sY
< 0) then sY
:= 0;
3726 if (gBackSize
.X
<= gPlayerScreenSize
.X
) or (gMapInfo
.Width
<= sWidth
) then c
:= 0 else c
:= trunc((gBackSize
.X
-gPlayerScreenSize
.X
)*sX
/(gMapInfo
.Width
-sWidth
));
3727 if (gBackSize
.Y
<= gPlayerScreenSize
.Y
) or (gMapInfo
.Height
<= sHeight
) then d
:= 0 else d
:= trunc((gBackSize
.Y
-gPlayerScreenSize
.Y
)*sY
/(gMapInfo
.Height
-sHeight
));
3729 //r_smallmap_h: 0: left; 1: center; 2: right
3730 //r_smallmap_v: 0: top; 1: center; 2: bottom
3732 if (gMapInfo
.Width
= sWidth
) then
3736 else if (gMapInfo
.Width
< sWidth
) then
3738 case r_smallmap_h
of
3739 1: sX
:= -((sWidth
-gMapInfo
.Width
) div 2); // center
3740 2: sX
:= -(sWidth
-gMapInfo
.Width
); // right
3741 else sX
:= 0; // left
3745 if (gMapInfo
.Height
= sHeight
) then
3749 else if (gMapInfo
.Height
< sHeight
) then
3751 case r_smallmap_v
of
3752 1: sY
:= -((sHeight
-gMapInfo
.Height
) div 2); // center
3753 2: sY
:= -(sHeight
-gMapInfo
.Height
); // bottom
3754 else sY
:= 0; // top
3760 p
.viewPortW
:= sWidth
;
3761 p
.viewPortH
:= sHeight
;
3763 {$IFDEF ENABLE_HOLMES}
3764 if (p
= gPlayer1
) then
3766 g_Holmes_plrViewPos(sX
, sY
);
3767 g_Holmes_plrViewSize(sWidth
, sHeight
);
3771 renderMapInternal(-c
, -d
, true);
3773 if (gGameSettings
.GameMode
<> GM_SINGLE
) and (gPlayerIndicator
> 0) then
3774 case gPlayerIndicator
of
3776 p
.DrawIndicator(_RGB(255, 255, 255));
3779 for i
:= 0 to High(gPlayers
) do
3780 if gPlayers
[i
] <> nil then
3781 if gPlayers
[i
] = p
then p
.DrawIndicator(_RGB(255, 255, 255))
3782 else if (gPlayers
[i
].Team
= p
.Team
) and (gPlayers
[i
].Team
<> TEAM_NONE
) then
3783 if gPlayerIndicatorStyle
= 1 then
3784 gPlayers
[i
].DrawIndicator(_RGB(192, 192, 192))
3785 else gPlayers
[i
].DrawIndicator(gPlayers
[i
].GetColor
);
3789 for a := 0 to High(gCollideMap) do
3790 for b := 0 to High(gCollideMap[a]) do
3793 if ByteBool(gCollideMap[a, b] and MARK_WALL) then
3795 if ByteBool(gCollideMap[a, b] and MARK_DOOR) then
3799 1: e_DrawPoint(1, b, a, 200, 200, 200);
3800 2: e_DrawPoint(1, b, a, 64, 64, 255);
3801 3: e_DrawPoint(1, b, a, 255, 0, 255);
3811 if gShowMap
then DrawMinimap(p
, _TRect(0, 0, 128, 128));
3812 if g_Debug_Player
then
3813 g_Player_DrawDebug(p
);
3817 procedure drawProfilers ();
3822 if g_profile_frame_draw
and (profileFrameDraw
<> nil) then px
:= px
-drawProfiles(px
, py
, profileFrameDraw
);
3823 if g_profile_collision
and (profMapCollision
<> nil) then begin px
:= px
-drawProfiles(px
, py
, profMapCollision
); py
-= calcProfilesHeight(profMonsLOS
); end;
3824 if g_profile_los
and (profMonsLOS
<> nil) then begin px
:= px
-drawProfiles(px
, py
, profMonsLOS
); py
-= calcProfilesHeight(profMonsLOS
); end;
3827 procedure g_Game_Draw();
3834 plView1
, plView2
: TPlayer
;
3837 if gExit
= EXIT_QUIT
then Exit
;
3839 Time
:= sys_GetTicks() {div 1000};
3840 FPSCounter
:= FPSCounter
+1;
3841 if Time
- FPSTime
>= 1000 then
3848 e_SetRendertarget(True);
3849 e_SetViewPort(0, 0, gScreenWidth
, gScreenHeight
);
3851 if gGameOn
or (gState
= STATE_FOLD
) then
3853 if (gPlayer1
<> nil) and (gPlayer2
<> nil) then
3855 gSpectMode
:= SPECT_NONE
;
3856 if not gRevertPlayers
then
3858 plView1
:= gPlayer1
;
3859 plView2
:= gPlayer2
;
3863 plView1
:= gPlayer2
;
3864 plView2
:= gPlayer1
;
3868 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
3870 gSpectMode
:= SPECT_NONE
;
3871 if gPlayer2
= nil then
3874 plView1
:= gPlayer2
;
3883 if (plView1
= nil) and (plView2
= nil) and (gSpectMode
= SPECT_NONE
) then
3884 gSpectMode
:= SPECT_STATS
;
3886 if gSpectMode
= SPECT_PLAYERS
then
3887 if gPlayers
<> nil then
3889 plView1
:= GetActivePlayer_ByID(gSpectPID1
);
3890 if plView1
= nil then
3892 gSpectPID1
:= GetActivePlayerID_Next();
3893 plView1
:= GetActivePlayer_ByID(gSpectPID1
);
3895 if gSpectViewTwo
then
3897 plView2
:= GetActivePlayer_ByID(gSpectPID2
);
3898 if plView2
= nil then
3900 gSpectPID2
:= GetActivePlayerID_Next();
3901 plView2
:= GetActivePlayer_ByID(gSpectPID2
);
3906 if gSpectMode
= SPECT_MAPVIEW
then
3908 // Ðåæèì ïðîñìîòðà êàðòû
3910 e_SetViewPort(0, 0, gScreenWidth
, gScreenHeight
);
3911 DrawMapView(gSpectX
, gSpectY
, gScreenWidth
, gScreenHeight
);
3912 gHearPoint1
.Active
:= True;
3913 gHearPoint1
.Coords
.X
:= gScreenWidth
div 2 + gSpectX
;
3914 gHearPoint1
.Coords
.Y
:= gScreenHeight
div 2 + gSpectY
;
3915 gHearPoint2
.Active
:= False;
3919 Split
:= (plView1
<> nil) and (plView2
<> nil);
3921 // Òî÷êè ñëóõà èãðîêîâ
3922 if plView1
<> nil then
3924 gHearPoint1
.Active
:= True;
3925 gHearPoint1
.Coords
.X
:= plView1
.GameX
+ PLAYER_RECT
.Width
;
3926 gHearPoint1
.Coords
.Y
:= plView1
.GameY
+ PLAYER_RECT
.Height
DIV 2;
3928 gHearPoint1
.Active
:= False;
3929 if plView2
<> nil then
3931 gHearPoint2
.Active
:= True;
3932 gHearPoint2
.Coords
.X
:= plView2
.GameX
+ PLAYER_RECT
.Width
;
3933 gHearPoint2
.Coords
.Y
:= plView2
.GameY
+ PLAYER_RECT
.Height
DIV 2;
3935 gHearPoint2
.Active
:= False;
3937 // Ðàçìåð ýêðàíîâ èãðîêîâ:
3938 gPlayerScreenSize
.X
:= gScreenWidth
-196;
3941 gPlayerScreenSize
.Y
:= gScreenHeight
div 2;
3942 if gScreenHeight
mod 2 = 0 then
3943 Dec(gPlayerScreenSize
.Y
);
3946 gPlayerScreenSize
.Y
:= gScreenHeight
;
3949 if gScreenHeight
mod 2 = 0 then
3950 e_SetViewPort(0, gPlayerScreenSize
.Y
+2, gPlayerScreenSize
.X
+196, gPlayerScreenSize
.Y
)
3952 e_SetViewPort(0, gPlayerScreenSize
.Y
+1, gPlayerScreenSize
.X
+196, gPlayerScreenSize
.Y
);
3954 DrawPlayer(plView1
);
3955 gPlayer1ScreenCoord
.X
:= sX
;
3956 gPlayer1ScreenCoord
.Y
:= sY
;
3960 e_SetViewPort(0, 0, gPlayerScreenSize
.X
+196, gPlayerScreenSize
.Y
);
3962 DrawPlayer(plView2
);
3963 gPlayer2ScreenCoord
.X
:= sX
;
3964 gPlayer2ScreenCoord
.Y
:= sY
;
3967 e_SetViewPort(0, 0, gScreenWidth
, gScreenHeight
);
3970 e_DrawLine(2, 0, gScreenHeight
div 2, gScreenWidth
, gScreenHeight
div 2, 0, 0, 0);
3973 {$IFDEF ENABLE_HOLMES}
3975 if (g_holmes_enabled
) then g_Holmes_Draw();
3978 if MessageText
<> '' then
3982 e_CharFont_GetSizeFmt(gMenuFont
, MessageText
, w
, h
);
3984 e_CharFont_PrintFmt(gMenuFont
, (gScreenWidth
div 2)-(w
div 2),
3985 (gScreenHeight
div 2)-(h
div 2), MessageText
)
3987 e_CharFont_PrintFmt(gMenuFont
, (gScreenWidth
div 2)-(w
div 2),
3988 Round(gScreenHeight
/ 2.75)-(h
div 2), MessageText
);
3991 if IsDrawStat
or (gSpectMode
= 1) then DrawStat();
3993 if gSpectHUD
and (not gChatShow
) and (gSpectMode
<> SPECT_NONE
) and (not gSpectAuto
) then
3995 // Draw spectator GUI
3998 e_TextureFontGetSize(gStdFont
, ww
, hh
);
4001 e_TextureFontPrintEx(0, gScreenHeight
- (hh
+2)*2, 'MODE: Stats', gStdFont
, 255, 255, 255, 1);
4003 e_TextureFontPrintEx(0, gScreenHeight
- (hh
+2)*2, 'MODE: Observe Map', gStdFont
, 255, 255, 255, 1);
4005 e_TextureFontPrintEx(0, gScreenHeight
- (hh
+2)*2, 'MODE: Watch Players', gStdFont
, 255, 255, 255, 1);
4007 e_TextureFontPrintEx(2*ww
, gScreenHeight
- (hh
+2), '< jump >', gStdFont
, 255, 255, 255, 1);
4008 if gSpectMode
= SPECT_STATS
then
4010 e_TextureFontPrintEx(16*ww
, gScreenHeight
- (hh
+2)*2, 'Autoview', gStdFont
, 255, 255, 255, 1);
4011 e_TextureFontPrintEx(16*ww
, gScreenHeight
- (hh
+2), '< fire >', gStdFont
, 255, 255, 255, 1);
4013 if gSpectMode
= SPECT_MAPVIEW
then
4015 e_TextureFontPrintEx(22*ww
, gScreenHeight
- (hh
+2)*2, '[-]', gStdFont
, 255, 255, 255, 1);
4016 e_TextureFontPrintEx(26*ww
, gScreenHeight
- (hh
+2)*2, 'Step ' + IntToStr(gSpectStep
), gStdFont
, 255, 255, 255, 1);
4017 e_TextureFontPrintEx(34*ww
, gScreenHeight
- (hh
+2)*2, '[+]', gStdFont
, 255, 255, 255, 1);
4018 e_TextureFontPrintEx(18*ww
, gScreenHeight
- (hh
+2), '<prev weap>', gStdFont
, 255, 255, 255, 1);
4019 e_TextureFontPrintEx(30*ww
, gScreenHeight
- (hh
+2), '<next weap>', gStdFont
, 255, 255, 255, 1);
4021 if gSpectMode
= SPECT_PLAYERS
then
4023 e_TextureFontPrintEx(22*ww
, gScreenHeight
- (hh
+2)*2, 'Player 1', gStdFont
, 255, 255, 255, 1);
4024 e_TextureFontPrintEx(20*ww
, gScreenHeight
- (hh
+2), '<left/right>', gStdFont
, 255, 255, 255, 1);
4025 if gSpectViewTwo
then
4027 e_TextureFontPrintEx(37*ww
, gScreenHeight
- (hh
+2)*2, 'Player 2', gStdFont
, 255, 255, 255, 1);
4028 e_TextureFontPrintEx(34*ww
, gScreenHeight
- (hh
+2), '<prev w/next w>', gStdFont
, 255, 255, 255, 1);
4029 e_TextureFontPrintEx(52*ww
, gScreenHeight
- (hh
+2)*2, '2x View', gStdFont
, 255, 255, 255, 1);
4030 e_TextureFontPrintEx(51*ww
, gScreenHeight
- (hh
+2), '<up/down>', gStdFont
, 255, 255, 255, 1);
4034 e_TextureFontPrintEx(35*ww
, gScreenHeight
- (hh
+2)*2, '2x View', gStdFont
, 255, 255, 255, 1);
4035 e_TextureFontPrintEx(34*ww
, gScreenHeight
- (hh
+2), '<up/down>', gStdFont
, 255, 255, 255, 1);
4041 if gPauseMain
and gGameOn
and (g_ActiveWindow
= nil) then
4043 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4044 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4046 e_CharFont_GetSize(gMenuFont
, _lc
[I_MENU_PAUSE
], w
, h
);
4047 e_CharFont_Print(gMenuFont
, (gScreenWidth
div 2)-(w
div 2),
4048 (gScreenHeight
div 2)-(h
div 2), _lc
[I_MENU_PAUSE
]);
4053 if (gState
= STATE_MENU
) then
4055 if (g_ActiveWindow
= nil) or (g_ActiveWindow
.BackTexture
= '') then DrawMenuBackground('MENU_BACKGROUND');
4056 // F3 at menu will show game loading dialog
4057 if e_KeyPressed(IK_F3
) then g_Menu_Show_LoadMenu(true);
4058 if (g_ActiveWindow
<> nil) then
4060 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4061 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4065 // F3 at titlepic will show game loading dialog
4066 if e_KeyPressed(IK_F3
) then
4068 g_Menu_Show_LoadMenu(true);
4069 if (g_ActiveWindow
<> nil) then e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4074 if gState
= STATE_FOLD
then
4076 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 0, 0, 0, EndingGameCounter
);
4079 if gState
= STATE_INTERCUSTOM
then
4081 if gLastMap
and (gGameSettings
.GameMode
= GM_COOP
) then
4083 back
:= 'TEXTURE_endpic';
4084 if not g_Texture_Get(back
, ID
) then
4085 back
:= _lc
[I_TEXTURE_ENDPIC
];
4090 DrawMenuBackground(back
);
4094 if g_ActiveWindow
<> nil then
4096 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4097 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4101 if gState
= STATE_INTERSINGLE
then
4103 if EndingGameCounter
> 0 then
4105 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 0, 0, 0, EndingGameCounter
);
4111 DrawMenuBackground(back
);
4115 if g_ActiveWindow
<> nil then
4117 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4118 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4123 if gState
= STATE_ENDPIC
then
4126 if g_Texture_Get('TEXTURE_endpic', ID
) then DrawMenuBackground('TEXTURE_endpic')
4127 else DrawMenuBackground(_lc
[I_TEXTURE_ENDPIC
]);
4129 if g_ActiveWindow
<> nil then
4131 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4132 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4136 if gState
= STATE_SLIST
then
4138 // if g_Texture_Get('MENU_BACKGROUND', ID) then
4140 // e_DrawSize(ID, 0, 0, 0, False, False, gScreenWidth, gScreenHeight);
4141 // //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4143 DrawMenuBackground('MENU_BACKGROUND');
4144 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4145 g_Serverlist_Draw(slCurrent
, slTable
);
4149 if g_ActiveWindow
<> nil then
4153 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4154 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4156 g_ActiveWindow
.Draw();
4163 if g_debug_Sounds
and gGameOn
then
4165 for w
:= 0 to High(e_SoundsArray
) do
4166 for h
:= 0 to e_SoundsArray
[w
].nRefs
do
4167 e_DrawPoint(1, w
+100, h
+100, 255, 0, 0);
4172 e_TextureFontPrint(0, 0, Format('FPS: %d', [FPS
]), gStdFont
);
4173 e_TextureFontPrint(0, 16, Format('UPS: %d', [UPS
]), gStdFont
);
4176 if gGameOn
and gShowTime
then
4177 drawTime(gScreenWidth
-72, gScreenHeight
-16);
4179 if gGameOn
then drawProfilers();
4181 // TODO: draw this after the FBO and remap mouse click coordinates
4183 {$IFDEF ENABLE_HOLMES}
4187 // blit framebuffer to screen
4189 e_SetRendertarget(False);
4190 e_SetViewPort(0, 0, gWinSizeX
, gWinSizeY
);
4191 e_BlitFramebuffer(gWinSizeX
, gWinSizeY
);
4193 // draw the overlay stuff on top of it
4198 procedure g_Game_Quit();
4200 g_Game_StopAllSounds(True);
4203 g_PlayerModel_FreeData();
4204 g_Texture_DeleteAll();
4205 g_Frames_DeleteAll();
4207 //g_Menu_Free(); //k8: this segfaults after resolution change; who cares?
4210 if NetInitDone
then g_Net_Free
;
4212 // Íàäî óäàëèòü êàðòó ïîñëå òåñòà:
4213 if gMapToDelete
<> '' then
4214 g_Game_DeleteTestMap();
4220 procedure g_FatalError(Text: String);
4222 g_Console_Add(Format(_lc
[I_FATAL_ERROR
], [Text]), True);
4223 e_WriteLog(Format(_lc
[I_FATAL_ERROR
], [Text]), TMsgType
.Warning
);
4225 gExit
:= EXIT_SIMPLE
;
4228 procedure g_SimpleError(Text: String);
4230 g_Console_Add(Format(_lc
[I_SIMPLE_ERROR
], [Text]), True);
4231 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], [Text]), TMsgType
.Warning
);
4234 procedure g_Game_SetupScreenSize();
4236 RES_FACTOR
= 4.0 / 3.0;
4242 // Ðàçìåð ýêðàíîâ èãðîêîâ:
4243 gPlayerScreenSize
.X
:= gScreenWidth
-196;
4244 if (gPlayer1
<> nil) and (gPlayer2
<> nil) then
4245 gPlayerScreenSize
.Y
:= gScreenHeight
div 2
4247 gPlayerScreenSize
.Y
:= gScreenHeight
;
4249 // Ðàçìåð çàäíåãî ïëàíà:
4250 if BackID
<> DWORD(-1) then
4253 if (gScreenWidth
*s
> gMapInfo
.Width
) or
4254 (gScreenHeight
*s
> gMapInfo
.Height
) then
4256 gBackSize
.X
:= gScreenWidth
;
4257 gBackSize
.Y
:= gScreenHeight
;
4261 e_GetTextureSize(BackID
, @bw
, @bh
);
4262 rf
:= Single(bw
) / Single(bh
);
4263 if (rf
> RES_FACTOR
) then bw
:= Round(Single(bh
) * RES_FACTOR
)
4264 else if (rf
< RES_FACTOR
) then bh
:= Round(Single(bw
) / RES_FACTOR
);
4265 s
:= Max(gScreenWidth
/ bw
, gScreenHeight
/ bh
);
4266 if (s
< 1.0) then s
:= 1.0;
4267 gBackSize
.X
:= Round(bw
*s
);
4268 gBackSize
.Y
:= Round(bh
*s
);
4273 procedure g_Game_ChangeResolution(newWidth
, newHeight
: Word; nowFull
, nowMax
: Boolean);
4275 sys_SetDisplayMode(newWidth
, newHeight
, gBPP
, nowFull
, nowMax
);
4278 procedure g_Game_AddPlayer(Team
: Byte = TEAM_NONE
);
4280 if ((not gGameOn
) and (gState
<> STATE_INTERCUSTOM
))
4281 or (not (gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
])) then
4284 if (gGameSettings
.MaxLives
> 0) and (gLMSRespawn
= LMS_RESPAWN_NONE
) then
4287 if gPlayer1
= nil then
4289 if g_Game_IsClient
then
4291 if NetPlrUID1
> -1 then
4292 MC_SEND_CheatRequest(NET_CHEAT_SPECTATE
);
4296 if not (Team
in [TEAM_RED
, TEAM_BLUE
]) then
4297 Team
:= gPlayer1Settings
.Team
;
4299 // Ñîçäàíèå ïåðâîãî èãðîêà:
4300 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4301 gPlayer1Settings
.Color
,
4303 if gPlayer1
= nil then
4304 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]))
4307 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4308 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [gPlayer1
.Name
]), True);
4309 if g_Game_IsServer
and g_Game_IsNet
then
4310 MH_SEND_PlayerCreate(gPlayer1
.UID
);
4311 gPlayer1
.Respawn(False, True);
4312 g_Net_Slist_ServerPlayerComes();
4317 if gPlayer2
= nil then
4319 if g_Game_IsClient
then
4321 if NetPlrUID2
> -1 then
4322 gPlayer2
:= g_Player_Get(NetPlrUID2
);
4326 if not (Team
in [TEAM_RED
, TEAM_BLUE
]) then
4327 Team
:= gPlayer2Settings
.Team
;
4329 // Ñîçäàíèå âòîðîãî èãðîêà:
4330 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
4331 gPlayer2Settings
.Color
,
4333 if gPlayer2
= nil then
4334 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]))
4337 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
4338 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [gPlayer2
.Name
]), True);
4339 if g_Game_IsServer
and g_Game_IsNet
then
4340 MH_SEND_PlayerCreate(gPlayer2
.UID
);
4341 gPlayer2
.Respawn(False, True);
4342 g_Net_Slist_ServerPlayerComes();
4349 procedure g_Game_RemovePlayer();
4353 if ((not gGameOn
) and (gState
<> STATE_INTERCUSTOM
))
4354 or (not (gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
])) then
4359 if g_Game_IsServer
then
4362 Pl
.Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
4363 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [Pl
.Name
]), True);
4364 g_Player_Remove(Pl
.UID
);
4365 g_Net_Slist_ServerPlayerLeaves();
4369 gSpectLatchPID2
:= Pl
.UID
;
4377 if g_Game_IsServer
then
4380 Pl
.Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
4381 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [Pl
.Name
]), True);
4382 g_Player_Remove(Pl
.UID
);
4383 g_Net_Slist_ServerPlayerLeaves();
4386 gSpectLatchPID1
:= Pl
.UID
;
4388 MC_SEND_CheatRequest(NET_CHEAT_SPECTATE
);
4392 g_Net_Slist_ServerPlayerLeaves();
4395 procedure g_Game_Spectate();
4397 g_Game_RemovePlayer();
4398 if gPlayer1
<> nil then
4399 g_Game_RemovePlayer();
4402 procedure g_Game_SpectateCenterView();
4404 gSpectX
:= Max(gMapInfo
.Width
div 2 - gScreenWidth
div 2, 0);
4405 gSpectY
:= Max(gMapInfo
.Height
div 2 - gScreenHeight
div 2, 0);
4408 procedure g_Game_StartSingle(Map
: String; TwoPlayers
: Boolean; nPlayers
: Byte);
4415 e_WriteLog('Starting singleplayer game...', TMsgType
.Notify
);
4417 g_Game_ClearLoading();
4420 FillByte(gGameSettings
, SizeOf(TGameSettings
), 0);
4423 gGameSettings
.GameType
:= GT_SINGLE
;
4424 gGameSettings
.MaxLives
:= 0;
4425 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_ALLOWEXIT
;
4426 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_MONSTERS
;
4427 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_BOTVSMONSTER
;
4428 gSwitchGameMode
:= GM_SINGLE
;
4430 gLMSRespawn
:= LMS_RESPAWN_NONE
;
4431 gLMSRespawnTime
:= 0;
4432 gSpectLatchPID1
:= 0;
4433 gSpectLatchPID2
:= 0;
4435 g_Game_ExecuteEvent('ongamestart');
4437 // Óñòàíîâêà ðàçìåðîâ îêîí èãðîêîâ:
4438 g_Game_SetupScreenSize();
4440 // Ñîçäàíèå ïåðâîãî èãðîêà:
4441 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4442 gPlayer1Settings
.Color
,
4443 gPlayer1Settings
.Team
, False));
4444 if gPlayer1
= nil then
4446 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
4450 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4453 // Ñîçäàíèå âòîðîãî èãðîêà, åñëè åñòü:
4456 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
4457 gPlayer2Settings
.Color
,
4458 gPlayer2Settings
.Team
, False));
4459 if gPlayer2
= nil then
4461 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
4465 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
4469 // Çàãðóçêà è çàïóñê êàðòû:
4470 if not g_Game_StartMap(false{asMegawad}, MAP
, True) then
4472 if (Pos(':\', Map
) > 0) or (Pos(':/', Map
) > 0) then tmps
:= Map
else tmps
:= gGameSettings
.WAD
+ ':\' + MAP
;
4473 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [tmps
]));
4477 // Íàñòðîéêè èãðîêîâ è áîòîâ:
4481 for i
:= nPl
+1 to nPlayers
do
4482 g_Player_Create(STD_PLAYER_MODEL
, _RGB(0, 0, 0), 0, True);
4485 procedure g_Game_StartCustom(Map
: String; GameMode
: Byte;
4486 TimeLimit
, GoalLimit
: Word;
4488 Options
: LongWord; nPlayers
: Byte);
4494 e_WriteLog('Starting custom game...', TMsgType
.Notify
);
4496 g_Game_ClearLoading();
4499 gGameSettings
.GameType
:= GT_CUSTOM
;
4500 gGameSettings
.GameMode
:= GameMode
;
4501 gSwitchGameMode
:= GameMode
;
4502 gGameSettings
.TimeLimit
:= TimeLimit
;
4503 gGameSettings
.GoalLimit
:= GoalLimit
;
4504 gGameSettings
.MaxLives
:= IfThen(GameMode
= GM_CTF
, 0, MaxLives
);
4505 gGameSettings
.Options
:= Options
;
4507 gCoopTotalMonstersKilled
:= 0;
4508 gCoopTotalSecretsFound
:= 0;
4509 gCoopTotalMonsters
:= 0;
4510 gCoopTotalSecrets
:= 0;
4514 gLMSRespawn
:= LMS_RESPAWN_NONE
;
4515 gLMSRespawnTime
:= 0;
4516 gSpectLatchPID1
:= 0;
4517 gSpectLatchPID2
:= 0;
4519 g_Game_ExecuteEvent('ongamestart');
4521 // Óñòàíîâêà ðàçìåðîâ îêîí èãðîêîâ:
4522 g_Game_SetupScreenSize();
4524 // Ðåæèì íàáëþäàòåëÿ:
4525 if nPlayers
= 0 then
4532 if nPlayers
>= 1 then
4534 // Ñîçäàíèå ïåðâîãî èãðîêà:
4535 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4536 gPlayer1Settings
.Color
,
4537 gPlayer1Settings
.Team
, False));
4538 if gPlayer1
= nil then
4540 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
4544 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4548 if nPlayers
>= 2 then
4550 // Ñîçäàíèå âòîðîãî èãðîêà:
4551 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
4552 gPlayer2Settings
.Color
,
4553 gPlayer2Settings
.Team
, False));
4554 if gPlayer2
= nil then
4556 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
4560 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
4564 // Çàãðóçêà è çàïóñê êàðòû:
4565 if not g_Game_StartMap(true{asMegawad}, Map
, True) then
4567 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [Map
]));
4571 // Íåò òî÷åê ïîÿâëåíèÿ:
4572 if (g_Map_GetPointCount(RESPAWNPOINT_PLAYER1
) +
4573 g_Map_GetPointCount(RESPAWNPOINT_PLAYER2
) +
4574 g_Map_GetPointCount(RESPAWNPOINT_DM
) +
4575 g_Map_GetPointCount(RESPAWNPOINT_RED
)+
4576 g_Map_GetPointCount(RESPAWNPOINT_BLUE
)) < 1 then
4578 g_FatalError(_lc
[I_GAME_ERROR_GET_SPAWN
]);
4582 // Íàñòðîéêè èãðîêîâ è áîòîâ:
4586 for i
:= nPl
+1 to nPlayers
do
4587 g_Player_Create(STD_PLAYER_MODEL
, _RGB(0, 0, 0), 0, True);
4590 procedure g_Game_StartServer(Map
: String; GameMode
: Byte;
4591 TimeLimit
, GoalLimit
: Word; MaxLives
: Byte;
4592 Options
: LongWord; nPlayers
: Byte;
4593 IPAddr
: LongWord; Port
: Word);
4596 g_Net_Slist_ServerClosed();
4598 e_WriteLog('Starting net game (server)...', TMsgType
.Notify
);
4600 g_Game_ClearLoading();
4603 gGameSettings
.GameType
:= GT_SERVER
;
4604 gGameSettings
.GameMode
:= GameMode
;
4605 gSwitchGameMode
:= GameMode
;
4606 gGameSettings
.TimeLimit
:= TimeLimit
;
4607 gGameSettings
.GoalLimit
:= GoalLimit
;
4608 gGameSettings
.MaxLives
:= IfThen(GameMode
= GM_CTF
, 0, MaxLives
);
4609 gGameSettings
.Options
:= Options
;
4611 gCoopTotalMonstersKilled
:= 0;
4612 gCoopTotalSecretsFound
:= 0;
4613 gCoopTotalMonsters
:= 0;
4614 gCoopTotalSecrets
:= 0;
4618 gLMSRespawn
:= LMS_RESPAWN_NONE
;
4619 gLMSRespawnTime
:= 0;
4620 gSpectLatchPID1
:= 0;
4621 gSpectLatchPID2
:= 0;
4623 g_Game_ExecuteEvent('ongamestart');
4625 // Óñòàíîâêà ðàçìåðîâ îêíà èãðîêà
4626 g_Game_SetupScreenSize();
4628 // Ðåæèì íàáëþäàòåëÿ:
4629 if nPlayers
= 0 then
4635 if nPlayers
>= 1 then
4637 // Ñîçäàíèå ïåðâîãî èãðîêà:
4638 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4639 gPlayer1Settings
.Color
,
4640 gPlayer1Settings
.Team
, False));
4641 if gPlayer1
= nil then
4643 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
4647 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4650 if nPlayers
>= 2 then
4652 // Ñîçäàíèå âòîðîãî èãðîêà:
4653 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
4654 gPlayer2Settings
.Color
,
4655 gPlayer2Settings
.Team
, False));
4656 if gPlayer2
= nil then
4658 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
4662 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
4665 g_Game_SetLoadingText(_lc
[I_LOAD_HOST
], 0, False);
4666 if NetForwardPorts
then
4667 g_Game_SetLoadingText(_lc
[I_LOAD_PORTS
], 0, False);
4670 if not g_Net_Host(IPAddr
, Port
, NetMaxClients
) then
4672 g_FatalError(_lc
[I_NET_MSG
] + Format(_lc
[I_NET_ERR_HOST
], [Port
]));
4676 g_Net_Slist_Set(NetMasterList
);
4678 g_Net_Slist_ServerStarted();
4680 // Çàãðóçêà è çàïóñê êàðòû:
4681 if not g_Game_StartMap(false{asMegawad}, Map
, True) then
4683 g_Net_Slist_ServerClosed();
4684 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [Map
]));
4688 // Íåò òî÷åê ïîÿâëåíèÿ:
4689 if (g_Map_GetPointCount(RESPAWNPOINT_PLAYER1
) +
4690 g_Map_GetPointCount(RESPAWNPOINT_PLAYER2
) +
4691 g_Map_GetPointCount(RESPAWNPOINT_DM
) +
4692 g_Map_GetPointCount(RESPAWNPOINT_RED
)+
4693 g_Map_GetPointCount(RESPAWNPOINT_BLUE
)) < 1 then
4695 g_Net_Slist_ServerClosed();
4696 g_FatalError(_lc
[I_GAME_ERROR_GET_SPAWN
]);
4700 // Íàñòðîéêè èãðîêîâ è áîòîâ:
4703 g_Net_Slist_ServerMapStarted();
4704 NetState
:= NET_STATE_GAME
;
4707 procedure g_Game_StartClient(Addr
: String; Port
: Word; PW
: String);
4722 e_WriteLog('Starting net game (client)...', TMsgType
.Notify
);
4723 e_WriteLog('NET: Trying to connect to ' + Addr
+ ':' + IntToStr(Port
) + '...', TMsgType
.Notify
);
4725 g_Game_ClearLoading();
4728 gGameSettings
.GameType
:= GT_CLIENT
;
4730 gCoopTotalMonstersKilled
:= 0;
4731 gCoopTotalSecretsFound
:= 0;
4732 gCoopTotalMonsters
:= 0;
4733 gCoopTotalSecrets
:= 0;
4737 g_Game_ExecuteEvent('ongamestart');
4739 // Óñòàíîâêà ðàçìåðîâ îêîí èãðîêîâ:
4740 g_Game_SetupScreenSize();
4742 NetState
:= NET_STATE_AUTH
;
4744 g_Game_SetLoadingText(_lc
[I_LOAD_CONNECT
], 0, False);
4746 // create (or update) map/resource databases
4747 g_Res_CreateDatabases(true);
4749 gLMSRespawn
:= LMS_RESPAWN_NONE
;
4750 gLMSRespawnTime
:= 0;
4751 gSpectLatchPID1
:= 0;
4752 gSpectLatchPID2
:= 0;
4755 if not g_Net_Connect(Addr
, Port
) then
4757 g_FatalError(_lc
[I_NET_MSG
] + _lc
[I_NET_ERR_CONN
]);
4758 NetState
:= NET_STATE_NONE
;
4762 g_Game_SetLoadingText(_lc
[I_LOAD_SEND_INFO
], 0, False);
4764 g_Game_SetLoadingText(_lc
[I_LOAD_WAIT_INFO
], 0, False);
4769 // fuck! https://www.mail-archive.com/enet-discuss@cubik.org/msg00852.html
4770 // tl;dr: on shitdows, we can get -1 sometimes, and it is *NOT* a failure.
4771 // thank you, enet. let's ignore failures altogether then.
4772 while (enet_host_service(NetHost
, @NetEvent
, 50) > 0) do
4774 if (NetEvent
.kind
= ENET_EVENT_TYPE_RECEIVE
) then
4776 if (NetEvent
.channelID
= NET_CHAN_DOWNLOAD_EX
) then
4778 // ignore all download packets, they're processed by separate code
4779 enet_packet_destroy(NetEvent
.packet
);
4782 Ptr
:= NetEvent
.packet
^.data
;
4783 if not InMsg
.Init(Ptr
, NetEvent
.packet
^.dataLength
, True) then
4785 enet_packet_destroy(NetEvent
.packet
);
4789 InMsg
.ReadLongWord(); // skip size
4790 MID
:= InMsg
.ReadByte();
4792 if (MID
= NET_MSG_INFO
) and (State
= 0) then
4794 NetMyID
:= InMsg
.ReadByte();
4795 NetPlrUID1
:= InMsg
.ReadWord();
4797 WadName
:= InMsg
.ReadString();
4798 Map
:= InMsg
.ReadString();
4800 gWADHash
:= InMsg
.ReadMD5();
4802 gGameSettings
.GameMode
:= InMsg
.ReadByte();
4803 gSwitchGameMode
:= gGameSettings
.GameMode
;
4804 gGameSettings
.GoalLimit
:= InMsg
.ReadWord();
4805 gGameSettings
.TimeLimit
:= InMsg
.ReadWord();
4806 gGameSettings
.MaxLives
:= InMsg
.ReadByte();
4807 gGameSettings
.Options
:= InMsg
.ReadLongWord();
4808 T
:= InMsg
.ReadLongWord();
4810 //newResPath := g_Res_SearchSameWAD(MapsDir, WadName, gWADHash);
4811 //if newResPath = '' then
4813 //g_Game_SetLoadingText(_lc[I_LOAD_DL_RES], 0, False);
4814 newResPath
:= g_Res_DownloadMapWAD(ExtractFileName(WadName
), gWADHash
);
4815 if newResPath
= '' then
4817 g_FatalError(_lc
[I_NET_ERR_HASH
]);
4818 enet_packet_destroy(NetEvent
.packet
);
4819 NetState
:= NET_STATE_NONE
;
4822 e_LogWritefln('using downloaded map wad [%s] for [%s]`', [newResPath
, WadName
], TMsgType
.Notify
);
4824 //newResPath := ExtractRelativePath(MapsDir, newResPath);
4827 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4828 gPlayer1Settings
.Color
,
4829 gPlayer1Settings
.Team
, False));
4831 if gPlayer1
= nil then
4833 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
4835 enet_packet_destroy(NetEvent
.packet
);
4836 NetState
:= NET_STATE_NONE
;
4840 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4841 gPlayer1
.UID
:= NetPlrUID1
;
4842 gPlayer1
.Reset(True);
4844 if not g_Game_StartMap(false{asMegawad}, newResPath
+ ':\' + Map
, True) then
4846 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [WadName
+ ':\' + Map
]));
4848 enet_packet_destroy(NetEvent
.packet
);
4849 NetState
:= NET_STATE_NONE
;
4857 enet_packet_destroy(NetEvent
.packet
);
4861 enet_packet_destroy(NetEvent
.packet
);
4865 if (NetEvent
.kind
= ENET_EVENT_TYPE_DISCONNECT
) then
4868 if (NetEvent
.data
<= NET_DISC_MAX
) then
4869 g_Console_Add(_lc
[I_NET_MSG_ERROR
] + _lc
[I_NET_ERR_CONN
] + ' ' +
4870 _lc
[TStrings_Locale(Cardinal(I_NET_DISC_NONE
) + NetEvent
.data
)], True);
4877 ProcessLoading(true);
4879 if g_Net_UserRequestExit() then
4888 g_FatalError(_lc
[I_NET_MSG
] + _lc
[I_NET_ERR_CONN
]);
4889 NetState
:= NET_STATE_NONE
;
4894 NetState
:= NET_STATE_GAME
;
4895 MC_SEND_FullStateRequest
;
4896 e_WriteLog('NET: Connection successful.', TMsgType
.Notify
);
4900 lastAsMegaWad
: Boolean = false;
4902 procedure g_Game_ChangeMap(const MapPath
: String);
4906 g_Game_ClearLoading();
4908 Force
:= gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
];
4909 // Åñëè óðîâåíü çàâåðøèëñÿ ïî òðèããåðó Âûõîä, íå î÷èùàòü èíâåíòàðü
4910 if gExitByTrigger
then
4913 gExitByTrigger
:= False;
4915 if not g_Game_StartMap(lastAsMegaWad
, MapPath
, Force
) then
4916 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [MapPath
]));
4919 procedure g_Game_Restart();
4923 if g_Game_IsClient
then
4925 map
:= g_ExtractFileName(gMapInfo
.Map
);
4926 e_LogWritefln('g_Game_Restart: map = "%s" gCurrentMapFileName = "%s"', [map
, gCurrentMapFileName
]);
4930 g_Game_ClearLoading();
4931 g_Game_StartMap(lastAsMegaWad
, Map
, True, gCurrentMapFileName
);
4934 function g_Game_StartMap (asMegawad
: Boolean; Map
: String; Force
: Boolean = False; const oldMapPath
: AnsiString=''): Boolean;
4936 NewWAD
, ResName
: String;
4940 g_Map_Free((Map
<> gCurrentMapFileName
) and (oldMapPath
<> gCurrentMapFileName
));
4941 g_Player_RemoveAllCorpses();
4943 if (not g_Game_IsClient
) and
4944 (gSwitchGameMode
<> gGameSettings
.GameMode
) and
4945 (gGameSettings
.GameMode
<> GM_SINGLE
) then
4947 if gSwitchGameMode
= GM_CTF
then
4948 gGameSettings
.MaxLives
:= 0;
4949 gGameSettings
.GameMode
:= gSwitchGameMode
;
4952 gSwitchGameMode
:= gGameSettings
.GameMode
;
4954 g_Player_ResetTeams();
4956 lastAsMegaWad
:= asMegawad
;
4957 if isWadPath(Map
) then
4959 NewWAD
:= g_ExtractWadName(Map
);
4960 ResName
:= g_ExtractFileName(Map
);
4961 if g_Game_IsServer
then
4963 nws
:= findDiskWad(NewWAD
);
4964 //writeln('000: Map=[', Map, ']; nws=[', nws, ']; NewWAD=[', NewWAD, ']');
4967 if (length(nws
) = 0) then nws
:= e_FindWad(MegawadDirs
, NewWAD
);
4968 if (length(nws
) = 0) then nws
:= e_FindWad(MapDirs
, NewWAD
);
4972 if (length(nws
) = 0) then nws
:= e_FindWad(MapDirs
, NewWAD
);
4973 if (length(nws
) = 0) then nws
:= e_FindWad(MegawadDirs
, NewWAD
);
4975 //if (length(nws) = 0) then nws := e_FindWad(MapDownloadDirs, NewWAD);
4976 //writeln('001: Map=[', Map, ']; nws=[', nws, ']; NewWAD=[', NewWAD, ']');
4978 if (length(nws
) = 0) then
4980 ResName
:= ''; // failed
4985 if (g_Game_IsNet
) then gWADHash
:= MD5File(nws
);
4986 //writeln('********: nws=', nws, ' : Map=', Map, ' : nw=', NewWAD, ' : resname=', ResName);
4987 g_Game_LoadWAD(NewWAD
);
4992 // hash received in MC_RECV_GameEvent -> NET_EV_MAPSTART
4993 NewWAD
:= g_Game_ClientWAD(NewWAD
, gWADHash
);
4998 NewWAD
:= gGameSettings
.WAD
;
5004 //writeln('********: gsw=', gGameSettings.WAD, '; rn=', ResName);
5006 if (ResName
<> '') and (NewWAD
<> '') then
5008 //result := g_Map_Load(gGameSettings.WAD + ':\' + ResName);
5009 result
:= g_Map_Load(NewWAD
+':\'+ResName
);
5013 g_Player_ResetAll(Force
or gLastMap
, gGameSettings
.GameType
= GT_SINGLE
);
5015 gState
:= STATE_NONE
;
5016 g_ActiveWindow
:= nil;
5022 if gGameSettings
.GameMode
= GM_CTF
then
5024 g_Map_ResetFlag(FLAG_RED
);
5025 g_Map_ResetFlag(FLAG_BLUE
);
5026 // CTF, à ôëàãîâ íåò:
5027 if not g_Map_HaveFlagPoints() then
5028 g_SimpleError(_lc
[I_GAME_ERROR_CTF
]);
5033 gState
:= STATE_MENU
;
5038 gPauseMain
:= false;
5039 gPauseHolmes
:= false;
5040 NetTimeToUpdate
:= 1;
5041 NetTimeToReliable
:= 0;
5042 NetTimeToMaster
:= NetMasterRate
;
5043 gSpectLatchPID1
:= 0;
5044 gSpectLatchPID2
:= 0;
5045 gMissionFailed
:= False;
5048 gCoopMonstersKilled
:= 0;
5049 gCoopSecretsFound
:= 0;
5051 gVoteInProgress
:= False;
5052 gVotePassed
:= False;
5058 if not gGameOn
then Exit
;
5060 g_Game_SpectateCenterView();
5062 if g_Game_IsServer
then
5064 if (gGameSettings
.MaxLives
> 0) and (gGameSettings
.WarmupTime
> 0) then
5066 gLMSRespawn
:= LMS_RESPAWN_WARMUP
;
5067 gLMSRespawnTime
:= gTime
+ gGameSettings
.WarmupTime
*1000;
5068 gLMSSoftSpawn
:= True;
5069 if g_Game_IsNet
then
5070 MH_SEND_GameEvent(NET_EV_LMS_WARMUP
, gLMSRespawnTime
- gTime
);
5074 gLMSRespawn
:= LMS_RESPAWN_NONE
;
5075 gLMSRespawnTime
:= 0;
5079 if NetMode
= NET_SERVER
then
5081 MH_SEND_GameEvent(NET_EV_MAPSTART
, gGameSettings
.GameMode
, Map
);
5084 g_Net_Slist_ServerMapStarted();
5086 if NetClients
<> nil then
5087 for I
:= 0 to High(NetClients
) do
5088 if NetClients
[I
].Used
then
5090 NetClients
[I
].Voted
:= False;
5091 if NetClients
[I
].RequestedFullUpdate
then
5093 MH_SEND_Everything((NetClients
[I
].State
= NET_STATE_AUTH
), I
);
5094 NetClients
[I
].RequestedFullUpdate
:= False;
5098 g_Net_UnbanNonPermHosts();
5103 gCoopTotalMonstersKilled
:= 0;
5104 gCoopTotalSecretsFound
:= 0;
5105 gCoopTotalMonsters
:= 0;
5106 gCoopTotalSecrets
:= 0;
5110 g_Game_ExecuteEvent('onmapstart');
5113 procedure SetFirstLevel
;
5117 MapList
:= g_Map_GetMapsList(gGameSettings
.WAD
);
5118 if MapList
= nil then
5121 SortSArray(MapList
);
5122 gNextMap
:= MapList
[Low(MapList
)];
5127 procedure g_Game_ExitLevel(const Map
: AnsiString);
5131 gCoopTotalMonstersKilled
:= gCoopTotalMonstersKilled
+ gCoopMonstersKilled
;
5132 gCoopTotalSecretsFound
:= gCoopTotalSecretsFound
+ gCoopSecretsFound
;
5133 gCoopTotalMonsters
:= gCoopTotalMonsters
+ gTotalMonsters
;
5134 gCoopTotalSecrets
:= gCoopTotalSecrets
+ gSecretsCount
;
5136 // Âûøëè â âûõîä â Îäèíî÷íîé èãðå:
5137 if gGameSettings
.GameType
= GT_SINGLE
then
5138 gExit
:= EXIT_ENDLEVELSINGLE
5139 else // Âûøëè â âûõîä â Ñâîåé èãðå
5141 gExit
:= EXIT_ENDLEVELCUSTOM
;
5142 if gGameSettings
.GameMode
= GM_COOP
then
5143 g_Player_RememberAll
;
5145 if not g_Map_Exist(gGameSettings
.WAD
+ ':\' + gNextMap
) then
5148 if gGameSettings
.GameMode
= GM_COOP
then
5151 gStatsPressed
:= True;
5152 gNextMap
:= 'MAP01';
5154 if not g_Map_Exist(gGameSettings
.WAD
+ ':\' + gNextMap
) then
5157 if g_Game_IsNet
then
5159 MH_SEND_GameStats();
5160 MH_SEND_CoopStats();
5166 procedure g_Game_RestartLevel();
5170 if gGameSettings
.GameMode
= GM_SINGLE
then
5175 gExit
:= EXIT_ENDLEVELCUSTOM
;
5176 Map
:= g_ExtractFileName(gMapInfo
.Map
);
5180 function g_Game_ClientWAD (NewWAD
: String; const WHash
: TMD5Digest
): AnsiString;
5182 gWAD
{, xwad}: String;
5185 if not g_Game_IsClient
then Exit
;
5186 //e_LogWritefln('*** g_Game_ClientWAD: `%s`', [NewWAD]);
5188 gWAD
:= g_Res_DownloadMapWAD(ExtractFileName(NewWAD
), WHash
);
5193 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_WAD
], [ExtractFileName(NewWAD
)]));
5197 e_LogWritefln('using downloaded client map wad [%s] for [%s]', [gWAD
, NewWAD
], TMsgType
.Notify
);
5200 g_Game_LoadWAD(NewWAD
);
5204 if LowerCase(NewWAD) = LowerCase(gGameSettings.WAD) then Exit;
5205 gWAD := g_Res_SearchSameWAD(MapsDir, ExtractFileName(NewWAD), WHash);
5208 g_Game_SetLoadingText(_lc[I_LOAD_DL_RES], 0, False);
5209 gWAD := g_Res_DownloadMapWAD(ExtractFileName(NewWAD), WHash);
5213 g_FatalError(Format(_lc[I_GAME_ERROR_MAP_WAD], [ExtractFileName(NewWAD)]));
5217 NewWAD := ExtractRelativePath(MapsDir, gWAD);
5218 g_Game_LoadWAD(NewWAD);
5222 procedure g_Game_RestartRound(NoMapRestart
: Boolean = False);
5224 i
, n
, nb
, nr
: Integer;
5226 if not g_Game_IsServer
then Exit
;
5227 if gLMSRespawn
= LMS_RESPAWN_NONE
then Exit
;
5228 gLMSRespawn
:= LMS_RESPAWN_NONE
;
5229 gLMSRespawnTime
:= 0;
5232 if (gGameSettings
.GameMode
= GM_COOP
) and not NoMapRestart
then
5234 gMissionFailed
:= True;
5235 g_Game_RestartLevel
;
5239 n
:= 0; nb
:= 0; nr
:= 0;
5240 for i
:= Low(gPlayers
) to High(gPlayers
) do
5241 if (gPlayers
[i
] <> nil) and
5242 ((not gPlayers
[i
].FSpectator
) or gPlayers
[i
].FWantsInGame
or
5243 (gPlayers
[i
] is TBot
)) then
5246 if gPlayers
[i
].Team
= TEAM_RED
then Inc(nr
)
5247 else if gPlayers
[i
].Team
= TEAM_BLUE
then Inc(nb
)
5250 if (n
< 1) or ((gGameSettings
.GameMode
= GM_TDM
) and ((nr
= 0) or (nb
= 0))) then
5252 // wait a second until the fuckers finally decide to join
5253 gLMSRespawn
:= LMS_RESPAWN_WARMUP
;
5254 gLMSRespawnTime
:= gTime
+ gGameSettings
.WarmupTime
*1000;
5255 gLMSSoftSpawn
:= NoMapRestart
;
5256 if g_Game_IsNet
then
5257 MH_SEND_GameEvent(NET_EV_LMS_WARMUP
, gLMSRespawnTime
- gTime
);
5261 g_Player_RemoveAllCorpses
;
5262 g_Game_Message(_lc
[I_MESSAGE_LMS_START
], 144);
5263 if g_Game_IsNet
then
5264 MH_SEND_GameEvent(NET_EV_LMS_START
);
5266 for i
:= Low(gPlayers
) to High(gPlayers
) do
5268 if gPlayers
[i
] = nil then continue
;
5269 if gPlayers
[i
] is TBot
then gPlayers
[i
].FWantsInGame
:= True;
5270 // don't touch normal spectators
5271 if gPlayers
[i
].FSpectator
and not gPlayers
[i
].FWantsInGame
then
5273 gPlayers
[i
].FNoRespawn
:= True;
5274 gPlayers
[i
].Lives
:= 0;
5275 if g_Game_IsNet
then
5276 MH_SEND_PlayerStats(gPlayers
[I
].UID
);
5279 gPlayers
[i
].FNoRespawn
:= False;
5280 gPlayers
[i
].Lives
:= gGameSettings
.MaxLives
;
5281 gPlayers
[i
].Respawn(False, True);
5282 if gGameSettings
.GameMode
= GM_COOP
then
5284 gPlayers
[i
].Frags
:= 0;
5285 gPlayers
[i
].RecallState
;
5287 if (gPlayer1
= nil) and (gSpectLatchPID1
> 0) then
5288 gPlayer1
:= g_Player_Get(gSpectLatchPID1
);
5289 if (gPlayer2
= nil) and (gSpectLatchPID2
> 0) then
5290 gPlayer2
:= g_Player_Get(gSpectLatchPID2
);
5293 g_Items_RestartRound();
5295 gLMSSoftSpawn
:= False;
5298 function g_Game_GetFirstMap(WAD
: String): String;
5302 MapList
:= g_Map_GetMapsList(WAD
);
5303 if MapList
= nil then
5306 SortSArray(MapList
);
5307 Result
:= MapList
[Low(MapList
)];
5309 if not g_Map_Exist(WAD
+ ':\' + Result
) then
5315 function g_Game_GetNextMap(): String;
5322 MapList
:= g_Map_GetMapsList(gGameSettings
.WAD
);
5323 if MapList
= nil then
5326 Map
:= g_ExtractFileName(gMapInfo
.Map
);
5328 SortSArray(MapList
);
5330 for I
:= Low(MapList
) to High(MapList
) do
5331 if Map
= MapList
[I
] then
5337 if MapIndex
<> -255 then
5339 if MapIndex
= High(MapList
) then
5340 Result
:= MapList
[Low(MapList
)]
5342 Result
:= MapList
[MapIndex
+ 1];
5344 if not g_Map_Exist(gGameSettings
.WAD
+ ':\' + Result
) then Result
:= Map
;
5350 procedure g_Game_NextLevel();
5352 if gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
, GM_COOP
] then
5353 gExit
:= EXIT_ENDLEVELCUSTOM
5356 gExit
:= EXIT_ENDLEVELSINGLE
;
5360 if gNextMap
<> '' then Exit
;
5361 gNextMap
:= g_Game_GetNextMap();
5364 function g_Game_IsTestMap(): Boolean;
5366 result
:= StrEquCI1251(TEST_MAP_NAME
, g_ExtractFileName(gMapInfo
.Map
));
5369 procedure g_Game_DeleteTestMap();
5372 //MapName: AnsiString;
5380 a
:= Pos('.wad:\', toLowerCase1251(gMapToDelete
));
5381 if (a
= 0) then a
:= Pos('.wad:/', toLowerCase1251(gMapToDelete
));
5382 if (a
= 0) then exit
;
5384 // Âûäåëÿåì èìÿ wad-ôàéëà è èìÿ êàðòû
5385 WadName
:= Copy(gMapToDelete
, 1, a
+3);
5386 Delete(gMapToDelete
, 1, a
+5);
5387 gMapToDelete
:= UpperCase(gMapToDelete
);
5389 //CopyMemory(@MapName[0], @gMapToDelete[1], Min(16, Length(gMapToDelete)));
5392 // Èìÿ êàðòû íå ñòàíäàðòíîå òåñòîâîå:
5393 if MapName <> TEST_MAP_NAME then
5396 if not gTempDelete then
5398 time := g_GetFileTime(WadName);
5399 WAD := TWADFile.Create();
5402 if not WAD.ReadFile(WadName) then
5403 begin // Íåò òàêîãî WAD-ôàéëà
5408 // Ñîñòàâëÿåì ñïèñîê êàðò è èùåì íóæíóþ:
5410 MapList := WAD.GetResourcesList('');
5412 if MapList <> nil then
5413 for a := 0 to High(MapList) do
5414 if MapList[a] = MapName then
5416 // Óäàëÿåì è ñîõðàíÿåì:
5417 WAD.RemoveResource('', MapName);
5418 WAD.SaveTo(WadName);
5423 g_SetFileTime(WadName, time);
5426 if gTempDelete
then DeleteFile(WadName
);
5429 procedure GameCVars(P
: SSArray
);
5432 stat
: TPlayerStatArray
;
5435 procedure ParseGameFlag(Flag
: LongWord; OffMsg
, OnMsg
: TStrings_Locale
; OnMapChange
: Boolean = False);
5439 if Length(P
) > 1 then
5444 gsGameFlags
:= gsGameFlags
or Flag
5446 gsGameFlags
:= gsGameFlags
and (not Flag
);
5448 if g_Game_IsServer
then
5451 gGameSettings
.Options
:= gGameSettings
.Options
or Flag
5453 gGameSettings
.Options
:= gGameSettings
.Options
and (not Flag
);
5454 if g_Game_IsNet
then MH_SEND_GameSettings
;
5458 if LongBool(gsGameFlags
and Flag
) then
5459 g_Console_Add(_lc
[OnMsg
])
5461 g_Console_Add(_lc
[OffMsg
]);
5463 if OnMapChange
and g_Game_IsServer
then
5464 g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
5469 cmd
:= LowerCase(P
[0]);
5471 if cmd
= 'g_gamemode' then
5473 if (Length(P
) > 1) then
5475 a
:= g_Game_TextToMode(P
[1]);
5476 if a
= GM_SINGLE
then a
:= GM_COOP
;
5477 gsGameMode
:= g_Game_ModeToText(a
);
5478 if g_Game_IsServer
then
5480 gSwitchGameMode
:= a
;
5481 if (gGameOn
and (gGameSettings
.GameMode
= GM_SINGLE
)) or
5482 (gState
= STATE_INTERSINGLE
) then
5483 gSwitchGameMode
:= GM_SINGLE
;
5485 gGameSettings
.GameMode
:= gSwitchGameMode
;
5489 if gSwitchGameMode
= gGameSettings
.GameMode
then
5490 g_Console_Add(Format(_lc
[I_MSG_GAMEMODE_CURRENT
],
5491 [g_Game_ModeToText(gGameSettings
.GameMode
)]))
5493 g_Console_Add(Format(_lc
[I_MSG_GAMEMODE_CHANGE
],
5494 [g_Game_ModeToText(gGameSettings
.GameMode
),
5495 g_Game_ModeToText(gSwitchGameMode
)]));
5497 else if cmd
= 'g_friendlyfire' then
5499 ParseGameFlag(GAME_OPTION_TEAMDAMAGE
, I_MSG_FRIENDLY_FIRE_OFF
, I_MSG_FRIENDLY_FIRE_ON
);
5501 else if cmd
= 'g_weaponstay' then
5503 ParseGameFlag(GAME_OPTION_WEAPONSTAY
, I_MSG_WEAPONSTAY_OFF
, I_MSG_WEAPONSTAY_ON
);
5505 else if cmd
= 'g_allow_exit' then
5507 ParseGameFlag(GAME_OPTION_ALLOWEXIT
, I_MSG_ALLOWEXIT_OFF
, I_MSG_ALLOWEXIT_ON
, True);
5509 else if cmd
= 'g_allow_monsters' then
5511 ParseGameFlag(GAME_OPTION_MONSTERS
, I_MSG_ALLOWMON_OFF
, I_MSG_ALLOWMON_ON
, True);
5513 else if cmd
= 'g_bot_vsplayers' then
5515 ParseGameFlag(GAME_OPTION_BOTVSPLAYER
, I_MSG_BOTSVSPLAYERS_OFF
, I_MSG_BOTSVSPLAYERS_ON
);
5517 else if cmd
= 'g_bot_vsmonsters' then
5519 ParseGameFlag(GAME_OPTION_BOTVSMONSTER
, I_MSG_BOTSVSMONSTERS_OFF
, I_MSG_BOTSVSMONSTERS_ON
);
5521 else if cmd
= 'g_dm_keys' then
5523 ParseGameFlag(GAME_OPTION_DMKEYS
, I_MSG_DMKEYS_OFF
, I_MSG_DMKEYS_ON
, True);
5525 else if cmd
= 'g_gameflags' then
5527 if Length(P
) > 1 then
5529 gsGameFlags
:= StrToDWordDef(P
[1], gsGameFlags
);
5530 if g_Game_IsServer
then
5532 gGameSettings
.Options
:= gsGameFlags
;
5533 if g_Game_IsNet
then MH_SEND_GameSettings
;
5537 g_Console_Add(Format('%s %u', [cmd
, gsGameFlags
]));
5539 else if cmd
= 'g_warmup_time' then
5541 if Length(P
) > 1 then
5543 gsWarmupTime
:= nclamp(StrToIntDef(P
[1], gsWarmupTime
), 0, $FFFF);
5544 if g_Game_IsServer
then
5546 gGameSettings
.WarmupTime
:= gsWarmupTime
;
5547 // extend warmup if it's already going
5548 if gLMSRespawn
= LMS_RESPAWN_WARMUP
then
5550 gLMSRespawnTime
:= gTime
+ gsWarmupTime
* 1000;
5551 if g_Game_IsNet
then MH_SEND_GameEvent(NET_EV_LMS_WARMUP
, gLMSRespawnTime
- gTime
);
5553 if g_Game_IsNet
then MH_SEND_GameSettings
;
5557 g_Console_Add(Format(_lc
[I_MSG_WARMUP
], [Integer(gsWarmupTime
)]));
5558 if g_Game_IsServer
then g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
5560 else if cmd
= 'g_spawn_invul' then
5562 if Length(P
) > 1 then
5564 gsSpawnInvul
:= nclamp(StrToIntDef(P
[1], gsSpawnInvul
), 0, $FFFF);
5565 if g_Game_IsServer
then
5567 gGameSettings
.SpawnInvul
:= gsSpawnInvul
;
5568 if g_Game_IsNet
then MH_SEND_GameSettings
;
5572 g_Console_Add(Format('%s %d', [cmd
, Integer(gsSpawnInvul
)]));
5574 else if cmd
= 'g_item_respawn_time' then
5576 if Length(P
) > 1 then
5578 gsItemRespawnTime
:= nclamp(StrToIntDef(P
[1], gsItemRespawnTime
), 0, $FFFF);
5579 if g_Game_IsServer
then
5581 gGameSettings
.ItemRespawnTime
:= gsItemRespawnTime
;
5582 if g_Game_IsNet
then MH_SEND_GameSettings
;
5586 g_Console_Add(Format('%s %d', [cmd
, Integer(gsItemRespawnTime
)]));
5587 if g_Game_IsServer
then g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
5589 else if cmd
= 'sv_intertime' then
5591 if (Length(P
) > 1) then
5592 gDefInterTime
:= Min(Max(StrToIntDef(P
[1], gDefInterTime
), -1), 120);
5594 g_Console_Add(cmd
+ ' = ' + IntToStr(gDefInterTime
));
5596 else if cmd
= 'g_max_particles' then
5598 if Length(p
) = 2 then
5600 a
:= Max(0, StrToInt(p
[1]));
5603 else if Length(p
) = 1 then
5605 e_LogWritefln('%s', [g_GFX_GetMax()])
5609 e_LogWritefln('usage: %s <n>', [cmd
])
5612 else if cmd
= 'g_max_shells' then
5614 if Length(p
) = 2 then
5616 a
:= Max(0, StrToInt(p
[1]));
5619 else if Length(p
) = 1 then
5621 e_LogWritefln('%s', [g_Shells_GetMax()])
5625 e_LogWritefln('usage: %s <n>', [cmd
])
5628 else if cmd
= 'g_max_gibs' then
5630 if Length(p
) = 2 then
5632 a
:= Max(0, StrToInt(p
[1]));
5635 else if Length(p
) = 1 then
5637 e_LogWritefln('%s', [g_Gibs_GetMax()])
5641 e_LogWritefln('usage: %s <n>', [cmd
])
5644 else if cmd
= 'g_max_corpses' then
5646 if Length(p
) = 2 then
5648 a
:= Max(0, StrToInt(p
[1]));
5651 else if Length(p
) = 1 then
5653 e_LogWritefln('%s', [g_Corpses_GetMax()])
5657 e_LogWritefln('usage: %s <n>', [cmd
])
5660 else if cmd
= 'g_scorelimit' then
5662 if Length(P
) > 1 then
5664 gsGoalLimit
:= nclamp(StrToIntDef(P
[1], gsGoalLimit
), 0, $FFFF);
5666 if g_Game_IsServer
then
5669 if gGameSettings
.GameMode
= GM_DM
then
5671 stat
:= g_Player_GetStats();
5673 for a
:= 0 to High(stat
) do
5674 if stat
[a
].Frags
> b
then
5678 b
:= Max(gTeamStat
[TEAM_RED
].Goals
, gTeamStat
[TEAM_BLUE
].Goals
);
5680 // if someone has a higher score, set it to that instead
5681 gsGoalLimit
:= max(gsGoalLimit
, b
);
5682 gGameSettings
.GoalLimit
:= gsGoalLimit
;
5684 if g_Game_IsNet
then MH_SEND_GameSettings
;
5688 g_Console_Add(Format(_lc
[I_MSG_SCORE_LIMIT
], [Integer(gsGoalLimit
)]));
5690 else if cmd
= 'g_timelimit' then
5692 if Length(P
) > 1 then
5694 gsTimeLimit
:= nclamp(StrToIntDef(P
[1], gsTimeLimit
), 0, $FFFF);
5695 if g_Game_IsServer
then
5697 gGameSettings
.TimeLimit
:= gsTimeLimit
;
5698 if g_Game_IsNet
then MH_SEND_GameSettings
;
5701 g_Console_Add(Format(_lc
[I_MSG_TIME_LIMIT
],
5702 [gsTimeLimit
div 3600,
5703 (gsTimeLimit
div 60) mod 60,
5704 gsTimeLimit
mod 60]));
5706 else if cmd
= 'g_maxlives' then
5708 if Length(P
) > 1 then
5710 gsMaxLives
:= nclamp(StrToIntDef(P
[1], gsMaxLives
), 0, $FFFF);
5711 if g_Game_IsServer
then
5713 gGameSettings
.MaxLives
:= gsMaxLives
;
5714 if g_Game_IsNet
then MH_SEND_GameSettings
;
5718 g_Console_Add(Format(_lc
[I_MSG_LIVES
], [Integer(gsMaxLives
)]));
5722 procedure PlayerSettingsCVars(P
: SSArray
);
5726 cmd
:= LowerCase(P
[0]);
5730 if (Length(P
) > 1) then
5732 gPlayer1Settings
.Name
:= b_Text_Unformat(P
[1]);
5733 if g_Game_IsClient
then
5734 MC_SEND_PlayerSettings
5735 else if gGameOn
and (gPlayer1
<> nil) then
5737 gPlayer1
.Name
:= b_Text_Unformat(P
[1]);
5738 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer1
.UID
);
5744 if (Length(P
) > 1) then
5746 gPlayer2Settings
.Name
:= b_Text_Unformat(P
[1]);
5747 if g_Game_IsClient
then
5748 MC_SEND_PlayerSettings
5749 else if gGameOn
and (gPlayer2
<> nil) then
5751 gPlayer2
.Name
:= b_Text_Unformat(P
[1]);
5752 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer2
.UID
);
5758 if Length(P
) > 3 then
5760 gPlayer1Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
5761 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
5762 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
5763 if g_Game_IsClient
then
5764 MC_SEND_PlayerSettings
5765 else if gGameOn
and (gPlayer1
<> nil) then
5767 gPlayer1
.SetColor(gPlayer1Settings
.Color
);
5768 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer1
.UID
);
5774 if Length(P
) > 3 then
5776 gPlayer2Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
5777 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
5778 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
5779 if g_Game_IsClient
then
5780 MC_SEND_PlayerSettings
5781 else if gGameOn
and (gPlayer2
<> nil) then
5783 gPlayer2
.SetColor(gPlayer2Settings
.Color
);
5784 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer2
.UID
);
5790 if (Length(P
) > 1) then
5792 gPlayer1Settings
.Model
:= P
[1];
5793 if g_Game_IsClient
then
5794 MC_SEND_PlayerSettings
5795 else if gGameOn
and (gPlayer1
<> nil) then
5797 gPlayer1
.FActualModelName
:= gPlayer1Settings
.Model
;
5798 gPlayer1
.SetModel(gPlayer1Settings
.Model
);
5799 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer1
.UID
);
5805 if (Length(P
) > 1) then
5807 gPlayer2Settings
.Model
:= P
[1];
5808 if g_Game_IsClient
then
5809 MC_SEND_PlayerSettings
5810 else if gGameOn
and (gPlayer2
<> nil) then
5812 gPlayer2
.FActualModelName
:= gPlayer2Settings
.Model
;
5813 gPlayer2
.SetModel(gPlayer2Settings
.Model
);
5814 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer2
.UID
);
5821 procedure PrintHeapStats();
5825 hs
:= GetFPCHeapStatus();
5826 e_LogWriteLn ('v===== heap status =====v');
5827 e_LogWriteFln('max heap size = %d k', [hs
.MaxHeapSize
div 1024]);
5828 e_LogWriteFln('max heap used = %d k', [hs
.MaxHeapUsed
div 1024]);
5829 e_LogWriteFln('cur heap size = %d k', [hs
.CurrHeapSize
div 1024]);
5830 e_LogWriteFln('cur heap used = %d k', [hs
.CurrHeapUsed
div 1024]);
5831 e_LogWriteFln('cur heap free = %d k', [hs
.CurrHeapFree
div 1024]);
5832 e_LogWriteLn ('^=======================^');
5835 procedure DebugCommands(P
: SSArray
);
5842 // Êîìàíäû îòëàäî÷íîãî ðåæèìà:
5843 if {gDebugMode}conIsCheatsEnabled
then
5845 cmd
:= LowerCase(P
[0]);
5846 if cmd
= 'd_window' then
5848 g_Console_Add(Format('gScreenWidth = %d, gScreenHeight = %d', [gScreenWidth
, gScreenHeight
]));
5849 g_Console_Add(Format('gScreenWidth = %d, gScreenHeight = %d', [gScreenWidth
, gScreenHeight
]));
5851 else if cmd
= 'd_sounds' then
5853 if (Length(P
) > 1) and
5854 ((P
[1] = '1') or (P
[1] = '0')) then
5855 g_Debug_Sounds
:= (P
[1][1] = '1');
5857 g_Console_Add(Format('d_sounds is %d', [Byte(g_Debug_Sounds
)]));
5859 else if cmd
= 'd_frames' then
5861 if (Length(P
) > 1) and
5862 ((P
[1] = '1') or (P
[1] = '0')) then
5863 g_Debug_Frames
:= (P
[1][1] = '1');
5865 g_Console_Add(Format('d_frames is %d', [Byte(g_Debug_Frames
)]));
5867 else if cmd
= 'd_winmsg' then
5869 if (Length(P
) > 1) and
5870 ((P
[1] = '1') or (P
[1] = '0')) then
5871 g_Debug_WinMsgs
:= (P
[1][1] = '1');
5873 g_Console_Add(Format('d_winmsg is %d', [Byte(g_Debug_WinMsgs
)]));
5875 else if (cmd
= 'd_monoff') and not g_Game_IsNet
then
5877 if (Length(P
) > 1) and
5878 ((P
[1] = '1') or (P
[1] = '0')) then
5879 g_Debug_MonsterOff
:= (P
[1][1] = '1');
5881 g_Console_Add(Format('d_monoff is %d', [Byte(g_debug_MonsterOff
)]));
5883 else if (cmd
= 'd_botoff') and not g_Game_IsNet
then
5885 if Length(P
) > 1 then
5887 '0': g_debug_BotAIOff
:= 0;
5888 '1': g_debug_BotAIOff
:= 1;
5889 '2': g_debug_BotAIOff
:= 2;
5890 '3': g_debug_BotAIOff
:= 3;
5893 g_Console_Add(Format('d_botoff is %d', [g_debug_BotAIOff
]));
5895 else if cmd
= 'd_monster' then
5897 if gGameOn
and (gPlayer1
<> nil) and (gPlayer1
.alive
) and (not g_Game_IsNet
) then
5898 if Length(P
) < 2 then
5900 g_Console_Add(cmd
+ ' [ID | Name] [behaviour]');
5901 g_Console_Add('ID | Name');
5902 for b
:= MONSTER_DEMON
to MONSTER_MAN
do
5903 g_Console_Add(Format('%2d | %s', [b
, g_Mons_NameByTypeId(b
)]));
5904 conwriteln('behav. num'#10'normal 0'#10'killer 1'#10'maniac 2'#10'insane 3'#10'cannibal 4'#10'good 5');
5907 a
:= StrToIntDef(P
[1], 0);
5908 if (a
< MONSTER_DEMON
) or (a
> MONSTER_MAN
) then
5909 a
:= g_Mons_TypeIdByName(P
[1]);
5911 if (a
< MONSTER_DEMON
) or (a
> MONSTER_MAN
) then
5912 g_Console_Add(Format(_lc
[I_MSG_NO_MONSTER
], [P
[1]]))
5915 with gPlayer1
.Obj
do
5917 mon
:= g_Monsters_Create(a
,
5918 X
+ Rect
.X
+ (Rect
.Width
div 2),
5919 Y
+ Rect
.Y
+ Rect
.Height
,
5920 gPlayer1
.Direction
, True);
5922 if (Length(P
) > 2) and (mon
<> nil) then
5924 if (CompareText(P
[2], 'normal') = 0) then mon
.MonsterBehaviour
:= BH_NORMAL
5925 else if (CompareText(P
[2], 'killer') = 0) then mon
.MonsterBehaviour
:= BH_KILLER
5926 else if (CompareText(P
[2], 'maniac') = 0) then mon
.MonsterBehaviour
:= BH_MANIAC
5927 else if (CompareText(P
[2], 'insane') = 0) then mon
.MonsterBehaviour
:= BH_INSANE
5928 else if (CompareText(P
[2], 'cannibal') = 0) then mon
.MonsterBehaviour
:= BH_CANNIBAL
5929 else if (CompareText(P
[2], 'good') = 0) then mon
.MonsterBehaviour
:= BH_GOOD
5930 else if (CompareText(P
[2], 'friend') = 0) then mon
.MonsterBehaviour
:= BH_GOOD
5931 else if (CompareText(P
[2], 'friendly') = 0) then mon
.MonsterBehaviour
:= BH_GOOD
5932 else mon
.MonsterBehaviour
:= Min(Max(StrToIntDef(P
[2], BH_NORMAL
), BH_NORMAL
), BH_GOOD
);
5937 else if (cmd
= 'd_health') then
5939 if (Length(P
) > 1) and
5940 ((P
[1] = '1') or (P
[1] = '0')) then
5941 g_debug_HealthBar
:= (P
[1][1] = '1');
5943 g_Console_Add(Format('d_health is %d', [Byte(g_debug_HealthBar
)]));
5945 else if (cmd
= 'd_player') then
5947 if (Length(P
) > 1) and
5948 ((P
[1] = '1') or (P
[1] = '0')) then
5949 g_debug_Player
:= (P
[1][1] = '1');
5951 g_Console_Add(Format(cmd
+ ' is %d', [Byte(g_Debug_Player
)]));
5953 else if (cmd
= 'd_mem') then
5959 g_Console_Add(_lc
[I_MSG_NOT_DEBUG
]);
5963 procedure GameCheats(P
: SSArray
);
5969 if (not gGameOn
) or (not conIsCheatsEnabled
) then
5971 g_Console_Add('not available');
5977 g_Console_Add('where is the player?!');
5980 cmd
:= LowerCase(P
[0]);
5984 plr
.GodMode
:= not plr
.GodMode
;
5985 if plr
.GodMode
then g_Console_Add('player is godlike now') else g_Console_Add('player is mortal now');
5988 // give <health|exit|weapons|air|suit|jetpack|berserk|all>
5989 if cmd
= 'give' then
5991 if length(P
) < 2 then begin g_Console_Add('give what?!'); exit
; end;
5992 for f
:= 1 to High(P
) do
5994 cmd
:= LowerCase(P
[f
]);
5995 if cmd
= 'health' then begin plr
.RestoreHealthArmor(); g_Console_Add('player feels himself better'); continue
; end;
5996 if (cmd
= 'all') {or (cmd = 'weapons')} then begin plr
.AllRulez(False); g_Console_Add('player got the gifts'); continue
; end;
5997 if cmd
= 'exit' then
5999 if gTriggers
<> nil then
6001 for a
:= 0 to High(gTriggers
) do
6003 if gTriggers
[a
].TriggerType
= TRIGGER_EXIT
then
6005 g_Console_Add('player left the map');
6006 gExitByTrigger
:= True;
6007 //g_Game_ExitLevel(gTriggers[a].Data.MapName);
6008 g_Game_ExitLevel(gTriggers
[a
].tgcMap
);
6016 if cmd
= 'air' then begin plr
.GiveItem(ITEM_OXYGEN
); g_Console_Add('player got some air'); continue
; end;
6017 if cmd
= 'jetpack' then begin plr
.GiveItem(ITEM_JETPACK
); g_Console_Add('player got a jetpack'); continue
; end;
6018 if cmd
= 'suit' then begin plr
.GiveItem(ITEM_SUIT
); g_Console_Add('player got an envirosuit'); continue
; end;
6019 if cmd
= 'berserk' then begin plr
.GiveItem(ITEM_MEDKIT_BLACK
); g_Console_Add('player got a berserk pack'); continue
; end;
6020 if cmd
= 'backpack' then begin plr
.GiveItem(ITEM_AMMO_BACKPACK
); g_Console_Add('player got a backpack'); continue
; end;
6022 if cmd
= 'helmet' then begin plr
.GiveItem(ITEM_HELMET
); g_Console_Add('player got a helmet'); continue
; end;
6023 if cmd
= 'bottle' then begin plr
.GiveItem(ITEM_BOTTLE
); g_Console_Add('player got a bottle of health'); continue
; end;
6025 if cmd
= 'stimpack' then begin plr
.GiveItem(ITEM_MEDKIT_SMALL
); g_Console_Add('player got a stimpack'); continue
; end;
6026 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;
6028 if cmd
= 'greenarmor' then begin plr
.GiveItem(ITEM_ARMOR_GREEN
); g_Console_Add('player got a security armor'); continue
; end;
6029 if cmd
= 'bluearmor' then begin plr
.GiveItem(ITEM_ARMOR_BLUE
); g_Console_Add('player got a combat armor'); continue
; end;
6031 if (cmd
= 'megasphere') or (cmd
= 'mega') then begin plr
.GiveItem(ITEM_SPHERE_BLUE
); g_Console_Add('player got a megasphere'); continue
; end;
6032 if (cmd
= 'soulsphere') or (cmd
= 'soul')then begin plr
.GiveItem(ITEM_SPHERE_WHITE
); g_Console_Add('player got a soul sphere'); continue
; end;
6034 if (cmd
= 'invul') or (cmd
= 'invulnerability') then begin plr
.GiveItem(ITEM_INVUL
); g_Console_Add('player got invulnerability'); continue
; end;
6035 if (cmd
= 'invis') or (cmd
= 'invisibility') then begin plr
.GiveItem(ITEM_INVIS
); g_Console_Add('player got invisibility'); continue
; end;
6037 if cmd
= 'redkey' then begin plr
.GiveItem(ITEM_KEY_RED
); g_Console_Add('player got the red key'); continue
; end;
6038 if cmd
= 'greenkey' then begin plr
.GiveItem(ITEM_KEY_GREEN
); g_Console_Add('player got the green key'); continue
; end;
6039 if cmd
= 'bluekey' then begin plr
.GiveItem(ITEM_KEY_BLUE
); g_Console_Add('player got the blue key'); continue
; end;
6041 if (cmd
= 'shotgun') or (cmd
= 'sg') then begin plr
.GiveItem(ITEM_WEAPON_SHOTGUN1
); g_Console_Add('player got a shotgun'); continue
; end;
6042 if (cmd
= 'supershotgun') or (cmd
= 'ssg') then begin plr
.GiveItem(ITEM_WEAPON_SHOTGUN2
); g_Console_Add('player got a supershotgun'); continue
; end;
6043 if cmd
= 'chaingun' then begin plr
.GiveItem(ITEM_WEAPON_CHAINGUN
); g_Console_Add('player got a chaingun'); continue
; end;
6044 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;
6045 if cmd
= 'plasmagun' then begin plr
.GiveItem(ITEM_WEAPON_PLASMA
); g_Console_Add('player got a plasma gun'); continue
; end;
6046 if cmd
= 'bfg' then begin plr
.GiveItem(ITEM_WEAPON_BFG
); g_Console_Add('player got a BFG-9000'); continue
; end;
6048 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;
6049 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;
6050 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;
6051 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;
6052 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;
6053 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;
6055 if cmd
= 'superchaingun' then begin plr
.GiveItem(ITEM_WEAPON_SUPERPULEMET
); g_Console_Add('player got a superchaingun'); continue
; end;
6056 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;
6058 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;
6059 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;
6061 if cmd
= 'chainsaw' then begin plr
.GiveItem(ITEM_WEAPON_SAW
); g_Console_Add('player got a chainsaw'); continue
; end;
6063 if cmd
= 'ammo' then
6065 plr
.GiveItem(ITEM_AMMO_SHELLS_BOX
);
6066 plr
.GiveItem(ITEM_AMMO_BULLETS_BOX
);
6067 plr
.GiveItem(ITEM_AMMO_CELL_BIG
);
6068 plr
.GiveItem(ITEM_AMMO_ROCKET_BOX
);
6069 plr
.GiveItem(ITEM_AMMO_FUELCAN
);
6070 g_Console_Add('player got some ammo');
6074 if cmd
= 'clip' then begin plr
.GiveItem(ITEM_AMMO_BULLETS
); g_Console_Add('player got some bullets'); continue
; end;
6075 if cmd
= 'bullets' then begin plr
.GiveItem(ITEM_AMMO_BULLETS_BOX
); g_Console_Add('player got a box of bullets'); continue
; end;
6077 if cmd
= 'shells' then begin plr
.GiveItem(ITEM_AMMO_SHELLS
); g_Console_Add('player got some shells'); continue
; end;
6078 if cmd
= 'shellbox' then begin plr
.GiveItem(ITEM_AMMO_SHELLS_BOX
); g_Console_Add('player got a box of shells'); continue
; end;
6080 if cmd
= 'cells' then begin plr
.GiveItem(ITEM_AMMO_CELL
); g_Console_Add('player got some cells'); continue
; end;
6081 if cmd
= 'battery' then begin plr
.GiveItem(ITEM_AMMO_CELL_BIG
); g_Console_Add('player got cell battery'); continue
; end;
6083 if cmd
= 'rocket' then begin plr
.GiveItem(ITEM_AMMO_ROCKET
); g_Console_Add('player got a rocket'); continue
; end;
6084 if cmd
= 'rocketbox' then begin plr
.GiveItem(ITEM_AMMO_ROCKET_BOX
); g_Console_Add('player got some rockets'); continue
; end;
6086 if (cmd
= 'fuel') or (cmd
= 'fuelcan') then begin plr
.GiveItem(ITEM_AMMO_FUELCAN
); g_Console_Add('player got fuel canister'); continue
; end;
6088 if cmd
= 'weapons' then
6090 plr
.GiveItem(ITEM_WEAPON_SHOTGUN1
);
6091 plr
.GiveItem(ITEM_WEAPON_SHOTGUN2
);
6092 plr
.GiveItem(ITEM_WEAPON_CHAINGUN
);
6093 plr
.GiveItem(ITEM_WEAPON_ROCKETLAUNCHER
);
6094 plr
.GiveItem(ITEM_WEAPON_PLASMA
);
6095 plr
.GiveItem(ITEM_WEAPON_BFG
);
6096 g_Console_Add('player got weapons');
6100 if cmd
= 'keys' then
6102 plr
.GiveItem(ITEM_KEY_RED
);
6103 plr
.GiveItem(ITEM_KEY_GREEN
);
6104 plr
.GiveItem(ITEM_KEY_BLUE
);
6105 g_Console_Add('player got all keys');
6109 g_Console_Add('i don''t know how to give '''+cmd
+'''!');
6114 if cmd
= 'open' then
6116 g_Console_Add('player activated sesame');
6117 g_Triggers_OpenAll();
6124 if gFly
then g_Console_Add('player feels himself lighter') else g_Console_Add('player lost his wings');
6128 if cmd
= 'noclip' then
6131 g_Console_Add('wall hardeness adjusted');
6135 if cmd
= 'notarget' then
6137 plr
.NoTarget
:= not plr
.NoTarget
;
6138 if plr
.NoTarget
then g_Console_Add('player hides in shadows') else g_Console_Add('player is brave again');
6142 if cmd
= 'noreload' then
6144 plr
.NoReload
:= not plr
.NoReload
;
6145 if plr
.NoReload
then g_Console_Add('player is action hero now') else g_Console_Add('player is ordinary man now');
6149 if cmd
= 'speedy' then
6151 MAX_RUNVEL
:= 32-MAX_RUNVEL
;
6152 g_Console_Add('speed adjusted');
6156 if cmd
= 'jumpy' then
6158 VEL_JUMP
:= 30-VEL_JUMP
;
6159 g_Console_Add('jump height adjusted');
6163 if cmd
= 'automap' then
6165 gShowMap
:= not gShowMap
;
6166 if gShowMap
then g_Console_Add('player gains second sight') else g_Console_Add('player lost second sight');
6170 if cmd
= 'aimline' then
6172 gAimLine
:= not gAimLine
;
6173 if gAimLine
then g_Console_Add('player gains laser sight') else g_Console_Add('player lost laser sight');
6178 procedure GameCommands(P
: SSArray
);
6184 pl
: pTNetClient
= nil;
6192 cmd
:= LowerCase(P
[0]);
6194 if cmd
= 'pause' then
6196 if (g_ActiveWindow
= nil) then
6197 g_Game_Pause(not gPauseMain
);
6199 else if cmd
= 'endgame' then
6200 gExit
:= EXIT_SIMPLE
6201 else if cmd
= 'restart' then
6203 if gGameOn
or (gState
in [STATE_INTERSINGLE
, STATE_INTERCUSTOM
]) then
6205 if g_Game_IsClient
then
6207 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6212 g_Console_Add(_lc
[I_MSG_NOT_GAME
]);
6214 else if cmd
= 'kick' then
6216 if g_Game_IsServer
then
6218 if Length(P
) < 2 then
6220 g_Console_Add('kick <name>');
6225 g_Console_Add('kick <name>');
6229 if g_Game_IsNet
then
6230 pl
:= g_Net_Client_ByName(P
[1]);
6233 s
:= g_Net_ClientName_ByID(pl
^.ID
);
6234 enet_peer_disconnect(pl
^.Peer
, NET_DISC_KICK
);
6235 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
6236 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
6237 g_Net_Slist_ServerPlayerLeaves();
6238 end else if gPlayers
<> nil then
6239 for a
:= Low(gPlayers
) to High(gPlayers
) do
6240 if gPlayers
[a
] <> nil then
6241 if Copy(LowerCase(gPlayers
[a
].Name
), 1, Length(P
[1])) = LowerCase(P
[1]) then
6243 // Íå îòêëþ÷àòü îñíîâíûõ èãðîêîâ â ñèíãëå
6244 if not(gPlayers
[a
] is TBot
) and (gGameSettings
.GameType
= GT_SINGLE
) then
6246 gPlayers
[a
].Lives
:= 0;
6247 gPlayers
[a
].Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
6248 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [gPlayers
[a
].Name
]), True);
6249 g_Player_Remove(gPlayers
[a
].UID
);
6250 g_Net_Slist_ServerPlayerLeaves();
6251 // Åñëè íå ïåðåìåøàòü, ïðè äîáàâëåíèè íîâûõ áîòîâ ïîÿâÿòñÿ ñòàðûå
6255 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6257 else if cmd
= 'kick_id' then
6259 if g_Game_IsServer
and g_Game_IsNet
then
6261 if Length(P
) < 2 then
6263 g_Console_Add('kick_id <client ID>');
6268 g_Console_Add('kick_id <client ID>');
6272 a
:= StrToIntDef(P
[1], 0);
6273 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
6275 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
6277 s
:= g_Net_ClientName_ByID(NetClients
[a
].ID
);
6278 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_KICK
);
6279 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
6280 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
6281 g_Net_Slist_ServerPlayerLeaves();
6285 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6287 else if cmd
= 'ban' then
6289 if g_Game_IsServer
and g_Game_IsNet
then
6291 if Length(P
) < 2 then
6293 g_Console_Add('ban <name>');
6298 g_Console_Add('ban <name>');
6302 pl
:= g_Net_Client_ByName(P
[1]);
6305 s
:= g_Net_ClientName_ByID(pl
^.ID
);
6306 g_Net_BanHost(pl
^.Peer
^.address
.host
, False);
6307 enet_peer_disconnect(pl
^.Peer
, NET_DISC_TEMPBAN
);
6308 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
6309 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
6310 g_Net_Slist_ServerPlayerLeaves();
6312 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
6314 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6316 else if cmd
= 'ban_id' then
6318 if g_Game_IsServer
and g_Game_IsNet
then
6320 if Length(P
) < 2 then
6322 g_Console_Add('ban_id <client ID>');
6327 g_Console_Add('ban_id <client ID>');
6331 a
:= StrToIntDef(P
[1], 0);
6332 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
6333 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
6335 s
:= g_Net_ClientName_ByID(NetClients
[a
].ID
);
6336 g_Net_BanHost(NetClients
[a
].Peer
^.address
.host
, False);
6337 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_TEMPBAN
);
6338 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
6339 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
6340 g_Net_Slist_ServerPlayerLeaves();
6343 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6345 else if cmd
= 'permban' then
6347 if g_Game_IsServer
and g_Game_IsNet
then
6349 if Length(P
) < 2 then
6351 g_Console_Add('permban <name>');
6356 g_Console_Add('permban <name>');
6360 pl
:= g_Net_Client_ByName(P
[1]);
6363 s
:= g_Net_ClientName_ByID(pl
^.ID
);
6364 g_Net_BanHost(pl
^.Peer
^.address
.host
);
6365 enet_peer_disconnect(pl
^.Peer
, NET_DISC_BAN
);
6366 g_Net_SaveBanList();
6367 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
6368 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
6369 g_Net_Slist_ServerPlayerLeaves();
6371 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
6373 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6375 else if cmd
= 'permban_id' then
6377 if g_Game_IsServer
and g_Game_IsNet
then
6379 if Length(P
) < 2 then
6381 g_Console_Add('permban_id <client ID>');
6386 g_Console_Add('permban_id <client ID>');
6390 a
:= StrToIntDef(P
[1], 0);
6391 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
6392 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
6394 s
:= g_Net_ClientName_ByID(NetClients
[a
].ID
);
6395 g_Net_BanHost(NetClients
[a
].Peer
^.address
.host
);
6396 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_BAN
);
6397 g_Net_SaveBanList();
6398 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
6399 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
6400 g_Net_Slist_ServerPlayerLeaves();
6403 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6405 else if cmd
= 'unban' then
6407 if g_Game_IsServer
and g_Game_IsNet
then
6409 if Length(P
) < 2 then
6411 g_Console_Add('unban <IP Address>');
6416 g_Console_Add('unban <IP Address>');
6420 if g_Net_UnbanHost(P
[1]) then
6422 g_Console_Add(Format(_lc
[I_MSG_UNBAN_OK
], [P
[1]]));
6423 g_Net_SaveBanList();
6425 g_Console_Add(Format(_lc
[I_MSG_UNBAN_FAIL
], [P
[1]]));
6427 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6429 else if cmd
= 'clientlist' then
6431 if g_Game_IsServer
and g_Game_IsNet
then
6434 if NetClients
<> nil then
6435 for a
:= Low(NetClients
) to High(NetClients
) do
6436 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
6438 plr
:= g_Player_Get(NetClients
[a
].Player
);
6439 if plr
= nil then continue
;
6441 g_Console_Add(Format('#%2d: %-15s | %s', [a
,
6442 IpToStr(NetClients
[a
].Peer
^.address
.host
), plr
.Name
]));
6445 g_Console_Add(_lc
[I_MSG_NOCLIENTS
]);
6447 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6449 else if cmd
= 'connect' then
6451 if (NetMode
= NET_NONE
) then
6453 if Length(P
) < 2 then
6455 g_Console_Add('connect <IP> [port] [password]');
6460 g_Console_Add('connect <IP> [port] [password]');
6464 if Length(P
) > 2 then
6465 prt
:= StrToIntDef(P
[2], 25666)
6469 if Length(P
) > 3 then
6474 g_Game_StartClient(P
[1], prt
, pw
);
6477 else if cmd
= 'disconnect' then
6479 if (NetMode
= NET_CLIENT
) then
6482 else if cmd
= 'reconnect' then
6484 if (NetMode
= NET_SERVER
) then
6487 if (NetMode
= NET_CLIENT
) then
6490 gExit
:= EXIT_SIMPLE
;
6494 //TODO: Use last successful password to reconnect, instead of ''
6495 g_Game_StartClient(NetClientIP
, NetClientPort
, '');
6497 else if (cmd
= 'addbot') or
6498 (cmd
= 'bot_add') then
6500 if Length(P
) > 2 then
6501 g_Bot_Add(TEAM_NONE
, StrToIntDef(P
[1], 2), StrToIntDef(P
[2], 100))
6502 else if Length(P
) > 1 then
6503 g_Bot_Add(TEAM_NONE
, StrToIntDef(P
[1], 2))
6505 g_Bot_Add(TEAM_NONE
, 2);
6507 else if cmd
= 'bot_addlist' then
6509 if Length(P
) > 1 then
6511 if Length(P
) = 2 then
6512 g_Bot_AddList(TEAM_NONE
, P
[1], StrToIntDef(P
[1], -1))
6513 else if Length(P
) = 3 then
6514 g_Bot_AddList(TEAM_NONE
, P
[1], StrToIntDef(P
[1], -1), StrToIntDef(P
[2], 100))
6516 g_Bot_AddList(IfThen(P
[2] = 'red', TEAM_RED
, TEAM_BLUE
), P
[1], StrToIntDef(P
[1], -1));
6519 else if cmd
= 'bot_removeall' then
6521 else if cmd
= 'chat' then
6523 if g_Game_IsNet
then
6525 if Length(P
) > 1 then
6527 for a
:= 1 to High(P
) do
6528 chstr
:= chstr
+ P
[a
] + ' ';
6530 if Length(chstr
) > 200 then SetLength(chstr
, 200);
6532 if Length(chstr
) < 1 then
6534 g_Console_Add('chat <text>');
6538 chstr
:= b_Text_Format(chstr
);
6539 if g_Game_IsClient
then
6540 MC_SEND_Chat(chstr
, NET_CHAT_PLAYER
)
6542 MH_SEND_Chat(gPlayer1Settings
.Name
+ ': ' + chstr
, NET_CHAT_PLAYER
);
6545 g_Console_Add('chat <text>');
6547 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6549 else if cmd
= 'teamchat' then
6551 if g_Game_IsNet
and (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
6553 if Length(P
) > 1 then
6555 for a
:= 1 to High(P
) do
6556 chstr
:= chstr
+ P
[a
] + ' ';
6558 if Length(chstr
) > 200 then SetLength(chstr
, 200);
6560 if Length(chstr
) < 1 then
6562 g_Console_Add('teamchat <text>');
6566 chstr
:= b_Text_Format(chstr
);
6567 if g_Game_IsClient
then
6568 MC_SEND_Chat(chstr
, NET_CHAT_TEAM
)
6570 MH_SEND_Chat(gPlayer1Settings
.Name
+ ': ' + chstr
, NET_CHAT_TEAM
,
6571 gPlayer1Settings
.Team
);
6574 g_Console_Add('teamchat <text>');
6576 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6578 else if cmd
= 'game' then
6580 if gGameSettings
.GameType
<> GT_NONE
then
6582 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6585 if Length(P
) = 1 then
6587 g_Console_Add(cmd
+ ' <WAD> [MAP] [# players]');
6590 // game not started yet, load fist map from some wad
6592 s
:= addWadExtension(P
[1]);
6593 found
:= e_FindResource(AllMapDirs
, s
);
6597 P
[1] := ExpandFileName(P
[1]);
6598 // if map not choosed then set first map
6599 if Length(P
) < 3 then
6602 P
[2] := g_Game_GetFirstMap(P
[1]);
6605 s
:= P
[1] + ':\' + UpperCase(P
[2]);
6607 if g_Map_Exist(s
) then
6611 with gGameSettings
do
6613 Options
:= gsGameFlags
;
6614 GameMode
:= g_Game_TextToMode(gsGameMode
);
6615 if gSwitchGameMode
<> GM_NONE
then
6616 GameMode
:= gSwitchGameMode
;
6617 if GameMode
= GM_NONE
then GameMode
:= GM_DM
;
6618 if GameMode
= GM_SINGLE
then GameMode
:= GM_COOP
;
6620 if Length(P
) >= 4 then
6621 b
:= StrToIntDef(P
[3], 1);
6622 g_Game_StartCustom(s
, GameMode
, TimeLimit
,
6623 GoalLimit
, MaxLives
, Options
, b
);
6628 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
6630 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [UpperCase(P
[2]), P
[1]]));
6632 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]));
6634 else if cmd
= 'host' then
6636 if gGameSettings
.GameType
<> GT_NONE
then
6638 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6641 if Length(P
) < 4 then
6643 g_Console_Add(cmd
+ ' <listen IP> <port> <WAD> [MAP] [# players]');
6646 if not StrToIp(P
[1], listen
) then
6648 prt
:= StrToIntDef(P
[2], 25666);
6650 s
:= addWadExtension(P
[3]);
6651 found
:= e_FindResource(AllMapDirs
, s
);
6655 // get first map in wad, if not specified
6656 if Length(P
) < 5 then
6659 P
[4] := g_Game_GetFirstMap(P
[1]);
6661 s
:= P
[3] + ':\' + UpperCase(P
[4]);
6662 if g_Map_Exist(s
) then
6666 with gGameSettings
do
6668 Options
:= gsGameFlags
;
6669 GameMode
:= g_Game_TextToMode(gsGameMode
);
6670 if gSwitchGameMode
<> GM_NONE
then GameMode
:= gSwitchGameMode
;
6671 if GameMode
= GM_NONE
then GameMode
:= GM_DM
;
6672 if GameMode
= GM_SINGLE
then GameMode
:= GM_COOP
;
6674 if Length(P
) >= 6 then
6675 b
:= StrToIntDef(P
[5], 0);
6676 g_Game_StartServer(s
, GameMode
, TimeLimit
, GoalLimit
, MaxLives
, Options
, b
, listen
, prt
)
6682 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[3]]))
6684 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [UpperCase(P
[4]), P
[3]]))
6689 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[3]]))
6692 else if cmd
= 'map' then
6694 if Length(P
) = 1 then
6696 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
6698 g_Console_Add(cmd
+ ' <MAP>');
6699 g_Console_Add(cmd
+ ' <WAD> [MAP]')
6703 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
])
6708 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
6710 if Length(P
) < 3 then
6712 // first param is map or wad
6713 s
:= UpperCase(P
[1]);
6714 if g_Map_Exist(gGameSettings
.WAD
+ ':\' + s
) then
6716 gExitByTrigger
:= False;
6719 // already in game, finish current map
6721 gExit
:= EXIT_ENDLEVELCUSTOM
;
6725 // intermission, so change map immediately
6732 found
:= e_FindResource(AllMapDirs
, s
);
6734 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [s
, 'WAD ' + P
[1]]));
6737 // no such map, found wad
6740 P
[1] := ExpandFileName(pw
);
6741 P
[2] := g_Game_GetFirstMap(P
[1]);
6742 s
:= P
[1] + ':\' + P
[2];
6743 if g_Map_Exist(s
) then
6745 gExitByTrigger
:= False;
6748 // already in game, finish current map
6750 gExit
:= EXIT_ENDLEVELCUSTOM
6754 // intermission, so change map immediately
6761 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
6763 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]))
6768 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]))
6774 s
:= addWadExtension(P
[1]);
6775 found
:= e_FindResource(AllMapDirs
, s
);
6779 P
[2] := UpperCase(P
[2]);
6780 s
:= P
[1] + ':\' + P
[2];
6781 if g_Map_Exist(s
) then
6783 gExitByTrigger
:= False;
6787 gExit
:= EXIT_ENDLEVELCUSTOM
6796 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]))
6801 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]))
6807 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
])
6811 else if cmd
= 'nextmap' then
6813 if not(gGameOn
or (gState
= STATE_INTERCUSTOM
)) then
6815 g_Console_Add(_lc
[I_MSG_NOT_GAME
])
6820 if Length(P
) = 1 then
6822 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
6824 g_Console_Add(cmd
+ ' <MAP>');
6825 g_Console_Add(cmd
+ ' <WAD> [MAP]');
6830 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6836 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
6838 if Length(P
) < 3 then
6840 // first param is map or wad
6841 s
:= UpperCase(P
[1]);
6842 if g_Map_Exist(gGameSettings
.WAD
+ ':\' + s
) then
6845 gExitByTrigger
:= False;
6851 // no such map, found wad
6852 pw
:= addWadExtension(P
[1]);
6853 found
:= e_FindResource(MapDirs
, pw
);
6855 found
:= e_FindResource(WadDirs
, pw
);
6857 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [s
, P
[1]]));
6860 // map not specified, select first map
6862 P
[2] := g_Game_GetFirstMap(P
[1]);
6863 s
:= P
[1] + ':\' + P
[2];
6864 if g_Map_Exist(s
) then
6866 gExitByTrigger
:= False;
6873 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
6875 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]))
6880 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]))
6886 // specified two params wad + map
6887 pw
:= addWadExtension(P
[1]);
6888 found
:= e_FindResource(MapDirs
, pw
);
6890 found
:= e_FindResource(MapDirs
, pw
);
6894 P
[2] := UpperCase(P
[2]);
6895 s
:= P
[1] + ':\' + P
[2];
6896 if g_Map_Exist(s
) then
6898 gExitByTrigger
:= False;
6904 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]))
6909 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]))
6915 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
])
6920 if gNextMap
= '' then
6921 g_Console_Add(_lc
[I_MSG_NEXTMAP_UNSET
])
6923 g_Console_Add(Format(_lc
[I_MSG_NEXTMAP_SET
], [gNextMap
]))
6927 else if (cmd
= 'endmap') or (cmd
= 'goodbye') then
6931 g_Console_Add(_lc
[I_MSG_NOT_GAME
])
6935 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
6937 gExitByTrigger
:= False;
6938 // next map not specified, try to find trigger EXIT
6939 if (gNextMap
= '') and (gTriggers
<> nil) then
6941 for a
:= 0 to High(gTriggers
) do
6943 if gTriggers
[a
].TriggerType
= TRIGGER_EXIT
then
6945 gExitByTrigger
:= True;
6946 //gNextMap := gTriggers[a].Data.MapName;
6947 gNextMap
:= gTriggers
[a
].tgcMap
;
6952 if gNextMap
= '' then
6953 gNextMap
:= g_Game_GetNextMap();
6954 if not isWadPath(gNextMap
) then
6955 s
:= gGameSettings
.WAD
+ ':\' + gNextMap
6958 if g_Map_Exist(s
) then
6959 gExit
:= EXIT_ENDLEVELCUSTOM
6961 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [gNextMap
]))
6965 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
])
6969 else if (cmd
= 'event') then
6971 if (Length(P
) <= 1) then
6973 for a
:= 0 to High(gEvents
) do
6974 if gEvents
[a
].Command
= '' then
6975 g_Console_Add(gEvents
[a
].Name
+ ' <none>')
6977 g_Console_Add(gEvents
[a
].Name
+ ' "' + gEvents
[a
].Command
+ '"');
6980 if (Length(P
) = 2) then
6982 for a
:= 0 to High(gEvents
) do
6983 if gEvents
[a
].Name
= P
[1] then
6984 if gEvents
[a
].Command
= '' then
6985 g_Console_Add(gEvents
[a
].Name
+ ' <none>')
6987 g_Console_Add(gEvents
[a
].Name
+ ' "' + gEvents
[a
].Command
+ '"');
6990 for a
:= 0 to High(gEvents
) do
6991 if gEvents
[a
].Name
= P
[1] then
6993 gEvents
[a
].Command
:= '';
6994 for b
:= 2 to High(P
) do
6995 if Pos(' ', P
[b
]) = 0 then
6996 gEvents
[a
].Command
:= gEvents
[a
].Command
+ ' ' + P
[b
]
6998 gEvents
[a
].Command
:= gEvents
[a
].Command
+ ' "' + P
[b
] + '"';
6999 gEvents
[a
].Command
:= Trim(gEvents
[a
].Command
);
7003 else if cmd
= 'suicide' then
7007 if g_Game_IsClient
then
7008 MC_SEND_CheatRequest(NET_CHEAT_SUICIDE
)
7011 if gPlayer1
<> nil then
7012 gPlayer1
.Damage(SUICIDE_DAMAGE
, gPlayer1
.UID
, 0, 0, HIT_SELF
);
7013 if gPlayer2
<> nil then
7014 gPlayer2
.Damage(SUICIDE_DAMAGE
, gPlayer2
.UID
, 0, 0, HIT_SELF
);
7018 else if cmd
= 'screenshot' then
7022 else if cmd
= 'weapon' then
7024 if Length(p
) = 2 then
7026 a
:= WP_FIRST
+ StrToInt(p
[1]) - 1;
7027 if (a
>= WP_FIRST
) and (a
<= WP_LAST
) then
7028 gSelectWeapon
[0, a
] := True
7031 else if (cmd
= 'p1_weapon') or (cmd
= 'p2_weapon') then
7033 if Length(p
) = 2 then
7035 a
:= WP_FIRST
+ StrToInt(p
[1]) - 1;
7036 b
:= ord(cmd
[2]) - ord('1');
7037 if (a
>= WP_FIRST
) and (a
<= WP_LAST
) then
7038 gSelectWeapon
[b
, a
] := True
7041 // Êîìàíäû Ñâîåé èãðû:
7042 else if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
7044 if cmd
= 'bot_addred' then
7046 if Length(P
) > 1 then
7047 g_Bot_Add(TEAM_RED
, StrToIntDef(P
[1], 2))
7049 g_Bot_Add(TEAM_RED
, 2);
7051 else if cmd
= 'bot_addblue' then
7053 if Length(P
) > 1 then
7054 g_Bot_Add(TEAM_BLUE
, StrToIntDef(P
[1], 2))
7056 g_Bot_Add(TEAM_BLUE
, 2);
7058 else if cmd
= 'spectate' then
7064 else if cmd
= 'say' then
7066 if g_Game_IsServer
and g_Game_IsNet
then
7068 if Length(P
) > 1 then
7071 for a
:= 1 to High(P
) do
7072 chstr
:= chstr
+ P
[a
] + ' ';
7074 if Length(chstr
) > 200 then SetLength(chstr
, 200);
7076 if Length(chstr
) < 1 then
7078 g_Console_Add('say <text>');
7082 chstr
:= b_Text_Format(chstr
);
7083 MH_SEND_Chat(chstr
, NET_CHAT_PLAYER
);
7085 else g_Console_Add('say <text>');
7087 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
7089 else if cmd
= 'tell' then
7091 if g_Game_IsServer
and g_Game_IsNet
then
7093 if (Length(P
) > 2) and (P
[1] <> '') then
7096 for a
:= 2 to High(P
) do
7097 chstr
:= chstr
+ P
[a
] + ' ';
7099 if Length(chstr
) > 200 then SetLength(chstr
, 200);
7101 if Length(chstr
) < 1 then
7103 g_Console_Add('tell <playername> <text>');
7107 pl
:= g_Net_Client_ByName(P
[1]);
7109 MH_SEND_Chat(b_Text_Format(chstr
), NET_CHAT_PLAYER
, pl
^.ID
)
7111 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
7113 else g_Console_Add('tell <playername> <text>');
7115 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
7117 else if cmd
= 'centerprint' then
7119 if (Length(P
) > 2) and (P
[1] <> '') then
7122 for a
:= 2 to High(P
) do
7123 chstr
:= chstr
+ P
[a
] + ' ';
7125 if Length(chstr
) > 200 then SetLength(chstr
, 200);
7127 if Length(chstr
) < 1 then
7129 g_Console_Add('centerprint <timeout> <text>');
7133 a
:= StrToIntDef(P
[1], 100);
7134 chstr
:= b_Text_Format(chstr
);
7135 g_Game_Message(chstr
, a
);
7136 if g_Game_IsNet
and g_Game_IsServer
then
7137 MH_SEND_GameEvent(NET_EV_BIGTEXT
, a
, chstr
);
7139 else g_Console_Add('centerprint <timeout> <text>');
7141 else if (cmd
= 'overtime') and not g_Game_IsClient
then
7143 if (Length(P
) = 1) or (StrToIntDef(P
[1], -1) <= 0) then
7145 // Äîïîëíèòåëüíîå âðåìÿ:
7146 gGameSettings
.TimeLimit
:= (gTime
- gGameStartTime
) div 1000 + Word(StrToIntDef(P
[1], 0));
7148 g_Console_Add(Format(_lc
[I_MSG_TIME_LIMIT
],
7149 [gGameSettings
.TimeLimit
div 3600,
7150 (gGameSettings
.TimeLimit
div 60) mod 60,
7151 gGameSettings
.TimeLimit
mod 60]));
7152 if g_Game_IsNet
then MH_SEND_GameSettings
;
7154 else if (cmd
= 'rcon_password') and g_Game_IsClient
then
7156 if (Length(P
) <= 1) then
7157 g_Console_Add('rcon_password <password>')
7159 MC_SEND_RCONPassword(P
[1]);
7161 else if cmd
= 'rcon' then
7163 if g_Game_IsClient
then
7165 if Length(P
) > 1 then
7168 for a
:= 1 to High(P
) do
7169 chstr
:= chstr
+ P
[a
] + ' ';
7171 if Length(chstr
) > 200 then SetLength(chstr
, 200);
7173 if Length(chstr
) < 1 then
7175 g_Console_Add('rcon <command>');
7179 MC_SEND_RCONCommand(chstr
);
7181 else g_Console_Add('rcon <command>');
7184 else if cmd
= 'ready' then
7186 if g_Game_IsServer
and (gLMSRespawn
= LMS_RESPAWN_WARMUP
) then
7187 gLMSRespawnTime
:= gTime
+ 100;
7189 else if (cmd
= 'callvote') and g_Game_IsNet
then
7191 if Length(P
) > 1 then
7194 for a
:= 1 to High(P
) do begin
7195 if a
> 1 then chstr
:= chstr
+ ' ';
7196 chstr
:= chstr
+ P
[a
];
7199 if Length(chstr
) > 200 then SetLength(chstr
, 200);
7201 if Length(chstr
) < 1 then
7203 g_Console_Add('callvote <command>');
7207 if g_Game_IsClient
then
7208 MC_SEND_Vote(True, chstr
)
7210 g_Game_StartVote(chstr
, gPlayer1Settings
.Name
);
7211 g_Console_Process('vote', True);
7214 g_Console_Add('callvote <command>');
7216 else if (cmd
= 'vote') and g_Game_IsNet
then
7218 if g_Game_IsClient
then
7220 else if gVoteInProgress
then
7222 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
7223 a
:= Floor((NetClientCount
+1)/2.0) + 1
7225 a
:= Floor(NetClientCount
/2.0) + 1;
7230 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_REVOKED
], [gPlayer1Settings
.Name
, gVoteCount
, a
]), True);
7231 MH_SEND_VoteEvent(NET_VE_REVOKE
, gPlayer1Settings
.Name
, 'a', gVoteCount
, a
);
7237 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_VOTE
], [gPlayer1Settings
.Name
, gVoteCount
, a
]), True);
7238 MH_SEND_VoteEvent(NET_VE_VOTE
, gPlayer1Settings
.Name
, 'a', gVoteCount
, a
);
7246 procedure SystemCommands(P
: SSArray
);
7250 cmd
:= LowerCase(P
[0]);
7259 gRC_Width
:= Max(1, gRC_Width
);
7260 gRC_Height
:= Max(1, gRC_Height
);
7261 gBPP
:= Max(1, gBPP
);
7262 if sys_SetDisplayMode(gRC_Width
, gRC_Height
, gBPP
, gRC_FullScreen
, gRC_Maximized
) = True then
7263 e_LogWriteln('resolution changed')
7265 e_LogWriteln('resolution not changed');
7266 sys_EnableVSync(gVSync
);
7270 if Length(p
) = 2 then
7272 gMaxFPS
:= StrToIntDef(p
[1], gMaxFPS
);
7274 gFrameTime
:= 1000 div gMaxFPS
7278 e_LogWritefln('r_maxfps %d', [gMaxFPS
]);
7282 if Length(p
) = 2 then
7284 gAskLanguage
:= true;
7285 gLanguage
:= LANGUAGE_ENGLISH
;
7286 case LowerCase(p
[1]) of
7289 gAskLanguage
:= false;
7290 gLanguage
:= LANGUAGE_ENGLISH
;
7294 gAskLanguage
:= false;
7295 gLanguage
:= LANGUAGE_RUSSIAN
;
7299 gAskLanguage
:= true;
7300 gLanguage
:= LANGUAGE_ENGLISH
;
7303 g_Language_Set(gLanguage
);
7307 e_LogWritefln('usage: %s <English|Russian|Ask>', [cmd
]);
7313 procedure g_TakeScreenShot(Filename
: string = '');
7314 var s
: TStream
; t
: TDateTime
; dir
, date
, name
: String;
7316 if e_NoGraphics
then Exit
;
7318 dir
:= e_GetWriteableDir(ScreenshotDirs
);
7320 if Filename
= '' then
7323 DateTimeToString(date
, 'yyyy-mm-dd-hh-nn-ss', t
);
7324 Filename
:= 'screenshot-' + date
;
7327 name
:= e_CatPath(dir
, Filename
+ '.png');
7328 s
:= createDiskFile(name
);
7330 e_MakeScreenshot(s
, gScreenWidth
, gScreenHeight
);
7332 g_Console_Add(Format(_lc
[I_CONSOLE_SCREENSHOT
], [name
]))
7334 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_WRITE
], [name
]));
7339 g_Console_Add('oh shit, i can''t create screenshot!')
7343 procedure g_Game_InGameMenu(Show
: Boolean);
7345 if (g_ActiveWindow
= nil) and Show
then
7347 if gGameSettings
.GameType
= GT_SINGLE
then
7348 g_GUI_ShowWindow('GameSingleMenu')
7351 if g_Game_IsClient
then
7352 g_GUI_ShowWindow('GameClientMenu')
7354 if g_Game_IsNet
then
7355 g_GUI_ShowWindow('GameServerMenu')
7357 g_GUI_ShowWindow('GameCustomMenu');
7359 g_Sound_PlayEx('MENU_OPEN');
7361 // Ïàóçà ïðè ìåíþ òîëüêî â îäèíî÷íîé èãðå:
7362 if (not g_Game_IsNet
) then
7366 if (g_ActiveWindow
<> nil) and (not Show
) then
7368 // Ïàóçà ïðè ìåíþ òîëüêî â îäèíî÷íîé èãðå:
7369 if (not g_Game_IsNet
) then
7370 g_Game_Pause(False);
7374 procedure g_Game_Pause (Enable
: Boolean);
7378 if not gGameOn
then exit
;
7380 if not (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
]) then exit
;
7383 gPauseMain
:= Enable
;
7385 if (gPause
<> oldPause
) then g_Game_PauseAllSounds(gPause
);
7388 procedure g_Game_HolmesPause (Enable
: Boolean);
7392 if not gGameOn
then exit
;
7393 if not (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
]) then exit
;
7396 gPauseHolmes
:= Enable
;
7398 if (gPause
<> oldPause
) then g_Game_PauseAllSounds(gPause
);
7401 procedure g_Game_PauseAllSounds(Enable
: Boolean);
7406 if gTriggers
<> nil then
7407 for i
:= 0 to High(gTriggers
) do
7408 with gTriggers
[i
] do
7409 if (TriggerType
= TRIGGER_SOUND
) and
7411 Sound
.IsPlaying() then
7413 Sound
.Pause(Enable
);
7417 if gPlayers
<> nil then
7418 for i
:= 0 to High(gPlayers
) do
7419 if gPlayers
[i
] <> nil then
7420 gPlayers
[i
].PauseSounds(Enable
);
7423 if gMusic
<> nil then
7424 gMusic
.Pause(Enable
);
7427 procedure g_Game_StopAllSounds(all
: Boolean);
7431 if gTriggers
<> nil then
7432 for i
:= 0 to High(gTriggers
) do
7433 with gTriggers
[i
] do
7434 if (TriggerType
= TRIGGER_SOUND
) and
7438 if gMusic
<> nil then
7445 procedure g_Game_UpdateTriggerSounds
;
7448 if gTriggers
<> nil then
7449 for i
:= 0 to High(gTriggers
) do
7450 with gTriggers
[i
] do
7451 if (TriggerType
= TRIGGER_SOUND
) and (Sound
<> nil) and tgcLocal
and Sound
.IsPlaying() then
7452 Sound
.SetCoordsRect(X
, Y
, Width
, Height
, tgcVolume
/ 255.0)
7455 function g_Game_IsWatchedPlayer(UID
: Word): Boolean;
7458 if (gPlayer1
<> nil) and (gPlayer1
.UID
= UID
) then
7463 if (gPlayer2
<> nil) and (gPlayer2
.UID
= UID
) then
7468 if gSpectMode
<> SPECT_PLAYERS
then
7470 if gSpectPID1
= UID
then
7475 if gSpectViewTwo
and (gSpectPID2
= UID
) then
7482 function g_Game_IsWatchedTeam(Team
: Byte): Boolean;
7487 if (gPlayer1
<> nil) and (gPlayer1
.Team
= Team
) then
7492 if (gPlayer2
<> nil) and (gPlayer2
.Team
= Team
) then
7497 if gSpectMode
<> SPECT_PLAYERS
then
7499 Pl
:= g_Player_Get(gSpectPID1
);
7500 if (Pl
<> nil) and (Pl
.Team
= Team
) then
7505 if gSpectViewTwo
then
7507 Pl
:= g_Player_Get(gSpectPID2
);
7508 if (Pl
<> nil) and (Pl
.Team
= Team
) then
7516 procedure g_Game_Message(Msg
: string; Time
: Word);
7518 MessageLineLength
:= (gScreenWidth
- 204) div e_CharFont_GetMaxWidth(gMenuFont
);
7519 MessageText
:= b_Text_Wrap(b_Text_Format(Msg
), MessageLineLength
);
7520 MessageTime
:= Time
;
7523 procedure g_Game_ChatSound(Text: String; Taunt
: Boolean = True);
7525 punct
: Array[0..13] of String =
7526 ('.', ',', ':', ';', '!', '?', '(', ')', '''', '"', '/', '\', '*', '^');
7532 function IsPunctuation(S
: String): Boolean;
7537 if Length(S
) <> 1 then
7539 for i
:= Low(punct
) to High(punct
) do
7540 if S
= punct
[i
] then
7546 function FilterPunctuation(S
: String): String;
7550 for i
:= Low(punct
) to High(punct
) do
7551 S
:= StringReplace(S
, punct
[i
], ' ', [rfReplaceAll
]);
7557 if gUseChatSounds
and Taunt
and (gChatSounds
<> nil) and (Pos(': ', Text) > 0) then
7559 // remove player name
7560 Delete(Text, 1, Pos(': ', Text) + 2 - 1);
7561 // for FullWord check
7562 Text := toLowerCase1251(' ' + Text + ' ');
7563 fpText
:= FilterPunctuation(Text);
7565 for i
:= 0 to Length(gChatSounds
) - 1 do
7568 for j
:= 0 to Length(gChatSounds
[i
].Tags
) - 1 do
7570 if gChatSounds
[i
].FullWord
and (not IsPunctuation(gChatSounds
[i
].Tags
[j
])) then
7571 ok
:= Pos(' ' + gChatSounds
[i
].Tags
[j
] + ' ', fpText
) > 0
7573 ok
:= Pos(gChatSounds
[i
].Tags
[j
], Text) > 0;
7579 gChatSounds
[i
].Sound
.Play();
7585 g_Sound_PlayEx('SOUND_GAME_RADIO');
7588 procedure g_Game_Announce_GoodShot(SpawnerUID
: Word);
7597 if not g_Game_IsWatchedPlayer(SpawnerUID
) then
7601 if goodsnd
[a
].IsPlaying() then
7604 goodsnd
[Random(4)].Play();
7607 procedure g_Game_Announce_KillCombo(Param
: Integer);
7614 UID
:= Param
and $FFFF;
7619 Pl
:= g_Player_Get(UID
);
7628 g_Console_Add(Format(_lc
[I_PLAYER_KILL_2X
], [Name
]), True);
7632 g_Console_Add(Format(_lc
[I_PLAYER_KILL_3X
], [Name
]), True);
7636 g_Console_Add(Format(_lc
[I_PLAYER_KILL_4X
], [Name
]), True);
7640 g_Console_Add(Format(_lc
[I_PLAYER_KILL_MX
], [Name
]), True);
7648 if not g_Game_IsWatchedPlayer(UID
) then
7651 if (not g_Game_IsWatchedPlayer(UID
)) and (c
< 4) then
7655 if killsnd
[n
].IsPlaying() then
7660 procedure g_Game_Announce_BodyKill(SpawnerUID
: Word);
7668 if not g_Game_IsWatchedPlayer(SpawnerUID
) then
7672 if hahasnd
[a
].IsPlaying() then
7675 hahasnd
[Random(3)].Play();
7678 procedure g_Game_StartVote(Command
, Initiator
: string);
7682 if not gVotesEnabled
then Exit
;
7683 if gGameSettings
.GameType
<> GT_SERVER
then Exit
;
7684 if gVoteInProgress
or gVotePassed
then
7686 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_INPROGRESS
], [gVoteCommand
]), True);
7687 MH_SEND_VoteEvent(NET_VE_INPROGRESS
, gVoteCommand
);
7690 gVoteInProgress
:= True;
7691 gVotePassed
:= False;
7692 gVoteTimer
:= gTime
+ gVoteTimeout
* 1000;
7695 gVoteCommand
:= Command
;
7697 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
7698 Need
:= Floor((NetClientCount
+1)/2.0)+1
7700 Need
:= Floor(NetClientCount
/2.0)+1;
7701 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_STARTED
], [Initiator
, Command
, Need
]), True);
7702 MH_SEND_VoteEvent(NET_VE_STARTED
, Initiator
, Command
, Need
);
7705 procedure g_Game_CheckVote
;
7709 if gGameSettings
.GameType
<> GT_SERVER
then Exit
;
7710 if not gVoteInProgress
then Exit
;
7712 if (gTime
>= gVoteTimer
) then
7714 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
7715 Need
:= Floor((NetClientCount
+1)/2.0) + 1
7717 Need
:= Floor(NetClientCount
/2.0) + 1;
7718 if gVoteCount
>= Need
then
7720 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_PASSED
], [gVoteCommand
]), True);
7721 MH_SEND_VoteEvent(NET_VE_PASSED
, gVoteCommand
);
7722 gVotePassed
:= True;
7723 gVoteCmdTimer
:= gTime
+ 5000;
7727 g_Console_Add(_lc
[I_MESSAGE_VOTE_FAILED
], True);
7728 MH_SEND_VoteEvent(NET_VE_FAILED
);
7730 if NetClients
<> nil then
7731 for I
:= Low(NetClients
) to High(NetClients
) do
7732 if NetClients
[i
].Used
then
7733 NetClients
[i
].Voted
:= False;
7734 gVoteInProgress
:= False;
7740 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
7741 Need
:= Floor((NetClientCount
+1)/2.0) + 1
7743 Need
:= Floor(NetClientCount
/2.0) + 1;
7744 if gVoteCount
>= Need
then
7746 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_PASSED
], [gVoteCommand
]), True);
7747 MH_SEND_VoteEvent(NET_VE_PASSED
, gVoteCommand
);
7748 gVoteInProgress
:= False;
7749 gVotePassed
:= True;
7750 gVoteCmdTimer
:= gTime
+ 5000;
7753 if NetClients
<> nil then
7754 for I
:= Low(NetClients
) to High(NetClients
) do
7755 if NetClients
[i
].Used
then
7756 NetClients
[i
].Voted
:= False;
7761 procedure g_Game_LoadMapList(FileName
: string);
7769 if not FileExists(FileName
) then Exit
;
7771 AssignFile(ListFile
, FileName
);
7773 while not EOF(ListFile
) do
7775 ReadLn(ListFile
, s
);
7778 if s
= '' then Continue
;
7780 SetLength(MapList
, Length(MapList
)+1);
7781 MapList
[High(MapList
)] := s
;
7783 CloseFile(ListFile
);
7786 procedure g_Game_SetDebugMode();
7789 // ×èòû (äàæå â ñâîåé èãðå):
7793 procedure g_Game_SetLoadingText(Text: String; Max
: Integer; reWrite
: Boolean);
7797 if Length(LoadingStat
.Msgs
) = 0 then
7803 begin // Ïåðåõîäèì íà ñëåäóþùóþ ñòðîêó èëè ñêðîëëèðóåì:
7804 if NextMsg
= Length(Msgs
) then
7806 for i
:= 0 to High(Msgs
)-1 do
7807 Msgs
[i
] := Msgs
[i
+1];
7815 Msgs
[NextMsg
-1] := Text;
7819 PBarWasHere
:= false;
7822 g_ActiveWindow
:= nil;
7824 ProcessLoading(true);
7827 procedure g_Game_StepLoading(Value
: Integer = -1);
7838 if (ShowCount
> LOADING_SHOW_STEP
) or (Value
> -1) then
7846 procedure g_Game_ClearLoading();
7855 len
:= ((gScreenHeight
div 3)*2 - 50) div LOADING_INTERLINE
;
7856 if len
< 1 then len
:= 1;
7857 SetLength(Msgs
, len
);
7858 for len
:= Low(Msgs
) to High(Msgs
) do
7861 PBarWasHere
:= false;
7865 procedure Parse_Params(var pars
: TParamStrValues
);
7872 while i
<= ParamCount
do
7875 if (s
[1] = '-') and (Length(s
) > 1) then
7877 if (s
[2] = '-') and (Length(s
) > 2) then
7878 begin // Îäèíî÷íûé ïàðàìåòð
7879 SetLength(pars
, Length(pars
) + 1);
7880 with pars
[High(pars
)] do
7882 Name
:= LowerCase(s
);
7887 if (i
< ParamCount
) then
7888 begin // Ïàðàìåòð ñî çíà÷åíèåì
7890 SetLength(pars
, Length(pars
) + 1);
7891 with pars
[High(pars
)] do
7893 Name
:= LowerCase(s
);
7894 Value
:= LowerCase(ParamStr(i
));
7903 function Find_Param_Value(var pars
: TParamStrValues
; aName
: String): String;
7908 for i
:= 0 to High(pars
) do
7909 if pars
[i
].Name
= aName
then
7911 Result
:= pars
[i
].Value
;
7916 procedure g_Game_Process_Params();
7918 pars
: TParamStrValues
;
7921 LimT
, LimS
: Integer;
7932 s
:= Find_Param_Value(pars
, '--debug');
7935 g_Game_SetDebugMode();
7936 s
:= Find_Param_Value(pars
, '--netdump');
7941 // Connect when game loads
7942 ip
:= Find_Param_Value(pars
, '-connect');
7946 s
:= Find_Param_Value(pars
, '-port');
7947 if (s
= '') or not TryStrToInt(s
, Port
) then
7950 s
:= Find_Param_Value(pars
, '-pw');
7952 g_Game_StartClient(ip
, Port
, s
);
7956 s
:= LowerCase(Find_Param_Value(pars
, '-dbg-mainwad'));
7959 gDefaultMegawadStart
:= s
;
7962 if (Find_Param_Value(pars
, '--dbg-mainwad-restore') <> '') or
7963 (Find_Param_Value(pars
, '--dbg-mainwad-default') <> '') then
7965 gDefaultMegawadStart
:= DF_Default_Megawad_Start
;
7968 // Start map when game loads:
7969 map
:= LowerCase(Find_Param_Value(pars
, '-map'));
7970 if isWadPath(map
) then
7973 s
:= Find_Param_Value(pars
, '-gm');
7974 GMode
:= g_Game_TextToMode(s
);
7975 if GMode
= GM_NONE
then GMode
:= GM_DM
;
7976 if GMode
= GM_SINGLE
then GMode
:= GM_COOP
;
7979 s
:= Find_Param_Value(pars
, '-limt');
7980 if (s
= '') or (not TryStrToInt(s
, LimT
)) then
7986 s
:= Find_Param_Value(pars
, '-lims');
7987 if (s
= '') or (not TryStrToInt(s
, LimS
)) then
7993 s
:= Find_Param_Value(pars
, '-lives');
7994 if (s
= '') or (not TryStrToInt(s
, Lives
)) then
8000 s
:= Find_Param_Value(pars
, '-opt');
8004 Opt
:= StrToIntDef(s
, 0);
8007 s
:= Find_Param_Value(pars
, '--close');
8011 // Override map to test:
8012 s
:= LowerCase(Find_Param_Value(pars
, '-testmap'));
8015 if e_IsValidResourceName(s
) then
8016 e_FindResource(AllMapDirs
, s
);
8017 gTestMap
:= ExpandFileName(s
);
8020 // Delete test map after play:
8021 s
:= Find_Param_Value(pars
, '--testdelete');
8024 //gMapToDelete := MapsDir + map;
8025 e_WriteLog('"--testdelete" is deprecated, use --tempdelete.', TMsgType
.Fatal
);
8029 // Delete temporary WAD after play:
8030 s
:= Find_Param_Value(pars
, '--tempdelete');
8031 if (s
<> '') and (gTestMap
<> '') then
8033 gMapToDelete
:= gTestMap
;
8034 gTempDelete
:= True;
8037 // Number of players:
8038 s
:= Find_Param_Value(pars
, '-pl');
8040 n
:= DEFAULT_PLAYERS
8042 n
:= StrToIntDef(s
, DEFAULT_PLAYERS
);
8045 s
:= Find_Param_Value(pars
, '-port');
8046 if (s
= '') or not TryStrToInt(s
, Port
) then
8047 g_Game_StartCustom(map
, GMode
, LimT
, LimS
, Lives
, Opt
, n
)
8049 g_Game_StartServer(map
, GMode
, LimT
, LimS
, Lives
, Opt
, n
, 0, Port
);
8052 // Execute script when game loads:
8053 s
:= Find_Param_Value(pars
, '-exec');
8056 // if not isWadPath(s) then
8057 // s := GameDir + '/' + s;
8062 if IOResult
<> 0 then
8064 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], ['Failed to read file: ' + s
]), TMsgType
.Warning
);
8065 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_READ
], [s
]));
8069 e_WriteLog('Executing script: ' + s
, TMsgType
.Notify
);
8070 g_Console_Add(Format(_lc
[I_CONSOLE_EXEC
], [s
]));
8075 if IOResult
<> 0 then
8077 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], ['Failed to read file: ' + s
]), TMsgType
.Warning
);
8078 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_READ
], [s
]));
8082 if Pos('#', s
) <> 1 then // script comment
8083 g_Console_Process(s
, True);
8094 conRegVar('pf_draw_frame', @g_profile_frame_draw
, 'draw frame rendering profiles', 'render profiles');
8095 //conRegVar('pf_update_frame', @g_profile_frame_update, 'draw frame updating profiles', 'update profiles');
8096 conRegVar('pf_coldet', @g_profile_collision
, 'draw collision detection profiles', 'coldet profiles');
8097 conRegVar('pf_los', @g_profile_los
, 'draw monster LOS profiles', 'monster LOS profiles');
8099 conRegVar('r_sq_draw', @gdbg_map_use_accel_render
, 'accelerated spatial queries in rendering', 'accelerated rendering');
8100 conRegVar('cd_sq_enabled', @gdbg_map_use_accel_coldet
, 'accelerated spatial queries in map coldet', 'accelerated map coldet');
8101 conRegVar('mon_sq_enabled', @gmon_debug_use_sqaccel
, 'accelerated spatial queries for monsters', 'accelerated monster coldet');
8102 conRegVar('wtrace_sq_enabled', @gwep_debug_fast_trace
, 'accelerated spatial queries for weapon hitscan trace', 'accelerated weapon hitscan');
8104 conRegVar('pr_enabled', @gpart_dbg_enabled
, 'enable/disable particles', 'particles');
8105 conRegVar('pr_phys_enabled', @gpart_dbg_phys_enabled
, 'enable/disable particle physics', 'particle physics');
8107 conRegVar('los_enabled', @gmon_dbg_los_enabled
, 'enable/disable monster LOS calculations', 'monster LOS', true);
8108 conRegVar('mon_think', @gmon_debug_think
, 'enable/disable monster thinking', 'monster thinking', true);
8110 {$IFDEF ENABLE_HOLMES}
8111 conRegVar('dbg_holmes', @g_holmes_enabled
, 'enable/disable Holmes', 'Holmes', true);
8114 conRegVar('dbg_ignore_level_bounds', @g_dbg_ignore_bounds
, 'ignore level bounds', '', false);
8116 conRegVar('r_scale', @g_dbg_scale
, 0.01, 100.0, 'render scale', '', false);
8117 conRegVar('r_resolution_scale', @r_pixel_scale
, 0.01, 100.0, 'upscale factor', '', false);
8119 conRegVar('light_enabled', @gwin_k8_enable_light_experiments
, 'enable/disable dynamic lighting', 'lighting');
8120 conRegVar('light_player_halo', @g_playerLight
, 'enable/disable player halo', 'player light halo');
8122 conRegVar('r_smallmap_align_h', @r_smallmap_h
, 'halign: 0: left; 1: center; 2: right', 'horizontal aligning of small maps');
8123 conRegVar('r_smallmap_align_v', @r_smallmap_v
, 'valign: 0: top; 1: center; 2: bottom', 'vertial aligning of small maps');
8125 conRegVar('r_showfps', @gShowFPS
, 'draw fps counter', 'draw fps counter');
8126 conRegVar('r_showtime', @gShowTime
, 'show game time', 'show game time');
8127 conRegVar('r_showping', @gShowPing
, 'show ping', 'show ping');
8128 conRegVar('r_showscore', @gShowGoals
, 'show score', 'show score');
8129 conRegVar('r_showkillmsg', @gShowKillMsg
, 'show kill log', 'show kill log');
8130 conRegVar('r_showlives', @gShowLives
, 'show lives', 'show lives');
8131 conRegVar('r_showspect', @gSpectHUD
, 'show spectator hud', 'show spectator hud');
8132 conRegVar('r_showstat', @gShowStat
, 'show stats', 'show stats');