Skip to content

Commit a923d19

Browse files
author
Matthew Cline
committed
Get game's current world save folder
Use World::ReadWorldFolder() to get "region1" (or whatever it currently is). Only have offset for Linux.
1 parent 9f822af commit a923d19

3 files changed

Lines changed: 24 additions & 0 deletions

File tree

Memory.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,6 +1028,7 @@
10281028
<Address name="current_weather" description="5x5 array of bytes for surrounding biomes. For each: 0=clear, 1=raining, 2=snowing." />
10291029
<Address name="game_mode" description="Current game mode" />
10301030
<Address name="control_mode" description="Current control mode" />
1031+
<Address name="save_folder" descript="Name of save folder of current game"/>
10311032
<!--<Address name="control_mode_copy" description="Copy of the control mode in DF memory" />-->
10321033
</Group>
10331034
<Group name="Legends">
@@ -3058,6 +3059,7 @@
30583059
<Address name="control_mode" value="0x8c3de90" />
30593060
<Address name="game_mode" value="0x8c3deA0" />
30603061
<Address name="current_weather" value="0x93F05E4" />
3062+
<Address name="save_folder" value="0x958a378" />
30613063
</Group>
30623064
<Group name="Items">
30633065
<Address name="items_vector" value="0x940b1fc" />

library/include/dfhack/modules/World.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ namespace DFHack
107107
void SetCurrentWeather(uint8_t weather);
108108
bool ReadGameMode(t_gamemodes& rd);
109109
bool WriteGameMode(const t_gamemodes & wr); // this is very dangerous
110+
std::string ReadWorldFolder();
110111
private:
111112
struct Private;
112113
Private *d;

library/modules/World.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ struct World::Private
6767
uint32_t gamemode_offset;
6868
uint32_t controlmode_offset;
6969
uint32_t controlmodecopy_offset;
70+
71+
bool StartedFolder;
72+
uint32_t folder_name_offset;
73+
7074
Process * owner;
7175
};
7276

@@ -106,6 +110,14 @@ World::World()
106110
d->StartedMode = true;
107111
}
108112
catch(Error::All &){};
113+
try
114+
{
115+
d->folder_name_offset = OG_World->getAddress( "save_folder" );
116+
d->StartedFolder = true;
117+
}
118+
catch(Error::All &){};
119+
120+
109121
d->Inited = true;
110122
}
111123

@@ -220,3 +232,12 @@ void World::SetCurrentWeather(uint8_t weather)
220232
d->owner->write(d->weather_offset,sizeof(buf),buf);
221233
}
222234
}
235+
236+
string World::ReadWorldFolder()
237+
{
238+
if (d->Inited && d->StartedFolder)
239+
{
240+
return string( * ( (string*) d->folder_name_offset ) );
241+
}
242+
return string("");
243+
}

0 commit comments

Comments
 (0)