fix M_ScrollString not null terminating its output
this caused music test to have non terminated strings
This commit is contained in:
1 parent
421d735052
commit
599eda96aa
2 files changed
+8
-4
No files matched your search
+6
-2
@@ -5766,7 +5766,8 @@ static void M_DrawMusicTest(void)
|
||||
x = 24;
|
||||
y = 64;
|
||||
|
||||
if (renderisnewtic) st_musictime++;
|
||||
if (renderisnewtic)
|
||||
st_musictime++;
|
||||
|
||||
while (t <= b)
|
||||
{
|
||||
@@ -5774,12 +5775,13 @@ static void M_DrawMusicTest(void)
|
||||
V_DrawFill(20, y-4, 280-1, 16, 237);
|
||||
|
||||
{
|
||||
|
||||
const musicdef_t *def = S_GetMusicCredit(t);
|
||||
const size_t MAXLENGTH = 34;
|
||||
const char *songname = def->title[0] ? def->title : def->source;
|
||||
|
||||
size_t namelength = strlen(songname);
|
||||
|
||||
static const size_t MAXLENGTH = 34;
|
||||
char buf[MAXLENGTH+1];
|
||||
|
||||
if (t == st_sel && namelength > MAXLENGTH)
|
||||
@@ -5788,11 +5790,13 @@ static void M_DrawMusicTest(void)
|
||||
strlcpy(buf, songname, MAXLENGTH);
|
||||
|
||||
V_DrawString(x, y, (t == st_sel ? V_YELLOWMAP : 0)|V_ALLOWLOWERCASE|V_MONOSPACE, buf);
|
||||
|
||||
if (curplaying == def)
|
||||
{
|
||||
V_DrawFill(20+280-9, y-4, 8, 16, 230);
|
||||
}
|
||||
}
|
||||
|
||||
t++;
|
||||
y += 16;
|
||||
}
|
||||
|
||||
+2
-2
@@ -1261,7 +1261,7 @@ void M_ScrollString(const char name[], size_t len, char result[], size_t maxlen,
|
||||
const size_t amount = len - maxlen + 1;
|
||||
|
||||
// Note: anything above 17 will cause zero division
|
||||
const size_t MAXSPEED = 6;
|
||||
static const size_t MAXSPEED = 6;
|
||||
const tic_t t = timer / (35/min(amount, MAXSPEED));
|
||||
|
||||
const size_t state = (t / amount) % 4;
|
||||
@@ -1296,7 +1296,7 @@ void M_ScrollString(const char name[], size_t len, char result[], size_t maxlen,
|
||||
}
|
||||
|
||||
// Technically not necessary, since it gets set again after function call, but just in case
|
||||
result[maxlen] = 0;
|
||||
result[maxlen-1] = '\0';
|
||||
}
|
||||
|
||||
void M_MinimapGenerate(void)
|
||||
|
||||
Reference in new issue
Block a user