Maps + Materials for 31.20. Still many broken offsets!

develop
Petr Mrázek 2011-03-06 20:27:40 +01:00
parent 9b0c426f9c
commit 9e62ee6e75
5 changed files with 186 additions and 30 deletions

@ -745,6 +745,9 @@
<Address name="region_z"/>
<Address name="world_size_x"/>
<Address name="world_size_y"/>
<Offset name="world_size_x_from_wdata" />
<Offset name="world_size_y_from_wdata" />
<Address name="world_data" description="Pointer to a structure containing world region data(AFAIK) in DF 31.20 and newer."/>
<Group name="block" description="The map block structure.">
<Offset name="vein_vector" description="Mineral veins, objects holding tile types under ice, etc..."/>
<Offset name="vegetation_vector" description="All the plants in this block, including farm plats."/>
@ -761,12 +764,14 @@
<Group name="features">
<Group name="global">
<Address name="vector" />
<Offset name="vector_from_wdata" />
<Offset name="funcptr" />
<Offset name="material" />
<Offset name="submaterial" />
</Group>
<Group name="local">
<Address name="start_ptr" />
<Offset name="start_ptr_from_wdata" />
<Offset name="material" />
<Offset name="submaterial" />
</Group>
@ -774,6 +779,8 @@
<Group name="geology">
<Address name="geoblock_vector" />
<Address name="ptr2_region_array" />
<Offset name="geoblock_vector_from_wdata" />
<Offset name="ptr2_region_array_from_wdata" />
<!-- values for the region structure -->
<HexValue name="region_size" />
<Offset name="region_geo_index_off" />
@ -2030,6 +2037,65 @@
-->
</Offsets>
</Version>
<Version name="v0.31.20 SDL" os="windows" base="v0.31.19 SDL" rebase="0x6000" >
<PETimeStamp value="0x4D734FB5" />
<MD5 value="5e2725ae9e87ff504ef0b1dcf52f059d" />
<Offsets>
<Group name="Materials">
<Address name="creature_type_vector" value="0x1724020 0x1724880" />
<Address name="inorganics" value="0x1723f30 0x1724790" />
<Address name="organics_all" value="0x1723f50 0x17247b0" />
<Address name="organics_plants" value="0x1723f60 0x17247c0" />
<Address name="organics_trees" value="0x1723f80 0x17247e0" />
<Group name="descriptors">
<Address name="all_colors_vector" value="0x1729984 0x172a1e4" />
<Address name="colors_vector" value="0x1729964 0x172a1c4" />
</Group>
<Group name="creature"> I'M NOT SURE ABOUT THESE
<!--
<Offset name="caste_vector" value="0x128" />
<Offset name="extract_vector" value="0x2054" />
<Offset name="tile" value="0xe0" />
<Offset name="tile_color" value="0xf6" />
-->
<Group name="caste">
<Offset name="attributes" value="0xdbc 0xd40" /> LOOKS LIKE CRAP, but seems to work anyway
<Offset name="bodypart_vector" value="0x5ac 0x530" />
<Offset name="color_modifiers" value="0x11e4 0x1168" />
</Group>
</Group>
0x530
71389344 + 0x5ac
</Group>
"region1" = 0x18639d8
some features vector = 0x18639f8 ?
<Group name="Maps">
<Address name="world_data" value="0x1723758" /> 0x16cca38 + 0x56d20
<Address name="world_size_x" valid="false" />
<Address name="world_size_y" valid="false" />
<Offset name="world_size_x_from_wdata" value="0x8C" />
<Offset name="world_size_y_from_wdata" value="0x8E" />
<Group name="features">
<Group name="global">
<Address name="vector" valid="false"/>
<Offset name="vector_from_wdata" value="0x180" />
</Group>
<Group name="local">
<Address name="start_ptr" valid="false" />
<Offset name="start_ptr_from_wdata" value="0x204" />
</Group>
</Group>
<Group name="geology">
<Offset name="geoblock_vector_from_wdata" value="0x190" /> maybe
<Offset name="ptr2_region_array_from_wdata" value="0x1C0" /> maybe
<Address name="geoblock_vector" valid="false" />
<Address name="ptr2_region_array" valid="false" />
</Group>
</Group>
</Offsets>
</Version>
.-"""-.
' \
|,. ,-. | _________________________

@ -70,8 +70,6 @@ struct Maps::Private
DFContextShared *d;
Process * owner;
OffsetGroup *OG_local_features;
OffsetGroup *OG_global_features;
OffsetGroup *OG_vector;
bool Inited;
bool Started;
@ -79,6 +77,8 @@ struct Maps::Private
bool hasFeatures;
bool hasVeggies;
bool usesWorldDataPtr;
set <uint32_t> unknown_veins;
// map between feature address and the read object
@ -94,6 +94,7 @@ Maps::Maps(DFContextShared* _d)
Process *p = d->owner = _d->p;
d->Inited = d->Started = false;
d->block = NULL;
d->usesWorldDataPtr = false;
DFHack::VersionInfo * mem = p->getDescriptor();
Server::Maps::maps_offsets &off = d->offsets;
@ -101,6 +102,13 @@ Maps::Maps(DFContextShared* _d)
// get the offsets once here
OffsetGroup *OG_Maps = mem->getGroup("Maps");
try
{
off.world_data = OG_Maps->getAddress("world_data");
d->usesWorldDataPtr = true;
cout << "uses world ptr" << endl;
}catch(Error::AllMemdef &){}
{
off.map_offset = OG_Maps->getAddress ("map_data");
off.x_count_offset = OG_Maps->getAddress ("x_count_block");
@ -109,8 +117,16 @@ Maps::Maps(DFContextShared* _d)
off.region_x_offset = OG_Maps->getAddress ("region_x");
off.region_y_offset = OG_Maps->getAddress ("region_y");
off.region_z_offset = OG_Maps->getAddress ("region_z");
off.world_size_x = OG_Maps->getAddress ("world_size_x");
off.world_size_y = OG_Maps->getAddress ("world_size_y");
if(d->usesWorldDataPtr)
{
off.world_size_x = OG_Maps->getOffset ("world_size_x_from_wdata");
off.world_size_y = OG_Maps->getOffset ("world_size_y_from_wdata");
}
else
{
off.world_size_x = OG_Maps->getAddress ("world_size_x");
off.world_size_y = OG_Maps->getAddress ("world_size_y");
}
OffsetGroup *OG_MapBlock = OG_Maps->getGroup("block");
{
off.tile_type_offset = OG_MapBlock->getOffset ("type");
@ -123,31 +139,55 @@ Maps::Maps(DFContextShared* _d)
off.temperature1_offset = OG_MapBlock->getOffset ("temperature1");
off.temperature2_offset = OG_MapBlock->getOffset ("temperature2");
}
try
{
OffsetGroup *OG_Geology = OG_Maps->getGroup("geology");
if(d->usesWorldDataPtr)
{
off.world_regions = OG_Geology->getOffset ("ptr2_region_array_from_wdata");
off.world_geoblocks_vector = OG_Geology->getOffset ("geoblock_vector_from_wdata");
}
else
{
off.world_regions = OG_Geology->getAddress ("ptr2_region_array");
off.region_size = OG_Geology->getHexValue ("region_size");
off.region_geo_index_offset = OG_Geology->getOffset ("region_geo_index_off");
off.geolayer_geoblock_offset = OG_Geology->getOffset ("geolayer_geoblock_offset");
off.world_geoblocks_vector = OG_Geology->getAddress ("geoblock_vector");
off.type_inside_geolayer = OG_Geology->getOffset ("type_inside_geolayer");
}
off.region_size = OG_Geology->getHexValue ("region_size");
off.region_geo_index_offset = OG_Geology->getOffset ("region_geo_index_off");
off.geolayer_geoblock_offset = OG_Geology->getOffset ("geolayer_geoblock_offset");
off.type_inside_geolayer = OG_Geology->getOffset ("type_inside_geolayer");
}
catch(Error::AllMemdef &)
{
d->hasGeology = false;
}
OffsetGroup *OG_global_features = OG_Maps->getGroup("features")->getGroup("global");
OffsetGroup *OG_local_features = OG_Maps->getGroup("features")->getGroup("local");
try
{
d->OG_global_features = OG_Maps->getGroup("features")->getGroup("global");
d->OG_local_features = OG_Maps->getGroup("features")->getGroup("local");
if(d->usesWorldDataPtr)
{
off.local_f_start = OG_local_features->getOffset("start_ptr_from_wdata");
off.global_vector = OG_global_features->getOffset("vector_from_wdata");
}
else
{
off.local_f_start = OG_local_features->getAddress("start_ptr");
off.global_vector = OG_global_features->getAddress("vector");
}
off.local_material = OG_local_features->getOffset("material");
off.local_submaterial = OG_local_features->getOffset("submaterial");
off.global_funcptr = OG_global_features->getOffset("funcptr");
off.global_material = OG_global_features->getOffset("material");
off.global_submaterial = OG_global_features->getOffset("submaterial");
}
catch(Error::AllMemdef &)
{
d->hasFeatures = false;
}
try
{
OffsetGroup * OG_Veg = d->d->offset_descriptor->getGroup("Vegetation");
@ -739,16 +779,28 @@ bool Maps::ReadGeology (vector < vector <uint16_t> >& assign)
Process *p = d->owner;
// get needed addresses and offsets. Now this is what I call crazy.
uint16_t worldSizeX, worldSizeY;
uint32_t regions, geoblocks_vector_addr;
Server::Maps::maps_offsets &off = d->offsets;
// get world size
p->readWord (off.world_size_x, worldSizeX);
p->readWord (off.world_size_y, worldSizeY);
// get pointer to first part of 2d array of regions
uint32_t regions = p->readDWord (off.world_regions);
if(d->usesWorldDataPtr)
{
uint32_t world = p->readDWord(off.world_data);
p->readWord (world + off.world_size_x, worldSizeX);
p->readWord (world + off.world_size_y, worldSizeY);
regions = p->readDWord ( world + off.world_regions); // ptr2_region_array
geoblocks_vector_addr = world + off.world_geoblocks_vector;
}
else
{
p->readWord (off.world_size_x, worldSizeX);
p->readWord (off.world_size_y, worldSizeY);
// get pointer to first part of 2d array of regions
regions = p->readDWord (off.world_regions); // ptr2_region_array
geoblocks_vector_addr = off.world_geoblocks_vector;
}
// read the geoblock vector
DfVector <uint32_t> geoblocks (d->d->p, off.world_geoblocks_vector);
DfVector <uint32_t> geoblocks (d->d->p, geoblocks_vector_addr);
// iterate over 8 surrounding regions + local region
for (int i = eNorthWest; i < eBiomeCount; i++)
@ -811,15 +863,26 @@ bool Maps::ReadLocalFeatures( std::map <planecoord, std::vector<t_feature *> > &
return false;
Process * p = d->owner;
Server::Maps::maps_offsets &off = d->offsets;
uint32_t base = 0;
if(d->usesWorldDataPtr)
{
uint32_t world = p->readDWord(off.world_data);
if(!world) return false;
base = p->readDWord(world + off.local_f_start);
}
else
{
base = p->readDWord(off.local_f_start);
}
// deref pointer to the humongo-structure
uint32_t base = p->readDWord(d->OG_local_features->getAddress("start_ptr"));
if(!base)
return false;
const uint32_t sizeof_vec = d->OG_vector->getHexValue("sizeof");
const uint32_t sizeof_elem = 16;
const uint32_t offset_elem = 4;
const uint32_t main_mat_offset = d->OG_local_features->getOffset("material"); // 0x30
const uint32_t sub_mat_offset = d->OG_local_features->getOffset("submaterial"); // 0x34
const uint32_t main_mat_offset = off.local_material;
const uint32_t sub_mat_offset = off.local_submaterial;
local_features.clear();
@ -904,11 +967,20 @@ bool Maps::ReadGlobalFeatures( std::vector <t_feature> & features)
return false;
Process * p = d->owner;
const uint32_t global_feature_vector = d->OG_global_features->getAddress("vector");
const uint32_t global_feature_funcptr = d->OG_global_features->getOffset("funcptr");
const uint32_t main_mat_offset = d->OG_global_features->getOffset("material"); // 0x34
const uint32_t sub_mat_offset = d->OG_global_features->getOffset("submaterial"); // 0x38
Server::Maps::maps_offsets &off = d->offsets;
uint32_t global_feature_vector;
if(d->usesWorldDataPtr)
{
global_feature_vector = p->readDWord(off.world_data) + off.global_vector;
}
else
{
global_feature_vector = off.global_vector;
}
// deref pointer to the humongo-structure
const uint32_t global_feature_funcptr = off.global_funcptr;
const uint32_t main_mat_offset = off.global_material;
const uint32_t sub_mat_offset = off.global_submaterial;
DfVector<uint32_t> p_features (p,global_feature_vector);
features.clear();

@ -76,6 +76,17 @@ typedef struct
uint32_t geolayer_geoblock_offset;// = minfo->getOffset ("geolayer_geoblock_offset");
uint32_t type_inside_geolayer;// = mem->getOffset ("type_inside_geolayer");
/*
FEATURES
*/
uint32_t world_data;
uint32_t local_f_start; // offset from world_data or absolute address.
uint32_t local_material;
uint32_t local_submaterial;
uint32_t global_vector; // offset from world_data or absolute address.
uint32_t global_funcptr;
uint32_t global_material;
uint32_t global_submaterial;
/*
* Vegetation
*/

@ -47,6 +47,7 @@ int main (int numargs, const char ** args)
uint32_t region_z_offset = mapsg->getAddress("region_z");
uint32_t designatus = mapblockg->getOffset("designation");
uint32_t biomus = mapblockg->getOffset("biome_stuffs");
int32_t regionX, regionY, regionZ;
@ -56,11 +57,12 @@ int main (int numargs, const char ** args)
p->readDWord (region_z_offset, (uint32_t &)regionZ);
Maps->Start();
/*
vector<DFHack::t_feature> global_features;
std::map <DFHack::planecoord, std::vector<DFHack::t_feature *> > local_features;
Maps->ReadLocalFeatures(local_features);
Maps->ReadGlobalFeatures(global_features);
*/
//Maps->ReadLocalFeatures(local_features);
//Maps->ReadGlobalFeatures(global_features);
int32_t cursorX, cursorY, cursorZ;
Pos->getCursorCoords(cursorX,cursorY,cursorZ);
@ -121,6 +123,7 @@ int main (int numargs, const char ** args)
std::cout << "smooth?" << std::endl;
uint32_t designato = block.origin + designatus + (tileX * 16 + tileY) * sizeof(t_designation);
printf("designation offset: 0x%x\n", designato);
printf("biomestuffs: 0x%x\n", block.origin + biomus);
#define PRINT_FLAG( X ) printf("%-16s= %c\n", #X , ( des.X ? 'Y' : ' ' ) )
PRINT_FLAG( hidden );
@ -132,8 +135,9 @@ int main (int numargs, const char ** args)
planecoord pc;
pc.dim.x=blockX; pc.dim.y=blockY;
PRINT_FLAG( feature_local );
/*
if( des.feature_local )
{
printf("%-16s %4d (%2d) %s\n", "",
@ -142,8 +146,10 @@ int main (int numargs, const char ** args)
sa_feature(local_features[pc][block.local_feature]->type)
);
}
*/
PRINT_FLAG( feature_global );
/*
if( des.feature_global ){
printf("%-16s %4d (%2d) %s\n", "",
block.global_feature,
@ -151,6 +157,7 @@ int main (int numargs, const char ** args)
sa_feature(global_features[block.global_feature].type)
);
}
*/
#undef PRINT_FLAG
std::cout << std::endl;
}

@ -137,7 +137,7 @@ int main (int argc, const char* argv[])
}
// get region geology
if(!Maps->ReadGeology( layerassign ))
if(showbaselayers && !Maps->ReadGeology( layerassign ))
{
cerr << "Can't get region geology." << endl;
#ifndef LINUX_BUILD