diff --git a/README.rst b/README.rst index ff93b49f3..1e479d107 100644 --- a/README.rst +++ b/README.rst @@ -84,6 +84,10 @@ dfprospector ============ Lists all available minerals on the map and how much of them there is. +dfprobe +============ +Can be used to determine tile properties. + dfreveal ======== Reveals the whole map, waits for input and hides it again. If you close diff --git a/library/DFContext.cpp b/library/DFContext.cpp index 15939dee9..1499f566d 100644 --- a/library/DFContext.cpp +++ b/library/DFContext.cpp @@ -59,6 +59,7 @@ Context::Context (Process* p) : d (new DFContextShared()) Context::~Context() { + cerr << "called Context destructor" << endl; Detach(); delete d; } @@ -88,6 +89,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..17c6c2034 100644 --- a/library/modules/Maps.cpp +++ b/library/modules/Maps.cpp @@ -123,8 +123,10 @@ Maps::Maps(DFContextShared* _d) Maps::~Maps() { + cerr << "called Maps destructor" << endl; if(d->Started) Finish(); + delete d; } /*-----------------------------------* diff --git a/tools/examples/processenum.cpp b/tools/examples/processenum.cpp index 50b0df0a1..728736b65 100644 --- a/tools/examples/processenum.cpp +++ b/tools/examples/processenum.cpp @@ -102,6 +102,17 @@ int main (void) Cman.Refresh(&inval); int nCont = Cman.size(); int nInval = inval.size(); + DFHack::Context * cont = Cman.getSingleContext(); + if(cont) + { + if(cont->Attach()) + cont->getMaps(); + bool result = cont->Detach(); + if(!result) + { + cerr << "Something went horribly wrong during detach" << endl; + } + } cout << "Contexts:" << endl; for(int i = 0; i < nCont; i++)