summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3b07d5b)
raw | patch | inline | side by side (parent: 3b07d5b)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Mon, 17 Jan 2022 15:16:29 +0000 (18:16 +0300) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Fri, 9 Jun 2023 07:53:20 +0000 (10:53 +0300) |
diff --git a/src/game/g_game.pas b/src/game/g_game.pas
index 5f7efda1bd62421ae0f36cef45e00593361d7c77..315f1afc2d9c6b50693dc5daa804e99e6fc3fe6a 100644 (file)
--- a/src/game/g_game.pas
+++ b/src/game/g_game.pas
STATFILE_VERSION = $03;
var
- gStdFont: DWORD;
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;
- hasPBarGfx: Boolean;
LoadingStat: TLoadingStat;
MessageText: String;
IsDrawStat: Boolean;
g_playerLight: Boolean;
g_dynLights: array of TDynLight = nil;
g_dynLightCount: Integer = 0;
+ EndPicPath: AnsiString; // full path, used by render
implementation
{$IFDEF ENABLE_HOLMES}
g_holmes,
{$ENDIF}
- e_res, g_window, g_menu, r_render, r_textures, r_animations, r_gfx, r_map,
+ e_res, g_window, g_menu, r_render, r_gfx,
e_input, e_log, g_console, r_console, g_items, g_map, g_panel,
g_playermodel, g_gfx, g_options, Math,
g_triggers, g_monsters, e_sound, CONFIG,
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;
- //InterPic: String;
InterText: record
lines: SSArray;
img: String;
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;
- {b, }len: Integer;
+ len: Integer;
s: AnsiString;
begin
g_Game_FreeWAD();
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
- 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
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);
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);
- 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_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();
- g_Texture_DeleteAll();
- g_Frames_DeleteAll();
{$IFNDEF HEADLESS}
//g_Menu_Free(); //k8: this segfaults after resolution change; who cares?
{$ENDIF}
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_Sound_Delete('SOUND_GAME_TELEPORT');
g_Sound_Delete('SOUND_GAME_NOTELEPORT');
g_Sound_Delete('SOUND_GAME_SECRET');
begin
//result := g_Map_Load(gGameSettings.WAD + ':\' + ResName);
result := g_Map_Load(NewWAD+':\'+ResName);
- r_Map_LoadTextures;
+ r_Render_LoadTextures;
end;
if Result then
begin
index 1204fcda617d533c1654580f3c5e785f79613178..f7ab15fdceedae8301bae1e96433705602953ccc 100644 (file)
uses
SysUtils, Classes, Math,
- e_log, r_graphics, g_options, r_textures,
+ e_log, r_graphics, g_options, r_textures, r_game,
conbuf,
g_base, g_console, g_game, g_menu
;
index ed204cd2ce66c7f785980dc6d75cde3c092a3ec2..1a5085831d7b5892ffad6f4ffec4fda0a6d42b00 100644 (file)
interface
+ procedure r_Game_Load;
+ procedure r_Game_Free;
+
+ procedure r_Game_LoadTextures;
+ procedure r_Game_FreeTextures;
+
procedure r_Game_Draw;
procedure r_Game_DrawLoadingStat;
procedure r_Game_DrawMenuBackground (tex: AnsiString);
+ var
+ gStdFont: DWORD;
+
implementation
uses
FPS: Word;
FPSCounter: Word;
FPSTime: LongWord;
+ hasPBarGfx: Boolean;
+
+ procedure r_Game_Load;
+ var
+ wl, hl: Integer;
+ wr, hr: Integer;
+ wb, hb: Integer;
+ wm, hm: Integer;
+ begin
+ // early load
+ 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);
+ // game data
+ 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');
+ // bar
+ 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
+ hasPBarGfx := false;
+ end;
+ end;
+
+ procedure r_Game_Free;
+ begin
+ 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');
+ end;
+
+ procedure r_Game_LoadTextures;
+ begin
+ g_Texture_CreateWADEx('TEXTURE_endpic', EndPicPath, gTextureFilter);
+ end;
+
+ procedure r_Game_FreeTextures;
+ begin
+ g_Texture_Delete('TEXTURE_endpic')
+ end;
function GetActivePlayer_ByID(ID: Integer): TPlayer;
var
index d34100da06db6f9ccf48591bf9177694cc057f4f..da98c9582c511414a33812fb85381adaa168d503 100644 (file)
procedure r_Map_Free;
procedure r_Map_LoadTextures;
- // TODO procedure r_Map_FreeTextures
+ procedure r_Map_FreeTextures;
procedure r_Map_Update;
end
end;
+ procedure r_Map_FreeTextures;
+ begin
+ // TODO
+ end;
+
procedure dplClear ();
begin
if (gDrawPanelList = nil) then gDrawPanelList := TBinHeapPanelDraw.Create() else gDrawPanelList.clear();
index c9b4ff7a3c9119d30a16411c8d7cfa9d3ad52144..d2f2dfd1535ed599a71766ffad09aa0b9026a270 100644 (file)
uses
SysUtils, Classes, Math, e_log,
- r_graphics, g_options, r_animations,
+ r_graphics, g_options, r_animations, r_game,
MAPDEF,
g_base, g_basic, g_game, g_phys,
g_monsters
index e82db0819e468fa02717f44089895a1963e505db..679e85a7dc0a06837776c1992a70d043f5ca84bb 100644 (file)
uses
SysUtils, Classes, Math,
- r_graphics,
+ r_graphics, r_game,
g_basic, g_language, g_game, g_menu
;
index 41c519be71b9c70166ac045bb43a5e4f5423f29b..7d0269c08a631ae2fc03c42dfbd35eef517c42ce 100644 (file)
{$IFDEF ENABLE_HOLMES}
g_holmes,
{$ENDIF}
- r_playermodel, r_graphics, r_animations, r_textures, r_items
+ r_playermodel, r_graphics, r_animations, r_textures, r_items, r_game
;
var
index b6bb016f74410f1cf5dd53fa0e57c355ccd35720..2eec521475ec4c7806fa08c8d63a59538c1da293 100644 (file)
procedure r_Render_Initialize;
procedure r_Render_Finalize;
- procedure r_Render_Resize (w, h: Integer);
-
procedure r_Render_Load;
procedure r_Render_Free;
+ procedure r_Render_LoadTextures;
+ procedure r_Render_FreeTextures;
+
+ procedure r_Render_Resize (w, h: Integer);
+
procedure r_Render_Update;
procedure r_Render_Apply;
SysUtils, Classes, Math,
e_log, g_system,
g_game, g_options, g_console,
- r_window, r_graphics, r_console, r_playermodel,
- r_weapons, r_items, r_gfx, r_monsters, r_map, r_player
+ r_window, r_graphics, r_console, r_playermodel, r_textures, r_animations,
+ r_weapons, r_items, r_gfx, r_monsters, r_map, r_player, r_game
;
var
end
end;
+ procedure r_Render_LoadTextures;
+ begin
+ r_Game_LoadTextures;
+ r_Map_LoadTextures;
+ end;
+
+ procedure r_Render_FreeTextures;
+ begin
+ r_Map_FreeTextures;
+ r_Game_FreeTextures;
+ end;
+
procedure r_Render_Load;
begin
+ r_Game_Load; // load first!
r_Player_Load;
r_Map_Load;
r_PlayerModel_Load;
r_PlayerModel_Free;
r_Map_Free;
r_Player_Free;
+ r_Game_Free;
+ g_Texture_DeleteAll;
+ g_Frames_DeleteAll;
end;
procedure r_Render_Initialize;
index 629ca3a69fde4a62f866d0bcf140f2ba131f3190..da6edc87bf1e9e90d28678c566859e454999ff73 100644 (file)
uses
SysUtils,
- e_log, r_graphics, e_input, g_options, g_game, g_gui, g_weapons, g_console;
+ e_log, r_graphics, r_game, e_input, g_options, g_game, g_gui, g_weapons, g_console;
var
angleFire: Boolean;