MCPcopy Create free account
hub / github.com/DFHack/dfhack / decrement_counter

Function decrement_counter

plugins/timestream.cpp:421–427  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

419
420template <typename FT, typename T>
421static void decrement_counter(T *obj, FT T::*field, int32_t timeskip) {
422 if (obj->*field <= 0)
423 return;
424 // TODO: check for overflow/underflow
425 int32_t cur_val = static_cast<int32_t>(obj->*field);
426 obj->*field = static_cast<FT>(std::max(1, cur_val - timeskip));
427}
428
429static void adjust_unit_counters(df::unit * unit, int32_t timeskip) {
430 auto * c1 = &unit->counters;

Callers 5

adjust_unit_countersFunction · 0.85
adjust_job_counterFunction · 0.85
adjust_unitsFunction · 0.85
adjust_activitiesFunction · 0.85
adjust_buildingsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected