[avida-cvs] avida CVS commits: /current/source/event cPopulation.events /current/source/main resource.cc

mercere99 avida-cvs at alife.org
Tue Oct 21 18:05:40 PDT 2003


mercere99		Tue Oct 21 10:05:40 2003 EDT

  Modified files:              
    /avida/current/source/event	cPopulation.events 
    /avida/current/source/main	resource.cc 
  Log:
  Added in some warning code for when people encounter problems with the
  set_resource event (the event does seem to be working though....)
  
  
  
Index: avida/current/source/event/cPopulation.events
diff -u avida/current/source/event/cPopulation.events:1.45 avida/current/source/event/cPopulation.events:1.46
--- avida/current/source/event/cPopulation.events:1.45	Sun Oct 12 13:07:50 2003
+++ avida/current/source/event/cPopulation.events	Tue Oct 21 10:05:39 2003
@@ -1709,5 +1709,7 @@
 double res_count
 :body:
 cResourceLib & res_lib = population->GetEnvironment().GetResourceLib();
-int res_id = res_lib.GetResource(res_name)->GetID();
-population->SetResource(res_id, res_count);
+cResource * found_resource = res_lib.GetResource(res_name);
+if (found_resource != NULL) {
+  population->SetResource(found_resource->GetID(), res_count);
+}
Index: avida/current/source/main/resource.cc
diff -u avida/current/source/main/resource.cc:1.5 avida/current/source/main/resource.cc:1.6
--- avida/current/source/main/resource.cc:1.5	Sat May 17 02:48:10 2003
+++ avida/current/source/main/resource.cc	Tue Oct 21 10:05:39 2003
@@ -71,6 +71,7 @@
   for (int i = 0; i < resource_array.GetSize(); i++) {
     if (resource_array[i]->GetName() == res_name) return resource_array[i];
   }
+  cerr << "Error: Unknown resource '" << res_name << "'." << endl;
   return NULL;
 }
 






More information about the Avida-cvs mailing list