Skip to content

Commit

Permalink
Port /tg/ move manager, drift and jetpack components. (#27698)
Browse files Browse the repository at this point in the history
* Port /tg/ move manager, drift and jetpack components.

* don't add go through newtonian movement if not moved to a turf

* various cleans for blood drifts and mob speed

* fix slow meteors

* why on fuck's earth aren't speedbikes vehicles

* style lint

* also wtf

* okay i'm an idiot

* fix meaty ore speed and blood decal double stepping

* fix not unbuckling pulled object occupants

* don't bother dealing with immovable rods just yet

* exclude bubblegum and vetus from move manager for now

* fix issues related to null weightless blood icons

* reset blood icon state properly

* fuck it, we'll deal with mobs when basic mobs happen

* break infinite loop in decal splat
  • Loading branch information
warriorstar-orion authored Jan 22, 2025
1 parent 3954981 commit 157276d
Show file tree
Hide file tree
Showing 105 changed files with 2,361 additions and 533 deletions.
9 changes: 9 additions & 0 deletions code/__DEFINES/MC.dm
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,12 @@
}\
/datum/controller/subsystem/timer/##X/fire() {..() /*just so it shows up on the profiler*/} \
/datum/controller/subsystem/timer/##X

#define MOVEMENT_SUBSYSTEM_DEF(X) GLOBAL_REAL(SS##X, /datum/controller/subsystem/movement/##X);\
/datum/controller/subsystem/movement/##X/New(){\
NEW_SS_GLOBAL(SS##X);\
PreInit();\
ss_id="movement_[#X]";\
}\
/datum/controller/subsystem/movement/##X/fire() {..() /*just so it shows up on the profiler*/} \
/datum/controller/subsystem/movement/##X
1 change: 1 addition & 0 deletions code/__DEFINES/color_defines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@

#define COLOR_BLOOD_BASE "#A10808"
#define COLOR_BLOOD_MACHINE "#1F181F"
#define COLOR_BLOOD_XENO "#05EE05"

// Pipe colours
#define PIPE_COLOR_GREY "#ffffff" //yes white is grey
Expand Down
9 changes: 9 additions & 0 deletions code/__DEFINES/dcs/mob_signals.dm
Original file line number Diff line number Diff line change
Expand Up @@ -218,3 +218,12 @@

/// from remove_ventcrawler(): (mob/living/crawler)
#define COMSIG_LIVING_EXIT_VENTCRAWL "living_exit_ventcrawl"

/// From base of /client/Move(): (new_loc, direction)
#define COMSIG_MOB_CLIENT_PRE_MOVE "mob_client_pre_move"
/// Should always match COMPONENT_MOVABLE_BLOCK_PRE_MOVE as these are interchangeable and used to block movement.
#define COMSIG_MOB_CLIENT_BLOCK_PRE_MOVE COMPONENT_MOVABLE_BLOCK_PRE_MOVE
/// The argument of move_args which corresponds to the loc we're moving to
#define MOVE_ARG_NEW_LOC 1
/// The arugment of move_args which dictates our movement direction
#define MOVE_ARG_DIRECTION 2
16 changes: 16 additions & 0 deletions code/__DEFINES/dcs/movable_signals.dm
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,19 @@
/// Called when blocking a teleport
#define COMSIG_ATOM_INTERCEPT_TELEPORTED "intercept_teleported"
#define COMPONENT_BLOCK_TELEPORT (1<<0)
///from base of atom/movable/newtonian_move(): (inertia_direction, start_delay)
#define COMSIG_MOVABLE_NEWTONIAN_MOVE "movable_newtonian_move"
#define COMPONENT_MOVABLE_NEWTONIAN_BLOCK (1<<0)

///from datum/component/drift/apply_initial_visuals(): ()
#define COMSIG_MOVABLE_DRIFT_VISUAL_ATTEMPT "movable_drift_visual_attempt"
#define DRIFT_VISUAL_FAILED (1<<0)
///from datum/component/drift/allow_final_movement(): ()
#define COMSIG_MOVABLE_DRIFT_BLOCK_INPUT "movable_drift_block_input"
#define DRIFT_ALLOW_INPUT (1<<0)

///called when the movable's glide size is updated: (new_glide_size)
#define COMSIG_MOVABLE_UPDATE_GLIDE_SIZE "movable_glide_size"

