Skip to content

Commit 9a0790e

Browse files
authored
Add ability to toggle tunnel weather blending effect (PR #3526)
1 parent 9c9362f commit 9a0790e

File tree

11 files changed

+66
-1
lines changed

11 files changed

+66
-1
lines changed

Client/game_sa/CGameSA.cpp

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ void CGameSA::SetCoronaZTestEnabled(bool isEnabled)
664664
m_isCoronaZTestEnabled = isEnabled;
665665
}
666666

667-
void CGameSA::SetWaterCreaturesEnabled(bool isEnabled)
667+
void CGameSA::SetWaterCreaturesEnabled(bool isEnabled)
668668
{
669669
if (isEnabled == m_areWaterCreaturesEnabled)
670670
return;
@@ -684,6 +684,29 @@ void CGameSA::SetWaterCreaturesEnabled(bool isEnabled)
684684
m_areWaterCreaturesEnabled = isEnabled;
685685
}
686686

687+
void CGameSA::SetTunnelWeatherBlendEnabled(bool isEnabled)
688+
{
689+
if (isEnabled == m_isTunnelWeatherBlendEnabled)
690+
return;
691+
// CWeather::UpdateInTunnelness
692+
DWORD functionAddress = 0x72B630;
693+
if (isEnabled)
694+
{
695+
// Restore original bytes: 83 EC 20
696+
MemPut<BYTE>(functionAddress, 0x83); // Restore 83
697+
MemPut<BYTE>(functionAddress + 1, 0xEC); // Restore EC
698+
MemPut<BYTE>(functionAddress + 2, 0x20); // Restore 20
699+
}
700+
else
701+
{
702+
// Patch CWeather::UpdateInTunnelness (Found By AlexTMjugador)
703+
MemPut<BYTE>(functionAddress, 0xC3); // Write C3 (RET)
704+
MemPut<BYTE>(functionAddress + 1, 0x90); // Write 90 (NOP)
705+
MemPut<BYTE>(functionAddress + 2, 0x90); // Write 90 (NOP)
706+
}
707+
m_isTunnelWeatherBlendEnabled = isEnabled;
708+
}
709+
687710
void CGameSA::SetBurnFlippedCarsEnabled(bool isEnabled)
688711
{
689712
if (isEnabled == m_isBurnFlippedCarsEnabled)

Client/game_sa/CGameSA.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,10 @@ class CGameSA : public CGame
244244
bool IsRoadSignsTextEnabled() const noexcept override { return m_isRoadSignsTextEnabled; }
245245
void SetRoadSignsTextEnabled(bool isEnabled) override;
246246

247+
bool IsTunnelWeatherBlendEnabled() const noexcept override { return m_isTunnelWeatherBlendEnabled; }
248+
void SetTunnelWeatherBlendEnabled(bool isEnabled) override;
249+
250+
247251
unsigned long GetMinuteDuration();
248252
void SetMinuteDuration(unsigned long ulTime);
249253

@@ -363,6 +367,7 @@ class CGameSA : public CGame
363367
int m_iCheckStatus;
364368
bool m_bUnderworldWarp;
365369
bool m_isCoronaZTestEnabled{true};
370+
bool m_isTunnelWeatherBlendEnabled{true};
366371
bool m_areWaterCreaturesEnabled{true};
367372
bool m_isBurnFlippedCarsEnabled{true};
368373
bool m_isFireballDestructEnabled{true};

Client/mods/deathmatch/logic/CClientGame.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6108,6 +6108,9 @@ bool CClientGame::SetWorldSpecialProperty(WorldSpecialProperty property, bool is
61086108
case WorldSpecialProperty::ROADSIGNSTEXT:
61096109
g_pGame->SetRoadSignsTextEnabled(isEnabled);
61106110
return true;
6111+
case WorldSpecialProperty::TUNNELWEATHERBLEND:
6112+
g_pGame->SetTunnelWeatherBlendEnabled(isEnabled);
6113+
return true;
61116114
}
61126115
return false;
61136116
}
@@ -6143,6 +6146,8 @@ bool CClientGame::IsWorldSpecialProperty(WorldSpecialProperty property)
61436146
return g_pGame->IsExtendedWaterCannonsEnabled();
61446147
case WorldSpecialProperty::ROADSIGNSTEXT:
61456148
return g_pGame->IsRoadSignsTextEnabled();
6149+
case WorldSpecialProperty::TUNNELWEATHERBLEND:
6150+
return g_pGame->IsTunnelWeatherBlendEnabled();
61466151
}
61476152
return false;
61486153
}

