multidwarf initial commit

develop
noah metz 2024-01-05 10:59:45 -07:00
parent 1968cffb13
commit 8c4de06999
4 changed files with 133 additions and 13 deletions

22
.gitmodules vendored

@ -1,33 +1,33 @@
[submodule "plugins/stonesense"]
path = plugins/stonesense
url = ../../DFHack/stonesense.git
url = https://github.com/DFHack/stonesense.git
[submodule "plugins/isoworld"]
path = plugins/isoworld
url = ../../DFHack/isoworld.git
url = https://github.com/DFHack/isoworld.git
[submodule "library/xml"]
path = library/xml
url = ../../DFHack/df-structures.git
url = https://github.com/DFHack/df-structures.git
[submodule "depends/clsocket"]
path = depends/clsocket
url = ../../DFHack/clsocket.git
url = https://github.com/DFHack/clsocket.git
[submodule "scripts2"]
path = scripts
url = ../../DFHack/scripts.git
url = https://github.com/DFHack/scripts.git
[submodule "depends/jsoncpp"]
path = depends/jsoncpp-sub
url = ../../DFHack/jsoncpp.git
url = https://github.com/DFHack/jsoncpp.git
[submodule "depends/xlsxio"]
path = depends/xlsxio
url = ../../DFHack/xlsxio.git
url = https://github.com/DFHack/xlsxio.git
[submodule "depends/libzip"]
path = depends/libzip
url = ../../DFHack/libzip.git
url = https://github.com/DFHack/libzip.git
[submodule "depends/libexpat"]
path = depends/libexpat
url = ../../DFHack/libexpat.git
url = https://github.com/DFHack/libexpat.git
[submodule "depends/luacov"]
path = depends/luacov
url = ../../DFHack/luacov.git
url = https://github.com/DFHack/luacov.git
[submodule "depends/googletest"]
path = depends/googletest
url = ../../google/googletest.git
url = https://github.com/google/googletest.git

@ -2,7 +2,7 @@
set -e
# Number of jobs == core count
jobs=$(grep -c ^processor /proc/cpuinfo)
jobs=$(nproc)
# Calculate absolute paths for docker to do mounts
srcdir=$(realpath "$(dirname "$(readlink -f "$0")")"/..)
@ -45,7 +45,7 @@ if ! docker run --rm -i -v "$srcdir":/src -v "$srcdir/build/win64-cross/":/src/b
-e steam_password \
--name dfhack-win \
ghcr.io/dfhack/build-env:msvc \
bash -c "cd /src/build && dfhack-configure windows 64 Release -DCMAKE_INSTALL_PREFIX=/src/build/output -DBUILD_DOCS=1 $CMAKE_EXTRA_ARGS && dfhack-make -j$jobs install" \
bash -c "chown ${builder_uid} /src /src/build && cd /src/build && dfhack-configure windows 64 Release -DCMAKE_INSTALL_PREFIX=/src/build/output -DBUILD_DOCS=1 $CMAKE_EXTRA_ARGS && dfhack-make -j$jobs install" \
; then
echo
echo "Build failed"

@ -171,6 +171,7 @@ if(BUILD_SUPPORTED)
dfhack_plugin(work-now work-now.cpp)
dfhack_plugin(xlsxreader xlsxreader.cpp LINK_LIBRARIES lua xlsxio_read_STATIC zip expat)
dfhack_plugin(zone zone.cpp LINK_LIBRARIES lua)
dfhack_plugin(multidwarf multidwarf.cpp LINK_LIBRARIES clsocket lua)
endif(BUILD_SUPPORTED)
# If you are adding a plugin that you do not intend to commit to the DFHack repo,

@ -0,0 +1,119 @@
#include <string>
#include <vector>
#include "df/world.h"
#include "Core.h"
#include "Debug.h"
#include "PluginManager.h"
#include "modules/Persistence.h"
#include "modules/World.h"
using std::string;
using std::vector;
using namespace DFHack;
DFHACK_PLUGIN("multidwarf");
DFHACK_PLUGIN_IS_ENABLED(is_enabled);
REQUIRE_GLOBAL(world);
namespace DFHack {
DBG_DECLARE(multidwarf, status, DebugCategory::LDEBUG);
DBG_DECLARE(multidwarf, onupdate, DebugCategory::LDEBUG);
DBG_DECLARE(multidwarf, command, DebugCategory::LDEBUG);
}
static command_result command_callback1(color_ostream &out, vector<string> &parameters);
DFhackCExport command_result plugin_init(color_ostream &out, std::vector<PluginCommand> &commands) {
DEBUG(status,out).print("initializing %s\n", plugin_name);
commands.push_back(PluginCommand(
"multidwarf",
"Short (~54 character) description of command.",
command_callback1));
return CR_OK;
}
DFhackCExport command_result plugin_shutdown(color_ostream &out) {
DEBUG(status,out).print("shutting down %s\n", plugin_name);
return CR_OK;
}
DFhackCExport command_result plugin_enable(color_ostream &out, bool enable) {
DEBUG(status,out).print("%s from the API\n", enable ? "enabled" : "disabled");
is_enabled = enable;
return CR_OK;
}
DFhackCExport command_result plugin_onstatechange(color_ostream &out, state_change_event event) {
switch (event) {
case SC_UNKNOWN:
DEBUG(status,out).print("game state changed: SC_UNKNOWN\n");
break;
case SC_WORLD_LOADED:
DEBUG(status,out).print("game state changed: SC_WORLD_LOADED\n");
break;
case SC_WORLD_UNLOADED:
DEBUG(status,out).print("game state changed: SC_WORLD_UNLOADED\n");
break;
case SC_MAP_LOADED:
DEBUG(status,out).print("game state changed: SC_MAP_LOADED\n");
break;
case SC_MAP_UNLOADED:
DEBUG(status,out).print("game state changed: SC_MAP_UNLOADED\n");
break;
case SC_VIEWSCREEN_CHANGED:
DEBUG(status,out).print("game state changed: SC_VIEWSCREEN_CHANGED\n");
break;
case SC_CORE_INITIALIZED:
DEBUG(status,out).print("game state changed: SC_CORE_INITIALIZED\n");
break;
case SC_BEGIN_UNLOAD:
DEBUG(status,out).print("game state changed: SC_BEGIN_UNLOAD\n");
break;
case SC_PAUSED:
DEBUG(status,out).print("game state changed: SC_PAUSED\n");
break;
case SC_UNPAUSED:
DEBUG(status,out).print("game state changed: SC_UNPAUSED\n");
break;
}
return CR_OK;
}
DFhackCExport command_result plugin_onupdate (color_ostream &out) {
DEBUG(onupdate,out).print(
"onupdate called (run 'debugfilter set info multidwarf onupdate' to stop"
" seeing these messages)\n");
return CR_OK;
}
DFhackCExport command_result plugin_save_data (color_ostream &out) {
DEBUG(status,out).print("save or unload is imminent; time to persist state\n");
return CR_OK;
}
DFhackCExport command_result plugin_load_data (color_ostream &out) {
DEBUG(status,out).print("world is loading; time to load persisted state\n");
return CR_OK;
}
static command_result command_callback1(color_ostream &out, vector<string> &parameters) {
DEBUG(command,out).print("%s command called with %zu parameters\n",
plugin_name, parameters.size());
CoreSuspender suspend;
return CR_OK;
}