(svn r13620) [NoAI] -Fix: foreach() on empty lists gave weird error (bug by Yexo)
--- a/bin/ai/regression/regression.nut Mon Jun 23 16:23:36 2008 +0000
+++ b/bin/ai/regression/regression.nut Tue Jun 24 11:37:33 2008 +0000
@@ -164,6 +164,11 @@
for (local i = list.Begin(); list.HasNext(); i = list.Next()) {
print(" " + i);
}
+
+ list.Clear();
+ foreach (idx, val in list) {
+ print(" " + idx);
+ }
}
function Regression::Std()
--- a/src/ai/api/ai_abstractlist.cpp Mon Jun 23 16:23:36 2008 +0000
+++ b/src/ai/api/ai_abstractlist.cpp Tue Jun 24 11:37:33 2008 +0000
@@ -718,6 +718,10 @@
SQInteger AIAbstractList::_nexti(HSQUIRRELVM vm) {
if (sq_gettype(vm, 2) == OT_NULL) {
+ if (this->IsEmpty()) {
+ sq_pushnull(vm);
+ return 1;
+ }
sq_pushinteger(vm, this->Begin());
return 1;
}