removed CLAMP define

This commit is contained in:
spookerton
2022-03-31 19:21:58 +01:00
parent bcfe3e9851
commit 602cc67d2b
65 changed files with 116 additions and 118 deletions

View File

@@ -100,7 +100,7 @@
else
set_temperature = max(amount, 0)
if("setPower") //setting power to 0 is redundant anyways
var/new_setting = CLAMP(text2num(params["value"]), 0, 100)
var/new_setting = clamp(text2num(params["value"]), 0, 100)
set_power_level(new_setting)
add_fingerprint(usr)

View File

@@ -11,8 +11,6 @@
#define CLAMP01(x) clamp(x, 0, 1)
#define CLAMP(CLVALUE, CLMIN, CLMAX) clamp(CLVALUE, CLMIN, CLMAX)
#define TAN(x) tan(x)
#define ATAN2(x, y) arctan(x, y)
@@ -190,8 +188,8 @@
while(pixel_y < -16)
pixel_y += 32
new_y--
new_x = CLAMP(new_x, 0, world.maxx)
new_y = CLAMP(new_y, 0, world.maxy)
new_x = clamp(new_x, 0, world.maxx)
new_y = clamp(new_y, 0, world.maxy)
return locate(new_x, new_y, starting.z)
// Returns a list where [1] is all x values and [2] is all y values that overlap between the given pair of rectangles

View File

@@ -929,9 +929,9 @@ GLOBAL_LIST_EMPTY(cached_examine_icons)
if (!value) return color
var/list/RGB = ReadRGB(color)
RGB[1] = CLAMP(RGB[1]+value,0,255)
RGB[2] = CLAMP(RGB[2]+value,0,255)
RGB[3] = CLAMP(RGB[3]+value,0,255)
RGB[1] = clamp(RGB[1]+value,0,255)
RGB[2] = clamp(RGB[2]+value,0,255)
RGB[3] = clamp(RGB[3]+value,0,255)
return rgb(RGB[1],RGB[2],RGB[3])
/proc/sort_atoms_by_layer(var/list/atoms)

View File

@@ -50,7 +50,7 @@
/proc/color_rotation(angle)
if(angle == 0)
return color_identity()
angle = CLAMP(angle, -180, 180)
angle = clamp(angle, -180, 180)
var/cos = cos(angle)
var/sin = sin(angle)
@@ -65,7 +65,7 @@
//Makes everything brighter or darker without regard to existing color or brightness
/proc/color_brightness(power)
power = CLAMP(power, -255, 255)
power = clamp(power, -255, 255)
power = power/255
return list(1,0,0, 0,1,0, 0,0,1, power,power,power)
@@ -85,7 +85,7 @@
//Exxagerates or removes brightness
/proc/color_contrast(value)
value = CLAMP(value, -100, 100)
value = clamp(value, -100, 100)
if(value == 0)
return color_identity()
@@ -108,7 +108,7 @@
/proc/color_saturation(value as num)
if(value == 0)
return color_identity()
value = CLAMP(value, -100, 100)
value = clamp(value, -100, 100)
if(value > 0)
value *= 3
var/x = 1 + value / 100

View File

@@ -41,7 +41,7 @@
var/obj/item/weapon/tank/rigtank = owner_rig.air_supply
var/charge_percentage = rigcell ? rigcell.charge / rigcell.maxcharge : 0
var/air_percentage = rigtank ? CLAMP(rigtank.air_contents.total_moles / 17.4693, 0, 1) : 0
var/air_percentage = rigtank ? clamp(rigtank.air_contents.total_moles / 17.4693, 0, 1) : 0
var/air_on = owner_rig.wearer?.internal ? 1 : 0
power.icon_state = "pwr[round(charge_percentage / 0.2, 1)]"
@@ -91,7 +91,7 @@
var/obj/machinery/portable_atmospherics/canister/mechtank = owner_mech.internal_tank
var/charge_percentage = mechcell ? mechcell.charge / mechcell.maxcharge : 0
var/air_percentage = mechtank ? CLAMP(mechtank.air_contents.total_moles / 1863.47, 0, 1) : 0
var/air_percentage = mechtank ? clamp(mechtank.air_contents.total_moles / 1863.47, 0, 1) : 0
var/health_percentage = owner_mech.health / owner_mech.maxhealth
var/air_on = owner_mech.use_internal_tank

View File

@@ -132,8 +132,8 @@
overlays += dir
/obj/screen/movable/pic_in_pic/proc/set_view_size(width, height, do_refresh = TRUE)
width = CLAMP(width, 0, max_dimensions)
height = CLAMP(height, 0, max_dimensions)
width = clamp(width, 0, max_dimensions)
height = clamp(height, 0, max_dimensions)
src.width = width
src.height = height

View File

@@ -39,7 +39,7 @@
shown = 0
client = user.client
progress = CLAMP(progress, 0, goal)
progress = clamp(progress, 0, goal)
bar.icon_state = "prog_bar_[round(((progress / goal) * 100), 5)]"
if (!shown && user.is_preference_enabled(/datum/client_preference/show_progress_bar))
user.client.images += bar

View File

@@ -140,7 +140,7 @@
holding = null
. = TRUE
if("volume_adj")
volume_rate = CLAMP(text2num(params["vol"]), minrate, maxrate)
volume_rate = clamp(text2num(params["vol"]), minrate, maxrate)
. = TRUE
update_icon()

View File

@@ -39,7 +39,7 @@
if(dist <= round(max_range + world.view - 2, 1))
M.playsound_local(epicenter, get_sfx("explosion"), 100, 1, frequency, falloff = 5) // get_sfx() is so that everyone gets the same sound
else if(dist <= far_dist)
var/far_volume = CLAMP(far_dist, 30, 50) // Volume is based on explosion size and dist
var/far_volume = clamp(far_dist, 30, 50) // Volume is based on explosion size and dist
far_volume += (dist <= far_dist * 0.5 ? 50 : 0) // add 50 volume if the mob is pretty close to the explosion
M.playsound_local(epicenter, 'sound/effects/explosionfar.ogg', far_volume, 1, frequency, falloff = 5)

