summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2b04301)
raw | patch | inline | side by side (parent: 2b04301)
author | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Wed, 30 Aug 2017 20:06:09 +0000 (23:06 +0300) | ||
committer | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Wed, 30 Aug 2017 20:06:35 +0000 (23:06 +0300) |
diff --git a/src/engine/e_log.pas b/src/engine/e_log.pas
index afc638cac7be82a9d7af6a0f1eb764811adf4eb8..3a8d0adc2900ef25e1f3fb3ea896c54320504e3e 100644 (file)
--- a/src/engine/e_log.pas
+++ b/src/engine/e_log.pas
begin
e_LogWritefln('%s', [TextLine], RecordCategory, WriteTime);
end;
-(*
-var
- LogFile: TextFile;
- Prefix: ShortString = '';
- OutStr: String;
-begin
- if driverInited and (length(TextLine) > 0) then
- begin
- case RecordCategory of
- MSG_FATALERROR: write('FATAL: ');
- MSG_WARNING: write('WARNING: ');
- end;
- writeln(TextLine);
- end;
-
- if FileName = '' then Exit;
-
- Assign(LogFile, FileName);
- try
- if FileExists(FileName) then
- Append(LogFile)
- else
- Rewrite(LogFile);
- try
- if FirstRecord then
- begin
- Writeln(LogFile, '--- Log started at '+TimeToStr(Time)+' ---');
- FirstRecord := False;
- end;
- case RecordCategory of
- MSG_FATALERROR: Prefix := '!!!';
- MSG_WARNING: Prefix := '! ';
- MSG_NOTIFY: Prefix := '***';
- end;
- if WriteTime then
- OutStr := '['+TimeToStr(Time)+'] '+Prefix+' '+TextLine
- else
- OutStr := Prefix+' '+TextLine;
- Writeln(LogFile, OutStr);
- if e_WriteToStdOut then
- Writeln(OutStr);
- finally
- Close(LogFile);
- end;
- except // sorry
- end;
-end;
-*)
// returns formatted string if `writerCB` is `nil`, empty string otherwise
diff --git a/src/shared/conbuf.pas b/src/shared/conbuf.pas
index 4bb1bea0af8b0e8620f580785347a117bdb0c037..12b0a6e71db79a8f4d9deaf16b91b2eee7ec8bb2 100644 (file)
--- a/src/shared/conbuf.pas
+++ b/src/shared/conbuf.pas
var
conbufDumpToStdOut: Boolean = false;
+ conbufConPrefix: Boolean = true;
implementation
begin
for np := 0 to count-1 do
begin
- if needCon then begin write(stdout, 'CON: '); needCon := false; end;
+ if needCon then
+ begin
+ if conbufConPrefix then write(stdout, 'CON: ');
+ needCon := false;
+ end;
write(stdout, buf[np]);
needCon := (buf[np] = #10);
end;
index 8207f602fcac68605e3d9d58194b117ddb4cc65c..a916ff6ceb694d234c337faeae4646e3cffb3e5f 100644 (file)
--- a/src/shared/wadreader.pas
+++ b/src/shared/wadreader.pas
type
SArray = array of ShortString;
- TWADFile = class(TObject)
+ TWADFile = class
private
fFileName: AnsiString; // empty: not opened
fIter: TSFSFileList;
function GetResourceEx (name: AnsiString; wantMap: Boolean; var pData: Pointer; var Len: Integer): Boolean;
public
- constructor Create();
- destructor Destroy(); override;
+ constructor Create ();
+ destructor Destroy (); override;
- procedure FreeWAD();
+ procedure FreeWAD ();
function ReadFile (FileName: AnsiString): Boolean;
function ReadMemory (Data: Pointer; Len: LongWord): Boolean;
diff --git a/src/shared/xdynrec.pas b/src/shared/xdynrec.pas
index f129dd035af96a9b8c12f84feec6bf58a35349b8..456a01376f25c8ce60c8aa65236d78cc90ad0927 100644 (file)
--- a/src/shared/xdynrec.pas
+++ b/src/shared/xdynrec.pas
implementation
uses
- SysUtils;
+ SysUtils, e_log;
// ////////////////////////////////////////////////////////////////////////// //
if (Length(fld.mRecRefId) = 0) then continue;
assert(fld.mEBSType <> nil);
rt := findRecordByTypeId(fld.mEBSTypeName, fld.mRecRefId);
- if (rt = nil) then raise Exception.Create(Format('record of type ''%s'' with id ''%s'' links to inexistant record of type ''%s'' with id ''%d''', [rec.mName, rec.mId, fld.mEBSTypeName, fld.mRecRefId]));
+ if (rt = nil) then
+ begin
+ e_LogWritefln('record of type ''%s'' with id ''%s'' links to inexistant record of type ''%s'' with id ''%s''', [rec.mName, rec.mId, fld.mEBSTypeName, fld.mRecRefId], MSG_WARNING);
+ //raise Exception.Create(Format('record of type ''%s'' with id ''%s'' links to inexistant record of type ''%s'' with id ''%s''', [rec.mName, rec.mId, fld.mEBSTypeName, fld.mRecRefId]));
+ end;
//writeln(' ', rec.mName, '.', rec.mId, ':', fld.mName, ' -> ', rt.mName, '.', rt.mId, ' (', fld.mEBSTypeName, '.', fld.mRecRefId, ')');
fld.mRecRefId := '';
fld.mRecRef := rt;
if (btype = 0) then break; // no more blocks
readLongWord(st); // reserved
bsize := readLongInt(st);
- //writeln('btype=', btype, '; bsize=', bsize);
+ {$IF DEFINED(D2D_XDYN_DEBUG)}writeln('btype=', btype, '; bsize=', bsize);{$ENDIF}
if (bsize < 0) or (bsize > $1fffffff) then raise Exception.Create(Format('block of type %d has invalid size %d', [btype, bsize]));
if loaded[btype] then raise Exception.Create(Format('block of type %d already loaded', [btype]));
loaded[btype] := true;
diff --git a/src/tools/mapcvt.dpr b/src/tools/mapcvt.dpr
index cd02ab9b5d1c4fdf259d4bd281345745eb6bdccb..71784e27c7b9f02124177b401616b33a2e3f1fe8 100644 (file)
--- a/src/tools/mapcvt.dpr
+++ b/src/tools/mapcvt.dpr
uses
SysUtils, Classes,
+ sfs in '../sfs/sfs.pas',
+ sfsPlainFS in '../sfs/sfsPlainFS.pas',
+ sfsZipFS in '../sfs/sfsZipFS.pas',
xstreams in '../shared/xstreams.pas',
xparser in '../shared/xparser.pas',
xdynrec in '../shared/xdynrec.pas',
xprofiler in '../shared/xprofiler.pas',
utils in '../shared/utils.pas',
+ conbuf in '../shared/conbuf.pas',
+ e_log in '../engine/e_log.pas',
+ wadreader in '../shared/wadreader.pas',
MAPDEF in '../shared/MAPDEF.pas';
outname: AnsiString = '';
totext: Integer = -1; // <0: guess; force outname extension
sign: packed array[0..3] of AnsiChar;
+ wad: TWADFile = nil;
+ waddata: Pointer;
+ waddlen: Integer;
begin
if (ParamCount = 0) then
begin
if (ParamCount = 1) then
begin
outname := forceFilenameExt(ParamStr(1), '');
+ if isWadPath(outname) then
+ begin
+ outname := SFSReplacePathDelims(g_ExtractFilePathName(outname), '/');
+ if (Length(outname) = 0) then begin writeln('FATAL: can''t guess output name!'); Halt(1); end;
+ end;
end
else
begin
end;
//writeln('outname: [', outname, ']; totext=', totext);
+ e_InitWritelnDriver();
+ conbufDumpToStdOut := true;
+ conbufConPrefix := false;
+
writeln('parsing "mapdef.txt"...');
//pr := TFileTextParser.Create('mapdef.txt');
pr := TStrTextParser.Create(defaultMapDef);
end;
writeln('parsing "', inname, '"...');
- st := openDiskFileRO(inname);
+
+ if isWadPath(inname) then
+ begin
+ wad := TWADFile.Create();
+ wad.ReadFile(g_ExtractWadName(inname));
+ wad.GetMapResource(g_ExtractFilePathName(inname), waddata, waddlen);
+ st := TSFSMemoryChunkStream.Create(waddata, waddlen, true);
+ wad.Free();
+ end
+ else
+ begin
+ st := openDiskFileRO(inname);
+ end;
+
st.ReadBuffer(sign, 4);
st.position := 0;
if (sign[0] = 'M') and (sign[1] = 'A') and (sign[2] = 'P') and (sign[3] = #1) then
map := dfmapdef.parseBinMap(st);
stt := curTimeMicro()-stt;
writeln('binary map parsed in ', stt div 1000, '.', stt mod 1000, ' microseconds');
+ st.Free();
end
else
begin
diff --git a/src/tools/mapgen.dpr b/src/tools/mapgen.dpr
index bb38d087d8e153896ac54b725dc86839ad4fb190..32db7726c3f03d841708a271cfea9c7ec4a56377 100644 (file)
--- a/src/tools/mapgen.dpr
+++ b/src/tools/mapgen.dpr
xstreams in '../shared/xstreams.pas',
xparser in '../shared/xparser.pas',
xdynrec in '../shared/xdynrec.pas',
- utils in '../shared/utils.pas';
+ utils in '../shared/utils.pas',
+ conbuf in '../shared/conbuf.pas',
+ e_log in '../engine/e_log.pas';
// ////////////////////////////////////////////////////////////////////////// //
begin
//writeln(getFilenamePath(ParamStr(0)), '|');
+ e_InitWritelnDriver();
+ conbufDumpToStdOut := true;
+ conbufConPrefix := false;
+
writeln('parsing "mapdef.txt"...');
try
st := openDiskFileRO('mapdef.txt');