mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-20 12:35:33 +01:00
Many smart pipe fixes (#60981)
* Smart pipes now actually go over smart pipes
This was ostensibly the main feature of smart pipes, so should be
fairly important
Parentheses are technically not required around the |, but I think
it's important to emphasise the importance of parentheses around
bitwise operators as this was apparently broken since 3e8407c471
Also purge var/connections and var/connection_num, since it's
literally only used for a `machine.connection_num < 3` check
which is completely redundant, and we already build a bitfield
tracking active directions.
* Smart pipes bridge over straight pipe types
This improves bridging to now go over most devices where possible,
letting you, for example, bridge over a perpindicular layer adapter.
* Pipe construction: Better documentation
Cleans up smart pipe documentation to match what's actually happening.
No functional changes.
* Skip pipes on different layers earlier
This prevents a pipe being made into a bridge perpindicular to a pipe
on a completely different layer, then failing to turn into a bridge
perpindicular to a relevant pipe.
* Pop superfluous parentheses
* Prevent creation of stub pipes
Setting the RPD to create a smart pipe that can only connect in one
direction would cause it to create invisible pipes that would still
block the placement of other pipes.
* The RPD can now reprogram smart pipes
The RPD can only affect smart pipes in directions that they are not
currently connected to.
This makes it easier to adjust designs after the fact, including
prevening round-start pipes from eagerly linking to a grey layer
adapter.
* Even smarter pipes
No more turning into bridge pipes. We now only try to be smart if
placement would fail, and we do our best to find a solution
whenever there is at least one smart pipe involved, regardless
of whether we're currently placing a smart pipe or not.
We never reconfigure any directions that a smart pipe is currently
connected, and we never reconfigure a smart pipe to have one or less
usable directions.
* Smartly go across perpindicular layer adapters
Also works when we're placing a layer adapter perpindicular to a
promiscuous smart pipe
* Pipes: Factor out loops and some bitfiddling
Create and use helpers with documented purposes over inline bitfiddling,
when it makes sense.
Many loops and switch statements were recreating information that was
already there.
Some relationships between pipe bitfield states were already assumed.
This centralises the functionality that relies upon these assumptions,
places them where the bits are defined, and documents them.
Rewrite some bitwise operations to be more idiomatic.
* Smart pipes: Debugging output
I normally clean history before pushing changes to any project,
but I feel like this should be saved.
* Revert "Smart pipes: Debugging output"
This reverts commit bb3aa76cf6d08e4d0951113a26fc9d48b6bc1735.
* Add trailing comma
The lack of this was making the linter sad
This commit is contained in:
@@ -10,7 +10,7 @@ RPD
|
||||
#define BUILD_MODE (1<<0)
|
||||
#define WRENCH_MODE (1<<1)
|
||||
#define DESTROY_MODE (1<<2)
|
||||
|
||||
#define REPROGRAM_MODE (1<<3)
|
||||
|
||||
GLOBAL_LIST_INIT(atmos_pipe_recipes, list(
|
||||
"Pipes" = list(
|
||||
@@ -216,6 +216,8 @@ GLOBAL_LIST_INIT(transit_tube_recipes, list(
|
||||
var/transit_build_speed = 0.5 SECONDS
|
||||
///Speed of removal of unwrenched devices
|
||||
var/destroy_speed = 0.5 SECONDS
|
||||
///Speed of reprogramming connectable directions of smart pipes
|
||||
var/reprogram_speed = 0.5 SECONDS
|
||||
///Category currently active (Atmos, disposal, transit)
|
||||
var/category = ATMOS_CATEGORY
|
||||
///Piping layer we are going to spawn the atmos device in
|
||||
@@ -231,7 +233,7 @@ GLOBAL_LIST_INIT(transit_tube_recipes, list(
|
||||
///Stores the first transit device
|
||||
var/static/datum/pipe_info/first_transit
|
||||
///The modes that are allowed for the RPD
|
||||
var/mode = BUILD_MODE | DESTROY_MODE | WRENCH_MODE
|
||||
var/mode = BUILD_MODE | DESTROY_MODE | WRENCH_MODE | REPROGRAM_MODE
|
||||
/// Bitflags for upgrades
|
||||
var/upgrade_flags
|
||||
|
||||
@@ -409,12 +411,12 @@ GLOBAL_LIST_INIT(transit_tube_recipes, list(
|
||||
playeffect = FALSE
|
||||
if("mode")
|
||||
var/n = text2num(params["mode"])
|
||||
if(mode & n)
|
||||
mode &= ~n
|
||||
else
|
||||
mode |= n
|
||||
mode ^= n
|
||||
if("init_dir_setting")
|
||||
p_init_dir ^= text2dir(params["dir_flag"])
|
||||
var/target_dir = p_init_dir ^ text2dir(params["dir_flag"])
|
||||
// Refuse to create a smart pipe that can only connect in one direction (it would act weirdly and lack an icon)
|
||||
if (ISNOTSTUB(target_dir))
|
||||
p_init_dir = target_dir
|
||||
if("init_reset")
|
||||
p_init_dir = ALL_CARDINALS
|
||||
if(playeffect)
|
||||
@@ -457,6 +459,42 @@ GLOBAL_LIST_INIT(transit_tube_recipes, list(
|
||||
qdel(attack_target)
|
||||
return
|
||||
|
||||
if(mode & REPROGRAM_MODE)
|
||||
var/obj/machinery/atmospherics/pipe/smart/S = attack_target
|
||||
if(istype(S))
|
||||
if (S.dir == ALL_CARDINALS)
|
||||
to_chat(user, span_warning("\The [S] has no unconnected directions!"))
|
||||
return
|
||||
var/target_init_dir = S.GetInitDirections()
|
||||
if (target_init_dir == p_init_dir)
|
||||
to_chat(user, span_warning("\The [S] is already in this configuration!"))
|
||||
return
|
||||
// Check for differences in unconnected directions
|
||||
var/target_differences = (p_init_dir ^ target_init_dir) & ~S.connections
|
||||
if (target_differences)
|
||||
to_chat(user, span_notice("You start reprogramming \the [S]..."))
|
||||
playsound(get_turf(src), 'sound/machines/click.ogg', 50, TRUE)
|
||||
if(do_after(user, reprogram_speed, target = S))
|
||||
// Double check to make sure that nothing has changed. If anything we were about to change is now connected, abort
|
||||
if (target_differences & S.connections)
|
||||
to_chat(user, span_warning("\The [src]'s screen flashes a warning: Can't configure a pipe in a currently connected direction."))
|
||||
return
|
||||
var/new_dir = (S.GetInitDirections() & ~target_differences) | target_differences
|
||||
// Don't make a smart pipe with only one connection
|
||||
if (ISSTUB(new_dir))
|
||||
to_chat(user, span_warning("\The [src]'s screen flashes a warning: Can't configure a pipe to only connect in one direction."))
|
||||
return
|
||||
S.SetInitDirections(new_dir)
|
||||
S.update_pipe_icon()
|
||||
user.visible_message(span_notice("[user] reprograms the \the [S]."),span_notice("You reprogram \the [S]."))
|
||||
return
|
||||
to_chat(user, span_warning("\The [S] is already in this configuration for its unconnected directions!"))
|
||||
return
|
||||
var/obj/item/pipe/quaternary/I = attack_target
|
||||
if(istype(I) && ispath(I.pipe_type, /obj/machinery/atmospherics/pipe/smart))
|
||||
I.p_init_dir = p_init_dir
|
||||
I.update()
|
||||
|
||||
if(mode & BUILD_MODE)
|
||||
switch(category) //if we've gotten this var, the target is valid
|
||||
if(ATMOS_CATEGORY) //Making pipes
|
||||
@@ -584,6 +622,7 @@ GLOBAL_LIST_INIT(transit_tube_recipes, list(
|
||||
#undef BUILD_MODE
|
||||
#undef DESTROY_MODE
|
||||
#undef WRENCH_MODE
|
||||
#undef REPROGRAM_MODE
|
||||
|
||||
/obj/item/rpd_upgrade
|
||||
name = "RPD advanced design disk"
|
||||
|
||||
Reference in New Issue
Block a user