- sanitized callback interface.

This commit is contained in:
Christoph Oelckers 2021-09-01 21:54:23 +02:00
parent 143e947839
commit add368433e
9 changed files with 158 additions and 161 deletions

View file

@ -154,7 +154,10 @@ bool CanMove(DBloodActor* actor, DBloodActor* target, int nAngle, int nRange)
return false;
int floorZ = getflorzofslope(nSector, x, y);
int nXSector = sector[nSector].extra;
char Underwater = 0; char Water = 0; char Depth = 0; char Crusher = 0;
bool Underwater = 0;
bool Water = 0;
bool Depth = 0;
bool Crusher = 0;
XSECTOR* pXSector = NULL;
if (nXSector > 0)
{

View file

@ -37,6 +37,7 @@ public:
int& xvel() { return Blood::xvel[index]; }
int& yvel() { return Blood::yvel[index]; }
int& zvel() { return Blood::zvel[index]; }
int GetIndex() { return s().index; } // this is for error printing only!
GENDUDEEXTRA& genDudeExtra() { return Blood::gGenDudeExtra[index]; }
POINT3D& basePoint() { return Blood::baseSprite[index]; }

View file

@ -30,11 +30,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
BEGIN_BLD_NS
void fxFlameLick(int nSprite) // 0
void fxFlameLick(DBloodActor* actor, int) // 0
{
spritetype *pSprite = &sprite[nSprite];
int nXSprite = pSprite->extra;
XSPRITE *pXSprite = &xsprite[nXSprite];
spritetype *pSprite = &actor->s();
XSPRITE *pXSprite = &actor->x();
int top, bottom;
GetSpriteExtents(pSprite, &top, &bottom);
for (int i = 0; i < 3; i++)
@ -49,31 +48,30 @@ void fxFlameLick(int nSprite) // 0
spritetype *pFX = gFX.fxSpawn(FX_32, pSprite->sectnum, x, y, z, 0);
if (pFX)
{
xvel[pFX->index] = xvel[nSprite] + Random2(-dx);
yvel[pFX->index] = yvel[nSprite] + Random2(-dy);
zvel[pFX->index] = zvel[nSprite] - Random(0x1aaaa);
xvel[pFX->index] = actor->xvel() + Random2(-dx);
yvel[pFX->index] = actor->yvel() + Random2(-dy);
zvel[pFX->index] = actor->zvel() - Random(0x1aaaa);
}
}
if (pXSprite->burnTime > 0)
evPost(nSprite, 3, 5, kCallbackFXFlameLick);
evPost(actor, 5, kCallbackFXFlameLick);
}
void Remove(int nSprite) // 1
void Remove(DBloodActor* actor, int) // 1
{
spritetype *pSprite = &sprite[nSprite];
evKill(nSprite, 3);
spritetype *pSprite = &actor->s();
evKill(actor, kCallbackFXFlareSpark);
if (pSprite->extra > 0)
seqKill(3, pSprite->extra);
sfxKill3DSound(pSprite, 0, -1);
DeleteSprite(nSprite);
DeleteSprite(actor);
}
void FlareBurst(int nSprite) // 2
void FlareBurst(DBloodActor* actor, int) // 2
{
assert(nSprite >= 0 && nSprite < kMaxSprites);
auto actor = &bloodActors[nSprite];
spritetype *pSprite = &sprite[nSprite];
int nAngle = getangle(xvel[nSprite], yvel[nSprite]);
assert(actor != nullptr);
spritetype *pSprite = &actor->s();
int nAngle = getangle(actor->xvel(), actor->yvel());
int nRadius = 0x55555;
for (int i = 0; i < 8; i++)
{
@ -99,97 +97,97 @@ void FlareBurst(int nSprite) // 2
zvel[pSpawn->index] += dz;
evPost(pSpawn->index, 3, 960, kCallbackRemove);
}
evPost(nSprite, 3, 0, kCallbackRemove);
evPost(actor, 0, kCallbackRemove);
}
void fxFlareSpark(int nSprite) // 3
void fxFlareSpark(DBloodActor* actor, int) // 3
{
spritetype *pSprite = &sprite[nSprite];
spritetype *pSprite = &actor->s();
spritetype *pFX = gFX.fxSpawn(FX_28, pSprite->sectnum, pSprite->x, pSprite->y, pSprite->z, 0);
if (pFX)
{
xvel[pFX->index] = xvel[nSprite] + Random2(0x1aaaa);
yvel[pFX->index] = yvel[nSprite] + Random2(0x1aaaa);
zvel[pFX->index] = zvel[nSprite] - Random(0x1aaaa);
xvel[pFX->index] = actor->xvel() + Random2(0x1aaaa);
yvel[pFX->index] = actor->yvel() + Random2(0x1aaaa);
zvel[pFX->index] = actor->zvel() - Random(0x1aaaa);
}
evPost(nSprite, 3, 4, kCallbackFXFlareSpark);
evPost(actor, 4, kCallbackFXFlareSpark);
}
void fxFlareSparkLite(int nSprite) // 4
void fxFlareSparkLite(DBloodActor* actor, int) // 4
{
spritetype *pSprite = &sprite[nSprite];
spritetype *pSprite = &actor->s();
spritetype *pFX = gFX.fxSpawn(FX_28, pSprite->sectnum, pSprite->x, pSprite->y, pSprite->z, 0);
if (pFX)
{
xvel[pFX->index] = xvel[nSprite] + Random2(0x1aaaa);
yvel[pFX->index] = yvel[nSprite] + Random2(0x1aaaa);
zvel[pFX->index] = zvel[nSprite] - Random(0x1aaaa);
xvel[pFX->index] = actor->xvel() + Random2(0x1aaaa);
yvel[pFX->index] = actor->yvel() + Random2(0x1aaaa);
zvel[pFX->index] = actor->zvel() - Random(0x1aaaa);
}
evPost(nSprite, 3, 12, kCallbackFXFlareSparkLite);
evPost(actor, 12, kCallbackFXFlareSparkLite);
}
void fxZombieBloodSpurt(int nSprite) // 5
void fxZombieBloodSpurt(DBloodActor* actor, int) // 5
{
assert(nSprite >= 0 && nSprite < kMaxSprites);
spritetype *pSprite = &sprite[nSprite];
assert(actor != nullptr);
spritetype *pSprite = &actor->s();
int nXSprite = pSprite->extra;
assert(nXSprite > 0 && nXSprite < kMaxXSprites);
XSPRITE *pXSprite = &xsprite[nXSprite];
XSPRITE *pXSprite = &actor->x();
int top, bottom;
GetSpriteExtents(pSprite, &top, &bottom);
spritetype *pFX = gFX.fxSpawn(FX_27, pSprite->sectnum, pSprite->x, pSprite->y, top, 0);
if (pFX)
{
xvel[pFX->index] = xvel[nSprite] + Random2(0x11111);
yvel[pFX->index] = yvel[nSprite] + Random2(0x11111);
zvel[pFX->index] = zvel[nSprite] - 0x6aaaa;
xvel[pFX->index] = actor->xvel() + Random2(0x11111);
yvel[pFX->index] = actor->yvel() + Random2(0x11111);
zvel[pFX->index] = actor->zvel() - 0x6aaaa;
}
if (pXSprite->data1 > 0)
{
evPost(nSprite, 3, 4, kCallbackFXZombieSpurt);
evPost(actor, 4, kCallbackFXZombieSpurt);
pXSprite->data1 -= 4;
}
else if (pXSprite->data2 > 0)
{
evPost(nSprite, 3, 60, kCallbackFXZombieSpurt);
evPost(actor, 60, kCallbackFXZombieSpurt);
pXSprite->data1 = 40;
pXSprite->data2--;
}
}
void fxBloodSpurt(int nSprite) // 6
void fxBloodSpurt(DBloodActor* actor, int) // 6
{
spritetype *pSprite = &sprite[nSprite];
spritetype *pSprite = &actor->s();
spritetype *pFX = gFX.fxSpawn(FX_27, pSprite->sectnum, pSprite->x, pSprite->y, pSprite->z, 0);
if (pFX)
{
pFX->ang = 0;
xvel[pFX->index] = xvel[nSprite]>>8;
yvel[pFX->index] = yvel[nSprite]>>8;
zvel[pFX->index] = zvel[nSprite]>>8;
xvel[pFX->index] = actor->xvel()>>8;
yvel[pFX->index] = actor->yvel()>>8;
zvel[pFX->index] = actor->zvel()>>8;
}
evPost(nSprite, 3, 6, kCallbackFXBloodSpurt);
evPost(actor, 6, kCallbackFXBloodSpurt);
}
void fxArcSpark(int nSprite) // 7
void fxArcSpark(DBloodActor* actor, int) // 7
{
spritetype* pSprite = &sprite[nSprite];
spritetype* pSprite = &actor->s();
spritetype* pFX = gFX.fxSpawn(FX_15, pSprite->sectnum, pSprite->x, pSprite->y, pSprite->z, 0);
if (pFX)
{
xvel[pFX->index] = xvel[nSprite] + Random2(0x10000);
yvel[pFX->index] = yvel[nSprite] + Random2(0x10000);
zvel[pFX->index] = zvel[nSprite] - Random(0x1aaaa);
xvel[pFX->index] = actor->xvel() + Random2(0x10000);
yvel[pFX->index] = actor->yvel() + Random2(0x10000);
zvel[pFX->index] = actor->zvel() - Random(0x1aaaa);
}
evPost(nSprite, 3, 3, kCallbackFXArcSpark);
evPost(actor, 3, kCallbackFXArcSpark);
}
void fxDynPuff(int nSprite) // 8
void fxDynPuff(DBloodActor* actor, int) // 8
{
spritetype *pSprite = &sprite[nSprite];
if (zvel[nSprite])
spritetype *pSprite = &actor->s();
if (actor->zvel())
{
int nDist = (pSprite->xrepeat*(tileWidth(pSprite->picnum)/2))>>2;
int x = pSprite->x + MulScale(nDist, Cos(pSprite->ang-512), 30);
@ -198,26 +196,25 @@ void fxDynPuff(int nSprite) // 8
spritetype *pFX = gFX.fxSpawn(FX_7, pSprite->sectnum, x, y, z, 0);
if (pFX)
{
xvel[pFX->index] = xvel[nSprite];
yvel[pFX->index] = yvel[nSprite];
zvel[pFX->index] = zvel[nSprite];
xvel[pFX->index] = actor->xvel();
yvel[pFX->index] = actor->yvel();
zvel[pFX->index] = actor->zvel();
}
}
evPost(nSprite, 3, 12, kCallbackFXDynPuff);
evPost(actor, 12, kCallbackFXDynPuff);
}
void Respawn(int nSprite) // 9
void Respawn(DBloodActor* actor, int) // 9
{
auto actor = &bloodActors[nSprite];
spritetype *pSprite = &sprite[nSprite];
spritetype *pSprite = &actor->s();
assert(pSprite->extra > 0 && pSprite->extra < kMaxXSprites);
XSPRITE *pXSprite = &xsprite[pSprite->extra];
if (pSprite->statnum != kStatRespawn && pSprite->statnum != kStatThing) {
viewSetSystemMessage("Sprite #%d is not on Respawn or Thing list\n", nSprite);
viewSetSystemMessage("Sprite #%d is not on Respawn or Thing list\n", actor->GetIndex());
return;
} else if (!(pSprite->flags & kHitagRespawn)) {
viewSetSystemMessage("Sprite #%d does not have the respawn attribute\n", nSprite);
viewSetSystemMessage("Sprite #%d does not have the respawn attribute\n", actor->GetIndex());
return;
}
@ -225,31 +222,31 @@ void Respawn(int nSprite) // 9
case 1: {
int nTime = MulScale(actGetRespawnTime(actor), 0x4000, 16);
pXSprite->respawnPending = 2;
evPost(nSprite, 3, nTime, kCallbackRespawn);
evPost(actor, nTime, kCallbackRespawn);
break;
}
case 2: {
int nTime = MulScale(actGetRespawnTime(actor), 0x2000, 16);
pXSprite->respawnPending = 3;
evPost(nSprite, 3, nTime, kCallbackRespawn);
evPost(actor, nTime, kCallbackRespawn);
break;
}
case 3: {
assert(pSprite->owner != kStatRespawn);
assert(pSprite->owner >= 0 && pSprite->owner < kMaxStatus);
ChangeSpriteStat(nSprite, pSprite->owner);
ChangeSpriteStat(actor->s().index, pSprite->owner);
pSprite->type = pSprite->inittype;
pSprite->owner = -1;
pSprite->flags &= ~kHitagRespawn;
xvel[nSprite] = yvel[nSprite] = zvel[nSprite] = 0;
actor->xvel() = actor->yvel() = actor->zvel() = 0;
pXSprite->respawnPending = 0;
pXSprite->burnTime = 0;
pXSprite->isTriggered = 0;
if (IsDudeSprite(pSprite)) {
int nType = pSprite->type-kDudeBase;
pSprite->x = baseSprite[nSprite].x;
pSprite->y = baseSprite[nSprite].y;
pSprite->z = baseSprite[nSprite].z;
pSprite->x = actor->basePoint().x;
pSprite->y = actor->basePoint().y;
pSprite->z = actor->basePoint().z;
pSprite->cstat |= 0x1101;
#ifdef NOONE_EXTENSIONS
if (!gModernMap || pXSprite->sysData2 <= 0) pXSprite->health = dudeInfo[pSprite->type - kDudeBase].startHealth << 4;
@ -291,9 +288,9 @@ void Respawn(int nSprite) // 9
}
}
void PlayerBubble(int nSprite) // 10
void PlayerBubble(DBloodActor* actor, int) // 10
{
spritetype *pSprite = &sprite[nSprite];
spritetype *pSprite = &actor->s();
if (IsPlayerSprite(pSprite))
{
PLAYER *pPlayer = &gPlayer[pSprite->type-kDudePlayer1];
@ -312,21 +309,21 @@ void PlayerBubble(int nSprite) // 10
spritetype *pFX = gFX.fxSpawn((FX_ID)(FX_23+Random(3)), pSprite->sectnum, x, y, z, 0);
if (pFX)
{
xvel[pFX->index] = xvel[nSprite] + Random2(0x1aaaa);
yvel[pFX->index] = yvel[nSprite] + Random2(0x1aaaa);
zvel[pFX->index] = zvel[nSprite] + Random2(0x1aaaa);
xvel[pFX->index] = actor->xvel() + Random2(0x1aaaa);
yvel[pFX->index] = actor->yvel() + Random2(0x1aaaa);
zvel[pFX->index] = actor->zvel() + Random2(0x1aaaa);
}
}
evPost(nSprite, 3, 4, kCallbackPlayerBubble);
evPost(actor, 4, kCallbackPlayerBubble);
}
}
void EnemyBubble(int nSprite) // 11
void EnemyBubble(DBloodActor* actor, int) // 11
{
spritetype *pSprite = &sprite[nSprite];
spritetype *pSprite = &actor->s();
int top, bottom;
GetSpriteExtents(pSprite, &top, &bottom);
for (int i = 0; i < (abs(zvel[nSprite])>>18); i++)
for (int i = 0; i < (abs(actor->zvel())>>18); i++)
{
int nDist = (pSprite->xrepeat*(tileWidth(pSprite->picnum)/2))>>2;
int nAngle = Random(2048);
@ -336,15 +333,15 @@ void EnemyBubble(int nSprite) // 11
spritetype *pFX = gFX.fxSpawn((FX_ID)(FX_23+Random(3)), pSprite->sectnum, x, y, z, 0);
if (pFX)
{
xvel[pFX->index] = xvel[nSprite] + Random2(0x1aaaa);
yvel[pFX->index] = yvel[nSprite] + Random2(0x1aaaa);
zvel[pFX->index] = zvel[nSprite] + Random2(0x1aaaa);
xvel[pFX->index] = actor->xvel() + Random2(0x1aaaa);
yvel[pFX->index] = actor->yvel() + Random2(0x1aaaa);
zvel[pFX->index] = actor->zvel() + Random2(0x1aaaa);
}
}
evPost(nSprite, 3, 4, kCallbackEnemeyBubble);
evPost(actor, 4, kCallbackEnemeyBubble);
}
void CounterCheck(int nSector) // 12
void CounterCheck(DBloodActor*, int nSector) // 12
{
assert(nSector >= 0 && nSector < kMaxSectors);
if (sector[nSector].type != kSectorCounter) return;
@ -372,18 +369,18 @@ void CounterCheck(int nSector) // 12
}
void FinishHim(int nSprite) // 13
void FinishHim(DBloodActor* actor, int) // 13
{
spritetype* pSprite = &sprite[nSprite];
spritetype* pSprite = &actor->s();
int nXSprite = pSprite->extra;
XSPRITE* pXSprite = &xsprite[nXSprite];
XSPRITE* pXSprite = &actor->x();
if (IsPlayerSprite(pSprite) && playerSeqPlaying(&gPlayer[pSprite->type - kDudePlayer1], 16) && pXSprite->target_i == gMe->nSprite)
sndStartSample(3313, -1, 1, 0);
}
void fxBloodBits(int nSprite) // 14
void fxBloodBits(DBloodActor* actor, int) // 14
{
spritetype *pSprite = &sprite[nSprite];
spritetype *pSprite = &actor->s();
int ceilZ, ceilHit, floorZ, floorHit;
GetZRange(pSprite, &ceilZ, &ceilHit, &floorZ, &floorHit, pSprite->clipdist, CLIPMASK0);
int top, bottom;
@ -406,41 +403,41 @@ void fxBloodBits(int nSprite) // 14
if (pFX)
pFX->ang = nAngle;
}
gFX.remove(nSprite);
gFX.remove(actor->s().index);
}
void fxTeslaAlt(int nSprite) // 15
void fxTeslaAlt(DBloodActor* actor, int) // 15
{
spritetype* pSprite = &sprite[nSprite];
spritetype* pSprite = &actor->s();
spritetype* pFX = gFX.fxSpawn(FX_49, pSprite->sectnum, pSprite->x, pSprite->y, pSprite->z, 0);
if (pFX)
{
xvel[pFX->index] = xvel[nSprite] + Random2(0x1aaaa);
yvel[pFX->index] = yvel[nSprite] + Random2(0x1aaaa);
zvel[pFX->index] = zvel[nSprite] - Random(0x1aaaa);
xvel[pFX->index] = actor->xvel() + Random2(0x1aaaa);
yvel[pFX->index] = actor->yvel() + Random2(0x1aaaa);
zvel[pFX->index] = actor->zvel() - Random(0x1aaaa);
}
evPost(nSprite, 3, 3, kCallbackFXTeslaAlt);
evPost(actor, 3, kCallbackFXTeslaAlt);
}
int tommySleeveSnd[] = { 608, 609, 611 }; // unused?
int sawedOffSleeveSnd[] = { 610, 612 };
void fxBouncingSleeve(int nSprite) // 16
void fxBouncingSleeve(DBloodActor* actor, int) // 16
{
spritetype* pSprite = &sprite[nSprite]; int ceilZ, ceilHit, floorZ, floorHit;
spritetype* pSprite = &actor->s(); int ceilZ, ceilHit, floorZ, floorHit;
GetZRange(pSprite, &ceilZ, &ceilHit, &floorZ, &floorHit, pSprite->clipdist, CLIPMASK0);
int top, bottom; GetSpriteExtents(pSprite, &top, &bottom);
pSprite->z += floorZ - bottom;
int zv = zvel[nSprite] - velFloor[pSprite->sectnum];
int zv = actor->zvel() - velFloor[pSprite->sectnum];
if (zvel[nSprite] == 0) sleeveStopBouncing(pSprite);
if (actor->zvel() == 0) sleeveStopBouncing(pSprite);
else if (zv > 0) {
actFloorBounceVector((int*)& xvel[nSprite], (int*)& yvel[nSprite], &zv, pSprite->sectnum, 0x9000);
zvel[nSprite] = zv;
if (velFloor[pSprite->sectnum] == 0 && abs(zvel[nSprite]) < 0x20000) {
actFloorBounceVector((int*)& actor->xvel(), (int*)& actor->yvel(), &zv, pSprite->sectnum, 0x9000);
actor->zvel() = zv;
if (velFloor[pSprite->sectnum] == 0 && abs(actor->zvel()) < 0x20000) {
sleeveStopBouncing(pSprite);
return;
}
@ -485,9 +482,9 @@ void sleeveStopBouncing(spritetype* pSprite) {
}
void returnFlagToBase(int nSprite) // 17
void returnFlagToBase(DBloodActor* actor, int) // 17
{
spritetype* pSprite = &sprite[nSprite];
spritetype* pSprite = &actor->s();
if (pSprite->owner >= 0 && pSprite->owner < kMaxSprites)
{
spritetype* pOwner = &sprite[pSprite->owner];
@ -510,9 +507,9 @@ void returnFlagToBase(int nSprite) // 17
evPost(pSprite->index, 3, 0, kCallbackRemove);
}
void fxPodBloodSpray(int nSprite) // 18
void fxPodBloodSpray(DBloodActor* actor, int) // 18
{
spritetype* pSprite = &sprite[nSprite];
spritetype* pSprite = &actor->s();
spritetype* pFX;
if (pSprite->type == 53)
pFX = gFX.fxSpawn(FX_53, pSprite->sectnum, pSprite->x, pSprite->y, pSprite->z, 0);
@ -521,16 +518,16 @@ void fxPodBloodSpray(int nSprite) // 18
if (pFX)
{
pFX->ang = 0;
xvel[pFX->index] = xvel[nSprite] >> 8;
yvel[pFX->index] = yvel[nSprite] >> 8;
zvel[pFX->index] = zvel[nSprite] >> 8;
xvel[pFX->index] = actor->xvel() >> 8;
yvel[pFX->index] = actor->yvel() >> 8;
zvel[pFX->index] = actor->zvel() >> 8;
}
evPost(nSprite, 3, 6, kCallbackFXPodBloodSpray);
evPost(actor, 6, kCallbackFXPodBloodSpray);
}
void fxPodBloodSplat(int nSprite) // 19
void fxPodBloodSplat(DBloodActor* actor, int) // 19
{
spritetype *pSprite = &sprite[nSprite];
spritetype *pSprite = &actor->s();
int ceilZ, ceilHit, floorZ, floorHit;
GetZRange(pSprite, &ceilZ, &ceilHit, &floorZ, &floorHit, pSprite->clipdist, CLIPMASK0);
int top, bottom;
@ -560,14 +557,14 @@ void fxPodBloodSplat(int nSprite) // 19
if (pFX)
pFX->ang = nAngle;
}
gFX.remove(nSprite);
gFX.remove(actor->s().index);
}
void LeechStateTimer(int nSprite) // 20
void LeechStateTimer(DBloodActor* actor, int) // 20
{
spritetype *pSprite = &sprite[nSprite];
spritetype *pSprite = &actor->s();
if (pSprite->statnum == kStatThing && !(pSprite->flags & 32)) {
switch (pSprite->type) {
case kThingDroppedLifeLeech:
@ -580,19 +577,19 @@ void LeechStateTimer(int nSprite) // 20
}
}
void sub_76A08(spritetype *pSprite, spritetype *pSprite2, PLAYER *pPlayer) // ???
void sub_76A08(DBloodActor *actor, spritetype *pSprite2, PLAYER *pPlayer) // ???
{
int top, bottom;
int nSprite = pSprite->index;
auto pSprite = &actor->s();
GetSpriteExtents(pSprite, &top, &bottom);
pSprite->x = pSprite2->x;
pSprite->y = pSprite2->y;
pSprite->z = sector[pSprite2->sectnum].floorz-(bottom-pSprite->z);
pSprite->ang = pSprite2->ang;
ChangeSpriteSect(nSprite, pSprite2->sectnum);
ChangeSpriteSect(pSprite->index, pSprite2->sectnum);
sfxPlay3DSound(pSprite2, 201, -1, 0);
xvel[nSprite] = yvel[nSprite] = zvel[nSprite] = 0;
viewBackupSpriteLoc(nSprite, pSprite);
actor->xvel() = actor->yvel() = actor->zvel() = 0;
viewBackupSpriteLoc(pSprite->index, pSprite);
if (pPlayer)
{
playerResetInertia(pPlayer);
@ -600,14 +597,13 @@ void sub_76A08(spritetype *pSprite, spritetype *pSprite2, PLAYER *pPlayer) // ??
}
}
void DropVoodooCb(int nSprite) // unused
void DropVoodooCb(DBloodActor* actor, int) // unused
{
auto actor = &bloodActors[nSprite];
spritetype *pSprite = &sprite[nSprite];
spritetype *pSprite = &actor->s();
int nOwner = pSprite->owner;
if (nOwner < 0 || nOwner >= kMaxSprites)
{
evPost(nSprite, 3, 0, kCallbackRemove);
evPost(actor, 0, kCallbackRemove);
return;
}
spritetype *pOwner = &sprite[nOwner];
@ -618,17 +614,17 @@ void DropVoodooCb(int nSprite) // unused
pPlayer = NULL;
if (!pPlayer)
{
evPost(nSprite, 3, 0, kCallbackRemove);
evPost(actor, 0, kCallbackRemove);
return;
}
pSprite->ang = getangle(pOwner->x-pSprite->x, pOwner->y-pSprite->y);
int nXSprite = pSprite->extra;
if (nXSprite > 0)
{
XSPRITE *pXSprite = &xsprite[nXSprite];
XSPRITE *pXSprite = &actor->x();
if (pXSprite->data1 == 0)
{
evPost(nSprite, 3, 0, kCallbackRemove);
evPost(actor, 0, kCallbackRemove);
return;
}
int nSprite2;
@ -664,8 +660,8 @@ void DropVoodooCb(int nSprite) // unused
{
int nDmg = actDamageSprite(actor, actor2, kDamageSpirit, pXSprite->data1<<4);
pXSprite->data1 = ClipLow(pXSprite->data1-nDmg, 0);
sub_76A08(pSprite2, pSprite, pPlayer2);
evPost(nSprite, 3, 0, kCallbackRemove);
sub_76A08(actor2, pSprite, pPlayer2);
evPost(actor, 0, kCallbackRemove);
return;
}
}
@ -705,8 +701,8 @@ void DropVoodooCb(int nSprite) // unused
}
if (vd && (Chance(vd) || nNextSprite < 0))
{
sub_76A08(pSprite2, pSprite, NULL);
evPost(nSprite, 3, 0, kCallbackRemove);
sub_76A08(actor2, pSprite, NULL);
evPost(actor, 0, kCallbackRemove);
return;
}
}
@ -714,13 +710,13 @@ void DropVoodooCb(int nSprite) // unused
}
}
pXSprite->data1 = ClipLow(pXSprite->data1-1, 0);
evPost(nSprite, 3, 0, kCallbackRemove);
evPost(actor, 0, kCallbackRemove);
}
}
void callbackCondition(int nSprite) {
XSPRITE* pXSprite = &xsprite[sprite[nSprite].extra];
void callbackCondition(DBloodActor* actor, int)
{
XSPRITE* pXSprite = &actor->x();
if (pXSprite->isTriggered) return;
TRCONDITION* pCond = &gCondition[pXSprite->sysData1];
@ -730,11 +726,11 @@ void callbackCondition(int nSprite) {
useCondition(&sprite[pXSprite->reference], pXSprite, evn);
}
evPost(nSprite, OBJ_SPRITE, pXSprite->busyTime, kCallbackCondition);
evPost(actor, pXSprite->busyTime, kCallbackCondition);
return;
}
void(*gCallback[kCallbackMax])(int) =
void(*gCallback[kCallbackMax])(DBloodActor*, int) =
{
fxFlameLick,
Remove,

View file

@ -58,6 +58,6 @@ enum CALLBACK_ID {
kCallbackMax,
};
extern void (*gCallback[kCallbackMax])(int);
extern void(*gCallback[kCallbackMax])(DBloodActor*, int);
END_BLD_NS

View file

@ -595,7 +595,8 @@ void evProcess(unsigned int time)
{
assert(event.funcID < kCallbackMax);
assert(gCallback[event.funcID] != nullptr);
gCallback[event.funcID](event.index);
if (event.type == OBJ_SPRITE) gCallback[event.funcID](&bloodActors[event.index], 0);
else gCallback[event.funcID](nullptr, event.index);
}
else
{

View file

@ -76,7 +76,6 @@ struct RXBUCKET
uint16_t index;
uint8_t type;
};
extern void (*gCallback[])(int);
extern RXBUCKET rxBucket[];
extern unsigned short bucketHead[];

View file

@ -229,7 +229,7 @@ void CFX::fxProcess(void)
continue;
}
assert(gCallback[pFXData->funcID] != NULL);
gCallback[pFXData->funcID](nSprite);
gCallback[pFXData->funcID](&bloodActors[nSprite], 0);
continue;
}
if (nSector != pSprite->sectnum)
@ -255,7 +255,7 @@ void CFX::fxProcess(void)
continue;
}
assert(gCallback[pFXData->funcID] != NULL);
gCallback[pFXData->funcID](nSprite);
gCallback[pFXData->funcID](&bloodActors[nSprite], 0);
continue;
}
}

