mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 18:53:06 +00:00
Fix annoying runtime with exosuit fab
This commit is contained in:
@@ -451,6 +451,7 @@
|
||||
if(..())
|
||||
return
|
||||
if(!allowed(user))
|
||||
to_chat(user, SPAN_WARNING("\The [src] rejects your use due to lack of access!"))
|
||||
return
|
||||
tgui_interact(user)
|
||||
|
||||
@@ -667,16 +668,54 @@
|
||||
/obj/machinery/mecha_part_fabricator/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
|
||||
var/matstring = lowertext(material)
|
||||
var/datum/material/M = get_material_by_name(matstring)
|
||||
|
||||
var/obj/item/stack/material/S = M.place_sheet(get_turf(src))
|
||||
// 0 or null, nothing to eject
|
||||
if(!materials[matstring])
|
||||
return
|
||||
// Problem, fix problem and abort
|
||||
if(materials[matstring] < 0)
|
||||
warning("[src] tried to eject material '[material]', which it has 'materials[matstring]' of!")
|
||||
materials[matstring] = 0
|
||||
return
|
||||
|
||||
// Find the material datum for our material
|
||||
var/datum/material/M = get_material_by_name(matstring)
|
||||
if(!M)
|
||||
warning("[src] tried to eject material '[matstring]', which didn't match any known material datum!")
|
||||
return
|
||||
// Find what type of sheets it makes
|
||||
var/obj/item/stack/material/S = M.stack_type
|
||||
if(!S)
|
||||
warning("[src] tried to eject material '[matstring]', which didn't have a stack_type!")
|
||||
return
|
||||
|
||||
// If we were passed -1, then it's recursive ejection and we should eject all we can
|
||||
if(amount <= 0)
|
||||
<<<<<<< HEAD
|
||||
amount = S.max_amount
|
||||
var/ejected = min(round(materials[matstring] / S.perunit), amount)
|
||||
S.amount = min(ejected, amount)
|
||||
if(S.amount <= 0)
|
||||
qdel(S)
|
||||
||||||| parent of dbb9fb762a... Merge pull request #11508 from VOREStation/Arokha/exoruntime
|
||||
amount = S.max_amount
|
||||
var/ejected = min(round(materials[matstring] / S.perunit), amount)
|
||||
if(!S.set_amount(ejected, amount))
|
||||
=======
|
||||
amount = initial(S.max_amount)
|
||||
// Smaller of what we have left, or the desired amount (note the amount is in sheets, but the array stores perunit values)
|
||||
var/ejected = min(round(materials[matstring] / initial(S.perunit)), amount)
|
||||
|
||||
// Place a sheet
|
||||
S = M.place_sheet(get_turf(src), ejected)
|
||||
if(!istype(S))
|
||||
warning("[src] tried to eject material '[material]', which didn't generate a proper stack when asked!")
|
||||
>>>>>>> dbb9fb762a... Merge pull request #11508 from VOREStation/Arokha/exoruntime
|
||||
return
|
||||
|
||||
// Reduce our amount stored
|
||||
materials[matstring] -= ejected * S.perunit
|
||||
|
||||
// Recurse if we have enough left for more sheets
|
||||
if(recursive && materials[matstring] >= S.perunit)
|
||||
eject_materials(matstring, -1)
|
||||
|
||||
@@ -29,12 +29,29 @@
|
||||
var/pass_color = FALSE // Will the item pass its own color var to the created item? Dyed cloth, wood, etc.
|
||||
var/strict_color_stacking = FALSE // Will the stack merge with other stacks that are different colors? (Dyed cloth, wood, etc)
|
||||
|
||||
/obj/item/stack/Initialize(var/ml, var/amount)
|
||||
/obj/item/stack/Initialize(var/ml, var/starting_amount)
|
||||
. = ..()
|
||||
if(!stacktype)
|
||||
stacktype = type
|
||||
<<<<<<< HEAD
|
||||
if(amount)
|
||||
src.amount = amount
|
||||
||||||| parent of dbb9fb762a... Merge pull request #11508 from VOREStation/Arokha/exoruntime
|
||||
if(!isnull(amount)) // Could be 0
|
||||
if(amount < 0)
|
||||
amount = max_amount
|
||||
set_amount(amount, TRUE)
|
||||
=======
|
||||
if(!isnull(starting_amount)) // Could be 0
|
||||
// Negative numbers are 'give full stack', like -1
|
||||
if(starting_amount < 0)
|
||||
// But sometimes a coder forgot to define what that even means
|
||||
if(max_amount)
|
||||
starting_amount = max_amount
|
||||
else
|
||||
starting_amount = 1
|
||||
set_amount(starting_amount, TRUE)
|
||||
>>>>>>> dbb9fb762a... Merge pull request #11508 from VOREStation/Arokha/exoruntime
|
||||
update_icon()
|
||||
|
||||
/obj/item/stack/Destroy()
|
||||
|
||||
@@ -233,27 +233,68 @@
|
||||
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
|
||||
<<<<<<< HEAD
|
||||
var/recursive = amount == -1 ? 1 : 0
|
||||
material = lowertext(material)
|
||||
var/obj/item/stack/material/mattype
|
||||
var/datum/material/MAT = get_material_by_name(material)
|
||||
||||||| parent of dbb9fb762a... Merge pull request #11508 from VOREStation/Arokha/exoruntime
|
||||
var/recursive = amount == -1 ? TRUE : FALSE
|
||||
material = lowertext(material)
|
||||
var/obj/item/stack/material/mattype
|
||||
var/datum/material/MAT = get_material_by_name(material)
|
||||
=======
|
||||
var/recursive = amount == -1 ? TRUE : FALSE
|
||||
var/matstring = lowertext(material)
|
||||
>>>>>>> dbb9fb762a... Merge pull request #11508 from VOREStation/Arokha/exoruntime
|
||||
|
||||
if(!MAT)
|
||||
// 0 or null, nothing to eject
|
||||
if(!materials[matstring])
|
||||
return
|
||||
// Problem, fix problem and abort
|
||||
if(materials[matstring] < 0)
|
||||
warning("[src] tried to eject material '[material]', which it has 'materials[matstring]' of!")
|
||||
materials[matstring] = 0
|
||||
return
|
||||
|
||||
mattype = MAT.stack_type
|
||||
|
||||
if(!mattype)
|
||||
// Find the material datum for our material
|
||||
var/datum/material/M = get_material_by_name(matstring)
|
||||
if(!M)
|
||||
warning("[src] tried to eject material '[matstring]', which didn't match any known material datum!")
|
||||
return
|
||||
// Find what type of sheets it makes
|
||||
var/obj/item/stack/material/S = M.stack_type
|
||||
if(!S)
|
||||
warning("[src] tried to eject material '[matstring]', which didn't have a stack_type!")
|
||||
return
|
||||
|
||||
var/obj/item/stack/material/S = new mattype(loc)
|
||||
// If we were passed -1, then it's recursive ejection and we should eject all we can
|
||||
if(amount <= 0)
|
||||
<<<<<<< HEAD
|
||||
amount = S.max_amount
|
||||
var/ejected = min(round(materials[material] / S.perunit), amount)
|
||||
S.amount = min(ejected, amount)
|
||||
if(S.amount <= 0)
|
||||
qdel(S)
|
||||
||||||| parent of dbb9fb762a... Merge pull request #11508 from VOREStation/Arokha/exoruntime
|
||||
amount = S.max_amount
|
||||
var/ejected = min(round(materials[material] / S.perunit), amount)
|
||||
if(!S.set_amount(ejected, amount))
|
||||
=======
|
||||
amount = initial(S.max_amount)
|
||||
// Smaller of what we have left, or the desired amount (note the amount is in sheets, but the array stores perunit values)
|
||||
var/ejected = min(round(materials[matstring] / initial(S.perunit)), amount)
|
||||
|
||||
// Place a sheet
|
||||
S = M.place_sheet(get_turf(src), ejected)
|
||||
if(!istype(S))
|
||||
warning("[src] tried to eject material '[material]', which didn't generate a proper stack when asked!")
|
||||
>>>>>>> dbb9fb762a... Merge pull request #11508 from VOREStation/Arokha/exoruntime
|
||||
return
|
||||
materials[material] -= ejected * S.perunit
|
||||
if(recursive && materials[material] >= S.perunit)
|
||||
eject_materials(material, -1)
|
||||
|
||||
// Reduce our amount stored
|
||||
materials[matstring] -= ejected * S.perunit
|
||||
|
||||
// Recurse if we have enough left for more sheets
|
||||
if(recursive && materials[matstring] >= S.perunit)
|
||||
eject_materials(matstring, -1)
|
||||
|
||||
Reference in New Issue
Block a user