mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-26 14:39:58 +01:00
Replaces world.icon_size (and some magic numbers) with defines (#86819)
## About The Pull Request All usages of world.icon_size in code have been replaced with new `ICONSIZE_X`, `ICONSIZE_Y` and `ICONSIZE_ALL` defines depending on context Replaces some "32" magic numbers with the defines A few bits of code have been modified to split up x/y math as well ## Why It's Good For The Game Magic number bad, code more readable, code more flexible and I'm told there's an access cost to doing world.icon_size so minor performance gains ## Changelog 🆑 tonty code: made some code relating to the world's icon size more readable /🆑 --------- Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com>
This commit is contained in:
@@ -246,18 +246,18 @@
|
||||
if(isnull(icon_x))
|
||||
icon_x = text2num(LAZYACCESS(modifiers, ICON_X))
|
||||
if(isnull(icon_x))
|
||||
icon_x = view_list[1]*world.icon_size/2
|
||||
icon_x = view_list[1]*ICON_SIZE_X/2
|
||||
var/icon_y = text2num(LAZYACCESS(modifiers, VIS_Y))
|
||||
if(isnull(icon_y))
|
||||
icon_y = text2num(LAZYACCESS(modifiers, ICON_Y))
|
||||
if(isnull(icon_y))
|
||||
icon_y = view_list[2]*world.icon_size/2
|
||||
var/x_cap = range_modifier * view_list[1]*world.icon_size / 2
|
||||
var/y_cap = range_modifier * view_list[2]*world.icon_size / 2
|
||||
var/uncapped_x = round(range_modifier * (icon_x - view_list[1]*world.icon_size/2) * MOUSE_POINTER_OFFSET_MULT)
|
||||
var/uncapped_y = round(range_modifier * (icon_y - view_list[2]*world.icon_size/2) * MOUSE_POINTER_OFFSET_MULT)
|
||||
icon_y = view_list[2]*ICON_SIZE_Y/2
|
||||
var/x_cap = range_modifier * view_list[1]*ICON_SIZE_X / 2
|
||||
var/y_cap = range_modifier * view_list[2]*ICON_SIZE_Y / 2
|
||||
var/uncapped_x = round(range_modifier * (icon_x - view_list[1]*ICON_SIZE_X/2) * MOUSE_POINTER_OFFSET_MULT)
|
||||
var/uncapped_y = round(range_modifier * (icon_y - view_list[2]*ICON_SIZE_Y/2) * MOUSE_POINTER_OFFSET_MULT)
|
||||
given_x = clamp(uncapped_x, -x_cap, x_cap)
|
||||
given_y = clamp(uncapped_y, -y_cap, y_cap)
|
||||
given_turf = locate(owner.x+round(given_x/world.icon_size, 1),owner.y+round(given_y/world.icon_size, 1),owner.z)
|
||||
given_turf = locate(owner.x+round(given_x/ICON_SIZE_X, 1),owner.y+round(given_y/ICON_SIZE_Y, 1),owner.z)
|
||||
|
||||
#undef MOUSE_POINTER_OFFSET_MULT
|
||||
|
||||
Reference in New Issue
Block a user