From 23faef24d7c1bb0fc4be7b4f7effc26c1786c0f1 Mon Sep 17 00:00:00 2001 From: toaster Date: Wed, 23 Sep 2020 23:46:54 +0100 Subject: [PATCH] * Introduce SPR2_XTRA for face graphics, since the current system is prone to plenty of conflicts with modders if you're not careful. * Fixed a bug where you'd see :nick: on the current character selection screen if you didn't have many skins loaded. * Fixed a bug where character skins loaded in PK3s would attempt to load every single lump of the PK3, even if it wasn't in the same subfolder as the original S_SKIN, as a sprite into the player struct. Could stand to be ported to vanilla. Requires new chars.kart, which was created using the help of the indev 2.2-based Kartmaker update which will be available shortly. --- src/info.c | 1 + src/info.h | 1 + src/lua_skinlib.c | 25 ------------------------- src/m_menu.c | 7 +++---- src/r_skins.c | 39 ++++----------------------------------- src/r_skins.h | 1 - src/st_stuff.c | 27 ++++++++++++++++++++++----- src/st_stuff.h | 2 +- src/w_wad.c | 30 ++++++++++++++++++++++++++++++ src/w_wad.h | 2 ++ 10 files changed, 64 insertions(+), 71 deletions(-) diff --git a/src/info.c b/src/info.c index 17ea99c48..5cf83132d 100644 --- a/src/info.c +++ b/src/info.c @@ -742,6 +742,7 @@ char spr2names[NUMPLAYERSPRITES][5] = "SPIN", // Spinout "SQSH", // Squish "SIGN", // Finish signpost + "XTRA", // Three Faces of Darkness }; playersprite_t free_spr2 = SPR2_FIRSTFREESLOT; diff --git a/src/info.h b/src/info.h index 1f7235944..e90d117f4 100644 --- a/src/info.h +++ b/src/info.h @@ -1020,6 +1020,7 @@ typedef enum playersprite SPR2_SPIN, SPR2_SQSH, SPR2_SIGN, + SPR2_XTRA, SPR2_FIRSTFREESLOT, SPR2_LASTFREESLOT = 0x7f, NUMPLAYERSPRITES diff --git a/src/lua_skinlib.c b/src/lua_skinlib.c index 8fd6f6d62..c8da7f4d8 100644 --- a/src/lua_skinlib.c +++ b/src/lua_skinlib.c @@ -25,9 +25,6 @@ enum skin { skin_wadnum, skin_flags, skin_realname, - skin_facerank, - skin_facewant, - skin_facemmap, // SRB2kart skin_kartspeed, skin_kartweight, @@ -48,9 +45,6 @@ static const char *const skin_opt[] = { "wadnum", "flags", "realname", - "facerank", - "facewant", - "facemmap", "kartspeed", "kartweight", "followitem", @@ -69,7 +63,6 @@ static int skin_get(lua_State *L) { skin_t *skin = *((skin_t **)luaL_checkudata(L, 1, META_SKIN)); enum skin field = luaL_checkoption(L, 2, NULL, skin_opt); - INT32 i; // skins are always valid, only added, never removed I_Assert(skin != NULL); @@ -93,24 +86,6 @@ static int skin_get(lua_State *L) case skin_realname: lua_pushstring(L, skin->realname); break; - case skin_facerank: - for (i = 0; i < 8; i++) - if (!skin->facerank[i]) - break; - lua_pushlstring(L, skin->facerank, i); - break; - case skin_facewant: - for (i = 0; i < 8; i++) - if (!skin->facewant[i]) - break; - lua_pushlstring(L, skin->facewant, i); - break; - case skin_facemmap: - for (i = 0; i < 8; i++) - if (!skin->facemmap[i]) - break; - lua_pushlstring(L, skin->facemmap, i); - break; // SRB2kart case skin_kartspeed: lua_pushinteger(L, skin->kartspeed); diff --git a/src/m_menu.c b/src/m_menu.c index a974f4361..2f38aee17 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -5601,7 +5601,7 @@ static void DrawReplayHutReplayInfo(void) // Lat: 08/06/2020: For some reason missing skins have their value set to 255 (don't even ask me why I didn't write this) // and for an even STRANGER reason this passes the first check below, so we're going to make sure that the skin here ISN'T 255 before we do anything stupid. - if (demolist[dir_on[menudepthleft]].standings[0].skin != 0xFF && W_CheckNumForName(skins[demolist[dir_on[menudepthleft]].standings[0].skin].facewant) != LUMPERROR) + if (demolist[dir_on[menudepthleft]].standings[0].skin != 0xFF) { patch = faceprefix[demolist[dir_on[menudepthleft]].standings[0].skin][FACE_WANTED]; colormap = R_GetTranslationColormap( @@ -5803,7 +5803,7 @@ static void M_DrawReplayStartMenu(void) // Lat: 08/06/2020: For some reason missing skins have their value set to 255 (don't even ask me why I didn't write this) // and for an even STRANGER reason this passes the first check below, so we're going to make sure that the skin here ISN'T 255 before we do anything stupid. - if (demolist[dir_on[menudepthleft]].standings[i].skin != 0xFF && W_CheckNumForName(skins[demolist[dir_on[menudepthleft]].standings[i].skin].facerank) != LUMPERROR) + if (demolist[dir_on[menudepthleft]].standings[i].skin != 0xFF) { patch = faceprefix[demolist[dir_on[menudepthleft]].standings[i].skin][FACE_RANK]; colormap = R_GetTranslationColormap( @@ -7795,7 +7795,6 @@ void M_DrawTimeAttackMenu(void) y = currentMenu->y; // Character face! - if (W_CheckNumForName(skins[cv_chooseskin.value-1].facewant) != LUMPERROR) { UINT8 *colormap = R_GetTranslationColormap(cv_chooseskin.value-1, cv_playercolor[0].value, GTC_MENUCACHE); V_DrawMappedPatch(BASEVIDWIDTH-x - SHORT(faceprefix[cv_chooseskin.value-1][FACE_WANTED]->width), y, 0, faceprefix[cv_chooseskin.value-1][FACE_WANTED], colormap); @@ -9554,7 +9553,7 @@ static void M_DrawSetupMultiPlayerMenu(void) { const INT32 icons = 4; INT32 k = -icons; - INT16 col = setupm_fakeskin - icons; + INT16 col = (setupm_fakeskin - icons) % numskins; INT32 x = BASEVIDWIDTH/2 - ((icons+1)*24) - 4; fixed_t scale = FRACUNIT/2; INT32 offx = 8, offy = 8; diff --git a/src/r_skins.c b/src/r_skins.c index 3cdfeb649..3509551d1 100644 --- a/src/r_skins.c +++ b/src/r_skins.c @@ -109,9 +109,6 @@ static void Sk_SetDefaultValue(skin_t *skin) skin->flags = 0; strcpy(skin->realname, "Someone"); - strncpy(skin->facerank, "PLAYRANK", 9); - strncpy(skin->facewant, "PLAYWANT", 9); - strncpy(skin->facemmap, "PLAYMMAP", 9); skin->starttranscolor = 96; skin->prefcolor = SKINCOLOR_GREEN; skin->supercolor = SKINCOLOR_SUPERGOLD1; @@ -404,6 +401,8 @@ static void R_LoadSkinSprites(UINT16 wadnum, UINT16 *lump, UINT16 *lastlump, ski *lastlump = W_CheckNumForNamePwad("S_END",wadnum,*lump); // stop at S_END // old wadding practices die hard -- stop at S_SKIN (or P_SKIN) or S_START if they come before S_END. + newlastlump = W_FindNextEmptyInPwad(wadnum,*lump); + if (newlastlump < *lastlump) *lastlump = newlastlump; newlastlump = W_CheckForSkinMarkerInPwad(wadnum,*lump); if (newlastlump < *lastlump) *lastlump = newlastlump; newlastlump = W_CheckForPatchSkinMarkerInPwad(wadnum,*lump); @@ -411,7 +410,7 @@ static void R_LoadSkinSprites(UINT16 wadnum, UINT16 *lump, UINT16 *lastlump, ski newlastlump = W_CheckNumForNamePwad("S_START",wadnum,*lump); if (newlastlump < *lastlump) *lastlump = newlastlump; - // ...and let's handle super, too + /*// ...and let's handle super, too newlastlump = W_CheckNumForNamePwad("S_SUPER",wadnum,*lump); if (newlastlump < *lastlump) { @@ -422,7 +421,7 @@ static void R_LoadSkinSprites(UINT16 wadnum, UINT16 *lump, UINT16 *lastlump, ski newlastlump--; *lastlump = newlastlump; // okay, make the normal sprite set loading end there - } + }*/ // load all sprite sets we are aware of... for normal stuff. for (sprite2 = 0; sprite2 < free_spr2; sprite2++) @@ -629,21 +628,6 @@ void R_AddSkins(UINT16 wadnum) STRBUFCPY(skin->realname, value); SYMBOLCONVERT(skin->realname) } - else if (!stricmp(stoken, "facerank")) - { - strupr(value); - strncpy(skin->facerank, value, sizeof skin->facerank); - } - else if (!stricmp(stoken, "facewant")) - { - strupr(value); - strncpy(skin->facewant, value, sizeof skin->facewant); - } - else if (!stricmp(stoken, "facemmap")) - { - strupr(value); - strncpy(skin->facemmap, value, sizeof skin->facemmap); - } else if (!stricmp(stoken, "rivals")) { size_t len = strlen(value); @@ -799,21 +783,6 @@ void R_PatchSkins(UINT16 wadnum) STRBUFCPY(skin->realname, value); SYMBOLCONVERT(skin->realname) } - else if (!stricmp(stoken, "facerank")) - { - STRBUFCPY(skin->facerank, value); - SYMBOLCONVERT(skin->facerank) - } - else if (!stricmp(stoken, "facewant")) - { - STRBUFCPY(skin->facewant, value); - SYMBOLCONVERT(skin->facewant) - } - else if (!stricmp(stoken, "facemmap")) - { - STRBUFCPY(skin->facemmap, value); - SYMBOLCONVERT(skin->facemmap) - } else if (!stricmp(stoken, "rivals")) { size_t len = strlen(value); diff --git a/src/r_skins.h b/src/r_skins.h index b17da3198..4d90b19bf 100644 --- a/src/r_skins.h +++ b/src/r_skins.h @@ -37,7 +37,6 @@ typedef struct skinflags_t flags; char realname[SKINNAMESIZE+1]; // Display name for level completion. - char facerank[9], facewant[9], facemmap[9]; // Arbitrarily named patch lumps // SRB2kart UINT8 kartspeed; diff --git a/src/st_stuff.c b/src/st_stuff.c index 2bd86181d..d7bcb0744 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -366,11 +366,28 @@ void ST_LoadGraphics(void) } // made separate so that skins code can reload custom face graphics -void ST_LoadFaceGraphics(char *rankstr, char *wantstr, char *mmapstr, INT32 skinnum) +void ST_LoadFaceGraphics(INT32 skinnum) { - faceprefix[skinnum][FACE_RANK] = W_CachePatchName(rankstr, PU_HUDGFX); - faceprefix[skinnum][FACE_WANTED] = W_CachePatchName(wantstr, PU_HUDGFX); - faceprefix[skinnum][FACE_MINIMAP] = W_CachePatchName(mmapstr, PU_HUDGFX); +#define FACE_MAX (FACE_MINIMAP+1) + spritedef_t *sprdef = &skins[skinnum].sprites[SPR2_XTRA]; + spriteframe_t *sprframe; + UINT8 i = 0, maxer = min(sprdef->numframes, FACE_MAX); + while (i < maxer) + { + sprframe = &sprdef->spriteframes[i]; + faceprefix[skinnum][i] = W_CachePatchNum(sprframe->lumppat[0], PU_HUDGFX); + i++; + } + if (i < FACE_MAX) + { + patch_t *missing = W_CachePatchName("MISSING", PU_HUDGFX); + while (i < FACE_MAX) + { + faceprefix[skinnum][i] = missing; + i++; + } + } +#undef FACE_MAX } void ST_ReloadSkinFaceGraphics(void) @@ -378,7 +395,7 @@ void ST_ReloadSkinFaceGraphics(void) INT32 i; for (i = 0; i < numskins; i++) - ST_LoadFaceGraphics(skins[i].facerank, skins[i].facewant, skins[i].facemmap, i); + ST_LoadFaceGraphics(i); } static inline void ST_InitData(void) diff --git a/src/st_stuff.h b/src/st_stuff.h index 28b7f0eb4..e72a3b77a 100644 --- a/src/st_stuff.h +++ b/src/st_stuff.h @@ -48,7 +48,7 @@ void ST_UnloadGraphics(void); void ST_LoadGraphics(void); // face load graphics, called when skin changes -void ST_LoadFaceGraphics(char *rankstr, char *wantstr, char *mmapstr, INT32 playernum); +void ST_LoadFaceGraphics(INT32 playernum); void ST_ReloadSkinFaceGraphics(void); void ST_doPaletteStuff(void); diff --git a/src/w_wad.c b/src/w_wad.c index eeb4dd227..acf2790c2 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -921,6 +921,36 @@ const char *W_CheckNameForNum(lumpnum_t lumpnum) return W_CheckNameForNumPwad(WADFILENUM(lumpnum),LUMPNUM(lumpnum)); } +// +// wadid is a wad number +// (Used for sprites loading) +// +// 'startlump' is the lump number to start the search +// +UINT16 W_FindNextEmptyInPwad(UINT16 wad, UINT16 startlump) +{ + UINT16 i; + + if (!TestValidLump(wad,0)) + return INT16_MAX; + + // + // scan forward + // start at 'startlump', useful parameter when there are multiple + // resources with the same name + // + if (startlump < wadfiles[wad]->numlumps) + { + lumpinfo_t *lump_p = wadfiles[wad]->lumpinfo + startlump; + for (i = startlump; i < wadfiles[wad]->numlumps; i++, lump_p++) + if (!lump_p->size) + return i; + } + + // not found. + return INT16_MAX; +} + // // Same as the original, but checks in one pwad only. // wadid is a wad number diff --git a/src/w_wad.h b/src/w_wad.h index b1d3b55c3..4797f4afd 100644 --- a/src/w_wad.h +++ b/src/w_wad.h @@ -158,6 +158,8 @@ INT32 W_InitMultipleFiles(char **filenames, boolean addons); const char *W_CheckNameForNumPwad(UINT16 wad, UINT16 lump); const char *W_CheckNameForNum(lumpnum_t lumpnum); +UINT16 W_FindNextEmptyInPwad(UINT16 wad, UINT16 startlump); // checks only in one pwad + UINT16 W_CheckNumForNamePwad(const char *name, UINT16 wad, UINT16 startlump); // checks only in one pwad UINT16 W_CheckNumForLongNamePwad(const char *name, UINT16 wad, UINT16 startlump);