From 93bfc35ad6f7a163da3081ddd20a9e1292c1243f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 2 May 2021 00:58:54 +0200 Subject: [PATCH] - use the volumes to find the starting maps for the menu and the clusters for the cutscenes. --- source/core/gamestruct.h | 2 +- source/core/mapinfo.h | 2 -- source/core/menu/razemenu.cpp | 27 +++++++++++++++++++++++++-- source/core/parsefuncs.h | 2 +- source/games/blood/src/blood.h | 2 -- source/games/blood/src/d_menu.cpp | 17 ----------------- source/games/blood/src/levels.cpp | 11 ++++++----- source/games/duke/src/d_menu.cpp | 21 +-------------------- source/games/exhumed/src/d_menu.cpp | 7 ------- source/games/exhumed/src/exhumed.cpp | 6 ++++++ source/games/exhumed/src/exhumed.h | 1 - source/games/sw/src/d_menu.cpp | 17 +---------------- source/games/sw/src/scrip2.cpp | 6 ++++++ wadsrc/static/menudef.txt | 8 ++++---- 14 files changed, 51 insertions(+), 78 deletions(-) diff --git a/source/core/gamestruct.h b/source/core/gamestruct.h index 4b8b95e28..9f9cd59cb 100644 --- a/source/core/gamestruct.h +++ b/source/core/gamestruct.h @@ -64,7 +64,7 @@ struct GameInterface virtual void MenuSound(EMenuSounds snd) {} virtual bool CanSave() { return true; } virtual void CustomMenuSelection(int menu, int item) {} - virtual bool StartGame(FNewGameStartup& gs) { return false; } + virtual bool StartGame(FNewGameStartup& gs) { return true; } virtual FSavegameInfo GetSaveSig() { return { "", 0, 0}; } virtual double SmallFontScale() { return 1; } virtual void SerializeGameState(FSerializer& arc) {} diff --git a/source/core/mapinfo.h b/source/core/mapinfo.h index 67d560f32..35e451d54 100644 --- a/source/core/mapinfo.h +++ b/source/core/mapinfo.h @@ -108,8 +108,6 @@ struct VolumeRecord // episodes FString name; FString subtitle; int index = -1; - CutsceneDef intro; - CutsceneDef outro; int flags = 0; int shortcut = 0; }; diff --git a/source/core/menu/razemenu.cpp b/source/core/menu/razemenu.cpp index 0e3416d47..556f9b63d 100644 --- a/source/core/menu/razemenu.cpp +++ b/source/core/menu/razemenu.cpp @@ -83,8 +83,31 @@ bool help_disabled; FNewGameStartup NewGameStartupInfo; + //FNewGameStartup NewGameStartupInfo; +static bool DoStartGame(FNewGameStartup& gs) +{ + auto vol = FindVolume(gs.Episode); + if (!vol) return false; + + if (isShareware() && (vol->flags & VF_SHAREWARELOCK)) + { + M_StartMessage(GStrings("SHAREWARELOCK"), 1, NAME_None); + return false; + } + + auto map = FindMapByName(vol->startmap); + if (!map) return false; + soundEngine->StopAllChannels(); + + gi->StartGame(gs); // play game specific effects (like Duke/RR/SW's voice lines when starting a game.) + + DeferedStartGame(map, gs.Skill); + return true; +} + + bool M_SetSpecialMenu(FName& menu, int param) { @@ -115,14 +138,14 @@ bool M_SetSpecialMenu(FName& menu, int param) case NAME_Startgame: case NAME_StartgameNoSkill: - menu = NAME_Startgame; NewGameStartupInfo.Skill = param; if (menu == NAME_StartgameNoSkill) { + menu = NAME_Startgame; NewGameStartupInfo.Episode = param; NewGameStartupInfo.Skill = 1; } - if (gi->StartGame(NewGameStartupInfo)) + if (DoStartGame(NewGameStartupInfo)) { M_ClearMenus(); int ep = NewGameStartupInfo.Episode; diff --git a/source/core/parsefuncs.h b/source/core/parsefuncs.h index ef844c2d9..58aed981e 100644 --- a/source/core/parsefuncs.h +++ b/source/core/parsefuncs.h @@ -120,7 +120,7 @@ void parseDefineCutscene(FScanner& sc, FScriptPosition& pos) while (!sc.FoundEndBrace(eblockend)) { sc.MustGetString(); - auto volume = MustFindVolume(vol); + auto volume = MustFindCluster(vol); if (sc.Compare("intro")) parseCutscene(sc, volume->intro); else if (sc.Compare("outro")) parseCutscene(sc, volume->outro); else if (sc.Compare("flags")) sc.GetNumber(volume->flags); diff --git a/source/games/blood/src/blood.h b/source/games/blood/src/blood.h index 5c253f635..fafc74b70 100644 --- a/source/games/blood/src/blood.h +++ b/source/games/blood/src/blood.h @@ -78,7 +78,6 @@ extern int blood_globalflags; void QuitGame(void); void PreloadCache(void); -void StartLevel(MapRecord *gameOptions); void ProcessFrame(void); void ScanINIFiles(void); void EndLevel(); @@ -108,7 +107,6 @@ struct GameInterface : ::GameInterface void MenuOpened() override; void MenuClosed() override; bool CanSave() override; - bool StartGame(FNewGameStartup& gs) override; void QuitToTitle() override; FString GetCoordString() override; ReservedSpace GetReservedScreenSpace(int viewsize) override; diff --git a/source/games/blood/src/d_menu.cpp b/source/games/blood/src/d_menu.cpp index 4e0e35a59..7207729db 100644 --- a/source/games/blood/src/d_menu.cpp +++ b/source/games/blood/src/d_menu.cpp @@ -159,23 +159,6 @@ bool GameInterface::CanSave() return (gamestate == GS_LEVEL && gPlayer[myconnectindex].pXSprite->health != 0); } -bool GameInterface::StartGame(FNewGameStartup& gs) -{ - if (gs.Episode >= 1) - { - if (g_gameType & GAMEFLAG_SHAREWARE) - { - M_StartMessage(GStrings("BUYBLOOD"), 1, NAME_None); // unreachable because we do not support Blood SW versions yet. - return false; - } - } - - sfxKillAllSounds(); - auto map = FindMapByLevelNum(makelevelnum(gs.Episode, gs.Level)); - DeferedStartGame(map, gs.Skill); - return true; -} - FSavegameInfo GameInterface::GetSaveSig() { return { SAVESIG_BLD, MINSAVEVER_BLD, SAVEVER_BLD }; diff --git a/source/games/blood/src/levels.cpp b/source/games/blood/src/levels.cpp index 48195b93d..7d42fbe43 100644 --- a/source/games/blood/src/levels.cpp +++ b/source/games/blood/src/levels.cpp @@ -104,9 +104,9 @@ void levelLoadMapInfo(IniFile *pIni, MapRecord *pLevelInfo, const char *pzSectio pLevelInfo->weather = pIni->GetKeyInt(pzSection, "Weather", -0); for (int i = 0; i < kMaxMessages; i++) { - sprintf(buffer, "Message%d", i+1); - auto msg = pIni->GetKeyString(pzSection, buffer, ""); - pLevelInfo->AddMessage(i, msg); + sprintf(buffer, "Message%d", i + 1); + auto msg = pIni->GetKeyString(pzSection, buffer, ""); + pLevelInfo->AddMessage(i, msg); } } @@ -182,7 +182,7 @@ void levelLoadDefaults(void) if (cutALevel < 0) cutALevel = 0; int j; - for (j = 0; j < kMaxLevels; j++) + for (j = 1; j <= kMaxLevels; j++) { sprintf(buffer2, "Map%d", j); if (!BloodINI->KeyExists(buffer, buffer2)) @@ -190,10 +190,11 @@ void levelLoadDefaults(void) auto pLevelInfo = AllocateMap(); const char *pMap = BloodINI->GetKeyString(buffer, buffer2, NULL); CheckSectionAbend(pMap); - SetLevelNum(pLevelInfo, makelevelnum(i, j)); + SetLevelNum(pLevelInfo, makelevelnum(i-1, j-1)); pLevelInfo->cluster = i; pLevelInfo->mapindex = j; pLevelInfo->labelName = pMap; + if (j == 1) volume->startmap = pLevelInfo->labelName; pLevelInfo->fileName.Format("%s.map", pMap); levelLoadMapInfo(BloodINI, pLevelInfo, pMap, i, j); if (j == cutALevel) diff --git a/source/games/duke/src/d_menu.cpp b/source/games/duke/src/d_menu.cpp index 4f08d61fa..343483ee3 100644 --- a/source/games/duke/src/d_menu.cpp +++ b/source/games/duke/src/d_menu.cpp @@ -97,19 +97,8 @@ bool GameInterface::CanSave() bool GameInterface::StartGame(FNewGameStartup& gs) { - if (gs.Episode >= 1) - { - if (g_gameType & GAMEFLAG_SHAREWARE) - { - M_StartMessage(GStrings("BUYDUKE"), 1, NAME_None); - return false; - } - } - int32_t skillsound = PISTOL_BODYHIT; - soundEngine->StopAllChannels(); - static const short sounds_d[] = { JIBBED_ACTOR6, BONUS_SPEECH1, DUKE_GETWEAPON2, JIBBED_ACTOR5, JIBBED_ACTOR5 }; static const short sounds_r[] = { 427, 428, 196, 195, 197 }; if (gs.Skill >=0 && gs.Skill <= 5) skillsound = isRR()? sounds_r[gs.Skill] : sounds_d[gs.Skill]; @@ -126,15 +115,7 @@ bool GameInterface::StartGame(FNewGameStartup& gs) } Net_ClearFifo(); } - - auto map = FindMapByLevelNum(makelevelnum(gs.Episode, gs.Level)); - if (map) - { - DeferedStartGame(map, gs.Skill); - return true; - } - return false; - + return true; } FSavegameInfo GameInterface::GetSaveSig() diff --git a/source/games/exhumed/src/d_menu.cpp b/source/games/exhumed/src/d_menu.cpp index 4a7fdf88e..50d7282ef 100644 --- a/source/games/exhumed/src/d_menu.cpp +++ b/source/games/exhumed/src/d_menu.cpp @@ -72,13 +72,6 @@ void GameInterface::QuitToTitle() gameaction = ga_mainmenu; } -bool GameInterface::StartGame(FNewGameStartup& gs) -{ - auto map = FindMapByLevelNum(gs.Skill); // 0 is training, 1 is the regular game - the game does not have skill levels. - DeferedStartGame(map, 1, true); - return true; -} - FSavegameInfo GameInterface::GetSaveSig() { return { SAVESIG_PS, MINSAVEVER_PS, SAVEVER_PS }; diff --git a/source/games/exhumed/src/exhumed.cpp b/source/games/exhumed/src/exhumed.cpp index 95ca2ff4b..24f64b325 100644 --- a/source/games/exhumed/src/exhumed.cpp +++ b/source/games/exhumed/src/exhumed.cpp @@ -495,6 +495,12 @@ void GameInterface::app_init() #if 0 help_disabled = true; #endif + + auto vol0 = MustFindVolume(0); + auto vol1 = MustFindVolume(1); + if (vol0) vol0->startmap = "LEV1"; + if (vol1) vol1->startmap = "LEV0"; + // Create the global level table. Parts of the engine need it, even though the game itself does not. for (int i = 0; i <= 32; i++) { diff --git a/source/games/exhumed/src/exhumed.h b/source/games/exhumed/src/exhumed.h index ab0e531f5..110149ff5 100644 --- a/source/games/exhumed/src/exhumed.h +++ b/source/games/exhumed/src/exhumed.h @@ -221,7 +221,6 @@ struct GameInterface : ::GameInterface bool GenerateSavePic() override; void MenuOpened() override; void MenuSound(EMenuSounds snd) override; - bool StartGame(FNewGameStartup& gs) override; FSavegameInfo GetSaveSig() override; void SerializeGameState(FSerializer& arc); bool CanSave() override; diff --git a/source/games/sw/src/d_menu.cpp b/source/games/sw/src/d_menu.cpp index eff540c1c..e1425e8ec 100644 --- a/source/games/sw/src/d_menu.cpp +++ b/source/games/sw/src/d_menu.cpp @@ -102,22 +102,8 @@ bool GameInterface::StartGame(FNewGameStartup& gs) int handle = 0; int zero = 0; - MapRecord* map; - if (gs.Episode >= 1) - { - if (g_gameType & GAMEFLAG_SHAREWARE) - { - M_StartMessage(GStrings("BUYSW"), 1, NAME_None); - return false; - } - map = FindMapByLevelNum(5); - } - else - map = FindMapByLevelNum(1); - - if (!map) return false; CameraTestMode = false; - StopFX(); + StopAmbientSound(); //InitNewGame(); @@ -140,7 +126,6 @@ bool GameInterface::StartGame(FNewGameStartup& gs) } Net_ClearFifo(); } - DeferedStartGame(map, gs.Skill); return true; } diff --git a/source/games/sw/src/scrip2.cpp b/source/games/sw/src/scrip2.cpp index 8e6759179..4d8f8dfb1 100644 --- a/source/games/sw/src/scrip2.cpp +++ b/source/games/sw/src/scrip2.cpp @@ -807,6 +807,12 @@ void LoadCustomInfoFromScript(const char *filename) break; } } + auto vol0 = MustFindVolume(0); + auto vol1 = MustFindVolume(1); + auto map1 = FindMapByLevelNum(1); + auto map5 = FindMapByLevelNum(5); + if (vol0 && map1) vol0->startmap = map1->labelName; + if (vol1 && map5) vol1->startmap = map5->labelName; } END_SW_NS diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index f19c4ccea..26b796b32 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -66,9 +66,9 @@ LISTMENU "MainMenu" Position 160, 65 linespacing 22 ExhumedPlasma - ExhumedTextItem "$MNU_NEWGAME", "n", "StartGameNoSkill", 1 + ExhumedTextItem "$MNU_NEWGAME", "n", "StartGameNoSkill", 0 ExhumedTextItem "$MNU_LOADGAME", "l", "LoadGameMenu" - ExhumedTextItem "$TXT_EX_MAP00", "m", "StartGameNoSkill", 0 + ExhumedTextItem "$TXT_EX_MAP00", "m", "StartGameNoSkill", 1 ExhumedTextItem "$MNU_OPTIONS", "v", "OptionsMenu" ExhumedTextItem "$MNU_QUITGAME", "q", "QuitMenu" } @@ -137,9 +137,9 @@ LISTMENU "IngameMenu" Position 160, 65 linespacing 22 ExhumedLogo - ExhumedTextItem "$MNU_NEWGAME", "n", "StartGameNoSkill", 1 + ExhumedTextItem "$MNU_NEWGAME", "n", "StartGameNoSkill", 0 ExhumedTextItem "$MNU_LOADGAME", "l", "LoadGameMenu" - ExhumedTextItem "$TXT_EX_MAP00", "m", "StartGameNoSkill", 0 + ExhumedTextItem "$TXT_EX_MAP00", "m", "StartGameNoSkill", 1 ExhumedTextItem "$MNU_OPTIONS", "v", "OptionsMenu" ExhumedTextItem "$MNU_QUITGAME", "q", "QuitMenu" }