Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions src/OpenSHC/Game/GameCore/Constructor_GameCore.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#include "../GameCore.func.hpp"

namespace OpenSHC {
namespace Game {

// FUNCTION: STRONGHOLDCRUSADER 0x0046B1F0
GameCore* GameCore::Constructor_GameCore()
{
this->currentMenuViewType = UI::Enums::MVT_NO_VIEW;
this->unknownAlwaysZero01 = 0;
this->currentlyInGameUnk_0xa4 = FALSE;
this->mapTimeInTicks = 0;
this->unknownAlwaysZero02 = 0;
this->field26_0x74 = 0;
this->field24_0x6c = 0;
this->isTimeHalted2 = 0;
this->unlockAllHistoricalCampaigns = 0;
this->unused1 = 0;
this->solitaryAltUDungeon = FALSE;
this->currentTrailType = TT_FIRST_EDITION;
this->field59_0xf8 = 0;
this->specialMultiplayerState = 0;
this->cheatModeFlag = FALSE;
this->solitaryAllBuildingsAreFree = FALSE;
this->unknownAlwaysZero = 0;
this->newPlayerID = 0;
this->activeMenuTab.buildMenuTab = UI::Enums::BMTT_CASTLE;
this->gameSpeedMultiplicator = 1;
this->forty = 40;
this->menuType7_MenuItemClickHandlerUnk = NULL;
this->countdown = 1;
this->uniqueGameObjectTracker = 1;
this->gameSpeedLevel = 40;
this->settingBubbleHelp = 1;
this->twohundred = 200;
this->field62_0x104 = 1;
this->field63_0x108 = 1;
this->field52_0xdc = 1;
this->scenarioProgress.progressCallToArms = 1;
this->scenarioProgress.progressSaladinsConquest = 6;
this->scenarioProgress.progressTheKingsCrusade = 11;
this->scenarioProgress.progressCrusaderStates = 16;
this->furthestMission = 33;
this->viewportFocusBeforeBarracksHotkey = -1;
this->viewportFocusBeforeMercenaryHotkey = -1;
this->viewportFocusBeforeGranaryHotkey = -1;
this->viewportFocusBeforeMarketHotkey = -1;
this->viewportFocusBeforeKeepHotkey = -1;
this->viewportFocusBeforeArmoryHotkey = -1;
return this;
}

}
}
10 changes: 3 additions & 7 deletions src/OpenSHC/Game/GameCore/exitToScenarioDescriptionMenu.cpp
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
#include "OpenSHC/Game/GameCore.func.hpp"
#include "OpenSHC/UI/Enums/MenuViewType.hpp"
#include "../GameCore.func.hpp"

#include "OpenSHC/Globals/DAT_GameCore.hpp"

namespace OpenSHC {
namespace Game {

using OpenSHC::UI::Enums::MenuViewType;

// FUNCTION: STRONGHOLDCRUSADER 0x00471A80
void GameCore::exitToScenarioDescriptionMenu()
{
MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::removeLadyAndJester, this)();
MACRO_CALL_MEMBER(GameCore_Func::removeLadyAndJester, this)();
DAT_GameCore::instance.field22_0x64 = 0;
MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)(
OpenSHC::UI::Enums::MVT_SCENARIO_DESCRIPTION, 0);
MACRO_CALL_MEMBER(GameCore_Func::switchToMenuView, DAT_GameCore::ptr)(UI::Enums::MVT_SCENARIO_DESCRIPTION, 0);
}

}
Expand Down
67 changes: 67 additions & 0 deletions src/OpenSHC/Game/GameCore/hideOrUnhideUI.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#include "../GameCore.func.hpp"

#include "OpenSHC/Globals/DAT_GameCore.hpp"
#include "OpenSHC/Globals/DAT_MouseState.hpp"

namespace OpenSHC {
namespace Game {

// FUNCTION: STRONGHOLDCRUSADER 0x00471AA0
void GameCore::hideOrUnhideUI()
{
if ((DAT_GameCore::instance.currentMenuViewType == UI::Enums::MVT_BUILD_MENU
|| DAT_GameCore::instance.currentMenuViewType == UI::Enums::MVT_MAP_EDITOR_LANDSCAPING)
&& DAT_MouseState::instance.selectionBoxMode == 0) {
// hide the menu
if (DAT_GameCore::instance.activeMenuTab.buildMenuTab != UI::Enums::BMTT_MENU_HIDDEN
&& DAT_GameCore::instance.activeMenuTab.buildMenuTab != 62) {
if (DAT_GameCore::instance.currentMenuViewType == UI::Enums::MVT_BUILD_MENU) {
if (DAT_GameCore::instance.activeMenuTab.buildMenuTab == UI::Enums::BMTT_SOLDIERS) {
DAT_GameCore::instance.buildmenuMenuTabToSwitchTo.buildMenuTab = 62;
} else {
MACRO_CALL_MEMBER(GameCore_Func::setTabToSwitchTo, DAT_GameCore::ptr)();
DAT_GameCore::instance.buildmenuMenuTabToSwitchTo.buildMenuTab = UI::Enums::BMTT_MENU_HIDDEN;
}
}
if (DAT_GameCore::instance.currentMenuViewType == UI::Enums::MVT_MAP_EDITOR_LANDSCAPING) {
DAT_GameCore::instance.landscapingmenuMenuTabToSwitchTo = UI::Enums::BMTT_MENU_HIDDEN;
}
MACRO_CALL_MEMBER(GameCore_Func::switchToMenuView, DAT_GameCore::ptr)(
(MenuViewType)DAT_GameCore::instance.currentMenuViewType, 0);
return;
}

// unhide the menu
if (DAT_GameCore::instance.currentMenuViewType == UI::Enums::MVT_BUILD_MENU) {
if (DAT_GameCore::instance.activeMenuTab.buildMenuTab == 62) {
DAT_GameCore::instance.buildmenuMenuTabToSwitchTo.buildMenuTab = UI::Enums::BMTT_SOLDIERS;
} else {
MACRO_CALL_MEMBER(GameCore_Func::swapBuildMenuTab, DAT_GameCore::ptr)();
}
}
if (DAT_GameCore::instance.currentMenuViewType == UI::Enums::MVT_MAP_EDITOR_LANDSCAPING) {
DAT_GameCore::instance.landscapingmenuMenuTabToSwitchTo
= DAT_GameCore::instance.secondaryActiveMenuTabToSwitchTo.tabType;
}
if (DAT_GameCore::instance.buildmenuMenuTabToSwitchTo.buildMenuTab == UI::Enums::BMTT_MENU_HIDDEN) {
if (DAT_GameCore::instance.currentMenuViewType == UI::Enums::MVT_BUILD_MENU) {
DAT_GameCore::instance.buildmenuMenuTabToSwitchTo.buildMenuTab = UI::Enums::BMTT_CASTLE;
}
if (DAT_GameCore::instance.currentMenuViewType == UI::Enums::MVT_MAP_EDITOR_LANDSCAPING) {
DAT_GameCore::instance.landscapingmenuMenuTabToSwitchTo = 231;
}
}
MACRO_CALL_MEMBER(GameCore_Func::switchToMenuView, DAT_GameCore::ptr)(
(MenuViewType)DAT_GameCore::instance.currentMenuViewType, 0);
return;
}

if (DAT_GameCore::instance.currentMenuViewType == UI::Enums::MVT_BUILDING_AND_STATUS_MENU) {
this->secondaryActiveMenuTabToSwitchTo = this->buildmenuMenuTabToSwitchTo;
DAT_GameCore::instance.buildmenuMenuTabToSwitchTo.buildMenuTab = UI::Enums::BMTT_MENU_HIDDEN;
MACRO_CALL_MEMBER(GameCore_Func::switchToMenuView, DAT_GameCore::ptr)(UI::Enums::MVT_BUILD_MENU, 0);
}
}

}
}
45 changes: 45 additions & 0 deletions src/OpenSHC/Game/GameCore/incrementMission.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#include "../GameCore.func.hpp"

#include "OpenSHC/IO/SettingsFileState.func.hpp"
#include "OpenSHC/Map/MapPropertiesState.func.hpp"

#include "OpenSHC/Globals/DAT_GameCore.hpp"
#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp"
#include "OpenSHC/Globals/DAT_MapPropertiesState.hpp"
#include "OpenSHC/Globals/DAT_SettingsFileState.hpp"

