From 739871bc0fafe1a80f498c88447ae5c9b912b5e0 Mon Sep 17 00:00:00 2001 From: lethosor Date: Wed, 29 Jun 2022 00:03:49 -0400 Subject: [PATCH] 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);