Add MAXTOL
This commit is contained in:
parent
c827a72aab
commit
7bc58c4c0e
|
@ -594,21 +594,21 @@ static void readfreeslots(MYFILE *f)
|
||||||
else if (fastcmp(type, "TOL"))
|
else if (fastcmp(type, "TOL"))
|
||||||
{
|
{
|
||||||
// Search if we already have a typeoflevel by that name...
|
// Search if we already have a typeoflevel by that name...
|
||||||
for (i = 0; i < numtolinfo; i++)
|
for (i = 0; TYPEOFLEVEL[i].name; i++)
|
||||||
if (fastcmp(word, TYPEOFLEVEL[i].name))
|
if (fastcmp(word, TYPEOFLEVEL[i].name))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// We found it? Then don't allocate another one.
|
// We found it? Then don't allocate another one.
|
||||||
if (i < numtolinfo)
|
if (TYPEOFLEVEL[i].name)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// We don't, so freeslot it.
|
// We don't, so freeslot it.
|
||||||
if (lastcustomtol > 31) // Unless you have way too many, since they're flags.
|
if (lastcustomtol == MAXTOL) // Unless you have way too many, since they're flags.
|
||||||
deh_warning("Ran out of free typeoflevel slots!\n");
|
deh_warning("Ran out of free typeoflevel slots!\n");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
G_AddTOL((1<<lastcustomtol), word);
|
G_AddTOL(lastcustomtol, word);
|
||||||
lastcustomtol++;
|
lastcustomtol <<= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1114,38 +1114,7 @@ static void readsprite2(MYFILE *f, INT32 num)
|
||||||
Z_Free(s);
|
Z_Free(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
INT32 numtolinfo = NUMBASETOL;
|
// copypasted from readPlayer :]
|
||||||
UINT32 lastcustomtol = 13;
|
|
||||||
|
|
||||||
tolinfo_t TYPEOFLEVEL[NUMMAXTOL] = {
|
|
||||||
{"SOLO",TOL_SP},
|
|
||||||
{"SP",TOL_SP},
|
|
||||||
{"SINGLEPLAYER",TOL_SP},
|
|
||||||
{"SINGLE",TOL_SP},
|
|
||||||
|
|
||||||
{"COOP",TOL_COOP},
|
|
||||||
{"CO-OP",TOL_COOP},
|
|
||||||
|
|
||||||
{"COMPETITION",TOL_COMPETITION},
|
|
||||||
{"RACE",TOL_RACE},
|
|
||||||
|
|
||||||
{"MATCH",TOL_MATCH},
|
|
||||||
{"TAG",TOL_TAG},
|
|
||||||
{"CTF",TOL_CTF},
|
|
||||||
|
|
||||||
{"2D",TOL_2D},
|
|
||||||
{"MARIO",TOL_MARIO},
|
|
||||||
{"NIGHTS",TOL_NIGHTS},
|
|
||||||
{"OLDBRAK",TOL_ERZ3},
|
|
||||||
|
|
||||||
{"XMAS",TOL_XMAS},
|
|
||||||
{"CHRISTMAS",TOL_XMAS},
|
|
||||||
{"WINTER",TOL_XMAS},
|
|
||||||
|
|
||||||
{NULL, 0}
|
|
||||||
};
|
|
||||||
|
|
||||||
// copypasted from readPlayer :sleep:
|
|
||||||
static const char *const GAMETYPERULE_LIST[];
|
static const char *const GAMETYPERULE_LIST[];
|
||||||
static void readgametype(MYFILE *f, char *gtname)
|
static void readgametype(MYFILE *f, char *gtname)
|
||||||
{
|
{
|
||||||
|
@ -10479,20 +10448,19 @@ static inline int lib_freeslot(lua_State *L)
|
||||||
{
|
{
|
||||||
// Search if we already have a typeoflevel by that name...
|
// Search if we already have a typeoflevel by that name...
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < numtolinfo; i++)
|
for (i = 0; TYPEOFLEVEL[i].name; i++)
|
||||||
if (fastcmp(word, TYPEOFLEVEL[i].name))
|
if (fastcmp(word, TYPEOFLEVEL[i].name))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// We don't, so allocate a new one.
|
// We don't, so allocate a new one.
|
||||||
if (i >= numtolinfo) {
|
if (TYPEOFLEVEL[i].name == NULL) {
|
||||||
if (lastcustomtol > 31) // Unless you have way too many, since they're flags.
|
if (lastcustomtol == MAXTOL) // Unless you have way too many, since they're flags.
|
||||||
CONS_Alert(CONS_WARNING, "Ran out of free typeoflevel slots!\n");
|
CONS_Alert(CONS_WARNING, "Ran out of free typeoflevel slots!\n");
|
||||||
else {
|
else {
|
||||||
UINT32 newtol = (1<<lastcustomtol);
|
|
||||||
CONS_Printf("TypeOfLevel TOL_%s allocated.\n",word);
|
CONS_Printf("TypeOfLevel TOL_%s allocated.\n",word);
|
||||||
G_AddTOL(newtol, word);
|
G_AddTOL(lastcustomtol, word);
|
||||||
lua_pushinteger(L, newtol);
|
lua_pushinteger(L, lastcustomtol);
|
||||||
lastcustomtol++;
|
lastcustomtol <<= 1;
|
||||||
r++;
|
r++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -437,6 +437,7 @@ extern const char *Gametype_ConstantNames[NUMGAMETYPES];
|
||||||
extern INT32 pointlimits[NUMGAMETYPES];
|
extern INT32 pointlimits[NUMGAMETYPES];
|
||||||
extern INT32 timelimits[NUMGAMETYPES];
|
extern INT32 timelimits[NUMGAMETYPES];
|
||||||
|
|
||||||
|
// TypeOfLevel things
|
||||||
enum TypeOfLevel
|
enum TypeOfLevel
|
||||||
{
|
{
|
||||||
TOL_SP = 0x01, ///< Single Player
|
TOL_SP = 0x01, ///< Single Player
|
||||||
|
@ -461,16 +462,16 @@ enum TypeOfLevel
|
||||||
TOL_XMAS = 0x1000, ///< Christmas NiGHTS
|
TOL_XMAS = 0x1000, ///< Christmas NiGHTS
|
||||||
};
|
};
|
||||||
|
|
||||||
#define NUMBASETOL 18
|
#define MAXTOL (1<<31)
|
||||||
#define NUMMAXTOL (18 + NUMGAMETYPEFREESLOTS)
|
#define NUMBASETOLNAMES (19)
|
||||||
|
#define NUMTOLNAMES (NUMBASETOLNAMES + NUMGAMETYPEFREESLOTS)
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
const char *name;
|
const char *name;
|
||||||
UINT32 flag;
|
UINT32 flag;
|
||||||
} tolinfo_t;
|
} tolinfo_t;
|
||||||
extern tolinfo_t TYPEOFLEVEL[NUMMAXTOL];
|
extern tolinfo_t TYPEOFLEVEL[NUMTOLNAMES];
|
||||||
extern INT32 numtolinfo;
|
|
||||||
extern UINT32 lastcustomtol;
|
extern UINT32 lastcustomtol;
|
||||||
|
|
||||||
extern tic_t totalplaytime;
|
extern tic_t totalplaytime;
|
||||||
|
|
42
src/g_game.c
42
src/g_game.c
|
@ -3384,6 +3384,36 @@ UINT32 gametypetol[NUMGAMETYPES] =
|
||||||
TOL_CTF, // CTF
|
TOL_CTF, // CTF
|
||||||
};
|
};
|
||||||
|
|
||||||
|
tolinfo_t TYPEOFLEVEL[NUMTOLNAMES] = {
|
||||||
|
{"SOLO",TOL_SP},
|
||||||
|
{"SP",TOL_SP},
|
||||||
|
{"SINGLEPLAYER",TOL_SP},
|
||||||
|
{"SINGLE",TOL_SP},
|
||||||
|
|
||||||
|
{"COOP",TOL_COOP},
|
||||||
|
{"CO-OP",TOL_COOP},
|
||||||
|
|
||||||
|
{"COMPETITION",TOL_COMPETITION},
|
||||||
|
{"RACE",TOL_RACE},
|
||||||
|
|
||||||
|
{"MATCH",TOL_MATCH},
|
||||||
|
{"TAG",TOL_TAG},
|
||||||
|
{"CTF",TOL_CTF},
|
||||||
|
|
||||||
|
{"2D",TOL_2D},
|
||||||
|
{"MARIO",TOL_MARIO},
|
||||||
|
{"NIGHTS",TOL_NIGHTS},
|
||||||
|
{"OLDBRAK",TOL_ERZ3},
|
||||||
|
|
||||||
|
{"XMAS",TOL_XMAS},
|
||||||
|
{"CHRISTMAS",TOL_XMAS},
|
||||||
|
{"WINTER",TOL_XMAS},
|
||||||
|
|
||||||
|
{NULL, 0}
|
||||||
|
};
|
||||||
|
|
||||||
|
UINT32 lastcustomtol = (TOL_XMAS<<1);
|
||||||
|
|
||||||
//
|
//
|
||||||
// G_AddTOL
|
// G_AddTOL
|
||||||
//
|
//
|
||||||
|
@ -3391,16 +3421,16 @@ UINT32 gametypetol[NUMGAMETYPES] =
|
||||||
//
|
//
|
||||||
void G_AddTOL(UINT32 newtol, const char *tolname)
|
void G_AddTOL(UINT32 newtol, const char *tolname)
|
||||||
{
|
{
|
||||||
TYPEOFLEVEL[numtolinfo].name = Z_StrDup(tolname);
|
INT32 i;
|
||||||
TYPEOFLEVEL[numtolinfo].flag = newtol;
|
for (i = 0; TYPEOFLEVEL[i].name; i++)
|
||||||
numtolinfo++;
|
;
|
||||||
|
|
||||||
TYPEOFLEVEL[numtolinfo].name = NULL;
|
TYPEOFLEVEL[i].name = Z_StrDup(tolname);
|
||||||
TYPEOFLEVEL[numtolinfo].flag = 0;
|
TYPEOFLEVEL[i].flag = newtol;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// G_AddTOL
|
// G_AddGametypeTOL
|
||||||
//
|
//
|
||||||
// Assigns a type of level to a gametype.
|
// Assigns a type of level to a gametype.
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in New Issue