Merge branch 'rm-old-modules' into develop

develop
lethosor 2022-07-12 11:23:10 -04:00
commit 4cdb0ff138
No known key found for this signature in database
GPG Key ID: 76A269552F4F58C1
20 changed files with 14 additions and 953 deletions

@ -206,11 +206,9 @@ set(DFHACK_BUILD_ID "" CACHE STRING "Build ID (should be specified on command li
if(UNIX) if(UNIX)
# put the lib into DF/hack # put the lib into DF/hack
set(DFHACK_LIBRARY_DESTINATION hack) set(DFHACK_LIBRARY_DESTINATION hack)
set(DFHACK_EGGY_DESTINATION libs)
else() else()
# windows is crap, therefore we can't do nice things with it. leave the libs on a nasty pile... # 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_LIBRARY_DESTINATION .)
set(DFHACK_EGGY_DESTINATION .)
endif() endif()
# external tools will be installed here: # external tools will be installed here:

@ -51,6 +51,11 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
## Documentation ## Documentation
## API ## 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.
- ``Constructions`` module (C++-only): removed ``t_construction``, ``isValid()``, ``getCount()``, ``getConstruction()``, and ``copyConstruction()``. Access ``world.constructions`` directly instead.
## Lua ## 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. - ``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.

@ -114,19 +114,11 @@ set(MAIN_SOURCES_DARWIN
Process-darwin.cpp Process-darwin.cpp
) )
set(MAIN_SOURCES_LINUX_EGGY
${CONSOLE_SOURCES}
Hooks-egg.cpp
PlugLoad-linux.cpp
Process-linux.cpp
)
set(MODULE_HEADERS set(MODULE_HEADERS
include/modules/Buildings.h include/modules/Buildings.h
include/modules/Burrows.h include/modules/Burrows.h
include/modules/Constructions.h include/modules/Constructions.h
include/modules/Designations.h include/modules/Designations.h
include/modules/Engravings.h
include/modules/EventManager.h include/modules/EventManager.h
include/modules/Filesystem.h include/modules/Filesystem.h
include/modules/Graphic.h include/modules/Graphic.h
@ -138,7 +130,6 @@ set(MODULE_HEADERS
include/modules/MapCache.h include/modules/MapCache.h
include/modules/Maps.h include/modules/Maps.h
include/modules/Materials.h include/modules/Materials.h
include/modules/Notes.h
include/modules/Once.h include/modules/Once.h
include/modules/Persistence.h include/modules/Persistence.h
include/modules/Random.h include/modules/Random.h
@ -154,7 +145,6 @@ set(MODULE_SOURCES
modules/Burrows.cpp modules/Burrows.cpp
modules/Constructions.cpp modules/Constructions.cpp
modules/Designations.cpp modules/Designations.cpp
modules/Engravings.cpp
modules/EventManager.cpp modules/EventManager.cpp
modules/Filesystem.cpp modules/Filesystem.cpp
modules/Graphic.cpp modules/Graphic.cpp
@ -165,7 +155,6 @@ set(MODULE_SOURCES
modules/MapCache.cpp modules/MapCache.cpp
modules/Maps.cpp modules/Maps.cpp
modules/Materials.cpp modules/Materials.cpp
modules/Notes.cpp
modules/Once.cpp modules/Once.cpp
modules/Persistence.cpp modules/Persistence.cpp
modules/Random.cpp modules/Random.cpp
@ -173,7 +162,6 @@ set(MODULE_SOURCES
modules/Screen.cpp modules/Screen.cpp
modules/Translation.cpp modules/Translation.cpp
modules/Units.cpp modules/Units.cpp
modules/Windows.cpp
modules/World.cpp modules/World.cpp
) )
@ -211,10 +199,7 @@ list(APPEND PROJECT_SOURCES ${MAIN_SOURCES})
list(APPEND PROJECT_SOURCES ${MODULE_SOURCES}) list(APPEND PROJECT_SOURCES ${MODULE_SOURCES})
if(UNIX) if(UNIX)
option(BUILD_EGGY "Make DFHack strangely egg-shaped." OFF) if(APPLE)
if(BUILD_EGGY)
list(APPEND PROJECT_SOURCES ${MAIN_SOURCES_LINUX_EGGY})
elseif(APPLE)
list(APPEND PROJECT_SOURCES ${MAIN_SOURCES_DARWIN}) list(APPEND PROJECT_SOURCES ${MAIN_SOURCES_DARWIN})
else() else()
list(APPEND PROJECT_SOURCES ${MAIN_SOURCES_LINUX}) list(APPEND PROJECT_SOURCES ${MAIN_SOURCES_LINUX})
@ -376,15 +361,9 @@ add_executable(dfhack-run dfhack-run.cpp)
add_executable(binpatch binpatch.cpp) add_executable(binpatch binpatch.cpp)
target_link_libraries(binpatch dfhack-md5) 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) 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 PROPERTIES COMPILE_FLAGS "/FI\"Export.h\"" )
set_target_properties(dfhack-client PROPERTIES COMPILE_FLAGS "/FI\"Export.h\"" ) set_target_properties(dfhack-client PROPERTIES COMPILE_FLAGS "/FI\"Export.h\"" )
else() else()
@ -439,23 +418,15 @@ if(UNIX)
DESTINATION .) DESTINATION .)
endif() endif()
else() else()
if(NOT BUILD_EGGY) # On windows, copy the renamed SDL so DF can still run.
# On windows, copy the renamed SDL so DF can still run. install(PROGRAMS ${dfhack_SOURCE_DIR}/package/windows/win${DFHACK_BUILD_ARCH}/SDLreal.dll
install(PROGRAMS ${dfhack_SOURCE_DIR}/package/windows/win${DFHACK_BUILD_ARCH}/SDLreal.dll DESTINATION ${DFHACK_LIBRARY_DESTINATION})
DESTINATION ${DFHACK_LIBRARY_DESTINATION})
endif()
endif() endif()
# install the main lib # install the main lib
if(NOT BUILD_EGGY) install(TARGETS dfhack
install(TARGETS dfhack LIBRARY DESTINATION ${DFHACK_LIBRARY_DESTINATION}
LIBRARY DESTINATION ${DFHACK_LIBRARY_DESTINATION} RUNTIME 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 the offset file # install the offset file
install(FILES xml/symbols.xml install(FILES xml/symbols.xml

@ -53,8 +53,6 @@ using namespace std;
#include "modules/Filesystem.h" #include "modules/Filesystem.h"
#include "modules/Gui.h" #include "modules/Gui.h"
#include "modules/World.h" #include "modules/World.h"
#include "modules/Graphic.h"
#include "modules/Windows.h"
#include "modules/Persistence.h" #include "modules/Persistence.h"
#include "RemoteServer.h" #include "RemoteServer.h"
#include "RemoteTools.h" #include "RemoteTools.h"
@ -1563,7 +1561,6 @@ Core::Core() :
last_local_map_ptr = NULL; last_local_map_ptr = NULL;
last_pause_state = false; last_pause_state = false;
top_viewscreen = NULL; top_viewscreen = NULL;
screen_window = NULL;
color_ostream::log_errors_to_stderr = true; color_ostream::log_errors_to_stderr = true;
@ -1834,8 +1831,6 @@ bool Core::Init()
cerr << "Starting DF input capture thread.\n"; cerr << "Starting DF input capture thread.\n";
// set up hotkey capture // set up hotkey capture
d->hotkeythread = std::thread(fHKthread, (void *) temp); 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; started = true;
modstate = 0; modstate = 0;
@ -1979,14 +1974,6 @@ bool Core::isSuspended(void)
return ownerThread.load() == std::this_thread::get_id(); return ownerThread.load() == std::this_thread::get_id();
} }
int Core::TileUpdate()
{
if(!started)
return false;
screen_window->paint();
return true;
}
void Core::doUpdate(color_ostream &out, bool first_update) void Core::doUpdate(color_ostream &out, bool first_update)
{ {
Lua::Core::Reset(out, "DF code execution"); Lua::Core::Reset(out, "DF code execution");
@ -2925,5 +2912,4 @@ TYPE * Core::get##TYPE() \
} }
MODULE_GETTER(Materials); MODULE_GETTER(Materials);
MODULE_GETTER(Notes);
MODULE_GETTER(Graphic); MODULE_GETTER(Graphic);

@ -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 <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <vector>
#include <string>
#include <map>
#include "Core.h"
#include "Hooks.h"
#include <iostream>
// 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;
}

@ -35,7 +35,6 @@ distribution.
#include <stdio.h> #include <stdio.h>
#include "tinythread.h" #include "tinythread.h"
#include "modules/Graphic.h"
#include "../plugins/uicommon.h" #include "../plugins/uicommon.h"
/* /*

@ -58,7 +58,6 @@ namespace DFHack
class Process; class Process;
class Module; class Module;
class Materials; class Materials;
class Notes;
struct VersionInfo; struct VersionInfo;
class VersionInfoFactory; class VersionInfoFactory;
class PluginManager; class PluginManager;
@ -69,10 +68,6 @@ namespace DFHack
namespace Lua { namespace Core { namespace Lua { namespace Core {
DFHACK_EXPORT void Reset(color_ostream &out, const char *where); DFHACK_EXPORT void Reset(color_ostream &out, const char *where);
} } } }
namespace Windows
{
class df_window;
}
namespace Screen namespace Screen
{ {
@ -126,12 +121,6 @@ namespace DFHack
friend int ::SDL_Init(uint32_t flags); friend int ::SDL_Init(uint32_t flags);
friend int ::wgetch(WINDOW * w); friend int ::wgetch(WINDOW * w);
#endif #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: public:
/// Get the single Core instance or make one. /// Get the single Core instance or make one.
static Core& getInstance() static Core& getInstance()
@ -146,8 +135,6 @@ namespace DFHack
/// get the materials module /// get the materials module
Materials * getMaterials(); Materials * getMaterials();
/// get the notes module
Notes * getNotes();
/// get the graphic module /// get the graphic module
Graphic * getGraphic(); Graphic * getGraphic();
/// sets the current hotkey command /// sets the current hotkey command
@ -193,7 +180,6 @@ namespace DFHack
std::unique_ptr<DFHack::Process> p; std::unique_ptr<DFHack::Process> p;
std::shared_ptr<DFHack::VersionInfo> vinfo; std::shared_ptr<DFHack::VersionInfo> vinfo;
DFHack::Windows::df_window * screen_window;
static void print(const char *format, ...) Wformat(printf,1,2); static void print(const char *format, ...) Wformat(printf,1,2);
static void printerr(const char *format, ...) Wformat(printf,1,2); static void printerr(const char *format, ...) Wformat(printf,1,2);
@ -213,7 +199,6 @@ namespace DFHack
bool Init(); bool Init();
int Update (void); int Update (void);
int TileUpdate (void);
int Shutdown (void); int Shutdown (void);
int DFH_SDL_Event(SDL::Event* event); int DFH_SDL_Event(SDL::Event* event);
bool ncurses_wgetch(int in, int & out); bool ncurses_wgetch(int in, int & out);
@ -242,7 +227,6 @@ namespace DFHack
struct struct
{ {
Materials * pMaterials; Materials * pMaterials;
Notes * pNotes;
Graphic * pGraphic; Graphic * pGraphic;
} s_mods; } s_mods;
std::vector<std::unique_ptr<Module>> allModules; std::vector<std::unique_ptr<Module>> allModules;

@ -54,7 +54,6 @@ distribution.
// DFHack modules // DFHack modules
#include "modules/Buildings.h" #include "modules/Buildings.h"
#include "modules/Engravings.h"
#include "modules/Materials.h" #include "modules/Materials.h"
#include "modules/Constructions.h" #include "modules/Constructions.h"
#include "modules/Units.h" #include "modules/Units.h"

@ -47,7 +47,6 @@ namespace SDL
// these functions are here because they call into DFHack::Core and therefore need to // these functions are here because they call into DFHack::Core and therefore need to
// be declared as friend functions/known // be declared as friend functions/known
#ifdef _DARWIN #ifdef _DARWIN
#include "modules/Graphic.h"
DFhackCExport int DFH_SDL_NumJoysticks(void); DFhackCExport int DFH_SDL_NumJoysticks(void);
DFhackCExport void DFH_SDL_Quit(void); DFhackCExport void DFH_SDL_Quit(void);
DFhackCExport int DFH_SDL_PollEvent(SDL::Event* event); DFhackCExport int DFH_SDL_PollEvent(SDL::Event* event);
@ -75,21 +74,3 @@ DFhackCExport void * SDL_GetVideoSurface(void);
DFhackCExport int SDL_SemWait(vPtr sem); DFhackCExport int SDL_SemWait(vPtr sem);
DFhackCExport int SDL_SemPost(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);

@ -33,7 +33,6 @@ namespace DFHack
{ {
class Module; class Module;
std::unique_ptr<Module> createMaterials(); std::unique_ptr<Module> createMaterials();
std::unique_ptr<Module> createNotes();
std::unique_ptr<Module> createGraphic(); std::unique_ptr<Module> createGraphic();
} }
#endif #endif

@ -42,23 +42,7 @@ namespace DFHack
{ {
namespace Constructions 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 df::construction * findAtTile(df::coord pos);
DFHACK_EXPORT bool designateNew(df::coord pos, df::construction_type type, DFHACK_EXPORT bool designateNew(df::coord pos, df::construction_type type,

@ -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

@ -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 <vector>
#include <string>
#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<t_note*>* notes;
};
}
#endif // __cplusplus
#endif

@ -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 <cstddef>
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 <df_window *> 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();
}
};
}
}

@ -51,22 +51,6 @@ using namespace DFHack;
using namespace df::enums; using namespace df::enums;
using df::global::world; 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) df::construction * Constructions::findAtTile(df::coord pos)
{ {
@ -77,23 +61,6 @@ df::construction * Constructions::findAtTile(df::coord pos)
return NULL; 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, bool Constructions::designateNew(df::coord pos, df::construction_type type,
df::item_type item, int mat_index) df::item_type item, int mat_index)
{ {

@ -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 <string>
#include <vector>
#include <map>
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;
}

@ -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 <string>
#include <vector>
#include <map>
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 <DataDefs.h>
#include "df/ui.h"
using namespace DFHack;
std::unique_ptr<Module> DFHack::createNotes()
{
return dts::make_unique<Notes>();
}
// FIXME: not even a wrapper now
Notes::Notes()
{
notes = (std::vector<t_note*>*) &df::global::ui->waypoints.points;
}

@ -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 <string>
#include "DataDefs.h"
#include "df/init.h"
#include "df/ui.h"
#include <df/graphic.h>
#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;
}

@ -13,7 +13,6 @@ dfhack_plugin(eventExample eventExample.cpp)
dfhack_plugin(frozen frozen.cpp) dfhack_plugin(frozen frozen.cpp)
dfhack_plugin(kittens kittens.cpp LINK_LIBRARIES ${CMAKE_THREAD_LIBS_INIT}) dfhack_plugin(kittens kittens.cpp LINK_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
dfhack_plugin(memview memview.cpp memutils.cpp LINK_LIBRARIES lua) dfhack_plugin(memview memview.cpp memutils.cpp LINK_LIBRARIES lua)
dfhack_plugin(notes notes.cpp)
dfhack_plugin(onceExample onceExample.cpp) dfhack_plugin(onceExample onceExample.cpp)
dfhack_plugin(renderer-msg renderer-msg.cpp) dfhack_plugin(renderer-msg renderer-msg.cpp)
dfhack_plugin(rprobe rprobe.cpp) dfhack_plugin(rprobe rprobe.cpp)

@ -1,72 +0,0 @@
#include "Core.h"
#include <Console.h>
#include <Export.h>
#include <PluginManager.h>
#include <vector>
#include <string>
#include <modules/Notes.h>
using std::vector;
using std::string;
using namespace DFHack;
command_result df_notes (color_ostream &out, vector <string> & parameters);
DFHACK_PLUGIN("notes");
DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &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 <string> & parameters)
{
CoreSuspender suspend;
DFHack::Notes * note_mod = Core::getInstance().getNotes();
std::vector<t_note*>* 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;
}