| 325 | using df_tick_type = std::remove_reference_t<decltype(*cur_year_tick)>; |
| 326 | |
| 327 | static df_tick_type flow_next_required_tick(int flow_index) |
| 328 | { |
| 329 | using namespace df::enums::flow_type; |
| 330 | |
| 331 | const auto flow = (*flows)[flow_index]; |
| 332 | |
| 333 | if (flow == nullptr || flow->flags.bits.DEAD) |
| 334 | return std::numeric_limits<df_tick_type>::max(); |
| 335 | |
| 336 | const auto cur_tick = *cur_year_tick; |
| 337 | |
| 338 | struct update_parameters_t { |
| 339 | int speed; |
| 340 | int cycle; |
| 341 | }; |
| 342 | |
| 343 | const auto [speed, cycle] = [flow] () -> update_parameters_t { |
| 344 | switch (flow->type) |
| 345 | { |
| 346 | case ItemCloud: |
| 347 | case MaterialDust: |
| 348 | case MaterialGas: |
| 349 | case MaterialVapor: |
| 350 | if (flow->flags.bits.CREEPING) |
| 351 | return update_parameters_t{10, 100}; |
| 352 | else |
| 353 | return update_parameters_t{1, 5}; |
| 354 | case Dragonfire: |
| 355 | case Fire: |
| 356 | case Web: |
| 357 | return update_parameters_t{1, 3}; |
| 358 | default: |
| 359 | return update_parameters_t{10, 100}; |
| 360 | } |
| 361 | }(); |
| 362 | |
| 363 | const int stride = cycle / speed; |
| 364 | |
| 365 | const int phase = (flow_index % stride) * speed; |
| 366 | |
| 367 | const int cur_phase = cur_tick % cycle; |
| 368 | |
| 369 | return cur_tick + (phase - cur_phase) + ((cur_phase > phase) ? cycle : 0); |
| 370 | } |
| 371 | |
| 372 | static df_tick_type flows_next_required_tick() { |
| 373 | if (flows == nullptr || flows->empty()) |
no outgoing calls
no test coverage detected