Floors are loaded one level below solid blocks.

develop
Japa 2013-04-06 02:42:51 +05:30
parent 541e4f0947
commit 660ce50542
2 changed files with 89 additions and 73 deletions

@ -1 +1 @@
Subproject commit 3b06d1cf27a9d74010731492186f3d2b2cfbd88f Subproject commit c53ade8b997afbe33783aaa4aadfd39c9786fc51

@ -223,9 +223,9 @@ int coord_to_index_48(int x, int y) {
bool gather_embark_tile(int EmbX, int EmbY, EmbarkTile * tile, MapExtras::MapCache * MP) { bool gather_embark_tile(int EmbX, int EmbY, EmbarkTile * tile, MapExtras::MapCache * MP) {
tile->set_is_valid(false); tile->set_is_valid(false);
tile->set_world_x(df::global::world->map.region_x + (EmbX/3)); //fixme: verify. tile->set_world_x(df::global::world->map.region_x + (EmbX/3));
tile->set_world_y(df::global::world->map.region_y + (EmbY/3)); //fixme: verify. tile->set_world_y(df::global::world->map.region_y + (EmbY/3));
tile->set_world_z(df::global::world->map.region_z); //fixme: verify. tile->set_world_z(df::global::world->map.region_z + 1); //adding one because floors get shifted one downwards.
tile->set_current_year(*df::global::cur_year); tile->set_current_year(*df::global::cur_year);
tile->set_current_season(*df::global::cur_season); tile->set_current_season(*df::global::cur_season);
int num_valid_layers = 0; int num_valid_layers = 0;
@ -249,28 +249,41 @@ bool gather_embark_tile_layer(int EmbX, int EmbY, int EmbZ, EmbarkTileLayer * ti
int num_valid_blocks = 0; int num_valid_blocks = 0;
for(int yy = 0; yy < 3; yy++) { for(int yy = 0; yy < 3; yy++) {
for(int xx = 0; xx < 3; xx++) { for(int xx = 0; xx < 3; xx++) {
DFCoord current_coord; DFCoord current_coord, upper_coord;
current_coord.x = EmbX+xx; current_coord.x = EmbX+xx;
current_coord.y = EmbY+yy; current_coord.y = EmbY+yy;
current_coord.z = EmbZ; current_coord.z = EmbZ;
upper_coord = current_coord;
upper_coord.z += 1;
MapExtras::Block * b = MP->BlockAt(current_coord); MapExtras::Block * b = MP->BlockAt(current_coord);
MapExtras::Block * b_upper = MP->BlockAt(upper_coord);
if(b && b->getRaw()) { if(b && b->getRaw()) {
for(int block_y=0; block_y<16; block_y++) { for(int block_y=0; block_y<16; block_y++) {
for(int block_x=0; block_x<16; block_x++) { for(int block_x=0; block_x<16; block_x++) {
df::coord2d block_coord; df::coord2d block_coord;
block_coord.x = block_x; block_coord.x = block_x;
block_coord.y = block_y; block_coord.y = block_y;
DFHack::t_matpair actual_mat = b->staticMaterialAt(block_coord);
df::tiletype tile_type = b->tiletypeAt(block_coord); df::tiletype tile_type = b->tiletypeAt(block_coord);
df::tiletype upper_tile = df::tiletype::Void;
if(b_upper && b_upper->getRaw()) {
upper_tile = b_upper->tiletypeAt(block_coord);
}
df::tile_designation designation = b->DesignationAt(block_coord); df::tile_designation designation = b->DesignationAt(block_coord);
DFHack::t_matpair actual_mat;
if(tileShapeBasic(tileShape(upper_tile)) == tiletype_shape_basic::Floor) { //if the upper tile is a floor, use that material instead.
actual_mat = b_upper->staticMaterialAt(block_coord);
}
else {
actual_mat = b->staticMaterialAt(block_coord);
}
unsigned int array_index = coord_to_index_48(xx*16+block_x, yy*16+block_y); unsigned int array_index = coord_to_index_48(xx*16+block_x, yy*16+block_y);
//make a new fake material at the given index //make a new fake material at the given index
if(tileMaterial(tile_type) == tiletype_material::FROZEN_LIQUID) { //Ice. if(tileMaterial(tile_type) == tiletype_material::FROZEN_LIQUID && (tileShapeBasic(tileShape(upper_tile)) != tiletype_shape_basic::Floor)) { //Ice.
tile->set_mat_type_table(array_index, BasicMaterial::LIQUID); //Ice is totally a liquid, shut up. tile->set_mat_type_table(array_index, BasicMaterial::LIQUID); //Ice is totally a liquid, shut up.
tile->set_mat_subtype_table(array_index, LiquidType::ICE); tile->set_mat_subtype_table(array_index, LiquidType::ICE);
num_valid_blocks++; num_valid_blocks++;
} }
else if(designation.bits.flow_size) { //Contains either water or lava. else if(designation.bits.flow_size && (tileShapeBasic(tileShape(upper_tile)) != tiletype_shape_basic::Floor)) { //Contains either water or lava.
tile->set_mat_type_table(array_index, BasicMaterial::LIQUID); tile->set_mat_type_table(array_index, BasicMaterial::LIQUID);
if(designation.bits.liquid_type) //Magma if(designation.bits.liquid_type) //Magma
tile->set_mat_subtype_table(array_index, LiquidType::MAGMA); tile->set_mat_subtype_table(array_index, LiquidType::MAGMA);
@ -278,7 +291,10 @@ bool gather_embark_tile_layer(int EmbX, int EmbY, int EmbZ, EmbarkTileLayer * ti
tile->set_mat_subtype_table(array_index, LiquidType::WATER); tile->set_mat_subtype_table(array_index, LiquidType::WATER);
num_valid_blocks++; num_valid_blocks++;
} }
else if(tileShapeBasic(tileShape(tile_type)) != tiletype_shape_basic::Open) { else if(((tileShapeBasic(tileShape(tile_type)) != tiletype_shape_basic::Open) ||
(tileShapeBasic(tileShape(upper_tile)) == tiletype_shape_basic::Floor)) &&
((tileShapeBasic(tileShape(tile_type)) != tiletype_shape_basic::Floor) ||
(tileShapeBasic(tileShape(upper_tile)) == tiletype_shape_basic::Floor))) { //if the upper tile is a floor, we don't skip, otherwise we do.
if(actual_mat.mat_type == builtin_mats::INORGANIC) { //inorganic if(actual_mat.mat_type == builtin_mats::INORGANIC) { //inorganic
tile->set_mat_type_table(array_index, BasicMaterial::INORGANIC); tile->set_mat_type_table(array_index, BasicMaterial::INORGANIC);
tile->set_mat_subtype_table(array_index, actual_mat.mat_index); tile->set_mat_subtype_table(array_index, actual_mat.mat_index);