mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 18:53:06 +00:00
Merge pull request #1334 from Datraen/BetterMicrowave
Replaces previous microwave hackfix with proper checks.
This commit is contained in:
@@ -69,23 +69,38 @@
|
|||||||
break
|
break
|
||||||
return .
|
return .
|
||||||
|
|
||||||
/datum/recipe/proc/check_items(var/obj/machinery/microwave/container as obj)
|
/datum/recipe/proc/check_items(var/obj/container as obj)
|
||||||
. = 1
|
. = 1
|
||||||
if (items && items.len)
|
if (items && items.len)
|
||||||
var/list/checklist = list()
|
var/list/checklist = list()
|
||||||
checklist = items.Copy() // You should really trust Copy
|
checklist = items.Copy() // You should really trust Copy
|
||||||
for(var/obj/O in container.ingredient_list)
|
if(istype(container, /obj/machinery))
|
||||||
if(istype(O,/obj/item/weapon/reagent_containers/food/snacks/grown))
|
var/obj/machinery/machine = container
|
||||||
continue // Fruit is handled in check_fruit().
|
for(var/obj/O in (machine.contents - machine.component_parts))
|
||||||
var/found = 0
|
if(istype(O,/obj/item/weapon/reagent_containers/food/snacks/grown))
|
||||||
for(var/i = 1; i < checklist.len+1; i++)
|
continue // Fruit is handled in check_fruit().
|
||||||
var/item_type = checklist[i]
|
var/found = 0
|
||||||
if (istype(O,item_type))
|
for(var/i = 1; i < checklist.len+1; i++)
|
||||||
checklist.Cut(i, i+1)
|
var/item_type = checklist[i]
|
||||||
found = 1
|
if (istype(O,item_type))
|
||||||
break
|
checklist.Cut(i, i+1)
|
||||||
if (!found)
|
found = 1
|
||||||
. = 0
|
break
|
||||||
|
if (!found)
|
||||||
|
. = 0
|
||||||
|
else
|
||||||
|
for(var/obj/O in container.contents)
|
||||||
|
if(istype(O,/obj/item/weapon/reagent_containers/food/snacks/grown))
|
||||||
|
continue // Fruit is handled in check_fruit().
|
||||||
|
var/found = 0
|
||||||
|
for(var/i = 1; i < checklist.len+1; i++)
|
||||||
|
var/item_type = checklist[i]
|
||||||
|
if (istype(O,item_type))
|
||||||
|
checklist.Cut(i, i+1)
|
||||||
|
found = 1
|
||||||
|
break
|
||||||
|
if (!found)
|
||||||
|
. = 0
|
||||||
if (checklist.len)
|
if (checklist.len)
|
||||||
. = -1
|
. = -1
|
||||||
return .
|
return .
|
||||||
@@ -93,25 +108,39 @@
|
|||||||
//general version
|
//general version
|
||||||
/datum/recipe/proc/make(var/obj/container as obj)
|
/datum/recipe/proc/make(var/obj/container as obj)
|
||||||
var/obj/result_obj = new result(container)
|
var/obj/result_obj = new result(container)
|
||||||
for (var/obj/O in (container.contents-result_obj))
|
if(istype(container, /obj/machinery))
|
||||||
O.reagents.trans_to_obj(result_obj, O.reagents.total_volume)
|
var/obj/machinery/machine = container
|
||||||
qdel(O)
|
for (var/obj/O in ((machine.contents-result_obj)-machine.component_parts))
|
||||||
|
O.reagents.trans_to_obj(result_obj, O.reagents.total_volume)
|
||||||
|
qdel(O)
|
||||||
|
else
|
||||||
|
for (var/obj/O in (container.contents-result_obj))
|
||||||
|
O.reagents.trans_to_obj(result_obj, O.reagents.total_volume)
|
||||||
|
qdel(O)
|
||||||
container.reagents.clear_reagents()
|
container.reagents.clear_reagents()
|
||||||
return result_obj
|
return result_obj
|
||||||
|
|
||||||
// food-related
|
// food-related
|
||||||
/datum/recipe/proc/make_food(var/obj/machinery/microwave/container as obj)
|
/datum/recipe/proc/make_food(var/obj/container as obj)
|
||||||
if(!result)
|
if(!result)
|
||||||
world << "<span class='danger'>Recipe [type] is defined without a result, please bug this.</span>"
|
world << "<span class='danger'>Recipe [type] is defined without a result, please bug this.</span>"
|
||||||
return
|
return
|
||||||
var/obj/result_obj = new result(container)
|
var/obj/result_obj = new result(container)
|
||||||
for (var/obj/O in (container.ingredient_list)) //We no longer need to take result_obj out of the list, since it doesn't exist in the list.
|
if(istype(container, /obj/machinery))
|
||||||
if (O.reagents)
|
var/obj/machinery/machine = container
|
||||||
O.reagents.del_reagent("nutriment")
|
for (var/obj/O in ((machine.contents-result_obj)-machine.component_parts))
|
||||||
O.reagents.update_total()
|
if (O.reagents)
|
||||||
O.reagents.trans_to_obj(result_obj, O.reagents.total_volume)
|
O.reagents.del_reagent("nutriment")
|
||||||
qdel(O)
|
O.reagents.update_total()
|
||||||
container.ingredient_list.Cut() //Trust in Cut().
|
O.reagents.trans_to_obj(result_obj, O.reagents.total_volume)
|
||||||
|
qdel(O)
|
||||||
|
else
|
||||||
|
for (var/obj/O in (container.contents-result_obj))
|
||||||
|
if (O.reagents)
|
||||||
|
O.reagents.del_reagent("nutriment")
|
||||||
|
O.reagents.update_total()
|
||||||
|
O.reagents.trans_to_obj(result_obj, O.reagents.total_volume)
|
||||||
|
qdel(O)
|
||||||
container.reagents.clear_reagents()
|
container.reagents.clear_reagents()
|
||||||
return result_obj
|
return result_obj
|
||||||
|
|
||||||
|
|||||||
@@ -18,8 +18,6 @@
|
|||||||
var/global/list/acceptable_items // List of the items you can put in
|
var/global/list/acceptable_items // List of the items you can put in
|
||||||
var/global/list/acceptable_reagents // List of the reagents you can put in
|
var/global/list/acceptable_reagents // List of the reagents you can put in
|
||||||
var/global/max_n_of_items = 0
|
var/global/max_n_of_items = 0
|
||||||
|
|
||||||
var/list/ingredient_list = list() //MUST BE INTIALIZED OR YOU GET RUNTIME ERRORS
|
|
||||||
|
|
||||||
|
|
||||||
// see code/modules/food/recipes_microwave.dm for recipes
|
// see code/modules/food/recipes_microwave.dm for recipes
|
||||||
@@ -116,13 +114,12 @@
|
|||||||
user << "<span class='warning'>It's dirty!</span>"
|
user << "<span class='warning'>It's dirty!</span>"
|
||||||
return 1
|
return 1
|
||||||
else if(is_type_in_list(O,acceptable_items))
|
else if(is_type_in_list(O,acceptable_items))
|
||||||
if (ingredient_list.len>=max_n_of_items)
|
if (contents.len>=(max_n_of_items + component_parts.len)) //Adds component_parts to the maximum number of items.
|
||||||
user << "<span class='warning'>This [src] is full of ingredients, you cannot put more.</span>"
|
user << "<span class='warning'>This [src] is full of ingredients, you cannot put more.</span>"
|
||||||
return 1
|
return 1
|
||||||
if(istype(O, /obj/item/stack) && O:get_amount() > 1) // This is bad, but I can't think of how to change it
|
if(istype(O, /obj/item/stack) && O:get_amount() > 1) // This is bad, but I can't think of how to change it
|
||||||
var/obj/item/stack/S = O
|
var/obj/item/stack/S = O
|
||||||
var/obj/item/stack/K = new O.type (src) //Needed for change into ingredient lists, rather than just contents.
|
new O.type (src)
|
||||||
ingredient_list += K
|
|
||||||
S.use(1)
|
S.use(1)
|
||||||
user.visible_message( \
|
user.visible_message( \
|
||||||
"<span class='notice'>\The [user] has added one of [O] to \the [src].</span>", \
|
"<span class='notice'>\The [user] has added one of [O] to \the [src].</span>", \
|
||||||
@@ -132,7 +129,6 @@
|
|||||||
// user.remove_from_mob(O) //This just causes problems so far as I can tell. -Pete
|
// user.remove_from_mob(O) //This just causes problems so far as I can tell. -Pete
|
||||||
user.drop_item()
|
user.drop_item()
|
||||||
O.loc = src
|
O.loc = src
|
||||||
ingredient_list += O
|
|
||||||
user.visible_message( \
|
user.visible_message( \
|
||||||
"<span class='notice'>\The [user] has added \the [O] to \the [src].</span>", \
|
"<span class='notice'>\The [user] has added \the [O] to \the [src].</span>", \
|
||||||
"<span class='notice'>You add \the [O] to \the [src].</span>")
|
"<span class='notice'>You add \the [O] to \the [src].</span>")
|
||||||
@@ -181,7 +177,7 @@
|
|||||||
var/list/items_counts = new
|
var/list/items_counts = new
|
||||||
var/list/items_measures = new
|
var/list/items_measures = new
|
||||||
var/list/items_measures_p = new
|
var/list/items_measures_p = new
|
||||||
for (var/obj/O in ingredient_list)
|
for (var/obj/O in (contents-component_parts))
|
||||||
var/display_name = O.name
|
var/display_name = O.name
|
||||||
if (istype(O,/obj/item/weapon/reagent_containers/food/snacks/egg))
|
if (istype(O,/obj/item/weapon/reagent_containers/food/snacks/egg))
|
||||||
items_measures[display_name] = "egg"
|
items_measures[display_name] = "egg"
|
||||||
@@ -241,7 +237,7 @@
|
|||||||
if(stat & (NOPOWER|BROKEN))
|
if(stat & (NOPOWER|BROKEN))
|
||||||
return
|
return
|
||||||
start()
|
start()
|
||||||
if (reagents.total_volume==0 && !(locate(/obj) in ingredient_list)) //dry run
|
if (reagents.total_volume==0 && !(locate(/obj) in (contents-component_parts))) //dry run
|
||||||
if (!wzhzhzh(10))
|
if (!wzhzhzh(10))
|
||||||
abort()
|
abort()
|
||||||
return
|
return
|
||||||
@@ -303,7 +299,7 @@
|
|||||||
return 1
|
return 1
|
||||||
|
|
||||||
/obj/machinery/microwave/proc/has_extra_item()
|
/obj/machinery/microwave/proc/has_extra_item()
|
||||||
for (var/obj/O in ingredient_list)
|
for (var/obj/O in (contents-component_parts))
|
||||||
if ( \
|
if ( \
|
||||||
!istype(O,/obj/item/weapon/reagent_containers/food) && \
|
!istype(O,/obj/item/weapon/reagent_containers/food) && \
|
||||||
!istype(O, /obj/item/weapon/grown) \
|
!istype(O, /obj/item/weapon/grown) \
|
||||||
@@ -329,9 +325,8 @@
|
|||||||
src.updateUsrDialog()
|
src.updateUsrDialog()
|
||||||
|
|
||||||
/obj/machinery/microwave/proc/dispose()
|
/obj/machinery/microwave/proc/dispose()
|
||||||
for (var/obj/O in ingredient_list)
|
for (var/obj/O in (contents-component_parts))
|
||||||
O.loc = src.loc
|
O.loc = src.loc
|
||||||
ingredient_list -= O
|
|
||||||
if (src.reagents.total_volume)
|
if (src.reagents.total_volume)
|
||||||
src.dirty++
|
src.dirty++
|
||||||
src.reagents.clear_reagents()
|
src.reagents.clear_reagents()
|
||||||
@@ -365,7 +360,7 @@
|
|||||||
/obj/machinery/microwave/proc/fail()
|
/obj/machinery/microwave/proc/fail()
|
||||||
var/obj/item/weapon/reagent_containers/food/snacks/badrecipe/ffuu = new(src)
|
var/obj/item/weapon/reagent_containers/food/snacks/badrecipe/ffuu = new(src)
|
||||||
var/amount = 0
|
var/amount = 0
|
||||||
for (var/obj/O in ingredient_list-ffuu)
|
for (var/obj/O in (contents-ffuu)-component_parts)
|
||||||
amount++
|
amount++
|
||||||
if (O.reagents)
|
if (O.reagents)
|
||||||
var/id = O.reagents.get_master_reagent_id()
|
var/id = O.reagents.get_master_reagent_id()
|
||||||
|
|||||||
Reference in New Issue
Block a user