Skip to content
Merged
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
20 changes: 20 additions & 0 deletions Client/game_sa/CGameSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,9 @@ bool CGameSA::IsCheatEnabled(const char* szCheatName)
if (!strcmp(szCheatName, PROP_EXTRA_AIR_RESISTANCE))
return IsExtraAirResistanceEnabled();

if (!strcmp(szCheatName, PROP_UNDERWORLD_WARP))
return IsUnderWorldWarpEnabled();

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

if (!strcmp(szCheatName, PROP_UNDERWORLD_WARP))
{
SetUnderWorldWarpEnabled(bEnable);
return true;
}

std::map<std::string, SCheatSA*>::iterator it = m_Cheats.find(szCheatName);
if (it == m_Cheats.end())
return false;
Expand All @@ -622,6 +631,7 @@ void CGameSA::ResetCheats()
SetRandomFoliageEnabled(true);
SetMoonEasterEggEnabled(false);
SetExtraAirResistanceEnabled(true);
SetUnderWorldWarpEnabled(true);

std::map<std::string, SCheatSA*>::iterator it;
for (it = m_Cheats.begin(); it != m_Cheats.end(); it++)
Expand Down Expand Up @@ -668,6 +678,16 @@ void CGameSA::SetExtraAirResistanceEnabled(bool bEnable)
MemPut<BYTE>(0x72DDD9, bEnable ? 0x01 : 0x00);
}

void CGameSA::SetUnderWorldWarpEnabled(bool bEnable)
{
m_bUnderworldWarp = !bEnable;
}

bool CGameSA::IsUnderWorldWarpEnabled()
{
return !m_bUnderworldWarp;
}

bool CGameSA::GetJetpackWeaponEnabled(eWeaponType weaponType)
{
if (weaponType >= WEAPONTYPE_BRASSKNUCKLE && weaponType < WEAPONTYPE_LAST_WEAPONTYPE)
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 @@ -83,6 +83,7 @@
#define PROP_RANDOM_FOLIAGE "randomfoliage"
#define PROP_SNIPER_MOON "snipermoon"
#define PROP_EXTRA_AIR_RESISTANCE "extraairresistance"
#define PROP_UNDERWORLD_WARP "underworldwarp"

struct SCheatSA
{
Expand Down Expand Up @@ -399,6 +400,9 @@ class CGameSA : public CGame
bool IsExtraAirResistanceEnabled();
void SetExtraAirResistanceEnabled(bool bEnable);

bool IsUnderWorldWarpEnabled();
void SetUnderWorldWarpEnabled(bool bEnable);

bool VerifySADataFileNames();
bool PerformChecks();
int& GetCheckStatus(void) { return m_iCheckStatus; }
Expand Down Expand Up @@ -489,6 +493,7 @@ class CGameSA : public CGame
bool m_bAsyncScriptForced;
bool m_bASyncLoadingSuspended;
int m_iCheckStatus;
bool m_bUnderworldWarp;

static unsigned long* VAR_SystemTime;
static unsigned long* VAR_IsAtMenu;
Expand Down
59 changes: 58 additions & 1 deletion Client/game_sa/CWorldSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,63 @@ CWorldSA::CWorldSA()
m_pBuildingRemovals = new std::multimap<unsigned short, SBuildingRemoval*>;
m_pDataBuildings = new std::multimap<unsigned short, sDataBuildingRemovalItem*>;
m_pBinaryBuildings = new std::multimap<unsigned short, sBuildingRemovalItem*>;

InstallHooks();
}

void HOOK_FallenPeds();
void HOOK_FallenCars();

void CWorldSA::InstallHooks(void)
{
HookInstall(0x565CB0, (DWORD)HOOK_FallenPeds, 5);
HookInstall(0x565E80, (DWORD)HOOK_FallenCars, 5);
}

DWORD CONTINUE_CWorld_FallenPeds = 0x00565CBA;
DWORD CONTINUE_CWorld_FallenCars = 0x00565E8A;

void _declspec(naked) HOOK_FallenPeds()
{
if (pGame && pGame->IsUnderWorldWarpEnabled())
{
_asm
{
sub esp, 2Ch
push ebx
mov ebx, ds:0B74490h
jmp CONTINUE_CWorld_FallenPeds
}
}
else
{
_asm
{
ret
}
}
}


void _declspec(naked) HOOK_FallenCars()
{
if (pGame && !pGame->IsUnderWorldWarpEnabled())
{
_asm
{
sub esp, 2Ch
push ebx
mov ebx, ds:0B74494h
jmp CONTINUE_CWorld_FallenCars
}
}
else
{
_asm
{
ret
}
}
}

void CWorldSA::Add(CEntity* pEntity, eDebugCaller CallerId)
Expand Down Expand Up @@ -1298,4 +1355,4 @@ bool CWorldSA::CalculateImpactPosition(const CVector& vecInputStart, CVector& ve
// Include dead peds
MemPutFast<DWORD>(0xB7CD71, 0);
return false;
}
}
1 change: 1 addition & 0 deletions Client/game_sa/CWorldSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class CWorldSA : public CWorld
{
public:
CWorldSA();
void InstallHooks(void);
void Add(CEntity* entity, eDebugCaller CallerId);
void Add(CEntitySAInterface* entityInterface, eDebugCaller CallerId);
void Remove(CEntity* entity, eDebugCaller CallerId);
Expand Down