Skip to content

Commit

Permalink
Add new special world property ignorefirestate (multitheftauto#3845)
Browse files Browse the repository at this point in the history
  • Loading branch information
FileEX authored Nov 21, 2024
1 parent 6f90880 commit 46f3580
Show file tree
Hide file tree
Showing 12 changed files with 69 additions and 1 deletion.
28 changes: 28 additions & 0 deletions Client/game_sa/CGameSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -848,6 +848,34 @@ void CGameSA::SetRoadSignsTextEnabled(bool isEnabled)
m_isRoadSignsTextEnabled = isEnabled;
}

void CGameSA::SetIgnoreFireStateEnabled(bool isEnabled)
{
if (isEnabled == m_isIgnoreFireStateEnabled)
return;

if (isEnabled)
{
MemSet((void*)0x6511B9, 0x90, 10); // CCarEnterExit::IsVehicleStealable
MemSet((void*)0x643A95, 0x90, 14); // CTaskComplexEnterCar::CreateFirstSubTask
MemSet((void*)0x6900B5, 0x90, 14); // CTaskComplexCopInCar::ControlSubTask
MemSet((void*)0x64F3DB, 0x90, 14); // CCarEnterExit::IsPlayerToQuitCarEnter

MemSet((void*)0x685A7F, 0x90, 14); // CTaskSimplePlayerOnFoot::ProcessPlayerWeapon
}
else
{
// Restore original bytes
MemCpy((void*)0x6511B9, "\x88\x86\x90\x04\x00\x00\x85\xC0\x75\x3E", 10);
MemCpy((void*)0x643A95, "\x8B\x88\x90\x04\x00\x00\x85\xC9\x0F\x85\x99\x01\x00\x00", 14);
MemCpy((void*)0x6900B5, "\x8B\x81\x90\x04\x00\x00\x85\xC0\x0F\x85\x1A\x01\x00\x00", 14);
MemCpy((void*)0x64F3DB, "\x8B\x85\x90\x04\x00\x00\x85\xC0\x0F\x85\x1B\x01\x00\x00", 14);

MemCpy((void*)0x685A7F, "\x8B\x86\x30\x07\x00\x00\x85\xC0\x0F\x85\x1D\x01\x00\x00", 14);
}

m_isIgnoreFireStateEnabled = isEnabled;
}

