1 (* Copyright (C) Doom 2D: Forever Developers
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, version 3 of the License ONLY.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 {$INCLUDE ../shared/a_modes.inc}
23 g_basic
, g_player
, e_graphics
, g_res_downloader
,
24 g_sound
, g_gui
, utils
, md5
, mempool
, xprofiler
,
28 TGameSettings
= record
35 ItemRespawnTime
: Word;
36 RulezTimeMultiplier
: Word;
47 TDelayedEvent
= record
56 Sound
: TPlayableSound
;
57 Tags
: Array of String;
61 TPlayerSettings
= record
66 // ones below are sent only to the server
68 WeaponPreferences
: Array[WP_FIRST
..WP_LAST
+1] of Byte;
85 function g_Game_IsNet(): Boolean;
86 function g_Game_IsServer(): Boolean;
87 function g_Game_IsClient(): Boolean;
88 procedure g_Game_Init();
89 procedure g_Game_Free (freeTextures
: Boolean=true);
90 procedure g_Game_LoadData();
91 procedure g_Game_FreeData();
92 procedure g_Game_Update();
93 procedure g_Game_PreUpdate();
94 procedure g_Game_Draw();
95 procedure g_Game_Quit();
96 procedure g_Game_SetupScreenSize();
97 procedure g_Game_ChangeResolution(newWidth
, newHeight
: Word; nowFull
, nowMax
: Boolean);
98 function g_Game_ModeToText(Mode
: Byte): string;
99 function g_Game_TextToMode(Mode
: string): Byte;
100 procedure g_Game_ExecuteEvent(Name
: String);
101 function g_Game_DelayEvent(DEType
: Byte; Time
: LongWord; Num
: Integer = 0; Str
: String = ''): Integer;
102 procedure g_Game_AddPlayer(Team
: Byte = TEAM_NONE
);
103 procedure g_Game_RemovePlayer();
104 procedure g_Game_Spectate();
105 procedure g_Game_SpectateCenterView();
106 procedure g_Game_StartSingle(Map
: String; TwoPlayers
: Boolean; nPlayers
: Byte);
107 procedure g_Game_StartCustom(Map
: String; GameMode
: Byte; TimeLimit
, ScoreLimit
: Word; MaxLives
: Byte; Options
: LongWord; nPlayers
: Byte);
108 procedure g_Game_StartServer(Map
: String; GameMode
: Byte; TimeLimit
, ScoreLimit
: Word; MaxLives
: Byte; Options
: LongWord; nPlayers
: Byte; IPAddr
: LongWord; Port
: Word);
109 procedure g_Game_StartClient(Addr
: String; Port
: Word; PW
: String);
110 procedure g_Game_Restart();
111 procedure g_Game_RestartLevel();
112 procedure g_Game_RestartRound(NoMapRestart
: Boolean = False);
113 function g_Game_ClientWAD (NewWAD
: String; const WHash
: TMD5Digest
): AnsiString;
114 function g_Game_StartMap(asMegawad
: Boolean; Map
: String; Force
: Boolean = False; const oldMapPath
: AnsiString=''): Boolean;
115 procedure g_Game_ChangeMap(const MapPath
: String);
116 procedure g_Game_ExitLevel(const Map
: AnsiString);
117 function g_Game_GetFirstMap(WAD
: String): String;
118 function g_Game_GetNextMap(): String;
119 procedure g_Game_NextLevel();
120 procedure g_Game_Pause(Enable
: Boolean);
121 procedure g_Game_HolmesPause(Enable
: Boolean);
122 procedure g_Game_InGameMenu(Show
: Boolean);
123 function g_Game_IsWatchedPlayer(UID
: Word): Boolean;
124 function g_Game_IsWatchedTeam(Team
: Byte): Boolean;
125 procedure g_Game_Message(Msg
: String; Time
: Word);
126 procedure g_Game_LoadMapList(FileName
: String);
127 procedure g_Game_PauseAllSounds(Enable
: Boolean);
128 procedure g_Game_StopAllSounds(all
: Boolean);
129 procedure g_Game_UpdateTriggerSounds();
130 function g_Game_GetMegaWADInfo(WAD
: String): TMegaWADInfo
;
131 procedure g_Game_ChatSound(Text: String; Taunt
: Boolean = True);
132 procedure g_Game_Announce_GoodShot(SpawnerUID
: Word);
133 procedure g_Game_Announce_KillCombo(Param
: Integer);
134 procedure g_Game_Announce_BodyKill(SpawnerUID
: Word);
135 procedure g_Game_Effect_Bubbles(fX
, fY
: Integer; count
: Word; devX
, devY
: Byte; Silent
: Boolean = False);
136 procedure g_Game_StartVote(Command
, Initiator
: string);
137 procedure g_Game_CheckVote
;
138 procedure g_TakeScreenShot(Filename
: string = '');
139 procedure g_FatalError(Text: String);
140 procedure g_SimpleError(Text: String);
141 function g_Game_IsTestMap(): Boolean;
142 procedure g_Game_DeleteTestMap();
143 procedure GameCVars(P
: SSArray
);
144 procedure PlayerSettingsCVars(P
: SSArray
);
145 procedure SystemCommands(P
: SSArray
);
146 procedure GameCommands(P
: SSArray
);
147 procedure GameCheats(P
: SSArray
);
148 procedure DebugCommands(P
: SSArray
);
149 procedure g_Game_Process_Params
;
150 procedure g_Game_SetLoadingText(Text: String; Max
: Integer; reWrite
: Boolean);
151 procedure g_Game_StepLoading(Value
: Integer = -1);
152 procedure g_Game_ClearLoading();
153 procedure g_Game_SetDebugMode();
154 procedure DrawLoadingStat();
155 procedure DrawMenuBackground(tex
: AnsiString);
157 { procedure SetWinPause(Enable: Boolean); }
162 LOADING_SHOW_STEP
= 100;
163 LOADING_INTERLINE
= 20;
178 MESSAGE_DIKEY
= WM_USER
+ 1;
183 EXIT_ENDLEVELSINGLE
= 4;
184 EXIT_ENDLEVELCUSTOM
= 5;
186 GAME_OPTION_RESERVED
= 1;
187 GAME_OPTION_TEAMDAMAGE
= 2;
188 GAME_OPTION_ALLOWEXIT
= 4;
189 GAME_OPTION_WEAPONSTAY
= 8;
190 GAME_OPTION_MONSTERS
= 16;
191 GAME_OPTION_BOTVSPLAYER
= 32;
192 GAME_OPTION_BOTVSMONSTER
= 64;
193 GAME_OPTION_DMKEYS
= 128;
194 GAME_OPTION_TEAMHITTRACE
= 256;
195 GAME_OPTION_TEAMHITPROJECTILE
= 512;
196 GAME_OPTION_TEAMABSORBDAMAGE
= 1024;
197 GAME_OPTION_ALLOWDROPFLAG
= 2048;
198 GAME_OPTION_THROWFLAG
= 4096;
199 GAME_OPTION_RULEZRANDOM
= 8192;
204 STATE_INTERCUSTOM
= 3;
205 STATE_INTERSINGLE
= 4;
211 LMS_RESPAWN_NONE
= 0;
212 LMS_RESPAWN_WARMUP
= 1;
213 LMS_RESPAWN_FINAL
= 2;
230 CONFIG_FILENAME
= 'Doom2DF.cfg';
232 TEST_MAP_NAME
= '$$$_TEST_$$$';
234 STD_PLAYER_MODEL
= 'Doomer';
242 STATFILE_VERSION
= $03;
246 gGameSettings
: TGameSettings
;
247 gPlayer1Settings
: TPlayerSettings
;
248 gPlayer2Settings
: TPlayerSettings
;
250 gPlayerScreenSize
: TDFPoint
;
251 gPlayer1ScreenCoord
: TDFPoint
;
252 gPlayer2ScreenCoord
: TDFPoint
;
253 gPlayer1
: TPlayer
= nil;
254 gPlayer2
: TPlayer
= nil;
255 gPlayerDrawn
: TPlayer
= nil;
257 gLerpFactor
: Single = 1.0;
258 gSwitchGameMode
: Byte = GM_DM
;
259 gHearPoint1
, gHearPoint2
: THearPoint
;
260 gSoundEffectsDF
: Boolean = False;
261 gSoundTriggerTime
: Word = 0;
262 gAnnouncer
: Integer = ANNOUNCE_NONE
;
263 goodsnd
: array[0..3] of TPlayableSound
;
264 killsnd
: array[0..3] of TPlayableSound
;
265 hahasnd
: array[0..2] of TPlayableSound
;
266 sound_get_flag
: array[0..1] of TPlayableSound
;
267 sound_lost_flag
: array[0..1] of TPlayableSound
;
268 sound_ret_flag
: array[0..1] of TPlayableSound
;
269 sound_cap_flag
: array[0..1] of TPlayableSound
;
270 gBodyKillEvent
: Integer = -1;
271 gDefInterTime
: ShortInt = -1;
272 gInterEndTime
: LongWord = 0;
273 gInterTime
: LongWord = 0;
274 gServInterTime
: Byte = 0;
275 gGameStartTime
: LongWord = 0;
276 gTotalMonsters
: Integer = 0;
277 gPauseMain
: Boolean = false;
278 gPauseHolmes
: Boolean = false;
279 gShowTime
: Boolean = False;
280 gShowFPS
: Boolean = False;
281 gShowScore
: Boolean = True;
282 gShowStat
: Boolean = True;
283 gShowPIDs
: Boolean = False;
284 gShowKillMsg
: Boolean = True;
285 gShowLives
: Boolean = True;
286 gShowPing
: Boolean = False;
287 gShowMap
: Boolean = False;
289 gState
: Byte = STATE_NONE
;
291 sWidth
, sHeight
: Word;
292 gSpectMode
: Byte = SPECT_NONE
;
293 gSpectHUD
: Boolean = True;
294 gSpectKeyPress
: Boolean = False;
295 gSpectX
: Integer = 0;
296 gSpectY
: Integer = 0;
297 gSpectStep
: Byte = 8;
298 gSpectViewTwo
: Boolean = False;
299 gSpectPID1
: Integer = -1;
300 gSpectPID2
: Integer = -1;
301 gSpectAuto
: Boolean = False;
302 gSpectAutoNext
: LongWord;
303 gSpectAutoStepX
: Integer;
304 gSpectAutoStepY
: Integer;
305 gMusic
: TMusic
= nil;
306 gLoadGameMode
: Boolean;
307 gCheats
: Boolean = False;
308 gMapOnce
: Boolean = False;
309 gMapToDelete
: String;
310 gTempDelete
: Boolean = False;
311 gLastMap
: Boolean = False;
314 gResolutionChange
: Boolean = False;
315 gRC_Width
, gRC_Height
: Integer;
316 gRC_FullScreen
, gRC_Maximized
: Boolean;
317 gLanguageChange
: Boolean = False;
318 gDebugMode
: Boolean = False;
319 g_debug_Sounds
: Boolean = False;
320 g_debug_Frames
: Boolean = False;
321 g_debug_WinMsgs
: Boolean = False;
322 g_debug_MonsterOff
: Boolean = False;
323 g_debug_BotAIOff
: Byte = 0;
324 g_debug_HealthBar
: Boolean = False;
325 g_Debug_Player
: Boolean = False;
326 gCoopMonstersKilled
: Word = 0;
327 gCoopSecretsFound
: Word = 0;
328 gCoopTotalMonstersKilled
: Word = 0;
329 gCoopTotalSecretsFound
: Word = 0;
330 gCoopTotalMonsters
: Word = 0;
331 gCoopTotalSecrets
: Word = 0;
332 gStatsOff
: Boolean = False;
333 gStatsPressed
: Boolean = False;
334 gExitByTrigger
: Boolean = False;
335 gNextMap
: String = '';
336 gLMSRespawn
: Byte = LMS_RESPAWN_NONE
;
337 gLMSRespawnTime
: Cardinal = 0;
338 gLMSSoftSpawn
: Boolean = False;
339 gMissionFailed
: Boolean = False;
340 gVoteInProgress
: Boolean = False;
341 gVotePassed
: Boolean = False;
342 gVoteCommand
: string = '';
343 gVoteTimer
: Cardinal = 0;
344 gVoteCmdTimer
: Cardinal = 0;
345 gVoteCount
: Integer = 0;
346 gVoteTimeout
: Cardinal = 30;
347 gVoted
: Boolean = False;
348 gVotesEnabled
: Boolean = True;
349 gEvents
: Array of TGameEvent
;
350 gDelayedEvents
: Array of TDelayedEvent
;
351 gUseChatSounds
: Boolean = True;
352 gChatSounds
: Array of TChatSound
;
353 gWeaponAction
: Array [0..1, WP_FACT
..WP_LACT
] of Boolean; // [player, weapon_action]
354 gSelectWeapon
: Array [0..1, WP_FIRST
..WP_LAST
] of Boolean; // [player, weapon]
355 gInterReadyCount
: Integer = 0;
356 gMaxBots
: Integer = 127;
358 g_dbg_ignore_bounds
: Boolean = false;
359 r_smallmap_h
: Integer = 0; // 0: left; 1: center; 2: right
360 r_smallmap_v
: Integer = 2; // 0: top; 1: center; 2: bottom
362 // move button values:
363 // bits 0-1: l/r state:
364 // 0: neither left, nor right pressed
367 // bits 4-5: l/r state when strafe was pressed
368 P1MoveButton
: Byte = 0;
369 P2MoveButton
: Byte = 0;
371 g_profile_frame_update
: Boolean = false;
372 g_profile_frame_draw
: Boolean = false;
373 g_profile_collision
: Boolean = false;
374 g_profile_los
: Boolean = false;
375 g_profile_history_size
: Integer = 1000;
377 g_rlayer_back
: Boolean = true;
378 g_rlayer_step
: Boolean = true;
379 g_rlayer_wall
: Boolean = true;
380 g_rlayer_door
: Boolean = true;
381 g_rlayer_acid1
: Boolean = true;
382 g_rlayer_acid2
: Boolean = true;
383 g_rlayer_water
: Boolean = true;
384 g_rlayer_fore
: Boolean = true;
387 procedure g_ResetDynlights ();
388 procedure g_AddDynLight (x
, y
, radius
: Integer; r
, g
, b
, a
: Single);
389 procedure g_DynLightExplosion (x
, y
, radius
: Integer; r
, g
, b
: Single);
391 function conIsCheatsEnabled (): Boolean; inline;
392 function gPause (): Boolean; inline;
398 {$INCLUDE ../nogl/noGLuses.inc}
399 {$IFDEF ENABLE_HOLMES}
402 e_texture
, e_res
, g_textures
, g_window
, g_menu
,
403 e_input
, e_log
, g_console
, g_items
, g_map
, g_panel
,
404 g_playermodel
, g_gfx
, g_options
, Math
,
405 g_triggers
, g_monsters
, e_sound
, CONFIG
,
406 g_language
, g_net
, g_main
, g_phys
,
407 ENet
, e_msg
, g_netmsg
, g_netmaster
,
408 sfs
, wadreader
, g_system
;
412 hasPBarGfx
: Boolean = false;
415 // ////////////////////////////////////////////////////////////////////////// //
416 function gPause (): Boolean; inline; begin result
:= gPauseMain
or gPauseHolmes
; end;
419 // ////////////////////////////////////////////////////////////////////////// //
420 function conIsCheatsEnabled (): Boolean; inline;
423 if g_Game_IsNet
then exit
;
424 if not gDebugMode
then
426 //if not gCheats then exit;
427 if not (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
]) then exit
;
428 if not (gGameSettings
.GameMode
in [GM_COOP
, GM_SINGLE
]) then exit
;
434 // ////////////////////////////////////////////////////////////////////////// //
436 profileFrameDraw
: TProfiler
= nil;
439 // ////////////////////////////////////////////////////////////////////////// //
442 x
, y
, radius
: Integer;
445 exploRadius
: Integer;
449 g_dynLights
: array of TDynLight
= nil;
450 g_dynLightCount
: Integer = 0;
451 g_playerLight
: Boolean = false;
453 procedure g_ResetDynlights ();
457 if not gwin_has_stencil
then begin g_dynLightCount
:= 0; exit
; end;
459 for idx
:= 0 to g_dynLightCount
-1 do
461 if g_dynLights
[idx
].exploCount
= -666 then
468 Inc(g_dynLights
[idx
].exploCount
);
469 if (g_dynLights
[idx
].exploCount
< 10) then
471 g_dynLights
[idx
].radius
:= g_dynLights
[idx
].exploRadius
+g_dynLights
[idx
].exploCount
*8;
472 g_dynLights
[idx
].a
:= 0.4+g_dynLights
[idx
].exploCount
/10;
473 if (g_dynLights
[idx
].a
> 0.8) then g_dynLights
[idx
].a
:= 0.8;
474 if lnum
<> idx
then g_dynLights
[lnum
] := g_dynLights
[idx
];
479 g_dynLightCount
:= lnum
;
482 procedure g_AddDynLight (x
, y
, radius
: Integer; r
, g
, b
, a
: Single);
484 if not gwin_has_stencil
then exit
;
485 if g_dynLightCount
= length(g_dynLights
) then SetLength(g_dynLights
, g_dynLightCount
+1024);
486 g_dynLights
[g_dynLightCount
].x
:= x
;
487 g_dynLights
[g_dynLightCount
].y
:= y
;
488 g_dynLights
[g_dynLightCount
].radius
:= radius
;
489 g_dynLights
[g_dynLightCount
].r
:= r
;
490 g_dynLights
[g_dynLightCount
].g
:= g
;
491 g_dynLights
[g_dynLightCount
].b
:= b
;
492 g_dynLights
[g_dynLightCount
].a
:= a
;
493 g_dynLights
[g_dynLightCount
].exploCount
:= -666;
494 Inc(g_dynLightCount
);
497 procedure g_DynLightExplosion (x
, y
, radius
: Integer; r
, g
, b
: Single);
499 if not gwin_has_stencil
then exit
;
500 if g_dynLightCount
= length(g_dynLights
) then SetLength(g_dynLights
, g_dynLightCount
+1024);
501 g_dynLights
[g_dynLightCount
].x
:= x
;
502 g_dynLights
[g_dynLightCount
].y
:= y
;
503 g_dynLights
[g_dynLightCount
].radius
:= 0;
504 g_dynLights
[g_dynLightCount
].exploRadius
:= radius
;
505 g_dynLights
[g_dynLightCount
].r
:= r
;
506 g_dynLights
[g_dynLightCount
].g
:= g
;
507 g_dynLights
[g_dynLightCount
].b
:= b
;
508 g_dynLights
[g_dynLightCount
].a
:= 0;
509 g_dynLights
[g_dynLightCount
].exploCount
:= 0;
510 Inc(g_dynLightCount
);
514 // ////////////////////////////////////////////////////////////////////////// //
515 function calcProfilesHeight (prof
: TProfiler
): Integer;
518 if (prof
= nil) then exit
;
519 if (length(prof
.bars
) = 0) then exit
;
520 result
:= length(prof
.bars
)*(16+2);
524 function drawProfiles (x
, y
: Integer; prof
: TProfiler
): Integer;
531 if (prof
= nil) then exit
;
533 if (length(prof
.bars
) = 0) then exit
;
535 hgt
:= calcProfilesHeight(prof
);
536 if (x
< 0) then x
:= gScreenWidth
-(wdt
-1)+x
;
537 if (y
< 0) then y
:= gScreenHeight
-(hgt
-1)+y
;
539 //e_DrawFillQuad(x, y, x+wdt-1, y+hgt-1, 255, 255, 255, 200, B_BLEND);
540 //e_DrawFillQuad(x, y, x+wdt-1, y+hgt-1, 20, 20, 20, 0, B_NONE);
541 e_DarkenQuadWH(x
, y
, wdt
, hgt
, 150);
544 for ii
:= 0 to High(prof
.bars
) do
546 e_TextureFontPrintEx(x
+2+4*prof
.bars
[ii
].level
, yy
, Format('%s: %d', [prof
.bars
[ii
].name
, prof
.bars
[ii
].value
]), gStdFont
, 255, 255, 0, 1, false);
553 // ////////////////////////////////////////////////////////////////////////// //
555 TEndCustomGameStat
= record
556 PlayerStat
: TPlayerStatArray
;
560 Map
, MapName
: String;
563 TEndSingleGameStat
= record
564 PlayerStat
: Array [0..1] of record
570 TotalSecrets
: Integer;
573 TLoadingStat
= record
577 Msgs
: Array of String;
579 PBarWasHere
: Boolean; // did we draw a progress bar for this message?
582 TParamStrValue
= record
587 TParamStrValues
= Array of TParamStrValue
;
590 INTER_ACTION_TEXT
= 1;
591 INTER_ACTION_PIC
= 2;
592 INTER_ACTION_MUSIC
= 3;
596 FPSCounter
, UPSCounter
: Word;
597 FPSTime
, UPSTime
: LongWord;
598 DataLoaded
: Boolean = False;
599 IsDrawStat
: Boolean = False;
600 CustomStat
: TEndCustomGameStat
;
601 SingleStat
: TEndSingleGameStat
;
602 LoadingStat
: TLoadingStat
;
603 EndingGameCounter
: Byte = 0;
606 MessageLineLength
: Integer = 80;
607 MapList
: SSArray
= nil;
608 MapIndex
: Integer = -1;
609 InterReadyTime
: Integer = -1;
610 StatShotDone
: Boolean = False;
611 StatFilename
: string = ''; // used by stat screenshot to save with the same name as the csv
612 StatDate
: string = '';
618 text: Array of ShortString;
619 anim
: Array of ShortString;
620 pic
: Array of ShortString;
621 mus
: Array of ShortString;
623 triggers
: Array of record
625 actions
: Array of record
626 action
, p1
, p2
: Integer;
629 cur_trigger
: Integer;
642 function Compare(a
, b
: TPlayerStat
): Integer;
644 if a
.Spectator
then Result
:= 1
645 else if b
.Spectator
then Result
:= -1
646 else if a
.Assists
< b
.Assists
then Result
:= 1
647 else if a
.Assists
> b
.Assists
then Result
:= -1
648 else if a
.Frags
< b
.Frags
then Result
:= 1
649 else if a
.Frags
> b
.Frags
then Result
:= -1
650 else if a
.Deaths
< b
.Deaths
then Result
:= -1
651 else if a
.Deaths
> b
.Deaths
then Result
:= 1
652 else if a
.Kills
< b
.Kills
then Result
:= -1
656 procedure SortGameStat(var stat
: TPlayerStatArray
);
661 if stat
= nil then Exit
;
663 for I
:= High(stat
) downto Low(stat
) do
664 for J
:= Low(stat
) to High(stat
) - 1 do
665 if Compare(stat
[J
], stat
[J
+ 1]) = 1 then
668 stat
[J
] := stat
[J
+ 1];
673 // saves a shitty CSV containing the game stats passed to it
674 procedure SaveGameStat(Stat
: TEndCustomGameStat
; Path
: string);
677 dir
, fname
, map
, mode
, etime
: String;
681 dir
:= e_GetWriteableDir(StatsDirs
);
682 // stats are placed in stats/yy/mm/dd/*.csv
683 fname
:= e_CatPath(dir
, Path
);
684 ForceDirectories(fname
); // ensure yy/mm/dd exists within the stats dir
685 fname
:= e_CatPath(fname
, StatFilename
+ '.csv');
686 AssignFile(s
, fname
);
688 SetTextCodePage(s
, CP_UTF8
);
690 // line 1: stats ver, datetime, server name, map name, game mode, time limit, score limit, dmflags, game time, num players
691 if g_Game_IsNet
then fname
:= NetServerName
else fname
:= '';
692 map
:= g_ExtractWadNameNoPath(gMapInfo
.Map
) + ':/' + g_ExtractFileName(gMapInfo
.Map
);
693 mode
:= g_Game_ModeToText(Stat
.GameMode
);
694 etime
:= Format('%d:%.2d:%.2d', [
695 Stat
.GameTime
div 1000 div 3600,
696 (Stat
.GameTime
div 1000 div 60) mod 60,
697 Stat
.GameTime
div 1000 mod 60
699 WriteLn(s
, 'stats_ver,datetime,server,map,mode,timelimit,scorelimit,dmflags,time,num_players');
700 WriteLn(s
, Format('%d,%s,%s,%s,%s,%u,%u,%u,%s,%d', [
706 gGameSettings
.TimeLimit
,
707 gGameSettings
.ScoreLimit
,
708 gGameSettings
.Options
,
710 Length(Stat
.PlayerStat
)
712 // line 2: game specific shit
713 // if it's a team game: red score, blue score
714 // if it's a coop game: monsters killed, monsters total, secrets found, secrets total
716 if Stat
.GameMode
in [GM_TDM
, GM_CTF
] then
718 Format('red_score,blue_score' + LineEnding
+ '%d,%d', [Stat
.TeamStat
[TEAM_RED
].Score
, Stat
.TeamStat
[TEAM_BLUE
].Score
]))
719 else if Stat
.GameMode
in [GM_COOP
, GM_SINGLE
] then
721 Format('mon_killed,mon_total,secrets_found,secrets_total' + LineEnding
+ '%d,%d,%d,%d',[gCoopMonstersKilled
, gTotalMonsters
, gCoopSecretsFound
, gSecretsCount
]));
722 // lines 3-...: team, player name, frags, deaths
723 WriteLn(s
, 'team,name,frags,assists,deaths');
724 for I
:= Low(Stat
.PlayerStat
) to High(Stat
.PlayerStat
) do
725 with Stat
.PlayerStat
[I
] do
726 WriteLn(s
, Format('%d,%s,%d,%d', [Team
, dquoteStr(Name
), Frags
, Assists
, Deaths
]));
728 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_WRITE
], [fname
]));
731 g_Console_Add('could not create gamestats file "' + fname
+ '"');
736 procedure ClearDebugCvars();
738 g_debug_Sounds
:= False;
739 g_debug_Frames
:= False;
740 g_debug_WinMsgs
:= False;
741 g_debug_MonsterOff
:= False;
742 g_debug_BotAIOff
:= 0;
743 g_debug_HealthBar
:= False;
744 g_Debug_Player
:= False;
747 function g_Game_ModeToText(Mode
: Byte): string;
751 GM_DM
: Result
:= _lc
[I_MENU_GAME_TYPE_DM
];
752 GM_TDM
: Result
:= _lc
[I_MENU_GAME_TYPE_TDM
];
753 GM_CTF
: Result
:= _lc
[I_MENU_GAME_TYPE_CTF
];
754 GM_COOP
: Result
:= _lc
[I_MENU_GAME_TYPE_COOP
];
755 GM_SINGLE
: Result
:= _lc
[I_MENU_GAME_TYPE_SINGLE
];
759 function g_Game_TextToMode(Mode
: string): Byte;
762 Mode
:= UpperCase(Mode
);
763 if Mode
= _lc
[I_MENU_GAME_TYPE_DM
] then
768 if Mode
= _lc
[I_MENU_GAME_TYPE_TDM
] then
773 if Mode
= _lc
[I_MENU_GAME_TYPE_CTF
] then
778 if Mode
= _lc
[I_MENU_GAME_TYPE_COOP
] then
783 if Mode
= _lc
[I_MENU_GAME_TYPE_SINGLE
] then
790 function g_Game_IsNet(): Boolean;
792 Result
:= (gGameSettings
.GameType
in [GT_SERVER
, GT_CLIENT
]);
795 function g_Game_IsServer(): Boolean;
797 Result
:= (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
, GT_SERVER
]);
800 function g_Game_IsClient(): Boolean;
802 Result
:= (gGameSettings
.GameType
= GT_CLIENT
);
805 function g_Game_GetMegaWADInfo(WAD
: String): TMegaWADInfo
;
812 Result
.name
:= ExtractFileName(WAD
);
813 Result
.description
:= '';
816 w
:= TWADFile
.Create();
819 if not w
.GetResource('INTERSCRIPT', p
, len
) then
825 cfg
:= TConfig
.CreateMem(p
, len
);
826 Result
.name
:= cfg
.ReadStr('megawad', 'name', ExtractFileName(WAD
));
827 Result
.description
:= cfg
.ReadStr('megawad', 'description', '');
828 Result
.author
:= cfg
.ReadStr('megawad', 'author', '');
829 Result
.pic
:= cfg
.ReadStr('megawad', 'pic', '');
835 procedure g_Game_FreeWAD();
839 for a
:= 0 to High(MegaWAD
.res
.pic
) do
840 if MegaWAD
.res
.pic
[a
] <> '' then
841 g_Texture_Delete(MegaWAD
.res
.pic
[a
]);
843 for a
:= 0 to High(MegaWAD
.res
.mus
) do
844 if MegaWAD
.res
.mus
[a
] <> '' then
845 g_Sound_Delete(MegaWAD
.res
.mus
[a
]);
847 MegaWAD
.res
.pic
:= nil;
848 MegaWAD
.res
.text := nil;
849 MegaWAD
.res
.anim
:= nil;
850 MegaWAD
.res
.mus
:= nil;
851 MegaWAD
.triggers
:= nil;
853 g_Texture_Delete('TEXTURE_endpic');
854 g_Sound_Delete('MUSIC_endmus');
856 ZeroMemory(@MegaWAD
, SizeOf(MegaWAD
));
857 gGameSettings
.WAD
:= '';
860 procedure g_Game_LoadWAD(WAD
: string);
869 gGameSettings
.WAD
:= WAD
;
870 if not (gGameSettings
.GameMode
in [GM_COOP
, GM_SINGLE
]) then
873 MegaWAD
.info
:= g_Game_GetMegaWADInfo(WAD
);
875 w
:= TWADFile
.Create();
878 if not w
.GetResource('INTERSCRIPT', p
, len
) then
884 cfg
:= TConfig
.CreateMem(p
, len
);
889 s := cfg.ReadStr('pic', 'pic'+IntToStr(b), '');
890 if s = '' then Break;
893 SetLength(MegaWAD.res.pic, Length(MegaWAD.res.pic)+1);
894 MegaWAD.res.pic[High(MegaWAD.res.pic)] := s;
896 g_Texture_CreateWADEx(s, s);
902 s := cfg.ReadStr('mus', 'mus'+IntToStr(b), '');
903 if s = '' then Break;
906 SetLength(MegaWAD.res.mus, Length(MegaWAD.res.mus)+1);
907 MegaWAD.res.mus[High(MegaWAD.res.mus)] := s;
909 g_Music_CreateWADEx(s, s);
912 MegaWAD
.endpic
:= cfg
.ReadStr('megawad', 'endpic', '');
913 if MegaWAD
.endpic
<> '' then
915 TEXTUREFILTER
:= GL_LINEAR
;
916 s
:= e_GetResourcePath(WadDirs
, MegaWAD
.endpic
, WAD
);
917 g_Texture_CreateWADEx('TEXTURE_endpic', s
);
918 TEXTUREFILTER
:= GL_NEAREST
;
920 MegaWAD
.endmus
:= cfg
.ReadStr('megawad', 'endmus', 'Standart.wad:D2DMUS\ÊÎÍÅÖ');
921 if MegaWAD
.endmus
<> '' then
923 s
:= e_GetResourcePath(WadDirs
, MegaWAD
.endmus
, WAD
);
924 g_Sound_CreateWADEx('MUSIC_endmus', s
, True);
932 {procedure start_trigger(t: string);
936 function next_trigger(): Boolean;
940 procedure DisableCheats();
946 if gPlayer1
<> nil then gPlayer1
.GodMode
:= False;
947 if gPlayer2
<> nil then gPlayer2
.GodMode
:= False;
948 if gPlayer1
<> nil then gPlayer1
.NoTarget
:= False;
949 if gPlayer2
<> nil then gPlayer2
.NoTarget
:= False;
951 {$IF DEFINED(D2F_DEBUG)}
952 if gPlayer1
<> nil then gPlayer1
.NoTarget
:= True;
953 gAimLine
:= g_dbg_aimline_on
;
957 procedure g_Game_ExecuteEvent(Name
: String);
963 if gEvents
= nil then
965 for a
:= 0 to High(gEvents
) do
966 if gEvents
[a
].Name
= Name
then
968 if gEvents
[a
].Command
<> '' then
969 g_Console_Process(gEvents
[a
].Command
, True);
974 function g_Game_DelayEvent(DEType
: Byte; Time
: LongWord; Num
: Integer = 0; Str
: String = ''): Integer;
979 if gDelayedEvents
<> nil then
980 for a
:= 0 to High(gDelayedEvents
) do
981 if not gDelayedEvents
[a
].Pending
then
988 SetLength(gDelayedEvents
, Length(gDelayedEvents
) + 1);
989 n
:= High(gDelayedEvents
);
991 gDelayedEvents
[n
].Pending
:= True;
992 gDelayedEvents
[n
].DEType
:= DEType
;
993 gDelayedEvents
[n
].DENum
:= Num
;
994 gDelayedEvents
[n
].DEStr
:= Str
;
995 if DEType
= DE_GLOBEVENT
then
996 gDelayedEvents
[n
].Time
:= (sys_GetTicks() {div 1000}) + Time
998 gDelayedEvents
[n
].Time
:= gTime
+ Time
;
1002 procedure EndGame();
1008 if g_Game_IsNet
and g_Game_IsServer
then
1009 MH_SEND_GameEvent(NET_EV_MAPEND
, Byte(gMissionFailed
));
1012 gPauseMain
:= false;
1013 gPauseHolmes
:= false;
1016 g_Game_StopAllSounds(False);
1021 EndingGameCounter
:= 0;
1022 g_ActiveWindow
:= nil;
1024 gLMSRespawn
:= LMS_RESPAWN_NONE
;
1025 gLMSRespawnTime
:= 0;
1028 EXIT_SIMPLE
: // Âûõîä ÷åðåç ìåíþ èëè êîíåö òåñòà
1033 begin // Ýòî áûë òåñò
1037 begin // Âûõîä â ãëàâíîå ìåíþ
1038 gMusic
.SetByName('MUSIC_MENU');
1040 if gState
<> STATE_SLIST
then
1042 g_GUI_ShowWindow('MainMenu');
1043 gState
:= STATE_MENU
;
1046 // Îáíîâëÿåì ñïèñîê ñåðâåðîâ
1047 slReturnPressed
:= True;
1048 if g_Net_Slist_Fetch(slCurrent
) then
1050 if slCurrent
= nil then
1051 slWaitStr
:= _lc
[I_NET_SLIST_NOSERVERS
];
1054 slWaitStr
:= _lc
[I_NET_SLIST_ERROR
];
1055 g_Serverlist_GenerateTable(slCurrent
, slTable
);
1058 g_Game_ExecuteEvent('ongameend');
1062 EXIT_RESTART
: // Íà÷àòü óðîâåíü ñíà÷àëà
1064 if not g_Game_IsClient
then g_Game_Restart();
1067 EXIT_ENDLEVELCUSTOM
: // Çàêîí÷èëñÿ óðîâåíü â Ñâîåé èãðå
1069 // Ñòàòèñòèêà Ñâîåé èãðû:
1070 FileName
:= g_ExtractWadName(gMapInfo
.Map
);
1072 CustomStat
.GameTime
:= gTime
;
1073 CustomStat
.Map
:= ExtractFileName(FileName
)+':'+g_ExtractFileName(gMapInfo
.Map
); //ResName;
1074 CustomStat
.MapName
:= gMapInfo
.Name
;
1075 CustomStat
.GameMode
:= gGameSettings
.GameMode
;
1076 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
1077 CustomStat
.TeamStat
:= gTeamStat
;
1079 CustomStat
.PlayerStat
:= nil;
1081 // Ñòàòèñòèêà èãðîêîâ:
1082 if gPlayers
<> nil then
1084 for a
:= 0 to High(gPlayers
) do
1085 if gPlayers
[a
] <> nil then
1087 SetLength(CustomStat
.PlayerStat
, Length(CustomStat
.PlayerStat
)+1);
1088 with CustomStat
.PlayerStat
[High(CustomStat
.PlayerStat
)] do
1091 Name
:= gPlayers
[a
].Name
;
1092 Frags
:= gPlayers
[a
].Frags
;
1093 Assists
:= gPlayers
[a
].Assists
;
1094 Deaths
:= gPlayers
[a
].Death
;
1095 Kills
:= gPlayers
[a
].Kills
;
1096 Team
:= gPlayers
[a
].Team
;
1097 Color
:= gPlayers
[a
].Model
.Color
;
1098 Spectator
:= gPlayers
[a
].FSpectator
;
1102 SortGameStat(CustomStat
.PlayerStat
);
1104 if (gSaveStats
or gScreenshotStats
) and (Length(CustomStat
.PlayerStat
) > 1) then
1107 if g_Game_IsNet
then StatFilename
:= NetServerName
else StatFilename
:= 'local';
1108 StatDate
:= FormatDateTime('yymmdd_hhnnss', t
);
1109 StatFilename
:= StatFilename
+ '_' + CustomStat
.Map
+ '_' + g_Game_ModeToText(CustomStat
.GameMode
);
1110 StatFilename
:= sanitizeFilename(StatFilename
) + '_' + StatDate
;
1112 SaveGameStat(CustomStat
, FormatDateTime('yyyy"/"mm"/"dd', t
));
1115 StatShotDone
:= False;
1118 g_Game_ExecuteEvent('onmapend');
1119 if not g_Game_IsClient
then g_Player_ResetReady
;
1120 gInterReadyCount
:= 0;
1122 // Çàòóõàþùèé ýêðàí:
1123 EndingGameCounter
:= 255;
1124 gState
:= STATE_FOLD
;
1126 if gDefInterTime
< 0 then
1127 gInterEndTime
:= IfThen((gGameSettings
.GameType
= GT_SERVER
) and (gPlayer1
= nil), 15000, 25000)
1129 gInterEndTime
:= gDefInterTime
* 1000;
1132 EXIT_ENDLEVELSINGLE
: // Çàêîí÷èëñÿ óðîâåíü â Îäèíî÷íîé èãðå
1134 // Ñòàòèñòèêà Îäèíî÷íîé èãðû:
1135 SingleStat
.GameTime
:= gTime
;
1136 SingleStat
.TwoPlayers
:= gPlayer2
<> nil;
1137 SingleStat
.TotalSecrets
:= gSecretsCount
;
1138 // Ñòàòèñòèêà ïåðâîãî èãðîêà:
1139 SingleStat
.PlayerStat
[0].Kills
:= gPlayer1
.MonsterKills
;
1140 SingleStat
.PlayerStat
[0].Secrets
:= gPlayer1
.Secrets
;
1141 // Ñòàòèñòèêà âòîðîãî èãðîêà (åñëè åñòü):
1142 if SingleStat
.TwoPlayers
then
1144 SingleStat
.PlayerStat
[1].Kills
:= gPlayer2
.MonsterKills
;
1145 SingleStat
.PlayerStat
[1].Secrets
:= gPlayer2
.Secrets
;
1148 g_Game_ExecuteEvent('onmapend');
1151 if gNextMap
<> '' then
1153 gMusic
.SetByName('MUSIC_INTERMUS');
1155 gState
:= STATE_INTERSINGLE
;
1158 g_Game_ExecuteEvent('oninter');
1160 else // Áîëüøå íåò êàðò
1162 // Çàòóõàþùèé ýêðàí:
1163 EndingGameCounter
:= 255;
1164 gState
:= STATE_FOLD
;
1169 // Îêîí÷àíèå îáðàáîòàíî:
1170 if gExit
<> EXIT_QUIT
then
1174 procedure drawTime(X
, Y
: Integer); inline;
1176 e_TextureFontPrint(x
, y
,
1177 Format('%d:%.2d:%.2d', [
1178 gTime
div 1000 div 3600,
1179 (gTime
div 1000 div 60) mod 60,
1180 gTime
div 1000 mod 60
1185 procedure DrawStat();
1187 pc
, x
, y
, w
, h
: Integer;
1188 w1
, w2
, w3
, w4
: Integer;
1190 cw
, ch
, r
, g
, b
, rr
, gg
, bb
: Byte;
1193 stat
: TPlayerStatArray
;
1201 pc
:= g_Player_GetCount
;
1202 e_TextureFontGetSize(gStdFont
, cw
, ch
);
1204 w
:= gScreenWidth
-(gScreenWidth
div 5);
1205 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
1208 h
:= 40+ch
*5+(ch
+8)*pc
;
1209 x
:= (gScreenWidth
div 2)-(w
div 2);
1210 y
:= (gScreenHeight
div 2)-(h
div 2);
1212 e_DrawFillQuad(x
, y
, x
+w
-1, y
+h
-1, 64, 64, 64, 32);
1213 e_DrawQuad(x
, y
, x
+w
-1, y
+h
-1, 255, 127, 0);
1215 drawTime(x
+w
-78, y
+8);
1217 wad
:= g_ExtractWadNameNoPath(gMapInfo
.Map
);
1218 map
:= g_ExtractFileName(gMapInfo
.Map
);
1219 mapstr
:= wad
+ ':\' + map
+ ' - ' + gMapInfo
.Name
;
1221 case gGameSettings
.GameMode
of
1224 if gGameSettings
.MaxLives
= 0 then
1225 s1
:= _lc
[I_GAME_DM
]
1227 s1
:= _lc
[I_GAME_LMS
];
1228 s2
:= Format(_lc
[I_GAME_FRAG_LIMIT
], [gGameSettings
.ScoreLimit
]);
1229 s3
:= Format(_lc
[I_GAME_TIME_LIMIT
], [gGameSettings
.TimeLimit
div 3600, (gGameSettings
.TimeLimit
div 60) mod 60, gGameSettings
.TimeLimit
mod 60]);
1234 if gGameSettings
.MaxLives
= 0 then
1235 s1
:= _lc
[I_GAME_TDM
]
1237 s1
:= _lc
[I_GAME_TLMS
];
1238 s2
:= Format(_lc
[I_GAME_FRAG_LIMIT
], [gGameSettings
.ScoreLimit
]);
1239 s3
:= Format(_lc
[I_GAME_TIME_LIMIT
], [gGameSettings
.TimeLimit
div 3600, (gGameSettings
.TimeLimit
div 60) mod 60, gGameSettings
.TimeLimit
mod 60]);
1244 s1
:= _lc
[I_GAME_CTF
];
1245 s2
:= Format(_lc
[I_GAME_SCORE_LIMIT
], [gGameSettings
.ScoreLimit
]);
1246 s3
:= Format(_lc
[I_GAME_TIME_LIMIT
], [gGameSettings
.TimeLimit
div 3600, (gGameSettings
.TimeLimit
div 60) mod 60, gGameSettings
.TimeLimit
mod 60]);
1251 if gGameSettings
.MaxLives
= 0 then
1252 s1
:= _lc
[I_GAME_COOP
]
1254 s1
:= _lc
[I_GAME_SURV
];
1255 s2
:= _lc
[I_GAME_MONSTERS
] + ' ' + IntToStr(gCoopMonstersKilled
) + '/' + IntToStr(gTotalMonsters
);
1256 s3
:= _lc
[I_GAME_SECRETS
] + ' ' + IntToStr(gCoopSecretsFound
) + '/' + IntToStr(gSecretsCount
);
1267 e_TextureFontPrintEx(x
+(w
div 2)-(Length(s1
)*cw
div 2), _y
, s1
, gStdFont
, 255, 255, 255, 1);
1269 e_TextureFontPrintEx(x
+(w
div 2)-(Length(mapstr
)*cw
div 2), _y
, mapstr
, gStdFont
, 200, 200, 200, 1);
1271 e_TextureFontPrintEx(x
+16, _y
, s2
, gStdFont
, 200, 200, 200, 1);
1273 e_TextureFontPrintEx(x
+w
-16-(Length(s3
))*cw
, _y
, s3
,
1274 gStdFont
, 200, 200, 200, 1);
1276 if NetMode
= NET_SERVER
then
1277 e_TextureFontPrintEx(x
+8, y
+ 8, _lc
[I_NET_SERVER
], gStdFont
, 255, 255, 255, 1)
1279 if NetMode
= NET_CLIENT
then
1280 e_TextureFontPrintEx(x
+8, y
+ 8,
1281 NetClientIP
+ ':' + IntToStr(NetClientPort
), gStdFont
, 255, 255, 255, 1);
1285 stat
:= g_Player_GetStats();
1288 w2
:= (w
-16) div 6 + 48; // øèðèíà 2 ñòîëáöà
1289 w3
:= (w
-16) div 6; // øèðèíà 3 è 4 ñòîëáöîâ
1291 w1
:= w
-16-w2
-w3
-w4
; // îñòàâøååñÿ ïðîñòðàíñòâî - äëÿ öâåòà è èìåíè èãðîêà
1293 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
1297 for a
:= TEAM_RED
to TEAM_BLUE
do
1299 if a
= TEAM_RED
then
1301 s1
:= _lc
[I_GAME_TEAM_RED
];
1308 s1
:= _lc
[I_GAME_TEAM_BLUE
];
1314 e_TextureFontPrintEx(x
+16, _y
, s1
, gStdFont
, r
, g
, b
, 1);
1315 e_TextureFontPrintEx(x
+w1
+16, _y
, IntToStr(gTeamStat
[a
].Score
),
1316 gStdFont
, r
, g
, b
, 1);
1317 e_TextureFontPrintEx(x
+w1
+w2
, _y
, _lc
[I_GAME_FRAGS
],
1318 gStdFont
, r
, g
, b
, 1);
1319 e_TextureFontPrintEx(x
+w1
+w2
+72, _y
, _lc
[I_GAME_ASSISTS
],
1320 gStdFont
, r
, g
, b
, 1);
1322 _y
:= _y
+ch
+(ch
div 4);
1323 e_DrawLine(1, x
+16, _y
, x
+w
-16, _y
, r
, g
, b
);
1324 _y
:= _y
+(ch
div 4);
1326 for aa
:= 0 to High(stat
) do
1327 if stat
[aa
].Team
= a
then
1343 namestr
:= Format('[%5d] %s', [UID
, Name
])
1347 e_TextureFontPrintEx(x
+16, _y
, namestr
, gStdFont
, rr
, gg
, bb
, 1);
1349 e_TextureFontPrintEx(x
+w1
+16, _y
, Format(_lc
[I_GAME_PING_MS
], [Ping
, Loss
]), gStdFont
, rr
, gg
, bb
, 1);
1351 e_TextureFontPrintEx(x
+w1
+w2
+16, _y
, IntToStr(Frags
), gStdFont
, rr
, gg
, bb
, 1);
1353 e_TextureFontPrintEx(x
+w1
+w2
+72, _y
, IntToStr(Assists
), gStdFont
, rr
, gg
, bb
, 1);
1355 e_TextureFontPrintEx(x
+w1
+w2
+w3
+16, _y
, IntToStr(Deaths
), gStdFont
, rr
, gg
, bb
, 1);
1362 else if gGameSettings
.GameMode
in [GM_DM
, GM_COOP
] then
1365 e_TextureFontPrintEx(x
+16, _y
, _lc
[I_GAME_PLAYER_NAME
], gStdFont
, 255, 127, 0, 1);
1366 e_TextureFontPrintEx(x
+16+w1
, _y
, _lc
[I_GAME_PING
], gStdFont
, 255, 127, 0, 1);
1367 e_TextureFontPrintEx(x
+16+w1
+w2
, _y
, _lc
[I_GAME_FRAGS
], gStdFont
, 255, 127, 0, 1);
1368 e_TextureFontPrintEx(x
+16+w1
+w2
+w3
, _y
, _lc
[I_GAME_DEATHS
], gStdFont
, 255, 127, 0, 1);
1371 for aa
:= 0 to High(stat
) do
1385 namestr
:= Format('[%5d] %s', [UID
, Name
])
1389 e_DrawFillQuad(x
+16, _y
+4, x
+32-1, _y
+16+4-1, Color
.R
, Color
.G
, Color
.B
, 0);
1390 e_DrawQuad(x
+16, _y
+4, x
+32-1, _y
+16+4-1, 192, 192, 192);
1392 e_TextureFontPrintEx(x
+16+16+8, _y
+4, namestr
, gStdFont
, r
, g
, 0, 1);
1394 e_TextureFontPrintEx(x
+w1
+16, _y
+4, Format(_lc
[I_GAME_PING_MS
], [Ping
, Loss
]), gStdFont
, r
, g
, 0, 1);
1396 e_TextureFontPrintEx(x
+w1
+w2
+16, _y
+4, IntToStr(Frags
), gStdFont
, r
, g
, 0, 1);
1398 e_TextureFontPrintEx(x
+w1
+w2
+w3
+16, _y
+4, IntToStr(Deaths
), gStdFont
, r
, g
, 0, 1);
1404 procedure g_Game_Init();
1407 knownFiles
: array of AnsiString = nil;
1409 wext
, s
: AnsiString;
1414 gTempDelete
:= False;
1416 sfsGCDisable(); // temporary disable removing of temporary volumes
1419 TEXTUREFILTER
:= GL_LINEAR
;
1420 g_Texture_CreateWADEx('MENU_BACKGROUND', GameWAD
+':TEXTURES\TITLE');
1421 g_Texture_CreateWADEx('INTER', GameWAD
+':TEXTURES\INTER');
1422 g_Texture_CreateWADEx('ENDGAME_EN', GameWAD
+':TEXTURES\ENDGAME_EN');
1423 g_Texture_CreateWADEx('ENDGAME_RU', GameWAD
+':TEXTURES\ENDGAME_RU');
1424 TEXTUREFILTER
:= GL_NEAREST
;
1426 LoadStdFont('STDTXT', 'STDFONT', gStdFont
);
1427 LoadFont('MENUTXT', 'MENUFONT', gMenuFont
);
1428 LoadFont('SMALLTXT', 'SMALLFONT', gMenuSmallFont
);
1430 g_Game_ClearLoading();
1431 g_Game_SetLoadingText(Format('Doom 2D: Forever %s', [GAME_VERSION
]), 0, False);
1432 g_Game_SetLoadingText('', 0, False);
1434 g_Game_SetLoadingText(_lc
[I_LOAD_CONSOLE
], 0, False);
1437 g_Game_SetLoadingText(_lc
[I_LOAD_MODELS
], 0, False);
1438 g_PlayerModel_LoadData();
1440 // load models from all possible wad types, in all known directories
1441 // this does a loosy job (linear search, ooph!), but meh
1442 for wext
in wadExtensions
do
1444 for f
:= High(ModelDirs
) downto Low(ModelDirs
) do
1446 if (FindFirst(ModelDirs
[f
]+DirectorySeparator
+'*'+wext
, faAnyFile
, SR
) = 0) then
1450 for s
in knownFiles
do
1452 if (strEquCI1251(forceFilenameExt(SR
.Name
, ''), forceFilenameExt(ExtractFileName(s
), ''))) then
1460 SetLength(knownFiles
, length(knownFiles
)+1);
1461 knownFiles
[High(knownFiles
)] := ModelDirs
[f
]+DirectorySeparator
+SR
.Name
;
1463 until (FindNext(SR
) <> 0);
1469 if (length(knownFiles
) = 0) then raise Exception
.Create('no player models found!');
1471 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
);
1472 for s
in knownFiles
do
1474 if not g_PlayerModel_Load(s
) then e_LogWritefln('Error loading model "%s"', [s
], TMsgType
.Warning
);
1478 gPauseMain
:= false;
1479 gPauseHolmes
:= false;
1482 {e_MouseInfo.Accel := 1.0;}
1484 g_Game_SetLoadingText(_lc
[I_LOAD_GAME_DATA
], 0, False);
1487 g_Game_SetLoadingText(_lc
[I_LOAD_MUSIC
], 0, False);
1488 g_Sound_CreateWADEx('MUSIC_INTERMUS', GameWAD
+':MUSIC\INTERMUS', True);
1489 g_Sound_CreateWADEx('MUSIC_MENU', GameWAD
+':MUSIC\MENU', True);
1490 g_Sound_CreateWADEx('MUSIC_ROUNDMUS', GameWAD
+':MUSIC\ROUNDMUS', True, True);
1491 g_Sound_CreateWADEx('MUSIC_STDENDMUS', GameWAD
+':MUSIC\ENDMUS', True);
1494 g_Game_SetLoadingText(_lc
[I_LOAD_MENUS
], 0, False);
1498 gMusic
:= TMusic
.Create();
1499 gMusic
.SetByName('MUSIC_MENU');
1502 gGameSettings
.WarmupTime
:= 30;
1504 gState
:= STATE_MENU
;
1506 SetLength(gEvents
, 6);
1507 gEvents
[0].Name
:= 'ongamestart';
1508 gEvents
[1].Name
:= 'ongameend';
1509 gEvents
[2].Name
:= 'onmapstart';
1510 gEvents
[3].Name
:= 'onmapend';
1511 gEvents
[4].Name
:= 'oninter';
1512 gEvents
[5].Name
:= 'onwadend';
1514 sfsGCEnable(); // enable releasing unused volumes
1518 procedure g_Game_Free(freeTextures
: Boolean=true);
1520 if NetMode
= NET_CLIENT
then g_Net_Disconnect();
1521 if NetMode
= NET_SERVER
then g_Net_Host_Die();
1523 g_Map_Free(freeTextures
);
1525 g_Player_RemoveAllCorpses();
1527 gGameSettings
.GameType
:= GT_NONE
;
1528 if gGameSettings
.GameMode
= GM_SINGLE
then
1529 gGameSettings
.GameMode
:= GM_DM
;
1530 gSwitchGameMode
:= gGameSettings
.GameMode
;
1533 gExitByTrigger
:= False;
1536 function IsActivePlayer(p
: TPlayer
): Boolean;
1541 Result
:= (not p
.FDummy
) and (not p
.FSpectator
);
1544 function GetActivePlayer_ByID(ID
: Integer): TPlayer
;
1551 if gPlayers
= nil then
1553 for a
:= Low(gPlayers
) to High(gPlayers
) do
1554 if IsActivePlayer(gPlayers
[a
]) then
1556 if gPlayers
[a
].UID
<> ID
then
1558 Result
:= gPlayers
[a
];
1563 function GetActivePlayerID_Next(Skip
: Integer = -1): Integer;
1569 if gPlayers
= nil then
1573 for a
:= Low(gPlayers
) to High(gPlayers
) do
1574 if IsActivePlayer(gPlayers
[a
]) then
1576 SetLength(ids
, Length(ids
) + 1);
1577 ids
[High(ids
)] := gPlayers
[a
].UID
;
1578 if gPlayers
[a
].UID
= Skip
then
1581 if Length(ids
) = 0 then
1586 Result
:= ids
[(idx
+ 1) mod Length(ids
)];
1589 function GetActivePlayerID_Prev(Skip
: Integer = -1): Integer;
1595 if gPlayers
= nil then
1599 for a
:= Low(gPlayers
) to High(gPlayers
) do
1600 if IsActivePlayer(gPlayers
[a
]) then
1602 SetLength(ids
, Length(ids
) + 1);
1603 ids
[High(ids
)] := gPlayers
[a
].UID
;
1604 if gPlayers
[a
].UID
= Skip
then
1607 if Length(ids
) = 0 then
1610 Result
:= ids
[Length(ids
) - 1]
1612 Result
:= ids
[(Length(ids
) - 1 + idx
) mod Length(ids
)];
1615 function GetActivePlayerID_Random(Skip
: Integer = -1): Integer;
1621 if gPlayers
= nil then
1625 for a
:= Low(gPlayers
) to High(gPlayers
) do
1626 if IsActivePlayer(gPlayers
[a
]) then
1628 SetLength(ids
, Length(ids
) + 1);
1629 ids
[High(ids
)] := gPlayers
[a
].UID
;
1630 if gPlayers
[a
].UID
= Skip
then
1633 if Length(ids
) = 0 then
1635 if Length(ids
) = 1 then
1640 Result
:= ids
[Random(Length(ids
))];
1642 while (idx
<> -1) and (Result
= Skip
) and (a
> 0) do
1644 Result
:= ids
[Random(Length(ids
))];
1649 function GetRandomSpectMode(Current
: Byte): Byte;
1656 0: Result
:= SPECT_STATS
;
1657 1: Result
:= SPECT_MAPVIEW
;
1658 2: Result
:= SPECT_MAPVIEW
;
1659 3: Result
:= SPECT_PLAYERS
;
1660 4: Result
:= SPECT_PLAYERS
;
1661 5: Result
:= SPECT_PLAYERS
;
1662 6: Result
:= SPECT_PLAYERS
;
1664 if (Current
in [SPECT_STATS
, SPECT_MAPVIEW
]) and (Current
= Result
) then
1668 procedure ProcessPlayerControls (plr
: TPlayer
; p
: Integer; var MoveButton
: Byte);
1674 if (plr
= nil) then exit
;
1675 if (p
= 2) then time
:= 1000 else time
:= 1;
1676 strafeDir
:= MoveButton
shr 4;
1677 MoveButton
:= MoveButton
and $0F;
1679 if gPlayerAction
[p
, ACTION_MOVELEFT
] and (not gPlayerAction
[p
, ACTION_MOVERIGHT
]) then
1680 MoveButton
:= 1 // Íàæàòà òîëüêî "Âëåâî"
1681 else if (not gPlayerAction
[p
, ACTION_MOVELEFT
]) and gPlayerAction
[p
, ACTION_MOVERIGHT
] then
1682 MoveButton
:= 2 // Íàæàòà òîëüêî "Âïðàâî"
1683 else if (not gPlayerAction
[p
, ACTION_MOVELEFT
]) and (not gPlayerAction
[p
, ACTION_MOVERIGHT
]) then
1684 MoveButton
:= 0; // Íå íàæàòû íè "Âëåâî", íè "Âïðàâî"
1686 // Ñåé÷àñ èëè ðàíüøå áûëè íàæàòû "Âëåâî"/"Âïðàâî" => ïåðåäàåì èãðîêó:
1687 if MoveButton
= 1 then
1688 plr
.PressKey(KEY_LEFT
, time
)
1689 else if MoveButton
= 2 then
1690 plr
.PressKey(KEY_RIGHT
, time
);
1692 // if we have "strafe" key, turn off old strafe mechanics
1693 if gPlayerAction
[p
, ACTION_STRAFE
] then
1695 // new strafe mechanics
1696 if (strafeDir
= 0) then
1697 strafeDir
:= MoveButton
; // start strafing
1698 // now set direction according to strafe (reversed)
1699 if (strafeDir
= 2) then
1700 plr
.SetDirection(TDirection
.D_LEFT
)
1701 else if (strafeDir
= 1) then
1702 plr
.SetDirection(TDirection
.D_RIGHT
)
1706 strafeDir
:= 0; // not strafing anymore
1707 // Ðàíüøå áûëà íàæàòà "Âïðàâî", à ñåé÷àñ "Âëåâî" => áåæèì âïðàâî, ñìîòðèì âëåâî:
1708 if (MoveButton
= 2) and gPlayerAction
[p
, ACTION_MOVELEFT
] then
1709 plr
.SetDirection(TDirection
.D_LEFT
)
1710 // Ðàíüøå áûëà íàæàòà "Âëåâî", à ñåé÷àñ "Âïðàâî" => áåæèì âëåâî, ñìîòðèì âïðàâî:
1711 else if (MoveButton
= 1) and gPlayerAction
[p
, ACTION_MOVERIGHT
] then
1712 plr
.SetDirection(TDirection
.D_RIGHT
)
1713 // ×òî-òî áûëî íàæàòî è íå èçìåíèëîñü => êóäà áåæèì, òóäà è ñìîòðèì:
1714 else if MoveButton
<> 0 then
1715 plr
.SetDirection(TDirection(MoveButton
-1))
1718 // fix movebutton state
1719 MoveButton
:= MoveButton
or (strafeDir
shl 4);
1721 // Îñòàëüíûå êëàâèøè:
1722 if gPlayerAction
[p
, ACTION_JUMP
] then plr
.PressKey(KEY_JUMP
, time
);
1723 if gPlayerAction
[p
, ACTION_LOOKUP
] then plr
.PressKey(KEY_UP
, time
);
1724 if gPlayerAction
[p
, ACTION_LOOKDOWN
] then plr
.PressKey(KEY_DOWN
, time
);
1725 if gPlayerAction
[p
, ACTION_ATTACK
] then plr
.PressKey(KEY_FIRE
);
1726 if gPlayerAction
[p
, ACTION_ACTIVATE
] then plr
.PressKey(KEY_OPEN
);
1728 for i
:= WP_FACT
to WP_LACT
do
1730 if gWeaponAction
[p
, i
] then
1732 plr
.ProcessWeaponAction(i
);
1733 gWeaponAction
[p
, i
] := False
1737 for i
:= WP_FIRST
to WP_LAST
do
1739 if gSelectWeapon
[p
, i
] then
1741 plr
.QueueWeaponSwitch(i
); // all choices are passed there, and god will take the best
1742 gSelectWeapon
[p
, i
] := False
1746 // HACK: add dynlight here
1747 if gwin_k8_enable_light_experiments
then
1749 if e_KeyPressed(IK_F8
) and gGameOn
and (not gConsoleShow
) and (g_ActiveWindow
= nil) then
1751 g_playerLight
:= true;
1753 if e_KeyPressed(IK_F9
) and gGameOn
and (not gConsoleShow
) and (g_ActiveWindow
= nil) then
1755 g_playerLight
:= false;
1759 if gwin_has_stencil
and g_playerLight
then g_AddDynLight(plr
.GameX
+32, plr
.GameY
+40, 128, 1, 1, 0, 0.6);
1762 // HACK: don't have a "key was pressed" function
1763 procedure InterReady();
1765 if InterReadyTime
> gTime
then Exit
;
1766 InterReadyTime
:= gTime
+ 3000;
1767 MC_SEND_CheatRequest(NET_CHEAT_READY
);
1770 procedure g_Game_PreUpdate();
1772 // these are in separate PreUpdate functions because they can interact during Update()
1773 // and are synced over the net
1774 // we don't care that much about corpses and gibs
1775 g_Player_PreUpdate();
1776 g_Monsters_PreUpdate();
1777 g_Items_PreUpdate();
1778 g_Weapon_PreUpdate();
1781 procedure g_Game_Update();
1783 Msg
: g_gui
.TMessage
;
1789 function sendMonsPos (mon
: TMonster
): Boolean;
1791 result
:= false; // don't stop
1792 // this will also reset "need-send" flag
1793 if mon
.gncNeedSend
then
1795 MH_SEND_MonsterPos(mon
.UID
);
1797 else if (mon
.MonsterType
= MONSTER_BARREL
) then
1799 if (mon
.GameVelX
<> 0) or (mon
.GameVelY
<> 0) then MH_SEND_MonsterPos(mon
.UID
);
1801 else if (mon
.MonsterState
<> MONSTATE_SLEEP
) then
1803 if (mon
.MonsterState
<> MONSTATE_DEAD
) or (mon
.GameVelX
<> 0) or (mon
.GameVelY
<> 0) then MH_SEND_MonsterPos(mon
.UID
);
1807 function sendMonsPosUnexpected (mon
: TMonster
): Boolean;
1809 result
:= false; // don't stop
1810 // this will also reset "need-send" flag
1811 if mon
.gncNeedSend
then MH_SEND_MonsterPos(mon
.UID
);
1814 function sendItemPos (it
: PItem
): Boolean;
1816 result
:= false; // don't stop
1819 MH_SEND_ItemPos(it
.myId
);
1820 it
.needSend
:= False;
1825 reliableUpdate
: Boolean;
1830 // Ïîðà âûêëþ÷àòü èãðó:
1831 if gExit
= EXIT_QUIT
then
1833 // Èãðà çàêîí÷èëàñü - îáðàáàòûâàåì:
1837 if gExit
= EXIT_QUIT
then
1841 // ×èòàåì êëàâèàòóðó è äæîéñòèê, åñëè îêíî àêòèâíî
1842 // no need to, as we'll do it in event handler
1844 // Îáíîâëÿåì êîíñîëü (äâèæåíèå è ñîîáùåíèÿ):
1847 if (NetMode
= NET_NONE
) and (g_Game_IsNet
) and (gGameOn
or (gState
in [STATE_FOLD
, STATE_INTERCUSTOM
])) then
1849 gExit
:= EXIT_SIMPLE
;
1854 // process master server communications
1855 g_Net_Slist_Pulse();
1858 STATE_INTERSINGLE
, // Ñòàòèñòêà ïîñëå ïðîõîæäåíèÿ óðîâíÿ â Îäèíî÷íîé èãðå
1859 STATE_INTERCUSTOM
, // Ñòàòèñòêà ïîñëå ïðîõîæäåíèÿ óðîâíÿ â Ñâîåé èãðå
1860 STATE_INTERTEXT
, // Òåêñò ìåæäó óðîâíÿìè
1861 STATE_INTERPIC
: // Êàðòèíêà ìåæäó óðîâíÿìè
1863 if g_Game_IsNet
and g_Game_IsServer
then
1865 gInterTime
:= gInterTime
+ GAME_TICK
;
1866 a
:= Min((gInterEndTime
- gInterTime
) div 1000 + 1, 255);
1867 if a
<> gServInterTime
then
1869 gServInterTime
:= a
;
1870 MH_SEND_TimeSync(gServInterTime
);
1874 if (not g_Game_IsClient
) and
1878 e_KeyPressed(IK_RETURN
) or e_KeyPressed(IK_KPRETURN
) or e_KeyPressed(IK_SPACE
) or
1879 e_KeyPressed(VK_FIRE
) or e_KeyPressed(VK_OPEN
) or
1880 e_KeyPressed(JOY0_ATTACK
) or e_KeyPressed(JOY1_ATTACK
) or
1881 e_KeyPressed(JOY2_ATTACK
) or e_KeyPressed(JOY3_ATTACK
)
1883 and (not gJustChatted
) and (not gConsoleShow
) and (not gChatShow
)
1884 and (g_ActiveWindow
= nil)
1886 or (g_Game_IsNet
and ((gInterTime
> gInterEndTime
) or ((gInterReadyCount
>= NetClientCount
) and (NetClientCount
> 0))))
1889 begin // Íàæàëè <Enter>/<Ïðîáåë> èëè ïðîøëî äîñòàòî÷íî âðåìåíè:
1890 g_Game_StopAllSounds(True);
1892 if gMapOnce
then // Ýòî áûë òåñò
1893 gExit
:= EXIT_SIMPLE
1895 if gNextMap
<> '' then // Ïåðåõîäèì íà ñëåäóþùóþ êàðòó
1896 g_Game_ChangeMap(gNextMap
)
1897 else // Ñëåäóþùåé êàðòû íåò
1899 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
] then
1901 // Âûõîä â ãëàâíîå ìåíþ:
1903 g_GUI_ShowWindow('MainMenu');
1904 gMusic
.SetByName('MUSIC_MENU');
1906 gState
:= STATE_MENU
;
1909 // Ôèíàëüíàÿ êàðòèíêà:
1910 g_Game_ExecuteEvent('onwadend');
1912 if not gMusic
.SetByName('MUSIC_endmus') then
1913 gMusic
.SetByName('MUSIC_STDENDMUS');
1915 gState
:= STATE_ENDPIC
;
1917 g_Game_ExecuteEvent('ongameend');
1922 else if g_Game_IsClient
and
1925 e_KeyPressed(IK_RETURN
) or e_KeyPressed(IK_KPRETURN
) or e_KeyPressed(IK_SPACE
) or
1926 e_KeyPressed(VK_FIRE
) or e_KeyPressed(VK_OPEN
) or
1927 e_KeyPressed(JOY0_ATTACK
) or e_KeyPressed(JOY1_ATTACK
) or
1928 e_KeyPressed(JOY2_ATTACK
) or e_KeyPressed(JOY3_ATTACK
)
1930 and (not gJustChatted
) and (not gConsoleShow
) and (not gChatShow
)
1931 and (g_ActiveWindow
= nil)
1939 if gState
= STATE_INTERTEXT
then
1940 if InterText
.counter
> 0 then
1941 InterText
.counter
:= InterText
.counter
- 1;
1944 STATE_FOLD
: // Çàòóõàíèå ýêðàíà
1946 if EndingGameCounter
= 0 then
1948 // Çàêîí÷èëñÿ óðîâåíü â Ñâîåé èãðå:
1949 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
1951 gState
:= STATE_INTERCUSTOM
;
1952 InterReadyTime
:= -1;
1953 if gLastMap
and (gGameSettings
.GameMode
= GM_COOP
) then
1955 g_Game_ExecuteEvent('onwadend');
1956 if not gMusic
.SetByName('MUSIC_endmus') then
1957 gMusic
.SetByName('MUSIC_STDENDMUS');
1960 gMusic
.SetByName('MUSIC_ROUNDMUS');
1964 else // Çàêîí÷èëàñü ïîñëåäíÿÿ êàðòà â Îäèíî÷íîé èãðå
1966 gMusic
.SetByName('MUSIC_INTERMUS');
1968 gState
:= STATE_INTERSINGLE
;
1971 g_Game_ExecuteEvent('oninter');
1974 DecMin(EndingGameCounter
, 6, 0);
1977 STATE_ENDPIC
: // Êàðòèíêà îêîí÷àíèÿ ìåãàÂàäà
1979 if gMapOnce
then // Ýòî áûë òåñò
1981 gExit
:= EXIT_SIMPLE
;
1987 g_Serverlist_Control(slCurrent
, slTable
);
1990 // Ñòàòèñòèêà ïî Tab:
1992 IsDrawStat
:= (not gConsoleShow
) and (not gChatShow
) and (gGameSettings
.GameType
<> GT_SINGLE
) and g_Console_Action(ACTION_SCORES
);
1995 if gGameOn
and not gPause
and (gState
<> STATE_FOLD
) then
1997 // Âðåìÿ += 28 ìèëëèñåêóíä:
1998 gTime
:= gTime
+ GAME_TICK
;
2000 // Ñîîáùåíèå ïîñåðåäèíå ýêðàíà:
2001 if MessageTime
= 0 then
2003 if MessageTime
> 0 then
2004 MessageTime
:= MessageTime
- 1;
2006 if (g_Game_IsServer
) then
2008 // Áûë çàäàí ëèìèò âðåìåíè:
2009 if (gGameSettings
.TimeLimit
> 0) then
2010 if (gTime
- gGameStartTime
) div 1000 >= gGameSettings
.TimeLimit
then
2011 begin // Îí ïðîøåë => êîíåö óðîâíÿ
2016 // Íàäî ðåñïàâíèòü èãðîêîâ â LMS:
2017 if (gLMSRespawn
> LMS_RESPAWN_NONE
) and (gLMSRespawnTime
< gTime
) then
2018 g_Game_RestartRound(gLMSSoftSpawn
);
2020 // Ïðîâåðèì ðåçóëüòàò ãîëîñîâàíèÿ, åñëè âðåìÿ ïðîøëî
2021 if gVoteInProgress
and (gVoteTimer
< gTime
) then
2023 else if gVotePassed
and (gVoteCmdTimer
< gTime
) then
2025 g_Console_Process(gVoteCommand
);
2027 gVotePassed
:= False;
2030 // Çàìåðÿåì âðåìÿ çàõâàòà ôëàãîâ
2031 if gFlags
[FLAG_RED
].State
= FLAG_STATE_CAPTURED
then
2032 gFlags
[FLAG_RED
].CaptureTime
:= gFlags
[FLAG_RED
].CaptureTime
+ GAME_TICK
;
2033 if gFlags
[FLAG_BLUE
].State
= FLAG_STATE_CAPTURED
then
2034 gFlags
[FLAG_BLUE
].CaptureTime
:= gFlags
[FLAG_BLUE
].CaptureTime
+ GAME_TICK
;
2036 // Áûë çàäàí ëèìèò ïîáåä:
2037 if (gGameSettings
.ScoreLimit
> 0) then
2041 if gGameSettings
.GameMode
= GM_DM
then
2042 begin // Â DM èùåì èãðîêà ñ max ôðàãàìè
2043 for i
:= 0 to High(gPlayers
) do
2044 if gPlayers
[i
] <> nil then
2045 if gPlayers
[i
].Frags
> b
then
2046 b
:= gPlayers
[i
].Frags
;
2049 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
2050 begin //  CTF/TDM âûáèðàåì êîìàíäó ñ íàèáîëüøèì ñ÷åòîì
2051 b
:= Max(gTeamStat
[TEAM_RED
].Score
, gTeamStat
[TEAM_BLUE
].Score
);
2054 // Ëèìèò ïîáåä íàáðàí => êîíåö óðîâíÿ:
2055 if b
>= gGameSettings
.ScoreLimit
then
2062 // Îáðàáàòûâàåì êëàâèøè èãðîêîâ:
2063 if gPlayer1
<> nil then gPlayer1
.ReleaseKeys();
2064 if gPlayer2
<> nil then gPlayer2
.ReleaseKeys();
2065 if (not gConsoleShow
) and (not gChatShow
) and (g_ActiveWindow
= nil) then
2067 ProcessPlayerControls(gPlayer1
, 0, P1MoveButton
);
2068 ProcessPlayerControls(gPlayer2
, 1, P2MoveButton
);
2069 end // if not console
2072 if g_Game_IsNet
and (gPlayer1
<> nil) then gPlayer1
.PressKey(KEY_CHAT
, 10000);
2074 // process weapon switch queue
2078 if (gPlayer1
= nil) and (gPlayer2
= nil) and
2079 (not gConsoleShow
) and (not gChatShow
) and (g_ActiveWindow
= nil) then
2081 if not gSpectKeyPress
then
2083 if gPlayerAction
[0, ACTION_JUMP
] and (not gSpectAuto
) then
2085 // switch spect mode
2087 SPECT_NONE
: ; // not spectator
2089 SPECT_MAPVIEW
: Inc(gSpectMode
);
2090 SPECT_PLAYERS
: gSpectMode
:= SPECT_STATS
; // reset to 1
2092 gSpectKeyPress
:= True;
2094 if (gSpectMode
= SPECT_MAPVIEW
)
2095 and (not gSpectAuto
) then
2097 if gPlayerAction
[0, ACTION_MOVELEFT
] then
2098 gSpectX
:= Max(gSpectX
- gSpectStep
, 0);
2099 if gPlayerAction
[0, ACTION_MOVERIGHT
] then
2100 gSpectX
:= Min(gSpectX
+ gSpectStep
, gMapInfo
.Width
- gScreenWidth
);
2101 if gPlayerAction
[0, ACTION_LOOKUP
] then
2102 gSpectY
:= Max(gSpectY
- gSpectStep
, 0);
2103 if gPlayerAction
[0, ACTION_LOOKDOWN
] then
2104 gSpectY
:= Min(gSpectY
+ gSpectStep
, gMapInfo
.Height
- gScreenHeight
);
2105 if gWeaponAction
[0, WP_PREV
] then
2108 if gSpectStep
> 4 then gSpectStep
:= gSpectStep
shr 1;
2109 gWeaponAction
[0, WP_PREV
] := False;
2111 if gWeaponAction
[0, WP_NEXT
] then
2114 if gSpectStep
< 64 then gSpectStep
:= gSpectStep
shl 1;
2115 gWeaponAction
[0, WP_NEXT
] := False;
2118 if (gSpectMode
= SPECT_PLAYERS
)
2119 and (not gSpectAuto
) then
2121 if gPlayerAction
[0, ACTION_LOOKUP
] then
2124 gSpectViewTwo
:= True;
2125 gSpectKeyPress
:= True;
2127 if gPlayerAction
[0, ACTION_LOOKDOWN
] then
2129 // remove second view
2130 gSpectViewTwo
:= False;
2131 gSpectKeyPress
:= True;
2133 if gPlayerAction
[0, ACTION_MOVELEFT
] then
2135 // prev player (view 1)
2136 gSpectPID1
:= GetActivePlayerID_Prev(gSpectPID1
);
2137 gSpectKeyPress
:= True;
2139 if gPlayerAction
[0, ACTION_MOVERIGHT
] then
2141 // next player (view 1)
2142 gSpectPID1
:= GetActivePlayerID_Next(gSpectPID1
);
2143 gSpectKeyPress
:= True;
2145 if gWeaponAction
[0, WP_PREV
] then
2147 // prev player (view 2)
2148 gSpectPID2
:= GetActivePlayerID_Prev(gSpectPID2
);
2149 gWeaponAction
[0, WP_PREV
] := False;
2151 if gWeaponAction
[0, WP_NEXT
] then
2153 // next player (view 2)
2154 gSpectPID2
:= GetActivePlayerID_Next(gSpectPID2
);
2155 gWeaponAction
[0, WP_NEXT
] := False;
2158 if gPlayerAction
[0, ACTION_ATTACK
] then
2160 if (gSpectMode
= SPECT_STATS
) and (not gSpectAuto
) then
2163 gSpectAutoNext
:= 0;
2164 gSpectViewTwo
:= False;
2165 gSpectKeyPress
:= True;
2170 gSpectMode
:= SPECT_STATS
;
2171 gSpectAuto
:= False;
2172 gSpectKeyPress
:= True;
2177 if (not gPlayerAction
[0, ACTION_JUMP
]) and
2178 (not gPlayerAction
[0, ACTION_ATTACK
]) and
2179 (not gPlayerAction
[0, ACTION_MOVELEFT
]) and
2180 (not gPlayerAction
[0, ACTION_MOVERIGHT
]) and
2181 (not gPlayerAction
[0, ACTION_LOOKUP
]) and
2182 (not gPlayerAction
[0, ACTION_LOOKDOWN
]) then
2183 gSpectKeyPress
:= False;
2187 if gSpectMode
= SPECT_MAPVIEW
then
2189 i
:= Min(Max(gSpectX
+ gSpectAutoStepX
, 0), gMapInfo
.Width
- gScreenWidth
);
2191 gSpectAutoNext
:= gTime
2194 i
:= Min(Max(gSpectY
+ gSpectAutoStepY
, 0), gMapInfo
.Height
- gScreenHeight
);
2196 gSpectAutoNext
:= gTime
2200 if gSpectAutoNext
<= gTime
then
2202 if gSpectAutoNext
> 0 then
2204 gSpectMode
:= GetRandomSpectMode(gSpectMode
);
2208 gSpectX
:= Random(gMapInfo
.Width
- gScreenWidth
);
2209 gSpectY
:= Random(gMapInfo
.Height
- gScreenHeight
);
2210 gSpectAutoStepX
:= Random(9) - 4;
2211 gSpectAutoStepY
:= Random(9) - 4;
2212 if ((gSpectX
< 800) and (gSpectAutoStepX
< 0)) or
2213 ((gSpectX
> gMapInfo
.Width
- gScreenWidth
- 800) and (gSpectAutoStepX
> 0)) then
2214 gSpectAutoStepX
:= gSpectAutoStepX
* -1;
2215 if ((gSpectY
< 800) and (gSpectAutoStepY
< 0)) or
2216 ((gSpectY
> gMapInfo
.Height
- gScreenHeight
- 800) and (gSpectAutoStepY
> 0)) then
2217 gSpectAutoStepY
:= gSpectAutoStepY
* -1;
2221 gSpectPID1
:= GetActivePlayerID_Random(gSpectPID1
);
2226 SPECT_STATS
: gSpectAutoNext
:= gTime
+ (Random(3) + 5) * 1000;
2227 SPECT_MAPVIEW
: gSpectAutoNext
:= gTime
+ (Random(4) + 7) * 1000;
2228 SPECT_PLAYERS
: gSpectAutoNext
:= gTime
+ (Random(7) + 8) * 1000;
2234 // Îáíîâëÿåì âñå îñòàëüíîå:
2237 g_Triggers_Update();
2239 g_Monsters_Update();
2241 g_Player_UpdateAll();
2242 g_Player_UpdatePhysicalObjects();
2244 // server: send newly spawned monsters unconditionally
2245 if (gGameSettings
.GameType
= GT_SERVER
) then
2247 if (Length(gMonstersSpawned
) > 0) then
2249 for I
:= 0 to High(gMonstersSpawned
) do MH_SEND_MonsterSpawn(gMonstersSpawned
[I
]);
2250 SetLength(gMonstersSpawned
, 0);
2254 if (gSoundTriggerTime
> 8) then
2256 g_Game_UpdateTriggerSounds();
2257 gSoundTriggerTime
:= 0;
2261 Inc(gSoundTriggerTime
);
2264 if (NetMode
= NET_SERVER
) then
2266 Inc(NetTimeToUpdate
);
2267 Inc(NetTimeToReliable
);
2269 // send monster updates
2270 if (NetTimeToReliable
>= NetRelupdRate
) or (NetTimeToUpdate
>= NetUpdateRate
) then
2272 // send all monsters (periodic sync)
2273 reliableUpdate
:= (NetTimeToReliable
>= NetRelupdRate
);
2275 for I
:= 0 to High(gPlayers
) do
2277 if (gPlayers
[I
] <> nil) then MH_SEND_PlayerPos(reliableUpdate
, gPlayers
[I
].UID
);
2280 g_Mons_ForEach(sendMonsPos
);
2282 // update flags that aren't stationary
2283 if gGameSettings
.GameMode
= GM_CTF
then
2284 for I
:= FLAG_RED
to FLAG_BLUE
do
2285 if gFlags
[I
].NeedSend
then
2287 gFlags
[I
].NeedSend
:= False;
2291 // update items that aren't stationary
2292 g_Items_ForEachAlive(sendItemPos
);
2294 if reliableUpdate
then
2296 NetTimeToReliable
:= 0;
2297 NetTimeToUpdate
:= NetUpdateRate
;
2301 NetTimeToUpdate
:= 0;
2306 // send only mosters with some unexpected changes
2307 g_Mons_ForEach(sendMonsPosUnexpected
);
2310 // send unexpected platform changes
2311 g_Map_NetSendInterestingPanels();
2313 g_Net_Slist_ServerUpdate();
2315 if NetUseMaster then
2317 if (gTime >= NetTimeToMaster) or g_Net_Slist_IsConnectionInProgress then
2319 if (not g_Net_Slist_IsConnectionActive) then g_Net_Slist_Connect(false); // non-blocking connection to the master
2321 NetTimeToMaster := gTime + NetMasterRate;
2326 else if (NetMode
= NET_CLIENT
) then
2328 MC_SEND_PlayerPos();
2330 end; // if gameOn ...
2332 // Àêòèâíî îêíî èíòåðôåéñà - ïåðåäàåì êëàâèøè åìó:
2333 if g_ActiveWindow
<> nil then
2335 w
:= e_GetFirstKeyPressed();
2337 if (w
<> IK_INVALID
) then
2339 Msg
.Msg
:= MESSAGE_DIKEY
;
2341 g_ActiveWindow
.OnMessage(Msg
);
2344 // Åñëè îíî îò ýòîãî íå çàêðûëîñü, òî îáíîâëÿåì:
2345 if g_ActiveWindow
<> nil then
2346 g_ActiveWindow
.Update();
2348 // Íóæíî ñìåíèòü ðàçðåøåíèå:
2349 if gResolutionChange
then
2351 e_WriteLog('Changing resolution', TMsgType
.Notify
);
2352 g_Game_ChangeResolution(gRC_Width
, gRC_Height
, gRC_FullScreen
, gRC_Maximized
);
2353 gResolutionChange
:= False;
2354 g_ActiveWindow
:= nil;
2357 // Íóæíî ñìåíèòü ÿçûê:
2358 if gLanguageChange
then
2360 //e_WriteLog('Read language file', MSG_NOTIFY);
2361 //g_Language_Load(DataDir + gLanguage + '.txt');
2362 g_Language_Set(gLanguage
);
2366 gLanguageChange
:= False;
2370 // Ãîðÿ÷àÿ êëàâèøà äëÿ âûçîâà ìåíþ âûõîäà èç èãðû (F10):
2371 if e_KeyPressed(IK_F10
) and
2373 (not gConsoleShow
) and
2374 (g_ActiveWindow
= nil) then
2379 Time
:= sys_GetTicks() {div 1000};
2381 // Îáðàáîòêà îòëîæåííûõ ñîáûòèé:
2382 if gDelayedEvents
<> nil then
2383 for a
:= 0 to High(gDelayedEvents
) do
2384 if gDelayedEvents
[a
].Pending
and
2386 ((gDelayedEvents
[a
].DEType
= DE_GLOBEVENT
) and (gDelayedEvents
[a
].Time
<= Time
)) or
2387 ((gDelayedEvents
[a
].DEType
> DE_GLOBEVENT
) and (gDelayedEvents
[a
].Time
<= gTime
))
2390 case gDelayedEvents
[a
].DEType
of
2392 g_Game_ExecuteEvent(gDelayedEvents
[a
].DEStr
);
2395 g_Game_Announce_GoodShot(gDelayedEvents
[a
].DENum
);
2399 g_Game_Announce_KillCombo(gDelayedEvents
[a
].DENum
);
2400 if g_Game_IsNet
and g_Game_IsServer
then
2401 MH_SEND_GameEvent(NET_EV_KILLCOMBO
, gDelayedEvents
[a
].DENum
);
2405 g_Game_Announce_BodyKill(gDelayedEvents
[a
].DENum
);
2407 gDelayedEvents
[a
].Pending
:= False;
2410 // Êàæäóþ ñåêóíäó îáíîâëÿåì ñ÷åò÷èê îáíîâëåíèé:
2411 UPSCounter
:= UPSCounter
+ 1;
2412 if Time
- UPSTime
>= 1000 then
2421 g_Weapon_AddDynLights();
2422 g_Items_AddDynLights();
2426 procedure g_Game_LoadChatSounds(Resource
: string);
2429 FileName
, Snd
: string;
2431 len
, cnt
, tags
, i
, j
: Integer;
2434 FileName
:= g_ExtractWadName(Resource
);
2436 WAD
:= TWADFile
.Create();
2437 WAD
.ReadFile(FileName
);
2439 if not WAD
.GetResource(g_ExtractFilePathName(Resource
), p
, len
) then
2446 cfg
:= TConfig
.CreateMem(p
, len
);
2447 cnt
:= cfg
.ReadInt('ChatSounds', 'Count', 0);
2449 SetLength(gChatSounds
, cnt
);
2450 for i
:= 0 to Length(gChatSounds
) - 1 do
2452 gChatSounds
[i
].Sound
:= nil;
2453 Snd
:= Trim(cfg
.ReadStr(IntToStr(i
), 'Sound', ''));
2454 tags
:= cfg
.ReadInt(IntToStr(i
), 'Tags', 0);
2455 if (Snd
= '') or (Tags
<= 0) then
2457 g_Sound_CreateWADEx('SOUND_CHAT_MACRO' + IntToStr(i
), GameWAD
+':'+Snd
);
2458 gChatSounds
[i
].Sound
:= TPlayableSound
.Create();
2459 gChatSounds
[i
].Sound
.SetByName('SOUND_CHAT_MACRO' + IntToStr(i
));
2460 SetLength(gChatSounds
[i
].Tags
, tags
);
2461 for j
:= 0 to tags
- 1 do
2462 gChatSounds
[i
].Tags
[j
] := toLowerCase1251(cfg
.ReadStr(IntToStr(i
), 'Tag' + IntToStr(j
), ''));
2463 gChatSounds
[i
].FullWord
:= cfg
.ReadBool(IntToStr(i
), 'FullWord', False);
2470 procedure g_Game_FreeChatSounds();
2474 for i
:= 0 to Length(gChatSounds
) - 1 do
2476 gChatSounds
[i
].Sound
.Free();
2477 g_Sound_Delete('SOUND_CHAT_MACRO' + IntToStr(i
));
2479 SetLength(gChatSounds
, 0);
2483 procedure g_Game_LoadData();
2490 if DataLoaded
then Exit
;
2492 e_WriteLog('Loading game data...', TMsgType
.Notify
);
2494 g_Texture_CreateWADEx('NOTEXTURE', GameWAD
+':TEXTURES\NOTEXTURE');
2495 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUD', GameWAD
+':TEXTURES\HUD');
2496 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDAIR', GameWAD
+':TEXTURES\AIRBAR');
2497 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDJET', GameWAD
+':TEXTURES\JETBAR');
2498 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDBG', GameWAD
+':TEXTURES\HUDBG');
2499 g_Texture_CreateWADEx('TEXTURE_PLAYER_ARMORHUD', GameWAD
+':TEXTURES\ARMORHUD');
2500 g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG', GameWAD
+':TEXTURES\FLAGHUD_R_BASE');
2501 g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG_S', GameWAD
+':TEXTURES\FLAGHUD_R_STOLEN');
2502 g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG_D', GameWAD
+':TEXTURES\FLAGHUD_R_DROP');
2503 g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG', GameWAD
+':TEXTURES\FLAGHUD_B_BASE');
2504 g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG_S', GameWAD
+':TEXTURES\FLAGHUD_B_STOLEN');
2505 g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG_D', GameWAD
+':TEXTURES\FLAGHUD_B_DROP');
2506 g_Texture_CreateWADEx('TEXTURE_PLAYER_TALKBUBBLE', GameWAD
+':TEXTURES\TALKBUBBLE');
2507 g_Texture_CreateWADEx('TEXTURE_PLAYER_INVULPENTA', GameWAD
+':TEXTURES\PENTA');
2508 g_Texture_CreateWADEx('TEXTURE_PLAYER_INDICATOR', GameWAD
+':TEXTURES\PLRIND');
2511 if not g_Texture_CreateWADEx('UI_GFX_PBAR_LEFT', GameWAD
+':TEXTURES\LLEFT') then hasPBarGfx
:= false;
2512 if not g_Texture_CreateWADEx('UI_GFX_PBAR_MARKER', GameWAD
+':TEXTURES\LMARKER') then hasPBarGfx
:= false;
2513 if not g_Texture_CreateWADEx('UI_GFX_PBAR_MIDDLE', GameWAD
+':TEXTURES\LMIDDLE') then hasPBarGfx
:= false;
2514 if not g_Texture_CreateWADEx('UI_GFX_PBAR_RIGHT', GameWAD
+':TEXTURES\LRIGHT') then hasPBarGfx
:= false;
2518 g_Texture_GetSize('UI_GFX_PBAR_LEFT', wl
, hl
);
2519 g_Texture_GetSize('UI_GFX_PBAR_RIGHT', wr
, hr
);
2520 g_Texture_GetSize('UI_GFX_PBAR_MIDDLE', wb
, hb
);
2521 g_Texture_GetSize('UI_GFX_PBAR_MARKER', wm
, hm
);
2522 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
2528 hasPBarGfx
:= false;
2532 g_Frames_CreateWAD(nil, 'FRAMES_TELEPORT', GameWAD
+':TEXTURES\TELEPORT', 64, 64, 10, False);
2533 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH', GameWAD
+':WEAPONS\PUNCH', 64, 64, 4, False);
2534 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_UP', GameWAD
+':WEAPONS\PUNCH_UP', 64, 64, 4, False);
2535 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_DN', GameWAD
+':WEAPONS\PUNCH_DN', 64, 64, 4, False);
2536 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_BERSERK', GameWAD
+':WEAPONS\PUNCHB', 64, 64, 4, False);
2537 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_BERSERK_UP', GameWAD
+':WEAPONS\PUNCHB_UP', 64, 64, 4, False);
2538 g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_BERSERK_DN', GameWAD
+':WEAPONS\PUNCHB_DN', 64, 64, 4, False);
2539 g_Sound_CreateWADEx('SOUND_GAME_TELEPORT', GameWAD
+':SOUNDS\TELEPORT');
2540 g_Sound_CreateWADEx('SOUND_GAME_NOTELEPORT', GameWAD
+':SOUNDS\NOTELEPORT');
2541 g_Sound_CreateWADEx('SOUND_GAME_SECRET', GameWAD
+':SOUNDS\SECRET');
2542 g_Sound_CreateWADEx('SOUND_GAME_DOOROPEN', GameWAD
+':SOUNDS\DOOROPEN');
2543 g_Sound_CreateWADEx('SOUND_GAME_DOORCLOSE', GameWAD
+':SOUNDS\DOORCLOSE');
2544 g_Sound_CreateWADEx('SOUND_GAME_BULK1', GameWAD
+':SOUNDS\BULK1');
2545 g_Sound_CreateWADEx('SOUND_GAME_BULK2', GameWAD
+':SOUNDS\BULK2');
2546 g_Sound_CreateWADEx('SOUND_GAME_BUBBLE1', GameWAD
+':SOUNDS\BUBBLE1');
2547 g_Sound_CreateWADEx('SOUND_GAME_BUBBLE2', GameWAD
+':SOUNDS\BUBBLE2');
2548 g_Sound_CreateWADEx('SOUND_GAME_BURNING', GameWAD
+':SOUNDS\BURNING');
2549 g_Sound_CreateWADEx('SOUND_GAME_SWITCH1', GameWAD
+':SOUNDS\SWITCH1');
2550 g_Sound_CreateWADEx('SOUND_GAME_SWITCH0', GameWAD
+':SOUNDS\SWITCH0');
2551 g_Sound_CreateWADEx('SOUND_GAME_RADIO', GameWAD
+':SOUNDS\RADIO');
2552 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD1', GameWAD
+':SOUNDS\GOOD1');
2553 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD2', GameWAD
+':SOUNDS\GOOD2');
2554 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD3', GameWAD
+':SOUNDS\GOOD3');
2555 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD4', GameWAD
+':SOUNDS\GOOD4');
2556 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL2X', GameWAD
+':SOUNDS\KILL2X');
2557 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL3X', GameWAD
+':SOUNDS\KILL3X');
2558 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL4X', GameWAD
+':SOUNDS\KILL4X');
2559 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILLMX', GameWAD
+':SOUNDS\KILLMX');
2560 g_Sound_CreateWADEx('SOUND_ANNOUNCER_MUHAHA1', GameWAD
+':SOUNDS\MUHAHA1');
2561 g_Sound_CreateWADEx('SOUND_ANNOUNCER_MUHAHA2', GameWAD
+':SOUNDS\MUHAHA2');
2562 g_Sound_CreateWADEx('SOUND_ANNOUNCER_MUHAHA3', GameWAD
+':SOUNDS\MUHAHA3');
2563 g_Sound_CreateWADEx('SOUND_CTF_GET1', GameWAD
+':SOUNDS\GETFLAG1');
2564 g_Sound_CreateWADEx('SOUND_CTF_GET2', GameWAD
+':SOUNDS\GETFLAG2');
2565 g_Sound_CreateWADEx('SOUND_CTF_LOST1', GameWAD
+':SOUNDS\LOSTFLG1');
2566 g_Sound_CreateWADEx('SOUND_CTF_LOST2', GameWAD
+':SOUNDS\LOSTFLG2');
2567 g_Sound_CreateWADEx('SOUND_CTF_RETURN1', GameWAD
+':SOUNDS\RETFLAG1');
2568 g_Sound_CreateWADEx('SOUND_CTF_RETURN2', GameWAD
+':SOUNDS\RETFLAG2');
2569 g_Sound_CreateWADEx('SOUND_CTF_CAPTURE1', GameWAD
+':SOUNDS\CAPFLAG1');
2570 g_Sound_CreateWADEx('SOUND_CTF_CAPTURE2', GameWAD
+':SOUNDS\CAPFLAG2');
2572 goodsnd
[0] := TPlayableSound
.Create();
2573 goodsnd
[1] := TPlayableSound
.Create();
2574 goodsnd
[2] := TPlayableSound
.Create();
2575 goodsnd
[3] := TPlayableSound
.Create();
2577 goodsnd
[0].SetByName('SOUND_ANNOUNCER_GOOD1');
2578 goodsnd
[1].SetByName('SOUND_ANNOUNCER_GOOD2');
2579 goodsnd
[2].SetByName('SOUND_ANNOUNCER_GOOD3');
2580 goodsnd
[3].SetByName('SOUND_ANNOUNCER_GOOD4');
2582 killsnd
[0] := TPlayableSound
.Create();
2583 killsnd
[1] := TPlayableSound
.Create();
2584 killsnd
[2] := TPlayableSound
.Create();
2585 killsnd
[3] := TPlayableSound
.Create();
2587 killsnd
[0].SetByName('SOUND_ANNOUNCER_KILL2X');
2588 killsnd
[1].SetByName('SOUND_ANNOUNCER_KILL3X');
2589 killsnd
[2].SetByName('SOUND_ANNOUNCER_KILL4X');
2590 killsnd
[3].SetByName('SOUND_ANNOUNCER_KILLMX');
2592 hahasnd
[0] := TPlayableSound
.Create();
2593 hahasnd
[1] := TPlayableSound
.Create();
2594 hahasnd
[2] := TPlayableSound
.Create();
2596 hahasnd
[0].SetByName('SOUND_ANNOUNCER_MUHAHA1');
2597 hahasnd
[1].SetByName('SOUND_ANNOUNCER_MUHAHA2');
2598 hahasnd
[2].SetByName('SOUND_ANNOUNCER_MUHAHA3');
2600 sound_get_flag
[0] := TPlayableSound
.Create();
2601 sound_get_flag
[1] := TPlayableSound
.Create();
2602 sound_lost_flag
[0] := TPlayableSound
.Create();
2603 sound_lost_flag
[1] := TPlayableSound
.Create();
2604 sound_ret_flag
[0] := TPlayableSound
.Create();
2605 sound_ret_flag
[1] := TPlayableSound
.Create();
2606 sound_cap_flag
[0] := TPlayableSound
.Create();
2607 sound_cap_flag
[1] := TPlayableSound
.Create();
2609 sound_get_flag
[0].SetByName('SOUND_CTF_GET1');
2610 sound_get_flag
[1].SetByName('SOUND_CTF_GET2');
2611 sound_lost_flag
[0].SetByName('SOUND_CTF_LOST1');
2612 sound_lost_flag
[1].SetByName('SOUND_CTF_LOST2');
2613 sound_ret_flag
[0].SetByName('SOUND_CTF_RETURN1');
2614 sound_ret_flag
[1].SetByName('SOUND_CTF_RETURN2');
2615 sound_cap_flag
[0].SetByName('SOUND_CTF_CAPTURE1');
2616 sound_cap_flag
[1].SetByName('SOUND_CTF_CAPTURE2');
2618 g_Game_LoadChatSounds(GameWAD
+':CHATSND\SNDCFG');
2620 g_Game_SetLoadingText(_lc
[I_LOAD_ITEMS_DATA
], 0, False);
2623 g_Game_SetLoadingText(_lc
[I_LOAD_WEAPONS_DATA
], 0, False);
2624 g_Weapon_LoadData();
2626 g_Monsters_LoadData();
2631 procedure g_Game_FreeData();
2633 if not DataLoaded
then Exit
;
2636 g_Weapon_FreeData();
2637 g_Monsters_FreeData();
2639 e_WriteLog('Releasing game data...', TMsgType
.Notify
);
2641 g_Texture_Delete('NOTEXTURE');
2642 g_Texture_Delete('TEXTURE_PLAYER_HUD');
2643 g_Texture_Delete('TEXTURE_PLAYER_HUDBG');
2644 g_Texture_Delete('TEXTURE_PLAYER_ARMORHUD');
2645 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG');
2646 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG_S');
2647 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG_D');
2648 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG');
2649 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG_S');
2650 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG_D');
2651 g_Texture_Delete('TEXTURE_PLAYER_TALKBUBBLE');
2652 g_Texture_Delete('TEXTURE_PLAYER_INVULPENTA');
2653 g_Frames_DeleteByName('FRAMES_TELEPORT');
2654 g_Frames_DeleteByName('FRAMES_PUNCH');
2655 g_Frames_DeleteByName('FRAMES_PUNCH_UP');
2656 g_Frames_DeleteByName('FRAMES_PUNCH_DN');
2657 g_Frames_DeleteByName('FRAMES_PUNCH_BERSERK');
2658 g_Frames_DeleteByName('FRAMES_PUNCH_BERSERK_UP');
2659 g_Frames_DeleteByName('FRAMES_PUNCH_BERSERK_DN');
2660 g_Sound_Delete('SOUND_GAME_TELEPORT');
2661 g_Sound_Delete('SOUND_GAME_NOTELEPORT');
2662 g_Sound_Delete('SOUND_GAME_SECRET');
2663 g_Sound_Delete('SOUND_GAME_DOOROPEN');
2664 g_Sound_Delete('SOUND_GAME_DOORCLOSE');
2665 g_Sound_Delete('SOUND_GAME_BULK1');
2666 g_Sound_Delete('SOUND_GAME_BULK2');
2667 g_Sound_Delete('SOUND_GAME_BUBBLE1');
2668 g_Sound_Delete('SOUND_GAME_BUBBLE2');
2669 g_Sound_Delete('SOUND_GAME_BURNING');
2670 g_Sound_Delete('SOUND_GAME_SWITCH1');
2671 g_Sound_Delete('SOUND_GAME_SWITCH0');
2678 g_Sound_Delete('SOUND_ANNOUNCER_GOOD1');
2679 g_Sound_Delete('SOUND_ANNOUNCER_GOOD2');
2680 g_Sound_Delete('SOUND_ANNOUNCER_GOOD3');
2681 g_Sound_Delete('SOUND_ANNOUNCER_GOOD4');
2688 g_Sound_Delete('SOUND_ANNOUNCER_KILL2X');
2689 g_Sound_Delete('SOUND_ANNOUNCER_KILL3X');
2690 g_Sound_Delete('SOUND_ANNOUNCER_KILL4X');
2691 g_Sound_Delete('SOUND_ANNOUNCER_KILLMX');
2697 g_Sound_Delete('SOUND_ANNOUNCER_MUHAHA1');
2698 g_Sound_Delete('SOUND_ANNOUNCER_MUHAHA2');
2699 g_Sound_Delete('SOUND_ANNOUNCER_MUHAHA3');
2701 sound_get_flag
[0].Free();
2702 sound_get_flag
[1].Free();
2703 sound_lost_flag
[0].Free();
2704 sound_lost_flag
[1].Free();
2705 sound_ret_flag
[0].Free();
2706 sound_ret_flag
[1].Free();
2707 sound_cap_flag
[0].Free();
2708 sound_cap_flag
[1].Free();
2710 g_Sound_Delete('SOUND_CTF_GET1');
2711 g_Sound_Delete('SOUND_CTF_GET2');
2712 g_Sound_Delete('SOUND_CTF_LOST1');
2713 g_Sound_Delete('SOUND_CTF_LOST2');
2714 g_Sound_Delete('SOUND_CTF_RETURN1');
2715 g_Sound_Delete('SOUND_CTF_RETURN2');
2716 g_Sound_Delete('SOUND_CTF_CAPTURE1');
2717 g_Sound_Delete('SOUND_CTF_CAPTURE2');
2719 g_Game_FreeChatSounds();
2721 DataLoaded
:= False;
2724 procedure DrawCustomStat();
2730 ww2
, hh2
, r
, g
, b
, rr
, gg
, bb
: Byte;
2731 s1
, s2
, topstr
: String;
2733 e_TextureFontGetSize(gStdFont
, ww2
, hh2
);
2737 if g_Console_Action(ACTION_SCORES
) then
2739 if not gStatsPressed
then
2741 gStatsOff
:= not gStatsOff
;
2742 gStatsPressed
:= True;
2746 gStatsPressed
:= False;
2750 s1
:= _lc
[I_MENU_INTER_NOTICE_TAB
];
2751 w
:= (Length(s1
) * ww2
) div 2;
2752 x
:= gScreenWidth
div 2 - w
;
2754 e_TextureFontPrint(x
, y
, s1
, gStdFont
);
2758 if (gGameSettings
.GameMode
= GM_COOP
) then
2760 if gMissionFailed
then
2761 topstr
:= _lc
[I_MENU_INTER_MISSION_FAIL
]
2763 topstr
:= _lc
[I_MENU_INTER_LEVEL_COMPLETE
];
2766 topstr
:= _lc
[I_MENU_INTER_ROUND_OVER
];
2768 e_CharFont_GetSize(gMenuFont
, topstr
, ww1
, hh1
);
2769 e_CharFont_Print(gMenuFont
, (gScreenWidth
div 2)-(ww1
div 2), 16, topstr
);
2771 if g_Game_IsNet
then
2773 topstr
:= Format(_lc
[I_MENU_INTER_NOTICE_TIME
], [gServInterTime
]);
2774 if not gChatShow
then
2775 e_TextureFontPrintEx((gScreenWidth
div 2)-(Length(topstr
)*ww2
div 2),
2776 gScreenHeight
-(hh2
+4)*2, topstr
, gStdFont
, 255, 255, 255, 1);
2779 if g_Game_IsClient
then
2780 topstr
:= _lc
[I_MENU_INTER_NOTICE_MAP
]
2782 topstr
:= _lc
[I_MENU_INTER_NOTICE_SPACE
];
2783 if not gChatShow
then
2784 e_TextureFontPrintEx((gScreenWidth
div 2)-(Length(topstr
)*ww2
div 2),
2785 gScreenHeight
-(hh2
+4), topstr
, gStdFont
, 255, 255, 255, 1);
2790 w
:= gScreenWidth
-x
*2;
2796 e_DrawFillQuad(x
, y
, gScreenWidth
-x
-1, gScreenHeight
-y
-1, 64, 64, 64, 32);
2797 e_DrawQuad(x
, y
, gScreenWidth
-x
-1, gScreenHeight
-y
-1, 255, 127, 0);
2799 m
:= Max(Length(_lc
[I_MENU_MAP
])+1, Length(_lc
[I_GAME_GAME_TIME
])+1)*ww2
;
2801 case CustomStat
.GameMode
of
2804 if gGameSettings
.MaxLives
= 0 then
2805 s1
:= _lc
[I_GAME_DM
]
2807 s1
:= _lc
[I_GAME_LMS
];
2811 if gGameSettings
.MaxLives
= 0 then
2812 s1
:= _lc
[I_GAME_TDM
]
2814 s1
:= _lc
[I_GAME_TLMS
];
2816 GM_CTF
: s1
:= _lc
[I_GAME_CTF
];
2819 if gGameSettings
.MaxLives
= 0 then
2820 s1
:= _lc
[I_GAME_COOP
]
2822 s1
:= _lc
[I_GAME_SURV
];
2828 e_TextureFontPrintEx(x
+(w
div 2)-(Length(s1
)*ww2
div 2), _y
, s1
, gStdFont
, 255, 255, 255, 1);
2832 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_MENU_MAP
], gStdFont
, 255, 127, 0, 1);
2833 e_TextureFontPrint(x
+8+m
, _y
, Format('%s - %s', [CustomStat
.Map
, CustomStat
.MapName
]), gStdFont
);
2836 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_GAME_TIME
], gStdFont
, 255, 127, 0, 1);
2837 e_TextureFontPrint(x
+8+m
, _y
, Format('%d:%.2d:%.2d', [CustomStat
.GameTime
div 1000 div 3600,
2838 (CustomStat
.GameTime
div 1000 div 60) mod 60,
2839 CustomStat
.GameTime
div 1000 mod 60]), gStdFont
);
2841 pc
:= Length(CustomStat
.PlayerStat
);
2842 if pc
= 0 then Exit
;
2844 if CustomStat
.GameMode
= GM_COOP
then
2846 m
:= Max(Length(_lc
[I_GAME_MONSTERS
])+1, Length(_lc
[I_GAME_SECRETS
])+1)*ww2
;
2848 s2
:= _lc
[I_GAME_MONSTERS
];
2849 e_TextureFontPrintEx(x
+8, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2850 e_TextureFontPrintEx(x
+8+m
, _y
, IntToStr(gCoopMonstersKilled
) + '/' + IntToStr(gTotalMonsters
), gStdFont
, 255, 255, 255, 1);
2852 s2
:= _lc
[I_GAME_SECRETS
];
2853 e_TextureFontPrintEx(x
+8, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2854 e_TextureFontPrintEx(x
+8+m
, _y
, IntToStr(gCoopSecretsFound
) + '/' + IntToStr(gSecretsCount
), gStdFont
, 255, 255, 255, 1);
2857 m
:= Max(Length(_lc
[I_GAME_MONSTERS_TOTAL
])+1, Length(_lc
[I_GAME_SECRETS_TOTAL
])+1)*ww2
;
2859 s2
:= _lc
[I_GAME_MONSTERS_TOTAL
];
2860 e_TextureFontPrintEx(x
+250, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2861 e_TextureFontPrintEx(x
+250+m
, _y
, IntToStr(gCoopTotalMonstersKilled
) + '/' + IntToStr(gCoopTotalMonsters
), gStdFont
, 255, 255, 255, 1);
2863 s2
:= _lc
[I_GAME_SECRETS_TOTAL
];
2864 e_TextureFontPrintEx(x
+250, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2865 e_TextureFontPrintEx(x
+250+m
, _y
, IntToStr(gCoopTotalSecretsFound
) + '/' + IntToStr(gCoopTotalSecrets
), gStdFont
, 255, 255, 255, 1);
2869 if CustomStat
.GameMode
in [GM_TDM
, GM_CTF
] then
2874 if TeamStat
[TEAM_RED
].Score
> TeamStat
[TEAM_BLUE
].Score
then s1
:= _lc
[I_GAME_WIN_RED
]
2875 else if TeamStat
[TEAM_BLUE
].Score
> TeamStat
[TEAM_RED
].Score
then s1
:= _lc
[I_GAME_WIN_BLUE
]
2876 else s1
:= _lc
[I_GAME_WIN_DRAW
];
2878 e_TextureFontPrintEx(x
+8+(w
div 2)-(Length(s1
)*ww2
div 2), _y
, s1
, gStdFont
, 255, 255, 255, 1);
2881 for t
:= TEAM_RED
to TEAM_BLUE
do
2883 if t
= TEAM_RED
then
2885 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_TEAM_RED
],
2886 gStdFont
, 255, 0, 0, 1);
2887 e_TextureFontPrintEx(x
+w1
+8, _y
, IntToStr(CustomStat
.TeamStat
[TEAM_RED
].Score
),
2888 gStdFont
, 255, 0, 0, 1);
2895 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_TEAM_BLUE
],
2896 gStdFont
, 0, 0, 255, 1);
2897 e_TextureFontPrintEx(x
+w1
+8, _y
, IntToStr(CustomStat
.TeamStat
[TEAM_BLUE
].Score
),
2898 gStdFont
, 0, 0, 255, 1);
2904 e_DrawLine(1, x
+8, _y
+20, x
-8+w
, _y
+20, r
, g
, b
);
2907 for p
:= 0 to High(CustomStat
.PlayerStat
) do
2908 if CustomStat
.PlayerStat
[p
].Team
= t
then
2909 with CustomStat
.PlayerStat
[p
] do
2923 if (gPlayers
[Num
] <> nil) and (gPlayers
[Num
].FReady
) then
2924 e_TextureFontPrintEx(x
+16, _y
, Name
+ ' *', gStdFont
, rr
, gg
, bb
, 1)
2926 e_TextureFontPrintEx(x
+16, _y
, Name
, gStdFont
, rr
, gg
, bb
, 1);
2927 e_TextureFontPrintEx(x
+w1
+16, _y
, IntToStr(Frags
), gStdFont
, rr
, gg
, bb
, 1);
2928 e_TextureFontPrintEx(x
+w1
+72, _y
, IntToStr(Assists
), gStdFont
, rr
, gg
, bb
, 1);
2929 e_TextureFontPrintEx(x
+w1
+w2
+16, _y
, IntToStr(Deaths
), gStdFont
, rr
, gg
, bb
, 1);
2936 else if CustomStat
.GameMode
in [GM_DM
, GM_COOP
] then
2939 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_PLAYER_NAME
], gStdFont
, 255, 127, 0, 1);
2940 e_TextureFontPrintEx(x
+8+w1
, _y
, _lc
[I_GAME_FRAGS
], gStdFont
, 255, 127, 0, 1);
2941 e_TextureFontPrintEx(x
+8+w1
+w2
, _y
, _lc
[I_GAME_DEATHS
], gStdFont
, 255, 127, 0, 1);
2944 for p
:= 0 to High(CustomStat
.PlayerStat
) do
2945 with CustomStat
.PlayerStat
[p
] do
2947 e_DrawFillQuad(x
+8, _y
+4, x
+24-1, _y
+16+4-1, Color
.R
, Color
.G
, Color
.B
, 0);
2954 if (gPlayers
[Num
] <> nil) and (gPlayers
[Num
].FReady
) then
2955 e_TextureFontPrintEx(x
+8+16+8, _y
+4, Name
+ ' *', gStdFont
, r
, r
, r
, 1, True)
2957 e_TextureFontPrintEx(x
+8+16+8, _y
+4, Name
, gStdFont
, r
, r
, r
, 1, True);
2958 e_TextureFontPrintEx(x
+w1
+8+16+8, _y
+4, IntToStr(Frags
), gStdFont
, r
, r
, r
, 1, True);
2959 e_TextureFontPrintEx(x
+w1
+w2
+8+16+8, _y
+4, IntToStr(Deaths
), gStdFont
, r
, r
, r
, 1, True);
2964 // HACK: take stats screenshot immediately after the first frame of the stats showing
2965 if gScreenshotStats
and (not StatShotDone
) and (Length(CustomStat
.PlayerStat
) > 1) then
2967 g_TakeScreenShot('stats/' + StatFilename
);
2968 StatShotDone
:= True;
2972 procedure DrawSingleStat();
2974 tm
, key_x
, val_x
, y
: Integer;
2978 procedure player_stat(n
: Integer);
2984 s1
:= Format(' %d ', [SingleStat
.PlayerStat
[n
].Kills
]);
2985 s2
:= Format(' %d', [gTotalMonsters
]);
2987 e_CharFont_Print(gMenuFont
, key_x
, y
, _lc
[I_MENU_INTER_KILLS
]);
2988 e_CharFont_PrintEx(gMenuFont
, val_x
, y
, s1
, _RGB(255, 0, 0));
2989 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2990 e_CharFont_Print(gMenuFont
, val_x
+w1
, y
, '/');
2992 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2993 e_CharFont_PrintEx(gMenuFont
, val_x
+w1
, y
, s2
, _RGB(255, 0, 0));
2995 // "Kills-per-minute: ##.#":
2996 s1
:= _lc
[I_MENU_INTER_KPM
];
2998 kpm
:= (SingleStat
.PlayerStat
[n
].Kills
/ tm
) * 60
3000 kpm
:= SingleStat
.PlayerStat
[n
].Kills
;
3001 s2
:= Format(' %.1f', [kpm
]);
3003 e_CharFont_Print(gMenuFont
, key_x
, y
+32, s1
);
3004 e_CharFont_PrintEx(gMenuFont
, val_x
, y
+32, s2
, _RGB(255, 0, 0));
3006 // "Secrets found: # / #":
3007 s1
:= Format(' %d ', [SingleStat
.PlayerStat
[n
].Secrets
]);
3008 s2
:= Format(' %d', [SingleStat
.TotalSecrets
]);
3010 e_CharFont_Print(gMenuFont
, key_x
, y
+64, _lc
[I_MENU_INTER_SECRETS
]);
3011 e_CharFont_PrintEx(gMenuFont
, val_x
, y
+64, s1
, _RGB(255, 0, 0));
3012 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
3013 e_CharFont_Print(gMenuFont
, val_x
+w1
, y
+64, '/');
3015 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
3016 e_CharFont_PrintEx(gMenuFont
, val_x
+w1
, y
+64, s2
, _RGB(255, 0, 0));
3020 // "Level Complete":
3021 e_CharFont_GetSize(gMenuFont
, _lc
[I_MENU_INTER_LEVEL_COMPLETE
], w1
, h
);
3022 e_CharFont_Print(gMenuFont
, (gScreenWidth
-w1
) div 2, 32, _lc
[I_MENU_INTER_LEVEL_COMPLETE
]);
3024 // Îïðåäåëÿåì êîîðäèíàòû âûðàâíèâàíèÿ ïî ñàìîé äëèííîé ñòðîêå:
3025 s1
:= _lc
[I_MENU_INTER_KPM
];
3026 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
3029 e_CharFont_GetSize(gMenuFont
, s1
, w2
, h
);
3031 key_x
:= (gScreenWidth
-w1
-w2
) div 2;
3032 val_x
:= key_x
+ w1
;
3035 tm
:= SingleStat
.GameTime
div 1000;
3036 s1
:= _lc
[I_MENU_INTER_TIME
];
3037 s2
:= Format(' %d:%.2d:%.2d', [tm
div (60*60), (tm
mod (60*60)) div 60, tm
mod 60]);
3039 e_CharFont_Print(gMenuFont
, key_x
, 80, s1
);
3040 e_CharFont_PrintEx(gMenuFont
, val_x
, 80, s2
, _RGB(255, 0, 0));
3042 if SingleStat
.TwoPlayers
then
3045 s1
:= _lc
[I_MENU_PLAYER_1
];
3046 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
3047 e_CharFont_Print(gMenuFont
, (gScreenWidth
-w1
) div 2, 128, s1
);
3049 // Ñòàòèñòèêà ïåðâîãî èãðîêà:
3054 s1
:= _lc
[I_MENU_PLAYER_2
];
3055 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
3056 e_CharFont_Print(gMenuFont
, (gScreenWidth
-w1
) div 2, 288, s1
);
3058 // Ñòàòèñòèêà âòîðîãî èãðîêà:
3064 // Ñòàòèñòèêà ïåðâîãî èãðîêà:
3070 procedure DrawLoadingStat();
3071 procedure drawRect (x
, y
, w
, h
: Integer);
3073 if (w
< 1) or (h
< 1) then exit
;
3075 glVertex2f(x
+0.375, y
+0.375);
3076 glVertex2f(x
+w
+0.375, y
+0.375);
3077 glVertex2f(x
+w
+0.375, y
+h
+0.375);
3078 glVertex2f(x
+0.375, y
+h
+0.375);
3082 function drawPBar (cur
, total
: Integer; washere
: Boolean): Boolean;
3084 rectW
, rectH
: Integer;
3091 idl
, idr
, idb
, idm
: LongWord;
3095 if (total
< 1) then exit
;
3096 if (cur
< 1) then exit
; // don't blink
3097 if (not washere
) and (cur
>= total
) then exit
; // don't blink
3098 //if (cur < 0) then cur := 0;
3099 //if (cur > total) then cur := total;
3102 if (hasPBarGfx
) then
3104 g_Texture_Get('UI_GFX_PBAR_LEFT', idl
);
3105 g_Texture_GetSize('UI_GFX_PBAR_LEFT', wl
, hl
);
3106 g_Texture_Get('UI_GFX_PBAR_RIGHT', idr
);
3107 g_Texture_GetSize('UI_GFX_PBAR_RIGHT', wr
, hr
);
3108 g_Texture_Get('UI_GFX_PBAR_MIDDLE', idb
);
3109 g_Texture_GetSize('UI_GFX_PBAR_MIDDLE', wb
, hb
);
3110 g_Texture_Get('UI_GFX_PBAR_MARKER', idm
);
3111 g_Texture_GetSize('UI_GFX_PBAR_MARKER', wm
, hm
);
3113 //rectW := gScreenWidth-360;
3114 rectW
:= trunc(624.0*gScreenWidth
/1024.0);
3117 x0
:= (gScreenWidth
-rectW
) div 2;
3118 y0
:= gScreenHeight
-rectH
-64;
3119 if (y0
< 2) then y0
:= 2;
3121 glEnable(GL_SCISSOR_TEST
);
3124 glScissor(x0
, gScreenHeight
-y0
-rectH
, rectW
, rectH
);
3125 e_DrawSize(idl
, x0
, y0
, 0, true, false, wl
, hl
);
3126 e_DrawSize(idr
, x0
+rectW
-wr
, y0
, 0, true, false, wr
, hr
);
3129 glScissor(x0
+wl
, gScreenHeight
-y0
-rectH
, rectW
-wl
-wr
, rectH
);
3131 while (f
< x0
+rectW
) do
3133 e_DrawSize(idb
, f
, y0
, 0, true, false, wb
, hb
);
3138 wdt
:= (rectW
-wl
-wr
)*cur
div total
;
3139 if (wdt
> rectW
-wl
-wr
) then wdt
:= rectW
-wr
-wr
;
3142 my
:= y0
; // don't be so smart, ketmar: +(rectH-wm) div 2;
3143 glScissor(x0
+wl
, gScreenHeight
-my
-rectH
, wdt
, hm
);
3147 e_DrawSize(idm
, f
, y0
, 0, true, false, wm
, hm
);
3153 glScissor(0, 0, gScreenWidth
, gScreenHeight
);
3157 rectW
:= gScreenWidth
-64;
3160 x0
:= (gScreenWidth
-rectW
) div 2;
3161 y0
:= gScreenHeight
-rectH
-64;
3162 if (y0
< 2) then y0
:= 2;
3164 glDisable(GL_BLEND
);
3165 glDisable(GL_TEXTURE_2D
);
3167 //glClearColor(0, 0, 0, 0);
3168 //glClear(GL_COLOR_BUFFER_BIT);
3170 glColor4ub(127, 127, 127, 255);
3171 drawRect(x0
-2, y0
-2, rectW
+4, rectH
+4);
3173 glColor4ub(0, 0, 0, 255);
3174 drawRect(x0
-1, y0
-1, rectW
+2, rectH
+2);
3176 glColor4ub(127, 127, 127, 255);
3177 wdt
:= rectW
*cur
div total
;
3178 if (wdt
> rectW
) then wdt
:= rectW
;
3179 drawRect(x0
, y0
, wdt
, rectH
);
3188 if (Length(LoadingStat
.Msgs
) = 0) then exit
;
3190 e_CharFont_GetSize(gMenuFont
, _lc
[I_MENU_LOADING
], ww
, hh
);
3191 yy
:= (gScreenHeight
div 3);
3192 e_CharFont_Print(gMenuFont
, (gScreenWidth
div 2)-(ww
div 2), yy
-2*hh
, _lc
[I_MENU_LOADING
]);
3193 xx
:= (gScreenWidth
div 3);
3197 for i
:= 0 to NextMsg
-1 do
3199 if (i
= (NextMsg
-1)) and (MaxValue
> 0) then
3200 s
:= Format('%s: %d/%d', [Msgs
[i
], CurValue
, MaxValue
])
3204 e_CharFont_PrintEx(gMenuSmallFont
, xx
, yy
, s
, _RGB(255, 0, 0));
3205 yy
:= yy
+ LOADING_INTERLINE
;
3206 PBarWasHere
:= drawPBar(CurValue
, MaxValue
, PBarWasHere
);
3211 procedure DrawMenuBackground(tex
: AnsiString);
3217 if g_Texture_Get(tex
, ID
) then
3219 e_Clear(GL_COLOR_BUFFER_BIT
, 0, 0, 0);
3220 e_GetTextureSize(ID
, @w
, @h
);
3222 w
:= round(w
* 1.333 * (gScreenHeight
/ h
))
3224 w
:= trunc(w
* (gScreenHeight
/ h
));
3225 e_DrawSize(ID
, (gScreenWidth
- w
) div 2, 0, 0, False, False, w
, gScreenHeight
);
3227 else e_Clear(GL_COLOR_BUFFER_BIT
, 0, 0, 0);
3230 procedure DrawMinimap(p
: TPlayer
; RenderRect
: e_graphics
.TRect
);
3232 a
, aX
, aY
, aX2
, aY2
, Scale
, ScaleSz
: Integer;
3234 function monDraw (mon
: TMonster
): Boolean;
3236 result
:= false; // don't stop
3241 // Ëåâûé âåðõíèé óãîë
3242 aX
:= Obj
.X
div ScaleSz
+ 1;
3243 aY
:= Obj
.Y
div ScaleSz
+ 1;
3245 aX2
:= max(Obj
.Rect
.Width
div ScaleSz
, 1);
3246 aY2
:= max(Obj
.Rect
.Height
div ScaleSz
, 1);
3247 // Ïðàâûé íèæíèé óãîë
3248 aX2
:= aX
+ aX2
- 1;
3249 aY2
:= aY
+ aY2
- 1;
3250 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 255, 0, 0);
3256 if (gMapInfo
.Width
> RenderRect
.Right
- RenderRect
.Left
) or
3257 (gMapInfo
.Height
> RenderRect
.Bottom
- RenderRect
.Top
) then
3260 // Ñêîëüêî ïèêñåëîâ êàðòû â 1 ïèêñåëå ìèíè-êàðòû:
3261 ScaleSz
:= 16 div Scale
;
3262 // Ðàçìåðû ìèíè-êàðòû:
3263 aX
:= max(gMapInfo
.Width
div ScaleSz
, 1);
3264 aY
:= max(gMapInfo
.Height
div ScaleSz
, 1);
3266 e_DrawFillQuad(0, 0, aX
-1, aY
-1, 0, 0, 0, 0);
3268 if gWalls
<> nil then
3271 for a
:= 0 to High(gWalls
) do
3273 if PanelType
<> 0 then
3275 // Ëåâûé âåðõíèé óãîë:
3276 aX
:= X
div ScaleSz
;
3277 aY
:= Y
div ScaleSz
;
3279 aX2
:= max(Width
div ScaleSz
, 1);
3280 aY2
:= max(Height
div ScaleSz
, 1);
3281 // Ïðàâûé íèæíèé óãîë:
3282 aX2
:= aX
+ aX2
- 1;
3283 aY2
:= aY
+ aY2
- 1;
3286 PANEL_WALL
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 208, 208, 208, 0);
3287 PANEL_OPENDOOR
, PANEL_CLOSEDOOR
:
3288 if Enabled
then e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 160, 160, 160, 0);
3292 if gSteps
<> nil then
3295 for a
:= 0 to High(gSteps
) do
3297 if PanelType
<> 0 then
3299 // Ëåâûé âåðõíèé óãîë:
3300 aX
:= X
div ScaleSz
;
3301 aY
:= Y
div ScaleSz
;
3303 aX2
:= max(Width
div ScaleSz
, 1);
3304 aY2
:= max(Height
div ScaleSz
, 1);
3305 // Ïðàâûé íèæíèé óãîë:
3306 aX2
:= aX
+ aX2
- 1;
3307 aY2
:= aY
+ aY2
- 1;
3309 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 128, 128, 128, 0);
3312 if gLifts
<> nil then
3315 for a
:= 0 to High(gLifts
) do
3317 if PanelType
<> 0 then
3319 // Ëåâûé âåðõíèé óãîë:
3320 aX
:= X
div ScaleSz
;
3321 aY
:= Y
div ScaleSz
;
3323 aX2
:= max(Width
div ScaleSz
, 1);
3324 aY2
:= max(Height
div ScaleSz
, 1);
3325 // Ïðàâûé íèæíèé óãîë:
3326 aX2
:= aX
+ aX2
- 1;
3327 aY2
:= aY
+ aY2
- 1;
3330 LIFTTYPE_UP
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 116, 72, 36, 0);
3331 LIFTTYPE_DOWN
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 116, 124, 96, 0);
3332 LIFTTYPE_LEFT
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 200, 80, 4, 0);
3333 LIFTTYPE_RIGHT
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 252, 140, 56, 0);
3337 if gWater
<> nil then
3340 for a
:= 0 to High(gWater
) do
3342 if PanelType
<> 0 then
3344 // Ëåâûé âåðõíèé óãîë:
3345 aX
:= X
div ScaleSz
;
3346 aY
:= Y
div ScaleSz
;
3348 aX2
:= max(Width
div ScaleSz
, 1);
3349 aY2
:= max(Height
div ScaleSz
, 1);
3350 // Ïðàâûé íèæíèé óãîë:
3351 aX2
:= aX
+ aX2
- 1;
3352 aY2
:= aY
+ aY2
- 1;
3354 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 0, 192, 0);
3357 if gAcid1
<> nil then
3359 // Ðèñóåì êèñëîòó 1:
3360 for a
:= 0 to High(gAcid1
) do
3362 if PanelType
<> 0 then
3364 // Ëåâûé âåðõíèé óãîë:
3365 aX
:= X
div ScaleSz
;
3366 aY
:= Y
div ScaleSz
;
3368 aX2
:= max(Width
div ScaleSz
, 1);
3369 aY2
:= max(Height
div ScaleSz
, 1);
3370 // Ïðàâûé íèæíèé óãîë:
3371 aX2
:= aX
+ aX2
- 1;
3372 aY2
:= aY
+ aY2
- 1;
3374 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 176, 0, 0);
3377 if gAcid2
<> nil then
3379 // Ðèñóåì êèñëîòó 2:
3380 for a
:= 0 to High(gAcid2
) do
3382 if PanelType
<> 0 then
3384 // Ëåâûé âåðõíèé óãîë:
3385 aX
:= X
div ScaleSz
;
3386 aY
:= Y
div ScaleSz
;
3388 aX2
:= max(Width
div ScaleSz
, 1);
3389 aY2
:= max(Height
div ScaleSz
, 1);
3390 // Ïðàâûé íèæíèé óãîë:
3391 aX2
:= aX
+ aX2
- 1;
3392 aY2
:= aY
+ aY2
- 1;
3394 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 176, 0, 0, 0);
3397 if gPlayers
<> nil then
3400 for a
:= 0 to High(gPlayers
) do
3401 if gPlayers
[a
] <> nil then with gPlayers
[a
] do
3403 // Ëåâûé âåðõíèé óãîë:
3404 aX
:= Obj
.X
div ScaleSz
+ 1;
3405 aY
:= Obj
.Y
div ScaleSz
+ 1;
3407 aX2
:= max(Obj
.Rect
.Width
div ScaleSz
, 1);
3408 aY2
:= max(Obj
.Rect
.Height
div ScaleSz
, 1);
3409 // Ïðàâûé íèæíèé óãîë:
3410 aX2
:= aX
+ aX2
- 1;
3411 aY2
:= aY
+ aY2
- 1;
3413 if gPlayers
[a
] = p
then
3414 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 255, 0, 0)
3417 TEAM_RED
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 0, 0, 0);
3418 TEAM_BLUE
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 0, 255, 0);
3419 else e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 128, 0, 0);
3424 g_Mons_ForEach(monDraw
);
3429 procedure renderAmbientQuad (hasAmbient
: Boolean; constref ambColor
: TDFColor
);
3431 if not hasAmbient
then exit
;
3432 e_AmbientQuad(sX
, sY
, sWidth
, sHeight
, ambColor
.r
, ambColor
.g
, ambColor
.b
, ambColor
.a
);
3436 // setup sX, sY, sWidth, sHeight, and transformation matrix before calling this!
3437 //FIXME: broken for splitscreen mode
3438 procedure renderDynLightsInternal ();
3440 //hasAmbient: Boolean;
3441 //ambColor: TDFColor;
3443 lx
, ly
, lrad
: Integer;
3444 scxywh
: array[0..3] of GLint
;
3447 if e_NoGraphics
then exit
;
3449 //TODO: lights should be in separate grid, i think
3450 // but on the other side: grid may be slower for dynlights, as their lifetime is short
3451 if (not gwin_k8_enable_light_experiments
) or (not gwin_has_stencil
) or (g_dynLightCount
< 1) then exit
;
3454 //ambColor := gCurrentMap['light_ambient'].rgba;
3455 //hasAmbient := (not ambColor.isOpaque) or (not ambColor.isBlack);
3457 { // this will multiply incoming color to alpha from framebuffer
3459 glBlendFunc(GL_DST_ALPHA, GL_ONE);
3463 * light rendering: (INVALID!)
3464 * glStencilFunc(GL_EQUAL, 0, $ff);
3466 * glClear(GL_STENCIL_BUFFER_BIT);
3467 * glStencilOp(GL_KEEP, GL_KEEP, GL_INCR);
3468 * draw shadow volume into stencil buffer
3469 * glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); // modify color buffer
3470 * glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); // don't modify stencil buffer
3472 * draw color-less quad with light alpha (WARNING! don't touch color!)
3473 * glEnable(GL_BLEND);
3474 * glBlendFunc(GL_DST_ALPHA, GL_ONE);
3475 * draw all geometry up to and including walls (with alpha-testing, probably) -- this does lighting
3477 wassc
:= (glIsEnabled(GL_SCISSOR_TEST
) <> 0);
3478 if wassc
then glGetIntegerv(GL_SCISSOR_BOX
, @scxywh
[0]) else glGetIntegerv(GL_VIEWPORT
, @scxywh
[0]);
3480 // setup OpenGL parameters
3481 glStencilMask($FFFFFFFF);
3482 glStencilFunc(GL_ALWAYS
, 0, $FFFFFFFF);
3483 glEnable(GL_STENCIL_TEST
);
3484 glEnable(GL_SCISSOR_TEST
);
3485 glClear(GL_STENCIL_BUFFER_BIT
);
3486 glStencilFunc(GL_EQUAL
, 0, $ff);
3488 for lln
:= 0 to g_dynLightCount
-1 do
3490 lx
:= g_dynLights
[lln
].x
;
3491 ly
:= g_dynLights
[lln
].y
;
3492 lrad
:= g_dynLights
[lln
].radius
;
3493 if (lrad
< 3) then continue
;
3495 if (lx
-sX
+lrad
< 0) then continue
;
3496 if (ly
-sY
+lrad
< 0) then continue
;
3497 if (lx
-sX
-lrad
>= gPlayerScreenSize
.X
) then continue
;
3498 if (ly
-sY
-lrad
>= gPlayerScreenSize
.Y
) then continue
;
3500 // set scissor to optimize drawing
3501 if (g_dbg_scale
= 1.0) then
3503 glScissor((lx
-sX
)-lrad
+2, gPlayerScreenSize
.Y
-(ly
-sY
)-lrad
-1+2, lrad
*2-4, lrad
*2-4);
3507 glScissor(0, 0, gScreenWidth
, gScreenHeight
);
3509 // no need to clear stencil buffer, light blitting will do it for us... but only for normal scale
3510 if (g_dbg_scale
<> 1.0) then glClear(GL_STENCIL_BUFFER_BIT
);
3511 glStencilOp(GL_KEEP
, GL_KEEP
, GL_INCR
);
3512 // draw extruded panels
3513 glDisable(GL_TEXTURE_2D
);
3514 glDisable(GL_BLEND
);
3515 glColorMask(GL_FALSE
, GL_FALSE
, GL_FALSE
, GL_FALSE
); // no need to modify color buffer
3516 if (lrad
> 4) then g_Map_DrawPanelShadowVolumes(lx
, ly
, lrad
);
3517 // render light texture
3518 glColorMask(GL_TRUE
, GL_TRUE
, GL_TRUE
, GL_TRUE
); // modify color buffer
3519 glStencilOp(GL_ZERO
, GL_ZERO
, GL_ZERO
); // draw light, and clear stencil buffer
3522 glBlendFunc(GL_SRC_ALPHA
, GL_ONE_MINUS_SRC_ALPHA
);
3523 glEnable(GL_TEXTURE_2D
);
3524 // color and opacity
3525 glColor4f(g_dynLights
[lln
].r
, g_dynLights
[lln
].g
, g_dynLights
[lln
].b
, g_dynLights
[lln
].a
);
3526 glBindTexture(GL_TEXTURE_2D
, g_Texture_Light());
3528 glTexCoord2f(0.0, 0.0); glVertex2i(lx
-lrad
, ly
-lrad
); // top-left
3529 glTexCoord2f(1.0, 0.0); glVertex2i(lx
+lrad
, ly
-lrad
); // top-right
3530 glTexCoord2f(1.0, 1.0); glVertex2i(lx
+lrad
, ly
+lrad
); // bottom-right
3531 glTexCoord2f(0.0, 1.0); glVertex2i(lx
-lrad
, ly
+lrad
); // bottom-left
3536 glDisable(GL_STENCIL_TEST
);
3537 glDisable(GL_BLEND
);
3538 glDisable(GL_SCISSOR_TEST
);
3539 //glScissor(0, 0, sWidth, sHeight);
3541 glScissor(scxywh
[0], scxywh
[1], scxywh
[2], scxywh
[3]);
3542 if wassc
then glEnable(GL_SCISSOR_TEST
) else glDisable(GL_SCISSOR_TEST
);
3546 function fixViewportForScale (): Boolean;
3548 nx0
, ny0
, nw
, nh
: Integer;
3551 if (g_dbg_scale
<> 1.0) then
3554 nx0
:= round(sX
-(gPlayerScreenSize
.X
-(sWidth
*g_dbg_scale
))/2/g_dbg_scale
);
3555 ny0
:= round(sY
-(gPlayerScreenSize
.Y
-(sHeight
*g_dbg_scale
))/2/g_dbg_scale
);
3556 nw
:= round(sWidth
/g_dbg_scale
);
3557 nh
:= round(sHeight
/g_dbg_scale
);
3566 // setup sX, sY, sWidth, sHeight, and transformation matrix before calling this!
3567 // WARNING! this WILL CALL `glTranslatef()`, but won't restore matrices!
3568 procedure renderMapInternal (backXOfs
, backYOfs
: Integer; setTransMatrix
: Boolean);
3570 TDrawCB
= procedure ();
3573 hasAmbient
: Boolean;
3575 doAmbient
: Boolean = false;
3577 procedure drawPanelType (profname
: AnsiString; panType
: DWord
; doDraw
: Boolean);
3582 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin(profname
);
3583 if gdbg_map_use_accel_render
then
3585 tagmask
:= panelTypeToTag(panType
);
3586 while (gDrawPanelList
.count
> 0) do
3588 pan
:= TPanel(gDrawPanelList
.front());
3589 if ((pan
.tag
and tagmask
) = 0) then break
;
3590 if doDraw
then pan
.Draw(doAmbient
, ambColor
);
3591 gDrawPanelList
.popFront();
3596 if doDraw
then g_Map_DrawPanels(panType
, hasAmbient
, ambColor
);
3598 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
3601 procedure drawOther (profname
: AnsiString; cb
: TDrawCB
);
3603 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin(profname
);
3604 if assigned(cb
) then cb();
3605 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
3609 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin('total');
3611 // our accelerated renderer will collect all panels to gDrawPanelList
3612 // we can use panel tag to render level parts (see GridTagXXX in g_map.pas)
3613 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin('collect');
3614 if gdbg_map_use_accel_render
then
3616 g_Map_CollectDrawPanels(sX
, sY
, sWidth
, sHeight
);
3618 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
3620 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin('skyback');
3621 g_Map_DrawBack(backXOfs
, backYOfs
);
3622 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
3624 if setTransMatrix
then
3626 //if (g_dbg_scale <> 1.0) then glTranslatef(0.0, -0.375/2, 0);
3627 glScalef(g_dbg_scale
, g_dbg_scale
, 1.0);
3628 glTranslatef(-sX
, -sY
, 0);
3632 ambColor
:= gCurrentMap
['light_ambient'].rgba
;
3633 hasAmbient
:= (not ambColor
.isOpaque
) or (not ambColor
.isBlack
);
3638 //writeln('color: (', ambColor.r, ',', ambColor.g, ',', ambColor.b, ',', ambColor.a, ')');
3639 glColor4ub(ambColor.r, ambColor.g, ambColor.b, ambColor.a);
3640 glClear(GL_COLOR_BUFFER_BIT);
3643 //writeln('color: (', ambColor.r, ',', ambColor.g, ',', ambColor.b, ',', ambColor.a, ')');
3646 drawPanelType('*back', PANEL_BACK
, g_rlayer_back
);
3647 drawPanelType('*step', PANEL_STEP
, g_rlayer_step
);
3648 drawOther('items', @g_Items_Draw
);
3649 drawOther('weapons', @g_Weapon_Draw
);
3650 drawOther('shells', @g_Player_DrawShells
);
3651 drawOther('drawall', @g_Player_DrawAll
);
3652 drawOther('corpses', @g_Player_DrawCorpses
);
3653 drawPanelType('*wall', PANEL_WALL
, g_rlayer_wall
);
3654 drawOther('monsters', @g_Monsters_Draw
);
3655 drawOther('itemdrop', @g_Items_DrawDrop
);
3656 drawPanelType('*door', PANEL_CLOSEDOOR
, g_rlayer_door
);
3657 drawOther('gfx', @g_GFX_Draw
);
3658 drawOther('flags', @g_Map_DrawFlags
);
3659 drawPanelType('*acid1', PANEL_ACID1
, g_rlayer_acid1
);
3660 drawPanelType('*acid2', PANEL_ACID2
, g_rlayer_acid2
);
3661 drawPanelType('*water', PANEL_WATER
, g_rlayer_water
);
3662 drawOther('dynlights', @renderDynLightsInternal
);
3664 if hasAmbient
{and ((not g_playerLight) or (not gwin_has_stencil) or (g_dynLightCount < 1))} then
3666 renderAmbientQuad(hasAmbient
, ambColor
);
3670 drawPanelType('*fore', PANEL_FORE
, g_rlayer_fore
);
3673 if g_debug_HealthBar
then
3675 g_Monsters_DrawHealth();
3676 g_Player_DrawHealth();
3679 if (profileFrameDraw
<> nil) then profileFrameDraw
.mainEnd(); // map rendering
3683 procedure DrawMapView(x
, y
, w
, h
: Integer);
3690 bx
:= Round(x
/(gMapInfo
.Width
- w
)*(gBackSize
.X
- w
));
3691 by
:= Round(y
/(gMapInfo
.Height
- h
)*(gBackSize
.Y
- h
));
3698 fixViewportForScale();
3699 renderMapInternal(-bx
, -by
, true);
3705 procedure DrawPlayer(p
: TPlayer
);
3707 px
, py
, a
, b
, c
, d
, i
, fX
, fY
: Integer;
3711 if (p
= nil) or (p
.FDummy
) then
3714 g_Map_DrawBack(0, 0);
3719 if (profileFrameDraw
= nil) then profileFrameDraw
:= TProfiler
.Create('RENDER', g_profile_history_size
);
3720 if (profileFrameDraw
<> nil) then profileFrameDraw
.mainBegin(g_profile_frame_draw
);
3726 camObj
:= p
.getCameraObj();
3727 camObj
.lerp(gLerpFactor
, fX
, fY
);
3728 px
:= fX
+ PLAYER_RECT_CX
;
3729 py
:= fY
+ PLAYER_RECT_CY
+nlerp(p
.SlopeOld
, camObj
.slopeUpLeft
, gLerpFactor
);
3731 if (g_dbg_scale
= 1.0) and (not g_dbg_ignore_bounds
) then
3733 if (px
> (gPlayerScreenSize
.X
div 2)) then a
:= -px
+(gPlayerScreenSize
.X
div 2) else a
:= 0;
3734 if (py
> (gPlayerScreenSize
.Y
div 2)) then b
:= -py
+(gPlayerScreenSize
.Y
div 2) else b
:= 0;
3736 if (px
> gMapInfo
.Width
-(gPlayerScreenSize
.X
div 2)) then a
:= -gMapInfo
.Width
+gPlayerScreenSize
.X
;
3737 if (py
> gMapInfo
.Height
-(gPlayerScreenSize
.Y
div 2)) then b
:= -gMapInfo
.Height
+gPlayerScreenSize
.Y
;
3739 if (gMapInfo
.Width
= gPlayerScreenSize
.X
) then a
:= 0
3740 else if (gMapInfo
.Width
< gPlayerScreenSize
.X
) then
3743 a
:= (gPlayerScreenSize
.X
-gMapInfo
.Width
) div 2;
3746 if (gMapInfo
.Height
= gPlayerScreenSize
.Y
) then b
:= 0
3747 else if (gMapInfo
.Height
< gPlayerScreenSize
.Y
) then
3750 b
:= (gPlayerScreenSize
.Y
-gMapInfo
.Height
) div 2;
3755 // scaled, ignore level bounds
3756 a
:= -px
+(gPlayerScreenSize
.X
div 2);
3757 b
:= -py
+(gPlayerScreenSize
.Y
div 2);
3762 sWidth
:= gPlayerScreenSize
.X
;
3763 sHeight
:= gPlayerScreenSize
.Y
;
3764 fixViewportForScale();
3766 i
:= py
- (sY
+ sHeight
div 2);
3767 if (p
.IncCam
> 0) then
3769 // clamp to level bounds
3770 if (sY
- p
.IncCam
< 0) then
3771 p
.IncCam
:= nclamp(sY
, 0, 120);
3772 // clamp around player position
3774 p
.IncCam
:= nclamp(p
.IncCam
, 0, max(0, 120 - i
));
3776 else if (p
.IncCam
< 0) then
3778 // clamp to level bounds
3779 if (sY
+ sHeight
- p
.IncCam
> gMapInfo
.Height
) then
3780 p
.IncCam
:= nclamp(sY
+ sHeight
- gMapInfo
.Height
, -120, 0);
3781 // clamp around player position
3783 p
.IncCam
:= nclamp(p
.IncCam
, min(0, -120 - i
), 0);
3786 sY
:= sY
- nlerp(p
.IncCamOld
, p
.IncCam
, gLerpFactor
);
3788 if (not g_dbg_ignore_bounds
) then
3790 if (sX
+sWidth
> gMapInfo
.Width
) then sX
:= gMapInfo
.Width
-sWidth
;
3791 if (sY
+sHeight
> gMapInfo
.Height
) then sY
:= gMapInfo
.Height
-sHeight
;
3792 if (sX
< 0) then sX
:= 0;
3793 if (sY
< 0) then sY
:= 0;
3796 if (gBackSize
.X
<= gPlayerScreenSize
.X
) or (gMapInfo
.Width
<= sWidth
) then c
:= 0 else c
:= trunc((gBackSize
.X
-gPlayerScreenSize
.X
)*sX
/(gMapInfo
.Width
-sWidth
));
3797 if (gBackSize
.Y
<= gPlayerScreenSize
.Y
) or (gMapInfo
.Height
<= sHeight
) then d
:= 0 else d
:= trunc((gBackSize
.Y
-gPlayerScreenSize
.Y
)*sY
/(gMapInfo
.Height
-sHeight
));
3799 //r_smallmap_h: 0: left; 1: center; 2: right
3800 //r_smallmap_v: 0: top; 1: center; 2: bottom
3802 if (gMapInfo
.Width
= sWidth
) then
3806 else if (gMapInfo
.Width
< sWidth
) then
3808 case r_smallmap_h
of
3809 1: sX
:= -((sWidth
-gMapInfo
.Width
) div 2); // center
3810 2: sX
:= -(sWidth
-gMapInfo
.Width
); // right
3811 else sX
:= 0; // left
3815 if (gMapInfo
.Height
= sHeight
) then
3819 else if (gMapInfo
.Height
< sHeight
) then
3821 case r_smallmap_v
of
3822 1: sY
:= -((sHeight
-gMapInfo
.Height
) div 2); // center
3823 2: sY
:= -(sHeight
-gMapInfo
.Height
); // bottom
3824 else sY
:= 0; // top
3830 p
.viewPortW
:= sWidth
;
3831 p
.viewPortH
:= sHeight
;
3833 {$IFDEF ENABLE_HOLMES}
3834 if (p
= gPlayer1
) then
3836 g_Holmes_plrViewPos(sX
, sY
);
3837 g_Holmes_plrViewSize(sWidth
, sHeight
);
3841 renderMapInternal(-c
, -d
, true);
3843 if (gGameSettings
.GameMode
<> GM_SINGLE
) and (gPlayerIndicator
> 0) then
3844 case gPlayerIndicator
of
3846 p
.DrawIndicator(_RGB(255, 255, 255));
3849 for i
:= 0 to High(gPlayers
) do
3850 if gPlayers
[i
] <> nil then
3851 if gPlayers
[i
] = p
then p
.DrawIndicator(_RGB(255, 255, 255))
3852 else if (gPlayers
[i
].Team
= p
.Team
) and (gPlayers
[i
].Team
<> TEAM_NONE
) then
3853 if gPlayerIndicatorStyle
= 1 then
3854 gPlayers
[i
].DrawIndicator(_RGB(192, 192, 192))
3855 else gPlayers
[i
].DrawIndicator(gPlayers
[i
].GetColor
);
3859 for a := 0 to High(gCollideMap) do
3860 for b := 0 to High(gCollideMap[a]) do
3863 if ByteBool(gCollideMap[a, b] and MARK_WALL) then
3865 if ByteBool(gCollideMap[a, b] and MARK_DOOR) then
3869 1: e_DrawPoint(1, b, a, 200, 200, 200);
3870 2: e_DrawPoint(1, b, a, 64, 64, 255);
3871 3: e_DrawPoint(1, b, a, 255, 0, 255);
3881 if gShowMap
then DrawMinimap(p
, _TRect(0, 0, 128, 128));
3882 if g_Debug_Player
then
3883 g_Player_DrawDebug(p
);
3887 procedure drawProfilers ();
3892 if g_profile_frame_draw
and (profileFrameDraw
<> nil) then px
:= px
-drawProfiles(px
, py
, profileFrameDraw
);
3893 if g_profile_collision
and (profMapCollision
<> nil) then begin px
:= px
-drawProfiles(px
, py
, profMapCollision
); py
-= calcProfilesHeight(profMonsLOS
); end;
3894 if g_profile_los
and (profMonsLOS
<> nil) then begin px
:= px
-drawProfiles(px
, py
, profMonsLOS
); py
-= calcProfilesHeight(profMonsLOS
); end;
3897 procedure g_Game_Draw();
3904 plView1
, plView2
: TPlayer
;
3907 if gExit
= EXIT_QUIT
then Exit
;
3909 Time
:= sys_GetTicks() {div 1000};
3910 FPSCounter
:= FPSCounter
+1;
3911 if Time
- FPSTime
>= 1000 then
3918 e_SetRendertarget(True);
3919 e_SetViewPort(0, 0, gScreenWidth
, gScreenHeight
);
3921 if gGameOn
or (gState
= STATE_FOLD
) then
3923 if (gPlayer1
<> nil) and (gPlayer2
<> nil) then
3925 gSpectMode
:= SPECT_NONE
;
3926 if not gRevertPlayers
then
3928 plView1
:= gPlayer1
;
3929 plView2
:= gPlayer2
;
3933 plView1
:= gPlayer2
;
3934 plView2
:= gPlayer1
;
3938 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
3940 gSpectMode
:= SPECT_NONE
;
3941 if gPlayer2
= nil then
3944 plView1
:= gPlayer2
;
3953 if (plView1
= nil) and (plView2
= nil) and (gSpectMode
= SPECT_NONE
) then
3954 gSpectMode
:= SPECT_STATS
;
3956 if gSpectMode
= SPECT_PLAYERS
then
3957 if gPlayers
<> nil then
3959 plView1
:= GetActivePlayer_ByID(gSpectPID1
);
3960 if plView1
= nil then
3962 gSpectPID1
:= GetActivePlayerID_Next();
3963 plView1
:= GetActivePlayer_ByID(gSpectPID1
);
3965 if gSpectViewTwo
then
3967 plView2
:= GetActivePlayer_ByID(gSpectPID2
);
3968 if plView2
= nil then
3970 gSpectPID2
:= GetActivePlayerID_Next();
3971 plView2
:= GetActivePlayer_ByID(gSpectPID2
);
3976 if gSpectMode
= SPECT_MAPVIEW
then
3978 // Ðåæèì ïðîñìîòðà êàðòû
3980 e_SetViewPort(0, 0, gScreenWidth
, gScreenHeight
);
3981 DrawMapView(gSpectX
, gSpectY
, gScreenWidth
, gScreenHeight
);
3982 gHearPoint1
.Active
:= True;
3983 gHearPoint1
.Coords
.X
:= gScreenWidth
div 2 + gSpectX
;
3984 gHearPoint1
.Coords
.Y
:= gScreenHeight
div 2 + gSpectY
;
3985 gHearPoint2
.Active
:= False;
3989 Split
:= (plView1
<> nil) and (plView2
<> nil);
3991 // Òî÷êè ñëóõà èãðîêîâ
3992 if plView1
<> nil then
3994 gHearPoint1
.Active
:= True;
3995 gHearPoint1
.Coords
.X
:= plView1
.GameX
+ PLAYER_RECT
.Width
;
3996 gHearPoint1
.Coords
.Y
:= plView1
.GameY
+ PLAYER_RECT
.Height
DIV 2;
3998 gHearPoint1
.Active
:= False;
3999 if plView2
<> nil then
4001 gHearPoint2
.Active
:= True;
4002 gHearPoint2
.Coords
.X
:= plView2
.GameX
+ PLAYER_RECT
.Width
;
4003 gHearPoint2
.Coords
.Y
:= plView2
.GameY
+ PLAYER_RECT
.Height
DIV 2;
4005 gHearPoint2
.Active
:= False;
4007 // Ðàçìåð ýêðàíîâ èãðîêîâ:
4008 gPlayerScreenSize
.X
:= gScreenWidth
-196;
4011 gPlayerScreenSize
.Y
:= gScreenHeight
div 2;
4012 if gScreenHeight
mod 2 = 0 then
4013 Dec(gPlayerScreenSize
.Y
);
4016 gPlayerScreenSize
.Y
:= gScreenHeight
;
4019 if gScreenHeight
mod 2 = 0 then
4020 e_SetViewPort(0, gPlayerScreenSize
.Y
+2, gPlayerScreenSize
.X
+196, gPlayerScreenSize
.Y
)
4022 e_SetViewPort(0, gPlayerScreenSize
.Y
+1, gPlayerScreenSize
.X
+196, gPlayerScreenSize
.Y
);
4024 DrawPlayer(plView1
);
4025 gPlayer1ScreenCoord
.X
:= sX
;
4026 gPlayer1ScreenCoord
.Y
:= sY
;
4030 e_SetViewPort(0, 0, gPlayerScreenSize
.X
+196, gPlayerScreenSize
.Y
);
4032 DrawPlayer(plView2
);
4033 gPlayer2ScreenCoord
.X
:= sX
;
4034 gPlayer2ScreenCoord
.Y
:= sY
;
4037 e_SetViewPort(0, 0, gScreenWidth
, gScreenHeight
);
4040 e_DrawLine(2, 0, gScreenHeight
div 2, gScreenWidth
, gScreenHeight
div 2, 0, 0, 0);
4043 {$IFDEF ENABLE_HOLMES}
4045 if (g_holmes_enabled
) then g_Holmes_Draw();
4048 if MessageText
<> '' then
4052 e_CharFont_GetSizeFmt(gMenuFont
, MessageText
, w
, h
);
4054 e_CharFont_PrintFmt(gMenuFont
, (gScreenWidth
div 2)-(w
div 2),
4055 (gScreenHeight
div 2)-(h
div 2), MessageText
)
4057 e_CharFont_PrintFmt(gMenuFont
, (gScreenWidth
div 2)-(w
div 2),
4058 Round(gScreenHeight
/ 2.75)-(h
div 2), MessageText
);
4061 if IsDrawStat
or (gSpectMode
= SPECT_STATS
) then
4064 if gSpectHUD
and (not gChatShow
) and (gSpectMode
<> SPECT_NONE
) and (not gSpectAuto
) then
4066 // Draw spectator GUI
4069 e_TextureFontGetSize(gStdFont
, ww
, hh
);
4072 e_TextureFontPrintEx(0, gScreenHeight
- (hh
+2)*2, 'MODE: Stats', gStdFont
, 255, 255, 255, 1);
4074 e_TextureFontPrintEx(0, gScreenHeight
- (hh
+2)*2, 'MODE: Observe Map', gStdFont
, 255, 255, 255, 1);
4076 e_TextureFontPrintEx(0, gScreenHeight
- (hh
+2)*2, 'MODE: Watch Players', gStdFont
, 255, 255, 255, 1);
4078 e_TextureFontPrintEx(2*ww
, gScreenHeight
- (hh
+2), '< jump >', gStdFont
, 255, 255, 255, 1);
4079 if gSpectMode
= SPECT_STATS
then
4081 e_TextureFontPrintEx(16*ww
, gScreenHeight
- (hh
+2)*2, 'Autoview', gStdFont
, 255, 255, 255, 1);
4082 e_TextureFontPrintEx(16*ww
, gScreenHeight
- (hh
+2), '< fire >', gStdFont
, 255, 255, 255, 1);
4084 if gSpectMode
= SPECT_MAPVIEW
then
4086 e_TextureFontPrintEx(22*ww
, gScreenHeight
- (hh
+2)*2, '[-]', gStdFont
, 255, 255, 255, 1);
4087 e_TextureFontPrintEx(26*ww
, gScreenHeight
- (hh
+2)*2, 'Step ' + IntToStr(gSpectStep
), gStdFont
, 255, 255, 255, 1);
4088 e_TextureFontPrintEx(34*ww
, gScreenHeight
- (hh
+2)*2, '[+]', gStdFont
, 255, 255, 255, 1);
4089 e_TextureFontPrintEx(18*ww
, gScreenHeight
- (hh
+2), '<prev weap>', gStdFont
, 255, 255, 255, 1);
4090 e_TextureFontPrintEx(30*ww
, gScreenHeight
- (hh
+2), '<next weap>', gStdFont
, 255, 255, 255, 1);
4092 if gSpectMode
= SPECT_PLAYERS
then
4094 e_TextureFontPrintEx(22*ww
, gScreenHeight
- (hh
+2)*2, 'Player 1', gStdFont
, 255, 255, 255, 1);
4095 e_TextureFontPrintEx(20*ww
, gScreenHeight
- (hh
+2), '<left/right>', gStdFont
, 255, 255, 255, 1);
4096 if gSpectViewTwo
then
4098 e_TextureFontPrintEx(37*ww
, gScreenHeight
- (hh
+2)*2, 'Player 2', gStdFont
, 255, 255, 255, 1);
4099 e_TextureFontPrintEx(34*ww
, gScreenHeight
- (hh
+2), '<prev w/next w>', gStdFont
, 255, 255, 255, 1);
4100 e_TextureFontPrintEx(52*ww
, gScreenHeight
- (hh
+2)*2, '2x View', gStdFont
, 255, 255, 255, 1);
4101 e_TextureFontPrintEx(51*ww
, gScreenHeight
- (hh
+2), '<up/down>', gStdFont
, 255, 255, 255, 1);
4105 e_TextureFontPrintEx(35*ww
, gScreenHeight
- (hh
+2)*2, '2x View', gStdFont
, 255, 255, 255, 1);
4106 e_TextureFontPrintEx(34*ww
, gScreenHeight
- (hh
+2), '<up/down>', gStdFont
, 255, 255, 255, 1);
4112 if gPauseMain
and gGameOn
and (g_ActiveWindow
= nil) then
4114 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4115 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4117 e_CharFont_GetSize(gMenuFont
, _lc
[I_MENU_PAUSE
], w
, h
);
4118 e_CharFont_Print(gMenuFont
, (gScreenWidth
div 2)-(w
div 2),
4119 (gScreenHeight
div 2)-(h
div 2), _lc
[I_MENU_PAUSE
]);
4124 if (gState
= STATE_MENU
) then
4126 if (g_ActiveWindow
= nil) or (g_ActiveWindow
.BackTexture
= '') then DrawMenuBackground('MENU_BACKGROUND');
4127 // F3 at menu will show game loading dialog
4128 if e_KeyPressed(IK_F3
) then g_Menu_Show_LoadMenu(true);
4129 if (g_ActiveWindow
<> nil) then
4131 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4132 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4136 // F3 at titlepic will show game loading dialog
4137 if e_KeyPressed(IK_F3
) then
4139 g_Menu_Show_LoadMenu(true);
4140 if (g_ActiveWindow
<> nil) then e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4145 if gState
= STATE_FOLD
then
4147 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 0, 0, 0, EndingGameCounter
);
4150 if gState
= STATE_INTERCUSTOM
then
4152 if gLastMap
and (gGameSettings
.GameMode
= GM_COOP
) then
4154 back
:= 'TEXTURE_endpic';
4155 if not g_Texture_Get(back
, ID
) then
4156 back
:= _lc
[I_TEXTURE_ENDPIC
];
4161 DrawMenuBackground(back
);
4165 if g_ActiveWindow
<> nil then
4167 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4168 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4172 if gState
= STATE_INTERSINGLE
then
4174 if EndingGameCounter
> 0 then
4176 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 0, 0, 0, EndingGameCounter
);
4182 DrawMenuBackground(back
);
4186 if g_ActiveWindow
<> nil then
4188 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4189 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4194 if gState
= STATE_ENDPIC
then
4197 if g_Texture_Get('TEXTURE_endpic', ID
) then DrawMenuBackground('TEXTURE_endpic')
4198 else DrawMenuBackground(_lc
[I_TEXTURE_ENDPIC
]);
4200 if g_ActiveWindow
<> nil then
4202 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4203 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4207 if gState
= STATE_SLIST
then
4209 // if g_Texture_Get('MENU_BACKGROUND', ID) then
4211 // e_DrawSize(ID, 0, 0, 0, False, False, gScreenWidth, gScreenHeight);
4212 // //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4214 DrawMenuBackground('MENU_BACKGROUND');
4215 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4216 g_Serverlist_Draw(slCurrent
, slTable
);
4220 if g_ActiveWindow
<> nil then
4224 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
4225 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
4227 g_ActiveWindow
.Draw();
4234 if g_debug_Sounds
and gGameOn
then
4236 for w
:= 0 to High(e_SoundsArray
) do
4237 for h
:= 0 to e_SoundsArray
[w
].nRefs
do
4238 e_DrawPoint(1, w
+100, h
+100, 255, 0, 0);
4243 e_TextureFontPrint(0, 0, Format('FPS: %d', [FPS
]), gStdFont
);
4244 e_TextureFontPrint(0, 16, Format('UPS: %d', [UPS
]), gStdFont
);
4247 if gGameOn
and gShowTime
then
4248 drawTime(gScreenWidth
-72, gScreenHeight
-16);
4250 if gGameOn
then drawProfilers();
4252 // TODO: draw this after the FBO and remap mouse click coordinates
4254 {$IFDEF ENABLE_HOLMES}
4258 // blit framebuffer to screen
4260 e_SetRendertarget(False);
4261 e_SetViewPort(0, 0, gWinSizeX
, gWinSizeY
);
4262 e_BlitFramebuffer(gWinSizeX
, gWinSizeY
);
4264 // draw the overlay stuff on top of it
4269 procedure g_Game_Quit();
4271 g_Game_StopAllSounds(True);
4274 g_PlayerModel_FreeData();
4275 g_Texture_DeleteAll();
4276 g_Frames_DeleteAll();
4278 //g_Menu_Free(); //k8: this segfaults after resolution change; who cares?
4281 if NetInitDone
then g_Net_Free
;
4283 // Íàäî óäàëèòü êàðòó ïîñëå òåñòà:
4284 if gMapToDelete
<> '' then
4285 g_Game_DeleteTestMap();
4291 procedure g_FatalError(Text: String);
4293 g_Console_Add(Format(_lc
[I_FATAL_ERROR
], [Text]), True);
4294 e_WriteLog(Format(_lc
[I_FATAL_ERROR
], [Text]), TMsgType
.Warning
);
4296 gExit
:= EXIT_SIMPLE
;
4297 if gGameOn
then EndGame
;
4300 procedure g_SimpleError(Text: String);
4302 g_Console_Add(Format(_lc
[I_SIMPLE_ERROR
], [Text]), True);
4303 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], [Text]), TMsgType
.Warning
);
4306 procedure g_Game_SetupScreenSize();
4308 RES_FACTOR
= 4.0 / 3.0;
4314 // Ðàçìåð ýêðàíîâ èãðîêîâ:
4315 gPlayerScreenSize
.X
:= gScreenWidth
-196;
4316 if (gPlayer1
<> nil) and (gPlayer2
<> nil) then
4317 gPlayerScreenSize
.Y
:= gScreenHeight
div 2
4319 gPlayerScreenSize
.Y
:= gScreenHeight
;
4321 // Ðàçìåð çàäíåãî ïëàíà:
4322 if BackID
<> DWORD(-1) then
4325 if (gScreenWidth
*s
> gMapInfo
.Width
) or
4326 (gScreenHeight
*s
> gMapInfo
.Height
) then
4328 gBackSize
.X
:= gScreenWidth
;
4329 gBackSize
.Y
:= gScreenHeight
;
4333 e_GetTextureSize(BackID
, @bw
, @bh
);
4334 rf
:= Single(bw
) / Single(bh
);
4335 if (rf
> RES_FACTOR
) then bw
:= Round(Single(bh
) * RES_FACTOR
)
4336 else if (rf
< RES_FACTOR
) then bh
:= Round(Single(bw
) / RES_FACTOR
);
4337 s
:= Max(gScreenWidth
/ bw
, gScreenHeight
/ bh
);
4338 if (s
< 1.0) then s
:= 1.0;
4339 gBackSize
.X
:= Round(bw
*s
);
4340 gBackSize
.Y
:= Round(bh
*s
);
4345 procedure g_Game_ChangeResolution(newWidth
, newHeight
: Word; nowFull
, nowMax
: Boolean);
4347 sys_SetDisplayMode(newWidth
, newHeight
, gBPP
, nowFull
, nowMax
);
4350 procedure g_Game_AddPlayer(Team
: Byte = TEAM_NONE
);
4352 if ((not gGameOn
) and (gState
<> STATE_INTERCUSTOM
))
4353 or (not (gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
])) then
4356 if (gGameSettings
.MaxLives
> 0) and (gLMSRespawn
= LMS_RESPAWN_NONE
) then
4359 if gPlayer1
= nil then
4361 if g_Game_IsClient
then
4363 if NetPlrUID1
> -1 then
4364 MC_SEND_CheatRequest(NET_CHEAT_SPECTATE
);
4368 if not (Team
in [TEAM_RED
, TEAM_BLUE
]) then
4369 Team
:= gPlayer1Settings
.Team
;
4371 // Ñîçäàíèå ïåðâîãî èãðîêà:
4372 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4373 gPlayer1Settings
.Color
,
4375 if gPlayer1
= nil then
4376 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]))
4379 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4380 gPlayer1
.WeapSwitchMode
:= gPlayer1Settings
.WeaponSwitch
;
4381 gPlayer1
.setWeaponPrefs(gPlayer1Settings
.WeaponPreferences
);
4382 gPlayer1
.SwitchToEmpty
:= gPlayer1Settings
.SwitchToEmpty
;
4383 gPlayer1
.SkipFist
:= gPlayer1Settings
.SkipFist
;
4384 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [gPlayer1
.Name
]), True);
4385 if g_Game_IsServer
and g_Game_IsNet
then
4386 MH_SEND_PlayerCreate(gPlayer1
.UID
);
4387 gPlayer1
.Respawn(False, True);
4388 g_Net_Slist_ServerPlayerComes();
4393 if gPlayer2
= nil then
4395 if g_Game_IsClient
then
4397 if NetPlrUID2
> -1 then
4398 gPlayer2
:= g_Player_Get(NetPlrUID2
);
4402 if not (Team
in [TEAM_RED
, TEAM_BLUE
]) then
4403 Team
:= gPlayer2Settings
.Team
;
4405 // Ñîçäàíèå âòîðîãî èãðîêà:
4406 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
4407 gPlayer2Settings
.Color
,
4409 if gPlayer2
= nil then
4410 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]))
4413 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
4414 gPlayer2
.WeapSwitchMode
:= gPlayer2Settings
.WeaponSwitch
;
4415 gPlayer2
.setWeaponPrefs(gPlayer2Settings
.WeaponPreferences
);
4416 gPlayer2
.SwitchToEmpty
:= gPlayer2Settings
.SwitchToEmpty
;
4417 gPlayer2
.SkipFist
:= gPlayer2Settings
.SkipFist
;
4418 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [gPlayer2
.Name
]), True);
4419 if g_Game_IsServer
and g_Game_IsNet
then
4420 MH_SEND_PlayerCreate(gPlayer2
.UID
);
4421 gPlayer2
.Respawn(False, True);
4422 g_Net_Slist_ServerPlayerComes();
4429 procedure g_Game_RemovePlayer();
4433 if ((not gGameOn
) and (gState
<> STATE_INTERCUSTOM
))
4434 or (not (gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
])) then
4439 if g_Game_IsServer
then
4442 Pl
.Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
4443 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [Pl
.Name
]), True);
4444 g_Player_Remove(Pl
.UID
);
4445 g_Net_Slist_ServerPlayerLeaves();
4449 gSpectLatchPID2
:= Pl
.UID
;
4457 if g_Game_IsServer
then
4460 Pl
.Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
4461 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [Pl
.Name
]), True);
4462 g_Player_Remove(Pl
.UID
);
4463 g_Net_Slist_ServerPlayerLeaves();
4466 gSpectLatchPID1
:= Pl
.UID
;
4468 MC_SEND_CheatRequest(NET_CHEAT_SPECTATE
);
4472 g_Net_Slist_ServerPlayerLeaves();
4475 procedure g_Game_Spectate();
4477 g_Game_RemovePlayer();
4478 if gPlayer1
<> nil then
4479 g_Game_RemovePlayer();
4482 procedure g_Game_SpectateCenterView();
4484 gSpectX
:= Max(gMapInfo
.Width
div 2 - gScreenWidth
div 2, 0);
4485 gSpectY
:= Max(gMapInfo
.Height
div 2 - gScreenHeight
div 2, 0);
4488 procedure g_Game_StartSingle(Map
: String; TwoPlayers
: Boolean; nPlayers
: Byte);
4495 e_WriteLog('Starting singleplayer game...', TMsgType
.Notify
);
4497 g_Game_ClearLoading();
4500 FillByte(gGameSettings
, SizeOf(TGameSettings
), 0);
4503 gGameSettings
.GameType
:= GT_SINGLE
;
4504 gGameSettings
.MaxLives
:= 0;
4505 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_ALLOWEXIT
;
4506 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_MONSTERS
;
4507 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_BOTVSMONSTER
;
4508 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_TEAMHITPROJECTILE
;
4509 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_TEAMHITTRACE
;
4510 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_RULEZRANDOM
;
4511 gSwitchGameMode
:= GM_SINGLE
;
4513 gLMSRespawn
:= LMS_RESPAWN_NONE
;
4514 gLMSRespawnTime
:= 0;
4515 gSpectLatchPID1
:= 0;
4516 gSpectLatchPID2
:= 0;
4518 g_Game_ExecuteEvent('ongamestart');
4520 // Óñòàíîâêà ðàçìåðîâ îêîí èãðîêîâ:
4521 g_Game_SetupScreenSize();
4523 // Ñîçäàíèå ïåðâîãî èãðîêà:
4524 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4525 gPlayer1Settings
.Color
,
4526 gPlayer1Settings
.Team
, False));
4527 if gPlayer1
= nil then
4529 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
4533 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4534 gPlayer1
.WeapSwitchMode
:= gPlayer1Settings
.WeaponSwitch
;
4535 gPlayer1
.setWeaponPrefs(gPlayer1Settings
.WeaponPreferences
);
4536 gPlayer1
.SwitchToEmpty
:= gPlayer1Settings
.SwitchToEmpty
;
4537 gPlayer1
.SkipFist
:= gPlayer1Settings
.SkipFist
;
4540 // Ñîçäàíèå âòîðîãî èãðîêà, åñëè åñòü:
4543 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
4544 gPlayer2Settings
.Color
,
4545 gPlayer2Settings
.Team
, False));
4546 if gPlayer2
= nil then
4548 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
4552 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
4553 gPlayer2
.WeapSwitchMode
:= gPlayer2Settings
.WeaponSwitch
;
4554 gPlayer2
.setWeaponPrefs(gPlayer2Settings
.WeaponPreferences
);
4555 gPlayer2
.SwitchToEmpty
:= gPlayer2Settings
.SwitchToEmpty
;
4556 gPlayer2
.SkipFist
:= gPlayer2Settings
.SkipFist
;
4560 // Çàãðóçêà è çàïóñê êàðòû:
4561 if not g_Game_StartMap(false{asMegawad}, MAP
, True) then
4563 if (Pos(':\', Map
) > 0) or (Pos(':/', Map
) > 0) then tmps
:= Map
else tmps
:= gGameSettings
.WAD
+ ':\' + MAP
;
4564 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [tmps
]));
4568 // Íàñòðîéêè èãðîêîâ è áîòîâ:
4572 for i
:= nPl
+1 to nPlayers
do
4573 g_Player_Create(STD_PLAYER_MODEL
, _RGB(0, 0, 0), 0, True);
4576 procedure g_Game_StartCustom(Map
: String; GameMode
: Byte;
4577 TimeLimit
, ScoreLimit
: Word;
4579 Options
: LongWord; nPlayers
: Byte);
4585 e_WriteLog('Starting custom game...', TMsgType
.Notify
);
4587 g_Game_ClearLoading();
4590 gGameSettings
.GameType
:= GT_CUSTOM
;
4591 gGameSettings
.GameMode
:= GameMode
;
4592 gSwitchGameMode
:= GameMode
;
4593 gGameSettings
.TimeLimit
:= TimeLimit
;
4594 gGameSettings
.ScoreLimit
:= ScoreLimit
;
4595 gGameSettings
.MaxLives
:= IfThen(GameMode
= GM_CTF
, 0, MaxLives
);
4596 gGameSettings
.Options
:= Options
;
4598 gCoopTotalMonstersKilled
:= 0;
4599 gCoopTotalSecretsFound
:= 0;
4600 gCoopTotalMonsters
:= 0;
4601 gCoopTotalSecrets
:= 0;
4605 gLMSRespawn
:= LMS_RESPAWN_NONE
;
4606 gLMSRespawnTime
:= 0;
4607 gSpectLatchPID1
:= 0;
4608 gSpectLatchPID2
:= 0;
4610 g_Game_ExecuteEvent('ongamestart');
4612 // Óñòàíîâêà ðàçìåðîâ îêîí èãðîêîâ:
4613 g_Game_SetupScreenSize();
4615 // Ðåæèì íàáëþäàòåëÿ:
4616 if nPlayers
= 0 then
4623 if nPlayers
>= 1 then
4625 // Ñîçäàíèå ïåðâîãî èãðîêà:
4626 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4627 gPlayer1Settings
.Color
,
4628 gPlayer1Settings
.Team
, False));
4629 if gPlayer1
= nil then
4631 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
4635 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4636 gPlayer1
.WeapSwitchMode
:= gPlayer1Settings
.WeaponSwitch
;
4637 gPlayer1
.setWeaponPrefs(gPlayer1Settings
.WeaponPreferences
);
4638 gPlayer1
.SwitchToEmpty
:= gPlayer1Settings
.SwitchToEmpty
;
4639 gPlayer1
.SkipFist
:= gPlayer1Settings
.SkipFist
;
4643 if nPlayers
>= 2 then
4645 // Ñîçäàíèå âòîðîãî èãðîêà:
4646 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
4647 gPlayer2Settings
.Color
,
4648 gPlayer2Settings
.Team
, False));
4649 if gPlayer2
= nil then
4651 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
4655 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
4656 gPlayer2
.WeapSwitchMode
:= gPlayer2Settings
.WeaponSwitch
;
4657 gPlayer2
.setWeaponPrefs(gPlayer2Settings
.WeaponPreferences
);
4658 gPlayer2
.SwitchToEmpty
:= gPlayer2Settings
.SwitchToEmpty
;
4659 gPlayer2
.SkipFist
:= gPlayer2Settings
.SkipFist
;
4663 // Çàãðóçêà è çàïóñê êàðòû:
4664 if not g_Game_StartMap(true{asMegawad}, Map
, True) then
4666 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [Map
]));
4670 // Íåò òî÷åê ïîÿâëåíèÿ:
4671 if (g_Map_GetPointCount(RESPAWNPOINT_PLAYER1
) +
4672 g_Map_GetPointCount(RESPAWNPOINT_PLAYER2
) +
4673 g_Map_GetPointCount(RESPAWNPOINT_DM
) +
4674 g_Map_GetPointCount(RESPAWNPOINT_RED
)+
4675 g_Map_GetPointCount(RESPAWNPOINT_BLUE
)) < 1 then
4677 g_FatalError(_lc
[I_GAME_ERROR_GET_SPAWN
]);
4681 // Íàñòðîéêè èãðîêîâ è áîòîâ:
4685 for i
:= nPl
+1 to nPlayers
do
4686 g_Player_Create(STD_PLAYER_MODEL
, _RGB(0, 0, 0), 0, True);
4689 procedure g_Game_StartServer(Map
: String; GameMode
: Byte;
4690 TimeLimit
, ScoreLimit
: Word; MaxLives
: Byte;
4691 Options
: LongWord; nPlayers
: Byte;
4692 IPAddr
: LongWord; Port
: Word);
4695 g_Net_Slist_ServerClosed();
4697 e_WriteLog('Starting net game (server)...', TMsgType
.Notify
);
4699 g_Game_ClearLoading();
4704 gGameSettings
.GameType
:= GT_SERVER
;
4705 gGameSettings
.GameMode
:= GameMode
;
4706 gSwitchGameMode
:= GameMode
;
4707 gGameSettings
.TimeLimit
:= TimeLimit
;
4708 gGameSettings
.ScoreLimit
:= ScoreLimit
;
4709 gGameSettings
.MaxLives
:= IfThen(GameMode
= GM_CTF
, 0, MaxLives
);
4710 gGameSettings
.Options
:= Options
;
4712 gCoopTotalMonstersKilled
:= 0;
4713 gCoopTotalSecretsFound
:= 0;
4714 gCoopTotalMonsters
:= 0;
4715 gCoopTotalSecrets
:= 0;
4719 gLMSRespawn
:= LMS_RESPAWN_NONE
;
4720 gLMSRespawnTime
:= 0;
4721 gSpectLatchPID1
:= 0;
4722 gSpectLatchPID2
:= 0;
4724 g_Game_ExecuteEvent('ongamestart');
4726 // Óñòàíîâêà ðàçìåðîâ îêíà èãðîêà
4727 g_Game_SetupScreenSize();
4729 // Ðåæèì íàáëþäàòåëÿ:
4730 if nPlayers
= 0 then
4736 if nPlayers
>= 1 then
4738 // Ñîçäàíèå ïåðâîãî èãðîêà:
4739 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4740 gPlayer1Settings
.Color
,
4741 gPlayer1Settings
.Team
, False));
4742 if gPlayer1
= nil then
4744 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
4748 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4749 gPlayer1
.WeapSwitchMode
:= gPlayer1Settings
.WeaponSwitch
;
4750 gPlayer1
.setWeaponPrefs(gPlayer1Settings
.WeaponPreferences
);
4751 gPlayer1
.SwitchToEmpty
:= gPlayer1Settings
.SwitchToEmpty
;
4752 gPlayer1
.SkipFist
:= gPlayer1Settings
.SkipFist
;
4755 if nPlayers
>= 2 then
4757 // Ñîçäàíèå âòîðîãî èãðîêà:
4758 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
4759 gPlayer2Settings
.Color
,
4760 gPlayer2Settings
.Team
, False));
4761 if gPlayer2
= nil then
4763 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
4767 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
4768 gPlayer2
.WeapSwitchMode
:= gPlayer2Settings
.WeaponSwitch
;
4769 gPlayer2
.setWeaponPrefs(gPlayer2Settings
.WeaponPreferences
);
4770 gPlayer2
.SwitchToEmpty
:= gPlayer2Settings
.SwitchToEmpty
;
4771 gPlayer2
.SkipFist
:= gPlayer2Settings
.SkipFist
;
4774 g_Game_SetLoadingText(_lc
[I_LOAD_HOST
], 0, False);
4775 if NetForwardPorts
then
4776 g_Game_SetLoadingText(_lc
[I_LOAD_PORTS
], 0, False);
4779 if not g_Net_Host(IPAddr
, Port
, NetMaxClients
) then
4781 g_FatalError(_lc
[I_NET_MSG
] + Format(_lc
[I_NET_ERR_HOST
], [Port
]));
4785 g_Net_Slist_Set(NetMasterList
);
4787 g_Net_Slist_ServerStarted();
4789 // Çàãðóçêà è çàïóñê êàðòû:
4790 if not g_Game_StartMap(false{asMegawad}, Map
, True) then
4792 g_Net_Slist_ServerClosed();
4793 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [Map
]));
4797 // Íåò òî÷åê ïîÿâëåíèÿ:
4798 if (g_Map_GetPointCount(RESPAWNPOINT_PLAYER1
) +
4799 g_Map_GetPointCount(RESPAWNPOINT_PLAYER2
) +
4800 g_Map_GetPointCount(RESPAWNPOINT_DM
) +
4801 g_Map_GetPointCount(RESPAWNPOINT_RED
)+
4802 g_Map_GetPointCount(RESPAWNPOINT_BLUE
)) < 1 then
4804 g_Net_Slist_ServerClosed();
4805 g_FatalError(_lc
[I_GAME_ERROR_GET_SPAWN
]);
4809 // Íàñòðîéêè èãðîêîâ è áîòîâ:
4812 g_Net_Slist_ServerMapStarted();
4813 NetState
:= NET_STATE_GAME
;
4816 procedure g_Game_StartClient(Addr
: String; Port
: Word; PW
: String);
4831 e_WriteLog('Starting net game (client)...', TMsgType
.Notify
);
4832 e_WriteLog('NET: Trying to connect to ' + Addr
+ ':' + IntToStr(Port
) + '...', TMsgType
.Notify
);
4834 g_Game_ClearLoading();
4839 gGameSettings
.GameType
:= GT_CLIENT
;
4841 gCoopTotalMonstersKilled
:= 0;
4842 gCoopTotalSecretsFound
:= 0;
4843 gCoopTotalMonsters
:= 0;
4844 gCoopTotalSecrets
:= 0;
4848 g_Game_ExecuteEvent('ongamestart');
4850 // Óñòàíîâêà ðàçìåðîâ îêîí èãðîêîâ:
4851 g_Game_SetupScreenSize();
4853 NetState
:= NET_STATE_AUTH
;
4855 g_Game_SetLoadingText(_lc
[I_LOAD_CONNECT
], 0, False);
4857 // create (or update) map/resource databases
4858 g_Res_CreateDatabases(true);
4860 gLMSRespawn
:= LMS_RESPAWN_NONE
;
4861 gLMSRespawnTime
:= 0;
4862 gSpectLatchPID1
:= 0;
4863 gSpectLatchPID2
:= 0;
4866 if not g_Net_Connect(Addr
, Port
) then
4868 g_FatalError(_lc
[I_NET_MSG
] + _lc
[I_NET_ERR_CONN
]);
4869 NetState
:= NET_STATE_NONE
;
4873 g_Game_SetLoadingText(_lc
[I_LOAD_SEND_INFO
], 0, False);
4875 g_Game_SetLoadingText(_lc
[I_LOAD_WAIT_INFO
], 0, False);
4880 // fuck! https://www.mail-archive.com/enet-discuss@cubik.org/msg00852.html
4881 // tl;dr: on shitdows, we can get -1 sometimes, and it is *NOT* a failure.
4882 // thank you, enet. let's ignore failures altogether then.
4883 while (enet_host_service(NetHost
, @NetEvent
, 50) > 0) do
4885 if (NetEvent
.kind
= ENET_EVENT_TYPE_RECEIVE
) then
4887 Ptr
:= NetEvent
.packet
^.data
;
4888 if not InMsg
.Init(Ptr
, NetEvent
.packet
^.dataLength
, True) then
4890 enet_packet_destroy(NetEvent
.packet
);
4894 InMsg
.ReadLongWord(); // skip size
4895 MID
:= InMsg
.ReadByte();
4897 if (MID
= NET_MSG_INFO
) and (State
= 0) then
4899 NetMyID
:= InMsg
.ReadByte();
4900 NetPlrUID1
:= InMsg
.ReadWord();
4902 WadName
:= InMsg
.ReadString();
4903 Map
:= InMsg
.ReadString();
4905 gWADHash
:= InMsg
.ReadMD5();
4907 gGameSettings
.GameMode
:= InMsg
.ReadByte();
4908 gSwitchGameMode
:= gGameSettings
.GameMode
;
4909 gGameSettings
.ScoreLimit
:= InMsg
.ReadWord();
4910 gGameSettings
.TimeLimit
:= InMsg
.ReadWord();
4911 gGameSettings
.MaxLives
:= InMsg
.ReadByte();
4912 gGameSettings
.Options
:= InMsg
.ReadLongWord();
4913 T
:= InMsg
.ReadLongWord();
4915 //newResPath := g_Res_SearchSameWAD(MapsDir, WadName, gWADHash);
4916 //if newResPath = '' then
4918 //g_Game_SetLoadingText(_lc[I_LOAD_DL_RES], 0, False);
4919 newResPath
:= g_Res_DownloadMapWAD(ExtractFileName(WadName
), gWADHash
);
4920 if newResPath
= '' then
4922 g_FatalError(_lc
[I_NET_ERR_HASH
]);
4923 enet_packet_destroy(NetEvent
.packet
);
4924 NetState
:= NET_STATE_NONE
;
4927 e_LogWritefln('using downloaded map wad [%s] for [%s]`', [newResPath
, WadName
], TMsgType
.Notify
);
4929 //newResPath := ExtractRelativePath(MapsDir, newResPath);
4932 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
4933 gPlayer1Settings
.Color
,
4934 gPlayer1Settings
.Team
, False));
4936 if gPlayer1
= nil then
4938 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
4940 enet_packet_destroy(NetEvent
.packet
);
4941 NetState
:= NET_STATE_NONE
;
4945 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
4946 gPlayer1
.WeapSwitchMode
:= gPlayer1Settings
.WeaponSwitch
;
4947 gPlayer1
.setWeaponPrefs(gPlayer1Settings
.WeaponPreferences
);
4948 gPlayer1
.SwitchToEmpty
:= gPlayer1Settings
.SwitchToEmpty
;
4949 gPlayer1
.SkipFist
:= gPlayer1Settings
.SkipFist
;
4950 gPlayer1
.UID
:= NetPlrUID1
;
4951 gPlayer1
.Reset(True);
4953 if not g_Game_StartMap(false{asMegawad}, newResPath
+ ':\' + Map
, True) then
4955 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [WadName
+ ':\' + Map
]));
4957 enet_packet_destroy(NetEvent
.packet
);
4958 NetState
:= NET_STATE_NONE
;
4966 enet_packet_destroy(NetEvent
.packet
);
4970 enet_packet_destroy(NetEvent
.packet
);
4974 if (NetEvent
.kind
= ENET_EVENT_TYPE_DISCONNECT
) then
4977 if (NetEvent
.data
<= NET_DISC_MAX
) then
4978 g_Console_Add(_lc
[I_NET_MSG_ERROR
] + _lc
[I_NET_ERR_CONN
] + ' ' +
4979 _lc
[TStrings_Locale(Cardinal(I_NET_DISC_NONE
) + NetEvent
.data
)], True);
4986 ProcessLoading(True);
4987 if g_Net_UserRequestExit() then
4996 g_FatalError(_lc
[I_NET_MSG
] + _lc
[I_NET_ERR_CONN
]);
4997 NetState
:= NET_STATE_NONE
;
5002 NetState
:= NET_STATE_GAME
;
5003 MC_SEND_FullStateRequest
;
5004 e_WriteLog('NET: Connection successful.', TMsgType
.Notify
);
5008 lastAsMegaWad
: Boolean = false;
5010 procedure g_Game_ChangeMap(const MapPath
: String);
5014 g_Game_ClearLoading();
5016 Force
:= gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
];
5017 // Åñëè óðîâåíü çàâåðøèëñÿ ïî òðèããåðó Âûõîä, íå î÷èùàòü èíâåíòàðü
5018 if gExitByTrigger
then
5021 gExitByTrigger
:= False;
5023 if not g_Game_StartMap(lastAsMegaWad
, MapPath
, Force
) then
5024 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [MapPath
]));
5027 procedure g_Game_Restart();
5031 if g_Game_IsClient
then
5033 map
:= g_ExtractFileName(gMapInfo
.Map
);
5034 e_LogWritefln('g_Game_Restart: map = "%s" gCurrentMapFileName = "%s"', [map
, gCurrentMapFileName
]);
5038 g_Game_ClearLoading();
5039 g_Game_StartMap(lastAsMegaWad
, Map
, True, gCurrentMapFileName
);
5042 function g_Game_StartMap (asMegawad
: Boolean; Map
: String; Force
: Boolean = False; const oldMapPath
: AnsiString=''): Boolean;
5044 NewWAD
, ResName
: String;
5048 g_Map_Free((Map
<> gCurrentMapFileName
) and (oldMapPath
<> gCurrentMapFileName
));
5049 g_Player_RemoveAllCorpses();
5051 if (not g_Game_IsClient
) and
5052 (gSwitchGameMode
<> gGameSettings
.GameMode
) and
5053 (gGameSettings
.GameMode
<> GM_SINGLE
) then
5055 if gSwitchGameMode
= GM_CTF
then
5056 gGameSettings
.MaxLives
:= 0;
5057 gGameSettings
.GameMode
:= gSwitchGameMode
;
5060 gSwitchGameMode
:= gGameSettings
.GameMode
;
5062 g_Player_ResetTeams();
5064 lastAsMegaWad
:= asMegawad
;
5065 if isWadPath(Map
) then
5067 NewWAD
:= g_ExtractWadName(Map
);
5068 ResName
:= g_ExtractFileName(Map
);
5069 if g_Game_IsServer
then
5071 nws
:= findDiskWad(NewWAD
);
5072 //writeln('000: Map=[', Map, ']; nws=[', nws, ']; NewWAD=[', NewWAD, ']');
5075 if (length(nws
) = 0) then nws
:= e_FindWad(MegawadDirs
, NewWAD
);
5076 if (length(nws
) = 0) then nws
:= e_FindWad(MapDirs
, NewWAD
);
5080 if (length(nws
) = 0) then nws
:= e_FindWad(MapDirs
, NewWAD
);
5081 if (length(nws
) = 0) then nws
:= e_FindWad(MegawadDirs
, NewWAD
);
5083 //if (length(nws) = 0) then nws := e_FindWad(MapDownloadDirs, NewWAD);
5084 //writeln('001: Map=[', Map, ']; nws=[', nws, ']; NewWAD=[', NewWAD, ']');
5086 if (length(nws
) = 0) then
5088 ResName
:= ''; // failed
5093 if (g_Game_IsNet
) then gWADHash
:= MD5File(nws
);
5094 //writeln('********: nws=', nws, ' : Map=', Map, ' : nw=', NewWAD, ' : resname=', ResName);
5095 g_Game_LoadWAD(NewWAD
);
5100 // hash received in MC_RECV_GameEvent -> NET_EV_MAPSTART
5101 NewWAD
:= g_Game_ClientWAD(NewWAD
, gWADHash
);
5106 NewWAD
:= gGameSettings
.WAD
;
5112 //writeln('********: gsw=', gGameSettings.WAD, '; rn=', ResName);
5114 if (ResName
<> '') and (NewWAD
<> '') then
5116 //result := g_Map_Load(gGameSettings.WAD + ':\' + ResName);
5117 result
:= g_Map_Load(NewWAD
+':\'+ResName
);
5121 g_Player_ResetAll(Force
or gLastMap
, gGameSettings
.GameType
= GT_SINGLE
);
5123 gState
:= STATE_NONE
;
5124 g_ActiveWindow
:= nil;
5130 if gGameSettings
.GameMode
= GM_CTF
then
5132 g_Map_ResetFlag(FLAG_RED
);
5133 g_Map_ResetFlag(FLAG_BLUE
);
5134 // CTF, à ôëàãîâ íåò:
5135 if not g_Map_HaveFlagPoints() then
5136 g_SimpleError(_lc
[I_GAME_ERROR_CTF
]);
5141 gState
:= STATE_MENU
;
5146 gPauseMain
:= false;
5147 gPauseHolmes
:= false;
5148 NetTimeToUpdate
:= 1;
5149 NetTimeToReliable
:= 0;
5150 NetTimeToMaster
:= NetMasterRate
;
5151 gSpectLatchPID1
:= 0;
5152 gSpectLatchPID2
:= 0;
5153 gMissionFailed
:= False;
5156 gCoopMonstersKilled
:= 0;
5157 gCoopSecretsFound
:= 0;
5159 gVoteInProgress
:= False;
5160 gVotePassed
:= False;
5166 if not gGameOn
then Exit
;
5168 g_Game_SpectateCenterView();
5170 if g_Game_IsServer
then
5172 if (gGameSettings
.MaxLives
> 0) and (gGameSettings
.WarmupTime
> 0) then
5174 gLMSRespawn
:= LMS_RESPAWN_WARMUP
;
5175 gLMSRespawnTime
:= gTime
+ gGameSettings
.WarmupTime
*1000;
5176 gLMSSoftSpawn
:= True;
5177 if g_Game_IsNet
then
5178 MH_SEND_GameEvent(NET_EV_LMS_WARMUP
, gLMSRespawnTime
- gTime
);
5182 gLMSRespawn
:= LMS_RESPAWN_NONE
;
5183 gLMSRespawnTime
:= 0;
5187 if NetMode
= NET_SERVER
then
5189 // reset full state flags
5190 if NetClients
<> nil then
5191 for I
:= 0 to High(NetClients
) do
5192 NetClients
[I
].FullUpdateSent
:= False;
5194 MH_SEND_GameEvent(NET_EV_MAPSTART
, gGameSettings
.GameMode
, Map
);
5197 g_Net_Slist_ServerMapStarted();
5199 if NetClients
<> nil then
5200 for I
:= 0 to High(NetClients
) do
5201 if NetClients
[I
].Used
then
5203 NetClients
[I
].Voted
:= False;
5204 if NetClients
[I
].RequestedFullUpdate
then
5206 MH_SEND_Everything((NetClients
[I
].State
= NET_STATE_AUTH
), I
);
5207 NetClients
[I
].RequestedFullUpdate
:= False;
5211 g_Net_UnbanNonPerm();
5216 gCoopTotalMonstersKilled
:= 0;
5217 gCoopTotalSecretsFound
:= 0;
5218 gCoopTotalMonsters
:= 0;
5219 gCoopTotalSecrets
:= 0;
5223 g_Game_ExecuteEvent('onmapstart');
5226 procedure SetFirstLevel
;
5230 MapList
:= g_Map_GetMapsList(gGameSettings
.WAD
);
5231 if MapList
= nil then
5234 SortSArray(MapList
);
5235 gNextMap
:= MapList
[Low(MapList
)];
5240 procedure g_Game_ExitLevel(const Map
: AnsiString);
5244 gCoopTotalMonstersKilled
:= gCoopTotalMonstersKilled
+ gCoopMonstersKilled
;
5245 gCoopTotalSecretsFound
:= gCoopTotalSecretsFound
+ gCoopSecretsFound
;
5246 gCoopTotalMonsters
:= gCoopTotalMonsters
+ gTotalMonsters
;
5247 gCoopTotalSecrets
:= gCoopTotalSecrets
+ gSecretsCount
;
5249 // Âûøëè â âûõîä â Îäèíî÷íîé èãðå:
5250 if gGameSettings
.GameType
= GT_SINGLE
then
5251 gExit
:= EXIT_ENDLEVELSINGLE
5252 else // Âûøëè â âûõîä â Ñâîåé èãðå
5254 gExit
:= EXIT_ENDLEVELCUSTOM
;
5255 if gGameSettings
.GameMode
= GM_COOP
then
5256 g_Player_RememberAll
;
5258 if not g_Map_Exist(gGameSettings
.WAD
+ ':\' + gNextMap
) then
5261 if gGameSettings
.GameMode
= GM_COOP
then
5264 gStatsPressed
:= True;
5265 gNextMap
:= 'MAP01';
5267 if not g_Map_Exist(gGameSettings
.WAD
+ ':\' + gNextMap
) then
5270 if g_Game_IsNet
then
5272 MH_SEND_GameStats();
5273 MH_SEND_CoopStats();
5279 procedure g_Game_RestartLevel();
5283 if gGameSettings
.GameMode
= GM_SINGLE
then
5288 gExit
:= EXIT_ENDLEVELCUSTOM
;
5289 Map
:= g_ExtractFileName(gMapInfo
.Map
);
5293 function g_Game_ClientWAD (NewWAD
: String; const WHash
: TMD5Digest
): AnsiString;
5295 gWAD
{, xwad}: String;
5298 if not g_Game_IsClient
then Exit
;
5299 //e_LogWritefln('*** g_Game_ClientWAD: `%s`', [NewWAD]);
5301 gWAD
:= g_Res_DownloadMapWAD(ExtractFileName(NewWAD
), WHash
);
5306 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_WAD
], [ExtractFileName(NewWAD
)]));
5310 e_LogWritefln('using downloaded client map wad [%s] for [%s]', [gWAD
, NewWAD
], TMsgType
.Notify
);
5313 g_Game_LoadWAD(NewWAD
);
5317 if LowerCase(NewWAD) = LowerCase(gGameSettings.WAD) then Exit;
5318 gWAD := g_Res_SearchSameWAD(MapsDir, ExtractFileName(NewWAD), WHash);
5321 g_Game_SetLoadingText(_lc[I_LOAD_DL_RES], 0, False);
5322 gWAD := g_Res_DownloadMapWAD(ExtractFileName(NewWAD), WHash);
5326 g_FatalError(Format(_lc[I_GAME_ERROR_MAP_WAD], [ExtractFileName(NewWAD)]));
5330 NewWAD := ExtractRelativePath(MapsDir, gWAD);
5331 g_Game_LoadWAD(NewWAD);
5335 procedure g_Game_RestartRound(NoMapRestart
: Boolean = False);
5337 i
, n
, nb
, nr
: Integer;
5339 if not g_Game_IsServer
then Exit
;
5340 if gLMSRespawn
= LMS_RESPAWN_NONE
then Exit
;
5341 gLMSRespawn
:= LMS_RESPAWN_NONE
;
5342 gLMSRespawnTime
:= 0;
5345 if (gGameSettings
.GameMode
= GM_COOP
) and not NoMapRestart
then
5347 gMissionFailed
:= True;
5348 g_Game_RestartLevel
;
5352 n
:= 0; nb
:= 0; nr
:= 0;
5353 for i
:= Low(gPlayers
) to High(gPlayers
) do
5354 if (gPlayers
[i
] <> nil) and
5355 ((not gPlayers
[i
].FSpectator
) or gPlayers
[i
].FWantsInGame
or
5356 (gPlayers
[i
] is TBot
)) then
5359 if gPlayers
[i
].Team
= TEAM_RED
then Inc(nr
)
5360 else if gPlayers
[i
].Team
= TEAM_BLUE
then Inc(nb
)
5363 if (n
< 1) or ((gGameSettings
.GameMode
= GM_TDM
) and ((nr
= 0) or (nb
= 0))) then
5365 // wait a second until the fuckers finally decide to join
5366 gLMSRespawn
:= LMS_RESPAWN_WARMUP
;
5367 gLMSRespawnTime
:= gTime
+ gGameSettings
.WarmupTime
*1000;
5368 gLMSSoftSpawn
:= NoMapRestart
;
5369 if g_Game_IsNet
then
5370 MH_SEND_GameEvent(NET_EV_LMS_WARMUP
, gLMSRespawnTime
- gTime
);
5374 g_Player_RemoveAllCorpses
;
5375 g_Game_Message(_lc
[I_MESSAGE_LMS_START
], 144);
5376 if g_Game_IsNet
then
5377 MH_SEND_GameEvent(NET_EV_LMS_START
);
5379 for i
:= Low(gPlayers
) to High(gPlayers
) do
5381 if gPlayers
[i
] = nil then continue
;
5382 if gPlayers
[i
] is TBot
then gPlayers
[i
].FWantsInGame
:= True;
5383 // don't touch normal spectators
5384 if gPlayers
[i
].FSpectator
and not gPlayers
[i
].FWantsInGame
then
5386 gPlayers
[i
].FNoRespawn
:= True;
5387 gPlayers
[i
].Lives
:= 0;
5388 if g_Game_IsNet
then
5389 MH_SEND_PlayerStats(gPlayers
[I
].UID
);
5392 gPlayers
[i
].FNoRespawn
:= False;
5393 gPlayers
[i
].Lives
:= gGameSettings
.MaxLives
;
5394 gPlayers
[i
].Respawn(False, True);
5395 if gGameSettings
.GameMode
= GM_COOP
then
5397 gPlayers
[i
].Frags
:= 0;
5398 gPlayers
[i
].Assists
:= 0;
5399 gPlayers
[i
].RecallState
;
5401 if (gPlayer1
= nil) and (gSpectLatchPID1
> 0) then
5402 gPlayer1
:= g_Player_Get(gSpectLatchPID1
);
5403 if (gPlayer2
= nil) and (gSpectLatchPID2
> 0) then
5404 gPlayer2
:= g_Player_Get(gSpectLatchPID2
);
5407 g_Items_RestartRound();
5409 gLMSSoftSpawn
:= False;
5412 function g_Game_GetFirstMap(WAD
: String): String;
5416 MapList
:= g_Map_GetMapsList(WAD
);
5417 if MapList
= nil then
5420 SortSArray(MapList
);
5421 Result
:= MapList
[Low(MapList
)];
5423 if not g_Map_Exist(WAD
+ ':\' + Result
) then
5429 function g_Game_GetNextMap(): String;
5436 MapList
:= g_Map_GetMapsList(gGameSettings
.WAD
);
5437 if MapList
= nil then
5440 Map
:= g_ExtractFileName(gMapInfo
.Map
);
5442 SortSArray(MapList
);
5444 for I
:= Low(MapList
) to High(MapList
) do
5445 if Map
= MapList
[I
] then
5451 if MapIndex
<> -255 then
5453 if MapIndex
= High(MapList
) then
5454 Result
:= MapList
[Low(MapList
)]
5456 Result
:= MapList
[MapIndex
+ 1];
5458 if not g_Map_Exist(gGameSettings
.WAD
+ ':\' + Result
) then Result
:= Map
;
5464 procedure g_Game_NextLevel();
5466 if gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
, GM_COOP
] then
5467 gExit
:= EXIT_ENDLEVELCUSTOM
5470 gExit
:= EXIT_ENDLEVELSINGLE
;
5474 if gNextMap
<> '' then Exit
;
5475 gNextMap
:= g_Game_GetNextMap();
5478 function g_Game_IsTestMap(): Boolean;
5480 result
:= StrEquCI1251(TEST_MAP_NAME
, g_ExtractFileName(gMapInfo
.Map
));
5483 procedure g_Game_DeleteTestMap();
5486 //MapName: AnsiString;
5494 a
:= Pos('.wad:\', toLowerCase1251(gMapToDelete
));
5495 if (a
= 0) then a
:= Pos('.wad:/', toLowerCase1251(gMapToDelete
));
5496 if (a
= 0) then exit
;
5498 // Âûäåëÿåì èìÿ wad-ôàéëà è èìÿ êàðòû
5499 WadName
:= Copy(gMapToDelete
, 1, a
+3);
5500 Delete(gMapToDelete
, 1, a
+5);
5501 gMapToDelete
:= UpperCase(gMapToDelete
);
5503 //CopyMemory(@MapName[0], @gMapToDelete[1], Min(16, Length(gMapToDelete)));
5506 // Èìÿ êàðòû íå ñòàíäàðòíîå òåñòîâîå:
5507 if MapName <> TEST_MAP_NAME then
5510 if not gTempDelete then
5512 time := g_GetFileTime(WadName);
5513 WAD := TWADFile.Create();
5516 if not WAD.ReadFile(WadName) then
5517 begin // Íåò òàêîãî WAD-ôàéëà
5522 // Ñîñòàâëÿåì ñïèñîê êàðò è èùåì íóæíóþ:
5524 MapList := WAD.GetResourcesList('');
5526 if MapList <> nil then
5527 for a := 0 to High(MapList) do
5528 if MapList[a] = MapName then
5530 // Óäàëÿåì è ñîõðàíÿåì:
5531 WAD.RemoveResource('', MapName);
5532 WAD.SaveTo(WadName);
5537 g_SetFileTime(WadName, time);
5540 if gTempDelete
then DeleteFile(WadName
);
5543 procedure GameCVars(P
: SSArray
);
5546 stat
: TPlayerStatArray
;
5550 procedure ParseGameFlag(Flag
: LongWord; OffMsg
, OnMsg
: TStrings_Locale
; OnMapChange
: Boolean = False);
5554 if Length(P
) > 1 then
5559 gsGameFlags
:= gsGameFlags
or Flag
5561 gsGameFlags
:= gsGameFlags
and (not Flag
);
5563 if g_Game_IsServer
then
5566 gGameSettings
.Options
:= gGameSettings
.Options
or Flag
5568 gGameSettings
.Options
:= gGameSettings
.Options
and (not Flag
);
5569 if g_Game_IsNet
then MH_SEND_GameSettings
;
5573 if LongBool(gsGameFlags
and Flag
) then
5574 g_Console_Add(_lc
[OnMsg
])
5576 g_Console_Add(_lc
[OffMsg
]);
5578 if OnMapChange
and g_Game_IsServer
then
5579 g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
5584 cmd
:= LowerCase(P
[0]);
5586 if cmd
= 'g_gamemode' then
5588 if (Length(P
) > 1) then
5590 a
:= g_Game_TextToMode(P
[1]);
5591 if a
= GM_SINGLE
then a
:= GM_COOP
;
5592 gsGameMode
:= g_Game_ModeToText(a
);
5593 if g_Game_IsServer
then
5595 gSwitchGameMode
:= a
;
5596 if (gGameOn
and (gGameSettings
.GameMode
= GM_SINGLE
)) or
5597 (gState
= STATE_INTERSINGLE
) then
5598 gSwitchGameMode
:= GM_SINGLE
;
5600 gGameSettings
.GameMode
:= gSwitchGameMode
;
5604 if gSwitchGameMode
= gGameSettings
.GameMode
then
5605 g_Console_Add(Format(_lc
[I_MSG_GAMEMODE_CURRENT
],
5606 [g_Game_ModeToText(gGameSettings
.GameMode
)]))
5608 g_Console_Add(Format(_lc
[I_MSG_GAMEMODE_CHANGE
],
5609 [g_Game_ModeToText(gGameSettings
.GameMode
),
5610 g_Game_ModeToText(gSwitchGameMode
)]));
5612 else if cmd
= 'g_friendlyfire' then
5614 ParseGameFlag(GAME_OPTION_TEAMDAMAGE
, I_MSG_FRIENDLY_FIRE_OFF
, I_MSG_FRIENDLY_FIRE_ON
);
5616 else if cmd
= 'g_friendly_absorb_damage' then
5618 ParseGameFlag(GAME_OPTION_TEAMABSORBDAMAGE
, I_MSG_FRIENDLY_ABSORB_DAMAGE_OFF
, I_MSG_FRIENDLY_ABSORB_DAMAGE_ON
);
5620 else if cmd
= 'g_friendly_hit_trace' then
5622 ParseGameFlag(GAME_OPTION_TEAMHITTRACE
, I_MSG_FRIENDLY_HIT_TRACE_OFF
, I_MSG_FRIENDLY_HIT_TRACE_ON
);
5624 else if cmd
= 'g_friendly_hit_projectile' then
5626 ParseGameFlag(GAME_OPTION_TEAMHITPROJECTILE
, I_MSG_FRIENDLY_PROJECT_TRACE_OFF
, I_MSG_FRIENDLY_PROJECT_TRACE_ON
);
5628 else if cmd
= 'g_rulez_randomize_respawn' then
5630 ParseGameFlag(GAME_OPTION_RULEZRANDOM
, I_MSG_RULEZ_RANDOM_ON
, I_MSG_RULEZ_RANDOM_OFF
);
5632 else if cmd
= 'g_weaponstay' then
5634 ParseGameFlag(GAME_OPTION_WEAPONSTAY
, I_MSG_WEAPONSTAY_OFF
, I_MSG_WEAPONSTAY_ON
);
5636 else if cmd
= 'g_allow_exit' then
5638 ParseGameFlag(GAME_OPTION_ALLOWEXIT
, I_MSG_ALLOWEXIT_OFF
, I_MSG_ALLOWEXIT_ON
, True);
5640 else if cmd
= 'g_allow_monsters' then
5642 ParseGameFlag(GAME_OPTION_MONSTERS
, I_MSG_ALLOWMON_OFF
, I_MSG_ALLOWMON_ON
, True);
5644 else if cmd
= 'g_allow_dropflag' then
5646 ParseGameFlag(GAME_OPTION_ALLOWDROPFLAG
, I_MSG_ALLOWDROPFLAG_OFF
, I_MSG_ALLOWDROPFLAG_ON
);
5648 else if cmd
= 'g_throw_flag' then
5650 ParseGameFlag(GAME_OPTION_THROWFLAG
, I_MSG_THROWFLAG_OFF
, I_MSG_THROWFLAG_ON
);
5652 else if cmd
= 'g_bot_vsplayers' then
5654 ParseGameFlag(GAME_OPTION_BOTVSPLAYER
, I_MSG_BOTSVSPLAYERS_OFF
, I_MSG_BOTSVSPLAYERS_ON
);
5656 else if cmd
= 'g_bot_vsmonsters' then
5658 ParseGameFlag(GAME_OPTION_BOTVSMONSTER
, I_MSG_BOTSVSMONSTERS_OFF
, I_MSG_BOTSVSMONSTERS_ON
);
5660 else if cmd
= 'g_dm_keys' then
5662 ParseGameFlag(GAME_OPTION_DMKEYS
, I_MSG_DMKEYS_OFF
, I_MSG_DMKEYS_ON
, True);
5664 else if cmd
= 'g_gameflags' then
5666 if Length(P
) > 1 then
5668 gsGameFlags
:= StrToDWordDef(P
[1], gsGameFlags
);
5669 if g_Game_IsServer
then
5671 gGameSettings
.Options
:= gsGameFlags
;
5672 if g_Game_IsNet
then MH_SEND_GameSettings
;
5676 g_Console_Add(Format('%s %u', [cmd
, gsGameFlags
]));
5678 else if cmd
= 'g_warmup_time' then
5680 if Length(P
) > 1 then
5682 gsWarmupTime
:= nclamp(StrToIntDef(P
[1], gsWarmupTime
), 0, $FFFF);
5683 if g_Game_IsServer
then
5685 gGameSettings
.WarmupTime
:= gsWarmupTime
;
5686 // extend warmup if it's already going
5687 if gLMSRespawn
= LMS_RESPAWN_WARMUP
then
5689 gLMSRespawnTime
:= gTime
+ gsWarmupTime
* 1000;
5690 if g_Game_IsNet
then MH_SEND_GameEvent(NET_EV_LMS_WARMUP
, gLMSRespawnTime
- gTime
);
5692 if g_Game_IsNet
then MH_SEND_GameSettings
;
5696 g_Console_Add(Format(_lc
[I_MSG_WARMUP
], [Integer(gsWarmupTime
)]));
5697 if g_Game_IsServer
then g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
5699 else if cmd
= 'g_spawn_invul' then
5701 if Length(P
) > 1 then
5703 gsSpawnInvul
:= nclamp(StrToIntDef(P
[1], gsSpawnInvul
), 0, $FFFF);
5704 if g_Game_IsServer
then
5706 gGameSettings
.SpawnInvul
:= gsSpawnInvul
;
5707 if g_Game_IsNet
then MH_SEND_GameSettings
;
5711 g_Console_Add(Format('%s %d', [cmd
, Integer(gsSpawnInvul
)]));
5713 else if cmd
= 'g_item_respawn_time' then
5715 if Length(P
) > 1 then
5717 gsItemRespawnTime
:= nclamp(StrToIntDef(P
[1], gsItemRespawnTime
), 0, $FFFF);
5718 if g_Game_IsServer
then
5720 gGameSettings
.ItemRespawnTime
:= gsItemRespawnTime
;
5721 if g_Game_IsNet
then MH_SEND_GameSettings
;
5725 g_Console_Add(Format('%s %d', [cmd
, Integer(gsItemRespawnTime
)]));
5726 if g_Game_IsServer
then g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
5728 else if cmd
= 'g_rulez_time_multiplier' then
5730 if Length(P
) > 1 then
5732 gsRulezTimeMultiplier
:= nclamp(StrToIntDef(P
[1], gsRulezTimeMultiplier
), 0, $FFFF);
5733 if g_Game_IsServer
then
5735 gGameSettings
.RulezTimeMultiplier
:= gsRulezTimeMultiplier
;
5736 if g_Game_IsNet
then MH_SEND_GameSettings
;
5740 g_Console_Add(Format('%s %d', [cmd
, Integer(gsRulezTimeMultiplier
)]));
5741 if g_Game_IsServer
then g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
5743 else if cmd
= 'sv_intertime' then
5745 if (Length(P
) > 1) then
5746 gDefInterTime
:= Min(Max(StrToIntDef(P
[1], gDefInterTime
), -1), 120);
5748 g_Console_Add(cmd
+ ' = ' + IntToStr(gDefInterTime
));
5750 else if cmd
= 'g_max_particles' then
5752 if Length(p
) = 2 then
5754 a
:= Max(0, StrToIntDef(p
[1], 0));
5757 else if Length(p
) = 1 then
5759 e_LogWritefln('%s', [g_GFX_GetMax()])
5763 e_LogWritefln('usage: %s <n>', [cmd
])
5766 else if cmd
= 'g_max_shells' then
5768 if Length(p
) = 2 then
5770 a
:= Max(0, StrToIntDef(p
[1], 0));
5773 else if Length(p
) = 1 then
5775 e_LogWritefln('%s', [g_Shells_GetMax()])
5779 e_LogWritefln('usage: %s <n>', [cmd
])
5782 else if cmd
= 'g_max_gibs' then
5784 if Length(p
) = 2 then
5786 a
:= Max(0, StrToIntDef(p
[1], 0));
5789 else if Length(p
) = 1 then
5791 e_LogWritefln('%s', [g_Gibs_GetMax()])
5795 e_LogWritefln('usage: %s <n>', [cmd
])
5798 else if cmd
= 'g_max_corpses' then
5800 if Length(p
) = 2 then
5802 a
:= Max(0, StrToIntDef(p
[1], 0));
5805 else if Length(p
) = 1 then
5807 e_LogWritefln('%s', [g_Corpses_GetMax()])
5811 e_LogWritefln('usage: %s <n>', [cmd
])
5814 else if cmd
= 'g_force_model' then
5816 if Length(p
) = 2 then
5818 a
:= StrToIntDef(p
[1], 0);
5819 g_Force_Model_Set(a
);
5820 if (g_Force_Model_Get() <> 0) and (gPlayers
<> nil) then
5822 for a
:= Low(gPlayers
) to High(gPlayers
) do
5824 if (gPlayers
[a
] <> nil) then
5826 if (gPlayers
[a
].UID
= gPlayer1
.UID
) then
5828 else if (gPlayer2
<> nil) and (gPlayers
[a
].UID
= gPlayer2
.UID
) then
5830 gPlayers
[a
].setModel(g_Forced_Model_GetName());
5834 else if (g_Force_Model_Get() = 0) and (gPlayers
<> nil) then
5836 for a
:= Low(gPlayers
) to High(gPlayers
) do
5838 if (gPlayers
[a
] <> nil) then
5840 if (gPlayers
[a
].UID
= gPlayer1
.UID
) then
5842 else if (gPlayer2
<> nil) and (gPlayers
[a
].UID
= gPlayer2
.UID
) then
5844 gPlayers
[a
].setModel(gPlayers
[a
].FActualModelName
);
5850 else if cmd
= 'g_force_model_name' then
5852 if (Length(P
) > 1) then
5854 cmd
:= b_Text_Unformat(P
[1]);
5855 g_Forced_Model_SetName(cmd
);
5856 if (g_Force_Model_Get() <> 0) and (gPlayers
<> nil) then
5858 for a
:= Low(gPlayers
) to High(gPlayers
) do
5860 if (gPlayers
[a
] <> nil) then
5862 if (gPlayers
[a
].UID
= gPlayer1
.UID
) then
5864 else if (gPlayer2
<> nil) and (gPlayers
[a
].UID
= gPlayer2
.UID
) then
5866 gPlayers
[a
].setModel(g_Forced_Model_GetName());
5872 else if cmd
= 'g_scorelimit' then
5874 if Length(P
) > 1 then
5876 gsScoreLimit
:= nclamp(StrToIntDef(P
[1], gsScoreLimit
), 0, $FFFF);
5878 if g_Game_IsServer
then
5881 if gGameSettings
.GameMode
= GM_DM
then
5883 stat
:= g_Player_GetStats();
5885 for a
:= 0 to High(stat
) do
5886 if stat
[a
].Frags
> b
then
5890 b
:= Max(gTeamStat
[TEAM_RED
].Score
, gTeamStat
[TEAM_BLUE
].Score
);
5892 // if someone has a higher score, set it to that instead
5893 gsScoreLimit
:= max(gsScoreLimit
, b
);
5894 gGameSettings
.ScoreLimit
:= gsScoreLimit
;
5896 if g_Game_IsNet
then MH_SEND_GameSettings
;
5900 g_Console_Add(Format(_lc
[I_MSG_SCORE_LIMIT
], [Integer(gsScoreLimit
)]));
5902 else if cmd
= 'g_timelimit' then
5904 if Length(P
) > 1 then
5906 gsTimeLimit
:= nclamp(StrToIntDef(P
[1], gsTimeLimit
), 0, $FFFF);
5907 if g_Game_IsServer
then
5909 gGameSettings
.TimeLimit
:= gsTimeLimit
;
5910 if g_Game_IsNet
then MH_SEND_GameSettings
;
5913 g_Console_Add(Format(_lc
[I_MSG_TIME_LIMIT
],
5914 [gsTimeLimit
div 3600,
5915 (gsTimeLimit
div 60) mod 60,
5916 gsTimeLimit
mod 60]));
5918 else if cmd
= 'g_max_bots' then
5920 if Length(P
) > 1 then
5921 gMaxBots
:= nclamp(StrToIntDef(P
[1], gMaxBots
), 0, 127);
5922 g_Console_Add('g_max_bots = ' + IntToStr(gMaxBots
));
5924 else if cmd
= 'g_maxlives' then
5926 if Length(P
) > 1 then
5928 gsMaxLives
:= nclamp(StrToIntDef(P
[1], gsMaxLives
), 0, $FFFF);
5929 if g_Game_IsServer
then
5931 gGameSettings
.MaxLives
:= gsMaxLives
;
5932 if g_Game_IsNet
then MH_SEND_GameSettings
;
5936 g_Console_Add(Format(_lc
[I_MSG_LIVES
], [Integer(gsMaxLives
)]));
5940 procedure PlayerSettingsCVars(P
: SSArray
);
5945 function ParseTeam(s
: string): Byte;
5949 'red', '1': result
:= TEAM_RED
;
5950 'blue', '2': result
:= TEAM_BLUE
;
5951 else result
:= TEAM_NONE
;
5955 cmd
:= LowerCase(P
[0]);
5959 if (Length(P
) > 1) then
5961 gPlayer1Settings
.Name
:= b_Text_Unformat(P
[1]);
5962 if g_Game_IsClient
then
5963 MC_SEND_PlayerSettings
5964 else if gGameOn
and (gPlayer1
<> nil) then
5966 gPlayer1
.Name
:= b_Text_Unformat(P
[1]);
5967 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer1
.UID
);
5973 if (Length(P
) > 1) then
5975 gPlayer2Settings
.Name
:= b_Text_Unformat(P
[1]);
5976 if g_Game_IsClient
then
5977 MC_SEND_PlayerSettings
5978 else if gGameOn
and (gPlayer2
<> nil) then
5980 gPlayer2
.Name
:= b_Text_Unformat(P
[1]);
5981 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer2
.UID
);
5987 if Length(P
) > 3 then
5989 gPlayer1Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
5990 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
5991 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
5992 if g_Game_IsClient
then
5993 MC_SEND_PlayerSettings
5994 else if gGameOn
and (gPlayer1
<> nil) then
5996 gPlayer1
.SetColor(gPlayer1Settings
.Color
);
5997 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer1
.UID
);
6003 if Length(P
) > 3 then
6005 gPlayer2Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
6006 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
6007 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
6008 if g_Game_IsClient
then
6009 MC_SEND_PlayerSettings
6010 else if gGameOn
and (gPlayer2
<> nil) then
6012 gPlayer2
.SetColor(gPlayer2Settings
.Color
);
6013 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer2
.UID
);
6019 if (Length(P
) > 1) then
6021 gPlayer1Settings
.Model
:= P
[1];
6022 if g_Game_IsClient
then
6023 MC_SEND_PlayerSettings
6024 else if gGameOn
and (gPlayer1
<> nil) then
6026 gPlayer1
.FActualModelName
:= gPlayer1Settings
.Model
;
6027 gPlayer1
.SetModel(gPlayer1Settings
.Model
);
6028 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer1
.UID
);
6034 if (Length(P
) > 1) then
6036 gPlayer2Settings
.Model
:= P
[1];
6037 if g_Game_IsClient
then
6038 MC_SEND_PlayerSettings
6039 else if gGameOn
and (gPlayer2
<> nil) then
6041 gPlayer2
.FActualModelName
:= gPlayer2Settings
.Model
;
6042 gPlayer2
.SetModel(gPlayer2Settings
.Model
);
6043 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer2
.UID
);
6049 // TODO: switch teams if in game or store this separately
6050 if (Length(P
) > 1) then
6052 team
:= ParseTeam(P
[1]);
6053 if team
= TEAM_NONE
then
6054 g_Console_Add('expected ''red'', ''blue'', 1 or 2')
6055 else if not gGameOn
and not g_Game_IsNet
then
6056 gPlayer1Settings
.Team
:= team
6058 g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
6063 // TODO: switch teams if in game or store this separately
6064 if (Length(P
) > 1) then
6066 team
:= ParseTeam(P
[1]);
6067 if team
= TEAM_NONE
then
6068 g_Console_Add('expected ''red'', ''blue'', 1 or 2')
6069 else if not gGameOn
and not g_Game_IsNet
then
6070 gPlayer2Settings
.Team
:= team
6072 g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
6077 if (Length(P
) = 2) then
6078 gPlayer1Settings
.WeaponSwitch
:= EnsureRange(StrTointDef(P
[1], 0), 0, 2);
6082 if (Length(P
) = 2) then
6083 gPlayer2Settings
.WeaponSwitch
:= EnsureRange(StrTointDef(P
[1], 0), 0, 2);
6087 if (Length(P
) = 2) then
6088 gPlayer1Settings
.SwitchToEmpty
:= EnsureRange(StrTointDef(P
[1], 0), 0, 1);
6092 if (Length(P
) = 2) then
6093 gPlayer2Settings
.SwitchToEmpty
:= EnsureRange(StrTointDef(P
[1], 0), 0, 1);
6097 if (Length(P
) = 2) then
6098 gPlayer1Settings
.SkipFist
:= EnsureRange(StrTointDef(P
[1], 0), 0, 1);
6102 if (Length(P
) = 2) then
6103 gPlayer2Settings
.SkipFist
:= EnsureRange(StrTointDef(P
[1], 0), 0, 1);
6105 'p1_priority_kastet':
6107 if (Length(P
) = 2) then
6108 gPlayer1Settings
.WeaponPreferences
[WEAPON_KASTET
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6110 'p2_priority_kastet':
6112 if (Length(P
) = 2) then
6113 gPlayer2Settings
.WeaponPreferences
[WEAPON_KASTET
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6117 if (Length(P
) = 2) then
6118 gPlayer1Settings
.WeaponPreferences
[WEAPON_SAW
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6122 if (Length(P
) = 2) then
6123 gPlayer2Settings
.WeaponPreferences
[WEAPON_SAW
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6125 'p1_priority_pistol':
6127 if (Length(P
) = 2) then
6128 gPlayer1Settings
.WeaponPreferences
[WEAPON_KASTET
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6130 'p2_priority_pistol':
6132 if (Length(P
) = 2) then
6133 gPlayer2Settings
.WeaponPreferences
[WEAPON_KASTET
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6135 'p1_priority_shotgun1':
6137 if (Length(P
) = 2) then
6138 gPlayer1Settings
.WeaponPreferences
[WEAPON_SHOTGUN1
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6140 'p2_priority_shotgun1':
6142 if (Length(P
) = 2) then
6143 gPlayer2Settings
.WeaponPreferences
[WEAPON_SHOTGUN1
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6145 'p1_priority_shotgun2':
6147 if (Length(P
) = 2) then
6148 gPlayer1Settings
.WeaponPreferences
[WEAPON_SHOTGUN2
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6150 'p2_priority_shotgun2':
6152 if (Length(P
) = 2) then
6153 gPlayer2Settings
.WeaponPreferences
[WEAPON_SHOTGUN2
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6155 'p1_priority_chaingun':
6157 if (Length(P
) = 2) then
6158 gPlayer1Settings
.WeaponPreferences
[WEAPON_CHAINGUN
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6160 'p2_priority_chaingun':
6162 if (Length(P
) = 2) then
6163 gPlayer2Settings
.WeaponPreferences
[WEAPON_CHAINGUN
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6165 'p1_priority_rocketlauncher':
6167 if (Length(P
) = 2) then
6168 gPlayer1Settings
.WeaponPreferences
[WEAPON_ROCKETLAUNCHER
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6170 'p2_priority_rocketlauncher':
6172 if (Length(P
) = 2) then
6173 gPlayer2Settings
.WeaponPreferences
[WEAPON_ROCKETLAUNCHER
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6175 'p1_priority_plasma':
6177 if (Length(P
) = 2) then
6178 gPlayer1Settings
.WeaponPreferences
[WEAPON_PLASMA
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6180 'p2_priority_plasma':
6182 if (Length(P
) = 2) then
6183 gPlayer2Settings
.WeaponPreferences
[WEAPON_PLASMA
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6187 if (Length(P
) = 2) then
6188 gPlayer1Settings
.WeaponPreferences
[WEAPON_BFG
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6192 if (Length(P
) = 2) then
6193 gPlayer2Settings
.WeaponPreferences
[WEAPON_BFG
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6195 'p1_priority_super':
6197 if (Length(P
) = 2) then
6198 gPlayer1Settings
.WeaponPreferences
[WEAPON_SUPERPULEMET
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6200 'p2_priority_super':
6202 if (Length(P
) = 2) then
6203 gPlayer2Settings
.WeaponPreferences
[WEAPON_SUPERPULEMET
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6205 'p1_priority_flamethrower':
6207 if (Length(P
) = 2) then
6208 gPlayer1Settings
.WeaponPreferences
[WEAPON_FLAMETHROWER
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6210 'p2_priority_flamethrower':
6212 if (Length(P
) = 2) then
6213 gPlayer2Settings
.WeaponPreferences
[WEAPON_FLAMETHROWER
] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6215 'p1_priority_berserk':
6217 if (Length(P
) = 2) then
6218 gPlayer1Settings
.WeaponPreferences
[WP_LAST
+1] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6220 'p2_priority_berserk':
6222 if (Length(P
) = 2) then
6223 gPlayer2Settings
.WeaponPreferences
[WP_LAST
+1] := EnsureRange(StrToIntDef(P
[1], WP_FIRST
), WP_FIRST
, WP_LAST
+1);
6228 procedure PrintHeapStats();
6232 hs
:= GetFPCHeapStatus();
6233 e_LogWriteLn ('v===== heap status =====v');
6234 e_LogWriteFln('max heap size = %d k', [hs
.MaxHeapSize
div 1024]);
6235 e_LogWriteFln('max heap used = %d k', [hs
.MaxHeapUsed
div 1024]);
6236 e_LogWriteFln('cur heap size = %d k', [hs
.CurrHeapSize
div 1024]);
6237 e_LogWriteFln('cur heap used = %d k', [hs
.CurrHeapUsed
div 1024]);
6238 e_LogWriteFln('cur heap free = %d k', [hs
.CurrHeapFree
div 1024]);
6239 e_LogWriteLn ('^=======================^');
6242 procedure DebugCommands(P
: SSArray
);
6249 // Êîìàíäû îòëàäî÷íîãî ðåæèìà:
6250 if {gDebugMode}conIsCheatsEnabled
then
6252 cmd
:= LowerCase(P
[0]);
6253 if cmd
= 'd_window' then
6255 g_Console_Add(Format('gScreenWidth = %d, gScreenHeight = %d', [gScreenWidth
, gScreenHeight
]));
6256 g_Console_Add(Format('gScreenWidth = %d, gScreenHeight = %d', [gScreenWidth
, gScreenHeight
]));
6258 else if cmd
= 'd_sounds' then
6260 if (Length(P
) > 1) and
6261 ((P
[1] = '1') or (P
[1] = '0')) then
6262 g_Debug_Sounds
:= (P
[1][1] = '1');
6264 g_Console_Add(Format('d_sounds is %d', [Byte(g_Debug_Sounds
)]));
6266 else if cmd
= 'd_frames' then
6268 if (Length(P
) > 1) and
6269 ((P
[1] = '1') or (P
[1] = '0')) then
6270 g_Debug_Frames
:= (P
[1][1] = '1');
6272 g_Console_Add(Format('d_frames is %d', [Byte(g_Debug_Frames
)]));
6274 else if cmd
= 'd_winmsg' then
6276 if (Length(P
) > 1) and
6277 ((P
[1] = '1') or (P
[1] = '0')) then
6278 g_Debug_WinMsgs
:= (P
[1][1] = '1');
6280 g_Console_Add(Format('d_winmsg is %d', [Byte(g_Debug_WinMsgs
)]));
6282 else if (cmd
= 'd_monoff') and not g_Game_IsNet
then
6284 if (Length(P
) > 1) and
6285 ((P
[1] = '1') or (P
[1] = '0')) then
6286 g_Debug_MonsterOff
:= (P
[1][1] = '1');
6288 g_Console_Add(Format('d_monoff is %d', [Byte(g_debug_MonsterOff
)]));
6290 else if (cmd
= 'd_botoff') and not g_Game_IsNet
then
6292 if Length(P
) > 1 then
6294 '0': g_debug_BotAIOff
:= 0;
6295 '1': g_debug_BotAIOff
:= 1;
6296 '2': g_debug_BotAIOff
:= 2;
6297 '3': g_debug_BotAIOff
:= 3;
6300 g_Console_Add(Format('d_botoff is %d', [g_debug_BotAIOff
]));
6302 else if cmd
= 'd_monster' then
6304 if gGameOn
and (gPlayer1
<> nil) and (gPlayer1
.alive
) and (not g_Game_IsNet
) then
6305 if Length(P
) < 2 then
6307 g_Console_Add(cmd
+ ' [ID | Name] [behaviour]');
6308 g_Console_Add('ID | Name');
6309 for b
:= MONSTER_DEMON
to MONSTER_MAN
do
6310 g_Console_Add(Format('%2d | %s', [b
, g_Mons_NameByTypeId(b
)]));
6311 conwriteln('behav. num'#10'normal 0'#10'killer 1'#10'maniac 2'#10'insane 3'#10'cannibal 4'#10'good 5');
6314 a
:= StrToIntDef(P
[1], 0);
6315 if (a
< MONSTER_DEMON
) or (a
> MONSTER_MAN
) then
6316 a
:= g_Mons_TypeIdByName(P
[1]);
6318 if (a
< MONSTER_DEMON
) or (a
> MONSTER_MAN
) then
6319 g_Console_Add(Format(_lc
[I_MSG_NO_MONSTER
], [P
[1]]))
6322 with gPlayer1
.Obj
do
6324 mon
:= g_Monsters_Create(a
,
6325 X
+ Rect
.X
+ (Rect
.Width
div 2),
6326 Y
+ Rect
.Y
+ Rect
.Height
,
6327 gPlayer1
.Direction
, True);
6329 if (Length(P
) > 2) and (mon
<> nil) then
6331 if (CompareText(P
[2], 'normal') = 0) then mon
.MonsterBehaviour
:= BH_NORMAL
6332 else if (CompareText(P
[2], 'killer') = 0) then mon
.MonsterBehaviour
:= BH_KILLER
6333 else if (CompareText(P
[2], 'maniac') = 0) then mon
.MonsterBehaviour
:= BH_MANIAC
6334 else if (CompareText(P
[2], 'insane') = 0) then mon
.MonsterBehaviour
:= BH_INSANE
6335 else if (CompareText(P
[2], 'cannibal') = 0) then mon
.MonsterBehaviour
:= BH_CANNIBAL
6336 else if (CompareText(P
[2], 'good') = 0) then mon
.MonsterBehaviour
:= BH_GOOD
6337 else if (CompareText(P
[2], 'friend') = 0) then mon
.MonsterBehaviour
:= BH_GOOD
6338 else if (CompareText(P
[2], 'friendly') = 0) then mon
.MonsterBehaviour
:= BH_GOOD
6339 else mon
.MonsterBehaviour
:= Min(Max(StrToIntDef(P
[2], BH_NORMAL
), BH_NORMAL
), BH_GOOD
);
6344 else if (cmd
= 'd_health') then
6346 if (Length(P
) > 1) and
6347 ((P
[1] = '1') or (P
[1] = '0')) then
6348 g_debug_HealthBar
:= (P
[1][1] = '1');
6350 g_Console_Add(Format('d_health is %d', [Byte(g_debug_HealthBar
)]));
6352 else if (cmd
= 'd_player') then
6354 if (Length(P
) > 1) and
6355 ((P
[1] = '1') or (P
[1] = '0')) then
6356 g_debug_Player
:= (P
[1][1] = '1');
6358 g_Console_Add(Format(cmd
+ ' is %d', [Byte(g_Debug_Player
)]));
6360 else if (cmd
= 'd_mem') then
6366 g_Console_Add(_lc
[I_MSG_NOT_DEBUG
]);
6370 procedure GameCheats(P
: SSArray
);
6376 if (not gGameOn
) or (not conIsCheatsEnabled
) then
6378 g_Console_Add('not available');
6384 g_Console_Add('where is the player?!');
6387 cmd
:= LowerCase(P
[0]);
6391 plr
.GodMode
:= not plr
.GodMode
;
6392 if plr
.GodMode
then g_Console_Add('player is godlike now') else g_Console_Add('player is mortal now');
6395 // give <health|exit|weapons|air|suit|jetpack|berserk|all>
6396 if cmd
= 'give' then
6398 if length(P
) < 2 then begin g_Console_Add('give what?!'); exit
; end;
6399 for f
:= 1 to High(P
) do
6401 cmd
:= LowerCase(P
[f
]);
6402 if cmd
= 'health' then begin plr
.RestoreHealthArmor(); g_Console_Add('player feels himself better'); continue
; end;
6403 if (cmd
= 'all') {or (cmd = 'weapons')} then begin plr
.AllRulez(False); g_Console_Add('player got the gifts'); continue
; end;
6404 if cmd
= 'exit' then
6406 if gTriggers
<> nil then
6408 for a
:= 0 to High(gTriggers
) do
6410 if gTriggers
[a
].TriggerType
= TRIGGER_EXIT
then
6412 g_Console_Add('player left the map');
6413 gExitByTrigger
:= True;
6414 //g_Game_ExitLevel(gTriggers[a].Data.MapName);
6415 g_Game_ExitLevel(gTriggers
[a
].tgcMap
);
6423 if cmd
= 'air' then begin plr
.GiveItem(ITEM_OXYGEN
); g_Console_Add('player got some air'); continue
; end;
6424 if cmd
= 'jetpack' then begin plr
.GiveItem(ITEM_JETPACK
); g_Console_Add('player got a jetpack'); continue
; end;
6425 if cmd
= 'suit' then begin plr
.GiveItem(ITEM_SUIT
); g_Console_Add('player got an envirosuit'); continue
; end;
6426 if cmd
= 'berserk' then begin plr
.GiveItem(ITEM_MEDKIT_BLACK
); g_Console_Add('player got a berserk pack'); continue
; end;
6427 if cmd
= 'backpack' then begin plr
.GiveItem(ITEM_AMMO_BACKPACK
); g_Console_Add('player got a backpack'); continue
; end;
6429 if cmd
= 'helmet' then begin plr
.GiveItem(ITEM_HELMET
); g_Console_Add('player got a helmet'); continue
; end;
6430 if cmd
= 'bottle' then begin plr
.GiveItem(ITEM_BOTTLE
); g_Console_Add('player got a bottle of health'); continue
; end;
6432 if cmd
= 'stimpack' then begin plr
.GiveItem(ITEM_MEDKIT_SMALL
); g_Console_Add('player got a stimpack'); continue
; end;
6433 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;
6435 if cmd
= 'greenarmor' then begin plr
.GiveItem(ITEM_ARMOR_GREEN
); g_Console_Add('player got a security armor'); continue
; end;
6436 if cmd
= 'bluearmor' then begin plr
.GiveItem(ITEM_ARMOR_BLUE
); g_Console_Add('player got a combat armor'); continue
; end;
6438 if (cmd
= 'megasphere') or (cmd
= 'mega') then begin plr
.GiveItem(ITEM_SPHERE_BLUE
); g_Console_Add('player got a megasphere'); continue
; end;
6439 if (cmd
= 'soulsphere') or (cmd
= 'soul')then begin plr
.GiveItem(ITEM_SPHERE_WHITE
); g_Console_Add('player got a soul sphere'); continue
; end;
6441 if (cmd
= 'invul') or (cmd
= 'invulnerability') then begin plr
.GiveItem(ITEM_INVUL
); g_Console_Add('player got invulnerability'); continue
; end;
6442 if (cmd
= 'invis') or (cmd
= 'invisibility') then begin plr
.GiveItem(ITEM_INVIS
); g_Console_Add('player got invisibility'); continue
; end;
6444 if cmd
= 'redkey' then begin plr
.GiveItem(ITEM_KEY_RED
); g_Console_Add('player got the red key'); continue
; end;
6445 if cmd
= 'greenkey' then begin plr
.GiveItem(ITEM_KEY_GREEN
); g_Console_Add('player got the green key'); continue
; end;
6446 if cmd
= 'bluekey' then begin plr
.GiveItem(ITEM_KEY_BLUE
); g_Console_Add('player got the blue key'); continue
; end;
6448 if (cmd
= 'shotgun') or (cmd
= 'sg') then begin plr
.GiveItem(ITEM_WEAPON_SHOTGUN1
); g_Console_Add('player got a shotgun'); continue
; end;
6449 if (cmd
= 'supershotgun') or (cmd
= 'ssg') then begin plr
.GiveItem(ITEM_WEAPON_SHOTGUN2
); g_Console_Add('player got a supershotgun'); continue
; end;
6450 if cmd
= 'chaingun' then begin plr
.GiveItem(ITEM_WEAPON_CHAINGUN
); g_Console_Add('player got a chaingun'); continue
; end;
6451 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;
6452 if cmd
= 'plasmagun' then begin plr
.GiveItem(ITEM_WEAPON_PLASMA
); g_Console_Add('player got a plasma gun'); continue
; end;
6453 if cmd
= 'bfg' then begin plr
.GiveItem(ITEM_WEAPON_BFG
); g_Console_Add('player got a BFG-9000'); continue
; end;
6455 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;
6456 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;
6457 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;
6458 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;
6459 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;
6460 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;
6462 if cmd
= 'superchaingun' then begin plr
.GiveItem(ITEM_WEAPON_SUPERPULEMET
); g_Console_Add('player got a superchaingun'); continue
; end;
6463 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;
6465 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;
6466 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;
6468 if cmd
= 'chainsaw' then begin plr
.GiveItem(ITEM_WEAPON_SAW
); g_Console_Add('player got a chainsaw'); continue
; end;
6470 if cmd
= 'ammo' then
6472 plr
.GiveItem(ITEM_AMMO_SHELLS_BOX
);
6473 plr
.GiveItem(ITEM_AMMO_BULLETS_BOX
);
6474 plr
.GiveItem(ITEM_AMMO_CELL_BIG
);
6475 plr
.GiveItem(ITEM_AMMO_ROCKET_BOX
);
6476 plr
.GiveItem(ITEM_AMMO_FUELCAN
);
6477 g_Console_Add('player got some ammo');
6481 if cmd
= 'clip' then begin plr
.GiveItem(ITEM_AMMO_BULLETS
); g_Console_Add('player got some bullets'); continue
; end;
6482 if cmd
= 'bullets' then begin plr
.GiveItem(ITEM_AMMO_BULLETS_BOX
); g_Console_Add('player got a box of bullets'); continue
; end;
6484 if cmd
= 'shells' then begin plr
.GiveItem(ITEM_AMMO_SHELLS
); g_Console_Add('player got some shells'); continue
; end;
6485 if cmd
= 'shellbox' then begin plr
.GiveItem(ITEM_AMMO_SHELLS_BOX
); g_Console_Add('player got a box of shells'); continue
; end;
6487 if cmd
= 'cells' then begin plr
.GiveItem(ITEM_AMMO_CELL
); g_Console_Add('player got some cells'); continue
; end;
6488 if cmd
= 'battery' then begin plr
.GiveItem(ITEM_AMMO_CELL_BIG
); g_Console_Add('player got cell battery'); continue
; end;
6490 if cmd
= 'rocket' then begin plr
.GiveItem(ITEM_AMMO_ROCKET
); g_Console_Add('player got a rocket'); continue
; end;
6491 if cmd
= 'rocketbox' then begin plr
.GiveItem(ITEM_AMMO_ROCKET_BOX
); g_Console_Add('player got some rockets'); continue
; end;
6493 if (cmd
= 'fuel') or (cmd
= 'fuelcan') then begin plr
.GiveItem(ITEM_AMMO_FUELCAN
); g_Console_Add('player got fuel canister'); continue
; end;
6495 if cmd
= 'weapons' then
6497 plr
.GiveItem(ITEM_WEAPON_SHOTGUN1
);
6498 plr
.GiveItem(ITEM_WEAPON_SHOTGUN2
);
6499 plr
.GiveItem(ITEM_WEAPON_CHAINGUN
);
6500 plr
.GiveItem(ITEM_WEAPON_ROCKETLAUNCHER
);
6501 plr
.GiveItem(ITEM_WEAPON_PLASMA
);
6502 plr
.GiveItem(ITEM_WEAPON_BFG
);
6503 g_Console_Add('player got weapons');
6507 if cmd
= 'keys' then
6509 plr
.GiveItem(ITEM_KEY_RED
);
6510 plr
.GiveItem(ITEM_KEY_GREEN
);
6511 plr
.GiveItem(ITEM_KEY_BLUE
);
6512 g_Console_Add('player got all keys');
6516 g_Console_Add('i don''t know how to give '''+cmd
+'''!');
6521 if cmd
= 'open' then
6523 g_Console_Add('player activated sesame');
6524 g_Triggers_OpenAll();
6531 if gFly
then g_Console_Add('player feels himself lighter') else g_Console_Add('player lost his wings');
6535 if cmd
= 'noclip' then
6538 g_Console_Add('wall hardeness adjusted');
6542 if cmd
= 'notarget' then
6544 plr
.NoTarget
:= not plr
.NoTarget
;
6545 if plr
.NoTarget
then g_Console_Add('player hides in shadows') else g_Console_Add('player is brave again');
6549 if cmd
= 'noreload' then
6551 plr
.NoReload
:= not plr
.NoReload
;
6552 if plr
.NoReload
then g_Console_Add('player is action hero now') else g_Console_Add('player is ordinary man now');
6556 if cmd
= 'speedy' then
6558 MAX_RUNVEL
:= 32-MAX_RUNVEL
;
6559 g_Console_Add('speed adjusted');
6563 if cmd
= 'jumpy' then
6565 VEL_JUMP
:= 30-VEL_JUMP
;
6566 g_Console_Add('jump height adjusted');
6570 if cmd
= 'automap' then
6572 gShowMap
:= not gShowMap
;
6573 if gShowMap
then g_Console_Add('player gains second sight') else g_Console_Add('player lost second sight');
6577 if cmd
= 'aimline' then
6579 gAimLine
:= not gAimLine
;
6580 if gAimLine
then g_Console_Add('player gains laser sight') else g_Console_Add('player lost laser sight');
6585 procedure GameCommands(P
: SSArray
);
6591 pl
: pTNetClient
= nil;
6600 cmd
:= LowerCase(P
[0]);
6602 if cmd
= 'pause' then
6604 if (g_ActiveWindow
= nil) then
6605 g_Game_Pause(not gPauseMain
);
6607 else if cmd
= 'endgame' then
6608 gExit
:= EXIT_SIMPLE
6609 else if cmd
= 'restart' then
6611 if gGameOn
or (gState
in [STATE_INTERSINGLE
, STATE_INTERCUSTOM
]) then
6613 if g_Game_IsClient
then
6615 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6620 g_Console_Add(_lc
[I_MSG_NOT_GAME
]);
6622 else if cmd
= 'kick' then
6624 if g_Game_IsServer
then
6626 if Length(P
) < 2 then
6628 g_Console_Add('kick <name>');
6633 g_Console_Add('kick <name>');
6637 if g_Game_IsNet
then
6638 pl
:= g_Net_Client_ByName(P
[1]);
6641 s
:= g_Net_ClientName_ByID(pl
^.ID
);
6642 g_Net_Host_Kick(pl
^.ID
, NET_DISC_KICK
);
6643 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
6644 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
6645 g_Net_Slist_ServerPlayerLeaves();
6646 end else if gPlayers
<> nil then
6647 for a
:= Low(gPlayers
) to High(gPlayers
) do
6648 if gPlayers
[a
] <> nil then
6649 if Copy(LowerCase(gPlayers
[a
].Name
), 1, Length(P
[1])) = LowerCase(P
[1]) then
6651 // Íå îòêëþ÷àòü îñíîâíûõ èãðîêîâ â ñèíãëå
6652 if not(gPlayers
[a
] is TBot
) and (gGameSettings
.GameType
= GT_SINGLE
) then
6654 gPlayers
[a
].Lives
:= 0;
6655 gPlayers
[a
].Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
6656 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [gPlayers
[a
].Name
]), True);
6657 g_Player_Remove(gPlayers
[a
].UID
);
6658 g_Net_Slist_ServerPlayerLeaves();
6659 // Åñëè íå ïåðåìåøàòü, ïðè äîáàâëåíèè íîâûõ áîòîâ ïîÿâÿòñÿ ñòàðûå
6663 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
6665 else if cmd
= 'kick_id' then
6667 if g_Game_IsServer
and g_Game_IsNet
then
6669 if Length(P
) < 2 then
6671 g_Console_Add('kick_id <client ID>');
6676 g_Console_Add('kick_id <client ID>');
6680 a
:= StrToIntDef(P
[1], 0);
6681 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
6683 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
6685 s
:= g_Net_ClientName_ByID(NetClients
[a
].ID
);
6686 g_Net_Host_Kick(NetClients
[a
].ID
, NET_DISC_KICK
);
6687 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
6688 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
6689 g_Net_Slist_ServerPlayerLeaves();
6693 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6695 else if cmd
= 'kick_pid' then
6697 if g_Game_IsServer
and g_Game_IsNet
then
6699 if Length(P
) < 2 then
6701 g_Console_Add('kick_pid <player ID>');
6706 g_Console_Add('kick_pid <player ID>');
6710 a
:= StrToIntDef(P
[1], 0);
6711 pl
:= g_Net_Client_ByPlayer(a
);
6712 if (pl
<> nil) and pl
^.Used
and (pl
^.Peer
<> nil) then
6714 s
:= g_Net_ClientName_ByID(pl
^.ID
);
6715 g_Net_Host_Kick(pl
^.ID
, NET_DISC_KICK
);
6716 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
6717 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
6718 g_Net_Slist_ServerPlayerLeaves();
6721 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6723 else if cmd
= 'ban' then
6725 if g_Game_IsServer
and g_Game_IsNet
then
6727 if Length(P
) < 2 then
6729 g_Console_Add('ban <name>');
6734 g_Console_Add('ban <name>');
6738 pl
:= g_Net_Client_ByName(P
[1]);
6740 g_Net_Host_Ban(pl
, False)
6742 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
6744 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6746 else if cmd
= 'ban_id' then
6748 if g_Game_IsServer
and g_Game_IsNet
then
6750 if Length(P
) < 2 then
6752 g_Console_Add('ban_id <client ID>');
6757 g_Console_Add('ban_id <client ID>');
6761 a
:= StrToIntDef(P
[1], 0);
6762 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
6763 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
6764 g_Net_Host_Ban(pl
, False);
6766 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6768 else if cmd
= 'ban_pid' then
6770 if g_Game_IsServer
and g_Game_IsNet
then
6772 if Length(P
) < 2 then
6774 g_Console_Add('ban_pid <player ID>');
6779 g_Console_Add('ban_pid <player ID>');
6783 a
:= StrToIntDef(P
[1], 0);
6784 pl
:= g_Net_Client_ByPlayer(a
);
6785 if (pl
<> nil) and pl
^.Used
and (pl
^.Peer
<> nil) then
6786 g_Net_Host_Ban(pl
, False);
6788 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6790 else if cmd
= 'permban' then
6792 if g_Game_IsServer
and g_Game_IsNet
then
6794 if Length(P
) < 2 then
6796 g_Console_Add('permban <name>');
6801 g_Console_Add('permban <name>');
6805 pl
:= g_Net_Client_ByName(P
[1]);
6807 g_Net_Host_Ban(pl
, True)
6809 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
6811 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6813 else if cmd
= 'permban_id' then
6815 if g_Game_IsServer
and g_Game_IsNet
then
6817 if Length(P
) < 2 then
6819 g_Console_Add('permban_id <client ID>');
6824 g_Console_Add('permban_id <client ID>');
6828 a
:= StrToIntDef(P
[1], 0);
6829 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
6830 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
6831 g_Net_Host_Ban(@NetClients
[a
], True);
6833 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6835 else if cmd
= 'permban_pid' then
6837 if g_Game_IsServer
and g_Game_IsNet
then
6839 if Length(P
) < 2 then
6841 g_Console_Add('permban_pid <player ID>');
6846 g_Console_Add('permban_pid <player ID>');
6850 a
:= StrToIntDef(P
[1], 0);
6851 pl
:= g_Net_Client_ByPlayer(a
);
6852 if (pl
<> nil) and pl
^.Used
and (pl
^.Peer
<> nil) then
6853 g_Net_Host_Ban(pl
, True);
6855 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6857 else if cmd
= 'permban_ip' then
6859 if g_Game_IsServer
and g_Game_IsNet
then
6861 if Length(P
) < 2 then
6863 g_Console_Add('permban_ip <IP address>');
6868 g_Console_Add('permban_ip <IP address>');
6872 g_Net_BanAddress(P
[1]);
6873 g_Net_SaveBanList();
6874 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [P
[1]]));
6876 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6878 else if cmd
= 'unban' then
6880 if g_Game_IsServer
and g_Game_IsNet
then
6882 if Length(P
) < 2 then
6884 g_Console_Add('unban <IP Address>');
6889 g_Console_Add('unban <IP Address>');
6893 if g_Net_UnbanAddress(P
[1]) then
6895 g_Console_Add(Format(_lc
[I_MSG_UNBAN_OK
], [P
[1]]));
6896 g_Net_SaveBanList();
6898 g_Console_Add(Format(_lc
[I_MSG_UNBAN_FAIL
], [P
[1]]));
6900 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6902 else if cmd
= 'clientlist' then
6904 if g_Game_IsServer
and g_Game_IsNet
then
6907 if NetClients
<> nil then
6908 for a
:= Low(NetClients
) to High(NetClients
) do
6909 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
6911 plr
:= g_Player_Get(NetClients
[a
].Player
);
6912 if plr
= nil then continue
;
6914 g_Console_Add(Format('#%2d: %-15s | %s', [a
,
6915 IpToStr(NetClients
[a
].Peer
^.address
.host
), plr
.Name
]));
6918 g_Console_Add(_lc
[I_MSG_NOCLIENTS
]);
6920 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
6922 else if cmd
= 'connect' then
6924 if (NetMode
= NET_NONE
) then
6926 if Length(P
) < 2 then
6928 g_Console_Add('connect <IP> [port] [password]');
6933 g_Console_Add('connect <IP> [port] [password]');
6937 if Length(P
) > 2 then
6938 prt
:= StrToIntDef(P
[2], 25666)
6942 if Length(P
) > 3 then
6947 g_Game_StartClient(P
[1], prt
, pw
);
6950 else if cmd
= 'disconnect' then
6952 if (NetMode
= NET_CLIENT
) then
6955 else if cmd
= 'reconnect' then
6957 if (NetMode
= NET_SERVER
) then
6960 if (NetMode
= NET_CLIENT
) then
6963 gExit
:= EXIT_SIMPLE
;
6967 //TODO: Use last successful password to reconnect, instead of ''
6968 g_Game_StartClient(NetClientIP
, NetClientPort
, '');
6970 else if (cmd
= 'addbot') or
6971 (cmd
= 'bot_add') then
6974 1: g_Bot_Add(TEAM_NONE
, 2);
6975 2: g_Bot_Add(TEAM_NONE
, StrToIntDef(P
[1], 2));
6977 g_Bot_Add(TEAM_NONE
, StrToIntDef(P
[1], 2), StrToIntDef(P
[2], 100));
6980 else if cmd
= 'bot_addlist' then
6983 1: g_Bot_AddList(TEAM_NONE
, '');
6984 2: g_Bot_AddList(TEAM_NONE
, P
[1], StrToIntDef(P
[1], -1));
6986 if P
[2] = 'red' then
6988 else if P
[2] = 'blue' then
6994 then g_Bot_AddList(t
, P
[1], StrToIntDef(P
[1], -1))
6995 else g_Bot_AddList(t
, P
[1], StrToIntDef(P
[1], -1), StrToIntDef(P
[3], 100));
6998 else if cmd
= 'bot_removeall' then
7000 else if cmd
= 'chat' then
7002 if g_Game_IsNet
then
7004 if Length(P
) > 1 then
7006 for a
:= 1 to High(P
) do
7007 chstr
:= chstr
+ P
[a
] + ' ';
7009 if Length(chstr
) > 200 then SetLength(chstr
, 200);
7011 if Length(chstr
) < 1 then
7013 g_Console_Add('chat <text>');
7017 chstr
:= b_Text_Format(chstr
);
7018 if g_Game_IsClient
then
7019 MC_SEND_Chat(chstr
, NET_CHAT_PLAYER
)
7021 MH_SEND_Chat(gPlayer1Settings
.Name
+ ': ' + chstr
, NET_CHAT_PLAYER
);
7024 g_Console_Add('chat <text>');
7026 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
7028 else if cmd
= 'teamchat' then
7030 if g_Game_IsNet
and (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
7032 if Length(P
) > 1 then
7034 for a
:= 1 to High(P
) do
7035 chstr
:= chstr
+ P
[a
] + ' ';
7037 if Length(chstr
) > 200 then SetLength(chstr
, 200);
7039 if Length(chstr
) < 1 then
7041 g_Console_Add('teamchat <text>');
7045 chstr
:= b_Text_Format(chstr
);
7046 if g_Game_IsClient
then
7047 MC_SEND_Chat(chstr
, NET_CHAT_TEAM
)
7049 MH_SEND_Chat(gPlayer1Settings
.Name
+ ': ' + chstr
, NET_CHAT_TEAM
,
7050 gPlayer1Settings
.Team
);
7053 g_Console_Add('teamchat <text>');
7055 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
7057 else if (cmd
= 'an') or (cmd
= 'announce') then
7059 if g_Game_IsNet
then
7061 if Length(P
) > 1 then
7063 for a
:= 1 to High(P
) do
7064 chstr
:= chstr
+ P
[a
] + ' ';
7066 if Length(chstr
) > 200 then SetLength(chstr
, 200);
7068 if Length(chstr
) < 1 then
7070 g_Console_Add('announce <text>');
7074 chstr
:= 'centerprint 100 ' + b_Text_Format(chstr
);
7075 if g_Game_IsClient
then
7076 MC_SEND_RCONCommand(chstr
)
7078 g_Console_Process(chstr
, True);
7081 g_Console_Add('announce <text>');
7083 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
7085 else if cmd
= 'game' then
7087 if gGameSettings
.GameType
<> GT_NONE
then
7089 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
7092 if Length(P
) = 1 then
7094 g_Console_Add(cmd
+ ' <WAD> [MAP] [# players]');
7097 // game not started yet, load fist map from some wad
7099 s
:= addWadExtension(P
[1]);
7100 found
:= e_FindResource(AllMapDirs
, s
);
7104 P
[1] := ExpandFileName(P
[1]);
7105 // if map not choosed then set first map
7106 if Length(P
) < 3 then
7109 P
[2] := g_Game_GetFirstMap(P
[1]);
7112 s
:= P
[1] + ':\' + UpperCase(P
[2]);
7114 if g_Map_Exist(s
) then
7118 with gGameSettings
do
7120 Options
:= gsGameFlags
;
7121 GameMode
:= g_Game_TextToMode(gsGameMode
);
7122 if gSwitchGameMode
<> GM_NONE
then
7123 GameMode
:= gSwitchGameMode
;
7124 if GameMode
= GM_NONE
then GameMode
:= GM_DM
;
7125 if GameMode
= GM_SINGLE
then GameMode
:= GM_COOP
;
7127 if Length(P
) >= 4 then
7128 b
:= StrToIntDef(P
[3], 1);
7129 g_Game_StartCustom(s
, GameMode
, TimeLimit
,
7130 ScoreLimit
, MaxLives
, Options
, b
);
7135 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
7137 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [UpperCase(P
[2]), P
[1]]));
7139 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]));
7141 else if cmd
= 'host' then
7143 if gGameSettings
.GameType
<> GT_NONE
then
7145 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
7148 if Length(P
) < 4 then
7150 g_Console_Add(cmd
+ ' <listen IP> <port> <WAD> [MAP] [# players]');
7153 if not StrToIp(P
[1], listen
) then
7155 prt
:= StrToIntDef(P
[2], 25666);
7157 s
:= addWadExtension(P
[3]);
7158 found
:= e_FindResource(AllMapDirs
, s
);
7162 // get first map in wad, if not specified
7163 if Length(P
) < 5 then
7166 P
[4] := g_Game_GetFirstMap(P
[1]);
7168 s
:= P
[3] + ':\' + UpperCase(P
[4]);
7169 if g_Map_Exist(s
) then
7173 with gGameSettings
do
7175 Options
:= gsGameFlags
;
7176 GameMode
:= g_Game_TextToMode(gsGameMode
);
7177 if gSwitchGameMode
<> GM_NONE
then GameMode
:= gSwitchGameMode
;
7178 if GameMode
= GM_NONE
then GameMode
:= GM_DM
;
7179 if GameMode
= GM_SINGLE
then GameMode
:= GM_COOP
;
7181 if Length(P
) >= 6 then
7182 b
:= StrToIntDef(P
[5], 0);
7183 g_Game_StartServer(s
, GameMode
, TimeLimit
, ScoreLimit
, MaxLives
, Options
, b
, listen
, prt
)
7189 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[3]]))
7191 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [UpperCase(P
[4]), P
[3]]))
7196 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[3]]))
7199 else if cmd
= 'map' then
7201 if Length(P
) = 1 then
7203 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
7205 g_Console_Add(cmd
+ ' <MAP>');
7206 g_Console_Add(cmd
+ ' <WAD> [MAP]')
7210 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
])
7213 else if not e_IsValidResourceName(P
[1]) then
7215 g_Console_Add('wad name must not be absolute or relative');
7219 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
7221 if Length(P
) < 3 then
7223 // first param is map or wad
7224 s
:= UpperCase(P
[1]);
7225 if g_Map_Exist(gGameSettings
.WAD
+ ':\' + s
) then
7227 gExitByTrigger
:= False;
7230 // already in game, finish current map
7232 gExit
:= EXIT_ENDLEVELCUSTOM
;
7236 // intermission, so change map immediately
7243 found
:= e_FindResource(AllMapDirs
, s
);
7245 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [s
, 'WAD ' + P
[1]]));
7248 // no such map, found wad
7251 P
[1] := ExpandFileName(pw
);
7252 P
[2] := g_Game_GetFirstMap(P
[1]);
7253 s
:= P
[1] + ':\' + P
[2];
7254 if g_Map_Exist(s
) then
7256 gExitByTrigger
:= False;
7259 // already in game, finish current map
7261 gExit
:= EXIT_ENDLEVELCUSTOM
7265 // intermission, so change map immediately
7272 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
7274 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]))
7279 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]))
7285 s
:= addWadExtension(P
[1]);
7286 found
:= e_FindResource(AllMapDirs
, s
);
7290 P
[2] := UpperCase(P
[2]);
7291 s
:= P
[1] + ':\' + P
[2];
7292 if g_Map_Exist(s
) then
7294 gExitByTrigger
:= False;
7298 gExit
:= EXIT_ENDLEVELCUSTOM
7307 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]))
7312 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]))
7318 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
])
7322 else if cmd
= 'nextmap' then
7324 if not(gGameOn
or (gState
= STATE_INTERCUSTOM
)) then
7326 g_Console_Add(_lc
[I_MSG_NOT_GAME
])
7331 if Length(P
) = 1 then
7333 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
7335 g_Console_Add(cmd
+ ' <MAP>');
7336 g_Console_Add(cmd
+ ' <WAD> [MAP]');
7341 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
7344 else if not e_IsValidResourceName(P
[1]) then
7346 g_Console_Add('wad name must not be absolute or relative');
7351 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
7353 if Length(P
) < 3 then
7355 // first param is map or wad
7356 s
:= UpperCase(P
[1]);
7357 if g_Map_Exist(gGameSettings
.WAD
+ ':\' + s
) then
7360 gExitByTrigger
:= False;
7366 // no such map, found wad
7367 pw
:= addWadExtension(P
[1]);
7368 found
:= e_FindResource(MapDirs
, pw
);
7370 found
:= e_FindResource(WadDirs
, pw
);
7372 g_Console_Add(Format(_lc
[I_MSG_NO_MAP_FALLBACK
], [s
, P
[1]]));
7375 // map not specified, select first map
7377 P
[2] := g_Game_GetFirstMap(P
[1]);
7378 s
:= P
[1] + ':\' + P
[2];
7379 if g_Map_Exist(s
) then
7381 gExitByTrigger
:= False;
7388 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
7390 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]))
7395 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]))
7401 // specified two params wad + map
7402 pw
:= addWadExtension(P
[1]);
7403 found
:= e_FindResource(MapDirs
, pw
);
7405 found
:= e_FindResource(MapDirs
, pw
);
7409 P
[2] := UpperCase(P
[2]);
7410 s
:= P
[1] + ':\' + P
[2];
7411 if g_Map_Exist(s
) then
7413 gExitByTrigger
:= False;
7419 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]))
7424 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]))
7430 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
])
7435 if gNextMap
= '' then
7436 g_Console_Add(_lc
[I_MSG_NEXTMAP_UNSET
])
7438 g_Console_Add(Format(_lc
[I_MSG_NEXTMAP_SET
], [gNextMap
]))
7442 else if (cmd
= 'endmap') or (cmd
= 'goodbye') then
7446 g_Console_Add(_lc
[I_MSG_NOT_GAME
])
7450 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
7452 gExitByTrigger
:= False;
7453 // next map not specified, try to find trigger EXIT
7454 if (gNextMap
= '') and (gTriggers
<> nil) then
7456 for a
:= 0 to High(gTriggers
) do
7458 if gTriggers
[a
].TriggerType
= TRIGGER_EXIT
then
7460 gExitByTrigger
:= True;
7461 //gNextMap := gTriggers[a].Data.MapName;
7462 gNextMap
:= gTriggers
[a
].tgcMap
;
7467 if gNextMap
= '' then
7468 gNextMap
:= g_Game_GetNextMap();
7469 if not isWadPath(gNextMap
) then
7470 s
:= gGameSettings
.WAD
+ ':\' + gNextMap
7473 if g_Map_Exist(s
) then
7474 gExit
:= EXIT_ENDLEVELCUSTOM
7476 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [gNextMap
]))
7480 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
])
7484 else if (cmd
= 'event') then
7486 if (Length(P
) <= 1) then
7488 for a
:= 0 to High(gEvents
) do
7489 if gEvents
[a
].Command
= '' then
7490 g_Console_Add(gEvents
[a
].Name
+ ' <none>')
7492 g_Console_Add(gEvents
[a
].Name
+ ' "' + gEvents
[a
].Command
+ '"');
7495 if (Length(P
) = 2) then
7497 for a
:= 0 to High(gEvents
) do
7498 if gEvents
[a
].Name
= P
[1] then
7499 if gEvents
[a
].Command
= '' then
7500 g_Console_Add(gEvents
[a
].Name
+ ' <none>')
7502 g_Console_Add(gEvents
[a
].Name
+ ' "' + gEvents
[a
].Command
+ '"');
7505 for a
:= 0 to High(gEvents
) do
7506 if gEvents
[a
].Name
= P
[1] then
7508 gEvents
[a
].Command
:= '';
7509 for b
:= 2 to High(P
) do
7510 if Pos(' ', P
[b
]) = 0 then
7511 gEvents
[a
].Command
:= gEvents
[a
].Command
+ ' ' + P
[b
]
7513 gEvents
[a
].Command
:= gEvents
[a
].Command
+ ' "' + P
[b
] + '"';
7514 gEvents
[a
].Command
:= Trim(gEvents
[a
].Command
);
7518 else if cmd
= 'suicide' then
7522 if g_Game_IsClient
then
7523 MC_SEND_CheatRequest(NET_CHEAT_SUICIDE
)
7526 if gPlayer1
<> nil then
7527 gPlayer1
.Damage(SUICIDE_DAMAGE
, gPlayer1
.UID
, 0, 0, HIT_SELF
);
7528 if gPlayer2
<> nil then
7529 gPlayer2
.Damage(SUICIDE_DAMAGE
, gPlayer2
.UID
, 0, 0, HIT_SELF
);
7533 else if cmd
= 'screenshot' then
7537 else if (cmd
= 'weapnext') or (cmd
= 'weapprev') then
7539 a
:= 1 - (ord(cmd
[5]) - ord('n'));
7541 gWeaponAction
[0, WP_PREV
] := True;
7543 gWeaponAction
[0, WP_NEXT
] := True;
7545 else if cmd
= 'weapon' then
7547 if Length(p
) = 2 then
7549 a
:= WP_FIRST
+ StrToIntDef(p
[1], 0) - 1;
7550 if (a
>= WP_FIRST
) and (a
<= WP_LAST
) then
7551 gSelectWeapon
[0, a
] := True
7554 else if (cmd
= 'p1_weapnext') or (cmd
= 'p1_weapprev')
7555 or (cmd
= 'p2_weapnext') or (cmd
= 'p2_weapprev') then
7557 a
:= 1 - (ord(cmd
[8]) - ord('n'));
7558 b
:= ord(cmd
[2]) - ord('1');
7560 gWeaponAction
[b
, WP_PREV
] := True;
7562 gWeaponAction
[b
, WP_NEXT
] := True;
7564 else if (cmd
= 'p1_weapon') or (cmd
= 'p2_weapon') then
7566 if Length(p
) = 2 then
7568 a
:= WP_FIRST
+ StrToIntDef(p
[1], 0) - 1;
7569 b
:= ord(cmd
[2]) - ord('1');
7570 if (a
>= WP_FIRST
) and (a
<= WP_LAST
) then
7571 gSelectWeapon
[b
, a
] := True
7574 else if (cmd
= 'p1_weapbest') or (cmd
= 'p2_weapbest') then
7576 b
:= ord(cmd
[2]) - ord('1');
7578 gSelectWeapon
[b
, gPlayer1
.GetMorePrefered()] := True
7580 gSelectWeapon
[b
, gPlayer2
.GetMorePrefered()] := True;
7582 else if (cmd
= 'dropflag') then
7584 if g_Game_IsServer
then
7586 if gPlayer2
<> nil then gPlayer2
.TryDropFlag();
7587 if gPlayer1
<> nil then gPlayer1
.TryDropFlag();
7590 MC_SEND_CheatRequest(NET_CHEAT_DROPFLAG
);
7592 else if (cmd
= 'p1_dropflag') or (cmd
= 'p2_dropflag') then
7594 b
:= ord(cmd
[2]) - ord('1');
7595 if g_Game_IsServer
then
7597 if (b
= 1) and (gPlayer2
<> nil) then gPlayer2
.TryDropFlag()
7598 else if (b
= 0) and (gPlayer1
<> nil) then gPlayer1
.TryDropFlag();
7601 MC_SEND_CheatRequest(NET_CHEAT_DROPFLAG
);
7603 // Êîìàíäû Ñâîåé èãðû:
7604 else if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
7606 if cmd
= 'bot_addred' then
7608 if Length(P
) > 1 then
7609 g_Bot_Add(TEAM_RED
, StrToIntDef(P
[1], 2))
7611 g_Bot_Add(TEAM_RED
, 2);
7613 else if cmd
= 'bot_addblue' then
7615 if Length(P
) > 1 then
7616 g_Bot_Add(TEAM_BLUE
, StrToIntDef(P
[1], 2))
7618 g_Bot_Add(TEAM_BLUE
, 2);
7620 else if cmd
= 'spectate' then
7626 else if cmd
= 'say' then
7628 if g_Game_IsServer
and g_Game_IsNet
then
7630 if Length(P
) > 1 then
7633 for a
:= 1 to High(P
) do
7634 chstr
:= chstr
+ P
[a
] + ' ';
7636 if Length(chstr
) > 200 then SetLength(chstr
, 200);
7638 if Length(chstr
) < 1 then
7640 g_Console_Add('say <text>');
7644 chstr
:= b_Text_Format(chstr
);
7645 MH_SEND_Chat(chstr
, NET_CHAT_PLAYER
);
7647 else g_Console_Add('say <text>');
7649 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
7651 else if cmd
= 'tell' then
7653 if g_Game_IsServer
and g_Game_IsNet
then
7655 if (Length(P
) > 2) and (P
[1] <> '') then
7658 for a
:= 2 to High(P
) do
7659 chstr
:= chstr
+ P
[a
] + ' ';
7661 if Length(chstr
) > 200 then SetLength(chstr
, 200);
7663 if Length(chstr
) < 1 then
7665 g_Console_Add('tell <playername> <text>');
7669 pl
:= g_Net_Client_ByName(P
[1]);
7671 MH_SEND_Chat(b_Text_Format(chstr
), NET_CHAT_PLAYER
, pl
^.ID
)
7673 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
7675 else g_Console_Add('tell <playername> <text>');
7677 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
7679 else if cmd
= 'centerprint' then
7681 if (Length(P
) > 2) and (P
[1] <> '') then
7684 for a
:= 2 to High(P
) do
7685 chstr
:= chstr
+ P
[a
] + ' ';
7687 if Length(chstr
) > 200 then SetLength(chstr
, 200);
7689 if Length(chstr
) < 1 then
7691 g_Console_Add('centerprint <timeout> <text>');
7695 a
:= StrToIntDef(P
[1], 100);
7696 chstr
:= b_Text_Format(chstr
);
7697 g_Game_Message(chstr
, a
);
7698 if g_Game_IsNet
and g_Game_IsServer
then
7699 MH_SEND_GameEvent(NET_EV_BIGTEXT
, a
, chstr
);
7701 else g_Console_Add('centerprint <timeout> <text>');
7703 else if (cmd
= 'overtime') and not g_Game_IsClient
then
7705 if (Length(P
) = 1) or (StrToIntDef(P
[1], -1) <= 0) then
7707 // Äîïîëíèòåëüíîå âðåìÿ:
7708 gGameSettings
.TimeLimit
:= (gTime
- gGameStartTime
) div 1000 + Word(StrToIntDef(P
[1], 0));
7710 g_Console_Add(Format(_lc
[I_MSG_TIME_LIMIT
],
7711 [gGameSettings
.TimeLimit
div 3600,
7712 (gGameSettings
.TimeLimit
div 60) mod 60,
7713 gGameSettings
.TimeLimit
mod 60]));
7714 if g_Game_IsNet
then MH_SEND_GameSettings
;
7716 else if (cmd
= 'rcon_password') and g_Game_IsClient
then
7718 if (Length(P
) <= 1) then
7719 g_Console_Add('rcon_password <password>')
7721 MC_SEND_RCONPassword(P
[1]);
7723 else if cmd
= 'rcon' then
7725 if g_Game_IsClient
then
7727 if Length(P
) > 1 then
7730 for a
:= 1 to High(P
) do
7731 chstr
:= chstr
+ P
[a
] + ' ';
7733 if Length(chstr
) > 200 then SetLength(chstr
, 200);
7735 if Length(chstr
) < 1 then
7737 g_Console_Add('rcon <command>');
7741 MC_SEND_RCONCommand(chstr
);
7743 else g_Console_Add('rcon <command>');
7746 else if cmd
= 'ready' then
7748 if g_Game_IsServer
and (gLMSRespawn
= LMS_RESPAWN_WARMUP
) then
7749 gLMSRespawnTime
:= gTime
+ 100;
7751 else if (cmd
= 'callvote') and g_Game_IsNet
then
7753 if Length(P
) > 1 then
7756 for a
:= 1 to High(P
) do begin
7757 if a
> 1 then chstr
:= chstr
+ ' ';
7758 chstr
:= chstr
+ P
[a
];
7761 if Length(chstr
) > 200 then SetLength(chstr
, 200);
7763 if Length(chstr
) < 1 then
7765 g_Console_Add('callvote <command>');
7769 if g_Game_IsClient
then
7770 MC_SEND_Vote(True, chstr
)
7772 g_Game_StartVote(chstr
, gPlayer1Settings
.Name
);
7773 g_Console_Process('vote', True);
7776 g_Console_Add('callvote <command>');
7778 else if (cmd
= 'vote') and g_Game_IsNet
then
7780 if g_Game_IsClient
then
7782 else if gVoteInProgress
then
7784 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
7785 a
:= Floor((NetClientCount
+1)/2.0) + 1
7787 a
:= Floor(NetClientCount
/2.0) + 1;
7792 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_REVOKED
], [gPlayer1Settings
.Name
, gVoteCount
, a
]), True);
7793 MH_SEND_VoteEvent(NET_VE_REVOKE
, gPlayer1Settings
.Name
, 'a', gVoteCount
, a
);
7799 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_VOTE
], [gPlayer1Settings
.Name
, gVoteCount
, a
]), True);
7800 MH_SEND_VoteEvent(NET_VE_VOTE
, gPlayer1Settings
.Name
, 'a', gVoteCount
, a
);
7808 procedure SystemCommands(P
: SSArray
);
7812 cmd
:= LowerCase(P
[0]);
7821 gRC_Width
:= Max(1, gRC_Width
);
7822 gRC_Height
:= Max(1, gRC_Height
);
7823 gBPP
:= Max(1, gBPP
);
7824 if sys_SetDisplayMode(gRC_Width
, gRC_Height
, gBPP
, gRC_FullScreen
, gRC_Maximized
) = True then
7825 e_LogWriteln('resolution changed')
7827 e_LogWriteln('resolution not changed');
7828 sys_EnableVSync(gVSync
);
7832 if Length(p
) = 2 then
7834 gMaxFPS
:= StrToIntDef(p
[1], gMaxFPS
);
7836 gFrameTime
:= 1000 div gMaxFPS
7840 e_LogWritefln('r_maxfps %d', [gMaxFPS
]);
7844 if Length(p
) = 2 then
7846 gAskLanguage
:= true;
7847 gLanguage
:= LANGUAGE_ENGLISH
;
7848 case LowerCase(p
[1]) of
7851 gAskLanguage
:= false;
7852 gLanguage
:= LANGUAGE_ENGLISH
;
7856 gAskLanguage
:= false;
7857 gLanguage
:= LANGUAGE_RUSSIAN
;
7861 gAskLanguage
:= true;
7862 gLanguage
:= LANGUAGE_ENGLISH
;
7865 g_Language_Set(gLanguage
);
7869 e_LogWritefln('usage: %s <English|Russian|Ask>', [cmd
]);
7875 procedure g_TakeScreenShot(Filename
: string = '');
7876 var s
: TStream
; t
: TDateTime
; dir
, date
, name
: String;
7878 if e_NoGraphics
then Exit
;
7880 dir
:= e_GetWriteableDir(ScreenshotDirs
);
7882 if Filename
= '' then
7885 DateTimeToString(date
, 'yyyy-mm-dd-hh-nn-ss', t
);
7886 Filename
:= 'screenshot-' + date
;
7889 name
:= e_CatPath(dir
, Filename
+ '.png');
7890 s
:= createDiskFile(name
);
7892 e_MakeScreenshot(s
, gWinSizeX
, gWinSizeY
);
7894 g_Console_Add(Format(_lc
[I_CONSOLE_SCREENSHOT
], [name
]))
7896 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_WRITE
], [name
]));
7901 g_Console_Add('oh shit, i can''t create screenshot!')
7905 procedure g_Game_InGameMenu(Show
: Boolean);
7907 if (g_ActiveWindow
= nil) and Show
then
7909 if gGameSettings
.GameType
= GT_SINGLE
then
7910 g_GUI_ShowWindow('GameSingleMenu')
7913 if g_Game_IsClient
then
7914 g_GUI_ShowWindow('GameClientMenu')
7916 if g_Game_IsNet
then
7917 g_GUI_ShowWindow('GameServerMenu')
7919 g_GUI_ShowWindow('GameCustomMenu');
7921 g_Sound_PlayEx('MENU_OPEN');
7923 // Ïàóçà ïðè ìåíþ òîëüêî â îäèíî÷íîé èãðå:
7924 if (not g_Game_IsNet
) then
7928 if (g_ActiveWindow
<> nil) and (not Show
) then
7930 // Ïàóçà ïðè ìåíþ òîëüêî â îäèíî÷íîé èãðå:
7931 if (not g_Game_IsNet
) then
7932 g_Game_Pause(False);
7936 procedure g_Game_Pause (Enable
: Boolean);
7940 if not gGameOn
then exit
;
7942 if not (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
]) then exit
;
7945 gPauseMain
:= Enable
;
7947 if (gPause
<> oldPause
) then g_Game_PauseAllSounds(gPause
);
7950 procedure g_Game_HolmesPause (Enable
: Boolean);
7954 if not gGameOn
then exit
;
7955 if not (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
]) then exit
;
7958 gPauseHolmes
:= Enable
;
7960 if (gPause
<> oldPause
) then g_Game_PauseAllSounds(gPause
);
7963 procedure g_Game_PauseAllSounds(Enable
: Boolean);
7968 if gTriggers
<> nil then
7969 for i
:= 0 to High(gTriggers
) do
7970 with gTriggers
[i
] do
7971 if (TriggerType
= TRIGGER_SOUND
) and
7973 Sound
.IsPlaying() then
7975 Sound
.Pause(Enable
);
7979 if gPlayers
<> nil then
7980 for i
:= 0 to High(gPlayers
) do
7981 if gPlayers
[i
] <> nil then
7982 gPlayers
[i
].PauseSounds(Enable
);
7985 if gMusic
<> nil then
7986 gMusic
.Pause(Enable
);
7989 procedure g_Game_StopAllSounds(all
: Boolean);
7993 if gTriggers
<> nil then
7994 for i
:= 0 to High(gTriggers
) do
7995 with gTriggers
[i
] do
7996 if (TriggerType
= TRIGGER_SOUND
) and
8000 if gMusic
<> nil then
8007 procedure g_Game_UpdateTriggerSounds
;
8010 if gTriggers
<> nil then
8011 for i
:= 0 to High(gTriggers
) do
8012 with gTriggers
[i
] do
8013 if (TriggerType
= TRIGGER_SOUND
) and (Sound
<> nil) and tgcLocal
and Sound
.IsPlaying() then
8014 Sound
.SetCoordsRect(X
, Y
, Width
, Height
, tgcVolume
/ 255.0)
8017 function g_Game_IsWatchedPlayer(UID
: Word): Boolean;
8020 if (gPlayer1
<> nil) and (gPlayer1
.UID
= UID
) then
8025 if (gPlayer2
<> nil) and (gPlayer2
.UID
= UID
) then
8030 if gSpectMode
<> SPECT_PLAYERS
then
8032 if gSpectPID1
= UID
then
8037 if gSpectViewTwo
and (gSpectPID2
= UID
) then
8044 function g_Game_IsWatchedTeam(Team
: Byte): Boolean;
8049 if (gPlayer1
<> nil) and (gPlayer1
.Team
= Team
) then
8054 if (gPlayer2
<> nil) and (gPlayer2
.Team
= Team
) then
8059 if gSpectMode
<> SPECT_PLAYERS
then
8061 Pl
:= g_Player_Get(gSpectPID1
);
8062 if (Pl
<> nil) and (Pl
.Team
= Team
) then
8067 if gSpectViewTwo
then
8069 Pl
:= g_Player_Get(gSpectPID2
);
8070 if (Pl
<> nil) and (Pl
.Team
= Team
) then
8078 procedure g_Game_Message(Msg
: string; Time
: Word);
8080 MessageLineLength
:= (gScreenWidth
- 204) div e_CharFont_GetMaxWidth(gMenuFont
);
8081 MessageText
:= b_Text_Wrap(b_Text_Format(Msg
), MessageLineLength
);
8082 MessageTime
:= Time
;
8085 procedure g_Game_ChatSound(Text: String; Taunt
: Boolean = True);
8087 punct
: Array[0..13] of String =
8088 ('.', ',', ':', ';', '!', '?', '(', ')', '''', '"', '/', '\', '*', '^');
8094 function IsPunctuation(S
: String): Boolean;
8099 if Length(S
) <> 1 then
8101 for i
:= Low(punct
) to High(punct
) do
8102 if S
= punct
[i
] then
8108 function FilterPunctuation(S
: String): String;
8112 for i
:= Low(punct
) to High(punct
) do
8113 S
:= StringReplace(S
, punct
[i
], ' ', [rfReplaceAll
]);
8119 if gUseChatSounds
and Taunt
and (gChatSounds
<> nil) and (Pos(': ', Text) > 0) then
8121 // remove player name
8122 Delete(Text, 1, Pos(': ', Text) + 2 - 1);
8123 // for FullWord check
8124 Text := toLowerCase1251(' ' + Text + ' ');
8125 fpText
:= FilterPunctuation(Text);
8127 for i
:= 0 to Length(gChatSounds
) - 1 do
8130 for j
:= 0 to Length(gChatSounds
[i
].Tags
) - 1 do
8132 if gChatSounds
[i
].FullWord
and (not IsPunctuation(gChatSounds
[i
].Tags
[j
])) then
8133 ok
:= Pos(' ' + gChatSounds
[i
].Tags
[j
] + ' ', fpText
) > 0
8135 ok
:= Pos(gChatSounds
[i
].Tags
[j
], Text) > 0;
8141 gChatSounds
[i
].Sound
.Play();
8147 g_Sound_PlayEx('SOUND_GAME_RADIO');
8150 procedure g_Game_Announce_GoodShot(SpawnerUID
: Word);
8159 if not g_Game_IsWatchedPlayer(SpawnerUID
) then
8163 if goodsnd
[a
].IsPlaying() then
8166 goodsnd
[Random(4)].Play();
8169 procedure g_Game_Announce_KillCombo(Param
: Integer);
8176 UID
:= Param
and $FFFF;
8181 Pl
:= g_Player_Get(UID
);
8190 g_Console_Add(Format(_lc
[I_PLAYER_KILL_2X
], [Name
]), True);
8194 g_Console_Add(Format(_lc
[I_PLAYER_KILL_3X
], [Name
]), True);
8198 g_Console_Add(Format(_lc
[I_PLAYER_KILL_4X
], [Name
]), True);
8202 g_Console_Add(Format(_lc
[I_PLAYER_KILL_MX
], [Name
]), True);
8210 if not g_Game_IsWatchedPlayer(UID
) then
8213 if (not g_Game_IsWatchedPlayer(UID
)) and (c
< 4) then
8217 if killsnd
[n
].IsPlaying() then
8222 procedure g_Game_Announce_BodyKill(SpawnerUID
: Word);
8230 if not g_Game_IsWatchedPlayer(SpawnerUID
) then
8234 if hahasnd
[a
].IsPlaying() then
8237 hahasnd
[Random(3)].Play();
8240 procedure g_Game_Effect_Bubbles (fX
, fY
: Integer; count
: Word; devX
, devY
: Byte; Silent
: Boolean);
8242 g_GFX_Bubbles(fX
, fY
, count
, devX
, devY
);
8243 if not Silent
then if Random(2) = 0
8244 then g_Sound_PlayExAt('SOUND_GAME_BUBBLE1', fX
, fY
)
8245 else g_Sound_PlayExAt('SOUND_GAME_BUBBLE2', fX
, fY
);
8248 procedure g_Game_StartVote(Command
, Initiator
: string);
8252 if not gVotesEnabled
then Exit
;
8253 if gGameSettings
.GameType
<> GT_SERVER
then Exit
;
8254 if gVoteInProgress
or gVotePassed
then
8256 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_INPROGRESS
], [gVoteCommand
]), True);
8257 MH_SEND_VoteEvent(NET_VE_INPROGRESS
, gVoteCommand
);
8260 gVoteInProgress
:= True;
8261 gVotePassed
:= False;
8262 gVoteTimer
:= gTime
+ gVoteTimeout
* 1000;
8265 gVoteCommand
:= Command
;
8267 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
8268 Need
:= Floor((NetClientCount
+1)/2.0)+1
8270 Need
:= Floor(NetClientCount
/2.0)+1;
8271 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_STARTED
], [Initiator
, Command
, Need
]), True);
8272 MH_SEND_VoteEvent(NET_VE_STARTED
, Initiator
, Command
, Need
);
8275 procedure g_Game_CheckVote
;
8279 if gGameSettings
.GameType
<> GT_SERVER
then Exit
;
8280 if not gVoteInProgress
then Exit
;
8282 if (gTime
>= gVoteTimer
) then
8284 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
8285 Need
:= Floor((NetClientCount
+1)/2.0) + 1
8287 Need
:= Floor(NetClientCount
/2.0) + 1;
8288 if gVoteCount
>= Need
then
8290 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_PASSED
], [gVoteCommand
]), True);
8291 MH_SEND_VoteEvent(NET_VE_PASSED
, gVoteCommand
);
8292 gVotePassed
:= True;
8293 gVoteCmdTimer
:= gTime
+ 5000;
8297 g_Console_Add(_lc
[I_MESSAGE_VOTE_FAILED
], True);
8298 MH_SEND_VoteEvent(NET_VE_FAILED
);
8300 if NetClients
<> nil then
8301 for I
:= Low(NetClients
) to High(NetClients
) do
8302 if NetClients
[i
].Used
then
8303 NetClients
[i
].Voted
:= False;
8304 gVoteInProgress
:= False;
8310 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
8311 Need
:= Floor((NetClientCount
+1)/2.0) + 1
8313 Need
:= Floor(NetClientCount
/2.0) + 1;
8314 if gVoteCount
>= Need
then
8316 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_PASSED
], [gVoteCommand
]), True);
8317 MH_SEND_VoteEvent(NET_VE_PASSED
, gVoteCommand
);
8318 gVoteInProgress
:= False;
8319 gVotePassed
:= True;
8320 gVoteCmdTimer
:= gTime
+ 5000;
8323 if NetClients
<> nil then
8324 for I
:= Low(NetClients
) to High(NetClients
) do
8325 if NetClients
[i
].Used
then
8326 NetClients
[i
].Voted
:= False;
8331 procedure g_Game_LoadMapList(FileName
: string);
8339 if not FileExists(FileName
) then Exit
;
8341 AssignFile(ListFile
, FileName
);
8343 while not EOF(ListFile
) do
8345 ReadLn(ListFile
, s
);
8348 if s
= '' then Continue
;
8350 SetLength(MapList
, Length(MapList
)+1);
8351 MapList
[High(MapList
)] := s
;
8353 CloseFile(ListFile
);
8356 procedure g_Game_SetDebugMode();
8359 // ×èòû (äàæå â ñâîåé èãðå):
8363 procedure g_Game_SetLoadingText(Text: String; Max
: Integer; reWrite
: Boolean);
8367 if Length(LoadingStat
.Msgs
) = 0 then
8373 begin // Ïåðåõîäèì íà ñëåäóþùóþ ñòðîêó èëè ñêðîëëèðóåì:
8374 if NextMsg
= Length(Msgs
) then
8376 for i
:= 0 to High(Msgs
)-1 do
8377 Msgs
[i
] := Msgs
[i
+1];
8385 Msgs
[NextMsg
-1] := Text;
8389 PBarWasHere
:= false;
8392 g_ActiveWindow
:= nil;
8393 ProcessLoading(True);
8396 procedure g_Game_StepLoading(Value
: Integer = -1);
8408 if (ShowCount
> LOADING_SHOW_STEP
) or (Value
> -1) then
8411 ProcessLoading(False);
8416 procedure g_Game_ClearLoading();
8425 len
:= ((gScreenHeight
div 3)*2 - 50) div LOADING_INTERLINE
;
8426 if len
< 1 then len
:= 1;
8427 SetLength(Msgs
, len
);
8428 for len
:= Low(Msgs
) to High(Msgs
) do
8431 PBarWasHere
:= false;
8435 procedure Parse_Params(var pars
: TParamStrValues
);
8442 while i
<= ParamCount
do
8445 if (Length(s
) > 1) and (s
[1] = '-') then
8447 if (Length(s
) > 2) and (s
[2] = '-') then
8448 begin // Îäèíî÷íûé ïàðàìåòð
8449 SetLength(pars
, Length(pars
) + 1);
8450 with pars
[High(pars
)] do
8452 Name
:= LowerCase(s
);
8457 if (i
< ParamCount
) then
8458 begin // Ïàðàìåòð ñî çíà÷åíèåì
8460 SetLength(pars
, Length(pars
) + 1);
8461 with pars
[High(pars
)] do
8463 Name
:= LowerCase(s
);
8464 Value
:= LowerCase(ParamStr(i
));
8473 function Find_Param_Value(var pars
: TParamStrValues
; aName
: String): String;
8478 for i
:= 0 to High(pars
) do
8479 if pars
[i
].Name
= aName
then
8481 Result
:= pars
[i
].Value
;
8486 procedure g_Game_Process_Params();
8488 pars
: TParamStrValues
;
8491 LimT
, LimS
: Integer;
8502 s
:= Find_Param_Value(pars
, '--debug');
8505 g_Game_SetDebugMode();
8506 s
:= Find_Param_Value(pars
, '--netdump');
8511 // Connect when game loads
8512 ip
:= Find_Param_Value(pars
, '-connect');
8516 s
:= Find_Param_Value(pars
, '-port');
8517 if (s
= '') or not TryStrToInt(s
, Port
) then
8520 s
:= Find_Param_Value(pars
, '-pw');
8522 g_Game_StartClient(ip
, Port
, s
);
8526 s
:= LowerCase(Find_Param_Value(pars
, '-dbg-mainwad'));
8529 gDefaultMegawadStart
:= s
;
8532 if (Find_Param_Value(pars
, '--dbg-mainwad-restore') <> '') or
8533 (Find_Param_Value(pars
, '--dbg-mainwad-default') <> '') then
8535 gDefaultMegawadStart
:= DF_Default_Megawad_Start
;
8538 // Start map when game loads:
8539 map
:= LowerCase(Find_Param_Value(pars
, '-map'));
8540 if isWadPath(map
) then
8543 s
:= Find_Param_Value(pars
, '-gm');
8544 GMode
:= g_Game_TextToMode(s
);
8545 if GMode
= GM_NONE
then GMode
:= GM_DM
;
8546 if GMode
= GM_SINGLE
then GMode
:= GM_COOP
;
8549 s
:= Find_Param_Value(pars
, '-limt');
8550 if (s
= '') or (not TryStrToInt(s
, LimT
)) then
8556 s
:= Find_Param_Value(pars
, '-lims');
8557 if (s
= '') or (not TryStrToInt(s
, LimS
)) then
8563 s
:= Find_Param_Value(pars
, '-lives');
8564 if (s
= '') or (not TryStrToInt(s
, Lives
)) then
8570 s
:= Find_Param_Value(pars
, '-opt');
8574 Opt
:= StrToIntDef(s
, 0);
8577 s
:= Find_Param_Value(pars
, '--close');
8581 // Override map to test:
8582 s
:= LowerCase(Find_Param_Value(pars
, '-testmap'));
8585 if e_IsValidResourceName(s
) then
8586 e_FindResource(AllMapDirs
, s
);
8587 gTestMap
:= ExpandFileName(s
);
8590 // Delete test map after play:
8591 s
:= Find_Param_Value(pars
, '--testdelete');
8594 //gMapToDelete := MapsDir + map;
8595 e_WriteLog('"--testdelete" is deprecated, use --tempdelete.', TMsgType
.Fatal
);
8599 // Delete temporary WAD after play:
8600 s
:= Find_Param_Value(pars
, '--tempdelete');
8601 if (s
<> '') and (gTestMap
<> '') then
8603 gMapToDelete
:= gTestMap
;
8604 gTempDelete
:= True;
8607 // Number of players:
8608 s
:= Find_Param_Value(pars
, '-pl');
8610 n
:= DEFAULT_PLAYERS
8612 n
:= StrToIntDef(s
, DEFAULT_PLAYERS
);
8615 s
:= Find_Param_Value(pars
, '-port');
8616 if (s
= '') or not TryStrToInt(s
, Port
) then
8617 g_Game_StartCustom(map
, GMode
, LimT
, LimS
, Lives
, Opt
, n
)
8619 g_Game_StartServer(map
, GMode
, LimT
, LimS
, Lives
, Opt
, n
, 0, Port
);
8622 // Execute script when game loads:
8623 s
:= Find_Param_Value(pars
, '-exec');
8626 // if not isWadPath(s) then
8627 // s := GameDir + '/' + s;
8632 if IOResult
<> 0 then
8634 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], ['Failed to read file: ' + s
]), TMsgType
.Warning
);
8635 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_READ
], [s
]));
8639 e_WriteLog('Executing script: ' + s
, TMsgType
.Notify
);
8640 g_Console_Add(Format(_lc
[I_CONSOLE_EXEC
], [s
]));
8645 if IOResult
<> 0 then
8647 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], ['Failed to read file: ' + s
]), TMsgType
.Warning
);
8648 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_READ
], [s
]));
8652 if Pos('#', s
) <> 1 then // script comment
8653 g_Console_Process(s
, True);
8664 conRegVar('pf_draw_frame', @g_profile_frame_draw
, 'draw frame rendering profiles', 'render profiles');
8665 //conRegVar('pf_update_frame', @g_profile_frame_update, 'draw frame updating profiles', 'update profiles');
8666 conRegVar('pf_coldet', @g_profile_collision
, 'draw collision detection profiles', 'coldet profiles');
8667 conRegVar('pf_los', @g_profile_los
, 'draw monster LOS profiles', 'monster LOS profiles');
8669 conRegVar('r_sq_draw', @gdbg_map_use_accel_render
, 'accelerated spatial queries in rendering', 'accelerated rendering');
8670 conRegVar('cd_sq_enabled', @gdbg_map_use_accel_coldet
, 'accelerated spatial queries in map coldet', 'accelerated map coldet');
8671 conRegVar('mon_sq_enabled', @gmon_debug_use_sqaccel
, 'accelerated spatial queries for monsters', 'accelerated monster coldet');
8672 conRegVar('wtrace_sq_enabled', @gwep_debug_fast_trace
, 'accelerated spatial queries for weapon hitscan trace', 'accelerated weapon hitscan');
8674 conRegVar('pr_enabled', @gpart_dbg_enabled
, 'enable/disable particles', 'particles');
8675 conRegVar('pr_phys_enabled', @gpart_dbg_phys_enabled
, 'enable/disable particle physics', 'particle physics');
8677 conRegVar('los_enabled', @gmon_dbg_los_enabled
, 'enable/disable monster LOS calculations', 'monster LOS', true);
8678 conRegVar('mon_think', @gmon_debug_think
, 'enable/disable monster thinking', 'monster thinking', true);
8680 {$IFDEF ENABLE_HOLMES}
8681 conRegVar('dbg_holmes', @g_holmes_enabled
, 'enable/disable Holmes', 'Holmes', true);
8684 conRegVar('dbg_ignore_level_bounds', @g_dbg_ignore_bounds
, 'ignore level bounds', '', false);
8686 conRegVar('r_scale', @g_dbg_scale
, 0.01, 100.0, 'render scale', '', false);
8687 conRegVar('r_resolution_scale', @r_pixel_scale
, 0.01, 100.0, 'upscale factor', '', false);
8689 conRegVar('light_enabled', @gwin_k8_enable_light_experiments
, 'enable/disable dynamic lighting', 'lighting');
8690 conRegVar('light_player_halo', @g_playerLight
, 'enable/disable player halo', 'player light halo');
8692 conRegVar('r_smallmap_align_h', @r_smallmap_h
, 'halign: 0: left; 1: center; 2: right', 'horizontal aligning of small maps');
8693 conRegVar('r_smallmap_align_v', @r_smallmap_v
, 'valign: 0: top; 1: center; 2: bottom', 'vertial aligning of small maps');
8695 conRegVar('r_showfps', @gShowFPS
, 'draw fps counter', 'draw fps counter');
8696 conRegVar('r_showtime', @gShowTime
, 'show game time', 'show game time');
8697 conRegVar('r_showping', @gShowPing
, 'show ping', 'show ping');
8698 conRegVar('r_showscore', @gShowScore
, 'show score', 'show score');
8699 conRegVar('r_showkillmsg', @gShowKillMsg
, 'show kill log', 'show kill log');
8700 conRegVar('r_showlives', @gShowLives
, 'show lives', 'show lives');
8701 conRegVar('r_showspect', @gSpectHUD
, 'show spectator hud', 'show spectator hud');
8702 conRegVar('r_showstat', @gShowStat
, 'show stats', 'show stats');
8703 conRegVar('r_showpids', @gShowPIDs
, 'show PIDs', 'show PIDs');