forked from teamnwah/openmw-tes3coop
gold dropping works without crash, but the code needs clean up.
This commit is contained in:
parent
178ad876d7
commit
fca9f1fc5f
2 changed files with 40 additions and 24 deletions
|
@ -9,6 +9,9 @@
|
||||||
|
|
||||||
#include "../mwgui/window_manager.hpp"
|
#include "../mwgui/window_manager.hpp"
|
||||||
|
|
||||||
|
#include "../mwworld/world.hpp" /// FIXME
|
||||||
|
#include "../mwworld/manualref.hpp" /// FIXME
|
||||||
|
|
||||||
#include "ptr.hpp"
|
#include "ptr.hpp"
|
||||||
#include "player.hpp"
|
#include "player.hpp"
|
||||||
#include "class.hpp"
|
#include "class.hpp"
|
||||||
|
@ -326,6 +329,8 @@ namespace MWWorld
|
||||||
insertCellRefList(mRendering, cell.weapons, cell, *mPhysics);
|
insertCellRefList(mRendering, cell.weapons, cell, *mPhysics);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// \todo this whole code needs major clean up, and doesn't belong in this class.
|
||||||
void Scene::insertObject(MWWorld::Ptr ptr, Ptr::CellStore* cell)
|
void Scene::insertObject(MWWorld::Ptr ptr, Ptr::CellStore* cell)
|
||||||
{
|
{
|
||||||
std::string type = ptr.getTypeName();
|
std::string type = ptr.getTypeName();
|
||||||
|
@ -401,9 +406,41 @@ namespace MWWorld
|
||||||
}
|
}
|
||||||
else if (type == typeid(ESM::Miscellaneous).name())
|
else if (type == typeid(ESM::Miscellaneous).name())
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Miscellaneous, MWWorld::RefData>* ref = ptr.get<ESM::Miscellaneous>();
|
|
||||||
cell->miscItems.list.push_back( *ref );
|
// if this is gold, we need to fetch the correct mesh depending on the amount of gold.
|
||||||
newPtr = MWWorld::Ptr(&cell->miscItems.list.back(), cell);
|
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);
|
||||||
|
|
||||||
|
ESMS::LiveCellRef<ESM::Miscellaneous, MWWorld::RefData>* ref = newRef.getPtr().get<ESM::Miscellaneous>();
|
||||||
|
|
||||||
|
cell->miscItems.list.push_back( *ref );
|
||||||
|
newPtr = MWWorld::Ptr(&cell->miscItems.list.back(), cell);
|
||||||
|
|
||||||
|
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
|
||||||
|
{
|
||||||
|
ESMS::LiveCellRef<ESM::Miscellaneous, MWWorld::RefData>* ref = ptr.get<ESM::Miscellaneous>();
|
||||||
|
|
||||||
|
cell->miscItems.list.push_back( *ref );
|
||||||
|
newPtr = MWWorld::Ptr(&cell->miscItems.list.back(), cell);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
throw std::runtime_error("Trying to insert object of unhandled type");
|
throw std::runtime_error("Trying to insert object of unhandled type");
|
||||||
|
|
|
@ -982,27 +982,6 @@ namespace MWWorld
|
||||||
else
|
else
|
||||||
cell = getPlayer().getPlayer().getCell();
|
cell = getPlayer().getPlayer().getCell();
|
||||||
|
|
||||||
// if this is gold, we need to fetch the correct mesh depending on the amount of gold.
|
|
||||||
if (MWWorld::Class::get(object).getName(object) == getStore().gameSettings.search("sGold")->str)
|
|
||||||
{
|
|
||||||
int goldAmount = object.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";
|
|
||||||
|
|
||||||
std::cout << "using " << base << std::endl;
|
|
||||||
MWWorld::ManualRef newRef (getStore(), base);
|
|
||||||
object = newRef.getPtr();
|
|
||||||
object.getRefData().setCount(goldAmount);
|
|
||||||
}
|
|
||||||
|
|
||||||
ESM::Position& pos = object.getRefData().getPosition();
|
ESM::Position& pos = object.getRefData().getPosition();
|
||||||
pos.pos[0] = result.second[0];
|
pos.pos[0] = result.second[0];
|
||||||
pos.pos[1] = -result.second[2];
|
pos.pos[1] = -result.second[2];
|
||||||
|
|
Loading…
Reference in a new issue