diff --git a/code/__defines/dcs/signals.dm b/code/__defines/dcs/signals.dm index 26b1d2d44a..017c92c922 100644 --- a/code/__defines/dcs/signals.dm +++ b/code/__defines/dcs/signals.dm @@ -80,6 +80,8 @@ #define COMSIG_ATOM_UPDATED_ICON "atom_updated_icon" ///from base of atom/Entered(): (atom/movable/entering, /atom) #define COMSIG_ATOM_ENTERED "atom_entered" +/// Sent from the atom that just Entered src. From base of atom/Entered(): (/atom/entered_atom, /atom/oldLoc) +#define COMSIG_ATOM_ENTERING "atom_entering" ///from base of atom/Exit(): (/atom/movable/exiting, /atom/newloc) #define COMSIG_ATOM_EXIT "atom_exit" #define COMPONENT_ATOM_BLOCK_EXIT (1<<0) diff --git a/code/datums/components/resize_guard.dm b/code/datums/components/resize_guard.dm new file mode 100644 index 0000000000..724d252443 --- /dev/null +++ b/code/datums/components/resize_guard.dm @@ -0,0 +1,19 @@ +/datum/component/resize_guard + +/datum/component/resize_guard/Initialize() + if(!isliving(parent)) + return COMPONENT_INCOMPATIBLE + +/datum/component/resize_guard/RegisterWithParent() + // When our parent mob enters any atom, we check resize + RegisterSignal(parent, COMSIG_ATOM_ENTERING, .proc/check_resize) + +/datum/component/resize_guard/UnregisterFromParent() + UnregisterSignal(parent, COMSIG_ATOM_ENTERING) + +/datum/component/resize_guard/proc/check_resize() + var/area/A = get_area(parent) + if(A?.limit_mob_size) + var/mob/living/L = parent + L.resize(L.size_multiplier) + qdel(src) \ No newline at end of file diff --git a/code/game/atoms.dm b/code/game/atoms.dm index c20c29be7b..e4ad20f5d4 100644 --- a/code/game/atoms.dm +++ b/code/game/atoms.dm @@ -638,6 +638,7 @@ . = ..() GLOB.moved_event.raise_event(AM, old_loc, AM.loc) SEND_SIGNAL(src, COMSIG_ATOM_ENTERED, AM, old_loc) + SEND_SIGNAL(AM, COMSIG_ATOM_ENTERING, src, old_loc) /atom/Exit(atom/movable/AM, atom/new_loc) . = ..() diff --git a/code/modules/admin/verbs/resize.dm b/code/modules/admin/verbs/resize.dm index dddaeb9ec1..522e89de85 100644 --- a/code/modules/admin/verbs/resize.dm +++ b/code/modules/admin/verbs/resize.dm @@ -5,12 +5,48 @@ if(!check_rights(R_ADMIN, R_FUN)) return +<<<<<<< HEAD var/size_multiplier = input(usr, "Input size multiplier.", "Resize", 1) L.resize(size_multiplier, TRUE, TRUE) if(size_multiplier >= RESIZE_TINY && size_multiplier <= RESIZE_HUGE) L.size_uncapped = FALSE else L.size_uncapped = TRUE +||||||| parent of 4c52a2cdd4... Merge pull request #10095 from ShadowLarkens/better_resize_guard + var/size_multiplier = input(usr, "Input size multiplier.", "Resize", 1) as num|null + if(!size_multiplier) + return //cancelled + + size_multiplier = clamp(size_multiplier, 0.01, 1000) + var/can_be_big = L.has_large_resize_bounds() + var/very_big = is_extreme_size(size_multiplier) + + if(very_big && can_be_big) // made an extreme size in an area that allows it, don't assume adminbuse + to_chat(src,"[L] will lose this size upon moving into an area where this size is not allowed.") + else if(very_big) // made an extreme size in an area that doesn't allow it, assume adminbuse + to_chat(src,"[L] will retain this normally unallowed size outside this area.") + L.size_uncapped = TRUE + else if(L.size_uncapped) // made a normal size after having been an extreme adminbuse size + to_chat(src,"[L] now returned to normal area-based size limitations.") + L.size_uncapped = FALSE + + L.resize(size_multiplier, animate = TRUE, uncapped = TRUE, ignore_prefs = TRUE) +======= + var/size_multiplier = input(usr, "Input size multiplier.", "Resize", 1) as num|null + if(!size_multiplier) + return //cancelled + + size_multiplier = clamp(size_multiplier, 0.01, 1000) + var/can_be_big = L.has_large_resize_bounds() + var/very_big = is_extreme_size(size_multiplier) + + if(very_big && can_be_big) // made an extreme size in an area that allows it, don't assume adminbuse + to_chat(src,"[L] will lose this size upon moving into an area where this size is not allowed.") + else if(very_big) // made an extreme size in an area that doesn't allow it, assume adminbuse + to_chat(src,"[L] will retain this normally unallowed size outside this area.") + + L.resize(size_multiplier, animate = TRUE, uncapped = TRUE, ignore_prefs = TRUE) +>>>>>>> 4c52a2cdd4... Merge pull request #10095 from ShadowLarkens/better_resize_guard log_and_message_admins("has changed [key_name(L)]'s size multiplier to [size_multiplier].") feedback_add_details("admin_verb","RESIZE") \ No newline at end of file diff --git a/code/modules/mob/living/living_defines_vr.dm b/code/modules/mob/living/living_defines_vr.dm index 6964193c5c..59a3fd7a5d 100644 --- a/code/modules/mob/living/living_defines_vr.dm +++ b/code/modules/mob/living/living_defines_vr.dm @@ -6,8 +6,6 @@ appearance_flags = TILE_BOUND|PIXEL_SCALE|KEEP_TOGETHER var/hunger_rate = DEFAULT_HUNGER_FACTOR var/resizable = TRUE - var/size_uncapped = FALSE //Determines if a mob's size obedies the resize cap, used for adminbus resize. - //custom say verbs var/custom_say = null var/custom_ask = null diff --git a/code/modules/nifsoft/software/15_misc.dm b/code/modules/nifsoft/software/15_misc.dm index 2b173346ce..bf98451bac 100644 --- a/code/modules/nifsoft/software/15_misc.dm +++ b/code/modules/nifsoft/software/15_misc.dm @@ -134,7 +134,13 @@ to_chat(nif.human,"The safety features of the NIF Program prevent you from choosing this size.") return else +<<<<<<< HEAD if(nif.human.resize(new_size/100)) +||||||| parent of 4c52a2cdd4... Merge pull request #10095 from ShadowLarkens/better_resize_guard + if(nif.human.resize(new_size/100, ignore_prefs = TRUE)) +======= + if(nif.human.resize(new_size/100, uncapped=nif.human.has_large_resize_bounds(), ignore_prefs = TRUE)) +>>>>>>> 4c52a2cdd4... Merge pull request #10095 from ShadowLarkens/better_resize_guard to_chat(nif.human,"You set the size to [new_size]%") nif.human.visible_message("Swirling grey mist envelops [nif.human] as they change size!","Swirling streams of nanites wrap around you as you change size!") spawn(0) diff --git a/code/modules/vore/resizing/resize_vr.dm b/code/modules/vore/resizing/resize_vr.dm index f726775207..aa1c95bc18 100644 --- a/code/modules/vore/resizing/resize_vr.dm +++ b/code/modules/vore/resizing/resize_vr.dm @@ -1,6 +1,3 @@ -GLOBAL_LIST_EMPTY(size_uncapped_mobs) -GLOBAL_VAR(size_uncapped_mobs_timer) - // Adding needed defines to /mob/living // Note: Polaris had this on /mob/living/carbon/human We need it higher up for animals and stuff. /mob/living @@ -60,6 +57,7 @@ GLOBAL_VAR(size_uncapped_mobs_timer) return FALSE return TRUE +<<<<<<< HEAD /proc/add_to_uncapped_list(var/mob/living/L) if(L.size_uncapped) return @@ -92,14 +90,87 @@ GLOBAL_VAR(size_uncapped_mobs_timer) if(!GLOB.size_uncapped_mobs.len) deltimer(GLOB.size_uncapped_mobs_timer) GLOB.size_uncapped_mobs_timer = null +||||||| parent of 4c52a2cdd4... Merge pull request #10095 from ShadowLarkens/better_resize_guard +/atom/movable/proc/has_large_resize_bounds() + var/area/A = get_area(src) //Get the atom's area to check for size limit. + return !A.limit_mob_size + +/proc/is_extreme_size(size) + return (size < RESIZE_MINIMUM || size > RESIZE_MAXIMUM) + +/proc/add_to_uncapped_list(var/mob/living/L) + if(L.size_uncapped) + return + if(!GLOB.size_uncapped_mobs.len) + //Could be a subsystem but arguably a giant waste of time to make into a subsystem. A subsystem that is paused on and off all the time? Eh. + //If you're that worried, make metrics for how often this even runs and then decide. + GLOB.size_uncapped_mobs_timer = addtimer(CALLBACK(GLOBAL_PROC, .check_uncapped_list), 2 SECONDS, TIMER_LOOP | TIMER_UNIQUE | TIMER_STOPPABLE) + GLOB.size_uncapped_mobs |= weakref(L) + +/proc/remove_from_uncapped_list(var/mob/living/L) + if(!GLOB.size_uncapped_mobs.len) + return + + GLOB.size_uncapped_mobs -= weakref(L) + + if(!GLOB.size_uncapped_mobs.len) + deltimer(GLOB.size_uncapped_mobs_timer) + GLOB.size_uncapped_mobs_timer = null + +/proc/check_uncapped_list() + for(var/weakref/wr in GLOB.size_uncapped_mobs) + var/mob/living/L = wr.resolve() + if(!istype(L) || L.size_uncapped) + GLOB.size_uncapped_mobs -= wr + continue + + // If we get here, you're a mob, and you don't have admin exclusion (size_uncapped) to being big, and you're very likely big. + // If you're not abnormally big, the below will do nothing, so it's fine to run anyway. + if(!L.has_large_resize_bounds()) + L.resize(L.size_multiplier, ignore_prefs = TRUE) //Calling this will have resize() clamp it + GLOB.size_uncapped_mobs -= wr + + if(!GLOB.size_uncapped_mobs.len) + deltimer(GLOB.size_uncapped_mobs_timer) + GLOB.size_uncapped_mobs_timer = null +======= +/atom/movable/proc/has_large_resize_bounds() + var/area/A = get_area(src) //Get the atom's area to check for size limit. + return !A.limit_mob_size + +/proc/is_extreme_size(size) + return (size < RESIZE_MINIMUM || size > RESIZE_MAXIMUM) + +>>>>>>> 4c52a2cdd4... Merge pull request #10095 from ShadowLarkens/better_resize_guard /mob/living/proc/resize(var/new_size, var/animate = TRUE, var/uncapped = FALSE) if(!uncapped) +<<<<<<< HEAD new_size = clamp(new_size, RESIZE_TINY, RESIZE_HUGE) src.size_uncapped = FALSE remove_from_uncapped_list(src) else add_to_uncapped_list(src) +||||||| parent of 4c52a2cdd4... Merge pull request #10095 from ShadowLarkens/better_resize_guard + new_size = clamp(new_size, RESIZE_MINIMUM, RESIZE_MAXIMUM) + remove_from_uncapped_list(src) + else if(is_extreme_size(new_size)) + add_to_uncapped_list(src) + +======= + new_size = clamp(new_size, RESIZE_MINIMUM, RESIZE_MAXIMUM) + var/datum/component/resize_guard/guard = GetComponent(/datum/component/resize_guard) + if(guard) + qdel(guard) + else if(has_large_resize_bounds()) + if(is_extreme_size(new_size)) + AddComponent(/datum/component/resize_guard) + else + var/datum/component/resize_guard/guard = GetComponent(/datum/component/resize_guard) + if(guard) + qdel(guard) + +>>>>>>> 4c52a2cdd4... Merge pull request #10095 from ShadowLarkens/better_resize_guard if(size_multiplier == new_size) return 1 diff --git a/code/modules/vore/resizing/sizegun_vr.dm b/code/modules/vore/resizing/sizegun_vr.dm index d042c6cb34..0cbc068657 100644 --- a/code/modules/vore/resizing/sizegun_vr.dm +++ b/code/modules/vore/resizing/sizegun_vr.dm @@ -98,10 +98,40 @@ /obj/item/projectile/beam/sizelaser/admin/on_hit(var/atom/target) var/mob/living/M = target if(istype(M)) +<<<<<<< HEAD M.resize(set_size, TRUE, TRUE) if(set_size >= RESIZE_TINY && set_size <= RESIZE_HUGE) M.size_uncapped = FALSE M.size_uncapped = TRUE +||||||| parent of 4c52a2cdd4... Merge pull request #10095 from ShadowLarkens/better_resize_guard + + var/can_be_big = M.has_large_resize_bounds() + var/very_big = is_extreme_size(set_size) + + if(very_big && can_be_big) // made an extreme size in an area that allows it, don't assume adminbuse + to_chat(firer, "[M] will lose this size upon moving into an area where this size is not allowed.") + else if(very_big) // made an extreme size in an area that doesn't allow it, assume adminbuse + to_chat(firer, "[M] will retain this normally unallowed size outside this area.") + M.size_uncapped = TRUE + else if(M.size_uncapped) // made a normal size after having been an extreme adminbuse size + to_chat(firer, "[M] now returned to normal area-based size limitations.") + M.size_uncapped = FALSE + + M.resize(set_size, uncapped = TRUE, ignoring_prefs = TRUE) // Always ignores prefs, caution is advisable + +======= + + var/can_be_big = M.has_large_resize_bounds() + var/very_big = is_extreme_size(set_size) + + if(very_big && can_be_big) // made an extreme size in an area that allows it, don't assume adminbuse + to_chat(firer, "[M] will lose this size upon moving into an area where this size is not allowed.") + else if(very_big) // made an extreme size in an area that doesn't allow it, assume adminbuse + to_chat(firer, "[M] will retain this normally unallowed size outside this area.") + + M.resize(set_size, uncapped = TRUE, ignore_prefs = TRUE) // Always ignores prefs, caution is advisable + +>>>>>>> 4c52a2cdd4... Merge pull request #10095 from ShadowLarkens/better_resize_guard to_chat(M, "The beam fires into your body, changing your size!") M.updateicon() return diff --git a/vorestation.dme b/vorestation.dme index 9c834a5c0e..7b77361369 100644 --- a/vorestation.dme +++ b/vorestation.dme @@ -353,6 +353,7 @@ #include "code\datums\autolathe\tools.dm" #include "code\datums\autolathe\tools_vr.dm" #include "code\datums\components\_component.dm" +#include "code\datums\components\resize_guard.dm" #include "code\datums\elements\_element.dm" #include "code\datums\game_masters\_common.dm" #include "code\datums\helper_datums\construction_datum.dm"