Merge pull request #6555 from eswordthecat/megaseed

Fix #6538.
This commit is contained in:
Rob Nelson
2015-11-11 13:14:55 -08:00

View File

@@ -42,7 +42,6 @@ var/global/num_vending_terminals = 1
var/vend_delay = 10 //How long does it take to vend? var/vend_delay = 10 //How long does it take to vend?
var/shoot_chance = 2 //How often do we throw items? var/shoot_chance = 2 //How often do we throw items?
var/datum/data/vending_product/currently_vending = null // A /datum/data/vending_product instance of what we're paying for right now. var/datum/data/vending_product/currently_vending = null // A /datum/data/vending_product instance of what we're paying for right now.
var/delay_product_spawn // If set, uses sleep() in product spawn proc (mostly for seeds to retrieve correct names).
// To be filled out at compile time // To be filled out at compile time
var/list/products = list() // For each, use the following pattern: var/list/products = list() // For each, use the following pattern:
var/list/contraband = list() // list(/type/path = amount,/type/path2 = amount2) var/list/contraband = list() // list(/type/path = amount,/type/path2 = amount2)
@@ -112,10 +111,6 @@ var/global/num_vending_terminals = 1
// so if slogantime is 10 minutes, it will say it at somewhere between 10 and 20 minutes after the machine is crated. // so if slogantime is 10 minutes, it will say it at somewhere between 10 and 20 minutes after the machine is crated.
src.last_slogan = world.time + rand(0, slogan_delay) src.last_slogan = world.time + rand(0, slogan_delay)
if(!product_records.len)
src.build_inventory(products)
src.build_inventory(contraband, 1)
src.build_inventory(premium, 0, 1)
power_change() power_change()
coinbox = new(src) coinbox = new(src)
@@ -125,6 +120,12 @@ var/global/num_vending_terminals = 1
return return
/obj/machinery/vending/initialize()
product_records = new/list()
build_inventory(products)
build_inventory(contraband, 1)
build_inventory(premium, 0, 1)
/obj/machinery/vending/RefreshParts() /obj/machinery/vending/RefreshParts()
var/manipcount = 0 var/manipcount = 0
for(var/obj/item/weapon/stock_parts/SP in component_parts) for(var/obj/item/weapon/stock_parts/SP in component_parts)
@@ -253,35 +254,34 @@ var/global/num_vending_terminals = 1
//writepanic("[__FILE__].[__LINE__] ([src.type])([usr ? usr.ckey : ""]) \\/obj/machinery/vending/proc/build_inventory() called tick#: [world.time]") //writepanic("[__FILE__].[__LINE__] ([src.type])([usr ? usr.ckey : ""]) \\/obj/machinery/vending/proc/build_inventory() called tick#: [world.time]")
var/obj/item/temp var/obj/item/temp
for(var/typepath in productlist) for (var/typepath in productlist)
var/amount = productlist[typepath] var/amount = productlist[typepath]
var/price = prices[typepath] var/price = prices[typepath]
if(isnull(amount)) amount = 1
var/datum/data/vending_product/R = new /datum/data/vending_product() if (isnull(amount))
amount = 1
var/datum/data/vending_product/R = new()
R.product_path = typepath R.product_path = typepath
R.amount = amount R.amount = amount
R.original_amount = amount R.original_amount = amount
R.price = price R.price = price
R.display_color = pick("red","blue","green") R.display_color = pick("red", "blue", "green")
if(hidden) if (hidden)
R.category=CAT_HIDDEN R.category=CAT_HIDDEN
hidden_records += R hidden_records += R
else if(req_coin) else if (req_coin)
R.category=CAT_COIN R.category=CAT_COIN
coin_records += R coin_records += R
else else
R.category=CAT_NORMAL R.category = CAT_NORMAL
product_records += R product_records.Add(R)
temp = typepath temp = new typepath(null)
if (delay_product_spawn) R.product_name = temp.name
sleep(1) R.subcategory = temp.vending_cat
R.product_name = initial(temp.name)
R.subcategory = initial(temp.vending_cat)
/obj/machinery/vending/proc/get_item_by_type(var/this_type) /obj/machinery/vending/proc/get_item_by_type(var/this_type)
//writepanic("[__FILE__].[__LINE__] ([src.type])([usr ? usr.ckey : ""]) \\/obj/machinery/vending/proc/get_item_by_type() called tick#: [world.time]") //writepanic("[__FILE__].[__LINE__] ([src.type])([usr ? usr.ckey : ""]) \\/obj/machinery/vending/proc/get_item_by_type() called tick#: [world.time]")
@@ -759,30 +759,26 @@ var/global/num_vending_terminals = 1
/obj/machinery/vending/proc/add_item(var/obj/item/I) /obj/machinery/vending/proc/add_item(var/obj/item/I)
//writepanic("[__FILE__].[__LINE__] ([src.type])([usr ? usr.ckey : ""]) \\/obj/machinery/vending/proc/add_item() called tick#: [world.time]") //writepanic("[__FILE__].[__LINE__] ([src.type])([usr ? usr.ckey : ""]) \\/obj/machinery/vending/proc/add_item() called tick#: [world.time]")
var/found = 0 var/found = FALSE
for (var/datum/data/vending_product/D in product_records)
if(D.product_path == I.type)
D.amount++
found = 1
if(!found) for (var/datum/data/vending_product/D in product_records)
var/datum/data/vending_product/R = new /datum/data/vending_product() if (D.product_path == I.type)
D.amount++
found = TRUE
break
if (!found)
var/datum/data/vending_product/R = new()
R.product_path = I.type R.product_path = I.type
R.amount = 1 R.amount = 1
R.original_amount = 0 R.original_amount = 0
R.price = 0 R.price = 0
R.display_color = pick("red","blue","green") R.display_color = pick("red", "blue", "green")
R.product_name = I.name
R.category = CAT_NORMAL
R.subcategory = I.vending_cat
R.category=CAT_NORMAL product_records.Add(R)
product_records += R
if(delay_product_spawn)
sleep(1)
R.product_name = I.name
R.subcategory = I.vending_cat
else
R.product_name = I.name
R.subcategory = I.vending_cat
qdel(I) qdel(I)