Merge branch 'udmf-next' into stringargs

This commit is contained in:
MascaraSnake 2020-01-11 16:17:53 +01:00
commit b163316cbf
6 changed files with 100 additions and 10 deletions

View File

@ -161,13 +161,21 @@ static const char *const side_opt[] = {
enum vertex_e { enum vertex_e {
vertex_valid = 0, vertex_valid = 0,
vertex_x, vertex_x,
vertex_y vertex_y,
vertex_floorz,
vertex_floorzset,
vertex_ceilingz,
vertex_ceilingzset
}; };
static const char *const vertex_opt[] = { static const char *const vertex_opt[] = {
"valid", "valid",
"x", "x",
"y", "y",
"floorz",
"floorzset",
"ceilingz",
"ceilingzset",
NULL}; NULL};
enum ffloor_e { enum ffloor_e {
@ -1014,6 +1022,18 @@ static int vertex_get(lua_State *L)
case vertex_y: case vertex_y:
lua_pushfixed(L, vertex->y); lua_pushfixed(L, vertex->y);
return 1; 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; return 0;
} }

View File

@ -846,6 +846,8 @@ static void P_LoadVertices(UINT8 *data)
{ {
v->x = SHORT(mv->x)<<FRACBITS; v->x = SHORT(mv->x)<<FRACBITS;
v->y = SHORT(mv->y)<<FRACBITS; v->y = SHORT(mv->y)<<FRACBITS;
v->floorzset = v->ceilingzset = false;
v->floorz = v->ceilingz = 0;
} }
} }
@ -1368,6 +1370,16 @@ static void ParseTextmapVertexParameter(UINT32 i, char *param, char *val)
vertexes[i].x = FLOAT_TO_FIXED(atof(val)); vertexes[i].x = FLOAT_TO_FIXED(atof(val));
else if (fastcmp(param, "y")) else if (fastcmp(param, "y"))
vertexes[i].y = FLOAT_TO_FIXED(atof(val)); 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) static void ParseTextmapSectorParameter(UINT32 i, char *param, char *val)
@ -1593,6 +1605,8 @@ static void P_LoadTextmap(void)
{ {
// Defaults. // Defaults.
vt->x = vt->y = INT32_MAX; vt->x = vt->y = INT32_MAX;
vt->floorzset = vt->ceilingzset = false;
vt->floorz = vt->ceilingz = 0;
TextmapParse(vertexesPos[i], i, ParseTextmapVertexParameter); TextmapParse(vertexesPos[i], i, ParseTextmapVertexParameter);
@ -3693,11 +3707,11 @@ boolean P_LoadLevel(boolean fromnetsave)
return false; return false;
// init gravity, tag lists, // init gravity, tag lists,
// anything that P_ResetDynamicSlopes/P_LoadThings needs to know // anything that P_SpawnSlopes/P_LoadThings needs to know
P_InitSpecials(); P_InitSpecials();
#ifdef ESLOPE #ifdef ESLOPE
P_ResetDynamicSlopes(fromnetsave); P_SpawnSlopes(fromnetsave);
#endif #endif
P_SpawnMapThings(!fromnetsave); P_SpawnMapThings(!fromnetsave);

View File

@ -456,8 +456,8 @@ static pslope_t *MakeViaMapthings(INT16 tag1, INT16 tag2, INT16 tag3, UINT8 flag
return ret; return ret;
} }
/// Create vertex based slopes. /// Create vertex based slopes using tagged mapthings.
static void line_SpawnViaVertexes(const int linenum, const boolean spawnthinker) static void line_SpawnViaMapthingVertexes(const int linenum, const boolean spawnthinker)
{ {
line_t *line = lines + linenum; line_t *line = lines + linenum;
side_t *side; side_t *side;
@ -497,6 +497,56 @@ static void line_SpawnViaVertexes(const int linenum, const boolean spawnthinker)
side->sector->hasslope = true; side->sector->hasslope = true;
} }
/// Spawn textmap vertex slopes.
static 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 ? 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]);
}
if (v1->ceilingzset || v2->ceilingzset || v3->ceilingzset)
{
vector3_t vtx[3] = {
{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]);
}
}
}
static boolean P_SetSlopeFromTag(sector_t *sec, INT32 tag, boolean ceiling) static boolean P_SetSlopeFromTag(sector_t *sec, INT32 tag, boolean ceiling)
{ {
INT32 i; INT32 i;
@ -587,12 +637,16 @@ pslope_t *P_SlopeById(UINT16 id)
return ret; return ret;
} }
/// Reset slopes and read them from special lines. /// Initializes and reads the slopes from the map data.
void P_ResetDynamicSlopes(const boolean fromsave) { void P_SpawnSlopes(const boolean fromsave) {
size_t i; size_t i;
slopelist = NULL; slopelist = NULL;
slopecount = 0; slopecount = 0;
/// Generates vertex slopes.
SpawnVertexSlopes();
/// Generates line special-defined slopes. /// Generates line special-defined slopes.
for (i = 0; i < numlines; i++) for (i = 0; i < numlines; i++)
{ {
@ -603,7 +657,7 @@ void P_ResetDynamicSlopes(const boolean fromsave) {
break; break;
case 704: case 704:
line_SpawnViaVertexes(i, !fromsave); line_SpawnViaMapthingVertexes(i, !fromsave);
break; break;
default: default:

View File

@ -23,7 +23,7 @@ extern UINT16 slopecount;
void P_LinkSlopeThinkers (void); void P_LinkSlopeThinkers (void);
void P_CalculateSlopeNormal(pslope_t *slope); void P_CalculateSlopeNormal(pslope_t *slope);
void P_ResetDynamicSlopes(const boolean fromsave); void P_SpawnSlopes(const boolean fromsave);
// //
// P_CopySectorSlope // P_CopySectorSlope

View File

@ -6353,7 +6353,7 @@ static void P_RunLevelLoadExecutors(void)
} }
/** Before things are loaded, initialises certain stuff in case they're needed /** 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. * P_SpawnSpecials, in case you couldn't tell.
* *
* \sa P_SpawnSpecials, P_InitTagLists * \sa P_SpawnSpecials, P_InitTagLists

View File

@ -84,6 +84,8 @@ typedef struct extracolormap_s
typedef struct typedef struct
{ {
fixed_t x, y; fixed_t x, y;
boolean floorzset, ceilingzset;
fixed_t floorz, ceilingz;
} vertex_t; } vertex_t;
// Forward of linedefs, for sectors. // Forward of linedefs, for sectors.