View file

@ -7831,13 +7831,11 @@ void levelEndLevelCustom(int nLevel) {
gNextLevel = FindMapByIndex(currentLevel->cluster, nLevel + 1);
}
void callbackUniMissileBurst(int nSprite) // 22
void callbackUniMissileBurst(DBloodActor* actor, int) // 22
{
auto actor = &bloodActors[nSprite];
assert(nSprite >= 0 && nSprite < kMaxSprites);
if (sprite[nSprite].statnum != kStatProjectile) return;
spritetype* pSprite = &sprite[nSprite];
int nAngle = getangle(xvel[nSprite], yvel[nSprite]);
spritetype* pSprite = &actor->s();
if (pSprite->statnum != kStatProjectile) return;
int nAngle = getangle(actor->xvel(), actor->yvel());
int nRadius = 0x55555;
for (int i = 0; i < 8; i++)
@ -7880,21 +7878,20 @@ void callbackUniMissileBurst(int nSprite) // 22
zvel[pBurst->index] += dz;
evPost(pBurst->index, 3, 960, kCallbackRemove);
}
evPost(nSprite, 3, 0, kCallbackRemove);
evPost(actor, 0, kCallbackRemove);
}
void callbackMakeMissileBlocking(int nSprite) // 23
void callbackMakeMissileBlocking(DBloodActor* actor, int) // 23
{
assert(nSprite >= 0 && nSprite < kMaxSprites);
if (sprite[nSprite].statnum != kStatProjectile) return;
sprite[nSprite].cstat |= CSTAT_SPRITE_BLOCK;
if (!actor || actor->s().statnum != kStatProjectile) return;
actor->s().cstat |= CSTAT_SPRITE_BLOCK;
}
void callbackGenDudeUpdate(int nSprite) // 24
void callbackGenDudeUpdate(DBloodActor* actor, int) // 24
{
if (spriRangeIsFine(nSprite))
genDudeUpdate(&bloodActors[nSprite]);
if (actor)
genDudeUpdate(actor);
}
void clampSprite(spritetype* pSprite, int which) {

View file

@ -386,9 +386,9 @@ void playerQavScenePlay(PLAYER* pPlayer);
void playerQavSceneDraw(PLAYER* pPlayer, int a2, double a3, double a4, int a5);
void playerQavSceneReset(PLAYER* pPlayer);
// ------------------------------------------------------------------------- //
void callbackUniMissileBurst(int nSprite);
void callbackMakeMissileBlocking(int nSprite);
void callbackGenDudeUpdate(int nSprite);
void callbackUniMissileBurst(DBloodActor*actor, int nSprite);
void callbackMakeMissileBlocking(DBloodActor* actor, int nSprite);
void callbackGenDudeUpdate(DBloodActor* actor, int nSprite);
// ------------------------------------------------------------------------- //
PLAYER* getPlayerById(short id);
bool isGrown(spritetype* pSprite);