|
|
@ -6,6 +6,7 @@
|
|
|
|
#include "modules/EventManager.h"
|
|
|
|
#include "modules/EventManager.h"
|
|
|
|
#include "modules/Job.h"
|
|
|
|
#include "modules/Job.h"
|
|
|
|
#include "modules/Maps.h"
|
|
|
|
#include "modules/Maps.h"
|
|
|
|
|
|
|
|
#include "modules/Once.h"
|
|
|
|
|
|
|
|
|
|
|
|
#include "df/building.h"
|
|
|
|
#include "df/building.h"
|
|
|
|
#include "df/caste_raw.h"
|
|
|
|
#include "df/caste_raw.h"
|
|
|
@ -211,7 +212,9 @@ bool maybeApply(color_ostream& out, df::syndrome* syndrome, int32_t workerId, df
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ( syndrome->syn_affected_creature.size() != syndrome->syn_affected_caste.size() ) {
|
|
|
|
if ( syndrome->syn_affected_creature.size() != syndrome->syn_affected_caste.size() ) {
|
|
|
|
|
|
|
|
if ( DFHack::Once::doOnce("autoSyndrome: different affected creature/caste sizes.") ) {
|
|
|
|
out.print("%s, line %d: different affected creature/caste sizes.\n", __FILE__, __LINE__);
|
|
|
|
out.print("%s, line %d: different affected creature/caste sizes.\n", __FILE__, __LINE__);
|
|
|
|
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for ( size_t c = 0; c < syndrome->syn_affected_creature.size(); c++ ) {
|
|
|
|
for ( size_t c = 0; c < syndrome->syn_affected_creature.size(); c++ ) {
|
|
|
@ -244,6 +247,7 @@ void processJob(color_ostream& out, void* jobPtr) {
|
|
|
|
CoreSuspender suspender;
|
|
|
|
CoreSuspender suspender;
|
|
|
|
df::job* job = (df::job*)jobPtr;
|
|
|
|
df::job* job = (df::job*)jobPtr;
|
|
|
|
if ( job == NULL ) {
|
|
|
|
if ( job == NULL ) {
|
|
|
|
|
|
|
|
if ( DFHack::Once::doOnce("autoSyndrome_processJob_null job") )
|
|
|
|
out.print("Error %s line %d: null job.\n", __FILE__, __LINE__);
|
|
|
|
out.print("Error %s line %d: null job.\n", __FILE__, __LINE__);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -262,6 +266,7 @@ void processJob(color_ostream& out, void* jobPtr) {
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( reaction == NULL ) {
|
|
|
|
if ( reaction == NULL ) {
|
|
|
|
|
|
|
|
if ( DFHack::Once::doOnce("autoSyndrome processJob couldNotFind") )
|
|
|
|
out.print("%s, line %d: could not find reaction \"%s\".\n", __FILE__, __LINE__, job->reaction_name.c_str() );
|
|
|
|
out.print("%s, line %d: could not find reaction \"%s\".\n", __FILE__, __LINE__, job->reaction_name.c_str() );
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -271,10 +276,12 @@ void processJob(color_ostream& out, void* jobPtr) {
|
|
|
|
if ( job->general_refs[a]->getType() != df::enums::general_ref_type::UNIT_WORKER )
|
|
|
|
if ( job->general_refs[a]->getType() != df::enums::general_ref_type::UNIT_WORKER )
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
if ( workerId != -1 ) {
|
|
|
|
if ( workerId != -1 ) {
|
|
|
|
|
|
|
|
if ( DFHack::Once::doOnce("autoSyndrome processJob two workers same job") )
|
|
|
|
out.print("%s, line %d: Found two workers on the same job.\n", __FILE__, __LINE__);
|
|
|
|
out.print("%s, line %d: Found two workers on the same job.\n", __FILE__, __LINE__);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
workerId = ((df::general_ref_unit_workerst*)job->general_refs[a])->unit_id;
|
|
|
|
workerId = ((df::general_ref_unit_workerst*)job->general_refs[a])->unit_id;
|
|
|
|
if (workerId == -1) {
|
|
|
|
if (workerId == -1) {
|
|
|
|
|
|
|
|
if ( DFHack::Once::doOnce("autoSyndrome processJob invalid worker") )
|
|
|
|
out.print("%s, line %d: invalid worker.\n", __FILE__, __LINE__);
|
|
|
|
out.print("%s, line %d: invalid worker.\n", __FILE__, __LINE__);
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -294,10 +301,12 @@ void processJob(color_ostream& out, void* jobPtr) {
|
|
|
|
if ( job->general_refs[a]->getType() != df::enums::general_ref_type::BUILDING_HOLDER )
|
|
|
|
if ( job->general_refs[a]->getType() != df::enums::general_ref_type::BUILDING_HOLDER )
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
if ( buildingId != -1 ) {
|
|
|
|
if ( buildingId != -1 ) {
|
|
|
|
|
|
|
|
if ( DFHack::Once::doOnce("autoSyndrome processJob two buildings same job") )
|
|
|
|
out.print("%s, line %d: Found two buildings for the same job.\n", __FILE__, __LINE__);
|
|
|
|
out.print("%s, line %d: Found two buildings for the same job.\n", __FILE__, __LINE__);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
buildingId = ((df::general_ref_building_holderst*)job->general_refs[a])->building_id;
|
|
|
|
buildingId = ((df::general_ref_building_holderst*)job->general_refs[a])->building_id;
|
|
|
|
if (buildingId == -1) {
|
|
|
|
if (buildingId == -1) {
|
|
|
|
|
|
|
|
if ( DFHack::Once::doOnce("autoSyndrome processJob invalid building") )
|
|
|
|
out.print("%s, line %d: invalid building.\n", __FILE__, __LINE__);
|
|
|
|
out.print("%s, line %d: invalid building.\n", __FILE__, __LINE__);
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -305,6 +314,7 @@ void processJob(color_ostream& out, void* jobPtr) {
|
|
|
|
|
|
|
|
|
|
|
|
df::building* building = df::building::find(buildingId);
|
|
|
|
df::building* building = df::building::find(buildingId);
|
|
|
|
if ( building == NULL ) {
|
|
|
|
if ( building == NULL ) {
|
|
|
|
|
|
|
|
if ( DFHack::Once::doOnce("autoSyndrome processJob couldn't find building") )
|
|
|
|
out.print("%s, line %d: error: couldn't find building %d.\n", __FILE__, __LINE__, buildingId);
|
|
|
|
out.print("%s, line %d: error: couldn't find building %d.\n", __FILE__, __LINE__, buildingId);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -453,6 +463,7 @@ void processJob(color_ostream& out, void* jobPtr) {
|
|
|
|
int32_t giveSyndrome(color_ostream& out, int32_t workerId, df::syndrome* syndrome) {
|
|
|
|
int32_t giveSyndrome(color_ostream& out, int32_t workerId, df::syndrome* syndrome) {
|
|
|
|
int32_t index = df::unit::binsearch_index(df::global::world->units.all, workerId);
|
|
|
|
int32_t index = df::unit::binsearch_index(df::global::world->units.all, workerId);
|
|
|
|
if ( index < 0 ) {
|
|
|
|
if ( index < 0 ) {
|
|
|
|
|
|
|
|
if ( DFHack::Once::doOnce("autoSyndrome giveSyndrome couldn't find unit") )
|
|
|
|
out.print("%s line %d: Couldn't find unit %d.\n", __FILE__, __LINE__, workerId);
|
|
|
|
out.print("%s line %d: Couldn't find unit %d.\n", __FILE__, __LINE__, workerId);
|
|
|
|
return -1;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|