Client/mods/deathmatch/logic/CPacketHandler.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2390,6 +2390,7 @@ void CPacketHandler::Packet_MapInfo(NetBitStreamInterface& bitStream)
23902390
g_pClientGame->SetWorldSpecialProperty(WorldSpecialProperty::FIREBALLDESTRUCT, wsProps.data2.fireballdestruct);
23912391
g_pClientGame->SetWorldSpecialProperty(WorldSpecialProperty::ROADSIGNSTEXT, wsProps.data3.roadsignstext);
23922392
g_pClientGame->SetWorldSpecialProperty(WorldSpecialProperty::EXTENDEDWATERCANNONS, wsProps.data4.extendedwatercannons);
2393+
g_pClientGame->SetWorldSpecialProperty(WorldSpecialProperty::TUNNELWEATHERBLEND, wsProps.data5.tunnelweatherblend);
23932394

23942395
float fJetpackMaxHeight = 100;
23952396
if (!bitStream.Read(fJetpackMaxHeight))

Client/sdk/game/CGame.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,9 @@ class __declspec(novtable) CGame
225225
virtual bool IsRoadSignsTextEnabled() const noexcept = 0;
226226
virtual void SetRoadSignsTextEnabled(bool isEnabled) = 0;
227227

228+
virtual bool IsTunnelWeatherBlendEnabled() const noexcept = 0;
229+
virtual void SetTunnelWeatherBlendEnabled(bool isEnabled) = 0;
230+
228231
virtual CWeapon* CreateWeapon() = 0;
229232
virtual CWeaponStat* CreateWeaponStat(eWeaponType weaponType, eWeaponSkill weaponSkill) = 0;
230233

@@ -269,4 +272,5 @@ class __declspec(novtable) CGame
269272
virtual void RestoreGameBuildings() = 0;
270273

271274
virtual bool SetBuildingPoolSize(size_t size) = 0;
275+
272276
};

Server/mods/deathmatch/logic/CGame.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ CGame::CGame() : m_FloodProtect(4, 30000, 30000) // Max of 4 connecti
248248
m_WorldSpecialProps[WorldSpecialProperty::FIREBALLDESTRUCT] = true;
249249
m_WorldSpecialProps[WorldSpecialProperty::EXTENDEDWATERCANNONS] = true;
250250
m_WorldSpecialProps[WorldSpecialProperty::ROADSIGNSTEXT] = true;
251+
m_WorldSpecialProps[WorldSpecialProperty::TUNNELWEATHERBLEND] = true;
251252

252253
m_JetpackWeapons[WEAPONTYPE_MICRO_UZI] = true;
253254
m_JetpackWeapons[WEAPONTYPE_TEC9] = true;

Server/mods/deathmatch/logic/packets/CMapInfoPacket.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ bool CMapInfoPacket::Write(NetBitStreamInterface& BitStream) const
191191
wsProps.data2.fireballdestruct = g_pGame->IsWorldSpecialPropertyEnabled(WorldSpecialProperty::FIREBALLDESTRUCT);
192192
wsProps.data3.roadsignstext = g_pGame->IsWorldSpecialPropertyEnabled(WorldSpecialProperty::ROADSIGNSTEXT);
193193
wsProps.data4.extendedwatercannons = g_pGame->IsWorldSpecialPropertyEnabled(WorldSpecialProperty::EXTENDEDWATERCANNONS);
194+
wsProps.data5.tunnelweatherblend = g_pGame->IsWorldSpecialPropertyEnabled(WorldSpecialProperty::TUNNELWEATHERBLEND);
194195
BitStream.Write(&wsProps);
195196
}
196197

