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

Suggestion of Steam issue solution #21

Open
Mortasen opened this issue Nov 12, 2021 · 5 comments
Open

Suggestion of Steam issue solution #21

Mortasen opened this issue Nov 12, 2021 · 5 comments

Comments

@Mortasen
Copy link

When I try to launch mapshot to render a map for my save, this window appears:
image
and the program says: "Error: factorio exited early" even if I press OK.
Here is the log:

$ ./mapshot-linux render test --factorio_binary factorio_link/bin/x64/factorio --alsologtostderr --factorio_verbose
I1112 16:06:52.085064   28920 factorio.go:275] Path /opt/factorio does not exists, skipped
I1112 16:06:52.086357   28920 factorio.go:282] Found factorio data dir: /home/namerif/.factorio
I1112 16:06:52.086409   28920 factorio.go:275] Path /home/namerif/factorio does not exists, skipped
I1112 16:06:52.086433   28920 factorio.go:275] Path /home/namerif/Library/Application Support/factorio does not exists, skipped
I1112 16:06:52.086453   28920 factorio.go:289] Using Factorio data dir: /home/namerif/.factorio
I1112 16:06:52.086469   28920 factorio.go:275] Path /opt/factorio does not exists, skipped
I1112 16:06:52.086484   28920 factorio.go:282] Found factorio data dir: /home/namerif/.factorio
I1112 16:06:52.086497   28920 factorio.go:275] Path /home/namerif/factorio does not exists, skipped
I1112 16:06:52.086511   28920 factorio.go:275] Path /home/namerif/Library/Application Support/factorio does not exists, skipped
I1112 16:06:52.086520   28920 factorio.go:289] Using Factorio data dir: /home/namerif/.factorio
I1112 16:06:52.087334   28920 factorio.go:355] Factorio binary found: factorio_link/bin/x64/factorio
I1112 16:06:52.087355   28920 factorio.go:362] Using Factorio binary: factorio_link/bin/x64/factorio
I1112 16:06:52.087379   28920 render.go:105] runid: b7f357c9-88c2-4ca7-8a67-20b1b48000e5
I1112 16:06:52.087486   28920 root.go:30] temp dir: /tmp/mapshot3663988854
I1112 16:06:52.087517   28920 factorio.go:116] Looking for save "test"; test does not exists.
I1112 16:06:52.087534   28920 factorio.go:116] Looking for save "test"; test.zip does not exists.
I1112 16:06:52.087762   28920 factorio.go:110] Looking for save "test"; /home/namerif/.factorio/saves/test.zip exists.
Generating mapshot "test" using file /home/namerif/.factorio/saves/test.zip
I1112 16:06:52.093038   28920 render.go:125] copied save from "/home/namerif/.factorio/saves/test.zip" to "/tmp/mapshot3663988854/test.zip"
I1112 16:06:52.093567   28920 factorio.go:183] copying mod mod-list.json from /home/namerif/.factorio/mods/mod-list.json to /tmp/mapshot3663988854/mods/mod-list.json
I1112 16:06:52.094088   28920 factorio.go:206] created mod-list.json
I1112 16:06:52.095460   28920 render.go:141] mod created at "/tmp/mapshot3663988854/mods/mapshot"
I1112 16:06:52.095602   28920 render.go:94] overrides file created at "/tmp/mapshot3663988854/mods/mapshot/overrides.lua"
I1112 16:06:52.095627   28920 render.go:155] removed done-file "/home/namerif/.factorio/script-output/mapshot-done-b7f357c9-88c2-4ca7-8a67-20b1b48000e5": remove /home/namerif/.factorio/script-output/mapshot-done-b7f357c9-88c2-4ca7-8a67-20b1b48000e5: no such file or directory
Starting Factorio...
I1112 16:06:52.095716   28920 factorio.go:124] Running factorio with args: [--disable-audio --disable-prototype-history --load-game /tmp/mapshot3663988854/test.zip --mod-directory /tmp/mapshot3663988854/mods]
   0.000 Initializing Steam API.
