Custom gametype rankings

This commit is contained in:
Jaime Passos 2019-12-18 22:02:37 -03:00
parent 0421c81e04
commit 5e818e1dab
4 changed files with 42 additions and 14 deletions

View file

@ -1156,6 +1156,7 @@ static void readgametype(MYFILE *f, char *gtname)
INT32 newgttimelimit = 0;
UINT8 newgtleftcolor = 0;
UINT8 newgtrightcolor = 0;
INT16 newgtrankingstype = -1;
int newgtinttype = 0;
char gtdescription[441];
@ -1243,7 +1244,13 @@ static void readgametype(MYFILE *f, char *gtname)
newgtleftcolor = (UINT8)get_number(word2);
else if (fastcmp(word, "HEADERRIGHTCOLOR") || fastcmp(word, "HEADERRIGHTCOLOUR"))
newgtrightcolor = (UINT8)get_number(word2);
// Type of intermission
// Rankings type
else if (fastcmp(word, "RANKINGTYPE"))
{
// Case insensitive
newgtrankingstype = (int)get_number(word2);
}
// Intermission type
else if (fastcmp(word, "INTERMISSIONTYPE"))
{
// Case sensitive
@ -1308,6 +1315,9 @@ static void readgametype(MYFILE *f, char *gtname)
G_SetGametypeDescription(newgtidx, gtdescription, newgtleftcolor, newgtrightcolor);
// Not covered by G_AddGametype alone.
if (newgtrankingstype == -1)
newgtrankingstype = newgtidx;
gametyperankings[newgtidx] = newgtrankingstype;
intermissiontypes[newgtidx] = newgtinttype;
pointlimits[newgtidx] = newgtpointlimit;
timelimits[newgtidx] = newgttimelimit;

View file

@ -3084,7 +3084,7 @@ const char *Gametype_ConstantNames[NUMGAMETYPES] =
"GT_CTF" // GT_CTF
};
// Game type rules
// Gametype rules
UINT32 gametypedefaultrules[NUMGAMETYPES] =
{
// Co-op
@ -3169,6 +3169,23 @@ void G_SetGametypeDescription(INT16 gtype, char *descriptiontext, UINT8 leftcolo
gametypedesc[gtype].col[1] = rightcolor;
}
// Gametype rankings
INT16 gametyperankings[NUMGAMETYPES] =
{
GT_COOP,
GT_COMPETITION,
GT_RACE,
GT_MATCH,
GT_TEAMMATCH,
GT_TAG,
GT_HIDEANDSEEK,
GT_CTF,
};
// Gametype to TOL (Type Of Level)
UINT32 gametypetol[NUMGAMETYPES] =
{
TOL_COOP, // Co-op

View file

@ -203,6 +203,7 @@ boolean G_CheckDemoStatus(void);
extern UINT32 gametypedefaultrules[NUMGAMETYPES];
extern UINT32 gametypetol[NUMGAMETYPES];
extern INT16 gametyperankings[NUMGAMETYPES];
void G_SetGametype(INT16 gametype);
INT16 G_AddGametype(UINT32 rules);

View file

@ -2371,7 +2371,7 @@ void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, I
for (i = 0; i < scorelines; i++)
{
if (players[tab[i].num].spectator && gametype != GT_COOP)
if (players[tab[i].num].spectator && gametyperankings[gametype] != GT_COOP)
continue; //ignore them.
greycheck = greycheckdef;
@ -2434,7 +2434,7 @@ void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, I
}
}
if (G_GametypeUsesLives() && !(gametype == GT_COOP && (cv_cooplives.value == 0 || cv_cooplives.value == 3)) && (players[tab[i].num].lives != INFLIVES)) //show lives
if (G_GametypeUsesLives() && !(gametyperankings[gametype] == GT_COOP && (cv_cooplives.value == 0 || cv_cooplives.value == 3)) && (players[tab[i].num].lives != INFLIVES)) //show lives
V_DrawRightAlignedString(x, y+4, V_ALLOWLOWERCASE|(greycheck ? V_60TRANS : 0), va("%dx", players[tab[i].num].lives));
else if (G_TagGametype() && players[tab[i].num].pflags & PF_TAGIT)
{
@ -2447,7 +2447,7 @@ void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, I
if (players[tab[i].num].exiting || (players[tab[i].num].pflags & PF_FINISHED))
V_DrawSmallScaledPatch(x - SHORT(exiticon->width)/2 - 1, y-3, 0, exiticon);
if (gametype == GT_RACE)
if (gametyperankings[gametype] == GT_RACE)
{
if (circuitmap)
{
@ -2726,7 +2726,7 @@ void HU_DrawDualTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scoreline
for (i = 0; i < scorelines; i++)
{
if (players[tab[i].num].spectator && gametype != GT_COOP)
if (players[tab[i].num].spectator && gametyperankings[gametype] != GT_COOP)
continue; //ignore them.
greycheck = greycheckdef;
@ -2743,7 +2743,7 @@ void HU_DrawDualTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scoreline
| (greycheck ? V_TRANSLUCENT : 0)
| V_ALLOWLOWERCASE, name);
if (G_GametypeUsesLives() && !(gametype == GT_COOP && (cv_cooplives.value == 0 || cv_cooplives.value == 3)) && (players[tab[i].num].lives != INFLIVES)) //show lives
if (G_GametypeUsesLives() && !(gametyperankings[gametype] == GT_COOP && (cv_cooplives.value == 0 || cv_cooplives.value == 3)) && (players[tab[i].num].lives != INFLIVES)) //show lives
V_DrawRightAlignedString(x, y+4, V_ALLOWLOWERCASE, va("%dx", players[tab[i].num].lives));
else if (G_TagGametype() && players[tab[i].num].pflags & PF_TAGIT)
V_DrawSmallScaledPatch(x-28, y-4, 0, tagico);
@ -2792,7 +2792,7 @@ void HU_DrawDualTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scoreline
}
// All data drawn with thin string for space.
if (gametype == GT_RACE)
if (gametyperankings[gametype] == GT_RACE)
{
if (circuitmap)
{
@ -2832,7 +2832,7 @@ static void HU_Draw32TabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scor
for (i = 0; i < scorelines; i++)
{
if (players[tab[i].num].spectator && gametype != GT_COOP)
if (players[tab[i].num].spectator && gametyperankings[gametype] != GT_COOP)
continue; //ignore them.
greycheck = greycheckdef;
@ -2902,7 +2902,7 @@ static void HU_Draw32TabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scor
}
// All data drawn with thin string for space.
if (gametype == GT_RACE)
if (gametyperankings[gametype] == GT_RACE)
{
if (circuitmap)
{
@ -3040,7 +3040,7 @@ static void HU_DrawRankings(void)
V_DrawCenteredString(256, 16, 0, va("%d", cv_pointlimit.value));
}
}
else if (gametype == GT_COOP)
else if (gametyperankings[gametype] == GT_COOP)
{
INT32 totalscore = 0;
for (i = 0; i < MAXPLAYERS; i++)
@ -3074,7 +3074,7 @@ static void HU_DrawRankings(void)
tab[i].num = -1;
tab[i].name = 0;
if (gametype == GT_RACE && !circuitmap)
if (gametyperankings[gametype] == GT_RACE && !circuitmap)
tab[i].count = INT32_MAX;
}
@ -3094,7 +3094,7 @@ static void HU_DrawRankings(void)
if (!G_PlatformGametype() && players[i].spectator)
continue;
if (gametype == GT_RACE)
if (gametyperankings[gametype] == GT_RACE)
{
if (circuitmap)
{
@ -3117,7 +3117,7 @@ static void HU_DrawRankings(void)
}
}
}
else if (gametype == GT_COMPETITION)
else if (gametyperankings[gametype] == GT_COMPETITION)
{
// todo put something more fitting for the gametype here, such as current
// number of categories led