Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Apr 3, 2013
1 parent 6b925b3 commit e62d9bb
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 133 deletions.
5 changes: 0 additions & 5 deletions doomsday/client/include/map/gamemap.h
Expand Up @@ -391,11 +391,6 @@ class GameMap
void updateSurfacesOnMaterialChange(Material &material);
};

/**
* Change the global "current" map.
*/
void P_SetCurrentMap(GameMap *map);

/**
* Retrieve an immutable copy of the LOS trace line.
*
Expand Down
44 changes: 18 additions & 26 deletions doomsday/client/include/map/p_mapdata.h
Expand Up @@ -35,13 +35,13 @@ typedef struct mapentitypropertydef_s {
int id;

/// Entity-unique name for this property.
char* name;
char *name;

/// Value type identifier for this property.
valuetype_t type;

/// Entity definition which owns this property.
struct mapentitydef_s* entity;
struct mapentitydef_s *entity;
} MapEntityPropertyDef;

/**
Expand All @@ -53,7 +53,7 @@ typedef struct mapentitydef_s {

/// Set of known properties for this entity.
uint numProps;
MapEntityPropertyDef* props;
MapEntityPropertyDef *props;

#ifdef __cplusplus
mapentitydef_s(int _id) : id(_id), numProps(0), props(0) {}
Expand All @@ -69,24 +69,26 @@ extern "C" {
*
* @param def MapEntityDef instance.
* @param propertyId Entity-unique identifier for the property to lookup.
* @param retDef If not @c NULL, the found property definition is written here (else @c 0 if not found).
* @param retDef If not @c NULL, the found property definition is
* written here (else @c 0 if not found).
*
* @return Logical index of the found property (zero-based) else @c -1 if not found.
*/
int MapEntityDef_Property2(MapEntityDef* def, int propertyId, MapEntityPropertyDef** retDef);
int MapEntityDef_Property(MapEntityDef* def, int propertyId/*,MapEntityPropertyDef** retDef = NULL*/);
int MapEntityDef_Property2(MapEntityDef *def, int propertyId,
MapEntityPropertyDef **retDef = 0);

/**
* Lookup a defined property by name.
*
* @param def MapEntityDef instance.
* @param propertyName Entity-unique name for the property to lookup.
* @param retDef If not @c NULL, the found property definition is written here (else @c 0 if not found).
* @param retDef If not @c NULL, the found property definition is
* written here (else @c 0 if not found).
*
* @return Logical index of the found property (zero-based) else @c -1 if not found.
*/
int MapEntityDef_PropertyByName2(MapEntityDef* def, const char* propertyName, MapEntityPropertyDef** retDef);
int MapEntityDef_PropertyByName(MapEntityDef* def, const char* propertyName/*,MapEntityPropertyDef** retDef = NULL*/);
int MapEntityDef_PropertyByName(MapEntityDef *def, char const *propertyName,
MapEntityPropertyDef **retDef = 0);

/**
* Lookup a MapEntityDef by unique identfier @a id.
Expand All @@ -95,7 +97,7 @@ int MapEntityDef_PropertyByName(MapEntityDef* def, const char* propertyName/*,Ma
*
* @return Found MapEntityDef else @c NULL.
*/
MapEntityDef* P_MapEntityDef(int id);
MapEntityDef *P_MapEntityDef(int id);

/**
* Lookup a MapEntityDef by unique name.
Expand All @@ -104,7 +106,7 @@ MapEntityDef* P_MapEntityDef(int id);
*
* @return Found MapEntityDef else @c NULL.
*/
MapEntityDef* P_MapEntityDefByName(char const* name);
MapEntityDef *P_MapEntityDefByName(char const *name);

/**
* Lookup the unique name associated with MapEntityDef @a def.
Expand All @@ -113,7 +115,7 @@ MapEntityDef* P_MapEntityDefByName(char const* name);
*
* @return Unique name associated with @a def if found, else a zero-length string.
*/
AutoStr* P_NameForMapEntityDef(MapEntityDef* def);
AutoStr *P_NameForMapEntityDef(MapEntityDef *def);

#ifdef __cplusplus
} // extern "C"
Expand All @@ -125,28 +127,18 @@ AutoStr* P_NameForMapEntityDef(MapEntityDef* def);
extern "C" {
#endif

boolean P_SetMapEntityProperty(EntityDatabase* db, MapEntityPropertyDef* propertyDef, uint elementIndex, valuetype_t valueType, void* valueAdr);

/*
byte P_GetGMOByte(int entityId, uint elementIndex, int propertyId);
short P_GetGMOShort(int entityId, uint elementIndex, int propertyId);
int P_GetGMOInt(int entityId, uint elementIndex, int propertyId);
fixed_t P_GetGMOFixed(int entityId, uint elementIndex, int propertyId);
angle_t P_GetGMOAngle(int entityId, uint elementIndex, int propertyId);
float P_GetGMOFloat(int entityId, uint elementIndex, int propertyId);
*/

extern Uri* mapUri;
boolean P_SetMapEntityProperty(EntityDatabase *db, MapEntityPropertyDef *propertyDef,
uint elementIndex, valuetype_t valueType, void* valueAdr);

/**
* To be called to initialize the game map object defs.
*/
void P_InitMapEntityDefs(void);
void P_InitMapEntityDefs();

/**
* To be called to free all memory allocated for the map obj defs.
*/
void P_ShutdownMapEntityDefs(void);
void P_ShutdownMapEntityDefs();

#ifdef __cplusplus
} // extern "C"
Expand Down
4 changes: 3 additions & 1 deletion doomsday/client/src/dd_main.cpp
Expand Up @@ -1481,8 +1481,10 @@ bool DD_ChangeGame(de::Game& game, bool allowReload = false)
// Clear player data, too, since we just lost all clmobjs.
Cl_InitPlayers();

P_SetCurrentMap(0);
// Most memory is allocated from the zone.
//Z_FreeTags(PU_MAP, PU_PURGELEVEL - 1);
Z_FreeTags(PU_GAMESTATIC, PU_PURGELEVEL - 1);
theMap = 0;

P_ShutdownMapEntityDefs();

Expand Down
2 changes: 1 addition & 1 deletion doomsday/client/src/edit_map.cpp
Expand Up @@ -2019,7 +2019,7 @@ boolean MPE_GameObjProperty(char const *entityName, uint elementIndex,

// Is this a known property?
MapEntityPropertyDef *propertyDef;
if(MapEntityDef_PropertyByName2(entityDef, propertyName, &propertyDef) < 0)
if(MapEntityDef_PropertyByName(entityDef, propertyName, &propertyDef) < 0)
{
Con_Message("Warning: MPE_GameObjProperty: Entity \"%s\" has no \"%s\" property, ignoring.",
entityName, propertyName);
Expand Down
5 changes: 2 additions & 3 deletions doomsday/client/src/map/dam_main.cpp
Expand Up @@ -352,9 +352,8 @@ boolean DAM_AttemptMapLoad(uri_s const *_uri)

map->_effectiveGravity = map->_globalGravity;

// @todo should be called from P_LoadMap() but R_InitMap requires the
// theMap to be set first.
P_SetCurrentMap(map);
/// @todo Should be done in P_LoadMap() (note: R_InitMap)
theMap = map;

#ifdef __CLIENT__
Rend_RadioInitForMap();
Expand Down

0 comments on commit e62d9bb

Please sign in to comment.