Skip to content

Commit

Permalink
UI data improvements for plumbing reaction chamber (tgstation#88881)
Browse files Browse the repository at this point in the history
## About The Pull Request
- Catalysts would be stored in both `required_reagents` & `catalysts`
lists so it would occupy memory twice. This ensures they are stored in
their own respective lists thus saving memory
- Removes redundant `return FALSE` statements inside `ui_act()`. The
parent return value is already `FALSE` so we can just allow that to
return instead of explicitly specifying it when a certain condition
fails

## Changelog
:cl:
code: improved ui data code for plumbing reaction chamber
/:cl:
  • Loading branch information
SyncIt21 authored Jan 7, 2025
1 parent 816026f commit f33c275
Showing 1 changed file with 16 additions and 22 deletions.
38 changes: 16 additions & 22 deletions code/modules/plumbing/plumbers/reaction_chamber.dm
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@
///towards which temperature do we build (except during draining)?
var/target_temperature = 300

/obj/machinery/plumbing/reaction_chamber/Destroy()
return ..()

/obj/machinery/plumbing/reaction_chamber/Initialize(mapload, bolt, layer)
. = ..()
AddComponent(/datum/component/plumbing/reaction_chamber, bolt, layer)
Expand Down Expand Up @@ -94,8 +91,6 @@
var/list/reagents_data = list()
for(var/datum/reagent/required_reagent as anything in required_reagents) //make a list where the key is text, because that looks alot better in the ui than a typepath
var/list/reagent_data = list()
if(catalysts[required_reagent])
continue
reagent_data["name"] = initial(required_reagent.name)
reagent_data["volume"] = required_reagents[required_reagent]
reagents_data += list(reagent_data)
Expand Down Expand Up @@ -131,45 +126,48 @@
if(!input_reagent)
return FALSE

if(catalysts[input_reagent])
return FALSE

var/input_amount = text2num(params["amount"])
if(!input_amount)
return FALSE

if(!required_reagents[input_reagent])
var/input_amount = text2num(params["amount"])
if(input_amount)
required_reagents[input_reagent] = input_amount
return TRUE
return FALSE
required_reagents[input_reagent] = input_amount
return TRUE

if("remove")
var/reagent = get_chem_id(params["chem"])
if(reagent)
required_reagents.Remove(reagent)
return TRUE
return FALSE

if("temperature")
var/target = text2num(params["target"])
if(!isnull(target))
target_temperature = clamp(target, 0, 1000)
return TRUE
return FALSE

if("catalyst")
var/reagent = get_chem_id(params["chem"])

if(!reagent)
return FALSE

if(reagent && !catalysts[reagent])
if(!catalysts[reagent])
catalysts[reagent] = required_reagents[reagent]
required_reagents -= reagent
return TRUE
else
return FALSE

if("catremove")
var/reagent = get_chem_id(params["chem"])
if(reagent)
if(!reagent)
return FALSE

if(catalysts[reagent])
required_reagents[reagent] = catalysts[reagent]
catalysts -= reagent
return TRUE
return FALSE

var/result = handle_ui_act(action, params, ui, state)
if(isnull(result))
Expand Down Expand Up @@ -213,10 +211,6 @@

/obj/machinery/plumbing/reaction_chamber/chem/handle_reagents(seconds_per_tick)
if(reagents.ph < acidic_limit || reagents.ph > alkaline_limit)
//no power
if(machine_stat & NOPOWER)
return

//nothing to react with
var/num_of_reagents = length(reagents.reagent_list)
if(!num_of_reagents)
Expand Down

0 comments on commit f33c275

Please sign in to comment.