From 524c96cff0878961efba11c32d20b360fb73f0fe Mon Sep 17 00:00:00 2001 From: Fabian Greffrath Date: Fri, 9 Dec 2022 19:02:31 +0100 Subject: [PATCH] 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 --- src/u_mapinfo.c | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/src/u_mapinfo.c b/src/u_mapinfo.c index 65cf8909..9f0cd1f9 100644 --- a/src/u_mapinfo.c +++ b/src/u_mapinfo.c @@ -668,15 +668,6 @@ static int ParseStandardProperty(u_scanner_t* s, mapentry_t *mape) U_GetNextToken(s, true); } 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); return status; } @@ -758,6 +749,34 @@ void U_ParseMapInfo(boolean is_default, const char *buffer, size_t length) 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. for(i = 0; i < U_mapinfo.mapcount; i++) {