namespace OpenSHC {
namespace Game {

// FUNCTION: STRONGHOLDCRUSADER 0x00471A00
void GameCore::incrementMission()
{
++this->missionNumber1to20;
MACRO_CALL_MEMBER(GameCore_Func::removeLadyAndJester, this)();
if (!this->unlockAllHistoricalCampaigns && this->missionNumber1to20 > this->furthestMission) {
this->furthestMission = this->missionNumber1to20;
}
MACRO_CALL_MEMBER(IO::SettingsFileState_Func::writeUserConfig, DAT_SettingsFileState::ptr)();

if (!MACRO_CALL_MEMBER(Map::MapPropertiesState_Func::isValueInRangeOneToTwenty, DAT_MapPropertiesState::ptr)(
this->missionNumber1to20)) {
DAT_GameCore::instance.field22_0x64 = 0;
MACRO_CALL_MEMBER(GameCore_Func::switchToMenuView, DAT_GameCore::ptr)(
UI::Enums::MVT_MISSION_FINISHED_TRANSITION, 0);
} else {
DAT_GameSynchronyState::instance.currentPlayerSlotID = 1;
if (this->missionNumber1to20 != 33 && !DAT_GameCore::instance.field26_0x74) {
MACRO_CALL_MEMBER(GameCore_Func::switchToMenuView, DAT_GameCore::ptr)(
UI::Enums::MVT_MISSION_FINISHED_TRANSITION, 0);
} else {
DAT_GameCore::instance.field22_0x64 = 0;
MACRO_CALL_MEMBER(GameCore_Func::switchToMenuView, DAT_GameCore::ptr)(
UI::Enums::MVT_SCENARIO_DESCRIPTION, 0);
}
}
DAT_GameCore::instance.field26_0x74 = 0;
DAT_GameCore::instance.unknownAlwaysZero = 0;
}

}
}
72 changes: 72 additions & 0 deletions src/OpenSHC/Game/GameCore/incrementMissionProgress.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#include "../GameCore.func.hpp"

#include "OpenSHC/IO/SettingsFileState.func.hpp"
#include "OpenSHC/Map/MapPropertiesState.func.hpp"

#include "OpenSHC/Globals/DAT_GameCore.hpp"
#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp"
#include "OpenSHC/Globals/DAT_MapPropertiesState.hpp"
#include "OpenSHC/Globals/DAT_SettingsFileState.hpp"

namespace OpenSHC {
namespace Game {

// FUNCTION: STRONGHOLDCRUSADER 0x004718F0
void GameCore::incrementMissionProgress()
{
++this->missionNumber1to20;
if (!this->unlockAllHistoricalCampaigns && !DAT_GameCore::instance.field26_0x74) {
if (this->missionNumber1to20 <= 6) {
if (this->missionNumber1to20 > this->scenarioProgress.progressCallToArms) {
this->scenarioProgress.progressCallToArms = this->missionNumber1to20;
}
} else if (this->missionNumber1to20 <= 11) {
if (this->missionNumber1to20 > this->scenarioProgress.progressSaladinsConquest) {
this->scenarioProgress.progressSaladinsConquest = this->missionNumber1to20;
}
} else if (this->missionNumber1to20 <= 16) {
if (this->missionNumber1to20 > this->scenarioProgress.progressTheKingsCrusade) {
this->scenarioProgress.progressTheKingsCrusade = this->missionNumber1to20;
}
} else if (this->missionNumber1to20 <= 21) {
if (this->missionNumber1to20 > this->scenarioProgress.progressCrusaderStates) {
this->scenarioProgress.progressCrusaderStates = this->missionNumber1to20;
}
}
}
MACRO_CALL_MEMBER(IO::SettingsFileState_Func::writeUserConfig, DAT_SettingsFileState::ptr)();

if (!MACRO_CALL_MEMBER(Map::MapPropertiesState_Func::isValueInRangeOneToTwenty, DAT_MapPropertiesState::ptr)(
this->missionNumber1to20)) {
MACRO_CALL_MEMBER(GameCore_Func::switchToMenuView, DAT_GameCore::ptr)(
UI::Enums::MVT_MISSION_FINISHED_TRANSITION, 0);
DAT_GameCore::instance.field26_0x74 = 0;
DAT_GameCore::instance.unknownAlwaysZero = 0;
return;
}

MACRO_CALL_MEMBER(GameCore_Func::removeJesterAndLadyUnitsInCertainMissions, this)();
DAT_GameSynchronyState::instance.currentPlayerSlotID = 1;
int const firstMissionOfCampaign = this->historicCampaignNumber * 5 - 4;
if (this->missionNumber1to20 != firstMissionOfCampaign && !DAT_GameCore::instance.field26_0x74) {
MACRO_CALL_MEMBER(GameCore_Func::switchToMenuView, DAT_GameCore::ptr)(
UI::Enums::MVT_MISSION_FINISHED_TRANSITION, 0);
DAT_GameCore::instance.field26_0x74 = 0;
DAT_GameCore::instance.unknownAlwaysZero = 0;
return;
}

if (DAT_GameCore::instance.field26_0x74 && this->missionNumber1to20 != firstMissionOfCampaign) {
MACRO_CALL_MEMBER(GameCore_Func::switchToMenuView, DAT_GameCore::ptr)(
UI::Enums::MVT_HISTORIC_MISSION_PICTURE, 0);
} else {
MACRO_CALL_MEMBER(GameCore_Func::switchToMenuView, DAT_GameCore::ptr)(
UI::Enums::MVT_HISTORIC_CAMPAIGN_INTRO, 0);
}
DAT_GameCore::instance.field22_0x64 = 0;
DAT_GameCore::instance.field26_0x74 = 0;
DAT_GameCore::instance.unknownAlwaysZero = 0;
}

}
}
17 changes: 5 additions & 12 deletions src/OpenSHC/Game/GameCore/isGameHaltingMenuOpen.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#include "OpenSHC/Game/GameCore.func.hpp"
#include "OpenSHC/Game/GameMode.hpp"
#include "OpenSHC/UI/Enums/MenuModalType.hpp"
#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp"
#include "../GameCore.func.hpp"

