From 8bb047fcc6a67aa0c0faef880aa1d7dd2ed758a0 Mon Sep 17 00:00:00 2001 From: lethosor Date: Sat, 28 May 2022 16:55:20 -0400 Subject: [PATCH 1/4] Remove Notes module Only used in a devel plugin that prints notes, and can be easily replaced with `ui.waypoints.points` --- docs/changelog.txt | 2 + library/CMakeLists.txt | 3 - library/Core.cpp | 6 - library/include/Core.h | 9 - library/include/ModuleFactory.h | 1 - library/include/modules/Notes.h | 65 ------- library/include/modules/Windows.h | 270 ------------------------------ library/modules/Notes.cpp | 53 ------ library/modules/Windows.cpp | 118 ------------- plugins/devel/CMakeLists.txt | 1 - plugins/devel/notes.cpp | 72 -------- 11 files changed, 2 insertions(+), 598 deletions(-) delete mode 100644 library/include/modules/Notes.h delete mode 100644 library/include/modules/Windows.h delete mode 100644 library/modules/Notes.cpp delete mode 100644 library/modules/Windows.cpp delete mode 100644 plugins/devel/notes.cpp diff --git a/docs/changelog.txt b/docs/changelog.txt index 2d5a5cf64..290c4ec3b 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -47,6 +47,8 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: ## Documentation ## API +- Removed ``Notes`` module (C++-only). Access ``ui.waypoints.points`` directly instead. +- Removed ``Windows`` module (C++-only) - unused. ## Lua - ``tile-material``: fix the order of declarations. The ``GetTileMat`` function now returns the material as intended (always returned nil before). Also changed the license info, with permission of the original author. diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt index 9e7bf8590..440281cf7 100644 --- a/library/CMakeLists.txt +++ b/library/CMakeLists.txt @@ -138,7 +138,6 @@ set(MODULE_HEADERS include/modules/MapCache.h include/modules/Maps.h include/modules/Materials.h - include/modules/Notes.h include/modules/Once.h include/modules/Persistence.h include/modules/Random.h @@ -165,7 +164,6 @@ set(MODULE_SOURCES modules/MapCache.cpp modules/Maps.cpp modules/Materials.cpp - modules/Notes.cpp modules/Once.cpp modules/Persistence.cpp modules/Random.cpp @@ -173,7 +171,6 @@ set(MODULE_SOURCES modules/Screen.cpp modules/Translation.cpp modules/Units.cpp - modules/Windows.cpp modules/World.cpp ) diff --git a/library/Core.cpp b/library/Core.cpp index 10f5057f3..55aa9dc55 100644 --- a/library/Core.cpp +++ b/library/Core.cpp @@ -54,7 +54,6 @@ using namespace std; #include "modules/Gui.h" #include "modules/World.h" #include "modules/Graphic.h" -#include "modules/Windows.h" #include "modules/Persistence.h" #include "RemoteServer.h" #include "RemoteTools.h" @@ -1564,7 +1563,6 @@ Core::Core() : last_local_map_ptr = NULL; last_pause_state = false; top_viewscreen = NULL; - screen_window = NULL; color_ostream::log_errors_to_stderr = true; @@ -1835,8 +1833,6 @@ bool Core::Init() cerr << "Starting DF input capture thread.\n"; // set up hotkey capture d->hotkeythread = std::thread(fHKthread, (void *) temp); - screen_window = new Windows::top_level_window(); - screen_window->addChild(new Windows::dfhack_dummy(5,10)); started = true; modstate = 0; @@ -1984,7 +1980,6 @@ int Core::TileUpdate() { if(!started) return false; - screen_window->paint(); return true; } @@ -2922,5 +2917,4 @@ TYPE * Core::get##TYPE() \ } MODULE_GETTER(Materials); -MODULE_GETTER(Notes); MODULE_GETTER(Graphic); diff --git a/library/include/Core.h b/library/include/Core.h index 1648ae113..f6acd9425 100644 --- a/library/include/Core.h +++ b/library/include/Core.h @@ -58,7 +58,6 @@ namespace DFHack class Process; class Module; class Materials; - class Notes; struct VersionInfo; class VersionInfoFactory; class PluginManager; @@ -69,10 +68,6 @@ namespace DFHack namespace Lua { namespace Core { DFHACK_EXPORT void Reset(color_ostream &out, const char *where); } } - namespace Windows - { - class df_window; - } namespace Screen { @@ -146,8 +141,6 @@ namespace DFHack /// get the materials module Materials * getMaterials(); - /// get the notes module - Notes * getNotes(); /// get the graphic module Graphic * getGraphic(); /// sets the current hotkey command @@ -193,7 +186,6 @@ namespace DFHack std::unique_ptr p; std::shared_ptr vinfo; - DFHack::Windows::df_window * screen_window; static void print(const char *format, ...) Wformat(printf,1,2); static void printerr(const char *format, ...) Wformat(printf,1,2); @@ -242,7 +234,6 @@ namespace DFHack struct { Materials * pMaterials; - Notes * pNotes; Graphic * pGraphic; } s_mods; std::vector> allModules; diff --git a/library/include/ModuleFactory.h b/library/include/ModuleFactory.h index 5c3c149a2..c99e7b328 100644 --- a/library/include/ModuleFactory.h +++ b/library/include/ModuleFactory.h @@ -33,7 +33,6 @@ namespace DFHack { class Module; std::unique_ptr createMaterials(); - std::unique_ptr createNotes(); std::unique_ptr createGraphic(); } #endif diff --git a/library/include/modules/Notes.h b/library/include/modules/Notes.h deleted file mode 100644 index 14bb9db84..000000000 --- a/library/include/modules/Notes.h +++ /dev/null @@ -1,65 +0,0 @@ -#pragma once -#ifndef CL_MOD_NOTES -#define CL_MOD_NOTES -/** - * \defgroup grp_notes In game notes (and routes) - * @ingroup grp_notes - */ -#include "Export.h" -#include "Module.h" - -#include -#include - -#ifdef __cplusplus -namespace DFHack -{ -#endif - /** - * Game's structure for a note. - * \ingroup grp_notes - */ - struct t_note - { - // First note created has id 0, second has id 1, etc. Not affected - // by lower id notes being deleted. - uint32_t id; // 0 - uint8_t symbol; // 4 - uint8_t unk1; // alignment padding? - uint16_t foreground; // 6 - uint16_t background; // 8 - uint16_t unk2; // alignment padding? - - std::string name; // C - std::string text; // 10 - - uint16_t x; // 14 - uint16_t y; // 16 - uint16_t z; // 18 - - // Is there more? - }; - -#ifdef __cplusplus - - /** - * The notes module - allows reading DF in-game notes - * \ingroup grp_modules - * \ingroup grp_notes - */ - class DFHACK_EXPORT Notes : public Module - { - public: - Notes(); - ~Notes(){}; - bool Finish() - { - return true; - } - std::vector* notes; - }; - -} -#endif // __cplusplus - -#endif diff --git a/library/include/modules/Windows.h b/library/include/modules/Windows.h deleted file mode 100644 index f9b282cf3..000000000 --- a/library/include/modules/Windows.h +++ /dev/null @@ -1,270 +0,0 @@ -/* -https://github.com/peterix/dfhack -Copyright (c) 2009-2012 Petr Mrázek (peterix@gmail.com) - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any -damages arising from the use of this software. - -Permission is granted to anyone to use this software for any -purpose, including commercial applications, and to alter it and -redistribute it freely, subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must -not claim that you wrote the original software. If you use this -software in a product, an acknowledgment in the product documentation -would be appreciated but is not required. - -2. Altered source versions must be plainly marked as such, and -must not be misrepresented as being the original software. - -3. This notice may not be removed or altered from any source -distribution. -*/ - -#pragma once -#include "Export.h" -#include - -namespace DFHack -{ -namespace Windows -{ - /* - * DF window stuffs - */ - enum df_color - { - black, - blue, - green, - cyan, - red, - magenta, - brown, - lgray, - dgray, - lblue, - lgreen, - lcyan, - lred, - lmagenta, - yellow, - white - // maybe add transparency? - }; - - // The tile format DF uses internally - struct df_screentile - { - uint8_t symbol; - uint8_t foreground; ///< df_color - uint8_t background; ///< df_color - uint8_t bright; - }; - - - // our silly painter things and window things follow. - class df_window; - struct df_tilebuf - { - df_screentile * data; - unsigned int width; - unsigned int height; - }; - - DFHACK_EXPORT df_screentile *getScreenBuffer(); - - class DFHACK_EXPORT painter - { - friend class df_window; - public: - df_screentile* get(unsigned int x, unsigned int y) - { - if(x >= width || y >= height) - return 0; - return &buffer[x*height + y]; - }; - bool set(unsigned int x, unsigned int y, df_screentile tile ) - { - if(x >= width || y >= height) - return false; - buffer[x*height + y] = tile; - return true; - } - df_color foreground (df_color change = (df_color) -1) - { - if(change != -1) - current_foreground = change; - return current_foreground; - } - df_color background (df_color change = (df_color) -1) - { - if(change != -1) - current_background = change; - return current_background; - } - void bright (bool change) - { - current_bright = change; - } - bool bright () - { - return current_bright; - } - void printStr(std::string & str, bool wrap = false) - { - for ( auto iter = str.begin(); iter != str.end(); iter++) - { - auto elem = *iter; - if(cursor_y >= (int)height) - break; - if(wrap) - { - if(cursor_x >= (int)width) - cursor_x = wrap_column; - } - df_screentile & tile = buffer[cursor_x * height + cursor_y]; - tile.symbol = elem; - tile.foreground = current_foreground; - tile.background = current_background; - tile.bright = current_bright; - cursor_x++; - } - } - void set_wrap (int new_column) - { - wrap_column = new_column; - } - void gotoxy(unsigned int x, unsigned int y) - { - cursor_x = x; - cursor_y = y; - } - void reset() - { - cursor_x = 0; - cursor_y = 0; - current_background = black; - current_foreground = white; - current_bright = false; - wrap_column = 0; - } - private: - painter (df_window * orig, df_screentile * buf, unsigned int width, unsigned int height) - { - origin = orig; - this->width = width; - this->height = height; - this->buffer = buf; - reset(); - } - df_window* origin; - unsigned int width; - unsigned int height; - df_screentile* buffer; - // current paint cursor position - int cursor_x; - int cursor_y; - int wrap_column; - // current foreground color - df_color current_foreground; - // current background color - df_color current_background; - // make bright? - bool current_bright; - }; - - class DFHACK_EXPORT df_window - { - friend class painter; - public: - df_window(int x, int y, unsigned int width, unsigned int height); - virtual ~df_window(); - virtual bool move (int left_, int top_, unsigned int width_, unsigned int height_) = 0; - virtual void paint () = 0; - virtual painter * lock(); - bool unlock (painter * painter); - virtual bool addChild(df_window *); - virtual df_tilebuf getBuffer() = 0; - public: - df_screentile* buffer; - unsigned int width; - unsigned int height; - protected: - df_window * parent; - std::vector children; - int left; - int top; - // FIXME: FAKE - bool locked; - painter * current_painter; - }; - - class DFHACK_EXPORT top_level_window : public df_window - { - public: - top_level_window(); - virtual bool move (int left_, int top_, unsigned int width_, unsigned int height_); - virtual void paint (); - virtual painter * lock(); - virtual df_tilebuf getBuffer(); - }; - class DFHACK_EXPORT buffered_window : public df_window - { - public: - buffered_window(int x, int y, unsigned int width, unsigned int height):df_window(x,y,width, height) - { - buffer = new df_screentile[width*height]; - }; - virtual ~buffered_window() - { - delete buffer; - } - virtual void blit_to_parent () - { - df_tilebuf par = parent->getBuffer(); - for(unsigned xi = 0; xi < width; xi++) - { - for(unsigned yi = 0; yi < height; yi++) - { - unsigned parx = left + xi; - unsigned pary = top + yi; - if(pary >= par.height) continue; - if(parx >= par.width) continue; - par.data[parx * par.height + pary] = buffer[xi * height + yi]; - } - } - } - virtual df_tilebuf getBuffer() - { - df_tilebuf buf; - buf.data = buffer; - buf.width = width; - buf.height = height; - return buf; - }; - }; - class DFHACK_EXPORT dfhack_dummy : public buffered_window - { - public: - dfhack_dummy(int x, int y):buffered_window(x,y,6,1){}; - virtual bool move (int left_, int top_, unsigned int width_, unsigned int height_) - { - top = top_; - left = left_; - return true; - } - virtual void paint () - { - painter * p = lock(); - p->bright(true); - p->background(black); - p->foreground(white); - std::string dfhack = "DFHack"; - p->printStr(dfhack); - blit_to_parent(); - } - }; -} -} diff --git a/library/modules/Notes.cpp b/library/modules/Notes.cpp deleted file mode 100644 index 04fb59e4d..000000000 --- a/library/modules/Notes.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/* -www.sourceforge.net/projects/dfhack -Copyright (c) 2009 Petr Mrázek (peterix), Kenneth Ferland (Impaler[WrG]), dorf - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any -damages arising from the use of this software. - -Permission is granted to anyone to use this software for any -purpose, including commercial applications, and to alter it and -redistribute it freely, subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must -not claim that you wrote the original software. If you use this -software in a product, an acknowledgment in the product documentation -would be appreciated but is not required. - -2. Altered source versions must be plainly marked as such, and -must not be misrepresented as being the original software. - -3. This notice may not be removed or altered from any source -distribution. -*/ - -#include "Internal.h" - -#include -#include -#include -using namespace std; - -#include "VersionInfo.h" -#include "Types.h" -#include "Error.h" -#include "MemAccess.h" -#include "MiscUtils.h" -#include "ModuleFactory.h" -#include "Core.h" -#include "modules/Notes.h" -#include -#include "df/ui.h" -using namespace DFHack; - -std::unique_ptr DFHack::createNotes() -{ - return dts::make_unique(); -} - -// FIXME: not even a wrapper now -Notes::Notes() -{ - notes = (std::vector*) &df::global::ui->waypoints.points; -} diff --git a/library/modules/Windows.cpp b/library/modules/Windows.cpp deleted file mode 100644 index af5368e50..000000000 --- a/library/modules/Windows.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/* -https://github.com/peterix/dfhack -Copyright (c) 2009-2012 Petr Mrázek (peterix@gmail.com) - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any -damages arising from the use of this software. - -Permission is granted to anyone to use this software for any -purpose, including commercial applications, and to alter it and -redistribute it freely, subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must -not claim that you wrote the original software. If you use this -software in a product, an acknowledgment in the product documentation -would be appreciated but is not required. - -2. Altered source versions must be plainly marked as such, and -must not be misrepresented as being the original software. - -3. This notice may not be removed or altered from any source -distribution. -*/ - -#include "Export.h" -#include "Module.h" -#include "BitArray.h" -#include - -#include "DataDefs.h" -#include "df/init.h" -#include "df/ui.h" -#include -#include "modules/Windows.h" - -using namespace DFHack; -using df::global::gps; - -Windows::df_screentile *Windows::getScreenBuffer() -{ - if (!gps) return NULL; - return (df_screentile *) gps->screen; -} - -Windows::df_window::df_window(int x, int y, unsigned int width, unsigned int height) -:buffer(0), width(width), height(height), parent(0), left(x), top(y), current_painter(NULL) -{ - buffer = 0; -}; -Windows::df_window::~df_window() -{ - for(auto iter = children.begin();iter != children.end();iter++) - { - delete *iter; - } - children.clear(); -}; -Windows::painter * Windows::df_window::lock() -{ - locked = true; - current_painter = new Windows::painter(this,buffer,width, height); - return current_painter; -}; - -bool Windows::df_window::addChild( df_window * child) -{ - children.push_back(child); - child->parent = this; - return true; -} - -bool Windows::df_window::unlock (painter * painter) -{ - if(current_painter == painter) - { - delete current_painter; - current_painter = 0; - locked = false; - return true; - } - return false; -} - -Windows::top_level_window::top_level_window() : df_window(0,0,gps ? gps->dimx : 80,gps ? gps->dimy : 25) -{ - buffer = 0; -} - -bool Windows::top_level_window::move (int left_, int top_, unsigned int width_, unsigned int height_) -{ - width = width_; - height = height_; - // what if we are painting already? Is that possible? - return true; -}; - -Windows::painter * Windows::top_level_window::lock() -{ - buffer = getScreenBuffer(); - return df_window::lock(); -} - -void Windows::top_level_window::paint () -{ - for(auto iter = children.begin();iter != children.end();iter++) - { - (*iter)->paint(); - } -}; - -Windows::df_tilebuf Windows::top_level_window::getBuffer() -{ - df_tilebuf buf; - buf.data = getScreenBuffer(); - buf.height = df::global::gps->dimy; - buf.width = df::global::gps->dimx; - return buf; -} diff --git a/plugins/devel/CMakeLists.txt b/plugins/devel/CMakeLists.txt index 6d15f09dd..d1b84614f 100644 --- a/plugins/devel/CMakeLists.txt +++ b/plugins/devel/CMakeLists.txt @@ -13,7 +13,6 @@ dfhack_plugin(eventExample eventExample.cpp) dfhack_plugin(frozen frozen.cpp) dfhack_plugin(kittens kittens.cpp LINK_LIBRARIES ${CMAKE_THREAD_LIBS_INIT}) dfhack_plugin(memview memview.cpp memutils.cpp LINK_LIBRARIES lua) -dfhack_plugin(notes notes.cpp) dfhack_plugin(onceExample onceExample.cpp) dfhack_plugin(renderer-msg renderer-msg.cpp) dfhack_plugin(rprobe rprobe.cpp) diff --git a/plugins/devel/notes.cpp b/plugins/devel/notes.cpp deleted file mode 100644 index 33b768af7..000000000 --- a/plugins/devel/notes.cpp +++ /dev/null @@ -1,72 +0,0 @@ -#include "Core.h" -#include -#include -#include -#include -#include -#include - -using std::vector; -using std::string; -using namespace DFHack; - -command_result df_notes (color_ostream &out, vector & parameters); - -DFHACK_PLUGIN("notes"); - -DFhackCExport command_result plugin_init ( color_ostream &out, std::vector &commands) -{ - commands.push_back(PluginCommand("dumpnotes", - "Dumps in-game notes", - df_notes)); - return CR_OK; -} - -DFhackCExport command_result plugin_shutdown ( color_ostream &out ) -{ - return CR_OK; -} - -command_result df_notes (color_ostream &con, vector & parameters) -{ - CoreSuspender suspend; - - DFHack::Notes * note_mod = Core::getInstance().getNotes(); - std::vector* note_list = note_mod->notes; - - if (note_list == NULL) - { - con.printerr("Notes are not supported under this version of DF.\n"); - return CR_OK; - } - - if (note_list->empty()) - { - con << "There are no notes." << std::endl; - return CR_OK; - } - - - for (size_t i = 0; i < note_list->size(); i++) - { - t_note* note = (*note_list)[i]; - - con.print("Note %p at: %d/%d/%d\n",note, note->x, note->y, note->z); - con.print("Note id: %d\n", note->id); - con.print("Note symbol: '%c'\n", note->symbol); - - if (note->name.length() > 0) - con << "Note name: " << (note->name) << std::endl; - if (note->text.length() > 0) - con << "Note text: " << (note->text) << std::endl; - - if (note->unk1 != 0) - con.print("unk1: %x\n", note->unk1); - if (note->unk2 != 0) - con.print("unk2: %x\n", note->unk2); - - con << std::endl; - } - - return CR_OK; -} From 4c7caa2658a29c77841bb7fa401ce58e6b000ae8 Mon Sep 17 00:00:00 2001 From: lethosor Date: Sat, 4 Jun 2022 12:57:18 -0400 Subject: [PATCH 2/4] Remove unneeded dependencies on modules/Graphic.h --- docs/changelog.txt | 1 + library/CMakeLists.txt | 2 - library/Core.cpp | 1 - library/PlugLoad-windows.cpp | 1 - library/include/DFHack.h | 1 - library/include/Hooks.h | 1 - library/include/modules/Engravings.h | 63 ---------------------- library/modules/Engravings.cpp | 78 ---------------------------- 8 files changed, 1 insertion(+), 147 deletions(-) delete mode 100644 library/include/modules/Engravings.h delete mode 100644 library/modules/Engravings.cpp diff --git a/docs/changelog.txt b/docs/changelog.txt index 290c4ec3b..8f663d9bc 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -47,6 +47,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: ## Documentation ## API +- Removed ``Engravings`` module (C++-only). Access ``world.engravings`` directly instead. - Removed ``Notes`` module (C++-only). Access ``ui.waypoints.points`` directly instead. - Removed ``Windows`` module (C++-only) - unused. diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt index 440281cf7..c9e9cd844 100644 --- a/library/CMakeLists.txt +++ b/library/CMakeLists.txt @@ -126,7 +126,6 @@ set(MODULE_HEADERS include/modules/Burrows.h include/modules/Constructions.h include/modules/Designations.h - include/modules/Engravings.h include/modules/EventManager.h include/modules/Filesystem.h include/modules/Graphic.h @@ -153,7 +152,6 @@ set(MODULE_SOURCES modules/Burrows.cpp modules/Constructions.cpp modules/Designations.cpp - modules/Engravings.cpp modules/EventManager.cpp modules/Filesystem.cpp modules/Graphic.cpp diff --git a/library/Core.cpp b/library/Core.cpp index 55aa9dc55..cfb029d57 100644 --- a/library/Core.cpp +++ b/library/Core.cpp @@ -53,7 +53,6 @@ using namespace std; #include "modules/Filesystem.h" #include "modules/Gui.h" #include "modules/World.h" -#include "modules/Graphic.h" #include "modules/Persistence.h" #include "RemoteServer.h" #include "RemoteTools.h" diff --git a/library/PlugLoad-windows.cpp b/library/PlugLoad-windows.cpp index 96c2e900a..848d25f50 100644 --- a/library/PlugLoad-windows.cpp +++ b/library/PlugLoad-windows.cpp @@ -35,7 +35,6 @@ distribution. #include #include "tinythread.h" -#include "modules/Graphic.h" #include "../plugins/uicommon.h" /* diff --git a/library/include/DFHack.h b/library/include/DFHack.h index 8a094cf86..0a5183adc 100644 --- a/library/include/DFHack.h +++ b/library/include/DFHack.h @@ -54,7 +54,6 @@ distribution. // DFHack modules #include "modules/Buildings.h" -#include "modules/Engravings.h" #include "modules/Materials.h" #include "modules/Constructions.h" #include "modules/Units.h" diff --git a/library/include/Hooks.h b/library/include/Hooks.h index f5ef7079c..7a266e92c 100644 --- a/library/include/Hooks.h +++ b/library/include/Hooks.h @@ -47,7 +47,6 @@ namespace SDL // these functions are here because they call into DFHack::Core and therefore need to // be declared as friend functions/known #ifdef _DARWIN -#include "modules/Graphic.h" DFhackCExport int DFH_SDL_NumJoysticks(void); DFhackCExport void DFH_SDL_Quit(void); DFhackCExport int DFH_SDL_PollEvent(SDL::Event* event); diff --git a/library/include/modules/Engravings.h b/library/include/modules/Engravings.h deleted file mode 100644 index bf30c62a8..000000000 --- a/library/include/modules/Engravings.h +++ /dev/null @@ -1,63 +0,0 @@ -/* -https://github.com/peterix/dfhack -Copyright (c) 2009-2012 Petr Mrázek (peterix@gmail.com) - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any -damages arising from the use of this software. - -Permission is granted to anyone to use this software for any -purpose, including commercial applications, and to alter it and -redistribute it freely, subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must -not claim that you wrote the original software. If you use this -software in a product, an acknowledgment in the product documentation -would be appreciated but is not required. - -2. Altered source versions must be plainly marked as such, and -must not be misrepresented as being the original software. - -3. This notice may not be removed or altered from any source -distribution. -*/ - -#pragma once -#ifndef CL_MOD_ENGRAVINGS -#define CL_MOD_ENGRAVINGS -/* -* DF engravings -*/ -#include "Export.h" -#include "DataDefs.h" -#include "df/engraving.h" -/** - * \defgroup grp_engraving Engraving module parts - * @ingroup grp_modules - */ -namespace DFHack -{ -namespace Engravings -{ -// "Simplified" copy of engraving -struct t_engraving { - int32_t artist; - int32_t masterpiece_event; - int32_t skill_rating; - df::coord pos; - df::engraving_flags flags; - int8_t tile; - int32_t art_id; - int16_t art_subid; - df::item_quality quality; - // Pointer to original object, in case you want to modify it - df::engraving *origin; -}; - -DFHACK_EXPORT bool isValid(); -DFHACK_EXPORT uint32_t getCount(); -DFHACK_EXPORT bool copyEngraving (const int32_t index, t_engraving &out); -DFHACK_EXPORT df::engraving * getEngraving (const int32_t index); -} -} -#endif diff --git a/library/modules/Engravings.cpp b/library/modules/Engravings.cpp deleted file mode 100644 index c2e0e6fce..000000000 --- a/library/modules/Engravings.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* -https://github.com/peterix/dfhack -Copyright (c) 2009-2012 Petr Mrázek (peterix@gmail.com) - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any -damages arising from the use of this software. - -Permission is granted to anyone to use this software for any -purpose, including commercial applications, and to alter it and -redistribute it freely, subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must -not claim that you wrote the original software. If you use this -software in a product, an acknowledgment in the product documentation -would be appreciated but is not required. - -2. Altered source versions must be plainly marked as such, and -must not be misrepresented as being the original software. - -3. This notice may not be removed or altered from any source -distribution. -*/ - - -#include "Internal.h" - -#include -#include -#include -using namespace std; - -#include "VersionInfo.h" -#include "MemAccess.h" -#include "Types.h" -#include "Core.h" - -#include "modules/Engravings.h" -#include "df/world.h" - -using namespace DFHack; -using df::global::world; - -bool Engravings::isValid() -{ - return (world != NULL); -} - -uint32_t Engravings::getCount() -{ - return world->engravings.size(); -} - -df::engraving * Engravings::getEngraving(int index) -{ - if (uint32_t(index) >= getCount()) - return NULL; - return world->engravings[index]; -} - -bool Engravings::copyEngraving(const int32_t index, t_engraving &out) -{ - if (uint32_t(index) >= getCount()) - return false; - - out.origin = world->engravings[index]; - - out.artist = out.origin->artist; - out.masterpiece_event = out.origin->masterpiece_event; - out.skill_rating = out.origin->skill_rating; - out.pos = out.origin->pos; - out.flags = out.origin->flags; - out.tile = out.origin->tile; - out.art_id = out.origin->art_id; - out.art_subid = out.origin->art_subid; - out.quality = out.origin->quality; - return true; -} From 1147add5207c730c2b162020347518144b451ddf Mon Sep 17 00:00:00 2001 From: lethosor Date: Tue, 28 Jun 2022 23:44:34 -0400 Subject: [PATCH 3/4] Constructions module: remove some old/unused functions/types --- docs/changelog.txt | 1 + library/include/modules/Constructions.h | 16 ------------ library/modules/Constructions.cpp | 33 ------------------------- 3 files changed, 1 insertion(+), 49 deletions(-) diff --git a/docs/changelog.txt b/docs/changelog.txt index 8f663d9bc..a06629f62 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -50,6 +50,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: - Removed ``Engravings`` module (C++-only). Access ``world.engravings`` directly instead. - Removed ``Notes`` module (C++-only). Access ``ui.waypoints.points`` directly instead. - Removed ``Windows`` module (C++-only) - unused. +- ``Constructions`` module (C++-only): removed ``t_construction``, ``isValid()``, ``getCount()``, ``getConstruction()``, and ``copyConstruction()``. Access ``world.constructions`` directly instead. ## Lua - ``tile-material``: fix the order of declarations. The ``GetTileMat`` function now returns the material as intended (always returned nil before). Also changed the license info, with permission of the original author. diff --git a/library/include/modules/Constructions.h b/library/include/modules/Constructions.h index 3831d4bb1..c7a1c048b 100644 --- a/library/include/modules/Constructions.h +++ b/library/include/modules/Constructions.h @@ -42,23 +42,7 @@ namespace DFHack { namespace Constructions { -// "Simplified" copy of construction -struct t_construction { - df::coord pos; - df::item_type item_type; - int16_t item_subtype; - int16_t mat_type; - int32_t mat_index; - df::construction_flags flags; - int16_t original_tile; - // Pointer to original object, in case you want to modify it - df::construction *origin; -}; -DFHACK_EXPORT bool isValid(); -DFHACK_EXPORT uint32_t getCount(); -DFHACK_EXPORT bool copyConstruction (const int32_t index, t_construction &out); -DFHACK_EXPORT df::construction * getConstruction (const int32_t index); DFHACK_EXPORT df::construction * findAtTile(df::coord pos); DFHACK_EXPORT bool designateNew(df::coord pos, df::construction_type type, diff --git a/library/modules/Constructions.cpp b/library/modules/Constructions.cpp index 9cec2eab9..5fc632500 100644 --- a/library/modules/Constructions.cpp +++ b/library/modules/Constructions.cpp @@ -51,22 +51,6 @@ using namespace DFHack; using namespace df::enums; using df::global::world; -bool Constructions::isValid() -{ - return (world != NULL); -} - -uint32_t Constructions::getCount() -{ - return world->constructions.size(); -} - -df::construction * Constructions::getConstruction(const int32_t index) -{ - if (uint32_t(index) >= getCount()) - return NULL; - return world->constructions[index]; -} df::construction * Constructions::findAtTile(df::coord pos) { @@ -77,23 +61,6 @@ df::construction * Constructions::findAtTile(df::coord pos) return NULL; } -bool Constructions::copyConstruction(const int32_t index, t_construction &out) -{ - if (uint32_t(index) >= getCount()) - return false; - - out.origin = world->constructions[index]; - - out.pos = out.origin->pos; - out.item_type = out.origin->item_type; - out.item_subtype = out.origin->item_subtype; - out.mat_type = out.origin->mat_type; - out.mat_index = out.origin->mat_index; - out.flags = out.origin->flags; - out.original_tile = out.origin->original_tile; - return true; -} - bool Constructions::designateNew(df::coord pos, df::construction_type type, df::item_type item, int mat_index) { From 739871bc0fafe1a80f498c88447ae5c9b912b5e0 Mon Sep 17 00:00:00 2001 From: lethosor Date: Wed, 29 Jun 2022 00:03:49 -0400 Subject: [PATCH 4/4] Remove Hooks-egg.cpp and related code and configuration options --- CMakeLists.txt | 2 - docs/changelog.txt | 1 + library/CMakeLists.txt | 42 ++++--------------- library/Core.cpp | 7 ---- library/Hooks-egg.cpp | 92 ----------------------------------------- library/include/Core.h | 7 ---- library/include/Hooks.h | 18 -------- 7 files changed, 10 insertions(+), 159 deletions(-) delete mode 100644 library/Hooks-egg.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 8271840e6..d01d105c5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -206,11 +206,9 @@ set(DFHACK_BUILD_ID "" CACHE STRING "Build ID (should be specified on command li if(UNIX) # put the lib into DF/hack set(DFHACK_LIBRARY_DESTINATION hack) - set(DFHACK_EGGY_DESTINATION libs) else() # windows is crap, therefore we can't do nice things with it. leave the libs on a nasty pile... set(DFHACK_LIBRARY_DESTINATION .) - set(DFHACK_EGGY_DESTINATION .) endif() # external tools will be installed here: diff --git a/docs/changelog.txt b/docs/changelog.txt index a06629f62..9ff01740f 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -47,6 +47,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: ## Documentation ## API +- Removed "egg" ("eggy") hook support (Linux only). The only remaining method of hooking into DF is by interposing SDL calls, which has been the method used by all binary releases of DFHack. - Removed ``Engravings`` module (C++-only). Access ``world.engravings`` directly instead. - Removed ``Notes`` module (C++-only). Access ``ui.waypoints.points`` directly instead. - Removed ``Windows`` module (C++-only) - unused. diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt index c9e9cd844..95a8e610a 100644 --- a/library/CMakeLists.txt +++ b/library/CMakeLists.txt @@ -114,13 +114,6 @@ set(MAIN_SOURCES_DARWIN Process-darwin.cpp ) -set(MAIN_SOURCES_LINUX_EGGY - ${CONSOLE_SOURCES} - Hooks-egg.cpp - PlugLoad-linux.cpp - Process-linux.cpp -) - set(MODULE_HEADERS include/modules/Buildings.h include/modules/Burrows.h @@ -206,10 +199,7 @@ list(APPEND PROJECT_SOURCES ${MAIN_SOURCES}) list(APPEND PROJECT_SOURCES ${MODULE_SOURCES}) if(UNIX) - option(BUILD_EGGY "Make DFHack strangely egg-shaped." OFF) - if(BUILD_EGGY) - list(APPEND PROJECT_SOURCES ${MAIN_SOURCES_LINUX_EGGY}) - elseif(APPLE) + if(APPLE) list(APPEND PROJECT_SOURCES ${MAIN_SOURCES_DARWIN}) else() list(APPEND PROJECT_SOURCES ${MAIN_SOURCES_LINUX}) @@ -371,15 +361,9 @@ add_executable(dfhack-run dfhack-run.cpp) add_executable(binpatch binpatch.cpp) target_link_libraries(binpatch dfhack-md5) -if(BUILD_EGGY) - set_target_properties(dfhack PROPERTIES OUTPUT_NAME "egg" ) -else() - if(WIN32) - set_target_properties(dfhack PROPERTIES OUTPUT_NAME "SDL" ) - endif() -endif() - if(WIN32) + # name the resulting library SDL.dll on Windows + set_target_properties(dfhack PROPERTIES OUTPUT_NAME "SDL" ) set_target_properties(dfhack PROPERTIES COMPILE_FLAGS "/FI\"Export.h\"" ) set_target_properties(dfhack-client PROPERTIES COMPILE_FLAGS "/FI\"Export.h\"" ) else() @@ -434,23 +418,15 @@ if(UNIX) DESTINATION .) endif() else() - if(NOT BUILD_EGGY) - # On windows, copy the renamed SDL so DF can still run. - install(PROGRAMS ${dfhack_SOURCE_DIR}/package/windows/win${DFHACK_BUILD_ARCH}/SDLreal.dll - DESTINATION ${DFHACK_LIBRARY_DESTINATION}) - endif() + # On windows, copy the renamed SDL so DF can still run. + install(PROGRAMS ${dfhack_SOURCE_DIR}/package/windows/win${DFHACK_BUILD_ARCH}/SDLreal.dll + DESTINATION ${DFHACK_LIBRARY_DESTINATION}) endif() # install the main lib -if(NOT BUILD_EGGY) - install(TARGETS dfhack - LIBRARY DESTINATION ${DFHACK_LIBRARY_DESTINATION} - RUNTIME DESTINATION ${DFHACK_LIBRARY_DESTINATION}) -else() - install(TARGETS dfhack - LIBRARY DESTINATION ${DFHACK_EGGY_DESTINATION} - RUNTIME DESTINATION ${DFHACK_EGGY_DESTINATION}) -endif() +install(TARGETS dfhack + LIBRARY DESTINATION ${DFHACK_LIBRARY_DESTINATION} + RUNTIME DESTINATION ${DFHACK_LIBRARY_DESTINATION}) # install the offset file install(FILES xml/symbols.xml diff --git a/library/Core.cpp b/library/Core.cpp index cfb029d57..941d1bebf 100644 --- a/library/Core.cpp +++ b/library/Core.cpp @@ -1975,13 +1975,6 @@ bool Core::isSuspended(void) return ownerThread.load() == std::this_thread::get_id(); } -int Core::TileUpdate() -{ - if(!started) - return false; - return true; -} - void Core::doUpdate(color_ostream &out, bool first_update) { Lua::Core::Reset(out, "DF code execution"); diff --git a/library/Hooks-egg.cpp b/library/Hooks-egg.cpp deleted file mode 100644 index c98cf5da2..000000000 --- a/library/Hooks-egg.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/* -https://github.com/peterix/dfhack -Copyright (c) 2009-2012 Petr Mrázek (peterix@gmail.com) - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any -damages arising from the use of this software. - -Permission is granted to anyone to use this software for any -purpose, including commercial applications, and to alter it and -redistribute it freely, subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must -not claim that you wrote the original software. If you use this -software in a product, an acknowledgment in the product documentation -would be appreciated but is not required. - -2. Altered source versions must be plainly marked as such, and -must not be misrepresented as being the original software. - -3. This notice may not be removed or altered from any source -distribution. -*/ -#include -#include -#include -#include -#include -#include -#include - -#include "Core.h" -#include "Hooks.h" -#include - -// hook - called before rendering -DFhackCExport int egg_init(void) -{ - // reroute stderr - freopen("stderr.log", "w", stderr); - // we don't reroute stdout until we figure out if this should be done at all - // See: Console-linux.cpp - fprintf(stderr,"dfhack: hooking successful\n"); - return true; -} - -// hook - called before rendering -DFhackCExport int egg_shutdown(void) -{ - DFHack::Core & c = DFHack::Core::getInstance(); - return c.Shutdown(); -} - -// hook - called for each game tick (or more often) -DFhackCExport int egg_tick(void) -{ - DFHack::Core & c = DFHack::Core::getInstance(); - return c.Update(); -} -// hook - called before rendering -DFhackCExport int egg_prerender(void) -{ - DFHack::Core & c = DFHack::Core::getInstance(); - return c.TileUpdate(); -} - -// hook - called for each SDL event, returns 0 when the event has been consumed. 1 otherwise -DFhackCExport int egg_sdl_event(SDL::Event* event) -{ - // if the event is valid, intercept - if( event != 0 ) - { - DFHack::Core & c = DFHack::Core::getInstance(); - return c.DFH_SDL_Event(event); - } - return true; -} - -// return this if you want to kill the event. -const int curses_error = -1; -// hook - ncurses event, -1 signifies error. -DFhackCExport int egg_curses_event(int orig_return) -{ - /* - if(orig_return != -1) - { - DFHack::Core & c = DFHack::Core::getInstance(); - int out; - return c.ncurses_wgetch(orig_return,); - }*/ - return orig_return; -} diff --git a/library/include/Core.h b/library/include/Core.h index f6acd9425..531d1b581 100644 --- a/library/include/Core.h +++ b/library/include/Core.h @@ -121,12 +121,6 @@ namespace DFHack friend int ::SDL_Init(uint32_t flags); friend int ::wgetch(WINDOW * w); #endif - friend int ::egg_init(void); - friend int ::egg_shutdown(void); - friend int ::egg_tick(void); - friend int ::egg_prerender(void); - friend int ::egg_sdl_event(SDL::Event* event); - friend int ::egg_curses_event(int orig_return); public: /// Get the single Core instance or make one. static Core& getInstance() @@ -205,7 +199,6 @@ namespace DFHack bool Init(); int Update (void); - int TileUpdate (void); int Shutdown (void); int DFH_SDL_Event(SDL::Event* event); bool ncurses_wgetch(int in, int & out); diff --git a/library/include/Hooks.h b/library/include/Hooks.h index 7a266e92c..d17b96acf 100644 --- a/library/include/Hooks.h +++ b/library/include/Hooks.h @@ -74,21 +74,3 @@ DFhackCExport void * SDL_GetVideoSurface(void); DFhackCExport int SDL_SemWait(vPtr sem); DFhackCExport int SDL_SemPost(vPtr sem); - -// hook - called early from DF's main() -DFhackCExport int egg_init(void); - -// hook - called before rendering -DFhackCExport int egg_shutdown(void); - -// hook - called for each game tick (or more often) -DFhackCExport int egg_tick(void); - -// hook - called before rendering -DFhackCExport int egg_prerender(void); - -// hook - called for each SDL event, can filter both the event and the return value -DFhackCExport int egg_sdl_event(SDL::Event* event); - -// hook - ncurses event. return -1 to consume -DFhackCExport int egg_curses_event(int orig_return);