Skip to content

Commit 5ee6414

Browse files
authored
Add "flyingcomponents" special world property (PR #3597)
1 parent f3b3013 commit 5ee6414

File tree

11 files changed

+55
-12
lines changed

11 files changed

+55
-12
lines changed

Client/mods/deathmatch/logic/CClientGame.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6044,6 +6044,9 @@ bool CClientGame::SetWorldSpecialProperty(WorldSpecialProperty property, bool is
60446044
case WorldSpecialProperty::IGNOREFIRESTATE:
60456045
g_pGame->SetIgnoreFireStateEnabled(isEnabled);
60466046
break;
6047+
case WorldSpecialProperty::FLYINGCOMPONENTS:
6048+
m_pVehicleManager->SetSpawnFlyingComponentEnabled(isEnabled);
6049+
break;
60476050
default:
60486051
return false;
60496052
}
@@ -6094,6 +6097,8 @@ bool CClientGame::IsWorldSpecialProperty(WorldSpecialProperty property)
60946097
return g_pGame->IsTunnelWeatherBlendEnabled();
60956098
case WorldSpecialProperty::IGNOREFIRESTATE:
60966099
return g_pGame->IsIgnoreFireStateEnabled();
6100+
case WorldSpecialProperty::FLYINGCOMPONENTS:
6101+
return m_pVehicleManager->IsSpawnFlyingComponentEnabled();
60976102
}
60986103
return false;
60996104
}

Client/mods/deathmatch/logic/CClientVehicle.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -808,10 +808,12 @@ void CClientVehicle::Fix()
808808

809809
SFixedArray<unsigned char, MAX_DOORS> ucDoorStates;
810810
GetInitialDoorStates(ucDoorStates);
811+
812+
bool flyingComponents = m_pVehicleManager->IsSpawnFlyingComponentEnabled();
811813
for (int i = 0; i < MAX_DOORS; i++)
812-
SetDoorStatus(i, ucDoorStates[i], true);
814+
SetDoorStatus(i, ucDoorStates[i], flyingComponents);
813815
for (int i = 0; i < MAX_PANELS; i++)
814-
SetPanelStatus(i, 0);
816+
SetPanelStatus(i, 0, flyingComponents);
815817
for (int i = 0; i < MAX_LIGHTS; i++)
816818
SetLightStatus(i, 0);
817819
for (int i = 0; i < MAX_WHEELS; i++)
@@ -2170,11 +2172,12 @@ void CClientVehicle::StreamedInPulse()
21702172
{
21712173
// Set the damage model doors
21722174
CDamageManager* pDamageManager = m_pVehicle->GetDamageManager();
2175+
bool flyingComponents = m_pVehicleManager->IsSpawnFlyingComponentEnabled();
21732176

21742177
for (int i = 0; i < MAX_DOORS; i++)
2175-
pDamageManager->SetDoorStatus(static_cast<eDoors>(i), m_ucDoorStates[i], true);
2178+
pDamageManager->SetDoorStatus(static_cast<eDoors>(i), m_ucDoorStates[i], flyingComponents);
21762179
for (int i = 0; i < MAX_PANELS; i++)
2177-
pDamageManager->SetPanelStatus(static_cast<ePanels>(i), m_ucPanelStates[i]);
2180+
pDamageManager->SetPanelStatus(static_cast<ePanels>(i), m_ucPanelStates[i], flyingComponents);
21782181
for (int i = 0; i < MAX_LIGHTS; i++)
21792182
pDamageManager->SetLightStatus(static_cast<eLights>(i), m_ucLightStates[i]);
21802183
}

Client/mods/deathmatch/logic/CClientVehicleManager.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,13 @@ class CClientVehicleManager
7070
void OnCreation(CClientVehicle* pVehicle);
7171
void OnDestruction(CClientVehicle* pVehicle);
7272

