Improves VV-related code (#54416)

VV-related code cleanup
    Added code to trigger the proper setters for several variables that have them.
    Added some admin logging for var-edit teleports.
    Cleaned-up some code all around.
This commit is contained in:
Rohesie
2020-10-19 15:38:26 +01:00
committed by GitHub
parent 21a23a3602
commit 192bfb5f4c
13 changed files with 189 additions and 88 deletions
+39
View File
@@ -1020,13 +1020,52 @@
* the object has been admin edited
*/
/atom/vv_edit_var(var_name, var_value)
switch(var_name)
if(NAMEOF(src, light_range))
if(light_system == STATIC_LIGHT)
set_light(l_range = var_value)
else
set_light_range(var_value)
. = TRUE
if(NAMEOF(src, light_power))
if(light_system == STATIC_LIGHT)
set_light(l_power = var_value)
else
set_light_power(var_value)
. = TRUE
if(NAMEOF(src, light_color))
if(light_system == STATIC_LIGHT)
set_light(l_color = var_value)
else
set_light_color(var_value)
. = TRUE
if(NAMEOF(src, light_on))
set_smoothed_icon_state(var_value)
. = TRUE
if(NAMEOF(src, light_flags))
set_light_flags(var_value)
. = TRUE
if(NAMEOF(src, smoothing_junction))
set_smoothed_icon_state(var_value)
. = TRUE
if(NAMEOF(src, opacity))
set_opacity(var_value)
. = TRUE
if(!isnull(.))
datum_flags |= DF_VAR_EDITED
return
if(!GLOB.Debug2)
flags_1 |= ADMIN_SPAWNED_1
. = ..()
switch(var_name)
if(NAMEOF(src, color))
add_atom_colour(color, ADMIN_COLOUR_PRIORITY)
/**
* Return the markup to for the dropdown list for the VV panel for this atom
*
+26 -15
View File
@@ -165,45 +165,56 @@
return FALSE
return T.zPassOut(src, direction, destination) && destination.zPassIn(src, direction, T)
/atom/movable/vv_edit_var(var_name, var_value)
var/static/list/banned_edits = list("step_x", "step_y", "step_size", "bounds")
var/static/list/careful_edits = list("bound_x", "bound_y", "bound_width", "bound_height")
if(var_name in banned_edits)
var/static/list/banned_edits = list("step_x" = TRUE, "step_y" = TRUE, "step_size" = TRUE, "bounds" = TRUE)
var/static/list/careful_edits = list("bound_x" = TRUE, "bound_y" = TRUE, "bound_width" = TRUE, "bound_height" = TRUE)
if(banned_edits[var_name])
return FALSE //PLEASE no.
if((var_name in careful_edits) && (var_value % world.icon_size) != 0)
if((careful_edits[var_name]) && (var_value % world.icon_size) != 0)
return FALSE
switch(var_name)
if(NAMEOF(src, anchored))
set_anchored(var_value)
return TRUE
if(NAMEOF(src, x))
var/turf/T = locate(var_value, y, z)
if(T)
forceMove(T)
admin_teleport(T)
return TRUE
return FALSE
if(NAMEOF(src, y))
var/turf/T = locate(x, var_value, z)
if(T)
forceMove(T)
admin_teleport(T)
return TRUE
return FALSE
if(NAMEOF(src, z))
var/turf/T = locate(x, y, var_value)
if(T)
forceMove(T)
admin_teleport(T)
return TRUE
return FALSE
if(NAMEOF(src, loc))
if(istype(var_value, /atom))
forceMove(var_value)
return TRUE
else if(isnull(var_value))
moveToNullspace()
if(isatom(var_value) || isnull(var_value))
admin_teleport(var_value)
return TRUE
return FALSE
if(NAMEOF(src, anchored))
set_anchored(var_value)
. = TRUE
if(NAMEOF(src, pulledby))
set_pulledby(var_value)
. = TRUE
if(NAMEOF(src, glide_size))
set_glide_size(var_value)
. = TRUE
if(!isnull(.))
datum_flags |= DF_VAR_EDITED
return
return ..()
/atom/movable/proc/start_pulling(atom/movable/AM, state, force = move_force, supress_message = FALSE)
if(QDELETED(AM))
return FALSE
+18 -5
View File
@@ -105,13 +105,26 @@
return
var/atom/loc = get_turf(usr)
log_admin("[key_name(usr)] teleported [key_name(M)] to [AREACOORD(loc)]")
var/msg = "[key_name_admin(usr)] teleported [ADMIN_LOOKUPFLW(M)] to [ADMIN_VERBOSEJMP(loc)]"
message_admins(msg)
admin_ticket_log(M, msg)
M.forceMove(loc)
M.admin_teleport(loc)
SSblackbox.record_feedback("tally", "admin_verb", 1, "Get Mob") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
/// Proc to hook user-enacted teleporting behavior and keep logging of the event.
/atom/movable/proc/admin_teleport(atom/new_location)
if(isnull(new_location))
log_admin("[key_name(usr)] teleported [key_name(src)] to nullspace")
moveToNullspace()
else
log_admin("[key_name(usr)] teleported [key_name(src)] to [AREACOORD(loc)]")
forceMove(new_location)
/mob/admin_teleport(atom/new_location)
var/msg = "[key_name_admin(usr)] teleported [ADMIN_LOOKUPFLW(src)] to [isnull(new_location) ? "nullspace" : ADMIN_VERBOSEJMP(loc)]"
message_admins(msg)
admin_ticket_log(src, msg)
return ..()
/client/proc/Getkey()
set category = "Admin.Game"
set name = "Get Key"
-28
View File
@@ -84,34 +84,6 @@
L = thing
L.source_atom.update_light()
/atom/vv_edit_var(var_name, var_value)
switch (var_name)
if (NAMEOF(src, light_range))
if(light_system == STATIC_LIGHT)
set_light(l_range = var_value)
else
set_light_range(var_value)
datum_flags |= DF_VAR_EDITED
return TRUE
if (NAMEOF(src, light_power))
if(light_system == STATIC_LIGHT)
set_light(l_power = var_value)
else
set_light_power(var_value)
datum_flags |= DF_VAR_EDITED
return TRUE
if (NAMEOF(src, light_color))
if(light_system == STATIC_LIGHT)
set_light(l_color = var_value)
else
set_light_color(var_value)
datum_flags |= DF_VAR_EDITED
return TRUE
return ..()
/atom/proc/flash_lighting_fx(_range = FLASH_LIGHT_RANGE, _power = FLASH_LIGHT_POWER, _color = COLOR_WHITE, _duration = FLASH_LIGHT_DURATION)
return
-4
View File
@@ -74,8 +74,6 @@
var/fubar_brain = newbrain.suicided || brainmob.suiciding //brain is from a suicider
if(!fubar_brain && !(newbrain.organ_flags & ORGAN_FAILING)) // the brain organ hasn't been beaten to death, nor was from a suicider.
brainmob.set_stat(CONSCIOUS) //we manually revive the brain mob
brainmob.remove_from_dead_mob_list()
brainmob.add_to_alive_mob_list()
else if(!fubar_brain && newbrain.organ_flags & ORGAN_FAILING) // the brain is damaged, but not from a suicider
to_chat(user, "<span class='warning'>[src]'s indicator light turns yellow and its brain integrity alarm beeps softly. Perhaps you should check [newbrain] for damage.</span>")
playsound(src, 'sound/machines/synth_no.ogg', 5, TRUE)
@@ -119,8 +117,6 @@
brainmob.set_stat(DEAD)
brainmob.emp_damage = 0
brainmob.reset_perspective() //so the brainmob follows the brain organ instead of the mmi. And to update our vision
brainmob.remove_from_alive_mob_list() //Get outta here
brainmob.add_to_dead_mob_list()
brain.brainmob = brainmob //Set the brain to use the brainmob
log_game("[key_name(user)] has ejected the brain of [key_name(brainmob)] from an MMI at [AREACOORD(src)]")
brainmob = null //Set mmi brainmob var to null
@@ -149,8 +149,6 @@ GLOBAL_VAR(posibrain_notify_cooldown)
to_chat(brainmob, policy)
brainmob.mind.assigned_role = new_role
brainmob.set_stat(CONSCIOUS)
brainmob.remove_from_dead_mob_list()
brainmob.add_to_alive_mob_list()
visible_message(new_mob_message)
check_success()
+19
View File
@@ -1298,3 +1298,22 @@
set_lying_angle(pick(90, 270))
else
set_lying_angle(new_lying_angle)
/mob/living/carbon/vv_edit_var(var_name, var_value)
switch(var_name)
if(NAMEOF(src, disgust))
set_disgust(var_value)
. = TRUE
if(NAMEOF(src, hal_screwyhud))
set_screwyhud(var_value)
. = TRUE
if(NAMEOF(src, handcuffed))
set_handcuffed(var_value)
. = TRUE
if(!isnull(.))
datum_flags |= DF_VAR_EDITED
return
return ..()
-4
View File
@@ -47,7 +47,6 @@
/mob/living/death(gibbed)
var/was_dead_before = stat == DEAD
set_stat(DEAD)
unset_machine()
timeofdeath = world.time
@@ -59,9 +58,6 @@
deadchat_broadcast(" has died at <b>[get_area_name(T)]</b>.", "<b>[mind.name]</b>", follow_target = src, turf_target = T, message_type=DEADCHAT_DEATHRATTLE)
if(mind)
mind.store_memory("Time of death: [tod]", 0)
remove_from_alive_mob_list()
if(!gibbed && !was_dead_before)
add_to_dead_mob_list()
set_drugginess(0)
set_disgust(0)
SetSleeping(0, 0)
+43 -13
View File
@@ -609,8 +609,6 @@
if(full_heal)
fully_heal(admin_revive = admin_revive)
if(stat == DEAD && can_be_revived()) //in some cases you can't revive (e.g. no brain)
remove_from_dead_mob_list()
add_to_alive_mob_list()
set_suicide(FALSE)
set_stat(UNCONSCIOUS) //the mob starts unconscious,
updatehealth() //then we check if the mob should wake up.
@@ -1375,26 +1373,52 @@
if (client && ranged_ability?.ranged_mousepointer)
client.mouse_pointer_icon = ranged_ability.ranged_mousepointer
/mob/living/vv_edit_var(var_name, var_value)
switch(var_name)
if (NAMEOF(src, maxHealth))
if (!isnum(var_value) || var_value <= 0)
return FALSE
if(NAMEOF(src, stat))
if((stat == DEAD) && (var_value < DEAD))//Bringing the dead back to life
remove_from_dead_mob_list()
add_to_alive_mob_list()
if((stat < DEAD) && (var_value == DEAD))//Kill he
remove_from_alive_mob_list()
add_to_dead_mob_list()
if(NAMEOF(src, health)) //this doesn't work. gotta use procs instead.
return FALSE
if(NAMEOF(src, druggy))
set_drugginess(var_value)
. = TRUE
if(NAMEOF(src, resting))
set_resting(var_value)
. = TRUE
if(NAMEOF(src, fire_stacks))
set_fire_stacks(var_value)
. = TRUE
if(NAMEOF(src, lying_angle))
set_lying_angle(var_value)
. = TRUE
if(NAMEOF(src, buckled))
set_buckled(var_value)
. = TRUE
if(NAMEOF(src, num_legs))
set_num_legs(var_value)
. = TRUE
if(NAMEOF(src, usable_legs))
set_usable_legs(var_value)
. = TRUE
if(NAMEOF(src, num_hands))
set_num_hands(var_value)
. = TRUE
if(NAMEOF(src, usable_hands))
set_usable_hands(var_value)
. = TRUE
if(NAMEOF(src, body_position))
set_body_position(var_value)
. = TRUE
if(!isnull(.))
datum_flags |= DF_VAR_EDITED
return
. = ..()
switch(var_name)
if(NAMEOF(src, eye_blind))
set_blindness(var_value)
if(NAMEOF(src, eye_blurry))
set_blurriness(var_value)
if(NAMEOF(src, maxHealth))
updatehealth()
if(NAMEOF(src, resize))
@@ -1402,6 +1426,7 @@
if(NAMEOF(src, lighting_alpha))
sync_lighting_plane_alpha()
/mob/living/vv_get_header()
. = ..()
var/refid = REF(src)
@@ -1618,6 +1643,9 @@
if(HARD_CRIT)
if(stat != UNCONSCIOUS)
cure_blind(UNCONSCIOUS_TRAIT)
if(DEAD)
remove_from_dead_mob_list()
add_to_alive_mob_list()
switch(stat) //Current stat.
if(CONSCIOUS)
if(. >= UNCONSCIOUS)
@@ -1645,6 +1673,8 @@
ADD_TRAIT(src, TRAIT_CRITICAL_CONDITION, STAT_TRAIT)
if(DEAD)
REMOVE_TRAIT(src, TRAIT_CRITICAL_CONDITION, STAT_TRAIT)
remove_from_alive_mob_list()
add_to_dead_mob_list()
///Reports the event of the change in value of the buckled variable.
@@ -6,6 +6,5 @@
clear_fullscreens()
//New pAI's get a brand new mind to prevent meta stuff from their previous life. This new mind causes problems down the line if it's not deleted here.
remove_from_alive_mob_list()
ghostize()
qdel(src)
@@ -193,8 +193,6 @@
if(mmi.brainmob)
if(mmi.brainmob.stat == DEAD)
mmi.brainmob.set_stat(CONSCIOUS)
mmi.brainmob.remove_from_dead_mob_list()
mmi.brainmob.add_to_alive_mob_list()
mind.transfer_to(mmi.brainmob)
mmi.update_icon()
else
+44
View File
@@ -1331,3 +1331,47 @@
SEND_SIGNAL(src, COMSIG_MOB_STATCHANGE, new_stat)
. = stat
stat = new_stat
/mob/vv_edit_var(var_name, var_value)
switch(var_name)
if(NAMEOF(src, control_object))
var/obj/O = var_value
if(!istype(O) || (O.obj_flags & DANGEROUS_POSSESSION))
return FALSE
if(NAMEOF(src, machine))
set_machine(var_value)
. = TRUE
if(NAMEOF(src, focus))
set_focus(var_value)
. = TRUE
if(NAMEOF(src, nutrition))
set_nutrition(var_value)
. = TRUE
if(NAMEOF(src, stat))
set_stat(var_value)
. = TRUE
if(NAMEOF(src, dizziness))
set_dizziness(var_value)
. = TRUE
if(NAMEOF(src, eye_blind))
set_blindness(var_value)
. = TRUE
if(NAMEOF(src, eye_blurry))
set_blurriness(var_value)
. = TRUE
if(!isnull(.))
datum_flags |= DF_VAR_EDITED
return
var/slowdown_edit = (var_name == NAMEOF(src, cached_multiplicative_slowdown))
var/diff
if(slowdown_edit && isnum(cached_multiplicative_slowdown) && isnum(var_value))
remove_movespeed_modifier(/datum/movespeed_modifier/admin_varedit)
diff = var_value - cached_multiplicative_slowdown
. = ..()
if(. && slowdown_edit && isnum(diff))
add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/admin_varedit, multiplicative_slowdown = diff)
@@ -142,20 +142,6 @@ GLOBAL_LIST_EMPTY(movespeed_modification_cache)
update_movespeed(TRUE)
return final
/// Handles the special case of editing the movement var
/mob/vv_edit_var(var_name, var_value)
if(var_name == NAMEOF(src, control_object))
var/obj/O = var_value
if(!istype(O) || (O.obj_flags & DANGEROUS_POSSESSION))
return FALSE
var/slowdown_edit = (var_name == NAMEOF(src, cached_multiplicative_slowdown))
var/diff
if(slowdown_edit && isnum(cached_multiplicative_slowdown) && isnum(var_value))
remove_movespeed_modifier(/datum/movespeed_modifier/admin_varedit)
diff = var_value - cached_multiplicative_slowdown
. = ..()
if(. && slowdown_edit && isnum(diff))
add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/admin_varedit, multiplicative_slowdown = diff)
///Is there a movespeed modifier for this mob
/mob/proc/has_movespeed_modifier(datum/movespeed_modifier/datum_type_id)