From 8d7e638f6eeb92ea0889c72fb41dd733f80ea718 Mon Sep 17 00:00:00 2001 From: Krausus Date: Tue, 28 Jun 2016 11:34:54 -0400 Subject: [PATCH] Improved to_chat debug message (#4795) Also fixed a couple related, minor bugs --- code/_compile_options.dm | 3 +++ code/game/gamemodes/nuclear/nuclearbomb.dm | 4 +++- code/game/objects/items/toys.dm | 5 +++-- goon/code/datums/browserOutput.dm | 11 ++++++++--- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/code/_compile_options.dm b/code/_compile_options.dm index cac93fdbaf6..5e9d9462d7f 100644 --- a/code/_compile_options.dm +++ b/code/_compile_options.dm @@ -20,3 +20,6 @@ This may require updating to a beta release. #endif var/global/list/processing_objects = list() //This has to be initialized BEFORE world + +// Macros that must exist before world.dm +#define to_chat to_chat_filename=__FILE__;to_chat_line=__LINE__;to_chat_src=src;__to_chat diff --git a/code/game/gamemodes/nuclear/nuclearbomb.dm b/code/game/gamemodes/nuclear/nuclearbomb.dm index 85e6967f180..7b57764da16 100644 --- a/code/game/gamemodes/nuclear/nuclearbomb.dm +++ b/code/game/gamemodes/nuclear/nuclearbomb.dm @@ -402,7 +402,9 @@ var/bomb_set /obj/item/weapon/disk/nuclear/process() var/turf/disk_loc = get_turf(src) if(disk_loc.z != ZLEVEL_STATION && disk_loc.z != ZLEVEL_CENTCOMM) - to_chat(get(src, /mob), "You can't help but feel that you just lost something back there...") + var/holder = get(src, /mob) + if(holder) + to_chat(holder, "You can't help but feel that you just lost something back there...") qdel(src) /obj/item/weapon/disk/nuclear/Destroy() diff --git a/code/game/objects/items/toys.dm b/code/game/objects/items/toys.dm index 6907ea08671..6c0cf78de6e 100644 --- a/code/game/objects/items/toys.dm +++ b/code/game/objects/items/toys.dm @@ -531,11 +531,12 @@ obj/item/toy/cards/deck/MouseDrop(atom/over_object) if(!remove_item_from_storage(M)) M.unEquip(src) M.put_in_l_hand(src) - else if("r_hand") + to_chat(usr, "You pick up the deck.") + if("r_hand") if(!remove_item_from_storage(M)) M.unEquip(src) M.put_in_r_hand(src) - to_chat(usr, "You pick up the deck.") + to_chat(usr, "You pick up the deck.") else to_chat(usr, "You can't reach it from here.") diff --git a/goon/code/datums/browserOutput.dm b/goon/code/datums/browserOutput.dm index ff873789940..67d9507187a 100644 --- a/goon/code/datums/browserOutput.dm +++ b/goon/code/datums/browserOutput.dm @@ -197,11 +197,16 @@ var/list/chatResources = list( /proc/bi(obj) bicon(obj) -/proc/to_chat(target, message) +var/to_chat_filename +var/to_chat_line +var/to_chat_src +// Call using macro: to_chat(target, message) +/proc/__to_chat(target, message) if(istype(message, /image) || istype(message, /sound) || istype(target, /savefile) || !(ismob(target) || islist(target) || isclient(target) || target == world)) target << message - if (!isatom(target)) // Really easy to mix these up, and not having to make sure things are mobs makes the code cleaner. - CRASH("DEBUG: to_chat called with invalid message") + if(!istext(message)) + message = "(non-text type)" + world.Error(new/exception("DEBUG: to_chat called with invalid message: [message]", to_chat_filename, to_chat_line), e_src = to_chat_src) return else if(istext(message))