U_I Phase 2.0: Code cleanup

Removing calls to update_icons_layers and the like, stubbing them to help track down future calls.
This commit is contained in:
Arokha Sieyes
2018-03-08 19:33:44 -05:00
parent 62e0c122fa
commit 53a185f838
41 changed files with 396 additions and 577 deletions
-7
View File
@@ -1001,11 +1001,6 @@
//strip their stuff and stick it in the crate
for(var/obj/item/I in M)
M.drop_from_inventory(I, locker)
if(ishuman(M))
var/mob/living/carbon/human/H = M
H.update_icons_layers() //Cheaper
else
M.update_icons()
//so they black out before warping
M.Paralyse(5)
@@ -1188,10 +1183,8 @@
usr << "This can only be used on instances of type /mob/living/carbon/human"
return
var/block=text2num(href_list["block"])
//testing("togmutate([href_list["block"]] -> [block])")
usr.client.cmd_admin_toggle_block(H,block)
show_player_panel(H)
//H.regenerate_icons()
else if(href_list["adminplayeropts"])
var/mob/M = locate(href_list["adminplayeropts"])
-1
View File
@@ -37,7 +37,6 @@
if(ishuman(usr))
var/mob/living/carbon/human/H = usr
H.name = H.get_visible_name()
// usr.regenerate_icons() //So the name is updated properly
usr.loc = O.loc // Appear where the object you were controlling is -- TLE
usr.client.eye = usr
+4 -4
View File
@@ -287,10 +287,10 @@ datum/preferences
if(icon_updates)
character.force_update_limbs()
character.update_mutations(0)
character.update_underwear(0)
character.update_hair(0)
character.update_icons_all()
character.update_icons_body()
character.update_mutations()
character.update_underwear()
character.update_hair()
/datum/preferences/proc/open_load_dialog(mob/user)
var/dat = "<body>"
@@ -265,6 +265,15 @@
return
..()
/obj/item/clothing/suit/straight_jacket/equipped(var/mob/living/user,var/slot)
. = ..()
if(slot == slot_wear_suit)
user.drop_l_hand()
user.drop_r_hand()
if(ishuman(user))
var/mob/living/carbon/human/H = user
H.drop_from_inventory(H.handcuffed)
/obj/item/clothing/suit/ianshirt
name = "worn shirt"
desc = "A worn out, curiously comfortable t-shirt with a picture of Ian. You wouldn't go so far as to say it feels like being hugged when you wear it but it's pretty close. Good for sleeping in."
-1
View File
@@ -247,7 +247,6 @@
var/mob/M = obj.loc
if(ismob(M))
M.remove_from_mob(obj)
M.update_icons_layers() //so their overlays update
if(!silent)
var/obj/oldobj = obj
@@ -103,7 +103,6 @@
if (ishuman(body))
var/mob/living/carbon/human/H = body
icon = H.icon
LAZYCLEARLIST(H.list_huds)
H.update_icons()
overlays = H.overlays
else
-2
View File
@@ -83,8 +83,6 @@ var/list/holder_mob_icon_cache = list()
H.update_inv_l_hand()
else if(H.r_hand == src)
H.update_inv_r_hand()
//else
//H.regenerate_icons() //Basically just too expensive. Probably also not necessary.
//Mob specific holders.
/obj/item/weapon/holder/diona
-1
View File
@@ -138,7 +138,6 @@ var/list/slot_equipment_priority = list( \
remove_from_mob(W, target)
if(!(W && W.loc))
return 1 // self destroying objects (tk, grabs)
update_icons_layers()
return 1
return 0
-2
View File
@@ -290,10 +290,8 @@
H.bloody_hands = 0
H.update_inv_gloves(0)
H.germ_level = 0
update_icons_layers(FALSE) //apply the now updated overlays to the mob
update_icons_body()
/mob/living/carbon/fire_act(datum/gas_mixture/air, exposed_temperature, exposed_volume)
..()
var/temp_inc = max(min(BODYTEMP_HEATING_MAX*(1-get_heat_protection()), exposed_temperature - bodytemperature), 0)
+3 -10
View File
@@ -5,7 +5,8 @@
icon = 'icons/effects/effects.dmi' //We have an ultra-complex update icons that overlays everything, don't load some stupid random male human
icon_state = "nothing"
var/list/hud_list[TOTAL_HUDS]
has_huds = TRUE //We do have HUDs (like health, wanted, status, not inventory slots)
var/embedded_flag //To check if we've need to roll for damage on movement while an item is imbedded in us.
var/obj/item/weapon/rig/wearing_rig // This is very not good, but it's much much better than calling get_rig() every update_canmove() call.
var/last_push_time //For human_attackhand.dm, keeps track of the last use of disarm
@@ -40,9 +41,8 @@
nutrition = rand(200,400)
make_hud_overlays()
human_mob_list |= src
..()
hide_underwear.Cut()
@@ -59,13 +59,6 @@
for(var/organ in organs)
qdel(organ)
LAZYCLEARLIST(list_layers)
list_layers = null //Be free!
LAZYCLEARLIST(list_body)
list_body = null
LAZYCLEARLIST(list_huds)
list_huds = null
return ..()
/mob/living/carbon/human/Stat()
@@ -102,8 +102,6 @@
can_be_antagged = TRUE
var/has_huds = TRUE //Do they have all the fancy life huds? Not for mannequins.
// Used by mobs in virtual reality to point back to the "real" mob the client belongs to.
var/mob/living/carbon/human/vr_holder = null
// Used by "real" mobs after they leave a VR session
@@ -108,7 +108,7 @@
return FBP_NONE
/mob/living/carbon/human/proc/make_hud_overlays()
/mob/living/carbon/human/make_hud_overlays()
hud_list[HEALTH_HUD] = gen_hud_image(ingame_hud_med, src, "100", plane = PLANE_CH_HEALTH)
if(isSynthetic())
hud_list[STATUS_HUD] = gen_hud_image(ingame_hud, src, "hudrobo", plane = PLANE_CH_STATUS)
@@ -2,7 +2,8 @@
var/obj/item/organ/internal/eyes/eyes = internal_organs_by_name[O_EYES]
if(eyes)
eyes.update_colour()
regenerate_icons()
update_icons_body() //Body handles eyes
update_eyes() //For floating eyes only
/mob/living/carbon/var/list/internal_organs = list()
/mob/living/carbon/human/var/list/organs = list()
@@ -152,12 +152,14 @@ This saves us from having to call add_fingerprint() any time something is put in
else if (W == wear_id)
wear_id = null
update_inv_wear_id()
BITSET(hud_updateflag, ID_HUD)
BITSET(hud_updateflag, WANTED_HUD)
else if (W == r_store)
r_store = null
update_inv_pockets()
//update_inv_pockets() //Doesn't do anything.
else if (W == l_store)
l_store = null
update_inv_pockets()
//update_inv_pockets() //Doesn't do anything.
else if (W == s_store)
s_store = null
update_inv_s_store()
@@ -195,8 +197,7 @@ This saves us from having to call add_fingerprint() any time something is put in
//This is an UNSAFE proc. Use mob_can_equip() before calling this one! Or rather use equip_to_slot_if_possible() or advanced_equip_to_slot_if_possible()
//set redraw_mob to 0 if you don't wish the hud to be updated - if you're doing it manually in your own proc.
/mob/living/carbon/human/equip_to_slot(obj/item/W as obj, slot, redraw_mob = 1)
/mob/living/carbon/human/equip_to_slot(obj/item/W as obj, slot)
if(!slot)
return
@@ -213,39 +214,41 @@ This saves us from having to call add_fingerprint() any time something is put in
src.back = W
W.equipped(src, slot)
worn_clothing += back
update_inv_back(redraw_mob)
update_inv_back()
if(slot_wear_mask)
src.wear_mask = W
if(wear_mask.flags_inv & (BLOCKHAIR|BLOCKHEADHAIR))
update_hair(redraw_mob) //rebuild hair
update_inv_ears(0)
update_hair() //rebuild hair
update_inv_ears()
W.equipped(src, slot)
worn_clothing += wear_mask
update_inv_wear_mask(redraw_mob)
update_inv_wear_mask()
if(slot_handcuffed)
src.handcuffed = W
update_inv_handcuffed(redraw_mob)
update_inv_handcuffed()
if(slot_legcuffed)
src.legcuffed = W
W.equipped(src, slot)
update_inv_legcuffed(redraw_mob)
update_inv_legcuffed()
if(slot_l_hand)
src.l_hand = W
W.equipped(src, slot)
update_inv_l_hand(redraw_mob)
update_inv_l_hand()
if(slot_r_hand)
src.r_hand = W
W.equipped(src, slot)
update_inv_r_hand(redraw_mob)
update_inv_r_hand()
if(slot_belt)
src.belt = W
W.equipped(src, slot)
worn_clothing += belt
update_inv_belt(redraw_mob)
update_inv_belt()
if(slot_wear_id)
src.wear_id = W
W.equipped(src, slot)
update_inv_wear_id(redraw_mob)
update_inv_wear_id()
BITSET(hud_updateflag, ID_HUD)
BITSET(hud_updateflag, WANTED_HUD)
if(slot_l_ear)
src.l_ear = W
if(l_ear.slot_flags & SLOT_TWOEARS)
@@ -254,7 +257,7 @@ This saves us from having to call add_fingerprint() any time something is put in
src.r_ear = O
O.hud_layerise()
W.equipped(src, slot)
update_inv_ears(redraw_mob)
update_inv_ears()
if(slot_r_ear)
src.r_ear = W
if(r_ear.slot_flags & SLOT_TWOEARS)
@@ -263,54 +266,54 @@ This saves us from having to call add_fingerprint() any time something is put in
src.l_ear = O
O.hud_layerise()
W.equipped(src, slot)
update_inv_ears(redraw_mob)
update_inv_ears()
if(slot_glasses)
src.glasses = W
W.equipped(src, slot)
update_inv_glasses(redraw_mob)
update_inv_glasses()
if(slot_gloves)
src.gloves = W
W.equipped(src, slot)
worn_clothing += glasses
update_inv_gloves(redraw_mob)
update_inv_gloves()
if(slot_head)
src.head = W
if(head.flags_inv & (BLOCKHAIR|BLOCKHEADHAIR|HIDEMASK))
update_hair(redraw_mob) //rebuild hair
update_hair() //rebuild hair
update_inv_ears(0)
update_inv_wear_mask(0)
if(istype(W,/obj/item/clothing/head/kitty))
W.update_icon(src)
W.equipped(src, slot)
worn_clothing += head
update_inv_head(redraw_mob)
update_inv_head()
if(slot_shoes)
src.shoes = W
W.equipped(src, slot)
worn_clothing += shoes
update_inv_shoes(redraw_mob)
update_inv_shoes()
if(slot_wear_suit)
src.wear_suit = W
W.equipped(src, slot)
worn_clothing += wear_suit
update_inv_wear_suit(redraw_mob)
update_inv_wear_suit()
if(slot_w_uniform)
src.w_uniform = W
W.equipped(src, slot)
worn_clothing += w_uniform
update_inv_w_uniform(redraw_mob)
update_inv_w_uniform()
if(slot_l_store)
src.l_store = W
W.equipped(src, slot)
update_inv_pockets(redraw_mob)
//update_inv_pockets() //Doesn't do anything
if(slot_r_store)
src.r_store = W
W.equipped(src, slot)
update_inv_pockets(redraw_mob)
//update_inv_pockets() //Doesn't do anything
if(slot_s_store)
src.s_store = W
W.equipped(src, slot)
update_inv_s_store(redraw_mob)
update_inv_s_store()
if(slot_in_backpack)
if(src.get_active_hand() == W)
src.remove_from_mob(W)
+22 -24
View File
@@ -1582,26 +1582,24 @@
we only set those statuses and icons upon changes. Then those HUD items will simply add those pre-made images.
This proc below is only called when those HUD elements need to change as determined by the mobs hud_updateflag.
*/
/mob/living/carbon/human/proc/handle_hud_list()
if (BITTEST(hud_updateflag, HEALTH_HUD))
var/image/holder = hud_list[HEALTH_HUD]
var/image/holder = grab_hud(HEALTH_HUD)
if(stat == DEAD)
holder.icon_state = "-100" // X_X
else
holder.icon_state = RoundHealth((health-config.health_threshold_crit)/(getMaxHealth()-config.health_threshold_crit)*100)
hud_list[HEALTH_HUD] = holder
apply_hud(HEALTH_HUD, holder)
if (BITTEST(hud_updateflag, LIFE_HUD))
var/image/holder = hud_list[LIFE_HUD]
var/image/holder = grab_hud(LIFE_HUD)
if(isSynthetic())
holder.icon_state = "hudrobo"
else if(stat == DEAD)
holder.icon_state = "huddead"
else
holder.icon_state = "hudhealthy"
hud_list[LIFE_HUD] = holder
apply_hud(LIFE_HUD, holder)
if (BITTEST(hud_updateflag, STATUS_HUD))
var/foundVirus = 0
@@ -1610,8 +1608,8 @@
foundVirus = 1
break
var/image/holder = hud_list[STATUS_HUD]
var/image/holder2 = hud_list[STATUS_HUD_OOC]
var/image/holder = grab_hud(STATUS_HUD)
var/image/holder2 = grab_hud(STATUS_HUD_OOC)
if (isSynthetic())
holder.icon_state = "hudrobo"
else if(stat == DEAD)
@@ -1633,11 +1631,11 @@
else
holder2.icon_state = "hudhealthy"
hud_list[STATUS_HUD] = holder
hud_list[STATUS_HUD_OOC] = holder2
apply_hud(STATUS_HUD, holder)
apply_hud(STATUS_HUD_OOC, holder2)
if (BITTEST(hud_updateflag, ID_HUD))
var/image/holder = hud_list[ID_HUD]
var/image/holder = grab_hud(ID_HUD)
if(wear_id)
var/obj/item/weapon/card/id/I = wear_id.GetID()
if(I)
@@ -1647,11 +1645,10 @@
else
holder.icon_state = "hudunknown"
hud_list[ID_HUD] = holder
apply_hud(ID_HUD, holder)
if (BITTEST(hud_updateflag, WANTED_HUD))
var/image/holder = hud_list[WANTED_HUD]
var/image/holder = grab_hud(WANTED_HUD)
holder.icon_state = "hudblank"
var/perpname = name
if(wear_id)
@@ -1674,15 +1671,16 @@
else if((R.fields["id"] == E.fields["id"]) && (R.fields["criminal"] == "Released"))
holder.icon_state = "hudreleased"
break
hud_list[WANTED_HUD] = holder
apply_hud(WANTED_HUD, holder)
if ( BITTEST(hud_updateflag, IMPLOYAL_HUD) \
|| BITTEST(hud_updateflag, IMPCHEM_HUD) \
|| BITTEST(hud_updateflag, IMPTRACK_HUD))
var/image/holder1 = hud_list[IMPTRACK_HUD]
var/image/holder2 = hud_list[IMPLOYAL_HUD]
var/image/holder3 = hud_list[IMPCHEM_HUD]
var/image/holder1 = grab_hud(IMPTRACK_HUD)
var/image/holder2 = grab_hud(IMPLOYAL_HUD)
var/image/holder3 = grab_hud(IMPCHEM_HUD)
holder1.icon_state = "hudblank"
holder2.icon_state = "hudblank"
@@ -1698,21 +1696,21 @@
if(istype(I,/obj/item/weapon/implant/chem))
holder3.icon_state = "hud_imp_chem"
hud_list[IMPTRACK_HUD] = holder1
hud_list[IMPLOYAL_HUD] = holder2
hud_list[IMPCHEM_HUD] = holder3
apply_hud(IMPTRACK_HUD, holder1)
apply_hud(IMPLOYAL_HUD, holder2)
apply_hud(IMPCHEM_HUD, holder3)
if (BITTEST(hud_updateflag, SPECIALROLE_HUD))
var/image/holder = hud_list[SPECIALROLE_HUD]
var/image/holder = grab_hud(SPECIALROLE_HUD)
holder.icon_state = "hudblank"
if(mind && mind.special_role)
if(hud_icon_reference[mind.special_role])
holder.icon_state = hud_icon_reference[mind.special_role]
else
holder.icon_state = "hudsyndicate"
hud_list[SPECIALROLE_HUD] = holder
apply_hud(SPECIALROLE_HUD, holder)
hud_updateflag = 0
update_icons_huds()
/mob/living/carbon/human/handle_stunned()
if(!can_feel_pain())
File diff suppressed because it is too large Load Diff
+4 -4
View File
@@ -72,16 +72,16 @@
/mob/living/u_equip(obj/W as obj)
if (W == r_hand)
r_hand = null
update_inv_r_hand(0)
update_inv_r_hand()
else if (W == l_hand)
l_hand = null
update_inv_l_hand(0)
update_inv_l_hand()
else if (W == back)
back = null
update_inv_back(0)
update_inv_back()
else if (W == wear_mask)
wear_mask = null
update_inv_wear_mask(0)
update_inv_wear_mask()
return
/mob/living/get_equipped_item(var/slot)
+28
View File
@@ -1,6 +1,13 @@
/mob/living/New()
..()
//Prime this list if we need it.
if(has_huds)
add_overlay(backplane,TRUE) //Strap this on here, to block HUDs from appearing in rightclick menus: http://www.byond.com/forum/?post=2336679
hud_list = list()
hud_list.len = TOTAL_HUDS
make_hud_overlays()
//I'll just hang my coat up over here
dsoverlay = image('icons/mob/darksight.dmi',global_hud.darksight) //This is a secret overlay! Go look at the file, you'll see.
var/mutable_appearance/dsma = new(dsoverlay) //Changing like ten things, might as well.
@@ -855,6 +862,7 @@ default behaviour is:
resting = !resting
to_chat(src, "<span class='notice'>You are now [resting ? "resting" : "getting up"]</span>")
update_canmove()
/mob/living/proc/cannot_use_vents()
if(mob_size > MOB_SMALL)
@@ -1003,6 +1011,7 @@ default behaviour is:
break
if(lying != lying_prev)
lying_prev = lying
update_transform()
return canmove
@@ -1157,3 +1166,22 @@ default behaviour is:
item.throw_at(target, throw_range, item.throw_speed, src)
//Add an entry to overlays, assuming it exists
/mob/living/proc/apply_hud(cache_index, var/image/I)
hud_list[cache_index] = I
if((. = hud_list[cache_index]))
//underlays += .
add_overlay(.)
//Remove an entry from overlays, and from the list
/mob/living/proc/grab_hud(cache_index)
var/I = hud_list[cache_index]
if(I)
//underlays -= I
cut_overlay(I)
hud_list[cache_index] = null
return I
/mob/living/proc/make_hud_overlays()
return
@@ -54,3 +54,6 @@
var/glow_range = 2
var/glow_intensity = null
var/glow_color = "#FFFFFF" // The color they're glowing!
var/list/hud_list //Holder for health hud, status hud, wanted hud, etc (not like inventory slots)
var/has_huds = FALSE //Whether or not we should bother initializing the above list
+1 -1
View File
@@ -7,7 +7,7 @@
var/list/stating_laws = list()// Channels laws are currently being stated on
var/obj/item/device/radio/common_radio
var/list/hud_list[10]
has_huds = TRUE
var/list/speech_synthesizer_langs = list() //which languages can be vocalized by the speech synthesizer
//Used in say.dm.
@@ -12,6 +12,7 @@
var/list/adding = list()
var/list/other = list()
var/list/hotkeybuttons = list()
var/list/slot_info = list()
hud.adding = adding
hud.other = other
@@ -34,6 +35,7 @@
inv_box.screen_loc = slot_data["loc"]
inv_box.slot_id = slot_data["slot"]
inv_box.icon_state = slot_data["state"]
slot_info["[inv_box.slot_id]"] = inv_box.screen_loc
if(slot_data["dir"])
inv_box.set_dir(slot_data["dir"])
@@ -249,9 +251,9 @@
inv_box.slot_id = slot_r_hand
inv_box.color = ui_color
inv_box.alpha = ui_alpha
hud.r_hand_hud_object = inv_box
hud.adding += inv_box
slot_info["[slot_r_hand]"] = inv_box.screen_loc
inv_box = new /obj/screen/inventory/hand()
inv_box.hud = src
@@ -266,6 +268,7 @@
inv_box.alpha = ui_alpha
hud.l_hand_hud_object = inv_box
hud.adding += inv_box
slot_info["[slot_l_hand]"] = inv_box.screen_loc
//Swaphand titlebar
using = new /obj/screen/inventory()
+3
View File
@@ -858,14 +858,17 @@
/mob/proc/Resting(amount)
facing_dir = null
resting = max(max(resting,amount),0)
update_canmove()
return
/mob/proc/SetResting(amount)
resting = max(amount,0)
update_canmove()
return
/mob/proc/AdjustResting(amount)
resting = max(resting + amount,0)
update_canmove()
return
/mob/proc/AdjustLosebreath(amount)
+22 -1
View File
@@ -624,7 +624,28 @@ var/global/image/backplane
backplane = image('icons/misc/win32.dmi')
backplane.alpha = 0
backplane.plane = -100
backplane.layer = BACKPLANE_LAYER
backplane.layer = MOB_LAYER-0.01
backplane.mouse_opacity = 0
return TRUE
/mob/proc/position_hud_item(var/obj/item/item, var/slot)
if(!istype(hud_used) || !slot || !LAZYLEN(hud_used.slot_info))
return
//They may have hidden their entire hud but the hands
if(!hud_used.hud_shown && slot > slot_r_hand)
item.screen_loc = null
return
//They may have hidden the icons in the bottom left with the hide button
if(!hud_used.inventory_shown && slot > slot_r_store)
item.screen_loc = null
return
var/screen_place = hud_used.slot_info["[slot]"]
if(!screen_place)
item.screen_loc = null
return
item.screen_loc = screen_place
@@ -247,8 +247,6 @@
mannequin.job = previewJob.title
previewJob.equip_preview(mannequin, player_alt_titles[previewJob.title])
mannequin.regenerate_icons()
/datum/preferences/proc/update_preview_icon()
var/mob/living/carbon/human/dummy/mannequin/mannequin = get_mannequin(client_ckey)
mannequin.delete_inventory(TRUE)
@@ -266,4 +264,4 @@
stamp = getFlatIcon(mannequin, defdir=SOUTH)
preview_icon.Blend(stamp, ICON_OVERLAY, 49, 1)
preview_icon.Scale(preview_icon.Width() * 2, preview_icon.Height() * 2) // Scaling here to prevent blurring in the browser.
preview_icon.Scale(preview_icon.Width() * 2, preview_icon.Height() * 2) // Scaling here to prevent blurring in the browser.
+10 -15
View File
@@ -1,31 +1,26 @@
//Most of these are defined at this level to reduce on checks elsewhere in the code.
//Having them here also makes for a nice reference list of the various overlay-updating procs available
/mob/proc/regenerate_icons() //TODO: phase this out completely if possible
/mob/proc/regenerate_icons() //Update every aspect of the mob's icons (expensive, resist the urge to use unless you need it)
return
/mob/proc/update_icons()
update_icon() //Ugh.
return
/mob/proc/update_icons_layers(var/update_icons = TRUE)
if(update_icons)
update_icons()
// Obsolete
/mob/proc/update_icons_layers()
return
/mob/proc/update_icons_huds(var/update_icons = TRUE)
if(update_icons)
update_icons()
/mob/proc/update_icons_huds()
return
/mob/proc/update_icons_body(var/update_icons = TRUE)
if(update_icons)
update_icons()
/mob/proc/update_icons_body()
return
/mob/proc/update_icons_all()
update_icons_huds(FALSE)
update_icons_body(FALSE)
update_icons_layers(FALSE)
update_icons()
return
// End obsolete
/mob/proc/update_hud()
return
+1 -1
View File
@@ -873,7 +873,7 @@ Note that amputating the affected organ does in fact remove the infection from t
spawn(1)
victim.updatehealth()
victim.UpdateDamageIcon()
victim.regenerate_icons()
victim.update_icons_body()
dir = 2
switch(disintegrate)
+2 -2
View File
@@ -499,13 +499,13 @@
B.loc = h_user
B.hud_layerise()
h_user.l_store = B
h_user.update_inv_pockets()
//h_user.update_inv_pockets() //Doesn't do anything
else if (h_user.r_store == src)
h_user.drop_from_inventory(src)
B.loc = h_user
B.hud_layerise()
h_user.r_store = B
h_user.update_inv_pockets()
//h_user.update_inv_pockets() //Doesn't do anything
else if (h_user.head == src)
h_user.u_equip(src)
h_user.put_in_hands(B)