diff --git a/doomsday/client/client.pro b/doomsday/client/client.pro index 79d29d1e03..64231ac626 100644 --- a/doomsday/client/client.pro +++ b/doomsday/client/client.pro @@ -263,7 +263,6 @@ DENG_HEADERS += \ include/map/p_particle.h \ include/map/p_players.h \ include/map/p_polyobjs.h \ - include/map/p_sight.h \ include/map/p_ticker.h \ include/map/plane.h \ include/map/polyobj.h \ diff --git a/doomsday/client/include/de_play.h b/doomsday/client/include/de_play.h index 72b4f6e13f..1735438945 100644 --- a/doomsday/client/include/de_play.h +++ b/doomsday/client/include/de_play.h @@ -41,7 +41,6 @@ #include "map/p_intercept.h" #include "map/p_maputil.h" #include "map/p_particle.h" -#include "map/p_sight.h" #include "map/p_ticker.h" #include "map/p_players.h" #include "map/p_objlink.h" diff --git a/doomsday/client/include/map/gamemap.h b/doomsday/client/include/map/gamemap.h index b29ab8c8d4..3c465752ae 100644 --- a/doomsday/client/include/map/gamemap.h +++ b/doomsday/client/include/map/gamemap.h @@ -91,8 +91,6 @@ class GameMap boolean inited; } thinkers; - struct generators_s *generators; - // Client only data: cmhash_t clMobjHash[CLIENT_MOBJ_HASH_SIZE]; @@ -108,7 +106,7 @@ class GameMap uint numPolyObjs; Polyobj **polyObjs; - de::MapElement *bsp; + de::MapElement *_bspRoot; /// BSP object LUTs: HEdges hedges; @@ -118,6 +116,8 @@ class GameMap EntityDatabase *entityDatabase; private: + struct generators_s *_generators; + PlaneSet _trackedPlanes; SurfaceSet _scrollingSurfaces; #ifdef __CLIENT__ @@ -132,7 +132,7 @@ class GameMap struct blockmap_s *bspLeafBlockmap; nodepile_t mobjNodes, lineNodes; // All kinds of wacky links. - nodeindex_t* lineLinks; // Indices to roots. + nodeindex_t *lineLinks; // Indices to roots. coord_t globalGravity; // The defined gravity for this map. coord_t effectiveGravity; // The effective gravity for this map. @@ -159,12 +159,62 @@ class GameMap uint lineCount() const { return lines.size(); } + /** + * Returns the root element for the map's BSP tree. + */ + de::MapElement *bspRoot() const; + uint hedgeCount() const { return hedges.count(); } uint bspNodeCount() const { return bspNodes.count(); } uint bspLeafCount() const { return bspLeafs.count(); } + /** + * Determine the BSP leaf on the back side of the BS partition that lies in front + * of the specified point within the map's coordinate space. + * + * @note Always returns a valid BspLeaf although the point may not actually lay + * within it (however it is on the same side of the space partition)! + * + * @param point XY coordinates of the point to test. + * + * @return BspLeaf instance for that BSP node's leaf. + */ + BspLeaf *bspLeafAtPoint(const_pvec2d_t point); + + /** + * @copybrief bspLeafAtPoint() + * @param x X coordinate of the point to test. + * @param y Y coordinate of the point to test. + * @return BspLeaf instance for that BSP node's leaf. + */ + inline BspLeaf *bspLeafAtPoint(coord_t x, coord_t y) { + coord_t point[2] = { x, y }; + return bspLeafAtPoint(point); + } + + /** + * Traces a line of sight. + * + * @param from World position, trace origin coordinates. + * @param to World position, trace target coordinates. + * @param flags Line Sight Flags (LS_*) @ref lineSightFlags + * + * @return @c true if the traverser function returns @c true + * for all visited lines. + */ + bool lineOfSight(const_pvec3d_t from, const_pvec3d_t to, coord_t bottomSlope, + coord_t topSlope, int flags); + + /** + * Retrieve a pointer to the Generators collection for the map. If no collection + * has yet been constructed a new empty collection will be initialized. + * + * @return Generators collection for the map. + */ + struct generators_s *generators(); + #ifdef __CLIENT__ /** @@ -674,16 +724,6 @@ boolean GameMap_ClMobjIterator(GameMap *map, boolean (*callback) (struct mobj_s struct clplane_s *GameMap_NewClPlane(GameMap *map, uint sectornum, clplanetype_t type, coord_t dest, float speed); -/** - * Retrieve a pointer to the Generators collection for this map. - * If no collection has yet been constructed a new empty collection will be - * initialized as a result of this call. - * - * @param map GameMap instance. - * @return Generators collection for this map. - */ -struct generators_s *GameMap_Generators(GameMap *map); - /** * Initialize all Polyobjs in the map. To be called after map load. * @@ -801,37 +841,16 @@ int GameMap_BspNodeIterator(GameMap *map, int (*callback) (BspNode *, void *), v * interceptable object linked within Blockmap cells which cover the path this * defines. */ -int GameMap_PathTraverse2(GameMap *map, const_pvec2d_t from, const_pvec2d_t to, - int flags, traverser_t callback, void *parameters); int GameMap_PathTraverse(GameMap *map, const_pvec2d_t from, const_pvec2d_t to, - int flags, traverser_t callback/* void* parameters=NULL*/); - -int GameMap_PathXYTraverse2(GameMap *map, coord_t fromX, coord_t fromY, coord_t toX, coord_t toY, - int flags, traverser_t callback, void *parameters); -int GameMap_PathXYTraverse(GameMap *map, coord_t fromX, coord_t fromY, coord_t toX, coord_t toY, - int flags, traverser_t callback); + int flags, traverser_t callback, void *parameters = 0); -/** - * Determine the BSP leaf on the back side of the BS partition that lies in front - * of the specified point within the map's coordinate space. - * - * @note Always returns a valid BspLeaf although the point may not actually lay - * within it (however it is on the same side of the space partition)! - * - * @param map GameMap instance. - * @param x X coordinate of the point to test. - * @param y Y coordinate of the point to test. - * @return BspLeaf instance for that BSP node's leaf. - */ -BspLeaf *GameMap_BspLeafAtPointXY(GameMap *map, coord_t x, coord_t y); - -/** - * @copybrief GameMap_BspLeafAtPointXY() - * @param map GameMap instance. - * @param point XY coordinates of the point to test. - * @return BspLeaf instance for that BSP node's leaf. - */ -BspLeaf *GameMap_BspLeafAtPoint(GameMap *map, coord_t const point[2]); +inline int GameMap_PathTraverse(GameMap *map, coord_t fromX, coord_t fromY, + coord_t toX, coord_t toY, int flags, traverser_t callback, void *parameters = 0) +{ + coord_t from[2] = { fromX, fromY }; + coord_t to[2] = { toX, toY }; + return GameMap_PathTraverse(map, from, to, flags, callback, parameters); +} /** * Private member functions: diff --git a/doomsday/client/include/map/p_sight.h b/doomsday/client/include/map/p_sight.h deleted file mode 100644 index 8c3a68750d..0000000000 --- a/doomsday/client/include/map/p_sight.h +++ /dev/null @@ -1,41 +0,0 @@ -/** - * @file p_sight.h - * Gamemap Line of Sight Testing. @ingroup map - * - * @authors Copyright © 2003-2013 Jaakko Keränen - * @authors Copyright © 2006-2013 Daniel Swanson - * - * @par License - * GPL: http://www.gnu.org/licenses/gpl.html - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. This program is distributed in the hope that it - * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General - * Public License for more details. You should have received a copy of the GNU - * General Public License along with this program; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA - */ - -#ifndef LIBDENG_MAP_GAMEMAP_SIGHT_H -#define LIBDENG_MAP_GAMEMAP_SIGHT_H - -#include "gamemap.h" - -/** - * Traces a line of sight. - * - * @param from World position, trace origin coordinates. - * @param to World position, trace target coordinates. - * @param flags Line Sight Flags (LS_*) @ref lineSightFlags - * - * @return @c true if the traverser function returns @c true - * for all visited lines. - */ -boolean GameMap_CheckLineSight(GameMap *map, const_pvec3d_t from, const_pvec3d_t to, - coord_t bottomSlope, coord_t topSlope, int flags); - -#endif // LIBDENG_MAP_GAMEMAP_SIGHT_H diff --git a/doomsday/client/src/audio/s_environ.cpp b/doomsday/client/src/audio/s_environ.cpp index 4e53202b81..8bd8250822 100644 --- a/doomsday/client/src/audio/s_environ.cpp +++ b/doomsday/client/src/audio/s_environ.cpp @@ -306,7 +306,7 @@ static boolean calcBspLeafReverb(BspLeaf *bspLeaf) bspLeaf->_reverb[SRD_DAMPING] = v; /* DEBUG_Message(("bspLeaf %04i: vol:%3i sp:%3i dec:%3i dam:%3i\n", - GameMap_BspLeafIndex(theMap, (bspLeaf), bspLeaf->reverb[SRD_VOLUME], + GameMap_BspLeafIndex(theMap, bspLeaf), bspLeaf->reverb[SRD_VOLUME], bspLeaf->reverb[SRD_SPACE], bspLeaf->reverb[SRD_DECAY], bspLeaf->reverb[SRD_DAMPING])); */ diff --git a/doomsday/client/src/client/cl_main.cpp b/doomsday/client/src/client/cl_main.cpp index c5df730108..6cd8cb549e 100644 --- a/doomsday/client/src/client/cl_main.cpp +++ b/doomsday/client/src/client/cl_main.cpp @@ -1,4 +1,4 @@ -/** @file +/** @file cl_main.cpp Network Client * * @authors Copyright © 2003-2013 Jaakko Keränen * @authors Copyright © 2006-2013 Daniel Swanson @@ -17,12 +17,6 @@ * http://www.gnu.org/licenses */ -/** - * cl_main.c: Network Client - */ - -// HEADER FILES ------------------------------------------------------------ - #include #include #include @@ -35,24 +29,11 @@ #include "de_misc.h" #include "de_play.h" +#include "map/gamemap.h" #include "render/r_main.h" -// MACROS ------------------------------------------------------------------ - -// TYPES ------------------------------------------------------------------- - -// EXTERNAL FUNCTION PROTOTYPES -------------------------------------------- - -// PUBLIC FUNCTION PROTOTYPES ---------------------------------------------- - -// PRIVATE FUNCTION PROTOTYPES --------------------------------------------- - -// EXTERNAL DATA DECLARATIONS ---------------------------------------------- - extern int gotFrame; -// PUBLIC DATA DEFINITIONS ------------------------------------------------- - ident_t clientID; boolean handshakeReceived = false; int gameReady = false; @@ -60,10 +41,6 @@ int serverTime; boolean netLoggedIn = false; // Logged in to the server. int clientPaused = false; // Set by the server. -// PRIVATE DATA DEFINITIONS ------------------------------------------------ - -// CODE -------------------------------------------------------------------- - void Cl_InitID(void) { int i; diff --git a/doomsday/client/src/client/cl_sound.cpp b/doomsday/client/src/client/cl_sound.cpp index 2f1779d220..4a64ad83c9 100644 --- a/doomsday/client/src/client/cl_sound.cpp +++ b/doomsday/client/src/client/cl_sound.cpp @@ -253,7 +253,7 @@ ifdef _DEBUG Con_Printf("Cl_ReadSoundDelta2(%i): Start snd=%i [%x] vol=%.2f", type, sound, flags, volume); if(cmo) Con_Printf(", mo=%i\n", cmo->mo.thinker.id); -else if(sector) Con_Printf(", sector=%i\n", GameMap_SectorIndex(theMap, (sector)); +else if(sector) Con_Printf(", sector=%i\n", GameMap_SectorIndex(theMap, sector)); else if(poly) Con_Printf(", poly=%i\n", GET_POLYOBJ_IDX(poly)); else Con_Printf("\n"); #endif @@ -272,7 +272,7 @@ else Con_Printf("\n"); Con_Printf("Cl_ReadSoundDelta2(%i): Stop sound %i", type, sound); if(cmo) Con_Printf(", mo=%i\n", cmo->mo.thinker.id); -else if(sector) Con_Printf(", sector=%i\n", GameMap_SectorIndex(theMap, (sector)); +else if(sector) Con_Printf(", sector=%i\n", GameMap_SectorIndex(theMap, sector)); else if(poly) Con_Printf(", poly=%i\n", GET_POLYOBJ_IDX(poly)); else Con_Printf("\n"); #endif diff --git a/doomsday/client/src/client/cl_world.cpp b/doomsday/client/src/client/cl_world.cpp index 68ae688fee..d725a6e41a 100644 --- a/doomsday/client/src/client/cl_world.cpp +++ b/doomsday/client/src/client/cl_world.cpp @@ -31,6 +31,7 @@ #include "api_map.h" #include "api_materialarchive.h" +#include "map/gamemap.h" #include "client/cl_world.h" #include "r_util.h" diff --git a/doomsday/client/src/edit_bias.cpp b/doomsday/client/src/edit_bias.cpp index 7d5c32e2df..84dac2a728 100644 --- a/doomsday/client/src/edit_bias.cpp +++ b/doomsday/client/src/edit_bias.cpp @@ -20,6 +20,9 @@ * 02110-1301 USA */ +#include +#include + #include "de_base.h" #include "de_edit.h" #include "de_system.h" @@ -31,8 +34,7 @@ #include "de_play.h" #include "de_filesys.h" -#include -#include +#include "map/gamemap.h" D_CMD(BLEditor); diff --git a/doomsday/client/src/edit_map.cpp b/doomsday/client/src/edit_map.cpp index 276a343038..531e69717e 100644 --- a/doomsday/client/src/edit_map.cpp +++ b/doomsday/client/src/edit_map.cpp @@ -1458,7 +1458,7 @@ static bool buildBsp(GameMap &map) collateVertexes(nodeBuilder, map, e_mapNumVertexes, e_mapVertexesArray); BspTreeNode *rootNode = nodeBuilder.root(); - map.bsp = rootNode->userData(); // We'll formally take ownership shortly... + map._bspRoot = rootNode->userData(); // We'll formally take ownership shortly... // Iterative pre-order traversal of the BspBuilder's map element tree. BspTreeNode *cur = rootNode; diff --git a/doomsday/client/src/map/blockmapvisual.cpp b/doomsday/client/src/map/blockmapvisual.cpp index b0e667f67e..cbec739db4 100644 --- a/doomsday/client/src/map/blockmapvisual.cpp +++ b/doomsday/client/src/map/blockmapvisual.cpp @@ -19,7 +19,9 @@ * 02110-1301 USA */ -#include +#include + +#include #include "de_base.h" #include "de_console.h" @@ -28,9 +30,10 @@ #include "de_play.h" #include "de_ui.h" -#include -#include "map/blockmapvisual.h" #include "map/blockmap.h" +#include "map/gamemap.h" + +#include "map/blockmapvisual.h" byte bmapShowDebug = 0; // 1 = mobjs, 2 = linedefs, 3 = BSP leafs, 4 = polyobjs. float bmapDebugSize = 1.5f; diff --git a/doomsday/client/src/map/dam_file.cpp b/doomsday/client/src/map/dam_file.cpp index f829b03adc..a969847fc8 100644 --- a/doomsday/client/src/map/dam_file.cpp +++ b/doomsday/client/src/map/dam_file.cpp @@ -30,6 +30,7 @@ #include "de_misc.h" #include "de_filesys.h" +#include "map/gamemap.h" #include "map/p_mapdata.h" // Global archived map format version identifier. Increment when making diff --git a/doomsday/client/src/map/dam_main.cpp b/doomsday/client/src/map/dam_main.cpp index ddfc6b41de..73d08be0a9 100644 --- a/doomsday/client/src/map/dam_main.cpp +++ b/doomsday/client/src/map/dam_main.cpp @@ -28,6 +28,10 @@ #include "de_network.h" #include "de_render.h" +#include "map/gamemap.h" + +#include "map/dam_main.h" + using namespace de; // Should we be caching successfully loaded maps? diff --git a/doomsday/client/src/map/gamemap.cpp b/doomsday/client/src/map/gamemap.cpp index cebd5b9ad3..d23747677d 100644 --- a/doomsday/client/src/map/gamemap.cpp +++ b/doomsday/client/src/map/gamemap.cpp @@ -39,35 +39,40 @@ using namespace de; GameMap::GameMap() { uri = 0; - memset(uniqueId, 0, sizeof(uniqueId)); - memset(&aaBox, 0, sizeof(aaBox)); - memset(&thinkers, 0, sizeof(thinkers)); - generators = 0; - memset(&clMobjHash, 0, sizeof(clMobjHash)); - memset(&clActivePlanes, 0, sizeof(clActivePlanes)); - memset(&clActivePolyobjs, 0, sizeof(clActivePolyobjs)); + std::memset(uniqueId, 0, sizeof(uniqueId)); + std::memset(&aaBox, 0, sizeof(aaBox)); + std::memset(&thinkers, 0, sizeof(thinkers)); + _generators = 0; + std::memset(&clMobjHash, 0, sizeof(clMobjHash)); + std::memset(&clActivePlanes, 0, sizeof(clActivePlanes)); + std::memset(&clActivePolyobjs, 0, sizeof(clActivePolyobjs)); numPolyObjs = 0; polyObjs = 0; - bsp = 0; + _bspRoot = 0; entityDatabase = 0; mobjBlockmap = 0; polyobjBlockmap = 0; lineBlockmap = 0; bspLeafBlockmap = 0; - memset(&mobjNodes, 0, sizeof(mobjNodes)); - memset(&lineNodes, 0, sizeof(lineNodes)); + std::memset(&mobjNodes, 0, sizeof(mobjNodes)); + std::memset(&lineNodes, 0, sizeof(lineNodes)); lineLinks = 0; globalGravity = 0; effectiveGravity = 0; ambientLightLevel = 0; - memset(skyFix, 0, sizeof(skyFix)); - memset(&traceOpening, 0, sizeof(traceOpening)); - memset(&traceLOS, 0, sizeof(traceLOS)); + std::memset(skyFix, 0, sizeof(skyFix)); + std::memset(&traceOpening, 0, sizeof(traceOpening)); + std::memset(&traceLOS, 0, sizeof(traceLOS)); } GameMap::~GameMap() {} +MapElement *GameMap::bspRoot() const +{ + return _bspRoot; +} + void GameMap::updateBounds() { bool isFirst = true; @@ -479,30 +484,28 @@ static void initPolyobj(Polyobj *po) P_PolyobjLink(po); } -Generators* GameMap_Generators(GameMap* map) +Generators *GameMap::generators() { - DENG2_ASSERT(map); // Time to initialize a new collection? - if(!map->generators) + if(!_generators) { - map->generators = Generators_New(map->sectorCount()); + _generators = Generators_New(sectorCount()); } - return map->generators; + return _generators; } -void GameMap_InitPolyobjs(GameMap* map) +void GameMap_InitPolyobjs(GameMap *map) { - uint i; DENG2_ASSERT(map); - for(i = 0; i < map->numPolyObjs; ++i) + for(uint i = 0; i < map->numPolyObjs; ++i) { initPolyobj(map->polyObjs[i]); } } -void GameMap_InitNodePiles(GameMap* map) +void GameMap_InitNodePiles(GameMap *map) { - uint i, starttime = 0; + uint starttime = 0; DENG2_ASSERT(map); @@ -516,7 +519,7 @@ void GameMap_InitNodePiles(GameMap* map) // Allocate the rings. map->lineLinks = (nodeindex_t *) Z_Malloc(sizeof(*map->lineLinks) * map->lineCount(), PU_MAPSTATIC, 0); - for(i = 0; i < map->lineCount(); ++i) + for(uint i = 0; i < map->lineCount(); ++i) { map->lineLinks[i] = NP_New(&map->lineNodes, NP_ROOT_NODE); } @@ -1427,7 +1430,7 @@ static int collectMobjIntercepts(uint const block[2], void* parameters) return GameMap_IterateCellMobjs(map, block, PIT_AddMobjIntercepts, NULL); } -int GameMap_PathTraverse2(GameMap *map, const_pvec2d_t from, const_pvec2d_t to, +int GameMap_PathTraverse(GameMap *map, const_pvec2d_t from, const_pvec2d_t to, int flags, traverser_t callback, void *parameters) { DENG2_ASSERT(map); @@ -1454,32 +1457,9 @@ int GameMap_PathTraverse2(GameMap *map, const_pvec2d_t from, const_pvec2d_t to, return P_TraverseIntercepts(callback, parameters); } -int GameMap_PathTraverse(GameMap *map, const_pvec2d_t from, const_pvec2d_t to, - int flags, traverser_t callback) +BspLeaf *GameMap::bspLeafAtPoint(const_pvec2d_t const point) { - return GameMap_PathTraverse2(map, from, to, flags, callback, NULL/*no parameters*/); -} - -int GameMap_PathXYTraverse2(GameMap *map, coord_t fromX, coord_t fromY, coord_t toX, coord_t toY, - int flags, traverser_t callback, void *parameters) -{ - vec2d_t from; V2d_Set(from, fromX, fromY); - vec2d_t to; V2d_Set(to, toX, toY); - return GameMap_PathTraverse2(map, from, to, flags, callback, parameters); -} - -int GameMap_PathXYTraverse(GameMap *map, coord_t fromX, coord_t fromY, coord_t toX, coord_t toY, - int flags, traverser_t callback) -{ - return GameMap_PathXYTraverse2(map, fromX, fromY, toX, toY, flags, callback, NULL/*no parameters*/); -} - -BspLeaf *GameMap_BspLeafAtPoint(GameMap *map, coord_t const point_[]) -{ - vec2d_t point; V2d_Set(point, point_? point_[VX] : 0, - point_? point_[VY] : 0); - - MapElement *bspElement = map->bsp; + MapElement *bspElement = _bspRoot; while(bspElement->type() != DMU_BSPLEAF) { BspNode const &node = *bspElement->castTo(); @@ -1490,9 +1470,3 @@ BspLeaf *GameMap_BspLeafAtPoint(GameMap *map, coord_t const point_[]) } return bspElement->castTo(); } - -BspLeaf *GameMap_BspLeafAtPointXY(GameMap *map, coord_t x, coord_t y) -{ - vec2d_t point; V2d_Set(point, x, y); - return GameMap_BspLeafAtPoint(map, point); -} diff --git a/doomsday/client/src/map/p_data.cpp b/doomsday/client/src/map/p_data.cpp index 4165d1b816..d2dbd1906c 100644 --- a/doomsday/client/src/map/p_data.cpp +++ b/doomsday/client/src/map/p_data.cpp @@ -31,6 +31,7 @@ #include "de_filesys.h" #include "Game" +#include "map/gamemap.h" #include "map/propertyvalue.h" #include "render/rend_bias.h" #include "render/vlight.h" diff --git a/doomsday/client/src/map/p_maputil.cpp b/doomsday/client/src/map/p_maputil.cpp index 38d3c7e482..1a6bec7d3d 100644 --- a/doomsday/client/src/map/p_maputil.cpp +++ b/doomsday/client/src/map/p_maputil.cpp @@ -1,4 +1,4 @@ -/** @file p_maputil.cpp +/** @file p_maputil.cpp Map Utility Routines * * @authors Copyright © 2003-2013 Jaakko Keränen * @authors Copyright © 2006-2013 Daniel Swanson @@ -17,17 +17,14 @@ * http://www.gnu.org/licenses */ -/** - * Map Utility Routines - */ - -#include +#include #include "de_base.h" #include "de_console.h" #include "de_play.h" #include "de_misc.h" +#include "map/gamemap.h" #include "render/r_main.h" // validCount #define ORDER(x,y,a,b) ( (x)<(y)? ((a)=(x),(b)=(y)) : ((b)=(x),(a)=(y)) ) @@ -49,7 +46,7 @@ } #undef P_TraceLOS -DENG_EXTERN_C const divline_t* P_TraceLOS() +DENG_EXTERN_C divline_t const *P_TraceLOS() { static divline_t emptyLOS; if(theMap) @@ -83,17 +80,17 @@ DENG_EXTERN_C void P_SetTraceOpening(LineDef *line) } #undef P_BspLeafAtPoint -DENG_EXTERN_C BspLeaf *P_BspLeafAtPoint(coord_t const point[]) +DENG_EXTERN_C BspLeaf *P_BspLeafAtPoint(const_pvec2d_t point) { if(!theMap) return NULL; - return GameMap_BspLeafAtPoint(theMap, point); + return theMap->bspLeafAtPoint(point); } #undef P_BspLeafAtPointXY DENG_EXTERN_C BspLeaf *P_BspLeafAtPointXY(coord_t x, coord_t y) { if(!theMap) return NULL; - return GameMap_BspLeafAtPointXY(theMap, x, y); + return theMap->bspLeafAtPoint(x, y); } boolean P_IsPointXYInBspLeaf(coord_t x, coord_t y, BspLeaf const *bspLeaf) @@ -130,7 +127,8 @@ boolean P_IsPointXYInSector(coord_t x, coord_t y, Sector const *sector) if(!sector) return false; // I guess? /// @todo Do not assume @a sector is from the current map. - BspLeaf *bspLeaf = GameMap_BspLeafAtPointXY(theMap, x, y); + DENG_ASSERT(theMap); + BspLeaf *bspLeaf = theMap->bspLeafAtPoint(x, y); if(bspLeaf->sectorPtr() != sector) return false; return P_IsPointXYInBspLeaf(x, y, bspLeaf); @@ -729,15 +727,15 @@ DENG_EXTERN_C int P_AllLinesBoxIterator(const AABoxd* box, int (*callback) (Line } #undef P_PathTraverse2 -DENG_EXTERN_C int P_PathTraverse2(coord_t const from[2], coord_t const to[2], int flags, traverser_t callback, - void* paramaters) +DENG_EXTERN_C int P_PathTraverse2(const_pvec2d_t from, const_pvec2d_t to, int flags, traverser_t callback, + void *parameters) { if(!theMap) return false; // Continue iteration. - return GameMap_PathTraverse2(theMap, from, to, flags, callback, paramaters); + return GameMap_PathTraverse(theMap, from, to, flags, callback, parameters); } #undef P_PathTraverse -DENG_EXTERN_C int P_PathTraverse(coord_t const from[2], coord_t const to[2], int flags, traverser_t callback) +DENG_EXTERN_C int P_PathTraverse(const_pvec2d_t from, const_pvec2d_t to, int flags, traverser_t callback) { if(!theMap) return false; // Continue iteration. return GameMap_PathTraverse(theMap, from, to, flags, callback); @@ -748,7 +746,7 @@ DENG_EXTERN_C int P_PathXYTraverse2(coord_t fromX, coord_t fromY, coord_t toX, c traverser_t callback, void* paramaters) { if(!theMap) return false; // Continue iteration. - return GameMap_PathXYTraverse2(theMap, fromX, fromY, toX, toY, flags, callback, paramaters); + return GameMap_PathTraverse(theMap, fromX, fromY, toX, toY, flags, callback, paramaters); } #undef P_PathXYTraverse @@ -756,13 +754,13 @@ DENG_EXTERN_C int P_PathXYTraverse(coord_t fromX, coord_t fromY, coord_t toX, co traverser_t callback) { if(!theMap) return false; // Continue iteration. - return GameMap_PathXYTraverse(theMap, fromX, fromY, toX, toY, flags, callback); + return GameMap_PathTraverse(theMap, fromX, fromY, toX, toY, flags, callback); } #undef P_CheckLineSight -DENG_EXTERN_C boolean P_CheckLineSight(coord_t const from[3], coord_t const to[3], coord_t bottomSlope, +DENG_EXTERN_C boolean P_CheckLineSight(const_pvec3d_t from, const_pvec3d_t to, coord_t bottomSlope, coord_t topSlope, int flags) { if(!theMap) return false; // I guess? - return GameMap_CheckLineSight(theMap, from, to, bottomSlope, topSlope, flags); + return theMap->lineOfSight(from, to, bottomSlope, topSlope, flags); } diff --git a/doomsday/client/src/map/p_objlink.cpp b/doomsday/client/src/map/p_objlink.cpp index f5bf3d74d6..9d464a5a7d 100644 --- a/doomsday/client/src/map/p_objlink.cpp +++ b/doomsday/client/src/map/p_objlink.cpp @@ -17,7 +17,7 @@ * http://www.gnu.org/licenses */ -#include +#include #include "de_base.h" #include "de_console.h" @@ -28,6 +28,9 @@ #include "de_defs.h" #include "gridmap.h" +#include "map/gamemap.h" + +#include "map/p_objlink.h" #define BLOCK_WIDTH (128) #define BLOCK_HEIGHT (128) diff --git a/doomsday/client/src/map/p_particle.cpp b/doomsday/client/src/map/p_particle.cpp index 4d887c08f5..e71ae7994f 100644 --- a/doomsday/client/src/map/p_particle.cpp +++ b/doomsday/client/src/map/p_particle.cpp @@ -92,7 +92,7 @@ static int destroyGenerator(ptcgen_t *gen, void *parameters) GameMap *map = theMap; /// @todo Do not assume generator is from the CURRENT map. - Generators_Unlink(GameMap_Generators(map), gen); + Generators_Unlink(map->generators(), gen); GameMap_ThinkerRemove(map, &gen->thinker); PtcGen_Delete(gen); @@ -133,7 +133,7 @@ static ptcgenid_t findIdForNewGenerator(Generators *gens) static ptcgen_t *P_NewGenerator() { GameMap *map = theMap; - Generators *gens = GameMap_Generators(map); + Generators *gens = map->generators(); ptcgenid_t id = findIdForNewGenerator(gens); if(id) { @@ -226,7 +226,7 @@ void P_CreatePtcGenLinks() BEGIN_PROF(PROF_PTCGEN_LINK); - Generators *gens = GameMap_Generators(theMap); + Generators *gens = theMap->generators(); Generators_EmptyLists(gens); if(useParticles) @@ -351,8 +351,8 @@ static int generatorByPlaneIterator(ptcgen_t *gen, void *parameters) static ptcgen_t *generatorByPlane(Plane *plane) { - GameMap *map = theMap; /// @todo Do not assume plane is from the CURRENT map. - Generators *gens = GameMap_Generators(map); + /// @todo Do not assume plane is from the CURRENT map. + Generators *gens = theMap->generators(); generatorbyplaneiterator_params_t parm; parm.plane = plane; parm.found = NULL; @@ -866,7 +866,7 @@ static void P_SpinParticle(ptcgen_t *gen, particle_t *pt) static int const yawSigns[4] = { 1, 1, -1, -1 }; static int const pitchSigns[4] = { 1, -1, 1, -1 }; - Generators *gens = GameMap_Generators(theMap); /// @todo Do not assume generator is from the CURRENT map. + Generators *gens = theMap->generators(); /// @todo Do not assume generator is from the CURRENT map. ded_ptcstage_t const *stDef = &gen->def->stages[pt->stage]; uint const index = pt - &gen->ptcs[Generators_GeneratorId(gens, gen) / 8]; @@ -1470,10 +1470,9 @@ static int updateGenerator(ptcgen_t *gen, void *parameters) void P_UpdateParticleGens() { - Generators* gens; - if(!theMap) return; - gens = GameMap_Generators(theMap); + + Generators *gens = theMap->generators(); if(!gens) return; // Update existing generators. diff --git a/doomsday/client/src/map/p_players.cpp b/doomsday/client/src/map/p_players.cpp index 2efaa83803..9c22deeba1 100644 --- a/doomsday/client/src/map/p_players.cpp +++ b/doomsday/client/src/map/p_players.cpp @@ -1,4 +1,4 @@ -/** @file +/** @file p_players.cpp * * @authors Copyright © 2003-2013 Jaakko Keränen * @authors Copyright © 2006-2013 Daniel Swanson @@ -17,54 +17,31 @@ * http://www.gnu.org/licenses */ -/** - * p_players.c: Players - */ - -// HEADER FILES ------------------------------------------------------------ - #define DENG_NO_API_MACROS_PLAYER #include "de_base.h" #include "de_play.h" #include "de_network.h" -// MACROS ------------------------------------------------------------------ - -// TYPES ------------------------------------------------------------------- - -// EXTERNAL FUNCTION PROTOTYPES -------------------------------------------- - -// PUBLIC FUNCTION PROTOTYPES ---------------------------------------------- +#include "map/gamemap.h" -// PRIVATE FUNCTION PROTOTYPES --------------------------------------------- - -// EXTERNAL DATA DECLARATIONS ---------------------------------------------- - -// PUBLIC DATA DEFINITIONS ------------------------------------------------- - -player_t* viewPlayer; +player_t *viewPlayer; player_t ddPlayers[DDMAXPLAYERS]; int consolePlayer; int displayPlayer; -// PRIVATE DATA DEFINITIONS ------------------------------------------------ - -// CODE -------------------------------------------------------------------- - /** * Determine which console is used by the given local player. Local players * are numbered starting from zero. */ int P_LocalToConsole(int localPlayer) { - int i, count; - - for(i = 0, count = 0; i < DDMAXPLAYERS; ++i) + int count = 0; + for(int i = 0; i < DDMAXPLAYERS; ++i) { int console = (i + consolePlayer) % DDMAXPLAYERS; - player_t* plr = &ddPlayers[console]; - ddplayer_t* ddpl = &plr->shared; + player_t *plr = &ddPlayers[console]; + ddplayer_t *ddpl = &plr->shared; if(ddpl->flags & DDPF_LOCAL) { @@ -83,8 +60,8 @@ int P_LocalToConsole(int localPlayer) */ int P_ConsoleToLocal(int playerNum) { - int i, count = 0; - player_t* plr = &ddPlayers[playerNum]; + int i, count = 0; + player_t *plr = &ddPlayers[playerNum]; if(playerNum < 0 || playerNum >= DDMAXPLAYERS) { @@ -102,7 +79,7 @@ int P_ConsoleToLocal(int playerNum) for(i = 0; i < DDMAXPLAYERS; ++i) { int console = (i + consolePlayer) % DDMAXPLAYERS; - player_t* plr = &ddPlayers[console]; + player_t *plr = &ddPlayers[console]; if(console == playerNum) { @@ -118,15 +95,13 @@ int P_ConsoleToLocal(int playerNum) /** * Given a ptr to ddplayer_t, return it's logical index. */ -int P_GetDDPlayerIdx(ddplayer_t* ddpl) +int P_GetDDPlayerIdx(ddplayer_t *ddpl) { if(ddpl) + for(uint i = 0; i < DDMAXPLAYERS; ++i) { - uint i; - - for(i = 0; i < DDMAXPLAYERS; ++i) - if(&ddPlayers[i].shared == ddpl) - return i; + if(&ddPlayers[i].shared == ddpl) + return i; } return -1; @@ -176,7 +151,7 @@ boolean P_IsInVoid(player_t *player) short P_LookDirToShort(float lookDir) { - int dir = (int) (lookDir/110.f * DDMAXSHORT); + int dir = int( lookDir/110.f * DDMAXSHORT ); if(dir < DDMINSHORT) return DDMINSHORT; if(dir > DDMAXSHORT) return DDMAXSHORT; @@ -185,23 +160,23 @@ short P_LookDirToShort(float lookDir) float P_ShortToLookDir(short s) { - return s / (float)DDMAXSHORT * 110.f; + return s / float( DDMAXSHORT ) * 110.f; } #undef DD_GetPlayer -DENG_EXTERN_C ddplayer_t* DD_GetPlayer(int number) +DENG_EXTERN_C ddplayer_t *DD_GetPlayer(int number) { return (ddplayer_t *) &ddPlayers[number].shared; } // net_main.c -DENG_EXTERN_C const char* Net_GetPlayerName(int player); +DENG_EXTERN_C char const *Net_GetPlayerName(int player); DENG_EXTERN_C ident_t Net_GetPlayerID(int player); -DENG_EXTERN_C Smoother* Net_PlayerSmoother(int player); +DENG_EXTERN_C Smoother *Net_PlayerSmoother(int player); // p_control.c -DENG_EXTERN_C void P_NewPlayerControl(int id, controltype_t type, const char *name, const char* bindContext); -DENG_EXTERN_C void P_GetControlState(int playerNum, int control, float* pos, float* relativeOffset); +DENG_EXTERN_C void P_NewPlayerControl(int id, controltype_t type, char const *name, char const *bindContext); +DENG_EXTERN_C void P_GetControlState(int playerNum, int control, float *pos, float *relativeOffset); DENG_EXTERN_C int P_GetImpulseControlState(int playerNum, int control); DENG_EXTERN_C void P_Impulse(int playerNum, int control); diff --git a/doomsday/client/src/map/p_polyobjs.cpp b/doomsday/client/src/map/p_polyobjs.cpp index 6f0b6c1ec7..9193f781ec 100644 --- a/doomsday/client/src/map/p_polyobjs.cpp +++ b/doomsday/client/src/map/p_polyobjs.cpp @@ -22,6 +22,8 @@ #include "de_base.h" #include "de_play.h" +#include "map/gamemap.h" + // Called when the polyobj hits a mobj. static void (*po_callback) (mobj_t *mobj, void *line, void *polyobj); diff --git a/doomsday/client/src/map/p_sight.cpp b/doomsday/client/src/map/p_sight.cpp index f0c4134211..c6aac40111 100644 --- a/doomsday/client/src/map/p_sight.cpp +++ b/doomsday/client/src/map/p_sight.cpp @@ -343,9 +343,9 @@ class LineSightTest } }; -boolean GameMap_CheckLineSight(GameMap *map, const_pvec3d_t from, const_pvec3d_t to, +bool GameMap::lineOfSight(const_pvec3d_t from, const_pvec3d_t to, coord_t bottomSlope, coord_t topSlope, int flags) { - DENG_ASSERT(map && map->bsp); - return LineSightTest(from, to, float(bottomSlope), float(topSlope), flags).trace(*map->bsp); + DENG_ASSERT(_bspRoot); + return LineSightTest(from, to, float(bottomSlope), float(topSlope), flags).trace(*_bspRoot); } diff --git a/doomsday/client/src/map/p_ticker.cpp b/doomsday/client/src/map/p_ticker.cpp index 54f2021108..39961f7c46 100644 --- a/doomsday/client/src/map/p_ticker.cpp +++ b/doomsday/client/src/map/p_ticker.cpp @@ -1,4 +1,4 @@ -/** @file p_ticker.cpp +/** @file p_ticker.cpp Timed Playsim Events. * * @authors Copyright © 2003-2013 Jaakko Keränen * @authors Copyright © 2006-2013 Daniel Swanson @@ -17,38 +17,15 @@ * http://www.gnu.org/licenses */ -/** - * Timed Playsim Events. - */ - -// HEADER FILES ------------------------------------------------------------ - #include "de_base.h" #include "de_network.h" #include "de_render.h" #include "de_play.h" #include "de_misc.h" +#include "map/gamemap.h" #include "render/sky.h" -// MACROS ------------------------------------------------------------------ - -// TYPES ------------------------------------------------------------------- - -// EXTERNAL FUNCTION PROTOTYPES -------------------------------------------- - -// PUBLIC FUNCTION PROTOTYPES ---------------------------------------------- - -// PRIVATE FUNCTION PROTOTYPES --------------------------------------------- - -// EXTERNAL DATA DECLARATIONS ---------------------------------------------- - -// PUBLIC DATA DEFINITIONS ------------------------------------------------- - -// PRIVATE DATA DEFINITIONS ------------------------------------------------ - -// CODE -------------------------------------------------------------------- - int P_MobjTicker(thinker_t* th, void* context) { DENG_UNUSED(context); diff --git a/doomsday/client/src/map/plane.cpp b/doomsday/client/src/map/plane.cpp index d8089626ce..13b0f5e092 100644 --- a/doomsday/client/src/map/plane.cpp +++ b/doomsday/client/src/map/plane.cpp @@ -21,10 +21,14 @@ #include "de_base.h" #include "de_console.h" #include "de_play.h" + #include "map/linedef.h" +#include "map/gamemap.h" +#include "map/surface.h" + #include "render/r_main.h" // frameTimePos -#include "map/surface.h" +#include "map/plane.h" using namespace de; diff --git a/doomsday/client/src/map/surface.cpp b/doomsday/client/src/map/surface.cpp index 4e0bbe6253..23f5d13ccd 100644 --- a/doomsday/client/src/map/surface.cpp +++ b/doomsday/client/src/map/surface.cpp @@ -18,13 +18,17 @@ * 02110-1301 USA */ +#include +#include +#include + #include "de_base.h" #include "de_play.h" #include "de_defs.h" #include "Materials" -#include -#include -#include +#include "map/gamemap.h" + +#include "map/surface.h" using namespace de; diff --git a/doomsday/client/src/render/lumobj.cpp b/doomsday/client/src/render/lumobj.cpp index 147051050c..46f40f48bf 100644 --- a/doomsday/client/src/render/lumobj.cpp +++ b/doomsday/client/src/render/lumobj.cpp @@ -32,6 +32,7 @@ #include "de_defs.h" #include "gl/sys_opengl.h" +#include "map/gamemap.h" #include "MaterialSnapshot" #include "MaterialVariantSpec" #include "Texture" diff --git a/doomsday/client/src/render/r_lgrid.cpp b/doomsday/client/src/render/r_lgrid.cpp index 852be5ac0b..1aa5d3bf08 100644 --- a/doomsday/client/src/render/r_lgrid.cpp +++ b/doomsday/client/src/render/r_lgrid.cpp @@ -37,6 +37,7 @@ #include "de_play.h" #include "gl/sys_opengl.h" +#include "map/gamemap.h" // MACROS ------------------------------------------------------------------ diff --git a/doomsday/client/src/render/r_things.cpp b/doomsday/client/src/render/r_things.cpp index eb31ddeedb..b385a196d0 100644 --- a/doomsday/client/src/render/r_things.cpp +++ b/doomsday/client/src/render/r_things.cpp @@ -35,6 +35,7 @@ #include "de_resource.h" #include "gl/sys_opengl.h" // TODO: get rid of this +#include "map/gamemap.h" #include "def_main.h" #ifdef __CLIENT__ diff --git a/doomsday/client/src/render/rend_bias.cpp b/doomsday/client/src/render/rend_bias.cpp index f3b626f82b..7a155b9a7c 100644 --- a/doomsday/client/src/render/rend_bias.cpp +++ b/doomsday/client/src/render/rend_bias.cpp @@ -29,6 +29,8 @@ #include "de_misc.h" #include "de_play.h" +#include "map/gamemap.h" + using namespace de; BEGIN_PROF_TIMERS() diff --git a/doomsday/client/src/render/rend_decor.cpp b/doomsday/client/src/render/rend_decor.cpp index bacf582fbf..d3e92d77fd 100644 --- a/doomsday/client/src/render/rend_decor.cpp +++ b/doomsday/client/src/render/rend_decor.cpp @@ -30,6 +30,8 @@ #include "def_main.h" #include "m_profiler.h" #include "MaterialVariantSpec" +#include "map/gamemap.h" + #include #include diff --git a/doomsday/client/src/render/rend_fakeradio.cpp b/doomsday/client/src/render/rend_fakeradio.cpp index a43739edd3..b5733a201e 100644 --- a/doomsday/client/src/render/rend_fakeradio.cpp +++ b/doomsday/client/src/render/rend_fakeradio.cpp @@ -31,6 +31,7 @@ #include #include "MaterialSnapshot" #include "MaterialVariantSpec" +#include "map/gamemap.h" #include "render/rendpoly.h" using namespace de; diff --git a/doomsday/client/src/render/rend_main.cpp b/doomsday/client/src/render/rend_main.cpp index d07a7336c3..fcb4125c70 100644 --- a/doomsday/client/src/render/rend_main.cpp +++ b/doomsday/client/src/render/rend_main.cpp @@ -40,6 +40,7 @@ #endif #include "Texture" #include "map/blockmapvisual.h" +#include "map/gamemap.h" #include "render/sprite.h" #include "gl/sys_opengl.h" @@ -3529,15 +3530,16 @@ void Rend_RenderMap() viewsidey = viewData->viewCos; // We don't want BSP clip checking for the first BSP leaf. + MapElement *bspRootElement = theMap->bspRoot(); firstBspLeaf = true; - if(theMap->bsp->type() == DMU_BSPNODE) + if(bspRootElement->type() == DMU_BSPNODE) { - Rend_RenderNode(theMap->bsp); + Rend_RenderNode(bspRootElement); } else { // A single leaf is a special case. - Rend_RenderBspLeaf(theMap->bsp->castTo()); + Rend_RenderBspLeaf(bspRootElement->castTo()); } if(Rend_MobjShadowsEnabled()) diff --git a/doomsday/client/src/render/rend_particle.cpp b/doomsday/client/src/render/rend_particle.cpp index 12b51a345b..d630308667 100644 --- a/doomsday/client/src/render/rend_particle.cpp +++ b/doomsday/client/src/render/rend_particle.cpp @@ -33,6 +33,7 @@ #include "resource/image.h" #include "gl/texturecontent.h" #include "map/generators.h" +#include "map/gamemap.h" using namespace de; @@ -234,12 +235,12 @@ void Rend_ParticleInitForNewFrame(void) memset(visiblePtcGens, 0, GENERATORS_MAX); } -void Rend_ParticleMarkInSectorVisible(Sector* sector) +void Rend_ParticleMarkInSectorVisible(Sector *sector) { if(!useParticles || !theMap || !sector) return; /// @todo Do the assume sector is from the CURRENT map. - gens = GameMap_Generators(theMap); + gens = theMap->generators(); if(!gens) return; Generators_IterateList(gens, GameMap_SectorIndex(theMap, sector), markPtcGenVisible, NULL/*no parameters*/); @@ -843,11 +844,11 @@ static void renderPass(boolean useBlending) assert(!Sys_GLCheckError()); } -void Rend_RenderParticles(void) +void Rend_RenderParticles() { if(!useParticles || !theMap) return; - gens = GameMap_Generators(theMap); + gens = theMap->generators(); if(!gens) return; // No visible particles at all? @@ -928,15 +929,14 @@ static int drawGeneratorOrigin(ptcgen_t* gen, void* parameters) #undef MAX_GENERATOR_DIST } -void Rend_RenderGenerators(void) +void Rend_RenderGenerators() { - float eye[3]; - if(!devDrawGenerators || !theMap) return; - gens = GameMap_Generators(theMap); + gens = theMap->generators(); if(!gens) return; + float eye[3]; eye[VX] = vOrigin[VX]; eye[VY] = vOrigin[VZ]; eye[VZ] = vOrigin[VY]; diff --git a/doomsday/client/src/render/rend_shadow.cpp b/doomsday/client/src/render/rend_shadow.cpp index 0f12c2fcae..ca53fd4229 100644 --- a/doomsday/client/src/render/rend_shadow.cpp +++ b/doomsday/client/src/render/rend_shadow.cpp @@ -23,6 +23,10 @@ #include "de_render.h" #include "de_system.h" +#include "map/gamemap.h" + +#include "render/rend_shadow.h" + typedef struct { rvertex_t vertices[4]; ColorRawf colors[4]; diff --git a/doomsday/client/src/render/sprite.cpp b/doomsday/client/src/render/sprite.cpp index 9764c70de8..46b950b5b7 100644 --- a/doomsday/client/src/render/sprite.cpp +++ b/doomsday/client/src/render/sprite.cpp @@ -30,6 +30,7 @@ #include "MaterialSnapshot" #include "MaterialVariantSpec" +#include "map/gamemap.h" #include "Texture" using namespace de; diff --git a/doomsday/server/server.pro b/doomsday/server/server.pro index 7e6b35b55a..bc51e2f236 100644 --- a/doomsday/server/server.pro +++ b/doomsday/server/server.pro @@ -215,7 +215,6 @@ DENG_HEADERS += \ $$SRC/include/map/p_particle.h \ $$SRC/include/map/p_players.h \ $$SRC/include/map/p_polyobjs.h \ - $$SRC/include/map/p_sight.h \ $$SRC/include/map/p_ticker.h \ $$SRC/include/map/plane.h \ $$SRC/include/map/polyobj.h \