Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RECOUP/PORT] large refactor of machine/power code to cut down on processing time and wasted lists + Fixes age-old apc exploit #11188

Open
wants to merge 22 commits into
base: master
Choose a base branch
from

Conversation

PestoVerde322
Copy link
Contributor

@PestoVerde322 PestoVerde322 commented Jul 14, 2024

This PR recoup #9968, so the description and everything is pretty much the same.

Ports:

About The Pull Request

PR 1 & 2
APCs now respect power input and output. Effectively, as much power goes into a cell that come out. It has to do with the way power is temporarily drawn from Equipment part of the APC(look at the linked pr, its 3 paragraphs) but it basically boils down to this:

  • Two cells and an inducer no longer can be used to generate infinite free power
  • Charging Cells in a recharger no longer is busted.
  • Cells now directly take from power, and only take from the surplus power. TG making the first PR basically made every recharger a bonifide power-sink, but with the second pr this is viable.

PR 3
Kylerace explains it quite well.

came back to this because i realized that

all machines were area sensitive, meaning they had a list with at least a reference to themselves (assuming they arent in the contents of another movable which most arent) for the purposes of handling power differences when their area changes
pipes are machines
there are ~14k machines and ~6k pipes
i made this problem worse with a recent pr by making it a nested list
so i needed to track what machines needed power, and this pr had work already done that could be used for that purpose. now machines that have use_power == NO_POWER_USE do not have this extra memory overhead for no reason

currently every machine that uses power draws that amount from its area from a dynamic channel via auto_use_power() which is called every SSmachines fire(), then in apc/process() the area's dynamic power draw is reset and the power is used. with static power its not calculated then reset every loop, its just taken from the grid. so now machines handle updating their static power usage from their current area (this doesnt touch power machines that require a wire connection). in order to allow this, use_power, idle_power_usage, and active_power_usage have setters to track state correctly and update the static power usage on the machines current area and handle area sensitivity.

also goes through a lot of heavy abusers of SSmachine processing time and tries to make it faster. makes airalarm/process() into a signal handler for COMSIG_TURF_EXPOSE since air alarms only need to process for changes.

This should also resolve some bugs introduced in #4401, namely non-processing machines not actually consuming power. I will need to do some testing to confirm.

PERSONAL PORT NOTE: The original PR was closed due to a bug related to the the processing machines, on testing, this bug didn't really seem to be the case. Despite all, I STRONGLY suggest to merge this as a stepping stone for the following PRs:

Why It's Good For The Game

Cutting down subsystem costs is always good.

Fixing terrible power inconsistencies as well.

Testing Photographs and Procedure

Screenshots&Videos

image

Adjusting Air Alarm values

dreamseeker_32tNhryIxn.mp4

APC taking from surplus power, rather than from APC

surplus.1.mp4

Space ruin powering a cell charger

dreamseeker_UgVCUYBJvh

Changelog

🆑 PigeonVerde322, Rkz, Kylerace, ArcaneMusic, zxaber
refactor: refactors machine and power code to cut down on processing costs
fix: fixes non-processing machines failing to consume power
fix: fixes rechargers and inducers allowing for effectively infinite power. Now, what is used to charge these cells is exactly what can be expended from them.
tweak: rechargers now suck power directly from surplus energy on the powergrid, as opposed to the Equipment part of an APC. This is to prevent the former fix from making every single recharger on the station a mini-energy siphon.
add: examining any machinery will now tell if it's powered or not.
/:cl:

@github-actions github-actions bot added the TGUI-Changes Contains changes to TGUI. Make sure its up to date with TGUI 4.0 label Jul 14, 2024
Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@PowerfulBacon
Copy link
Member

What was the bug that caused the original PR to be closed, how have you tested that it no longer exists?

@PestoVerde322
Copy link
Contributor Author

PestoVerde322 commented Aug 5, 2024

What was the bug that caused the original PR to be closed, how have you tested that it no longer exists?

To requote what i said on discord so it's on github: I need tgstation/tgstation#82540 to prevent that bug, since at the end of the day, it's due to an Init reason and i did not want to make the PR bigger than it should be. (Actually caused by Faulty LateInitialize not calling parent and thus, making many machinery to skip power connection)

Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

PigeonVerde322 added 2 commits September 8, 2024 11:18
Copy link
Contributor

@Tsar-Salat Tsar-Salat left a comment

Choose a reason for hiding this comment

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

Bacon approved this months ago, faulty map workflow failed which probably took it off the radar

This looks good to merge

(this was originally a recoup of my code, I must note. So take my approval below bacon's)

Copy link

github-actions bot commented Nov 9, 2024

This pull request has conflicts, please resolve those before we can evaluate the pull request.

Copy link

github-actions bot commented Dec 3, 2024

This pull request has conflicts, please resolve those before we can evaluate the pull request.

Copy link

This PR has been marked as stale due to being in an unmergable state for 7 days. Please resolve any conflicts and add testing evidence, then contact a project maintainer to have the stale label removed.

@github-actions github-actions bot added the Stale label Dec 20, 2024
Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@PestoVerde322 PestoVerde322 force-pushed the processing-lists-Recoup branch from 8096db4 to 40ac1a8 Compare December 24, 2024 23:41
PigeonVerde322 added 2 commits December 25, 2024 01:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Code Improvement Feature Fix Refactor TGUI-Changes Contains changes to TGUI. Make sure its up to date with TGUI 4.0 Tweak
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants