diff --git a/apps/opencs/model/tools/referencecheck.cpp b/apps/opencs/model/tools/referencecheck.cpp index d8e056a76..aae83bd5e 100644 --- a/apps/opencs/model/tools/referencecheck.cpp +++ b/apps/opencs/model/tools/referencecheck.cpp @@ -36,21 +36,14 @@ void CSMTools::ReferenceCheckStage::perform(int stage, CSMDoc::Messages &message } else { // Check if reference charge is valid for it's proper referenced type CSMWorld::RefIdData::LocalIndex localIndex = mDataSet.searchId(cellRef.mRefID); - if (localIndex.second == CSMWorld::UniversalId::Type_Armor || - localIndex.second == CSMWorld::UniversalId::Type_Weapon) { - if (cellRef.mChargeFloat < 0) { - std::string str = " has negative durability "; + bool isLight = localIndex.second == CSMWorld::UniversalId::Type_Light; + if ((isLight && cellRef.mChargeFloat < -1) || (!isLight && cellRef.mChargeInt < -1)) { + std::string str = " has invalid charge "; + if (localIndex.second == CSMWorld::UniversalId::Type_Light) str += boost::lexical_cast(cellRef.mChargeFloat); - messages.push_back(std::make_pair(id, id.getId() + str)); - } - } else if (localIndex.second == CSMWorld::UniversalId::Type_Lockpick || - localIndex.second == CSMWorld::UniversalId::Type_Probe || - localIndex.second == CSMWorld::UniversalId::Type_Repair) { - if (cellRef.mChargeInt < -1) { - std::string str = " has invalid charges "; + else str += boost::lexical_cast(cellRef.mChargeInt); - messages.push_back(std::make_pair(id, id.getId() + str)); - } + messages.push_back(std::make_pair(id, id.getId() + str)); } } } diff --git a/components/esm/cellref.hpp b/components/esm/cellref.hpp index 56932aa4d..01b6a8473 100644 --- a/components/esm/cellref.hpp +++ b/components/esm/cellref.hpp @@ -59,10 +59,12 @@ namespace ESM // For weapon or armor, this is the remaining item health. // For tools (lockpicks, probes, repair hammer) it is the remaining uses. + // For lights it is remaining time. + // This could be -1 if the charge was not touched yet (i.e. full). union { - int mChargeInt; - float mChargeFloat; + int mChargeInt; // Used by everything except lights + float mChargeFloat; // Used only by lights }; // Remaining enchantment charge. This could be -1 if the charge was not touched yet (i.e. full).