diff --git a/src/game/g_game.pas b/src/game/g_game.pas
index 664377ccad70d23e9a067e6e8dba179848495e6f..c15aeaae6fa4750e39c3169fe78ad73f98129958 100644 (file)
--- a/src/game/g_game.pas
+++ b/src/game/g_game.pas
-(* Copyright (C) Doom 2D: Forever Developers
+ (* Copyright (C) Doom 2D: Forever Developers
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
interface
interface
-uses
- SysUtils, Classes,
- MAPDEF,
- g_base, g_basic, g_player, r_graphics, g_res_downloader,
- g_sound, g_gui, utils, md5, mempool, xprofiler,
- g_touch, g_weapons;
+ uses
+ {$IFDEF ENABLE_MENU}
+ g_gui,
+ {$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_Update();
procedure g_Game_PreUpdate();
procedure g_Game_Quit();
procedure g_Game_Update();
procedure g_Game_PreUpdate();
procedure g_Game_Quit();
-procedure g_Game_SetupScreenSize();
-procedure g_Game_ChangeResolution(newWidth, newHeight: Word; nowFull, nowMax: Boolean);
function g_Game_ModeToText(Mode: Byte): string;
function g_Game_TextToMode(Mode: string): Byte;
procedure g_Game_ExecuteEvent(Name: String);
function g_Game_ModeToText(Mode: Byte): string;
function g_Game_TextToMode(Mode: string): Byte;
procedure g_Game_ExecuteEvent(Name: String);
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);
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;
function GetActivePlayerID_Next(Skip: Integer = -1): Integer;
procedure SortGameStat(var stat: TPlayerStatArray);
function GetActivePlayerID_Next(Skip: Integer = -1): Integer;
procedure SortGameStat(var stat: TPlayerStatArray);
-procedure KeyPress (K: Word);
-procedure CharPress (C: AnsiChar);
+
+{$IFDEF ENABLE_MENU}
+ procedure g_Game_InGameMenu(Show: Boolean);
+{$ENDIF}
+{$IFNDEF HEADLESS}
+ procedure CharPress (C: AnsiChar);
+{$ENDIF}
+ procedure KeyPress (K: Word);
{ 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;
STATFILE_VERSION = $03;
var
STATFILE_VERSION = $03;
var
- gStdFont: DWORD;
gGameSettings: TGameSettings;
gPlayer1Settings: TPlayerSettings;
gPlayer2Settings: TPlayerSettings;
gGameSettings: TGameSettings;
gPlayer1Settings: TPlayerSettings;
gPlayer2Settings: TPlayerSettings;
StatShotDone: Boolean;
StatFilename: string = ''; // used by stat screenshot to save with the same name as the csv
SingleStat: TEndSingleGameStat;
StatShotDone: Boolean;
StatFilename: string = ''; // used by stat screenshot to save with the same name as the csv
SingleStat: TEndSingleGameStat;
- hasPBarGfx: Boolean;
LoadingStat: TLoadingStat;
MessageText: String;
IsDrawStat: Boolean;
LoadingStat: TLoadingStat;
MessageText: String;
IsDrawStat: Boolean;
g_playerLight: Boolean;
g_dynLights: array of TDynLight = nil;
g_dynLightCount: Integer = 0;
g_playerLight: Boolean;
g_dynLights: array of TDynLight = nil;
g_dynLightCount: Integer = 0;
+ EndPicPath: AnsiString; // full path, used by render
implementation
uses
implementation
uses
-{$IFDEF ENABLE_HOLMES}
- g_holmes,
-{$ENDIF}
- e_res, g_textures, g_window, g_menu,
- e_input, e_log, g_console, r_console, g_items, g_map, g_panel,
+ {$IFDEF ENABLE_HOLMES}
+ g_holmes,
+ {$ENDIF}
+ {$IFDEF ENABLE_MENU}
+ g_menu,
+ {$ENDIF}
+ {$IFNDEF HEADLESS}
+ r_render, 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 = (
end;
end;
+{$IFDEF ENABLE_MENU}
procedure KeyPress (K: Word);
procedure KeyPress (K: Word);
-{$IFNDEF HEADLESS}
-var
- Msg: g_gui.TMessage;
-{$ENDIF}
+ var Msg: g_gui.TMessage;
begin
begin
-{$IFNDEF HEADLESS}
case K of
VK_ESCAPE: // <Esc>:
begin
case K of
VK_ESCAPE: // <Esc>:
begin
end;
end;
end;
end;
end;
end;
-{$ENDIF}
end;
end;
-
-procedure CharPress (C: AnsiChar);
-var
- Msg: g_gui.TMessage;
- a: Integer;
-begin
- if gConsoleShow or gChatShow then
- begin
- g_Console_Char(C)
- end
- else if (g_ActiveWindow <> nil) then
+{$ELSE}
+ procedure KeyPress (K: Word);
begin
begin
- Msg.Msg := WM_CHAR;
- Msg.WParam := Ord(C);
- g_ActiveWindow.OnMessage(Msg);
- end
- else
+ gJustChatted := False;
+ if gConsoleShow or gChatShow then
+ begin
+ g_Console_Control(K);
+ end
+ end;
+{$ENDIF}
+
+{$IFNDEF HEADLESS}
+ procedure CharPress (C: AnsiChar);
+ {$IFDEF ENABLE_MENU}
+ var Msg: g_gui.TMessage;
+ {$ENDIF}
+ var a: Integer;
begin
begin
- for a := 0 to 14 do charbuff[a] := charbuff[a+1];
- charbuff[15] := upcase1251(C);
- Cheat();
+ if gConsoleShow or gChatShow then
+ begin
+ g_Console_Char(C);
+ end
+ {$IFDEF ENABLE_MENU}
+ else if g_ActiveWindow <> nil then
+ begin
+ Msg.Msg := WM_CHAR;
+ Msg.WParam := Ord(C);
+ g_ActiveWindow.OnMessage(Msg);
+ end
+ {$ENDIF}
+ else
+ begin
+ for a := 0 to 14 do
+ begin
+ charbuff[a] := charbuff[a + 1];
+ end;
+ charbuff[15] := upcase1251(C);
+ Cheat;
+ end;
end;
end;
-end;
+{$ENDIF}
// ////////////////////////////////////////////////////////////////////////// //
// ////////////////////////////////////////////////////////////////////////// //
UPSTime: LongWord;
DataLoaded: Boolean = False;
MessageTime: Word;
UPSTime: LongWord;
DataLoaded: Boolean = False;
MessageTime: Word;
- MessageLineLength: Integer = 80;
MapList: SSArray = nil;
MapIndex: Integer = -1;
InterReadyTime: Integer = -1;
MapList: SSArray = nil;
MapIndex: Integer = -1;
InterReadyTime: Integer = -1;
info: TMegaWADInfo;
endpic: String;
endmus: String;
info: TMegaWADInfo;
endpic: String;
endmus: String;
- res: record
- text: Array of ShortString;
- anim: Array of ShortString;
- pic: Array of ShortString;
- mus: Array of ShortString;
- end;
- triggers: Array of record
- event: ShortString;
- actions: Array of record
- action, p1, p2: Integer;
- end;
- end;
- cur_trigger: Integer;
- cur_action: Integer;
end;
end;
- //InterPic: String;
InterText: record
lines: SSArray;
img: String;
InterText: record
lines: SSArray;
img: String;
FreeMem(p);
end;
FreeMem(p);
end;
-procedure g_Game_FreeWAD();
-var
- a: Integer;
-begin
- for a := 0 to High(MegaWAD.res.pic) do
- if MegaWAD.res.pic[a] <> '' then
- g_Texture_Delete(MegaWAD.res.pic[a]);
-
- for a := 0 to High(MegaWAD.res.mus) do
- if MegaWAD.res.mus[a] <> '' then
- g_Sound_Delete(MegaWAD.res.mus[a]);
-
- MegaWAD.res.pic := nil;
- MegaWAD.res.text := nil;
- MegaWAD.res.anim := nil;
- MegaWAD.res.mus := nil;
- MegaWAD.triggers := nil;
-
- g_Texture_Delete('TEXTURE_endpic');
- g_Sound_Delete('MUSIC_endmus');
-
- ZeroMemory(@MegaWAD, SizeOf(MegaWAD));
- gGameSettings.WAD := '';
-end;
+ procedure g_Game_FreeWAD;
+ begin
+ EndPicPath := '';
+ g_Sound_Delete('MUSIC_endmus');
+ ZeroMemory(@MegaWAD, SizeOf(MegaWAD));
+ gGameSettings.WAD := '';
+ end;
procedure g_Game_LoadWAD(WAD: string);
var
w: TWADFile;
cfg: TConfig;
p: Pointer;
procedure g_Game_LoadWAD(WAD: string);
var
w: TWADFile;
cfg: TConfig;
p: Pointer;
- {b, }len: Integer;
+ len: Integer;
s: AnsiString;
begin
g_Game_FreeWAD();
s: AnsiString;
begin
g_Game_FreeWAD();
cfg := TConfig.CreateMem(p, len);
cfg := TConfig.CreateMem(p, len);
- {b := 1;
- while True do
- begin
- s := cfg.ReadStr('pic', 'pic'+IntToStr(b), '');
- if s = '' then Break;
- b := b+1;
-
- SetLength(MegaWAD.res.pic, Length(MegaWAD.res.pic)+1);
- MegaWAD.res.pic[High(MegaWAD.res.pic)] := s;
-
- g_Texture_CreateWADEx(s, s);
- end;
-
- b := 1;
- while True do
- begin
- s := cfg.ReadStr('mus', 'mus'+IntToStr(b), '');
- if s = '' then Break;
- b := b+1;
-
- SetLength(MegaWAD.res.mus, Length(MegaWAD.res.mus)+1);
- MegaWAD.res.mus[High(MegaWAD.res.mus)] := s;
-
- g_Music_CreateWADEx(s, s);
- end;}
-
+ EndPicPath := '';
MegaWAD.endpic := cfg.ReadStr('megawad', 'endpic', '');
if MegaWAD.endpic <> '' then
MegaWAD.endpic := cfg.ReadStr('megawad', 'endpic', '');
if MegaWAD.endpic <> '' then
- begin
- s := e_GetResourcePath(WadDirs, MegaWAD.endpic, WAD);
- g_Texture_CreateWADEx('TEXTURE_endpic', s, gTextureFilter);
- end;
+ EndPicPath := e_GetResourcePath(WadDirs, MegaWAD.endpic, WAD);
+
MegaWAD.endmus := cfg.ReadStr('megawad', 'endmus', 'Standart.wad:D2DMUS\КОНЕЦ');
if MegaWAD.endmus <> '' then
begin
MegaWAD.endmus := cfg.ReadStr('megawad', 'endmus', 'Standart.wad:D2DMUS\КОНЕЦ');
if MegaWAD.endmus <> '' then
begin
gDelayedEvents[n].DENum := Num;
gDelayedEvents[n].DEStr := Str;
if DEType = DE_GLOBEVENT then
gDelayedEvents[n].DENum := Num;
gDelayedEvents[n].DEStr := Str;
if DEType = DE_GLOBEVENT then
- gDelayedEvents[n].Time := (sys_GetTicks() {div 1000}) + Time
+ gDelayedEvents[n].Time := (GetTickCount64() {div 1000}) + Time
else
gDelayedEvents[n].Time := gTime + Time;
Result := n;
else
gDelayedEvents[n].Time := gTime + Time;
Result := n;
MessageText := '';
EndingGameCounter := 0;
MessageText := '';
EndingGameCounter := 0;
+
+{$IFDEF ENABLE_MENU}
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 // Выход в главное меню
+ begin // Выход в главное меню
+ {$IFDEF DISABLE_MENU}
+ gState := STATE_MENU; // ???
+ {$ELSE}
gMusic.SetByName('MUSIC_MENU');
gMusic.Play();
if gState <> STATE_SLIST then
begin
g_GUI_ShowWindow('MainMenu');
gState := STATE_MENU;
gMusic.SetByName('MUSIC_MENU');
gMusic.Play();
if gState <> STATE_SLIST then
begin
g_GUI_ShowWindow('MainMenu');
gState := STATE_MENU;
- end else
+ end
+ else
begin
// Обновляем список серверов
slReturnPressed := True;
begin
// Обновляем список серверов
slReturnPressed := True;
slWaitStr := _lc[I_NET_SLIST_ERROR];
g_Serverlist_GenerateTable(slCurrent, slTable);
end;
slWaitStr := _lc[I_NET_SLIST_ERROR];
g_Serverlist_GenerateTable(slCurrent, slTable);
end;
-
- g_Game_ExecuteEvent('ongameend');
- end;
+ {$ENDIF}
+ g_Game_ExecuteEvent('ongameend');
+ end;
end;
EXIT_RESTART: // Начать уровень сначала
end;
EXIT_RESTART: // Начать уровень сначала
end;
procedure g_Game_Init();
end;
procedure g_Game_Init();
-var
- SR: TSearchRec;
- knownFiles: array of AnsiString = nil;
- found: Boolean;
- wext, s: AnsiString;
- f: Integer;
begin
gExit := 0;
gMapToDelete := '';
begin
gExit := 0;
gMapToDelete := '';
sfsGCDisable(); // temporary disable removing of temporary volumes
try
sfsGCDisable(); // temporary disable removing of temporary volumes
try
- g_Texture_CreateWADEx('MENU_BACKGROUND', GameWAD+':TEXTURES\TITLE', gTextureFilter);
- g_Texture_CreateWADEx('INTER', GameWAD+':TEXTURES\INTER', gTextureFilter);
- g_Texture_CreateWADEx('ENDGAME_EN', GameWAD+':TEXTURES\ENDGAME_EN', gTextureFilter);
- g_Texture_CreateWADEx('ENDGAME_RU', GameWAD+':TEXTURES\ENDGAME_RU', gTextureFilter);
-
- LoadStdFont('STDTXT', 'STDFONT', gStdFont);
- LoadFont('MENUTXT', 'MENUFONT', gMenuFont);
- LoadFont('SMALLTXT', 'SMALLFONT', gMenuSmallFont);
-
g_Game_ClearLoading();
g_Game_SetLoadingText(Format('Doom 2D: Forever %s', [GAME_VERSION]), 0, False);
g_Game_SetLoadingText('', 0, False);
g_Game_ClearLoading();
g_Game_SetLoadingText(Format('Doom 2D: Forever %s', [GAME_VERSION]), 0, False);
g_Game_SetLoadingText('', 0, False);
- g_Game_SetLoadingText(_lc[I_LOAD_MODELS], 0, False);
- // load models from all possible wad types, in all known directories
- // this does a loosy job (linear search, ooph!), but meh
- for wext in wadExtensions do
- begin
- for f := High(ModelDirs) downto Low(ModelDirs) do
- begin
- if (FindFirst(ModelDirs[f]+DirectorySeparator+'*'+wext, faAnyFile, SR) = 0) then
- begin
- repeat
- found := false;
- for s in knownFiles do
- begin
- if (strEquCI1251(forceFilenameExt(SR.Name, ''), forceFilenameExt(ExtractFileName(s), ''))) then
- begin
- found := true;
- break;
- end;
- end;
- if not found then
- begin
- SetLength(knownFiles, length(knownFiles)+1);
- knownFiles[High(knownFiles)] := ModelDirs[f]+DirectorySeparator+SR.Name;
- end;
- until (FindNext(SR) <> 0);
- end;
- FindClose(SR);
- end;
- end;
-
- if (length(knownFiles) = 0) then raise Exception.Create('no player models found!');
-
- if (length(knownFiles) = 1) then e_LogWriteln('1 player model found.', TMsgType.Notify) else e_LogWritefln('%d player models found.', [Integer(length(knownFiles))], TMsgType.Notify);
- for s in knownFiles do
- begin
- if not g_PlayerModel_Load(s) then e_LogWritefln('Error loading model "%s"', [s], TMsgType.Warning);
- end;
+// g_Game_SetLoadingText(_lc[I_LOAD_MODELS], 0, False);
gGameOn := false;
gPauseMain := false;
gGameOn := false;
gPauseMain := false;
end
end;
end
end;
+{$IFDEF ENABLE_MENU}
// 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
+ {$IFDEF ENABLE_MENU}
+ 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)
+{$IFDEF ENABLE_MENU}
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;
+{$IFDEF ENABLE_MENU}
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)
+{$IFDEF ENABLE_MENU}
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 DISABLE_MENU}
+ 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)
+{$IFDEF ENABLE_MENU}
+ and (g_ActiveWindow = nil)
+{$ENDIF}
+ then
begin
if not gSpectKeyPress then
begin
begin
if not gSpectKeyPress then
begin
end; // if gameOn ...
// Активно окно интерфейса - передаем клавиши ему:
end; // if gameOn ...
// Активно окно интерфейса - передаем клавиши ему:
+{$IFDEF ENABLE_MENU}
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);
- g_Game_ChangeResolution(gRC_Width, gRC_Height, gRC_FullScreen, gRC_Maximized);
+ {$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}
- Time := sys_GetTicks() {div 1000};
+ Time := GetTickCount64() {div 1000};
// Обработка отложенных событий:
if gDelayedEvents <> nil then
// Обработка отложенных событий:
if gDelayedEvents <> nil then
end;
procedure g_Game_LoadData();
end;
procedure g_Game_LoadData();
-var
- wl, hl: Integer;
- wr, hr: Integer;
- wb, hb: Integer;
- wm, hm: Integer;
begin
if DataLoaded then Exit;
e_WriteLog('Loading game data...', TMsgType.Notify);
begin
if DataLoaded then Exit;
e_WriteLog('Loading game data...', TMsgType.Notify);
- g_Texture_CreateWADEx('NOTEXTURE', GameWAD+':TEXTURES\NOTEXTURE');
- g_Texture_CreateWADEx('TEXTURE_PLAYER_HUD', GameWAD+':TEXTURES\HUD');
- g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDAIR', GameWAD+':TEXTURES\AIRBAR');
- g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDJET', GameWAD+':TEXTURES\JETBAR');
- g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDBG', GameWAD+':TEXTURES\HUDBG');
- g_Texture_CreateWADEx('TEXTURE_PLAYER_ARMORHUD', GameWAD+':TEXTURES\ARMORHUD');
- g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG', GameWAD+':TEXTURES\FLAGHUD_R_BASE');
- g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG_S', GameWAD+':TEXTURES\FLAGHUD_R_STOLEN');
- g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG_D', GameWAD+':TEXTURES\FLAGHUD_R_DROP');
- g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG', GameWAD+':TEXTURES\FLAGHUD_B_BASE');
- g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG_S', GameWAD+':TEXTURES\FLAGHUD_B_STOLEN');
- g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG_D', GameWAD+':TEXTURES\FLAGHUD_B_DROP');
- g_Texture_CreateWADEx('TEXTURE_PLAYER_TALKBUBBLE', GameWAD+':TEXTURES\TALKBUBBLE');
- g_Texture_CreateWADEx('TEXTURE_PLAYER_INVULPENTA', GameWAD+':TEXTURES\PENTA');
- g_Texture_CreateWADEx('TEXTURE_PLAYER_INDICATOR', GameWAD+':TEXTURES\PLRIND');
-
- hasPBarGfx := true;
- if not g_Texture_CreateWADEx('UI_GFX_PBAR_LEFT', GameWAD+':TEXTURES\LLEFT') then hasPBarGfx := false;
- if not g_Texture_CreateWADEx('UI_GFX_PBAR_MARKER', GameWAD+':TEXTURES\LMARKER') then hasPBarGfx := false;
- if not g_Texture_CreateWADEx('UI_GFX_PBAR_MIDDLE', GameWAD+':TEXTURES\LMIDDLE') then hasPBarGfx := false;
- if not g_Texture_CreateWADEx('UI_GFX_PBAR_RIGHT', GameWAD+':TEXTURES\LRIGHT') then hasPBarGfx := false;
-
- if hasPBarGfx then
- begin
- g_Texture_GetSize('UI_GFX_PBAR_LEFT', wl, hl);
- g_Texture_GetSize('UI_GFX_PBAR_RIGHT', wr, hr);
- g_Texture_GetSize('UI_GFX_PBAR_MIDDLE', wb, hb);
- g_Texture_GetSize('UI_GFX_PBAR_MARKER', wm, hm);
- if (wl > 0) and (hl > 0) and (wr > 0) and (hr = hl) and (wb > 0) and (hb = hl) and (wm > 0) and (hm > 0) and (hm <= hl) then
- begin
- // yay!
- end
- else
- begin
- hasPBarGfx := false;
- end;
- end;
-
- g_Frames_CreateWAD(nil, 'FRAMES_TELEPORT', GameWAD+':TEXTURES\TELEPORT', 64, 64, 10, False);
- g_Frames_CreateWAD(nil, 'FRAMES_PUNCH', GameWAD+':WEAPONS\PUNCH', 64, 64, 4, False);
- g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_UP', GameWAD+':WEAPONS\PUNCH_UP', 64, 64, 4, False);
- g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_DN', GameWAD+':WEAPONS\PUNCH_DN', 64, 64, 4, False);
- g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_BERSERK', GameWAD+':WEAPONS\PUNCHB', 64, 64, 4, False);
- g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_BERSERK_UP', GameWAD+':WEAPONS\PUNCHB_UP', 64, 64, 4, False);
- g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_BERSERK_DN', GameWAD+':WEAPONS\PUNCHB_DN', 64, 64, 4, False);
g_Sound_CreateWADEx('SOUND_GAME_TELEPORT', GameWAD+':SOUNDS\TELEPORT');
g_Sound_CreateWADEx('SOUND_GAME_NOTELEPORT', GameWAD+':SOUNDS\NOTELEPORT');
g_Sound_CreateWADEx('SOUND_GAME_SECRET', GameWAD+':SOUNDS\SECRET');
g_Sound_CreateWADEx('SOUND_GAME_TELEPORT', GameWAD+':SOUNDS\TELEPORT');
g_Sound_CreateWADEx('SOUND_GAME_NOTELEPORT', GameWAD+':SOUNDS\NOTELEPORT');
g_Sound_CreateWADEx('SOUND_GAME_SECRET', GameWAD+':SOUNDS\SECRET');
gMusic.Free();
g_Game_FreeData();
g_PlayerModel_FreeData();
gMusic.Free();
g_Game_FreeData();
g_PlayerModel_FreeData();
- g_Texture_DeleteAll();
- g_Frames_DeleteAll();
{$IFNDEF HEADLESS}
//g_Menu_Free(); //k8: this segfaults after resolution change; who cares?
{$ENDIF}
{$IFNDEF HEADLESS}
//g_Menu_Free(); //k8: this segfaults after resolution change; who cares?
{$ENDIF}
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();
e_WriteLog('Releasing game data...', TMsgType.Notify);
e_WriteLog('Releasing game data...', TMsgType.Notify);
- g_Texture_Delete('NOTEXTURE');
- g_Texture_Delete('TEXTURE_PLAYER_HUD');
- g_Texture_Delete('TEXTURE_PLAYER_HUDBG');
- g_Texture_Delete('TEXTURE_PLAYER_ARMORHUD');
- g_Texture_Delete('TEXTURE_PLAYER_REDFLAG');
- g_Texture_Delete('TEXTURE_PLAYER_REDFLAG_S');
- g_Texture_Delete('TEXTURE_PLAYER_REDFLAG_D');
- g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG');
- g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG_S');
- g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG_D');
- g_Texture_Delete('TEXTURE_PLAYER_TALKBUBBLE');
- g_Texture_Delete('TEXTURE_PLAYER_INVULPENTA');
- g_Frames_DeleteByName('FRAMES_TELEPORT');
- g_Frames_DeleteByName('FRAMES_PUNCH');
- g_Frames_DeleteByName('FRAMES_PUNCH_UP');
- g_Frames_DeleteByName('FRAMES_PUNCH_DN');
- g_Frames_DeleteByName('FRAMES_PUNCH_BERSERK');
- g_Frames_DeleteByName('FRAMES_PUNCH_BERSERK_UP');
- g_Frames_DeleteByName('FRAMES_PUNCH_BERSERK_DN');
g_Sound_Delete('SOUND_GAME_TELEPORT');
g_Sound_Delete('SOUND_GAME_NOTELEPORT');
g_Sound_Delete('SOUND_GAME_SECRET');
g_Sound_Delete('SOUND_GAME_TELEPORT');
g_Sound_Delete('SOUND_GAME_NOTELEPORT');
g_Sound_Delete('SOUND_GAME_SECRET');
e_WriteLog(Format(_lc[I_SIMPLE_ERROR], [Text]), TMsgType.Warning);
end;
e_WriteLog(Format(_lc[I_SIMPLE_ERROR], [Text]), TMsgType.Warning);
end;
-procedure g_Game_SetupScreenSize();
-const
- RES_FACTOR = 4.0 / 3.0;
-var
- s: Single;
- rf: Single;
- bw, bh: Word;
-begin
-// Размер экранов игроков:
- gPlayerScreenSize.X := gScreenWidth-196;
- if (gPlayer1 <> nil) and (gPlayer2 <> nil) then
- gPlayerScreenSize.Y := gScreenHeight div 2
- else
- gPlayerScreenSize.Y := gScreenHeight;
-
-// Размер заднего плана:
- if BackID <> DWORD(-1) then
- begin
- s := SKY_STRETCH;
- if (gScreenWidth*s > gMapInfo.Width) or
- (gScreenHeight*s > gMapInfo.Height) then
- begin
- gBackSize.X := gScreenWidth;
- gBackSize.Y := gScreenHeight;
- end
- else
- begin
- e_GetTextureSize(BackID, @bw, @bh);
- rf := Single(bw) / Single(bh);
- if (rf > RES_FACTOR) then bw := Round(Single(bh) * RES_FACTOR)
- else if (rf < RES_FACTOR) then bh := Round(Single(bw) / RES_FACTOR);
- s := Max(gScreenWidth / bw, gScreenHeight / bh);
- if (s < 1.0) then s := 1.0;
- gBackSize.X := Round(bw*s);
- gBackSize.Y := Round(bh*s);
- end;
- end;
-end;
-
-procedure g_Game_ChangeResolution(newWidth, newHeight: Word; nowFull, nowMax: Boolean);
-begin
- sys_SetDisplayMode(newWidth, newHeight, gBPP, nowFull, nowMax);
-end;
-
procedure g_Game_AddPlayer(Team: Byte = TEAM_NONE);
begin
if ((not gGameOn) and (gState <> STATE_INTERCUSTOM))
procedure g_Game_AddPlayer(Team: Byte = TEAM_NONE);
begin
if ((not gGameOn) and (gState <> STATE_INTERCUSTOM))
g_Game_ExecuteEvent('ongamestart');
g_Game_ExecuteEvent('ongamestart');
-// Установка размеров окон игроков:
- g_Game_SetupScreenSize();
-
// Создание первого игрока:
gPlayer1 := g_Player_Get(g_Player_Create(gPlayer1Settings.Model,
gPlayer1Settings.Color,
// Создание первого игрока:
gPlayer1 := g_Player_Get(g_Player_Create(gPlayer1Settings.Model,
gPlayer1Settings.Color,
g_Game_ExecuteEvent('ongamestart');
g_Game_ExecuteEvent('ongamestart');
-// Установка размеров окон игроков:
- g_Game_SetupScreenSize();
-
// Режим наблюдателя:
if nPlayers = 0 then
begin
// Режим наблюдателя:
if nPlayers = 0 then
begin
g_Game_ExecuteEvent('ongamestart');
g_Game_ExecuteEvent('ongamestart');
-// Установка размеров окна игрока
- g_Game_SetupScreenSize();
-
// Режим наблюдателя:
if nPlayers = 0 then
begin
// Режим наблюдателя:
if nPlayers = 0 then
begin
g_Game_ExecuteEvent('ongamestart');
g_Game_ExecuteEvent('ongamestart');
-// Установка размеров окон игроков:
- g_Game_SetupScreenSize();
-
NetState := NET_STATE_AUTH;
g_Game_SetLoadingText(_lc[I_LOAD_CONNECT], 0, False);
NetState := NET_STATE_AUTH;
g_Game_SetLoadingText(_lc[I_LOAD_CONNECT], 0, False);
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);
+ {$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;
+ {$IFDEF ENABLE_MENU}
+ 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
+ {$IFDEF ENABLE_MENU}
+ 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 = 'weapnext') or (cmd = 'weapprev') then
begin
end
else if (cmd = 'weapnext') or (cmd = 'weapprev') then
begin
g_Game_Free();
g_Game_Quit();
end;
g_Game_Free();
g_Game_Quit();
end;
+{$IFNDEF HEADLESS}
'r_reset':
'r_reset':
- begin
- gRC_Width := Max(1, gRC_Width);
- gRC_Height := Max(1, gRC_Height);
- gBPP := Max(1, gBPP);
- if sys_SetDisplayMode(gRC_Width, gRC_Height, gBPP, gRC_FullScreen, gRC_Maximized) = True then
- e_LogWriteln('resolution changed')
- else
- e_LogWriteln('resolution not changed');
- sys_EnableVSync(gVSync);
- end;
+ 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 = '');
procedure g_TakeScreenShot(Filename: string = '');
- var s: TStream; t: TDateTime; dir, date, name: String;
+ var t: TDateTime; dir, date, name: String;
begin
begin
- if e_NoGraphics then Exit;
- try
- dir := e_GetWriteableDir(ScreenshotDirs);
+ if e_NoGraphics then
+ Exit;
- if Filename = '' then
- begin
- t := Now;
- DateTimeToString(date, 'yyyy-mm-dd-hh-nn-ss', t);
- Filename := 'screenshot-' + date;
- end;
-
- name := e_CatPath(dir, Filename + '.png');
- s := createDiskFile(name);
- try
- e_MakeScreenshot(s, gWinSizeX, gWinSizeY);
- s.Free;
- g_Console_Add(Format(_lc[I_CONSOLE_SCREENSHOT], [name]))
- except
- g_Console_Add(Format(_lc[I_CONSOLE_ERROR_WRITE], [name]));
- s.Free;
- DeleteFile(name)
- end
- except
- g_Console_Add('oh shit, i can''t create screenshot!')
- end
+ dir := e_GetWriteableDir(ScreenshotDirs);
+ if Filename = '' then
+ begin
+ t := Now;
+ DateTimeToString(date, 'yyyy-mm-dd-hh-nn-ss', t);
+ Filename := 'screenshot-' + date;
+ end;
+
+ name := e_CatPath(dir, Filename + '.png');
+ if r_Render_WriteScreenShot(name) then
+ g_Console_Add(Format(_lc[I_CONSOLE_SCREENSHOT], [name]))
+ else
+ g_Console_Add(Format(_lc[I_CONSOLE_ERROR_WRITE], [name]));
end;
end;
+{$ENDIF}
+{$IFDEF ENABLE_MENU}
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
end;
end;
end;
end;
-procedure g_Game_Message(Msg: string; Time: Word);
-begin
- MessageLineLength := (gScreenWidth - 204) div e_CharFont_GetMaxWidth(gMenuFont);
- MessageText := b_Text_Wrap(b_Text_Format(Msg), MessageLineLength);
- MessageTime := Time;
-end;
+ procedure g_Game_Message (Msg: string; Time: Word);
+ begin
+ MessageText := Msg;
+ MessageTime := Time;
+ end;
procedure g_Game_ChatSound(Text: String; Taunt: Boolean = True);
const
procedure g_Game_ChatSound(Text: String; Taunt: Boolean = True);
const
PBarWasHere := false;
end;
PBarWasHere := false;
end;
- g_ActiveWindow := nil;
- ProcessLoading(True);
+ {$IFDEF ENABLE_MENU}
+ g_ActiveWindow := nil;
+ {$ENDIF}
+
+ ProcessLoading(true);
end;
procedure g_Game_StepLoading(Value: Integer = -1);
end;
procedure g_Game_StepLoading(Value: Integer = -1);