bool DwarfMap::ReadGeoLayers(ProcessPeek &proc, Point region, const DFMemMap &mem, Vector<int> &geo)
{
// Get region x/y position
dword region_row_ptr = proc.Read32(mem.world_addr + mem.regions_off);
if (IsNull(region_row_ptr))
return false;
region_row_ptr += region.x * 4; // Column address
// Find geo layer index in region block
dword region_col_ptr = proc.Read32(region_row_ptr);
if (IsNull(region_col_ptr))
return false;
dword region_ptr = region_col_ptr + region.y * mem.region_block_size;
dword geo_index = proc.Read16(region_ptr+mem.region_geo_index_off);
if (IsNull(geo_index))
return false;
// Find geo block using index
dword geo_start_ptr = mem.world_addr + mem.geo_blocks_off;
dword geo_end_ptr = mem.world_addr + mem.geo_blocks_off + 4;
geo_start_ptr = proc.Read32(geo_start_ptr);
geo_end_ptr = proc.Read32(geo_end_ptr);
if (IsNull(geo_start_ptr) || IsNull(geo_end_ptr))
return false;
// Offset
dword geo_block_ptr = proc.Read32(geo_start_ptr + geo_index * 4);
// Read geo layers
dword geo_layer_start_ptr = proc.Read32(geo_block_ptr +
;
dword geo_layer_end_ptr = proc.Read32(geo_block_ptr + 12);
if (IsNull(geo_layer_start_ptr) || IsNull(geo_layer_end_ptr))
return false;
for (; geo_layer_start_ptr < geo_layer_end_ptr; geo_layer_start_ptr += 4) {
dword geo_layer_ptr = proc.Read32(geo_layer_start_ptr);
if (IsNull(geo_layer_ptr))
return false;
geo_layer_ptr += 2;
dword mat_gloss_index = proc.Read16(geo_layer_ptr);
if (IsNull(mat_gloss_index))
return false;
geo.Add(mat_gloss_index);
}
return true;
}