Fixes morgue updating and removes VGhooks

This commit is contained in:
Krausus
2016-07-11 17:39:21 -04:00
parent 26e13f270f
commit 355fb3c080
12 changed files with 54 additions and 129 deletions
-4
View File
@@ -1,4 +0,0 @@
// Called when a mob moves from one MASTER area to another.
// (Master, as opposed to lighting subareas)
/hook/mobAreaChange
name = "MobAreaChange"
-54
View File
@@ -1,54 +0,0 @@
/************
* D2K5-STYLE HOOKS
*
* BLATANTLY STOLEN FROM D2K5 AND MODIFIED
*
* SOMEHOW SUCKS LESS THAN BAY'S HOOKS
************
The major change is to standardize them a bit
by changing the event prefix to On instead of Hook.
Oh and it's documented and cleaned up. - N3X
*/
/hook
var/name = "DefaultHookName"
var/list/handlers = list()
proc/Called(var/list/args) // When the hook is called
return 0
proc/Setup() // Called when the setup things is ran for the hook, objs contain all objects with that is hooking
/hook_handler
// Your hook handler should do this:
// proc/OnThingHappened(var/list/args)
// return handled // boolean
var/global/list/hooks = list()
/proc/SetupHooks()
for(var/hook_path in typesof(/hook))
var/hook/hook = new hook_path
hooks[hook.name] = hook
// log_to_dd("Found hook: " + hook.name)
for(var/hook_path in typesof(/hook_handler))
var/hook_handler/hook_handler = new hook_path
for(var/name in hooks)
if(hascall(hook_handler, "On" + name))
var/hook/hook = hooks[name]
hook.handlers += hook_handler
// log_to_dd("Found hook handler for: " + name)
for(var/hook/hook in hooks)
hook.Setup()
/proc/CallHook(var/name as text, var/list/args)
var/hook/hook = hooks[name]
if(!hook)
//log_to_dd("WARNING: Hook with name " + name + " does not exist")
return
if(hook.Called(args))
return
for(var/hook_handler/hook_handler in hook.handlers)
call(hook_handler, "On" + hook.name)(args)
-2
View File
@@ -1,2 +0,0 @@
/hook/login
name = "Login"
+21
View File
@@ -99,3 +99,24 @@
* Parameters: var/mob/living/carbon/human/captain
*/
/hook/captain_spawned
/**
* Mob login hook.
* Called in login.dm when a player logs in to a mob.
* Parameters: var/client/client, var/mob/mob
*/
/hook/mob_login
/**
* Mob logout hook.
* Called in logout.dm when a player logs out of a mob.
* Parameters: var/client/client, var/mob/mob
*/
/hook/mob_logout
/**
* Mob area change hook.
* Called in area.dm when a mob moves from one area to another.
* Parameters: var/mob/mob, var/area/newarea, var/area/oldarea
*/
/hook/mob_area_change
+1 -1
View File
@@ -310,7 +310,7 @@
M.lastarea = src
// /vg/ - EVENTS!
CallHook("MobAreaChange", list("mob" = M, "new" = newarea, "old" = oldarea))
callHook("mob_area_change", list("mob" = M, "newarea" = newarea, "oldarea" = oldarea))
if(!istype(A,/mob/living)) return
+19 -45
View File
@@ -449,50 +449,24 @@
to_chat(usr, "\red Access denied.")
return
/hook/Login/proc/update_morgue(var/client/client, var/mob/L)
//Update morgues on login/logout
if(L.stat == DEAD)
var/obj/structure/morgue/Morgue = null
var/mob/living/carbon/human/C = null
if(istype(L,/mob/dead/observer)) //We're a ghost, let's find our corpse
var/mob/dead/observer/G = L
if(!G.mind) //This'll probably break morgue sprites, but the line under the next If statement causes runtimes with Assume Direct Control.
return
if(G.can_reenter_corpse && G.mind.current)
C = G.mind.current
else if(istype(L,/mob/living/carbon/human))
C = L
/mob/proc/update_morgue()
if(stat == DEAD)
var/obj/structure/morgue/morgue
var/mob/living/C = src
var/mob/dead/observer/G = src
if(istype(G) && G.can_reenter_corpse && G.mind) //We're a ghost, let's find our corpse
C = G.mind.current
if(istype(C)) //We found our corpse, is it inside a morgue?
morgue = get(C.loc, /obj/structure/morgue)
if(morgue)
morgue.update()
if(C) //We found our corpse, is it inside a morgue?
if(istype(C.loc,/obj/structure/morgue))
Morgue = C.loc
else if(istype(C.loc,/obj/structure/closet/body_bag))
var/obj/structure/closet/body_bag/B = C.loc
if(istype(B.loc,/obj/structure/morgue))
Morgue = B.loc
if(Morgue)
Morgue.update()
/hook/mob_login/proc/update_morgue(var/client/client, var/mob/mob)
//Update morgues on login
mob.update_morgue()
return 1
/hook/Logout/proc/update_morgue(var/client/client, var/mob/L)
//Update morgues on login/logout
if(L.stat == DEAD)
var/obj/structure/morgue/Morgue = null
var/mob/living/carbon/human/C = null
if(istype(L,/mob/dead/observer)) //We're a ghost, let's find our corpse
var/mob/dead/observer/G = L
if(!G.mind) //This'll probably break morgue sprites, but the line under the next If statement causes runtimes with Assume Direct Control.
return 1
if(G.can_reenter_corpse && G.mind.current)
C = G.mind.current
else if(istype(L,/mob/living/carbon/human))
C = L
if(C) //We found our corpse, is it inside a morgue?
if(istype(C.loc,/obj/structure/morgue))
Morgue = C.loc
else if(istype(C.loc,/obj/structure/closet/body_bag))
var/obj/structure/closet/body_bag/B = C.loc
if(istype(B.loc,/obj/structure/morgue))
Morgue = B.loc
if(Morgue)
Morgue.update()
/hook/mob_logout/proc/update_morgue(var/client/client, var/mob/mob)
//Update morgues on logout
mob.update_morgue()
return 1
+10 -15
View File
@@ -51,23 +51,18 @@ if(vlc.attachEvent) {
"}
// Hook into the events we desire.
/hook_handler/soundmanager
// Set up player on login
proc/OnLogin(var/list/args)
//testing("Received OnLogin.")
var/client/C = args["client"]
C.media = new /datum/media_manager(args["mob"])
C.media.open()
spawn(20)
C.media.update_music()
/hook/mob_login/proc/init_media_manager(client/client, mob/mob)
client.media = new /datum/media_manager(mob)
client.media.open()
spawn(20)
client.media.update_music()
return 1
// Update when moving between areas.
proc/OnMobAreaChange(var/list/args)
var/mob/M = args["mob"]
//if(istype(M, /mob/living/carbon/human)||istype(M, /mob/dead/observer))
// testing("Received OnMobAreaChange for [M.type] [M] (M.client=[M.client==null?"null":"/client"]).")
if(M.client)
M.update_music()
/hook/mob_area_change/proc/update_media(mob/mob, area/newarea, area/oldarea)
if(mob.client)
mob.update_music()
return 1
/mob/proc/update_music()
if(client && client.media)
+1 -1
View File
@@ -77,7 +77,7 @@
for(var/datum/alternate_appearance/AA in viewing_alternate_appearances)
AA.display_to(list(src))
CallHook("Login", list("client" = src.client, "mob" = src))
callHook("mob_login", list("client" = client, "mob" = src))
// Calling update_interface() in /mob/Login() causes the Cyborg to immediately be ghosted; because of winget().
// Calling it in the overriden Login, such as /mob/living/Login() doesn't cause this.
+1 -1
View File
@@ -11,6 +11,6 @@
send2adminirc("[key_name(src)] logged out - no more admins online.")
..()
CallHook("Logout", list("client" = src.client, "mob" = src))
callHook("mob_logout", list("client" = client, "mob" = src))
return 1
+1 -1
View File
@@ -27,7 +27,7 @@
loc = pick(watch_locations)
*/
CallHook("Login", list("client" = src.client, "mob" = src))
callHook("mob_login", list("client" = client, "mob" = src))
new_player_panel()
if(ckey in deadmins)
-2
View File
@@ -35,8 +35,6 @@ var/global/datum/global_init/init = new ()
if(config && config.log_runtimes)
log = file("data/logs/runtime/[time2text(world.realtime,"YYYY-MM-DD-(hh-mm-ss)")]-runtime.log")
SetupHooks() // /vg/
if(config && config.server_name != null && config.server_suffix && world.port > 0)
// dumb and hardcoded but I don't care~
config.server_name += " #[(world.port % 1000) / 100]"
-3
View File
@@ -83,9 +83,6 @@
#include "code\_globalvars\lists\names.dm"
#include "code\_globalvars\lists\objects.dm"
#include "code\_globalvars\lists\reagents.dm"
#include "code\_hooks\area.dm"
#include "code\_hooks\hooks.dm"
#include "code\_hooks\mob.dm"
#include "code\_onclick\_defines.dm"
#include "code\_onclick\adjacent.dm"
#include "code\_onclick\ai.dm"