View File

@@ -276,9 +276,9 @@
/obj/item/proc/get_volume_by_throwforce_and_or_w_class() // This is used for figuring out how loud our sounds are for throwing.
if(throwforce && w_class)
return CLAMP((throwforce + w_class) * 5, 30, 100)// Add the item's throwforce to its weight class and multiply by 5, then clamp the value between 30 and 100
return clamp((throwforce + w_class) * 5, 30, 100)// Add the item's throwforce to its weight class and multiply by 5, then clamp the value between 30 and 100
else if(w_class)
return CLAMP(w_class * 8, 20, 100) // Multiply the item's weight class by 8, then clamp the value between 20 and 100
return clamp(w_class * 8, 20, 100) // Multiply the item's weight class by 8, then clamp the value between 20 and 100
else
return 0

View File

@@ -41,7 +41,7 @@
/obj/item/weapon/plastique/attack_self(mob/user as mob)
var/newtime = input(usr, "Please set the timer.", "Timer", 10) as num
if(user.get_active_hand() == src)
newtime = CLAMP(newtime, 10, 60000)
newtime = clamp(newtime, 10, 60000)
timer = newtime
to_chat(user, "Timer set for [timer] seconds.")

View File

@@ -494,7 +494,7 @@ var/list/global/tank_gauge_cache = list()
var/release_ratio = 0.002
if(tank_pressure)
release_ratio = CLAMP(sqrt(max(tank_pressure-env_pressure,0)/tank_pressure), 0.002, 1)
release_ratio = clamp(sqrt(max(tank_pressure-env_pressure,0)/tank_pressure), 0.002, 1)
var/datum/gas_mixture/leaked_gas = air_contents.remove_ratio(release_ratio)
//dynamic air release based on ambient pressure

View File

@@ -53,4 +53,4 @@
/datum/blob_type/pressurized_slime/on_chunk_use(obj/item/weapon/blobcore_chunk/B, mob/living/user) // Drenches you in water.
if(user)
user.ExtinguishMob()
user.fire_stacks = CLAMP(user.fire_stacks - 1, -25, 25)
user.fire_stacks = clamp(user.fire_stacks - 1, -25, 25)

View File

