Skip to content

Commit

Permalink
Implements SidebarSide for ScenarioClass.
Browse files Browse the repository at this point in the history
  • Loading branch information
CCHyper committed Dec 6, 2022
1 parent e5618ca commit d4caede
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/extensions/scenario/scenarioext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
* @author: CCHyper
*/
ScenarioClassExtension::ScenarioClassExtension(const ScenarioClass *this_ptr) :
GlobalExtensionClass(this_ptr)
GlobalExtensionClass(this_ptr),
SidebarSide(SIDE_NONE)
{
//if (this_ptr) EXT_DEBUG_TRACE("ScenarioClassExtension::ScenarioClassExtension - 0x%08X\n", (uintptr_t)(ThisPtr));

Expand Down
6 changes: 5 additions & 1 deletion src/extensions/scenario/scenarioext.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@ class ScenarioClassExtension final : public GlobalExtensionClass<ScenarioClass>
virtual const char *Full_Name() const override { return "Scenario"; }

void Init_Clear();
bool Read_INI(CCINIClass &ini);

public:

/**
* x
*/
SideType SidebarSide;
};
15 changes: 13 additions & 2 deletions src/extensions/scenario/scenarioext_hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,16 @@ static bool Read_Scenario_INI_Init_Side(CCINIClass &ini)

ASSERT_FATAL_PRINT(Scen->SpeechSide != SIDE_NONE && Scen->SpeechSide < Sides.Count(), "Invalid \"SpeechSide\" value in [Basic] section!");

/**
* #issue-309
*
* Read sidebar side override.
*/
ScenExtension->SidebarSide = housetype->Side;
ScenExtension->SidebarSide = ini.Get_SideType("Basic", "SidebarSide", ScenExtension->SidebarSide);

ASSERT_FATAL_PRINT(ScenExtension->SidebarSide != SIDE_NONE && ScenExtension->SidebarSide < Sides.Count(), "Invalid \"SidebarSide\" value in [Basic] section!");

} else {

#if 0
Expand All @@ -510,6 +520,7 @@ static bool Read_Scenario_INI_Init_Side(CCINIClass &ini)

Scen->IsGDI = (unsigned char)housetype->Side & 0xFF;
Scen->SpeechSide = housetype->Side;
ScenExtension->SidebarSide = housetype->Side;

}

Expand Down Expand Up @@ -546,9 +557,9 @@ static bool Read_Scenario_INI_Prep_For_Side()
#endif

DEBUG_INFO("Calling Prep_For_Side()...\n");
if (!Prep_For_Side(housetype->Side)) {
if (!Prep_For_Side(ScenExtension->SidebarSide)) {

DEBUG_WARNING("Prep_For_Side(%d) failed! Trying with side 0...\n", housetype->Side);
DEBUG_WARNING("Prep_For_Side(%d) failed! Trying with side 0...\n", ScenExtension->SidebarSide);

/**
* Try once again but with the Side 0 (GDI) assets.
Expand Down
4 changes: 3 additions & 1 deletion src/vinifera/vinifera_saveload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@
#include "addon.h"
#include "ccini.h"

#include "scenarioext.h"


/**
* Constant of the current build version number. This number should be
Expand Down Expand Up @@ -509,7 +511,7 @@ bool Vinifera_Get_All(IStream *pStm, bool load_net)
* Fetch the houses side type and use this to decide which assets to load.
*/
DEBUG_INFO("About to call Prep_For_Side()...\n");
if (!Prep_For_Side(housetype->Side)) {
if (!Prep_For_Side(ScenExtension->SidebarSide)) {
DEBUG_WARNING("Prep_For_Side(%d) failed! Trying with side '%d'...\n", housetype->Side);

/**
Expand Down

0 comments on commit d4caede

Please sign in to comment.