summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 20b94bc)
raw | patch | inline | side by side (parent: 20b94bc)
author | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Sun, 20 Oct 2019 21:11:50 +0000 (00:11 +0300) | ||
committer | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Sun, 20 Oct 2019 21:12:18 +0000 (00:12 +0300) |
src/engine/e_res.pas | patch | blob | history | |
src/game/g_game.pas | patch | blob | history | |
src/game/g_playermodel.pas | patch | blob | history |
diff --git a/src/engine/e_res.pas b/src/engine/e_res.pas
index db328791be0a74d3cf40e5915a16a5165b0058db..e5d47567b3c167cfaf4f792b0b8de647539c3a4e 100644 (file)
--- a/src/engine/e_res.pas
+++ b/src/engine/e_res.pas
function e_GetResourcePath (dirs: SSArray; path: AnsiString; defWad: AnsiString): AnsiString;
{--- same as SysUtils.FinFirst ---}
- function e_FindFirst (dirs: SSArray; name: AnsiString; attr: LongInt; out Rslt: TRawbyteSearchRec): LongInt;
+ function e_FindFirst (dirs: SSArray; name: AnsiString; attr: LongInt; out Rslt: TSearchRec): LongInt;
{--- try to create directory from list, throws if no one directory created ---}
function e_GetDir (dirs: SSArray): AnsiString;
e_LogWritefln(' this>>> %s', [result]);
end;
- function e_FindFirst (dirs: SSArray; name: AnsiString; attr: LongInt; out Rslt: TRawbyteSearchRec): LongInt;
+ function e_FindFirst (dirs: SSArray; name: AnsiString; attr: LongInt; out Rslt: TSearchRec): LongInt;
var i: Integer; dir: AnsiString;
begin
if debug_e_res then
result := FindFirst(dir, attr, Rslt);
if debug_e_res then
e_LogWritefln(' %s: %s -- %s', [i, dir, result]);
- Dec(i);
+ Dec(i);
end
end;
diff --git a/src/game/g_game.pas b/src/game/g_game.pas
index 0505dceb74d336c6d8a2afe83ea699fc9c13782c..4fd60574821c735e0e057cf05dbfe67e00812e9c 100644 (file)
--- a/src/game/g_game.pas
+++ b/src/game/g_game.pas
procedure g_Game_Init();
var
SR: TSearchRec;
+ knownFiles: array of AnsiString = nil;
+ found: Boolean;
+ wext, s: AnsiString;
+ f: Integer;
begin
gExit := 0;
gMapToDelete := '';
g_Game_SetLoadingText(_lc[I_LOAD_MODELS], 0, False);
g_PlayerModel_LoadData();
- if e_FindFirst(ModelDirs, '*.wad', faAnyFile, SR) = 0 then
- repeat
- if not g_PlayerModel_Load(e_FindWad(ModelDirs, SR.Name)) then
- e_WriteLog(Format('Error loading model %s', [SR.Name]), TMsgType.Warning);
- until FindNext(SR) <> 0;
- FindClose(SR);
-
- if e_FindFirst(ModelDirs, '*.pk3', faAnyFile, SR) = 0 then
- repeat
- if not g_PlayerModel_Load(e_FindWad(ModelDirs, SR.Name)) then
- e_WriteLog(Format('Error loading model %s', [SR.Name]), TMsgType.Warning);
- until FindNext(SR) <> 0;
- FindClose(SR);
-
- if e_FindFirst(ModelDirs, '*.zip', faAnyFile, SR) = 0 then
- repeat
- if not g_PlayerModel_Load(e_FindWad(ModelDirs, SR.Name)) then
- e_WriteLog(Format('Error loading model %s', [SR.Name]), TMsgType.Warning);
- until FindNext(SR) <> 0;
- FindClose(SR);
+ // 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;
gGameOn := false;
gPauseMain := false;
index 612644fce1527f96799429ada9fa976fe0dba7d8..6ffea1fbc3fc094fb714fb25df4ef20623235c4a 100644 (file)
prefix: string;
ok, chk: Boolean;
begin
- e_WriteLog(Format('Loading player model: %s', [ExtractFileName(FileName)]), TMsgType.Notify);
+ e_WriteLog(Format('Loading player model "%s"...', [FileName]), TMsgType.Notify);
Result := False;