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
;
824 pc
:= g_Player_GetCount
;
825 e_TextureFontGetSize(gStdFont
, cw
, ch
);
827 w
:= gScreenWidth
-(gScreenWidth
div 5);
828 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
831 h
:= 40+ch
*5+(ch
+8)*pc
;
832 x
:= (gScreenWidth
div 2)-(w
div 2);
833 y
:= (gScreenHeight
div 2)-(h
div 2);
835 e_DrawFillQuad(x
, y
, x
+w
-1, y
+h
-1, 64, 64, 64, 32);
836 e_DrawQuad(x
, y
, x
+w
-1, y
+h
-1, 255, 127, 0);
838 g_ProcessResourceStr(gMapInfo
.Map
, @wad
, nil, @map
);
839 wad
:= ExtractFileName(wad
);
840 mapstr
:= wad
+ ':\' + map
+ ' - ' + gMapInfo
.Name
;
842 case gGameSettings
.GameMode
of
845 if gGameSettings
.MaxLives
= 0 then
848 s1
:= _lc
[I_GAME_LMS
];
849 s2
:= Format(_lc
[I_GAME_FRAG_LIMIT
], [gGameSettings
.GoalLimit
]);
850 s3
:= Format(_lc
[I_GAME_TIME_LIMIT
], [gGameSettings
.TimeLimit
div 3600, (gGameSettings
.TimeLimit
div 60) mod 60, gGameSettings
.TimeLimit
mod 60]);
855 if gGameSettings
.MaxLives
= 0 then
856 s1
:= _lc
[I_GAME_TDM
]
858 s1
:= _lc
[I_GAME_TLMS
];
859 s2
:= Format(_lc
[I_GAME_FRAG_LIMIT
], [gGameSettings
.GoalLimit
]);
860 s3
:= Format(_lc
[I_GAME_TIME_LIMIT
], [gGameSettings
.TimeLimit
div 3600, (gGameSettings
.TimeLimit
div 60) mod 60, gGameSettings
.TimeLimit
mod 60]);
865 s1
:= _lc
[I_GAME_CTF
];
866 s2
:= Format(_lc
[I_GAME_SCORE_LIMIT
], [gGameSettings
.GoalLimit
]);
867 s3
:= Format(_lc
[I_GAME_TIME_LIMIT
], [gGameSettings
.TimeLimit
div 3600, (gGameSettings
.TimeLimit
div 60) mod 60, gGameSettings
.TimeLimit
mod 60]);
872 if gGameSettings
.MaxLives
= 0 then
873 s1
:= _lc
[I_GAME_COOP
]
875 s1
:= _lc
[I_GAME_SURV
];
876 s2
:= _lc
[I_GAME_MONSTERS
] + ' ' + IntToStr(gCoopMonstersKilled
) + '/' + IntToStr(gTotalMonsters
);
877 s3
:= _lc
[I_GAME_SECRETS
] + ' ' + IntToStr(gCoopSecretsFound
) + '/' + IntToStr(gSecretsCount
);
888 e_TextureFontPrintEx(x
+(w
div 2)-(Length(s1
)*cw
div 2), _y
, s1
, gStdFont
, 255, 255, 255, 1);
890 e_TextureFontPrintEx(x
+(w
div 2)-(Length(mapstr
)*cw
div 2), _y
, mapstr
, gStdFont
, 200, 200, 200, 1);
892 e_TextureFontPrintEx(x
+16, _y
, s2
, gStdFont
, 200, 200, 200, 1);
894 e_TextureFontPrintEx(x
+w
-16-(Length(s3
))*cw
, _y
, s3
,
895 gStdFont
, 200, 200, 200, 1);
897 if NetMode
= NET_SERVER
then
898 e_TextureFontPrintEx(x
+8, y
+ 8, _lc
[I_NET_SERVER
], gStdFont
, 255, 255, 255, 1)
900 if NetMode
= NET_CLIENT
then
901 e_TextureFontPrintEx(x
+8, y
+ 8,
902 NetClientIP
+ ':' + IntToStr(NetClientPort
), gStdFont
, 255, 255, 255, 1);
906 stat
:= g_Player_GetStats();
909 w2
:= (w
-16) div 6 + 48; // øèðèíà 2 ñòîëáöà
910 w3
:= (w
-16) div 6; // øèðèíà 3 è 4 ñòîëáöîâ
912 w1
:= w
-16-w2
-w3
-w4
; // îñòàâøååñÿ ïðîñòðàíñòâî - äëÿ öâåòà è èìåíè èãðîêà
914 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
918 for a
:= TEAM_RED
to TEAM_BLUE
do
922 s1
:= _lc
[I_GAME_TEAM_RED
];
929 s1
:= _lc
[I_GAME_TEAM_BLUE
];
935 e_TextureFontPrintEx(x
+16, _y
, s1
, gStdFont
, r
, g
, b
, 1);
936 e_TextureFontPrintEx(x
+w1
+16, _y
, IntToStr(gTeamStat
[a
].Goals
),
937 gStdFont
, r
, g
, b
, 1);
939 _y
:= _y
+ch
+(ch
div 4);
940 e_DrawLine(1, x
+16, _y
, x
+w
-16, _y
, r
, g
, b
);
943 for aa
:= 0 to High(stat
) do
944 if stat
[aa
].Team
= a
then
960 e_TextureFontPrintEx(x
+16, _y
, Name
, gStdFont
, rr
, gg
, bb
, 1);
962 e_TextureFontPrintEx(x
+w1
+16, _y
, Format(_lc
[I_GAME_PING_MS
], [Ping
, Loss
]), gStdFont
, rr
, gg
, bb
, 1);
964 e_TextureFontPrintEx(x
+w1
+w2
+16, _y
, IntToStr(Frags
), gStdFont
, rr
, gg
, bb
, 1);
966 e_TextureFontPrintEx(x
+w1
+w2
+w3
+16, _y
, IntToStr(Deaths
), gStdFont
, rr
, gg
, bb
, 1);
973 else if gGameSettings
.GameMode
in [GM_DM
, GM_COOP
] then
976 e_TextureFontPrintEx(x
+16, _y
, _lc
[I_GAME_PLAYER_NAME
], gStdFont
, 255, 127, 0, 1);
977 e_TextureFontPrintEx(x
+16+w1
, _y
, _lc
[I_GAME_PING
], gStdFont
, 255, 127, 0, 1);
978 e_TextureFontPrintEx(x
+16+w1
+w2
, _y
, _lc
[I_GAME_FRAGS
], gStdFont
, 255, 127, 0, 1);
979 e_TextureFontPrintEx(x
+16+w1
+w2
+w3
, _y
, _lc
[I_GAME_DEATHS
], gStdFont
, 255, 127, 0, 1);
982 for aa
:= 0 to High(stat
) do
996 e_DrawFillQuad(x
+16, _y
+4, x
+32-1, _y
+16+4-1, Color
.R
, Color
.G
, Color
.B
, 0);
997 e_DrawQuad(x
+16, _y
+4, x
+32-1, _y
+16+4-1, 192, 192, 192);
999 e_TextureFontPrintEx(x
+16+16+8, _y
+4, Name
, gStdFont
, r
, g
, 0, 1);
1001 e_TextureFontPrintEx(x
+w1
+16, _y
+4, Format(_lc
[I_GAME_PING_MS
], [Ping
, Loss
]), gStdFont
, r
, g
, 0, 1);
1003 e_TextureFontPrintEx(x
+w1
+w2
+16, _y
+4, IntToStr(Frags
), gStdFont
, r
, g
, 0, 1);
1005 e_TextureFontPrintEx(x
+w1
+w2
+w3
+16, _y
+4, IntToStr(Deaths
), gStdFont
, r
, g
, 0, 1);
1011 procedure g_Game_Init();
1017 gTempDelete
:= False;
1019 g_Texture_CreateWADEx('MENU_BACKGROUND', GameWAD
+':TEXTURES\TITLE');
1020 g_Texture_CreateWADEx('INTER', GameWAD
+':TEXTURES\INTER');
1021 g_Texture_CreateWADEx('ENDGAME_EN', GameWAD
+':TEXTURES\ENDGAME_EN');
1022 g_Texture_CreateWADEx('ENDGAME_RU', GameWAD
+':TEXTURES\ENDGAME_RU');
1024 LoadStdFont('STDTXT', 'STDFONT', gStdFont
);
1025 LoadFont('MENUTXT', 'MENUFONT', gMenuFont
);
1026 LoadFont('SMALLTXT', 'SMALLFONT', gMenuSmallFont
);
1028 g_Game_ClearLoading();
1029 g_Game_SetLoadingText(Format('Doom 2D: Forever %s', [GAME_VERSION
]), 0, False);
1030 g_Game_SetLoadingText('', 0, False);
1032 g_Game_SetLoadingText(_lc
[I_LOAD_CONSOLE
], 0, False);
1035 g_Game_SetLoadingText(_lc
[I_LOAD_MODELS
], 0, False);
1036 g_PlayerModel_LoadData();
1038 if FindFirst(ModelsDir
+'*.wad', faAnyFile
, SR
) = 0 then
1040 if not g_PlayerModel_Load(ModelsDir
+SR
.Name
) then
1041 e_WriteLog(Format('Error loading model %s', [SR
.Name
]), MSG_WARNING
);
1042 until FindNext(SR
) <> 0;
1048 LastScreenShot
:= 0;
1050 {e_MouseInfo.Accel := 1.0;}
1052 g_Game_SetLoadingText(_lc
[I_LOAD_GAME_DATA
], 0, False);
1055 g_Game_SetLoadingText(_lc
[I_LOAD_MUSIC
], 0, False);
1056 g_Sound_CreateWADEx('MUSIC_INTERMUS', GameWAD
+':MUSIC\INTERMUS', True);
1057 g_Sound_CreateWADEx('MUSIC_MENU', GameWAD
+':MUSIC\MENU', True);
1058 g_Sound_CreateWADEx('MUSIC_ROUNDMUS', GameWAD
+':MUSIC\ROUNDMUS');
1059 g_Sound_CreateWADEx('MUSIC_STDENDMUS', GameWAD
+':MUSIC\ENDMUS', True);
1061 g_Game_SetLoadingText(_lc
[I_LOAD_MENUS
], 0, False);
1064 gMusic
:= TMusic
.Create();
1065 gMusic
.SetByName('MUSIC_MENU');
1068 gGameSettings
.WarmupTime
:= 30;
1070 gState
:= STATE_MENU
;
1072 SetLength(gEvents
, 6);
1073 gEvents
[0].Name
:= 'ongamestart';
1074 gEvents
[1].Name
:= 'ongameend';
1075 gEvents
[2].Name
:= 'onmapstart';
1076 gEvents
[3].Name
:= 'onmapend';
1077 gEvents
[4].Name
:= 'oninter';
1078 gEvents
[5].Name
:= 'onwadend';
1081 procedure g_Game_Free();
1083 if NetMode
= NET_CLIENT
then g_Net_Disconnect();
1084 if NetMode
= NET_SERVER
then g_Net_Host_Die();
1088 g_Player_RemoveAllCorpses();
1090 gGameSettings
.GameType
:= GT_NONE
;
1091 if gGameSettings
.GameMode
= GM_SINGLE
then
1092 gGameSettings
.GameMode
:= GM_DM
;
1093 gSwitchGameMode
:= gGameSettings
.GameMode
;
1096 gExitByTrigger
:= False;
1099 function IsActivePlayer(p
: TPlayer
): Boolean;
1104 Result
:= (not p
.FDummy
) and (not p
.FSpectator
);
1107 function GetActivePlayer_ByID(ID
: Integer): TPlayer
;
1114 if gPlayers
= nil then
1116 for a
:= Low(gPlayers
) to High(gPlayers
) do
1117 if IsActivePlayer(gPlayers
[a
]) then
1119 if gPlayers
[a
].UID
<> ID
then
1121 Result
:= gPlayers
[a
];
1126 function GetActivePlayerID_Next(Skip
: Integer = -1): Integer;
1132 if gPlayers
= nil then
1136 for a
:= Low(gPlayers
) to High(gPlayers
) do
1137 if IsActivePlayer(gPlayers
[a
]) then
1139 SetLength(ids
, Length(ids
) + 1);
1140 ids
[High(ids
)] := gPlayers
[a
].UID
;
1141 if gPlayers
[a
].UID
= Skip
then
1144 if Length(ids
) = 0 then
1149 Result
:= ids
[(idx
+ 1) mod Length(ids
)];
1152 function GetActivePlayerID_Prev(Skip
: Integer = -1): Integer;
1158 if gPlayers
= nil then
1162 for a
:= Low(gPlayers
) to High(gPlayers
) do
1163 if IsActivePlayer(gPlayers
[a
]) then
1165 SetLength(ids
, Length(ids
) + 1);
1166 ids
[High(ids
)] := gPlayers
[a
].UID
;
1167 if gPlayers
[a
].UID
= Skip
then
1170 if Length(ids
) = 0 then
1173 Result
:= ids
[Length(ids
) - 1]
1175 Result
:= ids
[(Length(ids
) - 1 + idx
) mod Length(ids
)];
1178 procedure g_Game_Update();
1180 Msg
: g_gui
.TMessage
;
1186 // Ïîðà âûêëþ÷àòü èãðó:
1187 if gExit
= EXIT_QUIT
then
1189 // Èãðà çàêîí÷èëàñü - îáðàáàòûâàåì:
1193 if gExit
= EXIT_QUIT
then
1197 // ×èòàåì êëàâèàòóðó è äæîéñòèê, åñëè îêíî àêòèâíî:
1200 // Îáíîâëÿåì êîíñîëü (äâèæåíèå è ñîîáùåíèÿ):
1203 if (NetMode
= NET_NONE
) and (g_Game_IsNet
) and (gGameOn
or (gState
in [STATE_FOLD
, STATE_INTERCUSTOM
])) then
1205 gExit
:= EXIT_SIMPLE
;
1211 STATE_INTERSINGLE
, // Ñòàòèñòêà ïîñëå ïðîõîæäåíèÿ óðîâíÿ â Îäèíî÷íîé èãðå
1212 STATE_INTERCUSTOM
, // Ñòàòèñòêà ïîñëå ïðîõîæäåíèÿ óðîâíÿ â Ñâîåé èãðå
1213 STATE_INTERTEXT
, // Òåêñò ìåæäó óðîâíÿìè
1214 STATE_INTERPIC
: // Êàðòèíêà ìåæäó óðîâíÿìè
1216 if g_Game_IsNet
and g_Game_IsServer
then
1218 gInterTime
:= gInterTime
+ GAME_TICK
;
1219 a
:= Min((gInterEndTime
- gInterTime
) div 1000 + 1, 255);
1220 if a
<> gServInterTime
then
1222 gServInterTime
:= a
;
1223 MH_SEND_TimeSync(gServInterTime
);
1227 if (not g_Game_IsClient
) and
1230 (e_KeyPressed(IK_RETURN
) or e_KeyPressed(IK_SPACE
))
1231 and (not gJustChatted
) and (not gConsoleShow
) and (not gChatShow
)
1232 and (g_ActiveWindow
= nil)
1234 or (g_Game_IsNet
and (gInterTime
> gInterEndTime
))
1237 begin // Íàæàëè <Enter>/<Ïðîáåë> èëè ïðîøëî äîñòàòî÷íî âðåìåíè:
1238 g_Game_StopAllSounds(True);
1240 if gMapOnce
then // Ýòî áûë òåñò
1241 gExit
:= EXIT_SIMPLE
1243 if gNextMap
<> '' then // Ïåðåõîäèì íà ñëåäóþùóþ êàðòó
1244 g_Game_ChangeMap(gNextMap
)
1245 else // Ñëåäóþùåé êàðòû íåò
1247 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
] then
1249 // Âûõîä â ãëàâíîå ìåíþ:
1251 g_GUI_ShowWindow('MainMenu');
1252 gMusic
.SetByName('MUSIC_MENU');
1254 gState
:= STATE_MENU
;
1257 // Ôèíàëüíàÿ êàðòèíêà:
1258 g_Game_ExecuteEvent('onwadend');
1260 if not gMusic
.SetByName('MUSIC_endmus') then
1261 gMusic
.SetByName('MUSIC_STDENDMUS');
1263 gState
:= STATE_ENDPIC
;
1265 g_Game_ExecuteEvent('ongameend');
1271 if gState
= STATE_INTERTEXT
then
1272 if InterText
.counter
> 0 then
1273 InterText
.counter
:= InterText
.counter
- 1;
1276 STATE_FOLD
: // Çàòóõàíèå ýêðàíà
1278 if EndingGameCounter
= 0 then
1280 // Çàêîí÷èëñÿ óðîâåíü â Ñâîåé èãðå:
1281 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
1283 if gLastMap
and (gGameSettings
.GameMode
= GM_COOP
) then
1285 g_Game_ExecuteEvent('onwadend');
1286 if not gMusic
.SetByName('MUSIC_endmus') then
1287 gMusic
.SetByName('MUSIC_STDENDMUS');
1290 gMusic
.SetByName('MUSIC_ROUNDMUS');
1293 gState
:= STATE_INTERCUSTOM
;
1295 else // Çàêîí÷èëàñü ïîñëåäíÿÿ êàðòà â Îäèíî÷íîé èãðå
1297 gMusic
.SetByName('MUSIC_INTERMUS');
1299 gState
:= STATE_INTERSINGLE
;
1301 g_Game_ExecuteEvent('oninter');
1304 DecMin(EndingGameCounter
, 6, 0);
1307 STATE_ENDPIC
: // Êàðòèíêà îêîí÷àíèÿ ìåãàÂàäà
1309 if gMapOnce
then // Ýòî áûë òåñò
1311 gExit
:= EXIT_SIMPLE
;
1317 g_Serverlist_Control(slCurrent
);
1320 if g_Game_IsNet
then
1321 if not gConsoleShow
then
1322 if not gChatShow
then
1324 if g_ActiveWindow
= nil then
1326 if e_KeyPressed(gGameControls
.GameControls
.Chat
) then
1327 g_Console_Chat_Switch(False)
1328 else if (e_KeyPressed(gGameControls
.GameControls
.TeamChat
)) and
1329 (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
1330 g_Console_Chat_Switch(True);
1333 if not gChatEnter
then
1334 if (not e_KeyPressed(gGameControls
.GameControls
.Chat
))
1335 and (not e_KeyPressed(gGameControls
.GameControls
.TeamChat
)) then
1338 // Ñòàòèñòèêà ïî Tab:
1340 IsDrawStat
:= (not gConsoleShow
) and (not gChatShow
) and
1341 (gGameSettings
.GameType
<> GT_SINGLE
) and
1342 e_KeyPressed(gGameControls
.GameControls
.Stat
);
1345 if gGameOn
and not gPause
and (gState
<> STATE_FOLD
) then
1347 // Âðåìÿ += 28 ìèëëèñåêóíä:
1348 gTime
:= gTime
+ GAME_TICK
;
1350 // Ñîîáùåíèå ïîñåðåäèíå ýêðàíà:
1351 if MessageTime
= 0 then
1353 if MessageTime
> 0 then
1354 MessageTime
:= MessageTime
- 1;
1356 if (g_Game_IsServer
) then
1358 // Áûë çàäàí ëèìèò âðåìåíè:
1359 if (gGameSettings
.TimeLimit
> 0) then
1360 if (gTime
- gGameStartTime
) div 1000 >= gGameSettings
.TimeLimit
then
1361 begin // Îí ïðîøåë => êîíåö óðîâíÿ
1366 // Íàäî ðåñïàâíèòü èãðîêîâ â LMS:
1367 if (gLMSRespawn
> LMS_RESPAWN_NONE
) and (gLMSRespawnTime
< gTime
) then
1368 g_Game_RestartRound(gLMSSoftSpawn
);
1370 // Ïðîâåðèì ðåçóëüòàò ãîëîñîâàíèÿ, åñëè âðåìÿ ïðîøëî
1371 if gVoteInProgress
and (gVoteTimer
< gTime
) then
1373 else if gVotePassed
and (gVoteCmdTimer
< gTime
) then
1375 g_Console_Process(gVoteCommand
);
1377 gVotePassed
:= False;
1380 // Çàìåðÿåì âðåìÿ çàõâàòà ôëàãîâ
1381 if gFlags
[FLAG_RED
].State
= FLAG_STATE_CAPTURED
then
1382 gFlags
[FLAG_RED
].CaptureTime
:= gFlags
[FLAG_RED
].CaptureTime
+ GAME_TICK
;
1383 if gFlags
[FLAG_BLUE
].State
= FLAG_STATE_CAPTURED
then
1384 gFlags
[FLAG_BLUE
].CaptureTime
:= gFlags
[FLAG_BLUE
].CaptureTime
+ GAME_TICK
;
1386 // Áûë çàäàí ëèìèò ïîáåä:
1387 if (gGameSettings
.GoalLimit
> 0) then
1391 if gGameSettings
.GameMode
= GM_DM
then
1392 begin // Â DM èùåì èãðîêà ñ max ôðàãàìè
1393 for i
:= 0 to High(gPlayers
) do
1394 if gPlayers
[i
] <> nil then
1395 if gPlayers
[i
].Frags
> b
then
1396 b
:= gPlayers
[i
].Frags
;
1399 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
1400 begin //  CTF/TDM âûáèðàåì êîìàíäó ñ íàèáîëüøèì ñ÷åòîì
1401 b
:= Max(gTeamStat
[TEAM_RED
].Goals
, gTeamStat
[TEAM_BLUE
].Goals
);
1404 // Ëèìèò ïîáåä íàáðàí => êîíåö óðîâíÿ:
1405 if b
>= gGameSettings
.GoalLimit
then
1412 // Îáðàáàòûâàåì êëàâèøè èãðîêîâ:
1413 if gPlayer1
<> nil then gPlayer1
.ReleaseKeys();
1414 if gPlayer2
<> nil then gPlayer2
.ReleaseKeys();
1415 if (not gConsoleShow
) and (not gChatShow
) and (g_ActiveWindow
= nil) then
1418 if gPlayer1
<> nil then
1419 with gGameControls
.P1Control
do
1421 if e_KeyPressed(KeyLeft
) and (not e_KeyPressed(KeyRight
)) then
1422 P1MoveButton
:= 1 // Íàæàòà òîëüêî "Âëåâî"
1424 if (not e_KeyPressed(KeyLeft
)) and e_KeyPressed(KeyRight
) then
1425 P1MoveButton
:= 2 // Íàæàòà òîëüêî "Âïðàâî"
1427 if (not e_KeyPressed(KeyLeft
)) and (not e_KeyPressed(KeyRight
)) then
1428 P1MoveButton
:= 0; // Íå íàæàòû íè "Âëåâî", íè "Âïðàâî"
1430 // Ñåé÷àñ èëè ðàíüøå áûëè íàæàòû "Âëåâî"/"Âïðàâî" => ïåðåäàåì èãðîêó:
1431 if P1MoveButton
= 1 then
1432 gPlayer1
.PressKey(KEY_LEFT
)
1434 if P1MoveButton
= 2 then
1435 gPlayer1
.PressKey(KEY_RIGHT
);
1437 // Ðàíüøå áûëà íàæàòà "Âïðàâî", à ñåé÷àñ "Âëåâî" => áåæèì âïðàâî, ñìîòðèì âëåâî:
1438 if (P1MoveButton
= 2) and e_KeyPressed(KeyLeft
) then
1439 gPlayer1
.SetDirection(D_LEFT
)
1441 // Ðàíüøå áûëà íàæàòà "Âëåâî", à ñåé÷àñ "Âïðàâî" => áåæèì âëåâî, ñìîòðèì âïðàâî:
1442 if (P1MoveButton
= 1) and e_KeyPressed(KeyRight
) then
1443 gPlayer1
.SetDirection(D_RIGHT
)
1445 // ×òî-òî áûëî íàæàòî è íå èçìåíèëîñü => êóäà áåæèì, òóäà è ñìîòðèì:
1446 if P1MoveButton
<> 0 then
1447 gPlayer1
.SetDirection(TDirection(P1MoveButton
-1));
1449 // Îñòàëüíûå êëàâèøè:
1450 if e_KeyPressed(KeyJump
) then gPlayer1
.PressKey(KEY_JUMP
);
1451 if e_KeyPressed(KeyUp
) then gPlayer1
.PressKey(KEY_UP
);
1452 if e_KeyPressed(KeyDown
) then gPlayer1
.PressKey(KEY_DOWN
);
1453 if e_KeyPressed(KeyFire
) then gPlayer1
.PressKey(KEY_FIRE
);
1454 if e_KeyPressed(KeyNextWeapon
) then gPlayer1
.PressKey(KEY_NEXTWEAPON
);
1455 if e_KeyPressed(KeyPrevWeapon
) then gPlayer1
.PressKey(KEY_PREVWEAPON
);
1456 if e_KeyPressed(KeyOpen
) then gPlayer1
.PressKey(KEY_OPEN
);
1459 if gPlayer2
<> nil then
1460 with gGameControls
.P2Control
do
1462 if e_KeyPressed(KeyLeft
) and (not e_KeyPressed(KeyRight
)) then
1463 P2MoveButton
:= 1 // Íàæàòà òîëüêî "Âëåâî"
1465 if (not e_KeyPressed(KeyLeft
)) and e_KeyPressed(KeyRight
) then
1466 P2MoveButton
:= 2 // Íàæàòà òîëüêî "Âïðàâî"
1468 if (not e_KeyPressed(KeyLeft
)) and (not e_KeyPressed(KeyRight
)) then
1469 P2MoveButton
:= 0; // Íå íàæàòû íè "Âëåâî", íè "Âïðàâî"
1471 // Ñåé÷àñ èëè ðàíüøå áûëè íàæàòû "Âëåâî"/"Âïðàâî" => ïåðåäàåì èãðîêó:
1472 if P2MoveButton
= 1 then
1473 gPlayer2
.PressKey(KEY_LEFT
, 1000)
1475 if P2MoveButton
= 2 then
1476 gPlayer2
.PressKey(KEY_RIGHT
, 1000);
1478 // Ðàíüøå áûëà íàæàòà "Âïðàâî", à ñåé÷àñ "Âëåâî" => áåæèì âïðàâî, ñìîòðèì âëåâî:
1479 if (P2MoveButton
= 2) and e_KeyPressed(KeyLeft
) then
1480 gPlayer2
.SetDirection(D_LEFT
)
1482 // Ðàíüøå áûëà íàæàòà "Âëåâî", à ñåé÷àñ "Âïðàâî" => áåæèì âëåâî, ñìîòðèì âïðàâî:
1483 if (P2MoveButton
= 1) and e_KeyPressed(KeyRight
) then
1484 gPlayer2
.SetDirection(D_RIGHT
)
1486 // ×òî-òî áûëî íàæàòî è íå èçìåíèëîñü => êóäà áåæèì, òóäà è ñìîòðèì:
1487 if P2MoveButton
<> 0 then
1488 gPlayer2
.SetDirection(TDirection(P2MoveButton
-1));
1490 // Îñòàëüíûå êëàâèøè:
1491 if e_KeyPressed(KeyJump
) then gPlayer2
.PressKey(KEY_JUMP
, 1000);
1492 if e_KeyPressed(KeyUp
) then gPlayer2
.PressKey(KEY_UP
, 1000);
1493 if e_KeyPressed(KeyDown
) then gPlayer2
.PressKey(KEY_DOWN
, 1000);
1494 if e_KeyPressed(KeyFire
) then gPlayer2
.PressKey(KEY_FIRE
);
1495 if e_KeyPressed(KeyNextWeapon
) then gPlayer2
.PressKey(KEY_NEXTWEAPON
);
1496 if e_KeyPressed(KeyPrevWeapon
) then gPlayer2
.PressKey(KEY_PREVWEAPON
);
1497 if e_KeyPressed(KeyOpen
) then gPlayer2
.PressKey(KEY_OPEN
);
1499 end // if not console
1501 if g_Game_IsNet
and (gPlayer1
<> nil) then
1502 gPlayer1
.PressKey(KEY_CHAT
, 10000);
1507 if (gPlayer1
= nil) and (gPlayer2
= nil) and
1508 (not gConsoleShow
) and (not gChatShow
) and (g_ActiveWindow
= nil) then
1510 if not gSpectKeyPress
then
1512 if e_KeyPressed(gGameControls
.P1Control
.KeyJump
) then
1514 // switch spect mode
1516 SPECT_NONE
: ; // not spectator
1518 SPECT_MAPVIEW
: Inc(gSpectMode
);
1519 SPECT_PLAYERS
: gSpectMode
:= SPECT_STATS
; // reset to 1
1521 gSpectKeyPress
:= True;
1523 if gSpectMode
= SPECT_MAPVIEW
then
1525 if e_KeyPressed(gGameControls
.P1Control
.KeyLeft
) then
1526 gSpectX
:= Max(gSpectX
- gSpectStep
, 0);
1527 if e_KeyPressed(gGameControls
.P1Control
.KeyRight
) then
1528 gSpectX
:= Min(gSpectX
+ gSpectStep
, gMapInfo
.Width
- gScreenWidth
);
1529 if e_KeyPressed(gGameControls
.P1Control
.KeyUp
) then
1530 gSpectY
:= Max(gSpectY
- gSpectStep
, 0);
1531 if e_KeyPressed(gGameControls
.P1Control
.KeyDown
) then
1532 gSpectY
:= Min(gSpectY
+ gSpectStep
, gMapInfo
.Height
- gScreenHeight
);
1533 if e_KeyPressed(gGameControls
.P1Control
.KeyPrevWeapon
) then
1536 if gSpectStep
> 4 then gSpectStep
:= gSpectStep
shr 1;
1537 gSpectKeyPress
:= True;
1539 if e_KeyPressed(gGameControls
.P1Control
.KeyNextWeapon
) then
1542 if gSpectStep
< 64 then gSpectStep
:= gSpectStep
shl 1;
1543 gSpectKeyPress
:= True;
1546 if gSpectMode
= SPECT_PLAYERS
then
1548 if e_KeyPressed(gGameControls
.P1Control
.KeyUp
) then
1551 gSpectViewTwo
:= True;
1552 gSpectKeyPress
:= True;
1554 if e_KeyPressed(gGameControls
.P1Control
.KeyDown
) then
1556 // remove second view
1557 gSpectViewTwo
:= False;
1558 gSpectKeyPress
:= True;
1560 if e_KeyPressed(gGameControls
.P1Control
.KeyLeft
) then
1562 // prev player (view 1)
1563 gSpectPID1
:= GetActivePlayerID_Prev(gSpectPID1
);
1564 gSpectKeyPress
:= True;
1566 if e_KeyPressed(gGameControls
.P1Control
.KeyRight
) then
1568 // next player (view 1)
1569 gSpectPID1
:= GetActivePlayerID_Next(gSpectPID1
);
1570 gSpectKeyPress
:= True;
1572 if e_KeyPressed(gGameControls
.P1Control
.KeyPrevWeapon
) then
1574 // prev player (view 2)
1575 gSpectPID2
:= GetActivePlayerID_Prev(gSpectPID2
);
1576 gSpectKeyPress
:= True;
1578 if e_KeyPressed(gGameControls
.P1Control
.KeyNextWeapon
) then
1580 // next player (view 2)
1581 gSpectPID2
:= GetActivePlayerID_Next(gSpectPID2
);
1582 gSpectKeyPress
:= True;
1587 if (not e_KeyPressed(gGameControls
.P1Control
.KeyJump
)) and
1588 (not e_KeyPressed(gGameControls
.P1Control
.KeyLeft
)) and
1589 (not e_KeyPressed(gGameControls
.P1Control
.KeyRight
)) and
1590 (not e_KeyPressed(gGameControls
.P1Control
.KeyUp
)) and
1591 (not e_KeyPressed(gGameControls
.P1Control
.KeyDown
)) and
1592 (not e_KeyPressed(gGameControls
.P1Control
.KeyPrevWeapon
)) and
1593 (not e_KeyPressed(gGameControls
.P1Control
.KeyNextWeapon
)) then
1594 gSpectKeyPress
:= False;
1597 // Îáíîâëÿåì âñå îñòàëüíîå:
1600 g_Triggers_Update();
1602 g_Monsters_Update();
1604 g_Player_UpdateAll();
1605 g_Player_UpdatePhysicalObjects();
1606 if gGameSettings
.GameType
= GT_SERVER
then
1607 if Length(gMonstersSpawned
) > 0 then
1609 for I
:= 0 to High(gMonstersSpawned
) do
1610 MH_SEND_MonsterSpawn(gMonstersSpawned
[I
]);
1611 SetLength(gMonstersSpawned
, 0);
1614 if (gSoundTriggerTime
> 8) then
1616 g_Game_UpdateTriggerSounds();
1617 gSoundTriggerTime
:= 0;
1620 Inc(gSoundTriggerTime
);
1622 if (NetMode
= NET_SERVER
) then
1624 Inc(NetTimeToUpdate
);
1625 Inc(NetTimeToReliable
);
1626 if NetTimeToReliable
>= NetRelupdRate
then
1628 for I
:= 0 to High(gPlayers
) do
1629 if gPlayers
[I
] <> nil then
1630 MH_SEND_PlayerPos(True, gPlayers
[I
].UID
);
1632 if gMonsters
<> nil then
1633 for I
:= 0 to High(gMonsters
) do
1634 if gMonsters
[I
] <> nil then
1636 if (gMonsters
[I
].MonsterType
= MONSTER_BARREL
) then
1638 if (gMonsters
[I
].GameVelX
<> 0) or (gMonsters
[I
].GameVelY
<> 0) then
1639 MH_SEND_MonsterPos(gMonsters
[I
].UID
);
1642 if (gMonsters
[I
].MonsterState
<> MONSTATE_SLEEP
) then
1643 if (gMonsters
[I
].MonsterState
<> MONSTATE_DEAD
) or
1644 (gMonsters
[I
].GameVelX
<> 0) or
1645 (gMonsters
[I
].GameVelY
<> 0) then
1646 MH_SEND_MonsterPos(gMonsters
[I
].UID
);
1649 NetTimeToReliable
:= 0;
1650 NetTimeToUpdate
:= NetUpdateRate
;
1652 else if NetTimeToUpdate
>= NetUpdateRate
then
1654 if gPlayers
<> nil then
1655 for I
:= 0 to High(gPlayers
) do
1656 if gPlayers
[I
] <> nil then
1657 MH_SEND_PlayerPos(False, gPlayers
[I
].UID
);
1659 if gMonsters
<> nil then
1660 for I
:= 0 to High(gMonsters
) do
1661 if gMonsters
[I
] <> nil then
1663 if (gMonsters
[I
].MonsterType
= MONSTER_BARREL
) then
1665 if (gMonsters
[I
].GameVelX
<> 0) or (gMonsters
[I
].GameVelY
<> 0) then
1666 MH_SEND_MonsterPos(gMonsters
[I
].UID
);
1669 if (gMonsters
[I
].MonsterState
<> MONSTATE_SLEEP
) then
1670 if (gMonsters
[I
].MonsterState
<> MONSTATE_DEAD
) or
1671 (gMonsters
[I
].GameVelX
<> 0) or
1672 (gMonsters
[I
].GameVelY
<> 0) then
1673 MH_SEND_MonsterPos(gMonsters
[I
].UID
);
1676 NetTimeToUpdate
:= 0;
1679 if NetUseMaster
then
1680 if gTime
>= NetTimeToMaster
then
1682 if (NetMHost
= nil) or (NetMPeer
= nil) then
1683 if not g_Net_Slist_Connect
then
1684 g_Console_Add(_lc
[I_NET_MSG_ERROR
] + _lc
[I_NET_SLIST_ERROR
]);
1687 NetTimeToMaster
:= gTime
+ NetMasterRate
;
1691 if NetMode
= NET_CLIENT
then
1692 MC_SEND_PlayerPos();
1693 end; // if gameOn ...
1695 // Àêòèâíî îêíî èíòåðôåéñà - ïåðåäàåì êëàâèøè åìó:
1696 if g_ActiveWindow
<> nil then
1698 w
:= e_GetFirstKeyPressed();
1700 if (w
<> IK_INVALID
) then
1702 Msg
.Msg
:= MESSAGE_DIKEY
;
1704 g_ActiveWindow
.OnMessage(Msg
);
1707 // Åñëè îíî îò ýòîãî íå çàêðûëîñü, òî îáíîâëÿåì:
1708 if g_ActiveWindow
<> nil then
1709 g_ActiveWindow
.Update();
1711 // Íóæíî ñìåíèòü ðàçðåøåíèå:
1712 if gResolutionChange
then
1714 e_WriteLog('Changing resolution', MSG_NOTIFY
);
1715 g_Game_ChangeResolution(gRC_Width
, gRC_Height
, gRC_FullScreen
, gRC_Maximized
);
1716 gResolutionChange
:= False;
1719 // Íóæíî ñìåíèòü ÿçûê:
1720 if gLanguageChange
then
1722 //e_WriteLog('Read language file', MSG_NOTIFY);
1723 //g_Language_Load(DataDir + gLanguage + '.txt');
1724 g_Language_Set(gLanguage
);
1726 gLanguageChange
:= False;
1730 // Äåëàåì ñêðèíøîò (íå ÷àùå 200 ìèëëèñåêóíä):
1731 if e_KeyPressed(gGameControls
.GameControls
.TakeScreenshot
) then
1732 if (GetTimer()-LastScreenShot
) > 200000 then
1735 LastScreenShot
:= GetTimer();
1738 // Ãîðÿ÷àÿ êëàâèøà äëÿ âûçîâà ìåíþ âûõîäà èç èãðû (F10):
1739 if e_KeyPressed(IK_F10
) and
1741 (not gConsoleShow
) and
1742 (g_ActiveWindow
= nil) then
1747 Time
:= GetTimer() div 1000;
1749 // Îáðàáîòêà îòëîæåííûõ ñîáûòèé:
1750 if gDelayedEvents
<> nil then
1751 for a
:= 0 to High(gDelayedEvents
) do
1752 if gDelayedEvents
[a
].Pending
and
1754 ((gDelayedEvents
[a
].DEType
= DE_GLOBEVENT
) and (gDelayedEvents
[a
].Time
<= Time
)) or
1755 ((gDelayedEvents
[a
].DEType
> DE_GLOBEVENT
) and (gDelayedEvents
[a
].Time
<= gTime
))
1758 case gDelayedEvents
[a
].DEType
of
1760 g_Game_ExecuteEvent(gDelayedEvents
[a
].DEStr
);
1763 g_Game_Announce_GoodShot(gDelayedEvents
[a
].DENum
);
1767 g_Game_Announce_KillCombo(gDelayedEvents
[a
].DENum
);
1768 if g_Game_IsNet
and g_Game_IsServer
then
1769 MH_SEND_GameEvent(NET_EV_KILLCOMBO
, gDelayedEvents
[a
].DENum
);
1772 gDelayedEvents
[a
].Pending
:= False;
1775 // Êàæäóþ ñåêóíäó îáíîâëÿåì ñ÷åò÷èê îáíîâëåíèé:
1776 UPSCounter
:= UPSCounter
+ 1;
1777 if Time
- UPSTime
>= 1000 then
1785 procedure g_Game_LoadData();
1787 if DataLoaded
then Exit
;
1789 e_WriteLog('Loading game data...', MSG_NOTIFY
);
1791 g_Texture_CreateWADEx('NOTEXTURE', GameWAD
+':TEXTURES\NOTEXTURE');
1792 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUD', GameWAD
+':TEXTURES\HUD');
1793 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDAIR', GameWAD
+':TEXTURES\AIRBAR');
1794 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDJET', GameWAD
+':TEXTURES\JETBAR');
1795 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDBG', GameWAD
+':TEXTURES\HUDBG');
1796 g_Texture_CreateWADEx('TEXTURE_PLAYER_ARMORHUD', GameWAD
+':TEXTURES\ARMORHUD');
1797 g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG', GameWAD
+':TEXTURES\FLAGHUD_RB');
1798 g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG_S', GameWAD
+':TEXTURES\FLAGHUD_RS');
1799 g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG_D', GameWAD
+':TEXTURES\FLAGHUD_RD');
1800 g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG', GameWAD
+':TEXTURES\FLAGHUD_BB');
1801 g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG_S', GameWAD
+':TEXTURES\FLAGHUD_BS');
1802 g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG_D', GameWAD
+':TEXTURES\FLAGHUD_BD');
1803 g_Texture_CreateWADEx('TEXTURE_PLAYER_TALKBUBBLE', GameWAD
+':TEXTURES\TALKBUBBLE');
1804 g_Texture_CreateWADEx('TEXTURE_PLAYER_INVULPENTA', GameWAD
+':TEXTURES\PENTA');
1805 g_Frames_CreateWAD(nil, 'FRAMES_TELEPORT', GameWAD
+':TEXTURES\TELEPORT', 64, 64, 10, False);
1806 g_Sound_CreateWADEx('SOUND_GAME_TELEPORT', GameWAD
+':SOUNDS\TELEPORT');
1807 g_Sound_CreateWADEx('SOUND_GAME_NOTELEPORT', GameWAD
+':SOUNDS\NOTELEPORT');
1808 g_Sound_CreateWADEx('SOUND_GAME_DOOROPEN', GameWAD
+':SOUNDS\DOOROPEN');
1809 g_Sound_CreateWADEx('SOUND_GAME_DOORCLOSE', GameWAD
+':SOUNDS\DOORCLOSE');
1810 g_Sound_CreateWADEx('SOUND_GAME_BULK1', GameWAD
+':SOUNDS\BULK1');
1811 g_Sound_CreateWADEx('SOUND_GAME_BULK2', GameWAD
+':SOUNDS\BULK2');
1812 g_Sound_CreateWADEx('SOUND_GAME_BUBBLE1', GameWAD
+':SOUNDS\BUBBLE1');
1813 g_Sound_CreateWADEx('SOUND_GAME_BUBBLE2', GameWAD
+':SOUNDS\BUBBLE2');
1814 g_Sound_CreateWADEx('SOUND_GAME_SWITCH1', GameWAD
+':SOUNDS\SWITCH1');
1815 g_Sound_CreateWADEx('SOUND_GAME_SWITCH0', GameWAD
+':SOUNDS\SWITCH0');
1816 g_Sound_CreateWADEx('SOUND_GAME_RADIO', GameWAD
+':SOUNDS\RADIO');
1817 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD1', GameWAD
+':SOUNDS\GOOD1');
1818 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD2', GameWAD
+':SOUNDS\GOOD2');
1819 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD3', GameWAD
+':SOUNDS\GOOD3');
1820 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD4', GameWAD
+':SOUNDS\GOOD4');
1821 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL2X', GameWAD
+':SOUNDS\KILL2X');
1822 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL3X', GameWAD
+':SOUNDS\KILL3X');
1823 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL4X', GameWAD
+':SOUNDS\KILL4X');
1824 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILLMX', GameWAD
+':SOUNDS\KILLMX');
1826 goodsnd
[0] := TPlayableSound
.Create();
1827 goodsnd
[1] := TPlayableSound
.Create();
1828 goodsnd
[2] := TPlayableSound
.Create();
1829 goodsnd
[3] := TPlayableSound
.Create();
1831 goodsnd
[0].SetByName('SOUND_ANNOUNCER_GOOD1');
1832 goodsnd
[1].SetByName('SOUND_ANNOUNCER_GOOD2');
1833 goodsnd
[2].SetByName('SOUND_ANNOUNCER_GOOD3');
1834 goodsnd
[3].SetByName('SOUND_ANNOUNCER_GOOD4');
1836 killsnd
[0] := TPlayableSound
.Create();
1837 killsnd
[1] := TPlayableSound
.Create();
1838 killsnd
[2] := TPlayableSound
.Create();
1839 killsnd
[3] := TPlayableSound
.Create();
1841 killsnd
[0].SetByName('SOUND_ANNOUNCER_KILL2X');
1842 killsnd
[1].SetByName('SOUND_ANNOUNCER_KILL3X');
1843 killsnd
[2].SetByName('SOUND_ANNOUNCER_KILL4X');
1844 killsnd
[3].SetByName('SOUND_ANNOUNCER_KILLMX');
1846 g_Game_SetLoadingText(_lc
[I_LOAD_ITEMS_DATA
], 0, False);
1849 g_Game_SetLoadingText(_lc
[I_LOAD_WEAPONS_DATA
], 0, False);
1850 g_Weapon_LoadData();
1852 g_Monsters_LoadData();
1857 procedure g_Game_FreeData();
1859 if not DataLoaded
then Exit
;
1862 g_Weapon_FreeData();
1863 g_Monsters_FreeData();
1865 e_WriteLog('Releasing game data...', MSG_NOTIFY
);
1867 g_Texture_Delete('NOTEXTURE');
1868 g_Texture_Delete('TEXTURE_PLAYER_HUD');
1869 g_Texture_Delete('TEXTURE_PLAYER_HUDBG');
1870 g_Texture_Delete('TEXTURE_PLAYER_ARMORHUD');
1871 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG');
1872 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG_S');
1873 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG_D');
1874 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG');
1875 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG_S');
1876 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG_D');
1877 g_Texture_Delete('TEXTURE_PLAYER_TALKBUBBLE');
1878 g_Texture_Delete('TEXTURE_PLAYER_INVULPENTA');
1879 g_Frames_DeleteByName('FRAMES_TELEPORT');
1880 g_Sound_Delete('SOUND_GAME_TELEPORT');
1881 g_Sound_Delete('SOUND_GAME_NOTELEPORT');
1882 g_Sound_Delete('SOUND_GAME_DOOROPEN');
1883 g_Sound_Delete('SOUND_GAME_DOORCLOSE');
1884 g_Sound_Delete('SOUND_GAME_BULK1');
1885 g_Sound_Delete('SOUND_GAME_BULK2');
1886 g_Sound_Delete('SOUND_GAME_BUBBLE1');
1887 g_Sound_Delete('SOUND_GAME_BUBBLE2');
1888 g_Sound_Delete('SOUND_GAME_SWITCH1');
1889 g_Sound_Delete('SOUND_GAME_SWITCH0');
1896 g_Sound_Delete('SOUND_ANNOUNCER_GOOD1');
1897 g_Sound_Delete('SOUND_ANNOUNCER_GOOD2');
1898 g_Sound_Delete('SOUND_ANNOUNCER_GOOD3');
1899 g_Sound_Delete('SOUND_ANNOUNCER_GOOD4');
1906 g_Sound_Delete('SOUND_ANNOUNCER_KILL2X');
1907 g_Sound_Delete('SOUND_ANNOUNCER_KILL3X');
1908 g_Sound_Delete('SOUND_ANNOUNCER_KILL4X');
1909 g_Sound_Delete('SOUND_ANNOUNCER_KILLMX');
1911 DataLoaded
:= False;
1914 procedure DrawCustomStat();
1920 ww2
, hh2
, r
, g
, b
, rr
, gg
, bb
: Byte;
1921 s1
, s2
, topstr
: String;
1923 e_TextureFontGetSize(gStdFont
, ww2
, hh2
);
1926 if e_KeyPressed(IK_TAB
) then
1928 if not gStatsPressed
then
1930 gStatsOff
:= not gStatsOff
;
1931 gStatsPressed
:= True;
1935 gStatsPressed
:= False;
1939 s1
:= _lc
[I_MENU_INTER_NOTICE_TAB
];
1940 w
:= (Length(s1
) * ww2
) div 2;
1941 x
:= gScreenWidth
div 2 - w
;
1943 e_TextureFontPrint(x
, y
, s1
, gStdFont
);
1947 if (gGameSettings
.GameMode
= GM_COOP
) then
1949 if gMissionFailed
then
1950 topstr
:= _lc
[I_MENU_INTER_MISSION_FAIL
]
1952 topstr
:= _lc
[I_MENU_INTER_LEVEL_COMPLETE
];
1955 topstr
:= _lc
[I_MENU_INTER_ROUND_OVER
];
1957 e_CharFont_GetSize(gMenuFont
, topstr
, ww1
, hh1
);
1958 e_CharFont_Print(gMenuFont
, (gScreenWidth
div 2)-(ww1
div 2), 16, topstr
);
1960 if g_Game_IsNet
then
1962 topstr
:= Format(_lc
[I_MENU_INTER_NOTICE_TIME
], [gServInterTime
]);
1963 if not gChatShow
then
1964 e_TextureFontPrintEx((gScreenWidth
div 2)-(Length(topstr
)*ww2
div 2),
1965 gScreenHeight
-(hh2
+4)*2, topstr
, gStdFont
, 255, 255, 255, 1);
1968 if g_Game_IsClient
then
1969 topstr
:= _lc
[I_MENU_INTER_NOTICE_MAP
]
1971 topstr
:= _lc
[I_MENU_INTER_NOTICE_SPACE
];
1972 if not gChatShow
then
1973 e_TextureFontPrintEx((gScreenWidth
div 2)-(Length(topstr
)*ww2
div 2),
1974 gScreenHeight
-(hh2
+4), topstr
, gStdFont
, 255, 255, 255, 1);
1979 w
:= gScreenWidth
-x
*2;
1985 e_DrawFillQuad(x
, y
, gScreenWidth
-x
-1, gScreenHeight
-y
-1, 64, 64, 64, 32);
1986 e_DrawQuad(x
, y
, gScreenWidth
-x
-1, gScreenHeight
-y
-1, 255, 127, 0);
1988 m
:= Max(Length(_lc
[I_MENU_MAP
])+1, Length(_lc
[I_GAME_GAME_TIME
])+1)*ww2
;
1990 case CustomStat
.GameMode
of
1993 if gGameSettings
.MaxLives
= 0 then
1994 s1
:= _lc
[I_GAME_DM
]
1996 s1
:= _lc
[I_GAME_LMS
];
2000 if gGameSettings
.MaxLives
= 0 then
2001 s1
:= _lc
[I_GAME_TDM
]
2003 s1
:= _lc
[I_GAME_TLMS
];
2005 GM_CTF
: s1
:= _lc
[I_GAME_CTF
];
2008 if gGameSettings
.MaxLives
= 0 then
2009 s1
:= _lc
[I_GAME_COOP
]
2011 s1
:= _lc
[I_GAME_SURV
];
2017 e_TextureFontPrintEx(x
+(w
div 2)-(Length(s1
)*ww2
div 2), _y
, s1
, gStdFont
, 255, 255, 255, 1);
2021 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_MENU_MAP
], gStdFont
, 255, 127, 0, 1);
2022 e_TextureFontPrint(x
+8+m
, _y
, Format('%s - %s', [CustomStat
.Map
, CustomStat
.MapName
]), gStdFont
);
2025 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_GAME_TIME
], gStdFont
, 255, 127, 0, 1);
2026 e_TextureFontPrint(x
+8+m
, _y
, Format('%d:%.2d:%.2d', [CustomStat
.GameTime
div 1000 div 3600,
2027 (CustomStat
.GameTime
div 1000 div 60) mod 60,
2028 CustomStat
.GameTime
div 1000 mod 60]), gStdFont
);
2030 pc
:= Length(CustomStat
.PlayerStat
);
2031 if pc
= 0 then Exit
;
2033 if CustomStat
.GameMode
= GM_COOP
then
2035 m
:= Max(Length(_lc
[I_GAME_MONSTERS
])+1, Length(_lc
[I_GAME_SECRETS
])+1)*ww2
;
2037 s2
:= _lc
[I_GAME_MONSTERS
];
2038 e_TextureFontPrintEx(x
+8, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2039 e_TextureFontPrintEx(x
+8+m
, _y
, IntToStr(gCoopMonstersKilled
) + '/' + IntToStr(gTotalMonsters
), gStdFont
, 255, 255, 255, 1);
2041 s2
:= _lc
[I_GAME_SECRETS
];
2042 e_TextureFontPrintEx(x
+8, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2043 e_TextureFontPrintEx(x
+8+m
, _y
, IntToStr(gCoopSecretsFound
) + '/' + IntToStr(gSecretsCount
), gStdFont
, 255, 255, 255, 1);
2046 m
:= Max(Length(_lc
[I_GAME_MONSTERS_TOTAL
])+1, Length(_lc
[I_GAME_SECRETS_TOTAL
])+1)*ww2
;
2048 s2
:= _lc
[I_GAME_MONSTERS_TOTAL
];
2049 e_TextureFontPrintEx(x
+250, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2050 e_TextureFontPrintEx(x
+250+m
, _y
, IntToStr(gCoopTotalMonstersKilled
) + '/' + IntToStr(gCoopTotalMonsters
), gStdFont
, 255, 255, 255, 1);
2052 s2
:= _lc
[I_GAME_SECRETS_TOTAL
];
2053 e_TextureFontPrintEx(x
+250, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2054 e_TextureFontPrintEx(x
+250+m
, _y
, IntToStr(gCoopTotalSecretsFound
) + '/' + IntToStr(gCoopTotalSecrets
), gStdFont
, 255, 255, 255, 1);
2058 if CustomStat
.GameMode
in [GM_TDM
, GM_CTF
] then
2063 if TeamStat
[TEAM_RED
].Goals
> TeamStat
[TEAM_BLUE
].Goals
then s1
:= _lc
[I_GAME_WIN_RED
]
2064 else if TeamStat
[TEAM_BLUE
].Goals
> TeamStat
[TEAM_RED
].Goals
then s1
:= _lc
[I_GAME_WIN_BLUE
]
2065 else s1
:= _lc
[I_GAME_WIN_DRAW
];
2067 e_TextureFontPrintEx(x
+8+(w
div 2)-(Length(s1
)*ww2
div 2), _y
, s1
, gStdFont
, 255, 255, 255, 1);
2070 for t
:= TEAM_RED
to TEAM_BLUE
do
2072 if t
= TEAM_RED
then
2074 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_TEAM_RED
],
2075 gStdFont
, 255, 0, 0, 1);
2076 e_TextureFontPrintEx(x
+w1
+8, _y
, IntToStr(CustomStat
.TeamStat
[TEAM_RED
].Goals
),
2077 gStdFont
, 255, 0, 0, 1);
2084 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_TEAM_BLUE
],
2085 gStdFont
, 0, 0, 255, 1);
2086 e_TextureFontPrintEx(x
+w1
+8, _y
, IntToStr(CustomStat
.TeamStat
[TEAM_BLUE
].Goals
),
2087 gStdFont
, 0, 0, 255, 1);
2093 e_DrawLine(1, x
+8, _y
+20, x
-8+w
, _y
+20, r
, g
, b
);
2096 for p
:= 0 to High(CustomStat
.PlayerStat
) do
2097 if CustomStat
.PlayerStat
[p
].Team
= t
then
2098 with CustomStat
.PlayerStat
[p
] do
2112 e_TextureFontPrintEx(x
+8, _y
, Name
, gStdFont
, rr
, gg
, bb
, 1);
2113 e_TextureFontPrintEx(x
+w1
+8, _y
, IntToStr(Frags
), gStdFont
, rr
, gg
, bb
, 1);
2114 e_TextureFontPrintEx(x
+w1
+w2
+8, _y
, IntToStr(Deaths
), gStdFont
, rr
, gg
, bb
, 1);
2121 else if CustomStat
.GameMode
in [GM_DM
, GM_COOP
] then
2124 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_PLAYER_NAME
], gStdFont
, 255, 127, 0, 1);
2125 e_TextureFontPrintEx(x
+8+w1
, _y
, _lc
[I_GAME_FRAGS
], gStdFont
, 255, 127, 0, 1);
2126 e_TextureFontPrintEx(x
+8+w1
+w2
, _y
, _lc
[I_GAME_DEATHS
], gStdFont
, 255, 127, 0, 1);
2129 for p
:= 0 to High(CustomStat
.PlayerStat
) do
2130 with CustomStat
.PlayerStat
[p
] do
2132 e_DrawFillQuad(x
+8, _y
+4, x
+24-1, _y
+16+4-1, Color
.R
, Color
.G
, Color
.B
, 0);
2139 e_TextureFontPrintEx(x
+8+16+8, _y
+4, Name
, gStdFont
, r
, r
, r
, 1, True);
2140 e_TextureFontPrintEx(x
+w1
+8+16+8, _y
+4, IntToStr(Frags
), gStdFont
, r
, r
, r
, 1, True);
2141 e_TextureFontPrintEx(x
+w1
+w2
+8+16+8, _y
+4, IntToStr(Deaths
), gStdFont
, r
, r
, r
, 1, True);
2147 procedure DrawSingleStat();
2149 tm
, key_x
, val_x
, y
: Integer;
2153 procedure player_stat(n
: Integer);
2159 s1
:= Format(' %d ', [SingleStat
.PlayerStat
[n
].Kills
]);
2160 s2
:= Format(' %d', [gTotalMonsters
]);
2162 e_CharFont_Print(gMenuFont
, key_x
, y
, _lc
[I_MENU_INTER_KILLS
]);
2163 e_CharFont_PrintEx(gMenuFont
, val_x
, y
, s1
, _RGB(255, 0, 0));
2164 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2165 e_CharFont_Print(gMenuFont
, val_x
+w1
, y
, '/');
2167 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2168 e_CharFont_PrintEx(gMenuFont
, val_x
+w1
, y
, s2
, _RGB(255, 0, 0));
2170 // "Kills-per-minute: ##.#":
2171 s1
:= _lc
[I_MENU_INTER_KPM
];
2173 kpm
:= (SingleStat
.PlayerStat
[n
].Kills
/ tm
) * 60
2175 kpm
:= SingleStat
.PlayerStat
[n
].Kills
;
2176 s2
:= Format(' %.1f', [kpm
]);
2178 e_CharFont_Print(gMenuFont
, key_x
, y
+32, s1
);
2179 e_CharFont_PrintEx(gMenuFont
, val_x
, y
+32, s2
, _RGB(255, 0, 0));
2181 // "Secrets found: # / #":
2182 s1
:= Format(' %d ', [SingleStat
.PlayerStat
[n
].Secrets
]);
2183 s2
:= Format(' %d', [SingleStat
.TotalSecrets
]);
2185 e_CharFont_Print(gMenuFont
, key_x
, y
+64, _lc
[I_MENU_INTER_SECRETS
]);
2186 e_CharFont_PrintEx(gMenuFont
, val_x
, y
+64, s1
, _RGB(255, 0, 0));
2187 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2188 e_CharFont_Print(gMenuFont
, val_x
+w1
, y
+64, '/');
2190 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2191 e_CharFont_PrintEx(gMenuFont
, val_x
+w1
, y
+64, s2
, _RGB(255, 0, 0));
2195 // "Level Complete":
2196 e_CharFont_GetSize(gMenuFont
, _lc
[I_MENU_INTER_LEVEL_COMPLETE
], w1
, h
);
2197 e_CharFont_Print(gMenuFont
, (gScreenWidth
-w1
) div 2, 32, _lc
[I_MENU_INTER_LEVEL_COMPLETE
]);
2199 // Îïðåäåëÿåì êîîðäèíàòû âûðàâíèâàíèÿ ïî ñàìîé äëèííîé ñòðîêå:
2200 s1
:= _lc
[I_MENU_INTER_KPM
];
2201 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2204 e_CharFont_GetSize(gMenuFont
, s1
, w2
, h
);
2206 key_x
:= (gScreenWidth
-w1
-w2
) div 2;
2207 val_x
:= key_x
+ w1
;
2210 tm
:= SingleStat
.GameTime
div 1000;
2211 s1
:= _lc
[I_MENU_INTER_TIME
];
2212 s2
:= Format(' %d:%.2d:%.2d', [tm
div (60*60), (tm
mod (60*60)) div 60, tm
mod 60]);
2214 e_CharFont_Print(gMenuFont
, key_x
, 80, s1
);
2215 e_CharFont_PrintEx(gMenuFont
, val_x
, 80, s2
, _RGB(255, 0, 0));
2217 if SingleStat
.TwoPlayers
then
2220 s1
:= _lc
[I_MENU_PLAYER_1
];
2221 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2222 e_CharFont_Print(gMenuFont
, (gScreenWidth
-w1
) div 2, 128, s1
);
2224 // Ñòàòèñòèêà ïåðâîãî èãðîêà:
2229 s1
:= _lc
[I_MENU_PLAYER_2
];
2230 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2231 e_CharFont_Print(gMenuFont
, (gScreenWidth
-w1
) div 2, 288, s1
);
2233 // Ñòàòèñòèêà âòîðîãî èãðîêà:
2239 // Ñòàòèñòèêà ïåðâîãî èãðîêà:
2245 procedure DrawLoadingStat();
2251 if Length(LoadingStat
.Msgs
) = 0 then
2254 e_CharFont_GetSize(gMenuFont
, _lc
[I_MENU_LOADING
], ww
, hh
);
2255 yy
:= (gScreenHeight
div 3);
2256 e_CharFont_Print(gMenuFont
, (gScreenWidth
div 2)-(ww
div 2), yy
-2*hh
, _lc
[I_MENU_LOADING
]);
2257 xx
:= (gScreenWidth
div 3);
2260 for i
:= 0 to NextMsg
-1 do
2262 if (i
= (NextMsg
-1)) and (MaxValue
> 0) then
2263 s
:= Format('%s: %d/%d', [Msgs
[i
], CurValue
, MaxValue
])
2267 e_CharFont_PrintEx(gMenuSmallFont
, xx
, yy
, s
, _RGB(255, 0, 0));
2268 yy
:= yy
+ LOADING_INTERLINE
;
2272 procedure DrawMinimap(p
: TPlayer
; RenderRect
: TRect
);
2274 a
, aX
, aY
, aX2
, aY2
, Scale
, ScaleSz
: Integer;
2276 if (gMapInfo
.Width
> RenderRect
.Right
- RenderRect
.Left
) or
2277 (gMapInfo
.Height
> RenderRect
.Bottom
- RenderRect
.Top
) then
2280 // Ñêîëüêî ïèêñåëîâ êàðòû â 1 ïèêñåëå ìèíè-êàðòû:
2281 ScaleSz
:= 16 div Scale
;
2282 // Ðàçìåðû ìèíè-êàðòû:
2283 aX
:= max(gMapInfo
.Width
div ScaleSz
, 1);
2284 aY
:= max(gMapInfo
.Height
div ScaleSz
, 1);
2286 e_DrawFillQuad(0, 0, aX
-1, aY
-1, 0, 0, 0, 0);
2288 if gWalls
<> nil then
2291 for a
:= 0 to High(gWalls
) do
2293 if PanelType
<> 0 then
2295 // Ëåâûé âåðõíèé óãîë:
2296 aX
:= X
div ScaleSz
;
2297 aY
:= Y
div ScaleSz
;
2299 aX2
:= max(Width
div ScaleSz
, 1);
2300 aY2
:= max(Height
div ScaleSz
, 1);
2301 // Ïðàâûé íèæíèé óãîë:
2302 aX2
:= aX
+ aX2
- 1;
2303 aY2
:= aY
+ aY2
- 1;
2306 PANEL_WALL
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 208, 208, 208, 0);
2307 PANEL_OPENDOOR
, PANEL_CLOSEDOOR
:
2308 if Enabled
then e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 160, 160, 160, 0);
2312 if gSteps
<> nil then
2315 for a
:= 0 to High(gSteps
) do
2317 if PanelType
<> 0 then
2319 // Ëåâûé âåðõíèé óãîë:
2320 aX
:= X
div ScaleSz
;
2321 aY
:= Y
div ScaleSz
;
2323 aX2
:= max(Width
div ScaleSz
, 1);
2324 aY2
:= max(Height
div ScaleSz
, 1);
2325 // Ïðàâûé íèæíèé óãîë:
2326 aX2
:= aX
+ aX2
- 1;
2327 aY2
:= aY
+ aY2
- 1;
2329 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 128, 128, 128, 0);
2332 if gLifts
<> nil then
2335 for a
:= 0 to High(gLifts
) do
2337 if PanelType
<> 0 then
2339 // Ëåâûé âåðõíèé óãîë:
2340 aX
:= X
div ScaleSz
;
2341 aY
:= Y
div ScaleSz
;
2343 aX2
:= max(Width
div ScaleSz
, 1);
2344 aY2
:= max(Height
div ScaleSz
, 1);
2345 // Ïðàâûé íèæíèé óãîë:
2346 aX2
:= aX
+ aX2
- 1;
2347 aY2
:= aY
+ aY2
- 1;
2350 0: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 116, 72, 36, 0);
2351 1: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 116, 124, 96, 0);
2352 2: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 200, 80, 4, 0);
2353 3: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 252, 140, 56, 0);
2357 if gWater
<> nil then
2360 for a
:= 0 to High(gWater
) do
2362 if PanelType
<> 0 then
2364 // Ëåâûé âåðõíèé óãîë:
2365 aX
:= X
div ScaleSz
;
2366 aY
:= Y
div ScaleSz
;
2368 aX2
:= max(Width
div ScaleSz
, 1);
2369 aY2
:= max(Height
div ScaleSz
, 1);
2370 // Ïðàâûé íèæíèé óãîë:
2371 aX2
:= aX
+ aX2
- 1;
2372 aY2
:= aY
+ aY2
- 1;
2374 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 0, 192, 0);
2377 if gAcid1
<> nil then
2379 // Ðèñóåì êèñëîòó 1:
2380 for a
:= 0 to High(gAcid1
) do
2382 if PanelType
<> 0 then
2384 // Ëåâûé âåðõíèé óãîë:
2385 aX
:= X
div ScaleSz
;
2386 aY
:= Y
div ScaleSz
;
2388 aX2
:= max(Width
div ScaleSz
, 1);
2389 aY2
:= max(Height
div ScaleSz
, 1);
2390 // Ïðàâûé íèæíèé óãîë:
2391 aX2
:= aX
+ aX2
- 1;
2392 aY2
:= aY
+ aY2
- 1;
2394 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 176, 0, 0);
2397 if gAcid2
<> nil then
2399 // Ðèñóåì êèñëîòó 2:
2400 for a
:= 0 to High(gAcid2
) do
2402 if PanelType
<> 0 then
2404 // Ëåâûé âåðõíèé óãîë:
2405 aX
:= X
div ScaleSz
;
2406 aY
:= Y
div ScaleSz
;
2408 aX2
:= max(Width
div ScaleSz
, 1);
2409 aY2
:= max(Height
div ScaleSz
, 1);
2410 // Ïðàâûé íèæíèé óãîë:
2411 aX2
:= aX
+ aX2
- 1;
2412 aY2
:= aY
+ aY2
- 1;
2414 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 176, 0, 0, 0);
2417 if gPlayers
<> nil then
2420 for a
:= 0 to High(gPlayers
) do
2421 if gPlayers
[a
] <> nil then with gPlayers
[a
] do
2423 // Ëåâûé âåðõíèé óãîë:
2424 aX
:= Obj
.X
div ScaleSz
+ 1;
2425 aY
:= Obj
.Y
div ScaleSz
+ 1;
2427 aX2
:= max(Obj
.Rect
.Width
div ScaleSz
, 1);
2428 aY2
:= max(Obj
.Rect
.Height
div ScaleSz
, 1);
2429 // Ïðàâûé íèæíèé óãîë:
2430 aX2
:= aX
+ aX2
- 1;
2431 aY2
:= aY
+ aY2
- 1;
2433 if gPlayers
[a
] = p
then
2434 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 255, 0, 0)
2437 TEAM_RED
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 0, 0, 0);
2438 TEAM_BLUE
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 0, 255, 0);
2439 else e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 128, 0, 0);
2443 if gMonsters
<> nil then
2446 for a
:= 0 to High(gMonsters
) do
2447 if gMonsters
[a
] <> nil then with gMonsters
[a
] do
2449 // Ëåâûé âåðõíèé óãîë:
2450 aX
:= Obj
.X
div ScaleSz
+ 1;
2451 aY
:= Obj
.Y
div ScaleSz
+ 1;
2453 aX2
:= max(Obj
.Rect
.Width
div ScaleSz
, 1);
2454 aY2
:= max(Obj
.Rect
.Height
div ScaleSz
, 1);
2455 // Ïðàâûé íèæíèé óãîë:
2456 aX2
:= aX
+ aX2
- 1;
2457 aY2
:= aY
+ aY2
- 1;
2459 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 255, 0, 0);
2465 procedure DrawMapView(x
, y
, w
, h
: Integer);
2471 bx
:= Round(x
/(gMapInfo
.Width
- w
)*(gBackSize
.X
- w
));
2472 by
:= Round(y
/(gMapInfo
.Height
- h
)*(gBackSize
.Y
- h
));
2473 g_Map_DrawBack(-bx
, -by
);
2480 glTranslatef(-x
, -y
, 0);
2482 g_Map_DrawPanels(PANEL_BACK
);
2483 g_Map_DrawPanels(PANEL_STEP
);
2486 g_Player_DrawShells();
2488 g_Player_DrawCorpses();
2489 g_Map_DrawPanels(PANEL_WALL
);
2491 g_Map_DrawPanels(PANEL_CLOSEDOOR
);
2494 g_Map_DrawPanels(PANEL_ACID1
);
2495 g_Map_DrawPanels(PANEL_ACID2
);
2496 g_Map_DrawPanels(PANEL_WATER
);
2497 g_Map_DrawPanels(PANEL_FORE
);
2498 if g_debug_HealthBar
then
2500 g_Monsters_DrawHealth();
2501 g_Player_DrawHealth();
2507 procedure DrawPlayer(p
: TPlayer
);
2509 px
, py
, a
, b
, c
, d
: Integer;
2512 if (p
= nil) or (p
.FDummy
) then
2515 g_Map_DrawBack(0, 0);
2524 px
:= p
.GameX
+ PLAYER_RECT_CX
;
2525 py
:= p
.GameY
+ PLAYER_RECT_CY
;
2527 if px
> (gPlayerScreenSize
.X
div 2) then
2528 a
:= -px
+ (gPlayerScreenSize
.X
div 2)
2531 if py
> (gPlayerScreenSize
.Y
div 2) then
2532 b
:= -py
+ (gPlayerScreenSize
.Y
div 2)
2535 if px
> (gMapInfo
.Width
- (gPlayerScreenSize
.X
div 2)) then
2536 a
:= -gMapInfo
.Width
+ gPlayerScreenSize
.X
;
2537 if py
> (gMapInfo
.Height
- (gPlayerScreenSize
.Y
div 2)) then
2538 b
:= -gMapInfo
.Height
+ gPlayerScreenSize
.Y
;
2539 if gMapInfo
.Width
<= gPlayerScreenSize
.X
then
2541 if gMapInfo
.Height
<= gPlayerScreenSize
.Y
then
2544 if p
.IncCam
<> 0 then
2546 if py
> (gMapInfo
.Height
- (gPlayerScreenSize
.Y
div 2)) then
2548 if p
.IncCam
> 120-(py
-(gMapInfo
.Height
-(gPlayerScreenSize
.Y
div 2))) then
2549 p
.IncCam
:= 120-(py
-(gMapInfo
.Height
-(gPlayerScreenSize
.Y
div 2)));
2552 if py
< (gPlayerScreenSize
.Y
div 2) then
2554 if p
.IncCam
< -120+((gPlayerScreenSize
.Y
div 2)-py
) then
2555 p
.IncCam
:= -120+((gPlayerScreenSize
.Y
div 2)-py
);
2558 if p
.IncCam
< 0 then
2559 while (py
+(gPlayerScreenSize
.Y
div 2)-p
.IncCam
> gMapInfo
.Height
) and
2561 p
.IncCam
:= p
.IncCam
+ 1;
2563 if p
.IncCam
> 0 then
2564 while (py
-(gPlayerScreenSize
.Y
div 2)-p
.IncCam
< 0) and
2566 p
.IncCam
:= p
.IncCam
- 1;
2569 if (px
< gPlayerScreenSize
.X
div 2) or
2570 (gMapInfo
.Width
-gPlayerScreenSize
.X
<= 256) then
2573 if (px
> gMapInfo
.Width
-(gPlayerScreenSize
.X
div 2)) then
2574 c
:= gBackSize
.X
- gPlayerScreenSize
.X
2576 c
:= Round((px
-(gPlayerScreenSize
.X
div 2))/(gMapInfo
.Width
-gPlayerScreenSize
.X
)*(gBackSize
.X
-gPlayerScreenSize
.X
));
2578 if (py
-p
.IncCam
<= gPlayerScreenSize
.Y
div 2) or
2579 (gMapInfo
.Height
-gPlayerScreenSize
.Y
<= 256) then
2582 if (py
-p
.IncCam
>= gMapInfo
.Height
-(gPlayerScreenSize
.Y
div 2)) then
2583 d
:= gBackSize
.Y
- gPlayerScreenSize
.Y
2585 d
:= Round((py
-p
.IncCam
-(gPlayerScreenSize
.Y
div 2))/(gMapInfo
.Height
-gPlayerScreenSize
.Y
)*(gBackSize
.Y
-gPlayerScreenSize
.Y
));
2587 g_Map_DrawBack(-c
, -d
);
2590 sY
:= -(b
+p
.IncCam
);
2591 sWidth
:= gPlayerScreenSize
.X
;
2592 sHeight
:= gPlayerScreenSize
.Y
;
2594 glTranslatef(a
, b
+p
.IncCam
, 0);
2596 g_Map_DrawPanels(PANEL_BACK
);
2597 g_Map_DrawPanels(PANEL_STEP
);
2600 g_Player_DrawShells();
2602 g_Player_DrawCorpses();
2603 g_Map_DrawPanels(PANEL_WALL
);
2605 g_Map_DrawPanels(PANEL_CLOSEDOOR
);
2608 g_Map_DrawPanels(PANEL_ACID1
);
2609 g_Map_DrawPanels(PANEL_ACID2
);
2610 g_Map_DrawPanels(PANEL_WATER
);
2611 g_Map_DrawPanels(PANEL_FORE
);
2612 if g_debug_HealthBar
then
2614 g_Monsters_DrawHealth();
2615 g_Player_DrawHealth();
2618 if p
.FSpectator
then
2619 e_TextureFontPrintEx(p
.GameX
+ PLAYER_RECT_CX
- 4,
2620 p
.GameY
+ PLAYER_RECT_CY
- 4,
2621 'X', gStdFont
, 255, 255, 255, 1, True);
2623 for a := 0 to High(gCollideMap) do
2624 for b := 0 to High(gCollideMap[a]) do
2627 if ByteBool(gCollideMap[a, b] and MARK_WALL) then
2629 if ByteBool(gCollideMap[a, b] and MARK_DOOR) then
2633 1: e_DrawPoint(1, b, a, 200, 200, 200);
2634 2: e_DrawPoint(1, b, a, 64, 64, 255);
2635 3: e_DrawPoint(1, b, a, 255, 0, 255);
2646 //DrawMinimap(p, _TRect(0, 0, 128, 128));
2647 if g_Debug_Player
then
2648 g_Player_DrawDebug(p
);
2652 procedure g_Game_Draw();
2659 plView1
, plView2
: TPlayer
;
2662 if gExit
= EXIT_QUIT
then Exit
;
2664 Time
:= GetTimer() div 1000;
2665 FPSCounter
:= FPSCounter
+1;
2666 if Time
- FPSTime
>= 1000 then
2673 if gGameOn
or (gState
= STATE_FOLD
) then
2675 if (gPlayer1
<> nil) and (gPlayer2
<> nil) then
2677 gSpectMode
:= SPECT_NONE
;
2678 if not gRevertPlayers
then
2680 plView1
:= gPlayer1
;
2681 plView2
:= gPlayer2
;
2685 plView1
:= gPlayer2
;
2686 plView2
:= gPlayer1
;
2690 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
2692 gSpectMode
:= SPECT_NONE
;
2693 if gPlayer2
= nil then
2696 plView1
:= gPlayer2
;
2705 if (plView1
= nil) and (plView2
= nil) and (gSpectMode
= SPECT_NONE
) then
2706 gSpectMode
:= SPECT_STATS
;
2708 if gSpectMode
= SPECT_PLAYERS
then
2709 if gPlayers
<> nil then
2711 plView1
:= GetActivePlayer_ByID(gSpectPID1
);
2712 if plView1
= nil then
2714 gSpectPID1
:= GetActivePlayerID_Next();
2715 plView1
:= GetActivePlayer_ByID(gSpectPID1
);
2717 if gSpectViewTwo
then
2719 plView2
:= GetActivePlayer_ByID(gSpectPID2
);
2720 if plView2
= nil then
2722 gSpectPID2
:= GetActivePlayerID_Next();
2723 plView2
:= GetActivePlayer_ByID(gSpectPID2
);
2728 if gSpectMode
= SPECT_MAPVIEW
then
2730 // Ðåæèì ïðîñìîòðà êàðòû
2732 e_SetViewPort(0, 0, gScreenWidth
, gScreenHeight
);
2733 DrawMapView(gSpectX
, gSpectY
, gScreenWidth
, gScreenHeight
);
2734 gHearPoint1
.Active
:= True;
2735 gHearPoint1
.Coords
.X
:= gScreenWidth
div 2 + gSpectX
;
2736 gHearPoint1
.Coords
.Y
:= gScreenHeight
div 2 + gSpectY
;
2737 gHearPoint2
.Active
:= False;
2741 Split
:= (plView1
<> nil) and (plView2
<> nil);
2743 // Òî÷êè ñëóõà èãðîêîâ
2744 if plView1
<> nil then
2746 gHearPoint1
.Active
:= True;
2747 gHearPoint1
.Coords
.X
:= plView1
.GameX
;
2748 gHearPoint1
.Coords
.Y
:= plView1
.GameY
;
2750 gHearPoint1
.Active
:= False;
2751 if plView2
<> nil then
2753 gHearPoint2
.Active
:= True;
2754 gHearPoint2
.Coords
.X
:= plView2
.GameX
;
2755 gHearPoint2
.Coords
.Y
:= plView2
.GameY
;
2757 gHearPoint2
.Active
:= False;
2759 // Ðàçìåð ýêðàíîâ èãðîêîâ:
2760 gPlayerScreenSize
.X
:= gScreenWidth
-196;
2763 gPlayerScreenSize
.Y
:= gScreenHeight
div 2;
2764 if gScreenHeight
mod 2 = 0 then
2765 Dec(gPlayerScreenSize
.Y
);
2768 gPlayerScreenSize
.Y
:= gScreenHeight
;
2771 if gScreenHeight
mod 2 = 0 then
2772 e_SetViewPort(0, gPlayerScreenSize
.Y
+2, gPlayerScreenSize
.X
+196, gPlayerScreenSize
.Y
)
2774 e_SetViewPort(0, gPlayerScreenSize
.Y
+1, gPlayerScreenSize
.X
+196, gPlayerScreenSize
.Y
);
2776 DrawPlayer(plView1
);
2777 gPlayer1ScreenCoord
.X
:= sX
;
2778 gPlayer1ScreenCoord
.Y
:= sY
;
2782 e_SetViewPort(0, 0, gPlayerScreenSize
.X
+196, gPlayerScreenSize
.Y
);
2784 DrawPlayer(plView2
);
2785 gPlayer2ScreenCoord
.X
:= sX
;
2786 gPlayer2ScreenCoord
.Y
:= sY
;
2789 e_SetViewPort(0, 0, gScreenWidth
, gScreenHeight
);
2792 e_DrawLine(2, 0, gScreenHeight
div 2, gScreenWidth
, gScreenHeight
div 2, 0, 0, 0);
2795 if MessageText
<> '' then
2799 e_CharFont_GetSizeFmt(gMenuFont
, MessageText
, w
, h
);
2801 e_CharFont_PrintFmt(gMenuFont
, (gScreenWidth
div 2)-(w
div 2),
2802 (gScreenHeight
div 2)-(h
div 2), MessageText
)
2804 e_CharFont_PrintFmt(gMenuFont
, (gScreenWidth
div 2)-(w
div 2),
2805 Round(gScreenHeight
/ 2.75)-(h
div 2), MessageText
);
2808 if IsDrawStat
or (gSpectMode
= 1) then DrawStat();
2810 if gSpectHUD
and (not gChatShow
) and (gSpectMode
<> SPECT_NONE
) then
2812 // Draw spectator GUI
2815 e_TextureFontGetSize(gStdFont
, ww
, hh
);
2818 e_TextureFontPrintEx(0, gScreenHeight
- (hh
+2)*2, 'MODE: Stats', gStdFont
, 255, 255, 255, 1);
2820 e_TextureFontPrintEx(0, gScreenHeight
- (hh
+2)*2, 'MODE: Observe Map', gStdFont
, 255, 255, 255, 1);
2822 e_TextureFontPrintEx(0, gScreenHeight
- (hh
+2)*2, 'MODE: Watch Players', gStdFont
, 255, 255, 255, 1);
2824 e_TextureFontPrintEx(2*ww
, gScreenHeight
- (hh
+2), '< jump >', gStdFont
, 255, 255, 255, 1);
2825 if gSpectMode
= SPECT_MAPVIEW
then
2827 e_TextureFontPrintEx(22*ww
, gScreenHeight
- (hh
+2)*2, '[-]', gStdFont
, 255, 255, 255, 1);
2828 e_TextureFontPrintEx(26*ww
, gScreenHeight
- (hh
+2)*2, 'Step ' + IntToStr(gSpectStep
), gStdFont
, 255, 255, 255, 1);
2829 e_TextureFontPrintEx(34*ww
, gScreenHeight
- (hh
+2)*2, '[+]', gStdFont
, 255, 255, 255, 1);
2830 e_TextureFontPrintEx(18*ww
, gScreenHeight
- (hh
+2), '<prev weap>', gStdFont
, 255, 255, 255, 1);
2831 e_TextureFontPrintEx(30*ww
, gScreenHeight
- (hh
+2), '<next weap>', gStdFont
, 255, 255, 255, 1);
2833 if gSpectMode
= SPECT_PLAYERS
then
2835 e_TextureFontPrintEx(22*ww
, gScreenHeight
- (hh
+2)*2, 'Player 1', gStdFont
, 255, 255, 255, 1);
2836 e_TextureFontPrintEx(20*ww
, gScreenHeight
- (hh
+2), '<left/right>', gStdFont
, 255, 255, 255, 1);
2837 if gSpectViewTwo
then
2839 e_TextureFontPrintEx(37*ww
, gScreenHeight
- (hh
+2)*2, 'Player 2', gStdFont
, 255, 255, 255, 1);
2840 e_TextureFontPrintEx(34*ww
, gScreenHeight
- (hh
+2), '<prev w/next w>', gStdFont
, 255, 255, 255, 1);
2841 e_TextureFontPrintEx(52*ww
, gScreenHeight
- (hh
+2)*2, '2x View', gStdFont
, 255, 255, 255, 1);
2842 e_TextureFontPrintEx(51*ww
, gScreenHeight
- (hh
+2), '<up/down>', gStdFont
, 255, 255, 255, 1);
2846 e_TextureFontPrintEx(35*ww
, gScreenHeight
- (hh
+2)*2, '2x View', gStdFont
, 255, 255, 255, 1);
2847 e_TextureFontPrintEx(34*ww
, gScreenHeight
- (hh
+2), '<up/down>', gStdFont
, 255, 255, 255, 1);
2853 if gPause
and gGameOn
and (g_ActiveWindow
= nil) then
2855 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 48, 48, 48, 180);
2857 e_CharFont_GetSize(gMenuFont
, _lc
[I_MENU_PAUSE
], w
, h
);
2858 e_CharFont_Print(gMenuFont
, (gScreenWidth
div 2)-(w
div 2),
2859 (gScreenHeight
div 2)-(h
div 2), _lc
[I_MENU_PAUSE
]);
2864 if (gState
= STATE_MENU
) then
2866 if ((g_ActiveWindow
= nil) or (g_ActiveWindow
.BackTexture
= '')) then
2868 if g_Texture_Get('MENU_BACKGROUND', ID
) then
2869 e_DrawSize(ID
, 0, 0, 0, False, False, gScreenWidth
, gScreenHeight
)
2870 else e_Clear(GL_COLOR_BUFFER_BIT
, 0, 0, 0);
2872 if g_ActiveWindow
<> nil then
2873 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 48, 48, 48, 180);
2876 if gState
= STATE_FOLD
then
2877 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 0, 0, 0, EndingGameCounter
);
2879 if gState
= STATE_INTERCUSTOM
then
2881 if gLastMap
and (gGameSettings
.GameMode
= GM_COOP
) then
2883 back
:= 'TEXTURE_endpic';
2884 if not g_Texture_Get(back
, ID
) then
2885 back
:= _lc
[I_TEXTURE_ENDPIC
];
2890 if g_Texture_Get(back
, ID
) then
2891 e_DrawSize(ID
, 0, 0, 0, False, False, gScreenWidth
, gScreenHeight
)
2893 e_Clear(GL_COLOR_BUFFER_BIT
, 0, 0, 0);
2897 if g_ActiveWindow
<> nil then
2898 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 48, 48, 48, 180);
2901 if gState
= STATE_INTERSINGLE
then
2903 if EndingGameCounter
> 0 then
2904 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 0, 0, 0, EndingGameCounter
)
2909 if g_Texture_Get(back
, ID
) then
2910 e_DrawSize(ID
, 0, 0, 0, False, False, gScreenWidth
, gScreenHeight
)
2912 e_Clear(GL_COLOR_BUFFER_BIT
, 0, 0, 0);
2916 if g_ActiveWindow
<> nil then
2917 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 48, 48, 48, 180);
2921 if gState
= STATE_ENDPIC
then
2924 if not g_Texture_Get('TEXTURE_endpic', ID
) then
2925 g_Texture_Get(_lc
[I_TEXTURE_ENDPIC
], ID
);
2927 if ID
<> DWORD(-1) then
2928 e_DrawSize(ID
, 0, 0, 0, False, False, gScreenWidth
, gScreenHeight
)
2930 e_Clear(GL_COLOR_BUFFER_BIT
, 0, 0, 0);
2932 if g_ActiveWindow
<> nil then
2933 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 48, 48, 48, 180);
2936 if gState
= STATE_SLIST
then
2938 if g_Texture_Get('MENU_BACKGROUND', ID
) then
2940 e_DrawSize(ID
, 0, 0, 0, False, False, gScreenWidth
, gScreenHeight
);
2941 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 48, 48, 48, 180);
2943 g_Serverlist_Draw(slCurrent
);
2947 if g_ActiveWindow
<> nil then
2950 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 48, 48, 48, 180);
2951 g_ActiveWindow
.Draw();
2956 if g_debug_Sounds
and gGameOn
then
2958 for w
:= 0 to High(e_SoundsArray
) do
2959 for h
:= 0 to e_SoundsArray
[w
].nRefs
do
2960 e_DrawPoint(1, w
+100, h
+100, 255, 0, 0);
2965 e_TextureFontPrint(0, 0, Format('FPS: %d', [FPS
]), gStdFont
);
2966 e_TextureFontPrint(0, 16, Format('UPS: %d', [UPS
]), gStdFont
);
2969 if gGameOn
and gShowTime
and (gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
]) then
2970 e_TextureFontPrint(gScreenWidth
-72, 0,
2971 Format('%d:%.2d:%.2d', [gTime
div 1000 div 3600, (gTime
div 1000 div 60) mod 60, gTime
div 1000 mod 60]),
2975 procedure g_Game_Quit();
2977 g_Game_StopAllSounds(True);
2979 g_Game_SaveOptions();
2981 g_PlayerModel_FreeData();
2982 g_Texture_DeleteAll();
2983 g_Frames_DeleteAll();
2986 if NetInitDone
then g_Net_Free
;
2988 // Íàäî óäàëèòü êàðòó ïîñëå òåñòà:
2989 if gMapToDelete
<> '' then
2990 g_Game_DeleteTestMap();
2996 procedure g_FatalError(Text: String);
2998 g_Console_Add(Format(_lc
[I_FATAL_ERROR
], [Text]), True);
2999 e_WriteLog(Format(_lc
[I_FATAL_ERROR
], [Text]), MSG_WARNING
);
3001 gExit
:= EXIT_SIMPLE
;
3004 procedure g_SimpleError(Text: String);
3006 g_Console_Add(Format(_lc
[I_SIMPLE_ERROR
], [Text]), True);
3007 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], [Text]), MSG_WARNING
);
3010 procedure g_Game_SetupScreenSize();
3014 // Ðàçìåð ýêðàíîâ èãðîêîâ:
3015 gPlayerScreenSize
.X
:= gScreenWidth
-196;
3016 if (gPlayer1
<> nil) and (gPlayer2
<> nil) then
3017 gPlayerScreenSize
.Y
:= gScreenHeight
div 2
3019 gPlayerScreenSize
.Y
:= gScreenHeight
;
3021 // Ðàçìåð çàäíåãî ïëàíà:
3022 if BackID
<> DWORD(-1) then
3026 if (gScreenWidth
*d
> gMapInfo
.Width
) or
3027 (gScreenHeight
*d
> gMapInfo
.Height
) then
3030 gBackSize
.X
:= Round(gScreenWidth
*d
);
3031 gBackSize
.Y
:= Round(gScreenHeight
*d
);
3035 procedure g_Game_ChangeResolution(newWidth
, newHeight
: Word; nowFull
, nowMax
: Boolean);
3037 g_Window_SetSize(newWidth
, newHeight
, nowFull
);
3040 procedure g_Game_AddPlayer(Team
: Byte = TEAM_NONE
);
3042 if ((not gGameOn
) and (gState
<> STATE_INTERCUSTOM
))
3043 or (not (gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
])) then
3045 if gPlayer1
= nil then
3047 if g_Game_IsClient
then
3049 if NetPlrUID1
> -1 then
3051 MC_SEND_CheatRequest(NET_CHEAT_SPECTATE
);
3052 gPlayer1
:= g_Player_Get(NetPlrUID1
);
3057 if not (Team
in [TEAM_RED
, TEAM_BLUE
]) then
3058 Team
:= gPlayer1Settings
.Team
;
3060 // Ñîçäàíèå ïåðâîãî èãðîêà:
3061 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
3062 gPlayer1Settings
.Color
,
3064 if gPlayer1
= nil then
3065 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]))
3068 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
3069 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [gPlayer1
.Name
]), True);
3070 if g_Game_IsServer
and g_Game_IsNet
then
3071 MH_SEND_PlayerCreate(gPlayer1
.UID
);
3072 gPlayer1
.Respawn(False, True);
3074 if g_Game_IsNet
and NetUseMaster
then
3080 if gPlayer2
= nil then
3082 if g_Game_IsClient
then
3084 if NetPlrUID2
> -1 then
3085 gPlayer2
:= g_Player_Get(NetPlrUID2
);
3089 if not (Team
in [TEAM_RED
, TEAM_BLUE
]) then
3090 Team
:= gPlayer2Settings
.Team
;
3092 // Ñîçäàíèå âòîðîãî èãðîêà:
3093 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
3094 gPlayer2Settings
.Color
,
3096 if gPlayer2
= nil then
3097 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]))
3100 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
3101 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [gPlayer2
.Name
]), True);
3102 if g_Game_IsServer
and g_Game_IsNet
then
3103 MH_SEND_PlayerCreate(gPlayer2
.UID
);
3104 gPlayer2
.Respawn(False, True);
3106 if g_Game_IsNet
and NetUseMaster
then
3114 procedure g_Game_RemovePlayer();
3118 if ((not gGameOn
) and (gState
<> STATE_INTERCUSTOM
))
3119 or (not (gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
])) then
3124 if g_Game_IsServer
then
3127 Pl
.Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
3128 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [Pl
.Name
]), True);
3129 g_Player_Remove(Pl
.UID
);
3131 if g_Game_IsNet
and NetUseMaster
then
3140 if g_Game_IsServer
then
3143 Pl
.Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
3144 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [Pl
.Name
]), True);
3145 g_Player_Remove(Pl
.UID
);
3147 if g_Game_IsNet
and NetUseMaster
then
3152 MC_SEND_CheatRequest(NET_CHEAT_SPECTATE
);
3158 procedure g_Game_Spectate();
3160 g_Game_RemovePlayer();
3161 if gPlayer1
<> nil then
3162 g_Game_RemovePlayer();
3165 procedure g_Game_SpectateCenterView();
3167 gSpectX
:= Max(gMapInfo
.Width
div 2 - gScreenWidth
div 2, 0);
3168 gSpectY
:= Max(gMapInfo
.Height
div 2 - gScreenHeight
div 2, 0);
3171 procedure g_Game_StartSingle(Map
: String; TwoPlayers
: Boolean; nPlayers
: Byte);
3177 e_WriteLog('Starting singleplayer game...', MSG_NOTIFY
);
3179 g_Game_ClearLoading();
3182 FillByte(gGameSettings
, SizeOf(TGameSettings
), 0);
3185 gGameSettings
.GameType
:= GT_SINGLE
;
3186 gGameSettings
.MaxLives
:= 0;
3187 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_ALLOWEXIT
;
3188 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_MONSTERS
;
3189 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_BOTVSMONSTER
;
3190 gSwitchGameMode
:= GM_SINGLE
;
3192 g_Game_ExecuteEvent('ongamestart');
3194 // Óñòàíîâêà ðàçìåðîâ îêîí èãðîêîâ:
3195 g_Game_SetupScreenSize();
3197 // Ñîçäàíèå ïåðâîãî èãðîêà:
3198 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
3199 gPlayer1Settings
.Color
,
3200 gPlayer1Settings
.Team
, False));
3201 if gPlayer1
= nil then
3203 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
3207 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
3210 // Ñîçäàíèå âòîðîãî èãðîêà, åñëè åñòü:
3213 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
3214 gPlayer2Settings
.Color
,
3215 gPlayer2Settings
.Team
, False));
3216 if gPlayer2
= nil then
3218 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
3222 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
3226 // Çàãðóçêà è çàïóñê êàðòû:
3227 if not g_Game_StartMap(MAP
, True) then
3229 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [gGameSettings
.WAD
+ ':\' + MAP
]));
3233 // Íàñòðîéêè èãðîêîâ è áîòîâ:
3237 for i
:= nPl
+1 to nPlayers
do
3238 g_Player_Create(STD_PLAYER_MODEL
, _RGB(0, 0, 0), 0, True);
3241 procedure g_Game_StartCustom(Map
: String; GameMode
: Byte;
3242 TimeLimit
, GoalLimit
: Word;
3244 Options
: LongWord
; nPlayers
: Byte);
3250 e_WriteLog('Starting custom game...', MSG_NOTIFY
);
3252 g_Game_ClearLoading();
3255 gGameSettings
.GameType
:= GT_CUSTOM
;
3256 gGameSettings
.GameMode
:= GameMode
;
3257 gSwitchGameMode
:= GameMode
;
3258 gGameSettings
.TimeLimit
:= TimeLimit
;
3259 gGameSettings
.GoalLimit
:= GoalLimit
;
3260 gGameSettings
.MaxLives
:= IfThen(GameMode
= GM_CTF
, 0, MaxLives
);
3261 gGameSettings
.Options
:= Options
;
3263 gCoopTotalMonstersKilled
:= 0;
3264 gCoopTotalSecretsFound
:= 0;
3265 gCoopTotalMonsters
:= 0;
3266 gCoopTotalSecrets
:= 0;
3270 g_Game_ExecuteEvent('ongamestart');
3272 // Óñòàíîâêà ðàçìåðîâ îêîí èãðîêîâ:
3273 g_Game_SetupScreenSize();
3275 // Ðåæèì íàáëþäàòåëÿ:
3276 if nPlayers
= 0 then
3283 if nPlayers
>= 1 then
3285 // Ñîçäàíèå ïåðâîãî èãðîêà:
3286 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
3287 gPlayer1Settings
.Color
,
3288 gPlayer1Settings
.Team
, False));
3289 if gPlayer1
= nil then
3291 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
3295 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
3299 if nPlayers
>= 2 then
3301 // Ñîçäàíèå âòîðîãî èãðîêà:
3302 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
3303 gPlayer2Settings
.Color
,
3304 gPlayer2Settings
.Team
, False));
3305 if gPlayer2
= nil then
3307 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
3311 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
3315 // Çàãðóçêà è çàïóñê êàðòû:
3316 if not g_Game_StartMap(Map
, True) then
3318 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [Map
]));
3322 // Íåò òî÷åê ïîÿâëåíèÿ:
3323 if (g_Map_GetPointCount(RESPAWNPOINT_PLAYER1
) +
3324 g_Map_GetPointCount(RESPAWNPOINT_PLAYER2
) +
3325 g_Map_GetPointCount(RESPAWNPOINT_DM
) +
3326 g_Map_GetPointCount(RESPAWNPOINT_RED
)+
3327 g_Map_GetPointCount(RESPAWNPOINT_BLUE
)) < 1 then
3329 g_FatalError(_lc
[I_GAME_ERROR_GET_SPAWN
]);
3333 // Íàñòðîéêè èãðîêîâ è áîòîâ:
3337 for i
:= nPl
+1 to nPlayers
do
3338 g_Player_Create(STD_PLAYER_MODEL
, _RGB(0, 0, 0), 0, True);
3341 procedure g_Game_StartServer(Map
: String; GameMode
: Byte;
3342 TimeLimit
, GoalLimit
: Word; MaxLives
: Byte;
3343 Options
: LongWord
; nPlayers
: Byte;
3344 IPAddr
: LongWord
; Port
: Word);
3348 e_WriteLog('Starting net game (server)...', MSG_NOTIFY
);
3350 g_Game_ClearLoading();
3353 gGameSettings
.GameType
:= GT_SERVER
;
3354 gGameSettings
.GameMode
:= GameMode
;
3355 gSwitchGameMode
:= GameMode
;
3356 gGameSettings
.TimeLimit
:= TimeLimit
;
3357 gGameSettings
.GoalLimit
:= GoalLimit
;
3358 gGameSettings
.MaxLives
:= IfThen(GameMode
= GM_CTF
, 0, MaxLives
);
3359 gGameSettings
.Options
:= Options
;
3361 gCoopTotalMonstersKilled
:= 0;
3362 gCoopTotalSecretsFound
:= 0;
3363 gCoopTotalMonsters
:= 0;
3364 gCoopTotalSecrets
:= 0;
3368 g_Game_ExecuteEvent('ongamestart');
3370 // Óñòàíîâêà ðàçìåðîâ îêíà èãðîêà
3371 g_Game_SetupScreenSize();
3373 // Ðåæèì íàáëþäàòåëÿ:
3374 if nPlayers
= 0 then
3380 if nPlayers
>= 1 then
3382 // Ñîçäàíèå ïåðâîãî èãðîêà:
3383 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
3384 gPlayer1Settings
.Color
,
3385 gPlayer1Settings
.Team
, False));
3386 if gPlayer1
= nil then
3388 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
3392 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
3395 if nPlayers
>= 2 then
3397 // Ñîçäàíèå âòîðîãî èãðîêà:
3398 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
3399 gPlayer2Settings
.Color
,
3400 gPlayer2Settings
.Team
, False));
3401 if gPlayer2
= nil then
3403 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
3407 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
3411 if not g_Net_Host(IPAddr
, Port
, NetMaxClients
) then
3413 g_FatalError(_lc
[I_NET_MSG
] + _lc
[I_NET_ERR_HOST
]);
3417 g_Net_Slist_Set(NetSlistIP
, NetSlistPort
);
3419 // Çàãðóçêà è çàïóñê êàðòû:
3420 if not g_Game_StartMap(Map
, True) then
3422 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [Map
]));
3426 // Íåò òî÷åê ïîÿâëåíèÿ:
3427 if (g_Map_GetPointCount(RESPAWNPOINT_PLAYER1
) +
3428 g_Map_GetPointCount(RESPAWNPOINT_PLAYER2
) +
3429 g_Map_GetPointCount(RESPAWNPOINT_DM
) +
3430 g_Map_GetPointCount(RESPAWNPOINT_RED
)+
3431 g_Map_GetPointCount(RESPAWNPOINT_BLUE
)) < 1 then
3433 g_FatalError(_lc
[I_GAME_ERROR_GET_SPAWN
]);
3437 // Íàñòðîéêè èãðîêîâ è áîòîâ:
3440 NetState
:= NET_STATE_GAME
;
3443 procedure g_Game_StartClient(Addr
: String; Port
: Word; PW
: String);
3457 e_WriteLog('Starting net game (client)...', MSG_NOTIFY
);
3458 e_WriteLog('NET: Trying to connect to ' + Addr
+ ':' + IntToStr(Port
) + '...', MSG_NOTIFY
);
3460 g_Game_ClearLoading();
3463 gGameSettings
.GameType
:= GT_CLIENT
;
3465 gCoopTotalMonstersKilled
:= 0;
3466 gCoopTotalSecretsFound
:= 0;
3467 gCoopTotalMonsters
:= 0;
3468 gCoopTotalSecrets
:= 0;
3472 g_Game_ExecuteEvent('ongamestart');
3474 // Óñòàíîâêà ðàçìåðîâ îêîí èãðîêîâ:
3475 g_Game_SetupScreenSize();
3477 NetState
:= NET_STATE_AUTH
;
3479 g_Game_SetLoadingText(_lc
[I_LOAD_CONNECT
], 0, False);
3481 if not g_Net_Connect(Addr
, Port
) then
3483 g_FatalError(_lc
[I_NET_MSG
] + _lc
[I_NET_ERR_CONN
]);
3484 NetState
:= NET_STATE_NONE
;
3488 g_Game_SetLoadingText(_lc
[I_LOAD_SEND_INFO
], 0, False);
3490 g_Game_SetLoadingText(_lc
[I_LOAD_WAIT_INFO
], 0, False);
3495 while (enet_host_service(NetHost
, @NetEvent
, 0) > 0) do
3497 if (NetEvent
.kind
= ENET_EVENT_TYPE_RECEIVE
) then
3499 Ptr
:= NetEvent
.packet
^.data
;
3502 MID
:= e_Raw_Read_Byte(Ptr
);
3504 if (MID
= NET_MSG_INFO
) and (State
= 0) then
3506 NetMyID
:= e_Raw_Read_Byte(Ptr
);
3507 NetPlrUID1
:= e_Raw_Read_Word(Ptr
);
3509 WadName
:= e_Raw_Read_String(Ptr
);
3510 Map
:= e_Raw_Read_String(Ptr
);
3512 gWADHash
:= e_Raw_Read_MD5(Ptr
);
3514 gGameSettings
.GameMode
:= e_Raw_Read_Byte(Ptr
);
3515 gSwitchGameMode
:= gGameSettings
.GameMode
;
3516 gGameSettings
.GoalLimit
:= e_Raw_Read_Word(Ptr
);
3517 gGameSettings
.TimeLimit
:= e_Raw_Read_Word(Ptr
);
3518 gGameSettings
.MaxLives
:= e_Raw_Read_Byte(Ptr
);
3519 gGameSettings
.Options
:= e_Raw_Read_LongWord(Ptr
);
3520 T
:= e_Raw_Read_LongWord(Ptr
);
3522 newResPath
:= g_Res_SearchSameWAD(MapsDir
, WadName
, gWADHash
);
3523 if newResPath
= '' then
3525 g_Game_SetLoadingText(_lc
[I_LOAD_DL_RES
], 0, False);
3526 newResPath
:= g_Res_DownloadWAD(WadName
);
3527 if newResPath
= '' then
3529 g_FatalError(_lc
[I_NET_ERR_HASH
]);
3530 enet_packet_destroy(NetEvent
.packet
);
3531 NetState
:= NET_STATE_NONE
;
3535 newResPath
:= ExtractRelativePath(MapsDir
, newResPath
);
3537 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
3538 gPlayer1Settings
.Color
,
3539 gPlayer1Settings
.Team
, False));
3541 if gPlayer1
= nil then
3543 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
3545 enet_packet_destroy(NetEvent
.packet
);
3546 NetState
:= NET_STATE_NONE
;
3550 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
3551 gPlayer1
.UID
:= NetPlrUID1
;
3552 gPlayer1
.Reset(True);
3554 if not g_Game_StartMap(newResPath
+ ':\' + Map
, True) then
3556 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [WadName
+ ':\' + Map
]));
3558 enet_packet_destroy(NetEvent
.packet
);
3559 NetState
:= NET_STATE_NONE
;
3567 enet_packet_destroy(NetEvent
.packet
);
3571 enet_packet_destroy(NetEvent
.packet
);
3574 if (NetEvent
.kind
= ENET_EVENT_TYPE_DISCONNECT
) then
3577 if (NetEvent
.data
<= NET_DISC_MAX
) then
3578 g_Console_Add(_lc
[I_NET_MSG_ERROR
] + _lc
[I_NET_ERR_CONN
] + ' ' +
3579 _lc
[TStrings_Locale(Cardinal(I_NET_DISC_NONE
) + NetEvent
.data
)], True);
3589 if e_KeyPressed(IK_ESCAPE
) or e_KeyPressed(IK_SPACE
) then
3598 g_FatalError(_lc
[I_NET_MSG
] + _lc
[I_NET_ERR_CONN
]);
3599 NetState
:= NET_STATE_NONE
;
3603 gLMSRespawn
:= LMS_RESPAWN_NONE
;
3604 gLMSRespawnTime
:= 0;
3607 NetState
:= NET_STATE_GAME
;
3608 MC_SEND_FullStateRequest
;
3609 e_WriteLog('NET: Connection successful.', MSG_NOTIFY
);
3612 procedure g_Game_SaveOptions();
3614 g_Options_Write_Video(GameDir
+'/'+CONFIG_FILENAME
);
3617 procedure g_Game_ChangeMap(MapPath
: String);
3621 g_Game_ClearLoading();
3623 Force
:= gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
];
3624 // Åñëè óðîâåíü çàâåðøèëñÿ ïî òðèããåðó Âûõîä, íå î÷èùàòü èíâåíòàðü
3625 if gExitByTrigger
then
3628 gExitByTrigger
:= False;
3630 if not g_Game_StartMap(MapPath
, Force
) then
3631 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [MapPath
]));
3634 procedure g_Game_Restart();
3638 if g_Game_IsClient
then
3640 g_ProcessResourceStr(gMapInfo
.Map
, nil, nil, @Map
);
3644 g_Game_ClearLoading();
3645 g_Game_StartMap(Map
, True);
3648 function g_Game_StartMap(Map
: String; Force
: Boolean = False): Boolean;
3650 NewWAD
, ResName
: String;
3654 g_Player_RemoveAllCorpses();
3656 if (not g_Game_IsClient
) and
3657 (gSwitchGameMode
<> gGameSettings
.GameMode
) and
3658 (gGameSettings
.GameMode
<> GM_SINGLE
) then
3660 if gSwitchGameMode
= GM_CTF
then
3661 gGameSettings
.MaxLives
:= 0;
3662 gGameSettings
.GameMode
:= gSwitchGameMode
;
3665 gSwitchGameMode
:= gGameSettings
.GameMode
;
3667 g_Player_ResetTeams();
3669 if Pos(':\', Map
) > 0 then
3671 g_ProcessResourceStr(Map
, @NewWAD
, nil, @ResName
);
3672 if g_Game_IsServer
then
3674 gWADHash
:= MD5File(MapsDir
+ NewWAD
);
3675 g_Game_LoadWAD(NewWAD
);
3677 // hash recieved in MC_RECV_GameEvent -> NET_EV_MAPSTART
3678 g_Game_ClientWAD(NewWAD
, gWADHash
);
3682 Result
:= g_Map_Load(MapsDir
+ gGameSettings
.WAD
+ ':\' + ResName
);
3685 g_Player_ResetAll(Force
or gLastMap
, gGameSettings
.GameType
= GT_SINGLE
);
3687 gState
:= STATE_NONE
;
3688 g_ActiveWindow
:= nil;
3694 if gGameSettings
.GameMode
= GM_CTF
then
3696 g_Map_ResetFlag(FLAG_RED
);
3697 g_Map_ResetFlag(FLAG_BLUE
);
3698 // CTF, à ôëàãîâ íåò:
3699 if not g_Map_HaveFlagPoints() then
3700 g_SimpleError(_lc
[I_GAME_ERROR_CTF
]);
3705 gState
:= STATE_MENU
;
3712 NetTimeToUpdate
:= 1;
3713 NetTimeToReliable
:= 0;
3714 NetTimeToMaster
:= NetMasterRate
;
3715 gLMSRespawn
:= LMS_RESPAWN_NONE
;
3716 gLMSRespawnTime
:= 0;
3717 gMissionFailed
:= False;
3720 gCoopMonstersKilled
:= 0;
3721 gCoopSecretsFound
:= 0;
3723 gVoteInProgress
:= False;
3724 gVotePassed
:= False;
3730 if not gGameOn
then Exit
;
3732 g_Game_SpectateCenterView();
3734 if (gGameSettings
.MaxLives
> 0) and (gGameSettings
.WarmupTime
> 0) then
3736 gLMSRespawn
:= LMS_RESPAWN_WARMUP
;
3737 gLMSRespawnTime
:= gTime
+ gGameSettings
.WarmupTime
*1000;
3738 gLMSSoftSpawn
:= True;
3739 if NetMode
= NET_SERVER
then
3740 MH_SEND_GameEvent(NET_EV_LMS_WARMUP
, (gLMSRespawnTime
- gTime
) div 1000)
3742 g_Console_Add(Format(_lc
[I_MSG_WARMUP_START
], [(gLMSRespawnTime
- gTime
) div 1000]), True);
3745 if NetMode
= NET_SERVER
then
3747 MH_SEND_GameEvent(NET_EV_MAPSTART
, gGameSettings
.GameMode
, Map
);
3750 if NetUseMaster
then
3752 if (NetMHost
= nil) or (NetMPeer
= nil) then
3753 if not g_Net_Slist_Connect
then
3754 g_Console_Add(_lc
[I_NET_MSG_ERROR
] + _lc
[I_NET_SLIST_ERROR
]);
3759 if NetClients
<> nil then
3760 for I
:= 0 to High(NetClients
) do
3761 if NetClients
[I
].Used
then
3763 NetClients
[I
].Voted
:= False;
3764 if NetClients
[I
].RequestedFullUpdate
then
3766 MH_SEND_Everything((NetClients
[I
].State
= NET_STATE_AUTH
), I
);
3767 NetClients
[I
].RequestedFullUpdate
:= False;
3771 g_Net_UnbanNonPermHosts();
3776 gCoopTotalMonstersKilled
:= 0;
3777 gCoopTotalSecretsFound
:= 0;
3778 gCoopTotalMonsters
:= 0;
3779 gCoopTotalSecrets
:= 0;
3783 g_Game_ExecuteEvent('onmapstart');
3786 procedure SetFirstLevel();
3790 MapList
:= g_Map_GetMapsList(MapsDir
+ gGameSettings
.WAD
);
3791 if MapList
= nil then
3794 SortSArray(MapList
);
3795 gNextMap
:= MapList
[Low(MapList
)];
3800 procedure g_Game_ExitLevel(Map
: Char16
);
3804 gCoopTotalMonstersKilled
:= gCoopTotalMonstersKilled
+ gCoopMonstersKilled
;
3805 gCoopTotalSecretsFound
:= gCoopTotalSecretsFound
+ gCoopSecretsFound
;
3806 gCoopTotalMonsters
:= gCoopTotalMonsters
+ gTotalMonsters
;
3807 gCoopTotalSecrets
:= gCoopTotalSecrets
+ gSecretsCount
;
3809 // Âûøëè â âûõîä â Îäèíî÷íîé èãðå:
3810 if gGameSettings
.GameType
= GT_SINGLE
then
3811 gExit
:= EXIT_ENDLEVELSINGLE
3812 else // Âûøëè â âûõîä â Ñâîåé èãðå
3814 gExit
:= EXIT_ENDLEVELCUSTOM
;
3815 if gGameSettings
.GameMode
= GM_COOP
then
3816 g_Player_RememberAll
;
3818 if not g_Map_Exist(MapsDir
+ gGameSettings
.WAD
+ ':\' + gNextMap
) then
3821 if gGameSettings
.GameMode
= GM_COOP
then
3824 gStatsPressed
:= True;
3825 gNextMap
:= 'MAP01';
3827 if not g_Map_Exist(MapsDir
+ gGameSettings
.WAD
+ ':\' + gNextMap
) then
3830 if g_Game_IsNet
then
3832 MH_SEND_GameStats();
3833 MH_SEND_CoopStats();
3839 procedure g_Game_RestartLevel();
3843 if gGameSettings
.GameMode
= GM_SINGLE
then
3848 gExit
:= EXIT_ENDLEVELCUSTOM
;
3849 g_ProcessResourceStr(gMapInfo
.Map
, nil, nil, @Map
);
3853 procedure g_Game_ClientWAD(NewWAD
: String; WHash
: TMD5Digest
);
3857 if LowerCase(NewWAD
) = LowerCase(gGameSettings
.WAD
) then
3859 if not g_Game_IsClient
then
3861 gWAD
:= g_Res_SearchSameWAD(MapsDir
, ExtractFileName(NewWAD
), WHash
);
3864 g_Game_SetLoadingText(_lc
[I_LOAD_DL_RES
], 0, False);
3865 gWAD
:= g_Res_DownloadWAD(ExtractFileName(NewWAD
));
3869 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_WAD
], [ExtractFileName(NewWAD
)]));
3873 NewWAD
:= ExtractRelativePath(MapsDir
, gWAD
);
3874 g_Game_LoadWAD(NewWAD
);
3877 procedure g_Game_RestartRound(NoMapRestart
: Boolean = False);
3879 i
, n
, nb
, nr
: Integer;
3881 if not g_Game_IsServer
then Exit
;
3882 if gLMSRespawn
= LMS_RESPAWN_NONE
then Exit
;
3883 gLMSRespawn
:= LMS_RESPAWN_NONE
;
3884 gLMSRespawnTime
:= 0;
3887 if (gGameSettings
.GameMode
= GM_COOP
) and not NoMapRestart
then
3889 gMissionFailed
:= True;
3890 g_Game_RestartLevel
;
3894 n
:= 0; nb
:= 0; nr
:= 0;
3895 for i
:= Low(gPlayers
) to High(gPlayers
) do
3896 if (gPlayers
[i
] <> nil) and
3897 ((not gPlayers
[i
].FSpectator
) or gPlayers
[i
].FWantsInGame
or
3898 (gPlayers
[i
] is TBot
)) then
3901 if gPlayers
[i
].Team
= TEAM_RED
then Inc(nr
)
3902 else if gPlayers
[i
].Team
= TEAM_BLUE
then Inc(nb
)
3905 if (n
< 2) or ((gGameSettings
.GameMode
= GM_TDM
) and ((nr
= 0) or (nb
= 0))) then
3907 // wait a second until the fuckers finally decide to join
3908 gLMSRespawn
:= LMS_RESPAWN_WARMUP
;
3909 gLMSRespawnTime
:= gTime
+ 1000;
3910 gLMSSoftSpawn
:= NoMapRestart
;
3914 g_Player_RemoveAllCorpses
;
3915 g_Game_Message(_lc
[I_MESSAGE_LMS_START
], 144);
3916 if g_Game_IsNet
then
3917 MH_SEND_GameEvent(NET_EV_LMS_START
);
3919 for i
:= Low(gPlayers
) to High(gPlayers
) do
3921 if gPlayers
[i
] = nil then continue
;
3922 if gPlayers
[i
] is TBot
then gPlayers
[i
].FWantsInGame
:= True;
3923 // don't touch normal spectators
3924 if gPlayers
[i
].FSpectator
and not gPlayers
[i
].FWantsInGame
then
3926 gPlayers
[i
].FNoRespawn
:= True;
3927 gPlayers
[i
].Lives
:= 0;
3928 if g_Game_IsNet
then
3929 MH_SEND_PlayerStats(gPlayers
[I
].UID
);
3932 gPlayers
[i
].FNoRespawn
:= False;
3933 gPlayers
[i
].Lives
:= gGameSettings
.MaxLives
;
3934 gPlayers
[i
].Respawn(False, True);
3935 if gGameSettings
.GameMode
= GM_COOP
then
3937 gPlayers
[i
].Frags
:= 0;
3938 gPlayers
[i
].RecallState
;
3940 if (gPlayer1
= nil) and (gLMSPID1
> 0) then
3941 gPlayer1
:= g_Player_Get(gLMSPID1
);
3942 if (gPlayer2
= nil) and (gLMSPID2
> 0) then
3943 gPlayer2
:= g_Player_Get(gLMSPID2
);
3946 for i
:= Low(gItems
) to High(gItems
) do
3948 if gItems
[i
].Respawnable
then
3950 gItems
[i
].QuietRespawn
:= True;
3951 gItems
[i
].RespawnTime
:= 0;
3956 if g_Game_IsNet
then MH_SEND_ItemDestroy(True, i
);
3960 for i
:= Low(gMonsters
) to High(gMonsters
) do
3962 if (gMonsters
[i
] <> nil) and not gMonsters
[i
].FNoRespawn
then
3963 gMonsters
[i
].Respawn
;
3966 gLMSSoftSpawn
:= False;
3969 function g_Game_GetFirstMap(WAD
: String): String;
3973 MapList
:= g_Map_GetMapsList(WAD
);
3974 if MapList
= nil then
3977 SortSArray(MapList
);
3978 Result
:= MapList
[Low(MapList
)];
3980 if not g_Map_Exist(WAD
+ ':\' + Result
) then
3986 function g_Game_GetNextMap(): String;
3993 MapList
:= g_Map_GetMapsList(MapsDir
+ gGameSettings
.WAD
);
3994 if MapList
= nil then
3997 g_ProcessResourceStr(gMapInfo
.Map
, nil, nil, @Map
);
3999 SortSArray(MapList
);
4001 for I
:= Low(MapList
) to High(MapList
) do
4002 if Map
= MapList
[I
] then
4008 if MapIndex
<> -255 then
4010 if MapIndex
= High(MapList
) then
4011 Result
:= MapList
[Low(MapList
)]
4013 Result
:= MapList
[MapIndex
+ 1];
4015 if not g_Map_Exist(MapsDir
+ gGameSettings
.WAD
+ ':\' + Result
) then Result
:= Map
;
4021 procedure g_Game_NextLevel();
4023 if gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
, GM_COOP
] then
4024 gExit
:= EXIT_ENDLEVELCUSTOM
4027 gExit
:= EXIT_ENDLEVELSINGLE
;
4031 if gNextMap
<> '' then Exit
;
4032 gNextMap
:= g_Game_GetNextMap();
4035 function g_Game_IsTestMap(): Boolean;
4037 FName
, Sect
, Res
: String;
4039 g_ProcessResourceStr(gMapInfo
.Map
, FName
, Sect
, Res
);
4040 Result
:= UpperCase(Res
) = TEST_MAP_NAME
;
4043 procedure g_Game_DeleteTestMap();
4051 a
:= Pos('.wad:\', gMapToDelete
);
4055 // Âûäåëÿåì èìÿ wad-ôàéëà è èìÿ êàðòû:
4056 WadName
:= Copy(gMapToDelete
, 1, a
+ 3);
4057 Delete(gMapToDelete
, 1, a
+ 5);
4058 gMapToDelete
:= UpperCase(gMapToDelete
);
4060 CopyMemory(@MapName
[0], @gMapToDelete
[1], Min(16, Length(gMapToDelete
)));
4062 // Èìÿ êàðòû íå ñòàíäàðòíîå òåñòîâîå:
4063 if MapName
<> TEST_MAP_NAME
then
4066 if not gTempDelete
then
4068 time
:= g_GetFileTime(WadName
);
4069 WAD
:= TWADEditor_1
.Create();
4072 if not WAD
.ReadFile(WadName
) then
4073 begin // Íåò òàêîãî WAD-ôàéëà
4078 // Ñîñòàâëÿåì ñïèñîê êàðò è èùåì íóæíóþ:
4080 MapList
:= WAD
.GetResourcesList('');
4082 if MapList
<> nil then
4083 for a
:= 0 to High(MapList
) do
4084 if MapList
[a
] = MapName
then
4086 // Óäàëÿåì è ñîõðàíÿåì:
4087 WAD
.RemoveResource('', MapName
);
4088 WAD
.SaveTo(WadName
);
4093 g_SetFileTime(WadName
, time
);
4095 DeleteFile(WadName
);
4098 procedure GameCVars(P
: SArray
);
4101 stat
: TPlayerStatArray
;
4106 cmd
:= LowerCase(P
[0]);
4107 if cmd
= 'r_showfps' then
4109 if (Length(P
) > 1) and
4110 ((P
[1] = '1') or (P
[1] = '0')) then
4111 gShowFPS
:= (P
[1][1] = '1');
4114 g_Console_Add(_lc
[I_MSG_SHOW_FPS_ON
])
4116 g_Console_Add(_lc
[I_MSG_SHOW_FPS_OFF
]);
4118 else if (cmd
= 'g_friendlyfire') and not g_Game_IsClient
then
4120 with gGameSettings
do
4122 if (Length(P
) > 1) and
4123 ((P
[1] = '1') or (P
[1] = '0')) then
4125 if (P
[1][1] = '1') then
4126 Options
:= Options
or GAME_OPTION_TEAMDAMAGE
4128 Options
:= Options
and (not GAME_OPTION_TEAMDAMAGE
);
4131 if (LongBool(Options
and GAME_OPTION_TEAMDAMAGE
)) then
4132 g_Console_Add(_lc
[I_MSG_FRIENDLY_FIRE_ON
])
4134 g_Console_Add(_lc
[I_MSG_FRIENDLY_FIRE_OFF
]);
4136 if g_Game_IsNet
then MH_SEND_GameSettings
;
4139 else if (cmd
= 'g_weaponstay') and not g_Game_IsClient
then
4141 with gGameSettings
do
4143 if (Length(P
) > 1) and
4144 ((P
[1] = '1') or (P
[1] = '0')) then
4146 if (P
[1][1] = '1') then
4147 Options
:= Options
or GAME_OPTION_WEAPONSTAY
4149 Options
:= Options
and (not GAME_OPTION_WEAPONSTAY
);
4152 if (LongBool(Options
and GAME_OPTION_WEAPONSTAY
)) then
4153 g_Console_Add(_lc
[I_MSG_WEAPONSTAY_ON
])
4155 g_Console_Add(_lc
[I_MSG_WEAPONSTAY_OFF
]);
4157 if g_Game_IsNet
then MH_SEND_GameSettings
;
4160 else if cmd
= 'g_gamemode' then
4162 a
:= g_Game_TextToMode(P
[1]);
4163 if a
= GM_SINGLE
then a
:= GM_COOP
;
4164 if (Length(P
) > 1) and (a
<> GM_NONE
) and (not g_Game_IsClient
) then
4166 gSwitchGameMode
:= a
;
4167 if (gGameOn
and (gGameSettings
.GameMode
= GM_SINGLE
)) or
4168 (gState
= STATE_INTERSINGLE
) then
4169 gSwitchGameMode
:= GM_SINGLE
;
4171 gGameSettings
.GameMode
:= gSwitchGameMode
;
4173 if gSwitchGameMode
= gGameSettings
.GameMode
then
4174 g_Console_Add(Format(_lc
[I_MSG_GAMEMODE_CURRENT
],
4175 [g_Game_ModeToText(gGameSettings
.GameMode
)]))
4177 g_Console_Add(Format(_lc
[I_MSG_GAMEMODE_CHANGE
],
4178 [g_Game_ModeToText(gGameSettings
.GameMode
),
4179 g_Game_ModeToText(gSwitchGameMode
)]));
4181 else if (cmd
= 'g_allow_exit') and not g_Game_IsClient
then
4183 with gGameSettings
do
4185 if (Length(P
) > 1) and
4186 ((P
[1] = '1') or (P
[1] = '0')) then
4188 if (P
[1][1] = '1') then
4189 Options
:= Options
or GAME_OPTION_ALLOWEXIT
4191 Options
:= Options
and (not GAME_OPTION_ALLOWEXIT
);
4194 if (LongBool(Options
and GAME_OPTION_ALLOWEXIT
)) then
4195 g_Console_Add(_lc
[I_MSG_ALLOWEXIT_ON
])
4197 g_Console_Add(_lc
[I_MSG_ALLOWEXIT_OFF
]);
4198 g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
4200 if g_Game_IsNet
then MH_SEND_GameSettings
;
4203 else if (cmd
= 'g_allow_monsters') and not g_Game_IsClient
then
4205 with gGameSettings
do
4207 if (Length(P
) > 1) and
4208 ((P
[1] = '1') or (P
[1] = '0')) then
4210 if (P
[1][1] = '1') then
4211 Options
:= Options
or GAME_OPTION_MONSTERS
4213 Options
:= Options
and (not GAME_OPTION_MONSTERS
);
4216 if (LongBool(Options
and GAME_OPTION_MONSTERS
)) then
4217 g_Console_Add(_lc
[I_MSG_ALLOWMON_ON
])
4219 g_Console_Add(_lc
[I_MSG_ALLOWMON_OFF
]);
4220 g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
4222 if g_Game_IsNet
then MH_SEND_GameSettings
;
4225 else if (cmd
= 'g_bot_vsplayers') and not g_Game_IsClient
then
4227 with gGameSettings
do
4229 if (Length(P
) > 1) and
4230 ((P
[1] = '1') or (P
[1] = '0')) then
4232 if (P
[1][1] = '1') then
4233 Options
:= Options
or GAME_OPTION_BOTVSPLAYER
4235 Options
:= Options
and (not GAME_OPTION_BOTVSPLAYER
);
4238 if (LongBool(Options
and GAME_OPTION_BOTVSPLAYER
)) then
4239 g_Console_Add(_lc
[I_MSG_BOTSVSPLAYERS_ON
])
4241 g_Console_Add(_lc
[I_MSG_BOTSVSPLAYERS_OFF
]);
4243 if g_Game_IsNet
then MH_SEND_GameSettings
;
4246 else if (cmd
= 'g_bot_vsmonsters') and not g_Game_IsClient
then
4248 with gGameSettings
do
4250 if (Length(P
) > 1) and
4251 ((P
[1] = '1') or (P
[1] = '0')) then
4253 if (P
[1][1] = '1') then
4254 Options
:= Options
or GAME_OPTION_BOTVSMONSTER
4256 Options
:= Options
and (not GAME_OPTION_BOTVSMONSTER
);
4259 if (LongBool(Options
and GAME_OPTION_BOTVSMONSTER
)) then
4260 g_Console_Add(_lc
[I_MSG_BOTSVSMONSTERS_ON
])
4262 g_Console_Add(_lc
[I_MSG_BOTSVSMONSTERS_OFF
]);
4264 if g_Game_IsNet
then MH_SEND_GameSettings
;
4267 else if (cmd
= 'g_warmuptime') and not g_Game_IsClient
then
4269 if Length(P
) > 1 then
4271 if StrToIntDef(P
[1], gGameSettings
.WarmupTime
) = 0 then
4272 gGameSettings
.WarmupTime
:= 30
4274 gGameSettings
.WarmupTime
:= StrToIntDef(P
[1], gGameSettings
.WarmupTime
);
4277 g_Console_Add(Format(_lc
[I_MSG_WARMUP
],
4278 [gGameSettings
.WarmupTime
]));
4279 g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
4281 else if cmd
= 'net_interp' then
4283 if (Length(P
) > 1) then
4284 NetInterpLevel
:= StrToIntDef(P
[1], NetInterpLevel
);
4286 g_Console_Add('net_interp = ' + IntToStr(NetInterpLevel
));
4287 config
:= TConfig
.CreateFile(GameDir
+'/'+CONFIG_FILENAME
);
4288 config
.WriteInt('Client', 'InterpolationSteps', NetInterpLevel
);
4289 config
.SaveFile(GameDir
+'/'+CONFIG_FILENAME
);
4292 else if cmd
= 'net_forceplayerupdate' then
4294 if (Length(P
) > 1) and
4295 ((P
[1] = '1') or (P
[1] = '0')) then
4296 NetForcePlayerUpdate
:= (P
[1][1] = '1');
4298 if NetForcePlayerUpdate
then
4299 g_Console_Add('net_forceplayerupdate = 1')
4301 g_Console_Add('net_forceplayerupdate = 0');
4302 config
:= TConfig
.CreateFile(GameDir
+'/'+CONFIG_FILENAME
);
4303 config
.WriteBool('Client', 'ForcePlayerUpdate', NetForcePlayerUpdate
);
4304 config
.SaveFile(GameDir
+'/'+CONFIG_FILENAME
);
4307 else if cmd
= 'net_predictself' then
4309 if (Length(P
) > 1) and
4310 ((P
[1] = '1') or (P
[1] = '0')) then
4311 NetPredictSelf
:= (P
[1][1] = '1');
4313 if NetPredictSelf
then
4314 g_Console_Add('net_predictself = 1')
4316 g_Console_Add('net_predictself = 0');
4317 config
:= TConfig
.CreateFile(GameDir
+'/'+CONFIG_FILENAME
);
4318 config
.WriteBool('Client', 'PredictSelf', NetPredictSelf
);
4319 config
.SaveFile(GameDir
+'/'+CONFIG_FILENAME
);
4322 else if cmd
= 'sv_name' then
4324 if (Length(P
) > 1) and (Length(P
[1]) > 0) then
4326 NetServerName
:= P
[1];
4327 if Length(NetServerName
) > 64 then
4328 SetLength(NetServerName
, 64);
4329 if g_Game_IsServer
and g_Game_IsNet
and NetUseMaster
then
4333 g_Console_Add(cmd
+ ' = "' + NetServerName
+ '"');
4335 else if cmd
= 'sv_passwd' then
4337 if (Length(P
) > 1) and (Length(P
[1]) > 0) then
4339 NetPassword
:= P
[1];
4340 if Length(NetPassword
) > 24 then
4341 SetLength(NetPassword
, 24);
4342 if g_Game_IsServer
and g_Game_IsNet
and NetUseMaster
then
4346 g_Console_Add(cmd
+ ' = "' + AnsiLowerCase(NetPassword
) + '"');
4348 else if cmd
= 'sv_maxplrs' then
4350 if (Length(P
) > 1) then
4352 NetMaxClients
:= Min(Max(StrToIntDef(P
[1], NetMaxClients
), 1), NET_MAXCLIENTS
);
4353 if g_Game_IsServer
and g_Game_IsNet
then
4356 for a
:= 0 to High(NetClients
) do
4357 if NetClients
[a
].Used
then
4360 if b
> NetMaxClients
then
4362 s
:= g_Player_Get(NetClients
[a
].Player
).Name
;
4363 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_FULL
);
4364 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
4365 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
4368 if NetUseMaster
then
4373 g_Console_Add(cmd
+ ' = ' + IntToStr(NetMaxClients
));
4375 else if cmd
= 'sv_public' then
4377 if (Length(P
) > 1) then
4379 NetUseMaster
:= StrToIntDef(P
[1], Byte(NetUseMaster
)) > 0;
4380 if g_Game_IsServer
and g_Game_IsNet
then
4381 if NetUseMaster
then
4383 if NetMPeer
= nil then
4384 if not g_Net_Slist_Connect() then
4385 g_Console_Add(_lc
[I_NET_MSG_ERROR
] + _lc
[I_NET_SLIST_ERROR
]);
4386 g_Net_Slist_Update();
4389 if NetMPeer
<> nil then
4390 g_Net_Slist_Disconnect();
4393 g_Console_Add(cmd
+ ' = ' + IntToStr(Byte(NetUseMaster
)));
4395 else if cmd
= 'sv_intertime' then
4397 if (Length(P
) > 1) then
4398 gDefInterTime
:= Min(Max(StrToIntDef(P
[1], gDefInterTime
), -1), 120);
4400 g_Console_Add(cmd
+ ' = ' + IntToStr(gDefInterTime
));
4402 else if cmd
= 'p1_name' then
4404 if (Length(P
) > 1) and gGameOn
then
4406 if g_Game_IsClient
then
4408 gPlayer1Settings
.Name
:= b_Text_Unformat(P
[1]);
4409 MC_SEND_PlayerSettings
;
4412 if gPlayer1
<> nil then
4414 gPlayer1
.Name
:= b_Text_Unformat(P
[1]);
4415 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer1
.UID
);
4418 gPlayer1Settings
.Name
:= b_Text_Unformat(P
[1]);
4421 else if cmd
= 'p2_name' then
4423 if (Length(P
) > 1) and gGameOn
then
4425 if g_Game_IsClient
then
4427 gPlayer2Settings
.Name
:= b_Text_Unformat(P
[1]);
4428 MC_SEND_PlayerSettings
;
4431 if gPlayer2
<> nil then
4433 gPlayer2
.Name
:= b_Text_Unformat(P
[1]);
4434 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer2
.UID
);
4437 gPlayer2Settings
.Name
:= b_Text_Unformat(P
[1]);
4440 else if cmd
= 'p1_color' then
4442 if Length(P
) > 3 then
4443 if g_Game_IsClient
then
4445 gPlayer1Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
4446 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
4447 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
4448 MC_SEND_PlayerSettings
;
4451 if gPlayer1
<> nil then
4453 gPlayer1
.Model
.SetColor(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
4454 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
4455 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
4456 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer1
.UID
);
4459 gPlayer1Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
4460 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
4461 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
4463 else if (cmd
= 'p2_color') and not g_Game_IsNet
then
4465 if Length(P
) > 3 then
4466 if g_Game_IsClient
then
4468 gPlayer2Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
4469 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
4470 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
4471 MC_SEND_PlayerSettings
;
4474 if gPlayer2
<> nil then
4476 gPlayer2
.Model
.SetColor(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
4477 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
4478 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
4479 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer2
.UID
);
4482 gPlayer2Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
4483 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
4484 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
4486 else if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
4488 if cmd
= 'r_showtime' then
4490 if (Length(P
) > 1) and
4491 ((P
[1] = '1') or (P
[1] = '0')) then
4492 gShowTime
:= (P
[1][1] = '1');
4495 g_Console_Add(_lc
[I_MSG_TIME_ON
])
4497 g_Console_Add(_lc
[I_MSG_TIME_OFF
]);
4499 else if cmd
= 'r_showscore' then
4501 if (Length(P
) > 1) and
4502 ((P
[1] = '1') or (P
[1] = '0')) then
4503 gShowGoals
:= (P
[1][1] = '1');
4506 g_Console_Add(_lc
[I_MSG_SCORE_ON
])
4508 g_Console_Add(_lc
[I_MSG_SCORE_OFF
]);
4510 else if cmd
= 'r_showstat' then
4512 if (Length(P
) > 1) and
4513 ((P
[1] = '1') or (P
[1] = '0')) then
4514 gShowStat
:= (P
[1][1] = '1');
4517 g_Console_Add(_lc
[I_MSG_STATS_ON
])
4519 g_Console_Add(_lc
[I_MSG_STATS_OFF
]);
4521 else if cmd
= 'r_showkillmsg' then
4523 if (Length(P
) > 1) and
4524 ((P
[1] = '1') or (P
[1] = '0')) then
4525 gShowKillMsg
:= (P
[1][1] = '1');
4527 if gShowKillMsg
then
4528 g_Console_Add(_lc
[I_MSG_KILL_MSGS_ON
])
4530 g_Console_Add(_lc
[I_MSG_KILL_MSGS_OFF
]);
4532 else if cmd
= 'r_showlives' then
4534 if (Length(P
) > 1) and
4535 ((P
[1] = '1') or (P
[1] = '0')) then
4536 gShowLives
:= (P
[1][1] = '1');
4539 g_Console_Add(_lc
[I_MSG_LIVES_ON
])
4541 g_Console_Add(_lc
[I_MSG_LIVES_OFF
]);
4543 else if cmd
= 'r_showspect' then
4545 if (Length(P
) > 1) and
4546 ((P
[1] = '1') or (P
[1] = '0')) then
4547 gSpectHUD
:= (P
[1][1] = '1');
4550 g_Console_Add(_lc
[I_MSG_SPECT_HUD_ON
])
4552 g_Console_Add(_lc
[I_MSG_SPECT_HUD_OFF
]);
4554 else if cmd
= 'r_showping' then
4556 if (Length(P
) > 1) and
4557 ((P
[1] = '1') or (P
[1] = '0')) then
4558 gShowPing
:= (P
[1][1] = '1');
4561 g_Console_Add(_lc
[I_MSG_PING_ON
])
4563 g_Console_Add(_lc
[I_MSG_PING_OFF
]);
4565 else if (cmd
= 'g_scorelimit') and not g_Game_IsClient
then
4567 if Length(P
) > 1 then
4569 if StrToIntDef(P
[1], gGameSettings
.GoalLimit
) = 0 then
4570 gGameSettings
.GoalLimit
:= 0
4575 if gGameSettings
.GameMode
= GM_DM
then
4577 stat
:= g_Player_GetStats();
4579 for a
:= 0 to High(stat
) do
4580 if stat
[a
].Frags
> b
then
4584 b
:= Max(gTeamStat
[TEAM_RED
].Goals
, gTeamStat
[TEAM_BLUE
].Goals
);
4586 gGameSettings
.GoalLimit
:= Max(StrToIntDef(P
[1], gGameSettings
.GoalLimit
), b
);
4589 if g_Game_IsNet
then MH_SEND_GameSettings
;
4592 g_Console_Add(Format(_lc
[I_MSG_SCORE_LIMIT
], [gGameSettings
.GoalLimit
]));
4594 else if (cmd
= 'g_timelimit') and not g_Game_IsClient
then
4596 if (Length(P
) > 1) and (StrToIntDef(P
[1], -1) >= 0) then
4597 gGameSettings
.TimeLimit
:= StrToIntDef(P
[1], -1);
4599 g_Console_Add(Format(_lc
[I_MSG_TIME_LIMIT
],
4600 [gGameSettings
.TimeLimit
div 3600,
4601 (gGameSettings
.TimeLimit
div 60) mod 60,
4602 gGameSettings
.TimeLimit
mod 60]));
4603 if g_Game_IsNet
then MH_SEND_GameSettings
;
4605 else if (cmd
= 'g_maxlives') and not g_Game_IsClient
then
4607 if Length(P
) > 1 then
4609 if StrToIntDef(P
[1], gGameSettings
.MaxLives
) = 0 then
4610 gGameSettings
.MaxLives
:= 0
4614 stat
:= g_Player_GetStats();
4616 for a
:= 0 to High(stat
) do
4617 if stat
[a
].Lives
> b
then
4619 gGameSettings
.MaxLives
:=
4620 Max(StrToIntDef(P
[1], gGameSettings
.MaxLives
), b
);
4624 g_Console_Add(Format(_lc
[I_MSG_LIVES
],
4625 [gGameSettings
.MaxLives
]));
4626 if g_Game_IsNet
then MH_SEND_GameSettings
;
4631 procedure DebugCommands(P
: SArray
);
4637 // Êîìàíäû îòëàäî÷íîãî ðåæèìà:
4640 cmd
:= LowerCase(P
[0]);
4641 if cmd
= 'd_window' then
4643 g_Console_Add(Format('gWinPosX = %d, gWinPosY %d', [gWinPosX
, gWinPosY
]));
4644 g_Console_Add(Format('gWinRealPosX = %d, gWinRealPosY %d', [gWinRealPosX
, gWinRealPosY
]));
4645 g_Console_Add(Format('gScreenWidth = %d, gScreenHeight = %d', [gScreenWidth
, gScreenHeight
]));
4646 g_Console_Add(Format('gWinSizeX = %d, gWinSizeY = %d', [gWinSizeX
, gWinSizeY
]));
4647 g_Console_Add(Format('Frame X = %d, Y = %d, Caption Y = %d', [gWinFrameX
, gWinFrameY
, gWinCaption
]));
4649 else if cmd
= 'd_sounds' then
4651 if (Length(P
) > 1) and
4652 ((P
[1] = '1') or (P
[1] = '0')) then
4653 g_Debug_Sounds
:= (P
[1][1] = '1');
4655 g_Console_Add(Format('d_sounds is %d', [Byte(g_Debug_Sounds
)]));
4657 else if cmd
= 'd_frames' then
4659 if (Length(P
) > 1) and
4660 ((P
[1] = '1') or (P
[1] = '0')) then
4661 g_Debug_Frames
:= (P
[1][1] = '1');
4663 g_Console_Add(Format('d_frames is %d', [Byte(g_Debug_Frames
)]));
4665 else if cmd
= 'd_winmsg' then
4667 if (Length(P
) > 1) and
4668 ((P
[1] = '1') or (P
[1] = '0')) then
4669 g_Debug_WinMsgs
:= (P
[1][1] = '1');
4671 g_Console_Add(Format('d_winmsg is %d', [Byte(g_Debug_WinMsgs
)]));
4673 else if (cmd
= 'd_monoff') and not g_Game_IsNet
then
4675 if (Length(P
) > 1) and
4676 ((P
[1] = '1') or (P
[1] = '0')) then
4677 g_Debug_MonsterOff
:= (P
[1][1] = '1');
4679 g_Console_Add(Format('d_monoff is %d', [Byte(g_debug_MonsterOff
)]));
4681 else if (cmd
= 'd_botoff') and not g_Game_IsNet
then
4683 if Length(P
) > 1 then
4685 '0': g_debug_BotAIOff
:= 0;
4686 '1': g_debug_BotAIOff
:= 1;
4687 '2': g_debug_BotAIOff
:= 2;
4688 '3': g_debug_BotAIOff
:= 3;
4691 g_Console_Add(Format('d_botoff is %d', [g_debug_BotAIOff
]));
4693 else if cmd
= 'd_monster' then
4695 if gGameOn
and (gPlayer1
<> nil) and (gPlayer1
.Live
) and (not g_Game_IsNet
) then
4696 if Length(P
) < 2 then
4698 g_Console_Add(cmd
+ ' [ID | Name] [behaviour]');
4699 g_Console_Add('ID | Name');
4700 for b
:= MONSTER_DEMON
to MONSTER_MAN
do
4701 g_Console_Add(Format('%2d | %s', [b
, g_Monsters_GetNameByID(b
)]));
4704 a
:= StrToIntDef(P
[1], 0);
4705 if (a
< MONSTER_DEMON
) or (a
> MONSTER_MAN
) then
4706 a
:= g_Monsters_GetIDByName(P
[1]);
4708 if (a
< MONSTER_DEMON
) or (a
> MONSTER_MAN
) then
4709 g_Console_Add(Format(_lc
[I_MSG_NO_MONSTER
], [P
[1]]))
4712 with gPlayer1
.Obj
do
4713 b
:= g_Monsters_Create(a
,
4714 X
+ Rect
.X
+ (Rect
.Width
div 2),
4715 Y
+ Rect
.Y
+ Rect
.Height
,
4716 gPlayer1
.Direction
, True);
4717 if (Length(P
) > 2) and (b
>= 0) then
4718 gMonsters
[b
].MonsterBehaviour
:= Min(Max(StrToIntDef(P
[2], BH_NORMAL
), BH_NORMAL
), BH_GOOD
);
4722 else if (cmd
= 'd_health') then
4724 if (Length(P
) > 1) and
4725 ((P
[1] = '1') or (P
[1] = '0')) then
4726 g_debug_HealthBar
:= (P
[1][1] = '1');
4728 g_Console_Add(Format('d_health is %d', [Byte(g_debug_HealthBar
)]));
4730 else if (cmd
= 'd_player') then
4732 if (Length(P
) > 1) and
4733 ((P
[1] = '1') or (P
[1] = '0')) then
4734 g_debug_Player
:= (P
[1][1] = '1');
4736 g_Console_Add(Format(cmd
+ ' is %d', [Byte(g_Debug_Player
)]));
4738 else if (cmd
= 'd_joy') then
4741 g_Console_Add(e_JoystickStateToString(a
));
4745 g_Console_Add(_lc
[I_MSG_NOT_DEBUG
]);
4748 procedure GameCommands(P
: SArray
);
4761 cmd
:= LowerCase(P
[0]);
4763 if (cmd
= 'quit') or
4770 else if cmd
= 'pause' then
4772 if (g_ActiveWindow
= nil) then
4773 g_Game_Pause(not gPause
);
4775 else if cmd
= 'endgame' then
4776 gExit
:= EXIT_SIMPLE
4777 else if cmd
= 'restart' then
4779 if gGameOn
or (gState
in [STATE_INTERSINGLE
, STATE_INTERCUSTOM
]) then
4781 if g_Game_IsClient
then
4783 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4788 g_Console_Add(_lc
[I_MSG_NOT_GAME
]);
4790 else if cmd
= 'kick' then
4792 if g_Game_IsServer
then
4794 if Length(P
) < 2 then
4796 g_Console_Add('kick <name>');
4801 g_Console_Add('kick <name>');
4805 if g_Game_IsNet
then
4806 pl
:= g_Net_Client_ByName(P
[1]);
4809 s
:= g_Net_ClientName_ByID(pl
^.ID
);
4810 enet_peer_disconnect(pl
^.Peer
, NET_DISC_KICK
);
4811 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
4812 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
4813 if NetUseMaster
then
4815 end else if gPlayers
<> nil then
4816 for a
:= Low(gPlayers
) to High(gPlayers
) do
4817 if gPlayers
[a
] <> nil then
4818 if Copy(LowerCase(gPlayers
[a
].Name
), 1, Length(P
[1])) = LowerCase(P
[1]) then
4820 // Íå îòêëþ÷àòü îñíîâíûõ èãðîêîâ â ñèíãëå
4821 if not(gPlayers
[a
] is TBot
) and (gGameSettings
.GameType
= GT_SINGLE
) then
4823 gPlayers
[a
].Lives
:= 0;
4824 gPlayers
[a
].Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
4825 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [gPlayers
[a
].Name
]), True);
4826 g_Player_Remove(gPlayers
[a
].UID
);
4827 if NetUseMaster
then
4829 // Åñëè íå ïåðåìåøàòü, ïðè äîáàâëåíèè íîâûõ áîòîâ ïîÿâÿòñÿ ñòàðûå
4833 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
4835 else if cmd
= 'kick_id' then
4837 if g_Game_IsServer
and g_Game_IsNet
then
4839 if Length(P
) < 2 then
4841 g_Console_Add('kick_id <client ID>');
4846 g_Console_Add('kick_id <client ID>');
4850 a
:= StrToIntDef(P
[1], 0);
4851 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
4853 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
4855 s
:= g_Net_ClientName_ByID(NetClients
[a
].ID
);
4856 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_KICK
);
4857 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
4858 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
4859 if NetUseMaster
then
4864 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4866 else if cmd
= 'ban' then
4868 if g_Game_IsServer
and g_Game_IsNet
then
4870 if Length(P
) < 2 then
4872 g_Console_Add('ban <name>');
4877 g_Console_Add('ban <name>');
4881 pl
:= g_Net_Client_ByName(P
[1]);
4884 s
:= g_Net_ClientName_ByID(pl
^.ID
);
4885 g_Net_BanHost(pl
^.Peer
^.address
.host
, False);
4886 enet_peer_disconnect(pl
^.Peer
, NET_DISC_TEMPBAN
);
4887 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
4888 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
4889 if NetUseMaster
then
4892 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
4894 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4896 else if cmd
= 'ban_id' then
4898 if g_Game_IsServer
and g_Game_IsNet
then
4900 if Length(P
) < 2 then
4902 g_Console_Add('ban_id <client ID>');
4907 g_Console_Add('ban_id <client ID>');
4911 a
:= StrToIntDef(P
[1], 0);
4912 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
4913 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
4915 s
:= g_Net_ClientName_ByID(NetClients
[a
].ID
);
4916 g_Net_BanHost(NetClients
[a
].Peer
^.address
.host
, False);
4917 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_TEMPBAN
);
4918 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
4919 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
4920 if NetUseMaster
then
4924 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4926 else if cmd
= 'permban' then
4928 if g_Game_IsServer
and g_Game_IsNet
then
4930 if Length(P
) < 2 then
4932 g_Console_Add('permban <name>');
4937 g_Console_Add('permban <name>');
4941 pl
:= g_Net_Client_ByName(P
[1]);
4944 s
:= g_Net_ClientName_ByID(pl
^.ID
);
4945 g_Net_BanHost(pl
^.Peer
^.address
.host
);
4946 enet_peer_disconnect(pl
^.Peer
, NET_DISC_BAN
);
4947 g_Net_SaveBanList();
4948 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
4949 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
4950 if NetUseMaster
then
4953 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
4955 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4957 else if cmd
= 'permban_id' then
4959 if g_Game_IsServer
and g_Game_IsNet
then
4961 if Length(P
) < 2 then
4963 g_Console_Add('permban_id <client ID>');
4968 g_Console_Add('permban_id <client ID>');
4972 a
:= StrToIntDef(P
[1], 0);
4973 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
4974 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
4976 s
:= g_Net_ClientName_ByID(NetClients
[a
].ID
);
4977 g_Net_BanHost(NetClients
[a
].Peer
^.address
.host
);
4978 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_BAN
);
4979 g_Net_SaveBanList();
4980 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
4981 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
4982 if NetUseMaster
then
4986 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4988 else if cmd
= 'unban' then
4990 if g_Game_IsServer
and g_Game_IsNet
then
4992 if Length(P
) < 2 then
4994 g_Console_Add('unban <IP Address>');
4999 g_Console_Add('unban <IP Address>');
5003 if g_Net_UnbanHost(P
[1]) then
5005 g_Console_Add(Format(_lc
[I_MSG_UNBAN_OK
], [P
[1]]));
5006 g_Net_SaveBanList();
5008 g_Console_Add(Format(_lc
[I_MSG_UNBAN_FAIL
], [P
[1]]));
5010 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
5012 else if cmd
= 'clientlist' then
5014 if g_Game_IsServer
and g_Game_IsNet
then
5017 if NetClients
<> nil then
5018 for a
:= Low(NetClients
) to High(NetClients
) do
5019 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
5021 plr
:= g_Player_Get(NetClients
[a
].Player
);
5022 if plr
= nil then continue
;
5024 g_Console_Add(Format('#%2d: %-15s | %s', [a
,
5025 IpToStr(NetClients
[a
].Peer
^.address
.host
), plr
.Name
]));
5028 g_Console_Add(_lc
[I_MSG_NOCLIENTS
]);
5030 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
5032 else if cmd
= 'connect' then
5034 if (NetMode
= NET_NONE
) then
5036 if Length(P
) < 2 then
5038 g_Console_Add('connect <IP> [port] [password]');
5043 g_Console_Add('connect <IP> [port] [password]');
5047 if Length(P
) > 2 then
5048 prt
:= StrToIntDef(P
[2], 25666)
5052 if Length(P
) > 3 then
5057 g_Game_StartClient(P
[1], prt
, pw
);
5060 else if cmd
= 'disconnect' then
5062 if (NetMode
= NET_CLIENT
) then
5065 else if cmd
= 'reconnect' then
5067 if (NetMode
= NET_SERVER
) then
5070 if (NetMode
= NET_CLIENT
) then
5073 gExit
:= EXIT_SIMPLE
;
5077 //TODO: Use last successful password to reconnect, instead of ''
5078 g_Game_StartClient(NetClientIP
, NetClientPort
, '');
5080 else if (cmd
= 'addbot') or
5081 (cmd
= 'bot_add') then
5083 if Length(P
) > 1 then
5084 g_Bot_Add(TEAM_NONE
, StrToIntDef(P
[1], 2))
5086 g_Bot_Add(TEAM_NONE
, 2);
5088 else if cmd
= 'bot_addlist' then
5090 if Length(P
) > 1 then
5091 if Length(P
) = 2 then
5092 g_Bot_AddList(TEAM_NONE
, P
[1], StrToIntDef(P
[1], -1))
5094 g_Bot_AddList(IfThen(P
[2] = 'red', TEAM_RED
, TEAM_BLUE
), P
[1], StrToIntDef(P
[1], -1));
5096 else if cmd
= 'bot_removeall' then
5098 else if cmd
= 'chat' then
5100 if g_Game_IsNet
then
5102 if Length(P
) > 1 then
5104 for a
:= 1 to High(P
) do
5105 chstr
:= chstr
+ P
[a
] + ' ';
5107 if Length(chstr
) > 200 then SetLength(chstr
, 200);
5109 if Length(chstr
) < 1 then
5111 g_Console_Add('chat <text>');
5115 chstr
:= b_Text_Format(chstr
);
5116 if g_Game_IsClient
then
5117 MC_SEND_Chat(chstr
, NET_CHAT_PLAYER
)
5119 MH_SEND_Chat(gPlayer1Settings
.Name
+ ': ' + chstr
, NET_CHAT_PLAYER
);
5122 g_Console_Add('chat <text>');
5124 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
5126 else if cmd
= 'teamchat' then
5128 if g_Game_IsNet
and (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
5130 if Length(P
) > 1 then
5132 for a
:= 1 to High(P
) do
5133 chstr
:= chstr
+ P
[a
] + ' ';
5135 if Length(chstr
) > 200 then SetLength(chstr
, 200);
5137 if Length(chstr
) < 1 then
5139 g_Console_Add('teamchat <text>');
5143 chstr
:= b_Text_Format(chstr
);
5144 if g_Game_IsClient
then
5145 MC_SEND_Chat(chstr
, NET_CHAT_TEAM
)
5147 MH_SEND_Chat(gPlayer1Settings
.Name
+ ': ' + chstr
, NET_CHAT_TEAM
,
5148 gPlayer1Settings
.Team
);
5151 g_Console_Add('teamchat <text>');
5153 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
5155 else if cmd
= 'game' then
5157 if gGameSettings
.GameType
<> GT_NONE
then
5159 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
5162 if Length(P
) = 1 then
5164 g_Console_Add(cmd
+ ' <WAD> [MAP] [# players]');
5167 // Èãðà åù¸ íå çàïóùåíà, ñíà÷àëà íàì íàäî çàãðóçèòü êàêîé-òî WAD
5168 if Pos('.wad', LowerCase(P
[1])) = 0 then
5169 P
[1] := P
[1] + '.wad';
5171 if FileExists(MapsDir
+ P
[1]) then
5173 // Åñëè êàðòà íå óêàçàíà, áåð¸ì ïåðâóþ êàðòó â ôàéëå
5174 if Length(P
) < 3 then
5177 P
[2] := g_Game_GetFirstMap(MapsDir
+ P
[1]);
5180 s
:= P
[1] + ':\' + UpperCase(P
[2]);
5182 if g_Map_Exist(MapsDir
+ s
) then
5184 // Çàïóñêàåì ñâîþ èãðó
5186 with gGameSettings
do
5188 GameMode
:= g_Game_TextToMode(gcGameMode
);
5189 if gSwitchGameMode
<> GM_NONE
then
5190 GameMode
:= gSwitchGameMode
;
5191 if GameMode
= GM_NONE
then GameMode
:= GM_DM
;
5192 if GameMode
= GM_SINGLE
then GameMode
:= GM_COOP
;
5194 if Length(P
) >= 4 then
5195 b
:= StrToIntDef(P
[3], 1);
5196 g_Game_StartCustom(s
, GameMode
, TimeLimit
,
5197 GoalLimit
, MaxLives
, Options
, b
);
5202 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
5204 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [UpperCase(P
[2])]));
5206 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]));
5208 else if cmd
= 'host' then
5210 if gGameSettings
.GameType
<> GT_NONE
then
5212 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
5215 if Length(P
) < 4 then
5217 g_Console_Add(cmd
+ ' <listen IP> <port> <WAD> [MAP] [# players]');
5220 if not StrToIp(P
[1], listen
) then
5222 prt
:= StrToIntDef(P
[2], 25666);
5224 if Pos('.wad', LowerCase(P
[3])) = 0 then
5225 P
[3] := P
[3] + '.wad';
5227 if FileExists(MapsDir
+ P
[3]) then
5229 // Åñëè êàðòà íå óêàçàíà, áåð¸ì ïåðâóþ êàðòó â ôàéëå
5230 if Length(P
) < 5 then
5233 P
[4] := g_Game_GetFirstMap(MapsDir
+ P
[1]);
5236 s
:= P
[3] + ':\' + UpperCase(P
[4]);
5238 if g_Map_Exist(MapsDir
+ s
) then
5240 // Çàïóñêàåì ñâîþ èãðó
5242 with gGameSettings
do
5244 GameMode
:= g_Game_TextToMode(gcGameMode
);
5245 if gSwitchGameMode
<> GM_NONE
then
5246 GameMode
:= gSwitchGameMode
;
5247 if GameMode
= GM_NONE
then GameMode
:= GM_DM
;
5248 if GameMode
= GM_SINGLE
then GameMode
:= GM_COOP
;
5250 if Length(P
) >= 6 then
5251 b
:= StrToIntDef(P
[5], 0);
5252 g_Game_StartServer(s
, GameMode
, TimeLimit
,
5253 GoalLimit
, MaxLives
, Options
, b
, listen
, prt
);
5258 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[3]]))
5260 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [UpperCase(P
[4])]));
5262 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[3]]));
5264 else if cmd
= 'map' then
5266 if Length(P
) = 1 then
5268 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
5270 g_Console_Add(cmd
+ ' <MAP>');
5271 g_Console_Add(cmd
+ ' <WAD> [MAP]');
5273 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
5275 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
5277 // Èä¸ò ñâîÿ èãðà èëè ñåðâåð
5278 if Length(P
) < 3 then
5280 // Ïåðâûé ïàðàìåòð - ëèáî êàðòà, ëèáî èìÿ WAD ôàéëà
5281 s
:= UpperCase(P
[1]);
5282 if g_Map_Exist(MapsDir
+ gGameSettings
.WAD
+ ':\' + s
) then
5283 begin // Êàðòà íàøëàñü
5284 gExitByTrigger
:= False;
5286 begin // Èä¸ò èãðà - çàâåðøàåì óðîâåíü
5288 gExit
:= EXIT_ENDLEVELCUSTOM
;
5290 else // Èíòåðìèññèÿ - ñðàçó çàãðóæàåì êàðòó
5291 g_Game_ChangeMap(s
);
5294 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [s
]));
5295 // Òàêîé êàðòû íåò, èùåì WAD ôàéë
5296 if Pos('.wad', LowerCase(P
[1])) = 0 then
5297 P
[1] := P
[1] + '.wad';
5299 if FileExists(MapsDir
+ P
[1]) then
5301 // Ïàðàìåòðà êàðòû íåò, ïîýòîìó ñòàâèì ïåðâóþ èç ôàéëà
5303 P
[2] := g_Game_GetFirstMap(MapsDir
+ P
[1]);
5305 s
:= P
[1] + ':\' + P
[2];
5307 if g_Map_Exist(MapsDir
+ s
) then
5309 gExitByTrigger
:= False;
5311 begin // Èä¸ò èãðà - çàâåðøàåì óðîâåíü
5313 gExit
:= EXIT_ENDLEVELCUSTOM
;
5315 else // Èíòåðìèññèÿ - ñðàçó çàãðóæàåì êàðòó
5316 g_Game_ChangeMap(s
);
5319 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
5321 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]));
5323 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]));
5327 // Óêàçàíî äâà ïàðàìåòðà, çíà÷èò ïåðâûé - WAD ôàéë, à âòîðîé - êàðòà
5328 if Pos('.wad', LowerCase(P
[1])) = 0 then
5329 P
[1] := P
[1] + '.wad';
5331 if FileExists(MapsDir
+ P
[1]) then
5334 P
[2] := UpperCase(P
[2]);
5335 s
:= P
[1] + ':\' + P
[2];
5337 if g_Map_Exist(MapsDir
+ s
) then
5338 begin // Íàøëè êàðòó
5339 gExitByTrigger
:= False;
5341 begin // Èä¸ò èãðà - çàâåðøàåì óðîâåíü
5343 gExit
:= EXIT_ENDLEVELCUSTOM
;
5345 else // Èíòåðìèññèÿ - ñðàçó çàãðóæàåì êàðòó
5346 g_Game_ChangeMap(s
);
5348 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]));
5350 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]));
5353 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
5355 else if cmd
= 'nextmap' then
5357 if not(gGameOn
or (gState
= STATE_INTERCUSTOM
)) then
5358 g_Console_Add(_lc
[I_MSG_NOT_GAME
])
5361 if Length(P
) = 1 then
5363 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
5365 g_Console_Add(cmd
+ ' <MAP>');
5366 g_Console_Add(cmd
+ ' <WAD> [MAP]');
5369 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
5374 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
5376 if Length(P
) < 3 then
5378 // Ïåðâûé ïàðàìåòð - ëèáî êàðòà, ëèáî èìÿ WAD ôàéëà
5379 s
:= UpperCase(P
[1]);
5380 if g_Map_Exist(MapsDir
+ gGameSettings
.WAD
+ ':\' + s
) then
5381 begin // Êàðòà íàøëàñü
5382 gExitByTrigger
:= False;
5387 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [s
]));
5388 // Òàêîé êàðòû íåò, èùåì WAD ôàéë
5389 if Pos('.wad', LowerCase(P
[1])) = 0 then
5390 P
[1] := P
[1] + '.wad';
5392 if FileExists(MapsDir
+ P
[1]) then
5394 // Ïàðàìåòðà êàðòû íåò, ïîýòîìó ñòàâèì ïåðâóþ èç ôàéëà
5396 P
[2] := g_Game_GetFirstMap(MapsDir
+ P
[1]);
5398 s
:= P
[1] + ':\' + P
[2];
5400 if g_Map_Exist(MapsDir
+ s
) then
5401 begin // Óñòàíàâëèâàåì êàðòó
5402 gExitByTrigger
:= False;
5407 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
5409 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]));
5411 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]));
5415 // Óêàçàíî äâà ïàðàìåòðà, çíà÷èò ïåðâûé - WAD ôàéë, à âòîðîé - êàðòà
5416 if Pos('.wad', LowerCase(P
[1])) = 0 then
5417 P
[1] := P
[1] + '.wad';
5419 if FileExists(MapsDir
+ P
[1]) then
5422 P
[2] := UpperCase(P
[2]);
5423 s
:= P
[1] + ':\' + P
[2];
5425 if g_Map_Exist(MapsDir
+ s
) then
5426 begin // Íàøëè êàðòó
5427 gExitByTrigger
:= False;
5431 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]));
5433 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]));
5436 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
5439 if gNextMap
= '' then
5440 g_Console_Add(_lc
[I_MSG_NEXTMAP_UNSET
])
5442 g_Console_Add(Format(_lc
[I_MSG_NEXTMAP_SET
], [gNextMap
]));
5445 else if (cmd
= 'endmap') or (cmd
= 'goodbye') then
5448 g_Console_Add(_lc
[I_MSG_NOT_GAME
])
5450 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
5452 gExitByTrigger
:= False;
5453 // Ñëåäóþùàÿ êàðòà íå çàäàíà, ïðîáóåì íàéòè òðèããåð Âûõîä
5454 if (gNextMap
= '') and (gTriggers
<> nil) then
5455 for a
:= 0 to High(gTriggers
) do
5456 if gTriggers
[a
].TriggerType
= TRIGGER_EXIT
then
5458 gExitByTrigger
:= True;
5459 gNextMap
:= gTriggers
[a
].Data
.MapName
;
5462 // Èùåì ñëåäóþùóþ êàðòó â WAD ôàéëå
5463 if gNextMap
= '' then
5464 gNextMap
:= g_Game_GetNextMap();
5465 // Ïðîâåðÿåì, íå çàäàí ëè WAD ôàéë ðåñóðñíîé ñòðîêîé
5466 if Pos(':\', gNextMap
) = 0 then
5467 s
:= gGameSettings
.WAD
+ ':\' + gNextMap
5470 // Åñëè êàðòà íàéäåíà, âûõîäèì ñ óðîâíÿ
5471 if g_Map_Exist(MapsDir
+ s
) then
5472 gExit
:= EXIT_ENDLEVELCUSTOM
5474 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [gNextMap
]));
5476 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
5478 else if (cmd
= 'event') then
5480 if (Length(P
) <= 1) then
5482 for a
:= 0 to High(gEvents
) do
5483 if gEvents
[a
].Command
= '' then
5484 g_Console_Add(gEvents
[a
].Name
+ ' <none>')
5486 g_Console_Add(gEvents
[a
].Name
+ ' "' + gEvents
[a
].Command
+ '"');
5489 if (Length(P
) = 2) then
5491 for a
:= 0 to High(gEvents
) do
5492 if gEvents
[a
].Name
= P
[1] then
5493 if gEvents
[a
].Command
= '' then
5494 g_Console_Add(gEvents
[a
].Name
+ ' <none>')
5496 g_Console_Add(gEvents
[a
].Name
+ ' "' + gEvents
[a
].Command
+ '"');
5499 for a
:= 0 to High(gEvents
) do
5500 if gEvents
[a
].Name
= P
[1] then
5502 gEvents
[a
].Command
:= '';
5503 for b
:= 2 to High(P
) do
5504 if Pos(' ', P
[b
]) = 0 then
5505 gEvents
[a
].Command
:= gEvents
[a
].Command
+ ' ' + P
[b
]
5507 gEvents
[a
].Command
:= gEvents
[a
].Command
+ ' "' + P
[b
] + '"';
5508 gEvents
[a
].Command
:= Trim(gEvents
[a
].Command
);
5512 // Êîìàíäû Ñâîåé èãðû:
5513 else if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
5515 if cmd
= 'bot_addred' then
5517 if Length(P
) > 1 then
5518 g_Bot_Add(TEAM_RED
, StrToIntDef(P
[1], 2))
5520 g_Bot_Add(TEAM_RED
, 2);
5522 else if cmd
= 'bot_addblue' then
5524 if Length(P
) > 1 then
5525 g_Bot_Add(TEAM_BLUE
, StrToIntDef(P
[1], 2))
5527 g_Bot_Add(TEAM_BLUE
, 2);
5529 else if cmd
= 'suicide' then
5533 if g_Game_IsClient
then
5534 MC_SEND_CheatRequest(NET_CHEAT_SUICIDE
)
5537 if gPlayer1
<> nil then
5538 gPlayer1
.Damage(SUICIDE_DAMAGE
, gPlayer1
.UID
, 0, 0, HIT_SELF
);
5539 if gPlayer2
<> nil then
5540 gPlayer2
.Damage(SUICIDE_DAMAGE
, gPlayer2
.UID
, 0, 0, HIT_SELF
);
5544 else if cmd
= 'spectate' then
5550 else if cmd
= 'say' then
5552 if g_Game_IsServer
and g_Game_IsNet
then
5554 if Length(P
) > 1 then
5557 for a
:= 1 to High(P
) do
5558 chstr
:= chstr
+ P
[a
] + ' ';
5560 if Length(chstr
) > 200 then SetLength(chstr
, 200);
5562 if Length(chstr
) < 1 then
5564 g_Console_Add('say <text>');
5568 chstr
:= b_Text_Format(chstr
);
5569 MH_SEND_Chat(chstr
, NET_CHAT_PLAYER
);
5571 else g_Console_Add('say <text>');
5573 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
5575 else if cmd
= 'tell' then
5577 if g_Game_IsServer
and g_Game_IsNet
then
5579 if (Length(P
) > 2) and (P
[1] <> '') then
5582 for a
:= 2 to High(P
) do
5583 chstr
:= chstr
+ P
[a
] + ' ';
5585 if Length(chstr
) > 200 then SetLength(chstr
, 200);
5587 if Length(chstr
) < 1 then
5589 g_Console_Add('tell <playername> <text>');
5593 pl
:= g_Net_Client_ByName(P
[1]);
5595 MH_SEND_Chat(b_Text_Format(chstr
), NET_CHAT_PLAYER
, pl
^.ID
)
5597 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
5599 else g_Console_Add('tell <playername> <text>');
5601 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
5603 else if (cmd
= 'overtime') and not g_Game_IsClient
then
5605 if (Length(P
) = 1) or (StrToIntDef(P
[1], -1) <= 0) then
5607 // Äîïîëíèòåëüíîå âðåìÿ:
5608 gGameSettings
.TimeLimit
:= (gTime
- gGameStartTime
) div 1000 + Word(StrToIntDef(P
[1], 0));
5610 g_Console_Add(Format(_lc
[I_MSG_TIME_LIMIT
],
5611 [gGameSettings
.TimeLimit
div 3600,
5612 (gGameSettings
.TimeLimit
div 60) mod 60,
5613 gGameSettings
.TimeLimit
mod 60]));
5614 if g_Game_IsNet
then MH_SEND_GameSettings
;
5616 else if (cmd
= 'rcon_password') and g_Game_IsClient
then
5618 if (Length(P
) <= 1) then
5619 g_Console_Add('rcon_password <password>')
5621 MC_SEND_RCONPassword(P
[1]);
5623 else if cmd
= 'rcon' then
5625 if g_Game_IsClient
then
5627 if Length(P
) > 1 then
5630 for a
:= 1 to High(P
) do
5631 chstr
:= chstr
+ P
[a
] + ' ';
5633 if Length(chstr
) > 200 then SetLength(chstr
, 200);
5635 if Length(chstr
) < 1 then
5637 g_Console_Add('rcon <command>');
5641 MC_SEND_RCONCommand(chstr
);
5643 else g_Console_Add('rcon <command>');
5646 else if cmd
= 'ready' then
5648 if g_Game_IsServer
and (gLMSRespawn
= LMS_RESPAWN_WARMUP
) then
5649 gLMSRespawnTime
:= gTime
+ 100;
5651 else if (cmd
= 'callvote') and g_Game_IsNet
then
5653 if Length(P
) > 1 then
5656 for a
:= 1 to High(P
) do begin
5657 if a
> 1 then chstr
:= chstr
+ ' ';
5658 chstr
:= chstr
+ P
[a
];
5661 if Length(chstr
) > 200 then SetLength(chstr
, 200);
5663 if Length(chstr
) < 1 then
5665 g_Console_Add('callvote <command>');
5669 if g_Game_IsClient
then
5670 MC_SEND_Vote(True, chstr
)
5672 g_Game_StartVote(chstr
, gPlayer1Settings
.Name
);
5673 g_Console_Process('vote', True);
5676 g_Console_Add('callvote <command>');
5678 else if (cmd
= 'vote') and g_Game_IsNet
then
5680 if g_Game_IsClient
then
5682 else if gVoteInProgress
then
5684 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
5685 a
:= Floor((NetClientCount
+1)/2.0) + 1
5687 a
:= Floor(NetClientCount
/2.0) + 1;
5692 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_REVOKED
], [gPlayer1Settings
.Name
, gVoteCount
, a
]), True);
5693 MH_SEND_VoteEvent(NET_VE_REVOKE
, gPlayer1Settings
.Name
, 'a', gVoteCount
, a
);
5699 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_VOTE
], [gPlayer1Settings
.Name
, gVoteCount
, a
]), True);
5700 MH_SEND_VoteEvent(NET_VE_VOTE
, gPlayer1Settings
.Name
, 'a', gVoteCount
, a
);
5708 procedure g_TakeScreenShot();
5713 for a
:= 1 to High(Word) do
5715 FileName
:= Format(GameDir
+'/Screenshots/Screenshot%.3d.bmp', [a
]);
5716 if not FileExists(FileName
) then
5718 e_MakeScreenshot(FileName
, gScreenWidth
, gScreenHeight
);
5719 g_Console_Add(Format(_lc
[I_CONSOLE_SCREENSHOT
], [ExtractFileName(FileName
)]));
5725 procedure g_Game_InGameMenu(Show
: Boolean);
5727 if (g_ActiveWindow
= nil) and Show
then
5729 if gGameSettings
.GameType
= GT_SINGLE
then
5730 g_GUI_ShowWindow('GameSingleMenu')
5733 if g_Game_IsClient
then
5734 g_GUI_ShowWindow('GameClientMenu')
5736 if g_Game_IsNet
then
5737 g_GUI_ShowWindow('GameServerMenu')
5739 g_GUI_ShowWindow('GameCustomMenu');
5741 g_Sound_PlayEx('MENU_OPEN');
5743 // Ïàóçà ïðè ìåíþ òîëüêî â îäèíî÷íîé èãðå:
5744 if (not g_Game_IsNet
) then
5748 if (g_ActiveWindow
<> nil) and (not Show
) then
5750 // Ïàóçà ïðè ìåíþ òîëüêî â îäèíî÷íîé èãðå:
5751 if (not g_Game_IsNet
) then
5752 g_Game_Pause(False);
5756 procedure g_Game_Pause(Enable
: Boolean);
5761 if gPause
= Enable
then
5764 if not (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
]) then
5768 g_Game_PauseAllSounds(Enable
);
5771 procedure g_Game_PauseAllSounds(Enable
: Boolean);
5776 if gTriggers
<> nil then
5777 for i
:= 0 to High(gTriggers
) do
5778 with gTriggers
[i
] do
5779 if (TriggerType
= TRIGGER_SOUND
) and
5781 Sound
.IsPlaying() then
5783 Sound
.Pause(Enable
);
5787 if gPlayers
<> nil then
5788 for i
:= 0 to High(gPlayers
) do
5789 if gPlayers
[i
] <> nil then
5790 gPlayers
[i
].PauseSounds(Enable
);
5793 if gMusic
<> nil then
5794 gMusic
.Pause(Enable
);
5797 procedure g_Game_StopAllSounds(all
: Boolean);
5801 if gTriggers
<> nil then
5802 for i
:= 0 to High(gTriggers
) do
5803 with gTriggers
[i
] do
5804 if (TriggerType
= TRIGGER_SOUND
) and
5808 if gMusic
<> nil then
5815 procedure g_Game_UpdateTriggerSounds();
5819 if gTriggers
<> nil then
5820 for i
:= 0 to High(gTriggers
) do
5821 with gTriggers
[i
] do
5822 if (TriggerType
= TRIGGER_SOUND
) and
5825 Sound
.IsPlaying() then
5827 if ((gPlayer1
<> nil) and g_CollidePoint(gPlayer1
.GameX
, gPlayer1
.GameY
, X
, Y
, Width
, Height
)) or
5828 ((gPlayer2
<> nil) and g_CollidePoint(gPlayer2
.GameX
, gPlayer2
.GameY
, X
, Y
, Width
, Height
)) then
5830 Sound
.SetPan(0.5 - Data
.Pan
/255.0);
5831 Sound
.SetVolume(Data
.Volume
/255.0);
5834 Sound
.SetCoords(X
+(Width
div 2), Y
+(Height
div 2), Data
.Volume
/255.0);
5838 function g_Game_IsWatchedPlayer(UID
: Word): Boolean;
5841 if (gPlayer1
<> nil) and (gPlayer1
.UID
= UID
) then
5846 if (gPlayer2
<> nil) and (gPlayer2
.UID
= UID
) then
5851 if gSpectMode
<> SPECT_PLAYERS
then
5853 if gSpectPID1
= UID
then
5858 if gSpectViewTwo
and (gSpectPID2
= UID
) then
5865 function g_Game_IsWatchedTeam(Team
: Byte): Boolean;
5870 if (gPlayer1
<> nil) and (gPlayer1
.Team
= Team
) then
5875 if (gPlayer2
<> nil) and (gPlayer2
.Team
= Team
) then
5880 if gSpectMode
<> SPECT_PLAYERS
then
5882 Pl
:= g_Player_Get(gSpectPID1
);
5883 if (Pl
<> nil) and (Pl
.Team
= Team
) then
5888 if gSpectViewTwo
then
5890 Pl
:= g_Player_Get(gSpectPID2
);
5891 if (Pl
<> nil) and (Pl
.Team
= Team
) then
5899 procedure g_Game_Message(Msg
: string; Time
: Word);
5901 MessageText
:= b_Text_Format(Msg
);
5902 MessageTime
:= Time
;
5905 procedure g_Game_Announce_GoodShot(SpawnerUID
: Word);
5914 if not g_Game_IsWatchedPlayer(SpawnerUID
) then
5918 if goodsnd
[a
].IsPlaying() then
5921 goodsnd
[Random(4)].Play();
5924 procedure g_Game_Announce_KillCombo(Param
: Integer);
5931 UID
:= Param
and $FFFF;
5936 Pl
:= g_Player_Get(UID
);
5945 g_Console_Add(Format(_lc
[I_PLAYER_KILL_2X
], [Name
]), True);
5949 g_Console_Add(Format(_lc
[I_PLAYER_KILL_3X
], [Name
]), True);
5953 g_Console_Add(Format(_lc
[I_PLAYER_KILL_4X
], [Name
]), True);
5957 g_Console_Add(Format(_lc
[I_PLAYER_KILL_MX
], [Name
]), True);
5965 if not g_Game_IsWatchedPlayer(UID
) then
5968 if (not g_Game_IsWatchedPlayer(UID
)) and (c
< 4) then
5972 if killsnd
[n
].IsPlaying() then
5977 procedure g_Game_StartVote(Command
, Initiator
: string);
5981 if not gVotesEnabled
then Exit
;
5982 if gGameSettings
.GameType
<> GT_SERVER
then Exit
;
5983 if gVoteInProgress
or gVotePassed
then
5985 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_INPROGRESS
], [gVoteCommand
]), True);
5986 MH_SEND_VoteEvent(NET_VE_INPROGRESS
, gVoteCommand
);
5989 gVoteInProgress
:= True;
5990 gVotePassed
:= False;
5991 gVoteTimer
:= gTime
+ gVoteTimeout
* 1000;
5994 gVoteCommand
:= Command
;
5996 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
5997 Need
:= Floor((NetClientCount
+1)/2.0)+1
5999 Need
:= Floor(NetClientCount
/2.0)+1;
6000 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_STARTED
], [Initiator
, Command
, Need
]), True);
6001 MH_SEND_VoteEvent(NET_VE_STARTED
, Initiator
, Command
, Need
);
6004 procedure g_Game_CheckVote
;
6008 if gGameSettings
.GameType
<> GT_SERVER
then Exit
;
6009 if not gVoteInProgress
then Exit
;
6011 if (gTime
>= gVoteTimer
) then
6013 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
6014 Need
:= Floor((NetClientCount
+1)/2.0) + 1
6016 Need
:= Floor(NetClientCount
/2.0) + 1;
6017 if gVoteCount
>= Need
then
6019 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_PASSED
], [gVoteCommand
]), True);
6020 MH_SEND_VoteEvent(NET_VE_PASSED
, gVoteCommand
);
6021 gVotePassed
:= True;
6022 gVoteCmdTimer
:= gTime
+ 5000;
6026 g_Console_Add(_lc
[I_MESSAGE_VOTE_FAILED
], True);
6027 MH_SEND_VoteEvent(NET_VE_FAILED
);
6029 if NetClients
<> nil then
6030 for I
:= Low(NetClients
) to High(NetClients
) do
6031 if NetClients
[i
].Used
then
6032 NetClients
[i
].Voted
:= False;
6033 gVoteInProgress
:= False;
6039 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
6040 Need
:= Floor((NetClientCount
+1)/2.0) + 1
6042 Need
:= Floor(NetClientCount
/2.0) + 1;
6043 if gVoteCount
>= Need
then
6045 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_PASSED
], [gVoteCommand
]), True);
6046 MH_SEND_VoteEvent(NET_VE_PASSED
, gVoteCommand
);
6047 gVoteInProgress
:= False;
6048 gVotePassed
:= True;
6049 gVoteCmdTimer
:= gTime
+ 5000;
6052 if NetClients
<> nil then
6053 for I
:= Low(NetClients
) to High(NetClients
) do
6054 if NetClients
[i
].Used
then
6055 NetClients
[i
].Voted
:= False;
6060 procedure g_Game_LoadMapList(FileName
: string);
6068 if not FileExists(FileName
) then Exit
;
6070 AssignFile(ListFile
, FileName
);
6072 while not EOF(ListFile
) do
6074 ReadLn(ListFile
, s
);
6077 if s
= '' then Continue
;
6079 SetLength(MapList
, Length(MapList
)+1);
6080 MapList
[High(MapList
)] := s
;
6082 CloseFile(ListFile
);
6085 procedure g_Game_SetDebugMode();
6088 // ×èòû (äàæå â ñâîåé èãðå):
6092 procedure g_Game_SetLoadingText(Text: String; Max
: Integer; reWrite
: Boolean);
6096 if Length(LoadingStat
.Msgs
) = 0 then
6102 begin // Ïåðåõîäèì íà ñëåäóþùóþ ñòðîêó èëè ñêðîëëèðóåì:
6103 if NextMsg
= Length(Msgs
) then
6105 for i
:= 0 to High(Msgs
)-1 do
6106 Msgs
[i
] := Msgs
[i
+1];
6114 Msgs
[NextMsg
-1] := Text;
6120 g_ActiveWindow
:= nil;
6125 procedure g_Game_StepLoading();
6131 if (ShowCount
> LOADING_SHOW_STEP
) then
6139 procedure g_Game_ClearLoading();
6148 len
:= ((gScreenHeight
div 3)*2 - 50) div LOADING_INTERLINE
;
6149 if len
< 1 then len
:= 1;
6150 SetLength(Msgs
, len
);
6151 for len
:= Low(Msgs
) to High(Msgs
) do
6157 procedure Parse_Params(var pars
: TParamStrValues
);
6164 while i
<= ParamCount
do
6167 if (s
[1] = '-') and (Length(s
) > 1) then
6169 if (s
[2] = '-') and (Length(s
) > 2) then
6170 begin // Îäèíî÷íûé ïàðàìåòð
6171 SetLength(pars
, Length(pars
) + 1);
6172 with pars
[High(pars
)] do
6174 Name
:= LowerCase(s
);
6179 if (i
< ParamCount
) then
6180 begin // Ïàðàìåòð ñî çíà÷åíèåì
6182 SetLength(pars
, Length(pars
) + 1);
6183 with pars
[High(pars
)] do
6185 Name
:= LowerCase(s
);
6186 Value
:= LowerCase(ParamStr(i
));
6195 function Find_Param_Value(var pars
: TParamStrValues
; aName
: String): String;
6200 for i
:= 0 to High(pars
) do
6201 if pars
[i
].Name
= aName
then
6203 Result
:= pars
[i
].Value
;
6208 procedure g_Game_Process_Params();
6210 pars
: TParamStrValues
;
6213 LimT
, LimS
: Integer;
6224 s
:= Find_Param_Value(pars
, '--debug');
6226 g_Game_SetDebugMode();
6228 // Connect when game loads
6229 ip
:= Find_Param_Value(pars
, '-connect');
6233 s
:= Find_Param_Value(pars
, '-port');
6234 if (s
= '') or not TryStrToInt(s
, Port
) then
6237 s
:= Find_Param_Value(pars
, '-pw');
6239 g_Game_StartClient(ip
, Port
, s
);
6243 // Start map when game loads:
6244 map
:= LowerCase(Find_Param_Value(pars
, '-map'));
6245 if (map
<> '') and (Pos('.wad:\', map
) > 0) then
6248 s
:= Find_Param_Value(pars
, '-gm');
6249 GMode
:= g_Game_TextToMode(s
);
6250 if GMode
= GM_NONE
then GMode
:= GM_DM
;
6251 if GMode
= GM_SINGLE
then GMode
:= GM_COOP
;
6254 s
:= Find_Param_Value(pars
, '-limt');
6255 if (s
= '') or (not TryStrToInt(s
, LimT
)) then
6261 s
:= Find_Param_Value(pars
, '-lims');
6262 if (s
= '') or (not TryStrToInt(s
, LimS
)) then
6268 s
:= Find_Param_Value(pars
, '-lives');
6269 if (s
= '') or (not TryStrToInt(s
, Lives
)) then
6275 s
:= Find_Param_Value(pars
, '-opt');
6277 Opt
:= GAME_OPTION_ALLOWEXIT
or GAME_OPTION_BOTVSPLAYER
or GAME_OPTION_BOTVSMONSTER
6279 Opt
:= StrToIntDef(s
, 0);
6281 Opt
:= GAME_OPTION_ALLOWEXIT
or GAME_OPTION_BOTVSPLAYER
or GAME_OPTION_BOTVSMONSTER
;
6284 s
:= Find_Param_Value(pars
, '--close');
6288 // Delete test map after play:
6289 s
:= Find_Param_Value(pars
, '--testdelete');
6291 gMapToDelete
:= MapsDir
+ map
;
6293 // Delete temporary WAD after play:
6294 s
:= Find_Param_Value(pars
, '--tempdelete');
6297 gMapToDelete
:= MapsDir
+ map
;
6298 gTempDelete
:= True;
6301 // Number of players:
6302 s
:= Find_Param_Value(pars
, '-pl');
6306 n
:= StrToIntDef(s
, 1);
6309 s
:= Find_Param_Value(pars
, '-port');
6310 if (s
= '') or not TryStrToInt(s
, Port
) then
6311 g_Game_StartCustom(map
, GMode
, LimT
, LimS
, Lives
, Opt
, n
)
6313 g_Game_StartServer(map
, GMode
, LimT
, LimS
, Lives
, Opt
, n
, 0, Port
);
6316 // Execute script when game loads:
6317 s
:= Find_Param_Value(pars
, '-exec');
6320 if Pos(':\', s
) = 0 then
6321 s
:= GameDir
+ '/' + s
;
6326 if IOResult
<> 0 then
6328 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], ['Failed to read file: ' + s
]), MSG_WARNING
);
6329 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_READ
], [s
]));
6333 e_WriteLog('Executing script: ' + s
, MSG_NOTIFY
);
6334 g_Console_Add(Format(_lc
[I_CONSOLE_EXEC
], [s
]));
6339 if IOResult
<> 0 then
6341 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], ['Failed to read file: ' + s
]), MSG_WARNING
);
6342 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_READ
], [s
]));
6346 if Pos('#', s
) <> 1 then // script comment
6347 g_Console_Process(s
, True);