mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-20 19:39:41 +00:00
Update cell reference record verifier messages
This commit is contained in:
parent
dc847dce09
commit
5b8880c6fa
2 changed files with 21 additions and 23 deletions
|
@ -9,7 +9,7 @@ CSMTools::ReferenceCheckStage::ReferenceCheckStage(
|
|||
const CSMWorld::IdCollection<ESM::Faction>& factions)
|
||||
:
|
||||
mReferences(references),
|
||||
mReferencables(referencables),
|
||||
mObjects(referencables),
|
||||
mDataSet(referencables.getDataSet()),
|
||||
mCells(cells),
|
||||
mFactions(factions)
|
||||
|
@ -30,75 +30,73 @@ void CSMTools::ReferenceCheckStage::perform(int stage, CSMDoc::Messages &message
|
|||
|
||||
// Check for empty reference id
|
||||
if (cellRef.mRefID.empty()) {
|
||||
messages.push_back(std::make_pair(id, " is an empty instance (not based on an object)"));
|
||||
messages.push_back(std::make_pair(id, "Instance is not based on an object"));
|
||||
} else {
|
||||
// Check for non existing referenced object
|
||||
if (mReferencables.searchId(cellRef.mRefID) == -1) {
|
||||
messages.push_back(std::make_pair(id, " is referencing non existing object " + cellRef.mRefID));
|
||||
if (mObjects.searchId(cellRef.mRefID) == -1) {
|
||||
messages.push_back(std::make_pair(id, "Instance of a non-existent object '" + cellRef.mRefID + "'"));
|
||||
} else {
|
||||
// Check if reference charge is valid for it's proper referenced type
|
||||
CSMWorld::RefIdData::LocalIndex localIndex = mDataSet.searchId(cellRef.mRefID);
|
||||
bool isLight = localIndex.second == CSMWorld::UniversalId::Type_Light;
|
||||
if ((isLight && cellRef.mChargeFloat < -1) || (!isLight && cellRef.mChargeInt < -1)) {
|
||||
std::string str = " has invalid charge ";
|
||||
std::string str = "Invalid charge: ";
|
||||
if (localIndex.second == CSMWorld::UniversalId::Type_Light)
|
||||
str += std::to_string(cellRef.mChargeFloat);
|
||||
else
|
||||
str += std::to_string(cellRef.mChargeInt);
|
||||
messages.push_back(std::make_pair(id, id.getId() + str));
|
||||
messages.push_back(std::make_pair(id, str));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If object have owner, check if that owner reference is valid
|
||||
if (!cellRef.mOwner.empty() && mReferencables.searchId(cellRef.mOwner) == -1)
|
||||
messages.push_back(std::make_pair(id, " has non existing owner " + cellRef.mOwner));
|
||||
if (!cellRef.mOwner.empty() && mObjects.searchId(cellRef.mOwner) == -1)
|
||||
messages.push_back(std::make_pair(id, "Owner object '" + cellRef.mOwner + "' does not exist"));
|
||||
|
||||
// If object have creature soul trapped, check if that creature reference is valid
|
||||
if (!cellRef.mSoul.empty())
|
||||
if (mReferencables.searchId(cellRef.mSoul) == -1)
|
||||
messages.push_back(std::make_pair(id, " has non existing trapped soul " + cellRef.mSoul));
|
||||
if (mObjects.searchId(cellRef.mSoul) == -1)
|
||||
messages.push_back(std::make_pair(id, "Trapped soul object '" + cellRef.mSoul + "' does not exist"));
|
||||
|
||||
bool hasFaction = !cellRef.mFaction.empty();
|
||||
|
||||
// If object have faction, check if that faction reference is valid
|
||||
if (hasFaction)
|
||||
if (mFactions.searchId(cellRef.mFaction) == -1)
|
||||
messages.push_back(std::make_pair(id, " has non existing faction " + cellRef.mFaction));
|
||||
messages.push_back(std::make_pair(id, "Faction '" + cellRef.mFaction + "' does not exist"));
|
||||
|
||||
// Check item's faction rank
|
||||
if (hasFaction && cellRef.mFactionRank < -1)
|
||||
messages.push_back(std::make_pair(id, " has faction set but has invalid faction rank " + std::to_string(cellRef.mFactionRank)));
|
||||
else if (!hasFaction && cellRef.mFactionRank != -2)
|
||||
messages.push_back(std::make_pair(id, " has invalid faction rank " + std::to_string(cellRef.mFactionRank)));
|
||||
if ((hasFaction && cellRef.mFactionRank < -1) || (!hasFaction && cellRef.mFactionRank != -2))
|
||||
messages.push_back(std::make_pair(id, "Invalid faction rank " + std::to_string(cellRef.mFactionRank)));
|
||||
|
||||
// If door have destination cell, check if that reference is valid
|
||||
if (!cellRef.mDestCell.empty())
|
||||
if (mCells.searchId(cellRef.mDestCell) == -1)
|
||||
messages.push_back(std::make_pair(id, " has non existing destination cell " + cellRef.mDestCell));
|
||||
messages.push_back(std::make_pair(id, "Destination cell '" + cellRef.mDestCell + "' does not exist"));
|
||||
|
||||
// Check if scale isn't negative
|
||||
if (cellRef.mScale < 0)
|
||||
{
|
||||
std::string str = " has negative scale ";
|
||||
std::string str = "Negative scale: ";
|
||||
str += std::to_string(cellRef.mScale);
|
||||
messages.push_back(std::make_pair(id, id.getId() + str));
|
||||
messages.push_back(std::make_pair(id, str));
|
||||
}
|
||||
|
||||
// Check if enchantement points aren't negative or are at full (-1)
|
||||
if (cellRef.mEnchantmentCharge < 0 && cellRef.mEnchantmentCharge != -1)
|
||||
{
|
||||
std::string str = " has negative enchantment points ";
|
||||
std::string str = "Negative enchantment points: ";
|
||||
str += std::to_string(cellRef.mEnchantmentCharge);
|
||||
messages.push_back(std::make_pair(id, id.getId() + str));
|
||||
messages.push_back(std::make_pair(id, str));
|
||||
}
|
||||
|
||||
// Check if gold value isn't negative
|
||||
if (cellRef.mGoldValue < 0)
|
||||
{
|
||||
std::string str = " has negative gold value ";
|
||||
std::string str = "Negative gold value: ";
|
||||
str += cellRef.mGoldValue;
|
||||
messages.push_back(std::make_pair(id, id.getId() + str));
|
||||
messages.push_back(std::make_pair(id, str));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace CSMTools
|
|||
|
||||
private:
|
||||
const CSMWorld::RefCollection& mReferences;
|
||||
const CSMWorld::RefIdCollection& mReferencables;
|
||||
const CSMWorld::RefIdCollection& mObjects;
|
||||
const CSMWorld::RefIdData& mDataSet;
|
||||
const CSMWorld::IdCollection<CSMWorld::Cell>& mCells;
|
||||
const CSMWorld::IdCollection<ESM::Faction>& mFactions;
|
||||
|
|
Loading…
Reference in a new issue