forked from teamnwah/openmw-tes3coop
move responsibility for cell changing from CellStore::insertObject to Class::moveToCell
This commit is contained in:
parent
bcc47cd5fb
commit
e7666d3a7f
41 changed files with 300 additions and 126 deletions
|
@ -94,4 +94,14 @@ namespace MWClass
|
||||||
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MWWorld::Ptr
|
||||||
|
Activator::moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const
|
||||||
|
{
|
||||||
|
MWWorld::LiveCellRef<ESM::Activator> *ref =
|
||||||
|
ptr.get<ESM::Activator>();
|
||||||
|
|
||||||
|
return MWWorld::Ptr(&cell.activators.insert(*ref), &cell);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,10 @@ namespace MWClass
|
||||||
{
|
{
|
||||||
class Activator : public MWWorld::Class
|
class Activator : public MWWorld::Class
|
||||||
{
|
{
|
||||||
|
|
||||||
|
virtual MWWorld::Ptr
|
||||||
|
moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
||||||
|
|
|
@ -149,4 +149,13 @@ namespace MWClass
|
||||||
{
|
{
|
||||||
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionAlchemy());
|
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionAlchemy());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MWWorld::Ptr
|
||||||
|
Apparatus::moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const
|
||||||
|
{
|
||||||
|
MWWorld::LiveCellRef<ESM::Apparatus> *ref =
|
||||||
|
ptr.get<ESM::Apparatus>();
|
||||||
|
|
||||||
|
return MWWorld::Ptr(&cell.appas.insert(*ref), &cell);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,10 @@ namespace MWClass
|
||||||
{
|
{
|
||||||
class Apparatus : public MWWorld::Class
|
class Apparatus : public MWWorld::Class
|
||||||
{
|
{
|
||||||
|
|
||||||
|
virtual MWWorld::Ptr
|
||||||
|
moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
||||||
|
|
|
@ -276,4 +276,13 @@ namespace MWClass
|
||||||
|
|
||||||
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionEquip(ptr));
|
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionEquip(ptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MWWorld::Ptr
|
||||||
|
Armor::moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const
|
||||||
|
{
|
||||||
|
MWWorld::LiveCellRef<ESM::Armor> *ref =
|
||||||
|
ptr.get<ESM::Armor>();
|
||||||
|
|
||||||
|
return MWWorld::Ptr(&cell.armors.insert(*ref), &cell);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,9 @@ namespace MWClass
|
||||||
{
|
{
|
||||||
class Armor : public MWWorld::Class
|
class Armor : public MWWorld::Class
|
||||||
{
|
{
|
||||||
|
virtual MWWorld::Ptr
|
||||||
|
moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
||||||
|
|
|
@ -157,4 +157,12 @@ namespace MWClass
|
||||||
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionRead(ptr));
|
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionRead(ptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MWWorld::Ptr
|
||||||
|
Book::moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const
|
||||||
|
{
|
||||||
|
MWWorld::LiveCellRef<ESM::Book> *ref =
|
||||||
|
ptr.get<ESM::Book>();
|
||||||
|
|
||||||
|
return MWWorld::Ptr(&cell.books.insert(*ref), &cell);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,9 @@ namespace MWClass
|
||||||
{
|
{
|
||||||
class Book : public MWWorld::Class
|
class Book : public MWWorld::Class
|
||||||
{
|
{
|
||||||
|
virtual MWWorld::Ptr
|
||||||
|
moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
||||||
|
|
|
@ -227,4 +227,13 @@ namespace MWClass
|
||||||
|
|
||||||
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionEquip(ptr));
|
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionEquip(ptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MWWorld::Ptr
|
||||||
|
Clothing::moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const
|
||||||
|
{
|
||||||
|
MWWorld::LiveCellRef<ESM::Clothing> *ref =
|
||||||
|
ptr.get<ESM::Clothing>();
|
||||||
|
|
||||||
|
return MWWorld::Ptr(&cell.clothes.insert(*ref), &cell);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,9 @@ namespace MWClass
|
||||||
{
|
{
|
||||||
class Clothing : public MWWorld::Class
|
class Clothing : public MWWorld::Class
|
||||||
{
|
{
|
||||||
|
virtual MWWorld::Ptr
|
||||||
|
moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
||||||
|
|
|
@ -207,4 +207,13 @@ namespace MWClass
|
||||||
{
|
{
|
||||||
ptr.getCellRef().lockLevel = 0;
|
ptr.getCellRef().lockLevel = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MWWorld::Ptr
|
||||||
|
Container::moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const
|
||||||
|
{
|
||||||
|
MWWorld::LiveCellRef<ESM::Container> *ref =
|
||||||
|
ptr.get<ESM::Container>();
|
||||||
|
|
||||||
|
return MWWorld::Ptr(&cell.containers.insert(*ref), &cell);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,10 @@ namespace MWClass
|
||||||
{
|
{
|
||||||
void ensureCustomData (const MWWorld::Ptr& ptr) const;
|
void ensureCustomData (const MWWorld::Ptr& ptr) const;
|
||||||
|
|
||||||
|
|
||||||
|
virtual MWWorld::Ptr
|
||||||
|
moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
||||||
|
|
|
@ -195,4 +195,13 @@ namespace MWClass
|
||||||
|
|
||||||
return weight;
|
return weight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MWWorld::Ptr
|
||||||
|
Creature::moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const
|
||||||
|
{
|
||||||
|
MWWorld::LiveCellRef<ESM::Creature> *ref =
|
||||||
|
ptr.get<ESM::Creature>();
|
||||||
|
|
||||||
|
return MWWorld::Ptr(&cell.creatures.insert(*ref), &cell);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,9 @@ namespace MWClass
|
||||||
{
|
{
|
||||||
void ensureCustomData (const MWWorld::Ptr& ptr) const;
|
void ensureCustomData (const MWWorld::Ptr& ptr) const;
|
||||||
|
|
||||||
|
virtual MWWorld::Ptr
|
||||||
|
moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual std::string getId (const MWWorld::Ptr& ptr) const;
|
virtual std::string getId (const MWWorld::Ptr& ptr) const;
|
||||||
|
|
|
@ -209,4 +209,13 @@ namespace MWClass
|
||||||
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MWWorld::Ptr
|
||||||
|
Door::moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const
|
||||||
|
{
|
||||||
|
MWWorld::LiveCellRef<ESM::Door> *ref =
|
||||||
|
ptr.get<ESM::Door>();
|
||||||
|
|
||||||
|
return MWWorld::Ptr(&cell.doors.insert(*ref), &cell);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,9 @@ namespace MWClass
|
||||||
{
|
{
|
||||||
class Door : public MWWorld::Class
|
class Door : public MWWorld::Class
|
||||||
{
|
{
|
||||||
|
virtual MWWorld::Ptr
|
||||||
|
moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
||||||
|
|
|
@ -156,4 +156,13 @@ namespace MWClass
|
||||||
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MWWorld::Ptr
|
||||||
|
Ingredient::moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const
|
||||||
|
{
|
||||||
|
MWWorld::LiveCellRef<ESM::Ingredient> *ref =
|
||||||
|
ptr.get<ESM::Ingredient>();
|
||||||
|
|
||||||
|
return MWWorld::Ptr(&cell.ingreds.insert(*ref), &cell);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,9 @@ namespace MWClass
|
||||||
{
|
{
|
||||||
class Ingredient : public MWWorld::Class
|
class Ingredient : public MWWorld::Class
|
||||||
{
|
{
|
||||||
|
virtual MWWorld::Ptr
|
||||||
|
moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
||||||
|
|
|
@ -196,4 +196,13 @@ namespace MWClass
|
||||||
|
|
||||||
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionEquip(ptr));
|
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionEquip(ptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MWWorld::Ptr
|
||||||
|
Light::moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const
|
||||||
|
{
|
||||||
|
MWWorld::LiveCellRef<ESM::Light> *ref =
|
||||||
|
ptr.get<ESM::Light>();
|
||||||
|
|
||||||
|
return MWWorld::Ptr(&cell.lights.insert(*ref), &cell);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,9 @@ namespace MWClass
|
||||||
{
|
{
|
||||||
class Light : public MWWorld::Class
|
class Light : public MWWorld::Class
|
||||||
{
|
{
|
||||||
|
virtual MWWorld::Ptr
|
||||||
|
moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
||||||
|
|
|
@ -165,4 +165,13 @@ namespace MWClass
|
||||||
|
|
||||||
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionEquip(ptr));
|
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionEquip(ptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MWWorld::Ptr
|
||||||
|
Lockpick::moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const
|
||||||
|
{
|
||||||
|
MWWorld::LiveCellRef<ESM::Tool> *ref =
|
||||||
|
ptr.get<ESM::Tool>();
|
||||||
|
|
||||||
|
return MWWorld::Ptr(&cell.lockpicks.insert(*ref), &cell);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,9 @@ namespace MWClass
|
||||||
{
|
{
|
||||||
class Lockpick : public MWWorld::Class
|
class Lockpick : public MWWorld::Class
|
||||||
{
|
{
|
||||||
|
virtual MWWorld::Ptr
|
||||||
|
moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include "../mwworld/actiontake.hpp"
|
#include "../mwworld/actiontake.hpp"
|
||||||
#include "../mwworld/cellstore.hpp"
|
#include "../mwworld/cellstore.hpp"
|
||||||
#include "../mwworld/physicssystem.hpp"
|
#include "../mwworld/physicssystem.hpp"
|
||||||
|
#include "../mwworld/manualref.hpp"
|
||||||
|
|
||||||
#include "../mwgui/window_manager.hpp"
|
#include "../mwgui/window_manager.hpp"
|
||||||
#include "../mwgui/tooltips.hpp"
|
#include "../mwgui/tooltips.hpp"
|
||||||
|
@ -183,4 +184,39 @@ namespace MWClass
|
||||||
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MWWorld::Ptr
|
||||||
|
Miscellaneous::moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const
|
||||||
|
{
|
||||||
|
MWWorld::Ptr newPtr;
|
||||||
|
|
||||||
|
const ESMS::ESMStore &store =
|
||||||
|
MWBase::Environment::get().getWorld()->getStore();
|
||||||
|
|
||||||
|
if (MWWorld::Class::get(ptr).getName(ptr) == store.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";
|
||||||
|
|
||||||
|
// Really, I have no idea why moving ref out of conditional
|
||||||
|
// scope causes list::push_back throwing std::bad_alloc
|
||||||
|
MWWorld::ManualRef newRef(store, base);
|
||||||
|
MWWorld::LiveCellRef<ESM::Miscellaneous> *ref =
|
||||||
|
newRef.getPtr().get<ESM::Miscellaneous>();
|
||||||
|
newPtr = MWWorld::Ptr(&cell.miscItems.insert(*ref), &cell);
|
||||||
|
} else {
|
||||||
|
MWWorld::LiveCellRef<ESM::Miscellaneous> *ref =
|
||||||
|
ptr.get<ESM::Miscellaneous>();
|
||||||
|
newPtr = MWWorld::Ptr(&cell.miscItems.insert(*ref), &cell);
|
||||||
|
}
|
||||||
|
return newPtr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,9 @@ namespace MWClass
|
||||||
{
|
{
|
||||||
class Miscellaneous : public MWWorld::Class
|
class Miscellaneous : public MWWorld::Class
|
||||||
{
|
{
|
||||||
|
virtual MWWorld::Ptr
|
||||||
|
moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
||||||
|
|
|
@ -380,4 +380,13 @@ namespace MWClass
|
||||||
y = 0;
|
y = 0;
|
||||||
x = 0;
|
x = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MWWorld::Ptr
|
||||||
|
Npc::moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const
|
||||||
|
{
|
||||||
|
MWWorld::LiveCellRef<ESM::NPC> *ref =
|
||||||
|
ptr.get<ESM::NPC>();
|
||||||
|
|
||||||
|
return MWWorld::Ptr(&cell.npcs.insert(*ref), &cell);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,9 @@ namespace MWClass
|
||||||
{
|
{
|
||||||
void ensureCustomData (const MWWorld::Ptr& ptr) const;
|
void ensureCustomData (const MWWorld::Ptr& ptr) const;
|
||||||
|
|
||||||
|
virtual MWWorld::Ptr
|
||||||
|
moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual std::string getId (const MWWorld::Ptr& ptr) const;
|
virtual std::string getId (const MWWorld::Ptr& ptr) const;
|
||||||
|
|
|
@ -160,4 +160,14 @@ namespace MWClass
|
||||||
return boost::shared_ptr<MWWorld::Action> (
|
return boost::shared_ptr<MWWorld::Action> (
|
||||||
new MWWorld::ActionApply (actor, ref->base->mId, actor));
|
new MWWorld::ActionApply (actor, ref->base->mId, actor));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MWWorld::Ptr
|
||||||
|
Potion::moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const
|
||||||
|
{
|
||||||
|
MWWorld::LiveCellRef<ESM::Potion> *ref =
|
||||||
|
ptr.get<ESM::Potion>();
|
||||||
|
|
||||||
|
return MWWorld::Ptr(&cell.potions.insert(*ref), &cell);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,9 @@ namespace MWClass
|
||||||
{
|
{
|
||||||
class Potion : public MWWorld::Class
|
class Potion : public MWWorld::Class
|
||||||
{
|
{
|
||||||
|
virtual MWWorld::Ptr
|
||||||
|
moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
||||||
|
|
|
@ -164,4 +164,14 @@ namespace MWClass
|
||||||
|
|
||||||
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionEquip(ptr));
|
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionEquip(ptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MWWorld::Ptr
|
||||||
|
Probe::moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const
|
||||||
|
{
|
||||||
|
MWWorld::LiveCellRef<ESM::Probe> *ref =
|
||||||
|
ptr.get<ESM::Probe>();
|
||||||
|
|
||||||
|
return MWWorld::Ptr(&cell.probes.insert(*ref), &cell);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,9 @@ namespace MWClass
|
||||||
{
|
{
|
||||||
class Probe : public MWWorld::Class
|
class Probe : public MWWorld::Class
|
||||||
{
|
{
|
||||||
|
virtual MWWorld::Ptr
|
||||||
|
moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
||||||
|
|
|
@ -146,4 +146,13 @@ namespace MWClass
|
||||||
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MWWorld::Ptr
|
||||||
|
Repair::moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const
|
||||||
|
{
|
||||||
|
MWWorld::LiveCellRef<ESM::Repair> *ref =
|
||||||
|
ptr.get<ESM::Repair>();
|
||||||
|
|
||||||
|
return MWWorld::Ptr(&cell.repairs.insert(*ref), &cell);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,9 @@ namespace MWClass
|
||||||
{
|
{
|
||||||
class Repair : public MWWorld::Class
|
class Repair : public MWWorld::Class
|
||||||
{
|
{
|
||||||
|
virtual MWWorld::Ptr
|
||||||
|
moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
||||||
|
|
|
@ -53,4 +53,13 @@ namespace MWClass
|
||||||
|
|
||||||
registerClass (typeid (ESM::Static).name(), instance);
|
registerClass (typeid (ESM::Static).name(), instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MWWorld::Ptr
|
||||||
|
Static::moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const
|
||||||
|
{
|
||||||
|
MWWorld::LiveCellRef<ESM::Static> *ref =
|
||||||
|
ptr.get<ESM::Static>();
|
||||||
|
|
||||||
|
return MWWorld::Ptr(&cell.statics.insert(*ref), &cell);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,9 @@ namespace MWClass
|
||||||
{
|
{
|
||||||
class Static : public MWWorld::Class
|
class Static : public MWWorld::Class
|
||||||
{
|
{
|
||||||
|
virtual MWWorld::Ptr
|
||||||
|
moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
||||||
|
|
|
@ -365,4 +365,13 @@ namespace MWClass
|
||||||
|
|
||||||
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionEquip(ptr));
|
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionEquip(ptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MWWorld::Ptr
|
||||||
|
Weapon::moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const
|
||||||
|
{
|
||||||
|
MWWorld::LiveCellRef<ESM::Weapon> *ref =
|
||||||
|
ptr.get<ESM::Weapon>();
|
||||||
|
|
||||||
|
return MWWorld::Ptr(&cell.weapons.insert(*ref), &cell);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,9 @@ namespace MWClass
|
||||||
{
|
{
|
||||||
class Weapon : public MWWorld::Class
|
class Weapon : public MWWorld::Class
|
||||||
{
|
{
|
||||||
|
virtual MWWorld::Ptr
|
||||||
|
moveToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
||||||
|
|
|
@ -8,8 +8,6 @@
|
||||||
#include "../mwbase/world.hpp"
|
#include "../mwbase/world.hpp"
|
||||||
|
|
||||||
#include "ptr.hpp"
|
#include "ptr.hpp"
|
||||||
#include "manualref.hpp"
|
|
||||||
#include "class.hpp"
|
|
||||||
|
|
||||||
namespace MWWorld
|
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,8 +155,6 @@ namespace MWWorld
|
||||||
forEachImp (functor, weapons);
|
forEachImp (functor, weapons);
|
||||||
}
|
}
|
||||||
|
|
||||||
const MWWorld::Ptr insertObject(const MWWorld::Ptr &ptr, const ESM::Position &pos);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
template<class Functor, class List>
|
template<class Functor, class List>
|
||||||
|
|
|
@ -5,7 +5,10 @@
|
||||||
|
|
||||||
#include <OgreVector3.h>
|
#include <OgreVector3.h>
|
||||||
|
|
||||||
|
#include <components/esm/defs.hpp>
|
||||||
|
|
||||||
#include "ptr.hpp"
|
#include "ptr.hpp"
|
||||||
|
#include "refdata.hpp"
|
||||||
#include "nullaction.hpp"
|
#include "nullaction.hpp"
|
||||||
#include "containerstore.hpp"
|
#include "containerstore.hpp"
|
||||||
|
|
||||||
|
@ -217,4 +220,32 @@ namespace MWWorld
|
||||||
{
|
{
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MWWorld::Ptr
|
||||||
|
Class::moveToCellImpl(const Ptr &ptr, CellStore &cell) const
|
||||||
|
{
|
||||||
|
throw std::runtime_error("unable to move class to cell");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MWWorld::Ptr
|
||||||
|
Class::moveToCell(const Ptr &ptr, CellStore &cell) const
|
||||||
|
{
|
||||||
|
Ptr newPtr = moveToCellImpl(ptr, cell);
|
||||||
|
|
||||||
|
newPtr.getRefData().setCount(ptr.getRefData().getCount());
|
||||||
|
ptr.getRefData().setCount(0);
|
||||||
|
newPtr.getRefData().enable();
|
||||||
|
|
||||||
|
return newPtr;
|
||||||
|
}
|
||||||
|
|
||||||
|
MWWorld::Ptr
|
||||||
|
Class::moveToCell(const Ptr &ptr, CellStore &cell, const ESM::Position &pos) const
|
||||||
|
{
|
||||||
|
Ptr newPtr = moveToCell(ptr, cell);
|
||||||
|
newPtr.getRefData().getPosition() = pos;
|
||||||
|
|
||||||
|
return newPtr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,12 +31,18 @@ namespace MWGui
|
||||||
struct ToolTipInfo;
|
struct ToolTipInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace ESM
|
||||||
|
{
|
||||||
|
struct Position;
|
||||||
|
}
|
||||||
|
|
||||||
namespace MWWorld
|
namespace MWWorld
|
||||||
{
|
{
|
||||||
class Ptr;
|
class Ptr;
|
||||||
class ContainerStore;
|
class ContainerStore;
|
||||||
class InventoryStore;
|
class InventoryStore;
|
||||||
class PhysicsSystem;
|
class PhysicsSystem;
|
||||||
|
class CellStore;
|
||||||
|
|
||||||
/// \brief Base class for referenceable esm records
|
/// \brief Base class for referenceable esm records
|
||||||
class Class
|
class Class
|
||||||
|
@ -51,6 +57,8 @@ namespace MWWorld
|
||||||
|
|
||||||
Class();
|
Class();
|
||||||
|
|
||||||
|
virtual Ptr moveToCellImpl(const Ptr &ptr, CellStore &cell) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// NPC-stances.
|
/// NPC-stances.
|
||||||
|
@ -206,6 +214,12 @@ namespace MWWorld
|
||||||
virtual void adjustRotation(const MWWorld::Ptr& ptr,float& x,float& y,float& z) const;
|
virtual void adjustRotation(const MWWorld::Ptr& ptr,float& x,float& y,float& z) const;
|
||||||
|
|
||||||
virtual std::string getModel(const MWWorld::Ptr &ptr) const;
|
virtual std::string getModel(const MWWorld::Ptr &ptr) const;
|
||||||
|
|
||||||
|
virtual Ptr
|
||||||
|
moveToCell(const Ptr &ptr, CellStore &cell) const;
|
||||||
|
|
||||||
|
virtual Ptr
|
||||||
|
moveToCell(const Ptr &ptr, CellStore &cell, const ESM::Position &pos) const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1042,7 +1042,9 @@ namespace MWWorld
|
||||||
{
|
{
|
||||||
mLocalScripts.remove(object);
|
mLocalScripts.remove(object);
|
||||||
|
|
||||||
MWWorld::Ptr dropped = cell.insertObject(object, pos);
|
MWWorld::Ptr dropped =
|
||||||
|
MWWorld::Class::get(object).moveToCell(object, cell, pos);
|
||||||
|
|
||||||
mWorldScene->addObjectToScene(dropped);
|
mWorldScene->addObjectToScene(dropped);
|
||||||
|
|
||||||
std::string script = MWWorld::Class::get(dropped).getScript(dropped);
|
std::string script = MWWorld::Class::get(dropped).getScript(dropped);
|
||||||
|
|
Loading…
Reference in a new issue