Ending the map feature failtrain.

develop
Petr Mrázek 2011-05-07 09:07:28 +02:00
parent 97af676bdb
commit 8b2ab8de68
2 changed files with 30 additions and 50 deletions

@ -674,62 +674,43 @@ bool Maps::StartFeatures()
// deref pointer to the humongo-structure
if(!base)
return false;
// regionX and regionY are in embark squares!
// we convert to full region tiles
// this also works in adventure mode
// region X coord - whole regions
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 loc_main_mat_offset = off.local_material;
const uint32_t loc_sub_mat_offset = off.local_submaterial;
const uint32_t sizeof_16vec = 16* sizeof_vec;
for(uint32_t blockX = 0; blockX < d->x_block_count; blockX ++)
for(uint32_t blockY = 0; blockY < d->x_block_count; blockY ++)
{
int16_t zz; // bx@1
signed int xx; // edx@2
signed int yy; // edi@4
int v7; // eax@7
int block; // ebx@8
int designation; // eax@9
int32_t x_cooked_; // eax@11
int16_t y_cooked; // dx@11
int loc_f_array16x16; // esi@11
int64_t x_esquare; // qax@11
int64_t x_cooked; // si@11
int64_t y_esquare; // qax@11
int v16; // eax@12
int local_f_idx; // edx@12
int v18; // eax@12
int result; // eax@14
int v20; // ebx@17
int designation_; // [sp+14h] [bp+4h]@9
x_esquare = blockX / 3 + d->regionX; // *(_DWORD *)(WORLD + 0x55720);
x_cooked = ((BYTE4(x_esquare) & 0xF) + (_DWORD)x_esquare) >> 4;
y_esquare = blockY / 3 + d->regionY;
y_cooked = ((BYTE4(y_esquare) & 0xF) + (_DWORD)y_esquare) >> 4;
x_cooked_ = x_cooked;
uint32_t array_elem = p->readDWord(base + 4 * (x_cooked >> 4));
loc_f_array16x16 = p->readDWord((y_cooked & 0xFFFFFFF0) + 4 + array_elem);
/*
// region X coord (48x48 tiles)
uint16_t region_x_local = ( (blockX / 3) + d->regionX ) / 16;
// region Y coord (48x48 tiles)
uint64_t region_y_local = ( (blockY / 3) + d->regionY ) / 16;
// this is just a few pointers to arrays of 16B (4 DWORD) structs
uint32_t array_elem = p->readDWord(base + (region_x_local / 16) * 4);
for(uint32_t blockY = 0; blockY < d->y_block_count; blockY ++)
{
// regionX and regionY are in embark squares!
// we convert to full region tiles
// this also works in adventure mode
// region X coord - whole regions
uint32_t region_x = ( (blockX / 3) + d->regionX ) / 16;
// region Y coord - whole regions
uint32_t region_y = ( (blockY / 3) + d->regionY ) / 16;
uint32_t bigregion_x = region_x / 16;
uint32_t bigregion_y = region_y / 16;
uint32_t sub_x = region_x % 16;
uint32_t sub_y = region_y % 16;
// megaregions = 16x16 squares of regions = 256x256 squares of embark squares
// base = pointer to local feature structure (inside world data struct)
// bigregion is 16x16 regions. for each bigregion in X dimension:
uint32_t mega_column = p->readDWord(base + bigregion_x * 4);
// 16B structs, second DWORD of the struct is a pointer
uint32_t loc_f_array16x16 = p->readDWord(array_elem
+ ( sizeof_elem * ( (uint32_t)region_y_local/16))
+ offset_elem);
*/
uint32_t loc_f_array16x16 = p->readDWord(mega_column + offset_elem + (sizeof_elem * bigregion_y));
if(loc_f_array16x16)
{
// wtf + sizeof(vector<ptr>) * crap;
//uint32_t feat_vector = loc_f_array16x16 + sizeof_vec * (16 * (region_x_local % 16) + (region_y_local % 16));
uint32_t feat_vector = loc_f_array16x16 + sizeof_vec/*16*/ * (y_cooked % 16 + 16 * x_cooked_ % 16);
//loc_f_array16x16 + sizeof_vec * (16 * (x_cooked % 16) + (region_y_local % 16));
uint32_t feat_vector = loc_f_array16x16 + sizeof_16vec * sub_x + sizeof_vec * sub_y;
DfVector<uint32_t> p_features(p, feat_vector);
uint32_t size = p_features.size();
DFCoord pc(blockX,blockY);
@ -777,6 +758,7 @@ bool Maps::StartFeatures()
tempvec.push_back(&(d->local_feature_store[cur_ptr]));
}
}
cout << "coord: " << pc.x << ":" << pc.y << " = " << tempvec.size() << endl;
d->m_local_feature[pc] = tempvec;
}
}
@ -883,11 +865,10 @@ bool Maps::ReadFeatures(mapblock40d * block, t_feature ** local, t_feature ** gl
if(!d->FeaturesStarted) return false;
DFCoord c = block->position;
c.z = 0;
if(global && block->global_feature != -1)
*global = &(d->v_global_feature[block->global_feature]);
else if (global)
*global = 0;
*local = 0;
if(block->global_feature != -1)
*global = &(d->v_global_feature[block->global_feature]);
if(local && block->local_feature != -1)
{
map <DFCoord, std::vector <t_feature* > >::iterator iter = d->m_local_feature.find(c);
@ -897,8 +878,6 @@ bool Maps::ReadFeatures(mapblock40d * block, t_feature ** local, t_feature ** gl
}
else *local = 0;
}
else if(local)
*local = 0;
return true;
}

@ -180,6 +180,7 @@ int main (int numargs, const char ** args)
printf("%-16s", "");
printf(" %4d", block.local_feature);
printf(" (%2d)", local->type);
printf(" addr 0x%X ", local->origin);
printf(" %s\n", sa_feature(local->type));
}
PRINT_FLAG( feature_global );