From f2b26fec365412474ac016751e33470ded337703 Mon Sep 17 00:00:00 2001 From: danij Date: Sun, 9 Jun 2013 17:41:21 +0100 Subject: [PATCH] Refactor|EntityDatabase: EntityDatabase now a C++ class; allocated with Map --- .../client/include/world/entitydatabase.h | 102 ++++++---- doomsday/client/include/world/map.h | 7 +- doomsday/client/include/world/p_mapdata.h | 13 -- doomsday/client/src/world/api_map.cpp | 7 +- doomsday/client/src/world/api_mapedit.cpp | 16 +- doomsday/client/src/world/entitydatabase.cpp | 189 +++++++----------- doomsday/client/src/world/map.cpp | 12 +- doomsday/client/src/world/p_data.cpp | 64 +++--- doomsday/client/src/world/world.cpp | 3 - 9 files changed, 191 insertions(+), 222 deletions(-) diff --git a/doomsday/client/include/world/entitydatabase.h b/doomsday/client/include/world/entitydatabase.h index ba41f98efa..74d4ee18e8 100644 --- a/doomsday/client/include/world/entitydatabase.h +++ b/doomsday/client/include/world/entitydatabase.h @@ -1,19 +1,6 @@ -/** - * @file entitydatabase.h - * Entity property value database. @ingroup world +/** @file world/entitydatabase.h World entity property database. * - * The EntityDatabase is used in the process of transferring mobj spawn spot - * information and stuff like line action specials from the wad map loader - * plugin via the engine, through to the game plugin. - * - * The primary reason for its existence is that the engine does not know about - * the game specific properties of the map data types. The engine does not care - * at all about the values or indeed even what properties are registered; it is - * simply a way of piping information from one part of the system to another. - * - * @todo C++ allows making this even more generic: a set/map of polymorphic objects. - * - * @author Copyright © 2007-2013 Daniel Swanson + * @authors Copyright © 2007-2013 Daniel Swanson * * @par License * GPL: http://www.gnu.org/licenses/gpl.html @@ -30,43 +17,76 @@ * 02110-1301 USA */ -#ifndef LIBDENG_MAP_ENTITYDATABASE_H -#define LIBDENG_MAP_ENTITYDATABASE_H +#ifndef DENG_WORLD_ENTITYDATABASE_H +#define DENG_WORLD_ENTITYDATABASE_H -#include "api_mapedit.h" // valuetype_t +#include +#include -#ifdef __cplusplus -class PropertyValue; +#include "api_mapedit.h" // valuetype_t +#include "world/propertyvalue.h" +#include "world/p_mapdata.h" -extern "C" { -#endif +namespace de { /** - * C Wrapper API: + * An EntityDatabase is used in the process of transferring mobj spawn spot + * information and stuff like line action specials from the wad map loader + * plugin via the engine, through to the game plugin. + * + * The primary reason for its existence is that the engine does not know about + * the game specific properties of the map data types. The engine does not care + * at all about the values or indeed even what properties are registered; it is + * simply a way of piping information from one part of the system to another. + * + * @todo C++ allows making this more generic: a set/map of polymorphic objects + * e.g., QVariant. */ +class EntityDatabase +{ +public: + EntityDatabase(); -struct mapentitydef_s; -struct mapentitypropertydef_s; - -struct entitydatabase_s; -typedef struct entitydatabase_s EntityDatabase; - -EntityDatabase* EntityDatabase_New(void); + /// @return Total number of entities by definition @a entityDef. + uint entityCount(MapEntityDef const *entityDef); -void EntityDatabase_Delete(EntityDatabase* db); + /** + * Returns @c true iff an entity with definition @a entityDef and + * @a elementIndex is known/present. + */ + bool hasEntity(MapEntityDef const *entityDef, int elementIndex); -uint EntityDatabase_EntityCount(EntityDatabase* db, struct mapentitydef_s* entityDef); + /** + * Lookup a known entity element property value in the database. + * + * @param def Definition of the property to lookup an element value for. + * @param elementIndex Unique element index of the value to lookup. + * + * @return The found PropertyValue. + */ + PropertyValue const &property(MapEntityPropertyDef const *def, int elementIndex); -boolean EntityDatabase_HasEntity(EntityDatabase* db, struct mapentitydef_s* entityDef, int elementIndex); + /** + * Replace/add a value for a known entity element property to the database. + * + * @param def Definition of the property to add an element value for. + * @param elementIndex Unique element index for the value. + * @param value The new PropertyValue. Ownership passes to this database. + */ + void setProperty(MapEntityPropertyDef const *def, int elementIndex, + PropertyValue *value); -#ifdef __cplusplus -PropertyValue const* EntityDatabase_Property(EntityDatabase* db, struct mapentitypropertydef_s* propertyDef, int elementIndex); -#endif + /// @copydoc setProperty + inline void setProperty(MapEntityPropertyDef const *def, int elementIndex, + valuetype_t valueType, void *valueAdr) + { + setProperty(def, elementIndex, BuildPropertyValue(valueType, valueAdr)); + } -boolean EntityDatabase_SetProperty(EntityDatabase* db, struct mapentitypropertydef_s* propertyDef, int elementIndex, valuetype_t valueType, void* valueAdr); +private: + DENG2_PRIVATE(d) +}; -#ifdef __cplusplus -} // extern "C" -#endif +} // namespace de -#endif // LIBDENG_MAP_ENTITYDATABASE_H +#endif // DENG_WORLD_ENTITYDATABASE_H diff --git a/doomsday/client/include/world/map.h b/doomsday/client/include/world/map.h index cd692b3d37..5cbc436ef3 100644 --- a/doomsday/client/include/world/map.h +++ b/doomsday/client/include/world/map.h @@ -24,7 +24,6 @@ #include #include -#include "EntityDatabase" #include "m_nodepile.h" #include "p_particle.h" #include "Polyobj" @@ -69,6 +68,7 @@ struct clpolyobj_s; namespace de { +class EntityDatabase; #ifdef __CLIENT__ class LightGrid; #endif @@ -131,9 +131,6 @@ class Map struct clpolyobj_s *clActivePolyobjs[CLIENT_MAX_MOVERS]; #endif - /// Map entities and element properties (things, line specials, etc...). - EntityDatabase *entityDatabase; - public: nodepile_t mobjNodes, lineNodes; // All kinds of wacky links. nodeindex_t *lineLinks; // Indices to roots. @@ -480,6 +477,8 @@ class Map */ void unlinkPolyobj(Polyobj &polyobj); + EntityDatabase &entityDatabase() const; + /** * Retrieve a pointer to the Generators collection for the map. If no collection * has yet been constructed a new empty collection will be initialized. diff --git a/doomsday/client/include/world/p_mapdata.h b/doomsday/client/include/world/p_mapdata.h index 8a0c49c825..b61f56a990 100644 --- a/doomsday/client/include/world/p_mapdata.h +++ b/doomsday/client/include/world/p_mapdata.h @@ -116,19 +116,6 @@ MapEntityDef *P_MapEntityDefByName(char const *name); */ AutoStr *P_NameForMapEntityDef(MapEntityDef *def); -#ifdef __cplusplus -} // extern "C" -#endif - -#include "../EntityDatabase" - -#ifdef __cplusplus -extern "C" { -#endif - -boolean P_SetMapEntityProperty(EntityDatabase *db, MapEntityPropertyDef *propertyDef, - int elementIndex, valuetype_t valueType, void* valueAdr); - /** * To be called to initialize the game map object defs. */ diff --git a/doomsday/client/src/world/api_map.cpp b/doomsday/client/src/world/api_map.cpp index bf9d3f7842..0fc1a0361e 100644 --- a/doomsday/client/src/world/api_map.cpp +++ b/doomsday/client/src/world/api_map.cpp @@ -35,6 +35,7 @@ #include "api_map.h" #include "world/dmuargs.h" +#include "world/entitydatabase.h" #include "world/world.h" #ifdef __CLIENT__ @@ -1532,9 +1533,9 @@ DENG_EXTERN_C boolean P_LoadMap(char const *uriCString) #undef P_CountMapObjs DENG_EXTERN_C uint P_CountMapObjs(int entityId) { - if(!App_World().hasMap() || !App_World().map().entityDatabase) return 0; - EntityDatabase *db = App_World().map().entityDatabase; - return EntityDatabase_EntityCount(db, P_MapEntityDef(entityId)); + if(!App_World().hasMap()) return 0; + EntityDatabase &entities = App_World().map().entityDatabase(); + return entities.entityCount(P_MapEntityDef(entityId)); } // p_mapdata.cpp diff --git a/doomsday/client/src/world/api_mapedit.cpp b/doomsday/client/src/world/api_mapedit.cpp index 8806c4f51f..4173a33cd4 100644 --- a/doomsday/client/src/world/api_mapedit.cpp +++ b/doomsday/client/src/world/api_mapedit.cpp @@ -27,6 +27,7 @@ #include "Materials" +#include "world/entitydatabase.h" #include "world/p_mapdata.h" #include "world/map.h" @@ -403,7 +404,7 @@ int MPE_PolyobjCreate(int *lines, int lineCount, int tag, int sequenceType, #undef MPE_GameObjProperty boolean MPE_GameObjProperty(char const *entityName, int elementIndex, - char const *propertyName, valuetype_t type, void *valueAdr) + char const *propertyName, valuetype_t valueType, void *valueAdr) { LOG_AS("MPE_GameObjProperty"); @@ -429,8 +430,17 @@ boolean MPE_GameObjProperty(char const *entityName, int elementIndex, return false; } - return P_SetMapEntityProperty(editMap->entityDatabase, - propertyDef, elementIndex, type, valueAdr); + try + { + EntityDatabase &entities = editMap->entityDatabase(); + entities.setProperty(propertyDef, elementIndex, valueType, valueAdr); + return true; + } + catch(Error const &er) + { + LOG_WARNING("%s. Ignoring.") << er.asText(); + } + return false; } // p_data.cpp diff --git a/doomsday/client/src/world/entitydatabase.cpp b/doomsday/client/src/world/entitydatabase.cpp index 8270ef3bd3..a6a7bf2216 100644 --- a/doomsday/client/src/world/entitydatabase.cpp +++ b/doomsday/client/src/world/entitydatabase.cpp @@ -18,27 +18,37 @@ * 02110-1301 USA */ +#include + +#include + #include "de_base.h" #include "world/p_mapdata.h" #include "world/propertyvalue.h" -#include -#include -#include +#include "world/entitydatabase.h" -struct entitydatabase_s +// An entity is a set of one or more properties. +// Key is the unique identifier of said property in the +// MapEntityPropertyDef it is derived from. +typedef std::map Entity; + +// Entities are stored in a set, each associated with a unique map element index. +typedef std::map Entities; + +// Entities are grouped in sets by their unique identifier. +typedef std::map EntitySet; + +namespace de { + +DENG2_PIMPL(EntityDatabase) { -private: - // An entity is a set of one or more properties. - // Key is the unique identifier of said property in the MapEntityPropertyDef it is derived from. - typedef std::map Entity; - // Entities are stored in a set, each associated with a unique map element index. - typedef std::map Entities; - // Entities are grouped in sets by their unique identifier. - typedef std::map EntitySet; - -public: - ~entitydatabase_s() + EntitySet entitySets; + + Instance(Public *i) : Base(i) + {} + + ~Instance() { DENG2_FOR_EACH(EntitySet, setIt, entitySets) DENG2_FOR_EACH(Entities, entityIt, setIt->second) @@ -48,84 +58,21 @@ struct entitydatabase_s } } - /// @return Total number of entities by definition @a entityDef. - uint entityCount(MapEntityDef const* entityDef) - { - DENG2_ASSERT(entityDef); - Entities* set = entities(entityDef->id); - return set->size(); - } - - /// @return @c true= An entity by definition @a entityDef and @a elementIndex is known/present. - bool hasEntity(MapEntityDef const* entityDef, int elementIndex) - { - DENG2_ASSERT(entityDef); - Entities* set = entities(entityDef->id); - return entityByElementIndex(*set, elementIndex, false /*do not create*/) != 0; - } - /** - * Lookup a known entity element property value in the database. - * - * @throws de::Error If @a elementIndex is out-of-range. - * - * @param def Definition of the property to lookup an element value for. - * @param elementIndex Unique element index of the value to lookup. - * - * @return The found PropertyValue. + * Lookup the set in which entities with the unique identifier + * @a entityId are stored. */ - PropertyValue const& property(MapEntityPropertyDef const* def, int elementIndex) - { - DENG2_ASSERT(def); - Entities* set = entities(def->entity->id); - Entity* entity = entityByElementIndex(*set, elementIndex, false /*do not create*/); - if(!entity) throw de::Error("property", QString("There is no element %1 of type %2") - .arg(elementIndex).arg(Str_Text(P_NameForMapEntityDef(def->entity)))); - - Entity::const_iterator found = entity->find(def->id); - DENG2_ASSERT(found != entity->end()); // Sanity check. - return *found->second; - } - - /** - * Replace/add a value for a known entity element property to the database. - * - * @param def Definition of the property to add an element value for. - * @param elementIndex Unique element index for the value. - * @param value The new PropertyValue. Ownership passes to this database. - */ - void setProperty(MapEntityPropertyDef const* def, int elementIndex, PropertyValue* value) - { - DENG2_ASSERT(def); - Entities* set = entities(def->entity->id); - Entity* entity = entityByElementIndex(*set, elementIndex, true); - if(!entity) throw de::Error("setProperty", "Failed adding new entity element record"); - - // Do we already have a record for this? - Entity::iterator found = entity->find(def->id); - if(found != entity->end()) - { - PropertyValue** adr = &found->second; - delete *adr; - *adr = value; - return; - } - - // Add a new record. - entity->insert(std::pair(def->id, value)); - } - -private: - /// Lookup the set in which entities with the unique identifier @a entityId are stored. - Entities* entities(int entityId) + Entities *entities(int entityId) { std::pair result; result = entitySets.insert(std::pair(entityId, Entities())); return &result.first->second; } - /// Lookup an entity in @a set by its unique @a elementIndex. - Entity* entityByElementIndex(Entities& set, int elementIndex, bool canCreate) + /** + * Lookup an entity in @a set by its unique @a elementIndex. + */ + Entity *entityByElementIndex(Entities& set, int elementIndex, bool canCreate) { // Do we already have a record for this entity? Entities::iterator found = set.find(elementIndex); @@ -138,46 +85,62 @@ struct entitydatabase_s result = set.insert(std::pair(elementIndex, Entity())); return &result.first->second; } - - EntitySet entitySets; }; -EntityDatabase* EntityDatabase_New(void) -{ - void* region = Z_Calloc(sizeof(entitydatabase_s), PU_MAPSTATIC, 0); - return new (region) entitydatabase_s(); -} +EntityDatabase::EntityDatabase() : d(new Instance(this)) +{} -void EntityDatabase_Delete(EntityDatabase* db) +uint EntityDatabase::entityCount(MapEntityDef const *entityDef) { - if(!db) return; - db->~entitydatabase_s(); - Z_Free(db); + DENG2_ASSERT(entityDef); + Entities *set = d->entities(entityDef->id); + return set->size(); } -uint EntityDatabase_EntityCount(EntityDatabase* db, MapEntityDef* entityDef) +bool EntityDatabase::hasEntity(MapEntityDef const *entityDef, int elementIndex) { - DENG2_ASSERT(db); - return db->entityCount(entityDef); + DENG2_ASSERT(entityDef); + Entities *set = d->entities(entityDef->id); + return d->entityByElementIndex(*set, elementIndex, false /*do not create*/) != 0; } -boolean EntityDatabase_HasEntity(EntityDatabase* db, MapEntityDef* entityDef, int elementIndex) +PropertyValue const &EntityDatabase::property(MapEntityPropertyDef const *def, + int elementIndex) { - DENG2_ASSERT(db); - return CPP_BOOL(db->hasEntity(entityDef, elementIndex)); + DENG2_ASSERT(def); + Entities *set = d->entities(def->entity->id); + Entity *entity = d->entityByElementIndex(*set, elementIndex, false /*do not create*/); + if(!entity) + throw Error("EntityDatabase::property", QString("There is no element %1 of type %2") + .arg(elementIndex) + .arg(Str_Text(P_NameForMapEntityDef(def->entity)))); + + Entity::const_iterator found = entity->find(def->id); + DENG2_ASSERT(found != entity->end()); // Sanity check. + return *found->second; } -PropertyValue const* EntityDatabase_Property(EntityDatabase* db, - struct mapentitypropertydef_s* propertyDef, int elementIndex) +void EntityDatabase::setProperty(MapEntityPropertyDef const *def, int elementIndex, + PropertyValue *value) { - DENG2_ASSERT(db); - return &db->property(propertyDef, elementIndex); -} + DENG2_ASSERT(def); + Entities *set = d->entities(def->entity->id); + Entity *entity = d->entityByElementIndex(*set, elementIndex, true); + if(!entity) + throw Error("EntityDatabase::setProperty", "Failed adding new entity element record"); + + // Do we already have a record for this? + Entity::iterator found = entity->find(def->id); + if(found != entity->end()) + { + PropertyValue **adr = &found->second; + delete *adr; + *adr = value; + return; + } -boolean EntityDatabase_SetProperty(EntityDatabase* db, MapEntityPropertyDef* propertyDef, - int elementIndex, valuetype_t valueType, void* valueAdr) -{ - DENG2_ASSERT(db); - db->setProperty(propertyDef, elementIndex, BuildPropertyValue(valueType, valueAdr)); - return true; + // Add a new record. + entity->insert(std::pair(def->id, value)); } + +} // namespace de diff --git a/doomsday/client/src/world/map.cpp b/doomsday/client/src/world/map.cpp index 8489caf9e9..3528a51763 100644 --- a/doomsday/client/src/world/map.cpp +++ b/doomsday/client/src/world/map.cpp @@ -40,6 +40,7 @@ #include "BspBuilder" #include "world/blockmap.h" +#include "world/entitydatabase.h" #include "world/generators.h" #include "world/lineowner.h" #include "world/p_intercept.h" @@ -104,6 +105,9 @@ DENG2_PIMPL(Map) BspNodes bspNodes; BspLeafs bspLeafs; + /// Map entities and element properties (things, line specials, etc...). + EntityDatabase entityDatabase; + /// Blockmaps: Blockmap *mobjBlockmap; Blockmap *polyobjBlockmap; @@ -692,7 +696,6 @@ Map::Map() : d(new Instance(this)) zap(clActivePlanes); zap(clActivePolyobjs); #endif - entityDatabase = EntityDatabase_New(); lineLinks = 0; _globalGravity = 0; _effectiveGravity = 0; @@ -708,8 +711,6 @@ Map::~Map() // mobjHash/activePlanes/activePolyobjs - free them! // End client only data. - EntityDatabase_Delete(entityDatabase); - // mobj/line/polyobj/bspLeaf blockmaps - free them! // mobjNodes/lineNodes/lineLinks - free them! } @@ -996,6 +997,11 @@ void Map::initPolyobjs() } } +EntityDatabase &Map::entityDatabase() const +{ + return d->entityDatabase; +} + Generators *Map::generators() { // Time to initialize a new collection? diff --git a/doomsday/client/src/world/p_data.cpp b/doomsday/client/src/world/p_data.cpp index 40b03bab05..49779c8fd6 100644 --- a/doomsday/client/src/world/p_data.cpp +++ b/doomsday/client/src/world/p_data.cpp @@ -285,20 +285,6 @@ void P_ShutdownMapEntityDefs() clearEntityDefs(); } -boolean P_SetMapEntityProperty(EntityDatabase *db, MapEntityPropertyDef *propertyDef, - int elementIndex, valuetype_t valueType, void *valueAdr) -{ - try - { - return EntityDatabase_SetProperty(db, propertyDef, elementIndex, valueType, valueAdr); - } - catch(Error const &er) - { - LOG_WARNING("%s. Ignoring.") << er.asText(); - } - return false; -} - static MapEntityPropertyDef *entityPropertyDef(int entityId, int propertyId) { // Is this a known entity? @@ -315,16 +301,16 @@ static MapEntityPropertyDef *entityPropertyDef(int entityId, int propertyId) return property; // Found it. } -static void setValue(void *dst, valuetype_t dstType, PropertyValue const *pvalue) +static void setValue(void *dst, valuetype_t dstType, PropertyValue const &pvalue) { switch(dstType) { - case DDVT_FIXED: *((fixed_t *) dst) = pvalue->asFixed(); break; - case DDVT_FLOAT: *( (float *) dst) = pvalue->asFloat(); break; - case DDVT_BYTE: *( (byte *) dst) = pvalue->asByte(); break; - case DDVT_INT: *( (int *) dst) = pvalue->asInt32(); break; - case DDVT_SHORT: *( (short *) dst) = pvalue->asInt16(); break; - case DDVT_ANGLE: *((angle_t *) dst) = pvalue->asAngle(); break; + case DDVT_FIXED: *((fixed_t *) dst) = pvalue.asFixed(); break; + case DDVT_FLOAT: *( (float *) dst) = pvalue.asFloat(); break; + case DDVT_BYTE: *( (byte *) dst) = pvalue.asByte(); break; + case DDVT_INT: *( (int *) dst) = pvalue.asInt32(); break; + case DDVT_SHORT: *( (short *) dst) = pvalue.asInt16(); break; + case DDVT_ANGLE: *((angle_t *) dst) = pvalue.asAngle(); break; default: throw Error("setValue", QString("Unknown value type %d").arg(dstType)); } @@ -334,14 +320,14 @@ static void setValue(void *dst, valuetype_t dstType, PropertyValue const *pvalue DENG_EXTERN_C byte P_GetGMOByte(int entityId, int elementIndex, int propertyId) { byte returnVal = 0; - if(App_World().hasMap() && App_World().map().entityDatabase) + if(App_World().hasMap()) { try { - EntityDatabase *db = App_World().map().entityDatabase; + EntityDatabase &db = App_World().map().entityDatabase(); MapEntityPropertyDef *propDef = entityPropertyDef(entityId, propertyId); - setValue(&returnVal, DDVT_BYTE, EntityDatabase_Property(db, propDef, elementIndex)); + setValue(&returnVal, DDVT_BYTE, db.property(propDef, elementIndex)); } catch(Error const &er) { @@ -355,14 +341,14 @@ DENG_EXTERN_C byte P_GetGMOByte(int entityId, int elementIndex, int propertyId) DENG_EXTERN_C short P_GetGMOShort(int entityId, int elementIndex, int propertyId) { short returnVal = 0; - if(App_World().hasMap() && App_World().map().entityDatabase) + if(App_World().hasMap()) { try { - EntityDatabase *db = App_World().map().entityDatabase; + EntityDatabase &db = App_World().map().entityDatabase(); MapEntityPropertyDef *propDef = entityPropertyDef(entityId, propertyId); - setValue(&returnVal, DDVT_SHORT, EntityDatabase_Property(db, propDef, elementIndex)); + setValue(&returnVal, DDVT_SHORT, db.property(propDef, elementIndex)); } catch(Error const &er) { @@ -376,14 +362,14 @@ DENG_EXTERN_C short P_GetGMOShort(int entityId, int elementIndex, int propertyId DENG_EXTERN_C int P_GetGMOInt(int entityId, int elementIndex, int propertyId) { int returnVal = 0; - if(App_World().hasMap() && App_World().map().entityDatabase) + if(App_World().hasMap()) { try { - EntityDatabase *db = App_World().map().entityDatabase; + EntityDatabase &db = App_World().map().entityDatabase(); MapEntityPropertyDef *propDef = entityPropertyDef(entityId, propertyId); - setValue(&returnVal, DDVT_INT, EntityDatabase_Property(db, propDef, elementIndex)); + setValue(&returnVal, DDVT_INT, db.property(propDef, elementIndex)); } catch(Error const &er) { @@ -397,14 +383,14 @@ DENG_EXTERN_C int P_GetGMOInt(int entityId, int elementIndex, int propertyId) DENG_EXTERN_C fixed_t P_GetGMOFixed(int entityId, int elementIndex, int propertyId) { fixed_t returnVal = 0; - if(App_World().hasMap() && App_World().map().entityDatabase) + if(App_World().hasMap()) { try { - EntityDatabase *db = App_World().map().entityDatabase; + EntityDatabase &db = App_World().map().entityDatabase(); MapEntityPropertyDef *propDef = entityPropertyDef(entityId, propertyId); - setValue(&returnVal, DDVT_FIXED, EntityDatabase_Property(db, propDef, elementIndex)); + setValue(&returnVal, DDVT_FIXED, db.property(propDef, elementIndex)); } catch(Error const &er) { @@ -418,14 +404,14 @@ DENG_EXTERN_C fixed_t P_GetGMOFixed(int entityId, int elementIndex, int property DENG_EXTERN_C angle_t P_GetGMOAngle(int entityId, int elementIndex, int propertyId) { angle_t returnVal = 0; - if(App_World().hasMap() && App_World().map().entityDatabase) + if(App_World().hasMap()) { try { - EntityDatabase *db = App_World().map().entityDatabase; + EntityDatabase &db = App_World().map().entityDatabase(); MapEntityPropertyDef *propDef = entityPropertyDef(entityId, propertyId); - setValue(&returnVal, DDVT_ANGLE, EntityDatabase_Property(db, propDef, elementIndex)); + setValue(&returnVal, DDVT_ANGLE, db.property(propDef, elementIndex)); } catch(Error const &er) { @@ -439,14 +425,14 @@ DENG_EXTERN_C angle_t P_GetGMOAngle(int entityId, int elementIndex, int property DENG_EXTERN_C float P_GetGMOFloat(int entityId, int elementIndex, int propertyId) { float returnVal = 0; - if(App_World().hasMap() && App_World().map().entityDatabase) + if(App_World().hasMap()) { try { - EntityDatabase *db = App_World().map().entityDatabase; + EntityDatabase &db = App_World().map().entityDatabase(); MapEntityPropertyDef *propDef = entityPropertyDef(entityId, propertyId); - setValue(&returnVal, DDVT_FLOAT, EntityDatabase_Property(db, propDef, elementIndex)); + setValue(&returnVal, DDVT_FLOAT, db.property(propDef, elementIndex)); } catch(Error const &er) { diff --git a/doomsday/client/src/world/world.cpp b/doomsday/client/src/world/world.cpp index 2f94fd3b2e..8ed24e1974 100644 --- a/doomsday/client/src/world/world.cpp +++ b/doomsday/client/src/world/world.cpp @@ -581,9 +581,6 @@ void World::setupMap(int mode) gameTime = 0; } - // We are now finished with the map entity db. - EntityDatabase_Delete(d->map->entityDatabase); - #ifdef __SERVER__ // Init server data. Sv_InitPools();