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

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

Closed
wants to merge 31 commits into from

Conversation

Tsar-Salat
Copy link
Contributor

@Tsar-Salat Tsar-Salat commented Oct 5, 2023

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.

TODO

  • base pr, no conflicts
  • test air alarm/gas changes
  • non-processing machines consume power
  • Recharging cells works as expected
  • Expected inducer behavior
  • Expected recharger behavior on shuttles
  • Expected recharger behavior on Space Ruins
  • ready to review

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

🆑 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.
/: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 Oct 5, 2023
@Tsar-Salat
Copy link
Contributor Author

This PR is a branch of #9314, so that will need to be merged prior to this progressing. It is also why it inherited that PRs commit history.

@Tsar-Salat
Copy link
Contributor Author

Ah, I see the issue. Terribad initialization, especially with random cola machines. Converting them into spawners(like they should be), seems to not be spamming me with del runtimes & fails anymore

@github-actions github-actions bot added the Mapping DMM Change label Oct 6, 2023
@github-actions
Copy link

github-actions bot commented Oct 7, 2023

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

@Tsar-Salat Tsar-Salat changed the title large refactor of machine/power code to cut down on processing time and wasted lists large refactor of machine/power code to cut down on processing time and wasted lists + Fixes age-old apc exploit Oct 25, 2023
@Tsar-Salat
Copy link
Contributor Author

guh, it breaks on ruins

@Tsar-Salat
Copy link
Contributor Author

This is annoying, the processing machines bug hasnt been fixed at all!

Copy link

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

@Tsar-Salat
Copy link
Contributor Author

Cant figure this out, Ill come back to this at a later date (maybe)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Code Improvement Fix Mapping DMM Change Merge Conflict 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.

1 participant