Don't use translation in Autosave filenames, fixes #305

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.
This commit is contained in:
Daniel Gibson 2020-08-02 03:48:25 +02:00
parent d708fbd974
commit 7d2bda07a3
2 changed files with 14 additions and 5 deletions

View file

@ -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 );
@ -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" );
@ -1935,7 +1944,6 @@ bool idSessionLocal::SaveGame( const char *saveName, bool autosave ) {
}
// setup up filenames and paths
gameFile = saveName;
ScrubSaveGameFileName( gameFile );
gameFile = "savegames/" + gameFile;

View file

@ -163,7 +163,8 @@ public:
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 );