| 759 | } |
| 760 | |
| 761 | static df::unit *getOperatorUnit(df::building_siegeenginest *bld, bool force = false) |
| 762 | { |
| 763 | CHECK_NULL_POINTER(bld); |
| 764 | |
| 765 | auto engine = find_engine(bld); |
| 766 | if (!engine) |
| 767 | return NULL; |
| 768 | |
| 769 | if (engine->operator_id != -1 && |
| 770 | (world->frame_counter - engine->operator_frame) <= 5) |
| 771 | { |
| 772 | auto op_unit = df::unit::find(engine->operator_id); |
| 773 | if (op_unit) |
| 774 | return op_unit; |
| 775 | } |
| 776 | |
| 777 | if (force) |
| 778 | { |
| 779 | color_ostream_proxy out(Core::getInstance().getConsole()); |
| 780 | out.print("Forced siege operator search\n"); |
| 781 | |
| 782 | auto &active = world->units.active; |
| 783 | for (size_t i = 0; i < active.size(); i++) |
| 784 | if (active[i]->pos == engine->center && Units::isCitizen(active[i])) |
| 785 | return active[i]; |
| 786 | } |
| 787 | |
| 788 | return NULL; |
| 789 | } |
| 790 | |
| 791 | /* |
| 792 | * Trajectory raytracing |
no test coverage detected