return 0 for length of arrays inside nonexistent containers (bug #13734)

This commit is contained in:
Patrick Parker 2009-07-21 05:34:46 +00:00
parent 23bd84f78a
commit 808d642bf8
2 changed files with 10 additions and 1 deletions

View File

@ -3,6 +3,8 @@ Version 1.7.2+svn:
* New unit graphics and animations for the Troll Hero.
* Language and i18n:
* Updated translations: Dutch, French
* WML Engine:
* return 0 for length of arrays inside nonexistent containers (bug #13734)
* Miscellaneous and bugfixes:
* 'Recruit' and 'recall' don't appear in context menus unless the
leader is on a keep. (bug #13856 and #13855)

View File

@ -532,7 +532,14 @@ t_string& game_state::get_variable(const std::string& key)
const t_string& game_state::get_variable_const(const std::string& key) const
{
variable_info to_get(key, false, variable_info::TYPE_SCALAR);
if(!to_get.is_valid) return temporaries[key];
if(!to_get.is_valid) {
t_string& to_return = temporaries[key];
if(key.size() > 7 and key.substr(key.size()-7)==".length") {
// length is a special attribute, so guarantee its correctness
to_return = "0";
}
return to_return;
}
return to_get.as_scalar();
}