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

@@ -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)) \