mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-04-27 20:41:46 +00:00
Cache level ID for Emblems, too
This commit is contained in:
parent
c7db580338
commit
2fbbe52ded
3 changed files with 29 additions and 6 deletions
|
|
@ -2142,6 +2142,7 @@ void reademblemdata(MYFILE *f, INT32 num)
|
||||||
else if (fastcmp(word, "MAPNAME"))
|
else if (fastcmp(word, "MAPNAME"))
|
||||||
{
|
{
|
||||||
emblemlocations[num-1].level = Z_StrDup(word2);
|
emblemlocations[num-1].level = Z_StrDup(word2);
|
||||||
|
emblemlocations[num-1].levelCache = NEXTMAP_INVALID;
|
||||||
}
|
}
|
||||||
else if (fastcmp(word, "SPRITE"))
|
else if (fastcmp(word, "SPRITE"))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
30
src/m_cond.c
30
src/m_cond.c
|
|
@ -656,7 +656,7 @@ static const char *M_GetConditionString(condition_t *cn)
|
||||||
INT32 checkLevel;
|
INT32 checkLevel;
|
||||||
|
|
||||||
i = cn->requirement-1;
|
i = cn->requirement-1;
|
||||||
checkLevel = G_MapNumber(emblemlocations[i].level);
|
checkLevel = M_EmblemMapNum(&emblemlocations[i]);
|
||||||
|
|
||||||
if (checkLevel >= nummapheaders || !mapheaderinfo[checkLevel])
|
if (checkLevel >= nummapheaders || !mapheaderinfo[checkLevel])
|
||||||
return va("INVALID MEDAL MAP \"%d:%d\"", cn->requirement, checkLevel);
|
return va("INVALID MEDAL MAP \"%d:%d\"", cn->requirement, checkLevel);
|
||||||
|
|
@ -952,7 +952,7 @@ UINT8 M_CheckLevelEmblems(void)
|
||||||
if (emblemlocations[i].type < ET_TIME || gamedata->collected[i])
|
if (emblemlocations[i].type < ET_TIME || gamedata->collected[i])
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
checkLevel = G_MapNumber(emblemlocations[i].level);
|
checkLevel = M_EmblemMapNum(&emblemlocations[i]);
|
||||||
|
|
||||||
if (checkLevel >= nummapheaders || !mapheaderinfo[checkLevel])
|
if (checkLevel >= nummapheaders || !mapheaderinfo[checkLevel])
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -992,7 +992,7 @@ UINT8 M_CompletionEmblems(void) // Bah! Duplication sucks, but it's for a separa
|
||||||
if (emblemlocations[i].type < ET_TIME || gamedata->collected[i])
|
if (emblemlocations[i].type < ET_TIME || gamedata->collected[i])
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
checkLevel = G_MapNumber(emblemlocations[i].level);
|
checkLevel = M_EmblemMapNum(&emblemlocations[i]);
|
||||||
|
|
||||||
if (checkLevel >= nummapheaders || !mapheaderinfo[checkLevel])
|
if (checkLevel >= nummapheaders || !mapheaderinfo[checkLevel])
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -1339,7 +1339,12 @@ UINT16 M_UnlockableMapNum(unlockable_t *unlock)
|
||||||
{
|
{
|
||||||
if (unlock->stringVarCache == -1)
|
if (unlock->stringVarCache == -1)
|
||||||
{
|
{
|
||||||
unlock->stringVarCache = G_MapNumber(unlock->stringVar);
|
INT32 result = G_MapNumber(unlock->stringVar);
|
||||||
|
|
||||||
|
if (result >= nummapheaders)
|
||||||
|
return result;
|
||||||
|
|
||||||
|
unlock->stringVarCache = result;
|
||||||
}
|
}
|
||||||
|
|
||||||
return unlock->stringVarCache;
|
return unlock->stringVarCache;
|
||||||
|
|
@ -1352,6 +1357,21 @@ UINT16 M_UnlockableMapNum(unlockable_t *unlock)
|
||||||
// Misc Emblem shit
|
// Misc Emblem shit
|
||||||
// ----------------
|
// ----------------
|
||||||
|
|
||||||
|
UINT16 M_EmblemMapNum(emblem_t *emblem)
|
||||||
|
{
|
||||||
|
if (emblem->levelCache == NEXTMAP_INVALID)
|
||||||
|
{
|
||||||
|
UINT16 result = G_MapNumber(emblem->level);
|
||||||
|
|
||||||
|
if (result >= nummapheaders)
|
||||||
|
return result;
|
||||||
|
|
||||||
|
emblem->levelCache = result;
|
||||||
|
}
|
||||||
|
|
||||||
|
return emblem->levelCache;
|
||||||
|
}
|
||||||
|
|
||||||
// Returns pointer to an emblem if an emblem exists for that level.
|
// Returns pointer to an emblem if an emblem exists for that level.
|
||||||
// Pass -1 mapnum to continue from last emblem.
|
// Pass -1 mapnum to continue from last emblem.
|
||||||
// NULL if not found.
|
// NULL if not found.
|
||||||
|
|
@ -1369,7 +1389,7 @@ emblem_t *M_GetLevelEmblems(INT32 mapnum)
|
||||||
|
|
||||||
while (--i >= 0)
|
while (--i >= 0)
|
||||||
{
|
{
|
||||||
INT32 checkLevel = G_MapNumber(emblemlocations[i].level);
|
INT32 checkLevel = M_EmblemMapNum(&emblemlocations[i]);
|
||||||
|
|
||||||
if (checkLevel >= nummapheaders || !mapheaderinfo[checkLevel])
|
if (checkLevel >= nummapheaders || !mapheaderinfo[checkLevel])
|
||||||
continue;
|
continue;
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,8 @@ struct emblem_t
|
||||||
{
|
{
|
||||||
UINT8 type; ///< Emblem type
|
UINT8 type; ///< Emblem type
|
||||||
INT16 tag; ///< Tag of emblem mapthing
|
INT16 tag; ///< Tag of emblem mapthing
|
||||||
char * level; ///< Level on which this emblem can be found.
|
char *level; ///< Level on which this emblem can be found.
|
||||||
|
INT16 levelCache; ///< Stored G_MapNumber()+1 result
|
||||||
UINT8 sprite; ///< emblem sprite to use, 0 - 25
|
UINT8 sprite; ///< emblem sprite to use, 0 - 25
|
||||||
UINT16 color; ///< skincolor to use
|
UINT16 color; ///< skincolor to use
|
||||||
INT32 flags; ///< GE or ME constants
|
INT32 flags; ///< GE or ME constants
|
||||||
|
|
@ -229,5 +230,6 @@ cupheader_t *M_UnlockableCup(unlockable_t *unlock);
|
||||||
UINT16 M_UnlockableMapNum(unlockable_t *unlock);
|
UINT16 M_UnlockableMapNum(unlockable_t *unlock);
|
||||||
|
|
||||||
INT32 M_EmblemSkinNum(emblem_t *emblem);
|
INT32 M_EmblemSkinNum(emblem_t *emblem);
|
||||||
|
UINT16 M_EmblemMapNum(emblem_t *emblem);
|
||||||
|
|
||||||
#define M_Achieved(a) ((a) >= MAXCONDITIONSETS || gamedata->achieved[a])
|
#define M_Achieved(a) ((a) >= MAXCONDITIONSETS || gamedata->achieved[a])
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue