- 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 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 UndoFlashes();
void DoLights();

View file

@ -421,7 +421,7 @@ MOVEEND:
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) {
pSprite->pal = 1;
@ -552,7 +552,7 @@ HITWALL:
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 (i = 0; i < numwalls; i++)
for(auto& wal : walls())
{
auto wallp = &wall[i];
int j = wallp->picnum;
markTileForPrecache(j, wallp->pal);
int j = wal.picnum;
markTileForPrecache(j, wal.pal);
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;
markTileForPrecache(j, wallp->pal);
int j = wal.overpicnum;
markTileForPrecache(j, wal.pal);
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();
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()
{
int n = NextIndex();

View file

@ -202,7 +202,7 @@ void ExplodeGrenade(DExhumedActor* pActor)
runlist_RadialDamageEnemy(pActor, nDamage, BulletInfo[kWeaponGrenade].nRadius);
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);
}

View file

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

View file

@ -346,7 +346,7 @@ void DropMagic(DExhumedActor* pActor)
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);
}
nMagicCount = RandomSize(2);

View file

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

View file

@ -1974,7 +1974,7 @@ void AIObject::Tick(RunListEvent* ev)
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);
// int edi = nSprite | 0x4000;

View file

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

View file

@ -426,8 +426,7 @@ void DoSpiritHead()
if (nCount < (15 * nPixels) / 16) {
SoundBigEntrance();
AddGlow(pSpiritSpr->sectnum, 20);
AddFlash(pSpiritSpr->sectnum, pSpiritSpr->x, pSpiritSpr->y,
pSpiritSpr->z, 128);
AddFlash(pSpiritSpr->sector(), pSpiritSpr->x, pSpiritSpr->y, pSpiritSpr->z, 128);
nHeadStage = 3;
TintPalette(255, 255, 255);
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);
AddFlash(pSprite->sectnum, pSprite->x, pSprite->y, pSprite->z, 128);
AddFlash(pSprite->sector(), pSprite->x, pSprite->y, pSprite->z, 128);
StopActorSound(pActor);
}