Skip to content

Commit

Permalink
Make sure wibble is set correctly on script slab change (dkfans#3475)
Browse files Browse the repository at this point in the history
  • Loading branch information
Loobinex authored Sep 20, 2024
1 parent 5f25463 commit fd1e6af
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 26 deletions.
56 changes: 30 additions & 26 deletions src/map_blocks.c
Original file line number Diff line number Diff line change
Expand Up @@ -1515,6 +1515,35 @@ static void shuffle_unattached_things_on_slab(MapSlabCoord slb_x, MapSlabCoord s
}
}

void set_alt_bit_on_slabs_around(MapSlabCoord slb_x, MapSlabCoord slb_y)
{
for (int i = 0; i < AROUND_EIGHT_LENGTH; i++)
{
MapSlabCoord sslb_x;
MapSlabCoord sslb_y;
sslb_x = slb_x + (MapSlabCoord)my_around_eight[i].delta_x;
sslb_y = slb_y + (MapSlabCoord)my_around_eight[i].delta_y;
struct SlabMap* slb;
slb = get_slabmap_block(sslb_x, sslb_y);
if (slabmap_block_invalid(slb)) {
continue;
}
int ssub_x;
int ssub_y;
for (ssub_y = 0; ssub_y < STL_PER_SLB; ssub_y++)
{
for (ssub_x = 0; ssub_x < STL_PER_SLB; ssub_x++)
{
MapSubtlCoord sstl_x;
MapSubtlCoord sstl_y;
sstl_x = slab_subtile(sslb_x, ssub_x);
sstl_y = slab_subtile(sslb_y, ssub_y);
set_alt_bit_based_on_slab(slb->kind, sstl_x, sstl_y);
}
}
}
}

void dump_slab_on_map(SlabKind slbkind, long slabset_id, MapSubtlCoord stl_x, MapSubtlCoord stl_y, PlayerNumber owner)
{
MapSlabCoord slb_x;
Expand Down Expand Up @@ -1637,32 +1666,7 @@ void place_animating_slab_type_on_map(SlabKind slbkind, char ani_frame, MapSubtl
delete_attached_things_on_slab(slb_x, slb_y);
dump_slab_on_map(slbkind, SLABSETS_PER_SLAB * slbkind + ani_frame, stl_x, stl_y, owner);
shuffle_unattached_things_on_slab(slb_x, slb_y);
int i;
for (i = 0; i < AROUND_EIGHT_LENGTH; i++)
{
MapSlabCoord sslb_x;
MapSlabCoord sslb_y;
sslb_x = slb_x + (MapSlabCoord)my_around_eight[i].delta_x;
sslb_y = slb_y + (MapSlabCoord)my_around_eight[i].delta_y;
struct SlabMap *slb;
slb = get_slabmap_block(sslb_x, sslb_y);
if (slabmap_block_invalid(slb)) {
continue;
}
int ssub_x;
int ssub_y;
for (ssub_y=0; ssub_y < STL_PER_SLB; ssub_y++)
{
for (ssub_x=0; ssub_x < STL_PER_SLB; ssub_x++)
{
MapSubtlCoord sstl_x;
MapSubtlCoord sstl_y;
sstl_x = slab_subtile(sslb_x,ssub_x);
sstl_y = slab_subtile(sslb_y,ssub_y);
set_alt_bit_based_on_slab(slb->kind, sstl_x, sstl_y);
}
}
}
set_alt_bit_on_slabs_around(slb_x, slb_y);
if (slbkind == SlbT_GEMS)
{
remove_unwanted_things_from_wall_slab(slb_x, slb_y);
Expand Down
1 change: 1 addition & 0 deletions src/map_blocks.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ TbBool subtile_is_diggable_at_diagonal_angle(struct Thing *thing, unsigned short

#define place_slab_type_on_map(nslab, stl_x, stl_y, owner, keep_blocks_around) place_slab_type_on_map_f(nslab, stl_x, stl_y, owner, keep_blocks_around, __func__)
void place_slab_type_on_map_f(SlabKind nslab, MapSubtlCoord stl_x, MapSubtlCoord stl_y, PlayerNumber owner, unsigned char a5,const char *func_name);
void set_alt_bit_on_slabs_around(MapSlabCoord slb_x, MapSlabCoord slb_y);
void mine_out_block(MapSubtlCoord stl_x, MapSubtlCoord stl_y, PlayerNumber plyr_idx);
TbBool dig_has_revealed_area(MapSubtlCoord rev_stl_x, MapSubtlCoord rev_stl_y, PlayerNumber plyr_idx);
void dig_out_block(MapSubtlCoord stl_x, MapSubtlCoord stl_y, PlayerNumber plyr_idx);
Expand Down
1 change: 1 addition & 0 deletions src/room_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ TbBool replace_slab_from_script(MapSlabCoord slb_x, MapSlabCoord slb_y, unsigned
else
{
place_slab_type_on_map(slabkind, slab_subtile(slb_x, 0), slab_subtile(slb_y, 0), plyr_idx, 0);
set_alt_bit_on_slabs_around(slb_x, slb_y);
}
return true;
}
Expand Down

0 comments on commit fd1e6af

Please sign in to comment.