X Tutup
Skip to content

Fix the accumulation of zombie traders and some other unnecessary things#5783

Merged
sturnclaw merged 5 commits intopioneerspacesim:masterfrom
Gliese852:fix-tradeships-accumulation
Mar 1, 2024
Merged

Fix the accumulation of zombie traders and some other unnecessary things#5783
sturnclaw merged 5 commits intopioneerspacesim:masterfrom
Gliese852:fix-tradeships-accumulation

Conversation

@Gliese852
Copy link
Contributor

@Gliese852 Gliese852 commented Feb 26, 2024

Collected the simplest, but quite effective fixes so that when you stay in one system for a long time, there is no noticeable drop in performance.

Fixes #5735
(taking into account that #5127 and #5785 are merged)

Although at least there remains the problem that occasionally the tradeship runs out of fuel; repairing it probably requires serious intervention in the autopilot, or the creation of evacuation ships, for example. just explode them

Recently the 'onShipDocked' event stopped being emitted when a ship is
spawned inside a station, but the TradeShips module was not adapted to
this.
Without this, the ship will either crash when attempting to land, or
receive an autopilot error if it attempts to begin docking from a
planet's orbit.
The logic was that after each call, add 'every' to 'at' and get a new
call time.

Naturally, after some time acceleration, 'at' was very behind the
current time, and the callback was called every frame because it was
always overdue.
Copy link
Member

@impaktor impaktor left a comment

Choose a reason for hiding this comment

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

nice!

*
* Returns:
*
* acceleration - number, m/s/s
Copy link
Member

Choose a reason for hiding this comment

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

pointless nitpick from me: do we want m/s/s or m/s^2 ?

@fluffyfreak
Copy link
Contributor

fluffyfreak commented Feb 26, 2024

occasionally the tradeship runs out of fuel; repairing it probably requires serious intervention

Or just delete them... the player won't notice, and log a warning

Copy link
Member

@sturnclaw sturnclaw left a comment

Choose a reason for hiding this comment

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

occasionally the tradeship runs out of fuel

This sounds like a SAR mission opportunity to me.

@Gliese852 thank you for taking the time to dig into this issue! Very good catch with the life support callback remaining as a zombie, that was definitely my fault when I moved the callback from C++ into Lua. I think the callback requires further thought - it really only needs to run every 5 seconds for the player's ship - all others can have it run once every hour or so. We'd technically lose some "systemic gameplay" from making it player-only, but NPC tradeships probably shouldn't be created with missing life support equipment when carrying perishable cargo.

The GetThrusterAcceleration method is fine as-is, though I'd like to make the Propulsion component directly available via ship:GetComponent("Propulsion") and move most of the "passthrough" thruster-related APIs to that component.

@claudiusmueller
Copy link

This sounds like a SAR mission opportunity to me.

I wish we could start connecting modules like this!

I guess within SAR I could check for any ships without fuel? Hmm.....

@bszlrd
Copy link
Contributor

bszlrd commented Feb 27, 2024

SAR missions from out-of-fuel ships also will likely giv a different kind of mission, maybe even a more urgent one.
At least I suspect that most of them run out of fuel in the deceleration phase, so they likely still have a relatively high speed. Which is a quite different catch-up maneuver than for an orbiting ship.
Maybe there could even be a comms message about the distress, and they cold be highlighted on the orbital map? And then the player could either give them fuel, or evacuate, depending on capacities.

@Gliese852
Copy link
Contributor Author

@claudiusmueller

I guess within SAR I could check for any ships without fuel? Hmm.....

The OutOfFuel module monitors the status of ship tanks, and I think it can be taught to generate an onShipOutOfFuel event that your SAR module could catch.

if state == "EMPTY" then

@Gliese852
Copy link
Contributor Author

@nozmajner

At least I suspect that most of them run out of fuel in the deceleration phase

In our case, these are almost always ships that have wasted their fuel during maneuvers while waiting for docking, so they are most likely hanging out in a low orbit.

@impaktor
Copy link
Member

In case the SAR discussion is serious, I think it would be better to just blow up the NPC ship when it runs out of fuel. Connecting SAR to it sounds like a lot of work, and to generate missions for something that's not really supposed to happen seems like difficult to debug (unless it's built into the Tradeship module that some fraction should run out of fuel and call on SAR).

@Gliese852
Copy link
Contributor Author

@fluffyfreak

Or just delete them... the player won't notice, and log a warning

I also thought the tradeship could be refueled a little.

@fluffyfreak
Copy link
Contributor

fluffyfreak commented Feb 27, 2024

@fluffyfreak

Or just delete them... the player won't notice, and log a warning

I also thought the tradeship could be refueled a little.

🤔 yes, I guess that would be a less violent option 😆 NPC behaviour far from a player doesn't really need a lot of finesse, as long as things keep working they might as well have infinite fuel.

Does the player care if an NPC across the star system has fuel issues? WIll they even know?

My suggestion would be to just delete them, or refuel them, the player won't notice either way unless it happens right in front of them... so of the two, refuel seems safest unless you want to add a distance test to refuel those closer than 1 AU and delete any further away

@fluffyfreak
Copy link
Contributor

Always pick the "Keep It Simple Stupid" option with something like this, then make a note to fix WHY they're running out of fuel later, and even later on add a SAR mission if someone wants to do that.

@claudiusmueller
Copy link

Always pick the "Keep It Simple Stupid" option with something like this, then make a note to fix WHY they're running out of fuel later, and even later on add a SAR mission if someone wants to do that.

This gets my vote. I'll make a note of the idea to maybe hook up SAR to out of fuel ships irrespective of which module they come from. But that's outside of this scope.

@Gliese852 Gliese852 force-pushed the fix-tradeships-accumulation branch from 7a123f8 to 233d08d Compare February 27, 2024 19:48
Timer.CallEvery terminates if the callback returns true, corrected the
returned parameters and forwarded it. Otherwise, they accumulated over
time.
@Gliese852 Gliese852 force-pushed the fix-tradeships-accumulation branch from 233d08d to 312718d Compare February 27, 2024 19:52
@Gliese852
Copy link
Contributor Author

Sorry, I made a small force push, otherwise LifeSupport check would have been disabled when docking, and wouldn't turn on again.

@Gliese852
Copy link
Contributor Author

Tested this, apparently, after more than a year, there are approximately the estimated number of tradeships.

image

Although fps does drop over time - this is due to the fact that Mola Ramsayi accumulate over the pads and cannot dock - the model does not have a "landing spike". A very detailed collision test going on there and it consumes a lot of CPU. @nozmajner is already aware and promised to correct the model. And this will be the final nail in the coffin #5735

@Gliese852
Copy link
Contributor Author

I did a cherry-pick of #5785, and left the computer for ~6 hours at x10000, (7 years in the game), good to see performance hasn't changed, and the number of ships is approximately estimated. So we can say that this PR fixes #5735 completely.
image

@sturnclaw sturnclaw merged commit e61c6ab into pioneerspacesim:master Mar 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Game is becoming slow after long flights

6 participants

X Tutup