mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-07-01 08:41:52 +00:00
feat: log invalid enum values for infostring loaders
This commit is contained in:
@ -2,6 +2,7 @@
|
||||
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
InfoStringToStructConverterBase::InfoStringToStructConverterBase(const InfoString& infoString,
|
||||
void* structure,
|
||||
@ -148,7 +149,8 @@ bool InfoStringToStructConverterBase::ConvertScriptString(const std::string& val
|
||||
return true;
|
||||
}
|
||||
|
||||
bool InfoStringToStructConverterBase::ConvertEnumInt(const std::string& value, const size_t offset, const char** enumValues, const size_t enumSize)
|
||||
bool InfoStringToStructConverterBase::ConvertEnumInt(
|
||||
const std::string& fieldName, const std::string& value, const size_t offset, const char** enumValues, const size_t enumSize)
|
||||
{
|
||||
for (auto i = 0u; i < enumSize; i++)
|
||||
{
|
||||
@ -159,6 +161,19 @@ bool InfoStringToStructConverterBase::ConvertEnumInt(const std::string& value, c
|
||||
}
|
||||
}
|
||||
|
||||
std::ostringstream ss;
|
||||
ss << "Not a valid value for field \"" << fieldName << "\": \"" << value << "\". Valid values are:\n ";
|
||||
|
||||
for (auto i = 0u; i < enumSize; i++)
|
||||
{
|
||||
if (i > 0)
|
||||
ss << ", ";
|
||||
ss << '"' << enumValues[i] << '"';
|
||||
}
|
||||
|
||||
ss << '\n';
|
||||
std::cerr << ss.str();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -110,7 +110,7 @@ protected:
|
||||
bool ConvertFloat(const std::string& value, size_t offset);
|
||||
bool ConvertMilliseconds(const std::string& value, size_t offset);
|
||||
bool ConvertScriptString(const std::string& value, size_t offset);
|
||||
bool ConvertEnumInt(const std::string& value, size_t offset, const char** enumValues, size_t enumSize);
|
||||
bool ConvertEnumInt(const std::string& fieldName, const std::string& value, size_t offset, const char** enumValues, size_t enumSize);
|
||||
|
||||
public:
|
||||
InfoStringToStructConverterBase(const InfoString& infoString, void* structure, ZoneScriptStrings& zoneScriptStrings, MemoryManager* memory);
|
||||
|
Reference in New Issue
Block a user