Skip to content

Commit

Permalink
Merge branch 'master' into attachments-flavor-textinator
Browse files Browse the repository at this point in the history
  • Loading branch information
KoishiVibe authored Jul 24, 2024
2 parents ea7ff77 + 03c0038 commit 7c21062
Show file tree
Hide file tree
Showing 61 changed files with 643 additions and 182 deletions.
1 change: 1 addition & 0 deletions code/__DEFINES/atmospherics.dm
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,4 @@ var/MAX_EXPLOSION_RANGE = 14
#define VENT_GAS_SMOKE "Smoke"
#define VENT_GAS_CN20 "CN20 Nerve Gas"
#define VENT_GAS_CN20_XENO "CN20-X Nerve Gas"
#define VENT_GAS_LSD "ALD-91 LSD Gas"
1 change: 0 additions & 1 deletion code/__pragmas.dm
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#pragma SoftReservedKeyword error
#pragma DuplicateVariable error
#pragma DuplicateProcDefinition error
#pragma TooManyArguments error
#pragma PointlessParentCall error
#pragma PointlessBuiltinCall error
#pragma SuspiciousMatrixCall error
Expand Down
3 changes: 3 additions & 0 deletions code/_macros.dm
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@
#define GENERATE_DEBUG_ID "[rand(0, 9)][rand(0, 9)][rand(0, 9)][rand(0, 9)][pick(alphabet_lowercase)][pick(alphabet_lowercase)][pick(alphabet_lowercase)][pick(alphabet_lowercase)]"

#define RECT new /datum/shape/rectangle
#define SQUARE new /datum/shape/rectangle/square
#define ELLIPSE new /datum/shape/ellipse
#define CIRCLE new /datum/shape/ellipse/circle
#define QTREE new /datum/quadtree
#define SEARCH_QTREE(qtree, shape_range, flags) qtree.query_range(shape_range, null, flags)

Expand Down
3 changes: 1 addition & 2 deletions code/controllers/subsystem/sound.dm
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ SUBSYSTEM_DEF(sound)
if(!run_hearers) // Initialize for handling next template
run_hearers = run_queue[run_template] // get base hearers
if(run_template.range) // ranging
var/datum/shape/rectangle/zone = RECT(run_template.x, run_template.y, run_template.range * 2, run_template.range * 2)
run_hearers |= SSquadtree.players_in_range(zone, run_template.z)
run_hearers |= SSquadtree.players_in_range(SQUARE(run_template.x, run_template.y, run_template.range * 2), run_template.z)
if(MC_TICK_CHECK)
return
while(length(run_hearers)) // Output sound to hearers
Expand Down
52 changes: 0 additions & 52 deletions code/controllers/subsystem/ticker.dm
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,6 @@ SUBSYSTEM_DEF(ticker)
mode.declare_completion(force_ending)
REDIS_PUBLISH("byond.round", "type" = "round-complete")
flash_clients()
addtimer(CALLBACK(
SSvote,
/datum/controller/subsystem/vote/proc/initiate_vote,
"gamemode",
"SERVER",
CALLBACK(src, PROC_REF(handle_map_reboot)),
TRUE
), 3 SECONDS)
Master.SetRunLevel(RUNLEVEL_POSTGAME)

/// Attempt to start game asynchronously if applicable
Expand Down Expand Up @@ -161,16 +153,6 @@ SUBSYSTEM_DEF(ticker)
return FALSE
return TRUE

/datum/controller/subsystem/ticker/proc/handle_map_reboot()
addtimer(CALLBACK(
SSvote,
/datum/controller/subsystem/vote/proc/initiate_vote,
"groundmap",
"SERVER",
CALLBACK(src, PROC_REF(Reboot)),
TRUE
), 3 SECONDS)

/datum/controller/subsystem/ticker/proc/setup()
to_chat(world, SPAN_BOLDNOTICE("Enjoy the game!"))
var/init_start = world.timeofday
Expand Down Expand Up @@ -349,40 +331,6 @@ SUBSYSTEM_DEF(ticker)
fdel("data/mode.txt")
WRITE_FILE(file("data/mode.txt"), the_mode)


/datum/controller/subsystem/ticker/proc/Reboot(reason, delay)
set waitfor = FALSE

if(usr && !check_rights(R_SERVER))
return

if(graceful)
to_chat_forced(world, "<h3>[SPAN_BOLDNOTICE("Shutting down...")]</h3>")
world.Reboot(FALSE)
return

if(!delay)
delay = CONFIG_GET(number/round_end_countdown) * 10

var/skip_delay = check_rights()
if(delay_end && !skip_delay)
to_chat(world, SPAN_BOLDNOTICE("An admin has delayed the round end."))
return

to_chat(world, SPAN_BOLDNOTICE("Rebooting World in [DisplayTimeText(delay)]. [reason]"))

var/start_wait = world.time
sleep(delay - (world.time - start_wait))

if(delay_end && !skip_delay)
to_chat(world, SPAN_BOLDNOTICE("Reboot was cancelled by an admin."))
return

log_game("Rebooting World. [reason]")
to_chat_forced(world, "<h3>[SPAN_BOLDNOTICE("Rebooting...")]</h3>")

