Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
DelineFortune committed Jan 16, 2024
2 parents e6bbcd6 + 5d0a1f0 commit bd1afd9
Show file tree
Hide file tree
Showing 120 changed files with 462 additions and 363 deletions.
3 changes: 3 additions & 0 deletions code/__DEFINES/_math.dm
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,6 @@

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

/// Performs a linear interpolation between a and b. Note that amount=0 returns a, amount=1 returns b, and amount=0.5 returns the mean of a and b.
#define LERP(a, b, amount) ( amount ? ((a) + ((b) - (a)) * (amount)) : a )
32 changes: 19 additions & 13 deletions code/__DEFINES/colours.dm
Original file line number Diff line number Diff line change
Expand Up @@ -14,59 +14,65 @@

// BLACK AND WHITE COLOR DEFINE.

/// Full white. rgb(255, 255, 255)
/// White rgb(255, 255, 255)
#define COLOR_WHITE "#FFFFFF"
/// Full black. rgb(0, 0, 0)
/// Black rgb(0, 0, 0)
#define COLOR_BLACK "#000000"

// THE THREE PRIMARIES COLORS DEFINES.

/// Full red. rgb(255, 0, 0)
/// Red rgb(255, 0, 0)
#define COLOR_RED "#FF0000"
/// Full green. rgb(0, 255, 0)
/// Green rgb(0, 255, 0)
#define COLOR_GREEN "#00FF00"
/// Full blue. rgb(0, 0, 255)
/// Blue rgb(0, 0, 255)
#define COLOR_BLUE "#0000FF"

//mix of two full primary colors

/// full cyan rgb(0, 255, 255) B + G
/// Cyan rgb(0, 255, 255) B + G
#define COLOR_CYAN "#00FFFF"
/// full magenta(not pink) rgb(255, 0, 255) R+B
#define COLOR_PINK "#FF00FF"
/// full yellow rgb(255, 255, 0) R+G
/// Magenta rgb(255, 0, 255) R+B
#define COLOR_MAGENTA "#FF00FF"
/// Yellow rgb(255, 255, 0) R+G
#define COLOR_YELLOW "#FFFF00"

// colors define in use bellow

/// Olive rgb(128, 128, 0)
#define COLOR_OLIVE "#808000"
/// Silver rgb(192, 192, 192) shade of grey
#define COLOR_SILVER "#C0C0C0"
/// Gray rgb(128, 128, 128)
#define COLOR_GRAY "#808080"

#define COLOR_FLOORTILE_GRAY "#8D8B8B"

#define COLOR_HALF_TRANSPARENT_BLACK "#0000007A"

#define COLOR_DARK_RED "#A50824"

/// Maroon rgb(128, 0, 0) shade of red
#define COLOR_MAROON "#800000"

#define COLOR_VIVID_RED "#FF3232"
#define COLOR_LIGHT_GRAYISH_RED "#E4C7C5"
#define COLOR_SOFT_RED "#FA8282"

#define COLOR_VERY_SOFT_YELLOW "#FAE48E"

#define COLOR_OLIVE "#808000"

///light green rgb( 0, 128, 0)
#define COLOR_LIGHT_GREEN "#008000"
#define COLOR_DARK_MODERATE_LIME_GREEN "#44964A"

#define COLOR_TEAL "#008080"

#define COLOR_MODERATE_BLUE "#555CC2"

/// Purple rgb( 128, 0, 128)
#define COLOR_PURPLE "#800080"
#define COLOR_STRONG_VIOLET "#6927c5"

#define COLOR_BEIGE "#CEB689"
#define LIGHT_BEIGE "#CEB689"
#define COLOR_DARK_MODERATE_ORANGE "#8B633B"

#define COLOR_BROWN "#BA9F6D"
Expand Down
1 change: 0 additions & 1 deletion code/__DEFINES/minimap.dm
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ GLOBAL_LIST_INIT(all_minimap_flags, bitfield2list(MINIMAP_FLAG_ALL))

#define MINIMAP_ICON_COLOR_COMMANDER "#c6fcfc"
#define MINIMAP_ICON_COLOR_HEAD "#F0C542"
#define MINIMAP_ICON_COLOR_SILVER "#c0c0c0"
#define MINIMAP_ICON_COLOR_BRONZE "#eb9545"

