mirror of
https://github.com/OpenMW/openmw.git
synced 2025-06-24 10:41:34 +00:00
improves MWClass mapping (#3166)
Currently, we use a peculiar mapping of ESM classes by their std::type_info::name. This mapping is an undefined behaviour because std::type_info::name is strictly implementation defined. It could return a non-unique value on some platforms. With this PR we use the unsigned int sRecordId of the ESM class as a more efficient lookup type that does not build on undefined behaviour. We can expect marginally faster save-game loading with these changes as well.
This commit is contained in:
parent
98f8295765
commit
ef906cbfa8
64 changed files with 265 additions and 258 deletions
|
@ -89,7 +89,7 @@ namespace MWClass
|
|||
{
|
||||
std::shared_ptr<Class> instance (new Activator);
|
||||
|
||||
registerClass (typeid (ESM::Activator).name(), instance);
|
||||
registerClass (ESM::Activator::sRecordId, instance);
|
||||
}
|
||||
|
||||
bool Activator::hasToolTip (const MWWorld::ConstPtr& ptr) const
|
||||
|
|
|
@ -69,7 +69,7 @@ namespace MWClass
|
|||
{
|
||||
std::shared_ptr<Class> instance (new Apparatus);
|
||||
|
||||
registerClass (typeid (ESM::Apparatus).name(), instance);
|
||||
registerClass (ESM::Apparatus::sRecordId, instance);
|
||||
}
|
||||
|
||||
std::string Apparatus::getUpSoundId (const MWWorld::ConstPtr& ptr) const
|
||||
|
|
|
@ -163,7 +163,7 @@ namespace MWClass
|
|||
{
|
||||
std::shared_ptr<Class> instance (new Armor);
|
||||
|
||||
registerClass (typeid (ESM::Armor).name(), instance);
|
||||
registerClass (ESM::Armor::sRecordId, instance);
|
||||
}
|
||||
|
||||
std::string Armor::getUpSoundId (const MWWorld::ConstPtr& ptr) const
|
||||
|
@ -322,7 +322,7 @@ namespace MWClass
|
|||
if(*slot == MWWorld::InventoryStore::Slot_CarriedLeft)
|
||||
{
|
||||
MWWorld::ConstContainerStoreIterator weapon = invStore.getSlot(MWWorld::InventoryStore::Slot_CarriedRight);
|
||||
if(weapon != invStore.end() && weapon->getTypeName() == typeid(ESM::Weapon).name())
|
||||
if(weapon != invStore.end() && weapon->getType() == ESM::Weapon::sRecordId)
|
||||
{
|
||||
const MWWorld::LiveCellRef<ESM::Weapon> *ref = weapon->get<ESM::Weapon>();
|
||||
if (MWMechanics::getWeaponType(ref->mBase->mData.mType)->mFlags & ESM::WeaponType::TwoHanded)
|
||||
|
|
|
@ -36,7 +36,7 @@ namespace MWClass
|
|||
{
|
||||
std::shared_ptr<MWWorld::Class> instance (new BodyPart);
|
||||
|
||||
registerClass (typeid (ESM::BodyPart).name(), instance);
|
||||
registerClass (ESM::BodyPart::sRecordId, instance);
|
||||
}
|
||||
|
||||
std::string BodyPart::getModel(const MWWorld::ConstPtr &ptr) const
|
||||
|
|
|
@ -85,7 +85,7 @@ namespace MWClass
|
|||
{
|
||||
std::shared_ptr<Class> instance (new Book);
|
||||
|
||||
registerClass (typeid (ESM::Book).name(), instance);
|
||||
registerClass (ESM::Book::sRecordId, instance);
|
||||
}
|
||||
|
||||
std::string Book::getUpSoundId (const MWWorld::ConstPtr& ptr) const
|
||||
|
|
|
@ -121,7 +121,7 @@ namespace MWClass
|
|||
{
|
||||
std::shared_ptr<Class> instance (new Clothing);
|
||||
|
||||
registerClass (typeid (ESM::Clothing).name(), instance);
|
||||
registerClass (ESM::Clothing::sRecordId, instance);
|
||||
}
|
||||
|
||||
std::string Clothing::getUpSoundId (const MWWorld::ConstPtr& ptr) const
|
||||
|
|
|
@ -242,7 +242,7 @@ namespace MWClass
|
|||
{
|
||||
std::shared_ptr<Class> instance (new Container);
|
||||
|
||||
registerClass (typeid (ESM::Container).name(), instance);
|
||||
registerClass (ESM::Container::sRecordId, instance);
|
||||
}
|
||||
|
||||
bool Container::hasToolTip (const MWWorld::ConstPtr& ptr) const
|
||||
|
|
|
@ -238,7 +238,7 @@ namespace MWClass
|
|||
{
|
||||
MWWorld::InventoryStore &inv = getInventoryStore(ptr);
|
||||
MWWorld::ContainerStoreIterator weaponslot = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedRight);
|
||||
if (weaponslot != inv.end() && weaponslot->getTypeName() == typeid(ESM::Weapon).name())
|
||||
if (weaponslot != inv.end() && weaponslot->getType() == ESM::Weapon::sRecordId)
|
||||
weapon = *weaponslot;
|
||||
}
|
||||
|
||||
|
@ -497,7 +497,7 @@ namespace MWClass
|
|||
{
|
||||
std::shared_ptr<Class> instance (new Creature);
|
||||
|
||||
registerClass (typeid (ESM::Creature).name(), instance);
|
||||
registerClass (ESM::Creature::sRecordId, instance);
|
||||
}
|
||||
|
||||
float Creature::getMaxSpeed(const MWWorld::Ptr &ptr) const
|
||||
|
|
|
@ -70,7 +70,7 @@ namespace MWClass
|
|||
{
|
||||
std::shared_ptr<Class> instance (new CreatureLevList);
|
||||
|
||||
registerClass (typeid (ESM::CreatureLevList).name(), instance);
|
||||
registerClass (ESM::CreatureLevList::sRecordId, instance);
|
||||
}
|
||||
|
||||
void CreatureLevList::getModelsToPreload(const MWWorld::Ptr &ptr, std::vector<std::string> &models) const
|
||||
|
|
|
@ -264,7 +264,7 @@ namespace MWClass
|
|||
{
|
||||
std::shared_ptr<Class> instance (new Door);
|
||||
|
||||
registerClass (typeid (ESM::Door).name(), instance);
|
||||
registerClass (ESM::Door::sRecordId, instance);
|
||||
}
|
||||
|
||||
MWGui::ToolTipInfo Door::getToolTipInfo (const MWWorld::ConstPtr& ptr, int count) const
|
||||
|
|
|
@ -81,7 +81,7 @@ namespace MWClass
|
|||
{
|
||||
std::shared_ptr<Class> instance (new Ingredient);
|
||||
|
||||
registerClass (typeid (ESM::Ingredient).name(), instance);
|
||||
registerClass (ESM::Ingredient::sRecordId, instance);
|
||||
}
|
||||
|
||||
std::string Ingredient::getUpSoundId (const MWWorld::ConstPtr& ptr) const
|
||||
|
|
|
@ -19,6 +19,6 @@ namespace MWClass
|
|||
{
|
||||
std::shared_ptr<Class> instance (new ItemLevList);
|
||||
|
||||
registerClass (typeid (ESM::ItemLevList).name(), instance);
|
||||
registerClass (ESM::ItemLevList::sRecordId, instance);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -124,7 +124,7 @@ namespace MWClass
|
|||
{
|
||||
std::shared_ptr<Class> instance (new Light);
|
||||
|
||||
registerClass (typeid (ESM::Light).name(), instance);
|
||||
registerClass (ESM::Light::sRecordId, instance);
|
||||
}
|
||||
|
||||
std::string Light::getUpSoundId (const MWWorld::ConstPtr& ptr) const
|
||||
|
|
|
@ -80,7 +80,7 @@ namespace MWClass
|
|||
{
|
||||
std::shared_ptr<Class> instance (new Lockpick);
|
||||
|
||||
registerClass (typeid (ESM::Lockpick).name(), instance);
|
||||
registerClass (ESM::Lockpick::sRecordId, instance);
|
||||
}
|
||||
|
||||
std::string Lockpick::getUpSoundId (const MWWorld::ConstPtr& ptr) const
|
||||
|
|
|
@ -106,7 +106,7 @@ namespace MWClass
|
|||
{
|
||||
std::shared_ptr<Class> instance (new Miscellaneous);
|
||||
|
||||
registerClass (typeid (ESM::Miscellaneous).name(), instance);
|
||||
registerClass (ESM::Miscellaneous::sRecordId, instance);
|
||||
}
|
||||
|
||||
std::string Miscellaneous::getUpSoundId (const MWWorld::ConstPtr& ptr) const
|
||||
|
|
|
@ -459,12 +459,12 @@ namespace MWClass
|
|||
if (equipped != invStore.end())
|
||||
{
|
||||
std::vector<ESM::PartReference> parts;
|
||||
if(equipped->getTypeName() == typeid(ESM::Clothing).name())
|
||||
if(equipped->getType() == ESM::Clothing::sRecordId)
|
||||
{
|
||||
const ESM::Clothing *clothes = equipped->get<ESM::Clothing>()->mBase;
|
||||
parts = clothes->mParts.mParts;
|
||||
}
|
||||
else if(equipped->getTypeName() == typeid(ESM::Armor).name())
|
||||
else if(equipped->getType() == ESM::Armor::sRecordId)
|
||||
{
|
||||
const ESM::Armor *armor = equipped->get<ESM::Armor>()->mBase;
|
||||
parts = armor->mParts.mParts;
|
||||
|
@ -543,7 +543,7 @@ namespace MWClass
|
|||
MWWorld::InventoryStore &inv = getInventoryStore(ptr);
|
||||
MWWorld::ContainerStoreIterator weaponslot = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedRight);
|
||||
MWWorld::Ptr weapon = ((weaponslot != inv.end()) ? *weaponslot : MWWorld::Ptr());
|
||||
if(!weapon.isEmpty() && weapon.getTypeName() != typeid(ESM::Weapon).name())
|
||||
if(!weapon.isEmpty() && weapon.getType() != ESM::Weapon::sRecordId)
|
||||
weapon = MWWorld::Ptr();
|
||||
|
||||
MWMechanics::applyFatigueLoss(ptr, weapon, attackStrength);
|
||||
|
@ -766,7 +766,7 @@ namespace MWClass
|
|||
MWWorld::InventoryStore &inv = getInventoryStore(ptr);
|
||||
MWWorld::ContainerStoreIterator armorslot = inv.getSlot(hitslot);
|
||||
MWWorld::Ptr armor = ((armorslot != inv.end()) ? *armorslot : MWWorld::Ptr());
|
||||
bool hasArmor = !armor.isEmpty() && armor.getTypeName() == typeid(ESM::Armor).name();
|
||||
bool hasArmor = !armor.isEmpty() && armor.getType() == ESM::Armor::sRecordId;
|
||||
// If there's no item in the carried left slot or if it is not a shield redistribute the hit.
|
||||
if (!hasArmor && hitslot == MWWorld::InventoryStore::Slot_CarriedLeft)
|
||||
{
|
||||
|
@ -778,7 +778,7 @@ namespace MWClass
|
|||
if (armorslot != inv.end())
|
||||
{
|
||||
armor = *armorslot;
|
||||
hasArmor = !armor.isEmpty() && armor.getTypeName() == typeid(ESM::Armor).name();
|
||||
hasArmor = !armor.isEmpty() && armor.getType() == ESM::Armor::sRecordId;
|
||||
}
|
||||
}
|
||||
if (hasArmor)
|
||||
|
@ -1036,7 +1036,7 @@ namespace MWClass
|
|||
void Npc::registerSelf()
|
||||
{
|
||||
std::shared_ptr<Class> instance (new Npc);
|
||||
registerClass (typeid (ESM::NPC).name(), instance);
|
||||
registerClass (ESM::NPC::sRecordId, instance);
|
||||
}
|
||||
|
||||
bool Npc::hasToolTip(const MWWorld::ConstPtr& ptr) const
|
||||
|
@ -1135,7 +1135,7 @@ namespace MWClass
|
|||
for(int i = 0;i < MWWorld::InventoryStore::Slots;i++)
|
||||
{
|
||||
MWWorld::ConstContainerStoreIterator it = invStore.getSlot(i);
|
||||
if (it == invStore.end() || it->getTypeName() != typeid(ESM::Armor).name())
|
||||
if (it == invStore.end() || it->getType() != ESM::Armor::sRecordId)
|
||||
{
|
||||
// unarmored
|
||||
ratings[i] = (fUnarmoredBase1 * unarmoredSkill) * (fUnarmoredBase2 * unarmoredSkill);
|
||||
|
@ -1232,7 +1232,7 @@ namespace MWClass
|
|||
|
||||
const MWWorld::InventoryStore &inv = Npc::getInventoryStore(ptr);
|
||||
MWWorld::ConstContainerStoreIterator boots = inv.getSlot(MWWorld::InventoryStore::Slot_Boots);
|
||||
if(boots == inv.end() || boots->getTypeName() != typeid(ESM::Armor).name())
|
||||
if(boots == inv.end() || boots->getType() != ESM::Armor::sRecordId)
|
||||
return (name == "left") ? "FootBareLeft" : "FootBareRight";
|
||||
|
||||
switch(boots->getClass().getEquipmentSkill(*boots))
|
||||
|
|
|
@ -74,7 +74,7 @@ namespace MWClass
|
|||
{
|
||||
std::shared_ptr<Class> instance (new Potion);
|
||||
|
||||
registerClass (typeid (ESM::Potion).name(), instance);
|
||||
registerClass (ESM::Potion::sRecordId, instance);
|
||||
}
|
||||
|
||||
std::string Potion::getUpSoundId (const MWWorld::ConstPtr& ptr) const
|
||||
|
|
|
@ -80,7 +80,7 @@ namespace MWClass
|
|||
{
|
||||
std::shared_ptr<Class> instance (new Probe);
|
||||
|
||||
registerClass (typeid (ESM::Probe).name(), instance);
|
||||
registerClass (ESM::Probe::sRecordId, instance);
|
||||
}
|
||||
|
||||
std::string Probe::getUpSoundId (const MWWorld::ConstPtr& ptr) const
|
||||
|
|
|
@ -69,7 +69,7 @@ namespace MWClass
|
|||
{
|
||||
std::shared_ptr<Class> instance (new Repair);
|
||||
|
||||
registerClass (typeid (ESM::Repair).name(), instance);
|
||||
registerClass (ESM::Repair::sRecordId, instance);
|
||||
}
|
||||
|
||||
std::string Repair::getUpSoundId (const MWWorld::ConstPtr& ptr) const
|
||||
|
|
|
@ -59,7 +59,7 @@ namespace MWClass
|
|||
{
|
||||
std::shared_ptr<Class> instance (new Static);
|
||||
|
||||
registerClass (typeid (ESM::Static).name(), instance);
|
||||
registerClass (ESM::Static::sRecordId, instance);
|
||||
}
|
||||
|
||||
MWWorld::Ptr Static::copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const
|
||||
|
|
|
@ -125,7 +125,7 @@ namespace MWClass
|
|||
{
|
||||
std::shared_ptr<Class> instance (new Weapon);
|
||||
|
||||
registerClass (typeid (ESM::Weapon).name(), instance);
|
||||
registerClass (ESM::Weapon::sRecordId, instance);
|
||||
}
|
||||
|
||||
std::string Weapon::getUpSoundId (const MWWorld::ConstPtr& ptr) const
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
bool MWDialogue::Filter::testActor (const ESM::DialInfo& info) const
|
||||
{
|
||||
bool isCreature = (mActor.getTypeName() != typeid (ESM::NPC).name());
|
||||
bool isCreature = (mActor.getType() != ESM::NPC::sRecordId);
|
||||
|
||||
// actor id
|
||||
if (!info.mActor.empty())
|
||||
|
@ -160,7 +160,7 @@ bool MWDialogue::Filter::testSelectStructs (const ESM::DialInfo& info) const
|
|||
|
||||
bool MWDialogue::Filter::testDisposition (const ESM::DialInfo& info, bool invert) const
|
||||
{
|
||||
bool isCreature = (mActor.getTypeName() != typeid (ESM::NPC).name());
|
||||
bool isCreature = (mActor.getType() != ESM::NPC::sRecordId);
|
||||
|
||||
if (isCreature)
|
||||
return true;
|
||||
|
@ -207,7 +207,7 @@ bool MWDialogue::Filter::testFunctionLocal(const MWDialogue::SelectWrapper& sele
|
|||
|
||||
bool MWDialogue::Filter::testSelectStruct (const SelectWrapper& select) const
|
||||
{
|
||||
if (select.isNpcOnly() && (mActor.getTypeName() != typeid (ESM::NPC).name()))
|
||||
if (select.isNpcOnly() && (mActor.getType() != ESM::NPC::sRecordId))
|
||||
// If the actor is a creature, we pass all conditions only applicable to NPCs.
|
||||
return true;
|
||||
|
||||
|
@ -452,7 +452,7 @@ int MWDialogue::Filter::getSelectStructInteger (const SelectWrapper& select) con
|
|||
{
|
||||
if (target.getClass().isNpc() && target.getClass().getNpcStats(target).isWerewolf())
|
||||
return 2;
|
||||
if (target.getTypeName() == typeid(ESM::Creature).name())
|
||||
if (target.getType() == ESM::Creature::sRecordId)
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -194,7 +194,7 @@ namespace MWGui
|
|||
for (size_t i = 0; i < mModel->getItemCount(); ++i)
|
||||
{
|
||||
MWWorld::Ptr item = mModel->getItem(i).mBase;
|
||||
if (item.getTypeName() != typeid(ESM::Ingredient).name())
|
||||
if (item.getType() != ESM::Ingredient::sRecordId)
|
||||
continue;
|
||||
|
||||
itemNames.insert(item.getClass().getName(item));
|
||||
|
|
|
@ -209,7 +209,7 @@ bool ContainerItemModel::onDropItem(const MWWorld::Ptr &item, int count)
|
|||
|
||||
MWWorld::Ptr target = mItemSources[0].first;
|
||||
|
||||
if (target.getTypeName() != typeid(ESM::Container).name())
|
||||
if (target.getType() != ESM::Container::sRecordId)
|
||||
return true;
|
||||
|
||||
// check container organic flag
|
||||
|
|
|
@ -508,13 +508,13 @@ namespace MWGui
|
|||
|
||||
int services = mPtr.getClass().getServices(mPtr);
|
||||
|
||||
bool travel = (mPtr.getTypeName() == typeid(ESM::NPC).name() && !mPtr.get<ESM::NPC>()->mBase->getTransport().empty())
|
||||
|| (mPtr.getTypeName() == typeid(ESM::Creature).name() && !mPtr.get<ESM::Creature>()->mBase->getTransport().empty());
|
||||
bool travel = (mPtr.getType() == ESM::NPC::sRecordId && !mPtr.get<ESM::NPC>()->mBase->getTransport().empty())
|
||||
|| (mPtr.getType() == ESM::Creature::sRecordId && !mPtr.get<ESM::Creature>()->mBase->getTransport().empty());
|
||||
|
||||
const MWWorld::Store<ESM::GameSetting> &gmst =
|
||||
MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
|
||||
|
||||
if (mPtr.getTypeName() == typeid(ESM::NPC).name())
|
||||
if (mPtr.getType() == ESM::NPC::sRecordId)
|
||||
mTopicsList->addItem(gmst.find("sPersuasion")->mValue.getString());
|
||||
|
||||
if (services & ESM::NPC::AllItems)
|
||||
|
|
|
@ -46,7 +46,7 @@ namespace
|
|||
|
||||
bool isRightHandWeapon(const MWWorld::Ptr& item)
|
||||
{
|
||||
if (item.getClass().getTypeName() != typeid(ESM::Weapon).name())
|
||||
if (item.getClass().getType() != ESM::Weapon::sRecordId)
|
||||
return false;
|
||||
std::vector<int> equipmentSlots = item.getClass().getEquipmentSlots(item).first;
|
||||
return (!equipmentSlots.empty() && equipmentSlots.front() == MWWorld::InventoryStore::Slot_CarriedRight);
|
||||
|
@ -281,7 +281,7 @@ namespace MWGui
|
|||
// If we unequip weapon during attack, it can lead to unexpected behaviour
|
||||
if (MWBase::Environment::get().getMechanicsManager()->isAttackingOrSpell(mPtr))
|
||||
{
|
||||
bool isWeapon = item.mBase.getTypeName() == typeid(ESM::Weapon).name();
|
||||
bool isWeapon = item.mBase.getType() == ESM::Weapon::sRecordId;
|
||||
MWWorld::InventoryStore& invStore = mPtr.getClass().getInventoryStore(mPtr);
|
||||
|
||||
if (isWeapon && invStore.isEquipped(item.mBase))
|
||||
|
@ -555,9 +555,9 @@ namespace MWGui
|
|||
if (!script.empty())
|
||||
{
|
||||
// Ingredients, books and repair hammers must not have OnPCEquip set to 1 here
|
||||
const std::string& type = ptr.getTypeName();
|
||||
bool isBook = type == typeid(ESM::Book).name();
|
||||
if (!isBook && type != typeid(ESM::Ingredient).name() && type != typeid(ESM::Repair).name())
|
||||
auto type = ptr.getType();
|
||||
bool isBook = type == ESM::Book::sRecordId;
|
||||
if (!isBook && type != ESM::Ingredient::sRecordId && type != ESM::Repair::sRecordId)
|
||||
ptr.getRefData().getLocals().setVarByInt(script, "onpcequip", 1);
|
||||
// Books must have PCSkipEquip set to 1 instead
|
||||
else if (isBook)
|
||||
|
@ -593,8 +593,8 @@ namespace MWGui
|
|||
useItem(ptr);
|
||||
|
||||
// If item is ingredient or potion don't stop drag and drop to simplify action of taking more than one 1 item
|
||||
if ((ptr.getTypeName() == typeid(ESM::Potion).name() ||
|
||||
ptr.getTypeName() == typeid(ESM::Ingredient).name())
|
||||
if ((ptr.getType() == ESM::Potion::sRecordId ||
|
||||
ptr.getType() == ESM::Ingredient::sRecordId)
|
||||
&& mDragAndDrop->mDraggedCount > 1)
|
||||
{
|
||||
// Item can be provided from other window for example container.
|
||||
|
@ -704,19 +704,19 @@ namespace MWGui
|
|||
if (!MWBase::Environment::get().getWindowManager()->isAllowed(GW_Inventory))
|
||||
return;
|
||||
// make sure the object is of a type that can be picked up
|
||||
const std::string& type = object.getTypeName();
|
||||
if ( (type != typeid(ESM::Apparatus).name())
|
||||
&& (type != typeid(ESM::Armor).name())
|
||||
&& (type != typeid(ESM::Book).name())
|
||||
&& (type != typeid(ESM::Clothing).name())
|
||||
&& (type != typeid(ESM::Ingredient).name())
|
||||
&& (type != typeid(ESM::Light).name())
|
||||
&& (type != typeid(ESM::Miscellaneous).name())
|
||||
&& (type != typeid(ESM::Lockpick).name())
|
||||
&& (type != typeid(ESM::Probe).name())
|
||||
&& (type != typeid(ESM::Repair).name())
|
||||
&& (type != typeid(ESM::Weapon).name())
|
||||
&& (type != typeid(ESM::Potion).name()))
|
||||
auto type = object.getType();
|
||||
if ( (type != ESM::Apparatus::sRecordId)
|
||||
&& (type != ESM::Armor::sRecordId)
|
||||
&& (type != ESM::Book::sRecordId)
|
||||
&& (type != ESM::Clothing::sRecordId)
|
||||
&& (type != ESM::Ingredient::sRecordId)
|
||||
&& (type != ESM::Light::sRecordId)
|
||||
&& (type != ESM::Miscellaneous::sRecordId)
|
||||
&& (type != ESM::Lockpick::sRecordId)
|
||||
&& (type != ESM::Probe::sRecordId)
|
||||
&& (type != ESM::Repair::sRecordId)
|
||||
&& (type != ESM::Weapon::sRecordId)
|
||||
&& (type != ESM::Potion::sRecordId))
|
||||
return;
|
||||
|
||||
// An object that can be picked up must have a tooltip.
|
||||
|
@ -809,7 +809,7 @@ namespace MWGui
|
|||
|
||||
lastId = item.getCellRef().getRefId();
|
||||
|
||||
if (item.getClass().getTypeName() == typeid(ESM::Weapon).name() &&
|
||||
if (item.getClass().getType() == ESM::Weapon::sRecordId &&
|
||||
isRightHandWeapon(item) &&
|
||||
item.getClass().canBeEquipped(item, player).first)
|
||||
{
|
||||
|
|
|
@ -387,9 +387,9 @@ namespace MWGui
|
|||
|
||||
if (key->type == Type_Item)
|
||||
{
|
||||
bool isWeapon = item.getTypeName() == typeid(ESM::Weapon).name();
|
||||
bool isTool = item.getTypeName() == typeid(ESM::Probe).name() ||
|
||||
item.getTypeName() == typeid(ESM::Lockpick).name();
|
||||
bool isWeapon = item.getType() == ESM::Weapon::sRecordId;
|
||||
bool isTool = item.getType() == ESM::Probe::sRecordId ||
|
||||
item.getType() == ESM::Lockpick::sRecordId;
|
||||
|
||||
// delay weapon switching if player is busy
|
||||
if (isDelayNeeded && (isWeapon || isTool))
|
||||
|
|
|
@ -27,22 +27,22 @@
|
|||
|
||||
namespace
|
||||
{
|
||||
bool compareType(const std::string& type1, const std::string& type2)
|
||||
bool compareType(unsigned int type1, unsigned int type2)
|
||||
{
|
||||
// this defines the sorting order of types. types that are first in the vector appear before other types.
|
||||
std::vector<std::string> mapping;
|
||||
mapping.emplace_back(typeid(ESM::Weapon).name() );
|
||||
mapping.emplace_back(typeid(ESM::Armor).name() );
|
||||
mapping.emplace_back(typeid(ESM::Clothing).name() );
|
||||
mapping.emplace_back(typeid(ESM::Potion).name() );
|
||||
mapping.emplace_back(typeid(ESM::Ingredient).name() );
|
||||
mapping.emplace_back(typeid(ESM::Apparatus).name() );
|
||||
mapping.emplace_back(typeid(ESM::Book).name() );
|
||||
mapping.emplace_back(typeid(ESM::Light).name() );
|
||||
mapping.emplace_back(typeid(ESM::Miscellaneous).name() );
|
||||
mapping.emplace_back(typeid(ESM::Lockpick).name() );
|
||||
mapping.emplace_back(typeid(ESM::Repair).name() );
|
||||
mapping.emplace_back(typeid(ESM::Probe).name() );
|
||||
std::vector<unsigned int> mapping;
|
||||
mapping.emplace_back(ESM::Weapon::sRecordId );
|
||||
mapping.emplace_back(ESM::Armor::sRecordId );
|
||||
mapping.emplace_back(ESM::Clothing::sRecordId );
|
||||
mapping.emplace_back(ESM::Potion::sRecordId );
|
||||
mapping.emplace_back(ESM::Ingredient::sRecordId );
|
||||
mapping.emplace_back(ESM::Apparatus::sRecordId );
|
||||
mapping.emplace_back(ESM::Book::sRecordId );
|
||||
mapping.emplace_back(ESM::Light::sRecordId );
|
||||
mapping.emplace_back(ESM::Miscellaneous::sRecordId );
|
||||
mapping.emplace_back(ESM::Lockpick::sRecordId );
|
||||
mapping.emplace_back(ESM::Repair::sRecordId );
|
||||
mapping.emplace_back(ESM::Probe::sRecordId );
|
||||
|
||||
assert( std::find(mapping.begin(), mapping.end(), type1) != mapping.end() );
|
||||
assert( std::find(mapping.begin(), mapping.end(), type2) != mapping.end() );
|
||||
|
@ -62,15 +62,15 @@ namespace
|
|||
float result = 0;
|
||||
|
||||
// compare items by type
|
||||
std::string leftName = left.mBase.getTypeName();
|
||||
std::string rightName = right.mBase.getTypeName();
|
||||
auto leftType = left.mBase.getType();
|
||||
auto rightType = right.mBase.getType();
|
||||
|
||||
if (leftName != rightName)
|
||||
return compareType(leftName, rightName);
|
||||
if (leftType != rightType)
|
||||
return compareType(leftType, rightType);
|
||||
|
||||
// compare items by name
|
||||
leftName = Misc::StringUtils::lowerCaseUtf8(left.mBase.getClass().getName(left.mBase));
|
||||
rightName = Misc::StringUtils::lowerCaseUtf8(right.mBase.getClass().getName(right.mBase));
|
||||
std::string leftName = Misc::StringUtils::lowerCaseUtf8(left.mBase.getClass().getName(left.mBase));
|
||||
std::string rightName = Misc::StringUtils::lowerCaseUtf8(right.mBase.getClass().getName(right.mBase));
|
||||
|
||||
result = leftName.compare(rightName);
|
||||
if (result != 0)
|
||||
|
@ -179,22 +179,22 @@ namespace MWGui
|
|||
MWWorld::Ptr base = item.mBase;
|
||||
|
||||
int category = 0;
|
||||
if (base.getTypeName() == typeid(ESM::Armor).name()
|
||||
|| base.getTypeName() == typeid(ESM::Clothing).name())
|
||||
if (base.getType() == ESM::Armor::sRecordId
|
||||
|| base.getType() == ESM::Clothing::sRecordId)
|
||||
category = Category_Apparel;
|
||||
else if (base.getTypeName() == typeid(ESM::Weapon).name())
|
||||
else if (base.getType() == ESM::Weapon::sRecordId)
|
||||
category = Category_Weapon;
|
||||
else if (base.getTypeName() == typeid(ESM::Ingredient).name()
|
||||
|| base.getTypeName() == typeid(ESM::Potion).name())
|
||||
else if (base.getType() == ESM::Ingredient::sRecordId
|
||||
|| base.getType() == ESM::Potion::sRecordId)
|
||||
category = Category_Magic;
|
||||
else if (base.getTypeName() == typeid(ESM::Miscellaneous).name()
|
||||
|| base.getTypeName() == typeid(ESM::Ingredient).name()
|
||||
|| base.getTypeName() == typeid(ESM::Repair).name()
|
||||
|| base.getTypeName() == typeid(ESM::Lockpick).name()
|
||||
|| base.getTypeName() == typeid(ESM::Light).name()
|
||||
|| base.getTypeName() == typeid(ESM::Apparatus).name()
|
||||
|| base.getTypeName() == typeid(ESM::Book).name()
|
||||
|| base.getTypeName() == typeid(ESM::Probe).name())
|
||||
else if (base.getType() == ESM::Miscellaneous::sRecordId
|
||||
|| base.getType() == ESM::Ingredient::sRecordId
|
||||
|| base.getType() == ESM::Repair::sRecordId
|
||||
|| base.getType() == ESM::Lockpick::sRecordId
|
||||
|| base.getType() == ESM::Light::sRecordId
|
||||
|| base.getType() == ESM::Apparatus::sRecordId
|
||||
|| base.getType() == ESM::Book::sRecordId
|
||||
|| base.getType() == ESM::Probe::sRecordId)
|
||||
category = Category_Misc;
|
||||
|
||||
if (item.mFlags & ItemStack::Flag_Enchanted)
|
||||
|
@ -205,7 +205,7 @@ namespace MWGui
|
|||
|
||||
if (mFilter & Filter_OnlyIngredients)
|
||||
{
|
||||
if (base.getTypeName() != typeid(ESM::Ingredient).name())
|
||||
if (base.getType() != ESM::Ingredient::sRecordId)
|
||||
return false;
|
||||
|
||||
if (!mNameFilter.empty() && !mEffectFilter.empty())
|
||||
|
@ -238,18 +238,18 @@ namespace MWGui
|
|||
|
||||
if ((mFilter & Filter_OnlyEnchanted) && !(item.mFlags & ItemStack::Flag_Enchanted))
|
||||
return false;
|
||||
if ((mFilter & Filter_OnlyChargedSoulstones) && (base.getTypeName() != typeid(ESM::Miscellaneous).name()
|
||||
if ((mFilter & Filter_OnlyChargedSoulstones) && (base.getType() != ESM::Miscellaneous::sRecordId
|
||||
|| base.getCellRef().getSoul() == "" || !MWBase::Environment::get().getWorld()->getStore().get<ESM::Creature>().search(base.getCellRef().getSoul())))
|
||||
return false;
|
||||
if ((mFilter & Filter_OnlyRepairTools) && (base.getTypeName() != typeid(ESM::Repair).name()))
|
||||
if ((mFilter & Filter_OnlyRepairTools) && (base.getType() != ESM::Repair::sRecordId))
|
||||
return false;
|
||||
if ((mFilter & Filter_OnlyEnchantable) && (item.mFlags & ItemStack::Flag_Enchanted
|
||||
|| (base.getTypeName() != typeid(ESM::Armor).name()
|
||||
&& base.getTypeName() != typeid(ESM::Clothing).name()
|
||||
&& base.getTypeName() != typeid(ESM::Weapon).name()
|
||||
&& base.getTypeName() != typeid(ESM::Book).name())))
|
||||
|| (base.getType() != ESM::Armor::sRecordId
|
||||
&& base.getType() != ESM::Clothing::sRecordId
|
||||
&& base.getType() != ESM::Weapon::sRecordId
|
||||
&& base.getType() != ESM::Book::sRecordId)))
|
||||
return false;
|
||||
if ((mFilter & Filter_OnlyEnchantable) && base.getTypeName() == typeid(ESM::Book).name()
|
||||
if ((mFilter & Filter_OnlyEnchantable) && base.getType() == ESM::Book::sRecordId
|
||||
&& !base.get<ESM::Book>()->mBase->mData.mIsScroll)
|
||||
return false;
|
||||
|
||||
|
@ -263,8 +263,8 @@ namespace MWGui
|
|||
if ((mFilter & Filter_OnlyRepairable) && (
|
||||
!base.getClass().hasItemHealth(base)
|
||||
|| (base.getClass().getItemHealth(base) == base.getClass().getItemMaxHealth(base))
|
||||
|| (base.getTypeName() != typeid(ESM::Weapon).name()
|
||||
&& base.getTypeName() != typeid(ESM::Armor).name())))
|
||||
|| (base.getType() != ESM::Weapon::sRecordId
|
||||
&& base.getType() != ESM::Armor::sRecordId)))
|
||||
return false;
|
||||
|
||||
if (mFilter & Filter_OnlyRechargable)
|
||||
|
|
|
@ -115,7 +115,7 @@ namespace MWGui
|
|||
std::vector<ESM::Transport::Dest> transport;
|
||||
if (mPtr.getClass().isNpc())
|
||||
transport = mPtr.get<ESM::NPC>()->mBase->getTransport();
|
||||
else if (mPtr.getTypeName() == typeid(ESM::Creature).name())
|
||||
else if (mPtr.getType() == ESM::Creature::sRecordId)
|
||||
transport = mPtr.get<ESM::Creature>()->mBase->getTransport();
|
||||
|
||||
for(unsigned int i = 0;i<transport.size();i++)
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace MWLua
|
|||
return std::to_string(id.mIndex) + "_" + std::to_string(id.mContentFile);
|
||||
}
|
||||
|
||||
const static std::map<std::type_index, std::string_view> classNames = {
|
||||
const static std::map<std::type_index, std::string> classNames = {
|
||||
{typeid(MWClass::Activator), "Activator"},
|
||||
{typeid(MWClass::Armor), "Armor"},
|
||||
{typeid(MWClass::Book), "Book"},
|
||||
|
@ -40,7 +40,7 @@ namespace MWLua
|
|||
{typeid(MWClass::Weapon), "Weapon"},
|
||||
};
|
||||
|
||||
std::string_view getMWClassName(const std::type_index& cls_type, std::string_view fallback)
|
||||
std::string getMWClassName(const std::type_index& cls_type, std::string fallback)
|
||||
{
|
||||
auto it = classNames.find(cls_type);
|
||||
if (it != classNames.end())
|
||||
|
@ -55,13 +55,13 @@ namespace MWLua
|
|||
return id == "prisonmarker" || id == "divinemarker" || id == "templemarker" || id == "northmarker";
|
||||
}
|
||||
|
||||
std::string_view getMWClassName(const MWWorld::Ptr& ptr)
|
||||
std::string getMWClassName(const MWWorld::Ptr& ptr)
|
||||
{
|
||||
if (ptr.getCellRef().getRefIdRef() == "player")
|
||||
return "Player";
|
||||
if (isMarker(ptr))
|
||||
return "Marker";
|
||||
return getMWClassName(typeid(ptr.getClass()), ptr.getTypeName());
|
||||
return ptr.getTypeDescription();
|
||||
}
|
||||
|
||||
std::string ptrToString(const MWWorld::Ptr& ptr)
|
||||
|
|
|
@ -19,8 +19,8 @@ namespace MWLua
|
|||
std::string idToString(const ObjectId& id);
|
||||
std::string ptrToString(const MWWorld::Ptr& ptr);
|
||||
bool isMarker(const MWWorld::Ptr& ptr);
|
||||
std::string_view getMWClassName(const std::type_index& cls_type, std::string_view fallback = "Unknown");
|
||||
std::string_view getMWClassName(const MWWorld::Ptr& ptr);
|
||||
std::string getMWClassName(const std::type_index& cls_type, std::string fallback = "Unknown");
|
||||
std::string getMWClassName(const MWWorld::Ptr& ptr);
|
||||
|
||||
// Holds a mapping ObjectId -> MWWord::Ptr.
|
||||
class ObjectRegistry
|
||||
|
|
|
@ -879,7 +879,7 @@ namespace MWMechanics
|
|||
MWWorld::ContainerStoreIterator torch = inventoryStore.end();
|
||||
for (MWWorld::ContainerStoreIterator it = inventoryStore.begin(); it != inventoryStore.end(); ++it)
|
||||
{
|
||||
if (it->getTypeName() == typeid(ESM::Light).name() &&
|
||||
if (it->getType() == ESM::Light::sRecordId &&
|
||||
it->getClass().canBeEquipped(*it, ptr).first)
|
||||
{
|
||||
torch = it;
|
||||
|
@ -894,10 +894,10 @@ namespace MWMechanics
|
|||
if (!ptr.getClass().getCreatureStats (ptr).getAiSequence().isInCombat())
|
||||
{
|
||||
// For non-hostile NPCs, unequip whatever is in the left slot in favor of a light.
|
||||
if (heldIter != inventoryStore.end() && heldIter->getTypeName() != typeid(ESM::Light).name())
|
||||
if (heldIter != inventoryStore.end() && heldIter->getType() != ESM::Light::sRecordId)
|
||||
inventoryStore.unequipItem(*heldIter, ptr);
|
||||
}
|
||||
else if (heldIter == inventoryStore.end() || heldIter->getTypeName() == typeid(ESM::Light).name())
|
||||
else if (heldIter == inventoryStore.end() || heldIter->getType() == ESM::Light::sRecordId)
|
||||
{
|
||||
// For hostile NPCs, see if they have anything better to equip first
|
||||
auto shield = inventoryStore.getPreferredShield(ptr);
|
||||
|
@ -916,7 +916,7 @@ namespace MWMechanics
|
|||
}
|
||||
else
|
||||
{
|
||||
if (heldIter != inventoryStore.end() && heldIter->getTypeName() == typeid(ESM::Light).name())
|
||||
if (heldIter != inventoryStore.end() && heldIter->getType() == ESM::Light::sRecordId)
|
||||
{
|
||||
// At day, unequip lights and auto equip shields or other suitable items
|
||||
// (Note: autoEquip will ignore lights)
|
||||
|
@ -1708,7 +1708,7 @@ namespace MWMechanics
|
|||
MWBase::Environment::get().getDialogueManager()->say(iter->first, "hit");
|
||||
|
||||
// Apply soultrap
|
||||
if (iter->first.getTypeName() == typeid(ESM::Creature).name())
|
||||
if (iter->first.getType() == ESM::Creature::sRecordId)
|
||||
soulTrap(iter->first);
|
||||
|
||||
// Magic effects will be reset later, and the magic effect that could kill the actor
|
||||
|
|
|
@ -383,7 +383,7 @@ void CharacterController::refreshJumpAnims(const std::string& weapShortGroup, Ju
|
|||
|
||||
bool CharacterController::onOpen()
|
||||
{
|
||||
if (mPtr.getTypeName() == typeid(ESM::Container).name())
|
||||
if (mPtr.getType() == ESM::Container::sRecordId)
|
||||
{
|
||||
if (!mAnimation->hasAnimation("containeropen"))
|
||||
return true;
|
||||
|
@ -404,7 +404,7 @@ bool CharacterController::onOpen()
|
|||
|
||||
void CharacterController::onClose()
|
||||
{
|
||||
if (mPtr.getTypeName() == typeid(ESM::Container).name())
|
||||
if (mPtr.getType() == ESM::Container::sRecordId)
|
||||
{
|
||||
if (!mAnimation->hasAnimation("containerclose"))
|
||||
return;
|
||||
|
@ -591,7 +591,7 @@ void CharacterController::refreshMovementAnims(const std::string& weapShortGroup
|
|||
// even if we are running. This must be replicated, otherwise the observed speed would differ drastically.
|
||||
std::string anim = mCurrentMovement;
|
||||
mAdjustMovementAnimSpeed = true;
|
||||
if (mPtr.getClass().getTypeName() == typeid(ESM::Creature).name()
|
||||
if (mPtr.getClass().getType() == ESM::Creature::sRecordId
|
||||
&& !(mPtr.get<ESM::Creature>()->mBase->mFlags & ESM::Creature::Flies))
|
||||
{
|
||||
CharacterState walkState = runStateToWalkState(mMovementState);
|
||||
|
@ -1432,7 +1432,7 @@ bool CharacterController::updateWeaponState(CharacterState& idle)
|
|||
{
|
||||
MWWorld::InventoryStore &inv = cls.getInventoryStore(mPtr);
|
||||
MWWorld::ConstContainerStoreIterator weapon = getActiveWeapon(mPtr, &weaptype);
|
||||
isWeapon = (weapon != inv.end() && weapon->getTypeName() == typeid(ESM::Weapon).name());
|
||||
isWeapon = (weapon != inv.end() && weapon->getType() == ESM::Weapon::sRecordId);
|
||||
if (isWeapon)
|
||||
{
|
||||
weapSpeed = weapon->get<ESM::Weapon>()->mBase->mData.mSpeed;
|
||||
|
@ -1467,7 +1467,7 @@ bool CharacterController::updateWeaponState(CharacterState& idle)
|
|||
mAttackStrength = 0;
|
||||
|
||||
// Randomize attacks for non-bipedal creatures with Weapon flag
|
||||
if (mPtr.getClass().getTypeName() == typeid(ESM::Creature).name() &&
|
||||
if (mPtr.getClass().getType() == ESM::Creature::sRecordId &&
|
||||
!mPtr.getClass().isBipedal(mPtr) &&
|
||||
(!mAnimation->hasAnimation(mCurrentWeapon) || isRandomAttackAnimation(mCurrentWeapon)))
|
||||
{
|
||||
|
@ -1590,9 +1590,9 @@ bool CharacterController::updateWeaponState(CharacterState& idle)
|
|||
|
||||
if(!target.isEmpty())
|
||||
{
|
||||
if(item.getTypeName() == typeid(ESM::Lockpick).name())
|
||||
if(item.getType() == ESM::Lockpick::sRecordId)
|
||||
Security(mPtr).pickLock(target, item, resultMessage, resultSound);
|
||||
else if(item.getTypeName() == typeid(ESM::Probe).name())
|
||||
else if(item.getType() == ESM::Probe::sRecordId)
|
||||
Security(mPtr).probeTrap(target, item, resultMessage, resultSound);
|
||||
}
|
||||
mAnimation->play(mCurrentWeapon, priorityWeapon,
|
||||
|
@ -1867,7 +1867,7 @@ bool CharacterController::updateWeaponState(CharacterState& idle)
|
|||
{
|
||||
const MWWorld::InventoryStore& inv = mPtr.getClass().getInventoryStore(mPtr);
|
||||
MWWorld::ConstContainerStoreIterator torch = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedLeft);
|
||||
if(torch != inv.end() && torch->getTypeName() == typeid(ESM::Light).name()
|
||||
if(torch != inv.end() && torch->getType() == ESM::Light::sRecordId
|
||||
&& updateCarriedLeftVisible(mWeaponType))
|
||||
{
|
||||
if (mAnimation->isPlaying("shield"))
|
||||
|
|
|
@ -71,7 +71,7 @@ namespace MWMechanics
|
|||
|
||||
MWWorld::InventoryStore& inv = blocker.getClass().getInventoryStore(blocker);
|
||||
MWWorld::ContainerStoreIterator shield = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedLeft);
|
||||
if (shield == inv.end() || shield->getTypeName() != typeid(ESM::Armor).name())
|
||||
if (shield == inv.end() || shield->getType() != ESM::Armor::sRecordId)
|
||||
return false;
|
||||
|
||||
if (!blocker.getRefData().getBaseNode())
|
||||
|
|
|
@ -29,11 +29,11 @@ namespace MWMechanics
|
|||
{
|
||||
mOldItemPtr=oldItem;
|
||||
mWeaponType = -1;
|
||||
mObjectType.clear();
|
||||
mObjectType = 0;
|
||||
if(!itemEmpty())
|
||||
{
|
||||
mObjectType = mOldItemPtr.getTypeName();
|
||||
if (mObjectType == typeid(ESM::Weapon).name())
|
||||
mObjectType = mOldItemPtr.getType();
|
||||
if (mObjectType == ESM::Weapon::sRecordId)
|
||||
mWeaponType = mOldItemPtr.get<ESM::Weapon>()->mBase->mData.mType;
|
||||
}
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ namespace MWMechanics
|
|||
|
||||
const bool powerfulSoul = getGemCharge() >= \
|
||||
MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find ("iSoulAmountForConstantEffect")->mValue.getInteger();
|
||||
if ((mObjectType == typeid(ESM::Armor).name()) || (mObjectType == typeid(ESM::Clothing).name()))
|
||||
if ((mObjectType == ESM::Armor::sRecordId) || (mObjectType == ESM::Clothing::sRecordId))
|
||||
{ // Armor or Clothing
|
||||
switch(mCastStyle)
|
||||
{
|
||||
|
@ -150,7 +150,7 @@ namespace MWMechanics
|
|||
return;
|
||||
}
|
||||
}
|
||||
else if(mObjectType == typeid(ESM::Book).name())
|
||||
else if(mObjectType == ESM::Book::sRecordId)
|
||||
{ // Scroll or Book
|
||||
mCastStyle = ESM::Enchantment::CastOnce;
|
||||
return;
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace MWMechanics
|
|||
ESM::EffectList mEffectList;
|
||||
|
||||
std::string mNewItemName;
|
||||
std::string mObjectType;
|
||||
unsigned int mObjectType;
|
||||
int mWeaponType;
|
||||
|
||||
const ESM::Enchantment* getRecord(const ESM::Enchantment& newEnchantment) const;
|
||||
|
|
|
@ -66,14 +66,14 @@ namespace MWMechanics
|
|||
|
||||
// Is this another levelled item or a real item?
|
||||
MWWorld::ManualRef ref (MWBase::Environment::get().getWorld()->getStore(), item, 1);
|
||||
if (ref.getPtr().getTypeName() != typeid(ESM::ItemLevList).name()
|
||||
&& ref.getPtr().getTypeName() != typeid(ESM::CreatureLevList).name())
|
||||
if (ref.getPtr().getType() != ESM::ItemLevList::sRecordId
|
||||
&& ref.getPtr().getType() != ESM::CreatureLevList::sRecordId)
|
||||
{
|
||||
return item;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ref.getPtr().getTypeName() == typeid(ESM::ItemLevList).name())
|
||||
if (ref.getPtr().getType() == ESM::ItemLevList::sRecordId)
|
||||
return getLevelledItem(ref.getPtr().get<ESM::ItemLevList>()->mBase, false, seed);
|
||||
else
|
||||
return getLevelledItem(ref.getPtr().get<ESM::CreatureLevList>()->mBase, true, seed);
|
||||
|
|
|
@ -555,7 +555,7 @@ namespace MWMechanics
|
|||
{
|
||||
// Make sure zero base price items/services can't be bought/sold for 1 gold
|
||||
// and return the intended base price for creature merchants
|
||||
if (basePrice == 0 || ptr.getTypeName() == typeid(ESM::Creature).name())
|
||||
if (basePrice == 0 || ptr.getType() == ESM::Creature::sRecordId)
|
||||
return basePrice;
|
||||
|
||||
const MWMechanics::NpcStats &sellerStats = ptr.getClass().getNpcStats(ptr);
|
||||
|
|
|
@ -84,7 +84,7 @@ void Objects::update(float duration, bool paused)
|
|||
|
||||
for(auto& object : mObjects)
|
||||
{
|
||||
if (object.first.getTypeName() != typeid(ESM::Container).name())
|
||||
if (object.first.getType() != ESM::Container::sRecordId)
|
||||
continue;
|
||||
|
||||
if (object.second->isAnimPlaying("containeropen"))
|
||||
|
|
|
@ -274,7 +274,7 @@ namespace MWMechanics
|
|||
|
||||
bool godmode = mCaster == MWMechanics::getPlayer() && MWBase::Environment::get().getWorld()->getGodModeState();
|
||||
bool isProjectile = false;
|
||||
if (item.getTypeName() == typeid(ESM::Weapon).name())
|
||||
if (item.getType() == ESM::Weapon::sRecordId)
|
||||
{
|
||||
int type = item.get<ESM::Weapon>()->mBase->mData.mType;
|
||||
ESM::WeaponType::Class weapclass = MWMechanics::getWeaponType(type)->mWeaponClass;
|
||||
|
|
|
@ -213,8 +213,8 @@ namespace
|
|||
if (!wasEquipped)
|
||||
return;
|
||||
|
||||
std::string type = currentItem->getTypeName();
|
||||
if (type != typeid(ESM::Weapon).name() && type != typeid(ESM::Armor).name() && type != typeid(ESM::Clothing).name())
|
||||
auto type = currentItem->getType();
|
||||
if (type != ESM::Weapon::sRecordId && type != ESM::Armor::sRecordId && type != ESM::Clothing::sRecordId)
|
||||
return;
|
||||
|
||||
if (actor.getClass().getCreatureStats(actor).isDead())
|
||||
|
@ -1038,4 +1038,4 @@ void onMagicEffectRemoved(const MWWorld::Ptr& target, ActiveSpells::ActiveSpellP
|
|||
anim->removeEffect(effect.mEffectId);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -96,7 +96,7 @@ namespace MWMechanics
|
|||
|
||||
float ratePotion (const MWWorld::Ptr &item, const MWWorld::Ptr& actor)
|
||||
{
|
||||
if (item.getTypeName() != typeid(ESM::Potion).name())
|
||||
if (item.getType() != ESM::Potion::sRecordId)
|
||||
return 0.f;
|
||||
|
||||
const ESM::Potion* potion = item.get<ESM::Potion>()->mBase;
|
||||
|
|
|
@ -214,7 +214,7 @@ namespace MWMechanics
|
|||
case ESM::MagicEffect::Soultrap:
|
||||
{
|
||||
if (!target.getClass().isNpc() // no messagebox for NPCs
|
||||
&& (target.getTypeName() == typeid(ESM::Creature).name() && target.get<ESM::Creature>()->mBase->mData.mSoul == 0))
|
||||
&& (target.getType() == ESM::Creature::sRecordId && target.get<ESM::Creature>()->mBase->mData.mSoul == 0))
|
||||
{
|
||||
if (castByPlayer)
|
||||
MWBase::Environment::get().getWindowManager()->messageBox("#{sMagicInvalidTarget}");
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace MWMechanics
|
|||
}
|
||||
|
||||
// reject if npc is a creature
|
||||
if ( merchant.getTypeName() != typeid(ESM::NPC).name() ) {
|
||||
if ( merchant.getType() != ESM::NPC::sRecordId ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace MWMechanics
|
|||
float rateWeapon (const MWWorld::Ptr &item, const MWWorld::Ptr& actor, const MWWorld::Ptr& enemy, int type,
|
||||
float arrowRating, float boltRating)
|
||||
{
|
||||
if (enemy.isEmpty() || item.getTypeName() != typeid(ESM::Weapon).name())
|
||||
if (enemy.isEmpty() || item.getType() != ESM::Weapon::sRecordId)
|
||||
return 0.f;
|
||||
|
||||
if (item.getClass().hasItemHealth(item) && item.getClass().getItemHealth(item) == 0)
|
||||
|
|
|
@ -21,13 +21,13 @@ namespace MWMechanics
|
|||
*weaptype = ESM::Weapon::HandToHand;
|
||||
else
|
||||
{
|
||||
const std::string &type = weapon->getTypeName();
|
||||
if(type == typeid(ESM::Weapon).name())
|
||||
auto type = weapon->getType();
|
||||
if(type == ESM::Weapon::sRecordId)
|
||||
{
|
||||
const MWWorld::LiveCellRef<ESM::Weapon> *ref = weapon->get<ESM::Weapon>();
|
||||
*weaptype = ref->mBase->mData.mType;
|
||||
}
|
||||
else if (type == typeid(ESM::Lockpick).name() || type == typeid(ESM::Probe).name())
|
||||
else if (type == ESM::Lockpick::sRecordId || type == ESM::Probe::sRecordId)
|
||||
*weaptype = ESM::Weapon::PickProbe;
|
||||
}
|
||||
|
||||
|
|
|
@ -143,21 +143,21 @@ bool ActorAnimation::updateCarriedLeftVisible(const int weaptype) const
|
|||
const MWWorld::InventoryStore& inv = cls.getInventoryStore(mPtr);
|
||||
const MWWorld::ConstContainerStoreIterator weapon = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedRight);
|
||||
const MWWorld::ConstContainerStoreIterator shield = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedLeft);
|
||||
if (shield != inv.end() && shield->getTypeName() == typeid(ESM::Armor).name() && !getShieldMesh(*shield).empty())
|
||||
if (shield != inv.end() && shield->getType() == ESM::Armor::sRecordId && !getShieldMesh(*shield).empty())
|
||||
{
|
||||
if(stats.getDrawState() != MWMechanics::DrawState_Weapon)
|
||||
return false;
|
||||
|
||||
if (weapon != inv.end())
|
||||
{
|
||||
const std::string &type = weapon->getTypeName();
|
||||
if(type == typeid(ESM::Weapon).name())
|
||||
auto type = weapon->getType();
|
||||
if(type == ESM::Weapon::sRecordId)
|
||||
{
|
||||
const MWWorld::LiveCellRef<ESM::Weapon> *ref = weapon->get<ESM::Weapon>();
|
||||
ESM::Weapon::Type weaponType = (ESM::Weapon::Type)ref->mBase->mData.mType;
|
||||
return !(MWMechanics::getWeaponType(weaponType)->mFlags & ESM::WeaponType::TwoHanded);
|
||||
}
|
||||
else if (type == typeid(ESM::Lockpick).name() || type == typeid(ESM::Probe).name())
|
||||
else if (type == ESM::Lockpick::sRecordId || type == ESM::Probe::sRecordId)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -184,7 +184,7 @@ void ActorAnimation::updateHolsteredShield(bool showCarriedLeft)
|
|||
|
||||
const MWWorld::InventoryStore& inv = mPtr.getClass().getInventoryStore(mPtr);
|
||||
MWWorld::ConstContainerStoreIterator shield = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedLeft);
|
||||
if (shield == inv.end() || shield->getTypeName() != typeid(ESM::Armor).name())
|
||||
if (shield == inv.end() || shield->getType() != ESM::Armor::sRecordId)
|
||||
return;
|
||||
|
||||
// Can not show holdstered shields with two-handed weapons at all
|
||||
|
@ -192,8 +192,8 @@ void ActorAnimation::updateHolsteredShield(bool showCarriedLeft)
|
|||
if(weapon == inv.end())
|
||||
return;
|
||||
|
||||
const std::string &type = weapon->getTypeName();
|
||||
if(type == typeid(ESM::Weapon).name())
|
||||
auto type = weapon->getType();
|
||||
if(type == ESM::Weapon::sRecordId)
|
||||
{
|
||||
const MWWorld::LiveCellRef<ESM::Weapon> *ref = weapon->get<ESM::Weapon>();
|
||||
ESM::Weapon::Type weaponType = (ESM::Weapon::Type)ref->mBase->mData.mType;
|
||||
|
@ -254,17 +254,17 @@ bool ActorAnimation::useShieldAnimations() const
|
|||
const MWWorld::ConstContainerStoreIterator weapon = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedRight);
|
||||
const MWWorld::ConstContainerStoreIterator shield = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedLeft);
|
||||
if (weapon != inv.end() && shield != inv.end() &&
|
||||
shield->getTypeName() == typeid(ESM::Armor).name() &&
|
||||
shield->getType() == ESM::Armor::sRecordId &&
|
||||
!getShieldMesh(*shield).empty())
|
||||
{
|
||||
const std::string &type = weapon->getTypeName();
|
||||
if(type == typeid(ESM::Weapon).name())
|
||||
auto type = weapon->getType();
|
||||
if(type == ESM::Weapon::sRecordId)
|
||||
{
|
||||
const MWWorld::LiveCellRef<ESM::Weapon> *ref = weapon->get<ESM::Weapon>();
|
||||
ESM::Weapon::Type weaponType = (ESM::Weapon::Type)ref->mBase->mData.mType;
|
||||
return !(MWMechanics::getWeaponType(weaponType)->mFlags & ESM::WeaponType::TwoHanded);
|
||||
}
|
||||
else if (type == typeid(ESM::Lockpick).name() || type == typeid(ESM::Probe).name())
|
||||
else if (type == ESM::Lockpick::sRecordId || type == ESM::Probe::sRecordId)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -288,8 +288,8 @@ std::string ActorAnimation::getHolsteredWeaponBoneName(const MWWorld::ConstPtr&
|
|||
if(weapon.isEmpty())
|
||||
return boneName;
|
||||
|
||||
const std::string &type = weapon.getClass().getTypeName();
|
||||
if(type == typeid(ESM::Weapon).name())
|
||||
auto type = weapon.getClass().getType();
|
||||
if(type == ESM::Weapon::sRecordId)
|
||||
{
|
||||
const MWWorld::LiveCellRef<ESM::Weapon> *ref = weapon.get<ESM::Weapon>();
|
||||
int weaponType = ref->mBase->mData.mType;
|
||||
|
@ -323,7 +323,7 @@ void ActorAnimation::updateHolsteredWeapon(bool showHolsteredWeapons)
|
|||
|
||||
const MWWorld::InventoryStore& inv = mPtr.getClass().getInventoryStore(mPtr);
|
||||
MWWorld::ConstContainerStoreIterator weapon = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedRight);
|
||||
if (weapon == inv.end() || weapon->getTypeName() != typeid(ESM::Weapon).name())
|
||||
if (weapon == inv.end() || weapon->getType() != ESM::Weapon::sRecordId)
|
||||
return;
|
||||
|
||||
// Since throwing weapons stack themselves, do not show such weapon itself
|
||||
|
@ -399,7 +399,7 @@ void ActorAnimation::updateQuiver()
|
|||
|
||||
const MWWorld::InventoryStore& inv = mPtr.getClass().getInventoryStore(mPtr);
|
||||
MWWorld::ConstContainerStoreIterator weapon = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedRight);
|
||||
if(weapon == inv.end() || weapon->getTypeName() != typeid(ESM::Weapon).name())
|
||||
if(weapon == inv.end() || weapon->getType() != ESM::Weapon::sRecordId)
|
||||
return;
|
||||
|
||||
std::string mesh = weapon->getClass().getModel(*weapon);
|
||||
|
@ -471,7 +471,7 @@ void ActorAnimation::updateQuiver()
|
|||
|
||||
void ActorAnimation::itemAdded(const MWWorld::ConstPtr& item, int /*count*/)
|
||||
{
|
||||
if (item.getTypeName() == typeid(ESM::Light).name())
|
||||
if (item.getType() == ESM::Light::sRecordId)
|
||||
{
|
||||
const ESM::Light* light = item.get<ESM::Light>()->mBase;
|
||||
if (!(light->mData.mFlags & ESM::Light::Carry))
|
||||
|
@ -486,7 +486,7 @@ void ActorAnimation::itemAdded(const MWWorld::ConstPtr& item, int /*count*/)
|
|||
// If the count of equipped ammo or throwing weapon was changed, we should update quiver
|
||||
const MWWorld::InventoryStore& inv = mPtr.getClass().getInventoryStore(mPtr);
|
||||
MWWorld::ConstContainerStoreIterator weapon = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedRight);
|
||||
if(weapon == inv.end() || weapon->getTypeName() != typeid(ESM::Weapon).name())
|
||||
if(weapon == inv.end() || weapon->getType() != ESM::Weapon::sRecordId)
|
||||
return;
|
||||
|
||||
MWWorld::ConstContainerStoreIterator ammo = inv.end();
|
||||
|
@ -502,7 +502,7 @@ void ActorAnimation::itemAdded(const MWWorld::ConstPtr& item, int /*count*/)
|
|||
|
||||
void ActorAnimation::itemRemoved(const MWWorld::ConstPtr& item, int /*count*/)
|
||||
{
|
||||
if (item.getTypeName() == typeid(ESM::Light).name())
|
||||
if (item.getType() == ESM::Light::sRecordId)
|
||||
{
|
||||
ItemLightMap::iterator iter = mItemLights.find(item);
|
||||
if (iter != mItemLights.end())
|
||||
|
@ -520,7 +520,7 @@ void ActorAnimation::itemRemoved(const MWWorld::ConstPtr& item, int /*count*/)
|
|||
// If the count of equipped ammo or throwing weapon was changed, we should update quiver
|
||||
const MWWorld::InventoryStore& inv = mPtr.getClass().getInventoryStore(mPtr);
|
||||
MWWorld::ConstContainerStoreIterator weapon = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedRight);
|
||||
if(weapon == inv.end() || weapon->getTypeName() != typeid(ESM::Weapon).name())
|
||||
if(weapon == inv.end() || weapon->getType() != ESM::Weapon::sRecordId)
|
||||
return;
|
||||
|
||||
MWWorld::ConstContainerStoreIterator ammo = inv.end();
|
||||
|
|
|
@ -1794,7 +1794,7 @@ namespace MWRender
|
|||
if (!ptr.getClass().getEnchantment(ptr).empty())
|
||||
mGlowUpdater = SceneUtil::addEnchantedGlow(mObjectRoot, mResourceSystem, ptr.getClass().getEnchantmentColor(ptr));
|
||||
}
|
||||
if (ptr.getTypeName() == typeid(ESM::Light).name() && allowLight)
|
||||
if (ptr.getType() == ESM::Light::sRecordId && allowLight)
|
||||
addExtraLight(getOrCreateObjectRoot(), ptr.get<ESM::Light>()->mBase);
|
||||
|
||||
if (!allowLight && mObjectRoot)
|
||||
|
@ -1823,7 +1823,7 @@ namespace MWRender
|
|||
|
||||
bool ObjectAnimation::canBeHarvested() const
|
||||
{
|
||||
if (mPtr.getTypeName() != typeid(ESM::Container).name())
|
||||
if (mPtr.getType() != ESM::Container::sRecordId)
|
||||
return false;
|
||||
|
||||
const MWWorld::LiveCellRef<ESM::Container>* ref = mPtr.get<ESM::Container>();
|
||||
|
|
|
@ -395,7 +395,7 @@ namespace MWRender
|
|||
if(iter != inv.end())
|
||||
{
|
||||
groupname = "inventoryweapononehand";
|
||||
if(iter->getTypeName() == typeid(ESM::Weapon).name())
|
||||
if(iter->getType() == ESM::Weapon::sRecordId)
|
||||
{
|
||||
MWWorld::LiveCellRef<ESM::Weapon> *ref = iter->get<ESM::Weapon>();
|
||||
int type = ref->mBase->mData.mType;
|
||||
|
@ -428,7 +428,7 @@ namespace MWRender
|
|||
mAnimation->play(mCurrentAnimGroup, 1, Animation::BlendMask_All, false, 1.0f, "start", "stop", 0.0f, 0);
|
||||
|
||||
MWWorld::ConstContainerStoreIterator torch = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedLeft);
|
||||
if(torch != inv.end() && torch->getTypeName() == typeid(ESM::Light).name() && showCarriedLeft)
|
||||
if(torch != inv.end() && torch->getType() == ESM::Light::sRecordId && showCarriedLeft)
|
||||
{
|
||||
if(!mAnimation->getInfo("torch"))
|
||||
mAnimation->play("torch", 2, Animation::BlendMask_LeftArm, false,
|
||||
|
|
|
@ -119,7 +119,7 @@ void CreatureWeaponAnimation::updatePart(PartHolderPtr& scene, int slot)
|
|||
std::string itemModel = item.getClass().getModel(item);
|
||||
if (slot == MWWorld::InventoryStore::Slot_CarriedRight)
|
||||
{
|
||||
if(item.getTypeName() == typeid(ESM::Weapon).name())
|
||||
if(item.getType() == ESM::Weapon::sRecordId)
|
||||
{
|
||||
int type = item.get<ESM::Weapon>()->mBase->mData.mType;
|
||||
bonename = MWMechanics::getWeaponType(type)->mAttachBone;
|
||||
|
@ -137,7 +137,7 @@ void CreatureWeaponAnimation::updatePart(PartHolderPtr& scene, int slot)
|
|||
else
|
||||
{
|
||||
bonename = "Shield Bone";
|
||||
if (item.getTypeName() == typeid(ESM::Armor).name())
|
||||
if (item.getType() == ESM::Armor::sRecordId)
|
||||
{
|
||||
// Shield body part model should be used if possible.
|
||||
const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
|
||||
|
@ -174,7 +174,7 @@ void CreatureWeaponAnimation::updatePart(PartHolderPtr& scene, int slot)
|
|||
// Crossbows start out with a bolt attached
|
||||
// FIXME: code duplicated from NpcAnimation
|
||||
if (slot == MWWorld::InventoryStore::Slot_CarriedRight &&
|
||||
item.getTypeName() == typeid(ESM::Weapon).name() &&
|
||||
item.getType() == ESM::Weapon::sRecordId &&
|
||||
item.get<ESM::Weapon>()->mBase->mData.mType == ESM::Weapon::MarksmanCrossbow)
|
||||
{
|
||||
const ESM::WeaponType* weaponInfo = MWMechanics::getWeaponType(ESM::Weapon::MarksmanCrossbow);
|
||||
|
@ -246,7 +246,7 @@ osg::Group *CreatureWeaponAnimation::getArrowBone()
|
|||
|
||||
const MWWorld::InventoryStore& inv = mPtr.getClass().getInventoryStore(mPtr);
|
||||
MWWorld::ConstContainerStoreIterator weapon = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedRight);
|
||||
if(weapon == inv.end() || weapon->getTypeName() != typeid(ESM::Weapon).name())
|
||||
if(weapon == inv.end() || weapon->getType() != ESM::Weapon::sRecordId)
|
||||
return nullptr;
|
||||
|
||||
int type = weapon->get<ESM::Weapon>()->mBase->mData.mType;
|
||||
|
|
|
@ -594,13 +594,13 @@ void NpcAnimation::updateParts()
|
|||
int prio = 1;
|
||||
bool enchantedGlow = !store->getClass().getEnchantment(*store).empty();
|
||||
osg::Vec4f glowColor = store->getClass().getEnchantmentColor(*store);
|
||||
if(store->getTypeName() == typeid(ESM::Clothing).name())
|
||||
if(store->getType() == ESM::Clothing::sRecordId)
|
||||
{
|
||||
prio = ((slotlist[i].mBasePriority+1)<<1) + 0;
|
||||
const ESM::Clothing *clothes = store->get<ESM::Clothing>()->mBase;
|
||||
addPartGroup(slotlist[i].mSlot, prio, clothes->mParts.mParts, enchantedGlow, &glowColor);
|
||||
}
|
||||
else if(store->getTypeName() == typeid(ESM::Armor).name())
|
||||
else if(store->getType() == ESM::Armor::sRecordId)
|
||||
{
|
||||
prio = ((slotlist[i].mBasePriority+1)<<1) + 1;
|
||||
const ESM::Armor *armor = store->get<ESM::Armor>()->mBase;
|
||||
|
@ -640,7 +640,7 @@ void NpcAnimation::updateParts()
|
|||
{
|
||||
MWWorld::ConstContainerStoreIterator store = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedLeft);
|
||||
MWWorld::ConstPtr part;
|
||||
if(store != inv.end() && (part=*store).getTypeName() == typeid(ESM::Light).name())
|
||||
if(store != inv.end() && (part=*store).getType() == ESM::Light::sRecordId)
|
||||
{
|
||||
const ESM::Light *light = part.get<ESM::Light>()->mBase;
|
||||
addOrReplaceIndividualPart(ESM::PRT_Shield, MWWorld::InventoryStore::Slot_CarriedLeft,
|
||||
|
@ -771,7 +771,7 @@ bool NpcAnimation::addOrReplaceIndividualPart(ESM::PartReferenceType type, int g
|
|||
{
|
||||
const MWWorld::InventoryStore& inv = mPtr.getClass().getInventoryStore(mPtr);
|
||||
MWWorld::ConstContainerStoreIterator weapon = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedRight);
|
||||
if(weapon != inv.end() && weapon->getTypeName() == typeid(ESM::Weapon).name())
|
||||
if(weapon != inv.end() && weapon->getType() == ESM::Weapon::sRecordId)
|
||||
{
|
||||
int weaponType = weapon->get<ESM::Weapon>()->mBase->mData.mType;
|
||||
const std::string weaponBonename = MWMechanics::getWeaponType(weaponType)->mAttachBone;
|
||||
|
@ -943,7 +943,7 @@ void NpcAnimation::showWeapons(bool showWeapon)
|
|||
mesh, !weapon->getClass().getEnchantment(*weapon).empty(), &glowColor);
|
||||
|
||||
// Crossbows start out with a bolt attached
|
||||
if (weapon->getTypeName() == typeid(ESM::Weapon).name() &&
|
||||
if (weapon->getType() == ESM::Weapon::sRecordId &&
|
||||
weapon->get<ESM::Weapon>()->mBase->mData.mType == ESM::Weapon::MarksmanCrossbow)
|
||||
{
|
||||
int ammotype = MWMechanics::getWeaponType(ESM::Weapon::MarksmanCrossbow)->mAmmoType;
|
||||
|
@ -975,7 +975,7 @@ void NpcAnimation::showCarriedLeft(bool show)
|
|||
osg::Vec4f glowColor = iter->getClass().getEnchantmentColor(*iter);
|
||||
std::string mesh = iter->getClass().getModel(*iter);
|
||||
// For shields we must try to use the body part model
|
||||
if (iter->getTypeName() == typeid(ESM::Armor).name())
|
||||
if (iter->getType() == ESM::Armor::sRecordId)
|
||||
{
|
||||
const ESM::Armor *armor = iter->get<ESM::Armor>()->mBase;
|
||||
const std::vector<ESM::PartReference>& bodyparts = armor->mParts.mParts;
|
||||
|
@ -987,7 +987,7 @@ void NpcAnimation::showCarriedLeft(bool show)
|
|||
{
|
||||
if (mesh.empty())
|
||||
reserveIndividualPart(ESM::PRT_Shield, MWWorld::InventoryStore::Slot_CarriedLeft, 1);
|
||||
if (iter->getTypeName() == typeid(ESM::Light).name() && mObjectParts[ESM::PRT_Shield])
|
||||
if (iter->getType() == ESM::Light::sRecordId && mObjectParts[ESM::PRT_Shield])
|
||||
addExtraLight(mObjectParts[ESM::PRT_Shield]->getNode()->asGroup(), iter->get<ESM::Light>()->mBase);
|
||||
}
|
||||
}
|
||||
|
@ -1033,7 +1033,7 @@ osg::Group* NpcAnimation::getArrowBone()
|
|||
|
||||
const MWWorld::InventoryStore& inv = mPtr.getClass().getInventoryStore(mPtr);
|
||||
MWWorld::ConstContainerStoreIterator weapon = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedRight);
|
||||
if(weapon == inv.end() || weapon->getTypeName() != typeid(ESM::Weapon).name())
|
||||
if(weapon == inv.end() || weapon->getType() != ESM::Weapon::sRecordId)
|
||||
return nullptr;
|
||||
|
||||
int type = weapon->get<ESM::Weapon>()->mBase->mData.mType;
|
||||
|
|
|
@ -66,7 +66,7 @@ void WeaponAnimation::attachArrow(const MWWorld::Ptr& actor)
|
|||
MWWorld::ConstContainerStoreIterator weaponSlot = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedRight);
|
||||
if (weaponSlot == inv.end())
|
||||
return;
|
||||
if (weaponSlot->getTypeName() != typeid(ESM::Weapon).name())
|
||||
if (weaponSlot->getType() != ESM::Weapon::sRecordId)
|
||||
return;
|
||||
|
||||
int type = weaponSlot->get<ESM::Weapon>()->mBase->mData.mType;
|
||||
|
@ -109,7 +109,7 @@ void WeaponAnimation::releaseArrow(MWWorld::Ptr actor, float attackStrength)
|
|||
MWWorld::ContainerStoreIterator weapon = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedRight);
|
||||
if (weapon == inv.end())
|
||||
return;
|
||||
if (weapon->getTypeName() != typeid(ESM::Weapon).name())
|
||||
if (weapon->getType() != ESM::Weapon::sRecordId)
|
||||
return;
|
||||
|
||||
// The orientation of the launched projectile. Always the same as the actor orientation, even if the ArrowBone's orientation dictates otherwise.
|
||||
|
|
|
@ -50,7 +50,7 @@ namespace
|
|||
|
||||
void addRandomToStore(const MWWorld::Ptr& itemPtr, int count, MWWorld::Ptr& owner, MWWorld::ContainerStore& store, bool topLevel = true)
|
||||
{
|
||||
if(itemPtr.getTypeName() == typeid(ESM::ItemLevList).name())
|
||||
if(itemPtr.getType() == ESM::ItemLevList::sRecordId)
|
||||
{
|
||||
const ESM::ItemLevList* levItemList = itemPtr.get<ESM::ItemLevList>()->mBase;
|
||||
|
||||
|
@ -108,7 +108,7 @@ namespace MWScript
|
|||
// Check if "item" can be placed in a container
|
||||
MWWorld::ManualRef manualRef(MWBase::Environment::get().getWorld()->getStore(), item, 1);
|
||||
MWWorld::Ptr itemPtr = manualRef.getPtr();
|
||||
bool isLevelledList = itemPtr.getClass().getTypeName() == typeid(ESM::ItemLevList).name();
|
||||
bool isLevelledList = itemPtr.getClass().getType() == ESM::ItemLevList::sRecordId;
|
||||
if(!isLevelledList)
|
||||
MWWorld::ContainerStore::getType(itemPtr);
|
||||
|
||||
|
@ -120,7 +120,7 @@ namespace MWScript
|
|||
}
|
||||
|
||||
// Calls to unresolved containers affect the base record
|
||||
if(ptr.getClass().getTypeName() == typeid(ESM::Container).name() && (!ptr.getRefData().getCustomData() ||
|
||||
if(ptr.getClass().getType() == ESM::Container::sRecordId && (!ptr.getRefData().getCustomData() ||
|
||||
!ptr.getClass().getContainerStore(ptr).isResolved()))
|
||||
{
|
||||
ptr.getClass().modifyBaseInventory(ptr.getCellRef().getRefId(), item, count);
|
||||
|
@ -232,7 +232,7 @@ namespace MWScript
|
|||
return;
|
||||
}
|
||||
// Calls to unresolved containers affect the base record instead
|
||||
else if(ptr.getClass().getTypeName() == typeid(ESM::Container).name() &&
|
||||
else if(ptr.getClass().getType() == ESM::Container::sRecordId &&
|
||||
(!ptr.getRefData().getCustomData() || !ptr.getClass().getContainerStore(ptr).isResolved()))
|
||||
{
|
||||
ptr.getClass().modifyBaseInventory(ptr.getCellRef().getRefId(), item, -count);
|
||||
|
@ -380,7 +380,7 @@ namespace MWScript
|
|||
const MWWorld::InventoryStore& invStore = ptr.getClass().getInventoryStore (ptr);
|
||||
MWWorld::ConstContainerStoreIterator it = invStore.getSlot (slot);
|
||||
|
||||
if (it == invStore.end() || it->getTypeName () != typeid(ESM::Armor).name())
|
||||
if (it == invStore.end() || it->getType () != ESM::Armor::sRecordId)
|
||||
{
|
||||
runtime.push(-1);
|
||||
return;
|
||||
|
@ -464,13 +464,13 @@ namespace MWScript
|
|||
runtime.push(-1);
|
||||
return;
|
||||
}
|
||||
else if (it->getTypeName() != typeid(ESM::Weapon).name())
|
||||
else if (it->getType() != ESM::Weapon::sRecordId)
|
||||
{
|
||||
if (it->getTypeName() == typeid(ESM::Lockpick).name())
|
||||
if (it->getType() == ESM::Lockpick::sRecordId)
|
||||
{
|
||||
runtime.push(-2);
|
||||
}
|
||||
else if (it->getTypeName() == typeid(ESM::Probe).name())
|
||||
else if (it->getType() == ESM::Probe::sRecordId)
|
||||
{
|
||||
runtime.push(-3);
|
||||
}
|
||||
|
|
|
@ -310,7 +310,7 @@ namespace MWScript
|
|||
|
||||
// Instantly reset door to closed state
|
||||
// This is done when using Lock in scripts, but not when using Lock spells.
|
||||
if (ptr.getTypeName() == typeid(ESM::Door).name() && !ptr.getCellRef().getTeleport())
|
||||
if (ptr.getType() == ESM::Door::sRecordId && !ptr.getCellRef().getTeleport())
|
||||
{
|
||||
MWBase::Environment::get().getWorld()->activateDoor(ptr, MWWorld::DoorState::Idle);
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
namespace MWWorld
|
||||
{
|
||||
std::map<std::string, std::shared_ptr<Class> > Class::sClasses;
|
||||
std::map<unsigned int, std::shared_ptr<Class> > Class::sClasses;
|
||||
|
||||
void Class::insertObjectRendering (const Ptr& ptr, const std::string& mesh, MWRender::RenderingInterface& renderingInterface) const
|
||||
{
|
||||
|
@ -228,15 +228,12 @@ namespace MWWorld
|
|||
throw std::runtime_error("Class does not support armor rating");
|
||||
}
|
||||
|
||||
const Class& Class::get (const std::string& key)
|
||||
const Class& Class::get (unsigned int key)
|
||||
{
|
||||
if (key.empty())
|
||||
throw std::logic_error ("Class::get(): attempting to get an empty key");
|
||||
|
||||
std::map<std::string, std::shared_ptr<Class> >::const_iterator iter = sClasses.find (key);
|
||||
auto iter = sClasses.find (key);
|
||||
|
||||
if (iter==sClasses.end())
|
||||
throw std::logic_error ("Class::get(): unknown class key: " + key);
|
||||
throw std::logic_error ("Class::get(): unknown class key: " + std::to_string(key));
|
||||
|
||||
return *iter->second;
|
||||
}
|
||||
|
@ -246,9 +243,9 @@ namespace MWWorld
|
|||
throw std::runtime_error ("class does not support persistence");
|
||||
}
|
||||
|
||||
void Class::registerClass(const std::string& key, std::shared_ptr<Class> instance)
|
||||
void Class::registerClass(unsigned int key, std::shared_ptr<Class> instance)
|
||||
{
|
||||
instance->mTypeName = key;
|
||||
instance->mType = key;
|
||||
sClasses.insert(std::make_pair(key, instance));
|
||||
}
|
||||
|
||||
|
|
|
@ -54,9 +54,8 @@ namespace MWWorld
|
|||
/// \brief Base class for referenceable esm records
|
||||
class Class
|
||||
{
|
||||
static std::map<std::string, std::shared_ptr<Class> > sClasses;
|
||||
|
||||
std::string mTypeName;
|
||||
static std::map<unsigned int, std::shared_ptr<Class> > sClasses;
|
||||
unsigned int mType;
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -73,8 +72,8 @@ namespace MWWorld
|
|||
Class (const Class&) = delete;
|
||||
Class& operator= (const Class&) = delete;
|
||||
|
||||
const std::string& getTypeName() const {
|
||||
return mTypeName;
|
||||
unsigned int getType() const {
|
||||
return mType;
|
||||
}
|
||||
|
||||
virtual void insertObjectRendering (const Ptr& ptr, const std::string& mesh, MWRender::RenderingInterface& renderingInterface) const;
|
||||
|
@ -338,10 +337,10 @@ namespace MWWorld
|
|||
const;
|
||||
///< Write additional state from \a ptr into \a state.
|
||||
|
||||
static const Class& get (const std::string& key);
|
||||
static const Class& get (unsigned int key);
|
||||
///< If there is no class for this \a key, an exception is thrown.
|
||||
|
||||
static void registerClass (const std::string& key, std::shared_ptr<Class> instance);
|
||||
static void registerClass (unsigned int key, std::shared_ptr<Class> instance);
|
||||
|
||||
virtual int getBaseGold(const MWWorld::ConstPtr& ptr) const;
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#include "containerstore.hpp"
|
||||
|
||||
#include <cassert>
|
||||
#include <typeinfo>
|
||||
#include <stdexcept>
|
||||
|
||||
#include <components/debug/debuglog.hpp>
|
||||
|
@ -567,7 +566,7 @@ void MWWorld::ContainerStore::addInitialItem (const std::string& id, const std::
|
|||
void MWWorld::ContainerStore::addInitialItemImp(const MWWorld::Ptr& ptr, const std::string& owner, int count,
|
||||
Misc::Rng::Seed* seed, bool topLevel)
|
||||
{
|
||||
if (ptr.getTypeName()==typeid (ESM::ItemLevList).name())
|
||||
if (ptr.getType()==ESM::ItemLevList::sRecordId)
|
||||
{
|
||||
if(!seed)
|
||||
return;
|
||||
|
@ -693,44 +692,44 @@ int MWWorld::ContainerStore::getType (const ConstPtr& ptr)
|
|||
if (ptr.isEmpty())
|
||||
throw std::runtime_error ("can't put a non-existent object into a container");
|
||||
|
||||
if (ptr.getTypeName()==typeid (ESM::Potion).name())
|
||||
if (ptr.getType()==ESM::Potion::sRecordId)
|
||||
return Type_Potion;
|
||||
|
||||
if (ptr.getTypeName()==typeid (ESM::Apparatus).name())
|
||||
if (ptr.getType()==ESM::Apparatus::sRecordId)
|
||||
return Type_Apparatus;
|
||||
|
||||
if (ptr.getTypeName()==typeid (ESM::Armor).name())
|
||||
if (ptr.getType()==ESM::Armor::sRecordId)
|
||||
return Type_Armor;
|
||||
|
||||
if (ptr.getTypeName()==typeid (ESM::Book).name())
|
||||
if (ptr.getType()==ESM::Book::sRecordId)
|
||||
return Type_Book;
|
||||
|
||||
if (ptr.getTypeName()==typeid (ESM::Clothing).name())
|
||||
if (ptr.getType()==ESM::Clothing::sRecordId)
|
||||
return Type_Clothing;
|
||||
|
||||
if (ptr.getTypeName()==typeid (ESM::Ingredient).name())
|
||||
if (ptr.getType()==ESM::Ingredient::sRecordId)
|
||||
return Type_Ingredient;
|
||||
|
||||
if (ptr.getTypeName()==typeid (ESM::Light).name())
|
||||
if (ptr.getType()==ESM::Light::sRecordId)
|
||||
return Type_Light;
|
||||
|
||||
if (ptr.getTypeName()==typeid (ESM::Lockpick).name())
|
||||
if (ptr.getType()==ESM::Lockpick::sRecordId)
|
||||
return Type_Lockpick;
|
||||
|
||||
if (ptr.getTypeName()==typeid (ESM::Miscellaneous).name())
|
||||
if (ptr.getType()==ESM::Miscellaneous::sRecordId)
|
||||
return Type_Miscellaneous;
|
||||
|
||||
if (ptr.getTypeName()==typeid (ESM::Probe).name())
|
||||
if (ptr.getType()==ESM::Probe::sRecordId)
|
||||
return Type_Probe;
|
||||
|
||||
if (ptr.getTypeName()==typeid (ESM::Repair).name())
|
||||
if (ptr.getType()==ESM::Repair::sRecordId)
|
||||
return Type_Repair;
|
||||
|
||||
if (ptr.getTypeName()==typeid (ESM::Weapon).name())
|
||||
if (ptr.getType()==ESM::Weapon::sRecordId)
|
||||
return Type_Weapon;
|
||||
|
||||
throw std::runtime_error (
|
||||
"Object '" + ptr.getCellRef().getRefId() + "' of type " + ptr.getTypeName() + " can not be placed into a container");
|
||||
"Object '" + ptr.getCellRef().getRefId() + "' of type " + ptr.getTypeDescription() + " can not be placed into a container");
|
||||
}
|
||||
|
||||
MWWorld::Ptr MWWorld::ContainerStore::findReplacement(const std::string& id)
|
||||
|
|
|
@ -139,8 +139,8 @@ MWWorld::ContainerStoreIterator MWWorld::InventoryStore::add(const Ptr& itemPtr,
|
|||
if (allowAutoEquip && actorPtr != MWMechanics::getPlayer()
|
||||
&& actorPtr.getClass().isNpc() && !actorPtr.getClass().getNpcStats(actorPtr).isWerewolf())
|
||||
{
|
||||
const std::string& type = itemPtr.getTypeName();
|
||||
if (type == typeid(ESM::Armor).name() || type == typeid(ESM::Clothing).name())
|
||||
auto type = itemPtr.getType();
|
||||
if (type == ESM::Armor::sRecordId || type == ESM::Clothing::sRecordId)
|
||||
autoEquip(actorPtr);
|
||||
}
|
||||
|
||||
|
@ -431,7 +431,7 @@ void MWWorld::InventoryStore::autoEquipArmor (const MWWorld::Ptr& actor, TSlots&
|
|||
|
||||
if (iter.getType() == ContainerStore::Type_Armor)
|
||||
{
|
||||
if (old.getTypeName() == typeid(ESM::Armor).name())
|
||||
if (old.getType() == ESM::Armor::sRecordId)
|
||||
{
|
||||
if (old.get<ESM::Armor>()->mBase->mData.mType < test.get<ESM::Armor>()->mBase->mData.mType)
|
||||
continue;
|
||||
|
@ -465,7 +465,7 @@ void MWWorld::InventoryStore::autoEquipArmor (const MWWorld::Ptr& actor, TSlots&
|
|||
}
|
||||
}
|
||||
|
||||
if (old.getTypeName() == typeid(ESM::Clothing).name())
|
||||
if (old.getType() == ESM::Clothing::sRecordId)
|
||||
{
|
||||
// check value
|
||||
if (old.getClass().getValue (old) >= test.getClass().getValue (test))
|
||||
|
@ -617,8 +617,8 @@ int MWWorld::InventoryStore::remove(const Ptr& item, int count, const Ptr& actor
|
|||
if (equipReplacement && wasEquipped && (actor != MWMechanics::getPlayer())
|
||||
&& actor.getClass().isNpc() && !actor.getClass().getNpcStats(actor).isWerewolf())
|
||||
{
|
||||
const std::string& type = item.getTypeName();
|
||||
if (type == typeid(ESM::Armor).name() || type == typeid(ESM::Clothing).name())
|
||||
auto type = item.getType();
|
||||
if (type == ESM::Armor::sRecordId || type == ESM::Clothing::sRecordId)
|
||||
autoEquip(actor);
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include "class.hpp"
|
||||
#include "esmstore.hpp"
|
||||
|
||||
MWWorld::LiveCellRefBase::LiveCellRefBase(const std::string& type, const ESM::CellRef &cref)
|
||||
MWWorld::LiveCellRefBase::LiveCellRefBase(unsigned int type, const ESM::CellRef &cref)
|
||||
: mClass(&Class::get(type)), mRef(cref), mData(cref)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
#ifndef GAME_MWWORLD_LIVECELLREF_H
|
||||
#define GAME_MWWORLD_LIVECELLREF_H
|
||||
|
||||
#include <typeinfo>
|
||||
|
||||
#include "cellref.hpp"
|
||||
|
||||
#include "refdata.hpp"
|
||||
|
@ -31,7 +29,7 @@ namespace MWWorld
|
|||
/** runtime-data */
|
||||
RefData mData;
|
||||
|
||||
LiveCellRefBase(const std::string& type, const ESM::CellRef &cref=ESM::CellRef());
|
||||
LiveCellRefBase(unsigned int type, const ESM::CellRef &cref=ESM::CellRef());
|
||||
/* Need this for the class to be recognized as polymorphic */
|
||||
virtual ~LiveCellRefBase() { }
|
||||
|
||||
|
@ -43,6 +41,8 @@ namespace MWWorld
|
|||
virtual void save (ESM::ObjectState& state) const = 0;
|
||||
///< Save LiveCellRef state into \a state.
|
||||
|
||||
virtual std::string getTypeDescription() const { return ""; }
|
||||
|
||||
protected:
|
||||
|
||||
void loadImp (const ESM::ObjectState& state);
|
||||
|
@ -77,11 +77,11 @@ namespace MWWorld
|
|||
struct LiveCellRef : public LiveCellRefBase
|
||||
{
|
||||
LiveCellRef(const ESM::CellRef& cref, const X* b = nullptr)
|
||||
: LiveCellRefBase(typeid(X).name(), cref), mBase(b)
|
||||
: LiveCellRefBase(X::sRecordId, cref), mBase(b)
|
||||
{}
|
||||
|
||||
LiveCellRef(const X* b = nullptr)
|
||||
: LiveCellRefBase(typeid(X).name()), mBase(b)
|
||||
: LiveCellRefBase(X::sRecordId), mBase(b)
|
||||
{}
|
||||
|
||||
// The object that this instance is based on.
|
||||
|
@ -95,6 +95,8 @@ namespace MWWorld
|
|||
void save (ESM::ObjectState& state) const override;
|
||||
///< Save LiveCellRef state into \a state.
|
||||
|
||||
std::string getTypeDescription() const override { return X::getRecordType(); }
|
||||
|
||||
static bool checkState (const ESM::ObjectState& state);
|
||||
///< Check if state is valid and report errors.
|
||||
///
|
||||
|
|
|
@ -43,7 +43,7 @@ namespace
|
|||
bool operator()(const MWWorld::Ptr& containerPtr)
|
||||
{
|
||||
// Ignore containers without generated content
|
||||
if (containerPtr.getTypeName() == typeid(ESM::Container).name() &&
|
||||
if (containerPtr.getType() == ESM::Container::sRecordId &&
|
||||
containerPtr.getRefData().getCustomData() == nullptr)
|
||||
return true;
|
||||
|
||||
|
|
|
@ -6,10 +6,10 @@
|
|||
#include "class.hpp"
|
||||
#include "livecellref.hpp"
|
||||
|
||||
const std::string& MWWorld::Ptr::getTypeName() const
|
||||
unsigned int MWWorld::Ptr::getType() const
|
||||
{
|
||||
if(mRef != nullptr)
|
||||
return mRef->mClass->getTypeName();
|
||||
return mRef->mClass->getType();
|
||||
throw std::runtime_error("Can't get type name from an empty object.");
|
||||
}
|
||||
|
||||
|
@ -55,10 +55,10 @@ MWWorld::Ptr::operator const void *()
|
|||
|
||||
// -------------------------------------------------------------------------------
|
||||
|
||||
const std::string &MWWorld::ConstPtr::getTypeName() const
|
||||
unsigned int MWWorld::ConstPtr::getType() const
|
||||
{
|
||||
if(mRef != nullptr)
|
||||
return mRef->mClass->getTypeName();
|
||||
return mRef->mClass->getType();
|
||||
throw std::runtime_error("Can't get type name from an empty object.");
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,12 @@ namespace MWWorld
|
|||
return mRef == nullptr;
|
||||
}
|
||||
|
||||
const std::string& getTypeName() const;
|
||||
unsigned int getType() const;
|
||||
|
||||
std::string getTypeDescription() const
|
||||
{
|
||||
return mRef ? mRef->getTypeDescription() : "nullptr";
|
||||
}
|
||||
|
||||
const Class& getClass() const
|
||||
{
|
||||
|
@ -51,8 +56,8 @@ namespace MWWorld
|
|||
if(ref) return ref;
|
||||
|
||||
std::stringstream str;
|
||||
str<< "Bad LiveCellRef cast to "<<typeid(T).name()<<" from ";
|
||||
if(mRef != nullptr) str<< getTypeName();
|
||||
str<< "Bad LiveCellRef cast to "<<T::getRecordType()<<" from ";
|
||||
if(mRef != nullptr) str<< getTypeDescription();
|
||||
else str<< "an empty object";
|
||||
|
||||
throw std::runtime_error(str.str());
|
||||
|
@ -111,7 +116,12 @@ namespace MWWorld
|
|||
return mRef == nullptr;
|
||||
}
|
||||
|
||||
const std::string& getTypeName() const;
|
||||
unsigned int getType() const;
|
||||
|
||||
std::string getTypeDescription() const
|
||||
{
|
||||
return mRef ? mRef->getTypeDescription() : "nullptr";
|
||||
}
|
||||
|
||||
const Class& getClass() const
|
||||
{
|
||||
|
@ -127,8 +137,8 @@ namespace MWWorld
|
|||
if(ref) return ref;
|
||||
|
||||
std::stringstream str;
|
||||
str<< "Bad LiveCellRef cast to "<<typeid(T).name()<<" from ";
|
||||
if(mRef != nullptr) str<< getTypeName();
|
||||
str<< "Bad LiveCellRef cast to "<<T::getRecordType()<<" from ";
|
||||
if(mRef != nullptr) str<< getTypeDescription();
|
||||
else str<< "an empty object";
|
||||
|
||||
throw std::runtime_error(str.str());
|
||||
|
|
|
@ -784,9 +784,9 @@ namespace MWWorld
|
|||
|
||||
void World::addContainerScripts(const Ptr& reference, CellStore * cell)
|
||||
{
|
||||
if( reference.getTypeName()==typeid (ESM::Container).name() ||
|
||||
reference.getTypeName()==typeid (ESM::NPC).name() ||
|
||||
reference.getTypeName()==typeid (ESM::Creature).name())
|
||||
if( reference.getType()==ESM::Container::sRecordId ||
|
||||
reference.getType()==ESM::NPC::sRecordId ||
|
||||
reference.getType()==ESM::Creature::sRecordId)
|
||||
{
|
||||
MWWorld::ContainerStore& container = reference.getClass().getContainerStore(reference);
|
||||
for(MWWorld::ContainerStoreIterator it = container.begin(); it != container.end(); ++it)
|
||||
|
@ -827,9 +827,9 @@ namespace MWWorld
|
|||
|
||||
void World::removeContainerScripts(const Ptr& reference)
|
||||
{
|
||||
if( reference.getTypeName()==typeid (ESM::Container).name() ||
|
||||
reference.getTypeName()==typeid (ESM::NPC).name() ||
|
||||
reference.getTypeName()==typeid (ESM::Creature).name())
|
||||
if( reference.getType()==ESM::Container::sRecordId ||
|
||||
reference.getType()==ESM::NPC::sRecordId ||
|
||||
reference.getType()==ESM::Creature::sRecordId)
|
||||
{
|
||||
MWWorld::ContainerStore& container = reference.getClass().getContainerStore(reference);
|
||||
for(MWWorld::ContainerStoreIterator it = container.begin(); it != container.end(); ++it)
|
||||
|
@ -3415,7 +3415,7 @@ namespace MWWorld
|
|||
return true;
|
||||
|
||||
// Consider references inside containers as well (except if we are looking for a Creature, they cannot be in containers)
|
||||
bool isContainer = ptr.getClass().getTypeName() == typeid(ESM::Container).name();
|
||||
bool isContainer = ptr.getClass().getType() == ESM::Container::sRecordId;
|
||||
if (mType != World::Detect_Creature && (ptr.getClass().isActor() || isContainer))
|
||||
{
|
||||
// but ignore containers without resolved content
|
||||
|
@ -3470,10 +3470,10 @@ namespace MWWorld
|
|||
// If in werewolf form, this detects only NPCs, otherwise only creatures
|
||||
if (detector.getClass().isNpc() && detector.getClass().getNpcStats(detector).isWerewolf())
|
||||
{
|
||||
if (ptr.getClass().getTypeName() != typeid(ESM::NPC).name())
|
||||
if (ptr.getClass().getType() != ESM::NPC::sRecordId)
|
||||
return false;
|
||||
}
|
||||
else if (ptr.getClass().getTypeName() != typeid(ESM::Creature).name())
|
||||
else if (ptr.getClass().getType() != ESM::Creature::sRecordId)
|
||||
return false;
|
||||
|
||||
if (ptr.getClass().getCreatureStats(ptr).isDead())
|
||||
|
|
Loading…
Reference in a new issue