///signal sent out by an atom when it is no longer pulling something : (atom/pulling)
#define COMSIG_ATOM_NO_LONGER_PULLING "movable_no_longer_pulling"
15 changes: 15 additions & 0 deletions code/__DEFINES/dcs/moveloop_signals.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
///from [/datum/move_loop/start_loop] ():
#define COMSIG_MOVELOOP_START "moveloop_start"
///from [/datum/move_loop/stop_loop] ():
#define COMSIG_MOVELOOP_STOP "moveloop_stop"
///from [/datum/move_loop/process] ():
#define COMSIG_MOVELOOP_PREPROCESS_CHECK "moveloop_preprocess_check"
#define MOVELOOP_SKIP_STEP (1<<0)
///from [/datum/move_loop/process] (succeeded, visual_delay):
#define COMSIG_MOVELOOP_POSTPROCESS "moveloop_postprocess"
//from [/datum/move_loop/has_target/jps/recalculate_path] ():
#define COMSIG_MOVELOOP_JPS_REPATH "moveloop_jps_repath"
///From base of /datum/move_loop/process() after attempting to move a movable: (datum/move_loop/loop, old_dir)
#define COMSIG_MOVABLE_MOVED_FROM_LOOP "movable_moved_from_loop"
///from [/datum/move_loop/has_target/jps/on_finish_pathing]
#define COMSIG_MOVELOOP_JPS_FINISHED_PATHING "moveloop_jps_finished_pathing"
8 changes: 8 additions & 0 deletions code/__DEFINES/dcs/obj_signals.dm
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@
#define COMSIG_GLOB_CURSED_SLOT_MACHINE_WON "cursed_slot_machine_won"


// /obj/item/tank/jetpack

/// from /obj/item/tank/jetpack/proc/turn_on() : ()
#define COMSIG_JETPACK_ACTIVATED "jetpack_activated"
#define JETPACK_ACTIVATION_FAILED (1<<0)
/// from /obj/item/tank/jetpack/proc/turn_off() : ()
#define COMSIG_JETPACK_DEACTIVATED "jetpack_deactivated"

// other subtypes

/// from /datum/component/shelved/UnregisterFromParent(): (parent_uid)
Expand Down
14 changes: 14 additions & 0 deletions code/__DEFINES/directions.dm
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,25 @@
/// returns TRUE if direction is cardinal and false if not
#define IS_DIR_CARDINAL(dir) (!IS_DIR_DIAGONAL(dir))

///True if the dir is north or south, false therwise
#define NSCOMPONENT(d) (d&(NORTH|SOUTH))
///True if the dir is east/west, false otherwise
#define EWCOMPONENT(d) (d&(EAST|WEST))

/// Inverse direction, taking into account UP|DOWN if necessary.
#define REVERSE_DIR(dir) ( ((dir & 85) << 1) | ((dir & 170) >> 1) )
/// returns TRUE if the direction is EAST or WEST
#define DIR_JUST_HORIZONTAL(dir) ((dir == EAST) || (dir == WEST))
/// returns TRUE if the direction is NORTH or SOUTH
#define DIR_JUST_VERTICAL(dir) ((dir == NORTH) || (dir == SOUTH))

/// North direction as a string "[1]"
#define TEXT_NORTH "[NORTH]"
/// South direction as a string "[2]"
#define TEXT_SOUTH "[SOUTH]"
/// East direction as a string "[4]"
#define TEXT_EAST "[EAST]"
/// West direction as a string "[8]"
#define TEXT_WEST "[WEST]"

#define EXCLUSIVE_OR(thing_one, thing_two) ((thing_one)^(thing_two))
4 changes: 4 additions & 0 deletions code/__DEFINES/mob_defines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -383,3 +383,7 @@
#define BRAIN_DAMAGE_RATIO_MODERATE 6 / 12
#define BRAIN_DAMAGE_RATIO_SEVERE 8 / 12
#define BRAIN_DAMAGE_RATIO_CRITICAL 10 / 12

#define GRAB_PIXEL_SHIFT_PASSIVE 6
#define GRAB_PIXEL_SHIFT_AGGRESSIVE 12
#define GRAB_PIXEL_SHIFT_NECK 16
71 changes: 71 additions & 0 deletions code/__DEFINES/movement_defines.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/// The minimum for glide_size to be clamped to.
#define MIN_GLIDE_SIZE 1
/// The maximum for glide_size to be clamped to.
/// This shouldn't be higher than the icon size, and generally you shouldn't be changing this, but it's here just in case.
#define MAX_GLIDE_SIZE 32

