From 0273b28d122dcb8628d2a726d8ab694c55d4d9d8 Mon Sep 17 00:00:00 2001 From: CCHyper <73803386+CCHyper@users.noreply.github.com> Date: Mon, 14 Jun 2021 01:50:21 +0100 Subject: [PATCH] Implements IsShowBriefing to ScenarioClass, allowing the briefing statement to be shown before the mission start. --- src/extensions/scenario/scenarioext.cpp | 4 +- src/extensions/scenario/scenarioext.h | 5 ++ src/extensions/scenario/scenarioext_hooks.cpp | 63 +++++++++++++++++++ src/extensions/scenario/scenarioext_init.cpp | 12 ++-- 4 files changed, 77 insertions(+), 7 deletions(-) diff --git a/src/extensions/scenario/scenarioext.cpp b/src/extensions/scenario/scenarioext.cpp index 846a62001..c5592c988 100644 --- a/src/extensions/scenario/scenarioext.cpp +++ b/src/extensions/scenario/scenarioext.cpp @@ -55,7 +55,8 @@ */ ScenarioClassExtension::ScenarioClassExtension(const ScenarioClass *this_ptr) : GlobalExtensionClass(this_ptr), - IsIceDestruction(true) + IsIceDestruction(true), + IsShowBriefing(false) { //if (this_ptr) EXT_DEBUG_TRACE("ScenarioClassExtension::ScenarioClassExtension - 0x%08X\n", (uintptr_t)(ThisPtr)); @@ -204,6 +205,7 @@ bool ScenarioClassExtension::Read_INI(CCINIClass &ini) static const char * const BASIC = "Basic"; IsIceDestruction = ini.Get_Bool(BASIC, "IceDestructionEnabled", IsIceDestruction); + IsShowBriefing = ini.Get_Bool(BASIC, "ShowBriefing", IsShowBriefing); /** * #issue-123 diff --git a/src/extensions/scenario/scenarioext.h b/src/extensions/scenario/scenarioext.h index 73783b439..35982b6d1 100644 --- a/src/extensions/scenario/scenarioext.h +++ b/src/extensions/scenario/scenarioext.h @@ -63,4 +63,9 @@ class ScenarioClassExtension final : public GlobalExtensionClass * Can ice get destroyed when hit by certain weapons? */ bool IsIceDestruction; + + /** + * Should the mission briefing statement be shown before the mission starts? + */ + bool IsShowBriefing; }; diff --git a/src/extensions/scenario/scenarioext_hooks.cpp b/src/extensions/scenario/scenarioext_hooks.cpp index 239dd6ffd..95819bb29 100644 --- a/src/extensions/scenario/scenarioext_hooks.cpp +++ b/src/extensions/scenario/scenarioext_hooks.cpp @@ -37,6 +37,8 @@ #include "ccfile.h" #include "ccini.h" #include "addon.h" +#include "wwmouse.h" +#include "restate.h" #include "fatal.h" #include "debughandler.h" #include "asserthandler.h" @@ -45,6 +47,66 @@ #include "hooker_macros.h" +/** + * Show the mission briefing statement. + * + * @author: CCHyper + */ +static void Scenario_Show_Mission_Briefing() +{ + char buffer[25]; + + /** + * If there's no briefing movie, restate the mission at the beginning. + */ + if (Scen->BriefMovie != VQ_NONE) { + std::snprintf(buffer, sizeof(buffer), "%s.VQA", Movies[Scen->BriefMovie]); + } + + /** + * Briefings are only displayed in normal games when no briefing video is found. + * + * #issue-28 + * + * Also, Show the briefing if the scenario has been flagged to show it. + */ + if (Session.Type == GAME_NORMAL && (Scen->BriefMovie == VQ_NONE || !CCFileClass(buffer).Is_Available() || ScenExtension->IsShowBriefing)) { + + /** + * Make sure the mouse is visible before showing the restatement. + */ + while (WWMouse->Get_Mouse_State()) { + WWMouse->Show_Mouse(); + } + + /** + * Show the mission briefing screen. + */ + Restate_Mission(Scen); + } +} + +/** + * This patch replaces the section of code in Start_Scenario() that shows + * the mission briefing statement if no briefing video is found. + * + * @author: CCHyper + */ +DECLARE_PATCH(_Start_Scenario_BriefMovie_RestateMission_Patch) +{ + /** + * Show the mission briefing statement. + */ + Scenario_Show_Mission_Briefing(); + + /** + * Continue to showing the Dropship Loadout menu (if enabled). + */ + _asm { mov eax, 0x007E2438 } // Scen + JMP_REG(ecx, 0x005DB3B1); +} + + /** * Process additions to the Rules data from the input file. * @@ -177,4 +239,5 @@ void ScenarioClassExtension_Hooks() Patch_Jump(0x005DC9D4, &_Do_Win_Skip_MPlayer_Score_Screen_Patch); Patch_Jump(0x005DCD92, &_Do_Lose_Skip_MPlayer_Score_Screen_Patch); Patch_Jump(0x005DD8D5, &_Read_Scenario_INI_MPlayer_INI_Patch); + Patch_Jump(0x005DB37F, &_Start_Scenario_BriefMovie_RestateMission_Patch); } diff --git a/src/extensions/scenario/scenarioext_init.cpp b/src/extensions/scenario/scenarioext_init.cpp index 335e8d314..c62c8a8cd 100644 --- a/src/extensions/scenario/scenarioext_init.cpp +++ b/src/extensions/scenario/scenarioext_init.cpp @@ -42,9 +42,9 @@ /** * Patch for including the extended class members in the creation process. - * + * * @warning: Do not touch this unless you know what you are doing! - * + * * @author: CCHyper */ DECLARE_PATCH(_ScenarioClass_Constructor_Patch) @@ -77,9 +77,9 @@ DECLARE_PATCH(_ScenarioClass_Constructor_Patch) /** * Patch for including the extended class members in the destruction process. - * + * * @warning: Do not touch this unless you know what you are doing! - * + * * @author: CCHyper */ DECLARE_PATCH(_ScenarioClass_Destructor_Patch) @@ -103,9 +103,9 @@ DECLARE_PATCH(_ScenarioClass_Destructor_Patch) /** * Patch for including the extended class members when initialsing the scenario data. - * + * * @warning: Do not touch this unless you know what you are doing! - * + * * @author: CCHyper */ DECLARE_PATCH(_ScenarioClass_Init_Clear_Patch)