diff --git a/library/include/modules/kitchen.h b/library/include/modules/kitchen.h index b169dfb3f..a18011390 100644 --- a/library/include/modules/kitchen.h +++ b/library/include/modules/kitchen.h @@ -30,9 +30,9 @@ distribution. #include "Module.h" #include "Types.h" #include "VersionInfo.h" -#include "modules/Materials.h" -#include "modules/Items.h" #include "Core.h" +#include "modules/Items.h" + /** * \defgroup grp_kitchen Kitchen settings * @ingroup grp_modules @@ -40,6 +40,8 @@ distribution. namespace DFHack { +namespace Simple +{ namespace Kitchen { typedef uint8_t t_exclusionType; @@ -52,45 +54,33 @@ const t_itemSubtype limitSubtype = 0; // used to store limit as an entry in the const t_exclusionType limitExclusion = 4; // used to store limit as an entry in the exclusion list /** - * Kitchen exclusions manipulator class. Currently geared towards plants and seeds. - * @ingroup grp_kitchen + * Kitchen exclusions manipulator. Currently geared towards plants and seeds. + * \ingroup grp_modules + * \ingroup grp_kitchen */ -class DFHACK_EXPORT Exclusions -{ -public: - /// ctor - Exclusions(DFHack::Core& core_); - /// dtor - ~Exclusions(); - - /// print the exclusion list, with the material index also translated into its token (for organics) - for debug really - void debug_print() const; - /// remove this material from the exclusion list if it is in it - void allowPlantSeedCookery(t_materialIndex materialIndex); +// print the exclusion list, with the material index also translated into its token (for organics) - for debug really +DFHACK_EXPORT void debug_print(Core &); - /// add this material to the exclusion list, if it is not already in it - void denyPlantSeedCookery(t_materialIndex materialIndex); +// remove this material from the exclusion list if it is in it +DFHACK_EXPORT void allowPlantSeedCookery(t_materialIndex materialIndex); - /// fills a map with info from the limit info storage entries in the exclusion list - void fillWatchMap(std::map& watchMap) const; +// add this material to the exclusion list, if it is not already in it +DFHACK_EXPORT void denyPlantSeedCookery(t_materialIndex materialIndex); - /// removes a limit info storage entry from the exclusion list if it's present - void removeLimit(t_materialIndex materialIndex); +// fills a map with info from the limit info storage entries in the exclusion list +DFHACK_EXPORT void fillWatchMap(std::map& watchMap); - /// add a limit info storage item to the exclusion list, or alters an existing one - void setLimit(t_materialIndex materialIndex, unsigned int limit); +// removes a limit info storage entry from the exclusion list if it's present +DFHACK_EXPORT void removeLimit(t_materialIndex materialIndex); - /// clears all limit info storage items from the exclusion list - void clearLimits(); +// add a limit info storage item to the exclusion list, or alters an existing one +DFHACK_EXPORT void setLimit(t_materialIndex materialIndex, unsigned int limit); - /// the size of the exclusions vectors (they are all the same size - if not, there is a problem!) - std::size_t size() const; -private: - class Private; - Private* d; - -}; +// clears all limit info storage items from the exclusion list +DFHACK_EXPORT void clearLimits(); +DFHACK_EXPORT std::size_t size(); +} } } diff --git a/library/modules/kitchen.cpp b/library/modules/kitchen.cpp index cd67a9e23..3a85b3926 100644 --- a/library/modules/kitchen.cpp +++ b/library/modules/kitchen.cpp @@ -9,226 +9,191 @@ #include using namespace std; -#include "Types.h" #include "VersionInfo.h" #include "MemAccess.h" -#include "modules/Materials.h" -#include "modules/Items.h" -#include "modules/Units.h" +#include "Types.h" +#include "Error.h" #include "modules/kitchen.h" #include "ModuleFactory.h" #include "Core.h" -#include "Virtual.h" +using namespace DFHack; +using namespace DFHack::Simple; + +#include "DataDefs.h" +#include "df/world.h" +#include "df/ui.h" #include "df/item_type.h" +#include "df/plant_raw.h" + +using namespace df::enums; +using df::global::world; +using df::global::ui; -namespace DFHack +void Kitchen::debug_print(Core &core) { -namespace Kitchen + core.con.print("Kitchen Exclusions\n"); + for(std::size_t i = 0; i < size(); ++i) + { + core.con.print("%2u: IT:%2i IS:%i MT:%3i MI:%2i ET:%i %s\n", + i, + ui->kitchen.item_types[i], + ui->kitchen.item_subtypes[i], + ui->kitchen.mat_types[i], + ui->kitchen.mat_indices[i], + ui->kitchen.exc_types[i], + (ui->kitchen.mat_types[i] >= 419 && ui->kitchen.mat_types[i] <= 618) ? world->raws.plants.all[ui->kitchen.mat_indices[i]]->id.c_str() : "n/a" + ); + } + core.con.print("\n"); +} + +void Kitchen::allowPlantSeedCookery(t_materialIndex materialIndex) { - class Exclusions::Private + bool match = false; + do { - public: - Private (DFHack::Core& core_) - : core(core_) - , itemTypes (*((std::vector*)(addr(core_,0)))) - , itemSubtypes (*((std::vector*)(addr(core_,1)))) - , materialTypes (*((std::vector*)(addr(core_,2)))) - , materialIndices (*((std::vector*)(addr(core_,3)))) - , exclusionTypes (*((std::vector*)(addr(core_,4)))) + match = false; + std::size_t matchIndex = 0; + for(std::size_t i = 0; i < size(); ++i) { - }; - DFHack::Core& core; - std::vector& itemTypes; // the item types vector of the kitchen exclusion list - std::vector& itemSubtypes; // the item subtype vector of the kitchen exclusion list - std::vector& materialTypes; // the material subindex vector of the kitchen exclusion list - std::vector& materialIndices; // the material index vector of the kitchen exclusion list - std::vector& exclusionTypes; // the exclusion type vector of the kitchen excluions list - - static void * addr(const DFHack::Core& core, int index) + if(ui->kitchen.mat_indices[i] == materialIndex + && (ui->kitchen.item_types[i] == df::item_type::SEEDS || ui->kitchen.item_types[i] == df::item_type::PLANT) + && ui->kitchen.exc_types[i] == cookingExclusion + ) + { + match = true; + matchIndex = i; + } + } + if(match) { - static char * start = core.vinfo->getAddress("kitchen_limits"); - return start + sizeof(std::vector) * index; - }; - }; - - Exclusions::Exclusions(Core & c) - { - d = new Private(c); - }; - - Exclusions::~Exclusions() - { - delete d; - }; + ui->kitchen.item_types.erase(ui->kitchen.item_types.begin() + matchIndex); + ui->kitchen.item_subtypes.erase(ui->kitchen.item_subtypes.begin() + matchIndex); + ui->kitchen.mat_indices.erase(ui->kitchen.mat_indices.begin() + matchIndex); + ui->kitchen.mat_types.erase(ui->kitchen.mat_types.begin() + matchIndex); + ui->kitchen.exc_types.erase(ui->kitchen.exc_types.begin() + matchIndex); + } + } while(match); +}; - void Exclusions::debug_print() const +void Kitchen::denyPlantSeedCookery(t_materialIndex materialIndex) +{ + df::plant_raw *type = world->raws.plants.all[materialIndex]; + bool SeedAlreadyIn = false; + bool PlantAlreadyIn = false; + for(std::size_t i = 0; i < size(); ++i) { - d->core.con.print("Kitchen Exclusions\n"); - Materials& materialsModule= *d->core.getMaterials(); - for(std::size_t i = 0; i < size(); ++i) + if(ui->kitchen.mat_indices[i] == materialIndex + && ui->kitchen.exc_types[i] == cookingExclusion) { - d->core.con.print("%2u: IT:%2i IS:%i MT:%3i MI:%2i ET:%i %s\n", - i, - d->itemTypes[i], - d->itemSubtypes[i], - d->materialTypes[i], - d->materialIndices[i], - d->exclusionTypes[i], - materialsModule.df_organic->at(d->materialIndices[i])->ID.c_str() - ); + if(ui->kitchen.item_types[i] == df::item_type::SEEDS) + SeedAlreadyIn = true; + else if (ui->kitchen.item_types[i] == df::item_type::PLANT) + PlantAlreadyIn = true; } - d->core.con.print("\n"); } + if(!SeedAlreadyIn) + { + ui->kitchen.item_types.push_back(df::item_type::SEEDS); + ui->kitchen.item_subtypes.push_back(organicSubtype); + ui->kitchen.mat_types.push_back(type->material_defs.type_seed); + ui->kitchen.mat_indices.push_back(materialIndex); + ui->kitchen.exc_types.push_back(cookingExclusion); + } + if(!PlantAlreadyIn) + { + ui->kitchen.item_types.push_back(df::item_type::PLANT); + ui->kitchen.item_subtypes.push_back(organicSubtype); + ui->kitchen.mat_types.push_back(type->material_defs.type_basic_mat); + ui->kitchen.mat_indices.push_back(materialIndex); + ui->kitchen.exc_types.push_back(cookingExclusion); + } +}; - void Exclusions::allowPlantSeedCookery(t_materialIndex materialIndex) +void Kitchen::fillWatchMap(std::map& watchMap) +{ + watchMap.clear(); + for(std::size_t i = 0; i < size(); ++i) { - bool match = false; - do + if(ui->kitchen.item_subtypes[i] == limitType && ui->kitchen.item_subtypes[i] == limitSubtype && ui->kitchen.exc_types[i] == limitExclusion) { - match = false; - std::size_t matchIndex = 0; - for(std::size_t i = 0; i < size(); ++i) - { - if(d->materialIndices[i] == materialIndex - && (d->itemTypes[i] == df::item_type::SEEDS || d->itemTypes[i] == df::item_type::PLANT) - && d->exclusionTypes[i] == cookingExclusion - ) - { - match = true; - matchIndex = i; - } - } - if(match) - { - d->itemTypes.erase(d->itemTypes.begin() + matchIndex); - d->itemSubtypes.erase(d->itemSubtypes.begin() + matchIndex); - d->materialIndices.erase(d->materialIndices.begin() + matchIndex); - d->materialTypes.erase(d->materialTypes.begin() + matchIndex); - d->exclusionTypes.erase(d->exclusionTypes.begin() + matchIndex); - } - } while(match); - }; + watchMap[ui->kitchen.mat_indices[i]] = (unsigned int) ui->kitchen.mat_types[i]; + } + } +}; - void Exclusions::denyPlantSeedCookery(t_materialIndex materialIndex) +void Kitchen::removeLimit(t_materialIndex materialIndex) +{ + bool match = false; + do { - Materials *mats = d->core.getMaterials(); - df_plant_type *type = mats->df_organic->at(materialIndex); - bool SeedAlreadyIn = false; - bool PlantAlreadyIn = false; + match = false; + std::size_t matchIndex = 0; for(std::size_t i = 0; i < size(); ++i) { - if(d->materialIndices[i] == materialIndex - && d->exclusionTypes[i] == cookingExclusion) + if(ui->kitchen.item_types[i] == limitType + && ui->kitchen.item_subtypes[i] == limitSubtype + && ui->kitchen.mat_indices[i] == materialIndex + && ui->kitchen.exc_types[i] == limitExclusion) { - if(d->itemTypes[i] == df::item_type::SEEDS) - SeedAlreadyIn = true; - else if (d->itemTypes[i] == df::item_type::PLANT) - PlantAlreadyIn = true; + match = true; + matchIndex = i; } } - if(!SeedAlreadyIn) + if(match) { - d->itemTypes.push_back(df::item_type::SEEDS); - d->itemSubtypes.push_back(organicSubtype); - d->materialTypes.push_back(type->material_type_seed); - d->materialIndices.push_back(materialIndex); - d->exclusionTypes.push_back(cookingExclusion); + ui->kitchen.item_types.erase(ui->kitchen.item_types.begin() + matchIndex); + ui->kitchen.item_subtypes.erase(ui->kitchen.item_subtypes.begin() + matchIndex); + ui->kitchen.mat_types.erase(ui->kitchen.mat_types.begin() + matchIndex); + ui->kitchen.mat_indices.erase(ui->kitchen.mat_indices.begin() + matchIndex); + ui->kitchen.exc_types.erase(ui->kitchen.exc_types.begin() + matchIndex); } - if(!PlantAlreadyIn) - { - d->itemTypes.push_back(df::item_type::PLANT); - d->itemSubtypes.push_back(organicSubtype); - d->materialTypes.push_back(type->material_type_basic_mat); - d->materialIndices.push_back(materialIndex); - d->exclusionTypes.push_back(cookingExclusion); - } - }; + } while(match); +}; - void Exclusions::fillWatchMap(std::map& watchMap) const +void Kitchen::setLimit(t_materialIndex materialIndex, unsigned int limit) +{ + removeLimit(materialIndex); + if(limit > seedLimit) { - watchMap.clear(); - for(std::size_t i = 0; i < size(); ++i) - { - if(d->itemTypes[i] == limitType && d->itemSubtypes[i] == limitSubtype && d->exclusionTypes[i] == limitExclusion) - { - watchMap[d->materialIndices[i]] = (unsigned int) d->materialTypes[i]; - } - } - }; + limit = seedLimit; + } + ui->kitchen.item_types.push_back(limitType); + ui->kitchen.item_subtypes.push_back(limitSubtype); + ui->kitchen.mat_indices.push_back(materialIndex); + ui->kitchen.mat_types.push_back((t_materialType) (limit < seedLimit) ? limit : seedLimit); + ui->kitchen.exc_types.push_back(limitExclusion); +}; - void Exclusions::removeLimit(t_materialIndex materialIndex) +void Kitchen::clearLimits() +{ + bool match = false; + do { - bool match = false; - do + match = false; + std::size_t matchIndex; + for(std::size_t i = 0; i < size(); ++i) { - match = false; - std::size_t matchIndex = 0; - for(std::size_t i = 0; i < size(); ++i) + if(ui->kitchen.item_types[i] == limitType + && ui->kitchen.item_subtypes[i] == limitSubtype + && ui->kitchen.exc_types[i] == limitExclusion) { - if(d->itemTypes[i] == limitType - && d->itemSubtypes[i] == limitSubtype - && d->materialIndices[i] == materialIndex - && d->exclusionTypes[i] == limitExclusion) - { - match = true; - matchIndex = i; - } + match = true; + matchIndex = i; } - if(match) - { - d->itemTypes.erase(d->itemTypes.begin() + matchIndex); - d->itemSubtypes.erase(d->itemSubtypes.begin() + matchIndex); - d->materialTypes.erase(d->materialTypes.begin() + matchIndex); - d->materialIndices.erase(d->materialIndices.begin() + matchIndex); - d->exclusionTypes.erase(d->exclusionTypes.begin() + matchIndex); - } - } while(match); - }; - - void Exclusions::setLimit(t_materialIndex materialIndex, unsigned int limit) - { - removeLimit(materialIndex); - if(limit > seedLimit) + } + if(match) { - limit = seedLimit; + ui->kitchen.item_types.erase(ui->kitchen.item_types.begin() + matchIndex); + ui->kitchen.item_subtypes.erase(ui->kitchen.item_subtypes.begin() + matchIndex); + ui->kitchen.mat_indices.erase(ui->kitchen.mat_indices.begin() + matchIndex); + ui->kitchen.mat_types.erase(ui->kitchen.mat_types.begin() + matchIndex); + ui->kitchen.exc_types.erase(ui->kitchen.exc_types.begin() + matchIndex); } - d->itemTypes.push_back(limitType); - d->itemSubtypes.push_back(limitSubtype); - d->materialIndices.push_back(materialIndex); - d->materialTypes.push_back((t_materialType) (limit < seedLimit) ? limit : seedLimit); - d->exclusionTypes.push_back(limitExclusion); - }; + } while(match); +}; - void Exclusions::clearLimits() - { - bool match = false; - do - { - match = false; - std::size_t matchIndex; - for(std::size_t i = 0; i < size(); ++i) - { - if(d->itemTypes[i] == limitType - && d->itemSubtypes[i] == limitSubtype - && d->exclusionTypes[i] == limitExclusion) - { - match = true; - matchIndex = i; - } - } - if(match) - { - d->itemTypes.erase(d->itemTypes.begin() + matchIndex); - d->itemSubtypes.erase(d->itemSubtypes.begin() + matchIndex); - d->materialIndices.erase(d->materialIndices.begin() + matchIndex); - d->materialTypes.erase(d->materialTypes.begin() + matchIndex); - d->exclusionTypes.erase(d->exclusionTypes.begin() + matchIndex); - } - } while(match); - }; - size_t Exclusions::size() const - { - return d->itemTypes.size(); - }; -} -}; \ No newline at end of file +size_t Kitchen::size() +{ + return ui->kitchen.item_types.size(); +}; diff --git a/plugins/seedwatch.cpp b/plugins/seedwatch.cpp index 91da6813c..20d59be36 100755 --- a/plugins/seedwatch.cpp +++ b/plugins/seedwatch.cpp @@ -8,15 +8,14 @@ #include "Core.h" #include "Export.h" #include "PluginManager.h" -#include "modules/Materials.h" #include "modules/Items.h" #include "modules/World.h" #include "modules/kitchen.h" #include "VersionInfo.h" #include "df/item_flags.h" -using DFHack::t_materialType; -using DFHack::t_materialIndex; +using namespace DFHack; +using namespace DFHack::Simple; const int buffer = 20; // seed number buffer - 20 is reasonable bool running = false; // whether seedwatch is counting the seeds or not @@ -39,7 +38,7 @@ bool ignoreSeeds(df::item_flags& f) // seeds with the following flags should not f.bits.in_job; }; -void printHelp(DFHack::Core& core) // prints help +void printHelp(Core& core) // prints help { core.con.print( "Watches the numbers of seeds available and enables/disables seed and plant cooking.\n" @@ -93,17 +92,17 @@ std::string searchAbbreviations(std::string in) } }; -DFhackCExport DFHack::command_result df_seedwatch(DFHack::Core* pCore, std::vector& parameters) +DFhackCExport command_result df_seedwatch(Core* pCore, std::vector& parameters) { - DFHack::Core& core = *pCore; + Core& core = *pCore; if(!core.isValid()) { - return DFHack::CR_FAILURE; + return CR_FAILURE; } core.Suspend(); - DFHack::Materials& materialsModule = *core.getMaterials(); - std::vector organics; + Materials& materialsModule = *core.getMaterials(); + std::vector organics; materialsModule.CopyOrganicMaterials(organics); std::map materialsReverser; @@ -112,17 +111,17 @@ DFhackCExport DFHack::command_result df_seedwatch(DFHack::Core* pCore, std::vect materialsReverser[organics[i].id] = i; } - DFHack::World *w = core.getWorld(); - DFHack::t_gamemodes gm; + World *w = core.getWorld(); + t_gamemodes gm; w->ReadGameMode(gm);// FIXME: check return value // if game mode isn't fortress mode - if(gm.g_mode != DFHack::GAMEMODE_DWARF || gm.g_type != DFHack::GAMETYPE_DWARF_MAIN) + if(gm.g_mode != GAMEMODE_DWARF || gm.g_type != GAMETYPE_DWARF_MAIN) { // just print the help printHelp(core); core.Resume(); - return DFHack::CR_OK; + return CR_OK; } std::string par; @@ -148,8 +147,7 @@ DFhackCExport DFHack::command_result df_seedwatch(DFHack::Core* pCore, std::vect } else if(par == "clear") { - DFHack::Kitchen::Exclusions kitchenExclusions(core); - kitchenExclusions.clearLimits(); + Kitchen::clearLimits(); core.con.print("seedwatch watchlist cleared\n"); } else if(par == "info") @@ -163,9 +161,8 @@ DFhackCExport DFHack::command_result df_seedwatch(DFHack::Core* pCore, std::vect { core.con.print("seedwatch is not supervising. Use 'seedwatch start' to start supervision.\n"); } - DFHack::Kitchen::Exclusions kitchenExclusions(core); std::map watchMap; - kitchenExclusions.fillWatchMap(watchMap); + Kitchen::fillWatchMap(watchMap); if(watchMap.empty()) { core.con.print("The watch list is empty.\n"); @@ -181,10 +178,9 @@ DFhackCExport DFHack::command_result df_seedwatch(DFHack::Core* pCore, std::vect } else if(par == "debug") { - DFHack::Kitchen::Exclusions kitchenExclusions(core); std::map watchMap; - kitchenExclusions.fillWatchMap(watchMap); - kitchenExclusions.debug_print(); + Kitchen::fillWatchMap(watchMap); + Kitchen::debug_print(core); } /* else if(par == "dumpmaps") @@ -209,8 +205,7 @@ DFhackCExport DFHack::command_result df_seedwatch(DFHack::Core* pCore, std::vect std::string token = searchAbbreviations(par); if(materialsReverser.count(token) > 0) { - DFHack::Kitchen::Exclusions kitchenExclusions(core); - kitchenExclusions.removeLimit(materialsReverser[token]); + Kitchen::removeLimit(materialsReverser[token]); core.con.print("%s is not being watched\n", token.c_str()); } else @@ -226,8 +221,7 @@ DFhackCExport DFHack::command_result df_seedwatch(DFHack::Core* pCore, std::vect { for(std::map::const_iterator i = abbreviations.begin(); i != abbreviations.end(); ++i) { - DFHack::Kitchen::Exclusions kitchenExclusions(core); - if(materialsReverser.count(i->second) > 0) kitchenExclusions.setLimit(materialsReverser[i->second], limit); + if(materialsReverser.count(i->second) > 0) Kitchen::setLimit(materialsReverser[i->second], limit); } } else @@ -235,8 +229,7 @@ DFhackCExport DFHack::command_result df_seedwatch(DFHack::Core* pCore, std::vect std::string token = searchAbbreviations(parameters[0]); if(materialsReverser.count(token) > 0) { - DFHack::Kitchen::Exclusions kitchenExclusions(core); - kitchenExclusions.setLimit(materialsReverser[token], limit); + Kitchen::setLimit(materialsReverser[token], limit); core.con.print("%s is being watched.\n", token.c_str()); } else @@ -251,7 +244,7 @@ DFhackCExport DFHack::command_result df_seedwatch(DFHack::Core* pCore, std::vect } core.Resume(); - return DFHack::CR_OK; + return CR_OK; } DFhackCExport const char* plugin_name(void) @@ -259,10 +252,10 @@ DFhackCExport const char* plugin_name(void) return "seedwatch"; } -DFhackCExport DFHack::command_result plugin_init(DFHack::Core* pCore, std::vector& commands) +DFhackCExport command_result plugin_init(Core* pCore, std::vector& commands) { commands.clear(); - commands.push_back(DFHack::PluginCommand("seedwatch", "Switches cookery based on quantity of seeds, to keep reserves", df_seedwatch)); + commands.push_back(PluginCommand("seedwatch", "Switches cookery based on quantity of seeds, to keep reserves", df_seedwatch)); // fill in the abbreviations map, with abbreviations for the standard plants abbreviations["bs"] = "SLIVER_BARB"; abbreviations["bt"] = "TUBER_BLOATED"; @@ -285,14 +278,14 @@ DFhackCExport DFHack::command_result plugin_init(DFHack::Core* pCore, std::vecto abbreviations["vh"] = "HERB_VALLEY"; abbreviations["ws"] = "BERRIES_STRAW_WILD"; abbreviations["wv"] = "VINE_WHIP"; - return DFHack::CR_OK; + return CR_OK; } -DFhackCExport DFHack::command_result plugin_onstatechange(DFHack::Core* pCore, DFHack::state_change_event event) +DFhackCExport command_result plugin_onstatechange(Core* pCore, state_change_event event) { switch (event) { - case DFHack::SC_GAME_LOADED: - case DFHack::SC_GAME_UNLOADED: + case SC_GAME_LOADED: + case SC_GAME_UNLOADED: if (running) pCore->con.printerr("seedwatch deactivated due to game load/unload\n"); running = false; @@ -301,34 +294,34 @@ DFhackCExport DFHack::command_result plugin_onstatechange(DFHack::Core* pCore, D break; } - return DFHack::CR_OK; + return CR_OK; } -DFhackCExport DFHack::command_result plugin_onupdate(DFHack::Core* pCore) +DFhackCExport command_result plugin_onupdate(Core* pCore) { if (running) { // reduce processing rate static int counter = 0; if (++counter < 500) - return DFHack::CR_OK; + return CR_OK; counter = 0; - DFHack::Core& core = *pCore; - DFHack::World *w = core.getWorld(); - DFHack::t_gamemodes gm; + Core& core = *pCore; + World *w = core.getWorld(); + t_gamemodes gm; w->ReadGameMode(gm);// FIXME: check return value // if game mode isn't fortress mode - if(gm.g_mode != DFHack::GAMEMODE_DWARF || gm.g_type != DFHack::GAMETYPE_DWARF_MAIN) + if(gm.g_mode != GAMEMODE_DWARF || gm.g_type != GAMETYPE_DWARF_MAIN) { // stop running. running = false; core.con.printerr("seedwatch deactivated due to game mode switch\n"); - return DFHack::CR_OK; + return CR_OK; } // this is dwarf mode, continue std::map seedCount; // the number of seeds - DFHack::Items& itemsModule = *core.getItems(); + Items& itemsModule = *core.getItems(); itemsModule.Start(); std::vector items; itemsModule.readItemVector(items); @@ -349,25 +342,24 @@ DFhackCExport DFHack::command_result plugin_onupdate(DFHack::Core* pCore) } itemsModule.Finish(); - DFHack::Kitchen::Exclusions kitchenExclusions(core); std::map watchMap; - kitchenExclusions.fillWatchMap(watchMap); + Kitchen::fillWatchMap(watchMap); for(auto i = watchMap.begin(); i != watchMap.end(); ++i) { if(seedCount[i->first] <= i->second) { - kitchenExclusions.denyPlantSeedCookery(i->first); + Kitchen::denyPlantSeedCookery(i->first); } else if(i->second + buffer < seedCount[i->first]) { - kitchenExclusions.allowPlantSeedCookery(i->first); + Kitchen::allowPlantSeedCookery(i->first); } } } - return DFHack::CR_OK; + return CR_OK; } -DFhackCExport DFHack::command_result plugin_shutdown(DFHack::Core* pCore) +DFhackCExport command_result plugin_shutdown(Core* pCore) { - return DFHack::CR_OK; + return CR_OK; }