Skip to content

Commit

Permalink
Add roadsignstext special world property (#3385)
Browse files Browse the repository at this point in the history
* Added roadsignstext special world property

* Fix compatibility
  • Loading branch information
FileEX authored May 23, 2024
1 parent e3338c2 commit 4a746ec
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Client/game_sa/CGameSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,17 @@ void CGameSA::SetFireballDestructEnabled(bool isEnabled)
m_isFireballDestructEnabled = isEnabled;
}

void CGameSA::SetRoadSignsTextEnabled(bool isEnabled)
{
if (isEnabled == m_isRoadSignsTextEnabled)
return;

// Skip JMP to CCustomRoadsignMgr::RenderRoadsignAtomic
MemPut<BYTE>(0x5342ED, isEnabled ? 0xEB : 0x74);

m_isRoadSignsTextEnabled = isEnabled;
}

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

bool IsRoadSignsTextEnabled() const noexcept override { return m_isRoadSignsTextEnabled; }
void SetRoadSignsTextEnabled(bool isEnabled) override;

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

Expand Down Expand Up @@ -336,6 +339,7 @@ class CGameSA : public CGame
bool m_areWaterCreaturesEnabled{true};
bool m_isBurnFlippedCarsEnabled{true};
bool m_isFireballDestructEnabled{true};
bool m_isRoadSignsTextEnabled{true};

static unsigned int& ClumpOffset;

Expand Down
5 changes: 5 additions & 0 deletions Client/mods/deathmatch/logic/CClientGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6091,6 +6091,9 @@ bool CClientGame::SetWorldSpecialProperty(WorldSpecialProperty property, bool is
case WorldSpecialProperty::FIREBALLDESTRUCT:
g_pGame->SetFireballDestructEnabled(isEnabled);
return true;
case WorldSpecialProperty::ROADSIGNSTEXT:
g_pGame->SetRoadSignsTextEnabled(isEnabled);
return true;
}
return false;
}
Expand Down Expand Up @@ -6122,6 +6125,8 @@ bool CClientGame::IsWorldSpecialProperty(WorldSpecialProperty property)
return g_pGame->IsBurnFlippedCarsEnabled();
case WorldSpecialProperty::FIREBALLDESTRUCT:
return g_pGame->IsFireballDestructEnabled();
case WorldSpecialProperty::ROADSIGNSTEXT:
return g_pGame->IsRoadSignsTextEnabled();
}
return false;
}
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 @@ -2387,6 +2387,7 @@ void CPacketHandler::Packet_MapInfo(NetBitStreamInterface& bitStream)
g_pClientGame->SetWorldSpecialProperty(WorldSpecialProperty::WATERCREATURES, wsProps.data.watercreatures);
g_pClientGame->SetWorldSpecialProperty(WorldSpecialProperty::BURNFLIPPEDCARS, wsProps.data.burnflippedcars);
g_pClientGame->SetWorldSpecialProperty(WorldSpecialProperty::FIREBALLDESTRUCT, wsProps.data2.fireballdestruct);
g_pClientGame->SetWorldSpecialProperty(WorldSpecialProperty::ROADSIGNSTEXT, wsProps.data3.roadsignstext);

float fJetpackMaxHeight = 100;
if (!bitStream.Read(fJetpackMaxHeight))
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 @@ -217,6 +217,9 @@ class __declspec(novtable) CGame
virtual bool IsFireballDestructEnabled() const noexcept = 0;
virtual void SetFireballDestructEnabled(bool isEnabled) = 0;

virtual bool IsRoadSignsTextEnabled() const noexcept = 0;
virtual void SetRoadSignsTextEnabled(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 @@ -246,6 +246,7 @@ CGame::CGame() : m_FloodProtect(4, 30000, 30000) // Max of 4 connecti
m_WorldSpecialProps[WorldSpecialProperty::WATERCREATURES] = true;
m_WorldSpecialProps[WorldSpecialProperty::BURNFLIPPEDCARS] = true;
m_WorldSpecialProps[WorldSpecialProperty::FIREBALLDESTRUCT] = true;
m_WorldSpecialProps[WorldSpecialProperty::ROADSIGNSTEXT] = true;

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 @@ -189,6 +189,7 @@ bool CMapInfoPacket::Write(NetBitStreamInterface& BitStream) const
wsProps.data.watercreatures = g_pGame->IsWorldSpecialPropertyEnabled(WorldSpecialProperty::WATERCREATURES);
wsProps.data.burnflippedcars = g_pGame->IsWorldSpecialPropertyEnabled(WorldSpecialProperty::BURNFLIPPEDCARS);
wsProps.data2.fireballdestruct = g_pGame->IsWorldSpecialPropertyEnabled(WorldSpecialProperty::FIREBALLDESTRUCT);
wsProps.data3.roadsignstext = g_pGame->IsWorldSpecialPropertyEnabled(WorldSpecialProperty::ROADSIGNSTEXT);
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 @@ -98,6 +98,7 @@ ADD_ENUM(WorldSpecialProperty::CORONAZTEST, "coronaztest")
ADD_ENUM(WorldSpecialProperty::WATERCREATURES, "watercreatures")
ADD_ENUM(WorldSpecialProperty::BURNFLIPPEDCARS, "burnflippedcars")
ADD_ENUM(WorldSpecialProperty::FIREBALLDESTRUCT, "fireballdestruct")
ADD_ENUM(WorldSpecialProperty::ROADSIGNSTEXT, "roadsignstext")
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 @@ -88,6 +88,7 @@ enum class WorldSpecialProperty
WATERCREATURES,
BURNFLIPPEDCARS,
FIREBALLDESTRUCT,
ROADSIGNSTEXT,
};
DECLARE_ENUM_CLASS(WorldSpecialProperty);

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

bool Read(NetBitStreamInterface& bitStream)
{
Expand All @@ -2041,6 +2045,12 @@ struct SWorldSpecialPropertiesStateSync : public ISyncStructure
else
data2.fireballdestruct = true;

if (bitStream.Can(eBitStreamVersion::WorldSpecialProperty_RoadSignsText))
isOK &= bitStream.ReadBits(reinterpret_cast<char*>(&data3), BITCOUNT3);
else
data3.roadsignstext = true;


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

if (bitStream.Can(eBitStreamVersion::WorldSpecialProperty_RoadSignsText))
bitStream.WriteBits(reinterpret_cast<const char*>(&data3), BITCOUNT3);

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

struct
{
bool roadsignstext : 1;
} data3;

SWorldSpecialPropertiesStateSync()
{
// Set default states
Expand All @@ -2098,6 +2116,7 @@ struct SWorldSpecialPropertiesStateSync : public ISyncStructure
data.watercreatures = true;
data.burnflippedcars = true;
data2.fireballdestruct = true;
data3.roadsignstext = true;
}
};

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 @@ -540,6 +540,10 @@ enum class eBitStreamVersion : unsigned short
// 2023-10-12
CPlayerJoinCompletePacket_ServerName,

// Add "roadsignstext" to setWorldSpecialPropertyEnabled
// 2024-05-17
WorldSpecialProperty_RoadSignsText,

// 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 4a746ec

Please sign in to comment.