Header changes/cleanup.

develop
Petr Mrázek 2011-12-31 12:48:42 +01:00
parent 1284b30f79
commit 9db20bd84d
137 changed files with 899 additions and 1199 deletions

@ -13,54 +13,52 @@ include_directories (include)
include_directories (depends/md5) include_directories (depends/md5)
include_directories (depends/tinyxml) include_directories (depends/tinyxml)
include_directories (depends/tthread) include_directories (depends/tthread)
include_directories (private)
execute_process(COMMAND perl xml/list.pl xml include/dfhack/df ";" execute_process(COMMAND perl xml/list.pl xml include/df ";"
WORKING_DIRECTORY ${dfapi_SOURCE_DIR} WORKING_DIRECTORY ${dfapi_SOURCE_DIR}
OUTPUT_VARIABLE GENERATED_HDRS) OUTPUT_VARIABLE GENERATED_HDRS)
SET(PROJECT_HDRS_INTERNAL SET(PROJECT_HDRS_INTERNAL
private/ContextShared.h
private/Internal.h
private/wdirent.h
) )
SET(PROJECT_HDRS SET(PROJECT_HDRS
include/Internal.h
include/DFHack.h include/DFHack.h
include/dfhack/Console.h include/Console.h
include/dfhack/Core.h include/Core.h
include/dfhack/DataDefs.h include/DataDefs.h
include/dfhack/Error.h include/Error.h
include/dfhack/Export.h include/Export.h
include/dfhack/FakeSDL.h include/Hooks.h
include/dfhack/MiscUtils.h include/MiscUtils.h
include/dfhack/Module.h include/Module.h
include/dfhack/Pragma.h include/Pragma.h
include/dfhack/Process.h include/MemAccess.h
include/dfhack/TileTypes.h include/SDL_events.h
include/dfhack/Types.h include/SDL_keyboard.h
include/dfhack/Vector.h include/SDL_keysym.h
include/dfhack/VersionInfo.h include/TileTypes.h
include/dfhack/VersionInfoFactory.h include/Types.h
include/dfhack/Virtual.h include/Vector.h
include/dfhack/extra/MapExtras.h include/VersionInfo.h
include/dfhack/extra/stopwatch.h include/VersionInfoFactory.h
include/dfhack/extra/termutil.h include/Virtual.h
include/dfhack/modules/Buildings.h include/modules/Buildings.h
include/dfhack/modules/Constructions.h include/modules/Constructions.h
include/dfhack/modules/Units.h include/modules/Units.h
include/dfhack/modules/Engravings.h include/modules/Engravings.h
include/dfhack/modules/Gui.h include/modules/Gui.h
include/dfhack/modules/Items.h include/modules/Items.h
include/dfhack/modules/kitchen.h include/modules/kitchen.h
include/dfhack/modules/Maps.h include/modules/Maps.h
include/dfhack/modules/Materials.h include/modules/MapCache.h
include/dfhack/modules/Notes.h include/modules/Materials.h
include/dfhack/modules/Translation.h include/modules/Notes.h
include/dfhack/modules/Vegetation.h include/modules/Translation.h
include/dfhack/modules/Vermin.h include/modules/Vegetation.h
include/dfhack/modules/World.h include/modules/Vermin.h
include/dfhack/modules/Graphic.h include/modules/World.h
include/modules/Graphic.h
) )
SET(PROJECT_SRCS SET(PROJECT_SRCS
@ -68,6 +66,7 @@ Core.cpp
DataDefs.cpp DataDefs.cpp
DataStatics.cpp DataStatics.cpp
DataStaticsCtor.cpp DataStaticsCtor.cpp
MiscUtils.cpp
PluginManager.cpp PluginManager.cpp
TileTypes.cpp TileTypes.cpp
VersionInfo.cpp VersionInfo.cpp
@ -105,17 +104,18 @@ SET(PROJECT_HDRS_LINUX
) )
SET(PROJECT_HDRS_WINDOWS SET(PROJECT_HDRS_WINDOWS
include/wdirent.h
) )
SET(PROJECT_SRCS_LINUX SET(PROJECT_SRCS_LINUX
Console-linux.cpp Console-linux.cpp
FakeSDL-linux.cpp Hooks-linux.cpp
Process-linux.cpp Process-linux.cpp
) )
SET(PROJECT_SRCS_WINDOWS SET(PROJECT_SRCS_WINDOWS
Console-windows.cpp Console-windows.cpp
FakeSDL-windows.cpp Hooks-windows.cpp
Process-windows.cpp Process-windows.cpp
) )
@ -139,14 +139,14 @@ FILE(GLOB GENERATE_INPUT_SCRIPTS ${dfapi_SOURCE_DIR}/xml/*.pm ${dfapi_SOURCE_DIR
FILE(GLOB GENERATE_INPUT_XMLS ${dfapi_SOURCE_DIR}/xml/*.xml) FILE(GLOB GENERATE_INPUT_XMLS ${dfapi_SOURCE_DIR}/xml/*.xml)
ADD_CUSTOM_COMMAND( ADD_CUSTOM_COMMAND(
OUTPUT ${dfapi_SOURCE_DIR}/include/dfhack/df/static.inc OUTPUT ${dfapi_SOURCE_DIR}/include/df/static.inc
COMMAND perl xml/codegen.pl xml include/dfhack/df COMMAND perl xml/codegen.pl xml include/df
WORKING_DIRECTORY ${dfapi_SOURCE_DIR} WORKING_DIRECTORY ${dfapi_SOURCE_DIR}
MAIN_DEPENDENCY ${dfapi_SOURCE_DIR}/xml/codegen.pl MAIN_DEPENDENCY ${dfapi_SOURCE_DIR}/xml/codegen.pl
DEPENDS ${GENERATE_INPUT_XMLS} ${GENERATE_INPUT_SCRIPTS} DEPENDS ${GENERATE_INPUT_XMLS} ${GENERATE_INPUT_SCRIPTS}
) )
ADD_CUSTOM_TARGET(generate_headers DEPENDS ${dfapi_SOURCE_DIR}/include/dfhack/df/static.inc) ADD_CUSTOM_TARGET(generate_headers DEPENDS ${dfapi_SOURCE_DIR}/include/df/static.inc)
# Compilation # Compilation

@ -61,8 +61,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <errno.h> #include <errno.h>
#include <deque> #include <deque>
#include "dfhack/Console.h" #include "Console.h"
#include "dfhack/FakeSDL.h" #include "Hooks.h"
using namespace DFHack; using namespace DFHack;
#include "tinythread.h" #include "tinythread.h"

@ -50,8 +50,8 @@ POSSIBILITY OF SUCH DAMAGE.
#include <istream> #include <istream>
#include <string> #include <string>
#include "dfhack/Console.h" #include "Console.h"
#include "dfhack/FakeSDL.h" #include "Hooks.h"
#include <cstdio> #include <cstdio>
#include <cstdlib> #include <cstdlib>
#include <sstream> #include <sstream>

@ -34,28 +34,28 @@ distribution.
#include <sstream> #include <sstream>
using namespace std; using namespace std;
#include "dfhack/Error.h" #include "Error.h"
#include "dfhack/Process.h" #include "MemAccess.h"
#include "dfhack/Core.h" #include "Core.h"
#include "dfhack/DataDefs.h" #include "DataDefs.h"
#include "dfhack/Console.h" #include "Console.h"
#include "dfhack/Module.h" #include "Module.h"
#include "dfhack/VersionInfoFactory.h" #include "VersionInfoFactory.h"
#include "dfhack/VersionInfo.h" #include "VersionInfo.h"
#include "dfhack/PluginManager.h" #include "PluginManager.h"
#include "ModuleFactory.h" #include "ModuleFactory.h"
#include "dfhack/modules/Gui.h" #include "modules/Gui.h"
#include "dfhack/modules/World.h" #include "modules/World.h"
#include "dfhack/modules/Graphic.h" #include "modules/Graphic.h"
using namespace DFHack; using namespace DFHack;
#include "dfhack/SDL_fakes/events.h" #include "SDL_events.h"
#include "dfhack/df/ui.h" #include "df/ui.h"
#include "dfhack/df/world.h" #include "df/world.h"
#include "dfhack/df/world_data.h" #include "df/world_data.h"
#include "dfhack/df/interface.h" #include "df/interface.h"
#include "dfhack/df/viewscreen_dwarfmodest.h" #include "df/viewscreen_dwarfmodest.h"
#include <stdio.h> #include <stdio.h>
#include <iomanip> #include <iomanip>

@ -28,12 +28,12 @@ distribution.
#include <vector> #include <vector>
#include <map> #include <map>
#include "dfhack/Process.h" #include "MemAccess.h"
#include "dfhack/Core.h" #include "Core.h"
#include "dfhack/VersionInfo.h" #include "VersionInfo.h"
#include "tinythread.h" #include "tinythread.h"
// must be last due to MS stupidity // must be last due to MS stupidity
#include "dfhack/DataDefs.h" #include "DataDefs.h"
using namespace DFHack; using namespace DFHack;

@ -1,10 +1,10 @@
#include "Internal.h" #include "Internal.h"
#include "dfhack/DataDefs.h" #include "DataDefs.h"
#include "dfhack/MiscUtils.h" #include "MiscUtils.h"
#include "dfhack/df/world.h" #include "df/world.h"
#include "dfhack/df/world_data.h" #include "df/world_data.h"
#include "dfhack/df/ui.h" #include "df/ui.h"
namespace { namespace {
template<class T> template<class T>
@ -14,5 +14,5 @@ namespace {
} }
// Instantiate all the static objects // Instantiate all the static objects
#include "dfhack/df/static.inc" #include "df/static.inc"
#include "dfhack/df/static.enums.inc" #include "df/static.enums.inc"

@ -1,6 +1,6 @@
#include "Internal.h" #include "Internal.h"
#include "dfhack/DataDefs.h" #include "DataDefs.h"
#include "dfhack/MiscUtils.h" #include "MiscUtils.h"
// Object constructors // Object constructors
#include "dfhack/df/static.ctors.inc" #include "df/static.ctors.inc"

@ -39,8 +39,8 @@ distribution.
#include <map> #include <map>
#include "DFHack.h" #include "DFHack.h"
#include "dfhack/Core.h" #include "Core.h"
#include "dfhack/FakeSDL.h" #include "Hooks.h"
#include <iostream> #include <iostream>
/* /*

@ -28,12 +28,12 @@ distribution.
#include <stdint.h> #include <stdint.h>
#include <vector> #include <vector>
#include <string> #include <string>
#include "dfhack/Core.h" #include "Core.h"
#include "dfhack/FakeSDL.h" #include "Hooks.h"
#include <stdio.h> #include <stdio.h>
#include "tinythread.h" #include "tinythread.h"
#include "dfhack/modules/Graphic.h" #include "modules/Graphic.h"
/* /*
* Plugin loading functions * Plugin loading functions

@ -23,13 +23,13 @@ distribution.
*/ */
#include "Internal.h" #include "Internal.h"
#include "dfhack/Core.h" #include "Core.h"
#include "dfhack/Process.h" #include "MemAccess.h"
#include "dfhack/PluginManager.h" #include "PluginManager.h"
#include "dfhack/Console.h" #include "Console.h"
#include "dfhack/DataDefs.h" #include "DataDefs.h"
#include "dfhack/df/viewscreen.h" #include "df/viewscreen.h"
using namespace DFHack; using namespace DFHack;
@ -278,7 +278,6 @@ command_result Plugin::invoke( std::string & command, std::vector <std::string>
for (int i = 0; i < commands.size();i++) for (int i = 0; i < commands.size();i++)
{ {
PluginCommand &cmd = commands[i]; PluginCommand &cmd = commands[i];
if(cmd.name == command) if(cmd.name == command)
{ {
// running interactive things from some other source than the console would break it // running interactive things from some other source than the console would break it
@ -294,7 +293,7 @@ command_result Plugin::invoke( std::string & command, std::vector <std::string>
df::viewscreen *top = c.getTopViewscreen(); df::viewscreen *top = c.getTopViewscreen();
if ((cmd.viewscreen_type && !cmd.viewscreen_type->is_instance(top)) if ((cmd.viewscreen_type && !cmd.viewscreen_type->is_instance(top))
|| !cmd.guard(&c, top)) || !cmd.guard(&c, top))
{ {
c.con.printerr("Could not invoke %s: unsuitable UI state.\n", command.c_str()); c.con.printerr("Could not invoke %s: unsuitable UI state.\n", command.c_str());
cr = CR_FAILURE; cr = CR_FAILURE;

@ -36,10 +36,10 @@ distribution.
using namespace std; using namespace std;
#include <md5wrapper.h> #include <md5wrapper.h>
#include "dfhack/Process.h" #include "MemAccess.h"
#include "dfhack/VersionInfoFactory.h" #include "VersionInfoFactory.h"
#include "dfhack/VersionInfo.h" #include "VersionInfo.h"
#include "dfhack/Error.h" #include "Error.h"
#include <string.h> #include <string.h>
using namespace DFHack; using namespace DFHack;

@ -91,10 +91,10 @@ extern "C" __declspec(dllimport) NTSTATUS __stdcall RtlDestroyQueryDebugBuffer(
#include <map> #include <map>
using namespace std; using namespace std;
#include "dfhack/VersionInfo.h" #include "VersionInfo.h"
#include "dfhack/VersionInfoFactory.h" #include "VersionInfoFactory.h"
#include "dfhack/Error.h" #include "Error.h"
#include "dfhack/Process.h" #include "MemAccess.h"
using namespace DFHack; using namespace DFHack;
namespace DFHack namespace DFHack
{ {

@ -23,8 +23,8 @@ distribution.
*/ */
#include "Internal.h" #include "Internal.h"
#include "dfhack/TileTypes.h" #include "TileTypes.h"
#include "dfhack/Export.h" #include "Export.h"
namespace DFHack namespace DFHack
{ {

@ -31,9 +31,9 @@ distribution.
#include <map> #include <map>
using namespace std; using namespace std;
#include "dfhack/VersionInfo.h" #include "VersionInfo.h"
#include "dfhack/Error.h" #include "Error.h"
#include "dfhack/Process.h" #include "MemAccess.h"
using namespace DFHack; using namespace DFHack;
//Inital amount of space in levels vector (since we usually know the number, efficient!) //Inital amount of space in levels vector (since we usually know the number, efficient!)

@ -31,9 +31,9 @@ distribution.
#include <iostream> #include <iostream>
using namespace std; using namespace std;
#include "dfhack/VersionInfoFactory.h" #include "VersionInfoFactory.h"
#include "dfhack/VersionInfo.h" #include "VersionInfo.h"
#include "dfhack/Error.h" #include "Error.h"
using namespace DFHack; using namespace DFHack;
#include <tinyxml.h> #include <tinyxml.h>

@ -4,9 +4,9 @@
#include <vector> #include <vector>
#include <map> #include <map>
#include "dfhack/Process.h" #include "MemAccess.h"
#include "dfhack/Core.h" #include "Core.h"
#include "dfhack/Virtual.h" #include "Virtual.h"
using namespace DFHack; using namespace DFHack;
std::string t_virtual::getClassName() const std::string t_virtual::getClassName() const

@ -23,8 +23,8 @@ distribution.
*/ */
#pragma once #pragma once
#include "dfhack/Pragma.h" #include "Pragma.h"
#include "dfhack/Export.h" #include "Export.h"
#include <stdint.h> #include <stdint.h>
#include <string.h> #include <string.h>
#include <sstream> #include <sstream>

@ -23,8 +23,8 @@ distribution.
*/ */
#pragma once #pragma once
#include "dfhack/Pragma.h" #include "Pragma.h"
#include "dfhack/Export.h" #include "Export.h"
#include <deque> #include <deque>
#include <fstream> #include <fstream>
#include <assert.h> #include <assert.h>

@ -24,15 +24,15 @@ distribution.
#pragma once #pragma once
#include "dfhack/Pragma.h" #include "Pragma.h"
#include "dfhack/Export.h" #include "Export.h"
#include "dfhack/FakeSDL.h" #include "Hooks.h"
#include <vector> #include <vector>
#include <stack> #include <stack>
#include <map> #include <map>
#include <stdint.h> #include <stdint.h>
#include "dfhack/Console.h" #include "Console.h"
#include "dfhack/modules/Graphic.h" #include "modules/Graphic.h"
struct WINDOW; struct WINDOW;

@ -47,34 +47,34 @@ distribution.
#include <stdint.h> #include <stdint.h>
// DFHack core classes and types // DFHack core classes and types
#include "dfhack/Error.h" #include "Error.h"
#include "dfhack/VersionInfo.h" #include "VersionInfo.h"
#include "dfhack/Process.h" #include "MemAccess.h"
#include "dfhack/Types.h" #include "Types.h"
// DFHack modules // DFHack modules
#include "dfhack/modules/Buildings.h" #include "modules/Buildings.h"
#include "dfhack/modules/Engravings.h" #include "modules/Engravings.h"
#include "dfhack/modules/Materials.h" #include "modules/Materials.h"
#include "dfhack/modules/Constructions.h" #include "modules/Constructions.h"
#include "dfhack/modules/Units.h" #include "modules/Units.h"
#include "dfhack/modules/Translation.h" #include "modules/Translation.h"
#include "dfhack/modules/World.h" #include "modules/World.h"
#include "dfhack/modules/Items.h" #include "modules/Items.h"
#include "dfhack/modules/Vegetation.h" #include "modules/Vegetation.h"
#include "dfhack/modules/Maps.h" #include "modules/Maps.h"
#include "dfhack/modules/Gui.h" #include "modules/Gui.h"
/* /*
* This is a header full of ugly, volatile things. * This is a header full of ugly, volatile things.
* Only for use of official DFHack tools! * Only for use of official DFHack tools!
*/ */
#ifdef DFHACK_WANT_MISCUTILS #ifdef DFHACK_WANT_MISCUTILS
#include "dfhack/MiscUtils.h" #include "MiscUtils.h"
#endif #endif
// define this to get the static tiletype->properties mapping // define this to get the static tiletype->properties mapping
#ifdef DFHACK_WANT_TILETYPES #ifdef DFHACK_WANT_TILETYPES
#include "dfhack/TileTypes.h" #include "TileTypes.h"
#endif #endif
#endif #endif

@ -28,8 +28,8 @@ distribution.
#include <vector> #include <vector>
#include <map> #include <map>
#include "dfhack/Core.h" #include "Core.h"
#include "dfhack/BitArray.h" #include "BitArray.h"
// Stop some MS stupidity // Stop some MS stupidity
#ifdef interface #ifdef interface

@ -27,8 +27,8 @@ distribution.
#ifndef ERROR_H_INCLUDED #ifndef ERROR_H_INCLUDED
#define ERROR_H_INCLUDED #define ERROR_H_INCLUDED
#include "dfhack/Export.h" #include "Export.h"
#include "dfhack/Pragma.h" #include "Pragma.h"
#include <string> #include <string>
#include <sstream> #include <sstream>
#include <exception> #include <exception>

@ -28,39 +28,20 @@ distribution.
* Some much needed SDL fakery. * Some much needed SDL fakery.
*/ */
#include "dfhack/Pragma.h" #include "Pragma.h"
#include "dfhack/Export.h" #include "Export.h"
#include <string> #include <string>
#include <stdint.h> #include <stdint.h>
// function and variable pointer... we don't try to understand what SDL does here // function and variable pointer... we don't try to understand what SDL does here
typedef void * fPtr; typedef void * fPtr;
typedef void * vPtr; typedef void * vPtr;
struct WINDOW; struct WINDOW;
namespace SDL namespace SDL
{ {
union Event; union Event;
//struct Thread;
//struct Mutex;
//struct Cond;
//struct Library;
} }
/*
// mutex stuff
DFhackCExport SDL::Mutex * SDL_CreateMutex(void);
DFhackCExport int SDL_mutexP(SDL::Mutex *);
DFhackCExport int SDL_mutexV(SDL::Mutex *);
DFhackCExport void SDL_DestroyMutex(SDL::Mutex *);
// thread stuff
DFhackCExport SDL::Thread *SDL_CreateThread(int (*fn)(void *), void *data);
DFhackCExport uint32_t SDL_ThreadID();
// condition variables
DFhackCExport SDL::Cond *SDL_CreateCond(void);
DFhackCExport void SDL_DestroyCond(SDL::Cond *cond);
DFhackCExport int SDL_CondSignal(SDL::Cond *cond);
DFhackCExport int SDL_CondWait(SDL::Cond *cond, SDL::Mutex * mut);
*/
// 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
DFhackCExport int SDL_NumJoysticks(void); DFhackCExport int SDL_NumJoysticks(void);
@ -69,4 +50,3 @@ DFhackCExport int SDL_PollEvent(SDL::Event* event);
DFhackCExport int SDL_Init(uint32_t flags); DFhackCExport int SDL_Init(uint32_t flags);
DFhackCExport int wgetch(WINDOW * win); DFhackCExport int wgetch(WINDOW * win);
// Other crud is in the OS-specific core files.

@ -24,9 +24,6 @@ distribution.
#pragma once #pragma once
#ifndef DFCOMMONINTERNAL_H_INCLUDED
#define DFCOMMONINTERNAL_H_INCLUDED
// this makes everything that includes this file export symbols when using DFHACK_EXPORT (see DFExport.h) // this makes everything that includes this file export symbols when using DFHACK_EXPORT (see DFExport.h)
#ifndef BUILD_DFHACK_LIB #ifndef BUILD_DFHACK_LIB
#define BUILD_DFHACK_LIB #define BUILD_DFHACK_LIB
@ -38,10 +35,7 @@ distribution.
#endif #endif
// one file for telling the MSVC compiler where it can shove its pointless warnings // one file for telling the MSVC compiler where it can shove its pointless warnings
#include "dfhack/Pragma.h" #include "Pragma.h"
// C99 integer types // C99 integer types
#include <stdint.h> #include <stdint.h>
#endif // DFCOMMONINTERNAL_H_INCLUDED

@ -28,8 +28,8 @@ distribution.
#ifndef PROCESS_H_INCLUDED #ifndef PROCESS_H_INCLUDED
#define PROCESS_H_INCLUDED #define PROCESS_H_INCLUDED
#include "dfhack/Pragma.h" #include "Pragma.h"
#include "dfhack/Export.h" #include "Export.h"
#include <iostream> #include <iostream>
#include <cstring> #include <cstring>
#include <map> #include <map>

@ -0,0 +1,104 @@
/*
https://github.com/peterix/dfhack
Copyright (c) 2009-2011 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 <iostream>
#include <iomanip>
#include <climits>
#include <stdint.h>
#include <vector>
#include <sstream>
#include <cstdio>
using namespace std;
template <typename T>
void print_bits ( T val, DFHack::Console& out )
{
stringstream strs;
T n_bits = sizeof ( val ) * CHAR_BIT;
int cnt;
for ( unsigned i = 0; i < n_bits; ++i )
{
cnt = i/10;
strs << cnt << " ";
}
strs << endl;
for ( unsigned i = 0; i < n_bits; ++i )
{
cnt = i%10;
strs << cnt << " ";
}
strs << endl;
for ( unsigned i = 0; i < n_bits; ++i )
{
strs << "--";
}
strs << endl;
for ( unsigned i = 0; i < n_bits; ++i )
{
strs<< !!( val & 1 ) << " ";
val >>= 1;
}
strs << endl;
out.print(strs.str().c_str());
}
//FIXME: Error 8 error C4519: default template arguments are only allowed on a class template
template <typename CT, typename FT, typename AT/* = FT*/>
CT *binsearch_in_vector(std::vector<CT*> &vec, FT CT::*field, AT value)
{
int min = -1, max = (int)vec.size();
CT **p = vec.data();
FT key = (FT)value;
for (;;)
{
int mid = (min + max)>>1;
if (mid == min)
{
return NULL;
}
FT midv = p[mid]->*field;
if (midv == key)
{
return p[mid];
}
else if (midv < key)
{
min = mid;
}
else
{
max = mid;
}
}
}
/**
* Returns the amount of milliseconds elapsed since the UNIX epoch.
* Works on both windows and linux.
* source: http://stackoverflow.com/questions/1861294/how-to-calculate-execution-time-of-a-code-snippet-in-c
*/
DFHACK_EXPORT uint64_t GetTimeMs64();

@ -27,7 +27,7 @@ distribution.
#ifndef MODULE_H_INCLUDED #ifndef MODULE_H_INCLUDED
#define MODULE_H_INCLUDED #define MODULE_H_INCLUDED
#include "dfhack/Export.h" #include "Export.h"
namespace DFHack namespace DFHack
{ {
/** /**

@ -24,11 +24,11 @@ distribution.
#pragma once #pragma once
#include "dfhack/Export.h" #include "Export.h"
#include "Hooks.h"
#include <map> #include <map>
#include <string> #include <string>
#include <vector> #include <vector>
#include "FakeSDL.h"
struct DFLibrary; struct DFLibrary;
namespace tthread namespace tthread
{ {

@ -24,7 +24,7 @@
// Needed for processing its event types without polluting our namespaces with C garbage // Needed for processing its event types without polluting our namespaces with C garbage
#pragma once #pragma once
#include "keyboard.h" #include "SDL_keyboard.h"
namespace SDL namespace SDL
{ {

@ -24,7 +24,7 @@
// Needed for processing its event types without polluting our namespaces with C garbage // Needed for processing its event types without polluting our namespaces with C garbage
#pragma once #pragma once
#include "keysym.h" #include "SDL_keysym.h"
#include <stdint.h> #include <stdint.h>
namespace SDL namespace SDL

@ -27,8 +27,8 @@ distribution.
#ifndef TILETYPES_H_INCLUDED #ifndef TILETYPES_H_INCLUDED
#define TILETYPES_H_INCLUDED #define TILETYPES_H_INCLUDED
#include "dfhack/Pragma.h" #include "Pragma.h"
#include "dfhack/Export.h" #include "Export.h"
namespace DFHack namespace DFHack
{ {

@ -25,8 +25,8 @@ distribution.
#pragma once #pragma once
#include "dfhack/Pragma.h" #include "Pragma.h"
#include "dfhack/Export.h" #include "Export.h"
namespace DFHack namespace DFHack
{ {

@ -28,10 +28,10 @@ distribution.
#ifndef DFVECTOR_H_INCLUDED #ifndef DFVECTOR_H_INCLUDED
#define DFVECTOR_H_INCLUDED #define DFVECTOR_H_INCLUDED
#include "dfhack/Pragma.h" #include "Pragma.h"
#include "dfhack/Export.h" #include "Export.h"
#include "dfhack/VersionInfo.h" #include "VersionInfo.h"
#include "dfhack/Process.h" #include "MemAccess.h"
#include <string.h> #include <string.h>
#include <vector> #include <vector>

@ -28,9 +28,9 @@ distribution.
#ifndef MEMINFO_H_INCLUDED #ifndef MEMINFO_H_INCLUDED
#define MEMINFO_H_INCLUDED #define MEMINFO_H_INCLUDED
#include "dfhack/Pragma.h" #include "Pragma.h"
#include "dfhack/Export.h" #include "Export.h"
#include "dfhack/Types.h" #include "Types.h"
#include <map> #include <map>
#include <sys/types.h> #include <sys/types.h>
#include <vector> #include <vector>

@ -28,8 +28,8 @@ distribution.
#ifndef MEMINFO_MANAGER_H_INCLUDED #ifndef MEMINFO_MANAGER_H_INCLUDED
#define MEMINFO_MANAGER_H_INCLUDED #define MEMINFO_MANAGER_H_INCLUDED
#include "dfhack/Pragma.h" #include "Pragma.h"
#include "dfhack/Export.h" #include "Export.h"
class TiXmlElement; class TiXmlElement;
namespace DFHack namespace DFHack

@ -1,269 +0,0 @@
/*
https://github.com/peterix/dfhack
Copyright (c) 2009-2011 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 <iostream>
#include <iomanip>
#include <climits>
#include <stdint.h>
#include <vector>
#include <sstream>
#include <ctime>
#include <cstdio>
using namespace std;
/*
#include <dfhack/Process.h>
#include <dfhack/VersionInfo.h>
#include <dfhack/Vector.h>
void DumpObjStr0Vector (const char * name, DFHack::Process *p, uint32_t addr)
{
cout << "----==== " << name << " ====----" << endl;
DFHack::DfVector <uint32_t> vect(p,addr);
for(uint32_t i = 0; i < vect.size();i++)
{
uint32_t addr = vect[i];
cout << p->readSTLString(addr) << endl;
}
cout << endl;
}
void DumpObjVtables (const char * name, DFHack::Process *p, uint32_t addr)
{
cout << "----==== " << name << " ====----" << endl;
DFHack::DfVector <uint32_t> vect(p,addr);
for(uint32_t i = 0; i < vect.size();i++)
{
uint32_t addr = vect[i];
uint32_t vptr = p->readDWord(addr);
cout << p->readClassName(vptr) << endl;
}
cout << endl;
}
void DumpDWordVector (const char * name, DFHack::Process *p, uint32_t addr)
{
cout << "----==== " << name << " ====----" << endl;
DFHack::DfVector <uint32_t> vect(p,addr);
for(uint32_t i = 0; i < vect.size();i++)
{
uint32_t number = vect[i];
cout << number << endl;
}
cout << endl;
}
*/
/*
address = absolute address of dump start
length = length in lines. 1 line = 16 bytes
*/
/*
void hexdump (DFHack::Context *DF, uint32_t address, uint32_t length)
{
char *buf = new char[length];
DF->ReadRaw(address, length, (uint8_t *) buf);
uint32_t i = 0;
while (i < length)
{
// leading offset
if(i%16 == 0)
cout << "0x" << hex << setw(8) << address + i << "| ";
// bytes
for(int k = 0; k < 4; k++)
{
cout << hex << setw(2) << int(static_cast<unsigned char>(buf[i])) << " ";
i++;
if(i == length) break;
}
if(i%16 == 0 || i>= length)
{
cout << endl;
}
else if(i%4 == 0)
{
cout << " ";
}
}
delete buf;
}
void interleave_hex (DFHack::Context* DF, vector < uint32_t > & addresses, uint32_t length)
{
vector <char * > bufs;
for(uint32_t counter = 0; counter < addresses.size(); counter ++)
{
char * buf = new char[length * 16];
DF->ReadRaw(addresses[counter], length * 16, (uint8_t *) buf);
bufs.push_back(buf);
}
cout << setfill('0');
// output a header
cout << "line offset ";
for (uint32_t obj = 0; obj < addresses.size(); obj++)
{
cout << "0x" << hex << setw(9) << addresses[obj] << " ";
}
cout << endl;
for(uint32_t offs = 0 ; offs < length * 16; offs += 4)
{
if((!(offs % 16)) && offs != 0)
{
cout << endl;
}
cout << setfill(' ');
cout << dec << setw(4) << offs/4 << " ";
cout << setfill('0');
cout << "0x" << hex << setw(4) << offs << " ";
for (uint32_t object = 0; object < bufs.size(); object++)
{
// bytes
for(int k = 0; k < 4; k++)
{
uint8_t data = bufs[object][offs + k];
cout << hex << setw(2) << int(static_cast<unsigned char>(data)) << " ";
}
cout << " ";
}
cout << endl;
}
for(uint32_t counter = 0; counter < addresses.size(); counter ++)
{
delete bufs[counter];
}
}
*/
template <typename T>
void print_bits ( T val, DFHack::Console& out )
{
stringstream strs;
T n_bits = sizeof ( val ) * CHAR_BIT;
int cnt;
for ( unsigned i = 0; i < n_bits; ++i )
{
cnt = i/10;
strs << cnt << " ";
}
strs << endl;
for ( unsigned i = 0; i < n_bits; ++i )
{
cnt = i%10;
strs << cnt << " ";
}
strs << endl;
for ( unsigned i = 0; i < n_bits; ++i )
{
strs << "--";
}
strs << endl;
for ( unsigned i = 0; i < n_bits; ++i )
{
strs<< !!( val & 1 ) << " ";
val >>= 1;
}
strs << endl;
out.print(strs.str().c_str());
}
/*
// this is probably completely bogus
std::string PrintSplatterType (int16_t mat1, int32_t mat2, vector<DFHack::t_matgloss> &creature_types)
{
std::string ret;
switch (mat1)
{
case 0:
return "Rock";
case 1:
return "Amber";
case 2:
return "Coral";
case 3:
return "Green Glass";
case 4:
return "Clear Glass";
case 5:
return "Crystal Glass";
case 6:
return "Water";
case 7:
return "Coal";
case 8:
return "Potash";
case 9:
return "Ash";
case 10:
return "Pearlash";
case 11:
return "Lye";
case 12:
return "Mud";
case 13:
return "Vomit";
case 14:
return "Salt";
case 15:
return "Filth";
case 16:
return "Frozen? Filth";
case 18:
return "Grime";
case 0xF2:
return "Very Specific Blood (references a named creature)";
case 0x2A:
case 0x2B:
if(mat2 != -1)
{
ret += creature_types[mat2].id;
ret += " ";
}
ret += "Blood";
return ret;
default:
return "Unknown";
}
}
*/
//FIXME: Error 8 error C4519: default template arguments are only allowed on a class template
template <typename CT, typename FT, typename AT/* = FT*/>
CT *binsearch_in_vector(std::vector<CT*> &vec, FT CT::*field, AT value) {
int min = -1, max = (int)vec.size();
CT **p = vec.data();
FT key = (FT)value;
for (;;) {
int mid = (min + max)>>1;
if (mid == min)
return NULL;
FT midv = p[mid]->*field;
if (midv == key)
return p[mid];
else if (midv < key)
min = mid;
else
max = mid;
}
}

@ -1,47 +0,0 @@
// Returns the amount of milliseconds elapsed since the UNIX epoch.
// Works on both windows and linux.
// source: http://stackoverflow.com/questions/1861294/how-to-calculate-execution-time-of-a-code-snippet-in-c
#ifndef LINUX_BUILD
#include <Windows.h>
#else
#include <sys/time.h>
#include <ctime>
#endif
#ifdef LINUX_BUILD // Linux
uint64_t GetTimeMs64()
{
struct timeval tv;
gettimeofday(&tv, NULL);
uint64_t ret = tv.tv_usec;
// Convert from micro seconds (10^-6) to milliseconds (10^-3)
ret /= 1000;
// Adds the seconds (10^0) after converting them to milliseconds (10^-3)
ret += (tv.tv_sec * 1000);
return ret;
}
#else // Windows
uint64_t GetTimeMs64()
{
FILETIME ft;
LARGE_INTEGER li;
// Get the amount of 100 nano seconds intervals elapsed since January 1, 1601 (UTC)
// and copy it to a LARGE_INTEGER structure.
GetSystemTimeAsFileTime(&ft);
li.LowPart = ft.dwLowDateTime;
li.HighPart = ft.dwHighDateTime;
uint64_t ret = li.QuadPart;
// Convert from file time to UNIX epoch time.
ret -= 116444736000000000LL;
// From 100 nano seconds (10^-7) to 1 millisecond (10^-3) intervals
ret /= 10000;
return ret;
}
#endif

@ -1,54 +0,0 @@
/*
https://github.com/peterix/dfhack
Copyright (c) 2009-2011 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 TERMUTIL_H
#define TERMUTIL_H
#ifdef LINUX_BUILD
// FIXME: is this ever true?
bool TemporaryTerminal ()
{
return false;
}
#else
#include <windows.h>
#include <stdio.h>
#include <conio.h>
bool TemporaryTerminal ()
{
CONSOLE_SCREEN_BUFFER_INFO csbi;
HANDLE hStdOutput;
hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE);
if (!GetConsoleScreenBufferInfo(hStdOutput, &csbi))
{
printf("GetConsoleScreenBufferInfo failed: %d\n", GetLastError());
return false;
}
return ((!csbi.dwCursorPosition.X) && (!csbi.dwCursorPosition.Y));
};
#endif // LINUX_BUILD
#endif

@ -29,8 +29,8 @@ distribution.
* \defgroup grp_buildings Building module parts - also includes zones and stockpiles * \defgroup grp_buildings Building module parts - also includes zones and stockpiles
* @ingroup grp_modules * @ingroup grp_modules
*/ */
#include "dfhack/Export.h" #include "Export.h"
#include "dfhack/Module.h" #include "Module.h"
#ifdef __cplusplus #ifdef __cplusplus
namespace DFHack namespace DFHack

@ -28,8 +28,8 @@ distribution.
/* /*
* DF constructions * DF constructions
*/ */
#include "dfhack/Export.h" #include "Export.h"
#include "dfhack/Module.h" #include "Module.h"
/** /**
* \defgroup grp_constructions Construction module parts * \defgroup grp_constructions Construction module parts

@ -28,8 +28,8 @@ distribution.
/* /*
* DF engravings * DF engravings
*/ */
#include "dfhack/Export.h" #include "Export.h"
#include "dfhack/Module.h" #include "Module.h"
/** /**
* \defgroup grp_engraving Engraving module parts * \defgroup grp_engraving Engraving module parts

@ -1,6 +1,6 @@
/* /*
https://github.com/peterix/dfhack https://github.com/peterix/dfhack
Copyright (c) 2009-2011 Petr Mrázek (peterix@gmail.com) Copyright (c) 2009-2011 Petr Mr<EFBFBD>zek (peterix@gmail.com)
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any warranty. In no event will the authors be held liable for any
@ -31,8 +31,8 @@ distribution.
#define CL_MOD_GRAPHIC #define CL_MOD_GRAPHIC
#include <stdint.h> #include <stdint.h>
#include "dfhack/Export.h" #include "Export.h"
#include "dfhack/Module.h" #include "Module.h"
namespace DFHack namespace DFHack
{ {

@ -26,10 +26,10 @@ distribution.
#ifndef CL_MOD_GUI #ifndef CL_MOD_GUI
#define CL_MOD_GUI #define CL_MOD_GUI
#include "dfhack/Export.h" #include "Export.h"
#include "dfhack/Module.h" #include "Module.h"
#include "dfhack/Virtual.h" #include "Virtual.h"
#include "dfhack/BitArray.h" #include "BitArray.h"
#include <string> #include <string>
/** /**

@ -26,12 +26,12 @@ distribution.
/* /*
* Items! * Items!
*/ */
#include "dfhack/Export.h" #include "Export.h"
#include "dfhack/Module.h" #include "Module.h"
#include "dfhack/Types.h" #include "Types.h"
#include "dfhack/Virtual.h" #include "Virtual.h"
#include "dfhack/modules/Materials.h" #include "modules/Materials.h"
#include "dfhack/Process.h" #include "MemAccess.h"
/** /**
* \defgroup grp_items Items module and its types * \defgroup grp_items Items module and its types
* @ingroup grp_modules * @ingroup grp_modules

@ -26,8 +26,8 @@ distribution.
#ifndef MAPEXTRAS_H #ifndef MAPEXTRAS_H
#define MAPEXTRAS_H #define MAPEXTRAS_H
#include "dfhack/modules/Maps.h" #include "modules/Maps.h"
#include "dfhack/TileTypes.h" #include "TileTypes.h"
#include <stdint.h> #include <stdint.h>
#include <cstring> #include <cstring>
namespace MapExtras namespace MapExtras

@ -30,12 +30,12 @@ distribution.
#ifndef CL_MOD_MAPS #ifndef CL_MOD_MAPS
#define CL_MOD_MAPS #define CL_MOD_MAPS
#include "dfhack/Export.h" #include "Export.h"
#include "dfhack/Module.h" #include "Module.h"
#include "dfhack/modules/Vegetation.h" #include "modules/Vegetation.h"
#include <vector> #include <vector>
#include "dfhack/Virtual.h" #include "Virtual.h"
#include "dfhack/BitArray.h" #include "BitArray.h"
#include "Materials.h" #include "Materials.h"
/** /**

@ -29,10 +29,10 @@ distribution.
* \defgroup grp_materials Materials module - used for reading raws mostly * \defgroup grp_materials Materials module - used for reading raws mostly
* @ingroup grp_modules * @ingroup grp_modules
*/ */
#include "dfhack/Export.h" #include "Export.h"
#include "dfhack/Module.h" #include "Module.h"
#include "dfhack/Types.h" #include "Types.h"
#include "dfhack/BitArray.h" #include "BitArray.h"
#include <vector> #include <vector>
#include <string> #include <string>

@ -5,8 +5,8 @@
* \defgroup grp_notes In game notes (and routes) * \defgroup grp_notes In game notes (and routes)
* @ingroup grp_notes * @ingroup grp_notes
*/ */
#include "dfhack/Export.h" #include "Export.h"
#include "dfhack/Module.h" #include "Module.h"
#include <vector> #include <vector>
#include <string> #include <string>

@ -30,9 +30,9 @@ distribution.
* @ingroup grp_modules * @ingroup grp_modules
*/ */
#include "dfhack/Export.h" #include "Export.h"
#include "dfhack/Module.h" #include "Module.h"
#include "dfhack/Types.h" #include "Types.h"
namespace DFHack namespace DFHack
{ {

@ -28,9 +28,9 @@ distribution.
/* /*
* Creatures * Creatures
*/ */
#include "dfhack/Export.h" #include "Export.h"
#include "dfhack/Module.h" #include "Module.h"
#include "dfhack/modules/Items.h" #include "modules/Items.h"
/** /**
* \defgroup grp_units Unit module parts * \defgroup grp_units Unit module parts
* @ingroup grp_modules * @ingroup grp_modules

@ -30,9 +30,9 @@ distribution.
* @ingroup grp_modules * @ingroup grp_modules
*/ */
#include "dfhack/Export.h" #include "Export.h"
#include "dfhack/Module.h" #include "Module.h"
#include "dfhack/Types.h" #include "Types.h"
namespace DFHack namespace DFHack
{ {
/** /**

@ -5,8 +5,8 @@
* \defgroup grp_vermin Wild vermin (ants, bees, etc) * \defgroup grp_vermin Wild vermin (ants, bees, etc)
* @ingroup grp_vermin * @ingroup grp_vermin
*/ */
#include "dfhack/Export.h" #include "Export.h"
#include "dfhack/Module.h" #include "Module.h"
#ifdef __cplusplus #ifdef __cplusplus
namespace DFHack namespace DFHack

@ -31,8 +31,8 @@ distribution.
* @ingroup grp_modules * @ingroup grp_modules
*/ */
#include "dfhack/Export.h" #include "Export.h"
#include "dfhack/Module.h" #include "Module.h"
#include <ostream> #include <ostream>
namespace DFHack namespace DFHack

@ -26,13 +26,13 @@ distribution.
/* /*
* kitchen settings * kitchen settings
*/ */
#include "dfhack/Export.h" #include "Export.h"
#include "dfhack/Module.h" #include "Module.h"
#include "dfhack/Types.h" #include "Types.h"
#include "dfhack/VersionInfo.h" #include "VersionInfo.h"
#include "dfhack/modules/Materials.h" #include "modules/Materials.h"
#include "dfhack/modules/Items.h" #include "modules/Items.h"
#include <dfhack/Core.h> #include "Core.h"
/** /**
* \defgroup grp_kitchen Kitchen settings * \defgroup grp_kitchen Kitchen settings
* @ingroup grp_modules * @ingroup grp_modules

@ -30,14 +30,14 @@ distribution.
#include <map> #include <map>
using namespace std; using namespace std;
#include "dfhack/VersionInfo.h" #include "VersionInfo.h"
#include "dfhack/Process.h" #include "MemAccess.h"
#include "dfhack/Vector.h" #include "Vector.h"
#include "dfhack/Types.h" #include "Types.h"
#include "dfhack/Error.h" #include "Error.h"
#include "dfhack/modules/Buildings.h" #include "modules/Buildings.h"
#include "ModuleFactory.h" #include "ModuleFactory.h"
#include "dfhack/Core.h" #include "Core.h"
using namespace DFHack; using namespace DFHack;
//raw //raw

@ -31,13 +31,13 @@ distribution.
using namespace std; using namespace std;
#include "dfhack/VersionInfo.h" #include "VersionInfo.h"
#include "dfhack/Process.h" #include "MemAccess.h"
#include "dfhack/Vector.h" #include "Vector.h"
#include "dfhack/Types.h" #include "Types.h"
#include "dfhack/modules/Constructions.h" #include "modules/Constructions.h"
#include "ModuleFactory.h" #include "ModuleFactory.h"
#include "dfhack/Core.h" #include "Core.h"
using namespace DFHack; using namespace DFHack;

@ -30,13 +30,13 @@ distribution.
#include <map> #include <map>
using namespace std; using namespace std;
#include "dfhack/VersionInfo.h" #include "VersionInfo.h"
#include "dfhack/Process.h" //#include "MemAccess.h"
#include "dfhack/Vector.h" #include "Vector.h"
#include "dfhack/Types.h" #include "Types.h"
#include "dfhack/modules/Engravings.h" #include "modules/Engravings.h"
#include "ModuleFactory.h" #include "ModuleFactory.h"
#include "dfhack/Core.h" #include "Core.h"
using namespace DFHack; using namespace DFHack;

@ -1,6 +1,6 @@
/* /*
https://github.com/peterix/dfhack https://github.com/peterix/dfhack
Copyright (c) 2009-2011 Petr Mrázek (peterix@gmail.com) Copyright (c) 2009-2011 Petr Mr<EFBFBD>zek (peterix@gmail.com)
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any warranty. In no event will the authors be held liable for any
@ -33,13 +33,13 @@ distribution.
#include <cstdlib> #include <cstdlib>
using namespace std; using namespace std;
#include "dfhack/modules/Graphic.h" #include "modules/Graphic.h"
#include "dfhack/Error.h" #include "Error.h"
#include "dfhack/VersionInfo.h" #include "VersionInfo.h"
#include "dfhack/Process.h" #include "MemAccess.h"
#include "dfhack/Vector.h" #include "Vector.h"
#include "ModuleFactory.h" #include "ModuleFactory.h"
#include <dfhack/Core.h> #include "Core.h"
using namespace DFHack; using namespace DFHack;

@ -30,13 +30,13 @@ distribution.
#include <map> #include <map>
using namespace std; using namespace std;
#include "dfhack/modules/Gui.h" #include "modules/Gui.h"
#include "dfhack/Process.h" #include "MemAccess.h"
#include "dfhack/VersionInfo.h" #include "VersionInfo.h"
#include "dfhack/Types.h" #include "Types.h"
#include "dfhack/Error.h" #include "Error.h"
#include "ModuleFactory.h" #include "ModuleFactory.h"
#include "dfhack/Core.h" #include "Core.h"
using namespace DFHack; using namespace DFHack;
Module* DFHack::createGui() Module* DFHack::createGui()

@ -33,16 +33,16 @@ distribution.
#include <set> #include <set>
using namespace std; using namespace std;
#include "dfhack/Types.h" #include "Types.h"
#include "dfhack/VersionInfo.h" #include "VersionInfo.h"
#include "dfhack/Process.h" #include "MemAccess.h"
#include "dfhack/Vector.h" #include "Vector.h"
#include "dfhack/modules/Materials.h" #include "modules/Materials.h"
#include "dfhack/modules/Items.h" #include "modules/Items.h"
#include "dfhack/modules/Units.h" #include "modules/Units.h"
#include "ModuleFactory.h" #include "ModuleFactory.h"
#include <dfhack/Core.h> #include "Core.h"
#include <dfhack/Virtual.h> #include "Virtual.h"
using namespace DFHack; using namespace DFHack;

@ -33,13 +33,13 @@ distribution.
#include <cstdlib> #include <cstdlib>
using namespace std; using namespace std;
#include "dfhack/modules/Maps.h" #include "modules/Maps.h"
#include "dfhack/Error.h" #include "Error.h"
#include "dfhack/VersionInfo.h" #include "VersionInfo.h"
#include "dfhack/Process.h" #include "MemAccess.h"
#include "dfhack/Vector.h" #include "Vector.h"
#include "ModuleFactory.h" #include "ModuleFactory.h"
#include <dfhack/Core.h> #include "Core.h"
#define MAPS_GUARD if(!d->Started) throw DFHack::Error::ModuleNotInitialized(); #define MAPS_GUARD if(!d->Started) throw DFHack::Error::ModuleNotInitialized();

@ -31,14 +31,14 @@ distribution.
#include <cstring> #include <cstring>
using namespace std; using namespace std;
#include "dfhack/Types.h" #include "Types.h"
#include "dfhack/modules/Materials.h" #include "modules/Materials.h"
#include "dfhack/VersionInfo.h" #include "VersionInfo.h"
#include "dfhack/Process.h" #include "MemAccess.h"
#include "dfhack/Vector.h" #include "Vector.h"
#include <dfhack/Error.h> #include "Error.h"
#include "ModuleFactory.h" #include "ModuleFactory.h"
#include <dfhack/Core.h> #include "Core.h"
using namespace DFHack; using namespace DFHack;

@ -29,13 +29,13 @@ distribution.
#include <map> #include <map>
using namespace std; using namespace std;
#include "dfhack/VersionInfo.h" #include "VersionInfo.h"
#include "dfhack/Types.h" #include "Types.h"
#include "dfhack/Error.h" #include "Error.h"
#include "dfhack/Process.h" #include "MemAccess.h"
#include "ModuleFactory.h" #include "ModuleFactory.h"
#include "dfhack/Core.h" #include "Core.h"
#include "dfhack/modules/Notes.h" #include "modules/Notes.h"
using namespace DFHack; using namespace DFHack;
Module* DFHack::createNotes() Module* DFHack::createNotes()

@ -30,13 +30,13 @@ distribution.
#include <cassert> #include <cassert>
using namespace std; using namespace std;
#include "dfhack/modules/Translation.h" #include "modules/Translation.h"
#include "dfhack/VersionInfo.h" #include "VersionInfo.h"
#include "dfhack/Process.h" #include "MemAccess.h"
#include "dfhack/Vector.h" #include "Vector.h"
#include "dfhack/Types.h" #include "Types.h"
#include "ModuleFactory.h" #include "ModuleFactory.h"
#include <dfhack/Core.h> #include "Core.h"
using namespace DFHack; using namespace DFHack;
Module* DFHack::createTranslation() Module* DFHack::createTranslation()

@ -34,18 +34,18 @@ distribution.
using namespace std; using namespace std;
#include "dfhack/VersionInfo.h" #include "VersionInfo.h"
#include "dfhack/Process.h" #include "MemAccess.h"
#include "dfhack/Vector.h" #include "Vector.h"
#include "dfhack/Error.h" #include "Error.h"
#include "dfhack/Types.h" #include "Types.h"
// we connect to those // we connect to those
#include "dfhack/modules/Materials.h" #include "modules/Materials.h"
#include "dfhack/modules/Units.h" #include "modules/Units.h"
#include "dfhack/modules/Translation.h" #include "modules/Translation.h"
#include "ModuleFactory.h" #include "ModuleFactory.h"
#include <dfhack/Core.h> #include "Core.h"
using namespace DFHack; using namespace DFHack;

@ -30,14 +30,14 @@ distribution.
#include <map> #include <map>
using namespace std; using namespace std;
#include "dfhack/VersionInfo.h" #include "VersionInfo.h"
#include "dfhack/Process.h" #include "MemAccess.h"
#include "dfhack/Vector.h" #include "Vector.h"
#include "dfhack/Types.h" #include "Types.h"
#include "dfhack/modules/Vegetation.h" #include "modules/Vegetation.h"
#include "dfhack/modules/Translation.h" #include "modules/Translation.h"
#include "ModuleFactory.h" #include "ModuleFactory.h"
#include <dfhack/Core.h> #include "Core.h"
using namespace DFHack; using namespace DFHack;
Module* DFHack::createVegetation() Module* DFHack::createVegetation()

@ -29,13 +29,13 @@ distribution.
#include <map> #include <map>
using namespace std; using namespace std;
#include "dfhack/VersionInfo.h" #include "VersionInfo.h"
#include "dfhack/Types.h" #include "Types.h"
#include "dfhack/Error.h" #include "Error.h"
#include "dfhack/Process.h" #include "MemAccess.h"
#include "dfhack/modules/Vermin.h" #include "modules/Vermin.h"
#include "ModuleFactory.h" #include "ModuleFactory.h"
#include "dfhack/Core.h" #include "Core.h"
using namespace DFHack; using namespace DFHack;
struct Vermin::Private struct Vermin::Private
@ -106,7 +106,6 @@ SpawnPoints* Vermin::getSpawnPoints()
cerr << "Couldn't get spawn points: Vermin module not inited" << endl; cerr << "Couldn't get spawn points: Vermin module not inited" << endl;
return NULL; return NULL;
} }
return new SpawnPoints(this); return new SpawnPoints(this);
} }
@ -120,15 +119,11 @@ SpawnPoints::SpawnPoints(Vermin* v_)
cerr << "Couldn't get spawn points: Vermin module not inited" << endl; cerr << "Couldn't get spawn points: Vermin module not inited" << endl;
return; return;
} }
//p_sp = new DfVector <uint32_t> (v->d->spawn_points_vector);
//p_sp = new vector <void*> (v->d->spawn_points_vector);
p_sp = (vector <void*>*) (v->d->spawn_points_vector); p_sp = (vector <void*>*) (v->d->spawn_points_vector);
} }
SpawnPoints::~SpawnPoints() SpawnPoints::~SpawnPoints()
{ {
// Do NOT delete p_sp; it's a pointer to memory the game owns.
} }
size_t SpawnPoints::size() size_t SpawnPoints::size()

@ -30,13 +30,13 @@ distribution.
#include <cstring> #include <cstring>
using namespace std; using namespace std;
#include "dfhack/modules/World.h" #include "modules/World.h"
#include "dfhack/Process.h" #include "MemAccess.h"
#include "dfhack/VersionInfo.h" #include "VersionInfo.h"
#include "dfhack/Types.h" #include "Types.h"
#include "dfhack/Error.h" #include "Error.h"
#include "ModuleFactory.h" #include "ModuleFactory.h"
#include <dfhack/Core.h> #include "Core.h"
using namespace DFHack; using namespace DFHack;

@ -9,17 +9,17 @@
#include <set> #include <set>
using namespace std; using namespace std;
#include "dfhack/Types.h" #include "Types.h"
#include "dfhack/VersionInfo.h" #include "VersionInfo.h"
#include "dfhack/Process.h" #include "MemAccess.h"
#include "dfhack/Vector.h" #include "Vector.h"
#include "dfhack/modules/Materials.h" #include "modules/Materials.h"
#include "dfhack/modules/Items.h" #include "modules/Items.h"
#include "dfhack/modules/Units.h" #include "modules/Units.h"
#include "dfhack/modules/kitchen.h" #include "modules/kitchen.h"
#include "ModuleFactory.h" #include "ModuleFactory.h"
#include <dfhack/Core.h> #include "Core.h"
#include <dfhack/Virtual.h> #include "Virtual.h"
namespace DFHack namespace DFHack
{ {

@ -1,9 +1,9 @@
#include <dfhack/Core.h> #include "Core.h"
#include <dfhack/Console.h> #include "Console.h"
#include <dfhack/Export.h> #include "Export.h"
#include <dfhack/PluginManager.h> #include "PluginManager.h"
#include <dfhack/Process.h> #include "MemAccess.h"
#include "dfhack/extra/stopwatch.h" #include "MiscUtils.h"
#include <vector> #include <vector>
#include <string> #include <string>

@ -1,8 +1,8 @@
#ifndef HEXSEARCH_H #ifndef HEXSEARCH_H
#define HEXSEARCH_H #define HEXSEARCH_H
#include <vector> #include <vector>
#include "dfhack/Core.h" //for some reason process.h needs core #include "Core.h" //for some reason process.h needs core
#include "dfhack/Process.h" #include "MemAccess.h"
//(not yet)implemented using Boyer-Moore algorithm //(not yet)implemented using Boyer-Moore algorithm

@ -1,6 +1,6 @@
#ifndef LUA_CONSOLE_H #ifndef LUA_CONSOLE_H
#define LUA_CONSOLE_H #define LUA_CONSOLE_H
#include <dfhack/Console.h> #include <Console.h>
#include "luamain.h" #include "luamain.h"
namespace lua namespace lua

@ -3,8 +3,8 @@
#include <map> #include <map>
#include <dfhack/Core.h> #include "Core.h"
#include <dfhack/Process.h> #include <MemAccess.h>
#include "luamain.h" #include "luamain.h"
#include "OutFile.h" #include "OutFile.h"
#include "bit.h" #include "bit.h"

@ -1,8 +1,8 @@
#ifndef LUA_PROCESS_H #ifndef LUA_PROCESS_H
#define LUA_PROCESS_H #define LUA_PROCESS_H
#include <dfhack/Core.h> #include "Core.h"
#include <dfhack/Process.h> #include <MemAccess.h>
#include "luamain.h" #include "luamain.h"

@ -1,7 +1,7 @@
#ifndef LUA_VERSIONINFO_H #ifndef LUA_VERSIONINFO_H
#define LUA_VERSIONINFO_H #define LUA_VERSIONINFO_H
#include <dfhack/Core.h> #include "Core.h"
#include <dfhack/VersionInfo.h> #include <VersionInfo.h>
#include "luamain.h" #include "luamain.h"
namespace lua namespace lua
{ {

@ -8,19 +8,19 @@
#include <set> #include <set>
using namespace std; using namespace std;
#include <dfhack/Core.h> #include "Core.h"
#include <dfhack/Console.h> #include <Console.h>
#include <dfhack/Export.h> #include <Export.h>
#include <dfhack/PluginManager.h> #include <PluginManager.h>
#include <vector> #include <vector>
#include <string> #include <string>
#include <algorithm> #include <algorithm>
#include <dfhack/modules/Maps.h> #include <modules/Maps.h>
#include <dfhack/modules/Gui.h> #include <modules/Gui.h>
#include <dfhack/modules/Items.h> #include <modules/Items.h>
#include <dfhack/modules/Materials.h> #include <modules/Materials.h>
#include <dfhack/extra/MapExtras.h> #include <modules/MapCache.h>
using namespace DFHack; using namespace DFHack;
using MapExtras::Block; using MapExtras::Block;

@ -1,11 +1,11 @@
#include <dfhack/Core.h> #include "Core.h"
#include <dfhack/Console.h> #include <Console.h>
#include <dfhack/Export.h> #include <Export.h>
#include <dfhack/PluginManager.h> #include <PluginManager.h>
#include <dfhack/modules/Maps.h> #include <modules/Maps.h>
#include <dfhack/modules/Items.h> #include <modules/Items.h>
#include <dfhack/modules/Units.h> #include <modules/Units.h>
#include <dfhack/modules/Gui.h> #include <modules/Gui.h>
using namespace DFHack; using namespace DFHack;

@ -8,17 +8,17 @@
#include <set> #include <set>
using namespace std; using namespace std;
#include <dfhack/Core.h> #include "Core.h"
#include <dfhack/Console.h> #include <Console.h>
#include <dfhack/Export.h> #include <Export.h>
#include <dfhack/PluginManager.h> #include <PluginManager.h>
#include <vector> #include <vector>
#include <string> #include <string>
#include <dfhack/modules/Maps.h> #include <modules/Maps.h>
#include <dfhack/modules/Items.h> #include <modules/Items.h>
#include <dfhack/modules/Units.h> #include <modules/Units.h>
#include <dfhack/modules/Materials.h> #include <modules/Materials.h>
#include <dfhack/modules/Translation.h> #include <modules/Translation.h>
using namespace DFHack; using namespace DFHack;
DFhackCExport command_result df_cleanowned (Core * c, vector <string> & parameters); DFhackCExport command_result df_cleanowned (Core * c, vector <string> & parameters);

@ -1,10 +1,10 @@
#include <dfhack/Core.h> #include "Core.h"
#include <dfhack/Console.h> #include <Console.h>
#include <dfhack/Export.h> #include <Export.h>
#include <dfhack/PluginManager.h> #include <PluginManager.h>
#include <vector> #include <vector>
#include <string> #include <string>
#include <dfhack/modules/Vermin.h> #include <modules/Vermin.h>
using std::vector; using std::vector;
using std::string; using std::string;

@ -7,12 +7,12 @@
#include <assert.h> #include <assert.h>
#include <string.h> #include <string.h>
using namespace std; using namespace std;
#include <dfhack/Core.h> #include "Core.h"
#include <dfhack/Console.h> #include <Console.h>
#include <dfhack/Export.h> #include <Export.h>
#include <dfhack/PluginManager.h> #include <PluginManager.h>
#include <dfhack/modules/Maps.h> #include <modules/Maps.h>
#include <dfhack/TileTypes.h> #include <TileTypes.h>
using namespace DFHack; using namespace DFHack;
DFhackCExport command_result df_deramp (Core * c, vector <string> & parameters); DFhackCExport command_result df_deramp (Core * c, vector <string> & parameters);

@ -1,13 +1,13 @@
//Quick building occupancy flag test. //Quick building occupancy flag test.
//Individual bits had no apparent meaning. Assume it's an enum, set by number. //Individual bits had no apparent meaning. Assume it's an enum, set by number.
#include <dfhack/Core.h> #include "Core.h"
#include <dfhack/Console.h> #include <Console.h>
#include <dfhack/Export.h> #include <Export.h>
#include <dfhack/PluginManager.h> #include <PluginManager.h>
#include <dfhack/modules/Maps.h> #include <modules/Maps.h>
#include <dfhack/modules/Gui.h> #include <modules/Gui.h>
#include <dfhack/extra/MapExtras.h> #include <modules/MapCache.h>
#include <vector> #include <vector>
#include <cstdio> #include <cstdio>
#include <stack> #include <stack>

@ -1,8 +1,8 @@
#include <dfhack/Core.h> #include "Core.h"
#include <dfhack/Export.h> #include <Export.h>
#include <dfhack/PluginManager.h> #include <PluginManager.h>
#include <dfhack/modules/Items.h> #include <modules/Items.h>
#include <dfhack/modules/Gui.h> #include <modules/Gui.h>
#include <vector> #include <vector>
#include <string> #include <string>
#include <string.h> #include <string.h>

@ -1,13 +1,13 @@
#include <dfhack/Core.h> #include "Core.h"
#include <dfhack/Console.h> #include "Console.h"
#include <dfhack/Export.h> #include "Export.h"
#include <dfhack/PluginManager.h> #include "PluginManager.h"
#include "MiscUtils.h"
#include <vector> #include <vector>
#include <string> #include <string>
#include "dfhack/extra/stopwatch.h" #include "modules/Maps.h"
#include "dfhack/modules/Maps.h" #include "modules/Items.h"
#include "dfhack/modules/Items.h" #include <modules/Gui.h>
#include <dfhack/modules/Gui.h>
#include <llimits.h> #include <llimits.h>
using std::vector; using std::vector;
@ -329,8 +329,8 @@ DFhackCExport command_result kittens (Core * c, vector <string> & parameters)
} }
} }
#include "dfhack/modules/Units.h" #include "modules/Units.h"
#include "dfhack/VersionInfo.h" #include "VersionInfo.h"
#include <stddef.h> #include <stddef.h>
command_result test_creature_offsets(Core* c, vector< string >& parameters) command_result test_creature_offsets(Core* c, vector< string >& parameters)

@ -1,194 +1,194 @@
#include <dfhack/Core.h> #include "Core.h"
#include <dfhack/Console.h> #include "Console.h"
#include <dfhack/PluginManager.h> #include "PluginManager.h"
#include <dfhack/Process.h> #include "MemAccess.h"
#include <dfhack/extra/stopwatch.h> #include "MiscUtils.h"
#include <../depends/tthread/tinythread.h> //not sure if correct #include <../depends/tthread/tinythread.h> //not sure if correct
#include <string> #include <string>
#include <vector> #include <vector>
#include <sstream> #include <sstream>
using std::vector; using std::vector;
using std::string; using std::string;
using namespace DFHack; using namespace DFHack;
uint64_t timeLast=0; uint64_t timeLast=0;
static tthread::mutex* mymutex=0; static tthread::mutex* mymutex=0;
struct memory_data struct memory_data
{ {
size_t addr; size_t addr;
size_t len; size_t len;
size_t refresh; size_t refresh;
int state; int state;
uint8_t *buf,*lbuf; uint8_t *buf,*lbuf;
vector<t_memrange> ranges; vector<t_memrange> ranges;
}memdata; }memdata;
enum HEXVIEW_STATES enum HEXVIEW_STATES
{ {
STATE_OFF,STATE_ON STATE_OFF,STATE_ON
}; };
DFhackCExport command_result memview (Core * c, vector <string> & parameters); DFhackCExport command_result memview (Core * c, vector <string> & parameters);
DFhackCExport const char * plugin_name ( void ) DFhackCExport const char * plugin_name ( void )
{ {
return "memview"; return "memview";
} }
DFhackCExport command_result plugin_init ( Core * c, std::vector <PluginCommand> &commands) DFhackCExport command_result plugin_init ( Core * c, std::vector <PluginCommand> &commands)
{ {
commands.clear(); commands.clear();
commands.push_back(PluginCommand("memview","Shows memory in real time. Params: adrr length refresh_rate. If addr==0 then stop viewing",memview)); 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; memdata.state=STATE_OFF;
mymutex=new tthread::mutex; mymutex=new tthread::mutex;
return CR_OK; return CR_OK;
} }
size_t convert(const std::string& p,bool ishex=false) size_t convert(const std::string& p,bool ishex=false)
{ {
size_t ret; size_t ret;
std::stringstream conv; std::stringstream conv;
if(ishex) if(ishex)
conv<<std::hex; conv<<std::hex;
conv<<p; conv<<p;
conv>>ret; conv>>ret;
return ret; return ret;
} }
bool isAddr(uint32_t *trg,vector<t_memrange> & ranges) bool isAddr(uint32_t *trg,vector<t_memrange> & ranges)
{ {
if(trg[0]%4==0) if(trg[0]%4==0)
for(size_t i=0;i<ranges.size();i++) for(size_t i=0;i<ranges.size();i++)
if(ranges[i].isInRange(trg[0])) if(ranges[i].isInRange(trg[0]))
return true; return true;
return false; return false;
} }
void outputHex(uint8_t *buf,uint8_t *lbuf,size_t len,size_t start,Core *c,vector<t_memrange> & ranges) void outputHex(uint8_t *buf,uint8_t *lbuf,size_t len,size_t start,Core *c,vector<t_memrange> & ranges)
{ {
Console &con=c->con; Console &con=c->con;
const size_t page_size=16; const size_t page_size=16;
con.clear(); con.clear();
for(size_t i=0;i<len;i+=page_size) for(size_t i=0;i<len;i+=page_size)
{ {
con.gotoxy(1,i/page_size+1); con.gotoxy(1,i/page_size+1);
con.print("0x%08X ",i+start); con.print("0x%08X ",i+start);
for(size_t j=0;(j<page_size) && (i+j<len);j++) for(size_t j=0;(j<page_size) && (i+j<len);j++)
{ {
if(j%4==0) if(j%4==0)
{ {
con.reset_color(); con.reset_color();
if(isAddr((uint32_t *)(buf+j+i),ranges)) if(isAddr((uint32_t *)(buf+j+i),ranges))
con.color(Console::COLOR_LIGHTRED); //coloring in the middle does not work con.color(Console::COLOR_LIGHTRED); //coloring in the middle does not work
//TODO make something better? //TODO make something better?
} }
if(lbuf[j+i]!=buf[j+i]) if(lbuf[j+i]!=buf[j+i])
con.print("*%02X",buf[j+i]); //if modfied show a star con.print("*%02X",buf[j+i]); //if modfied show a star
else else
con.print(" %02X",buf[j+i]); con.print(" %02X",buf[j+i]);
} }
con.reset_color(); con.reset_color();
con.print(" | "); con.print(" | ");
for(size_t j=0;(j<page_size) && (i+j<len);j++) for(size_t j=0;(j<page_size) && (i+j<len);j++)
if((buf[j+i]>31)&&(buf[j+i]<128)) //only printable ascii if((buf[j+i]>31)&&(buf[j+i]<128)) //only printable ascii
con.print("%c",buf[j+i]); con.print("%c",buf[j+i]);
else else
con.print("."); con.print(".");
//con.print("\n"); //con.print("\n");
} }
con.print("\n"); con.print("\n");
con.flush(); con.flush();
} }
void Deinit() void Deinit()
{ {
if(memdata.state==STATE_ON) if(memdata.state==STATE_ON)
{ {
memdata.state=STATE_OFF; memdata.state=STATE_OFF;
delete [] memdata.buf; delete [] memdata.buf;
delete [] memdata.lbuf; delete [] memdata.lbuf;
} }
} }
DFhackCExport command_result plugin_onupdate ( Core * c ) DFhackCExport command_result plugin_onupdate ( Core * c )
{ {
mymutex->lock(); mymutex->lock();
if(memdata.state==STATE_OFF) if(memdata.state==STATE_OFF)
{ {
mymutex->unlock(); mymutex->unlock();
return CR_OK; return CR_OK;
} }
//Console &con=c->con; //Console &con=c->con;
uint64_t time2 = GetTimeMs64(); uint64_t time2 = GetTimeMs64();
uint64_t delta = time2-timeLast; uint64_t delta = time2-timeLast;
if(memdata.refresh!=0) if(memdata.refresh!=0)
if(delta<memdata.refresh) if(delta<memdata.refresh)
{ {
mymutex->unlock(); mymutex->unlock();
return CR_OK; return CR_OK;
} }
timeLast = time2; timeLast = time2;
c->p->read(memdata.addr,memdata.len,memdata.buf); c->p->read(memdata.addr,memdata.len,memdata.buf);
outputHex(memdata.buf,memdata.lbuf,memdata.len,memdata.addr,c,memdata.ranges); outputHex(memdata.buf,memdata.lbuf,memdata.len,memdata.addr,c,memdata.ranges);
memcpy(memdata.lbuf, memdata.buf, memdata.len); memcpy(memdata.lbuf, memdata.buf, memdata.len);
if(memdata.refresh==0) if(memdata.refresh==0)
Deinit(); Deinit();
mymutex->unlock(); mymutex->unlock();
return CR_OK; return CR_OK;
} }
DFhackCExport command_result memview (Core * c, vector <string> & parameters) DFhackCExport command_result memview (Core * c, vector <string> & parameters)
{ {
mymutex->lock(); mymutex->lock();
c->p->getMemRanges(memdata.ranges); c->p->getMemRanges(memdata.ranges);
memdata.addr=convert(parameters[0],true); memdata.addr=convert(parameters[0],true);
if(memdata.addr==0) if(memdata.addr==0)
{ {
Deinit(); Deinit();
memdata.state=STATE_OFF; memdata.state=STATE_OFF;
mymutex->unlock(); mymutex->unlock();
return CR_OK; return CR_OK;
} }
else else
{ {
Deinit(); Deinit();
bool isValid=false; bool isValid=false;
for(size_t i=0;i<memdata.ranges.size();i++) for(size_t i=0;i<memdata.ranges.size();i++)
if(memdata.ranges[i].isInRange(memdata.addr)) if(memdata.ranges[i].isInRange(memdata.addr))
isValid=true; isValid=true;
if(!isValid) if(!isValid)
{ {
c->con.printerr("Invalid address:%x\n",memdata.addr); c->con.printerr("Invalid address:%x\n",memdata.addr);
mymutex->unlock(); mymutex->unlock();
return CR_OK; return CR_OK;
} }
memdata.state=STATE_ON; memdata.state=STATE_ON;
} }
if(parameters.size()>1) if(parameters.size()>1)
memdata.len=convert(parameters[1]); memdata.len=convert(parameters[1]);
else else
memdata.len=20*16; memdata.len=20*16;
if(parameters.size()>2) if(parameters.size()>2)
memdata.refresh=convert(parameters[2]); memdata.refresh=convert(parameters[2]);
else else
memdata.refresh=0; memdata.refresh=0;
uint8_t *buf,*lbuf; uint8_t *buf,*lbuf;
memdata.buf=new uint8_t[memdata.len]; memdata.buf=new uint8_t[memdata.len];
memdata.lbuf=new uint8_t[memdata.len]; memdata.lbuf=new uint8_t[memdata.len];
c->p->getMemRanges(memdata.ranges); c->p->getMemRanges(memdata.ranges);
mymutex->unlock(); mymutex->unlock();
return CR_OK; return CR_OK;
} }
DFhackCExport command_result plugin_shutdown ( Core * c ) DFhackCExport command_result plugin_shutdown ( Core * c )
{ {
mymutex->lock(); mymutex->lock();
Deinit(); Deinit();
delete mymutex; delete mymutex;
mymutex->unlock(); mymutex->unlock();
return CR_OK; return CR_OK;
} }

@ -1,10 +1,10 @@
#include <dfhack/Core.h> #include "Core.h"
#include <dfhack/Console.h> #include <Console.h>
#include <dfhack/Export.h> #include <Export.h>
#include <dfhack/PluginManager.h> #include <PluginManager.h>
#include <vector> #include <vector>
#include <string> #include <string>
#include <dfhack/modules/Notes.h> #include <modules/Notes.h>
using std::vector; using std::vector;
using std::string; using std::string;

@ -1,10 +1,10 @@
#include <dfhack/Core.h> #include "Core.h"
#include <dfhack/Console.h> #include <Console.h>
#include <dfhack/Export.h> #include <Export.h>
#include <dfhack/PluginManager.h> #include <PluginManager.h>
#include <vector> #include <vector>
#include <string> #include <string>
#include <dfhack/modules/Materials.h> #include <modules/Materials.h>
#include <stdlib.h> #include <stdlib.h>
using std::vector; using std::vector;

@ -7,15 +7,15 @@
using std::vector; using std::vector;
using std::string; using std::string;
#include <dfhack/Core.h> #include "Core.h"
#include <dfhack/Console.h> #include <Console.h>
#include <dfhack/Export.h> #include <Export.h>
#include <dfhack/PluginManager.h> #include <PluginManager.h>
#include <dfhack/modules/Vegetation.h> #include <modules/Vegetation.h>
#include <dfhack/modules/Maps.h> #include <modules/Maps.h>
#include <dfhack/modules/Gui.h> #include <modules/Gui.h>
#include <dfhack/TileTypes.h> #include <TileTypes.h>
#include <dfhack/extra/MapExtras.h> #include <extra/MapExtras.h>
using namespace MapExtras; using namespace MapExtras;
using namespace DFHack; using namespace DFHack;

@ -3,11 +3,11 @@
// //
// Linux only, enabled with BUILD_VECTORS cmake option. // Linux only, enabled with BUILD_VECTORS cmake option.
#include <dfhack/Core.h> #include "Core.h"
#include <dfhack/Console.h> #include <Console.h>
#include <dfhack/Export.h> #include <Export.h>
#include <dfhack/PluginManager.h> #include <PluginManager.h>
#include <dfhack/Process.h> #include <MemAccess.h>
#include <vector> #include <vector>
#include <string> #include <string>

@ -1 +1 @@
Subproject commit 8ffad51635ceeae55870106a75f3dd84b044ea5a Subproject commit 355674a508d72349983455f04791b4481b6c1515

@ -7,14 +7,14 @@
#include <set> #include <set>
using namespace std; using namespace std;
#include <dfhack/Core.h> #include "Core.h"
#include <dfhack/Console.h> #include <Console.h>
#include <dfhack/Export.h> #include <Export.h>
#include <dfhack/PluginManager.h> #include <PluginManager.h>
#include <vector> #include <vector>
#include <string> #include <string>
#include <algorithm> #include <algorithm>
#include <dfhack/modules/Items.h> #include <modules/Items.h>
using namespace DFHack; using namespace DFHack;

@ -8,12 +8,12 @@
#include <assert.h> #include <assert.h>
#include <string.h> #include <string.h>
using namespace std; using namespace std;
#include <dfhack/Core.h> #include "Core.h"
#include <dfhack/Console.h> #include <Console.h>
#include <dfhack/Export.h> #include <Export.h>
#include <dfhack/PluginManager.h> #include <PluginManager.h>
#include <dfhack/VersionInfo.h> #include <VersionInfo.h>
#include <dfhack/modules/Units.h> #include <modules/Units.h>
using namespace DFHack; using namespace DFHack;
// dfhack interface // dfhack interface

@ -5,13 +5,13 @@
#include <algorithm> //for min(). #include <algorithm> //for min().
#include <map> #include <map>
#include <vector> #include <vector>
#include <dfhack/Core.h> #include "Core.h"
#include <dfhack/Console.h> #include <Console.h>
#include <dfhack/Export.h> #include <Export.h>
#include <dfhack/PluginManager.h> #include <PluginManager.h>
#include <dfhack/modules/Maps.h> #include <modules/Maps.h>
#include <dfhack/extra/MapExtras.h> #include <modules/MapCache.h>
#include <dfhack/modules/Gui.h> #include <modules/Gui.h>
using std::stack; using std::stack;
using MapExtras::MapCache; using MapExtras::MapCache;
using namespace DFHack; using namespace DFHack;

@ -6,11 +6,11 @@
#include <stddef.h> #include <stddef.h>
#include <string.h> #include <string.h>
using namespace std; using namespace std;
#include <dfhack/Core.h> #include "Core.h"
#include <dfhack/Console.h> #include <Console.h>
#include <dfhack/Export.h> #include <Export.h>
#include <dfhack/PluginManager.h> #include <PluginManager.h>
#include <dfhack/modules/Maps.h> #include <modules/Maps.h>
using namespace DFHack; using namespace DFHack;
DFhackCExport command_result df_flows (Core * c, vector <string> & parameters); DFhackCExport command_result df_flows (Core * c, vector <string> & parameters);

Some files were not shown because too many files have changed in this diff Show More