Skip to content

Commit

Permalink
Synchronize changes from 1.6 master branch [ci skip]
Browse files Browse the repository at this point in the history
219ad73 Add new world special property: fireballdestruct (PR #3179)
  • Loading branch information
github-actions[bot] committed Sep 10, 2023
2 parents 59a1b9f + 219ad73 commit a79ecf6
Show file tree
Hide file tree
Showing 11 changed files with 60 additions and 12 deletions.
18 changes: 15 additions & 3 deletions Client/game_sa/CGameSA.cpp
Expand Up @@ -568,12 +568,9 @@ bool CGameSA::SetCheatEnabled(const char* szCheatName, bool bEnable)

void CGameSA::ResetCheats()
{
// Reset cheats that can't be set by setWorldSpecialPropertyEnabled
std::map<std::string, SCheatSA*>::iterator it;
for (it = m_Cheats.begin(); it != m_Cheats.end(); it++)
{
if (it->second->m_bCanBeSet)
continue;
if (it->second->m_byAddress > (BYTE*)0x8A4000)
MemPutFast<BYTE>(it->second->m_byAddress, 0);
else
Expand Down Expand Up @@ -727,6 +724,21 @@ void CGameSA::SetBurnFlippedCarsEnabled(bool isEnabled)
m_isBurnFlippedCarsEnabled = isEnabled;
}

void CGameSA::SetFireballDestructEnabled(bool isEnabled)
{
if (isEnabled)
{
BYTE originalCodes[7] = {0x81, 0x66, 0x1C, 0x7E, 0xFF, 0xFF, 0xFF};
MemCpy((void*)0x6CCE45, &originalCodes, 7); // CPlane::BlowUpCar
MemCpy((void*)0x6C6E01, &originalCodes, 7); // CHeli::BlowUpCar
}
else
{
MemSet((void*)0x6CCE45, 0x90, 7); // CPlane::BlowUpCar
MemSet((void*)0x6C6E01, 0x90, 7); // CHeli::BlowUpCar
}
}

bool CGameSA::PerformChecks()
{
std::map<std::string, SCheatSA*>::iterator it;
Expand Down
16 changes: 10 additions & 6 deletions Client/game_sa/CGameSA.h
Expand Up @@ -206,14 +206,17 @@ class CGameSA : public CGame
void SetVehicleSunGlareEnabled(bool bEnabled);
bool IsVehicleSunGlareEnabled();

void SetCoronaZTestEnabled(bool isEnabled);
bool IsCoronaZTestEnabled() const noexcept { return m_isCoronaZTestEnabled; }
void SetCoronaZTestEnabled(bool isEnabled) override;
bool IsCoronaZTestEnabled() const noexcept override { return m_isCoronaZTestEnabled; }

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

bool IsBurnFlippedCarsEnabled() const noexcept { return m_isBurnFlippedCarsEnabled; }
void SetBurnFlippedCarsEnabled(bool isEnabled);
bool IsBurnFlippedCarsEnabled() const noexcept override { return m_isBurnFlippedCarsEnabled; }
void SetBurnFlippedCarsEnabled(bool isEnabled) override;

bool IsFireballDestructEnabled() const noexcept override { return m_isFireballDestructEnabled; }
void SetFireballDestructEnabled(bool isEnabled) override;

unsigned long GetMinuteDuration();
void SetMinuteDuration(unsigned long ulTime);
Expand Down Expand Up @@ -327,6 +330,7 @@ class CGameSA : public CGame
bool m_isCoronaZTestEnabled{true};
bool m_areWaterCreaturesEnabled{true};
bool m_isBurnFlippedCarsEnabled{true};
bool m_isFireballDestructEnabled{true};

static unsigned int& ClumpOffset;
static unsigned long* VAR_SystemTime;
Expand Down
5 changes: 5 additions & 0 deletions Client/mods/deathmatch/logic/CClientGame.cpp
Expand Up @@ -5934,6 +5934,9 @@ bool CClientGame::SetWorldSpecialProperty(WorldSpecialProperty property, bool is
case WorldSpecialProperty::BURNFLIPPEDCARS:
g_pGame->SetBurnFlippedCarsEnabled(isEnabled);
return true;
case WorldSpecialProperty::FIREBALLDESTRUCT:
g_pGame->SetFireballDestructEnabled(isEnabled);
return true;
}
return false;
}
Expand Down Expand Up @@ -5963,6 +5966,8 @@ bool CClientGame::IsWorldSpecialProperty(WorldSpecialProperty property)
return g_pGame->IsWaterCreaturesEnabled();
case WorldSpecialProperty::BURNFLIPPEDCARS:
return g_pGame->IsBurnFlippedCarsEnabled();
case WorldSpecialProperty::FIREBALLDESTRUCT:
return g_pGame->IsFireballDestructEnabled();
}
return false;
}
Expand Down
1 change: 1 addition & 0 deletions Client/mods/deathmatch/logic/CPacketHandler.cpp
Expand Up @@ -2368,6 +2368,7 @@ void CPacketHandler::Packet_MapInfo(NetBitStreamInterface& bitStream)
g_pClientGame->SetWorldSpecialProperty(WorldSpecialProperty::CORONAZTEST, wsProps.data.coronaztest);
g_pClientGame->SetWorldSpecialProperty(WorldSpecialProperty::WATERCREATURES, wsProps.data.watercreatures);
g_pClientGame->SetWorldSpecialProperty(WorldSpecialProperty::BURNFLIPPEDCARS, wsProps.data.burnflippedcars);
g_pClientGame->SetWorldSpecialProperty(WorldSpecialProperty::FIREBALLDESTRUCT, wsProps.data2.fireballdestruct);

