diff --git a/src/game/g_game.pas b/src/game/g_game.pas
index 0505dceb74d336c6d8a2afe83ea699fc9c13782c..80f53ccc05e25ea145ac322c15bdc4898ff3d935 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;
procedure g_Game_SaveOptions;
var s: AnsiString;
begin
- s := e_GetDir(ConfigDirs);
+ s := e_GetWriteableDir(ConfigDirs);
if s <> '' then
g_Options_Write_Video(s + '/' + CONFIG_FILENAME)
else
if (Length(P) > 1) then
NetInterpLevel := StrToIntDef(P[1], NetInterpLevel);
g_Console_Add('net_interp = ' + IntToStr(NetInterpLevel));
- s := e_GetDir(ConfigDirs);
+ s := e_GetWriteableDir(ConfigDirs);
if s <> '' then
begin
config := TConfig.CreateFile(s + '/' + CONFIG_FILENAME);
else
g_Console_Add('net_forceplayerupdate = 0');
- s := e_GetDir(ConfigDirs);
+ s := e_GetWriteableDir(ConfigDirs);
if s <> '' then
begin
config := TConfig.CreateFile(s + '/' + CONFIG_FILENAME);
else
g_Console_Add('net_predictself = 0');
- s := e_GetDir(ConfigDirs);
+ s := e_GetWriteableDir(ConfigDirs);
if s <> '' then
begin
config := TConfig.CreateFile(s + '/' + CONFIG_FILENAME);