//Movement loop priority. Only one loop can run at a time, this dictates that
// Higher numbers beat lower numbers
///Standard, go lower then this if you want to override, higher otherwise
#define MOVEMENT_DEFAULT_PRIORITY 10
///Very few things should override this
#define MOVEMENT_SPACE_PRIORITY 100
///Higher then the heavens
#define MOVEMENT_ABOVE_SPACE_PRIORITY (MOVEMENT_SPACE_PRIORITY + 1)

//Movement loop flags
///Should the loop act immediately following its addition?
#define MOVEMENT_LOOP_START_FAST (1<<0)
///Do we not use the priority system?
#define MOVEMENT_LOOP_IGNORE_PRIORITY (1<<1)
///Should we override the loop's glide?
#define MOVEMENT_LOOP_IGNORE_GLIDE (1<<2)
///Should we not update our movables dir on move?
#define MOVEMENT_LOOP_NO_DIR_UPDATE (1<<3)
///Is the loop moving the movable outside its control, like it's an external force? e.g. footsteps won't play if enabled.
#define MOVEMENT_LOOP_OUTSIDE_CONTROL (1<<4)

// Movement loop status flags
/// Has the loop been paused, soon to be resumed?
#define MOVELOOP_STATUS_PAUSED (1<<0)
/// Is the loop running? (Is true even when paused)
#define MOVELOOP_STATUS_RUNNING (1<<1)
/// Is the loop queued in a subsystem?
#define MOVELOOP_STATUS_QUEUED (1<<2)

/**
* Returns a bitfield containing flags both present in `flags` arg and the `processing_move_loop_flags` move_packet variable.
* Has no use outside of procs called within the movement proc chain.
*/
#define CHECK_MOVE_LOOP_FLAGS(movable, flags) (movable.move_packet ? (movable.move_packet.processing_move_loop_flags & (flags)) : NONE)

//Index defines for movement bucket data packets
#define MOVEMENT_BUCKET_TIME 1
#define MOVEMENT_BUCKET_LIST 2

///Return values for moveloop Move()
#define MOVELOOP_FAILURE 0
#define MOVELOOP_SUCCESS 1
#define MOVELOOP_NOT_READY 2

#define ACTIVE_MOVEMENT_OLDLOC 1
#define ACTIVE_MOVEMENT_DIRECTION 2
#define ACTIVE_MOVEMENT_FORCED 3
#define ACTIVE_MOVEMENT_OLDLOCS 4

/// The arguments of this macro correspond directly to the argument order of /atom/movable/proc/Moved
#define SET_ACTIVE_MOVEMENT(_old_loc, _direction, _forced, _oldlocs) \
active_movement = list( \
_old_loc, \
_direction, \
_forced, \
_oldlocs, \
)

/// Finish any active movements
#define RESOLVE_ACTIVE_MOVEMENT \
if(active_movement) { \
var/__move_args = active_movement; \
active_movement = null; \
Moved(arglist(__move_args)); \
}
16 changes: 0 additions & 16 deletions code/__DEFINES/movement_info.dm

This file was deleted.

8 changes: 7 additions & 1 deletion code/__DEFINES/vehicle_defines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,16 @@
/// The vehicle being ridden requires pixel offsets for all directions
#define RIDING_OFFSET_ALL "ALL"

/// Compensating for time dilation
GLOBAL_VAR_INIT(glide_size_multiplier, 1.0)

///Broken down, here's what this does:
/// divides the world icon_size (32) by delay divided by ticklag to get the number of pixels something should be moving each tick.
/// The division result is given a min value of 1 to prevent obscenely slow glide sizes from being set
/// Then that's multiplied by the global glide size multiplier. 1.25 by default feels pretty close to spot on. This is just to try to get byond to behave.
/// The whole result is then clamped to within the range above.
/// Not very readable but it works
#define DELAY_TO_GLIDE_SIZE(delay) (clamp(((world.icon_size / max((delay) / world.tick_lag, 1))), 1, 32))
#define DELAY_TO_GLIDE_SIZE(delay) (clamp(((world.icon_size / max((delay) / world.tick_lag, 1)) * GLOB.glide_size_multiplier), MIN_GLIDE_SIZE, MAX_GLIDE_SIZE))

///Similar to DELAY_TO_GLIDE_SIZE, except without the clamping, and it supports piping in an unrelated scalar
#define MOVEMENT_ADJUSTED_GLIDE_SIZE(delay, movement_disparity) (world.icon_size / ((delay) / world.tick_lag) * movement_disparity * GLOB.glide_size_multiplier)
38 changes: 38 additions & 0 deletions code/__HELPERS/lists.dm
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,44 @@
};\
} while(FALSE)

