From aed4ca2fd21065c949967304247c6cf580ec0309 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Mon, 20 Aug 2018 15:24:20 +0300 Subject: [PATCH] [Client] Allow use of baseId for more record types Additionally, don't allow new enchantment records to be created if they have no effects, to avoid a crash. --- apps/openmw/mwmp/RecordHelper.cpp | 8 +++++++- apps/openmw/mwmp/Worldstate.cpp | 6 +++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/apps/openmw/mwmp/RecordHelper.cpp b/apps/openmw/mwmp/RecordHelper.cpp index 0dd538818..86cc6417d 100644 --- a/apps/openmw/mwmp/RecordHelper.cpp +++ b/apps/openmw/mwmp/RecordHelper.cpp @@ -292,7 +292,13 @@ void RecordHelper::overrideEnchantmentRecord(const mwmp::EnchantmentRecord& reco if (record.baseId.empty()) { - world->getModifiableStore().overrideRecord(recordData); + if (recordData.mEffects.mList.empty()) + { + LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Ignoring new enchantment record with no effects"); + return; + } + else + world->getModifiableStore().overrideRecord(recordData); } else if (doesEnchantmentRecordExist(record.baseId)) { diff --git a/apps/openmw/mwmp/Worldstate.cpp b/apps/openmw/mwmp/Worldstate.cpp index 44aa60990..63bde9349 100644 --- a/apps/openmw/mwmp/Worldstate.cpp +++ b/apps/openmw/mwmp/Worldstate.cpp @@ -47,7 +47,7 @@ void Worldstate::addRecords() LOG_APPEND(Log::LOG_ERROR, "- spell record %s, %s\n-- baseId is %s", record.data.mId.c_str(), record.data.mName.c_str(), hasBaseId ? record.baseId.c_str() : "empty"); - RecordHelper::overrideSpellRecord(record.data); + RecordHelper::overrideSpellRecord(record); } } else if (recordsType == mwmp::RECORD_TYPE::POTION) @@ -59,7 +59,7 @@ void Worldstate::addRecords() LOG_APPEND(Log::LOG_ERROR, "- potion record %s, %s\n-- baseId is %s", record.data.mId.c_str(), record.data.mName.c_str(), hasBaseId ? record.baseId.c_str() : "empty"); - RecordHelper::overridePotionRecord(record.data); + RecordHelper::overridePotionRecord(record); } } else if (recordsType == mwmp::RECORD_TYPE::ENCHANTMENT) @@ -71,7 +71,7 @@ void Worldstate::addRecords() LOG_APPEND(Log::LOG_ERROR, "- enchantment record %s, %i\n-- baseId is %s", record.data.mId.c_str(), record.data.mData.mType, hasBaseId ? record.baseId.c_str() : "empty"); - RecordHelper::overrideEnchantmentRecord(record.data); + RecordHelper::overrideEnchantmentRecord(record); } } else if (recordsType == mwmp::RECORD_TYPE::CREATURE)