| 920 | } |
| 921 | |
| 922 | bool Buildings::setSize(df::building *bld, df::coord2d size, int direction) |
| 923 | { |
| 924 | CHECK_NULL_POINTER(bld); |
| 925 | CHECK_INVALID_ARGUMENT(bld->id == -1); |
| 926 | |
| 927 | // Compute correct size and apply it |
| 928 | df::coord2d old_size = size; |
| 929 | df::coord2d center; |
| 930 | getCorrectSize(size, center, bld->getType(), bld->getSubtype(), |
| 931 | bld->getCustomType(), direction); |
| 932 | |
| 933 | // Delete old extents if size has changed. |
| 934 | if (old_size != size && bld->room.extents) |
| 935 | { |
| 936 | delete[] bld->room.extents; |
| 937 | bld->room.extents = NULL; |
| 938 | } |
| 939 | |
| 940 | bld->x2 = bld->x1 + size.x - 1; |
| 941 | bld->y2 = bld->y1 + size.y - 1; |
| 942 | bld->centerx = bld->x1 + center.x; |
| 943 | bld->centery = bld->y1 + center.y; |
| 944 | |
| 945 | auto type = bld->getType(); |
| 946 | |
| 947 | switch (type) |
| 948 | { |
| 949 | using namespace df::enums::building_type; |
| 950 | case WaterWheel: |
| 951 | { |
| 952 | auto obj = (df::building_water_wheelst*)bld; |
| 953 | obj->is_vertical = !!direction; |
| 954 | break; |
| 955 | } |
| 956 | case AxleHorizontal: |
| 957 | { |
| 958 | auto obj = (df::building_axle_horizontalst*)bld; |
| 959 | obj->is_vertical = !!direction; |
| 960 | break; |
| 961 | } |
| 962 | case ScrewPump: |
| 963 | { |
| 964 | auto obj = (df::building_screw_pumpst*)bld; |
| 965 | obj->direction = (df::screw_pump_direction)direction; |
| 966 | break; |
| 967 | } |
| 968 | case Rollers: |
| 969 | { |
| 970 | auto obj = (df::building_rollersst*)bld; |
| 971 | obj->direction = (df::screw_pump_direction)direction; |
| 972 | break; |
| 973 | } |
| 974 | case Bridge: |
| 975 | { |
| 976 | auto obj = (df::building_bridgest*)bld; |
| 977 | auto psize = getSize(bld); |
| 978 | obj->gate_flags.bits.has_support = hasSupport(psize.first, psize.second); |
| 979 | obj->direction = (df::building_bridgest::T_direction)direction; |
nothing calls this directly
no test coverage detected