Personal crafting & Dependencies

This commit is contained in:
Chompstation Bot
2021-05-06 04:51:46 +00:00
committed by Darlantan
parent 04a8c35801
commit d7f20396de
42 changed files with 2569 additions and 386 deletions

View File

@@ -416,13 +416,9 @@ This actually tests if they have the same entries and values.
//Mergesort: any value in a list
/proc/sortList(var/list/L)
if(L.len < 2)
return L
var/middle = L.len / 2 + 1 // Copy is first,second-1
return mergeLists(sortList(L.Copy(0,middle)), sortList(L.Copy(middle))) //second parameter null = to end of list
//any value in a list
/proc/sortList(list/L, cmp=/proc/cmp_text_asc)
return sortTim(L.Copy(), cmp)
//Mergsorge: uses sortList() but uses the var's name specifically. This should probably be using mergeAtom() instead
/proc/sortNames(var/list/L)

View File

@@ -256,6 +256,7 @@ GLOBAL_LIST_EMPTY(mannequins)
var/datum/digest_mode/DM = new T
GLOB.digest_modes[DM.id] = DM
// VOREStation Add End
init_crafting_recipes(GLOB.crafting_recipes)
/*
// Custom species traits
@@ -292,8 +293,13 @@ GLOBAL_LIST_EMPTY(mannequins)
return 1 // Hooks must return 1
return 1
/// Inits the crafting recipe list, sorting crafting recipe requirements in the process.
/proc/init_crafting_recipes(list/crafting_recipes)
for(var/path in subtypesof(/datum/crafting_recipe))
var/datum/crafting_recipe/recipe = new path()
recipe.reqs = sortList(recipe.reqs, /proc/cmp_crafting_req_priority)
crafting_recipes += recipe
return crafting_recipes
/* // Uncomment to debug chemical reaction list.
/client/verb/debug_chemical_list()

View File

@@ -64,4 +64,23 @@
return b_score - a_score
/proc/cmp_typepaths_asc(A, B)
return sorttext("[B]","[A]")
return sorttext("[B]","[A]")
/**
* Sorts crafting recipe requirements before the crafting recipe is inserted into GLOB.crafting_recipes
*
* Prioritises [/datum/reagent] to ensure reagent requirements are always processed first when crafting.
* This prevents any reagent_containers from being consumed before the reagents they contain, which can
* lead to runtimes and item duplication when it happens.
*/
/proc/cmp_crafting_req_priority(A, B)
var/lhs
var/rhs
lhs = ispath(A, /datum/reagent) ? 0 : 1
rhs = ispath(B, /datum/reagent) ? 0 : 1
return lhs - rhs
/proc/cmp_text_asc(a,b)
return sorttext(b,a)

View File

@@ -0,0 +1,14 @@
GLOBAL_LIST_EMPTY(string_lists)
/**
* Caches lists with non-numeric stringify-able values (text or typepath).
*/
/proc/string_list(list/values)
var/string_id = values.Join("-")
. = GLOB.string_lists[string_id]
if(.)
return
return GLOB.string_lists[string_id] = values