Some more harddel fixes (#58305)

This commit is contained in:
LemonInTheDark
2021-04-11 19:37:20 -07:00
committed by GitHub
parent 269492047d
commit 54f0b0ceb9
11 changed files with 50 additions and 49 deletions

View File

@@ -167,3 +167,8 @@
/// For the pH meter flashing method /// For the pH meter flashing method
#define ENABLE_FLASHING -1 #define ENABLE_FLASHING -1
#define DISABLE_FLASHING 14 #define DISABLE_FLASHING 14
#define GOLDSCHLAGER_VODKA (10)
#define GOLDSCHLAGER_GOLD (1)
#define GOLDSCHLAGER_GOLD_RATIO (GOLDSCHLAGER_GOLD/(GOLDSCHLAGER_VODKA+GOLDSCHLAGER_GOLD))

View File

@@ -51,32 +51,32 @@
//there is at least one unique catalyst for the short reaction, so there is no conflict //there is at least one unique catalyst for the short reaction, so there is no conflict
return FALSE return FALSE
//if we got this far, the longer reaction will be impossible to create if the shorter one is earlier in GLOB.chemical_reactions_list, and will require the reagents to be added in a particular order otherwise //if we got this far, the longer reaction will be impossible to create if the shorter one is earlier in GLOB.chemical_reactions_list_reactant_index, and will require the reagents to be added in a particular order otherwise
return TRUE return TRUE
/proc/get_chemical_reaction(id) /proc/get_chemical_reaction(id)
if(!GLOB.chemical_reactions_list) if(!GLOB.chemical_reactions_list_reactant_index)
return return
for(var/reagent in GLOB.chemical_reactions_list) for(var/reagent in GLOB.chemical_reactions_list_reactant_index)
for(var/R in GLOB.chemical_reactions_list[reagent]) for(var/R in GLOB.chemical_reactions_list_reactant_index[reagent])
var/datum/reac = R var/datum/reac = R
if(reac.type == id) if(reac.type == id)
return R return R
/proc/remove_chemical_reaction(datum/chemical_reaction/R) /proc/remove_chemical_reaction(datum/chemical_reaction/R)
if(!GLOB.chemical_reactions_list || !R) if(!GLOB.chemical_reactions_list_reactant_index || !R)
return return
for(var/rid in R.required_reagents) for(var/rid in R.required_reagents)
GLOB.chemical_reactions_list[rid] -= R GLOB.chemical_reactions_list_reactant_index[rid] -= R
//see build_chemical_reactions_list in holder.dm for explanations //see build_chemical_reactions_list in holder.dm for explanations
/proc/add_chemical_reaction(datum/chemical_reaction/R) /proc/add_chemical_reaction(datum/chemical_reaction/R)
if(!GLOB.chemical_reactions_list || !R.required_reagents || !R.required_reagents.len) if(!GLOB.chemical_reactions_list_reactant_index || !R.required_reagents || !R.required_reagents.len)
return return
var/primary_reagent = R.required_reagents[1] var/primary_reagent = R.required_reagents[1]
if(!GLOB.chemical_reactions_list[primary_reagent]) if(!GLOB.chemical_reactions_list_reactant_index[primary_reagent])
GLOB.chemical_reactions_list[primary_reagent] = list() GLOB.chemical_reactions_list_reactant_index[primary_reagent] = list()
GLOB.chemical_reactions_list[primary_reagent] += R GLOB.chemical_reactions_list_reactant_index[primary_reagent] += R
//Creates foam from the reagent. Metaltype is for metal foam, notification is what to show people in textbox //Creates foam from the reagent. Metaltype is for metal foam, notification is what to show people in textbox
/datum/reagents/proc/create_foam(foamtype,foam_volume,metaltype = 0,notification = null) /datum/reagents/proc/create_foam(foamtype,foam_volume,metaltype = 0,notification = null)

View File

@@ -17,7 +17,8 @@ GLOBAL_LIST_EMPTY(alarmdisplay) //list of all machines or programs that
GLOBAL_LIST_EMPTY_TYPED(singularities, /datum/component/singularity) //list of all singularities on the station GLOBAL_LIST_EMPTY_TYPED(singularities, /datum/component/singularity) //list of all singularities on the station
GLOBAL_LIST_EMPTY(mechpad_list) //list of all /obj/machinery/mechpad GLOBAL_LIST_EMPTY(mechpad_list) //list of all /obj/machinery/mechpad
GLOBAL_LIST(chemical_reactions_list) //list of all /datum/chemical_reaction datums. Used during chemical reactions. Indexed by REACTANT types GLOBAL_LIST(chemical_reactions_list) //list of all /datum/chemical_reaction datums indexed by their typepath. Use this for general lookup stuff
GLOBAL_LIST(chemical_reactions_list_reactant_index) //list of all /datum/chemical_reaction datums. Used during chemical reactions. Indexed by REACTANT types
GLOBAL_LIST(chemical_reactions_list_product_index) //list of all /datum/chemical_reaction datums. Used for the reaction lookup UI. Indexed by PRODUCT type GLOBAL_LIST(chemical_reactions_list_product_index) //list of all /datum/chemical_reaction datums. Used for the reaction lookup UI. Indexed by PRODUCT type
GLOBAL_LIST(chemical_reagents_list) //list of all /datum/reagent datums indexed by reagent id. Used by chemistry stuff GLOBAL_LIST(chemical_reagents_list) //list of all /datum/reagent datums indexed by reagent id. Used by chemistry stuff
GLOBAL_LIST(chemical_reactions_results_lookup_list) //List of all reactions with their associated product and result ids. Used for reaction lookups GLOBAL_LIST(chemical_reactions_results_lookup_list) //List of all reactions with their associated product and result ids. Used for reaction lookups

View File

@@ -16,7 +16,7 @@
/datum/chemical_reaction/drink/goldschlager /datum/chemical_reaction/drink/goldschlager
results = list(/datum/reagent/consumable/ethanol/goldschlager = 10) results = list(/datum/reagent/consumable/ethanol/goldschlager = 10)
required_reagents = list(/datum/reagent/consumable/ethanol/vodka = 10, /datum/reagent/gold = 1) required_reagents = list(/datum/reagent/consumable/ethanol/vodka = GOLDSCHLAGER_VODKA, /datum/reagent/gold = GOLDSCHLAGER_GOLD)
reaction_tags = REACTION_TAG_DRINK | REACTION_TAG_EASY reaction_tags = REACTION_TAG_DRINK | REACTION_TAG_EASY
/datum/chemical_reaction/drink/patron /datum/chemical_reaction/drink/patron

View File

@@ -41,6 +41,11 @@
ADD_TRAIT(src, TRAIT_VENTCRAWLER_ALWAYS, INNATE_TRAIT) ADD_TRAIT(src, TRAIT_VENTCRAWLER_ALWAYS, INNATE_TRAIT)
/mob/living/simple_animal/hostile/regalrat/Destroy()
. = ..()
QDEL_NULL(domain)
QDEL_NULL(riot)
/mob/living/simple_animal/hostile/regalrat/proc/get_player() /mob/living/simple_animal/hostile/regalrat/proc/get_player()
var/list/mob/dead/observer/candidates = pollGhostCandidates("Do you want to play as the Royal Rat, cheesey be his crown?", ROLE_SENTIENCE, null, FALSE, 100, POLL_IGNORE_SENTIENCE_POTION) var/list/mob/dead/observer/candidates = pollGhostCandidates("Do you want to play as the Royal Rat, cheesey be his crown?", ROLE_SENTIENCE, null, FALSE, 100, POLL_IGNORE_SENTIENCE_POTION)
if(LAZYLEN(candidates) && !mind) if(LAZYLEN(candidates) && !mind)

View File

@@ -23,19 +23,20 @@
//Chemical Reactions - Initialises all /datum/chemical_reaction into a list //Chemical Reactions - Initialises all /datum/chemical_reaction into a list
// It is filtered into multiple lists within a list. // It is filtered into multiple lists within a list.
// For example: // For example:
// chemical_reaction_list[/datum/reagent/toxin/plasma] is a list of all reactions relating to plasma // chemical_reactions_list_reactant_index[/datum/reagent/toxin/plasma] is a list of all reactions relating to plasma
//For chemical reaction list product index - indexes reactions based off the product reagent type - see get_recipe_from_reagent_product() in helpers //For chemical reaction list product index - indexes reactions based off the product reagent type - see get_recipe_from_reagent_product() in helpers
//For chemical reactions list lookup list - creates a bit list of info passed to the UI. This is saved to reduce lag from new windows opening, since it's a lot of data. //For chemical reactions list lookup list - creates a bit list of info passed to the UI. This is saved to reduce lag from new windows opening, since it's a lot of data.
//Prevent these reactions from appearing in lookup tables (UI code) //Prevent these reactions from appearing in lookup tables (UI code)
var/list/blacklist = (/datum/chemical_reaction/randomized) var/list/blacklist = (/datum/chemical_reaction/randomized)
if(GLOB.chemical_reactions_list) if(GLOB.chemical_reactions_list_reactant_index)
return return
//Randomized need to go last since they need to check against conflicts with normal recipes //Randomized need to go last since they need to check against conflicts with normal recipes
var/paths = subtypesof(/datum/chemical_reaction) - typesof(/datum/chemical_reaction/randomized) + subtypesof(/datum/chemical_reaction/randomized) var/paths = subtypesof(/datum/chemical_reaction) - typesof(/datum/chemical_reaction/randomized) + subtypesof(/datum/chemical_reaction/randomized)
GLOB.chemical_reactions_list = list() //reagents to reaction list GLOB.chemical_reactions_list = list() //typepath to reaction list
GLOB.chemical_reactions_list_reactant_index = list() //reagents to reaction list
GLOB.chemical_reactions_results_lookup_list = list() //UI glob GLOB.chemical_reactions_results_lookup_list = list() //UI glob
GLOB.chemical_reactions_list_product_index = list() //product to reaction list GLOB.chemical_reactions_list_product_index = list() //product to reaction list
@@ -50,6 +51,8 @@
if(!D.required_reagents || !D.required_reagents.len) //Skip impossible reactions if(!D.required_reagents || !D.required_reagents.len) //Skip impossible reactions
continue continue
GLOB.chemical_reactions_list[path] = D
for(var/reaction in D.required_reagents) for(var/reaction in D.required_reagents)
reaction_ids += reaction reaction_ids += reaction
var/datum/reagent/reagent = find_reagent_object_from_type(reaction) var/datum/reagent/reagent = find_reagent_object_from_type(reaction)
@@ -81,9 +84,9 @@
// Create filters based on each reagent id in the required reagents list - this is used to speed up handle_reactions() // Create filters based on each reagent id in the required reagents list - this is used to speed up handle_reactions()
for(var/id in reaction_ids) for(var/id in reaction_ids)
if(!GLOB.chemical_reactions_list[id]) if(!GLOB.chemical_reactions_list_reactant_index[id])
GLOB.chemical_reactions_list[id] = list() GLOB.chemical_reactions_list_reactant_index[id] = list()
GLOB.chemical_reactions_list[id] += D GLOB.chemical_reactions_list_reactant_index[id] += D
break // Don't bother adding ourselves to other reagent ids, it is redundant break // Don't bother adding ourselves to other reagent ids, it is redundant
///////////////////////////////Main reagents code///////////////////////////////////////////// ///////////////////////////////Main reagents code/////////////////////////////////////////////
@@ -818,7 +821,7 @@
return FALSE return FALSE
var/list/cached_reagents = reagent_list var/list/cached_reagents = reagent_list
var/list/cached_reactions = GLOB.chemical_reactions_list var/list/cached_reactions = GLOB.chemical_reactions_list_reactant_index
var/datum/cached_my_atom = my_atom var/datum/cached_my_atom = my_atom
LAZYNULL(failed_but_capable_reactions) LAZYNULL(failed_but_capable_reactions)
@@ -1482,7 +1485,7 @@
var/list/possible_reactions = list() var/list/possible_reactions = list()
if(!length(cached_reagents)) if(!length(cached_reagents))
return null return null
cached_reactions = GLOB.chemical_reactions_list cached_reactions = GLOB.chemical_reactions_list_reactant_index
for(var/_reagent in cached_reagents) for(var/_reagent in cached_reagents)
var/datum/reagent/reagent = _reagent var/datum/reagent/reagent = _reagent
for(var/_reaction in cached_reactions[reagent.type]) // Was a big list but now it should be smaller since we filtered it with our reagent id for(var/_reaction in cached_reactions[reagent.type]) // Was a big list but now it should be smaller since we filtered it with our reagent id

View File

@@ -77,10 +77,10 @@
/obj/machinery/chem_recipe_debug/proc/setup_reactions() /obj/machinery/chem_recipe_debug/proc/setup_reactions()
cached_reactions = list() cached_reactions = list()
if(process_all) if(process_all)
for(var/reaction in GLOB.chemical_reactions_list) for(var/reaction in GLOB.chemical_reactions_list_reactant_index)
if(is_type_in_list(GLOB.chemical_reactions_list[reaction], cached_reactions)) if(is_type_in_list(GLOB.chemical_reactions_list_reactant_index[reaction], cached_reactions))
continue continue
cached_reactions += GLOB.chemical_reactions_list[reaction] cached_reactions += GLOB.chemical_reactions_list_reactant_index[reaction]
else else
cached_reactions = reaction_names cached_reactions = reaction_names
reagents.clear_reagents() reagents.clear_reagents()

View File

@@ -516,22 +516,9 @@ All effects don't start immediately, but rather get worse over time; the rate is
shot_glass_icon_state = "shotglassgold" shot_glass_icon_state = "shotglassgold"
chemical_flags = REAGENT_CAN_BE_SYNTHESIZED chemical_flags = REAGENT_CAN_BE_SYNTHESIZED
/// Ratio of gold that the goldschlager recipe contains
var/static/gold_ratio
// This drink is really popular with a certain demographic. // This drink is really popular with a certain demographic.
var/teenage_girl_quality = DRINK_VERYGOOD var/teenage_girl_quality = DRINK_VERYGOOD
/datum/reagent/consumable/ethanol/goldschlager/New()
. = ..()
if(!gold_ratio)
// Calculate the amount of gold that goldschlager is made from
var/datum/chemical_reaction/drink/goldschlager/goldschlager_reaction = new
var/vodka_amount = goldschlager_reaction.required_reagents[/datum/reagent/consumable/ethanol/vodka]
var/gold_amount = goldschlager_reaction.required_reagents[/datum/reagent/gold]
gold_ratio = gold_amount / (gold_amount + vodka_amount)
qdel(goldschlager_reaction)
/datum/reagent/consumable/ethanol/goldschlager/expose_mob(mob/living/exposed_mob, methods=TOUCH, reac_volume) /datum/reagent/consumable/ethanol/goldschlager/expose_mob(mob/living/exposed_mob, methods=TOUCH, reac_volume)
// Reset quality each time, since the bottle can be shared // Reset quality each time, since the bottle can be shared
quality = initial(quality) quality = initial(quality)
@@ -548,7 +535,7 @@ All effects don't start immediately, but rather get worse over time; the rate is
if(!(methods & INGEST)) if(!(methods & INGEST))
return ..() return ..()
var/convert_amount = trans_volume * gold_ratio var/convert_amount = trans_volume * min(GOLDSCHLAGER_GOLD_RATIO, 1)
A.reagents.remove_reagent(/datum/reagent/consumable/ethanol/goldschlager, convert_amount) A.reagents.remove_reagent(/datum/reagent/consumable/ethanol/goldschlager, convert_amount)
A.reagents.add_reagent(/datum/reagent/gold, convert_amount) A.reagents.add_reagent(/datum/reagent/gold, convert_amount)
return ..() return ..()

View File

@@ -35,7 +35,7 @@ GLOBAL_LIST_INIT(medicine_reagents, build_medicine_reagents())
/datum/chemical_reaction/randomized /datum/chemical_reaction/randomized
//Increase default leniency because these are already hard enough //Increase default leniency because these are already hard enough
optimal_ph_min = 1 optimal_ph_min = 1
optimal_ph_max = 13 optimal_ph_max = 13
temp_exponent_factor = 0 temp_exponent_factor = 0
ph_exponent_factor = 1 ph_exponent_factor = 1
@@ -92,28 +92,28 @@ GLOBAL_LIST_INIT(medicine_reagents, build_medicine_reagents())
if(randomize_req_temperature) if(randomize_req_temperature)
is_cold_recipe = pick(TRUE,FALSE) is_cold_recipe = pick(TRUE,FALSE)
if(is_cold_recipe) if(is_cold_recipe)
required_temp = rand(min_temp+50, max_temp) required_temp = rand(min_temp+50, max_temp)
optimal_temp = rand(min_temp+25, required_temp-10) optimal_temp = rand(min_temp+25, required_temp-10)
overheat_temp = rand(min_temp, optimal_temp-10) overheat_temp = rand(min_temp, optimal_temp-10)
if(overheat_temp >= 200) //Otherwise it can disappear when you're mixing and I don't want this to happen here if(overheat_temp >= 200) //Otherwise it can disappear when you're mixing and I don't want this to happen here
overheat_temp = 200 overheat_temp = 200
if(exo_or_endothermic) if(exo_or_endothermic)
thermic_constant = (rand(-200, 200)) thermic_constant = (rand(-200, 200))
else else
required_temp = rand(min_temp, max_temp-50) required_temp = rand(min_temp, max_temp-50)
optimal_temp = rand(required_temp+10, max_temp-25) optimal_temp = rand(required_temp+10, max_temp-25)
overheat_temp = rand(optimal_temp, max_temp+50) overheat_temp = rand(optimal_temp, max_temp+50)
if(overheat_temp <= 400) if(overheat_temp <= 400)
overheat_temp = 400 overheat_temp = 400
if(exo_or_endothermic) if(exo_or_endothermic)
thermic_constant = (rand(-200, 200)) thermic_constant = (rand(-200, 200))
if(randomize_req_ph) if(randomize_req_ph)
optimal_ph_min = min_ph + rand(0, inoptimal_range_ph) optimal_ph_min = min_ph + rand(0, inoptimal_range_ph)
optimal_ph_max = max((max_ph + rand(0, inoptimal_range_ph)), (min_ph + 1)) //Always ensure we've a window of 1 optimal_ph_max = max((max_ph + rand(0, inoptimal_range_ph)), (min_ph + 1)) //Always ensure we've a window of 1
determin_ph_range = inoptimal_range_ph determin_ph_range = inoptimal_range_ph
H_ion_release = (rand(0, 25)/100)// 0 - 0.25 H_ion_release = (rand(0, 25)/100)// 0 - 0.25
if(randomize_impurity_minimum) if(randomize_impurity_minimum)
purity_min = (rand(0, 4)/10) purity_min = (rand(0, 4)/10)
@@ -169,7 +169,7 @@ GLOBAL_LIST_INIT(medicine_reagents, build_medicine_reagents())
/datum/chemical_reaction/randomized/proc/HasConflicts() /datum/chemical_reaction/randomized/proc/HasConflicts()
for(var/x in required_reagents) for(var/x in required_reagents)
for(var/datum/chemical_reaction/R in GLOB.chemical_reactions_list[x]) for(var/datum/chemical_reaction/R in GLOB.chemical_reactions_list_reactant_index[x])
if(chem_recipes_do_conflict(R,src)) if(chem_recipes_do_conflict(R,src))
return TRUE return TRUE
return FALSE return FALSE

View File

@@ -6,8 +6,8 @@
build_chemical_reactions_lists() build_chemical_reactions_lists()
build_chemical_reagent_list() build_chemical_reagent_list()
for(var/I in GLOB.chemical_reactions_list) for(var/I in GLOB.chemical_reactions_list_reactant_index)
for(var/V in GLOB.chemical_reactions_list[I]) for(var/V in GLOB.chemical_reactions_list_reactant_index[I])
var/datum/chemical_reaction/R = V var/datum/chemical_reaction/R = V
for(var/id in (R.required_reagents + R.required_catalysts)) for(var/id in (R.required_reagents + R.required_catalysts))
if(!GLOB.chemical_reagents_list[id]) if(!GLOB.chemical_reagents_list[id])

View File

@@ -5,8 +5,8 @@
/datum/unit_test/reagent_recipe_collisions/Run() /datum/unit_test/reagent_recipe_collisions/Run()
build_chemical_reactions_lists() build_chemical_reactions_lists()
var/list/reactions = list() var/list/reactions = list()
for(var/V in GLOB.chemical_reactions_list) for(var/V in GLOB.chemical_reactions_list_reactant_index)
reactions += GLOB.chemical_reactions_list[V] reactions += GLOB.chemical_reactions_list_reactant_index[V]
for(var/i in 1 to (reactions.len-1)) for(var/i in 1 to (reactions.len-1))
for(var/i2 in (i+1) to reactions.len) for(var/i2 in (i+1) to reactions.len)
var/datum/chemical_reaction/r1 = reactions[i] var/datum/chemical_reaction/r1 = reactions[i]