Skip to content

Commit

Permalink
Refactor|GameMap: Removed the now obsolete GameMap_LineDef()
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Apr 3, 2013
1 parent 3bf7714 commit d884d30
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 46 deletions.
9 changes: 0 additions & 9 deletions doomsday/client/include/map/gamemap.h
Expand Up @@ -443,15 +443,6 @@ void GameMap_InitSkyFix(GameMap *map);

void GameMap_UpdateSkyFixForSector(GameMap *map, Sector *sec);

/**
* Lookup a LineDef by its unique index.
*
* @param map GameMap instance.
* @param idx Unique index of the line.
* @return Pointer to LineDef with this index else @c NULL if @a idx is not valid.
*/
LineDef *GameMap_LineDef(GameMap *map, uint idx);

/**
* Lookup a SideDef by its unique index.
*
Expand Down
2 changes: 1 addition & 1 deletion doomsday/client/src/edit_map.cpp
Expand Up @@ -1110,7 +1110,7 @@ static void hardenPolyobjs(GameMap &dest, EditMap &e_map)
destP->lines = (LineDef **) Z_Malloc(sizeof(*destP->lines) * (destP->lineCount + 1), PU_MAP, 0);
for(uint j = 0; j < destP->lineCount; ++j)
{
LineDef *line = GameMap_LineDef(&dest, srcP->lines[j]->_origIndex - 1);
LineDef *line = dest.lines().at(srcP->lines[j]->_origIndex - 1);
HEdge *hedge = &hedges[j];

// This line belongs to a polyobj.
Expand Down
7 changes: 2 additions & 5 deletions doomsday/client/src/map/bsp/partitioner.cpp
Expand Up @@ -400,9 +400,8 @@ struct Partitioner::Instance
// Initialize line info.
uint numLines = GameMap_LineDefCount(map);
lineInfos.reserve(numLines);
for(uint i = 0; i < numLines; ++i)
foreach(LineDef *line, map->lines())
{
LineDef *line = GameMap_LineDef(map, i);
lineInfos.push_back(LineInfo(line, DIST_EPSILON));
LineInfo &lineInfo = lineInfos.back();

Expand Down Expand Up @@ -2578,10 +2577,8 @@ static AABoxd findMapBounds2(GameMap *map)
AABoxd bounds;
bool initialized = false;

for(uint i = 0; i < GameMap_LineDefCount(map); ++i)
foreach(LineDef *line, map->lines())
{
LineDef *line = GameMap_LineDef(map, i);

// Do not consider zero-length lines (already screened at a higher level).
//if(lineDefInfo(*line).flags.testFlag(LineDefInfo::ZEROLENGTH)) continue;

Expand Down
2 changes: 1 addition & 1 deletion doomsday/client/src/map/dam_file.cpp
Expand Up @@ -583,7 +583,7 @@ static void readSector(GameMap *map, uint idx)
#endif
for(int i = 0; i < lineCount; ++i)
{
LineDef *line = GameMap_LineDef(map, readLong() - 1);
LineDef *line = map->lines().at(readLong() - 1);
// Ownership of the line is not given to the sector.
s->_lines.append(line);
}
Expand Down
7 changes: 0 additions & 7 deletions doomsday/client/src/map/gamemap.cpp
Expand Up @@ -220,13 +220,6 @@ int GameMap_LineDefIndex(GameMap *map, LineDef const *line)
return map->_lines.indexOf(const_cast<LineDef *>(line)); // Bad performance: O(n)
}

LineDef *GameMap_LineDef(GameMap *map, uint idx)
{
DENG2_ASSERT(map);
if(idx >= uint( map->_lines.size() )) return 0;
return map->_lines[idx];
}

int GameMap_SideDefIndex(GameMap *map, SideDef const *side)
{
DENG2_ASSERT(map);
Expand Down
4 changes: 2 additions & 2 deletions doomsday/client/src/map/p_dmu.cpp
Expand Up @@ -339,7 +339,7 @@ void *P_ToPtr(int type, uint index)
return GameMap_HEdge(theMap, index);

case DMU_LINEDEF:
return GameMap_LineDef(theMap, index);
return theMap->lines().at(index);

case DMU_SIDEDEF:
return GameMap_SideDef(theMap, index);
Expand Down Expand Up @@ -466,7 +466,7 @@ int P_Callback(int type, uint index, void *context, int (*callback)(void *p, voi

case DMU_LINEDEF:
if(index < GameMap_LineDefCount(theMap))
return callback(GameMap_LineDef(theMap, index), context);
return callback(theMap->lines().at(index), context);
break;

case DMU_SIDEDEF:
Expand Down
4 changes: 1 addition & 3 deletions doomsday/client/src/render/r_fakeradio.cpp
Expand Up @@ -244,10 +244,8 @@ void Rend_RadioInitForMap()
AABoxd bounds;
vec2d_t point;

for(uint i = 0; i < GameMap_LineDefCount(theMap); ++i)
foreach(LineDef *line, theMap->lines())
{
LineDef *line = GameMap_LineDef(theMap, i);

if(!Rend_RadioLineCastsShadow(*line)) continue;

// For each side of the line.
Expand Down
32 changes: 14 additions & 18 deletions doomsday/client/src/render/rend_fakeradio.cpp
Expand Up @@ -1586,29 +1586,25 @@ void Rend_DrawShadowOffsetVerts()
GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE);
glEnable(GL_TEXTURE_2D);

for(uint i = 0; i < GameMap_LineDefCount(theMap); ++i)
foreach(LineDef *line, theMap->lines())
for(uint k = 0; k < 2; ++k)
{
LineDef *line = GameMap_LineDef(theMap, i);

for(uint k = 0; k < 2; ++k)
Vertex &vtx = line->vertex(k);
LineOwner const *base = vtx.firstLineOwner();
LineOwner const *own = base;
do
{
Vertex &vtx = line->vertex(k);
LineOwner const *base = vtx.firstLineOwner();
LineOwner const *own = base;
do
{
coord_t pos[3];
pos[VZ] = own->line().frontSector().floor().visHeight();
coord_t pos[3];
pos[VZ] = own->line().frontSector().floor().visHeight();

V2d_Sum(pos, vtx.origin(), own->extendedShadowOffset());
drawPoint(pos, 1, yellow);
V2d_Sum(pos, vtx.origin(), own->extendedShadowOffset());
drawPoint(pos, 1, yellow);

V2d_Sum(pos, vtx.origin(), own->innerShadowOffset());
drawPoint(pos, 1, red);
V2d_Sum(pos, vtx.origin(), own->innerShadowOffset());
drawPoint(pos, 1, red);

own = &own->next();
} while(own != base);
}
own = &own->next();
} while(own != base);
}

glDisable(GL_TEXTURE_2D);
Expand Down

0 comments on commit d884d30

Please sign in to comment.