Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hard-Core Mode : Forbid S/L #1402

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
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
6 changes: 6 additions & 0 deletions src/Phobos.Ext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,12 @@ DEFINE_HOOK(0x67D04E, GameSave_SavegameInformation, 0x7)
Info.ExecutableName.Size - sizeof(" + Phobos " FILE_VERSION_STR)
);

if (Phobos::Config::NoSaveLoad)
{
// You've somehow cheated to make through this
Debug::FatalErrorAndExit("Hard Core mode enabled, save game not allowed!");
}

return 0;
}

Expand Down
59 changes: 58 additions & 1 deletion src/Phobos.INI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
#include <SessionClass.h>
#include <MessageListClass.h>
#include <HouseClass.h>

#include <LoadOptionsClass.h>
#include <WWMessageBox.h>
#include <Utilities/Parser.h>
#include <Utilities/GeneralUtils.h>
#include <Utilities/Patch.h>
Expand Down Expand Up @@ -53,6 +54,7 @@ bool Phobos::Config::ShowBriefing = true;
bool Phobos::Config::ShowHarvesterCounter = false;
bool Phobos::Config::ShowPowerDelta = true;
bool Phobos::Config::ShowWeedsCounter = false;
bool Phobos::Config::NoSaveLoad = false;

bool Phobos::Misc::CustomGS = false;
int Phobos::Misc::CustomGS_ChangeInterval[7] = { -1, -1, -1, -1, -1, -1, -1 };
Expand Down Expand Up @@ -90,6 +92,14 @@ DEFINE_HOOK(0x5FACDF, OptionsClass_LoadSettings_LoadPhobosSettings, 0x5)

Phobos::Config::ShowDesignatorRange = CCINIClass::INI_RA2MD->ReadBool("Phobos", "ShowDesignatorRange", false);

Phobos::Config::NoSaveLoad = CCINIClass::INI_RA2MD->ReadBool("Phobos", "NoSaveLoad", false);

if (Phobos::Config::NoSaveLoad)
{
Patch::Apply_LJMP(0x55DBCD, 0x55DC99); // Disable MainLoop_SaveGame

}

CCINIClass* pINI_UIMD = CCINIClass::LoadINIFile(GameStrings::UIMD_INI);

// LoadingScreen
Expand Down Expand Up @@ -269,3 +279,50 @@ DEFINE_HOOK(0x55DBCD, MainLoop_SaveGame, 0x6)

return SkipSave;
}

DEFINE_HOOK(0x558DDC, LoadOptionsClass_MakeDlg_NoSL, 0x5)
{
GET(LoadOptionsClass*, self, ESI);
if (Phobos::Config::NoSaveLoad)
{
if (self->Mode == LoadOptionsMode::Save || self->Mode == LoadOptionsMode::Load)
{
WWMessageBox::Instance->Process(
L"Hard-Core mode on, save/load forbidden!",
StringTable::LoadString(GameStrings::TXT_OK),
nullptr, nullptr
);
return 0x558EA9;
}
}
return 0;
}

/*
// Yeah I know you are going to say Ares pre 0.A had similar save/load button disable, but better not conflict it I think:

// disable the loading button in the single player menu

DEFINE_HOOK(52D6C2, Singleplayer_hDlg_DisableSaves, A)
{
R->ECX(FALSE);
return 0x52D6CC;
}

// disable load, save and delete buttons on the ingame menu
DEFINE_HOOK(4F17F6, sub_4F1720_DisableSaves, 6)
{
GET(HWND, hDlg, EBP);

using namespace GameOptionsDialog;

for(int item=LoadGameButton; item<=DeleteGameButton; ++item) {
if(HWND hItem = GetDlgItem(hDlg, item)) {
EnableWindow(hItem, FALSE);
}
}

return 0x4F1834;
}

*/
1 change: 1 addition & 0 deletions src/Phobos.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ class Phobos
static bool ShowHarvesterCounter;
static bool ShowWeedsCounter;
static bool ShowPlanningPath;
static bool NoSaveLoad;
};

class Misc
Expand Down
Loading