Makes math helpers defines for performance (#5654)

This commit is contained in:
kevinz000
2018-12-06 13:13:59 -08:00
committed by Atermonera
parent ec57465a5c
commit 8da11c17a2
48 changed files with 911 additions and 849 deletions

View File

@@ -239,7 +239,7 @@ proc/admin_notice(var/message, var/rights)
// Display the notes on the current page
var/number_pages = note_keys.len / PLAYER_NOTES_ENTRIES_PER_PAGE
// Emulate ceil(why does BYOND not have ceil)
// Emulate CEILING(why does BYOND not have ceil, 1)
if(number_pages != round(number_pages))
number_pages = round(number_pages) + 1
var/page_index = page - 1

View File

@@ -545,7 +545,7 @@
data["charge"] = cell ? round(cell.charge,1) : 0
data["maxcharge"] = cell ? cell.maxcharge : 0
data["chargestatus"] = cell ? Floor((cell.charge/cell.maxcharge)*50) : 0
data["chargestatus"] = cell ? FLOOR((cell.charge/cell.maxcharge)*50, 1) : 0
data["emagged"] = subverted
data["coverlock"] = locked

View File

@@ -33,7 +33,7 @@
kill()
return
if(IsMultiple(activeFor, 5))
if(ISMULTIPLE(activeFor, 5))
if(prob(15))
var/obj/machinery/vending/infectedMachine = pick(vendingMachines)
vendingMachines.Remove(infectedMachine)
@@ -41,7 +41,7 @@
infectedMachine.shut_up = 0
infectedMachine.shoot_inventory = 1
if(IsMultiple(activeFor, 12))
if(ISMULTIPLE(activeFor, 12))
originMachine.speak(pick("Try our aggressive new marketing strategies!", \
"You should buy products to feed your lifestyle obsession!", \
"Consume!", \

View File

@@ -171,7 +171,7 @@
cooking_obj = null
else
var/failed
var/overcook_period = max(Floor(cook_time/5),1)
var/overcook_period = max(FLOOR(cook_time/5, 1),1)
cooking_obj = result
var/count = overcook_period
while(1)

View File

@@ -32,7 +32,7 @@
var/activeness = ((metric.assess_department(ROLE_SECURITY) + metric.assess_department(ROLE_ENGINEERING) + metric.assess_department(ROLE_MEDICAL)) / 3)
activeness = max(activeness, 20)
carp_amount = Ceiling(station_strength * (activeness / 100) + 1)
carp_amount = CEILING(station_strength * (activeness / 100) + 1, 1)
/datum/gm_action/carp_migration/start()
..()

View File

@@ -413,7 +413,7 @@
overlays += I
return
var/offset = Floor(20/cards.len)
var/offset = FLOOR(20/cards.len, 1)
var/matrix/M = matrix()
if(direction)

View File

@@ -265,7 +265,7 @@
pull_data()
var/incoming = get_pin_data(IC_INPUT, 1)
if(!isnull(incoming))
result = ToDegrees(incoming)
result = TODEGREES(incoming)
set_pin_data(IC_OUTPUT, 1, result)
push_data()
@@ -283,7 +283,7 @@
pull_data()
var/incoming = get_pin_data(IC_INPUT, 1)
if(!isnull(incoming))
result = ToRadians(incoming)
result = TORADIANS(incoming)
set_pin_data(IC_OUTPUT, 1, result)
push_data()

View File

@@ -71,7 +71,7 @@
var/result = null
var/A = get_pin_data(IC_INPUT, 1)
if(!isnull(A))
result = Tan(A)
result = TAN(A)
set_pin_data(IC_OUTPUT, 1, result)
push_data()
@@ -91,7 +91,7 @@
var/result = null
var/A = get_pin_data(IC_INPUT, 1)
if(!isnull(A))
result = Csc(A)
result = CSC(A)
set_pin_data(IC_OUTPUT, 1, result)
push_data()
@@ -112,7 +112,7 @@
var/result = null
var/A = get_pin_data(IC_INPUT, 1)
if(!isnull(A))
result = Sec(A)
result = SEC(A)
set_pin_data(IC_OUTPUT, 1, result)
push_data()
@@ -133,7 +133,7 @@
var/result = null
var/A = get_pin_data(IC_INPUT, 1)
if(!isnull(A))
result = Cot(A)
result = COT(A)
set_pin_data(IC_OUTPUT, 1, result)
push_data()

View File

@@ -202,7 +202,7 @@ var/list/mining_overlay_cache = list()
if(severity <= 2) // Now to expose the ore lying under the sand.
spawn(1) // Otherwise most of the ore is lost to the explosion, which makes this rather moot.
for(var/ore in resources)
var/amount_to_give = rand(Ceiling(resources[ore]/2), resources[ore]) // Should result in at least one piece of ore.
var/amount_to_give = rand(CEILING(resources[ore]/2, 1), resources[ore]) // Should result in at least one piece of ore.
for(var/i=1, i <= amount_to_give, i++)
var/oretype = ore_types[ore]
new oretype(src)

View File

@@ -32,7 +32,7 @@
for(var/i = 0;i<name_count;i++)
new_name = ""
for(var/x = rand(Floor(syllable_count/syllable_divisor),syllable_count);x>0;x--)
for(var/x = rand(FLOOR(syllable_count/syllable_divisor, 1),syllable_count);x>0;x--)
new_name += pick(syllables)
full_name += " [capitalize(lowertext(new_name))]"

View File

@@ -363,7 +363,7 @@
stop_pulling()
src << "<span class='warning'>You slipped on [slipped_on]!</span>"
playsound(src.loc, 'sound/misc/slip.ogg', 50, 1, -3)
Weaken(Floor(stun_duration/2))
Weaken(FLOOR(stun_duration/2, 1))
return 1
/mob/living/carbon/proc/add_chemical_effect(var/effect, var/magnitude = 1)

View File

@@ -34,7 +34,7 @@
chargen_value_descriptors = list()
for(var/i = 1 to LAZYLEN(standalone_value_descriptors))
chargen_value_descriptors[standalone_value_descriptors[i]] = i
default_value = ceil(LAZYLEN(standalone_value_descriptors) * 0.5)
default_value = CEILING(LAZYLEN(standalone_value_descriptors) * 0.5, 1)
..()
/datum/mob_descriptor/proc/get_third_person_message_start(var/datum/gender/my_gender)
@@ -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(ceil(value * maxval), 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(ceil(value * maxval), 1, maxval)
value = Clamp(CEILING(value * maxval, 1), 1, maxval)
return comparative_value_descriptors_larger[value]

View File

@@ -165,4 +165,4 @@
else
src << "<span class='notice'>I am not ready to reproduce yet...</span>"
else
src << "<span class='notice'>I am not old enough to reproduce yet...</span>"
src << "<span class='notice'>I am not old enough to reproduce yet...</span>"

View File

@@ -674,7 +674,7 @@
//Robots take half damage from basic attacks.
/mob/living/silicon/robot/attack_generic(var/mob/user, var/damage, var/attack_message)
return ..(user,Floor(damage/2),attack_message)
return ..(user,FLOOR(damage/2, 1),attack_message)
/mob/living/silicon/robot/proc/allowed(mob/M)
//check if it doesn't require any access at all

View File

@@ -188,9 +188,9 @@ Nurse Family
for(var/I = 1 to spiderling_count)
if(prob(10) && src)
var/mob/living/simple_animal/hostile/giant_spider/swarmling = new swarmling_type(src.loc)
var/swarm_health = Floor(swarmling.maxHealth * 0.4)
var/swarm_dam_lower = Floor(melee_damage_lower * 0.4)
var/swarm_dam_upper = Floor(melee_damage_upper * 0.4)
var/swarm_health = FLOOR(swarmling.maxHealth * 0.4, 1)
var/swarm_dam_lower = FLOOR(melee_damage_lower * 0.4, 1)
var/swarm_dam_upper = FLOOR(melee_damage_upper * 0.4, 1)
swarmling.name = "spiderling"
swarmling.maxHealth = swarm_health
swarmling.health = swarm_health

View File

@@ -38,9 +38,9 @@
for(var/i = 1 to spiderling_count)
if(prob(swarmling_prob) && src)
var/mob/living/simple_mob/animal/giant_spider/swarmling = new swarmling_type(src.loc)
var/swarm_health = Floor(swarmling.maxHealth * 0.4)
var/swarm_dam_lower = Floor(melee_damage_lower * 0.4)
var/swarm_dam_upper = Floor(melee_damage_upper * 0.4)
var/swarm_health = FLOOR(swarmling.maxHealth * 0.4, 1)
var/swarm_dam_lower = FLOOR(melee_damage_lower * 0.4, 1)
var/swarm_dam_upper = FLOOR(melee_damage_upper * 0.4, 1)
swarmling.name = "spiderling"
swarmling.maxHealth = swarm_health
swarmling.health = swarm_health

View File

@@ -275,5 +275,5 @@ var/list/robot_hud_colours = list("#CFCFCF","#AFAFAF","#8F8F8F","#6F6F6F","#4F4F
dam_state = min_dam_state
// Apply colour and return product.
var/list/hud_colours = (robotic < ORGAN_ROBOT) ? flesh_hud_colours : robot_hud_colours
hud_damage_image.color = hud_colours[max(1,min(ceil(dam_state*hud_colours.len),hud_colours.len))]
hud_damage_image.color = hud_colours[max(1,min(CEILING(dam_state*hud_colours.len, 1),hud_colours.len))]
return hud_damage_image

View File

@@ -137,7 +137,7 @@
else
icon_state = "shredder-off"
// Fullness overlay
overlays += "shredder-[max(0,min(5,Floor(paperamount/max_paper*5)))]"
overlays += "shredder-[max(0,min(5,FLOOR(paperamount/max_paper*5, 1)))]"
if (panel_open)
overlays += "panel_open"

View File

@@ -70,12 +70,12 @@ var/datum/planet/sif/planet_sif = null
high_color = "#FFFFFF"
min = 0.70
var/lerp_weight = (abs(min - sun_position)) * 4
var/interpolate_weight = (abs(min - sun_position)) * 4
var/weather_light_modifier = 1
if(weather_holder && weather_holder.current_weather)
weather_light_modifier = weather_holder.current_weather.light_modifier
var/new_brightness = (Interpolate(low_brightness, high_brightness, weight = lerp_weight) ) * weather_light_modifier
var/new_brightness = (LERP(low_brightness, high_brightness, interpolate_weight) ) * weather_light_modifier
var/new_color = null
if(weather_holder && weather_holder.current_weather && weather_holder.current_weather.light_color)
@@ -91,9 +91,9 @@ var/datum/planet/sif/planet_sif = null
var/high_g = high_color_list[2]
var/high_b = high_color_list[3]
var/new_r = Interpolate(low_r, high_r, weight = lerp_weight)
var/new_g = Interpolate(low_g, high_g, weight = lerp_weight)
var/new_b = Interpolate(low_b, high_b, weight = lerp_weight)
var/new_r = LERP(low_r, high_r, interpolate_weight)
var/new_g = LERP(low_g, high_g, interpolate_weight)
var/new_b = LERP(low_b, high_b, interpolate_weight)
new_color = rgb(new_r, new_g, new_b)

View File

@@ -54,15 +54,15 @@
var/seconds = remaining_hour % seconds_in_minute / 10
var/hour_text = num2text(Floor(hours))
var/hour_text = num2text(FLOOR(hours, 1))
if(length(hour_text) < 2)
hour_text = "0[hour_text]" // Add padding if needed, to look more like time2text().
var/minute_text = num2text(Floor(minutes))
var/minute_text = num2text(FLOOR(minutes, 1))
if(length(minute_text) < 2)
minute_text = "0[minute_text]"
var/second_text = num2text(Floor(seconds))
var/second_text = num2text(FLOOR(seconds, 1))
if(length(second_text) < 2)
second_text = "0[second_text]"

View File

@@ -98,7 +98,7 @@
visuals.icon_state = current_weather.icon_state
/datum/weather_holder/proc/update_temperature()
temperature = Interpolate(current_weather.temp_low, current_weather.temp_high, weight = our_planet.sun_position)
temperature = LERP(current_weather.temp_low, current_weather.temp_high, our_planet.sun_position)
our_planet.needs_work |= PLANET_PROCESS_TEMP
/datum/weather_holder/proc/get_weather_datum(desired_type)

View File

@@ -532,7 +532,7 @@ obj/structure/cable/proc/cableColor(var/colorC)
if(!S || S.robotic < ORGAN_ROBOT || S.open == 3)
return ..()
var/use_amt = min(src.amount, ceil(S.burn_dam/5), 5)
var/use_amt = min(src.amount, CEILING(S.burn_dam/5, 1), 5)
if(can_use(use_amt))
if(S.robo_repair(5*use_amt, BURN, "some damaged wiring", src, user))
src.use(use_amt)

View File

@@ -171,8 +171,8 @@
use_power = light_max_power
else
var/temp_mod = ((plasma_temperature-5000)/20000)
use_range = light_min_range + ceil((light_max_range-light_min_range)*temp_mod)
use_power = light_min_power + ceil((light_max_power-light_min_power)*temp_mod)
use_range = light_min_range + CEILING((light_max_range-light_min_range)*temp_mod, 1)
use_power = light_min_power + CEILING((light_max_power-light_min_power)*temp_mod, 1)
if(last_range != use_range || last_power != use_power)
set_light(use_range,use_power)
@@ -318,8 +318,8 @@
/obj/effect/fusion_em_field/proc/Radiate()
if(istype(loc, /turf))
var/empsev = max(1, min(3, ceil(size/2)))
for(var/atom/movable/AM in range(max(1,Floor(size/2)), loc))
var/empsev = max(1, min(3, CEILING(size/2, 1)))
for(var/atom/movable/AM in range(max(1,FLOOR(size/2, 1)), loc))
if(AM == src || AM == owned_core || !AM.simulated)
continue
@@ -386,7 +386,7 @@
//determine a random amount to actually react this cycle, and remove it from the standard pool
//this is a hack, and quite nonrealistic :(
for(var/reactant in react_pool)
react_pool[reactant] = rand(Floor(react_pool[reactant]/2),react_pool[reactant])
react_pool[reactant] = rand(FLOOR(react_pool[reactant]/2, 1),react_pool[reactant])
dormant_reactant_quantities[reactant] -= react_pool[reactant]
if(!react_pool[reactant])
react_pool -= reactant
@@ -574,7 +574,7 @@
/obj/effect/fusion_em_field/proc/Rupture()
visible_message("<span class='danger'>\The [src] shudders like a dying animal before flaring to eye-searing brightness and rupturing!</span>")
set_light(15, 15, "#CCCCFF")
empulse(get_turf(src), ceil(plasma_temperature/1000), ceil(plasma_temperature/300))
empulse(get_turf(src), CEILING(plasma_temperature/1000, 1), CEILING(plasma_temperature/300, 1))
global_announcer.autosay("WARNING: FIELD RUPTURE IMMINENT!", "Containment Monitor")
RadiateAll()
var/list/things_in_range = range(10, owned_core)
@@ -584,7 +584,7 @@
turfs_in_range.Add(T)
explosion(pick(things_in_range), -1, 5, 5, 5)
empulse(pick(things_in_range), ceil(plasma_temperature/1000), ceil(plasma_temperature/300))
empulse(pick(things_in_range), CEILING(plasma_temperature/1000, 1), CEILING(plasma_temperature/300, 1))
spawn(25)
explosion(pick(things_in_range), -1, 5, 5, 5)
spawn(25)
@@ -655,7 +655,7 @@
/obj/effect/fusion_em_field/proc/BluespaceQuenchEvent() //!!FUN!! causes a number of explosions in an area around the core. Will likely destory or heavily damage the reactor.
visible_message("<span class='danger'>\The [src] shudders like a dying animal before flaring to eye-searing brightness and rupturing!</span>")
set_light(15, 15, "#CCCCFF")
empulse(get_turf(src), ceil(plasma_temperature/1000), ceil(plasma_temperature/300))
empulse(get_turf(src), CEILING(plasma_temperature/1000, 1), CEILING(plasma_temperature/300, 1))
global_announcer.autosay("WARNING: FIELD RUPTURE IMMINENT!", "Containment Monitor")
RadiateAll()
var/list/things_in_range = range(10, owned_core)
@@ -665,7 +665,7 @@
turfs_in_range.Add(T)
for(var/loopcount = 1 to 10)
explosion(pick(things_in_range), -1, 5, 5, 5)
empulse(pick(things_in_range), ceil(plasma_temperature/1000), ceil(plasma_temperature/300))
empulse(pick(things_in_range), CEILING(plasma_temperature/1000, 1), CEILING(plasma_temperature/300, 1))
Destroy()
owned_core.Shutdown()
return

View File

@@ -46,7 +46,7 @@
return PROCESS_KILL
if(istype(loc, /turf))
radiation_repository.radiate(src, max(1,ceil(radioactivity/30)))
radiation_repository.radiate(src, max(1,CEILING(radioactivity/30, 1)))
/obj/item/weapon/fuel_assembly/Destroy()
processing_objects -= src

View File

@@ -207,7 +207,7 @@
return
if(istype(W, /obj/item/stack/material) && W.get_material_name() == DEFAULT_WALL_MATERIAL)
var/amt = Ceiling(( initial(integrity) - integrity)/10)
var/amt = CEILING(( initial(integrity) - integrity)/10, 1)
if(!amt)
to_chat(user, "<span class='notice'>\The [src] is already fully repaired.</span>")
return

View File

@@ -584,7 +584,7 @@
if(one_handed_penalty)
if(!held_twohanded)
acc_mod += -ceil(one_handed_penalty/2)
acc_mod += -CEILING(one_handed_penalty/2, 1)
disp_mod += one_handed_penalty*0.5 //dispersion per point of two-handedness
//Accuracy modifiers

View File

@@ -19,10 +19,10 @@
/datum/random_map/noise/set_map_size()
// Make sure the grid is a square with limits that are
// (n^2)+1, otherwise diamond-square won't work.
if(!IsPowerOfTwo((limit_x-1)))
limit_x = RoundUpToPowerOfTwo(limit_x) + 1
if(!IsPowerOfTwo((limit_y-1)))
limit_y = RoundUpToPowerOfTwo(limit_y) + 1
if(!ISPOWEROFTWO((limit_x-1)))
limit_x = ROUNDUPTOPOWEROFTWO(limit_x) + 1
if(!ISPOWEROFTWO((limit_y-1)))
limit_y = ROUNDUPTOPOWEROFTWO(limit_y) + 1
// Sides must be identical lengths.
if(limit_x > limit_y)
limit_y = limit_x

View File

@@ -70,7 +70,7 @@
/datum/reagent/toxin/hydrophoron/touch_turf(var/turf/simulated/T)
if(!istype(T))
return
T.assume_gas("phoron", ceil(volume/2), T20C)
T.assume_gas("phoron", CEILING(volume/2, 1), T20C)
for(var/turf/simulated/floor/target_tile in range(0,T))
target_tile.assume_gas("phoron", volume/2, 400+T0C)
spawn (0) target_tile.hotspot_expose(700, 400)

View File

@@ -100,7 +100,7 @@
user.setClickCooldown(user.get_attack_speed(src)) //puts a limit on how fast people can eat/drink things
self_feed_message(user)
reagents.trans_to_mob(user, issmall(user) ? ceil(amount_per_transfer_from_this/2) : amount_per_transfer_from_this, CHEM_INGEST)
reagents.trans_to_mob(user, issmall(user) ? CEILING(amount_per_transfer_from_this/2, 1) : amount_per_transfer_from_this, CHEM_INGEST)
feed_sound(user)
return 1
else

View File

@@ -154,7 +154,7 @@
// Makes shields become gradually more red as the projector's health decreases.
/obj/item/shield_projector/proc/update_shield_colors()
// This is done at the projector instead of the shields themselves to avoid needing to calculate this more than once every update.
var/lerp_weight = shield_health / max_shield_health
var/interpolate_weight = shield_health / max_shield_health
var/list/low_color_list = hex2rgb(low_color)
var/low_r = low_color_list[1]
@@ -166,9 +166,9 @@
var/high_g = high_color_list[2]
var/high_b = high_color_list[3]
var/new_r = Interpolate(low_r, high_r, weight = lerp_weight)
var/new_g = Interpolate(low_g, high_g, weight = lerp_weight)
var/new_b = Interpolate(low_b, high_b, weight = lerp_weight)
var/new_r = LERP(low_r, high_r, interpolate_weight)
var/new_g = LERP(low_g, high_g, interpolate_weight)
var/new_b = LERP(low_b, high_b, interpolate_weight)
var/new_color = rgb(new_r, new_g, new_b)

View File

@@ -88,7 +88,7 @@
if(autopilot_delay % 10 == 0) // Every ten ticks.
var/seconds_left = autopilot_delay * 2
if(seconds_left >= 60) // A minute
var/minutes_left = Floor(seconds_left / 60)
var/minutes_left = FLOOR(seconds_left / 60, 1)
seconds_left = seconds_left % 60
autopilot_say("Departing in [minutes_left] minute\s[seconds_left ? ", [seconds_left] seconds":""].")
else

View File

@@ -58,7 +58,7 @@
if(NORTH)
int_panel_x = ux + Floor(lift_size_x/2)
int_panel_x = ux + FLOOR(lift_size_x/2, 1)
int_panel_y = uy + 1
ext_panel_x = ux
ext_panel_y = ey + 2
@@ -75,7 +75,7 @@
if(SOUTH)
int_panel_x = ux + Floor(lift_size_x/2)
int_panel_x = ux + FLOOR(lift_size_x/2, 1)
int_panel_y = ey - 1
ext_panel_x = ex
ext_panel_y = uy - 2
@@ -93,7 +93,7 @@
if(EAST)
int_panel_x = ux+1
int_panel_y = uy + Floor(lift_size_y/2)
int_panel_y = uy + FLOOR(lift_size_y/2, 1)
ext_panel_x = ex+2
ext_panel_y = ey
@@ -110,7 +110,7 @@
if(WEST)
int_panel_x = ex-1
int_panel_y = uy + Floor(lift_size_y/2)
int_panel_y = uy + FLOOR(lift_size_y/2, 1)
ext_panel_x = ux-2
ext_panel_y = uy