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_Draw();
88 procedure g_Game_Quit();
89 procedure g_Game_SetupScreenSize();
90 procedure g_Game_ChangeResolution(newWidth
, newHeight
: Word; nowFull
, nowMax
: Boolean);
91 function g_Game_ModeToText(Mode
: Byte): string;
92 function g_Game_TextToMode(Mode
: string): Byte;
93 procedure g_Game_ExecuteEvent(Name
: String);
94 function g_Game_DelayEvent(DEType
: Byte; Time
: LongWord; Num
: Integer = 0; Str
: String = ''): Integer;
95 procedure g_Game_AddPlayer(Team
: Byte = TEAM_NONE
);
96 procedure g_Game_RemovePlayer();
97 procedure g_Game_Spectate();
98 procedure g_Game_SpectateCenterView();
99 procedure g_Game_StartSingle(Map
: String; TwoPlayers
: Boolean; nPlayers
: Byte);
100 procedure g_Game_StartCustom(Map
: String; GameMode
: Byte; TimeLimit
, GoalLimit
: Word; MaxLives
: Byte; Options
: LongWord; nPlayers
: Byte);
101 procedure g_Game_StartServer(Map
: String; GameMode
: Byte; TimeLimit
, GoalLimit
: Word; MaxLives
: Byte; Options
: LongWord; nPlayers
: Byte; IPAddr
: LongWord; Port
: Word);
102 procedure g_Game_StartClient(Addr
: String; Port
: Word; PW
: String);
103 procedure g_Game_Restart();
104 procedure g_Game_RestartLevel();
105 procedure g_Game_RestartRound(NoMapRestart
: Boolean = False);
106 function g_Game_ClientWAD (NewWAD
: String; const WHash
: TMD5Digest
): AnsiString;
107 function g_Game_StartMap(asMegawad
: Boolean; Map
: String; Force
: Boolean = False; const oldMapPath
: AnsiString=''): Boolean;
108 procedure g_Game_ChangeMap(const MapPath
: String);
109 procedure g_Game_ExitLevel(const Map
: AnsiString);
110 function g_Game_GetFirstMap(WAD
: String): String;
111 function g_Game_GetNextMap(): String;
112 procedure g_Game_NextLevel();
113 procedure g_Game_Pause(Enable
: Boolean);
114 procedure g_Game_HolmesPause(Enable
: Boolean);
115 procedure g_Game_InGameMenu(Show
: Boolean);
116 function g_Game_IsWatchedPlayer(UID
: Word): Boolean;
117 function g_Game_IsWatchedTeam(Team
: Byte): Boolean;
118 procedure g_Game_Message(Msg
: String; Time
: Word);
119 procedure g_Game_LoadMapList(FileName
: String);
120 procedure g_Game_PauseAllSounds(Enable
: Boolean);
121 procedure g_Game_StopAllSounds(all
: Boolean);
122 procedure g_Game_UpdateTriggerSounds();
123 function g_Game_GetMegaWADInfo(WAD
: String): TMegaWADInfo
;
124 procedure g_Game_ChatSound(Text: String; Taunt
: Boolean = True);
125 procedure g_Game_Announce_GoodShot(SpawnerUID
: Word);
126 procedure g_Game_Announce_KillCombo(Param
: Integer);
127 procedure g_Game_Announce_BodyKill(SpawnerUID
: Word);
128 procedure g_Game_StartVote(Command
, Initiator
: string);
129 procedure g_Game_CheckVote
;
130 procedure g_TakeScreenShot(Filename
: string = '');
131 procedure g_FatalError(Text: String);
132 procedure g_SimpleError(Text: String);
133 function g_Game_IsTestMap(): Boolean;
134 procedure g_Game_DeleteTestMap();
135 procedure GameCVars(P
: SSArray
);
136 procedure PlayerSettingsCVars(P
: SSArray
);
137 procedure SystemCommands(P
: SSArray
);
138 procedure GameCommands(P
: SSArray
);
139 procedure GameCheats(P
: SSArray
);
140 procedure DebugCommands(P
: SSArray
);
141 procedure g_Game_Process_Params
;
142 procedure g_Game_SetLoadingText(Text: String; Max
: Integer; reWrite
: Boolean);
143 procedure g_Game_StepLoading(Value
: Integer = -1);
144 procedure g_Game_ClearLoading();
145 procedure g_Game_SetDebugMode();
146 procedure DrawLoadingStat();
147 procedure DrawMenuBackground(tex
: AnsiString);
149 { procedure SetWinPause(Enable: Boolean); }
154 LOADING_SHOW_STEP
= 100;
155 LOADING_INTERLINE
= 20;
170 MESSAGE_DIKEY
= WM_USER
+ 1;
175 EXIT_ENDLEVELSINGLE
= 4;
176 EXIT_ENDLEVELCUSTOM
= 5;
178 GAME_OPTION_RESERVED
= 1;
179 GAME_OPTION_TEAMDAMAGE
= 2;
180 GAME_OPTION_ALLOWEXIT
= 4;
181 GAME_OPTION_WEAPONSTAY
= 8;
182 GAME_OPTION_MONSTERS
= 16;
183 GAME_OPTION_BOTVSPLAYER
= 32;
184 GAME_OPTION_BOTVSMONSTER
= 64;
185 GAME_OPTION_DMKEYS
= 128;
190 STATE_INTERCUSTOM
= 3;
191 STATE_INTERSINGLE
= 4;
197 LMS_RESPAWN_NONE
= 0;
198 LMS_RESPAWN_WARMUP
= 1;
199 LMS_RESPAWN_FINAL
= 2;
216 CONFIG_FILENAME
= 'Doom2DF.cfg';
218 TEST_MAP_NAME
= '$$$_TEST_$$$';
220 STD_PLAYER_MODEL
= 'Doomer';
228 STATFILE_VERSION
= $03;
232 gGameSettings
: TGameSettings
;
233 gPlayer1Settings
: TPlayerSettings
;
234 gPlayer2Settings
: TPlayerSettings
;
236 gPlayerScreenSize
: TDFPoint
;
237 gPlayer1ScreenCoord
: TDFPoint
;
238 gPlayer2ScreenCoord
: TDFPoint
;
239 gPlayer1
: TPlayer
= nil;
240 gPlayer2
: TPlayer
= nil;
241 gPlayerDrawn
: TPlayer
= nil;
243 gLerpFactor
: Single = 1.0;
244 gSwitchGameMode
: Byte = GM_DM
;
245 gHearPoint1
, gHearPoint2
: THearPoint
;
246 gSoundEffectsDF
: Boolean = False;
247 gSoundTriggerTime
: Word = 0;
248 gAnnouncer
: Integer = ANNOUNCE_NONE
;
249 goodsnd
: array[0..3] of TPlayableSound
;
250 killsnd
: array[0..3] of TPlayableSound
;
251 hahasnd
: array[0..2] of TPlayableSound
;
252 sound_get_flag
: array[0..1] of TPlayableSound
;
253 sound_lost_flag
: array[0..1] of TPlayableSound
;
254 sound_ret_flag
: array[0..1] of TPlayableSound
;
255 sound_cap_flag
: array[0..1] of TPlayableSound
;
256 gBodyKillEvent
: Integer = -1;
257 gDefInterTime
: ShortInt = -1;
258 gInterEndTime
: LongWord = 0;
259 gInterTime
: LongWord = 0;
260 gServInterTime
: Byte = 0;
261 gGameStartTime
: LongWord = 0;
262 gTotalMonsters
: Integer = 0;
263 gPauseMain
: Boolean = false;
264 gPauseHolmes
: Boolean = false;
265 gShowTime
: Boolean = False;
266 gShowFPS
: Boolean = False;
267 gShowGoals
: Boolean = True;
268 gShowStat
: Boolean = True;
269 gShowKillMsg
: Boolean = True;
270 gShowLives
: Boolean = True;
271 gShowPing
: Boolean = False;
272 gShowMap
: Boolean = False;
274 gState
: Byte = STATE_NONE
;
276 sWidth
, sHeight
: Word;
277 gSpectMode
: Byte = SPECT_NONE
;
278 gSpectHUD
: Boolean = True;
279 gSpectKeyPress
: Boolean = False;
280 gSpectX
: Integer = 0;
281 gSpectY
: Integer = 0;
282 gSpectStep
: Byte = 8;
283 gSpectViewTwo
: Boolean = False;
284 gSpectPID1
: Integer = -1;
285 gSpectPID2
: Integer = -1;
286 gSpectAuto
: Boolean = False;
287 gSpectAutoNext
: LongWord;
288 gSpectAutoStepX
: Integer;
289 gSpectAutoStepY
: Integer;
290 gMusic
: TMusic
= nil;
291 gLoadGameMode
: Boolean;
292 gCheats
: Boolean = False;
293 gMapOnce
: Boolean = False;
294 gMapToDelete
: String;
295 gTempDelete
: Boolean = False;
296 gLastMap
: Boolean = False;
299 gResolutionChange
: Boolean = False;
300 gRC_Width
, gRC_Height
: Integer;
301 gRC_FullScreen
, gRC_Maximized
: Boolean;
302 gLanguageChange
: Boolean = False;
303 gDebugMode
: Boolean = False;
304 g_debug_Sounds
: Boolean = False;
305 g_debug_Frames
: Boolean = False;
306 g_debug_WinMsgs
: Boolean = False;
307 g_debug_MonsterOff
: Boolean = False;
308 g_debug_BotAIOff
: Byte = 0;
309 g_debug_HealthBar
: Boolean = False;
310 g_Debug_Player
: Boolean = False;
311 gCoopMonstersKilled
: Word = 0;
312 gCoopSecretsFound
: Word = 0;
313 gCoopTotalMonstersKilled
: Word = 0;
314 gCoopTotalSecretsFound
: Word = 0;
315 gCoopTotalMonsters
: Word = 0;
316 gCoopTotalSecrets
: Word = 0;
317 gStatsOff
: Boolean = False;
318 gStatsPressed
: Boolean = False;
319 gExitByTrigger
: Boolean = False;
320 gNextMap
: String = '';
321 gLMSRespawn
: Byte = LMS_RESPAWN_NONE
;
322 gLMSRespawnTime
: Cardinal = 0;
323 gLMSSoftSpawn
: Boolean = False;
324 gMissionFailed
: Boolean = False;
325 gVoteInProgress
: Boolean = False;
326 gVotePassed
: Boolean = False;
327 gVoteCommand
: string = '';
328 gVoteTimer
: Cardinal = 0;
329 gVoteCmdTimer
: Cardinal = 0;
330 gVoteCount
: Integer = 0;
331 gVoteTimeout
: Cardinal = 30;
332 gVoted
: Boolean = False;
333 gVotesEnabled
: Boolean = True;
334 gEvents
: Array of TGameEvent
;
335 gDelayedEvents
: Array of TDelayedEvent
;
336 gUseChatSounds
: Boolean = True;
337 gChatSounds
: Array of TChatSound
;
338 gSelectWeapon
: Array [0..1, WP_FIRST
..WP_LAST
] of Boolean; // [player, weapon]
339 gInterReadyCount
: Integer = 0;
341 g_dbg_ignore_bounds
: Boolean = false;
342 r_smallmap_h
: Integer = 0; // 0: left; 1: center; 2: right
343 r_smallmap_v
: Integer = 2; // 0: top; 1: center; 2: bottom
345 // move button values:
346 // bits 0-1: l/r state:
347 // 0: neither left, nor right pressed
350 // bits 4-5: l/r state when strafe was pressed
351 P1MoveButton
: Byte = 0;
352 P2MoveButton
: Byte = 0;
354 g_profile_frame_update
: Boolean = false;
355 g_profile_frame_draw
: Boolean = false;
356 g_profile_collision
: Boolean = false;
357 g_profile_los
: Boolean = false;
358 g_profile_history_size
: Integer = 1000;
360 g_rlayer_back
: Boolean = true;
361 g_rlayer_step
: Boolean = true;
362 g_rlayer_wall
: Boolean = true;
363 g_rlayer_door
: Boolean = true;
364 g_rlayer_acid1
: Boolean = true;
365 g_rlayer_acid2
: Boolean = true;
366 g_rlayer_water
: Boolean = true;
367 g_rlayer_fore
: Boolean = true;
370 procedure g_ResetDynlights ();
371 procedure g_AddDynLight (x
, y
, radius
: Integer; r
, g
, b
, a
: Single);
372 procedure g_DynLightExplosion (x
, y
, radius
: Integer; r
, g
, b
: Single);
374 function conIsCheatsEnabled (): Boolean; inline;
375 function gPause (): Boolean; inline;
381 {$INCLUDE ../nogl/noGLuses.inc}
382 {$IFDEF ENABLE_HOLMES}
385 e_texture
, e_res
, g_textures
, g_window
, g_menu
,
386 e_input
, e_log
, g_console
, g_items
, g_map
, g_panel
,
387 g_playermodel
, g_gfx
, g_options
, Math
,
388 g_triggers
, g_monsters
, e_sound
, CONFIG
,
389 g_language
, g_net
, g_main
, g_phys
,
390 ENet
, e_msg
, g_netmsg
, g_netmaster
,
391 sfs
, wadreader
, g_system
;
395 hasPBarGfx
: Boolean = false;
398 // ////////////////////////////////////////////////////////////////////////// //
399 function gPause (): Boolean; inline; begin result
:= gPauseMain
or gPauseHolmes
; end;
402 // ////////////////////////////////////////////////////////////////////////// //
403 function conIsCheatsEnabled (): Boolean; inline;
406 if g_Game_IsNet
then exit
;
407 if not gDebugMode
then
409 //if not gCheats then exit;
410 if not (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
]) then exit
;
411 if not (gGameSettings
.GameMode
in [GM_COOP
, GM_SINGLE
]) then exit
;
417 // ////////////////////////////////////////////////////////////////////////// //
419 profileFrameDraw
: TProfiler
= nil;
422 // ////////////////////////////////////////////////////////////////////////// //
425 x
, y
, radius
: Integer;
428 exploRadius
: Integer;
432 g_dynLights
: array of TDynLight
= nil;
433 g_dynLightCount
: Integer = 0;
434 g_playerLight
: Boolean = false;
436 procedure g_ResetDynlights ();
440 if not gwin_has_stencil
then begin g_dynLightCount
:= 0; exit
; end;
442 for idx
:= 0 to g_dynLightCount
-1 do
444 if g_dynLights
[idx
].exploCount
= -666 then
451 Inc(g_dynLights
[idx
].exploCount
);
452 if (g_dynLights
[idx
].exploCount
< 10) then
454 g_dynLights
[idx
].radius
:= g_dynLights
[idx
].exploRadius
+g_dynLights
[idx
].exploCount
*8;
455 g_dynLights
[idx
].a
:= 0.4+g_dynLights
[idx
].exploCount
/10;
456 if (g_dynLights
[idx
].a
> 0.8) then g_dynLights
[idx
].a
:= 0.8;
457 if lnum
<> idx
then g_dynLights
[lnum
] := g_dynLights
[idx
];
462 g_dynLightCount
:= lnum
;
465 procedure g_AddDynLight (x
, y
, radius
: Integer; r
, g
, b
, a
: Single);
467 if not gwin_has_stencil
then exit
;
468 if g_dynLightCount
= length(g_dynLights
) then SetLength(g_dynLights
, g_dynLightCount
+1024);
469 g_dynLights
[g_dynLightCount
].x
:= x
;
470 g_dynLights
[g_dynLightCount
].y
:= y
;
471 g_dynLights
[g_dynLightCount
].radius
:= radius
;
472 g_dynLights
[g_dynLightCount
].r
:= r
;
473 g_dynLights
[g_dynLightCount
].g
:= g
;
474 g_dynLights
[g_dynLightCount
].b
:= b
;
475 g_dynLights
[g_dynLightCount
].a
:= a
;
476 g_dynLights
[g_dynLightCount
].exploCount
:= -666;
477 Inc(g_dynLightCount
);
480 procedure g_DynLightExplosion (x
, y
, radius
: Integer; r
, g
, b
: Single);
482 if not gwin_has_stencil
then exit
;
483 if g_dynLightCount
= length(g_dynLights
) then SetLength(g_dynLights
, g_dynLightCount
+1024);
484 g_dynLights
[g_dynLightCount
].x
:= x
;
485 g_dynLights
[g_dynLightCount
].y
:= y
;
486 g_dynLights
[g_dynLightCount
].radius
:= 0;
487 g_dynLights
[g_dynLightCount
].exploRadius
:= radius
;
488 g_dynLights
[g_dynLightCount
].r
:= r
;
489 g_dynLights
[g_dynLightCount
].g
:= g
;
490 g_dynLights
[g_dynLightCount
].b
:= b
;
491 g_dynLights
[g_dynLightCount
].a
:= 0;
492 g_dynLights
[g_dynLightCount
].exploCount
:= 0;
493 Inc(g_dynLightCount
);
497 // ////////////////////////////////////////////////////////////////////////// //
498 function calcProfilesHeight (prof
: TProfiler
): Integer;
501 if (prof
= nil) then exit
;
502 if (length(prof
.bars
) = 0) then exit
;
503 result
:= length(prof
.bars
)*(16+2);
507 function drawProfiles (x
, y
: Integer; prof
: TProfiler
): Integer;
514 if (prof
= nil) then exit
;
516 if (length(prof
.bars
) = 0) then exit
;
518 hgt
:= calcProfilesHeight(prof
);
519 if (x
< 0) then x
:= gScreenWidth
-(wdt
-1)+x
;
520 if (y
< 0) then y
:= gScreenHeight
-(hgt
-1)+y
;
522 //e_DrawFillQuad(x, y, x+wdt-1, y+hgt-1, 255, 255, 255, 200, B_BLEND);
523 //e_DrawFillQuad(x, y, x+wdt-1, y+hgt-1, 20, 20, 20, 0, B_NONE);
524 e_DarkenQuadWH(x
, y
, wdt
, hgt
, 150);
527 for ii
:= 0 to High(prof
.bars
) do
529 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);
536 // ////////////////////////////////////////////////////////////////////////// //
538 TEndCustomGameStat
= record
539 PlayerStat
: TPlayerStatArray
;
543 Map
, MapName
: String;
546 TEndSingleGameStat
= record
547 PlayerStat
: Array [0..1] of record
553 TotalSecrets
: Integer;
556 TLoadingStat
= record
560 Msgs
: Array of String;
562 PBarWasHere
: Boolean; // did we draw a progress bar for this message?
565 TParamStrValue
= record
570 TParamStrValues
= Array of TParamStrValue
;
573 INTER_ACTION_TEXT
= 1;
574 INTER_ACTION_PIC
= 2;
575 INTER_ACTION_MUSIC
= 3;
579 FPSCounter
, UPSCounter
: Word;
580 FPSTime
, UPSTime
: LongWord;
581 DataLoaded
: Boolean = False;
582 IsDrawStat
: Boolean = False;
583 CustomStat
: TEndCustomGameStat
;
584 SingleStat
: TEndSingleGameStat
;
585 LoadingStat
: TLoadingStat
;
586 EndingGameCounter
: Byte = 0;
589 MessageLineLength
: Integer = 80;
590 MapList
: SSArray
= nil;
591 MapIndex
: Integer = -1;
592 InterReadyTime
: Integer = -1;
593 StatShotDone
: Boolean = False;
594 StatFilename
: string = ''; // used by stat screenshot to save with the same name as the csv
595 StatDate
: string = '';
601 text: Array of ShortString;
602 anim
: Array of ShortString;
603 pic
: Array of ShortString;
604 mus
: Array of ShortString;
606 triggers
: Array of record
608 actions
: Array of record
609 action
, p1
, p2
: Integer;
612 cur_trigger
: Integer;
625 function Compare(a
, b
: TPlayerStat
): Integer;
627 if a
.Spectator
then Result
:= 1
628 else if b
.Spectator
then Result
:= -1
629 else if a
.Frags
< b
.Frags
then Result
:= 1
630 else if a
.Frags
> b
.Frags
then Result
:= -1
631 else if a
.Deaths
< b
.Deaths
then Result
:= -1
632 else if a
.Deaths
> b
.Deaths
then Result
:= 1
633 else if a
.Kills
< b
.Kills
then Result
:= -1
637 procedure SortGameStat(var stat
: TPlayerStatArray
);
642 if stat
= nil then Exit
;
644 for I
:= High(stat
) downto Low(stat
) do
645 for J
:= Low(stat
) to High(stat
) - 1 do
646 if Compare(stat
[J
], stat
[J
+ 1]) = 1 then
649 stat
[J
] := stat
[J
+ 1];
654 // saves a shitty CSV containing the game stats passed to it
655 procedure SaveGameStat(Stat
: TEndCustomGameStat
; Path
: string);
658 dir
, fname
, map
, mode
, etime
: String;
662 dir
:= e_GetWriteableDir(StatsDirs
);
663 // stats are placed in stats/yy/mm/dd/*.csv
664 fname
:= e_CatPath(dir
, Path
);
665 ForceDirectories(fname
); // ensure yy/mm/dd exists within the stats dir
666 fname
:= e_CatPath(fname
, StatFilename
+ '.csv');
667 AssignFile(s
, fname
);
670 // line 1: stats ver, datetime, server name, map name, game mode, time limit, score limit, dmflags, game time, num players
671 if g_Game_IsNet
then fname
:= NetServerName
else fname
:= '';
672 map
:= g_ExtractWadNameNoPath(gMapInfo
.Map
) + ':/' + g_ExtractFileName(gMapInfo
.Map
);
673 mode
:= g_Game_ModeToText(Stat
.GameMode
);
674 etime
:= Format('%d:%.2d:%.2d', [
675 Stat
.GameTime
div 1000 div 3600,
676 (Stat
.GameTime
div 1000 div 60) mod 60,
677 Stat
.GameTime
div 1000 mod 60
679 WriteLn(s
, 'stats_ver,datetime,server,map,mode,timelimit,scorelimit,dmflags,time,num_players');
680 WriteLn(s
, Format('%d,%s,%s,%s,%s,%u,%u,%u,%s,%d', [
686 gGameSettings
.TimeLimit
,
687 gGameSettings
.GoalLimit
,
688 gGameSettings
.Options
,
690 Length(Stat
.PlayerStat
)
692 // line 2: game specific shit
693 // if it's a team game: red score, blue score
694 // if it's a coop game: monsters killed, monsters total, secrets found, secrets total
696 if Stat
.GameMode
in [GM_TDM
, GM_CTF
] then
698 Format('red_score,blue_score' + LineEnding
+ '%d,%d', [Stat
.TeamStat
[TEAM_RED
].Goals
, Stat
.TeamStat
[TEAM_BLUE
].Goals
]))
699 else if Stat
.GameMode
in [GM_COOP
, GM_SINGLE
] then
701 Format('mon_killed,mon_total,secrets_found,secrets_total' + LineEnding
+ '%d,%d,%d,%d',[gCoopMonstersKilled
, gTotalMonsters
, gCoopSecretsFound
, gSecretsCount
]));
702 // lines 3-...: team, player name, frags, deaths
703 WriteLn(s
, 'team,name,frags,deaths');
704 for I
:= Low(Stat
.PlayerStat
) to High(Stat
.PlayerStat
) do
705 with Stat
.PlayerStat
[I
] do
706 WriteLn(s
, Format('%d,%s,%d,%d', [Team
, dquoteStr(Name
), Frags
, Deaths
]));
708 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_WRITE
], [fname
]));
711 g_Console_Add('could not create gamestats file "' + fname
+ '"');
716 function g_Game_ModeToText(Mode
: Byte): string;
720 GM_DM
: Result
:= _lc
[I_MENU_GAME_TYPE_DM
];
721 GM_TDM
: Result
:= _lc
[I_MENU_GAME_TYPE_TDM
];
722 GM_CTF
: Result
:= _lc
[I_MENU_GAME_TYPE_CTF
];
723 GM_COOP
: Result
:= _lc
[I_MENU_GAME_TYPE_COOP
];
724 GM_SINGLE
: Result
:= _lc
[I_MENU_GAME_TYPE_SINGLE
];
728 function g_Game_TextToMode(Mode
: string): Byte;
731 Mode
:= UpperCase(Mode
);
732 if Mode
= _lc
[I_MENU_GAME_TYPE_DM
] then
737 if Mode
= _lc
[I_MENU_GAME_TYPE_TDM
] then
742 if Mode
= _lc
[I_MENU_GAME_TYPE_CTF
] then
747 if Mode
= _lc
[I_MENU_GAME_TYPE_COOP
] then
752 if Mode
= _lc
[I_MENU_GAME_TYPE_SINGLE
] then
759 function g_Game_IsNet(): Boolean;
761 Result
:= (gGameSettings
.GameType
in [GT_SERVER
, GT_CLIENT
]);
764 function g_Game_IsServer(): Boolean;
766 Result
:= (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
, GT_SERVER
]);
769 function g_Game_IsClient(): Boolean;
771 Result
:= (gGameSettings
.GameType
= GT_CLIENT
);
774 function g_Game_GetMegaWADInfo(WAD
: String): TMegaWADInfo
;
781 Result
.name
:= ExtractFileName(WAD
);
782 Result
.description
:= '';
785 w
:= TWADFile
.Create();
788 if not w
.GetResource('INTERSCRIPT', p
, len
) then
794 cfg
:= TConfig
.CreateMem(p
, len
);
795 Result
.name
:= cfg
.ReadStr('megawad', 'name', ExtractFileName(WAD
));
796 Result
.description
:= cfg
.ReadStr('megawad', 'description', '');
797 Result
.author
:= cfg
.ReadStr('megawad', 'author', '');
798 Result
.pic
:= cfg
.ReadStr('megawad', 'pic', '');
804 procedure g_Game_FreeWAD();
808 for a
:= 0 to High(MegaWAD
.res
.pic
) do
809 if MegaWAD
.res
.pic
[a
] <> '' then
810 g_Texture_Delete(MegaWAD
.res
.pic
[a
]);
812 for a
:= 0 to High(MegaWAD
.res
.mus
) do
813 if MegaWAD
.res
.mus
[a
] <> '' then
814 g_Sound_Delete(MegaWAD
.res
.mus
[a
]);
816 MegaWAD
.res
.pic
:= nil;
817 MegaWAD
.res
.text := nil;
818 MegaWAD
.res
.anim
:= nil;
819 MegaWAD
.res
.mus
:= nil;
820 MegaWAD
.triggers
:= nil;
822 g_Texture_Delete('TEXTURE_endpic');
823 g_Sound_Delete('MUSIC_endmus');
825 ZeroMemory(@MegaWAD
, SizeOf(MegaWAD
));
826 gGameSettings
.WAD
:= '';
829 procedure g_Game_LoadWAD(WAD
: string);
838 gGameSettings
.WAD
:= WAD
;
839 if not (gGameSettings
.GameMode
in [GM_COOP
, GM_SINGLE
]) then
842 MegaWAD
.info
:= g_Game_GetMegaWADInfo(WAD
);
844 w
:= TWADFile
.Create();
847 if not w
.GetResource('INTERSCRIPT', p
, len
) then
853 cfg
:= TConfig
.CreateMem(p
, len
);
858 s := cfg.ReadStr('pic', 'pic'+IntToStr(b), '');
859 if s = '' then Break;
862 SetLength(MegaWAD.res.pic, Length(MegaWAD.res.pic)+1);
863 MegaWAD.res.pic[High(MegaWAD.res.pic)] := s;
865 g_Texture_CreateWADEx(s, s);
871 s := cfg.ReadStr('mus', 'mus'+IntToStr(b), '');
872 if s = '' then Break;
875 SetLength(MegaWAD.res.mus, Length(MegaWAD.res.mus)+1);
876 MegaWAD.res.mus[High(MegaWAD.res.mus)] := s;
878 g_Music_CreateWADEx(s, s);
881 MegaWAD
.endpic
:= cfg
.ReadStr('megawad', 'endpic', '');
882 if MegaWAD
.endpic
<> '' then
884 TEXTUREFILTER
:= GL_LINEAR
;
885 s
:= e_GetResourcePath(WadDirs
, MegaWAD
.endpic
, WAD
);
886 g_Texture_CreateWADEx('TEXTURE_endpic', s
);
887 TEXTUREFILTER
:= GL_NEAREST
;
889 MegaWAD
.endmus
:= cfg
.ReadStr('megawad', 'endmus', 'Standart.wad:D2DMUS\ÊÎÍÅÖ');
890 if MegaWAD
.endmus
<> '' then
892 s
:= e_GetResourcePath(WadDirs
, MegaWAD
.endmus
, WAD
);
893 g_Sound_CreateWADEx('MUSIC_endmus', s
, True);
901 {procedure start_trigger(t: string);
905 function next_trigger(): Boolean;
909 procedure DisableCheats();
915 if gPlayer1
<> nil then gPlayer1
.GodMode
:= False;
916 if gPlayer2
<> nil then gPlayer2
.GodMode
:= False;
917 if gPlayer1
<> nil then gPlayer1
.NoTarget
:= False;
918 if gPlayer2
<> nil then gPlayer2
.NoTarget
:= False;
920 {$IF DEFINED(D2F_DEBUG)}
921 if gPlayer1
<> nil then gPlayer1
.NoTarget
:= True;
922 gAimLine
:= g_dbg_aimline_on
;
926 procedure g_Game_ExecuteEvent(Name
: String);
932 if gEvents
= nil then
934 for a
:= 0 to High(gEvents
) do
935 if gEvents
[a
].Name
= Name
then
937 if gEvents
[a
].Command
<> '' then
938 g_Console_Process(gEvents
[a
].Command
, True);
943 function g_Game_DelayEvent(DEType
: Byte; Time
: LongWord; Num
: Integer = 0; Str
: String = ''): Integer;
948 if gDelayedEvents
<> nil then
949 for a
:= 0 to High(gDelayedEvents
) do
950 if not gDelayedEvents
[a
].Pending
then
957 SetLength(gDelayedEvents
, Length(gDelayedEvents
) + 1);
958 n
:= High(gDelayedEvents
);
960 gDelayedEvents
[n
].Pending
:= True;
961 gDelayedEvents
[n
].DEType
:= DEType
;
962 gDelayedEvents
[n
].DENum
:= Num
;
963 gDelayedEvents
[n
].DEStr
:= Str
;
964 if DEType
= DE_GLOBEVENT
then
965 gDelayedEvents
[n
].Time
:= (sys_GetTicks() {div 1000}) + Time
967 gDelayedEvents
[n
].Time
:= gTime
+ Time
;
977 if g_Game_IsNet
and g_Game_IsServer
then
978 MH_SEND_GameEvent(NET_EV_MAPEND
, Byte(gMissionFailed
));
982 gPauseHolmes
:= false;
985 g_Game_StopAllSounds(False);
990 EndingGameCounter
:= 0;
991 g_ActiveWindow
:= nil;
993 gLMSRespawn
:= LMS_RESPAWN_NONE
;
994 gLMSRespawnTime
:= 0;
997 EXIT_SIMPLE
: // Âûõîä ÷åðåç ìåíþ èëè êîíåö òåñòà
1002 begin // Ýòî áûë òåñò
1006 begin // Âûõîä â ãëàâíîå ìåíþ
1007 gMusic
.SetByName('MUSIC_MENU');
1009 if gState
<> STATE_SLIST
then
1011 g_GUI_ShowWindow('MainMenu');
1012 gState
:= STATE_MENU
;
1015 // Îáíîâëÿåì ñïèñîê ñåðâåðîâ
1016 slReturnPressed
:= True;
1017 if g_Net_Slist_Fetch(slCurrent
) then
1019 if slCurrent
= nil then
1020 slWaitStr
:= _lc
[I_NET_SLIST_NOSERVERS
];
1023 slWaitStr
:= _lc
[I_NET_SLIST_ERROR
];
1024 g_Serverlist_GenerateTable(slCurrent
, slTable
);
1027 g_Game_ExecuteEvent('ongameend');
1031 EXIT_RESTART
: // Íà÷àòü óðîâåíü ñíà÷àëà
1033 if not g_Game_IsClient
then g_Game_Restart();
1036 EXIT_ENDLEVELCUSTOM
: // Çàêîí÷èëñÿ óðîâåíü â Ñâîåé èãðå
1038 // Ñòàòèñòèêà Ñâîåé èãðû:
1039 FileName
:= g_ExtractWadName(gMapInfo
.Map
);
1041 CustomStat
.GameTime
:= gTime
;
1042 CustomStat
.Map
:= ExtractFileName(FileName
)+':'+g_ExtractFileName(gMapInfo
.Map
); //ResName;
1043 CustomStat
.MapName
:= gMapInfo
.Name
;
1044 CustomStat
.GameMode
:= gGameSettings
.GameMode
;
1045 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
1046 CustomStat
.TeamStat
:= gTeamStat
;
1048 CustomStat
.PlayerStat
:= nil;
1050 // Ñòàòèñòèêà èãðîêîâ:
1051 if gPlayers
<> nil then
1053 for a
:= 0 to High(gPlayers
) do
1054 if gPlayers
[a
] <> nil then
1056 SetLength(CustomStat
.PlayerStat
, Length(CustomStat
.PlayerStat
)+1);
1057 with CustomStat
.PlayerStat
[High(CustomStat
.PlayerStat
)] do
1060 Name
:= gPlayers
[a
].Name
;
1061 Frags
:= gPlayers
[a
].Frags
;
1062 Deaths
:= gPlayers
[a
].Death
;
1063 Kills
:= gPlayers
[a
].Kills
;
1064 Team
:= gPlayers
[a
].Team
;
1065 Color
:= gPlayers
[a
].Model
.Color
;
1066 Spectator
:= gPlayers
[a
].FSpectator
;
1070 SortGameStat(CustomStat
.PlayerStat
);
1072 if (gSaveStats
or gScreenshotStats
) and (Length(CustomStat
.PlayerStat
) > 1) then
1075 if g_Game_IsNet
then StatFilename
:= NetServerName
else StatFilename
:= 'local';
1076 StatDate
:= FormatDateTime('yymmdd_hhnnss', t
);
1077 StatFilename
:= StatFilename
+ '_' + CustomStat
.Map
+ '_' + g_Game_ModeToText(CustomStat
.GameMode
);
1078 StatFilename
:= sanitizeFilename(StatFilename
) + '_' + StatDate
;
1080 SaveGameStat(CustomStat
, FormatDateTime('yyyy"/"mm"/"dd', t
));
1083 StatShotDone
:= False;
1086 g_Game_ExecuteEvent('onmapend');
1087 if not g_Game_IsClient
then g_Player_ResetReady
;
1088 gInterReadyCount
:= 0;
1090 // Çàòóõàþùèé ýêðàí:
1091 EndingGameCounter
:= 255;
1092 gState
:= STATE_FOLD
;
1094 if gDefInterTime
< 0 then
1095 gInterEndTime
:= IfThen((gGameSettings
.GameType
= GT_SERVER
) and (gPlayer1
= nil), 15000, 25000)
1097 gInterEndTime
:= gDefInterTime
* 1000;
1100 EXIT_ENDLEVELSINGLE
: // Çàêîí÷èëñÿ óðîâåíü â Îäèíî÷íîé èãðå
1102 // Ñòàòèñòèêà Îäèíî÷íîé èãðû:
1103 SingleStat
.GameTime
:= gTime
;
1104 SingleStat
.TwoPlayers
:= gPlayer2
<> nil;
1105 SingleStat
.TotalSecrets
:= gSecretsCount
;
1106 // Ñòàòèñòèêà ïåðâîãî èãðîêà:
1107 SingleStat
.PlayerStat
[0].Kills
:= gPlayer1
.MonsterKills
;
1108 SingleStat
.PlayerStat
[0].Secrets
:= gPlayer1
.Secrets
;
1109 // Ñòàòèñòèêà âòîðîãî èãðîêà (åñëè åñòü):
1110 if SingleStat
.TwoPlayers
then
1112 SingleStat
.PlayerStat
[1].Kills
:= gPlayer2
.MonsterKills
;
1113 SingleStat
.PlayerStat
[1].Secrets
:= gPlayer2
.Secrets
;
1116 g_Game_ExecuteEvent('onmapend');
1119 if gNextMap
<> '' then
1121 gMusic
.SetByName('MUSIC_INTERMUS');
1123 gState
:= STATE_INTERSINGLE
;
1126 g_Game_ExecuteEvent('oninter');
1128 else // Áîëüøå íåò êàðò
1130 // Çàòóõàþùèé ýêðàí:
1131 EndingGameCounter
:= 255;
1132 gState
:= STATE_FOLD
;
1137 // Îêîí÷àíèå îáðàáîòàíî:
1138 if gExit
<> EXIT_QUIT
then
1142 procedure drawTime(X
, Y
: Integer); inline;
1144 e_TextureFontPrint(x
, y
,
1145 Format('%d:%.2d:%.2d', [
1146 gTime
div 1000 div 3600,
1147 (gTime
div 1000 div 60) mod 60,
1148 gTime
div 1000 mod 60
1153 procedure DrawStat();
1155 pc
, x
, y
, w
, h
: Integer;
1156 w1
, w2
, w3
, w4
: Integer;
1158 cw
, ch
, r
, g
, b
, rr
, gg
, bb
: Byte;
1161 stat
: TPlayerStatArray
;
1168 pc
:= g_Player_GetCount
;
1169 e_TextureFontGetSize(gStdFont
, cw
, ch
);
1171 w
:= gScreenWidth
-(gScreenWidth
div 5);
1172 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
1175 h
:= 40+ch
*5+(ch
+8)*pc
;
1176 x
:= (gScreenWidth
div 2)-(w
div 2);
1177 y
:= (gScreenHeight
div 2)-(h
div 2);
1179 e_DrawFillQuad(x
, y
, x
+w
-1, y
+h
-1, 64, 64, 64, 32);
1180 e_DrawQuad(x
, y
, x
+w
-1, y
+h
-1, 255, 127, 0);
1182 drawTime(x
+w
-78, y
+8);
1184 wad
:= g_ExtractWadNameNoPath(gMapInfo
.Map
);
1185 map
:= g_ExtractFileName(gMapInfo
.Map
);
1186 mapstr
:= wad
+ ':\' + map
+ ' - ' + gMapInfo
.Name
;
1188 case gGameSettings
.GameMode
of
1191 if gGameSettings
.MaxLives
= 0 then
1192 s1
:= _lc
[I_GAME_DM
]
1194 s1
:= _lc
[I_GAME_LMS
];
1195 s2
:= Format(_lc
[I_GAME_FRAG_LIMIT
], [gGameSettings
.GoalLimit
]);
1196 s3
:= Format(_lc
[I_GAME_TIME_LIMIT
], [gGameSettings
.TimeLimit
div 3600, (gGameSettings
.TimeLimit
div 60) mod 60, gGameSettings
.TimeLimit
mod 60]);
1201 if gGameSettings
.MaxLives
= 0 then
1202 s1
:= _lc
[I_GAME_TDM
]
1204 s1
:= _lc
[I_GAME_TLMS
];
1205 s2
:= Format(_lc
[I_GAME_FRAG_LIMIT
], [gGameSettings
.GoalLimit
]);
1206 s3
:= Format(_lc
[I_GAME_TIME_LIMIT
], [gGameSettings
.TimeLimit
div 3600, (gGameSettings
.TimeLimit
div 60) mod 60, gGameSettings
.TimeLimit
mod 60]);
1211 s1
:= _lc
[I_GAME_CTF
];
1212 s2
:= Format(_lc
[I_GAME_SCORE_LIMIT
], [gGameSettings
.GoalLimit
]);
1213 s3
:= Format(_lc
[I_GAME_TIME_LIMIT
], [gGameSettings
.TimeLimit
div 3600, (gGameSettings
.TimeLimit
div 60) mod 60, gGameSettings
.TimeLimit
mod 60]);
1218 if gGameSettings
.MaxLives
= 0 then
1219 s1
:= _lc
[I_GAME_COOP
]
1221 s1
:= _lc
[I_GAME_SURV
];
1222 s2
:= _lc
[I_GAME_MONSTERS
] + ' ' + IntToStr(gCoopMonstersKilled
) + '/' + IntToStr(gTotalMonsters
);
1223 s3
:= _lc
[I_GAME_SECRETS
] + ' ' + IntToStr(gCoopSecretsFound
) + '/' + IntToStr(gSecretsCount
);
1234 e_TextureFontPrintEx(x
+(w
div 2)-(Length(s1
)*cw
div 2), _y
, s1
, gStdFont
, 255, 255, 255, 1);
1236 e_TextureFontPrintEx(x
+(w
div 2)-(Length(mapstr
)*cw
div 2), _y
, mapstr
, gStdFont
, 200, 200, 200, 1);
1238 e_TextureFontPrintEx(x
+16, _y
, s2
, gStdFont
, 200, 200, 200, 1);
1240 e_TextureFontPrintEx(x
+w
-16-(Length(s3
))*cw
, _y
, s3
,
1241 gStdFont
, 200, 200, 200, 1);
1243 if NetMode
= NET_SERVER
then
1244 e_TextureFontPrintEx(x
+8, y
+ 8, _lc
[I_NET_SERVER
], gStdFont
, 255, 255, 255, 1)
1246 if NetMode
= NET_CLIENT
then
1247 e_TextureFontPrintEx(x
+8, y
+ 8,
1248 NetClientIP
+ ':' + IntToStr(NetClientPort
), gStdFont
, 255, 255, 255, 1);
1252 stat
:= g_Player_GetStats();
1255 w2
:= (w
-16) div 6 + 48; // øèðèíà 2 ñòîëáöà
1256 w3
:= (w
-16) div 6; // øèðèíà 3 è 4 ñòîëáöîâ
1258 w1
:= w
-16-w2
-w3
-w4
; // îñòàâøååñÿ ïðîñòðàíñòâî - äëÿ öâåòà è èìåíè èãðîêà
1260 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
1264 for a
:= TEAM_RED
to TEAM_BLUE
do
1266 if a
= TEAM_RED
then
1268 s1
:= _lc
[I_GAME_TEAM_RED
];
1275 s1
:= _lc
[I_GAME_TEAM_BLUE
];
1281 e_TextureFontPrintEx(x
+16, _y
, s1
, gStdFont
, r
, g
, b
, 1);
1282 e_TextureFontPrintEx(x
+w1
+16, _y
, IntToStr(gTeamStat
[a
].Goals
),
1283 gStdFont
, r
, g
, b
, 1);
1285 _y
:= _y
+ch
+(ch
div 4);
1286 e_DrawLine(1, x
+16, _y
, x
+w
-16, _y
, r
, g
, b
);
1287 _y
:= _y
+(ch
div 4);
1289 for aa
:= 0 to High(stat
) do
1290 if stat
[aa
].Team
= a
then
1306 e_TextureFontPrintEx(x
+16, _y
, Name
, gStdFont
, rr
, gg
, bb
, 1);
1308 e_TextureFontPrintEx(x
+w1
+16, _y
, Format(_lc
[I_GAME_PING_MS
], [Ping
, Loss
]), gStdFont
, rr
, gg
, bb
, 1);
1310 e_TextureFontPrintEx(x
+w1
+w2
+16, _y
, IntToStr(Frags
), gStdFont
, rr
, gg
, bb
, 1);
1312 e_TextureFontPrintEx(x
+w1
+w2
+w3
+16, _y
, IntToStr(Deaths
), gStdFont
, rr
, gg
, bb
, 1);
1319 else if gGameSettings
.GameMode
in [GM_DM
, GM_COOP
] then
1322 e_TextureFontPrintEx(x
+16, _y
, _lc
[I_GAME_PLAYER_NAME
], gStdFont
, 255, 127, 0, 1);
1323 e_TextureFontPrintEx(x
+16+w1
, _y
, _lc
[I_GAME_PING
], gStdFont
, 255, 127, 0, 1);
1324 e_TextureFontPrintEx(x
+16+w1
+w2
, _y
, _lc
[I_GAME_FRAGS
], gStdFont
, 255, 127, 0, 1);
1325 e_TextureFontPrintEx(x
+16+w1
+w2
+w3
, _y
, _lc
[I_GAME_DEATHS
], gStdFont
, 255, 127, 0, 1);
1328 for aa
:= 0 to High(stat
) do
1342 e_DrawFillQuad(x
+16, _y
+4, x
+32-1, _y
+16+4-1, Color
.R
, Color
.G
, Color
.B
, 0);
1343 e_DrawQuad(x
+16, _y
+4, x
+32-1, _y
+16+4-1, 192, 192, 192);
1345 e_TextureFontPrintEx(x
+16+16+8, _y
+4, Name
, gStdFont
, r
, g
, 0, 1);
1347 e_TextureFontPrintEx(x
+w1
+16, _y
+4, Format(_lc
[I_GAME_PING_MS
], [Ping
, Loss
]), gStdFont
, r
, g
, 0, 1);
1349 e_TextureFontPrintEx(x
+w1
+w2
+16, _y
+4, IntToStr(Frags
), gStdFont
, r
, g
, 0, 1);
1351 e_TextureFontPrintEx(x
+w1
+w2
+w3
+16, _y
+4, IntToStr(Deaths
), gStdFont
, r
, g
, 0, 1);
1357 procedure g_Game_Init();
1360 knownFiles
: array of AnsiString = nil;
1362 wext
, s
: AnsiString;
1367 gTempDelete
:= False;
1369 sfsGCDisable(); // temporary disable removing of temporary volumes
1372 TEXTUREFILTER
:= GL_LINEAR
;
1373 g_Texture_CreateWADEx('MENU_BACKGROUND', GameWAD
+':TEXTURES\TITLE');
1374 g_Texture_CreateWADEx('INTER', GameWAD
+':TEXTURES\INTER');
1375 g_Texture_CreateWADEx('ENDGAME_EN', GameWAD
+':TEXTURES\ENDGAME_EN');
1376 g_Texture_CreateWADEx('ENDGAME_RU', GameWAD
+':TEXTURES\ENDGAME_RU');
1377 TEXTUREFILTER
:= GL_NEAREST
;
1379 LoadStdFont('STDTXT', 'STDFONT', gStdFont
);
1380 LoadFont('MENUTXT', 'MENUFONT', gMenuFont
);
1381 LoadFont('SMALLTXT', 'SMALLFONT', gMenuSmallFont
);
1383 g_Game_ClearLoading();
1384 g_Game_SetLoadingText(Format('Doom 2D: Forever %s', [GAME_VERSION
]), 0, False);
1385 g_Game_SetLoadingText('', 0, False);
1387 g_Game_SetLoadingText(_lc
[I_LOAD_CONSOLE
], 0, False);
1390 g_Game_SetLoadingText(_lc
[I_LOAD_MODELS
], 0, False);
1391 g_PlayerModel_LoadData();
1393 // load models from all possible wad types, in all known directories
1394 // this does a loosy job (linear search, ooph!), but meh
1395 for wext
in wadExtensions
do
1397 for f
:= High(ModelDirs
) downto Low(ModelDirs
) do
1399 if (FindFirst(ModelDirs
[f
]+DirectorySeparator
+'*'+wext
, faAnyFile
, SR
) = 0) then
1403 for s
in knownFiles
do
1405 if (strEquCI1251(forceFilenameExt(SR
.Name
, ''), forceFilenameExt(ExtractFileName(s
), ''))) then
1413 SetLength(knownFiles
, length(knownFiles
)+1);
1414 knownFiles
[High(knownFiles
)] := ModelDirs
[f
]+DirectorySeparator
+SR
.Name
;
1416 until (FindNext(SR
) <> 0);
1422 if (length(knownFiles
) = 0) then raise Exception
.Create('no player models found!');
1424 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
);
1425 for s
in knownFiles
do
1427 if not g_PlayerModel_Load(s
) then e_LogWritefln('Error loading model "%s"', [s
], TMsgType
.Warning
);
1431 gPauseMain
:= false;
1432 gPauseHolmes
:= false;
1435 {e_MouseInfo.Accel := 1.0;}
1437 g_Game_SetLoadingText(_lc
[I_LOAD_GAME_DATA
], 0, False);
1440 g_Game_SetLoadingText(_lc
[I_LOAD_MUSIC
], 0, False);
1441 g_Sound_CreateWADEx('MUSIC_INTERMUS', GameWAD
+':MUSIC\INTERMUS', True);
1442 g_Sound_CreateWADEx('MUSIC_MENU', GameWAD
+':MUSIC\MENU', True);
1443 g_Sound_CreateWADEx('MUSIC_ROUNDMUS', GameWAD
+':MUSIC\ROUNDMUS', True, True);
1444 g_Sound_CreateWADEx('MUSIC_STDENDMUS', GameWAD
+':MUSIC\ENDMUS', True);
1447 g_Game_SetLoadingText(_lc
[I_LOAD_MENUS
], 0, False);
1451 gMusic
:= TMusic
.Create();
1452 gMusic
.SetByName('MUSIC_MENU');
1455 gGameSettings
.WarmupTime
:= 30;
1457 gState
:= STATE_MENU
;
1459 SetLength(gEvents
, 6);
1460 gEvents
[0].Name
:= 'ongamestart';
1461 gEvents
[1].Name
:= 'ongameend';
1462 gEvents
[2].Name
:= 'onmapstart';
1463 gEvents
[3].Name
:= 'onmapend';
1464 gEvents
[4].Name
:= 'oninter';
1465 gEvents
[5].Name
:= 'onwadend';
1467 sfsGCEnable(); // enable releasing unused volumes
1471 procedure g_Game_Free(freeTextures
: Boolean=true);
1473 if NetMode
= NET_CLIENT
then g_Net_Disconnect();
1474 if NetMode
= NET_SERVER
then g_Net_Host_Die();
1476 g_Map_Free(freeTextures
);
1478 g_Player_RemoveAllCorpses();
1480 gGameSettings
.GameType
:= GT_NONE
;
1481 if gGameSettings
.GameMode
= GM_SINGLE
then
1482 gGameSettings
.GameMode
:= GM_DM
;
1483 gSwitchGameMode
:= gGameSettings
.GameMode
;
1486 gExitByTrigger
:= False;
1489 function IsActivePlayer(p
: TPlayer
): Boolean;
1494 Result
:= (not p
.FDummy
) and (not p
.FSpectator
);
1497 function GetActivePlayer_ByID(ID
: Integer): TPlayer
;
1504 if gPlayers
= nil then
1506 for a
:= Low(gPlayers
) to High(gPlayers
) do
1507 if IsActivePlayer(gPlayers
[a
]) then
1509 if gPlayers
[a
].UID
<> ID
then
1511 Result
:= gPlayers
[a
];
1516 function GetActivePlayerID_Next(Skip
: Integer = -1): Integer;
1522 if gPlayers
= nil then
1526 for a
:= Low(gPlayers
) to High(gPlayers
) do
1527 if IsActivePlayer(gPlayers
[a
]) then
1529 SetLength(ids
, Length(ids
) + 1);
1530 ids
[High(ids
)] := gPlayers
[a
].UID
;
1531 if gPlayers
[a
].UID
= Skip
then
1534 if Length(ids
) = 0 then
1539 Result
:= ids
[(idx
+ 1) mod Length(ids
)];
1542 function GetActivePlayerID_Prev(Skip
: Integer = -1): Integer;
1548 if gPlayers
= nil then
1552 for a
:= Low(gPlayers
) to High(gPlayers
) do
1553 if IsActivePlayer(gPlayers
[a
]) then
1555 SetLength(ids
, Length(ids
) + 1);
1556 ids
[High(ids
)] := gPlayers
[a
].UID
;
1557 if gPlayers
[a
].UID
= Skip
then
1560 if Length(ids
) = 0 then
1563 Result
:= ids
[Length(ids
) - 1]
1565 Result
:= ids
[(Length(ids
) - 1 + idx
) mod Length(ids
)];
1568 function GetActivePlayerID_Random(Skip
: Integer = -1): Integer;
1574 if gPlayers
= nil then
1578 for a
:= Low(gPlayers
) to High(gPlayers
) do
1579 if IsActivePlayer(gPlayers
[a
]) then
1581 SetLength(ids
, Length(ids
) + 1);
1582 ids
[High(ids
)] := gPlayers
[a
].UID
;
1583 if gPlayers
[a
].UID
= Skip
then
1586 if Length(ids
) = 0 then
1588 if Length(ids
) = 1 then
1593 Result
:= ids
[Random(Length(ids
))];
1595 while (idx
<> -1) and (Result
= Skip
) and (a
> 0) do
1597 Result
:= ids
[Random(Length(ids
))];
1602 function GetRandomSpectMode(Current
: Byte): Byte;
1609 0: Result
:= SPECT_STATS
;
1610 1: Result
:= SPECT_MAPVIEW
;
1611 2: Result
:= SPECT_MAPVIEW
;
1612 3: Result
:= SPECT_PLAYERS
;
1613 4: Result
:= SPECT_PLAYERS
;
1614 5: Result
:= SPECT_PLAYERS
;
1615 6: Result
:= SPECT_PLAYERS
;
1617 if (Current
in [SPECT_STATS
, SPECT_MAPVIEW
]) and (Current
= Result
) then
1621 procedure ProcessPlayerControls (plr
: TPlayer
; p
: Integer; var MoveButton
: Byte);
1627 if (plr
= nil) then exit
;
1628 if (p
= 2) then time
:= 1000 else time
:= 1;
1629 strafeDir
:= MoveButton
shr 4;
1630 MoveButton
:= MoveButton
and $0F;
1632 if gPlayerAction
[p
, ACTION_MOVELEFT
] and (not gPlayerAction
[p
, ACTION_MOVERIGHT
]) then
1633 MoveButton
:= 1 // Íàæàòà òîëüêî "Âëåâî"
1634 else if (not gPlayerAction
[p
, ACTION_MOVELEFT
]) and gPlayerAction
[p
, ACTION_MOVERIGHT
] then
1635 MoveButton
:= 2 // Íàæàòà òîëüêî "Âïðàâî"
1636 else if (not gPlayerAction
[p
, ACTION_MOVELEFT
]) and (not gPlayerAction
[p
, ACTION_MOVERIGHT
]) then
1637 MoveButton
:= 0; // Íå íàæàòû íè "Âëåâî", íè "Âïðàâî"
1639 // Ñåé÷àñ èëè ðàíüøå áûëè íàæàòû "Âëåâî"/"Âïðàâî" => ïåðåäàåì èãðîêó:
1640 if MoveButton
= 1 then
1641 plr
.PressKey(KEY_LEFT
, time
)
1642 else if MoveButton
= 2 then
1643 plr
.PressKey(KEY_RIGHT
, time
);
1645 // if we have "strafe" key, turn off old strafe mechanics
1646 if gPlayerAction
[p
, ACTION_STRAFE
] then
1648 // new strafe mechanics
1649 if (strafeDir
= 0) then
1650 strafeDir
:= MoveButton
; // start strafing
1651 // now set direction according to strafe (reversed)
1652 if (strafeDir
= 2) then
1653 plr
.SetDirection(TDirection
.D_LEFT
)
1654 else if (strafeDir
= 1) then
1655 plr
.SetDirection(TDirection
.D_RIGHT
)
1659 strafeDir
:= 0; // not strafing anymore
1660 // Ðàíüøå áûëà íàæàòà "Âïðàâî", à ñåé÷àñ "Âëåâî" => áåæèì âïðàâî, ñìîòðèì âëåâî:
1661 if (MoveButton
= 2) and gPlayerAction
[p
, ACTION_MOVELEFT
] then
1662 plr
.SetDirection(TDirection
.D_LEFT
)
1663 // Ðàíüøå áûëà íàæàòà "Âëåâî", à ñåé÷àñ "Âïðàâî" => áåæèì âëåâî, ñìîòðèì âïðàâî:
1664 else if (MoveButton
= 1) and gPlayerAction
[p
, ACTION_MOVERIGHT
] then
1665 plr
.SetDirection(TDirection
.D_RIGHT
)
1666 // ×òî-òî áûëî íàæàòî è íå èçìåíèëîñü => êóäà áåæèì, òóäà è ñìîòðèì:
1667 else if MoveButton
<> 0 then
1668 plr
.SetDirection(TDirection(MoveButton
-1))
1671 // fix movebutton state
1672 MoveButton
:= MoveButton
or (strafeDir
shl 4);
1674 // Îñòàëüíûå êëàâèøè:
1675 if gPlayerAction
[p
, ACTION_JUMP
] then plr
.PressKey(KEY_JUMP
, time
);
1676 if gPlayerAction
[p
, ACTION_LOOKUP
] then plr
.PressKey(KEY_UP
, time
);
1677 if gPlayerAction
[p
, ACTION_LOOKDOWN
] then plr
.PressKey(KEY_DOWN
, time
);
1678 if gPlayerAction
[p
, ACTION_ATTACK
] then plr
.PressKey(KEY_FIRE
);
1679 if gPlayerAction
[p
, ACTION_WEAPNEXT
] then plr
.PressKey(KEY_NEXTWEAPON
);
1680 if gPlayerAction
[p
, ACTION_WEAPPREV
] then plr
.PressKey(KEY_PREVWEAPON
);
1681 if gPlayerAction
[p
, ACTION_ACTIVATE
] then plr
.PressKey(KEY_OPEN
);
1683 gPlayerAction
[p
, ACTION_WEAPNEXT
] := False; // HACK, remove after readyweaon&pendinweapon implementation
1684 gPlayerAction
[p
, ACTION_WEAPPREV
] := False; // HACK, remove after readyweaon&pendinweapon implementation
1686 for i
:= WP_FIRST
to WP_LAST
do
1688 if gSelectWeapon
[p
, i
] then
1690 plr
.QueueWeaponSwitch(i
); // all choices are passed there, and god will take the best
1691 gSelectWeapon
[p
, i
] := False
1695 // HACK: add dynlight here
1696 if gwin_k8_enable_light_experiments
then
1698 if e_KeyPressed(IK_F8
) and gGameOn
and (not gConsoleShow
) and (g_ActiveWindow
= nil) then
1700 g_playerLight
:= true;
1702 if e_KeyPressed(IK_F9
) and gGameOn
and (not gConsoleShow
) and (g_ActiveWindow
= nil) then
1704 g_playerLight
:= false;
1708 if gwin_has_stencil
and g_playerLight
then g_AddDynLight(plr
.GameX
+32, plr
.GameY
+40, 128, 1, 1, 0, 0.6);
1711 // HACK: don't have a "key was pressed" function
1712 procedure InterReady();
1714 if InterReadyTime
> gTime
then Exit
;
1715 InterReadyTime
:= gTime
+ 3000;
1716 MC_SEND_CheatRequest(NET_CHEAT_READY
);
1719 procedure g_Game_Update();
1721 Msg
: g_gui
.TMessage
;
1727 function sendMonsPos (mon
: TMonster
): Boolean;
1729 result
:= false; // don't stop
1730 // this will also reset "need-send" flag
1731 if mon
.gncNeedSend
then
1733 MH_SEND_MonsterPos(mon
.UID
);
1735 else if (mon
.MonsterType
= MONSTER_BARREL
) then
1737 if (mon
.GameVelX
<> 0) or (mon
.GameVelY
<> 0) then MH_SEND_MonsterPos(mon
.UID
);
1739 else if (mon
.MonsterState
<> MONSTATE_SLEEP
) then
1741 if (mon
.MonsterState
<> MONSTATE_DEAD
) or (mon
.GameVelX
<> 0) or (mon
.GameVelY
<> 0) then MH_SEND_MonsterPos(mon
.UID
);
1745 function sendMonsPosUnexpected (mon
: TMonster
): Boolean;
1747 result
:= false; // don't stop
1748 // this will also reset "need-send" flag
1749 if mon
.gncNeedSend
then MH_SEND_MonsterPos(mon
.UID
);
1753 reliableUpdate
: Boolean;
1758 // Ïîðà âûêëþ÷àòü èãðó:
1759 if gExit
= EXIT_QUIT
then
1761 // Èãðà çàêîí÷èëàñü - îáðàáàòûâàåì:
1765 if gExit
= EXIT_QUIT
then
1769 // ×èòàåì êëàâèàòóðó è äæîéñòèê, åñëè îêíî àêòèâíî
1770 // no need to, as we'll do it in event handler
1772 // Îáíîâëÿåì êîíñîëü (äâèæåíèå è ñîîáùåíèÿ):
1775 if (NetMode
= NET_NONE
) and (g_Game_IsNet
) and (gGameOn
or (gState
in [STATE_FOLD
, STATE_INTERCUSTOM
])) then
1777 gExit
:= EXIT_SIMPLE
;
1782 // process master server communications
1783 g_Net_Slist_Pulse();
1786 STATE_INTERSINGLE
, // Ñòàòèñòêà ïîñëå ïðîõîæäåíèÿ óðîâíÿ â Îäèíî÷íîé èãðå
1787 STATE_INTERCUSTOM
, // Ñòàòèñòêà ïîñëå ïðîõîæäåíèÿ óðîâíÿ â Ñâîåé èãðå
1788 STATE_INTERTEXT
, // Òåêñò ìåæäó óðîâíÿìè
1789 STATE_INTERPIC
: // Êàðòèíêà ìåæäó óðîâíÿìè
1791 if g_Game_IsNet
and g_Game_IsServer
then
1793 gInterTime
:= gInterTime
+ GAME_TICK
;
1794 a
:= Min((gInterEndTime
- gInterTime
) div 1000 + 1, 255);
1795 if a
<> gServInterTime
then
1797 gServInterTime
:= a
;
1798 MH_SEND_TimeSync(gServInterTime
);
1802 if (not g_Game_IsClient
) and
1806 e_KeyPressed(IK_RETURN
) or e_KeyPressed(IK_KPRETURN
) or e_KeyPressed(IK_SPACE
) or
1807 e_KeyPressed(VK_FIRE
) or e_KeyPressed(VK_OPEN
) or
1808 e_KeyPressed(JOY0_ATTACK
) or e_KeyPressed(JOY1_ATTACK
) or
1809 e_KeyPressed(JOY2_ATTACK
) or e_KeyPressed(JOY3_ATTACK
)
1811 and (not gJustChatted
) and (not gConsoleShow
) and (not gChatShow
)
1812 and (g_ActiveWindow
= nil)
1814 or (g_Game_IsNet
and ((gInterTime
> gInterEndTime
) or ((gInterReadyCount
>= NetClientCount
) and (NetClientCount
> 0))))
1817 begin // Íàæàëè <Enter>/<Ïðîáåë> èëè ïðîøëî äîñòàòî÷íî âðåìåíè:
1818 g_Game_StopAllSounds(True);
1820 if gMapOnce
then // Ýòî áûë òåñò
1821 gExit
:= EXIT_SIMPLE
1823 if gNextMap
<> '' then // Ïåðåõîäèì íà ñëåäóþùóþ êàðòó
1824 g_Game_ChangeMap(gNextMap
)
1825 else // Ñëåäóþùåé êàðòû íåò
1827 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
] then
1829 // Âûõîä â ãëàâíîå ìåíþ:
1831 g_GUI_ShowWindow('MainMenu');
1832 gMusic
.SetByName('MUSIC_MENU');
1834 gState
:= STATE_MENU
;
1837 // Ôèíàëüíàÿ êàðòèíêà:
1838 g_Game_ExecuteEvent('onwadend');
1840 if not gMusic
.SetByName('MUSIC_endmus') then
1841 gMusic
.SetByName('MUSIC_STDENDMUS');
1843 gState
:= STATE_ENDPIC
;
1845 g_Game_ExecuteEvent('ongameend');
1850 else if g_Game_IsClient
and
1853 e_KeyPressed(IK_RETURN
) or e_KeyPressed(IK_KPRETURN
) or e_KeyPressed(IK_SPACE
) or
1854 e_KeyPressed(VK_FIRE
) or e_KeyPressed(VK_OPEN
) or
1855 e_KeyPressed(JOY0_ATTACK
) or e_KeyPressed(JOY1_ATTACK
) or
1856 e_KeyPressed(JOY2_ATTACK
) or e_KeyPressed(JOY3_ATTACK
)
1858 and (not gJustChatted
) and (not gConsoleShow
) and (not gChatShow
)
1859 and (g_ActiveWindow
= nil)
1867 if gState
= STATE_INTERTEXT
then
1868 if InterText
.counter
> 0 then
1869 InterText
.counter
:= InterText
.counter
- 1;
1872 STATE_FOLD
: // Çàòóõàíèå ýêðàíà
1874 if EndingGameCounter
= 0 then
1876 // Çàêîí÷èëñÿ óðîâåíü â Ñâîåé èãðå:
1877 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
1879 InterReadyTime
:= -1;
1880 if gLastMap
and (gGameSettings
.GameMode
= GM_COOP
) then
1882 g_Game_ExecuteEvent('onwadend');
1883 if not gMusic
.SetByName('MUSIC_endmus') then
1884 gMusic
.SetByName('MUSIC_STDENDMUS');
1887 gMusic
.SetByName('MUSIC_ROUNDMUS');
1890 gState
:= STATE_INTERCUSTOM
;
1893 else // Çàêîí÷èëàñü ïîñëåäíÿÿ êàðòà â Îäèíî÷íîé èãðå
1895 gMusic
.SetByName('MUSIC_INTERMUS');
1897 gState
:= STATE_INTERSINGLE
;
1900 g_Game_ExecuteEvent('oninter');
1903 DecMin(EndingGameCounter
, 6, 0);
1906 STATE_ENDPIC
: // Êàðòèíêà îêîí÷àíèÿ ìåãàÂàäà
1908 if gMapOnce
then // Ýòî áûë òåñò
1910 gExit
:= EXIT_SIMPLE
;
1916 g_Serverlist_Control(slCurrent
, slTable
);
1919 // Ñòàòèñòèêà ïî Tab:
1921 IsDrawStat
:= (not gConsoleShow
) and (not gChatShow
) and (gGameSettings
.GameType
<> GT_SINGLE
) and g_Console_Action(ACTION_SCORES
);
1924 if gGameOn
and not gPause
and (gState
<> STATE_FOLD
) then
1926 // Âðåìÿ += 28 ìèëëèñåêóíä:
1927 gTime
:= gTime
+ GAME_TICK
;
1929 // Ñîîáùåíèå ïîñåðåäèíå ýêðàíà:
1930 if MessageTime
= 0 then
1932 if MessageTime
> 0 then
1933 MessageTime
:= MessageTime
- 1;
1935 if (g_Game_IsServer
) then
1937 // Áûë çàäàí ëèìèò âðåìåíè:
1938 if (gGameSettings
.TimeLimit
> 0) then
1939 if (gTime
- gGameStartTime
) div 1000 >= gGameSettings
.TimeLimit
then
1940 begin // Îí ïðîøåë => êîíåö óðîâíÿ
1945 // Íàäî ðåñïàâíèòü èãðîêîâ â LMS:
1946 if (gLMSRespawn
> LMS_RESPAWN_NONE
) and (gLMSRespawnTime
< gTime
) then
1947 g_Game_RestartRound(gLMSSoftSpawn
);
1949 // Ïðîâåðèì ðåçóëüòàò ãîëîñîâàíèÿ, åñëè âðåìÿ ïðîøëî
1950 if gVoteInProgress
and (gVoteTimer
< gTime
) then
1952 else if gVotePassed
and (gVoteCmdTimer
< gTime
) then
1954 g_Console_Process(gVoteCommand
);
1956 gVotePassed
:= False;
1959 // Çàìåðÿåì âðåìÿ çàõâàòà ôëàãîâ
1960 if gFlags
[FLAG_RED
].State
= FLAG_STATE_CAPTURED
then
1961 gFlags
[FLAG_RED
].CaptureTime
:= gFlags
[FLAG_RED
].CaptureTime
+ GAME_TICK
;
1962 if gFlags
[FLAG_BLUE
].State
= FLAG_STATE_CAPTURED
then
1963 gFlags
[FLAG_BLUE
].CaptureTime
:= gFlags
[FLAG_BLUE
].CaptureTime
+ GAME_TICK
;
1965 // Áûë çàäàí ëèìèò ïîáåä:
1966 if (gGameSettings
.GoalLimit
> 0) then
1970 if gGameSettings
.GameMode
= GM_DM
then
1971 begin // Â DM èùåì èãðîêà ñ max ôðàãàìè
1972 for i
:= 0 to High(gPlayers
) do
1973 if gPlayers
[i
] <> nil then
1974 if gPlayers
[i
].Frags
> b
then
1975 b
:= gPlayers
[i
].Frags
;
1978 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
1979 begin //  CTF/TDM âûáèðàåì êîìàíäó ñ íàèáîëüøèì ñ÷åòîì
1980 b
:= Max(gTeamStat
[TEAM_RED
].Goals
, gTeamStat
[TEAM_BLUE
].Goals
);
1983 // Ëèìèò ïîáåä íàáðàí => êîíåö óðîâíÿ:
1984 if b
>= gGameSettings
.GoalLimit
then
1991 // Îáðàáàòûâàåì êëàâèøè èãðîêîâ:
1992 if gPlayer1
<> nil then gPlayer1
.ReleaseKeys();
1993 if gPlayer2
<> nil then gPlayer2
.ReleaseKeys();
1994 if (not gConsoleShow
) and (not gChatShow
) and (g_ActiveWindow
= nil) then
1996 ProcessPlayerControls(gPlayer1
, 0, P1MoveButton
);
1997 ProcessPlayerControls(gPlayer2
, 1, P2MoveButton
);
1998 end // if not console
2001 if g_Game_IsNet
and (gPlayer1
<> nil) then gPlayer1
.PressKey(KEY_CHAT
, 10000);
2003 // process weapon switch queue
2007 if (gPlayer1
= nil) and (gPlayer2
= nil) and
2008 (not gConsoleShow
) and (not gChatShow
) and (g_ActiveWindow
= nil) then
2010 if not gSpectKeyPress
then
2012 if gPlayerAction
[0, ACTION_JUMP
] and (not gSpectAuto
) then
2014 // switch spect mode
2016 SPECT_NONE
: ; // not spectator
2018 SPECT_MAPVIEW
: Inc(gSpectMode
);
2019 SPECT_PLAYERS
: gSpectMode
:= SPECT_STATS
; // reset to 1
2021 gSpectKeyPress
:= True;
2023 if (gSpectMode
= SPECT_MAPVIEW
)
2024 and (not gSpectAuto
) then
2026 if gPlayerAction
[0, ACTION_MOVELEFT
] then
2027 gSpectX
:= Max(gSpectX
- gSpectStep
, 0);
2028 if gPlayerAction
[0, ACTION_MOVERIGHT
] then
2029 gSpectX
:= Min(gSpectX
+ gSpectStep
, gMapInfo
.Width
- gScreenWidth
);
2030 if gPlayerAction
[0, ACTION_LOOKUP
] then
2031 gSpectY
:= Max(gSpectY
- gSpectStep
, 0);
2032 if gPlayerAction
[0, ACTION_LOOKDOWN
] then
2033 gSpectY
:= Min(gSpectY
+ gSpectStep
, gMapInfo
.Height
- gScreenHeight
);
2034 if gPlayerAction
[0, ACTION_WEAPPREV
] then
2037 if gSpectStep
> 4 then gSpectStep
:= gSpectStep
shr 1;
2038 gSpectKeyPress
:= True;
2040 if gPlayerAction
[0, ACTION_WEAPNEXT
] then
2043 if gSpectStep
< 64 then gSpectStep
:= gSpectStep
shl 1;
2044 gSpectKeyPress
:= True;
2047 if (gSpectMode
= SPECT_PLAYERS
)
2048 and (not gSpectAuto
) then
2050 if gPlayerAction
[0, ACTION_LOOKUP
] then
2053 gSpectViewTwo
:= True;
2054 gSpectKeyPress
:= True;
2056 if gPlayerAction
[0, ACTION_LOOKDOWN
] then
2058 // remove second view
2059 gSpectViewTwo
:= False;
2060 gSpectKeyPress
:= True;
2062 if gPlayerAction
[0, ACTION_MOVELEFT
] then
2064 // prev player (view 1)
2065 gSpectPID1
:= GetActivePlayerID_Prev(gSpectPID1
);
2066 gSpectKeyPress
:= True;
2068 if gPlayerAction
[0, ACTION_MOVERIGHT
] then
2070 // next player (view 1)
2071 gSpectPID1
:= GetActivePlayerID_Next(gSpectPID1
);
2072 gSpectKeyPress
:= True;
2074 if gPlayerAction
[0, ACTION_WEAPPREV
] then
2076 // prev player (view 2)
2077 gSpectPID2
:= GetActivePlayerID_Prev(gSpectPID2
);
2078 gSpectKeyPress
:= True;
2080 if gPlayerAction
[0, ACTION_WEAPNEXT
] then
2082 // next player (view 2)
2083 gSpectPID2
:= GetActivePlayerID_Next(gSpectPID2
);
2084 gSpectKeyPress
:= True;
2087 if gPlayerAction
[0, ACTION_ATTACK
] then
2089 if (gSpectMode
= SPECT_STATS
) and (not gSpectAuto
) then
2092 gSpectAutoNext
:= 0;
2093 gSpectViewTwo
:= False;
2094 gSpectKeyPress
:= True;
2099 gSpectMode
:= SPECT_STATS
;
2100 gSpectAuto
:= False;
2101 gSpectKeyPress
:= True;
2106 if (not gPlayerAction
[0, ACTION_JUMP
]) and
2107 (not gPlayerAction
[0, ACTION_ATTACK
]) and
2108 (not gPlayerAction
[0, ACTION_MOVELEFT
]) and
2109 (not gPlayerAction
[0, ACTION_MOVERIGHT
]) and
2110 (not gPlayerAction
[0, ACTION_LOOKUP
]) and
2111 (not gPlayerAction
[0, ACTION_LOOKDOWN
]) and
2112 (not gPlayerAction
[0, ACTION_WEAPPREV
]) and
2113 (not gPlayerAction
[0, ACTION_WEAPNEXT
]) then
2114 gSpectKeyPress
:= False;
2118 if gSpectMode
= SPECT_MAPVIEW
then
2120 i
:= Min(Max(gSpectX
+ gSpectAutoStepX
, 0), gMapInfo
.Width
- gScreenWidth
);
2122 gSpectAutoNext
:= gTime
2125 i
:= Min(Max(gSpectY
+ gSpectAutoStepY
, 0), gMapInfo
.Height
- gScreenHeight
);
2127 gSpectAutoNext
:= gTime
2131 if gSpectAutoNext
<= gTime
then
2133 if gSpectAutoNext
> 0 then
2135 gSpectMode
:= GetRandomSpectMode(gSpectMode
);
2139 gSpectX
:= Random(gMapInfo
.Width
- gScreenWidth
);
2140 gSpectY
:= Random(gMapInfo
.Height
- gScreenHeight
);
2141 gSpectAutoStepX
:= Random(9) - 4;
2142 gSpectAutoStepY
:= Random(9) - 4;
2143 if ((gSpectX
< 800) and (gSpectAutoStepX
< 0)) or
2144 ((gSpectX
> gMapInfo
.Width
- gScreenWidth
- 800) and (gSpectAutoStepX
> 0)) then
2145 gSpectAutoStepX
:= gSpectAutoStepX
* -1;
2146 if ((gSpectY
< 800) and (gSpectAutoStepY
< 0)) or
2147 ((gSpectY
> gMapInfo
.Height
- gScreenHeight
- 800) and (gSpectAutoStepY
> 0)) then
2148 gSpectAutoStepY
:= gSpectAutoStepY
* -1;
2152 gSpectPID1
:= GetActivePlayerID_Random(gSpectPID1
);
2157 SPECT_STATS
: gSpectAutoNext
:= gTime
+ (Random(3) + 5) * 1000;
2158 SPECT_MAPVIEW
: gSpectAutoNext
:= gTime
+ (Random(4) + 7) * 1000;
2159 SPECT_PLAYERS
: gSpectAutoNext
:= gTime
+ (Random(7) + 8) * 1000;
2165 // these are in separate PreUpdate functions because they can interact during Update()
2166 // we don't care that much about corpses and gibs
2167 g_Player_PreUpdate();
2168 g_Monsters_PreUpdate();
2169 g_Items_PreUpdate();
2170 g_Weapon_PreUpdate();
2172 // Îáíîâëÿåì âñå îñòàëüíîå:
2175 g_Triggers_Update();
2177 g_Monsters_Update();
2179 g_Player_UpdateAll();
2180 g_Player_UpdatePhysicalObjects();
2182 // server: send newly spawned monsters unconditionally
2183 if (gGameSettings
.GameType
= GT_SERVER
) then
2185 if (Length(gMonstersSpawned
) > 0) then
2187 for I
:= 0 to High(gMonstersSpawned
) do MH_SEND_MonsterSpawn(gMonstersSpawned
[I
]);
2188 SetLength(gMonstersSpawned
, 0);
2192 if (gSoundTriggerTime
> 8) then
2194 g_Game_UpdateTriggerSounds();
2195 gSoundTriggerTime
:= 0;
2199 Inc(gSoundTriggerTime
);
2202 if (NetMode
= NET_SERVER
) then
2204 Inc(NetTimeToUpdate
);
2205 Inc(NetTimeToReliable
);
2207 // send monster updates
2208 if (NetTimeToReliable
>= NetRelupdRate
) or (NetTimeToUpdate
>= NetUpdateRate
) then
2210 // send all monsters (periodic sync)
2211 reliableUpdate
:= (NetTimeToReliable
>= NetRelupdRate
);
2213 for I
:= 0 to High(gPlayers
) do
2215 if (gPlayers
[I
] <> nil) then MH_SEND_PlayerPos(reliableUpdate
, gPlayers
[I
].UID
);
2218 g_Mons_ForEach(sendMonsPos
);
2220 if reliableUpdate
then
2222 NetTimeToReliable
:= 0;
2223 NetTimeToUpdate
:= NetUpdateRate
;
2227 NetTimeToUpdate
:= 0;
2232 // send only mosters with some unexpected changes
2233 g_Mons_ForEach(sendMonsPosUnexpected
);
2236 // send unexpected platform changes
2237 g_Map_NetSendInterestingPanels();
2239 g_Net_Slist_ServerUpdate();
2241 if NetUseMaster then
2243 if (gTime >= NetTimeToMaster) or g_Net_Slist_IsConnectionInProgress then
2245 if (not g_Net_Slist_IsConnectionActive) then g_Net_Slist_Connect(false); // non-blocking connection to the master
2247 NetTimeToMaster := gTime + NetMasterRate;
2252 else if (NetMode
= NET_CLIENT
) then
2254 MC_SEND_PlayerPos();
2256 end; // if gameOn ...
2258 // Àêòèâíî îêíî èíòåðôåéñà - ïåðåäàåì êëàâèøè åìó:
2259 if g_ActiveWindow
<> nil then
2261 w
:= e_GetFirstKeyPressed();
2263 if (w
<> IK_INVALID
) then
2265 Msg
.Msg
:= MESSAGE_DIKEY
;
2267 g_ActiveWindow
.OnMessage(Msg
);
2270 // Åñëè îíî îò ýòîãî íå çàêðûëîñü, òî îáíîâëÿåì:
2271 if g_ActiveWindow
<> nil then
2272 g_ActiveWindow
.Update();
2274 // Íóæíî ñìåíèòü ðàçðåøåíèå:
2275 if gResolutionChange
then
2277 e_WriteLog('Changing resolution', TMsgType
.Notify
);
2278 g_Game_ChangeResolution(gRC_Width
, gRC_Height
, gRC_FullScreen
, gRC_Maximized
);
2279 gResolutionChange
:= False;
2280 g_ActiveWindow
:= nil;
2283 // Íóæíî ñìåíèòü ÿçûê:
2284 if gLanguageChange
then
2286 //e_WriteLog('Read language file', MSG_NOTIFY);
2287 //g_Language_Load(DataDir + gLanguage + '.txt');
2288 g_Language_Set(gLanguage
);
2292 gLanguageChange
:= False;
2296 // Ãîðÿ÷àÿ êëàâèøà äëÿ âûçîâà ìåíþ âûõîäà èç èãðû (F10):
2297 if e_KeyPressed(IK_F10
) and
2299 (not gConsoleShow
) and
2300 (g_ActiveWindow
= nil) then
2305 Time
:= sys_GetTicks() {div 1000};
2307 // Îáðàáîòêà îòëîæåííûõ ñîáûòèé:
2308 if gDelayedEvents
<> nil then
2309 for a
:= 0 to High(gDelayedEvents
) do
2310 if gDelayedEvents
[a
].Pending
and
2312 ((gDelayedEvents
[a
].DEType
= DE_GLOBEVENT
) and (gDelayedEvents
[a
].Time
<= Time
)) or
2313 ((gDelayedEvents
[a
].DEType
> DE_GLOBEVENT
) and (gDelayedEvents
[a
].Time
<= gTime
))
2316 case gDelayedEvents
[a
].DEType
of
2318 g_Game_ExecuteEvent(gDelayedEvents
[a
].DEStr
);
2321 g_Game_Announce_GoodShot(gDelayedEvents
[a
].DENum
);
2325 g_Game_Announce_KillCombo(gDelayedEvents
[a
].DENum
);
2326 if g_Game_IsNet
and g_Game_IsServer
then
2327 MH_SEND_GameEvent(NET_EV_KILLCOMBO
, gDelayedEvents
[a
].DENum
);
2331 g_Game_Announce_BodyKill(gDelayedEvents
[a
].DENum
);
2333 gDelayedEvents
[a
].Pending
:= False;
2336 // Êàæäóþ ñåêóíäó îáíîâëÿåì ñ÷åò÷èê îáíîâëåíèé:
2337 UPSCounter
:= UPSCounter
+ 1;
2338 if Time
- UPSTime
>= 1000 then
2347 g_Weapon_AddDynLights();
2348 g_Items_AddDynLights();
2352 procedure g_Game_LoadChatSounds(Resource
: string);
2355 FileName
, Snd
: string;
2357 len
, cnt
, tags
, i
, j
: Integer;
2360 FileName
:= g_ExtractWadName(Resource
);
2362 WAD
:= TWADFile
.Create();
2363 WAD
.ReadFile(FileName
);
2365 if not WAD
.GetResource(g_ExtractFilePathName(Resource
), p
, len
) then
2372 cfg
:= TConfig
.CreateMem(p
, len
);
2373 cnt
:= cfg
.ReadInt('ChatSounds', 'Count', 0);
2375 SetLength(gChatSounds
, cnt
);
2376 for i
:= 0 to Length(gChatSounds
) - 1 do
2378 gChatSounds
[i
].Sound
:= nil;
2379 Snd
:= Trim(cfg
.ReadStr(IntToStr(i
), 'Sound', ''));
2380 tags
:= cfg
.ReadInt(IntToStr(i
), 'Tags', 0);
2381 if (Snd
= '') or (Tags
<= 0) then
2383 g_Sound_CreateWADEx('SOUND_CHAT_MACRO' + IntToStr(i
), GameWAD
+':'+Snd
);
2384 gChatSounds
[i
].Sound
:= TPlayableSound
.Create();
2385 gChatSounds
[i
].Sound
.SetByName('SOUND_CHAT_MACRO' + IntToStr(i
));
2386 SetLength(gChatSounds
[i
].Tags
, tags
);
2387 for j
:= 0 to tags
- 1 do
2388 gChatSounds
[i
].Tags
[j
] := toLowerCase1251(cfg
.ReadStr(IntToStr(i
), 'Tag' + IntToStr(j
), ''));
2389 gChatSounds
[i
].FullWord
:= cfg
.ReadBool(IntToStr(i
), 'FullWord', False);
2396 procedure g_Game_FreeChatSounds();
2400 for i
:= 0 to Length(gChatSounds
) - 1 do
2402 gChatSounds
[i
].Sound
.Free();
2403 g_Sound_Delete('SOUND_CHAT_MACRO' + IntToStr(i
));
2405 SetLength(gChatSounds
, 0);
2409 procedure g_Game_LoadData();
2416 if DataLoaded
then Exit
;
2418 e_WriteLog('Loading game data...', TMsgType
.Notify
);
2420 g_Texture_CreateWADEx('NOTEXTURE', GameWAD
+':TEXTURES\NOTEXTURE');
2421 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUD', GameWAD
+':TEXTURES\HUD');
2422 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDAIR', GameWAD
+':TEXTURES\AIRBAR');
2423 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDJET', GameWAD
+':TEXTURES\JETBAR');
2424 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDBG', GameWAD
+':TEXTURES\HUDBG');
2425 g_Texture_CreateWADEx('TEXTURE_PLAYER_ARMORHUD', GameWAD
+':TEXTURES\ARMORHUD');
2426 g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG', GameWAD
+':TEXTURES\FLAGHUD_R_BASE');
2427 g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG_S', GameWAD
+':TEXTURES\FLAGHUD_R_STOLEN');
2428 g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG_D', GameWAD
+':TEXTURES\FLAGHUD_R_DROP');
2429 g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG', GameWAD
+':TEXTURES\FLAGHUD_B_BASE');
2430 g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG_S', GameWAD
+':TEXTURES\FLAGHUD_B_STOLEN');
2431 g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG_D', GameWAD
+':TEXTURES\FLAGHUD_B_DROP');
2432 g_Texture_CreateWADEx('TEXTURE_PLAYER_TALKBUBBLE', GameWAD
+':TEXTURES\TALKBUBBLE');
2433 g_Texture_CreateWADEx('TEXTURE_PLAYER_INVULPENTA', GameWAD
+':TEXTURES\PENTA');
2434 g_Texture_CreateWADEx('TEXTURE_PLAYER_INDICATOR', GameWAD
+':TEXTURES\PLRIND');
2437 if not g_Texture_CreateWADEx('UI_GFX_PBAR_LEFT', GameWAD
+':TEXTURES\LLEFT') then hasPBarGfx
:= false;
2438 if not g_Texture_CreateWADEx('UI_GFX_PBAR_MARKER', GameWAD
+':TEXTURES\LMARKER') then hasPBarGfx
:= false;
2439 if not g_Texture_CreateWADEx('UI_GFX_PBAR_MIDDLE', GameWAD
+':TEXTURES\LMIDDLE') then hasPBarGfx
:= false;
2440 if not g_Texture_CreateWADEx('UI_GFX_PBAR_RIGHT', GameWAD
+':TEXTURES\LRIGHT') then hasPBarGfx
:= false;
2444 g_Texture_GetSize('UI_GFX_PBAR_LEFT', wl
, hl
);
2445 g_Texture_GetSize('UI_GFX_PBAR_RIGHT', wr
, hr
);
2446 g_Texture_GetSize('UI_GFX_PBAR_MIDDLE', wb
, hb
);
2447 g_Texture_GetSize('UI_GFX_PBAR_MARKER', wm
, hm
);
2448 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
2454 hasPBarGfx
:= false;
2458 g_Frames_CreateWAD(nil, 'FRAMES_TELEPORT', GameWAD
+':TEXTURES\TELEPORT', 64, 64, 10, False);
2459 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH', GameWAD
+':WEAPONS\PUNCH', 64, 64, 4, False);
2460 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_UP', GameWAD
+':WEAPONS\PUNCH_UP', 64, 64, 4, False);
2461 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_DN', GameWAD
+':WEAPONS\PUNCH_DN', 64, 64, 4, False);
2462 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_BERSERK', GameWAD
+':WEAPONS\PUNCHB', 64, 64, 4, False);
2463 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_BERSERK_UP', GameWAD
+':WEAPONS\PUNCHB_UP', 64, 64, 4, False);
2464 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_BERSERK_DN', GameWAD
+':WEAPONS\PUNCHB_DN', 64, 64, 4, False);
2465 g_Sound_CreateWADEx('SOUND_GAME_TELEPORT', GameWAD
+':SOUNDS\TELEPORT');
2466 g_Sound_CreateWADEx('SOUND_GAME_NOTELEPORT', GameWAD
+':SOUNDS\NOTELEPORT');
2467 g_Sound_CreateWADEx('SOUND_GAME_SECRET', GameWAD
+':SOUNDS\SECRET');
2468 g_Sound_CreateWADEx('SOUND_GAME_DOOROPEN', GameWAD
+':SOUNDS\DOOROPEN');
2469 g_Sound_CreateWADEx('SOUND_GAME_DOORCLOSE', GameWAD
+':SOUNDS\DOORCLOSE');
2470 g_Sound_CreateWADEx('SOUND_GAME_BULK1', GameWAD
+':SOUNDS\BULK1');
2471 g_Sound_CreateWADEx('SOUND_GAME_BULK2', GameWAD
+':SOUNDS\BULK2');
2472 g_Sound_CreateWADEx('SOUND_GAME_BUBBLE1', GameWAD
+':SOUNDS\BUBBLE1');
2473 g_Sound_CreateWADEx('SOUND_GAME_BUBBLE2', GameWAD
+':SOUNDS\BUBBLE2');
2474 g_Sound_CreateWADEx('SOUND_GAME_BURNING', GameWAD
+':SOUNDS\BURNING');
2475 g_Sound_CreateWADEx('SOUND_GAME_SWITCH1', GameWAD
+':SOUNDS\SWITCH1');
2476 g_Sound_CreateWADEx('SOUND_GAME_SWITCH0', GameWAD
+':SOUNDS\SWITCH0');
2477 g_Sound_CreateWADEx('SOUND_GAME_RADIO', GameWAD
+':SOUNDS\RADIO');
2478 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD1', GameWAD
+':SOUNDS\GOOD1');
2479 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD2', GameWAD
+':SOUNDS\GOOD2');
2480 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD3', GameWAD
+':SOUNDS\GOOD3');
2481 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD4', GameWAD
+':SOUNDS\GOOD4');
2482 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL2X', GameWAD
+':SOUNDS\KILL2X');
2483 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL3X', GameWAD
+':SOUNDS\KILL3X');
2484 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL4X', GameWAD
+':SOUNDS\KILL4X');
2485 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILLMX', GameWAD
+':SOUNDS\KILLMX');
2486 g_Sound_CreateWADEx('SOUND_ANNOUNCER_MUHAHA1', GameWAD
+':SOUNDS\MUHAHA1');
2487 g_Sound_CreateWADEx('SOUND_ANNOUNCER_MUHAHA2', GameWAD
+':SOUNDS\MUHAHA2');
2488 g_Sound_CreateWADEx('SOUND_ANNOUNCER_MUHAHA3', GameWAD
+':SOUNDS\MUHAHA3');
2489 g_Sound_CreateWADEx('SOUND_CTF_GET1', GameWAD
+':SOUNDS\GETFLAG1');
2490 g_Sound_CreateWADEx('SOUND_CTF_GET2', GameWAD
+':SOUNDS\GETFLAG2');
2491 g_Sound_CreateWADEx('SOUND_CTF_LOST1', GameWAD
+':SOUNDS\LOSTFLG1');
2492 g_Sound_CreateWADEx('SOUND_CTF_LOST2', GameWAD
+':SOUNDS\LOSTFLG2');
2493 g_Sound_CreateWADEx('SOUND_CTF_RETURN1', GameWAD
+':SOUNDS\RETFLAG1');
2494 g_Sound_CreateWADEx('SOUND_CTF_RETURN2', GameWAD
+':SOUNDS\RETFLAG2');
2495 g_Sound_CreateWADEx('SOUND_CTF_CAPTURE1', GameWAD
+':SOUNDS\CAPFLAG1');
2496 g_Sound_CreateWADEx('SOUND_CTF_CAPTURE2', GameWAD
+':SOUNDS\CAPFLAG2');
2498 goodsnd
[0] := TPlayableSound
.Create();
2499 goodsnd
[1] := TPlayableSound
.Create();
2500 goodsnd
[2] := TPlayableSound
.Create();
2501 goodsnd
[3] := TPlayableSound
.Create();
2503 goodsnd
[0].SetByName('SOUND_ANNOUNCER_GOOD1');
2504 goodsnd
[1].SetByName('SOUND_ANNOUNCER_GOOD2');
2505 goodsnd
[2].SetByName('SOUND_ANNOUNCER_GOOD3');
2506 goodsnd
[3].SetByName('SOUND_ANNOUNCER_GOOD4');
2508 killsnd
[0] := TPlayableSound
.Create();
2509 killsnd
[1] := TPlayableSound
.Create();
2510 killsnd
[2] := TPlayableSound
.Create();
2511 killsnd
[3] := TPlayableSound
.Create();
2513 killsnd
[0].SetByName('SOUND_ANNOUNCER_KILL2X');
2514 killsnd
[1].SetByName('SOUND_ANNOUNCER_KILL3X');
2515 killsnd
[2].SetByName('SOUND_ANNOUNCER_KILL4X');
2516 killsnd
[3].SetByName('SOUND_ANNOUNCER_KILLMX');
2518 hahasnd
[0] := TPlayableSound
.Create();
2519 hahasnd
[1] := TPlayableSound
.Create();
2520 hahasnd
[2] := TPlayableSound
.Create();
2522 hahasnd
[0].SetByName('SOUND_ANNOUNCER_MUHAHA1');
2523 hahasnd
[1].SetByName('SOUND_ANNOUNCER_MUHAHA2');
2524 hahasnd
[2].SetByName('SOUND_ANNOUNCER_MUHAHA3');
2526 sound_get_flag
[0] := TPlayableSound
.Create();
2527 sound_get_flag
[1] := TPlayableSound
.Create();
2528 sound_lost_flag
[0] := TPlayableSound
.Create();
2529 sound_lost_flag
[1] := TPlayableSound
.Create();
2530 sound_ret_flag
[0] := TPlayableSound
.Create();
2531 sound_ret_flag
[1] := TPlayableSound
.Create();
2532 sound_cap_flag
[0] := TPlayableSound
.Create();
2533 sound_cap_flag
[1] := TPlayableSound
.Create();
2535 sound_get_flag
[0].SetByName('SOUND_CTF_GET1');
2536 sound_get_flag
[1].SetByName('SOUND_CTF_GET2');
2537 sound_lost_flag
[0].SetByName('SOUND_CTF_LOST1');
2538 sound_lost_flag
[1].SetByName('SOUND_CTF_LOST2');
2539 sound_ret_flag
[0].SetByName('SOUND_CTF_RETURN1');
2540 sound_ret_flag
[1].SetByName('SOUND_CTF_RETURN2');
2541 sound_cap_flag
[0].SetByName('SOUND_CTF_CAPTURE1');
2542 sound_cap_flag
[1].SetByName('SOUND_CTF_CAPTURE2');
2544 g_Game_LoadChatSounds(GameWAD
+':CHATSND\SNDCFG');
2546 g_Game_SetLoadingText(_lc
[I_LOAD_ITEMS_DATA
], 0, False);
2549 g_Game_SetLoadingText(_lc
[I_LOAD_WEAPONS_DATA
], 0, False);
2550 g_Weapon_LoadData();
2552 g_Monsters_LoadData();
2557 procedure g_Game_FreeData();
2559 if not DataLoaded
then Exit
;
2562 g_Weapon_FreeData();
2563 g_Monsters_FreeData();
2565 e_WriteLog('Releasing game data...', TMsgType
.Notify
);
2567 g_Texture_Delete('NOTEXTURE');
2568 g_Texture_Delete('TEXTURE_PLAYER_HUD');
2569 g_Texture_Delete('TEXTURE_PLAYER_HUDBG');
2570 g_Texture_Delete('TEXTURE_PLAYER_ARMORHUD');
2571 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG');
2572 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG_S');
2573 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG_D');
2574 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG');
2575 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG_S');
2576 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG_D');
2577 g_Texture_Delete('TEXTURE_PLAYER_TALKBUBBLE');
2578 g_Texture_Delete('TEXTURE_PLAYER_INVULPENTA');
2579 g_Frames_DeleteByName('FRAMES_TELEPORT');
2580 g_Frames_DeleteByName('FRAMES_PUNCH');
2581 g_Frames_DeleteByName('FRAMES_PUNCH_UP');
2582 g_Frames_DeleteByName('FRAMES_PUNCH_DN');
2583 g_Frames_DeleteByName('FRAMES_PUNCH_BERSERK');
2584 g_Frames_DeleteByName('FRAMES_PUNCH_BERSERK_UP');
2585 g_Frames_DeleteByName('FRAMES_PUNCH_BERSERK_DN');
2586 g_Sound_Delete('SOUND_GAME_TELEPORT');
2587 g_Sound_Delete('SOUND_GAME_NOTELEPORT');
2588 g_Sound_Delete('SOUND_GAME_SECRET');
2589 g_Sound_Delete('SOUND_GAME_DOOROPEN');
2590 g_Sound_Delete('SOUND_GAME_DOORCLOSE');
2591 g_Sound_Delete('SOUND_GAME_BULK1');
2592 g_Sound_Delete('SOUND_GAME_BULK2');
2593 g_Sound_Delete('SOUND_GAME_BUBBLE1');
2594 g_Sound_Delete('SOUND_GAME_BUBBLE2');
2595 g_Sound_Delete('SOUND_GAME_BURNING');
2596 g_Sound_Delete('SOUND_GAME_SWITCH1');
2597 g_Sound_Delete('SOUND_GAME_SWITCH0');
2604 g_Sound_Delete('SOUND_ANNOUNCER_GOOD1');
2605 g_Sound_Delete('SOUND_ANNOUNCER_GOOD2');
2606 g_Sound_Delete('SOUND_ANNOUNCER_GOOD3');
2607 g_Sound_Delete('SOUND_ANNOUNCER_GOOD4');
2614 g_Sound_Delete('SOUND_ANNOUNCER_KILL2X');
2615 g_Sound_Delete('SOUND_ANNOUNCER_KILL3X');
2616 g_Sound_Delete('SOUND_ANNOUNCER_KILL4X');
2617 g_Sound_Delete('SOUND_ANNOUNCER_KILLMX');
2623 g_Sound_Delete('SOUND_ANNOUNCER_MUHAHA1');
2624 g_Sound_Delete('SOUND_ANNOUNCER_MUHAHA2');
2625 g_Sound_Delete('SOUND_ANNOUNCER_MUHAHA3');
2627 sound_get_flag
[0].Free();
2628 sound_get_flag
[1].Free();
2629 sound_lost_flag
[0].Free();
2630 sound_lost_flag
[1].Free();
2631 sound_ret_flag
[0].Free();
2632 sound_ret_flag
[1].Free();
2633 sound_cap_flag
[0].Free();
2634 sound_cap_flag
[1].Free();
2636 g_Sound_Delete('SOUND_CTF_GET1');
2637 g_Sound_Delete('SOUND_CTF_GET2');
2638 g_Sound_Delete('SOUND_CTF_LOST1');
2639 g_Sound_Delete('SOUND_CTF_LOST2');
2640 g_Sound_Delete('SOUND_CTF_RETURN1');
2641 g_Sound_Delete('SOUND_CTF_RETURN2');
2642 g_Sound_Delete('SOUND_CTF_CAPTURE1');
2643 g_Sound_Delete('SOUND_CTF_CAPTURE2');
2645 g_Game_FreeChatSounds();
2647 DataLoaded
:= False;
2650 procedure DrawCustomStat();
2656 ww2
, hh2
, r
, g
, b
, rr
, gg
, bb
: Byte;
2657 s1
, s2
, topstr
: String;
2659 e_TextureFontGetSize(gStdFont
, ww2
, hh2
);
2663 if g_Console_Action(ACTION_SCORES
) then
2665 if not gStatsPressed
then
2667 gStatsOff
:= not gStatsOff
;
2668 gStatsPressed
:= True;
2672 gStatsPressed
:= False;
2676 s1
:= _lc
[I_MENU_INTER_NOTICE_TAB
];
2677 w
:= (Length(s1
) * ww2
) div 2;
2678 x
:= gScreenWidth
div 2 - w
;
2680 e_TextureFontPrint(x
, y
, s1
, gStdFont
);
2684 if (gGameSettings
.GameMode
= GM_COOP
) then
2686 if gMissionFailed
then
2687 topstr
:= _lc
[I_MENU_INTER_MISSION_FAIL
]
2689 topstr
:= _lc
[I_MENU_INTER_LEVEL_COMPLETE
];
2692 topstr
:= _lc
[I_MENU_INTER_ROUND_OVER
];
2694 e_CharFont_GetSize(gMenuFont
, topstr
, ww1
, hh1
);
2695 e_CharFont_Print(gMenuFont
, (gScreenWidth
div 2)-(ww1
div 2), 16, topstr
);
2697 if g_Game_IsNet
then
2699 topstr
:= Format(_lc
[I_MENU_INTER_NOTICE_TIME
], [gServInterTime
]);
2700 if not gChatShow
then
2701 e_TextureFontPrintEx((gScreenWidth
div 2)-(Length(topstr
)*ww2
div 2),
2702 gScreenHeight
-(hh2
+4)*2, topstr
, gStdFont
, 255, 255, 255, 1);
2705 if g_Game_IsClient
then
2706 topstr
:= _lc
[I_MENU_INTER_NOTICE_MAP
]
2708 topstr
:= _lc
[I_MENU_INTER_NOTICE_SPACE
];
2709 if not gChatShow
then
2710 e_TextureFontPrintEx((gScreenWidth
div 2)-(Length(topstr
)*ww2
div 2),
2711 gScreenHeight
-(hh2
+4), topstr
, gStdFont
, 255, 255, 255, 1);
2716 w
:= gScreenWidth
-x
*2;
2722 e_DrawFillQuad(x
, y
, gScreenWidth
-x
-1, gScreenHeight
-y
-1, 64, 64, 64, 32);
2723 e_DrawQuad(x
, y
, gScreenWidth
-x
-1, gScreenHeight
-y
-1, 255, 127, 0);
2725 m
:= Max(Length(_lc
[I_MENU_MAP
])+1, Length(_lc
[I_GAME_GAME_TIME
])+1)*ww2
;
2727 case CustomStat
.GameMode
of
2730 if gGameSettings
.MaxLives
= 0 then
2731 s1
:= _lc
[I_GAME_DM
]
2733 s1
:= _lc
[I_GAME_LMS
];
2737 if gGameSettings
.MaxLives
= 0 then
2738 s1
:= _lc
[I_GAME_TDM
]
2740 s1
:= _lc
[I_GAME_TLMS
];
2742 GM_CTF
: s1
:= _lc
[I_GAME_CTF
];
2745 if gGameSettings
.MaxLives
= 0 then
2746 s1
:= _lc
[I_GAME_COOP
]
2748 s1
:= _lc
[I_GAME_SURV
];
2754 e_TextureFontPrintEx(x
+(w
div 2)-(Length(s1
)*ww2
div 2), _y
, s1
, gStdFont
, 255, 255, 255, 1);
2758 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_MENU_MAP
], gStdFont
, 255, 127, 0, 1);
2759 e_TextureFontPrint(x
+8+m
, _y
, Format('%s - %s', [CustomStat
.Map
, CustomStat
.MapName
]), gStdFont
);
2762 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_GAME_TIME
], gStdFont
, 255, 127, 0, 1);
2763 e_TextureFontPrint(x
+8+m
, _y
, Format('%d:%.2d:%.2d', [CustomStat
.GameTime
div 1000 div 3600,
2764 (CustomStat
.GameTime
div 1000 div 60) mod 60,
2765 CustomStat
.GameTime
div 1000 mod 60]), gStdFont
);
2767 pc
:= Length(CustomStat
.PlayerStat
);
2768 if pc
= 0 then Exit
;
2770 if CustomStat
.GameMode
= GM_COOP
then
2772 m
:= Max(Length(_lc
[I_GAME_MONSTERS
])+1, Length(_lc
[I_GAME_SECRETS
])+1)*ww2
;
2774 s2
:= _lc
[I_GAME_MONSTERS
];
2775 e_TextureFontPrintEx(x
+8, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2776 e_TextureFontPrintEx(x
+8+m
, _y
, IntToStr(gCoopMonstersKilled
) + '/' + IntToStr(gTotalMonsters
), gStdFont
, 255, 255, 255, 1);
2778 s2
:= _lc
[I_GAME_SECRETS
];
2779 e_TextureFontPrintEx(x
+8, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2780 e_TextureFontPrintEx(x
+8+m
, _y
, IntToStr(gCoopSecretsFound
) + '/' + IntToStr(gSecretsCount
), gStdFont
, 255, 255, 255, 1);
2783 m
:= Max(Length(_lc
[I_GAME_MONSTERS_TOTAL
])+1, Length(_lc
[I_GAME_SECRETS_TOTAL
])+1)*ww2
;
2785 s2
:= _lc
[I_GAME_MONSTERS_TOTAL
];
2786 e_TextureFontPrintEx(x
+250, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2787 e_TextureFontPrintEx(x
+250+m
, _y
, IntToStr(gCoopTotalMonstersKilled
) + '/' + IntToStr(gCoopTotalMonsters
), gStdFont
, 255, 255, 255, 1);
2789 s2
:= _lc
[I_GAME_SECRETS_TOTAL
];
2790 e_TextureFontPrintEx(x
+250, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2791 e_TextureFontPrintEx(x
+250+m
, _y
, IntToStr(gCoopTotalSecretsFound
) + '/' + IntToStr(gCoopTotalSecrets
), gStdFont
, 255, 255, 255, 1);
2795 if CustomStat
.GameMode
in [GM_TDM
, GM_CTF
] then
2800 if TeamStat
[TEAM_RED
].Goals
> TeamStat
[TEAM_BLUE
].Goals
then s1
:= _lc
[I_GAME_WIN_RED
]
2801 else if TeamStat
[TEAM_BLUE
].Goals
> TeamStat
[TEAM_RED
].Goals
then s1
:= _lc
[I_GAME_WIN_BLUE
]
2802 else s1
:= _lc
[I_GAME_WIN_DRAW
];
2804 e_TextureFontPrintEx(x
+8+(w
div 2)-(Length(s1
)*ww2
div 2), _y
, s1
, gStdFont
, 255, 255, 255, 1);
2807 for t
:= TEAM_RED
to TEAM_BLUE
do
2809 if t
= TEAM_RED
then
2811 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_TEAM_RED
],
2812 gStdFont
, 255, 0, 0, 1);
2813 e_TextureFontPrintEx(x
+w1
+8, _y
, IntToStr(CustomStat
.TeamStat
[TEAM_RED
].Goals
),
2814 gStdFont
, 255, 0, 0, 1);
2821 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_TEAM_BLUE
],
2822 gStdFont
, 0, 0, 255, 1);
2823 e_TextureFontPrintEx(x
+w1
+8, _y
, IntToStr(CustomStat
.TeamStat
[TEAM_BLUE
].Goals
),
2824 gStdFont
, 0, 0, 255, 1);
2830 e_DrawLine(1, x
+8, _y
+20, x
-8+w
, _y
+20, r
, g
, b
);
2833 for p
:= 0 to High(CustomStat
.PlayerStat
) do
2834 if CustomStat
.PlayerStat
[p
].Team
= t
then
2835 with CustomStat
.PlayerStat
[p
] do
2849 if (gPlayers
[Num
] <> nil) and (gPlayers
[Num
].FReady
) then
2850 e_TextureFontPrintEx(x
+16, _y
, Name
+ ' *', gStdFont
, rr
, gg
, bb
, 1)
2852 e_TextureFontPrintEx(x
+16, _y
, Name
, gStdFont
, rr
, gg
, bb
, 1);
2853 e_TextureFontPrintEx(x
+w1
+16, _y
, IntToStr(Frags
), gStdFont
, rr
, gg
, bb
, 1);
2854 e_TextureFontPrintEx(x
+w1
+w2
+16, _y
, IntToStr(Deaths
), gStdFont
, rr
, gg
, bb
, 1);
2861 else if CustomStat
.GameMode
in [GM_DM
, GM_COOP
] then
2864 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_PLAYER_NAME
], gStdFont
, 255, 127, 0, 1);
2865 e_TextureFontPrintEx(x
+8+w1
, _y
, _lc
[I_GAME_FRAGS
], gStdFont
, 255, 127, 0, 1);
2866 e_TextureFontPrintEx(x
+8+w1
+w2
, _y
, _lc
[I_GAME_DEATHS
], gStdFont
, 255, 127, 0, 1);
2869 for p
:= 0 to High(CustomStat
.PlayerStat
) do
2870 with CustomStat
.PlayerStat
[p
] do
2872 e_DrawFillQuad(x
+8, _y
+4, x
+24-1, _y
+16+4-1, Color
.R
, Color
.G
, Color
.B
, 0);
2879 if (gPlayers
[Num
] <> nil) and (gPlayers
[Num
].FReady
) then
2880 e_TextureFontPrintEx(x
+8+16+8, _y
+4, Name
+ ' *', gStdFont
, r
, r
, r
, 1, True)
2882 e_TextureFontPrintEx(x
+8+16+8, _y
+4, Name
, gStdFont
, r
, r
, r
, 1, True);
2883 e_TextureFontPrintEx(x
+w1
+8+16+8, _y
+4, IntToStr(Frags
), gStdFont
, r
, r
, r
, 1, True);
2884 e_TextureFontPrintEx(x
+w1
+w2
+8+16+8, _y
+4, IntToStr(Deaths
), gStdFont
, r
, r
, r
, 1, True);
2889 // HACK: take stats screenshot immediately after the first frame of the stats showing
2890 if gScreenshotStats
and (not StatShotDone
) and (Length(CustomStat
.PlayerStat
) > 1) then
2892 g_TakeScreenShot('stats/' + StatFilename
);
2893 StatShotDone
:= True;
2897 procedure DrawSingleStat();
2899 tm
, key_x
, val_x
, y
: Integer;
2903 procedure player_stat(n
: Integer);
2909 s1
:= Format(' %d ', [SingleStat
.PlayerStat
[n
].Kills
]);
2910 s2
:= Format(' %d', [gTotalMonsters
]);
2912 e_CharFont_Print(gMenuFont
, key_x
, y
, _lc
[I_MENU_INTER_KILLS
]);
2913 e_CharFont_PrintEx(gMenuFont
, val_x
, y
, s1
, _RGB(255, 0, 0));
2914 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2915 e_CharFont_Print(gMenuFont
, val_x
+w1
, y
, '/');
2917 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2918 e_CharFont_PrintEx(gMenuFont
, val_x
+w1
, y
, s2
, _RGB(255, 0, 0));
2920 // "Kills-per-minute: ##.#":
2921 s1
:= _lc
[I_MENU_INTER_KPM
];
2923 kpm
:= (SingleStat
.PlayerStat
[n
].Kills
/ tm
) * 60
2925 kpm
:= SingleStat
.PlayerStat
[n
].Kills
;
2926 s2
:= Format(' %.1f', [kpm
]);
2928 e_CharFont_Print(gMenuFont
, key_x
, y
+32, s1
);
2929 e_CharFont_PrintEx(gMenuFont
, val_x
, y
+32, s2
, _RGB(255, 0, 0));
2931 // "Secrets found: # / #":
2932 s1
:= Format(' %d ', [SingleStat
.PlayerStat
[n
].Secrets
]);
2933 s2
:= Format(' %d', [SingleStat
.TotalSecrets
]);
2935 e_CharFont_Print(gMenuFont
, key_x
, y
+64, _lc
[I_MENU_INTER_SECRETS
]);
2936 e_CharFont_PrintEx(gMenuFont
, val_x
, y
+64, s1
, _RGB(255, 0, 0));
2937 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2938 e_CharFont_Print(gMenuFont
, val_x
+w1
, y
+64, '/');
2940 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2941 e_CharFont_PrintEx(gMenuFont
, val_x
+w1
, y
+64, s2
, _RGB(255, 0, 0));
2945 // "Level Complete":
2946 e_CharFont_GetSize(gMenuFont
, _lc
[I_MENU_INTER_LEVEL_COMPLETE
], w1
, h
);
2947 e_CharFont_Print(gMenuFont
, (gScreenWidth
-w1
) div 2, 32, _lc
[I_MENU_INTER_LEVEL_COMPLETE
]);
2949 // Îïðåäåëÿåì êîîðäèíàòû âûðàâíèâàíèÿ ïî ñàìîé äëèííîé ñòðîêå:
2950 s1
:= _lc
[I_MENU_INTER_KPM
];
2951 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2954 e_CharFont_GetSize(gMenuFont
, s1
, w2
, h
);
2956 key_x
:= (gScreenWidth
-w1
-w2
) div 2;
2957 val_x
:= key_x
+ w1
;
2960 tm
:= SingleStat
.GameTime
div 1000;
2961 s1
:= _lc
[I_MENU_INTER_TIME
];
2962 s2
:= Format(' %d:%.2d:%.2d', [tm
div (60*60), (tm
mod (60*60)) div 60, tm
mod 60]);
2964 e_CharFont_Print(gMenuFont
, key_x
, 80, s1
);
2965 e_CharFont_PrintEx(gMenuFont
, val_x
, 80, s2
, _RGB(255, 0, 0));
2967 if SingleStat
.TwoPlayers
then
2970 s1
:= _lc
[I_MENU_PLAYER_1
];
2971 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2972 e_CharFont_Print(gMenuFont
, (gScreenWidth
-w1
) div 2, 128, s1
);
2974 // Ñòàòèñòèêà ïåðâîãî èãðîêà:
2979 s1
:= _lc
[I_MENU_PLAYER_2
];
2980 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2981 e_CharFont_Print(gMenuFont
, (gScreenWidth
-w1
) div 2, 288, s1
);
2983 // Ñòàòèñòèêà âòîðîãî èãðîêà:
2989 // Ñòàòèñòèêà ïåðâîãî èãðîêà:
2995 procedure DrawLoadingStat();
2996 procedure drawRect (x
, y
, w
, h
: Integer);
2998 if (w
< 1) or (h
< 1) then exit
;
3000 glVertex2f(x
+0.375, y
+0.375);
3001 glVertex2f(x
+w
+0.375, y
+0.375);
3002 glVertex2f(x
+w
+0.375, y
+h
+0.375);
3003 glVertex2f(x
+0.375, y
+h
+0.375);
3007 function drawPBar (cur
, total
: Integer; washere
: Boolean): Boolean;
3009 rectW
, rectH
: Integer;
3016 idl
, idr
, idb
, idm
: LongWord;
3020 if (total
< 1) then exit
;
3021 if (cur
< 1) then exit
; // don't blink
3022 if (not washere
) and (cur
>= total
) then exit
; // don't blink
3023 //if (cur < 0) then cur := 0;
3024 //if (cur > total) then cur := total;
3027 if (hasPBarGfx
) then
3029 g_Texture_Get('UI_GFX_PBAR_LEFT', idl
);
3030 g_Texture_GetSize('UI_GFX_PBAR_LEFT', wl
, hl
);
3031 g_Texture_Get('UI_GFX_PBAR_RIGHT', idr
);
3032 g_Texture_GetSize('UI_GFX_PBAR_RIGHT', wr
, hr
);
3033 g_Texture_Get('UI_GFX_PBAR_MIDDLE', idb
);
3034 g_Texture_GetSize('UI_GFX_PBAR_MIDDLE', wb
, hb
);
3035 g_Texture_Get('UI_GFX_PBAR_MARKER', idm
);
3036 g_Texture_GetSize('UI_GFX_PBAR_MARKER', wm
, hm
);
3038 //rectW := gScreenWidth-360;
3039 rectW
:= trunc(624.0*gScreenWidth
/1024.0);
3042 x0
:= (gScreenWidth
-rectW
) div 2;
3043 y0
:= gScreenHeight
-rectH
-64;
3044 if (y0
< 2) then y0
:= 2;
3046 glEnable(GL_SCISSOR_TEST
);
3049 glScissor(x0
, gScreenHeight
-y0
-rectH
, rectW
, rectH
);
3050 e_DrawSize(idl
, x0
, y0
, 0, true, false, wl
, hl
);
3051 e_DrawSize(idr
, x0
+rectW
-wr
, y0
, 0, true, false, wr
, hr
);
3054 glScissor(x0
+wl
, gScreenHeight
-y0
-rectH
, rectW
-wl
-wr
, rectH
);
3056 while (f
< x0
+rectW
) do
3058 e_DrawSize(idb
, f
, y0
, 0, true, false, wb
, hb
);
3063 wdt
:= (rectW
-wl
-wr
)*cur
div total
;
3064 if (wdt
> rectW
-wl
-wr
) then wdt
:= rectW
-wr
-wr
;
3067 my
:= y0
; // don't be so smart, ketmar: +(rectH-wm) div 2;
3068 glScissor(x0
+wl
, gScreenHeight
-my
-rectH
, wdt
, hm
);
3072 e_DrawSize(idm
, f
, y0
, 0, true, false, wm
, hm
);
3078 glScissor(0, 0, gScreenWidth
, gScreenHeight
);
3082 rectW
:= gScreenWidth
-64;
3085 x0
:= (gScreenWidth
-rectW
) div 2;
3086 y0
:= gScreenHeight
-rectH
-64;
3087 if (y0
< 2) then y0
:= 2;
3089 glDisable(GL_BLEND
);
3090 glDisable(GL_TEXTURE_2D
);
3092 //glClearColor(0, 0, 0, 0);
3093 //glClear(GL_COLOR_BUFFER_BIT);
3095 glColor4ub(127, 127, 127, 255);
3096 drawRect(x0
-2, y0
-2, rectW
+4, rectH
+4);
3098 glColor4ub(0, 0, 0, 255);
3099 drawRect(x0
-1, y0
-1, rectW
+2, rectH
+2);
3101 glColor4ub(127, 127, 127, 255);
3102 wdt
:= rectW
*cur
div total
;
3103 if (wdt
> rectW
) then wdt
:= rectW
;
3104 drawRect(x0
, y0
, wdt
, rectH
);
3113 if (Length(LoadingStat
.Msgs
) = 0) then exit
;
3115 e_CharFont_GetSize(gMenuFont
, _lc
[I_MENU_LOADING
], ww
, hh
);
3116 yy
:= (gScreenHeight
div 3);
3117 e_CharFont_Print(gMenuFont
, (gScreenWidth
div 2)-(ww
div 2), yy
-2*hh
, _lc
[I_MENU_LOADING
]);
3118 xx
:= (gScreenWidth
div 3);
3122 for i
:= 0 to NextMsg
-1 do
3124 if (i
= (NextMsg
-1)) and (MaxValue
> 0) then
3125 s
:= Format('%s: %d/%d', [Msgs
[i
], CurValue
, MaxValue
])
3129 e_CharFont_PrintEx(gMenuSmallFont
, xx
, yy
, s
, _RGB(255, 0, 0));
3130 yy
:= yy
+ LOADING_INTERLINE
;
3131 PBarWasHere
:= drawPBar(CurValue
, MaxValue
, PBarWasHere
);
3136 procedure DrawMenuBackground(tex
: AnsiString);
3142 if g_Texture_Get(tex
, ID
) then
3144 e_Clear(GL_COLOR_BUFFER_BIT
, 0, 0, 0);
3145 e_GetTextureSize(ID
, @w
, @h
);
3147 w
:= round(w
* 1.333 * (gScreenHeight
/ h
))
3149 w
:= trunc(w
* (gScreenHeight
/ h
));
3150 e_DrawSize(ID
, (gScreenWidth
- w
) div 2, 0, 0, False, False, w
, gScreenHeight
);
3152 else e_Clear(GL_COLOR_BUFFER_BIT
, 0, 0, 0);
3155 procedure DrawMinimap(p
: TPlayer
; RenderRect
: e_graphics
.TRect
);
3157 a
, aX
, aY
, aX2
, aY2
, Scale
, ScaleSz
: Integer;
3159 function monDraw (mon
: TMonster
): Boolean;
3161 result
:= false; // don't stop
3166 // Ëåâûé âåðõíèé óãîë
3167 aX
:= Obj
.X
div ScaleSz
+ 1;
3168 aY
:= Obj
.Y
div ScaleSz
+ 1;
3170 aX2
:= max(Obj
.Rect
.Width
div ScaleSz
, 1);
3171 aY2
:= max(Obj
.Rect
.Height
div ScaleSz
, 1);
3172 // Ïðàâûé íèæíèé óãîë
3173 aX2
:= aX
+ aX2
- 1;
3174 aY2
:= aY
+ aY2
- 1;
3175 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 255, 0, 0);
3181 if (gMapInfo
.Width
> RenderRect
.Right
- RenderRect
.Left
) or
3182 (gMapInfo
.Height
> RenderRect
.Bottom
- RenderRect
.Top
) then
3185 // Ñêîëüêî ïèêñåëîâ êàðòû â 1 ïèêñåëå ìèíè-êàðòû:
3186 ScaleSz
:= 16 div Scale
;
3187 // Ðàçìåðû ìèíè-êàðòû:
3188 aX
:= max(gMapInfo
.Width
div ScaleSz
, 1);
3189 aY
:= max(gMapInfo
.Height
div ScaleSz
, 1);
3191 e_DrawFillQuad(0, 0, aX
-1, aY
-1, 0, 0, 0, 0);
3193 if gWalls
<> nil then
3196 for a
:= 0 to High(gWalls
) do
3198 if PanelType
<> 0 then
3200 // Ëåâûé âåðõíèé óãîë:
3201 aX
:= X
div ScaleSz
;
3202 aY
:= Y
div ScaleSz
;
3204 aX2
:= max(Width
div ScaleSz
, 1);
3205 aY2
:= max(Height
div ScaleSz
, 1);
3206 // Ïðàâûé íèæíèé óãîë:
3207 aX2
:= aX
+ aX2
- 1;
3208 aY2
:= aY
+ aY2
- 1;
3211 PANEL_WALL
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 208, 208, 208, 0);
3212 PANEL_OPENDOOR
, PANEL_CLOSEDOOR
:
3213 if Enabled
then e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 160, 160, 160, 0);
3217 if gSteps
<> nil then
3220 for a
:= 0 to High(gSteps
) do
3222 if PanelType
<> 0 then
3224 // Ëåâûé âåðõíèé óãîë:
3225 aX
:= X
div ScaleSz
;
3226 aY
:= Y
div ScaleSz
;
3228 aX2
:= max(Width
div ScaleSz
, 1);
3229 aY2
:= max(Height
div ScaleSz
, 1);
3230 // Ïðàâûé íèæíèé óãîë:
3231 aX2
:= aX
+ aX2
- 1;
3232 aY2
:= aY
+ aY2
- 1;
3234 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 128, 128, 128, 0);
3237 if gLifts
<> nil then
3240 for a
:= 0 to High(gLifts
) do
3242 if PanelType
<> 0 then
3244 // Ëåâûé âåðõíèé óãîë:
3245 aX
:= X
div ScaleSz
;
3246 aY
:= Y
div ScaleSz
;
3248 aX2
:= max(Width
div ScaleSz
, 1);
3249 aY2
:= max(Height
div ScaleSz
, 1);
3250 // Ïðàâûé íèæíèé óãîë:
3251 aX2
:= aX
+ aX2
- 1;
3252 aY2
:= aY
+ aY2
- 1;
3255 LIFTTYPE_UP
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 116, 72, 36, 0);
3256 LIFTTYPE_DOWN
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 116, 124, 96, 0);
3257 LIFTTYPE_LEFT
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 200, 80, 4, 0);
3258 LIFTTYPE_RIGHT
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 252, 140, 56, 0);
3262 if gWater
<> nil then
3265 for a
:= 0 to High(gWater
) do
3267 if PanelType
<> 0 then
3269 // Ëåâûé âåðõíèé óãîë:
3270 aX
:= X
div ScaleSz
;
3271 aY
:= Y
div ScaleSz
;
3273 aX2
:= max(Width
div ScaleSz
, 1);
3274 aY2
:= max(Height
div ScaleSz
, 1);
3275 // Ïðàâûé íèæíèé óãîë:
3276 aX2
:= aX
+ aX2
- 1;
3277 aY2
:= aY
+ aY2
- 1;
3279 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 0, 192, 0);
3282 if gAcid1
<> nil then
3284 // Ðèñóåì êèñëîòó 1:
3285 for a
:= 0 to High(gAcid1
) do
3287 if PanelType
<> 0 then
3289 // Ëåâûé âåðõíèé óãîë:
3290 aX
:= X
div ScaleSz
;
3291 aY
:= Y
div ScaleSz
;
3293 aX2
:= max(Width
div ScaleSz
, 1);
3294 aY2
:= max(Height
div ScaleSz
, 1);
3295 // Ïðàâûé íèæíèé óãîë:
3296 aX2
:= aX
+ aX2
- 1;
3297 aY2
:= aY
+ aY2
- 1;
3299 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 176, 0, 0);
3302 if gAcid2
<> nil then
3304 // Ðèñóåì êèñëîòó 2:
3305 for a
:= 0 to High(gAcid2
) do
3307 if PanelType
<> 0 then
3309 // Ëåâûé âåðõíèé óãîë:
3310 aX
:= X
div ScaleSz
;
3311 aY
:= Y
div ScaleSz
;
3313 aX2
:= max(Width
div ScaleSz
, 1);
3314 aY2
:= max(Height
div ScaleSz
, 1);
3315 // Ïðàâûé íèæíèé óãîë:
3316 aX2
:= aX
+ aX2
- 1;
3317 aY2
:= aY
+ aY2
- 1;
3319 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 176, 0, 0, 0);
3322 if gPlayers
<> nil then
3325 for a
:= 0 to High(gPlayers
) do
3326 if gPlayers
[a
] <> nil then with gPlayers
[a
] do
3328 // Ëåâûé âåðõíèé óãîë:
3329 aX
:= Obj
.X
div ScaleSz
+ 1;
3330 aY
:= Obj
.Y
div ScaleSz
+ 1;
3332 aX2
:= max(Obj
.Rect
.Width
div ScaleSz
, 1);
3333 aY2
:= max(Obj
.Rect
.Height
div ScaleSz
, 1);
3334 // Ïðàâûé íèæíèé óãîë:
3335 aX2
:= aX
+ aX2
- 1;
3336 aY2
:= aY
+ aY2
- 1;
3338 if gPlayers
[a
] = p
then
3339 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 255, 0, 0)
3342 TEAM_RED
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 0, 0, 0);
3343 TEAM_BLUE
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 0, 255, 0);
3344 else e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 128, 0, 0);
3349 g_Mons_ForEach(monDraw
);
3354 procedure renderAmbientQuad (hasAmbient
: Boolean; constref ambColor
: TDFColor
);
3356 if not hasAmbient
then exit
;
3357 e_AmbientQuad(sX
, sY
, sWidth
, sHeight
, ambColor
.r
, ambColor
.g
, ambColor
.b
, ambColor
.a
);
3361 // setup sX, sY, sWidth, sHeight, and transformation matrix before calling this!
3362 //FIXME: broken for splitscreen mode
3363 procedure renderDynLightsInternal ();
3365 //hasAmbient: Boolean;
3366 //ambColor: TDFColor;
3368 lx
, ly
, lrad
: Integer;
3369 scxywh
: array[0..3] of GLint
;
3372 if e_NoGraphics
then exit
;
3374 //TODO: lights should be in separate grid, i think
3375 // but on the other side: grid may be slower for dynlights, as their lifetime is short
3376 if (not gwin_k8_enable_light_experiments
) or (not gwin_has_stencil
) or (g_dynLightCount
< 1) then exit
;
3379 //ambColor := gCurrentMap['light_ambient'].rgba;
3380 //hasAmbient := (not ambColor.isOpaque) or (not ambColor.isBlack);
3382 { // this will multiply incoming color to alpha from framebuffer
3384 glBlendFunc(GL_DST_ALPHA, GL_ONE);
3388 * light rendering: (INVALID!)
3389 * glStencilFunc(GL_EQUAL, 0, $ff);
3391 * glClear(GL_STENCIL_BUFFER_BIT);
3392 * glStencilOp(GL_KEEP, GL_KEEP, GL_INCR);
3393 * draw shadow volume into stencil buffer
3394 * glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); // modify color buffer
3395 * glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); // don't modify stencil buffer
3397 * draw color-less quad with light alpha (WARNING! don't touch color!)
3398 * glEnable(GL_BLEND);
3399 * glBlendFunc(GL_DST_ALPHA, GL_ONE);
3400 * draw all geometry up to and including walls (with alpha-testing, probably) -- this does lighting
3402 wassc
:= (glIsEnabled(GL_SCISSOR_TEST
) <> 0);
3403 if wassc
then glGetIntegerv(GL_SCISSOR_BOX
, @scxywh
[0]) else glGetIntegerv(GL_VIEWPORT
, @scxywh
[0]);
3405 // setup OpenGL parameters
3406 glStencilMask($FFFFFFFF);
3407 glStencilFunc(GL_ALWAYS
, 0, $FFFFFFFF);
3408 glEnable(GL_STENCIL_TEST
);
3409 glEnable(GL_SCISSOR_TEST
);
3410 glClear(GL_STENCIL_BUFFER_BIT
);
3411 glStencilFunc(GL_EQUAL
, 0, $ff);
3413 for lln
:= 0 to g_dynLightCount
-1 do
3415 lx
:= g_dynLights
[lln
].x
;
3416 ly
:= g_dynLights
[lln
].y
;
3417 lrad
:= g_dynLights
[lln
].radius
;
3418 if (lrad
< 3) then continue
;
3420 if (lx
-sX
+lrad
< 0) then continue
;
3421 if (ly
-sY
+lrad
< 0) then continue
;
3422 if (lx
-sX
-lrad
>= gPlayerScreenSize
.X
) then continue
;
3423 if (ly
-sY
-lrad
>= gPlayerScreenSize
.Y
) then continue
;
3425 // set scissor to optimize drawing
3426 if (g_dbg_scale
= 1.0) then
3428 glScissor((lx
-sX
)-lrad
+2, gPlayerScreenSize
.Y
-(ly
-sY
)-lrad
-1+2, lrad
*2-4, lrad
*2-4);
3432 glScissor(0, 0, gScreenWidth
, gScreenHeight
);
3434 // no need to clear stencil buffer, light blitting will do it for us... but only for normal scale
3435 if (g_dbg_scale
<> 1.0) then glClear(GL_STENCIL_BUFFER_BIT
);
3436 glStencilOp(GL_KEEP
, GL_KEEP
, GL_INCR
);
3437 // draw extruded panels
3438 glDisable(GL_TEXTURE_2D
);
3439 glDisable(GL_BLEND
);
3440 glColorMask(GL_FALSE
, GL_FALSE
, GL_FALSE
, GL_FALSE
); // no need to modify color buffer
3441 if (lrad
> 4) then g_Map_DrawPanelShadowVolumes(lx
, ly
, lrad
);
3442 // render light texture
3443 glColorMask(GL_TRUE
, GL_TRUE
, GL_TRUE
, GL_TRUE
); // modify color buffer
3444 glStencilOp(GL_ZERO
, GL_ZERO
, GL_ZERO
); // draw light, and clear stencil buffer
3447 glBlendFunc(GL_SRC_ALPHA
, GL_ONE_MINUS_SRC_ALPHA
);
3448 glEnable(GL_TEXTURE_2D
);
3449 // color and opacity
3450 glColor4f(g_dynLights
[lln
].r
, g_dynLights
[lln
].g
, g_dynLights
[lln
].b
, g_dynLights
[lln
].a
);
3451 glBindTexture(GL_TEXTURE_2D
, g_Texture_Light());
3453 glTexCoord2f(0.0, 0.0); glVertex2i(lx
-lrad
, ly
-lrad
); // top-left
3454 glTexCoord2f(1.0, 0.0); glVertex2i(lx
+lrad
, ly
-lrad
); // top-right
3455 glTexCoord2f(1.0, 1.0); glVertex2i(lx
+lrad
, ly
+lrad
); // bottom-right
3456 glTexCoord2f(0.0, 1.0); glVertex2i(lx
-lrad
, ly
+lrad
); // bottom-left
3461 glDisable(GL_STENCIL_TEST
);
3462 glDisable(GL_BLEND
);
3463 glDisable(GL_SCISSOR_TEST
);
3464 //glScissor(0, 0, sWidth, sHeight);
3466 glScissor(scxywh
[0], scxywh
[1], scxywh
[2], scxywh
[3]);
3467 if wassc
then glEnable(GL_SCISSOR_TEST
) else glDisable(GL_SCISSOR_TEST
);
3471 function fixViewportForScale (): Boolean;
3473 nx0
, ny0
, nw
, nh
: Integer;
3476 if (g_dbg_scale
<> 1.0) then
3479 nx0
:= round(sX
-(gPlayerScreenSize
.X
-(sWidth
*g_dbg_scale
))/2/g_dbg_scale
);
3480 ny0
:= round(sY
-(gPlayerScreenSize
.Y
-(sHeight
*g_dbg_scale
))/2/g_dbg_scale
);
3481 nw
:= round(sWidth
/g_dbg_scale
);
3482 nh
:= round(sHeight
/g_dbg_scale
);
3491 // setup sX, sY, sWidth, sHeight, and transformation matrix before calling this!
3492 // WARNING! this WILL CALL `glTranslatef()`, but won't restore matrices!
3493 procedure renderMapInternal (backXOfs
, backYOfs
: Integer; setTransMatrix
: Boolean);
3495 TDrawCB
= procedure ();
3498 hasAmbient
: Boolean;
3500 doAmbient
: Boolean = false;
3502 procedure drawPanelType (profname
: AnsiString; panType
: DWord
; doDraw
: Boolean);
3507 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin(profname
);
3508 if gdbg_map_use_accel_render
then
3510 tagmask
:= panelTypeToTag(panType
);
3511 while (gDrawPanelList
.count
> 0) do
3513 pan
:= TPanel(gDrawPanelList
.front());
3514 if ((pan
.tag
and tagmask
) = 0) then break
;
3515 if doDraw
then pan
.Draw(doAmbient
, ambColor
);
3516 gDrawPanelList
.popFront();
3521 if doDraw
then g_Map_DrawPanels(panType
, hasAmbient
, ambColor
);
3523 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
3526 procedure drawOther (profname
: AnsiString; cb
: TDrawCB
);
3528 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin(profname
);
3529 if assigned(cb
) then cb();
3530 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
3534 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin('total');
3536 // our accelerated renderer will collect all panels to gDrawPanelList
3537 // we can use panel tag to render level parts (see GridTagXXX in g_map.pas)
3538 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin('collect');
3539 if gdbg_map_use_accel_render
then
3541 g_Map_CollectDrawPanels(sX
, sY
, sWidth
, sHeight
);
3543 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
3545 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin('skyback');
3546 g_Map_DrawBack(backXOfs
, backYOfs
);
3547 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
3549 if setTransMatrix
then
3551 //if (g_dbg_scale <> 1.0) then glTranslatef(0.0, -0.375/2, 0);
3552 glScalef(g_dbg_scale
, g_dbg_scale
, 1.0);
3553 glTranslatef(-sX
, -sY
, 0);
3557 ambColor
:= gCurrentMap
['light_ambient'].rgba
;
3558 hasAmbient
:= (not ambColor
.isOpaque
) or (not ambColor
.isBlack
);
3563 //writeln('color: (', ambColor.r, ',', ambColor.g, ',', ambColor.b, ',', ambColor.a, ')');
3564 glColor4ub(ambColor.r, ambColor.g, ambColor.b, ambColor.a);
3565 glClear(GL_COLOR_BUFFER_BIT);
3568 //writeln('color: (', ambColor.r, ',', ambColor.g, ',', ambColor.b, ',', ambColor.a, ')');
3571 drawPanelType('*back', PANEL_BACK
, g_rlayer_back
);
3572 drawPanelType('*step', PANEL_STEP
, g_rlayer_step
);
3573 drawOther('items', @g_Items_Draw
);
3574 drawOther('weapons', @g_Weapon_Draw
);
3575 drawOther('shells', @g_Player_DrawShells
);
3576 drawOther('drawall', @g_Player_DrawAll
);
3577 drawOther('corpses', @g_Player_DrawCorpses
);
3578 drawPanelType('*wall', PANEL_WALL
, g_rlayer_wall
);
3579 drawOther('monsters', @g_Monsters_Draw
);
3580 drawOther('itemdrop', @g_Items_DrawDrop
);
3581 drawPanelType('*door', PANEL_CLOSEDOOR
, g_rlayer_door
);
3582 drawOther('gfx', @g_GFX_Draw
);
3583 drawOther('flags', @g_Map_DrawFlags
);
3584 drawPanelType('*acid1', PANEL_ACID1
, g_rlayer_acid1
);
3585 drawPanelType('*acid2', PANEL_ACID2
, g_rlayer_acid2
);
3586 drawPanelType('*water', PANEL_WATER
, g_rlayer_water
);
3587 drawOther('dynlights', @renderDynLightsInternal
);
3589 if hasAmbient
{and ((not g_playerLight) or (not gwin_has_stencil) or (g_dynLightCount < 1))} then
3591 renderAmbientQuad(hasAmbient
, ambColor
);
3595 drawPanelType('*fore', PANEL_FORE
, g_rlayer_fore
);
3598 if g_debug_HealthBar
then
3600 g_Monsters_DrawHealth();
3601 g_Player_DrawHealth();
3604 if (profileFrameDraw
<> nil) then profileFrameDraw
.mainEnd(); // map rendering
3608 procedure DrawMapView(x
, y
, w
, h
: Integer);
3615 bx
:= Round(x
/(gMapInfo
.Width
- w
)*(gBackSize
.X
- w
));
3616 by
:= Round(y
/(gMapInfo
.Height
- h
)*(gBackSize
.Y
- h
));
3623 fixViewportForScale();
3624 renderMapInternal(-bx
, -by
, true);
3630 procedure DrawPlayer(p
: TPlayer
);
3632 px
, py
, a
, b
, c
, d
, i
, fX
, fY
: Integer;
3636 if (p
= nil) or (p
.FDummy
) then
3639 g_Map_DrawBack(0, 0);
3644 if (profileFrameDraw
= nil) then profileFrameDraw
:= TProfiler
.Create('RENDER', g_profile_history_size
);
3645 if (profileFrameDraw
<> nil) then profileFrameDraw
.mainBegin(g_profile_frame_draw
);
3651 camObj
:= p
.getCameraObj();
3652 camObj
.lerp(gLerpFactor
, fX
, fY
);
3653 px
:= fX
+ PLAYER_RECT_CX
;
3654 py
:= fY
+ PLAYER_RECT_CY
+nlerp(p
.SlopeOld
, camObj
.slopeUpLeft
, gLerpFactor
);
3656 if (g_dbg_scale
= 1.0) and (not g_dbg_ignore_bounds
) then
3658 if (px
> (gPlayerScreenSize
.X
div 2)) then a
:= -px
+(gPlayerScreenSize
.X
div 2) else a
:= 0;
3659 if (py
> (gPlayerScreenSize
.Y
div 2)) then b
:= -py
+(gPlayerScreenSize
.Y
div 2) else b
:= 0;
3661 if (px
> gMapInfo
.Width
-(gPlayerScreenSize
.X
div 2)) then a
:= -gMapInfo
.Width
+gPlayerScreenSize
.X
;
3662 if (py
> gMapInfo
.Height
-(gPlayerScreenSize
.Y
div 2)) then b
:= -gMapInfo
.Height
+gPlayerScreenSize
.Y
;
3664 if (gMapInfo
.Width
= gPlayerScreenSize
.X
) then a
:= 0
3665 else if (gMapInfo
.Width
< gPlayerScreenSize
.X
) then
3668 a
:= (gPlayerScreenSize
.X
-gMapInfo
.Width
) div 2;
3671 if (gMapInfo
.Height
= gPlayerScreenSize
.Y
) then b
:= 0
3672 else if (gMapInfo
.Height
< gPlayerScreenSize
.Y
) then
3675 b
:= (gPlayerScreenSize
.Y
-gMapInfo
.Height
) div 2;
3680 // scaled, ignore level bounds
3681 a
:= -px
+(gPlayerScreenSize
.X
div 2);
3682 b
:= -py
+(gPlayerScreenSize
.Y
div 2);
3687 sWidth
:= gPlayerScreenSize
.X
;
3688 sHeight
:= gPlayerScreenSize
.Y
;
3689 fixViewportForScale();
3691 i
:= py
- (sY
+ sHeight
div 2);
3692 if (p
.IncCam
> 0) then
3694 // clamp to level bounds
3695 if (sY
- p
.IncCam
< 0) then
3696 p
.IncCam
:= nclamp(sY
, 0, 120);
3697 // clamp around player position
3699 p
.IncCam
:= nclamp(p
.IncCam
, 0, max(0, 120 - i
));
3701 else if (p
.IncCam
< 0) then
3703 // clamp to level bounds
3704 if (sY
+ sHeight
- p
.IncCam
> gMapInfo
.Height
) then
3705 p
.IncCam
:= nclamp(sY
+ sHeight
- gMapInfo
.Height
, -120, 0);
3706 // clamp around player position
3708 p
.IncCam
:= nclamp(p
.IncCam
, min(0, -120 - i
), 0);
3711 sY
:= sY
- nlerp(p
.IncCamOld
, p
.IncCam
, gLerpFactor
);
3713 if (not g_dbg_ignore_bounds
) then
3715 if (sX
+sWidth
> gMapInfo
.Width
) then sX
:= gMapInfo
.Width
-sWidth
;
3716 if (sY
+sHeight
> gMapInfo
.Height
) then sY
:= gMapInfo
.Height
-sHeight
;
3717 if (sX
< 0) then sX
:= 0;
3718 if (sY
< 0) then sY
:= 0;
3721 if (gBackSize
.X
<= gPlayerScreenSize
.X
) or (gMapInfo
.Width
<= sWidth
) then c
:= 0 else c
:= trunc((gBackSize
.X
-gPlayerScreenSize
.X
)*sX
/(gMapInfo
.Width
-sWidth
));
3722 if (gBackSize
.Y
<= gPlayerScreenSize
.Y
) or (gMapInfo
.Height
<= sHeight
) then d
:= 0 else d
:= trunc((gBackSize
.Y
-gPlayerScreenSize
.Y
)*sY
/(gMapInfo
.Height
-sHeight
));
3724 //r_smallmap_h: 0: left; 1: center; 2: right
3725 //r_smallmap_v: 0: top; 1: center; 2: bottom
3727 if (gMapInfo
.Width
= sWidth
) then
3731 else if (gMapInfo
.Width
< sWidth
) then
3733 case r_smallmap_h
of
3734 1: sX
:= -((sWidth
-gMapInfo
.Width
) div 2); // center
3735 2: sX
:= -(sWidth
-gMapInfo
.Width
); // right
3736 else sX
:= 0; // left
3740 if (gMapInfo
.Height
= sHeight
) then
3744 else if (gMapInfo
.Height
< sHeight
) then
3746 case r_smallmap_v
of
3747 1: sY
:= -((sHeight
-gMapInfo
.Height
) div 2); // center
3748 2: sY
:= -(sHeight
-gMapInfo
.Height
); // bottom
3749 else sY
:= 0; // top
3755 p
.viewPortW
:= sWidth
;
3756 p
.viewPortH
:= sHeight
;
3758 {$IFDEF ENABLE_HOLMES}
3759 if (p
= gPlayer1
) then
3761 g_Holmes_plrViewPos(sX
, sY
);
3762 g_Holmes_plrViewSize(sWidth
, sHeight
);
3766 renderMapInternal(-c
, -d
, true);
3768 if (gGameSettings
.GameMode
<> GM_SINGLE
) and (gPlayerIndicator
> 0) then
3769 case gPlayerIndicator
of
3771 p
.DrawIndicator(_RGB(255, 255, 255));
3774 for i
:= 0 to High(gPlayers
) do
3775 if gPlayers
[i
] <> nil then
3776 if gPlayers
[i
] = p
then p
.DrawIndicator(_RGB(255, 255, 255))
3777 else if (gPlayers
[i
].Team
= p
.Team
) and (gPlayers
[i
].Team
<> TEAM_NONE
) then
3778 if gPlayerIndicatorStyle
= 1 then
3779 gPlayers
[i
].DrawIndicator(_RGB(192, 192, 192))
3780 else gPlayers
[i
].DrawIndicator(gPlayers
[i
].GetColor
);
3784 for a := 0 to High(gCollideMap) do
3785 for b := 0 to High(gCollideMap[a]) do
3788 if ByteBool(gCollideMap[a, b] and MARK_WALL) then
3790 if ByteBool(gCollideMap[a, b] and MARK_DOOR) then
3794 1: e_DrawPoint(1, b, a, 200, 200, 200);
3795 2: e_DrawPoint(1, b, a, 64, 64, 255);
3796 3: e_DrawPoint(1, b, a, 255, 0, 255);
3806 if gShowMap
then DrawMinimap(p
, _TRect(0, 0, 128, 128));
3807 if g_Debug_Player
then
3808 g_Player_DrawDebug(p
);
3812 procedure drawProfilers ();
3817 if g_profile_frame_draw
and (profileFrameDraw
<> nil) then px
:= px
-drawProfiles(px
, py
, profileFrameDraw
);
3818 if g_profile_collision
and (profMapCollision
<> nil) then begin px
:= px
-drawProfiles(px
, py
, profMapCollision
); py
-= calcProfilesHeight(profMonsLOS
); end;
3819 if g_profile_los
and (profMonsLOS
<> nil) then begin px
:= px
-drawProfiles(px
, py
, profMonsLOS
); py
-= calcProfilesHeight(profMonsLOS
); end;
3822 procedure g_Game_Draw();
3829 plView1
, plView2
: TPlayer
;
3832 if gExit
= EXIT_QUIT
then Exit
;
3834 Time
:= sys_GetTicks() {div 1000};
3835 FPSCounter
:= FPSCounter
+1;
3836 if Time
- FPSTime
>= 1000 then
3843 e_SetRendertarget(True);
3844 e_SetViewPort(0, 0, gScreenWidth
, gScreenHeight
);
3846 if gGameOn
or (gState
= STATE_FOLD
) then
3848 if (gPlayer1
<> nil) and (gPlayer2
<> nil) then
3850 gSpectMode
:= SPECT_NONE
;
3851 if not gRevertPlayers
then
3853 plView1
:= gPlayer1
;
3854 plView2
:= gPlayer2
;
3858 plView1
:= gPlayer2
;
3859 plView2
:= gPlayer1
;
3863 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
3865 gSpectMode
:= SPECT_NONE
;
3866 if gPlayer2
= nil then
3869 plView1
:= gPlayer2
;
3878 if (plView1
= nil) and (plView2
= nil) and (gSpectMode
= SPECT_NONE
) then
3879 gSpectMode
:= SPECT_STATS
;
3881 if gSpectMode
= SPECT_PLAYERS
then
3882 if gPlayers
<> nil then
3884 plView1
:= GetActivePlayer_ByID(gSpectPID1
);
3885 if plView1
= nil then
3887 gSpectPID1
:= GetActivePlayerID_Next();
3888 plView1
:= GetActivePlayer_ByID(gSpectPID1
);
3890 if gSpectViewTwo
then
3892 plView2
:= GetActivePlayer_ByID(gSpectPID2
);
3893 if plView2
= nil then
3895 gSpectPID2
:= GetActivePlayerID_Next();
3896 plView2
:= GetActivePlayer_ByID(gSpectPID2
);
3901 if gSpectMode
= SPECT_MAPVIEW
then
3903 // Ðåæèì ïðîñìîòðà êàðòû
3905 e_SetViewPort(0, 0, gScreenWidth
, gScreenHeight
);
3906 DrawMapView(gSpectX
, gSpectY
, gScreenWidth
, gScreenHeight
);
3907 gHearPoint1
.Active
:= True;
3908 gHearPoint1
.Coords
.X
:= gScreenWidth
div 2 + gSpectX
;
3909 gHearPoint1
.Coords
.Y
:= gScreenHeight
div 2 + gSpectY
;
3910 gHearPoint2
.Active
:= False;
3914 Split
:= (plView1
<> nil) and (plView2
<> nil);
3916 // Òî÷êè ñëóõà èãðîêîâ
3917 if plView1
<> nil then
3919 gHearPoint1
.Active
:= True;
3920 gHearPoint1
.Coords
.X
:= plView1
.GameX
+ PLAYER_RECT
.Width
;
3921 gHearPoint1
.Coords
.Y
:= plView1
.GameY
+ PLAYER_RECT
.Height
DIV 2;
3923 gHearPoint1
.Active
:= False;
3924 if plView2
<> nil then
3926 gHearPoint2
.Active
:= True;
3927 gHearPoint2
.Coords
.X
:= plView2
.GameX
+ PLAYER_RECT
.Width
;
3928 gHearPoint2
.Coords
.Y
:= plView2
.GameY
+ PLAYER_RECT
.Height
DIV 2;
3930 gHearPoint2
.Active
:= False;
3932 // Ðàçìåð ýêðàíîâ èãðîêîâ:
3933 gPlayerScreenSize
.X
:= gScreenWidth
-196;
3936 gPlayerScreenSize
.Y
:= gScreenHeight
div 2;
3937 if gScreenHeight
mod 2 = 0 then
3938 Dec(gPlayerScreenSize
.Y
);
3941 gPlayerScreenSize
.Y
:= gScreenHeight
;
3944 if gScreenHeight
mod 2 = 0 then
3945 e_SetViewPort(0, gPlayerScreenSize
.Y
+2, gPlayerScreenSize
.X
+196, gPlayerScreenSize
.Y
)
3947 e_SetViewPort(0, gPlayerScreenSize
.Y
+1, gPlayerScreenSize
.X
+196, gPlayerScreenSize
.Y
);
3949 DrawPlayer(plView1
);
3950 gPlayer1ScreenCoord
.X
:= sX
;
3951 gPlayer1ScreenCoord
.Y
:= sY
;
3955 e_SetViewPort(0, 0, gPlayerScreenSize
.X
+196, gPlayerScreenSize
.Y
);
3957 DrawPlayer(plView2
);
3958 gPlayer2ScreenCoord
.X
:= sX
;
3959 gPlayer2ScreenCoord
.Y
:= sY
;
3962 e_SetViewPort(0, 0, gScreenWidth
, gScreenHeight
);
3965 e_DrawLine(2, 0, gScreenHeight
div 2, gScreenWidth
, gScreenHeight
div 2, 0, 0, 0);
3968 {$IFDEF ENABLE_HOLMES}
3970 if (g_holmes_enabled
) then g_Holmes_Draw();
3973 if MessageText
<> '' then
3977 e_CharFont_GetSizeFmt(gMenuFont
, MessageText
, w
, h
);
3979 e_CharFont_PrintFmt(gMenuFont
, (gScreenWidth
div 2)-(w
div 2),
3980 (gScreenHeight
div 2)-(h
div 2), MessageText
)
3982 e_CharFont_PrintFmt(gMenuFont
, (gScreenWidth
div 2)-(w
div 2),
3983 Round(gScreenHeight
/ 2.75)-(h
div 2), MessageText
);
3986 if IsDrawStat
or (gSpectMode
= 1) then DrawStat();
3988 if gSpectHUD
and (not gChatShow
) and (gSpectMode
<> SPECT_NONE
) and (not gSpectAuto
) then
3990 // Draw spectator GUI
3993 e_TextureFontGetSize(gStdFont
, ww
, hh
);
3996 e_TextureFontPrintEx(0, gScreenHeight
- (hh
+2)*2, 'MODE: Stats', gStdFont
, 255, 255, 255, 1);
3998 e_TextureFontPrintEx(0, gScreenHeight
- (hh
+2)*2, 'MODE: Observe Map', gStdFont
, 255, 255, 255, 1);
4000 e_TextureFontPrintEx(0, gScreenHeight
- (hh
+2)*2, 'MODE: Watch Players', gStdFont
, 255, 255, 255, 1);
4002 e_TextureFontPrintEx(2*ww
, gScreenHeight
- (hh
+2), '< jump >', gStdFont
, 255, 255, 255, 1);
4003 if gSpectMode
= SPECT_STATS
then
4005 e_TextureFontPrintEx(16*ww
, gScreenHeight
- (hh
+2)*2, 'Autoview', gStdFont
, 255, 255, 255, 1);
4006 e_TextureFontPrintEx(16*ww
, gScreenHeight
- (hh
+2), '< fire >', gStdFont
, 255, 255, 255, 1);
4008 if gSpectMode
= SPECT_MAPVIEW
then
4010 e_TextureFontPrintEx(22*ww
, gScreenHeight
- (hh
+2)*2, '[-]', gStdFont
, 255, 255, 255, 1);
4011 e_TextureFontPrintEx(26*ww
, gScreenHeight
- (hh
+2)*2, 'Step ' + IntToStr(gSpectStep
), gStdFont
, 255, 255, 255, 1);
4012 e_TextureFontPrintEx(34*ww
, gScreenHeight
- (hh
+2)*2, '[+]', gStdFont
, 255, 255, 255, 1);
4013 e_TextureFontPrintEx(18*ww
, gScreenHeight
- (hh
+2), '<prev weap>', gStdFont
, 255, 255, 255, 1);
4014 e_TextureFontPrintEx(30*ww
, gScreenHeight
- (hh
+2), '<next weap>', gStdFont
, 255, 255, 255, 1);
4016 if gSpectMode
= SPECT_PLAYERS
then
4018 e_TextureFontPrintEx(22*ww
, gScreenHeight
- (hh
+2)*2, 'Player 1', gStdFont
, 255, 255, 255, 1);
4019 e_TextureFontPrintEx(20*ww
, gScreenHeight
- (hh
+2), '<left/right>', gStdFont
, 255, 255, 255, 1);
4020 if gSpectViewTwo
then
4022 e_TextureFontPrintEx(37*ww
, gScreenHeight
- (hh
+2)*2, 'Player 2', gStdFont
, 255, 255, 255, 1);
4023 e_TextureFontPrintEx(34*ww
, gScreenHeight
- (hh
+2), '<prev w/next w>', gStdFont
, 255, 255, 255, 1);
4024 e_TextureFontPrintEx(52*ww
, gScreenHeight
- (hh
+2)*2, '2x View', gStdFont
, 255, 255, 255, 1);
4025 e_TextureFontPrintEx(51*ww
, gScreenHeight
- (hh
+2), '<up/down>', gStdFont
, 255, 255, 255, 1);
4029 e_TextureFontPrintEx(35*ww
, gScreenHeight
- (hh
+2)*2, '2x View', gStdFont
, 255, 255, 255, 1);
4030 e_TextureFontPrintEx(34*ww
, gScreenHeight
- (hh
+2), '<up/down>', gStdFont
, 255, 255, 255, 1);
4036 if gPauseMain
and gGameOn
and (g_ActiveWindow
= nil) then
4038 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4039 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4041 e_CharFont_GetSize(gMenuFont
, _lc
[I_MENU_PAUSE
], w
, h
);
4042 e_CharFont_Print(gMenuFont
, (gScreenWidth
div 2)-(w
div 2),
4043 (gScreenHeight
div 2)-(h
div 2), _lc
[I_MENU_PAUSE
]);
4048 if (gState
= STATE_MENU
) then
4050 if (g_ActiveWindow
= nil) or (g_ActiveWindow
.BackTexture
= '') then DrawMenuBackground('MENU_BACKGROUND');
4051 // F3 at menu will show game loading dialog
4052 if e_KeyPressed(IK_F3
) then g_Menu_Show_LoadMenu(true);
4053 if (g_ActiveWindow
<> nil) then
4055 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4056 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4060 // F3 at titlepic will show game loading dialog
4061 if e_KeyPressed(IK_F3
) then
4063 g_Menu_Show_LoadMenu(true);
4064 if (g_ActiveWindow
<> nil) then e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4069 if gState
= STATE_FOLD
then
4071 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 0, 0, 0, EndingGameCounter
);
4074 if gState
= STATE_INTERCUSTOM
then
4076 if gLastMap
and (gGameSettings
.GameMode
= GM_COOP
) then
4078 back
:= 'TEXTURE_endpic';
4079 if not g_Texture_Get(back
, ID
) then
4080 back
:= _lc
[I_TEXTURE_ENDPIC
];
4085 DrawMenuBackground(back
);
4089 if g_ActiveWindow
<> nil then
4091 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4092 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4096 if gState
= STATE_INTERSINGLE
then
4098 if EndingGameCounter
> 0 then
4100 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 0, 0, 0, EndingGameCounter
);
4106 DrawMenuBackground(back
);
4110 if g_ActiveWindow
<> nil then
4112 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4113 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4118 if gState
= STATE_ENDPIC
then
4121 if g_Texture_Get('TEXTURE_endpic', ID
) then DrawMenuBackground('TEXTURE_endpic')
4122 else DrawMenuBackground(_lc
[I_TEXTURE_ENDPIC
]);
4124 if g_ActiveWindow
<> nil then
4126 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4127 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4131 if gState
= STATE_SLIST
then
4133 // if g_Texture_Get('MENU_BACKGROUND', ID) then
4135 // e_DrawSize(ID, 0, 0, 0, False, False, gScreenWidth, gScreenHeight);
4136 // //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4138 DrawMenuBackground('MENU_BACKGROUND');
4139 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4140 g_Serverlist_Draw(slCurrent
, slTable
);
4144 if g_ActiveWindow
<> nil then
4148 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4149 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4151 g_ActiveWindow
.Draw();
4158 if g_debug_Sounds
and gGameOn
then
4160 for w
:= 0 to High(e_SoundsArray
) do
4161 for h
:= 0 to e_SoundsArray
[w
].nRefs
do
4162 e_DrawPoint(1, w
+100, h
+100, 255, 0, 0);
4167 e_TextureFontPrint(0, 0, Format('FPS: %d', [FPS
]), gStdFont
);
4168 e_TextureFontPrint(0, 16, Format('UPS: %d', [UPS
]), gStdFont
);
4171 if gGameOn
and gShowTime
then
4172 drawTime(gScreenWidth
-72, gScreenHeight
-16);
4174 if gGameOn
then drawProfilers();
4176 // TODO: draw this after the FBO and remap mouse click coordinates
4178 {$IFDEF ENABLE_HOLMES}
4182 // blit framebuffer to screen
4184 e_SetRendertarget(False);
4185 e_SetViewPort(0, 0, gWinSizeX
, gWinSizeY
);
4186 e_BlitFramebuffer(gWinSizeX
, gWinSizeY
);
4188 // draw the overlay stuff on top of it
4193 procedure g_Game_Quit();
4195 g_Game_StopAllSounds(True);
4198 g_PlayerModel_FreeData();
4199 g_Texture_DeleteAll();
4200 g_Frames_DeleteAll();
4202 //g_Menu_Free(); //k8: this segfaults after resolution change; who cares?
4205 if NetInitDone
then g_Net_Free
;
4207 // Íàäî óäàëèòü êàðòó ïîñëå òåñòà:
4208 if gMapToDelete
<> '' then
4209 g_Game_DeleteTestMap();
4215 procedure g_FatalError(Text: String);
4217 g_Console_Add(Format(_lc
[I_FATAL_ERROR
], [Text]), True);
4218 e_WriteLog(Format(_lc
[I_FATAL_ERROR
], [Text]), TMsgType
.Warning
);
4220 gExit
:= EXIT_SIMPLE
;
4223 procedure g_SimpleError(Text: String);
4225 g_Console_Add(Format(_lc
[I_SIMPLE_ERROR
], [Text]), True);
4226 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], [Text]), TMsgType
.Warning
);
4229 procedure g_Game_SetupScreenSize();
4231 RES_FACTOR
= 4.0 / 3.0;
4237 // Ðàçìåð ýêðàíîâ èãðîêîâ:
4238 gPlayerScreenSize
.X
:= gScreenWidth
-196;
4239 if (gPlayer1
<> nil) and (gPlayer2
<> nil) then
4240 gPlayerScreenSize
.Y
:= gScreenHeight
div 2
4242 gPlayerScreenSize
.Y
:= gScreenHeight
;
4244 // Ðàçìåð çàäíåãî ïëàíà:
4245 if BackID
<> DWORD(-1) then
4248 if (gScreenWidth
*s
> gMapInfo
.Width
) or
4249 (gScreenHeight
*s
> gMapInfo
.Height
) then
4251 gBackSize
.X
:= gScreenWidth
;
4252 gBackSize
.Y
:= gScreenHeight
;
4256 e_GetTextureSize(BackID
, @bw
, @bh
);
4257 rf
:= Single(bw
) / Single(bh
);
4258 if (rf
> RES_FACTOR
) then bw
:= Round(Single(bh
) * RES_FACTOR
)
4259 else if (rf
< RES_FACTOR
) then bh
:= Round(Single(bw
) / RES_FACTOR
);
4260 s
:= Max(gScreenWidth
/ bw
, gScreenHeight
/ bh
);
4261 if (s
< 1.0) then s
:= 1.0;
4262 gBackSize
.X
:= Round(bw
*s
);
4263 gBackSize
.Y
:= Round(bh
*s
);
4268 procedure g_Game_ChangeResolution(newWidth
, newHeight
: Word; nowFull
, nowMax
: Boolean);
4270 sys_SetDisplayMode(newWidth
, newHeight
, gBPP
, nowFull
, nowMax
);
4273 procedure g_Game_AddPlayer(Team
: Byte = TEAM_NONE
);
4275 if ((not gGameOn
) and (gState
<> STATE_INTERCUSTOM
))
4276 or (not (gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
])) then
4279 if (gGameSettings
.MaxLives
> 0) and (gLMSRespawn
= LMS_RESPAWN_NONE
) then
4282 if gPlayer1
= nil then
4284 if g_Game_IsClient
then
4286 if NetPlrUID1
> -1 then
4287 MC_SEND_CheatRequest(NET_CHEAT_SPECTATE
);
4291 if not (Team
in [TEAM_RED
, TEAM_BLUE
]) then
4292 Team
:= gPlayer1Settings
.Team
;
4294 // Ñîçäàíèå ïåðâîãî èãðîêà:
4295 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4296 gPlayer1Settings
.Color
,
4298 if gPlayer1
= nil then
4299 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]))
4302 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4303 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [gPlayer1
.Name
]), True);
4304 if g_Game_IsServer
and g_Game_IsNet
then
4305 MH_SEND_PlayerCreate(gPlayer1
.UID
);
4306 gPlayer1
.Respawn(False, True);
4307 g_Net_Slist_ServerPlayerComes();
4312 if gPlayer2
= nil then
4314 if g_Game_IsClient
then
4316 if NetPlrUID2
> -1 then
4317 gPlayer2
:= g_Player_Get(NetPlrUID2
);
4321 if not (Team
in [TEAM_RED
, TEAM_BLUE
]) then
4322 Team
:= gPlayer2Settings
.Team
;
4324 // Ñîçäàíèå âòîðîãî èãðîêà:
4325 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
4326 gPlayer2Settings
.Color
,
4328 if gPlayer2
= nil then
4329 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]))
4332 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
4333 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [gPlayer2
.Name
]), True);
4334 if g_Game_IsServer
and g_Game_IsNet
then
4335 MH_SEND_PlayerCreate(gPlayer2
.UID
);
4336 gPlayer2
.Respawn(False, True);
4337 g_Net_Slist_ServerPlayerComes();
4344 procedure g_Game_RemovePlayer();
4348 if ((not gGameOn
) and (gState
<> STATE_INTERCUSTOM
))
4349 or (not (gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
])) then
4354 if g_Game_IsServer
then
4357 Pl
.Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
4358 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [Pl
.Name
]), True);
4359 g_Player_Remove(Pl
.UID
);
4360 g_Net_Slist_ServerPlayerLeaves();
4364 gSpectLatchPID2
:= Pl
.UID
;
4372 if g_Game_IsServer
then
4375 Pl
.Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
4376 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [Pl
.Name
]), True);
4377 g_Player_Remove(Pl
.UID
);
4378 g_Net_Slist_ServerPlayerLeaves();
4381 gSpectLatchPID1
:= Pl
.UID
;
4383 MC_SEND_CheatRequest(NET_CHEAT_SPECTATE
);
4387 g_Net_Slist_ServerPlayerLeaves();
4390 procedure g_Game_Spectate();
4392 g_Game_RemovePlayer();
4393 if gPlayer1
<> nil then
4394 g_Game_RemovePlayer();
4397 procedure g_Game_SpectateCenterView();
4399 gSpectX
:= Max(gMapInfo
.Width
div 2 - gScreenWidth
div 2, 0);
4400 gSpectY
:= Max(gMapInfo
.Height
div 2 - gScreenHeight
div 2, 0);
4403 procedure g_Game_StartSingle(Map
: String; TwoPlayers
: Boolean; nPlayers
: Byte);
4410 e_WriteLog('Starting singleplayer game...', TMsgType
.Notify
);
4412 g_Game_ClearLoading();
4415 FillByte(gGameSettings
, SizeOf(TGameSettings
), 0);
4418 gGameSettings
.GameType
:= GT_SINGLE
;
4419 gGameSettings
.MaxLives
:= 0;
4420 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_ALLOWEXIT
;
4421 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_MONSTERS
;
4422 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_BOTVSMONSTER
;
4423 gSwitchGameMode
:= GM_SINGLE
;
4425 gLMSRespawn
:= LMS_RESPAWN_NONE
;
4426 gLMSRespawnTime
:= 0;
4427 gSpectLatchPID1
:= 0;
4428 gSpectLatchPID2
:= 0;
4430 g_Game_ExecuteEvent('ongamestart');
4432 // Óñòàíîâêà ðàçìåðîâ îêîí èãðîêîâ:
4433 g_Game_SetupScreenSize();
4435 // Ñîçäàíèå ïåðâîãî èãðîêà:
4436 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4437 gPlayer1Settings
.Color
,
4438 gPlayer1Settings
.Team
, False));
4439 if gPlayer1
= nil then
4441 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
4445 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4448 // Ñîçäàíèå âòîðîãî èãðîêà, åñëè åñòü:
4451 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
4452 gPlayer2Settings
.Color
,
4453 gPlayer2Settings
.Team
, False));
4454 if gPlayer2
= nil then
4456 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
4460 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
4464 // Çàãðóçêà è çàïóñê êàðòû:
4465 if not g_Game_StartMap(false{asMegawad}, MAP
, True) then
4467 if (Pos(':\', Map
) > 0) or (Pos(':/', Map
) > 0) then tmps
:= Map
else tmps
:= gGameSettings
.WAD
+ ':\' + MAP
;
4468 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [tmps
]));
4472 // Íàñòðîéêè èãðîêîâ è áîòîâ:
4476 for i
:= nPl
+1 to nPlayers
do
4477 g_Player_Create(STD_PLAYER_MODEL
, _RGB(0, 0, 0), 0, True);
4480 procedure g_Game_StartCustom(Map
: String; GameMode
: Byte;
4481 TimeLimit
, GoalLimit
: Word;
4483 Options
: LongWord; nPlayers
: Byte);
4489 e_WriteLog('Starting custom game...', TMsgType
.Notify
);
4491 g_Game_ClearLoading();
4494 gGameSettings
.GameType
:= GT_CUSTOM
;
4495 gGameSettings
.GameMode
:= GameMode
;
4496 gSwitchGameMode
:= GameMode
;
4497 gGameSettings
.TimeLimit
:= TimeLimit
;
4498 gGameSettings
.GoalLimit
:= GoalLimit
;
4499 gGameSettings
.MaxLives
:= IfThen(GameMode
= GM_CTF
, 0, MaxLives
);
4500 gGameSettings
.Options
:= Options
;
4502 gCoopTotalMonstersKilled
:= 0;
4503 gCoopTotalSecretsFound
:= 0;
4504 gCoopTotalMonsters
:= 0;
4505 gCoopTotalSecrets
:= 0;
4509 gLMSRespawn
:= LMS_RESPAWN_NONE
;
4510 gLMSRespawnTime
:= 0;
4511 gSpectLatchPID1
:= 0;
4512 gSpectLatchPID2
:= 0;
4514 g_Game_ExecuteEvent('ongamestart');
4516 // Óñòàíîâêà ðàçìåðîâ îêîí èãðîêîâ:
4517 g_Game_SetupScreenSize();
4519 // Ðåæèì íàáëþäàòåëÿ:
4520 if nPlayers
= 0 then
4527 if nPlayers
>= 1 then
4529 // Ñîçäàíèå ïåðâîãî èãðîêà:
4530 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4531 gPlayer1Settings
.Color
,
4532 gPlayer1Settings
.Team
, False));
4533 if gPlayer1
= nil then
4535 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
4539 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4543 if nPlayers
>= 2 then
4545 // Ñîçäàíèå âòîðîãî èãðîêà:
4546 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
4547 gPlayer2Settings
.Color
,
4548 gPlayer2Settings
.Team
, False));
4549 if gPlayer2
= nil then
4551 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
4555 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
4559 // Çàãðóçêà è çàïóñê êàðòû:
4560 if not g_Game_StartMap(true{asMegawad}, Map
, True) then
4562 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [Map
]));
4566 // Íåò òî÷åê ïîÿâëåíèÿ:
4567 if (g_Map_GetPointCount(RESPAWNPOINT_PLAYER1
) +
4568 g_Map_GetPointCount(RESPAWNPOINT_PLAYER2
) +
4569 g_Map_GetPointCount(RESPAWNPOINT_DM
) +
4570 g_Map_GetPointCount(RESPAWNPOINT_RED
)+
4571 g_Map_GetPointCount(RESPAWNPOINT_BLUE
)) < 1 then
4573 g_FatalError(_lc
[I_GAME_ERROR_GET_SPAWN
]);
4577 // Íàñòðîéêè èãðîêîâ è áîòîâ:
4581 for i
:= nPl
+1 to nPlayers
do
4582 g_Player_Create(STD_PLAYER_MODEL
, _RGB(0, 0, 0), 0, True);
4585 procedure g_Game_StartServer(Map
: String; GameMode
: Byte;
4586 TimeLimit
, GoalLimit
: Word; MaxLives
: Byte;
4587 Options
: LongWord; nPlayers
: Byte;
4588 IPAddr
: LongWord; Port
: Word);
4591 g_Net_Slist_ServerClosed();
4593 e_WriteLog('Starting net game (server)...', TMsgType
.Notify
);
4595 g_Game_ClearLoading();
4598 gGameSettings
.GameType
:= GT_SERVER
;
4599 gGameSettings
.GameMode
:= GameMode
;
4600 gSwitchGameMode
:= GameMode
;
4601 gGameSettings
.TimeLimit
:= TimeLimit
;
4602 gGameSettings
.GoalLimit
:= GoalLimit
;
4603 gGameSettings
.MaxLives
:= IfThen(GameMode
= GM_CTF
, 0, MaxLives
);
4604 gGameSettings
.Options
:= Options
;
4606 gCoopTotalMonstersKilled
:= 0;
4607 gCoopTotalSecretsFound
:= 0;
4608 gCoopTotalMonsters
:= 0;
4609 gCoopTotalSecrets
:= 0;
4613 gLMSRespawn
:= LMS_RESPAWN_NONE
;
4614 gLMSRespawnTime
:= 0;
4615 gSpectLatchPID1
:= 0;
4616 gSpectLatchPID2
:= 0;
4618 g_Game_ExecuteEvent('ongamestart');
4620 // Óñòàíîâêà ðàçìåðîâ îêíà èãðîêà
4621 g_Game_SetupScreenSize();
4623 // Ðåæèì íàáëþäàòåëÿ:
4624 if nPlayers
= 0 then
4630 if nPlayers
>= 1 then
4632 // Ñîçäàíèå ïåðâîãî èãðîêà:
4633 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4634 gPlayer1Settings
.Color
,
4635 gPlayer1Settings
.Team
, False));
4636 if gPlayer1
= nil then
4638 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
4642 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4645 if nPlayers
>= 2 then
4647 // Ñîçäàíèå âòîðîãî èãðîêà:
4648 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
4649 gPlayer2Settings
.Color
,
4650 gPlayer2Settings
.Team
, False));
4651 if gPlayer2
= nil then
4653 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
4657 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
4660 g_Game_SetLoadingText(_lc
[I_LOAD_HOST
], 0, False);
4661 if NetForwardPorts
then
4662 g_Game_SetLoadingText(_lc
[I_LOAD_PORTS
], 0, False);
4665 if not g_Net_Host(IPAddr
, Port
, NetMaxClients
) then
4667 g_FatalError(_lc
[I_NET_MSG
] + Format(_lc
[I_NET_ERR_HOST
], [Port
]));
4671 g_Net_Slist_Set(NetMasterList
);
4673 g_Net_Slist_ServerStarted();
4675 // Çàãðóçêà è çàïóñê êàðòû:
4676 if not g_Game_StartMap(false{asMegawad}, Map
, True) then
4678 g_Net_Slist_ServerClosed();
4679 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [Map
]));
4683 // Íåò òî÷åê ïîÿâëåíèÿ:
4684 if (g_Map_GetPointCount(RESPAWNPOINT_PLAYER1
) +
4685 g_Map_GetPointCount(RESPAWNPOINT_PLAYER2
) +
4686 g_Map_GetPointCount(RESPAWNPOINT_DM
) +
4687 g_Map_GetPointCount(RESPAWNPOINT_RED
)+
4688 g_Map_GetPointCount(RESPAWNPOINT_BLUE
)) < 1 then
4690 g_Net_Slist_ServerClosed();
4691 g_FatalError(_lc
[I_GAME_ERROR_GET_SPAWN
]);
4695 // Íàñòðîéêè èãðîêîâ è áîòîâ:
4698 g_Net_Slist_ServerMapStarted();
4699 NetState
:= NET_STATE_GAME
;
4702 procedure g_Game_StartClient(Addr
: String; Port
: Word; PW
: String);
4717 e_WriteLog('Starting net game (client)...', TMsgType
.Notify
);
4718 e_WriteLog('NET: Trying to connect to ' + Addr
+ ':' + IntToStr(Port
) + '...', TMsgType
.Notify
);
4720 g_Game_ClearLoading();
4723 gGameSettings
.GameType
:= GT_CLIENT
;
4725 gCoopTotalMonstersKilled
:= 0;
4726 gCoopTotalSecretsFound
:= 0;
4727 gCoopTotalMonsters
:= 0;
4728 gCoopTotalSecrets
:= 0;
4732 g_Game_ExecuteEvent('ongamestart');
4734 // Óñòàíîâêà ðàçìåðîâ îêîí èãðîêîâ:
4735 g_Game_SetupScreenSize();
4737 NetState
:= NET_STATE_AUTH
;
4739 g_Game_SetLoadingText(_lc
[I_LOAD_CONNECT
], 0, False);
4741 // create (or update) map/resource databases
4742 g_Res_CreateDatabases(true);
4744 gLMSRespawn
:= LMS_RESPAWN_NONE
;
4745 gLMSRespawnTime
:= 0;
4746 gSpectLatchPID1
:= 0;
4747 gSpectLatchPID2
:= 0;
4750 if not g_Net_Connect(Addr
, Port
) then
4752 g_FatalError(_lc
[I_NET_MSG
] + _lc
[I_NET_ERR_CONN
]);
4753 NetState
:= NET_STATE_NONE
;
4757 g_Game_SetLoadingText(_lc
[I_LOAD_SEND_INFO
], 0, False);
4759 g_Game_SetLoadingText(_lc
[I_LOAD_WAIT_INFO
], 0, False);
4764 // fuck! https://www.mail-archive.com/enet-discuss@cubik.org/msg00852.html
4765 // tl;dr: on shitdows, we can get -1 sometimes, and it is *NOT* a failure.
4766 // thank you, enet. let's ignore failures altogether then.
4767 while (enet_host_service(NetHost
, @NetEvent
, 50) > 0) do
4769 if (NetEvent
.kind
= ENET_EVENT_TYPE_RECEIVE
) then
4771 if (NetEvent
.channelID
= NET_CHAN_DOWNLOAD_EX
) then
4773 // ignore all download packets, they're processed by separate code
4774 enet_packet_destroy(NetEvent
.packet
);
4777 Ptr
:= NetEvent
.packet
^.data
;
4778 if not InMsg
.Init(Ptr
, NetEvent
.packet
^.dataLength
, True) then
4780 enet_packet_destroy(NetEvent
.packet
);
4784 InMsg
.ReadLongWord(); // skip size
4785 MID
:= InMsg
.ReadByte();
4787 if (MID
= NET_MSG_INFO
) and (State
= 0) then
4789 NetMyID
:= InMsg
.ReadByte();
4790 NetPlrUID1
:= InMsg
.ReadWord();
4792 WadName
:= InMsg
.ReadString();
4793 Map
:= InMsg
.ReadString();
4795 gWADHash
:= InMsg
.ReadMD5();
4797 gGameSettings
.GameMode
:= InMsg
.ReadByte();
4798 gSwitchGameMode
:= gGameSettings
.GameMode
;
4799 gGameSettings
.GoalLimit
:= InMsg
.ReadWord();
4800 gGameSettings
.TimeLimit
:= InMsg
.ReadWord();
4801 gGameSettings
.MaxLives
:= InMsg
.ReadByte();
4802 gGameSettings
.Options
:= InMsg
.ReadLongWord();
4803 T
:= InMsg
.ReadLongWord();
4805 //newResPath := g_Res_SearchSameWAD(MapsDir, WadName, gWADHash);
4806 //if newResPath = '' then
4808 //g_Game_SetLoadingText(_lc[I_LOAD_DL_RES], 0, False);
4809 newResPath
:= g_Res_DownloadMapWAD(ExtractFileName(WadName
), gWADHash
);
4810 if newResPath
= '' then
4812 g_FatalError(_lc
[I_NET_ERR_HASH
]);
4813 enet_packet_destroy(NetEvent
.packet
);
4814 NetState
:= NET_STATE_NONE
;
4817 e_LogWritefln('using downloaded map wad [%s] for [%s]`', [newResPath
, WadName
], TMsgType
.Notify
);
4819 //newResPath := ExtractRelativePath(MapsDir, newResPath);
4822 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4823 gPlayer1Settings
.Color
,
4824 gPlayer1Settings
.Team
, False));
4826 if gPlayer1
= nil then
4828 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
4830 enet_packet_destroy(NetEvent
.packet
);
4831 NetState
:= NET_STATE_NONE
;
4835 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4836 gPlayer1
.UID
:= NetPlrUID1
;
4837 gPlayer1
.Reset(True);
4839 if not g_Game_StartMap(false{asMegawad}, newResPath
+ ':\' + Map
, True) then
4841 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [WadName
+ ':\' + Map
]));
4843 enet_packet_destroy(NetEvent
.packet
);
4844 NetState
:= NET_STATE_NONE
;
4852 enet_packet_destroy(NetEvent
.packet
);
4856 enet_packet_destroy(NetEvent
.packet
);
4860 if (NetEvent
.kind
= ENET_EVENT_TYPE_DISCONNECT
) then
4863 if (NetEvent
.data
<= NET_DISC_MAX
) then
4864 g_Console_Add(_lc
[I_NET_MSG_ERROR
] + _lc
[I_NET_ERR_CONN
] + ' ' +
4865 _lc
[TStrings_Locale(Cardinal(I_NET_DISC_NONE
) + NetEvent
.data
)], True);
4872 ProcessLoading(true);
4874 if g_Net_UserRequestExit() then
4883 g_FatalError(_lc
[I_NET_MSG
] + _lc
[I_NET_ERR_CONN
]);
4884 NetState
:= NET_STATE_NONE
;
4889 NetState
:= NET_STATE_GAME
;
4890 MC_SEND_FullStateRequest
;
4891 e_WriteLog('NET: Connection successful.', TMsgType
.Notify
);
4895 lastAsMegaWad
: Boolean = false;
4897 procedure g_Game_ChangeMap(const MapPath
: String);
4901 g_Game_ClearLoading();
4903 Force
:= gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
];
4904 // Åñëè óðîâåíü çàâåðøèëñÿ ïî òðèããåðó Âûõîä, íå î÷èùàòü èíâåíòàðü
4905 if gExitByTrigger
then
4908 gExitByTrigger
:= False;
4910 if not g_Game_StartMap(lastAsMegaWad
, MapPath
, Force
) then
4911 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [MapPath
]));
4914 procedure g_Game_Restart();
4918 if g_Game_IsClient
then
4920 map
:= g_ExtractFileName(gMapInfo
.Map
);
4921 e_LogWritefln('g_Game_Restart: map = "%s" gCurrentMapFileName = "%s"', [map
, gCurrentMapFileName
]);
4925 g_Game_ClearLoading();
4926 g_Game_StartMap(lastAsMegaWad
, Map
, True, gCurrentMapFileName
);
4929 function g_Game_StartMap (asMegawad
: Boolean; Map
: String; Force
: Boolean = False; const oldMapPath
: AnsiString=''): Boolean;
4931 NewWAD
, ResName
: String;
4935 g_Map_Free((Map
<> gCurrentMapFileName
) and (oldMapPath
<> gCurrentMapFileName
));
4936 g_Player_RemoveAllCorpses();
4938 if (not g_Game_IsClient
) and
4939 (gSwitchGameMode
<> gGameSettings
.GameMode
) and
4940 (gGameSettings
.GameMode
<> GM_SINGLE
) then
4942 if gSwitchGameMode
= GM_CTF
then
4943 gGameSettings
.MaxLives
:= 0;
4944 gGameSettings
.GameMode
:= gSwitchGameMode
;
4947 gSwitchGameMode
:= gGameSettings
.GameMode
;
4949 g_Player_ResetTeams();
4951 lastAsMegaWad
:= asMegawad
;
4952 if isWadPath(Map
) then
4954 NewWAD
:= g_ExtractWadName(Map
);
4955 ResName
:= g_ExtractFileName(Map
);
4956 if g_Game_IsServer
then
4958 nws
:= findDiskWad(NewWAD
);
4959 //writeln('000: Map=[', Map, ']; nws=[', nws, ']; NewWAD=[', NewWAD, ']');
4962 if (length(nws
) = 0) then nws
:= e_FindWad(MegawadDirs
, NewWAD
);
4963 if (length(nws
) = 0) then nws
:= e_FindWad(MapDirs
, NewWAD
);
4967 if (length(nws
) = 0) then nws
:= e_FindWad(MapDirs
, NewWAD
);
4968 if (length(nws
) = 0) then nws
:= e_FindWad(MegawadDirs
, NewWAD
);
4970 //if (length(nws) = 0) then nws := e_FindWad(MapDownloadDirs, NewWAD);
4971 //writeln('001: Map=[', Map, ']; nws=[', nws, ']; NewWAD=[', NewWAD, ']');
4973 if (length(nws
) = 0) then
4975 ResName
:= ''; // failed
4980 if (g_Game_IsNet
) then gWADHash
:= MD5File(nws
);
4981 //writeln('********: nws=', nws, ' : Map=', Map, ' : nw=', NewWAD, ' : resname=', ResName);
4982 g_Game_LoadWAD(NewWAD
);
4987 // hash received in MC_RECV_GameEvent -> NET_EV_MAPSTART
4988 NewWAD
:= g_Game_ClientWAD(NewWAD
, gWADHash
);
4993 NewWAD
:= gGameSettings
.WAD
;
4999 //writeln('********: gsw=', gGameSettings.WAD, '; rn=', ResName);
5001 if (ResName
<> '') and (NewWAD
<> '') then
5003 //result := g_Map_Load(gGameSettings.WAD + ':\' + ResName);
5004 result
:= g_Map_Load(NewWAD
+':\'+ResName
);
5008 g_Player_ResetAll(Force
or gLastMap
, gGameSettings
.GameType
= GT_SINGLE
);
5010 gState
:= STATE_NONE
;
5011 g_ActiveWindow
:= nil;
5017 if gGameSettings
.GameMode
= GM_CTF
then
5019 g_Map_ResetFlag(FLAG_RED
);
5020 g_Map_ResetFlag(FLAG_BLUE
);
5021 // CTF, à ôëàãîâ íåò:
5022 if not g_Map_HaveFlagPoints() then
5023 g_SimpleError(_lc
[I_GAME_ERROR_CTF
]);
5028 gState
:= STATE_MENU
;
5033 gPauseMain
:= false;
5034 gPauseHolmes
:= false;
5035 NetTimeToUpdate
:= 1;
5036 NetTimeToReliable
:= 0;
5037 NetTimeToMaster
:= NetMasterRate
;
5038 gSpectLatchPID1
:= 0;
5039 gSpectLatchPID2
:= 0;
5040 gMissionFailed
:= False;
5043 gCoopMonstersKilled
:= 0;
5044 gCoopSecretsFound
:= 0;
5046 gVoteInProgress
:= False;
5047 gVotePassed
:= False;
5053 if not gGameOn
then Exit
;
5055 g_Game_SpectateCenterView();
5057 if g_Game_IsServer
then
5059 if (gGameSettings
.MaxLives
> 0) and (gGameSettings
.WarmupTime
> 0) then
5061 gLMSRespawn
:= LMS_RESPAWN_WARMUP
;
5062 gLMSRespawnTime
:= gTime
+ gGameSettings
.WarmupTime
*1000;
5063 gLMSSoftSpawn
:= True;
5064 if g_Game_IsNet
then
5065 MH_SEND_GameEvent(NET_EV_LMS_WARMUP
, gLMSRespawnTime
- gTime
);
5069 gLMSRespawn
:= LMS_RESPAWN_NONE
;
5070 gLMSRespawnTime
:= 0;
5074 if NetMode
= NET_SERVER
then
5076 MH_SEND_GameEvent(NET_EV_MAPSTART
, gGameSettings
.GameMode
, Map
);
5079 g_Net_Slist_ServerMapStarted();
5081 if NetClients
<> nil then
5082 for I
:= 0 to High(NetClients
) do
5083 if NetClients
[I
].Used
then
5085 NetClients
[I
].Voted
:= False;
5086 if NetClients
[I
].RequestedFullUpdate
then
5088 MH_SEND_Everything((NetClients
[I
].State
= NET_STATE_AUTH
), I
);
5089 NetClients
[I
].RequestedFullUpdate
:= False;
5093 g_Net_UnbanNonPermHosts();
5098 gCoopTotalMonstersKilled
:= 0;
5099 gCoopTotalSecretsFound
:= 0;
5100 gCoopTotalMonsters
:= 0;
5101 gCoopTotalSecrets
:= 0;
5105 g_Game_ExecuteEvent('onmapstart');
5108 procedure SetFirstLevel
;
5112 MapList
:= g_Map_GetMapsList(gGameSettings
.WAD
);
5113 if MapList
= nil then
5116 SortSArray(MapList
);
5117 gNextMap
:= MapList
[Low(MapList
)];
5122 procedure g_Game_ExitLevel(const Map
: AnsiString);
5126 gCoopTotalMonstersKilled
:= gCoopTotalMonstersKilled
+ gCoopMonstersKilled
;
5127 gCoopTotalSecretsFound
:= gCoopTotalSecretsFound
+ gCoopSecretsFound
;
5128 gCoopTotalMonsters
:= gCoopTotalMonsters
+ gTotalMonsters
;
5129 gCoopTotalSecrets
:= gCoopTotalSecrets
+ gSecretsCount
;
5131 // Âûøëè â âûõîä â Îäèíî÷íîé èãðå:
5132 if gGameSettings
.GameType
= GT_SINGLE
then
5133 gExit
:= EXIT_ENDLEVELSINGLE
5134 else // Âûøëè â âûõîä â Ñâîåé èãðå
5136 gExit
:= EXIT_ENDLEVELCUSTOM
;
5137 if gGameSettings
.GameMode
= GM_COOP
then
5138 g_Player_RememberAll
;
5140 if not g_Map_Exist(gGameSettings
.WAD
+ ':\' + gNextMap
) then
5143 if gGameSettings
.GameMode
= GM_COOP
then
5146 gStatsPressed
:= True;
5147 gNextMap
:= 'MAP01';
5149 if not g_Map_Exist(gGameSettings
.WAD
+ ':\' + gNextMap
) then
5152 if g_Game_IsNet
then
5154 MH_SEND_GameStats();
5155 MH_SEND_CoopStats();
5161 procedure g_Game_RestartLevel();
5165 if gGameSettings
.GameMode
= GM_SINGLE
then
5170 gExit
:= EXIT_ENDLEVELCUSTOM
;
5171 Map
:= g_ExtractFileName(gMapInfo
.Map
);
5175 function g_Game_ClientWAD (NewWAD
: String; const WHash
: TMD5Digest
): AnsiString;
5177 gWAD
{, xwad}: String;
5180 if not g_Game_IsClient
then Exit
;
5181 //e_LogWritefln('*** g_Game_ClientWAD: `%s`', [NewWAD]);
5183 gWAD
:= g_Res_DownloadMapWAD(ExtractFileName(NewWAD
), WHash
);
5188 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_WAD
], [ExtractFileName(NewWAD
)]));
5192 e_LogWritefln('using downloaded client map wad [%s] for [%s]', [gWAD
, NewWAD
], TMsgType
.Notify
);
5195 g_Game_LoadWAD(NewWAD
);
5199 if LowerCase(NewWAD) = LowerCase(gGameSettings.WAD) then Exit;
5200 gWAD := g_Res_SearchSameWAD(MapsDir, ExtractFileName(NewWAD), WHash);
5203 g_Game_SetLoadingText(_lc[I_LOAD_DL_RES], 0, False);
5204 gWAD := g_Res_DownloadMapWAD(ExtractFileName(NewWAD), WHash);
5208 g_FatalError(Format(_lc[I_GAME_ERROR_MAP_WAD], [ExtractFileName(NewWAD)]));
5212 NewWAD := ExtractRelativePath(MapsDir, gWAD);
5213 g_Game_LoadWAD(NewWAD);
5217 procedure g_Game_RestartRound(NoMapRestart
: Boolean = False);
5219 i
, n
, nb
, nr
: Integer;
5221 if not g_Game_IsServer
then Exit
;
5222 if gLMSRespawn
= LMS_RESPAWN_NONE
then Exit
;
5223 gLMSRespawn
:= LMS_RESPAWN_NONE
;
5224 gLMSRespawnTime
:= 0;
5227 if (gGameSettings
.GameMode
= GM_COOP
) and not NoMapRestart
then
5229 gMissionFailed
:= True;
5230 g_Game_RestartLevel
;
5234 n
:= 0; nb
:= 0; nr
:= 0;
5235 for i
:= Low(gPlayers
) to High(gPlayers
) do
5236 if (gPlayers
[i
] <> nil) and
5237 ((not gPlayers
[i
].FSpectator
) or gPlayers
[i
].FWantsInGame
or
5238 (gPlayers
[i
] is TBot
)) then
5241 if gPlayers
[i
].Team
= TEAM_RED
then Inc(nr
)
5242 else if gPlayers
[i
].Team
= TEAM_BLUE
then Inc(nb
)
5245 if (n
< 1) or ((gGameSettings
.GameMode
= GM_TDM
) and ((nr
= 0) or (nb
= 0))) then
5247 // wait a second until the fuckers finally decide to join
5248 gLMSRespawn
:= LMS_RESPAWN_WARMUP
;
5249 gLMSRespawnTime
:= gTime
+ gGameSettings
.WarmupTime
*1000;
5250 gLMSSoftSpawn
:= NoMapRestart
;
5251 if g_Game_IsNet
then
5252 MH_SEND_GameEvent(NET_EV_LMS_WARMUP
, gLMSRespawnTime
- gTime
);
5256 g_Player_RemoveAllCorpses
;
5257 g_Game_Message(_lc
[I_MESSAGE_LMS_START
], 144);
5258 if g_Game_IsNet
then
5259 MH_SEND_GameEvent(NET_EV_LMS_START
);
5261 for i
:= Low(gPlayers
) to High(gPlayers
) do
5263 if gPlayers
[i
] = nil then continue
;
5264 if gPlayers
[i
] is TBot
then gPlayers
[i
].FWantsInGame
:= True;
5265 // don't touch normal spectators
5266 if gPlayers
[i
].FSpectator
and not gPlayers
[i
].FWantsInGame
then
5268 gPlayers
[i
].FNoRespawn
:= True;
5269 gPlayers
[i
].Lives
:= 0;
5270 if g_Game_IsNet
then
5271 MH_SEND_PlayerStats(gPlayers
[I
].UID
);
5274 gPlayers
[i
].FNoRespawn
:= False;
5275 gPlayers
[i
].Lives
:= gGameSettings
.MaxLives
;
5276 gPlayers
[i
].Respawn(False, True);
5277 if gGameSettings
.GameMode
= GM_COOP
then
5279 gPlayers
[i
].Frags
:= 0;
5280 gPlayers
[i
].RecallState
;
5282 if (gPlayer1
= nil) and (gSpectLatchPID1
> 0) then
5283 gPlayer1
:= g_Player_Get(gSpectLatchPID1
);
5284 if (gPlayer2
= nil) and (gSpectLatchPID2
> 0) then
5285 gPlayer2
:= g_Player_Get(gSpectLatchPID2
);
5288 g_Items_RestartRound();
5290 gLMSSoftSpawn
:= False;
5293 function g_Game_GetFirstMap(WAD
: String): String;
5297 MapList
:= g_Map_GetMapsList(WAD
);
5298 if MapList
= nil then
5301 SortSArray(MapList
);
5302 Result
:= MapList
[Low(MapList
)];
5304 if not g_Map_Exist(WAD
+ ':\' + Result
) then
5310 function g_Game_GetNextMap(): String;
5317 MapList
:= g_Map_GetMapsList(gGameSettings
.WAD
);
5318 if MapList
= nil then
5321 Map
:= g_ExtractFileName(gMapInfo
.Map
);
5323 SortSArray(MapList
);
5325 for I
:= Low(MapList
) to High(MapList
) do
5326 if Map
= MapList
[I
] then
5332 if MapIndex
<> -255 then
5334 if MapIndex
= High(MapList
) then
5335 Result
:= MapList
[Low(MapList
)]
5337 Result
:= MapList
[MapIndex
+ 1];
5339 if not g_Map_Exist(gGameSettings
.WAD
+ ':\' + Result
) then Result
:= Map
;
5345 procedure g_Game_NextLevel();
5347 if gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
, GM_COOP
] then
5348 gExit
:= EXIT_ENDLEVELCUSTOM
5351 gExit
:= EXIT_ENDLEVELSINGLE
;
5355 if gNextMap
<> '' then Exit
;
5356 gNextMap
:= g_Game_GetNextMap();
5359 function g_Game_IsTestMap(): Boolean;
5361 result
:= StrEquCI1251(TEST_MAP_NAME
, g_ExtractFileName(gMapInfo
.Map
));
5364 procedure g_Game_DeleteTestMap();
5367 //MapName: AnsiString;
5375 a
:= Pos('.wad:\', toLowerCase1251(gMapToDelete
));
5376 if (a
= 0) then a
:= Pos('.wad:/', toLowerCase1251(gMapToDelete
));
5377 if (a
= 0) then exit
;
5379 // Âûäåëÿåì èìÿ wad-ôàéëà è èìÿ êàðòû
5380 WadName
:= Copy(gMapToDelete
, 1, a
+3);
5381 Delete(gMapToDelete
, 1, a
+5);
5382 gMapToDelete
:= UpperCase(gMapToDelete
);
5384 //CopyMemory(@MapName[0], @gMapToDelete[1], Min(16, Length(gMapToDelete)));
5387 // Èìÿ êàðòû íå ñòàíäàðòíîå òåñòîâîå:
5388 if MapName <> TEST_MAP_NAME then
5391 if not gTempDelete then
5393 time := g_GetFileTime(WadName);
5394 WAD := TWADFile.Create();
5397 if not WAD.ReadFile(WadName) then
5398 begin // Íåò òàêîãî WAD-ôàéëà
5403 // Ñîñòàâëÿåì ñïèñîê êàðò è èùåì íóæíóþ:
5405 MapList := WAD.GetResourcesList('');
5407 if MapList <> nil then
5408 for a := 0 to High(MapList) do
5409 if MapList[a] = MapName then
5411 // Óäàëÿåì è ñîõðàíÿåì:
5412 WAD.RemoveResource('', MapName);
5413 WAD.SaveTo(WadName);
5418 g_SetFileTime(WadName, time);
5421 if gTempDelete
then DeleteFile(WadName
);
5424 procedure GameCVars(P
: SSArray
);
5427 stat
: TPlayerStatArray
;
5430 procedure ParseGameFlag(Flag
: LongWord; OffMsg
, OnMsg
: TStrings_Locale
; OnMapChange
: Boolean = False);
5434 if Length(P
) > 1 then
5439 gsGameFlags
:= gsGameFlags
or Flag
5441 gsGameFlags
:= gsGameFlags
and (not Flag
);
5443 if g_Game_IsServer
then
5446 gGameSettings
.Options
:= gGameSettings
.Options
or Flag
5448 gGameSettings
.Options
:= gGameSettings
.Options
and (not Flag
);
5449 if g_Game_IsNet
then MH_SEND_GameSettings
;
5453 if LongBool(gsGameFlags
and Flag
) then
5454 g_Console_Add(_lc
[OnMsg
])
5456 g_Console_Add(_lc
[OffMsg
]);
5458 if OnMapChange
and g_Game_IsServer
then
5459 g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
5464 cmd
:= LowerCase(P
[0]);
5466 if cmd
= 'g_gamemode' then
5468 if (Length(P
) > 1) then
5470 a
:= g_Game_TextToMode(P
[1]);
5471 if a
= GM_SINGLE
then a
:= GM_COOP
;
5472 gsGameMode
:= g_Game_ModeToText(a
);
5473 if g_Game_IsServer
then
5475 gSwitchGameMode
:= a
;
5476 if (gGameOn
and (gGameSettings
.GameMode
= GM_SINGLE
)) or
5477 (gState
= STATE_INTERSINGLE
) then
5478 gSwitchGameMode
:= GM_SINGLE
;
5480 gGameSettings
.GameMode
:= gSwitchGameMode
;
5484 if gSwitchGameMode
= gGameSettings
.GameMode
then
5485 g_Console_Add(Format(_lc
[I_MSG_GAMEMODE_CURRENT
],
5486 [g_Game_ModeToText(gGameSettings
.GameMode
)]))
5488 g_Console_Add(Format(_lc
[I_MSG_GAMEMODE_CHANGE
],
5489 [g_Game_ModeToText(gGameSettings
.GameMode
),
5490 g_Game_ModeToText(gSwitchGameMode
)]));
5492 else if cmd
= 'g_friendlyfire' then
5494 ParseGameFlag(GAME_OPTION_TEAMDAMAGE
, I_MSG_FRIENDLY_FIRE_OFF
, I_MSG_FRIENDLY_FIRE_ON
);
5496 else if cmd
= 'g_weaponstay' then
5498 ParseGameFlag(GAME_OPTION_WEAPONSTAY
, I_MSG_WEAPONSTAY_OFF
, I_MSG_WEAPONSTAY_ON
);
5500 else if cmd
= 'g_allow_exit' then
5502 ParseGameFlag(GAME_OPTION_ALLOWEXIT
, I_MSG_ALLOWEXIT_OFF
, I_MSG_ALLOWEXIT_ON
, True);
5504 else if cmd
= 'g_allow_monsters' then
5506 ParseGameFlag(GAME_OPTION_MONSTERS
, I_MSG_ALLOWMON_OFF
, I_MSG_ALLOWMON_ON
, True);
5508 else if cmd
= 'g_bot_vsplayers' then
5510 ParseGameFlag(GAME_OPTION_BOTVSPLAYER
, I_MSG_BOTSVSPLAYERS_OFF
, I_MSG_BOTSVSPLAYERS_ON
);
5512 else if cmd
= 'g_bot_vsmonsters' then
5514 ParseGameFlag(GAME_OPTION_BOTVSMONSTER
, I_MSG_BOTSVSMONSTERS_OFF
, I_MSG_BOTSVSMONSTERS_ON
);
5516 else if cmd
= 'g_dm_keys' then
5518 ParseGameFlag(GAME_OPTION_DMKEYS
, I_MSG_DMKEYS_OFF
, I_MSG_DMKEYS_ON
, True);
5520 else if cmd
= 'g_gameflags' then
5522 if Length(P
) > 1 then
5524 gsGameFlags
:= StrToDWordDef(P
[1], gsGameFlags
);
5525 if g_Game_IsServer
then
5527 gGameSettings
.Options
:= gsGameFlags
;
5528 if g_Game_IsNet
then MH_SEND_GameSettings
;
5532 g_Console_Add(Format('%s %u', [cmd
, gsGameFlags
]));
5534 else if cmd
= 'g_warmup_time' then
5536 if Length(P
) > 1 then
5538 gsWarmupTime
:= nclamp(StrToIntDef(P
[1], gsWarmupTime
), 0, $FFFF);
5539 if g_Game_IsServer
then
5541 gGameSettings
.WarmupTime
:= gsWarmupTime
;
5542 // extend warmup if it's already going
5543 if gLMSRespawn
= LMS_RESPAWN_WARMUP
then
5545 gLMSRespawnTime
:= gTime
+ gsWarmupTime
* 1000;
5546 if g_Game_IsNet
then MH_SEND_GameEvent(NET_EV_LMS_WARMUP
, gLMSRespawnTime
- gTime
);
5548 if g_Game_IsNet
then MH_SEND_GameSettings
;
5552 g_Console_Add(Format(_lc
[I_MSG_WARMUP
], [Integer(gsWarmupTime
)]));
5553 if g_Game_IsServer
then g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
5555 else if cmd
= 'g_spawn_invul' then
5557 if Length(P
) > 1 then
5559 gsSpawnInvul
:= nclamp(StrToIntDef(P
[1], gsSpawnInvul
), 0, $FFFF);
5560 if g_Game_IsServer
then
5562 gGameSettings
.SpawnInvul
:= gsSpawnInvul
;
5563 if g_Game_IsNet
then MH_SEND_GameSettings
;
5567 g_Console_Add(Format('%s %d', [cmd
, Integer(gsSpawnInvul
)]));
5569 else if cmd
= 'g_item_respawn_time' then
5571 if Length(P
) > 1 then
5573 gsItemRespawnTime
:= nclamp(StrToIntDef(P
[1], gsItemRespawnTime
), 0, $FFFF);
5574 if g_Game_IsServer
then
5576 gGameSettings
.ItemRespawnTime
:= gsItemRespawnTime
;
5577 if g_Game_IsNet
then MH_SEND_GameSettings
;
5581 g_Console_Add(Format('%s %d', [cmd
, Integer(gsItemRespawnTime
)]));
5582 if g_Game_IsServer
then g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
5584 else if cmd
= 'sv_intertime' then
5586 if (Length(P
) > 1) then
5587 gDefInterTime
:= Min(Max(StrToIntDef(P
[1], gDefInterTime
), -1), 120);
5589 g_Console_Add(cmd
+ ' = ' + IntToStr(gDefInterTime
));
5591 else if cmd
= 'g_max_particles' then
5593 if Length(p
) = 2 then
5595 a
:= Max(0, StrToInt(p
[1]));
5598 else if Length(p
) = 1 then
5600 e_LogWritefln('%s', [g_GFX_GetMax()])
5604 e_LogWritefln('usage: %s <n>', [cmd
])
5607 else if cmd
= 'g_max_shells' then
5609 if Length(p
) = 2 then
5611 a
:= Max(0, StrToInt(p
[1]));
5614 else if Length(p
) = 1 then
5616 e_LogWritefln('%s', [g_Shells_GetMax()])
5620 e_LogWritefln('usage: %s <n>', [cmd
])
5623 else if cmd
= 'g_max_gibs' then
5625 if Length(p
) = 2 then
5627 a
:= Max(0, StrToInt(p
[1]));
5630 else if Length(p
) = 1 then
5632 e_LogWritefln('%s', [g_Gibs_GetMax()])
5636 e_LogWritefln('usage: %s <n>', [cmd
])
5639 else if cmd
= 'g_max_corpses' then
5641 if Length(p
) = 2 then
5643 a
:= Max(0, StrToInt(p
[1]));
5646 else if Length(p
) = 1 then
5648 e_LogWritefln('%s', [g_Corpses_GetMax()])
5652 e_LogWritefln('usage: %s <n>', [cmd
])
5655 else if cmd
= 'g_scorelimit' then
5657 if Length(P
) > 1 then
5659 gsGoalLimit
:= nclamp(StrToIntDef(P
[1], gsGoalLimit
), 0, $FFFF);
5661 if g_Game_IsServer
then
5664 if gGameSettings
.GameMode
= GM_DM
then
5666 stat
:= g_Player_GetStats();
5668 for a
:= 0 to High(stat
) do
5669 if stat
[a
].Frags
> b
then
5673 b
:= Max(gTeamStat
[TEAM_RED
].Goals
, gTeamStat
[TEAM_BLUE
].Goals
);
5675 // if someone has a higher score, set it to that instead
5676 gsGoalLimit
:= max(gsGoalLimit
, b
);
5677 gGameSettings
.GoalLimit
:= gsGoalLimit
;
5679 if g_Game_IsNet
then MH_SEND_GameSettings
;
5683 g_Console_Add(Format(_lc
[I_MSG_SCORE_LIMIT
], [Integer(gsGoalLimit
)]));
5685 else if cmd
= 'g_timelimit' then
5687 if Length(P
) > 1 then
5689 gsTimeLimit
:= nclamp(StrToIntDef(P
[1], gsTimeLimit
), 0, $FFFF);
5690 if g_Game_IsServer
then
5692 gGameSettings
.TimeLimit
:= gsTimeLimit
;
5693 if g_Game_IsNet
then MH_SEND_GameSettings
;
5696 g_Console_Add(Format(_lc
[I_MSG_TIME_LIMIT
],
5697 [gsTimeLimit
div 3600,
5698 (gsTimeLimit
div 60) mod 60,
5699 gsTimeLimit
mod 60]));
5701 else if cmd
= 'g_maxlives' then
5703 if Length(P
) > 1 then
5705 gsMaxLives
:= nclamp(StrToIntDef(P
[1], gsMaxLives
), 0, $FFFF);
5706 if g_Game_IsServer
then
5708 gGameSettings
.MaxLives
:= gsMaxLives
;
5709 if g_Game_IsNet
then MH_SEND_GameSettings
;
5713 g_Console_Add(Format(_lc
[I_MSG_LIVES
], [Integer(gsMaxLives
)]));
5717 procedure PlayerSettingsCVars(P
: SSArray
);
5721 cmd
:= LowerCase(P
[0]);
5725 if (Length(P
) > 1) then
5727 gPlayer1Settings
.Name
:= b_Text_Unformat(P
[1]);
5728 if g_Game_IsClient
then
5729 MC_SEND_PlayerSettings
5730 else if gGameOn
and (gPlayer1
<> nil) then
5732 gPlayer1
.Name
:= b_Text_Unformat(P
[1]);
5733 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer1
.UID
);
5739 if (Length(P
) > 1) then
5741 gPlayer2Settings
.Name
:= b_Text_Unformat(P
[1]);
5742 if g_Game_IsClient
then
5743 MC_SEND_PlayerSettings
5744 else if gGameOn
and (gPlayer2
<> nil) then
5746 gPlayer2
.Name
:= b_Text_Unformat(P
[1]);
5747 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer2
.UID
);
5753 if Length(P
) > 3 then
5755 gPlayer1Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
5756 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
5757 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
5758 if g_Game_IsClient
then
5759 MC_SEND_PlayerSettings
5760 else if gGameOn
and (gPlayer1
<> nil) then
5762 gPlayer1
.SetColor(gPlayer1Settings
.Color
);
5763 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer1
.UID
);
5769 if Length(P
) > 3 then
5771 gPlayer2Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
5772 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
5773 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
5774 if g_Game_IsClient
then
5775 MC_SEND_PlayerSettings
5776 else if gGameOn
and (gPlayer2
<> nil) then
5778 gPlayer2
.SetColor(gPlayer2Settings
.Color
);
5779 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer2
.UID
);
5785 if (Length(P
) > 1) then
5787 gPlayer1Settings
.Model
:= P
[1];
5788 if g_Game_IsClient
then
5789 MC_SEND_PlayerSettings
5790 else if gGameOn
and (gPlayer1
<> nil) then
5792 gPlayer1
.FActualModelName
:= gPlayer1Settings
.Model
;
5793 gPlayer1
.SetModel(gPlayer1Settings
.Model
);
5794 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer1
.UID
);
5800 if (Length(P
) > 1) then
5802 gPlayer2Settings
.Model
:= P
[1];
5803 if g_Game_IsClient
then
5804 MC_SEND_PlayerSettings
5805 else if gGameOn
and (gPlayer2
<> nil) then
5807 gPlayer2
.FActualModelName
:= gPlayer2Settings
.Model
;
5808 gPlayer2
.SetModel(gPlayer2Settings
.Model
);
5809 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer2
.UID
);
5816 procedure PrintHeapStats();
5820 hs
:= GetFPCHeapStatus();
5821 e_LogWriteLn ('v===== heap status =====v');
5822 e_LogWriteFln('max heap size = %d k', [hs
.MaxHeapSize
div 1024]);
5823 e_LogWriteFln('max heap used = %d k', [hs
.MaxHeapUsed
div 1024]);
5824 e_LogWriteFln('cur heap size = %d k', [hs
.CurrHeapSize
div 1024]);
5825 e_LogWriteFln('cur heap used = %d k', [hs
.CurrHeapUsed
div 1024]);
5826 e_LogWriteFln('cur heap free = %d k', [hs
.CurrHeapFree
div 1024]);
5827 e_LogWriteLn ('^=======================^');
5830 procedure DebugCommands(P
: SSArray
);
5837 // Êîìàíäû îòëàäî÷íîãî ðåæèìà:
5838 if {gDebugMode}conIsCheatsEnabled
then
5840 cmd
:= LowerCase(P
[0]);
5841 if cmd
= 'd_window' then
5843 g_Console_Add(Format('gScreenWidth = %d, gScreenHeight = %d', [gScreenWidth
, gScreenHeight
]));
5844 g_Console_Add(Format('gScreenWidth = %d, gScreenHeight = %d', [gScreenWidth
, gScreenHeight
]));
5846 else if cmd
= 'd_sounds' then
5848 if (Length(P
) > 1) and
5849 ((P
[1] = '1') or (P
[1] = '0')) then
5850 g_Debug_Sounds
:= (P
[1][1] = '1');
5852 g_Console_Add(Format('d_sounds is %d', [Byte(g_Debug_Sounds
)]));
5854 else if cmd
= 'd_frames' then
5856 if (Length(P
) > 1) and
5857 ((P
[1] = '1') or (P
[1] = '0')) then
5858 g_Debug_Frames
:= (P
[1][1] = '1');
5860 g_Console_Add(Format('d_frames is %d', [Byte(g_Debug_Frames
)]));
5862 else if cmd
= 'd_winmsg' then
5864 if (Length(P
) > 1) and
5865 ((P
[1] = '1') or (P
[1] = '0')) then
5866 g_Debug_WinMsgs
:= (P
[1][1] = '1');
5868 g_Console_Add(Format('d_winmsg is %d', [Byte(g_Debug_WinMsgs
)]));
5870 else if (cmd
= 'd_monoff') and not g_Game_IsNet
then
5872 if (Length(P
) > 1) and
5873 ((P
[1] = '1') or (P
[1] = '0')) then
5874 g_Debug_MonsterOff
:= (P
[1][1] = '1');
5876 g_Console_Add(Format('d_monoff is %d', [Byte(g_debug_MonsterOff
)]));
5878 else if (cmd
= 'd_botoff') and not g_Game_IsNet
then
5880 if Length(P
) > 1 then
5882 '0': g_debug_BotAIOff
:= 0;
5883 '1': g_debug_BotAIOff
:= 1;
5884 '2': g_debug_BotAIOff
:= 2;
5885 '3': g_debug_BotAIOff
:= 3;
5888 g_Console_Add(Format('d_botoff is %d', [g_debug_BotAIOff
]));
5890 else if cmd
= 'd_monster' then
5892 if gGameOn
and (gPlayer1
<> nil) and (gPlayer1
.alive
) and (not g_Game_IsNet
) then
5893 if Length(P
) < 2 then
5895 g_Console_Add(cmd
+ ' [ID | Name] [behaviour]');
5896 g_Console_Add('ID | Name');
5897 for b
:= MONSTER_DEMON
to MONSTER_MAN
do
5898 g_Console_Add(Format('%2d | %s', [b
, g_Mons_NameByTypeId(b
)]));
5899 conwriteln('behav. num'#10'normal 0'#10'killer 1'#10'maniac 2'#10'insane 3'#10'cannibal 4'#10'good 5');
5902 a
:= StrToIntDef(P
[1], 0);
5903 if (a
< MONSTER_DEMON
) or (a
> MONSTER_MAN
) then
5904 a
:= g_Mons_TypeIdByName(P
[1]);
5906 if (a
< MONSTER_DEMON
) or (a
> MONSTER_MAN
) then
5907 g_Console_Add(Format(_lc
[I_MSG_NO_MONSTER
], [P
[1]]))
5910 with gPlayer1
.Obj
do
5912 mon
:= g_Monsters_Create(a
,
5913 X
+ Rect
.X
+ (Rect
.Width
div 2),
5914 Y
+ Rect
.Y
+ Rect
.Height
,
5915 gPlayer1
.Direction
, True);
5917 if (Length(P
) > 2) and (mon
<> nil) then
5919 if (CompareText(P
[2], 'normal') = 0) then mon
.MonsterBehaviour
:= BH_NORMAL
5920 else if (CompareText(P
[2], 'killer') = 0) then mon
.MonsterBehaviour
:= BH_KILLER
5921 else if (CompareText(P
[2], 'maniac') = 0) then mon
.MonsterBehaviour
:= BH_MANIAC
5922 else if (CompareText(P
[2], 'insane') = 0) then mon
.MonsterBehaviour
:= BH_INSANE
5923 else if (CompareText(P
[2], 'cannibal') = 0) then mon
.MonsterBehaviour
:= BH_CANNIBAL
5924 else if (CompareText(P
[2], 'good') = 0) then mon
.MonsterBehaviour
:= BH_GOOD
5925 else if (CompareText(P
[2], 'friend') = 0) then mon
.MonsterBehaviour
:= BH_GOOD
5926 else if (CompareText(P
[2], 'friendly') = 0) then mon
.MonsterBehaviour
:= BH_GOOD
5927 else mon
.MonsterBehaviour
:= Min(Max(StrToIntDef(P
[2], BH_NORMAL
), BH_NORMAL
), BH_GOOD
);
5932 else if (cmd
= 'd_health') then
5934 if (Length(P
) > 1) and
5935 ((P
[1] = '1') or (P
[1] = '0')) then
5936 g_debug_HealthBar
:= (P
[1][1] = '1');
5938 g_Console_Add(Format('d_health is %d', [Byte(g_debug_HealthBar
)]));
5940 else if (cmd
= 'd_player') then
5942 if (Length(P
) > 1) and
5943 ((P
[1] = '1') or (P
[1] = '0')) then
5944 g_debug_Player
:= (P
[1][1] = '1');
5946 g_Console_Add(Format(cmd
+ ' is %d', [Byte(g_Debug_Player
)]));
5948 else if (cmd
= 'd_mem') then
5954 g_Console_Add(_lc
[I_MSG_NOT_DEBUG
]);
5958 procedure GameCheats(P
: SSArray
);
5964 if (not gGameOn
) or (not conIsCheatsEnabled
) then
5966 g_Console_Add('not available');
5972 g_Console_Add('where is the player?!');
5975 cmd
:= LowerCase(P
[0]);
5979 plr
.GodMode
:= not plr
.GodMode
;
5980 if plr
.GodMode
then g_Console_Add('player is godlike now') else g_Console_Add('player is mortal now');
5983 // give <health|exit|weapons|air|suit|jetpack|berserk|all>
5984 if cmd
= 'give' then
5986 if length(P
) < 2 then begin g_Console_Add('give what?!'); exit
; end;
5987 for f
:= 1 to High(P
) do
5989 cmd
:= LowerCase(P
[f
]);
5990 if cmd
= 'health' then begin plr
.RestoreHealthArmor(); g_Console_Add('player feels himself better'); continue
; end;
5991 if (cmd
= 'all') {or (cmd = 'weapons')} then begin plr
.AllRulez(False); g_Console_Add('player got the gifts'); continue
; end;
5992 if cmd
= 'exit' then
5994 if gTriggers
<> nil then
5996 for a
:= 0 to High(gTriggers
) do
5998 if gTriggers
[a
].TriggerType
= TRIGGER_EXIT
then
6000 g_Console_Add('player left the map');
6001 gExitByTrigger
:= True;
6002 //g_Game_ExitLevel(gTriggers[a].Data.MapName);
6003 g_Game_ExitLevel(gTriggers
[a
].tgcMap
);
6011 if cmd
= 'air' then begin plr
.GiveItem(ITEM_OXYGEN
); g_Console_Add('player got some air'); continue
; end;
6012 if cmd
= 'jetpack' then begin plr
.GiveItem(ITEM_JETPACK
); g_Console_Add('player got a jetpack'); continue
; end;
6013 if cmd
= 'suit' then begin plr
.GiveItem(ITEM_SUIT
); g_Console_Add('player got an envirosuit'); continue
; end;
6014 if cmd
= 'berserk' then begin plr
.GiveItem(ITEM_MEDKIT_BLACK
); g_Console_Add('player got a berserk pack'); continue
; end;
6015 if cmd
= 'backpack' then begin plr
.GiveItem(ITEM_AMMO_BACKPACK
); g_Console_Add('player got a backpack'); continue
; end;
6017 if cmd
= 'helmet' then begin plr
.GiveItem(ITEM_HELMET
); g_Console_Add('player got a helmet'); continue
; end;
6018 if cmd
= 'bottle' then begin plr
.GiveItem(ITEM_BOTTLE
); g_Console_Add('player got a bottle of health'); continue
; end;
6020 if cmd
= 'stimpack' then begin plr
.GiveItem(ITEM_MEDKIT_SMALL
); g_Console_Add('player got a stimpack'); continue
; end;
6021 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;
6023 if cmd
= 'greenarmor' then begin plr
.GiveItem(ITEM_ARMOR_GREEN
); g_Console_Add('player got a security armor'); continue
; end;
6024 if cmd
= 'bluearmor' then begin plr
.GiveItem(ITEM_ARMOR_BLUE
); g_Console_Add('player got a combat armor'); continue
; end;
6026 if (cmd
= 'megasphere') or (cmd
= 'mega') then begin plr
.GiveItem(ITEM_SPHERE_BLUE
); g_Console_Add('player got a megasphere'); continue
; end;
6027 if (cmd
= 'soulsphere') or (cmd
= 'soul')then begin plr
.GiveItem(ITEM_SPHERE_WHITE
); g_Console_Add('player got a soul sphere'); continue
; end;
6029 if (cmd
= 'invul') or (cmd
= 'invulnerability') then begin plr
.GiveItem(ITEM_INVUL
); g_Console_Add('player got invulnerability'); continue
; end;
6030 if (cmd
= 'invis') or (cmd
= 'invisibility') then begin plr
.GiveItem(ITEM_INVIS
); g_Console_Add('player got invisibility'); continue
; end;
6032 if cmd
= 'redkey' then begin plr
.GiveItem(ITEM_KEY_RED
); g_Console_Add('player got the red key'); continue
; end;
6033 if cmd
= 'greenkey' then begin plr
.GiveItem(ITEM_KEY_GREEN
); g_Console_Add('player got the green key'); continue
; end;
6034 if cmd
= 'bluekey' then begin plr
.GiveItem(ITEM_KEY_BLUE
); g_Console_Add('player got the blue key'); continue
; end;
6036 if (cmd
= 'shotgun') or (cmd
= 'sg') then begin plr
.GiveItem(ITEM_WEAPON_SHOTGUN1
); g_Console_Add('player got a shotgun'); continue
; end;
6037 if (cmd
= 'supershotgun') or (cmd
= 'ssg') then begin plr
.GiveItem(ITEM_WEAPON_SHOTGUN2
); g_Console_Add('player got a supershotgun'); continue
; end;
6038 if cmd
= 'chaingun' then begin plr
.GiveItem(ITEM_WEAPON_CHAINGUN
); g_Console_Add('player got a chaingun'); continue
; end;
6039 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;
6040 if cmd
= 'plasmagun' then begin plr
.GiveItem(ITEM_WEAPON_PLASMA
); g_Console_Add('player got a plasma gun'); continue
; end;
6041 if cmd
= 'bfg' then begin plr
.GiveItem(ITEM_WEAPON_BFG
); g_Console_Add('player got a BFG-9000'); continue
; end;
6043 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;
6044 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;
6045 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;
6046 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;
6047 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;
6048 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;
6050 if cmd
= 'superchaingun' then begin plr
.GiveItem(ITEM_WEAPON_SUPERPULEMET
); g_Console_Add('player got a superchaingun'); continue
; end;
6051 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;
6053 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;
6054 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;
6056 if cmd
= 'chainsaw' then begin plr
.GiveItem(ITEM_WEAPON_SAW
); g_Console_Add('player got a chainsaw'); continue
; end;
6058 if cmd
= 'ammo' then
6060 plr
.GiveItem(ITEM_AMMO_SHELLS_BOX
);
6061 plr
.GiveItem(ITEM_AMMO_BULLETS_BOX
);
6062 plr
.GiveItem(ITEM_AMMO_CELL_BIG
);
6063 plr
.GiveItem(ITEM_AMMO_ROCKET_BOX
);
6064 plr
.GiveItem(ITEM_AMMO_FUELCAN
);
6065 g_Console_Add('player got some ammo');
6069 if cmd
= 'clip' then begin plr
.GiveItem(ITEM_AMMO_BULLETS
); g_Console_Add('player got some bullets'); continue
; end;
6070 if cmd
= 'bullets' then begin plr
.GiveItem(ITEM_AMMO_BULLETS_BOX
); g_Console_Add('player got a box of bullets'); continue
; end;
6072 if cmd
= 'shells' then begin plr
.GiveItem(ITEM_AMMO_SHELLS
); g_Console_Add('player got some shells'); continue
; end;
6073 if cmd
= 'shellbox' then begin plr
.GiveItem(ITEM_AMMO_SHELLS_BOX
); g_Console_Add('player got a box of shells'); continue
; end;
6075 if cmd
= 'cells' then begin plr
.GiveItem(ITEM_AMMO_CELL
); g_Console_Add('player got some cells'); continue
; end;
6076 if cmd
= 'battery' then begin plr
.GiveItem(ITEM_AMMO_CELL_BIG
); g_Console_Add('player got cell battery'); continue
; end;
6078 if cmd
= 'rocket' then begin plr
.GiveItem(ITEM_AMMO_ROCKET
); g_Console_Add('player got a rocket'); continue
; end;
6079 if cmd
= 'rocketbox' then begin plr
.GiveItem(ITEM_AMMO_ROCKET_BOX
); g_Console_Add('player got some rockets'); continue
; end;
6081 if (cmd
= 'fuel') or (cmd
= 'fuelcan') then begin plr
.GiveItem(ITEM_AMMO_FUELCAN
); g_Console_Add('player got fuel canister'); continue
; end;
6083 if cmd
= 'weapons' then
6085 plr
.GiveItem(ITEM_WEAPON_SHOTGUN1
);
6086 plr
.GiveItem(ITEM_WEAPON_SHOTGUN2
);
6087 plr
.GiveItem(ITEM_WEAPON_CHAINGUN
);
6088 plr
.GiveItem(ITEM_WEAPON_ROCKETLAUNCHER
);
6089 plr
.GiveItem(ITEM_WEAPON_PLASMA
);
6090 plr
.GiveItem(ITEM_WEAPON_BFG
);
6091 g_Console_Add('player got weapons');
6095 if cmd
= 'keys' then
6097 plr
.GiveItem(ITEM_KEY_RED
);
6098 plr
.GiveItem(ITEM_KEY_GREEN
);
6099 plr
.GiveItem(ITEM_KEY_BLUE
);
6100 g_Console_Add('player got all keys');
6104 g_Console_Add('i don''t know how to give '''+cmd
+'''!');
6109 if cmd
= 'open' then
6111 g_Console_Add('player activated sesame');
6112 g_Triggers_OpenAll();
6119 if gFly
then g_Console_Add('player feels himself lighter') else g_Console_Add('player lost his wings');
6123 if cmd
= 'noclip' then
6126 g_Console_Add('wall hardeness adjusted');
6130 if cmd
= 'notarget' then
6132 plr
.NoTarget
:= not plr
.NoTarget
;
6133 if plr
.NoTarget
then g_Console_Add('player hides in shadows') else g_Console_Add('player is brave again');
6137 if cmd
= 'noreload' then
6139 plr
.NoReload
:= not plr
.NoReload
;
6140 if plr
.NoReload
then g_Console_Add('player is action hero now') else g_Console_Add('player is ordinary man now');
6144 if cmd
= 'speedy' then
6146 MAX_RUNVEL
:= 32-MAX_RUNVEL
;
6147 g_Console_Add('speed adjusted');
6151 if cmd
= 'jumpy' then
6153 VEL_JUMP
:= 30-VEL_JUMP
;
6154 g_Console_Add('jump height adjusted');
6158 if cmd
= 'automap' then
6160 gShowMap
:= not gShowMap
;
6161 if gShowMap
then g_Console_Add('player gains second sight') else g_Console_Add('player lost second sight');
6165 if cmd
= 'aimline' then
6167 gAimLine
:= not gAimLine
;
6168 if gAimLine
then g_Console_Add('player gains laser sight') else g_Console_Add('player lost laser sight');
6173 procedure GameCommands(P
: SSArray
);
6179 pl
: pTNetClient
= nil;
6187 cmd
:= LowerCase(P
[0]);
6189 if cmd
= 'pause' then
6191 if (g_ActiveWindow
= nil) then
6192 g_Game_Pause(not gPauseMain
);
6194 else if cmd
= 'endgame' then
6195 gExit
:= EXIT_SIMPLE
6196 else if cmd
= 'restart' then
6198 if gGameOn
or (gState
in [STATE_INTERSINGLE
, STATE_INTERCUSTOM
]) then
6200 if g_Game_IsClient
then
6202 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6207 g_Console_Add(_lc
[I_MSG_NOT_GAME
]);
6209 else if cmd
= 'kick' then
6211 if g_Game_IsServer
then
6213 if Length(P
) < 2 then
6215 g_Console_Add('kick <name>');
6220 g_Console_Add('kick <name>');
6224 if g_Game_IsNet
then
6225 pl
:= g_Net_Client_ByName(P
[1]);
6228 s
:= g_Net_ClientName_ByID(pl
^.ID
);
6229 enet_peer_disconnect(pl
^.Peer
, NET_DISC_KICK
);
6230 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
6231 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
6232 g_Net_Slist_ServerPlayerLeaves();
6233 end else if gPlayers
<> nil then
6234 for a
:= Low(gPlayers
) to High(gPlayers
) do
6235 if gPlayers
[a
] <> nil then
6236 if Copy(LowerCase(gPlayers
[a
].Name
), 1, Length(P
[1])) = LowerCase(P
[1]) then
6238 // Íå îòêëþ÷àòü îñíîâíûõ èãðîêîâ â ñèíãëå
6239 if not(gPlayers
[a
] is TBot
) and (gGameSettings
.GameType
= GT_SINGLE
) then
6241 gPlayers
[a
].Lives
:= 0;
6242 gPlayers
[a
].Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
6243 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [gPlayers
[a
].Name
]), True);
6244 g_Player_Remove(gPlayers
[a
].UID
);
6245 g_Net_Slist_ServerPlayerLeaves();
6246 // Åñëè íå ïåðåìåøàòü, ïðè äîáàâëåíèè íîâûõ áîòîâ ïîÿâÿòñÿ ñòàðûå
6250 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6252 else if cmd
= 'kick_id' then
6254 if g_Game_IsServer
and g_Game_IsNet
then
6256 if Length(P
) < 2 then
6258 g_Console_Add('kick_id <client ID>');
6263 g_Console_Add('kick_id <client ID>');
6267 a
:= StrToIntDef(P
[1], 0);
6268 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
6270 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
6272 s
:= g_Net_ClientName_ByID(NetClients
[a
].ID
);
6273 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_KICK
);
6274 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
6275 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
6276 g_Net_Slist_ServerPlayerLeaves();
6280 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6282 else if cmd
= 'ban' then
6284 if g_Game_IsServer
and g_Game_IsNet
then
6286 if Length(P
) < 2 then
6288 g_Console_Add('ban <name>');
6293 g_Console_Add('ban <name>');
6297 pl
:= g_Net_Client_ByName(P
[1]);
6300 s
:= g_Net_ClientName_ByID(pl
^.ID
);
6301 g_Net_BanHost(pl
^.Peer
^.address
.host
, False);
6302 enet_peer_disconnect(pl
^.Peer
, NET_DISC_TEMPBAN
);
6303 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
6304 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
6305 g_Net_Slist_ServerPlayerLeaves();
6307 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
6309 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6311 else if cmd
= 'ban_id' then
6313 if g_Game_IsServer
and g_Game_IsNet
then
6315 if Length(P
) < 2 then
6317 g_Console_Add('ban_id <client ID>');
6322 g_Console_Add('ban_id <client ID>');
6326 a
:= StrToIntDef(P
[1], 0);
6327 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
6328 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
6330 s
:= g_Net_ClientName_ByID(NetClients
[a
].ID
);
6331 g_Net_BanHost(NetClients
[a
].Peer
^.address
.host
, False);
6332 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_TEMPBAN
);
6333 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
6334 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
6335 g_Net_Slist_ServerPlayerLeaves();
6338 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6340 else if cmd
= 'permban' then
6342 if g_Game_IsServer
and g_Game_IsNet
then
6344 if Length(P
) < 2 then
6346 g_Console_Add('permban <name>');
6351 g_Console_Add('permban <name>');
6355 pl
:= g_Net_Client_ByName(P
[1]);
6358 s
:= g_Net_ClientName_ByID(pl
^.ID
);
6359 g_Net_BanHost(pl
^.Peer
^.address
.host
);
6360 enet_peer_disconnect(pl
^.Peer
, NET_DISC_BAN
);
6361 g_Net_SaveBanList();
6362 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
6363 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
6364 g_Net_Slist_ServerPlayerLeaves();
6366 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
6368 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6370 else if cmd
= 'permban_id' then
6372 if g_Game_IsServer
and g_Game_IsNet
then
6374 if Length(P
) < 2 then
6376 g_Console_Add('permban_id <client ID>');
6381 g_Console_Add('permban_id <client ID>');
6385 a
:= StrToIntDef(P
[1], 0);
6386 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
6387 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
6389 s
:= g_Net_ClientName_ByID(NetClients
[a
].ID
);
6390 g_Net_BanHost(NetClients
[a
].Peer
^.address
.host
);
6391 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_BAN
);
6392 g_Net_SaveBanList();
6393 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
6394 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
6395 g_Net_Slist_ServerPlayerLeaves();
6398 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6400 else if cmd
= 'unban' then
6402 if g_Game_IsServer
and g_Game_IsNet
then
6404 if Length(P
) < 2 then
6406 g_Console_Add('unban <IP Address>');
6411 g_Console_Add('unban <IP Address>');
6415 if g_Net_UnbanHost(P
[1]) then
6417 g_Console_Add(Format(_lc
[I_MSG_UNBAN_OK
], [P
[1]]));
6418 g_Net_SaveBanList();
6420 g_Console_Add(Format(_lc
[I_MSG_UNBAN_FAIL
], [P
[1]]));
6422 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6424 else if cmd
= 'clientlist' then
6426 if g_Game_IsServer
and g_Game_IsNet
then
6429 if NetClients
<> nil then
6430 for a
:= Low(NetClients
) to High(NetClients
) do
6431 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
6433 plr
:= g_Player_Get(NetClients
[a
].Player
);
6434 if plr
= nil then continue
;
6436 g_Console_Add(Format('#%2d: %-15s | %s', [a
,
6437 IpToStr(NetClients
[a
].Peer
^.address
.host
), plr
.Name
]));
6440 g_Console_Add(_lc
[I_MSG_NOCLIENTS
]);
6442 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6444 else if cmd
= 'connect' then
6446 if (NetMode
= NET_NONE
) then
6448 if Length(P
) < 2 then
6450 g_Console_Add('connect <IP> [port] [password]');
6455 g_Console_Add('connect <IP> [port] [password]');
6459 if Length(P
) > 2 then
6460 prt
:= StrToIntDef(P
[2], 25666)
6464 if Length(P
) > 3 then
6469 g_Game_StartClient(P
[1], prt
, pw
);
6472 else if cmd
= 'disconnect' then
6474 if (NetMode
= NET_CLIENT
) then
6477 else if cmd
= 'reconnect' then
6479 if (NetMode
= NET_SERVER
) then
6482 if (NetMode
= NET_CLIENT
) then
6485 gExit
:= EXIT_SIMPLE
;
6489 //TODO: Use last successful password to reconnect, instead of ''
6490 g_Game_StartClient(NetClientIP
, NetClientPort
, '');
6492 else if (cmd
= 'addbot') or
6493 (cmd
= 'bot_add') then
6495 if Length(P
) > 2 then
6496 g_Bot_Add(TEAM_NONE
, StrToIntDef(P
[1], 2), StrToIntDef(P
[2], 100))
6497 else if Length(P
) > 1 then
6498 g_Bot_Add(TEAM_NONE
, StrToIntDef(P
[1], 2))
6500 g_Bot_Add(TEAM_NONE
, 2);
6502 else if cmd
= 'bot_addlist' then
6504 if Length(P
) > 1 then
6506 if Length(P
) = 2 then
6507 g_Bot_AddList(TEAM_NONE
, P
[1], StrToIntDef(P
[1], -1))
6508 else if Length(P
) = 3 then
6509 g_Bot_AddList(TEAM_NONE
, P
[1], StrToIntDef(P
[1], -1), StrToIntDef(P
[2], 100))
6511 g_Bot_AddList(IfThen(P
[2] = 'red', TEAM_RED
, TEAM_BLUE
), P
[1], StrToIntDef(P
[1], -1));
6514 else if cmd
= 'bot_removeall' then
6516 else if cmd
= 'chat' then
6518 if g_Game_IsNet
then
6520 if Length(P
) > 1 then
6522 for a
:= 1 to High(P
) do
6523 chstr
:= chstr
+ P
[a
] + ' ';
6525 if Length(chstr
) > 200 then SetLength(chstr
, 200);
6527 if Length(chstr
) < 1 then
6529 g_Console_Add('chat <text>');
6533 chstr
:= b_Text_Format(chstr
);
6534 if g_Game_IsClient
then
6535 MC_SEND_Chat(chstr
, NET_CHAT_PLAYER
)
6537 MH_SEND_Chat(gPlayer1Settings
.Name
+ ': ' + chstr
, NET_CHAT_PLAYER
);
6540 g_Console_Add('chat <text>');
6542 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6544 else if cmd
= 'teamchat' then
6546 if g_Game_IsNet
and (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
6548 if Length(P
) > 1 then
6550 for a
:= 1 to High(P
) do
6551 chstr
:= chstr
+ P
[a
] + ' ';
6553 if Length(chstr
) > 200 then SetLength(chstr
, 200);
6555 if Length(chstr
) < 1 then
6557 g_Console_Add('teamchat <text>');
6561 chstr
:= b_Text_Format(chstr
);
6562 if g_Game_IsClient
then
6563 MC_SEND_Chat(chstr
, NET_CHAT_TEAM
)
6565 MH_SEND_Chat(gPlayer1Settings
.Name
+ ': ' + chstr
, NET_CHAT_TEAM
,
6566 gPlayer1Settings
.Team
);
6569 g_Console_Add('teamchat <text>');
6571 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6573 else if cmd
= 'game' then
6575 if gGameSettings
.GameType
<> GT_NONE
then
6577 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6580 if Length(P
) = 1 then
6582 g_Console_Add(cmd
+ ' <WAD> [MAP] [# players]');
6585 // game not started yet, load fist map from some wad
6587 s
:= addWadExtension(P
[1]);
6588 found
:= e_FindResource(AllMapDirs
, s
);
6592 P
[1] := ExpandFileName(P
[1]);
6593 // if map not choosed then set first map
6594 if Length(P
) < 3 then
6597 P
[2] := g_Game_GetFirstMap(P
[1]);
6600 s
:= P
[1] + ':\' + UpperCase(P
[2]);
6602 if g_Map_Exist(s
) then
6606 with gGameSettings
do
6608 GameMode
:= g_Game_TextToMode(gsGameMode
);
6609 if gSwitchGameMode
<> GM_NONE
then
6610 GameMode
:= gSwitchGameMode
;
6611 if GameMode
= GM_NONE
then GameMode
:= GM_DM
;
6612 if GameMode
= GM_SINGLE
then GameMode
:= GM_COOP
;
6614 if Length(P
) >= 4 then
6615 b
:= StrToIntDef(P
[3], 1);
6616 g_Game_StartCustom(s
, GameMode
, TimeLimit
,
6617 GoalLimit
, MaxLives
, Options
, b
);
6622 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
6624 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [UpperCase(P
[2]), P
[1]]));
6626 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]));
6628 else if cmd
= 'host' then
6630 if gGameSettings
.GameType
<> GT_NONE
then
6632 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6635 if Length(P
) < 4 then
6637 g_Console_Add(cmd
+ ' <listen IP> <port> <WAD> [MAP] [# players]');
6640 if not StrToIp(P
[1], listen
) then
6642 prt
:= StrToIntDef(P
[2], 25666);
6644 s
:= addWadExtension(P
[3]);
6645 found
:= e_FindResource(AllMapDirs
, s
);
6649 // get first map in wad, if not specified
6650 if Length(P
) < 5 then
6653 P
[4] := g_Game_GetFirstMap(P
[1]);
6655 s
:= P
[3] + ':\' + UpperCase(P
[4]);
6656 if g_Map_Exist(s
) then
6660 with gGameSettings
do
6662 GameMode
:= g_Game_TextToMode(gsGameMode
);
6663 if gSwitchGameMode
<> GM_NONE
then GameMode
:= gSwitchGameMode
;
6664 if GameMode
= GM_NONE
then GameMode
:= GM_DM
;
6665 if GameMode
= GM_SINGLE
then GameMode
:= GM_COOP
;
6667 if Length(P
) >= 6 then
6668 b
:= StrToIntDef(P
[5], 0);
6669 g_Game_StartServer(s
, GameMode
, TimeLimit
, GoalLimit
, MaxLives
, Options
, b
, listen
, prt
)
6675 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[3]]))
6677 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [UpperCase(P
[4]), P
[3]]))
6682 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[3]]))
6685 else if cmd
= 'map' then
6687 if Length(P
) = 1 then
6689 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
6691 g_Console_Add(cmd
+ ' <MAP>');
6692 g_Console_Add(cmd
+ ' <WAD> [MAP]')
6696 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
])
6701 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
6703 if Length(P
) < 3 then
6705 // first param is map or wad
6706 s
:= UpperCase(P
[1]);
6707 if g_Map_Exist(gGameSettings
.WAD
+ ':\' + s
) then
6709 gExitByTrigger
:= False;
6712 // already in game, finish current map
6714 gExit
:= EXIT_ENDLEVELCUSTOM
;
6718 // intermission, so change map immediately
6725 found
:= e_FindResource(AllMapDirs
, s
);
6727 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [s
, 'WAD ' + P
[1]]));
6730 // no such map, found wad
6733 P
[1] := ExpandFileName(pw
);
6734 P
[2] := g_Game_GetFirstMap(P
[1]);
6735 s
:= P
[1] + ':\' + P
[2];
6736 if g_Map_Exist(s
) then
6738 gExitByTrigger
:= False;
6741 // already in game, finish current map
6743 gExit
:= EXIT_ENDLEVELCUSTOM
6747 // intermission, so change map immediately
6754 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
6756 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]))
6761 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]))
6767 s
:= addWadExtension(P
[1]);
6768 found
:= e_FindResource(AllMapDirs
, s
);
6772 P
[2] := UpperCase(P
[2]);
6773 s
:= P
[1] + ':\' + P
[2];
6774 if g_Map_Exist(s
) then
6776 gExitByTrigger
:= False;
6780 gExit
:= EXIT_ENDLEVELCUSTOM
6789 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]))
6794 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]))
6800 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
])
6804 else if cmd
= 'nextmap' then
6806 if not(gGameOn
or (gState
= STATE_INTERCUSTOM
)) then
6808 g_Console_Add(_lc
[I_MSG_NOT_GAME
])
6813 if Length(P
) = 1 then
6815 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
6817 g_Console_Add(cmd
+ ' <MAP>');
6818 g_Console_Add(cmd
+ ' <WAD> [MAP]');
6823 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6829 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
6831 if Length(P
) < 3 then
6833 // first param is map or wad
6834 s
:= UpperCase(P
[1]);
6835 if g_Map_Exist(gGameSettings
.WAD
+ ':\' + s
) then
6838 gExitByTrigger
:= False;
6844 // no such map, found wad
6845 pw
:= addWadExtension(P
[1]);
6846 found
:= e_FindResource(MapDirs
, pw
);
6848 found
:= e_FindResource(WadDirs
, pw
);
6850 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [s
, P
[1]]));
6853 // map not specified, select first map
6855 P
[2] := g_Game_GetFirstMap(P
[1]);
6856 s
:= P
[1] + ':\' + P
[2];
6857 if g_Map_Exist(s
) then
6859 gExitByTrigger
:= False;
6866 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
6868 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]))
6873 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]))
6879 // specified two params wad + map
6880 pw
:= addWadExtension(P
[1]);
6881 found
:= e_FindResource(MapDirs
, pw
);
6883 found
:= e_FindResource(MapDirs
, pw
);
6887 P
[2] := UpperCase(P
[2]);
6888 s
:= P
[1] + ':\' + P
[2];
6889 if g_Map_Exist(s
) then
6891 gExitByTrigger
:= False;
6897 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]))
6902 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]))
6908 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
])
6913 if gNextMap
= '' then
6914 g_Console_Add(_lc
[I_MSG_NEXTMAP_UNSET
])
6916 g_Console_Add(Format(_lc
[I_MSG_NEXTMAP_SET
], [gNextMap
]))
6920 else if (cmd
= 'endmap') or (cmd
= 'goodbye') then
6924 g_Console_Add(_lc
[I_MSG_NOT_GAME
])
6928 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
6930 gExitByTrigger
:= False;
6931 // next map not specified, try to find trigger EXIT
6932 if (gNextMap
= '') and (gTriggers
<> nil) then
6934 for a
:= 0 to High(gTriggers
) do
6936 if gTriggers
[a
].TriggerType
= TRIGGER_EXIT
then
6938 gExitByTrigger
:= True;
6939 //gNextMap := gTriggers[a].Data.MapName;
6940 gNextMap
:= gTriggers
[a
].tgcMap
;
6945 if gNextMap
= '' then
6946 gNextMap
:= g_Game_GetNextMap();
6947 if not isWadPath(gNextMap
) then
6948 s
:= gGameSettings
.WAD
+ ':\' + gNextMap
6951 if g_Map_Exist(s
) then
6952 gExit
:= EXIT_ENDLEVELCUSTOM
6954 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [gNextMap
]))
6958 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
])
6962 else if (cmd
= 'event') then
6964 if (Length(P
) <= 1) then
6966 for a
:= 0 to High(gEvents
) do
6967 if gEvents
[a
].Command
= '' then
6968 g_Console_Add(gEvents
[a
].Name
+ ' <none>')
6970 g_Console_Add(gEvents
[a
].Name
+ ' "' + gEvents
[a
].Command
+ '"');
6973 if (Length(P
) = 2) then
6975 for a
:= 0 to High(gEvents
) do
6976 if gEvents
[a
].Name
= P
[1] then
6977 if gEvents
[a
].Command
= '' then
6978 g_Console_Add(gEvents
[a
].Name
+ ' <none>')
6980 g_Console_Add(gEvents
[a
].Name
+ ' "' + gEvents
[a
].Command
+ '"');
6983 for a
:= 0 to High(gEvents
) do
6984 if gEvents
[a
].Name
= P
[1] then
6986 gEvents
[a
].Command
:= '';
6987 for b
:= 2 to High(P
) do
6988 if Pos(' ', P
[b
]) = 0 then
6989 gEvents
[a
].Command
:= gEvents
[a
].Command
+ ' ' + P
[b
]
6991 gEvents
[a
].Command
:= gEvents
[a
].Command
+ ' "' + P
[b
] + '"';
6992 gEvents
[a
].Command
:= Trim(gEvents
[a
].Command
);
6996 else if cmd
= 'suicide' then
7000 if g_Game_IsClient
then
7001 MC_SEND_CheatRequest(NET_CHEAT_SUICIDE
)
7004 if gPlayer1
<> nil then
7005 gPlayer1
.Damage(SUICIDE_DAMAGE
, gPlayer1
.UID
, 0, 0, HIT_SELF
);
7006 if gPlayer2
<> nil then
7007 gPlayer2
.Damage(SUICIDE_DAMAGE
, gPlayer2
.UID
, 0, 0, HIT_SELF
);
7011 else if cmd
= 'screenshot' then
7015 else if cmd
= 'weapon' then
7017 if Length(p
) = 2 then
7019 a
:= WP_FIRST
+ StrToInt(p
[1]) - 1;
7020 if (a
>= WP_FIRST
) and (a
<= WP_LAST
) then
7021 gSelectWeapon
[0, a
] := True
7024 else if (cmd
= 'p1_weapon') or (cmd
= 'p2_weapon') then
7026 if Length(p
) = 2 then
7028 a
:= WP_FIRST
+ StrToInt(p
[1]) - 1;
7029 b
:= ord(cmd
[2]) - ord('1');
7030 if (a
>= WP_FIRST
) and (a
<= WP_LAST
) then
7031 gSelectWeapon
[b
, a
] := True
7034 // Êîìàíäû Ñâîåé èãðû:
7035 else if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
7037 if cmd
= 'bot_addred' then
7039 if Length(P
) > 1 then
7040 g_Bot_Add(TEAM_RED
, StrToIntDef(P
[1], 2))
7042 g_Bot_Add(TEAM_RED
, 2);
7044 else if cmd
= 'bot_addblue' then
7046 if Length(P
) > 1 then
7047 g_Bot_Add(TEAM_BLUE
, StrToIntDef(P
[1], 2))
7049 g_Bot_Add(TEAM_BLUE
, 2);
7051 else if cmd
= 'spectate' then
7057 else if cmd
= 'say' then
7059 if g_Game_IsServer
and g_Game_IsNet
then
7061 if Length(P
) > 1 then
7064 for a
:= 1 to High(P
) do
7065 chstr
:= chstr
+ P
[a
] + ' ';
7067 if Length(chstr
) > 200 then SetLength(chstr
, 200);
7069 if Length(chstr
) < 1 then
7071 g_Console_Add('say <text>');
7075 chstr
:= b_Text_Format(chstr
);
7076 MH_SEND_Chat(chstr
, NET_CHAT_PLAYER
);
7078 else g_Console_Add('say <text>');
7080 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
7082 else if cmd
= 'tell' then
7084 if g_Game_IsServer
and g_Game_IsNet
then
7086 if (Length(P
) > 2) and (P
[1] <> '') then
7089 for a
:= 2 to High(P
) do
7090 chstr
:= chstr
+ P
[a
] + ' ';
7092 if Length(chstr
) > 200 then SetLength(chstr
, 200);
7094 if Length(chstr
) < 1 then
7096 g_Console_Add('tell <playername> <text>');
7100 pl
:= g_Net_Client_ByName(P
[1]);
7102 MH_SEND_Chat(b_Text_Format(chstr
), NET_CHAT_PLAYER
, pl
^.ID
)
7104 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
7106 else g_Console_Add('tell <playername> <text>');
7108 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
7110 else if cmd
= 'centerprint' then
7112 if (Length(P
) > 2) and (P
[1] <> '') then
7115 for a
:= 2 to High(P
) do
7116 chstr
:= chstr
+ P
[a
] + ' ';
7118 if Length(chstr
) > 200 then SetLength(chstr
, 200);
7120 if Length(chstr
) < 1 then
7122 g_Console_Add('centerprint <timeout> <text>');
7126 a
:= StrToIntDef(P
[1], 100);
7127 chstr
:= b_Text_Format(chstr
);
7128 g_Game_Message(chstr
, a
);
7129 if g_Game_IsNet
and g_Game_IsServer
then
7130 MH_SEND_GameEvent(NET_EV_BIGTEXT
, a
, chstr
);
7132 else g_Console_Add('centerprint <timeout> <text>');
7134 else if (cmd
= 'overtime') and not g_Game_IsClient
then
7136 if (Length(P
) = 1) or (StrToIntDef(P
[1], -1) <= 0) then
7138 // Äîïîëíèòåëüíîå âðåìÿ:
7139 gGameSettings
.TimeLimit
:= (gTime
- gGameStartTime
) div 1000 + Word(StrToIntDef(P
[1], 0));
7141 g_Console_Add(Format(_lc
[I_MSG_TIME_LIMIT
],
7142 [gGameSettings
.TimeLimit
div 3600,
7143 (gGameSettings
.TimeLimit
div 60) mod 60,
7144 gGameSettings
.TimeLimit
mod 60]));
7145 if g_Game_IsNet
then MH_SEND_GameSettings
;
7147 else if (cmd
= 'rcon_password') and g_Game_IsClient
then
7149 if (Length(P
) <= 1) then
7150 g_Console_Add('rcon_password <password>')
7152 MC_SEND_RCONPassword(P
[1]);
7154 else if cmd
= 'rcon' then
7156 if g_Game_IsClient
then
7158 if Length(P
) > 1 then
7161 for a
:= 1 to High(P
) do
7162 chstr
:= chstr
+ P
[a
] + ' ';
7164 if Length(chstr
) > 200 then SetLength(chstr
, 200);
7166 if Length(chstr
) < 1 then
7168 g_Console_Add('rcon <command>');
7172 MC_SEND_RCONCommand(chstr
);
7174 else g_Console_Add('rcon <command>');
7177 else if cmd
= 'ready' then
7179 if g_Game_IsServer
and (gLMSRespawn
= LMS_RESPAWN_WARMUP
) then
7180 gLMSRespawnTime
:= gTime
+ 100;
7182 else if (cmd
= 'callvote') and g_Game_IsNet
then
7184 if Length(P
) > 1 then
7187 for a
:= 1 to High(P
) do begin
7188 if a
> 1 then chstr
:= chstr
+ ' ';
7189 chstr
:= chstr
+ P
[a
];
7192 if Length(chstr
) > 200 then SetLength(chstr
, 200);
7194 if Length(chstr
) < 1 then
7196 g_Console_Add('callvote <command>');
7200 if g_Game_IsClient
then
7201 MC_SEND_Vote(True, chstr
)
7203 g_Game_StartVote(chstr
, gPlayer1Settings
.Name
);
7204 g_Console_Process('vote', True);
7207 g_Console_Add('callvote <command>');
7209 else if (cmd
= 'vote') and g_Game_IsNet
then
7211 if g_Game_IsClient
then
7213 else if gVoteInProgress
then
7215 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
7216 a
:= Floor((NetClientCount
+1)/2.0) + 1
7218 a
:= Floor(NetClientCount
/2.0) + 1;
7223 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_REVOKED
], [gPlayer1Settings
.Name
, gVoteCount
, a
]), True);
7224 MH_SEND_VoteEvent(NET_VE_REVOKE
, gPlayer1Settings
.Name
, 'a', gVoteCount
, a
);
7230 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_VOTE
], [gPlayer1Settings
.Name
, gVoteCount
, a
]), True);
7231 MH_SEND_VoteEvent(NET_VE_VOTE
, gPlayer1Settings
.Name
, 'a', gVoteCount
, a
);
7239 procedure SystemCommands(P
: SSArray
);
7243 cmd
:= LowerCase(P
[0]);
7252 gRC_Width
:= Max(1, gRC_Width
);
7253 gRC_Height
:= Max(1, gRC_Height
);
7254 gBPP
:= Max(1, gBPP
);
7255 if sys_SetDisplayMode(gRC_Width
, gRC_Height
, gBPP
, gRC_FullScreen
, gRC_Maximized
) = True then
7256 e_LogWriteln('resolution changed')
7258 e_LogWriteln('resolution not changed');
7259 sys_EnableVSync(gVSync
);
7263 if Length(p
) = 2 then
7265 gMaxFPS
:= StrToIntDef(p
[1], gMaxFPS
);
7267 gFrameTime
:= 1000 div gMaxFPS
7271 e_LogWritefln('r_maxfps %d', [gMaxFPS
]);
7275 if Length(p
) = 2 then
7277 gAskLanguage
:= true;
7278 gLanguage
:= LANGUAGE_ENGLISH
;
7279 case LowerCase(p
[1]) of
7282 gAskLanguage
:= false;
7283 gLanguage
:= LANGUAGE_ENGLISH
;
7287 gAskLanguage
:= false;
7288 gLanguage
:= LANGUAGE_RUSSIAN
;
7292 gAskLanguage
:= true;
7293 gLanguage
:= LANGUAGE_ENGLISH
;
7296 g_Language_Set(gLanguage
);
7300 e_LogWritefln('usage: %s <English|Russian|Ask>', [cmd
]);
7306 procedure g_TakeScreenShot(Filename
: string = '');
7307 var s
: TStream
; t
: TDateTime
; dir
, date
, name
: String;
7309 if e_NoGraphics
then Exit
;
7311 dir
:= e_GetWriteableDir(ScreenshotDirs
);
7313 if Filename
= '' then
7316 DateTimeToString(date
, 'yyyy-mm-dd-hh-nn-ss', t
);
7317 Filename
:= 'screenshot-' + date
;
7320 name
:= e_CatPath(dir
, Filename
+ '.png');
7321 s
:= createDiskFile(name
);
7323 e_MakeScreenshot(s
, gScreenWidth
, gScreenHeight
);
7325 g_Console_Add(Format(_lc
[I_CONSOLE_SCREENSHOT
], [name
]))
7327 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_WRITE
], [name
]));
7332 g_Console_Add('oh shit, i can''t create screenshot!')
7336 procedure g_Game_InGameMenu(Show
: Boolean);
7338 if (g_ActiveWindow
= nil) and Show
then
7340 if gGameSettings
.GameType
= GT_SINGLE
then
7341 g_GUI_ShowWindow('GameSingleMenu')
7344 if g_Game_IsClient
then
7345 g_GUI_ShowWindow('GameClientMenu')
7347 if g_Game_IsNet
then
7348 g_GUI_ShowWindow('GameServerMenu')
7350 g_GUI_ShowWindow('GameCustomMenu');
7352 g_Sound_PlayEx('MENU_OPEN');
7354 // Ïàóçà ïðè ìåíþ òîëüêî â îäèíî÷íîé èãðå:
7355 if (not g_Game_IsNet
) then
7359 if (g_ActiveWindow
<> nil) and (not Show
) then
7361 // Ïàóçà ïðè ìåíþ òîëüêî â îäèíî÷íîé èãðå:
7362 if (not g_Game_IsNet
) then
7363 g_Game_Pause(False);
7367 procedure g_Game_Pause (Enable
: Boolean);
7371 if not gGameOn
then exit
;
7373 if not (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
]) then exit
;
7376 gPauseMain
:= Enable
;
7378 if (gPause
<> oldPause
) then g_Game_PauseAllSounds(gPause
);
7381 procedure g_Game_HolmesPause (Enable
: Boolean);
7385 if not gGameOn
then exit
;
7386 if not (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
]) then exit
;
7389 gPauseHolmes
:= Enable
;
7391 if (gPause
<> oldPause
) then g_Game_PauseAllSounds(gPause
);
7394 procedure g_Game_PauseAllSounds(Enable
: Boolean);
7399 if gTriggers
<> nil then
7400 for i
:= 0 to High(gTriggers
) do
7401 with gTriggers
[i
] do
7402 if (TriggerType
= TRIGGER_SOUND
) and
7404 Sound
.IsPlaying() then
7406 Sound
.Pause(Enable
);
7410 if gPlayers
<> nil then
7411 for i
:= 0 to High(gPlayers
) do
7412 if gPlayers
[i
] <> nil then
7413 gPlayers
[i
].PauseSounds(Enable
);
7416 if gMusic
<> nil then
7417 gMusic
.Pause(Enable
);
7420 procedure g_Game_StopAllSounds(all
: Boolean);
7424 if gTriggers
<> nil then
7425 for i
:= 0 to High(gTriggers
) do
7426 with gTriggers
[i
] do
7427 if (TriggerType
= TRIGGER_SOUND
) and
7431 if gMusic
<> nil then
7438 procedure g_Game_UpdateTriggerSounds
;
7441 if gTriggers
<> nil then
7442 for i
:= 0 to High(gTriggers
) do
7443 with gTriggers
[i
] do
7444 if (TriggerType
= TRIGGER_SOUND
) and (Sound
<> nil) and tgcLocal
and Sound
.IsPlaying() then
7445 Sound
.SetCoordsRect(X
, Y
, Width
, Height
, tgcVolume
/ 255.0)
7448 function g_Game_IsWatchedPlayer(UID
: Word): Boolean;
7451 if (gPlayer1
<> nil) and (gPlayer1
.UID
= UID
) then
7456 if (gPlayer2
<> nil) and (gPlayer2
.UID
= UID
) then
7461 if gSpectMode
<> SPECT_PLAYERS
then
7463 if gSpectPID1
= UID
then
7468 if gSpectViewTwo
and (gSpectPID2
= UID
) then
7475 function g_Game_IsWatchedTeam(Team
: Byte): Boolean;
7480 if (gPlayer1
<> nil) and (gPlayer1
.Team
= Team
) then
7485 if (gPlayer2
<> nil) and (gPlayer2
.Team
= Team
) then
7490 if gSpectMode
<> SPECT_PLAYERS
then
7492 Pl
:= g_Player_Get(gSpectPID1
);
7493 if (Pl
<> nil) and (Pl
.Team
= Team
) then
7498 if gSpectViewTwo
then
7500 Pl
:= g_Player_Get(gSpectPID2
);
7501 if (Pl
<> nil) and (Pl
.Team
= Team
) then
7509 procedure g_Game_Message(Msg
: string; Time
: Word);
7511 MessageLineLength
:= (gScreenWidth
- 204) div e_CharFont_GetMaxWidth(gMenuFont
);
7512 MessageText
:= b_Text_Wrap(b_Text_Format(Msg
), MessageLineLength
);
7513 MessageTime
:= Time
;
7516 procedure g_Game_ChatSound(Text: String; Taunt
: Boolean = True);
7518 punct
: Array[0..13] of String =
7519 ('.', ',', ':', ';', '!', '?', '(', ')', '''', '"', '/', '\', '*', '^');
7525 function IsPunctuation(S
: String): Boolean;
7530 if Length(S
) <> 1 then
7532 for i
:= Low(punct
) to High(punct
) do
7533 if S
= punct
[i
] then
7539 function FilterPunctuation(S
: String): String;
7543 for i
:= Low(punct
) to High(punct
) do
7544 S
:= StringReplace(S
, punct
[i
], ' ', [rfReplaceAll
]);
7550 if gUseChatSounds
and Taunt
and (gChatSounds
<> nil) and (Pos(': ', Text) > 0) then
7552 // remove player name
7553 Delete(Text, 1, Pos(': ', Text) + 2 - 1);
7554 // for FullWord check
7555 Text := toLowerCase1251(' ' + Text + ' ');
7556 fpText
:= FilterPunctuation(Text);
7558 for i
:= 0 to Length(gChatSounds
) - 1 do
7561 for j
:= 0 to Length(gChatSounds
[i
].Tags
) - 1 do
7563 if gChatSounds
[i
].FullWord
and (not IsPunctuation(gChatSounds
[i
].Tags
[j
])) then
7564 ok
:= Pos(' ' + gChatSounds
[i
].Tags
[j
] + ' ', fpText
) > 0
7566 ok
:= Pos(gChatSounds
[i
].Tags
[j
], Text) > 0;
7572 gChatSounds
[i
].Sound
.Play();
7578 g_Sound_PlayEx('SOUND_GAME_RADIO');
7581 procedure g_Game_Announce_GoodShot(SpawnerUID
: Word);
7590 if not g_Game_IsWatchedPlayer(SpawnerUID
) then
7594 if goodsnd
[a
].IsPlaying() then
7597 goodsnd
[Random(4)].Play();
7600 procedure g_Game_Announce_KillCombo(Param
: Integer);
7607 UID
:= Param
and $FFFF;
7612 Pl
:= g_Player_Get(UID
);
7621 g_Console_Add(Format(_lc
[I_PLAYER_KILL_2X
], [Name
]), True);
7625 g_Console_Add(Format(_lc
[I_PLAYER_KILL_3X
], [Name
]), True);
7629 g_Console_Add(Format(_lc
[I_PLAYER_KILL_4X
], [Name
]), True);
7633 g_Console_Add(Format(_lc
[I_PLAYER_KILL_MX
], [Name
]), True);
7641 if not g_Game_IsWatchedPlayer(UID
) then
7644 if (not g_Game_IsWatchedPlayer(UID
)) and (c
< 4) then
7648 if killsnd
[n
].IsPlaying() then
7653 procedure g_Game_Announce_BodyKill(SpawnerUID
: Word);
7662 if not g_Game_IsWatchedPlayer(SpawnerUID
) then
7666 if hahasnd
[a
].IsPlaying() then
7669 hahasnd
[Random(3)].Play();
7672 procedure g_Game_StartVote(Command
, Initiator
: string);
7676 if not gVotesEnabled
then Exit
;
7677 if gGameSettings
.GameType
<> GT_SERVER
then Exit
;
7678 if gVoteInProgress
or gVotePassed
then
7680 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_INPROGRESS
], [gVoteCommand
]), True);
7681 MH_SEND_VoteEvent(NET_VE_INPROGRESS
, gVoteCommand
);
7684 gVoteInProgress
:= True;
7685 gVotePassed
:= False;
7686 gVoteTimer
:= gTime
+ gVoteTimeout
* 1000;
7689 gVoteCommand
:= Command
;
7691 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
7692 Need
:= Floor((NetClientCount
+1)/2.0)+1
7694 Need
:= Floor(NetClientCount
/2.0)+1;
7695 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_STARTED
], [Initiator
, Command
, Need
]), True);
7696 MH_SEND_VoteEvent(NET_VE_STARTED
, Initiator
, Command
, Need
);
7699 procedure g_Game_CheckVote
;
7703 if gGameSettings
.GameType
<> GT_SERVER
then Exit
;
7704 if not gVoteInProgress
then Exit
;
7706 if (gTime
>= gVoteTimer
) then
7708 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
7709 Need
:= Floor((NetClientCount
+1)/2.0) + 1
7711 Need
:= Floor(NetClientCount
/2.0) + 1;
7712 if gVoteCount
>= Need
then
7714 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_PASSED
], [gVoteCommand
]), True);
7715 MH_SEND_VoteEvent(NET_VE_PASSED
, gVoteCommand
);
7716 gVotePassed
:= True;
7717 gVoteCmdTimer
:= gTime
+ 5000;
7721 g_Console_Add(_lc
[I_MESSAGE_VOTE_FAILED
], True);
7722 MH_SEND_VoteEvent(NET_VE_FAILED
);
7724 if NetClients
<> nil then
7725 for I
:= Low(NetClients
) to High(NetClients
) do
7726 if NetClients
[i
].Used
then
7727 NetClients
[i
].Voted
:= False;
7728 gVoteInProgress
:= False;
7734 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
7735 Need
:= Floor((NetClientCount
+1)/2.0) + 1
7737 Need
:= Floor(NetClientCount
/2.0) + 1;
7738 if gVoteCount
>= Need
then
7740 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_PASSED
], [gVoteCommand
]), True);
7741 MH_SEND_VoteEvent(NET_VE_PASSED
, gVoteCommand
);
7742 gVoteInProgress
:= False;
7743 gVotePassed
:= True;
7744 gVoteCmdTimer
:= gTime
+ 5000;
7747 if NetClients
<> nil then
7748 for I
:= Low(NetClients
) to High(NetClients
) do
7749 if NetClients
[i
].Used
then
7750 NetClients
[i
].Voted
:= False;
7755 procedure g_Game_LoadMapList(FileName
: string);
7763 if not FileExists(FileName
) then Exit
;
7765 AssignFile(ListFile
, FileName
);
7767 while not EOF(ListFile
) do
7769 ReadLn(ListFile
, s
);
7772 if s
= '' then Continue
;
7774 SetLength(MapList
, Length(MapList
)+1);
7775 MapList
[High(MapList
)] := s
;
7777 CloseFile(ListFile
);
7780 procedure g_Game_SetDebugMode();
7783 // ×èòû (äàæå â ñâîåé èãðå):
7787 procedure g_Game_SetLoadingText(Text: String; Max
: Integer; reWrite
: Boolean);
7791 if Length(LoadingStat
.Msgs
) = 0 then
7797 begin // Ïåðåõîäèì íà ñëåäóþùóþ ñòðîêó èëè ñêðîëëèðóåì:
7798 if NextMsg
= Length(Msgs
) then
7800 for i
:= 0 to High(Msgs
)-1 do
7801 Msgs
[i
] := Msgs
[i
+1];
7809 Msgs
[NextMsg
-1] := Text;
7813 PBarWasHere
:= false;
7816 g_ActiveWindow
:= nil;
7818 ProcessLoading(true);
7821 procedure g_Game_StepLoading(Value
: Integer = -1);
7832 if (ShowCount
> LOADING_SHOW_STEP
) or (Value
> -1) then
7840 procedure g_Game_ClearLoading();
7849 len
:= ((gScreenHeight
div 3)*2 - 50) div LOADING_INTERLINE
;
7850 if len
< 1 then len
:= 1;
7851 SetLength(Msgs
, len
);
7852 for len
:= Low(Msgs
) to High(Msgs
) do
7855 PBarWasHere
:= false;
7859 procedure Parse_Params(var pars
: TParamStrValues
);
7866 while i
<= ParamCount
do
7869 if (s
[1] = '-') and (Length(s
) > 1) then
7871 if (s
[2] = '-') and (Length(s
) > 2) then
7872 begin // Îäèíî÷íûé ïàðàìåòð
7873 SetLength(pars
, Length(pars
) + 1);
7874 with pars
[High(pars
)] do
7876 Name
:= LowerCase(s
);
7881 if (i
< ParamCount
) then
7882 begin // Ïàðàìåòð ñî çíà÷åíèåì
7884 SetLength(pars
, Length(pars
) + 1);
7885 with pars
[High(pars
)] do
7887 Name
:= LowerCase(s
);
7888 Value
:= LowerCase(ParamStr(i
));
7897 function Find_Param_Value(var pars
: TParamStrValues
; aName
: String): String;
7902 for i
:= 0 to High(pars
) do
7903 if pars
[i
].Name
= aName
then
7905 Result
:= pars
[i
].Value
;
7910 procedure g_Game_Process_Params();
7912 pars
: TParamStrValues
;
7915 LimT
, LimS
: Integer;
7926 s
:= Find_Param_Value(pars
, '--debug');
7929 g_Game_SetDebugMode();
7930 s
:= Find_Param_Value(pars
, '--netdump');
7935 // Connect when game loads
7936 ip
:= Find_Param_Value(pars
, '-connect');
7940 s
:= Find_Param_Value(pars
, '-port');
7941 if (s
= '') or not TryStrToInt(s
, Port
) then
7944 s
:= Find_Param_Value(pars
, '-pw');
7946 g_Game_StartClient(ip
, Port
, s
);
7950 s
:= LowerCase(Find_Param_Value(pars
, '-dbg-mainwad'));
7953 gDefaultMegawadStart
:= s
;
7956 if (Find_Param_Value(pars
, '--dbg-mainwad-restore') <> '') or
7957 (Find_Param_Value(pars
, '--dbg-mainwad-default') <> '') then
7959 gDefaultMegawadStart
:= DF_Default_Megawad_Start
;
7962 // Start map when game loads:
7963 map
:= LowerCase(Find_Param_Value(pars
, '-map'));
7964 if isWadPath(map
) then
7967 s
:= Find_Param_Value(pars
, '-gm');
7968 GMode
:= g_Game_TextToMode(s
);
7969 if GMode
= GM_NONE
then GMode
:= GM_DM
;
7970 if GMode
= GM_SINGLE
then GMode
:= GM_COOP
;
7973 s
:= Find_Param_Value(pars
, '-limt');
7974 if (s
= '') or (not TryStrToInt(s
, LimT
)) then
7980 s
:= Find_Param_Value(pars
, '-lims');
7981 if (s
= '') or (not TryStrToInt(s
, LimS
)) then
7987 s
:= Find_Param_Value(pars
, '-lives');
7988 if (s
= '') or (not TryStrToInt(s
, Lives
)) then
7994 s
:= Find_Param_Value(pars
, '-opt');
7996 Opt
:= GAME_OPTION_ALLOWEXIT
or GAME_OPTION_BOTVSPLAYER
or
7997 GAME_OPTION_BOTVSMONSTER
or GAME_OPTION_DMKEYS
7999 Opt
:= StrToIntDef(s
, 0);
8002 s
:= Find_Param_Value(pars
, '--close');
8006 // Override map to test:
8007 s
:= LowerCase(Find_Param_Value(pars
, '-testmap'));
8010 if e_IsValidResourceName(s
) then
8011 e_FindResource(AllMapDirs
, s
);
8012 gTestMap
:= ExpandFileName(s
);
8015 // Delete test map after play:
8016 s
:= Find_Param_Value(pars
, '--testdelete');
8019 //gMapToDelete := MapsDir + map;
8020 e_WriteLog('"--testdelete" is deprecated, use --tempdelete.', TMsgType
.Fatal
);
8024 // Delete temporary WAD after play:
8025 s
:= Find_Param_Value(pars
, '--tempdelete');
8026 if (s
<> '') and (gTestMap
<> '') then
8028 gMapToDelete
:= gTestMap
;
8029 gTempDelete
:= True;
8032 // Number of players:
8033 s
:= Find_Param_Value(pars
, '-pl');
8035 n
:= DEFAULT_PLAYERS
8037 n
:= StrToIntDef(s
, DEFAULT_PLAYERS
);
8040 s
:= Find_Param_Value(pars
, '-port');
8041 if (s
= '') or not TryStrToInt(s
, Port
) then
8042 g_Game_StartCustom(map
, GMode
, LimT
, LimS
, Lives
, Opt
, n
)
8044 g_Game_StartServer(map
, GMode
, LimT
, LimS
, Lives
, Opt
, n
, 0, Port
);
8047 // Execute script when game loads:
8048 s
:= Find_Param_Value(pars
, '-exec');
8051 // if not isWadPath(s) then
8052 // s := GameDir + '/' + s;
8057 if IOResult
<> 0 then
8059 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], ['Failed to read file: ' + s
]), TMsgType
.Warning
);
8060 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_READ
], [s
]));
8064 e_WriteLog('Executing script: ' + s
, TMsgType
.Notify
);
8065 g_Console_Add(Format(_lc
[I_CONSOLE_EXEC
], [s
]));
8070 if IOResult
<> 0 then
8072 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], ['Failed to read file: ' + s
]), TMsgType
.Warning
);
8073 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_READ
], [s
]));
8077 if Pos('#', s
) <> 1 then // script comment
8078 g_Console_Process(s
, True);
8089 conRegVar('pf_draw_frame', @g_profile_frame_draw
, 'draw frame rendering profiles', 'render profiles');
8090 //conRegVar('pf_update_frame', @g_profile_frame_update, 'draw frame updating profiles', 'update profiles');
8091 conRegVar('pf_coldet', @g_profile_collision
, 'draw collision detection profiles', 'coldet profiles');
8092 conRegVar('pf_los', @g_profile_los
, 'draw monster LOS profiles', 'monster LOS profiles');
8094 conRegVar('r_sq_draw', @gdbg_map_use_accel_render
, 'accelerated spatial queries in rendering', 'accelerated rendering');
8095 conRegVar('cd_sq_enabled', @gdbg_map_use_accel_coldet
, 'accelerated spatial queries in map coldet', 'accelerated map coldet');
8096 conRegVar('mon_sq_enabled', @gmon_debug_use_sqaccel
, 'accelerated spatial queries for monsters', 'accelerated monster coldet');
8097 conRegVar('wtrace_sq_enabled', @gwep_debug_fast_trace
, 'accelerated spatial queries for weapon hitscan trace', 'accelerated weapon hitscan');
8099 conRegVar('pr_enabled', @gpart_dbg_enabled
, 'enable/disable particles', 'particles');
8100 conRegVar('pr_phys_enabled', @gpart_dbg_phys_enabled
, 'enable/disable particle physics', 'particle physics');
8102 conRegVar('los_enabled', @gmon_dbg_los_enabled
, 'enable/disable monster LOS calculations', 'monster LOS', true);
8103 conRegVar('mon_think', @gmon_debug_think
, 'enable/disable monster thinking', 'monster thinking', true);
8105 {$IFDEF ENABLE_HOLMES}
8106 conRegVar('dbg_holmes', @g_holmes_enabled
, 'enable/disable Holmes', 'Holmes', true);
8109 conRegVar('dbg_ignore_level_bounds', @g_dbg_ignore_bounds
, 'ignore level bounds', '', false);
8111 conRegVar('r_scale', @g_dbg_scale
, 0.01, 100.0, 'render scale', '', false);
8112 conRegVar('r_resolution_scale', @r_pixel_scale
, 0.01, 100.0, 'upscale factor', '', false);
8114 conRegVar('light_enabled', @gwin_k8_enable_light_experiments
, 'enable/disable dynamic lighting', 'lighting');
8115 conRegVar('light_player_halo', @g_playerLight
, 'enable/disable player halo', 'player light halo');
8117 conRegVar('r_smallmap_align_h', @r_smallmap_h
, 'halign: 0: left; 1: center; 2: right', 'horizontal aligning of small maps');
8118 conRegVar('r_smallmap_align_v', @r_smallmap_v
, 'valign: 0: top; 1: center; 2: bottom', 'vertial aligning of small maps');
8120 conRegVar('r_showfps', @gShowFPS
, 'draw fps counter', 'draw fps counter');
8121 conRegVar('r_showtime', @gShowTime
, 'show game time', 'show game time');
8122 conRegVar('r_showping', @gShowPing
, 'show ping', 'show ping');
8123 conRegVar('r_showscore', @gShowGoals
, 'show score', 'show score');
8124 conRegVar('r_showkillmsg', @gShowKillMsg
, 'show kill log', 'show kill log');
8125 conRegVar('r_showlives', @gShowLives
, 'show lives', 'show lives');
8126 conRegVar('r_showspect', @gSpectHUD
, 'show spectator hud', 'show spectator hud');
8127 conRegVar('r_showstat', @gShowStat
, 'show stats', 'show stats');