| 1348 | static const int32_t DEFAULT_AGREEMENT_MULTIPLIER = 128; |
| 1349 | |
| 1350 | static int32_t get_buy_request_multiplier(df::item *item, const df::entity_buy_prices *buy_prices) { |
| 1351 | CHECK_NULL_POINTER(item); |
| 1352 | if (!buy_prices) |
| 1353 | return DEFAULT_AGREEMENT_MULTIPLIER; |
| 1354 | |
| 1355 | int16_t item_type = item->getType(); |
| 1356 | int16_t item_subtype = item->getSubtype(); |
| 1357 | int16_t mat_type = item->getMaterial(); |
| 1358 | int32_t mat_subtype = item->getMaterialIndex(); |
| 1359 | |
| 1360 | for (size_t idx = 0; idx < buy_prices->price.size(); ++idx) { |
| 1361 | if ((buy_prices->items->item_type[idx] == item_type) && |
| 1362 | (buy_prices->items->item_subtype[idx] == -1 || buy_prices->items->item_subtype[idx] == item_subtype) && |
| 1363 | (buy_prices->items->mat_types[idx] == -1 || buy_prices->items->mat_types[idx] == mat_type) && |
| 1364 | (buy_prices->items->mat_indices[idx] == -1 || buy_prices->items->mat_indices[idx] == mat_subtype) |
| 1365 | ) |
| 1366 | return buy_prices->price[idx]; |
| 1367 | } |
| 1368 | return DEFAULT_AGREEMENT_MULTIPLIER; |
| 1369 | } |
| 1370 | |
| 1371 | template<typename T> |
| 1372 | static int get_price(const vector<T> &res, int32_t val, const vector<int32_t> &pri) { |
no test coverage detected