mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Skin rivals system: Adjust for fixes/consistency
- Previously duplicated across R_AddSkins and R_PatchSkins, now handled in R_ProcessPatchableFields. - Increase the size of the buffer to SKINNAMESIZE+1, to prevent silent failure for long character names.
This commit is contained in:
parent
65f679c0bc
commit
acc5fc85b9
1 changed files with 51 additions and 79 deletions
130
src/r_skins.c
130
src/r_skins.c
|
|
@ -727,9 +727,59 @@ static void R_LoadSkinSprites(UINT16 wadnum, UINT16 *lump, UINT16 *lastlump, ski
|
||||||
// returns whether found appropriate property
|
// returns whether found appropriate property
|
||||||
static boolean R_ProcessPatchableFields(skin_t *skin, char *stoken, char *value)
|
static boolean R_ProcessPatchableFields(skin_t *skin, char *stoken, char *value)
|
||||||
{
|
{
|
||||||
|
if (!stricmp(stoken, "rivals"))
|
||||||
|
{
|
||||||
|
size_t len = strlen(value);
|
||||||
|
size_t i;
|
||||||
|
char rivalname[SKINNAMESIZE+1] = "";
|
||||||
|
UINT8 pos = 0;
|
||||||
|
UINT8 numrivals = 0;
|
||||||
|
|
||||||
|
// Can't use strtok, because the above function's already using it.
|
||||||
|
// Using it causes it to upset the saved pointer,
|
||||||
|
// corrupting the reading for the rest of the file.
|
||||||
|
|
||||||
|
// So instead we get to crawl through the value, character by character,
|
||||||
|
// and write it down as we go, until we hit a comma or the end of the string.
|
||||||
|
// Yaaay.
|
||||||
|
|
||||||
|
for (i = 0; i <= len; i++)
|
||||||
|
{
|
||||||
|
if (numrivals >= SKINRIVALS)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (value[i] == ',' || i == len)
|
||||||
|
{
|
||||||
|
if (pos == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
STRBUFCPY(skin->rivals[numrivals], rivalname);
|
||||||
|
strlwr(skin->rivals[numrivals]);
|
||||||
|
numrivals++;
|
||||||
|
|
||||||
|
if (i == len)
|
||||||
|
break;
|
||||||
|
|
||||||
|
for (; pos > 0; pos--)
|
||||||
|
{
|
||||||
|
rivalname[pos] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
rivalname[pos] = value[i];
|
||||||
|
pos++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// custom translation table
|
// custom translation table
|
||||||
if (!stricmp(stoken, "startcolor"))
|
else if (!stricmp(stoken, "startcolor"))
|
||||||
|
{
|
||||||
skin->starttranscolor = atoi(value);
|
skin->starttranscolor = atoi(value);
|
||||||
|
}
|
||||||
|
|
||||||
#define FULLPROCESS(field) else if (!stricmp(stoken, #field)) skin->field = get_number(value);
|
#define FULLPROCESS(field) else if (!stricmp(stoken, #field)) skin->field = get_number(value);
|
||||||
// character type identification
|
// character type identification
|
||||||
|
|
@ -917,45 +967,6 @@ void R_AddSkins(UINT16 wadnum, boolean mainfile)
|
||||||
STRBUFCPY(skin->realname, value);
|
STRBUFCPY(skin->realname, value);
|
||||||
SYMBOLCONVERT(skin->realname)
|
SYMBOLCONVERT(skin->realname)
|
||||||
}
|
}
|
||||||
else if (!stricmp(stoken, "rivals"))
|
|
||||||
{
|
|
||||||
size_t len = strlen(value);
|
|
||||||
size_t i;
|
|
||||||
char rivalname[SKINNAMESIZE] = "";
|
|
||||||
UINT8 pos = 0;
|
|
||||||
UINT8 numrivals = 0;
|
|
||||||
|
|
||||||
// Can't use strtok, because this function's already using it.
|
|
||||||
// Using it causes it to upset the saved pointer,
|
|
||||||
// corrupting the reading for the rest of the file.
|
|
||||||
|
|
||||||
// So instead we get to crawl through the value, character by character,
|
|
||||||
// and write it down as we go, until we hit a comma or the end of the string.
|
|
||||||
// Yaaay.
|
|
||||||
|
|
||||||
for (i = 0; i <= len; i++)
|
|
||||||
{
|
|
||||||
if (numrivals >= SKINRIVALS)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (value[i] == ',' || i == len)
|
|
||||||
{
|
|
||||||
STRBUFCPY(skin->rivals[numrivals], rivalname);
|
|
||||||
strlwr(skin->rivals[numrivals]);
|
|
||||||
numrivals++;
|
|
||||||
|
|
||||||
memset(rivalname, 0, sizeof (rivalname));
|
|
||||||
pos = 0;
|
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
rivalname[pos] = value[i];
|
|
||||||
pos++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (!R_ProcessPatchableFields(skin, stoken, value))
|
else if (!R_ProcessPatchableFields(skin, stoken, value))
|
||||||
CONS_Debug(DBG_SETUP, "R_AddSkins: Unknown keyword '%s' in S_SKIN lump #%d (WAD %s)\n", stoken, lump, wadfiles[wadnum]->filename);
|
CONS_Debug(DBG_SETUP, "R_AddSkins: Unknown keyword '%s' in S_SKIN lump #%d (WAD %s)\n", stoken, lump, wadfiles[wadnum]->filename);
|
||||||
|
|
||||||
|
|
@ -1073,45 +1084,6 @@ void R_PatchSkins(UINT16 wadnum, boolean mainfile)
|
||||||
STRBUFCPY(skin->realname, value);
|
STRBUFCPY(skin->realname, value);
|
||||||
SYMBOLCONVERT(skin->realname)
|
SYMBOLCONVERT(skin->realname)
|
||||||
}
|
}
|
||||||
else if (!stricmp(stoken, "rivals"))
|
|
||||||
{
|
|
||||||
size_t len = strlen(value);
|
|
||||||
size_t i;
|
|
||||||
char rivalname[SKINNAMESIZE] = "";
|
|
||||||
UINT8 pos = 0;
|
|
||||||
UINT8 numrivals = 0;
|
|
||||||
|
|
||||||
// Can't use strtok, because this function's already using it.
|
|
||||||
// Using it causes it to upset the saved pointer,
|
|
||||||
// corrupting the reading for the rest of the file.
|
|
||||||
|
|
||||||
// So instead we get to crawl through the value, character by character,
|
|
||||||
// and write it down as we go, until we hit a comma or the end of the string.
|
|
||||||
// Yaaay.
|
|
||||||
|
|
||||||
for (i = 0; i <= len; i++)
|
|
||||||
{
|
|
||||||
if (numrivals >= SKINRIVALS)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (value[i] == ',' || i == len)
|
|
||||||
{
|
|
||||||
STRBUFCPY(skin->rivals[numrivals], rivalname);
|
|
||||||
strlwr(skin->rivals[numrivals]);
|
|
||||||
numrivals++;
|
|
||||||
|
|
||||||
memset(rivalname, 0, sizeof (rivalname));
|
|
||||||
pos = 0;
|
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
rivalname[pos] = value[i];
|
|
||||||
pos++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (!R_ProcessPatchableFields(skin, stoken, value))
|
else if (!R_ProcessPatchableFields(skin, stoken, value))
|
||||||
CONS_Debug(DBG_SETUP, "R_PatchSkins: Unknown keyword '%s' in P_SKIN lump #%d (WAD %s)\n", stoken, lump, wadfiles[wadnum]->filename);
|
CONS_Debug(DBG_SETUP, "R_PatchSkins: Unknown keyword '%s' in P_SKIN lump #%d (WAD %s)\n", stoken, lump, wadfiles[wadnum]->filename);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue