|
|
|
@ -8,8 +8,6 @@
|
|
|
|
|
#include "../mwbase/world.hpp"
|
|
|
|
|
|
|
|
|
|
#include "ptr.hpp"
|
|
|
|
|
#include "manualref.hpp"
|
|
|
|
|
#include "class.hpp"
|
|
|
|
|
|
|
|
|
|
namespace MWWorld
|
|
|
|
|
{
|
|
|
|
@ -127,121 +125,4 @@ namespace MWWorld
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// \todo this whole code needs major clean up
|
|
|
|
|
const MWWorld::Ptr CellStore::insertObject (const Ptr& ptr, const ESM::Position &pos)
|
|
|
|
|
{
|
|
|
|
|
std::string type = ptr.getTypeName();
|
|
|
|
|
|
|
|
|
|
MWWorld::Ptr newPtr;
|
|
|
|
|
|
|
|
|
|
// insert into the correct CellRefList
|
|
|
|
|
if (type == typeid(ESM::Potion).name())
|
|
|
|
|
{
|
|
|
|
|
MWWorld::LiveCellRef<ESM::Potion>* ref = ptr.get<ESM::Potion>();
|
|
|
|
|
newPtr = MWWorld::Ptr(&potions.insert(*ref), this);
|
|
|
|
|
}
|
|
|
|
|
else if (type == typeid(ESM::Apparatus).name())
|
|
|
|
|
{
|
|
|
|
|
MWWorld::LiveCellRef<ESM::Apparatus>* ref = ptr.get<ESM::Apparatus>();
|
|
|
|
|
newPtr = MWWorld::Ptr(&appas.insert(*ref), this);
|
|
|
|
|
}
|
|
|
|
|
else if (type == typeid(ESM::Armor).name())
|
|
|
|
|
{
|
|
|
|
|
MWWorld::LiveCellRef<ESM::Armor>* ref = ptr.get<ESM::Armor>();
|
|
|
|
|
newPtr = MWWorld::Ptr(&armors.insert(*ref), this);
|
|
|
|
|
}
|
|
|
|
|
else if (type == typeid(ESM::Book).name())
|
|
|
|
|
{
|
|
|
|
|
MWWorld::LiveCellRef<ESM::Book>* ref = ptr.get<ESM::Book>();
|
|
|
|
|
newPtr = MWWorld::Ptr(&books.insert(*ref), this);
|
|
|
|
|
}
|
|
|
|
|
else if (type == typeid(ESM::Clothing).name())
|
|
|
|
|
{
|
|
|
|
|
MWWorld::LiveCellRef<ESM::Clothing>* ref = ptr.get<ESM::Clothing>();
|
|
|
|
|
newPtr = MWWorld::Ptr(&clothes.insert(*ref), this);
|
|
|
|
|
}
|
|
|
|
|
else if (type == typeid(ESM::Ingredient).name())
|
|
|
|
|
{
|
|
|
|
|
MWWorld::LiveCellRef<ESM::Ingredient>* ref = ptr.get<ESM::Ingredient>();
|
|
|
|
|
newPtr = MWWorld::Ptr(&ingreds.insert(*ref), this);
|
|
|
|
|
}
|
|
|
|
|
else if (type == typeid(ESM::Light).name())
|
|
|
|
|
{
|
|
|
|
|
MWWorld::LiveCellRef<ESM::Light>* ref = ptr.get<ESM::Light>();
|
|
|
|
|
newPtr = MWWorld::Ptr(&lights.insert(*ref), this);
|
|
|
|
|
}
|
|
|
|
|
else if (type == typeid(ESM::Tool).name())
|
|
|
|
|
{
|
|
|
|
|
MWWorld::LiveCellRef<ESM::Tool>* ref = ptr.get<ESM::Tool>();
|
|
|
|
|
newPtr = MWWorld::Ptr(&lockpicks.insert(*ref), this);
|
|
|
|
|
}
|
|
|
|
|
else if (type == typeid(ESM::Repair).name())
|
|
|
|
|
{
|
|
|
|
|
MWWorld::LiveCellRef<ESM::Repair>* ref = ptr.get<ESM::Repair>();
|
|
|
|
|
newPtr = MWWorld::Ptr(&repairs.insert(*ref), this);
|
|
|
|
|
}
|
|
|
|
|
else if (type == typeid(ESM::Probe).name())
|
|
|
|
|
{
|
|
|
|
|
MWWorld::LiveCellRef<ESM::Probe>* ref = ptr.get<ESM::Probe>();
|
|
|
|
|
newPtr = MWWorld::Ptr(&probes.insert(*ref), this);
|
|
|
|
|
}
|
|
|
|
|
else if (type == typeid(ESM::Weapon).name())
|
|
|
|
|
{
|
|
|
|
|
MWWorld::LiveCellRef<ESM::Weapon>* ref = ptr.get<ESM::Weapon>();
|
|
|
|
|
newPtr = MWWorld::Ptr(&weapons.insert(*ref), this);
|
|
|
|
|
}
|
|
|
|
|
else if (type == typeid(ESM::Miscellaneous).name())
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// if this is gold, we need to fetch the correct mesh depending on the amount of gold.
|
|
|
|
|
if (MWWorld::Class::get(ptr).getName(ptr) == MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sGold")->str)
|
|
|
|
|
{
|
|
|
|
|
int goldAmount = ptr.getRefData().getCount();
|
|
|
|
|
|
|
|
|
|
std::string base = "Gold_001";
|
|
|
|
|
if (goldAmount >= 100)
|
|
|
|
|
base = "Gold_100";
|
|
|
|
|
else if (goldAmount >= 25)
|
|
|
|
|
base = "Gold_025";
|
|
|
|
|
else if (goldAmount >= 10)
|
|
|
|
|
base = "Gold_010";
|
|
|
|
|
else if (goldAmount >= 5)
|
|
|
|
|
base = "Gold_005";
|
|
|
|
|
|
|
|
|
|
MWWorld::ManualRef newRef(
|
|
|
|
|
MWBase::Environment::get().getWorld()->getStore(),
|
|
|
|
|
base);
|
|
|
|
|
|
|
|
|
|
MWWorld::LiveCellRef<ESM::Miscellaneous>* ref =
|
|
|
|
|
newRef.getPtr().get<ESM::Miscellaneous>();
|
|
|
|
|
|
|
|
|
|
newPtr = MWWorld::Ptr(&miscItems.insert(*ref), this);
|
|
|
|
|
/*
|
|
|
|
|
ESM::Position& p = newPtr.getRefData().getPosition();
|
|
|
|
|
p.pos[0] = ptr.getRefData().getPosition().pos[0];
|
|
|
|
|
p.pos[1] = ptr.getRefData().getPosition().pos[1];
|
|
|
|
|
p.pos[2] = ptr.getRefData().getPosition().pos[2];
|
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MWWorld::LiveCellRef<ESM::Miscellaneous>* ref =
|
|
|
|
|
ptr.get<ESM::Miscellaneous>();
|
|
|
|
|
|
|
|
|
|
newPtr = MWWorld::Ptr(&miscItems.insert(*ref), this);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
throw std::runtime_error("Trying to insert object of unhandled type");
|
|
|
|
|
|
|
|
|
|
newPtr.getRefData().getPosition() = pos;
|
|
|
|
|
|
|
|
|
|
newPtr.getRefData().setCount(ptr.getRefData().getCount());
|
|
|
|
|
ptr.getRefData().setCount(0);
|
|
|
|
|
newPtr.getRefData().enable();
|
|
|
|
|
|
|
|
|
|
return newPtr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|