Skip to content

Commit 1d64d37

Browse files
committed
Implements IsShowBriefing to ScenarioClass, allowing the briefing statement to be shown before the mission start.
1 parent 850f118 commit 1d64d37

4 files changed

Lines changed: 79 additions & 8 deletions

File tree

src/extensions/scenario/scenarioext.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@
4242
* @author: CCHyper
4343
*/
4444
ScenarioClassExtension::ScenarioClassExtension(const ScenarioClass *this_ptr) :
45-
GlobalExtensionClass(this_ptr)
45+
GlobalExtensionClass(this_ptr),
46+
IsShowBriefing(false)
4647
{
4748
//if (this_ptr) EXT_DEBUG_TRACE("ScenarioClassExtension::ScenarioClassExtension - 0x%08X\n", (uintptr_t)(ThisPtr));
4849

@@ -184,13 +185,17 @@ bool ScenarioClassExtension::Read_INI(CCINIClass &ini)
184185
{
185186
//EXT_DEBUG_TRACE("ScenarioClassExtension::Read_INI - 0x%08X\n", (uintptr_t)(This()));
186187

188+
static const char * const BASIC = "Basic";
189+
187190
/**
188191
* #issue-123
189192
*
190193
* Fetch additional tutorial message data (if present) from the scenario.
191194
*/
192195
Read_Tutorial_INI(ini, true);
193196

197+
IsShowBriefing = ini.Get_Bool(BASIC, "ShowBriefing", IsShowBriefing);
198+
194199
return true;
195200
}
196201

src/extensions/scenario/scenarioext.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,8 @@ class ScenarioClassExtension final : public GlobalExtensionClass<ScenarioClass>
5656
bool Read_Tutorial_INI(CCINIClass &ini, bool log = false);
5757

5858
public:
59-
59+
/**
60+
* Should the mission briefing statement be shown before the mission starts?
61+
*/
62+
bool IsShowBriefing;
6063
};

src/extensions/scenario/scenarioext_hooks.cpp

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
#include "ccfile.h"
3939
#include "ccini.h"
4040
#include "addon.h"
41+
#include "wwmouse.h"
42+
#include "restate.h"
4143
#include "fatal.h"
4244
#include "debughandler.h"
4345
#include "asserthandler.h"
@@ -46,6 +48,66 @@
4648
#include "hooker_macros.h"
4749

4850

51+
/**
52+
* Show the mission briefing statement.
53+
*
54+
* @author: CCHyper
55+
*/
56+
static void Scenario_Show_Mission_Briefing()
57+
{
58+
char buffer[25];
59+
60+
/**
61+
* If there's no briefing movie, restate the mission at the beginning.
62+
*/
63+
if (Scen->BriefMovie != VQ_NONE) {
64+
std::snprintf(buffer, sizeof(buffer), "%s.VQA", Movies[Scen->BriefMovie]);
65+
}
66+
67+
/**
68+
* Briefings are only displayed in normal games when no briefing video is found.
69+
*
70+
* #issue-28
71+
*
72+
* Also, Show the briefing if the scenario has been flagged to show it.
73+
*/
74+
if (Session.Type == GAME_NORMAL && (Scen->BriefMovie == VQ_NONE || !CCFileClass(buffer).Is_Available() || ScenExtension->IsShowBriefing)) {
75+
76+
/**
77+
* Make sure the mouse is visible before showing the restatement.
78+
*/
79+
while (WWMouse->Get_Mouse_State()) {
80+
WWMouse->Show_Mouse();
81+
}
82+
83+
/**
84+
* Show the mission briefing screen.
85+
*/
86+
Restate_Mission(Scen);
87+
}
88+
}
89+
90+
/**
91+
* This patch replaces the section of code in Start_Scenario() that shows
92+
* the mission briefing statement if no briefing video is found.
93+
*
94+
* @author: CCHyper
95+
*/
96+
DECLARE_PATCH(_Start_Scenario_BriefMovie_RestateMission_Patch)
97+
{
98+
/**
99+
* Show the mission briefing statement.
100+
*/
101+
Scenario_Show_Mission_Briefing();
102+
103+
/**
104+
* Continue to showing the Dropship Loadout menu (if enabled).
105+
*/
106+
_asm { mov eax, 0x007E2438 } // Scen
107+
JMP_REG(ecx, 0x005DB3B1);
108+
}
109+
110+
49111
/**
50112
* Process additions to the Rules data from the input file.
51113
*
@@ -178,4 +240,5 @@ void ScenarioClassExtension_Hooks()
178240
Patch_Jump(0x005DC9D4, &_Do_Win_Skip_MPlayer_Score_Screen_Patch);
179241
Patch_Jump(0x005DCD92, &_Do_Lose_Skip_MPlayer_Score_Screen_Patch);
180242
Patch_Jump(0x005DD8D5, &_Read_Scenario_INI_MPlayer_INI_Patch);
243+
Patch_Jump(0x005DB37F, &_Start_Scenario_BriefMovie_RestateMission_Patch);
181244
}

src/extensions/scenario/scenarioext_init.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@
4242

4343
/**
4444
* Patch for including the extended class members in the creation process.
45-
*
45+
*
4646
* @warning: Do not touch this unless you know what you are doing!
47-
*
47+
*
4848
* @author: CCHyper
4949
*/
5050
DECLARE_PATCH(_ScenarioClass_Constructor_Patch)
@@ -77,9 +77,9 @@ DECLARE_PATCH(_ScenarioClass_Constructor_Patch)
7777

7878
/**
7979
* Patch for including the extended class members in the destruction process.
80-
*
80+
*
8181
* @warning: Do not touch this unless you know what you are doing!
82-
*
82+
*
8383
* @author: CCHyper
8484
*/
8585
DECLARE_PATCH(_ScenarioClass_Destructor_Patch)
@@ -103,9 +103,9 @@ DECLARE_PATCH(_ScenarioClass_Destructor_Patch)
103103

104104
/**
105105
* Patch for including the extended class members when initialsing the scenario data.
106-
*
106+
*
107107
* @warning: Do not touch this unless you know what you are doing!
108-
*
108+
*
109109
* @author: CCHyper
110110
*/
111111
DECLARE_PATCH(_ScenarioClass_Init_Clear_Patch)

0 commit comments

Comments
 (0)