The library is compilable under Linux with GCC and under Windows with
MinGW32 and MSVC compilers. It is using the cmake build system. See
COMPILE for details.
@@ -485,17 +490,17 @@ the dfhack repository is welcome and the right thing to do :)
code does have a lot of comments though (and getting better all the
time).
-
+
Several things should be kept in mind when contributing to DFHack.
-
+
DFhack uses ANSI formatting and four spaces as indentation. Line
endings are UNIX. The files use UTF-8 encoding. Code not following this
won't make me happy, because I'll have to fix it. There's a good chance
I'll make you fix it ;)
-
+
You can send patches or make a clone of the github repo and ask me on
the IRC channel to pull your code in. I'll review it and see if there
are any problems. I'll fix them if they are minor.
@@ -505,7 +510,7 @@ this is also a good place to dump new ideas and/or bugs that need
fixing.
-
+
DFHack uses modules to partition sets of features into manageable
chunks. A module can have both client and server side.
Client side is the part that goes into the main library and is
@@ -543,7 +548,7 @@ server, it allows accelerating the reading of map blocks.
pretty fast, but needs quite a bit of care to not break.
-
+
- Internal
- either part of the codebase or statically linked.
@@ -555,7 +560,7 @@ dependencies for core dfhack should be either public domain or require
attribution at most. External dependencies for tools can be either
that, or any Free Software licenses.
-
+
- tinyxml
- used by core dfhack to read offset definitions from Memory.xml
@@ -567,7 +572,7 @@ DF binaries on Linux.
-
+
- wide-character ncurses
- used for the veinlook tool on Linux.
@@ -576,7 +581,7 @@ DF binaries on Linux.
-
+
- cmake
- you need cmake to generate the build system and some configuration
@@ -587,7 +592,7 @@ headers
-
+
The files with memory offset definitions used by dfhack can be found in the
data folder.
diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt
index d66f0af51..8e09a2203 100644
--- a/library/CMakeLists.txt
+++ b/library/CMakeLists.txt
@@ -186,9 +186,17 @@ if(MSVC)
ADD_CUSTOM_COMMAND(TARGET dfhack POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/data/Memory.xml $(TargetDir)/Memory.xml
)
+ ADD_CUSTOM_COMMAND(TARGET dfhack POST_BUILD
+ COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/Compile.html $(TargetDir)/Compile.html
+ )
+ ADD_CUSTOM_COMMAND(TARGET dfhack POST_BUILD
+ COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/Readme.html $(TargetDir)/Readme.html
+ )
else(MSVC)
# Just put the file in the output directory on Linux and Mac
- configure_file(${CMAKE_SOURCE_DIR}/data/Memory-ng.xml ${DATA_OUTPUT_PATH}/Memory.xml COPYONLY)
+ configure_file(${CMAKE_SOURCE_DIR}/data/Memory.xml ${DATA_OUTPUT_PATH}/Memory.xml COPYONLY)
+ configure_file(${CMAKE_SOURCE_DIR}/Compile.html ${DATA_OUTPUT_PATH}/Compile.html COPYONLY)
+ configure_file(${CMAKE_SOURCE_DIR}/Readme.html ${DATA_OUTPUT_PATH}/Readme.html COPYONLY)
endif(MSVC)
IF(UNIX)
diff --git a/library/DFContext.cpp b/library/DFContext.cpp
index 15939dee9..d46302426 100644
--- a/library/DFContext.cpp
+++ b/library/DFContext.cpp
@@ -88,6 +88,7 @@ bool Context::Detach()
{
if (!d->p->detach())
{
+ cerr << "Context::Detach failed!" << endl;
return false;
}
d->shm_start = 0;
diff --git a/library/DFProcess-linux-SHM.cpp b/library/DFProcess-linux-SHM.cpp
index 9c8d9aab1..acf519ecf 100644
--- a/library/DFProcess-linux-SHM.cpp
+++ b/library/DFProcess-linux-SHM.cpp
@@ -569,10 +569,7 @@ bool SHMProcess::attach()
bool SHMProcess::detach()
{
- if(!d->attached)
- {
- return false;
- }
+ if(!d->attached) return true;
if(d->locked)
{
resume();
diff --git a/library/DFProcess-linux-wine.cpp b/library/DFProcess-linux-wine.cpp
index 6f288a078..b71e2266f 100644
--- a/library/DFProcess-linux-wine.cpp
+++ b/library/DFProcess-linux-wine.cpp
@@ -331,7 +331,7 @@ bool WineProcess::attach()
bool WineProcess::detach()
{
- if(!d->attached) return false;
+ if(!d->attached) return true;
if(!d->suspended) suspend();
int result = 0;
// close /proc/PID/mem
diff --git a/library/DFProcess-linux.cpp b/library/DFProcess-linux.cpp
index 2402609e1..25dfa0d8c 100644
--- a/library/DFProcess-linux.cpp
+++ b/library/DFProcess-linux.cpp
@@ -318,7 +318,7 @@ bool NormalProcess::attach()
bool NormalProcess::detach()
{
- if(!d->attached) return false;
+ if(!d->attached) return true;
if(!d->suspended) suspend();
int result = 0;
// close /proc/PID/mem
diff --git a/library/DFProcess-windows-SHM.cpp b/library/DFProcess-windows-SHM.cpp
index f9a7cad26..5bb100e34 100644
--- a/library/DFProcess-windows-SHM.cpp
+++ b/library/DFProcess-windows-SHM.cpp
@@ -632,10 +632,7 @@ bool SHMProcess::attach()
bool SHMProcess::detach()
{
- if(!d->attached)
- {
- return false;
- }
+ if(!d->attached) return true;
//cerr << "detach" << endl;// FIXME: throw
if(d->locked)
{
diff --git a/library/DFProcess-windows.cpp b/library/DFProcess-windows.cpp
index da44a0f32..dad67b135 100644
--- a/library/DFProcess-windows.cpp
+++ b/library/DFProcess-windows.cpp
@@ -249,10 +249,7 @@ bool NormalProcess::attach()
bool NormalProcess::detach()
{
- if(!d->attached)
- {
- return false;
- }
+ if(!d->attached) return true;
resume();
d->attached = false;
return true;
diff --git a/library/include/dfhack/DFModule.h b/library/include/dfhack/DFModule.h
index d4c840b64..7ed3e6738 100644
--- a/library/include/dfhack/DFModule.h
+++ b/library/include/dfhack/DFModule.h
@@ -33,7 +33,7 @@ namespace DFHack
class DFHACK_EXPORT Module
{
public:
- ~Module(){};
+ virtual ~Module(){};
virtual bool Start(){return true;};// default start...
virtual bool Finish() = 0;// everything should have a Finish()
// should Context call Finish when Resume is called?
diff --git a/library/modules/Maps.cpp b/library/modules/Maps.cpp
index e7d43a2a5..0cf3588a1 100644
--- a/library/modules/Maps.cpp
+++ b/library/modules/Maps.cpp
@@ -125,6 +125,7 @@ Maps::~Maps()
{
if(d->Started)
Finish();
+ delete d;
}
/*-----------------------------------*
diff --git a/offsetedit/CMakeLists.txt b/offsetedit/CMakeLists.txt
index 246f3ba3d..f8065bc4c 100644
--- a/offsetedit/CMakeLists.txt
+++ b/offsetedit/CMakeLists.txt
@@ -1,3 +1,4 @@
+
project(dfoffsetedit)
cmake_minimum_required(VERSION 2.6)
find_package(Qt4 QUIET)
diff --git a/offsetedit/src/CMakeLists.txt b/offsetedit/src/CMakeLists.txt
index 0804dd66e..9a2218413 100644
--- a/offsetedit/src/CMakeLists.txt
+++ b/offsetedit/src/CMakeLists.txt
@@ -18,7 +18,7 @@ SET( dfoffsetedit_RCS
# in result dfoffsetedit_RC_SRCS variable will contain paths to files produced by rcc
QT4_ADD_RESOURCES( dfoffsetedit_RC_SRCS ${dfoffsetedit_RCS} )
-QT4_WRAP_UI(dfoffsetedit_UI_h ${dfedit_UI})
+QT4_WRAP_UI(dfoffsetedit_UI_h ${dfoffsetedit_UI})
qt4_automoc(${dfoffsetedit_SRCS})
add_executable(dfoffsetedit ${dfoffsetedit_SRCS} ${dfoffsetedit_RC_SRCS} ${dfoffsetedit_UI_h})
diff --git a/tools/examples/processenum.cpp b/tools/examples/processenum.cpp
index 50b0df0a1..745e94371 100644
--- a/tools/examples/processenum.cpp
+++ b/tools/examples/processenum.cpp
@@ -102,6 +102,23 @@ int main (void)
Cman.Refresh(&inval);
int nCont = Cman.size();
int nInval = inval.size();
+ DFHack::Context * cont = Cman.getSingleContext();
+ if(cont)
+ {
+ if(cont->Attach())
+ {
+ DFHack::Maps * mapz = cont->getMaps();
+ cont->Suspend();
+ mapz->Start();
+ cont->Resume();
+ }
+
+ bool result = cont->Detach();
+ if(!result)
+ {
+ cerr << "Something went horribly wrong during detach" << endl;
+ }
+ }
cout << "Contexts:" << endl;
for(int i = 0; i < nCont; i++)
diff --git a/tools/supported/CMakeLists.txt b/tools/supported/CMakeLists.txt
index 0a0d93f68..f7006aeb2 100644
--- a/tools/supported/CMakeLists.txt
+++ b/tools/supported/CMakeLists.txt
@@ -51,6 +51,11 @@ TARGET_LINK_LIBRARIES(dfflows dfhack)
ADD_EXECUTABLE(dfliquids liquids.cpp)
TARGET_LINK_LIBRARIES(dfliquids dfhack)
+# Solves the problem of unusable items after reclaim by clearing the 'in_job' bit of all items.
+# Original author: Quietust
+ADD_EXECUTABLE(dfcleartask cleartask.cpp)
+TARGET_LINK_LIBRARIES(dfcleartask dfhack)
+
# position - check the DF window and cursor parameters
ADD_EXECUTABLE(dfposition position.cpp)
TARGET_LINK_LIBRARIES(dfposition dfhack)
@@ -104,6 +109,7 @@ dfunstuck
dfprobe
dfdoffsets
dfattachtest
+dfcleartask
dfexpbench
dfsuspend
dfflows
diff --git a/tools/supported/cleartask.cpp b/tools/supported/cleartask.cpp
new file mode 100644
index 000000000..267a686ff
--- /dev/null
+++ b/tools/supported/cleartask.cpp
@@ -0,0 +1,73 @@
+// clears the "tasked" flag on all items
+// original code by Quietust (http://www.bay12forums.com/smf/index.php?action=profile;u=18111)
+#include
+#include
+#include
+#include
+#include
+#include
+using namespace std;
+
+#include
+#include
+#include
+
+int main ()
+{
+ DFHack::Process * p;
+ unsigned int i;
+ DFHack::ContextManager DFMgr("Memory.xml");
+ DFHack::Context * DF;
+ try
+ {
+ DF = DFMgr.getSingleContext();
+ DF->Attach();
+ }
+ catch (exception& e)
+ {
+ cerr << e.what() << endl;
+#ifndef LINUX_BUILD
+ cin.ignore();
+#endif
+ return 1;
+ }
+
+ DFHack::memory_info * mem = DF->getMemoryInfo();
+ p = DF->getProcess();
+ uint32_t item_vec_offset = 0;
+ try
+ {
+ item_vec_offset = p->getDescriptor()->getAddress ("items_vector");
+ }
+ catch(DFHack::Error::MissingMemoryDefinition & e)
+ {
+ cerr << "missing offset for the item vector, exiting :(" << endl;
+ #ifndef LINUX_BUILD
+ cin.ignore();
+ #endif
+ return 1;
+ }
+
+ DFHack::DfVector p_items (p, item_vec_offset);
+ uint32_t size = p_items.size();
+
+ int numtasked = 0;
+ for (i=0;ireadDWord(p_items[i] + 0x0C);
+ if (flags.bits.in_job)
+ {
+ flags.bits.in_job = 0;
+ p->writeDWord(p_items[i] + 0x0C, flags.whole);
+ numtasked++;
+ }
+ }
+ cout << "Found and untasked " << numtasked << " items." << endl;
+
+#ifndef LINUX_BUILD
+ cout << "Done. Press any key to continue" << endl;
+ cin.ignore();
+#endif
+ return 0;
+}
\ No newline at end of file