mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-24 21:48:39 +01:00
[MIRROR] [MDB IGNORE] Fix ticket machines behaving unexpectedly and causing runtimes [MDB IGNORE] (#15824)
* [MDB IGNORE] Fix ticket machines behaving unexpectedly and causing runtimes (#69406) * Adds a unique ID to the ticket machine in an icebox ruin, preventing it from getting mixed up with the HoP's. * Adds more text on examining ticket machines and the tickets from them, allowing people to know what position in queue they are. * Tickets now properly display their number, and is named after their position in queue. * Adds more user alerts to certain actions around the ticket machine, such as when there are no more people in queue. * [MDB IGNORE] Fix ticket machines behaving unexpectedly and causing runtimes Co-authored-by: distributivgesetz <distributivgesetz93@gmail.com>
This commit is contained in:
co-authored by
distributivgesetz
parent
11e79e85b7
commit
432d8f6581
@@ -146,7 +146,9 @@
|
||||
/turf/open/misc/asteroid/snow/icemoon,
|
||||
/area/icemoon/underground/explored)
|
||||
"np" = (
|
||||
/obj/machinery/ticket_machine/directional/north,
|
||||
/obj/machinery/ticket_machine/directional/north{
|
||||
id = "ticket_machine_icemailroom"
|
||||
},
|
||||
/turf/open/floor/iron/white,
|
||||
/area/ruin/powered/mailroom)
|
||||
"nM" = (
|
||||
|
||||
@@ -319,6 +319,10 @@
|
||||
return
|
||||
. += span_warning("You cannot read it!")
|
||||
|
||||
/obj/item/paper/extinguish()
|
||||
..()
|
||||
update_appearance()
|
||||
|
||||
/obj/item/paper/ui_status(mob/user,/datum/ui_state/state)
|
||||
// Are we on fire? Hard to read if so
|
||||
if(resistance_flags & ON_FIRE)
|
||||
|
||||
@@ -13,14 +13,20 @@
|
||||
maptext_x = 7
|
||||
maptext_y = 10
|
||||
layer = HIGH_OBJ_LAYER
|
||||
var/ticket_number = 0 //Increment the ticket number whenever the HOP presses his button
|
||||
var/current_number = 0 //What ticket number are we currently serving?
|
||||
var/max_number = 100 //At this point, you need to refill it.
|
||||
var/cooldown = 50
|
||||
///Increment the ticket number whenever the HOP presses his button
|
||||
var/ticket_number = 0
|
||||
///What ticket number are we currently serving?
|
||||
var/current_number = 0
|
||||
///At this point, you need to refill it.
|
||||
var/max_number = 100
|
||||
var/cooldown = 5 SECONDS
|
||||
var/ready = TRUE
|
||||
var/id = "ticket_machine_default" //For buttons
|
||||
var/list/ticket_holders = list()
|
||||
///List of tickets that exist currently
|
||||
var/list/obj/item/ticket_machine_ticket/tickets = list()
|
||||
///Current ticket to be served, essentially the head of the tickets queue
|
||||
var/obj/item/ticket_machine_ticket/current_ticket
|
||||
|
||||
/obj/machinery/ticket_machine/Initialize(mapload)
|
||||
. = ..()
|
||||
@@ -34,6 +40,11 @@
|
||||
|
||||
MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/ticket_machine, 32)
|
||||
|
||||
/obj/machinery/ticket_machine/examine(mob/user)
|
||||
. = ..()
|
||||
. += span_notice("The ticket machine shows that ticket #[current_number] is currently being served.")
|
||||
. += span_notice("You can take a ticket out with <b>Left-Click</b> to be number [ticket_number + 1] in queue.")
|
||||
|
||||
/obj/machinery/ticket_machine/multitool_act(mob/living/user, obj/item/I)
|
||||
if(!multitool_check_buffer(user, I)) //make sure it has a data buffer
|
||||
return
|
||||
@@ -51,23 +62,25 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/ticket_machine, 32)
|
||||
obj_flags |= EMAGGED
|
||||
if(tickets.len)
|
||||
for(var/obj/item/ticket_machine_ticket/ticket in tickets)
|
||||
ticket.audible_message(span_notice("\the [ticket] disperses!"))
|
||||
ticket.audible_message(span_notice("\the [ticket] disperses!"), hearing_distance = SAMETILE_MESSAGE_RANGE)
|
||||
qdel(ticket)
|
||||
tickets.Cut()
|
||||
update_appearance()
|
||||
|
||||
///Increments the counter by one, if there is a ticket after the current one we are serving.
|
||||
///If we have a current ticket, remove it from the top of our tickets list and replace it with the next one if applicable
|
||||
/obj/machinery/ticket_machine/proc/increment()
|
||||
if(current_number > ticket_number)
|
||||
return
|
||||
if(current_number && !(obj_flags & EMAGGED) && tickets[current_number])
|
||||
tickets[current_number].audible_message(span_notice("\the [tickets[current_number]] disperses!"))
|
||||
qdel(tickets[current_number])
|
||||
if(current_number < ticket_number)
|
||||
current_number ++ //Increment the one we're serving.
|
||||
if(!(obj_flags & EMAGGED) && current_ticket)
|
||||
current_ticket.audible_message(span_notice("\the [current_ticket] disperses!"), hearing_distance = SAMETILE_MESSAGE_RANGE)
|
||||
tickets.Cut(1,2)
|
||||
QDEL_NULL(current_ticket)
|
||||
if(LAZYLEN(tickets))
|
||||
current_ticket = tickets[1]
|
||||
current_number++ //Increment the one we're serving.
|
||||
playsound(src, 'sound/misc/announce_dig.ogg', 50, FALSE)
|
||||
say("Now serving ticket #[current_number]!")
|
||||
if(!(obj_flags & EMAGGED) && tickets[current_number])
|
||||
tickets[current_number].audible_message(span_notice("\the [tickets[current_number]] vibrates!"))
|
||||
say("Now serving [current_ticket]!")
|
||||
if(!(obj_flags & EMAGGED))
|
||||
current_ticket.audible_message(span_notice("\the [current_ticket] vibrates!"), hearing_distance = SAMETILE_MESSAGE_RANGE)
|
||||
update_appearance() //Update our icon here rather than when they take a ticket to show the current ticket number being served
|
||||
|
||||
/obj/machinery/button/ticket_machine
|
||||
@@ -90,7 +103,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/ticket_machine, 32)
|
||||
if(M.buffer && !istype(M.buffer, /obj/machinery/ticket_machine))
|
||||
return
|
||||
var/obj/item/assembly/control/ticket_machine/controller = device
|
||||
controller.linked = WEAKREF(M.buffer)
|
||||
controller.ticket_machine_ref = WEAKREF(M.buffer)
|
||||
id = null
|
||||
controller.id = null
|
||||
to_chat(user, span_warning("You've linked [src] to [M.buffer]."))
|
||||
@@ -98,7 +111,8 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/ticket_machine, 32)
|
||||
/obj/item/assembly/control/ticket_machine
|
||||
name = "ticket machine controller"
|
||||
desc = "A remote controller for the HoP's ticket machine."
|
||||
var/datum/weakref/linked //To whom are we linked?
|
||||
///Weakref to our ticket machine
|
||||
var/datum/weakref/ticket_machine_ref
|
||||
|
||||
/obj/item/assembly/control/ticket_machine/Initialize(mapload)
|
||||
..()
|
||||
@@ -107,25 +121,28 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/ticket_machine, 32)
|
||||
/obj/item/assembly/control/ticket_machine/LateInitialize()
|
||||
find_machine()
|
||||
|
||||
/obj/item/assembly/control/ticket_machine/proc/find_machine() //Locate the one to which we're linked
|
||||
/// Locate the ticket machine to which we're linked by our ID
|
||||
/obj/item/assembly/control/ticket_machine/proc/find_machine()
|
||||
for(var/obj/machinery/ticket_machine/ticketsplease in GLOB.machines)
|
||||
if(ticketsplease.id == id)
|
||||
linked = WEAKREF(ticketsplease)
|
||||
if(linked)
|
||||
ticket_machine_ref = WEAKREF(ticketsplease)
|
||||
if(ticket_machine_ref)
|
||||
return TRUE
|
||||
else
|
||||
return FALSE
|
||||
|
||||
/obj/item/assembly/control/ticket_machine/activate()
|
||||
/obj/item/assembly/control/ticket_machine/activate(mob/activator)
|
||||
if(cooldown)
|
||||
return
|
||||
if(!linked)
|
||||
if(!ticket_machine_ref)
|
||||
return
|
||||
var/obj/machinery/ticket_machine/machine = linked.resolve()
|
||||
var/obj/machinery/ticket_machine/machine = ticket_machine_ref.resolve()
|
||||
if(!machine)
|
||||
return
|
||||
cooldown = TRUE
|
||||
machine.increment()
|
||||
if(isnull(machine.current_ticket))
|
||||
to_chat(activator, span_notice("The button light indicates that there are no more tickets to be processed."))
|
||||
addtimer(VARSET_CALLBACK(src, cooldown, FALSE), 10)
|
||||
|
||||
/obj/machinery/ticket_machine/update_icon()
|
||||
@@ -143,7 +160,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/ticket_machine, 32)
|
||||
return ..()
|
||||
|
||||
/obj/machinery/ticket_machine/proc/handle_maptext()
|
||||
switch(ticket_number) //This is here to handle maptext offsets so that the numbers align.
|
||||
switch(current_number) //This is here to handle maptext offsets so that the numbers align.
|
||||
if(0 to 9)
|
||||
maptext_x = 13
|
||||
if(10 to 99)
|
||||
@@ -166,7 +183,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/ticket_machine, 32)
|
||||
current_number = 0
|
||||
if(tickets.len)
|
||||
for(var/obj/item/ticket_machine_ticket/ticket in tickets)
|
||||
ticket.audible_message(span_notice("\the [ticket] disperses!"))
|
||||
ticket.audible_message(span_notice("\the [ticket] disperses!"), hearing_distance = SAMETILE_MESSAGE_RANGE)
|
||||
qdel(ticket)
|
||||
tickets.Cut()
|
||||
max_number = initial(max_number)
|
||||
@@ -190,11 +207,8 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/ticket_machine, 32)
|
||||
return
|
||||
playsound(src, 'sound/machines/terminal_insert_disc.ogg', 100, FALSE)
|
||||
ticket_number++
|
||||
to_chat(user, span_notice("You take a ticket from [src], looks like you're ticket number #[ticket_number]..."))
|
||||
var/obj/item/ticket_machine_ticket/theirticket = new /obj/item/ticket_machine_ticket(get_turf(src))
|
||||
theirticket.name = "Ticket #[ticket_number]"
|
||||
theirticket.maptext = MAPTEXT(ticket_number)
|
||||
theirticket.saved_maptext = MAPTEXT(ticket_number)
|
||||
to_chat(user, span_notice("You take a ticket from [src], looks like you're number [ticket_number] in queue..."))
|
||||
var/obj/item/ticket_machine_ticket/theirticket = new (get_turf(src), ticket_number)
|
||||
theirticket.source = src
|
||||
theirticket.owner_ref = user_ref
|
||||
user.put_in_hands(theirticket)
|
||||
@@ -207,10 +221,10 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/ticket_machine, 32)
|
||||
user.dropItemToGround(theirticket)
|
||||
user.adjust_fire_stacks(1)
|
||||
user.ignite_mob()
|
||||
return
|
||||
update_appearance()
|
||||
|
||||
/obj/item/ticket_machine_ticket
|
||||
name = "Ticket"
|
||||
name = "\improper ticket"
|
||||
desc = "A ticket which shows your place in the Head of Personnel's line. Made from Nanotrasen patented NanoPaper®. Though solid, its form seems to shimmer slightly. Feels (and burns) just like the real thing."
|
||||
icon = 'icons/obj/bureaucracy.dmi'
|
||||
icon_state = "ticket"
|
||||
@@ -219,10 +233,26 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/ticket_machine, 32)
|
||||
w_class = WEIGHT_CLASS_TINY
|
||||
resistance_flags = FLAMMABLE
|
||||
max_integrity = 50
|
||||
var/number
|
||||
var/saved_maptext = null
|
||||
var/owner_ref // A ref to our owner. Doesn't need to be weak because mobs have unique refs
|
||||
var/obj/machinery/ticket_machine/source
|
||||
|
||||
/obj/item/ticket_machine_ticket/Initialize(mapload, num)
|
||||
. = ..()
|
||||
number = num
|
||||
if(!isnull(num))
|
||||
name += " #[num]"
|
||||
saved_maptext = MAPTEXT(num)
|
||||
maptext = saved_maptext
|
||||
|
||||
/obj/item/ticket_machine_ticket/examine(mob/user)
|
||||
. = ..()
|
||||
if(!isnull(number))
|
||||
. += span_notice("The ticket reads shimmering text that tells you that you are number [number] in queue.")
|
||||
if(source)
|
||||
. += span_notice("Below that, you can see that you are [number - source.current_number] spot\s away from being served.")
|
||||
|
||||
/obj/item/ticket_machine_ticket/attack_hand(mob/user, list/modifiers)
|
||||
. = ..()
|
||||
maptext = saved_maptext //For some reason, storage code removes all maptext off objs, this stops its number from being wiped off when taken out of storage.
|
||||
@@ -233,13 +263,11 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/ticket_machine, 32)
|
||||
|
||||
return ..()
|
||||
|
||||
/obj/item/paper/extinguish()
|
||||
..()
|
||||
update_appearance()
|
||||
|
||||
/obj/item/ticket_machine_ticket/Destroy()
|
||||
if(source)
|
||||
source.ticket_holders -= owner_ref
|
||||
source.tickets -= src
|
||||
if(source.current_ticket == src)
|
||||
source.current_ticket = null
|
||||
source = null
|
||||
return ..()
|
||||
|
||||
Reference in New Issue
Block a user