Merge pull request #106 from matthew-cline/TOPIC-folder

Get game's current world save folder
develop
Petr Mrázek 2011-07-17 02:26:06 -07:00
commit e021199178
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="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="game_mode" description="Current game mode" />
<Address name="control_mode" description="Current control 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" />--> <!--<Address name="control_mode_copy" description="Copy of the control mode in DF memory" />-->
</Group> </Group>
<Group name="Legends"> <Group name="Legends">
@ -3058,6 +3059,7 @@
<Address name="control_mode" value="0x8c3de90" /> <Address name="control_mode" value="0x8c3de90" />
<Address name="game_mode" value="0x8c3deA0" /> <Address name="game_mode" value="0x8c3deA0" />
<Address name="current_weather" value="0x93F05E4" /> <Address name="current_weather" value="0x93F05E4" />
<Address name="save_folder" value="0x958a378" />
</Group> </Group>
<Group name="Items"> <Group name="Items">
<Address name="items_vector" value="0x940b1fc" /> <Address name="items_vector" value="0x940b1fc" />

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

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