- use regular indices instead of xindices for the SEQ list.

This also fixes incorrect use of walls in the nnext sector checks for sequences.
This commit is contained in:
Christoph Oelckers 2021-11-19 16:50:27 +01:00
parent c019e118a5
commit 1472d021f6
2 changed files with 49 additions and 60 deletions

View file

@ -3531,16 +3531,16 @@ void useSeqSpawnerGen(DBloodActor* sourceactor, int objType, int index, DBloodAc
if (pXSource->data2 <= 0)
{
if (pXSource->data3 == 3 || pXSource->data3 == 1)
seqKill(2, sector[index].extra);
seqKill(2, index);
if (pXSource->data3 == 3 || pXSource->data3 == 2)
seqKill(1, sector[index].extra);
seqKill(1, index);
}
else
{
if (pXSource->data3 == 3 || pXSource->data3 == 1)
seqSpawn(pXSource->data2, 2, sector[index].extra, -1);
seqSpawn(pXSource->data2, SS_FLOOR, index, -1);
if (pXSource->data3 == 3 || pXSource->data3 == 2)
seqSpawn(pXSource->data2, 1, sector[index].extra, -1);
seqSpawn(pXSource->data2, SS_CEILING, index, -1);
}
return;
@ -3548,26 +3548,26 @@ void useSeqSpawnerGen(DBloodActor* sourceactor, int objType, int index, DBloodAc
if (pXSource->data2 <= 0)
{
if (pXSource->data3 == 3 || pXSource->data3 == 1)
seqKill(0, wall[index].extra);
seqKill(0, index);
if ((pXSource->data3 == 3 || pXSource->data3 == 2) && (wall[index].cstat & CSTAT_WALL_MASKED))
seqKill(4, wall[index].extra);
seqKill(4, index);
}
else
{
if (pXSource->data3 == 3 || pXSource->data3 == 1)
seqSpawn(pXSource->data2, 0, wall[index].extra, -1);
seqSpawn(pXSource->data2, SS_WALL, index, -1);
if (pXSource->data3 == 3 || pXSource->data3 == 2) {
if (wall[index].nextwall < 0) {
if (pXSource->data3 == 3)
seqSpawn(pXSource->data2, 0, wall[index].extra, -1);
seqSpawn(pXSource->data2, SS_WALL, index, -1);
} else {
if (!(wall[index].cstat & CSTAT_WALL_MASKED))
wall[index].cstat |= CSTAT_WALL_MASKED;
seqSpawn(pXSource->data2, 4, wall[index].extra, -1);
seqSpawn(pXSource->data2, SS_MASKED, index, -1);
}
}
@ -3925,7 +3925,7 @@ bool condCheckMixed(DBloodActor* aCond, const EVENT& event, int cmpOp, bool PUSH
{
case OBJ_WALL:
{
if (!xwallRangeIsFine(wall[objIndex].extra))
if (!wall[objIndex].hasX())
return condCmp(0, arg1, arg2, cmpOp);
auto pObj = &wall[objIndex];
@ -3946,17 +3946,17 @@ bool condCheckMixed(DBloodActor* aCond, const EVENT& event, int cmpOp, bool PUSH
case 70:
switch (arg3)
{
default: return (condCmp(seqGetID(0, pObj->extra), arg1, arg2, cmpOp) || condCmp(seqGetID(4, pObj->extra), arg1, arg2, cmpOp));
case 1: return condCmp(seqGetID(0, pObj->extra), arg1, arg2, cmpOp);
case 2: return condCmp(seqGetID(4, pObj->extra), arg1, arg2, cmpOp);
default: return (condCmp(seqGetID(0, objIndex), arg1, arg2, cmpOp) || condCmp(seqGetID(4, objIndex), arg1, arg2, cmpOp));
case 1: return condCmp(seqGetID(0, objIndex), arg1, arg2, cmpOp);
case 2: return condCmp(seqGetID(4, objIndex), arg1, arg2, cmpOp);
}
break;
case 71:
switch (arg3)
{
default: return (condCmp(seqGetStatus(0, pObj->extra), arg1, arg2, cmpOp) || condCmp(seqGetStatus(4, pObj->extra), arg1, arg2, cmpOp));
case 1: return condCmp(seqGetStatus(0, pObj->extra), arg1, arg2, cmpOp);
case 2: return condCmp(seqGetStatus(4, pObj->extra), arg1, arg2, cmpOp);
default: return (condCmp(seqGetStatus(0, objIndex), arg1, arg2, cmpOp) || condCmp(seqGetStatus(4, objIndex), arg1, arg2, cmpOp));
case 1: return condCmp(seqGetStatus(0, objIndex), arg1, arg2, cmpOp);
case 2: return condCmp(seqGetStatus(4, objIndex), arg1, arg2, cmpOp);
}
break;
}
@ -3989,10 +3989,10 @@ bool condCheckMixed(DBloodActor* aCond, const EVENT& event, int cmpOp, bool PUSH
}
case OBJ_SECTOR:
{
if (xsectRangeIsFine(sector[objIndex].extra))
if (!sector[objIndex].hasX())
return condCmp(0, arg1, arg2, cmpOp);
XSECTOR* pXObj = &xsector[sector[objIndex].extra];
XSECTOR* pXObj = &sector[objIndex].xs();
switch (cond) {
case 41: return condCmp(pXObj->data, arg1, arg2, cmpOp);
case 50: return condCmp(pXObj->rxID, arg1, arg2, cmpOp);
@ -4009,17 +4009,17 @@ bool condCheckMixed(DBloodActor* aCond, const EVENT& event, int cmpOp, bool PUSH
// wall???
switch (arg3)
{
default: return (condCmp(seqGetID(1, wall[objIndex].extra), arg1, arg2, cmpOp) || condCmp(seqGetID(2, wall[objIndex].extra), arg1, arg2, cmpOp));
case 1: return condCmp(seqGetID(1, wall[objIndex].extra), arg1, arg2, cmpOp);
case 2: return condCmp(seqGetID(2, wall[objIndex].extra), arg1, arg2, cmpOp);
default: return (condCmp(seqGetID(1, objIndex), arg1, arg2, cmpOp) || condCmp(seqGetID(2, objIndex), arg1, arg2, cmpOp));
case 1: return condCmp(seqGetID(1, objIndex), arg1, arg2, cmpOp);
case 2: return condCmp(seqGetID(2, objIndex), arg1, arg2, cmpOp);
}
break;
case 71:
switch (arg3)
{
default: return (condCmp(seqGetStatus(1, wall[objIndex].extra), arg1, arg2, cmpOp) || condCmp(seqGetStatus(2, wall[objIndex].extra), arg1, arg2, cmpOp));
case 1: return condCmp(seqGetStatus(1, wall[objIndex].extra), arg1, arg2, cmpOp);
case 2: return condCmp(seqGetStatus(2, wall[objIndex].extra), arg1, arg2, cmpOp);
default: return (condCmp(seqGetStatus(1, objIndex), arg1, arg2, cmpOp) || condCmp(seqGetStatus(2, objIndex), arg1, arg2, cmpOp));
case 1: return condCmp(seqGetStatus(1, objIndex), arg1, arg2, cmpOp);
case 2: return condCmp(seqGetStatus(2, objIndex), arg1, arg2, cmpOp);
}
break;
}

View file

@ -126,13 +126,10 @@ void seqPrecacheId(int id, int palette)
//
//---------------------------------------------------------------------------
void UpdateCeiling(int nXSector, SEQFRAME* pFrame)
void UpdateCeiling(int nSector, SEQFRAME* pFrame)
{
assert(nXSector > 0 && nXSector < kMaxXSectors);
int nSector = xsector[nXSector].reference;
assert(validSectorIndex(nSector));
sectortype* pSector = &sector[nSector];
assert(pSector->extra == nXSector);
pSector->ceilingpicnum = seqGetTile(pFrame);
pSector->ceilingshade = pFrame->shade;
if (pFrame->palette)
@ -145,13 +142,10 @@ void UpdateCeiling(int nXSector, SEQFRAME* pFrame)
//
//---------------------------------------------------------------------------
void UpdateFloor(int nXSector, SEQFRAME* pFrame)
void UpdateFloor(int nSector, SEQFRAME* pFrame)
{
assert(nXSector > 0 && nXSector < kMaxXSectors);
int nSector = xsector[nXSector].reference;
assert(validSectorIndex(nSector));
sectortype* pSector = &sector[nSector];
assert(pSector->extra == nXSector);
pSector->floorpicnum = seqGetTile(pFrame);
pSector->floorshade = pFrame->shade;
if (pFrame->palette)
@ -164,13 +158,11 @@ void UpdateFloor(int nXSector, SEQFRAME* pFrame)
//
//---------------------------------------------------------------------------
void UpdateWall(int nXWall, SEQFRAME* pFrame)
void UpdateWall(int nWall, SEQFRAME* pFrame)
{
assert(nXWall > 0 && nXWall < kMaxXWalls);
int nWall = xwall[nXWall].reference;
assert(nWall >= 0 && nWall < kMaxWalls);
assert(validWallIndex(nWall));
walltype* pWall = &wall[nWall];
assert(pWall->extra == nXWall);
assert(pWall->hasX());
pWall->picnum = seqGetTile(pFrame);
if (pFrame->palette)
pWall->pal = pFrame->palette;
@ -198,15 +190,12 @@ void UpdateWall(int nXWall, SEQFRAME* pFrame)
//
//---------------------------------------------------------------------------
void UpdateMasked(int nXWall, SEQFRAME* pFrame)
void UpdateMasked(int nWall, SEQFRAME* pFrame)
{
assert(nXWall > 0 && nXWall < kMaxXWalls);
int nWall = xwall[nXWall].reference;
assert(nWall >= 0 && nWall < kMaxWalls);
assert(validWallIndex(nWall));
walltype* pWall = &wall[nWall];
assert(pWall->extra == nXWall);
assert(pWall->nextwall >= 0);
walltype* pWallNext = &wall[pWall->nextwall];
assert(pWall->hasX());
walltype* pWallNext = pWall->nextWall();
pWall->overpicnum = pWallNext->overpicnum = seqGetTile(pFrame);
if (pFrame->palette)
pWall->pal = pWallNext->pal = pFrame->palette;
@ -496,9 +485,9 @@ static ActiveList activeList;
//
//---------------------------------------------------------------------------
SEQINST* GetInstance(int type, int nXIndex)
SEQINST* GetInstance(int type, int nIndex)
{
return activeList.get(type, nXIndex);
return activeList.get(type, nIndex);
}
SEQINST* GetInstance(DBloodActor* actor)
@ -520,10 +509,10 @@ int seqGetID(DBloodActor* actor)
return -1;
}
void seqKill(int type, int nXIndex)
void seqKill(int type, int nIndex)
{
assert(type != SS_SPRITE);
activeList.remove(type, nXIndex);
activeList.remove(type, nIndex);
}
void seqKillAll()
@ -606,14 +595,14 @@ Seq* getSequence(int res_id)
//
//---------------------------------------------------------------------------
void seqSpawn(int nSeqID, int type, int nXIndex, int callback)
void seqSpawn(int nSeqID, int type, int nIndex, int callback)
{
assert(type != SS_SPRITE);
Seq* pSequence = getSequence(nSeqID);
if (pSequence == nullptr) return;
SEQINST* pInst = activeList.get(type, nXIndex);
SEQINST* pInst = activeList.get(type, nIndex);
if (!pInst)
{
pInst = activeList.getNew();
@ -631,7 +620,7 @@ void seqSpawn(int nSeqID, int type, int nXIndex, int callback)
pInst->timeCounter = (short)pSequence->ticksPerFrame;
pInst->frameIndex = 0;
pInst->type = type;
pInst->seqindex = nXIndex;
pInst->seqindex = nIndex;
pInst->actor = nullptr;
pInst->Update();
}
@ -671,16 +660,16 @@ void seqSpawn(int nSeqID, DBloodActor* actor, int callback)
//
//---------------------------------------------------------------------------
int seqGetStatus(int type, int nXIndex)
int seqGetStatus(int type, int nIndex)
{
SEQINST* pInst = activeList.get(type, nXIndex);
SEQINST* pInst = activeList.get(type, nIndex);
if (pInst) return pInst->frameIndex;
return -1;
}
int seqGetID(int type, int nXIndex)
int seqGetID(int type, int nIndex)
{
SEQINST* pInst = activeList.get(type, nXIndex);
SEQINST* pInst = activeList.get(type, nIndex);
if (pInst) return pInst->nSeqID;
return -1;
}
@ -727,11 +716,11 @@ void seqProcess(int nTicks)
else if (pInst->type == SS_MASKED)
{
int nWall = xwall[index].reference;
assert(nWall >= 0 && nWall < kMaxWalls);
wall[nWall].cstat &= ~(8 + 16 + 32);
if (wall[nWall].nextwall != -1)
wall[wall[nWall].nextwall].cstat &= ~(8 + 16 + 32);
assert(index >= 0 && index < kMaxWalls);
auto pWall = &wall[index];
pWall->cstat &= ~(8 + 16 + 32);
if (pWall->twoSided())
pWall->nextWall()->cstat &= ~(8 + 16 + 32);
}
}