- moved the blockmap into a substructure of FLevelLocals.

This part can certainly improved a lot but the most important thing, grouping all those global variables into one place, is done.
This commit is contained in:
Christoph Oelckers 2017-03-17 14:24:21 +01:00
commit 33d36157c8
10 changed files with 189 additions and 174 deletions

View file

@ -470,7 +470,7 @@ int SightCheck::P_SightBlockLinesIterator (int x, int y)
unsigned int i;
extern polyblock_t **PolyBlockMap;
offset = y*bmapwidth+x;
offset = y*level.blockmap.bmapwidth+x;
// if any of the previous blocks may contain a portal we may abort the collection of lines here, but we may not abort the sight check.
// (We still try to delay activating this for as long as possible.)
@ -498,9 +498,7 @@ int SightCheck::P_SightBlockLinesIterator (int x, int y)
polyLink = polyLink->next;
}
offset = *(blockmap + offset);
for (list = blockmaplump + offset + 1; *list != -1; list++)
for (list = level.blockmap.GetLines(x, y); *list != -1; list++)
{
if (!P_SightCheckLine (&level.lines[*list]))
{
@ -655,15 +653,15 @@ bool SightCheck::P_SightPathTraverse ()
portals.Push({ 0, topslope, bottomslope, sector_t::floor, lastsector->GetOppositePortalGroup(sector_t::floor) });
}
x1 -= bmaporgx;
y1 -= bmaporgy;
xt1 = x1 / MAPBLOCKUNITS;
yt1 = y1 / MAPBLOCKUNITS;
x1 -= level.blockmap.bmaporgx;
y1 -= level.blockmap.bmaporgy;
xt1 = x1 / FBlockmap::MAPBLOCKUNITS;
yt1 = y1 / FBlockmap::MAPBLOCKUNITS;
x2 -= bmaporgx;
y2 -= bmaporgy;
xt2 = x2 / MAPBLOCKUNITS;
yt2 = y2 / MAPBLOCKUNITS;
x2 -= level.blockmap.bmaporgx;
y2 -= level.blockmap.bmaporgy;
xt2 = x2 / FBlockmap::MAPBLOCKUNITS;
yt2 = y2 / FBlockmap::MAPBLOCKUNITS;
mapx = xs_FloorToInt(xt1);
mapy = xs_FloorToInt(yt1);
@ -741,7 +739,7 @@ bool SightCheck::P_SightPathTraverse ()
{
// end traversing when reaching the end of the blockmap
// an early out is not possible because with portals a trace can easily land outside the map's bounds.
if (mapx < 0 || mapx >= bmapwidth || mapy < 0 || mapy >= bmapheight)
if (level.blockmap.isValidBlock(mapx, mapy))
{
break;
}