Skip to content

Commit

Permalink
LoadGame: fix chapters not being translated on autosaves and quicksaves
Browse files Browse the repository at this point in the history
  • Loading branch information
a1batross committed Mar 6, 2021
1 parent aa22e70 commit 36a3df5
Showing 1 changed file with 29 additions and 10 deletions.
39 changes: 29 additions & 10 deletions menus/LoadGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,25 +194,44 @@ void CMenuSavesListModel::Update( void )
COM_FileBase( filenames[j], saveName[i] );
COM_FileBase( filenames[j], delName[i] );

// fill save desc
snprintf( m_szCells[i][0], MAX_CELLSTRING, "%s %s", comment + CS_SIZE, comment + CS_SIZE + CS_TIME );
if( comment[0] == '#' )
// they are defined by comment string format
const char *time = comment + CS_SIZE;
const char *date = comment + CS_SIZE + CS_TIME;
const char *elapsedTime = comment + CS_SIZE + CS_TIME * 2;

char *title = comment;
char type[CS_SIZE] = {}, *p = nullptr;
const char *translated_title = nullptr;

// if comments begin with [ and there is second ]
if( comment[0] == '[' && ( p = strchr( comment, ']' )))
{
title = p + 1;
Q_strncpy( type, comment, title - comment + 1 );
}

if( *title == '#' )
{
// strip everything after first space
char s[CS_SIZE];
char *p = strchr( comment, ' ' );
size_t len;

len = p ? p - comment + 1 : CS_SIZE;
p = strchr( title, ' ' );

size_t len = p ? (p - title + 1) : ( CS_SIZE - ( title - comment ));

Q_strncpy( s, comment, len );
Q_strncpy( m_szCells[i][1], L( s ), MAX_CELLSTRING );
Q_strncpy( s, title, len );
translated_title = L( s );
}
else
{
Q_strncpy( m_szCells[i][1], comment, MAX_CELLSTRING );
translated_title = title;
}
Q_strncpy( m_szCells[i][2], comment + CS_SIZE + (CS_TIME * 2), MAX_CELLSTRING );

// fill save desc
snprintf( m_szCells[i][0], MAX_CELLSTRING, "%s %s", time, date );
snprintf( m_szCells[i][1], MAX_CELLSTRING, "%s%s", type, translated_title );
Q_strncpy( m_szCells[i][2], elapsedTime, MAX_CELLSTRING );

}

m_iNumItems = i;
Expand Down

0 comments on commit 36a3df5

Please sign in to comment.