Fixed pause state offset in 31.12 linux version, dfreveal pauses and has improved usability.

develop
Petr Mrázek 2010-09-04 07:43:39 +02:00
parent 813b771cd6
commit f6b137230a
6 changed files with 35 additions and 7 deletions

@ -1874,6 +1874,10 @@
<Version name="v0.31.12 linux" os="linux" base="v0.31.11 linux" rebase="-0x1000"> <Version name="v0.31.12 linux" os="linux" base="v0.31.11 linux" rebase="-0x1000">
<MD5 value="e79cead03187ecb692961b316b7cdcd4" /> <MD5 value="e79cead03187ecb692961b316b7cdcd4" />
<Offsets> <Offsets>
<Group name="GUI">
<!-- FIXME: this could be wrong for many other versions. Investigate. -->
<Address name="pause_state" value="0x92ec65c"/>
</Group>
<Group name="Constructions"> <Group name="Constructions">
<Address name="vector" value="0x92f30a4"/> <Address name="vector" value="0x92f30a4"/>
<Offset name="sizeof" value="0x14"/> <Offset name="sizeof" value="0x14"/>

@ -32,6 +32,7 @@
#include "dfhack/modules/Items.h" #include "dfhack/modules/Items.h"
#include "dfhack/modules/Vegetation.h" #include "dfhack/modules/Vegetation.h"
#include "dfhack/modules/Maps.h" #include "dfhack/modules/Maps.h"
#include "dfhack/modules/Gui.h"
/* /*
* This is a header full of ugly, volatile things. * This is a header full of ugly, volatile things.

@ -21,7 +21,9 @@ namespace DFHack
bool Finish(); bool Finish();
///true if paused, false if not ///true if paused, false if not
bool ReadPauseState(); bool ReadPauseState();
///true if paused, false if not
void SetPauseState(bool paused);
/// read the DF menu view state (stock screen, unit screen, other screens /// read the DF menu view state (stock screen, unit screen, other screens
bool ReadViewScreen(t_viewscreen &); bool ReadViewScreen(t_viewscreen &);
/// read the DF menu state (designation menu ect) /// read the DF menu state (designation menu ect)

@ -93,13 +93,19 @@ bool Gui::Finish()
bool Gui::ReadPauseState() bool Gui::ReadPauseState()
{ {
// replace with an exception
if(!d->PauseInited) return false; if(!d->PauseInited) return false;
uint32_t pauseState = d->owner->readDWord (d->pause_state_offset); uint32_t pauseState = d->owner->readDWord (d->pause_state_offset);
return pauseState & 1; return pauseState & 1;
} }
void Gui::SetPauseState(bool paused)
{
if(!d->PauseInited) return;
cout << "pause set" << endl;
d->owner->writeDWord (d->pause_state_offset, paused);
}
uint32_t Gui::ReadMenuState() uint32_t Gui::ReadMenuState()
{ {
if(d->MenuStateInited) if(d->MenuStateInited)

@ -70,6 +70,7 @@ Maps::Maps(DFContextShared* _d)
d->d = _d; d->d = _d;
Process *p = d->owner = _d->p; Process *p = d->owner = _d->p;
d->Inited = d->Started = false; d->Inited = d->Started = false;
d->block = NULL;
DFHack::VersionInfo * mem = p->getDescriptor(); DFHack::VersionInfo * mem = p->getDescriptor();
Server::Maps::maps_offsets &off = d->offsets; Server::Maps::maps_offsets &off = d->offsets;

@ -6,6 +6,7 @@
using namespace std; using namespace std;
#include <DFHack.h> #include <DFHack.h>
#include <dfhack/modules/Gui.h>
struct hideblock struct hideblock
{ {
@ -37,6 +38,16 @@ int main (void)
} }
DFHack::Maps *Maps =DF->getMaps(); DFHack::Maps *Maps =DF->getMaps();
DFHack::Gui *Gui =DF->getGui();
// walk the map, save the hide bits, reveal.
cout << "Pausing..." << endl;
// horrible hack to make sure the pause is really set
Gui->SetPauseState(true);
DF->Resume();
usleep(100);
DF->Suspend();
// init the map // init the map
if(!Maps->Start()) if(!Maps->Start())
{ {
@ -46,11 +57,12 @@ int main (void)
#endif #endif
return 1; return 1;
} }
cout << "Revealing, please wait..." << endl;
Maps->getSize(x_max,y_max,z_max); Maps->getSize(x_max,y_max,z_max);
vector <hideblock> hidesaved; vector <hideblock> hidesaved;
// walk the map, save the hide bits, reveal.
cout << "Revealing... please wait." << endl;
for(uint32_t x = 0; x< x_max;x++) for(uint32_t x = 0; x< x_max;x++)
{ {
for(uint32_t y = 0; y< y_max;y++) for(uint32_t y = 0; y< y_max;y++)
@ -80,8 +92,10 @@ int main (void)
} }
// FIXME: force game pause here! // FIXME: force game pause here!
DF->Detach(); DF->Detach();
cout << "Map revealed. Close window/force exit to keep it that way." << endl; cout << "Map revealed. The game has been paused for you." << endl;
cout << "Press any key to unreveal. Don't close DF or unpause in that case!" << endl; cout << "Unpausing can unleash the forces of hell!" << endl << endl;
cout << "Press any key to unreveal." << endl;
cout << "Close to keep the map revealed." << endl;
cin.ignore(); cin.ignore();
cout << "Unrevealing... please wait." << endl; cout << "Unrevealing... please wait." << endl;
// FIXME: do some consistency checks here! // FIXME: do some consistency checks here!