From 6f4e3807286e802bd6f5b2c62f8ca16aeafa9d1a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 2 May 2021 13:12:24 +0200 Subject: [PATCH] - migrated RR's cutscene definitions. Also turned several level-specific init options into map flags or map parameters. --- source/core/g_mapinfo.cpp | 13 +- source/core/mapinfo.h | 1 + source/core/precache.cpp | 15 +++ source/core/precache.h | 1 + source/games/duke/src/player_r.cpp | 20 +-- source/games/duke/src/premap.cpp | 6 +- source/games/duke/src/premap_r.cpp | 31 ----- .../redneck.redneck/engine/rmapinfo.txt | 124 ++++++++++++++++++ .../static/filter/redneck/engine/engine.def | 3 +- .../static/zscript/games/duke/ui/screens.zs | 16 +-- 10 files changed, 166 insertions(+), 64 deletions(-) create mode 100644 wadsrc/static/filter/redneck.redneck/engine/rmapinfo.txt diff --git a/source/core/g_mapinfo.cpp b/source/core/g_mapinfo.cpp index c899cb35d..5e5a38d65 100644 --- a/source/core/g_mapinfo.cpp +++ b/source/core/g_mapinfo.cpp @@ -550,6 +550,12 @@ DEFINE_MAP_OPTION(rr_startsound, false) info->rr_startsound = parse.sc.Number; } +DEFINE_MAP_OPTION(rr_mamaspawn, false) +{ + parse.ParseAssign(); + parse.sc.MustGetNumber(); + info->rr_mamaspawn = parse.sc.Number; +} //========================================================================== // @@ -583,6 +589,7 @@ MapFlagHandlers[] = { "secretexitoverride", MITYPE_SETFLAG, LEVEL_SECRETEXITOVERRIDE, 0, -1 }, { "clearinventory", MITYPE_SETFLAG, LEVEL_CLEARINVENTORY, 0, -1 }, { "clearweapons", MITYPE_SETFLAG, LEVEL_CLEARWEAPONS, 0, -1 }, + { "forcenoeog", MITYPE_SETFLAG, LEVEL_FORCENOEOG, 0, -1 }, { "rrra_hulkspawn", MITYPE_SETFLAGG,LEVEL_RR_HULKSPAWN, 0, GAMEFLAG_RRRA }, { "rr_clearmoonshine", MITYPE_SETFLAGG,LEVEL_RR_CLEARMOONSHINE, 0, GAMEFLAG_RR }, @@ -884,7 +891,6 @@ void FMapInfoParser::ParseEpisodeInfo () void FMapInfoParser::ParseCutsceneInfo() { - unsigned int i; FString map; FString pic; FString name; @@ -923,7 +929,7 @@ void FMapInfoParser::ParseCutsceneInfo() else if (!ParseCloseBrace()) { // Unknown - sc.ScriptMessage("Unknown property '%s' found in episode definition\n", sc.String); + sc.ScriptMessage("Unknown property '%s' found in cutscene definition\n", sc.String); SkipToNext(); } else @@ -943,7 +949,6 @@ void FMapInfoParser::ParseCutsceneInfo() void FMapInfoParser::ParseGameInfo() { - unsigned int i; FString map; FString pic; FString name; @@ -974,7 +979,7 @@ void FMapInfoParser::ParseGameInfo() else if (!ParseCloseBrace()) { // Unknown - sc.ScriptMessage("Unknown property '%s' found in episode definition\n", sc.String); + sc.ScriptMessage("Unknown property '%s' found in gameinfo definition\n", sc.String); SkipToNext(); } else diff --git a/source/core/mapinfo.h b/source/core/mapinfo.h index 7b51c9566..d12ffb783 100644 --- a/source/core/mapinfo.h +++ b/source/core/mapinfo.h @@ -150,6 +150,7 @@ struct MapRecord // game specific stuff int rr_startsound = 0; + int rr_mamaspawn = 5; const char* LabelName() const { diff --git a/source/core/precache.cpp b/source/core/precache.cpp index ed660c7cd..bced0634f 100644 --- a/source/core/precache.cpp +++ b/source/core/precache.cpp @@ -39,7 +39,9 @@ #include "hw_material.h" #include "gamestruct.h" #include "gamecontrol.h" +#include "texturemanager.h" #include "glbackend/gl_models.h" +#include "mapinfo.h" BEGIN_BLD_NS extern short voxelIndex[MAXTILES]; @@ -128,6 +130,19 @@ void precacheMarkedTiles() int dapalnum = pair->Key >> 32; doprecache(dapicnum, dapalnum); } + + // Cache everything the map explicitly declares. + TMap cachetexmap; + for (auto& tex : currentLevel->PrecacheTextures) cachetexmap.Insert(tex, true); + + decltype(cachetexmap)::Iterator it2(cachetexmap); + decltype(cachetexmap)::Pair* pair2; + while (it2.NextPair(pair2)) + { + auto tex = TexMan.FindGameTexture(pair2->Key, ETextureType::Any); + if (tex) PrecacheTex(tex, 0); + } + cachemap.Clear(); } diff --git a/source/core/precache.h b/source/core/precache.h index bcf40813f..fab410227 100644 --- a/source/core/precache.h +++ b/source/core/precache.h @@ -2,5 +2,6 @@ void PrecacheHardwareTextures(int nTile); void markTileForPrecache(int tilenum, int palnum); +void markTextureForPrecache(const char* texname); void markVoxelForPrecache(int voxnum); void precacheMarkedTiles(); diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index 8403e5922..148df22b6 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -1464,26 +1464,8 @@ int doincrements_r(struct player_struct* p) { if (!wupass) { - short snd; + int snd = currentLevel->rr_startsound ? currentLevel->rr_startsound : 391; wupass = 1; - switch (currentLevel->levelNumber) - { - default: snd = 391; break; - case makelevelnum(0, 0): snd = isRRRA() ? 63 : 391; break; - case makelevelnum(0, 1): snd = 64; break; - case makelevelnum(0, 2): snd = 77; break; - case makelevelnum(0, 3): snd = 80; break; - case makelevelnum(0, 4): snd = 102; break; - case makelevelnum(0, 5): snd = 103; break; - case makelevelnum(0, 6): snd = 104; break; - case makelevelnum(1, 0): snd = 105; break; - case makelevelnum(1, 1): snd = 176; break; - case makelevelnum(1, 2): snd = 177; break; - case makelevelnum(1, 3): snd = 198; break; - case makelevelnum(1, 4): snd = 230; break; - case makelevelnum(1, 5): snd = 255; break; - case makelevelnum(1, 6): snd = 283; break; - } S_PlayActorSound(snd, pact); } else if (PlayClock > 1024) diff --git a/source/games/duke/src/premap.cpp b/source/games/duke/src/premap.cpp index 698b9351e..b5aebdc50 100644 --- a/source/games/duke/src/premap.cpp +++ b/source/games/duke/src/premap.cpp @@ -36,6 +36,7 @@ Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms #include "automap.h" #include "dukeactor.h" #include "interpolate.h" +#include "precache.h" BEGIN_DUKE_NS @@ -1003,7 +1004,10 @@ bool setnextmap(bool checksecretexit) { if (ud.secretlevel > 0) { - map = FindMapByIndex(currentLevel->cluster, ud.secretlevel); + // allow overriding the secret exit destination to make episode compilation easier with maps containing secret exits. + if (currentLevel->flags & LEVEL_SECRETEXITOVERRIDE) map = FindNextSecretMap(currentLevel); + if (!map) map = FindMapByIndex(currentLevel->cluster, ud.secretlevel); + if (map) { from_bonus = FindNextMap(currentLevel); diff --git a/source/games/duke/src/premap_r.cpp b/source/games/duke/src/premap_r.cpp index 7b0af18db..ca85c3083 100644 --- a/source/games/duke/src/premap_r.cpp +++ b/source/games/duke/src/premap_r.cpp @@ -366,37 +366,6 @@ static void cachegoodsprites(void) for (i = SMALLSMOKE; i < (SMALLSMOKE + 4); i++) tloadtile(i); - if (isRRRA() && currentLevel->levelNumber == makelevelnum(0, 4)) - { - tloadtile(RRTILE2577); - } - if (!isRRRA() && currentLevel->levelNumber == makelevelnum(1, 2)) - { - tloadtile(RRTILE3190); - tloadtile(RRTILE3191); - tloadtile(RRTILE3192); - tloadtile(RRTILE3144); - tloadtile(RRTILE3139); - tloadtile(RRTILE3132); - tloadtile(RRTILE3120); - tloadtile(RRTILE3121); - tloadtile(RRTILE3122); - tloadtile(RRTILE3123); - tloadtile(RRTILE3124); - } - if (lastlevel) - { - i = isRRRA() ? UFO1_RRRA : UFO1_RR; - tloadtile(i); - i = UFO2; - tloadtile(i); - i = UFO3; - tloadtile(i); - i = UFO4; - tloadtile(i); - i = UFO5; - tloadtile(i); - } } //--------------------------------------------------------------------------- diff --git a/wadsrc/static/filter/redneck.redneck/engine/rmapinfo.txt b/wadsrc/static/filter/redneck.redneck/engine/rmapinfo.txt new file mode 100644 index 000000000..dcbd6a8d9 --- /dev/null +++ b/wadsrc/static/filter/redneck.redneck/engine/rmapinfo.txt @@ -0,0 +1,124 @@ +// Cutscene definitions for RR + +cluster 1 +{ + outro + { + function = RRCutscenes.BuildE1End + } +} + +cluster 2 +{ + outro + { + function = RRCutscenes.BuildE2End + } +} + +map { 1, 1 } +{ + interbackground = "BONUSPIC01" + rr_startsound = 391 // fixme: allow symbolic names +} + +map { 1, 2 } +{ + interbackground = "BONUSPIC02" + rr_startsound = 64 +} + +map { 1, 3 } +{ + interbackground = "BONUSPIC03" + rr_startsound = 77 +} + +map { 1, 4 } +{ + interbackground = "BONUSPIC04" + rr_startsound = 80 +} + +map { 1, 5 } +{ + interbackground = "BONUSPIC05" + rr_startsound = 102 +} + +map { 1, 6 } +{ + interbackground = "BONUSPIC06" + rr_startsound = 103 +} + +map { 1, 7 } +{ + interbackground = "BONUSPIC07" + rr_startsound = 104 +} + +map { 2, 1 } +{ + interbackground = "BONUSPIC08" + rr_startsound = 105 +} + +map { 2, 2 } +{ + interbackground = "BONUSPIC09" + rr_startsound = 176 + clearweapons +} + +map { 2, 3 } +{ + interbackground = "BONUSPIC10" + rr_startsound = 177 + PrecacheTextures = "#03190","#03191","#03192","#03144","#03139","#03132","#03120","#03121","#03122","#03123","#03124" +} + +map { 2, 4 } +{ + interbackground = "BONUSPIC11" + rr_startsound = 198 +} + +map { 2, 5 } +{ + interbackground = "BONUSPIC12" + rr_startsound = 230 +} + +map { 2, 6 } +{ + interbackground = "BONUSPIC13" + rr_startsound = 255 +} + +map { 2, 7 } +{ + interbackground = "BONUSPIC14" + rr_startsound = 283 + PrecacheTextures = "UFO1", "UFO2", "UFO3", "UFO4", "UFO5" +} + +map { 2, 8 } +{ + interbackground = "BONUSPIC14" + rr_startsound = 391 +} + +cutscenes +{ + loadscreen + { + function = DukeCutscenes.BuildLoading // identical with Duke's + } +} + +gameinfo +{ + summaryscreen = RRCutscenes.BuildSPSummary + mpsummaryscreen = DukeCutscenes.BuildMPSummary // identical with Duke's +} diff --git a/wadsrc/static/filter/redneck/engine/engine.def b/wadsrc/static/filter/redneck/engine/engine.def index 1ec0d03d2..23d74da39 100644 --- a/wadsrc/static/filter/redneck/engine/engine.def +++ b/wadsrc/static/filter/redneck/engine/engine.def @@ -1,5 +1,5 @@ // Cutscene definitions for RR - +/* definecutscene intro { function RRCutscenes.BuildIntro @@ -34,3 +34,4 @@ definecutscene loading definecutscene summary RRCutscenes.BuildSPSummary definecutscene mpsummary DukeCutscenes.BuildMPSummary // identical with Duke's +*/ \ No newline at end of file diff --git a/wadsrc/static/zscript/games/duke/ui/screens.zs b/wadsrc/static/zscript/games/duke/ui/screens.zs index 6228a19b8..440e05221 100644 --- a/wadsrc/static/zscript/games/duke/ui/screens.zs +++ b/wadsrc/static/zscript/games/duke/ui/screens.zs @@ -822,16 +822,16 @@ class RRLevelSummaryScreen : SummaryScreenBase { Super.Init(dofadeout? (fadein | fadeout) : fadein); SetParameters(m, s); - String s; - if (level.flags & MapRecord.USERMAP) - s = "BONUSPIC01"; - else if (!Raze.isRRRA()) - s = String.Format("BONUSPIC%02d", 1 + clamp((level.levelNumber / 1000) * 7 + (level.levelNumber % 1000), 0, 13)); - else - s = String.Format("LEVELMAP%02d", 1 + clamp((level.levelNumber / 1000) * 7 + (level.levelNumber % 1000), 0, 13)); + String basetex = level.InterBackground; + if (basetex.length() == 0) + { + let cluster = level.GetCluster(); + if (cluster != null) basetex = cluster.InterBackground; + } + if (basetex.length() == 0) basetex = "BONUSPIC01"; lastmapname = level.DisplayName(); - texBg = TexMan.CheckForTexture(s); + texBg = TexMan.CheckForTexture(basetex); return self; }