Merge pull request #11210 from Ghommie/Ghommie-cit588

[s] Fixing an issue with slot machines crashing the server.
This commit is contained in:
kevinz000
2020-02-23 06:02:13 -07:00
committed by GitHub
6 changed files with 22 additions and 13 deletions
+2
View File
@@ -521,3 +521,5 @@ GLOBAL_LIST_INIT(pda_reskins, list(PDA_SKIN_CLASSIC = 'icons/obj/pda.dmi', PDA_S
#define NIGHTSHIFT_AREA_RECREATION 2 //dorms common areas, etc
#define NIGHTSHIFT_AREA_DEPARTMENT_HALLS 3 //interior hallways, etc
#define NIGHTSHIFT_AREA_NONE 4 //default/highest.
#define UNTIL(X) while(!(X)) stoplag()
+9
View File
@@ -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,10 @@
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
qdel(C)
-2
View File
@@ -1234,8 +1234,6 @@ GLOBAL_DATUM_INIT(dview_mob, /mob/dview, new)
return FALSE
return TRUE
#define UNTIL(X) while(!(X)) stoplag()
/proc/pass()
return
+1
View File
@@ -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)
+9 -11
View File
@@ -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
+1
View File
@@ -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()
. = ..()