float fJetpackMaxHeight = 100;
if (!bitStream.Read(fJetpackMaxHeight))
Expand Down
9 changes: 6 additions & 3 deletions Client/sdk/game/CGame.h
Expand Up @@ -205,14 +205,17 @@ class __declspec(novtable) CGame
virtual bool IsVehicleSunGlareEnabled() = 0;

virtual void SetCoronaZTestEnabled(bool isEnabled) = 0;
virtual bool IsCoronaZTestEnabled() const = 0;
virtual bool IsCoronaZTestEnabled() const noexcept = 0;

virtual bool IsWaterCreaturesEnabled() const = 0;
virtual bool IsWaterCreaturesEnabled() const noexcept = 0;
virtual void SetWaterCreaturesEnabled(bool isEnabled) = 0;

virtual bool IsBurnFlippedCarsEnabled() const = 0;
virtual bool IsBurnFlippedCarsEnabled() const noexcept = 0;
virtual void SetBurnFlippedCarsEnabled(bool isEnabled) = 0;

virtual bool IsFireballDestructEnabled() const noexcept = 0;
virtual void SetFireballDestructEnabled(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
Expand Up @@ -243,6 +243,7 @@ CGame::CGame() : m_FloodProtect(4, 30000, 30000) // Max of 4 connecti
m_WorldSpecialProps[WorldSpecialProperty::CORONAZTEST] = true;
m_WorldSpecialProps[WorldSpecialProperty::WATERCREATURES] = true;
m_WorldSpecialProps[WorldSpecialProperty::BURNFLIPPEDCARS] = true;
m_WorldSpecialProps[WorldSpecialProperty::FIREBALLDESTRUCT] = 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
Expand Up @@ -188,6 +188,7 @@ bool CMapInfoPacket::Write(NetBitStreamInterface& BitStream) const
wsProps.data.coronaztest = g_pGame->IsWorldSpecialPropertyEnabled(WorldSpecialProperty::CORONAZTEST);
wsProps.data.watercreatures = g_pGame->IsWorldSpecialPropertyEnabled(WorldSpecialProperty::WATERCREATURES);
wsProps.data.burnflippedcars = g_pGame->IsWorldSpecialPropertyEnabled(WorldSpecialProperty::BURNFLIPPEDCARS);
wsProps.data2.fireballdestruct = g_pGame->IsWorldSpecialPropertyEnabled(WorldSpecialProperty::FIREBALLDESTRUCT);
BitStream.Write(&wsProps);
}

Expand Down
1 change: 1 addition & 0 deletions Shared/mods/deathmatch/logic/Enums.cpp
Expand Up @@ -95,6 +95,7 @@ ADD_ENUM(WorldSpecialProperty::VEHICLESUNGLARE, "vehiclesunglare")
ADD_ENUM(WorldSpecialProperty::CORONAZTEST, "coronaztest")
ADD_ENUM(WorldSpecialProperty::WATERCREATURES, "watercreatures")
ADD_ENUM(WorldSpecialProperty::BURNFLIPPEDCARS, "burnflippedcars")
ADD_ENUM(WorldSpecialProperty::FIREBALLDESTRUCT, "fireballdestruct")
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
Expand Up @@ -87,6 +87,7 @@ enum class WorldSpecialProperty
CORONAZTEST,
WATERCREATURES,
BURNFLIPPEDCARS,
FIREBALLDESTRUCT,
};
DECLARE_ENUM_CLASS(WorldSpecialProperty);

Expand Down
15 changes: 15 additions & 0 deletions Shared/sdk/net/SyncStructures.h
Expand Up @@ -2028,10 +2028,18 @@ struct SWorldSpecialPropertiesStateSync : public ISyncStructure
{
BITCOUNT = 12
};
enum
{
BITCOUNT2 = 1
};

bool Read(NetBitStreamInterface& bitStream)
{
bool isOK = bitStream.ReadBits(reinterpret_cast<char*>(&data), BITCOUNT);
if (bitStream.Can(eBitStreamVersion::WorldSpecialProperty_FireballDestruct))
isOK &= bitStream.ReadBits(reinterpret_cast<char*>(&data2), BITCOUNT2);
else
data2.fireballdestruct = true;

//// Example for adding item:
// if (bitStream.Can(eBitStreamVersion::YourProperty))
Expand All @@ -2044,6 +2052,8 @@ struct SWorldSpecialPropertiesStateSync : public ISyncStructure
void Write(NetBitStreamInterface& bitStream) const
{
bitStream.WriteBits(reinterpret_cast<const char*>(&data), BITCOUNT);
if (bitStream.Can(eBitStreamVersion::WorldSpecialProperty_FireballDestruct))
bitStream.WriteBits(reinterpret_cast<const char*>(&data2), BITCOUNT2);

//// Example for adding item:
// if (bitStream.Can(eBitStreamVersion::YourProperty))
Expand All @@ -2067,6 +2077,10 @@ struct SWorldSpecialPropertiesStateSync : public ISyncStructure
} data;

// Add new ones in separate structs
struct
{
bool fireballdestruct : 1;
} data2;

SWorldSpecialPropertiesStateSync()
{
Expand All @@ -2083,6 +2097,7 @@ struct SWorldSpecialPropertiesStateSync : public ISyncStructure
data.coronaztest = true;
data.watercreatures = true;
data.burnflippedcars = true;
data2.fireballdestruct = true;
}
};

Expand Down
4 changes: 4 additions & 0 deletions Shared/sdk/net/bitstream.h
Expand Up @@ -532,6 +532,10 @@ enum class eBitStreamVersion : unsigned short
// 2023-08-17
WorldSpecialProperties,

// Add "fireballdestruct" to setWorldSpecialPropertyEnabled
// 2023-09-09
WorldSpecialProperty_FireballDestruct,

// 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 a79ecf6

Please sign in to comment.