#define MINIMAP_ICON_COLOR_DOCTOR "#b83737"
Expand Down
2 changes: 1 addition & 1 deletion code/__DEFINES/text.dm
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@
#define MAX_EMOTE_LEN 256
#define MAX_PAPER_MESSAGE_LEN 3072
#define MAX_BOOK_MESSAGE_LEN 9216
#define MAX_NAME_LEN 26
#define MAX_NAME_LEN 28
5 changes: 4 additions & 1 deletion code/__DEFINES/tgs.dm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// tgstation-server DMAPI

#define TGS_DMAPI_VERSION "7.0.1"
#define TGS_DMAPI_VERSION "7.0.2"

// All functions and datums outside this document are subject to change with any version and should not be relied on.

Expand Down Expand Up @@ -426,6 +426,7 @@

/**
* Send a message to connected chats. This function may sleep!
* If TGS is offline when called, the message may be placed in a queue to be sent and this function will return immediately. Your message will be sent when TGS reconnects to the game.
*
* message - The [/datum/tgs_message_content] to send.
* admin_only: If [TRUE], message will be sent to admin connected chats. Vice-versa applies.
Expand All @@ -435,6 +436,7 @@

/**
* Send a private message to a specific user. This function may sleep!
* If TGS is offline when called, the message may be placed in a queue to be sent and this function will return immediately. Your message will be sent when TGS reconnects to the game.
*
* message - The [/datum/tgs_message_content] to send.
* user: The [/datum/tgs_chat_user] to PM.
Expand All @@ -444,6 +446,7 @@

/**
* Send a message to connected chats that are flagged as game-related in TGS. This function may sleep!
* If TGS is offline when called, the message may be placed in a queue to be sent and this function will return immediately. Your message will be sent when TGS reconnects to the game.
*
* message - The [/datum/tgs_message_content] to send.
* channels - Optional list of [/datum/tgs_chat_channel]s to restrict the message to.
Expand Down
18 changes: 1 addition & 17 deletions code/__HELPERS/#maths.dm
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,23 @@ 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 Clamp(val, min_val, max_val) (max(min_val, min(val, max_val)))
#define CLAMP01(x) (clamp(x, 0, 1))

// cotangent
#define Cot(x) (1 / Tan(x))
#define Cot(x) (1 / tan(x))

// cosecant
#define Csc(x) (1 / sin(x))

#define Default(a, b) (a ? a : b)
#define Floor(x) (round(x))

//Finds nearest integer to x, above or below
//something.5 or higher, round up, else round down
#define roundNearest(x) (((Ceiling(x) - x) <= (x - Floor(x))) ? Ceiling(x) : Floor(x))

// Greatest Common Divisor - Euclid's algorithm
#define Gcd(a, b) (b ? Gcd(b, a % b) : a)

#define Inverse(x) (1 / x)
#define IsEven(x) (x % 2 == 0)

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

#define IsInteger(x) (Floor(x) == x)
#define IsOdd(x) (!IsEven(x))
#define IsMultiple(x, y) (x % y == 0)
Expand All @@ -47,9 +39,6 @@ GLOBAL_LIST_INIT(sqrtTable, list(1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4,
// secant
#define Sec(x) (1 / cos(x))

// tangent
#define Tan(x) (sin(x) / cos(x))

// 57.2957795 = 180 / Pi
#define ToDegrees(radians) (radians * 57.2957795)

Expand Down Expand Up @@ -85,11 +74,6 @@ GLOBAL_LIST_INIT(sqrtTable, list(1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4,

return rotated_point

// Round up
/proc/n_ceil(num)
if(isnum(num))
return round(num)+1

///Format a power value in W, kW, MW, or GW.
/proc/display_power(powerused)
if(powerused < 1000) //Less than a kW
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, 1) / time_unit
return Ceiling(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 @@ -91,21 +91,21 @@ GLOBAL_VAR_INIT(rollovercheck_last_timeofday, 0)
return "right now"
if(second < 60)
return "[second] second[(second != 1)? "s":""]"
var/minute = FLOOR(second / 60, 1)
var/minute = Floor(second / 60)
second = FLOOR(MODULUS(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, 1)
var/hour = Floor(minute / 60)
minute = MODULUS(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, 1)
var/day = Floor(hour / 24)
hour = MODULUS(hour, 24)
var/hourT
if(hour)
Expand Down
6 changes: 3 additions & 3 deletions code/__HELPERS/icons.dm
Original file line number Diff line number Diff line change
Expand Up @@ -548,9 +548,9 @@ world
if (!value) return color

var/list/RGB = ReadRGB(color)
RGB[1] = Clamp(RGB[1]+value,0,255)
RGB[2] = Clamp(RGB[2]+value,0,255)
RGB[3] = Clamp(RGB[3]+value,0,255)
RGB[1] = clamp(RGB[1]+value,0,255)
RGB[2] = clamp(RGB[2]+value,0,255)
RGB[3] = clamp(RGB[3]+value,0,255)
return rgb(RGB[1],RGB[2],RGB[3])

/proc/sort_atoms_by_layer(list/atoms)
Expand Down
10 changes: 5 additions & 5 deletions code/__HELPERS/unsorted.dm
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@
#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(round(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(round(f), 1441, 1489) % 2) == 0 ? \
clamp(round(f), 1441, 1489) + 1 : \
clamp(round(f), 1441, 1489) \
)

//Turns 1479 into 147.9
Expand Down Expand Up @@ -1633,7 +1633,7 @@ GLOBAL_LIST_INIT(WALLITEMS, list(
. = 0
var/i = DS2TICKS(initial_delay)
do
. += CEILING(i*DELTA_CALC, 1)
. += Ceiling(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
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 - 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)
return locate(tX, tY, tZ)


Expand Down
4 changes: 2 additions & 2 deletions code/controllers/subsystem/minimap.dm
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ SUBSYSTEM_DEF(minimaps)
else if(yval < smallest_y)
smallest_y = yval

minimaps_by_z["[level]"].x_offset = FLOOR((SCREEN_PIXEL_SIZE-largest_x-smallest_x) / MINIMAP_SCALE, 1)
minimaps_by_z["[level]"].y_offset = FLOOR((SCREEN_PIXEL_SIZE-largest_y-smallest_y) / MINIMAP_SCALE, 1)
minimaps_by_z["[level]"].x_offset = Floor((SCREEN_PIXEL_SIZE-largest_x-smallest_x) / MINIMAP_SCALE)
minimaps_by_z["[level]"].y_offset = Floor((SCREEN_PIXEL_SIZE-largest_y-smallest_y) / MINIMAP_SCALE)

icon_gen.Shift(EAST, minimaps_by_z["[level]"].x_offset)
icon_gen.Shift(NORTH, minimaps_by_z["[level]"].y_offset)
Expand Down
2 changes: 1 addition & 1 deletion code/controllers/subsystem/timer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ SUBSYSTEM_DEF(timer)
be supported and may refuse to run or run with a 0 wait")

if (flags & TIMER_CLIENT_TIME) // REALTIMEOFDAY has a resolution of 1 decisecond
wait = max(CEILING(wait, 1), 1) // so if we use tick_lag timers may be inserted in the "past"
wait = max(Ceiling(wait), 1) // so if we use tick_lag timers may be inserted in the "past"
else
wait = max(CEILING(wait, world.tick_lag), world.tick_lag)

Expand Down
2 changes: 1 addition & 1 deletion code/controllers/subsystem/x_evolution.dm
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ SUBSYSTEM_DEF(xevolution)
//Add on any bonuses from thie hivecore after applying upgrade progress
boost_power_new += (0.5 * HS.has_special_structure(XENO_STRUCTURE_CORE))

boost_power_new = Clamp(boost_power_new, BOOST_POWER_MIN, BOOST_POWER_MAX)
boost_power_new = clamp(boost_power_new, BOOST_POWER_MIN, BOOST_POWER_MAX)

boost_power_new += HS.evolution_bonus
if(!force_boost_power)
Expand Down
4 changes: 2 additions & 2 deletions code/datums/beam.dm
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,11 @@
//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) : CEILING(Pixel_x/world.icon_size, 1)
a = Pixel_x > 0 ? round(Pixel_x/32) : Ceiling(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) : CEILING(Pixel_y/world.icon_size, 1)
a = Pixel_y > 0 ? round(Pixel_y/32) : Ceiling(Pixel_y/world.icon_size)
X.y += a
Pixel_y %= world.icon_size

Expand Down
2 changes: 1 addition & 1 deletion code/datums/components/overlay_lighting.dm
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@
turn_off()
range = clamp(CEILING(new_range, 0.5), 1, 7)
var/pixel_bounds = ((range - 1) * 64) + 32
lumcount_range = CEILING(range, 1)
lumcount_range = Ceiling(range)
if(current_holder && overlay_lighting_flags & LIGHTING_ON)
current_holder.underlays -= visible_mask
visible_mask.icon = light_overlays["[pixel_bounds]"]
Expand Down
6 changes: 3 additions & 3 deletions code/datums/diseases/advance/advance.dm
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,9 @@ GLOBAL_LIST_INIT(advance_cures, list(

hidden = list( (properties["stealth"] > 2), (properties["stealth"] > 3) )
// The more symptoms we have, the less transmittable it is but some symptoms can make up for it.
SetSpread(Clamp(properties["transmittable"] - symptoms.len, BLOOD, AIRBORNE))
SetSpread(clamp(properties["transmittable"] - symptoms.len, BLOOD, AIRBORNE))
permeability_mod = max(Ceiling(0.4 * properties["transmittable"]), 1)
cure_chance = 15 - Clamp(properties["resistance"], -5, 5) // can be between 10 and 20
cure_chance = 15 - clamp(properties["resistance"], -5, 5) // can be between 10 and 20
stage_prob = max(properties["stage_rate"], 2)
SetSeverity(properties["severity"])
GenerateCure(properties)
Expand Down Expand Up @@ -254,7 +254,7 @@ GLOBAL_LIST_INIT(advance_cures, list(
// Will generate a random cure, the less resistance the symptoms have, the harder the cure.
/datum/disease/advance/proc/GenerateCure(list/properties = list())
if(properties && properties.len)
var/res = Clamp(properties["resistance"] - (symptoms.len / 2), 1, GLOB.advance_cures.len)
var/res = clamp(properties["resistance"] - (symptoms.len / 2), 1, GLOB.advance_cures.len)
cure_id = GLOB.advance_cures[res]

// Get the cure name from the cure_id
Expand Down
2 changes: 1 addition & 1 deletion code/datums/stamina/_stamina.dm
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
if(!has_stamina)
return

current_stamina = Clamp(current_stamina - amount, 0, max_stamina)
current_stamina = clamp(current_stamina - amount, 0, max_stamina)

if(current_stamina < max_stamina)
START_PROCESSING(SSobj, src)
Expand Down
2 changes: 1 addition & 1 deletion code/defines/procs/announcement.dm
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@
for(var/mob/T in targets)
if(isobserver(T))
continue
if(!ishuman(T) || isyautja(T) || !is_mainship_level(T.z))
if(!ishuman(T) || isyautja(T) || !is_mainship_level((get_turf(T))?.z))
targets.Remove(T)

log_ares_announcement("[title] Shipwide Update", message)
Expand Down
2 changes: 1 addition & 1 deletion code/game/jobs/job/civilians/other/survivors.dm
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
var/hostile = FALSE

/datum/job/civilian/survivor/set_spawn_positions(count)
spawn_positions = Clamp((round(count * SURVIVOR_TO_TOTAL_SPAWN_RATIO)), 2, 8)
spawn_positions = clamp((round(count * SURVIVOR_TO_TOTAL_SPAWN_RATIO)), 2, 8)
total_positions = spawn_positions

/datum/job/civilian/survivor/equip_job(mob/living/survivor)
Expand Down
2 changes: 1 addition & 1 deletion code/game/jobs/slot_scaling.dm
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
/proc/job_slot_formula(marine_count, factor, c, min, max)
if(marine_count <= factor)
return min
return round(Clamp((marine_count/factor)+c, min, max))
return round(clamp((marine_count/factor)+c, min, max))

/proc/medic_slot_formula(playercount)
return job_slot_formula(playercount,40,1,3,5)
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/computer/research.dm
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@
if("purchase_document")
if(!photocopier)
return
var/purchase_tier = FLOOR(text2num(params["purchase_document"]), 1)
var/purchase_tier = Floor(text2num(params["purchase_document"]))
if(purchase_tier <= 0 || purchase_tier > 5)
return
if(purchase_tier > GLOB.chemical_data.clearance_level)
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/telecomms/presets.dm
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
return // Leave the poor thing alone

health -= damage
health = Clamp(health, 0, initial(health))
health = clamp(health, 0, initial(health))

if(health <= 0)
toggled = FALSE // requires flipping on again once repaired
Expand Down
Loading

0 comments on commit bd1afd9

Please sign in to comment.