diff --git a/extras/conf/udb/Includes/SRB222_misc.cfg b/extras/conf/udb/Includes/SRB222_misc.cfg index 544516f7d..d7b02dbf7 100644 --- a/extras/conf/udb/Includes/SRB222_misc.cfg +++ b/extras/conf/udb/Includes/SRB222_misc.cfg @@ -253,8 +253,8 @@ universalfields friction { - type = 0; - default = 0; + type = 1; + default = 0.90625; } triggertag diff --git a/src/lua_maplib.c b/src/lua_maplib.c index 287aa73c7..4e376f0d5 100644 --- a/src/lua_maplib.c +++ b/src/lua_maplib.c @@ -681,7 +681,7 @@ static int sector_get(lua_State *L) lua_pushinteger(L, (UINT8)sector->triggerer); return 1; case sector_friction: // friction - lua_pushinteger(L, sector->friction); + lua_pushfixed(L, sector->friction); return 1; case sector_gravity: // gravity lua_pushfixed(L, sector->gravity); diff --git a/src/p_setup.c b/src/p_setup.c index 817bd8fec..e39675a55 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1054,6 +1054,8 @@ static void P_LoadSectors(UINT8 *data) ss->triggertag = 0; ss->triggerer = TO_PLAYER; + ss->friction = ORIG_FRICTION; + P_InitializeSector(ss); } } @@ -1720,7 +1722,7 @@ static void ParseTextmapSectorParameter(UINT32 i, char *param, char *val) else if (fastcmp(param, "ropehang") && fastcmp("true", val)) sectors[i].specialflags |= SSF_ROPEHANG; else if (fastcmp(param, "friction")) - sectors[i].friction = atol(val); + sectors[i].friction = FLOAT_TO_FIXED(atof(val)); else if (fastcmp(param, "gravity")) sectors[i].gravity = FLOAT_TO_FIXED(atof(val)); else if (fastcmp(param, "damagetype")) @@ -2449,6 +2451,8 @@ static void P_LoadTextmap(void) sc->triggertag = 0; sc->triggerer = TO_PLAYER; + sc->friction = ORIG_FRICTION; + textmap_colormap.used = false; textmap_colormap.lightcolor = 0; textmap_colormap.lightalpha = 25; @@ -5337,8 +5341,20 @@ static void P_ConvertBinaryLinedefTypes(void) case 540: //Floor friction { INT32 s; + fixed_t strength; // friction value of sector + fixed_t friction; // friction value to be applied during movement + + strength = sides[lines[i].sidenum[0]].textureoffset >> FRACBITS; + if (strength > 0) // sludge + strength = strength*2; // otherwise, the maximum sludginess value is +967... + + // The following might seem odd. At the time of movement, + // the move distance is multiplied by 'friction/0x10000', so a + // higher friction value actually means 'less friction'. + friction = ORIG_FRICTION - (0x1EB8*strength)/0x80; // ORIG_FRICTION is 0xE800 + TAG_ITER_SECTORS(tag, s) - sectors[s].friction = sides[lines[i].sidenum[0]].textureoffset >> FRACBITS; + sectors[s].friction = friction; break; } case 541: //Wind diff --git a/src/p_spec.c b/src/p_spec.c index 53c7f9cc8..337385560 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -8359,23 +8359,15 @@ static void P_SpawnFriction(void) size_t i; sector_t *s = sectors; - fixed_t strength; // friction value of sector fixed_t friction; // friction value to be applied during movement INT32 movefactor; // applied to each player move to simulate inertia for (i = 0; i < numsectors; i++, s++) { - if (!s->friction) + if (s->friction == ORIG_FRICTION) continue; - strength = s->friction; - if (strength > 0) // sludge - strength = strength*2; // otherwise, the maximum sludginess value is +967... - - // The following might seem odd. At the time of movement, - // the move distance is multiplied by 'friction/0x10000', so a - // higher friction value actually means 'less friction'. - friction = ORIG_FRICTION - (0x1EB8*strength)/0x80; // ORIG_FRICTION is 0xE800 + friction = s->friction; if (friction > FRACUNIT) friction = FRACUNIT; diff --git a/src/r_defs.h b/src/r_defs.h index c4fcb6601..e9ee1b764 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -429,7 +429,7 @@ typedef struct sector_s mtag_t triggertag; // tag to call upon triggering UINT8 triggerer; // who can trigger? - INT32 friction; + fixed_t friction; // Sprite culling feature struct line_s *cullheight;