mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-20 07:53:51 +00:00
Remove RefData::getHandle
This commit is contained in:
parent
47758c11cd
commit
19988d5e45
11 changed files with 32 additions and 159 deletions
|
@ -189,12 +189,6 @@ namespace MWBase
|
|||
///< Return a pointer to a liveCellRef with the given name.
|
||||
/// \param activeOnly do non search inactive cells.
|
||||
|
||||
virtual MWWorld::Ptr getPtrViaHandle (const std::string& handle) = 0;
|
||||
///< Return a pointer to a liveCellRef with the given Ogre handle.
|
||||
|
||||
virtual MWWorld::Ptr searchPtrViaHandle (const std::string& handle) = 0;
|
||||
///< Return a pointer to a liveCellRef with the given Ogre handle or Ptr() if not found
|
||||
|
||||
virtual MWWorld::Ptr searchPtrViaActorId (int actorId) = 0;
|
||||
///< Search is limited to the active cells.
|
||||
|
||||
|
|
|
@ -966,6 +966,7 @@ namespace MWPhysics
|
|||
|
||||
bool PhysicsSystem::isActorStandingOn(const MWWorld::Ptr &actor, const MWWorld::Ptr &object) const
|
||||
{
|
||||
/*
|
||||
const std::string& actorHandle = actor.getRefData().getHandle();
|
||||
const std::string& objectHandle = object.getRefData().getHandle();
|
||||
|
||||
|
@ -975,11 +976,13 @@ namespace MWPhysics
|
|||
if (it->first == actorHandle && it->second == objectHandle)
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
return false;
|
||||
}
|
||||
|
||||
void PhysicsSystem::getActorsStandingOn(const MWWorld::Ptr &object, std::vector<std::string> &out) const
|
||||
{
|
||||
/*
|
||||
const std::string& objectHandle = object.getRefData().getHandle();
|
||||
|
||||
for (std::map<std::string, std::string>::const_iterator it = mStandingCollisions.begin();
|
||||
|
@ -988,10 +991,12 @@ namespace MWPhysics
|
|||
if (it->second == objectHandle)
|
||||
out.push_back(it->first);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
bool PhysicsSystem::isActorCollidingWith(const MWWorld::Ptr &actor, const MWWorld::Ptr &object) const
|
||||
{
|
||||
/*
|
||||
const std::string& actorHandle = actor.getRefData().getHandle();
|
||||
const std::string& objectHandle = object.getRefData().getHandle();
|
||||
|
||||
|
@ -1001,11 +1006,13 @@ namespace MWPhysics
|
|||
if (it->first == actorHandle && it->second == objectHandle)
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
return false;
|
||||
}
|
||||
|
||||
void PhysicsSystem::getActorsCollidingWith(const MWWorld::Ptr &object, std::vector<std::string> &out) const
|
||||
{
|
||||
/*
|
||||
const std::string& objectHandle = object.getRefData().getHandle();
|
||||
|
||||
for (std::map<std::string, std::string>::const_iterator it = mCollisions.begin();
|
||||
|
@ -1014,6 +1021,7 @@ namespace MWPhysics
|
|||
if (it->second == objectHandle)
|
||||
out.push_back(it->first);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void PhysicsSystem::disableWater()
|
||||
|
|
|
@ -40,16 +40,6 @@ namespace MWWorld
|
|||
mList.push_back(item);
|
||||
return mList.back();
|
||||
}
|
||||
|
||||
LiveCellRef<X> *searchViaHandle (const std::string& handle)
|
||||
{
|
||||
for (typename List::iterator iter (mList.begin()); iter!=mList.end(); ++iter)
|
||||
if (iter->mData.getBaseNode() &&
|
||||
iter->mData.getHandle()==handle)
|
||||
return &*iter;
|
||||
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -282,77 +282,6 @@ namespace MWWorld
|
|||
return Ptr();
|
||||
}
|
||||
|
||||
Ptr CellStore::searchViaHandle (const std::string& handle)
|
||||
{
|
||||
bool oldState = mHasState;
|
||||
|
||||
mHasState = true;
|
||||
|
||||
if (LiveCellRef<ESM::Activator> *ref = mActivators.searchViaHandle (handle))
|
||||
return Ptr (ref, this);
|
||||
|
||||
if (LiveCellRef<ESM::Potion> *ref = mPotions.searchViaHandle (handle))
|
||||
return Ptr (ref, this);
|
||||
|
||||
if (LiveCellRef<ESM::Apparatus> *ref = mAppas.searchViaHandle (handle))
|
||||
return Ptr (ref, this);
|
||||
|
||||
if (LiveCellRef<ESM::Armor> *ref = mArmors.searchViaHandle (handle))
|
||||
return Ptr (ref, this);
|
||||
|
||||
if (LiveCellRef<ESM::Book> *ref = mBooks.searchViaHandle (handle))
|
||||
return Ptr (ref, this);
|
||||
|
||||
if (LiveCellRef<ESM::Clothing> *ref = mClothes.searchViaHandle (handle))
|
||||
return Ptr (ref, this);
|
||||
|
||||
if (LiveCellRef<ESM::Container> *ref = mContainers.searchViaHandle (handle))
|
||||
return Ptr (ref, this);
|
||||
|
||||
if (LiveCellRef<ESM::Creature> *ref = mCreatures.searchViaHandle (handle))
|
||||
return Ptr (ref, this);
|
||||
|
||||
if (LiveCellRef<ESM::Door> *ref = mDoors.searchViaHandle (handle))
|
||||
return Ptr (ref, this);
|
||||
|
||||
if (LiveCellRef<ESM::Ingredient> *ref = mIngreds.searchViaHandle (handle))
|
||||
return Ptr (ref, this);
|
||||
|
||||
if (LiveCellRef<ESM::CreatureLevList> *ref = mCreatureLists.searchViaHandle (handle))
|
||||
return Ptr (ref, this);
|
||||
|
||||
if (LiveCellRef<ESM::ItemLevList> *ref = mItemLists.searchViaHandle (handle))
|
||||
return Ptr (ref, this);
|
||||
|
||||
if (LiveCellRef<ESM::Light> *ref = mLights.searchViaHandle (handle))
|
||||
return Ptr (ref, this);
|
||||
|
||||
if (LiveCellRef<ESM::Lockpick> *ref = mLockpicks.searchViaHandle (handle))
|
||||
return Ptr (ref, this);
|
||||
|
||||
if (LiveCellRef<ESM::Miscellaneous> *ref = mMiscItems.searchViaHandle (handle))
|
||||
return Ptr (ref, this);
|
||||
|
||||
if (LiveCellRef<ESM::NPC> *ref = mNpcs.searchViaHandle (handle))
|
||||
return Ptr (ref, this);
|
||||
|
||||
if (LiveCellRef<ESM::Probe> *ref = mProbes.searchViaHandle (handle))
|
||||
return Ptr (ref, this);
|
||||
|
||||
if (LiveCellRef<ESM::Repair> *ref = mRepairs.searchViaHandle (handle))
|
||||
return Ptr (ref, this);
|
||||
|
||||
if (LiveCellRef<ESM::Static> *ref = mStatics.searchViaHandle (handle))
|
||||
return Ptr (ref, this);
|
||||
|
||||
if (LiveCellRef<ESM::Weapon> *ref = mWeapons.searchViaHandle (handle))
|
||||
return Ptr (ref, this);
|
||||
|
||||
mHasState = oldState;
|
||||
|
||||
return Ptr();
|
||||
}
|
||||
|
||||
Ptr CellStore::searchViaActorId (int id)
|
||||
{
|
||||
if (Ptr ptr = ::searchViaActorId (mNpcs, id, this))
|
||||
|
|
|
@ -94,9 +94,6 @@ namespace MWWorld
|
|||
///< Will return an empty Ptr if cell is not loaded. Does not check references in
|
||||
/// containers.
|
||||
|
||||
Ptr searchViaHandle (const std::string& handle);
|
||||
///< Will return an empty Ptr if cell is not loaded.
|
||||
|
||||
Ptr searchViaActorId (int id);
|
||||
///< Will return an empty Ptr if cell is not loaded.
|
||||
|
||||
|
|
|
@ -123,17 +123,6 @@ namespace MWWorld
|
|||
{}
|
||||
}
|
||||
|
||||
const std::string &RefData::getHandle()
|
||||
{
|
||||
if(!mBaseNode)
|
||||
{
|
||||
static const std::string empty;
|
||||
return empty;
|
||||
}
|
||||
|
||||
return mBaseNode->getName();
|
||||
}
|
||||
|
||||
Ogre::SceneNode* RefData::getBaseNodeOld()
|
||||
{
|
||||
return mBaseNode;
|
||||
|
|
|
@ -81,9 +81,6 @@ namespace MWWorld
|
|||
|
||||
RefData& operator= (const RefData& refData);
|
||||
|
||||
/// Return OGRE handle (may be empty).
|
||||
const std::string &getHandle();
|
||||
|
||||
/// Return OGRE base node (can be a null pointer).
|
||||
/// obsolete
|
||||
Ogre::SceneNode* getBaseNodeOld();
|
||||
|
|
|
@ -563,7 +563,7 @@ namespace MWWorld
|
|||
MWBase::Environment::get().getMechanicsManager()->remove (ptr);
|
||||
MWBase::Environment::get().getSoundManager()->stopSound3D (ptr);
|
||||
mPhysics->remove(ptr);
|
||||
//Rendering.removeObject (ptr);
|
||||
//mRendering.removeObject (ptr);
|
||||
}
|
||||
|
||||
bool Scene::isCellActive(const CellStore &cell)
|
||||
|
@ -578,16 +578,6 @@ namespace MWWorld
|
|||
return false;
|
||||
}
|
||||
|
||||
Ptr Scene::searchPtrViaHandle (const std::string& handle)
|
||||
{
|
||||
for (CellStoreCollection::const_iterator iter (mActiveCells.begin());
|
||||
iter!=mActiveCells.end(); ++iter)
|
||||
if (Ptr ptr = (*iter)->searchViaHandle (handle))
|
||||
return ptr;
|
||||
|
||||
return Ptr();
|
||||
}
|
||||
|
||||
Ptr Scene::searchPtrViaActorId (int actorId)
|
||||
{
|
||||
for (CellStoreCollection::const_iterator iter (mActiveCells.begin());
|
||||
|
|
|
@ -117,8 +117,6 @@ namespace MWWorld
|
|||
|
||||
bool isCellActive(const CellStore &cell);
|
||||
|
||||
Ptr searchPtrViaHandle (const std::string& handle);
|
||||
|
||||
Ptr searchPtrViaActorId (int actorId);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -676,22 +676,6 @@ namespace MWWorld
|
|||
throw std::runtime_error ("unknown ID: " + name);
|
||||
}
|
||||
|
||||
Ptr World::getPtrViaHandle (const std::string& handle)
|
||||
{
|
||||
Ptr res = searchPtrViaHandle (handle);
|
||||
if (res.isEmpty ())
|
||||
throw std::runtime_error ("unknown Ogre handle: " + handle);
|
||||
return res;
|
||||
}
|
||||
|
||||
Ptr World::searchPtrViaHandle (const std::string& handle)
|
||||
{
|
||||
if (mPlayer->getPlayer().getRefData().getHandle()==handle)
|
||||
return mPlayer->getPlayer();
|
||||
|
||||
return mWorldScene->searchPtrViaHandle (handle);
|
||||
}
|
||||
|
||||
Ptr World::searchPtrViaActorId (int actorId)
|
||||
{
|
||||
// The player is not registered in any CellStore so must be checked manually
|
||||
|
@ -1060,10 +1044,10 @@ namespace MWWorld
|
|||
getFacedHandle(facedHandle, activationDistance);
|
||||
}
|
||||
|
||||
if (facedHandle.empty())
|
||||
//if (facedHandle.empty())
|
||||
return MWWorld::Ptr();
|
||||
|
||||
return getPtrViaHandle(facedHandle);
|
||||
//return getPtrViaHandle(facedHandle);
|
||||
}
|
||||
|
||||
std::pair<MWWorld::Ptr,Ogre::Vector3> World::getHitContact(const MWWorld::Ptr &ptr, float distance)
|
||||
|
@ -1083,7 +1067,6 @@ namespace MWWorld
|
|||
if(node != NULL)
|
||||
pos += node->_getDerivedPosition();
|
||||
}
|
||||
*/
|
||||
|
||||
std::pair<std::string,Ogre::Vector3> result;// = mPhysics->getHitContact(ptr.getRefData().getHandle(),
|
||||
// pos, rot, distance);
|
||||
|
@ -1091,6 +1074,8 @@ namespace MWWorld
|
|||
return std::make_pair(MWWorld::Ptr(), Ogre::Vector3(0.0f));
|
||||
|
||||
return std::make_pair(searchPtrViaHandle(result.first), result.second);
|
||||
*/
|
||||
return std::make_pair(MWWorld::Ptr(), Ogre::Vector3(0.0f));
|
||||
}
|
||||
|
||||
void World::deleteObject (const Ptr& ptr)
|
||||
|
@ -1875,10 +1860,11 @@ namespace MWWorld
|
|||
if (normal.angleBetween(Ogre::Vector3(0.f,0.f,1.f)).valueDegrees() >= 30)
|
||||
return false;
|
||||
|
||||
/*
|
||||
MWWorld::Ptr hitObject = searchPtrViaHandle(handle);
|
||||
if (!hitObject.isEmpty() && hitObject.getClass().isActor())
|
||||
return false;
|
||||
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
else
|
||||
|
@ -2239,8 +2225,9 @@ namespace MWWorld
|
|||
if (MWBase::Environment::get().getWindowManager()->isGuiMode())
|
||||
return;
|
||||
|
||||
/*
|
||||
std::vector<std::string> actors;
|
||||
//mPhysics->getActorsStandingOn(object, actors);
|
||||
mPhysics->getActorsStandingOn(object, actors);
|
||||
for (std::vector<std::string>::iterator it = actors.begin(); it != actors.end(); ++it)
|
||||
{
|
||||
MWWorld::Ptr actor = searchPtrViaHandle(*it); // Collision events are from the last frame, actor might no longer exist
|
||||
|
@ -2263,6 +2250,7 @@ namespace MWWorld
|
|||
MWBase::Environment::get().getSoundManager()->playSound3D(actor, "Health Damage", 1.0f, 1.0f);
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void World::hurtCollidingActors(const Ptr &object, float healthPerSecond)
|
||||
|
@ -2270,8 +2258,9 @@ namespace MWWorld
|
|||
if (MWBase::Environment::get().getWindowManager()->isGuiMode())
|
||||
return;
|
||||
|
||||
/*
|
||||
std::vector<std::string> actors;
|
||||
//mPhysics->getActorsCollidingWith(object, actors);
|
||||
mPhysics->getActorsCollidingWith(object, actors);
|
||||
for (std::vector<std::string>::iterator it = actors.begin(); it != actors.end(); ++it)
|
||||
{
|
||||
MWWorld::Ptr actor = searchPtrViaHandle(*it); // Collision events are from the last frame, actor might no longer exist
|
||||
|
@ -2294,6 +2283,7 @@ namespace MWWorld
|
|||
MWBase::Environment::get().getSoundManager()->playSound3D(actor, "Health Damage", 1.0f, 1.0f);
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
float World::getWindSpeed()
|
||||
|
@ -2338,15 +2328,14 @@ namespace MWWorld
|
|||
}
|
||||
}
|
||||
|
||||
struct ListHandlesFunctor
|
||||
struct ListObjectsFunctor
|
||||
{
|
||||
std::vector<std::string> mHandles;
|
||||
std::vector<MWWorld::Ptr> mObjects;
|
||||
|
||||
bool operator() (Ptr ptr)
|
||||
{
|
||||
Ogre::SceneNode* handle = ptr.getRefData().getBaseNodeOld();
|
||||
if (handle)
|
||||
mHandles.push_back(handle->getName());
|
||||
if (ptr.getRefData().getBaseNode())
|
||||
mObjects.push_back(ptr);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
@ -2356,12 +2345,12 @@ namespace MWWorld
|
|||
const Scene::CellStoreCollection& collection = mWorldScene->getActiveCells();
|
||||
for (Scene::CellStoreCollection::const_iterator cellIt = collection.begin(); cellIt != collection.end(); ++cellIt)
|
||||
{
|
||||
ListHandlesFunctor functor;
|
||||
(*cellIt)->forEach<ListHandlesFunctor>(functor);
|
||||
ListObjectsFunctor functor;
|
||||
(*cellIt)->forEach<ListObjectsFunctor>(functor);
|
||||
|
||||
for (std::vector<std::string>::iterator it = functor.mHandles.begin(); it != functor.mHandles.end(); ++it)
|
||||
if (Misc::StringUtils::ciEqual(searchPtrViaHandle(*it).getCellRef().getOwner(), npc.getCellRef().getRefId()))
|
||||
out.push_back(searchPtrViaHandle(*it));
|
||||
for (std::vector<MWWorld::Ptr>::iterator it = functor.mObjects.begin(); it != functor.mObjects.end(); ++it)
|
||||
if (Misc::StringUtils::ciEqual(it->getCellRef().getOwner(), npc.getCellRef().getRefId()))
|
||||
out.push_back(*it);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2714,8 +2703,8 @@ namespace MWWorld
|
|||
// For the player, use camera to aim
|
||||
std::string facedHandle;
|
||||
getFacedHandle(facedHandle, distance);
|
||||
if (!facedHandle.empty())
|
||||
target = getPtrViaHandle(facedHandle);
|
||||
//if (!facedHandle.empty())
|
||||
// target = getPtrViaHandle(facedHandle);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -98,8 +98,6 @@ namespace MWWorld
|
|||
World (const World&);
|
||||
World& operator= (const World&);
|
||||
|
||||
Ptr getPtrViaHandle (const std::string& handle, CellStore& cellStore);
|
||||
|
||||
int mActivationDistanceOverride;
|
||||
|
||||
std::string mStartupScript;
|
||||
|
@ -266,12 +264,6 @@ namespace MWWorld
|
|||
///< Return a pointer to a liveCellRef with the given name.
|
||||
/// \param activeOnly do non search inactive cells.
|
||||
|
||||
virtual Ptr getPtrViaHandle (const std::string& handle);
|
||||
///< Return a pointer to a liveCellRef with the given Ogre handle.
|
||||
|
||||
virtual Ptr searchPtrViaHandle (const std::string& handle);
|
||||
///< Return a pointer to a liveCellRef with the given Ogre handle or Ptr() if not found
|
||||
|
||||
virtual Ptr searchPtrViaActorId (int actorId);
|
||||
///< Search is limited to the active cells.
|
||||
|
||||
|
|
Loading…
Reference in a new issue