Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rooms also rebuild when destroyed #1152

Merged
merged 4 commits into from
Oct 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/player_compevents.c
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ long computer_event_check_rooms_full(struct Computer2 *comp, struct ComputerEven
long computer_event_rebuild_room(struct Computer2* comp, struct ComputerEvent* cevent, struct Event* event)
{
SYNCDBG(18, "Starting");
if (get_room_slabs_count(comp->dungeon->owner, event->target) == 0)
if (count_slabs_of_room_type(comp->dungeon->owner, event->target) == 0)
{
for (int i = 0; i < COMPUTER_PROCESSES_COUNT + 1; i++)
{
Expand Down
8 changes: 8 additions & 0 deletions src/room_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,10 @@ TbBool delete_room_slab(MapSlabCoord slb_x, MapSlabCoord slb_y, unsigned char is
if (room->slabs_count <= 1)
{
delete_room_flag(room);
if (count_slabs_of_room_type(room->owner, room->kind) <= 1)
{
event_create_event_or_update_nearby_existing_event(slb_x, slb_y, EvKind_RoomLost, room->owner, room->kind);
}
replace_room_slab(room, slb_x, slb_y, room->owner, is_destroyed);
kill_all_room_slabs_and_contents(room);
free_room_structure(room);
Expand Down Expand Up @@ -326,6 +330,10 @@ TbBool replace_slab_from_script(MapSlabCoord slb_x, MapSlabCoord slb_y, unsigned
delete_room_flag(room);
// Create a new one-slab room
place_room(plyr_idx, rkind, slab_subtile(slb_x, 0), slab_subtile(slb_y, 0));
if (count_slabs_of_room_type(room->owner, room->kind) <= 1)
{
event_create_event_or_update_nearby_existing_event(slb_x, slb_y, EvKind_RoomLost, room->owner, room->kind);
}
//Clean up old room
kill_all_room_slabs_and_contents(room);
free_room_structure(room);
Expand Down