Game mode reading, removed some include paths

develop
Petr Mrázek 2011-03-01 06:59:23 +01:00
parent c6a402c2b8
commit b1061d0f94
5 changed files with 43 additions and 12 deletions

@ -907,6 +907,7 @@
<Address name="current_tick" description="Current time of the year" />
<Address name="current_year" description="Current year" />
<Address name="current_weather" description="5x5 array of bytes for surrounding biomes. For each: 0=clear, 1=raining, 2=snowing." />
<Address name="game_mode" description="Current game mode" />
</Group>
</Offsets>
</Base>
@ -2029,11 +2030,12 @@
0x16dad88
<Address name="custom_workshop_vector" value="0x1724204" valid="true" />
</Group>
<Group name="World">
<Group name="World" valid="true">
<Address name="current_tick" value="0xe2e180" /> maybe
<Address name="current_year" value="0xf0d268" />
<Address name="current_weather" value="0x15027A0" />
fortress = 0, adventure = 1, arena = 0 0xb4a814
<Address name="game_mode" value="0xb4a814" />
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

@ -21,8 +21,6 @@ SET( EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/output CACHE PATH "Output direct
include_directories (${CMAKE_SOURCE_DIR}/library/include/)
include_directories (${CMAKE_SOURCE_DIR}/library/shm/)
include_directories (${CMAKE_SOURCE_DIR}/library/depends/md5/)
include_directories (${CMAKE_SOURCE_DIR}/library/depends/tinyxml/)
include_directories (${CMAKE_SOURCE_DIR}/library/depends/argstream/)
include_directories (${CMAKE_SOURCE_DIR}/library/private/)

@ -15,6 +15,15 @@ namespace DFHack
RAINING,
SNOWING
};
enum GameMode
{
Unknown = -1,
Fort = 0,
Adventurer,
Blarg,
Flarg,
Arena
};
class DFContextShared;
class DFHACK_EXPORT World : public Module
{
@ -31,7 +40,7 @@ namespace DFHack
uint32_t ReadCurrentDay();
uint8_t ReadCurrentWeather();
void SetCurrentWeather(uint8_t weather);
int32_t ReadGameMode();
private:
struct Private;
Private *d;

@ -49,9 +49,11 @@ struct World::Private
bool Inited;
bool StartedTime;
bool StartedWeather;
bool StartedMode;
uint32_t year_offset;
uint32_t tick_offset;
uint32_t weather_offset;
uint32_t gamemode_offset;
DFContextShared *d;
Process * owner;
};
@ -62,7 +64,7 @@ World::World(DFContextShared * _d)
d = new Private;
d->d = _d;
d->owner = _d->p;
d->Inited = d->StartedTime = d->StartedWeather = false;
d->Inited = d->StartedTime = d->StartedWeather = d->StartedMode = false;
OffsetGroup * OG_World = d->d->offset_descriptor->getGroup("World");
try
@ -78,6 +80,12 @@ World::World(DFContextShared * _d)
d->StartedWeather = true;
}
catch(Error::All &){};
try
{
d->gamemode_offset = OG_World->getAddress( "game_mode" );
d->StartedMode = true;
}
catch(Error::All &){};
d->Inited = true;
}
@ -110,6 +118,14 @@ uint32_t World::ReadCurrentTick()
return 0;
}
int32_t World::ReadGameMode()
{
if(d->Inited && d->StartedMode)
return d->owner->readDWord(d->gamemode_offset);
return -1;
}
// FIX'D according to this:
/*
World::ReadCurrentMonth and World::ReadCurrentDay

@ -21,6 +21,7 @@ int main (int argc, char** argv)
}
DFHack::Position * Position = 0;
DFHack::World * World = 0;
DFHack::ContextManager DFMgr("Memory.xml");
DFHack::Context * DF;
try
@ -28,6 +29,7 @@ int main (int argc, char** argv)
DF = DFMgr.getSingleContext();
DF->Attach();
Position = DF->getPosition();
World = DF->getWorld();
}
catch (exception& e)
{
@ -37,17 +39,21 @@ int main (int argc, char** argv)
#endif
return 1;
}
if(World)
{
cout << "Game mode " << World->ReadGameMode() << endl;
}
if (Position)
{
int32_t x,y,z;
int32_t width,height;
int32_t x,y,z;
int32_t width,height;
if(Position->getViewCoords(x,y,z))
if(Position->getViewCoords(x,y,z))
cout << "view coords: " << x << "/" << y << "/" << z << endl;
if(Position->getCursorCoords(x,y,z))
if(Position->getCursorCoords(x,y,z))
cout << "cursor coords: " << x << "/" << y << "/" << z << endl;
if(Position->getWindowSize(width,height))
cout << "window size : " << width << " " << height << endl;
if(Position->getWindowSize(width,height))
cout << "window size : " << width << " " << height << endl;
}
else
{