Author: alarantalara
Date: Sun Oct 23 17:40:01 2011
New Revision: 51591
URL: http://svn.gna.org/viewcvs/wesnoth?rev=51591&view=rev
Log:
fix bug 18701
Modified:
trunk/changelog
trunk/src/variable.cpp
Modified: trunk/changelog
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/changelog?rev=51591&r1=51590&r2=51591&view=diff
==============================================================================
--- trunk/changelog (original)
+++ trunk/changelog Sun Oct 23 17:40:01 2011
@@ -75,6 +75,7 @@
* Add --language/-L commandline option to set the language for that session
* The credits screen no longer mangles image path function in background
image lists
+ * Evaluate key length even if intervening WML children don't exist (bug
#18701)
Version 1.9.9:
* AI:
Modified: trunk/src/variable.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/variable.cpp?rev=51591&r1=51590&r2=51591&view=diff
==============================================================================
--- trunk/src/variable.cpp (original)
+++ trunk/src/variable.cpp Sun Oct 23 17:40:01 2011
@@ -588,6 +588,8 @@
key = varname;
std::string::const_iterator itor = std::find(key.begin(),key.end(),'.');
int dot_index = key.find('.');
+ // Return length if the last part of the key is length (include '.' to
avoid keys with the same suffix)
+ bool is_length = key.length() >= 7 && key.substr(key.length()-7) ==
".length";
// example varname = "unit_store.modifications.trait[0]"
while(itor != key.end()) { // subvar access
std::string element=key.substr(0,dot_index);
@@ -612,7 +614,7 @@
if(size <= inner_index) {
if(force_valid) {
// Add elements to the array until the
requested size is attained
- if(inner_explicit_index || key != "length") {
+ if(inner_explicit_index || !is_length) {
for(; size <= inner_index; ++size) {
vars->add_child(element);
}
@@ -621,13 +623,13 @@
WRN_NG << "variable_info: invalid WML array
index, "
<< varname << std::endl;
return;
- } else if(key != "length") {
+ } else if(!is_length) {
WRN_NG << "variable_info: retrieving member of
non-existent WML container, "
<< varname << std::endl;
return;
} //else return length 0 for non-existent WML array
(handled below)
}
- if(!inner_explicit_index && key == "length") {
+ if(!inner_explicit_index && is_length) {
switch(vartype) {
case variable_info::TYPE_ARRAY:
case variable_info::TYPE_CONTAINER:
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits