From fff65f34ca9f8f0f0ff4aa3b1f9ef4e151d09015 Mon Sep 17 00:00:00 2001 From: Couls Date: Sat, 27 Apr 2019 20:42:31 -0400 Subject: [PATCH] Code cleanup time! --- code/__DEFINES/flags.dm | 2 -- code/__HELPERS/unique_ids.dm | 20 ++++++++++++-------- code/__HELPERS/unsorted.dm | 16 +--------------- code/datums/datum.dm | 6 ------ code/modules/keybindings/focus.dm | 9 --------- code/modules/keybindings/setup.dm | 2 +- code/modules/mob/dead/dead.dm | 2 -- 7 files changed, 14 insertions(+), 43 deletions(-) diff --git a/code/__DEFINES/flags.dm b/code/__DEFINES/flags.dm index a9a9531f294..f9ec58a217e 100644 --- a/code/__DEFINES/flags.dm +++ b/code/__DEFINES/flags.dm @@ -3,8 +3,6 @@ // for /datum/var/datum_flags #define DF_USE_TAG (1<<0) -#define DF_VAR_EDITED (1<<1) -#define DF_ISPROCESSING (1<<2) //FLAGS BITMASK #define STOPSPRESSUREDMAGE 1 //This flag is used on the flags variable for SUIT and HEAD items which stop pressure damage. Note that the flag 1 was previous used as ONBACK, so it is possible for some code to use (flags & 1) when checking if something can be put on your back. Replace this code with (inv_flags & SLOT_BACK) if you see it anywhere To successfully stop you taking all pressure damage you must have both a suit and head item with this flag. diff --git a/code/__HELPERS/unique_ids.dm b/code/__HELPERS/unique_ids.dm index 01a630f8051..c7db1b2e772 100644 --- a/code/__HELPERS/unique_ids.dm +++ b/code/__HELPERS/unique_ids.dm @@ -18,20 +18,24 @@ var/global/next_unique_datum_id = 1 // /client/var/tmp/unique_datum_id = null -/datum/proc/UID() - if(!unique_datum_id) +/datum/proc/UID(input) + if (input) + if(istype(input, /datum)) + var/datum/thing = input + if(thing.datum_flags & DF_USE_TAG) + if(!thing.tag) + stack_trace("A ref was requested of an object with DF_USE_TAG set but no tag: [thing]") + thing.datum_flags &= ~DF_USE_TAG + else + return "\[[url_encode(thing.tag)]\]" + return "\ref[input]" + else if(!unique_datum_id) var/tag_backup = tag tag = null // Grab the raw ref, not the tag unique_datum_id = "\ref[src]_[next_unique_datum_id++]" tag = tag_backup return unique_datum_id -/client/UID() - if(!unique_datum_id) - unique_datum_id = "\ref[src]_[next_unique_datum_id++]" - return unique_datum_id - - /proc/locateUID(uid) if(!istext(uid)) return null diff --git a/code/__HELPERS/unsorted.dm b/code/__HELPERS/unsorted.dm index 71e2dc25ab7..68c8850e932 100644 --- a/code/__HELPERS/unsorted.dm +++ b/code/__HELPERS/unsorted.dm @@ -2028,18 +2028,4 @@ var/mob/dview/dview_mob = new CRASH(msg) /proc/pass() - return - -// \ref behaviour got changed in 512 so this is necesary to replicate old behaviour. -// If it ever becomes necesary to get a more performant REF(), this lies here in wait -// #define REF(thing) (thing && istype(thing, /datum) && (thing:datum_flags & DF_USE_TAG) && thing:tag ? "[thing:tag]" : "\ref[thing]") -/proc/REF(input) - if(istype(input, /datum)) - var/datum/thing = input - if(thing.datum_flags & DF_USE_TAG) - if(!thing.tag) - stack_trace("A ref was requested of an object with DF_USE_TAG set but no tag: [thing]") - thing.datum_flags &= ~DF_USE_TAG - else - return "\[[url_encode(thing.tag)]\]" - return "\ref[input]" + return \ No newline at end of file diff --git a/code/datums/datum.dm b/code/datums/datum.dm index b9c8f193f3f..9b11e1c23d1 100644 --- a/code/datums/datum.dm +++ b/code/datums/datum.dm @@ -43,12 +43,6 @@ qdel(C, FALSE, TRUE) dc.Cut() - var/list/focusers = src.focusers - if(focusers) - for(var/i in 1 to focusers.len) - var/mob/M = focusers[i] - M.set_focus(M) - var/list/lookup = comp_lookup if(lookup) for(var/sig in lookup) diff --git a/code/modules/keybindings/focus.dm b/code/modules/keybindings/focus.dm index 567b30c323a..3466f36f877 100644 --- a/code/modules/keybindings/focus.dm +++ b/code/modules/keybindings/focus.dm @@ -8,14 +8,5 @@ /mob/proc/set_focus(datum/new_focus) if(focus == new_focus) return - - if(new_focus) - if(!new_focus.focusers) //Set up the new focus - new_focus.focusers = list() - new_focus.focusers += src - - if(focus) - focus.focusers -= src //Tell the old focus we're done with it - focus = new_focus reset_perspective(focus) //Maybe this should be done manually? You figure it out, reader \ No newline at end of file diff --git a/code/modules/keybindings/setup.dm b/code/modules/keybindings/setup.dm index c75cdd6cd0e..ba0f09fbf84 100644 --- a/code/modules/keybindings/setup.dm +++ b/code/modules/keybindings/setup.dm @@ -42,5 +42,5 @@ for(var/k in 1 to macro_set.len) var/key = macro_set[k] var/command = macro_set[key] - winset(src, "[setname]-[REF(key)]", "parent=[setname];name=[key];command=[command]") + winset(src, "[setname]-[UID(key)]", "parent=[setname];name=[key];command=[command]") winset(src, null, "input.focus=true input.background-color=[COLOR_INPUT_ENABLED] mainwindow.macro=default") diff --git a/code/modules/mob/dead/dead.dm b/code/modules/mob/dead/dead.dm index d8074424b28..5f7d140b174 100644 --- a/code/modules/mob/dead/dead.dm +++ b/code/modules/mob/dead/dead.dm @@ -20,5 +20,3 @@ for(var/datum/light_source/L in light_sources) L.source_atom.update_light() return 1 -/mob/dead/Initialize() - set_focus(src) \ No newline at end of file