Player Z-tracking, again (#33216)

* Player Z-tracking, again

* requested changes

* shuttle changes

* a fix

* vending

* honk

* brainstuff take 1

* Honk

* adminspam into testing def

* remove rebase artifact
This commit is contained in:
vuonojenmustaturska
2017-12-15 01:35:30 +02:00
committed by Emmett Gaines
parent e57784a1bd
commit de51ac3667
13 changed files with 74 additions and 8 deletions

View File

@@ -1,14 +1,18 @@
SUBSYSTEM_DEF(mobs)
name = "Mobs"
priority = 100
flags = SS_KEEP_TIMING|SS_NO_INIT
flags = SS_KEEP_TIMING
runlevels = RUNLEVEL_GAME | RUNLEVEL_POSTGAME
var/list/currentrun = list()
var/static/list/clients_by_zlevel[][]
/datum/controller/subsystem/mobs/stat_entry()
..("P:[GLOB.mob_living_list.len]")
/datum/controller/subsystem/mobs/Initialize(start_timeofday)
clients_by_zlevel = new /list(world.maxz,0)
return ..()
/datum/controller/subsystem/mobs/fire(resumed = 0)
var/seconds = wait * 0.1

View File

@@ -254,6 +254,12 @@
loc = destination
if(!same_loc)
var/turf/oldturf = get_turf(oldloc)
var/turf/destturf = get_turf(destination)
var/old_z = (oldturf ? oldturf.z : null)
var/dest_z = (destturf ? destturf.z : null)
if (old_z != dest_z)
onTransitZ(old_z, dest_z)
destination.Entered(src, oldloc)
if(destarea && old_area != destarea)
destarea.Entered(src, oldloc)
@@ -276,6 +282,11 @@
old_area.Exited(src, null)
loc = null
/atom/movable/proc/onTransitZ(old_z,new_z)
for (var/item in src) // Notify contents of Z-transition. This can be overridden IF we know the items contents do not care.
var/atom/movable/AM = item
AM.onTransitZ(old_z,new_z)
//Called whenever an object moves and by mobs when they attempt to move themselves through space
//And when an object or action applies a force on src, see newtonian_move() below
//Return 0 to have src start/keep drifting in a no-grav area and 1 to stop/not start drifting

View File

@@ -1190,6 +1190,9 @@ IF YOU MODIFY THE PRODUCTS LIST OF A MACHINE, MAKE SURE TO UPDATE ITS RESUPPLY C
refill_canister = /obj/item/vending_refill/games
/obj/machinery/vending/onTransitZ()
return
#undef STANDARD_CHARGE
#undef CONTRABAND_CHARGE
#undef COIN_CHARGE

View File

@@ -130,9 +130,12 @@
return
if(destination_z)
var/old_z = A.z
A.x = destination_x
A.y = destination_y
A.z = destination_z
if (old_z != destination_z)
A.onTransitZ(old_z, destination_z)
if(isliving(A))
var/mob/living/L = A

View File

@@ -140,6 +140,9 @@
/atom/movable/lighting_object/blob_act()
return
/atom/movable/lighting_object/onTransitZ()
return
// Override here to prevent things accidentally moving around overlays.
/atom/movable/lighting_object/forceMove(atom/destination, var/no_tp=FALSE, var/harderforce = FALSE)
if(harderforce)

View File

@@ -81,3 +81,6 @@
WD.add_fingerprint(user)
dump_box_contents()
qdel(src)
/obj/structure/ore_box/onTransitZ()
return

View File

@@ -828,7 +828,7 @@
return pick(/area/hallway, /area/crew_quarters/locker)
/mob/living/carbon/human/interactive/proc/target_filter(target)
var/list/filtered_targets = list(/area, /turf, /obj/machinery/door, /atom/movable/light, /obj/structure/cable, /obj/machinery/atmospherics)
var/list/filtered_targets = list(/area, /turf, /obj/machinery/door, /atom/movable/lighting_object, /obj/structure/cable, /obj/machinery/atmospherics)
var/list/L = target
for(var/atom/A in target) // added a bunch of "junk" that clogs up the general find procs
if(is_type_in_list(A,filtered_targets))

View File

@@ -8,6 +8,18 @@
if((movement_type & FLYING) && !floating) //TODO: Better floating
float(on = TRUE)
if (client || registered_z) // This is a temporary error tracker to make sure we've caught everything
var/turf/T = get_turf(src)
if (client && registered_z != T.z)
#ifdef TESTING
message_admins("[src] [ADMIN_FLW(src)] has somehow ended up in Z-level [T.z] despite being registered in Z-level [registered_z]. If you could ask them how that happened and notify coderbus, it would be appreciated.")
#endif
log_game("Z-TRACKING: [src] has somehow ended up in Z-level [T.z] despite being registered in Z-level [registered_z].")
update_z(T.z)
else if (!client && registered_z)
log_game("Z-TRACKING: [src] of type [src.type] has a Z-registration despite not having a client.")
update_z(null)
if (notransform)
return
if(!loc)

View File

@@ -1027,3 +1027,18 @@
if(client)
reset_perspective(destination)
update_canmove() //if the mob was asleep inside a container and then got forceMoved out we need to make them fall.
/mob/living/proc/update_z(new_z) // 1+ to register, null to unregister
if (registered_z != new_z)
if (registered_z)
SSmobs.clients_by_zlevel[registered_z] -= src
if (client)
if (new_z)
SSmobs.clients_by_zlevel[new_z] += src
registered_z = new_z
else
registered_z = null
/mob/living/onTransitZ(old_z,new_z)
..()
update_z(new_z)

View File

@@ -78,3 +78,5 @@
var/last_words //used for database logging
var/list/obj/effect/proc_holder/abilities = list()
var/registered_z

View File

@@ -13,6 +13,10 @@
update_damage_hud()
update_health_hud()
if (loc)
var/turf/T = get_turf(src)
update_z(T.z)
//Vents
if(ventcrawler)
to_chat(src, "<span class='notice'>You can ventcrawl! Use alt+click on vents to quickly travel about the station.</span>")

View File

@@ -1,4 +1,5 @@
/mob/living/Logout()
update_z(null)
if(ranged_ability && client)
ranged_ability.remove_mousepointer(client)
..()

View File

@@ -91,15 +91,23 @@ All ShuttleMove procs go here
return
loc = newT
return TRUE
// Called on atoms after everything has been moved
/atom/movable/proc/afterShuttleMove(turf/oldT, list/movement_force, shuttle_dir, shuttle_preferred_direction, move_dir, rotation)
var/turf/newT = get_turf(src)
if (newT.z != oldT.z)
onTransitZ(oldT.z, newT.z)
if(light)
update_light()
if(rotation)
shuttleRotate(rotation)
update_parallax_contents()
return TRUE
@@ -330,9 +338,6 @@ All ShuttleMove procs go here
/atom/movable/lighting_object/onShuttleMove()
return FALSE
/atom/movable/light/onShuttleMove()
return FALSE
/obj/docking_port/stationary/onShuttleMove(turf/newT, turf/oldT, list/movement_force, move_dir, obj/docking_port/stationary/old_dock, obj/docking_port/mobile/moving_dock)
if(!moving_dock.can_move_docking_ports || old_dock == src)
return FALSE