From 0b5e4195936776364a247bfcef323bf9290cbdfc Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 9 Jan 2016 10:11:20 +0100 Subject: [PATCH] - fixed friction logic for sectors. Issues with the old code: * when calculating friction for a 3D-floor - swimmable or not - the 3D floor's top texture must be used. The previous version always checked the sector's floor texture, even though the top might as well come from the sector's ceiling. * 3D floors never checked for the SECF_FRICTION flag at all. According to Boom specs, sector-based friction must be ignored if this is the case. * Terrain based friction had a higher priority than the sector's own value. Changed the rules as follows: * if the sector's SECF_FRICTION flag is set (i.e. something explicitly changed the sector's friction), this value is used regardless of terrain settings. * if this flag is not set, the terrain's friction is used, if defined, using the proper plane for 3D-floors. * otherwise the default is used. --- src/p_map.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/p_map.cpp b/src/p_map.cpp index f409dafa4..fe5959df9 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -529,16 +529,18 @@ void P_PlayerStartStomp(AActor *actor) // //========================================================================== -inline fixed_t secfriction(const sector_t *sec) +inline fixed_t secfriction(const sector_t *sec, int plane = sector_t::floor) { - fixed_t friction = Terrains[TerrainTypes[sec->GetTexture(sector_t::floor)]].Friction; - return friction != 0 ? friction : sec->friction; + if (sec->Flags & SECF_FRICTION) return sec->friction; + fixed_t friction = Terrains[TerrainTypes[sec->GetTexture(plane)]].Friction; + return friction != 0 ? friction : ORIG_FRICTION; } -inline fixed_t secmovefac(const sector_t *sec) +inline fixed_t secmovefac(const sector_t *sec, int plane = sector_t::floor) { - fixed_t movefactor = Terrains[TerrainTypes[sec->GetTexture(sector_t::floor)]].MoveFactor; - return movefactor != 0 ? movefactor : sec->movefactor; + if (sec->Flags & SECF_FRICTION) return sec->friction; + fixed_t movefactor = Terrains[TerrainTypes[sec->GetTexture(plane)]].MoveFactor; + return movefactor != 0 ? movefactor : ORIG_FRICTION_FACTOR; } //========================================================================== @@ -584,11 +586,11 @@ int P_GetFriction(const AActor *mo, int *frictionfactor) mo->z < rover->bottom.plane->ZatPoint(mo->x, mo->y)) continue; - newfriction = secfriction(rover->model); + newfriction = secfriction(rover->model, rover->top.isceiling); if (newfriction < friction || friction == ORIG_FRICTION) { friction = newfriction; - movefactor = secmovefac(rover->model) >> 1; + movefactor = secmovefac(rover->model, rover->top.isceiling) >> 1; } } } @@ -622,11 +624,11 @@ int P_GetFriction(const AActor *mo, int *frictionfactor) else continue; - newfriction = secfriction(rover->model); + newfriction = secfriction(rover->model, rover->top.isceiling); if (newfriction < friction || friction == ORIG_FRICTION) { friction = newfriction; - movefactor = secmovefac(rover->model); + movefactor = secmovefac(rover->model, rover->top.isceiling); } }