mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-04-23 10:41:51 +00:00
Add line args; add map conversion function; convert slope specials.
This commit is contained in:
parent
2fb5eb843e
commit
c5960a6490
5 changed files with 207 additions and 55 deletions
|
@ -729,7 +729,7 @@ static void P_LoadRawNodes(UINT8 *data)
|
|||
static void GeneralDefaults(void)
|
||||
{
|
||||
UINT32 i;
|
||||
// UINT32 j;
|
||||
UINT32 j;
|
||||
|
||||
line_t *ld;
|
||||
side_t *sd;
|
||||
|
@ -752,12 +752,12 @@ static void GeneralDefaults(void)
|
|||
#endif
|
||||
// Defaults.
|
||||
/*
|
||||
ld->alpha = FRACUNIT;
|
||||
ld->alpha = FRACUNIT;*/
|
||||
|
||||
for (j = 0; j < NUMLINEARGS; j++)
|
||||
ld->args[j] = 0;
|
||||
|
||||
ld->executordelay = 0;
|
||||
/* ld->executordelay = 0;
|
||||
ld->udmfflags = 0;*/
|
||||
}
|
||||
|
||||
|
@ -1165,7 +1165,6 @@ static void TextmapLine(UINT32 i, char *param)
|
|||
lines[i].sidenum[0] = atol(M_GetToken(NULL));
|
||||
else if (fastcmp(param, "sideback"))
|
||||
lines[i].sidenum[1] = atol(M_GetToken(NULL));
|
||||
#ifdef ADVUDMF
|
||||
else if (fastncmp(param, "arg", 3) && strlen(param) > 3)
|
||||
{
|
||||
if (fastcmp(param + 4, "str"))
|
||||
|
@ -1191,10 +1190,12 @@ static void TextmapLine(UINT32 i, char *param)
|
|||
lines[i].args[argnum] = atol(M_GetToken(NULL));
|
||||
}
|
||||
}
|
||||
#ifdef ADVUDMF
|
||||
else if (fastcmp(param, "alpha"))
|
||||
lines[i].alpha = FLOAT_TO_FIXED(atof(M_GetToken(NULL)));
|
||||
else if (fastcmp(param, "executordelay"))
|
||||
lines[i].executordelay = atol(M_GetToken(NULL));
|
||||
|
||||
#endif
|
||||
// Flags
|
||||
else if (fastcmp(param, "blocking") && fastcmp("true", M_GetToken(NULL)))
|
||||
|
@ -2577,7 +2578,6 @@ static boolean LoadMapBSP (const virtres_t* virt)
|
|||
{
|
||||
case NT_BINARY:
|
||||
{
|
||||
|
||||
numsubsectors = virtssectors->size/ sizeof (mapsubsector_t);
|
||||
numnodes = virtnodes->size / sizeof (mapnode_t);
|
||||
numsegs = virtsegs->size / sizeof (mapseg_t);
|
||||
|
@ -2910,6 +2910,7 @@ static boolean LoadMapData (const virtres_t* virt)
|
|||
SetupLines();
|
||||
P_LoadRawSideDefs2(virtsidedefs->data);
|
||||
P_PrepareRawThings(virtthings->data);
|
||||
P_ConvertBinaryLinedefs();
|
||||
}
|
||||
|
||||
R_ClearTextureNumCache(true);
|
||||
|
|
153
src/p_slopes.c
153
src/p_slopes.c
|
@ -247,22 +247,16 @@ static void line_SpawnViaLine(const int linenum, const boolean spawnthinker)
|
|||
// because checking to see if a slope had changed will waste more memory than
|
||||
// if the slope was just updated when called
|
||||
line_t *line = lines + linenum;
|
||||
INT16 special = line->special;
|
||||
pslope_t *fslope = NULL, *cslope = NULL;
|
||||
vector3_t origin, point;
|
||||
vector2_t direction;
|
||||
fixed_t nx, ny, dz, extent;
|
||||
|
||||
boolean frontfloor = (special == 700 || special == 702 || special == 703);
|
||||
boolean backfloor = (special == 710 || special == 712 || special == 713);
|
||||
boolean frontceil = (special == 701 || special == 702 || special == 713);
|
||||
boolean backceil = (special == 711 || special == 712 || special == 703);
|
||||
|
||||
UINT8 flags = 0; // Slope flags
|
||||
if (line->flags & ML_NETONLY)
|
||||
flags |= SL_NOPHYSICS;
|
||||
if (line->flags & ML_NONET)
|
||||
flags |= SL_DYNAMIC;
|
||||
boolean frontfloor = line->args[0] == 1;
|
||||
boolean backfloor = line->args[0] == 2;
|
||||
boolean frontceil = line->args[1] == 1;
|
||||
boolean backceil = line->args[1] == 2;
|
||||
UINT8 flags = line->args[2]; // Slope flags
|
||||
|
||||
if(!frontfloor && !backfloor && !frontceil && !backceil)
|
||||
{
|
||||
|
@ -445,10 +439,12 @@ static pslope_t *MakeViaMapthings(INT16 tag1, INT16 tag2, INT16 tag3, UINT8 flag
|
|||
I_Error("MakeViaMapthings: Slope vertex %s (for linedef tag %d) not found!", sizeu1(i), tag1);
|
||||
vx[i].x = mt->x << FRACBITS;
|
||||
vx[i].y = mt->y << FRACBITS;
|
||||
if (mt->extrainfo)
|
||||
vx[i].z = mt->options << FRACBITS;
|
||||
else
|
||||
vx[i].z = (R_PointInSubsector(mt->x << FRACBITS, mt->y << FRACBITS)->sector->floorheight) + ((mt->options >> ZSHIFT) << FRACBITS);
|
||||
vx[i].z = mt->z << FRACBITS;
|
||||
|
||||
if (!mt->extrainfo)
|
||||
vx[i].z += R_PointInSubsector(mt->x << FRACBITS, mt->y << FRACBITS)->sector->floorheight;
|
||||
|
||||
CONS_Printf("%d %d %d\n", vx[i].x, vx[i].y, vx[i].z);
|
||||
}
|
||||
|
||||
ReconfigureViaVertexes(ret, vx[0], vx[1], vx[2]);
|
||||
|
@ -465,45 +461,30 @@ static void line_SpawnViaVertexes(const int linenum, const boolean spawnthinker)
|
|||
line_t *line = lines + linenum;
|
||||
side_t *side;
|
||||
pslope_t **slopetoset;
|
||||
UINT16 tag1, tag2, tag3;
|
||||
|
||||
UINT8 flags = 0;
|
||||
if (line->flags & ML_NETONLY)
|
||||
flags |= SL_NOPHYSICS;
|
||||
if (line->flags & ML_NONET)
|
||||
flags |= SL_DYNAMIC;
|
||||
|
||||
switch(line->special)
|
||||
CONS_Printf("arg0: %d\n", line->args[0]);
|
||||
switch(line->args[0])
|
||||
{
|
||||
case 704:
|
||||
case 0:
|
||||
slopetoset = &line->frontsector->f_slope;
|
||||
side = &sides[line->sidenum[0]];
|
||||
break;
|
||||
case 705:
|
||||
case 1:
|
||||
slopetoset = &line->frontsector->c_slope;
|
||||
side = &sides[line->sidenum[0]];
|
||||
break;
|
||||
case 714:
|
||||
case 2:
|
||||
slopetoset = &line->backsector->f_slope;
|
||||
side = &sides[line->sidenum[1]];
|
||||
break;
|
||||
case 715:
|
||||
case 3:
|
||||
slopetoset = &line->backsector->c_slope;
|
||||
side = &sides[line->sidenum[1]];
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
if (line->flags & ML_EFFECT6)
|
||||
{
|
||||
tag1 = line->tag;
|
||||
tag2 = side->textureoffset >> FRACBITS;
|
||||
tag3 = side->rowoffset >> FRACBITS;
|
||||
}
|
||||
else
|
||||
tag1 = tag2 = tag3 = line->tag;
|
||||
|
||||
*slopetoset = MakeViaMapthings(tag1, tag2, tag3, flags, spawnthinker);
|
||||
*slopetoset = MakeViaMapthings(line->args[1], line->args[2], line->args[3], line->args[4], spawnthinker);
|
||||
|
||||
side->sector->hasslope = true;
|
||||
}
|
||||
|
@ -567,25 +548,97 @@ void SpawnVertexSlopes (void)
|
|||
void P_CopySectorSlope(line_t *line)
|
||||
{
|
||||
sector_t *fsec = line->frontsector;
|
||||
int i, special = line->special;
|
||||
sector_t *bsec = line->backsector;
|
||||
int i;
|
||||
|
||||
|
||||
// Check for copy linedefs
|
||||
for (i = -1; (i = P_FindSectorFromLineTag(line, i)) >= 0;)
|
||||
if (line->args[0])
|
||||
{
|
||||
sector_t *srcsec = sectors + i;
|
||||
|
||||
if ((special - 719) & 1 && !fsec->f_slope && srcsec->f_slope)
|
||||
fsec->f_slope = srcsec->f_slope; //P_CopySlope(srcsec->f_slope);
|
||||
if ((special - 719) & 2 && !fsec->c_slope && srcsec->c_slope)
|
||||
fsec->c_slope = srcsec->c_slope; //P_CopySlope(srcsec->c_slope);
|
||||
for (i = -1; (i = P_FindSectorFromTag(line->args[0], i)) >= 0;)
|
||||
{
|
||||
sector_t *srcsec = sectors + i;
|
||||
if (!fsec->f_slope && srcsec->f_slope)
|
||||
{
|
||||
fsec->f_slope = srcsec->f_slope;
|
||||
fsec->hasslope = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (line->args[1])
|
||||
{
|
||||
for (i = -1; (i = P_FindSectorFromTag(line->args[1], i)) >= 0;)
|
||||
{
|
||||
sector_t *srcsec = sectors + i;
|
||||
if (!fsec->c_slope && srcsec->c_slope)
|
||||
{
|
||||
fsec->c_slope = srcsec->c_slope;
|
||||
fsec->hasslope = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fsec->hasslope = true;
|
||||
if (bsec)
|
||||
{
|
||||
if (line->args[2])
|
||||
{
|
||||
for (i = -1; (i = P_FindSectorFromTag(line->args[2], i)) >= 0;)
|
||||
{
|
||||
sector_t *srcsec = sectors + i;
|
||||
if (!bsec->f_slope && srcsec->f_slope)
|
||||
{
|
||||
bsec->f_slope = srcsec->f_slope;
|
||||
bsec->hasslope = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (line->args[3])
|
||||
{
|
||||
for (i = -1; (i = P_FindSectorFromTag(line->args[3], i)) >= 0;)
|
||||
{
|
||||
sector_t *srcsec = sectors + i;
|
||||
if (!bsec->c_slope && srcsec->c_slope)
|
||||
{
|
||||
bsec->c_slope = srcsec->c_slope;
|
||||
bsec->hasslope = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if this is an FOF control sector, make sure any target sectors also are marked as having slopes
|
||||
if (fsec->numattached)
|
||||
for (i = 0; i < (int)fsec->numattached; i++)
|
||||
sectors[fsec->attached[i]].hasslope = true;
|
||||
//Share slopes between front and back side
|
||||
if (line->args[4] & 1)
|
||||
{
|
||||
if (!bsec->f_slope && fsec->f_slope)
|
||||
{
|
||||
bsec->f_slope = fsec->f_slope;
|
||||
bsec->hasslope = true;
|
||||
}
|
||||
}
|
||||
if (line->args[4] & 2)
|
||||
{
|
||||
if (!fsec->f_slope && bsec->f_slope)
|
||||
{
|
||||
fsec->f_slope = bsec->f_slope;
|
||||
fsec->hasslope = true;
|
||||
}
|
||||
}
|
||||
if (line->args[4] & 4)
|
||||
{
|
||||
if (!bsec->c_slope && fsec->c_slope)
|
||||
{
|
||||
bsec->c_slope = fsec->c_slope;
|
||||
bsec->hasslope = true;
|
||||
}
|
||||
}
|
||||
if (line->args[4] & 8)
|
||||
{
|
||||
if (!fsec->c_slope && bsec->c_slope)
|
||||
{
|
||||
fsec->c_slope = bsec->c_slope;
|
||||
fsec->hasslope = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
line->special = 0; // Linedef was use to set slopes, it finished its job, so now make it a normal linedef
|
||||
}
|
||||
|
|
91
src/p_spec.c
91
src/p_spec.c
|
@ -6398,6 +6398,97 @@ static void P_RunLevelLoadExecutors(void)
|
|||
}
|
||||
}
|
||||
|
||||
//For maps in binary format, converts linedef specials to the setup used by UDMF.
|
||||
//\todo unfinished
|
||||
void P_ConvertBinaryLinedefs(void)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i < numlines; i++)
|
||||
{
|
||||
switch (lines[i].special)
|
||||
{
|
||||
case 700: //Slope front sector floor
|
||||
case 701: //Slope front sector ceiling
|
||||
case 702: //Slope front sector floor and ceiling
|
||||
case 703: //Slope front sector floor and back sector ceiling
|
||||
case 710: //Slope back sector floor
|
||||
case 711: //Slope back sector ceiling
|
||||
case 712: //Slope back sector floor and ceiling
|
||||
case 713: //Slope back sector floor and front sector ceiling
|
||||
{
|
||||
boolean frontfloor = (lines[i].special == 700 || lines[i].special == 702 || lines[i].special == 703);
|
||||
boolean backfloor = (lines[i].special == 710 || lines[i].special == 712 || lines[i].special == 713);
|
||||
boolean frontceil = (lines[i].special == 701 || lines[i].special == 702 || lines[i].special == 713);
|
||||
boolean backceil = (lines[i].special == 711 || lines[i].special == 712 || lines[i].special == 703);
|
||||
|
||||
lines[i].args[0] = backfloor ? 2 : (frontfloor ? 1 : 0);
|
||||
lines[i].args[1] = backceil ? 2 : (frontceil ? 1 : 0);
|
||||
|
||||
if (lines[i].flags & ML_NETONLY)
|
||||
lines[i].args[2] |= SL_NOPHYSICS;
|
||||
if (!(lines[i].flags & ML_NONET))
|
||||
lines[i].args[2] |= SL_DYNAMIC;
|
||||
|
||||
lines[i].special = 700;
|
||||
break;
|
||||
}
|
||||
case 704: //Slope front sector floor by 3 tagged vertices
|
||||
case 705: //Slope front sector ceiling by 3 tagged vertices
|
||||
case 714: //Slope back sector floor by 3 tagged vertices
|
||||
case 715: //Slope back sector ceiling by 3 tagged vertices
|
||||
{
|
||||
if (lines[i].special == 704)
|
||||
lines[i].args[0] = 0;
|
||||
else if (lines[i].special == 705)
|
||||
lines[i].args[0] = 1;
|
||||
else if (lines[i].special == 714)
|
||||
lines[i].args[0] = 2;
|
||||
else if (lines[i].special == 715)
|
||||
lines[i].args[0] = 3;
|
||||
|
||||
lines[i].args[1] = lines[i].tag;
|
||||
|
||||
if (lines[i].flags & ML_EFFECT6)
|
||||
{
|
||||
UINT8 side = lines[i].special >= 714;
|
||||
|
||||
if (side == 1 && lines[i].sidenum[1] == 0xffff)
|
||||
CONS_Debug(DBG_GAMELOGIC, "Line special %d (line #%s) missing 2nd side!\n", lines[i].special, sizeu1(i));
|
||||
else
|
||||
{
|
||||
lines[i].args[2] = sides[lines[i].sidenum[side]].textureoffset >> FRACBITS;
|
||||
lines[i].args[3] = sides[lines[i].sidenum[side]].rowoffset >> FRACBITS;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lines[i].args[2] = lines[i].args[1];
|
||||
lines[i].args[3] = lines[i].args[1];
|
||||
}
|
||||
|
||||
if (lines[i].flags & ML_NETONLY)
|
||||
lines[i].args[4] |= SL_NOPHYSICS;
|
||||
if (!(lines[i].flags & ML_NONET))
|
||||
lines[i].args[4] |= SL_DYNAMIC;
|
||||
|
||||
lines[i].special = 704;
|
||||
break;
|
||||
}
|
||||
case 720: //Copy front side floor slope
|
||||
case 721: //Copy front side ceiling slope
|
||||
case 722: //Copy front side floor and ceiling slope
|
||||
if (lines[i].special != 721)
|
||||
lines[i].args[0] = lines[i].tag;
|
||||
if (lines[i].special != 720)
|
||||
lines[i].args[1] = lines[i].tag;
|
||||
lines[i].special = 720;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Before things are loaded, initialises certain stuff in case they're needed
|
||||
* by P_ResetDynamicSlopes or P_LoadThings. This was split off from
|
||||
* P_SpawnSpecials, in case you couldn't tell.
|
||||
|
|
|
@ -34,6 +34,7 @@ void P_InitPicAnims(void);
|
|||
void P_SetupLevelFlatAnims(void);
|
||||
|
||||
// at map load
|
||||
void P_ConvertBinaryLinedefs(void);
|
||||
void P_InitSpecials(void);
|
||||
void P_SpawnSpecials(INT32 fromnetsave);
|
||||
|
||||
|
|
|
@ -373,6 +373,7 @@ typedef struct sector_s
|
|||
|
||||
// This points to the master's floorheight, so it can be changed in realtime!
|
||||
fixed_t *gravity; // per-sector gravity
|
||||
fixed_t *gravityptr; // For binary format: Read gravity from floor height of master sector
|
||||
boolean verticalflip; // If gravity < 0, then allow flipped physics
|
||||
sectorflags_t flags;
|
||||
|
||||
|
@ -413,6 +414,8 @@ typedef enum
|
|||
|
||||
#define HORIZONSPECIAL 41
|
||||
|
||||
#define NUMLINEARGS 6
|
||||
#define NUMLINESTRINGARGS 2
|
||||
typedef struct line_s
|
||||
{
|
||||
// Vertices, from v1 to v2.
|
||||
|
@ -451,6 +454,9 @@ typedef struct line_s
|
|||
|
||||
char *text; // a concatination of all front and back texture names, for linedef specials that require a string.
|
||||
INT16 callcount; // no. of calls left before triggering, for the "X calls" linedef specials, defaults to 0
|
||||
|
||||
int args[NUMLINEARGS];
|
||||
char *stringargs[NUMLINESTRINGARGS];
|
||||
} line_t;
|
||||
|
||||
//
|
||||
|
|
Loading…
Reference in a new issue