diff --git a/src/game/g_map.pas b/src/game/g_map.pas
index 577891f59bbd8ef187dfa536aa3b2406b22a8bdb..bbf39cb5efb7bad44613c76d9352e0cb2655b37b 100644 (file)
--- a/src/game/g_map.pas
+++ b/src/game/g_map.pas
function g_Map_ParseMap (data: Pointer; dataLen: Integer): TDynRecord;
function g_Map_ParseMap (data: Pointer; dataLen: Integer): TDynRecord;
+
+function g_Map_MinX (): Integer; inline;
+function g_Map_MinY (): Integer; inline;
+function g_Map_MaxX (): Integer; inline;
+function g_Map_MaxY (): Integer; inline;
+
const
NNF_NO_NAME = 0;
NNF_NAME_BEFORE = 1;
const
NNF_NO_NAME = 0;
NNF_NAME_BEFORE = 1;
GridTagLift = 1 shl 8; // gLifts
GridTagBlockMon = 1 shl 9; // gBlockMon
GridTagLift = 1 shl 8; // gLifts
GridTagBlockMon = 1 shl 9; // gBlockMon
+ GridTagObstacle = (GridTagStep or GridTagWall or GridTagDoor);
+ GridTagLiquid = (GridTagAcid1 or GridTagAcid2 or GridTagWater);
+
GridDrawableMask = (GridTagBack or GridTagStep or GridTagWall or GridTagDoor or GridTagAcid1 or GridTagAcid2 or GridTagWater or GridTagFore);
GridDrawableMask = (GridTagBack or GridTagStep or GridTagWall or GridTagDoor or GridTagAcid1 or GridTagAcid2 or GridTagWater or GridTagFore);
end;
end;
+// ////////////////////////////////////////////////////////////////////////// //
+function g_Map_MinX (): Integer; inline; begin if (mapGrid <> nil) then result := mapGrid.gridX0 else result := 0; end;
+function g_Map_MinY (): Integer; inline; begin if (mapGrid <> nil) then result := mapGrid.gridY0 else result := 0; end;
+function g_Map_MaxX (): Integer; inline; begin if (mapGrid <> nil) then result := mapGrid.gridX0+mapGrid.gridWidth-1 else result := 0; end;
+function g_Map_MaxY (): Integer; inline; begin if (mapGrid <> nil) then result := mapGrid.gridY0+mapGrid.gridHeight-1 else result := 0; end;
+
+
// ////////////////////////////////////////////////////////////////////////// //
var
dfmapdef: TDynMapDef = nil;
// ////////////////////////////////////////////////////////////////////////// //
var
dfmapdef: TDynMapDef = nil;
+
procedure loadMapDefinition ();
var
pr: TTextParser = nil;
procedure loadMapDefinition ();
var
pr: TTextParser = nil;
WAD: TWADFile = nil;
begin
if (dfmapdef <> nil) then exit;
WAD: TWADFile = nil;
begin
if (dfmapdef <> nil) then exit;
+
try
e_LogWritefln('parsing "mapdef.txt"...', []);
st := openDiskFileRO(DataDir+'mapdef.txt');
try
e_LogWritefln('parsing "mapdef.txt"...', []);
st := openDiskFileRO(DataDir+'mapdef.txt');
+ e_LogWritefln('found local "%smapdef.txt"', [DataDir]);
except
st := nil;
except
st := nil;
- e_LogWritefln('local "%smapdef.txt" not found', [DataDir]);
end;
end;
+
if (st = nil) then
begin
WAD := TWADFile.Create();
if (st = nil) then
begin
WAD := TWADFile.Create();
end;
end;
end;
end;
- if (st = nil) then
- begin
- //raise Exception.Create('cannot open "mapdef.txt"');
- e_LogWritefln('using default "mapdef.txt"...', [], MSG_WARNING);
- pr := TStrTextParser.Create(defaultMapDef);
- end
- else
- begin
- pr := TFileTextParser.Create(st);
+ try
+ if (st = nil) then
+ begin
+ //raise Exception.Create('cannot open "mapdef.txt"');
+ e_LogWriteln('using default "mapdef.txt"...');
+ pr := TStrTextParser.Create(defaultMapDef);
+ end
+ else
+ begin
+ pr := TFileTextParser.Create(st);
+ end;
+ except on e: Exception do
+ begin
+ e_LogWritefln('something is VERY wrong here! -- ', [e.message]);
+ raise;
+ end;
end;
try
end;
try
begin
result := nil;
if (dataLen < 4) then exit;
begin
result := nil;
if (dataLen < 4) then exit;
+
+ if (dfmapdef = nil) then writeln('need to load mapdef');
loadMapDefinition();
if (dfmapdef = nil) then raise Exception.Create('internal map loader error');
loadMapDefinition();
if (dfmapdef = nil) then raise Exception.Create('internal map loader error');
begin
// binary map
try
begin
// binary map
try
+ //e_LogWriteln('parsing binary map...');
result := dfmapdef.parseBinMap(wst);
except on e: Exception do
begin
result := dfmapdef.parseBinMap(wst);
except on e: Exception do
begin
// text map
pr := TFileTextParser.Create(wst);
try
// text map
pr := TFileTextParser.Create(wst);
try
+ //e_LogWriteln('parsing text map...');
result := dfmapdef.parseMap(pr);
except on e: Exception do
begin
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;
else e_LogWritefln('ERROR: %s', [e.message]);
pr.Free(); // will free `wst`
result := nil;
end;
pr.Free(); // will free `wst`
end;
end;
pr.Free(); // will free `wst`
end;
+ //e_LogWriteln('map parsed.');
end;
end;
end
else
begin
end
else
begin
- trigData := Trigger.trigRec.clone();
+ trigData := Trigger.trigRec.clone(nil);
end;
end;
end;
end;
FreeMem(Data);
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
generateExternalResourcesList(mapReader);
mapTextureList := mapReader['texture'];
// get all other lists here too
mapReader := g_Map_ParseMap(Data, Len);
except
mapReader := nil;
mapReader := g_Map_ParseMap(Data, Len);
except
mapReader := nil;
+ FreeMem(Data);
+ exit;
end;
FreeMem(Data);
end;
FreeMem(Data);
+ if (mapReader = nil) then exit;
+
if (mapReader.Width > 0) and (mapReader.Height > 0) then
begin
Result.Name := mapReader.MapName;
if (mapReader.Width > 0) and (mapReader.Height > 0) then
begin
Result.Name := mapReader.MapName;
end;
begin
end;
begin
+ if g_dbgpan_mplat_step then g_dbgpan_mplat_active := true;
+
UpdatePanelArray(gWalls);
UpdatePanelArray(gRenderBackgrounds);
UpdatePanelArray(gRenderForegrounds);
UpdatePanelArray(gWalls);
UpdatePanelArray(gRenderBackgrounds);
UpdatePanelArray(gRenderForegrounds);
UpdatePanelArray(gAcid2);
UpdatePanelArray(gSteps);
UpdatePanelArray(gAcid2);
UpdatePanelArray(gSteps);
+ if g_dbgpan_mplat_step then begin g_dbgpan_mplat_step := false; g_dbgpan_mplat_active := false; end;
+
if gGameSettings.GameMode = GM_CTF then
begin
for a := FLAG_RED to FLAG_BLUE do
if gGameSettings.GameMode = GM_CTF then
begin
for a := FLAG_RED to FLAG_BLUE do
if j > High(gPlayers) then j := 0;
if gPlayers[j] <> nil then
begin
if j > High(gPlayers) then j := 0;
if gPlayers[j] <> nil then
begin
- if gPlayers[j].Live and g_Obj_Collide(@Obj, @gPlayers[j].Obj) then
+ if gPlayers[j].alive and g_Obj_Collide(@Obj, @gPlayers[j].Obj) then
begin
if gPlayers[j].GetFlag(a) then Break;
end;
begin
if gPlayers[j].GetFlag(a) then Break;
end;