Running Steam on linuxmint 20.1 64-bit
STEAM_RUNTIME is enabled automatically
Steam runtime environment up-to-date!
Steam client's requirements are satisfied
WARNING: Using default/fallback debugger launch
/home/namerif/.local/share/Steam/ubuntu12_32/steam steam://run/427520//%27--disable-audio%27%20%27--disable-prototype-history%27%20%27--load-game%27%20%27%2Ftmp%2Fmapshot3663988854%2Ftest.zip%27%20%27--mod-directory%27%20%27%2Ftmp%2Fmapshot3663988854%2Fmods%27
   0.000 Steam requires game restart, restarting...
I1112 16:07:01.323575   28920 factorio.go:151] Factorio returned: <nil>
I1112 16:07:01.324636   28920 root.go:37] temp dir "/tmp/mapshot3663988854" removed
Error: factorio exited early

OS: Linux Mint 20.1 Cinnamon x64
Steam installed from the official website

@Mortasen
Copy link
Author

Mortasen commented Nov 15, 2021

Sorry, didn't notice that Steam version is not supported. But still, if it's not supported only because of this issue, I want to propose a solution that I found: this "Allow game launch?" window does not appear, if you run the game this way:
/home/USER/.local/share/Steam/ubuntu12_32/steam -applaunch 427520 --disable-audio --disable-prototype-history --load-game /tmp/mapshot1126956423/test.zip --mod-directory /tmp/mapshot1126956423/mods
instead of the method that currently is used in the program:
/home/USER/.local/share/Steam/ubuntu12_32/steam steam://run/427520//%27--disable-audio%27%20%27--disable-prototype-history%27%20%27--load-game%27%20%27%2Ftmp%2Fmapshot1126956423%2Ftest.zip%27%20%27--mod-directory%27%20%27%2Ftmp%2Fmapshot1126956423%2Fmods%27
So maybe it's possible to add parameter that uses this workaround for Steam version. Anyway, thanks for this mod, it's really helpful!

@Mortasen Mortasen changed the title Steam requires game restart because of parameters Suggestion of Steam issue solution Nov 15, 2021
@Palats
Copy link
Owner

Palats commented Nov 17, 2021

Thanks for the suggestions! From what I vaguely remember, one of the issue was that things were behaving differently whether Steam was running or not, leading to a very weird experience - and I did not find a good workaround at the time. I'll dig into your suggestion, to see if we can have something automatic, which does not fail (too much) if steam itself is not running. Thanks!

@Palats
Copy link
Owner

Palats commented Nov 19, 2021

I've tested a bit further, so a few notes, for the day I am motivated to add proper steam support:

  • Currently, mapshot does not run the steam binary, it runs the factorio binary. However, when pointing to a steam factorio binary, that binary will itself run steam - hence leading to the command lines mentioned in comment above.
  • That means there is no control over how steam is launched if using the steam factorio binary.
  • So, steam factorio support would mean calling steam directly, which is possible.
  • Determining the steam binary to use is tricky - e.g., on my system, this is not .local/share/Steam/ubuntu12_32/steam but .local/share/Steam/ubuntu12_64/steam as far as I can tell, but both are present. And when calling the wrong ones, it starts doing updates and other thing, so, probably not a good idea to pick a random one.
  • Simplest here would be to use the one in the path (or manually specified of course).

Then there is the question of shutdown at the end of the render:

  • When running the steam factorio binary, even exiting factorio will not stop the command - steam will still be running.
  • Same story with steam -applaunch 42752.
  • Shutting down factorio at the end of the render is not that fundamental - mapshot detects the end of the rendering through a file created in the script-output, and the shutdown is just to have a nice integrated experience.
  • Maybe there could be something to do to still shutdown factorio (but not steam) at the end of the render, by looking at the process list. A bit hacky, but the process hierarchy should be enough to consistently identify it.
  • It is possible to shutdown the steam client (steam -shutdown) - but we don't know if it was running before or not, so it might be a bit unexpected. So it is likely that the steam client will stay running afterward. Not ideal.

Bottom line, I think a steam factorio support on Linux would look like this:

  • Depending on the overall experience, we can either gate usage of steam version behind an explicit flag or make it automatic when possible (with still a flag to force it).
  • Auto detection: identify the presence of a steam command and then look for factorio files to know if it is there.
  • Then, when running in steam mode:
    • use steam -applaunch to run factorio, instead of calling the binary directly.
    • Looking up the process hierarchy to know which process to kill at the end of the render.
    • Optionally, shutdown steam.

The process management part would require extra logic for other systems (MacOS, Windows) which I'm not familiar with.

Also, it should be possible to use the steam version today without any special support in mapshot by creating a script containing something along the lines of:

#!/usr/bin/env bash
exec steam -applaunch 42752 "$@"

And then run mapshot with --factorio_binary pointing to this script and probably --factorio_keep_running. (Untested).

@changchiyou
Copy link

@Palats The shell script solution isn't work for me.

  • ./mapshot-linux render /opt/factorio/XI_1028_backup.zip --factorio_binary ./steam.sh --factorio_datadir /opt/factorio --alsologtostderr --factorio_keep_running:

    I1104 14:29:11.904367 3589125 factorio.go:282] Found factorio data dir: /opt/factorio
    I1104 14:29:11.904482 3589125 factorio.go:289] Using Factorio data dir: /opt/factorio
    I1104 14:29:11.904486 3589125 factorio.go:282] Found factorio data dir: /opt/factorio
    I1104 14:29:11.904488 3589125 factorio.go:289] Using Factorio data dir: /opt/factorio
    I1104 14:29:11.904493 3589125 factorio.go:356] Factorio binary found: ./steam.sh
    I1104 14:29:11.904496 3589125 factorio.go:363] Using Factorio binary: ./steam.sh
    I1104 14:29:11.904502 3589125 render.go:110] runid: ea13595d-be55-441f-af45-27ae8cdff55e
    I1104 14:29:11.904520 3589125 root.go:30] temp dir: /tmp/mapshot2197921783
    I1104 14:29:11.904526 3589125 factorio.go:110] Looking for save "/opt/factorio/XI_1028_backup.zip"; /opt/factorio/XI_1028_backup.zip exists.
    Generating mapshot "XI_1028_backup" using file /opt/factorio/XI_1028_backup.zip
    I1104 14:29:11.912568 3589125 render.go:130] copied save from "/opt/factorio/XI_1028_backup.zip" to "/tmp/mapshot2197921783/XI_1028_backup.zip"
    I1104 14:29:11.912647 3589125 factorio.go:183] copying mod mod-list.json from /opt/factorio/mods/mod-list.json to /tmp/mapshot2197921783/mods/mod-list.json
    I1104 14:29:11.912719 3589125 factorio.go:206] created mod-list.json
    I1104 14:29:11.912982 3589125 render.go:146] mod created at "/tmp/mapshot2197921783/mods/mapshot"
    I1104 14:29:11.913014 3589125 render.go:99] overrides file created at "/tmp/mapshot2197921783/mods/mapshot/overrides.lua"
    I1104 14:29:11.913024 3589125 render.go:160] removed done-file "/opt/factorio/script-output/mapshot-done-ea13595d-be55-441f-af45-27ae8cdff55e": remove /opt/factorio/script-output/mapshot-done-ea13595d-be55-441f-af45-27ae8cdff55e: no such file or directory
    Starting Factorio...
    I1104 14:29:11.913057 3589125 factorio.go:124] Running factorio with args: [--disable-audio --load-game /tmp/mapshot2197921783/XI_1028_backup.zip --mod-directory /tmp/mapshot2197921783/mods]
    I1104 14:29:11.922428 3589125 factorio.go:151] Factorio returned: <nil>
    I1104 14:29:11.924859 3589125 root.go:37] temp dir "/tmp/mapshot2197921783" removed
    Error: factorio exited early
    
  • cat ./steam.sh:

    #!/usr/bin/env bash
    exec steam -applaunch 42752 "$@"
    

I also treid 427520 as app id because it is currently listed in Factorio's Steam store url https://store.steampowered.com/app/427520/Factorio/ , but still not worked.

@Palats
Copy link
Owner

Palats commented Nov 4, 2024

Did you check if the output was created? Running through steam is likely to make it hard to detect exit, so I'm not surprised it would print that, but that does not mean the rendering was not created.

Otherwise, I'm afraid I don't have plan to look into it for now - running the steam version is a bit annoying and it is possible to download a standalone Factorio from the official site, even if you just have the Steam version of it.

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

No branches or pull requests

3 participants