- comparison with zero replacements

This commit is contained in:
Christoph Oelckers 2022-09-03 10:12:09 +02:00
parent ac84e3f045
commit 4af3f6e731
5 changed files with 32 additions and 36 deletions

View file

@ -4150,7 +4150,7 @@ static void checkCeilHit(DBloodActor* actor)
auto actor2 = coll.actor(); auto actor2 = coll.actor();
if (actor2 && actor2->hasX()) if (actor2 && actor2->hasX())
{ {
if ((actor2->spr.statnum == kStatThing || actor2->spr.statnum == kStatDude) && (actor->int_vel().X != 0 || actor->int_vel().Y != 0 || actor->int_vel().Z != 0)) if ((actor2->spr.statnum == kStatThing || actor2->spr.statnum == kStatDude) && (actor->vel.X != 0 || actor->vel.Y != 0 || actor->vel.Z != 0))
{ {
auto adelta = actor2->spr.pos - actor->spr.pos; auto adelta = actor2->spr.pos - actor->spr.pos;
if (actor2->spr.statnum == kStatThing) if (actor2->spr.statnum == kStatThing)
@ -4258,7 +4258,7 @@ static void checkHit(DBloodActor* actor)
// add size shroom abilities // add size shroom abilities
if ((actor2->IsPlayerActor() && isShrinked(actor2)) || (actor->IsPlayerActor() && isGrown(actor))) if ((actor2->IsPlayerActor() && isShrinked(actor2)) || (actor->IsPlayerActor() && isGrown(actor)))
{ {
if (actor->int_vel().X != 0 && actor2->IsDudeActor()) if (actor->vel.X != 0 && actor2->IsDudeActor())
{ {
int mass1 = getDudeInfo(actor->spr.type)->mass; int mass1 = getDudeInfo(actor->spr.type)->mass;
int mass2 = getDudeInfo(actor2->spr.type)->mass; int mass2 = getDudeInfo(actor2->spr.type)->mass;
@ -4526,7 +4526,7 @@ static Collision MoveThing(DBloodActor* actor)
lhit.setNone(); lhit.setNone();
GetActorExtents(actor, &top, &bottom); GetActorExtents(actor, &top, &bottom);
const int bakCompat = enginecompatibility_mode; const int bakCompat = enginecompatibility_mode;
if (actor->int_vel().X != 0 || actor->int_vel().Y) if (actor->vel.X != 0 || actor->int_vel().Y)
{ {
auto bakCstat = actor->spr.cstat; auto bakCstat = actor->spr.cstat;
actor->spr.cstat &= ~CSTAT_SPRITE_BLOCK_ALL; actor->spr.cstat &= ~CSTAT_SPRITE_BLOCK_ALL;
@ -4631,7 +4631,7 @@ static Collision MoveThing(DBloodActor* actor)
switch (actor->spr.type) switch (actor->spr.type)
{ {
case kThingNapalmBall: case kThingNapalmBall:
if (actor->int_vel().Z == 0 || Chance(0xA000)) actNapalmMove(actor); if (actor->vel.Z == 0 || Chance(0xA000)) actNapalmMove(actor);
break; break;
case kThingZombieHead: case kThingZombieHead:
@ -4650,7 +4650,7 @@ static Collision MoveThing(DBloodActor* actor)
lhit.setSector(pSector); lhit.setSector(pSector);
} }
else if (actor->int_vel().Z == 0) else if (actor->vel.Z == 0)
actor->spr.flags &= ~4; actor->spr.flags &= ~4;
} }
@ -4666,7 +4666,7 @@ static Collision MoveThing(DBloodActor* actor)
{ {
actor->hit.ceilhit = ceilColl; actor->hit.ceilhit = ceilColl;
actor->add_int_z(ClipLow(ceilZ - top, 0)); actor->add_int_z(ClipLow(ceilZ - top, 0));
if (actor->int_vel().Z < 0) if (actor->vel.Z < 0)
{ {
actor->set_int_bvel_x(MulScale(actor->int_vel().X, 0xc000, 16)); actor->set_int_bvel_x(MulScale(actor->int_vel().X, 0xc000, 16));
actor->set_int_bvel_y(MulScale(actor->int_vel().Y, 0xc000, 16)); actor->set_int_bvel_y(MulScale(actor->int_vel().Y, 0xc000, 16));
@ -4714,7 +4714,7 @@ static Collision MoveThing(DBloodActor* actor)
actor->add_int_bvel_y(-MulScale(t, actor->int_vel().Y, 16)); actor->add_int_bvel_y(-MulScale(t, actor->int_vel().Y, 16));
} }
} }
if (actor->int_vel().X != 0 || actor->int_vel().Y) if (actor->vel.X != 0 || actor->int_vel().Y)
actor->spr.angle = VecToAngle(actor->int_vel().X, actor->int_vel().Y); actor->spr.angle = VecToAngle(actor->int_vel().X, actor->int_vel().Y);
return lhit; return lhit;
} }
@ -4746,7 +4746,7 @@ void MoveDude(DBloodActor* actor)
assert(pSector); assert(pSector);
if (actor->int_vel().X != 0 || actor->int_vel().Y) if (actor->vel.X != 0 || actor->int_vel().Y)
{ {
if (pPlayer && gNoClip) if (pPlayer && gNoClip)
{ {
@ -4913,7 +4913,7 @@ void MoveDude(DBloodActor* actor)
actor->add_int_bvel_z(vc); actor->add_int_bvel_z(vc);
} }
} }
if (pPlayer && actor->int_vel().Z > 0x155555 && !pPlayer->fallScream && actor->xspr.height > 0) if (pPlayer && actor->vel.Z > 0x155555 && !pPlayer->fallScream && actor->xspr.height > 0)
{ {
const bool playerAlive = (actor->xspr.health > 0) || VanillaMode(); // only trigger falling scream if player is alive or vanilla mode const bool playerAlive = (actor->xspr.health > 0) || VanillaMode(); // only trigger falling scream if player is alive or vanilla mode
if (playerAlive) if (playerAlive)
@ -5156,7 +5156,7 @@ void MoveDude(DBloodActor* actor)
} }
} }
} }
else if (actor->int_vel().Z == 0) else if (actor->vel.Z == 0)
actor->spr.flags &= ~4; actor->spr.flags &= ~4;
} }
@ -5181,7 +5181,7 @@ void MoveDude(DBloodActor* actor)
GetActorExtents(actor, &top, &bottom); GetActorExtents(actor, &top, &bottom);
actor->xspr.height = ClipLow(floorZ - bottom, 0) >> 8; actor->xspr.height = ClipLow(floorZ - bottom, 0) >> 8;
if (actor->int_vel().X != 0 || actor->int_vel().Y) if (actor->vel.X != 0 || actor->int_vel().Y)
{ {
if (floorColl.type == kHitSprite) if (floorColl.type == kHitSprite)
{ {
@ -5230,7 +5230,7 @@ int MoveMissile(DBloodActor* actor)
gHitInfo.clearObj(); gHitInfo.clearObj();
if (actor->spr.type == kMissileFlameSpray) actAirDrag(actor, 0x1000); if (actor->spr.type == kMissileFlameSpray) actAirDrag(actor, 0x1000);
if (actor->GetTarget() != nullptr && (actor->int_vel().X != 0 || actor->int_vel().Y != 0 || actor->int_vel().Z)) if (actor->GetTarget() != nullptr && (actor->vel.X != 0 || actor->vel.Y != 0 || actor->int_vel().Z))
{ {
auto target = actor->GetTarget(); auto target = actor->GetTarget();
@ -5686,7 +5686,7 @@ static void actCheckThings()
actAirDrag(actor, 128); actAirDrag(actor, 128);
if (((actor->GetIndex() >> 8) & 15) == (gFrameCount & 15) && (actor->spr.flags & 2)) actor->spr.flags |= 4; if (((actor->GetIndex() >> 8) & 15) == (gFrameCount & 15) && (actor->spr.flags & 2)) actor->spr.flags |= 4;
if ((actor->spr.flags & 4) || actor->int_vel().X != 0 || actor->int_vel().Y != 0 || actor->int_vel().Z != 0 || actor->sector()->velFloor || actor->sector()->velCeil) if ((actor->spr.flags & 4) || actor->vel.X != 0 || actor->vel.Y != 0 || actor->vel.Z != 0 || actor->sector()->velFloor || actor->sector()->velCeil)
{ {
Collision hit = MoveThing(actor); Collision hit = MoveThing(actor);
if (hit.type) if (hit.type)
@ -6062,7 +6062,7 @@ static void actCheckDudes()
else else
pPlayer->chokeEffect = 0; pPlayer->chokeEffect = 0;
if (actor->int_vel().X != 0 || actor->int_vel().Y) if (actor->vel.X != 0 || actor->int_vel().Y)
sfxPlay3DSound(actor, 709, 100, 2); sfxPlay3DSound(actor, 709, 100, 2);
pPlayer->bubbleTime = ClipLow(pPlayer->bubbleTime - 4, 0); pPlayer->bubbleTime = ClipLow(pPlayer->bubbleTime - 4, 0);
@ -6114,7 +6114,7 @@ static void actCheckDudes()
if (pXSector && pXSector->Underwater) actAirDrag(actor, 5376); if (pXSector && pXSector->Underwater) actAirDrag(actor, 5376);
else actAirDrag(actor, 128); else actAirDrag(actor, 128);
if ((actor->spr.flags & 4) || actor->int_vel().X != 0 || actor->int_vel().Y != 0 || actor->int_vel().Z != 0 || actor->sector()->velFloor || actor->sector()->velCeil) if ((actor->spr.flags & 4) || actor->vel.X != 0 || actor->vel.Y != 0 || actor->vel.Z != 0 || actor->sector()->velFloor || actor->sector()->velCeil)
MoveDude(actor); MoveDude(actor);
} }
} }

View file

@ -199,9 +199,7 @@ void fxBloodSpurt(DBloodActor* actor, sectortype*) // 6
if (pFX) if (pFX)
{ {
pFX->set_int_ang(0); pFX->set_int_ang(0);
pFX->set_int_bvel_x(actor->int_vel().X >> 8); pFX->vel = actor->vel * (1./256);
pFX->set_int_bvel_y(actor->int_vel().Y >> 8);
pFX->set_int_bvel_z(actor->int_vel().Z >> 8);
} }
evPostActor(actor, 6, kCallbackFXBloodSpurt); evPostActor(actor, 6, kCallbackFXBloodSpurt);
} }
@ -521,7 +519,7 @@ void fxBouncingSleeve(DBloodActor* actor, sectortype*) // 16
int zv = actor->int_vel().Z - actor->sector()->velFloor; int zv = actor->int_vel().Z - actor->sector()->velFloor;
if (actor->int_vel().Z == 0) sleeveStopBouncing(actor); if (actor->vel.Z == 0) sleeveStopBouncing(actor);
else if (zv > 0) else if (zv > 0)
{ {
auto vec4 = actFloorBounceVector(actor, FixedToFloat(zv), actor->sector(), FixedToFloat(0x9000)); auto vec4 = actFloorBounceVector(actor, FixedToFloat(zv), actor->sector(), FixedToFloat(0x9000));
@ -626,9 +624,7 @@ void fxPodBloodSpray(DBloodActor* actor, sectortype*) // 18
if (pFX) if (pFX)
{ {
pFX->set_int_ang(0); pFX->set_int_ang(0);
pFX->set_int_bvel_x(actor->int_vel().X >> 8); pFX->vel = actor->vel * (1./256);
pFX->set_int_bvel_y(actor->int_vel().Y >> 8);
pFX->set_int_bvel_z(actor->int_vel().Z >> 8);
} }
evPostActor(actor, 6, kCallbackFXPodBloodSpray); evPostActor(actor, 6, kCallbackFXPodBloodSpray);
} }

View file

@ -216,7 +216,7 @@ void CFX::fxProcess(void)
actAirDrag(actor, pFXData->drag); actAirDrag(actor, pFXData->drag);
actor->add_int_pos({ actor->int_vel().X >> 12, actor->int_vel().Y >> 12, actor->int_vel().Z >> 8 }); actor->add_int_pos({ actor->int_vel().X >> 12, actor->int_vel().Y >> 12, actor->int_vel().Z >> 8 });
// Weird... // Weird...
if (actor->int_vel().X != 0 || (actor->int_vel().Y != 0 && actor->spr.pos.Z >= actor->sector()->floorz)) if (actor->vel.X != 0 || (actor->vel.Y != 0 && actor->spr.pos.Z >= actor->sector()->floorz))
{ {
updatesector(actor->spr.pos, &pSector); updatesector(actor->spr.pos, &pSector);
if (pSector == nullptr) if (pSector == nullptr)
@ -240,7 +240,7 @@ void CFX::fxProcess(void)
ChangeActorSect(actor, pSector); ChangeActorSect(actor, pSector);
} }
} }
if (actor->int_vel().X != 0 || actor->int_vel().Y != 0 || actor->int_vel().Z) if (actor->vel.X != 0 || actor->vel.Y != 0 || actor->int_vel().Z)
{ {
int32_t floorZ, ceilZ; int32_t floorZ, ceilZ;
getzsofslopeptr(pSector, actor->spr.pos, &ceilZ, &floorZ); getzsofslopeptr(pSector, actor->spr.pos, &ceilZ, &floorZ);

View file

@ -1054,7 +1054,7 @@ static void windGenDoVerticalWind(int factor, sectortype* pSector)
if (maxZfound && actor->int_pos().Z <= maxZ) if (maxZfound && actor->int_pos().Z <= maxZ)
{ {
zdiff = actor->int_pos().Z - maxZ; zdiff = actor->int_pos().Z - maxZ;
if (actor->int_vel().Z < 0) actor->add_int_bvel_z(MulScale(actor->int_vel().Z >> 4, zdiff, 16)); if (actor->vel.Z < 0) actor->add_int_bvel_z(MulScale(actor->int_vel().Z >> 4, zdiff, 16));
continue; continue;
} }
@ -1343,17 +1343,17 @@ void nnExtProcessSuperSprites()
} }
if (debrisactor->xspr.physAttr & kPhysGravity) debrisactor->xspr.physAttr |= kPhysFalling; if (debrisactor->xspr.physAttr & kPhysGravity) debrisactor->xspr.physAttr |= kPhysFalling;
if ((debrisactor->xspr.physAttr & kPhysFalling) || debrisactor->int_vel().X != 0 || debrisactor->int_vel().Y != 0 || debrisactor->int_vel().Z != 0 || debrisactor->sector()->velFloor || debrisactor->sector()->velCeil) if ((debrisactor->xspr.physAttr & kPhysFalling) || debrisactor->vel.X != 0 || debrisactor->vel.Y != 0 || debrisactor->vel.Z != 0 || debrisactor->sector()->velFloor || debrisactor->sector()->velCeil)
debrisMove(i); debrisMove(i);
if (debrisactor->int_vel().X != 0 || debrisactor->int_vel().Y) if (debrisactor->vel.X != 0 || debrisactor->int_vel().Y)
debrisactor->xspr.goalAng = getangle(debrisactor->int_vel().X, debrisactor->int_vel().Y) & 2047; debrisactor->xspr.goalAng = getangle(debrisactor->int_vel().X, debrisactor->int_vel().Y) & 2047;
int ang = debrisactor->int_ang() & 2047; int ang = debrisactor->int_ang() & 2047;
if ((uwater = spriteIsUnderwater(debrisactor)) == false) evKillActor(debrisactor, kCallbackEnemeyBubble); if ((uwater = spriteIsUnderwater(debrisactor)) == false) evKillActor(debrisactor, kCallbackEnemeyBubble);
else if (Chance(0x1000 - mass)) else if (Chance(0x1000 - mass))
{ {
if (debrisactor->int_vel().Z > 0x100) debrisBubble(debrisactor); if (debrisactor->vel.Z > 0x100) debrisBubble(debrisactor);
if (ang == debrisactor->xspr.goalAng) if (ang == debrisactor->xspr.goalAng)
{ {
debrisactor->xspr.goalAng = (debrisactor->int_ang() + Random3(kAng60)) & 2047; debrisactor->xspr.goalAng = (debrisactor->int_ang() + Random3(kAng60)) & 2047;
@ -1662,7 +1662,7 @@ void debrisMove(int listIndex)
uwater = true; uwater = true;
} }
if (actor->int_vel().X != 0 || actor->int_vel().Y) if (actor->vel.X != 0 || actor->int_vel().Y)
{ {
auto oldcstat = actor->spr.cstat; auto oldcstat = actor->spr.cstat;
@ -1816,7 +1816,7 @@ void debrisMove(int listIndex)
} }
} }
else if (actor->int_vel().Z == 0) else if (actor->vel.Z == 0)
{ {
actor->xspr.physAttr &= ~kPhysFalling; actor->xspr.physAttr &= ~kPhysFalling;
} }
@ -1849,7 +1849,7 @@ void debrisMove(int listIndex)
trTriggerSprite(actor, kCmdToggle, actor); trTriggerSprite(actor, kCmdToggle, actor);
} }
if (actor->int_vel().X == 0 && actor->int_vel().Y == 0) return; if (actor->vel.X == 0 && actor->vel.Y == 0) return;
else if (floorColl.type == kHitSprite) else if (floorColl.type == kHitSprite)
{ {
@ -2783,7 +2783,7 @@ void usePropertiesChanger(DBloodActor* sourceactor, int objType, sectortype* pSe
if (targetactor->spr.statnum == kStatThing) ChangeActorStat(targetactor, 0); if (targetactor->spr.statnum == kStatThing) ChangeActorStat(targetactor, 0);
// set random goal ang for swimming so they start turning // set random goal ang for swimming so they start turning
if ((flags & kPhysDebrisSwim) && targetactor->int_vel().X ==0 && targetactor->int_vel().Y == 0 && targetactor->int_vel().Z == 0) if ((flags & kPhysDebrisSwim) && targetactor->int_vel().X ==0 && targetactor->vel.Y == 0 && targetactor->vel.Z == 0)
targetactor->xspr.goalAng = (targetactor->int_ang() + Random3(kAng45)) & 2047; targetactor->xspr.goalAng = (targetactor->int_ang() + Random3(kAng45)) & 2047;
if (targetactor->xspr.physAttr & kPhysDebrisVector) if (targetactor->xspr.physAttr & kPhysDebrisVector)
@ -4623,7 +4623,7 @@ bool condCheckSprite(DBloodActor* aCond, int cmpOp, bool PUSH)
else if (arg1 == 2) return condCmp(objActor->int_vel().Y, arg1, arg2, cmpOp); else if (arg1 == 2) return condCmp(objActor->int_vel().Y, arg1, arg2, cmpOp);
else if (arg1 == 3) return condCmp(objActor->int_vel().Z, arg1, arg2, cmpOp); else if (arg1 == 3) return condCmp(objActor->int_vel().Z, arg1, arg2, cmpOp);
} }
else if (arg1 == 0) return (objActor->int_vel().X != 0 || objActor->int_vel().Y != 0 || objActor->int_vel().Z); else if (arg1 == 0) return (objActor->vel.X != 0 || objActor->vel.Y != 0 || objActor->int_vel().Z);
else if (arg1 == 1) return (objActor->int_vel().X); else if (arg1 == 1) return (objActor->int_vel().X);
else if (arg1 == 2) return (objActor->int_vel().Y); else if (arg1 == 2) return (objActor->int_vel().Y);
else if (arg1 == 3) return (objActor->int_vel().Z); else if (arg1 == 3) return (objActor->int_vel().Z);
@ -8210,7 +8210,7 @@ void aiPatrolMove(DBloodActor* actor)
if (hitactor->hasX() && hitactor->xspr.health) if (hitactor->hasX() && hitactor->xspr.health)
{ {
hitactor->xspr.dodgeDir = (actor->xspr.dodgeDir > 0) ? -1 : 1; hitactor->xspr.dodgeDir = (actor->xspr.dodgeDir > 0) ? -1 : 1;
if (hitactor->int_vel().X != 0 || hitactor->int_vel().Y) if (hitactor->vel.X != 0 || hitactor->int_vel().Y)
aiMoveDodge(hitactor); aiMoveDodge(hitactor);
} }
} }
@ -8580,7 +8580,7 @@ DBloodActor* aiPatrolSearchTargets(DBloodActor* actor)
{ {
DBloodActor* act = pPlayer->actor; DBloodActor* act = pPlayer->actor;
itCanHear = (!deaf && (nDist < hearDist || hearChance > 0)); itCanHear = (!deaf && (nDist < hearDist || hearChance > 0));
if (act && itCanHear && nDist < feelDist && (act->int_vel().X != 0 || act->int_vel().Y != 0 || act->int_vel().Z)) if (act && itCanHear && nDist < feelDist && (act->vel.X != 0 || act->vel.Y != 0 || act->int_vel().Z))
hearChance += ClipLow(mulscale8(1, ClipLow(((feelDist - nDist) + (abs(act->int_vel().X) + abs(act->int_vel().Y) + abs(act->int_vel().Z))) >> 6, 0)), 0); hearChance += ClipLow(mulscale8(1, ClipLow(((feelDist - nDist) + (abs(act->int_vel().X) + abs(act->int_vel().Y) + abs(act->int_vel().Z))) >> 6, 0)), 0);
} }

View file

@ -348,7 +348,7 @@ void SEQINST::Update()
// by NoOne: add surfaceSound trigger feature // by NoOne: add surfaceSound trigger feature
if (!VanillaMode() && pSequence->frames[frameIndex].surfaceSound && actor->int_vel().Z == 0 && actor->int_vel().X != 0) { if (!VanillaMode() && pSequence->frames[frameIndex].surfaceSound && actor->vel.Z == 0 && actor->vel.X != 0) {
if (actor->sector()->upperLink) break; // don't play surface sound for stacked sectors if (actor->sector()->upperLink) break; // don't play surface sound for stacked sectors
int surf = tileGetSurfType(actor->sector()->floorpicnum); int surf = tileGetSurfType(actor->sector()->floorpicnum);