Closed apanteleev closed 2 weeks ago
It looks like upstream Q2PRO may have addressed this issue already: https://github.com/skullernet/q2pro/commit/17e38fd9a17a69dc45296154f75320d3dc8dd172 So one solution would be to port this commit over.
Otherwise, using real paths consistently sounds sensible.
I share the same opinion to that of @res2k
I may have a controversial opinion, but i think that porting 17e38fd is not a bad idea, but could be just as error prone as the current behaviour.
Real saves are only stored in the host filesystem. The solution that honours that would work better.
This is not a part of the code I worked on, so please help me understand:
A development directory with a game is shared between two machines, a Linux one and a Windows one. The Windows machine runs the game, starts the base1 map, and writes a save into
/baseq2/save/.current/base1.{sav,sv2,ssv} The Linux machine runs the game, attempts to start the same map and fails with an error saying Couldn't open /.local/share/quake2rtx/baseq2/save/.current/base1.sav. Very confusing.
So basically, you have directory A where Windows saved the game and then directory B where a Linux system tried to pull the save from, but failed? I imagine the inverse also holds true?
If this is the case, +gamedir
on the command line should get around this.
Thanks all for the comments. I think that Q2PRO commit looks more like a hacky solution than a proper one. I guess I'll try to convert all save game logic to use real paths.
So basically, you have directory A where Windows saved the game and then directory B where a Linux system tried to pull the save from, but failed? I imagine the inverse also holds true? If this is the case, +gamedir on the command line should get around this.
The problem is not that the Linux system fails to pull the save, it's that there exists a file system state where a new game cannot be started because of broken logic.
I just got around to fixing this... Pull request https://github.com/NVIDIA/Q2RTX/pull/414
In src/server/save.c, the save files are accessed through different ways:
read_binary_file
and adjacent functions are going through the Q2's filesystem layer, which handles multiple search paths.ge->ReadLevel(name)
and similar functions take real filesystem paths.In some cases, that may lead to the game trying to access different componets of a save from different locations. One case that I encountered is this:
base1
map, and writes a save into<dev-path>/baseq2/save/.current/base1.{sav,sv2,ssv}
Couldn't open <user>/.local/share/quake2rtx/baseq2/save/.current/base1.sav
. Very confusing.The reason for that failure is that
SV_CheckForSavegame
callsread_level_file
, which checks whether a save exists usingread_binary_file
that asks the FS layer and therefore picks up the save from baseq2. That succeds, and later theread_level_file
function callsge->ReadLevel(name)
wherename
is a real path based onfs_gamedir
. Which is different from thebaseq2
location that the FS layer found. And it fails, taking the game down with it.Granted, this is an obscure use case, but it points at some real issues with save game handling. How should these be fixed? Obviously, all save file access should be done using the same method. Since the game library functions (
ge->...
) only take real paths, the other functions should also operate on real paths based onfs_gamedir
.Asking the contributors to https://github.com/NVIDIA/Q2RTX/pull/250 (XDG support) - do you see any potential issues with switching the save code to use real paths? @Connor-GH @res2k @runlevel5 @appetrosyan
Thanks!