Skip to content

Commit

Permalink
Merge branch 'master' into Pre-awaking-equipment
Browse files Browse the repository at this point in the history
  • Loading branch information
LC4492 authored Jan 29, 2024
2 parents c5405fb + 8393ddb commit bd8d46b
Show file tree
Hide file tree
Showing 137 changed files with 1,944 additions and 1,675 deletions.
2 changes: 1 addition & 1 deletion code/__DEFINES/lighting.dm
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ GLOBAL_LIST_INIT(emissive_color, EMISSIVE_COLOR)
GLOBAL_LIST_INIT(em_block_color, EM_BLOCK_COLOR)
/// A set of appearance flags applied to all emissive and emissive blocker overlays.
#define EMISSIVE_APPEARANCE_FLAGS (KEEP_APART|KEEP_TOGETHER|RESET_COLOR|RESET_TRANSFORM)
/// The color matrix used to mask out emissive blockers on the emissive plane. Alpha should default to zero, be solely dependent on the RGB value of [EMISSIVE_COLOR], and be independant of the RGB value of [EM_BLOCK_COLOR].
/// The color matrix used to mask out emissive blockers on the emissive plane. Alpha should default to zero, be solely dependent on the RGB value of [EMISSIVE_COLOR], and be independent of the RGB value of [EM_BLOCK_COLOR].
#define EM_MASK_MATRIX list(0,0,0,1/3, 0,0,0,1/3, 0,0,0,1/3, 0,0,0,0, 1,1,1,0)
/// A globaly cached version of [EM_MASK_MATRIX] for quick access.
GLOBAL_LIST_INIT(em_mask_matrix, EM_MASK_MATRIX)
Expand Down
4 changes: 2 additions & 2 deletions code/__DEFINES/subsystems.dm
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@
//! ### SS initialization hints
/**
* Negative values incidate a failure or warning of some kind, positive are good.
* 0 and 1 are unused so that TRUE and FALSE are guarenteed to be invalid values.
* 0 and 1 are unused so that TRUE and FALSE are guaranteed to be invalid values.
*/

/// Subsystem failed to initialize entirely. Print a warning, log, and disable firing.
#define SS_INIT_FAILURE -2

/// The default return value which must be overriden. Will succeed with a warning.
/// The default return value which must be overridden. Will succeed with a warning.
#define SS_INIT_NONE -1

/// Subsystem initialized sucessfully.
Expand Down
4 changes: 2 additions & 2 deletions code/__DEFINES/traits.dm
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,15 @@
#define TRAIT_FOREIGN_BIO "t_foreign_bio"
/// Eye color changes on intent. (G1 Synths and WJs)
#define TRAIT_INTENT_EYES "t_intent_eyes"
/// Masked synthetic biology. Basic medHUDs will percieve the mob as human. (Infiltrator Synths)
/// Masked synthetic biology. Basic medHUDs will perceive the mob as human. (Infiltrator Synths)
#define TRAIT_INFILTRATOR_SYNTH "t_infiltrator_synth"
/// Makes it impossible to strip the inventory of this mob.
#define TRAIT_UNSTRIPPABLE "t_unstrippable"

