mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-02-06 16:31:47 +00:00
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:
parent
eee6a6ff45
commit
ee92e043b9
3 changed files with 23 additions and 45 deletions
|
@ -584,6 +584,8 @@ static void readPlayer(MYFILE *f, INT32 num)
|
||||||
|
|
||||||
strlcpy(description[num].skinname, word2, sizeof description[num].skinname);
|
strlcpy(description[num].skinname, word2, sizeof description[num].skinname);
|
||||||
strlwr(description[num].skinname);
|
strlwr(description[num].skinname);
|
||||||
|
|
||||||
|
description[num].picname[0] = '\0'; // Redesign your logo. (See M_DrawSetupChoosePlayerMenu in m_menu.c...)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
deh_warning("readPlayer %d: unknown word '%s'", num, word);
|
deh_warning("readPlayer %d: unknown word '%s'", num, word);
|
||||||
|
|
43
src/m_menu.c
43
src/m_menu.c
|
@ -4859,25 +4859,18 @@ static void M_DrawSetupChoosePlayerMenu(void)
|
||||||
next = 0;
|
next = 0;
|
||||||
} while (next != i && PlayerMenu[next].status == IT_DISABLED); // Skip over all disabled characters.
|
} 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.
|
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;
|
picname = description[prev].picname;
|
||||||
if (picname[0] == '\0')
|
if (picname[0] == '\0')
|
||||||
{
|
{
|
||||||
picname = strtok(Z_StrDup(description[prev].skinname), "&");
|
picname = strtok(Z_StrDup(description[prev].skinname), "&");
|
||||||
for (j = 0; j < numskins; j++)
|
j = R_SkinAvailable(picname);
|
||||||
if (stricmp(skins[j].name, picname) == 0)
|
|
||||||
{
|
|
||||||
Z_Free(picname);
|
Z_Free(picname);
|
||||||
|
if (j == -1)
|
||||||
|
j = 0;
|
||||||
picname = skins[j].charsel;
|
picname = skins[j].charsel;
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (j == numskins) // AAAAAAAAAA
|
|
||||||
{
|
|
||||||
Z_Free(picname);
|
|
||||||
picname = skins[0].charsel;
|
|
||||||
}
|
|
||||||
strncpy(description[prev].picname, picname, 8); // Only iterate once.
|
strncpy(description[prev].picname, picname, 8); // Only iterate once.
|
||||||
}
|
}
|
||||||
patch = W_CachePatchName(picname, PU_CACHE);
|
patch = W_CachePatchName(picname, PU_CACHE);
|
||||||
|
@ -4888,25 +4881,18 @@ static void M_DrawSetupChoosePlayerMenu(void)
|
||||||
W_UnlockCachedPatch(patch);
|
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.
|
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;
|
picname = description[next].picname;
|
||||||
if (picname[0] == '\0')
|
if (picname[0] == '\0')
|
||||||
{
|
{
|
||||||
picname = strtok(Z_StrDup(description[next].skinname), "&");
|
picname = strtok(Z_StrDup(description[next].skinname), "&");
|
||||||
for (j = 0; j < numskins; j++)
|
j = R_SkinAvailable(picname);
|
||||||
if (stricmp(skins[j].name, picname) == 0)
|
|
||||||
{
|
|
||||||
Z_Free(picname);
|
Z_Free(picname);
|
||||||
|
if (j == -1)
|
||||||
|
j = 0;
|
||||||
picname = skins[j].charsel;
|
picname = skins[j].charsel;
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (j == numskins) // AAAAAAAAAA
|
|
||||||
{
|
|
||||||
Z_Free(picname);
|
|
||||||
picname = skins[0].charsel;
|
|
||||||
}
|
|
||||||
strncpy(description[next].picname, picname, 8); // Only iterate once.
|
strncpy(description[next].picname, picname, 8); // Only iterate once.
|
||||||
}
|
}
|
||||||
patch = W_CachePatchName(picname, PU_CACHE);
|
patch = W_CachePatchName(picname, PU_CACHE);
|
||||||
|
@ -4928,18 +4914,11 @@ static void M_DrawSetupChoosePlayerMenu(void)
|
||||||
if (picname[0] == '\0')
|
if (picname[0] == '\0')
|
||||||
{
|
{
|
||||||
picname = strtok(Z_StrDup(description[i].skinname), "&");
|
picname = strtok(Z_StrDup(description[i].skinname), "&");
|
||||||
for (j = 0; j < numskins; j++)
|
j = R_SkinAvailable(picname);
|
||||||
if (stricmp(skins[j].name, picname) == 0)
|
|
||||||
{
|
|
||||||
Z_Free(picname);
|
Z_Free(picname);
|
||||||
|
if (j == -1)
|
||||||
|
j = 0;
|
||||||
picname = skins[j].charsel;
|
picname = skins[j].charsel;
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (j == numskins) // AAAAAAAAAA
|
|
||||||
{
|
|
||||||
Z_Free(picname);
|
|
||||||
picname = skins[0].charsel;
|
|
||||||
}
|
|
||||||
strncpy(description[i].picname, picname, 8); // Only iterate once.
|
strncpy(description[i].picname, picname, 8); // Only iterate once.
|
||||||
}
|
}
|
||||||
patch = W_CachePatchName(picname, PU_CACHE);
|
patch = W_CachePatchName(picname, PU_CACHE);
|
||||||
|
|
|
@ -2337,6 +2337,7 @@ INT32 R_SkinAvailable(const char *name)
|
||||||
|
|
||||||
for (i = 0; i < numskins; i++)
|
for (i = 0; i < numskins; i++)
|
||||||
{
|
{
|
||||||
|
// search in the skin list
|
||||||
if (stricmp(skins[i].name,name)==0)
|
if (stricmp(skins[i].name,name)==0)
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
@ -2346,18 +2347,14 @@ INT32 R_SkinAvailable(const char *name)
|
||||||
// network code calls this when a 'skin change' is received
|
// network code calls this when a 'skin change' is received
|
||||||
void SetPlayerSkin(INT32 playernum, const char *skinname)
|
void SetPlayerSkin(INT32 playernum, const char *skinname)
|
||||||
{
|
{
|
||||||
INT32 i;
|
INT32 i = R_SkinAvailable(skinname);
|
||||||
player_t *player = &players[playernum];
|
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);
|
SetPlayerSkinByNum(playernum, i);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (P_IsLocalPlayer(player))
|
if (P_IsLocalPlayer(player))
|
||||||
CONS_Alert(CONS_WARNING, M_GetText("Skin '%s' not found.\n"), skinname);
|
CONS_Alert(CONS_WARNING, M_GetText("Skin '%s' not found.\n"), skinname);
|
||||||
|
|
Loading…
Reference in a new issue