forked from teamnwah/openmw-tes3coop
Merge pull request #178 from OpenMW/master
Add OpenMW commits up to 2 Mar 2017
This commit is contained in:
commit
a2ef39c655
31 changed files with 463 additions and 296 deletions
|
@ -116,6 +116,7 @@ Programmers
|
||||||
Pieter van der Kloet (pvdk)
|
Pieter van der Kloet (pvdk)
|
||||||
pkubik
|
pkubik
|
||||||
Radu-Marius Popovici (rpopovici)
|
Radu-Marius Popovici (rpopovici)
|
||||||
|
Rafael Moura (dhustkoder)
|
||||||
rdimesio
|
rdimesio
|
||||||
riothamus
|
riothamus
|
||||||
Rob Cutmore (rcutmore)
|
Rob Cutmore (rcutmore)
|
||||||
|
|
|
@ -43,8 +43,8 @@ namespace MWClass
|
||||||
|
|
||||||
void Actor::block(const MWWorld::Ptr &ptr) const
|
void Actor::block(const MWWorld::Ptr &ptr) const
|
||||||
{
|
{
|
||||||
MWWorld::InventoryStore& inv = getInventoryStore(ptr);
|
const MWWorld::InventoryStore& inv = getInventoryStore(ptr);
|
||||||
MWWorld::ContainerStoreIterator shield = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedLeft);
|
MWWorld::ConstContainerStoreIterator shield = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedLeft);
|
||||||
if (shield == inv.end())
|
if (shield == inv.end())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -295,7 +295,7 @@ namespace MWClass
|
||||||
|
|
||||||
std::pair<int, std::string> Armor::canBeEquipped(const MWWorld::ConstPtr &ptr, const MWWorld::Ptr &npc) const
|
std::pair<int, std::string> Armor::canBeEquipped(const MWWorld::ConstPtr &ptr, const MWWorld::Ptr &npc) const
|
||||||
{
|
{
|
||||||
MWWorld::InventoryStore& invStore = npc.getClass().getInventoryStore(npc);
|
const MWWorld::InventoryStore& invStore = npc.getClass().getInventoryStore(npc);
|
||||||
|
|
||||||
if (ptr.getCellRef().getCharge() == 0)
|
if (ptr.getCellRef().getCharge() == 0)
|
||||||
return std::make_pair(0, "#{sInventoryMessage1}");
|
return std::make_pair(0, "#{sInventoryMessage1}");
|
||||||
|
@ -332,7 +332,7 @@ namespace MWClass
|
||||||
// If equipping a shield, check if there's a twohanded weapon conflicting with it
|
// If equipping a shield, check if there's a twohanded weapon conflicting with it
|
||||||
if(*slot == MWWorld::InventoryStore::Slot_CarriedLeft)
|
if(*slot == MWWorld::InventoryStore::Slot_CarriedLeft)
|
||||||
{
|
{
|
||||||
MWWorld::ContainerStoreIterator weapon = invStore.getSlot(MWWorld::InventoryStore::Slot_CarriedRight);
|
MWWorld::ConstContainerStoreIterator weapon = invStore.getSlot(MWWorld::InventoryStore::Slot_CarriedRight);
|
||||||
|
|
||||||
if(weapon == invStore.end())
|
if(weapon == invStore.end())
|
||||||
return std::make_pair(1,"");
|
return std::make_pair(1,"");
|
||||||
|
|
|
@ -139,7 +139,7 @@ namespace MWClass
|
||||||
const std::string trapActivationSound = "Disarm Trap Fail";
|
const std::string trapActivationSound = "Disarm Trap Fail";
|
||||||
|
|
||||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayerPtr();
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayerPtr();
|
||||||
MWWorld::InventoryStore& invStore = player.getClass().getInventoryStore(player);
|
const MWWorld::InventoryStore& invStore = player.getClass().getInventoryStore(player);
|
||||||
|
|
||||||
bool isLocked = ptr.getCellRef().getLockLevel() > 0;
|
bool isLocked = ptr.getCellRef().getLockLevel() > 0;
|
||||||
bool isTrapped = !ptr.getCellRef().getTrap().empty();
|
bool isTrapped = !ptr.getCellRef().getTrap().empty();
|
||||||
|
@ -149,7 +149,7 @@ namespace MWClass
|
||||||
// make key id lowercase
|
// make key id lowercase
|
||||||
std::string keyId = ptr.getCellRef().getKey();
|
std::string keyId = ptr.getCellRef().getKey();
|
||||||
Misc::StringUtils::lowerCaseInPlace(keyId);
|
Misc::StringUtils::lowerCaseInPlace(keyId);
|
||||||
for (MWWorld::ContainerStoreIterator it = invStore.begin(); it != invStore.end(); ++it)
|
for (MWWorld::ConstContainerStoreIterator it = invStore.cbegin(); it != invStore.cend(); ++it)
|
||||||
{
|
{
|
||||||
std::string refId = it->getCellRef().getRefId();
|
std::string refId = it->getCellRef().getRefId();
|
||||||
Misc::StringUtils::lowerCaseInPlace(refId);
|
Misc::StringUtils::lowerCaseInPlace(refId);
|
||||||
|
|
|
@ -194,10 +194,10 @@ namespace MWClass
|
||||||
// FIXME: use const version of InventoryStore functions once they are available
|
// FIXME: use const version of InventoryStore functions once they are available
|
||||||
if (ptr.getClass().hasInventoryStore(ptr))
|
if (ptr.getClass().hasInventoryStore(ptr))
|
||||||
{
|
{
|
||||||
MWWorld::InventoryStore& invStore = ptr.getClass().getInventoryStore(ptr);
|
const MWWorld::InventoryStore& invStore = ptr.getClass().getInventoryStore(ptr);
|
||||||
for (int slot = 0; slot < MWWorld::InventoryStore::Slots; ++slot)
|
for (int slot = 0; slot < MWWorld::InventoryStore::Slots; ++slot)
|
||||||
{
|
{
|
||||||
MWWorld::ContainerStoreIterator equipped = invStore.getSlot(slot);
|
MWWorld::ConstContainerStoreIterator equipped = invStore.getSlot(slot);
|
||||||
if (equipped != invStore.end())
|
if (equipped != invStore.end())
|
||||||
{
|
{
|
||||||
model = equipped->getClass().getModel(*equipped);
|
model = equipped->getClass().getModel(*equipped);
|
||||||
|
|
|
@ -109,7 +109,7 @@ namespace MWClass
|
||||||
const std::string lockedSound = "LockedDoor";
|
const std::string lockedSound = "LockedDoor";
|
||||||
const std::string trapActivationSound = "Disarm Trap Fail";
|
const std::string trapActivationSound = "Disarm Trap Fail";
|
||||||
|
|
||||||
MWWorld::ContainerStore &invStore = actor.getClass().getContainerStore(actor);
|
const MWWorld::ContainerStore &invStore = actor.getClass().getContainerStore(actor);
|
||||||
|
|
||||||
bool isLocked = ptr.getCellRef().getLockLevel() > 0;
|
bool isLocked = ptr.getCellRef().getLockLevel() > 0;
|
||||||
bool isTrapped = !ptr.getCellRef().getTrap().empty();
|
bool isTrapped = !ptr.getCellRef().getTrap().empty();
|
||||||
|
@ -133,7 +133,7 @@ namespace MWClass
|
||||||
// make key id lowercase
|
// make key id lowercase
|
||||||
std::string keyId = ptr.getCellRef().getKey();
|
std::string keyId = ptr.getCellRef().getKey();
|
||||||
Misc::StringUtils::lowerCaseInPlace(keyId);
|
Misc::StringUtils::lowerCaseInPlace(keyId);
|
||||||
for (MWWorld::ContainerStoreIterator it = invStore.begin(); it != invStore.end(); ++it)
|
for (MWWorld::ConstContainerStoreIterator it = invStore.cbegin(); it != invStore.cend(); ++it)
|
||||||
{
|
{
|
||||||
std::string refId = it->getCellRef().getRefId();
|
std::string refId = it->getCellRef().getRefId();
|
||||||
Misc::StringUtils::lowerCaseInPlace(refId);
|
Misc::StringUtils::lowerCaseInPlace(refId);
|
||||||
|
|
|
@ -233,8 +233,8 @@ namespace MWClass
|
||||||
if (!(ref->mBase->mData.mFlags & ESM::Light::Carry))
|
if (!(ref->mBase->mData.mFlags & ESM::Light::Carry))
|
||||||
return std::make_pair(0,"");
|
return std::make_pair(0,"");
|
||||||
|
|
||||||
MWWorld::InventoryStore& invStore = npc.getClass().getInventoryStore(npc);
|
const MWWorld::InventoryStore& invStore = npc.getClass().getInventoryStore(npc);
|
||||||
MWWorld::ContainerStoreIterator weapon = invStore.getSlot(MWWorld::InventoryStore::Slot_CarriedRight);
|
MWWorld::ConstContainerStoreIterator weapon = invStore.getSlot(MWWorld::InventoryStore::Slot_CarriedRight);
|
||||||
|
|
||||||
if(weapon == invStore.end())
|
if(weapon == invStore.end())
|
||||||
return std::make_pair(1,"");
|
return std::make_pair(1,"");
|
||||||
|
|
|
@ -471,10 +471,10 @@ namespace MWClass
|
||||||
// preload equipped items
|
// preload equipped items
|
||||||
if (ptr.getClass().hasInventoryStore(ptr))
|
if (ptr.getClass().hasInventoryStore(ptr))
|
||||||
{
|
{
|
||||||
MWWorld::InventoryStore& invStore = ptr.getClass().getInventoryStore(ptr);
|
const MWWorld::InventoryStore& invStore = ptr.getClass().getInventoryStore(ptr);
|
||||||
for (int slot = 0; slot < MWWorld::InventoryStore::Slots; ++slot)
|
for (int slot = 0; slot < MWWorld::InventoryStore::Slots; ++slot)
|
||||||
{
|
{
|
||||||
MWWorld::ContainerStoreIterator equipped = invStore.getSlot(slot);
|
MWWorld::ConstContainerStoreIterator equipped = invStore.getSlot(slot);
|
||||||
if (equipped != invStore.end())
|
if (equipped != invStore.end())
|
||||||
{
|
{
|
||||||
std::vector<ESM::PartReference> parts;
|
std::vector<ESM::PartReference> parts;
|
||||||
|
@ -1127,7 +1127,7 @@ namespace MWClass
|
||||||
const MWWorld::Store<ESM::GameSetting> &store = world->getStore().get<ESM::GameSetting>();
|
const MWWorld::Store<ESM::GameSetting> &store = world->getStore().get<ESM::GameSetting>();
|
||||||
|
|
||||||
MWMechanics::NpcStats &stats = getNpcStats(ptr);
|
MWMechanics::NpcStats &stats = getNpcStats(ptr);
|
||||||
MWWorld::InventoryStore &invStore = getInventoryStore(ptr);
|
const MWWorld::InventoryStore &invStore = getInventoryStore(ptr);
|
||||||
|
|
||||||
float fUnarmoredBase1 = store.find("fUnarmoredBase1")->getFloat();
|
float fUnarmoredBase1 = store.find("fUnarmoredBase1")->getFloat();
|
||||||
float fUnarmoredBase2 = store.find("fUnarmoredBase2")->getFloat();
|
float fUnarmoredBase2 = store.find("fUnarmoredBase2")->getFloat();
|
||||||
|
@ -1136,7 +1136,7 @@ namespace MWClass
|
||||||
float ratings[MWWorld::InventoryStore::Slots];
|
float ratings[MWWorld::InventoryStore::Slots];
|
||||||
for(int i = 0;i < MWWorld::InventoryStore::Slots;i++)
|
for(int i = 0;i < MWWorld::InventoryStore::Slots;i++)
|
||||||
{
|
{
|
||||||
MWWorld::ContainerStoreIterator it = invStore.getSlot(i);
|
MWWorld::ConstContainerStoreIterator it = invStore.getSlot(i);
|
||||||
if (it == invStore.end() || it->getTypeName() != typeid(ESM::Armor).name())
|
if (it == invStore.end() || it->getTypeName() != typeid(ESM::Armor).name())
|
||||||
{
|
{
|
||||||
// unarmored
|
// unarmored
|
||||||
|
@ -1217,8 +1217,8 @@ namespace MWClass
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
MWWorld::InventoryStore &inv = Npc::getInventoryStore(ptr);
|
const MWWorld::InventoryStore &inv = Npc::getInventoryStore(ptr);
|
||||||
MWWorld::ContainerStoreIterator boots = inv.getSlot(MWWorld::InventoryStore::Slot_Boots);
|
MWWorld::ConstContainerStoreIterator boots = inv.getSlot(MWWorld::InventoryStore::Slot_Boots);
|
||||||
if(boots == inv.end() || boots->getTypeName() != typeid(ESM::Armor).name())
|
if(boots == inv.end() || boots->getTypeName() != typeid(ESM::Armor).name())
|
||||||
return (name == "left") ? "FootBareLeft" : "FootBareRight";
|
return (name == "left") ? "FootBareLeft" : "FootBareRight";
|
||||||
|
|
||||||
|
|
|
@ -344,13 +344,13 @@ int MWDialogue::Filter::getSelectStructInteger (const SelectWrapper& select) con
|
||||||
|
|
||||||
case SelectWrapper::Function_PcClothingModifier:
|
case SelectWrapper::Function_PcClothingModifier:
|
||||||
{
|
{
|
||||||
MWWorld::InventoryStore& store = player.getClass().getInventoryStore (player);
|
const MWWorld::InventoryStore& store = player.getClass().getInventoryStore (player);
|
||||||
|
|
||||||
int value = 0;
|
int value = 0;
|
||||||
|
|
||||||
for (int i=0; i<=15; ++i) // everything except things held in hands and ammunition
|
for (int i=0; i<=15; ++i) // everything except things held in hands and ammunition
|
||||||
{
|
{
|
||||||
MWWorld::ContainerStoreIterator slot = store.getSlot (i);
|
MWWorld::ConstContainerStoreIterator slot = store.getSlot (i);
|
||||||
|
|
||||||
if (slot!=store.end())
|
if (slot!=store.end())
|
||||||
value += slot->getClass().getValue (*slot);
|
value += slot->getClass().getValue (*slot);
|
||||||
|
|
|
@ -44,10 +44,10 @@ void MerchantRepair::startRepair(const MWWorld::Ptr &actor)
|
||||||
MWWorld::Ptr player = MWMechanics::getPlayer();
|
MWWorld::Ptr player = MWMechanics::getPlayer();
|
||||||
int playerGold = player.getClass().getContainerStore(player).count(MWWorld::ContainerStore::sGoldId);
|
int playerGold = player.getClass().getContainerStore(player).count(MWWorld::ContainerStore::sGoldId);
|
||||||
|
|
||||||
MWWorld::ContainerStore& store = player.getClass().getContainerStore(player);
|
const MWWorld::ContainerStore& store = player.getClass().getContainerStore(player);
|
||||||
int categories = MWWorld::ContainerStore::Type_Weapon | MWWorld::ContainerStore::Type_Armor;
|
int categories = MWWorld::ContainerStore::Type_Weapon | MWWorld::ContainerStore::Type_Armor;
|
||||||
for (MWWorld::ContainerStoreIterator iter (store.begin(categories));
|
for (MWWorld::ConstContainerStoreIterator iter (store.cbegin(categories));
|
||||||
iter!=store.end(); ++iter)
|
iter!=store.cend(); ++iter)
|
||||||
{
|
{
|
||||||
if (iter->getClass().hasItemHealth(*iter))
|
if (iter->getClass().hasItemHealth(*iter))
|
||||||
{
|
{
|
||||||
|
|
|
@ -310,7 +310,7 @@ namespace MWGui
|
||||||
{
|
{
|
||||||
MWWorld::Ptr item = *button->getUserData<MWWorld::Ptr>();
|
MWWorld::Ptr item = *button->getUserData<MWWorld::Ptr>();
|
||||||
MWBase::Environment::get().getWindowManager()->useItem(item);
|
MWBase::Environment::get().getWindowManager()->useItem(item);
|
||||||
MWWorld::ContainerStoreIterator rightHand = store.getSlot(MWWorld::InventoryStore::Slot_CarriedRight);
|
MWWorld::ConstContainerStoreIterator rightHand = store.getSlot(MWWorld::InventoryStore::Slot_CarriedRight);
|
||||||
// change draw state only if the item is in player's right hand
|
// change draw state only if the item is in player's right hand
|
||||||
if (rightHand != store.end() && item == *rightHand)
|
if (rightHand != store.end() && item == *rightHand)
|
||||||
{
|
{
|
||||||
|
|
|
@ -62,7 +62,7 @@ void adjustBoundItem (const std::string& item, bool bound, const MWWorld::Ptr& a
|
||||||
MWWorld::Ptr newPtr = *store.MWWorld::ContainerStore::add(item, 1, actor);
|
MWWorld::Ptr newPtr = *store.MWWorld::ContainerStore::add(item, 1, actor);
|
||||||
MWWorld::ActionEquip action(newPtr);
|
MWWorld::ActionEquip action(newPtr);
|
||||||
action.execute(actor);
|
action.execute(actor);
|
||||||
MWWorld::ContainerStoreIterator rightHand = store.getSlot(MWWorld::InventoryStore::Slot_CarriedRight);
|
MWWorld::ConstContainerStoreIterator rightHand = store.getSlot(MWWorld::InventoryStore::Slot_CarriedRight);
|
||||||
// change draw state only if the item is in player's right hand
|
// change draw state only if the item is in player's right hand
|
||||||
if (actor == MWMechanics::getPlayer()
|
if (actor == MWMechanics::getPlayer()
|
||||||
&& rightHand != store.end() && newPtr == *rightHand)
|
&& rightHand != store.end() && newPtr == *rightHand)
|
||||||
|
|
|
@ -1104,7 +1104,7 @@ bool CharacterController::updateWeaponState()
|
||||||
if (mPtr.getClass().hasInventoryStore(mPtr))
|
if (mPtr.getClass().hasInventoryStore(mPtr))
|
||||||
{
|
{
|
||||||
MWWorld::InventoryStore &inv = cls.getInventoryStore(mPtr);
|
MWWorld::InventoryStore &inv = cls.getInventoryStore(mPtr);
|
||||||
MWWorld::ContainerStoreIterator weapon = getActiveWeapon(stats, inv, &weaptype);
|
MWWorld::ConstContainerStoreIterator weapon = getActiveWeapon(stats, inv, &weaptype);
|
||||||
if(weapon != inv.end() && !(weaptype == WeapType_None && mWeaponType == WeapType_Spell))
|
if(weapon != inv.end() && !(weaptype == WeapType_None && mWeaponType == WeapType_Spell))
|
||||||
{
|
{
|
||||||
soundid = (weaptype == WeapType_None) ?
|
soundid = (weaptype == WeapType_None) ?
|
||||||
|
@ -1192,12 +1192,12 @@ bool CharacterController::updateWeaponState()
|
||||||
if (mPtr.getClass().hasInventoryStore(mPtr))
|
if (mPtr.getClass().hasInventoryStore(mPtr))
|
||||||
{
|
{
|
||||||
MWWorld::InventoryStore &inv = cls.getInventoryStore(mPtr);
|
MWWorld::InventoryStore &inv = cls.getInventoryStore(mPtr);
|
||||||
MWWorld::ContainerStoreIterator weapon = getActiveWeapon(stats, inv, &weaptype);
|
MWWorld::ConstContainerStoreIterator weapon = getActiveWeapon(stats, inv, &weaptype);
|
||||||
isWeapon = (weapon != inv.end() && weapon->getTypeName() == typeid(ESM::Weapon).name());
|
isWeapon = (weapon != inv.end() && weapon->getTypeName() == typeid(ESM::Weapon).name());
|
||||||
if(isWeapon)
|
if(isWeapon)
|
||||||
weapSpeed = weapon->get<ESM::Weapon>()->mBase->mData.mSpeed;
|
weapSpeed = weapon->get<ESM::Weapon>()->mBase->mData.mSpeed;
|
||||||
|
|
||||||
MWWorld::ContainerStoreIterator ammo = inv.getSlot(MWWorld::InventoryStore::Slot_Ammunition);
|
MWWorld::ConstContainerStoreIterator ammo = inv.getSlot(MWWorld::InventoryStore::Slot_Ammunition);
|
||||||
if (mWeaponType == WeapType_Crossbow)
|
if (mWeaponType == WeapType_Crossbow)
|
||||||
ammunition = (ammo != inv.end() && ammo->get<ESM::Weapon>()->mBase->mData.mType == ESM::Weapon::Bolt);
|
ammunition = (ammo != inv.end() && ammo->get<ESM::Weapon>()->mBase->mData.mType == ESM::Weapon::Bolt);
|
||||||
else if (mWeaponType == WeapType_BowAndArrow)
|
else if (mWeaponType == WeapType_BowAndArrow)
|
||||||
|
@ -1334,7 +1334,7 @@ bool CharacterController::updateWeaponState()
|
||||||
{
|
{
|
||||||
if (Settings::Manager::getBool("best attack", "Game"))
|
if (Settings::Manager::getBool("best attack", "Game"))
|
||||||
{
|
{
|
||||||
MWWorld::ContainerStoreIterator weapon = mPtr.getClass().getInventoryStore(mPtr).getSlot(MWWorld::InventoryStore::Slot_CarriedRight);
|
MWWorld::ConstContainerStoreIterator weapon = mPtr.getClass().getInventoryStore(mPtr).getSlot(MWWorld::InventoryStore::Slot_CarriedRight);
|
||||||
mAttackType = getBestAttack(weapon->get<ESM::Weapon>()->mBase);
|
mAttackType = getBestAttack(weapon->get<ESM::Weapon>()->mBase);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1533,8 +1533,8 @@ bool CharacterController::updateWeaponState()
|
||||||
|
|
||||||
if (mPtr.getClass().hasInventoryStore(mPtr))
|
if (mPtr.getClass().hasInventoryStore(mPtr))
|
||||||
{
|
{
|
||||||
MWWorld::InventoryStore& inv = mPtr.getClass().getInventoryStore(mPtr);
|
const MWWorld::InventoryStore& inv = mPtr.getClass().getInventoryStore(mPtr);
|
||||||
MWWorld::ContainerStoreIterator torch = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedLeft);
|
MWWorld::ConstContainerStoreIterator torch = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedLeft);
|
||||||
if(torch != inv.end() && torch->getTypeName() == typeid(ESM::Light).name()
|
if(torch != inv.end() && torch->getTypeName() == typeid(ESM::Light).name()
|
||||||
&& updateCarriedLeftVisible(mWeaponType))
|
&& updateCarriedLeftVisible(mWeaponType))
|
||||||
|
|
||||||
|
|
|
@ -6,12 +6,12 @@
|
||||||
#include <components/esm/loadmgef.hpp>
|
#include <components/esm/loadmgef.hpp>
|
||||||
|
|
||||||
#include "../mwworld/ptr.hpp"
|
#include "../mwworld/ptr.hpp"
|
||||||
|
#include "../mwworld/containerstore.hpp"
|
||||||
|
|
||||||
#include "../mwrender/animation.hpp"
|
#include "../mwrender/animation.hpp"
|
||||||
|
|
||||||
namespace MWWorld
|
namespace MWWorld
|
||||||
{
|
{
|
||||||
class ContainerStoreIterator;
|
|
||||||
class InventoryStore;
|
class InventoryStore;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1315,8 +1315,8 @@ namespace MWMechanics
|
||||||
float bootWeight = 0;
|
float bootWeight = 0;
|
||||||
if (ptr.getClass().isNpc())
|
if (ptr.getClass().isNpc())
|
||||||
{
|
{
|
||||||
MWWorld::InventoryStore& inv = ptr.getClass().getInventoryStore(ptr);
|
const MWWorld::InventoryStore& inv = ptr.getClass().getInventoryStore(ptr);
|
||||||
MWWorld::ContainerStoreIterator it = inv.getSlot(MWWorld::InventoryStore::Slot_Boots);
|
MWWorld::ConstContainerStoreIterator it = inv.getSlot(MWWorld::InventoryStore::Slot_Boots);
|
||||||
if (it != inv.end())
|
if (it != inv.end())
|
||||||
bootWeight = it->getClass().getWeight(*it);
|
bootWeight = it->getClass().getWeight(*it);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,8 @@ ActorAnimation::ActorAnimation(const MWWorld::Ptr& ptr, osg::ref_ptr<osg::Group>
|
||||||
{
|
{
|
||||||
MWWorld::ContainerStore& store = mPtr.getClass().getContainerStore(mPtr);
|
MWWorld::ContainerStore& store = mPtr.getClass().getContainerStore(mPtr);
|
||||||
|
|
||||||
for (MWWorld::ContainerStoreIterator iter = store.begin(MWWorld::ContainerStore::Type_Light); iter != store.end(); ++iter)
|
for (MWWorld::ConstContainerStoreIterator iter = store.cbegin(MWWorld::ContainerStore::Type_Light);
|
||||||
|
iter != store.cend(); ++iter)
|
||||||
{
|
{
|
||||||
const ESM::Light* light = iter->get<ESM::Light>()->mBase;
|
const ESM::Light* light = iter->get<ESM::Light>()->mBase;
|
||||||
if (!(light->mData.mFlags & ESM::Light::Carry))
|
if (!(light->mData.mFlags & ESM::Light::Carry))
|
||||||
|
|
|
@ -305,7 +305,7 @@ namespace MWRender
|
||||||
mCurrentAnimGroup = groupname;
|
mCurrentAnimGroup = groupname;
|
||||||
mAnimation->play(mCurrentAnimGroup, 1, Animation::BlendMask_All, false, 1.0f, "start", "stop", 0.0f, 0);
|
mAnimation->play(mCurrentAnimGroup, 1, Animation::BlendMask_All, false, 1.0f, "start", "stop", 0.0f, 0);
|
||||||
|
|
||||||
MWWorld::ContainerStoreIterator torch = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedLeft);
|
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->getTypeName() == typeid(ESM::Light).name() && showCarriedLeft)
|
||||||
{
|
{
|
||||||
if(!mAnimation->getInfo("torch"))
|
if(!mAnimation->getInfo("torch"))
|
||||||
|
|
|
@ -97,15 +97,15 @@ void CreatureWeaponAnimation::updatePart(PartHolderPtr& scene, int slot)
|
||||||
if (!mObjectRoot)
|
if (!mObjectRoot)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
MWWorld::InventoryStore& inv = mPtr.getClass().getInventoryStore(mPtr);
|
const MWWorld::InventoryStore& inv = mPtr.getClass().getInventoryStore(mPtr);
|
||||||
MWWorld::ContainerStoreIterator it = inv.getSlot(slot);
|
MWWorld::ConstContainerStoreIterator it = inv.getSlot(slot);
|
||||||
|
|
||||||
if (it == inv.end())
|
if (it == inv.end())
|
||||||
{
|
{
|
||||||
scene.reset();
|
scene.reset();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MWWorld::Ptr item = *it;
|
MWWorld::ConstPtr item = *it;
|
||||||
|
|
||||||
std::string bonename;
|
std::string bonename;
|
||||||
if (slot == MWWorld::InventoryStore::Slot_CarriedRight)
|
if (slot == MWWorld::InventoryStore::Slot_CarriedRight)
|
||||||
|
@ -134,7 +134,7 @@ void CreatureWeaponAnimation::updatePart(PartHolderPtr& scene, int slot)
|
||||||
item.getTypeName() == typeid(ESM::Weapon).name() &&
|
item.getTypeName() == typeid(ESM::Weapon).name() &&
|
||||||
item.get<ESM::Weapon>()->mBase->mData.mType == ESM::Weapon::MarksmanCrossbow)
|
item.get<ESM::Weapon>()->mBase->mData.mType == ESM::Weapon::MarksmanCrossbow)
|
||||||
{
|
{
|
||||||
MWWorld::ContainerStoreIterator ammo = inv.getSlot(MWWorld::InventoryStore::Slot_Ammunition);
|
MWWorld::ConstContainerStoreIterator ammo = inv.getSlot(MWWorld::InventoryStore::Slot_Ammunition);
|
||||||
if (ammo != inv.end() && ammo->get<ESM::Weapon>()->mBase->mData.mType == ESM::Weapon::Bolt)
|
if (ammo != inv.end() && ammo->get<ESM::Weapon>()->mBase->mData.mType == ESM::Weapon::Bolt)
|
||||||
attachArrow();
|
attachArrow();
|
||||||
else
|
else
|
||||||
|
|
|
@ -558,10 +558,10 @@ void NpcAnimation::updateParts()
|
||||||
bool wasArrowAttached = (mAmmunition.get() != NULL);
|
bool wasArrowAttached = (mAmmunition.get() != NULL);
|
||||||
mAmmunition.reset();
|
mAmmunition.reset();
|
||||||
|
|
||||||
MWWorld::InventoryStore& inv = mPtr.getClass().getInventoryStore(mPtr);
|
const MWWorld::InventoryStore& inv = mPtr.getClass().getInventoryStore(mPtr);
|
||||||
for(size_t i = 0;i < slotlistsize && mViewMode != VM_HeadOnly;i++)
|
for(size_t i = 0;i < slotlistsize && mViewMode != VM_HeadOnly;i++)
|
||||||
{
|
{
|
||||||
MWWorld::ContainerStoreIterator store = inv.getSlot(slotlist[i].mSlot);
|
MWWorld::ConstContainerStoreIterator store = inv.getSlot(slotlist[i].mSlot);
|
||||||
|
|
||||||
removePartGroup(slotlist[i].mSlot);
|
removePartGroup(slotlist[i].mSlot);
|
||||||
|
|
||||||
|
@ -618,8 +618,8 @@ void NpcAnimation::updateParts()
|
||||||
|
|
||||||
if(mPartPriorities[ESM::PRT_Shield] < 1)
|
if(mPartPriorities[ESM::PRT_Shield] < 1)
|
||||||
{
|
{
|
||||||
MWWorld::ContainerStoreIterator store = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedLeft);
|
MWWorld::ConstContainerStoreIterator store = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedLeft);
|
||||||
MWWorld::Ptr part;
|
MWWorld::ConstPtr part;
|
||||||
if(store != inv.end() && (part=*store).getTypeName() == typeid(ESM::Light).name())
|
if(store != inv.end() && (part=*store).getTypeName() == typeid(ESM::Light).name())
|
||||||
{
|
{
|
||||||
const ESM::Light *light = part.get<ESM::Light>()->mBase;
|
const ESM::Light *light = part.get<ESM::Light>()->mBase;
|
||||||
|
@ -748,8 +748,8 @@ bool NpcAnimation::addOrReplaceIndividualPart(ESM::PartReferenceType type, int g
|
||||||
|
|
||||||
if (!mSoundsDisabled)
|
if (!mSoundsDisabled)
|
||||||
{
|
{
|
||||||
MWWorld::InventoryStore& inv = mPtr.getClass().getInventoryStore(mPtr);
|
const MWWorld::InventoryStore& inv = mPtr.getClass().getInventoryStore(mPtr);
|
||||||
MWWorld::ContainerStoreIterator csi = inv.getSlot(group < 0 ? MWWorld::InventoryStore::Slot_Helmet : group);
|
MWWorld::ConstContainerStoreIterator csi = inv.getSlot(group < 0 ? MWWorld::InventoryStore::Slot_Helmet : group);
|
||||||
if (csi != inv.end())
|
if (csi != inv.end())
|
||||||
{
|
{
|
||||||
mSoundIds[type] = csi->getClass().getSound(*csi);
|
mSoundIds[type] = csi->getClass().getSound(*csi);
|
||||||
|
@ -883,8 +883,8 @@ void NpcAnimation::showWeapons(bool showWeapon)
|
||||||
mAmmunition.reset();
|
mAmmunition.reset();
|
||||||
if(showWeapon)
|
if(showWeapon)
|
||||||
{
|
{
|
||||||
MWWorld::InventoryStore& inv = mPtr.getClass().getInventoryStore(mPtr);
|
const MWWorld::InventoryStore& inv = mPtr.getClass().getInventoryStore(mPtr);
|
||||||
MWWorld::ContainerStoreIterator weapon = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedRight);
|
MWWorld::ConstContainerStoreIterator weapon = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedRight);
|
||||||
if(weapon != inv.end())
|
if(weapon != inv.end())
|
||||||
{
|
{
|
||||||
osg::Vec4f glowColor = getEnchantmentColor(*weapon);
|
osg::Vec4f glowColor = getEnchantmentColor(*weapon);
|
||||||
|
@ -896,7 +896,7 @@ void NpcAnimation::showWeapons(bool showWeapon)
|
||||||
if (weapon->getTypeName() == typeid(ESM::Weapon).name() &&
|
if (weapon->getTypeName() == typeid(ESM::Weapon).name() &&
|
||||||
weapon->get<ESM::Weapon>()->mBase->mData.mType == ESM::Weapon::MarksmanCrossbow)
|
weapon->get<ESM::Weapon>()->mBase->mData.mType == ESM::Weapon::MarksmanCrossbow)
|
||||||
{
|
{
|
||||||
MWWorld::ContainerStoreIterator ammo = inv.getSlot(MWWorld::InventoryStore::Slot_Ammunition);
|
MWWorld::ConstContainerStoreIterator ammo = inv.getSlot(MWWorld::InventoryStore::Slot_Ammunition);
|
||||||
if (ammo != inv.end() && ammo->get<ESM::Weapon>()->mBase->mData.mType == ESM::Weapon::Bolt)
|
if (ammo != inv.end() && ammo->get<ESM::Weapon>()->mBase->mData.mType == ESM::Weapon::Bolt)
|
||||||
attachArrow();
|
attachArrow();
|
||||||
}
|
}
|
||||||
|
@ -911,8 +911,8 @@ void NpcAnimation::showWeapons(bool showWeapon)
|
||||||
void NpcAnimation::showCarriedLeft(bool show)
|
void NpcAnimation::showCarriedLeft(bool show)
|
||||||
{
|
{
|
||||||
mShowCarriedLeft = show;
|
mShowCarriedLeft = show;
|
||||||
MWWorld::InventoryStore& inv = mPtr.getClass().getInventoryStore(mPtr);
|
const MWWorld::InventoryStore& inv = mPtr.getClass().getInventoryStore(mPtr);
|
||||||
MWWorld::ContainerStoreIterator iter = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedLeft);
|
MWWorld::ConstContainerStoreIterator iter = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedLeft);
|
||||||
if(show && iter != inv.end())
|
if(show && iter != inv.end())
|
||||||
{
|
{
|
||||||
osg::Vec4f glowColor = getEnchantmentColor(*iter);
|
osg::Vec4f glowColor = getEnchantmentColor(*iter);
|
||||||
|
|
|
@ -56,8 +56,8 @@ WeaponAnimation::~WeaponAnimation()
|
||||||
|
|
||||||
void WeaponAnimation::attachArrow(MWWorld::Ptr actor)
|
void WeaponAnimation::attachArrow(MWWorld::Ptr actor)
|
||||||
{
|
{
|
||||||
MWWorld::InventoryStore& inv = actor.getClass().getInventoryStore(actor);
|
const MWWorld::InventoryStore& inv = actor.getClass().getInventoryStore(actor);
|
||||||
MWWorld::ContainerStoreIterator weaponSlot = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedRight);
|
MWWorld::ConstContainerStoreIterator weaponSlot = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedRight);
|
||||||
if (weaponSlot == inv.end())
|
if (weaponSlot == inv.end())
|
||||||
return;
|
return;
|
||||||
if (weaponSlot->getTypeName() != typeid(ESM::Weapon).name())
|
if (weaponSlot->getTypeName() != typeid(ESM::Weapon).name())
|
||||||
|
@ -79,7 +79,7 @@ void WeaponAnimation::attachArrow(MWWorld::Ptr actor)
|
||||||
if (!parent)
|
if (!parent)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
MWWorld::ContainerStoreIterator ammo = inv.getSlot(MWWorld::InventoryStore::Slot_Ammunition);
|
MWWorld::ConstContainerStoreIterator ammo = inv.getSlot(MWWorld::InventoryStore::Slot_Ammunition);
|
||||||
if (ammo == inv.end())
|
if (ammo == inv.end())
|
||||||
return;
|
return;
|
||||||
std::string model = ammo->getClass().getModel(*ammo);
|
std::string model = ammo->getClass().getModel(*ammo);
|
||||||
|
|
|
@ -154,7 +154,7 @@ namespace MWScript
|
||||||
MWWorld::ContainerStore& store = ptr.getClass().getContainerStore (ptr);
|
MWWorld::ContainerStore& store = ptr.getClass().getContainerStore (ptr);
|
||||||
|
|
||||||
std::string itemName;
|
std::string itemName;
|
||||||
for (MWWorld::ContainerStoreIterator iter(store.begin()); iter != store.end(); ++iter)
|
for (MWWorld::ConstContainerStoreIterator iter(store.cbegin()); iter != store.cend(); ++iter)
|
||||||
if (::Misc::StringUtils::ciEqual(iter->getCellRef().getRefId(), item))
|
if (::Misc::StringUtils::ciEqual(iter->getCellRef().getRefId(), item))
|
||||||
itemName = iter->getClass().getName(*iter);
|
itemName = iter->getClass().getName(*iter);
|
||||||
|
|
||||||
|
@ -270,9 +270,9 @@ namespace MWScript
|
||||||
throw std::runtime_error ("armor index out of range");
|
throw std::runtime_error ("armor index out of range");
|
||||||
}
|
}
|
||||||
|
|
||||||
MWWorld::InventoryStore& invStore = ptr.getClass().getInventoryStore (ptr);
|
const MWWorld::InventoryStore& invStore = ptr.getClass().getInventoryStore (ptr);
|
||||||
|
MWWorld::ConstContainerStoreIterator it = invStore.getSlot (slot);
|
||||||
|
|
||||||
MWWorld::ContainerStoreIterator it = invStore.getSlot (slot);
|
|
||||||
if (it == invStore.end() || it->getTypeName () != typeid(ESM::Armor).name())
|
if (it == invStore.end() || it->getTypeName () != typeid(ESM::Armor).name())
|
||||||
{
|
{
|
||||||
runtime.push(-1);
|
runtime.push(-1);
|
||||||
|
@ -303,10 +303,10 @@ namespace MWScript
|
||||||
std::string item = runtime.getStringLiteral (runtime[0].mInteger);
|
std::string item = runtime.getStringLiteral (runtime[0].mInteger);
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
MWWorld::InventoryStore& invStore = ptr.getClass().getInventoryStore (ptr);
|
const MWWorld::InventoryStore& invStore = ptr.getClass().getInventoryStore (ptr);
|
||||||
for (int slot = 0; slot < MWWorld::InventoryStore::Slots; ++slot)
|
for (int slot = 0; slot < MWWorld::InventoryStore::Slots; ++slot)
|
||||||
{
|
{
|
||||||
MWWorld::ContainerStoreIterator it = invStore.getSlot (slot);
|
MWWorld::ConstContainerStoreIterator it = invStore.getSlot (slot);
|
||||||
if (it != invStore.end() && ::Misc::StringUtils::ciEqual(it->getCellRef().getRefId(), item))
|
if (it != invStore.end() && ::Misc::StringUtils::ciEqual(it->getCellRef().getRefId(), item))
|
||||||
{
|
{
|
||||||
runtime.push(1);
|
runtime.push(1);
|
||||||
|
@ -330,9 +330,9 @@ namespace MWScript
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
MWWorld::InventoryStore& invStore = ptr.getClass().getInventoryStore (ptr);
|
const MWWorld::InventoryStore& invStore = ptr.getClass().getInventoryStore (ptr);
|
||||||
for (MWWorld::ContainerStoreIterator it = invStore.begin(MWWorld::ContainerStore::Type_Miscellaneous);
|
for (MWWorld::ConstContainerStoreIterator it = invStore.cbegin(MWWorld::ContainerStore::Type_Miscellaneous);
|
||||||
it != invStore.end(); ++it)
|
it != invStore.cend(); ++it)
|
||||||
{
|
{
|
||||||
if (::Misc::StringUtils::ciEqual(it->getCellRef().getSoul(), name))
|
if (::Misc::StringUtils::ciEqual(it->getCellRef().getSoul(), name))
|
||||||
count += it->getRefData().getCount();
|
count += it->getRefData().getCount();
|
||||||
|
@ -350,8 +350,8 @@ namespace MWScript
|
||||||
{
|
{
|
||||||
MWWorld::Ptr ptr = R()(runtime);
|
MWWorld::Ptr ptr = R()(runtime);
|
||||||
|
|
||||||
MWWorld::InventoryStore& invStore = ptr.getClass().getInventoryStore (ptr);
|
const MWWorld::InventoryStore& invStore = ptr.getClass().getInventoryStore (ptr);
|
||||||
MWWorld::ContainerStoreIterator it = invStore.getSlot (MWWorld::InventoryStore::Slot_CarriedRight);
|
MWWorld::ConstContainerStoreIterator it = invStore.getSlot (MWWorld::InventoryStore::Slot_CarriedRight);
|
||||||
if (it == invStore.end() || it->getTypeName () != typeid(ESM::Weapon).name())
|
if (it == invStore.end() || it->getTypeName () != typeid(ESM::Weapon).name())
|
||||||
{
|
{
|
||||||
runtime.push(-1);
|
runtime.push(-1);
|
||||||
|
|
|
@ -580,7 +580,7 @@ namespace MWScript
|
||||||
int numNotEquipped = invStorePtr->count(item);
|
int numNotEquipped = invStorePtr->count(item);
|
||||||
for (int slot = 0; slot < MWWorld::InventoryStore::Slots; ++slot)
|
for (int slot = 0; slot < MWWorld::InventoryStore::Slots; ++slot)
|
||||||
{
|
{
|
||||||
MWWorld::ContainerStoreIterator it = invStorePtr->getSlot (slot);
|
MWWorld::ConstContainerStoreIterator it = invStorePtr->getSlot (slot);
|
||||||
if (it != invStorePtr->end() && ::Misc::StringUtils::ciEqual(it->getCellRef().getRefId(), item))
|
if (it != invStorePtr->end() && ::Misc::StringUtils::ciEqual(it->getCellRef().getRefId(), item))
|
||||||
{
|
{
|
||||||
numNotEquipped -= it->getRefData().getCount();
|
numNotEquipped -= it->getRefData().getCount();
|
||||||
|
|
|
@ -117,6 +117,26 @@ MWWorld::ContainerStore::ContainerStore() : mListener(NULL), mCachedWeight (0),
|
||||||
|
|
||||||
MWWorld::ContainerStore::~ContainerStore() {}
|
MWWorld::ContainerStore::~ContainerStore() {}
|
||||||
|
|
||||||
|
MWWorld::ConstContainerStoreIterator MWWorld::ContainerStore::cbegin (int mask) const
|
||||||
|
{
|
||||||
|
return ConstContainerStoreIterator (mask, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
MWWorld::ConstContainerStoreIterator MWWorld::ContainerStore::cend() const
|
||||||
|
{
|
||||||
|
return ConstContainerStoreIterator (this);
|
||||||
|
}
|
||||||
|
|
||||||
|
MWWorld::ConstContainerStoreIterator MWWorld::ContainerStore::begin (int mask) const
|
||||||
|
{
|
||||||
|
return cbegin(mask);
|
||||||
|
}
|
||||||
|
|
||||||
|
MWWorld::ConstContainerStoreIterator MWWorld::ContainerStore::end() const
|
||||||
|
{
|
||||||
|
return cend();
|
||||||
|
}
|
||||||
|
|
||||||
MWWorld::ContainerStoreIterator MWWorld::ContainerStore::begin (int mask)
|
MWWorld::ContainerStoreIterator MWWorld::ContainerStore::begin (int mask)
|
||||||
{
|
{
|
||||||
return ContainerStoreIterator (mask, this);
|
return ContainerStoreIterator (mask, this);
|
||||||
|
@ -189,7 +209,7 @@ MWWorld::ContainerStoreIterator MWWorld::ContainerStore::restack(const MWWorld::
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MWWorld::ContainerStore::stacks(const ConstPtr& ptr1, const ConstPtr& ptr2)
|
bool MWWorld::ContainerStore::stacks(const ConstPtr& ptr1, const ConstPtr& ptr2) const
|
||||||
{
|
{
|
||||||
const MWWorld::Class& cls1 = ptr1.getClass();
|
const MWWorld::Class& cls1 = ptr1.getClass();
|
||||||
const MWWorld::Class& cls2 = ptr2.getClass();
|
const MWWorld::Class& cls2 = ptr2.getClass();
|
||||||
|
@ -788,53 +808,36 @@ void MWWorld::ContainerStore::readState (const ESM::InventoryState& inventory)
|
||||||
mLevelledItemMap = inventory.mLevelledItemMap;
|
mLevelledItemMap = inventory.mLevelledItemMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<class PtrType>
|
||||||
MWWorld::ContainerStoreIterator::ContainerStoreIterator (ContainerStore *container)
|
template<class T>
|
||||||
: mType (-1), mMask (0), mContainer (container)
|
void MWWorld::ContainerStoreIteratorBase<PtrType>::copy (const ContainerStoreIteratorBase<T>& src)
|
||||||
{}
|
|
||||||
|
|
||||||
MWWorld::ContainerStoreIterator::ContainerStoreIterator (int mask, ContainerStore *container)
|
|
||||||
: mType (0), mMask (mask), mContainer (container)
|
|
||||||
{
|
{
|
||||||
nextType();
|
mType = src.mType;
|
||||||
|
mMask = src.mMask;
|
||||||
|
mContainer = src.mContainer;
|
||||||
|
mPtr = src.mPtr;
|
||||||
|
|
||||||
if (mType==-1 || (**this).getRefData().getCount())
|
switch (src.mType)
|
||||||
return;
|
{
|
||||||
|
case MWWorld::ContainerStore::Type_Potion: mPotion = src.mPotion; break;
|
||||||
++*this;
|
case MWWorld::ContainerStore::Type_Apparatus: mApparatus = src.mApparatus; break;
|
||||||
|
case MWWorld::ContainerStore::Type_Armor: mArmor = src.mArmor; break;
|
||||||
|
case MWWorld::ContainerStore::Type_Book: mBook = src.mBook; break;
|
||||||
|
case MWWorld::ContainerStore::Type_Clothing: mClothing = src.mClothing; break;
|
||||||
|
case MWWorld::ContainerStore::Type_Ingredient: mIngredient = src.mIngredient; break;
|
||||||
|
case MWWorld::ContainerStore::Type_Light: mLight = src.mLight; break;
|
||||||
|
case MWWorld::ContainerStore::Type_Lockpick: mLockpick = src.mLockpick; break;
|
||||||
|
case MWWorld::ContainerStore::Type_Miscellaneous: mMiscellaneous = src.mMiscellaneous; break;
|
||||||
|
case MWWorld::ContainerStore::Type_Probe: mProbe = src.mProbe; break;
|
||||||
|
case MWWorld::ContainerStore::Type_Repair: mRepair = src.mRepair; break;
|
||||||
|
case MWWorld::ContainerStore::Type_Weapon: mWeapon = src.mWeapon; break;
|
||||||
|
case -1: break;
|
||||||
|
default: assert(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MWWorld::ContainerStoreIterator::ContainerStoreIterator (ContainerStore *container, MWWorld::CellRefList<ESM::Potion>::List::iterator iterator)
|
template<class PtrType>
|
||||||
: mType(MWWorld::ContainerStore::Type_Potion), mMask(MWWorld::ContainerStore::Type_All), mContainer(container), mPotion(iterator){}
|
void MWWorld::ContainerStoreIteratorBase<PtrType>::incType()
|
||||||
MWWorld::ContainerStoreIterator::ContainerStoreIterator (ContainerStore *container, MWWorld::CellRefList<ESM::Apparatus>::List::iterator iterator)
|
|
||||||
: mType(MWWorld::ContainerStore::Type_Apparatus), mMask(MWWorld::ContainerStore::Type_All), mContainer(container), mApparatus(iterator){}
|
|
||||||
MWWorld::ContainerStoreIterator::ContainerStoreIterator (ContainerStore *container, MWWorld::CellRefList<ESM::Armor>::List::iterator iterator)
|
|
||||||
: mType(MWWorld::ContainerStore::Type_Armor), mMask(MWWorld::ContainerStore::Type_All), mContainer(container), mArmor(iterator){}
|
|
||||||
MWWorld::ContainerStoreIterator::ContainerStoreIterator (ContainerStore *container, MWWorld::CellRefList<ESM::Book>::List::iterator iterator)
|
|
||||||
: mType(MWWorld::ContainerStore::Type_Book), mMask(MWWorld::ContainerStore::Type_All), mContainer(container), mBook(iterator){}
|
|
||||||
MWWorld::ContainerStoreIterator::ContainerStoreIterator (ContainerStore *container, MWWorld::CellRefList<ESM::Clothing>::List::iterator iterator)
|
|
||||||
: mType(MWWorld::ContainerStore::Type_Clothing), mMask(MWWorld::ContainerStore::Type_All), mContainer(container), mClothing(iterator){}
|
|
||||||
MWWorld::ContainerStoreIterator::ContainerStoreIterator (ContainerStore *container, MWWorld::CellRefList<ESM::Ingredient>::List::iterator iterator)
|
|
||||||
: mType(MWWorld::ContainerStore::Type_Ingredient), mMask(MWWorld::ContainerStore::Type_All), mContainer(container), mIngredient(iterator){}
|
|
||||||
MWWorld::ContainerStoreIterator::ContainerStoreIterator (ContainerStore *container, MWWorld::CellRefList<ESM::Light>::List::iterator iterator)
|
|
||||||
: mType(MWWorld::ContainerStore::Type_Light), mMask(MWWorld::ContainerStore::Type_All), mContainer(container), mLight(iterator){}
|
|
||||||
MWWorld::ContainerStoreIterator::ContainerStoreIterator (ContainerStore *container, MWWorld::CellRefList<ESM::Lockpick>::List::iterator iterator)
|
|
||||||
: mType(MWWorld::ContainerStore::Type_Lockpick), mMask(MWWorld::ContainerStore::Type_All), mContainer(container), mLockpick(iterator){}
|
|
||||||
MWWorld::ContainerStoreIterator::ContainerStoreIterator (ContainerStore *container, MWWorld::CellRefList<ESM::Miscellaneous>::List::iterator iterator)
|
|
||||||
: mType(MWWorld::ContainerStore::Type_Miscellaneous), mMask(MWWorld::ContainerStore::Type_All), mContainer(container), mMiscellaneous(iterator){}
|
|
||||||
MWWorld::ContainerStoreIterator::ContainerStoreIterator (ContainerStore *container, MWWorld::CellRefList<ESM::Probe>::List::iterator iterator)
|
|
||||||
: mType(MWWorld::ContainerStore::Type_Probe), mMask(MWWorld::ContainerStore::Type_All), mContainer(container), mProbe(iterator){}
|
|
||||||
MWWorld::ContainerStoreIterator::ContainerStoreIterator (ContainerStore *container, MWWorld::CellRefList<ESM::Repair>::List::iterator iterator)
|
|
||||||
: mType(MWWorld::ContainerStore::Type_Repair), mMask(MWWorld::ContainerStore::Type_All), mContainer(container), mRepair(iterator){}
|
|
||||||
MWWorld::ContainerStoreIterator::ContainerStoreIterator (ContainerStore *container, MWWorld::CellRefList<ESM::Weapon>::List::iterator iterator)
|
|
||||||
: mType(MWWorld::ContainerStore::Type_Weapon), mMask(MWWorld::ContainerStore::Type_All), mContainer(container), mWeapon(iterator){}
|
|
||||||
|
|
||||||
MWWorld::ContainerStoreIterator::ContainerStoreIterator( const ContainerStoreIterator& src )
|
|
||||||
{
|
|
||||||
copy(src);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MWWorld::ContainerStoreIterator::incType()
|
|
||||||
{
|
{
|
||||||
if (mType==0)
|
if (mType==0)
|
||||||
mType = 1;
|
mType = 1;
|
||||||
|
@ -847,7 +850,8 @@ void MWWorld::ContainerStoreIterator::incType()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MWWorld::ContainerStoreIterator::nextType()
|
template<class PtrType>
|
||||||
|
void MWWorld::ContainerStoreIteratorBase<PtrType>::nextType()
|
||||||
{
|
{
|
||||||
while (mType!=-1)
|
while (mType!=-1)
|
||||||
{
|
{
|
||||||
|
@ -859,7 +863,8 @@ void MWWorld::ContainerStoreIterator::nextType()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MWWorld::ContainerStoreIterator::resetIterator()
|
template<class PtrType>
|
||||||
|
bool MWWorld::ContainerStoreIteratorBase<PtrType>::resetIterator()
|
||||||
{
|
{
|
||||||
switch (mType)
|
switch (mType)
|
||||||
{
|
{
|
||||||
|
@ -927,7 +932,8 @@ bool MWWorld::ContainerStoreIterator::resetIterator()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MWWorld::ContainerStoreIterator::incIterator()
|
template<class PtrType>
|
||||||
|
bool MWWorld::ContainerStoreIteratorBase<PtrType>::incIterator()
|
||||||
{
|
{
|
||||||
switch (mType)
|
switch (mType)
|
||||||
{
|
{
|
||||||
|
@ -995,30 +1001,63 @@ bool MWWorld::ContainerStoreIterator::incIterator()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
MWWorld::Ptr *MWWorld::ContainerStoreIterator::operator->() const
|
|
||||||
|
template<class PtrType>
|
||||||
|
template<class T>
|
||||||
|
bool MWWorld::ContainerStoreIteratorBase<PtrType>::isEqual (const ContainerStoreIteratorBase<T>& other) const
|
||||||
|
{
|
||||||
|
if (mContainer!=other.mContainer)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (mType!=other.mType)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
switch (mType)
|
||||||
|
{
|
||||||
|
case ContainerStore::Type_Potion: return mPotion==other.mPotion;
|
||||||
|
case ContainerStore::Type_Apparatus: return mApparatus==other.mApparatus;
|
||||||
|
case ContainerStore::Type_Armor: return mArmor==other.mArmor;
|
||||||
|
case ContainerStore::Type_Book: return mBook==other.mBook;
|
||||||
|
case ContainerStore::Type_Clothing: return mClothing==other.mClothing;
|
||||||
|
case ContainerStore::Type_Ingredient: return mIngredient==other.mIngredient;
|
||||||
|
case ContainerStore::Type_Light: return mLight==other.mLight;
|
||||||
|
case ContainerStore::Type_Lockpick: return mLockpick==other.mLockpick;
|
||||||
|
case ContainerStore::Type_Miscellaneous: return mMiscellaneous==other.mMiscellaneous;
|
||||||
|
case ContainerStore::Type_Probe: return mProbe==other.mProbe;
|
||||||
|
case ContainerStore::Type_Repair: return mRepair==other.mRepair;
|
||||||
|
case ContainerStore::Type_Weapon: return mWeapon==other.mWeapon;
|
||||||
|
case -1: return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class PtrType>
|
||||||
|
PtrType *MWWorld::ContainerStoreIteratorBase<PtrType>::operator->() const
|
||||||
{
|
{
|
||||||
mPtr = **this;
|
mPtr = **this;
|
||||||
return &mPtr;
|
return &mPtr;
|
||||||
}
|
}
|
||||||
|
|
||||||
MWWorld::Ptr MWWorld::ContainerStoreIterator::operator*() const
|
template<class PtrType>
|
||||||
|
PtrType MWWorld::ContainerStoreIteratorBase<PtrType>::operator*() const
|
||||||
{
|
{
|
||||||
Ptr ptr;
|
PtrType ptr;
|
||||||
|
|
||||||
switch (mType)
|
switch (mType)
|
||||||
{
|
{
|
||||||
case ContainerStore::Type_Potion: ptr = MWWorld::Ptr (&*mPotion, 0); break;
|
case ContainerStore::Type_Potion: ptr = PtrType (&*mPotion, 0); break;
|
||||||
case ContainerStore::Type_Apparatus: ptr = MWWorld::Ptr (&*mApparatus, 0); break;
|
case ContainerStore::Type_Apparatus: ptr = PtrType (&*mApparatus, 0); break;
|
||||||
case ContainerStore::Type_Armor: ptr = MWWorld::Ptr (&*mArmor, 0); break;
|
case ContainerStore::Type_Armor: ptr = PtrType (&*mArmor, 0); break;
|
||||||
case ContainerStore::Type_Book: ptr = MWWorld::Ptr (&*mBook, 0); break;
|
case ContainerStore::Type_Book: ptr = PtrType (&*mBook, 0); break;
|
||||||
case ContainerStore::Type_Clothing: ptr = MWWorld::Ptr (&*mClothing, 0); break;
|
case ContainerStore::Type_Clothing: ptr = PtrType (&*mClothing, 0); break;
|
||||||
case ContainerStore::Type_Ingredient: ptr = MWWorld::Ptr (&*mIngredient, 0); break;
|
case ContainerStore::Type_Ingredient: ptr = PtrType (&*mIngredient, 0); break;
|
||||||
case ContainerStore::Type_Light: ptr = MWWorld::Ptr (&*mLight, 0); break;
|
case ContainerStore::Type_Light: ptr = PtrType (&*mLight, 0); break;
|
||||||
case ContainerStore::Type_Lockpick: ptr = MWWorld::Ptr (&*mLockpick, 0); break;
|
case ContainerStore::Type_Lockpick: ptr = PtrType (&*mLockpick, 0); break;
|
||||||
case ContainerStore::Type_Miscellaneous: ptr = MWWorld::Ptr (&*mMiscellaneous, 0); break;
|
case ContainerStore::Type_Miscellaneous: ptr = PtrType (&*mMiscellaneous, 0); break;
|
||||||
case ContainerStore::Type_Probe: ptr = MWWorld::Ptr (&*mProbe, 0); break;
|
case ContainerStore::Type_Probe: ptr = PtrType (&*mProbe, 0); break;
|
||||||
case ContainerStore::Type_Repair: ptr = MWWorld::Ptr (&*mRepair, 0); break;
|
case ContainerStore::Type_Repair: ptr = PtrType (&*mRepair, 0); break;
|
||||||
case ContainerStore::Type_Weapon: ptr = MWWorld::Ptr (&*mWeapon, 0); break;
|
case ContainerStore::Type_Weapon: ptr = PtrType (&*mWeapon, 0); break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ptr.isEmpty())
|
if (ptr.isEmpty())
|
||||||
|
@ -1029,7 +1068,8 @@ MWWorld::Ptr MWWorld::ContainerStoreIterator::operator*() const
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
MWWorld::ContainerStoreIterator& MWWorld::ContainerStoreIterator::operator++()
|
template<class PtrType>
|
||||||
|
MWWorld::ContainerStoreIteratorBase<PtrType>& MWWorld::ContainerStoreIteratorBase<PtrType>::operator++()
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
@ -1041,78 +1081,16 @@ MWWorld::ContainerStoreIterator& MWWorld::ContainerStoreIterator::operator++()
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
MWWorld::ContainerStoreIterator MWWorld::ContainerStoreIterator::operator++ (int)
|
template<class PtrType>
|
||||||
|
MWWorld::ContainerStoreIteratorBase<PtrType> MWWorld::ContainerStoreIteratorBase<PtrType>::operator++ (int)
|
||||||
{
|
{
|
||||||
ContainerStoreIterator iter (*this);
|
ContainerStoreIteratorBase<PtrType> iter (*this);
|
||||||
++*this;
|
++*this;
|
||||||
return iter;
|
return iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MWWorld::ContainerStoreIterator::isEqual (const ContainerStoreIterator& iter) const
|
template<class PtrType>
|
||||||
{
|
MWWorld::ContainerStoreIteratorBase<PtrType>& MWWorld::ContainerStoreIteratorBase<PtrType>::operator= (const ContainerStoreIteratorBase<PtrType>& rhs)
|
||||||
if (mContainer!=iter.mContainer)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (mType!=iter.mType)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
switch (mType)
|
|
||||||
{
|
|
||||||
case ContainerStore::Type_Potion: return mPotion==iter.mPotion;
|
|
||||||
case ContainerStore::Type_Apparatus: return mApparatus==iter.mApparatus;
|
|
||||||
case ContainerStore::Type_Armor: return mArmor==iter.mArmor;
|
|
||||||
case ContainerStore::Type_Book: return mBook==iter.mBook;
|
|
||||||
case ContainerStore::Type_Clothing: return mClothing==iter.mClothing;
|
|
||||||
case ContainerStore::Type_Ingredient: return mIngredient==iter.mIngredient;
|
|
||||||
case ContainerStore::Type_Light: return mLight==iter.mLight;
|
|
||||||
case ContainerStore::Type_Lockpick: return mLockpick==iter.mLockpick;
|
|
||||||
case ContainerStore::Type_Miscellaneous: return mMiscellaneous==iter.mMiscellaneous;
|
|
||||||
case ContainerStore::Type_Probe: return mProbe==iter.mProbe;
|
|
||||||
case ContainerStore::Type_Repair: return mRepair==iter.mRepair;
|
|
||||||
case ContainerStore::Type_Weapon: return mWeapon==iter.mWeapon;
|
|
||||||
case -1: return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
int MWWorld::ContainerStoreIterator::getType() const
|
|
||||||
{
|
|
||||||
return mType;
|
|
||||||
}
|
|
||||||
|
|
||||||
const MWWorld::ContainerStore *MWWorld::ContainerStoreIterator::getContainerStore() const
|
|
||||||
{
|
|
||||||
return mContainer;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MWWorld::ContainerStoreIterator::copy(const ContainerStoreIterator& src)
|
|
||||||
{
|
|
||||||
mType = src.mType;
|
|
||||||
mMask = src.mMask;
|
|
||||||
mContainer = src.mContainer;
|
|
||||||
mPtr = src.mPtr;
|
|
||||||
|
|
||||||
switch (mType)
|
|
||||||
{
|
|
||||||
case MWWorld::ContainerStore::Type_Potion: mPotion = src.mPotion; break;
|
|
||||||
case MWWorld::ContainerStore::Type_Apparatus: mApparatus = src.mApparatus; break;
|
|
||||||
case MWWorld::ContainerStore::Type_Armor: mArmor = src.mArmor; break;
|
|
||||||
case MWWorld::ContainerStore::Type_Book: mBook = src.mBook; break;
|
|
||||||
case MWWorld::ContainerStore::Type_Clothing: mClothing = src.mClothing; break;
|
|
||||||
case MWWorld::ContainerStore::Type_Ingredient: mIngredient = src.mIngredient; break;
|
|
||||||
case MWWorld::ContainerStore::Type_Light: mLight = src.mLight; break;
|
|
||||||
case MWWorld::ContainerStore::Type_Lockpick: mLockpick = src.mLockpick; break;
|
|
||||||
case MWWorld::ContainerStore::Type_Miscellaneous: mMiscellaneous = src.mMiscellaneous; break;
|
|
||||||
case MWWorld::ContainerStore::Type_Probe: mProbe = src.mProbe; break;
|
|
||||||
case MWWorld::ContainerStore::Type_Repair: mRepair = src.mRepair; break;
|
|
||||||
case MWWorld::ContainerStore::Type_Weapon: mWeapon = src.mWeapon; break;
|
|
||||||
case -1: break;
|
|
||||||
default: assert(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MWWorld::ContainerStoreIterator& MWWorld::ContainerStoreIterator::operator=( const ContainerStoreIterator& rhs )
|
|
||||||
{
|
{
|
||||||
if (this!=&rhs)
|
if (this!=&rhs)
|
||||||
{
|
{
|
||||||
|
@ -1121,12 +1099,108 @@ MWWorld::ContainerStoreIterator& MWWorld::ContainerStoreIterator::operator=( con
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MWWorld::operator== (const ContainerStoreIterator& left, const ContainerStoreIterator& right)
|
template<class PtrType>
|
||||||
|
int MWWorld::ContainerStoreIteratorBase<PtrType>::getType() const
|
||||||
|
{
|
||||||
|
return mType;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class PtrType>
|
||||||
|
const MWWorld::ContainerStore *MWWorld::ContainerStoreIteratorBase<PtrType>::getContainerStore() const
|
||||||
|
{
|
||||||
|
return mContainer;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class PtrType>
|
||||||
|
MWWorld::ContainerStoreIteratorBase<PtrType>::ContainerStoreIteratorBase (ContainerStoreType container)
|
||||||
|
: mType (-1), mMask (0), mContainer (container)
|
||||||
|
{}
|
||||||
|
|
||||||
|
template<class PtrType>
|
||||||
|
MWWorld::ContainerStoreIteratorBase<PtrType>::ContainerStoreIteratorBase (int mask, ContainerStoreType container)
|
||||||
|
: mType (0), mMask (mask), mContainer (container)
|
||||||
|
{
|
||||||
|
nextType();
|
||||||
|
|
||||||
|
if (mType==-1 || (**this).getRefData().getCount())
|
||||||
|
return;
|
||||||
|
|
||||||
|
++*this;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class PtrType>
|
||||||
|
MWWorld::ContainerStoreIteratorBase<PtrType>::ContainerStoreIteratorBase (ContainerStoreType container, typename Iterator<ESM::Potion>::type iterator)
|
||||||
|
: mType(MWWorld::ContainerStore::Type_Potion), mMask(MWWorld::ContainerStore::Type_All), mContainer(container), mPotion(iterator){}
|
||||||
|
|
||||||
|
template<class PtrType>
|
||||||
|
MWWorld::ContainerStoreIteratorBase<PtrType>::ContainerStoreIteratorBase (ContainerStoreType container, typename Iterator<ESM::Apparatus>::type iterator)
|
||||||
|
: mType(MWWorld::ContainerStore::Type_Apparatus), mMask(MWWorld::ContainerStore::Type_All), mContainer(container), mApparatus(iterator){}
|
||||||
|
|
||||||
|
template<class PtrType>
|
||||||
|
MWWorld::ContainerStoreIteratorBase<PtrType>::ContainerStoreIteratorBase (ContainerStoreType container, typename Iterator<ESM::Armor>::type iterator)
|
||||||
|
: mType(MWWorld::ContainerStore::Type_Armor), mMask(MWWorld::ContainerStore::Type_All), mContainer(container), mArmor(iterator){}
|
||||||
|
|
||||||
|
template<class PtrType>
|
||||||
|
MWWorld::ContainerStoreIteratorBase<PtrType>::ContainerStoreIteratorBase (ContainerStoreType container, typename Iterator<ESM::Book>::type iterator)
|
||||||
|
: mType(MWWorld::ContainerStore::Type_Book), mMask(MWWorld::ContainerStore::Type_All), mContainer(container), mBook(iterator){}
|
||||||
|
|
||||||
|
template<class PtrType>
|
||||||
|
MWWorld::ContainerStoreIteratorBase<PtrType>::ContainerStoreIteratorBase (ContainerStoreType container, typename Iterator<ESM::Clothing>::type iterator)
|
||||||
|
: mType(MWWorld::ContainerStore::Type_Clothing), mMask(MWWorld::ContainerStore::Type_All), mContainer(container), mClothing(iterator){}
|
||||||
|
|
||||||
|
template<class PtrType>
|
||||||
|
MWWorld::ContainerStoreIteratorBase<PtrType>::ContainerStoreIteratorBase (ContainerStoreType container, typename Iterator<ESM::Ingredient>::type iterator)
|
||||||
|
: mType(MWWorld::ContainerStore::Type_Ingredient), mMask(MWWorld::ContainerStore::Type_All), mContainer(container), mIngredient(iterator){}
|
||||||
|
|
||||||
|
template<class PtrType>
|
||||||
|
MWWorld::ContainerStoreIteratorBase<PtrType>::ContainerStoreIteratorBase (ContainerStoreType container, typename Iterator<ESM::Light>::type iterator)
|
||||||
|
: mType(MWWorld::ContainerStore::Type_Light), mMask(MWWorld::ContainerStore::Type_All), mContainer(container), mLight(iterator){}
|
||||||
|
|
||||||
|
template<class PtrType>
|
||||||
|
MWWorld::ContainerStoreIteratorBase<PtrType>::ContainerStoreIteratorBase (ContainerStoreType container, typename Iterator<ESM::Lockpick>::type iterator)
|
||||||
|
: mType(MWWorld::ContainerStore::Type_Lockpick), mMask(MWWorld::ContainerStore::Type_All), mContainer(container), mLockpick(iterator){}
|
||||||
|
|
||||||
|
template<class PtrType>
|
||||||
|
MWWorld::ContainerStoreIteratorBase<PtrType>::ContainerStoreIteratorBase (ContainerStoreType container, typename Iterator<ESM::Miscellaneous>::type iterator)
|
||||||
|
: mType(MWWorld::ContainerStore::Type_Miscellaneous), mMask(MWWorld::ContainerStore::Type_All), mContainer(container), mMiscellaneous(iterator){}
|
||||||
|
|
||||||
|
template<class PtrType>
|
||||||
|
MWWorld::ContainerStoreIteratorBase<PtrType>::ContainerStoreIteratorBase (ContainerStoreType container, typename Iterator<ESM::Probe>::type iterator)
|
||||||
|
: mType(MWWorld::ContainerStore::Type_Probe), mMask(MWWorld::ContainerStore::Type_All), mContainer(container), mProbe(iterator){}
|
||||||
|
|
||||||
|
template<class PtrType>
|
||||||
|
MWWorld::ContainerStoreIteratorBase<PtrType>::ContainerStoreIteratorBase (ContainerStoreType container, typename Iterator<ESM::Repair>::type iterator)
|
||||||
|
: mType(MWWorld::ContainerStore::Type_Repair), mMask(MWWorld::ContainerStore::Type_All), mContainer(container), mRepair(iterator){}
|
||||||
|
|
||||||
|
template<class PtrType>
|
||||||
|
MWWorld::ContainerStoreIteratorBase<PtrType>::ContainerStoreIteratorBase (ContainerStoreType container, typename Iterator<ESM::Weapon>::type iterator)
|
||||||
|
: mType(MWWorld::ContainerStore::Type_Weapon), mMask(MWWorld::ContainerStore::Type_All), mContainer(container), mWeapon(iterator){}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T, class U>
|
||||||
|
bool MWWorld::operator== (const ContainerStoreIteratorBase<T>& left, const ContainerStoreIteratorBase<U>& right)
|
||||||
{
|
{
|
||||||
return left.isEqual (right);
|
return left.isEqual (right);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MWWorld::operator!= (const ContainerStoreIterator& left, const ContainerStoreIterator& right)
|
template<class T, class U>
|
||||||
|
bool MWWorld::operator!= (const ContainerStoreIteratorBase<T>& left, const ContainerStoreIteratorBase<U>& right)
|
||||||
{
|
{
|
||||||
return !(left==right);
|
return !(left==right);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template class MWWorld::ContainerStoreIteratorBase<MWWorld::Ptr>;
|
||||||
|
template class MWWorld::ContainerStoreIteratorBase<MWWorld::ConstPtr>;
|
||||||
|
|
||||||
|
template bool MWWorld::operator== (const ContainerStoreIteratorBase<Ptr>& left, const ContainerStoreIteratorBase<Ptr>& right);
|
||||||
|
template bool MWWorld::operator!= (const ContainerStoreIteratorBase<Ptr>& left, const ContainerStoreIteratorBase<Ptr>& right);
|
||||||
|
template bool MWWorld::operator== (const ContainerStoreIteratorBase<ConstPtr>& left, const ContainerStoreIteratorBase<ConstPtr>& right);
|
||||||
|
template bool MWWorld::operator!= (const ContainerStoreIteratorBase<ConstPtr>& left, const ContainerStoreIteratorBase<ConstPtr>& right);
|
||||||
|
template bool MWWorld::operator== (const ContainerStoreIteratorBase<ConstPtr>& left, const ContainerStoreIteratorBase<Ptr>& right);
|
||||||
|
template bool MWWorld::operator!= (const ContainerStoreIteratorBase<ConstPtr>& left, const ContainerStoreIteratorBase<Ptr>& right);
|
||||||
|
template bool MWWorld::operator== (const ContainerStoreIteratorBase<Ptr>& left, const ContainerStoreIteratorBase<ConstPtr>& right);
|
||||||
|
template bool MWWorld::operator!= (const ContainerStoreIteratorBase<Ptr>& left, const ContainerStoreIteratorBase<ConstPtr>& right);
|
||||||
|
|
||||||
|
template void MWWorld::ContainerStoreIteratorBase<MWWorld::Ptr>::copy(const ContainerStoreIteratorBase<Ptr>& src);
|
||||||
|
template void MWWorld::ContainerStoreIteratorBase<MWWorld::ConstPtr>::copy(const ContainerStoreIteratorBase<Ptr>& src);
|
||||||
|
template void MWWorld::ContainerStoreIteratorBase<MWWorld::ConstPtr>::copy(const ContainerStoreIteratorBase<ConstPtr>& src);
|
||||||
|
|
|
@ -29,7 +29,14 @@ namespace ESM
|
||||||
|
|
||||||
namespace MWWorld
|
namespace MWWorld
|
||||||
{
|
{
|
||||||
class ContainerStoreIterator;
|
class ContainerStore;
|
||||||
|
|
||||||
|
template<class PtrType>
|
||||||
|
class ContainerStoreIteratorBase;
|
||||||
|
|
||||||
|
typedef ContainerStoreIteratorBase<Ptr> ContainerStoreIterator;
|
||||||
|
typedef ContainerStoreIteratorBase<ConstPtr> ConstContainerStoreIterator;
|
||||||
|
|
||||||
|
|
||||||
class ContainerStoreListener
|
class ContainerStoreListener
|
||||||
{
|
{
|
||||||
|
@ -99,9 +106,11 @@ namespace MWWorld
|
||||||
ESM::InventoryState& inventory, int& index,
|
ESM::InventoryState& inventory, int& index,
|
||||||
bool equipable = false) const;
|
bool equipable = false) const;
|
||||||
|
|
||||||
|
|
||||||
virtual void storeEquipmentState (const MWWorld::LiveCellRefBase& ref, int index, ESM::InventoryState& inventory) const;
|
virtual void storeEquipmentState (const MWWorld::LiveCellRefBase& ref, int index, ESM::InventoryState& inventory) const;
|
||||||
|
|
||||||
virtual void readEquipmentState (const MWWorld::ContainerStoreIterator& iter, int index, const ESM::InventoryState& inventory);
|
virtual void readEquipmentState (const MWWorld::ContainerStoreIterator& iter, int index, const ESM::InventoryState& inventory);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
ContainerStore();
|
ContainerStore();
|
||||||
|
@ -110,8 +119,12 @@ namespace MWWorld
|
||||||
|
|
||||||
virtual ContainerStore* clone() { return new ContainerStore(*this); }
|
virtual ContainerStore* clone() { return new ContainerStore(*this); }
|
||||||
|
|
||||||
ContainerStoreIterator begin (int mask = Type_All);
|
ConstContainerStoreIterator cbegin (int mask = Type_All) const;
|
||||||
|
ConstContainerStoreIterator cend() const;
|
||||||
|
ConstContainerStoreIterator begin (int mask = Type_All) const;
|
||||||
|
ConstContainerStoreIterator end() const;
|
||||||
|
|
||||||
|
ContainerStoreIterator begin (int mask = Type_All);
|
||||||
ContainerStoreIterator end();
|
ContainerStoreIterator end();
|
||||||
|
|
||||||
virtual ContainerStoreIterator add (const Ptr& itemPtr, int count, const Ptr& actorPtr, bool setOwner=false);
|
virtual ContainerStoreIterator add (const Ptr& itemPtr, int count, const Ptr& actorPtr, bool setOwner=false);
|
||||||
|
@ -163,7 +176,7 @@ namespace MWWorld
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual bool stacks (const ConstPtr& ptr1, const ConstPtr& ptr2);
|
virtual bool stacks (const ConstPtr& ptr1, const ConstPtr& ptr2) const;
|
||||||
///< @return true if the two specified objects can stack with each other
|
///< @return true if the two specified objects can stack with each other
|
||||||
|
|
||||||
void fill (const ESM::InventoryList& items, const std::string& owner);
|
void fill (const ESM::InventoryList& items, const std::string& owner);
|
||||||
|
@ -187,96 +200,143 @@ namespace MWWorld
|
||||||
|
|
||||||
virtual void readState (const ESM::InventoryState& state);
|
virtual void readState (const ESM::InventoryState& state);
|
||||||
|
|
||||||
friend class ContainerStoreIterator;
|
friend class ContainerStoreIteratorBase<Ptr>;
|
||||||
|
friend class ContainerStoreIteratorBase<ConstPtr>;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// \brief Iteration over a subset of objects in a ContainerStore
|
|
||||||
///
|
template<class PtrType>
|
||||||
/// \note The iterator will automatically skip over deleted objects.
|
class ContainerStoreIteratorBase
|
||||||
class ContainerStoreIterator
|
: public std::iterator<std::forward_iterator_tag, PtrType, std::ptrdiff_t, PtrType *, PtrType&>
|
||||||
: public std::iterator<std::forward_iterator_tag, Ptr, std::ptrdiff_t, Ptr *, Ptr&>
|
|
||||||
{
|
{
|
||||||
|
template<class From, class To, class Dummy>
|
||||||
|
struct IsConvertible
|
||||||
|
{
|
||||||
|
static const bool value = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class Dummy>
|
||||||
|
struct IsConvertible<ConstPtr, Ptr, Dummy>
|
||||||
|
{
|
||||||
|
static const bool value = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T, class U>
|
||||||
|
struct IteratorTrait
|
||||||
|
{
|
||||||
|
typedef typename MWWorld::CellRefList<T>::List::iterator type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
struct IteratorTrait<T, ConstPtr>
|
||||||
|
{
|
||||||
|
typedef typename MWWorld::CellRefList<T>::List::const_iterator type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
struct Iterator : IteratorTrait<T, PtrType>
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T, class Dummy>
|
||||||
|
struct ContainerStoreTrait
|
||||||
|
{
|
||||||
|
typedef ContainerStore* type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class Dummy>
|
||||||
|
struct ContainerStoreTrait<ConstPtr, Dummy>
|
||||||
|
{
|
||||||
|
typedef const ContainerStore* type;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef typename ContainerStoreTrait<PtrType, void>::type ContainerStoreType;
|
||||||
|
|
||||||
int mType;
|
int mType;
|
||||||
int mMask;
|
int mMask;
|
||||||
ContainerStore *mContainer;
|
ContainerStoreType mContainer;
|
||||||
mutable Ptr mPtr;
|
mutable PtrType mPtr;
|
||||||
|
|
||||||
MWWorld::CellRefList<ESM::Potion>::List::iterator mPotion;
|
typename Iterator<ESM::Potion>::type mPotion;
|
||||||
MWWorld::CellRefList<ESM::Apparatus>::List::iterator mApparatus;
|
typename Iterator<ESM::Apparatus>::type mApparatus;
|
||||||
MWWorld::CellRefList<ESM::Armor>::List::iterator mArmor;
|
typename Iterator<ESM::Armor>::type mArmor;
|
||||||
MWWorld::CellRefList<ESM::Book>::List::iterator mBook;
|
typename Iterator<ESM::Book>::type mBook;
|
||||||
MWWorld::CellRefList<ESM::Clothing>::List::iterator mClothing;
|
typename Iterator<ESM::Clothing>::type mClothing;
|
||||||
MWWorld::CellRefList<ESM::Ingredient>::List::iterator mIngredient;
|
typename Iterator<ESM::Ingredient>::type mIngredient;
|
||||||
MWWorld::CellRefList<ESM::Light>::List::iterator mLight;
|
typename Iterator<ESM::Light>::type mLight;
|
||||||
MWWorld::CellRefList<ESM::Lockpick>::List::iterator mLockpick;
|
typename Iterator<ESM::Lockpick>::type mLockpick;
|
||||||
MWWorld::CellRefList<ESM::Miscellaneous>::List::iterator mMiscellaneous;
|
typename Iterator<ESM::Miscellaneous>::type mMiscellaneous;
|
||||||
MWWorld::CellRefList<ESM::Probe>::List::iterator mProbe;
|
typename Iterator<ESM::Probe>::type mProbe;
|
||||||
MWWorld::CellRefList<ESM::Repair>::List::iterator mRepair;
|
typename Iterator<ESM::Repair>::type mRepair;
|
||||||
MWWorld::CellRefList<ESM::Weapon>::List::iterator mWeapon;
|
typename Iterator<ESM::Weapon>::type mWeapon;
|
||||||
|
|
||||||
private:
|
ContainerStoreIteratorBase (ContainerStoreType container);
|
||||||
|
|
||||||
ContainerStoreIterator (ContainerStore *container);
|
|
||||||
///< End-iterator
|
///< End-iterator
|
||||||
|
|
||||||
ContainerStoreIterator (int mask, ContainerStore *container);
|
ContainerStoreIteratorBase (int mask, ContainerStoreType container);
|
||||||
///< Begin-iterator
|
///< Begin-iterator
|
||||||
|
|
||||||
// construct iterator using a CellRefList iterator
|
// construct iterator using a CellRefList iterator
|
||||||
ContainerStoreIterator (ContainerStore *container, MWWorld::CellRefList<ESM::Potion>::List::iterator);
|
ContainerStoreIteratorBase (ContainerStoreType container, typename Iterator<ESM::Potion>::type);
|
||||||
ContainerStoreIterator (ContainerStore *container, MWWorld::CellRefList<ESM::Apparatus>::List::iterator);
|
ContainerStoreIteratorBase (ContainerStoreType container, typename Iterator<ESM::Apparatus>::type);
|
||||||
ContainerStoreIterator (ContainerStore *container, MWWorld::CellRefList<ESM::Armor>::List::iterator);
|
ContainerStoreIteratorBase (ContainerStoreType container, typename Iterator<ESM::Armor>::type);
|
||||||
ContainerStoreIterator (ContainerStore *container, MWWorld::CellRefList<ESM::Book>::List::iterator);
|
ContainerStoreIteratorBase (ContainerStoreType container, typename Iterator<ESM::Book>::type);
|
||||||
ContainerStoreIterator (ContainerStore *container, MWWorld::CellRefList<ESM::Clothing>::List::iterator);
|
ContainerStoreIteratorBase (ContainerStoreType container, typename Iterator<ESM::Clothing>::type);
|
||||||
ContainerStoreIterator (ContainerStore *container, MWWorld::CellRefList<ESM::Ingredient>::List::iterator);
|
ContainerStoreIteratorBase (ContainerStoreType container, typename Iterator<ESM::Ingredient>::type);
|
||||||
ContainerStoreIterator (ContainerStore *container, MWWorld::CellRefList<ESM::Light>::List::iterator);
|
ContainerStoreIteratorBase (ContainerStoreType container, typename Iterator<ESM::Light>::type);
|
||||||
ContainerStoreIterator (ContainerStore *container, MWWorld::CellRefList<ESM::Lockpick>::List::iterator);
|
ContainerStoreIteratorBase (ContainerStoreType container, typename Iterator<ESM::Lockpick>::type);
|
||||||
ContainerStoreIterator (ContainerStore *container, MWWorld::CellRefList<ESM::Miscellaneous>::List::iterator);
|
ContainerStoreIteratorBase (ContainerStoreType container, typename Iterator<ESM::Miscellaneous>::type);
|
||||||
ContainerStoreIterator (ContainerStore *container, MWWorld::CellRefList<ESM::Probe>::List::iterator);
|
ContainerStoreIteratorBase (ContainerStoreType container, typename Iterator<ESM::Probe>::type);
|
||||||
ContainerStoreIterator (ContainerStore *container, MWWorld::CellRefList<ESM::Repair>::List::iterator);
|
ContainerStoreIteratorBase (ContainerStoreType container, typename Iterator<ESM::Repair>::type);
|
||||||
ContainerStoreIterator (ContainerStore *container, MWWorld::CellRefList<ESM::Weapon>::List::iterator);
|
ContainerStoreIteratorBase (ContainerStoreType container, typename Iterator<ESM::Weapon>::type);
|
||||||
|
|
||||||
void copy (const ContainerStoreIterator& src);
|
template<class T>
|
||||||
|
void copy (const ContainerStoreIteratorBase<T>& src);
|
||||||
|
|
||||||
void incType();
|
void incType ();
|
||||||
|
|
||||||
void nextType();
|
void nextType ();
|
||||||
|
|
||||||
bool resetIterator();
|
bool resetIterator ();
|
||||||
///< Reset iterator for selected type.
|
///< Reset iterator for selected type.
|
||||||
///
|
///
|
||||||
/// \return Type not empty?
|
/// \return Type not empty?
|
||||||
|
|
||||||
bool incIterator();
|
bool incIterator ();
|
||||||
///< Increment iterator for selected type.
|
///< Increment iterator for selected type.
|
||||||
///
|
///
|
||||||
/// \return reached the end?
|
/// \return reached the end?
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
template<class T>
|
||||||
|
ContainerStoreIteratorBase (const ContainerStoreIteratorBase<T>& other)
|
||||||
|
{
|
||||||
|
char CANNOT_CONVERT_CONST_ITERATOR_TO_ITERATOR[IsConvertible<T, PtrType, void>::value ? 1 : -1];
|
||||||
|
((void)CANNOT_CONVERT_CONST_ITERATOR_TO_ITERATOR);
|
||||||
|
copy (other);
|
||||||
|
}
|
||||||
|
|
||||||
ContainerStoreIterator(const ContainerStoreIterator& src);
|
template<class T>
|
||||||
|
bool isEqual(const ContainerStoreIteratorBase<T>& other) const;
|
||||||
|
|
||||||
Ptr *operator->() const;
|
PtrType *operator->() const;
|
||||||
|
PtrType operator*() const;
|
||||||
|
|
||||||
Ptr operator*() const;
|
ContainerStoreIteratorBase& operator++ ();
|
||||||
|
ContainerStoreIteratorBase operator++ (int);
|
||||||
ContainerStoreIterator& operator++();
|
ContainerStoreIteratorBase& operator= (const ContainerStoreIteratorBase& rhs);
|
||||||
|
|
||||||
ContainerStoreIterator operator++ (int);
|
|
||||||
|
|
||||||
ContainerStoreIterator& operator= (const ContainerStoreIterator& rhs);
|
|
||||||
|
|
||||||
bool isEqual (const ContainerStoreIterator& iter) const;
|
|
||||||
|
|
||||||
int getType() const;
|
int getType() const;
|
||||||
|
|
||||||
const ContainerStore *getContainerStore() const;
|
const ContainerStore *getContainerStore() const;
|
||||||
|
|
||||||
friend class ContainerStore;
|
friend class ContainerStore;
|
||||||
|
friend class ContainerStoreIteratorBase<Ptr>;
|
||||||
|
friend class ContainerStoreIteratorBase<ConstPtr>;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool operator== (const ContainerStoreIterator& left, const ContainerStoreIterator& right);
|
template<class T, class U>
|
||||||
bool operator!= (const ContainerStoreIterator& left, const ContainerStoreIterator& right);
|
bool operator== (const ContainerStoreIteratorBase<T>& left, const ContainerStoreIteratorBase<U>& right);
|
||||||
|
template<class T, class U>
|
||||||
|
bool operator!= (const ContainerStoreIteratorBase<T>& left, const ContainerStoreIteratorBase<U>& right);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -199,20 +199,12 @@ void MWWorld::InventoryStore::unequipAll(const MWWorld::Ptr& actor)
|
||||||
|
|
||||||
MWWorld::ContainerStoreIterator MWWorld::InventoryStore::getSlot (int slot)
|
MWWorld::ContainerStoreIterator MWWorld::InventoryStore::getSlot (int slot)
|
||||||
{
|
{
|
||||||
if (slot<0 || slot>=static_cast<int> (mSlots.size()))
|
return findSlot (slot);
|
||||||
throw std::runtime_error ("slot number out of range");
|
}
|
||||||
|
|
||||||
if (mSlots[slot]==end())
|
MWWorld::ConstContainerStoreIterator MWWorld::InventoryStore::getSlot (int slot) const
|
||||||
return end();
|
{
|
||||||
|
return findSlot (slot);
|
||||||
if (mSlots[slot]->getRefData().getCount()<1)
|
|
||||||
{
|
|
||||||
// Object has been deleted
|
|
||||||
// This should no longer happen, since the new remove function will unequip first
|
|
||||||
throw std::runtime_error("Invalid slot, make sure you are not calling RefData::setCount for a container object");
|
|
||||||
}
|
|
||||||
|
|
||||||
return mSlots[slot];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MWWorld::InventoryStore::canActorAutoEquip(const MWWorld::Ptr& actor, const MWWorld::Ptr& item)
|
bool MWWorld::InventoryStore::canActorAutoEquip(const MWWorld::Ptr& actor, const MWWorld::Ptr& item)
|
||||||
|
@ -241,6 +233,24 @@ bool MWWorld::InventoryStore::canActorAutoEquip(const MWWorld::Ptr& actor, const
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MWWorld::ContainerStoreIterator MWWorld::InventoryStore::findSlot (int slot) const
|
||||||
|
{
|
||||||
|
if (slot<0 || slot>=static_cast<int> (mSlots.size()))
|
||||||
|
throw std::runtime_error ("slot number out of range");
|
||||||
|
|
||||||
|
if (mSlots[slot]==end())
|
||||||
|
return mSlots[slot];
|
||||||
|
|
||||||
|
if (mSlots[slot]->getRefData().getCount()<1)
|
||||||
|
{
|
||||||
|
// Object has been deleted
|
||||||
|
// This should no longer happen, since the new remove function will unequip first
|
||||||
|
throw std::runtime_error("Invalid slot, make sure you are not calling RefData::setCount for a container object");
|
||||||
|
}
|
||||||
|
|
||||||
|
return mSlots[slot];
|
||||||
|
}
|
||||||
|
|
||||||
void MWWorld::InventoryStore::autoEquip (const MWWorld::Ptr& actor)
|
void MWWorld::InventoryStore::autoEquip (const MWWorld::Ptr& actor)
|
||||||
{
|
{
|
||||||
const MWBase::World *world = MWBase::Environment::get().getWorld();
|
const MWBase::World *world = MWBase::Environment::get().getWorld();
|
||||||
|
|
|
@ -116,6 +116,7 @@ namespace MWWorld
|
||||||
virtual void readEquipmentState (const MWWorld::ContainerStoreIterator& iter, int index, const ESM::InventoryState& inventory);
|
virtual void readEquipmentState (const MWWorld::ContainerStoreIterator& iter, int index, const ESM::InventoryState& inventory);
|
||||||
|
|
||||||
bool canActorAutoEquip(const MWWorld::Ptr& actor, const MWWorld::Ptr& item);
|
bool canActorAutoEquip(const MWWorld::Ptr& actor, const MWWorld::Ptr& item);
|
||||||
|
ContainerStoreIterator findSlot (int slot) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -155,6 +156,7 @@ namespace MWWorld
|
||||||
/// \note if no item selected, return end() iterator
|
/// \note if no item selected, return end() iterator
|
||||||
|
|
||||||
ContainerStoreIterator getSlot (int slot);
|
ContainerStoreIterator getSlot (int slot);
|
||||||
|
ConstContainerStoreIterator getSlot(int slot) const;
|
||||||
|
|
||||||
void unequipAll(const MWWorld::Ptr& actor);
|
void unequipAll(const MWWorld::Ptr& actor);
|
||||||
///< Unequip all currently equipped items.
|
///< Unequip all currently equipped items.
|
||||||
|
|
|
@ -70,6 +70,14 @@ const MWWorld::LiveCellRefBase *MWWorld::ConstPtr::getBase() const
|
||||||
return mRef;
|
return mRef;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MWWorld::ConstPtr::setContainerStore (const ContainerStore *store)
|
||||||
|
{
|
||||||
|
assert (store);
|
||||||
|
assert (!mCell);
|
||||||
|
|
||||||
|
mContainerStore = store;
|
||||||
|
}
|
||||||
|
|
||||||
const MWWorld::ContainerStore *MWWorld::ConstPtr::getContainerStore() const
|
const MWWorld::ContainerStore *MWWorld::ConstPtr::getContainerStore() const
|
||||||
{
|
{
|
||||||
return mContainerStore;
|
return mContainerStore;
|
||||||
|
|
|
@ -159,6 +159,9 @@ namespace MWWorld
|
||||||
return (mContainerStore == 0) && (mCell != 0);
|
return (mContainerStore == 0) && (mCell != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setContainerStore (const ContainerStore *store);
|
||||||
|
///< Must not be called on references that are in a cell.
|
||||||
|
|
||||||
const ContainerStore *getContainerStore() const;
|
const ContainerStore *getContainerStore() const;
|
||||||
///< May return a 0-pointer, if reference is not in a container.
|
///< May return a 0-pointer, if reference is not in a container.
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,8 @@ namespace osgMyGUI
|
||||||
, mFormat(MyGUI::PixelFormat::Unknow)
|
, mFormat(MyGUI::PixelFormat::Unknow)
|
||||||
, mUsage(MyGUI::TextureUsage::Default)
|
, mUsage(MyGUI::TextureUsage::Default)
|
||||||
, mNumElemBytes(0)
|
, mNumElemBytes(0)
|
||||||
|
, mWidth(0)
|
||||||
|
, mHeight(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,6 +27,8 @@ namespace osgMyGUI
|
||||||
, mFormat(MyGUI::PixelFormat::Unknow)
|
, mFormat(MyGUI::PixelFormat::Unknow)
|
||||||
, mUsage(MyGUI::TextureUsage::Default)
|
, mUsage(MyGUI::TextureUsage::Default)
|
||||||
, mNumElemBytes(0)
|
, mNumElemBytes(0)
|
||||||
|
, mWidth(texture->getTextureWidth())
|
||||||
|
, mHeight(texture->getTextureHeight())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,6 +67,9 @@ namespace osgMyGUI
|
||||||
mTexture->setSourceFormat(glfmt);
|
mTexture->setSourceFormat(glfmt);
|
||||||
mTexture->setSourceType(GL_UNSIGNED_BYTE);
|
mTexture->setSourceType(GL_UNSIGNED_BYTE);
|
||||||
|
|
||||||
|
mWidth = width;
|
||||||
|
mHeight = height;
|
||||||
|
|
||||||
mTexture->setFilter(osg::Texture::MIN_FILTER, osg::Texture::LINEAR);
|
mTexture->setFilter(osg::Texture::MIN_FILTER, osg::Texture::LINEAR);
|
||||||
mTexture->setFilter(osg::Texture::MAG_FILTER, osg::Texture::LINEAR);
|
mTexture->setFilter(osg::Texture::MAG_FILTER, osg::Texture::LINEAR);
|
||||||
mTexture->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE);
|
mTexture->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE);
|
||||||
|
@ -79,6 +86,8 @@ namespace osgMyGUI
|
||||||
mFormat = MyGUI::PixelFormat::Unknow;
|
mFormat = MyGUI::PixelFormat::Unknow;
|
||||||
mUsage = MyGUI::TextureUsage::Default;
|
mUsage = MyGUI::TextureUsage::Default;
|
||||||
mNumElemBytes = 0;
|
mNumElemBytes = 0;
|
||||||
|
mWidth = 0;
|
||||||
|
mHeight = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OSGTexture::loadFromFile(const std::string &fname)
|
void OSGTexture::loadFromFile(const std::string &fname)
|
||||||
|
@ -95,10 +104,10 @@ namespace osgMyGUI
|
||||||
// disable mip-maps
|
// disable mip-maps
|
||||||
mTexture->setFilter(osg::Texture2D::MIN_FILTER, osg::Texture2D::LINEAR);
|
mTexture->setFilter(osg::Texture2D::MIN_FILTER, osg::Texture2D::LINEAR);
|
||||||
|
|
||||||
// FIXME
|
mWidth = image->s();
|
||||||
mFormat = MyGUI::PixelFormat::R8G8B8;
|
mHeight = image->t();
|
||||||
mUsage = MyGUI::TextureUsage::Static | MyGUI::TextureUsage::Write;
|
|
||||||
mNumElemBytes = 3; // FIXME
|
mUsage = MyGUI::TextureUsage::Static;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OSGTexture::saveToFile(const std::string &fname)
|
void OSGTexture::saveToFile(const std::string &fname)
|
||||||
|
@ -108,16 +117,12 @@ namespace osgMyGUI
|
||||||
|
|
||||||
int OSGTexture::getWidth()
|
int OSGTexture::getWidth()
|
||||||
{
|
{
|
||||||
if(!mTexture.valid())
|
return mWidth;
|
||||||
return 0;
|
|
||||||
return mTexture->getTextureWidth();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int OSGTexture::getHeight()
|
int OSGTexture::getHeight()
|
||||||
{
|
{
|
||||||
if(!mTexture.valid())
|
return mHeight;
|
||||||
return 0;
|
|
||||||
return mTexture->getTextureHeight();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void *OSGTexture::lock(MyGUI::TextureUsage /*access*/)
|
void *OSGTexture::lock(MyGUI::TextureUsage /*access*/)
|
||||||
|
|
|
@ -29,6 +29,9 @@ namespace osgMyGUI
|
||||||
MyGUI::TextureUsage mUsage;
|
MyGUI::TextureUsage mUsage;
|
||||||
size_t mNumElemBytes;
|
size_t mNumElemBytes;
|
||||||
|
|
||||||
|
int mWidth;
|
||||||
|
int mHeight;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
OSGTexture(const std::string &name, Resource::ImageManager* imageManager);
|
OSGTexture(const std::string &name, Resource::ImageManager* imageManager);
|
||||||
OSGTexture(osg::Texture2D* texture);
|
OSGTexture(osg::Texture2D* texture);
|
||||||
|
|
|
@ -21,13 +21,14 @@ namespace Terrain
|
||||||
osg::ref_ptr<osg::TexMat> texMat = texMatMap[blendmapScale];
|
osg::ref_ptr<osg::TexMat> texMat = texMatMap[blendmapScale];
|
||||||
if (!texMat)
|
if (!texMat)
|
||||||
{
|
{
|
||||||
texMat = new osg::TexMat;
|
|
||||||
osg::Matrixf matrix;
|
osg::Matrixf matrix;
|
||||||
float scale = (blendmapScale/(static_cast<float>(blendmapScale)+1.f));
|
float scale = (blendmapScale/(static_cast<float>(blendmapScale)+1.f));
|
||||||
matrix.preMultTranslate(osg::Vec3f(0.5f, 0.5f, 0.f));
|
matrix.preMultTranslate(osg::Vec3f(0.5f, 0.5f, 0.f));
|
||||||
matrix.preMultScale(osg::Vec3f(scale, scale, 1.f));
|
matrix.preMultScale(osg::Vec3f(scale, scale, 1.f));
|
||||||
matrix.preMultTranslate(osg::Vec3f(-0.5f, -0.5f, 0.f));
|
matrix.preMultTranslate(osg::Vec3f(-0.5f, -0.5f, 0.f));
|
||||||
|
|
||||||
|
texMat = new osg::TexMat(matrix);
|
||||||
|
|
||||||
texMatMap[blendmapScale] = texMat;
|
texMatMap[blendmapScale] = texMat;
|
||||||
}
|
}
|
||||||
return texMat;
|
return texMat;
|
||||||
|
@ -39,8 +40,7 @@ namespace Terrain
|
||||||
osg::ref_ptr<osg::TexMat> texMat = texMatMap[layerTileSize];
|
osg::ref_ptr<osg::TexMat> texMat = texMatMap[layerTileSize];
|
||||||
if (!texMat)
|
if (!texMat)
|
||||||
{
|
{
|
||||||
texMat = new osg::TexMat;
|
texMat = new osg::TexMat(osg::Matrix::scale(osg::Vec3f(layerTileSize,layerTileSize,1.f)));
|
||||||
texMat->setMatrix(osg::Matrix::scale(osg::Vec3f(layerTileSize,layerTileSize,1.f)));
|
|
||||||
|
|
||||||
texMatMap[layerTileSize] = texMat;
|
texMatMap[layerTileSize] = texMat;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue