Fix #4951
This commit is contained in:
parent
a57ac415bb
commit
5bb5f5e86e
@ -231,14 +231,37 @@ bool ReplayPlay::addReplayFile(const std::string& fn, bool custom_replay, int ca
|
||||
else
|
||||
rd.m_minor_mode = "time-trial";
|
||||
|
||||
|
||||
// sscanf always stops at whitespaces, but a track name may contain a whitespace
|
||||
// Official tracks should avoid whitespaces in their name, but it
|
||||
// unavoidably occurs with some addons or WIP tracks.
|
||||
fgets(s, 1023, fd);
|
||||
if (sscanf(s, "track: %1023s", s1) != 1)
|
||||
if (std::strncmp(s, "track: ", 7) == 0)
|
||||
{
|
||||
int i = 0;
|
||||
for(i = 7; s[i] != '\0'; i++)
|
||||
{
|
||||
// Break when newline is reached
|
||||
if (s[i] == '\n' || s[i] == '\r')
|
||||
break;
|
||||
s1[i-7] = s[i];
|
||||
}
|
||||
s1[i-7] = '\0';
|
||||
|
||||
if (i >= 8)
|
||||
{
|
||||
rd.m_track_name = std::string(s1);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log::warn("Replay", "Track name is empty in replay file, '%s'.", fn.c_str());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Log::warn("Replay", "Track info not found in replay file, '%s'.", fn.c_str());
|
||||
return false;
|
||||
}
|
||||
rd.m_track_name = std::string(s1);
|
||||
|
||||
// If former official tracks are present as addons, show the matching replays.
|
||||
if (rd.m_track_name.compare("greenvalley") == 0)
|
||||
|
Loading…
Reference in New Issue
Block a user