Skip to content

Commit fb010a5

Browse files
committed
Merge branch 'develop' into sdl_console
2 parents 5f791a6 + c14701a commit fb010a5

5 files changed

Lines changed: 24 additions & 2 deletions

File tree

depends/lua/include/dfhack_llimits.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ struct lua_extra_state {
5757
#define luai_userstateopen(L) do { \
5858
luai_mutex(L) = (mutex_t*)malloc(sizeof(mutex_t)); \
5959
pthread_mutexattr_t attr; \
60+
pthread_mutexattr_init(&attr); \
6061
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); \
6162
pthread_mutex_init(luai_mutex(L), &attr); \
6263
} while (0)

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

library/Core.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,10 @@ void get_commands(color_ostream &con, std::vector<std::string> &commands) {
460460
static bool try_autocomplete(color_ostream &con, const std::string &first, std::string &completed)
461461
{
462462
std::vector<std::string> commands, possible;
463-
get_commands(con, commands);
463+
464+
// restore call to get_commands once we have updated the core lock to a deferred lock
465+
// so calling Lua from the console thread won't deadlock if Lua is currently busy
466+
//get_commands(con, commands);
464467
for (auto &command : commands)
465468
if (command.substr(0, first.size()) == first)
466469
possible.push_back(command);

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)