Skip to content

Commit

Permalink
Computer will rebuild Rooms when destroyed (#1152)
Browse files Browse the repository at this point in the history
Rooms can be destroyed by attacking it with units and the call to arm spell.
  • Loading branch information
Loobinex committed Oct 16, 2021
1 parent 8982497 commit 6b50ca1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
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

0 comments on commit 6b50ca1

Please sign in to comment.