bool CGameSA::PerformChecks()
{
std::map<std::string, SCheatSA*>::iterator it;
Expand Down
3 changes: 3 additions & 0 deletions Client/game_sa/CGameSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,8 @@ class CGameSA : public CGame
bool IsTunnelWeatherBlendEnabled() const noexcept override { return m_isTunnelWeatherBlendEnabled; }
void SetTunnelWeatherBlendEnabled(bool isEnabled) override;

bool IsIgnoreFireStateEnabled() const noexcept override { return m_isIgnoreFireStateEnabled; }
void SetIgnoreFireStateEnabled(bool isEnabled) override;

unsigned long GetMinuteDuration();
void SetMinuteDuration(unsigned long ulTime);
Expand Down Expand Up @@ -378,6 +380,7 @@ class CGameSA : public CGame
bool m_isRoadSignsTextEnabled{true};
bool m_isBuildingsRemoved{false};
bool m_isExtendedWaterCannonsEnabled{false};
bool m_isIgnoreFireStateEnabled{false};

static unsigned int& ClumpOffset;

Expand Down
8 changes: 7 additions & 1 deletion Client/mods/deathmatch/logic/CClientGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ CClientGame::CClientGame(bool bLocalPlay) : m_ServerInfo(new CServerInfo())
m_Glitches[GLITCH_BADDRIVEBYHITBOX] = false;
m_Glitches[GLITCH_QUICKSTAND] = false;
m_Glitches[GLITCH_KICKOUTOFVEHICLE_ONMODELREPLACE] = false;

g_pMultiplayer->DisableBadDrivebyHitboxes(true);

// Remove Night & Thermal vision view (if enabled).
Expand Down Expand Up @@ -6025,6 +6026,9 @@ bool CClientGame::SetWorldSpecialProperty(WorldSpecialProperty property, bool is
case WorldSpecialProperty::TUNNELWEATHERBLEND:
g_pGame->SetTunnelWeatherBlendEnabled(isEnabled);
return true;
case WorldSpecialProperty::IGNOREFIRESTATE:
g_pGame->SetIgnoreFireStateEnabled(isEnabled);
return true;
}
return false;
}
Expand Down Expand Up @@ -6062,6 +6066,8 @@ bool CClientGame::IsWorldSpecialProperty(WorldSpecialProperty property)
return g_pGame->IsRoadSignsTextEnabled();
case WorldSpecialProperty::TUNNELWEATHERBLEND:
return g_pGame->IsTunnelWeatherBlendEnabled();
case WorldSpecialProperty::IGNOREFIRESTATE:
return g_pGame->IsIgnoreFireStateEnabled();
}
return false;
}
Expand Down Expand Up @@ -6475,7 +6481,7 @@ void CClientGame::OutputServerInfo()
{
SString strEnabledGlitches;
const char* szGlitchNames[] = {"Quick reload", "Fast fire", "Fast move", "Crouch bug", "Close damage", "Hit anim", "Fast sprint",
"Bad driveby hitboxes", "Quick stand"};
"Bad driveby hitboxes", "Quick stand", "Kickout of vehicle on model replace"};
for (uint i = 0; i < NUM_GLITCHES; i++)
{
if (IsGlitchEnabled(i))
Expand Down
1 change: 1 addition & 0 deletions Client/mods/deathmatch/logic/CPacketHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2397,6 +2397,7 @@ void CPacketHandler::Packet_MapInfo(NetBitStreamInterface& bitStream)
g_pClientGame->SetWorldSpecialProperty(WorldSpecialProperty::ROADSIGNSTEXT, wsProps.data3.roadsignstext);
g_pClientGame->SetWorldSpecialProperty(WorldSpecialProperty::EXTENDEDWATERCANNONS, wsProps.data4.extendedwatercannons);
g_pClientGame->SetWorldSpecialProperty(WorldSpecialProperty::TUNNELWEATHERBLEND, wsProps.data5.tunnelweatherblend);
g_pClientGame->SetWorldSpecialProperty(WorldSpecialProperty::IGNOREFIRESTATE, wsProps.data6.ignoreFireState);

float fJetpackMaxHeight = 100;
if (!bitStream.Read(fJetpackMaxHeight))
Expand Down
1 change: 1 addition & 0 deletions Client/multiplayer_sa/CMultiplayerSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1862,6 +1862,7 @@ void CMultiplayerSA::DisableCloseRangeDamage(bool bDisabled)
MemPut<BYTE>(0x73BA00, 0x86);
}
}

bool CMultiplayerSA::GetInteriorSoundsEnabled()
{
return bInteriorSoundsEnabled;
Expand Down
3 changes: 3 additions & 0 deletions Client/sdk/game/CGame.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,9 @@ class __declspec(novtable) CGame
virtual bool IsTunnelWeatherBlendEnabled() const noexcept = 0;
virtual void SetTunnelWeatherBlendEnabled(bool isEnabled) = 0;

virtual bool IsIgnoreFireStateEnabled() const noexcept = 0;
virtual void SetIgnoreFireStateEnabled(bool isEnabled) = 0;

virtual CWeapon* CreateWeapon() = 0;
virtual CWeaponStat* CreateWeaponStat(eWeaponType weaponType, eWeaponSkill weaponSkill) = 0;

Expand Down
1 change: 1 addition & 0 deletions Server/mods/deathmatch/logic/CGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ CGame::CGame() : m_FloodProtect(4, 30000, 30000) // Max of 4 connecti
m_WorldSpecialProps[WorldSpecialProperty::EXTENDEDWATERCANNONS] = true;
m_WorldSpecialProps[WorldSpecialProperty::ROADSIGNSTEXT] = true;
m_WorldSpecialProps[WorldSpecialProperty::TUNNELWEATHERBLEND] = true;
m_WorldSpecialProps[WorldSpecialProperty::IGNOREFIRESTATE] = false;

m_JetpackWeapons[WEAPONTYPE_MICRO_UZI] = true;
m_JetpackWeapons[WEAPONTYPE_TEC9] = true;
Expand Down
1 change: 1 addition & 0 deletions Server/mods/deathmatch/logic/packets/CMapInfoPacket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ bool CMapInfoPacket::Write(NetBitStreamInterface& BitStream) const
wsProps.data3.roadsignstext = g_pGame->IsWorldSpecialPropertyEnabled(WorldSpecialProperty::ROADSIGNSTEXT);
wsProps.data4.extendedwatercannons = g_pGame->IsWorldSpecialPropertyEnabled(WorldSpecialProperty::EXTENDEDWATERCANNONS);
wsProps.data5.tunnelweatherblend = g_pGame->IsWorldSpecialPropertyEnabled(WorldSpecialProperty::TUNNELWEATHERBLEND);
wsProps.data6.ignoreFireState = g_pGame->IsWorldSpecialPropertyEnabled(WorldSpecialProperty::IGNOREFIRESTATE);
BitStream.Write(&wsProps);
}

