Skip to content

Commit e8dde7c

Browse files
committed
blyat
1 parent 0449bdd commit e8dde7c

9 files changed

Lines changed: 91 additions & 12 deletions

File tree

YRpp

docs/User-Interface.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,3 +589,16 @@ In `RA2MD.ini`:
589589
[Phobos]
590590
SaveGameOnScenarioStart=true ; boolean
591591
```
592+
593+
594+
### Forbid saving game
595+
596+
Game save can be forbidden in singleplayer games as some sort of "hardcore" mode. All existing save/load functionalities will be disabled.
597+
- When trying to click the save button, a message box with `TXT_HARDCORE_NOSAVE` CSF entry will appear instead of saving the game.
598+
- Scenarios successions will be disabled as well.
599+
- On the loading screen, the single-frame `hardcorelogo.shp` (for `Palette.pal`) will be drawn on the top right corner of the screen. If not present, the text with csf `TXT_HARDCORE_MODE` will be displayed instead.
600+
In `RA2MD.ini`:
601+
```ini
602+
[Phobos]
603+
NoSaveLoad=false ; boolean
604+
```

docs/Whats-New.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ ToolTipDescriptions=true ; boolean
9191
ToolTipBlur=false ; boolean
9292
SaveGameOnScenarioStart=true ; boolean
9393
HideLightFlashEffects=false ; boolean
94+
NoSaveLoad = false ; boolean
9495
```
9596

9697
### For Map Editor (Final Alert 2)
@@ -546,6 +547,7 @@ Vanilla fixes:
546547
- Certain global tileset indices (`ShorePieces`, `WaterSet`, `CliffSet`, `WaterCliffs`, `WaterBridge`, `BridgeSet` and `WoodBridgeSet`) are now correctly parsed for Lunar theater (by Starkku)
547548
- Fixed infantry `SecondaryFire` / `SecondaryProne` sequences being displayed in water instead of `WetAttack` (by Starkku)
548549
- Fixed objects with ally target and `AttackFriendlies=true` having their target reset every frame, particularly AI-owned buildings (by Starkku)
550+
- Save game disabler (by Trsdy)
549551
550552
Phobos fixes:
551553
- Fixed a few errors of calling for superweapon launch by `LaunchSW` or building infiltration (by Trsdy)

src/Commands/QuickSave.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,12 @@ const wchar_t* QuickSaveCommandClass::GetUIDescription() const
2727

2828
void QuickSaveCommandClass::Execute(WWKey eInput) const
2929
{
30-
auto PrintMessage = [](const wchar_t* pMessage)
30+
31+
if (Phobos::Config::NoSaveLoad)
3132
{
32-
MessageListClass::Instance->PrintMessage(
33-
pMessage,
34-
RulesClass::Instance->MessageDelay,
35-
HouseClass::CurrentPlayer->ColorSchemeIndex,
36-
true
37-
);
38-
};
33+
MessageListClass::Instance->PrintMessage(StringTable::LoadString(GameStrings::TXT_ERROR_SAVING_GAME));
34+
return;
35+
}
3936

4037
if (SessionClass::IsSingleplayer())
4138
{
@@ -51,6 +48,11 @@ void QuickSaveCommandClass::Execute(WWKey eInput) const
5148
}
5249
else
5350
{
54-
PrintMessage(GeneralUtils::LoadStringUnlessMissing("MSG:NotAvailableInMultiplayer", L"QuickSave is not available in multiplayer"));
51+
MessageListClass::Instance->PrintMessage(
52+
GeneralUtils::LoadStringUnlessMissing("MSG:NotAvailableInMultiplayer", L"QuickSave is not available in multiplayer"),
53+
RulesClass::Instance->MessageDelay,
54+
HouseClass::CurrentPlayer->ColorSchemeIndex,
55+
true
56+
);
5557
}
5658
}

src/Ext/Scenario/Body.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@ void ScenarioExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)
148148
this->ShowBriefing = ini_missionmd.ReadBool(scenarioName, "ShowBriefing", pINI->ReadBool(GameStrings::Basic, "ShowBriefing", this->ShowBriefing));
149149
this->BriefingTheme = ini_missionmd.ReadTheme(scenarioName, "BriefingTheme", pINI->ReadTheme(GameStrings::Basic, "BriefingTheme", this->BriefingTheme));
150150

151+
if (Phobos::Config::NoSaveLoad)
152+
ScenarioClass::Instance->EndOfGame = true;
151153
}
152154
}
153155

src/Misc/Hooks.PCX.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,30 @@ DEFINE_HOOK(0x552FCB, LoadProgressMgr_Draw_PCXLoadingScreen_Campaign, 0x6)
8383
return 0;
8484
}
8585

