Skip to content

Commit

Permalink
round(x) deprecation for 515 (#6281)
Browse files Browse the repository at this point in the history
# About the pull request


![image](https://github.com/cmss13-devs/cmss13/assets/14267245/43d08dca-fc72-4401-aabf-ae63460074e7)
> The first format returns the floor of A (the largest integer less than
or equal to A), and has been deprecated in favor of floor(A).

https://www.byond.com/docs/ref/#/proc/round

With the move to 515, replaces any use of the one-argument `round(x)`
with `floor(x)`.

<!-- Remove this text and explain what the purpose of your PR is.

Mention if you have tested your changes. If you changed a map, make sure
you used the mapmerge tool.
If this is an Issue Correction, you can type "Fixes Issue #169420" to
link the PR to the corresponding Issue number #169420.

Remember: something that is self-evident to you might not be to others.
Explain your rationale fully, even if you feel it goes without saying.
-->

# Explain why it's good for the game

`floor(x)` clearly communicates what is actually happening, as opposed
to `round(x)` which doesn't.
# Testing Photographs and Procedure
Boots without obvious issue.


# Changelog
No player-facing changes.
  • Loading branch information
Doubleumc committed May 15, 2024
1 parent e34bcc1 commit a136f35
Show file tree
Hide file tree
Showing 219 changed files with 924 additions and 924 deletions.
2 changes: 1 addition & 1 deletion code/__DEFINES/autofire.dm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Controls how many buckets should be kept, each representing a tick. Max is ten seconds, to have better perf.
#define AUTOFIRE_BUCKET_LEN (world.fps * 10)
/// Helper for getting the correct bucket
#define AUTOFIRE_BUCKET_POS(next_fire) (((round((next_fire - SSautomatedfire.head_offset) / world.tick_lag) + 1) % AUTOFIRE_BUCKET_LEN) || AUTOFIRE_BUCKET_LEN)
#define AUTOFIRE_BUCKET_POS(next_fire) (((floor((next_fire - SSautomatedfire.head_offset) / world.tick_lag) + 1) % AUTOFIRE_BUCKET_LEN) || AUTOFIRE_BUCKET_LEN)
6 changes: 3 additions & 3 deletions code/__HELPERS/#maths.dm
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ GLOBAL_LIST_INIT(sqrtTable, list(1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4,
#define ToRadians(degrees) ((degrees) * 0.0174532925)

// min is inclusive, max is exclusive
#define WRAP(val, min, max) clamp(( (min) == (max) ? (min) : (val) - (round(((val) - (min))/((max) - (min))) * ((max) - (min))) ),(min),(max))
#define WRAP(val, min, max) clamp(( (min) == (max) ? (min) : (val) - (floor(((val) - (min))/((max) - (min))) * ((max) - (min))) ),(min),(max))


// MATH PROCS
Expand Down Expand Up @@ -97,7 +97,7 @@ GLOBAL_LIST_INIT(sqrtTable, list(1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4,
var/static/list/units_prefix = list("", "un", "duo", "tre", "quattuor", "quin", "sex", "septen", "octo", "novem")
var/static/list/tens_prefix = list("", "decem", "vigin", "trigin", "quadragin", "quinquagin", "sexagin", "septuagin", "octogin", "nongen")
var/static/list/one_to_nine = list("monuple", "double", "triple", "quadruple", "quintuple", "sextuple", "septuple", "octuple", "nonuple")
number = round(number)
number = floor(number)
switch(number)
if(0)
return "empty tuple"
Expand All @@ -106,7 +106,7 @@ GLOBAL_LIST_INIT(sqrtTable, list(1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4,
if(10 to 19)
return "[units_prefix[(number%10)+1]]decuple"
if(20 to 99)
return "[units_prefix[(number%10)+1]][tens_prefix[round((number % 100)/10)+1]]tuple"
return "[units_prefix[(number%10)+1]][tens_prefix[floor((number % 100)/10)+1]]tuple"
if(100)
return "centuple"
else //It gets too tedious to use latin prefixes from here.
Expand Down
2 changes: 1 addition & 1 deletion code/__HELPERS/files.dm
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
/client/proc/file_spam_check()
var/time_to_wait = GLOB.fileaccess_timer - world.time
if(time_to_wait > 0)
to_chat(src, "<font color='red'>Error: file_spam_check(): Spam. Please wait [round(time_to_wait/10)] seconds.</font>")
to_chat(src, "<font color='red'>Error: file_spam_check(): Spam. Please wait [floor(time_to_wait/10)] seconds.</font>")
return 1
GLOB.fileaccess_timer = world.time + FTPDELAY
return 0
Expand Down
2 changes: 1 addition & 1 deletion code/__HELPERS/game.dm
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@
if(X1<X2)
b+=m
while(X1!=X2 || Y1!=Y2)
if(round(m*X1+b-Y1))
if(floor(m*X1+b-Y1))
Y1+=signY //Line exits tile vertically
else
X1+=signX //Line exits tile horizontally
Expand Down
2 changes: 1 addition & 1 deletion code/__HELPERS/icons.dm
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ world
while (gap > 1 || swapped)
swapped = 0
if(gap > 1)
gap = round(gap / 1.3) // 1.3 is the emperic comb sort coefficient
gap = floor(gap / 1.3) // 1.3 is the emperic comb sort coefficient
if(gap < 1)
gap = 1
for(var/i = 1; gap + i <= result.len; i++)
Expand Down
2 changes: 1 addition & 1 deletion code/__HELPERS/sanitize_values.dm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//general stuff
/proc/sanitize_integer(number, min=0, max=1, default=0)
if(isnum(number))
number = round(number)
number = floor(number)
if(min <= number && number <= max)
return number
return default
Expand Down
2 changes: 1 addition & 1 deletion code/__HELPERS/sorts/_Main.dm
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ GLOBAL_DATUM_INIT(sortInstance, /datum/sortInstance, new())
//[lo, left) elements <= pivot < [right, start) elements
//in other words, find where the pivot element should go using bisection search
while(left < right)
var/mid = (left + right) >> 1 //round((left+right)/2)
var/mid = (left + right) >> 1 //floor((left+right)/2)
if(call(cmp)(fetchElement(L,mid), pivot) > 0)
right = mid
else
Expand Down
2 changes: 1 addition & 1 deletion code/__HELPERS/type2type.dm
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
var/power = null
power = i - 1
while(power >= 0)
var/val = round(num / 16 ** power)
var/val = floor(num / 16 ** power)
num -= val * 16 ** power
switch(val)
if(9.0, 8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0, 0.0)
Expand Down
14 changes: 7 additions & 7 deletions code/__HELPERS/unsorted.dm
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@
#define skillcheckexplicit(user, skill, req_level) ((!user.skills || user.skills.is_skilled((skill), (req_level), TRUE)))

// Ensure the frequency is within bounds of what it should be sending/receiving at
// Sets f within bounds via `clamp(round(f), 1441, 1489)`
// Sets f within bounds via `clamp(floor(f), 1441, 1489)`
// If f is even, adds 1 to its value to make it odd
#define sanitize_frequency(f) ((clamp(round(f), 1441, 1489) % 2) == 0 ? \
clamp(round(f), 1441, 1489) + 1 : \
clamp(round(f), 1441, 1489) \
#define sanitize_frequency(f) ((clamp(floor(f), 1441, 1489) % 2) == 0 ? \
clamp(floor(f), 1441, 1489) + 1 : \
clamp(floor(f), 1441, 1489) \
)

//Turns 1479 into 147.9
#define format_frequency(f) "[round((f) / 10)].[(f) % 10]"
#define format_frequency(f) "[floor((f) / 10)].[(f) % 10]"

#define reverse_direction(direction) ( \
( dir & (NORTH|SOUTH) ? ~dir & (NORTH|SOUTH) : 0 ) | \
Expand Down Expand Up @@ -1766,8 +1766,8 @@ GLOBAL_DATUM_INIT(dview_mob, /mob/dview, new)
pixel_y_offset += ((AMiconheight/world.icon_size)-1)*(world.icon_size*0.5)

//DY and DX
var/rough_x = round(round(pixel_x_offset,world.icon_size)/world.icon_size)
var/rough_y = round(round(pixel_y_offset,world.icon_size)/world.icon_size)
var/rough_x = floor(round(pixel_x_offset,world.icon_size)/world.icon_size)
var/rough_y = floor(round(pixel_y_offset,world.icon_size)/world.icon_size)

//Find coordinates
var/turf/T = get_turf(AM) //use AM's turfs, as it's coords are the same as AM's AND AM's coords are lost if it is inside another atom
Expand Down
2 changes: 1 addition & 1 deletion code/_globalvars/global_lists.dm
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ GLOBAL_LIST_INIT(hj_emotes, setup_hazard_joe_emotes())
while(gap > 1 || swapped)
swapped = 0
if(gap > 1)
gap = round(gap / 1.247330950103979)
gap = floor(gap / 1.247330950103979)
if(gap < 1)
gap = 1
for(var/i = 1; gap + i <= length(surgeries); i++)
Expand Down
4 changes: 2 additions & 2 deletions code/_onclick/click.dm
Original file line number Diff line number Diff line change
Expand Up @@ -376,8 +376,8 @@
var/shiftX = C.pixel_x / world.icon_size
var/shiftY = C.pixel_y / world.icon_size
var/list/actual_view = getviewsize(C ? C.view : GLOB.world_view_size)
tX = clamp(origin.x + text2num(tX) + shiftX - round(actual_view[1] / 2) - 1, 1, world.maxx)
tY = clamp(origin.y + text2num(tY) + shiftY - round(actual_view[2] / 2) - 1, 1, world.maxy)
tX = clamp(origin.x + text2num(tX) + shiftX - floor(actual_view[1] / 2) - 1, 1, world.maxx)
tY = clamp(origin.y + text2num(tY) + shiftY - floor(actual_view[2] / 2) - 1, 1, world.maxy)
return locate(tX, tY, tZ)


Expand Down
12 changes: 6 additions & 6 deletions code/_onclick/hud/radial.dm
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ GLOBAL_LIST_EMPTY(radial_menus)
else
zone = 360 - starting_angle + ending_angle

max_elements = round(zone / min_angle)
max_elements = floor(zone / min_angle)
var/paged = max_elements < choices.len
if(elements.len < max_elements)
var/elements_to_add = max_elements - elements.len
Expand Down Expand Up @@ -177,7 +177,7 @@ GLOBAL_LIST_EMPTY(radial_menus)

/datum/radial_menu/proc/update_screen_objects(anim = FALSE)
var/list/page_choices = page_data[current_page]
var/angle_per_element = round(zone / length(page_choices))
var/angle_per_element = floor(zone / length(page_choices))
for(var/i in 1 to length(elements))
var/atom/movable/screen/radial/E = elements[i]
var/angle = WRAP(starting_angle + (i - 1) * angle_per_element,0,360)
Expand All @@ -197,8 +197,8 @@ GLOBAL_LIST_EMPTY(radial_menus)

/datum/radial_menu/proc/SetElement(atom/movable/screen/radial/slice/E,choice_id,angle,anim,anim_order)
//Position
var/py = round(cos(angle) * radius) + py_shift
var/px = round(sin(angle) * radius)
var/py = floor(cos(angle) * radius) + py_shift
var/px = floor(sin(angle) * radius)
if(anim)
var/timing = anim_order * 0.5
var/matrix/starting = matrix()
Expand Down Expand Up @@ -271,8 +271,8 @@ GLOBAL_LIST_EMPTY(radial_menus)
if(use_labels)
MA.maptext_width = 64
MA.maptext_height = 64
MA.maptext_x = -round(MA.maptext_width / 2) + 16
MA.maptext_y = -round(MA.maptext_height / 2) + 16
MA.maptext_x = -floor(MA.maptext_width / 2) + 16
MA.maptext_y = -floor(MA.maptext_height / 2) + 16
MA.maptext = SMALL_FONTS_CENTRED(7, label)
return MA

Expand Down
6 changes: 3 additions & 3 deletions code/_onclick/hud/screen_objects.dm
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
return ..()

/atom/movable/screen/action_button/proc/get_button_screen_loc(button_number)
var/row = round((button_number-1)/13) //13 is max amount of buttons per row
var/row = floor((button_number-1)/13) //13 is max amount of buttons per row
var/col = ((button_number - 1)%(13)) + 1
var/coord_col = "+[col-1]"
var/coord_col_offset = 4+2*col
Expand Down Expand Up @@ -129,9 +129,9 @@
//Calculate fullness for etiher max storage, or for storage slots if the container has them
var/fullness = 0
if (master_storage.storage_slots == null)
fullness = round(10*total_w/master_storage.max_storage_space)
fullness = floor(10*total_w/master_storage.max_storage_space)
else
fullness = round(10*master_storage.contents.len/master_storage.storage_slots)
fullness = floor(10*master_storage.contents.len/master_storage.storage_slots)
switch(fullness)
if(10)
color = "#ff0000"
Expand Down
2 changes: 1 addition & 1 deletion code/_onclick/item_attack.dm
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@

var/power = force
if(user.skills)
power = round(power * (1 + 0.25 * user.skills.get_skill_level(SKILL_MELEE_WEAPONS))) //25% bonus per melee level
power = floor(power * (1 + 0.25 * user.skills.get_skill_level(SKILL_MELEE_WEAPONS))) //25% bonus per melee level
if(!ishuman(M))
var/used_verb = "attacked"
if(attack_verb && attack_verb.len)
Expand Down
2 changes: 1 addition & 1 deletion code/controllers/configuration/config_entry.dm
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
return FALSE
var/temp = text2num(trim(str_val))
if(!isnull(temp))
config_entry_value = clamp(integer ? round(temp) : temp, min_val, max_val)
config_entry_value = clamp(integer ? floor(temp) : temp, min_val, max_val)
if(config_entry_value != temp && !(datum_flags & DF_VAR_EDITED))
log_config("Changing [name] from [temp] to [config_entry_value]!")
return TRUE
Expand Down
4 changes: 2 additions & 2 deletions code/controllers/mc/master.dm
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ GLOBAL_REAL(Master, /datum/controller/master) = new

for (var/datum/controller/subsystem/subsystem as anything in subsystems)
var/subsystem_init_stage = subsystem.init_stage
if (!isnum(subsystem_init_stage) || subsystem_init_stage < 1 || subsystem_init_stage > INITSTAGE_MAX || round(subsystem_init_stage) != subsystem_init_stage)
if (!isnum(subsystem_init_stage) || subsystem_init_stage < 1 || subsystem_init_stage > INITSTAGE_MAX || floor(subsystem_init_stage) != subsystem_init_stage)
stack_trace("ERROR: MC: subsystem `[subsystem.type]` has invalid init_stage: `[subsystem_init_stage]`. Setting to `[INITSTAGE_MAX]`")
subsystem_init_stage = subsystem.init_stage = INITSTAGE_MAX
stage_sorted_subsystems[subsystem_init_stage] += subsystem
Expand Down Expand Up @@ -668,7 +668,7 @@ GLOBAL_REAL(Master, /datum/controller/master) = new

tick_precentage = max(tick_precentage*0.5, tick_precentage-queue_node.tick_overrun)

current_ticklimit = round(TICK_USAGE + tick_precentage)
current_ticklimit = floor(TICK_USAGE + tick_precentage)

ran = TRUE

Expand Down
4 changes: 2 additions & 2 deletions code/controllers/subsystem/mapping.dm
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,9 @@ SUBSYSTEM_DEF(mapping)
var/x_offset = 1
var/y_offset = 1
if(bounds && world.maxx > bounds[MAP_MAXX])
x_offset = round(world.maxx / 2 - bounds[MAP_MAXX] / 2) + 1
x_offset = floor(world.maxx / 2 - bounds[MAP_MAXX] / 2) + 1
if(bounds && world.maxy > bounds[MAP_MAXY])
y_offset = round(world.maxy / 2 - bounds[MAP_MAXY] / 2) + 1
y_offset = floor(world.maxy / 2 - bounds[MAP_MAXY] / 2) + 1
if (!pm.load(x_offset, y_offset, start_z + parsed_maps[pm], no_changeturf = TRUE, new_z = TRUE))
errorList |= pm.original_path
// CM Snowflake for Mass Screenshot dimensions auto detection
Expand Down
2 changes: 1 addition & 1 deletion code/controllers/subsystem/statpanel.dm
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ SUBSYSTEM_DEF(statpanels)

target.stat_panel.send_message("update_stat", list(
"global_data" = global_data,
//"ping_str" = "Ping: [round(target.lastping, 1)]ms (Average: [round(target.avgping, 1)]ms)",
//"ping_str" = "Ping: [floor(target.lastping, 1)]ms (Average: [floor(target.avgping, 1)]ms)",
"other_str" = target.mob?.get_status_tab_items(),
))

Expand Down
6 changes: 3 additions & 3 deletions code/controllers/subsystem/ticker.dm
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ SUBSYSTEM_DEF(ticker)
if(isnull(start_at))
start_at = time_left || world.time + (CONFIG_GET(number/lobby_countdown) * 10)
to_chat_spaced(world, type = MESSAGE_TYPE_SYSTEM, margin_top = 2, margin_bottom = 0, html = SPAN_ROUNDHEADER("Welcome to the pre-game lobby of [CONFIG_GET(string/servername)]!"))
to_chat_spaced(world, type = MESSAGE_TYPE_SYSTEM, margin_top = 0, html = SPAN_ROUNDBODY("Please, setup your character and select ready. Game will start in [round(time_left / 10) || CONFIG_GET(number/lobby_countdown)] seconds."))
to_chat_spaced(world, type = MESSAGE_TYPE_SYSTEM, margin_top = 0, html = SPAN_ROUNDBODY("Please, setup your character and select ready. Game will start in [floor(time_left / 10) || CONFIG_GET(number/lobby_countdown)] seconds."))
SEND_GLOBAL_SIGNAL(COMSIG_GLOB_MODE_PREGAME_LOBBY)
current_state = GAME_STATE_PREGAME
fire()
Expand Down Expand Up @@ -346,8 +346,8 @@ SUBSYSTEM_DEF(ticker)

/datum/controller/subsystem/ticker/proc/GetTimeLeft()
if(isnull(SSticker.time_left))
return round(max(0, start_at - world.time) / 10)
return round(time_left / 10)
return floor(max(0, start_at - world.time) / 10)
return floor(time_left / 10)


/datum/controller/subsystem/ticker/proc/SetTimeLeft(newtime)
Expand Down
4 changes: 2 additions & 2 deletions code/controllers/subsystem/timer.dm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/// Controls how many buckets should be kept, each representing a tick. (1 minutes worth)
#define BUCKET_LEN (world.fps*1*60)
/// Helper for getting the correct bucket for a given timer
#define BUCKET_POS(timer) (((round((timer.timeToRun - timer.timer_subsystem.head_offset) / world.tick_lag)+1) % BUCKET_LEN)||BUCKET_LEN)
#define BUCKET_POS(timer) (((floor((timer.timeToRun - timer.timer_subsystem.head_offset) / world.tick_lag)+1) % BUCKET_LEN)||BUCKET_LEN)
/// Gets the maximum time at which timers will be invoked from buckets, used for deferring to secondary queue
#define TIMER_MAX(timer_ss) (timer_ss.head_offset + TICKS2DS(BUCKET_LEN + timer_ss.practical_offset - 1))
/// Max float with integer precision
Expand Down Expand Up @@ -411,7 +411,7 @@ SUBSYSTEM_DEF(timer)
if (flags & TIMER_STOPPABLE)
id = num2text(nextid, 100)
if (nextid >= SHORT_REAL_LIMIT)
nextid += min(1, 2 ** round(nextid / SHORT_REAL_LIMIT))
nextid += min(1, 2 ** floor(nextid / SHORT_REAL_LIMIT))
else
nextid++
timer_subsystem.timer_id_dict[id] = src
Expand Down
6 changes: 3 additions & 3 deletions code/controllers/subsystem/vote.dm
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ SUBSYSTEM_DEF(vote)

/datum/controller/subsystem/vote/fire()
if(mode)
time_remaining = round((started_time + CONFIG_GET(number/vote_period) - world.time)/10)
time_remaining = floor((started_time + CONFIG_GET(number/vote_period) - world.time)/10)

if(time_remaining < 0)
result()
Expand Down Expand Up @@ -363,7 +363,7 @@ SUBSYSTEM_DEF(vote)
var/vp = CONFIG_GET(number/vote_period)
SEND_SOUND(world, sound(vote_sound, channel = SOUND_CHANNEL_VOX, volume = vote_sound_vol))
to_chat(world, SPAN_CENTERBOLD("<br><br><font color='purple'><b>[text]</b><br>Type <b>vote</b> or click <a href='?src=[REF(src)]'>here</a> to place your votes.<br>You have [DisplayTimeText(vp)] to vote.</font><br><br>"))
time_remaining = round(vp/10)
time_remaining = floor(vp/10)
for(var/c in GLOB.clients)
var/client/C = c
var/datum/action/innate/vote/V = give_action(C.mob, /datum/action/innate/vote)
Expand All @@ -380,7 +380,7 @@ SUBSYSTEM_DEF(vote)

/datum/controller/subsystem/vote/proc/map_vote_adjustment(current_votes, carry_over, total_votes)
// Get 10% of the total map votes and remove them from the pool
var/total_vote_adjustment = round(total_votes * CONFIG_GET(number/vote_adjustment_callback))
var/total_vote_adjustment = floor(total_votes * CONFIG_GET(number/vote_adjustment_callback))

// Do not remove more votes than were made for the map
return -(min(current_votes, total_vote_adjustment))
Expand Down
2 changes: 1 addition & 1 deletion code/datums/ammo/ammo.dm
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@

var/obj/projectile/P = new /obj/projectile(curloc, original_P.weapon_cause_data)
P.generate_bullet(GLOB.ammo_list[bonus_projectiles_type]) //No bonus damage or anything.
P.accuracy = round(P.accuracy * original_P.accuracy/initial(original_P.accuracy)) //if the gun changes the accuracy of the main projectile, it also affects the bonus ones.
P.accuracy = floor(P.accuracy * original_P.accuracy/initial(original_P.accuracy)) //if the gun changes the accuracy of the main projectile, it also affects the bonus ones.
original_P.give_bullet_traits(P)
P.bonus_projectile_check = 2 //It's a bonus projectile!

Expand Down
12 changes: 6 additions & 6 deletions code/datums/beam.dm
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
/datum/beam/proc/Draw()
if(always_turn)
origin.setDir(get_dir(origin, target)) //Causes the source of the beam to rotate to continuosly face the BeamTarget.
var/Angle = round(Get_Angle(origin,target))
var/Angle = floor(Get_Angle(origin,target))
var/matrix/rot_matrix = matrix()
var/turf/origin_turf = get_turf(origin)
rot_matrix.Turn(Angle)
Expand All @@ -91,7 +91,7 @@
var/DX = get_pixel_position_x(target) - get_pixel_position_x(origin)
var/DY = get_pixel_position_y(target) - get_pixel_position_y(origin)
var/N = 0
var/length = round(sqrt((DX)**2+(DY)**2)) //hypotenuse of the triangle formed by target and origin's displacement
var/length = floor(sqrt((DX)**2+(DY)**2)) //hypotenuse of the triangle formed by target and origin's displacement

for(N in 0 to length-1 step world.icon_size)//-1 as we want < not <=, but we want the speed of X in Y to Z and step X
if(QDELETED(src))
Expand All @@ -116,20 +116,20 @@
if(DX == 0)
Pixel_x = 0
else
Pixel_x = round(sin(Angle) + world.icon_size*sin(Angle)*(N+world.icon_size/2) / world.icon_size)
Pixel_x = floor(sin(Angle) + world.icon_size*sin(Angle)*(N+world.icon_size/2) / world.icon_size)
if(DY == 0)
Pixel_y = 0
else
Pixel_y = round(cos(Angle) + world.icon_size*cos(Angle)*(N+world.icon_size/2) / world.icon_size)
Pixel_y = floor(cos(Angle) + world.icon_size*cos(Angle)*(N+world.icon_size/2) / world.icon_size)

//Position the effect so the beam is one continous line
var/a
if(abs(Pixel_x)>world.icon_size)
a = Pixel_x > 0 ? round(Pixel_x/32) : ceil(Pixel_x/world.icon_size)
a = Pixel_x > 0 ? floor(Pixel_x/32) : ceil(Pixel_x/world.icon_size)
X.x += a
Pixel_x %= world.icon_size
if(abs(Pixel_y)>world.icon_size)
a = Pixel_y > 0 ? round(Pixel_y/32) : ceil(Pixel_y/world.icon_size)
a = Pixel_y > 0 ? floor(Pixel_y/32) : ceil(Pixel_y/world.icon_size)
X.y += a
Pixel_y %= world.icon_size

Expand Down
Loading

0 comments on commit a136f35

Please sign in to comment.