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

[timestream] update building counters #5070

Merged
merged 1 commit into from
Dec 6, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ Template for new versions:
- `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
- `nestboxes`: don't consider eggs to be infertile just because the mother has left the nest; eggs can still hatch in this situation
- `timestream`: adjust the incubation counter on fertile eggs so they hatch at the expected time
- `timestream`: adjust the timeout on traps so they can be re-triggered at normal rates
- `logistics`: don't ignore rotten items when applying stockpile logistics operations (e.g. autodump, autoclaim, etc.)

## Misc Improvements
Expand Down
17 changes: 17 additions & 0 deletions plugins/timestream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "df/activity_event_writest.h"
#include "df/activity_event_worshipst.h"
#include "df/building_nest_boxst.h"
#include "df/building_trapst.h"
#include "df/init.h"
#include "df/item_eggst.h"
#include "df/unit.h"
Expand Down Expand Up @@ -579,6 +580,21 @@ static void adjust_activities(color_ostream &out, int32_t timeskip) {
}
}

static void adjust_buildings(color_ostream &out, int32_t timeskip) {
// decrement trap timers
for (df::building_trapst *tr : world->buildings.other.TRAP) {
decrement_counter(tr, &df::building_trapst::ready_timeout, timeskip);
// used by pressure plates to delay until the plate is triggerable again
// other trap types never set this to a value higher than 1 so it is safe to decrement here
decrement_counter(tr, &df::building_trapst::state, timeskip);
}

for (df::building *bld : world->buildings.all) {
// assumes age > 0, but that will become true very quickly for all new buildings
increment_counter(bld, &df::building::age, timeskip);
}
}

static void adjust_items(color_ostream &out, int32_t timeskip) {
// increment incubation counters for fertile eggs in non-forbidden nestboxes
for (df::building_nest_boxst *nb : world->buildings.other.NEST_BOX) {
Expand Down Expand Up @@ -636,6 +652,7 @@ static void do_cycle(color_ostream &out) {

adjust_units(out, timeskip);
adjust_activities(out, timeskip);
adjust_buildings(out, timeskip);
adjust_items(out, timeskip);
}

Expand Down
Loading