Raise sidedef limits

Also, fixes reading of GL3 nodes to use 32-bit indices for line IDs.
This commit is contained in:
Lactozilla 2023-09-21 02:06:06 -03:00
parent a373d96d07
commit 8fd9a82a19
7 changed files with 97 additions and 79 deletions

View file

@ -1072,7 +1072,7 @@ static int line_get(lua_State *L)
LUA_PushUserdata(L, &sides[line->sidenum[0]], META_SIDE); LUA_PushUserdata(L, &sides[line->sidenum[0]], META_SIDE);
return 1; return 1;
case line_backside: // backside case line_backside: // backside
if (line->sidenum[1] == 0xffff) if (line->sidenum[1] == NO_SIDEDEF)
return 0; return 0;
LUA_PushUserdata(L, &sides[line->sidenum[1]], META_SIDE); LUA_PushUserdata(L, &sides[line->sidenum[1]], META_SIDE);
return 1; return 1;

View file

@ -3900,7 +3900,7 @@ retry:
P_PathTraverse(leadx, traily, leadx + mo->momx, traily + mo->momy, P_PathTraverse(leadx, traily, leadx + mo->momx, traily + mo->momy,
PT_ADDLINES, PTR_SlideTraverse); PT_ADDLINES, PTR_SlideTraverse);
if (bestslideline && mo->player && bestslideline->sidenum[1] != 0xffff) if (bestslideline && mo->player && bestslideline->sidenum[1] != NO_SIDEDEF)
{ {
sector_t *sec = P_PointOnLineSide(mo->x, mo->y, bestslideline) ? bestslideline->frontsector : bestslideline->backsector; sector_t *sec = P_PointOnLineSide(mo->x, mo->y, bestslideline) ? bestslideline->frontsector : bestslideline->backsector;
P_CheckLavaWall(mo, sec); P_CheckLavaWall(mo, sec);

View file

@ -290,7 +290,7 @@ void P_CameraLineOpening(line_t *linedef)
sector_t *back; sector_t *back;
fixed_t frontfloor, frontceiling, backfloor, backceiling; fixed_t frontfloor, frontceiling, backfloor, backceiling;
if (linedef->sidenum[1] == 0xffff) if (linedef->sidenum[1] == NO_SIDEDEF)
{ {
// single sided line // single sided line
openrange = 0; openrange = 0;
@ -426,7 +426,7 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj)
{ {
sector_t *front, *back; sector_t *front, *back;
if (linedef->sidenum[1] == 0xffff) if (linedef->sidenum[1] == NO_SIDEDEF)
{ {
// single sided line // single sided line
openrange = 0; openrange = 0;

View file

@ -1079,7 +1079,7 @@ static void ArchiveSectors(void)
if (diff) if (diff)
{ {
WRITEUINT16(save_p, i); WRITEUINT32(save_p, i);
WRITEUINT8(save_p, diff); WRITEUINT8(save_p, diff);
if (diff & SD_DIFF2) if (diff & SD_DIFF2)
WRITEUINT8(save_p, diff2); WRITEUINT8(save_p, diff2);
@ -1150,18 +1150,19 @@ static void ArchiveSectors(void)
} }
} }
WRITEUINT16(save_p, 0xffff); WRITEUINT32(save_p, 0xffffffff);
} }
static void UnArchiveSectors(void) static void UnArchiveSectors(void)
{ {
UINT16 i, j; UINT32 i;
UINT16 j;
UINT8 diff, diff2, diff3, diff4; UINT8 diff, diff2, diff3, diff4;
for (;;) for (;;)
{ {
i = READUINT16(save_p); i = READUINT32(save_p);
if (i == 0xffff) if (i == 0xffffffff)
break; break;
if (i > numsectors) if (i > numsectors)
@ -1299,7 +1300,7 @@ static void ArchiveLines(void)
if (li->executordelay != spawnli->executordelay) if (li->executordelay != spawnli->executordelay)
diff2 |= LD_EXECUTORDELAY; diff2 |= LD_EXECUTORDELAY;
if (li->sidenum[0] != 0xffff) if (li->sidenum[0] != NO_SIDEDEF)
{ {
si = &sides[li->sidenum[0]]; si = &sides[li->sidenum[0]];
spawnsi = &spawnsides[li->sidenum[0]]; spawnsi = &spawnsides[li->sidenum[0]];
@ -1313,7 +1314,7 @@ static void ArchiveLines(void)
if (si->midtexture != spawnsi->midtexture) if (si->midtexture != spawnsi->midtexture)
diff |= LD_S1MIDTEX; diff |= LD_S1MIDTEX;
} }
if (li->sidenum[1] != 0xffff) if (li->sidenum[1] != NO_SIDEDEF)
{ {
si = &sides[li->sidenum[1]]; si = &sides[li->sidenum[1]];
spawnsi = &spawnsides[li->sidenum[1]]; spawnsi = &spawnsides[li->sidenum[1]];
@ -1332,7 +1333,7 @@ static void ArchiveLines(void)
if (diff) if (diff)
{ {
WRITEINT16(save_p, i); WRITEUINT32(save_p, i);
WRITEUINT8(save_p, diff); WRITEUINT8(save_p, diff);
if (diff & LD_DIFF2) if (diff & LD_DIFF2)
WRITEUINT8(save_p, diff2); WRITEUINT8(save_p, diff2);
@ -1391,21 +1392,21 @@ static void ArchiveLines(void)
WRITEINT32(save_p, li->executordelay); WRITEINT32(save_p, li->executordelay);
} }
} }
WRITEUINT16(save_p, 0xffff); WRITEUINT32(save_p, 0xffffffff);
} }
static void UnArchiveLines(void) static void UnArchiveLines(void)
{ {
UINT16 i; UINT32 i;
line_t *li; line_t *li;
side_t *si; side_t *si;
UINT8 diff, diff2; // no diff3 UINT8 diff, diff2; // no diff3
for (;;) for (;;)
{ {
i = READUINT16(save_p); i = READUINT32(save_p);
if (i == 0xffff) if (i == 0xffffffff)
break; break;
if (i > numlines) if (i > numlines)
I_Error("Invalid line number %u from server", i); I_Error("Invalid line number %u from server", i);
@ -1892,7 +1893,7 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type)
if (diff & MD_RTIME) if (diff & MD_RTIME)
WRITEINT32(save_p, mobj->reactiontime); WRITEINT32(save_p, mobj->reactiontime);
if (diff & MD_STATE) if (diff & MD_STATE)
WRITEUINT16(save_p, mobj->state-states); WRITEUINT32(save_p, mobj->state-states);
if (diff & MD_TICS) if (diff & MD_TICS)
WRITEINT32(save_p, mobj->tics); WRITEINT32(save_p, mobj->tics);
if (diff & MD_SPRITE) { if (diff & MD_SPRITE) {
@ -2916,7 +2917,7 @@ static thinker_t* LoadMobjThinker(actionf_p1 thinker)
mobj->reactiontime = mobj->info->reactiontime; mobj->reactiontime = mobj->info->reactiontime;
if (diff & MD_STATE) if (diff & MD_STATE)
mobj->state = &states[READUINT16(save_p)]; mobj->state = &states[READUINT32(save_p)];
else else
mobj->state = &states[mobj->info->spawnstate]; mobj->state = &states[mobj->info->spawnstate];
if (diff & MD_TICS) if (diff & MD_TICS)

View file

@ -1111,40 +1111,40 @@ static void P_InitializeLinedef(line_t *ld)
// cph 2006/09/30 - fix sidedef errors right away. // cph 2006/09/30 - fix sidedef errors right away.
// cph 2002/07/20 - these errors are fatal if not fixed, so apply them // cph 2002/07/20 - these errors are fatal if not fixed, so apply them
for (j = 0; j < 2; j++) for (j = 0; j < 2; j++)
if (ld->sidenum[j] != 0xffff && ld->sidenum[j] >= (UINT16)numsides) if (ld->sidenum[j] != NO_SIDEDEF && ld->sidenum[j] >= (UINT32)numsides)
{ {
ld->sidenum[j] = 0xffff; ld->sidenum[j] = NO_SIDEDEF;
CONS_Debug(DBG_SETUP, "P_InitializeLinedef: Linedef %s has out-of-range sidedef number\n", sizeu1((size_t)(ld - lines))); CONS_Debug(DBG_SETUP, "P_InitializeLinedef: Linedef %s has out-of-range sidedef number\n", sizeu1((size_t)(ld - lines)));
} }
// killough 11/98: fix common wad errors (missing sidedefs): // killough 11/98: fix common wad errors (missing sidedefs):
if (ld->sidenum[0] == 0xffff) if (ld->sidenum[0] == NO_SIDEDEF)
{ {
ld->sidenum[0] = 0; // Substitute dummy sidedef for missing right side ld->sidenum[0] = 0; // Substitute dummy sidedef for missing right side
// cph - print a warning about the bug // cph - print a warning about the bug
CONS_Debug(DBG_SETUP, "P_InitializeLinedef: Linedef %s missing first sidedef\n", sizeu1((size_t)(ld - lines))); CONS_Debug(DBG_SETUP, "P_InitializeLinedef: Linedef %s missing first sidedef\n", sizeu1((size_t)(ld - lines)));
} }
if ((ld->sidenum[1] == 0xffff) && (ld->flags & ML_TWOSIDED)) if ((ld->sidenum[1] == NO_SIDEDEF) && (ld->flags & ML_TWOSIDED))
{ {
ld->flags &= ~ML_TWOSIDED; // Clear 2s flag for missing left side ld->flags &= ~ML_TWOSIDED; // Clear 2s flag for missing left side
// cph - print a warning about the bug // cph - print a warning about the bug
CONS_Debug(DBG_SETUP, "P_InitializeLinedef: Linedef %s has two-sided flag set, but no second sidedef\n", sizeu1((size_t)(ld - lines))); CONS_Debug(DBG_SETUP, "P_InitializeLinedef: Linedef %s has two-sided flag set, but no second sidedef\n", sizeu1((size_t)(ld - lines)));
} }
if (ld->sidenum[0] != 0xffff) if (ld->sidenum[0] != NO_SIDEDEF)
{ {
sides[ld->sidenum[0]].special = ld->special; sides[ld->sidenum[0]].special = ld->special;
sides[ld->sidenum[0]].line = ld; sides[ld->sidenum[0]].line = ld;
} }
if (ld->sidenum[1] != 0xffff) if (ld->sidenum[1] != NO_SIDEDEF)
{ {
sides[ld->sidenum[1]].special = ld->special; sides[ld->sidenum[1]].special = ld->special;
sides[ld->sidenum[1]].line = ld; sides[ld->sidenum[1]].line = ld;
} }
} }
static void P_SetLinedefV1(size_t i, UINT16 vertex_num) static void P_SetLinedefV1(size_t i, UINT32 vertex_num)
{ {
if (vertex_num >= numvertexes) if (vertex_num >= numvertexes)
{ {
@ -1154,7 +1154,7 @@ static void P_SetLinedefV1(size_t i, UINT16 vertex_num)
lines[i].v1 = &vertexes[vertex_num]; lines[i].v1 = &vertexes[vertex_num];
} }
static void P_SetLinedefV2(size_t i, UINT16 vertex_num) static void P_SetLinedefV2(size_t i, UINT32 vertex_num)
{ {
if (vertex_num >= numvertexes) if (vertex_num >= numvertexes)
{ {
@ -1179,17 +1179,22 @@ static void P_LoadLinedefs(UINT8 *data)
memset(ld->stringargs, 0x00, NUMLINESTRINGARGS*sizeof(*ld->stringargs)); memset(ld->stringargs, 0x00, NUMLINESTRINGARGS*sizeof(*ld->stringargs));
ld->alpha = FRACUNIT; ld->alpha = FRACUNIT;
ld->executordelay = 0; ld->executordelay = 0;
P_SetLinedefV1(i, SHORT(mld->v1)); P_SetLinedefV1(i, (UINT16)SHORT(mld->v1));
P_SetLinedefV2(i, SHORT(mld->v2)); P_SetLinedefV2(i, (UINT16)SHORT(mld->v2));
ld->sidenum[0] = SHORT(mld->sidenum[0]); ld->sidenum[0] = (UINT16)SHORT(mld->sidenum[0]);
ld->sidenum[1] = SHORT(mld->sidenum[1]); ld->sidenum[1] = (UINT16)SHORT(mld->sidenum[1]);
if (ld->sidenum[0] == 0xffff)
ld->sidenum[0] = NO_SIDEDEF;
if (ld->sidenum[1] == 0xffff)
ld->sidenum[1] = NO_SIDEDEF;
P_InitializeLinedef(ld); P_InitializeLinedef(ld);
} }
} }
static void P_SetSidedefSector(size_t i, UINT16 sector_num) static void P_SetSidedefSector(size_t i, UINT32 sector_num)
{ {
// cph 2006/09/30 - catch out-of-range sector numbers; use sector 0 instead // cph 2006/09/30 - catch out-of-range sector numbers; use sector 0 instead
if (sector_num >= numsectors) if (sector_num >= numsectors)
@ -1350,7 +1355,7 @@ static void P_LoadSidedefs(UINT8 *data)
sd->offsetx_top = sd->offsetx_mid = sd->offsetx_bot = 0; sd->offsetx_top = sd->offsetx_mid = sd->offsetx_bot = 0;
sd->offsety_top = sd->offsety_mid = sd->offsety_bot = 0; sd->offsety_top = sd->offsety_mid = sd->offsety_bot = 0;
P_SetSidedefSector(i, SHORT(msd->sector)); P_SetSidedefSector(i, (UINT16)SHORT(msd->sector));
// Special info stored in texture fields! // Special info stored in texture fields!
switch (sd->special) switch (sd->special)
@ -2489,7 +2494,7 @@ static void P_WriteTextmap(void)
fprintf(f, "v1 = %s;\n", sizeu1(wlines[i].v1 - vertexes)); fprintf(f, "v1 = %s;\n", sizeu1(wlines[i].v1 - vertexes));
fprintf(f, "v2 = %s;\n", sizeu1(wlines[i].v2 - vertexes)); fprintf(f, "v2 = %s;\n", sizeu1(wlines[i].v2 - vertexes));
fprintf(f, "sidefront = %d;\n", wlines[i].sidenum[0]); fprintf(f, "sidefront = %d;\n", wlines[i].sidenum[0]);
if (wlines[i].sidenum[1] != 0xffff) if (wlines[i].sidenum[1] != NO_SIDEDEF)
fprintf(f, "sideback = %d;\n", wlines[i].sidenum[1]); fprintf(f, "sideback = %d;\n", wlines[i].sidenum[1]);
firsttag = Tag_FGet(&wlines[i].tags); firsttag = Tag_FGet(&wlines[i].tags);
if (firsttag != 0) if (firsttag != 0)
@ -2954,8 +2959,8 @@ static void P_LoadTextmap(void)
memset(ld->stringargs, 0x00, NUMLINESTRINGARGS*sizeof(*ld->stringargs)); memset(ld->stringargs, 0x00, NUMLINESTRINGARGS*sizeof(*ld->stringargs));
ld->alpha = FRACUNIT; ld->alpha = FRACUNIT;
ld->executordelay = 0; ld->executordelay = 0;
ld->sidenum[0] = 0xffff; ld->sidenum[0] = NO_SIDEDEF;
ld->sidenum[1] = 0xffff; ld->sidenum[1] = NO_SIDEDEF;
TextmapParse(linesPos[i], i, ParseTextmapLinedefParameter); TextmapParse(linesPos[i], i, ParseTextmapLinedefParameter);
@ -2963,7 +2968,7 @@ static void P_LoadTextmap(void)
I_Error("P_LoadTextmap: linedef %s has no v1 value set!\n", sizeu1(i)); I_Error("P_LoadTextmap: linedef %s has no v1 value set!\n", sizeu1(i));
if (!ld->v2) if (!ld->v2)
I_Error("P_LoadTextmap: linedef %s has no v2 value set!\n", sizeu1(i)); I_Error("P_LoadTextmap: linedef %s has no v2 value set!\n", sizeu1(i));
if (ld->sidenum[0] == 0xffff) if (ld->sidenum[0] == NO_SIDEDEF)
I_Error("P_LoadTextmap: linedef %s has no sidefront value set!\n", sizeu1(i)); I_Error("P_LoadTextmap: linedef %s has no sidefront value set!\n", sizeu1(i));
P_InitializeLinedef(ld); P_InitializeLinedef(ld);
@ -3017,7 +3022,7 @@ static void P_ProcessLinedefsAfterSidedefs(void)
for (; i--; ld++) for (; i--; ld++)
{ {
ld->frontsector = sides[ld->sidenum[0]].sector; //e6y: Can't be -1 here ld->frontsector = sides[ld->sidenum[0]].sector; //e6y: Can't be -1 here
ld->backsector = ld->sidenum[1] != 0xffff ? sides[ld->sidenum[1]].sector : 0; ld->backsector = ld->sidenum[1] != NO_SIDEDEF ? sides[ld->sidenum[1]].sector : 0;
if (udmf) if (udmf)
continue; continue;
@ -3256,9 +3261,9 @@ static void P_InitializeSeg(seg_t *seg)
{ {
if (seg->linedef) if (seg->linedef)
{ {
UINT16 side = seg->linedef->sidenum[seg->side]; UINT32 side = seg->linedef->sidenum[seg->side];
if (side == 0xffff) if (side == NO_SIDEDEF)
I_Error("P_InitializeSeg: Seg %s refers to side %d of linedef %s, which doesn't exist!\n", sizeu1((size_t)(seg - segs)), seg->side, sizeu1((size_t)(seg->linedef - lines))); I_Error("P_InitializeSeg: Seg %s refers to side %d of linedef %s, which doesn't exist!\n", sizeu1((size_t)(seg - segs)), seg->side, sizeu1((size_t)(seg->linedef - lines)));
seg->sidedef = &sides[side]; seg->sidedef = &sides[side];
@ -3443,7 +3448,7 @@ static boolean P_LoadExtraVertices(UINT8 **data)
static boolean P_LoadExtendedSubsectorsAndSegs(UINT8 **data, nodetype_t nodetype) static boolean P_LoadExtendedSubsectorsAndSegs(UINT8 **data, nodetype_t nodetype)
{ {
size_t i, k; size_t i, k;
INT16 m; size_t m;
seg_t *seg; seg_t *seg;
// Subsectors // Subsectors
@ -3466,23 +3471,33 @@ static boolean P_LoadExtendedSubsectorsAndSegs(UINT8 **data, nodetype_t nodetype
{ {
case NT_XGLN: case NT_XGLN:
case NT_XGL3: case NT_XGL3:
for (m = 0; m < subsectors[i].numlines; m++, k++) for (m = 0; m < (size_t)subsectors[i].numlines; m++, k++)
{ {
UINT32 vertexnum = READUINT32((*data)); UINT32 vertexnum = READUINT32((*data));
UINT16 linenum;
if (vertexnum >= numvertexes) if (vertexnum >= numvertexes)
I_Error("P_LoadExtendedSubsectorsAndSegs: Seg %s in subsector %d has invalid vertex %d!\n", sizeu1(k), m, vertexnum); I_Error("P_LoadExtendedSubsectorsAndSegs: Seg %s in subsector %s has invalid vertex %d!\n", sizeu1(k), sizeu1(m), vertexnum);
segs[k - 1 + ((m == 0) ? subsectors[i].numlines : 0)].v2 = segs[k].v1 = &vertexes[vertexnum]; segs[k - 1 + ((m == 0) ? subsectors[i].numlines : 0)].v2 = segs[k].v1 = &vertexes[vertexnum];
READUINT32((*data)); // partner, can be ignored by software renderer READUINT32((*data)); // partner, can be ignored by software renderer
linenum = (nodetype == NT_XGL3) ? READUINT32((*data)) : READUINT16((*data)); if (nodetype == NT_XGL3)
{
UINT32 linenum = READUINT32((*data));
if (linenum != 0xFFFFFFFF && linenum >= numlines)
I_Error("P_LoadExtendedSubsectorsAndSegs: Seg %s in subsector %s has invalid linedef %d!\n", sizeu1(k), sizeu2(i), linenum);
segs[k].glseg = linenum == 0xFFFFFFFF;
segs[k].linedef = linenum == 0xFFFFFFFF ? NULL : &lines[linenum];
}
else
{
UINT16 linenum = READUINT16((*data));
if (linenum != 0xFFFF && linenum >= numlines) if (linenum != 0xFFFF && linenum >= numlines)
I_Error("P_LoadExtendedSubsectorsAndSegs: Seg %s in subsector %s has invalid linedef %d!\n", sizeu1(k), sizeu2(i), linenum); I_Error("P_LoadExtendedSubsectorsAndSegs: Seg %s in subsector %s has invalid linedef %d!\n", sizeu1(k), sizeu2(i), linenum);
segs[k].glseg = (linenum == 0xFFFF); segs[k].glseg = linenum == 0xFFFF;
segs[k].linedef = (linenum == 0xFFFF) ? NULL : &lines[linenum]; segs[k].linedef = linenum == 0xFFFF ? NULL : &lines[linenum];
}
segs[k].side = READUINT8((*data)); segs[k].side = READUINT8((*data));
} }
while (segs[subsectors[i].firstline].glseg) while (segs[subsectors[i].firstline].glseg)
@ -3494,18 +3509,18 @@ static boolean P_LoadExtendedSubsectorsAndSegs(UINT8 **data, nodetype_t nodetype
break; break;
case NT_XNOD: case NT_XNOD:
for (m = 0; m < subsectors[i].numlines; m++, k++) for (m = 0; m < (size_t)subsectors[i].numlines; m++, k++)
{ {
UINT32 v1num = READUINT32((*data)); UINT32 v1num = READUINT32((*data));
UINT32 v2num = READUINT32((*data)); UINT32 v2num = READUINT32((*data));
UINT16 linenum = READUINT16((*data)); UINT16 linenum = READUINT16((*data));
if (v1num >= numvertexes) if (v1num >= numvertexes)
I_Error("P_LoadExtendedSubsectorsAndSegs: Seg %s in subsector %d has invalid v1 %d!\n", sizeu1(k), m, v1num); I_Error("P_LoadExtendedSubsectorsAndSegs: Seg %s in subsector %s has invalid v1 %d!\n", sizeu1(k), sizeu1(m), v1num);
if (v2num >= numvertexes) if (v2num >= numvertexes)
I_Error("P_LoadExtendedSubsectorsAndSegs: Seg %s in subsector %d has invalid v2 %d!\n", sizeu1(k), m, v2num); I_Error("P_LoadExtendedSubsectorsAndSegs: Seg %s in subsector %s has invalid v2 %d!\n", sizeu1(k), sizeu1(m), v2num);
if (linenum >= numlines) if (linenum >= numlines)
I_Error("P_LoadExtendedSubsectorsAndSegs: Seg %s in subsector %d has invalid linedef %d!\n", sizeu1(k), m, linenum); I_Error("P_LoadExtendedSubsectorsAndSegs: Seg %s in subsector %s has invalid linedef %d!\n", sizeu1(k), sizeu1(m), linenum);
segs[k].v1 = &vertexes[v1num]; segs[k].v1 = &vertexes[v1num];
segs[k].v2 = &vertexes[v2num]; segs[k].v2 = &vertexes[v2num];
@ -3990,7 +4005,7 @@ static void P_LinkMapData(void)
if (!seg->sidedef) if (!seg->sidedef)
CorruptMapError(va("P_LinkMapData: seg->sidedef is NULL " CorruptMapError(va("P_LinkMapData: seg->sidedef is NULL "
"(subsector %s, firstline is %d)", sizeu1(i), ss->firstline)); "(subsector %s, firstline is %d)", sizeu1(i), ss->firstline));
if (seg->sidedef - sides < 0 || seg->sidedef - sides > (UINT16)numsides) if (seg->sidedef - sides < 0 || seg->sidedef - sides > (UINT32)numsides)
CorruptMapError(va("P_LinkMapData: seg->sidedef refers to sidedef %s of %s " CorruptMapError(va("P_LinkMapData: seg->sidedef refers to sidedef %s of %s "
"(subsector %s, firstline is %d)", sizeu1(sidei), sizeu2(numsides), "(subsector %s, firstline is %d)", sizeu1(sidei), sizeu2(numsides),
sizeu3(i), ss->firstline)); sizeu3(i), ss->firstline));
@ -4915,7 +4930,7 @@ static void P_ConvertBinaryLinedefTypes(void)
break; break;
case 259: //Custom FOF case 259: //Custom FOF
if (lines[i].sidenum[1] == 0xffff) if (lines[i].sidenum[1] == NO_SIDEDEF)
I_Error("Custom FOF (tag %d) found without a linedef back side!", tag); I_Error("Custom FOF (tag %d) found without a linedef back side!", tag);
lines[i].args[0] = tag; lines[i].args[0] = tag;
@ -5269,8 +5284,8 @@ static void P_ConvertBinaryLinedefTypes(void)
lines[i].args[1] = sides[lines[i].sidenum[0]].midtexture; lines[i].args[1] = sides[lines[i].sidenum[0]].midtexture;
lines[i].args[2] = sides[lines[i].sidenum[0]].textureoffset >> FRACBITS; lines[i].args[2] = sides[lines[i].sidenum[0]].textureoffset >> FRACBITS;
lines[i].args[3] = sides[lines[i].sidenum[0]].rowoffset >> FRACBITS; lines[i].args[3] = sides[lines[i].sidenum[0]].rowoffset >> FRACBITS;
lines[i].args[4] = (lines[i].sidenum[1] != 0xffff) ? sides[lines[i].sidenum[1]].textureoffset >> FRACBITS : 0; lines[i].args[4] = (lines[i].sidenum[1] != NO_SIDEDEF) ? sides[lines[i].sidenum[1]].textureoffset >> FRACBITS : 0;
lines[i].args[5] = (lines[i].sidenum[1] != 0xffff) ? sides[lines[i].sidenum[1]].rowoffset >> FRACBITS : -1; lines[i].args[5] = (lines[i].sidenum[1] != NO_SIDEDEF) ? sides[lines[i].sidenum[1]].rowoffset >> FRACBITS : -1;
lines[i].args[6] = sides[lines[i].sidenum[0]].bottomtexture; lines[i].args[6] = sides[lines[i].sidenum[0]].bottomtexture;
break; break;
case 414: //Play sound effect case 414: //Play sound effect
@ -5374,7 +5389,7 @@ static void P_ConvertBinaryLinedefTypes(void)
lines[i].args[1] = max(sides[lines[i].sidenum[0]].textureoffset >> FRACBITS, 0); lines[i].args[1] = max(sides[lines[i].sidenum[0]].textureoffset >> FRACBITS, 0);
// failsafe: if user specifies Back Y Offset and NOT Front Y Offset, use the Back Offset // failsafe: if user specifies Back Y Offset and NOT Front Y Offset, use the Back Offset
// to be consistent with other light and fade specials // to be consistent with other light and fade specials
lines[i].args[2] = ((lines[i].sidenum[1] != 0xFFFF && !(sides[lines[i].sidenum[0]].rowoffset >> FRACBITS)) ? lines[i].args[2] = ((lines[i].sidenum[1] != NO_SIDEDEF && !(sides[lines[i].sidenum[0]].rowoffset >> FRACBITS)) ?
max(min(sides[lines[i].sidenum[1]].rowoffset >> FRACBITS, 255), 0) max(min(sides[lines[i].sidenum[1]].rowoffset >> FRACBITS, 255), 0)
: max(min(sides[lines[i].sidenum[0]].rowoffset >> FRACBITS, 255), 0)); : max(min(sides[lines[i].sidenum[0]].rowoffset >> FRACBITS, 255), 0));
} }
@ -5479,7 +5494,7 @@ static void P_ConvertBinaryLinedefTypes(void)
break; break;
case 442: //Change object type state case 442: //Change object type state
lines[i].args[0] = tag; lines[i].args[0] = tag;
lines[i].args[1] = (lines[i].sidenum[1] == 0xffff) ? 1 : 0; lines[i].args[1] = (lines[i].sidenum[1] == NO_SIDEDEF) ? 1 : 0;
break; break;
case 443: //Call Lua function case 443: //Call Lua function
if (lines[i].stringargs[0] == NULL) if (lines[i].stringargs[0] == NULL)
@ -5547,7 +5562,7 @@ static void P_ConvertBinaryLinedefTypes(void)
case 452: //Set FOF translucency case 452: //Set FOF translucency
lines[i].args[0] = sides[lines[i].sidenum[0]].textureoffset >> FRACBITS; lines[i].args[0] = sides[lines[i].sidenum[0]].textureoffset >> FRACBITS;
lines[i].args[1] = sides[lines[i].sidenum[0]].rowoffset >> FRACBITS; lines[i].args[1] = sides[lines[i].sidenum[0]].rowoffset >> FRACBITS;
lines[i].args[2] = lines[i].sidenum[1] != 0xffff ? (sides[lines[i].sidenum[1]].textureoffset >> FRACBITS) : (P_AproxDistance(lines[i].dx, lines[i].dy) >> FRACBITS); lines[i].args[2] = lines[i].sidenum[1] != NO_SIDEDEF ? (sides[lines[i].sidenum[1]].textureoffset >> FRACBITS) : (P_AproxDistance(lines[i].dx, lines[i].dy) >> FRACBITS);
if (lines[i].flags & ML_MIDPEG) if (lines[i].flags & ML_MIDPEG)
lines[i].args[3] |= TMST_RELATIVE; lines[i].args[3] |= TMST_RELATIVE;
if (lines[i].flags & ML_NOCLIMB) if (lines[i].flags & ML_NOCLIMB)
@ -5556,8 +5571,8 @@ static void P_ConvertBinaryLinedefTypes(void)
case 453: //Fade FOF case 453: //Fade FOF
lines[i].args[0] = sides[lines[i].sidenum[0]].textureoffset >> FRACBITS; lines[i].args[0] = sides[lines[i].sidenum[0]].textureoffset >> FRACBITS;
lines[i].args[1] = sides[lines[i].sidenum[0]].rowoffset >> FRACBITS; lines[i].args[1] = sides[lines[i].sidenum[0]].rowoffset >> FRACBITS;
lines[i].args[2] = lines[i].sidenum[1] != 0xffff ? (sides[lines[i].sidenum[1]].textureoffset >> FRACBITS) : (lines[i].dx >> FRACBITS); lines[i].args[2] = lines[i].sidenum[1] != NO_SIDEDEF ? (sides[lines[i].sidenum[1]].textureoffset >> FRACBITS) : (lines[i].dx >> FRACBITS);
lines[i].args[3] = lines[i].sidenum[1] != 0xffff ? (sides[lines[i].sidenum[1]].rowoffset >> FRACBITS) : (abs(lines[i].dy) >> FRACBITS); lines[i].args[3] = lines[i].sidenum[1] != NO_SIDEDEF ? (sides[lines[i].sidenum[1]].rowoffset >> FRACBITS) : (abs(lines[i].dy) >> FRACBITS);
if (lines[i].flags & ML_MIDPEG) if (lines[i].flags & ML_MIDPEG)
lines[i].args[4] |= TMFT_RELATIVE; lines[i].args[4] |= TMFT_RELATIVE;
if (lines[i].flags & ML_WRAPMIDTEX) if (lines[i].flags & ML_WRAPMIDTEX)
@ -5584,7 +5599,7 @@ static void P_ConvertBinaryLinedefTypes(void)
break; break;
case 455: //Fade colormap case 455: //Fade colormap
{ {
INT32 speed = (INT32)((((lines[i].flags & ML_DONTPEGBOTTOM) || !sides[lines[i].sidenum[0]].rowoffset) && lines[i].sidenum[1] != 0xFFFF) ? INT32 speed = (INT32)((((lines[i].flags & ML_DONTPEGBOTTOM) || !sides[lines[i].sidenum[0]].rowoffset) && lines[i].sidenum[1] != NO_SIDEDEF) ?
abs(sides[lines[i].sidenum[1]].rowoffset >> FRACBITS) abs(sides[lines[i].sidenum[1]].rowoffset >> FRACBITS)
: abs(sides[lines[i].sidenum[0]].rowoffset >> FRACBITS)); : abs(sides[lines[i].sidenum[0]].rowoffset >> FRACBITS));
@ -5614,7 +5629,7 @@ static void P_ConvertBinaryLinedefTypes(void)
lines[i].args[0] = tag; lines[i].args[0] = tag;
lines[i].args[1] = sides[lines[i].sidenum[0]].textureoffset >> FRACBITS; lines[i].args[1] = sides[lines[i].sidenum[0]].textureoffset >> FRACBITS;
lines[i].args[2] = sides[lines[i].sidenum[0]].rowoffset >> FRACBITS; lines[i].args[2] = sides[lines[i].sidenum[0]].rowoffset >> FRACBITS;
lines[i].args[3] = (lines[i].sidenum[1] != 0xffff) ? sides[lines[i].sidenum[1]].textureoffset >> FRACBITS : 0; lines[i].args[3] = (lines[i].sidenum[1] != NO_SIDEDEF) ? sides[lines[i].sidenum[1]].textureoffset >> FRACBITS : 0;
lines[i].args[4] = !!(lines[i].flags & ML_NOSKEW); lines[i].args[4] = !!(lines[i].flags & ML_NOSKEW);
break; break;
case 459: //Control text prompt case 459: //Control text prompt
@ -5634,7 +5649,7 @@ static void P_ConvertBinaryLinedefTypes(void)
lines[i].args[2] |= TMP_ALLPLAYERS; lines[i].args[2] |= TMP_ALLPLAYERS;
if (lines[i].flags & ML_MIDSOLID) if (lines[i].flags & ML_MIDSOLID)
lines[i].args[2] |= TMP_FREEZETHINKERS;*/ lines[i].args[2] |= TMP_FREEZETHINKERS;*/
lines[i].args[3] = (lines[i].sidenum[1] != 0xFFFF) ? sides[lines[i].sidenum[1]].textureoffset >> FRACBITS : tag; lines[i].args[3] = (lines[i].sidenum[1] != NO_SIDEDEF) ? sides[lines[i].sidenum[1]].textureoffset >> FRACBITS : tag;
break; break;
case 460: //Award rings case 460: //Award rings
lines[i].args[0] = sides[lines[i].sidenum[0]].textureoffset >> FRACBITS; lines[i].args[0] = sides[lines[i].sidenum[0]].textureoffset >> FRACBITS;
@ -5647,7 +5662,7 @@ static void P_ConvertBinaryLinedefTypes(void)
lines[i].args[3] = (lines[i].flags & ML_SKEWTD) ? AngleFixed(R_PointToAngle2(lines[i].v1->x, lines[i].v1->y, lines[i].v2->x, lines[i].v2->y)) >> FRACBITS : 0; lines[i].args[3] = (lines[i].flags & ML_SKEWTD) ? AngleFixed(R_PointToAngle2(lines[i].v1->x, lines[i].v1->y, lines[i].v2->x, lines[i].v2->y)) >> FRACBITS : 0;
if (lines[i].flags & ML_NOCLIMB) if (lines[i].flags & ML_NOCLIMB)
{ {
if (lines[i].sidenum[1] != 0xffff) // Make sure the linedef has a back side if (lines[i].sidenum[1] != NO_SIDEDEF) // Make sure the linedef has a back side
{ {
lines[i].args[4] = 1; lines[i].args[4] = 1;
lines[i].args[5] = sides[lines[i].sidenum[1]].textureoffset >> FRACBITS; lines[i].args[5] = sides[lines[i].sidenum[1]].textureoffset >> FRACBITS;
@ -5681,7 +5696,7 @@ static void P_ConvertBinaryLinedefTypes(void)
lines[i].args[0] = tag; lines[i].args[0] = tag;
lines[i].args[1] = sides[lines[i].sidenum[0]].textureoffset >> FRACBITS; lines[i].args[1] = sides[lines[i].sidenum[0]].textureoffset >> FRACBITS;
lines[i].args[2] = sides[lines[i].sidenum[0]].rowoffset >> FRACBITS; lines[i].args[2] = sides[lines[i].sidenum[0]].rowoffset >> FRACBITS;
if (lines[i].sidenum[1] != 0xffff) if (lines[i].sidenum[1] != NO_SIDEDEF)
lines[i].args[3] = sides[lines[i].sidenum[1]].textureoffset >> FRACBITS; lines[i].args[3] = sides[lines[i].sidenum[1]].textureoffset >> FRACBITS;
break; break;
case 482: //Polyobject - move case 482: //Polyobject - move
@ -5753,7 +5768,7 @@ static void P_ConvertBinaryLinedefTypes(void)
if (!(lines[i].flags & ML_DONTPEGBOTTOM)) if (!(lines[i].flags & ML_DONTPEGBOTTOM))
lines[i].args[1] /= 100; lines[i].args[1] /= 100;
// allow Back Y Offset to be consistent with other fade specials // allow Back Y Offset to be consistent with other fade specials
lines[i].args[2] = (lines[i].sidenum[1] != 0xffff && !sides[lines[i].sidenum[0]].rowoffset) ? lines[i].args[2] = (lines[i].sidenum[1] != NO_SIDEDEF && !sides[lines[i].sidenum[0]].rowoffset) ?
abs(sides[lines[i].sidenum[1]].rowoffset >> FRACBITS) abs(sides[lines[i].sidenum[1]].rowoffset >> FRACBITS)
: abs(sides[lines[i].sidenum[0]].rowoffset >> FRACBITS); : abs(sides[lines[i].sidenum[0]].rowoffset >> FRACBITS);
if (lines[i].flags & ML_MIDPEG) if (lines[i].flags & ML_MIDPEG)
@ -5780,7 +5795,7 @@ static void P_ConvertBinaryLinedefTypes(void)
lines[i].args[0] = tag; lines[i].args[0] = tag;
if (lines[i].flags & ML_MIDPEG) if (lines[i].flags & ML_MIDPEG)
{ {
if (lines[i].sidenum[1] == 0xffff) if (lines[i].sidenum[1] == NO_SIDEDEF)
{ {
CONS_Debug(DBG_GAMELOGIC, "Line special %d (line #%s) missing back side!\n", lines[i].special, sizeu1(i)); CONS_Debug(DBG_GAMELOGIC, "Line special %d (line #%s) missing back side!\n", lines[i].special, sizeu1(i));
lines[i].special = 0; lines[i].special = 0;
@ -5810,7 +5825,7 @@ static void P_ConvertBinaryLinedefTypes(void)
lines[i].args[0] = lines[i].special >= 507; lines[i].args[0] = lines[i].special >= 507;
if (lines[i].special % 2 == 0) if (lines[i].special % 2 == 0)
{ {
if (lines[i].sidenum[1] == 0xffff) if (lines[i].sidenum[1] == NO_SIDEDEF)
{ {
CONS_Debug(DBG_GAMELOGIC, "Line special %d (line #%s) missing back side!\n", lines[i].special, sizeu1(i)); CONS_Debug(DBG_GAMELOGIC, "Line special %d (line #%s) missing back side!\n", lines[i].special, sizeu1(i));
lines[i].special = 0; lines[i].special = 0;
@ -5966,7 +5981,7 @@ static void P_ConvertBinaryLinedefTypes(void)
{ {
UINT8 side = lines[i].special >= 714; UINT8 side = lines[i].special >= 714;
if (side == 1 && lines[i].sidenum[1] == 0xffff) if (side == 1 && lines[i].sidenum[1] == NO_SIDEDEF)
CONS_Debug(DBG_GAMELOGIC, "P_ConvertBinaryMap: Line special %d (line #%s) missing 2nd side!\n", lines[i].special, sizeu1(i)); CONS_Debug(DBG_GAMELOGIC, "P_ConvertBinaryMap: Line special %d (line #%s) missing 2nd side!\n", lines[i].special, sizeu1(i));
else else
{ {

View file

@ -557,7 +557,7 @@ static inline sector_t *getSector(INT32 currentSector, INT32 line, INT32 side)
*/ */
static inline boolean twoSided(INT32 sector, INT32 line) static inline boolean twoSided(INT32 sector, INT32 line)
{ {
return (sectors[sector].lines[line])->sidenum[1] != 0xffff; return (sectors[sector].lines[line])->sidenum[1] != NO_SIDEDEF;
} }
#endif #endif
@ -2897,7 +2897,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
{ {
size_t linenum; size_t linenum;
side_t *setfront = &sides[line->sidenum[0]]; side_t *setfront = &sides[line->sidenum[0]];
side_t *setback = (line->args[3] && line->sidenum[1] != 0xffff) ? &sides[line->sidenum[1]] : setfront; side_t *setback = (line->args[3] && line->sidenum[1] != NO_SIDEDEF) ? &sides[line->sidenum[1]] : setfront;
side_t *this; side_t *this;
boolean always = !(line->args[2]); // If args[2] is set: Only change mid texture if mid texture already exists on tagged lines, etc. boolean always = !(line->args[2]); // If args[2] is set: Only change mid texture if mid texture already exists on tagged lines, etc.
@ -2919,7 +2919,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
} }
// Back side // Back side
if (line->args[1] != TMSD_FRONT && lines[linenum].sidenum[1] != 0xffff) if (line->args[1] != TMSD_FRONT && lines[linenum].sidenum[1] != NO_SIDEDEF)
{ {
this = &sides[lines[linenum].sidenum[1]]; this = &sides[lines[linenum].sidenum[1]];
if (always || this->toptexture) this->toptexture = setback->toptexture; if (always || this->toptexture) this->toptexture = setback->toptexture;
@ -3153,7 +3153,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
if (line->args[2] & TMCF_RELATIVE) if (line->args[2] & TMCF_RELATIVE)
{ {
extracolormap_t *target = (!udmf && (line->flags & ML_TFERLINE) && line->sidenum[1] != 0xFFFF) ? extracolormap_t *target = (!udmf && (line->flags & ML_TFERLINE) && line->sidenum[1] != NO_SIDEDEF) ?
sides[line->sidenum[1]].colormap_data : sectors[secnum].extra_colormap; // use back colormap instead of target sector sides[line->sidenum[1]].colormap_data : sectors[secnum].extra_colormap; // use back colormap instead of target sector
extracolormap_t *exc = R_AddColormaps( extracolormap_t *exc = R_AddColormaps(
@ -3482,7 +3482,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
} }
if (!udmf && (line->flags & ML_TFERLINE)) // use back colormap instead of target sector if (!udmf && (line->flags & ML_TFERLINE)) // use back colormap instead of target sector
sectors[secnum].extra_colormap = (line->sidenum[1] != 0xFFFF) ? sectors[secnum].extra_colormap = (line->sidenum[1] != NO_SIDEDEF) ?
sides[line->sidenum[1]].colormap_data : NULL; sides[line->sidenum[1]].colormap_data : NULL;
exc = sectors[secnum].extra_colormap; exc = sectors[secnum].extra_colormap;
@ -7598,7 +7598,7 @@ static void P_SpawnScrollers(void)
{ {
if (l->args[1] != TMSD_BACK) if (l->args[1] != TMSD_BACK)
Add_Scroller(sc_side, l->args[2] << (FRACBITS - SCROLL_SHIFT), l->args[3] << (FRACBITS - SCROLL_SHIFT), control, lines[s].sidenum[0], accel, 0); Add_Scroller(sc_side, l->args[2] << (FRACBITS - SCROLL_SHIFT), l->args[3] << (FRACBITS - SCROLL_SHIFT), control, lines[s].sidenum[0], accel, 0);
if (l->args[1] != TMSD_FRONT && lines[s].sidenum[1] != 0xffff) if (l->args[1] != TMSD_FRONT && lines[s].sidenum[1] != NO_SIDEDEF)
Add_Scroller(sc_side, l->args[2] << (FRACBITS - SCROLL_SHIFT), l->args[3] << (FRACBITS - SCROLL_SHIFT), control, lines[s].sidenum[1], accel, 0); Add_Scroller(sc_side, l->args[2] << (FRACBITS - SCROLL_SHIFT), l->args[3] << (FRACBITS - SCROLL_SHIFT), control, lines[s].sidenum[1], accel, 0);
} }
break; break;
@ -7609,7 +7609,7 @@ static void P_SpawnScrollers(void)
Add_Scroller(sc_side, -l->args[1] << FRACBITS, l->args[2] << FRACBITS, -1, l->sidenum[0], accel, 0); Add_Scroller(sc_side, -l->args[1] << FRACBITS, l->args[2] << FRACBITS, -1, l->sidenum[0], accel, 0);
if (l->args[0] != TMSD_FRONT) if (l->args[0] != TMSD_FRONT)
{ {
if (l->sidenum[1] != 0xffff) if (l->sidenum[1] != NO_SIDEDEF)
Add_Scroller(sc_side, -l->args[1] << FRACBITS, l->args[2] << FRACBITS, -1, l->sidenum[1], accel, 0); Add_Scroller(sc_side, -l->args[1] << FRACBITS, l->args[2] << FRACBITS, -1, l->sidenum[1], accel, 0);
else else
CONS_Debug(DBG_GAMELOGIC, "Line special 500 (line #%s) missing back side!\n", sizeu1(i)); CONS_Debug(DBG_GAMELOGIC, "Line special 500 (line #%s) missing back side!\n", sizeu1(i));

View file

@ -512,6 +512,8 @@ typedef enum
#define NUMLINEARGS 10 #define NUMLINEARGS 10
#define NUMLINESTRINGARGS 2 #define NUMLINESTRINGARGS 2
#define NO_SIDEDEF 0xFFFFFFFF
typedef struct line_s typedef struct line_s
{ {
// Vertices, from v1 to v2. // Vertices, from v1 to v2.
@ -529,7 +531,7 @@ typedef struct line_s
char *stringargs[NUMLINESTRINGARGS]; char *stringargs[NUMLINESTRINGARGS];
// Visual appearance: sidedefs. // Visual appearance: sidedefs.
UINT16 sidenum[2]; // sidenum[1] will be 0xffff if one-sided UINT32 sidenum[2]; // sidenum[1] will be NO_SIDEDEF if one-sided
fixed_t alpha; // translucency fixed_t alpha; // translucency
UINT8 blendmode; // blendmode UINT8 blendmode; // blendmode
INT32 executordelay; INT32 executordelay;