world.Reboot(TRUE)

/datum/controller/subsystem/ticker/proc/create_characters()
if(!RoleAuthority)
return
Expand Down
1 change: 1 addition & 0 deletions code/datums/ammo/bullet/shotgun.dm
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@

/datum/ammo/bullet/shotgun/buckshot/special
name = "buckshot shell, USCM special type"
handful_state = "special_buck"
bonus_projectiles_type = /datum/ammo/bullet/shotgun/spread/special

accurate_range = 8
Expand Down
10 changes: 0 additions & 10 deletions code/datums/global_variables.dm
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,11 @@

/client/proc/debug_global_variable(name, value, level)
var/html = ""
var/change = 0
//to make the value bold if changed
if(!(admin_holder.rights & R_DEBUG))
return html

html += "<li style='backgroundColor:white'><a href='?_src_=glob_vars;varnameedit=[name]'>E</a><a href='?_src_=glob_vars;varnamechange=[name]'>C</a> "
if(value != initial(global.vars[name]))
html += "<font color='#B300B3'>"
change = 1

if (isnull(value))
html += "[name] = <span class='value'>null</span>"
Expand Down Expand Up @@ -175,8 +171,6 @@

else
html += "[name] = <span class='value'>[value]</span>"
if(change)
html += "</font>"

html += "</li>"

Expand Down Expand Up @@ -353,7 +347,6 @@
if(admin_holder && admin_holder.marked_datum)
possible_classes += "marked datum"
possible_classes += "edit referenced object"
possible_classes += "restore to default"

class = tgui_input_list(usr, "What kind of variable?","Variable Type", possible_classes)
if(!class)
Expand All @@ -365,9 +358,6 @@
mod_list(global.vars[variable])
return

if("restore to default")
global.vars[variable] = initial(global.vars[variable])

if("edit referenced object")
return .(global.vars[variable])

Expand Down
145 changes: 113 additions & 32 deletions code/datums/quadtree.dm
Original file line number Diff line number Diff line change
Expand Up @@ -49,43 +49,124 @@
..()
return QDEL_HINT_IWILLGC

/datum/shape //Leaving rectangles as a subtype if anyone decides to add circles later
/// A simple geometric shape for testing collisions and intersections. This one is a single point.
/datum/shape
/// Horizontal position of the shape's center point.
var/center_x = 0
/// Vertical position of the shape's center point.
var/center_y = 0
/// Distance from the shape's leftmost to rightmost extent.
var/bounds_x = 0
/// Distance from the shape's topmost to bottommost extent.
var/bounds_y = 0

/datum/shape/proc/intersects()
return
/datum/shape/proc/contains()
return
/datum/shape/New(center_x, center_y)
set_shape(center_x, center_y)

/// Assign shape variables.
/datum/shape/proc/set_shape(center_x, center_y)
src.center_x = center_x
src.center_y = center_y

/// Returns TRUE if the coordinates x, y are in or on the shape, otherwise FALSE.
/datum/shape/proc/contains_xy(x, y)
return center_x == x && center_y == y

/// Returns TRUE if the coord datum is in or on the shape, otherwise FALSE.
/datum/shape/proc/contains_coords(datum/coords/coords)
return contains_xy(coords.x_pos, coords.y_pos)

/// Returns TRUE if the atom is in or on the shape, otherwise FALSE.
/datum/shape/proc/contains_atom(atom/atom)
return contains_xy(atom.x, atom.y)

/// Returns TRUE if this shape's bounding box intersects the provided shape's bounding box, otherwise FALSE. Generally faster than a full intersection test.
/datum/shape/proc/intersects_aabb(datum/shape/aabb)
return (abs(src.center_x - aabb.center_x) <= (src.bounds_x + aabb.bounds_x) * 0.5) && (abs(src.center_y - aabb.center_y) <= (src.bounds_y + aabb.bounds_y) * 0.5)

/// Returns TRUE if this shape intersects the provided rectangle shape, otherwise FALSE.
/datum/shape/proc/intersects_rect(datum/shape/rectangle/rect)
return rect.contains_xy(src.center_x, src.center_y)

/// A simple geometric shape for testing collisions and intersections. This one is an axis-aligned rectangle.
/datum/shape/rectangle
/// Distance from the shape's leftmost to rightmost extent.
var/width = 0
/// Distance from the shape's topmost to bottommost extent.
var/height = 0

/datum/shape/rectangle/New(center_x, center_y, width, height)
set_shape(center_x, center_y, width, height)

/datum/shape/rectangle/set_shape(center_x, center_y, width, height)
..()
src.bounds_x = width
src.bounds_y = height
src.width = width
src.height = height

/datum/shape/rectangle/contains_xy(x, y)
return (abs(center_x - x) <= width * 0.5) && (abs(center_y - y) <= height * 0.5)

/datum/shape/rectangle/intersects_rect(datum/shape/rectangle/rect)
return intersects_aabb(rect)

/// A simple geometric shape for testing collisions and intersections. This one is an axis-aligned square.
/datum/shape/rectangle/square
/// Distance between the shape's opposing extents.
var/length = 0

