[Client] Only require refNumIndex & mpNum for CellStore::searchExact()

0.6.1
David Cernat 8 years ago
parent 8f2ef83be1
commit 7177d56cfb

@ -395,7 +395,7 @@ void Cell::initializeDedicatedActors(ActorList& actorList)
// If this key doesn't exist, create it
if (dedicatedActors.count(mapIndex) == 0)
{
MWWorld::Ptr ptrFound = store->searchExact(baseActor.refId, baseActor.refNumIndex, baseActor.mpNum);
MWWorld::Ptr ptrFound = store->searchExact(baseActor.refNumIndex, baseActor.mpNum);
if (!ptrFound) return;

@ -670,8 +670,7 @@ void LocalPlayer::addJournalItems()
if (!ptrCellStore) continue;
MWWorld::Ptr ptrFound = ptrCellStore->searchExact(journalItem.actorRefId,
journalItem.actorRefNumIndex, journalItem.actorMpNum);
MWWorld::Ptr ptrFound = ptrCellStore->searchExact(journalItem.actorRefNumIndex, journalItem.actorMpNum);
if (!ptrFound)
{

@ -159,17 +159,13 @@ void MechanicsHelper::processAttack(Attack attack, const MWWorld::Ptr& attacker)
}
else
{
if (mwmp::Main::get().getCellController()->isLocalActor(attack.target.refId,
attack.target.refNumIndex, attack.target.mpNum))
if (mwmp::Main::get().getCellController()->isLocalActor(attack.target.refNumIndex, attack.target.mpNum))
{
victim = mwmp::Main::get().getCellController()->getLocalActor(attack.target.refId,
attack.target.refNumIndex, attack.target.mpNum)->getPtr();
victim = mwmp::Main::get().getCellController()->getLocalActor(attack.target.refNumIndex, attack.target.mpNum)->getPtr();
}
else if (mwmp::Main::get().getCellController()->isDedicatedActor(attack.target.refId,
attack.target.refNumIndex, attack.target.mpNum))
else if (mwmp::Main::get().getCellController()->isDedicatedActor(attack.target.refNumIndex, attack.target.mpNum))
{
victim = mwmp::Main::get().getCellController()->getDedicatedActor(attack.target.refId,
attack.target.refNumIndex, attack.target.mpNum)->getPtr();
victim = mwmp::Main::get().getCellController()->getDedicatedActor(attack.target.refNumIndex, attack.target.mpNum)->getPtr();
}
}

@ -59,7 +59,7 @@ void WorldEvent::editContainers(MWWorld::CellStore* cellStore)
//LOG_APPEND(Log::LOG_VERBOSE, "- cellRef: %s, %i, %i", worldObject.refId.c_str(), worldObject.refNumIndex, worldObject.mpNum);
MWWorld::Ptr ptrFound = cellStore->searchExact(worldObject.refId, worldObject.refNumIndex, worldObject.mpNum);
MWWorld::Ptr ptrFound = cellStore->searchExact(worldObject.refNumIndex, worldObject.mpNum);
if (ptrFound)
{
@ -136,7 +136,7 @@ void WorldEvent::placeObjects(MWWorld::CellStore* cellStore)
LOG_APPEND(Log::LOG_VERBOSE, "- cellRef: %s, %i, %i, charge: %i, count: %i", worldObject.refId.c_str(),
worldObject.refNumIndex, worldObject.mpNum, worldObject.charge, worldObject.count);
MWWorld::Ptr ptrFound = cellStore->searchExact(worldObject.refId, 0, worldObject.mpNum);
MWWorld::Ptr ptrFound = cellStore->searchExact(0, worldObject.mpNum);
// Only create this object if it doesn't already exist
if (!ptrFound)
@ -172,7 +172,7 @@ void WorldEvent::deleteObjects(MWWorld::CellStore* cellStore)
LOG_APPEND(Log::LOG_VERBOSE, "- cellRef: %s, %i, %i", worldObject.refId.c_str(), worldObject.refNumIndex, worldObject.mpNum);
MWWorld::Ptr ptrFound = cellStore->searchExact(worldObject.refId, worldObject.refNumIndex, worldObject.mpNum);
MWWorld::Ptr ptrFound = cellStore->searchExact(worldObject.refNumIndex, worldObject.mpNum);
if (ptrFound)
{
@ -207,7 +207,7 @@ void WorldEvent::lockObjects(MWWorld::CellStore* cellStore)
LOG_APPEND(Log::LOG_VERBOSE, "- cellRef: %s, %i, %i", worldObject.refId.c_str(), worldObject.refNumIndex, worldObject.mpNum);
MWWorld::Ptr ptrFound = cellStore->searchExact(worldObject.refId, worldObject.refNumIndex, worldObject.mpNum);
MWWorld::Ptr ptrFound = cellStore->searchExact(worldObject.refNumIndex, worldObject.mpNum);
if (ptrFound)
{
@ -232,7 +232,7 @@ void WorldEvent::triggerTrapObjects(MWWorld::CellStore* cellStore)
LOG_APPEND(Log::LOG_VERBOSE, "- cellRef: %s, %i, %i", worldObject.refId.c_str(), worldObject.refNumIndex, worldObject.mpNum);
MWWorld::Ptr ptrFound = cellStore->searchExact(worldObject.refId, worldObject.refNumIndex, worldObject.mpNum);
MWWorld::Ptr ptrFound = cellStore->searchExact(worldObject.refNumIndex, worldObject.mpNum);
if (ptrFound)
{
@ -262,7 +262,7 @@ void WorldEvent::scaleObjects(MWWorld::CellStore* cellStore)
LOG_APPEND(Log::LOG_VERBOSE, "- cellRef: %s, %i, %i, scale: %f", worldObject.refId.c_str(), worldObject.refNumIndex,
worldObject.mpNum, worldObject.scale);
MWWorld::Ptr ptrFound = cellStore->searchExact(worldObject.refId, worldObject.refNumIndex, worldObject.mpNum);
MWWorld::Ptr ptrFound = cellStore->searchExact(worldObject.refNumIndex, worldObject.mpNum);
if (ptrFound)
{
@ -284,7 +284,7 @@ void WorldEvent::moveObjects(MWWorld::CellStore* cellStore)
LOG_APPEND(Log::LOG_VERBOSE, "- cellRef: %s, %i, %i", worldObject.refId.c_str(), worldObject.refNumIndex, worldObject.mpNum);
MWWorld::Ptr ptrFound = cellStore->searchExact(worldObject.refId, worldObject.refNumIndex, worldObject.mpNum);
MWWorld::Ptr ptrFound = cellStore->searchExact(worldObject.refNumIndex, worldObject.mpNum);
if (ptrFound)
{
@ -307,7 +307,7 @@ void WorldEvent::rotateObjects(MWWorld::CellStore* cellStore)
LOG_APPEND(Log::LOG_VERBOSE, "- cellRef: %s, %i, %i", worldObject.refId.c_str(), worldObject.refNumIndex, worldObject.mpNum);
MWWorld::Ptr ptrFound = cellStore->searchExact(worldObject.refId, worldObject.refNumIndex, worldObject.mpNum);
MWWorld::Ptr ptrFound = cellStore->searchExact(worldObject.refNumIndex, worldObject.mpNum);
if (ptrFound)
{
@ -330,7 +330,7 @@ void WorldEvent::animateObjects(MWWorld::CellStore* cellStore)
LOG_APPEND(Log::LOG_VERBOSE, "- cellRef: %s, %i, %i", worldObject.refId.c_str(), worldObject.refNumIndex, worldObject.mpNum);
MWWorld::Ptr ptrFound = cellStore->searchExact(worldObject.refId, worldObject.refNumIndex, worldObject.mpNum);
MWWorld::Ptr ptrFound = cellStore->searchExact(worldObject.refNumIndex, worldObject.mpNum);
if (ptrFound)
{
@ -354,7 +354,7 @@ void WorldEvent::activateDoors(MWWorld::CellStore* cellStore)
LOG_APPEND(Log::LOG_VERBOSE, "- cellRef: %s, %i, %i", worldObject.refId.c_str(), worldObject.refNumIndex, worldObject.mpNum);
MWWorld::Ptr ptrFound = cellStore->searchExact(worldObject.refId, worldObject.refNumIndex, worldObject.mpNum);
MWWorld::Ptr ptrFound = cellStore->searchExact(worldObject.refNumIndex, worldObject.mpNum);
if (ptrFound)
{
@ -378,7 +378,7 @@ void WorldEvent::setLocalShorts(MWWorld::CellStore* cellStore)
LOG_APPEND(Log::LOG_VERBOSE, "- cellRef: %s, %i, %i, index: %i, shortVal: %i", worldObject.refId.c_str(),
worldObject.refNumIndex, worldObject.mpNum, worldObject.index, worldObject.shortVal);
MWWorld::Ptr ptrFound = cellStore->searchExact(worldObject.refId, worldObject.refNumIndex, worldObject.mpNum);
MWWorld::Ptr ptrFound = cellStore->searchExact(worldObject.refNumIndex, worldObject.mpNum);
if (ptrFound)
{
@ -401,7 +401,7 @@ void WorldEvent::setLocalFloats(MWWorld::CellStore* cellStore)
LOG_APPEND(Log::LOG_VERBOSE, "- cellRef: %s, %i, %i, index: %i, floatVal: %f", worldObject.refId.c_str(),
worldObject.refNumIndex, worldObject.mpNum, worldObject.index, worldObject.floatVal);
MWWorld::Ptr ptrFound = cellStore->searchExact(worldObject.refId, worldObject.refNumIndex, worldObject.mpNum);
MWWorld::Ptr ptrFound = cellStore->searchExact(worldObject.refNumIndex, worldObject.mpNum);
if (ptrFound)
{

@ -474,12 +474,15 @@ namespace MWWorld
return Ptr();
}
// Added by tes3mp
/*
Start of tes3mp addition
A custom type of search visitor used to find objects by their reference numbers
*/
template <typename PtrType>
struct SearchExactVisitor
{
PtrType mFound;
std::string mIdToFind;
unsigned int mRefNumIndexToFind;
unsigned int mMpNumToFind;
@ -487,56 +490,97 @@ namespace MWWorld
{
if (ptr.getCellRef().getRefNum().mIndex == mRefNumIndexToFind && ptr.getCellRef().getMpNum() == mMpNumToFind)
{
if (ptr.getCellRef().getRefId() == mIdToFind)
{
mFound = ptr;
return false;
}
mFound = ptr;
return false;
}
return true;
}
};
/*
End of tes3mp addition
*/
/*
Start of tes3mp addition
///< Added by tes3mp and used to find an object by both its ID and its reference number
Ptr CellStore::searchExact (const std::string& id, unsigned int refNumIndex, unsigned int mpNum)
Allow the searching of objects by their reference numbers
*/
Ptr CellStore::searchExact (unsigned int refNumIndex, unsigned int mpNum)
{
SearchExactVisitor<MWWorld::Ptr> searchVisitor;
searchVisitor.mIdToFind = id;
searchVisitor.mRefNumIndexToFind = refNumIndex;
searchVisitor.mMpNumToFind = mpNum;
forEach(searchVisitor);
return searchVisitor.mFound;
}
/*
End of tes3mp addition
*/
/*
Start of tes3mp addition
// Added by tes3mp and used to get all the MergedRefs in the cell
Make it possible to get the mMergedRefs in the CellStore from elsewhere in the code
*/
std::vector<LiveCellRefBase*> *CellStore::getMergedRefs()
{
return &mMergedRefs;
}
/*
End of tes3mp addition
*/
/*
Start of tes3mp addition
// Added by tes3mp and used to get all the NPCs in the cell
Make it possible to get the mNPCs in the CellStore from elsewhere in the code
*/
CellRefList<ESM::NPC> *CellStore::getNpcs()
{
return &mNpcs;
}
/*
End of tes3mp addition
*/
// Added by tes3mp and used to get all the creatures in the cell
/*
Start of tes3mp addition
Make it possible to get the mCreatures in the CellStore from elsewhere in the code
*/
CellRefList<ESM::Creature> *CellStore::getCreatures()
{
return &mCreatures;
}
/*
End of tes3mp addition
*/
/*
Start of tes3mp addition
// Added by tes3mp and used to get all the creatures in the cell
Make it possible to get the mCreatureLists in the CellStore from elsewhere in the code
*/
CellRefList<ESM::CreatureLevList> *CellStore::getCreatureLists()
{
return &mCreatureLists;
}
/*
End of tes3mp addition
*/
/*
Start of tes3mp addition
// Added by tes3mp and used to get all the containers in the cell
Make it possible to get the mContainers in the CellStore from elsewhere in the code
*/
CellRefList<ESM::Container> *CellStore::getContainers()
{
return &mContainers;
}
/*
End of tes3mp addition
*/
float CellStore::getWaterLevel() const
{

@ -231,23 +231,65 @@ namespace MWWorld
Ptr searchViaActorId (int id);
///< Will return an empty Ptr if cell is not loaded.
Ptr searchExact (const std::string& id, unsigned int refNumIndex, unsigned int mpNum);
///< Added by tes3mp and used to find an object by both its ID and its reference number
/*
Start of tes3mp addition
Allow the searching of objects by their reference numbers
*/
Ptr searchExact (unsigned int refNumIndex, unsigned int mpNum);
/*
End of tes3mp addition
*/
/*
Start of tes3mp addition
Make it possible to get the mMergedRefs in the CellStore from elsewhere in the code
*/
std::vector<LiveCellRefBase*> *getMergedRefs();
// Added by tes3mp and used to get all the MergedRefs in the cell
/*
End of tes3mp addition
*/
/*
Start of tes3mp addition
Make it possible to get the mNPCs in the CellStore from elsewhere in the code
*/
CellRefList<ESM::NPC> *getNpcs();
// Added by tes3mp and used to get all the NPCs in the cell
/*
End of tes3mp addition
*/
/*
Start of tes3mp addition
Make it possible to get the mCreatures in the CellStore from elsewhere in the code
*/
CellRefList<ESM::Creature> *getCreatures();
// Added by tes3mp and used to get all the creatures in the cell
/*
End of tes3mp addition
*/
/*
Start of tes3mp addition
Make it possible to get the mCreatureLists in the CellStore from elsewhere in the code
*/
CellRefList<ESM::CreatureLevList> *getCreatureLists();
// Added by tes3mp and used to get all the leveled creature lists in the cell
/*
End of tes3mp addition
*/
/*
Start of tes3mp addition
Make it possible to get the mContainers in the CellStore from elsewhere in the code
*/
CellRefList<ESM::Container> *getContainers();
// Added by tes3mp and used to get all the containers in the cell
/*
End of tes3mp addition
*/
float getWaterLevel() const;

Loading…
Cancel
Save