From 143016dd0740dd171ca2bf4a1d793b17c39f311d Mon Sep 17 00:00:00 2001 From: Ccomp5950 Date: Sun, 9 Mar 2014 10:25:36 -0500 Subject: [PATCH] Code effeciency project: HUD items rewrite Before: Every tick each HUD item would recalculate and redo images for every mob in view. For items like the secHUD where we're transversing implants and the various records this gets very expensive. After: Mobs use their hud_list variable to store varius huditem images, when conditions change for those specific huditem images it updates the specific ones on demand. As a backup every 30 ticks or so the mob will update all of their hud_list. Also: moved proc/RoundHealth() from 2 seperate locations into __HELPERS/mobs.dm Conflicts: code/modules/mob/living/living.dm Conflicts: code/__HELPERS/mobs.dm code/datums/mind.dm code/game/objects/items/weapons/implants/implanter.dm code/modules/mob/dead/observer/observer.dm code/modules/mob/living/carbon/human/human.dm code/modules/mob/living/carbon/human/life.dm code/modules/mob/living/living.dm code/modules/mob/living/living_defines.dm code/modules/mob/living/silicon/ai/ai.dm code/modules/mob/living/silicon/silicon.dm code/modules/virus2/helpers.dm code/setup.dm icons/mob/hud.dmi --- code/__HELPERS/mobs.dm | 2 ++ .../items/weapons/implants/implanter.dm | 1 - code/modules/mob/dead/observer/observer.dm | 1 - code/modules/mob/living/carbon/human/human.dm | 1 - code/modules/mob/living/carbon/human/life.dm | 5 +++-- code/modules/mob/living/living.dm | 7 +++---- .../modules/mob/living/silicon/robot/robot.dm | 12 ++++++++++++ code/modules/mob/living/silicon/silicon.dm | 1 + code/modules/virus2/helpers.dm | 12 ++++++++---- code/setup.dm | 11 +++++------ icons/mob/hud.dmi | Bin 3184 -> 3189 bytes 11 files changed, 34 insertions(+), 19 deletions(-) diff --git a/code/__HELPERS/mobs.dm b/code/__HELPERS/mobs.dm index 9aa28fbabb2..84ee98948d2 100644 --- a/code/__HELPERS/mobs.dm +++ b/code/__HELPERS/mobs.dm @@ -98,6 +98,7 @@ proc/RoundHealth(health) return "health-100" return "0" + /* Proc for attack log creation, because really why not 1 argument is the actor @@ -116,3 +117,4 @@ proc/add_logs(mob/target, mob/user, what_done, var/object=null, var/addition=nul if(target.client) if(what_done != ("shaked" || "CPRed" || "grabbed")) message_admins("[user.name][ismob(user) ? "([user.ckey])" : ""] [what_done] [target.name][ismob(target) ? "([target.ckey])" : ""][object ? " with [object]" : " "][addition](JMP)") + diff --git a/code/game/objects/items/weapons/implants/implanter.dm b/code/game/objects/items/weapons/implants/implanter.dm index ff4cb1050cd..1576ac80458 100644 --- a/code/game/objects/items/weapons/implants/implanter.dm +++ b/code/game/objects/items/weapons/implants/implanter.dm @@ -51,7 +51,6 @@ src.imp = null update() - return /obj/item/weapon/implanter/traitor diff --git a/code/modules/mob/dead/observer/observer.dm b/code/modules/mob/dead/observer/observer.dm index 21554782bab..7b5e1b08241 100644 --- a/code/modules/mob/dead/observer/observer.dm +++ b/code/modules/mob/dead/observer/observer.dm @@ -94,7 +94,6 @@ Works together with spawning an observer, noted above. for(var/image/hud in client.images) if(copytext(hud.icon_state,1,4) == "hud") client.images.Remove(hud) - if(antagHUD) var/list/target_list = list() for(var/mob/living/target in oview(src, 14)) diff --git a/code/modules/mob/living/carbon/human/human.dm b/code/modules/mob/living/carbon/human/human.dm index 73f0f7e2ec9..cbf990accdc 100644 --- a/code/modules/mob/living/carbon/human/human.dm +++ b/code/modules/mob/living/carbon/human/human.dm @@ -90,7 +90,6 @@ hud_list[SPECIALROLE_HUD] = image('icons/mob/hud.dmi', src, "hudblank") hud_list[STATUS_HUD_OOC] = image('icons/mob/hud.dmi', src, "hudhealthy") - ..() if(dna) diff --git a/code/modules/mob/living/carbon/human/life.dm b/code/modules/mob/living/carbon/human/life.dm index 4903375e81e..2995654b329 100644 --- a/code/modules/mob/living/carbon/human/life.dm +++ b/code/modules/mob/living/carbon/human/life.dm @@ -1263,7 +1263,6 @@ if(hud_updateflag) handle_hud_list() - for(var/image/hud in client.images) if(copytext(hud.icon_state,1,4) == "hud") //ugly, but icon comparison is worse, I believe client.images.Remove(hud) @@ -1734,6 +1733,9 @@ makeSkeleton() return //No puking over skeletons, they don't smell at all! +// if(loc == /obj/structure/morgue) +// return + for(var/mob/living/carbon/human/H in range(decaylevel, src)) if(prob(5)) if(airborne_can_reach(get_turf(src), get_turf(H))) @@ -1817,7 +1819,6 @@ var/obj/item/weapon/card/id/I = wear_id.GetID() if(I) perpname = I.registered_name - for(var/datum/data/record/E in data_core.general) if(E.fields["name"] == perpname) for (var/datum/data/record/R in data_core.security) diff --git a/code/modules/mob/living/living.dm b/code/modules/mob/living/living.dm index c61446d6f92..2381f9741a8 100644 --- a/code/modules/mob/living/living.dm +++ b/code/modules/mob/living/living.dm @@ -273,7 +273,7 @@ /mob/living/proc/restore_all_organs() return - + /mob/living/proc/revive() rejuvenate() buckled = initial(src.buckled) @@ -318,12 +318,12 @@ if(iscarbon(src)) var/mob/living/carbon/C = src C.handcuffed = initial(C.handcuffed) - + // restore all of the human's blood if(ishuman(src)) var/mob/living/carbon/human/human_mob = src human_mob.restore_blood() - + for(var/datum/disease/D in viruses) D.cure(0) restore_all_organs() @@ -335,7 +335,6 @@ regenerate_icons() hud_updateflag |= 1 << HEALTH_HUD hud_updateflag |= 1 << STATUS_HUD - ..() return /mob/living/proc/UpdateDamageIcon() diff --git a/code/modules/mob/living/silicon/robot/robot.dm b/code/modules/mob/living/silicon/robot/robot.dm index 290b9f914d2..d4fb5431fa7 100644 --- a/code/modules/mob/living/silicon/robot/robot.dm +++ b/code/modules/mob/living/silicon/robot/robot.dm @@ -142,6 +142,18 @@ var/datum/robot_component/cell_component = components["power cell"] cell_component.wrapped = cell cell_component.installed = 1 + + hud_list[HEALTH_HUD] = image('icons/mob/hud.dmi', src, "hudblank") + hud_list[STATUS_HUD] = image('icons/mob/hud.dmi', src, "hudhealth100") + hud_list[ID_HUD] = image('icons/mob/hud.dmi', src, "hudblank") + hud_list[WANTED_HUD] = image('icons/mob/hud.dmi', src, "hudblank") + hud_list[IMPLOYAL_HUD] = image('icons/mob/hud.dmi', src, "hudblank") + hud_list[IMPCHEM_HUD] = image('icons/mob/hud.dmi', src, "hudblank") + hud_list[IMPTRACK_HUD] = image('icons/mob/hud.dmi', src, "hudblank") + hud_list[SPECIALROLE_HUD] = image('icons/mob/hud.dmi', src, "hudblank") + + + hud_list[HEALTH_HUD] = image('icons/mob/hud.dmi', src, "hudblank") hud_list[STATUS_HUD] = image('icons/mob/hud.dmi', src, "hudhealth100") diff --git a/code/modules/mob/living/silicon/silicon.dm b/code/modules/mob/living/silicon/silicon.dm index d0ff49d0a50..e07a1975004 100644 --- a/code/modules/mob/living/silicon/silicon.dm +++ b/code/modules/mob/living/silicon/silicon.dm @@ -220,3 +220,4 @@ now_pushing = null + diff --git a/code/modules/virus2/helpers.dm b/code/modules/virus2/helpers.dm index 68bfe215f8d..9fb9792a8c0 100644 --- a/code/modules/virus2/helpers.dm +++ b/code/modules/virus2/helpers.dm @@ -88,21 +88,25 @@ proc/airborne_can_reach(turf/source, turf/target, var/radius=5) D.minormutate() M.virus2["[D.uniqueID]"] = D M.hud_updateflag |= 1 << STATUS_HUD - return 1 - return 0 //Infects mob M with random lesser disease, if he doesn't have one /proc/infect_mob_random_lesser(var/mob/living/carbon/M) var/datum/disease2/disease/D = new /datum/disease2/disease D.makerandom() D.infectionchance = 1 - infect_virus2(M,D,1) + M.virus2["[D.uniqueID]"] = D + M.hud_updateflag |= 1 << STATUS_HUD //Infects mob M with random greated disease, if he doesn't have one /proc/infect_mob_random_greater(var/mob/living/carbon/M) var/datum/disease2/disease/D = new /datum/disease2/disease D.makerandom(1) - infect_virus2(M,D,1) + M.virus2["[D.uniqueID]"] = D + M.hud_updateflag |= 1 << STATUS_HUD + +//Fancy prob() function. +/proc/dprob(var/p) + return(prob(sqrt(p)) && prob(sqrt(p))) /mob/living/carbon/proc/spread_disease_to(var/mob/living/carbon/victim, var/vector = "Airborne") if (src == victim) diff --git a/code/setup.dm b/code/setup.dm index 9a3ebb21f65..2da555207a8 100644 --- a/code/setup.dm +++ b/code/setup.dm @@ -733,12 +733,12 @@ var/list/be_special_flags = list( #define RIGHT 2 // for secHUDs and medHUDs and variants. The number is the location of the image on the list hud_list of humans. -#define HEALTH_HUD 1 // a simple line rounding the mob's number health -#define STATUS_HUD 2 // alive, dead, diseased, etc. -#define ID_HUD 3 // the job asigned to your ID -#define WANTED_HUD 4 // wanted, released, parroled, security status +#define HEALTH_HUD 1 // a simple line rounding the mob's number health +#define STATUS_HUD 2 // alive, dead, diseased, etc. +#define ID_HUD 3 // the job asigned to your ID +#define WANTED_HUD 4 // wanted, released, parroled, security status #define IMPLOYAL_HUD 5 // loyality implant -#define IMPCHEM_HUD 6 // chemical implant +#define IMPCHEM_HUD 6 // chemical implant #define IMPTRACK_HUD 7 // tracking implant #define SPECIALROLE_HUD 8 // AntagHUD image #define STATUS_HUD_OOC 9 // STATUS_HUD without virus db check for someone being ill. @@ -844,4 +844,3 @@ var/list/RESTRICTED_CAMERA_NETWORKS = list( //Those networks can only be accesse #define COLOR_YELLOW "#FFFF00" #define COLOR_ORANGE "#FF9900" #define COLOR_WHITE "#FFFFFF" - diff --git a/icons/mob/hud.dmi b/icons/mob/hud.dmi index ffef4bf299c8ff8c12d18114e864406ae109f24b..7c38405e232e28458f19d1ded6a07cb5089db304 100644 GIT binary patch delta 589 zcmV-T0?X?@yrWtnGWoS|Ku)adTNVLU9mRw3s<~{x7 zqy@U6L4Vz3+KS}9w@$>%S@o91Q>v6tkO%lW6$Kv+uay~nV&8~c`Zss$`(z<;5 zNSQL1;e{KlWAfRJ7xS4FP37nHeAXy+d>X$;#d`#^OcvpObBG9cvhaGjf5hSM73{YP z_O^n(S=TsM!Q$wdRf`%ddm77deYO5z-WTw&4-_&(vF=q;46F!isLvz;bkoMBFRG6r zFr-f7gc}a61jfu!PE2ZC0omk;xiD?gu@yr;HjNl;tCxW^vv!m+HsR!dVl${@D2I*X zPEtnDWQ0QoVU63E#eno)e>D2of^^G)@wH!%-9|K6l)IRE$0{bXaiQ!)kou-^skSv@ zN{*V`3783Qfvu2`<>Et@J!AQ+mLXS5a4CQR@Um4>@C-d2MzAb6>OEK&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