Fix the missing comparison attribute warning in [variable] and add an additional warning for missing name

This commit is contained in:
Celtic Minstrel 2021-04-15 23:22:49 -04:00
parent ad1c42ca8f
commit 3627cb5766

View file

@ -93,11 +93,17 @@ namespace builtin_conditions {
bool variable_matches(const vconfig& values)
{
if(values["name"].blank()) {
lg::wml_error() << "[variable] with missing name=\n";
return true;
}
const std::string name = values["name"];
config::attribute_value value = resources::gamedata->get_variable_const(name);
if(values.get_config().attribute_count() != 2) {
if(auto n = values.get_config().attribute_count(); n > 2) {
lg::wml_error() << "[variable] name='" << name << "' found with multiple comparison attributes\n";
} else if(n < 2) {
lg::wml_error() << "[variable] name='" << name << "' found with no comparison attribute\n";
}
#define TEST_STR_ATTR(name, test) \
@ -143,7 +149,6 @@ namespace builtin_conditions {
#undef TEST_NUM_ATTR
#undef TEST_BOL_ATTR
lg::wml_error() << "[variable] name='" << name << "' found with no comparison attribute\n";
return true;
}
}