|
30 | 30 | #include "df/activity_event_writest.h" |
31 | 31 | #include "df/activity_event_worshipst.h" |
32 | 32 | #include "df/building_nest_boxst.h" |
| 33 | +#include "df/building_trapst.h" |
33 | 34 | #include "df/init.h" |
34 | 35 | #include "df/item_eggst.h" |
35 | 36 | #include "df/unit.h" |
@@ -579,6 +580,21 @@ static void adjust_activities(color_ostream &out, int32_t timeskip) { |
579 | 580 | } |
580 | 581 | } |
581 | 582 |
|
| 583 | +static void adjust_buildings(color_ostream &out, int32_t timeskip) { |
| 584 | + // decrement trap timers |
| 585 | + for (df::building_trapst *tr : world->buildings.other.TRAP) { |
| 586 | + decrement_counter(tr, &df::building_trapst::ready_timeout, timeskip); |
| 587 | + // used by pressure plates to delay until the plate is triggerable again |
| 588 | + // other trap types never set this to a value higher than 1 so it is safe to decrement here |
| 589 | + decrement_counter(tr, &df::building_trapst::state, timeskip); |
| 590 | + } |
| 591 | + |
| 592 | + for (df::building *bld : world->buildings.all) { |
| 593 | + // assumes age > 0, but that will become true very quickly for all new buildings |
| 594 | + increment_counter(bld, &df::building::age, timeskip); |
| 595 | + } |
| 596 | +} |
| 597 | + |
582 | 598 | static void adjust_items(color_ostream &out, int32_t timeskip) { |
583 | 599 | // increment incubation counters for fertile eggs in non-forbidden nestboxes |
584 | 600 | for (df::building_nest_boxst *nb : world->buildings.other.NEST_BOX) { |
@@ -636,6 +652,7 @@ static void do_cycle(color_ostream &out) { |
636 | 652 |
|
637 | 653 | adjust_units(out, timeskip); |
638 | 654 | adjust_activities(out, timeskip); |
| 655 | + adjust_buildings(out, timeskip); |
639 | 656 | adjust_items(out, timeskip); |
640 | 657 | } |
641 | 658 |
|
|
0 commit comments