From b33597e225f82b5df3cd96b4ca63e36739862295 Mon Sep 17 00:00:00 2001 From: toaster Date: Sun, 24 Sep 2023 15:43:48 +0100 Subject: [PATCH] Beginnings of system for using Chao Keys on large tiles - M_UpdateChallengeGridExtraData: Register whether major unlock tiles have had every surrounding Challenge cleared (CHE_ALLCLEAR) - M_DrawChallengeTile: For locked tiles with CHE_ALLCLEAR, show a little dot (temporary drawer) --- src/k_menudraw.c | 6 ++++ src/m_cond.c | 74 ++++++++++++++++++++++++++++++++++++++---------- src/m_cond.h | 1 + 3 files changed, 66 insertions(+), 15 deletions(-) diff --git a/src/k_menudraw.c b/src/k_menudraw.c index 0083ae643..2f1a10d91 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -5224,6 +5224,12 @@ static void M_DrawChallengeTile(INT16 i, INT16 j, INT32 x, INT32 y, boolean hili colormap ); + if (challengesmenu.extradata[id].flags & CHE_ALLCLEAR) + { + // Temporary drawer for "key should be usable" + V_DrawFill(x + 5, y + 5, 2, 2, 255); + } + pat = missingpat; colormap = NULL; diff --git a/src/m_cond.c b/src/m_cond.c index eecc73ae6..51da95621 100644 --- a/src/m_cond.c +++ b/src/m_cond.c @@ -417,7 +417,16 @@ void M_UpdateChallengeGridExtraData(challengegridextradata_t *extradata) for (j = 0; j < CHALLENGEGRIDHEIGHT; j++) { id = (i * CHALLENGEGRIDHEIGHT) + j; - extradata[id].flags = CHE_NONE; + num = gamedata->challengegrid[id]; + if (num >= MAXUNLOCKABLES || unlockables[num].majorunlock == false) + { + extradata[id].flags = CHE_NONE; + continue; + } + + // We only do this for large tiles, to reduce the complexity + // of most standard tile challenge comparisons + extradata[id].flags = CHE_ALLCLEAR; } } @@ -468,12 +477,22 @@ void M_UpdateChallengeGridExtraData(challengegridextradata_t *extradata) if (extradata[id].flags == CHE_HINT) { + // CHE_ALLCLEAR has already been removed, + // and CHE_HINT has already been applied, + // so nothing more needs to be done here. continue; } } - else if (work < MAXUNLOCKABLES && gamedata->unlocked[work]) + else if (work < MAXUNLOCKABLES) { - extradata[id].flags = CHE_HINT; + if (gamedata->unlocked[work] == true) + { + extradata[id].flags |= CHE_HINT; + } + else + { + extradata[id].flags &= ~CHE_ALLCLEAR; + } } } @@ -495,9 +514,13 @@ void M_UpdateChallengeGridExtraData(challengegridextradata_t *extradata) { //CONS_Printf(" %d - %d to left of %d is valid\n", work, tempid, id); // If we haven't already updated our id, it's the one to our left. - if (extradata[id].flags == CHE_HINT) + if (extradata[id].flags & CHE_HINT) { - extradata[tempid].flags = CHE_HINT; + extradata[tempid].flags |= CHE_HINT; + } + if (!(extradata[id].flags & CHE_ALLCLEAR)) + { + extradata[tempid].flags &= ~CHE_ALLCLEAR; } extradata[id].flags = CHE_CONNECTEDLEFT; id = tempid; @@ -505,16 +528,25 @@ void M_UpdateChallengeGridExtraData(challengegridextradata_t *extradata) /*else CONS_Printf(" %d - %d to left of %d is invalid\n", work, tempid, id);*/ } - else if (work < MAXUNLOCKABLES && gamedata->unlocked[work]) + else if (work < MAXUNLOCKABLES) { - extradata[id].flags = CHE_HINT; - continue; + if (gamedata->unlocked[work] == true) + { + extradata[id].flags |= CHE_HINT; + } + else + { + extradata[id].flags &= ~CHE_ALLCLEAR; + } } } // Since we're not modifying id past this point, the conditions become much simpler. - if ((extradata[id].flags & (CHE_HINT|CHE_DONTDRAW)) == CHE_HINT) + if (extradata[id].flags == CHE_HINT) { + // CHE_ALLCLEAR has already been removed, + // and CHE_HINT has already been applied, + // so nothing more needs to be done here. continue; } @@ -528,10 +560,16 @@ void M_UpdateChallengeGridExtraData(challengegridextradata_t *extradata) { ; } - else if (work < MAXUNLOCKABLES && gamedata->unlocked[work]) + else if (work < MAXUNLOCKABLES) { - extradata[id].flags = CHE_HINT; - continue; + if (gamedata->unlocked[work] == true) + { + extradata[id].flags |= CHE_HINT; + } + else + { + extradata[id].flags &= ~CHE_ALLCLEAR; + } } } @@ -551,10 +589,16 @@ void M_UpdateChallengeGridExtraData(challengegridextradata_t *extradata) { ; } - else if (work < MAXUNLOCKABLES && gamedata->unlocked[work]) + else if (work < MAXUNLOCKABLES) { - extradata[id].flags = CHE_HINT; - continue; + if (gamedata->unlocked[work] == true) + { + extradata[id].flags |= CHE_HINT; + } + else + { + extradata[id].flags &= ~CHE_ALLCLEAR; + } } } } diff --git a/src/m_cond.h b/src/m_cond.h index b330b942e..00960abbb 100644 --- a/src/m_cond.h +++ b/src/m_cond.h @@ -347,6 +347,7 @@ void M_UpdateChallengeGridExtraData(challengegridextradata_t *extradata); #define CHE_CONNECTEDLEFT (1<<1) #define CHE_CONNECTEDUP (1<<2) #define CHE_DONTDRAW (CHE_CONNECTEDLEFT|CHE_CONNECTEDUP) +#define CHE_ALLCLEAR (1<<3) char *M_BuildConditionSetString(UINT16 unlockid); #define DESCRIPTIONWIDTH 170