Skip to content

Commit

Permalink
Don't use translation in Autosave filenames, fixes #305
Browse files Browse the repository at this point in the history
idSessionLocal::SaveGame() uses saveName for both the description in
savegames/bla.txt and the filename itself ("bla" in this case), which
is a "scrubbed" version of that string ("file extension" removed,
problematic chars replaced with '_').
In case of Autosaves, MoveToNewMap() passes a translated name of the
map as saveName, which makes sense for the description, but not so much
for the filename.
In Spanish the Alpha Labs names are like "LAB. ALFA 1", "LAB. ALFA 2" ..
and everything after "LAB" is cut off as a file extension - so every
autosave of an Alpha Labs part overwrites the last one, as they all get
the same name...

The solution is to pass an additional (optional) argument saveFileName
to idSessionLocal::SaveGame(), and for autosaves pass the mapname
(which is the filename without .map; yes, it might contain slashes,
but the scrubber will turn them into _) instead of the translated name
as saveFileName.
  • Loading branch information
DanielGibson committed Aug 2, 2020
1 parent d708fbd commit 7d2bda0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
16 changes: 12 additions & 4 deletions neo/framework/Session.cpp
Expand Up @@ -1238,7 +1238,14 @@ void idSessionLocal::MoveToNewMap( const char *mapName ) {

if ( !mapSpawnData.serverInfo.GetBool("devmap") ) {
// Autosave at the beginning of the level
SaveGame( GetAutoSaveName( mapName ), true );

// DG: set an explicit savename to avoid problems with autosave names
// (they were translated which caused problems like all alpha labs parts
// getting the same filename in spanish, probably because the strings contained
// dots and everything behind them was cut off as "file extension".. see #305)
idStr saveFileName = "Autosave_";
saveFileName += mapName;
SaveGame( GetAutoSaveName( mapName ), true, saveFileName );
}

SetGUI( NULL, NULL );
Expand Down Expand Up @@ -1898,13 +1905,15 @@ void idSessionLocal::ScrubSaveGameFileName( idStr &saveFileName ) const {
idSessionLocal::SaveGame
===============
*/
bool idSessionLocal::SaveGame( const char *saveName, bool autosave ) {
bool idSessionLocal::SaveGame( const char *saveName, bool autosave, const char* saveFileName ) {
#ifdef ID_DEDICATED
common->Printf( "Dedicated servers cannot save games.\n" );
return false;
#else
int i;
idStr gameFile, previewFile, descriptionFile, mapName;
idStr previewFile, descriptionFile, mapName;
// DG: support setting an explicit savename to avoid problems with autosave names
idStr gameFile = (saveFileName != NULL) ? saveFileName : saveName;

if ( !mapSpawned ) {
common->Printf( "Not playing a game.\n" );
Expand Down Expand Up @@ -1935,7 +1944,6 @@ bool idSessionLocal::SaveGame( const char *saveName, bool autosave ) {
}

// setup up filenames and paths
gameFile = saveName;
ScrubSaveGameFileName( gameFile );

gameFile = "savegames/" + gameFile;
Expand Down
3 changes: 2 additions & 1 deletion neo/framework/Session_local.h
Expand Up @@ -163,7 +163,8 @@ class idSessionLocal : public idSession {
idStr GetAutoSaveName( const char *mapName ) const;

bool LoadGame(const char *saveName);
bool SaveGame(const char *saveName, bool autosave = false);
// DG: added saveFileName so we can set a sensible filename for autosaves (see comment in MoveToNewMap())
bool SaveGame(const char *saveName, bool autosave = false, const char* saveFileName = NULL);

const char *GetAuthMsg( void );

Expand Down

0 comments on commit 7d2bda0

Please sign in to comment.