UC_PASSWORD

Unlockable type that supports entering (case-insensitive) string
This commit is contained in:
toaster 2023-06-07 08:14:30 +01:00
parent f106d14d69
commit e162fffecf
4 changed files with 62 additions and 2 deletions

View file

@ -2585,6 +2585,13 @@ static void readcondition(UINT8 set, UINT32 id, char *word2)
//PARAMCHECK(1);
ty = UC_ADDON + offset;
}
else if (fastcmp(params[0], "PASSWORD"))
{
PARAMCHECK(1);
ty = UC_PASSWORD;
stringvar = Z_StrDup(params[1]);
re = -1;
}
else if ((offset=0) || fastcmp(params[0], "AND")
|| (++offset && fastcmp(params[0], "COMMA")))
{

View file

@ -844,6 +844,8 @@ boolean M_CheckCondition(condition_t *cn, player_t *player)
return true;
}
return false;
case UC_PASSWORD:
return (cn->stringvar == NULL);
// Just for string building
case UC_AND:
@ -1292,6 +1294,8 @@ static const char *M_GetConditionString(condition_t *cn)
if (gamedata->evercrashed)
return "launch \"Dr. Robotnik's Ring Racers\" again after a game crash";
return NULL;
case UC_PASSWORD:
return "enter a secret password";
case UC_AND:
return "&";
@ -1610,7 +1614,7 @@ char *M_BuildConditionSetString(UINT16 unlockid)
static boolean M_CheckUnlockConditions(player_t *player)
{
INT32 i;
UINT32 i;
conditionset_t *c;
boolean ret;
@ -1629,6 +1633,43 @@ static boolean M_CheckUnlockConditions(player_t *player)
return ret;
}
boolean M_ConditionInterpret(const char *password)
{
UINT32 i, j;
conditionset_t *c;
condition_t *cn;
for (i = 0; i < MAXCONDITIONSETS; ++i)
{
c = &conditionSets[i];
if (!c->numconditions || gamedata->achieved[i])
continue;
for (j = 0; j < c->numconditions; ++j)
{
cn = &c->condition[j];
if (cn->type != UC_PASSWORD)
continue;
if (cn->stringvar == NULL)
continue;
if (stricmp(cn->stringvar, password))
continue;
// Remove the password for this session.
Z_Free(cn->stringvar);
cn->stringvar = NULL;
return true;
}
}
return false;
}
boolean M_UpdateUnlockablesAndExtraEmblems(boolean loud, boolean doall)
{
UINT16 i = 0, response = 0, newkeys = 0;

View file

@ -55,6 +55,8 @@ typedef enum
UC_REPLAY, // Save a replay
UC_CRASH, // Hee ho !
UC_PASSWORD, // Type in something funny
// Just for string building
UC_AND,
UC_COMMA,
@ -333,6 +335,7 @@ void M_ClearStats(void);
boolean M_NotFreePlay(player_t *player);
// Updating conditions and unlockables
boolean M_ConditionInterpret(const char *password);
boolean M_CheckCondition(condition_t *cn, player_t *player);
boolean M_UpdateUnlockablesAndExtraEmblems(boolean loud, boolean doall);

View file

@ -173,8 +173,17 @@ void M_ExtrasTick(void)
if (menutyping.active == false && cv_dummyextraspassword.string[0] != '\0')
{
if (cht_Interpret(cv_dummyextraspassword.string) == true)
if (M_ConditionInterpret(cv_dummyextraspassword.string) == true)
{
if (M_UpdateUnlockablesAndExtraEmblems(true, true))
{
M_Challenges(0);
}
}
else if (cht_Interpret(cv_dummyextraspassword.string) == true)
{
M_InitExtras(-1);
}
CV_StealthSet(&cv_dummyextraspassword, "");
}