diff --git a/CMakeLists.txt b/CMakeLists.txt index 1b4608229..a5bf2d129 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,11 +26,14 @@ endif() # set up versioning. set(DF_VERSION_MAJOR "0") -set(DF_VERSION_MINOR "31") -set(DF_VERSION_PATCH "25") +set(DF_VERSION_MINOR "34") +set(DF_VERSION_PATCH "02") set(DF_VERSION "${DF_VERSION_MAJOR}.${DF_VERSION_MINOR}.${DF_VERSION_PATCH}") -set(DFHACK_RELEASE "9b") +set(DFHACK_RELEASE "1") + +set(DFHACK_VERSION "${DF_VERSION_MAJOR}.${DF_VERSION_MINOR}.${DF_VERSION_PATCH}-r${DFHACK_RELEASE}") +add_definitions(-DDFHACK_VERSION="${DFHACK_VERSION}") ## where to install things (after the build is done, classic 'make install' or package structure) # the dfhack libraries will be installed here: @@ -99,5 +102,5 @@ ELSEIF(WIN32) SET(CPACK_GENERATOR "ZIP") ENDIF() set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY 0) -set(CPACK_PACKAGE_FILE_NAME "dfhack-${DF_VERSION}-r${DFHACK_RELEASE}-${CMAKE_SYSTEM_NAME}") +set(CPACK_PACKAGE_FILE_NAME "dfhack-${DFHACK_VERSION}-${CMAKE_SYSTEM_NAME}") INCLUDE(CPack) diff --git a/library/Core.cpp b/library/Core.cpp index f8aed53af..b0c8f7599 100644 --- a/library/Core.cpp +++ b/library/Core.cpp @@ -385,7 +385,8 @@ static void runInteractiveCommand(Core *core, PluginManager *plug_mgr, int &clue for (size_t j = 0; j < plug->size();j++) { const PluginCommand & pcmd = (plug->operator[](j)); - out.insert({pcmd.isHotkeyCommand(),pcmd.name,pcmd.description}); + sortable so = {pcmd.isHotkeyCommand(),pcmd.name,pcmd.description}; + out.insert(so); } } for(auto iter = out.begin();iter != out.end();iter++) diff --git a/library/Hooks-windows.cpp b/library/Hooks-windows.cpp index 51e197722..da95f395b 100644 --- a/library/Hooks-windows.cpp +++ b/library/Hooks-windows.cpp @@ -46,7 +46,7 @@ namespace DFHack } void * LookupPlugin (DFLibrary * plugin ,const char * function) { - return (DFLibrary *) GetProcAddress((HMODULE)plugin, function); + return (void *) GetProcAddress((HMODULE)plugin, function); } void ClosePlugin (DFLibrary * plugin) { diff --git a/library/PluginManager.cpp b/library/PluginManager.cpp index 84f052bab..492c4be6f 100644 --- a/library/PluginManager.cpp +++ b/library/PluginManager.cpp @@ -120,6 +120,14 @@ struct Plugin::RefLock mutex * mut; int refcount; }; + +struct Plugin::RefAutolock +{ + RefLock * lock; + RefAutolock(RefLock * lck):lock(lck){ lock->lock(); }; + ~RefAutolock(){ lock->unlock(); }; +}; + Plugin::Plugin(Core * core, const std::string & filepath, const std::string & _filename, PluginManager * pm) { filename = filepath; @@ -154,15 +162,13 @@ Plugin::~Plugin() bool Plugin::load() { - access->lock(); + RefAutolock lock(access); if(state == PS_BROKEN) { - access->unlock(); return false; } else if(state == PS_LOADED) { - access->unlock(); return true; } Core & c = Core::getInstance(); @@ -172,16 +178,23 @@ bool Plugin::load() { con.printerr("Can't load plugin %s\n", filename.c_str()); state = PS_BROKEN; - access->unlock(); return false; } - const char * (*_PlugName)() =(const char * (*)()) LookupPlugin(plug, "plugin_name"); - if(!_PlugName) + const char ** plug_name =(const char ** ) LookupPlugin(plug, "name"); + if(!plug_name) { con.printerr("Plugin %s has no name.\n", filename.c_str()); ClosePlugin(plug); state = PS_BROKEN; - access->unlock(); + return false; + } + const char ** plug_version =(const char ** ) LookupPlugin(plug, "version"); + if(!plug_version || strcmp(DFHACK_VERSION, *plug_version) != 0) + { + con.printerr("Plugin sx was not built for this version of DFHack.\n" + "Plugin: %s, DFHack: %s\n", *plug_name, *plug_version, DFHACK_VERSION); + ClosePlugin(plug); + state = PS_BROKEN; return false; } plugin_init = (command_result (*)(Core *, std::vector &)) LookupPlugin(plug, "plugin_init"); @@ -190,20 +203,18 @@ bool Plugin::load() con.printerr("Plugin %s has no init function.\n", filename.c_str()); ClosePlugin(plug); state = PS_BROKEN; - access->unlock(); return false; } plugin_status = (command_result (*)(Core *, std::string &)) LookupPlugin(plug, "plugin_status"); plugin_onupdate = (command_result (*)(Core *)) LookupPlugin(plug, "plugin_onupdate"); plugin_shutdown = (command_result (*)(Core *)) LookupPlugin(plug, "plugin_shutdown"); plugin_onstatechange = (command_result (*)(Core *, state_change_event)) LookupPlugin(plug, "plugin_onstatechange"); - //name = _PlugName(); + this->name = *plug_name; plugin_lib = plug; if(plugin_init(&c,commands) == CR_OK) { state = PS_LOADED; parent->registerCommands(this); - access->unlock(); return true; } else @@ -211,10 +222,8 @@ bool Plugin::load() con.printerr("Plugin %s has failed to initialize properly.\n", filename.c_str()); ClosePlugin(plugin_lib); state = PS_BROKEN; - access->unlock(); return false; } - // not reachable } bool Plugin::unload() diff --git a/library/include/PluginManager.h b/library/include/PluginManager.h index d14f4d99a..75fb32315 100644 --- a/library/include/PluginManager.h +++ b/library/include/PluginManager.h @@ -102,6 +102,7 @@ namespace DFHack class Plugin { struct RefLock; + struct RefAutolock; enum plugin_state { PS_UNLOADED, @@ -185,5 +186,8 @@ namespace DFHack DFHACK_EXPORT bool default_hotkey(Core *, df::viewscreen *); DFHACK_EXPORT bool dwarfmode_hotkey(Core *, df::viewscreen *); DFHACK_EXPORT bool cursor_hotkey(Core *, df::viewscreen *); -} +}; +/// You have to have this in every plugin you write - just once. Ideally on top of the main file. +#define DFHACK_PLUGIN(plugin_name) DFhackCExport const char * version = DFHACK_VERSION;\ +DFhackCExport const char * name = plugin_name; diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index 2dcfe2766..638e5aca4 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -45,39 +45,43 @@ if (BUILD_DWARFEXPORT) add_subdirectory (dwarfexport) endif() -DFHACK_PLUGIN(reveal reveal.cpp) -DFHACK_PLUGIN(probe probe.cpp) -DFHACK_PLUGIN(drybuckets drybuckets.cpp) -DFHACK_PLUGIN(getplants getplants.cpp) -DFHACK_PLUGIN(plants plants.cpp) -DFHACK_PLUGIN(fastdwarf fastdwarf.cpp) -DFHACK_PLUGIN(prospector prospector.cpp) -DFHACK_PLUGIN(cleaners cleaners.cpp) -DFHACK_PLUGIN(weather weather.cpp) -DFHACK_PLUGIN(vdig vdig.cpp) -DFHACK_PLUGIN(colonies colonies.cpp) -DFHACK_PLUGIN(mode mode.cpp) -DFHACK_PLUGIN(liquids liquids.cpp) -DFHACK_PLUGIN(tiletypes tiletypes.cpp) -DFHACK_PLUGIN(tubefill tubefill.cpp) -DFHACK_PLUGIN(autodump autodump.cpp) -DFHACK_PLUGIN(cleanowned cleanowned.cpp) -DFHACK_PLUGIN(deramp deramp.cpp) -DFHACK_PLUGIN(flows flows.cpp) -DFHACK_PLUGIN(filltraffic filltraffic.cpp) -DFHACK_PLUGIN(seedwatch seedwatch.cpp) -DFHACK_PLUGIN(initflags initflags.cpp) -DFHACK_PLUGIN(stockpiles stockpiles.cpp) -DFHACK_PLUGIN(rename rename.cpp) -DFHACK_PLUGIN(fixwagons fixwagons.cpp) -DFHACK_PLUGIN(jobutils jobutils.cpp) -DFHACK_PLUGIN(regrass regrass.cpp) -DFHACK_PLUGIN(workflow workflow.cpp) -DFHACK_PLUGIN(showmood showmood.cpp) -DFHACK_PLUGIN(fixveins fixveins.cpp) -DFHACK_PLUGIN(fixpositions fixpositions.cpp) -DFHACK_PLUGIN(follow follow.cpp) -#DFHACK_PLUGIN(versionosd versionosd.cpp) +OPTION(BUILD_SUPPORTED "Build the supported plugins (reveal, probe, etc.)." ON) +if (BUILD_SUPPORTED) + DFHACK_PLUGIN(reveal reveal.cpp) + DFHACK_PLUGIN(probe probe.cpp) + DFHACK_PLUGIN(drybuckets drybuckets.cpp) + DFHACK_PLUGIN(getplants getplants.cpp) + DFHACK_PLUGIN(plants plants.cpp) + DFHACK_PLUGIN(fastdwarf fastdwarf.cpp) + DFHACK_PLUGIN(prospector prospector.cpp) + DFHACK_PLUGIN(cleaners cleaners.cpp) + DFHACK_PLUGIN(weather weather.cpp) + DFHACK_PLUGIN(vdig vdig.cpp) + DFHACK_PLUGIN(colonies colonies.cpp) + DFHACK_PLUGIN(mode mode.cpp) + DFHACK_PLUGIN(liquids liquids.cpp) + DFHACK_PLUGIN(tiletypes tiletypes.cpp) + DFHACK_PLUGIN(tubefill tubefill.cpp) + DFHACK_PLUGIN(autodump autodump.cpp) + DFHACK_PLUGIN(cleanowned cleanowned.cpp) + DFHACK_PLUGIN(deramp deramp.cpp) + DFHACK_PLUGIN(flows flows.cpp) + DFHACK_PLUGIN(filltraffic filltraffic.cpp) + DFHACK_PLUGIN(seedwatch seedwatch.cpp) + DFHACK_PLUGIN(initflags initflags.cpp) + DFHACK_PLUGIN(stockpiles stockpiles.cpp) + DFHACK_PLUGIN(rename rename.cpp) + DFHACK_PLUGIN(fixwagons fixwagons.cpp) + DFHACK_PLUGIN(jobutils jobutils.cpp) + DFHACK_PLUGIN(regrass regrass.cpp) + DFHACK_PLUGIN(workflow workflow.cpp) + DFHACK_PLUGIN(showmood showmood.cpp) + DFHACK_PLUGIN(fixveins fixveins.cpp) + DFHACK_PLUGIN(fixpositions fixpositions.cpp) + DFHACK_PLUGIN(follow follow.cpp) + #DFHACK_PLUGIN(versionosd versionosd.cpp) +endif() + # this is the skeleton plugin. If you want to make your own, make a copy and then change it OPTION(BUILD_SKELETON "Build the skeleton plugin." OFF) diff --git a/plugins/Dfusion/dfusion.cpp b/plugins/Dfusion/dfusion.cpp index 0cde3275f..4b740c43c 100644 --- a/plugins/Dfusion/dfusion.cpp +++ b/plugins/Dfusion/dfusion.cpp @@ -38,7 +38,6 @@ DFhackCExport const char * plugin_name ( void ) DFhackCExport command_result plugin_init ( Core * c, std::vector &commands) { - commands.clear(); lua::state st=lua::glua::Get(); //maybe remake it to run automaticaly lua::RegisterConsole(st,&c->con); diff --git a/plugins/autodump.cpp b/plugins/autodump.cpp index 8eb2fc628..67f31d7d5 100644 --- a/plugins/autodump.cpp +++ b/plugins/autodump.cpp @@ -32,18 +32,14 @@ using MapExtras::Block; using MapExtras::MapCache; using df::global::world; +DFHACK_PLUGIN("autodump"); + command_result df_autodump(Core * c, vector & parameters); command_result df_autodump_destroy_here(Core * c, vector & parameters); command_result df_autodump_destroy_item(Core * c, vector & parameters); -DFhackCExport const char * plugin_name ( void ) -{ - return "autodump"; -} - DFhackCExport command_result plugin_init ( Core * c, vector &commands) { - commands.clear(); commands.push_back(PluginCommand( "autodump", "Teleport items marked for dumping to the cursor.", df_autodump, false, diff --git a/plugins/cleaners.cpp b/plugins/cleaners.cpp index ffcb0e9dc..42bb9e757 100644 --- a/plugins/cleaners.cpp +++ b/plugins/cleaners.cpp @@ -22,6 +22,8 @@ using namespace df::enums; using df::global::world; using df::global::cursor; +DFHACK_PLUGIN("cleaners"); + command_result cleanmap (Core * c, bool snow, bool mud) { // Invoked from clean(), already suspended @@ -186,14 +188,8 @@ command_result clean (Core * c, vector & parameters) return CR_OK; } -DFhackCExport const char * plugin_name ( void ) -{ - return "cleaners"; -} - DFhackCExport command_result plugin_init ( Core * c, std::vector &commands) { - commands.clear(); commands.push_back(PluginCommand( "clean","Removes contaminants from map tiles, items and creatures.", clean, false, diff --git a/plugins/cleanowned.cpp b/plugins/cleanowned.cpp index 00aa85a9d..5b6907e59 100644 --- a/plugins/cleanowned.cpp +++ b/plugins/cleanowned.cpp @@ -28,14 +28,10 @@ using df::global::world; command_result df_cleanowned (Core * c, vector & parameters); -DFhackCExport const char * plugin_name ( void ) -{ - return "cleanowned"; -} +DFHACK_PLUGIN("cleanowned"); DFhackCExport command_result plugin_init ( Core * c, std::vector &commands) { - commands.clear(); commands.push_back(PluginCommand( "cleanowned", "Confiscates and dumps garbage owned by dwarfs.", df_cleanowned, false, diff --git a/plugins/colonies.cpp b/plugins/colonies.cpp index af6af8621..6b12f8100 100644 --- a/plugins/colonies.cpp +++ b/plugins/colonies.cpp @@ -14,14 +14,10 @@ using namespace DFHack::Simple; command_result colonies (Core * c, vector & parameters); -DFhackCExport const char * plugin_name ( void ) -{ - return "colonies"; -} +DFHACK_PLUGIN("colonies"); DFhackCExport command_result plugin_init ( Core * c, std::vector &commands) { - commands.clear(); commands.push_back(PluginCommand( "colonies", "List or change wild colonies (ants hills and such)", colonies, false, diff --git a/plugins/deramp.cpp b/plugins/deramp.cpp index a47fa932a..14e8d6842 100644 --- a/plugins/deramp.cpp +++ b/plugins/deramp.cpp @@ -17,6 +17,8 @@ using namespace df::enums; using df::global::world; +DFHACK_PLUGIN("deramp"); + command_result df_deramp (Core * c, vector & parameters) { if (!parameters.empty()) @@ -80,14 +82,8 @@ command_result df_deramp (Core * c, vector & parameters) return CR_OK; } -DFhackCExport const char * plugin_name ( void ) -{ - return "deramp"; -} - DFhackCExport command_result plugin_init ( Core * c, std::vector &commands) { - commands.clear(); commands.push_back(PluginCommand( "deramp", "De-ramp. All ramps marked for removal are replaced with floors.", df_deramp, false, diff --git a/plugins/devel/buildprobe.cpp b/plugins/devel/buildprobe.cpp index 3f8660164..223157641 100644 --- a/plugins/devel/buildprobe.cpp +++ b/plugins/devel/buildprobe.cpp @@ -21,14 +21,10 @@ using namespace DFHack; command_result readFlag (Core * c, vector & parameters); command_result writeFlag (Core * c, vector & parameters); -DFhackCExport const char * plugin_name ( void ) -{ - return "buildprobe"; -} +DFHACK_PLUGIN("buildprobe"); DFhackCExport command_result plugin_init ( Core * c, std::vector &commands) { - commands.clear(); commands.push_back(PluginCommand("bshow","Output building occupancy value",readFlag)); commands.push_back(PluginCommand("bset","Set building occupancy value",writeFlag)); return CR_OK; diff --git a/plugins/devel/catsplosion.cpp b/plugins/devel/catsplosion.cpp index 6a329f3e5..f6952405d 100644 --- a/plugins/devel/catsplosion.cpp +++ b/plugins/devel/catsplosion.cpp @@ -28,16 +28,12 @@ using namespace DFHack::Simple; command_result catsplosion (Core * c, std::vector & parameters); -DFhackCExport const char * plugin_name ( void ) -{ - return "catsplosion"; -} +DFHACK_PLUGIN("catsplosion"); // Mandatory init function. If you have some global state, create it here. DFhackCExport command_result plugin_init ( Core * c, std::vector &commands) { // Fill the command list with your commands. - commands.clear(); commands.push_back(PluginCommand( "catsplosion", "Do nothing, look pretty.", catsplosion, false, diff --git a/plugins/devel/frozen.cpp b/plugins/devel/frozen.cpp index 60f1d19b9..1bcb6f83e 100644 --- a/plugins/devel/frozen.cpp +++ b/plugins/devel/frozen.cpp @@ -80,14 +80,10 @@ command_result df_frozenwater (Core * c, vector & parameters) return CR_OK; } -DFhackCExport const char * plugin_name ( void ) -{ - return "frozen"; -} +DFHACK_PLUGIN("frozen"); DFhackCExport command_result plugin_init ( Core * c, std::vector &commands) { - commands.clear(); commands.push_back(PluginCommand("frozenlava", "Changes all ice into frozen magma.", df_frozenlava)); commands.push_back(PluginCommand("frozenwater", "Changes all ice into frozen water.", df_frozenwater)); return CR_OK; diff --git a/plugins/devel/itemhacks.cpp b/plugins/devel/itemhacks.cpp index 0a84df28b..af17a8acb 100644 --- a/plugins/devel/itemhacks.cpp +++ b/plugins/devel/itemhacks.cpp @@ -155,7 +155,6 @@ DFhackCExport const char * plugin_name ( void ) DFhackCExport command_result plugin_init ( Core * c, std::vector &commands) { - commands.clear(); commands.push_back(PluginCommand("dumpitems", "Dump items\ \n Options:\ diff --git a/plugins/devel/kittens.cpp b/plugins/devel/kittens.cpp index 19b392136..0135baf74 100644 --- a/plugins/devel/kittens.cpp +++ b/plugins/devel/kittens.cpp @@ -34,14 +34,10 @@ command_result trackpos (Core * c, vector & parameters); command_result colormods (Core * c, vector & parameters); command_result zoom (Core * c, vector & parameters); -DFhackCExport const char * plugin_name ( void ) -{ - return "kittens"; -} +DFHACK_PLUGIN("kittens"); DFhackCExport command_result plugin_init ( Core * c, std::vector &commands) { - commands.clear(); commands.push_back(PluginCommand("nyan","NYAN CAT INVASION!",kittens, true)); commands.push_back(PluginCommand("ktimer","Measure time between game updates and console lag (toggle).",ktimer)); commands.push_back(PluginCommand("trackmenu","Track menu ID changes (toggle).",trackmenu)); diff --git a/plugins/devel/memview.cpp b/plugins/devel/memview.cpp index 181a3aa71..35c6e6d3e 100644 --- a/plugins/devel/memview.cpp +++ b/plugins/devel/memview.cpp @@ -30,14 +30,10 @@ enum HEXVIEW_STATES }; command_result memview (Core * c, vector & parameters); -DFhackCExport const char * plugin_name ( void ) -{ - return "memview"; -} +DFHACK_PLUGIN("memview"); DFhackCExport command_result plugin_init ( Core * c, std::vector &commands) { - commands.clear(); commands.push_back(PluginCommand("memview","Shows memory in real time. Params: adrr length refresh_rate. If addr==0 then stop viewing",memview)); memdata.state=STATE_OFF; mymutex=new tthread::mutex; diff --git a/plugins/devel/notes.cpp b/plugins/devel/notes.cpp index 7e613181e..494828616 100644 --- a/plugins/devel/notes.cpp +++ b/plugins/devel/notes.cpp @@ -12,14 +12,10 @@ using namespace DFHack; command_result df_notes (Core * c, vector & parameters); -DFhackCExport const char * plugin_name ( void ) -{ - return "notes"; -} +DFHACK_PLUGIN("notes"); DFhackCExport command_result plugin_init ( Core * c, std::vector &commands) { - commands.clear(); commands.push_back(PluginCommand("dumpnotes", "Dumps in-game notes", df_notes)); diff --git a/plugins/devel/rawdump.cpp b/plugins/devel/rawdump.cpp index 1dc7ebe42..ee006205e 100644 --- a/plugins/devel/rawdump.cpp +++ b/plugins/devel/rawdump.cpp @@ -19,14 +19,10 @@ uint64_t timeLast = 0; command_result rawdump_i (Core * c, vector & parameters); command_result rawdump_p (Core * c, vector & parameters); -DFhackCExport const char * plugin_name ( void ) -{ - return "rawdump"; -} +DFHACK_PLUGIN("rawdump"); DFhackCExport command_result plugin_init ( Core * c, std::vector &commands) { - commands.clear(); commands.push_back(PluginCommand("dump_inorganic","Dump inorganic raws.",rawdump_i)); commands.push_back(PluginCommand("dump_plants","Dump plant raws.",rawdump_p)); return CR_OK; diff --git a/plugins/devel/tiles.cpp b/plugins/devel/tiles.cpp index 219a9d28b..1d30ca953 100644 --- a/plugins/devel/tiles.cpp +++ b/plugins/devel/tiles.cpp @@ -199,14 +199,10 @@ struct Settings Brush * brush; } settings; -DFhackCExport const char * plugin_name ( void ) -{ - return "tiles"; -} +DFHACK_PLUGIN("tiles"); DFhackCExport command_result plugin_init ( Core * c, std::vector &commands) { - commands.clear(); commands.push_back(PluginCommand("tiles", "A tile painter. See 'tile help' for details.", df_tiles)); commands.push_back(PluginCommand("paint", "Paint with the current tiles settings.", df_paint)); return CR_OK; diff --git a/plugins/devel/tilesieve.cpp b/plugins/devel/tilesieve.cpp index 658397daf..21bcd0c90 100644 --- a/plugins/devel/tilesieve.cpp +++ b/plugins/devel/tilesieve.cpp @@ -21,17 +21,13 @@ using df::global::world; // mostly to allow having the mandatory stuff on top of the file and commands on the bottom command_result tilesieve (Core * c, std::vector & parameters); -// A plugins must be able to return its name. This must correspond to the filename - skeleton.plug.so or skeleton.plug.dll -DFhackCExport const char * plugin_name ( void ) -{ - return "tilesieve"; -} +// A plugin must be able to return its name. This must correspond to the filename - skeleton.plug.so or skeleton.plug.dll +DFHACK_PLUGIN("tilesieve"); // Mandatory init function. If you have some global state, create it here. DFhackCExport command_result plugin_init ( Core * c, std::vector &commands) { // Fill the command list with your commands. - commands.clear(); commands.push_back(PluginCommand( "tilesieve", "Scan map for unknown tiles.", tilesieve, false, /* true means that the command can't be used from non-interactive user interface */ diff --git a/plugins/devel/vectors.cpp b/plugins/devel/vectors.cpp index 4d8fde9d9..f49c85e06 100644 --- a/plugins/devel/vectors.cpp +++ b/plugins/devel/vectors.cpp @@ -29,15 +29,10 @@ command_result df_vectors (Core * c, command_result df_clearvec (Core * c, vector & parameters); -DFhackCExport const char * plugin_name ( void ) -{ - return "vectors"; -} +DFHACK_PLUGIN("vectors"); DFhackCExport command_result plugin_init ( Core * c, std::vector &commands) { - commands.clear(); - commands.push_back(PluginCommand("vectors", "Scan memory for vectors.\ \n 1st param: start of scan\ diff --git a/plugins/df2mc b/plugins/df2mc index 23fbb78ed..f149da6ef 160000 --- a/plugins/df2mc +++ b/plugins/df2mc @@ -1 +1 @@ -Subproject commit 23fbb78edaff35a62887803e178a24f9148ffc84 +Subproject commit f149da6efead3c46845d7478d1ff3d11119c589d diff --git a/plugins/drybuckets.cpp b/plugins/drybuckets.cpp index 637c0dc98..23b63bb44 100644 --- a/plugins/drybuckets.cpp +++ b/plugins/drybuckets.cpp @@ -17,6 +17,8 @@ using namespace df::enums; using df::global::world; +DFHACK_PLUGIN("drybuckets"); + command_result df_drybuckets (Core * c, vector & parameters) { if (!parameters.empty()) @@ -39,14 +41,8 @@ command_result df_drybuckets (Core * c, vector & parameters) return CR_OK; } -DFhackCExport const char * plugin_name ( void ) -{ - return "drybuckets"; -} - DFhackCExport command_result plugin_init ( Core * c, std::vector &commands) { - commands.clear(); commands.push_back(PluginCommand("drybuckets", "Removes water from buckets.", df_drybuckets)); return CR_OK; } diff --git a/plugins/dwarfexport/dwarfexport.cpp b/plugins/dwarfexport/dwarfexport.cpp index 877c75e2b..996f8c98c 100644 --- a/plugins/dwarfexport/dwarfexport.cpp +++ b/plugins/dwarfexport/dwarfexport.cpp @@ -35,17 +35,12 @@ using df::global::world; // mostly to allow having the mandatory stuff on top of the file and commands on the bottom command_result export_dwarves (Core * c, std::vector & parameters); -// A plugins must be able to return its name. This must correspond to the filename - export.plug.so or export.plug.dll -DFhackCExport const char * plugin_name ( void ) -{ - return "dwarfexport"; -} +DFHACK_PLUGIN("dwarfexport"); // Mandatory init function. If you have some global state, create it here. DFhackCExport command_result plugin_init ( Core * c, std::vector &commands) { // Fill the command list with your commands. - commands.clear(); commands.push_back(PluginCommand("dwarfexport", "Export dwarves to RuneSmith-compatible XML.", export_dwarves /*, diff --git a/plugins/fastdwarf.cpp b/plugins/fastdwarf.cpp index e692a4cf9..6cb6fabbc 100644 --- a/plugins/fastdwarf.cpp +++ b/plugins/fastdwarf.cpp @@ -16,10 +16,7 @@ using df::global::world; using df::global::ui; // dfhack interface -DFhackCExport const char * plugin_name ( void ) -{ - return "fastdwarf"; -} +DFHACK_PLUGIN("fastdwarf"); DFhackCExport command_result plugin_shutdown ( Core * c ) { @@ -68,8 +65,6 @@ static command_result fastdwarf (Core * c, vector & parameters) DFhackCExport command_result plugin_init ( Core * c, std::vector &commands) { - commands.clear(); - commands.push_back(PluginCommand("fastdwarf", "enable/disable fastdwarf (parameter=0/1)", fastdwarf)); diff --git a/plugins/filltraffic.cpp b/plugins/filltraffic.cpp index 3c1653ec3..dc05ecbc4 100644 --- a/plugins/filltraffic.cpp +++ b/plugins/filltraffic.cpp @@ -34,14 +34,10 @@ void allNormal(DFCoord coord, MapExtras::MapCache & map); void allLow(DFCoord coord, MapExtras::MapCache & map); void allRestricted(DFCoord coord, MapExtras::MapCache & map); -DFhackCExport const char * plugin_name ( void ) -{ - return "filltraffic"; -} +DFHACK_PLUGIN("filltraffic"); DFhackCExport command_result plugin_init ( Core * c, std::vector &commands) { - commands.clear(); commands.push_back(PluginCommand( "filltraffic","Flood-fill with selected traffic designation from cursor", filltraffic, cursor_hotkey, diff --git a/plugins/fixpositions.cpp b/plugins/fixpositions.cpp index 5e75cc7f5..76f3e06ef 100644 --- a/plugins/fixpositions.cpp +++ b/plugins/fixpositions.cpp @@ -224,14 +224,10 @@ command_result df_fixmerchants (Core *c, vector ¶meters) return CR_OK; } -DFhackCExport const char * plugin_name ( void ) -{ - return "fixpositions"; -} +DFHACK_PLUGIN("fixpositions"); DFhackCExport command_result plugin_init ( Core * c, std::vector &commands) { - commands.clear(); commands.push_back(PluginCommand( "fixdiplomats", "Add Diplomat position to Elven civilizations for tree cap diplomacy.", df_fixdiplomats, false)); diff --git a/plugins/fixveins.cpp b/plugins/fixveins.cpp index bb136f14b..3d8d5caea 100644 --- a/plugins/fixveins.cpp +++ b/plugins/fixveins.cpp @@ -97,14 +97,10 @@ command_result df_fixveins (Core * c, vector & parameters) return CR_OK; } -DFhackCExport const char * plugin_name ( void ) -{ - return "fixveins"; -} +DFHACK_PLUGIN("fixveins"); DFhackCExport command_result plugin_init ( Core * c, std::vector &commands) { - commands.clear(); commands.push_back(PluginCommand("fixveins", "Remove invalid references to mineral inclusions and restore missing ones.", df_fixveins)); diff --git a/plugins/fixwagons.cpp b/plugins/fixwagons.cpp index 57db7a66c..3f27dc6dc 100644 --- a/plugins/fixwagons.cpp +++ b/plugins/fixwagons.cpp @@ -84,14 +84,10 @@ command_result df_fixwagons (Core *c, vector ¶meters) return CR_OK; } -DFhackCExport const char * plugin_name ( void ) -{ - return "fixwagons"; -} +DFHACK_PLUGIN("fixwagons"); DFhackCExport command_result plugin_init ( Core * c, std::vector &commands) { - commands.clear(); commands.push_back(PluginCommand( "fixwagons", "Fix all civilizations to be able to bring wagons.", df_fixwagons, false, diff --git a/plugins/flows.cpp b/plugins/flows.cpp index f639e9e9e..287dbc2c9 100644 --- a/plugins/flows.cpp +++ b/plugins/flows.cpp @@ -56,14 +56,10 @@ command_result df_flows (Core * c, vector & parameters) return CR_OK; } -DFhackCExport const char * plugin_name ( void ) -{ - return "flows"; -} +DFHACK_PLUGIN("flows"); DFhackCExport command_result plugin_init ( Core * c, std::vector &commands) { - commands.clear(); commands.push_back(PluginCommand("flows", "Counts map blocks with flowing liquids.", df_flows)); diff --git a/plugins/follow.cpp b/plugins/follow.cpp index 2c4237b3f..781bb69d8 100644 --- a/plugins/follow.cpp +++ b/plugins/follow.cpp @@ -22,15 +22,10 @@ command_result follow (Core * c, std::vector & parameters); df::unit *followedUnit; int32_t prevX, prevY, prevZ; -DFhackCExport const char * plugin_name ( void ) -{ - return "follow"; -} - +DFHACK_PLUGIN("follow"); DFhackCExport command_result plugin_init ( Core * c, std::vector &commands) { - commands.clear(); commands.push_back(PluginCommand( "follow", "Follow the selected unit until camera control is released", follow, false, diff --git a/plugins/getplants.cpp b/plugins/getplants.cpp index e1d483d8f..5361a7ea7 100644 --- a/plugins/getplants.cpp +++ b/plugins/getplants.cpp @@ -134,14 +134,10 @@ command_result df_getplants (Core * c, vector & parameters) return CR_OK; } -DFhackCExport const char * plugin_name ( void ) -{ - return "getplants"; -} +DFHACK_PLUGIN("getplants"); DFhackCExport command_result plugin_init ( Core * c, vector &commands) { - commands.clear(); commands.push_back(PluginCommand( "getplants", "Cut down all of the specified trees or gather specified shrubs", df_getplants, false, diff --git a/plugins/initflags.cpp b/plugins/initflags.cpp index 900855e4e..c9bbe4584 100644 --- a/plugins/initflags.cpp +++ b/plugins/initflags.cpp @@ -17,14 +17,10 @@ using df::global::d_init; command_result twaterlvl(Core * c, vector & parameters); command_result tidlers(Core * c, vector & parameters); -DFhackCExport const char * plugin_name ( void ) -{ - return "initflags"; -} +DFHACK_PLUGIN("initflags"); DFhackCExport command_result plugin_init (Core *c, std::vector &commands) { - commands.clear(); if (d_init) { commands.push_back(PluginCommand("twaterlvl", "Toggle display of water/magma depth.", twaterlvl, dwarfmode_hotkey)); diff --git a/plugins/jobutils.cpp b/plugins/jobutils.cpp index 34d71168f..805fc545e 100644 --- a/plugins/jobutils.cpp +++ b/plugins/jobutils.cpp @@ -45,14 +45,10 @@ static command_result job_material(Core *c, vector & parameters); static command_result job_duplicate(Core *c, vector & parameters); static command_result job_cmd(Core *c, vector & parameters); -DFhackCExport const char * plugin_name ( void ) -{ - return "jobutils"; -} +DFHACK_PLUGIN("jobutils"); DFhackCExport command_result plugin_init (Core *c, std::vector &commands) { - commands.clear(); if (!world || !ui) return CR_FAILURE; diff --git a/plugins/liquids.cpp b/plugins/liquids.cpp index c7cdf73aa..139faafcf 100644 --- a/plugins/liquids.cpp +++ b/plugins/liquids.cpp @@ -24,6 +24,26 @@ using namespace DFHack; using namespace df::enums; typedef vector coord_vec; +CommandHistory liquids_hist; + +command_result df_liquids (Core * c, vector & parameters); + +DFHACK_PLUGIN("liquids"); + +DFhackCExport command_result plugin_init ( Core * c, std::vector &commands) +{ + liquids_hist.load("liquids.history"); + commands.clear(); + commands.push_back(PluginCommand("liquids", "Place magma, water or obsidian.", df_liquids, true)); + return CR_OK; +} + +DFhackCExport command_result plugin_shutdown ( Core * c ) +{ + liquids_hist.save("liquids.history"); + return CR_OK; +} + class Brush { public: @@ -200,29 +220,6 @@ private: Core *c_; }; -CommandHistory liquids_hist; - -command_result df_liquids (Core * c, vector & parameters); - -DFhackCExport const char * plugin_name ( void ) -{ - return "liquids"; -} - -DFhackCExport command_result plugin_init ( Core * c, std::vector &commands) -{ - liquids_hist.load("liquids.history"); - commands.clear(); - commands.push_back(PluginCommand("liquids", "Place magma, water or obsidian.", df_liquids, true)); - return CR_OK; -} - -DFhackCExport command_result plugin_shutdown ( Core * c ) -{ - liquids_hist.save("liquids.history"); - return CR_OK; -} - command_result df_liquids (Core * c, vector & parameters) { int32_t x,y,z; diff --git a/plugins/mapexport/mapexport.cpp b/plugins/mapexport/mapexport.cpp index 004937fdb..2e5197718 100644 --- a/plugins/mapexport/mapexport.cpp +++ b/plugins/mapexport/mapexport.cpp @@ -25,10 +25,7 @@ typedef std::vector PlantList; command_result mapexport (Core * c, std::vector & parameters); -DFhackCExport const char * plugin_name ( void ) -{ - return "mapexport"; -} +DFHACK_PLUGIN("mapexport"); DFhackCExport command_result plugin_init ( Core * c, std::vector &commands) { diff --git a/plugins/mode.cpp b/plugins/mode.cpp index f5ec09ea8..1dfd42510 100644 --- a/plugins/mode.cpp +++ b/plugins/mode.cpp @@ -14,10 +14,7 @@ using namespace DFHack; command_result mode (Core * c, vector & parameters); -DFhackCExport const char * plugin_name ( void ) -{ - return "mode"; -} +DFHACK_PLUGIN("mode"); DFhackCExport command_result plugin_init ( Core * c, std::vector &commands) { diff --git a/plugins/plants.cpp b/plugins/plants.cpp index 88407201d..8e5d51a75 100644 --- a/plugins/plants.cpp +++ b/plugins/plants.cpp @@ -24,10 +24,7 @@ command_result df_grow (Core * c, vector & parameters); command_result df_immolate (Core * c, vector & parameters); command_result df_extirpate (Core * c, vector & parameters); -DFhackCExport const char * plugin_name ( void ) -{ - return "plants"; -} +DFHACK_PLUGIN("plants"); DFhackCExport command_result plugin_init ( Core * c, std::vector &commands) { diff --git a/plugins/probe.cpp b/plugins/probe.cpp index 2f7cbd83b..970a07350 100644 --- a/plugins/probe.cpp +++ b/plugins/probe.cpp @@ -34,10 +34,7 @@ using df::global::world; command_result df_probe (Core * c, vector & parameters); command_result df_cprobe (Core * c, vector & parameters); -DFhackCExport const char * plugin_name ( void ) -{ - return "probe"; -} +DFHACK_PLUGIN("probe"); DFhackCExport command_result plugin_init ( Core * c, std::vector &commands) { diff --git a/plugins/prospector.cpp b/plugins/prospector.cpp index a84e49157..a52ef756c 100644 --- a/plugins/prospector.cpp +++ b/plugins/prospector.cpp @@ -179,10 +179,7 @@ void printVeins(DFHack::Console & con, MatMap &mat_map, command_result prospector (Core * c, vector & parameters); -DFhackCExport const char * plugin_name ( void ) -{ - return "prospector"; -} +DFHACK_PLUGIN("prospector"); DFhackCExport command_result plugin_init ( Core * c, std::vector &commands) { diff --git a/plugins/qtplug/qtplug.cpp b/plugins/qtplug/qtplug.cpp index 02bdfa092..56bd1ecda 100644 --- a/plugins/qtplug/qtplug.cpp +++ b/plugins/qtplug/qtplug.cpp @@ -4,7 +4,7 @@ #include #include #include -#include +//#include #include #include #include @@ -25,10 +25,7 @@ static tthread::thread * QTThread; command_result runqt (Core * c, vector & parameters); -DFhackCExport const char * plugin_name ( void ) -{ - return "Qt Test"; -} +DFHACK_PLUGIN("qtplug"); DFhackCExport command_result plugin_init ( Core * c, std::vector &commands) { diff --git a/plugins/regrass.cpp b/plugins/regrass.cpp index 3e66642e6..c69457113 100644 --- a/plugins/regrass.cpp +++ b/plugins/regrass.cpp @@ -52,10 +52,7 @@ command_result df_regrass (Core * c, vector & parameters) return CR_OK; } -DFhackCExport const char *plugin_name ( void ) -{ - return "regrass"; -} +DFHACK_PLUGIN("regrass"); DFhackCExport command_result plugin_init (Core *c, std::vector &commands) { diff --git a/plugins/rename.cpp b/plugins/rename.cpp index fa4ffbc61..122671519 100644 --- a/plugins/rename.cpp +++ b/plugins/rename.cpp @@ -29,10 +29,7 @@ using df::global::world; static command_result rename(Core * c, vector & parameters); -DFhackCExport const char * plugin_name ( void ) -{ - return "rename"; -} +DFHACK_PLUGIN("rename"); DFhackCExport command_result plugin_init (Core *c, std::vector &commands) { diff --git a/plugins/reveal.cpp b/plugins/reveal.cpp index 49377123c..fd9b65c93 100644 --- a/plugins/reveal.cpp +++ b/plugins/reveal.cpp @@ -64,10 +64,7 @@ command_result revtoggle(DFHack::Core * c, std::vector & params); command_result revflood(DFHack::Core * c, std::vector & params); command_result nopause(DFHack::Core * c, std::vector & params); -DFhackCExport const char * plugin_name ( void ) -{ - return "reveal"; -} +DFHACK_PLUGIN("reveal"); DFhackCExport command_result plugin_init ( Core * c, std::vector &commands) { diff --git a/plugins/seedwatch.cpp b/plugins/seedwatch.cpp index 3d8f50e8e..d5573b400 100755 --- a/plugins/seedwatch.cpp +++ b/plugins/seedwatch.cpp @@ -245,10 +245,7 @@ command_result df_seedwatch(Core* pCore, vector& parameters) return CR_OK; } -DFhackCExport const char* plugin_name(void) -{ - return "seedwatch"; -} +DFHACK_PLUGIN("seedwatch"); DFhackCExport command_result plugin_init(Core* pCore, vector& commands) { diff --git a/plugins/server/main.cpp b/plugins/server/main.cpp index 578da8b5d..a13ae7eb8 100644 --- a/plugins/server/main.cpp +++ b/plugins/server/main.cpp @@ -13,10 +13,7 @@ using namespace DFHack; command_result server (Core * c, std::vector & parameters); // A plugins must be able to return its name. This must correspond to the filename - skeleton.plug.so or skeleton.plug.dll -DFhackCExport const char * plugin_name ( void ) -{ - return "server"; -} +DFHACK_PLUGIN("server"); // Mandatory init function. If you have some global state, create it here. DFhackCExport command_result plugin_init ( Core * c, std::vector &commands) diff --git a/plugins/showmood.cpp b/plugins/showmood.cpp index 4b31fee2e..6f5b6527c 100644 --- a/plugins/showmood.cpp +++ b/plugins/showmood.cpp @@ -266,10 +266,7 @@ command_result df_showmood (Core * c, vector & parameters) return CR_OK; } -DFhackCExport const char *plugin_name ( void ) -{ - return "showmood"; -} +DFHACK_PLUGIN("showmood"); DFhackCExport command_result plugin_init (Core *c, std::vector &commands) { diff --git a/plugins/skeleton/skeleton.cpp b/plugins/skeleton/skeleton.cpp index a5a66f35e..b2db81ff1 100644 --- a/plugins/skeleton/skeleton.cpp +++ b/plugins/skeleton/skeleton.cpp @@ -21,11 +21,9 @@ using namespace df::enums; // mostly to allow having the mandatory stuff on top of the file and commands on the bottom command_result skeleton (Core * c, std::vector & parameters); -// A plugins must be able to return its name. This must correspond to the filename - skeleton.plug.so or skeleton.plug.dll -DFhackCExport const char * plugin_name ( void ) -{ - return "skeleton"; -} +// A plugin must be able to return its name and version. +// The name string provided must correspond to the filename - skeleton.plug.so or skeleton.plug.dll in this case +DFHACK_PLUGIN("skeleton"); // Mandatory init function. If you have some global state, create it here. DFhackCExport command_result plugin_init ( Core * c, std::vector &commands) @@ -48,7 +46,7 @@ DFhackCExport command_result plugin_init ( Core * c, std::vector DFhackCExport command_result plugin_shutdown ( Core * c ) { // You *MUST* kill all threads you created before this returns. - // If everythin fails, just return CR_FAILURE. Your plugin will be + // If everything fails, just return CR_FAILURE. Your plugin will be // in a zombie state, but things won't crash. return CR_OK; } diff --git a/plugins/stockpiles.cpp b/plugins/stockpiles.cpp index 89041c56a..185973364 100644 --- a/plugins/stockpiles.cpp +++ b/plugins/stockpiles.cpp @@ -25,10 +25,7 @@ using df::building_stockpilest; static command_result copystock(Core *c, vector & parameters); static bool copystock_guard(Core *c, df::viewscreen *top); -DFhackCExport const char * plugin_name ( void ) -{ - return "stockpiles"; -} +DFHACK_PLUGIN("stockpiles"); DFhackCExport command_result plugin_init (Core *c, std::vector &commands) { diff --git a/plugins/stonesense b/plugins/stonesense index 852f0452d..37aaaca12 160000 --- a/plugins/stonesense +++ b/plugins/stonesense @@ -1 +1 @@ -Subproject commit 852f0452d13578dccd9971518a3627cc29e8abf6 +Subproject commit 37aaaca12d719ab47faedd1570158f37ad0362c7 diff --git a/plugins/tiletypes.cpp b/plugins/tiletypes.cpp index 90fbf73e4..cad4f0666 100644 --- a/plugins/tiletypes.cpp +++ b/plugins/tiletypes.cpp @@ -635,10 +635,7 @@ CommandHistory tiletypes_hist; command_result df_tiletypes (Core * c, vector & parameters); -DFhackCExport const char * plugin_name ( void ) -{ - return "tiletypes"; -} +DFHACK_PLUGIN("tiletypes"); DFhackCExport command_result plugin_init ( Core * c, std::vector &commands) { diff --git a/plugins/tubefill.cpp b/plugins/tubefill.cpp index 8d098770a..419c845b7 100644 --- a/plugins/tubefill.cpp +++ b/plugins/tubefill.cpp @@ -20,10 +20,7 @@ using df::global::world; command_result tubefill(DFHack::Core * c, std::vector & params); -DFhackCExport const char * plugin_name ( void ) -{ - return "tubefill"; -} +DFHACK_PLUGIN("tubefill"); DFhackCExport command_result plugin_init ( Core * c, std::vector &commands) { diff --git a/plugins/vdig.cpp b/plugins/vdig.cpp index ae9914afb..dd839063b 100644 --- a/plugins/vdig.cpp +++ b/plugins/vdig.cpp @@ -23,10 +23,7 @@ command_result expdig (Core * c, vector & parameters); command_result digcircle (Core *c, vector & parameters); -DFhackCExport const char * plugin_name ( void ) -{ - return "vdig"; -} +DFHACK_PLUGIN("vdig"); DFhackCExport command_result plugin_init ( Core * c, std::vector &commands) { diff --git a/plugins/versionosd.cpp b/plugins/versionosd.cpp index 5fa94c962..2aaff49cc 100644 --- a/plugins/versionosd.cpp +++ b/plugins/versionosd.cpp @@ -29,10 +29,7 @@ DFTileSurface* tiles[10]; char* file = "Cooz_curses_square_16x16.png"; Gui* gui; -DFhackCExport const char * plugin_name ( void ) -{ - return "versionosd"; -} +DFHACK_PLUGIN("versionosd"); DFTileSurface* createTile(int x, int y) { diff --git a/plugins/weather.cpp b/plugins/weather.cpp index 97285a126..6490bae17 100644 --- a/plugins/weather.cpp +++ b/plugins/weather.cpp @@ -15,10 +15,7 @@ unsigned char locked_data[25]; command_result weather (Core * c, vector & parameters); -DFhackCExport const char * plugin_name ( void ) -{ - return "weather"; -} +DFHACK_PLUGIN("weather"); DFhackCExport command_result plugin_init ( Core * c, std::vector &commands) { diff --git a/plugins/workflow.cpp b/plugins/workflow.cpp index 0d8738567..b93d6f437 100644 --- a/plugins/workflow.cpp +++ b/plugins/workflow.cpp @@ -55,10 +55,7 @@ static command_result workflow_cmd(Core *c, vector & parameters); static void init_state(Core *c); static void cleanup_state(Core *c); -DFhackCExport const char * plugin_name ( void ) -{ - return "workflow"; -} +DFHACK_PLUGIN("workflow"); DFhackCExport command_result plugin_init (Core *c, std::vector &commands) {