- addFlash at.al.

This commit is contained in:
Christoph Oelckers 2021-11-22 18:51:22 +01:00
parent 20891f276d
commit dfbb5192fb
13 changed files with 73 additions and 74 deletions

View file

@ -177,7 +177,7 @@ void FuncLava(int, int, int, int);
void InitLights(); void InitLights();
void AddFlash(int nSector, int x, int y, int z, int val); void AddFlash(sectortype* pSector, int x, int y, int z, int val);
void SetTorch(int nPlayer, int bTorchOnOff); void SetTorch(int nPlayer, int bTorchOnOff);
void UndoFlashes(); void UndoFlashes();
void DoLights(); void DoLights();

View file

@ -421,7 +421,7 @@ MOVEEND:
if (nVal == 0 && nType != 15 && nType != 3) if (nVal == 0 && nType != 15 && nType != 3)
{ {
AddFlash(pSprite->sectnum, pSprite->x, pSprite->y, pSprite->z, 0); AddFlash(pSprite->sector(), pSprite->x, pSprite->y, pSprite->z, 0);
if (pSprite->pal != 5) { if (pSprite->pal != 5) {
pSprite->pal = 1; pSprite->pal = 1;
@ -552,7 +552,7 @@ HITWALL:
nRadialBullet = -1; nRadialBullet = -1;
AddFlash(pSprite->sectnum, pSprite->x, pSprite->y, pSprite->z, 128); AddFlash(pSprite->sector(), pSprite->x, pSprite->y, pSprite->z, 128);
} }
} }
} }

View file

@ -54,20 +54,19 @@ void precache()
for (int k = 1; k <= picanm[j].num; k++) markTileForPrecache(j + k, sectp->floorpal); for (int k = 1; k <= picanm[j].num; k++) markTileForPrecache(j + k, sectp->floorpal);
} }
for (i = 0; i < numwalls; i++) for(auto& wal : walls())
{ {
auto wallp = &wall[i]; int j = wal.picnum;
int j = wallp->picnum; markTileForPrecache(j, wal.pal);
markTileForPrecache(j, wallp->pal);
if (picanm[j].sf & PICANM_ANIMTYPE_MASK) if (picanm[j].sf & PICANM_ANIMTYPE_MASK)
for (int k = 1; k <= picanm[j].num; k++) markTileForPrecache(j + k, wallp->pal); for (int k = 1; k <= picanm[j].num; k++) markTileForPrecache(j + k, wal.pal);
if (wallp->twoSided()) if (wal.twoSided())
{ {
int j = wallp->overpicnum; int j = wal.overpicnum;
markTileForPrecache(j, wallp->pal); markTileForPrecache(j, wal.pal);
if (picanm[j].sf & PICANM_ANIMTYPE_MASK) if (picanm[j].sf & PICANM_ANIMTYPE_MASK)
for (int k = 1; k <= picanm[j].num; k++) markTileForPrecache(j + k, wallp->pal); for (int k = 1; k <= picanm[j].num; k++) markTileForPrecache(j + k, wal.pal);
} }
} }

View file

@ -175,7 +175,7 @@ void DoRedAlert(int nVal)
{ {
auto spri = &ac->s(); auto spri = &ac->s();
PlayFXAtXYZ(StaticSound[kSoundAlarm], spri->x, spri->y, spri->z, spri->sectnum); PlayFXAtXYZ(StaticSound[kSoundAlarm], spri->x, spri->y, spri->z, spri->sectnum);
AddFlash(spri->sectnum, spri->x, spri->y, spri->z, 192); AddFlash(spri->sector(), spri->x, spri->y, spri->z, 192);
} }
} }
} }

View file

@ -158,6 +158,10 @@ public:
{ {
} }
ExhumedSectIterator(sectortype* stat) : SectIterator(stat)
{
}
DExhumedActor* Next() DExhumedActor* Next()
{ {
int n = NextIndex(); int n = NextIndex();

View file

@ -202,7 +202,7 @@ void ExplodeGrenade(DExhumedActor* pActor)
runlist_RadialDamageEnemy(pActor, nDamage, BulletInfo[kWeaponGrenade].nRadius); runlist_RadialDamageEnemy(pActor, nDamage, BulletInfo[kWeaponGrenade].nRadius);
BuildAnim(nullptr, var_28, 0, pGrenadeSprite->x, pGrenadeSprite->y, pGrenadeSprite->z, pGrenadeSprite->sectnum, var_20, 4); BuildAnim(nullptr, var_28, 0, pGrenadeSprite->x, pGrenadeSprite->y, pGrenadeSprite->z, pGrenadeSprite->sectnum, var_20, 4);
AddFlash(pGrenadeSprite->sectnum, pGrenadeSprite->x, pGrenadeSprite->y, pGrenadeSprite->z, 128); AddFlash(pGrenadeSprite->sector(), pGrenadeSprite->x, pGrenadeSprite->y, pGrenadeSprite->z, 128);
DestroyGrenade(pActor); DestroyGrenade(pActor);
} }

