Skip to content

Commit

Permalink
Variable: remove asserts on resources::gamedata absence
Browse files Browse the repository at this point in the history
In the case of as_nonempty_range, the function was rewritten to remove absolute reliance on gamedata.
In the other case, we simply silently return now.
  • Loading branch information
Vultraz committed Apr 8, 2017
1 parent 7364d72 commit 4bc0ac0
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/variable.cpp
Expand Up @@ -42,17 +42,17 @@ namespace
const config as_nonempty_range_default = config_of("_", config());
config::const_child_itors as_nonempty_range(const std::string& varname)
{
assert(resources::gamedata);
config::const_child_itors range = resources::gamedata->get_variable_access_read(varname).as_array();
config::const_child_itors range = as_nonempty_range_default.child_range("_");

if(range.empty())
{
return as_nonempty_range_default.child_range("_");
}
else
{
return range;
if(resources::gamedata) {
config::const_child_itors temp_range = resources::gamedata->get_variable_access_read(varname).as_array();

if(!temp_range.empty()) {
range = temp_range;
}
}

return range;
}
}

Expand Down Expand Up @@ -474,7 +474,9 @@ config &scoped_wml_variable::store(const config &var_value)

scoped_wml_variable::~scoped_wml_variable()
{
assert(resources::gamedata);
if(!resources::gamedata) {
return;
}

if(activated_) {
resources::gamedata->clear_variable_cfg(var_name_);
Expand Down

0 comments on commit 4bc0ac0

Please sign in to comment.