From 0b21a34ddd41d648eafd562b78d36dbdbf32fe6a Mon Sep 17 00:00:00 2001 From: Nev3r Date: Sat, 4 Jan 2020 10:24:42 +0100 Subject: [PATCH 01/10] Add vertex height vars into the vertex struct, and their textmap parsing. --- src/p_setup.c | 12 ++++++++++++ src/r_defs.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/src/p_setup.c b/src/p_setup.c index bd1c53104..0a802583a 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1368,6 +1368,16 @@ static void ParseTextmapVertexParameter(UINT32 i, char *param, char *val) vertexes[i].x = FLOAT_TO_FIXED(atof(val)); else if (fastcmp(param, "y")) vertexes[i].y = FLOAT_TO_FIXED(atof(val)); + else if (fastcmp(param, "zfloor")) + { + vertexes[i].floorz = FLOAT_TO_FIXED(atof(val)); + vertexes[i].floorzset = true; + } + else if (fastcmp(param, "zceiling")) + { + vertexes[i].ceilingz = FLOAT_TO_FIXED(atof(val)); + vertexes[i].ceilingzset = true; + } } static void ParseTextmapSectorParameter(UINT32 i, char *param, char *val) @@ -1576,6 +1586,8 @@ static void P_LoadTextmap(void) // Defaults. vt->x = vt->y = INT32_MAX; vt->z = 0; + vt->floorzset = vt->ceilingzset = false; + vt->floorz = vt->ceilingz = 0; TextmapParse(vertexesPos[i], i, ParseTextmapVertexParameter); diff --git a/src/r_defs.h b/src/r_defs.h index 96ef953ce..5f96958c9 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -84,6 +84,8 @@ typedef struct extracolormap_s typedef struct { fixed_t x, y, z; + boolean floorzset, ceilingzset; + fixed_t floorz, ceilingz; } vertex_t; // Forward of linedefs, for sectors. From faf127ff8860e18c5cba47572ca629527b0e4779 Mon Sep 17 00:00:00 2001 From: Nev3r Date: Sat, 4 Jan 2020 10:39:45 +0100 Subject: [PATCH 02/10] Add vertex slope spawning function. Rename P_ResetDynamicSlopes() to P_SpawnSlopes(). --- src/p_setup.c | 2 +- src/p_slopes.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++--- src/p_slopes.h | 2 +- 3 files changed, 59 insertions(+), 5 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 0a802583a..a1aaeb4ba 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3582,7 +3582,7 @@ boolean P_LoadLevel(boolean fromnetsave) P_InitSpecials(); #ifdef ESLOPE - P_ResetDynamicSlopes(fromnetsave); + P_SpawnSlopes(fromnetsave); #endif P_SpawnMapThings(!fromnetsave); diff --git a/src/p_slopes.c b/src/p_slopes.c index e66d7ed21..5c47c7226 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -507,6 +507,56 @@ static void line_SpawnViaVertexes(const int linenum, const boolean spawnthinker) side->sector->hasslope = true; } +/// Spawn textmap vertex slopes. +void SpawnVertexSlopes (void) +{ + line_t *l1, *l2; + sector_t* sc; + vertex_t *v1, *v2, *v3; + size_t i; + for (i = 0, sc = sectors; i < numsectors; i++, sc++) + { + // The vertex slopes only work for 3-vertex sectors (and thus 3-sided sectors). + if (sc->linecount != 3) + continue; + + l1 = sc->lines[0]; + l2 = sc->lines[1]; + + // Determine the vertexes. + v1 = l1->v1; + v2 = l1->v2; + if ((l2->v1 != v1) && (l2->v1 != v2)) + v3 = l2->v1; + else + v3 = l2->v2; + + if (v1->floorzset || v2->floorzset || v3->floorzset) + { + vector3_t vtx[3] = { + {v1->x, v1->y, v1->floorzset == true ? v1->floorz : sc->floorheight}, + {v2->x, v2->y, v2->floorzset == true ? v2->floorz : sc->floorheight}, + {v3->x, v3->y, v3->floorzset == true ? v3->floorz : sc->floorheight}}; + pslope_t* slop = Slope_Add(0); + sc->f_slope = slop; + sc->hasslope = true; + ReconfigureViaVertexes(slop, vtx[0], vtx[1], vtx[2]); + } + + if (v1->ceilingzset || v2->ceilingzset || v3->ceilingzset) + { + vector3_t vtx[3] = { + {v1->x, v1->y, v1->ceilingzset == true ? v1->ceilingz : sc->ceilingheight}, + {v2->x, v2->y, v2->ceilingzset == true ? v2->ceilingz : sc->ceilingheight}, + {v3->x, v3->y, v3->ceilingzset == true ? v3->ceilingz : sc->ceilingheight}}; + pslope_t* slop = Slope_Add(0); + sc->c_slope = slop; + sc->hasslope = true; + ReconfigureViaVertexes(slop, vtx[0], vtx[1], vtx[2]); + } + + } +} // // P_CopySectorSlope @@ -551,12 +601,16 @@ pslope_t *P_SlopeById(UINT16 id) return ret; } -/// Reset slopes and read them from special lines. -void P_ResetDynamicSlopes(const boolean fromsave) { +/// Initializes and reads the slopes from the map data. +void P_SpawnSlopes(const boolean fromsave) { size_t i; + slopelist = NULL; slopecount = 0; + /// Generates vertex slopes. + SpawnVertexSlopes(); + /// Generates line special-defined slopes. for (i = 0; i < numlines; i++) { @@ -577,7 +631,7 @@ void P_ResetDynamicSlopes(const boolean fromsave) { case 705: case 714: case 715: - line_SpawnViaVertexes(i, !fromsave); + line_SpawnViaVertexes(i, !fromsave); // Mapthing-based vertex slopes. break; default: diff --git a/src/p_slopes.h b/src/p_slopes.h index 96764051b..0bf03f26d 100644 --- a/src/p_slopes.h +++ b/src/p_slopes.h @@ -23,7 +23,7 @@ extern UINT16 slopecount; void P_LinkSlopeThinkers (void); void P_CalculateSlopeNormal(pslope_t *slope); -void P_ResetDynamicSlopes(const boolean fromsave); +void P_SpawnSlopes(const boolean fromsave); // // P_CopySectorSlope From c9294d1e3283588b9f1b742e5e4dae5541141683 Mon Sep 17 00:00:00 2001 From: Nev3r Date: Sat, 4 Jan 2020 11:17:54 +0100 Subject: [PATCH 03/10] Provide a fix for "non-sloped" slopes launch/land behavior by checking the normal's components. --- src/p_slopes.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/p_slopes.c b/src/p_slopes.c index 5c47c7226..870cd621f 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -50,10 +50,10 @@ static void ReconfigureViaVertexes (pslope_t *slope, const vector3_t v1, const v // Set some defaults for a non-sloped "slope" if (vec1.z == 0 && vec2.z == 0) { - /// \todo Fix fully flat cases. - slope->zangle = slope->xydirection = 0; slope->zdelta = slope->d.x = slope->d.y = 0; + slope->normal.x = slope->normal.y = 0; + slope->normal.z = FRACUNIT; } else { @@ -707,7 +707,9 @@ void P_ReverseQuantizeMomentumToSlope(vector3_t *momentum, pslope_t *slope) // Handles slope ejection for objects void P_SlopeLaunch(mobj_t *mo) { - if (!(mo->standingslope->flags & SL_NOPHYSICS)) // If there's physics, time for launching. + if (!(mo->standingslope->flags & SL_NOPHYSICS) // If there's physics, time for launching. + && (mo->standingslope->normal.x != 0 + || mo->standingslope->normal.y != 0)) { // Double the pre-rotation Z, then halve the post-rotation Z. This reduces the // vertical launch given from slopes while increasing the horizontal launch @@ -764,8 +766,7 @@ fixed_t P_GetWallTransferMomZ(mobj_t *mo, pslope_t *slope) void P_HandleSlopeLanding(mobj_t *thing, pslope_t *slope) { vector3_t mom; // Ditto. - - if (slope->flags & SL_NOPHYSICS) { // No physics, no need to make anything complicated. + if (slope->flags & SL_NOPHYSICS || (slope->normal.x == 0 && slope->normal.y == 0)) { // No physics, no need to make anything complicated. if (P_MobjFlip(thing)*(thing->momz) < 0) // falling, land on slope { thing->standingslope = slope; From 60999c7b8483805c271bd89e485edb5fd8f76357 Mon Sep 17 00:00:00 2001 From: Nev3r Date: Sat, 4 Jan 2020 11:25:46 +0100 Subject: [PATCH 04/10] Revert "Provide a fix for "non-sloped" slopes launch/land behavior by checking the normal's components." This reverts commit c9294d1e3283588b9f1b742e5e4dae5541141683. --- src/p_slopes.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/p_slopes.c b/src/p_slopes.c index 870cd621f..5c47c7226 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -50,10 +50,10 @@ static void ReconfigureViaVertexes (pslope_t *slope, const vector3_t v1, const v // Set some defaults for a non-sloped "slope" if (vec1.z == 0 && vec2.z == 0) { + /// \todo Fix fully flat cases. + slope->zangle = slope->xydirection = 0; slope->zdelta = slope->d.x = slope->d.y = 0; - slope->normal.x = slope->normal.y = 0; - slope->normal.z = FRACUNIT; } else { @@ -707,9 +707,7 @@ void P_ReverseQuantizeMomentumToSlope(vector3_t *momentum, pslope_t *slope) // Handles slope ejection for objects void P_SlopeLaunch(mobj_t *mo) { - if (!(mo->standingslope->flags & SL_NOPHYSICS) // If there's physics, time for launching. - && (mo->standingslope->normal.x != 0 - || mo->standingslope->normal.y != 0)) + if (!(mo->standingslope->flags & SL_NOPHYSICS)) // If there's physics, time for launching. { // Double the pre-rotation Z, then halve the post-rotation Z. This reduces the // vertical launch given from slopes while increasing the horizontal launch @@ -766,7 +764,8 @@ fixed_t P_GetWallTransferMomZ(mobj_t *mo, pslope_t *slope) void P_HandleSlopeLanding(mobj_t *thing, pslope_t *slope) { vector3_t mom; // Ditto. - if (slope->flags & SL_NOPHYSICS || (slope->normal.x == 0 && slope->normal.y == 0)) { // No physics, no need to make anything complicated. + + if (slope->flags & SL_NOPHYSICS) { // No physics, no need to make anything complicated. if (P_MobjFlip(thing)*(thing->momz) < 0) // falling, land on slope { thing->standingslope = slope; From f207048ab2f38133f18f5c162b2671e1f41bc8fa Mon Sep 17 00:00:00 2001 From: Nev3r Date: Sat, 4 Jan 2020 11:38:23 +0100 Subject: [PATCH 05/10] Add Lua support for vertex heights. --- src/lua_maplib.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/lua_maplib.c b/src/lua_maplib.c index 8ce6551f7..7e1097ced 100644 --- a/src/lua_maplib.c +++ b/src/lua_maplib.c @@ -158,7 +158,11 @@ enum vertex_e { vertex_valid = 0, vertex_x, vertex_y, - vertex_z + vertex_z, + vertex_floorz, + vertex_floorzset, + vertex_ceilingz, + vertex_ceilingzset }; static const char *const vertex_opt[] = { @@ -166,6 +170,10 @@ static const char *const vertex_opt[] = { "x", "y", "z", + "floorz", + "floorzset", + "ceilingz", + "ceilingzset", NULL}; enum ffloor_e { @@ -973,6 +981,18 @@ static int vertex_get(lua_State *L) case vertex_z: lua_pushfixed(L, vertex->z); return 1; + case vertex_floorzset: + lua_pushboolean(L, vertex->floorzset); + return 1; + case vertex_ceilingzset: + lua_pushboolean(L, vertex->ceilingzset); + return 1; + case vertex_floorz: + lua_pushfixed(L, vertex->floorz); + return 1; + case vertex_ceilingz: + lua_pushfixed(L, vertex->ceilingz); + return 1; } return 0; } From 72f23a1075eb0e6b8d745bd8f2c24cb511aa57bb Mon Sep 17 00:00:00 2001 From: Nev3r Date: Sat, 4 Jan 2020 23:01:01 +0100 Subject: [PATCH 06/10] Add missing initialization on vertex heights for binary maps. --- src/p_setup.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/p_setup.c b/src/p_setup.c index 2819cb570..0a1c675ef 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -846,6 +846,8 @@ static void P_LoadVertices(UINT8 *data) { v->x = SHORT(mv->x)<y = SHORT(mv->y)<floorzset = vt->ceilingzset = false; + vt->floorz = vt->ceilingz = 0; } } From 3bcf6b4b7ec71d4959a4ce8b52255929bc1d70fc Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Sat, 4 Jan 2020 18:33:58 -0500 Subject: [PATCH 07/10] SpawnVertexSlops() is only used in p_slopes.c --- src/p_slopes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_slopes.c b/src/p_slopes.c index 5c47c7226..13b283af6 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -508,7 +508,7 @@ static void line_SpawnViaVertexes(const int linenum, const boolean spawnthinker) } /// Spawn textmap vertex slopes. -void SpawnVertexSlopes (void) +static void SpawnVertexSlopes (void) { line_t *l1, *l2; sector_t* sc; From 641ac72b3f7e1a435e9095a618623c6718bfefeb Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Sat, 4 Jan 2020 18:34:16 -0500 Subject: [PATCH 08/10] Copy and Paste error --- src/p_setup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 0a1c675ef..a2872cf4b 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -846,8 +846,8 @@ static void P_LoadVertices(UINT8 *data) { v->x = SHORT(mv->x)<y = SHORT(mv->y)<floorzset = vt->ceilingzset = false; - vt->floorz = vt->ceilingz = 0; + v->floorzset = v->ceilingzset = false; + v->floorz = v->ceilingz = 0; } } From ba7a1c0375b37f34b627bcb9027e990881284c0c Mon Sep 17 00:00:00 2001 From: MascaraSnake Date: Fri, 10 Jan 2020 19:56:29 +0100 Subject: [PATCH 09/10] Some minor cleanup --- src/p_setup.c | 2 +- src/p_slopes.c | 19 +++++++++---------- src/p_spec.c | 2 +- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index a2872cf4b..f1b12b2f9 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3578,7 +3578,7 @@ boolean P_LoadLevel(boolean fromnetsave) return false; // init gravity, tag lists, - // anything that P_ResetDynamicSlopes/P_LoadThings needs to know + // anything that P_SpawnSlopes/P_LoadThings needs to know P_InitSpecials(); #ifdef ESLOPE diff --git a/src/p_slopes.c b/src/p_slopes.c index 13b283af6..18489c65e 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -508,7 +508,7 @@ static void line_SpawnViaVertexes(const int linenum, const boolean spawnthinker) } /// Spawn textmap vertex slopes. -static void SpawnVertexSlopes (void) +static void SpawnVertexSlopes(void) { line_t *l1, *l2; sector_t* sc; @@ -534,10 +534,10 @@ static void SpawnVertexSlopes (void) if (v1->floorzset || v2->floorzset || v3->floorzset) { vector3_t vtx[3] = { - {v1->x, v1->y, v1->floorzset == true ? v1->floorz : sc->floorheight}, - {v2->x, v2->y, v2->floorzset == true ? v2->floorz : sc->floorheight}, - {v3->x, v3->y, v3->floorzset == true ? v3->floorz : sc->floorheight}}; - pslope_t* slop = Slope_Add(0); + {v1->x, v1->y, v1->floorzset ? v1->floorz : sc->floorheight}, + {v2->x, v2->y, v2->floorzset ? v2->floorz : sc->floorheight}, + {v3->x, v3->y, v3->floorzset ? v3->floorz : sc->floorheight}}; + pslope_t *slop = Slope_Add(0); sc->f_slope = slop; sc->hasslope = true; ReconfigureViaVertexes(slop, vtx[0], vtx[1], vtx[2]); @@ -546,15 +546,14 @@ static void SpawnVertexSlopes (void) if (v1->ceilingzset || v2->ceilingzset || v3->ceilingzset) { vector3_t vtx[3] = { - {v1->x, v1->y, v1->ceilingzset == true ? v1->ceilingz : sc->ceilingheight}, - {v2->x, v2->y, v2->ceilingzset == true ? v2->ceilingz : sc->ceilingheight}, - {v3->x, v3->y, v3->ceilingzset == true ? v3->ceilingz : sc->ceilingheight}}; - pslope_t* slop = Slope_Add(0); + {v1->x, v1->y, v1->ceilingzset ? v1->ceilingz : sc->ceilingheight}, + {v2->x, v2->y, v2->ceilingzset ? v2->ceilingz : sc->ceilingheight}, + {v3->x, v3->y, v3->ceilingzset ? v3->ceilingz : sc->ceilingheight}}; + pslope_t *slop = Slope_Add(0); sc->c_slope = slop; sc->hasslope = true; ReconfigureViaVertexes(slop, vtx[0], vtx[1], vtx[2]); } - } } diff --git a/src/p_spec.c b/src/p_spec.c index 00a71602b..75cdb0cf1 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -6353,7 +6353,7 @@ static void P_RunLevelLoadExecutors(void) } /** Before things are loaded, initialises certain stuff in case they're needed - * by P_ResetDynamicSlopes or P_LoadThings. This was split off from + * by P_SpawnSlopes or P_LoadThings. This was split off from * P_SpawnSpecials, in case you couldn't tell. * * \sa P_SpawnSpecials, P_InitTagLists From afcaa94cd01ced5802c534b954131dca2e3f1727 Mon Sep 17 00:00:00 2001 From: Nev3r Date: Sat, 11 Jan 2020 08:52:30 +0100 Subject: [PATCH 10/10] Clarify ambiguity regarding mapthing-based vertex slopes. --- src/p_slopes.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/p_slopes.c b/src/p_slopes.c index 18489c65e..dffc96e55 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -458,8 +458,8 @@ static pslope_t *MakeViaMapthings(INT16 tag1, INT16 tag2, INT16 tag3, UINT8 flag return ret; } -/// Create vertex based slopes. -static void line_SpawnViaVertexes(const int linenum, const boolean spawnthinker) +/// Create vertex based slopes using tagged mapthings. +static void line_SpawnViaMapthingVertexes(const int linenum, const boolean spawnthinker) { line_t *line = lines + linenum; side_t *side; @@ -630,7 +630,7 @@ void P_SpawnSlopes(const boolean fromsave) { case 705: case 714: case 715: - line_SpawnViaVertexes(i, !fromsave); // Mapthing-based vertex slopes. + line_SpawnViaMapthingVertexes(i, !fromsave); break; default: