Merge branch 'warp-by-name' into 'master'
Properly fix the issue that !528 tried to; let the -warp parameter work with map name See merge request STJr/SRB2!596
This commit is contained in:
commit
01be810aee
34
src/d_main.c
34
src/d_main.c
|
@ -1169,26 +1169,6 @@ void D_SRB2Main(void)
|
||||||
if (M_CheckParm("-server") || dedicated)
|
if (M_CheckParm("-server") || dedicated)
|
||||||
netgame = server = true;
|
netgame = server = true;
|
||||||
|
|
||||||
if (M_CheckParm("-warp") && M_IsNextParm())
|
|
||||||
{
|
|
||||||
const char *word = M_GetNextParm();
|
|
||||||
char ch; // use this with sscanf to catch non-digits with
|
|
||||||
if (fastncmp(word, "MAP", 3)) // MAPxx name
|
|
||||||
pstartmap = M_MapNumber(word[3], word[4]);
|
|
||||||
else if (sscanf(word, "%d%c", &pstartmap, &ch) != 1) // a plain number
|
|
||||||
I_Error("Cannot warp to map %s (invalid map name)\n", word);
|
|
||||||
// Don't check if lump exists just yet because the wads haven't been loaded!
|
|
||||||
// Just do a basic range check here.
|
|
||||||
if (pstartmap < 1 || pstartmap > NUMMAPS)
|
|
||||||
I_Error("Cannot warp to map %d (out of range)\n", pstartmap);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!M_CheckParm("-server"))
|
|
||||||
G_SetGameModified(true);
|
|
||||||
autostart = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CONS_Printf("Z_Init(): Init zone memory allocation daemon. \n");
|
CONS_Printf("Z_Init(): Init zone memory allocation daemon. \n");
|
||||||
Z_Init();
|
Z_Init();
|
||||||
|
|
||||||
|
@ -1245,6 +1225,20 @@ void D_SRB2Main(void)
|
||||||
|
|
||||||
mainwadstally = packetsizetally; // technically not accurate atm, remember to port the two-stage -file process from kart in 2.2.x
|
mainwadstally = packetsizetally; // technically not accurate atm, remember to port the two-stage -file process from kart in 2.2.x
|
||||||
|
|
||||||
|
if (M_CheckParm("-warp") && M_IsNextParm())
|
||||||
|
{
|
||||||
|
const char *word = M_GetNextParm();
|
||||||
|
pstartmap = G_FindMapByNameOrCode(word, 0);
|
||||||
|
if (! pstartmap)
|
||||||
|
I_Error("Cannot find a map remotely named '%s'\n", word);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!M_CheckParm("-server"))
|
||||||
|
G_SetGameModified(true);
|
||||||
|
autostart = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
cht_Init();
|
cht_Init();
|
||||||
|
|
||||||
//---------------------------------------------------- READY SCREEN
|
//---------------------------------------------------- READY SCREEN
|
||||||
|
|
|
@ -1804,18 +1804,15 @@ static void Command_Map_f(void)
|
||||||
boolean newresetplayers;
|
boolean newresetplayers;
|
||||||
|
|
||||||
boolean mustmodifygame;
|
boolean mustmodifygame;
|
||||||
boolean usemapcode = false;
|
|
||||||
|
|
||||||
INT32 newmapnum;
|
INT32 newmapnum;
|
||||||
|
|
||||||
char * mapname;
|
char * mapname;
|
||||||
size_t mapnamelen;
|
|
||||||
char *realmapname = NULL;
|
char *realmapname = NULL;
|
||||||
|
|
||||||
INT32 newgametype = gametype;
|
INT32 newgametype = gametype;
|
||||||
|
|
||||||
INT32 d;
|
INT32 d;
|
||||||
char *p;
|
|
||||||
|
|
||||||
if (client && !IsPlayerAdmin(consoleplayer))
|
if (client && !IsPlayerAdmin(consoleplayer))
|
||||||
{
|
{
|
||||||
|
@ -1875,43 +1872,8 @@ static void Command_Map_f(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
mapname = ConcatCommandArgv(1, first_option);
|
mapname = ConcatCommandArgv(1, first_option);
|
||||||
mapnamelen = strlen(mapname);
|
|
||||||
|
|
||||||
if (mapnamelen == 2)/* maybe two digit code */
|
newmapnum = G_FindMapByNameOrCode(mapname, &realmapname);
|
||||||
{
|
|
||||||
if (( newmapnum = M_MapNumber(mapname[0], mapname[1]) ))
|
|
||||||
usemapcode = true;
|
|
||||||
}
|
|
||||||
else if (mapnamelen == 5 && strnicmp(mapname, "MAP", 3) == 0)
|
|
||||||
{
|
|
||||||
if (( newmapnum = M_MapNumber(mapname[3], mapname[4]) ) == 0)
|
|
||||||
{
|
|
||||||
CONS_Alert(CONS_ERROR, M_GetText("Invalid map code '%s'.\n"), mapname);
|
|
||||||
Z_Free(mapname);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
usemapcode = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!usemapcode)
|
|
||||||
{
|
|
||||||
/* Now detect map number in base 10, which no one asked for. */
|
|
||||||
newmapnum = strtol(mapname, &p, 10);
|
|
||||||
if (*p == '\0')/* we got it */
|
|
||||||
{
|
|
||||||
if (newmapnum < 1 || newmapnum > NUMMAPS)
|
|
||||||
{
|
|
||||||
CONS_Alert(CONS_ERROR, M_GetText("Invalid map number %d.\n"), newmapnum);
|
|
||||||
Z_Free(mapname);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
usemapcode = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
newmapnum = G_FindMap(mapname, &realmapname, NULL, NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (newmapnum == 0)
|
if (newmapnum == 0)
|
||||||
{
|
{
|
||||||
|
@ -1920,11 +1882,6 @@ static void Command_Map_f(void)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (usemapcode)
|
|
||||||
{
|
|
||||||
realmapname = G_BuildMapTitle(newmapnum);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mustmodifygame && option_force)
|
if (mustmodifygame && option_force)
|
||||||
{
|
{
|
||||||
G_SetGameModified(false);
|
G_SetGameModified(false);
|
||||||
|
|
55
src/g_game.c
55
src/g_game.c
|
@ -4536,6 +4536,61 @@ void G_FreeMapSearch(mapsearchfreq_t *freq, INT32 freqc)
|
||||||
Z_Free(freq);
|
Z_Free(freq);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
INT32 G_FindMapByNameOrCode(const char *mapname, char **realmapnamep)
|
||||||
|
{
|
||||||
|
boolean usemapcode = false;
|
||||||
|
|
||||||
|
INT32 newmapnum;
|
||||||
|
|
||||||
|
size_t mapnamelen;
|
||||||
|
|
||||||
|
char *p;
|
||||||
|
|
||||||
|
mapnamelen = strlen(mapname);
|
||||||
|
|
||||||
|
if (mapnamelen == 2)/* maybe two digit code */
|
||||||
|
{
|
||||||
|
if (( newmapnum = M_MapNumber(mapname[0], mapname[1]) ))
|
||||||
|
usemapcode = true;
|
||||||
|
}
|
||||||
|
else if (mapnamelen == 5 && strnicmp(mapname, "MAP", 3) == 0)
|
||||||
|
{
|
||||||
|
if (( newmapnum = M_MapNumber(mapname[3], mapname[4]) ))
|
||||||
|
usemapcode = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!usemapcode)
|
||||||
|
{
|
||||||
|
/* Now detect map number in base 10, which no one asked for. */
|
||||||
|
newmapnum = strtol(mapname, &p, 10);
|
||||||
|
if (*p == '\0')/* we got it */
|
||||||
|
{
|
||||||
|
if (newmapnum < 1 || newmapnum > NUMMAPS)
|
||||||
|
{
|
||||||
|
CONS_Alert(CONS_ERROR, M_GetText("Invalid map number %d.\n"), newmapnum);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
usemapcode = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
newmapnum = G_FindMap(mapname, realmapnamep, NULL, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (usemapcode)
|
||||||
|
{
|
||||||
|
/* we can't check mapheaderinfo for this hahahaha */
|
||||||
|
if (W_CheckNumForName(G_BuildMapName(newmapnum)) == LUMPERROR)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (realmapnamep)
|
||||||
|
(*realmapnamep) = G_BuildMapTitle(newmapnum);
|
||||||
|
}
|
||||||
|
|
||||||
|
return newmapnum;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// DEMO RECORDING
|
// DEMO RECORDING
|
||||||
//
|
//
|
||||||
|
|
|
@ -130,6 +130,9 @@ INT32 G_FindMap(const char *query, char **foundmapnamep,
|
||||||
mapsearchfreq_t **freqp, INT32 *freqc);
|
mapsearchfreq_t **freqp, INT32 *freqc);
|
||||||
void G_FreeMapSearch(mapsearchfreq_t *freq, INT32 freqc);
|
void G_FreeMapSearch(mapsearchfreq_t *freq, INT32 freqc);
|
||||||
|
|
||||||
|
/* Match map name by search + 2 digit map code or map number. */
|
||||||
|
INT32 G_FindMapByNameOrCode(const char *query, char **foundmapnamep);
|
||||||
|
|
||||||
// XMOD spawning
|
// XMOD spawning
|
||||||
mapthing_t *G_FindCTFStart(INT32 playernum);
|
mapthing_t *G_FindCTFStart(INT32 playernum);
|
||||||
mapthing_t *G_FindMatchStart(INT32 playernum);
|
mapthing_t *G_FindMatchStart(INT32 playernum);
|
||||||
|
|
Loading…
Reference in New Issue