mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-01-17 04:02:50 +00:00
Fix map warp
This commit is contained in:
parent
37c345c7eb
commit
2520b87f76
1 changed files with 14 additions and 41 deletions
55
src/g_game.c
55
src/g_game.c
|
|
@ -4703,55 +4703,28 @@ void G_FreeMapSearch(mapsearchfreq_t *freq, INT32 freqc)
|
|||
|
||||
INT32 G_FindMapByNameOrCode(const char *mapname, char **realmapnamep)
|
||||
{
|
||||
boolean usemapcode = false;
|
||||
|
||||
INT32 newmapnum;
|
||||
|
||||
size_t mapnamelen;
|
||||
|
||||
char *p;
|
||||
|
||||
mapnamelen = strlen(mapname);
|
||||
/* Now detect map number in base 10, which no one asked for. */
|
||||
newmapnum = strtol(mapname, &p, 10);
|
||||
|
||||
if (mapnamelen == 2)/* maybe two digit code */
|
||||
if (*p == '\0')/* we got it */
|
||||
{
|
||||
if (( newmapnum = G_MapNumber(mapname) ))
|
||||
usemapcode = true;
|
||||
}
|
||||
else if (mapnamelen == 5 && strnicmp(mapname, "MAP", 3) == 0)
|
||||
{
|
||||
if (( newmapnum = G_MapNumber(mapname) ))
|
||||
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)
|
||||
if (newmapnum < 1 || newmapnum > nummapheaders)
|
||||
return 0;
|
||||
|
||||
if (realmapnamep)
|
||||
(*realmapnamep) = G_BuildMapTitle(newmapnum);
|
||||
}
|
||||
else
|
||||
{
|
||||
newmapnum = G_MapNumber(mapname);
|
||||
|
||||
if (newmapnum > nummapheaders)
|
||||
return G_FindMap(mapname, realmapnamep, NULL, NULL);
|
||||
}
|
||||
|
||||
if (realmapnamep)
|
||||
(*realmapnamep) = G_BuildMapTitle(newmapnum);
|
||||
|
||||
return newmapnum;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue