Only calculate string when we need it

This commit is contained in:
Sally Coolatta 2021-12-25 05:18:33 -05:00 committed by SinnamonLat
parent 0e55de6dcc
commit 817e6f568a

View file

@ -913,13 +913,7 @@ static inline boolean HU_keyInChatString(char *s, char ch)
// //
static void HU_TickSongCredits(void) static void HU_TickSongCredits(void)
{ {
char *str; if (cursongcredit.def == NULL) // No def
INT32 len;
fixed_t destx;
cursongcredit.old_x = cursongcredit.x;
if (!cursongcredit.def) // No def
{ {
cursongcredit.x = cursongcredit.old_x = 0; cursongcredit.x = cursongcredit.old_x = 0;
cursongcredit.anim = 0; cursongcredit.anim = 0;
@ -927,12 +921,14 @@ static void HU_TickSongCredits(void)
return; return;
} }
str = va("\x1F"" %s", cursongcredit.def->source); cursongcredit.old_x = cursongcredit.x;
len = V_ThinStringWidth(str, V_ALLOWLOWERCASE|V_6WIDTHSPACE);
destx = (len+7) * FRACUNIT;
if (cursongcredit.anim > 0) if (cursongcredit.anim > 0)
{ {
char *str = va("\x1F"" %s", cursongcredit.def->source);
INT32 len = V_ThinStringWidth(str, V_ALLOWLOWERCASE|V_6WIDTHSPACE);
fixed_t destx = (len+7) * FRACUNIT;
if (cursongcredit.trans > 0) if (cursongcredit.trans > 0)
{ {
cursongcredit.trans--; cursongcredit.trans--;