[Avida-SVN] r3002 - development/source/main

brysonda at myxo.css.msu.edu brysonda at myxo.css.msu.edu
Fri Dec 5 17:20:20 PST 2008


Author: brysonda
Date: 2008-12-05 20:20:20 -0500 (Fri, 05 Dec 2008)
New Revision: 3002

Modified:
   development/source/main/cEnvironment.cc
Log:
Fix state grid loading.  Organism initialization with state grids still needs to be fixed though.

Modified: development/source/main/cEnvironment.cc
===================================================================
--- development/source/main/cEnvironment.cc	2008-12-05 22:20:08 UTC (rev 3001)
+++ development/source/main/cEnvironment.cc	2008-12-06 01:20:20 UTC (rev 3002)
@@ -819,17 +819,21 @@
   while (gridstr.GetSize() && cell < lgrid.GetSize()) {
     statename = gridstr.Pop(',');
     statename.Trim();
+    bool found = false;
     for (int i = 0; i < states.GetSize(); i++) {
       if (statename == states[i]) {
         lgrid[cell++] = i;
+        found = true;
         break;
       }
     }
-    cerr << "error: state identifier undefined for cell (" << (cell / width) << ", "
-         << (cell % width) << ") in state grid " << name << endl;
-    return false;
+    if (!found) {
+      cerr << "error: state identifier undefined for cell (" << (cell / width) << ", "
+           << (cell % width) << ") in state grid " << name << endl;
+      return false;
+    }
   }
-  if (cell != (lgrid.GetSize() - 1) || gridstr.GetSize() > 0) {
+  if (cell != lgrid.GetSize() || gridstr.GetSize() > 0) {
     cerr << "error: grid definition size mismatch for state grid " << name << endl;
     return false;
   }




More information about the Avida-cvs mailing list