index 1c5fb19e123bded268c49037fb551d2efac87d9f..df0de0fc591a48ffe3d16ce7f68ba412fd781b85 100644 (file)
--- a/src/shared/wadreader.pas
+++ b/src/shared/wadreader.pas
-{$MODE DELPHI}
+(* Copyright (C) DooM 2D:Forever Developers
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *)
+{$INCLUDE a_modes.inc}
unit wadreader;
-{$DEFINE SFS_DWFAD_DEBUG}
+{$DEFINE SFS_DFWAD_DEBUG}
{$DEFINE SFS_MAPDETECT_FX}
interface
function findDiskWad (fname: AnsiString): AnsiString;
+var
+ wadoptDebug: Boolean = false;
+ wadoptFast: Boolean = false;
+
+
implementation
uses
- SysUtils, Classes, BinEditor, e_log, g_options, utils, MAPSTRUCT;
+ SysUtils, Classes{, BinEditor}, e_log{, g_options}, utils, MAPSTRUCT;
function findDiskWad (fname: AnsiString): AnsiString;
if (lastSlash < 0) and (resourceStr[f] = '\') or (resourceStr[f] = '/') then lastSlash := f;
if resourceStr[f] = ':' then
begin
- if lastSlash > 0 then result := normSlashes(Copy(resourceStr, f, lastSlash-f));
+ if lastSlash > 0 then
+ begin
+ result := normSlashes(Copy(resourceStr, f, lastSlash-f));
+ while (length(result) > 0) and (result[1] = '/') do Delete(result, 1, 1);
+ end;
exit;
end;
end;
if resourceStr[f] = ':' then
begin
result := normSlashes(Copy(resourceStr, f+1, length(resourceStr)));
+ while (length(result) > 0) and (result[1] = '/') do Delete(result, 1, 1);
exit;
end;
end;
+ result := normSlashes(resourceStr);
+ while (length(result) > 0) and (result[1] = '/') do Delete(result, 1, 1);
end;
if wantMap then
begin
goodMap := false;
- e_WriteLog(Format('DFWAD: checking for good map in wad [%s], file [%s] (#%d)', [fFileName, fi.fname, f]), MSG_NOTIFY);
+ //e_WriteLog(Format('DFWAD: checking for good map in wad [%s], file [%s] (#%d)', [fFileName, fi.fname, f]), MSG_NOTIFY);
try
fs.readBuffer(sign, 3);
goodMap := (sign = MAP_SIGNATURE);
+ {
if goodMap then
e_WriteLog(Format(' GOOD map in wad [%s], file [%s] (#%d)', [fFileName, fi.fname, f]), MSG_NOTIFY)
else
e_WriteLog(Format(' BAD map in wad [%s], file [%s] (#%d)', [fFileName, fi.fname, f]), MSG_NOTIFY);
+ }
except
end;
if not goodMap then
begin
- e_WriteLog(Format(' not a map in wad [%s], file [%s] (#%d)', [fFileName, fi.fname, f]), MSG_NOTIFY);
+ //e_WriteLog(Format(' not a map in wad [%s], file [%s] (#%d)', [fFileName, fi.fname, f]), MSG_NOTIFY);
fs.Free();
continue;
end;
end;
if not goodMap then
begin
- e_WriteLog(Format(' not a map in wad [%s], file [%s] (#%d)', [fFileName, fi.fname, f]), MSG_NOTIFY);
+ //e_WriteLog(Format(' not a map in wad [%s], file [%s] (#%d)', [fFileName, fi.fname, f]), MSG_NOTIFY);
FreeMem(pData);
pData := nil;
Len := 0;
end;
{$ENDIF}
result := true;
- {$IFDEF SFS_DWFAD_DEBUG}
- if gSFSDebug then
+ {$IFDEF SFS_DFWAD_DEBUG}
+ if wadoptDebug then
e_WriteLog(Format('DFWAD: file [%s] FOUND in [%s]; size is %d bytes', [name, fFileName, Len]), MSG_NOTIFY);
{$ENDIF}
exit;
fi := fIter.Files[f];
if fi = nil then continue;
if length(fi.name) = 0 then continue;
- e_WriteLog(Format('DFWAD: checking for map in wad [%s], file [%s] (#%d)', [fFileName, fi.fname, f]), MSG_NOTIFY);
+ //e_WriteLog(Format('DFWAD: checking for map in wad [%s], file [%s] (#%d)', [fFileName, fi.fname, f]), MSG_NOTIFY);
if isMapResource(f) then
begin
s := removeExt(fi.name);
e_WriteLog(Format('TWADFile.ReadFile: error looking for [%s]', [FileName]), MSG_NOTIFY);
exit;
end;
- {$IFDEF SFS_DWFAD_DEBUG}
- if gSFSDebug then e_WriteLog(Format('TWADFile.ReadFile: FOUND [%s]', [rfn]), MSG_NOTIFY);
+ {$IFDEF SFS_DFWAD_DEBUG}
+ if wadoptDebug then e_WriteLog(Format('TWADFile.ReadFile: FOUND [%s]', [rfn]), MSG_NOTIFY);
{$ENDIF}
// cache this wad
try
- if gSFSFastMode then
+ if wadoptFast then
begin
if not SFSAddDataFile(rfn, true) then exit;
end
fIter := SFSFileList(rfn);
if fIter = nil then Exit;
fFileName := rfn;
- {$IFDEF SFS_DWFAD_DEBUG}
- if gSFSDebug then e_WriteLog(Format('TWADFile.ReadFile: [%s] opened', [fFileName]), MSG_NOTIFY);
+ {$IFDEF SFS_DFWAD_DEBUG}
+ if wadoptDebug then e_WriteLog(Format('TWADFile.ReadFile: [%s] opened', [fFileName]), MSG_NOTIFY);
{$ENDIF}
Result := True;
end;
fn := Format(' -- memwad %d -- ', [uniqueCounter]);
Inc(uniqueCounter);
- {$IFDEF SFS_DWFAD_DEBUG}
- e_WriteLog(Format('TWADFile.ReadMemory: [%s]', [fn]), MSG_NOTIFY);
+ {$IFDEF SFS_DFWAD_DEBUG}
+ if wadoptDebug then e_WriteLog(Format('TWADFile.ReadMemory: [%s]', [fn]), MSG_NOTIFY);
{$ENDIF}
try
if fIter = nil then Exit;
fFileName := fn;
- {$IFDEF SFS_DWFAD_DEBUG}
- e_WriteLog(Format('TWADFile.ReadMemory: [%s] opened', [fFileName]), MSG_NOTIFY);
+ {$IFDEF SFS_DFWAD_DEBUG}
+ if wadoptDebug then e_WriteLog(Format('TWADFile.ReadMemory: [%s] opened', [fFileName]), MSG_NOTIFY);
{$ENDIF}
{