diff --git a/src/game/g_map.pas b/src/game/g_map.pas
index 0b573c22cbd05472c84e1ea8e6e15934e3e482b8..d41d6775e28e69a574fde58c1559f77bf77bd070 100644 (file)
--- a/src/game/g_map.pas
+++ b/src/game/g_map.pas
procedure g_Map_DrawPanelShadowVolumes(lightX: Integer; lightY: Integer; radius: Integer);
// returns wall index in `gWalls` or -1
-function g_Map_traceToNearestWall (x0, y0, x1, y1: Integer; hitx: PInteger=nil; hity: PInteger=nil): Boolean;
+function g_Map_traceToNearestWall (x0, y0, x1, y1: Integer; hitx: PInteger=nil; hity: PInteger=nil): TPanel;
type
TForEachPanelCB = function (pan: TPanel): Boolean; // return `true` to stop
profMapCollision: TProfiler = nil; //WARNING: FOR DEBUGGING ONLY!
gDrawPanelList: TBinaryHeapObj = nil; // binary heap of all walls we have to render, populated by `g_Map_CollectDrawPanels()`
+
function panelTypeToTag (panelType: Word): Integer; // returns GridTagXXX
+type
+ TPanelGrid = specialize TBodyGridBase<TPanel>;
+
+var
+ mapGrid: TPanelGrid = nil;
+
+
implementation
uses
FLAG_SIGNATURE = $47414C46; // 'FLAG'
-type
- TPanelGrid = specialize TBodyGridBase<TPanel>;
-
-
function panelTypeToTag (panelType: Word): Integer;
begin
case panelType of
RespawnPoints: Array of TRespawnPoint;
FlagPoints: Array [FLAG_RED..FLAG_BLUE] of PFlagPoint;
//DOMFlagPoints: Array of TFlagPoint;
- mapGrid: TPanelGrid = nil;
procedure g_Map_ProfilersBegin ();
// wall index in `gWalls` or -1
-function g_Map_traceToNearestWall (x0, y0, x1, y1: Integer; hitx: PInteger=nil; hity: PInteger=nil): Boolean;
+function g_Map_traceToNearestWall (x0, y0, x1, y1: Integer; hitx: PInteger=nil; hity: PInteger=nil): TPanel;
var
ex, ey: Integer;
begin
- result := (mapGrid.traceRay(ex, ey, x0, y0, x1, y1, nil, (GridTagWall or GridTagDoor)) <> nil);
- if result then
+ result := mapGrid.traceRay(ex, ey, x0, y0, x1, y1, nil, (GridTagWall or GridTagDoor));
+ if (result <> nil) then
begin
if (hitx <> nil) then hitx^ := ex;
if (hity <> nil) then hity^ := ey;
pan: TPanel;
begin
tag := panelTypeToTag(tag);
- for idx := High(panels) downto 0 do
+ for idx := 0 to High(panels) do
begin
pan := panels[idx];
pan.tag := tag;
// "enabled" flag has meaning only for doors and walls (engine assumes it); but meh...
mapGrid.proxyEnabled[pan.proxyId] := pan.Enabled;
{$IFDEF MAP_DEBUG_ENABLED_FLAG}
+ {
if ((tag and (GridTagWall or GridTagDoor)) <> 0) then
begin
e_WriteLog(Format('INSERTED wall #%d(%d) enabled (%d)', [Integer(idx), Integer(pan.proxyId), Integer(mapGrid.proxyEnabled[pan.proxyId])]), MSG_NOTIFY);
end;
+ }
{$ENDIF}
end;
end;
calcBoundingBox(gLifts);
calcBoundingBox(gBlockMon);
- e_WriteLog(Format('map dimensions: (%d,%d)-(%d,%d)', [mapX0, mapY0, mapX1, mapY1]), MSG_WARNING);
+ e_WriteLog(Format('map dimensions: (%d,%d)-(%d,%d); editor size:(0,0)-(%d,%d)', [mapX0, mapY0, mapX1, mapY1, gMapInfo.Width, gMapInfo.Height]), MSG_WARNING);
+
+ if (mapX0 > 0) then mapX0 := 0;
+ if (mapY0 > 0) then mapY0 := 0;
- mapGrid := TPanelGrid.Create(mapX0-512, mapY0-512, mapX1-mapX0+1+512*2, mapY1-mapY0+1+512*2);
+ if (mapX1 < gMapInfo.Width-1) then mapX1 := gMapInfo.Width-1;
+ if (mapY1 < gMapInfo.Height-1) then mapY1 := gMapInfo.Height-1;
+
+ mapGrid := TPanelGrid.Create(mapX0-128, mapY0-128, mapX1-mapX0+1+128*2, mapY1-mapY0+1+128*2);
addPanelsToGrid(gWalls, PANEL_WALL);
addPanelsToGrid(gWalls, PANEL_CLOSEDOOR);
_textures := MapReader.GetTextures();
_texnummap := nil;
+ // Çàãðóçêà îïèñàíèÿ êàðòû:
+ e_WriteLog(' Reading map info...', MSG_NOTIFY);
+ g_Game_SetLoadingText(_lc[I_LOAD_MAP_HEADER], 0, False);
+ Header := MapReader.GetMapHeader();
+
+ with gMapInfo do
+ begin
+ Name := Header.MapName;
+ Description := Header.MapDescription;
+ Author := Header.MapAuthor;
+ MusicName := Header.MusicName;
+ SkyName := Header.SkyName;
+ Height := Header.Height;
+ Width := Header.Width;
+ end;
+
// Äîáàâëåíèå òåêñòóð â Textures[]:
if _textures <> nil then
begin
e_WriteLog('Creating map grid', MSG_NOTIFY);
mapCreateGrid();
-
// Åñëè íå LoadState, òî ñîçäàåì òðèããåðû:
if (triggers <> nil) and not gLoadGameMode then
begin
CreateMonster(monsters[a]);
end;
- // Çàãðóçêà îïèñàíèÿ êàðòû:
- e_WriteLog(' Reading map info...', MSG_NOTIFY);
- g_Game_SetLoadingText(_lc[I_LOAD_MAP_HEADER], 0, False);
- Header := MapReader.GetMapHeader();
-
MapReader.Free();
- with gMapInfo do
- begin
- Name := Header.MapName;
- Description := Header.MapDescription;
- Author := Header.MapAuthor;
- MusicName := Header.MusicName;
- SkyName := Header.SkyName;
- Height := Header.Height;
- Width := Header.Width;
- end;
-
// Çàãðóçêà íåáà:
if gMapInfo.SkyName <> '' then
begin
end
else}
begin
- mapGrid.forEachInAABB(x0, y0, wdt, hgt, checker, GridDrawableMask, true);
+ mapGrid.forEachInAABB(x0, y0, wdt, hgt, checker, GridDrawableMask);
end;
// list will be rendered in `g_game.DrawPlayer()`
end;
end
else}
begin
- mapGrid.forEachInAABB(lightX-radius, lightY-radius, radius*2, radius*2, checker, (GridTagWall or GridTagDoor), true);
+ mapGrid.forEachInAABB(lightX-radius, lightY-radius, radius*2, radius*2, checker, (GridTagWall or GridTagDoor));
end;
end;
if g_Game_IsServer and g_Game_IsNet then MH_SEND_PanelState(gWalls[ID].PanelType, ID);
{$IFDEF MAP_DEBUG_ENABLED_FLAG}
- e_WriteLog(Format('wall #%d(%d) enabled (%d) (%d,%d)-(%d,%d)', [Integer(ID), Integer(pan.proxyId), Integer(mapGrid.proxyEnabled[pan.proxyId]), pan.x, pan.y, pan.width, pan.height]), MSG_NOTIFY);
+ //e_WriteLog(Format('wall #%d(%d) enabled (%d) (%d,%d)-(%d,%d)', [Integer(ID), Integer(pan.proxyId), Integer(mapGrid.proxyEnabled[pan.proxyId]), pan.x, pan.y, pan.width, pan.height]), MSG_NOTIFY);
{$ENDIF}
end;
if g_Game_IsServer and g_Game_IsNet then MH_SEND_PanelState(pan.PanelType, ID);
{$IFDEF MAP_DEBUG_ENABLED_FLAG}
- e_WriteLog(Format('wall #%d(%d) disabled (%d) (%d,%d)-(%d,%d)', [Integer(ID), Integer(pan.proxyId), Integer(mapGrid.proxyEnabled[pan.proxyId]), pan.x, pan.y, pan.width, pan.height]), MSG_NOTIFY);
+ //e_WriteLog(Format('wall #%d(%d) disabled (%d) (%d,%d)-(%d,%d)', [Integer(ID), Integer(pan.proxyId), Integer(mapGrid.proxyEnabled[pan.proxyId]), pan.x, pan.y, pan.width, pan.height]), MSG_NOTIFY);
{$ENDIF}
end;