Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into vehicle-gunners-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Doubleumc committed May 15, 2024
2 parents a55893d + 601d521 commit 4fbd0f7
Show file tree
Hide file tree
Showing 291 changed files with 1,424 additions and 1,190 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
# Zonespace

/code/datums/tutorial/ @Zonespace27
/code/modules/admin/verbs/SDQL2/ @Zonespace27
/maps/tutorial/ @Zonespace27

# MULTIPLE OWNERS
2 changes: 1 addition & 1 deletion .github/workflows/labeler.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Labeling and Verification
on:
pull_request_target:
types: [opened, edited]
types: [opened, reopened, synchronize, edited]
jobs:
label:
runs-on: ubuntu-latest
Expand Down
11 changes: 1 addition & 10 deletions code/__DEFINES/_math.dm
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,17 @@
#define LEFT 1
#define RIGHT 2

#define CEILING(x, y) ( -round(-(x) / (y)) * (y) )

#define ROUND_UP(x) ( -round(-(x)))
#define CEILING(x, y) ( ceil((x) / (y)) * (y) )

// round() acts like floor(x, 1) by default but can't handle other values
#define FLOOR(x, y) ( floor((x) / (y)) * (y) )

// Real modulus that handles decimals
#define MODULUS(x, y) ( (x) - (y) * round((x) / (y)) )

// Returns true if val is from min to max, inclusive.
#define ISINRANGE(val, min, max) ((min) <= (val) && (val) <= (max))

// Same as above, exclusive.
#define ISINRANGE_EX(val, min, max) ((min) < (val) && (val) < (max))

// Will filter out extra rotations and negative rotations
// E.g: 540 becomes 180. -180 becomes 180.
#define SIMPLIFY_DEGREES(degrees) (MODULUS((degrees), 360))

/// Gets the sign of x, returns -1 if negative, 0 if 0, 1 if positive
#define SIGN(x) ( ((x) > 0) - ((x) < 0) )

Expand Down
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)
2 changes: 2 additions & 0 deletions code/__DEFINES/equipment.dm
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
#define HTML_USE_INITAL_ICON (1<<18)
// Whether or not the object sees emotes
#define USES_SEEING (1<<19)
// Can be quick drawn
#define QUICK_DRAWABLE (1<<20)

//==========================================================================================

Expand Down
22 changes: 13 additions & 9 deletions code/__DEFINES/turfs.dm
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
#define RANGE_TURFS(RADIUS, CENTER) \
block( \
locate(max(CENTER.x-(RADIUS),1), max(CENTER.y-(RADIUS),1), CENTER.z), \
locate(min(CENTER.x+(RADIUS),world.maxx), min(CENTER.y+(RADIUS),world.maxy), CENTER.z) \
)
block( \
(CENTER).x-(RADIUS), (CENTER).y-(RADIUS), (CENTER).z, \
(CENTER).x+(RADIUS), (CENTER).y+(RADIUS), (CENTER).z \
)

#define RECT_TURFS(H_RADIUS, V_RADIUS, CENTER) \
block( \
locate(max((CENTER).x-(H_RADIUS),1), max((CENTER).y-(V_RADIUS),1), (CENTER).z), \
locate(min((CENTER).x+(H_RADIUS),world.maxx), min((CENTER).y+(V_RADIUS),world.maxy), (CENTER).z) \
(CENTER).x-(H_RADIUS), (CENTER).y-(V_RADIUS), (CENTER).z, \
(CENTER).x+(H_RADIUS), (CENTER).y+(V_RADIUS), (CENTER).z \
)

///Returns all turfs in a zlevel
#define Z_TURFS(ZLEVEL) block(locate(1,1,ZLEVEL), locate(world.maxx, world.maxy, ZLEVEL))
#define Z_TURFS(ZLEVEL) block(1, 1, (ZLEVEL), world.maxx, world.maxy, (ZLEVEL))

/// Returns a list of turfs in the rectangle specified by BOTTOM LEFT corner and height/width, checks for being outside the world border for you
/// Returns a list of turfs in the rectangle specified by BOTTOM LEFT corner and height/width
#define CORNER_BLOCK(corner, width, height) CORNER_BLOCK_OFFSET(corner, width, height, 0, 0)

/// Returns a list of turfs similar to CORNER_BLOCK but with offsets
#define CORNER_BLOCK_OFFSET(corner, width, height, offset_x, offset_y) ((block(locate(corner.x + offset_x, corner.y + offset_y, corner.z), locate(min(corner.x + (width - 1) + offset_x, world.maxx), min(corner.y + (height - 1) + offset_y, world.maxy), corner.z))))
#define CORNER_BLOCK_OFFSET(corner, width, height, offset_x, offset_y) \
block( \
(corner).x + (offset_x), (corner).y + (offset_y), (corner).z, \
(corner).x + ((width) - 1) + (offset_x), (corner).y + ((height) - 1) + (offset_y), (corner).z \
)

