Skip to content

Conversation

@Tayrtahn
Copy link
Member

About the PR

Devices like vending machines and arcade games in the terminal no longer incorrectly state that they do not have power before opening.

Why / Balance

Fixes #38628.

Technical details

Spot the difference:
Screenshot 2025-06-28 at 4 41 00 PM

Screenshot 2025-06-28 at 4 41 20 PM

This PR changes the client version to also return true from that conditional.

Yes, I also think it's silly/bad to have two seemingly-identical static classes that need to be kept in sync - there really should just be a single class in Shared. Unfortunately, the client and server have different ApcPowerReceiverComponent definitions and TryGetComponent doesn't work with inheritance (so it can't be used with SharedApcPowerReceiverComponent). Try building and running with the reverted commit in this PR if you want to see the problem yourself. This should be dealt with in the future, but for now, this PR just puts the client and server classes back in sync.

Requirements

@github-actions github-actions bot added S: Needs Review Status: Requires additional reviews before being fully accepted. Not to be replaced by S: Approved. S: Untriaged Status: Indicates an item has not been triaged and doesn't have appropriate labels. size/XS Denotes a PR that changes 0-9 lines. labels Jun 29, 2025
@Tayrtahn Tayrtahn added T: Bugfix Type: Bugs and/or bugfixes P3: Standard Priority: Default priority for repository items. DB: Beginner Friendly Difficulty: Great for beginners. Unambiguous in scope, and explains how to achieve the result. S: Approved Status: Reviewed and approved by at least one maintainer; a PR may require another approval. A: General Interactions Area: General in-game interactions that don't relate to another area. and removed S: Untriaged Status: Indicates an item has not been triaged and doesn't have appropriate labels. labels Jun 29, 2025
@perryprog
Copy link
Contributor

Technically you can do this very normal and very okay way :^)

public static bool IsPowered(this EntitySystem system, EntityUid uid, IEntityManager entManager, SharedApcPowerReceiverComponent? receiver = null)
{
    var comp = entManager.ComponentFactory.GetRegistration("ApcPowerReceiver");
    IComponent? teehee = null;
    if (receiver == null && !entManager.TryGetComponent(uid, comp, out teehee))
        return true;
    receiver = teehee as SharedApcPowerReceiverComponent;
    return receiver?.Powered ?? true;
}

@Tayrtahn
Copy link
Member Author

Tayrtahn commented Jul 1, 2025

Technically you can do this very normal and very okay way :^)

public static bool IsPowered(this EntitySystem system, EntityUid uid, IEntityManager entManager, SharedApcPowerReceiverComponent? receiver = null)
{
    var comp = entManager.ComponentFactory.GetRegistration("ApcPowerReceiver");
    IComponent? teehee = null;
    if (receiver == null && !entManager.TryGetComponent(uid, comp, out teehee))
        return true;
    receiver = teehee as SharedApcPowerReceiverComponent;
    return receiver?.Powered ?? true;
}

That's very clever and I kinda hate it!

Copy link
Member

@beck-thompson beck-thompson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah agree with what you said they should be combined but this is clearly a mistake!

@PJBot PJBot removed the S: Needs Review Status: Requires additional reviews before being fully accepted. Not to be replaced by S: Approved. label Jul 14, 2025
@beck-thompson beck-thompson merged commit c60910d into space-wizards:master Jul 14, 2025
15 checks passed
@Tayrtahn Tayrtahn deleted the fix/ispowered-mispredict branch July 14, 2025 10:31
FairlySadPanda pushed a commit to FairlySadPanda/honk-station-15 that referenced this pull request Jul 25, 2025
* The simple solution

* The better solution

* Revert "The better solution"

This reverts commit 611e56e.
Princess-Cheeseballs pushed a commit to Princess-Cheeseballs/space-station-14 that referenced this pull request Aug 1, 2025
* The simple solution

* The better solution

* Revert "The better solution"

This reverts commit 611e56e.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A: General Interactions Area: General in-game interactions that don't relate to another area. DB: Beginner Friendly Difficulty: Great for beginners. Unambiguous in scope, and explains how to achieve the result. P3: Standard Priority: Default priority for repository items. S: Approved Status: Reviewed and approved by at least one maintainer; a PR may require another approval. size/XS Denotes a PR that changes 0-9 lines. T: Bugfix Type: Bugs and/or bugfixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Some vending machines at the terminal will say they are unpowered when they are infact powered

4 participants