Some hacks added to forceskin to:

* support hidden characters
* take the skin->name, not the number
* display the skin->name in the menu

Also, minor tweaks to other things.
This commit is contained in:
toasterbabe 2016-07-12 14:40:20 +01:00
parent b5108afe16
commit 80a3d79d4d
4 changed files with 69 additions and 16 deletions

View File

@ -1159,7 +1159,12 @@ found:
var->value = (INT32)(d * FRACUNIT);
}
else
var->value = atoi(var->string);
{
if (var == &cv_forceskin)
var->value = R_SkinAvailable(var->string);
else
var->value = atoi(var->string);
}
finish:
// See the note above.
@ -1383,6 +1388,30 @@ void CV_StealthSet(consvar_t *var, const char *value)
CV_SetCVar(var, value, true);
}
/** Sets a numeric value to a variable, sometimes calling its callback
* function.
*
* \param var The variable.
* \param value The numeric value, converted to a string before setting.
* \param stealth Do we call the callback function or not?
*/
static void CV_SetValueMaybeStealth(consvar_t *var, INT32 value, boolean stealth)
{
char val[32];
if (var == &cv_forceskin) // Special handling.
{
if ((value < 0) || (value >= numskins))
sprintf(val, "None");
else
sprintf(val, "%s", skins[value].name);
}
else
sprintf(val, "%d", value);
CV_SetCVar(var, val, stealth);
}
/** Sets a numeric value to a variable without calling its callback
* function.
*
@ -1392,10 +1421,7 @@ void CV_StealthSet(consvar_t *var, const char *value)
*/
void CV_StealthSetValue(consvar_t *var, INT32 value)
{
char val[32];
sprintf(val, "%d", value);
CV_SetCVar(var, val, true);
CV_SetValueMaybeStealth(var, value, true);
}
// New wrapper for what used to be CV_Set()
@ -1413,10 +1439,7 @@ void CV_Set(consvar_t *var, const char *value)
*/
void CV_SetValue(consvar_t *var, INT32 value)
{
char val[32];
sprintf(val, "%d", value);
CV_SetCVar(var, val, false);
CV_SetValueMaybeStealth(var, value, false);
}
/** Adds a value to a console variable.
@ -1436,7 +1459,23 @@ void CV_AddValue(consvar_t *var, INT32 increment)
// count pointlimit better
if (var == &cv_pointlimit && (gametype == GT_MATCH))
increment *= 50;
newvalue = var->value + increment;
if (var == &cv_forceskin) // Special handling.
{
INT32 oldvalue = var->value;
newvalue = oldvalue;
do
{
newvalue += increment;
if (newvalue < -1)
newvalue = (numskins - 1);
else if (newvalue >= numskins)
newvalue = -1;
} while ((oldvalue != newvalue)
&& !(R_SkinUnlock(newvalue)));
}
else
newvalue = var->value + increment;
if (var->PossibleValue)
{

View File

@ -332,7 +332,7 @@ consvar_t cv_usemapnumlaps = {"usemaplaps", "Yes", CV_NETVAR, CV_YesNo, NULL, 0,
// log elemental hazards -- not a netvar, is local to current player
consvar_t cv_hazardlog = {"hazardlog", "Yes", 0, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_forceskin = {"forceskin", "-1", CV_NETVAR|CV_CALL|CV_CHEAT, NULL, ForceSkin_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_forceskin = {"forceskin", "None", CV_NETVAR|CV_CALL|CV_CHEAT, NULL, ForceSkin_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_downloading = {"downloading", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_allowexitlevel = {"allowexitlevel", "No", CV_NETVAR, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL};

View File

@ -433,7 +433,7 @@ static void readAnimTex(MYFILE *f, INT32 num)
static boolean findFreeSlot(INT32 *num)
{
// Send the character select entry to a free slot.
while (*num < 32 && PlayerMenu[*num].status != IT_DISABLED)
while (*num < 32 && !(PlayerMenu[*num].status & IT_DISABLED)) // Will overwrite hidden characters, but it works out. You can't unlock if you're adding extra characters anyways.
*num = *num+1;
// No more free slots. :(

View File

@ -18,6 +18,7 @@
#include "st_stuff.h"
#include "w_wad.h"
#include "z_zone.h"
#include "m_menu.h" // Player character select
#include "m_misc.h"
#include "i_video.h" // rendermode
#include "r_things.h"
@ -2335,11 +2336,17 @@ void R_InitSkins(void)
// warning don't use with an invalid skinnum
boolean R_SkinUnlock(INT32 skinnum)
{
return ((skins[skinnum].availability == 2) // SP/Coop is strict
return ((skinnum == -1) // Simplifies things elsewhere, since there's already plenty of checks for less-than-0...
|| (skins[skinnum].availability == 2) // SP/Coop is strict
|| (modeattacking) // If you have someone else's run you might as well take a look
|| ((netgame)
&& ((cv_forceskin.value == skinnum) // Forceskin is weak
|| (G_RingSlingerGametype() && (skins[skinnum].availability != 0))))); // Ringslinger is disciplined
&& ((dedicated) // Same reasoning as Command_Map_f - dedicated would be a nightmare otherwise
|| ((cv_forceskin.value == skinnum) // Forceskin is weak
|| (G_RingSlingerGametype() && (skins[skinnum].availability != 0)) // Ringslinger is disciplined
)
)
)
);
}
// returns true if the skin name is found (loaded from pwad)
@ -2348,6 +2355,9 @@ INT32 R_SkinAvailable(const char *name)
{
INT32 i;
if (stricmp("NONE",name) == 0)
return -1;
for (i = 0; i < numskins; i++)
{
// search in the skin list
@ -2628,7 +2638,10 @@ void R_AddSkins(UINT16 wadnum)
else if (!stricmp(stoken, "availability"))
#ifdef DEVELOP
{
PlayerMenu[R_SkinAvailable(skin->name)].status = (IT_DISABLED|IT_CENTER);
skin->availability = atoi(value);
}
#else
;
#endif
@ -2704,7 +2717,8 @@ next_token:
R_FlushTranslationColormapCache();
CONS_Printf(M_GetText("Added skin '%s'\n"), skin->name);
if (skin->availability == 2) // Safe to print...
CONS_Printf(M_GetText("Added skin '%s'\n"), skin->name);
#ifdef SKINVALUES
skin_cons_t[numskins].value = numskins;
skin_cons_t[numskins].strvalue = skin->name;