[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.
remotes/1728160796594174844/tmp_0.7.0-alpha
David Cernat 6 years ago
parent a083439139
commit aed4ca2fd2

@ -292,7 +292,13 @@ void RecordHelper::overrideEnchantmentRecord(const mwmp::EnchantmentRecord& reco
if (record.baseId.empty()) 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)) else if (doesEnchantmentRecordExist(record.baseId))
{ {

@ -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(), 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"); hasBaseId ? record.baseId.c_str() : "empty");
RecordHelper::overrideSpellRecord(record.data); RecordHelper::overrideSpellRecord(record);
} }
} }
else if (recordsType == mwmp::RECORD_TYPE::POTION) 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(), 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"); hasBaseId ? record.baseId.c_str() : "empty");
RecordHelper::overridePotionRecord(record.data); RecordHelper::overridePotionRecord(record);
} }
} }
else if (recordsType == mwmp::RECORD_TYPE::ENCHANTMENT) 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, 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"); hasBaseId ? record.baseId.c_str() : "empty");
RecordHelper::overrideEnchantmentRecord(record.data); RecordHelper::overrideEnchantmentRecord(record);
} }
} }
else if (recordsType == mwmp::RECORD_TYPE::CREATURE) else if (recordsType == mwmp::RECORD_TYPE::CREATURE)

Loading…
Cancel
Save