summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7031a64)
raw | patch | inline | side by side (parent: 7031a64)
author | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Sun, 17 Apr 2016 04:02:59 +0000 (07:02 +0300) | ||
committer | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Sun, 17 Apr 2016 04:03:35 +0000 (07:03 +0300) |
src/game/g_netmsg.pas | patch | blob | history | |
src/shared/WADEDITOR.pas | patch | blob | history |
diff --git a/src/game/g_netmsg.pas b/src/game/g_netmsg.pas
index b24022f26280c1101adf89242f7ca0cfb0f2d1a9..ad92f47e300d3284a486787f57e293de45beebd0 100644 (file)
--- a/src/game/g_netmsg.pas
+++ b/src/game/g_netmsg.pas
Math, ENet, e_input, e_fixedbuffer, e_graphics, e_log,
g_textures, g_gfx, g_sound, g_console, g_basic, g_options, g_main,
g_game, g_player, g_map, g_panel, g_items, g_weapons, g_phys, g_gui,
- g_language, g_monsters, g_netmaster,
+ g_language, g_monsters, g_netmaster, sfs,
WADEDITOR, MAPDEF;
const
function ReadFile(const FileName: TFileName): AByte;
var
FileStream : TFileStream;
+ fname: string;
begin
+ e_WriteLog(Format('NETWORK: looking for file "%s"', [FileName]), MSG_NOTIFY);
+ fname := findDiskWad(FileName);
+ if length(fname) = 0 then
+ begin
+ e_WriteLog(Format('NETWORK: file "%s" not found!', [FileName]), MSG_FATALERROR);
+ SetLength(Result, 0);
+ exit;
+ end;
+ e_WriteLog(Format('NETWORK: found file "%s"', [fname]), MSG_NOTIFY);
Result := nil;
- FileStream:= TFileStream.Create(FileName, fmOpenRead or fmShareDenyWrite);
+ FileStream:= TFileStream.Create(fname, fmOpenRead or {fmShareDenyWrite}fmShareDenyNone);
try
- if FileStream.Size>0 then
+ if FileStream.Size > 0 then
begin
SetLength(Result, FileStream.Size);
FileStream.Read(Result[0], FileStream.Size);
index 5c9ca4f35a593c0b9691cce39096edf87f02a547..7a4c59e81d5efdcce492b2664f533bc1fe19fd29 100644 (file)
--- a/src/shared/WADEDITOR.pas
+++ b/src/shared/WADEDITOR.pas
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
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;
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
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;