xray-16 icon indicating copy to clipboard operation
xray-16 copied to clipboard

On Linux, quick save are being created in a subfolder instead of game saves folder

Open Xottab-DUTY opened this issue 1 year ago • 2 comments

Describe the bug When you use a quick save, the file name is <system name> - quicksave.<fmt>, where <system name> is the user profile name in the OS and <fmt> is file format – either scop or sav.

For some reason, when we try to save a file with path game folder/_appdata_/savedgames/user - quicksave.scop, the result appears to be game folder/_appdata_/gamesaves/user/- quicksave.scop – it creates a subfolder.

To Reproduce Steps to reproduce the behavior:

  1. Use a quick save
  2. See the bug

Expected behavior Quick saves should be saved into savedgames folder normally.

Screenshots, videos image image

Desktop (please complete the following information):

  • OS: any Linux
  • OpenXRay latest

Additional context Look at function CALifeStorageManager::save in xrGame/alife_storage_manager.cpp

Xottab-DUTY avatar Nov 20 '23 09:11 Xottab-DUTY

@AMS21, could you look?

Xottab-DUTY avatar Nov 20 '23 09:11 Xottab-DUTY

I've tried to replicate this but it works as expected on my machine. From what I've gathered while looking at the code I would assume that for some reason Core.UserName contains a trailing backslash as I can replicate this behavior by hard coding the name like this

diff --git a/src/xrCore/xrCore.cpp b/src/xrCore/xrCore.cpp
index bf0389127..395075f59 100644
--- a/src/xrCore/xrCore.cpp
+++ b/src/xrCore/xrCore.cpp
@@ -228,7 +228,7 @@ void xrCore::Initialize(pcstr _ApplicationName, pcstr commandLine, LogCallback c
         struct passwd *pw = getpwuid(uid);
         if(pw)
         {
-            strcpy(UserName, pw->pw_gecos);
+            strcpy(UserName, "lucy\\");
             char* pos = strchr(UserName, ','); // pw_gecos return string
             if(NULL != pos)
                 *pos = 0;

What I'm not sure how this backslash got in there in the first place, since I don't believe having a backslash in your username is allowed but I might be wrong here.

If that's the case one potential fix could be after setting UserName to go and replace all backslashes or other problematic characters with _.

I also notices that since we are using strcpy you could potentially overflow the buffer by having a username which is longer than 64 characters, which could easily be fixed by using strncpy.

AMS21 avatar Nov 20 '23 10:11 AMS21

In theory, this is fixed. We can reopen if it's not.

Xottab-DUTY avatar Apr 05 '24 21:04 Xottab-DUTY