Get game's current world save folder

Use World::ReadWorldFolder() to get "region1" (or whatever it currently
is).  Only have offset for Linux.
develop
Matthew Cline 2011-07-16 16:00:50 -07:00
parent 9f822af45a
commit a923d19f76
3 changed files with 24 additions and 0 deletions

@ -1028,6 +1028,7 @@
<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" />
<Address name="control_mode" description="Current control mode" />
<Address name="save_folder" descript="Name of save folder of current game"/>
<!--<Address name="control_mode_copy" description="Copy of the control mode in DF memory" />-->
</Group>
<Group name="Legends">
@ -3058,6 +3059,7 @@
<Address name="control_mode" value="0x8c3de90" />
<Address name="game_mode" value="0x8c3deA0" />
<Address name="current_weather" value="0x93F05E4" />
<Address name="save_folder" value="0x958a378" />
</Group>
<Group name="Items">
<Address name="items_vector" value="0x940b1fc" />

@ -107,6 +107,7 @@ namespace DFHack
void SetCurrentWeather(uint8_t weather);
bool ReadGameMode(t_gamemodes& rd);
bool WriteGameMode(const t_gamemodes & wr); // this is very dangerous
std::string ReadWorldFolder();
private:
struct Private;
Private *d;

@ -67,6 +67,10 @@ struct World::Private
uint32_t gamemode_offset;
uint32_t controlmode_offset;
uint32_t controlmodecopy_offset;
bool StartedFolder;
uint32_t folder_name_offset;
Process * owner;
};
@ -106,6 +110,14 @@ World::World()
d->StartedMode = true;
}
catch(Error::All &){};
try
{
d->folder_name_offset = OG_World->getAddress( "save_folder" );
d->StartedFolder = true;
}
catch(Error::All &){};
d->Inited = true;
}
@ -220,3 +232,12 @@ void World::SetCurrentWeather(uint8_t weather)
d->owner->write(d->weather_offset,sizeof(buf),buf);
}
}
string World::ReadWorldFolder()
{
if (d->Inited && d->StartedFolder)
{
return string( * ( (string*) d->folder_name_offset ) );
}
return string("");
}