mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-01-09 16:33:50 +00:00
Fixes a ton of harddels, sourced from #59996 I think this brings us down to like, ~100 per round from ~200, with only like 20 of those being proper hell failures. I've seen harddel profiles below 1 second of total cost. Feeling good. See you on the other side Makes the cryopod control computer into a weakref, never trust bee code Converts brig door timer internal lists to weakrefs Fixes a harddel caused by qdeling a motion sensitive camera after it had left its source area, jesus christ why didn't we do this already holy shit Converts the radio implant ref held by the antenna mutation to weakrefs because it isn't reliably cleaned up, makes the radio implant actually qdel its fucking radio Removes the target var from the throwing datum, it does literally nothing and just exists to cause harddels, mostly for the singularity Fixes a cable harddel sourced from things that try to enter blueprints after smoothing, but before roundstart. IE, shuttles. Removes shuttles from the blueprints Fixes emmisive blockers being added post qdel Removes some manual ghosting from cryopods, I initially did this for harddel reasons, but I figured out a better fix for that. I'm now doing it because it's got this really strange logic for like "re-entering the game" that doesn't actually link to what the ghostize proc does. We should remove this at some point Fixes robot hud objects harddeling due to hanging refs Fixes buildmode related hanging refs, I'm coming for you admin team Fixes a few instances of trying to add the forensics component post qdel, hhhhhhhhhhh Fixes some split personality harddels/weirdness Replaces a use of disconnect_duct with an init qdel hint, I suspect there's more issues with duct harddels, I've seen some odd logs about ahhh the area_contents list, but we can worry about that later Makes teleporter targets into weakrefs, properly types them as /atom Makes frequency devices into weakrefs Makes cameras remove themselves from camera nets on Destroy Makes tgui ui datums implement destroy, this means if I ever see one hang a ref to user or whatever, I know there's an error with calling close() properly. I've seen this harddel once, but not after this change so I assume there was some error with close(). IDK maybe this is a papering over? Would have to ask @stylemistake I've seen logs of beartraps being in world post del, putting a return there just in case. The same is true of nerf darts, but I haven't really looked into that yet Makes a shoe's ref to untying alerts a weakref, yes this is needed. Moves clearing client_in_contents to the Login of the new mob. This prevents doing things like ghosting someone before a mob qdel causing harddels Fixes a harddel set sourced from adding a status effect to a qdeleted thing. Is this an error? I'm honestly not sure. Converts bsa code to weakrefs Converts the partner var of heat exchangers to weakrefs Converts camera assemblies to weakrefs Fixes some dumb behavior with ammo casings and assuming you'll be on a turf post Destroy parent call Fixes? merger related harddels, you were never cleared from your own members list, so origin objects would end up making a new list, creating harddels. Potential input from @ninjanomnom about the logic Chasms store a static list of "falling atoms", which only exists for chasms that go somewhere else. This list wasn't being cleared of qdeleted objects, which is what happens when you fall in most chasms. Fixes this, and converts the list to weakrefs. Fixes some runtimes in both sheet code, and the weather listener element. This is here because runtime spam made testing more of a pain, didn't think it needed its own pr Fixes colorful reagent harddels sourced from reagents that were qdel'd before roundstart. I'm only like 50% sure this actually got it, but the issue may have been solved by #60174, so eh Turns the nuke op antag datum's ref to the war button into a weakref Fixes some holopad code that was not nulling refs all the time Converts camera bugs to weakrefs, this was the result of the bug being "reworked" like 6 years back without taking the existing ref clearing into account. Whole item needs a redo, but this'll do for now. Ensures that the both pulling and pullee refs are cleared on Destroy The crew monitor held all users in a non clearing list, makes that list a weakref because I hate everything Oh and I removed all sources of gas_mixture qdeletion, I'm kinda unsure on this since it's not technically supported, but any harddels from it might? indicate something going wrong with like, gas passing logic. I'd like @MrStonedOne's thoughts, since I trust him to call me an idiot if I'm wrong. <!-- Please add a short description of why you think these changes would benefit the game. If you can't justify it in words, it might not be worth adding. --> ## Why it's not good for the game I crashed sybil like 10 times to get this data, I'm gonna put it to good use. Don't think you're safe sybilites, I'm coming for you.
205 lines
5.9 KiB
Plaintext
205 lines
5.9 KiB
Plaintext
#define MAX_THROWING_DIST 1280 // 5 z-levels on default width
|
|
#define MAX_TICKS_TO_MAKE_UP 3 //how many missed ticks will we attempt to make up for this run.
|
|
|
|
SUBSYSTEM_DEF(throwing)
|
|
name = "Throwing"
|
|
priority = FIRE_PRIORITY_THROWING
|
|
wait = 1
|
|
flags = SS_NO_INIT|SS_KEEP_TIMING|SS_TICKER
|
|
runlevels = RUNLEVEL_GAME | RUNLEVEL_POSTGAME
|
|
|
|
var/list/currentrun
|
|
var/list/processing = list()
|
|
|
|
/datum/controller/subsystem/throwing/stat_entry(msg)
|
|
msg = "P:[length(processing)]"
|
|
return ..()
|
|
|
|
|
|
/datum/controller/subsystem/throwing/fire(resumed = 0)
|
|
if (!resumed)
|
|
src.currentrun = processing.Copy()
|
|
|
|
//cache for sanic speed (lists are references anyways)
|
|
var/list/currentrun = src.currentrun
|
|
|
|
while(length(currentrun))
|
|
var/atom/movable/AM = currentrun[currentrun.len]
|
|
var/datum/thrownthing/TT = currentrun[AM]
|
|
currentrun.len--
|
|
if (QDELETED(AM) || QDELETED(TT))
|
|
processing -= AM
|
|
if (MC_TICK_CHECK)
|
|
return
|
|
continue
|
|
|
|
TT.tick()
|
|
|
|
if (MC_TICK_CHECK)
|
|
return
|
|
|
|
currentrun = null
|
|
|
|
/datum/thrownthing
|
|
var/atom/movable/thrownthing
|
|
var/turf/target_turf
|
|
var/target_zone
|
|
var/init_dir
|
|
var/maxrange
|
|
var/speed
|
|
var/mob/thrower
|
|
var/diagonals_first
|
|
var/dist_travelled = 0
|
|
var/start_time
|
|
var/dist_x
|
|
var/dist_y
|
|
var/dx
|
|
var/dy
|
|
var/force = MOVE_FORCE_DEFAULT
|
|
var/gentle = FALSE
|
|
var/pure_diagonal
|
|
var/diagonal_error
|
|
var/datum/callback/callback
|
|
var/paused = FALSE
|
|
var/delayed_time = 0
|
|
var/last_move = 0
|
|
|
|
|
|
/datum/thrownthing/New(thrownthing, target_turf, init_dir, maxrange, speed, thrower, diagonals_first, force, gentle, callback, target_zone)
|
|
. = ..()
|
|
src.thrownthing = thrownthing
|
|
RegisterSignal(thrownthing, COMSIG_PARENT_QDELETING, .proc/on_thrownthing_qdel)
|
|
src.target_turf = target_turf
|
|
src.init_dir = init_dir
|
|
src.maxrange = maxrange
|
|
src.speed = speed
|
|
src.thrower = thrower
|
|
src.diagonals_first = diagonals_first
|
|
src.force = force
|
|
src.gentle = gentle
|
|
src.callback = callback
|
|
src.target_zone = target_zone
|
|
|
|
|
|
/datum/thrownthing/Destroy()
|
|
SSthrowing.processing -= thrownthing
|
|
SSthrowing.currentrun -= thrownthing
|
|
thrownthing.throwing = null
|
|
thrownthing = null
|
|
thrower = null
|
|
if(callback)
|
|
QDEL_NULL(callback) //It stores a reference to the thrownthing, its source. Let's clean that.
|
|
return ..()
|
|
|
|
|
|
///Defines the datum behavior on the thrownthing's qdeletion event.
|
|
/datum/thrownthing/proc/on_thrownthing_qdel(atom/movable/source, force)
|
|
SIGNAL_HANDLER
|
|
|
|
qdel(src)
|
|
|
|
|
|
/datum/thrownthing/proc/tick()
|
|
var/atom/movable/AM = thrownthing
|
|
if (!isturf(AM.loc) || !AM.throwing)
|
|
finalize()
|
|
return
|
|
|
|
if(paused)
|
|
delayed_time += world.time - last_move
|
|
return
|
|
|
|
if (dist_travelled && hitcheck()) //to catch sneaky things moving on our tile while we slept
|
|
finalize()
|
|
return
|
|
|
|
var/atom/step
|
|
|
|
last_move = world.time
|
|
|
|
//calculate how many tiles to move, making up for any missed ticks.
|
|
var/tilestomove = CEILING(min(((((world.time+world.tick_lag) - start_time + delayed_time) * speed) - (dist_travelled ? dist_travelled : -1)), speed*MAX_TICKS_TO_MAKE_UP) * (world.tick_lag * SSthrowing.wait), 1)
|
|
while (tilestomove-- > 0)
|
|
if ((dist_travelled >= maxrange || AM.loc == target_turf) && AM.has_gravity(AM.loc))
|
|
finalize()
|
|
return
|
|
|
|
if (dist_travelled <= max(dist_x, dist_y)) //if we haven't reached the target yet we home in on it, otherwise we use the initial direction
|
|
step = get_step(AM, get_dir(AM, target_turf))
|
|
else
|
|
step = get_step(AM, init_dir)
|
|
|
|
if (!pure_diagonal && !diagonals_first) // not a purely diagonal trajectory and we don't want all diagonal moves to be done first
|
|
if (diagonal_error >= 0 && max(dist_x,dist_y) - dist_travelled != 1) //we do a step forward unless we're right before the target
|
|
step = get_step(AM, dx)
|
|
diagonal_error += (diagonal_error < 0) ? dist_x/2 : -dist_y
|
|
|
|
if (!step) // going off the edge of the map makes get_step return null, don't let things go off the edge
|
|
finalize()
|
|
return
|
|
|
|
AM.Move(step, get_dir(AM, step), DELAY_TO_GLIDE_SIZE(1 / speed))
|
|
|
|
if (!AM.throwing) // we hit something during our move
|
|
finalize(hit = TRUE)
|
|
return
|
|
|
|
dist_travelled++
|
|
|
|
if (dist_travelled > MAX_THROWING_DIST)
|
|
finalize()
|
|
return
|
|
|
|
/datum/thrownthing/proc/finalize(hit = FALSE, target=null)
|
|
set waitfor = FALSE
|
|
//done throwing, either because it hit something or it finished moving
|
|
if(!thrownthing)
|
|
return
|
|
thrownthing.throwing = null
|
|
if (!hit)
|
|
for (var/thing in get_turf(thrownthing)) //looking for our target on the turf we land on.
|
|
var/atom/A = thing
|
|
if (A == target)
|
|
hit = TRUE
|
|
thrownthing.throw_impact(A, src)
|
|
if(QDELETED(thrownthing)) //throw_impact can delete things, such as glasses smashing
|
|
return //deletion should already be handled by on_thrownthing_qdel()
|
|
break
|
|
if (!hit)
|
|
thrownthing.throw_impact(get_turf(thrownthing), src) // we haven't hit something yet and we still must, let's hit the ground.
|
|
if(QDELETED(thrownthing)) //throw_impact can delete things, such as glasses smashing
|
|
return //deletion should already be handled by on_thrownthing_qdel()
|
|
thrownthing.newtonian_move(init_dir)
|
|
else
|
|
thrownthing.newtonian_move(init_dir)
|
|
|
|
if(target)
|
|
thrownthing.throw_impact(target, src)
|
|
if(QDELETED(thrownthing)) //throw_impact can delete things, such as glasses smashing
|
|
return //deletion should already be handled by on_thrownthing_qdel()
|
|
|
|
if (callback)
|
|
callback.Invoke()
|
|
|
|
if(!thrownthing.zfalling) // I don't think you can zfall while thrown but hey, just in case.
|
|
var/turf/T = get_turf(thrownthing)
|
|
if(T && thrownthing.has_gravity(T))
|
|
T.zFall(thrownthing)
|
|
|
|
if(thrownthing)
|
|
SEND_SIGNAL(thrownthing, COMSIG_MOVABLE_THROW_LANDED, src)
|
|
|
|
qdel(src)
|
|
|
|
/datum/thrownthing/proc/hit_atom(atom/A)
|
|
finalize(hit=TRUE, target=A)
|
|
|
|
/datum/thrownthing/proc/hitcheck()
|
|
for (var/thing in get_turf(thrownthing))
|
|
var/atom/movable/AM = thing
|
|
if (AM == thrownthing || (AM == thrower && !ismob(thrownthing)))
|
|
continue
|
|
if (AM.density && !(AM.pass_flags_self & LETPASSTHROW) && !(AM.flags_1 & ON_BORDER_1))
|
|
finalize(hit=TRUE, target=AM)
|
|
return TRUE
|