From 27cc2dc92cc7c2c5221a3e3234e8aadca343555e Mon Sep 17 00:00:00 2001 From: Kelly Martin Date: Mon, 14 May 2012 21:54:11 -0500 Subject: [PATCH] Add dwarf state table entries for the new jobs from .34.7 and .34.8. Also add a warning message for a dwarf who is doing an unknown job (instead of just reading random nonsense from off the end of the dwarf_states array). This code is backward-compatible (the extra job entries will simply be unused in pre-.8). --- plugins/autolabor.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/plugins/autolabor.cpp b/plugins/autolabor.cpp index cd3232e64..5a588cdde 100644 --- a/plugins/autolabor.cpp +++ b/plugins/autolabor.cpp @@ -348,7 +348,12 @@ static const dwarf_state dwarf_states[] = { OTHER /* CauseTrouble */, OTHER /* DrinkBlood */, OTHER /* ReportCrime */, - OTHER /* ExecuteCriminal */ + OTHER /* ExecuteCriminal */, + BUSY /* TrainAnimal */, + BUSY /* CarveTrack */, + BUSY /* PushTrackVehicle */, + BUSY /* PlaceTrackVehicle */, + BUSY /* StoreItemInVehicle */ }; struct labor_info @@ -886,8 +891,13 @@ DFhackCExport command_result plugin_onupdate ( color_ostream &out ) assert(job >= 0); assert(job < ARRAY_COUNT(dwarf_states)); */ - - dwarf_info[dwarf].state = dwarf_states[job]; + if (job >= 0 && job < ARRAY_COUNT(dwarf_states)) + dwarf_info[dwarf].state = dwarf_states[job]; + else + { + out.print("Dwarf %i \"%s\" has unknown job %i\n", dwarf, dwarfs[dwarf]->name.first_name.c_str(), job); + dwarf_info[dwarf].state = OTHER; + } } state_count[dwarf_info[dwarf].state]++;