| 419 | |
| 420 | template <typename FT, typename T> |
| 421 | static 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 | |
| 429 | static void adjust_unit_counters(df::unit * unit, int32_t timeskip) { |
| 430 | auto * c1 = &unit->counters; |
no outgoing calls
no test coverage detected