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

Game can't save. #23

Open
obsidianxenon opened this issue Jan 4, 2025 · 30 comments
Open

Game can't save. #23

obsidianxenon opened this issue Jan 4, 2025 · 30 comments
Assignees
Labels
bug This issue involves a bug. help wanted Help from someone else would be appreciated - including you! unable to replicate The bug cannot yet be replicated

Comments

@obsidianxenon
Copy link

The game says it saves/autosaves, but the save is nowhere to be found. It can read from the save directory, but it can't seem to write to it.

@duckfullstop
Copy link
Collaborator

duckfullstop commented Jan 4, 2025

This might be a permissions issue. Can you try doing chown -R 911:911 save then restarting the container?

If that doesn't work, try chmod 777 save and see if that works - if it does, please provide a ls -la of that directory afterwards, just so I have a better idea what permissions are necessary.

@duckfullstop duckfullstop added the bug This issue involves a bug. label Jan 4, 2025
@obsidianxenon
Copy link
Author

obsidianxenon commented Jan 4, 2025

@duckfullstop Wait so in what directory? Also I'm using port 3979 if that helps.

@duckfullstop
Copy link
Collaborator

Try doing it against your save directory - so I.E run those above commands while you're in the same directory that contains openttd.cfg.

If you don't have a save directory, could you provide a ls -la of what you do have?

@obsidianxenon
Copy link
Author

obsidianxenon commented Jan 5, 2025

@duckfullstop Ok neither worked (exited - Code 0), and in the logs I get from portainer I see at the end:
`[2025-01-05 00:02:28] dbg: [net:3] Listening on 0.0.0.0:3979 (IPv4)

[2025-01-05 00:02:28] dbg: [net:3] Network revision name: 14.1

[2025-01-05 00:02:30] dbg: [net:0] Loading requested map failed; closing server.

[2025-01-05 00:02:30] Game Load Failed... there is no town in this scenario

[2025-01-05 00:02:30] dbg: [net:3] Initializing UDP listeners

[2025-01-05 00:02:30] dbg: [net:3] Shutting down network`

Keep in mind it actually loaded before, so something else is buggered now.

EDIT: I just deleted the directory, made a new one, and put the save file in it. Now I'm back to original problem.

@duckfullstop duckfullstop self-assigned this Jan 5, 2025
@duckfullstop
Copy link
Collaborator

I think this is a legitimate issue, possibly due to a build train change; investigating...

@duckfullstop
Copy link
Collaborator

duckfullstop commented Jan 5, 2025

