diff --git a/apps/openmw/mwmp/WorldEvent.cpp b/apps/openmw/mwmp/WorldEvent.cpp index 5ad38bf87..6f2a84031 100644 --- a/apps/openmw/mwmp/WorldEvent.cpp +++ b/apps/openmw/mwmp/WorldEvent.cpp @@ -174,26 +174,35 @@ void WorldEvent::placeObjects(MWWorld::CellStore* cellStore) // Only create this object if it doesn't already exist if (!ptrFound) { - MWWorld::ManualRef ref(world->getStore(), worldObject.refId, 1); - MWWorld::Ptr newPtr = ref.getPtr(); + try + { + MWWorld::ManualRef ref(world->getStore(), worldObject.refId, 1); - if (worldObject.count > 1) - newPtr.getRefData().setCount(worldObject.count); + MWWorld::Ptr newPtr = ref.getPtr(); - if (worldObject.charge > -1) - newPtr.getCellRef().setCharge(worldObject.charge); + if (worldObject.count > 1) + newPtr.getRefData().setCount(worldObject.count); - if (worldObject.enchantmentCharge > -1) - newPtr.getCellRef().setEnchantmentCharge(worldObject.enchantmentCharge); + if (worldObject.charge > -1) + newPtr.getCellRef().setCharge(worldObject.charge); - newPtr.getCellRef().setGoldValue(worldObject.goldValue); - newPtr = world->placeObject(newPtr, cellStore, worldObject.position); + if (worldObject.enchantmentCharge > -1) + 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().setMpNum(worldObject.mpNum); + newPtr.getCellRef().setGoldValue(worldObject.goldValue); + 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) - world->PCDropped(newPtr); + 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 LOG_APPEND(Log::LOG_VERBOSE, "-- Object already existed!");