provide a default map progression if neither nextmap nor endpic are set (#835)

* fix and extend the code to provide a default map progression if neither nextmap nor endpic are set

* use strcasecmp instead of stricmp

* Update u_mapinfo.c

* Update u_mapinfo.c
This commit is contained in:
Fabian Greffrath 2022-12-09 19:02:31 +01:00 committed by GitHub
parent b1ec01f4bf
commit 524c96cff0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -668,15 +668,6 @@ static int ParseStandardProperty(u_scanner_t* s, mapentry_t *mape)
U_GetNextToken(s, true); U_GetNextToken(s, true);
} while (U_CheckToken(s, ',')); } while (U_CheckToken(s, ','));
if (!mape->nextmap[0] && !mape->endpic[0])
{
int ep, map;
G_ValidateMapName(mape->mapname, &ep, &map);
strcpy(mape->nextmap, MAPNAME(ep, map + 1));
}
free(pname); free(pname);
return status; return status;
} }
@ -758,6 +749,34 @@ void U_ParseMapInfo(boolean is_default, const char *buffer, size_t length)
continue; continue;
} }
// Set default level progression here to simplify the checks elsewhere.
// Doing this lets us skip all normal code for this if nothing has been defined.
if (parsed.endpic[0] && (strcmp(parsed.endpic, "-") != 0))
{
parsed.nextmap[0] = 0;
}
else if (!parsed.nextmap[0] && !parsed.endpic[0])
{
if (!strcasecmp(parsed.mapname, "MAP30"))
strcpy(parsed.endpic, "$CAST");
else if (!strcasecmp(parsed.mapname, "E1M8"))
strcpy(parsed.endpic, gamemode == retail ? "CREDIT" : "HELP2");
else if (!strcasecmp(parsed.mapname, "E2M8"))
strcpy(parsed.endpic, "VICTORY2");
else if (!strcasecmp(parsed.mapname, "E3M8"))
strcpy(parsed.endpic, "$BUNNY");
else if (!strcasecmp(parsed.mapname, "E4M8"))
strcpy(parsed.endpic, "ENDPIC");
else
{
int ep, map;
G_ValidateMapName(parsed.mapname, &ep, &map);
strcpy(parsed.nextmap, MAPNAME(ep, map + 1));
}
}
// Does this property already exist? If yes, replace it. // Does this property already exist? If yes, replace it.
for(i = 0; i < U_mapinfo.mapcount; i++) for(i = 0; i < U_mapinfo.mapcount; i++)
{ {