diff --git a/data/Memory-ng.xml b/data/Memory-ng.xml
index fb4cabaaf..0e11158be 100644
--- a/data/Memory-ng.xml
+++ b/data/Memory-ng.xml
@@ -908,6 +908,8 @@
+
+
@@ -2034,7 +2036,9 @@
maybe
-
+
+
+
fortress = 0, adventure = 1, arena = 0, menu and legends = 3 0xb4a814
Game mode: 0xb4a818 . fortress = 0, adventure = 1, arena = 4
0xe2e2a2 seems to be a copy of the first one
diff --git a/library/include/dfhack/modules/World.h b/library/include/dfhack/modules/World.h
index 80208643c..0985e5cfa 100644
--- a/library/include/dfhack/modules/World.h
+++ b/library/include/dfhack/modules/World.h
@@ -6,6 +6,7 @@
*/
#include "dfhack/DFExport.h"
#include "dfhack/DFModule.h"
+#include
namespace DFHack
{
@@ -15,11 +16,27 @@ namespace DFHack
RAINING,
SNOWING
};
+ enum ControlMode
+ {
+ CM_Managing = 0,
+ CM_DirectControl = 1,
+ CM_Kittens = 2, // not sure yet, but I think it will involve kittens
+ CM_Menu = 3,
+ CM_MAX = 3
+ };
enum GameMode
{
GM_Fort = 0,
GM_Adventurer = 1,
+ GM_Kittens = 2, // not sure yet, but I think it will involve kittens
GM_Menu = 3,
+ GM_Arena = 4,
+ GM_MAX
+ };
+ struct t_gamemodes
+ {
+ ControlMode control_mode;
+ GameMode game_mode;
};
class DFContextShared;
class DFHACK_EXPORT World : public Module
@@ -37,7 +54,8 @@ namespace DFHack
uint32_t ReadCurrentDay();
uint8_t ReadCurrentWeather();
void SetCurrentWeather(uint8_t weather);
- int32_t ReadGameMode();
+ bool ReadGameMode(t_gamemodes& rd);
+ bool WriteGameMode(const t_gamemodes & wr); // this is very dangerous
private:
struct Private;
Private *d;
diff --git a/library/modules/World.cpp b/library/modules/World.cpp
index d7b86caec..73b7a95cd 100644
--- a/library/modules/World.cpp
+++ b/library/modules/World.cpp
@@ -54,6 +54,8 @@ struct World::Private
uint32_t tick_offset;
uint32_t weather_offset;
uint32_t gamemode_offset;
+ uint32_t controlmode_offset;
+ uint32_t controlmodecopy_offset;
DFContextShared *d;
Process * owner;
};
@@ -83,6 +85,8 @@ World::World(DFContextShared * _d)
try
{
d->gamemode_offset = OG_World->getAddress( "game_mode" );
+ d->controlmode_offset = OG_World->getAddress( "control_mode" );
+ d->controlmodecopy_offset = OG_World->getAddress( "control_mode" );
d->StartedMode = true;
}
catch(Error::All &){};
@@ -118,13 +122,27 @@ uint32_t World::ReadCurrentTick()
return 0;
}
-int32_t World::ReadGameMode()
+bool World::ReadGameMode(t_gamemodes& rd)
{
if(d->Inited && d->StartedMode)
- return d->owner->readDWord(d->gamemode_offset);
- return -1;
+ {
+ rd.control_mode = (ControlMode) d->owner->readDWord( d->controlmode_offset);
+ rd.game_mode = (GameMode) d->owner->readDWord(d->gamemode_offset);
+ return true;
+ }
+ return false;
+}
+bool World::WriteGameMode(const t_gamemodes & wr)
+{
+ if(d->Inited && d->StartedMode)
+ {
+ d->owner->writeDWord(d->gamemode_offset,wr.game_mode);
+ d->owner->writeDWord(d->controlmode_offset,wr.control_mode);
+ d->owner->writeDWord(d->controlmodecopy_offset,wr.control_mode);
+ return true;
+ }
+ return false;
}
-
// FIX'D according to this:
/*
diff --git a/tools/supported/position.cpp b/tools/supported/position.cpp
index ffac17969..f3087f813 100644
--- a/tools/supported/position.cpp
+++ b/tools/supported/position.cpp
@@ -8,6 +8,30 @@ using namespace std;
#include
+std::ostream &operator<<(std::ostream &stream, DFHack::t_gamemodes funzies)
+{
+ char * gm[]=
+ {
+ "Fort",
+ "Adventurer",
+ "Kittens!",
+ "Menus",
+ "Arena",
+ };
+ char * cm[]=
+ {
+ "Managing",
+ "Direct Control",
+ "Kittens!",
+ "Menus"
+ };
+ if(funzies.game_mode <= DFHack::GM_MAX && funzies.control_mode <= DFHack::CM_MAX)
+ stream << "Game mode: " << gm[funzies.game_mode] << ", Control mode: " << cm[funzies.control_mode];
+ else
+ stream << "Game mode is too funky: (" << funzies.game_mode << "," << funzies.control_mode << ")";
+ return stream;
+}
+
int main (int argc, char** argv)
{
bool quiet = false;
@@ -39,9 +63,10 @@ int main (int argc, char** argv)
#endif
return 1;
}
- if(World)
+ DFHack::t_gamemodes gmm;
+ if(World->ReadGameMode(gmm))
{
- cout << "Game mode " << World->ReadGameMode() << endl;
+ cout << gmm << endl;
}
if (Position)
{