86+
DEFINE_HOOK(0x553076,LoadProgressMgr_Draw_ExtraText_Campaign,0x5)
87+
{
88+
GET(LoadProgressManager*, self, EBP);
89+
if(Phobos::Config::NoSaveLoad)
90+
{
91+
Point2D pos
92+
{
93+
self->TitleBarRect.X + self->TitleBarRect.Width - 100,
94+
self->TitleBarRect.Y + 10
95+
};
96+
LEA_STACK(RectangleStruct*, pBnd, STACK_OFFSET(0x1268,-0x1204));
97+
if(auto logo = FileSystem::LoadSHPFile("hardcorelogo.shp"))
98+
{
99+
self->ProgressSurface->DrawSHP(FileSystem::PALETTE_PAL,logo,0,&pos,pBnd,BlitterFlags::bf_400,0,0,ZGradient::Ground,1000,0,nullptr,0,0,0);
100+
}
101+
else
102+
{
103+
auto msg = GeneralUtils::LoadStringUnlessMissing("TXT_HARDCORE_MODE",L"HARDCORE");
104+
self->ProgressSurface->DrawTextA(msg,&pos,COLOR_RED);
105+
}
106+
}
107+
return 0;
108+
}
109+
86110
DEFINE_HOOK(0x6A99F3, StripClass_Draw_DrawMissing, 0x6)
87111
{
88112
GET_STACK(SHPStruct*, pCameo, STACK_OFFSET(0x48C, -0x444));

src/Phobos.Ext.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,12 @@ DEFINE_HOOK(0x67D04E, GameSave_SavegameInformation, 0x7)
279279
Info.ExecutableName.Size - sizeof(" + Phobos " FILE_VERSION_STR)
280280
);
281281

282+
if (Phobos::Config::NoSaveLoad)
283+
{
284+
// You've somehow cheated to make through this
285+
Debug::FatalErrorAndExit("Hard Core mode enabled, save game not allowed!");
286+
}
287+
282288
return 0;
283289
}
284290

src/Phobos.INI.cpp

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
#include <SessionClass.h>
66
#include <MessageListClass.h>
77
#include <HouseClass.h>
8-
8+
#include <LoadOptionsClass.h>
9+
#include <WWMessageBox.h>
910
#include <Utilities/Parser.h>
1011
#include <Utilities/GeneralUtils.h>
1112
#include <Utilities/Patch.h>
@@ -55,6 +56,7 @@ bool Phobos::Config::ShowHarvesterCounter = false;
5556
bool Phobos::Config::ShowPowerDelta = true;
5657
bool Phobos::Config::ShowWeedsCounter = false;
5758
bool Phobos::Config::HideLightFlashEffects = true;
59+
bool Phobos::Config::NoSaveLoad = false;
5860

5961
bool Phobos::Misc::CustomGS = false;
6062
int Phobos::Misc::CustomGS_ChangeInterval[7] = { -1, -1, -1, -1, -1, -1, -1 };
@@ -93,6 +95,13 @@ DEFINE_HOOK(0x5FACDF, OptionsClass_LoadSettings_LoadPhobosSettings, 0x5)
9395

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

98+
if (Phobos::Config::NoSaveLoad = CCINIClass::INI_RA2MD->ReadBool("Phobos", "NoSaveLoad", false))
99+
{
100+
Patch::Apply_LJMP(0x55DBCD, 0x55DC99); // Disable MainLoop_SaveGame
101+
Patch::Apply_RAW(0x67CEF0, {0x33,0xC0,0xC3}); // Corrupt savegame function
102+
Patch::Apply_TYPED(0x83D560, {(DWORD)std::rand()}); // Corrupt save game magicn
103+
}
104+
96105
CCINIClass ini_uimd {};
97106
ini_uimd.LoadFromFile(GameStrings::UIMD_INI);
98107

@@ -259,7 +268,7 @@ DEFINE_HOOK(0x55DBCD, MainLoop_SaveGame, 0x6)
259268
enum { SkipSave = 0x55DC99, InitialSave = 0x55DBE6 };
260269

261270
bool& scenario_saved = *reinterpret_cast<bool*>(0xABCE08);
262-
if (SessionClass::IsSingleplayer() && !scenario_saved)
271+
if (SessionClass::IsSingleplayer() && !scenario_saved && !Phobos::Config::NoSaveLoad)
263272
{
264273
scenario_saved = true;
265274
if (Phobos::ShouldQuickSave)
@@ -274,3 +283,23 @@ DEFINE_HOOK(0x55DBCD, MainLoop_SaveGame, 0x6)
274283

275284
return SkipSave;
276285
}
286+
287+
// Yeah I know you are going to say Ares pre 0.A had similar save/load button disable, but better not use that less informative approach
288+
DEFINE_HOOK(0x558DDC, LoadOptionsClass_MakeDlg_NoSL, 0x5)
289+
{
290+
GET(LoadOptionsClass*, self, ESI);
291+
if (Phobos::Config::NoSaveLoad)
292+
{
293+
if (self->Mode == LoadOptionsMode::Save || self->Mode == LoadOptionsMode::Load)
294+
{
295+
WWMessageBox::Instance->Process(
296+
GeneralUtils::LoadStringUnlessMissing(
297+
"TXT_HARDCORE_NOSAVE",L"Hard-Core mode on, save/load forbidden!"),
298+
StringTable::LoadString(GameStrings::TXT_OK),
299+
nullptr, nullptr
300+
);
301+
return 0x558EA9;
302+
}
303+
}
304+
return 0;
305+
}

src/Phobos.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ class Phobos
9292
static bool ShowWeedsCounter;
9393
static bool ShowPlanningPath;
9494
static bool HideLightFlashEffects;
95+
static bool NoSaveLoad;
9596
};
9697

9798
class Misc

0 commit comments

Comments
 (0)