host_cmd.c (Host_SavegameComment): Remove CR/LFs from level name.

Avoids broken saves, e.g. with autumn_sp map.  See:
https://celephais.net/board/view_thread.php?id=60452&start=3666
This commit is contained in:
Ozkan Sezer 2020-09-08 14:00:00 +03:00
parent 9c9e45d9bb
commit 15a41d2169

View file

@ -1000,9 +1000,18 @@ void Host_SavegameComment (char *text)
{
int i;
char kills[20];
char *p1, *p2;
for (i = 0; i < SAVEGAME_COMMENT_LENGTH; i++)
text[i] = ' ';
// Remove CR/LFs from level name to avoid broken saves, e.g. with autumn_sp map:
// https://celephais.net/board/view_thread.php?id=60452&start=3666
p1 = strchr(cl.levelname, '\n');
p2 = strchr(cl.levelname, '\r');
if (p1 != NULL) *p1 = 0;
if (p2 != NULL) *p2 = 0;
memcpy (text, cl.levelname, q_min(strlen(cl.levelname),22)); //johnfitz -- only copy 22 chars.
sprintf (kills,"kills:%3i/%3i", cl.stats[STAT_MONSTERS], cl.stats[STAT_TOTALMONSTERS]);
memcpy (text+22, kills, strlen(kills));
@ -1012,6 +1021,8 @@ void Host_SavegameComment (char *text)
if (text[i] == ' ')
text[i] = '_';
}
if (p1 != NULL) *p1 = '\n';
if (p2 != NULL) *p2 = '\r';
text[SAVEGAME_COMMENT_LENGTH] = '\0';
}