result := dfmapdef.parseMap(pr);
except on e: Exception do
begin
- if (pr <> nil) then e_LogWritefln('ERROR at (%s,%s): %s', [pr.line, pr.col, e.message])
+ if (pr <> nil) then e_LogWritefln('ERROR at (%s,%s): %s', [pr.tokLine, pr.tokCol, e.message])
else e_LogWritefln('ERROR: %s', [e.message]);
pr.Free(); // will free `wst`
result := nil;
FreeMem(Data);
+ if (mapReader = nil) then
+ begin
+ e_LogWritefln('invalid map file: ''%s''', [mapResName]);
+ exit;
+ end;
+
generateExternalResourcesList(mapReader);
mapTextureList := mapReader['texture'];
// get all other lists here too
FreeMem(Data);
+ if (mapReader = nil) then exit;
+
if (mapReader.Width > 0) and (mapReader.Height > 0) then
begin
Result.Name := mapReader.MapName;
tk: AnsiString;
edim: AnsiChar;
begin
+ if (pr.tokType = pr.TTEOF) then raise Exception.Create('field value expected');
+ if (pr.tokType = pr.TTSemi) then raise Exception.Create('extra semicolon');
// if this field should contain struct, convert type and parse struct
case mEBS of
TEBS.TNone: begin end;
begin
if (mRec2Free <> nil) then
begin
- for rec in mRec2Free do if (rec <> self) then rec.Free();
+ for rec in mRec2Free do
+ begin
+ if (rec <> self) then
+ begin
+ //writeln('freeing: ', LongWord(rec));
+ rec.Free();
+ end;
+ end;
mRec2Free.Free();
mRec2Free := nil;
end;
// fields
{$IF DEFINED(D2D_DYNREC_PROFILER)}stt := curTimeMicro();{$ENDIF}
+ //writeln('0: <', mName, '.', pr.tokStr, '>');
fld := field[pr.tokStr];
+ //writeln('1: <', mName, '.', pr.tokStr, '>');
{$IF DEFINED(D2D_DYNREC_PROFILER)}profFieldSearching := curTimeMicro()-stt;{$ENDIF}
if (fld <> nil) then
begin
+ //writeln('2: <', mName, '.', pr.tokStr, '>');
if fld.defined then raise Exception.Create(Format('duplicate field ''%s'' in record ''%s''', [fld.mName, mName]));
if fld.internal then raise Exception.Create(Format('internal field ''%s'' in record ''%s''', [fld.mName, mName]));
- pr.skipToken();
+ pr.skipToken(); // skip field name
+ //writeln('3: <', mName, '.', pr.tokStr, '>:', pr.tokType);
{$IF DEFINED(D2D_DYNREC_PROFILER)}stt := curTimeMicro();{$ENDIF}
fld.parseValue(pr);
{$IF DEFINED(D2D_DYNREC_PROFILER)}profFieldValParsing := curTimeMicro()-stt;{$ENDIF}