ULTIMA8: Refactor getActorFlags -> hasActorFlags

This commit is contained in:
Matthew Duggan 2020-04-24 09:37:32 +09:00
parent 2d4d093522
commit e0398b15ec
15 changed files with 35 additions and 35 deletions

View File

@ -181,7 +181,7 @@ bool MenuGump::OnKeyDown(int key, int mod) {
if (key == Common::KEYCODE_ESCAPE) {
// FIXME: this check should probably be in Game or GUIApp
MainActor *av = getMainActor();
if (av && !(av->getActorFlags() & Actor::ACT_DEAD))
if (av && !av->hasActorFlags(Actor::ACT_DEAD))
Close(); // don't allow closing if dead/game over
} else if (key >= Common::KEYCODE_1 && key <= Common::KEYCODE_9) {
selectEntry(key - Common::KEYCODE_1 + 1);

View File

@ -326,7 +326,7 @@ Gump *U8SaveGump::showLoadSaveGump(Gump *parent, bool save) {
// can't _save if game over
// FIXME: this check should probably be in Game or GUIApp
MainActor *av = getMainActor();
if (!av || (av->getActorFlags() & Actor::ACT_DEAD))
if (!av || av->hasActorFlags(Actor::ACT_DEAD))
return nullptr;
}

View File

@ -685,7 +685,7 @@ bool Debugger::cmdToggleInvincibility(int argc, const char **argv) {
}
MainActor *av = getMainActor();
if (av->getActorFlags() & Actor::ACT_INVINCIBLE) {
if (av->hasActorFlags(Actor::ACT_INVINCIBLE)) {
av->clearActorFlag(Actor::ACT_INVINCIBLE);
debugPrintf("Avatar is no longer invincible.\n");
} else {

View File

@ -942,7 +942,7 @@ bool Ultima8Engine::canSaveGameStateCurrently(bool isAutosave) {
// Don't allow saving when avatar is dead.
MainActor *av = getMainActor();
if (!av || (av->getActorFlags() & Actor::ACT_DEAD))
if (!av || av->hasActorFlags(Actor::ACT_DEAD))
return false;
return true;
@ -958,7 +958,7 @@ bool Ultima8Engine::saveGame(int slot, const Std::string &desc, bool ignore_moda
// Don't allow saving when avatar is dead.
// (Avatar is flagged dead by usecode when you finish the _game as well.)
MainActor *av = getMainActor();
if (!av || (av->getActorFlags() & Actor::ACT_DEAD)) {
if (!av || av->hasActorFlags(Actor::ACT_DEAD)) {
pout << "Can't save: _game over." << Std::endl;
return false;
}

View File

@ -625,11 +625,11 @@ void Actor::receiveHit(uint16 other, int dir, int damage, uint16 damage_type) {
Kernel::get_instance()->addProcess(sp);
}
if (damage > 0 && !(getActorFlags() & (ACT_IMMORTAL | ACT_INVINCIBLE))) {
if (damage > 0 && !hasActorFlags(ACT_IMMORTAL | ACT_INVINCIBLE)) {
if (damage >= _hitPoints) {
// we're dead
if (getActorFlags() & ACT_WITHSTANDDEATH) {
if (hasActorFlags(ACT_WITHSTANDDEATH)) {
// or maybe not...
setHP(getMaxHP());
@ -909,7 +909,7 @@ int Actor::calculateAttackDamage(uint16 other, int damage, uint16 damage_type) {
// blocking?
if ((getLastAnim() == Animation::startBlock ||
getLastAnim() == Animation::stopBlock) &&
!(getActorFlags() & ACT_STUNNED)) {
!hasActorFlags(ACT_STUNNED)) {
damage -= getStr() / 5;
}
@ -917,7 +917,7 @@ int Actor::calculateAttackDamage(uint16 other, int damage, uint16 damage_type) {
if (damage_type & WeaponInfo::DMG_FIRE)
ACmod /= 2; // armour doesn't protect from fire as well
if (getActorFlags() & ACT_STUNNED)
if (hasActorFlags(ACT_STUNNED))
ACmod /= 2; // stunned?
if (ACmod > 100) ACmod = 100;
@ -936,7 +936,7 @@ int Actor::calculateAttackDamage(uint16 other, int damage, uint16 damage_type) {
if (attackdex < 0) attackdex = 0;
if (defenddex <= 0) defenddex = 1;
if ((getActorFlags() & ACT_STUNNED) ||
if (hasActorFlags(ACT_STUNNED) ||
(getRandom() % (attackdex + 3) > getRandom() % defenddex)) {
hit = true;
}
@ -1011,8 +1011,8 @@ bool Actor::areEnemiesNear() {
if (!npc) continue;
if (npc == this) continue;
if (npc->getActorFlags() & (ACT_DEAD | ACT_FEIGNDEATH)) continue;
if (!(npc->getActorFlags() & ACT_INCOMBAT)) continue;
if (npc->hasActorFlags(ACT_DEAD | ACT_FEIGNDEATH)) continue;
if (!npc->hasActorFlags(ACT_INCOMBAT)) continue;
// TODO: check if hostile.
// Might not be strictly necessary, though. This function is only
@ -1377,7 +1377,7 @@ uint32 Actor::I_isImmortal(const uint8 *args, unsigned int /*argsize*/) {
ARG_ACTOR_FROM_PTR(actor);
if (!actor) return 0;
if (actor->getActorFlags() & ACT_IMMORTAL)
if (actor->hasActorFlags(ACT_IMMORTAL))
return 1;
else
return 0;
@ -1406,7 +1406,7 @@ uint32 Actor::I_isWithstandDeath(const uint8 *args, unsigned int /*argsize*/) {
ARG_ACTOR_FROM_PTR(actor);
if (!actor) return 0;
if (actor->getActorFlags() & ACT_WITHSTANDDEATH)
if (actor->hasActorFlags(ACT_WITHSTANDDEATH))
return 1;
else
return 0;
@ -1434,7 +1434,7 @@ uint32 Actor::I_isFeignDeath(const uint8 *args, unsigned int /*argsize*/) {
ARG_ACTOR_FROM_PTR(actor);
if (!actor) return 0;
if (actor->getActorFlags() & ACT_FEIGNDEATH)
if (actor->hasActorFlags(ACT_FEIGNDEATH))
return 1;
else
return 0;
@ -1444,7 +1444,7 @@ uint32 Actor::I_setFeignDeath(const uint8 *args, unsigned int /*argsize*/) {
ARG_ACTOR_FROM_PTR(actor);
if (!actor) return 0;
if (actor->getActorFlags() & ACT_FEIGNDEATH)
if (actor->hasActorFlags(ACT_FEIGNDEATH))
return 0;
actor->setActorFlag(ACT_FEIGNDEATH);
@ -1578,7 +1578,7 @@ uint32 Actor::I_getAirWalkEnabled(const uint8 *args, unsigned int /*argsize*/) {
ARG_ACTOR_FROM_PTR(actor);
if (!actor) return 0;
if (actor->getActorFlags() & ACT_AIRWALK)
if (actor->hasActorFlags(ACT_AIRWALK))
return 1;
else
return 0;

View File

@ -126,8 +126,8 @@ public:
_unk0C = b;
}
uint32 getActorFlags() const {
return _actorFlags;
bool hasActorFlags(uint32 flags) const {
return (_actorFlags & flags) != 0;
}
void setActorFlag(uint32 mask) {
_actorFlags |= mask;

View File

@ -95,7 +95,7 @@ bool ActorAnimProcess::init() {
return false;
}
if (actor->getActorFlags() & Actor::ACT_ANIMLOCK) {
if (actor->hasActorFlags(Actor::ACT_ANIMLOCK)) {
//! What do we do if actor was already animating?
//! don't do this animation or kill the previous one?
//! Or maybe wait until the previous one finishes?
@ -509,7 +509,7 @@ void ActorAnimProcess::doHitSpecial(Item *hit) {
break;
case 0x330: { // Slayer
// if we killed somebody, thunder&lightning
if (attacked && (attacked->getActorFlags() & Actor::ACT_DEAD)) {
if (attacked && attacked->hasActorFlags(Actor::ACT_DEAD)) {
// calling intrinsic...
PaletteFaderProcess::I_lightningBolt(0, 0);
int sfx;

View File

@ -63,7 +63,7 @@ void AnimAction::getAnimRange(Actor *actor, int dir,
unsigned int &startframe,
unsigned int &endframe) const {
getAnimRange(actor->getLastAnim(), actor->getDir(),
(actor->getActorFlags() & Actor::ACT_FIRSTSTEP) != 0,
actor->hasActorFlags(Actor::ACT_FIRSTSTEP),
dir, startframe, endframe);
}

View File

@ -65,7 +65,7 @@ bool AnimationTracker::init(Actor *actor_, Animation::Sequence action_,
_animAction->getAnimRange(actor_, _dir, _startFrame, _endFrame);
actor_->getLocation(_x, _y, _z);
_flipped = (actor_->getFlags() & Item::FLG_FLIPPED) != 0;
_firstStep = (actor_->getActorFlags() & Actor::ACT_FIRSTSTEP) != 0;
_firstStep = actor_->hasActorFlags(Actor::ACT_FIRSTSTEP);
} else {
_animAction->getAnimRange(state_->_lastAnim, state_->_direction,
state_->_firstStep, _dir, _startFrame, _endFrame);

View File

@ -54,7 +54,7 @@ void AvatarDeathProcess::run() {
return;
}
if (!(av->getActorFlags() & Actor::ACT_DEAD)) {
if (!av->hasActorFlags(Actor::ACT_DEAD)) {
perr << "AvatarDeathProcess: MainActor not dead" << Std::endl;
// avatar not dead?
terminate();

View File

@ -90,7 +90,7 @@ void AvatarMoverProcess::run() {
return;
}
bool combatRun = (avatar->getActorFlags() & Actor::ACT_COMBATRUN) != 0;
bool combatRun = avatar->hasActorFlags(Actor::ACT_COMBATRUN);
if (avatar->isInCombat() && !combatRun)
handleCombatMode();
else
@ -324,7 +324,7 @@ void AvatarMoverProcess::handleNormalMode() {
int32 direction = avatar->getDir();
uint32 now = g_system->getMillis();
bool stasis = guiapp->isAvatarInStasis();
bool combatRun = (avatar->getActorFlags() & Actor::ACT_COMBATRUN) != 0;
bool combatRun = avatar->hasActorFlags(Actor::ACT_COMBATRUN);
int32 mx, my;
mouse->getMouseCoords(mx, my);
@ -652,7 +652,7 @@ void AvatarMoverProcess::jump(Animation::Sequence action, int direction) {
}
// airwalk
if ((avatar->getActorFlags() & Actor::ACT_AIRWALK) &&
if (avatar->hasActorFlags(Actor::ACT_AIRWALK) &&
action == Animation::jump) {
waitFor(avatar->doAnim(Animation::airwalkJump, direction));
return;
@ -693,7 +693,7 @@ void AvatarMoverProcess::jump(Animation::Sequence action, int direction) {
void AvatarMoverProcess::turnToDirection(int direction) {
MainActor *avatar = getMainActor();
bool combatRun = (avatar->getActorFlags() & Actor::ACT_COMBATRUN) != 0;
bool combatRun = avatar->hasActorFlags(Actor::ACT_COMBATRUN);
int curdir = avatar->getDir();
int stepDelta;
bool combat = avatar->isInCombat() && !combatRun;
@ -742,7 +742,7 @@ void AvatarMoverProcess::turnToDirection(int direction) {
bool AvatarMoverProcess::checkTurn(int direction, bool moving) {
MainActor *avatar = getMainActor();
bool combatRun = (avatar->getActorFlags() & Actor::ACT_COMBATRUN) != 0;
bool combatRun = avatar->hasActorFlags(Actor::ACT_COMBATRUN);
int curdir = avatar->getDir();
bool combat = avatar->isInCombat() && !combatRun;
Animation::Sequence lastanim = avatar->getLastAnim();

View File

@ -190,7 +190,7 @@ bool CombatProcess::isValidTarget(Actor *target_) {
if (target_->isDead()) return false;
// feign death only works on undead and demons
if (target_->getActorFlags() & Actor::ACT_FEIGNDEATH) {
if (target_->hasActorFlags(Actor::ACT_FEIGNDEATH)) {
if ((a->getDefenseType() & WeaponInfo::DMG_UNDEAD) ||
(a->getShape() == 96)) return false; // CONSTANT!

View File

@ -149,9 +149,9 @@ void GrantPeaceProcess::run() {
} else {
// not undead
if (!(target->getActorFlags() & (Actor::ACT_DEAD |
Actor::ACT_IMMORTAL |
Actor::ACT_INVINCIBLE))) {
if (!target->hasActorFlags(Actor::ACT_DEAD |
Actor::ACT_IMMORTAL |
Actor::ACT_INVINCIBLE)) {
if (getRandom() % 10 == 0) {
target->receiveHit(_itemNum, 8, target->getHP(),
(WeaponInfo::DMG_MAGIC |

View File

@ -52,7 +52,7 @@ void PathfindingState::load(const Actor *_actor) {
_actor->getLocation(_x, _y, _z);
_lastAnim = _actor->getLastAnim();
_direction = _actor->getDir();
_firstStep = (_actor->getActorFlags() & Actor::ACT_FIRSTSTEP) != 0;
_firstStep = _actor->hasActorFlags(Actor::ACT_FIRSTSTEP);
_flipped = (_actor->getFlags() & Item::FLG_FLIPPED) != 0;
_combat = _actor->isInCombat();
}

View File

@ -171,7 +171,7 @@ void PathfinderProcess::run() {
// FIXME: this should happen before the pathfinder is actually called,
// since the running animation may move the actor, which could break
// the found _path.
if (actor->getActorFlags() & Actor::ACT_ANIMLOCK) {
if (actor->hasActorFlags(Actor::ACT_ANIMLOCK)) {
perr << "PathfinderProcess: ANIMLOCK, waiting" << Std::endl;
return;
}