@@ -400,7 +400,7 @@ var/global/list/valid_bloodtypes = list("A+", "A-", "B+", "B-", "AB+", "AB-", "O
if(isnull(last_descriptors[entry]))
pref.body_descriptors[entry] = descriptor.default_value // Species datums have initial default value.
else
pref.body_descriptors[entry] = CLAMP(last_descriptors[entry], 1, LAZYLEN(descriptor.standalone_value_descriptors))
pref.body_descriptors[entry] = clamp(last_descriptors[entry], 1, LAZYLEN(descriptor.standalone_value_descriptors))
/datum/category_item/player_setup_item/general/body/content(var/mob/user)
. = list()

View File

@@ -42,7 +42,7 @@
pref.volume_channels["[channel]"] = 1
var/value = input("Choose your volume for [channel] (0-200%)", "[channel] volume", (pref.volume_channels[channel] * 100))
if(isnum(value))
value = CLAMP(value, 0, 200)
value = clamp(value, 0, 200)
pref.volume_channels["[channel]"] = (value / 100)
return TOPIC_REFRESH
return ..()

View File

@@ -43,7 +43,7 @@
if(numeric_directions)
str = "[angle]"
else
str = angle_step_to_dir[CLAMP(round(angle/45)+1, 1, length(angle_step_to_dir))]
str = angle_step_to_dir[clamp(round(angle/45)+1, 1, length(angle_step_to_dir))]
str_col = "#ffffffaa"
else
str = "〡"

View File

@@ -145,7 +145,7 @@
var/account_name = href_list["holder_name"]
var/starting_funds = max(text2num(href_list["starting_funds"]), 0)
starting_funds = CLAMP(starting_funds, 0, station_account.money) // Not authorized to put the station in debt.
starting_funds = clamp(starting_funds, 0, station_account.money) // Not authorized to put the station in debt.
starting_funds = min(starting_funds, fund_cap) // Not authorized to give more than the fund cap.
create_account(account_name, starting_funds, src)

View File

@@ -83,7 +83,7 @@
var/amount = input(usr, "How many [initial_name]s do you want to take? (0 to [src.worth])", "Take Money", 20) as num
if(!src || QDELETED(src))
return
amount = round(CLAMP(amount, 0, src.worth))
amount = round(clamp(amount, 0, src.worth))
if(!amount)
return

View File

@@ -130,7 +130,7 @@
if("set_amount")
var/item_name = locate(href_list["item"])
var/n_amount = round(input("Enter amount", "New amount") as num)
n_amount = CLAMP(n_amount, 0, 20)
n_amount = clamp(n_amount, 0, 20)
if (!item_list[item_name] || !Adjacent(usr)) return
transaction_amount += (n_amount - item_list[item_name]) * price_list[item_name]
if(!n_amount)

View File

@@ -125,7 +125,7 @@
if("set_amount")
var/item_name = locate(href_list["item"])
var/n_amount = round(input("Enter amount", "New amount") as num)
n_amount = CLAMP(n_amount, 0, 20)
n_amount = clamp(n_amount, 0, 20)
if (!item_list[item_name] || !Adjacent(usr)) return
transaction_amount += (n_amount - item_list[item_name]) * price_list[item_name]
if(!n_amount)

View File

@@ -71,7 +71,7 @@
name = lowertext("[fullname] sandwich")
if(length(name) > 80) name = "[pick(list("absurd","colossal","enormous","ridiculous"))] sandwich"
w_class = n_ceil(CLAMP((ingredients.len/2),2,4))
w_class = n_ceil(clamp((ingredients.len/2),2,4))
/obj/item/weapon/reagent_containers/food/snacks/csandwich/Destroy()
for(var/obj/item/O in ingredients)

View File

@@ -123,7 +123,7 @@
/obj/item/integrated_circuit/transfer/pulsedemultiplexer/do_work()
var/output_index = get_pin_data(IC_INPUT, 1)
if(output_index == CLAMP(output_index, 1, number_of_outputs))
if(output_index == clamp(output_index, 1, number_of_outputs))
activate_pin(round(output_index + 1 ,1))
/obj/item/integrated_circuit/transfer/pulsedemultiplexer/medium

View File

@@ -296,7 +296,7 @@
/obj/item/integrated_circuit/input/advanced_locator/on_data_written()
var/rad = get_pin_data(IC_INPUT, 2)
if(isnum(rad))
rad = CLAMP(rad, 0, 7)
rad = clamp(rad, 0, 7)
radius = rad
/obj/item/integrated_circuit/input/advanced_locator/do_work()

View File

@@ -108,7 +108,7 @@
var/brightness = get_pin_data(IC_INPUT, 2)
if(new_color && isnum(brightness))
brightness = CLAMP(brightness, 0, 6)
brightness = clamp(brightness, 0, 6)
light_rgb = new_color
light_brightness = brightness

View File

@@ -83,7 +83,7 @@
else
direc = 1
if(isnum(new_amount))
new_amount = CLAMP(new_amount, 0, volume)
new_amount = clamp(new_amount, 0, volume)
transfer_amount = new_amount
@@ -132,7 +132,7 @@
if(!TS.Adjacent(TT))
activate_pin(3)
return
var/tramount = CLAMP(min(transfer_amount, reagents.maximum_volume - reagents.total_volume), 0, reagents.maximum_volume)
var/tramount = clamp(min(transfer_amount, reagents.maximum_volume - reagents.total_volume), 0, reagents.maximum_volume)
if(ismob(target))//Blood!
if(istype(target, /mob/living/carbon))
var/mob/living/carbon/T = target
@@ -206,7 +206,7 @@
else
direc = 1
if(isnum(new_amount))
new_amount = CLAMP(new_amount, 0, 50)
new_amount = clamp(new_amount, 0, 50)
transfer_amount = new_amount
/obj/item/integrated_circuit/reagent/pump/do_work()
@@ -328,7 +328,7 @@
else
direc = 1
if(isnum(new_amount))
new_amount = CLAMP(new_amount, 0, 50)
new_amount = clamp(new_amount, 0, 50)
transfer_amount = new_amount
/obj/item/integrated_circuit/reagent/filter/do_work()

View File

@@ -22,7 +22,7 @@
/obj/item/integrated_circuit/time/delay/do_work()
var/delay_input = get_pin_data(IC_INPUT, 1)
if(delay_input && isnum(delay_input) )
var/new_delay = CLAMP(delay_input, 1, 1 HOUR)
var/new_delay = clamp(delay_input, 1, 1 HOUR)
delay = new_delay
addtimer(CALLBACK(src, .proc/activate_pin, 2), delay)
@@ -51,7 +51,7 @@
/obj/item/integrated_circuit/time/ticker/on_data_written()
var/delay_input = get_pin_data(IC_INPUT, 2)
if(delay_input && isnum(delay_input) )
var/new_delay = CLAMP(delay_input, 1, 1 HOUR)
var/new_delay = clamp(delay_input, 1, 1 HOUR)
delay = new_delay
power_draw_per_use = CEILING((max_power_draw / delay) / delay, 1)

View File

@@ -296,7 +296,7 @@
else if(ores_processing[metal] == PROCESS_COMPRESS && O.compresses_to) //Compressing.
var/can_make = CLAMP(ores_stored[metal],0,sheets_per_tick-sheets)
var/can_make = clamp(ores_stored[metal],0,sheets_per_tick-sheets)
if(can_make%2>0) can_make--
var/datum/material/M = get_material_by_name(O.compresses_to)
@@ -311,7 +311,7 @@
else if(ores_processing[metal] == PROCESS_SMELT && O.smelts_to) //Smelting.
var/can_make = CLAMP(ores_stored[metal],0,sheets_per_tick-sheets)
var/can_make = clamp(ores_stored[metal],0,sheets_per_tick-sheets)
var/datum/material/M = get_material_by_name(O.smelts_to)
if(!istype(M) || !can_make || ores_stored[metal] < 1)

View File

@@ -99,10 +99,10 @@
/datum/mob_descriptor/proc/get_comparative_value_string_smaller(var/value, var/datum/gender/my_gender, var/datum/gender/other_gender)
var/maxval = LAZYLEN(comparative_value_descriptors_smaller)
value = CLAMP(CEILING(value * maxval, 1), 1, maxval)
value = clamp(CEILING(value * maxval, 1), 1, maxval)
return comparative_value_descriptors_smaller[value]
/datum/mob_descriptor/proc/get_comparative_value_string_larger(var/value, var/datum/gender/my_gender, var/datum/gender/other_gender)
var/maxval = LAZYLEN(comparative_value_descriptors_larger)
value = CLAMP(CEILING(value * maxval, 1), 1, maxval)
value = clamp(CEILING(value * maxval, 1), 1, maxval)
return comparative_value_descriptors_larger[value]

View File

@@ -105,7 +105,7 @@
for(var/datum/modifier/M in modifiers)
if(!isnull(M.explosion_modifier))
severity = CLAMP(severity + M.explosion_modifier, 1, 4)
severity = clamp(severity + M.explosion_modifier, 1, 4)
severity = round(severity)

View File

@@ -604,7 +604,7 @@ emp_act
var/converted_protection = 1 - protection
var/perm = reagent_permeability()
converted_protection *= perm
return CLAMP(1-converted_protection, 0, 1)
return clamp(1-converted_protection, 0, 1)
/mob/living/carbon/human/water_act(amount)
adjust_fire_stacks(-amount * 5)

View File

@@ -127,22 +127,22 @@
var/turf_move_cost = T.movement_cost
if(istype(T, /turf/simulated/floor/water))
if(species.water_movement)
turf_move_cost = CLAMP(turf_move_cost + species.water_movement, HUMAN_LOWEST_SLOWDOWN, 15)
turf_move_cost = clamp(turf_move_cost + species.water_movement, HUMAN_LOWEST_SLOWDOWN, 15)
if(shoes)
var/obj/item/clothing/shoes/feet = shoes
if(feet.water_speed)
turf_move_cost = CLAMP(turf_move_cost + feet.water_speed, HUMAN_LOWEST_SLOWDOWN, 15)
turf_move_cost = clamp(turf_move_cost + feet.water_speed, HUMAN_LOWEST_SLOWDOWN, 15)
. += turf_move_cost
else if(istype(T, /turf/simulated/floor/outdoors/snow))
if(species.snow_movement)
turf_move_cost = CLAMP(turf_move_cost + species.snow_movement, HUMAN_LOWEST_SLOWDOWN, 15)
turf_move_cost = clamp(turf_move_cost + species.snow_movement, HUMAN_LOWEST_SLOWDOWN, 15)
if(shoes)
var/obj/item/clothing/shoes/feet = shoes
if(feet.water_speed)
turf_move_cost = CLAMP(turf_move_cost + feet.snow_speed, HUMAN_LOWEST_SLOWDOWN, 15)
turf_move_cost = clamp(turf_move_cost + feet.snow_speed, HUMAN_LOWEST_SLOWDOWN, 15)
. += turf_move_cost
else
turf_move_cost = CLAMP(turf_move_cost, HUMAN_LOWEST_SLOWDOWN, 15)
turf_move_cost = clamp(turf_move_cost, HUMAN_LOWEST_SLOWDOWN, 15)
. += turf_move_cost
// Wind makes it easier or harder to move, depending on if you're with or against the wind.

View File

@@ -263,7 +263,7 @@
if(gene.is_active(src))
gene.OnMobLife(src)
radiation = CLAMP(radiation,0,250)
radiation = clamp(radiation,0,250)
if(!radiation)
if(species.appearance_flags & RADIATION_GLOWS)
@@ -531,7 +531,7 @@
if(toxins_pp > safe_toxins_max)
var/ratio = (poison/safe_toxins_max) * 10
if(reagents)
reagents.add_reagent("toxin", CLAMP(ratio, MIN_TOXIN_DAMAGE, MAX_TOXIN_DAMAGE))
reagents.add_reagent("toxin", clamp(ratio, MIN_TOXIN_DAMAGE, MAX_TOXIN_DAMAGE))
breath.adjust_gas(poison_type, -poison/6, update = 0) //update after
throw_alert("tox_in_air", /obj/screen/alert/tox_in_air)
else

View File

@@ -30,7 +30,7 @@
var/datum/gender/T = gender_datums[user.get_visible_gender()]
var/datum/gender/TT = gender_datums[target.get_visible_gender()]
if(!skill) skill = 1
attack_damage = CLAMP(attack_damage, 1, 5)
attack_damage = clamp(attack_damage, 1, 5)
if(target == user)
user.visible_message("<span class='danger'>[user] [pick(attack_verb)] [T.himself] in the [affecting.name]!</span>")

View File

@@ -145,7 +145,7 @@ var/global/list/sparring_attack_cache = list()
var/datum/gender/TU = gender_datums[user.get_visible_gender()]
var/datum/gender/TT = gender_datums[target.get_visible_gender()]
attack_damage = CLAMP(attack_damage, 1, 5) // We expect damage input of 1 to 5 for this proc. But we leave this check juuust in case.
attack_damage = clamp(attack_damage, 1, 5) // We expect damage input of 1 to 5 for this proc. But we leave this check juuust in case.
if(target == user)
user.visible_message("<span class='danger'>[user] [pick(attack_verb)] [TU.himself] in the [organ]!</span>")
@@ -220,7 +220,7 @@ var/global/list/sparring_attack_cache = list()
var/datum/gender/TT = gender_datums[target.get_visible_gender()]
var/organ = affecting.name
attack_damage = CLAMP(attack_damage, 1, 5)
attack_damage = clamp(attack_damage, 1, 5)
switch(attack_damage)
if(1 to 2) user.visible_message("<span class='danger'>[user] threw [target] a glancing [pick(attack_noun)] to the [organ]!</span>") //it's not that they're kicking lightly, it's that the kick didn't quite connect
@@ -267,7 +267,7 @@ var/global/list/sparring_attack_cache = list()
var/obj/item/clothing/shoes = user.shoes
var/datum/gender/TU = gender_datums[user.get_visible_gender()]
attack_damage = CLAMP(attack_damage, 1, 5)
attack_damage = clamp(attack_damage, 1, 5)
switch(attack_damage)
if(1 to 4) user.visible_message("<span class='danger'>[pick("[user] stomped on", "[user] slammed [TU.his] [shoes ? copytext(shoes.name, 1, -1) : "foot"] down onto")] [target]'s [organ]!</span>")

View File

@@ -171,7 +171,7 @@
if(LAZYLEN(modifiers))
for(var/datum/modifier/M in modifiers)
if(!isnull(M.emp_modifier))
severity = CLAMP(severity + M.emp_modifier, 1, 5)
severity = clamp(severity + M.emp_modifier, 1, 5)
if(severity == 5) // Effectively nullified.
return
@@ -385,7 +385,7 @@
return
/mob/living/proc/adjust_fire_stacks(add_fire_stacks) //Adjusting the amount of fire_stacks we have on person
fire_stacks = CLAMP(fire_stacks + add_fire_stacks, FIRE_MIN_STACKS, FIRE_MAX_STACKS)
fire_stacks = clamp(fire_stacks + add_fire_stacks, FIRE_MIN_STACKS, FIRE_MAX_STACKS)
/mob/living/proc/handle_fire()
if(fire_stacks < 0)

View File

@@ -306,7 +306,7 @@ var/list/channel_to_radio_key = new
if(sb_alpha < 0)
break
speech_bubble.loc = loc_before_turf
speech_bubble.alpha = CLAMP(sb_alpha, 0, 255)
speech_bubble.alpha = clamp(sb_alpha, 0, 255)
images_to_clients[speech_bubble] = list()
// Attempt Multi-Z Talking

View File

@@ -289,7 +289,7 @@
for(var/datum/modifier/M in modifiers)
if(!isnull(M.explosion_modifier))
severity = CLAMP(severity + M.explosion_modifier, 1, 4)
severity = clamp(severity + M.explosion_modifier, 1, 4)
severity = round(severity)

View File

@@ -116,7 +116,7 @@
for(var/datum/modifier/M in modifiers)
if(!isnull(M.explosion_modifier))
severity = CLAMP(severity + M.explosion_modifier, 1, 4)
severity = clamp(severity + M.explosion_modifier, 1, 4)
severity = round(severity)

View File

@@ -831,10 +831,10 @@
return
/mob/proc/AdjustLosebreath(amount)
losebreath = CLAMP(losebreath + amount, 0, 25)
losebreath = clamp(losebreath + amount, 0, 25)
/mob/proc/SetLosebreath(amount)
losebreath = CLAMP(amount, 0, 25)
losebreath = clamp(amount, 0, 25)
/mob/proc/get_species()
return ""

View File

@@ -377,7 +377,7 @@
//It's easier to break out of a grab by a smaller mob
break_strength += max(size_difference(affecting, assailant), 0)
var/break_chance = break_chance_table[CLAMP(break_strength, 1, break_chance_table.len)]
var/break_chance = break_chance_table[clamp(break_strength, 1, break_chance_table.len)]
if(prob(break_chance))
if(state == GRAB_KILL)
reset_kill_state()

View File

@@ -61,7 +61,7 @@
to_chat(target, "<span class='danger'>You feel extreme pain!</span>")
var/max_halloss = round(target.species.total_health * 0.8) //up to 80% of passing out
affecting.adjustHalLoss(CLAMP(max_halloss - affecting.halloss, 0, 30))
affecting.adjustHalLoss(clamp(max_halloss - affecting.halloss, 0, 30))
/obj/item/weapon/grab/proc/attack_eye(mob/living/carbon/human/target, mob/living/carbon/human/attacker)
if(!istype(attacker))

View File

@@ -144,7 +144,7 @@ var/list/organ_cache = list()
owner.death()
/obj/item/organ/proc/adjust_germ_level(var/amount) // Unless you're setting germ level directly to 0, use this proc instead
germ_level = CLAMP(germ_level + amount, 0, INFECTION_LEVEL_MAX)
germ_level = clamp(germ_level + amount, 0, INFECTION_LEVEL_MAX)
/obj/item/organ/process()

View File

@@ -114,7 +114,7 @@
else if(amount > 0)
last_strain_increase = world.time
strain = CLAMP(strain + amount, 0, min_broken_damage)
strain = clamp(strain + amount, 0, min_broken_damage)
/obj/item/organ/internal/regennetwork/process()
..()

View File

@@ -48,7 +48,7 @@
adjust_plasma(1)
/obj/item/organ/internal/xenos/plasmavessel/proc/adjust_plasma(var/amount = 0)
stored_plasma = CLAMP(stored_plasma + amount, 0, max_plasma)
stored_plasma = clamp(stored_plasma + amount, 0, max_plasma)
/obj/item/organ/internal/xenos/plasmavessel/grey
icon_state = "plasma_grey"

View File

@@ -59,13 +59,13 @@
var/newlim = input("Input new thrust limit (0..100%)", "Thrust limit", linked.thrust_limit*100) as num
if(!CanInteract(user, state))
return TOPIC_NOACTION
linked.thrust_limit = CLAMP(newlim/100, 0, 1)
linked.thrust_limit = clamp(newlim/100, 0, 1)
for(var/datum/ship_engine/E in linked.engines)
E.set_thrust_limit(linked.thrust_limit)
return TOPIC_REFRESH
if(href_list["global_limit"])
linked.thrust_limit = CLAMP(linked.thrust_limit + text2num(href_list["global_limit"]), 0, 1)
linked.thrust_limit = clamp(linked.thrust_limit + text2num(href_list["global_limit"]), 0, 1)
for(var/datum/ship_engine/E in linked.engines)
E.set_thrust_limit(linked.thrust_limit)
return TOPIC_REFRESH
@@ -76,13 +76,13 @@
var/newlim = input("Input new thrust limit (0..100)", "Thrust limit", E.get_thrust_limit()) as num
if(!CanInteract(user, state))
return
var/limit = CLAMP(newlim/100, 0, 1)
var/limit = clamp(newlim/100, 0, 1)
if(istype(E))
E.set_thrust_limit(limit)
return TOPIC_REFRESH
if(href_list["limit"])
var/datum/ship_engine/E = locate(href_list["engine"])
var/limit = CLAMP(E.get_thrust_limit() + text2num(href_list["limit"]), 0, 1)
var/limit = clamp(E.get_thrust_limit() + text2num(href_list["limit"]), 0, 1)
if(istype(E))
E.set_thrust_limit(limit)
return TOPIC_REFRESH

View File

@@ -163,8 +163,8 @@ GLOBAL_LIST_EMPTY(all_waypoints)
var/newy = input("Input new entry y coordinate", "Coordinate input", linked.y) as num
if(!CanInteract(user,state))
return TOPIC_NOACTION
R.fields["x"] = CLAMP(newx, 1, world.maxx)
R.fields["y"] = CLAMP(newy, 1, world.maxy)
R.fields["x"] = clamp(newx, 1, world.maxx)
R.fields["y"] = clamp(newy, 1, world.maxy)
known_sectors[sec_name] = R
if (href_list["remove"])
@@ -178,14 +178,14 @@ GLOBAL_LIST_EMPTY(all_waypoints)
if(!CanInteract(user,state))
return
if (newx)
dx = CLAMP(newx, 1, world.maxx)
dx = clamp(newx, 1, world.maxx)
if (href_list["sety"])
var/newy = input("Input new destiniation y coordinate", "Coordinate input", dy) as num|null
if(!CanInteract(user,state))
return
if (newy)
dy = CLAMP(newy, 1, world.maxy)
dy = clamp(newy, 1, world.maxy)
if (href_list["x"] && href_list["y"])
dx = text2num(href_list["x"])
@@ -198,7 +198,7 @@ GLOBAL_LIST_EMPTY(all_waypoints)
if (href_list["speedlimit"])
var/newlimit = input("Input new speed limit for autopilot (0 to brake)", "Autopilot speed limit", speedlimit*1000) as num|null
if(newlimit)
speedlimit = CLAMP(newlimit/1000, 0, 100)
speedlimit = clamp(newlimit/1000, 0, 100)
if (href_list["accellimit"])
var/newlimit = input("Input new acceleration limit", "Acceleration limit", accellimit*1000) as num|null
if(newlimit)

View File

@@ -91,7 +91,7 @@
if(!CanInteract(user,state))
return TOPIC_NOACTION
if (nrange)
sensors.set_range(CLAMP(nrange, 1, world.view))
sensors.set_range(clamp(nrange, 1, world.view))
return TOPIC_REFRESH
if (href_list["toggle"])
sensors.toggle()

View File

@@ -175,11 +175,11 @@
/obj/machinery/atmospherics/unary/engine/RefreshParts()
..()
//allows them to upgrade the max limit of fuel intake (which only gives diminishing returns) for increase in max thrust but massive reduction in fuel economy
var/bin_upgrade = 5 * CLAMP(total_component_rating_of_type(/obj/item/weapon/stock_parts/matter_bin), 0, 6)//5 litre per rank
var/bin_upgrade = 5 * clamp(total_component_rating_of_type(/obj/item/weapon/stock_parts/matter_bin), 0, 6)//5 litre per rank
volume_per_burn = bin_upgrade ? initial(volume_per_burn) + bin_upgrade : 2 //Penalty missing part: 10% fuel use, no thrust
boot_time = bin_upgrade ? initial(boot_time) - bin_upgrade : initial(boot_time) * 2
//energy cost - thb all of this is to limit the use of back up batteries
var/energy_upgrade = CLAMP(total_component_rating_of_type(/obj/item/weapon/stock_parts/capacitor), 0.1, 6)
var/energy_upgrade = clamp(total_component_rating_of_type(/obj/item/weapon/stock_parts/capacitor), 0.1, 6)
charge_per_burn = initial(charge_per_burn) / energy_upgrade
change_power_consumption(initial(idle_power_usage) / energy_upgrade, USE_POWER_IDLE)

View File

@@ -1,6 +1,6 @@
#define SHIP_MOVE_RESOLUTION 0.00001
#define MOVING(speed) abs(speed) >= min_speed
#define SANITIZE_SPEED(speed) SIGN(speed) * CLAMP(abs(speed), 0, max_speed)
#define SANITIZE_SPEED(speed) SIGN(speed) * clamp(abs(speed), 0, max_speed)
#define CHANGE_SPEED_BY(speed_var, v_diff) \
v_diff = SANITIZE_SPEED(v_diff);\
if(!MOVING(speed_var + v_diff)) \

View File

@@ -120,7 +120,7 @@ GLOBAL_LIST_EMPTY(fusion_cores)
. = owned_field.bullet_act(Proj)
/obj/machinery/power/fusion_core/proc/set_strength(var/value)
value = CLAMP(value, MIN_FIELD_STR, MAX_FIELD_STR)
value = clamp(value, MIN_FIELD_STR, MAX_FIELD_STR)
if(field_strength != value)
field_strength = value

View File

@@ -162,7 +162,7 @@
return
if(href_list["access_device"])
var/idx = CLAMP(text2num(href_list["toggle_active"]), 1, connected_devices.len)
var/idx = clamp(text2num(href_list["toggle_active"]), 1, connected_devices.len)
cur_viewed_device = connected_devices[idx]
updateUsrDialog()
return 1

View File

@@ -94,7 +94,7 @@
if(!new_val)
to_chat(usr, "<span class='warning'>That's not a valid number.</span>")
return 1
G.mega_energy = CLAMP(new_val, 1, 50)
G.mega_energy = clamp(new_val, 1, 50)
G.update_active_power_usage(G.mega_energy * 1500)
updateUsrDialog()
return 1
@@ -104,7 +104,7 @@
if(!new_val)
to_chat(usr, "<span class='warning'>That's not a valid number.</span>")
return 1
G.rate = CLAMP(new_val, 1, 10)
G.rate = clamp(new_val, 1, 10)
updateUsrDialog()
return 1

View File

@@ -152,7 +152,7 @@
if(energy)
SSradiation.radiate(src, round(((src.energy-150)/50)*5,1))
energy = CLAMP(energy - 5, 0, max_energy)
energy = clamp(energy - 5, 0, max_energy)
return

View File

@@ -158,7 +158,7 @@ GLOBAL_LIST_EMPTY(smeses)
//inputting
if(input_attempt && (!input_pulsed && !input_cut) && !grid_check)
target_load = CLAMP((capacity-charge)/SMESRATE, 0, input_level) // Amount we will request from the powernet.
target_load = clamp((capacity-charge)/SMESRATE, 0, input_level) // Amount we will request from the powernet.
var/input_available = FALSE
for(var/obj/machinery/power/terminal/term in terminals)
if(!term.powernet)

View File

@@ -303,7 +303,7 @@
// Volume will be 1 at no power, ~12.5 at ENERGY_NITROGEN, and 20+ at ENERGY_PHORON.
// Capped to 20 volume since higher volumes get annoying and it sounds worse.
// Formula previously was min(round(power/10)+1, 20)
soundloop.volume = CLAMP((50 + (power / 50)), 50, 100)
soundloop.volume = clamp((50 + (power / 50)), 50, 100)
// Swap loops between calm and delamming.
if(damage >= 300)

View File

@@ -62,7 +62,7 @@
set_dir(tesla_zap(src.loc, 7, TESLA_DEFAULT_POWER, TRUE))
for (var/ball in orbiting_balls)
var/range = rand(1, CLAMP(orbiting_balls.len, 3, 7))
var/range = rand(1, clamp(orbiting_balls.len, 3, 7))
tesla_zap(ball, range, TESLA_MINI_POWER/7*range, TRUE)
else
energy = 0 // ensure we dont have miniballs of miniballs
@@ -279,7 +279,7 @@
closest_grounding_rod.tesla_act(power, explosive, stun_mobs)
else if(closest_mob)
var/shock_damage = CLAMP(round(power/400), 10, 90) + rand(-5, 5)
var/shock_damage = clamp(round(power/400), 10, 90) + rand(-5, 5)
closest_mob.electrocute_act(shock_damage, source, 1 - closest_mob.get_shock_protection(), ran_zone())
log_game("TESLA([source.x],[source.y],[source.z]) Shocked [key_name(closest_mob)] for [shock_damage]dmg.")
message_admins("Tesla zapped [key_name_admin(closest_mob)]!")

View File

@@ -241,10 +241,10 @@
if(!homing_target)
return FALSE
var/datum/point/PT = RETURN_PRECISE_POINT(homing_target)
PT.x += CLAMP(homing_offset_x, 1, world.maxx)
PT.y += CLAMP(homing_offset_y, 1, world.maxy)
PT.x += clamp(homing_offset_x, 1, world.maxx)
PT.y += clamp(homing_offset_y, 1, world.maxy)
var/angle = closer_angle_difference(Angle, angle_between_points(RETURN_PRECISE_POINT(src), PT))
setAngle(Angle + CLAMP(angle, -homing_turn_speed, homing_turn_speed))
setAngle(Angle + clamp(angle, -homing_turn_speed, homing_turn_speed))
/obj/item/projectile/proc/set_homing_target(atom/A)
if(!A || (!isturf(A) && !isturf(A.loc)))
@@ -322,7 +322,7 @@
crash_with("WARNING: Projectile [type] deleted due to being unable to resolve a target after angle was null!")
qdel(src)
return
var/turf/target = locate(CLAMP(starting + xo, 1, world.maxx), CLAMP(starting + yo, 1, world.maxy), starting.z)
var/turf/target = locate(clamp(starting + xo, 1, world.maxx), clamp(starting + yo, 1, world.maxy), starting.z)
setAngle(Get_Angle(src, target))
if(dispersion)
setAngle(Angle + rand(-dispersion, dispersion))
@@ -464,7 +464,7 @@
// Multiply projectile damage by 1.2, then CLAMP the value between 30 and 100.
// This was 0.67 but in practice it made all projectiles that did 45 or less damage play at 30,
// which is hard to hear over the gunshots, and is rather rare for a projectile to do that much.
return CLAMP((value_to_use) * 1.2, 30, 100)
return clamp((value_to_use) * 1.2, 30, 100)
else
return 50 //if the projectile doesn't do damage or agony, play its hitsound at 50% volume.
@@ -812,7 +812,7 @@
/obj/item/projectile/proc/impact_sounds(atom/A)
if(hitsound_wall && !ismob(A)) // Mob sounds are handled in attack_mob().
var/volume = CLAMP(vol_by_damage() + 20, 0, 100)
var/volume = clamp(vol_by_damage() + 20, 0, 100)
if(silenced)
volume = 5
playsound(A, hitsound_wall, volume, 1, -1)

View File

@@ -113,7 +113,7 @@
subdivide(iteration, x, y+hsize, hsize)
subdivide(iteration, x+hsize, y+hsize, hsize)
#define NOISE2VALUE(X) CLAMP(round(((X)/cell_range)*10), 0, 9)
#define NOISE2VALUE(X) clamp(round(((X)/cell_range)*10), 0, 9)
/datum/random_map/noise/cleanup()
var/is_not_border_left
var/is_not_border_right

View File

@@ -197,7 +197,7 @@
if(!num)
return
arguments["num"] = num
var/amount_per_pill = CLAMP(reagents.total_volume / num, 0, MAX_UNITS_PER_PILL)
var/amount_per_pill = clamp(reagents.total_volume / num, 0, MAX_UNITS_PER_PILL)
var/default_name = "[reagents.get_master_reagent_name()] ([amount_per_pill]u)"
var/pills_text = num == 1 ? "new pill" : "[num] new pills"
tgui_modal_input(src, id, "Please name your [pills_text]:", null, arguments, default_name, MAX_CUSTOM_NAME_LEN)
@@ -217,7 +217,7 @@
if(!num)
return
arguments["num"] = num
var/amount_per_patch = CLAMP(reagents.total_volume / num, 0, MAX_UNITS_PER_PATCH)
var/amount_per_patch = clamp(reagents.total_volume / num, 0, MAX_UNITS_PER_PATCH)
var/default_name = "[reagents.get_master_reagent_name()] ([amount_per_patch]u)"
var/patches_text = num == 1 ? "new patch" : "[num] new patches"
tgui_modal_input(src, id, "Please name your [patches_text]:", null, arguments, default_name, MAX_CUSTOM_NAME_LEN)
@@ -232,7 +232,7 @@
if(!num)
return
arguments["num"] = num
var/amount_per_bottle = CLAMP(reagents.total_volume / num, 0, MAX_UNITS_PER_BOTTLE)
var/amount_per_bottle = clamp(reagents.total_volume / num, 0, MAX_UNITS_PER_BOTTLE)
var/default_name = "[reagents.get_master_reagent_name()]"
var/bottles_text = num == 1 ? "new bottle" : "[num] new bottles"
tgui_modal_input(src, id, "Please name your [bottles_text] ([amount_per_bottle]u in bottle):", null, arguments, default_name, MAX_CUSTOM_NAME_LEN)
@@ -288,13 +288,13 @@
if("create_pill")
if(condi || !reagents.total_volume)
return
var/count = CLAMP(round(text2num(arguments["num"]) || 0), 0, MAX_MULTI_AMOUNT)
var/count = clamp(round(text2num(arguments["num"]) || 0), 0, MAX_MULTI_AMOUNT)
if(!count)
return
if(!length(answer))
answer = reagents.get_master_reagent_name()
var/amount_per_pill = CLAMP(reagents.total_volume / count, 0, MAX_UNITS_PER_PILL)
var/amount_per_pill = clamp(reagents.total_volume / count, 0, MAX_UNITS_PER_PILL)
while(count--)
if(reagents.total_volume <= 0)
to_chat(usr, "<span class='notice'>Not enough reagents to create these pills!</span>")
@@ -316,20 +316,20 @@
return
tgui_act("modal_open", list("id" = "create_pill", "arguments" = list("num" = answer)), ui, state)
if("change_pill_style")
var/new_style = CLAMP(text2num(answer) || 0, 0, MAX_PILL_SPRITE)
var/new_style = clamp(text2num(answer) || 0, 0, MAX_PILL_SPRITE)
if(!new_style)
return
pillsprite = new_style
if("create_patch")
if(condi || !reagents.total_volume)
return
var/count = CLAMP(round(text2num(arguments["num"]) || 0), 0, MAX_MULTI_AMOUNT)
var/count = clamp(round(text2num(arguments["num"]) || 0), 0, MAX_MULTI_AMOUNT)
if(!count)
return
if(!length(answer))
answer = reagents.get_master_reagent_name()
var/amount_per_patch = CLAMP(reagents.total_volume / count, 0, MAX_UNITS_PER_PATCH)
var/amount_per_patch = clamp(reagents.total_volume / count, 0, MAX_UNITS_PER_PATCH)
// var/is_medical_patch = chemical_safety_check(reagents)
while(count--)
if(reagents.total_volume <= 0)
@@ -351,13 +351,13 @@
if("create_bottle")
if(condi || !reagents.total_volume)
return
var/count = CLAMP(round(text2num(arguments["num"]) || 0), 0, MAX_MULTI_AMOUNT)
var/count = clamp(round(text2num(arguments["num"]) || 0), 0, MAX_MULTI_AMOUNT)
if(!count)
return
if(!length(answer))
answer = reagents.get_master_reagent_name()
var/amount_per_bottle = CLAMP(reagents.total_volume / count, 0, MAX_UNITS_PER_BOTTLE)
var/amount_per_bottle = clamp(reagents.total_volume / count, 0, MAX_UNITS_PER_BOTTLE)
while(count--)
if(reagents.total_volume <= 0)
to_chat(usr, "<span class='notice'>Not enough reagents to create these bottles!</span>")
@@ -374,7 +374,7 @@
return
tgui_act("modal_open", list("id" = "create_bottle", "arguments" = list("num" = answer)), ui, state)
if("change_bottle_style")
var/new_style = CLAMP(text2num(answer) || 0, 0, MAX_BOTTLE_SPRITE)
var/new_style = clamp(text2num(answer) || 0, 0, MAX_BOTTLE_SPRITE)
if(!new_style)
return
bottlesprite = new_style

View File

@@ -205,7 +205,7 @@
if("adjust temp")
target_temp = input("Choose a target temperature.", "Temperature.", T20C) as num
target_temp = CLAMP(target_temp, min_temp, max_temp)
target_temp = clamp(target_temp, min_temp, max_temp)
update_icon()
@@ -310,7 +310,7 @@
// As of initial testing, a *10 gives ~5-6 minutes to go from room temp to 500C (+/-0.5C)
var/temp_diff = (current_temp < target_temp ? dy * 10 * target_temp / current_temp : dy * -10 * current_temp / target_temp)
current_temp = CLAMP(round((current_temp + temp_diff), 0.01), min_temp, max_temp)
current_temp = clamp(round((current_temp + temp_diff), 0.01), min_temp, max_temp)
use_power(power_rating * CELLRATE)
if(target_temp == round(current_temp, 1.0))

View File

@@ -542,7 +542,7 @@
if(iscarbon(M) && !M.isSynthetic())
var/message = pick("Oh god, it smells disgusting here.", "What is that stench?", "That's an awful odor.")
to_chat(M, "<span class='alien'>[message]</span>")
if(prob(CLAMP(amount, 5, 90)))
if(prob(clamp(amount, 5, 90)))
var/mob/living/L = M
L.vomit()
return ..()

View File

@@ -796,7 +796,7 @@
if(H.losebreath >= 15 && prob(H.losebreath))
H.Stun(2)
else
H.losebreath = CLAMP(H.losebreath + 3, 0, 20)
H.losebreath = clamp(H.losebreath + 3, 0, 20)
else
H.losebreath = max(H.losebreath - 4, 0)
@@ -891,7 +891,7 @@
I.damage = max(I.damage - 4 * removed * repair_strength, 0)
H.Confuse(2)
if(M.reagents.has_reagent("respirodaxon") || M.reagents.has_reagent("peridaxon"))
H.losebreath = CLAMP(H.losebreath + 1, 0, 10)
H.losebreath = clamp(H.losebreath + 1, 0, 10)
else
H.adjustOxyLoss(-30 * removed) // Deals with blood oxygenation.

View File

@@ -91,7 +91,7 @@
if("change_supplied_law_position")
var/new_position = input(usr, "Enter new supplied law position between 1 and [MAX_SUPPLIED_LAW_NUMBER], inclusive. Inherent laws at the same index as a supplied law will not be stated.", "Law Position", supplied_law_position) as num|null
if(isnum(new_position) && can_still_topic(usr, state))
supplied_law_position = CLAMP(new_position, 1, MAX_SUPPLIED_LAW_NUMBER)
supplied_law_position = clamp(new_position, 1, MAX_SUPPLIED_LAW_NUMBER)
return TRUE
if("edit_law")

View File

@@ -242,7 +242,7 @@ GLOBAL_DATUM_INIT(iconCache, /savefile, new("data/iconCache.sav")) //Cache of ic
data = debugmsg(arglist(params))
if(href_list["showingnum"])
message_buffer = CLAMP(text2num(href_list["showingnum"]), 50, 2000)
message_buffer = clamp(text2num(href_list["showingnum"]), 50, 2000)
if(data)
send_event(event = data)

View File

@@ -310,7 +310,7 @@ upon code review):
if("copypasta")
var/newvar = params["var"]
// A demo of proper input sanitation.
var = CLAMP(newvar, min_val, max_val)
var = clamp(newvar, min_val, max_val)
. = TRUE
update_icon() // Not applicable to all objects.
```