summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: dd22c43)
raw | patch | inline | side by side (parent: dd22c43)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Mon, 17 Jan 2022 15:16:29 +0000 (18:16 +0300) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Mon, 17 Jan 2022 15:16:29 +0000 (18:16 +0300) |
diff --git a/src/game/g_game.pas b/src/game/g_game.pas
index 539cf2c25f46a691ce730a68d9ffa80edd4f7a6b..2ce5d95e7107a6b547b0e99670db518ec0335e59 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 ec87b29133416e670dcfdd3462df0b489e1d242d..af6fa38e78d27de654cd04e39e75aa7c394eec5a 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 1970ac3baf39de4462a1fe43818ba205734b3463..9efb062512f975054c65b7f011fd189132e7a4a2 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 78931208c9e33acff7d102f83d61ceeb523d18ab..d4af4b55fdd5b89432ed810c7759a72c8edaa182 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;