Can you test against the new images that are being built right now (once they've finished baking, of course)? Took a bit of help from the developer discord, but I've successfully figured out why stuff wasn't getting put in the /config directory as it always used to - you might need to move stuff back there...

@obsidianxenon
Copy link
Author

@duckfullstop Do I just pull the image again?

@duckfullstop
Copy link
Collaborator

Once the image has finished being built, yeah - the page I linked to above has the status.

The builds can take upwards of an hour because the GitHub actions runners are pretty slow for stuff like this, so I'd go grab a coffee in the interim (or your beverage of choice).

@obsidianxenon
Copy link
Author

@duckfullstop I'll go have breakfast then.

@obsidianxenon
Copy link
Author

@duckfullstop So to give an update: The game now autosaves in the config/ directory (not to be confused with .config/), but it reads autosaves from config/save/autosave/. Another thing I have noticed is that the autosaves, which are structured like: Blah Transport, 1940-01-01-autosave.sav will not be read even if I put them in save/autosave/, unless I rename it to autosave0.sav or similar. I'm not quite sure what is going on here.

@duckfullstop
Copy link
Collaborator

duckfullstop commented Jan 7, 2025

Sorry for the delay, I've been yucky with flu and it hit me again yesterday 🤧

I've just pushed an update (d0ebf65) that will use an existing .config directory if it exists - that should unbreak existing installations.

I'm still super curious why you're unable to load anything. Can you provide a log from a container launch? (once the newest containers have built)

Also, could you run both ls and pwd from the OpenTTD game console when it's running, and post the results here? The easiest way to do that is to make sure the container is running with -it flags (i.e docker run -it *).

You can also try loading a save manually that way (load save.sav)

@obsidianxenon
Copy link
Author

obsidianxenon commented Jan 8, 2025

@duckfullstop The game launches normally with a name such as autosave.sav but with another name, in this case Nix Works, 1940-12-03-autosave.sav I get this recurring error:


/usr/local/bin/entrypoint: 30: [: /config/save/autosave/Nix: unexpected operator

/config/save/autosave/Nix Works, 1940-12-03-autosave.sav not found...

Also, as I said before, the game autosaves to /config/ but loads from /config/save/autosave/. Any idea how to change that?

One more thing: when I run those commands from the OpenTTD console, it just gives me the client's save directory (I am running with -it). Am I in the wrong spot? EDIT: I ran them with RCON and got this:

ls:
0) .. (Parent directory)
1) .. (autosave/ (Directory)

pwd: /config/save/

@duckfullstop
Copy link
Collaborator

So you're saying that the game is autosaving to /config/Nix Works, 1940-12-03-autosave.sav, not /config/save/autosave/Nix Works, 1940-12-03-autosave.sav?

If it is saving to the latter, could you try doing cd autosave/ then load *save file goes here.sav*?

I think I'm starting to figure out what your issue is - looks like an issue with the entrypoint script not handling spaces in savefile names. The original intention of the loadfile functionality was to allow for loading a base game at server launch, not to load an autosave - but that's definitely not to say I can't add the ability to load things with spaces.

@obsidianxenon
Copy link
Author

@duckfullstop Yes to the first question.

When I type rcon <mypassword> "load Nix Works, 1940-12-03-autosave.save" it comes back with Load a game by name or index. Usage: 'load <file | number>

I'm thinking it's the spaces as well.

@duckfullstop
Copy link
Collaborator

One last sanity check: loading a game by its index number works, right?

@obsidianxenon
Copy link
Author

@duckfullstop How do I do that?

@obsidianxenon
Copy link
Author

@duckfullstop Lol github had an outage. Anyways: Nevermind, the game does load from index number.

@pbystrov
Copy link

pbystrov commented Jan 9, 2025

This might be a permissions issue. Can you try doing chown -R 911:911 save then restarting the container?

Chowning save dir helped in my case. Is there a way to remap container user to another one? Running docker with --user didn't help

duckfullstop added a commit that referenced this issue Jan 9, 2025
Should properly escape and handle save file names provided on the `loadgame` parameter now.
@duckfullstop
Copy link
Collaborator

Please give the latest commit a whirl (once it's finished building)

This might be a permissions issue. Can you try doing chown -R 911:911 save then restarting the container?

Chowning save dir helped in my case. Is there a way to remap container user to another one? Running docker with --user didn't help

I think we've got two different discrete issues going on here - I can potentially add some support for setting the UID/GID of the container user, but please raise a different issue for that.

@obsidianxenon
Copy link
Author

obsidianxenon commented Jan 9, 2025

@duckfullstop So do you think its the spaces in my case? Also the game has an option to save to a different directory in openttd.cfg but it doesn't work. Just keeps saving to /config

@duckfullstop
Copy link
Collaborator

@duckfullstop So do you think its the spaces in my case?

This should now be fixed on the latest build - please report back!

Also the game has an option to save to a different directory in openttd.cfg but it doesn't work. Just keeps saving to /config

When you say /config, do you mean files are saving to /config/save.sav, or /config/save/save.sav? I'm unable to replicate the former, so if you're getting the latter, could you provide the relevant section of your openttd.cfg (presumably that's [misc])?

@obsidianxenon
Copy link
Author

[misc]
display_opt = SHOW_TOWN_NAMES|SHOW_STATION_NAMES|SHOW_SIGNS|FULL_ANIMATION|FUL>
fullscreen = false
video_hw_accel = true
video_vsync = false
support8bpp = no
soundsset =
musicset =
videodriver =
musicdriver =
sounddriver =
blitter =
language = english.lng
resolution = 640,480
screenshot_format =
savegame_format =
savegame_dir = /config/save/autosave/
rightclick_emulate = false
sprite_cache_size_px = 128
player_face = 0
transparency_options = 0
transparency_locks = 0
invisibility_options = 0
keyboard =
keyboard_caps =
last_newgrf_count = 6
gui_scale = -1

I have tried all sorts of options for savegame_dir (/config/save/autosave/, /home/pi/docker/openttd/config/save/autosave/ etc) but it still saves to /config not /config/save/ or /config/save/autosave/

Also, loading the Nix Works file still doesn't work. Gives this log:


      original_dos: Original Transport Tycoon Deluxe DOS edition graphics. (unusable: 5 missing files)

List of sounds sets:
  original_windows: Original Transport Tycoon Deluxe Windows edition sounds. (unusable: 1 missing file)
           NoSound: A sound pack without any sounds.

List of music sets:
           NoMusic: A music pack without actual music.
  original_windows: Original Transport Tycoon Deluxe Windows edition music. (unusable: 22 missing files)
      original_tto: Original Transport Tycoon (Original/World Editor) DOS edition music. (unusable: 17 missing files)
      original_dos: Original Transport Tycoon Deluxe DOS edition music. (unusable: 22 missing files)

List of music drivers:
              null: Null Music Driver

List of sound drivers:
              null: Null Sound Driver

List of video drivers:
         dedicated: Dedicated Video Driver
              null: Null Video Driver

List of blitters:
              null: Null Blitter (does nothing)

List of debug facility names:
driver, grf, map, misc, net, sprite, oldloader, npf, yapf, fontcache, script, sl, gamelog, desync, console

List of AIs:

List of Game Scripts:


INFO: Loading from latest autosave - /config/save/autosave/Nix Works, 1940-12-03-autosave.sav
OpenTTD 14.1


Command line options:
  -v drv              = Set video driver (see below)
  -s drv              = Set sound driver (see below)
  -m drv              = Set music driver (see below)
  -b drv              = Set the blitter to use (see below)
  -r res              = Set resolution (for instance 800x600)
  -h                  = Display this help text
  -t year             = Set starting year
  -d [[fac=]lvl[,...]]= Debug mode
  -e                  = Start Editor
  -g [savegame|scenario|heightmap] = Start new/savegame/scenario/heightmap immediately
  -G seed             = Set random seed
  -n host[:port][#company]= Join network game
  -p password         = Password to join server
  -P password         = Password to join company
  -D [host][:port]    = Start dedicated server
  -f                  = Fork into the background (dedicated only)
  -I graphics_set     = Force the graphics set (see below)
  -S sounds_set       = Force the sounds set (see below)
  -M music_set        = Force the music set (see below)
  -c config_file      = Use 'config_file' instead of 'openttd.cfg'
  -x                  = Never save configuration changes to disk
  -X                  = Don't use global folders to search for files
  -q savegame         = Write some information about the savegame and exit
  -Q                  = Don't scan for/load NewGRF files on startup
  -QQ                 = Disable NewGRF scanning/loading entirely

List of graphics sets:
           OpenGFX: OpenGFX base graphics set for OpenTTD. Freely available under the terms of the GNU General Public License version 2. [OpenGFX 7.1]
  original_windows: Original Transport Tycoon Deluxe Windows edition graphics. (unusable: 5 missing files)
      original_dos: Original Transport Tycoon Deluxe DOS edition graphics. (unusable: 5 missing files)

List of sounds sets:
  original_windows: Original Transport Tycoon Deluxe Windows edition sounds. (unusable: 1 missing file)
           NoSound: A sound pack without any sounds.

List of music sets:
           NoMusic: A music pack without actual music.
  original_windows: Original Transport Tycoon Deluxe Windows edition music. (unusable: 22 missing files)
      original_tto: Original Transport Tycoon (Original/World Editor) DOS edition music. (unusable: 17 missing files)
      original_dos: Original Transport Tycoon Deluxe DOS edition music. (unusable: 22 missing files)

List of music drivers:
              null: Null Music Driver

List of sound drivers:
              null: Null Sound Driver

List of video drivers:
         dedicated: Dedicated Video Driver
              null: Null Video Driver

List of blitters:
              null: Null Blitter (does nothing)

List of debug facility names:
driver, grf, map, misc, net, sprite, oldloader, npf, yapf, fontcache, script, sl, gamelog, desync, console

List of AIs:

List of Game Scripts:

@duckfullstop
Copy link
Collaborator

How are you launching the container? (Preferably full command line / docker-compose / whatever, please)

@obsidianxenon
Copy link
Author

I am using portainer, but I'll translate the options into a docker run command: docker run -d -it redditopenttd/openttd:latest -p 3979:3979/tcp -p 3979:3979/udp -e "loadgame=last-autosave" -v /home/pi/docker/openttd/config/:/config:rw -v /home/pi/docker/openttd/config/save/autosave/:/config/save/autosave:rw --restart unless-stopped

@duckfullstop
Copy link
Collaborator

duckfullstop commented Jan 11, 2025

I've just pushed 17d29d6 which should get autosaves inside save/autosave loading properly again.

As for why you're saving to /config, I am completely unable to replicate that after quite a while trying. Per the wiki, autosaves should be named autosave[0,1,2...].sav in the autosave directory - and that's the same functionality that I observe.

Savegames with a company name in them imply that you're starting your server from a save that you've loaded in from a client. Are you 100% sure that you're not reloading the same base save that you've manually placed in /config?

Could you try starting a game from scratch (i.e loadgame=none) and see if it persists? If it does, then please post your full openttd.cfg (redacting passwords and other secrets, of course).

@obsidianxenon
Copy link
Author

I pulled again and started the game with loadgame = false (I assume you meant that), and it still saves to /config in the format as described before. Here is my openttd.cfg: https://drive.google.com/file/d/1UFPDnxVbd5woHROMYPs9tkBi3o8bwm6X/view?usp=sharing

@duckfullstop
Copy link
Collaborator

duckfullstop commented Jan 12, 2025

I think I've identified your problem - at least, I can replicate it now.

I am using portainer, but I'll translate the options into a docker run command: -v /home/pi/docker/openttd/config/:/config:rw -v /home/pi/docker/openttd/config/save/autosave/:/config/save/autosave:rw

Why are you mounting /save/autosave again? Do you have separate filesystems on your host that's preventing you just passing it through as part of /config?

It appears that traversing filesystem mounts isn't supported upstream. If this is horribly breaking for you, then an issue probably needs to be raised on the main project. Otherwise, please mount just /config without any mounts inside.

I will update the readme with a gotcha on this.

@obsidianxenon
Copy link
Author

I completely forgot I submounted that as part of a troubleshooting step early on. Doesn't change anything though. Also just tried removing the save path from openttd.cfg. It may or may not have to do with the fact that I'm running this on a Raspberry Pi 5, I don't really see how, but in my experience, things that are crap on a Pi work on literally anything else.

@duckfullstop
Copy link
Collaborator

duckfullstop commented Jan 18, 2025

Going to be honest, I'm completely stumped at this point. Can you run the container completely fresh (with a blank mounted /config) and the variable DEBUG=1, join it and start a company for 10 minutes, have the game autosave (which happens after 10 minutes), and then post the log here? (unless you've figured it out since)

@duckfullstop duckfullstop added help wanted Help from someone else would be appreciated - including you! unable to replicate The bug cannot yet be replicated labels Jan 18, 2025
@obsidianxenon
Copy link
Author

Going to be honest, I'm completely stumped at this point. Can you run the container completely fresh (with a blank mounted /config) and the variable DEBUG=1, join it and start a company for 10 minutes, have the game autosave (which happens after 10 minutes), and then post the log here? (unless you've figured it out since)

Ok I will try that in a bit. On a side note, if you can't replicate this at all, I might end up just using a different machine or something. It seems like too much hassle for a server I'm going to use occasionally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue involves a bug. help wanted Help from someone else would be appreciated - including you! unable to replicate The bug cannot yet be replicated
Projects
None yet
Development

No branches or pull requests

3 participants