X-Git-Url: http://deadsoftware.ru/gitweb?p=d2df-sdl.git;a=blobdiff_plain;f=src%2Fshared%2FWADEDITOR.pas;h=7a4c59e81d5efdcce492b2664f533bc1fe19fd29;hp=5c9ca4f35a593c0b9691cce39096edf87f02a547;hb=17c0529fabf8840719502baca9da24e5c14678ae;hpb=7031a6441936ee1b8319773aad0f4f4c6bb97e3e diff --git a/src/shared/WADEDITOR.pas b/src/shared/WADEDITOR.pas index 5c9ca4f..7a4c59e 100644 --- a/src/shared/WADEDITOR.pas +++ b/src/shared/WADEDITOR.pas @@ -49,6 +49,9 @@ const procedure g_ProcessResourceStr (ResourceStr: String; var FileName, SectionName, ResourceName: String); overload; procedure g_ProcessResourceStr (ResourceStr: String; FileName, SectionName, ResourceName: PString); overload; +// return fixed string or empty string +function findDiskWad (fname: string): string; + implementation @@ -56,6 +59,41 @@ uses SysUtils, Classes, BinEditor, e_log, g_options; +function findDiskWad (fname: string): string; +var + path, rfn: string; +begin + result := ''; + path := ExtractFilePath(fname); + rfn := ExtractFileName(fname); + if not sfsFindFileCI(path, rfn) then + begin + //e_WriteLog(Format('TWADEditor_1.ReadFile: error looking for [%s] [%s]', [path, ExtractFileName(fname)]), MSG_NOTIFY); + if SFSStrEqu(ExtractFileExt(fname), '.wad') then + begin + rfn := ChangeFileExt(ExtractFileName(fname), '.pk3'); + //e_WriteLog(Format(' looking for [%s] [%s]', [path, rfn]), MSG_NOTIFY); + if not sfsFindFileCI(path, rfn) then + begin + //e_WriteLog(Format(' looking for [%s] [%s]', [path, rfn]), MSG_NOTIFY); + rfn := ChangeFileExt(ExtractFileName(fname), '.zip'); + if not sfsFindFileCI(path, rfn) then exit; + end; + end + else + begin + exit; + end; + //e_WriteLog(Format('TWADEditor_1.ReadFile: FOUND [%s]', [rfn]), MSG_NOTIFY); + end + else + begin + //if rfn <> ExtractFileName(FileName) then e_WriteLog(Format('TWADEditor_1.ReadFile: FOUND [%s]', [rfn]), MSG_NOTIFY); + end; + result := path+rfn; +end; + + procedure g_ProcessResourceStr (ResourceStr: String; var FileName, SectionName, ResourceName: String); var a, i: Integer; @@ -243,37 +281,16 @@ begin Result := False; //e_WriteLog(Format('TWADEditor_1.ReadFile: [%s]', [FileName]), MSG_NOTIFY); FreeWAD(); - path := ExtractFilePath(FileName); - rfn := ExtractFileName(FileName); - if not sfsFindFileCI(path, rfn) then + rfn := findDiskWad(FileName); + if length(rfn) = 0 then begin - //{if gSFSDebug then} e_WriteLog(Format('TWADEditor_1.ReadFile: error looking for [%s] [%s]', [path, ExtractFileName(FileName)]), MSG_NOTIFY); - if SFSStrEqu(ExtractFileExt(FileName), '.wad') then - begin - rfn := ChangeFileExt(ExtractFileName(FileName), '.pk3'); - //{if gSFSDebug then} e_WriteLog(Format(' looking for [%s] [%s]', [path, rfn]), MSG_NOTIFY); - if not sfsFindFileCI(path, rfn) then - begin - //{if gSFSDebug then} e_WriteLog(Format(' looking for [%s] [%s]', [path, rfn]), MSG_NOTIFY); - rfn := ChangeFileExt(ExtractFileName(FileName), '.zip'); - if not sfsFindFileCI(path, rfn) then exit; - end; - end - else - begin - exit; - end; - //{if gSFSDebug then} e_WriteLog(Format('TWADEditor_1.ReadFile: FOUND [%s]', [rfn]), MSG_NOTIFY); - end - else - begin - //if rfn <> ExtractFileName(FileName) then e_WriteLog(Format('TWADEditor_1.ReadFile: FOUND [%s]', [rfn]), MSG_NOTIFY); + e_WriteLog(Format('TWADEditor_1.ReadFile: error looking for [%s]', [FileName]), MSG_NOTIFY); + exit; end; {$IFDEF SFS_DWFAD_DEBUG} if gSFSDebug then e_WriteLog(Format('TWADEditor_1.ReadFile: FOUND [%s]', [rfn]), MSG_NOTIFY); {$ENDIF} // cache this wad - rfn := path+rfn; try if gSFSFastMode then begin @@ -290,17 +307,8 @@ begin if fIter = nil then Exit; fFileName := rfn; {$IFDEF SFS_DWFAD_DEBUG} - if gSFSDebug then - e_WriteLog(Format('TWADEditor_1.ReadFile: [%s] opened', [fFileName]), MSG_NOTIFY); + if gSFSDebug then e_WriteLog(Format('TWADEditor_1.ReadFile: [%s] opened', [fFileName]), MSG_NOTIFY); {$ENDIF} - { - for f := 0 to fIter.Count-1 do - begin - fi := fIter.Files[f]; - if fi = nil then continue; - e_WriteLog(Format('[%s]: [%s : %s] %u', [fFileName, fi.path, fi.name, fi.size]), MSG_NOTIFY); - end; - } Result := True; end;