forked from teamnwah/openmw-tes3coop
[Client] Ignore invalid object refIds from ObjectPlace packets
This commit is contained in:
parent
4496625154
commit
ce5670e57e
1 changed files with 23 additions and 14 deletions
|
@ -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);
|
||||||
|
|
||||||
if (guid == Main::get().getLocalPlayer()->guid && worldObject.droppedByPlayer)
|
// Because gold automatically gets replaced with a new object, make sure we set the mpNum at the end
|
||||||
world->PCDropped(newPtr);
|
newPtr.getCellRef().setMpNum(worldObject.mpNum);
|
||||||
|
|
||||||
|
if (guid == Main::get().getLocalPlayer()->guid && worldObject.droppedByPlayer)
|
||||||
|
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…
Reference in a new issue