mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-12-11 02:23:09 +00:00
Map lump names can be anything, map number is dynamically allocated
This commit is contained in:
parent
c609dffdab
commit
37c345c7eb
17 changed files with 91 additions and 171 deletions
|
|
@ -892,13 +892,7 @@ void D_StartTitle(void)
|
||||||
|
|
||||||
if (server)
|
if (server)
|
||||||
{
|
{
|
||||||
char mapname[6];
|
COM_BufAddText(va("map %s\n", G_BuildMapName(spstage_start)));
|
||||||
|
|
||||||
strlcpy(mapname, G_BuildMapName(spstage_start), sizeof (mapname));
|
|
||||||
strlwr(mapname);
|
|
||||||
mapname[5] = '\0';
|
|
||||||
|
|
||||||
COM_BufAddText(va("map %s\n", mapname));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2347,8 +2347,7 @@ void D_MapChange(INT32 mapnum, INT32 newgametype, boolean pencoremode, boolean r
|
||||||
if (delay != 2)
|
if (delay != 2)
|
||||||
{
|
{
|
||||||
UINT8 flags = 0;
|
UINT8 flags = 0;
|
||||||
const char *mapname = G_BuildMapName(mapnum);
|
I_Assert(W_CheckNumForName(G_BuildMapName(mapnum)) != LUMPERROR);
|
||||||
I_Assert(W_CheckNumForName(mapname) != LUMPERROR);
|
|
||||||
buf_p = buf;
|
buf_p = buf;
|
||||||
if (pencoremode)
|
if (pencoremode)
|
||||||
flags |= 1;
|
flags |= 1;
|
||||||
|
|
@ -2363,7 +2362,7 @@ void D_MapChange(INT32 mapnum, INT32 newgametype, boolean pencoremode, boolean r
|
||||||
// new gametype value
|
// new gametype value
|
||||||
WRITEUINT8(buf_p, newgametype);
|
WRITEUINT8(buf_p, newgametype);
|
||||||
|
|
||||||
WRITESTRINGN(buf_p, mapname, MAX_WADPATH);
|
WRITEINT16(buf_p, mapnum);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (delay == 1)
|
if (delay == 1)
|
||||||
|
|
@ -2791,7 +2790,6 @@ static void Command_Map_f(void)
|
||||||
*/
|
*/
|
||||||
static void Got_Mapcmd(UINT8 **cp, INT32 playernum)
|
static void Got_Mapcmd(UINT8 **cp, INT32 playernum)
|
||||||
{
|
{
|
||||||
char mapname[MAX_WADPATH+1];
|
|
||||||
UINT8 flags;
|
UINT8 flags;
|
||||||
INT32 resetplayer = 1, lastgametype;
|
INT32 resetplayer = 1, lastgametype;
|
||||||
UINT8 skipprecutscene, FLS;
|
UINT8 skipprecutscene, FLS;
|
||||||
|
|
@ -2833,7 +2831,7 @@ static void Got_Mapcmd(UINT8 **cp, INT32 playernum)
|
||||||
|
|
||||||
FLS = ((flags & (1<<3)) != 0);
|
FLS = ((flags & (1<<3)) != 0);
|
||||||
|
|
||||||
READSTRINGN(*cp, mapname, MAX_WADPATH);
|
mapnumber = READINT16(*cp);
|
||||||
|
|
||||||
if (netgame)
|
if (netgame)
|
||||||
P_SetRandSeed(READUINT32(*cp));
|
P_SetRandSeed(READUINT32(*cp));
|
||||||
|
|
@ -2841,7 +2839,7 @@ static void Got_Mapcmd(UINT8 **cp, INT32 playernum)
|
||||||
if (!skipprecutscene)
|
if (!skipprecutscene)
|
||||||
{
|
{
|
||||||
DEBFILE(va("Warping to %s [resetplayer=%d lastgametype=%d gametype=%d cpnd=%d]\n",
|
DEBFILE(va("Warping to %s [resetplayer=%d lastgametype=%d gametype=%d cpnd=%d]\n",
|
||||||
mapname, resetplayer, lastgametype, gametype, chmappending));
|
G_BuildMapName(mapnumber), resetplayer, lastgametype, gametype, chmappending));
|
||||||
CON_LogMessage(M_GetText("Speeding off to level...\n"));
|
CON_LogMessage(M_GetText("Speeding off to level...\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2861,13 +2859,12 @@ static void Got_Mapcmd(UINT8 **cp, INT32 playernum)
|
||||||
CV_StealthSetValue(&cv_playercolor[0], players[0].skincolor);
|
CV_StealthSetValue(&cv_playercolor[0], players[0].skincolor);
|
||||||
}
|
}
|
||||||
|
|
||||||
mapnumber = M_MapNumber(mapname[3], mapname[4]);
|
|
||||||
LUAh_MapChange(mapnumber);
|
LUAh_MapChange(mapnumber);
|
||||||
|
|
||||||
demo.savemode = (cv_recordmultiplayerdemos.value == 2) ? DSM_WILLAUTOSAVE : DSM_NOTSAVING;
|
demo.savemode = (cv_recordmultiplayerdemos.value == 2) ? DSM_WILLAUTOSAVE : DSM_NOTSAVING;
|
||||||
demo.savebutton = 0;
|
demo.savebutton = 0;
|
||||||
|
|
||||||
G_InitNew(pencoremode, mapname, resetplayer, skipprecutscene, FLS);
|
G_InitNew(pencoremode, mapnumber, resetplayer, skipprecutscene, FLS);
|
||||||
if (demo.playback && !demo.timing)
|
if (demo.playback && !demo.timing)
|
||||||
precache = true;
|
precache = true;
|
||||||
if (demo.timing)
|
if (demo.timing)
|
||||||
|
|
|
||||||
112
src/dehacked.c
112
src/dehacked.c
|
|
@ -1684,7 +1684,7 @@ static const struct {
|
||||||
|
|
||||||
#define MAXFLICKIES 64
|
#define MAXFLICKIES 64
|
||||||
|
|
||||||
static void readlevelheader(MYFILE *f, INT32 num)
|
static void readlevelheader(MYFILE *f, char * name)
|
||||||
{
|
{
|
||||||
char *s = Z_Malloc(MAXLINELEN, PU_STATIC, NULL);
|
char *s = Z_Malloc(MAXLINELEN, PU_STATIC, NULL);
|
||||||
char *word;
|
char *word;
|
||||||
|
|
@ -1692,10 +1692,24 @@ static void readlevelheader(MYFILE *f, INT32 num)
|
||||||
//char *word3; // Non-uppercase version of word2
|
//char *word3; // Non-uppercase version of word2
|
||||||
char *tmp;
|
char *tmp;
|
||||||
INT32 i;
|
INT32 i;
|
||||||
|
const INT32 num = G_MapNumber(name);
|
||||||
|
|
||||||
|
if (num > NUMMAPS)
|
||||||
|
{
|
||||||
|
I_Error("Too many maps!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mapheaderinfo[num-1])
|
||||||
|
G_SetGameModified(multiplayer, true); // only mark as a major mod if it replaces an already-existing mapheaderinfo
|
||||||
|
|
||||||
// Reset all previous map header information
|
// Reset all previous map header information
|
||||||
P_AllocMapHeader((INT16)(num-1));
|
P_AllocMapHeader((INT16)(num-1));
|
||||||
|
|
||||||
|
if (mapheaderinfo[num-1]->lumpname == NULL)
|
||||||
|
{
|
||||||
|
mapheaderinfo[num-1]->lumpname = Z_StrDup(name);
|
||||||
|
}
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (myfgets(s, MAXLINELEN, f))
|
if (myfgets(s, MAXLINELEN, f))
|
||||||
|
|
@ -1895,8 +1909,7 @@ static void readlevelheader(MYFILE *f, INT32 num)
|
||||||
// i.e., Nextlevel = AB, Nextlevel = FZ, etc.
|
// i.e., Nextlevel = AB, Nextlevel = FZ, etc.
|
||||||
|
|
||||||
// Convert to map number
|
// Convert to map number
|
||||||
if (word2[0] >= 'A' && word2[0] <= 'Z' && word2[2] == '\0')
|
i = G_MapNumber(word2);
|
||||||
i = M_MapNumber(word2[0], word2[1]);
|
|
||||||
|
|
||||||
mapheaderinfo[num-1]->nextlevel = (INT16)i;
|
mapheaderinfo[num-1]->nextlevel = (INT16)i;
|
||||||
}
|
}
|
||||||
|
|
@ -1911,8 +1924,7 @@ static void readlevelheader(MYFILE *f, INT32 num)
|
||||||
// i.e., MarathonNext = AB, MarathonNext = FZ, etc.
|
// i.e., MarathonNext = AB, MarathonNext = FZ, etc.
|
||||||
|
|
||||||
// Convert to map number
|
// Convert to map number
|
||||||
if (word2[0] >= 'A' && word2[0] <= 'Z' && word2[2] == '\0')
|
i = G_MapNumber(word2);
|
||||||
i = M_MapNumber(word2[0], word2[1]);
|
|
||||||
|
|
||||||
mapheaderinfo[num-1]->marathonnext = (INT16)i;
|
mapheaderinfo[num-1]->marathonnext = (INT16)i;
|
||||||
}
|
}
|
||||||
|
|
@ -3608,10 +3620,7 @@ static void reademblemdata(MYFILE *f, INT32 num)
|
||||||
// i.e., Level AB, Level FZ, etc.
|
// i.e., Level AB, Level FZ, etc.
|
||||||
|
|
||||||
// Convert to map number
|
// Convert to map number
|
||||||
if (word2[0] >= 'A' && word2[0] <= 'Z')
|
emblemlocations[num-1].level = (INT16)G_MapNumber(word2);
|
||||||
value = M_MapNumber(word2[0], word2[1]);
|
|
||||||
|
|
||||||
emblemlocations[num-1].level = (INT16)value;
|
|
||||||
}
|
}
|
||||||
else if (fastcmp(word, "SPRITE"))
|
else if (fastcmp(word, "SPRITE"))
|
||||||
{
|
{
|
||||||
|
|
@ -3836,10 +3845,7 @@ static void readunlockable(MYFILE *f, INT32 num)
|
||||||
// i.e., Level AB, Level FZ, etc.
|
// i.e., Level AB, Level FZ, etc.
|
||||||
|
|
||||||
// Convert to map number
|
// Convert to map number
|
||||||
if (word2[0] >= 'A' && word2[0] <= 'Z')
|
unlockables[num].variable = (INT16)G_MapNumber(word2);
|
||||||
i = M_MapNumber(word2[0], word2[1]);
|
|
||||||
|
|
||||||
unlockables[num].variable = (INT16)i;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
deh_warning("Unlockable %d: unknown word '%s'", num+1, word);
|
deh_warning("Unlockable %d: unknown word '%s'", num+1, word);
|
||||||
|
|
@ -3930,11 +3936,7 @@ static void readcondition(UINT8 set, UINT32 id, char *word2)
|
||||||
PARAMCHECK(1);
|
PARAMCHECK(1);
|
||||||
ty = UC_MAPVISITED + offset;
|
ty = UC_MAPVISITED + offset;
|
||||||
|
|
||||||
// Convert to map number if it appears to be one
|
re = G_MapNumber(params[1]);
|
||||||
if (params[1][0] >= 'A' && params[1][0] <= 'Z')
|
|
||||||
re = M_MapNumber(params[1][0], params[1][1]);
|
|
||||||
else
|
|
||||||
re = atoi(params[1]);
|
|
||||||
|
|
||||||
if (re < 0 || re >= NUMMAPS)
|
if (re < 0 || re >= NUMMAPS)
|
||||||
{
|
{
|
||||||
|
|
@ -3948,11 +3950,7 @@ static void readcondition(UINT8 set, UINT32 id, char *word2)
|
||||||
ty = UC_MAPTIME;
|
ty = UC_MAPTIME;
|
||||||
re = atoi(params[2]);
|
re = atoi(params[2]);
|
||||||
|
|
||||||
// Convert to map number if it appears to be one
|
x1 = (INT16)G_MapNumber(params[1]);
|
||||||
if (params[1][0] >= 'A' && params[1][0] <= 'Z')
|
|
||||||
x1 = (INT16)M_MapNumber(params[1][0], params[1][1]);
|
|
||||||
else
|
|
||||||
x1 = (INT16)atoi(params[1]);
|
|
||||||
|
|
||||||
if (x1 < 0 || x1 >= NUMMAPS)
|
if (x1 < 0 || x1 >= NUMMAPS)
|
||||||
{
|
{
|
||||||
|
|
@ -4160,12 +4158,7 @@ static void readmaincfg(MYFILE *f)
|
||||||
// i.e., Level AB, Level FZ, etc.
|
// i.e., Level AB, Level FZ, etc.
|
||||||
|
|
||||||
// Convert to map number
|
// Convert to map number
|
||||||
if (word2[0] >= 'A' && word2[0] <= 'Z')
|
spstage_start = spmarathon_start = (INT16)G_MapNumber(word2);
|
||||||
value = M_MapNumber(word2[0], word2[1]);
|
|
||||||
else
|
|
||||||
value = get_number(word2);
|
|
||||||
|
|
||||||
spstage_start = spmarathon_start = (INT16)value;
|
|
||||||
}
|
}
|
||||||
else if (fastcmp(word, "SPMARATHON_START"))
|
else if (fastcmp(word, "SPMARATHON_START"))
|
||||||
{
|
{
|
||||||
|
|
@ -4173,12 +4166,7 @@ static void readmaincfg(MYFILE *f)
|
||||||
// i.e., Level AB, Level FZ, etc.
|
// i.e., Level AB, Level FZ, etc.
|
||||||
|
|
||||||
// Convert to map number
|
// Convert to map number
|
||||||
if (word2[0] >= 'A' && word2[0] <= 'Z')
|
spmarathon_start = (INT16)G_MapNumber(word2);
|
||||||
value = M_MapNumber(word2[0], word2[1]);
|
|
||||||
else
|
|
||||||
value = get_number(word2);
|
|
||||||
|
|
||||||
spmarathon_start = (INT16)value;
|
|
||||||
}
|
}
|
||||||
else if (fastcmp(word, "SSTAGE_START"))
|
else if (fastcmp(word, "SSTAGE_START"))
|
||||||
{
|
{
|
||||||
|
|
@ -4186,12 +4174,7 @@ static void readmaincfg(MYFILE *f)
|
||||||
// i.e., Level AB, Level FZ, etc.
|
// i.e., Level AB, Level FZ, etc.
|
||||||
|
|
||||||
// Convert to map number
|
// Convert to map number
|
||||||
if (word2[0] >= 'A' && word2[0] <= 'Z')
|
sstage_start = (INT16)G_MapNumber(word2);
|
||||||
value = M_MapNumber(word2[0], word2[1]);
|
|
||||||
else
|
|
||||||
value = get_number(word2);
|
|
||||||
|
|
||||||
sstage_start = (INT16)value;
|
|
||||||
sstage_end = (INT16)(sstage_start+7); // 7 special stages total plus one weirdo
|
sstage_end = (INT16)(sstage_start+7); // 7 special stages total plus one weirdo
|
||||||
}
|
}
|
||||||
else if (fastcmp(word, "SMPSTAGE_START"))
|
else if (fastcmp(word, "SMPSTAGE_START"))
|
||||||
|
|
@ -4200,12 +4183,7 @@ static void readmaincfg(MYFILE *f)
|
||||||
// i.e., Level AB, Level FZ, etc.
|
// i.e., Level AB, Level FZ, etc.
|
||||||
|
|
||||||
// Convert to map number
|
// Convert to map number
|
||||||
if (word2[0] >= 'A' && word2[0] <= 'Z')
|
smpstage_start = (INT16)G_MapNumber(word2);
|
||||||
value = M_MapNumber(word2[0], word2[1]);
|
|
||||||
else
|
|
||||||
value = get_number(word2);
|
|
||||||
|
|
||||||
smpstage_start = (INT16)value;
|
|
||||||
smpstage_end = (INT16)(smpstage_start+6); // 7 special stages total
|
smpstage_end = (INT16)(smpstage_start+6); // 7 special stages total
|
||||||
}
|
}
|
||||||
else if (fastcmp(word, "REDTEAM"))
|
else if (fastcmp(word, "REDTEAM"))
|
||||||
|
|
@ -4294,12 +4272,7 @@ static void readmaincfg(MYFILE *f)
|
||||||
// i.e., Level AB, Level FZ, etc.
|
// i.e., Level AB, Level FZ, etc.
|
||||||
|
|
||||||
// Convert to map number
|
// Convert to map number
|
||||||
if (word2[0] >= 'A' && word2[0] <= 'Z')
|
titlemap = (INT16)G_MapNumber(word2);
|
||||||
value = M_MapNumber(word2[0], word2[1]);
|
|
||||||
else
|
|
||||||
value = get_number(word2);
|
|
||||||
|
|
||||||
titlemap = (INT16)value;
|
|
||||||
titlechanged = true;
|
titlechanged = true;
|
||||||
}
|
}
|
||||||
else if (fastcmp(word, "HIDETITLEPICS") || fastcmp(word, "TITLEPICSHIDE"))
|
else if (fastcmp(word, "HIDETITLEPICS") || fastcmp(word, "TITLEPICSHIDE"))
|
||||||
|
|
@ -4440,12 +4413,7 @@ static void readmaincfg(MYFILE *f)
|
||||||
// i.e., Level AB, Level FZ, etc.
|
// i.e., Level AB, Level FZ, etc.
|
||||||
|
|
||||||
// Convert to map number
|
// Convert to map number
|
||||||
if (word2[0] >= 'A' && word2[0] <= 'Z')
|
bootmap = (INT16)G_MapNumber(word2);
|
||||||
value = M_MapNumber(word2[0], word2[1]);
|
|
||||||
else
|
|
||||||
value = get_number(word2);
|
|
||||||
|
|
||||||
bootmap = (INT16)value;
|
|
||||||
//titlechanged = true;
|
//titlechanged = true;
|
||||||
}
|
}
|
||||||
else if (fastcmp(word, "TUTORIALMAP"))
|
else if (fastcmp(word, "TUTORIALMAP"))
|
||||||
|
|
@ -4454,12 +4422,7 @@ static void readmaincfg(MYFILE *f)
|
||||||
// i.e., Level AB, Level FZ, etc.
|
// i.e., Level AB, Level FZ, etc.
|
||||||
|
|
||||||
// Convert to map number
|
// Convert to map number
|
||||||
if (word2[0] >= 'A' && word2[0] <= 'Z')
|
tutorialmap = (INT16)G_MapNumber(word2);
|
||||||
value = M_MapNumber(word2[0], word2[1]);
|
|
||||||
else
|
|
||||||
value = get_number(word2);
|
|
||||||
|
|
||||||
tutorialmap = (INT16)value;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
deh_warning("Maincfg: unknown word '%s'", word);
|
deh_warning("Maincfg: unknown word '%s'", word);
|
||||||
|
|
@ -4859,24 +4822,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, boolean mainfile)
|
||||||
}
|
}
|
||||||
else if (fastcmp(word, "LEVEL"))
|
else if (fastcmp(word, "LEVEL"))
|
||||||
{
|
{
|
||||||
// Support using the actual map name,
|
readlevelheader(f, word2);
|
||||||
// i.e., Level AB, Level FZ, etc.
|
|
||||||
|
|
||||||
// Convert to map number
|
|
||||||
if (word2[0] >= 'A' && word2[0] <= 'Z')
|
|
||||||
i = M_MapNumber(word2[0], word2[1]);
|
|
||||||
|
|
||||||
if (i > 0 && i <= NUMMAPS)
|
|
||||||
{
|
|
||||||
if (mapheaderinfo[i])
|
|
||||||
G_SetGameModified(multiplayer, true); // only mark as a major mod if it replaces an already-existing mapheaderinfo
|
|
||||||
readlevelheader(f, i);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
deh_warning("Level number %d out of range (1 - %d)", i, NUMMAPS);
|
|
||||||
ignorelines(f);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (fastcmp(word, "GAMETYPE"))
|
else if (fastcmp(word, "GAMETYPE"))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -625,7 +625,7 @@ extern const char *compdate, *comptime, *comprevision, *compbranch;
|
||||||
|
|
||||||
/// Backwards compatibility with musicslots.
|
/// Backwards compatibility with musicslots.
|
||||||
/// \note You should leave this enabled unless you're working with a future SRB2 version.
|
/// \note You should leave this enabled unless you're working with a future SRB2 version.
|
||||||
#define MUSICSLOT_COMPATIBILITY
|
//#define MUSICSLOT_COMPATIBILITY
|
||||||
|
|
||||||
/// Experimental attempts at preventing MF_PAPERCOLLISION objects from getting stuck in walls.
|
/// Experimental attempts at preventing MF_PAPERCOLLISION objects from getting stuck in walls.
|
||||||
//#define PAPER_COLLISIONCORRECTION
|
//#define PAPER_COLLISIONCORRECTION
|
||||||
|
|
|
||||||
|
|
@ -324,7 +324,7 @@ typedef struct
|
||||||
*/
|
*/
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
// The original eight, plus one.
|
char * lumpname; ///< Lump name can be really long
|
||||||
char lvlttl[22]; ///< Level name without "Zone". (21 character limit instead of 32, 21 characters can display on screen max anyway)
|
char lvlttl[22]; ///< Level name without "Zone". (21 character limit instead of 32, 21 characters can display on screen max anyway)
|
||||||
char subttl[33]; ///< Subtitle for level
|
char subttl[33]; ///< Subtitle for level
|
||||||
char zonttl[22]; ///< "ZONE" replacement name
|
char zonttl[22]; ///< "ZONE" replacement name
|
||||||
|
|
@ -415,6 +415,7 @@ typedef struct
|
||||||
#define LF2_VISITNEEDED (1<<3) ///< Not available in Time Attack modes until you visit the level
|
#define LF2_VISITNEEDED (1<<3) ///< Not available in Time Attack modes until you visit the level
|
||||||
|
|
||||||
extern mapheader_t* mapheaderinfo[NUMMAPS];
|
extern mapheader_t* mapheaderinfo[NUMMAPS];
|
||||||
|
extern INT32 nummapheaders;
|
||||||
|
|
||||||
// This could support more, but is that a good idea?
|
// This could support more, but is that a good idea?
|
||||||
// Keep in mind that it may encourage people making overly long cups just because they "can", and would be a waste of memory.
|
// Keep in mind that it may encourage people making overly long cups just because they "can", and would be a waste of memory.
|
||||||
|
|
|
||||||
|
|
@ -1837,9 +1837,6 @@ void F_StartTitleScreen(void)
|
||||||
titlemapcameraref = NULL;
|
titlemapcameraref = NULL;
|
||||||
gamemap = titlemap;
|
gamemap = titlemap;
|
||||||
|
|
||||||
if (!mapheaderinfo[gamemap-1])
|
|
||||||
P_AllocMapHeader(gamemap-1);
|
|
||||||
|
|
||||||
maptol = mapheaderinfo[gamemap-1]->typeoflevel;
|
maptol = mapheaderinfo[gamemap-1]->typeoflevel;
|
||||||
globalweather = mapheaderinfo[gamemap-1]->weather;
|
globalweather = mapheaderinfo[gamemap-1]->weather;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3021,7 +3021,7 @@ void G_DoPlayDemo(char *defdemoname)
|
||||||
R_ExecuteSetViewSize();
|
R_ExecuteSetViewSize();
|
||||||
|
|
||||||
P_SetRandSeed(randseed);
|
P_SetRandSeed(randseed);
|
||||||
G_InitNew(demoflags & DF_ENCORE, G_BuildMapName(gamemap), true, true, false); // Doesn't matter whether you reset or not here, given changes to resetplayer.
|
G_InitNew(demoflags & DF_ENCORE, gamemap, true, true, false); // Doesn't matter whether you reset or not here, given changes to resetplayer.
|
||||||
|
|
||||||
for (i = 0; i < MAXPLAYERS; i++)
|
for (i = 0; i < MAXPLAYERS; i++)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
66
src/g_game.c
66
src/g_game.c
|
|
@ -185,6 +185,7 @@ struct quake quake;
|
||||||
|
|
||||||
// Map Header Information
|
// Map Header Information
|
||||||
mapheader_t* mapheaderinfo[NUMMAPS] = {NULL};
|
mapheader_t* mapheaderinfo[NUMMAPS] = {NULL};
|
||||||
|
INT32 nummapheaders;
|
||||||
|
|
||||||
// Kart cup definitions
|
// Kart cup definitions
|
||||||
cupheader_t *kartcupheaders = NULL;
|
cupheader_t *kartcupheaders = NULL;
|
||||||
|
|
@ -644,20 +645,14 @@ void G_SetGameModified(boolean silent, boolean major)
|
||||||
Command_ExitGame_f();
|
Command_ExitGame_f();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Builds an original game map name from a map number.
|
/** Returns the map lump name for a map number.
|
||||||
* The complexity is due to MAPA0-MAPZZ.
|
|
||||||
*
|
*
|
||||||
* \param map Map number.
|
* \param map Map number.
|
||||||
* \return Pointer to a static buffer containing the desired map name.
|
* \return Map name.
|
||||||
* \sa M_MapNumber
|
* \sa G_MapNumber
|
||||||
*/
|
*/
|
||||||
const char *G_BuildMapName(INT32 map)
|
const char *G_BuildMapName(INT32 map)
|
||||||
{
|
{
|
||||||
static char mapname[10] = "MAPXX"; // internal map name (wad resource name)
|
|
||||||
|
|
||||||
I_Assert(map >= 0);
|
|
||||||
I_Assert(map <= NUMMAPS);
|
|
||||||
|
|
||||||
if (map == 0) // hack???
|
if (map == 0) // hack???
|
||||||
{
|
{
|
||||||
if (gamestate == GS_TITLESCREEN)
|
if (gamestate == GS_TITLESCREEN)
|
||||||
|
|
@ -669,19 +664,35 @@ const char *G_BuildMapName(INT32 map)
|
||||||
map = G_RandMap(G_TOLFlag(cv_newgametype.value), map, false, 0, false, NULL)+1;
|
map = G_RandMap(G_TOLFlag(cv_newgametype.value), map, false, 0, false, NULL)+1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (map < 100)
|
if (map > 0 && map <= NUMMAPS && mapheaderinfo[map - 1] != NULL)
|
||||||
sprintf(&mapname[3], "%.2d", map);
|
{
|
||||||
|
return mapheaderinfo[map - 1]->lumpname;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mapname[3] = (char)('A' + (char)((map - 100) / 36));
|
return NULL;
|
||||||
if ((map - 100) % 36 < 10)
|
}
|
||||||
mapname[4] = (char)('0' + (char)((map - 100) % 36));
|
}
|
||||||
else
|
|
||||||
mapname[4] = (char)('A' + (char)((map - 100) % 36) - 10);
|
/** Returns the map number for map lump name.
|
||||||
mapname[5] = '\0';
|
*
|
||||||
|
* \param name Map name;
|
||||||
|
* \return Map number.
|
||||||
|
* \sa G_BuildMapName
|
||||||
|
*/
|
||||||
|
INT32 G_MapNumber(const char * name)
|
||||||
|
{
|
||||||
|
INT32 map;
|
||||||
|
|
||||||
|
for (map = 0; map < nummapheaders; ++map)
|
||||||
|
{
|
||||||
|
if (strcasecmp(mapheaderinfo[map]->lumpname, name) == 0)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return mapname;
|
return map + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Clips the console player's mouse aiming to the current view.
|
/** Clips the console player's mouse aiming to the current view.
|
||||||
|
|
@ -4318,7 +4329,7 @@ cleanup:
|
||||||
// Can be called by the startup code or the menu task,
|
// Can be called by the startup code or the menu task,
|
||||||
// consoleplayer, displayplayers[], playeringame[] should be set.
|
// consoleplayer, displayplayers[], playeringame[] should be set.
|
||||||
//
|
//
|
||||||
void G_DeferedInitNew(boolean pencoremode, const char *mapname, INT32 pickedchar, UINT8 ssplayers, boolean FLS)
|
void G_DeferedInitNew(boolean pencoremode, INT32 map, INT32 pickedchar, UINT8 ssplayers, boolean FLS)
|
||||||
{
|
{
|
||||||
INT32 i;
|
INT32 i;
|
||||||
UINT16 color = SKINCOLOR_NONE;
|
UINT16 color = SKINCOLOR_NONE;
|
||||||
|
|
@ -4350,18 +4361,17 @@ void G_DeferedInitNew(boolean pencoremode, const char *mapname, INT32 pickedchar
|
||||||
CV_StealthSetValue(&cv_playercolor[0], color);
|
CV_StealthSetValue(&cv_playercolor[0], color);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mapname)
|
D_MapChange(map, gametype, pencoremode, true, 1, false, FLS);
|
||||||
{
|
|
||||||
D_MapChange(M_MapNumber(mapname[3], mapname[4]), gametype, pencoremode, true, 1, false, FLS);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// This is the map command interpretation something like Command_Map_f
|
// This is the map command interpretation something like Command_Map_f
|
||||||
//
|
//
|
||||||
// called at: map cmd execution, doloadgame, doplaydemo
|
// called at: map cmd execution, doloadgame, doplaydemo
|
||||||
void G_InitNew(UINT8 pencoremode, const char *mapname, boolean resetplayer, boolean skipprecutscene, boolean FLS)
|
void G_InitNew(UINT8 pencoremode, INT32 map, boolean resetplayer, boolean skipprecutscene, boolean FLS)
|
||||||
{
|
{
|
||||||
|
const char * mapname = G_BuildMapName(map);
|
||||||
|
|
||||||
INT32 i;
|
INT32 i;
|
||||||
|
|
||||||
(void)FLS;
|
(void)FLS;
|
||||||
|
|
@ -4427,7 +4437,7 @@ void G_InitNew(UINT8 pencoremode, const char *mapname, boolean resetplayer, bool
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
gamemap = (INT16)M_MapNumber(mapname[3], mapname[4]); // get xx out of MAPxx
|
gamemap = map;
|
||||||
|
|
||||||
// gamemap changed; we assume that its map header is always valid,
|
// gamemap changed; we assume that its map header is always valid,
|
||||||
// so make it so
|
// so make it so
|
||||||
|
|
@ -4455,7 +4465,7 @@ void G_InitNew(UINT8 pencoremode, const char *mapname, boolean resetplayer, bool
|
||||||
{
|
{
|
||||||
char *title = G_BuildMapTitle(gamemap);
|
char *title = G_BuildMapTitle(gamemap);
|
||||||
|
|
||||||
CON_LogMessage(va(M_GetText("Map is now \"%s"), G_BuildMapName(gamemap)));
|
CON_LogMessage(va(M_GetText("Map is now \"%s"), mapname));
|
||||||
if (title)
|
if (title)
|
||||||
{
|
{
|
||||||
CON_LogMessage(va(": %s", title));
|
CON_LogMessage(va(": %s", title));
|
||||||
|
|
@ -4705,12 +4715,12 @@ INT32 G_FindMapByNameOrCode(const char *mapname, char **realmapnamep)
|
||||||
|
|
||||||
if (mapnamelen == 2)/* maybe two digit code */
|
if (mapnamelen == 2)/* maybe two digit code */
|
||||||
{
|
{
|
||||||
if (( newmapnum = M_MapNumber(mapname[0], mapname[1]) ))
|
if (( newmapnum = G_MapNumber(mapname) ))
|
||||||
usemapcode = true;
|
usemapcode = true;
|
||||||
}
|
}
|
||||||
else if (mapnamelen == 5 && strnicmp(mapname, "MAP", 3) == 0)
|
else if (mapnamelen == 5 && strnicmp(mapname, "MAP", 3) == 0)
|
||||||
{
|
{
|
||||||
if (( newmapnum = M_MapNumber(mapname[3], mapname[4]) ))
|
if (( newmapnum = G_MapNumber(mapname) ))
|
||||||
usemapcode = true;
|
usemapcode = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -81,8 +81,8 @@ extern consvar_t cv_resume;
|
||||||
#define MAXPLMOVE (50)
|
#define MAXPLMOVE (50)
|
||||||
#define SLOWTURNTICS (6)
|
#define SLOWTURNTICS (6)
|
||||||
|
|
||||||
// build an internal map name MAPxx from map number
|
|
||||||
const char *G_BuildMapName(INT32 map);
|
const char *G_BuildMapName(INT32 map);
|
||||||
|
INT32 G_MapNumber(const char *mapname);
|
||||||
|
|
||||||
void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer);
|
void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer);
|
||||||
|
|
||||||
|
|
@ -123,7 +123,7 @@ extern INT32 localaiming[MAXSPLITSCREENPLAYERS]; // should be an angle_t but sig
|
||||||
void G_ChangePlayerReferences(mobj_t *oldmo, mobj_t *newmo);
|
void G_ChangePlayerReferences(mobj_t *oldmo, mobj_t *newmo);
|
||||||
void G_DoReborn(INT32 playernum);
|
void G_DoReborn(INT32 playernum);
|
||||||
void G_PlayerReborn(INT32 player, boolean betweenmaps);
|
void G_PlayerReborn(INT32 player, boolean betweenmaps);
|
||||||
void G_InitNew(UINT8 pencoremode, const char *mapname, boolean resetplayer,
|
void G_InitNew(UINT8 pencoremode, INT32 map, boolean resetplayer,
|
||||||
boolean skipprecutscene, boolean FLS);
|
boolean skipprecutscene, boolean FLS);
|
||||||
char *G_BuildMapTitle(INT32 mapnum);
|
char *G_BuildMapTitle(INT32 mapnum);
|
||||||
|
|
||||||
|
|
@ -161,7 +161,7 @@ void G_SpawnPlayer(INT32 playernum);
|
||||||
|
|
||||||
// Can be called by the startup code or M_Responder.
|
// Can be called by the startup code or M_Responder.
|
||||||
// A normal game starts at map 1, but a warp test can start elsewhere
|
// A normal game starts at map 1, but a warp test can start elsewhere
|
||||||
void G_DeferedInitNew(boolean pencoremode, const char *mapname, INT32 pickedchar,
|
void G_DeferedInitNew(boolean pencoremode, INT32 map, INT32 pickedchar,
|
||||||
UINT8 ssplayers, boolean FLS);
|
UINT8 ssplayers, boolean FLS);
|
||||||
void G_DoLoadLevel(boolean resetplayer);
|
void G_DoLoadLevel(boolean resetplayer);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2387,6 +2387,7 @@ static int lib_sChangeMusic(lua_State *L)
|
||||||
|
|
||||||
#else
|
#else
|
||||||
const char *music_name = luaL_checkstring(L, 1);
|
const char *music_name = luaL_checkstring(L, 1);
|
||||||
|
UINT32 position, prefadems, fadeinms;
|
||||||
boolean looping = (boolean)lua_opttrueboolean(L, 2);
|
boolean looping = (boolean)lua_opttrueboolean(L, 2);
|
||||||
player_t *player = NULL;
|
player_t *player = NULL;
|
||||||
UINT16 music_flags = 0;
|
UINT16 music_flags = 0;
|
||||||
|
|
|
||||||
|
|
@ -7767,7 +7767,7 @@ static void M_StartGrandPrix(INT32 choice)
|
||||||
|
|
||||||
G_DeferedInitNew(
|
G_DeferedInitNew(
|
||||||
false,
|
false,
|
||||||
G_BuildMapName(grandprixinfo.cup->levellist[0] + 1),
|
grandprixinfo.cup->levellist[0] + 1,
|
||||||
(UINT8)(cv_chooseskin.value - 1),
|
(UINT8)(cv_chooseskin.value - 1),
|
||||||
(UINT8)(cv_splitplayers.value - 1),
|
(UINT8)(cv_splitplayers.value - 1),
|
||||||
false
|
false
|
||||||
|
|
@ -8066,7 +8066,7 @@ static void M_ChooseTimeAttack(INT32 choice)
|
||||||
else
|
else
|
||||||
G_RecordDemo(nameofdemo);
|
G_RecordDemo(nameofdemo);
|
||||||
|
|
||||||
G_DeferedInitNew(false, G_BuildMapName(cv_nextmap.value), (UINT8)(cv_chooseskin.value-1), 0, false);
|
G_DeferedInitNew(false, cv_nextmap.value, (UINT8)(cv_chooseskin.value-1), 0, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void M_HandleStaffReplay(INT32 choice)
|
static void M_HandleStaffReplay(INT32 choice)
|
||||||
|
|
|
||||||
26
src/m_misc.c
26
src/m_misc.c
|
|
@ -168,32 +168,6 @@ boolean takescreenshot = false; // Take a screenshot this tic
|
||||||
|
|
||||||
moviemode_t moviemode = MM_OFF;
|
moviemode_t moviemode = MM_OFF;
|
||||||
|
|
||||||
/** Returns the map number for a map identified by the last two characters in
|
|
||||||
* its name.
|
|
||||||
*
|
|
||||||
* \param first The first character after MAP.
|
|
||||||
* \param second The second character after MAP.
|
|
||||||
* \return The map number, or 0 if no map corresponds to these characters.
|
|
||||||
* \sa G_BuildMapName
|
|
||||||
*/
|
|
||||||
INT32 M_MapNumber(char first, char second)
|
|
||||||
{
|
|
||||||
if (isdigit(first))
|
|
||||||
{
|
|
||||||
if (isdigit(second))
|
|
||||||
return ((INT32)first - '0') * 10 + ((INT32)second - '0');
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isalpha(first))
|
|
||||||
return 0;
|
|
||||||
if (!isalnum(second))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return 100 + ((INT32)tolower(first) - 'a') * 36 + (isdigit(second) ? ((INT32)second - '0') :
|
|
||||||
((INT32)tolower(second) - 'a') + 10);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ==========================================================================
|
// ==========================================================================
|
||||||
// FILE INPUT / OUTPUT
|
// FILE INPUT / OUTPUT
|
||||||
// ==========================================================================
|
// ==========================================================================
|
||||||
|
|
|
||||||
|
|
@ -42,8 +42,6 @@ void M_StopMovie(void);
|
||||||
// the file where game vars and settings are saved
|
// the file where game vars and settings are saved
|
||||||
#define CONFIGFILENAME "kartconfig.cfg"
|
#define CONFIGFILENAME "kartconfig.cfg"
|
||||||
|
|
||||||
INT32 M_MapNumber(char first, char second);
|
|
||||||
|
|
||||||
boolean FIL_WriteFile(char const *name, const void *source, size_t length);
|
boolean FIL_WriteFile(char const *name, const void *source, size_t length);
|
||||||
size_t FIL_ReadFileTag(char const *name, UINT8 **buffer, INT32 tag);
|
size_t FIL_ReadFileTag(char const *name, UINT8 **buffer, INT32 tag);
|
||||||
#define FIL_ReadFile(n, b) FIL_ReadFileTag(n, b, PU_STATIC)
|
#define FIL_ReadFile(n, b) FIL_ReadFileTag(n, b, PU_STATIC)
|
||||||
|
|
|
||||||
|
|
@ -4381,7 +4381,7 @@ boolean P_LoadGame(INT16 mapoverride)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Only do this after confirming savegame is ok
|
// Only do this after confirming savegame is ok
|
||||||
G_DeferedInitNew(false, G_BuildMapName(gamemap), savedata.skin, 0, true);
|
G_DeferedInitNew(false, gamemap, savedata.skin, 0, true);
|
||||||
COM_BufAddText("dummyconsvar 1\n"); // G_DeferedInitNew doesn't do this
|
COM_BufAddText("dummyconsvar 1\n"); // G_DeferedInitNew doesn't do this
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -427,8 +427,10 @@ void P_AllocMapHeader(INT16 i)
|
||||||
if (!mapheaderinfo[i])
|
if (!mapheaderinfo[i])
|
||||||
{
|
{
|
||||||
mapheaderinfo[i] = Z_Malloc(sizeof(mapheader_t), PU_STATIC, NULL);
|
mapheaderinfo[i] = Z_Malloc(sizeof(mapheader_t), PU_STATIC, NULL);
|
||||||
|
mapheaderinfo[i]->lumpname = NULL;
|
||||||
mapheaderinfo[i]->flickies = NULL;
|
mapheaderinfo[i]->flickies = NULL;
|
||||||
mapheaderinfo[i]->grades = NULL;
|
mapheaderinfo[i]->grades = NULL;
|
||||||
|
nummapheaders++;
|
||||||
}
|
}
|
||||||
P_ClearSingleMapHeaderInfo(i + 1);
|
P_ClearSingleMapHeaderInfo(i + 1);
|
||||||
}
|
}
|
||||||
|
|
@ -4473,7 +4475,7 @@ boolean P_AddWadFile(const char *wadfilename)
|
||||||
INT16 num;
|
INT16 num;
|
||||||
if (name[5]!='\0')
|
if (name[5]!='\0')
|
||||||
continue;
|
continue;
|
||||||
num = (INT16)M_MapNumber(name[3], name[4]);
|
num = (INT16)G_MapNumber(name);
|
||||||
|
|
||||||
// we want to record whether this map exists. if it doesn't have a header, we can assume it's not relephant
|
// we want to record whether this map exists. if it doesn't have a header, we can assume it's not relephant
|
||||||
if (num <= NUMMAPS && mapheaderinfo[num-1])
|
if (num <= NUMMAPS && mapheaderinfo[num-1])
|
||||||
|
|
|
||||||
|
|
@ -2665,8 +2665,8 @@ static void Command_Tunes_f(void)
|
||||||
tunearg = mapheaderinfo[gamemap-1]->musname;
|
tunearg = mapheaderinfo[gamemap-1]->musname;
|
||||||
track = mapheaderinfo[gamemap-1]->mustrack;
|
track = mapheaderinfo[gamemap-1]->mustrack;
|
||||||
}
|
}
|
||||||
else if (!tunearg[2] && toupper(tunearg[0]) >= 'A' && toupper(tunearg[0]) <= 'Z')
|
else if (isalpha(tunearg[0]))
|
||||||
tunenum = (UINT16)M_MapNumber(tunearg[0], tunearg[1]);
|
tunenum = (UINT16)G_MapNumber(tunearg);
|
||||||
|
|
||||||
if (tunenum && tunenum >= 1036)
|
if (tunenum && tunenum >= 1036)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@
|
||||||
#ifdef SCANTHINGS
|
#ifdef SCANTHINGS
|
||||||
#include "p_setup.h" // P_ScanThings
|
#include "p_setup.h" // P_ScanThings
|
||||||
#endif
|
#endif
|
||||||
#include "m_misc.h" // M_MapNumber
|
#include "g_game.h" // G_MapNumber
|
||||||
|
|
||||||
#ifdef HWRENDER
|
#ifdef HWRENDER
|
||||||
#include "hardware/hw_main.h"
|
#include "hardware/hw_main.h"
|
||||||
|
|
@ -278,7 +278,7 @@ static inline void W_LoadDehackedLumps(UINT16 wadnum, boolean mainfile)
|
||||||
const char *name = lump_p->name;
|
const char *name = lump_p->name;
|
||||||
if (name[0] == 'M' && name[1] == 'A' && name[2] == 'P' && name[5]=='\0')
|
if (name[0] == 'M' && name[1] == 'A' && name[2] == 'P' && name[5]=='\0')
|
||||||
{
|
{
|
||||||
INT16 mapnum = (INT16)M_MapNumber(name[3], name[4]);
|
INT16 mapnum = (INT16)G_MapNumber(name);
|
||||||
P_ScanThings(mapnum, wadnum, lump + ML_THINGS);
|
P_ScanThings(mapnum, wadnum, lump + ML_THINGS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue