Fix SOC color name reading

This commit is contained in:
SwitchKaze 2020-05-30 16:52:44 -05:00
parent 50a225f8cd
commit fa786b1eed

View file

@ -769,7 +769,8 @@ static void readthing(MYFILE *f, INT32 num)
static void readskincolor(MYFILE *f, INT32 num) static void readskincolor(MYFILE *f, INT32 num)
{ {
char *s = Z_Malloc(MAXLINELEN, PU_STATIC, NULL); char *s = Z_Malloc(MAXLINELEN, PU_STATIC, NULL);
char *word, *word2, *word3; char *word = s;
char *word2;
char *tmp; char *tmp;
Color_cons_t[num].value = num; Color_cons_t[num].value = num;
@ -781,32 +782,31 @@ static void readskincolor(MYFILE *f, INT32 num)
if (s[0] == '\n') if (s[0] == '\n')
break; break;
// First remove trailing newline, if there is one
tmp = strchr(s, '\n');
if (tmp)
*tmp = '\0';
tmp = strchr(s, '#'); tmp = strchr(s, '#');
if (tmp) if (tmp)
*tmp = '\0'; *tmp = '\0';
if (s == tmp) if (s == tmp)
continue; // Skip comment lines, but don't break. continue; // Skip comment lines, but don't break.
word = strtok(s, " "); // Get the part before the " = "
if (word) tmp = strchr(s, '=');
strupr(word); if (tmp)
*(tmp-1) = '\0';
else else
break; break;
strupr(word);
word2 = strtok(NULL, " = "); // Now get the part after
if (word2) { word2 = tmp += 2;
word3 = Z_StrDup(word2);
strupr(word2);
} else
break;
if (word2[strlen(word2)-1] == '\n')
word2[strlen(word2)-1] = '\0';
if (word3[strlen(word3)-1] == '\n')
word3[strlen(word3)-1] = '\0';
if (fastcmp(word, "NAME")) if (fastcmp(word, "NAME"))
{ {
deh_strlcpy(skincolors[num].name, word3, deh_strlcpy(skincolors[num].name, word2,
sizeof (skincolors[num].name), va("Skincolor %d: name", num)); sizeof (skincolors[num].name), va("Skincolor %d: name", num));
} }
else if (fastcmp(word, "RAMP")) else if (fastcmp(word, "RAMP"))