Skip to content

Commit

Permalink
fix(multitasking): removes ability to perform identical do_after() an…
Browse files Browse the repository at this point in the history
…d do_mob()
  • Loading branch information
Filatelele committed Dec 19, 2023
1 parent 71f0f67 commit bbd907c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
5 changes: 5 additions & 0 deletions code/_global_vars/mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,8 @@ GLOBAL_LIST_EMPTY(silicon_mob_list) //List of all silicon mobs, including client
GLOBAL_LIST_EMPTY(living_mob_list_) //List of all alive mobs, including clientless. Excludes /mob/new_player
GLOBAL_LIST_EMPTY(dead_mob_list_) //List of all dead mobs, including clientless. Excludes /mob/new_player
GLOBAL_LIST_EMPTY(ghost_mob_list) //List of all ghosts, including clientless. Excludes /mob/new_player

/// List of mobs currently using do_mob() to prevent duplicated actions
GLOBAL_LIST_EMPTY(domobs)
/// List of mobs currently using do_after() to prevent duplicated actions
GLOBAL_LIST_EMPTY(doafters)
26 changes: 22 additions & 4 deletions code/_helpers/mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,14 @@

/proc/do_mob(atom/movable/affecter, mob/target, time = 30, target_zone = 0, uninterruptible = 0, progress = 1, incapacitation_flags = INCAPACITATION_DEFAULT)
if(!affecter || !target)
return 0
return FALSE

var/uniqueid = "domob_\ref[affecter]_\ref[target]"
if(uniqueid in GLOB.domobs)
return FALSE

LAZYADD(GLOB.domobs, uniqueid)

var/mob/user = affecter
var/is_mob_type = istype(user)
var/user_loc = affecter.loc
Expand Down Expand Up @@ -183,9 +190,18 @@
if(progbar)
qdel(progbar)

/proc/do_after(mob/user, delay, atom/target = null, needhand = 1, progress = 1, incapacitation_flags = INCAPACITATION_DEFAULT, same_direction = 0, can_move = 0)
LAZYREMOVE(GLOB.domobs, uniqueid)

/proc/do_after(mob/user, delay, atom/target = null, needhand = TRUE, progress = TRUE, incapacitation_flags = INCAPACITATION_DEFAULT, same_direction = FALSE, can_move = FALSE)
if(!user)
return 0
return FALSE

var/uniqueid = "doafter_\ref[user]_\ref[target]"
if(uniqueid in GLOB.doafters)
return FALSE

LAZYADD(GLOB.doafters, uniqueid)

var/atom/target_loc = null
var/target_type = null

Expand Down Expand Up @@ -229,9 +245,11 @@
. = 0
break

if (progbar)
if(progbar)
qdel(progbar)

LAZYREMOVE(GLOB.doafters, uniqueid)

/proc/is_species(A, species_datum)
. = FALSE
if(ishuman(A))
Expand Down

0 comments on commit bbd907c

Please sign in to comment.