1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-02-03 22:45:35 +00:00

Fix broken isClass check and renamed variable for clarity

This commit is contained in:
scrawl 2014-05-09 18:45:49 +02:00
parent 6e9458c076
commit 731bc9c275

View file

@ -825,13 +825,13 @@ namespace MWMechanics
commitCrime(ptr, victim, OT_Theft, item.getClass().getValue(item) * count); commitCrime(ptr, victim, OT_Theft, item.getClass().getValue(item) * count);
} }
bool MechanicsManager::commitCrime(const MWWorld::Ptr &ptr, const MWWorld::Ptr &victim, OffenseType type, int arg) bool MechanicsManager::commitCrime(const MWWorld::Ptr &player, const MWWorld::Ptr &victim, OffenseType type, int arg)
{ {
// NOTE: int arg can be from itemTaken() so DON'T modify it, since it is // NOTE: int arg can be from itemTaken() so DON'T modify it, since it is
// passed to reportCrime later on in this function. // passed to reportCrime later on in this function.
// Only player can commit crime // Only player can commit crime
if (ptr.getRefData().getHandle() != "player") if (player.getRefData().getHandle() != "player")
return false; return false;
const MWWorld::ESMStore& esmStore = MWBase::Environment::get().getWorld()->getStore(); const MWWorld::ESMStore& esmStore = MWBase::Environment::get().getWorld()->getStore();
@ -856,7 +856,7 @@ namespace MWMechanics
// Find all the actors within the alarm radius // Find all the actors within the alarm radius
std::vector<MWWorld::Ptr> neighbors; std::vector<MWWorld::Ptr> neighbors;
mActors.getObjectsInRange(Ogre::Vector3(ptr.getRefData().getPosition().pos), mActors.getObjectsInRange(Ogre::Vector3(player.getRefData().getPosition().pos),
esmStore.get<ESM::GameSetting>().find("fAlarmRadius")->getInt(), neighbors); esmStore.get<ESM::GameSetting>().find("fAlarmRadius")->getInt(), neighbors);
int id = MWBase::Environment::get().getWorld()->getPlayer().getNewCrimeId(); int id = MWBase::Environment::get().getWorld()->getPlayer().getNewCrimeId();
@ -864,10 +864,10 @@ namespace MWMechanics
// Find actors who witnessed the crime // Find actors who witnessed the crime
for (std::vector<MWWorld::Ptr>::iterator it = neighbors.begin(); it != neighbors.end(); ++it) for (std::vector<MWWorld::Ptr>::iterator it = neighbors.begin(); it != neighbors.end(); ++it)
{ {
if (*it == ptr) continue; // not the player if (*it == player) continue; // not the player
// Was the crime seen? // Was the crime seen?
if (MWBase::Environment::get().getWorld()->getLOS(ptr, *it) && awarenessCheck(ptr, *it) ) if (MWBase::Environment::get().getWorld()->getLOS(player, *it) && awarenessCheck(player, *it) )
{ {
// TODO: Add more messages // TODO: Add more messages
if (type == OT_Theft) if (type == OT_Theft)
@ -881,8 +881,8 @@ namespace MWMechanics
// This applies to both NPCs and creatures // This applies to both NPCs and creatures
// ... except if this is a guard: then the player is given a chance to pay a fine / go to jail instead // ... except if this is a guard: then the player is given a chance to pay a fine / go to jail instead
if (type == OT_Assault && !ptr.getClass().isClass(ptr, "guard")) if (type == OT_Assault && !it->getClass().isClass(*it, "guard"))
MWBase::Environment::get().getMechanicsManager()->startCombat(victim, ptr); MWBase::Environment::get().getMechanicsManager()->startCombat(victim, player);
} }
// Crime reporting only applies to NPCs // Crime reporting only applies to NPCs
@ -897,7 +897,7 @@ namespace MWMechanics
// Tell everyone, including yourself // Tell everyone, including yourself
for (std::vector<MWWorld::Ptr>::iterator it1 = neighbors.begin(); it1 != neighbors.end(); ++it1) for (std::vector<MWWorld::Ptr>::iterator it1 = neighbors.begin(); it1 != neighbors.end(); ++it1)
{ {
if ( *it1 == ptr if ( *it1 == player
|| !it1->getClass().isNpc()) continue; // not the player and is an NPC || !it1->getClass().isNpc()) continue; // not the player and is an NPC
// Will other witnesses paticipate in crime // Will other witnesses paticipate in crime
@ -914,7 +914,7 @@ namespace MWMechanics
} }
} }
if (reported) if (reported)
reportCrime(ptr, victim, type, arg); reportCrime(player, victim, type, arg);
return reported; return reported;
} }