/// Returns an outline (neighboring turfs) of the given block
#define CORNER_OUTLINE(corner, width, height) ( \
Expand Down
7 changes: 3 additions & 4 deletions code/__HELPERS/#maths.dm
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ GLOBAL_LIST_INIT(sqrtTable, list(1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4,

// MATH DEFINES

#define Ceiling(x) (-round(-(x)))
#define CLAMP01(x) (clamp((x), 0, 1))

// cotangent
Expand Down Expand Up @@ -45,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 @@ -98,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 @@ -107,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
8 changes: 4 additions & 4 deletions code/__HELPERS/_time.dm
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ GLOBAL_VAR_INIT(rollovercheck_last_timeofday, 0)
return gameTimestamp("mm:ss", time)

/proc/time_left_until(target_time, current_time, time_unit)
return Ceiling(target_time - current_time) / time_unit
return ceil(target_time - current_time) / time_unit

/proc/text2duration(text = "00:00") // Attempts to convert time text back to time value
var/split_text = splittext(text, ":")
Expand Down Expand Up @@ -92,21 +92,21 @@ GLOBAL_VAR_INIT(rollovercheck_last_timeofday, 0)
if(second < 60)
return "[second] second[(second != 1)? "s":""]"
var/minute = floor(second / 60)
second = FLOOR(MODULUS(second, 60), round_seconds_to)
second = FLOOR(second %% 60, round_seconds_to)
var/secondT
if(second)
secondT = " and [second] second[(second != 1)? "s":""]"
if(minute < 60)
return "[minute] minute[(minute != 1)? "s":""][secondT]"
var/hour = floor(minute / 60)
minute = MODULUS(minute, 60)
minute %%= 60
var/minuteT
if(minute)
minuteT = " and [minute] minute[(minute != 1)? "s":""]"
if(hour < 24)
return "[hour] hour[(hour != 1)? "s":""][minuteT][secondT]"
var/day = floor(hour / 24)
hour = MODULUS(hour, 24)
hour %%= 24
var/hourT
if(hour)
hourT = " and [hour] hour[(hour != 1)? "s":""]"
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
23 changes: 11 additions & 12 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 @@ -729,8 +729,7 @@
if(orange)
turfs -= get_turf(center)
. = list()
for(var/V in turfs)
var/turf/T = V
for(var/turf/T as anything in turfs)
. += T
. += T.contents
if(areas)
Expand Down Expand Up @@ -1060,7 +1059,7 @@ GLOBAL_DATUM(action_purple_power_up, /image)

var/cur_user_zone_sel = busy_user.zone_selected
var/cur_target_zone_sel
var/delayfraction = Ceiling(delay/numticks)
var/delayfraction = ceil(delay/numticks)
var/user_orig_loc = busy_user.loc
var/user_orig_turf = get_turf(busy_user)
var/target_orig_loc
Expand Down Expand Up @@ -1562,7 +1561,7 @@ GLOBAL_LIST_INIT(WALLITEMS, list(
. = 0
var/i = DS2TICKS(initial_delay)
do
. += Ceiling(i*DELTA_CALC)
. += ceil(i*DELTA_CALC)
sleep(i*world.tick_lag*DELTA_CALC)
i *= 2
while (TICK_USAGE > min(TICK_LIMIT_TO_RUN, Master.current_ticklimit))
Expand Down Expand Up @@ -1665,7 +1664,7 @@ GLOBAL_LIST_INIT(WALLITEMS, list(

// Redistribute the net displacement evenly on the side of the center line that needs it
// Only half the points are gonna be affected.
var/to_redistribute = abs(Ceiling(net_displacement / (variances.len/2)))
var/to_redistribute = abs(ceil(net_displacement / (variances.len/2)))
for(var/i in 1 to variances.len)
if(!net_displacement)
break
Expand Down Expand Up @@ -1767,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
1 change: 1 addition & 0 deletions code/_globalvars/bitfields.dm
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ DEFINE_BITFIELD(flags_atom, list(
"ATOM_DECORATED" = ATOM_DECORATED,
"USES_HEARING" = USES_HEARING,
"HTML_USE_INITAL_ICON" = HTML_USE_INITAL_ICON,
"QUICK_DRAWABLE" = QUICK_DRAWABLE,
))

DEFINE_BITFIELD(turf_flags, list(
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
Loading

0 comments on commit 4fbd0f7

Please sign in to comment.