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
;
300 TEndCustomGameStat
= record
301 PlayerStat
: TPlayerStatArray
;
305 Map
, MapName
: String;
308 TEndSingleGameStat
= record
309 PlayerStat
: Array [0..1] of record
315 TotalSecrets
: Integer;
318 TLoadingStat
= record
322 Msgs
: Array of String;
326 TParamStrValue
= record
331 TParamStrValues
= Array of TParamStrValue
;
334 INTER_ACTION_TEXT
= 1;
335 INTER_ACTION_PIC
= 2;
336 INTER_ACTION_MUSIC
= 3;
340 FPSCounter
, UPSCounter
: Word;
341 FPSTime
, UPSTime
: LongWord;
342 DataLoaded
: Boolean = False;
343 LastScreenShot
: Int64;
344 IsDrawStat
: Boolean = False;
345 CustomStat
: TEndCustomGameStat
;
346 SingleStat
: TEndSingleGameStat
;
347 LoadingStat
: TLoadingStat
;
348 EndingGameCounter
: Byte = 0;
351 MapList
: SArray
= nil;
352 MapIndex
: Integer = -1;
358 text: Array of ShortString;
359 anim
: Array of ShortString;
360 pic
: Array of ShortString;
361 mus
: Array of ShortString;
363 triggers
: Array of record
365 actions
: Array of record
366 action
, p1
, p2
: Integer;
369 cur_trigger
: Integer;
382 function Compare(a
, b
: TPlayerStat
): Integer;
384 if a
.Spectator
then Result
:= 1
385 else if b
.Spectator
then Result
:= -1
386 else if a
.Frags
< b
.Frags
then Result
:= 1
387 else if a
.Frags
> b
.Frags
then Result
:= -1
388 else if a
.Deaths
< b
.Deaths
then Result
:= -1
389 else if a
.Deaths
> b
.Deaths
then Result
:= 1
390 else if a
.Kills
< b
.Kills
then Result
:= -1
394 procedure SortGameStat(var stat
: TPlayerStatArray
);
399 if stat
= nil then Exit
;
401 for I
:= High(stat
) downto Low(stat
) do
402 for J
:= Low(stat
) to High(stat
) - 1 do
403 if Compare(stat
[J
], stat
[J
+ 1]) = 1 then
406 stat
[J
] := stat
[J
+ 1];
411 function g_Game_ModeToText(Mode
: Byte): string;
415 GM_DM
: Result
:= _lc
[I_MENU_GAME_TYPE_DM
];
416 GM_TDM
: Result
:= _lc
[I_MENU_GAME_TYPE_TDM
];
417 GM_CTF
: Result
:= _lc
[I_MENU_GAME_TYPE_CTF
];
418 GM_COOP
: Result
:= _lc
[I_MENU_GAME_TYPE_COOP
];
419 GM_SINGLE
: Result
:= _lc
[I_MENU_GAME_TYPE_SINGLE
];
423 function g_Game_TextToMode(Mode
: string): Byte;
426 Mode
:= UpperCase(Mode
);
427 if Mode
= _lc
[I_MENU_GAME_TYPE_DM
] then
432 if Mode
= _lc
[I_MENU_GAME_TYPE_TDM
] then
437 if Mode
= _lc
[I_MENU_GAME_TYPE_CTF
] then
442 if Mode
= _lc
[I_MENU_GAME_TYPE_COOP
] then
447 if Mode
= _lc
[I_MENU_GAME_TYPE_SINGLE
] then
454 function g_Game_IsNet(): Boolean;
456 Result
:= (gGameSettings
.GameType
in [GT_SERVER
, GT_CLIENT
]);
459 function g_Game_IsServer(): Boolean;
461 Result
:= (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
, GT_SERVER
]);
464 function g_Game_IsClient(): Boolean;
466 Result
:= (gGameSettings
.GameType
= GT_CLIENT
);
469 function g_Game_GetMegaWADInfo(WAD
: String): TMegaWADInfo
;
476 Result
.name
:= ExtractFileName(WAD
);
477 Result
.description
:= '';
480 w
:= TWADEditor_1
.Create();
483 if not w
.GetResource('', 'INTERSCRIPT', p
, len
) then
489 cfg
:= TConfig
.CreateMem(p
, len
);
490 Result
.name
:= cfg
.ReadStr('megawad', 'name', ExtractFileName(WAD
));
491 Result
.description
:= cfg
.ReadStr('megawad', 'description', '');
492 Result
.author
:= cfg
.ReadStr('megawad', 'author', '');
493 Result
.pic
:= cfg
.ReadStr('megawad', 'pic', '');
499 procedure g_Game_FreeWAD();
503 for a
:= 0 to High(MegaWAD
.res
.pic
) do
504 if MegaWAD
.res
.pic
[a
] <> '' then
505 g_Texture_Delete(MegaWAD
.res
.pic
[a
]);
507 for a
:= 0 to High(MegaWAD
.res
.mus
) do
508 if MegaWAD
.res
.mus
[a
] <> '' then
509 g_Sound_Delete(MegaWAD
.res
.mus
[a
]);
511 MegaWAD
.res
.pic
:= nil;
512 MegaWAD
.res
.text := nil;
513 MegaWAD
.res
.anim
:= nil;
514 MegaWAD
.res
.mus
:= nil;
515 MegaWAD
.triggers
:= nil;
517 g_Texture_Delete('TEXTURE_endpic');
518 g_Sound_Delete('MUSIC_endmus');
520 ZeroMemory(@MegaWAD
, SizeOf(MegaWAD
));
521 gGameSettings
.WAD
:= '';
524 procedure g_Game_LoadWAD(WAD
: string);
533 gGameSettings
.WAD
:= WAD
;
534 if not (gGameSettings
.GameMode
in [GM_COOP
, GM_SINGLE
]) then
537 MegaWAD
.info
:= g_Game_GetMegaWADInfo(MapsDir
+ WAD
);
539 w
:= TWADEditor_1
.Create();
540 w
.ReadFile(MapsDir
+ WAD
);
542 if not w
.GetResource('', 'INTERSCRIPT', p
, len
) then
548 cfg
:= TConfig
.CreateMem(p
, len
);
553 s := cfg.ReadStr('pic', 'pic'+IntToStr(b), '');
554 if s = '' then Break;
557 SetLength(MegaWAD.res.pic, Length(MegaWAD.res.pic)+1);
558 MegaWAD.res.pic[High(MegaWAD.res.pic)] := s;
560 g_Texture_CreateWADEx(s, s);
566 s := cfg.ReadStr('mus', 'mus'+IntToStr(b), '');
567 if s = '' then Break;
570 SetLength(MegaWAD.res.mus, Length(MegaWAD.res.mus)+1);
571 MegaWAD.res.mus[High(MegaWAD.res.mus)] := s;
573 g_Music_CreateWADEx(s, s);
576 MegaWAD
.endpic
:= cfg
.ReadStr('megawad', 'endpic', '');
577 if MegaWAD
.endpic
<> '' then
579 g_ProcessResourceStr(MegaWAD
.endpic
, @s
, nil, nil);
580 if s
= '' then s
:= MapsDir
+WAD
else s
:= GameDir
+'/wads/';
581 g_Texture_CreateWADEx('TEXTURE_endpic', s
+MegaWAD
.endpic
);
583 MegaWAD
.endmus
:= cfg
.ReadStr('megawad', 'endmus', 'Standart.wad:D2DMUS\ÊÎÍÅÖ');
584 if MegaWAD
.endmus
<> '' then
586 g_ProcessResourceStr(MegaWAD
.endmus
, @s
, nil, nil);
587 if s
= '' then s
:= MapsDir
+WAD
else s
:= GameDir
+'/wads/';
588 g_Sound_CreateWADEx('MUSIC_endmus', s
+MegaWAD
.endmus
, True);
596 {procedure start_trigger(t: string);
600 function next_trigger(): Boolean;
604 procedure DisableCheats();
610 if gPlayer1
<> nil then gPlayer1
.GodMode
:= False;
611 if gPlayer2
<> nil then gPlayer2
.GodMode
:= False;
612 if gPlayer1
<> nil then gPlayer1
.NoTarget
:= False;
613 if gPlayer2
<> nil then gPlayer2
.NoTarget
:= False;
616 procedure g_Game_ExecuteEvent(Name
: String);
622 if gEvents
= nil then
624 for a
:= 0 to High(gEvents
) do
625 if gEvents
[a
].Name
= Name
then
627 if gEvents
[a
].Command
<> '' then
628 g_Console_Process(gEvents
[a
].Command
, True);
633 function g_Game_DelayEvent(DEType
: Byte; Time
: LongWord; Num
: Integer = 0; Str
: String = ''): Integer;
638 if gDelayedEvents
<> nil then
639 for a
:= 0 to High(gDelayedEvents
) do
640 if not gDelayedEvents
[a
].Pending
then
647 SetLength(gDelayedEvents
, Length(gDelayedEvents
) + 1);
648 n
:= High(gDelayedEvents
);
650 gDelayedEvents
[n
].Pending
:= True;
651 gDelayedEvents
[n
].DEType
:= DEType
;
652 gDelayedEvents
[n
].DENum
:= Num
;
653 gDelayedEvents
[n
].DEStr
:= Str
;
654 if DEType
= DE_GLOBEVENT
then
655 gDelayedEvents
[n
].Time
:= (GetTimer() div 1000) + Time
657 gDelayedEvents
[n
].Time
:= gTime
+ Time
;
664 FileName
, SectionName
, ResName
: string;
666 if g_Game_IsNet
and g_Game_IsServer
then
667 MH_SEND_GameEvent(NET_EV_MAPEND
, Byte(gMissionFailed
));
673 g_Game_StopAllSounds(False);
678 EndingGameCounter
:= 0;
679 g_ActiveWindow
:= nil;
681 gLMSRespawn
:= LMS_RESPAWN_NONE
;
682 gLMSRespawnTime
:= 0;
685 EXIT_SIMPLE
: // Âûõîä ÷åðåç ìåíþ èëè êîíåö òåñòà
690 begin // Ýòî áûë òåñò
694 begin // Âûõîä â ãëàâíîå ìåíþ
695 gMusic
.SetByName('MUSIC_MENU');
697 if gState
<> STATE_SLIST
then
699 g_GUI_ShowWindow('MainMenu');
700 gState
:= STATE_MENU
;
703 // Îáíîâëÿåì ñïèñîê ñåðâåðîâ
704 slReturnPressed
:= True;
705 if g_Net_Slist_Fetch(slCurrent
) then
707 if slCurrent
= nil then
708 slWaitStr
:= _lc
[I_NET_SLIST_NOSERVERS
];
711 slWaitStr
:= _lc
[I_NET_SLIST_ERROR
];
714 g_Game_ExecuteEvent('ongameend');
718 EXIT_RESTART
: // Íà÷àòü óðîâåíü ñíà÷àëà
720 if not g_Game_IsClient
then g_Game_Restart();
723 EXIT_ENDLEVELCUSTOM
: // Çàêîí÷èëñÿ óðîâåíü â Ñâîåé èãðå
725 // Ñòàòèñòèêà Ñâîåé èãðû:
726 g_ProcessResourceStr(gMapInfo
.Map
, FileName
, SectionName
, ResName
);
728 CustomStat
.GameTime
:= gTime
;
729 CustomStat
.Map
:= ExtractFileName(FileName
)+':'+ResName
;
730 CustomStat
.MapName
:= gMapInfo
.Name
;
731 CustomStat
.GameMode
:= gGameSettings
.GameMode
;
732 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
733 CustomStat
.TeamStat
:= gTeamStat
;
735 CustomStat
.PlayerStat
:= nil;
737 // Ñòàòèñòèêà èãðîêîâ:
738 if gPlayers
<> nil then
740 for a
:= 0 to High(gPlayers
) do
741 if gPlayers
[a
] <> nil then
743 SetLength(CustomStat
.PlayerStat
, Length(CustomStat
.PlayerStat
)+1);
744 with CustomStat
.PlayerStat
[High(CustomStat
.PlayerStat
)] do
746 Name
:= gPlayers
[a
].Name
;
747 Frags
:= gPlayers
[a
].Frags
;
748 Deaths
:= gPlayers
[a
].Death
;
749 Kills
:= gPlayers
[a
].Kills
;
750 Team
:= gPlayers
[a
].Team
;
751 Color
:= gPlayers
[a
].Model
.Color
;
752 Spectator
:= gPlayers
[a
].FSpectator
;
756 SortGameStat(CustomStat
.PlayerStat
);
759 g_Game_ExecuteEvent('onmapend');
762 EndingGameCounter
:= 255;
763 gState
:= STATE_FOLD
;
765 if gDefInterTime
< 0 then
766 gInterEndTime
:= IfThen((gGameSettings
.GameType
= GT_SERVER
) and (gPlayer1
= nil), 15000, 25000)
768 gInterEndTime
:= gDefInterTime
* 1000;
771 EXIT_ENDLEVELSINGLE
: // Çàêîí÷èëñÿ óðîâåíü â Îäèíî÷íîé èãðå
773 // Ñòàòèñòèêà Îäèíî÷íîé èãðû:
774 SingleStat
.GameTime
:= gTime
;
775 SingleStat
.TwoPlayers
:= gPlayer2
<> nil;
776 SingleStat
.TotalSecrets
:= gSecretsCount
;
777 // Ñòàòèñòèêà ïåðâîãî èãðîêà:
778 SingleStat
.PlayerStat
[0].Kills
:= gPlayer1
.MonsterKills
;
779 SingleStat
.PlayerStat
[0].Secrets
:= gPlayer1
.Secrets
;
780 // Ñòàòèñòèêà âòîðîãî èãðîêà (åñëè åñòü):
781 if SingleStat
.TwoPlayers
then
783 SingleStat
.PlayerStat
[1].Kills
:= gPlayer2
.MonsterKills
;
784 SingleStat
.PlayerStat
[1].Secrets
:= gPlayer2
.Secrets
;
787 g_Game_ExecuteEvent('onmapend');
790 if gNextMap
<> '' then
792 gMusic
.SetByName('MUSIC_INTERMUS');
794 gState
:= STATE_INTERSINGLE
;
796 g_Game_ExecuteEvent('oninter');
798 else // Áîëüøå íåò êàðò
801 EndingGameCounter
:= 255;
802 gState
:= STATE_FOLD
;
807 // Îêîí÷àíèå îáðàáîòàíî:
808 if gExit
<> EXIT_QUIT
then
812 procedure DrawStat();
814 pc
, x
, y
, w
, h
: Integer;
815 w1
, w2
, w3
, w4
: Integer;
817 cw
, ch
, r
, g
, b
, rr
, gg
, bb
: Byte;
820 stat
: TPlayerStatArray
;
827 pc
:= g_Player_GetCount
;
828 e_TextureFontGetSize(gStdFont
, cw
, ch
);
830 w
:= gScreenWidth
-(gScreenWidth
div 5);
831 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
834 h
:= 40+ch
*5+(ch
+8)*pc
;
835 x
:= (gScreenWidth
div 2)-(w
div 2);
836 y
:= (gScreenHeight
div 2)-(h
div 2);
838 e_DrawFillQuad(x
, y
, x
+w
-1, y
+h
-1, 64, 64, 64, 32);
839 e_DrawQuad(x
, y
, x
+w
-1, y
+h
-1, 255, 127, 0);
841 g_ProcessResourceStr(gMapInfo
.Map
, @wad
, nil, @map
);
842 wad
:= ExtractFileName(wad
);
843 mapstr
:= wad
+ ':\' + map
+ ' - ' + gMapInfo
.Name
;
845 case gGameSettings
.GameMode
of
848 if gGameSettings
.MaxLives
= 0 then
851 s1
:= _lc
[I_GAME_LMS
];
852 s2
:= Format(_lc
[I_GAME_FRAG_LIMIT
], [gGameSettings
.GoalLimit
]);
853 s3
:= Format(_lc
[I_GAME_TIME_LIMIT
], [gGameSettings
.TimeLimit
div 3600, (gGameSettings
.TimeLimit
div 60) mod 60, gGameSettings
.TimeLimit
mod 60]);
858 if gGameSettings
.MaxLives
= 0 then
859 s1
:= _lc
[I_GAME_TDM
]
861 s1
:= _lc
[I_GAME_TLMS
];
862 s2
:= Format(_lc
[I_GAME_FRAG_LIMIT
], [gGameSettings
.GoalLimit
]);
863 s3
:= Format(_lc
[I_GAME_TIME_LIMIT
], [gGameSettings
.TimeLimit
div 3600, (gGameSettings
.TimeLimit
div 60) mod 60, gGameSettings
.TimeLimit
mod 60]);
868 s1
:= _lc
[I_GAME_CTF
];
869 s2
:= Format(_lc
[I_GAME_SCORE_LIMIT
], [gGameSettings
.GoalLimit
]);
870 s3
:= Format(_lc
[I_GAME_TIME_LIMIT
], [gGameSettings
.TimeLimit
div 3600, (gGameSettings
.TimeLimit
div 60) mod 60, gGameSettings
.TimeLimit
mod 60]);
875 if gGameSettings
.MaxLives
= 0 then
876 s1
:= _lc
[I_GAME_COOP
]
878 s1
:= _lc
[I_GAME_SURV
];
879 s2
:= _lc
[I_GAME_MONSTERS
] + ' ' + IntToStr(gCoopMonstersKilled
) + '/' + IntToStr(gTotalMonsters
);
880 s3
:= _lc
[I_GAME_SECRETS
] + ' ' + IntToStr(gCoopSecretsFound
) + '/' + IntToStr(gSecretsCount
);
891 e_TextureFontPrintEx(x
+(w
div 2)-(Length(s1
)*cw
div 2), _y
, s1
, gStdFont
, 255, 255, 255, 1);
893 e_TextureFontPrintEx(x
+(w
div 2)-(Length(mapstr
)*cw
div 2), _y
, mapstr
, gStdFont
, 200, 200, 200, 1);
895 e_TextureFontPrintEx(x
+16, _y
, s2
, gStdFont
, 200, 200, 200, 1);
897 e_TextureFontPrintEx(x
+w
-16-(Length(s3
))*cw
, _y
, s3
,
898 gStdFont
, 200, 200, 200, 1);
900 if NetMode
= NET_SERVER
then
901 e_TextureFontPrintEx(x
+8, y
+ 8, _lc
[I_NET_SERVER
], gStdFont
, 255, 255, 255, 1)
903 if NetMode
= NET_CLIENT
then
904 e_TextureFontPrintEx(x
+8, y
+ 8,
905 NetClientIP
+ ':' + IntToStr(NetClientPort
), gStdFont
, 255, 255, 255, 1);
909 stat
:= g_Player_GetStats();
912 w2
:= (w
-16) div 6 + 48; // øèðèíà 2 ñòîëáöà
913 w3
:= (w
-16) div 6; // øèðèíà 3 è 4 ñòîëáöîâ
915 w1
:= w
-16-w2
-w3
-w4
; // îñòàâøååñÿ ïðîñòðàíñòâî - äëÿ öâåòà è èìåíè èãðîêà
917 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
921 for a
:= TEAM_RED
to TEAM_BLUE
do
925 s1
:= _lc
[I_GAME_TEAM_RED
];
932 s1
:= _lc
[I_GAME_TEAM_BLUE
];
938 e_TextureFontPrintEx(x
+16, _y
, s1
, gStdFont
, r
, g
, b
, 1);
939 e_TextureFontPrintEx(x
+w1
+16, _y
, IntToStr(gTeamStat
[a
].Goals
),
940 gStdFont
, r
, g
, b
, 1);
942 _y
:= _y
+ch
+(ch
div 4);
943 e_DrawLine(1, x
+16, _y
, x
+w
-16, _y
, r
, g
, b
);
946 for aa
:= 0 to High(stat
) do
947 if stat
[aa
].Team
= a
then
963 e_TextureFontPrintEx(x
+16, _y
, Name
, gStdFont
, rr
, gg
, bb
, 1);
965 e_TextureFontPrintEx(x
+w1
+16, _y
, Format(_lc
[I_GAME_PING_MS
], [Ping
, Loss
]), gStdFont
, rr
, gg
, bb
, 1);
967 e_TextureFontPrintEx(x
+w1
+w2
+16, _y
, IntToStr(Frags
), gStdFont
, rr
, gg
, bb
, 1);
969 e_TextureFontPrintEx(x
+w1
+w2
+w3
+16, _y
, IntToStr(Deaths
), gStdFont
, rr
, gg
, bb
, 1);
976 else if gGameSettings
.GameMode
in [GM_DM
, GM_COOP
] then
979 e_TextureFontPrintEx(x
+16, _y
, _lc
[I_GAME_PLAYER_NAME
], gStdFont
, 255, 127, 0, 1);
980 e_TextureFontPrintEx(x
+16+w1
, _y
, _lc
[I_GAME_PING
], gStdFont
, 255, 127, 0, 1);
981 e_TextureFontPrintEx(x
+16+w1
+w2
, _y
, _lc
[I_GAME_FRAGS
], gStdFont
, 255, 127, 0, 1);
982 e_TextureFontPrintEx(x
+16+w1
+w2
+w3
, _y
, _lc
[I_GAME_DEATHS
], gStdFont
, 255, 127, 0, 1);
985 for aa
:= 0 to High(stat
) do
999 e_DrawFillQuad(x
+16, _y
+4, x
+32-1, _y
+16+4-1, Color
.R
, Color
.G
, Color
.B
, 0);
1000 e_DrawQuad(x
+16, _y
+4, x
+32-1, _y
+16+4-1, 192, 192, 192);
1002 e_TextureFontPrintEx(x
+16+16+8, _y
+4, Name
, gStdFont
, r
, g
, 0, 1);
1004 e_TextureFontPrintEx(x
+w1
+16, _y
+4, Format(_lc
[I_GAME_PING_MS
], [Ping
, Loss
]), gStdFont
, r
, g
, 0, 1);
1006 e_TextureFontPrintEx(x
+w1
+w2
+16, _y
+4, IntToStr(Frags
), gStdFont
, r
, g
, 0, 1);
1008 e_TextureFontPrintEx(x
+w1
+w2
+w3
+16, _y
+4, IntToStr(Deaths
), gStdFont
, r
, g
, 0, 1);
1014 procedure g_Game_Init();
1020 gTempDelete
:= False;
1022 g_Texture_CreateWADEx('MENU_BACKGROUND', GameWAD
+':TEXTURES\TITLE');
1023 g_Texture_CreateWADEx('INTER', GameWAD
+':TEXTURES\INTER');
1024 g_Texture_CreateWADEx('ENDGAME_EN', GameWAD
+':TEXTURES\ENDGAME_EN');
1025 g_Texture_CreateWADEx('ENDGAME_RU', GameWAD
+':TEXTURES\ENDGAME_RU');
1027 LoadStdFont('STDTXT', 'STDFONT', gStdFont
);
1028 LoadFont('MENUTXT', 'MENUFONT', gMenuFont
);
1029 LoadFont('SMALLTXT', 'SMALLFONT', gMenuSmallFont
);
1031 g_Game_ClearLoading();
1032 g_Game_SetLoadingText(Format('Doom 2D: Forever %s', [GAME_VERSION
]), 0, False);
1033 g_Game_SetLoadingText('', 0, False);
1035 g_Game_SetLoadingText(_lc
[I_LOAD_CONSOLE
], 0, False);
1038 g_Game_SetLoadingText(_lc
[I_LOAD_MODELS
], 0, False);
1039 g_PlayerModel_LoadData();
1041 if FindFirst(ModelsDir
+'*.wad', faAnyFile
, SR
) = 0 then
1043 if not g_PlayerModel_Load(ModelsDir
+SR
.Name
) then
1044 e_WriteLog(Format('Error loading model %s', [SR
.Name
]), MSG_WARNING
);
1045 until FindNext(SR
) <> 0;
1051 LastScreenShot
:= 0;
1053 {e_MouseInfo.Accel := 1.0;}
1055 g_Game_SetLoadingText(_lc
[I_LOAD_GAME_DATA
], 0, False);
1058 g_Game_SetLoadingText(_lc
[I_LOAD_MUSIC
], 0, False);
1059 g_Sound_CreateWADEx('MUSIC_INTERMUS', GameWAD
+':MUSIC\INTERMUS', True);
1060 g_Sound_CreateWADEx('MUSIC_MENU', GameWAD
+':MUSIC\MENU', True);
1061 g_Sound_CreateWADEx('MUSIC_ROUNDMUS', GameWAD
+':MUSIC\ROUNDMUS', True);
1062 g_Sound_CreateWADEx('MUSIC_STDENDMUS', GameWAD
+':MUSIC\ENDMUS', True);
1064 g_Game_SetLoadingText(_lc
[I_LOAD_MENUS
], 0, False);
1067 gMusic
:= TMusic
.Create();
1068 gMusic
.SetByName('MUSIC_MENU');
1071 gGameSettings
.WarmupTime
:= 30;
1073 gState
:= STATE_MENU
;
1075 SetLength(gEvents
, 6);
1076 gEvents
[0].Name
:= 'ongamestart';
1077 gEvents
[1].Name
:= 'ongameend';
1078 gEvents
[2].Name
:= 'onmapstart';
1079 gEvents
[3].Name
:= 'onmapend';
1080 gEvents
[4].Name
:= 'oninter';
1081 gEvents
[5].Name
:= 'onwadend';
1084 procedure g_Game_Free();
1086 if NetMode
= NET_CLIENT
then g_Net_Disconnect();
1087 if NetMode
= NET_SERVER
then g_Net_Host_Die();
1091 g_Player_RemoveAllCorpses();
1093 gGameSettings
.GameType
:= GT_NONE
;
1094 if gGameSettings
.GameMode
= GM_SINGLE
then
1095 gGameSettings
.GameMode
:= GM_DM
;
1096 gSwitchGameMode
:= gGameSettings
.GameMode
;
1099 gExitByTrigger
:= False;
1102 function IsActivePlayer(p
: TPlayer
): Boolean;
1107 Result
:= (not p
.FDummy
) and (not p
.FSpectator
);
1110 function GetActivePlayer_ByID(ID
: Integer): TPlayer
;
1117 if gPlayers
= nil then
1119 for a
:= Low(gPlayers
) to High(gPlayers
) do
1120 if IsActivePlayer(gPlayers
[a
]) then
1122 if gPlayers
[a
].UID
<> ID
then
1124 Result
:= gPlayers
[a
];
1129 function GetActivePlayerID_Next(Skip
: Integer = -1): Integer;
1135 if gPlayers
= nil then
1139 for a
:= Low(gPlayers
) to High(gPlayers
) do
1140 if IsActivePlayer(gPlayers
[a
]) then
1142 SetLength(ids
, Length(ids
) + 1);
1143 ids
[High(ids
)] := gPlayers
[a
].UID
;
1144 if gPlayers
[a
].UID
= Skip
then
1147 if Length(ids
) = 0 then
1152 Result
:= ids
[(idx
+ 1) mod Length(ids
)];
1155 function GetActivePlayerID_Prev(Skip
: Integer = -1): Integer;
1161 if gPlayers
= nil then
1165 for a
:= Low(gPlayers
) to High(gPlayers
) do
1166 if IsActivePlayer(gPlayers
[a
]) then
1168 SetLength(ids
, Length(ids
) + 1);
1169 ids
[High(ids
)] := gPlayers
[a
].UID
;
1170 if gPlayers
[a
].UID
= Skip
then
1173 if Length(ids
) = 0 then
1176 Result
:= ids
[Length(ids
) - 1]
1178 Result
:= ids
[(Length(ids
) - 1 + idx
) mod Length(ids
)];
1181 procedure g_Game_Update();
1183 Msg
: g_gui
.TMessage
;
1189 // Ïîðà âûêëþ÷àòü èãðó:
1190 if gExit
= EXIT_QUIT
then
1192 // Èãðà çàêîí÷èëàñü - îáðàáàòûâàåì:
1196 if gExit
= EXIT_QUIT
then
1200 // ×èòàåì êëàâèàòóðó è äæîéñòèê, åñëè îêíî àêòèâíî:
1203 // Îáíîâëÿåì êîíñîëü (äâèæåíèå è ñîîáùåíèÿ):
1206 if (NetMode
= NET_NONE
) and (g_Game_IsNet
) and (gGameOn
or (gState
in [STATE_FOLD
, STATE_INTERCUSTOM
])) then
1208 gExit
:= EXIT_SIMPLE
;
1214 STATE_INTERSINGLE
, // Ñòàòèñòêà ïîñëå ïðîõîæäåíèÿ óðîâíÿ â Îäèíî÷íîé èãðå
1215 STATE_INTERCUSTOM
, // Ñòàòèñòêà ïîñëå ïðîõîæäåíèÿ óðîâíÿ â Ñâîåé èãðå
1216 STATE_INTERTEXT
, // Òåêñò ìåæäó óðîâíÿìè
1217 STATE_INTERPIC
: // Êàðòèíêà ìåæäó óðîâíÿìè
1219 if g_Game_IsNet
and g_Game_IsServer
then
1221 gInterTime
:= gInterTime
+ GAME_TICK
;
1222 a
:= Min((gInterEndTime
- gInterTime
) div 1000 + 1, 255);
1223 if a
<> gServInterTime
then
1225 gServInterTime
:= a
;
1226 MH_SEND_TimeSync(gServInterTime
);
1230 if (not g_Game_IsClient
) and
1233 (e_KeyPressed(IK_RETURN
) or e_KeyPressed(IK_KPRETURN
) or e_KeyPressed(IK_SPACE
))
1234 and (not gJustChatted
) and (not gConsoleShow
) and (not gChatShow
)
1235 and (g_ActiveWindow
= nil)
1237 or (g_Game_IsNet
and (gInterTime
> gInterEndTime
))
1240 begin // Íàæàëè <Enter>/<Ïðîáåë> èëè ïðîøëî äîñòàòî÷íî âðåìåíè:
1241 g_Game_StopAllSounds(True);
1243 if gMapOnce
then // Ýòî áûë òåñò
1244 gExit
:= EXIT_SIMPLE
1246 if gNextMap
<> '' then // Ïåðåõîäèì íà ñëåäóþùóþ êàðòó
1247 g_Game_ChangeMap(gNextMap
)
1248 else // Ñëåäóþùåé êàðòû íåò
1250 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
] then
1252 // Âûõîä â ãëàâíîå ìåíþ:
1254 g_GUI_ShowWindow('MainMenu');
1255 gMusic
.SetByName('MUSIC_MENU');
1257 gState
:= STATE_MENU
;
1260 // Ôèíàëüíàÿ êàðòèíêà:
1261 g_Game_ExecuteEvent('onwadend');
1263 if not gMusic
.SetByName('MUSIC_endmus') then
1264 gMusic
.SetByName('MUSIC_STDENDMUS');
1266 gState
:= STATE_ENDPIC
;
1268 g_Game_ExecuteEvent('ongameend');
1274 if gState
= STATE_INTERTEXT
then
1275 if InterText
.counter
> 0 then
1276 InterText
.counter
:= InterText
.counter
- 1;
1279 STATE_FOLD
: // Çàòóõàíèå ýêðàíà
1281 if EndingGameCounter
= 0 then
1283 // Çàêîí÷èëñÿ óðîâåíü â Ñâîåé èãðå:
1284 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
1286 if gLastMap
and (gGameSettings
.GameMode
= GM_COOP
) then
1288 g_Game_ExecuteEvent('onwadend');
1289 if not gMusic
.SetByName('MUSIC_endmus') then
1290 gMusic
.SetByName('MUSIC_STDENDMUS');
1293 gMusic
.SetByName('MUSIC_ROUNDMUS');
1296 gState
:= STATE_INTERCUSTOM
;
1298 else // Çàêîí÷èëàñü ïîñëåäíÿÿ êàðòà â Îäèíî÷íîé èãðå
1300 gMusic
.SetByName('MUSIC_INTERMUS');
1302 gState
:= STATE_INTERSINGLE
;
1304 g_Game_ExecuteEvent('oninter');
1307 DecMin(EndingGameCounter
, 6, 0);
1310 STATE_ENDPIC
: // Êàðòèíêà îêîí÷àíèÿ ìåãàÂàäà
1312 if gMapOnce
then // Ýòî áûë òåñò
1314 gExit
:= EXIT_SIMPLE
;
1320 g_Serverlist_Control(slCurrent
);
1323 if g_Game_IsNet
then
1324 if not gConsoleShow
then
1325 if not gChatShow
then
1327 if g_ActiveWindow
= nil then
1329 if e_KeyPressed(gGameControls
.GameControls
.Chat
) then
1330 g_Console_Chat_Switch(False)
1331 else if (e_KeyPressed(gGameControls
.GameControls
.TeamChat
)) and
1332 (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
1333 g_Console_Chat_Switch(True);
1336 if not gChatEnter
then
1337 if (not e_KeyPressed(gGameControls
.GameControls
.Chat
))
1338 and (not e_KeyPressed(gGameControls
.GameControls
.TeamChat
)) then
1341 // Ñòàòèñòèêà ïî Tab:
1343 IsDrawStat
:= (not gConsoleShow
) and (not gChatShow
) and
1344 (gGameSettings
.GameType
<> GT_SINGLE
) and
1345 e_KeyPressed(gGameControls
.GameControls
.Stat
);
1348 if gGameOn
and not gPause
and (gState
<> STATE_FOLD
) then
1350 // Âðåìÿ += 28 ìèëëèñåêóíä:
1351 gTime
:= gTime
+ GAME_TICK
;
1353 // Ñîîáùåíèå ïîñåðåäèíå ýêðàíà:
1354 if MessageTime
= 0 then
1356 if MessageTime
> 0 then
1357 MessageTime
:= MessageTime
- 1;
1359 if (g_Game_IsServer
) then
1361 // Áûë çàäàí ëèìèò âðåìåíè:
1362 if (gGameSettings
.TimeLimit
> 0) then
1363 if (gTime
- gGameStartTime
) div 1000 >= gGameSettings
.TimeLimit
then
1364 begin // Îí ïðîøåë => êîíåö óðîâíÿ
1369 // Íàäî ðåñïàâíèòü èãðîêîâ â LMS:
1370 if (gLMSRespawn
> LMS_RESPAWN_NONE
) and (gLMSRespawnTime
< gTime
) then
1371 g_Game_RestartRound(gLMSSoftSpawn
);
1373 // Ïðîâåðèì ðåçóëüòàò ãîëîñîâàíèÿ, åñëè âðåìÿ ïðîøëî
1374 if gVoteInProgress
and (gVoteTimer
< gTime
) then
1376 else if gVotePassed
and (gVoteCmdTimer
< gTime
) then
1378 g_Console_Process(gVoteCommand
);
1380 gVotePassed
:= False;
1383 // Çàìåðÿåì âðåìÿ çàõâàòà ôëàãîâ
1384 if gFlags
[FLAG_RED
].State
= FLAG_STATE_CAPTURED
then
1385 gFlags
[FLAG_RED
].CaptureTime
:= gFlags
[FLAG_RED
].CaptureTime
+ GAME_TICK
;
1386 if gFlags
[FLAG_BLUE
].State
= FLAG_STATE_CAPTURED
then
1387 gFlags
[FLAG_BLUE
].CaptureTime
:= gFlags
[FLAG_BLUE
].CaptureTime
+ GAME_TICK
;
1389 // Áûë çàäàí ëèìèò ïîáåä:
1390 if (gGameSettings
.GoalLimit
> 0) then
1394 if gGameSettings
.GameMode
= GM_DM
then
1395 begin // Â DM èùåì èãðîêà ñ max ôðàãàìè
1396 for i
:= 0 to High(gPlayers
) do
1397 if gPlayers
[i
] <> nil then
1398 if gPlayers
[i
].Frags
> b
then
1399 b
:= gPlayers
[i
].Frags
;
1402 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
1403 begin //  CTF/TDM âûáèðàåì êîìàíäó ñ íàèáîëüøèì ñ÷åòîì
1404 b
:= Max(gTeamStat
[TEAM_RED
].Goals
, gTeamStat
[TEAM_BLUE
].Goals
);
1407 // Ëèìèò ïîáåä íàáðàí => êîíåö óðîâíÿ:
1408 if b
>= gGameSettings
.GoalLimit
then
1415 // Îáðàáàòûâàåì êëàâèøè èãðîêîâ:
1416 if gPlayer1
<> nil then gPlayer1
.ReleaseKeys();
1417 if gPlayer2
<> nil then gPlayer2
.ReleaseKeys();
1418 if (not gConsoleShow
) and (not gChatShow
) and (g_ActiveWindow
= nil) then
1421 if gPlayer1
<> nil then
1422 with gGameControls
.P1Control
do
1424 if e_KeyPressed(KeyLeft
) and (not e_KeyPressed(KeyRight
)) then
1425 P1MoveButton
:= 1 // Íàæàòà òîëüêî "Âëåâî"
1427 if (not e_KeyPressed(KeyLeft
)) and e_KeyPressed(KeyRight
) then
1428 P1MoveButton
:= 2 // Íàæàòà òîëüêî "Âïðàâî"
1430 if (not e_KeyPressed(KeyLeft
)) and (not e_KeyPressed(KeyRight
)) then
1431 P1MoveButton
:= 0; // Íå íàæàòû íè "Âëåâî", íè "Âïðàâî"
1433 // Ñåé÷àñ èëè ðàíüøå áûëè íàæàòû "Âëåâî"/"Âïðàâî" => ïåðåäàåì èãðîêó:
1434 if P1MoveButton
= 1 then
1435 gPlayer1
.PressKey(KEY_LEFT
)
1437 if P1MoveButton
= 2 then
1438 gPlayer1
.PressKey(KEY_RIGHT
);
1440 // Ðàíüøå áûëà íàæàòà "Âïðàâî", à ñåé÷àñ "Âëåâî" => áåæèì âïðàâî, ñìîòðèì âëåâî:
1441 if (P1MoveButton
= 2) and e_KeyPressed(KeyLeft
) then
1442 gPlayer1
.SetDirection(D_LEFT
)
1444 // Ðàíüøå áûëà íàæàòà "Âëåâî", à ñåé÷àñ "Âïðàâî" => áåæèì âëåâî, ñìîòðèì âïðàâî:
1445 if (P1MoveButton
= 1) and e_KeyPressed(KeyRight
) then
1446 gPlayer1
.SetDirection(D_RIGHT
)
1448 // ×òî-òî áûëî íàæàòî è íå èçìåíèëîñü => êóäà áåæèì, òóäà è ñìîòðèì:
1449 if P1MoveButton
<> 0 then
1450 gPlayer1
.SetDirection(TDirection(P1MoveButton
-1));
1452 // Îñòàëüíûå êëàâèøè:
1453 if e_KeyPressed(KeyJump
) then gPlayer1
.PressKey(KEY_JUMP
);
1454 if e_KeyPressed(KeyUp
) then gPlayer1
.PressKey(KEY_UP
);
1455 if e_KeyPressed(KeyDown
) then gPlayer1
.PressKey(KEY_DOWN
);
1456 if e_KeyPressed(KeyFire
) then gPlayer1
.PressKey(KEY_FIRE
);
1457 if e_KeyPressed(KeyNextWeapon
) then gPlayer1
.PressKey(KEY_NEXTWEAPON
);
1458 if e_KeyPressed(KeyPrevWeapon
) then gPlayer1
.PressKey(KEY_PREVWEAPON
);
1459 if e_KeyPressed(KeyOpen
) then gPlayer1
.PressKey(KEY_OPEN
);
1462 if gPlayer2
<> nil then
1463 with gGameControls
.P2Control
do
1465 if e_KeyPressed(KeyLeft
) and (not e_KeyPressed(KeyRight
)) then
1466 P2MoveButton
:= 1 // Íàæàòà òîëüêî "Âëåâî"
1468 if (not e_KeyPressed(KeyLeft
)) and e_KeyPressed(KeyRight
) then
1469 P2MoveButton
:= 2 // Íàæàòà òîëüêî "Âïðàâî"
1471 if (not e_KeyPressed(KeyLeft
)) and (not e_KeyPressed(KeyRight
)) then
1472 P2MoveButton
:= 0; // Íå íàæàòû íè "Âëåâî", íè "Âïðàâî"
1474 // Ñåé÷àñ èëè ðàíüøå áûëè íàæàòû "Âëåâî"/"Âïðàâî" => ïåðåäàåì èãðîêó:
1475 if P2MoveButton
= 1 then
1476 gPlayer2
.PressKey(KEY_LEFT
, 1000)
1478 if P2MoveButton
= 2 then
1479 gPlayer2
.PressKey(KEY_RIGHT
, 1000);
1481 // Ðàíüøå áûëà íàæàòà "Âïðàâî", à ñåé÷àñ "Âëåâî" => áåæèì âïðàâî, ñìîòðèì âëåâî:
1482 if (P2MoveButton
= 2) and e_KeyPressed(KeyLeft
) then
1483 gPlayer2
.SetDirection(D_LEFT
)
1485 // Ðàíüøå áûëà íàæàòà "Âëåâî", à ñåé÷àñ "Âïðàâî" => áåæèì âëåâî, ñìîòðèì âïðàâî:
1486 if (P2MoveButton
= 1) and e_KeyPressed(KeyRight
) then
1487 gPlayer2
.SetDirection(D_RIGHT
)
1489 // ×òî-òî áûëî íàæàòî è íå èçìåíèëîñü => êóäà áåæèì, òóäà è ñìîòðèì:
1490 if P2MoveButton
<> 0 then
1491 gPlayer2
.SetDirection(TDirection(P2MoveButton
-1));
1493 // Îñòàëüíûå êëàâèøè:
1494 if e_KeyPressed(KeyJump
) then gPlayer2
.PressKey(KEY_JUMP
, 1000);
1495 if e_KeyPressed(KeyUp
) then gPlayer2
.PressKey(KEY_UP
, 1000);
1496 if e_KeyPressed(KeyDown
) then gPlayer2
.PressKey(KEY_DOWN
, 1000);
1497 if e_KeyPressed(KeyFire
) then gPlayer2
.PressKey(KEY_FIRE
);
1498 if e_KeyPressed(KeyNextWeapon
) then gPlayer2
.PressKey(KEY_NEXTWEAPON
);
1499 if e_KeyPressed(KeyPrevWeapon
) then gPlayer2
.PressKey(KEY_PREVWEAPON
);
1500 if e_KeyPressed(KeyOpen
) then gPlayer2
.PressKey(KEY_OPEN
);
1502 end // if not console
1504 if g_Game_IsNet
and (gPlayer1
<> nil) then
1505 gPlayer1
.PressKey(KEY_CHAT
, 10000);
1510 if (gPlayer1
= nil) and (gPlayer2
= nil) and
1511 (not gConsoleShow
) and (not gChatShow
) and (g_ActiveWindow
= nil) then
1513 if not gSpectKeyPress
then
1515 if e_KeyPressed(gGameControls
.P1Control
.KeyJump
) then
1517 // switch spect mode
1519 SPECT_NONE
: ; // not spectator
1521 SPECT_MAPVIEW
: Inc(gSpectMode
);
1522 SPECT_PLAYERS
: gSpectMode
:= SPECT_STATS
; // reset to 1
1524 gSpectKeyPress
:= True;
1526 if gSpectMode
= SPECT_MAPVIEW
then
1528 if e_KeyPressed(gGameControls
.P1Control
.KeyLeft
) then
1529 gSpectX
:= Max(gSpectX
- gSpectStep
, 0);
1530 if e_KeyPressed(gGameControls
.P1Control
.KeyRight
) then
1531 gSpectX
:= Min(gSpectX
+ gSpectStep
, gMapInfo
.Width
- gScreenWidth
);
1532 if e_KeyPressed(gGameControls
.P1Control
.KeyUp
) then
1533 gSpectY
:= Max(gSpectY
- gSpectStep
, 0);
1534 if e_KeyPressed(gGameControls
.P1Control
.KeyDown
) then
1535 gSpectY
:= Min(gSpectY
+ gSpectStep
, gMapInfo
.Height
- gScreenHeight
);
1536 if e_KeyPressed(gGameControls
.P1Control
.KeyPrevWeapon
) then
1539 if gSpectStep
> 4 then gSpectStep
:= gSpectStep
shr 1;
1540 gSpectKeyPress
:= True;
1542 if e_KeyPressed(gGameControls
.P1Control
.KeyNextWeapon
) then
1545 if gSpectStep
< 64 then gSpectStep
:= gSpectStep
shl 1;
1546 gSpectKeyPress
:= True;
1549 if gSpectMode
= SPECT_PLAYERS
then
1551 if e_KeyPressed(gGameControls
.P1Control
.KeyUp
) then
1554 gSpectViewTwo
:= True;
1555 gSpectKeyPress
:= True;
1557 if e_KeyPressed(gGameControls
.P1Control
.KeyDown
) then
1559 // remove second view
1560 gSpectViewTwo
:= False;
1561 gSpectKeyPress
:= True;
1563 if e_KeyPressed(gGameControls
.P1Control
.KeyLeft
) then
1565 // prev player (view 1)
1566 gSpectPID1
:= GetActivePlayerID_Prev(gSpectPID1
);
1567 gSpectKeyPress
:= True;
1569 if e_KeyPressed(gGameControls
.P1Control
.KeyRight
) then
1571 // next player (view 1)
1572 gSpectPID1
:= GetActivePlayerID_Next(gSpectPID1
);
1573 gSpectKeyPress
:= True;
1575 if e_KeyPressed(gGameControls
.P1Control
.KeyPrevWeapon
) then
1577 // prev player (view 2)
1578 gSpectPID2
:= GetActivePlayerID_Prev(gSpectPID2
);
1579 gSpectKeyPress
:= True;
1581 if e_KeyPressed(gGameControls
.P1Control
.KeyNextWeapon
) then
1583 // next player (view 2)
1584 gSpectPID2
:= GetActivePlayerID_Next(gSpectPID2
);
1585 gSpectKeyPress
:= True;
1590 if (not e_KeyPressed(gGameControls
.P1Control
.KeyJump
)) and
1591 (not e_KeyPressed(gGameControls
.P1Control
.KeyLeft
)) and
1592 (not e_KeyPressed(gGameControls
.P1Control
.KeyRight
)) and
1593 (not e_KeyPressed(gGameControls
.P1Control
.KeyUp
)) and
1594 (not e_KeyPressed(gGameControls
.P1Control
.KeyDown
)) and
1595 (not e_KeyPressed(gGameControls
.P1Control
.KeyPrevWeapon
)) and
1596 (not e_KeyPressed(gGameControls
.P1Control
.KeyNextWeapon
)) then
1597 gSpectKeyPress
:= False;
1600 // Îáíîâëÿåì âñå îñòàëüíîå:
1603 g_Triggers_Update();
1605 g_Monsters_Update();
1607 g_Player_UpdateAll();
1608 g_Player_UpdatePhysicalObjects();
1609 if gGameSettings
.GameType
= GT_SERVER
then
1610 if Length(gMonstersSpawned
) > 0 then
1612 for I
:= 0 to High(gMonstersSpawned
) do
1613 MH_SEND_MonsterSpawn(gMonstersSpawned
[I
]);
1614 SetLength(gMonstersSpawned
, 0);
1617 if (gSoundTriggerTime
> 8) then
1619 g_Game_UpdateTriggerSounds();
1620 gSoundTriggerTime
:= 0;
1623 Inc(gSoundTriggerTime
);
1625 if (NetMode
= NET_SERVER
) then
1627 Inc(NetTimeToUpdate
);
1628 Inc(NetTimeToReliable
);
1629 if NetTimeToReliable
>= NetRelupdRate
then
1631 for I
:= 0 to High(gPlayers
) do
1632 if gPlayers
[I
] <> nil then
1633 MH_SEND_PlayerPos(True, gPlayers
[I
].UID
);
1635 if gMonsters
<> nil then
1636 for I
:= 0 to High(gMonsters
) do
1637 if gMonsters
[I
] <> nil then
1639 if (gMonsters
[I
].MonsterType
= MONSTER_BARREL
) then
1641 if (gMonsters
[I
].GameVelX
<> 0) or (gMonsters
[I
].GameVelY
<> 0) then
1642 MH_SEND_MonsterPos(gMonsters
[I
].UID
);
1645 if (gMonsters
[I
].MonsterState
<> MONSTATE_SLEEP
) then
1646 if (gMonsters
[I
].MonsterState
<> MONSTATE_DEAD
) or
1647 (gMonsters
[I
].GameVelX
<> 0) or
1648 (gMonsters
[I
].GameVelY
<> 0) then
1649 MH_SEND_MonsterPos(gMonsters
[I
].UID
);
1652 NetTimeToReliable
:= 0;
1653 NetTimeToUpdate
:= NetUpdateRate
;
1655 else if NetTimeToUpdate
>= NetUpdateRate
then
1657 if gPlayers
<> nil then
1658 for I
:= 0 to High(gPlayers
) do
1659 if gPlayers
[I
] <> nil then
1660 MH_SEND_PlayerPos(False, gPlayers
[I
].UID
);
1662 if gMonsters
<> nil then
1663 for I
:= 0 to High(gMonsters
) do
1664 if gMonsters
[I
] <> nil then
1666 if (gMonsters
[I
].MonsterType
= MONSTER_BARREL
) then
1668 if (gMonsters
[I
].GameVelX
<> 0) or (gMonsters
[I
].GameVelY
<> 0) then
1669 MH_SEND_MonsterPos(gMonsters
[I
].UID
);
1672 if (gMonsters
[I
].MonsterState
<> MONSTATE_SLEEP
) then
1673 if (gMonsters
[I
].MonsterState
<> MONSTATE_DEAD
) or
1674 (gMonsters
[I
].GameVelX
<> 0) or
1675 (gMonsters
[I
].GameVelY
<> 0) then
1676 MH_SEND_MonsterPos(gMonsters
[I
].UID
);
1679 NetTimeToUpdate
:= 0;
1682 if NetUseMaster
then
1683 if gTime
>= NetTimeToMaster
then
1685 if (NetMHost
= nil) or (NetMPeer
= nil) then
1686 if not g_Net_Slist_Connect
then
1687 g_Console_Add(_lc
[I_NET_MSG_ERROR
] + _lc
[I_NET_SLIST_ERROR
]);
1690 NetTimeToMaster
:= gTime
+ NetMasterRate
;
1694 if NetMode
= NET_CLIENT
then
1695 MC_SEND_PlayerPos();
1696 end; // if gameOn ...
1698 // Àêòèâíî îêíî èíòåðôåéñà - ïåðåäàåì êëàâèøè åìó:
1699 if g_ActiveWindow
<> nil then
1701 w
:= e_GetFirstKeyPressed();
1703 if (w
<> IK_INVALID
) then
1705 Msg
.Msg
:= MESSAGE_DIKEY
;
1707 g_ActiveWindow
.OnMessage(Msg
);
1710 // Åñëè îíî îò ýòîãî íå çàêðûëîñü, òî îáíîâëÿåì:
1711 if g_ActiveWindow
<> nil then
1712 g_ActiveWindow
.Update();
1714 // Íóæíî ñìåíèòü ðàçðåøåíèå:
1715 if gResolutionChange
then
1717 e_WriteLog('Changing resolution', MSG_NOTIFY
);
1718 g_Game_ChangeResolution(gRC_Width
, gRC_Height
, gRC_FullScreen
, gRC_Maximized
);
1719 gResolutionChange
:= False;
1722 // Íóæíî ñìåíèòü ÿçûê:
1723 if gLanguageChange
then
1725 //e_WriteLog('Read language file', MSG_NOTIFY);
1726 //g_Language_Load(DataDir + gLanguage + '.txt');
1727 g_Language_Set(gLanguage
);
1729 gLanguageChange
:= False;
1733 // Äåëàåì ñêðèíøîò (íå ÷àùå 200 ìèëëèñåêóíä):
1734 if e_KeyPressed(gGameControls
.GameControls
.TakeScreenshot
) then
1735 if (GetTimer()-LastScreenShot
) > 200000 then
1738 LastScreenShot
:= GetTimer();
1741 // Ãîðÿ÷àÿ êëàâèøà äëÿ âûçîâà ìåíþ âûõîäà èç èãðû (F10):
1742 if e_KeyPressed(IK_F10
) and
1744 (not gConsoleShow
) and
1745 (g_ActiveWindow
= nil) then
1750 Time
:= GetTimer() div 1000;
1752 // Îáðàáîòêà îòëîæåííûõ ñîáûòèé:
1753 if gDelayedEvents
<> nil then
1754 for a
:= 0 to High(gDelayedEvents
) do
1755 if gDelayedEvents
[a
].Pending
and
1757 ((gDelayedEvents
[a
].DEType
= DE_GLOBEVENT
) and (gDelayedEvents
[a
].Time
<= Time
)) or
1758 ((gDelayedEvents
[a
].DEType
> DE_GLOBEVENT
) and (gDelayedEvents
[a
].Time
<= gTime
))
1761 case gDelayedEvents
[a
].DEType
of
1763 g_Game_ExecuteEvent(gDelayedEvents
[a
].DEStr
);
1766 g_Game_Announce_GoodShot(gDelayedEvents
[a
].DENum
);
1770 g_Game_Announce_KillCombo(gDelayedEvents
[a
].DENum
);
1771 if g_Game_IsNet
and g_Game_IsServer
then
1772 MH_SEND_GameEvent(NET_EV_KILLCOMBO
, gDelayedEvents
[a
].DENum
);
1775 gDelayedEvents
[a
].Pending
:= False;
1778 // Êàæäóþ ñåêóíäó îáíîâëÿåì ñ÷åò÷èê îáíîâëåíèé:
1779 UPSCounter
:= UPSCounter
+ 1;
1780 if Time
- UPSTime
>= 1000 then
1788 procedure g_Game_LoadData();
1790 if DataLoaded
then Exit
;
1792 e_WriteLog('Loading game data...', MSG_NOTIFY
);
1794 g_Texture_CreateWADEx('NOTEXTURE', GameWAD
+':TEXTURES\NOTEXTURE');
1795 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUD', GameWAD
+':TEXTURES\HUD');
1796 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDAIR', GameWAD
+':TEXTURES\AIRBAR');
1797 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDJET', GameWAD
+':TEXTURES\JETBAR');
1798 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDBG', GameWAD
+':TEXTURES\HUDBG');
1799 g_Texture_CreateWADEx('TEXTURE_PLAYER_ARMORHUD', GameWAD
+':TEXTURES\ARMORHUD');
1800 g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG', GameWAD
+':TEXTURES\FLAGHUD_RB');
1801 g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG_S', GameWAD
+':TEXTURES\FLAGHUD_RS');
1802 g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG_D', GameWAD
+':TEXTURES\FLAGHUD_RD');
1803 g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG', GameWAD
+':TEXTURES\FLAGHUD_BB');
1804 g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG_S', GameWAD
+':TEXTURES\FLAGHUD_BS');
1805 g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG_D', GameWAD
+':TEXTURES\FLAGHUD_BD');
1806 g_Texture_CreateWADEx('TEXTURE_PLAYER_TALKBUBBLE', GameWAD
+':TEXTURES\TALKBUBBLE');
1807 g_Texture_CreateWADEx('TEXTURE_PLAYER_INVULPENTA', GameWAD
+':TEXTURES\PENTA');
1808 g_Frames_CreateWAD(nil, 'FRAMES_TELEPORT', GameWAD
+':TEXTURES\TELEPORT', 64, 64, 10, False);
1809 g_Sound_CreateWADEx('SOUND_GAME_TELEPORT', GameWAD
+':SOUNDS\TELEPORT');
1810 g_Sound_CreateWADEx('SOUND_GAME_NOTELEPORT', GameWAD
+':SOUNDS\NOTELEPORT');
1811 g_Sound_CreateWADEx('SOUND_GAME_DOOROPEN', GameWAD
+':SOUNDS\DOOROPEN');
1812 g_Sound_CreateWADEx('SOUND_GAME_DOORCLOSE', GameWAD
+':SOUNDS\DOORCLOSE');
1813 g_Sound_CreateWADEx('SOUND_GAME_BULK1', GameWAD
+':SOUNDS\BULK1');
1814 g_Sound_CreateWADEx('SOUND_GAME_BULK2', GameWAD
+':SOUNDS\BULK2');
1815 g_Sound_CreateWADEx('SOUND_GAME_BUBBLE1', GameWAD
+':SOUNDS\BUBBLE1');
1816 g_Sound_CreateWADEx('SOUND_GAME_BUBBLE2', GameWAD
+':SOUNDS\BUBBLE2');
1817 g_Sound_CreateWADEx('SOUND_GAME_SWITCH1', GameWAD
+':SOUNDS\SWITCH1');
1818 g_Sound_CreateWADEx('SOUND_GAME_SWITCH0', GameWAD
+':SOUNDS\SWITCH0');
1819 g_Sound_CreateWADEx('SOUND_GAME_RADIO', GameWAD
+':SOUNDS\RADIO');
1820 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD1', GameWAD
+':SOUNDS\GOOD1');
1821 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD2', GameWAD
+':SOUNDS\GOOD2');
1822 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD3', GameWAD
+':SOUNDS\GOOD3');
1823 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD4', GameWAD
+':SOUNDS\GOOD4');
1824 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL2X', GameWAD
+':SOUNDS\KILL2X');
1825 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL3X', GameWAD
+':SOUNDS\KILL3X');
1826 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL4X', GameWAD
+':SOUNDS\KILL4X');
1827 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILLMX', GameWAD
+':SOUNDS\KILLMX');
1829 goodsnd
[0] := TPlayableSound
.Create();
1830 goodsnd
[1] := TPlayableSound
.Create();
1831 goodsnd
[2] := TPlayableSound
.Create();
1832 goodsnd
[3] := TPlayableSound
.Create();
1834 goodsnd
[0].SetByName('SOUND_ANNOUNCER_GOOD1');
1835 goodsnd
[1].SetByName('SOUND_ANNOUNCER_GOOD2');
1836 goodsnd
[2].SetByName('SOUND_ANNOUNCER_GOOD3');
1837 goodsnd
[3].SetByName('SOUND_ANNOUNCER_GOOD4');
1839 killsnd
[0] := TPlayableSound
.Create();
1840 killsnd
[1] := TPlayableSound
.Create();
1841 killsnd
[2] := TPlayableSound
.Create();
1842 killsnd
[3] := TPlayableSound
.Create();
1844 killsnd
[0].SetByName('SOUND_ANNOUNCER_KILL2X');
1845 killsnd
[1].SetByName('SOUND_ANNOUNCER_KILL3X');
1846 killsnd
[2].SetByName('SOUND_ANNOUNCER_KILL4X');
1847 killsnd
[3].SetByName('SOUND_ANNOUNCER_KILLMX');
1849 g_Game_SetLoadingText(_lc
[I_LOAD_ITEMS_DATA
], 0, False);
1852 g_Game_SetLoadingText(_lc
[I_LOAD_WEAPONS_DATA
], 0, False);
1853 g_Weapon_LoadData();
1855 g_Monsters_LoadData();
1860 procedure g_Game_FreeData();
1862 if not DataLoaded
then Exit
;
1865 g_Weapon_FreeData();
1866 g_Monsters_FreeData();
1868 e_WriteLog('Releasing game data...', MSG_NOTIFY
);
1870 g_Texture_Delete('NOTEXTURE');
1871 g_Texture_Delete('TEXTURE_PLAYER_HUD');
1872 g_Texture_Delete('TEXTURE_PLAYER_HUDBG');
1873 g_Texture_Delete('TEXTURE_PLAYER_ARMORHUD');
1874 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG');
1875 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG_S');
1876 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG_D');
1877 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG');
1878 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG_S');
1879 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG_D');
1880 g_Texture_Delete('TEXTURE_PLAYER_TALKBUBBLE');
1881 g_Texture_Delete('TEXTURE_PLAYER_INVULPENTA');
1882 g_Frames_DeleteByName('FRAMES_TELEPORT');
1883 g_Sound_Delete('SOUND_GAME_TELEPORT');
1884 g_Sound_Delete('SOUND_GAME_NOTELEPORT');
1885 g_Sound_Delete('SOUND_GAME_DOOROPEN');
1886 g_Sound_Delete('SOUND_GAME_DOORCLOSE');
1887 g_Sound_Delete('SOUND_GAME_BULK1');
1888 g_Sound_Delete('SOUND_GAME_BULK2');
1889 g_Sound_Delete('SOUND_GAME_BUBBLE1');
1890 g_Sound_Delete('SOUND_GAME_BUBBLE2');
1891 g_Sound_Delete('SOUND_GAME_SWITCH1');
1892 g_Sound_Delete('SOUND_GAME_SWITCH0');
1899 g_Sound_Delete('SOUND_ANNOUNCER_GOOD1');
1900 g_Sound_Delete('SOUND_ANNOUNCER_GOOD2');
1901 g_Sound_Delete('SOUND_ANNOUNCER_GOOD3');
1902 g_Sound_Delete('SOUND_ANNOUNCER_GOOD4');
1909 g_Sound_Delete('SOUND_ANNOUNCER_KILL2X');
1910 g_Sound_Delete('SOUND_ANNOUNCER_KILL3X');
1911 g_Sound_Delete('SOUND_ANNOUNCER_KILL4X');
1912 g_Sound_Delete('SOUND_ANNOUNCER_KILLMX');
1914 DataLoaded
:= False;
1917 procedure DrawCustomStat();
1923 ww2
, hh2
, r
, g
, b
, rr
, gg
, bb
: Byte;
1924 s1
, s2
, topstr
: String;
1926 e_TextureFontGetSize(gStdFont
, ww2
, hh2
);
1929 if e_KeyPressed(IK_TAB
) then
1931 if not gStatsPressed
then
1933 gStatsOff
:= not gStatsOff
;
1934 gStatsPressed
:= True;
1938 gStatsPressed
:= False;
1942 s1
:= _lc
[I_MENU_INTER_NOTICE_TAB
];
1943 w
:= (Length(s1
) * ww2
) div 2;
1944 x
:= gScreenWidth
div 2 - w
;
1946 e_TextureFontPrint(x
, y
, s1
, gStdFont
);
1950 if (gGameSettings
.GameMode
= GM_COOP
) then
1952 if gMissionFailed
then
1953 topstr
:= _lc
[I_MENU_INTER_MISSION_FAIL
]
1955 topstr
:= _lc
[I_MENU_INTER_LEVEL_COMPLETE
];
1958 topstr
:= _lc
[I_MENU_INTER_ROUND_OVER
];
1960 e_CharFont_GetSize(gMenuFont
, topstr
, ww1
, hh1
);
1961 e_CharFont_Print(gMenuFont
, (gScreenWidth
div 2)-(ww1
div 2), 16, topstr
);
1963 if g_Game_IsNet
then
1965 topstr
:= Format(_lc
[I_MENU_INTER_NOTICE_TIME
], [gServInterTime
]);
1966 if not gChatShow
then
1967 e_TextureFontPrintEx((gScreenWidth
div 2)-(Length(topstr
)*ww2
div 2),
1968 gScreenHeight
-(hh2
+4)*2, topstr
, gStdFont
, 255, 255, 255, 1);
1971 if g_Game_IsClient
then
1972 topstr
:= _lc
[I_MENU_INTER_NOTICE_MAP
]
1974 topstr
:= _lc
[I_MENU_INTER_NOTICE_SPACE
];
1975 if not gChatShow
then
1976 e_TextureFontPrintEx((gScreenWidth
div 2)-(Length(topstr
)*ww2
div 2),
1977 gScreenHeight
-(hh2
+4), topstr
, gStdFont
, 255, 255, 255, 1);
1982 w
:= gScreenWidth
-x
*2;
1988 e_DrawFillQuad(x
, y
, gScreenWidth
-x
-1, gScreenHeight
-y
-1, 64, 64, 64, 32);
1989 e_DrawQuad(x
, y
, gScreenWidth
-x
-1, gScreenHeight
-y
-1, 255, 127, 0);
1991 m
:= Max(Length(_lc
[I_MENU_MAP
])+1, Length(_lc
[I_GAME_GAME_TIME
])+1)*ww2
;
1993 case CustomStat
.GameMode
of
1996 if gGameSettings
.MaxLives
= 0 then
1997 s1
:= _lc
[I_GAME_DM
]
1999 s1
:= _lc
[I_GAME_LMS
];
2003 if gGameSettings
.MaxLives
= 0 then
2004 s1
:= _lc
[I_GAME_TDM
]
2006 s1
:= _lc
[I_GAME_TLMS
];
2008 GM_CTF
: s1
:= _lc
[I_GAME_CTF
];
2011 if gGameSettings
.MaxLives
= 0 then
2012 s1
:= _lc
[I_GAME_COOP
]
2014 s1
:= _lc
[I_GAME_SURV
];
2020 e_TextureFontPrintEx(x
+(w
div 2)-(Length(s1
)*ww2
div 2), _y
, s1
, gStdFont
, 255, 255, 255, 1);
2024 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_MENU_MAP
], gStdFont
, 255, 127, 0, 1);
2025 e_TextureFontPrint(x
+8+m
, _y
, Format('%s - %s', [CustomStat
.Map
, CustomStat
.MapName
]), gStdFont
);
2028 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_GAME_TIME
], gStdFont
, 255, 127, 0, 1);
2029 e_TextureFontPrint(x
+8+m
, _y
, Format('%d:%.2d:%.2d', [CustomStat
.GameTime
div 1000 div 3600,
2030 (CustomStat
.GameTime
div 1000 div 60) mod 60,
2031 CustomStat
.GameTime
div 1000 mod 60]), gStdFont
);
2033 pc
:= Length(CustomStat
.PlayerStat
);
2034 if pc
= 0 then Exit
;
2036 if CustomStat
.GameMode
= GM_COOP
then
2038 m
:= Max(Length(_lc
[I_GAME_MONSTERS
])+1, Length(_lc
[I_GAME_SECRETS
])+1)*ww2
;
2040 s2
:= _lc
[I_GAME_MONSTERS
];
2041 e_TextureFontPrintEx(x
+8, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2042 e_TextureFontPrintEx(x
+8+m
, _y
, IntToStr(gCoopMonstersKilled
) + '/' + IntToStr(gTotalMonsters
), gStdFont
, 255, 255, 255, 1);
2044 s2
:= _lc
[I_GAME_SECRETS
];
2045 e_TextureFontPrintEx(x
+8, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2046 e_TextureFontPrintEx(x
+8+m
, _y
, IntToStr(gCoopSecretsFound
) + '/' + IntToStr(gSecretsCount
), gStdFont
, 255, 255, 255, 1);
2049 m
:= Max(Length(_lc
[I_GAME_MONSTERS_TOTAL
])+1, Length(_lc
[I_GAME_SECRETS_TOTAL
])+1)*ww2
;
2051 s2
:= _lc
[I_GAME_MONSTERS_TOTAL
];
2052 e_TextureFontPrintEx(x
+250, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2053 e_TextureFontPrintEx(x
+250+m
, _y
, IntToStr(gCoopTotalMonstersKilled
) + '/' + IntToStr(gCoopTotalMonsters
), gStdFont
, 255, 255, 255, 1);
2055 s2
:= _lc
[I_GAME_SECRETS_TOTAL
];
2056 e_TextureFontPrintEx(x
+250, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2057 e_TextureFontPrintEx(x
+250+m
, _y
, IntToStr(gCoopTotalSecretsFound
) + '/' + IntToStr(gCoopTotalSecrets
), gStdFont
, 255, 255, 255, 1);
2061 if CustomStat
.GameMode
in [GM_TDM
, GM_CTF
] then
2066 if TeamStat
[TEAM_RED
].Goals
> TeamStat
[TEAM_BLUE
].Goals
then s1
:= _lc
[I_GAME_WIN_RED
]
2067 else if TeamStat
[TEAM_BLUE
].Goals
> TeamStat
[TEAM_RED
].Goals
then s1
:= _lc
[I_GAME_WIN_BLUE
]
2068 else s1
:= _lc
[I_GAME_WIN_DRAW
];
2070 e_TextureFontPrintEx(x
+8+(w
div 2)-(Length(s1
)*ww2
div 2), _y
, s1
, gStdFont
, 255, 255, 255, 1);
2073 for t
:= TEAM_RED
to TEAM_BLUE
do
2075 if t
= TEAM_RED
then
2077 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_TEAM_RED
],
2078 gStdFont
, 255, 0, 0, 1);
2079 e_TextureFontPrintEx(x
+w1
+8, _y
, IntToStr(CustomStat
.TeamStat
[TEAM_RED
].Goals
),
2080 gStdFont
, 255, 0, 0, 1);
2087 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_TEAM_BLUE
],
2088 gStdFont
, 0, 0, 255, 1);
2089 e_TextureFontPrintEx(x
+w1
+8, _y
, IntToStr(CustomStat
.TeamStat
[TEAM_BLUE
].Goals
),
2090 gStdFont
, 0, 0, 255, 1);
2096 e_DrawLine(1, x
+8, _y
+20, x
-8+w
, _y
+20, r
, g
, b
);
2099 for p
:= 0 to High(CustomStat
.PlayerStat
) do
2100 if CustomStat
.PlayerStat
[p
].Team
= t
then
2101 with CustomStat
.PlayerStat
[p
] do
2115 e_TextureFontPrintEx(x
+8, _y
, Name
, gStdFont
, rr
, gg
, bb
, 1);
2116 e_TextureFontPrintEx(x
+w1
+8, _y
, IntToStr(Frags
), gStdFont
, rr
, gg
, bb
, 1);
2117 e_TextureFontPrintEx(x
+w1
+w2
+8, _y
, IntToStr(Deaths
), gStdFont
, rr
, gg
, bb
, 1);
2124 else if CustomStat
.GameMode
in [GM_DM
, GM_COOP
] then
2127 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_PLAYER_NAME
], gStdFont
, 255, 127, 0, 1);
2128 e_TextureFontPrintEx(x
+8+w1
, _y
, _lc
[I_GAME_FRAGS
], gStdFont
, 255, 127, 0, 1);
2129 e_TextureFontPrintEx(x
+8+w1
+w2
, _y
, _lc
[I_GAME_DEATHS
], gStdFont
, 255, 127, 0, 1);
2132 for p
:= 0 to High(CustomStat
.PlayerStat
) do
2133 with CustomStat
.PlayerStat
[p
] do
2135 e_DrawFillQuad(x
+8, _y
+4, x
+24-1, _y
+16+4-1, Color
.R
, Color
.G
, Color
.B
, 0);
2142 e_TextureFontPrintEx(x
+8+16+8, _y
+4, Name
, gStdFont
, r
, r
, r
, 1, True);
2143 e_TextureFontPrintEx(x
+w1
+8+16+8, _y
+4, IntToStr(Frags
), gStdFont
, r
, r
, r
, 1, True);
2144 e_TextureFontPrintEx(x
+w1
+w2
+8+16+8, _y
+4, IntToStr(Deaths
), gStdFont
, r
, r
, r
, 1, True);
2150 procedure DrawSingleStat();
2152 tm
, key_x
, val_x
, y
: Integer;
2156 procedure player_stat(n
: Integer);
2162 s1
:= Format(' %d ', [SingleStat
.PlayerStat
[n
].Kills
]);
2163 s2
:= Format(' %d', [gTotalMonsters
]);
2165 e_CharFont_Print(gMenuFont
, key_x
, y
, _lc
[I_MENU_INTER_KILLS
]);
2166 e_CharFont_PrintEx(gMenuFont
, val_x
, y
, s1
, _RGB(255, 0, 0));
2167 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2168 e_CharFont_Print(gMenuFont
, val_x
+w1
, y
, '/');
2170 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2171 e_CharFont_PrintEx(gMenuFont
, val_x
+w1
, y
, s2
, _RGB(255, 0, 0));
2173 // "Kills-per-minute: ##.#":
2174 s1
:= _lc
[I_MENU_INTER_KPM
];
2176 kpm
:= (SingleStat
.PlayerStat
[n
].Kills
/ tm
) * 60
2178 kpm
:= SingleStat
.PlayerStat
[n
].Kills
;
2179 s2
:= Format(' %.1f', [kpm
]);
2181 e_CharFont_Print(gMenuFont
, key_x
, y
+32, s1
);
2182 e_CharFont_PrintEx(gMenuFont
, val_x
, y
+32, s2
, _RGB(255, 0, 0));
2184 // "Secrets found: # / #":
2185 s1
:= Format(' %d ', [SingleStat
.PlayerStat
[n
].Secrets
]);
2186 s2
:= Format(' %d', [SingleStat
.TotalSecrets
]);
2188 e_CharFont_Print(gMenuFont
, key_x
, y
+64, _lc
[I_MENU_INTER_SECRETS
]);
2189 e_CharFont_PrintEx(gMenuFont
, val_x
, y
+64, s1
, _RGB(255, 0, 0));
2190 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2191 e_CharFont_Print(gMenuFont
, val_x
+w1
, y
+64, '/');
2193 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2194 e_CharFont_PrintEx(gMenuFont
, val_x
+w1
, y
+64, s2
, _RGB(255, 0, 0));
2198 // "Level Complete":
2199 e_CharFont_GetSize(gMenuFont
, _lc
[I_MENU_INTER_LEVEL_COMPLETE
], w1
, h
);
2200 e_CharFont_Print(gMenuFont
, (gScreenWidth
-w1
) div 2, 32, _lc
[I_MENU_INTER_LEVEL_COMPLETE
]);
2202 // Îïðåäåëÿåì êîîðäèíàòû âûðàâíèâàíèÿ ïî ñàìîé äëèííîé ñòðîêå:
2203 s1
:= _lc
[I_MENU_INTER_KPM
];
2204 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2207 e_CharFont_GetSize(gMenuFont
, s1
, w2
, h
);
2209 key_x
:= (gScreenWidth
-w1
-w2
) div 2;
2210 val_x
:= key_x
+ w1
;
2213 tm
:= SingleStat
.GameTime
div 1000;
2214 s1
:= _lc
[I_MENU_INTER_TIME
];
2215 s2
:= Format(' %d:%.2d:%.2d', [tm
div (60*60), (tm
mod (60*60)) div 60, tm
mod 60]);
2217 e_CharFont_Print(gMenuFont
, key_x
, 80, s1
);
2218 e_CharFont_PrintEx(gMenuFont
, val_x
, 80, s2
, _RGB(255, 0, 0));
2220 if SingleStat
.TwoPlayers
then
2223 s1
:= _lc
[I_MENU_PLAYER_1
];
2224 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2225 e_CharFont_Print(gMenuFont
, (gScreenWidth
-w1
) div 2, 128, s1
);
2227 // Ñòàòèñòèêà ïåðâîãî èãðîêà:
2232 s1
:= _lc
[I_MENU_PLAYER_2
];
2233 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2234 e_CharFont_Print(gMenuFont
, (gScreenWidth
-w1
) div 2, 288, s1
);
2236 // Ñòàòèñòèêà âòîðîãî èãðîêà:
2242 // Ñòàòèñòèêà ïåðâîãî èãðîêà:
2248 procedure DrawLoadingStat();
2254 if Length(LoadingStat
.Msgs
) = 0 then
2257 e_CharFont_GetSize(gMenuFont
, _lc
[I_MENU_LOADING
], ww
, hh
);
2258 yy
:= (gScreenHeight
div 3);
2259 e_CharFont_Print(gMenuFont
, (gScreenWidth
div 2)-(ww
div 2), yy
-2*hh
, _lc
[I_MENU_LOADING
]);
2260 xx
:= (gScreenWidth
div 3);
2263 for i
:= 0 to NextMsg
-1 do
2265 if (i
= (NextMsg
-1)) and (MaxValue
> 0) then
2266 s
:= Format('%s: %d/%d', [Msgs
[i
], CurValue
, MaxValue
])
2270 e_CharFont_PrintEx(gMenuSmallFont
, xx
, yy
, s
, _RGB(255, 0, 0));
2271 yy
:= yy
+ LOADING_INTERLINE
;
2275 procedure DrawMinimap(p
: TPlayer
; RenderRect
: TRect
);
2277 a
, aX
, aY
, aX2
, aY2
, Scale
, ScaleSz
: Integer;
2279 if (gMapInfo
.Width
> RenderRect
.Right
- RenderRect
.Left
) or
2280 (gMapInfo
.Height
> RenderRect
.Bottom
- RenderRect
.Top
) then
2283 // Ñêîëüêî ïèêñåëîâ êàðòû â 1 ïèêñåëå ìèíè-êàðòû:
2284 ScaleSz
:= 16 div Scale
;
2285 // Ðàçìåðû ìèíè-êàðòû:
2286 aX
:= max(gMapInfo
.Width
div ScaleSz
, 1);
2287 aY
:= max(gMapInfo
.Height
div ScaleSz
, 1);
2289 e_DrawFillQuad(0, 0, aX
-1, aY
-1, 0, 0, 0, 0);
2291 if gWalls
<> nil then
2294 for a
:= 0 to High(gWalls
) do
2296 if PanelType
<> 0 then
2298 // Ëåâûé âåðõíèé óãîë:
2299 aX
:= X
div ScaleSz
;
2300 aY
:= Y
div ScaleSz
;
2302 aX2
:= max(Width
div ScaleSz
, 1);
2303 aY2
:= max(Height
div ScaleSz
, 1);
2304 // Ïðàâûé íèæíèé óãîë:
2305 aX2
:= aX
+ aX2
- 1;
2306 aY2
:= aY
+ aY2
- 1;
2309 PANEL_WALL
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 208, 208, 208, 0);
2310 PANEL_OPENDOOR
, PANEL_CLOSEDOOR
:
2311 if Enabled
then e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 160, 160, 160, 0);
2315 if gSteps
<> nil then
2318 for a
:= 0 to High(gSteps
) do
2320 if PanelType
<> 0 then
2322 // Ëåâûé âåðõíèé óãîë:
2323 aX
:= X
div ScaleSz
;
2324 aY
:= Y
div ScaleSz
;
2326 aX2
:= max(Width
div ScaleSz
, 1);
2327 aY2
:= max(Height
div ScaleSz
, 1);
2328 // Ïðàâûé íèæíèé óãîë:
2329 aX2
:= aX
+ aX2
- 1;
2330 aY2
:= aY
+ aY2
- 1;
2332 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 128, 128, 128, 0);
2335 if gLifts
<> nil then
2338 for a
:= 0 to High(gLifts
) do
2340 if PanelType
<> 0 then
2342 // Ëåâûé âåðõíèé óãîë:
2343 aX
:= X
div ScaleSz
;
2344 aY
:= Y
div ScaleSz
;
2346 aX2
:= max(Width
div ScaleSz
, 1);
2347 aY2
:= max(Height
div ScaleSz
, 1);
2348 // Ïðàâûé íèæíèé óãîë:
2349 aX2
:= aX
+ aX2
- 1;
2350 aY2
:= aY
+ aY2
- 1;
2353 0: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 116, 72, 36, 0);
2354 1: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 116, 124, 96, 0);
2355 2: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 200, 80, 4, 0);
2356 3: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 252, 140, 56, 0);
2360 if gWater
<> nil then
2363 for a
:= 0 to High(gWater
) do
2365 if PanelType
<> 0 then
2367 // Ëåâûé âåðõíèé óãîë:
2368 aX
:= X
div ScaleSz
;
2369 aY
:= Y
div ScaleSz
;
2371 aX2
:= max(Width
div ScaleSz
, 1);
2372 aY2
:= max(Height
div ScaleSz
, 1);
2373 // Ïðàâûé íèæíèé óãîë:
2374 aX2
:= aX
+ aX2
- 1;
2375 aY2
:= aY
+ aY2
- 1;
2377 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 0, 192, 0);
2380 if gAcid1
<> nil then
2382 // Ðèñóåì êèñëîòó 1:
2383 for a
:= 0 to High(gAcid1
) do
2385 if PanelType
<> 0 then
2387 // Ëåâûé âåðõíèé óãîë:
2388 aX
:= X
div ScaleSz
;
2389 aY
:= Y
div ScaleSz
;
2391 aX2
:= max(Width
div ScaleSz
, 1);
2392 aY2
:= max(Height
div ScaleSz
, 1);
2393 // Ïðàâûé íèæíèé óãîë:
2394 aX2
:= aX
+ aX2
- 1;
2395 aY2
:= aY
+ aY2
- 1;
2397 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 176, 0, 0);
2400 if gAcid2
<> nil then
2402 // Ðèñóåì êèñëîòó 2:
2403 for a
:= 0 to High(gAcid2
) do
2405 if PanelType
<> 0 then
2407 // Ëåâûé âåðõíèé óãîë:
2408 aX
:= X
div ScaleSz
;
2409 aY
:= Y
div ScaleSz
;
2411 aX2
:= max(Width
div ScaleSz
, 1);
2412 aY2
:= max(Height
div ScaleSz
, 1);
2413 // Ïðàâûé íèæíèé óãîë:
2414 aX2
:= aX
+ aX2
- 1;
2415 aY2
:= aY
+ aY2
- 1;
2417 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 176, 0, 0, 0);
2420 if gPlayers
<> nil then
2423 for a
:= 0 to High(gPlayers
) do
2424 if gPlayers
[a
] <> nil then with gPlayers
[a
] do
2426 // Ëåâûé âåðõíèé óãîë:
2427 aX
:= Obj
.X
div ScaleSz
+ 1;
2428 aY
:= Obj
.Y
div ScaleSz
+ 1;
2430 aX2
:= max(Obj
.Rect
.Width
div ScaleSz
, 1);
2431 aY2
:= max(Obj
.Rect
.Height
div ScaleSz
, 1);
2432 // Ïðàâûé íèæíèé óãîë:
2433 aX2
:= aX
+ aX2
- 1;
2434 aY2
:= aY
+ aY2
- 1;
2436 if gPlayers
[a
] = p
then
2437 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 255, 0, 0)
2440 TEAM_RED
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 0, 0, 0);
2441 TEAM_BLUE
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 0, 255, 0);
2442 else e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 128, 0, 0);
2446 if gMonsters
<> nil then
2449 for a
:= 0 to High(gMonsters
) do
2450 if gMonsters
[a
] <> nil then with gMonsters
[a
] do
2452 // Ëåâûé âåðõíèé óãîë:
2453 aX
:= Obj
.X
div ScaleSz
+ 1;
2454 aY
:= Obj
.Y
div ScaleSz
+ 1;
2456 aX2
:= max(Obj
.Rect
.Width
div ScaleSz
, 1);
2457 aY2
:= max(Obj
.Rect
.Height
div ScaleSz
, 1);
2458 // Ïðàâûé íèæíèé óãîë:
2459 aX2
:= aX
+ aX2
- 1;
2460 aY2
:= aY
+ aY2
- 1;
2462 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 255, 0, 0);
2468 procedure DrawMapView(x
, y
, w
, h
: Integer);
2474 bx
:= Round(x
/(gMapInfo
.Width
- w
)*(gBackSize
.X
- w
));
2475 by
:= Round(y
/(gMapInfo
.Height
- h
)*(gBackSize
.Y
- h
));
2476 g_Map_DrawBack(-bx
, -by
);
2483 glTranslatef(-x
, -y
, 0);
2485 g_Map_DrawPanels(PANEL_BACK
);
2486 g_Map_DrawPanels(PANEL_STEP
);
2489 g_Player_DrawShells();
2491 g_Player_DrawCorpses();
2492 g_Map_DrawPanels(PANEL_WALL
);
2494 g_Map_DrawPanels(PANEL_CLOSEDOOR
);
2497 g_Map_DrawPanels(PANEL_ACID1
);
2498 g_Map_DrawPanels(PANEL_ACID2
);
2499 g_Map_DrawPanels(PANEL_WATER
);
2500 g_Map_DrawPanels(PANEL_FORE
);
2501 if g_debug_HealthBar
then
2503 g_Monsters_DrawHealth();
2504 g_Player_DrawHealth();
2510 procedure DrawPlayer(p
: TPlayer
);
2512 px
, py
, a
, b
, c
, d
: Integer;
2515 if (p
= nil) or (p
.FDummy
) then
2518 g_Map_DrawBack(0, 0);
2527 px
:= p
.GameX
+ PLAYER_RECT_CX
;
2528 py
:= p
.GameY
+ PLAYER_RECT_CY
;
2530 if px
> (gPlayerScreenSize
.X
div 2) then
2531 a
:= -px
+ (gPlayerScreenSize
.X
div 2)
2534 if py
> (gPlayerScreenSize
.Y
div 2) then
2535 b
:= -py
+ (gPlayerScreenSize
.Y
div 2)
2538 if px
> (gMapInfo
.Width
- (gPlayerScreenSize
.X
div 2)) then
2539 a
:= -gMapInfo
.Width
+ gPlayerScreenSize
.X
;
2540 if py
> (gMapInfo
.Height
- (gPlayerScreenSize
.Y
div 2)) then
2541 b
:= -gMapInfo
.Height
+ gPlayerScreenSize
.Y
;
2542 if gMapInfo
.Width
<= gPlayerScreenSize
.X
then
2544 if gMapInfo
.Height
<= gPlayerScreenSize
.Y
then
2547 if p
.IncCam
<> 0 then
2549 if py
> (gMapInfo
.Height
- (gPlayerScreenSize
.Y
div 2)) then
2551 if p
.IncCam
> 120-(py
-(gMapInfo
.Height
-(gPlayerScreenSize
.Y
div 2))) then
2552 p
.IncCam
:= 120-(py
-(gMapInfo
.Height
-(gPlayerScreenSize
.Y
div 2)));
2555 if py
< (gPlayerScreenSize
.Y
div 2) then
2557 if p
.IncCam
< -120+((gPlayerScreenSize
.Y
div 2)-py
) then
2558 p
.IncCam
:= -120+((gPlayerScreenSize
.Y
div 2)-py
);
2561 if p
.IncCam
< 0 then
2562 while (py
+(gPlayerScreenSize
.Y
div 2)-p
.IncCam
> gMapInfo
.Height
) and
2564 p
.IncCam
:= p
.IncCam
+ 1;
2566 if p
.IncCam
> 0 then
2567 while (py
-(gPlayerScreenSize
.Y
div 2)-p
.IncCam
< 0) and
2569 p
.IncCam
:= p
.IncCam
- 1;
2572 if (px
< gPlayerScreenSize
.X
div 2) or
2573 (gMapInfo
.Width
-gPlayerScreenSize
.X
<= 256) then
2576 if (px
> gMapInfo
.Width
-(gPlayerScreenSize
.X
div 2)) then
2577 c
:= gBackSize
.X
- gPlayerScreenSize
.X
2579 c
:= Round((px
-(gPlayerScreenSize
.X
div 2))/(gMapInfo
.Width
-gPlayerScreenSize
.X
)*(gBackSize
.X
-gPlayerScreenSize
.X
));
2581 if (py
-p
.IncCam
<= gPlayerScreenSize
.Y
div 2) or
2582 (gMapInfo
.Height
-gPlayerScreenSize
.Y
<= 256) then
2585 if (py
-p
.IncCam
>= gMapInfo
.Height
-(gPlayerScreenSize
.Y
div 2)) then
2586 d
:= gBackSize
.Y
- gPlayerScreenSize
.Y
2588 d
:= Round((py
-p
.IncCam
-(gPlayerScreenSize
.Y
div 2))/(gMapInfo
.Height
-gPlayerScreenSize
.Y
)*(gBackSize
.Y
-gPlayerScreenSize
.Y
));
2590 g_Map_DrawBack(-c
, -d
);
2593 sY
:= -(b
+p
.IncCam
);
2594 sWidth
:= gPlayerScreenSize
.X
;
2595 sHeight
:= gPlayerScreenSize
.Y
;
2597 glTranslatef(a
, b
+p
.IncCam
, 0);
2599 g_Map_DrawPanels(PANEL_BACK
);
2600 g_Map_DrawPanels(PANEL_STEP
);
2603 g_Player_DrawShells();
2605 g_Player_DrawCorpses();
2606 g_Map_DrawPanels(PANEL_WALL
);
2608 g_Map_DrawPanels(PANEL_CLOSEDOOR
);
2611 g_Map_DrawPanels(PANEL_ACID1
);
2612 g_Map_DrawPanels(PANEL_ACID2
);
2613 g_Map_DrawPanels(PANEL_WATER
);
2614 g_Map_DrawPanels(PANEL_FORE
);
2615 if g_debug_HealthBar
then
2617 g_Monsters_DrawHealth();
2618 g_Player_DrawHealth();
2621 if p
.FSpectator
then
2622 e_TextureFontPrintEx(p
.GameX
+ PLAYER_RECT_CX
- 4,
2623 p
.GameY
+ PLAYER_RECT_CY
- 4,
2624 'X', gStdFont
, 255, 255, 255, 1, True);
2626 for a := 0 to High(gCollideMap) do
2627 for b := 0 to High(gCollideMap[a]) do
2630 if ByteBool(gCollideMap[a, b] and MARK_WALL) then
2632 if ByteBool(gCollideMap[a, b] and MARK_DOOR) then
2636 1: e_DrawPoint(1, b, a, 200, 200, 200);
2637 2: e_DrawPoint(1, b, a, 64, 64, 255);
2638 3: e_DrawPoint(1, b, a, 255, 0, 255);
2649 //DrawMinimap(p, _TRect(0, 0, 128, 128));
2650 if g_Debug_Player
then
2651 g_Player_DrawDebug(p
);
2655 procedure g_Game_Draw();
2662 plView1
, plView2
: TPlayer
;
2665 if gExit
= EXIT_QUIT
then Exit
;
2667 Time
:= GetTimer() div 1000;
2668 FPSCounter
:= FPSCounter
+1;
2669 if Time
- FPSTime
>= 1000 then
2676 if gGameOn
or (gState
= STATE_FOLD
) then
2678 if (gPlayer1
<> nil) and (gPlayer2
<> nil) then
2680 gSpectMode
:= SPECT_NONE
;
2681 if not gRevertPlayers
then
2683 plView1
:= gPlayer1
;
2684 plView2
:= gPlayer2
;
2688 plView1
:= gPlayer2
;
2689 plView2
:= gPlayer1
;
2693 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
2695 gSpectMode
:= SPECT_NONE
;
2696 if gPlayer2
= nil then
2699 plView1
:= gPlayer2
;
2708 if (plView1
= nil) and (plView2
= nil) and (gSpectMode
= SPECT_NONE
) then
2709 gSpectMode
:= SPECT_STATS
;
2711 if gSpectMode
= SPECT_PLAYERS
then
2712 if gPlayers
<> nil then
2714 plView1
:= GetActivePlayer_ByID(gSpectPID1
);
2715 if plView1
= nil then
2717 gSpectPID1
:= GetActivePlayerID_Next();
2718 plView1
:= GetActivePlayer_ByID(gSpectPID1
);
2720 if gSpectViewTwo
then
2722 plView2
:= GetActivePlayer_ByID(gSpectPID2
);
2723 if plView2
= nil then
2725 gSpectPID2
:= GetActivePlayerID_Next();
2726 plView2
:= GetActivePlayer_ByID(gSpectPID2
);
2731 if gSpectMode
= SPECT_MAPVIEW
then
2733 // Ðåæèì ïðîñìîòðà êàðòû
2735 e_SetViewPort(0, 0, gScreenWidth
, gScreenHeight
);
2736 DrawMapView(gSpectX
, gSpectY
, gScreenWidth
, gScreenHeight
);
2737 gHearPoint1
.Active
:= True;
2738 gHearPoint1
.Coords
.X
:= gScreenWidth
div 2 + gSpectX
;
2739 gHearPoint1
.Coords
.Y
:= gScreenHeight
div 2 + gSpectY
;
2740 gHearPoint2
.Active
:= False;
2744 Split
:= (plView1
<> nil) and (plView2
<> nil);
2746 // Òî÷êè ñëóõà èãðîêîâ
2747 if plView1
<> nil then
2749 gHearPoint1
.Active
:= True;
2750 gHearPoint1
.Coords
.X
:= plView1
.GameX
;
2751 gHearPoint1
.Coords
.Y
:= plView1
.GameY
;
2753 gHearPoint1
.Active
:= False;
2754 if plView2
<> nil then
2756 gHearPoint2
.Active
:= True;
2757 gHearPoint2
.Coords
.X
:= plView2
.GameX
;
2758 gHearPoint2
.Coords
.Y
:= plView2
.GameY
;
2760 gHearPoint2
.Active
:= False;
2762 // Ðàçìåð ýêðàíîâ èãðîêîâ:
2763 gPlayerScreenSize
.X
:= gScreenWidth
-196;
2766 gPlayerScreenSize
.Y
:= gScreenHeight
div 2;
2767 if gScreenHeight
mod 2 = 0 then
2768 Dec(gPlayerScreenSize
.Y
);
2771 gPlayerScreenSize
.Y
:= gScreenHeight
;
2774 if gScreenHeight
mod 2 = 0 then
2775 e_SetViewPort(0, gPlayerScreenSize
.Y
+2, gPlayerScreenSize
.X
+196, gPlayerScreenSize
.Y
)
2777 e_SetViewPort(0, gPlayerScreenSize
.Y
+1, gPlayerScreenSize
.X
+196, gPlayerScreenSize
.Y
);
2779 DrawPlayer(plView1
);
2780 gPlayer1ScreenCoord
.X
:= sX
;
2781 gPlayer1ScreenCoord
.Y
:= sY
;
2785 e_SetViewPort(0, 0, gPlayerScreenSize
.X
+196, gPlayerScreenSize
.Y
);
2787 DrawPlayer(plView2
);
2788 gPlayer2ScreenCoord
.X
:= sX
;
2789 gPlayer2ScreenCoord
.Y
:= sY
;
2792 e_SetViewPort(0, 0, gScreenWidth
, gScreenHeight
);
2795 e_DrawLine(2, 0, gScreenHeight
div 2, gScreenWidth
, gScreenHeight
div 2, 0, 0, 0);
2798 if MessageText
<> '' then
2802 e_CharFont_GetSizeFmt(gMenuFont
, MessageText
, w
, h
);
2804 e_CharFont_PrintFmt(gMenuFont
, (gScreenWidth
div 2)-(w
div 2),
2805 (gScreenHeight
div 2)-(h
div 2), MessageText
)
2807 e_CharFont_PrintFmt(gMenuFont
, (gScreenWidth
div 2)-(w
div 2),
2808 Round(gScreenHeight
/ 2.75)-(h
div 2), MessageText
);
2811 if IsDrawStat
or (gSpectMode
= 1) then DrawStat();
2813 if gSpectHUD
and (not gChatShow
) and (gSpectMode
<> SPECT_NONE
) then
2815 // Draw spectator GUI
2818 e_TextureFontGetSize(gStdFont
, ww
, hh
);
2821 e_TextureFontPrintEx(0, gScreenHeight
- (hh
+2)*2, 'MODE: Stats', gStdFont
, 255, 255, 255, 1);
2823 e_TextureFontPrintEx(0, gScreenHeight
- (hh
+2)*2, 'MODE: Observe Map', gStdFont
, 255, 255, 255, 1);
2825 e_TextureFontPrintEx(0, gScreenHeight
- (hh
+2)*2, 'MODE: Watch Players', gStdFont
, 255, 255, 255, 1);
2827 e_TextureFontPrintEx(2*ww
, gScreenHeight
- (hh
+2), '< jump >', gStdFont
, 255, 255, 255, 1);
2828 if gSpectMode
= SPECT_MAPVIEW
then
2830 e_TextureFontPrintEx(22*ww
, gScreenHeight
- (hh
+2)*2, '[-]', gStdFont
, 255, 255, 255, 1);
2831 e_TextureFontPrintEx(26*ww
, gScreenHeight
- (hh
+2)*2, 'Step ' + IntToStr(gSpectStep
), gStdFont
, 255, 255, 255, 1);
2832 e_TextureFontPrintEx(34*ww
, gScreenHeight
- (hh
+2)*2, '[+]', gStdFont
, 255, 255, 255, 1);
2833 e_TextureFontPrintEx(18*ww
, gScreenHeight
- (hh
+2), '<prev weap>', gStdFont
, 255, 255, 255, 1);
2834 e_TextureFontPrintEx(30*ww
, gScreenHeight
- (hh
+2), '<next weap>', gStdFont
, 255, 255, 255, 1);
2836 if gSpectMode
= SPECT_PLAYERS
then
2838 e_TextureFontPrintEx(22*ww
, gScreenHeight
- (hh
+2)*2, 'Player 1', gStdFont
, 255, 255, 255, 1);
2839 e_TextureFontPrintEx(20*ww
, gScreenHeight
- (hh
+2), '<left/right>', gStdFont
, 255, 255, 255, 1);
2840 if gSpectViewTwo
then
2842 e_TextureFontPrintEx(37*ww
, gScreenHeight
- (hh
+2)*2, 'Player 2', gStdFont
, 255, 255, 255, 1);
2843 e_TextureFontPrintEx(34*ww
, gScreenHeight
- (hh
+2), '<prev w/next w>', gStdFont
, 255, 255, 255, 1);
2844 e_TextureFontPrintEx(52*ww
, gScreenHeight
- (hh
+2)*2, '2x View', gStdFont
, 255, 255, 255, 1);
2845 e_TextureFontPrintEx(51*ww
, gScreenHeight
- (hh
+2), '<up/down>', gStdFont
, 255, 255, 255, 1);
2849 e_TextureFontPrintEx(35*ww
, gScreenHeight
- (hh
+2)*2, '2x View', gStdFont
, 255, 255, 255, 1);
2850 e_TextureFontPrintEx(34*ww
, gScreenHeight
- (hh
+2), '<up/down>', gStdFont
, 255, 255, 255, 1);
2856 if gPause
and gGameOn
and (g_ActiveWindow
= nil) then
2858 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 48, 48, 48, 180);
2860 e_CharFont_GetSize(gMenuFont
, _lc
[I_MENU_PAUSE
], w
, h
);
2861 e_CharFont_Print(gMenuFont
, (gScreenWidth
div 2)-(w
div 2),
2862 (gScreenHeight
div 2)-(h
div 2), _lc
[I_MENU_PAUSE
]);
2867 if (gState
= STATE_MENU
) then
2869 if ((g_ActiveWindow
= nil) or (g_ActiveWindow
.BackTexture
= '')) then
2871 if g_Texture_Get('MENU_BACKGROUND', ID
) then
2872 e_DrawSize(ID
, 0, 0, 0, False, False, gScreenWidth
, gScreenHeight
)
2873 else e_Clear(GL_COLOR_BUFFER_BIT
, 0, 0, 0);
2875 if g_ActiveWindow
<> nil then
2876 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 48, 48, 48, 180);
2879 if gState
= STATE_FOLD
then
2880 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 0, 0, 0, EndingGameCounter
);
2882 if gState
= STATE_INTERCUSTOM
then
2884 if gLastMap
and (gGameSettings
.GameMode
= GM_COOP
) then
2886 back
:= 'TEXTURE_endpic';
2887 if not g_Texture_Get(back
, ID
) then
2888 back
:= _lc
[I_TEXTURE_ENDPIC
];
2893 if g_Texture_Get(back
, ID
) then
2894 e_DrawSize(ID
, 0, 0, 0, False, False, gScreenWidth
, gScreenHeight
)
2896 e_Clear(GL_COLOR_BUFFER_BIT
, 0, 0, 0);
2900 if g_ActiveWindow
<> nil then
2901 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 48, 48, 48, 180);
2904 if gState
= STATE_INTERSINGLE
then
2906 if EndingGameCounter
> 0 then
2907 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 0, 0, 0, EndingGameCounter
)
2912 if g_Texture_Get(back
, ID
) then
2913 e_DrawSize(ID
, 0, 0, 0, False, False, gScreenWidth
, gScreenHeight
)
2915 e_Clear(GL_COLOR_BUFFER_BIT
, 0, 0, 0);
2919 if g_ActiveWindow
<> nil then
2920 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 48, 48, 48, 180);
2924 if gState
= STATE_ENDPIC
then
2927 if not g_Texture_Get('TEXTURE_endpic', ID
) then
2928 g_Texture_Get(_lc
[I_TEXTURE_ENDPIC
], ID
);
2930 if ID
<> DWORD(-1) then
2931 e_DrawSize(ID
, 0, 0, 0, False, False, gScreenWidth
, gScreenHeight
)
2933 e_Clear(GL_COLOR_BUFFER_BIT
, 0, 0, 0);
2935 if g_ActiveWindow
<> nil then
2936 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 48, 48, 48, 180);
2939 if gState
= STATE_SLIST
then
2941 if g_Texture_Get('MENU_BACKGROUND', ID
) then
2943 e_DrawSize(ID
, 0, 0, 0, False, False, gScreenWidth
, gScreenHeight
);
2944 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 48, 48, 48, 180);
2946 g_Serverlist_Draw(slCurrent
);
2950 if g_ActiveWindow
<> nil then
2953 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 48, 48, 48, 180);
2954 g_ActiveWindow
.Draw();
2959 if g_debug_Sounds
and gGameOn
then
2961 for w
:= 0 to High(e_SoundsArray
) do
2962 for h
:= 0 to e_SoundsArray
[w
].nRefs
do
2963 e_DrawPoint(1, w
+100, h
+100, 255, 0, 0);
2968 e_TextureFontPrint(0, 0, Format('FPS: %d', [FPS
]), gStdFont
);
2969 e_TextureFontPrint(0, 16, Format('UPS: %d', [UPS
]), gStdFont
);
2972 if gGameOn
and gShowTime
and (gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
]) then
2973 e_TextureFontPrint(gScreenWidth
-72, 0,
2974 Format('%d:%.2d:%.2d', [gTime
div 1000 div 3600, (gTime
div 1000 div 60) mod 60, gTime
div 1000 mod 60]),
2978 procedure g_Game_Quit();
2980 g_Game_StopAllSounds(True);
2982 g_Game_SaveOptions();
2984 g_PlayerModel_FreeData();
2985 g_Texture_DeleteAll();
2986 g_Frames_DeleteAll();
2989 if NetInitDone
then g_Net_Free
;
2991 // Íàäî óäàëèòü êàðòó ïîñëå òåñòà:
2992 if gMapToDelete
<> '' then
2993 g_Game_DeleteTestMap();
2999 procedure g_FatalError(Text: String);
3001 g_Console_Add(Format(_lc
[I_FATAL_ERROR
], [Text]), True);
3002 e_WriteLog(Format(_lc
[I_FATAL_ERROR
], [Text]), MSG_WARNING
);
3004 gExit
:= EXIT_SIMPLE
;
3007 procedure g_SimpleError(Text: String);
3009 g_Console_Add(Format(_lc
[I_SIMPLE_ERROR
], [Text]), True);
3010 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], [Text]), MSG_WARNING
);
3013 procedure g_Game_SetupScreenSize();
3017 // Ðàçìåð ýêðàíîâ èãðîêîâ:
3018 gPlayerScreenSize
.X
:= gScreenWidth
-196;
3019 if (gPlayer1
<> nil) and (gPlayer2
<> nil) then
3020 gPlayerScreenSize
.Y
:= gScreenHeight
div 2
3022 gPlayerScreenSize
.Y
:= gScreenHeight
;
3024 // Ðàçìåð çàäíåãî ïëàíà:
3025 if BackID
<> DWORD(-1) then
3029 if (gScreenWidth
*d
> gMapInfo
.Width
) or
3030 (gScreenHeight
*d
> gMapInfo
.Height
) then
3033 gBackSize
.X
:= Round(gScreenWidth
*d
);
3034 gBackSize
.Y
:= Round(gScreenHeight
*d
);
3038 procedure g_Game_ChangeResolution(newWidth
, newHeight
: Word; nowFull
, nowMax
: Boolean);
3040 g_Window_SetSize(newWidth
, newHeight
, nowFull
);
3043 procedure g_Game_AddPlayer(Team
: Byte = TEAM_NONE
);
3045 if ((not gGameOn
) and (gState
<> STATE_INTERCUSTOM
))
3046 or (not (gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
])) then
3048 if gPlayer1
= nil then
3050 if g_Game_IsClient
then
3052 if NetPlrUID1
> -1 then
3054 MC_SEND_CheatRequest(NET_CHEAT_SPECTATE
);
3055 gPlayer1
:= g_Player_Get(NetPlrUID1
);
3060 if not (Team
in [TEAM_RED
, TEAM_BLUE
]) then
3061 Team
:= gPlayer1Settings
.Team
;
3063 // Ñîçäàíèå ïåðâîãî èãðîêà:
3064 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
3065 gPlayer1Settings
.Color
,
3067 if gPlayer1
= nil then
3068 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]))
3071 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
3072 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [gPlayer1
.Name
]), True);
3073 if g_Game_IsServer
and g_Game_IsNet
then
3074 MH_SEND_PlayerCreate(gPlayer1
.UID
);
3075 gPlayer1
.Respawn(False, True);
3077 if g_Game_IsNet
and NetUseMaster
then
3083 if gPlayer2
= nil then
3085 if g_Game_IsClient
then
3087 if NetPlrUID2
> -1 then
3088 gPlayer2
:= g_Player_Get(NetPlrUID2
);
3092 if not (Team
in [TEAM_RED
, TEAM_BLUE
]) then
3093 Team
:= gPlayer2Settings
.Team
;
3095 // Ñîçäàíèå âòîðîãî èãðîêà:
3096 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
3097 gPlayer2Settings
.Color
,
3099 if gPlayer2
= nil then
3100 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]))
3103 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
3104 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [gPlayer2
.Name
]), True);
3105 if g_Game_IsServer
and g_Game_IsNet
then
3106 MH_SEND_PlayerCreate(gPlayer2
.UID
);
3107 gPlayer2
.Respawn(False, True);
3109 if g_Game_IsNet
and NetUseMaster
then
3117 procedure g_Game_RemovePlayer();
3121 if ((not gGameOn
) and (gState
<> STATE_INTERCUSTOM
))
3122 or (not (gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
])) then
3127 if g_Game_IsServer
then
3130 Pl
.Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
3131 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [Pl
.Name
]), True);
3132 g_Player_Remove(Pl
.UID
);
3134 if g_Game_IsNet
and NetUseMaster
then
3143 if g_Game_IsServer
then
3146 Pl
.Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
3147 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [Pl
.Name
]), True);
3148 g_Player_Remove(Pl
.UID
);
3150 if g_Game_IsNet
and NetUseMaster
then
3155 MC_SEND_CheatRequest(NET_CHEAT_SPECTATE
);
3161 procedure g_Game_Spectate();
3163 g_Game_RemovePlayer();
3164 if gPlayer1
<> nil then
3165 g_Game_RemovePlayer();
3168 procedure g_Game_SpectateCenterView();
3170 gSpectX
:= Max(gMapInfo
.Width
div 2 - gScreenWidth
div 2, 0);
3171 gSpectY
:= Max(gMapInfo
.Height
div 2 - gScreenHeight
div 2, 0);
3174 procedure g_Game_StartSingle(Map
: String; TwoPlayers
: Boolean; nPlayers
: Byte);
3180 e_WriteLog('Starting singleplayer game...', MSG_NOTIFY
);
3182 g_Game_ClearLoading();
3185 FillByte(gGameSettings
, SizeOf(TGameSettings
), 0);
3188 gGameSettings
.GameType
:= GT_SINGLE
;
3189 gGameSettings
.MaxLives
:= 0;
3190 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_ALLOWEXIT
;
3191 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_MONSTERS
;
3192 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_BOTVSMONSTER
;
3193 gSwitchGameMode
:= GM_SINGLE
;
3195 g_Game_ExecuteEvent('ongamestart');
3197 // Óñòàíîâêà ðàçìåðîâ îêîí èãðîêîâ:
3198 g_Game_SetupScreenSize();
3200 // Ñîçäàíèå ïåðâîãî èãðîêà:
3201 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
3202 gPlayer1Settings
.Color
,
3203 gPlayer1Settings
.Team
, False));
3204 if gPlayer1
= nil then
3206 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
3210 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
3213 // Ñîçäàíèå âòîðîãî èãðîêà, åñëè åñòü:
3216 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
3217 gPlayer2Settings
.Color
,
3218 gPlayer2Settings
.Team
, False));
3219 if gPlayer2
= nil then
3221 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
3225 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
3229 // Çàãðóçêà è çàïóñê êàðòû:
3230 if not g_Game_StartMap(MAP
, True) then
3232 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [gGameSettings
.WAD
+ ':\' + MAP
]));
3236 // Íàñòðîéêè èãðîêîâ è áîòîâ:
3240 for i
:= nPl
+1 to nPlayers
do
3241 g_Player_Create(STD_PLAYER_MODEL
, _RGB(0, 0, 0), 0, True);
3244 procedure g_Game_StartCustom(Map
: String; GameMode
: Byte;
3245 TimeLimit
, GoalLimit
: Word;
3247 Options
: LongWord; nPlayers
: Byte);
3253 e_WriteLog('Starting custom game...', MSG_NOTIFY
);
3255 g_Game_ClearLoading();
3258 gGameSettings
.GameType
:= GT_CUSTOM
;
3259 gGameSettings
.GameMode
:= GameMode
;
3260 gSwitchGameMode
:= GameMode
;
3261 gGameSettings
.TimeLimit
:= TimeLimit
;
3262 gGameSettings
.GoalLimit
:= GoalLimit
;
3263 gGameSettings
.MaxLives
:= IfThen(GameMode
= GM_CTF
, 0, MaxLives
);
3264 gGameSettings
.Options
:= Options
;
3266 gCoopTotalMonstersKilled
:= 0;
3267 gCoopTotalSecretsFound
:= 0;
3268 gCoopTotalMonsters
:= 0;
3269 gCoopTotalSecrets
:= 0;
3273 g_Game_ExecuteEvent('ongamestart');
3275 // Óñòàíîâêà ðàçìåðîâ îêîí èãðîêîâ:
3276 g_Game_SetupScreenSize();
3278 // Ðåæèì íàáëþäàòåëÿ:
3279 if nPlayers
= 0 then
3286 if nPlayers
>= 1 then
3288 // Ñîçäàíèå ïåðâîãî èãðîêà:
3289 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
3290 gPlayer1Settings
.Color
,
3291 gPlayer1Settings
.Team
, False));
3292 if gPlayer1
= nil then
3294 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
3298 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
3302 if nPlayers
>= 2 then
3304 // Ñîçäàíèå âòîðîãî èãðîêà:
3305 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
3306 gPlayer2Settings
.Color
,
3307 gPlayer2Settings
.Team
, False));
3308 if gPlayer2
= nil then
3310 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
3314 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
3318 // Çàãðóçêà è çàïóñê êàðòû:
3319 if not g_Game_StartMap(Map
, True) then
3321 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [Map
]));
3325 // Íåò òî÷åê ïîÿâëåíèÿ:
3326 if (g_Map_GetPointCount(RESPAWNPOINT_PLAYER1
) +
3327 g_Map_GetPointCount(RESPAWNPOINT_PLAYER2
) +
3328 g_Map_GetPointCount(RESPAWNPOINT_DM
) +
3329 g_Map_GetPointCount(RESPAWNPOINT_RED
)+
3330 g_Map_GetPointCount(RESPAWNPOINT_BLUE
)) < 1 then
3332 g_FatalError(_lc
[I_GAME_ERROR_GET_SPAWN
]);
3336 // Íàñòðîéêè èãðîêîâ è áîòîâ:
3340 for i
:= nPl
+1 to nPlayers
do
3341 g_Player_Create(STD_PLAYER_MODEL
, _RGB(0, 0, 0), 0, True);
3344 procedure g_Game_StartServer(Map
: String; GameMode
: Byte;
3345 TimeLimit
, GoalLimit
: Word; MaxLives
: Byte;
3346 Options
: LongWord; nPlayers
: Byte;
3347 IPAddr
: LongWord; Port
: Word);
3351 e_WriteLog('Starting net game (server)...', MSG_NOTIFY
);
3353 g_Game_ClearLoading();
3356 gGameSettings
.GameType
:= GT_SERVER
;
3357 gGameSettings
.GameMode
:= GameMode
;
3358 gSwitchGameMode
:= GameMode
;
3359 gGameSettings
.TimeLimit
:= TimeLimit
;
3360 gGameSettings
.GoalLimit
:= GoalLimit
;
3361 gGameSettings
.MaxLives
:= IfThen(GameMode
= GM_CTF
, 0, MaxLives
);
3362 gGameSettings
.Options
:= Options
;
3364 gCoopTotalMonstersKilled
:= 0;
3365 gCoopTotalSecretsFound
:= 0;
3366 gCoopTotalMonsters
:= 0;
3367 gCoopTotalSecrets
:= 0;
3371 g_Game_ExecuteEvent('ongamestart');
3373 // Óñòàíîâêà ðàçìåðîâ îêíà èãðîêà
3374 g_Game_SetupScreenSize();
3376 // Ðåæèì íàáëþäàòåëÿ:
3377 if nPlayers
= 0 then
3383 if nPlayers
>= 1 then
3385 // Ñîçäàíèå ïåðâîãî èãðîêà:
3386 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
3387 gPlayer1Settings
.Color
,
3388 gPlayer1Settings
.Team
, False));
3389 if gPlayer1
= nil then
3391 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
3395 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
3398 if nPlayers
>= 2 then
3400 // Ñîçäàíèå âòîðîãî èãðîêà:
3401 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
3402 gPlayer2Settings
.Color
,
3403 gPlayer2Settings
.Team
, False));
3404 if gPlayer2
= nil then
3406 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
3410 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
3414 if not g_Net_Host(IPAddr
, Port
, NetMaxClients
) then
3416 g_FatalError(_lc
[I_NET_MSG
] + _lc
[I_NET_ERR_HOST
]);
3420 g_Net_Slist_Set(NetSlistIP
, NetSlistPort
);
3422 // Çàãðóçêà è çàïóñê êàðòû:
3423 if not g_Game_StartMap(Map
, True) then
3425 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [Map
]));
3429 // Íåò òî÷åê ïîÿâëåíèÿ:
3430 if (g_Map_GetPointCount(RESPAWNPOINT_PLAYER1
) +
3431 g_Map_GetPointCount(RESPAWNPOINT_PLAYER2
) +
3432 g_Map_GetPointCount(RESPAWNPOINT_DM
) +
3433 g_Map_GetPointCount(RESPAWNPOINT_RED
)+
3434 g_Map_GetPointCount(RESPAWNPOINT_BLUE
)) < 1 then
3436 g_FatalError(_lc
[I_GAME_ERROR_GET_SPAWN
]);
3440 // Íàñòðîéêè èãðîêîâ è áîòîâ:
3443 NetState
:= NET_STATE_GAME
;
3446 procedure g_Game_StartClient(Addr
: String; Port
: Word; PW
: String);
3460 e_WriteLog('Starting net game (client)...', MSG_NOTIFY
);
3461 e_WriteLog('NET: Trying to connect to ' + Addr
+ ':' + IntToStr(Port
) + '...', MSG_NOTIFY
);
3463 g_Game_ClearLoading();
3466 gGameSettings
.GameType
:= GT_CLIENT
;
3468 gCoopTotalMonstersKilled
:= 0;
3469 gCoopTotalSecretsFound
:= 0;
3470 gCoopTotalMonsters
:= 0;
3471 gCoopTotalSecrets
:= 0;
3475 g_Game_ExecuteEvent('ongamestart');
3477 // Óñòàíîâêà ðàçìåðîâ îêîí èãðîêîâ:
3478 g_Game_SetupScreenSize();
3480 NetState
:= NET_STATE_AUTH
;
3482 g_Game_SetLoadingText(_lc
[I_LOAD_CONNECT
], 0, False);
3484 if not g_Net_Connect(Addr
, Port
) then
3486 g_FatalError(_lc
[I_NET_MSG
] + _lc
[I_NET_ERR_CONN
]);
3487 NetState
:= NET_STATE_NONE
;
3491 g_Game_SetLoadingText(_lc
[I_LOAD_SEND_INFO
], 0, False);
3493 g_Game_SetLoadingText(_lc
[I_LOAD_WAIT_INFO
], 0, False);
3498 while (enet_host_service(NetHost
, @NetEvent
, 0) > 0) do
3500 if (NetEvent
.kind
= ENET_EVENT_TYPE_RECEIVE
) then
3502 Ptr
:= NetEvent
.packet
^.data
;
3505 MID
:= e_Raw_Read_Byte(Ptr
);
3507 if (MID
= NET_MSG_INFO
) and (State
= 0) then
3509 NetMyID
:= e_Raw_Read_Byte(Ptr
);
3510 NetPlrUID1
:= e_Raw_Read_Word(Ptr
);
3512 WadName
:= e_Raw_Read_String(Ptr
);
3513 Map
:= e_Raw_Read_String(Ptr
);
3515 gWADHash
:= e_Raw_Read_MD5(Ptr
);
3517 gGameSettings
.GameMode
:= e_Raw_Read_Byte(Ptr
);
3518 gSwitchGameMode
:= gGameSettings
.GameMode
;
3519 gGameSettings
.GoalLimit
:= e_Raw_Read_Word(Ptr
);
3520 gGameSettings
.TimeLimit
:= e_Raw_Read_Word(Ptr
);
3521 gGameSettings
.MaxLives
:= e_Raw_Read_Byte(Ptr
);
3522 gGameSettings
.Options
:= e_Raw_Read_LongWord(Ptr
);
3523 T
:= e_Raw_Read_LongWord(Ptr
);
3525 newResPath
:= g_Res_SearchSameWAD(MapsDir
, WadName
, gWADHash
);
3526 if newResPath
= '' then
3528 g_Game_SetLoadingText(_lc
[I_LOAD_DL_RES
], 0, False);
3529 newResPath
:= g_Res_DownloadWAD(WadName
);
3530 if newResPath
= '' then
3532 g_FatalError(_lc
[I_NET_ERR_HASH
]);
3533 enet_packet_destroy(NetEvent
.packet
);
3534 NetState
:= NET_STATE_NONE
;
3538 newResPath
:= ExtractRelativePath(MapsDir
, newResPath
);
3540 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
3541 gPlayer1Settings
.Color
,
3542 gPlayer1Settings
.Team
, False));
3544 if gPlayer1
= nil then
3546 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
3548 enet_packet_destroy(NetEvent
.packet
);
3549 NetState
:= NET_STATE_NONE
;
3553 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
3554 gPlayer1
.UID
:= NetPlrUID1
;
3555 gPlayer1
.Reset(True);
3557 if not g_Game_StartMap(newResPath
+ ':\' + Map
, True) then
3559 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [WadName
+ ':\' + Map
]));
3561 enet_packet_destroy(NetEvent
.packet
);
3562 NetState
:= NET_STATE_NONE
;
3570 enet_packet_destroy(NetEvent
.packet
);
3574 enet_packet_destroy(NetEvent
.packet
);
3577 if (NetEvent
.kind
= ENET_EVENT_TYPE_DISCONNECT
) then
3580 if (NetEvent
.data
<= NET_DISC_MAX
) then
3581 g_Console_Add(_lc
[I_NET_MSG_ERROR
] + _lc
[I_NET_ERR_CONN
] + ' ' +
3582 _lc
[TStrings_Locale(Cardinal(I_NET_DISC_NONE
) + NetEvent
.data
)], True);
3592 if e_KeyPressed(IK_ESCAPE
) or e_KeyPressed(IK_SPACE
) then
3601 g_FatalError(_lc
[I_NET_MSG
] + _lc
[I_NET_ERR_CONN
]);
3602 NetState
:= NET_STATE_NONE
;
3606 gLMSRespawn
:= LMS_RESPAWN_NONE
;
3607 gLMSRespawnTime
:= 0;
3610 NetState
:= NET_STATE_GAME
;
3611 MC_SEND_FullStateRequest
;
3612 e_WriteLog('NET: Connection successful.', MSG_NOTIFY
);
3615 procedure g_Game_SaveOptions();
3617 g_Options_Write_Video(GameDir
+'/'+CONFIG_FILENAME
);
3620 procedure g_Game_ChangeMap(MapPath
: String);
3624 g_Game_ClearLoading();
3626 Force
:= gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
];
3627 // Åñëè óðîâåíü çàâåðøèëñÿ ïî òðèããåðó Âûõîä, íå î÷èùàòü èíâåíòàðü
3628 if gExitByTrigger
then
3631 gExitByTrigger
:= False;
3633 if not g_Game_StartMap(MapPath
, Force
) then
3634 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [MapPath
]));
3637 procedure g_Game_Restart();
3641 if g_Game_IsClient
then
3643 g_ProcessResourceStr(gMapInfo
.Map
, nil, nil, @Map
);
3647 g_Game_ClearLoading();
3648 g_Game_StartMap(Map
, True);
3651 function g_Game_StartMap(Map
: String; Force
: Boolean = False): Boolean;
3653 NewWAD
, ResName
: String;
3657 g_Player_RemoveAllCorpses();
3659 if (not g_Game_IsClient
) and
3660 (gSwitchGameMode
<> gGameSettings
.GameMode
) and
3661 (gGameSettings
.GameMode
<> GM_SINGLE
) then
3663 if gSwitchGameMode
= GM_CTF
then
3664 gGameSettings
.MaxLives
:= 0;
3665 gGameSettings
.GameMode
:= gSwitchGameMode
;
3668 gSwitchGameMode
:= gGameSettings
.GameMode
;
3670 g_Player_ResetTeams();
3672 if Pos(':\', Map
) > 0 then
3674 g_ProcessResourceStr(Map
, @NewWAD
, nil, @ResName
);
3675 if g_Game_IsServer
then
3677 gWADHash
:= MD5File(MapsDir
+ NewWAD
);
3678 g_Game_LoadWAD(NewWAD
);
3680 // hash recieved in MC_RECV_GameEvent -> NET_EV_MAPSTART
3681 g_Game_ClientWAD(NewWAD
, gWADHash
);
3685 Result
:= g_Map_Load(MapsDir
+ gGameSettings
.WAD
+ ':\' + ResName
);
3688 g_Player_ResetAll(Force
or gLastMap
, gGameSettings
.GameType
= GT_SINGLE
);
3690 gState
:= STATE_NONE
;
3691 g_ActiveWindow
:= nil;
3697 if gGameSettings
.GameMode
= GM_CTF
then
3699 g_Map_ResetFlag(FLAG_RED
);
3700 g_Map_ResetFlag(FLAG_BLUE
);
3701 // CTF, à ôëàãîâ íåò:
3702 if not g_Map_HaveFlagPoints() then
3703 g_SimpleError(_lc
[I_GAME_ERROR_CTF
]);
3708 gState
:= STATE_MENU
;
3715 NetTimeToUpdate
:= 1;
3716 NetTimeToReliable
:= 0;
3717 NetTimeToMaster
:= NetMasterRate
;
3718 gLMSRespawn
:= LMS_RESPAWN_NONE
;
3719 gLMSRespawnTime
:= 0;
3720 gMissionFailed
:= False;
3723 gCoopMonstersKilled
:= 0;
3724 gCoopSecretsFound
:= 0;
3726 gVoteInProgress
:= False;
3727 gVotePassed
:= False;
3733 if not gGameOn
then Exit
;
3735 g_Game_SpectateCenterView();
3737 if (gGameSettings
.MaxLives
> 0) and (gGameSettings
.WarmupTime
> 0) then
3739 gLMSRespawn
:= LMS_RESPAWN_WARMUP
;
3740 gLMSRespawnTime
:= gTime
+ gGameSettings
.WarmupTime
*1000;
3741 gLMSSoftSpawn
:= True;
3742 if NetMode
= NET_SERVER
then
3743 MH_SEND_GameEvent(NET_EV_LMS_WARMUP
, (gLMSRespawnTime
- gTime
) div 1000)
3745 g_Console_Add(Format(_lc
[I_MSG_WARMUP_START
], [(gLMSRespawnTime
- gTime
) div 1000]), True);
3748 if NetMode
= NET_SERVER
then
3750 MH_SEND_GameEvent(NET_EV_MAPSTART
, gGameSettings
.GameMode
, Map
);
3753 if NetUseMaster
then
3755 if (NetMHost
= nil) or (NetMPeer
= nil) then
3756 if not g_Net_Slist_Connect
then
3757 g_Console_Add(_lc
[I_NET_MSG_ERROR
] + _lc
[I_NET_SLIST_ERROR
]);
3762 if NetClients
<> nil then
3763 for I
:= 0 to High(NetClients
) do
3764 if NetClients
[I
].Used
then
3766 NetClients
[I
].Voted
:= False;
3767 if NetClients
[I
].RequestedFullUpdate
then
3769 MH_SEND_Everything((NetClients
[I
].State
= NET_STATE_AUTH
), I
);
3770 NetClients
[I
].RequestedFullUpdate
:= False;
3774 g_Net_UnbanNonPermHosts();
3779 gCoopTotalMonstersKilled
:= 0;
3780 gCoopTotalSecretsFound
:= 0;
3781 gCoopTotalMonsters
:= 0;
3782 gCoopTotalSecrets
:= 0;
3786 g_Game_ExecuteEvent('onmapstart');
3789 procedure SetFirstLevel();
3793 MapList
:= g_Map_GetMapsList(MapsDir
+ gGameSettings
.WAD
);
3794 if MapList
= nil then
3797 SortSArray(MapList
);
3798 gNextMap
:= MapList
[Low(MapList
)];
3803 procedure g_Game_ExitLevel(Map
: Char16
);
3807 gCoopTotalMonstersKilled
:= gCoopTotalMonstersKilled
+ gCoopMonstersKilled
;
3808 gCoopTotalSecretsFound
:= gCoopTotalSecretsFound
+ gCoopSecretsFound
;
3809 gCoopTotalMonsters
:= gCoopTotalMonsters
+ gTotalMonsters
;
3810 gCoopTotalSecrets
:= gCoopTotalSecrets
+ gSecretsCount
;
3812 // Âûøëè â âûõîä â Îäèíî÷íîé èãðå:
3813 if gGameSettings
.GameType
= GT_SINGLE
then
3814 gExit
:= EXIT_ENDLEVELSINGLE
3815 else // Âûøëè â âûõîä â Ñâîåé èãðå
3817 gExit
:= EXIT_ENDLEVELCUSTOM
;
3818 if gGameSettings
.GameMode
= GM_COOP
then
3819 g_Player_RememberAll
;
3821 if not g_Map_Exist(MapsDir
+ gGameSettings
.WAD
+ ':\' + gNextMap
) then
3824 if gGameSettings
.GameMode
= GM_COOP
then
3827 gStatsPressed
:= True;
3828 gNextMap
:= 'MAP01';
3830 if not g_Map_Exist(MapsDir
+ gGameSettings
.WAD
+ ':\' + gNextMap
) then
3833 if g_Game_IsNet
then
3835 MH_SEND_GameStats();
3836 MH_SEND_CoopStats();
3842 procedure g_Game_RestartLevel();
3846 if gGameSettings
.GameMode
= GM_SINGLE
then
3851 gExit
:= EXIT_ENDLEVELCUSTOM
;
3852 g_ProcessResourceStr(gMapInfo
.Map
, nil, nil, @Map
);
3856 procedure g_Game_ClientWAD(NewWAD
: String; WHash
: TMD5Digest
);
3860 if LowerCase(NewWAD
) = LowerCase(gGameSettings
.WAD
) then
3862 if not g_Game_IsClient
then
3864 gWAD
:= g_Res_SearchSameWAD(MapsDir
, ExtractFileName(NewWAD
), WHash
);
3867 g_Game_SetLoadingText(_lc
[I_LOAD_DL_RES
], 0, False);
3868 gWAD
:= g_Res_DownloadWAD(ExtractFileName(NewWAD
));
3872 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_WAD
], [ExtractFileName(NewWAD
)]));
3876 NewWAD
:= ExtractRelativePath(MapsDir
, gWAD
);
3877 g_Game_LoadWAD(NewWAD
);
3880 procedure g_Game_RestartRound(NoMapRestart
: Boolean = False);
3882 i
, n
, nb
, nr
: Integer;
3884 if not g_Game_IsServer
then Exit
;
3885 if gLMSRespawn
= LMS_RESPAWN_NONE
then Exit
;
3886 gLMSRespawn
:= LMS_RESPAWN_NONE
;
3887 gLMSRespawnTime
:= 0;
3890 if (gGameSettings
.GameMode
= GM_COOP
) and not NoMapRestart
then
3892 gMissionFailed
:= True;
3893 g_Game_RestartLevel
;
3897 n
:= 0; nb
:= 0; nr
:= 0;
3898 for i
:= Low(gPlayers
) to High(gPlayers
) do
3899 if (gPlayers
[i
] <> nil) and
3900 ((not gPlayers
[i
].FSpectator
) or gPlayers
[i
].FWantsInGame
or
3901 (gPlayers
[i
] is TBot
)) then
3904 if gPlayers
[i
].Team
= TEAM_RED
then Inc(nr
)
3905 else if gPlayers
[i
].Team
= TEAM_BLUE
then Inc(nb
)
3908 if (n
< 2) or ((gGameSettings
.GameMode
= GM_TDM
) and ((nr
= 0) or (nb
= 0))) then
3910 // wait a second until the fuckers finally decide to join
3911 gLMSRespawn
:= LMS_RESPAWN_WARMUP
;
3912 gLMSRespawnTime
:= gTime
+ 1000;
3913 gLMSSoftSpawn
:= NoMapRestart
;
3917 g_Player_RemoveAllCorpses
;
3918 g_Game_Message(_lc
[I_MESSAGE_LMS_START
], 144);
3919 if g_Game_IsNet
then
3920 MH_SEND_GameEvent(NET_EV_LMS_START
);
3922 for i
:= Low(gPlayers
) to High(gPlayers
) do
3924 if gPlayers
[i
] = nil then continue
;
3925 if gPlayers
[i
] is TBot
then gPlayers
[i
].FWantsInGame
:= True;
3926 // don't touch normal spectators
3927 if gPlayers
[i
].FSpectator
and not gPlayers
[i
].FWantsInGame
then
3929 gPlayers
[i
].FNoRespawn
:= True;
3930 gPlayers
[i
].Lives
:= 0;
3931 if g_Game_IsNet
then
3932 MH_SEND_PlayerStats(gPlayers
[I
].UID
);
3935 gPlayers
[i
].FNoRespawn
:= False;
3936 gPlayers
[i
].Lives
:= gGameSettings
.MaxLives
;
3937 gPlayers
[i
].Respawn(False, True);
3938 if gGameSettings
.GameMode
= GM_COOP
then
3940 gPlayers
[i
].Frags
:= 0;
3941 gPlayers
[i
].RecallState
;
3943 if (gPlayer1
= nil) and (gLMSPID1
> 0) then
3944 gPlayer1
:= g_Player_Get(gLMSPID1
);
3945 if (gPlayer2
= nil) and (gLMSPID2
> 0) then
3946 gPlayer2
:= g_Player_Get(gLMSPID2
);
3949 for i
:= Low(gItems
) to High(gItems
) do
3951 if gItems
[i
].Respawnable
then
3953 gItems
[i
].QuietRespawn
:= True;
3954 gItems
[i
].RespawnTime
:= 0;
3959 if g_Game_IsNet
then MH_SEND_ItemDestroy(True, i
);
3963 for i
:= Low(gMonsters
) to High(gMonsters
) do
3965 if (gMonsters
[i
] <> nil) and not gMonsters
[i
].FNoRespawn
then
3966 gMonsters
[i
].Respawn
;
3969 gLMSSoftSpawn
:= False;
3972 function g_Game_GetFirstMap(WAD
: String): String;
3976 MapList
:= g_Map_GetMapsList(WAD
);
3977 if MapList
= nil then
3980 SortSArray(MapList
);
3981 Result
:= MapList
[Low(MapList
)];
3983 if not g_Map_Exist(WAD
+ ':\' + Result
) then
3989 function g_Game_GetNextMap(): String;
3996 MapList
:= g_Map_GetMapsList(MapsDir
+ gGameSettings
.WAD
);
3997 if MapList
= nil then
4000 g_ProcessResourceStr(gMapInfo
.Map
, nil, nil, @Map
);
4002 SortSArray(MapList
);
4004 for I
:= Low(MapList
) to High(MapList
) do
4005 if Map
= MapList
[I
] then
4011 if MapIndex
<> -255 then
4013 if MapIndex
= High(MapList
) then
4014 Result
:= MapList
[Low(MapList
)]
4016 Result
:= MapList
[MapIndex
+ 1];
4018 if not g_Map_Exist(MapsDir
+ gGameSettings
.WAD
+ ':\' + Result
) then Result
:= Map
;
4024 procedure g_Game_NextLevel();
4026 if gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
, GM_COOP
] then
4027 gExit
:= EXIT_ENDLEVELCUSTOM
4030 gExit
:= EXIT_ENDLEVELSINGLE
;
4034 if gNextMap
<> '' then Exit
;
4035 gNextMap
:= g_Game_GetNextMap();
4038 function g_Game_IsTestMap(): Boolean;
4040 FName
, Sect
, Res
: String;
4042 g_ProcessResourceStr(gMapInfo
.Map
, FName
, Sect
, Res
);
4043 Result
:= UpperCase(Res
) = TEST_MAP_NAME
;
4046 procedure g_Game_DeleteTestMap();
4054 a
:= Pos('.wad:\', gMapToDelete
);
4058 // Âûäåëÿåì èìÿ wad-ôàéëà è èìÿ êàðòû:
4059 WadName
:= Copy(gMapToDelete
, 1, a
+ 3);
4060 Delete(gMapToDelete
, 1, a
+ 5);
4061 gMapToDelete
:= UpperCase(gMapToDelete
);
4063 CopyMemory(@MapName
[0], @gMapToDelete
[1], Min(16, Length(gMapToDelete
)));
4065 // Èìÿ êàðòû íå ñòàíäàðòíîå òåñòîâîå:
4066 if MapName
<> TEST_MAP_NAME
then
4069 if not gTempDelete
then
4071 time
:= g_GetFileTime(WadName
);
4072 WAD
:= TWADEditor_1
.Create();
4075 if not WAD
.ReadFile(WadName
) then
4076 begin // Íåò òàêîãî WAD-ôàéëà
4081 // Ñîñòàâëÿåì ñïèñîê êàðò è èùåì íóæíóþ:
4083 MapList
:= WAD
.GetResourcesList('');
4085 if MapList
<> nil then
4086 for a
:= 0 to High(MapList
) do
4087 if MapList
[a
] = MapName
then
4089 // Óäàëÿåì è ñîõðàíÿåì:
4090 WAD
.RemoveResource('', MapName
);
4091 WAD
.SaveTo(WadName
);
4096 g_SetFileTime(WadName
, time
);
4098 DeleteFile(WadName
);
4101 procedure GameCVars(P
: SArray
);
4104 stat
: TPlayerStatArray
;
4109 cmd
:= LowerCase(P
[0]);
4110 if cmd
= 'r_showfps' then
4112 if (Length(P
) > 1) and
4113 ((P
[1] = '1') or (P
[1] = '0')) then
4114 gShowFPS
:= (P
[1][1] = '1');
4117 g_Console_Add(_lc
[I_MSG_SHOW_FPS_ON
])
4119 g_Console_Add(_lc
[I_MSG_SHOW_FPS_OFF
]);
4121 else if (cmd
= 'g_friendlyfire') and not g_Game_IsClient
then
4123 with gGameSettings
do
4125 if (Length(P
) > 1) and
4126 ((P
[1] = '1') or (P
[1] = '0')) then
4128 if (P
[1][1] = '1') then
4129 Options
:= Options
or GAME_OPTION_TEAMDAMAGE
4131 Options
:= Options
and (not GAME_OPTION_TEAMDAMAGE
);
4134 if (LongBool(Options
and GAME_OPTION_TEAMDAMAGE
)) then
4135 g_Console_Add(_lc
[I_MSG_FRIENDLY_FIRE_ON
])
4137 g_Console_Add(_lc
[I_MSG_FRIENDLY_FIRE_OFF
]);
4139 if g_Game_IsNet
then MH_SEND_GameSettings
;
4142 else if (cmd
= 'g_weaponstay') and not g_Game_IsClient
then
4144 with gGameSettings
do
4146 if (Length(P
) > 1) and
4147 ((P
[1] = '1') or (P
[1] = '0')) then
4149 if (P
[1][1] = '1') then
4150 Options
:= Options
or GAME_OPTION_WEAPONSTAY
4152 Options
:= Options
and (not GAME_OPTION_WEAPONSTAY
);
4155 if (LongBool(Options
and GAME_OPTION_WEAPONSTAY
)) then
4156 g_Console_Add(_lc
[I_MSG_WEAPONSTAY_ON
])
4158 g_Console_Add(_lc
[I_MSG_WEAPONSTAY_OFF
]);
4160 if g_Game_IsNet
then MH_SEND_GameSettings
;
4163 else if cmd
= 'g_gamemode' then
4165 a
:= g_Game_TextToMode(P
[1]);
4166 if a
= GM_SINGLE
then a
:= GM_COOP
;
4167 if (Length(P
) > 1) and (a
<> GM_NONE
) and (not g_Game_IsClient
) then
4169 gSwitchGameMode
:= a
;
4170 if (gGameOn
and (gGameSettings
.GameMode
= GM_SINGLE
)) or
4171 (gState
= STATE_INTERSINGLE
) then
4172 gSwitchGameMode
:= GM_SINGLE
;
4174 gGameSettings
.GameMode
:= gSwitchGameMode
;
4176 if gSwitchGameMode
= gGameSettings
.GameMode
then
4177 g_Console_Add(Format(_lc
[I_MSG_GAMEMODE_CURRENT
],
4178 [g_Game_ModeToText(gGameSettings
.GameMode
)]))
4180 g_Console_Add(Format(_lc
[I_MSG_GAMEMODE_CHANGE
],
4181 [g_Game_ModeToText(gGameSettings
.GameMode
),
4182 g_Game_ModeToText(gSwitchGameMode
)]));
4184 else if (cmd
= 'g_allow_exit') and not g_Game_IsClient
then
4186 with gGameSettings
do
4188 if (Length(P
) > 1) and
4189 ((P
[1] = '1') or (P
[1] = '0')) then
4191 if (P
[1][1] = '1') then
4192 Options
:= Options
or GAME_OPTION_ALLOWEXIT
4194 Options
:= Options
and (not GAME_OPTION_ALLOWEXIT
);
4197 if (LongBool(Options
and GAME_OPTION_ALLOWEXIT
)) then
4198 g_Console_Add(_lc
[I_MSG_ALLOWEXIT_ON
])
4200 g_Console_Add(_lc
[I_MSG_ALLOWEXIT_OFF
]);
4201 g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
4203 if g_Game_IsNet
then MH_SEND_GameSettings
;
4206 else if (cmd
= 'g_allow_monsters') and not g_Game_IsClient
then
4208 with gGameSettings
do
4210 if (Length(P
) > 1) and
4211 ((P
[1] = '1') or (P
[1] = '0')) then
4213 if (P
[1][1] = '1') then
4214 Options
:= Options
or GAME_OPTION_MONSTERS
4216 Options
:= Options
and (not GAME_OPTION_MONSTERS
);
4219 if (LongBool(Options
and GAME_OPTION_MONSTERS
)) then
4220 g_Console_Add(_lc
[I_MSG_ALLOWMON_ON
])
4222 g_Console_Add(_lc
[I_MSG_ALLOWMON_OFF
]);
4223 g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
4225 if g_Game_IsNet
then MH_SEND_GameSettings
;
4228 else if (cmd
= 'g_bot_vsplayers') and not g_Game_IsClient
then
4230 with gGameSettings
do
4232 if (Length(P
) > 1) and
4233 ((P
[1] = '1') or (P
[1] = '0')) then
4235 if (P
[1][1] = '1') then
4236 Options
:= Options
or GAME_OPTION_BOTVSPLAYER
4238 Options
:= Options
and (not GAME_OPTION_BOTVSPLAYER
);
4241 if (LongBool(Options
and GAME_OPTION_BOTVSPLAYER
)) then
4242 g_Console_Add(_lc
[I_MSG_BOTSVSPLAYERS_ON
])
4244 g_Console_Add(_lc
[I_MSG_BOTSVSPLAYERS_OFF
]);
4246 if g_Game_IsNet
then MH_SEND_GameSettings
;
4249 else if (cmd
= 'g_bot_vsmonsters') and not g_Game_IsClient
then
4251 with gGameSettings
do
4253 if (Length(P
) > 1) and
4254 ((P
[1] = '1') or (P
[1] = '0')) then
4256 if (P
[1][1] = '1') then
4257 Options
:= Options
or GAME_OPTION_BOTVSMONSTER
4259 Options
:= Options
and (not GAME_OPTION_BOTVSMONSTER
);
4262 if (LongBool(Options
and GAME_OPTION_BOTVSMONSTER
)) then
4263 g_Console_Add(_lc
[I_MSG_BOTSVSMONSTERS_ON
])
4265 g_Console_Add(_lc
[I_MSG_BOTSVSMONSTERS_OFF
]);
4267 if g_Game_IsNet
then MH_SEND_GameSettings
;
4270 else if (cmd
= 'g_warmuptime') and not g_Game_IsClient
then
4272 if Length(P
) > 1 then
4274 if StrToIntDef(P
[1], gGameSettings
.WarmupTime
) = 0 then
4275 gGameSettings
.WarmupTime
:= 30
4277 gGameSettings
.WarmupTime
:= StrToIntDef(P
[1], gGameSettings
.WarmupTime
);
4280 g_Console_Add(Format(_lc
[I_MSG_WARMUP
],
4281 [gGameSettings
.WarmupTime
]));
4282 g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
4284 else if cmd
= 'net_interp' then
4286 if (Length(P
) > 1) then
4287 NetInterpLevel
:= StrToIntDef(P
[1], NetInterpLevel
);
4289 g_Console_Add('net_interp = ' + IntToStr(NetInterpLevel
));
4290 config
:= TConfig
.CreateFile(GameDir
+'/'+CONFIG_FILENAME
);
4291 config
.WriteInt('Client', 'InterpolationSteps', NetInterpLevel
);
4292 config
.SaveFile(GameDir
+'/'+CONFIG_FILENAME
);
4295 else if cmd
= 'net_forceplayerupdate' then
4297 if (Length(P
) > 1) and
4298 ((P
[1] = '1') or (P
[1] = '0')) then
4299 NetForcePlayerUpdate
:= (P
[1][1] = '1');
4301 if NetForcePlayerUpdate
then
4302 g_Console_Add('net_forceplayerupdate = 1')
4304 g_Console_Add('net_forceplayerupdate = 0');
4305 config
:= TConfig
.CreateFile(GameDir
+'/'+CONFIG_FILENAME
);
4306 config
.WriteBool('Client', 'ForcePlayerUpdate', NetForcePlayerUpdate
);
4307 config
.SaveFile(GameDir
+'/'+CONFIG_FILENAME
);
4310 else if cmd
= 'net_predictself' then
4312 if (Length(P
) > 1) and
4313 ((P
[1] = '1') or (P
[1] = '0')) then
4314 NetPredictSelf
:= (P
[1][1] = '1');
4316 if NetPredictSelf
then
4317 g_Console_Add('net_predictself = 1')
4319 g_Console_Add('net_predictself = 0');
4320 config
:= TConfig
.CreateFile(GameDir
+'/'+CONFIG_FILENAME
);
4321 config
.WriteBool('Client', 'PredictSelf', NetPredictSelf
);
4322 config
.SaveFile(GameDir
+'/'+CONFIG_FILENAME
);
4325 else if cmd
= 'sv_name' then
4327 if (Length(P
) > 1) and (Length(P
[1]) > 0) then
4329 NetServerName
:= P
[1];
4330 if Length(NetServerName
) > 64 then
4331 SetLength(NetServerName
, 64);
4332 if g_Game_IsServer
and g_Game_IsNet
and NetUseMaster
then
4336 g_Console_Add(cmd
+ ' = "' + NetServerName
+ '"');
4338 else if cmd
= 'sv_passwd' then
4340 if (Length(P
) > 1) and (Length(P
[1]) > 0) then
4342 NetPassword
:= P
[1];
4343 if Length(NetPassword
) > 24 then
4344 SetLength(NetPassword
, 24);
4345 if g_Game_IsServer
and g_Game_IsNet
and NetUseMaster
then
4349 g_Console_Add(cmd
+ ' = "' + AnsiLowerCase(NetPassword
) + '"');
4351 else if cmd
= 'sv_maxplrs' then
4353 if (Length(P
) > 1) then
4355 NetMaxClients
:= Min(Max(StrToIntDef(P
[1], NetMaxClients
), 1), NET_MAXCLIENTS
);
4356 if g_Game_IsServer
and g_Game_IsNet
then
4359 for a
:= 0 to High(NetClients
) do
4360 if NetClients
[a
].Used
then
4363 if b
> NetMaxClients
then
4365 s
:= g_Player_Get(NetClients
[a
].Player
).Name
;
4366 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_FULL
);
4367 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
4368 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
4371 if NetUseMaster
then
4376 g_Console_Add(cmd
+ ' = ' + IntToStr(NetMaxClients
));
4378 else if cmd
= 'sv_public' then
4380 if (Length(P
) > 1) then
4382 NetUseMaster
:= StrToIntDef(P
[1], Byte(NetUseMaster
)) > 0;
4383 if g_Game_IsServer
and g_Game_IsNet
then
4384 if NetUseMaster
then
4386 if NetMPeer
= nil then
4387 if not g_Net_Slist_Connect() then
4388 g_Console_Add(_lc
[I_NET_MSG_ERROR
] + _lc
[I_NET_SLIST_ERROR
]);
4389 g_Net_Slist_Update();
4392 if NetMPeer
<> nil then
4393 g_Net_Slist_Disconnect();
4396 g_Console_Add(cmd
+ ' = ' + IntToStr(Byte(NetUseMaster
)));
4398 else if cmd
= 'sv_intertime' then
4400 if (Length(P
) > 1) then
4401 gDefInterTime
:= Min(Max(StrToIntDef(P
[1], gDefInterTime
), -1), 120);
4403 g_Console_Add(cmd
+ ' = ' + IntToStr(gDefInterTime
));
4405 else if cmd
= 'p1_name' then
4407 if (Length(P
) > 1) and gGameOn
then
4409 if g_Game_IsClient
then
4411 gPlayer1Settings
.Name
:= b_Text_Unformat(P
[1]);
4412 MC_SEND_PlayerSettings
;
4415 if gPlayer1
<> nil then
4417 gPlayer1
.Name
:= b_Text_Unformat(P
[1]);
4418 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer1
.UID
);
4421 gPlayer1Settings
.Name
:= b_Text_Unformat(P
[1]);
4424 else if cmd
= 'p2_name' then
4426 if (Length(P
) > 1) and gGameOn
then
4428 if g_Game_IsClient
then
4430 gPlayer2Settings
.Name
:= b_Text_Unformat(P
[1]);
4431 MC_SEND_PlayerSettings
;
4434 if gPlayer2
<> nil then
4436 gPlayer2
.Name
:= b_Text_Unformat(P
[1]);
4437 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer2
.UID
);
4440 gPlayer2Settings
.Name
:= b_Text_Unformat(P
[1]);
4443 else if cmd
= 'p1_color' then
4445 if Length(P
) > 3 then
4446 if g_Game_IsClient
then
4448 gPlayer1Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
4449 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
4450 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
4451 MC_SEND_PlayerSettings
;
4454 if gPlayer1
<> nil then
4456 gPlayer1
.Model
.SetColor(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
4457 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
4458 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
4459 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer1
.UID
);
4462 gPlayer1Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
4463 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
4464 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
4466 else if (cmd
= 'p2_color') and not g_Game_IsNet
then
4468 if Length(P
) > 3 then
4469 if g_Game_IsClient
then
4471 gPlayer2Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
4472 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
4473 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
4474 MC_SEND_PlayerSettings
;
4477 if gPlayer2
<> nil then
4479 gPlayer2
.Model
.SetColor(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
4480 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
4481 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
4482 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer2
.UID
);
4485 gPlayer2Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
4486 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
4487 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
4489 else if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
4491 if cmd
= 'r_showtime' then
4493 if (Length(P
) > 1) and
4494 ((P
[1] = '1') or (P
[1] = '0')) then
4495 gShowTime
:= (P
[1][1] = '1');
4498 g_Console_Add(_lc
[I_MSG_TIME_ON
])
4500 g_Console_Add(_lc
[I_MSG_TIME_OFF
]);
4502 else if cmd
= 'r_showscore' then
4504 if (Length(P
) > 1) and
4505 ((P
[1] = '1') or (P
[1] = '0')) then
4506 gShowGoals
:= (P
[1][1] = '1');
4509 g_Console_Add(_lc
[I_MSG_SCORE_ON
])
4511 g_Console_Add(_lc
[I_MSG_SCORE_OFF
]);
4513 else if cmd
= 'r_showstat' then
4515 if (Length(P
) > 1) and
4516 ((P
[1] = '1') or (P
[1] = '0')) then
4517 gShowStat
:= (P
[1][1] = '1');
4520 g_Console_Add(_lc
[I_MSG_STATS_ON
])
4522 g_Console_Add(_lc
[I_MSG_STATS_OFF
]);
4524 else if cmd
= 'r_showkillmsg' then
4526 if (Length(P
) > 1) and
4527 ((P
[1] = '1') or (P
[1] = '0')) then
4528 gShowKillMsg
:= (P
[1][1] = '1');
4530 if gShowKillMsg
then
4531 g_Console_Add(_lc
[I_MSG_KILL_MSGS_ON
])
4533 g_Console_Add(_lc
[I_MSG_KILL_MSGS_OFF
]);
4535 else if cmd
= 'r_showlives' then
4537 if (Length(P
) > 1) and
4538 ((P
[1] = '1') or (P
[1] = '0')) then
4539 gShowLives
:= (P
[1][1] = '1');
4542 g_Console_Add(_lc
[I_MSG_LIVES_ON
])
4544 g_Console_Add(_lc
[I_MSG_LIVES_OFF
]);
4546 else if cmd
= 'r_showspect' then
4548 if (Length(P
) > 1) and
4549 ((P
[1] = '1') or (P
[1] = '0')) then
4550 gSpectHUD
:= (P
[1][1] = '1');
4553 g_Console_Add(_lc
[I_MSG_SPECT_HUD_ON
])
4555 g_Console_Add(_lc
[I_MSG_SPECT_HUD_OFF
]);
4557 else if cmd
= 'r_showping' then
4559 if (Length(P
) > 1) and
4560 ((P
[1] = '1') or (P
[1] = '0')) then
4561 gShowPing
:= (P
[1][1] = '1');
4564 g_Console_Add(_lc
[I_MSG_PING_ON
])
4566 g_Console_Add(_lc
[I_MSG_PING_OFF
]);
4568 else if (cmd
= 'g_scorelimit') and not g_Game_IsClient
then
4570 if Length(P
) > 1 then
4572 if StrToIntDef(P
[1], gGameSettings
.GoalLimit
) = 0 then
4573 gGameSettings
.GoalLimit
:= 0
4578 if gGameSettings
.GameMode
= GM_DM
then
4580 stat
:= g_Player_GetStats();
4582 for a
:= 0 to High(stat
) do
4583 if stat
[a
].Frags
> b
then
4587 b
:= Max(gTeamStat
[TEAM_RED
].Goals
, gTeamStat
[TEAM_BLUE
].Goals
);
4589 gGameSettings
.GoalLimit
:= Max(StrToIntDef(P
[1], gGameSettings
.GoalLimit
), b
);
4592 if g_Game_IsNet
then MH_SEND_GameSettings
;
4595 g_Console_Add(Format(_lc
[I_MSG_SCORE_LIMIT
], [gGameSettings
.GoalLimit
]));
4597 else if (cmd
= 'g_timelimit') and not g_Game_IsClient
then
4599 if (Length(P
) > 1) and (StrToIntDef(P
[1], -1) >= 0) then
4600 gGameSettings
.TimeLimit
:= StrToIntDef(P
[1], -1);
4602 g_Console_Add(Format(_lc
[I_MSG_TIME_LIMIT
],
4603 [gGameSettings
.TimeLimit
div 3600,
4604 (gGameSettings
.TimeLimit
div 60) mod 60,
4605 gGameSettings
.TimeLimit
mod 60]));
4606 if g_Game_IsNet
then MH_SEND_GameSettings
;
4608 else if (cmd
= 'g_maxlives') and not g_Game_IsClient
then
4610 if Length(P
) > 1 then
4612 if StrToIntDef(P
[1], gGameSettings
.MaxLives
) = 0 then
4613 gGameSettings
.MaxLives
:= 0
4617 stat
:= g_Player_GetStats();
4619 for a
:= 0 to High(stat
) do
4620 if stat
[a
].Lives
> b
then
4622 gGameSettings
.MaxLives
:=
4623 Max(StrToIntDef(P
[1], gGameSettings
.MaxLives
), b
);
4627 g_Console_Add(Format(_lc
[I_MSG_LIVES
],
4628 [gGameSettings
.MaxLives
]));
4629 if g_Game_IsNet
then MH_SEND_GameSettings
;
4634 procedure DebugCommands(P
: SArray
);
4640 // Êîìàíäû îòëàäî÷íîãî ðåæèìà:
4643 cmd
:= LowerCase(P
[0]);
4644 if cmd
= 'd_window' then
4646 g_Console_Add(Format('gWinPosX = %d, gWinPosY %d', [gWinPosX
, gWinPosY
]));
4647 g_Console_Add(Format('gWinRealPosX = %d, gWinRealPosY %d', [gWinRealPosX
, gWinRealPosY
]));
4648 g_Console_Add(Format('gScreenWidth = %d, gScreenHeight = %d', [gScreenWidth
, gScreenHeight
]));
4649 g_Console_Add(Format('gWinSizeX = %d, gWinSizeY = %d', [gWinSizeX
, gWinSizeY
]));
4650 g_Console_Add(Format('Frame X = %d, Y = %d, Caption Y = %d', [gWinFrameX
, gWinFrameY
, gWinCaption
]));
4652 else if cmd
= 'd_sounds' then
4654 if (Length(P
) > 1) and
4655 ((P
[1] = '1') or (P
[1] = '0')) then
4656 g_Debug_Sounds
:= (P
[1][1] = '1');
4658 g_Console_Add(Format('d_sounds is %d', [Byte(g_Debug_Sounds
)]));
4660 else if cmd
= 'd_frames' then
4662 if (Length(P
) > 1) and
4663 ((P
[1] = '1') or (P
[1] = '0')) then
4664 g_Debug_Frames
:= (P
[1][1] = '1');
4666 g_Console_Add(Format('d_frames is %d', [Byte(g_Debug_Frames
)]));
4668 else if cmd
= 'd_winmsg' then
4670 if (Length(P
) > 1) and
4671 ((P
[1] = '1') or (P
[1] = '0')) then
4672 g_Debug_WinMsgs
:= (P
[1][1] = '1');
4674 g_Console_Add(Format('d_winmsg is %d', [Byte(g_Debug_WinMsgs
)]));
4676 else if (cmd
= 'd_monoff') and not g_Game_IsNet
then
4678 if (Length(P
) > 1) and
4679 ((P
[1] = '1') or (P
[1] = '0')) then
4680 g_Debug_MonsterOff
:= (P
[1][1] = '1');
4682 g_Console_Add(Format('d_monoff is %d', [Byte(g_debug_MonsterOff
)]));
4684 else if (cmd
= 'd_botoff') and not g_Game_IsNet
then
4686 if Length(P
) > 1 then
4688 '0': g_debug_BotAIOff
:= 0;
4689 '1': g_debug_BotAIOff
:= 1;
4690 '2': g_debug_BotAIOff
:= 2;
4691 '3': g_debug_BotAIOff
:= 3;
4694 g_Console_Add(Format('d_botoff is %d', [g_debug_BotAIOff
]));
4696 else if cmd
= 'd_monster' then
4698 if gGameOn
and (gPlayer1
<> nil) and (gPlayer1
.Live
) and (not g_Game_IsNet
) then
4699 if Length(P
) < 2 then
4701 g_Console_Add(cmd
+ ' [ID | Name] [behaviour]');
4702 g_Console_Add('ID | Name');
4703 for b
:= MONSTER_DEMON
to MONSTER_MAN
do
4704 g_Console_Add(Format('%2d | %s', [b
, g_Monsters_GetNameByID(b
)]));
4707 a
:= StrToIntDef(P
[1], 0);
4708 if (a
< MONSTER_DEMON
) or (a
> MONSTER_MAN
) then
4709 a
:= g_Monsters_GetIDByName(P
[1]);
4711 if (a
< MONSTER_DEMON
) or (a
> MONSTER_MAN
) then
4712 g_Console_Add(Format(_lc
[I_MSG_NO_MONSTER
], [P
[1]]))
4715 with gPlayer1
.Obj
do
4716 b
:= g_Monsters_Create(a
,
4717 X
+ Rect
.X
+ (Rect
.Width
div 2),
4718 Y
+ Rect
.Y
+ Rect
.Height
,
4719 gPlayer1
.Direction
, True);
4720 if (Length(P
) > 2) and (b
>= 0) then
4721 gMonsters
[b
].MonsterBehaviour
:= Min(Max(StrToIntDef(P
[2], BH_NORMAL
), BH_NORMAL
), BH_GOOD
);
4725 else if (cmd
= 'd_health') then
4727 if (Length(P
) > 1) and
4728 ((P
[1] = '1') or (P
[1] = '0')) then
4729 g_debug_HealthBar
:= (P
[1][1] = '1');
4731 g_Console_Add(Format('d_health is %d', [Byte(g_debug_HealthBar
)]));
4733 else if (cmd
= 'd_player') then
4735 if (Length(P
) > 1) and
4736 ((P
[1] = '1') or (P
[1] = '0')) then
4737 g_debug_Player
:= (P
[1][1] = '1');
4739 g_Console_Add(Format(cmd
+ ' is %d', [Byte(g_Debug_Player
)]));
4741 else if (cmd
= 'd_joy') then
4744 g_Console_Add(e_JoystickStateToString(a
));
4748 g_Console_Add(_lc
[I_MSG_NOT_DEBUG
]);
4751 procedure GameCommands(P
: SArray
);
4757 pl
: pTNetClient
= nil;
4764 cmd
:= LowerCase(P
[0]);
4766 if (cmd
= 'quit') or
4773 else if cmd
= 'pause' then
4775 if (g_ActiveWindow
= nil) then
4776 g_Game_Pause(not gPause
);
4778 else if cmd
= 'endgame' then
4779 gExit
:= EXIT_SIMPLE
4780 else if cmd
= 'restart' then
4782 if gGameOn
or (gState
in [STATE_INTERSINGLE
, STATE_INTERCUSTOM
]) then
4784 if g_Game_IsClient
then
4786 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4791 g_Console_Add(_lc
[I_MSG_NOT_GAME
]);
4793 else if cmd
= 'kick' then
4795 if g_Game_IsServer
then
4797 if Length(P
) < 2 then
4799 g_Console_Add('kick <name>');
4804 g_Console_Add('kick <name>');
4808 if g_Game_IsNet
then
4809 pl
:= g_Net_Client_ByName(P
[1]);
4812 s
:= g_Net_ClientName_ByID(pl
^.ID
);
4813 enet_peer_disconnect(pl
^.Peer
, NET_DISC_KICK
);
4814 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
4815 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
4816 if NetUseMaster
then
4818 end else if gPlayers
<> nil then
4819 for a
:= Low(gPlayers
) to High(gPlayers
) do
4820 if gPlayers
[a
] <> nil then
4821 if Copy(LowerCase(gPlayers
[a
].Name
), 1, Length(P
[1])) = LowerCase(P
[1]) then
4823 // Íå îòêëþ÷àòü îñíîâíûõ èãðîêîâ â ñèíãëå
4824 if not(gPlayers
[a
] is TBot
) and (gGameSettings
.GameType
= GT_SINGLE
) then
4826 gPlayers
[a
].Lives
:= 0;
4827 gPlayers
[a
].Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
4828 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [gPlayers
[a
].Name
]), True);
4829 g_Player_Remove(gPlayers
[a
].UID
);
4830 if NetUseMaster
then
4832 // Åñëè íå ïåðåìåøàòü, ïðè äîáàâëåíèè íîâûõ áîòîâ ïîÿâÿòñÿ ñòàðûå
4836 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
4838 else if cmd
= 'kick_id' then
4840 if g_Game_IsServer
and g_Game_IsNet
then
4842 if Length(P
) < 2 then
4844 g_Console_Add('kick_id <client ID>');
4849 g_Console_Add('kick_id <client ID>');
4853 a
:= StrToIntDef(P
[1], 0);
4854 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
4856 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
4858 s
:= g_Net_ClientName_ByID(NetClients
[a
].ID
);
4859 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_KICK
);
4860 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
4861 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
4862 if NetUseMaster
then
4867 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4869 else if cmd
= 'ban' then
4871 if g_Game_IsServer
and g_Game_IsNet
then
4873 if Length(P
) < 2 then
4875 g_Console_Add('ban <name>');
4880 g_Console_Add('ban <name>');
4884 pl
:= g_Net_Client_ByName(P
[1]);
4887 s
:= g_Net_ClientName_ByID(pl
^.ID
);
4888 g_Net_BanHost(pl
^.Peer
^.address
.host
, False);
4889 enet_peer_disconnect(pl
^.Peer
, NET_DISC_TEMPBAN
);
4890 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
4891 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
4892 if NetUseMaster
then
4895 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
4897 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4899 else if cmd
= 'ban_id' then
4901 if g_Game_IsServer
and g_Game_IsNet
then
4903 if Length(P
) < 2 then
4905 g_Console_Add('ban_id <client ID>');
4910 g_Console_Add('ban_id <client ID>');
4914 a
:= StrToIntDef(P
[1], 0);
4915 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
4916 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
4918 s
:= g_Net_ClientName_ByID(NetClients
[a
].ID
);
4919 g_Net_BanHost(NetClients
[a
].Peer
^.address
.host
, False);
4920 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_TEMPBAN
);
4921 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
4922 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
4923 if NetUseMaster
then
4927 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4929 else if cmd
= 'permban' then
4931 if g_Game_IsServer
and g_Game_IsNet
then
4933 if Length(P
) < 2 then
4935 g_Console_Add('permban <name>');
4940 g_Console_Add('permban <name>');
4944 pl
:= g_Net_Client_ByName(P
[1]);
4947 s
:= g_Net_ClientName_ByID(pl
^.ID
);
4948 g_Net_BanHost(pl
^.Peer
^.address
.host
);
4949 enet_peer_disconnect(pl
^.Peer
, NET_DISC_BAN
);
4950 g_Net_SaveBanList();
4951 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
4952 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
4953 if NetUseMaster
then
4956 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
4958 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4960 else if cmd
= 'permban_id' then
4962 if g_Game_IsServer
and g_Game_IsNet
then
4964 if Length(P
) < 2 then
4966 g_Console_Add('permban_id <client ID>');
4971 g_Console_Add('permban_id <client ID>');
4975 a
:= StrToIntDef(P
[1], 0);
4976 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
4977 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
4979 s
:= g_Net_ClientName_ByID(NetClients
[a
].ID
);
4980 g_Net_BanHost(NetClients
[a
].Peer
^.address
.host
);
4981 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_BAN
);
4982 g_Net_SaveBanList();
4983 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
4984 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
4985 if NetUseMaster
then
4989 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4991 else if cmd
= 'unban' then
4993 if g_Game_IsServer
and g_Game_IsNet
then
4995 if Length(P
) < 2 then
4997 g_Console_Add('unban <IP Address>');
5002 g_Console_Add('unban <IP Address>');
5006 if g_Net_UnbanHost(P
[1]) then
5008 g_Console_Add(Format(_lc
[I_MSG_UNBAN_OK
], [P
[1]]));
5009 g_Net_SaveBanList();
5011 g_Console_Add(Format(_lc
[I_MSG_UNBAN_FAIL
], [P
[1]]));
5013 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
5015 else if cmd
= 'clientlist' then
5017 if g_Game_IsServer
and g_Game_IsNet
then
5020 if NetClients
<> nil then
5021 for a
:= Low(NetClients
) to High(NetClients
) do
5022 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
5024 plr
:= g_Player_Get(NetClients
[a
].Player
);
5025 if plr
= nil then continue
;
5027 g_Console_Add(Format('#%2d: %-15s | %s', [a
,
5028 IpToStr(NetClients
[a
].Peer
^.address
.host
), plr
.Name
]));
5031 g_Console_Add(_lc
[I_MSG_NOCLIENTS
]);
5033 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
5035 else if cmd
= 'connect' then
5037 if (NetMode
= NET_NONE
) then
5039 if Length(P
) < 2 then
5041 g_Console_Add('connect <IP> [port] [password]');
5046 g_Console_Add('connect <IP> [port] [password]');
5050 if Length(P
) > 2 then
5051 prt
:= StrToIntDef(P
[2], 25666)
5055 if Length(P
) > 3 then
5060 g_Game_StartClient(P
[1], prt
, pw
);
5063 else if cmd
= 'disconnect' then
5065 if (NetMode
= NET_CLIENT
) then
5068 else if cmd
= 'reconnect' then
5070 if (NetMode
= NET_SERVER
) then
5073 if (NetMode
= NET_CLIENT
) then
5076 gExit
:= EXIT_SIMPLE
;
5080 //TODO: Use last successful password to reconnect, instead of ''
5081 g_Game_StartClient(NetClientIP
, NetClientPort
, '');
5083 else if (cmd
= 'addbot') or
5084 (cmd
= 'bot_add') then
5086 if Length(P
) > 1 then
5087 g_Bot_Add(TEAM_NONE
, StrToIntDef(P
[1], 2))
5089 g_Bot_Add(TEAM_NONE
, 2);
5091 else if cmd
= 'bot_addlist' then
5093 if Length(P
) > 1 then
5094 if Length(P
) = 2 then
5095 g_Bot_AddList(TEAM_NONE
, P
[1], StrToIntDef(P
[1], -1))
5097 g_Bot_AddList(IfThen(P
[2] = 'red', TEAM_RED
, TEAM_BLUE
), P
[1], StrToIntDef(P
[1], -1));
5099 else if cmd
= 'bot_removeall' then
5101 else if cmd
= 'chat' then
5103 if g_Game_IsNet
then
5105 if Length(P
) > 1 then
5107 for a
:= 1 to High(P
) do
5108 chstr
:= chstr
+ P
[a
] + ' ';
5110 if Length(chstr
) > 200 then SetLength(chstr
, 200);
5112 if Length(chstr
) < 1 then
5114 g_Console_Add('chat <text>');
5118 chstr
:= b_Text_Format(chstr
);
5119 if g_Game_IsClient
then
5120 MC_SEND_Chat(chstr
, NET_CHAT_PLAYER
)
5122 MH_SEND_Chat(gPlayer1Settings
.Name
+ ': ' + chstr
, NET_CHAT_PLAYER
);
5125 g_Console_Add('chat <text>');
5127 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
5129 else if cmd
= 'teamchat' then
5131 if g_Game_IsNet
and (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
5133 if Length(P
) > 1 then
5135 for a
:= 1 to High(P
) do
5136 chstr
:= chstr
+ P
[a
] + ' ';
5138 if Length(chstr
) > 200 then SetLength(chstr
, 200);
5140 if Length(chstr
) < 1 then
5142 g_Console_Add('teamchat <text>');
5146 chstr
:= b_Text_Format(chstr
);
5147 if g_Game_IsClient
then
5148 MC_SEND_Chat(chstr
, NET_CHAT_TEAM
)
5150 MH_SEND_Chat(gPlayer1Settings
.Name
+ ': ' + chstr
, NET_CHAT_TEAM
,
5151 gPlayer1Settings
.Team
);
5154 g_Console_Add('teamchat <text>');
5156 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
5158 else if cmd
= 'game' then
5160 if gGameSettings
.GameType
<> GT_NONE
then
5162 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
5165 if Length(P
) = 1 then
5167 g_Console_Add(cmd
+ ' <WAD> [MAP] [# players]');
5170 // Èãðà åù¸ íå çàïóùåíà, ñíà÷àëà íàì íàäî çàãðóçèòü êàêîé-òî WAD
5171 if Pos('.wad', LowerCase(P
[1])) = 0 then
5172 P
[1] := P
[1] + '.wad';
5174 if FileExists(MapsDir
+ P
[1]) then
5176 // Åñëè êàðòà íå óêàçàíà, áåð¸ì ïåðâóþ êàðòó â ôàéëå
5177 if Length(P
) < 3 then
5180 P
[2] := g_Game_GetFirstMap(MapsDir
+ P
[1]);
5183 s
:= P
[1] + ':\' + UpperCase(P
[2]);
5185 if g_Map_Exist(MapsDir
+ s
) then
5187 // Çàïóñêàåì ñâîþ èãðó
5189 with gGameSettings
do
5191 GameMode
:= g_Game_TextToMode(gcGameMode
);
5192 if gSwitchGameMode
<> GM_NONE
then
5193 GameMode
:= gSwitchGameMode
;
5194 if GameMode
= GM_NONE
then GameMode
:= GM_DM
;
5195 if GameMode
= GM_SINGLE
then GameMode
:= GM_COOP
;
5197 if Length(P
) >= 4 then
5198 b
:= StrToIntDef(P
[3], 1);
5199 g_Game_StartCustom(s
, GameMode
, TimeLimit
,
5200 GoalLimit
, MaxLives
, Options
, b
);
5205 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
5207 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [UpperCase(P
[2])]));
5209 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]));
5211 else if cmd
= 'host' then
5213 if gGameSettings
.GameType
<> GT_NONE
then
5215 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
5218 if Length(P
) < 4 then
5220 g_Console_Add(cmd
+ ' <listen IP> <port> <WAD> [MAP] [# players]');
5223 if not StrToIp(P
[1], listen
) then
5225 prt
:= StrToIntDef(P
[2], 25666);
5227 if Pos('.wad', LowerCase(P
[3])) = 0 then
5228 P
[3] := P
[3] + '.wad';
5230 if FileExists(MapsDir
+ P
[3]) then
5232 // Åñëè êàðòà íå óêàçàíà, áåð¸ì ïåðâóþ êàðòó â ôàéëå
5233 if Length(P
) < 5 then
5236 P
[4] := g_Game_GetFirstMap(MapsDir
+ P
[1]);
5239 s
:= P
[3] + ':\' + UpperCase(P
[4]);
5241 if g_Map_Exist(MapsDir
+ s
) then
5243 // Çàïóñêàåì ñâîþ èãðó
5245 with gGameSettings
do
5247 GameMode
:= g_Game_TextToMode(gcGameMode
);
5248 if gSwitchGameMode
<> GM_NONE
then
5249 GameMode
:= gSwitchGameMode
;
5250 if GameMode
= GM_NONE
then GameMode
:= GM_DM
;
5251 if GameMode
= GM_SINGLE
then GameMode
:= GM_COOP
;
5253 if Length(P
) >= 6 then
5254 b
:= StrToIntDef(P
[5], 0);
5255 g_Game_StartServer(s
, GameMode
, TimeLimit
,
5256 GoalLimit
, MaxLives
, Options
, b
, listen
, prt
);
5261 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[3]]))
5263 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [UpperCase(P
[4])]));
5265 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[3]]));
5267 else if cmd
= 'map' then
5269 if Length(P
) = 1 then
5271 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
5273 g_Console_Add(cmd
+ ' <MAP>');
5274 g_Console_Add(cmd
+ ' <WAD> [MAP]');
5276 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
5278 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
5280 // Èä¸ò ñâîÿ èãðà èëè ñåðâåð
5281 if Length(P
) < 3 then
5283 // Ïåðâûé ïàðàìåòð - ëèáî êàðòà, ëèáî èìÿ WAD ôàéëà
5284 s
:= UpperCase(P
[1]);
5285 if g_Map_Exist(MapsDir
+ gGameSettings
.WAD
+ ':\' + s
) then
5286 begin // Êàðòà íàøëàñü
5287 gExitByTrigger
:= False;
5289 begin // Èä¸ò èãðà - çàâåðøàåì óðîâåíü
5291 gExit
:= EXIT_ENDLEVELCUSTOM
;
5293 else // Èíòåðìèññèÿ - ñðàçó çàãðóæàåì êàðòó
5294 g_Game_ChangeMap(s
);
5297 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [s
]));
5298 // Òàêîé êàðòû íåò, èùåì WAD ôàéë
5299 if Pos('.wad', LowerCase(P
[1])) = 0 then
5300 P
[1] := P
[1] + '.wad';
5302 if FileExists(MapsDir
+ P
[1]) then
5304 // Ïàðàìåòðà êàðòû íåò, ïîýòîìó ñòàâèì ïåðâóþ èç ôàéëà
5306 P
[2] := g_Game_GetFirstMap(MapsDir
+ P
[1]);
5308 s
:= P
[1] + ':\' + P
[2];
5310 if g_Map_Exist(MapsDir
+ s
) then
5312 gExitByTrigger
:= False;
5314 begin // Èä¸ò èãðà - çàâåðøàåì óðîâåíü
5316 gExit
:= EXIT_ENDLEVELCUSTOM
;
5318 else // Èíòåðìèññèÿ - ñðàçó çàãðóæàåì êàðòó
5319 g_Game_ChangeMap(s
);
5322 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
5324 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]));
5326 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]));
5330 // Óêàçàíî äâà ïàðàìåòðà, çíà÷èò ïåðâûé - WAD ôàéë, à âòîðîé - êàðòà
5331 if Pos('.wad', LowerCase(P
[1])) = 0 then
5332 P
[1] := P
[1] + '.wad';
5334 if FileExists(MapsDir
+ P
[1]) then
5337 P
[2] := UpperCase(P
[2]);
5338 s
:= P
[1] + ':\' + P
[2];
5340 if g_Map_Exist(MapsDir
+ s
) then
5341 begin // Íàøëè êàðòó
5342 gExitByTrigger
:= False;
5344 begin // Èä¸ò èãðà - çàâåðøàåì óðîâåíü
5346 gExit
:= EXIT_ENDLEVELCUSTOM
;
5348 else // Èíòåðìèññèÿ - ñðàçó çàãðóæàåì êàðòó
5349 g_Game_ChangeMap(s
);
5351 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]));
5353 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]));
5356 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
5358 else if cmd
= 'nextmap' then
5360 if not(gGameOn
or (gState
= STATE_INTERCUSTOM
)) then
5361 g_Console_Add(_lc
[I_MSG_NOT_GAME
])
5364 if Length(P
) = 1 then
5366 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
5368 g_Console_Add(cmd
+ ' <MAP>');
5369 g_Console_Add(cmd
+ ' <WAD> [MAP]');
5372 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
5377 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
5379 if Length(P
) < 3 then
5381 // Ïåðâûé ïàðàìåòð - ëèáî êàðòà, ëèáî èìÿ WAD ôàéëà
5382 s
:= UpperCase(P
[1]);
5383 if g_Map_Exist(MapsDir
+ gGameSettings
.WAD
+ ':\' + s
) then
5384 begin // Êàðòà íàøëàñü
5385 gExitByTrigger
:= False;
5390 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [s
]));
5391 // Òàêîé êàðòû íåò, èùåì WAD ôàéë
5392 if Pos('.wad', LowerCase(P
[1])) = 0 then
5393 P
[1] := P
[1] + '.wad';
5395 if FileExists(MapsDir
+ P
[1]) then
5397 // Ïàðàìåòðà êàðòû íåò, ïîýòîìó ñòàâèì ïåðâóþ èç ôàéëà
5399 P
[2] := g_Game_GetFirstMap(MapsDir
+ P
[1]);
5401 s
:= P
[1] + ':\' + P
[2];
5403 if g_Map_Exist(MapsDir
+ s
) then
5404 begin // Óñòàíàâëèâàåì êàðòó
5405 gExitByTrigger
:= False;
5410 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
5412 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]));
5414 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]));
5418 // Óêàçàíî äâà ïàðàìåòðà, çíà÷èò ïåðâûé - WAD ôàéë, à âòîðîé - êàðòà
5419 if Pos('.wad', LowerCase(P
[1])) = 0 then
5420 P
[1] := P
[1] + '.wad';
5422 if FileExists(MapsDir
+ P
[1]) then
5425 P
[2] := UpperCase(P
[2]);
5426 s
:= P
[1] + ':\' + P
[2];
5428 if g_Map_Exist(MapsDir
+ s
) then
5429 begin // Íàøëè êàðòó
5430 gExitByTrigger
:= False;
5434 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]));
5436 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]));
5439 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
5442 if gNextMap
= '' then
5443 g_Console_Add(_lc
[I_MSG_NEXTMAP_UNSET
])
5445 g_Console_Add(Format(_lc
[I_MSG_NEXTMAP_SET
], [gNextMap
]));
5448 else if (cmd
= 'endmap') or (cmd
= 'goodbye') then
5451 g_Console_Add(_lc
[I_MSG_NOT_GAME
])
5453 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
5455 gExitByTrigger
:= False;
5456 // Ñëåäóþùàÿ êàðòà íå çàäàíà, ïðîáóåì íàéòè òðèããåð Âûõîä
5457 if (gNextMap
= '') and (gTriggers
<> nil) then
5458 for a
:= 0 to High(gTriggers
) do
5459 if gTriggers
[a
].TriggerType
= TRIGGER_EXIT
then
5461 gExitByTrigger
:= True;
5462 gNextMap
:= gTriggers
[a
].Data
.MapName
;
5465 // Èùåì ñëåäóþùóþ êàðòó â WAD ôàéëå
5466 if gNextMap
= '' then
5467 gNextMap
:= g_Game_GetNextMap();
5468 // Ïðîâåðÿåì, íå çàäàí ëè WAD ôàéë ðåñóðñíîé ñòðîêîé
5469 if Pos(':\', gNextMap
) = 0 then
5470 s
:= gGameSettings
.WAD
+ ':\' + gNextMap
5473 // Åñëè êàðòà íàéäåíà, âûõîäèì ñ óðîâíÿ
5474 if g_Map_Exist(MapsDir
+ s
) then
5475 gExit
:= EXIT_ENDLEVELCUSTOM
5477 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [gNextMap
]));
5479 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
5481 else if (cmd
= 'event') then
5483 if (Length(P
) <= 1) then
5485 for a
:= 0 to High(gEvents
) do
5486 if gEvents
[a
].Command
= '' then
5487 g_Console_Add(gEvents
[a
].Name
+ ' <none>')
5489 g_Console_Add(gEvents
[a
].Name
+ ' "' + gEvents
[a
].Command
+ '"');
5492 if (Length(P
) = 2) then
5494 for a
:= 0 to High(gEvents
) do
5495 if gEvents
[a
].Name
= P
[1] then
5496 if gEvents
[a
].Command
= '' then
5497 g_Console_Add(gEvents
[a
].Name
+ ' <none>')
5499 g_Console_Add(gEvents
[a
].Name
+ ' "' + gEvents
[a
].Command
+ '"');
5502 for a
:= 0 to High(gEvents
) do
5503 if gEvents
[a
].Name
= P
[1] then
5505 gEvents
[a
].Command
:= '';
5506 for b
:= 2 to High(P
) do
5507 if Pos(' ', P
[b
]) = 0 then
5508 gEvents
[a
].Command
:= gEvents
[a
].Command
+ ' ' + P
[b
]
5510 gEvents
[a
].Command
:= gEvents
[a
].Command
+ ' "' + P
[b
] + '"';
5511 gEvents
[a
].Command
:= Trim(gEvents
[a
].Command
);
5515 // Êîìàíäû Ñâîåé èãðû:
5516 else if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
5518 if cmd
= 'bot_addred' then
5520 if Length(P
) > 1 then
5521 g_Bot_Add(TEAM_RED
, StrToIntDef(P
[1], 2))
5523 g_Bot_Add(TEAM_RED
, 2);
5525 else if cmd
= 'bot_addblue' then
5527 if Length(P
) > 1 then
5528 g_Bot_Add(TEAM_BLUE
, StrToIntDef(P
[1], 2))
5530 g_Bot_Add(TEAM_BLUE
, 2);
5532 else if cmd
= 'suicide' then
5536 if g_Game_IsClient
then
5537 MC_SEND_CheatRequest(NET_CHEAT_SUICIDE
)
5540 if gPlayer1
<> nil then
5541 gPlayer1
.Damage(SUICIDE_DAMAGE
, gPlayer1
.UID
, 0, 0, HIT_SELF
);
5542 if gPlayer2
<> nil then
5543 gPlayer2
.Damage(SUICIDE_DAMAGE
, gPlayer2
.UID
, 0, 0, HIT_SELF
);
5547 else if cmd
= 'spectate' then
5553 else if cmd
= 'say' then
5555 if g_Game_IsServer
and g_Game_IsNet
then
5557 if Length(P
) > 1 then
5560 for a
:= 1 to High(P
) do
5561 chstr
:= chstr
+ P
[a
] + ' ';
5563 if Length(chstr
) > 200 then SetLength(chstr
, 200);
5565 if Length(chstr
) < 1 then
5567 g_Console_Add('say <text>');
5571 chstr
:= b_Text_Format(chstr
);
5572 MH_SEND_Chat(chstr
, NET_CHAT_PLAYER
);
5574 else g_Console_Add('say <text>');
5576 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
5578 else if cmd
= 'tell' then
5580 if g_Game_IsServer
and g_Game_IsNet
then
5582 if (Length(P
) > 2) and (P
[1] <> '') then
5585 for a
:= 2 to High(P
) do
5586 chstr
:= chstr
+ P
[a
] + ' ';
5588 if Length(chstr
) > 200 then SetLength(chstr
, 200);
5590 if Length(chstr
) < 1 then
5592 g_Console_Add('tell <playername> <text>');
5596 pl
:= g_Net_Client_ByName(P
[1]);
5598 MH_SEND_Chat(b_Text_Format(chstr
), NET_CHAT_PLAYER
, pl
^.ID
)
5600 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
5602 else g_Console_Add('tell <playername> <text>');
5604 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
5606 else if (cmd
= 'overtime') and not g_Game_IsClient
then
5608 if (Length(P
) = 1) or (StrToIntDef(P
[1], -1) <= 0) then
5610 // Äîïîëíèòåëüíîå âðåìÿ:
5611 gGameSettings
.TimeLimit
:= (gTime
- gGameStartTime
) div 1000 + Word(StrToIntDef(P
[1], 0));
5613 g_Console_Add(Format(_lc
[I_MSG_TIME_LIMIT
],
5614 [gGameSettings
.TimeLimit
div 3600,
5615 (gGameSettings
.TimeLimit
div 60) mod 60,
5616 gGameSettings
.TimeLimit
mod 60]));
5617 if g_Game_IsNet
then MH_SEND_GameSettings
;
5619 else if (cmd
= 'rcon_password') and g_Game_IsClient
then
5621 if (Length(P
) <= 1) then
5622 g_Console_Add('rcon_password <password>')
5624 MC_SEND_RCONPassword(P
[1]);
5626 else if cmd
= 'rcon' then
5628 if g_Game_IsClient
then
5630 if Length(P
) > 1 then
5633 for a
:= 1 to High(P
) do
5634 chstr
:= chstr
+ P
[a
] + ' ';
5636 if Length(chstr
) > 200 then SetLength(chstr
, 200);
5638 if Length(chstr
) < 1 then
5640 g_Console_Add('rcon <command>');
5644 MC_SEND_RCONCommand(chstr
);
5646 else g_Console_Add('rcon <command>');
5649 else if cmd
= 'ready' then
5651 if g_Game_IsServer
and (gLMSRespawn
= LMS_RESPAWN_WARMUP
) then
5652 gLMSRespawnTime
:= gTime
+ 100;
5654 else if (cmd
= 'callvote') and g_Game_IsNet
then
5656 if Length(P
) > 1 then
5659 for a
:= 1 to High(P
) do begin
5660 if a
> 1 then chstr
:= chstr
+ ' ';
5661 chstr
:= chstr
+ P
[a
];
5664 if Length(chstr
) > 200 then SetLength(chstr
, 200);
5666 if Length(chstr
) < 1 then
5668 g_Console_Add('callvote <command>');
5672 if g_Game_IsClient
then
5673 MC_SEND_Vote(True, chstr
)
5675 g_Game_StartVote(chstr
, gPlayer1Settings
.Name
);
5676 g_Console_Process('vote', True);
5679 g_Console_Add('callvote <command>');
5681 else if (cmd
= 'vote') and g_Game_IsNet
then
5683 if g_Game_IsClient
then
5685 else if gVoteInProgress
then
5687 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
5688 a
:= Floor((NetClientCount
+1)/2.0) + 1
5690 a
:= Floor(NetClientCount
/2.0) + 1;
5695 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_REVOKED
], [gPlayer1Settings
.Name
, gVoteCount
, a
]), True);
5696 MH_SEND_VoteEvent(NET_VE_REVOKE
, gPlayer1Settings
.Name
, 'a', gVoteCount
, a
);
5702 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_VOTE
], [gPlayer1Settings
.Name
, gVoteCount
, a
]), True);
5703 MH_SEND_VoteEvent(NET_VE_VOTE
, gPlayer1Settings
.Name
, 'a', gVoteCount
, a
);
5711 procedure g_TakeScreenShot();
5716 for a
:= 1 to High(Word) do
5718 FileName
:= Format(GameDir
+'/Screenshots/Screenshot%.3d.bmp', [a
]);
5719 if not FileExists(FileName
) then
5721 e_MakeScreenshot(FileName
, gScreenWidth
, gScreenHeight
);
5722 g_Console_Add(Format(_lc
[I_CONSOLE_SCREENSHOT
], [ExtractFileName(FileName
)]));
5728 procedure g_Game_InGameMenu(Show
: Boolean);
5730 if (g_ActiveWindow
= nil) and Show
then
5732 if gGameSettings
.GameType
= GT_SINGLE
then
5733 g_GUI_ShowWindow('GameSingleMenu')
5736 if g_Game_IsClient
then
5737 g_GUI_ShowWindow('GameClientMenu')
5739 if g_Game_IsNet
then
5740 g_GUI_ShowWindow('GameServerMenu')
5742 g_GUI_ShowWindow('GameCustomMenu');
5744 g_Sound_PlayEx('MENU_OPEN');
5746 // Ïàóçà ïðè ìåíþ òîëüêî â îäèíî÷íîé èãðå:
5747 if (not g_Game_IsNet
) then
5751 if (g_ActiveWindow
<> nil) and (not Show
) then
5753 // Ïàóçà ïðè ìåíþ òîëüêî â îäèíî÷íîé èãðå:
5754 if (not g_Game_IsNet
) then
5755 g_Game_Pause(False);
5759 procedure g_Game_Pause(Enable
: Boolean);
5764 if gPause
= Enable
then
5767 if not (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
]) then
5771 g_Game_PauseAllSounds(Enable
);
5774 procedure g_Game_PauseAllSounds(Enable
: Boolean);
5779 if gTriggers
<> nil then
5780 for i
:= 0 to High(gTriggers
) do
5781 with gTriggers
[i
] do
5782 if (TriggerType
= TRIGGER_SOUND
) and
5784 Sound
.IsPlaying() then
5786 Sound
.Pause(Enable
);
5790 if gPlayers
<> nil then
5791 for i
:= 0 to High(gPlayers
) do
5792 if gPlayers
[i
] <> nil then
5793 gPlayers
[i
].PauseSounds(Enable
);
5796 if gMusic
<> nil then
5797 gMusic
.Pause(Enable
);
5800 procedure g_Game_StopAllSounds(all
: Boolean);
5804 if gTriggers
<> nil then
5805 for i
:= 0 to High(gTriggers
) do
5806 with gTriggers
[i
] do
5807 if (TriggerType
= TRIGGER_SOUND
) and
5811 if gMusic
<> nil then
5818 procedure g_Game_UpdateTriggerSounds();
5822 if gTriggers
<> nil then
5823 for i
:= 0 to High(gTriggers
) do
5824 with gTriggers
[i
] do
5825 if (TriggerType
= TRIGGER_SOUND
) and
5828 Sound
.IsPlaying() then
5830 if ((gPlayer1
<> nil) and g_CollidePoint(gPlayer1
.GameX
, gPlayer1
.GameY
, X
, Y
, Width
, Height
)) or
5831 ((gPlayer2
<> nil) and g_CollidePoint(gPlayer2
.GameX
, gPlayer2
.GameY
, X
, Y
, Width
, Height
)) then
5833 Sound
.SetPan(0.5 - Data
.Pan
/255.0);
5834 Sound
.SetVolume(Data
.Volume
/255.0);
5837 Sound
.SetCoords(X
+(Width
div 2), Y
+(Height
div 2), Data
.Volume
/255.0);
5841 function g_Game_IsWatchedPlayer(UID
: Word): Boolean;
5844 if (gPlayer1
<> nil) and (gPlayer1
.UID
= UID
) then
5849 if (gPlayer2
<> nil) and (gPlayer2
.UID
= UID
) then
5854 if gSpectMode
<> SPECT_PLAYERS
then
5856 if gSpectPID1
= UID
then
5861 if gSpectViewTwo
and (gSpectPID2
= UID
) then
5868 function g_Game_IsWatchedTeam(Team
: Byte): Boolean;
5873 if (gPlayer1
<> nil) and (gPlayer1
.Team
= Team
) then
5878 if (gPlayer2
<> nil) and (gPlayer2
.Team
= Team
) then
5883 if gSpectMode
<> SPECT_PLAYERS
then
5885 Pl
:= g_Player_Get(gSpectPID1
);
5886 if (Pl
<> nil) and (Pl
.Team
= Team
) then
5891 if gSpectViewTwo
then
5893 Pl
:= g_Player_Get(gSpectPID2
);
5894 if (Pl
<> nil) and (Pl
.Team
= Team
) then
5902 procedure g_Game_Message(Msg
: string; Time
: Word);
5904 MessageText
:= b_Text_Format(Msg
);
5905 MessageTime
:= Time
;
5908 procedure g_Game_Announce_GoodShot(SpawnerUID
: Word);
5917 if not g_Game_IsWatchedPlayer(SpawnerUID
) then
5921 if goodsnd
[a
].IsPlaying() then
5924 goodsnd
[Random(4)].Play();
5927 procedure g_Game_Announce_KillCombo(Param
: Integer);
5934 UID
:= Param
and $FFFF;
5939 Pl
:= g_Player_Get(UID
);
5948 g_Console_Add(Format(_lc
[I_PLAYER_KILL_2X
], [Name
]), True);
5952 g_Console_Add(Format(_lc
[I_PLAYER_KILL_3X
], [Name
]), True);
5956 g_Console_Add(Format(_lc
[I_PLAYER_KILL_4X
], [Name
]), True);
5960 g_Console_Add(Format(_lc
[I_PLAYER_KILL_MX
], [Name
]), True);
5968 if not g_Game_IsWatchedPlayer(UID
) then
5971 if (not g_Game_IsWatchedPlayer(UID
)) and (c
< 4) then
5975 if killsnd
[n
].IsPlaying() then
5980 procedure g_Game_StartVote(Command
, Initiator
: string);
5984 if not gVotesEnabled
then Exit
;
5985 if gGameSettings
.GameType
<> GT_SERVER
then Exit
;
5986 if gVoteInProgress
or gVotePassed
then
5988 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_INPROGRESS
], [gVoteCommand
]), True);
5989 MH_SEND_VoteEvent(NET_VE_INPROGRESS
, gVoteCommand
);
5992 gVoteInProgress
:= True;
5993 gVotePassed
:= False;
5994 gVoteTimer
:= gTime
+ gVoteTimeout
* 1000;
5997 gVoteCommand
:= Command
;
5999 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
6000 Need
:= Floor((NetClientCount
+1)/2.0)+1
6002 Need
:= Floor(NetClientCount
/2.0)+1;
6003 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_STARTED
], [Initiator
, Command
, Need
]), True);
6004 MH_SEND_VoteEvent(NET_VE_STARTED
, Initiator
, Command
, Need
);
6007 procedure g_Game_CheckVote
;
6011 if gGameSettings
.GameType
<> GT_SERVER
then Exit
;
6012 if not gVoteInProgress
then Exit
;
6014 if (gTime
>= gVoteTimer
) then
6016 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
6017 Need
:= Floor((NetClientCount
+1)/2.0) + 1
6019 Need
:= Floor(NetClientCount
/2.0) + 1;
6020 if gVoteCount
>= Need
then
6022 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_PASSED
], [gVoteCommand
]), True);
6023 MH_SEND_VoteEvent(NET_VE_PASSED
, gVoteCommand
);
6024 gVotePassed
:= True;
6025 gVoteCmdTimer
:= gTime
+ 5000;
6029 g_Console_Add(_lc
[I_MESSAGE_VOTE_FAILED
], True);
6030 MH_SEND_VoteEvent(NET_VE_FAILED
);
6032 if NetClients
<> nil then
6033 for I
:= Low(NetClients
) to High(NetClients
) do
6034 if NetClients
[i
].Used
then
6035 NetClients
[i
].Voted
:= False;
6036 gVoteInProgress
:= False;
6042 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
6043 Need
:= Floor((NetClientCount
+1)/2.0) + 1
6045 Need
:= Floor(NetClientCount
/2.0) + 1;
6046 if gVoteCount
>= Need
then
6048 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_PASSED
], [gVoteCommand
]), True);
6049 MH_SEND_VoteEvent(NET_VE_PASSED
, gVoteCommand
);
6050 gVoteInProgress
:= False;
6051 gVotePassed
:= True;
6052 gVoteCmdTimer
:= gTime
+ 5000;
6055 if NetClients
<> nil then
6056 for I
:= Low(NetClients
) to High(NetClients
) do
6057 if NetClients
[i
].Used
then
6058 NetClients
[i
].Voted
:= False;
6063 procedure g_Game_LoadMapList(FileName
: string);
6071 if not FileExists(FileName
) then Exit
;
6073 AssignFile(ListFile
, FileName
);
6075 while not EOF(ListFile
) do
6077 ReadLn(ListFile
, s
);
6080 if s
= '' then Continue
;
6082 SetLength(MapList
, Length(MapList
)+1);
6083 MapList
[High(MapList
)] := s
;
6085 CloseFile(ListFile
);
6088 procedure g_Game_SetDebugMode();
6091 // ×èòû (äàæå â ñâîåé èãðå):
6095 procedure g_Game_SetLoadingText(Text: String; Max
: Integer; reWrite
: Boolean);
6099 if Length(LoadingStat
.Msgs
) = 0 then
6105 begin // Ïåðåõîäèì íà ñëåäóþùóþ ñòðîêó èëè ñêðîëëèðóåì:
6106 if NextMsg
= Length(Msgs
) then
6108 for i
:= 0 to High(Msgs
)-1 do
6109 Msgs
[i
] := Msgs
[i
+1];
6117 Msgs
[NextMsg
-1] := Text;
6123 g_ActiveWindow
:= nil;
6128 procedure g_Game_StepLoading();
6134 if (ShowCount
> LOADING_SHOW_STEP
) then
6142 procedure g_Game_ClearLoading();
6151 len
:= ((gScreenHeight
div 3)*2 - 50) div LOADING_INTERLINE
;
6152 if len
< 1 then len
:= 1;
6153 SetLength(Msgs
, len
);
6154 for len
:= Low(Msgs
) to High(Msgs
) do
6160 procedure Parse_Params(var pars
: TParamStrValues
);
6167 while i
<= ParamCount
do
6170 if (s
[1] = '-') and (Length(s
) > 1) then
6172 if (s
[2] = '-') and (Length(s
) > 2) then
6173 begin // Îäèíî÷íûé ïàðàìåòð
6174 SetLength(pars
, Length(pars
) + 1);
6175 with pars
[High(pars
)] do
6177 Name
:= LowerCase(s
);
6182 if (i
< ParamCount
) then
6183 begin // Ïàðàìåòð ñî çíà÷åíèåì
6185 SetLength(pars
, Length(pars
) + 1);
6186 with pars
[High(pars
)] do
6188 Name
:= LowerCase(s
);
6189 Value
:= LowerCase(ParamStr(i
));
6198 function Find_Param_Value(var pars
: TParamStrValues
; aName
: String): String;
6203 for i
:= 0 to High(pars
) do
6204 if pars
[i
].Name
= aName
then
6206 Result
:= pars
[i
].Value
;
6211 procedure g_Game_Process_Params();
6213 pars
: TParamStrValues
;
6216 LimT
, LimS
: Integer;
6227 s
:= Find_Param_Value(pars
, '--debug');
6229 g_Game_SetDebugMode();
6231 // Connect when game loads
6232 ip
:= Find_Param_Value(pars
, '-connect');
6236 s
:= Find_Param_Value(pars
, '-port');
6237 if (s
= '') or not TryStrToInt(s
, Port
) then
6240 s
:= Find_Param_Value(pars
, '-pw');
6242 g_Game_StartClient(ip
, Port
, s
);
6246 // Start map when game loads:
6247 map
:= LowerCase(Find_Param_Value(pars
, '-map'));
6248 if (map
<> '') and (Pos('.wad:\', map
) > 0) then
6251 s
:= Find_Param_Value(pars
, '-gm');
6252 GMode
:= g_Game_TextToMode(s
);
6253 if GMode
= GM_NONE
then GMode
:= GM_DM
;
6254 if GMode
= GM_SINGLE
then GMode
:= GM_COOP
;
6257 s
:= Find_Param_Value(pars
, '-limt');
6258 if (s
= '') or (not TryStrToInt(s
, LimT
)) then
6264 s
:= Find_Param_Value(pars
, '-lims');
6265 if (s
= '') or (not TryStrToInt(s
, LimS
)) then
6271 s
:= Find_Param_Value(pars
, '-lives');
6272 if (s
= '') or (not TryStrToInt(s
, Lives
)) then
6278 s
:= Find_Param_Value(pars
, '-opt');
6280 Opt
:= GAME_OPTION_ALLOWEXIT
or GAME_OPTION_BOTVSPLAYER
or GAME_OPTION_BOTVSMONSTER
6282 Opt
:= StrToIntDef(s
, 0);
6284 Opt
:= GAME_OPTION_ALLOWEXIT
or GAME_OPTION_BOTVSPLAYER
or GAME_OPTION_BOTVSMONSTER
;
6287 s
:= Find_Param_Value(pars
, '--close');
6291 // Delete test map after play:
6292 s
:= Find_Param_Value(pars
, '--testdelete');
6294 gMapToDelete
:= MapsDir
+ map
;
6296 // Delete temporary WAD after play:
6297 s
:= Find_Param_Value(pars
, '--tempdelete');
6300 gMapToDelete
:= MapsDir
+ map
;
6301 gTempDelete
:= True;
6304 // Number of players:
6305 s
:= Find_Param_Value(pars
, '-pl');
6309 n
:= StrToIntDef(s
, 1);
6312 s
:= Find_Param_Value(pars
, '-port');
6313 if (s
= '') or not TryStrToInt(s
, Port
) then
6314 g_Game_StartCustom(map
, GMode
, LimT
, LimS
, Lives
, Opt
, n
)
6316 g_Game_StartServer(map
, GMode
, LimT
, LimS
, Lives
, Opt
, n
, 0, Port
);
6319 // Execute script when game loads:
6320 s
:= Find_Param_Value(pars
, '-exec');
6323 if Pos(':\', s
) = 0 then
6324 s
:= GameDir
+ '/' + s
;
6329 if IOResult
<> 0 then
6331 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], ['Failed to read file: ' + s
]), MSG_WARNING
);
6332 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_READ
], [s
]));
6336 e_WriteLog('Executing script: ' + s
, MSG_NOTIFY
);
6337 g_Console_Add(Format(_lc
[I_CONSOLE_EXEC
], [s
]));
6342 if IOResult
<> 0 then
6344 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], ['Failed to read file: ' + s
]), MSG_WARNING
);
6345 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_READ
], [s
]));
6349 if Pos('#', s
) <> 1 then // script comment
6350 g_Console_Process(s
, True);