// Write out Objectives to entity keyvals void ObjectiveEntity::writeToEntity() { UndoableCommand cmd("saveObjectives"); // Try to convert the weak_ptr reference to a shared_ptr Entity* entity = Node_getEntity(_entityNode.lock()); assert(entity != NULL); // greebo: Remove all objective-related spawnargs first clearEntity(entity); for (ObjectiveMap::const_iterator i = _objectives.begin(); i != _objectives.end(); ++i) { // Obtain the Objective and construct the key prefix from the index const Objective& o = i->second; std::string prefix = "obj" + string::to_string(i->first) + "_"; // Set the entity keyvalues entity->setKeyValue(prefix + "desc", o.description); entity->setKeyValue(prefix + "ongoing", o.ongoing ? "1" : "0"); entity->setKeyValue(prefix + "visible", o.visible ? "1" : "0"); entity->setKeyValue(prefix + "mandatory", o.mandatory ? "1" : "0"); entity->setKeyValue(prefix + "irreversible", o.irreversible ? "1" : "0"); entity->setKeyValue(prefix + "state", string::to_string(o.state)); // Write an empty "objN_difficulty" value when this objective applies to all levels entity->setKeyValue(prefix + "difficulty", o.difficultyLevels); entity->setKeyValue(prefix + "enabling_objs", o.enablingObjs); entity->setKeyValue(prefix + "script_complete", o.completionScript); entity->setKeyValue(prefix + "script_failed", o.failureScript); entity->setKeyValue(prefix + "target_complete", o.completionTarget); entity->setKeyValue(prefix + "target_failed", o.failureTarget); entity->setKeyValue(prefix + "logic_success", o.logic.successLogic); entity->setKeyValue(prefix + "logic_failure", o.logic.failureLogic); // Write the Components for this Objective writeComponents(entity, prefix, o); } // Export the mission success/failure logic writeMissionLogic(*entity); // Export objective conditions writeObjectiveConditions(*entity); }
/** MAIN */ int main(int argc, char** argv) { int opt,threads; extern char* optarg; extern int optind; timer io_start, b_start, b_end; // Who we are fprintf(stderr, "StarBench - RGBYUV Kernel\n"); // Parse command line options while ( (opt=getopt(argc,argv,"i:c:ht:")) != EOF) { switch (opt) { case 'i': infile = optarg; break; case 'c': iterations = atoi(optarg); break; case 'h': fprintf(stderr, usage, argv[0]); return 0; break; /**************************************SET THREADS NUMBER**************************************************/ case 't': threads = atoi(optarg); break; default: fprintf(stderr, usage, argv[0]); return 0; break; } } if (infile == NULL || iterations < 0) { fprintf(stderr, "Illegal argument given, exiting\n"); return -1; } #ifdef VERBOSE statsme(); #endif rgbyuv_args_t args; TIME(io_start); if(initialize(&args)) { fprintf(stderr, "Could Not Initialize Kernel Data\n"); return -1; } TIME(b_start); /**************************************SET THREADS NUMBER**************************************************/ omp_set_num_threads(threads); processImage(&args); TIME(b_end); writeComponents(&args); if(finalize(&args)) { fprintf(stderr, "Could Not Free Allocated Memory\n"); return -1; } double io_time = (double)timediff(&io_start, &b_start)/1000; double b_time = (double)timediff(&b_start, &b_end)/1000; printf("\nI/O time: %.3f\nTime: %.3f\n", io_time, b_time); return 0; }