View file

@ -623,7 +623,7 @@ loc_flag:
{ {
BuildFlash(nPlayer, 512); BuildFlash(nPlayer, 512);
AddFlash( AddFlash(
pPlayerSprite->sectnum, pPlayerSprite->sector(),
pPlayerSprite->x, pPlayerSprite->x,
pPlayerSprite->y, pPlayerSprite->y,
pPlayerSprite->z, pPlayerSprite->z,

View file

@ -346,7 +346,7 @@ void DropMagic(DExhumedActor* pActor)
if (pAnimActor) if (pAnimActor)
{ {
AddFlash(pAnimActor->s().sectnum, pAnimActor->s().x, pAnimActor->s().y, pAnimActor->s().z, 128); AddFlash(pAnimActor->s().sector(), pAnimActor->s().x, pAnimActor->s().y, pAnimActor->s().z, 128);
ChangeActorStat(pAnimActor, 950); ChangeActorStat(pAnimActor, 950);
} }
nMagicCount = RandomSize(2); nMagicCount = RandomSize(2);

View file

@ -38,11 +38,15 @@ enum
struct Flash struct Flash
{ {
union
{
walltype* pWall;
sectortype* pSector;
DExhumedActor* pActor;
};
int next;
int8_t nType; int8_t nType;
int8_t shade; int8_t shade;
DExhumedActor* pActor;
int nIndex;
int next;
}; };
struct Glow struct Glow
@ -100,11 +104,14 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, Flash& w, Flash* d
{ {
if (arc.BeginObject(keyname)) if (arc.BeginObject(keyname))
{ {
arc("at0", w.nType) arc("type", w.nType)
("shade", w.shade) ("shade", w.shade)
("at1", w.nIndex) ("next", w.next);
("next", w.next)
.EndObject(); if (w.nType & 4) arc("index", w.pActor);
else if (w.nType & 1) arc("index", w.pSector);
else arc("index", w.pWall);
arc.EndObject();
} }
return arc; return arc;
} }
@ -217,11 +224,8 @@ void InitLights()
nLastFlash = -1; nLastFlash = -1;
} }
void AddFlash(int nSector, int x, int y, int z, int val) void AddFlash(sectortype* pSector, int x, int y, int z, int val)
{ {
assert(validSectorIndex(nSector));
auto sectp = &sector[nSector];
int var_28 = 0; int var_28 = 0;
int var_1C = val >> 8; int var_1C = val >> 8;
@ -236,7 +240,7 @@ void AddFlash(int nSector, int x, int y, int z, int val)
int var_14 = 0; int var_14 = 0;
for (auto& wal : wallsofsector(sectp)) for (auto& wal : wallsofsector(pSector))
{ {
auto average = wal.center(); auto average = wal.center();
@ -270,7 +274,7 @@ void AddFlash(int nSector, int x, int y, int z, int val)
if (wal.pal < 5) if (wal.pal < 5)
{ {
if (!pNextSector || pNextSector->floorz < sectp->floorz) if (!pNextSector || pNextSector->floorz < pSector->floorz)
{ {
int nFlash = GrabFlash(); int nFlash = GrabFlash();
if (nFlash < 0) { if (nFlash < 0) {
@ -279,7 +283,7 @@ void AddFlash(int nSector, int x, int y, int z, int val)
sFlash[nFlash].nType = var_20 | 2; sFlash[nFlash].nType = var_20 | 2;
sFlash[nFlash].shade = wal.shade; sFlash[nFlash].shade = wal.shade;
sFlash[nFlash].nIndex = wallnum(&wal); sFlash[nFlash].pWall = &wal;
wal.pal += 7; wal.pal += 7;
@ -294,14 +298,14 @@ void AddFlash(int nSector, int x, int y, int z, int val)
if (!var_1C && !wal.overpicnum && pNextSector) if (!var_1C && !wal.overpicnum && pNextSector)
{ {
AddFlash(wal.nextsector, x, y, z, val); AddFlash(pNextSector, x, y, z, val);
} }
} }
} }
} }
} }
if (var_14 && sectp->floorpal < 4) if (var_14 && pSector->floorpal < 4)
{ {
int nFlash = GrabFlash(); int nFlash = GrabFlash();
if (nFlash < 0) { if (nFlash < 0) {
@ -309,46 +313,46 @@ void AddFlash(int nSector, int x, int y, int z, int val)
} }
sFlash[nFlash].nType = var_20 | 1; sFlash[nFlash].nType = var_20 | 1;
sFlash[nFlash].nIndex = nSector; sFlash[nFlash].pSector = pSector;;
sFlash[nFlash].shade = sectp->floorshade; sFlash[nFlash].shade = pSector->floorshade;
sectp->floorpal += 7; pSector->floorpal += 7;
int edx = sectp->floorshade + var_28; int edx = pSector->floorshade + var_28;
int eax = edx; int eax = edx;
if (edx < -127) { if (edx < -127) {
eax = -127; eax = -127;
} }
sectp->floorshade = eax; pSector->floorshade = eax;
if (!(sectp->ceilingstat & 1)) if (!(pSector->ceilingstat & 1))
{ {
if (sectp->ceilingpal < 4) if (pSector->ceilingpal < 4)
{ {
int nFlash2 = GrabFlash(); int nFlash2 = GrabFlash();
if (nFlash2 >= 0) if (nFlash2 >= 0)
{ {
sFlash[nFlash2].nType = var_20 | 3; sFlash[nFlash2].nType = var_20 | 3;
sFlash[nFlash2].nIndex = nSector; sFlash[nFlash2].pSector = pSector;
sFlash[nFlash2].shade = sectp->ceilingshade; sFlash[nFlash2].shade = pSector->ceilingshade;
sectp->ceilingpal += 7; pSector->ceilingpal += 7;
int edx = sectp->ceilingshade + var_28; int edx = pSector->ceilingshade + var_28;
int eax = edx; int eax = edx;
if (edx < -127) { if (edx < -127) {
eax = -127; eax = -127;
} }
sectp->ceilingshade = eax; pSector->ceilingshade = eax;
} }
} }
} }
ExhumedSectIterator it(nSector); ExhumedSectIterator it(pSector);
while (auto pActor = it.Next()) while (auto pActor = it.Next())
{ {
auto pSprite = &pActor->s(); auto pSprite = &pActor->s();
@ -359,7 +363,6 @@ void AddFlash(int nSector, int x, int y, int z, int val)
{ {
sFlash[nFlash3].nType = var_20 | 4; sFlash[nFlash3].nType = var_20 | 4;
sFlash[nFlash3].shade = pSprite->shade; sFlash[nFlash3].shade = pSprite->shade;
sFlash[nFlash3].nIndex = -1;
sFlash[nFlash3].pActor = pActor; sFlash[nFlash3].pActor = pActor;
pSprite->pal += 7; pSprite->pal += 7;
@ -405,11 +408,11 @@ void UndoFlashes()
for (int nFlash = nFirstFlash; nFlash >= 0; nFlash = sFlash[nFlash].next) for (int nFlash = nFirstFlash; nFlash >= 0; nFlash = sFlash[nFlash].next)
{ {
assert(nFlash < 2000 && nFlash >= 0); assert(nFlash < 2000 && nFlash >= 0);
auto pFlash = &sFlash[nFlash];
uint8_t type = sFlash[nFlash].nType & 0x3F; uint8_t type = pFlash->nType & 0x3F;
int nIndex = sFlash[nFlash].nIndex;
if (sFlash[nFlash].nType & 0x80) if (pFlash->nType & 0x80)
{ {
int flashtype = type - 1; int flashtype = type - 1;
assert(flashtype >= 0); assert(flashtype >= 0);
@ -420,31 +423,25 @@ void UndoFlashes()
{ {
case 0: case 0:
{ {
assert(validSectorIndex(nIndex)); pShade = &pFlash->pSector->floorshade;
pShade = &sector[nIndex].floorshade;
break; break;
} }
case 1: case 1:
{ {
assert(validWallIndex(nIndex)); pShade = &pFlash->pWall->shade;
pShade = &wall[nIndex].shade;
break; break;
} }
case 2: case 2:
{ {
assert(validSectorIndex(nIndex)); pShade = &pFlash->pSector->ceilingshade;
pShade = &sector[nIndex].ceilingshade;
break; break;
} }
case 3: case 3:
{ {
auto ac = sFlash[nFlash].pActor; auto ac = pFlash->pActor;
if (!ac) continue; if (!ac) continue;
auto sp = &ac->s(); auto sp = &ac->s();
if (sp->pal >= 7) if (sp->pal >= 7)
@ -465,7 +462,7 @@ void UndoFlashes()
assert(pShade != NULL); assert(pShade != NULL);
int thisshade = (*pShade) + 6; int thisshade = (*pShade) + 6;
int maxshade = sFlash[nFlash].shade; int maxshade = pFlash->shade;
if (thisshade < maxshade) if (thisshade < maxshade)
{ {
@ -486,33 +483,33 @@ void UndoFlashes()
case 0: case 0:
{ {
sector[nIndex].floorpal -= 7; pFlash->pSector->floorpal -= 7;
sector[nIndex].floorshade = sFlash[nFlash].shade; pFlash->pSector->floorshade = pFlash->shade;
break; break;
} }
case 1: case 1:
{ {
wall[nIndex].pal -= 7; pFlash->pWall->pal -= 7;
wall[nIndex].shade = sFlash[nFlash].shade; pFlash->pWall->shade = pFlash->shade;
break; break;
} }
case 2: case 2:
{ {
sector[nIndex].ceilingpal -= 7; pFlash->pSector->ceilingpal -= 7;
sector[nIndex].ceilingshade = sFlash[nFlash].shade; pFlash->pSector->ceilingshade = pFlash->shade;
break; break;
} }
case 3: case 3:
{ {
auto ac = sFlash[nFlash].pActor; auto ac = pFlash->pActor;
auto sp = &ac->s(); auto sp = &ac->s();
if (sp->pal >= 7) if (sp->pal >= 7)
{ {
sp->pal -= 7; sp->pal -= 7;
sp->shade = sFlash[nFlash].shade; sp->shade = pFlash->shade;
} }
break; break;
@ -523,7 +520,7 @@ loc_1868A:
if (edi != -1) if (edi != -1)
{ {
sFlash[edi].next = sFlash[nFlash].next; sFlash[edi].next = pFlash->next;
} }
if (nFlash == nFirstFlash) if (nFlash == nFirstFlash)

View file

@ -1974,7 +1974,7 @@ void AIObject::Tick(RunListEvent* ev)
var_18 = 34; var_18 = 34;
} }
AddFlash(pSprite->sectnum, pSprite->x, pSprite->y, pSprite->z, 128); AddFlash(pSprite->sector(), pSprite->x, pSprite->y, pSprite->z, 128);
BuildAnim(nullptr, var_18, 0, pSprite->x, pSprite->y, pSprite->sector()->floorz, pSprite->sectnum, 240, 4); BuildAnim(nullptr, var_18, 0, pSprite->x, pSprite->y, pSprite->sector()->floorz, pSprite->sectnum, 240, 4);
// int edi = nSprite | 0x4000; // int edi = nSprite | 0x4000;

View file

@ -791,7 +791,7 @@ void AIPlayer::Tick(RunListEvent* ev)
if (nPlayer != nLocalPlayer) if (nPlayer != nLocalPlayer)
{ {
nFlashDepth = 5; nFlashDepth = 5;
AddFlash(pPlayerSprite->sectnum, AddFlash(pPlayerSprite->sector(),
pPlayerSprite->x, pPlayerSprite->x,
pPlayerSprite->y, pPlayerSprite->y,
pPlayerSprite->z, 0); pPlayerSprite->z, 0);

View file

@ -426,8 +426,7 @@ void DoSpiritHead()
if (nCount < (15 * nPixels) / 16) { if (nCount < (15 * nPixels) / 16) {
SoundBigEntrance(); SoundBigEntrance();
AddGlow(pSpiritSpr->sectnum, 20); AddGlow(pSpiritSpr->sectnum, 20);
AddFlash(pSpiritSpr->sectnum, pSpiritSpr->x, pSpiritSpr->y, AddFlash(pSpiritSpr->sector(), pSpiritSpr->x, pSpiritSpr->y, pSpiritSpr->z, 128);
pSpiritSpr->z, 128);
nHeadStage = 3; nHeadStage = 3;
TintPalette(255, 255, 255); TintPalette(255, 255, 255);
CopyHeadToWorkTile(kTileRamsesNormal); CopyHeadToWorkTile(kTileRamsesNormal);

View file

@ -110,7 +110,7 @@ void ExplodeSnakeSprite(DExhumedActor* pActor, int nPlayer)
BuildAnim(nullptr, 23, 0, pSprite->x, pSprite->y, pSprite->z, pSprite->sectnum, 40, 4); BuildAnim(nullptr, 23, 0, pSprite->x, pSprite->y, pSprite->z, pSprite->sectnum, 40, 4);
AddFlash(pSprite->sectnum, pSprite->x, pSprite->y, pSprite->z, 128); AddFlash(pSprite->sector(), pSprite->x, pSprite->y, pSprite->z, 128);
StopActorSound(pActor); StopActorSound(pActor);
} }