operator precedence!

develop
Petr Mrázek 2010-04-23 04:00:41 +02:00
parent a6c42c6468
commit ddc2dd354d
3 changed files with 63 additions and 30 deletions

@ -114,8 +114,8 @@ namespace DFHack
e_traffic traffic : 2; // needs enum
unsigned int flow_forbid : 1; // what?
unsigned int liquid_static : 1;
unsigned int feature_type_1 : 1; // this tile is a part of a feature
unsigned int feature_type_2 : 1; // this tile is a part of a feature
unsigned int feature_local : 1; // this tile is a part of a feature
unsigned int feature_global : 1; // this tile is a part of a feature
unsigned int liquid_character : 2; // those ripples on streams?
};

@ -113,18 +113,18 @@ int main (int numargs, const char ** args)
DFHack::Maps *Maps = DF.getMaps();
DFHack::Process * p = DF.getProcess();
uint32_t designatus = mem->getOffset("map_data_designation");
uint32_t block_feature1 = mem->getOffset("map_data_feature1");
uint32_t block_feature2 = mem->getOffset("map_data_feature2");
uint32_t block_feature1 = mem->getOffset("map_data_feature_local");
uint32_t block_feature2 = mem->getOffset("map_data_feature_global");
uint32_t region_x_offset = mem->getAddress("region_x");
uint32_t region_y_offset = mem->getAddress("region_y");
uint32_t region_z_offset = mem->getAddress("region_z");
uint32_t feature1_start_ptr = mem->getAddress("feature1_start_ptr");
uint32_t regionX, regionY, regionZ;
uint32_t feature1_start_ptr = mem->getAddress("local_feature_start_ptr");
int32_t regionX, regionY, regionZ;
// read position of the region inside DF world
p->readDWord (region_x_offset, regionX);
p->readDWord (region_y_offset, regionY);
p->readDWord (region_z_offset, regionZ);
p->readDWord (region_x_offset, (uint32_t &)regionX);
p->readDWord (region_y_offset, (uint32_t &)regionY);
p->readDWord (region_z_offset, (uint32_t &)regionZ);
Maps->Start();
@ -152,46 +152,78 @@ int main (int numargs, const char ** args)
if(tileTypeTable[tiletype].name)
cout << " = " << tileTypeTable[tiletype].name;
cout << endl;
// features present
if(des.feature_type_1)
// local feature present
if(des.feature_local)
{
cout << "feature type 1 present: " << p->readDWord(block.origin + block_feature1) << endl;
int32_t idx = p->readDWord(block.origin + block_feature1);
cout << "local feature present: " << p->readWord(block.origin + block_feature1) << endl;
int16_t idx = p->readWord(block.origin + block_feature1);
if(idx != -1)
{
uint64_t bigblock_x = cursorX / 48 + regionX;
// blah, dumb disassembly. too tired to think
uint16_t v12 = ((bigblock_x % 16) + bigblock_x) / 16;
uint64_t block48_x = cursorX / 48 + regionX;
cout << "cursorX: " << cursorX << ", regionX:" << regionX << endl;
cout << "bigblock_x: " << block48_x << endl;
uint16_t v12 = ((block48_x & 0xF) + block48_x) >> 4;
uint16_t v12b = block48_x / 16;
cout << "v12: " << v12 << " : " << v12b << endl;
uint64_t region_y_local = (cursorY / 48 + regionY) / 16;
cout << "region_y_local: " << region_y_local << endl;
// deref pointer to the humongo-structure
uint32_t base = p->readDWord(feature1_start_ptr);
cout << "base! : " << base << endl;
// this is just a few pointers to arrays of 16B (4 DWORD) structs
uint32_t array_elem = p->readDWord(base + (v12 / 16) * 4);
cout << "array_elem : " << array_elem << endl;
// second element of the struct is a pointer
uint32_t wtf = p->readDWord(array_elem + (16*(region_y_local/16)) + 4); // rounding!
cout << "wtf : " << wtf << " @" << array_elem + (16*(region_y_local/16)) << endl;
if(wtf)
{
uint32_t feat_vector = wtf + 24 * (region_y_local % 16);
//v14 = v10 + 24 * ((signed __int16)_tX + 16 * v9 % 16);
uint32_t feat_vector = wtf + 24 * ((region_y_local % 16) + 16 * (v12 % 16));
cout << "local feature vector: " << feat_vector << endl;
DfVector<uint32_t> p_features(p, feat_vector);
printf("feature addr: 0x%x\n", p_features[idx]);
/*
for(int k = 0 ; k < p_features.size();k++)
{
printf("feature %d addr: 0x%x\n", k, p_features[k]);
string name = p->readClassName(p->readDWord( p_features[k] ));
cout << name << endl;
}
*/
printf("feature %d addr: 0x%x\n", idx, p_features[idx]);
string name = p->readClassName(p->readDWord( p_features[idx] ));
bool discovered = p->readDWord( p_features[idx] + 4 );
cout << name << endl;
if(discovered)
{
cout << "You've discovered it already!" << endl;
}
}
}
if(des.feature_type_2)
}
// global feature present
if(des.feature_global)
{
int32_t idx = p->readDWord(block.origin + block_feature2);
cout << "feature type 2 present: " << idx << endl;
int16_t idx = p->readWord(block.origin + block_feature2);
cout << "global feature present: " << idx << endl;
if(idx != -1)
{
DfVector<uint32_t> p_features (p,mem->getAddress("feature2_vector"));
DfVector<uint32_t> p_features (p,mem->getAddress("global_feature_vector"));
if(idx < p_features.size())
{
uint32_t feat_ptr = p->readDWord(p_features[idx] + mem->getOffset("feature2_funcptr_"));
uint32_t feat_ptr = p->readDWord(p_features[idx] + mem->getOffset("global_feature_funcptr_"));
printf("feature descriptor?: 0x%x\n", feat_ptr);
string name = p->readClassName(p->readDWord( feat_ptr));
bool discovered = p->readDWord( p_features[idx] + 4 );
cout << name << endl;
if(discovered)
{
cout << "You've discovered it already!" << endl;
}
}
}
}

@ -1061,14 +1061,14 @@ size=212
<Offset name="map_data_temperature2_offset">0x179c</Offset>
<Offset name="map_data_biome_stuffs">0x1D9C</Offset>
<Offset name="map_data_pathfinding_offset">0x0D9c</Offset>
<Offset name="map_data_feature1">0x2C</Offset> adamantine?
<Offset name="map_data_feature2">0x30</Offset> hell?
<Offset name="map_data_feature_local">0x2C</Offset> local features
<Offset name="map_data_feature_global">0x30</Offset> global features
WORLD + 0x54374
<Address name="feature2_vector">0x16AF4FC</Address>
<Offset name= "feature2_funcptr_">0x100</Offset>
<Address name="global_feature_vector">0x16AF4FC</Address>
<Offset name= "global_feature_funcptr_">0x100</Offset>
WORLD + 0x54440
<Address name="feature1_start_ptr">0x16AF5C8</Address>
<Address name="local_feature_start_ptr">0x16AF5C8</Address>
<!--
map_data_map_x_offset 0x0058
@ -1377,8 +1377,9 @@ map_data_1b60_offset 0x1B9c
* features *
WORLD + 0x54374
<Address name="feature2_vector">0x16B0544</Address>
<Address name="feature1_start_ptr">0x16B0610</Address>
<Address name="global_feature_vector">0x16B0544</Address>
WORLD + 0x54440
<Address name="local_feature_start_ptr">0x16B0610</Address>
Creatures
=========