Get rid of "player" string checks (Fixes #2216)

celladd
scrawl 10 years ago
parent 68de876051
commit 3879ce6ac1

@ -355,7 +355,7 @@ namespace MWClass
if(!object.isEmpty()) if(!object.isEmpty())
getCreatureStats(ptr).setLastHitObject(object.getClass().getId(object)); getCreatureStats(ptr).setLastHitObject(object.getClass().getId(object));
if(setOnPcHitMe && !attacker.isEmpty() && attacker.getRefData().getHandle() == "player") if(setOnPcHitMe && !attacker.isEmpty() && attacker == MWBase::Environment::get().getWorld()->getPlayerPtr())
{ {
const std::string &script = ptr.get<ESM::Creature>()->mBase->mScript; const std::string &script = ptr.get<ESM::Creature>()->mBase->mScript;
/* Set the OnPCHitMe script variable. The script is responsible for clearing it. */ /* Set the OnPCHitMe script variable. The script is responsible for clearing it. */

@ -507,7 +507,7 @@ namespace MWClass
if(otherstats.isDead()) // Can't hit dead actors if(otherstats.isDead()) // Can't hit dead actors
return; return;
if(ptr.getRefData().getHandle() == "player") if(ptr == MWBase::Environment::get().getWorld()->getPlayerPtr())
MWBase::Environment::get().getWindowManager()->setEnemy(victim); MWBase::Environment::get().getWindowManager()->setEnemy(victim);
int weapskill = ESM::Skill::HandToHand; int weapskill = ESM::Skill::HandToHand;
@ -549,7 +549,7 @@ namespace MWClass
{ {
MWMechanics::getHandToHandDamage(ptr, victim, damage, healthdmg); MWMechanics::getHandToHandDamage(ptr, victim, damage, healthdmg);
} }
if(ptr.getRefData().getHandle() == "player") if(ptr == MWBase::Environment::get().getWorld()->getPlayerPtr())
{ {
skillUsageSucceeded(ptr, weapskill, 0); skillUsageSucceeded(ptr, weapskill, 0);
@ -625,7 +625,7 @@ namespace MWClass
if(!object.isEmpty()) if(!object.isEmpty())
getCreatureStats(ptr).setLastHitObject(object.getClass().getId(object)); getCreatureStats(ptr).setLastHitObject(object.getClass().getId(object));
if(setOnPcHitMe && !attacker.isEmpty() && attacker.getRefData().getHandle() == "player") if(setOnPcHitMe && !attacker.isEmpty() && attacker == MWBase::Environment::get().getWorld()->getPlayerPtr())
{ {
const std::string &script = ptr.getClass().getScript(ptr); const std::string &script = ptr.getClass().getScript(ptr);
/* Set the OnPCHitMe script variable. The script is responsible for clearing it. */ /* Set the OnPCHitMe script variable. The script is responsible for clearing it. */
@ -708,7 +708,7 @@ namespace MWClass
if (armorhealth == 0) if (armorhealth == 0)
armor = *inv.unequipItem(armor, ptr); armor = *inv.unequipItem(armor, ptr);
if (ptr.getRefData().getHandle() == "player") if (ptr == MWBase::Environment::get().getWorld()->getPlayerPtr())
skillUsageSucceeded(ptr, armor.getClass().getEquipmentSkill(armor), 0); skillUsageSucceeded(ptr, armor.getClass().getEquipmentSkill(armor), 0);
switch(armor.getClass().getEquipmentSkill(armor)) switch(armor.getClass().getEquipmentSkill(armor))
@ -724,7 +724,7 @@ namespace MWClass
break; break;
} }
} }
else if(ptr.getRefData().getHandle() == "player") else if(ptr == MWBase::Environment::get().getWorld()->getPlayerPtr())
skillUsageSucceeded(ptr, ESM::Skill::Unarmored, 0); skillUsageSucceeded(ptr, ESM::Skill::Unarmored, 0);
} }
} }
@ -737,7 +737,7 @@ namespace MWClass
if(damage > 0.0f) if(damage > 0.0f)
{ {
sndMgr->playSound3D(ptr, "Health Damage", 1.0f, 1.0f); sndMgr->playSound3D(ptr, "Health Damage", 1.0f, 1.0f);
if (ptr.getRefData().getHandle() == "player") if (ptr == MWBase::Environment::get().getWorld()->getPlayerPtr())
MWBase::Environment::get().getWindowManager()->activateHitOverlay(); MWBase::Environment::get().getWindowManager()->activateHitOverlay();
} }
float health = getCreatureStats(ptr).getHealth().getCurrent() - damage; float health = getCreatureStats(ptr).getHealth().getCurrent() - damage;
@ -815,7 +815,7 @@ namespace MWClass
const MWWorld::Ptr& actor) const const MWWorld::Ptr& actor) const
{ {
// player got activated by another NPC // player got activated by another NPC
if(ptr.getRefData().getHandle() == "player") if(ptr == MWBase::Environment::get().getWorld()->getPlayerPtr())
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionTalk(actor)); return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionTalk(actor));
// Werewolfs can't activate NPCs // Werewolfs can't activate NPCs

