Raise the skin limit to 256.

This commit is contained in:
Jaime Ita Passos 2021-04-19 04:01:49 -03:00
parent bcd3245b76
commit f93b1b8d7b
22 changed files with 195 additions and 149 deletions

View file

@ -2463,6 +2463,8 @@ void CL_ClearPlayer(INT32 playernum)
{ {
if (players[playernum].mo) if (players[playernum].mo)
P_RemoveMobj(players[playernum].mo); P_RemoveMobj(players[playernum].mo);
if (players[playernum].availabilities)
Z_Free(players[playernum].availabilities);
memset(&players[playernum], 0, sizeof (player_t)); memset(&players[playernum], 0, sizeof (player_t));
memset(playeraddress[playernum], 0, sizeof(*playeraddress)); memset(playeraddress[playernum], 0, sizeof(*playeraddress));
} }
@ -4486,9 +4488,9 @@ static INT16 Consistancy(void)
{ {
if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed)
continue; continue;
mo = (mobj_t *)th; mo = (mobj_t *)th;
if (mo->flags & (MF_SPECIAL | MF_SOLID | MF_PUSHABLE | MF_BOSS | MF_MISSILE | MF_SPRING | MF_MONITOR | MF_FIRE | MF_ENEMY | MF_PAIN | MF_STICKY)) if (mo->flags & (MF_SPECIAL | MF_SOLID | MF_PUSHABLE | MF_BOSS | MF_MISSILE | MF_SPRING | MF_MONITOR | MF_FIRE | MF_ENEMY | MF_PAIN | MF_STICKY))
{ {
ret -= mo->type; ret -= mo->type;

View file

@ -813,7 +813,8 @@ void D_StartTitle(void)
for (i = 0; i < MAXPLAYERS; i++) for (i = 0; i < MAXPLAYERS; i++)
CL_ClearPlayer(i); CL_ClearPlayer(i);
players[consoleplayer].availabilities = players[1].availabilities = R_GetSkinAvailabilities(); // players[1] is supposed to be for 2p R_GetSkinAvailabilities(&players[consoleplayer].availabilities);
R_GetSkinAvailabilities(&players[1].availabilities); // players[1] is supposed to be for 2p
splitscreen = false; splitscreen = false;
SplitScreen_OnChange(); SplitScreen_OnChange();
@ -1216,10 +1217,6 @@ void D_SRB2Main(void)
// Make backups of some SOCcable tables. // Make backups of some SOCcable tables.
P_BackupTables(); P_BackupTables();
// Setup character tables
// Have to be done here before files are loaded
M_InitCharacterTables();
mainwads = 3; // doesn't include music.dta mainwads = 3; // doesn't include music.dta
#ifdef USE_PATCH_DTA #ifdef USE_PATCH_DTA
mainwads++; mainwads++;

View file

@ -1235,7 +1235,7 @@ static void SendNameAndColor(void)
&& !strcmp(cv_skin.string, skins[players[consoleplayer].skin].name)) && !strcmp(cv_skin.string, skins[players[consoleplayer].skin].name))
return; return;
players[consoleplayer].availabilities = R_GetSkinAvailabilities(); R_GetSkinAvailabilities(&players[consoleplayer].availabilities);
// We'll handle it later if we're not playing. // We'll handle it later if we're not playing.
if (!Playing()) if (!Playing())
@ -1319,9 +1319,9 @@ static void SendNameAndColor(void)
// Finally write out the complete packet and send it off. // Finally write out the complete packet and send it off.
WRITESTRINGN(p, cv_playername.zstring, MAXPLAYERNAME); WRITESTRINGN(p, cv_playername.zstring, MAXPLAYERNAME);
WRITEUINT32(p, (UINT32)players[consoleplayer].availabilities);
WRITEUINT16(p, (UINT16)cv_playercolor.value); WRITEUINT16(p, (UINT16)cv_playercolor.value);
WRITEUINT8(p, (UINT8)cv_skin.value); WRITEUINT8(p, (UINT8)cv_skin.value);
WRITEMEM(p, players[consoleplayer].availabilities, sizeof(bitarray_t) * numskins);
SendNetXCmd(XD_NAMEANDCOLOR, buf, p - buf); SendNetXCmd(XD_NAMEANDCOLOR, buf, p - buf);
} }
@ -1363,7 +1363,7 @@ static void SendNameAndColor2(void)
} }
} }
players[secondplaya].availabilities = R_GetSkinAvailabilities(); R_GetSkinAvailabilities(&players[secondplaya].availabilities);
// We'll handle it later if we're not playing. // We'll handle it later if we're not playing.
if (!Playing()) if (!Playing())
@ -1455,10 +1455,13 @@ static void Got_NameAndColor(UINT8 **cp, INT32 playernum)
#endif #endif
READSTRINGN(*cp, name, MAXPLAYERNAME); READSTRINGN(*cp, name, MAXPLAYERNAME);
p->availabilities = READUINT32(*cp);
color = READUINT16(*cp); color = READUINT16(*cp);
skin = READUINT8(*cp); skin = READUINT8(*cp);
if (p->availabilities == NULL)
p->availabilities = Z_Malloc(sizeof(bitarray_t) * numskins, PU_STATIC, NULL);
READMEM(*cp, p->availabilities, sizeof(bitarray_t) * numskins);
// set name // set name
if (player_name_changes[playernum] < MAXNAMECHANGES) if (player_name_changes[playernum] < MAXNAMECHANGES)
{ {
@ -1491,9 +1494,9 @@ static void Got_NameAndColor(UINT8 **cp, INT32 playernum)
kick = true; kick = true;
// availabilities // availabilities
for (s = 0; s < MAXSKINS; s++) for (s = 0; s < numskins; s++)
{ {
if (!skins[s].availability && (p->availabilities & (1 << s))) if (!skins[s].availability && in_bit_array(p->availabilities, s))
{ {
kick = true; kick = true;
break; break;
@ -4278,7 +4281,8 @@ void Command_ExitGame_f(void)
for (i = 0; i < MAXPLAYERS; i++) for (i = 0; i < MAXPLAYERS; i++)
CL_ClearPlayer(i); CL_ClearPlayer(i);
players[consoleplayer].availabilities = players[1].availabilities = R_GetSkinAvailabilities(); // players[1] is supposed to be for 2p R_GetSkinAvailabilities(&players[consoleplayer].availabilities);
R_GetSkinAvailabilities(&players[1].availabilities); // players[1] is supposed to be for 2p
splitscreen = false; splitscreen = false;
SplitScreen_OnChange(); SplitScreen_OnChange();

View file

@ -379,7 +379,7 @@ typedef struct player_s
UINT16 skincolor; UINT16 skincolor;
INT32 skin; INT32 skin;
UINT32 availabilities; bitarray_t *availabilities;
UINT32 score; // player score UINT32 score; // player score
fixed_t dashspeed; // dashing speed fixed_t dashspeed; // dashing speed

View file

@ -162,23 +162,20 @@ void clear_levels(void)
static boolean findFreeSlot(INT32 *num) static boolean findFreeSlot(INT32 *num)
{ {
// Send the character select entry to a free slot. if (description)
while (*num < MAXSKINS && (description[*num].used)) {
*num = *num+1; // Send the character select entry to a free slot.
while (*num < numdescriptions && (description[*num].used))
(*num)++;
}
// No more free slots. :( // No more free slots.
if (*num >= MAXSKINS) if (*num >= MAXCHARACTERSLOTS)
return false; return false;
else if (*num >= numdescriptions)
M_InitCharacterTables((*num) + 1);
// Redesign your logo. (See M_DrawSetupChoosePlayerMenu in m_menu.c...) // Found one!
description[*num].picname[0] = '\0';
description[*num].nametag[0] = '\0';
description[*num].displayname[0] = '\0';
description[*num].oppositecolor = SKINCOLOR_NONE;
description[*num].tagtextcolor = SKINCOLOR_NONE;
description[*num].tagoutlinecolor = SKINCOLOR_NONE;
// Found one! ^_^
return (description[*num].used = true); return (description[*num].used = true);
} }
@ -891,7 +888,7 @@ void readspriteinfo(MYFILE *f, INT32 num, boolean sprite2)
INT32 value; INT32 value;
#endif #endif
char *lastline; char *lastline;
INT32 skinnumbers[MAXSKINS]; INT32 *skinnumbers = NULL;
INT32 foundskins = 0; INT32 foundskins = 0;
// allocate a spriteinfo // allocate a spriteinfo
@ -980,6 +977,8 @@ void readspriteinfo(MYFILE *f, INT32 num, boolean sprite2)
break; break;
} }
if (skinnumbers == NULL)
skinnumbers = Z_Malloc(sizeof(INT32) * numskins, PU_STATIC, NULL);
skinnumbers[foundskins] = skinnum; skinnumbers[foundskins] = skinnum;
foundskins++; foundskins++;
} }
@ -1043,6 +1042,8 @@ void readspriteinfo(MYFILE *f, INT32 num, boolean sprite2)
Z_Free(s); Z_Free(s);
Z_Free(info); Z_Free(info);
if (skinnumbers)
Z_Free(skinnumbers);
} }
void readsprite2(MYFILE *f, INT32 num) void readsprite2(MYFILE *f, INT32 num)

