From 59b567689a8cc971c43e513fc5ae5a692516b441 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 1 Oct 2024 16:38:14 +0200 Subject: [PATCH] make the broken ID24 levelnums work somehow so that Legacy of Rust's intermissions play. --- src/gamedata/g_mapinfo.cpp | 4 ++++ src/gamedata/g_mapinfo.h | 1 + src/gamedata/umapinfo.cpp | 14 ++++++++++---- src/wi_stuff.cpp | 4 ++-- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/gamedata/g_mapinfo.cpp b/src/gamedata/g_mapinfo.cpp index 6cd4fdcdf5..eb65e69433 100644 --- a/src/gamedata/g_mapinfo.cpp +++ b/src/gamedata/g_mapinfo.cpp @@ -2401,9 +2401,13 @@ static void SetLevelNum (level_info_t *info, int num) for (unsigned int i = 0; i < wadlevelinfos.Size(); ++i) { if (wadlevelinfos[i].levelnum == num) + { wadlevelinfos[i].levelnum = 0; + wadlevelinfos[i].broken_id24_levelnum = 0; + } } info->levelnum = num; + info->broken_id24_levelnum = num; // at least make it work - somehow. } //========================================================================== diff --git a/src/gamedata/g_mapinfo.h b/src/gamedata/g_mapinfo.h index b07e6e442f..8b2706ed06 100644 --- a/src/gamedata/g_mapinfo.h +++ b/src/gamedata/g_mapinfo.h @@ -324,6 +324,7 @@ struct FExitText struct level_info_t { int levelnum; + int broken_id24_levelnum; FString MapName; FString NextMap; diff --git a/src/gamedata/umapinfo.cpp b/src/gamedata/umapinfo.cpp index 50757e7343..d6a2c47ee8 100644 --- a/src/gamedata/umapinfo.cpp +++ b/src/gamedata/umapinfo.cpp @@ -58,6 +58,7 @@ struct UMapEntry char intermusic[9] = ""; int partime = 0; int nointermission = 0; + int id24_levelnum = 0; // note that this one's semantics are massively screwed up. Only to be used for ID24-style intermissions. }; static TArray Maps; @@ -124,7 +125,7 @@ static int ParseLumpName(FScanner &scanner, char *buffer) // // ----------------------------------------------- -static int ParseStandardProperty(FScanner &scanner, UMapEntry *mape) +static int ParseStandardProperty(FScanner &scanner, UMapEntry *mape, int *id24_levelnum) { // find the next line with content. // this line is no property. @@ -254,6 +255,7 @@ static int ParseStandardProperty(FScanner &scanner, UMapEntry *mape) epi.mEpisodeMap = mape->MapName; epi.mPicName = split[0]; epi.mNoSkill = false; + mape->id24_levelnum = *id24_levelnum = 1; unsigned i; for (i = 0; i < AllEpisodes.Size(); i++) @@ -324,15 +326,16 @@ static int ParseStandardProperty(FScanner &scanner, UMapEntry *mape) // // ----------------------------------------------- -static int ParseMapEntry(FScanner &scanner, UMapEntry *val) +static int ParseMapEntry(FScanner &scanner, UMapEntry *val, int *id24_levelnum) { scanner.MustGetToken(TK_Identifier); val->MapName = scanner.String; + val->id24_levelnum = ++(*id24_levelnum); scanner.MustGetToken('{'); while(!scanner.CheckToken('}')) { - ParseStandardProperty(scanner, val); + ParseStandardProperty(scanner, val, id24_levelnum); } return 1; } @@ -348,12 +351,13 @@ int ParseUMapInfo(int lumpnum) FScanner scanner(lumpnum); unsigned int i; + int id24_levelnum = 1; while (scanner.GetToken()) { scanner.TokenMustBe(TK_Map); UMapEntry parsed; - ParseMapEntry(scanner, &parsed); + ParseMapEntry(scanner, &parsed, &id24_levelnum); // Endpic overrides level exits. if (parsed.endpic[0]) @@ -455,6 +459,8 @@ void CommitUMapinfo(level_info_t *defaultinfo) if (map.exitpic[0]) levelinfo->ExitPic = map.exitpic; if (map.enteranim[0]) levelinfo->EnterAnim = map.enteranim; if (map.exitanim[0]) levelinfo->ExitAnim = map.exitanim; + levelinfo->broken_id24_levelnum = map.id24_levelnum; + Printf("%s: id24 levelnum = %d\n", map.MapName, map.id24_levelnum); /* UMAPINFO's intermusic is for the text screen, not the summary. if (map.intermusic[0]) { diff --git a/src/wi_stuff.cpp b/src/wi_stuff.cpp index 8a5c7945cc..3af0a7829a 100644 --- a/src/wi_stuff.cpp +++ b/src/wi_stuff.cpp @@ -302,7 +302,7 @@ private: auto* li = FindLevelInfo(state != StatCount ? wbs->next.GetChars() : wbs->current.GetChars()); if (!li) return false; - if (li->levelnum != condition.param) + if (li->broken_id24_levelnum != condition.param) return false; break; } @@ -311,7 +311,7 @@ private: auto* li = FindLevelInfo(state != StatCount ? wbs->next.GetChars() : wbs->current.GetChars()); if (!li) return false; - if (li->levelnum <= condition.param) + if (li->broken_id24_levelnum <= condition.param) return false; break; }