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

Request: Provide an option to "pause" the universe on server stop #543

Open
skylon07 opened this issue Jan 28, 2023 · 1 comment
Open

Request: Provide an option to "pause" the universe on server stop #543

skylon07 opened this issue Jan 28, 2023 · 1 comment

Comments

@skylon07
Copy link

skylon07 commented Jan 28, 2023

Workaround

For those experiencing this issue with their style of play, here is a script I made as a launcher for LunaServer.exe. This script basically records the time you stop the server, stores that in a LastStopTime.txt file in the Universe folder, then adds the time difference from LastStopTime.txt back to the game next time you start the server, effectively "time warping" the game back to the state you left it in.

LunaServer-runWithTimeFix.py.txt (you'll have to rename the file to .py; you can't upload .py files to github directly)


Background:

  • OS: Windows 10
  • KSP Version: 1.12.4
  • LMP version (include the build number if you are using a nighly build): 0.29.0

Mods (remember that mods are not supported):

N/A


While this isn't a "bug", I will write the expected behavior and current behavior from my perspective as a user.

Expected behaviour:

Stopping the server should theoretically halt the universe; if I restart the server after 24 hours, the universe should be re-created in the same state I left it, from craft orbits to positions of celestial bodies.

Current behaviour:

The server records certain times (StartTime.txt, Subspace.txt) to allow the universe to be simulated across time when the server is off. This means that if, for example (totally not a real experience) I were to have a craft on an intercept course with the Mun, and I stop the server and come back 24 hours later, the Mun has progressed in its orbit, leaving my craft nowhere near the Mun as I had left it.

There is a workaround that achieves my desired result (I think):

  1. When stopping the server, record my machine's time (referred to as lastStopTime)
  2. When starting the server again, record my machine's time again (referred to as startTime)
  3. Calculate timeDiff = startTime - lastStopTime
  4. Add timeDiff to the value stored in StartTime.txt
@skylon07
Copy link
Author

skylon07 commented Jan 28, 2023

Update on this: I made a python script to handle modifying StartTime.txt in the way I described above.

  1. When stopping the server, record my machine's time (referred to as lastStopTime)
  2. When starting the server again, record my machine's time again (referred to as startTime)
  3. Calculate timeDiff = startTime - lastStopTime
  4. Add timeDiff to the value stored in StartTime.txt

I'm going to do a real-world test of the script tomorrow. If it works, I'll post it

Edit: Yup, it works! I posted it in the "workaround" section in my original comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants