Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes a stackcrafting issue #6021

Merged
merged 1 commit into from
Sep 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion code/datums/recipe/material_recipe.dm
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
/datum/stack_recipe/material/check(atom/where, amount, obj/item/stack/material/stack, mob/user, silent, use_dir)
return ..()

/datum/stack_recipe/material/make(atom/where, amount, obj/item/stack/material/stack, mob/user, silent, use_dir)
/datum/stack_recipe/material/make(atom/where, amount, obj/item/stack/material/stack, mob/user, silent, use_dir, list/created = list())
return ..()
24 changes: 16 additions & 8 deletions code/datums/recipe/material_recipes/furniture.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,40 @@
exclusitivity = /obj/structure/bed
cost = 2

/datum/stack_recipe/material/furniture/bed/make(atom/where, amount, obj/item/stack/material/stack, mob/user, silent, use_dir)
return new /obj/structure/bed(where, stack.material)
/datum/stack_recipe/material/furniture/bed/make(atom/where, amount, obj/item/stack/material/stack, mob/user, silent, use_dir, list/created = list())
for(var/i in 1 to amount)
created += new /obj/structure/bed(where, stack.material)
return TRUE

/datum/stack_recipe/material/furniture/double_bed
name = "double bed"
result_type = /obj/structure/bed/double
exclusitivity = /obj/structure/bed
cost = 3

/datum/stack_recipe/material/furniture/double_bed/make(atom/where, amount, obj/item/stack/material/stack, mob/user, silent, use_dir)
return new /obj/structure/bed/double(where, stack.material)
/datum/stack_recipe/material/furniture/double_bed/make(atom/where, amount, obj/item/stack/material/stack, mob/user, silent, use_dir, list/created = list())
for(var/i in 1 to amount)
created += new /obj/structure/bed/double(where, stack.material)
return TRUE

/datum/stack_recipe/material/furniture/stool
name = "stool"
result_type = /obj/item/stool
exclusitivity = /obj/item/stool
cost = 3

/datum/stack_recipe/material/furniture/stool/make(atom/where, amount, obj/item/stack/material/stack, mob/user, silent, use_dir)
return new /obj/item/stool(where, stack.material)
/datum/stack_recipe/material/furniture/stool/make(atom/where, amount, obj/item/stack/material/stack, mob/user, silent, use_dir, list/created = list())
for(var/i in 1 to amount)
created += new /obj/item/stool(where, stack.material)
return TRUE

/datum/stack_recipe/material/furniture/chair
name = "chair"
result_type = /obj/structure/bed/chair
exclusitivity = /obj/structure/bed
cost = 3

/datum/stack_recipe/material/furniture/chair/make(atom/where, amount, obj/item/stack/material/stack, mob/user, silent, use_dir)
return new /obj/structure/bed/chair(where, stack.material)
/datum/stack_recipe/material/furniture/chair/make(atom/where, amount, obj/item/stack/material/stack, mob/user, silent, use_dir, list/created = list())
for(var/i in 1 to amount)
created += new /obj/structure/bed/chair(where, stack.material)
return TRUE
25 changes: 15 additions & 10 deletions code/datums/recipe/material_recipes/structures.dm
Original file line number Diff line number Diff line change
Expand Up @@ -10,42 +10,47 @@
result_type = /obj/structure/simple_door
cost = 5

/datum/stack_recipe/material/structure/door/make(atom/where, amount, obj/item/stack/material/stack, mob/user, silent, use_dir)
/datum/stack_recipe/material/structure/door/make(atom/where, amount, obj/item/stack/material/stack, mob/user, silent, use_dir, list/created = list())
for(var/i in 1 to amount)
new /obj/structure/simple_door(where, stack.material)
created += new /obj/structure/simple_door(where, stack.material)
return TRUE

/datum/stack_recipe/material/structure/barricade
name = "barricade"
result_type = /obj/structure/barricade
cost = 5

/datum/stack_recipe/material/structure/barricade/make(atom/where, amount, obj/item/stack/material/stack, mob/user, silent, use_dir)
/datum/stack_recipe/material/structure/barricade/make(atom/where, amount, obj/item/stack/material/stack, mob/user, silent, use_dir, list/created = list())
for(var/i in 1 to amount)
new /obj/structure/barricade(where, stack.material)
created += new /obj/structure/barricade(where, stack.material)
return TRUE

/datum/stack_recipe/material/structure/girder
name = "girder"
result_type = /obj/structure/girder
cost = 2

