diff --git a/code/_hooks/area.dm b/code/_hooks/area.dm deleted file mode 100644 index 6b2834af165..00000000000 --- a/code/_hooks/area.dm +++ /dev/null @@ -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" \ No newline at end of file diff --git a/code/_hooks/hooks.dm b/code/_hooks/hooks.dm deleted file mode 100644 index ccd0eb04722..00000000000 --- a/code/_hooks/hooks.dm +++ /dev/null @@ -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) \ No newline at end of file diff --git a/code/_hooks/mob.dm b/code/_hooks/mob.dm deleted file mode 100644 index f0ea2952f57..00000000000 --- a/code/_hooks/mob.dm +++ /dev/null @@ -1,2 +0,0 @@ -/hook/login - name = "Login" \ No newline at end of file diff --git a/code/controllers/hooks-defs.dm b/code/controllers/hooks-defs.dm index ae0e7e85b69..68db39c69dc 100644 --- a/code/controllers/hooks-defs.dm +++ b/code/controllers/hooks-defs.dm @@ -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 diff --git a/code/game/area/areas.dm b/code/game/area/areas.dm index 72305e67a6e..e38d689f19e 100644 --- a/code/game/area/areas.dm +++ b/code/game/area/areas.dm @@ -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 diff --git a/code/game/objects/structures/morgue.dm b/code/game/objects/structures/morgue.dm index 694cb294b46..71a0c8379a9 100644 --- a/code/game/objects/structures/morgue.dm +++ b/code/game/objects/structures/morgue.dm @@ -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() \ No newline at end of file +/hook/mob_logout/proc/update_morgue(var/client/client, var/mob/mob) + //Update morgues on logout + mob.update_morgue() + return 1 diff --git a/code/modules/media/mediamanager.dm b/code/modules/media/mediamanager.dm index d7a3edda003..125b224c8ea 100644 --- a/code/modules/media/mediamanager.dm +++ b/code/modules/media/mediamanager.dm @@ -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) diff --git a/code/modules/mob/login.dm b/code/modules/mob/login.dm index 28886862c2f..eec1b92e63d 100644 --- a/code/modules/mob/login.dm +++ b/code/modules/mob/login.dm @@ -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. diff --git a/code/modules/mob/logout.dm b/code/modules/mob/logout.dm index 43fc3f0b480..ac13431f6b0 100644 --- a/code/modules/mob/logout.dm +++ b/code/modules/mob/logout.dm @@ -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 \ No newline at end of file diff --git a/code/modules/mob/new_player/login.dm b/code/modules/mob/new_player/login.dm index f7cff248519..c226f3a0176 100644 --- a/code/modules/mob/new_player/login.dm +++ b/code/modules/mob/new_player/login.dm @@ -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) diff --git a/code/world.dm b/code/world.dm index 3aa661aeb05..a829cbde35a 100644 --- a/code/world.dm +++ b/code/world.dm @@ -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]" diff --git a/paradise.dme b/paradise.dme index 9342fc2b09f..63324d0208a 100644 --- a/paradise.dme +++ b/paradise.dme @@ -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"