Expand Down
1 change: 1 addition & 0 deletions Shared/mods/deathmatch/logic/Enums.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ ADD_ENUM(WorldSpecialProperty::FIREBALLDESTRUCT, "fireballdestruct")
ADD_ENUM(WorldSpecialProperty::EXTENDEDWATERCANNONS, "extendedwatercannons")
ADD_ENUM(WorldSpecialProperty::ROADSIGNSTEXT, "roadsignstext")
ADD_ENUM(WorldSpecialProperty::TUNNELWEATHERBLEND, "tunnelweatherblend")
ADD_ENUM(WorldSpecialProperty::IGNOREFIRESTATE, "ignorefirestate")
IMPLEMENT_ENUM_CLASS_END("world-special-property")

IMPLEMENT_ENUM_BEGIN(ePacketID)
Expand Down
1 change: 1 addition & 0 deletions Shared/mods/deathmatch/logic/Enums.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ enum class WorldSpecialProperty
ROADSIGNSTEXT,
EXTENDEDWATERCANNONS,
TUNNELWEATHERBLEND,
IGNOREFIRESTATE,
};
DECLARE_ENUM_CLASS(WorldSpecialProperty);

Expand Down
18 changes: 18 additions & 0 deletions Shared/sdk/net/SyncStructures.h
Original file line number Diff line number Diff line change
Expand Up @@ -2044,6 +2044,10 @@ struct SWorldSpecialPropertiesStateSync : public ISyncStructure
{
BITCOUNT5 = 1
};
enum
{
BITCOUNT6 = 1
};

bool Read(NetBitStreamInterface& bitStream)
{
Expand All @@ -2068,6 +2072,11 @@ struct SWorldSpecialPropertiesStateSync : public ISyncStructure
else
data5.tunnelweatherblend = true;

if (bitStream.Can(eBitStreamVersion::WorldSpecialProperty_IgnoreFireState))
isOK &= bitStream.ReadBits(reinterpret_cast<char*>(&data6), BITCOUNT6);
else
data6.ignoreFireState = false;

//// Example for adding item:
// if (bitStream.Can(eBitStreamVersion::YourProperty))
// isOK &= bitStream.ReadBits(reinterpret_cast<char*>(&data9), BITCOUNT9);
Expand All @@ -2091,6 +2100,9 @@ struct SWorldSpecialPropertiesStateSync : public ISyncStructure
if (bitStream.Can(eBitStreamVersion::WorldSpecialProperty_TunnelWeatherBlend))
bitStream.WriteBits(reinterpret_cast<const char*>(&data5), BITCOUNT5);

if (bitStream.Can(eBitStreamVersion::WorldSpecialProperty_IgnoreFireState))
bitStream.WriteBits(reinterpret_cast<const char*>(&data6), BITCOUNT6);

//// Example for adding item:
// if (bitStream.Can(eBitStreamVersion::YourProperty))
// bitStream.WriteBits(reinterpret_cast<const char*>(&data9), BITCOUNT9);
Expand Down Expand Up @@ -2132,6 +2144,11 @@ struct SWorldSpecialPropertiesStateSync : public ISyncStructure
{
bool tunnelweatherblend : 1;
} data5;

struct
{
bool ignoreFireState : 1;
} data6;

SWorldSpecialPropertiesStateSync()
{
Expand All @@ -2152,6 +2169,7 @@ struct SWorldSpecialPropertiesStateSync : public ISyncStructure
data3.roadsignstext = true;
data4.extendedwatercannons = true;
data5.tunnelweatherblend = true;
data6.ignoreFireState = false;
}
};

Expand Down
4 changes: 4 additions & 0 deletions Shared/sdk/net/bitstream.h
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,10 @@ enum class eBitStreamVersion : unsigned short
// 2024-09-04
CheckDuplicateSerials,

// Add ignorefirestate special world property
// 2024-11-07
WorldSpecialProperty_IgnoreFireState,

// This allows us to automatically increment the BitStreamVersion when things are added to this enum.
// Make sure you only add things above this comment.
Next,
Expand Down

0 comments on commit 46f3580

Please sign in to comment.