Skip to content

Commit

Permalink
Implements IsShowBriefing to ScenarioClass, allowing the briefing sta…
Browse files Browse the repository at this point in the history
…tement to be shown before the mission start.
  • Loading branch information
CCHyper committed Dec 26, 2023
1 parent 5dd59cd commit 0273b28
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 7 deletions.
4 changes: 3 additions & 1 deletion src/extensions/scenario/scenarioext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions src/extensions/scenario/scenarioext.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,9 @@ class ScenarioClassExtension final : public GlobalExtensionClass<ScenarioClass>
* Can ice get destroyed when hit by certain weapons?
*/
bool IsIceDestruction;

/**
* Should the mission briefing statement be shown before the mission starts?
*/
bool IsShowBriefing;
};
63 changes: 63 additions & 0 deletions src/extensions/scenario/scenarioext_hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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.
*
Expand Down Expand Up @@ -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);
}
12 changes: 6 additions & 6 deletions src/extensions/scenario/scenarioext_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 0273b28

Please sign in to comment.