| 1207 | } |
| 1208 | |
| 1209 | bool Buildings::constructWithFilters(df::building *bld, std::vector<df::job_item*> items) |
| 1210 | { |
| 1211 | CHECK_NULL_POINTER(bld); |
| 1212 | CHECK_INVALID_ARGUMENT(bld->id == -1); |
| 1213 | CHECK_INVALID_ARGUMENT(bld->isActual()); |
| 1214 | CHECK_INVALID_ARGUMENT(!items.empty() == needsItems(bld)); |
| 1215 | |
| 1216 | for (size_t i = 0; i < items.size(); i++) |
| 1217 | CHECK_NULL_POINTER(items[i]); |
| 1218 | |
| 1219 | df::job *job = NULL; |
| 1220 | if (!linkForConstruct(job, bld)) |
| 1221 | { |
| 1222 | for (size_t i = 0; i < items.size(); i++) |
| 1223 | delete items[i]; |
| 1224 | |
| 1225 | return false; |
| 1226 | } |
| 1227 | |
| 1228 | bool rough = false; |
| 1229 | |
| 1230 | for (size_t i = 0; i < items.size(); i++) |
| 1231 | { |
| 1232 | if (items[i]->quantity < 0) |
| 1233 | items[i]->quantity = computeMaterialAmount(bld); |
| 1234 | |
| 1235 | /* The game picks up explicitly listed items in reverse |
| 1236 | * order, but processes filters straight. This reverses |
| 1237 | * the order of filters so as to produce the same final |
| 1238 | * contained_items ordering as the normal ui way. */ |
| 1239 | vector_insert_at(job->job_items.elements, 0, items[i]); |
| 1240 | |
| 1241 | if (items[i]->item_type == item_type::BOULDER) |
| 1242 | rough = true; |
| 1243 | if (bld->mat_type == -1) |
| 1244 | bld->mat_type = items[i]->mat_type; |
| 1245 | if (bld->mat_index == -1) |
| 1246 | bld->mat_index = items[i]->mat_index; |
| 1247 | } |
| 1248 | |
| 1249 | buildings_do_onupdate = true; |
| 1250 | |
| 1251 | add_building_to_all_zones(bld); |
| 1252 | |
| 1253 | createDesign(bld, rough); |
| 1254 | return true; |
| 1255 | } |
| 1256 | |
| 1257 | static void delete_civzone_squad_links(df::building_civzonest* zone) |
| 1258 | { |
nothing calls this directly
no test coverage detected