Author: sapient
Date: Wed Aug 22 02:36:49 2007
New Revision: 19714
URL: http://svn.gna.org/viewcvs/wesnoth?rev=19714&view=rev
Log:
return "0" instead of empty string for the length of non-existant WML arrays
Modified:
trunk/src/variable.cpp
Modified: trunk/src/variable.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/variable.cpp?rev=19714&r1=19713&r2=19714&view=diff
==============================================================================
--- trunk/src/variable.cpp (original)
+++ trunk/src/variable.cpp Wed Aug 22 02:36:49 2007
@@ -239,14 +239,23 @@
size_t size = vars->get_children(element).size();
if(size <= inner_index) {
if(!force_valid) {
- WRN_NG << "variable_info: invalid WML array
index, " << varname << std::endl;
- return;
- }
- for(; size <= inner_index; ++size) {
- vars->add_child(element);
- }
- }
-
+ if(inner_explicit_index) {
+ WRN_NG << "variable_info: invalid WML
array index, "
+ << varname << std::endl;
+ return;
+ }
+ if(key != "length") {
+ WRN_NG << "variable_info: retrieving
member of non-existant WML container, "
+ << varname << std::endl;
+ return;
+ }
+ } else {
+ //add elements to the array until the requested
size is attained
+ for(; size <= inner_index; ++size) {
+ vars->add_child(element);
+ }
+ }
+ }
if(!inner_explicit_index && key == "length") {
switch(vartype) {
case variable_info::TYPE_ARRAY:
@@ -256,6 +265,7 @@
is_valid = force_valid ||
repos->temporaries.child(varname) != NULL;
break;
default:
+ //store the length of the array as a temporary
variable
repos->temporaries[varname] =
lexical_cast<std::string>(size);
is_valid = true;
break;
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits