mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 19:19:56 +00:00
[Client] Check validity of refIds in ObjectSpawn packets
This reverts c7bcf70c32
because it provides a better solution to the problem solved there, while solving another related problem as well.
This commit is contained in:
parent
8d286657d4
commit
7995466e3c
1 changed files with 32 additions and 31 deletions
|
@ -6,6 +6,7 @@
|
|||
#include "DedicatedPlayer.hpp"
|
||||
#include "PlayerList.hpp"
|
||||
#include "CellController.hpp"
|
||||
#include "RecordHelper.hpp"
|
||||
|
||||
#include <components/openmw-mp/Log.hpp>
|
||||
|
||||
|
@ -375,7 +376,7 @@ void ObjectList::placeObjects(MWWorld::CellStore* cellStore)
|
|||
}
|
||||
catch (std::exception&)
|
||||
{
|
||||
LOG_APPEND(Log::LOG_INFO, "-- Ignored placement of invalid object");
|
||||
LOG_MESSAGE_SIMPLE(Log::LOG_ERROR, "Ignored placement of invalid object %s", baseObject.refId.c_str());
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -393,6 +394,11 @@ void ObjectList::spawnObjects(MWWorld::CellStore* cellStore)
|
|||
// Ignore generic dynamic refIds because they could be anything on other clients
|
||||
if (baseObject.refId.find("$dynamic") != string::npos)
|
||||
continue;
|
||||
else if (!RecordHelper::doesCreatureExist(baseObject.refId) && !RecordHelper::doesNpcExist(baseObject.refId))
|
||||
{
|
||||
LOG_MESSAGE_SIMPLE(Log::LOG_ERROR, "Ignored spawning of invalid object %s", baseObject.refId.c_str());
|
||||
continue;
|
||||
}
|
||||
|
||||
MWWorld::Ptr ptrFound = cellStore->searchExact(0, baseObject.mpNum);
|
||||
|
||||
|
@ -402,8 +408,6 @@ void ObjectList::spawnObjects(MWWorld::CellStore* cellStore)
|
|||
MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), baseObject.refId, 1);
|
||||
MWWorld::Ptr newPtr = ref.getPtr();
|
||||
|
||||
if (newPtr.getClass().isActor())
|
||||
{
|
||||
newPtr = MWBase::Environment::get().getWorld()->placeObject(newPtr, cellStore, baseObject.position);
|
||||
MWMechanics::CreatureStats& creatureStats = newPtr.getClass().getCreatureStats(newPtr);
|
||||
|
||||
|
@ -439,9 +443,6 @@ void ObjectList::spawnObjects(MWWorld::CellStore* cellStore)
|
|||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
LOG_APPEND(Log::LOG_VERBOSE, "-- Cannot spawn non-actor object!");
|
||||
}
|
||||
else
|
||||
LOG_APPEND(Log::LOG_VERBOSE, "-- Actor already existed!");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue