6 g_basic
, g_player
, e_graphics
, Classes
, g_res_downloader
,
7 SysUtils
, g_sound
, g_gui
, MAPSTRUCT
, WADEDITOR
, md5
;
10 TGameSettings
= record
26 TDelayedEvent
= record
34 TPlayerSettings
= record
53 function g_Game_IsNet(): Boolean;
54 function g_Game_IsServer(): Boolean;
55 function g_Game_IsClient(): Boolean;
56 procedure g_Game_Init();
57 procedure g_Game_Free();
58 procedure g_Game_LoadData();
59 procedure g_Game_FreeData();
60 procedure g_Game_Update();
61 procedure g_Game_Draw();
62 procedure g_Game_Quit();
63 procedure g_Game_SetupScreenSize();
64 procedure g_Game_ChangeResolution(newWidth
, newHeight
: Word; nowFull
, nowMax
: Boolean);
65 function g_Game_ModeToText(Mode
: Byte): string;
66 function g_Game_TextToMode(Mode
: string): Byte;
67 procedure g_Game_ExecuteEvent(Name
: String);
68 function g_Game_DelayEvent(DEType
: Byte; Time
: LongWord; Num
: Integer = 0; Str
: String = ''): Integer;
69 procedure g_Game_AddPlayer(Team
: Byte = TEAM_NONE
);
70 procedure g_Game_RemovePlayer();
71 procedure g_Game_Spectate();
72 procedure g_Game_SpectateCenterView();
73 procedure g_Game_StartSingle(Map
: String; TwoPlayers
: Boolean; nPlayers
: Byte);
74 procedure g_Game_StartCustom(Map
: String; GameMode
: Byte; TimeLimit
, GoalLimit
: Word; MaxLives
: Byte; Options
: LongWord; nPlayers
: Byte);
75 procedure g_Game_StartServer(Map
: String; GameMode
: Byte; TimeLimit
, GoalLimit
: Word; MaxLives
: Byte; Options
: LongWord; nPlayers
: Byte; IPAddr
: LongWord; Port
: Word);
76 procedure g_Game_StartClient(Addr
: String; Port
: Word; PW
: String);
77 procedure g_Game_Restart();
78 procedure g_Game_RestartLevel();
79 procedure g_Game_RestartRound(NoMapRestart
: Boolean = False);
80 procedure g_Game_ClientWAD(NewWAD
: String; WHash
: TMD5Digest
);
81 procedure g_Game_SaveOptions();
82 function g_Game_StartMap(Map
: String; Force
: Boolean = False): Boolean;
83 procedure g_Game_ChangeMap(MapPath
: String);
84 procedure g_Game_ExitLevel(Map
: Char16
);
85 function g_Game_GetFirstMap(WAD
: String): String;
86 function g_Game_GetNextMap(): String;
87 procedure g_Game_NextLevel();
88 procedure g_Game_Pause(Enable
: Boolean);
89 procedure g_Game_InGameMenu(Show
: Boolean);
90 function g_Game_IsWatchedPlayer(UID
: Word): Boolean;
91 function g_Game_IsWatchedTeam(Team
: Byte): Boolean;
92 procedure g_Game_Message(Msg
: String; Time
: Word);
93 procedure g_Game_LoadMapList(FileName
: String);
94 procedure g_Game_PauseAllSounds(Enable
: Boolean);
95 procedure g_Game_StopAllSounds(all
: Boolean);
96 procedure g_Game_UpdateTriggerSounds();
97 function g_Game_GetMegaWADInfo(WAD
: String): TMegaWADInfo
;
98 procedure g_Game_Announce_GoodShot(SpawnerUID
: Word);
99 procedure g_Game_Announce_KillCombo(Param
: Integer);
100 procedure g_Game_StartVote(Command
, Initiator
: string);
101 procedure g_Game_CheckVote
;
102 procedure g_TakeScreenShot();
103 procedure g_FatalError(Text: String);
104 procedure g_SimpleError(Text: String);
105 function g_Game_IsTestMap(): Boolean;
106 procedure g_Game_DeleteTestMap();
107 procedure GameCVars(P
: SArray
);
108 procedure GameCommands(P
: SArray
);
109 procedure DebugCommands(P
: SArray
);
110 procedure g_Game_Process_Params
;
111 procedure g_Game_SetLoadingText(Text: String; Max
: Integer; reWrite
: Boolean);
112 procedure g_Game_StepLoading();
113 procedure g_Game_ClearLoading();
114 procedure g_Game_SetDebugMode();
115 procedure DrawLoadingStat();
117 { procedure SetWinPause(Enable: Boolean); }
122 LOADING_SHOW_STEP
= 100;
123 LOADING_INTERLINE
= 20;
138 MESSAGE_DIKEY
= WM_USER
+ 1;
143 EXIT_ENDLEVELSINGLE
= 4;
144 EXIT_ENDLEVELCUSTOM
= 5;
146 GAME_OPTION_RESERVED
= 1;
147 GAME_OPTION_TEAMDAMAGE
= 2;
148 GAME_OPTION_ALLOWEXIT
= 4;
149 GAME_OPTION_WEAPONSTAY
= 8;
150 GAME_OPTION_MONSTERS
= 16;
151 GAME_OPTION_BOTVSPLAYER
= 32;
152 GAME_OPTION_BOTVSMONSTER
= 64;
157 STATE_INTERCUSTOM
= 3;
158 STATE_INTERSINGLE
= 4;
164 LMS_RESPAWN_NONE
= 0;
165 LMS_RESPAWN_WARMUP
= 1;
166 LMS_RESPAWN_FINAL
= 2;
182 CONFIG_FILENAME
= 'Doom2DF.cfg';
183 LOG_FILENAME
= 'Doom2DF.log';
185 TEST_MAP_NAME
= '$$$_TEST_$$$';
187 STD_PLAYER_MODEL
= 'Doomer';
191 gGameSettings
: TGameSettings
;
192 gPlayer1Settings
: TPlayerSettings
;
193 gPlayer2Settings
: TPlayerSettings
;
195 gPlayerScreenSize
: TPoint
;
196 gPlayer1ScreenCoord
: TPoint
;
197 gPlayer2ScreenCoord
: TPoint
;
198 gPlayer1
: TPlayer
= nil;
199 gPlayer2
: TPlayer
= nil;
200 gPlayerDrawn
: TPlayer
= nil;
202 gSwitchGameMode
: Byte = GM_DM
;
203 gHearPoint1
, gHearPoint2
: THearPoint
;
204 gSoundEffectsDF
: Boolean = False;
205 gSoundTriggerTime
: Word = 0;
206 gAnnouncer
: Byte = ANNOUNCE_NONE
;
207 goodsnd
: array[0..3] of TPlayableSound
;
208 killsnd
: array[0..3] of TPlayableSound
;
209 gDefInterTime
: ShortInt = -1;
210 gInterEndTime
: LongWord = 0;
211 gInterTime
: LongWord = 0;
212 gServInterTime
: Byte = 0;
213 gGameStartTime
: LongWord = 0;
214 gTotalMonsters
: Integer = 0;
216 gShowTime
: Boolean = True;
217 gShowFPS
: Boolean = False;
218 gShowGoals
: Boolean = True;
219 gShowStat
: Boolean = True;
220 gShowKillMsg
: Boolean = True;
221 gShowLives
: Boolean = True;
222 gShowPing
: Boolean = False;
223 gShowMap
: Boolean = False;
225 gState
: Byte = STATE_NONE
;
227 sWidth
, sHeight
: Word;
228 gSpectMode
: Byte = SPECT_NONE
;
229 gSpectHUD
: Boolean = True;
230 gSpectKeyPress
: Boolean = False;
231 gSpectX
: Integer = 0;
232 gSpectY
: Integer = 0;
233 gSpectStep
: Byte = 8;
234 gSpectViewTwo
: Boolean = False;
235 gSpectPID1
: Integer = -1;
236 gSpectPID2
: Integer = -1;
237 gMusic
: TMusic
= nil;
238 gLoadGameMode
: Boolean;
239 gCheats
: Boolean = False;
240 gMapOnce
: Boolean = False;
241 gMapToDelete
: String;
242 gTempDelete
: Boolean = False;
243 gLastMap
: Boolean = False;
244 gWinPosX
, gWinPosY
: Integer;
245 gWinSizeX
, gWinSizeY
: Integer;
246 gWinFrameX
, gWinFrameY
, gWinCaption
: Integer;
247 gWinActive
: Boolean = False;
248 gResolutionChange
: Boolean = False;
249 gRC_Width
, gRC_Height
: Word;
250 gRC_FullScreen
, gRC_Maximized
: Boolean;
251 gLanguageChange
: Boolean = False;
252 gDebugMode
: Boolean = False;
253 g_debug_Sounds
: Boolean = False;
254 g_debug_Frames
: Boolean = False;
255 g_debug_WinMsgs
: Boolean = False;
256 g_debug_MonsterOff
: Boolean = False;
257 g_debug_BotAIOff
: Byte = 0;
258 g_debug_HealthBar
: Boolean = False;
259 g_Debug_Player
: Boolean = False;
260 gCoopMonstersKilled
: Word = 0;
261 gCoopSecretsFound
: Word = 0;
262 gCoopTotalMonstersKilled
: Word = 0;
263 gCoopTotalSecretsFound
: Word = 0;
264 gCoopTotalMonsters
: Word = 0;
265 gCoopTotalSecrets
: Word = 0;
266 gStatsOff
: Boolean = False;
267 gStatsPressed
: Boolean = False;
268 gExitByTrigger
: Boolean = False;
269 gNextMap
: String = '';
270 gLMSRespawn
: Byte = LMS_RESPAWN_NONE
;
271 gLMSRespawnTime
: Cardinal = 0;
272 gLMSSoftSpawn
: Boolean = False;
273 gMissionFailed
: Boolean = False;
274 gVoteInProgress
: Boolean = False;
275 gVotePassed
: Boolean = False;
276 gVoteCommand
: string = '';
277 gVoteTimer
: Cardinal = 0;
278 gVoteCmdTimer
: Cardinal = 0;
279 gVoteCount
: Integer = 0;
280 gVoteTimeout
: Cardinal = 30;
281 gVoted
: Boolean = False;
282 gVotesEnabled
: Boolean = True;
283 gEvents
: Array of TGameEvent
;
284 gDelayedEvents
: Array of TDelayedEvent
;
286 P1MoveButton
: Byte = 0;
287 P2MoveButton
: Byte = 0;
292 g_textures
, g_main
, g_window
, g_menu
,
293 e_input
, e_log
, g_console
, g_items
, g_map
,
294 g_playermodel
, g_gfx
, g_options
, g_weapons
, Math
,
295 g_triggers
, MAPDEF
, g_monsters
, e_sound
, CONFIG
,
296 BinEditor
, g_language
, g_net
, SDL
,
297 ENet
, e_fixedbuffer
, g_netmsg
, g_netmaster
, GL
, GLExt
,
301 TEndCustomGameStat
= record
302 PlayerStat
: TPlayerStatArray
;
306 Map
, MapName
: String;
309 TEndSingleGameStat
= record
310 PlayerStat
: Array [0..1] of record
316 TotalSecrets
: Integer;
319 TLoadingStat
= record
323 Msgs
: Array of String;
327 TParamStrValue
= record
332 TParamStrValues
= Array of TParamStrValue
;
335 INTER_ACTION_TEXT
= 1;
336 INTER_ACTION_PIC
= 2;
337 INTER_ACTION_MUSIC
= 3;
341 FPSCounter
, UPSCounter
: Word;
342 FPSTime
, UPSTime
: LongWord;
343 DataLoaded
: Boolean = False;
344 LastScreenShot
: Int64;
345 IsDrawStat
: Boolean = False;
346 CustomStat
: TEndCustomGameStat
;
347 SingleStat
: TEndSingleGameStat
;
348 LoadingStat
: TLoadingStat
;
349 EndingGameCounter
: Byte = 0;
352 MapList
: SArray
= nil;
353 MapIndex
: Integer = -1;
359 text: Array of ShortString;
360 anim
: Array of ShortString;
361 pic
: Array of ShortString;
362 mus
: Array of ShortString;
364 triggers
: Array of record
366 actions
: Array of record
367 action
, p1
, p2
: Integer;
370 cur_trigger
: Integer;
383 function Compare(a
, b
: TPlayerStat
): Integer;
385 if a
.Spectator
then Result
:= 1
386 else if b
.Spectator
then Result
:= -1
387 else if a
.Frags
< b
.Frags
then Result
:= 1
388 else if a
.Frags
> b
.Frags
then Result
:= -1
389 else if a
.Deaths
< b
.Deaths
then Result
:= -1
390 else if a
.Deaths
> b
.Deaths
then Result
:= 1
391 else if a
.Kills
< b
.Kills
then Result
:= -1
395 procedure SortGameStat(var stat
: TPlayerStatArray
);
400 if stat
= nil then Exit
;
402 for I
:= High(stat
) downto Low(stat
) do
403 for J
:= Low(stat
) to High(stat
) - 1 do
404 if Compare(stat
[J
], stat
[J
+ 1]) = 1 then
407 stat
[J
] := stat
[J
+ 1];
412 function g_Game_ModeToText(Mode
: Byte): string;
416 GM_DM
: Result
:= _lc
[I_MENU_GAME_TYPE_DM
];
417 GM_TDM
: Result
:= _lc
[I_MENU_GAME_TYPE_TDM
];
418 GM_CTF
: Result
:= _lc
[I_MENU_GAME_TYPE_CTF
];
419 GM_COOP
: Result
:= _lc
[I_MENU_GAME_TYPE_COOP
];
420 GM_SINGLE
: Result
:= _lc
[I_MENU_GAME_TYPE_SINGLE
];
424 function g_Game_TextToMode(Mode
: string): Byte;
427 Mode
:= UpperCase(Mode
);
428 if Mode
= _lc
[I_MENU_GAME_TYPE_DM
] then
433 if Mode
= _lc
[I_MENU_GAME_TYPE_TDM
] then
438 if Mode
= _lc
[I_MENU_GAME_TYPE_CTF
] then
443 if Mode
= _lc
[I_MENU_GAME_TYPE_COOP
] then
448 if Mode
= _lc
[I_MENU_GAME_TYPE_SINGLE
] then
455 function g_Game_IsNet(): Boolean;
457 Result
:= (gGameSettings
.GameType
in [GT_SERVER
, GT_CLIENT
]);
460 function g_Game_IsServer(): Boolean;
462 Result
:= (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
, GT_SERVER
]);
465 function g_Game_IsClient(): Boolean;
467 Result
:= (gGameSettings
.GameType
= GT_CLIENT
);
470 function g_Game_GetMegaWADInfo(WAD
: String): TMegaWADInfo
;
477 Result
.name
:= ExtractFileName(WAD
);
478 Result
.description
:= '';
481 w
:= TWADEditor_1
.Create();
484 if not w
.GetResource('', 'INTERSCRIPT', p
, len
) then
490 cfg
:= TConfig
.CreateMem(p
, len
);
491 Result
.name
:= cfg
.ReadStr('megawad', 'name', ExtractFileName(WAD
));
492 Result
.description
:= cfg
.ReadStr('megawad', 'description', '');
493 Result
.author
:= cfg
.ReadStr('megawad', 'author', '');
494 Result
.pic
:= cfg
.ReadStr('megawad', 'pic', '');
500 procedure g_Game_FreeWAD();
504 for a
:= 0 to High(MegaWAD
.res
.pic
) do
505 if MegaWAD
.res
.pic
[a
] <> '' then
506 g_Texture_Delete(MegaWAD
.res
.pic
[a
]);
508 for a
:= 0 to High(MegaWAD
.res
.mus
) do
509 if MegaWAD
.res
.mus
[a
] <> '' then
510 g_Sound_Delete(MegaWAD
.res
.mus
[a
]);
512 MegaWAD
.res
.pic
:= nil;
513 MegaWAD
.res
.text := nil;
514 MegaWAD
.res
.anim
:= nil;
515 MegaWAD
.res
.mus
:= nil;
516 MegaWAD
.triggers
:= nil;
518 g_Texture_Delete('TEXTURE_endpic');
519 g_Sound_Delete('MUSIC_endmus');
521 ZeroMemory(@MegaWAD
, SizeOf(MegaWAD
));
522 gGameSettings
.WAD
:= '';
525 procedure g_Game_LoadWAD(WAD
: string);
534 gGameSettings
.WAD
:= WAD
;
535 if not (gGameSettings
.GameMode
in [GM_COOP
, GM_SINGLE
]) then
538 MegaWAD
.info
:= g_Game_GetMegaWADInfo(MapsDir
+ WAD
);
540 w
:= TWADEditor_1
.Create();
541 w
.ReadFile(MapsDir
+ WAD
);
543 if not w
.GetResource('', 'INTERSCRIPT', p
, len
) then
549 cfg
:= TConfig
.CreateMem(p
, len
);
554 s := cfg.ReadStr('pic', 'pic'+IntToStr(b), '');
555 if s = '' then Break;
558 SetLength(MegaWAD.res.pic, Length(MegaWAD.res.pic)+1);
559 MegaWAD.res.pic[High(MegaWAD.res.pic)] := s;
561 g_Texture_CreateWADEx(s, s);
567 s := cfg.ReadStr('mus', 'mus'+IntToStr(b), '');
568 if s = '' then Break;
571 SetLength(MegaWAD.res.mus, Length(MegaWAD.res.mus)+1);
572 MegaWAD.res.mus[High(MegaWAD.res.mus)] := s;
574 g_Music_CreateWADEx(s, s);
577 MegaWAD
.endpic
:= cfg
.ReadStr('megawad', 'endpic', '');
578 if MegaWAD
.endpic
<> '' then
580 g_ProcessResourceStr(MegaWAD
.endpic
, @s
, nil, nil);
581 if s
= '' then s
:= MapsDir
+WAD
else s
:= GameDir
+'/wads/';
582 g_Texture_CreateWADEx('TEXTURE_endpic', s
+MegaWAD
.endpic
);
584 MegaWAD
.endmus
:= cfg
.ReadStr('megawad', 'endmus', 'Standart.wad:D2DMUS\ÊÎÍÅÖ');
585 if MegaWAD
.endmus
<> '' then
587 g_ProcessResourceStr(MegaWAD
.endmus
, @s
, nil, nil);
588 if s
= '' then s
:= MapsDir
+WAD
else s
:= GameDir
+'/wads/';
589 g_Sound_CreateWADEx('MUSIC_endmus', s
+MegaWAD
.endmus
, True);
597 {procedure start_trigger(t: string);
601 function next_trigger(): Boolean;
605 procedure DisableCheats();
611 if gPlayer1
<> nil then gPlayer1
.GodMode
:= False;
612 if gPlayer2
<> nil then gPlayer2
.GodMode
:= False;
613 if gPlayer1
<> nil then gPlayer1
.NoTarget
:= False;
614 if gPlayer2
<> nil then gPlayer2
.NoTarget
:= False;
617 procedure g_Game_ExecuteEvent(Name
: String);
623 if gEvents
= nil then
625 for a
:= 0 to High(gEvents
) do
626 if gEvents
[a
].Name
= Name
then
628 if gEvents
[a
].Command
<> '' then
629 g_Console_Process(gEvents
[a
].Command
, True);
634 function g_Game_DelayEvent(DEType
: Byte; Time
: LongWord; Num
: Integer = 0; Str
: String = ''): Integer;
639 if gDelayedEvents
<> nil then
640 for a
:= 0 to High(gDelayedEvents
) do
641 if not gDelayedEvents
[a
].Pending
then
648 SetLength(gDelayedEvents
, Length(gDelayedEvents
) + 1);
649 n
:= High(gDelayedEvents
);
651 gDelayedEvents
[n
].Pending
:= True;
652 gDelayedEvents
[n
].DEType
:= DEType
;
653 gDelayedEvents
[n
].DENum
:= Num
;
654 gDelayedEvents
[n
].DEStr
:= Str
;
655 if DEType
= DE_GLOBEVENT
then
656 gDelayedEvents
[n
].Time
:= (GetTimer() div 1000) + Time
658 gDelayedEvents
[n
].Time
:= gTime
+ Time
;
665 FileName
, SectionName
, ResName
: string;
667 if g_Game_IsNet
and g_Game_IsServer
then
668 MH_SEND_GameEvent(NET_EV_MAPEND
, Byte(gMissionFailed
));
674 g_Game_StopAllSounds(False);
679 EndingGameCounter
:= 0;
680 g_ActiveWindow
:= nil;
682 gLMSRespawn
:= LMS_RESPAWN_NONE
;
683 gLMSRespawnTime
:= 0;
686 EXIT_SIMPLE
: // Âûõîä ÷åðåç ìåíþ èëè êîíåö òåñòà
691 begin // Ýòî áûë òåñò
695 begin // Âûõîä â ãëàâíîå ìåíþ
696 gMusic
.SetByName('MUSIC_MENU');
698 if gState
<> STATE_SLIST
then
700 g_GUI_ShowWindow('MainMenu');
701 gState
:= STATE_MENU
;
704 // Îáíîâëÿåì ñïèñîê ñåðâåðîâ
705 slReturnPressed
:= True;
706 if g_Net_Slist_Fetch(slCurrent
) then
708 if slCurrent
= nil then
709 slWaitStr
:= _lc
[I_NET_SLIST_NOSERVERS
];
712 slWaitStr
:= _lc
[I_NET_SLIST_ERROR
];
715 g_Game_ExecuteEvent('ongameend');
719 EXIT_RESTART
: // Íà÷àòü óðîâåíü ñíà÷àëà
721 if not g_Game_IsClient
then g_Game_Restart();
724 EXIT_ENDLEVELCUSTOM
: // Çàêîí÷èëñÿ óðîâåíü â Ñâîåé èãðå
726 // Ñòàòèñòèêà Ñâîåé èãðû:
727 g_ProcessResourceStr(gMapInfo
.Map
, FileName
, SectionName
, ResName
);
729 CustomStat
.GameTime
:= gTime
;
730 CustomStat
.Map
:= ExtractFileName(FileName
)+':'+ResName
;
731 CustomStat
.MapName
:= gMapInfo
.Name
;
732 CustomStat
.GameMode
:= gGameSettings
.GameMode
;
733 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
734 CustomStat
.TeamStat
:= gTeamStat
;
736 CustomStat
.PlayerStat
:= nil;
738 // Ñòàòèñòèêà èãðîêîâ:
739 if gPlayers
<> nil then
741 for a
:= 0 to High(gPlayers
) do
742 if gPlayers
[a
] <> nil then
744 SetLength(CustomStat
.PlayerStat
, Length(CustomStat
.PlayerStat
)+1);
745 with CustomStat
.PlayerStat
[High(CustomStat
.PlayerStat
)] do
747 Name
:= gPlayers
[a
].Name
;
748 Frags
:= gPlayers
[a
].Frags
;
749 Deaths
:= gPlayers
[a
].Death
;
750 Kills
:= gPlayers
[a
].Kills
;
751 Team
:= gPlayers
[a
].Team
;
752 Color
:= gPlayers
[a
].Model
.Color
;
753 Spectator
:= gPlayers
[a
].FSpectator
;
757 SortGameStat(CustomStat
.PlayerStat
);
760 g_Game_ExecuteEvent('onmapend');
763 EndingGameCounter
:= 255;
764 gState
:= STATE_FOLD
;
766 if gDefInterTime
< 0 then
767 gInterEndTime
:= IfThen((gGameSettings
.GameType
= GT_SERVER
) and (gPlayer1
= nil), 15000, 25000)
769 gInterEndTime
:= gDefInterTime
* 1000;
772 EXIT_ENDLEVELSINGLE
: // Çàêîí÷èëñÿ óðîâåíü â Îäèíî÷íîé èãðå
774 // Ñòàòèñòèêà Îäèíî÷íîé èãðû:
775 SingleStat
.GameTime
:= gTime
;
776 SingleStat
.TwoPlayers
:= gPlayer2
<> nil;
777 SingleStat
.TotalSecrets
:= gSecretsCount
;
778 // Ñòàòèñòèêà ïåðâîãî èãðîêà:
779 SingleStat
.PlayerStat
[0].Kills
:= gPlayer1
.MonsterKills
;
780 SingleStat
.PlayerStat
[0].Secrets
:= gPlayer1
.Secrets
;
781 // Ñòàòèñòèêà âòîðîãî èãðîêà (åñëè åñòü):
782 if SingleStat
.TwoPlayers
then
784 SingleStat
.PlayerStat
[1].Kills
:= gPlayer2
.MonsterKills
;
785 SingleStat
.PlayerStat
[1].Secrets
:= gPlayer2
.Secrets
;
788 g_Game_ExecuteEvent('onmapend');
791 if gNextMap
<> '' then
793 gMusic
.SetByName('MUSIC_INTERMUS');
795 gState
:= STATE_INTERSINGLE
;
797 g_Game_ExecuteEvent('oninter');
799 else // Áîëüøå íåò êàðò
802 EndingGameCounter
:= 255;
803 gState
:= STATE_FOLD
;
808 // Îêîí÷àíèå îáðàáîòàíî:
809 if gExit
<> EXIT_QUIT
then
813 procedure DrawStat();
815 pc
, x
, y
, w
, h
: Integer;
816 w1
, w2
, w3
, w4
: Integer;
818 cw
, ch
, r
, g
, b
, rr
, gg
, bb
: Byte;
821 stat
: TPlayerStatArray
;
828 pc
:= g_Player_GetCount
;
829 e_TextureFontGetSize(gStdFont
, cw
, ch
);
831 w
:= gScreenWidth
-(gScreenWidth
div 5);
832 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
835 h
:= 40+ch
*5+(ch
+8)*pc
;
836 x
:= (gScreenWidth
div 2)-(w
div 2);
837 y
:= (gScreenHeight
div 2)-(h
div 2);
839 e_DrawFillQuad(x
, y
, x
+w
-1, y
+h
-1, 64, 64, 64, 32);
840 e_DrawQuad(x
, y
, x
+w
-1, y
+h
-1, 255, 127, 0);
842 g_ProcessResourceStr(gMapInfo
.Map
, @wad
, nil, @map
);
843 wad
:= ExtractFileName(wad
);
844 mapstr
:= wad
+ ':\' + map
+ ' - ' + gMapInfo
.Name
;
846 case gGameSettings
.GameMode
of
849 if gGameSettings
.MaxLives
= 0 then
852 s1
:= _lc
[I_GAME_LMS
];
853 s2
:= Format(_lc
[I_GAME_FRAG_LIMIT
], [gGameSettings
.GoalLimit
]);
854 s3
:= Format(_lc
[I_GAME_TIME_LIMIT
], [gGameSettings
.TimeLimit
div 3600, (gGameSettings
.TimeLimit
div 60) mod 60, gGameSettings
.TimeLimit
mod 60]);
859 if gGameSettings
.MaxLives
= 0 then
860 s1
:= _lc
[I_GAME_TDM
]
862 s1
:= _lc
[I_GAME_TLMS
];
863 s2
:= Format(_lc
[I_GAME_FRAG_LIMIT
], [gGameSettings
.GoalLimit
]);
864 s3
:= Format(_lc
[I_GAME_TIME_LIMIT
], [gGameSettings
.TimeLimit
div 3600, (gGameSettings
.TimeLimit
div 60) mod 60, gGameSettings
.TimeLimit
mod 60]);
869 s1
:= _lc
[I_GAME_CTF
];
870 s2
:= Format(_lc
[I_GAME_SCORE_LIMIT
], [gGameSettings
.GoalLimit
]);
871 s3
:= Format(_lc
[I_GAME_TIME_LIMIT
], [gGameSettings
.TimeLimit
div 3600, (gGameSettings
.TimeLimit
div 60) mod 60, gGameSettings
.TimeLimit
mod 60]);
876 if gGameSettings
.MaxLives
= 0 then
877 s1
:= _lc
[I_GAME_COOP
]
879 s1
:= _lc
[I_GAME_SURV
];
880 s2
:= _lc
[I_GAME_MONSTERS
] + ' ' + IntToStr(gCoopMonstersKilled
) + '/' + IntToStr(gTotalMonsters
);
881 s3
:= _lc
[I_GAME_SECRETS
] + ' ' + IntToStr(gCoopSecretsFound
) + '/' + IntToStr(gSecretsCount
);
892 e_TextureFontPrintEx(x
+(w
div 2)-(Length(s1
)*cw
div 2), _y
, s1
, gStdFont
, 255, 255, 255, 1);
894 e_TextureFontPrintEx(x
+(w
div 2)-(Length(mapstr
)*cw
div 2), _y
, mapstr
, gStdFont
, 200, 200, 200, 1);
896 e_TextureFontPrintEx(x
+16, _y
, s2
, gStdFont
, 200, 200, 200, 1);
898 e_TextureFontPrintEx(x
+w
-16-(Length(s3
))*cw
, _y
, s3
,
899 gStdFont
, 200, 200, 200, 1);
901 if NetMode
= NET_SERVER
then
902 e_TextureFontPrintEx(x
+8, y
+ 8, _lc
[I_NET_SERVER
], gStdFont
, 255, 255, 255, 1)
904 if NetMode
= NET_CLIENT
then
905 e_TextureFontPrintEx(x
+8, y
+ 8,
906 NetClientIP
+ ':' + IntToStr(NetClientPort
), gStdFont
, 255, 255, 255, 1);
910 stat
:= g_Player_GetStats();
913 w2
:= (w
-16) div 6 + 48; // øèðèíà 2 ñòîëáöà
914 w3
:= (w
-16) div 6; // øèðèíà 3 è 4 ñòîëáöîâ
916 w1
:= w
-16-w2
-w3
-w4
; // îñòàâøååñÿ ïðîñòðàíñòâî - äëÿ öâåòà è èìåíè èãðîêà
918 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
922 for a
:= TEAM_RED
to TEAM_BLUE
do
926 s1
:= _lc
[I_GAME_TEAM_RED
];
933 s1
:= _lc
[I_GAME_TEAM_BLUE
];
939 e_TextureFontPrintEx(x
+16, _y
, s1
, gStdFont
, r
, g
, b
, 1);
940 e_TextureFontPrintEx(x
+w1
+16, _y
, IntToStr(gTeamStat
[a
].Goals
),
941 gStdFont
, r
, g
, b
, 1);
943 _y
:= _y
+ch
+(ch
div 4);
944 e_DrawLine(1, x
+16, _y
, x
+w
-16, _y
, r
, g
, b
);
947 for aa
:= 0 to High(stat
) do
948 if stat
[aa
].Team
= a
then
964 e_TextureFontPrintEx(x
+16, _y
, Name
, gStdFont
, rr
, gg
, bb
, 1);
966 e_TextureFontPrintEx(x
+w1
+16, _y
, Format(_lc
[I_GAME_PING_MS
], [Ping
, Loss
]), gStdFont
, rr
, gg
, bb
, 1);
968 e_TextureFontPrintEx(x
+w1
+w2
+16, _y
, IntToStr(Frags
), gStdFont
, rr
, gg
, bb
, 1);
970 e_TextureFontPrintEx(x
+w1
+w2
+w3
+16, _y
, IntToStr(Deaths
), gStdFont
, rr
, gg
, bb
, 1);
977 else if gGameSettings
.GameMode
in [GM_DM
, GM_COOP
] then
980 e_TextureFontPrintEx(x
+16, _y
, _lc
[I_GAME_PLAYER_NAME
], gStdFont
, 255, 127, 0, 1);
981 e_TextureFontPrintEx(x
+16+w1
, _y
, _lc
[I_GAME_PING
], gStdFont
, 255, 127, 0, 1);
982 e_TextureFontPrintEx(x
+16+w1
+w2
, _y
, _lc
[I_GAME_FRAGS
], gStdFont
, 255, 127, 0, 1);
983 e_TextureFontPrintEx(x
+16+w1
+w2
+w3
, _y
, _lc
[I_GAME_DEATHS
], gStdFont
, 255, 127, 0, 1);
986 for aa
:= 0 to High(stat
) do
1000 e_DrawFillQuad(x
+16, _y
+4, x
+32-1, _y
+16+4-1, Color
.R
, Color
.G
, Color
.B
, 0);
1001 e_DrawQuad(x
+16, _y
+4, x
+32-1, _y
+16+4-1, 192, 192, 192);
1003 e_TextureFontPrintEx(x
+16+16+8, _y
+4, Name
, gStdFont
, r
, g
, 0, 1);
1005 e_TextureFontPrintEx(x
+w1
+16, _y
+4, Format(_lc
[I_GAME_PING_MS
], [Ping
, Loss
]), gStdFont
, r
, g
, 0, 1);
1007 e_TextureFontPrintEx(x
+w1
+w2
+16, _y
+4, IntToStr(Frags
), gStdFont
, r
, g
, 0, 1);
1009 e_TextureFontPrintEx(x
+w1
+w2
+w3
+16, _y
+4, IntToStr(Deaths
), gStdFont
, r
, g
, 0, 1);
1015 procedure g_Game_Init();
1021 gTempDelete
:= False;
1023 g_Texture_CreateWADEx('MENU_BACKGROUND', GameWAD
+':TEXTURES\TITLE');
1024 g_Texture_CreateWADEx('INTER', GameWAD
+':TEXTURES\INTER');
1025 g_Texture_CreateWADEx('ENDGAME_EN', GameWAD
+':TEXTURES\ENDGAME_EN');
1026 g_Texture_CreateWADEx('ENDGAME_RU', GameWAD
+':TEXTURES\ENDGAME_RU');
1028 LoadStdFont('STDTXT', 'STDFONT', gStdFont
);
1029 LoadFont('MENUTXT', 'MENUFONT', gMenuFont
);
1030 LoadFont('SMALLTXT', 'SMALLFONT', gMenuSmallFont
);
1032 g_Game_ClearLoading();
1033 g_Game_SetLoadingText(Format('Doom 2D: Forever %s', [GAME_VERSION
]), 0, False);
1034 g_Game_SetLoadingText('', 0, False);
1036 g_Game_SetLoadingText(_lc
[I_LOAD_CONSOLE
], 0, False);
1039 g_Game_SetLoadingText(_lc
[I_LOAD_MODELS
], 0, False);
1040 g_PlayerModel_LoadData();
1042 if FindFirst(ModelsDir
+'*.wad', faAnyFile
, SR
) = 0 then
1044 if not g_PlayerModel_Load(ModelsDir
+SR
.Name
) then
1045 e_WriteLog(Format('Error loading model %s', [SR
.Name
]), MSG_WARNING
);
1046 until FindNext(SR
) <> 0;
1049 if FindFirst(ModelsDir
+'*.pk3', faAnyFile
, SR
) = 0 then
1051 if not g_PlayerModel_Load(ModelsDir
+SR
.Name
) then
1052 e_WriteLog(Format('Error loading model %s', [SR
.Name
]), MSG_WARNING
);
1053 until FindNext(SR
) <> 0;
1056 if FindFirst(ModelsDir
+'*.zip', faAnyFile
, SR
) = 0 then
1058 if not g_PlayerModel_Load(ModelsDir
+SR
.Name
) then
1059 e_WriteLog(Format('Error loading model %s', [SR
.Name
]), MSG_WARNING
);
1060 until FindNext(SR
) <> 0;
1066 LastScreenShot
:= 0;
1068 {e_MouseInfo.Accel := 1.0;}
1070 g_Game_SetLoadingText(_lc
[I_LOAD_GAME_DATA
], 0, False);
1073 g_Game_SetLoadingText(_lc
[I_LOAD_MUSIC
], 0, False);
1074 g_Sound_CreateWADEx('MUSIC_INTERMUS', GameWAD
+':MUSIC\INTERMUS', True);
1075 g_Sound_CreateWADEx('MUSIC_MENU', GameWAD
+':MUSIC\MENU', True);
1076 g_Sound_CreateWADEx('MUSIC_ROUNDMUS', GameWAD
+':MUSIC\ROUNDMUS', True);
1077 g_Sound_CreateWADEx('MUSIC_STDENDMUS', GameWAD
+':MUSIC\ENDMUS', True);
1079 g_Game_SetLoadingText(_lc
[I_LOAD_MENUS
], 0, False);
1082 gMusic
:= TMusic
.Create();
1083 gMusic
.SetByName('MUSIC_MENU');
1086 gGameSettings
.WarmupTime
:= 30;
1088 gState
:= STATE_MENU
;
1090 SetLength(gEvents
, 6);
1091 gEvents
[0].Name
:= 'ongamestart';
1092 gEvents
[1].Name
:= 'ongameend';
1093 gEvents
[2].Name
:= 'onmapstart';
1094 gEvents
[3].Name
:= 'onmapend';
1095 gEvents
[4].Name
:= 'oninter';
1096 gEvents
[5].Name
:= 'onwadend';
1099 procedure g_Game_Free();
1101 if NetMode
= NET_CLIENT
then g_Net_Disconnect();
1102 if NetMode
= NET_SERVER
then g_Net_Host_Die();
1106 g_Player_RemoveAllCorpses();
1108 gGameSettings
.GameType
:= GT_NONE
;
1109 if gGameSettings
.GameMode
= GM_SINGLE
then
1110 gGameSettings
.GameMode
:= GM_DM
;
1111 gSwitchGameMode
:= gGameSettings
.GameMode
;
1114 gExitByTrigger
:= False;
1117 function IsActivePlayer(p
: TPlayer
): Boolean;
1122 Result
:= (not p
.FDummy
) and (not p
.FSpectator
);
1125 function GetActivePlayer_ByID(ID
: Integer): TPlayer
;
1132 if gPlayers
= nil then
1134 for a
:= Low(gPlayers
) to High(gPlayers
) do
1135 if IsActivePlayer(gPlayers
[a
]) then
1137 if gPlayers
[a
].UID
<> ID
then
1139 Result
:= gPlayers
[a
];
1144 function GetActivePlayerID_Next(Skip
: Integer = -1): Integer;
1150 if gPlayers
= nil then
1154 for a
:= Low(gPlayers
) to High(gPlayers
) do
1155 if IsActivePlayer(gPlayers
[a
]) then
1157 SetLength(ids
, Length(ids
) + 1);
1158 ids
[High(ids
)] := gPlayers
[a
].UID
;
1159 if gPlayers
[a
].UID
= Skip
then
1162 if Length(ids
) = 0 then
1167 Result
:= ids
[(idx
+ 1) mod Length(ids
)];
1170 function GetActivePlayerID_Prev(Skip
: Integer = -1): Integer;
1176 if gPlayers
= nil then
1180 for a
:= Low(gPlayers
) to High(gPlayers
) do
1181 if IsActivePlayer(gPlayers
[a
]) then
1183 SetLength(ids
, Length(ids
) + 1);
1184 ids
[High(ids
)] := gPlayers
[a
].UID
;
1185 if gPlayers
[a
].UID
= Skip
then
1188 if Length(ids
) = 0 then
1191 Result
:= ids
[Length(ids
) - 1]
1193 Result
:= ids
[(Length(ids
) - 1 + idx
) mod Length(ids
)];
1196 procedure g_Game_Update();
1198 Msg
: g_gui
.TMessage
;
1204 // Ïîðà âûêëþ÷àòü èãðó:
1205 if gExit
= EXIT_QUIT
then
1207 // Èãðà çàêîí÷èëàñü - îáðàáàòûâàåì:
1211 if gExit
= EXIT_QUIT
then
1215 // ×èòàåì êëàâèàòóðó è äæîéñòèê, åñëè îêíî àêòèâíî:
1218 // Îáíîâëÿåì êîíñîëü (äâèæåíèå è ñîîáùåíèÿ):
1221 if (NetMode
= NET_NONE
) and (g_Game_IsNet
) and (gGameOn
or (gState
in [STATE_FOLD
, STATE_INTERCUSTOM
])) then
1223 gExit
:= EXIT_SIMPLE
;
1229 STATE_INTERSINGLE
, // Ñòàòèñòêà ïîñëå ïðîõîæäåíèÿ óðîâíÿ â Îäèíî÷íîé èãðå
1230 STATE_INTERCUSTOM
, // Ñòàòèñòêà ïîñëå ïðîõîæäåíèÿ óðîâíÿ â Ñâîåé èãðå
1231 STATE_INTERTEXT
, // Òåêñò ìåæäó óðîâíÿìè
1232 STATE_INTERPIC
: // Êàðòèíêà ìåæäó óðîâíÿìè
1234 if g_Game_IsNet
and g_Game_IsServer
then
1236 gInterTime
:= gInterTime
+ GAME_TICK
;
1237 a
:= Min((gInterEndTime
- gInterTime
) div 1000 + 1, 255);
1238 if a
<> gServInterTime
then
1240 gServInterTime
:= a
;
1241 MH_SEND_TimeSync(gServInterTime
);
1245 if (not g_Game_IsClient
) and
1248 (e_KeyPressed(IK_RETURN
) or e_KeyPressed(IK_KPRETURN
) or e_KeyPressed(IK_SPACE
))
1249 and (not gJustChatted
) and (not gConsoleShow
) and (not gChatShow
)
1250 and (g_ActiveWindow
= nil)
1252 or (g_Game_IsNet
and (gInterTime
> gInterEndTime
))
1255 begin // Íàæàëè <Enter>/<Ïðîáåë> èëè ïðîøëî äîñòàòî÷íî âðåìåíè:
1256 g_Game_StopAllSounds(True);
1258 if gMapOnce
then // Ýòî áûë òåñò
1259 gExit
:= EXIT_SIMPLE
1261 if gNextMap
<> '' then // Ïåðåõîäèì íà ñëåäóþùóþ êàðòó
1262 g_Game_ChangeMap(gNextMap
)
1263 else // Ñëåäóþùåé êàðòû íåò
1265 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
] then
1267 // Âûõîä â ãëàâíîå ìåíþ:
1269 g_GUI_ShowWindow('MainMenu');
1270 gMusic
.SetByName('MUSIC_MENU');
1272 gState
:= STATE_MENU
;
1275 // Ôèíàëüíàÿ êàðòèíêà:
1276 g_Game_ExecuteEvent('onwadend');
1278 if not gMusic
.SetByName('MUSIC_endmus') then
1279 gMusic
.SetByName('MUSIC_STDENDMUS');
1281 gState
:= STATE_ENDPIC
;
1283 g_Game_ExecuteEvent('ongameend');
1289 if gState
= STATE_INTERTEXT
then
1290 if InterText
.counter
> 0 then
1291 InterText
.counter
:= InterText
.counter
- 1;
1294 STATE_FOLD
: // Çàòóõàíèå ýêðàíà
1296 if EndingGameCounter
= 0 then
1298 // Çàêîí÷èëñÿ óðîâåíü â Ñâîåé èãðå:
1299 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
1301 if gLastMap
and (gGameSettings
.GameMode
= GM_COOP
) then
1303 g_Game_ExecuteEvent('onwadend');
1304 if not gMusic
.SetByName('MUSIC_endmus') then
1305 gMusic
.SetByName('MUSIC_STDENDMUS');
1308 gMusic
.SetByName('MUSIC_ROUNDMUS');
1311 gState
:= STATE_INTERCUSTOM
;
1313 else // Çàêîí÷èëàñü ïîñëåäíÿÿ êàðòà â Îäèíî÷íîé èãðå
1315 gMusic
.SetByName('MUSIC_INTERMUS');
1317 gState
:= STATE_INTERSINGLE
;
1319 g_Game_ExecuteEvent('oninter');
1322 DecMin(EndingGameCounter
, 6, 0);
1325 STATE_ENDPIC
: // Êàðòèíêà îêîí÷àíèÿ ìåãàÂàäà
1327 if gMapOnce
then // Ýòî áûë òåñò
1329 gExit
:= EXIT_SIMPLE
;
1335 g_Serverlist_Control(slCurrent
);
1338 if g_Game_IsNet
then
1339 if not gConsoleShow
then
1340 if not gChatShow
then
1342 if g_ActiveWindow
= nil then
1344 if e_KeyPressed(gGameControls
.GameControls
.Chat
) then
1345 g_Console_Chat_Switch(False)
1346 else if (e_KeyPressed(gGameControls
.GameControls
.TeamChat
)) and
1347 (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
1348 g_Console_Chat_Switch(True);
1351 if not gChatEnter
then
1352 if (not e_KeyPressed(gGameControls
.GameControls
.Chat
))
1353 and (not e_KeyPressed(gGameControls
.GameControls
.TeamChat
)) then
1356 // Ñòàòèñòèêà ïî Tab:
1358 IsDrawStat
:= (not gConsoleShow
) and (not gChatShow
) and
1359 (gGameSettings
.GameType
<> GT_SINGLE
) and
1360 e_KeyPressed(gGameControls
.GameControls
.Stat
);
1363 if gGameOn
and not gPause
and (gState
<> STATE_FOLD
) then
1365 // Âðåìÿ += 28 ìèëëèñåêóíä:
1366 gTime
:= gTime
+ GAME_TICK
;
1368 // Ñîîáùåíèå ïîñåðåäèíå ýêðàíà:
1369 if MessageTime
= 0 then
1371 if MessageTime
> 0 then
1372 MessageTime
:= MessageTime
- 1;
1374 if (g_Game_IsServer
) then
1376 // Áûë çàäàí ëèìèò âðåìåíè:
1377 if (gGameSettings
.TimeLimit
> 0) then
1378 if (gTime
- gGameStartTime
) div 1000 >= gGameSettings
.TimeLimit
then
1379 begin // Îí ïðîøåë => êîíåö óðîâíÿ
1384 // Íàäî ðåñïàâíèòü èãðîêîâ â LMS:
1385 if (gLMSRespawn
> LMS_RESPAWN_NONE
) and (gLMSRespawnTime
< gTime
) then
1386 g_Game_RestartRound(gLMSSoftSpawn
);
1388 // Ïðîâåðèì ðåçóëüòàò ãîëîñîâàíèÿ, åñëè âðåìÿ ïðîøëî
1389 if gVoteInProgress
and (gVoteTimer
< gTime
) then
1391 else if gVotePassed
and (gVoteCmdTimer
< gTime
) then
1393 g_Console_Process(gVoteCommand
);
1395 gVotePassed
:= False;
1398 // Çàìåðÿåì âðåìÿ çàõâàòà ôëàãîâ
1399 if gFlags
[FLAG_RED
].State
= FLAG_STATE_CAPTURED
then
1400 gFlags
[FLAG_RED
].CaptureTime
:= gFlags
[FLAG_RED
].CaptureTime
+ GAME_TICK
;
1401 if gFlags
[FLAG_BLUE
].State
= FLAG_STATE_CAPTURED
then
1402 gFlags
[FLAG_BLUE
].CaptureTime
:= gFlags
[FLAG_BLUE
].CaptureTime
+ GAME_TICK
;
1404 // Áûë çàäàí ëèìèò ïîáåä:
1405 if (gGameSettings
.GoalLimit
> 0) then
1409 if gGameSettings
.GameMode
= GM_DM
then
1410 begin // Â DM èùåì èãðîêà ñ max ôðàãàìè
1411 for i
:= 0 to High(gPlayers
) do
1412 if gPlayers
[i
] <> nil then
1413 if gPlayers
[i
].Frags
> b
then
1414 b
:= gPlayers
[i
].Frags
;
1417 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
1418 begin //  CTF/TDM âûáèðàåì êîìàíäó ñ íàèáîëüøèì ñ÷åòîì
1419 b
:= Max(gTeamStat
[TEAM_RED
].Goals
, gTeamStat
[TEAM_BLUE
].Goals
);
1422 // Ëèìèò ïîáåä íàáðàí => êîíåö óðîâíÿ:
1423 if b
>= gGameSettings
.GoalLimit
then
1430 // Îáðàáàòûâàåì êëàâèøè èãðîêîâ:
1431 if gPlayer1
<> nil then gPlayer1
.ReleaseKeys();
1432 if gPlayer2
<> nil then gPlayer2
.ReleaseKeys();
1433 if (not gConsoleShow
) and (not gChatShow
) and (g_ActiveWindow
= nil) then
1436 if gPlayer1
<> nil then
1437 with gGameControls
.P1Control
do
1439 if e_KeyPressed(KeyLeft
) and (not e_KeyPressed(KeyRight
)) then
1440 P1MoveButton
:= 1 // Íàæàòà òîëüêî "Âëåâî"
1442 if (not e_KeyPressed(KeyLeft
)) and e_KeyPressed(KeyRight
) then
1443 P1MoveButton
:= 2 // Íàæàòà òîëüêî "Âïðàâî"
1445 if (not e_KeyPressed(KeyLeft
)) and (not e_KeyPressed(KeyRight
)) then
1446 P1MoveButton
:= 0; // Íå íàæàòû íè "Âëåâî", íè "Âïðàâî"
1448 // Ñåé÷àñ èëè ðàíüøå áûëè íàæàòû "Âëåâî"/"Âïðàâî" => ïåðåäàåì èãðîêó:
1449 if P1MoveButton
= 1 then
1450 gPlayer1
.PressKey(KEY_LEFT
)
1452 if P1MoveButton
= 2 then
1453 gPlayer1
.PressKey(KEY_RIGHT
);
1455 // Ðàíüøå áûëà íàæàòà "Âïðàâî", à ñåé÷àñ "Âëåâî" => áåæèì âïðàâî, ñìîòðèì âëåâî:
1456 if (P1MoveButton
= 2) and e_KeyPressed(KeyLeft
) then
1457 gPlayer1
.SetDirection(D_LEFT
)
1459 // Ðàíüøå áûëà íàæàòà "Âëåâî", à ñåé÷àñ "Âïðàâî" => áåæèì âëåâî, ñìîòðèì âïðàâî:
1460 if (P1MoveButton
= 1) and e_KeyPressed(KeyRight
) then
1461 gPlayer1
.SetDirection(D_RIGHT
)
1463 // ×òî-òî áûëî íàæàòî è íå èçìåíèëîñü => êóäà áåæèì, òóäà è ñìîòðèì:
1464 if P1MoveButton
<> 0 then
1465 gPlayer1
.SetDirection(TDirection(P1MoveButton
-1));
1467 // Îñòàëüíûå êëàâèøè:
1468 if e_KeyPressed(KeyJump
) then gPlayer1
.PressKey(KEY_JUMP
);
1469 if e_KeyPressed(KeyUp
) then gPlayer1
.PressKey(KEY_UP
);
1470 if e_KeyPressed(KeyDown
) then gPlayer1
.PressKey(KEY_DOWN
);
1471 if e_KeyPressed(KeyFire
) then gPlayer1
.PressKey(KEY_FIRE
);
1472 if e_KeyPressed(KeyNextWeapon
) then gPlayer1
.PressKey(KEY_NEXTWEAPON
);
1473 if e_KeyPressed(KeyPrevWeapon
) then gPlayer1
.PressKey(KEY_PREVWEAPON
);
1474 if e_KeyPressed(KeyOpen
) then gPlayer1
.PressKey(KEY_OPEN
);
1477 if gPlayer2
<> nil then
1478 with gGameControls
.P2Control
do
1480 if e_KeyPressed(KeyLeft
) and (not e_KeyPressed(KeyRight
)) then
1481 P2MoveButton
:= 1 // Íàæàòà òîëüêî "Âëåâî"
1483 if (not e_KeyPressed(KeyLeft
)) and e_KeyPressed(KeyRight
) then
1484 P2MoveButton
:= 2 // Íàæàòà òîëüêî "Âïðàâî"
1486 if (not e_KeyPressed(KeyLeft
)) and (not e_KeyPressed(KeyRight
)) then
1487 P2MoveButton
:= 0; // Íå íàæàòû íè "Âëåâî", íè "Âïðàâî"
1489 // Ñåé÷àñ èëè ðàíüøå áûëè íàæàòû "Âëåâî"/"Âïðàâî" => ïåðåäàåì èãðîêó:
1490 if P2MoveButton
= 1 then
1491 gPlayer2
.PressKey(KEY_LEFT
, 1000)
1493 if P2MoveButton
= 2 then
1494 gPlayer2
.PressKey(KEY_RIGHT
, 1000);
1496 // Ðàíüøå áûëà íàæàòà "Âïðàâî", à ñåé÷àñ "Âëåâî" => áåæèì âïðàâî, ñìîòðèì âëåâî:
1497 if (P2MoveButton
= 2) and e_KeyPressed(KeyLeft
) then
1498 gPlayer2
.SetDirection(D_LEFT
)
1500 // Ðàíüøå áûëà íàæàòà "Âëåâî", à ñåé÷àñ "Âïðàâî" => áåæèì âëåâî, ñìîòðèì âïðàâî:
1501 if (P2MoveButton
= 1) and e_KeyPressed(KeyRight
) then
1502 gPlayer2
.SetDirection(D_RIGHT
)
1504 // ×òî-òî áûëî íàæàòî è íå èçìåíèëîñü => êóäà áåæèì, òóäà è ñìîòðèì:
1505 if P2MoveButton
<> 0 then
1506 gPlayer2
.SetDirection(TDirection(P2MoveButton
-1));
1508 // Îñòàëüíûå êëàâèøè:
1509 if e_KeyPressed(KeyJump
) then gPlayer2
.PressKey(KEY_JUMP
, 1000);
1510 if e_KeyPressed(KeyUp
) then gPlayer2
.PressKey(KEY_UP
, 1000);
1511 if e_KeyPressed(KeyDown
) then gPlayer2
.PressKey(KEY_DOWN
, 1000);
1512 if e_KeyPressed(KeyFire
) then gPlayer2
.PressKey(KEY_FIRE
);
1513 if e_KeyPressed(KeyNextWeapon
) then gPlayer2
.PressKey(KEY_NEXTWEAPON
);
1514 if e_KeyPressed(KeyPrevWeapon
) then gPlayer2
.PressKey(KEY_PREVWEAPON
);
1515 if e_KeyPressed(KeyOpen
) then gPlayer2
.PressKey(KEY_OPEN
);
1517 end // if not console
1519 if g_Game_IsNet
and (gPlayer1
<> nil) then
1520 gPlayer1
.PressKey(KEY_CHAT
, 10000);
1525 if (gPlayer1
= nil) and (gPlayer2
= nil) and
1526 (not gConsoleShow
) and (not gChatShow
) and (g_ActiveWindow
= nil) then
1528 if not gSpectKeyPress
then
1530 if e_KeyPressed(gGameControls
.P1Control
.KeyJump
) then
1532 // switch spect mode
1534 SPECT_NONE
: ; // not spectator
1536 SPECT_MAPVIEW
: Inc(gSpectMode
);
1537 SPECT_PLAYERS
: gSpectMode
:= SPECT_STATS
; // reset to 1
1539 gSpectKeyPress
:= True;
1541 if gSpectMode
= SPECT_MAPVIEW
then
1543 if e_KeyPressed(gGameControls
.P1Control
.KeyLeft
) then
1544 gSpectX
:= Max(gSpectX
- gSpectStep
, 0);
1545 if e_KeyPressed(gGameControls
.P1Control
.KeyRight
) then
1546 gSpectX
:= Min(gSpectX
+ gSpectStep
, gMapInfo
.Width
- gScreenWidth
);
1547 if e_KeyPressed(gGameControls
.P1Control
.KeyUp
) then
1548 gSpectY
:= Max(gSpectY
- gSpectStep
, 0);
1549 if e_KeyPressed(gGameControls
.P1Control
.KeyDown
) then
1550 gSpectY
:= Min(gSpectY
+ gSpectStep
, gMapInfo
.Height
- gScreenHeight
);
1551 if e_KeyPressed(gGameControls
.P1Control
.KeyPrevWeapon
) then
1554 if gSpectStep
> 4 then gSpectStep
:= gSpectStep
shr 1;
1555 gSpectKeyPress
:= True;
1557 if e_KeyPressed(gGameControls
.P1Control
.KeyNextWeapon
) then
1560 if gSpectStep
< 64 then gSpectStep
:= gSpectStep
shl 1;
1561 gSpectKeyPress
:= True;
1564 if gSpectMode
= SPECT_PLAYERS
then
1566 if e_KeyPressed(gGameControls
.P1Control
.KeyUp
) then
1569 gSpectViewTwo
:= True;
1570 gSpectKeyPress
:= True;
1572 if e_KeyPressed(gGameControls
.P1Control
.KeyDown
) then
1574 // remove second view
1575 gSpectViewTwo
:= False;
1576 gSpectKeyPress
:= True;
1578 if e_KeyPressed(gGameControls
.P1Control
.KeyLeft
) then
1580 // prev player (view 1)
1581 gSpectPID1
:= GetActivePlayerID_Prev(gSpectPID1
);
1582 gSpectKeyPress
:= True;
1584 if e_KeyPressed(gGameControls
.P1Control
.KeyRight
) then
1586 // next player (view 1)
1587 gSpectPID1
:= GetActivePlayerID_Next(gSpectPID1
);
1588 gSpectKeyPress
:= True;
1590 if e_KeyPressed(gGameControls
.P1Control
.KeyPrevWeapon
) then
1592 // prev player (view 2)
1593 gSpectPID2
:= GetActivePlayerID_Prev(gSpectPID2
);
1594 gSpectKeyPress
:= True;
1596 if e_KeyPressed(gGameControls
.P1Control
.KeyNextWeapon
) then
1598 // next player (view 2)
1599 gSpectPID2
:= GetActivePlayerID_Next(gSpectPID2
);
1600 gSpectKeyPress
:= True;
1605 if (not e_KeyPressed(gGameControls
.P1Control
.KeyJump
)) and
1606 (not e_KeyPressed(gGameControls
.P1Control
.KeyLeft
)) and
1607 (not e_KeyPressed(gGameControls
.P1Control
.KeyRight
)) and
1608 (not e_KeyPressed(gGameControls
.P1Control
.KeyUp
)) and
1609 (not e_KeyPressed(gGameControls
.P1Control
.KeyDown
)) and
1610 (not e_KeyPressed(gGameControls
.P1Control
.KeyPrevWeapon
)) and
1611 (not e_KeyPressed(gGameControls
.P1Control
.KeyNextWeapon
)) then
1612 gSpectKeyPress
:= False;
1615 // Îáíîâëÿåì âñå îñòàëüíîå:
1618 g_Triggers_Update();
1620 g_Monsters_Update();
1622 g_Player_UpdateAll();
1623 g_Player_UpdatePhysicalObjects();
1624 if gGameSettings
.GameType
= GT_SERVER
then
1625 if Length(gMonstersSpawned
) > 0 then
1627 for I
:= 0 to High(gMonstersSpawned
) do
1628 MH_SEND_MonsterSpawn(gMonstersSpawned
[I
]);
1629 SetLength(gMonstersSpawned
, 0);
1632 if (gSoundTriggerTime
> 8) then
1634 g_Game_UpdateTriggerSounds();
1635 gSoundTriggerTime
:= 0;
1638 Inc(gSoundTriggerTime
);
1640 if (NetMode
= NET_SERVER
) then
1642 Inc(NetTimeToUpdate
);
1643 Inc(NetTimeToReliable
);
1644 if NetTimeToReliable
>= NetRelupdRate
then
1646 for I
:= 0 to High(gPlayers
) do
1647 if gPlayers
[I
] <> nil then
1648 MH_SEND_PlayerPos(True, gPlayers
[I
].UID
);
1650 if gMonsters
<> nil then
1651 for I
:= 0 to High(gMonsters
) do
1652 if gMonsters
[I
] <> nil then
1654 if (gMonsters
[I
].MonsterType
= MONSTER_BARREL
) then
1656 if (gMonsters
[I
].GameVelX
<> 0) or (gMonsters
[I
].GameVelY
<> 0) then
1657 MH_SEND_MonsterPos(gMonsters
[I
].UID
);
1660 if (gMonsters
[I
].MonsterState
<> MONSTATE_SLEEP
) then
1661 if (gMonsters
[I
].MonsterState
<> MONSTATE_DEAD
) or
1662 (gMonsters
[I
].GameVelX
<> 0) or
1663 (gMonsters
[I
].GameVelY
<> 0) then
1664 MH_SEND_MonsterPos(gMonsters
[I
].UID
);
1667 NetTimeToReliable
:= 0;
1668 NetTimeToUpdate
:= NetUpdateRate
;
1670 else if NetTimeToUpdate
>= NetUpdateRate
then
1672 if gPlayers
<> nil then
1673 for I
:= 0 to High(gPlayers
) do
1674 if gPlayers
[I
] <> nil then
1675 MH_SEND_PlayerPos(False, gPlayers
[I
].UID
);
1677 if gMonsters
<> nil then
1678 for I
:= 0 to High(gMonsters
) do
1679 if gMonsters
[I
] <> nil then
1681 if (gMonsters
[I
].MonsterType
= MONSTER_BARREL
) then
1683 if (gMonsters
[I
].GameVelX
<> 0) or (gMonsters
[I
].GameVelY
<> 0) then
1684 MH_SEND_MonsterPos(gMonsters
[I
].UID
);
1687 if (gMonsters
[I
].MonsterState
<> MONSTATE_SLEEP
) then
1688 if (gMonsters
[I
].MonsterState
<> MONSTATE_DEAD
) or
1689 (gMonsters
[I
].GameVelX
<> 0) or
1690 (gMonsters
[I
].GameVelY
<> 0) then
1691 MH_SEND_MonsterPos(gMonsters
[I
].UID
);
1694 NetTimeToUpdate
:= 0;
1697 if NetUseMaster
then
1698 if gTime
>= NetTimeToMaster
then
1700 if (NetMHost
= nil) or (NetMPeer
= nil) then
1701 if not g_Net_Slist_Connect
then
1702 g_Console_Add(_lc
[I_NET_MSG_ERROR
] + _lc
[I_NET_SLIST_ERROR
]);
1705 NetTimeToMaster
:= gTime
+ NetMasterRate
;
1709 if NetMode
= NET_CLIENT
then
1710 MC_SEND_PlayerPos();
1711 end; // if gameOn ...
1713 // Àêòèâíî îêíî èíòåðôåéñà - ïåðåäàåì êëàâèøè åìó:
1714 if g_ActiveWindow
<> nil then
1716 w
:= e_GetFirstKeyPressed();
1718 if (w
<> IK_INVALID
) then
1720 Msg
.Msg
:= MESSAGE_DIKEY
;
1722 g_ActiveWindow
.OnMessage(Msg
);
1725 // Åñëè îíî îò ýòîãî íå çàêðûëîñü, òî îáíîâëÿåì:
1726 if g_ActiveWindow
<> nil then
1727 g_ActiveWindow
.Update();
1729 // Íóæíî ñìåíèòü ðàçðåøåíèå:
1730 if gResolutionChange
then
1732 e_WriteLog('Changing resolution', MSG_NOTIFY
);
1733 g_Game_ChangeResolution(gRC_Width
, gRC_Height
, gRC_FullScreen
, gRC_Maximized
);
1734 gResolutionChange
:= False;
1737 // Íóæíî ñìåíèòü ÿçûê:
1738 if gLanguageChange
then
1740 //e_WriteLog('Read language file', MSG_NOTIFY);
1741 //g_Language_Load(DataDir + gLanguage + '.txt');
1742 g_Language_Set(gLanguage
);
1744 gLanguageChange
:= False;
1748 // Äåëàåì ñêðèíøîò (íå ÷àùå 200 ìèëëèñåêóíä):
1749 if e_KeyPressed(gGameControls
.GameControls
.TakeScreenshot
) then
1750 if (GetTimer()-LastScreenShot
) > 200000 then
1753 LastScreenShot
:= GetTimer();
1756 // Ãîðÿ÷àÿ êëàâèøà äëÿ âûçîâà ìåíþ âûõîäà èç èãðû (F10):
1757 if e_KeyPressed(IK_F10
) and
1759 (not gConsoleShow
) and
1760 (g_ActiveWindow
= nil) then
1765 Time
:= GetTimer() div 1000;
1767 // Îáðàáîòêà îòëîæåííûõ ñîáûòèé:
1768 if gDelayedEvents
<> nil then
1769 for a
:= 0 to High(gDelayedEvents
) do
1770 if gDelayedEvents
[a
].Pending
and
1772 ((gDelayedEvents
[a
].DEType
= DE_GLOBEVENT
) and (gDelayedEvents
[a
].Time
<= Time
)) or
1773 ((gDelayedEvents
[a
].DEType
> DE_GLOBEVENT
) and (gDelayedEvents
[a
].Time
<= gTime
))
1776 case gDelayedEvents
[a
].DEType
of
1778 g_Game_ExecuteEvent(gDelayedEvents
[a
].DEStr
);
1781 g_Game_Announce_GoodShot(gDelayedEvents
[a
].DENum
);
1785 g_Game_Announce_KillCombo(gDelayedEvents
[a
].DENum
);
1786 if g_Game_IsNet
and g_Game_IsServer
then
1787 MH_SEND_GameEvent(NET_EV_KILLCOMBO
, gDelayedEvents
[a
].DENum
);
1790 gDelayedEvents
[a
].Pending
:= False;
1793 // Êàæäóþ ñåêóíäó îáíîâëÿåì ñ÷åò÷èê îáíîâëåíèé:
1794 UPSCounter
:= UPSCounter
+ 1;
1795 if Time
- UPSTime
>= 1000 then
1803 procedure g_Game_LoadData();
1805 if DataLoaded
then Exit
;
1807 e_WriteLog('Loading game data...', MSG_NOTIFY
);
1809 g_Texture_CreateWADEx('NOTEXTURE', GameWAD
+':TEXTURES\NOTEXTURE');
1810 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUD', GameWAD
+':TEXTURES\HUD');
1811 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDAIR', GameWAD
+':TEXTURES\AIRBAR');
1812 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDJET', GameWAD
+':TEXTURES\JETBAR');
1813 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDBG', GameWAD
+':TEXTURES\HUDBG');
1814 g_Texture_CreateWADEx('TEXTURE_PLAYER_ARMORHUD', GameWAD
+':TEXTURES\ARMORHUD');
1815 g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG', GameWAD
+':TEXTURES\FLAGHUD_RB');
1816 g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG_S', GameWAD
+':TEXTURES\FLAGHUD_RS');
1817 g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG_D', GameWAD
+':TEXTURES\FLAGHUD_RD');
1818 g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG', GameWAD
+':TEXTURES\FLAGHUD_BB');
1819 g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG_S', GameWAD
+':TEXTURES\FLAGHUD_BS');
1820 g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG_D', GameWAD
+':TEXTURES\FLAGHUD_BD');
1821 g_Texture_CreateWADEx('TEXTURE_PLAYER_TALKBUBBLE', GameWAD
+':TEXTURES\TALKBUBBLE');
1822 g_Texture_CreateWADEx('TEXTURE_PLAYER_INVULPENTA', GameWAD
+':TEXTURES\PENTA');
1823 g_Frames_CreateWAD(nil, 'FRAMES_TELEPORT', GameWAD
+':TEXTURES\TELEPORT', 64, 64, 10, False);
1824 g_Sound_CreateWADEx('SOUND_GAME_TELEPORT', GameWAD
+':SOUNDS\TELEPORT');
1825 g_Sound_CreateWADEx('SOUND_GAME_NOTELEPORT', GameWAD
+':SOUNDS\NOTELEPORT');
1826 g_Sound_CreateWADEx('SOUND_GAME_DOOROPEN', GameWAD
+':SOUNDS\DOOROPEN');
1827 g_Sound_CreateWADEx('SOUND_GAME_DOORCLOSE', GameWAD
+':SOUNDS\DOORCLOSE');
1828 g_Sound_CreateWADEx('SOUND_GAME_BULK1', GameWAD
+':SOUNDS\BULK1');
1829 g_Sound_CreateWADEx('SOUND_GAME_BULK2', GameWAD
+':SOUNDS\BULK2');
1830 g_Sound_CreateWADEx('SOUND_GAME_BUBBLE1', GameWAD
+':SOUNDS\BUBBLE1');
1831 g_Sound_CreateWADEx('SOUND_GAME_BUBBLE2', GameWAD
+':SOUNDS\BUBBLE2');
1832 g_Sound_CreateWADEx('SOUND_GAME_SWITCH1', GameWAD
+':SOUNDS\SWITCH1');
1833 g_Sound_CreateWADEx('SOUND_GAME_SWITCH0', GameWAD
+':SOUNDS\SWITCH0');
1834 g_Sound_CreateWADEx('SOUND_GAME_RADIO', GameWAD
+':SOUNDS\RADIO');
1835 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD1', GameWAD
+':SOUNDS\GOOD1');
1836 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD2', GameWAD
+':SOUNDS\GOOD2');
1837 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD3', GameWAD
+':SOUNDS\GOOD3');
1838 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD4', GameWAD
+':SOUNDS\GOOD4');
1839 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL2X', GameWAD
+':SOUNDS\KILL2X');
1840 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL3X', GameWAD
+':SOUNDS\KILL3X');
1841 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL4X', GameWAD
+':SOUNDS\KILL4X');
1842 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILLMX', GameWAD
+':SOUNDS\KILLMX');
1844 goodsnd
[0] := TPlayableSound
.Create();
1845 goodsnd
[1] := TPlayableSound
.Create();
1846 goodsnd
[2] := TPlayableSound
.Create();
1847 goodsnd
[3] := TPlayableSound
.Create();
1849 goodsnd
[0].SetByName('SOUND_ANNOUNCER_GOOD1');
1850 goodsnd
[1].SetByName('SOUND_ANNOUNCER_GOOD2');
1851 goodsnd
[2].SetByName('SOUND_ANNOUNCER_GOOD3');
1852 goodsnd
[3].SetByName('SOUND_ANNOUNCER_GOOD4');
1854 killsnd
[0] := TPlayableSound
.Create();
1855 killsnd
[1] := TPlayableSound
.Create();
1856 killsnd
[2] := TPlayableSound
.Create();
1857 killsnd
[3] := TPlayableSound
.Create();
1859 killsnd
[0].SetByName('SOUND_ANNOUNCER_KILL2X');
1860 killsnd
[1].SetByName('SOUND_ANNOUNCER_KILL3X');
1861 killsnd
[2].SetByName('SOUND_ANNOUNCER_KILL4X');
1862 killsnd
[3].SetByName('SOUND_ANNOUNCER_KILLMX');
1864 g_Game_SetLoadingText(_lc
[I_LOAD_ITEMS_DATA
], 0, False);
1867 g_Game_SetLoadingText(_lc
[I_LOAD_WEAPONS_DATA
], 0, False);
1868 g_Weapon_LoadData();
1870 g_Monsters_LoadData();
1875 procedure g_Game_FreeData();
1877 if not DataLoaded
then Exit
;
1880 g_Weapon_FreeData();
1881 g_Monsters_FreeData();
1883 e_WriteLog('Releasing game data...', MSG_NOTIFY
);
1885 g_Texture_Delete('NOTEXTURE');
1886 g_Texture_Delete('TEXTURE_PLAYER_HUD');
1887 g_Texture_Delete('TEXTURE_PLAYER_HUDBG');
1888 g_Texture_Delete('TEXTURE_PLAYER_ARMORHUD');
1889 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG');
1890 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG_S');
1891 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG_D');
1892 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG');
1893 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG_S');
1894 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG_D');
1895 g_Texture_Delete('TEXTURE_PLAYER_TALKBUBBLE');
1896 g_Texture_Delete('TEXTURE_PLAYER_INVULPENTA');
1897 g_Frames_DeleteByName('FRAMES_TELEPORT');
1898 g_Sound_Delete('SOUND_GAME_TELEPORT');
1899 g_Sound_Delete('SOUND_GAME_NOTELEPORT');
1900 g_Sound_Delete('SOUND_GAME_DOOROPEN');
1901 g_Sound_Delete('SOUND_GAME_DOORCLOSE');
1902 g_Sound_Delete('SOUND_GAME_BULK1');
1903 g_Sound_Delete('SOUND_GAME_BULK2');
1904 g_Sound_Delete('SOUND_GAME_BUBBLE1');
1905 g_Sound_Delete('SOUND_GAME_BUBBLE2');
1906 g_Sound_Delete('SOUND_GAME_SWITCH1');
1907 g_Sound_Delete('SOUND_GAME_SWITCH0');
1914 g_Sound_Delete('SOUND_ANNOUNCER_GOOD1');
1915 g_Sound_Delete('SOUND_ANNOUNCER_GOOD2');
1916 g_Sound_Delete('SOUND_ANNOUNCER_GOOD3');
1917 g_Sound_Delete('SOUND_ANNOUNCER_GOOD4');
1924 g_Sound_Delete('SOUND_ANNOUNCER_KILL2X');
1925 g_Sound_Delete('SOUND_ANNOUNCER_KILL3X');
1926 g_Sound_Delete('SOUND_ANNOUNCER_KILL4X');
1927 g_Sound_Delete('SOUND_ANNOUNCER_KILLMX');
1929 DataLoaded
:= False;
1932 procedure DrawCustomStat();
1938 ww2
, hh2
, r
, g
, b
, rr
, gg
, bb
: Byte;
1939 s1
, s2
, topstr
: String;
1941 e_TextureFontGetSize(gStdFont
, ww2
, hh2
);
1944 if e_KeyPressed(IK_TAB
) then
1946 if not gStatsPressed
then
1948 gStatsOff
:= not gStatsOff
;
1949 gStatsPressed
:= True;
1953 gStatsPressed
:= False;
1957 s1
:= _lc
[I_MENU_INTER_NOTICE_TAB
];
1958 w
:= (Length(s1
) * ww2
) div 2;
1959 x
:= gScreenWidth
div 2 - w
;
1961 e_TextureFontPrint(x
, y
, s1
, gStdFont
);
1965 if (gGameSettings
.GameMode
= GM_COOP
) then
1967 if gMissionFailed
then
1968 topstr
:= _lc
[I_MENU_INTER_MISSION_FAIL
]
1970 topstr
:= _lc
[I_MENU_INTER_LEVEL_COMPLETE
];
1973 topstr
:= _lc
[I_MENU_INTER_ROUND_OVER
];
1975 e_CharFont_GetSize(gMenuFont
, topstr
, ww1
, hh1
);
1976 e_CharFont_Print(gMenuFont
, (gScreenWidth
div 2)-(ww1
div 2), 16, topstr
);
1978 if g_Game_IsNet
then
1980 topstr
:= Format(_lc
[I_MENU_INTER_NOTICE_TIME
], [gServInterTime
]);
1981 if not gChatShow
then
1982 e_TextureFontPrintEx((gScreenWidth
div 2)-(Length(topstr
)*ww2
div 2),
1983 gScreenHeight
-(hh2
+4)*2, topstr
, gStdFont
, 255, 255, 255, 1);
1986 if g_Game_IsClient
then
1987 topstr
:= _lc
[I_MENU_INTER_NOTICE_MAP
]
1989 topstr
:= _lc
[I_MENU_INTER_NOTICE_SPACE
];
1990 if not gChatShow
then
1991 e_TextureFontPrintEx((gScreenWidth
div 2)-(Length(topstr
)*ww2
div 2),
1992 gScreenHeight
-(hh2
+4), topstr
, gStdFont
, 255, 255, 255, 1);
1997 w
:= gScreenWidth
-x
*2;
2003 e_DrawFillQuad(x
, y
, gScreenWidth
-x
-1, gScreenHeight
-y
-1, 64, 64, 64, 32);
2004 e_DrawQuad(x
, y
, gScreenWidth
-x
-1, gScreenHeight
-y
-1, 255, 127, 0);
2006 m
:= Max(Length(_lc
[I_MENU_MAP
])+1, Length(_lc
[I_GAME_GAME_TIME
])+1)*ww2
;
2008 case CustomStat
.GameMode
of
2011 if gGameSettings
.MaxLives
= 0 then
2012 s1
:= _lc
[I_GAME_DM
]
2014 s1
:= _lc
[I_GAME_LMS
];
2018 if gGameSettings
.MaxLives
= 0 then
2019 s1
:= _lc
[I_GAME_TDM
]
2021 s1
:= _lc
[I_GAME_TLMS
];
2023 GM_CTF
: s1
:= _lc
[I_GAME_CTF
];
2026 if gGameSettings
.MaxLives
= 0 then
2027 s1
:= _lc
[I_GAME_COOP
]
2029 s1
:= _lc
[I_GAME_SURV
];
2035 e_TextureFontPrintEx(x
+(w
div 2)-(Length(s1
)*ww2
div 2), _y
, s1
, gStdFont
, 255, 255, 255, 1);
2039 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_MENU_MAP
], gStdFont
, 255, 127, 0, 1);
2040 e_TextureFontPrint(x
+8+m
, _y
, Format('%s - %s', [CustomStat
.Map
, CustomStat
.MapName
]), gStdFont
);
2043 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_GAME_TIME
], gStdFont
, 255, 127, 0, 1);
2044 e_TextureFontPrint(x
+8+m
, _y
, Format('%d:%.2d:%.2d', [CustomStat
.GameTime
div 1000 div 3600,
2045 (CustomStat
.GameTime
div 1000 div 60) mod 60,
2046 CustomStat
.GameTime
div 1000 mod 60]), gStdFont
);
2048 pc
:= Length(CustomStat
.PlayerStat
);
2049 if pc
= 0 then Exit
;
2051 if CustomStat
.GameMode
= GM_COOP
then
2053 m
:= Max(Length(_lc
[I_GAME_MONSTERS
])+1, Length(_lc
[I_GAME_SECRETS
])+1)*ww2
;
2055 s2
:= _lc
[I_GAME_MONSTERS
];
2056 e_TextureFontPrintEx(x
+8, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2057 e_TextureFontPrintEx(x
+8+m
, _y
, IntToStr(gCoopMonstersKilled
) + '/' + IntToStr(gTotalMonsters
), gStdFont
, 255, 255, 255, 1);
2059 s2
:= _lc
[I_GAME_SECRETS
];
2060 e_TextureFontPrintEx(x
+8, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2061 e_TextureFontPrintEx(x
+8+m
, _y
, IntToStr(gCoopSecretsFound
) + '/' + IntToStr(gSecretsCount
), gStdFont
, 255, 255, 255, 1);
2064 m
:= Max(Length(_lc
[I_GAME_MONSTERS_TOTAL
])+1, Length(_lc
[I_GAME_SECRETS_TOTAL
])+1)*ww2
;
2066 s2
:= _lc
[I_GAME_MONSTERS_TOTAL
];
2067 e_TextureFontPrintEx(x
+250, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2068 e_TextureFontPrintEx(x
+250+m
, _y
, IntToStr(gCoopTotalMonstersKilled
) + '/' + IntToStr(gCoopTotalMonsters
), gStdFont
, 255, 255, 255, 1);
2070 s2
:= _lc
[I_GAME_SECRETS_TOTAL
];
2071 e_TextureFontPrintEx(x
+250, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2072 e_TextureFontPrintEx(x
+250+m
, _y
, IntToStr(gCoopTotalSecretsFound
) + '/' + IntToStr(gCoopTotalSecrets
), gStdFont
, 255, 255, 255, 1);
2076 if CustomStat
.GameMode
in [GM_TDM
, GM_CTF
] then
2081 if TeamStat
[TEAM_RED
].Goals
> TeamStat
[TEAM_BLUE
].Goals
then s1
:= _lc
[I_GAME_WIN_RED
]
2082 else if TeamStat
[TEAM_BLUE
].Goals
> TeamStat
[TEAM_RED
].Goals
then s1
:= _lc
[I_GAME_WIN_BLUE
]
2083 else s1
:= _lc
[I_GAME_WIN_DRAW
];
2085 e_TextureFontPrintEx(x
+8+(w
div 2)-(Length(s1
)*ww2
div 2), _y
, s1
, gStdFont
, 255, 255, 255, 1);
2088 for t
:= TEAM_RED
to TEAM_BLUE
do
2090 if t
= TEAM_RED
then
2092 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_TEAM_RED
],
2093 gStdFont
, 255, 0, 0, 1);
2094 e_TextureFontPrintEx(x
+w1
+8, _y
, IntToStr(CustomStat
.TeamStat
[TEAM_RED
].Goals
),
2095 gStdFont
, 255, 0, 0, 1);
2102 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_TEAM_BLUE
],
2103 gStdFont
, 0, 0, 255, 1);
2104 e_TextureFontPrintEx(x
+w1
+8, _y
, IntToStr(CustomStat
.TeamStat
[TEAM_BLUE
].Goals
),
2105 gStdFont
, 0, 0, 255, 1);
2111 e_DrawLine(1, x
+8, _y
+20, x
-8+w
, _y
+20, r
, g
, b
);
2114 for p
:= 0 to High(CustomStat
.PlayerStat
) do
2115 if CustomStat
.PlayerStat
[p
].Team
= t
then
2116 with CustomStat
.PlayerStat
[p
] do
2130 e_TextureFontPrintEx(x
+8, _y
, Name
, gStdFont
, rr
, gg
, bb
, 1);
2131 e_TextureFontPrintEx(x
+w1
+8, _y
, IntToStr(Frags
), gStdFont
, rr
, gg
, bb
, 1);
2132 e_TextureFontPrintEx(x
+w1
+w2
+8, _y
, IntToStr(Deaths
), gStdFont
, rr
, gg
, bb
, 1);
2139 else if CustomStat
.GameMode
in [GM_DM
, GM_COOP
] then
2142 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_PLAYER_NAME
], gStdFont
, 255, 127, 0, 1);
2143 e_TextureFontPrintEx(x
+8+w1
, _y
, _lc
[I_GAME_FRAGS
], gStdFont
, 255, 127, 0, 1);
2144 e_TextureFontPrintEx(x
+8+w1
+w2
, _y
, _lc
[I_GAME_DEATHS
], gStdFont
, 255, 127, 0, 1);
2147 for p
:= 0 to High(CustomStat
.PlayerStat
) do
2148 with CustomStat
.PlayerStat
[p
] do
2150 e_DrawFillQuad(x
+8, _y
+4, x
+24-1, _y
+16+4-1, Color
.R
, Color
.G
, Color
.B
, 0);
2157 e_TextureFontPrintEx(x
+8+16+8, _y
+4, Name
, gStdFont
, r
, r
, r
, 1, True);
2158 e_TextureFontPrintEx(x
+w1
+8+16+8, _y
+4, IntToStr(Frags
), gStdFont
, r
, r
, r
, 1, True);
2159 e_TextureFontPrintEx(x
+w1
+w2
+8+16+8, _y
+4, IntToStr(Deaths
), gStdFont
, r
, r
, r
, 1, True);
2165 procedure DrawSingleStat();
2167 tm
, key_x
, val_x
, y
: Integer;
2171 procedure player_stat(n
: Integer);
2177 s1
:= Format(' %d ', [SingleStat
.PlayerStat
[n
].Kills
]);
2178 s2
:= Format(' %d', [gTotalMonsters
]);
2180 e_CharFont_Print(gMenuFont
, key_x
, y
, _lc
[I_MENU_INTER_KILLS
]);
2181 e_CharFont_PrintEx(gMenuFont
, val_x
, y
, s1
, _RGB(255, 0, 0));
2182 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2183 e_CharFont_Print(gMenuFont
, val_x
+w1
, y
, '/');
2185 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2186 e_CharFont_PrintEx(gMenuFont
, val_x
+w1
, y
, s2
, _RGB(255, 0, 0));
2188 // "Kills-per-minute: ##.#":
2189 s1
:= _lc
[I_MENU_INTER_KPM
];
2191 kpm
:= (SingleStat
.PlayerStat
[n
].Kills
/ tm
) * 60
2193 kpm
:= SingleStat
.PlayerStat
[n
].Kills
;
2194 s2
:= Format(' %.1f', [kpm
]);
2196 e_CharFont_Print(gMenuFont
, key_x
, y
+32, s1
);
2197 e_CharFont_PrintEx(gMenuFont
, val_x
, y
+32, s2
, _RGB(255, 0, 0));
2199 // "Secrets found: # / #":
2200 s1
:= Format(' %d ', [SingleStat
.PlayerStat
[n
].Secrets
]);
2201 s2
:= Format(' %d', [SingleStat
.TotalSecrets
]);
2203 e_CharFont_Print(gMenuFont
, key_x
, y
+64, _lc
[I_MENU_INTER_SECRETS
]);
2204 e_CharFont_PrintEx(gMenuFont
, val_x
, y
+64, s1
, _RGB(255, 0, 0));
2205 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2206 e_CharFont_Print(gMenuFont
, val_x
+w1
, y
+64, '/');
2208 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2209 e_CharFont_PrintEx(gMenuFont
, val_x
+w1
, y
+64, s2
, _RGB(255, 0, 0));
2213 // "Level Complete":
2214 e_CharFont_GetSize(gMenuFont
, _lc
[I_MENU_INTER_LEVEL_COMPLETE
], w1
, h
);
2215 e_CharFont_Print(gMenuFont
, (gScreenWidth
-w1
) div 2, 32, _lc
[I_MENU_INTER_LEVEL_COMPLETE
]);
2217 // Îïðåäåëÿåì êîîðäèíàòû âûðàâíèâàíèÿ ïî ñàìîé äëèííîé ñòðîêå:
2218 s1
:= _lc
[I_MENU_INTER_KPM
];
2219 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2222 e_CharFont_GetSize(gMenuFont
, s1
, w2
, h
);
2224 key_x
:= (gScreenWidth
-w1
-w2
) div 2;
2225 val_x
:= key_x
+ w1
;
2228 tm
:= SingleStat
.GameTime
div 1000;
2229 s1
:= _lc
[I_MENU_INTER_TIME
];
2230 s2
:= Format(' %d:%.2d:%.2d', [tm
div (60*60), (tm
mod (60*60)) div 60, tm
mod 60]);
2232 e_CharFont_Print(gMenuFont
, key_x
, 80, s1
);
2233 e_CharFont_PrintEx(gMenuFont
, val_x
, 80, s2
, _RGB(255, 0, 0));
2235 if SingleStat
.TwoPlayers
then
2238 s1
:= _lc
[I_MENU_PLAYER_1
];
2239 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2240 e_CharFont_Print(gMenuFont
, (gScreenWidth
-w1
) div 2, 128, s1
);
2242 // Ñòàòèñòèêà ïåðâîãî èãðîêà:
2247 s1
:= _lc
[I_MENU_PLAYER_2
];
2248 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2249 e_CharFont_Print(gMenuFont
, (gScreenWidth
-w1
) div 2, 288, s1
);
2251 // Ñòàòèñòèêà âòîðîãî èãðîêà:
2257 // Ñòàòèñòèêà ïåðâîãî èãðîêà:
2263 procedure DrawLoadingStat();
2269 if Length(LoadingStat
.Msgs
) = 0 then
2272 e_CharFont_GetSize(gMenuFont
, _lc
[I_MENU_LOADING
], ww
, hh
);
2273 yy
:= (gScreenHeight
div 3);
2274 e_CharFont_Print(gMenuFont
, (gScreenWidth
div 2)-(ww
div 2), yy
-2*hh
, _lc
[I_MENU_LOADING
]);
2275 xx
:= (gScreenWidth
div 3);
2278 for i
:= 0 to NextMsg
-1 do
2280 if (i
= (NextMsg
-1)) and (MaxValue
> 0) then
2281 s
:= Format('%s: %d/%d', [Msgs
[i
], CurValue
, MaxValue
])
2285 e_CharFont_PrintEx(gMenuSmallFont
, xx
, yy
, s
, _RGB(255, 0, 0));
2286 yy
:= yy
+ LOADING_INTERLINE
;
2290 procedure DrawMinimap(p
: TPlayer
; RenderRect
: TRect
);
2292 a
, aX
, aY
, aX2
, aY2
, Scale
, ScaleSz
: Integer;
2294 if (gMapInfo
.Width
> RenderRect
.Right
- RenderRect
.Left
) or
2295 (gMapInfo
.Height
> RenderRect
.Bottom
- RenderRect
.Top
) then
2298 // Ñêîëüêî ïèêñåëîâ êàðòû â 1 ïèêñåëå ìèíè-êàðòû:
2299 ScaleSz
:= 16 div Scale
;
2300 // Ðàçìåðû ìèíè-êàðòû:
2301 aX
:= max(gMapInfo
.Width
div ScaleSz
, 1);
2302 aY
:= max(gMapInfo
.Height
div ScaleSz
, 1);
2304 e_DrawFillQuad(0, 0, aX
-1, aY
-1, 0, 0, 0, 0);
2306 if gWalls
<> nil then
2309 for a
:= 0 to High(gWalls
) do
2311 if PanelType
<> 0 then
2313 // Ëåâûé âåðõíèé óãîë:
2314 aX
:= X
div ScaleSz
;
2315 aY
:= Y
div ScaleSz
;
2317 aX2
:= max(Width
div ScaleSz
, 1);
2318 aY2
:= max(Height
div ScaleSz
, 1);
2319 // Ïðàâûé íèæíèé óãîë:
2320 aX2
:= aX
+ aX2
- 1;
2321 aY2
:= aY
+ aY2
- 1;
2324 PANEL_WALL
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 208, 208, 208, 0);
2325 PANEL_OPENDOOR
, PANEL_CLOSEDOOR
:
2326 if Enabled
then e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 160, 160, 160, 0);
2330 if gSteps
<> nil then
2333 for a
:= 0 to High(gSteps
) do
2335 if PanelType
<> 0 then
2337 // Ëåâûé âåðõíèé óãîë:
2338 aX
:= X
div ScaleSz
;
2339 aY
:= Y
div ScaleSz
;
2341 aX2
:= max(Width
div ScaleSz
, 1);
2342 aY2
:= max(Height
div ScaleSz
, 1);
2343 // Ïðàâûé íèæíèé óãîë:
2344 aX2
:= aX
+ aX2
- 1;
2345 aY2
:= aY
+ aY2
- 1;
2347 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 128, 128, 128, 0);
2350 if gLifts
<> nil then
2353 for a
:= 0 to High(gLifts
) do
2355 if PanelType
<> 0 then
2357 // Ëåâûé âåðõíèé óãîë:
2358 aX
:= X
div ScaleSz
;
2359 aY
:= Y
div ScaleSz
;
2361 aX2
:= max(Width
div ScaleSz
, 1);
2362 aY2
:= max(Height
div ScaleSz
, 1);
2363 // Ïðàâûé íèæíèé óãîë:
2364 aX2
:= aX
+ aX2
- 1;
2365 aY2
:= aY
+ aY2
- 1;
2368 0: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 116, 72, 36, 0);
2369 1: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 116, 124, 96, 0);
2370 2: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 200, 80, 4, 0);
2371 3: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 252, 140, 56, 0);
2375 if gWater
<> nil then
2378 for a
:= 0 to High(gWater
) do
2380 if PanelType
<> 0 then
2382 // Ëåâûé âåðõíèé óãîë:
2383 aX
:= X
div ScaleSz
;
2384 aY
:= Y
div ScaleSz
;
2386 aX2
:= max(Width
div ScaleSz
, 1);
2387 aY2
:= max(Height
div ScaleSz
, 1);
2388 // Ïðàâûé íèæíèé óãîë:
2389 aX2
:= aX
+ aX2
- 1;
2390 aY2
:= aY
+ aY2
- 1;
2392 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 0, 192, 0);
2395 if gAcid1
<> nil then
2397 // Ðèñóåì êèñëîòó 1:
2398 for a
:= 0 to High(gAcid1
) do
2400 if PanelType
<> 0 then
2402 // Ëåâûé âåðõíèé óãîë:
2403 aX
:= X
div ScaleSz
;
2404 aY
:= Y
div ScaleSz
;
2406 aX2
:= max(Width
div ScaleSz
, 1);
2407 aY2
:= max(Height
div ScaleSz
, 1);
2408 // Ïðàâûé íèæíèé óãîë:
2409 aX2
:= aX
+ aX2
- 1;
2410 aY2
:= aY
+ aY2
- 1;
2412 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 176, 0, 0);
2415 if gAcid2
<> nil then
2417 // Ðèñóåì êèñëîòó 2:
2418 for a
:= 0 to High(gAcid2
) do
2420 if PanelType
<> 0 then
2422 // Ëåâûé âåðõíèé óãîë:
2423 aX
:= X
div ScaleSz
;
2424 aY
:= Y
div ScaleSz
;
2426 aX2
:= max(Width
div ScaleSz
, 1);
2427 aY2
:= max(Height
div ScaleSz
, 1);
2428 // Ïðàâûé íèæíèé óãîë:
2429 aX2
:= aX
+ aX2
- 1;
2430 aY2
:= aY
+ aY2
- 1;
2432 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 176, 0, 0, 0);
2435 if gPlayers
<> nil then
2438 for a
:= 0 to High(gPlayers
) do
2439 if gPlayers
[a
] <> nil then with gPlayers
[a
] do
2441 // Ëåâûé âåðõíèé óãîë:
2442 aX
:= Obj
.X
div ScaleSz
+ 1;
2443 aY
:= Obj
.Y
div ScaleSz
+ 1;
2445 aX2
:= max(Obj
.Rect
.Width
div ScaleSz
, 1);
2446 aY2
:= max(Obj
.Rect
.Height
div ScaleSz
, 1);
2447 // Ïðàâûé íèæíèé óãîë:
2448 aX2
:= aX
+ aX2
- 1;
2449 aY2
:= aY
+ aY2
- 1;
2451 if gPlayers
[a
] = p
then
2452 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 255, 0, 0)
2455 TEAM_RED
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 0, 0, 0);
2456 TEAM_BLUE
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 0, 255, 0);
2457 else e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 128, 0, 0);
2461 if gMonsters
<> nil then
2464 for a
:= 0 to High(gMonsters
) do
2465 if gMonsters
[a
] <> nil then with gMonsters
[a
] do
2467 // Ëåâûé âåðõíèé óãîë:
2468 aX
:= Obj
.X
div ScaleSz
+ 1;
2469 aY
:= Obj
.Y
div ScaleSz
+ 1;
2471 aX2
:= max(Obj
.Rect
.Width
div ScaleSz
, 1);
2472 aY2
:= max(Obj
.Rect
.Height
div ScaleSz
, 1);
2473 // Ïðàâûé íèæíèé óãîë:
2474 aX2
:= aX
+ aX2
- 1;
2475 aY2
:= aY
+ aY2
- 1;
2477 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 255, 0, 0);
2483 procedure DrawMapView(x
, y
, w
, h
: Integer);
2489 bx
:= Round(x
/(gMapInfo
.Width
- w
)*(gBackSize
.X
- w
));
2490 by
:= Round(y
/(gMapInfo
.Height
- h
)*(gBackSize
.Y
- h
));
2491 g_Map_DrawBack(-bx
, -by
);
2498 glTranslatef(-x
, -y
, 0);
2500 g_Map_DrawPanels(PANEL_BACK
);
2501 g_Map_DrawPanels(PANEL_STEP
);
2504 g_Player_DrawShells();
2506 g_Player_DrawCorpses();
2507 g_Map_DrawPanels(PANEL_WALL
);
2509 g_Map_DrawPanels(PANEL_CLOSEDOOR
);
2512 g_Map_DrawPanels(PANEL_ACID1
);
2513 g_Map_DrawPanels(PANEL_ACID2
);
2514 g_Map_DrawPanels(PANEL_WATER
);
2515 g_Map_DrawPanels(PANEL_FORE
);
2516 if g_debug_HealthBar
then
2518 g_Monsters_DrawHealth();
2519 g_Player_DrawHealth();
2525 procedure DrawPlayer(p
: TPlayer
);
2527 px
, py
, a
, b
, c
, d
: Integer;
2530 if (p
= nil) or (p
.FDummy
) then
2533 g_Map_DrawBack(0, 0);
2542 px
:= p
.GameX
+ PLAYER_RECT_CX
;
2543 py
:= p
.GameY
+ PLAYER_RECT_CY
;
2545 if px
> (gPlayerScreenSize
.X
div 2) then
2546 a
:= -px
+ (gPlayerScreenSize
.X
div 2)
2549 if py
> (gPlayerScreenSize
.Y
div 2) then
2550 b
:= -py
+ (gPlayerScreenSize
.Y
div 2)
2553 if px
> (gMapInfo
.Width
- (gPlayerScreenSize
.X
div 2)) then
2554 a
:= -gMapInfo
.Width
+ gPlayerScreenSize
.X
;
2555 if py
> (gMapInfo
.Height
- (gPlayerScreenSize
.Y
div 2)) then
2556 b
:= -gMapInfo
.Height
+ gPlayerScreenSize
.Y
;
2557 if gMapInfo
.Width
<= gPlayerScreenSize
.X
then
2559 if gMapInfo
.Height
<= gPlayerScreenSize
.Y
then
2562 if p
.IncCam
<> 0 then
2564 if py
> (gMapInfo
.Height
- (gPlayerScreenSize
.Y
div 2)) then
2566 if p
.IncCam
> 120-(py
-(gMapInfo
.Height
-(gPlayerScreenSize
.Y
div 2))) then
2567 p
.IncCam
:= 120-(py
-(gMapInfo
.Height
-(gPlayerScreenSize
.Y
div 2)));
2570 if py
< (gPlayerScreenSize
.Y
div 2) then
2572 if p
.IncCam
< -120+((gPlayerScreenSize
.Y
div 2)-py
) then
2573 p
.IncCam
:= -120+((gPlayerScreenSize
.Y
div 2)-py
);
2576 if p
.IncCam
< 0 then
2577 while (py
+(gPlayerScreenSize
.Y
div 2)-p
.IncCam
> gMapInfo
.Height
) and
2579 p
.IncCam
:= p
.IncCam
+ 1;
2581 if p
.IncCam
> 0 then
2582 while (py
-(gPlayerScreenSize
.Y
div 2)-p
.IncCam
< 0) and
2584 p
.IncCam
:= p
.IncCam
- 1;
2587 if (px
< gPlayerScreenSize
.X
div 2) or
2588 (gMapInfo
.Width
-gPlayerScreenSize
.X
<= 256) then
2591 if (px
> gMapInfo
.Width
-(gPlayerScreenSize
.X
div 2)) then
2592 c
:= gBackSize
.X
- gPlayerScreenSize
.X
2594 c
:= Round((px
-(gPlayerScreenSize
.X
div 2))/(gMapInfo
.Width
-gPlayerScreenSize
.X
)*(gBackSize
.X
-gPlayerScreenSize
.X
));
2596 if (py
-p
.IncCam
<= gPlayerScreenSize
.Y
div 2) or
2597 (gMapInfo
.Height
-gPlayerScreenSize
.Y
<= 256) then
2600 if (py
-p
.IncCam
>= gMapInfo
.Height
-(gPlayerScreenSize
.Y
div 2)) then
2601 d
:= gBackSize
.Y
- gPlayerScreenSize
.Y
2603 d
:= Round((py
-p
.IncCam
-(gPlayerScreenSize
.Y
div 2))/(gMapInfo
.Height
-gPlayerScreenSize
.Y
)*(gBackSize
.Y
-gPlayerScreenSize
.Y
));
2605 g_Map_DrawBack(-c
, -d
);
2608 sY
:= -(b
+p
.IncCam
);
2609 sWidth
:= gPlayerScreenSize
.X
;
2610 sHeight
:= gPlayerScreenSize
.Y
;
2612 glTranslatef(a
, b
+p
.IncCam
, 0);
2614 g_Map_DrawPanels(PANEL_BACK
);
2615 g_Map_DrawPanels(PANEL_STEP
);
2618 g_Player_DrawShells();
2620 g_Player_DrawCorpses();
2621 g_Map_DrawPanels(PANEL_WALL
);
2623 g_Map_DrawPanels(PANEL_CLOSEDOOR
);
2626 g_Map_DrawPanels(PANEL_ACID1
);
2627 g_Map_DrawPanels(PANEL_ACID2
);
2628 g_Map_DrawPanels(PANEL_WATER
);
2629 g_Map_DrawPanels(PANEL_FORE
);
2630 if g_debug_HealthBar
then
2632 g_Monsters_DrawHealth();
2633 g_Player_DrawHealth();
2636 if p
.FSpectator
then
2637 e_TextureFontPrintEx(p
.GameX
+ PLAYER_RECT_CX
- 4,
2638 p
.GameY
+ PLAYER_RECT_CY
- 4,
2639 'X', gStdFont
, 255, 255, 255, 1, True);
2641 for a := 0 to High(gCollideMap) do
2642 for b := 0 to High(gCollideMap[a]) do
2645 if ByteBool(gCollideMap[a, b] and MARK_WALL) then
2647 if ByteBool(gCollideMap[a, b] and MARK_DOOR) then
2651 1: e_DrawPoint(1, b, a, 200, 200, 200);
2652 2: e_DrawPoint(1, b, a, 64, 64, 255);
2653 3: e_DrawPoint(1, b, a, 255, 0, 255);
2664 //DrawMinimap(p, _TRect(0, 0, 128, 128));
2665 if g_Debug_Player
then
2666 g_Player_DrawDebug(p
);
2670 procedure g_Game_Draw();
2677 plView1
, plView2
: TPlayer
;
2680 if gExit
= EXIT_QUIT
then Exit
;
2682 Time
:= GetTimer() div 1000;
2683 FPSCounter
:= FPSCounter
+1;
2684 if Time
- FPSTime
>= 1000 then
2691 if gGameOn
or (gState
= STATE_FOLD
) then
2693 if (gPlayer1
<> nil) and (gPlayer2
<> nil) then
2695 gSpectMode
:= SPECT_NONE
;
2696 if not gRevertPlayers
then
2698 plView1
:= gPlayer1
;
2699 plView2
:= gPlayer2
;
2703 plView1
:= gPlayer2
;
2704 plView2
:= gPlayer1
;
2708 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
2710 gSpectMode
:= SPECT_NONE
;
2711 if gPlayer2
= nil then
2714 plView1
:= gPlayer2
;
2723 if (plView1
= nil) and (plView2
= nil) and (gSpectMode
= SPECT_NONE
) then
2724 gSpectMode
:= SPECT_STATS
;
2726 if gSpectMode
= SPECT_PLAYERS
then
2727 if gPlayers
<> nil then
2729 plView1
:= GetActivePlayer_ByID(gSpectPID1
);
2730 if plView1
= nil then
2732 gSpectPID1
:= GetActivePlayerID_Next();
2733 plView1
:= GetActivePlayer_ByID(gSpectPID1
);
2735 if gSpectViewTwo
then
2737 plView2
:= GetActivePlayer_ByID(gSpectPID2
);
2738 if plView2
= nil then
2740 gSpectPID2
:= GetActivePlayerID_Next();
2741 plView2
:= GetActivePlayer_ByID(gSpectPID2
);
2746 if gSpectMode
= SPECT_MAPVIEW
then
2748 // Ðåæèì ïðîñìîòðà êàðòû
2750 e_SetViewPort(0, 0, gScreenWidth
, gScreenHeight
);
2751 DrawMapView(gSpectX
, gSpectY
, gScreenWidth
, gScreenHeight
);
2752 gHearPoint1
.Active
:= True;
2753 gHearPoint1
.Coords
.X
:= gScreenWidth
div 2 + gSpectX
;
2754 gHearPoint1
.Coords
.Y
:= gScreenHeight
div 2 + gSpectY
;
2755 gHearPoint2
.Active
:= False;
2759 Split
:= (plView1
<> nil) and (plView2
<> nil);
2761 // Òî÷êè ñëóõà èãðîêîâ
2762 if plView1
<> nil then
2764 gHearPoint1
.Active
:= True;
2765 gHearPoint1
.Coords
.X
:= plView1
.GameX
;
2766 gHearPoint1
.Coords
.Y
:= plView1
.GameY
;
2768 gHearPoint1
.Active
:= False;
2769 if plView2
<> nil then
2771 gHearPoint2
.Active
:= True;
2772 gHearPoint2
.Coords
.X
:= plView2
.GameX
;
2773 gHearPoint2
.Coords
.Y
:= plView2
.GameY
;
2775 gHearPoint2
.Active
:= False;
2777 // Ðàçìåð ýêðàíîâ èãðîêîâ:
2778 gPlayerScreenSize
.X
:= gScreenWidth
-196;
2781 gPlayerScreenSize
.Y
:= gScreenHeight
div 2;
2782 if gScreenHeight
mod 2 = 0 then
2783 Dec(gPlayerScreenSize
.Y
);
2786 gPlayerScreenSize
.Y
:= gScreenHeight
;
2789 if gScreenHeight
mod 2 = 0 then
2790 e_SetViewPort(0, gPlayerScreenSize
.Y
+2, gPlayerScreenSize
.X
+196, gPlayerScreenSize
.Y
)
2792 e_SetViewPort(0, gPlayerScreenSize
.Y
+1, gPlayerScreenSize
.X
+196, gPlayerScreenSize
.Y
);
2794 DrawPlayer(plView1
);
2795 gPlayer1ScreenCoord
.X
:= sX
;
2796 gPlayer1ScreenCoord
.Y
:= sY
;
2800 e_SetViewPort(0, 0, gPlayerScreenSize
.X
+196, gPlayerScreenSize
.Y
);
2802 DrawPlayer(plView2
);
2803 gPlayer2ScreenCoord
.X
:= sX
;
2804 gPlayer2ScreenCoord
.Y
:= sY
;
2807 e_SetViewPort(0, 0, gScreenWidth
, gScreenHeight
);
2810 e_DrawLine(2, 0, gScreenHeight
div 2, gScreenWidth
, gScreenHeight
div 2, 0, 0, 0);
2813 if MessageText
<> '' then
2817 e_CharFont_GetSizeFmt(gMenuFont
, MessageText
, w
, h
);
2819 e_CharFont_PrintFmt(gMenuFont
, (gScreenWidth
div 2)-(w
div 2),
2820 (gScreenHeight
div 2)-(h
div 2), MessageText
)
2822 e_CharFont_PrintFmt(gMenuFont
, (gScreenWidth
div 2)-(w
div 2),
2823 Round(gScreenHeight
/ 2.75)-(h
div 2), MessageText
);
2826 if IsDrawStat
or (gSpectMode
= 1) then DrawStat();
2828 if gSpectHUD
and (not gChatShow
) and (gSpectMode
<> SPECT_NONE
) then
2830 // Draw spectator GUI
2833 e_TextureFontGetSize(gStdFont
, ww
, hh
);
2836 e_TextureFontPrintEx(0, gScreenHeight
- (hh
+2)*2, 'MODE: Stats', gStdFont
, 255, 255, 255, 1);
2838 e_TextureFontPrintEx(0, gScreenHeight
- (hh
+2)*2, 'MODE: Observe Map', gStdFont
, 255, 255, 255, 1);
2840 e_TextureFontPrintEx(0, gScreenHeight
- (hh
+2)*2, 'MODE: Watch Players', gStdFont
, 255, 255, 255, 1);
2842 e_TextureFontPrintEx(2*ww
, gScreenHeight
- (hh
+2), '< jump >', gStdFont
, 255, 255, 255, 1);
2843 if gSpectMode
= SPECT_MAPVIEW
then
2845 e_TextureFontPrintEx(22*ww
, gScreenHeight
- (hh
+2)*2, '[-]', gStdFont
, 255, 255, 255, 1);
2846 e_TextureFontPrintEx(26*ww
, gScreenHeight
- (hh
+2)*2, 'Step ' + IntToStr(gSpectStep
), gStdFont
, 255, 255, 255, 1);
2847 e_TextureFontPrintEx(34*ww
, gScreenHeight
- (hh
+2)*2, '[+]', gStdFont
, 255, 255, 255, 1);
2848 e_TextureFontPrintEx(18*ww
, gScreenHeight
- (hh
+2), '<prev weap>', gStdFont
, 255, 255, 255, 1);
2849 e_TextureFontPrintEx(30*ww
, gScreenHeight
- (hh
+2), '<next weap>', gStdFont
, 255, 255, 255, 1);
2851 if gSpectMode
= SPECT_PLAYERS
then
2853 e_TextureFontPrintEx(22*ww
, gScreenHeight
- (hh
+2)*2, 'Player 1', gStdFont
, 255, 255, 255, 1);
2854 e_TextureFontPrintEx(20*ww
, gScreenHeight
- (hh
+2), '<left/right>', gStdFont
, 255, 255, 255, 1);
2855 if gSpectViewTwo
then
2857 e_TextureFontPrintEx(37*ww
, gScreenHeight
- (hh
+2)*2, 'Player 2', gStdFont
, 255, 255, 255, 1);
2858 e_TextureFontPrintEx(34*ww
, gScreenHeight
- (hh
+2), '<prev w/next w>', gStdFont
, 255, 255, 255, 1);
2859 e_TextureFontPrintEx(52*ww
, gScreenHeight
- (hh
+2)*2, '2x View', gStdFont
, 255, 255, 255, 1);
2860 e_TextureFontPrintEx(51*ww
, gScreenHeight
- (hh
+2), '<up/down>', gStdFont
, 255, 255, 255, 1);
2864 e_TextureFontPrintEx(35*ww
, gScreenHeight
- (hh
+2)*2, '2x View', gStdFont
, 255, 255, 255, 1);
2865 e_TextureFontPrintEx(34*ww
, gScreenHeight
- (hh
+2), '<up/down>', gStdFont
, 255, 255, 255, 1);
2871 if gPause
and gGameOn
and (g_ActiveWindow
= nil) then
2873 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 48, 48, 48, 180);
2875 e_CharFont_GetSize(gMenuFont
, _lc
[I_MENU_PAUSE
], w
, h
);
2876 e_CharFont_Print(gMenuFont
, (gScreenWidth
div 2)-(w
div 2),
2877 (gScreenHeight
div 2)-(h
div 2), _lc
[I_MENU_PAUSE
]);
2882 if (gState
= STATE_MENU
) then
2884 if ((g_ActiveWindow
= nil) or (g_ActiveWindow
.BackTexture
= '')) then
2886 if g_Texture_Get('MENU_BACKGROUND', ID
) then
2887 e_DrawSize(ID
, 0, 0, 0, False, False, gScreenWidth
, gScreenHeight
)
2888 else e_Clear(GL_COLOR_BUFFER_BIT
, 0, 0, 0);
2890 if g_ActiveWindow
<> nil then
2891 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 48, 48, 48, 180);
2894 if gState
= STATE_FOLD
then
2895 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 0, 0, 0, EndingGameCounter
);
2897 if gState
= STATE_INTERCUSTOM
then
2899 if gLastMap
and (gGameSettings
.GameMode
= GM_COOP
) then
2901 back
:= 'TEXTURE_endpic';
2902 if not g_Texture_Get(back
, ID
) then
2903 back
:= _lc
[I_TEXTURE_ENDPIC
];
2908 if g_Texture_Get(back
, ID
) then
2909 e_DrawSize(ID
, 0, 0, 0, False, False, gScreenWidth
, gScreenHeight
)
2911 e_Clear(GL_COLOR_BUFFER_BIT
, 0, 0, 0);
2915 if g_ActiveWindow
<> nil then
2916 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 48, 48, 48, 180);
2919 if gState
= STATE_INTERSINGLE
then
2921 if EndingGameCounter
> 0 then
2922 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 0, 0, 0, EndingGameCounter
)
2927 if g_Texture_Get(back
, ID
) then
2928 e_DrawSize(ID
, 0, 0, 0, False, False, gScreenWidth
, gScreenHeight
)
2930 e_Clear(GL_COLOR_BUFFER_BIT
, 0, 0, 0);
2934 if g_ActiveWindow
<> nil then
2935 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 48, 48, 48, 180);
2939 if gState
= STATE_ENDPIC
then
2942 if not g_Texture_Get('TEXTURE_endpic', ID
) then
2943 g_Texture_Get(_lc
[I_TEXTURE_ENDPIC
], ID
);
2945 if ID
<> DWORD(-1) then
2946 e_DrawSize(ID
, 0, 0, 0, False, False, gScreenWidth
, gScreenHeight
)
2948 e_Clear(GL_COLOR_BUFFER_BIT
, 0, 0, 0);
2950 if g_ActiveWindow
<> nil then
2951 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 48, 48, 48, 180);
2954 if gState
= STATE_SLIST
then
2956 if g_Texture_Get('MENU_BACKGROUND', ID
) then
2958 e_DrawSize(ID
, 0, 0, 0, False, False, gScreenWidth
, gScreenHeight
);
2959 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 48, 48, 48, 180);
2961 g_Serverlist_Draw(slCurrent
);
2965 if g_ActiveWindow
<> nil then
2968 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 48, 48, 48, 180);
2969 g_ActiveWindow
.Draw();
2974 if g_debug_Sounds
and gGameOn
then
2976 for w
:= 0 to High(e_SoundsArray
) do
2977 for h
:= 0 to e_SoundsArray
[w
].nRefs
do
2978 e_DrawPoint(1, w
+100, h
+100, 255, 0, 0);
2983 e_TextureFontPrint(0, 0, Format('FPS: %d', [FPS
]), gStdFont
);
2984 e_TextureFontPrint(0, 16, Format('UPS: %d', [UPS
]), gStdFont
);
2987 if gGameOn
and gShowTime
and (gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
]) then
2988 e_TextureFontPrint(gScreenWidth
-72, 0,
2989 Format('%d:%.2d:%.2d', [gTime
div 1000 div 3600, (gTime
div 1000 div 60) mod 60, gTime
div 1000 mod 60]),
2993 procedure g_Game_Quit();
2995 g_Game_StopAllSounds(True);
2997 g_Game_SaveOptions();
2999 g_PlayerModel_FreeData();
3000 g_Texture_DeleteAll();
3001 g_Frames_DeleteAll();
3004 if NetInitDone
then g_Net_Free
;
3006 // Íàäî óäàëèòü êàðòó ïîñëå òåñòà:
3007 if gMapToDelete
<> '' then
3008 g_Game_DeleteTestMap();
3014 procedure g_FatalError(Text: String);
3016 g_Console_Add(Format(_lc
[I_FATAL_ERROR
], [Text]), True);
3017 e_WriteLog(Format(_lc
[I_FATAL_ERROR
], [Text]), MSG_WARNING
);
3019 gExit
:= EXIT_SIMPLE
;
3022 procedure g_SimpleError(Text: String);
3024 g_Console_Add(Format(_lc
[I_SIMPLE_ERROR
], [Text]), True);
3025 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], [Text]), MSG_WARNING
);
3028 procedure g_Game_SetupScreenSize();
3032 // Ðàçìåð ýêðàíîâ èãðîêîâ:
3033 gPlayerScreenSize
.X
:= gScreenWidth
-196;
3034 if (gPlayer1
<> nil) and (gPlayer2
<> nil) then
3035 gPlayerScreenSize
.Y
:= gScreenHeight
div 2
3037 gPlayerScreenSize
.Y
:= gScreenHeight
;
3039 // Ðàçìåð çàäíåãî ïëàíà:
3040 if BackID
<> DWORD(-1) then
3044 if (gScreenWidth
*d
> gMapInfo
.Width
) or
3045 (gScreenHeight
*d
> gMapInfo
.Height
) then
3048 gBackSize
.X
:= Round(gScreenWidth
*d
);
3049 gBackSize
.Y
:= Round(gScreenHeight
*d
);
3053 procedure g_Game_ChangeResolution(newWidth
, newHeight
: Word; nowFull
, nowMax
: Boolean);
3055 g_Window_SetSize(newWidth
, newHeight
, nowFull
);
3058 procedure g_Game_AddPlayer(Team
: Byte = TEAM_NONE
);
3060 if ((not gGameOn
) and (gState
<> STATE_INTERCUSTOM
))
3061 or (not (gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
])) then
3063 if gPlayer1
= nil then
3065 if g_Game_IsClient
then
3067 if NetPlrUID1
> -1 then
3069 MC_SEND_CheatRequest(NET_CHEAT_SPECTATE
);
3070 gPlayer1
:= g_Player_Get(NetPlrUID1
);
3075 if not (Team
in [TEAM_RED
, TEAM_BLUE
]) then
3076 Team
:= gPlayer1Settings
.Team
;
3078 // Ñîçäàíèå ïåðâîãî èãðîêà:
3079 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
3080 gPlayer1Settings
.Color
,
3082 if gPlayer1
= nil then
3083 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]))
3086 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
3087 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [gPlayer1
.Name
]), True);
3088 if g_Game_IsServer
and g_Game_IsNet
then
3089 MH_SEND_PlayerCreate(gPlayer1
.UID
);
3090 gPlayer1
.Respawn(False, True);
3092 if g_Game_IsNet
and NetUseMaster
then
3098 if gPlayer2
= nil then
3100 if g_Game_IsClient
then
3102 if NetPlrUID2
> -1 then
3103 gPlayer2
:= g_Player_Get(NetPlrUID2
);
3107 if not (Team
in [TEAM_RED
, TEAM_BLUE
]) then
3108 Team
:= gPlayer2Settings
.Team
;
3110 // Ñîçäàíèå âòîðîãî èãðîêà:
3111 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
3112 gPlayer2Settings
.Color
,
3114 if gPlayer2
= nil then
3115 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]))
3118 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
3119 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [gPlayer2
.Name
]), True);
3120 if g_Game_IsServer
and g_Game_IsNet
then
3121 MH_SEND_PlayerCreate(gPlayer2
.UID
);
3122 gPlayer2
.Respawn(False, True);
3124 if g_Game_IsNet
and NetUseMaster
then
3132 procedure g_Game_RemovePlayer();
3136 if ((not gGameOn
) and (gState
<> STATE_INTERCUSTOM
))
3137 or (not (gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
])) then
3142 if g_Game_IsServer
then
3145 Pl
.Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
3146 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [Pl
.Name
]), True);
3147 g_Player_Remove(Pl
.UID
);
3149 if g_Game_IsNet
and NetUseMaster
then
3158 if g_Game_IsServer
then
3161 Pl
.Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
3162 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [Pl
.Name
]), True);
3163 g_Player_Remove(Pl
.UID
);
3165 if g_Game_IsNet
and NetUseMaster
then
3170 MC_SEND_CheatRequest(NET_CHEAT_SPECTATE
);
3176 procedure g_Game_Spectate();
3178 g_Game_RemovePlayer();
3179 if gPlayer1
<> nil then
3180 g_Game_RemovePlayer();
3183 procedure g_Game_SpectateCenterView();
3185 gSpectX
:= Max(gMapInfo
.Width
div 2 - gScreenWidth
div 2, 0);
3186 gSpectY
:= Max(gMapInfo
.Height
div 2 - gScreenHeight
div 2, 0);
3189 procedure g_Game_StartSingle(Map
: String; TwoPlayers
: Boolean; nPlayers
: Byte);
3195 e_WriteLog('Starting singleplayer game...', MSG_NOTIFY
);
3197 g_Game_ClearLoading();
3200 FillByte(gGameSettings
, SizeOf(TGameSettings
), 0);
3203 gGameSettings
.GameType
:= GT_SINGLE
;
3204 gGameSettings
.MaxLives
:= 0;
3205 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_ALLOWEXIT
;
3206 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_MONSTERS
;
3207 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_BOTVSMONSTER
;
3208 gSwitchGameMode
:= GM_SINGLE
;
3210 g_Game_ExecuteEvent('ongamestart');
3212 // Óñòàíîâêà ðàçìåðîâ îêîí èãðîêîâ:
3213 g_Game_SetupScreenSize();
3215 // Ñîçäàíèå ïåðâîãî èãðîêà:
3216 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
3217 gPlayer1Settings
.Color
,
3218 gPlayer1Settings
.Team
, False));
3219 if gPlayer1
= nil then
3221 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
3225 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
3228 // Ñîçäàíèå âòîðîãî èãðîêà, åñëè åñòü:
3231 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
3232 gPlayer2Settings
.Color
,
3233 gPlayer2Settings
.Team
, False));
3234 if gPlayer2
= nil then
3236 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
3240 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
3244 // Çàãðóçêà è çàïóñê êàðòû:
3245 if not g_Game_StartMap(MAP
, True) then
3247 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [gGameSettings
.WAD
+ ':\' + MAP
]));
3251 // Íàñòðîéêè èãðîêîâ è áîòîâ:
3255 for i
:= nPl
+1 to nPlayers
do
3256 g_Player_Create(STD_PLAYER_MODEL
, _RGB(0, 0, 0), 0, True);
3259 procedure g_Game_StartCustom(Map
: String; GameMode
: Byte;
3260 TimeLimit
, GoalLimit
: Word;
3262 Options
: LongWord; nPlayers
: Byte);
3268 e_WriteLog('Starting custom game...', MSG_NOTIFY
);
3270 g_Game_ClearLoading();
3273 gGameSettings
.GameType
:= GT_CUSTOM
;
3274 gGameSettings
.GameMode
:= GameMode
;
3275 gSwitchGameMode
:= GameMode
;
3276 gGameSettings
.TimeLimit
:= TimeLimit
;
3277 gGameSettings
.GoalLimit
:= GoalLimit
;
3278 gGameSettings
.MaxLives
:= IfThen(GameMode
= GM_CTF
, 0, MaxLives
);
3279 gGameSettings
.Options
:= Options
;
3281 gCoopTotalMonstersKilled
:= 0;
3282 gCoopTotalSecretsFound
:= 0;
3283 gCoopTotalMonsters
:= 0;
3284 gCoopTotalSecrets
:= 0;
3288 g_Game_ExecuteEvent('ongamestart');
3290 // Óñòàíîâêà ðàçìåðîâ îêîí èãðîêîâ:
3291 g_Game_SetupScreenSize();
3293 // Ðåæèì íàáëþäàòåëÿ:
3294 if nPlayers
= 0 then
3301 if nPlayers
>= 1 then
3303 // Ñîçäàíèå ïåðâîãî èãðîêà:
3304 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
3305 gPlayer1Settings
.Color
,
3306 gPlayer1Settings
.Team
, False));
3307 if gPlayer1
= nil then
3309 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
3313 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
3317 if nPlayers
>= 2 then
3319 // Ñîçäàíèå âòîðîãî èãðîêà:
3320 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
3321 gPlayer2Settings
.Color
,
3322 gPlayer2Settings
.Team
, False));
3323 if gPlayer2
= nil then
3325 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
3329 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
3333 // Çàãðóçêà è çàïóñê êàðòû:
3334 if not g_Game_StartMap(Map
, True) then
3336 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [Map
]));
3340 // Íåò òî÷åê ïîÿâëåíèÿ:
3341 if (g_Map_GetPointCount(RESPAWNPOINT_PLAYER1
) +
3342 g_Map_GetPointCount(RESPAWNPOINT_PLAYER2
) +
3343 g_Map_GetPointCount(RESPAWNPOINT_DM
) +
3344 g_Map_GetPointCount(RESPAWNPOINT_RED
)+
3345 g_Map_GetPointCount(RESPAWNPOINT_BLUE
)) < 1 then
3347 g_FatalError(_lc
[I_GAME_ERROR_GET_SPAWN
]);
3351 // Íàñòðîéêè èãðîêîâ è áîòîâ:
3355 for i
:= nPl
+1 to nPlayers
do
3356 g_Player_Create(STD_PLAYER_MODEL
, _RGB(0, 0, 0), 0, True);
3359 procedure g_Game_StartServer(Map
: String; GameMode
: Byte;
3360 TimeLimit
, GoalLimit
: Word; MaxLives
: Byte;
3361 Options
: LongWord; nPlayers
: Byte;
3362 IPAddr
: LongWord; Port
: Word);
3366 e_WriteLog('Starting net game (server)...', MSG_NOTIFY
);
3368 g_Game_ClearLoading();
3371 gGameSettings
.GameType
:= GT_SERVER
;
3372 gGameSettings
.GameMode
:= GameMode
;
3373 gSwitchGameMode
:= GameMode
;
3374 gGameSettings
.TimeLimit
:= TimeLimit
;
3375 gGameSettings
.GoalLimit
:= GoalLimit
;
3376 gGameSettings
.MaxLives
:= IfThen(GameMode
= GM_CTF
, 0, MaxLives
);
3377 gGameSettings
.Options
:= Options
;
3379 gCoopTotalMonstersKilled
:= 0;
3380 gCoopTotalSecretsFound
:= 0;
3381 gCoopTotalMonsters
:= 0;
3382 gCoopTotalSecrets
:= 0;
3386 g_Game_ExecuteEvent('ongamestart');
3388 // Óñòàíîâêà ðàçìåðîâ îêíà èãðîêà
3389 g_Game_SetupScreenSize();
3391 // Ðåæèì íàáëþäàòåëÿ:
3392 if nPlayers
= 0 then
3398 if nPlayers
>= 1 then
3400 // Ñîçäàíèå ïåðâîãî èãðîêà:
3401 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
3402 gPlayer1Settings
.Color
,
3403 gPlayer1Settings
.Team
, False));
3404 if gPlayer1
= nil then
3406 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
3410 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
3413 if nPlayers
>= 2 then
3415 // Ñîçäàíèå âòîðîãî èãðîêà:
3416 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
3417 gPlayer2Settings
.Color
,
3418 gPlayer2Settings
.Team
, False));
3419 if gPlayer2
= nil then
3421 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
3425 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
3429 if not g_Net_Host(IPAddr
, Port
, NetMaxClients
) then
3431 g_FatalError(_lc
[I_NET_MSG
] + _lc
[I_NET_ERR_HOST
]);
3435 g_Net_Slist_Set(NetSlistIP
, NetSlistPort
);
3437 // Çàãðóçêà è çàïóñê êàðòû:
3438 if not g_Game_StartMap(Map
, True) then
3440 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [Map
]));
3444 // Íåò òî÷åê ïîÿâëåíèÿ:
3445 if (g_Map_GetPointCount(RESPAWNPOINT_PLAYER1
) +
3446 g_Map_GetPointCount(RESPAWNPOINT_PLAYER2
) +
3447 g_Map_GetPointCount(RESPAWNPOINT_DM
) +
3448 g_Map_GetPointCount(RESPAWNPOINT_RED
)+
3449 g_Map_GetPointCount(RESPAWNPOINT_BLUE
)) < 1 then
3451 g_FatalError(_lc
[I_GAME_ERROR_GET_SPAWN
]);
3455 // Íàñòðîéêè èãðîêîâ è áîòîâ:
3458 NetState
:= NET_STATE_GAME
;
3461 procedure g_Game_StartClient(Addr
: String; Port
: Word; PW
: String);
3475 e_WriteLog('Starting net game (client)...', MSG_NOTIFY
);
3476 e_WriteLog('NET: Trying to connect to ' + Addr
+ ':' + IntToStr(Port
) + '...', MSG_NOTIFY
);
3478 g_Game_ClearLoading();
3481 gGameSettings
.GameType
:= GT_CLIENT
;
3483 gCoopTotalMonstersKilled
:= 0;
3484 gCoopTotalSecretsFound
:= 0;
3485 gCoopTotalMonsters
:= 0;
3486 gCoopTotalSecrets
:= 0;
3490 g_Game_ExecuteEvent('ongamestart');
3492 // Óñòàíîâêà ðàçìåðîâ îêîí èãðîêîâ:
3493 g_Game_SetupScreenSize();
3495 NetState
:= NET_STATE_AUTH
;
3497 g_Game_SetLoadingText(_lc
[I_LOAD_CONNECT
], 0, False);
3499 if not g_Net_Connect(Addr
, Port
) then
3501 g_FatalError(_lc
[I_NET_MSG
] + _lc
[I_NET_ERR_CONN
]);
3502 NetState
:= NET_STATE_NONE
;
3506 g_Game_SetLoadingText(_lc
[I_LOAD_SEND_INFO
], 0, False);
3508 g_Game_SetLoadingText(_lc
[I_LOAD_WAIT_INFO
], 0, False);
3513 while (enet_host_service(NetHost
, @NetEvent
, 0) > 0) do
3515 if (NetEvent
.kind
= ENET_EVENT_TYPE_RECEIVE
) then
3517 Ptr
:= NetEvent
.packet
^.data
;
3520 MID
:= e_Raw_Read_Byte(Ptr
);
3522 if (MID
= NET_MSG_INFO
) and (State
= 0) then
3524 NetMyID
:= e_Raw_Read_Byte(Ptr
);
3525 NetPlrUID1
:= e_Raw_Read_Word(Ptr
);
3527 WadName
:= e_Raw_Read_String(Ptr
);
3528 Map
:= e_Raw_Read_String(Ptr
);
3530 gWADHash
:= e_Raw_Read_MD5(Ptr
);
3532 gGameSettings
.GameMode
:= e_Raw_Read_Byte(Ptr
);
3533 gSwitchGameMode
:= gGameSettings
.GameMode
;
3534 gGameSettings
.GoalLimit
:= e_Raw_Read_Word(Ptr
);
3535 gGameSettings
.TimeLimit
:= e_Raw_Read_Word(Ptr
);
3536 gGameSettings
.MaxLives
:= e_Raw_Read_Byte(Ptr
);
3537 gGameSettings
.Options
:= e_Raw_Read_LongWord(Ptr
);
3538 T
:= e_Raw_Read_LongWord(Ptr
);
3540 newResPath
:= g_Res_SearchSameWAD(MapsDir
, WadName
, gWADHash
);
3541 if newResPath
= '' then
3543 g_Game_SetLoadingText(_lc
[I_LOAD_DL_RES
], 0, False);
3544 newResPath
:= g_Res_DownloadWAD(WadName
);
3545 if newResPath
= '' then
3547 g_FatalError(_lc
[I_NET_ERR_HASH
]);
3548 enet_packet_destroy(NetEvent
.packet
);
3549 NetState
:= NET_STATE_NONE
;
3553 newResPath
:= ExtractRelativePath(MapsDir
, newResPath
);
3555 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
3556 gPlayer1Settings
.Color
,
3557 gPlayer1Settings
.Team
, False));
3559 if gPlayer1
= nil then
3561 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
3563 enet_packet_destroy(NetEvent
.packet
);
3564 NetState
:= NET_STATE_NONE
;
3568 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
3569 gPlayer1
.UID
:= NetPlrUID1
;
3570 gPlayer1
.Reset(True);
3572 if not g_Game_StartMap(newResPath
+ ':\' + Map
, True) then
3574 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [WadName
+ ':\' + Map
]));
3576 enet_packet_destroy(NetEvent
.packet
);
3577 NetState
:= NET_STATE_NONE
;
3585 enet_packet_destroy(NetEvent
.packet
);
3589 enet_packet_destroy(NetEvent
.packet
);
3592 if (NetEvent
.kind
= ENET_EVENT_TYPE_DISCONNECT
) then
3595 if (NetEvent
.data
<= NET_DISC_MAX
) then
3596 g_Console_Add(_lc
[I_NET_MSG_ERROR
] + _lc
[I_NET_ERR_CONN
] + ' ' +
3597 _lc
[TStrings_Locale(Cardinal(I_NET_DISC_NONE
) + NetEvent
.data
)], True);
3607 if e_KeyPressed(IK_ESCAPE
) or e_KeyPressed(IK_SPACE
) then
3616 g_FatalError(_lc
[I_NET_MSG
] + _lc
[I_NET_ERR_CONN
]);
3617 NetState
:= NET_STATE_NONE
;
3621 gLMSRespawn
:= LMS_RESPAWN_NONE
;
3622 gLMSRespawnTime
:= 0;
3625 NetState
:= NET_STATE_GAME
;
3626 MC_SEND_FullStateRequest
;
3627 e_WriteLog('NET: Connection successful.', MSG_NOTIFY
);
3630 procedure g_Game_SaveOptions();
3632 g_Options_Write_Video(GameDir
+'/'+CONFIG_FILENAME
);
3635 procedure g_Game_ChangeMap(MapPath
: String);
3639 g_Game_ClearLoading();
3641 Force
:= gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
];
3642 // Åñëè óðîâåíü çàâåðøèëñÿ ïî òðèããåðó Âûõîä, íå î÷èùàòü èíâåíòàðü
3643 if gExitByTrigger
then
3646 gExitByTrigger
:= False;
3648 if not g_Game_StartMap(MapPath
, Force
) then
3649 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [MapPath
]));
3652 procedure g_Game_Restart();
3656 if g_Game_IsClient
then
3658 g_ProcessResourceStr(gMapInfo
.Map
, nil, nil, @Map
);
3662 g_Game_ClearLoading();
3663 g_Game_StartMap(Map
, True);
3666 function g_Game_StartMap(Map
: String; Force
: Boolean = False): Boolean;
3668 NewWAD
, ResName
: String;
3672 g_Player_RemoveAllCorpses();
3674 if (not g_Game_IsClient
) and
3675 (gSwitchGameMode
<> gGameSettings
.GameMode
) and
3676 (gGameSettings
.GameMode
<> GM_SINGLE
) then
3678 if gSwitchGameMode
= GM_CTF
then
3679 gGameSettings
.MaxLives
:= 0;
3680 gGameSettings
.GameMode
:= gSwitchGameMode
;
3683 gSwitchGameMode
:= gGameSettings
.GameMode
;
3685 g_Player_ResetTeams();
3687 if Pos(':\', Map
) > 0 then
3689 g_ProcessResourceStr(Map
, @NewWAD
, nil, @ResName
);
3690 if g_Game_IsServer
then
3692 gWADHash
:= MD5File(MapsDir
+ NewWAD
);
3693 g_Game_LoadWAD(NewWAD
);
3695 // hash recieved in MC_RECV_GameEvent -> NET_EV_MAPSTART
3696 g_Game_ClientWAD(NewWAD
, gWADHash
);
3700 Result
:= g_Map_Load(MapsDir
+ gGameSettings
.WAD
+ ':\' + ResName
);
3703 g_Player_ResetAll(Force
or gLastMap
, gGameSettings
.GameType
= GT_SINGLE
);
3705 gState
:= STATE_NONE
;
3706 g_ActiveWindow
:= nil;
3712 if gGameSettings
.GameMode
= GM_CTF
then
3714 g_Map_ResetFlag(FLAG_RED
);
3715 g_Map_ResetFlag(FLAG_BLUE
);
3716 // CTF, à ôëàãîâ íåò:
3717 if not g_Map_HaveFlagPoints() then
3718 g_SimpleError(_lc
[I_GAME_ERROR_CTF
]);
3723 gState
:= STATE_MENU
;
3730 NetTimeToUpdate
:= 1;
3731 NetTimeToReliable
:= 0;
3732 NetTimeToMaster
:= NetMasterRate
;
3733 gLMSRespawn
:= LMS_RESPAWN_NONE
;
3734 gLMSRespawnTime
:= 0;
3735 gMissionFailed
:= False;
3738 gCoopMonstersKilled
:= 0;
3739 gCoopSecretsFound
:= 0;
3741 gVoteInProgress
:= False;
3742 gVotePassed
:= False;
3748 if not gGameOn
then Exit
;
3750 g_Game_SpectateCenterView();
3752 if (gGameSettings
.MaxLives
> 0) and (gGameSettings
.WarmupTime
> 0) then
3754 gLMSRespawn
:= LMS_RESPAWN_WARMUP
;
3755 gLMSRespawnTime
:= gTime
+ gGameSettings
.WarmupTime
*1000;
3756 gLMSSoftSpawn
:= True;
3757 if NetMode
= NET_SERVER
then
3758 MH_SEND_GameEvent(NET_EV_LMS_WARMUP
, (gLMSRespawnTime
- gTime
) div 1000)
3760 g_Console_Add(Format(_lc
[I_MSG_WARMUP_START
], [(gLMSRespawnTime
- gTime
) div 1000]), True);
3763 if NetMode
= NET_SERVER
then
3765 MH_SEND_GameEvent(NET_EV_MAPSTART
, gGameSettings
.GameMode
, Map
);
3768 if NetUseMaster
then
3770 if (NetMHost
= nil) or (NetMPeer
= nil) then
3771 if not g_Net_Slist_Connect
then
3772 g_Console_Add(_lc
[I_NET_MSG_ERROR
] + _lc
[I_NET_SLIST_ERROR
]);
3777 if NetClients
<> nil then
3778 for I
:= 0 to High(NetClients
) do
3779 if NetClients
[I
].Used
then
3781 NetClients
[I
].Voted
:= False;
3782 if NetClients
[I
].RequestedFullUpdate
then
3784 MH_SEND_Everything((NetClients
[I
].State
= NET_STATE_AUTH
), I
);
3785 NetClients
[I
].RequestedFullUpdate
:= False;
3789 g_Net_UnbanNonPermHosts();
3794 gCoopTotalMonstersKilled
:= 0;
3795 gCoopTotalSecretsFound
:= 0;
3796 gCoopTotalMonsters
:= 0;
3797 gCoopTotalSecrets
:= 0;
3801 g_Game_ExecuteEvent('onmapstart');
3804 procedure SetFirstLevel();
3808 MapList
:= g_Map_GetMapsList(MapsDir
+ gGameSettings
.WAD
);
3809 if MapList
= nil then
3812 SortSArray(MapList
);
3813 gNextMap
:= MapList
[Low(MapList
)];
3818 procedure g_Game_ExitLevel(Map
: Char16
);
3822 gCoopTotalMonstersKilled
:= gCoopTotalMonstersKilled
+ gCoopMonstersKilled
;
3823 gCoopTotalSecretsFound
:= gCoopTotalSecretsFound
+ gCoopSecretsFound
;
3824 gCoopTotalMonsters
:= gCoopTotalMonsters
+ gTotalMonsters
;
3825 gCoopTotalSecrets
:= gCoopTotalSecrets
+ gSecretsCount
;
3827 // Âûøëè â âûõîä â Îäèíî÷íîé èãðå:
3828 if gGameSettings
.GameType
= GT_SINGLE
then
3829 gExit
:= EXIT_ENDLEVELSINGLE
3830 else // Âûøëè â âûõîä â Ñâîåé èãðå
3832 gExit
:= EXIT_ENDLEVELCUSTOM
;
3833 if gGameSettings
.GameMode
= GM_COOP
then
3834 g_Player_RememberAll
;
3836 if not g_Map_Exist(MapsDir
+ gGameSettings
.WAD
+ ':\' + gNextMap
) then
3839 if gGameSettings
.GameMode
= GM_COOP
then
3842 gStatsPressed
:= True;
3843 gNextMap
:= 'MAP01';
3845 if not g_Map_Exist(MapsDir
+ gGameSettings
.WAD
+ ':\' + gNextMap
) then
3848 if g_Game_IsNet
then
3850 MH_SEND_GameStats();
3851 MH_SEND_CoopStats();
3857 procedure g_Game_RestartLevel();
3861 if gGameSettings
.GameMode
= GM_SINGLE
then
3866 gExit
:= EXIT_ENDLEVELCUSTOM
;
3867 g_ProcessResourceStr(gMapInfo
.Map
, nil, nil, @Map
);
3871 procedure g_Game_ClientWAD(NewWAD
: String; WHash
: TMD5Digest
);
3875 if LowerCase(NewWAD
) = LowerCase(gGameSettings
.WAD
) then
3877 if not g_Game_IsClient
then
3879 gWAD
:= g_Res_SearchSameWAD(MapsDir
, ExtractFileName(NewWAD
), WHash
);
3882 g_Game_SetLoadingText(_lc
[I_LOAD_DL_RES
], 0, False);
3883 gWAD
:= g_Res_DownloadWAD(ExtractFileName(NewWAD
));
3887 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_WAD
], [ExtractFileName(NewWAD
)]));
3891 NewWAD
:= ExtractRelativePath(MapsDir
, gWAD
);
3892 g_Game_LoadWAD(NewWAD
);
3895 procedure g_Game_RestartRound(NoMapRestart
: Boolean = False);
3897 i
, n
, nb
, nr
: Integer;
3899 if not g_Game_IsServer
then Exit
;
3900 if gLMSRespawn
= LMS_RESPAWN_NONE
then Exit
;
3901 gLMSRespawn
:= LMS_RESPAWN_NONE
;
3902 gLMSRespawnTime
:= 0;
3905 if (gGameSettings
.GameMode
= GM_COOP
) and not NoMapRestart
then
3907 gMissionFailed
:= True;
3908 g_Game_RestartLevel
;
3912 n
:= 0; nb
:= 0; nr
:= 0;
3913 for i
:= Low(gPlayers
) to High(gPlayers
) do
3914 if (gPlayers
[i
] <> nil) and
3915 ((not gPlayers
[i
].FSpectator
) or gPlayers
[i
].FWantsInGame
or
3916 (gPlayers
[i
] is TBot
)) then
3919 if gPlayers
[i
].Team
= TEAM_RED
then Inc(nr
)
3920 else if gPlayers
[i
].Team
= TEAM_BLUE
then Inc(nb
)
3923 if (n
< 2) or ((gGameSettings
.GameMode
= GM_TDM
) and ((nr
= 0) or (nb
= 0))) then
3925 // wait a second until the fuckers finally decide to join
3926 gLMSRespawn
:= LMS_RESPAWN_WARMUP
;
3927 gLMSRespawnTime
:= gTime
+ 1000;
3928 gLMSSoftSpawn
:= NoMapRestart
;
3932 g_Player_RemoveAllCorpses
;
3933 g_Game_Message(_lc
[I_MESSAGE_LMS_START
], 144);
3934 if g_Game_IsNet
then
3935 MH_SEND_GameEvent(NET_EV_LMS_START
);
3937 for i
:= Low(gPlayers
) to High(gPlayers
) do
3939 if gPlayers
[i
] = nil then continue
;
3940 if gPlayers
[i
] is TBot
then gPlayers
[i
].FWantsInGame
:= True;
3941 // don't touch normal spectators
3942 if gPlayers
[i
].FSpectator
and not gPlayers
[i
].FWantsInGame
then
3944 gPlayers
[i
].FNoRespawn
:= True;
3945 gPlayers
[i
].Lives
:= 0;
3946 if g_Game_IsNet
then
3947 MH_SEND_PlayerStats(gPlayers
[I
].UID
);
3950 gPlayers
[i
].FNoRespawn
:= False;
3951 gPlayers
[i
].Lives
:= gGameSettings
.MaxLives
;
3952 gPlayers
[i
].Respawn(False, True);
3953 if gGameSettings
.GameMode
= GM_COOP
then
3955 gPlayers
[i
].Frags
:= 0;
3956 gPlayers
[i
].RecallState
;
3958 if (gPlayer1
= nil) and (gLMSPID1
> 0) then
3959 gPlayer1
:= g_Player_Get(gLMSPID1
);
3960 if (gPlayer2
= nil) and (gLMSPID2
> 0) then
3961 gPlayer2
:= g_Player_Get(gLMSPID2
);
3964 for i
:= Low(gItems
) to High(gItems
) do
3966 if gItems
[i
].Respawnable
then
3968 gItems
[i
].QuietRespawn
:= True;
3969 gItems
[i
].RespawnTime
:= 0;
3974 if g_Game_IsNet
then MH_SEND_ItemDestroy(True, i
);
3978 for i
:= Low(gMonsters
) to High(gMonsters
) do
3980 if (gMonsters
[i
] <> nil) and not gMonsters
[i
].FNoRespawn
then
3981 gMonsters
[i
].Respawn
;
3984 gLMSSoftSpawn
:= False;
3987 function g_Game_GetFirstMap(WAD
: String): String;
3991 MapList
:= g_Map_GetMapsList(WAD
);
3992 if MapList
= nil then
3995 SortSArray(MapList
);
3996 Result
:= MapList
[Low(MapList
)];
3998 if not g_Map_Exist(WAD
+ ':\' + Result
) then
4004 function g_Game_GetNextMap(): String;
4011 MapList
:= g_Map_GetMapsList(MapsDir
+ gGameSettings
.WAD
);
4012 if MapList
= nil then
4015 g_ProcessResourceStr(gMapInfo
.Map
, nil, nil, @Map
);
4017 SortSArray(MapList
);
4019 for I
:= Low(MapList
) to High(MapList
) do
4020 if Map
= MapList
[I
] then
4026 if MapIndex
<> -255 then
4028 if MapIndex
= High(MapList
) then
4029 Result
:= MapList
[Low(MapList
)]
4031 Result
:= MapList
[MapIndex
+ 1];
4033 if not g_Map_Exist(MapsDir
+ gGameSettings
.WAD
+ ':\' + Result
) then Result
:= Map
;
4039 procedure g_Game_NextLevel();
4041 if gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
, GM_COOP
] then
4042 gExit
:= EXIT_ENDLEVELCUSTOM
4045 gExit
:= EXIT_ENDLEVELSINGLE
;
4049 if gNextMap
<> '' then Exit
;
4050 gNextMap
:= g_Game_GetNextMap();
4053 function g_Game_IsTestMap(): Boolean;
4055 FName
, Sect
, Res
: String;
4057 g_ProcessResourceStr(gMapInfo
.Map
, FName
, Sect
, Res
);
4058 Result
:= UpperCase(Res
) = TEST_MAP_NAME
;
4061 procedure g_Game_DeleteTestMap();
4072 a
:= Pos('.wad:\', gMapToDelete
);
4076 // Âûäåëÿåì èìÿ wad-ôàéëà è èìÿ êàðòû:
4077 WadName
:= Copy(gMapToDelete
, 1, a
+ 3);
4078 Delete(gMapToDelete
, 1, a
+ 5);
4079 gMapToDelete
:= UpperCase(gMapToDelete
);
4081 CopyMemory(@MapName
[0], @gMapToDelete
[1], Min(16, Length(gMapToDelete
)));
4084 // Èìÿ êàðòû íå ñòàíäàðòíîå òåñòîâîå:
4085 if MapName <> TEST_MAP_NAME then
4088 if not gTempDelete then
4090 time := g_GetFileTime(WadName);
4091 WAD := TWADEditor_1.Create();
4094 if not WAD.ReadFile(WadName) then
4095 begin // Íåò òàêîãî WAD-ôàéëà
4100 // Ñîñòàâëÿåì ñïèñîê êàðò è èùåì íóæíóþ:
4102 MapList := WAD.GetResourcesList('');
4104 if MapList <> nil then
4105 for a := 0 to High(MapList) do
4106 if MapList[a] = MapName then
4108 // Óäàëÿåì è ñîõðàíÿåì:
4109 WAD.RemoveResource('', MapName);
4110 WAD.SaveTo(WadName);
4115 g_SetFileTime(WadName, time);
4118 if gTempDelete
then DeleteFile(WadName
);
4121 procedure GameCVars(P
: SArray
);
4124 stat
: TPlayerStatArray
;
4129 cmd
:= LowerCase(P
[0]);
4130 if cmd
= 'r_showfps' then
4132 if (Length(P
) > 1) and
4133 ((P
[1] = '1') or (P
[1] = '0')) then
4134 gShowFPS
:= (P
[1][1] = '1');
4137 g_Console_Add(_lc
[I_MSG_SHOW_FPS_ON
])
4139 g_Console_Add(_lc
[I_MSG_SHOW_FPS_OFF
]);
4141 else if (cmd
= 'g_friendlyfire') and not g_Game_IsClient
then
4143 with gGameSettings
do
4145 if (Length(P
) > 1) and
4146 ((P
[1] = '1') or (P
[1] = '0')) then
4148 if (P
[1][1] = '1') then
4149 Options
:= Options
or GAME_OPTION_TEAMDAMAGE
4151 Options
:= Options
and (not GAME_OPTION_TEAMDAMAGE
);
4154 if (LongBool(Options
and GAME_OPTION_TEAMDAMAGE
)) then
4155 g_Console_Add(_lc
[I_MSG_FRIENDLY_FIRE_ON
])
4157 g_Console_Add(_lc
[I_MSG_FRIENDLY_FIRE_OFF
]);
4159 if g_Game_IsNet
then MH_SEND_GameSettings
;
4162 else if (cmd
= 'g_weaponstay') and not g_Game_IsClient
then
4164 with gGameSettings
do
4166 if (Length(P
) > 1) and
4167 ((P
[1] = '1') or (P
[1] = '0')) then
4169 if (P
[1][1] = '1') then
4170 Options
:= Options
or GAME_OPTION_WEAPONSTAY
4172 Options
:= Options
and (not GAME_OPTION_WEAPONSTAY
);
4175 if (LongBool(Options
and GAME_OPTION_WEAPONSTAY
)) then
4176 g_Console_Add(_lc
[I_MSG_WEAPONSTAY_ON
])
4178 g_Console_Add(_lc
[I_MSG_WEAPONSTAY_OFF
]);
4180 if g_Game_IsNet
then MH_SEND_GameSettings
;
4183 else if cmd
= 'g_gamemode' then
4185 a
:= g_Game_TextToMode(P
[1]);
4186 if a
= GM_SINGLE
then a
:= GM_COOP
;
4187 if (Length(P
) > 1) and (a
<> GM_NONE
) and (not g_Game_IsClient
) then
4189 gSwitchGameMode
:= a
;
4190 if (gGameOn
and (gGameSettings
.GameMode
= GM_SINGLE
)) or
4191 (gState
= STATE_INTERSINGLE
) then
4192 gSwitchGameMode
:= GM_SINGLE
;
4194 gGameSettings
.GameMode
:= gSwitchGameMode
;
4196 if gSwitchGameMode
= gGameSettings
.GameMode
then
4197 g_Console_Add(Format(_lc
[I_MSG_GAMEMODE_CURRENT
],
4198 [g_Game_ModeToText(gGameSettings
.GameMode
)]))
4200 g_Console_Add(Format(_lc
[I_MSG_GAMEMODE_CHANGE
],
4201 [g_Game_ModeToText(gGameSettings
.GameMode
),
4202 g_Game_ModeToText(gSwitchGameMode
)]));
4204 else if (cmd
= 'g_allow_exit') and not g_Game_IsClient
then
4206 with gGameSettings
do
4208 if (Length(P
) > 1) and
4209 ((P
[1] = '1') or (P
[1] = '0')) then
4211 if (P
[1][1] = '1') then
4212 Options
:= Options
or GAME_OPTION_ALLOWEXIT
4214 Options
:= Options
and (not GAME_OPTION_ALLOWEXIT
);
4217 if (LongBool(Options
and GAME_OPTION_ALLOWEXIT
)) then
4218 g_Console_Add(_lc
[I_MSG_ALLOWEXIT_ON
])
4220 g_Console_Add(_lc
[I_MSG_ALLOWEXIT_OFF
]);
4221 g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
4223 if g_Game_IsNet
then MH_SEND_GameSettings
;
4226 else if (cmd
= 'g_allow_monsters') and not g_Game_IsClient
then
4228 with gGameSettings
do
4230 if (Length(P
) > 1) and
4231 ((P
[1] = '1') or (P
[1] = '0')) then
4233 if (P
[1][1] = '1') then
4234 Options
:= Options
or GAME_OPTION_MONSTERS
4236 Options
:= Options
and (not GAME_OPTION_MONSTERS
);
4239 if (LongBool(Options
and GAME_OPTION_MONSTERS
)) then
4240 g_Console_Add(_lc
[I_MSG_ALLOWMON_ON
])
4242 g_Console_Add(_lc
[I_MSG_ALLOWMON_OFF
]);
4243 g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
4245 if g_Game_IsNet
then MH_SEND_GameSettings
;
4248 else if (cmd
= 'g_bot_vsplayers') and not g_Game_IsClient
then
4250 with gGameSettings
do
4252 if (Length(P
) > 1) and
4253 ((P
[1] = '1') or (P
[1] = '0')) then
4255 if (P
[1][1] = '1') then
4256 Options
:= Options
or GAME_OPTION_BOTVSPLAYER
4258 Options
:= Options
and (not GAME_OPTION_BOTVSPLAYER
);
4261 if (LongBool(Options
and GAME_OPTION_BOTVSPLAYER
)) then
4262 g_Console_Add(_lc
[I_MSG_BOTSVSPLAYERS_ON
])
4264 g_Console_Add(_lc
[I_MSG_BOTSVSPLAYERS_OFF
]);
4266 if g_Game_IsNet
then MH_SEND_GameSettings
;
4269 else if (cmd
= 'g_bot_vsmonsters') and not g_Game_IsClient
then
4271 with gGameSettings
do
4273 if (Length(P
) > 1) and
4274 ((P
[1] = '1') or (P
[1] = '0')) then
4276 if (P
[1][1] = '1') then
4277 Options
:= Options
or GAME_OPTION_BOTVSMONSTER
4279 Options
:= Options
and (not GAME_OPTION_BOTVSMONSTER
);
4282 if (LongBool(Options
and GAME_OPTION_BOTVSMONSTER
)) then
4283 g_Console_Add(_lc
[I_MSG_BOTSVSMONSTERS_ON
])
4285 g_Console_Add(_lc
[I_MSG_BOTSVSMONSTERS_OFF
]);
4287 if g_Game_IsNet
then MH_SEND_GameSettings
;
4290 else if (cmd
= 'g_warmuptime') and not g_Game_IsClient
then
4292 if Length(P
) > 1 then
4294 if StrToIntDef(P
[1], gGameSettings
.WarmupTime
) = 0 then
4295 gGameSettings
.WarmupTime
:= 30
4297 gGameSettings
.WarmupTime
:= StrToIntDef(P
[1], gGameSettings
.WarmupTime
);
4300 g_Console_Add(Format(_lc
[I_MSG_WARMUP
],
4301 [gGameSettings
.WarmupTime
]));
4302 g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
4304 else if cmd
= 'net_interp' then
4306 if (Length(P
) > 1) then
4307 NetInterpLevel
:= StrToIntDef(P
[1], NetInterpLevel
);
4309 g_Console_Add('net_interp = ' + IntToStr(NetInterpLevel
));
4310 config
:= TConfig
.CreateFile(GameDir
+'/'+CONFIG_FILENAME
);
4311 config
.WriteInt('Client', 'InterpolationSteps', NetInterpLevel
);
4312 config
.SaveFile(GameDir
+'/'+CONFIG_FILENAME
);
4315 else if cmd
= 'net_forceplayerupdate' then
4317 if (Length(P
) > 1) and
4318 ((P
[1] = '1') or (P
[1] = '0')) then
4319 NetForcePlayerUpdate
:= (P
[1][1] = '1');
4321 if NetForcePlayerUpdate
then
4322 g_Console_Add('net_forceplayerupdate = 1')
4324 g_Console_Add('net_forceplayerupdate = 0');
4325 config
:= TConfig
.CreateFile(GameDir
+'/'+CONFIG_FILENAME
);
4326 config
.WriteBool('Client', 'ForcePlayerUpdate', NetForcePlayerUpdate
);
4327 config
.SaveFile(GameDir
+'/'+CONFIG_FILENAME
);
4330 else if cmd
= 'net_predictself' then
4332 if (Length(P
) > 1) and
4333 ((P
[1] = '1') or (P
[1] = '0')) then
4334 NetPredictSelf
:= (P
[1][1] = '1');
4336 if NetPredictSelf
then
4337 g_Console_Add('net_predictself = 1')
4339 g_Console_Add('net_predictself = 0');
4340 config
:= TConfig
.CreateFile(GameDir
+'/'+CONFIG_FILENAME
);
4341 config
.WriteBool('Client', 'PredictSelf', NetPredictSelf
);
4342 config
.SaveFile(GameDir
+'/'+CONFIG_FILENAME
);
4345 else if cmd
= 'sv_name' then
4347 if (Length(P
) > 1) and (Length(P
[1]) > 0) then
4349 NetServerName
:= P
[1];
4350 if Length(NetServerName
) > 64 then
4351 SetLength(NetServerName
, 64);
4352 if g_Game_IsServer
and g_Game_IsNet
and NetUseMaster
then
4356 g_Console_Add(cmd
+ ' = "' + NetServerName
+ '"');
4358 else if cmd
= 'sv_passwd' then
4360 if (Length(P
) > 1) and (Length(P
[1]) > 0) then
4362 NetPassword
:= P
[1];
4363 if Length(NetPassword
) > 24 then
4364 SetLength(NetPassword
, 24);
4365 if g_Game_IsServer
and g_Game_IsNet
and NetUseMaster
then
4369 g_Console_Add(cmd
+ ' = "' + AnsiLowerCase(NetPassword
) + '"');
4371 else if cmd
= 'sv_maxplrs' then
4373 if (Length(P
) > 1) then
4375 NetMaxClients
:= Min(Max(StrToIntDef(P
[1], NetMaxClients
), 1), NET_MAXCLIENTS
);
4376 if g_Game_IsServer
and g_Game_IsNet
then
4379 for a
:= 0 to High(NetClients
) do
4380 if NetClients
[a
].Used
then
4383 if b
> NetMaxClients
then
4385 s
:= g_Player_Get(NetClients
[a
].Player
).Name
;
4386 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_FULL
);
4387 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
4388 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
4391 if NetUseMaster
then
4396 g_Console_Add(cmd
+ ' = ' + IntToStr(NetMaxClients
));
4398 else if cmd
= 'sv_public' then
4400 if (Length(P
) > 1) then
4402 NetUseMaster
:= StrToIntDef(P
[1], Byte(NetUseMaster
)) > 0;
4403 if g_Game_IsServer
and g_Game_IsNet
then
4404 if NetUseMaster
then
4406 if NetMPeer
= nil then
4407 if not g_Net_Slist_Connect() then
4408 g_Console_Add(_lc
[I_NET_MSG_ERROR
] + _lc
[I_NET_SLIST_ERROR
]);
4409 g_Net_Slist_Update();
4412 if NetMPeer
<> nil then
4413 g_Net_Slist_Disconnect();
4416 g_Console_Add(cmd
+ ' = ' + IntToStr(Byte(NetUseMaster
)));
4418 else if cmd
= 'sv_intertime' then
4420 if (Length(P
) > 1) then
4421 gDefInterTime
:= Min(Max(StrToIntDef(P
[1], gDefInterTime
), -1), 120);
4423 g_Console_Add(cmd
+ ' = ' + IntToStr(gDefInterTime
));
4425 else if cmd
= 'p1_name' then
4427 if (Length(P
) > 1) and gGameOn
then
4429 if g_Game_IsClient
then
4431 gPlayer1Settings
.Name
:= b_Text_Unformat(P
[1]);
4432 MC_SEND_PlayerSettings
;
4435 if gPlayer1
<> nil then
4437 gPlayer1
.Name
:= b_Text_Unformat(P
[1]);
4438 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer1
.UID
);
4441 gPlayer1Settings
.Name
:= b_Text_Unformat(P
[1]);
4444 else if cmd
= 'p2_name' then
4446 if (Length(P
) > 1) and gGameOn
then
4448 if g_Game_IsClient
then
4450 gPlayer2Settings
.Name
:= b_Text_Unformat(P
[1]);
4451 MC_SEND_PlayerSettings
;
4454 if gPlayer2
<> nil then
4456 gPlayer2
.Name
:= b_Text_Unformat(P
[1]);
4457 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer2
.UID
);
4460 gPlayer2Settings
.Name
:= b_Text_Unformat(P
[1]);
4463 else if cmd
= 'p1_color' then
4465 if Length(P
) > 3 then
4466 if g_Game_IsClient
then
4468 gPlayer1Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
4469 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
4470 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
4471 MC_SEND_PlayerSettings
;
4474 if gPlayer1
<> nil then
4476 gPlayer1
.Model
.SetColor(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
4477 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
4478 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
4479 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer1
.UID
);
4482 gPlayer1Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
4483 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
4484 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
4486 else if (cmd
= 'p2_color') and not g_Game_IsNet
then
4488 if Length(P
) > 3 then
4489 if g_Game_IsClient
then
4491 gPlayer2Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
4492 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
4493 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
4494 MC_SEND_PlayerSettings
;
4497 if gPlayer2
<> nil then
4499 gPlayer2
.Model
.SetColor(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
4500 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
4501 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
4502 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer2
.UID
);
4505 gPlayer2Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
4506 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
4507 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
4509 else if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
4511 if cmd
= 'r_showtime' then
4513 if (Length(P
) > 1) and
4514 ((P
[1] = '1') or (P
[1] = '0')) then
4515 gShowTime
:= (P
[1][1] = '1');
4518 g_Console_Add(_lc
[I_MSG_TIME_ON
])
4520 g_Console_Add(_lc
[I_MSG_TIME_OFF
]);
4522 else if cmd
= 'r_showscore' then
4524 if (Length(P
) > 1) and
4525 ((P
[1] = '1') or (P
[1] = '0')) then
4526 gShowGoals
:= (P
[1][1] = '1');
4529 g_Console_Add(_lc
[I_MSG_SCORE_ON
])
4531 g_Console_Add(_lc
[I_MSG_SCORE_OFF
]);
4533 else if cmd
= 'r_showstat' then
4535 if (Length(P
) > 1) and
4536 ((P
[1] = '1') or (P
[1] = '0')) then
4537 gShowStat
:= (P
[1][1] = '1');
4540 g_Console_Add(_lc
[I_MSG_STATS_ON
])
4542 g_Console_Add(_lc
[I_MSG_STATS_OFF
]);
4544 else if cmd
= 'r_showkillmsg' then
4546 if (Length(P
) > 1) and
4547 ((P
[1] = '1') or (P
[1] = '0')) then
4548 gShowKillMsg
:= (P
[1][1] = '1');
4550 if gShowKillMsg
then
4551 g_Console_Add(_lc
[I_MSG_KILL_MSGS_ON
])
4553 g_Console_Add(_lc
[I_MSG_KILL_MSGS_OFF
]);
4555 else if cmd
= 'r_showlives' then
4557 if (Length(P
) > 1) and
4558 ((P
[1] = '1') or (P
[1] = '0')) then
4559 gShowLives
:= (P
[1][1] = '1');
4562 g_Console_Add(_lc
[I_MSG_LIVES_ON
])
4564 g_Console_Add(_lc
[I_MSG_LIVES_OFF
]);
4566 else if cmd
= 'r_showspect' then
4568 if (Length(P
) > 1) and
4569 ((P
[1] = '1') or (P
[1] = '0')) then
4570 gSpectHUD
:= (P
[1][1] = '1');
4573 g_Console_Add(_lc
[I_MSG_SPECT_HUD_ON
])
4575 g_Console_Add(_lc
[I_MSG_SPECT_HUD_OFF
]);
4577 else if cmd
= 'r_showping' then
4579 if (Length(P
) > 1) and
4580 ((P
[1] = '1') or (P
[1] = '0')) then
4581 gShowPing
:= (P
[1][1] = '1');
4584 g_Console_Add(_lc
[I_MSG_PING_ON
])
4586 g_Console_Add(_lc
[I_MSG_PING_OFF
]);
4588 else if (cmd
= 'g_scorelimit') and not g_Game_IsClient
then
4590 if Length(P
) > 1 then
4592 if StrToIntDef(P
[1], gGameSettings
.GoalLimit
) = 0 then
4593 gGameSettings
.GoalLimit
:= 0
4598 if gGameSettings
.GameMode
= GM_DM
then
4600 stat
:= g_Player_GetStats();
4602 for a
:= 0 to High(stat
) do
4603 if stat
[a
].Frags
> b
then
4607 b
:= Max(gTeamStat
[TEAM_RED
].Goals
, gTeamStat
[TEAM_BLUE
].Goals
);
4609 gGameSettings
.GoalLimit
:= Max(StrToIntDef(P
[1], gGameSettings
.GoalLimit
), b
);
4612 if g_Game_IsNet
then MH_SEND_GameSettings
;
4615 g_Console_Add(Format(_lc
[I_MSG_SCORE_LIMIT
], [gGameSettings
.GoalLimit
]));
4617 else if (cmd
= 'g_timelimit') and not g_Game_IsClient
then
4619 if (Length(P
) > 1) and (StrToIntDef(P
[1], -1) >= 0) then
4620 gGameSettings
.TimeLimit
:= StrToIntDef(P
[1], -1);
4622 g_Console_Add(Format(_lc
[I_MSG_TIME_LIMIT
],
4623 [gGameSettings
.TimeLimit
div 3600,
4624 (gGameSettings
.TimeLimit
div 60) mod 60,
4625 gGameSettings
.TimeLimit
mod 60]));
4626 if g_Game_IsNet
then MH_SEND_GameSettings
;
4628 else if (cmd
= 'g_maxlives') and not g_Game_IsClient
then
4630 if Length(P
) > 1 then
4632 if StrToIntDef(P
[1], gGameSettings
.MaxLives
) = 0 then
4633 gGameSettings
.MaxLives
:= 0
4637 stat
:= g_Player_GetStats();
4639 for a
:= 0 to High(stat
) do
4640 if stat
[a
].Lives
> b
then
4642 gGameSettings
.MaxLives
:=
4643 Max(StrToIntDef(P
[1], gGameSettings
.MaxLives
), b
);
4647 g_Console_Add(Format(_lc
[I_MSG_LIVES
],
4648 [gGameSettings
.MaxLives
]));
4649 if g_Game_IsNet
then MH_SEND_GameSettings
;
4654 procedure DebugCommands(P
: SArray
);
4660 // Êîìàíäû îòëàäî÷íîãî ðåæèìà:
4663 cmd
:= LowerCase(P
[0]);
4664 if cmd
= 'd_window' then
4666 g_Console_Add(Format('gWinPosX = %d, gWinPosY %d', [gWinPosX
, gWinPosY
]));
4667 g_Console_Add(Format('gWinRealPosX = %d, gWinRealPosY %d', [gWinRealPosX
, gWinRealPosY
]));
4668 g_Console_Add(Format('gScreenWidth = %d, gScreenHeight = %d', [gScreenWidth
, gScreenHeight
]));
4669 g_Console_Add(Format('gWinSizeX = %d, gWinSizeY = %d', [gWinSizeX
, gWinSizeY
]));
4670 g_Console_Add(Format('Frame X = %d, Y = %d, Caption Y = %d', [gWinFrameX
, gWinFrameY
, gWinCaption
]));
4672 else if cmd
= 'd_sounds' then
4674 if (Length(P
) > 1) and
4675 ((P
[1] = '1') or (P
[1] = '0')) then
4676 g_Debug_Sounds
:= (P
[1][1] = '1');
4678 g_Console_Add(Format('d_sounds is %d', [Byte(g_Debug_Sounds
)]));
4680 else if cmd
= 'd_frames' then
4682 if (Length(P
) > 1) and
4683 ((P
[1] = '1') or (P
[1] = '0')) then
4684 g_Debug_Frames
:= (P
[1][1] = '1');
4686 g_Console_Add(Format('d_frames is %d', [Byte(g_Debug_Frames
)]));
4688 else if cmd
= 'd_winmsg' then
4690 if (Length(P
) > 1) and
4691 ((P
[1] = '1') or (P
[1] = '0')) then
4692 g_Debug_WinMsgs
:= (P
[1][1] = '1');
4694 g_Console_Add(Format('d_winmsg is %d', [Byte(g_Debug_WinMsgs
)]));
4696 else if (cmd
= 'd_monoff') and not g_Game_IsNet
then
4698 if (Length(P
) > 1) and
4699 ((P
[1] = '1') or (P
[1] = '0')) then
4700 g_Debug_MonsterOff
:= (P
[1][1] = '1');
4702 g_Console_Add(Format('d_monoff is %d', [Byte(g_debug_MonsterOff
)]));
4704 else if (cmd
= 'd_botoff') and not g_Game_IsNet
then
4706 if Length(P
) > 1 then
4708 '0': g_debug_BotAIOff
:= 0;
4709 '1': g_debug_BotAIOff
:= 1;
4710 '2': g_debug_BotAIOff
:= 2;
4711 '3': g_debug_BotAIOff
:= 3;
4714 g_Console_Add(Format('d_botoff is %d', [g_debug_BotAIOff
]));
4716 else if cmd
= 'd_monster' then
4718 if gGameOn
and (gPlayer1
<> nil) and (gPlayer1
.Live
) and (not g_Game_IsNet
) then
4719 if Length(P
) < 2 then
4721 g_Console_Add(cmd
+ ' [ID | Name] [behaviour]');
4722 g_Console_Add('ID | Name');
4723 for b
:= MONSTER_DEMON
to MONSTER_MAN
do
4724 g_Console_Add(Format('%2d | %s', [b
, g_Monsters_GetNameByID(b
)]));
4727 a
:= StrToIntDef(P
[1], 0);
4728 if (a
< MONSTER_DEMON
) or (a
> MONSTER_MAN
) then
4729 a
:= g_Monsters_GetIDByName(P
[1]);
4731 if (a
< MONSTER_DEMON
) or (a
> MONSTER_MAN
) then
4732 g_Console_Add(Format(_lc
[I_MSG_NO_MONSTER
], [P
[1]]))
4735 with gPlayer1
.Obj
do
4736 b
:= g_Monsters_Create(a
,
4737 X
+ Rect
.X
+ (Rect
.Width
div 2),
4738 Y
+ Rect
.Y
+ Rect
.Height
,
4739 gPlayer1
.Direction
, True);
4740 if (Length(P
) > 2) and (b
>= 0) then
4741 gMonsters
[b
].MonsterBehaviour
:= Min(Max(StrToIntDef(P
[2], BH_NORMAL
), BH_NORMAL
), BH_GOOD
);
4745 else if (cmd
= 'd_health') then
4747 if (Length(P
) > 1) and
4748 ((P
[1] = '1') or (P
[1] = '0')) then
4749 g_debug_HealthBar
:= (P
[1][1] = '1');
4751 g_Console_Add(Format('d_health is %d', [Byte(g_debug_HealthBar
)]));
4753 else if (cmd
= 'd_player') then
4755 if (Length(P
) > 1) and
4756 ((P
[1] = '1') or (P
[1] = '0')) then
4757 g_debug_Player
:= (P
[1][1] = '1');
4759 g_Console_Add(Format(cmd
+ ' is %d', [Byte(g_Debug_Player
)]));
4761 else if (cmd
= 'd_joy') then
4764 g_Console_Add(e_JoystickStateToString(a
));
4768 g_Console_Add(_lc
[I_MSG_NOT_DEBUG
]);
4771 procedure GameCommands(P
: SArray
);
4777 pl
: pTNetClient
= nil;
4784 cmd
:= LowerCase(P
[0]);
4786 if (cmd
= 'quit') or
4793 else if cmd
= 'pause' then
4795 if (g_ActiveWindow
= nil) then
4796 g_Game_Pause(not gPause
);
4798 else if cmd
= 'endgame' then
4799 gExit
:= EXIT_SIMPLE
4800 else if cmd
= 'restart' then
4802 if gGameOn
or (gState
in [STATE_INTERSINGLE
, STATE_INTERCUSTOM
]) then
4804 if g_Game_IsClient
then
4806 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4811 g_Console_Add(_lc
[I_MSG_NOT_GAME
]);
4813 else if cmd
= 'kick' then
4815 if g_Game_IsServer
then
4817 if Length(P
) < 2 then
4819 g_Console_Add('kick <name>');
4824 g_Console_Add('kick <name>');
4828 if g_Game_IsNet
then
4829 pl
:= g_Net_Client_ByName(P
[1]);
4832 s
:= g_Net_ClientName_ByID(pl
^.ID
);
4833 enet_peer_disconnect(pl
^.Peer
, NET_DISC_KICK
);
4834 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
4835 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
4836 if NetUseMaster
then
4838 end else if gPlayers
<> nil then
4839 for a
:= Low(gPlayers
) to High(gPlayers
) do
4840 if gPlayers
[a
] <> nil then
4841 if Copy(LowerCase(gPlayers
[a
].Name
), 1, Length(P
[1])) = LowerCase(P
[1]) then
4843 // Íå îòêëþ÷àòü îñíîâíûõ èãðîêîâ â ñèíãëå
4844 if not(gPlayers
[a
] is TBot
) and (gGameSettings
.GameType
= GT_SINGLE
) then
4846 gPlayers
[a
].Lives
:= 0;
4847 gPlayers
[a
].Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
4848 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [gPlayers
[a
].Name
]), True);
4849 g_Player_Remove(gPlayers
[a
].UID
);
4850 if NetUseMaster
then
4852 // Åñëè íå ïåðåìåøàòü, ïðè äîáàâëåíèè íîâûõ áîòîâ ïîÿâÿòñÿ ñòàðûå
4856 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
4858 else if cmd
= 'kick_id' then
4860 if g_Game_IsServer
and g_Game_IsNet
then
4862 if Length(P
) < 2 then
4864 g_Console_Add('kick_id <client ID>');
4869 g_Console_Add('kick_id <client ID>');
4873 a
:= StrToIntDef(P
[1], 0);
4874 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
4876 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
4878 s
:= g_Net_ClientName_ByID(NetClients
[a
].ID
);
4879 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_KICK
);
4880 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
4881 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
4882 if NetUseMaster
then
4887 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4889 else if cmd
= 'ban' then
4891 if g_Game_IsServer
and g_Game_IsNet
then
4893 if Length(P
) < 2 then
4895 g_Console_Add('ban <name>');
4900 g_Console_Add('ban <name>');
4904 pl
:= g_Net_Client_ByName(P
[1]);
4907 s
:= g_Net_ClientName_ByID(pl
^.ID
);
4908 g_Net_BanHost(pl
^.Peer
^.address
.host
, False);
4909 enet_peer_disconnect(pl
^.Peer
, NET_DISC_TEMPBAN
);
4910 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
4911 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
4912 if NetUseMaster
then
4915 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
4917 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4919 else if cmd
= 'ban_id' then
4921 if g_Game_IsServer
and g_Game_IsNet
then
4923 if Length(P
) < 2 then
4925 g_Console_Add('ban_id <client ID>');
4930 g_Console_Add('ban_id <client ID>');
4934 a
:= StrToIntDef(P
[1], 0);
4935 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
4936 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
4938 s
:= g_Net_ClientName_ByID(NetClients
[a
].ID
);
4939 g_Net_BanHost(NetClients
[a
].Peer
^.address
.host
, False);
4940 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_TEMPBAN
);
4941 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
4942 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
4943 if NetUseMaster
then
4947 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4949 else if cmd
= 'permban' then
4951 if g_Game_IsServer
and g_Game_IsNet
then
4953 if Length(P
) < 2 then
4955 g_Console_Add('permban <name>');
4960 g_Console_Add('permban <name>');
4964 pl
:= g_Net_Client_ByName(P
[1]);
4967 s
:= g_Net_ClientName_ByID(pl
^.ID
);
4968 g_Net_BanHost(pl
^.Peer
^.address
.host
);
4969 enet_peer_disconnect(pl
^.Peer
, NET_DISC_BAN
);
4970 g_Net_SaveBanList();
4971 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
4972 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
4973 if NetUseMaster
then
4976 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
4978 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4980 else if cmd
= 'permban_id' then
4982 if g_Game_IsServer
and g_Game_IsNet
then
4984 if Length(P
) < 2 then
4986 g_Console_Add('permban_id <client ID>');
4991 g_Console_Add('permban_id <client ID>');
4995 a
:= StrToIntDef(P
[1], 0);
4996 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
4997 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
4999 s
:= g_Net_ClientName_ByID(NetClients
[a
].ID
);
5000 g_Net_BanHost(NetClients
[a
].Peer
^.address
.host
);
5001 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_BAN
);
5002 g_Net_SaveBanList();
5003 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
5004 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
5005 if NetUseMaster
then
5009 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
5011 else if cmd
= 'unban' then
5013 if g_Game_IsServer
and g_Game_IsNet
then
5015 if Length(P
) < 2 then
5017 g_Console_Add('unban <IP Address>');
5022 g_Console_Add('unban <IP Address>');
5026 if g_Net_UnbanHost(P
[1]) then
5028 g_Console_Add(Format(_lc
[I_MSG_UNBAN_OK
], [P
[1]]));
5029 g_Net_SaveBanList();
5031 g_Console_Add(Format(_lc
[I_MSG_UNBAN_FAIL
], [P
[1]]));
5033 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
5035 else if cmd
= 'clientlist' then
5037 if g_Game_IsServer
and g_Game_IsNet
then
5040 if NetClients
<> nil then
5041 for a
:= Low(NetClients
) to High(NetClients
) do
5042 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
5044 plr
:= g_Player_Get(NetClients
[a
].Player
);
5045 if plr
= nil then continue
;
5047 g_Console_Add(Format('#%2d: %-15s | %s', [a
,
5048 IpToStr(NetClients
[a
].Peer
^.address
.host
), plr
.Name
]));
5051 g_Console_Add(_lc
[I_MSG_NOCLIENTS
]);
5053 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
5055 else if cmd
= 'connect' then
5057 if (NetMode
= NET_NONE
) then
5059 if Length(P
) < 2 then
5061 g_Console_Add('connect <IP> [port] [password]');
5066 g_Console_Add('connect <IP> [port] [password]');
5070 if Length(P
) > 2 then
5071 prt
:= StrToIntDef(P
[2], 25666)
5075 if Length(P
) > 3 then
5080 g_Game_StartClient(P
[1], prt
, pw
);
5083 else if cmd
= 'disconnect' then
5085 if (NetMode
= NET_CLIENT
) then
5088 else if cmd
= 'reconnect' then
5090 if (NetMode
= NET_SERVER
) then
5093 if (NetMode
= NET_CLIENT
) then
5096 gExit
:= EXIT_SIMPLE
;
5100 //TODO: Use last successful password to reconnect, instead of ''
5101 g_Game_StartClient(NetClientIP
, NetClientPort
, '');
5103 else if (cmd
= 'addbot') or
5104 (cmd
= 'bot_add') then
5106 if Length(P
) > 1 then
5107 g_Bot_Add(TEAM_NONE
, StrToIntDef(P
[1], 2))
5109 g_Bot_Add(TEAM_NONE
, 2);
5111 else if cmd
= 'bot_addlist' then
5113 if Length(P
) > 1 then
5114 if Length(P
) = 2 then
5115 g_Bot_AddList(TEAM_NONE
, P
[1], StrToIntDef(P
[1], -1))
5117 g_Bot_AddList(IfThen(P
[2] = 'red', TEAM_RED
, TEAM_BLUE
), P
[1], StrToIntDef(P
[1], -1));
5119 else if cmd
= 'bot_removeall' then
5121 else if cmd
= 'chat' then
5123 if g_Game_IsNet
then
5125 if Length(P
) > 1 then
5127 for a
:= 1 to High(P
) do
5128 chstr
:= chstr
+ P
[a
] + ' ';
5130 if Length(chstr
) > 200 then SetLength(chstr
, 200);
5132 if Length(chstr
) < 1 then
5134 g_Console_Add('chat <text>');
5138 chstr
:= b_Text_Format(chstr
);
5139 if g_Game_IsClient
then
5140 MC_SEND_Chat(chstr
, NET_CHAT_PLAYER
)
5142 MH_SEND_Chat(gPlayer1Settings
.Name
+ ': ' + chstr
, NET_CHAT_PLAYER
);
5145 g_Console_Add('chat <text>');
5147 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
5149 else if cmd
= 'teamchat' then
5151 if g_Game_IsNet
and (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
5153 if Length(P
) > 1 then
5155 for a
:= 1 to High(P
) do
5156 chstr
:= chstr
+ P
[a
] + ' ';
5158 if Length(chstr
) > 200 then SetLength(chstr
, 200);
5160 if Length(chstr
) < 1 then
5162 g_Console_Add('teamchat <text>');
5166 chstr
:= b_Text_Format(chstr
);
5167 if g_Game_IsClient
then
5168 MC_SEND_Chat(chstr
, NET_CHAT_TEAM
)
5170 MH_SEND_Chat(gPlayer1Settings
.Name
+ ': ' + chstr
, NET_CHAT_TEAM
,
5171 gPlayer1Settings
.Team
);
5174 g_Console_Add('teamchat <text>');
5176 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
5178 else if cmd
= 'game' then
5180 if gGameSettings
.GameType
<> GT_NONE
then
5182 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
5185 if Length(P
) = 1 then
5187 g_Console_Add(cmd
+ ' <WAD> [MAP] [# players]');
5190 // Èãðà åù¸ íå çàïóùåíà, ñíà÷àëà íàì íàäî çàãðóçèòü êàêîé-òî WAD
5191 P
[1] := addWadExtension(P
[1]);
5192 if FileExists(MapsDir
+ P
[1]) then
5194 // Åñëè êàðòà íå óêàçàíà, áåð¸ì ïåðâóþ êàðòó â ôàéëå
5195 if Length(P
) < 3 then
5198 P
[2] := g_Game_GetFirstMap(MapsDir
+ P
[1]);
5201 s
:= P
[1] + ':\' + UpperCase(P
[2]);
5203 if g_Map_Exist(MapsDir
+ s
) then
5205 // Çàïóñêàåì ñâîþ èãðó
5207 with gGameSettings
do
5209 GameMode
:= g_Game_TextToMode(gcGameMode
);
5210 if gSwitchGameMode
<> GM_NONE
then
5211 GameMode
:= gSwitchGameMode
;
5212 if GameMode
= GM_NONE
then GameMode
:= GM_DM
;
5213 if GameMode
= GM_SINGLE
then GameMode
:= GM_COOP
;
5215 if Length(P
) >= 4 then
5216 b
:= StrToIntDef(P
[3], 1);
5217 g_Game_StartCustom(s
, GameMode
, TimeLimit
,
5218 GoalLimit
, MaxLives
, Options
, b
);
5223 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
5225 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [UpperCase(P
[2])]));
5227 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]));
5229 else if cmd
= 'host' then
5231 if gGameSettings
.GameType
<> GT_NONE
then
5233 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
5236 if Length(P
) < 4 then
5238 g_Console_Add(cmd
+ ' <listen IP> <port> <WAD> [MAP] [# players]');
5241 if not StrToIp(P
[1], listen
) then
5243 prt
:= StrToIntDef(P
[2], 25666);
5245 P
[3] := addWadExtension(P
[3]);
5246 if FileExists(MapsDir
+ P
[3]) then
5248 // Åñëè êàðòà íå óêàçàíà, áåð¸ì ïåðâóþ êàðòó â ôàéëå
5249 if Length(P
) < 5 then
5252 P
[4] := g_Game_GetFirstMap(MapsDir
+ P
[1]);
5255 s
:= P
[3] + ':\' + UpperCase(P
[4]);
5257 if g_Map_Exist(MapsDir
+ s
) then
5259 // Çàïóñêàåì ñâîþ èãðó
5261 with gGameSettings
do
5263 GameMode
:= g_Game_TextToMode(gcGameMode
);
5264 if gSwitchGameMode
<> GM_NONE
then
5265 GameMode
:= gSwitchGameMode
;
5266 if GameMode
= GM_NONE
then GameMode
:= GM_DM
;
5267 if GameMode
= GM_SINGLE
then GameMode
:= GM_COOP
;
5269 if Length(P
) >= 6 then
5270 b
:= StrToIntDef(P
[5], 0);
5271 g_Game_StartServer(s
, GameMode
, TimeLimit
,
5272 GoalLimit
, MaxLives
, Options
, b
, listen
, prt
);
5277 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[3]]))
5279 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [UpperCase(P
[4])]));
5281 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[3]]));
5283 else if cmd
= 'map' then
5285 if Length(P
) = 1 then
5287 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
5289 g_Console_Add(cmd
+ ' <MAP>');
5290 g_Console_Add(cmd
+ ' <WAD> [MAP]');
5292 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
5294 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
5296 // Èä¸ò ñâîÿ èãðà èëè ñåðâåð
5297 if Length(P
) < 3 then
5299 // Ïåðâûé ïàðàìåòð - ëèáî êàðòà, ëèáî èìÿ WAD ôàéëà
5300 s
:= UpperCase(P
[1]);
5301 if g_Map_Exist(MapsDir
+ gGameSettings
.WAD
+ ':\' + s
) then
5302 begin // Êàðòà íàøëàñü
5303 gExitByTrigger
:= False;
5305 begin // Èä¸ò èãðà - çàâåðøàåì óðîâåíü
5307 gExit
:= EXIT_ENDLEVELCUSTOM
;
5309 else // Èíòåðìèññèÿ - ñðàçó çàãðóæàåì êàðòó
5310 g_Game_ChangeMap(s
);
5313 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [s
]));
5314 // Òàêîé êàðòû íåò, èùåì WAD ôàéë
5315 P
[1] := addWadExtension(P
[1]);
5316 if FileExists(MapsDir
+ P
[1]) then
5318 // Ïàðàìåòðà êàðòû íåò, ïîýòîìó ñòàâèì ïåðâóþ èç ôàéëà
5320 P
[2] := g_Game_GetFirstMap(MapsDir
+ P
[1]);
5322 s
:= P
[1] + ':\' + P
[2];
5324 if g_Map_Exist(MapsDir
+ s
) then
5326 gExitByTrigger
:= False;
5328 begin // Èä¸ò èãðà - çàâåðøàåì óðîâåíü
5330 gExit
:= EXIT_ENDLEVELCUSTOM
;
5332 else // Èíòåðìèññèÿ - ñðàçó çàãðóæàåì êàðòó
5333 g_Game_ChangeMap(s
);
5336 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
5338 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]));
5340 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]));
5344 // Óêàçàíî äâà ïàðàìåòðà, çíà÷èò ïåðâûé - WAD ôàéë, à âòîðîé - êàðòà
5345 P
[1] := addWadExtension(P
[1]);
5346 if FileExists(MapsDir
+ P
[1]) then
5349 P
[2] := UpperCase(P
[2]);
5350 s
:= P
[1] + ':\' + P
[2];
5352 if g_Map_Exist(MapsDir
+ s
) then
5353 begin // Íàøëè êàðòó
5354 gExitByTrigger
:= False;
5356 begin // Èä¸ò èãðà - çàâåðøàåì óðîâåíü
5358 gExit
:= EXIT_ENDLEVELCUSTOM
;
5360 else // Èíòåðìèññèÿ - ñðàçó çàãðóæàåì êàðòó
5361 g_Game_ChangeMap(s
);
5363 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]));
5365 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]));
5368 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
5370 else if cmd
= 'nextmap' then
5372 if not(gGameOn
or (gState
= STATE_INTERCUSTOM
)) then
5373 g_Console_Add(_lc
[I_MSG_NOT_GAME
])
5376 if Length(P
) = 1 then
5378 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
5380 g_Console_Add(cmd
+ ' <MAP>');
5381 g_Console_Add(cmd
+ ' <WAD> [MAP]');
5384 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
5389 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
5391 if Length(P
) < 3 then
5393 // Ïåðâûé ïàðàìåòð - ëèáî êàðòà, ëèáî èìÿ WAD ôàéëà
5394 s
:= UpperCase(P
[1]);
5395 if g_Map_Exist(MapsDir
+ gGameSettings
.WAD
+ ':\' + s
) then
5396 begin // Êàðòà íàøëàñü
5397 gExitByTrigger
:= False;
5402 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [s
]));
5403 // Òàêîé êàðòû íåò, èùåì WAD ôàéë
5404 P
[1] := addWadExtension(P
[1]);
5405 if FileExists(MapsDir
+ P
[1]) then
5407 // Ïàðàìåòðà êàðòû íåò, ïîýòîìó ñòàâèì ïåðâóþ èç ôàéëà
5409 P
[2] := g_Game_GetFirstMap(MapsDir
+ P
[1]);
5411 s
:= P
[1] + ':\' + P
[2];
5413 if g_Map_Exist(MapsDir
+ s
) then
5414 begin // Óñòàíàâëèâàåì êàðòó
5415 gExitByTrigger
:= False;
5420 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
5422 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]));
5424 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]));
5428 // Óêàçàíî äâà ïàðàìåòðà, çíà÷èò ïåðâûé - WAD ôàéë, à âòîðîé - êàðòà
5429 P
[1] := addWadExtension(P
[1]);
5430 if FileExists(MapsDir
+ P
[1]) then
5433 P
[2] := UpperCase(P
[2]);
5434 s
:= P
[1] + ':\' + P
[2];
5436 if g_Map_Exist(MapsDir
+ s
) then
5437 begin // Íàøëè êàðòó
5438 gExitByTrigger
:= False;
5442 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]));
5444 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]));
5447 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
5450 if gNextMap
= '' then
5451 g_Console_Add(_lc
[I_MSG_NEXTMAP_UNSET
])
5453 g_Console_Add(Format(_lc
[I_MSG_NEXTMAP_SET
], [gNextMap
]));
5456 else if (cmd
= 'endmap') or (cmd
= 'goodbye') then
5459 g_Console_Add(_lc
[I_MSG_NOT_GAME
])
5461 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
5463 gExitByTrigger
:= False;
5464 // Ñëåäóþùàÿ êàðòà íå çàäàíà, ïðîáóåì íàéòè òðèããåð Âûõîä
5465 if (gNextMap
= '') and (gTriggers
<> nil) then
5466 for a
:= 0 to High(gTriggers
) do
5467 if gTriggers
[a
].TriggerType
= TRIGGER_EXIT
then
5469 gExitByTrigger
:= True;
5470 gNextMap
:= gTriggers
[a
].Data
.MapName
;
5473 // Èùåì ñëåäóþùóþ êàðòó â WAD ôàéëå
5474 if gNextMap
= '' then
5475 gNextMap
:= g_Game_GetNextMap();
5476 // Ïðîâåðÿåì, íå çàäàí ëè WAD ôàéë ðåñóðñíîé ñòðîêîé
5477 if Pos(':\', gNextMap
) = 0 then
5478 s
:= gGameSettings
.WAD
+ ':\' + gNextMap
5481 // Åñëè êàðòà íàéäåíà, âûõîäèì ñ óðîâíÿ
5482 if g_Map_Exist(MapsDir
+ s
) then
5483 gExit
:= EXIT_ENDLEVELCUSTOM
5485 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [gNextMap
]));
5487 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
5489 else if (cmd
= 'event') then
5491 if (Length(P
) <= 1) then
5493 for a
:= 0 to High(gEvents
) do
5494 if gEvents
[a
].Command
= '' then
5495 g_Console_Add(gEvents
[a
].Name
+ ' <none>')
5497 g_Console_Add(gEvents
[a
].Name
+ ' "' + gEvents
[a
].Command
+ '"');
5500 if (Length(P
) = 2) then
5502 for a
:= 0 to High(gEvents
) do
5503 if gEvents
[a
].Name
= P
[1] then
5504 if gEvents
[a
].Command
= '' then
5505 g_Console_Add(gEvents
[a
].Name
+ ' <none>')
5507 g_Console_Add(gEvents
[a
].Name
+ ' "' + gEvents
[a
].Command
+ '"');
5510 for a
:= 0 to High(gEvents
) do
5511 if gEvents
[a
].Name
= P
[1] then
5513 gEvents
[a
].Command
:= '';
5514 for b
:= 2 to High(P
) do
5515 if Pos(' ', P
[b
]) = 0 then
5516 gEvents
[a
].Command
:= gEvents
[a
].Command
+ ' ' + P
[b
]
5518 gEvents
[a
].Command
:= gEvents
[a
].Command
+ ' "' + P
[b
] + '"';
5519 gEvents
[a
].Command
:= Trim(gEvents
[a
].Command
);
5523 // Êîìàíäû Ñâîåé èãðû:
5524 else if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
5526 if cmd
= 'bot_addred' then
5528 if Length(P
) > 1 then
5529 g_Bot_Add(TEAM_RED
, StrToIntDef(P
[1], 2))
5531 g_Bot_Add(TEAM_RED
, 2);
5533 else if cmd
= 'bot_addblue' then
5535 if Length(P
) > 1 then
5536 g_Bot_Add(TEAM_BLUE
, StrToIntDef(P
[1], 2))
5538 g_Bot_Add(TEAM_BLUE
, 2);
5540 else if cmd
= 'suicide' then
5544 if g_Game_IsClient
then
5545 MC_SEND_CheatRequest(NET_CHEAT_SUICIDE
)
5548 if gPlayer1
<> nil then
5549 gPlayer1
.Damage(SUICIDE_DAMAGE
, gPlayer1
.UID
, 0, 0, HIT_SELF
);
5550 if gPlayer2
<> nil then
5551 gPlayer2
.Damage(SUICIDE_DAMAGE
, gPlayer2
.UID
, 0, 0, HIT_SELF
);
5555 else if cmd
= 'spectate' then
5561 else if cmd
= 'say' then
5563 if g_Game_IsServer
and g_Game_IsNet
then
5565 if Length(P
) > 1 then
5568 for a
:= 1 to High(P
) do
5569 chstr
:= chstr
+ P
[a
] + ' ';
5571 if Length(chstr
) > 200 then SetLength(chstr
, 200);
5573 if Length(chstr
) < 1 then
5575 g_Console_Add('say <text>');
5579 chstr
:= b_Text_Format(chstr
);
5580 MH_SEND_Chat(chstr
, NET_CHAT_PLAYER
);
5582 else g_Console_Add('say <text>');
5584 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
5586 else if cmd
= 'tell' then
5588 if g_Game_IsServer
and g_Game_IsNet
then
5590 if (Length(P
) > 2) and (P
[1] <> '') then
5593 for a
:= 2 to High(P
) do
5594 chstr
:= chstr
+ P
[a
] + ' ';
5596 if Length(chstr
) > 200 then SetLength(chstr
, 200);
5598 if Length(chstr
) < 1 then
5600 g_Console_Add('tell <playername> <text>');
5604 pl
:= g_Net_Client_ByName(P
[1]);
5606 MH_SEND_Chat(b_Text_Format(chstr
), NET_CHAT_PLAYER
, pl
^.ID
)
5608 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
5610 else g_Console_Add('tell <playername> <text>');
5612 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
5614 else if (cmd
= 'overtime') and not g_Game_IsClient
then
5616 if (Length(P
) = 1) or (StrToIntDef(P
[1], -1) <= 0) then
5618 // Äîïîëíèòåëüíîå âðåìÿ:
5619 gGameSettings
.TimeLimit
:= (gTime
- gGameStartTime
) div 1000 + Word(StrToIntDef(P
[1], 0));
5621 g_Console_Add(Format(_lc
[I_MSG_TIME_LIMIT
],
5622 [gGameSettings
.TimeLimit
div 3600,
5623 (gGameSettings
.TimeLimit
div 60) mod 60,
5624 gGameSettings
.TimeLimit
mod 60]));
5625 if g_Game_IsNet
then MH_SEND_GameSettings
;
5627 else if (cmd
= 'rcon_password') and g_Game_IsClient
then
5629 if (Length(P
) <= 1) then
5630 g_Console_Add('rcon_password <password>')
5632 MC_SEND_RCONPassword(P
[1]);
5634 else if cmd
= 'rcon' then
5636 if g_Game_IsClient
then
5638 if Length(P
) > 1 then
5641 for a
:= 1 to High(P
) do
5642 chstr
:= chstr
+ P
[a
] + ' ';
5644 if Length(chstr
) > 200 then SetLength(chstr
, 200);
5646 if Length(chstr
) < 1 then
5648 g_Console_Add('rcon <command>');
5652 MC_SEND_RCONCommand(chstr
);
5654 else g_Console_Add('rcon <command>');
5657 else if cmd
= 'ready' then
5659 if g_Game_IsServer
and (gLMSRespawn
= LMS_RESPAWN_WARMUP
) then
5660 gLMSRespawnTime
:= gTime
+ 100;
5662 else if (cmd
= 'callvote') and g_Game_IsNet
then
5664 if Length(P
) > 1 then
5667 for a
:= 1 to High(P
) do begin
5668 if a
> 1 then chstr
:= chstr
+ ' ';
5669 chstr
:= chstr
+ P
[a
];
5672 if Length(chstr
) > 200 then SetLength(chstr
, 200);
5674 if Length(chstr
) < 1 then
5676 g_Console_Add('callvote <command>');
5680 if g_Game_IsClient
then
5681 MC_SEND_Vote(True, chstr
)
5683 g_Game_StartVote(chstr
, gPlayer1Settings
.Name
);
5684 g_Console_Process('vote', True);
5687 g_Console_Add('callvote <command>');
5689 else if (cmd
= 'vote') and g_Game_IsNet
then
5691 if g_Game_IsClient
then
5693 else if gVoteInProgress
then
5695 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
5696 a
:= Floor((NetClientCount
+1)/2.0) + 1
5698 a
:= Floor(NetClientCount
/2.0) + 1;
5703 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_REVOKED
], [gPlayer1Settings
.Name
, gVoteCount
, a
]), True);
5704 MH_SEND_VoteEvent(NET_VE_REVOKE
, gPlayer1Settings
.Name
, 'a', gVoteCount
, a
);
5710 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_VOTE
], [gPlayer1Settings
.Name
, gVoteCount
, a
]), True);
5711 MH_SEND_VoteEvent(NET_VE_VOTE
, gPlayer1Settings
.Name
, 'a', gVoteCount
, a
);
5719 procedure g_TakeScreenShot();
5724 for a
:= 1 to High(Word) do
5726 FileName
:= Format(GameDir
+'/Screenshots/Screenshot%.3d.bmp', [a
]);
5727 if not FileExists(FileName
) then
5729 e_MakeScreenshot(FileName
, gScreenWidth
, gScreenHeight
);
5730 g_Console_Add(Format(_lc
[I_CONSOLE_SCREENSHOT
], [ExtractFileName(FileName
)]));
5736 procedure g_Game_InGameMenu(Show
: Boolean);
5738 if (g_ActiveWindow
= nil) and Show
then
5740 if gGameSettings
.GameType
= GT_SINGLE
then
5741 g_GUI_ShowWindow('GameSingleMenu')
5744 if g_Game_IsClient
then
5745 g_GUI_ShowWindow('GameClientMenu')
5747 if g_Game_IsNet
then
5748 g_GUI_ShowWindow('GameServerMenu')
5750 g_GUI_ShowWindow('GameCustomMenu');
5752 g_Sound_PlayEx('MENU_OPEN');
5754 // Ïàóçà ïðè ìåíþ òîëüêî â îäèíî÷íîé èãðå:
5755 if (not g_Game_IsNet
) then
5759 if (g_ActiveWindow
<> nil) and (not Show
) then
5761 // Ïàóçà ïðè ìåíþ òîëüêî â îäèíî÷íîé èãðå:
5762 if (not g_Game_IsNet
) then
5763 g_Game_Pause(False);
5767 procedure g_Game_Pause(Enable
: Boolean);
5772 if gPause
= Enable
then
5775 if not (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
]) then
5779 g_Game_PauseAllSounds(Enable
);
5782 procedure g_Game_PauseAllSounds(Enable
: Boolean);
5787 if gTriggers
<> nil then
5788 for i
:= 0 to High(gTriggers
) do
5789 with gTriggers
[i
] do
5790 if (TriggerType
= TRIGGER_SOUND
) and
5792 Sound
.IsPlaying() then
5794 Sound
.Pause(Enable
);
5798 if gPlayers
<> nil then
5799 for i
:= 0 to High(gPlayers
) do
5800 if gPlayers
[i
] <> nil then
5801 gPlayers
[i
].PauseSounds(Enable
);
5804 if gMusic
<> nil then
5805 gMusic
.Pause(Enable
);
5808 procedure g_Game_StopAllSounds(all
: Boolean);
5812 if gTriggers
<> nil then
5813 for i
:= 0 to High(gTriggers
) do
5814 with gTriggers
[i
] do
5815 if (TriggerType
= TRIGGER_SOUND
) and
5819 if gMusic
<> nil then
5826 procedure g_Game_UpdateTriggerSounds();
5830 if gTriggers
<> nil then
5831 for i
:= 0 to High(gTriggers
) do
5832 with gTriggers
[i
] do
5833 if (TriggerType
= TRIGGER_SOUND
) and
5836 Sound
.IsPlaying() then
5838 if ((gPlayer1
<> nil) and g_CollidePoint(gPlayer1
.GameX
, gPlayer1
.GameY
, X
, Y
, Width
, Height
)) or
5839 ((gPlayer2
<> nil) and g_CollidePoint(gPlayer2
.GameX
, gPlayer2
.GameY
, X
, Y
, Width
, Height
)) then
5841 Sound
.SetPan(0.5 - Data
.Pan
/255.0);
5842 Sound
.SetVolume(Data
.Volume
/255.0);
5845 Sound
.SetCoords(X
+(Width
div 2), Y
+(Height
div 2), Data
.Volume
/255.0);
5849 function g_Game_IsWatchedPlayer(UID
: Word): Boolean;
5852 if (gPlayer1
<> nil) and (gPlayer1
.UID
= UID
) then
5857 if (gPlayer2
<> nil) and (gPlayer2
.UID
= UID
) then
5862 if gSpectMode
<> SPECT_PLAYERS
then
5864 if gSpectPID1
= UID
then
5869 if gSpectViewTwo
and (gSpectPID2
= UID
) then
5876 function g_Game_IsWatchedTeam(Team
: Byte): Boolean;
5881 if (gPlayer1
<> nil) and (gPlayer1
.Team
= Team
) then
5886 if (gPlayer2
<> nil) and (gPlayer2
.Team
= Team
) then
5891 if gSpectMode
<> SPECT_PLAYERS
then
5893 Pl
:= g_Player_Get(gSpectPID1
);
5894 if (Pl
<> nil) and (Pl
.Team
= Team
) then
5899 if gSpectViewTwo
then
5901 Pl
:= g_Player_Get(gSpectPID2
);
5902 if (Pl
<> nil) and (Pl
.Team
= Team
) then
5910 procedure g_Game_Message(Msg
: string; Time
: Word);
5912 MessageText
:= b_Text_Format(Msg
);
5913 MessageTime
:= Time
;
5916 procedure g_Game_Announce_GoodShot(SpawnerUID
: Word);
5925 if not g_Game_IsWatchedPlayer(SpawnerUID
) then
5929 if goodsnd
[a
].IsPlaying() then
5932 goodsnd
[Random(4)].Play();
5935 procedure g_Game_Announce_KillCombo(Param
: Integer);
5942 UID
:= Param
and $FFFF;
5947 Pl
:= g_Player_Get(UID
);
5956 g_Console_Add(Format(_lc
[I_PLAYER_KILL_2X
], [Name
]), True);
5960 g_Console_Add(Format(_lc
[I_PLAYER_KILL_3X
], [Name
]), True);
5964 g_Console_Add(Format(_lc
[I_PLAYER_KILL_4X
], [Name
]), True);
5968 g_Console_Add(Format(_lc
[I_PLAYER_KILL_MX
], [Name
]), True);
5976 if not g_Game_IsWatchedPlayer(UID
) then
5979 if (not g_Game_IsWatchedPlayer(UID
)) and (c
< 4) then
5983 if killsnd
[n
].IsPlaying() then
5988 procedure g_Game_StartVote(Command
, Initiator
: string);
5992 if not gVotesEnabled
then Exit
;
5993 if gGameSettings
.GameType
<> GT_SERVER
then Exit
;
5994 if gVoteInProgress
or gVotePassed
then
5996 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_INPROGRESS
], [gVoteCommand
]), True);
5997 MH_SEND_VoteEvent(NET_VE_INPROGRESS
, gVoteCommand
);
6000 gVoteInProgress
:= True;
6001 gVotePassed
:= False;
6002 gVoteTimer
:= gTime
+ gVoteTimeout
* 1000;
6005 gVoteCommand
:= Command
;
6007 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
6008 Need
:= Floor((NetClientCount
+1)/2.0)+1
6010 Need
:= Floor(NetClientCount
/2.0)+1;
6011 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_STARTED
], [Initiator
, Command
, Need
]), True);
6012 MH_SEND_VoteEvent(NET_VE_STARTED
, Initiator
, Command
, Need
);
6015 procedure g_Game_CheckVote
;
6019 if gGameSettings
.GameType
<> GT_SERVER
then Exit
;
6020 if not gVoteInProgress
then Exit
;
6022 if (gTime
>= gVoteTimer
) then
6024 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
6025 Need
:= Floor((NetClientCount
+1)/2.0) + 1
6027 Need
:= Floor(NetClientCount
/2.0) + 1;
6028 if gVoteCount
>= Need
then
6030 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_PASSED
], [gVoteCommand
]), True);
6031 MH_SEND_VoteEvent(NET_VE_PASSED
, gVoteCommand
);
6032 gVotePassed
:= True;
6033 gVoteCmdTimer
:= gTime
+ 5000;
6037 g_Console_Add(_lc
[I_MESSAGE_VOTE_FAILED
], True);
6038 MH_SEND_VoteEvent(NET_VE_FAILED
);
6040 if NetClients
<> nil then
6041 for I
:= Low(NetClients
) to High(NetClients
) do
6042 if NetClients
[i
].Used
then
6043 NetClients
[i
].Voted
:= False;
6044 gVoteInProgress
:= False;
6050 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
6051 Need
:= Floor((NetClientCount
+1)/2.0) + 1
6053 Need
:= Floor(NetClientCount
/2.0) + 1;
6054 if gVoteCount
>= Need
then
6056 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_PASSED
], [gVoteCommand
]), True);
6057 MH_SEND_VoteEvent(NET_VE_PASSED
, gVoteCommand
);
6058 gVoteInProgress
:= False;
6059 gVotePassed
:= True;
6060 gVoteCmdTimer
:= gTime
+ 5000;
6063 if NetClients
<> nil then
6064 for I
:= Low(NetClients
) to High(NetClients
) do
6065 if NetClients
[i
].Used
then
6066 NetClients
[i
].Voted
:= False;
6071 procedure g_Game_LoadMapList(FileName
: string);
6079 if not FileExists(FileName
) then Exit
;
6081 AssignFile(ListFile
, FileName
);
6083 while not EOF(ListFile
) do
6085 ReadLn(ListFile
, s
);
6088 if s
= '' then Continue
;
6090 SetLength(MapList
, Length(MapList
)+1);
6091 MapList
[High(MapList
)] := s
;
6093 CloseFile(ListFile
);
6096 procedure g_Game_SetDebugMode();
6099 // ×èòû (äàæå â ñâîåé èãðå):
6103 procedure g_Game_SetLoadingText(Text: String; Max
: Integer; reWrite
: Boolean);
6107 if Length(LoadingStat
.Msgs
) = 0 then
6113 begin // Ïåðåõîäèì íà ñëåäóþùóþ ñòðîêó èëè ñêðîëëèðóåì:
6114 if NextMsg
= Length(Msgs
) then
6116 for i
:= 0 to High(Msgs
)-1 do
6117 Msgs
[i
] := Msgs
[i
+1];
6125 Msgs
[NextMsg
-1] := Text;
6131 g_ActiveWindow
:= nil;
6136 procedure g_Game_StepLoading();
6142 if (ShowCount
> LOADING_SHOW_STEP
) then
6150 procedure g_Game_ClearLoading();
6159 len
:= ((gScreenHeight
div 3)*2 - 50) div LOADING_INTERLINE
;
6160 if len
< 1 then len
:= 1;
6161 SetLength(Msgs
, len
);
6162 for len
:= Low(Msgs
) to High(Msgs
) do
6168 procedure Parse_Params(var pars
: TParamStrValues
);
6175 while i
<= ParamCount
do
6178 if (s
[1] = '-') and (Length(s
) > 1) then
6180 if (s
[2] = '-') and (Length(s
) > 2) then
6181 begin // Îäèíî÷íûé ïàðàìåòð
6182 SetLength(pars
, Length(pars
) + 1);
6183 with pars
[High(pars
)] do
6185 Name
:= LowerCase(s
);
6190 if (i
< ParamCount
) then
6191 begin // Ïàðàìåòð ñî çíà÷åíèåì
6193 SetLength(pars
, Length(pars
) + 1);
6194 with pars
[High(pars
)] do
6196 Name
:= LowerCase(s
);
6197 Value
:= LowerCase(ParamStr(i
));
6206 function Find_Param_Value(var pars
: TParamStrValues
; aName
: String): String;
6211 for i
:= 0 to High(pars
) do
6212 if pars
[i
].Name
= aName
then
6214 Result
:= pars
[i
].Value
;
6219 procedure g_Game_Process_Params();
6221 pars
: TParamStrValues
;
6224 LimT
, LimS
: Integer;
6235 s
:= Find_Param_Value(pars
, '--debug');
6237 g_Game_SetDebugMode();
6239 // Connect when game loads
6240 ip
:= Find_Param_Value(pars
, '-connect');
6244 s
:= Find_Param_Value(pars
, '-port');
6245 if (s
= '') or not TryStrToInt(s
, Port
) then
6248 s
:= Find_Param_Value(pars
, '-pw');
6250 g_Game_StartClient(ip
, Port
, s
);
6254 // Start map when game loads:
6255 map
:= LowerCase(Find_Param_Value(pars
, '-map'));
6256 if isWadPath(map
) then
6259 s
:= Find_Param_Value(pars
, '-gm');
6260 GMode
:= g_Game_TextToMode(s
);
6261 if GMode
= GM_NONE
then GMode
:= GM_DM
;
6262 if GMode
= GM_SINGLE
then GMode
:= GM_COOP
;
6265 s
:= Find_Param_Value(pars
, '-limt');
6266 if (s
= '') or (not TryStrToInt(s
, LimT
)) then
6272 s
:= Find_Param_Value(pars
, '-lims');
6273 if (s
= '') or (not TryStrToInt(s
, LimS
)) then
6279 s
:= Find_Param_Value(pars
, '-lives');
6280 if (s
= '') or (not TryStrToInt(s
, Lives
)) then
6286 s
:= Find_Param_Value(pars
, '-opt');
6288 Opt
:= GAME_OPTION_ALLOWEXIT
or GAME_OPTION_BOTVSPLAYER
or GAME_OPTION_BOTVSMONSTER
6290 Opt
:= StrToIntDef(s
, 0);
6292 Opt
:= GAME_OPTION_ALLOWEXIT
or GAME_OPTION_BOTVSPLAYER
or GAME_OPTION_BOTVSMONSTER
;
6295 s
:= Find_Param_Value(pars
, '--close');
6299 // Delete test map after play:
6300 s
:= Find_Param_Value(pars
, '--testdelete');
6303 gMapToDelete
:= MapsDir
+ map
;
6304 e_WriteLog('"--testdelete" argument doesn''t supported anymore!', MSG_FATALERROR
);
6308 // Delete temporary WAD after play:
6309 s
:= Find_Param_Value(pars
, '--tempdelete');
6312 gMapToDelete
:= MapsDir
+ map
;
6313 gTempDelete
:= True;
6316 // Number of players:
6317 s
:= Find_Param_Value(pars
, '-pl');
6321 n
:= StrToIntDef(s
, 1);
6324 s
:= Find_Param_Value(pars
, '-port');
6325 if (s
= '') or not TryStrToInt(s
, Port
) then
6326 g_Game_StartCustom(map
, GMode
, LimT
, LimS
, Lives
, Opt
, n
)
6328 g_Game_StartServer(map
, GMode
, LimT
, LimS
, Lives
, Opt
, n
, 0, Port
);
6331 // Execute script when game loads:
6332 s
:= Find_Param_Value(pars
, '-exec');
6335 if Pos(':\', s
) = 0 then
6336 s
:= GameDir
+ '/' + s
;
6341 if IOResult
<> 0 then
6343 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], ['Failed to read file: ' + s
]), MSG_WARNING
);
6344 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_READ
], [s
]));
6348 e_WriteLog('Executing script: ' + s
, MSG_NOTIFY
);
6349 g_Console_Add(Format(_lc
[I_CONSOLE_EXEC
], [s
]));
6354 if IOResult
<> 0 then
6356 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], ['Failed to read file: ' + s
]), MSG_WARNING
);
6357 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_READ
], [s
]));
6361 if Pos('#', s
) <> 1 then // script comment
6362 g_Console_Process(s
, True);