Skip to content

Commit

Permalink
[MIRROR] Skip abstract types in merchant list generation
Browse files Browse the repository at this point in the history
  • Loading branch information
SierraKomodo authored and SuhEugene committed Nov 23, 2023
1 parent eb95eba commit 9c74c68
Showing 1 changed file with 16 additions and 31 deletions.
47 changes: 16 additions & 31 deletions code/datums/trading/trade.dm
Original file line number Diff line number Diff line change
Expand Up @@ -62,37 +62,22 @@
add_to_pool(trading_items, possible_trading_items, force = 1)
add_to_pool(wanted_items, possible_wanted_items, force = 1)

/datum/trader/proc/generate_pool(list/trading_pool)
. = list()
// Add types
for(var/type in trading_pool)
var/status = trading_pool[type]
if(status & TRADER_THIS_TYPE)
. += type
if(status & TRADER_SUBTYPES_ONLY)
. += subtypesof(type)

// Remove blacklisted
for (var/type in .)
var/status = trading_pool[type]
if (HAS_FLAGS(status, TRADER_BLACKLIST) || !validate_type_for_trade(type))
. -= type
if (HAS_FLAGS(status, TRADER_BLACKLIST_SUB))
. -= subtypesof(type)


/**
* Validates a given type can be used for trading. Intended to prevent certain items from being attainable via merchants.
*
* Returns boolean.
*/
/datum/trader/proc/validate_type_for_trade(type)
if (isatom(type))
var/atom/atom = type
// Block abstracts
if (type == initial(atom.abstract_type))
return FALSE
return TRUE

/datum/trader/proc/generate_pool(list/pool)
var/list/result = list()
for (var/path in pool)
var/status = pool[path]
if (GET_FLAGS(status, TRADER_THIS_TYPE) && !is_abstract(path))
result += path
if (GET_FLAGS(status, TRADER_SUBTYPES_ONLY))
result += subtypesof_real(path)
for (var/path in result)
var/status = pool[path]
if (GET_FLAGS(status, TRADER_BLACKLIST))
result -= path
if (GET_FLAGS(status, TRADER_BLACKLIST_SUB))
result -= subtypesof(path)
return result


//If this hits 0 then they decide to up and leave.
Expand Down

0 comments on commit 9c74c68

Please sign in to comment.