fixes infinite morphium duplication exploit (#9046)

* fixes very old exploit that we literally just discovered

* this is what i get for speedrunning a bugfix

* reworks material ejection code

* literally it worked fine this is just so github likes it

* Update code/game/machinery/autolathe.dm

Co-authored-by: Atermonera <atermonera@gmail.com>

* Update code/game/machinery/autolathe.dm

Co-authored-by: Atermonera <atermonera@gmail.com>

* code prettiness

---------

Co-authored-by: Atermonera <atermonera@gmail.com>
This commit is contained in:
Varlaisvea
2023-05-28 10:55:00 -08:00
committed by GitHub
co-authored by Atermonera
parent d4134ced6f
commit 0530f2458a
11 changed files with 58 additions and 126 deletions
@@ -92,6 +92,10 @@
name = "stack of durasteel hull"
type_to_spawn = /obj/item/stack/material/durasteel/hull
/obj/fiftyspawner/grass
name = "stack of grass"
type_to_spawn = /obj/item/stack/material/grass
/obj/fiftyspawner/wood
name = "stack of wood"
type_to_spawn = /obj/item/stack/material/wood
@@ -1,7 +1,7 @@
/datum/material/grass
name = MAT_GRASS
name = "grass"
display_name = "grass"
stack_type = /obj/item/stack/tile/grass
stack_type = /obj/item/stack/material/grass
ignition_point = T0C+300
melting_point = T0C+300
protectiveness = 0
@@ -27,5 +27,6 @@
new /datum/stack_recipe("pink-and-purple flowers", /obj/structure/flora/ausbushes/ppflowers, 3, one_per_turf = 0, on_floor = 1, recycle_material = "[name]"),
new /datum/stack_recipe("sparse grass", /obj/structure/flora/ausbushes/sparsegrass, 3, one_per_turf = 0, on_floor = 1, recycle_material = "[name]"),
new /datum/stack_recipe("full grass", /obj/structure/flora/ausbushes/fullgrass, 3, one_per_turf = 0, on_floor = 1, recycle_material = "[name]")
))
)),
new /datum/stack_recipe("grass floor tile", /obj/item/stack/tile/grass, 1, 4, 20, pass_stack_color = TRUE, recycle_material = "[name]"),
)
@@ -53,3 +53,8 @@
to_chat(user, "<span class='notice'>You add the newly-formed wood to the stack. It now contains [existing_wood.amount] planks.</span>")
else
return ..()
/obj/item/stack/material/grass
name = "grass"
icon_state = "tile_grass"
default_type = "grass"
+2 -30
View File
@@ -81,11 +81,9 @@
speed = T / 2
/obj/machinery/r_n_d/protolathe/dismantle()
for(var/f in materials)
eject_materials(f, -1)
eject_materials() //Proc on obj/machinery in code/game/machinery/machinery.dm
..()
/obj/machinery/r_n_d/protolathe/update_icon()
cut_overlays()
@@ -211,30 +209,4 @@
if(mat_efficiency != 1) // No matter out of nowhere
if(new_item.matter && new_item.matter.len > 0)
for(var/i in new_item.matter)
new_item.matter[i] = new_item.matter[i] * mat_efficiency
/obj/machinery/r_n_d/protolathe/proc/eject_materials(var/material, var/amount) // 0 amount = 0 means ejecting a full stack; -1 means eject everything
var/recursive = amount == -1 ? 1 : 0
material = lowertext(material)
var/obj/item/stack/material/mattype
var/datum/material/MAT = get_material_by_name(material)
if(!MAT)
return
mattype = MAT.stack_type
if(!mattype)
return
var/obj/item/stack/material/S = new mattype(loc)
if(amount <= 0)
amount = S.max_amount
var/ejected = min(round(materials[material] / S.perunit), amount)
S.amount = min(ejected, amount)
if(S.amount <= 0)
qdel(S)
return
materials[material] -= ejected * S.perunit
if(recursive && materials[material] >= S.perunit)
eject_materials(material, -1)
new_item.matter[i] = new_item.matter[i] * mat_efficiency
+1 -1
View File
@@ -11,7 +11,7 @@
var/busy = 0
var/obj/machinery/computer/rdconsole/linked_console
var/list/materials = list() // Materials this machine can accept.
materials = list() // Materials this machine can accept.
var/list/hidden_materials = list() // Materials this machine will not display, unless it contains them. Must be in the materials list as well.
/obj/machinery/r_n_d/attack_hand(mob/user as mob)