Skip to content

Commit 131a8f2

Browse files
authored
Merge pull request #5070 from myk002/myk_timestream
[timestream] update building counters
2 parents ae6dd93 + 4e4b21e commit 131a8f2

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

docs/changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ Template for new versions:
6363
- `autobutcher`: don't run a scanning and marking cycle on the first tick of a fortress to allow for all custom configuration to be set first
6464
- `nestboxes`: don't consider eggs to be infertile just because the mother has left the nest; eggs can still hatch in this situation
6565
- `timestream`: adjust the incubation counter on fertile eggs so they hatch at the expected time
66+
- `timestream`: adjust the timeout on traps so they can be re-triggered at normal rates
6667
- `logistics`: don't ignore rotten items when applying stockpile logistics operations (e.g. autodump, autoclaim, etc.)
6768

6869
## Misc Improvements

plugins/timestream.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "df/activity_event_writest.h"
3131
#include "df/activity_event_worshipst.h"
3232
#include "df/building_nest_boxst.h"
33+
#include "df/building_trapst.h"
3334
#include "df/init.h"
3435
#include "df/item_eggst.h"
3536
#include "df/unit.h"
@@ -579,6 +580,21 @@ static void adjust_activities(color_ostream &out, int32_t timeskip) {
579580
}
580581
}
581582

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+
582598
static void adjust_items(color_ostream &out, int32_t timeskip) {
583599
// increment incubation counters for fertile eggs in non-forbidden nestboxes
584600
for (df::building_nest_boxst *nb : world->buildings.other.NEST_BOX) {
@@ -636,6 +652,7 @@ static void do_cycle(color_ostream &out) {
636652

637653
adjust_units(out, timeskip);
638654
adjust_activities(out, timeskip);
655+
adjust_buildings(out, timeskip);
639656
adjust_items(out, timeskip);
640657
}
641658

0 commit comments

Comments
 (0)