diff --git a/src/m_cond.c b/src/m_cond.c index 3c7c958b1..a026625cf 100644 --- a/src/m_cond.c +++ b/src/m_cond.c @@ -45,7 +45,7 @@ emblem_t emblemlocations[MAXEMBLEMS]; // Unlockables unlockable_t unlockables[MAXUNLOCKABLES]; -// Number of emblems +// Highest used emblem ID INT32 numemblems = 0; // The challenge that will truly let the games begin. @@ -2271,7 +2271,7 @@ static const char *M_GetConditionString(condition_t *cn) i = cn->requirement-1; checkLevel = M_EmblemMapNum(&emblemlocations[i]); - if (checkLevel >= nummapheaders || !mapheaderinfo[checkLevel]) + if (checkLevel >= nummapheaders || !mapheaderinfo[checkLevel] || emblemlocations[i].type == ET_NONE) return va("INVALID MEDAL MAP \"%d:%d\"", cn->requirement, checkLevel); title = M_BuildConditionTitle(checkLevel); @@ -3402,6 +3402,8 @@ INT32 M_CountMedals(boolean all, boolean extraonly) { for (i = 0; i < numemblems; ++i) { + if (emblemlocations[i].type == ET_NONE) + continue; if ((emblemlocations[i].type == ET_GLOBAL) && (emblemlocations[i].flags & GE_NOTMEDAL)) continue; @@ -3432,6 +3434,8 @@ boolean M_GotEnoughMedals(INT32 number) INT32 i, gottenmedals = 0; for (i = 0; i < numemblems; ++i) { + if (emblemlocations[i].type == ET_NONE) + continue; if (!gamedata->collected[i]) continue; if (++gottenmedals < number) @@ -3701,6 +3705,9 @@ emblem_t *M_GetLevelEmblems(INT32 mapnum) while (--i >= 0) { + if (emblemlocations[i].type == ET_NONE) + continue; + INT32 checkLevel = M_EmblemMapNum(&emblemlocations[i]); if (checkLevel >= nummapheaders || !mapheaderinfo[checkLevel]) diff --git a/src/m_cond.h b/src/m_cond.h index 48b401171..d084ee001 100644 --- a/src/m_cond.h +++ b/src/m_cond.h @@ -171,10 +171,10 @@ struct conditionset_t }; // Emblem information -#define ET_GLOBAL 0 // Emblem with a position in space -#define ET_MAP 1 // Beat the map -#define ET_TIME 2 // Get the time -//#define ET_DEVTIME 3 // Time, but the value is tied to a Time Trial demo, not pre-defined +#define ET_NONE 0 // Empty slot +#define ET_GLOBAL 1 // Emblem with a position in space +#define ET_MAP 2 // Beat the map +#define ET_TIME 3 // Get the time // Global emblem flags #define GE_NOTMEDAL 1 // Doesn't count towards number of medals diff --git a/src/p_inter.c b/src/p_inter.c index 1f2583000..e2b20b8d9 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -229,7 +229,8 @@ boolean P_CanPickupEmblem(player_t *player, INT32 emblemID) boolean P_EmblemWasCollected(INT32 emblemID) { - if (emblemID < 0 || emblemID >= numemblems) + if (emblemID < 0 || emblemID >= numemblems + || emblemlocations[emblemID].type == ET_NONE) { // Invalid emblem ID, can't pickup. return true;