Preparation for hidden characters, making sure R_SkinAvailable was being used where appropriate.

Also, bugfix for something my optimisation introduced.
This commit is contained in:
toasterbabe 2016-07-11 23:40:31 +01:00
parent eee6a6ff45
commit ee92e043b9
3 changed files with 23 additions and 45 deletions

View file

@ -584,6 +584,8 @@ static void readPlayer(MYFILE *f, INT32 num)
strlcpy(description[num].skinname, word2, sizeof description[num].skinname);
strlwr(description[num].skinname);
description[num].picname[0] = '\0'; // Redesign your logo. (See M_DrawSetupChoosePlayerMenu in m_menu.c...)
}
else
deh_warning("readPlayer %d: unknown word '%s'", num, word);

View file

@ -4859,25 +4859,18 @@ static void M_DrawSetupChoosePlayerMenu(void)
next = 0;
} while (next != i && PlayerMenu[next].status == IT_DISABLED); // Skip over all disabled characters.
// Draw prev character if it's visible and its number isn't greater than the current one
// Draw prev character if it's visible and its number isn't greater than the current one or there's more than two
if ((o < 32) && !((prev == next) && prev > i)) // (prev != i) was previously a part of this, but we don't need to check again after above.
{
picname = description[prev].picname;
if (picname[0] == '\0')
{
picname = strtok(Z_StrDup(description[prev].skinname), "&");
for (j = 0; j < numskins; j++)
if (stricmp(skins[j].name, picname) == 0)
{
Z_Free(picname);
picname = skins[j].charsel;
break;
}
if (j == numskins) // AAAAAAAAAA
{
Z_Free(picname);
picname = skins[0].charsel;
}
j = R_SkinAvailable(picname);
Z_Free(picname);
if (j == -1)
j = 0;
picname = skins[j].charsel;
strncpy(description[prev].picname, picname, 8); // Only iterate once.
}
patch = W_CachePatchName(picname, PU_CACHE);
@ -4888,25 +4881,18 @@ static void M_DrawSetupChoosePlayerMenu(void)
W_UnlockCachedPatch(patch);
}
// Draw next character if it's visible and its number isn't less than the current one
// Draw next character if it's visible and its number isn't less than the current one or there's more than two
if ((o < 128) && !((prev == next) && next < i)) // (next != i) was previously a part of this, but it's implicitly true if (prev != i) is true.
{
picname = description[next].picname;
if (picname[0] == '\0')
{
picname = strtok(Z_StrDup(description[next].skinname), "&");
for (j = 0; j < numskins; j++)
if (stricmp(skins[j].name, picname) == 0)
{
Z_Free(picname);
picname = skins[j].charsel;
break;
}
if (j == numskins) // AAAAAAAAAA
{
Z_Free(picname);
picname = skins[0].charsel;
}
j = R_SkinAvailable(picname);
Z_Free(picname);
if (j == -1)
j = 0;
picname = skins[j].charsel;
strncpy(description[next].picname, picname, 8); // Only iterate once.
}
patch = W_CachePatchName(picname, PU_CACHE);
@ -4928,18 +4914,11 @@ static void M_DrawSetupChoosePlayerMenu(void)
if (picname[0] == '\0')
{
picname = strtok(Z_StrDup(description[i].skinname), "&");
for (j = 0; j < numskins; j++)
if (stricmp(skins[j].name, picname) == 0)
{
Z_Free(picname);
picname = skins[j].charsel;
break;
}
if (j == numskins) // AAAAAAAAAA
{
j = R_SkinAvailable(picname);
Z_Free(picname);
picname = skins[0].charsel;
}
if (j == -1)
j = 0;
picname = skins[j].charsel;
strncpy(description[i].picname, picname, 8); // Only iterate once.
}
patch = W_CachePatchName(picname, PU_CACHE);

View file

@ -2337,6 +2337,7 @@ INT32 R_SkinAvailable(const char *name)
for (i = 0; i < numskins; i++)
{
// search in the skin list
if (stricmp(skins[i].name,name)==0)
return i;
}
@ -2346,17 +2347,13 @@ INT32 R_SkinAvailable(const char *name)
// network code calls this when a 'skin change' is received
void SetPlayerSkin(INT32 playernum, const char *skinname)
{
INT32 i;
INT32 i = R_SkinAvailable(skinname);
player_t *player = &players[playernum];
for (i = 0; i < numskins; i++)
if (i != -1)
{
// search in the skin list
if (stricmp(skins[i].name, skinname) == 0)
{
SetPlayerSkinByNum(playernum, i);
return;
}
SetPlayerSkinByNum(playernum, i);
return;
}
if (P_IsLocalPlayer(player))