Skip to content

Commit 06300d5

Browse files
CrosRoad95ccw808
authored andcommitted
Feature for mapping. setWorldSpecialPropertyEnabled, underworldwarp property (#208)
1 parent e908401 commit 06300d5

File tree

4 files changed

+84
-1
lines changed

4 files changed

+84
-1
lines changed

Client/game_sa/CGameSA.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,9 @@ bool CGameSA::IsCheatEnabled(const char* szCheatName)
581581
if (!strcmp(szCheatName, PROP_EXTRA_AIR_RESISTANCE))
582582
return IsExtraAirResistanceEnabled();
583583

584+
if (!strcmp(szCheatName, PROP_UNDERWORLD_WARP))
585+
return IsUnderWorldWarpEnabled();
586+
584587
std::map<std::string, SCheatSA*>::iterator it = m_Cheats.find(szCheatName);
585588
if (it == m_Cheats.end())
586589
return false;
@@ -607,6 +610,12 @@ bool CGameSA::SetCheatEnabled(const char* szCheatName, bool bEnable)
607610
return true;
608611
}
609612

613+
if (!strcmp(szCheatName, PROP_UNDERWORLD_WARP))
614+
{
615+
SetUnderWorldWarpEnabled(bEnable);
616+
return true;
617+
}
618+
610619
std::map<std::string, SCheatSA*>::iterator it = m_Cheats.find(szCheatName);
611620
if (it == m_Cheats.end())
612621
return false;
@@ -622,6 +631,7 @@ void CGameSA::ResetCheats()
622631
SetRandomFoliageEnabled(true);
623632
SetMoonEasterEggEnabled(false);
624633
SetExtraAirResistanceEnabled(true);
634+
SetUnderWorldWarpEnabled(true);
625635

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

681+
void CGameSA::SetUnderWorldWarpEnabled(bool bEnable)
682+
{
683+
m_bUnderworldWarp = !bEnable;
684+
}
685+
686+
bool CGameSA::IsUnderWorldWarpEnabled()
687+
{
688+
return !m_bUnderworldWarp;
689+
}
690+
671691
bool CGameSA::GetJetpackWeaponEnabled(eWeaponType weaponType)
672692
{
673693
if (weaponType >= WEAPONTYPE_BRASSKNUCKLE && weaponType < WEAPONTYPE_LAST_WEAPONTYPE)

Client/game_sa/CGameSA.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
#define PROP_RANDOM_FOLIAGE "randomfoliage"
8484
#define PROP_SNIPER_MOON "snipermoon"
8585
#define PROP_EXTRA_AIR_RESISTANCE "extraairresistance"
86+
#define PROP_UNDERWORLD_WARP "underworldwarp"
8687

8788
struct SCheatSA
8889
{
@@ -399,6 +400,9 @@ class CGameSA : public CGame
399400
bool IsExtraAirResistanceEnabled();
400401
void SetExtraAirResistanceEnabled(bool bEnable);
401402

403+
bool IsUnderWorldWarpEnabled();
404+
void SetUnderWorldWarpEnabled(bool bEnable);
405+
402406
bool VerifySADataFileNames();
403407
bool PerformChecks();
404408
int& GetCheckStatus(void) { return m_iCheckStatus; }
@@ -489,6 +493,7 @@ class CGameSA : public CGame
489493
bool m_bAsyncScriptForced;
490494
bool m_bASyncLoadingSuspended;
491495
int m_iCheckStatus;
496+
bool m_bUnderworldWarp;
492497

493498
static unsigned long* VAR_SystemTime;
494499
static unsigned long* VAR_IsAtMenu;

Client/game_sa/CWorldSA.cpp

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,63 @@ CWorldSA::CWorldSA()
1515
m_pBuildingRemovals = new std::multimap<unsigned short, SBuildingRemoval*>;
1616
m_pDataBuildings = new std::multimap<unsigned short, sDataBuildingRemovalItem*>;
1717
m_pBinaryBuildings = new std::multimap<unsigned short, sBuildingRemovalItem*>;
18+
19+
InstallHooks();
20+
}
21+
22+
void HOOK_FallenPeds();
23+
void HOOK_FallenCars();
24+
25+
void CWorldSA::InstallHooks(void)
26+
{
27+
HookInstall(0x565CB0, (DWORD)HOOK_FallenPeds, 5);
28+
HookInstall(0x565E80, (DWORD)HOOK_FallenCars, 5);
29+
}
30+
31+
DWORD CONTINUE_CWorld_FallenPeds = 0x00565CBA;
32+
DWORD CONTINUE_CWorld_FallenCars = 0x00565E8A;
33+
34+
void _declspec(naked) HOOK_FallenPeds()
35+
{
36+
if (pGame && pGame->IsUnderWorldWarpEnabled())
37+
{
38+
_asm
39+
{
40+
sub esp, 2Ch
41+
push ebx
42+
mov ebx, ds:0B74490h
43+
jmp CONTINUE_CWorld_FallenPeds
44+
}
45+
}
46+
else
47+
{
48+
_asm
49+
{
50+
ret
51+
}
52+
}
53+
}
54+
55+
56+
void _declspec(naked) HOOK_FallenCars()
57+
{
58+
if (pGame && !pGame->IsUnderWorldWarpEnabled())
59+
{
60+
_asm
61+
{
62+
sub esp, 2Ch
63+
push ebx
64+
mov ebx, ds:0B74494h
65+
jmp CONTINUE_CWorld_FallenCars
66+
}
67+
}
68+
else
69+
{
70+
_asm
71+
{
72+
ret
73+
}
74+
}
1875
}
1976

2077
void CWorldSA::Add(CEntity* pEntity, eDebugCaller CallerId)
@@ -1298,4 +1355,4 @@ bool CWorldSA::CalculateImpactPosition(const CVector& vecInputStart, CVector& ve
12981355
// Include dead peds
12991356
MemPutFast<DWORD>(0xB7CD71, 0);
13001357
return false;
1301-
}
1358+
}

Client/game_sa/CWorldSA.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ class CWorldSA : public CWorld
5555
{
5656
public:
5757
CWorldSA();
58+
void InstallHooks(void);
5859
void Add(CEntity* entity, eDebugCaller CallerId);
5960
void Add(CEntitySAInterface* entityInterface, eDebugCaller CallerId);
6061
void Remove(CEntity* entity, eDebugCaller CallerId);

0 commit comments

Comments
 (0)