[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 this key doesn't exist, create it
if (dedicatedActors.count(mapIndex) == 0) 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; if (!ptrFound) return;

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

@ -159,17 +159,13 @@ void MechanicsHelper::processAttack(Attack attack, const MWWorld::Ptr& attacker)
} }
else else
{ {
if (mwmp::Main::get().getCellController()->isLocalActor(attack.target.refId, if (mwmp::Main::get().getCellController()->isLocalActor(attack.target.refNumIndex, attack.target.mpNum))
attack.target.refNumIndex, attack.target.mpNum))
{ {
victim = mwmp::Main::get().getCellController()->getLocalActor(attack.target.refId, victim = mwmp::Main::get().getCellController()->getLocalActor(attack.target.refNumIndex, attack.target.mpNum)->getPtr();
attack.target.refNumIndex, attack.target.mpNum)->getPtr();
} }
else if (mwmp::Main::get().getCellController()->isDedicatedActor(attack.target.refId, else if (mwmp::Main::get().getCellController()->isDedicatedActor(attack.target.refNumIndex, attack.target.mpNum))
attack.target.refNumIndex, attack.target.mpNum))
{ {
victim = mwmp::Main::get().getCellController()->getDedicatedActor(attack.target.refId, victim = mwmp::Main::get().getCellController()->getDedicatedActor(attack.target.refNumIndex, attack.target.mpNum)->getPtr();
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); //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) 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(), 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); 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 // Only create this object if it doesn't already exist
if (!ptrFound) 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); 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) 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); 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) 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); 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) 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, LOG_APPEND(Log::LOG_VERBOSE, "- cellRef: %s, %i, %i, scale: %f", worldObject.refId.c_str(), worldObject.refNumIndex,
worldObject.mpNum, worldObject.scale); 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) 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); 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) 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); 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) 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); 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) 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); 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) 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(), 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); 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) 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(), 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); 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) if (ptrFound)
{ {

@ -474,12 +474,15 @@ namespace MWWorld
return Ptr(); 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> template <typename PtrType>
struct SearchExactVisitor struct SearchExactVisitor
{ {
PtrType mFound; PtrType mFound;
std::string mIdToFind;
unsigned int mRefNumIndexToFind; unsigned int mRefNumIndexToFind;
unsigned int mMpNumToFind; unsigned int mMpNumToFind;
@ -487,56 +490,97 @@ namespace MWWorld
{ {
if (ptr.getCellRef().getRefNum().mIndex == mRefNumIndexToFind && ptr.getCellRef().getMpNum() == mMpNumToFind) 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; 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 Allow the searching of objects by their reference numbers
Ptr CellStore::searchExact (const std::string& id, unsigned int refNumIndex, unsigned int mpNum) */
Ptr CellStore::searchExact (unsigned int refNumIndex, unsigned int mpNum)
{ {
SearchExactVisitor<MWWorld::Ptr> searchVisitor; SearchExactVisitor<MWWorld::Ptr> searchVisitor;
searchVisitor.mIdToFind = id;
searchVisitor.mRefNumIndexToFind = refNumIndex; searchVisitor.mRefNumIndexToFind = refNumIndex;
searchVisitor.mMpNumToFind = mpNum; searchVisitor.mMpNumToFind = mpNum;
forEach(searchVisitor); forEach(searchVisitor);
return searchVisitor.mFound; 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() std::vector<LiveCellRefBase*> *CellStore::getMergedRefs()
{ {
return &mMergedRefs; 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() CellRefList<ESM::NPC> *CellStore::getNpcs()
{ {
return &mNpcs; 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() CellRefList<ESM::Creature> *CellStore::getCreatures()
{ {
return &mCreatures; 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() CellRefList<ESM::CreatureLevList> *CellStore::getCreatureLists()
{ {
return &mCreatureLists; 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() CellRefList<ESM::Container> *CellStore::getContainers()
{ {
return &mContainers; return &mContainers;
} }
/*
End of tes3mp addition
*/
float CellStore::getWaterLevel() const float CellStore::getWaterLevel() const
{ {

@ -231,23 +231,65 @@ namespace MWWorld
Ptr searchViaActorId (int id); Ptr searchViaActorId (int id);
///< Will return an empty Ptr if cell is not loaded. ///< 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(); 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(); 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(); 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(); 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(); CellRefList<ESM::Container> *getContainers();
// Added by tes3mp and used to get all the containers in the cell /*
End of tes3mp addition
*/
float getWaterLevel() const; float getWaterLevel() const;

Loading…
Cancel
Save