#define SORT_FIRST_INDEX(list) (list[1])
#define SORT_COMPARE_DIRECTLY(thing) (thing)
#define SORT_VAR_NO_TYPE(varname) var/varname

/****
* Even more custom binary search sorted insert, using defines instead of vars
* INPUT: Item to be inserted
* LIST: List to insert INPUT into
* TYPECONT: A define setting the var to the typepath of the contents of the list
* COMPARE: The item to compare against, usualy the same as INPUT
* COMPARISON: A define that takes an item to compare as input, and returns their comparable value
* COMPTYPE: How should the list be compared? Either COMPARE_KEY or COMPARE_VALUE.
*/
#define BINARY_INSERT_DEFINE(INPUT, LIST, TYPECONT, COMPARE, COMPARISON, COMPTYPE) \
do {\
var/list/__BIN_LIST = LIST;\
var/__BIN_CTTL = length(__BIN_LIST);\
if(!__BIN_CTTL) {\
__BIN_LIST += INPUT;\
} else {\
var/__BIN_LEFT = 1;\
var/__BIN_RIGHT = __BIN_CTTL;\
var/__BIN_MID = (__BIN_LEFT + __BIN_RIGHT) >> 1;\
##TYPECONT(__BIN_ITEM);\
while(__BIN_LEFT < __BIN_RIGHT) {\
__BIN_ITEM = COMPTYPE;\
if(##COMPARISON(__BIN_ITEM) <= ##COMPARISON(COMPARE)) {\
__BIN_LEFT = __BIN_MID + 1;\
} else {\
__BIN_RIGHT = __BIN_MID;\
};\
__BIN_MID = (__BIN_LEFT + __BIN_RIGHT) >> 1;\
};\
__BIN_ITEM = COMPTYPE;\
__BIN_MID = ##COMPARISON(__BIN_ITEM) > ##COMPARISON(COMPARE) ? __BIN_MID : __BIN_MID + 1;\
__BIN_LIST.Insert(__BIN_MID, INPUT);\
};\
} while(FALSE)

// Generic listoflist safe add and removal macros:
///If value is a list, wrap it in a list so it can be used with list add/remove operations
Expand Down
8 changes: 4 additions & 4 deletions code/__HELPERS/mob_helpers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@
var/user_loc = user.loc

var/drifting = 0
if(!user.Process_Spacemove(0) && user.inertia_dir)
if(GLOB.move_manager.processing_on(user, SSspacedrift))
drifting = 1

var/target_loc = target.loc
Expand Down Expand Up @@ -367,7 +367,7 @@
break
continue

if(drifting && !user.inertia_dir)
if(drifting && !GLOB.move_manager.processing_on(user, SSspacedrift))
drifting = 0
user_loc = user.loc

Expand Down Expand Up @@ -398,7 +398,7 @@
var/atom/Uloc = user.loc

var/drifting = FALSE
if(!allow_moving && !user.Process_Spacemove(0) && user.inertia_dir)
if(!allow_moving && GLOB.move_manager.processing_on(user, SSspacedrift))
drifting = TRUE

var/holding = user.get_active_hand()
Expand Down Expand Up @@ -426,7 +426,7 @@
if(progress)
progbar.update(world.time - starttime)
if(!allow_moving)
if(drifting && !user.inertia_dir)
if(drifting && !GLOB.move_manager.processing_on(user, SSspacedrift))
drifting = FALSE
Uloc = user.loc
if(!drifting && user.loc != Uloc)
Expand Down
3 changes: 3 additions & 0 deletions code/__HELPERS/unsorted.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1748,6 +1748,9 @@ GLOBAL_DATUM_INIT(dview_mob, /mob/dview, new)
matches[key] = value
return matches

/proc/return_typenames(type)
return splittext("[type]", "/")

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

//Increases delay as the server gets more overloaded,
Expand Down
66 changes: 0 additions & 66 deletions code/controllers/subsystem/SSspacedrift.dm

This file was deleted.

2 changes: 1 addition & 1 deletion code/controllers/subsystem/SSthrowing.dm
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ SUBSYSTEM_DEF(throwing)
finalize()
return

if(!AM.Move(step, get_dir(AM, step))) // we hit something during our move...
if(!AM.Move(step, get_dir(AM, step), DELAY_TO_GLIDE_SIZE(1 / speed))) // we hit something during our move...
if(AM.throwing) // ...but finalize() wasn't called on Bump() because of a higher level definition that doesn't always call parent.
finalize()
return
Expand Down
Loading

0 comments on commit 157276d

Please sign in to comment.