Switches hacky list copying method in check_items and check_fruit to use Copy(). Uses Cut() to make sure that one item does not satisfy the need for multiple items of the same type.

This commit is contained in:
Mustafa Kalash
2015-04-01 11:41:46 -04:00
parent 015fb291fa
commit 1a614c12de

View File

@@ -54,8 +54,8 @@
. = 1
if(fruit && fruit.len)
var/list/checklist = list()
for(var/fruittype in fruit) // I do not trust Copy().
checklist[fruittype] = fruit[fruittype]
// You should trust Copy().
checklist = fruit.Copy()
for(var/obj/item/weapon/reagent_containers/food/snacks/grown/G in container)
if(!G.seed || !G.seed.kitchen_tag || isnull(checklist[G.seed.kitchen_tag]))
continue
@@ -73,15 +73,15 @@
. = 1
if (items && items.len)
var/list/checklist = list()
for(var/item_type in items)
checklist |= item_type //Still don't trust Copy().
checklist = items.Copy() // You should really trust Copy
for(var/obj/O in container)
if(istype(O,/obj/item/weapon/reagent_containers/food/snacks/grown))
continue // Fruit is handled in check_fruit().
var/found = 0
for(var/item_type in checklist)
for(var/i = 1; i < checklist.len+1; i++)
var/item_type = checklist[i]
if (istype(O,item_type))
checklist-=item_type
checklist.Cut(i, i+1)
found = 1
break
if (!found)