// HIVE TRAITS
/// If the Hive is a Xenonid Hive
#define TRAIT_XENONID "t_xenonid"
/// If the Hive delays round end (this is overriden for some hives). Does not occur naturally. Must be applied in events.
/// If the Hive delays round end (this is overridden for some hives). Does not occur naturally. Must be applied in events.
#define TRAIT_NO_HIVE_DELAY "t_no_hive_delay"
/// If the Hive uses it's colors on the mobs. Does not occur naturally, excepting the Mutated hive.
#define TRAIT_NO_COLOR "t_no_color"
Expand Down
47 changes: 0 additions & 47 deletions code/__HELPERS/#maths.dm
Original file line number Diff line number Diff line change
Expand Up @@ -84,53 +84,6 @@ GLOBAL_LIST_INIT(sqrtTable, list(1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4,
return "[round((powerused * 0.000001),0.001)] MW"
return "[round((powerused * 0.000000001),0.0001)] GW"

/**
* Get a list of turfs in a line from `starting_atom` to `ending_atom`.
*
* Uses the ultra-fast [Bresenham Line-Drawing Algorithm](https://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm).
*/
/proc/get_line(atom/starting_atom, atom/ending_atom)
var/current_x_step = starting_atom.x//start at x and y, then add 1 or -1 to these to get every turf from starting_atom to ending_atom
var/current_y_step = starting_atom.y
var/starting_z = starting_atom.z

var/list/line = list(get_turf(starting_atom))//get_turf(atom) is faster than locate(x, y, z)

var/x_distance = ending_atom.x - current_x_step //x distance
var/y_distance = ending_atom.y - current_y_step

var/abs_x_distance = abs(x_distance)//Absolute value of x distance
var/abs_y_distance = abs(y_distance)

var/x_distance_sign = SIGN(x_distance) //Sign of x distance (+ or -)
var/y_distance_sign = SIGN(y_distance)

var/x = abs_x_distance >> 1 //Counters for steps taken, setting to distance/2
var/y = abs_y_distance >> 1 //Bit-shifting makes me l33t. It also makes get_line() unnessecarrily fast.

if(abs_x_distance >= abs_y_distance) //x distance is greater than y
for(var/distance_counter in 0 to (abs_x_distance - 1))//It'll take abs_x_distance steps to get there
y += abs_y_distance

if(y >= abs_x_distance) //Every abs_y_distance steps, step once in y direction
y -= abs_x_distance
current_y_step += y_distance_sign

current_x_step += x_distance_sign //Step on in x direction
line += locate(current_x_step, current_y_step, starting_z)//Add the turf to the list
else
for(var/distance_counter in 0 to (abs_y_distance - 1))
x += abs_x_distance

if(x >= abs_y_distance)
x -= abs_y_distance
current_x_step += x_distance_sign

current_y_step += y_distance_sign
line += locate(current_x_step, current_y_step, starting_z)
return line


///chances are 1:value. anyprob(1) will always return true
/proc/anyprob(value)
return (rand(1,value)==value)
Expand Down
4 changes: 2 additions & 2 deletions code/__HELPERS/sorts/_Main.dm
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ GLOBAL_DATUM_INIT(sortInstance, /datum/sortInstance, new())
var/count1 = 0 //# of times in a row that first run won
var/count2 = 0 // " " " " " " second run won

//do the straightfoward thin until one run starts winning consistently
//do the straightforward thin until one run starts winning consistently

do
//ASSERT(len1 > 1 && len2 > 0)
Expand Down Expand Up @@ -493,7 +493,7 @@ GLOBAL_DATUM_INIT(sortInstance, /datum/sortInstance, new())
var/count1 = 0 //# of times in a row that first run won
var/count2 = 0 // " " " " " " second run won

//do the straightfoward thing until one run starts winning consistently
//do the straightforward thing until one run starts winning consistently
do
//ASSERT(len1 > 0 && len2 > 1)
if(call(cmp)(fetchElement(L,cursor2), fetchElement(L,cursor1)) < 0)
Expand Down
119 changes: 39 additions & 80 deletions code/__HELPERS/unsorted.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1494,88 +1494,47 @@ GLOBAL_LIST_INIT(WALLITEMS, list(
/proc/format_text(text)
return replacetext(replacetext(text,"\proper ",""),"\improper ","")

/proc/getline(atom/M, atom/N, include_from_atom = TRUE)//Ultra-Fast Bresenham Line-Drawing Algorithm
var/px=M.x //starting x
var/py=M.y
var/line[] = list(locate(px,py,M.z))
var/dx=N.x-px //x distance
var/dy=N.y-py
var/dxabs=abs(dx)//Absolute value of x distance
var/dyabs=abs(dy)
var/sdx=sign(dx) //Sign of x distance (+ or -)
var/sdy=sign(dy)
var/x=dxabs>>1 //Counters for steps taken, setting to distance/2
var/y=dyabs>>1 //Bit-shifting makes me l33t. It also makes getline() unnessecarrily fast.
var/j //Generic integer for counting
if(dxabs>=dyabs) //x distance is greater than y
for(j=0;j<dxabs;j++)//It'll take dxabs steps to get there
y+=dyabs
if(y>=dxabs) //Every dyabs steps, step once in y direction
y-=dxabs
py+=sdy
px+=sdx //Step on in x direction
if(j > 0 || include_from_atom)
line+=locate(px,py,M.z)//Add the turf to the list
else
for(j=0;j<dyabs;j++)
x+=dxabs
if(x>=dyabs)
x-=dyabs
px+=sdx
py+=sdy
if(j > 0 || include_from_atom)
line+=locate(px,py,M.z)
return line
/**
* Get a list of turfs in a line from `start_atom` to `end_atom`.
*
* Based on a linear interpolation method from [Red Blob Games](https://www.redblobgames.com/grids/line-drawing/#optimization).
*
* Arguments:
* * start_atom - starting point of the line
* * end_atom - ending point of the line
* * include_start_atom - when truthy includes start_atom in the list, default TRUE
*
* Returns:
* list - turfs from start_atom (in/exclusive) to end_atom (inclusive)
*/
/proc/get_line(atom/start_atom, atom/end_atom, include_start_atom = TRUE)
var/turf/start_turf = get_turf(start_atom)
var/turf/end_turf = get_turf(end_atom)
var/start_z = start_turf.z

//Bresenham's algorithm. This one deals efficiently with all 8 octants.
//Just don't ask me how it works.
/proc/getline2(atom/from_atom, atom/to_atom, include_from_atom = TRUE)
if(!from_atom || !to_atom) return 0
var/list/turf/turfs = list()

var/cur_x = from_atom.x
var/cur_y = from_atom.y

var/w = to_atom.x - from_atom.x
var/h = to_atom.y - from_atom.y
var/dx1 = 0
var/dx2 = 0
var/dy1 = 0
var/dy2 = 0
if(w < 0)
dx1 = -1
dx2 = -1
else if(w > 0)
dx1 = 1
dx2 = 1
if(h < 0) dy1 = -1
else if(h > 0) dy1 = 1
var/longest = abs(w)
var/shortest = abs(h)
if(!(longest > shortest))
longest = abs(h)
shortest = abs(w)
if(h < 0) dy2 = -1
else if (h > 0) dy2 = 1
dx2 = 0

var/numerator = longest >> 1
var/i
for(i = 0; i <= longest; i++)
if(i > 0 || include_from_atom)
turfs += locate(cur_x,cur_y,from_atom.z)
numerator += shortest
if(!(numerator < longest))
numerator -= longest
cur_x += dx1
cur_y += dy1
else
cur_x += dx2
cur_y += dy2
var/list/line = list()
if(include_start_atom)
line += start_turf

var/step_count = get_dist(start_turf, end_turf)
if(!step_count)
return line

return turfs
//as step_count and step size (1) are known can pre-calculate a lerp step, tiny number (1e-5) for rounding consistency
var/step_x = (end_turf.x - start_turf.x) / step_count + 1e-5
var/step_y = (end_turf.y - start_turf.y) / step_count + 1e-5

//locate() truncates the fraction, adding 0.5 so its effectively rounding to nearest coords for free
var/x = start_turf.x + 0.5
var/y = start_turf.y + 0.5
for(var/step in 1 to (step_count - 1)) //increment then locate() skips start_turf (in 1), since end_turf is known can skip that step too (step_count - 1)
x += step_x
y += step_y
line += locate(x, y, start_z)

line += end_turf

return line

//Key thing that stops lag. Cornerstone of performance in ss13, Just sitting here, in unsorted.dm.

Expand Down Expand Up @@ -1621,8 +1580,8 @@ GLOBAL_LIST_INIT(WALLITEMS, list(
/proc/explosive_antigrief_check(obj/item/explosive/explosive, mob/user)
var/turf/Turf = get_turf(explosive)
if(!(Turf.loc.type in GLOB.explosive_antigrief_exempt_areas))
var/crash_occured = (SSticker?.mode?.is_in_endgame)
if((Turf.z in SSmapping.levels_by_any_trait(list(ZTRAIT_MARINE_MAIN_SHIP, ZTRAIT_RESERVED))) && (GLOB.security_level < SEC_LEVEL_RED) && !crash_occured)
var/crash_occurred = (SSticker?.mode?.is_in_endgame)
if((Turf.z in SSmapping.levels_by_any_trait(list(ZTRAIT_MARINE_MAIN_SHIP, ZTRAIT_RESERVED))) && (GLOB.security_level < SEC_LEVEL_RED) && !crash_occurred)
switch(CONFIG_GET(number/explosive_antigrief))
if(ANTIGRIEF_DISABLED)
return FALSE
Expand Down
2 changes: 1 addition & 1 deletion code/_onclick/adjacent.dm
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ Quick adjacency (to turf):

var/turf/curT = get_turf(A)
var/is_turf = isturf(A)
for(var/turf/T in getline2(A, src))
for(var/turf/T in get_line(A, src))
if(curT == T)
continue
if(T.density)
Expand Down
2 changes: 1 addition & 1 deletion code/_onclick/observer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
var/message = "You have been dead for [DisplayTimeText(deathtime)]."
message = SPAN_WARNING("[message]")
to_chat(src, message)
to_chat(src, SPAN_WARNING("You must wait atleast 2.5 minutes before rejoining the game!"))
to_chat(src, SPAN_WARNING("You must wait at least 2.5 minutes before rejoining the game!"))
do_observe(target)
return FALSE

Expand Down
4 changes: 2 additions & 2 deletions code/_onclick/xeno.dm
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
return UnarmedAttack(get_step(src, Get_Compass_Dir(src, A)), tile_attack = TRUE, ignores_resin = TRUE)
return FALSE

/**The parent proc, will default to UnarmedAttack behaviour unless overriden
/**The parent proc, will default to UnarmedAttack behaviour unless overridden
Return XENO_ATTACK_ACTION if it does something and the attack should have full attack delay.
Return XENO_NONCOMBAT_ACTION if it did something and should have some delay.
Return XENO_NO_DELAY_ACTION if it gave an error message or should have no delay at all, ex. "You can't X that, it's Y!"
Expand Down Expand Up @@ -131,6 +131,6 @@ so that it doesn't double up on the delays) so that it applies the delay immedia

return ..()

//Larva attack, will default to attack_alien behaviour unless overriden
//Larva attack, will default to attack_alien behaviour unless overridden
/atom/proc/attack_larva(mob/living/carbon/xenomorph/larva/user)
return attack_alien(user)
2 changes: 1 addition & 1 deletion code/controllers/mc/subsystem.dm
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@
/datum/controller/subsystem/proc/OnConfigLoad()

/**
* Used to initialize the subsystem. This is expected to be overriden by subtypes.
* Used to initialize the subsystem. This is expected to be overridden by subtypes.
*/
/datum/controller/subsystem/Initialize()
return SS_INIT_NONE
Expand Down
4 changes: 2 additions & 2 deletions code/controllers/subsystem/atoms.dm
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ SUBSYSTEM_DEF(atoms)
flags = SS_NO_FIRE

var/old_initialized
/// A count of how many initalize changes we've made. We want to prevent old_initialize being overriden by some other value, breaking init code
/// A count of how many initalize changes we've made. We want to prevent old_initialize being overridden by some other value, breaking init code
var/initialized_changed = 0
var/init_start_time
var/processing_late_loaders = FALSE
Expand Down Expand Up @@ -183,7 +183,7 @@ SUBSYSTEM_DEF(atoms)
/datum/controller/subsystem/atoms/proc/map_loader_stop()
clear_tracked_initalize()

/// Use this to set initialized to prevent error states where old_initialized is overriden. It keeps happening and it's cheesing me off
/// Use this to set initialized to prevent error states where old_initialized is overridden. It keeps happening and it's cheesing me off
/datum/controller/subsystem/atoms/proc/set_tracked_initalized(value)
if(!initialized_changed)
old_initialized = initialized
Expand Down
2 changes: 1 addition & 1 deletion code/controllers/subsystem/decorator.dm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// our atom declaration should not be hardcoded for this SS existance.
// our atom declaration should not be hardcoded for this SS existence.
// if this subsystem is deleted, stuff still works
// That's why we define this here
/atom/proc/Decorate(deferable = FALSE)
Expand Down
2 changes: 1 addition & 1 deletion code/controllers/subsystem/events.dm
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ SUBSYSTEM_DEF(events)
var/list/running = list()
var/list/currentrun = list()

///The next world.time that a naturally occuring random event can be selected.
///The next world.time that a naturally occurring random event can be selected.
var/scheduled = 0
///Lower bound for how frequently events will occur
var/frequency_lower = 5 MINUTES
Expand Down
2 changes: 1 addition & 1 deletion code/controllers/subsystem/minimap.dm
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ SUBSYSTEM_DEF(minimaps)
* the raw lists are to speed up the Fire() of the subsystem so we dont have to filter through
* WARNING!
* There is a byond bug: http://www.byond.com/forum/post/2661309
* That that forces us to use a seperate list ref when accessing the lists of this datum
* That that forces us to use a separate list ref when accessing the lists of this datum
* Yea it hurts me too
*/
/datum/hud_displays
Expand Down
22 changes: 21 additions & 1 deletion code/controllers/subsystem/ticker.dm
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,27 @@ SUBSYSTEM_DEF(ticker)

CHECK_TICK
if(!mode.can_start(bypass_checks))
to_chat(world, "Reverting to pre-game lobby.")
to_chat(world, "Requirements to start [GLOB.master_mode] not met. Reverting to pre-game lobby.")
// Make only one more attempt
if(world.time - 2 * wait > CONFIG_GET(number/lobby_countdown) SECONDS)
flash_clients()
delay_start = TRUE
var/active_admins = 0
for(var/client/admin_client in GLOB.admins)
if(!admin_client.is_afk() && check_client_rights(admin_client, R_SERVER, FALSE))
active_admins = TRUE
break
if(active_admins)
to_chat(world, SPAN_CENTERBOLD("The game start has been delayed."))
message_admins(SPAN_ADMINNOTICE("Alert: Insufficent players ready to start [GLOB.master_mode].\nEither change mode and map or start round and bypass checks."))
else
var/fallback_mode = CONFIG_GET(string/gamemode_default)
SSticker.save_mode(fallback_mode)
GLOB.master_mode = fallback_mode
to_chat(world, SPAN_BOLDNOTICE("Notice: The Gamemode for next round has been set to [fallback_mode]"))
handle_map_reboot()
else
to_chat(world, "Attempting again...")
QDEL_NULL(mode)
GLOB.RoleAuthority.reset_roles()
return FALSE
Expand Down
14 changes: 8 additions & 6 deletions code/controllers/subsystem/vote.dm
Original file line number Diff line number Diff line change
Expand Up @@ -273,12 +273,14 @@ SUBSYSTEM_DEF(vote)
question = "Gamemode vote"
randomize_entries = TRUE
for(var/mode_type in config.gamemode_cache)
var/datum/game_mode/M = mode_type
if(initial(M.config_tag))
var/vote_cycle_met = !initial(M.vote_cycle) || (text2num(SSperf_logging?.round?.id) % initial(M.vote_cycle) == 0)
var/min_players_met = length(GLOB.clients) >= M.required_players
if(initial(M.votable) && vote_cycle_met && min_players_met)
choices += initial(M.config_tag)
var/datum/game_mode/cur_mode = mode_type
if(initial(cur_mode.config_tag))
cur_mode = new mode_type
var/vote_cycle_met = !initial(cur_mode.vote_cycle) || (text2num(SSperf_logging?.round?.id) % initial(cur_mode.vote_cycle) == 0)
var/min_players_met = length(GLOB.clients) >= cur_mode.required_players
if(initial(cur_mode.votable) && vote_cycle_met && min_players_met)
choices += initial(cur_mode.config_tag)
qdel(cur_mode)
if("groundmap")
question = "Ground map vote"
vote_sound = 'sound/voice/start_your_voting.ogg'
Expand Down
2 changes: 1 addition & 1 deletion code/datums/autocells/explosion.dm
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
That's it. There are some special rules, though, namely:
* If the explosion occured in a wall, the wave is strengthened
* If the explosion occurred in a wall, the wave is strengthened
with power *= reflection_multiplier and reflected back in the
direction it came from
Expand Down
Loading

0 comments on commit bd8d46b

Please sign in to comment.