73+
bool IsSpawnFlyingComponentEnabled() const noexcept { return m_spawnFlyingComponentsDuringRecreate; }
74+
void SetSpawnFlyingComponentEnabled(bool isEnabled) noexcept { m_spawnFlyingComponentsDuringRecreate = isEnabled; }
75+
7376
protected:
7477
CClientManager* m_pManager;
7578
bool m_bCanRemoveFromList;
7679
CMappedArray<CClientVehicle*> m_List;
7780
CMappedArray<CClientVehicle*> m_StreamedIn;
81+
bool m_spawnFlyingComponentsDuringRecreate{true};
7882
};

Client/mods/deathmatch/logic/CNetAPI.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2243,18 +2243,19 @@ void CNetAPI::ReadVehiclePartsState(CClientVehicle* pVehicle, NetBitStreamInterf
22432243

22442244
SVehicleDamageSyncMethodeB damage;
22452245
BitStream.Read(&damage);
2246+
bool flyingComponents = m_pVehicleManager->IsSpawnFlyingComponentEnabled();
22462247

22472248
if (damage.data.bSyncDoors)
22482249
for (unsigned int i = 0; i < MAX_DOORS; ++i)
2249-
pVehicle->SetDoorStatus(i, damage.data.doors.data.ucStates[i], true);
2250+
pVehicle->SetDoorStatus(i, damage.data.doors.data.ucStates[i], flyingComponents);
22502251

22512252
if (damage.data.bSyncWheels)
22522253
for (unsigned int i = 0; i < MAX_WHEELS; ++i)
22532254
pVehicle->SetWheelStatus(i, damage.data.wheels.data.ucStates[i]);
22542255

22552256
if (damage.data.bSyncPanels)
22562257
for (unsigned int i = 0; i < MAX_PANELS; ++i)
2257-
pVehicle->SetPanelStatus(i, damage.data.panels.data.ucStates[i]);
2258+
pVehicle->SetPanelStatus(i, damage.data.panels.data.ucStates[i], flyingComponents);
22582259

22592260
if (damage.data.bSyncLights)
22602261
for (unsigned int i = 0; i < MAX_LIGHTS; ++i)

Client/mods/deathmatch/logic/CPacketHandler.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1628,10 +1628,12 @@ void CPacketHandler::Packet_VehicleDamageSync(NetBitStreamInterface& bitStream)
16281628
CDeathmatchVehicle* pVehicle = static_cast<CDeathmatchVehicle*>(g_pClientGame->m_pVehicleManager->Get(ID));
16291629
if (pVehicle)
16301630
{
1631+
bool flyingComponents = g_pClientGame->IsWorldSpecialProperty(WorldSpecialProperty::FLYINGCOMPONENTS);
1632+
16311633
for (unsigned int i = 0; i < MAX_DOORS; ++i)
16321634
{
16331635
if (damage.data.bDoorStatesChanged[i])
1634-
pVehicle->SetDoorStatus(i, damage.data.ucDoorStates[i], true);
1636+
pVehicle->SetDoorStatus(i, damage.data.ucDoorStates[i], flyingComponents);
16351637
}
16361638
for (unsigned int i = 0; i < MAX_WHEELS; ++i)
16371639
{
@@ -1641,7 +1643,7 @@ void CPacketHandler::Packet_VehicleDamageSync(NetBitStreamInterface& bitStream)
16411643
for (unsigned int i = 0; i < MAX_PANELS; ++i)
16421644
{
16431645
if (damage.data.bPanelStatesChanged[i])
1644-
pVehicle->SetPanelStatus(i, damage.data.ucPanelStates[i]);
1646+
pVehicle->SetPanelStatus(i, damage.data.ucPanelStates[i], flyingComponents);
16451647
}
16461648
for (unsigned int i = 0; i < MAX_LIGHTS; ++i)
16471649
{
@@ -2398,6 +2400,7 @@ void CPacketHandler::Packet_MapInfo(NetBitStreamInterface& bitStream)
23982400
g_pClientGame->SetWorldSpecialProperty(WorldSpecialProperty::EXTENDEDWATERCANNONS, wsProps.data4.extendedwatercannons);
23992401
g_pClientGame->SetWorldSpecialProperty(WorldSpecialProperty::TUNNELWEATHERBLEND, wsProps.data5.tunnelweatherblend);
24002402
g_pClientGame->SetWorldSpecialProperty(WorldSpecialProperty::IGNOREFIRESTATE, wsProps.data6.ignoreFireState);
2403+
g_pClientGame->SetWorldSpecialProperty(WorldSpecialProperty::FLYINGCOMPONENTS, wsProps.data7.flyingcomponents);
24012404

24022405
float fJetpackMaxHeight = 100;
24032406
if (!bitStream.Read(fJetpackMaxHeight))
@@ -3391,13 +3394,14 @@ void CPacketHandler::Packet_EntityAdd(NetBitStreamInterface& bitStream)
33913394
pVehicle->SetPaintjob(paintjob.data.ucPaintjob);
33923395
pVehicle->SetColor(vehColor);
33933396

3397+
bool flyingComponents = g_pClientGame->IsWorldSpecialProperty(WorldSpecialProperty::FLYINGCOMPONENTS);
33943398
// Setup our damage model
33953399
for (int i = 0; i < MAX_DOORS; i++)
3396-
pVehicle->SetDoorStatus(i, damage.data.ucDoorStates[i], true);
3400+
pVehicle->SetDoorStatus(i, damage.data.ucDoorStates[i], flyingComponents);
33973401
for (int i = 0; i < MAX_WHEELS; i++)
33983402
pVehicle->SetWheelStatus(i, damage.data.ucWheelStates[i]);
33993403
for (int i = 0; i < MAX_PANELS; i++)
3400-
pVehicle->SetPanelStatus(i, damage.data.ucPanelStates[i]);
3404+
pVehicle->SetPanelStatus(i, damage.data.ucPanelStates[i], flyingComponents);
34013405
for (int i = 0; i < MAX_LIGHTS; i++)
34023406
pVehicle->SetLightStatus(i, damage.data.ucLightStates[i]);
34033407
pVehicle->ResetDamageModelSync();

Server/mods/deathmatch/logic/CGame.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ CGame::CGame() : m_FloodProtect(4, 30000, 30000) // Max of 4 connecti
260260
m_WorldSpecialProps[WorldSpecialProperty::ROADSIGNSTEXT] = true;
261261
m_WorldSpecialProps[WorldSpecialProperty::TUNNELWEATHERBLEND] = true;
262262
m_WorldSpecialProps[WorldSpecialProperty::IGNOREFIRESTATE] = false;
263+
m_WorldSpecialProps[WorldSpecialProperty::FLYINGCOMPONENTS] = true;
263264

264265
m_JetpackWeapons[WEAPONTYPE_MICRO_UZI] = true;
265266
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
@@ -193,6 +193,7 @@ bool CMapInfoPacket::Write(NetBitStreamInterface& BitStream) const
193193
wsProps.data4.extendedwatercannons = g_pGame->IsWorldSpecialPropertyEnabled(WorldSpecialProperty::EXTENDEDWATERCANNONS);
194194
wsProps.data5.tunnelweatherblend = g_pGame->IsWorldSpecialPropertyEnabled(WorldSpecialProperty::TUNNELWEATHERBLEND);
195195
wsProps.data6.ignoreFireState = g_pGame->IsWorldSpecialPropertyEnabled(WorldSpecialProperty::IGNOREFIRESTATE);
196+
wsProps.data7.flyingcomponents = g_pGame->IsWorldSpecialPropertyEnabled(WorldSpecialProperty::FLYINGCOMPONENTS);
196197
BitStream.Write(&wsProps);
197198
}
198199

Shared/mods/deathmatch/logic/Enums.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ ADD_ENUM(WorldSpecialProperty::EXTENDEDWATERCANNONS, "extendedwatercannons")
102102
ADD_ENUM(WorldSpecialProperty::ROADSIGNSTEXT, "roadsignstext")
103103
ADD_ENUM(WorldSpecialProperty::TUNNELWEATHERBLEND, "tunnelweatherblend")
104104
ADD_ENUM(WorldSpecialProperty::IGNOREFIRESTATE, "ignorefirestate")
105+
ADD_ENUM(WorldSpecialProperty::FLYINGCOMPONENTS, "flyingcomponents")
105106
IMPLEMENT_ENUM_CLASS_END("world-special-property")
106107

107108
IMPLEMENT_ENUM_BEGIN(ePacketID)

Shared/mods/deathmatch/logic/Enums.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ enum class WorldSpecialProperty
9292
EXTENDEDWATERCANNONS,
9393
TUNNELWEATHERBLEND,
9494
IGNOREFIRESTATE,
95+
FLYINGCOMPONENTS,
9596
};
9697
DECLARE_ENUM_CLASS(WorldSpecialProperty);
9798

Shared/sdk/net/SyncStructures.h

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2075,6 +2075,10 @@ struct SWorldSpecialPropertiesStateSync : public ISyncStructure
20752075
{
20762076
BITCOUNT6 = 1
20772077
};
2078+
enum
2079+
{
2080+
BITCOUNT7 = 1
2081+
};
20782082

20792083
bool Read(NetBitStreamInterface& bitStream)
20802084
{
@@ -2103,7 +2107,12 @@ struct SWorldSpecialPropertiesStateSync : public ISyncStructure
21032107
isOK &= bitStream.ReadBits(reinterpret_cast<char*>(&data6), BITCOUNT6);
21042108
else
21052109
data6.ignoreFireState = false;
2106-
2110+
2111+
if (bitStream.Can(eBitStreamVersion::WorldSpecialProperty_FlyingComponents))
2112+
isOK &= bitStream.ReadBits(reinterpret_cast<char*>(&data7), BITCOUNT7);
2113+
else
2114+
data7.flyingcomponents = true;
2115+
21072116
//// Example for adding item:
21082117
// if (bitStream.Can(eBitStreamVersion::YourProperty))
21092118
// isOK &= bitStream.ReadBits(reinterpret_cast<char*>(&data9), BITCOUNT9);
@@ -2130,6 +2139,9 @@ struct SWorldSpecialPropertiesStateSync : public ISyncStructure
21302139
if (bitStream.Can(eBitStreamVersion::WorldSpecialProperty_IgnoreFireState))
21312140
bitStream.WriteBits(reinterpret_cast<const char*>(&data6), BITCOUNT6);
21322141

2142+
if (bitStream.Can(eBitStreamVersion::WorldSpecialProperty_FlyingComponents))
2143+
bitStream.WriteBits(reinterpret_cast<const char*>(&data7), BITCOUNT7);
2144+
21332145
//// Example for adding item:
21342146
// if (bitStream.Can(eBitStreamVersion::YourProperty))
21352147
// bitStream.WriteBits(reinterpret_cast<const char*>(&data9), BITCOUNT9);
@@ -2177,6 +2189,11 @@ struct SWorldSpecialPropertiesStateSync : public ISyncStructure
21772189
bool ignoreFireState : 1;
21782190
} data6;
21792191

2192+
struct
2193+
{
2194+
bool flyingcomponents : 1;
2195+
} data7;
2196+
21802197
SWorldSpecialPropertiesStateSync()
21812198
{
21822199
// Set default states
@@ -2197,6 +2214,7 @@ struct SWorldSpecialPropertiesStateSync : public ISyncStructure
21972214
data4.extendedwatercannons = true;
21982215
data5.tunnelweatherblend = true;
21992216
data6.ignoreFireState = false;
2217+
data7.flyingcomponents = true;
22002218
}
22012219
};
22022220

0 commit comments

Comments
 (0)