diff --git a/src/game/g_game.pas b/src/game/g_game.pas
index 4c2d6ded66bbb5817f54b28f3471330c11b6a2d7..23bf9bdc49cfa87e47d2093907cd62ab78a84abe 100644 (file)
--- a/src/game/g_game.pas
+++ b/src/game/g_game.pas
interface
interface
-uses
- SysUtils, Classes,
- MAPDEF,
- g_base, g_basic, g_player, g_res_downloader,
- g_sound, g_gui, utils, md5, mempool, xprofiler,
- g_touch, g_weapons;
+ uses
+ {$IFNDEF HEADLESS}
+ g_gui, g_touch,
+ {$ENDIF}
+ SysUtils, Classes, MAPDEF,
+ g_base, g_basic, g_player, g_res_downloader,
+ g_sound, utils, md5, mempool, xprofiler,
+ g_weapons
+ ;
type
TGameSettings = record
type
TGameSettings = record
procedure g_Game_NextLevel();
procedure g_Game_Pause(Enable: Boolean);
procedure g_Game_HolmesPause(Enable: Boolean);
procedure g_Game_NextLevel();
procedure g_Game_Pause(Enable: Boolean);
procedure g_Game_HolmesPause(Enable: Boolean);
-procedure g_Game_InGameMenu(Show: Boolean);
+{$IFNDEF HEADLESS}
+ procedure g_Game_InGameMenu(Show: Boolean);
+{$ENDIF}
function g_Game_IsWatchedPlayer(UID: Word): Boolean;
function g_Game_IsWatchedTeam(Team: Byte): Boolean;
procedure g_Game_Message(Msg: String; Time: Word);
function g_Game_IsWatchedPlayer(UID: Word): Boolean;
function g_Game_IsWatchedTeam(Team: Byte): Boolean;
procedure g_Game_Message(Msg: String; Time: Word);
procedure g_Game_Announce_BodyKill(SpawnerUID: Word);
procedure g_Game_StartVote(Command, Initiator: string);
procedure g_Game_CheckVote;
procedure g_Game_Announce_BodyKill(SpawnerUID: Word);
procedure g_Game_StartVote(Command, Initiator: string);
procedure g_Game_CheckVote;
-procedure g_TakeScreenShot(Filename: string = '');
+{$IFNDEF HEADLESS}
+ procedure g_TakeScreenShot(Filename: string = '');
+{$ENDIF}
procedure g_FatalError(Text: String);
procedure g_SimpleError(Text: String);
function g_Game_IsTestMap(): Boolean;
procedure g_FatalError(Text: String);
procedure g_SimpleError(Text: String);
function g_Game_IsTestMap(): Boolean;
procedure SortGameStat(var stat: TPlayerStatArray);
procedure KeyPress (K: Word);
procedure SortGameStat(var stat: TPlayerStatArray);
procedure KeyPress (K: Word);
-procedure CharPress (C: AnsiChar);
+
+{$IFNDEF HEADLESS}
+ procedure CharPress (C: AnsiChar);
+{$ENDIF}
{ procedure SetWinPause(Enable: Boolean); }
{ procedure SetWinPause(Enable: Boolean); }
GM_COOP = 4;
GM_SINGLE = 5;
GM_COOP = 4;
GM_SINGLE = 5;
- MESSAGE_DIKEY = WM_USER + 1;
-
EXIT_QUIT = 1;
EXIT_SIMPLE = 2;
EXIT_RESTART = 3;
EXIT_QUIT = 1;
EXIT_SIMPLE = 2;
EXIT_RESTART = 3;
implementation
uses
implementation
uses
-{$IFDEF ENABLE_HOLMES}
- g_holmes,
-{$ENDIF}
- e_res, g_window, g_menu, r_render, r_gfx,
- e_input, e_log, g_console, r_console, g_items, g_map, g_panel,
+ {$IFDEF ENABLE_HOLMES}
+ g_holmes,
+ {$ENDIF}
+ {$IFNDEF HEADLESS}
+ r_render, g_menu, g_system,
+ {$ENDIF}
+ e_res, g_window,
+ e_input, e_log, g_console, g_items, g_map, g_panel,
g_playermodel, g_gfx, g_options, Math,
g_triggers, g_monsters, e_sound, CONFIG,
g_language, g_net, g_phys,
ENet, e_msg, g_netmsg, g_netmaster,
g_playermodel, g_gfx, g_options, Math,
g_triggers, g_monsters, e_sound, CONFIG,
g_language, g_net, g_phys,
ENet, e_msg, g_netmsg, g_netmaster,
- sfs, wadreader, g_system, r_playermodel;
+ sfs, wadreader;
var
charbuff: packed array [0..15] of AnsiChar = (
var
charbuff: packed array [0..15] of AnsiChar = (
{$ENDIF}
end;
{$ENDIF}
end;
+{$IFNDEF HEADLESS}
procedure CharPress (C: AnsiChar);
var
Msg: g_gui.TMessage;
procedure CharPress (C: AnsiChar);
var
Msg: g_gui.TMessage;
Cheat();
end;
end;
Cheat();
end;
end;
+{$ENDIF}
// ////////////////////////////////////////////////////////////////////////// //
// ////////////////////////////////////////////////////////////////////////// //
MessageText := '';
EndingGameCounter := 0;
MessageText := '';
EndingGameCounter := 0;
+
+{$IFNDEF HEADLESS}
g_ActiveWindow := nil;
g_ActiveWindow := nil;
+{$ENDIF}
gLMSRespawn := LMS_RESPAWN_NONE;
gLMSRespawnTime := 0;
gLMSRespawn := LMS_RESPAWN_NONE;
gLMSRespawnTime := 0;
EXIT_SIMPLE: // Выход через меню или конец теста
begin
g_Game_Free();
EXIT_SIMPLE: // Выход через меню или конец теста
begin
g_Game_Free();
-
if gMapOnce then
if gMapOnce then
- begin // Это был тест
- g_Game_Quit();
- end
+ begin // Это был тест
+ g_Game_Quit();
+ end
else
else
- begin // Выход в главное меню
- gMusic.SetByName('MUSIC_MENU');
- gMusic.Play();
- if gState <> STATE_SLIST then
- begin
- g_GUI_ShowWindow('MainMenu');
- gState := STATE_MENU;
- end else
+ begin // Выход в главное меню
+{$IFDEF HEADLESS}
+ gState := STATE_MENU; // ???
+{$ELSE}
+ gMusic.SetByName('MUSIC_MENU');
+ gMusic.Play();
+ if gState <> STATE_SLIST then
+ begin
+ g_GUI_ShowWindow('MainMenu');
+ gState := STATE_MENU;
+ end else
+ begin
+ // Обновляем список серверов
+ slReturnPressed := True;
+ if g_Net_Slist_Fetch(slCurrent) then
begin
begin
- // Обновляем список серверов
- slReturnPressed := True;
- if g_Net_Slist_Fetch(slCurrent) then
- begin
- if slCurrent = nil then
- slWaitStr := _lc[I_NET_SLIST_NOSERVERS];
- end
- else
- slWaitStr := _lc[I_NET_SLIST_ERROR];
- g_Serverlist_GenerateTable(slCurrent, slTable);
- end;
-
- g_Game_ExecuteEvent('ongameend');
+ if slCurrent = nil then
+ slWaitStr := _lc[I_NET_SLIST_NOSERVERS];
+ end
+ else
+ slWaitStr := _lc[I_NET_SLIST_ERROR];
+ g_Serverlist_GenerateTable(slCurrent, slTable);
end;
end;
+{$ENDIF}
+ g_Game_ExecuteEvent('ongameend');
+ end;
end;
EXIT_RESTART: // Начать уровень сначала
end;
EXIT_RESTART: // Начать уровень сначала
end
end;
end
end;
+{$IFNDEF HEADLESS}
// HACK: add dynlight here
if gwin_k8_enable_light_experiments then
begin
// HACK: add dynlight here
if gwin_k8_enable_light_experiments then
begin
end;
if gwin_has_stencil and g_playerLight then g_AddDynLight(plr.GameX+32, plr.GameY+40, 128, 1, 1, 0, 0.6);
end;
if gwin_has_stencil and g_playerLight then g_AddDynLight(plr.GameX+32, plr.GameY+40, 128, 1, 1, 0, 0.6);
+{$ENDIF}
end;
// HACK: don't have a "key was pressed" function
end;
// HACK: don't have a "key was pressed" function
end;
procedure g_Game_Update();
end;
procedure g_Game_Update();
-var
- Msg: g_gui.TMessage;
- Time: Int64;
- a: Byte;
- w: Word;
- i, b: Integer;
+ var
+ {$IFNDEF HEADLESS}
+ Msg: g_gui.TMessage;
+ w: Word;
+ {$ENDIF}
+ Time: Int64;
+ a: Byte;
+ i, b: Integer;
function sendMonsPos (mon: TMonster): Boolean;
begin
function sendMonsPos (mon: TMonster): Boolean;
begin
// no need to, as we'll do it in event handler
// Обновляем консоль (движение и сообщения):
// no need to, as we'll do it in event handler
// Обновляем консоль (движение и сообщения):
- r_Console_Update;
g_Console_Update();
if (NetMode = NET_NONE) and (g_Game_IsNet) and (gGameOn or (gState in [STATE_FOLD, STATE_INTERCUSTOM])) then
g_Console_Update();
if (NetMode = NET_NONE) and (g_Game_IsNet) and (gGameOn or (gState in [STATE_FOLD, STATE_INTERCUSTOM])) then
e_KeyPressed(JOY2_ATTACK) or e_KeyPressed(JOY3_ATTACK)
)
and (not gJustChatted) and (not gConsoleShow) and (not gChatShow)
e_KeyPressed(JOY2_ATTACK) or e_KeyPressed(JOY3_ATTACK)
)
and (not gJustChatted) and (not gConsoleShow) and (not gChatShow)
+{$IFNDEF HEADLESS}
and (g_ActiveWindow = nil)
and (g_ActiveWindow = nil)
+{$ENDIF}
)
or (g_Game_IsNet and ((gInterTime > gInterEndTime) or ((gInterReadyCount >= NetClientCount) and (NetClientCount > 0))))
)
)
or (g_Game_IsNet and ((gInterTime > gInterEndTime) or ((gInterReadyCount >= NetClientCount) and (NetClientCount > 0))))
)
begin
// Выход в главное меню:
g_Game_Free;
begin
// Выход в главное меню:
g_Game_Free;
+{$IFNDEF HEADLESS}
g_GUI_ShowWindow('MainMenu');
gMusic.SetByName('MUSIC_MENU');
gMusic.Play();
g_GUI_ShowWindow('MainMenu');
gMusic.SetByName('MUSIC_MENU');
gMusic.Play();
+{$ENDIF}
gState := STATE_MENU;
end else
begin
gState := STATE_MENU;
end else
begin
e_KeyPressed(JOY2_ATTACK) or e_KeyPressed(JOY3_ATTACK)
)
and (not gJustChatted) and (not gConsoleShow) and (not gChatShow)
e_KeyPressed(JOY2_ATTACK) or e_KeyPressed(JOY3_ATTACK)
)
and (not gJustChatted) and (not gConsoleShow) and (not gChatShow)
+{$IFNDEF HEADLESS}
and (g_ActiveWindow = nil)
and (g_ActiveWindow = nil)
+{$ENDIF}
)
then
begin
)
then
begin
// Обрабатываем клавиши игроков:
if gPlayer1 <> nil then gPlayer1.ReleaseKeys();
if gPlayer2 <> nil then gPlayer2.ReleaseKeys();
// Обрабатываем клавиши игроков:
if gPlayer1 <> nil then gPlayer1.ReleaseKeys();
if gPlayer2 <> nil then gPlayer2.ReleaseKeys();
+{$IFDEF HEADLESS}
+ if (not gConsoleShow) and (not gChatShow) then
+{$ELSE}
if (not gConsoleShow) and (not gChatShow) and (g_ActiveWindow = nil) then
if (not gConsoleShow) and (not gChatShow) and (g_ActiveWindow = nil) then
+{$ENDIF}
begin
ProcessPlayerControls(gPlayer1, 0, P1MoveButton);
ProcessPlayerControls(gPlayer2, 1, P2MoveButton);
begin
ProcessPlayerControls(gPlayer1, 0, P1MoveButton);
ProcessPlayerControls(gPlayer2, 1, P2MoveButton);
end; // if server
// Наблюдатель
end; // if server
// Наблюдатель
- if (gPlayer1 = nil) and (gPlayer2 = nil) and
- (not gConsoleShow) and (not gChatShow) and (g_ActiveWindow = nil) then
+ if (gPlayer1 = nil) and (gPlayer2 = nil)
+ and (not gConsoleShow) and (not gChatShow)
+{$IFNDEF HEADLESS}
+ and (g_ActiveWindow = nil)
+{$ENDIF}
+ then
begin
if not gSpectKeyPress then
begin
begin
if not gSpectKeyPress then
begin
g_Weapon_Update();
g_Monsters_Update();
g_GFX_Update();
g_Weapon_Update();
g_Monsters_Update();
g_GFX_Update();
- r_GFX_Update;
g_Player_UpdateAll();
g_Player_UpdatePhysicalObjects();
g_Player_UpdateAll();
g_Player_UpdatePhysicalObjects();
end; // if gameOn ...
// Активно окно интерфейса - передаем клавиши ему:
end; // if gameOn ...
// Активно окно интерфейса - передаем клавиши ему:
+{$IFNDEF HEADLESS}
if g_ActiveWindow <> nil then
begin
w := e_GetFirstKeyPressed();
if g_ActiveWindow <> nil then
begin
w := e_GetFirstKeyPressed();
// Нужно сменить разрешение:
if gResolutionChange then
begin
// Нужно сменить разрешение:
if gResolutionChange then
begin
- e_WriteLog('Changing resolution', TMsgType.Notify);
- r_Render_Apply;
+ {$IFNDEF HEADLESS}
+ e_WriteLog('Changing resolution', TMsgType.Notify);
+ r_Render_Apply;
+ {$ENDIF}
gResolutionChange := False;
g_ActiveWindow := nil;
end;
gResolutionChange := False;
g_ActiveWindow := nil;
end;
//e_WriteLog('Read language file', MSG_NOTIFY);
//g_Language_Load(DataDir + gLanguage + '.txt');
g_Language_Set(gLanguage);
//e_WriteLog('Read language file', MSG_NOTIFY);
//g_Language_Load(DataDir + gLanguage + '.txt');
g_Language_Set(gLanguage);
-{$IFNDEF HEADLESS}
g_Menu_Reset();
g_Menu_Reset();
-{$ENDIF}
gLanguageChange := False;
end;
end;
gLanguageChange := False;
end;
end;
begin
KeyPress(IK_F10);
end;
begin
KeyPress(IK_F10);
end;
+{$ENDIF} // NOT HEADLESS
Time := GetTickCount64() {div 1000};
Time := GetTickCount64() {div 1000};
g_Game_DeleteTestMap();
gExit := EXIT_QUIT;
g_Game_DeleteTestMap();
gExit := EXIT_QUIT;
- sys_RequestQuit;
+
+ {$IFNDEF HEADLESS}
+ sys_RequestQuit;
+ {$ENDIF}
end;
procedure g_Game_FreeData();
end;
procedure g_Game_FreeData();
begin
//result := g_Map_Load(gGameSettings.WAD + ':\' + ResName);
result := g_Map_Load(NewWAD+':\'+ResName);
begin
//result := g_Map_Load(gGameSettings.WAD + ':\' + ResName);
result := g_Map_Load(NewWAD+':\'+ResName);
- r_Render_LoadTextures;
+ {$IFNDEF HEADLESS}
+ r_Render_LoadTextures;
+ {$ENDIF}
end;
if Result then
begin
g_Player_ResetAll(Force or gLastMap, gGameSettings.GameType = GT_SINGLE);
gState := STATE_NONE;
end;
if Result then
begin
g_Player_ResetAll(Force or gLastMap, gGameSettings.GameType = GT_SINGLE);
gState := STATE_NONE;
- g_ActiveWindow := nil;
+ {$IFNDEF HEADLESS}
+ g_ActiveWindow := nil;
+ {$ENDIF}
gGameOn := True;
DisableCheats();
gGameOn := True;
DisableCheats();
chstr := '';
if cmd = 'pause' then
begin
chstr := '';
if cmd = 'pause' then
begin
- if (g_ActiveWindow = nil) then
+ {$IFNDEF HEADLESS}
+ if (g_ActiveWindow = nil) then
+ g_Game_Pause(not gPauseMain);
+ {$ELSE}
g_Game_Pause(not gPauseMain);
g_Game_Pause(not gPauseMain);
+ {$ENDIF}
end
else if cmd = 'endgame' then
gExit := EXIT_SIMPLE
end
else if cmd = 'endgame' then
gExit := EXIT_SIMPLE
end
else if cmd = 'screenshot' then
begin
end
else if cmd = 'screenshot' then
begin
- g_TakeScreenShot()
+ {$IFNDEF HEADLESS}
+ g_TakeScreenShot()
+ {$ENDIF}
end
else if cmd = 'weapon' then
begin
end
else if cmd = 'weapon' then
begin
g_Game_Free();
g_Game_Quit();
end;
g_Game_Free();
g_Game_Quit();
end;
+{$IFNDEF HEADLESS}
'r_reset':
'r_reset':
- r_Render_Apply;
+ r_Render_Apply;
+{$ENDIF}
'r_maxfps':
begin
if Length(p) = 2 then
'r_maxfps':
begin
if Length(p) = 2 then
end;
end;
end;
end;
+{$IFNDEF HEADLESS}
procedure g_TakeScreenShot(Filename: string = '');
var t: TDateTime; dir, date, name: String;
begin
procedure g_TakeScreenShot(Filename: string = '');
var t: TDateTime; dir, date, name: String;
begin
else
g_Console_Add(Format(_lc[I_CONSOLE_ERROR_WRITE], [name]));
end;
else
g_Console_Add(Format(_lc[I_CONSOLE_ERROR_WRITE], [name]));
end;
+{$ENDIF}
+{$IFNDEF HEADLESS}
procedure g_Game_InGameMenu(Show: Boolean);
begin
if (g_ActiveWindow = nil) and Show then
procedure g_Game_InGameMenu(Show: Boolean);
begin
if (g_ActiveWindow = nil) and Show then
g_Game_Pause(False);
end;
end;
g_Game_Pause(False);
end;
end;
+{$ENDIF}
procedure g_Game_Pause (Enable: Boolean);
var
procedure g_Game_Pause (Enable: Boolean);
var
PBarWasHere := false;
end;
PBarWasHere := false;
end;
- g_ActiveWindow := nil;
+ {$IFNDEF HEADLESS}
+ g_ActiveWindow := nil;
+ {$ENDIF}
ProcessLoading(true);
end;
ProcessLoading(true);
end;