diff --git a/doomsday/engine/portable/include/gamemap.h b/doomsday/engine/portable/include/gamemap.h index 70dc86fddf..91d7dac729 100644 --- a/doomsday/engine/portable/include/gamemap.h +++ b/doomsday/engine/portable/include/gamemap.h @@ -112,7 +112,9 @@ typedef struct gamemap_s { nodepile_t mobjNodes, lineNodes; // All kinds of wacky links. nodeindex_t* lineLinks; // Indices to roots. - float globalGravity; // Gravity for the current map. + float globalGravity; // The defined gravity for this map. + float effectiveGravity; // The effective gravity for this map. + int ambientLightLevel; // Ambient lightlevel for the current map. /// Current LOS trace state. @@ -132,6 +134,31 @@ const char* GameMap_OldUniqueId(GameMap* map); void GameMap_Bounds(GameMap* map, float* min, float* max); +/** + * Retrieve the current effective gravity multiplier for this map. + * + * @param map GameMap instance. + * @return Effective gravity multiplier for this map. + */ +float GameMap_Gravity(GameMap* map); + +/** + * Change the effective gravity multiplier for this map. + * + * @param map GameMap instance. + * @param gravity New gravity multiplier. + * @return Same as @a map for caller convenience. + */ +GameMap* GameMap_SetGravity(GameMap* map, float gravity); + +/** + * Return the effective gravity multiplier to that originally defined for this map. + * + * @param map GameMap instance. + * @return Same as @a map for caller convenience. + */ +GameMap* GameMap_RestoreGravity(GameMap* map); + /** * Retrieve an immutable copy of the LOS trace line. * diff --git a/doomsday/engine/portable/include/p_mapdata.h b/doomsday/engine/portable/include/p_mapdata.h index 4efa0f3301..e7bfad32f0 100644 --- a/doomsday/engine/portable/include/p_mapdata.h +++ b/doomsday/engine/portable/include/p_mapdata.h @@ -187,8 +187,6 @@ extern surfacelist_t* movingSurfaceList; extern surfacelist_t* decoratedSurfaceList; extern surfacelist_t* glowingSurfaceList; -extern float mapGravity; - #include "gamemap.h" // The current map. diff --git a/doomsday/engine/portable/src/dam_main.c b/doomsday/engine/portable/src/dam_main.c index 4b1f0114e8..dc17083c93 100644 --- a/doomsday/engine/portable/src/dam_main.c +++ b/doomsday/engine/portable/src/dam_main.c @@ -600,6 +600,8 @@ boolean DAM_AttemptMapLoad(const Uri* uri) map->ambientLightLevel = 0; } + map->effectiveGravity = map->globalGravity; + // @todo should be called from P_LoadMap() but R_InitMap requires the // theMap to be set first. P_SetCurrentMap(map); diff --git a/doomsday/engine/portable/src/dd_main.c b/doomsday/engine/portable/src/dd_main.c index 5694757c5c..1cb14977b0 100644 --- a/doomsday/engine/portable/src/dd_main.c +++ b/doomsday/engine/portable/src/dd_main.c @@ -2215,7 +2215,8 @@ void* DD_GetVariable(int ddvalue) return &cplrThrustMul;*/ case DD_GRAVITY: - return &mapGravity; + valueF = theMap? GameMap_Gravity(theMap) : 0; + return &valueF; case DD_TORCH_RED: return &torchColor[CR]; @@ -2289,7 +2290,7 @@ void DD_SetVariable(int ddvalue, void *parm) return;*/ case DD_GRAVITY: - mapGravity = *(float*) parm; + if(theMap) GameMap_SetGravity(theMap, *(float*) parm); return; case DD_PSPRITE_OFFSET_X: diff --git a/doomsday/engine/portable/src/gamemap.c b/doomsday/engine/portable/src/gamemap.c index e41ade5391..ede8698955 100644 --- a/doomsday/engine/portable/src/gamemap.c +++ b/doomsday/engine/portable/src/gamemap.c @@ -54,6 +54,26 @@ void GameMap_Bounds(GameMap* map, float* min, float* max) max[VY] = map->bBox[BOXTOP]; } +float GameMap_Gravity(GameMap* map) +{ + assert(map); + return map->effectiveGravity; +} + +GameMap* GameMap_SetGravity(GameMap* map, float gravity) +{ + assert(map); + map->effectiveGravity = gravity; + return map; +} + +GameMap* GameMap_RestoreGravity(GameMap* map) +{ + assert(map); + map->effectiveGravity = map->globalGravity; + return map; +} + const divline_t* GameMap_TraceLOS(GameMap* map) { assert(map); diff --git a/doomsday/engine/portable/src/p_data.c b/doomsday/engine/portable/src/p_data.c index d9551712e7..ffdd415d71 100644 --- a/doomsday/engine/portable/src/p_data.c +++ b/doomsday/engine/portable/src/p_data.c @@ -64,8 +64,6 @@ surfacelist_t* movingSurfaceList = NULL; surfacelist_t* decoratedSurfaceList = NULL; surfacelist_t* glowingSurfaceList = NULL; -float mapGravity; - GameMap* theMap = NULL; // Bad texture list @@ -139,8 +137,6 @@ void P_SetCurrentMap(GameMap* map) decoratedSurfaceList = 0; glowingSurfaceList = 0; - mapGravity = 0; - theMap = map; return; } @@ -161,8 +157,6 @@ void P_SetCurrentMap(GameMap* map) decoratedSurfaceList = &map->decoratedSurfaceList; glowingSurfaceList = &map->glowingSurfaceList; - mapGravity = map->globalGravity; - theMap = map; } diff --git a/doomsday/engine/portable/src/p_particle.c b/doomsday/engine/portable/src/p_particle.c index 3df1590986..48856a6d54 100644 --- a/doomsday/engine/portable/src/p_particle.c +++ b/doomsday/engine/portable/src/p_particle.c @@ -1083,7 +1083,8 @@ static void P_MoveParticle(ptcgen_t* gen, particle_t* pt) P_SpinParticle(gen, pt); // Changes to momentum. - pt->mov[VZ] -= FixedMul(FLT2FIX(mapGravity), st->gravity); + /// @fixme Do not assume generator is from the CURRENT map. + pt->mov[VZ] -= FixedMul(FLT2FIX(GameMap_Gravity(theMap)), st->gravity); // Vector force. if(stDef->vectorForce[VX] != 0 || stDef->vectorForce[VY] != 0 || diff --git a/doomsday/plugins/common/src/d_netcl.c b/doomsday/plugins/common/src/d_netcl.c index 581bd24255..eb2b03d8cf 100644 --- a/doomsday/plugins/common/src/d_netcl.c +++ b/doomsday/plugins/common/src/d_netcl.c @@ -139,6 +139,7 @@ void NetCl_UpdateGameState(Reader* msg) } // Set gravity. + /// @fixme This is a map-property, not a global property. DD_SetVariable(DD_GRAVITY, &gsGravity); // Camera init included?