From a28fc65e6d21578e31d25f3fa08133977cb5388d Mon Sep 17 00:00:00 2001 From: expwnent Date: Thu, 13 Dec 2012 11:13:56 -0500 Subject: [PATCH] autoSyndrome now deals with creature_class. --- plugins/autoSyndrome.cpp | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/plugins/autoSyndrome.cpp b/plugins/autoSyndrome.cpp index 77217c6a0..a37d806fe 100644 --- a/plugins/autoSyndrome.cpp +++ b/plugins/autoSyndrome.cpp @@ -118,7 +118,7 @@ DFhackCExport command_result plugin_init(color_ostream& out, vectorunits.all[workerIndex]; df::creature_raw* creature = df::global::world->raws.creatures.all[unit->race]; + df::caste_raw* caste = creature->caste[unit->caste]; std::string& creature_name = creature->creature_id; - std::string& creature_caste = creature->caste[unit->caste]->caste_id; + std::string& creature_caste = caste->caste_id; //find all of the products it makes. Look for a stone with a low boiling point. bool foundIt = false; @@ -298,10 +299,40 @@ int32_t processJob(color_ostream& out, int32_t jobId) { //add each syndrome to the guy who did the job df::syndrome* syndrome = inorganic->material.syndrome[b]; //check that the syndrome applies to that guy - bool applies = syndrome->syn_affected_creature_1.size() == 0; + bool applies = syndrome->syn_affected_class.size() == 0; if ( applies ) { + //out.print("No syn_affected_class.\n"); + } + for ( size_t c = 0; c < syndrome->syn_affected_class.size(); c++ ) { + if ( applies ) + break; + for ( size_t d = 0; d < caste->creature_class.size(); d++ ) { + if ( *syndrome->syn_affected_class[c] == *caste->creature_class[d] ) { + applies = true; + break; + } + } + } + if ( syndrome->syn_affected_creature_1.size() != 0 ) { + applies = false; + } else { //out.print("No syn_affected_creature.\n"); } + for ( size_t c = 0; c < syndrome->syn_immune_class.size(); c++ ) { + if ( !applies ) + break; + for ( size_t d = 0; d < caste->creature_class.size(); d++ ) { + if ( *syndrome->syn_immune_class[c] == *caste->creature_class[d] ) { + applies = false; + break; + } + } + } + + if ( syndrome->syn_affected_creature_1.size() != syndrome->syn_affected_creature_2.size() ) { + out.print("%s, line %d: different affected creature/caste sizes.\n", __FILE__, __LINE__); + return -1; + } for ( size_t c = 0; c < syndrome->syn_affected_creature_1.size(); c++ ) { if ( creature_name != *syndrome->syn_affected_creature_1[c] ) continue;