[Client] Move overrideRecord() method for Sound records to right spot

This commit is contained in:
David Cernat 2021-01-17 16:04:12 +02:00
parent 08e3e9af76
commit 0eb01591e8
2 changed files with 48 additions and 48 deletions

View File

@ -1282,6 +1282,53 @@ void RecordHelper::overrideRecord(const mwmp::ScriptRecord& record)
}
}
void RecordHelper::overrideRecord(const mwmp::SoundRecord& record)
{
const ESM::Sound& recordData = record.data;
if (recordData.mId.empty())
{
LOG_APPEND(TimedLog::LOG_INFO, "-- Ignoring record override with no id provided");
return;
}
bool isExistingId = doesRecordIdExist<ESM::Sound>(recordData.mId);
MWBase::World* world = MWBase::Environment::get().getWorld();
if (record.baseId.empty())
{
world->getModifiableStore().overrideRecord(recordData);
}
else if (doesRecordIdExist<ESM::Sound>(record.baseId))
{
const ESM::Sound* baseData = world->getStore().get<ESM::Sound>().search(record.baseId);
ESM::Sound finalData = *baseData;
finalData.mId = recordData.mId;
if (record.baseOverrides.hasSound)
finalData.mSound = recordData.mSound;
if (record.baseOverrides.hasVolume)
finalData.mData.mVolume = recordData.mData.mVolume;
if (record.baseOverrides.hasMinRange)
finalData.mData.mMinRange = recordData.mData.mMinRange;
if (record.baseOverrides.hasMaxRange)
finalData.mData.mMaxRange = recordData.mData.mMaxRange;
world->getModifiableStore().overrideRecord(finalData);
}
else
{
LOG_APPEND(TimedLog::LOG_INFO, "-- Ignoring record override with invalid baseId %s", record.baseId.c_str());
return;
}
if (isExistingId)
world->updatePtrsWithRefId(recordData.mId);
}
void RecordHelper::overrideRecord(const mwmp::SpellRecord& record)
{
const ESM::Spell &recordData = record.data;
@ -1470,53 +1517,6 @@ void RecordHelper::overrideRecord(const mwmp::WeaponRecord& record)
world->updatePtrsWithRefId(recordData.mId);
}
void RecordHelper::overrideRecord(const mwmp::SoundRecord& record)
{
const ESM::Sound& recordData = record.data;
if (recordData.mId.empty())
{
LOG_APPEND(TimedLog::LOG_INFO, "-- Ignoring record override with no id provided");
return;
}
bool isExistingId = doesRecordIdExist<ESM::Sound>(recordData.mId);
MWBase::World* world = MWBase::Environment::get().getWorld();
if (record.baseId.empty())
{
world->getModifiableStore().overrideRecord(recordData);
}
else if (doesRecordIdExist<ESM::Sound>(record.baseId))
{
const ESM::Sound* baseData = world->getStore().get<ESM::Sound>().search(record.baseId);
ESM::Sound finalData = *baseData;
finalData.mId = recordData.mId;
if (record.baseOverrides.hasSound)
finalData.mSound = recordData.mSound;
if (record.baseOverrides.hasVolume)
finalData.mData.mVolume = recordData.mData.mVolume;
if (record.baseOverrides.hasMinRange)
finalData.mData.mMinRange = recordData.mData.mMinRange;
if (record.baseOverrides.hasMaxRange)
finalData.mData.mMaxRange = recordData.mData.mMaxRange;
world->getModifiableStore().overrideRecord(finalData);
}
else
{
LOG_APPEND(TimedLog::LOG_INFO, "-- Ignoring record override with invalid baseId %s", record.baseId.c_str());
return;
}
if (isExistingId)
world->updatePtrsWithRefId(recordData.mId);
}
void RecordHelper::createPlaceholderInteriorCell()
{
MWBase::World* world = MWBase::Environment::get().getWorld();

View File

@ -27,10 +27,10 @@ namespace RecordHelper
void overrideRecord(const mwmp::ProbeRecord& record);
void overrideRecord(const mwmp::RepairRecord& record);
void overrideRecord(const mwmp::ScriptRecord& record);
void overrideRecord(const mwmp::SoundRecord& record);
void overrideRecord(const mwmp::SpellRecord& record);
void overrideRecord(const mwmp::StaticRecord& record);
void overrideRecord(const mwmp::WeaponRecord& record);
void overrideRecord(const mwmp::SoundRecord& record);
template<class RecordType>
void overrideRecord(const RecordType &record)