Clean-up. There is still a little bug.

This commit is contained in:
gugus 2012-09-17 13:36:48 +02:00
parent d261263824
commit 032ff7c879
4 changed files with 31 additions and 16 deletions

View file

@ -187,6 +187,9 @@ namespace MWBase
virtual void rotateObject(const MWWorld::Ptr& ptr,float x,float y,float z, bool adjust = false) = 0;
virtual void safePlaceObject(const MWWorld::Ptr& ptr,MWWorld::CellStore &Cell,ESM::Position pos) = 0;
///< place an object in a "safe" location (ie not in the void, etc). Makes a copy of the Ptr.
virtual void indexToPosition (int cellX, int cellY, float &x, float &y, bool centre = false)
const = 0;
///< Convert cell numbers to position.

View file

@ -19,6 +19,7 @@
#include "../mwworld/player.hpp"
#include "components\esm\loadcell.hpp"
#include "../mwworld/manualref.hpp"
#include "OgreMath.h"
namespace MWScript
@ -369,7 +370,7 @@ namespace MWScript
pos.rot[0] = pos.rot[1] = 0;
pos.rot[2] = zRot;
MWWorld::Ptr ptr = MWBase::Environment::get().getWorld()->getPtr(itemID,false);
MWBase::Environment::get().getWorld()->copyObjectToCell(ptr,*store,pos);
MWBase::Environment::get().getWorld()->safePlaceObject(ptr,*store,pos);
}
else
{
@ -412,7 +413,7 @@ namespace MWScript
pos.rot[0] = pos.rot[1] = 0;
pos.rot[2] = zRot;
MWWorld::Ptr ptr = MWBase::Environment::get().getWorld()->getPtr(itemID,false);
MWBase::Environment::get().getWorld()->copyObjectToCell(ptr,*store,pos);
MWBase::Environment::get().getWorld()->safePlaceObject(ptr,*store,pos);
}
else
{
@ -450,13 +451,14 @@ namespace MWScript
ipos.pos[0] = pos.x;
ipos.pos[1] = pos.y;
ipos.pos[2] = pos.z;
ipos.rot[0] = 0;
ipos.rot[1] = 0;
ipos.rot[2] = 0;
MWWorld::CellStore* store = MWBase::Environment::get().getWorld()->getPlayer().getPlayer().getCell();
MWWorld::Ptr ptr = MWBase::Environment::get().getWorld()->getPtr(itemID,false);
int icount = ptr.getRefData().getCount();
ptr.getRefData().setCount(count);
MWBase::Environment::get().getWorld()->copyObjectToCell(ptr,*store,ipos);
ptr.getRefData().setCount(icount);
//store->ge
MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(),itemID);
ref.getPtr().getRefData().setCount(count);
MWBase::Environment::get().getWorld()->safePlaceObject(ref.getPtr(),*store,ipos);
}
};
@ -491,13 +493,15 @@ namespace MWScript
ipos.pos[0] = pos.x;
ipos.pos[1] = pos.y;
ipos.pos[2] = pos.z;
ipos.rot[0] = 0;
ipos.rot[1] = 0;
ipos.rot[2] = 0;
MWWorld::CellStore* store = me.getCell();
MWWorld::Ptr ptr = MWBase::Environment::get().getWorld()->getPtr(itemID,false);
int icount = ptr.getRefData().getCount();
ptr.getRefData().setCount(count);
MWBase::Environment::get().getWorld()->copyObjectToCell(ptr,*store,ipos);
ptr.getRefData().setCount(icount);
//store->ge
MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(),itemID);
ref.getPtr().getRefData().setCount(count);
MWBase::Environment::get().getWorld()->safePlaceObject(ref.getPtr(),*store,ipos);
}
};
@ -566,8 +570,8 @@ namespace MWScript
interpreter.installSegment5(opcodePlaceItemCell,new OpPlaceItemCell<ImplicitRef>);
interpreter.installSegment5(opcodePlaceItem,new OpPlaceItem<ImplicitRef>);
interpreter.installSegment5(opcodePlaceAtPc,new OpPlaceAtPc<ImplicitRef>);
interpreter.installSegment5(opcodePlaceAtMe,new OpPlaceAtPc<ImplicitRef>);
interpreter.installSegment5(opcodePlaceAtMeExplicit,new OpPlaceAtPc<ExplicitRef>);
interpreter.installSegment5(opcodePlaceAtMe,new OpPlaceAtMe<ImplicitRef>);
interpreter.installSegment5(opcodePlaceAtMeExplicit,new OpPlaceAtMe<ExplicitRef>);
}
}
}

View file

@ -656,6 +656,11 @@ namespace MWWorld
}
}
void World::safePlaceObject(const MWWorld::Ptr& ptr,MWWorld::CellStore &Cell,ESM::Position pos)
{
copyObjectToCell(ptr,Cell,pos);
}
void World::indexToPosition (int cellX, int cellY, float &x, float &y, bool centre) const
{
const int cellSize = 8192;

View file

@ -214,6 +214,9 @@ namespace MWWorld
/// \param adjust indicates rotation should be set or adjusted
virtual void rotateObject (const Ptr& ptr,float x,float y,float z, bool adjust = false);
virtual void safePlaceObject(const MWWorld::Ptr& ptr,MWWorld::CellStore &Cell,ESM::Position pos);
///< place an object in a "safe" location (ie not in the void, etc). Makes a copy of the Ptr.
virtual void indexToPosition (int cellX, int cellY, float &x, float &y, bool centre = false)
const;
///< Convert cell numbers to position.