/datum/shape/rectangle/square/New(center_x, center_y, length)
set_shape(center_x, center_y, length)

/datum/shape/rectangle/square/set_shape(center_x, center_y, length)
..(center_x, center_y, length, length)
src.length = length

/// A simple geometric shape for testing collisions and intersections. This one is an axis-aligned ellipse.
/datum/shape/ellipse
/// Distance from the shape's leftmost to rightmost extent.
var/width = 0
/// Distance from the shape's topmost to bottommost extent.
var/height = 0
VAR_PROTECTED/_axis_x_sq = 0
VAR_PROTECTED/_axis_y_sq = 0

/datum/shape/ellipse/New(center_x, center_y, width, height)
set_shape(center_x, center_y, width, height)

/datum/shape/rectangle/New(x, y, w, h)
/datum/shape/ellipse/set_shape(center_x, center_y, width, height)
..()
center_x = x
center_y = y
width = w
height = h

/datum/shape/rectangle/intersects(datum/shape/rectangle/range)
return !(range.center_x + range.width/2 < center_x - width / 2|| \
range.center_x - range.width/2 > center_x + width / 2|| \
range.center_y + range.height/2 < center_y - height / 2|| \
range.center_y - range.height/2 > center_y + height / 2)

/datum/shape/rectangle/contains(datum/coords/coords)
return (coords.x_pos >= center_x - width / 2 \
&& coords.x_pos <= center_x + width / 2 \
&& coords.y_pos >= center_y - height /2 \
&& coords.y_pos <= center_y + height / 2)

/datum/shape/rectangle/proc/contains_atom(atom/A)
return (A.x >= center_x - width / 2 \
&& A.x <= center_x + width / 2 \
&& A.y >= center_y - height /2 \
&& A.y <= center_y + height / 2)
src.bounds_x = width
src.bounds_y = height
src.width = width
src.height = height
src._axis_x_sq = (width * 0.5)**2
src._axis_y_sq = (height * 0.5)**2

/datum/shape/ellipse/contains_xy(x, y)
return ((center_x - x)**2 / _axis_x_sq + (center_y - y)**2 / _axis_y_sq <= 1)

/datum/shape/ellipse/intersects_rect(datum/shape/rectangle/rect)
if(..())
return TRUE

var/nearest_x = clamp(src.center_x, rect.center_x - rect.width * 0.5, rect.center_x + rect.width * 0.5)
var/nearest_y = clamp(src.center_y, rect.center_y - rect.height * 0.5, rect.center_y + rect.height * 0.5)

return src.contains_xy(nearest_x, nearest_y)

/// A simple geometric shape for testing collisions and intersections. This one is a circle.
/datum/shape/ellipse/circle
/// Distance from the shape's center to edge.
var/radius = 0

/datum/shape/ellipse/circle/New(center_x, center_y, radius)
set_shape(center_x, center_y, radius)

/datum/shape/ellipse/circle/set_shape(center_x, center_y, radius)
..(center_x, center_y, radius * 2, radius * 2)
src.radius = radius

/datum/quadtree/proc/subdivide()
//Warning: this might give you eye cancer
Expand All @@ -96,7 +177,7 @@
is_divided = TRUE

/datum/quadtree/proc/insert_player(datum/coords/qtplayer/p_coords)
if(!boundary.contains(p_coords))
if(!boundary.contains_coords(p_coords))
return FALSE

if(!player_coords)
Expand All @@ -118,11 +199,11 @@
player_coords.Add(p_coords)
return TRUE

/datum/quadtree/proc/query_range(datum/shape/rectangle/range, list/found_players, flags = 0)
/datum/quadtree/proc/query_range(datum/shape/range, list/found_players, flags = 0)
if(!found_players)
found_players = list()
. = found_players
if(!range?.intersects(boundary))
if(!range?.intersects_rect(boundary))
return
if(is_divided)
nw_branch.query_range(range, found_players, flags)
Expand All @@ -136,7 +217,7 @@
continue
if((flags & QTREE_EXCLUDE_OBSERVER) && P.is_observer)
continue
if(range.contains(P))
if(range.contains_coords(P))
if(flags & QTREE_SCAN_MOBS)
found_players.Add(P.player)
continue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,7 @@
list("Roller Bed", round(scale * 2), /obj/item/roller, VENDOR_ITEM_REGULAR),
list("Machete Scabbard (Full)", round(scale * 5), /obj/item/storage/large_holster/machete/full, VENDOR_ITEM_REGULAR),
list("Binoculars", round(scale * 1), /obj/item/device/binoculars, VENDOR_ITEM_REGULAR),
list("AN/PSQ-55 Sentry Console", round(scale * 1), /obj/item/device/sentry_computer, VENDOR_ITEM_REGULAR),
list("Spare PDT/L Battle Buddy Kit", round(scale * 3), /obj/item/storage/box/pdt_kit, VENDOR_ITEM_REGULAR),
list("Rail Flashlight", round(scale * 5), /obj/item/attachable/flashlight, VENDOR_ITEM_REGULAR),
)
Expand Down
Loading

0 comments on commit 7c21062

Please sign in to comment.