@ -99,7 +99,7 @@ bool disintegrateSlot (MWWorld::Ptr ptr, int slot, float disintegrate)
if (charge == 0) if (charge == 0)
{ {
// Will unequip the broken item and try to find a replacement // Will unequip the broken item and try to find a replacement
if (ptr.getRefData().getHandle() != "player") if (ptr != MWBase::Environment::get().getWorld()->getPlayerPtr())
inv.autoEquip(ptr); inv.autoEquip(ptr);
else else
inv.unequipItem(*item, ptr); inv.unequipItem(*item, ptr);
@ -154,6 +154,7 @@ void adjustCommandedActor (const MWWorld::Ptr& actor)
if (check.mCommanded && !hasCommandPackage) if (check.mCommanded && !hasCommandPackage)
{ {
// FIXME: don't use refid string
MWMechanics::AiFollow package("player", true); MWMechanics::AiFollow package("player", true);
stats.getAiSequence().stack(package, actor); stats.getAiSequence().stack(package, actor);
} }
@ -244,7 +245,7 @@ namespace MWMechanics
gem->getContainerStore()->unstack(*gem, caster); gem->getContainerStore()->unstack(*gem, caster);
gem->getCellRef().setSoul(mCreature.getCellRef().getRefId()); gem->getCellRef().setSoul(mCreature.getCellRef().getRefId());
if (caster.getRefData().getHandle() == "player") if (caster == MWBase::Environment::get().getWorld()->getPlayerPtr())
MWBase::Environment::get().getWindowManager()->messageBox("#{sSoultrapSuccess}"); MWBase::Environment::get().getWindowManager()->messageBox("#{sSoultrapSuccess}");
const ESM::Static* fx = MWBase::Environment::get().getWorld()->getStore().get<ESM::Static>() const ESM::Static* fx = MWBase::Environment::get().getWorld()->getStore().get<ESM::Static>()
@ -433,7 +434,7 @@ namespace MWMechanics
int intelligence = creatureStats.getAttribute(ESM::Attribute::Intelligence).getModified(); int intelligence = creatureStats.getAttribute(ESM::Attribute::Intelligence).getModified();
float base = 1.f; float base = 1.f;
if (ptr.getCellRef().getRefId() == "player") if (ptr == MWBase::Environment::get().getWorld()->getPlayerPtr())
base = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fPCbaseMagickaMult")->getFloat(); base = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fPCbaseMagickaMult")->getFloat();
else else
base = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fNPCbaseMagickaMult")->getFloat(); base = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fNPCbaseMagickaMult")->getFloat();
@ -543,7 +544,7 @@ namespace MWMechanics
{ {
spells.worsenCorprus(it->first); spells.worsenCorprus(it->first);
if (ptr.getRefData().getHandle() == "player") if (ptr == MWBase::Environment::get().getWorld()->getPlayerPtr())
MWBase::Environment::get().getWindowManager()->messageBox("#{sMagicCorprusWorsens}"); MWBase::Environment::get().getWindowManager()->messageBox("#{sMagicCorprusWorsens}");
} }
} }
@ -665,7 +666,7 @@ namespace MWMechanics
} }
} }
if (receivedMagicDamage && ptr.getRefData().getHandle() == "player") if (receivedMagicDamage && ptr == MWBase::Environment::get().getWorld()->getPlayerPtr())
MWBase::Environment::get().getWindowManager()->activateHitOverlay(false); MWBase::Environment::get().getWindowManager()->activateHitOverlay(false);
creatureStats.setHealth(health); creatureStats.setHealth(health);
@ -848,7 +849,7 @@ namespace MWMechanics
void Actors::updateEquippedLight (const MWWorld::Ptr& ptr, float duration) void Actors::updateEquippedLight (const MWWorld::Ptr& ptr, float duration)
{ {
bool isPlayer = ptr.getRefData().getHandle()=="player"; bool isPlayer = (ptr == MWBase::Environment::get().getWorld()->getPlayerPtr());
MWWorld::InventoryStore &inventoryStore = ptr.getClass().getInventoryStore(ptr); MWWorld::InventoryStore &inventoryStore = ptr.getClass().getInventoryStore(ptr);
MWWorld::ContainerStoreIterator heldIter = MWWorld::ContainerStoreIterator heldIter =
@ -1157,7 +1158,7 @@ namespace MWMechanics
// Handle player last, in case a cell transition occurs by casting a teleportation spell // Handle player last, in case a cell transition occurs by casting a teleportation spell
// (would invalidate the iterator) // (would invalidate the iterator)
if (iter->first.getCellRef().getRefId() == "player") if (iter->first == MWBase::Environment::get().getWorld()->getPlayerPtr())
{ {
playerCharacter = iter->second->getCharacterController(); playerCharacter = iter->second->getCharacterController();
continue; continue;

@ -1010,7 +1010,7 @@ bool CharacterController::updateWeaponState()
// For the player, set the spell we want to cast // For the player, set the spell we want to cast
// This has to be done at the start of the casting animation, // This has to be done at the start of the casting animation,
// *not* when selecting a spell in the GUI (otherwise you could change the spell mid-animation) // *not* when selecting a spell in the GUI (otherwise you could change the spell mid-animation)
if (mPtr.getRefData().getHandle() == "player") if (mPtr == MWBase::Environment::get().getWorld()->getPlayerPtr())
{ {
std::string selectedSpell = MWBase::Environment::get().getWindowManager()->getSelectedSpell(); std::string selectedSpell = MWBase::Environment::get().getWindowManager()->getSelectedSpell();
stats.getSpells().setSelectedSpell(selectedSpell); stats.getSpells().setSelectedSpell(selectedSpell);
@ -1094,7 +1094,7 @@ bool CharacterController::updateWeaponState()
mAttackType = "shoot"; mAttackType = "shoot";
else else
{ {
if(isWeapon && mPtr.getRefData().getHandle() == "player" && if(isWeapon && mPtr == MWBase::Environment::get().getWorld()->getPlayerPtr() &&
Settings::Manager::getBool("best attack", "Game")) Settings::Manager::getBool("best attack", "Game"))
{ {
MWWorld::ContainerStoreIterator weapon = mPtr.getClass().getInventoryStore(mPtr).getSlot(MWWorld::InventoryStore::Slot_CarriedRight); MWWorld::ContainerStoreIterator weapon = mPtr.getClass().getInventoryStore(mPtr).getSlot(MWWorld::InventoryStore::Slot_CarriedRight);
@ -1421,7 +1421,7 @@ void CharacterController::update(float duration)
// advance athletics // advance athletics
if(mHasMovedInXY && mPtr.getRefData().getHandle() == "player") if(mHasMovedInXY && mPtr == MWBase::Environment::get().getWorld()->getPlayerPtr())
{ {
if(inwater) if(inwater)
{ {
@ -1521,7 +1521,7 @@ void CharacterController::update(float duration)
} }
// advance acrobatics // advance acrobatics
if (mPtr.getRefData().getHandle() == "player") if (mPtr == MWBase::Environment::get().getWorld()->getPlayerPtr())
cls.skillUsageSucceeded(mPtr, ESM::Skill::Acrobatics, 0); cls.skillUsageSucceeded(mPtr, ESM::Skill::Acrobatics, 0);
// decrease fatigue // decrease fatigue
@ -1564,7 +1564,7 @@ void CharacterController::update(float duration)
else else
{ {
// report acrobatics progression // report acrobatics progression
if (mPtr.getRefData().getHandle() == "player") if (mPtr == MWBase::Environment::get().getWorld()->getPlayerPtr())
cls.skillUsageSucceeded(mPtr, ESM::Skill::Acrobatics, 1); cls.skillUsageSucceeded(mPtr, ESM::Skill::Acrobatics, 1);
} }
} }
@ -1797,7 +1797,7 @@ bool CharacterController::kill()
{ {
if( isDead() ) if( isDead() )
{ {
if( mPtr.getRefData().getHandle()=="player" && !isAnimPlaying(mCurrentDeath) ) if( mPtr == MWBase::Environment::get().getWorld()->getPlayerPtr() && !isAnimPlaying(mCurrentDeath) )
{ {
//player's death animation is over //player's death animation is over
MWBase::Environment::get().getStateManager()->askLoadRecent(); MWBase::Environment::get().getStateManager()->askLoadRecent();
@ -1813,7 +1813,7 @@ bool CharacterController::kill()
mCurrentIdle.clear(); mCurrentIdle.clear();
// Play Death Music if it was the player dying // Play Death Music if it was the player dying
if(mPtr.getRefData().getHandle()=="player") if(mPtr == MWBase::Environment::get().getWorld()->getPlayerPtr())
MWBase::Environment::get().getSoundManager()->streamMusic("Special/MW_Death.mp3"); MWBase::Environment::get().getSoundManager()->streamMusic("Special/MW_Death.mp3");
return true; return true;
@ -1854,7 +1854,7 @@ void CharacterController::updateMagicEffects()
float alpha = 1.f; float alpha = 1.f;
if (mPtr.getClass().getCreatureStats(mPtr).getMagicEffects().get(ESM::MagicEffect::Invisibility).getMagnitude()) if (mPtr.getClass().getCreatureStats(mPtr).getMagicEffects().get(ESM::MagicEffect::Invisibility).getMagnitude())
{ {
if (mPtr.getRefData().getHandle() == "player") if (mPtr == MWBase::Environment::get().getWorld()->getPlayerPtr())
alpha = 0.4f; alpha = 0.4f;
else else
alpha = 0.f; alpha = 0.f;

@ -133,7 +133,7 @@ namespace MWMechanics
blockerStats.setBlock(true); blockerStats.setBlock(true);
if (blocker.getCellRef().getRefId() == "player") if (blocker == MWBase::Environment::get().getWorld()->getPlayerPtr())
blocker.getClass().skillUsageSucceeded(blocker, ESM::Skill::Block, 0); blocker.getClass().skillUsageSucceeded(blocker, ESM::Skill::Block, 0);
return true; return true;
@ -157,7 +157,7 @@ namespace MWMechanics
&& actor.getClass().isNpc() && actor.getClass().getNpcStats(actor).isWerewolf()) && actor.getClass().isNpc() && actor.getClass().getNpcStats(actor).isWerewolf())
damage *= MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fWereWolfSilverWeaponDamageMult")->getFloat(); damage *= MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fWereWolfSilverWeaponDamageMult")->getFloat();
if (damage == 0 && attacker.getRefData().getHandle() == "player") if (damage == 0 && attacker == MWBase::Environment::get().getWorld()->getPlayerPtr())
MWBase::Environment::get().getWindowManager()->messageBox("#{sMagicTargetResistsWeapons}"); MWBase::Environment::get().getWindowManager()->messageBox("#{sMagicTargetResistsWeapons}");
} }
@ -176,7 +176,7 @@ namespace MWMechanics
return; return;
} }
if(attacker.getRefData().getHandle() == "player") if(attacker == MWBase::Environment::get().getWorld()->getPlayerPtr())
MWBase::Environment::get().getWindowManager()->setEnemy(victim); MWBase::Environment::get().getWindowManager()->setEnemy(victim);
int weapskill = ESM::Skill::Marksman; int weapskill = ESM::Skill::Marksman;
@ -211,7 +211,7 @@ namespace MWMechanics
adjustWeaponDamage(damage, weapon); adjustWeaponDamage(damage, weapon);
reduceWeaponCondition(damage, true, weapon, attacker); reduceWeaponCondition(damage, true, weapon, attacker);
if(attacker.getRefData().getHandle() == "player") if(attacker == MWBase::Environment::get().getWorld()->getPlayerPtr())
attacker.getClass().skillUsageSucceeded(attacker, weapskill, 0); attacker.getClass().skillUsageSucceeded(attacker, weapskill, 0);
if (victim.getClass().getCreatureStats(victim).getKnockedDown()) if (victim.getClass().getCreatureStats(victim).getKnockedDown())

@ -180,7 +180,7 @@ namespace MWMechanics
int actorLuck = stats.getAttribute(ESM::Attribute::Luck).getModified(); int actorLuck = stats.getAttribute(ESM::Attribute::Luck).getModified();
float castChance = (lowestSkill - spell->mData.mCost + castBonus + 0.2f * actorWillpower + 0.1f * actorLuck) * stats.getFatigueTerm(); float castChance = (lowestSkill - spell->mData.mCost + castBonus + 0.2f * actorWillpower + 0.1f * actorLuck) * stats.getFatigueTerm();
if (MWBase::Environment::get().getWorld()->getGodModeState() && actor.getRefData().getHandle() == "player") if (MWBase::Environment::get().getWorld()->getGodModeState() && actor == MWBase::Environment::get().getWorld()->getPlayerPtr())
castChance = 100; castChance = 100;
if (!cap) if (!cap)
@ -387,7 +387,7 @@ namespace MWMechanics
if (roll <= x) if (roll <= x)
{ {
// Fully resisted, show message // Fully resisted, show message
if (target.getRefData().getHandle() == "player") if (target == MWBase::Environment::get().getWorld()->getPlayerPtr())
MWBase::Environment::get().getWindowManager()->messageBox("#{sMagicPCResisted}"); MWBase::Environment::get().getWindowManager()->messageBox("#{sMagicPCResisted}");
return; return;
} }
@ -405,7 +405,7 @@ namespace MWMechanics
if (target.getClass().isActor()) if (target.getClass().isActor())
targetEffects += target.getClass().getCreatureStats(target).getMagicEffects(); targetEffects += target.getClass().getCreatureStats(target).getMagicEffects();
bool castByPlayer = (!caster.isEmpty() && caster.getRefData().getHandle() == "player"); bool castByPlayer = (!caster.isEmpty() && caster == MWBase::Environment::get().getWorld()->getPlayerPtr());
// Try absorbing if it's a spell // Try absorbing if it's a spell
// NOTE: Vanilla does this once per effect source instead of adding the % from all sources together, not sure // NOTE: Vanilla does this once per effect source instead of adding the % from all sources together, not sure
@ -482,7 +482,7 @@ namespace MWMechanics
if (magnitudeMult == 0) if (magnitudeMult == 0)
{ {
// Fully resisted, show message // Fully resisted, show message
if (target.getRefData().getHandle() == "player") if (target == MWBase::Environment::get().getWorld()->getPlayerPtr())
MWBase::Environment::get().getWindowManager()->messageBox("#{sMagicPCResisted}"); MWBase::Environment::get().getWindowManager()->messageBox("#{sMagicPCResisted}");
else if (castByPlayer) else if (castByPlayer)
MWBase::Environment::get().getWindowManager()->messageBox("#{sMagicTargetResisted}"); MWBase::Environment::get().getWindowManager()->messageBox("#{sMagicTargetResisted}");
@ -611,7 +611,7 @@ namespace MWMechanics
{ {
if (target.getCellRef().getLockLevel() < magnitude) //If the door is not already locked to a higher value, lock it to spell magnitude if (target.getCellRef().getLockLevel() < magnitude) //If the door is not already locked to a higher value, lock it to spell magnitude
{ {
if (caster.getRefData().getHandle() == "player") if (caster == MWBase::Environment::get().getWorld()->getPlayerPtr())
MWBase::Environment::get().getWindowManager()->messageBox("#{sMagicLockSuccess}"); MWBase::Environment::get().getWindowManager()->messageBox("#{sMagicLockSuccess}");
target.getCellRef().setLockLevel(static_cast<int>(magnitude)); target.getCellRef().setLockLevel(static_cast<int>(magnitude));
} }
@ -626,7 +626,7 @@ namespace MWMechanics
if (!caster.isEmpty() && caster.getClass().isActor()) if (!caster.isEmpty() && caster.getClass().isActor())
MWBase::Environment::get().getMechanicsManager()->objectOpened(caster, target); MWBase::Environment::get().getMechanicsManager()->objectOpened(caster, target);
if (caster.getRefData().getHandle() == "player") if (caster == MWBase::Environment::get().getWorld()->getPlayerPtr())
MWBase::Environment::get().getWindowManager()->messageBox("#{sMagicOpenSuccess}"); MWBase::Environment::get().getWindowManager()->messageBox("#{sMagicOpenSuccess}");
} }
target.getCellRef().setLockLevel(-abs(target.getCellRef().getLockLevel())); target.getCellRef().setLockLevel(-abs(target.getCellRef().getLockLevel()));
@ -652,7 +652,7 @@ namespace MWMechanics
else if (effectId == ESM::MagicEffect::RemoveCurse) else if (effectId == ESM::MagicEffect::RemoveCurse)
target.getClass().getCreatureStats(target).getSpells().purgeCurses(); target.getClass().getCreatureStats(target).getSpells().purgeCurses();
if (target.getRefData().getHandle() != "player") if (target != MWBase::Environment::get().getWorld()->getPlayerPtr())
return; return;
if (!MWBase::Environment::get().getWorld()->isTeleportingEnabled()) if (!MWBase::Environment::get().getWorld()->isTeleportingEnabled())
return; return;
@ -728,7 +728,7 @@ namespace MWMechanics
if (item.getCellRef().getEnchantmentCharge() < castCost) if (item.getCellRef().getEnchantmentCharge() < castCost)
{ {
if (mCaster.getRefData().getHandle() == "player") if (mCaster == MWBase::Environment::get().getWorld()->getPlayerPtr())
MWBase::Environment::get().getWindowManager()->messageBox("#{sMagicInsufficientCharge}"); MWBase::Environment::get().getWindowManager()->messageBox("#{sMagicInsufficientCharge}");
// Failure sound // Failure sound
@ -752,14 +752,14 @@ namespace MWMechanics
if (enchantment->mData.mType == ESM::Enchantment::WhenUsed) if (enchantment->mData.mType == ESM::Enchantment::WhenUsed)
{ {
if (mCaster.getRefData().getHandle() == "player") if (mCaster == MWBase::Environment::get().getWorld()->getPlayerPtr())
mCaster.getClass().skillUsageSucceeded (mCaster, ESM::Skill::Enchant, 1); mCaster.getClass().skillUsageSucceeded (mCaster, ESM::Skill::Enchant, 1);
} }
if (enchantment->mData.mType == ESM::Enchantment::CastOnce) if (enchantment->mData.mType == ESM::Enchantment::CastOnce)
item.getContainerStore()->remove(item, 1, mCaster); item.getContainerStore()->remove(item, 1, mCaster);
else if (enchantment->mData.mType != ESM::Enchantment::WhenStrikes) else if (enchantment->mData.mType != ESM::Enchantment::WhenStrikes)
{ {
if (mCaster.getRefData().getHandle() == "player") if (mCaster == MWBase::Environment::get().getWorld()->getPlayerPtr())
{ {
mCaster.getClass().skillUsageSucceeded (mCaster, ESM::Skill::Enchant, 3); mCaster.getClass().skillUsageSucceeded (mCaster, ESM::Skill::Enchant, 3);
} }
@ -827,7 +827,7 @@ namespace MWMechanics
int roll = static_cast<int>(std::rand() / (static_cast<double> (RAND_MAX)+1) * 100); // [0, 99] int roll = static_cast<int>(std::rand() / (static_cast<double> (RAND_MAX)+1) * 100); // [0, 99]
if (!fail && roll >= successChance) if (!fail && roll >= successChance)
{ {
if (mCaster.getRefData().getHandle() == "player") if (mCaster == MWBase::Environment::get().getWorld()->getPlayerPtr())
MWBase::Environment::get().getWindowManager()->messageBox("#{sMagicSkillFail}"); MWBase::Environment::get().getWindowManager()->messageBox("#{sMagicSkillFail}");
fail = true; fail = true;
} }
@ -845,7 +845,7 @@ namespace MWMechanics
} }
} }
if (mCaster.getRefData().getHandle() == "player" && spellIncreasesSkill(spell)) if (mCaster == MWBase::Environment::get().getWorld()->getPlayerPtr() && spellIncreasesSkill(spell))
mCaster.getClass().skillUsageSucceeded(mCaster, mCaster.getClass().skillUsageSucceeded(mCaster,
spellSchoolToSkill(school), 0); spellSchoolToSkill(school), 0);

@ -321,7 +321,7 @@ void RenderingManager::updatePlayerPtr(const MWWorld::Ptr &ptr)
void RenderingManager::rebuildPtr(const MWWorld::Ptr &ptr) void RenderingManager::rebuildPtr(const MWWorld::Ptr &ptr)
{ {
NpcAnimation *anim = NULL; NpcAnimation *anim = NULL;
if(ptr.getRefData().getHandle() == "player") if(ptr == MWBase::Environment::get().getWorld()->getPlayerPtr())
anim = mPlayerAnimation; anim = mPlayerAnimation;
else if(ptr.getClass().isActor()) else if(ptr.getClass().isActor())
anim = dynamic_cast<NpcAnimation*>(mActors->getAnimation(ptr)); anim = dynamic_cast<NpcAnimation*>(mActors->getAnimation(ptr));
@ -955,7 +955,7 @@ Animation* RenderingManager::getAnimation(const MWWorld::Ptr &ptr)
{ {
Animation *anim = mActors->getAnimation(ptr); Animation *anim = mActors->getAnimation(ptr);
if(!anim && ptr.getRefData().getHandle() == "player") if(!anim && ptr == MWBase::Environment::get().getWorld()->getPlayerPtr())
anim = mPlayerAnimation; anim = mPlayerAnimation;
if (!anim) if (!anim)

@ -175,7 +175,7 @@ namespace MWScript
MWWorld::ActionEquip action (*it); MWWorld::ActionEquip action (*it);
action.execute(ptr); action.execute(ptr);
if (ptr.getRefData().getHandle() == "player" && !ptr.getClass().getScript(ptr).empty()) if (ptr == MWBase::Environment::get().getWorld()->getPlayerPtr() && !ptr.getClass().getScript(ptr).empty())
ptr.getRefData().getLocals().setVarByInt(ptr.getClass().getScript(ptr), "onpcequip", 1); ptr.getRefData().getLocals().setVarByInt(ptr.getClass().getScript(ptr), "onpcequip", 1);
} }
}; };

@ -212,7 +212,7 @@ namespace MWScript
if (!ptr.isInCell()) if (!ptr.isInCell())
return; return;
if (ptr.getRefData().getHandle() == "player") if (ptr == MWBase::Environment::get().getWorld()->getPlayerPtr())
{ {
MWBase::Environment::get().getWorld()->getPlayer().setTeleported(true); MWBase::Environment::get().getWorld()->getPlayer().setTeleported(true);
} }
@ -287,7 +287,7 @@ namespace MWScript
if (ptr.getContainerStore()) if (ptr.getContainerStore())
return; return;
if (ptr.getRefData().getHandle() == "player") if (ptr == MWBase::Environment::get().getWorld()->getPlayerPtr())
{ {
MWBase::Environment::get().getWorld()->getPlayer().setTeleported(true); MWBase::Environment::get().getWorld()->getPlayer().setTeleported(true);
} }
@ -352,7 +352,7 @@ namespace MWScript
if (!ptr.isInCell()) if (!ptr.isInCell())
return; return;
if (ptr.getRefData().getHandle() == "player") if (ptr == MWBase::Environment::get().getWorld()->getPlayerPtr())
{ {
MWBase::Environment::get().getWorld()->getPlayer().setTeleported(true); MWBase::Environment::get().getWorld()->getPlayer().setTeleported(true);
} }
@ -371,7 +371,7 @@ namespace MWScript
// another morrowind oddity: player will be moved to the exterior cell at this location, // another morrowind oddity: player will be moved to the exterior cell at this location,
// non-player actors will move within the cell they are in. // non-player actors will move within the cell they are in.
MWWorld::Ptr updated; MWWorld::Ptr updated;
if (ptr.getRefData().getHandle() == "player") if (ptr == MWBase::Environment::get().getWorld()->getPlayerPtr())
{ {
MWWorld::CellStore* cell = MWBase::Environment::get().getWorld()->getExterior(cx,cy); MWWorld::CellStore* cell = MWBase::Environment::get().getWorld()->getExterior(cx,cy);
MWBase::Environment::get().getWorld()->moveObject(ptr,cell,x,y,z); MWBase::Environment::get().getWorld()->moveObject(ptr,cell,x,y,z);

@ -477,7 +477,7 @@ namespace MWSound
while(snditer != mActiveSounds.end()) while(snditer != mActiveSounds.end())
{ {
if(snditer->second.first != MWWorld::Ptr() && if(snditer->second.first != MWWorld::Ptr() &&
snditer->second.first.getCellRef().getRefId() != "player" && snditer->second.first != MWBase::Environment::get().getWorld()->getPlayerPtr() &&
snditer->second.first.getCell() == cell) snditer->second.first.getCell() == cell)
{ {
snditer->first->stop(); snditer->first->stop();

@ -20,7 +20,7 @@ void MWWorld::Action::execute (const Ptr& actor)
{ {
if (!mSoundId.empty()) if (!mSoundId.empty())
{ {
if (mKeepSound && actor.getRefData().getHandle()=="player") if (mKeepSound && actor == MWBase::Environment::get().getWorld()->getPlayerPtr())
MWBase::Environment::get().getSoundManager()->playSound(mSoundId, 1.0, 1.0, MWBase::Environment::get().getSoundManager()->playSound(mSoundId, 1.0, 1.0,
MWBase::SoundManager::Play_TypeSfx, MWBase::SoundManager::Play_Normal,mSoundOffset); MWBase::SoundManager::Play_TypeSfx, MWBase::SoundManager::Play_Normal,mSoundOffset);
else else

@ -210,7 +210,7 @@ MWWorld::ContainerStoreIterator MWWorld::ContainerStore::add(const std::string &
{ {
MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), id, count); MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), id, count);
// a bit pointless to set owner for the player // a bit pointless to set owner for the player
if (actorPtr.getRefData().getHandle() != "player") if (actorPtr != MWBase::Environment::get().getWorld()->getPlayerPtr())
return add(ref.getPtr(), count, actorPtr, true); return add(ref.getPtr(), count, actorPtr, true);
else else
return add(ref.getPtr(), count, actorPtr, false); return add(ref.getPtr(), count, actorPtr, false);

@ -13,7 +13,7 @@ namespace MWWorld
void FailedAction::executeImp(const Ptr &actor) void FailedAction::executeImp(const Ptr &actor)
{ {
if(actor.getRefData().getHandle() == "player" && !mMessage.empty()) if(actor == MWBase::Environment::get().getWorld()->getPlayerPtr() && !mMessage.empty())
MWBase::Environment::get().getWindowManager()->messageBox(mMessage); MWBase::Environment::get().getWindowManager()->messageBox(mMessage);
} }
} }

@ -133,7 +133,7 @@ MWWorld::ContainerStoreIterator MWWorld::InventoryStore::add(const Ptr& itemPtr,
const MWWorld::ContainerStoreIterator& retVal = MWWorld::ContainerStore::add(itemPtr, count, actorPtr, setOwner); const MWWorld::ContainerStoreIterator& retVal = MWWorld::ContainerStore::add(itemPtr, count, actorPtr, setOwner);
// Auto-equip items if an armor/clothing or weapon item is added, but not for the player nor werewolves // Auto-equip items if an armor/clothing or weapon item is added, but not for the player nor werewolves
if (actorPtr.getRefData().getHandle() != "player" if (actorPtr != MWBase::Environment::get().getWorld()->getPlayerPtr()
&& !(actorPtr.getClass().isNpc() && actorPtr.getClass().getNpcStats(actorPtr).isWerewolf())) && !(actorPtr.getClass().isNpc() && actorPtr.getClass().getNpcStats(actorPtr).isWerewolf()))
{ {
std::string type = itemPtr.getTypeName(); std::string type = itemPtr.getTypeName();
@ -503,7 +503,7 @@ int MWWorld::InventoryStore::remove(const Ptr& item, int count, const Ptr& actor
// If an armor/clothing item is removed, try to find a replacement, // If an armor/clothing item is removed, try to find a replacement,
// but not for the player nor werewolves. // but not for the player nor werewolves.
if ((actor.getRefData().getHandle() != "player") if ((actor != MWBase::Environment::get().getWorld()->getPlayerPtr())
&& !(actor.getClass().isNpc() && actor.getClass().getNpcStats(actor).isWerewolf())) && !(actor.getClass().isNpc() && actor.getClass().getNpcStats(actor).isWerewolf()))
{ {
std::string type = item.getTypeName(); std::string type = item.getTypeName();
@ -535,7 +535,7 @@ MWWorld::ContainerStoreIterator MWWorld::InventoryStore::unequipSlot(int slot, c
{ {
retval = restack(*it); retval = restack(*it);
if (actor.getRefData().getHandle() == "player") if (actor == MWBase::Environment::get().getWorld()->getPlayerPtr())
{ {
// Unset OnPCEquip Variable on item's script, if it has a script with that variable declared // Unset OnPCEquip Variable on item's script, if it has a script with that variable declared
const std::string& script = it->getClass().getScript(*it); const std::string& script = it->getClass().getScript(*it);

@ -1406,7 +1406,7 @@ namespace MWWorld
PtrVelocityList::const_iterator player(results.end()); PtrVelocityList::const_iterator player(results.end());
for(PtrVelocityList::const_iterator iter(results.begin());iter != results.end();++iter) for(PtrVelocityList::const_iterator iter(results.begin());iter != results.end();++iter)
{ {
if(iter->first.getRefData().getHandle() == "player") if(iter->first == getPlayerPtr())
{ {
/* Handle player last, in case a cell transition occurs */ /* Handle player last, in case a cell transition occurs */
player = iter; player = iter;
@ -2228,7 +2228,7 @@ namespace MWWorld
if (healthPerSecond > 0.0f) if (healthPerSecond > 0.0f)
{ {
if (actor.getRefData().getHandle() == "player") if (actor == getPlayerPtr())
MWBase::Environment::get().getWindowManager()->activateHitOverlay(false); MWBase::Environment::get().getWindowManager()->activateHitOverlay(false);
if (!MWBase::Environment::get().getSoundManager()->getSoundPlaying(actor, "Health Damage")) if (!MWBase::Environment::get().getSoundManager()->getSoundPlaying(actor, "Health Damage"))
@ -2259,7 +2259,7 @@ namespace MWWorld
if (healthPerSecond > 0.0f) if (healthPerSecond > 0.0f)
{ {
if (actor.getRefData().getHandle() == "player") if (actor == getPlayerPtr())
MWBase::Environment::get().getWindowManager()->activateHitOverlay(false); MWBase::Environment::get().getWindowManager()->activateHitOverlay(false);
if (!MWBase::Environment::get().getSoundManager()->getSoundPlaying(actor, "Health Damage")) if (!MWBase::Environment::get().getSoundManager()->getSoundPlaying(actor, "Health Damage"))
@ -2516,7 +2516,7 @@ namespace MWWorld
// the following is just for reattaching the camera properly. // the following is just for reattaching the camera properly.
mRendering->rebuildPtr(actor); mRendering->rebuildPtr(actor);
if(actor.getRefData().getHandle() == "player") if(actor == getPlayerPtr())
{ {
// Update the GUI only when called on the player // Update the GUI only when called on the player
MWBase::WindowManager* windowManager = MWBase::Environment::get().getWindowManager(); MWBase::WindowManager* windowManager = MWBase::Environment::get().getWindowManager();
@ -3167,7 +3167,7 @@ namespace MWWorld
void World::spawnBloodEffect(const Ptr &ptr, const Vector3 &worldPosition) void World::spawnBloodEffect(const Ptr &ptr, const Vector3 &worldPosition)
{ {
if (ptr.getRefData().getHandle() == "player" && Settings::Manager::getBool("hit fader", "GUI")) if (ptr == getPlayerPtr() && Settings::Manager::getBool("hit fader", "GUI"))
return; return;
int type = ptr.getClass().getBloodTexture(ptr); int type = ptr.getClass().getBloodTexture(ptr);

Loading…
Cancel
Save