[s] Fixing an issue with slot machines crashing the server.
This commit is contained in:
@@ -93,6 +93,8 @@
|
||||
|
||||
init_subtypes(/datum/crafting_recipe, GLOB.crafting_recipes)
|
||||
|
||||
INVOKE_ASYNC(GLOBAL_PROC, /proc/init_ref_coin_values) //so the current procedure doesn't sleep because of UNTIL()
|
||||
|
||||
//creates every subtype of prototype (excluding prototype) and adds it to list L.
|
||||
//if no list/L is provided, one is created.
|
||||
/proc/init_subtypes(prototype, list/L)
|
||||
@@ -110,3 +112,9 @@
|
||||
for(var/path in subtypesof(prototype))
|
||||
L+= path
|
||||
return L
|
||||
|
||||
/proc/init_ref_coin_values()
|
||||
for(var/path in typesof(/obj/item/coin))
|
||||
var/obj/item/coin/C = new path
|
||||
UNTIL(C.flags_1 & INITIALIZED_1) //we want to make sure the value is calculated and not null.
|
||||
GLOB.coin_values[path] = C.value
|
||||
|
||||
@@ -32,6 +32,7 @@ GLOBAL_LIST_EMPTY(meteor_list) // List of all meteors.
|
||||
GLOBAL_LIST_EMPTY(active_jammers) // List of active radio jammers
|
||||
GLOBAL_LIST_EMPTY(ladders)
|
||||
GLOBAL_LIST_EMPTY(trophy_cases)
|
||||
GLOBAL_LIST_EMPTY(coin_values)
|
||||
|
||||
GLOBAL_LIST_EMPTY(wire_color_directory)
|
||||
GLOBAL_LIST_EMPTY(wire_name_directory)
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
var/working = 0
|
||||
var/balance = 0 //How much money is in the machine, ready to be CONSUMED.
|
||||
var/jackpots = 0
|
||||
var/list/coinvalues = list()
|
||||
var/list/reels = list(list("", "", "") = 0, list("", "", "") = 0, list("", "", "") = 0, list("", "", "") = 0, list("", "", "") = 0)
|
||||
var/list/symbols = list(SEVEN = 1, "<font color='orange'>&</font>" = 2, "<font color='yellow'>@</font>" = 2, "<font color='green'>$</font>" = 2, "<font color='blue'>?</font>" = 2, "<font color='grey'>#</font>" = 2, "<font color='white'>!</font>" = 2, "<font color='fuchsia'>%</font>" = 2) //if people are winning too much, multiply every number in this list by 2 and see if they are still winning too much.
|
||||
|
||||
@@ -45,10 +44,6 @@
|
||||
|
||||
toggle_reel_spin(0)
|
||||
|
||||
for(var/cointype in typesof(/obj/item/coin))
|
||||
var/obj/item/coin/C = cointype
|
||||
coinvalues["[cointype]"] = initial(C.value)
|
||||
|
||||
/obj/machinery/computer/slot_machine/Destroy()
|
||||
if(balance)
|
||||
give_coins(balance)
|
||||
@@ -294,19 +289,22 @@
|
||||
|
||||
return amount
|
||||
|
||||
/obj/machinery/computer/slot_machine/proc/dispense(amount = 0, cointype = /obj/item/coin/silver, mob/living/target, throwit = 0)
|
||||
var/value = coinvalues["[cointype]"]
|
||||
/obj/machinery/computer/slot_machine/proc/dispense(amount = 0, cointype = /obj/item/coin/silver, mob/living/target, throwit = FALSE)
|
||||
var/value = GLOB.coin_values[cointype] || GLOB.coin_values[/obj/item/coin/iron]
|
||||
INVOKE_ASYNC(src, .proc/become_rich, amount, value, cointype, target, throwit)
|
||||
return amount % value
|
||||
|
||||
|
||||
while(amount >= value)
|
||||
/obj/machinery/computer/slot_machine/proc/become_rich(amount, value, cointype = /obj/item/coin/silver, mob/living/target, throwit = FALSE)
|
||||
if(value <= 0)
|
||||
return
|
||||
while(amount >= value && !QDELETED(src))
|
||||
var/obj/item/coin/C = new cointype(loc) //DOUBLE THE PAIN
|
||||
amount -= value
|
||||
if(throwit && target)
|
||||
C.throw_at(target, 3, 10)
|
||||
else
|
||||
random_step(C, 2, 40)
|
||||
|
||||
return amount
|
||||
CHECK_TICK
|
||||
|
||||
#undef SEVEN
|
||||
#undef SPIN_TIME
|
||||
|
||||
@@ -326,6 +326,7 @@ GLOBAL_LIST_INIT(sand_recipes, list(\
|
||||
var/cooldown = 0
|
||||
var/value
|
||||
var/coinflip
|
||||
item_flags = NO_MAT_REDEMPTION //You know, it's kind of a problem that money is worth more extrinsicly than intrinsically in this universe.
|
||||
|
||||
/obj/item/coin/Initialize()
|
||||
. = ..()
|
||||
|
||||
Reference in New Issue
Block a user