[Client] Ignore invalid object refIds from ObjectPlace packets

0.6.3
David Cernat 7 years ago
parent 4496625154
commit ce5670e57e

@ -174,26 +174,35 @@ void WorldEvent::placeObjects(MWWorld::CellStore* cellStore)
// Only create this object if it doesn't already exist // Only create this object if it doesn't already exist
if (!ptrFound) if (!ptrFound)
{ {
MWWorld::ManualRef ref(world->getStore(), worldObject.refId, 1); try
MWWorld::Ptr newPtr = ref.getPtr(); {
MWWorld::ManualRef ref(world->getStore(), worldObject.refId, 1);
if (worldObject.count > 1) MWWorld::Ptr newPtr = ref.getPtr();
newPtr.getRefData().setCount(worldObject.count);
if (worldObject.charge > -1) if (worldObject.count > 1)
newPtr.getCellRef().setCharge(worldObject.charge); newPtr.getRefData().setCount(worldObject.count);
if (worldObject.enchantmentCharge > -1) if (worldObject.charge > -1)
newPtr.getCellRef().setEnchantmentCharge(worldObject.enchantmentCharge); newPtr.getCellRef().setCharge(worldObject.charge);
newPtr.getCellRef().setGoldValue(worldObject.goldValue); if (worldObject.enchantmentCharge > -1)
newPtr = world->placeObject(newPtr, cellStore, worldObject.position); newPtr.getCellRef().setEnchantmentCharge(worldObject.enchantmentCharge);
// Because gold automatically gets replaced with a new object, make sure we set the mpNum at the end newPtr.getCellRef().setGoldValue(worldObject.goldValue);
newPtr.getCellRef().setMpNum(worldObject.mpNum); newPtr = world->placeObject(newPtr, cellStore, worldObject.position);
// Because gold automatically gets replaced with a new object, make sure we set the mpNum at the end
newPtr.getCellRef().setMpNum(worldObject.mpNum);
if (guid == Main::get().getLocalPlayer()->guid && worldObject.droppedByPlayer) if (guid == Main::get().getLocalPlayer()->guid && worldObject.droppedByPlayer)
world->PCDropped(newPtr); world->PCDropped(newPtr);
}
catch (std::exception&)
{
LOG_APPEND(Log::LOG_INFO, "-- Ignored placement of invalid object");
}
} }
else else
LOG_APPEND(Log::LOG_VERBOSE, "-- Object already existed!"); LOG_APPEND(Log::LOG_VERBOSE, "-- Object already existed!");

Loading…
Cancel
Save