Skip to content

Commit

Permalink
Refactor|GameMap: Removed more obsolete GameMap_* functions
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Apr 3, 2013
1 parent 28135c4 commit 3d26670
Show file tree
Hide file tree
Showing 12 changed files with 146 additions and 247 deletions.
56 changes: 0 additions & 56 deletions doomsday/client/include/map/gamemap.h
Expand Up @@ -532,62 +532,6 @@ int GameMap_HEdgeIndex(GameMap *map, HEdge const *hedge);
*/
int GameMap_BspNodeIndex(GameMap *map, BspNode const *bspNode);

/**
* Retrieve the number of Vertex instances owned by this.
*
* @param map GameMap instance.
* @return Number Vertexes.
*/
uint GameMap_VertexCount(GameMap *map);

/**
* Retrieve the number of LineDef instances owned by this.
*
* @param map GameMap instance.
* @return Number LineDef.
*/
uint GameMap_LineDefCount(GameMap *map);

/**
* Retrieve the number of SideDef instances owned by this.
*
* @param map GameMap instance.
* @return Number SideDef.
*/
uint GameMap_SideDefCount(GameMap *map);

/**
* Retrieve the number of Sector instances owned by this.
*
* @param map GameMap instance.
* @return Number Sector.
*/
uint GameMap_SectorCount(GameMap *map);

/**
* Retrieve the number of BspLeaf instances owned by this.
*
* @param map GameMap instance.
* @return Number BspLeaf.
*/
uint GameMap_BspLeafCount(GameMap *map);

/**
* Retrieve the number of HEdge instances owned by this.
*
* @param map GameMap instance.
* @return Number HEdge.
*/
uint GameMap_HEdgeCount(GameMap *map);

/**
* Retrieve the number of BspNode instances owned by this.
*
* @param map GameMap instance.
* @return Number BspNode.
*/
uint GameMap_BspNodeCount(GameMap *map);

/**
* Retrieve the number of Polyobj instances owned by this.
*
Expand Down
13 changes: 6 additions & 7 deletions doomsday/client/src/audio/s_environ.cpp
Expand Up @@ -143,9 +143,8 @@ static void setBspLeafSectorOwner(ownerlist_t *ownerList, BspLeaf *bspLeaf)
ownerList->head = node;
}

static void findBspLeafsAffectingSector(GameMap *map, uint secIDX)
static void findBspLeafsAffectingSector(GameMap *map, Sector *sec)
{
Sector *sec = map->sectors().at(secIDX);
if(!sec || !sec->lineCount()) return;

ownerlist_t bspLeafOwnerList;
Expand All @@ -158,7 +157,8 @@ static void findBspLeafsAffectingSector(GameMap *map, uint secIDX)
aaBox.maxY += 128;

// LOG_DEBUG("sector %u: min[x:%f, y:%f] max[x:%f, y:%f]")
// << secIDX << aaBox.minX << aaBox.minY << aaBox.maxX << aaBox.maxY;
// << GameMap_SectorIndex(map, sec)
// << aaBox.minX << aaBox.minY << aaBox.maxX << aaBox.maxY;

foreach(BspLeaf *bspLeaf, map->bspLeafs())
{
Expand Down Expand Up @@ -206,15 +206,14 @@ static void findBspLeafsAffectingSector(GameMap *map, uint secIDX)
}
}

void S_DetermineBspLeafsAffectingSectorReverb(GameMap* map)
void S_DetermineBspLeafsAffectingSectorReverb(GameMap *map)
{
uint startTime = Timer_RealMilliseconds();

/// @todo optimize: Make use of the BSP leaf blockmap.
uint numSectors = GameMap_SectorCount(map);
for(uint i = 0; i < numSectors; ++i)
foreach(Sector *sector, map->sectors())
{
findBspLeafsAffectingSector(map, i);
findBspLeafsAffectingSector(map, sector);
}

clearUnusedNodes();
Expand Down
6 changes: 3 additions & 3 deletions doomsday/client/src/client/cl_sound.cpp
Expand Up @@ -97,7 +97,7 @@ void Cl_ReadSoundDelta2(deltatype_t type, boolean skip)
{
uint index = deltaId;

if(index < GameMap_SectorCount(theMap))
if(index < theMap->sectorCount())
{
sector = theMap->sectors().at(index);
}
Expand All @@ -111,7 +111,7 @@ void Cl_ReadSoundDelta2(deltatype_t type, boolean skip)
{
uint index = deltaId;

if(index < GameMap_SideDefCount(theMap))
if(index < theMap->sideDefCount())
{
side = theMap->sideDefs().at(index);
}
Expand Down Expand Up @@ -335,7 +335,7 @@ void Cl_Sound(void)
else if(flags & SNDF_SECTOR)
{
num = Reader_ReadPackedUInt16(msgReader);
if(num >= GameMap_SectorCount(theMap))
if(num >= theMap->sectorCount())
{
Con_Message("Cl_Sound: Invalid sector number %i.", num);
return;
Expand Down
15 changes: 2 additions & 13 deletions doomsday/client/src/client/cl_world.cpp
Expand Up @@ -624,11 +624,7 @@ void Cl_ReadSectorDelta2(int deltaType, boolean /*skip*/)
ushort num = Reader_ReadUInt16(msgReader);

#ifdef _DEBUG
if(num >= GameMap_SectorCount(theMap))
{
// This is worrisome.
Con_Error("Cl_ReadSectorDelta2: Sector %i out of range.\n", num);
}
DENG_ASSERT(num < theMap->sectorCount());
#endif
Sector *sec = theMap->sectors().at(num);

Expand Down Expand Up @@ -771,14 +767,7 @@ void Cl_ReadSideDelta2(int deltaType, boolean skip)
if(skip)
return;

#ifdef _DEBUG
if(num >= GameMap_SideDefCount(theMap))
{
// This is worrisome.
Con_Error("Cl_ReadSideDelta2: Side %i out of range.\n", num);
}
#endif

DENG_ASSERT(num < theMap->sideDefCount());
SideDef *sideDef = theMap->sideDefs().at(num);

if(df & SIDF_TOP_MATERIAL)
Expand Down
19 changes: 10 additions & 9 deletions doomsday/client/src/dd_main.cpp
Expand Up @@ -2434,7 +2434,8 @@ void DD_SetInteger(int ddvalue, int parm)
* Get a pointer to the value of a variable. Not all variables support
* this. Added for 64-bit support.
*/
void* DD_GetVariable(int ddvalue)
#undef DD_GetVariable
void *DD_GetVariable(int ddvalue)
{
static uint valueU;
static float valueF;
Expand All @@ -2446,35 +2447,35 @@ void* DD_GetVariable(int ddvalue)
return &gx;

case DD_SECTOR_COUNT:
valueU = theMap? GameMap_SectorCount(theMap) : 0;
valueU = theMap? theMap->sectorCount() : 0;
return &valueU;

case DD_LINE_COUNT:
valueU = theMap? GameMap_LineDefCount(theMap) : 0;
valueU = theMap? theMap->lineCount() : 0;
return &valueU;

case DD_SIDE_COUNT:
valueU = theMap? GameMap_SideDefCount(theMap) : 0;
valueU = theMap? theMap->sideDefCount() : 0;
return &valueU;

case DD_VERTEX_COUNT:
valueU = theMap? GameMap_VertexCount(theMap) : 0;
valueU = theMap? theMap->vertexCount() : 0;
return &valueU;

case DD_POLYOBJ_COUNT:
valueU = theMap? GameMap_PolyobjCount(theMap) : 0;
return &valueU;

case DD_HEDGE_COUNT:
valueU = theMap? GameMap_HEdgeCount(theMap) : 0;
valueU = theMap? theMap->hedgeCount() : 0;
return &valueU;

case DD_BSPLEAF_COUNT:
valueU = theMap? GameMap_BspLeafCount(theMap) : 0;
valueU = theMap? theMap->bspLeafCount() : 0;
return &valueU;

case DD_BSPNODE_COUNT:
valueU = theMap? GameMap_BspNodeCount(theMap) : 0;
valueU = theMap? theMap->bspNodeCount() : 0;
return &valueU;

case DD_TRACE_ADDRESS:
Expand All @@ -2487,7 +2488,7 @@ void* DD_GetVariable(int ddvalue)
case DD_MAP_NAME:
if(theMap)
{
ded_mapinfo_t* mapInfo = Def_GetMapInfo(GameMap_Uri(theMap));
ded_mapinfo_t *mapInfo = Def_GetMapInfo(GameMap_Uri(theMap));
if(mapInfo && mapInfo->name[0])
{
int id = Def_Get(DD_DEF_TEXT, mapInfo->name, NULL);
Expand Down
28 changes: 13 additions & 15 deletions doomsday/client/src/edit_map.cpp
Expand Up @@ -564,9 +564,8 @@ static void buildSectorBspLeafLists(GameMap &map)

#ifdef DENG2_QT_4_7_OR_NEWER
uint count = 0;
for(uint k = 0; k < map.bspLeafCount(); ++k)
foreach(BspLeaf *bspLeaf, map.bspLeafs())
{
BspLeaf *bspLeaf = map.bspLeafs[k];
if(bspLeaf->sectorPtr() == sector)
++count;
}
Expand All @@ -576,9 +575,8 @@ static void buildSectorBspLeafLists(GameMap &map)
sector->_bspLeafs.reserve(count);
#endif

for(uint i = 0; i < map.bspLeafCount(); ++i)
foreach(BspLeaf *bspLeaf, map.bspLeafs())
{
BspLeaf *bspLeaf = map.bspLeafs[i];
if(bspLeaf->sectorPtr() == sector)
{
// Ownership of the BSP leaf is not given to the sector.
Expand Down Expand Up @@ -1321,7 +1319,7 @@ static void collateBspLeafHEdges(GameMap &map, BspBuilder &builder, BspLeaf &lea

// Add this HEdge to the LUT.
hedge->_origIndex = map.hedgeCount();
map.hedges.append(hedge);
map._hedges.append(hedge);

if(hedge->hasLine())
{
Expand Down Expand Up @@ -1353,8 +1351,8 @@ static void collateBspElements(GameMap &map, BspBuilder &builder, BspTreeNode &t
builder.take(leaf);

// Add this BspLeaf to the LUT.
leaf->_index = map.bspLeafs.count();
map.bspLeafs.append(leaf);
leaf->_index = map._bspLeafs.count();
map._bspLeafs.append(leaf);

collateBspLeafHEdges(map, builder, *leaf);

Expand All @@ -1373,8 +1371,8 @@ static void collateBspElements(GameMap &map, BspBuilder &builder, BspTreeNode &t
builder.take(node);

// Add this BspNode to the LUT.
node->_index = map.bspNodes.count();
map.bspNodes.append(node);
node->_index = map._bspNodes.count();
map._bspNodes.append(node);
}

static bool buildBsp(GameMap &map)
Expand Down Expand Up @@ -1413,14 +1411,14 @@ static bool buildBsp(GameMap &map)
/*
* Take ownership of all the built map data elements.
*/
DENG2_ASSERT(map.hedges.isEmpty());
DENG2_ASSERT(map.bspLeafs.isEmpty());
DENG2_ASSERT(map.bspNodes.isEmpty());
DENG2_ASSERT(map._hedges.isEmpty());
DENG2_ASSERT(map._bspLeafs.isEmpty());
DENG2_ASSERT(map._bspNodes.isEmpty());

#ifdef DENG2_QT_4_7_OR_NEWER
map.hedges.reserve(nodeBuilder.numHEdges());
map.bspNodes.reserve(nodeBuilder.numNodes());
map.bspLeafs.reserve(nodeBuilder.numLeafs());
map._hedges.reserve(nodeBuilder.numHEdges());
map._bspNodes.reserve(nodeBuilder.numNodes());
map._bspLeafs.reserve(nodeBuilder.numLeafs());
#endif

collateVertexes(nodeBuilder, map, editMap.vertexes);
Expand Down
3 changes: 1 addition & 2 deletions doomsday/client/src/map/bsp/partitioner.cpp
Expand Up @@ -398,8 +398,7 @@ struct Partitioner::Instance
}

// Initialize line info.
uint numLines = GameMap_LineDefCount(map);
lineInfos.reserve(numLines);
lineInfos.reserve(map->lineCount());
foreach(LineDef *line, map->lines())
{
lineInfos.push_back(LineInfo(line, DIST_EPSILON));
Expand Down

0 comments on commit 3d26670

Please sign in to comment.