View file

@ -241,7 +241,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, boolean mainfile)
i = 0; i = 0;
if (fastcmp(word, "CHARACTER")) if (fastcmp(word, "CHARACTER"))
{ {
if (i >= 0 && i < 32) if (i >= 0 && i < MAXCHARACTERSLOTS)
readPlayer(f, i); readPlayer(f, i);
else else
{ {

View file

@ -220,7 +220,8 @@ extern char logfilename[1024];
// NOTE: it needs more than this to increase the number of players... // NOTE: it needs more than this to increase the number of players...
#define MAXPLAYERS 32 #define MAXPLAYERS 32
#define MAXSKINS 32 #define MAXSKINS 256
#define MAXCHARACTERSLOTS (MAXSKINS * 2)
#define PLAYERSMASK (MAXPLAYERS-1) #define PLAYERSMASK (MAXPLAYERS-1)
#define MAXPLAYERNAME 21 #define MAXPLAYERNAME 21

View file

@ -2486,7 +2486,7 @@ void G_PlayerReborn(INT32 player, boolean betweenmaps)
UINT8 mare; UINT8 mare;
UINT16 skincolor; UINT16 skincolor;
INT32 skin; INT32 skin;
UINT32 availabilities; bitarray_t *availabilities;
tic_t jointime; tic_t jointime;
tic_t quittime; tic_t quittime;
boolean spectator; boolean spectator;

View file

@ -71,7 +71,7 @@
#endif #endif
md2_t md2_models[NUMSPRITES]; md2_t md2_models[NUMSPRITES];
md2_t md2_playermodels[MAXSKINS]; md2_t *md2_playermodels = NULL;
/* /*
@ -490,7 +490,11 @@ void HWR_InitModels(void)
size_t prefixlen; size_t prefixlen;
CONS_Printf("HWR_InitModels()...\n"); CONS_Printf("HWR_InitModels()...\n");
for (s = 0; s < MAXSKINS; s++)
if (numskins && md2_playermodels == NULL)
md2_playermodels = Z_Malloc(sizeof(md2_t), PU_STATIC, NULL);
for (s = 0; s < numskins; s++)
{ {
md2_playermodels[s].scale = -1.0f; md2_playermodels[s].scale = -1.0f;
md2_playermodels[s].model = NULL; md2_playermodels[s].model = NULL;
@ -501,6 +505,7 @@ void HWR_InitModels(void)
md2_playermodels[s].notfound = true; md2_playermodels[s].notfound = true;
md2_playermodels[s].error = false; md2_playermodels[s].error = false;
} }
for (i = 0; i < NUMSPRITES; i++) for (i = 0; i < NUMSPRITES; i++)
{ {
md2_models[i].scale = -1.0f; md2_models[i].scale = -1.0f;
@ -561,7 +566,7 @@ void HWR_InitModels(void)
addskinmodel: addskinmodel:
// add player model // add player model
for (s = 0; s < MAXSKINS; s++) for (s = 0; s < numskins; s++)
{ {
if (stricmp(skinname, skins[s].name) == 0) if (stricmp(skinname, skins[s].name) == 0)
{ {
@ -581,7 +586,7 @@ modelfound:
fclose(f); fclose(f);
} }
void HWR_AddPlayerModel(int skin) // For skins that were added after startup void HWR_AddPlayerModel(INT32 skin) // For skins that were added after startup
{ {
FILE *f; FILE *f;
char name[24], filename[32]; char name[24], filename[32];
@ -608,6 +613,9 @@ void HWR_AddPlayerModel(int skin) // For skins that were added after startup
} }
} }
// realloc player models table
md2_playermodels = Z_Realloc(md2_playermodels, sizeof(md2_t) * numskins, PU_STATIC, NULL);
// length of the player model prefix // length of the player model prefix
prefixlen = strlen(PLAYERMODELPREFIX); prefixlen = strlen(PLAYERMODELPREFIX);

View file

@ -37,7 +37,7 @@ typedef struct
} md2_t; } md2_t;
extern md2_t md2_models[NUMSPRITES]; extern md2_t md2_models[NUMSPRITES];
extern md2_t md2_playermodels[MAXSKINS]; extern md2_t *md2_playermodels;
void HWR_InitModels(void); void HWR_InitModels(void);
void HWR_AddPlayerModel(INT32 skin); void HWR_AddPlayerModel(INT32 skin);

View file

@ -10,6 +10,7 @@
#include "../doomdef.h" #include "../doomdef.h"
#include "../doomtype.h" #include "../doomtype.h"
#include "../info.h" #include "../info.h"
#include "../r_skins.h"
#include "../z_zone.h" #include "../z_zone.h"
#include "hw_model.h" #include "hw_model.h"
#include "hw_md2load.h" #include "hw_md2load.h"
@ -238,7 +239,7 @@ void HWR_ReloadModels(void)
size_t i; size_t i;
INT32 s; INT32 s;
for (s = 0; s < MAXSKINS; s++) for (s = 0; s < numskins; s++)
{ {
if (md2_playermodels[s].model) if (md2_playermodels[s].model)
LoadModelSprite2(md2_playermodels[s].model); LoadModelSprite2(md2_playermodels[s].model);

View file

@ -16,6 +16,7 @@
#include "d_player.h" #include "d_player.h"
#include "g_game.h" #include "g_game.h"
#include "p_local.h" #include "p_local.h"
#include "r_skins.h"
#include "lua_script.h" #include "lua_script.h"
#include "lua_libs.h" #include "lua_libs.h"
@ -161,7 +162,7 @@ static int player_get(lua_State *L)
else if (fastcmp(field,"skin")) else if (fastcmp(field,"skin"))
lua_pushinteger(L, plr->skin); lua_pushinteger(L, plr->skin);
else if (fastcmp(field,"availabilities")) else if (fastcmp(field,"availabilities"))
lua_pushinteger(L, plr->availabilities); lua_pushinteger(L, R_GetAvailabilitiesBits(plr->availabilities));
else if (fastcmp(field,"score")) else if (fastcmp(field,"score"))
lua_pushinteger(L, plr->score); lua_pushinteger(L, plr->score);
else if (fastcmp(field,"dashspeed")) else if (fastcmp(field,"dashspeed"))

View file

@ -285,7 +285,8 @@ void M_SilentUpdateUnlockablesAndEmblems(void)
unlockables[i].unlocked = M_Achieved(unlockables[i].conditionset - 1); unlockables[i].unlocked = M_Achieved(unlockables[i].conditionset - 1);
} }
players[consoleplayer].availabilities = players[1].availabilities = R_GetSkinAvailabilities(); // players[1] is supposed to be for 2p R_GetSkinAvailabilities(&players[consoleplayer].availabilities);
R_GetSkinAvailabilities(&players[1].availabilities); // players[1] is supposed to be for 2p
} }
// Emblem unlocking shit // Emblem unlocking shit

View file

@ -126,7 +126,9 @@ M_waiting_mode_t m_waiting_mode = M_NOT_WAITING;
const char *quitmsg[NUM_QUITMESSAGES]; const char *quitmsg[NUM_QUITMESSAGES];
// Stuff for customizing the player select screen Tails 09-22-2003 // Stuff for customizing the player select screen Tails 09-22-2003
description_t description[MAXSKINS]; description_t *description = NULL;
INT32 numdescriptions = 0;
INT16 char_on = -1, startchar = 0; INT16 char_on = -1, startchar = 0;
static char *char_notes = NULL; static char *char_notes = NULL;
@ -255,7 +257,7 @@ static void M_ConfirmTeamScramble(INT32 choice);
static void M_ConfirmTeamChange(INT32 choice); static void M_ConfirmTeamChange(INT32 choice);
static void M_SecretsMenu(INT32 choice); static void M_SecretsMenu(INT32 choice);
static void M_SetupChoosePlayer(INT32 choice); static void M_SetupChoosePlayer(INT32 choice);
static UINT8 M_SetupChoosePlayerDirect(INT32 choice); static UINT16 M_SetupChoosePlayerDirect(INT32 choice);
static void M_QuitSRB2(INT32 choice); static void M_QuitSRB2(INT32 choice);
menu_t SP_MainDef, OP_MainDef; menu_t SP_MainDef, OP_MainDef;
menu_t MISC_ScrambleTeamDef, MISC_ChangeTeamDef; menu_t MISC_ScrambleTeamDef, MISC_ChangeTeamDef;
@ -3970,24 +3972,32 @@ void M_Init(void)
#endif #endif
} }
void M_InitCharacterTables(void) static void M_InitCharacterDescription(INT32 i)
{ {
UINT8 i;
// Setup description table // Setup description table
for (i = 0; i < MAXSKINS; i++) description_t *desc = &description[i];
{ desc->picname[0] = '\0';
description[i].used = false; desc->nametag[0] = '\0';
strcpy(description[i].notes, "???"); desc->skinname[0] = '\0';
strcpy(description[i].picname, ""); desc->displayname[0] = '\0';
strcpy(description[i].nametag, ""); desc->prev = desc->next = 0;
strcpy(description[i].skinname, ""); desc->charpic = NULL;
strcpy(description[i].displayname, ""); desc->namepic = NULL;
description[i].prev = description[i].next = 0; desc->oppositecolor = SKINCOLOR_NONE;
description[i].charpic = NULL; desc->tagtextcolor = SKINCOLOR_NONE;
description[i].namepic = NULL; desc->tagoutlinecolor = SKINCOLOR_NONE;
description[i].oppositecolor = description[i].tagtextcolor = description[i].tagoutlinecolor = 0; strcpy(desc->notes, "???");
} }
void M_InitCharacterTables(INT32 num)
{
INT32 i = numdescriptions;
description = Z_Realloc(description, sizeof(description_t) * num, PU_STATIC, NULL);
numdescriptions = num;
for (; i < numdescriptions; i++)
M_InitCharacterDescription(i);
} }
// ========================================================================== // ==========================================================================
@ -4981,7 +4991,7 @@ static void M_PatchSkinNameTable(void)
for (j = 0; j < MAXSKINS; j++) for (j = 0; j < MAXSKINS; j++)
{ {
if (skins[j].name[0] != '\0' && R_SkinUsable(-1, j)) if (j < numskins && skins[j].name[0] != '\0' && R_SkinUsable(-1, j))
{ {
skins_cons_t[j].strvalue = skins[j].realname; skins_cons_t[j].strvalue = skins[j].realname;
skins_cons_t[j].value = j+1; skins_cons_t[j].value = j+1;
@ -8961,64 +8971,67 @@ static void M_CacheCharacterSelectEntry(INT32 i, INT32 skinnum)
description[i].namepic = W_CachePatchName(description[i].nametag, PU_PATCH); description[i].namepic = W_CachePatchName(description[i].nametag, PU_PATCH);
} }
static UINT8 M_SetupChoosePlayerDirect(INT32 choice) static UINT16 M_SetupChoosePlayerDirect(INT32 choice)
{ {
INT32 skinnum; INT32 skinnum;
UINT8 i; UINT16 i;
UINT8 firstvalid = 255, lastvalid = 255; UINT16 firstvalid = 65535, lastvalid = 65535;
boolean allowed = false; boolean allowed = false;
char *and;
(void)choice; (void)choice;
if (!mapheaderinfo[startmap-1] || mapheaderinfo[startmap-1]->forcecharacter[0] == '\0') if (!mapheaderinfo[startmap-1] || mapheaderinfo[startmap-1]->forcecharacter[0] == '\0')
{ {
for (i = 0; i < MAXSKINS; i++) // Handle charsels, availability, and unlocks. for (i = 0; i < numdescriptions; i++) // Handle charsels, availability, and unlocks.
{ {
if (description[i].used) // If the character's disabled through SOC, there's nothing we can do for it. char *and;
// If the character's disabled through SOC, there's nothing we can do for it.
if (!description[i].used)
continue;
and = strchr(description[i].skinname, '&');
if (and)
{ {
and = strchr(description[i].skinname, '&'); char firstskin[SKINNAMESIZE+1];
if (and) if (mapheaderinfo[startmap-1] && mapheaderinfo[startmap-1]->typeoflevel & TOL_NIGHTS) // skip tagteam characters for NiGHTS levels
{ continue;
char firstskin[SKINNAMESIZE+1]; strncpy(firstskin, description[i].skinname, (and - description[i].skinname));
if (mapheaderinfo[startmap-1] && mapheaderinfo[startmap-1]->typeoflevel & TOL_NIGHTS) // skip tagteam characters for NiGHTS levels firstskin[(and - description[i].skinname)] = '\0';
continue; description[i].skinnum[0] = R_SkinAvailable(firstskin);
strncpy(firstskin, description[i].skinname, (and - description[i].skinname)); description[i].skinnum[1] = R_SkinAvailable(and+1);
firstskin[(and - description[i].skinname)] = '\0'; }
description[i].skinnum[0] = R_SkinAvailable(firstskin); else
description[i].skinnum[1] = R_SkinAvailable(and+1); {
} description[i].skinnum[0] = R_SkinAvailable(description[i].skinname);
description[i].skinnum[1] = -1;
}
skinnum = description[i].skinnum[0];
if ((skinnum != -1) && (R_SkinUsable(-1, skinnum)))
{
// Handling order.
if (firstvalid == 65535)
firstvalid = i;
else else
{ {
description[i].skinnum[0] = R_SkinAvailable(description[i].skinname); description[i].prev = lastvalid;
description[i].skinnum[1] = -1; description[lastvalid].next = i;
} }
skinnum = description[i].skinnum[0]; lastvalid = i;
if ((skinnum != -1) && (R_SkinUsable(-1, skinnum)))
{
// Handling order.
if (firstvalid == 255)
firstvalid = i;
else
{
description[i].prev = lastvalid;
description[lastvalid].next = i;
}
lastvalid = i;
if (i == char_on) if (i == char_on)
allowed = true; allowed = true;
M_CacheCharacterSelectEntry(i, skinnum); M_CacheCharacterSelectEntry(i, skinnum);
}
// else -- Technically, character select icons without corresponding skins get bundled away behind this too. Sucks to be them.
} }
// else -- Technically, character select icons without corresponding skins get bundled away behind this too. Sucks to be them.
} }
} }
if (firstvalid == lastvalid) // We're being forced into a specific character, so might as well just skip it. if (firstvalid == lastvalid) // We're being forced into a specific character, so might as well just skip it.
{
return firstvalid; return firstvalid;
}
// One last bit of order we can't do in the iteration above. // One last bit of order we can't do in the iteration above.
description[firstvalid].prev = lastvalid; description[firstvalid].prev = lastvalid;
@ -9027,7 +9040,7 @@ static UINT8 M_SetupChoosePlayerDirect(INT32 choice)
if (!allowed) if (!allowed)
{ {
char_on = firstvalid; char_on = firstvalid;
if (startchar > 0 && startchar < MAXSKINS) if (startchar > 0 && startchar < numdescriptions)
{ {
INT16 workchar = startchar; INT16 workchar = startchar;
while (workchar--) while (workchar--)
@ -9035,13 +9048,13 @@ static UINT8 M_SetupChoosePlayerDirect(INT32 choice)
} }
} }
return MAXSKINS; return MAXCHARACTERSLOTS;
} }
static void M_SetupChoosePlayer(INT32 choice) static void M_SetupChoosePlayer(INT32 choice)
{ {
UINT8 skinset = M_SetupChoosePlayerDirect(choice); UINT16 skinset = M_SetupChoosePlayerDirect(choice);
if (skinset != MAXSKINS) if (skinset != MAXCHARACTERSLOTS)
{ {
M_ChoosePlayer(skinset); M_ChoosePlayer(skinset);
return; return;
@ -9362,7 +9375,7 @@ static void M_ChoosePlayer(INT32 choice)
UINT8 skinnum; UINT8 skinnum;
// skip this if forcecharacter or no characters available // skip this if forcecharacter or no characters available
if (choice == 255) if (choice == 65535)
{ {
skinnum = botskin = 0; skinnum = botskin = 0;
botingame = false; botingame = false;
@ -10431,7 +10444,7 @@ static void M_MarathonLiveEventBackup(INT32 choice)
// Going to Marathon menu... // Going to Marathon menu...
static void M_Marathon(INT32 choice) static void M_Marathon(INT32 choice)
{ {
UINT8 skinset; UINT16 skinset;
INT32 mapnum = 0; INT32 mapnum = 0;
if (choice != -1 && FIL_FileExists(liveeventbackup)) if (choice != -1 && FIL_FileExists(liveeventbackup))
@ -10454,7 +10467,7 @@ static void M_Marathon(INT32 choice)
skinset = M_SetupChoosePlayerDirect(-1); skinset = M_SetupChoosePlayerDirect(-1);
SP_MarathonMenu[marathonplayer].status = (skinset == MAXSKINS) ? IT_KEYHANDLER|IT_STRING : IT_NOTHING|IT_DISABLED; SP_MarathonMenu[marathonplayer].status = (skinset == MAXCHARACTERSLOTS) ? IT_KEYHANDLER|IT_STRING : IT_NOTHING|IT_DISABLED;
while (mapnum < NUMMAPS) while (mapnum < NUMMAPS)
{ {

View file

@ -200,8 +200,8 @@ void M_Drawer(void);
// Called by D_SRB2Main, loads the config file. // Called by D_SRB2Main, loads the config file.
void M_Init(void); void M_Init(void);
// Called by D_SRB2Main also, sets up the playermenu and description tables. // Called by deh_soc.c, sets up the playermenu and description tables.
void M_InitCharacterTables(void); void M_InitCharacterTables(INT32 num);
// Called by intro code to force menu up upon a keypress, // Called by intro code to force menu up upon a keypress,
// does nothing if menu is already up. // does nothing if menu is already up.
@ -431,7 +431,8 @@ typedef struct
INT32 gamemap; INT32 gamemap;
} saveinfo_t; } saveinfo_t;
extern description_t description[MAXSKINS]; extern description_t *description;
extern INT32 numdescriptions;
extern consvar_t cv_showfocuslost; extern consvar_t cv_showfocuslost;
extern consvar_t cv_newgametype, cv_nextmap, cv_chooseskin, cv_serversort; extern consvar_t cv_newgametype, cv_nextmap, cv_chooseskin, cv_serversort;

View file

@ -139,7 +139,7 @@ static void P_NetArchivePlayers(void)
WRITEUINT8(save_p, players[i].skincolor); WRITEUINT8(save_p, players[i].skincolor);
WRITEINT32(save_p, players[i].skin); WRITEINT32(save_p, players[i].skin);
WRITEUINT32(save_p, players[i].availabilities); WRITEMEM(save_p, players[i].availabilities, sizeof(bitarray_t) * numskins);
WRITEUINT32(save_p, players[i].score); WRITEUINT32(save_p, players[i].score);
WRITEFIXED(save_p, players[i].dashspeed); WRITEFIXED(save_p, players[i].dashspeed);
WRITESINT8(save_p, players[i].lives); WRITESINT8(save_p, players[i].lives);
@ -353,7 +353,7 @@ static void P_NetUnArchivePlayers(void)
players[i].skincolor = READUINT8(save_p); players[i].skincolor = READUINT8(save_p);
players[i].skin = READINT32(save_p); players[i].skin = READINT32(save_p);
players[i].availabilities = READUINT32(save_p); READMEM(save_p, players[i].availabilities, sizeof(bitarray_t) * numskins);
players[i].score = READUINT32(save_p); players[i].score = READUINT32(save_p);
players[i].dashspeed = READFIXED(save_p); // dashing speed players[i].dashspeed = READFIXED(save_p); // dashing speed
players[i].lives = READSINT8(save_p); players[i].lives = READSINT8(save_p);

View file

@ -2,7 +2,7 @@
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1993-1996 by id Software, Inc.
// Copyright (C) 2005-2009 by Andrey "entryway" Budko. // Copyright (C) 2005-2009 by Andrey "entryway" Budko.
// Copyright (C) 2018-2020 by Jaime "Lactozilla" Passos. // Copyright (C) 2018-2021 by Jaime "Lactozilla" Passos.
// Copyright (C) 2019-2020 by Sonic Team Junior. // Copyright (C) 2019-2020 by Sonic Team Junior.
// //
// This program is free software distributed under the // This program is free software distributed under the
@ -1494,7 +1494,7 @@ static void R_ParseSpriteInfo(boolean spr2)
spritenum_t sprnum = NUMSPRITES; spritenum_t sprnum = NUMSPRITES;
playersprite_t spr2num = NUMPLAYERSPRITES; playersprite_t spr2num = NUMPLAYERSPRITES;
INT32 i; INT32 i;
INT32 skinnumbers[MAXSKINS]; INT32 *skinnumbers = NULL;
INT32 foundskins = 0; INT32 foundskins = 0;
// Sprite name // Sprite name
@ -1592,6 +1592,8 @@ static void R_ParseSpriteInfo(boolean spr2)
if (skinnum == -1) if (skinnum == -1)
I_Error("Error parsing SPRTINFO lump: Unknown skin \"%s\"", skinName); I_Error("Error parsing SPRTINFO lump: Unknown skin \"%s\"", skinName);
if (skinnumbers == NULL)
skinnumbers = Z_Malloc(sizeof(INT32) * numskins, PU_STATIC, NULL);
skinnumbers[foundskins] = skinnum; skinnumbers[foundskins] = skinnum;
foundskins++; foundskins++;
} }
@ -1630,8 +1632,11 @@ static void R_ParseSpriteInfo(boolean spr2)
{ {
I_Error("Error parsing SPRTINFO lump: Expected \"{\" for sprite \"%s\", got \"%s\"",newSpriteName,sprinfoToken); I_Error("Error parsing SPRTINFO lump: Expected \"{\" for sprite \"%s\", got \"%s\"",newSpriteName,sprinfoToken);
} }
Z_Free(sprinfoToken); Z_Free(sprinfoToken);
Z_Free(info); Z_Free(info);
if (skinnumbers)
Z_Free(skinnumbers);
} }
// //

View file

@ -18,6 +18,7 @@
#include "st_stuff.h" #include "st_stuff.h"
#include "w_wad.h" #include "w_wad.h"
#include "z_zone.h" #include "z_zone.h"
#include "m_menu.h"
#include "m_misc.h" #include "m_misc.h"
#include "info.h" // spr2names #include "info.h" // spr2names
#include "i_video.h" // rendermode #include "i_video.h" // rendermode
@ -32,13 +33,7 @@
#endif #endif
INT32 numskins = 0; INT32 numskins = 0;
skin_t skins[MAXSKINS]; skin_t *skins = NULL;
// FIXTHIS: don't work because it must be inistilised before the config load
//#define SKINVALUES
#ifdef SKINVALUES
CV_PossibleValue_t skin_cons_t[MAXSKINS+1];
#endif
// //
// P_GetSkinSprite2 // P_GetSkinSprite2
@ -160,30 +155,37 @@ static void Sk_SetDefaultValue(skin_t *skin)
// //
void R_InitSkins(void) void R_InitSkins(void)
{ {
#ifdef SKINVALUES
INT32 i;
for (i = 0; i <= MAXSKINS; i++)
{
skin_cons_t[i].value = 0;
skin_cons_t[i].strvalue = NULL;
}
#endif
// no default skin! // no default skin!
numskins = 0; numskins = 0;
} }
UINT32 R_GetSkinAvailabilities(void) void R_GetSkinAvailabilities(bitarray_t **response)
{
INT32 s;
if (*response == NULL)
(*response) = Z_Calloc(sizeof(bitarray_t) * numskins, PU_STATIC, NULL);
for (s = 0; s < numskins; s++)
{
if (skins[s].availability && unlockables[skins[s].availability - 1].unlocked)
set_bit_array((*response), s);
else
unset_bit_array((*response), s);
}
}
UINT32 R_GetAvailabilitiesBits(bitarray_t *availabilities)
{ {
INT32 s; INT32 s;
UINT32 response = 0; UINT32 response = 0;
for (s = 0; s < MAXSKINS; s++) for (s = 0; s < min(numskins, 32); s++)
{ {
if (skins[s].availability && unlockables[skins[s].availability - 1].unlocked) if (in_bit_array(availabilities, s))
response |= (1 << s); response |= (1 << s);
} }
return response; return response;
} }
@ -193,7 +195,7 @@ boolean R_SkinUsable(INT32 playernum, INT32 skinnum)
{ {
return ((skinnum == -1) // Simplifies things elsewhere, since there's already plenty of checks for less-than-0... return ((skinnum == -1) // Simplifies things elsewhere, since there's already plenty of checks for less-than-0...
|| (!skins[skinnum].availability) || (!skins[skinnum].availability)
|| (((netgame || multiplayer) && playernum != -1) ? (players[playernum].availabilities & (1 << skinnum)) : (unlockables[skins[skinnum].availability - 1].unlocked)) || (((netgame || multiplayer) && playernum != -1) ? (in_bit_array(players[playernum].availabilities, skinnum)) : (unlockables[skins[skinnum].availability - 1].unlocked))
|| (modeattacking) // If you have someone else's run you might as well take a look || (modeattacking) // If you have someone else's run you might as well take a look
|| (Playing() && (R_SkinAvailable(mapheaderinfo[gamemap-1]->forcecharacter) == skinnum)) // Force 1. || (Playing() && (R_SkinAvailable(mapheaderinfo[gamemap-1]->forcecharacter) == skinnum)) // Force 1.
|| (netgame && (cv_forceskin.value == skinnum)) // Force 2. || (netgame && (cv_forceskin.value == skinnum)) // Force 2.
@ -594,6 +596,7 @@ void R_AddSkins(UINT16 wadnum)
buf2[size] = '\0'; buf2[size] = '\0';
// set defaults // set defaults
skins = Z_Realloc(skins, sizeof(skin_t) * (numskins + 1), PU_STATIC, NULL);
skin = &skins[numskins]; skin = &skins[numskins];
Sk_SetDefaultValue(skin); Sk_SetDefaultValue(skin);
skin->wadnum = wadnum; skin->wadnum = wadnum;
@ -695,17 +698,13 @@ next_token:
if (!skin->availability) // Safe to print... if (!skin->availability) // Safe to print...
CONS_Printf(M_GetText("Added skin '%s'\n"), skin->name); CONS_Printf(M_GetText("Added skin '%s'\n"), skin->name);
#ifdef SKINVALUES
skin_cons_t[numskins].value = numskins; numskins++;
skin_cons_t[numskins].strvalue = skin->name;
#endif
#ifdef HWRENDER #ifdef HWRENDER
if (rendermode == render_opengl) if (rendermode == render_opengl)
HWR_AddPlayerModel(numskins); HWR_AddPlayerModel(numskins-1);
#endif #endif
numskins++;
} }
return; return;
} }

View file

@ -86,7 +86,7 @@ typedef struct
/// Externs /// Externs
extern INT32 numskins; extern INT32 numskins;
extern skin_t skins[MAXSKINS]; extern skin_t *skins;
/// Function prototypes /// Function prototypes
void R_InitSkins(void); void R_InitSkins(void);
@ -94,7 +94,8 @@ void R_InitSkins(void);
void SetPlayerSkin(INT32 playernum,const char *skinname); void SetPlayerSkin(INT32 playernum,const char *skinname);
void SetPlayerSkinByNum(INT32 playernum,INT32 skinnum); // Tails 03-16-2002 void SetPlayerSkinByNum(INT32 playernum,INT32 skinnum); // Tails 03-16-2002
boolean R_SkinUsable(INT32 playernum, INT32 skinnum); boolean R_SkinUsable(INT32 playernum, INT32 skinnum);
UINT32 R_GetSkinAvailabilities(void); void R_GetSkinAvailabilities(bitarray_t **response);
UINT32 R_GetAvailabilitiesBits(bitarray_t *availabilities);
INT32 R_SkinAvailable(const char *name); INT32 R_SkinAvailable(const char *name);
void R_PatchSkins(UINT16 wadnum); void R_PatchSkins(UINT16 wadnum);
void R_AddSkins(UINT16 wadnum); void R_AddSkins(UINT16 wadnum);

View file

@ -43,7 +43,7 @@ typedef enum
// free sfx for S_AddSoundFx() // free sfx for S_AddSoundFx()
#define NUMSFXFREESLOTS 1600 // Matches SOC Editor. #define NUMSFXFREESLOTS 1600 // Matches SOC Editor.
#define NUMSKINSFXSLOTS (MAXSKINS*NUMSKINSOUNDS) #define NUMSKINSFXSLOTS (128*NUMSKINSOUNDS)
// //
// SoundFX struct. // SoundFX struct.
@ -874,7 +874,7 @@ typedef enum
// free slots for S_AddSoundFx() at run-time -------------------- // free slots for S_AddSoundFx() at run-time --------------------
sfx_freeslot0, sfx_freeslot0,
// //
// ... 60 free sounds here ... // ... 1600 free sounds here ...
// //
sfx_lastfreeslot = sfx_freeslot0 + NUMSFXFREESLOTS-1, sfx_lastfreeslot = sfx_freeslot0 + NUMSFXFREESLOTS-1,
// end of freeslots --------------------------------------------- // end of freeslots ---------------------------------------------

View file

@ -50,8 +50,8 @@ UINT16 objectsdrawn = 0;
// STATUS BAR DATA // STATUS BAR DATA
// //
patch_t *faceprefix[MAXSKINS]; // face status patches patch_t **faceprefix; // face status patches
patch_t *superprefix[MAXSKINS]; // super face status patches patch_t **superprefix; // super face status patches
// ------------------------------------------ // ------------------------------------------
// status bar overlay // status bar overlay
@ -368,6 +368,17 @@ void ST_ReloadSkinFaceGraphics(void)
{ {
INT32 i; INT32 i;
if (faceprefix)
Z_Free(faceprefix);
if (superprefix)
Z_Free(superprefix);
if (!numskins)
return;
faceprefix = Z_Malloc(sizeof(patch_t *) * numskins, PU_STATIC, NULL);
superprefix = Z_Malloc(sizeof(patch_t *) * numskins, PU_STATIC, NULL);
for (i = 0; i < numskins; i++) for (i = 0; i < numskins; i++)
ST_LoadFaceGraphics(i); ST_LoadFaceGraphics(i);
} }

View file

@ -42,7 +42,7 @@ void ST_UnloadGraphics(void);
void ST_LoadGraphics(void); void ST_LoadGraphics(void);
// face load graphics, called when skin changes // face load graphics, called when skin changes
void ST_LoadFaceGraphics(INT32 playernum); void ST_LoadFaceGraphics(INT32 skinnum);
void ST_ReloadSkinFaceGraphics(void); void ST_ReloadSkinFaceGraphics(void);
void ST_doPaletteStuff(void); void ST_doPaletteStuff(void);
@ -76,8 +76,8 @@ extern patch_t *sboscore;
extern patch_t *sbotime; extern patch_t *sbotime;
extern patch_t *sbocolon; extern patch_t *sbocolon;
extern patch_t *sboperiod; extern patch_t *sboperiod;
extern patch_t *faceprefix[MAXSKINS]; // face status patches extern patch_t **faceprefix; // face status patches
extern patch_t *superprefix[MAXSKINS]; // super face status patches extern patch_t **superprefix; // super face status patches
extern patch_t *livesback; extern patch_t *livesback;
extern patch_t *stlivex; extern patch_t *stlivex;
extern patch_t *ngradeletters[7]; extern patch_t *ngradeletters[7];