/datum/stack_recipe/material/structure/girder/make(atom/where, amount, obj/item/stack/material/stack, mob/user, silent, use_dir)
/datum/stack_recipe/material/structure/girder/make(atom/where, amount, obj/item/stack/material/stack, mob/user, silent, use_dir, list/created = list())
for(var/i in 1 to amount)
new /obj/structure/girder(where, stack.material)
created += new /obj/structure/girder(where, stack.material)
return TRUE

/datum/stack_recipe/material/structure/low_wall
name = "low walls"
result_type = /obj/structure/wall_frame
cost = 2

/datum/stack_recipe/material/structure/low_wall/make(atom/where, amount, obj/item/stack/material/stack, mob/user, silent, use_dir)
/datum/stack_recipe/material/structure/low_wall/make(atom/where, amount, obj/item/stack/material/stack, mob/user, silent, use_dir, list/created = list())
for(var/i in 1 to amount)
new /obj/structure/wall_frame(where, stack.material)
created += new /obj/structure/wall_frame(where, stack.material)
return TRUE

/datum/stack_recipe/material/structure/sculpting_block
name = "sculpting block"
result_type = /obj/structure/sculpting_block
cost = 15

/datum/stack_recipe/material/structure/sculpting_block/make(atom/where, amount, obj/item/stack/material/stack, mob/user, silent, use_dir)
/datum/stack_recipe/material/structure/sculpting_block/make(atom/where, amount, obj/item/stack/material/stack, mob/user, silent, use_dir, list/created = list())
for(var/i in 1 to amount)
new /obj/structure/sculpting_block(where, stack.material)
created += new /obj/structure/sculpting_block(where, stack.material)
return TRUE
17 changes: 11 additions & 6 deletions code/datums/recipe/material_recipes/tools.dm
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,31 @@
result_type = /obj/item/clothing/gloves/ring/material
cost = 1

/datum/stack_recipe/material/tools/ring/make(atom/where, amount, obj/item/stack/material/stack, mob/user, silent, use_dir)
return new /obj/item/clothing/gloves/ring/material(where, stack.material)
/datum/stack_recipe/material/tools/ring/make(atom/where, amount, obj/item/stack/material/stack, mob/user, silent, use_dir, list/created = list())
for(var/i in 1 to amount)
created += new /obj/item/clothing/gloves/ring/material(where, stack.material)
return TRUE

/datum/stack_recipe/material/tools/braclet
name = "ring"
result_type = /obj/item/clothing/accessory/bracelet/material
cost = 1

/datum/stack_recipe/material/tools/ring/make(atom/where, amount, obj/item/stack/material/stack, mob/user, silent, use_dir)
return new /obj/item/clothing/accessory/bracelet/material(where, stack.material)
/datum/stack_recipe/material/tools/ring/make(atom/where, amount, obj/item/stack/material/stack, mob/user, silent, use_dir, list/created = list())
for(var/i in 1 to amount)
created += new /obj/item/clothing/accessory/bracelet/material(where, stack.material)
return TRUE

/**
* for the /obj/item/material path
*/
/datum/stack_recipe/material/tools/simple
abstract_type = /datum/stack_recipe/material/tools/simple

/datum/stack_recipe/material/tools/simple/make(atom/where, amount, obj/item/stack/material/stack, mob/user, silent, use_dir)
/datum/stack_recipe/material/tools/simple/make(atom/where, amount, obj/item/stack/material/stack, mob/user, silent, use_dir, list/created = list())
ASSERT(ispath(result_type, /obj/item/material))
return new result_type(where, stack.material)
new result_type(where, stack.material)
return TRUE

/datum/stack_recipe/material/tools/simple/baseball_bat
name = "baseball bat"
Expand Down
15 changes: 10 additions & 5 deletions code/datums/recipe/stack_recipe.dm
Original file line number Diff line number Diff line change
Expand Up @@ -111,28 +111,33 @@
* this is past point of no return
* shouldn't cancel under any circumstances
*
* * When overriding this proc you **must** ensure list/created has a = list() in the args, if it doesn't call ..() first. Otherwise, the pattern being used will runtime.
*
* @params
* * where - where to spawn result
* * amount - amount
* * stack - stack used
* * user - (optional) person crafting
* * silent - (optional) suppress feedback to user
* * use_dir - (optional) override dir if no user to get it from
* * creating - (optional) list will be populated of objects created. supply a list so you can read it, or don't to ignore.
*/
/datum/stack_recipe/proc/make(atom/where, amount, obj/item/stack/stack, mob/user, silent, use_dir)
/datum/stack_recipe/proc/make(atom/where, amount, obj/item/stack/stack, mob/user, silent, use_dir, list/created = list())
if(result_is_stack)
var/obj/item/stack/casted = result_type
var/max_amount = initial(casted.max_amount)
var/safety = 50
while(amount)
if(!--safety)
CRASH("safety hit")
var/obj/item/stack/created = new result_type(where, min(amount, max_amount))
amount -= created.amount
var/obj/item/stack/creating = new result_type(where, min(amount, max_amount))
amount -= creating.amount
created += creating
else
for(var/i in 1 to min(amount, 50))
var/atom/movable/created = new result_type(where)
created.setDir(use_dir)
var/atom/movable/creating = new result_type(where)
creating.setDir(use_dir)
created += creating
return TRUE

/**
Expand Down
28 changes: 16 additions & 12 deletions code/datums/recipe/stack_recipes/misc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,56 +6,60 @@
result_type = /obj/item/oar
cost = 2

/datum/stack_recipe/oar/make(atom/where, amount, obj/item/stack/stack, mob/user, silent, use_dir)
/datum/stack_recipe/oar/make(atom/where, amount, obj/item/stack/stack, mob/user, silent, use_dir, list/created = list())
var/obj/item/stack/material/material_stack = stack
if(istype(material_stack))
for(var/i in 1 to amount)
new result_type(where, material_stack.material)
created += new result_type(where, material_stack.material)
else
for(var/i in 1 to amount)
new result_type(where)
created += new result_type(where)
return TRUE

/datum/stack_recipe/boat
name = "boat"
result_type = /obj/vehicle/ridden/boat
cost = 15

/datum/stack_recipe/boat/make(atom/where, amount, obj/item/stack/stack, mob/user, silent, use_dir)
/datum/stack_recipe/boat/make(atom/where, amount, obj/item/stack/stack, mob/user, silent, use_dir, list/created = list())
var/obj/item/stack/material/material_stack = stack
if(istype(material_stack))
for(var/i in 1 to amount)
new result_type(where, material_stack.material)
created += new result_type(where, material_stack.material)
else
for(var/i in 1 to amount)
new result_type(where)
created += new result_type(where)
return TRUE

/datum/stack_recipe/dragon_boat
name = "dragon boat"
result_type = /obj/vehicle/ridden/boat/dragon
cost = 25

/datum/stack_recipe/dragon_boat/make(atom/where, amount, obj/item/stack/stack, mob/user, silent, use_dir)
/datum/stack_recipe/dragon_boat/make(atom/where, amount, obj/item/stack/stack, mob/user, silent, use_dir, list/created = list())
var/obj/item/stack/material/material_stack = stack
if(istype(material_stack))
for(var/i in 1 to amount)
new result_type(where, material_stack.material)
created += new result_type(where, material_stack.material)
else
for(var/i in 1 to amount)
new result_type(where)
created += new result_type(where)
return TRUE

/datum/stack_recipe/pew
abstract_type = /datum/stack_recipe/pew
exclusitivity = /obj/structure/bed
cost = 1

/datum/stack_recipe/pew/make(atom/where, amount, obj/item/stack/stack, mob/user, silent, use_dir)
/datum/stack_recipe/pew/make(atom/where, amount, obj/item/stack/stack, mob/user, silent, use_dir, list/created = list())
var/obj/item/stack/material/material_stack = stack
if(istype(material_stack))
for(var/i in 1 to amount)
new result_type(where, material_stack.material)
created += new result_type(where, material_stack.material)
else
for(var/i in 1 to amount)
new result_type(where)
created += new result_type(where)
return TRUE

/datum/stack_recipe/pew/middle
name = "pew (middle)"
Expand Down
10 changes: 6 additions & 4 deletions code/datums/recipe/stack_recipes/structures.dm
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@
return FALSE
return TRUE

/datum/stack_recipe/railing/make(atom/where, amount, obj/item/stack/stack, mob/user, silent, use_dir = user?.dir)
/datum/stack_recipe/railing/make(atom/where, amount, obj/item/stack/stack, mob/user, silent, use_dir = user?.dir, list/created = list())
if(isnull(use_dir))
return
var/obj/structure/railing/built = new(where, TRUE)
built.setDir(use_dir)
return built
for(var/i in 1 to amount)
var/obj/structure/railing/built = new(where, TRUE)
built.setDir(use_dir)
created += built
return TRUE