diff --git a/apps/openmw/mwmp/Cell.cpp b/apps/openmw/mwmp/Cell.cpp index f8c93f5a8..f0eee0816 100644 --- a/apps/openmw/mwmp/Cell.cpp +++ b/apps/openmw/mwmp/Cell.cpp @@ -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; diff --git a/apps/openmw/mwmp/LocalPlayer.cpp b/apps/openmw/mwmp/LocalPlayer.cpp index 8aa54f331..40b05991c 100644 --- a/apps/openmw/mwmp/LocalPlayer.cpp +++ b/apps/openmw/mwmp/LocalPlayer.cpp @@ -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) { diff --git a/apps/openmw/mwmp/MechanicsHelper.cpp b/apps/openmw/mwmp/MechanicsHelper.cpp index 3269d7b3d..d9b53b843 100644 --- a/apps/openmw/mwmp/MechanicsHelper.cpp +++ b/apps/openmw/mwmp/MechanicsHelper.cpp @@ -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(); } } diff --git a/apps/openmw/mwmp/WorldEvent.cpp b/apps/openmw/mwmp/WorldEvent.cpp index befdff335..b9379fb47 100644 --- a/apps/openmw/mwmp/WorldEvent.cpp +++ b/apps/openmw/mwmp/WorldEvent.cpp @@ -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) { diff --git a/apps/openmw/mwworld/cellstore.cpp b/apps/openmw/mwworld/cellstore.cpp index ba33f8f68..0fc5a04e5 100644 --- a/apps/openmw/mwworld/cellstore.cpp +++ b/apps/openmw/mwworld/cellstore.cpp @@ -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 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 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 *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 *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 *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 *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 *CellStore::getContainers() { return &mContainers; } + /* + End of tes3mp addition + */ float CellStore::getWaterLevel() const { diff --git a/apps/openmw/mwworld/cellstore.hpp b/apps/openmw/mwworld/cellstore.hpp index ef1e0fa3d..11a34bff3 100644 --- a/apps/openmw/mwworld/cellstore.hpp +++ b/apps/openmw/mwworld/cellstore.hpp @@ -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 *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 *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 *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 *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 *getContainers(); - // Added by tes3mp and used to get all the containers in the cell + /* + End of tes3mp addition + */ float getWaterLevel() const;