MCPcopy Create free account
hub / github.com/DFHack/dfhack / get_buy_request_multiplier

Function get_buy_request_multiplier

library/modules/Items.cpp:1350–1369  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1348static const int32_t DEFAULT_AGREEMENT_MULTIPLIER = 128;
1349
1350static 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
1371template<typename T>
1372static int get_price(const vector<T> &res, int32_t val, const vector<int32_t> &pri) {

Callers 2

getValueMethod · 0.85
is_requested_trade_goodFunction · 0.85

Calls 2

getTypeMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected