Add vertex slope spawning function.

Rename P_ResetDynamicSlopes() to P_SpawnSlopes().
This commit is contained in:
Nev3r 2020-01-04 10:39:45 +01:00
parent 0b21a34ddd
commit faf127ff88
3 changed files with 59 additions and 5 deletions

View File

@ -3582,7 +3582,7 @@ boolean P_LoadLevel(boolean fromnetsave)
P_InitSpecials();
#ifdef ESLOPE
P_ResetDynamicSlopes(fromnetsave);
P_SpawnSlopes(fromnetsave);
#endif
P_SpawnMapThings(!fromnetsave);

View File

@ -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:

View File

@ -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