From bc5cdf88777e6655857317b60ee2ff655dafb298 Mon Sep 17 00:00:00 2001 From: expwnent Date: Sat, 5 Jan 2013 11:37:12 -0500 Subject: [PATCH] Auto syndrome: got rid of allow multiple syndromes option that didn't make any sense, and made sure that if allowing multiple targets it doesn't attach the syndrome to the worker twice. --- plugins/autoSyndrome.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/plugins/autoSyndrome.cpp b/plugins/autoSyndrome.cpp index 2fa9fb681..574bcf853 100644 --- a/plugins/autoSyndrome.cpp +++ b/plugins/autoSyndrome.cpp @@ -119,7 +119,7 @@ DFhackCExport command_result plugin_init(color_ostream& out, vectorunits.all[workerIndex]; + df::unit* worker = df::global::world->units.all[workerIndex]; //find the building that made it int32_t buildingId = -1; for ( size_t a = 0; a < job->general_refs.size(); a++ ) { @@ -333,7 +333,6 @@ void processJob(color_ostream& out, void* jobPtr) { //add each syndrome to the guy who did the job df::syndrome* syndrome = inorganic->material.syndrome[b]; bool workerOnly = false; - bool allowMultipleSyndromes = false; bool allowMultipleTargets = false; bool foundCommand = false; bool destroyRock = true; @@ -345,8 +344,6 @@ void processJob(color_ostream& out, void* jobPtr) { if ( commandStr == "" ) { if ( *clazz == "\\WORKER_ONLY" ) { workerOnly = true; - } else if ( *clazz == "\\ALLOW_MULTIPLE_SYNDROMES" ) { - allowMultipleSyndromes = true; } else if ( *clazz == "\\ALLOW_MULTIPLE_TARGETS" ) { allowMultipleTargets = true; } else if ( *clazz == "\\PRESERVE_ROCK" ) { @@ -414,10 +411,10 @@ void processJob(color_ostream& out, void* jobPtr) { } //only one syndrome per reaction will be applied, unless multiples are allowed. - if ( appliedSomething && !allowMultipleSyndromes ) + if ( appliedSomething && !allowMultipleTargets ) continue; - if ( maybeApply(out, syndrome, workerId, unit) ) { + if ( maybeApply(out, syndrome, workerId, worker) ) { appliedSomething = true; } @@ -427,6 +424,8 @@ void processJob(color_ostream& out, void* jobPtr) { //now try applying it to everybody inside the building for ( size_t a = 0; a < df::global::world->units.active.size(); a++ ) { df::unit* unit = df::global::world->units.active[a]; + if ( unit == worker ) + continue; if ( unit->pos.z != building->z ) continue; if ( unit->pos.x < building->x1 || unit->pos.x > building->x2 )