Shared/mods/deathmatch/logic/Enums.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ ADD_ENUM(WorldSpecialProperty::BURNFLIPPEDCARS, "burnflippedcars")
100100
ADD_ENUM(WorldSpecialProperty::FIREBALLDESTRUCT, "fireballdestruct")
101101
ADD_ENUM(WorldSpecialProperty::EXTENDEDWATERCANNONS, "extendedwatercannons")
102102
ADD_ENUM(WorldSpecialProperty::ROADSIGNSTEXT, "roadsignstext")
103+
ADD_ENUM(WorldSpecialProperty::TUNNELWEATHERBLEND, "tunnelweatherblend")
103104
IMPLEMENT_ENUM_CLASS_END("world-special-property")
104105

105106
IMPLEMENT_ENUM_BEGIN(ePacketID)

Shared/mods/deathmatch/logic/Enums.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ enum class WorldSpecialProperty
9090
FIREBALLDESTRUCT,
9191
ROADSIGNSTEXT,
9292
EXTENDEDWATERCANNONS,
93+
TUNNELWEATHERBLEND,
9394
};
9495
DECLARE_ENUM_CLASS(WorldSpecialProperty);
9596

Shared/sdk/net/SyncStructures.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2040,6 +2040,10 @@ struct SWorldSpecialPropertiesStateSync : public ISyncStructure
20402040
{
20412041
BITCOUNT4 = 1
20422042
};
2043+
enum
2044+
{
2045+
BITCOUNT5 = 1
2046+
};
20432047

20442048
bool Read(NetBitStreamInterface& bitStream)
20452049
{
@@ -2059,6 +2063,11 @@ struct SWorldSpecialPropertiesStateSync : public ISyncStructure
20592063
else
20602064
data4.extendedwatercannons = true;
20612065

2066+
if (bitStream.Can(eBitStreamVersion::WorldSpecialProperty_TunnelWeatherBlend))
2067+
isOK &= bitStream.ReadBits(reinterpret_cast<char*>(&data5), BITCOUNT5);
2068+
else
2069+
data5.tunnelweatherblend = true;
2070+
20622071
//// Example for adding item:
20632072
// if (bitStream.Can(eBitStreamVersion::YourProperty))
20642073
// isOK &= bitStream.ReadBits(reinterpret_cast<char*>(&data9), BITCOUNT9);
@@ -2079,6 +2088,9 @@ struct SWorldSpecialPropertiesStateSync : public ISyncStructure
20792088
if (bitStream.Can(eBitStreamVersion::WorldSpecialProperty_ExtendedWaterCannons))
20802089
bitStream.WriteBits(reinterpret_cast<const char*>(&data4), BITCOUNT4);
20812090

2091+
if (bitStream.Can(eBitStreamVersion::WorldSpecialProperty_TunnelWeatherBlend))
2092+
bitStream.WriteBits(reinterpret_cast<const char*>(&data5), BITCOUNT5);
2093+
20822094
//// Example for adding item:
20832095
// if (bitStream.Can(eBitStreamVersion::YourProperty))
20842096
// bitStream.WriteBits(reinterpret_cast<const char*>(&data9), BITCOUNT9);
@@ -2116,6 +2128,11 @@ struct SWorldSpecialPropertiesStateSync : public ISyncStructure
21162128
bool extendedwatercannons : 1;
21172129
} data4;
21182130

2131+
struct
2132+
{
2133+
bool tunnelweatherblend : 1;
2134+
} data5;
2135+
21192136
SWorldSpecialPropertiesStateSync()
21202137
{
21212138
// Set default states
@@ -2134,6 +2151,7 @@ struct SWorldSpecialPropertiesStateSync : public ISyncStructure
21342151
data2.fireballdestruct = true;
21352152
data3.roadsignstext = true;
21362153
data4.extendedwatercannons = true;
2154+
data5.tunnelweatherblend = true;
21372155
}
21382156
};
21392157

0 commit comments

Comments
 (0)