Skip to content

Commit

Permalink
Add special world property for water creatures (PR #3033)
Browse files Browse the repository at this point in the history
  • Loading branch information
samr46 authored Aug 1, 2023
1 parent 3f510fc commit 3134aa5
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
30 changes: 30 additions & 0 deletions Client/game_sa/CGameSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,9 @@ bool CGameSA::IsCheatEnabled(const char* szCheatName)
if (!strcmp(szCheatName, PROP_CORONA_ZTEST))
return IsCoronaZTestEnabled();

if (!strcmp(szCheatName, PROP_WATER_CREATURES))
return IsWaterCreaturesEnabled();

std::map<std::string, SCheatSA*>::iterator it = m_Cheats.find(szCheatName);
if (it == m_Cheats.end())
return false;
Expand Down Expand Up @@ -607,6 +610,12 @@ bool CGameSA::SetCheatEnabled(const char* szCheatName, bool bEnable)
return true;
}

if (!strcmp(szCheatName, PROP_WATER_CREATURES))
{
SetWaterCreaturesEnabled(bEnable);
return true;
}

std::map<std::string, SCheatSA*>::iterator it = m_Cheats.find(szCheatName);
if (it == m_Cheats.end())
return false;
Expand All @@ -625,6 +634,7 @@ void CGameSA::ResetCheats()
SetUnderWorldWarpEnabled(true);
SetCoronaZTestEnabled(true);
CVehicleSA::SetVehiclesSunGlareEnabled(false);
SetWaterCreaturesEnabled(true);

std::map<std::string, SCheatSA*>::iterator it;
for (it = m_Cheats.begin(); it != m_Cheats.end(); it++)
Expand Down Expand Up @@ -730,6 +740,26 @@ void CGameSA::SetCoronaZTestEnabled(bool isEnabled)
m_isCoronaZTestEnabled = isEnabled;
}

void CGameSA::SetWaterCreaturesEnabled(bool isEnabled)
{
if (isEnabled == m_areWaterCreaturesEnabled)
return;

const auto manager = reinterpret_cast<class WaterCreatureManager_c*>(0xC1DF30);
if (isEnabled)
{
unsigned char(__thiscall * Init)(WaterCreatureManager_c*) = reinterpret_cast<decltype(Init)>(0x6E3F90);
Init(manager);
}
else
{
void(__thiscall * Exit)(WaterCreatureManager_c*) = reinterpret_cast<decltype(Exit)>(0x6E3FD0);
Exit(manager);
}

m_areWaterCreaturesEnabled = isEnabled;
}

bool CGameSA::PerformChecks()
{
std::map<std::string, SCheatSA*>::iterator it;
Expand Down
5 changes: 5 additions & 0 deletions Client/game_sa/CGameSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ extern unsigned int OBJECTDYNAMICINFO_MAX; // default: 160
#define PROP_UNDERWORLD_WARP "underworldwarp"
#define PROP_VEHICLE_SUNGLARE "vehiclesunglare"
#define PROP_CORONA_ZTEST "coronaztest"
#define PROP_WATER_CREATURES "watercreatures"

struct SCheatSA
{
Expand Down Expand Up @@ -212,6 +213,9 @@ class CGameSA : public CGame
void SetCoronaZTestEnabled(bool isEnabled);
bool IsCoronaZTestEnabled() const noexcept { return m_isCoronaZTestEnabled; }

bool IsWaterCreaturesEnabled() const noexcept { return m_areWaterCreaturesEnabled; }
void SetWaterCreaturesEnabled(bool isEnabled);

unsigned long GetMinuteDuration();
void SetMinuteDuration(unsigned long ulTime);

Expand Down Expand Up @@ -322,6 +326,7 @@ class CGameSA : public CGame
int m_iCheckStatus;
bool m_bUnderworldWarp;
bool m_isCoronaZTestEnabled{true};
bool m_areWaterCreaturesEnabled{true};

static unsigned int& ClumpOffset;
static unsigned long* VAR_SystemTime;
Expand Down

0 comments on commit 3134aa5

Please sign in to comment.