#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp"
#include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp"
Expand All @@ -10,21 +7,17 @@
namespace OpenSHC {
namespace Game {

using OpenSHC::Game::GameMode;
using OpenSHC::UI::Enums::MenuModalType;
using OpenSHC::WindowsHelper::Enums::BOOLEnum;

// FUNCTION: STRONGHOLDCRUSADER 0x0046BD20
BOOLEnum GameCore::isGameHaltingMenuOpen()
{
if (DAT_GameSynchronyState::instance.currentGameMode != OpenSHC::Game::GM_SOLITARY
&& DAT_GameSynchronyState::instance.currentGameMode != OpenSHC::Game::GM_SKIRMISH_SINGLE_PLAYER) {
if (DAT_GameSynchronyState::instance.currentGameMode != GM_SOLITARY
&& DAT_GameSynchronyState::instance.currentGameMode != GM_SKIRMISH_SINGLE_PLAYER) {
return FALSE;
}
if (DAT_MenuTextInputState::instance.currentModalDialog != OpenSHC::UI::Enums::MMT_NO_MENU) {
if (DAT_MenuTextInputState::instance.currentModalDialog != UI::Enums::MMT_NO_MENU) {
return TRUE;
}
return DAT_MenuModalComposition1::instance.activeModalDialogID == OpenSHC::UI::Enums::MMT_IN_GAME_HELP_TEXT;
return DAT_MenuModalComposition1::instance.activeModalDialogID == UI::Enums::MMT_IN_GAME_HELP_TEXT;
}

}
Expand Down
39 changes: 39 additions & 0 deletions src/OpenSHC/Game/GameCore/isInBuildingTab.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#include "../GameCore.func.hpp"

#include "OpenSHC/Globals/DAT_GameCore.hpp"

namespace OpenSHC {
namespace Game {

// FUNCTION: STRONGHOLDCRUSADER 0x0046BB80
BOOLEnum GameCore::isInBuildingTab()
{
if (DAT_GameCore::instance.currentMenuViewType != UI::Enums::MVT_BUILDING_AND_STATUS_MENU) {
return FALSE;
}
if (DAT_GameCore::instance.activeMenuTab.tabType == UI::Enums::BASMTT_GRANARY_OR_MPMENU_TCPIP) {
return TRUE;
}
if (DAT_GameCore::instance.activeMenuTab.tabType == UI::Enums::BASMTT_SIEGETENT_CATAPULT) {
return TRUE;
}
if (DAT_GameCore::instance.activeMenuTab.tabType == UI::Enums::BASMTT_SIEGETENT_FIREBALLISTA) {
return TRUE;
}
if (DAT_GameCore::instance.activeMenuTab.tabType == UI::Enums::BASMTT_SIEGETENT_TREBUCHET) {
return TRUE;
}
if (DAT_GameCore::instance.activeMenuTab.tabType == UI::Enums::BASMTT_SIEGETENT_SIEGETOWER) {
return TRUE;
}
if (DAT_GameCore::instance.activeMenuTab.tabType == UI::Enums::BASMTT_SIEGETENT_BATTERINGRAM) {
return TRUE;
}
if (DAT_GameCore::instance.activeMenuTab.tabType == UI::Enums::BASMTT_SIEGETENT_SHIELD) {
return TRUE;
}
return DAT_GameCore::instance.activeMenuTab.tabType == UI::Enums::BASMTT_KEEP_OR_MPMENU_IPX;
}

}
}
Loading
Loading