Skip to content

Add setElementCollidableWith server-side #4101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions Client/mods/deathmatch/logic/rpc/CElementRPCs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ void CElementRPCs::LoadFunctions()
AddHandler(SET_PROPAGATE_CALLS_ENABLED, SetCallPropagationEnabled, "setCallPropagationEnabled");
AddHandler(SET_COLPOLYGON_HEIGHT, SetColPolygonHeight, "setColShapePolygonHeight");
AddHandler(SET_ELEMENT_ON_FIRE, SetElementOnFire, "setElementOnFire");
AddHandler(SET_ELEMENT_COLLIDABLE_WITH, SetElementCollidableWith, "setElementCollidableWith");
}

#define RUN_CHILDREN_SERVER(func) \
Expand Down Expand Up @@ -852,3 +853,19 @@ void CElementRPCs::SetElementOnFire(CClientEntity* pSource, NetBitStreamInterfac
{
pSource->SetOnFire(bitStream.ReadBit());
}

void CElementRPCs::SetElementCollidableWith(CClientEntity* pSource, NetBitStreamInterface& bitStream)
{
ElementID ElementID;

if (!bitStream.Can(eBitStreamVersion::SetElementCollidableWith_Serverside))
return;

bitStream.Read(ElementID);

CClientEntity* collidableWith = CElementIDs::GetElement(ElementID);

if (collidableWith == nullptr) // validity check
return;
Comment on lines +868 to +869
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (!collidableWith)
    return;

pSource->SetCollidableWith(collidableWith, bitStream.ReadBit());
}
1 change: 1 addition & 0 deletions Client/mods/deathmatch/logic/rpc/CElementRPCs.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,5 @@ class CElementRPCs : public CRPCFunctions
DECLARE_ELEMENT_RPC(SetCallPropagationEnabled);
DECLARE_ELEMENT_RPC(SetColPolygonHeight);
DECLARE_ELEMENT_RPC(SetElementOnFire);
DECLARE_ELEMENT_RPC(SetElementCollidableWith);
};
1 change: 1 addition & 0 deletions Server/mods/deathmatch/logic/CPerfStat.RPCPacketUsage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ ADD_ENUM1(TOGGLE_OBJECT_RESPAWN)
ADD_ENUM1(RESET_WORLD_PROPERTIES)
ADD_ENUM1(SPAWN_VEHICLE_FLYING_COMPONENT)
ADD_ENUM1(SET_ELEMENT_ON_FIRE)
ADD_ENUM1(SET_ELEMENT_COLLIDABLE_WITH)
IMPLEMENT_ENUM_END("eElementRPCFunctions")

DECLARE_ENUM(CRPCFunctions::eRPCFunctions);
Expand Down
36 changes: 35 additions & 1 deletion Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
#include "packets/CChatEchoPacket.h"
#include "packets/CConsoleEchoPacket.h"
#include "packets/CChatClearPacket.h"
#include "packets/CElementRPCPacket.h"
#include "version.h"
#include <net/rpc_enums.h>

Expand Down Expand Up @@ -12610,3 +12609,38 @@ bool CStaticFunctionDefinitions::SpawnVehicleFlyingComponent(CVehicle* const veh

return true;
}

bool CStaticFunctionDefinitions::SetElementCollidableWith(CElement* element, CElement* withElement, bool canCollide)
{
switch (element->GetType())
{
case EElementType::PLAYER:
case EElementType::PED:
case EElementType::OBJECT:
case EElementType::WEAPON:
case EElementType::VEHICLE:
{
switch (withElement->GetType())
{
case EElementType::PLAYER:
case EElementType::PED:
case EElementType::OBJECT:
case EElementType::WEAPON:
case EElementType::VEHICLE:
{
CBitStream BitStream;
BitStream.pBitStream->Write(withElement->GetID());
BitStream.pBitStream->WriteBit(canCollide);
m_pPlayerManager->BroadcastOnlyJoined(CElementRPCPacket(element, SET_ELEMENT_COLLIDABLE_WITH, *BitStream.pBitStream));
return true;
}
default:
break;
}
break;
}
default:
break;
}
return false;
}
1 change: 1 addition & 0 deletions Server/mods/deathmatch/logic/CStaticFunctionDefinitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -771,4 +771,5 @@ class CStaticFunctionDefinitions
static const char* GetOperatingSystemName();
static const char* GetVersionBuildTag();
static CMtaVersion GetVersionSortable();
static bool SetElementCollidableWith(CElement* element, CElement* withElement, bool canCollide);
};
6 changes: 6 additions & 0 deletions Server/mods/deathmatch/logic/luadefs/CLuaElementDefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ void CLuaElementDefs::LoadFunctions()
{"setElementFrozen", setElementFrozen},
{"setLowLODElement", setLowLODElement},
{"setElementOnFire", ArgumentParser<SetElementOnFire>},
{"setElementCollidableWith", ArgumentParser<SetElementCollidableWith>},
};

// Add functions
Expand Down Expand Up @@ -2460,3 +2461,8 @@ bool CLuaElementDefs::SetElementOnFire(CElement* element, bool onFire) noexcept
{
return CStaticFunctionDefinitions::SetElementOnFire(element, onFire);
}

bool CLuaElementDefs::SetElementCollidableWith(CElement* element, CElement* withElement, bool canCollide)
{
return CStaticFunctionDefinitions::SetElementCollidableWith(element, withElement, canCollide);
}
1 change: 1 addition & 0 deletions Server/mods/deathmatch/logic/luadefs/CLuaElementDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,5 @@ class CLuaElementDefs : public CLuaDefs
LUA_DECLARE(setLowLODElement);
LUA_DECLARE(setElementCallPropagationEnabled);
static bool SetElementOnFire(CElement* element, bool onFire) noexcept;
static bool SetElementCollidableWith(CElement* element, CElement* withElement, bool canCollide);
};
228 changes: 228 additions & 0 deletions Shared/sdk/net/bitstream.h
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,234 @@ enum class eBitStreamVersion : unsigned short
{
Unk = 0x030,


//
// 1.5.0 UNSTABLE - 2015-01-17
//

// Add "quickstand" to setGlitchEnabled
// 2015-07-13 0x063 209837dcdc30d267519abc12e1361a1d18cd1553
QuickStandGlitch,

//
// 1.5.0 RC RELEASED - 2015-07-15
//

//
// 1.5.1 RELEASED - 2015-11-05
//

// Update fix #9038 (bugged shotgun with bullet sync) to only work if all connected clients support it
// 2015-10-17 0x064 edbc6d37a734914b7349c693edf9a087a5a78a3d
ShotgunDamageFix,

//
// 1.5.2 RELEASED - 2016-01-24
//

// Add blend parameter to setPedAnimation (#62)
// 2016-09-05 0x065 f51983c3e3385b4de8d754e11efe329acaee9301
SetPedAnimation_Blend,

// Update net module version
// 2016-09-24 0x066 3de7e5bd2d425747617a24350f2974e02cddc6dc
NetUpdate_0x09E,

//
// 1.5.3 RELEASED - 2016-10-20
//

// Fix player nametag unicode characters missing on player join
// 2016-12-09 0x067 2e582453b476c1183bd9fae5363a7cffdb531834
UnicodeNametags,

// Add -1 parameter to setElementDimension (only to objects) (#111)
// 2017-02-22 0x068 2e319aa823929360da9e1f48c7eb233f1d6f29e5
DimensionOmnipresence,

// Add support for more special detections
// 2017-02-26 0x069 9b6187b3c2eaa655624254f8d83acb35b31243e7
MoreSpecialDetections_Nice69,

// Add option to enable fakelag command for testing sync issues
// 2017-03-08 0x06A a99fa0afa3b55e84f15aed335ab542520f39126d
FakeLagCommand,

//
// 1.5.4 RELEASED - 2017-04-17
//

// Add player element for onClientChatMessage (#138)
// 2017-07-04 0x06B 8c7095599c6d54784692bf93a1e6c7f56392c323
OnClientChatMessage_PlayerSource,

//
// 1.5.5 RELEASED - 2017-08-07
//

// Add bShallow argument for server-side water as well (#240)
// 2018-08-05 0x06C 1321b538559efe6d70deb5b784c2d392d52658f5
Water_bShallow_ServerSide,

//
// 1.5.6 RELEASED - 2018-09-07
// 1.5.7 RELEASED - 2019-08-31
//

// Add option to disable spawning components by setVehicleDoorState
// 2019-10-11 0x06D e79d97195439f70ac66ece1859152b4c4896af31
SetVehicleDoorState_SpawnFlyingComponent,

// Increment BitStream version for Discord update (#1330)
// 2020-03-27 0x06E a0ce68f284487ba636e839b06c103bc2442d95e0
Discord_InitialImplementation,

// Add analog control sync for accelerate and brake_reverse (#1164)
// 2020-04-02 0x06F 41e36cc67520dded2a5203727a726c4261c65e31
AnalogControlSync_AccelBrakeReverse,

//
// 1.5.8 RELEASED - 2020-10-11
//

// setWaterLevel: add bIncludeWorldSeaLevel and bIncludeOutsideWorldLevel
// 2020-11-03 0x70
SetWaterLevel_ChangeOutsideWorldLevel,

// Implement entering/exiting/jacking for peds #1748
// 2020-11-10 0x71
PedEnterExit,

// Add height for colpolygon (#1908)
// 2021-01-16 0x72
SetColPolygonHeight,

// Support for vehicle blow without explosion and blow state synchronisation
// 2021-02-26 0x73
VehicleBlowStateSupport,

// Implement messageType parameter to onClientChatMessage (#1020)
// 2021-05-15 0x74
OnClientChatMessage_MessageType,

// Add serverside event "onPlayerResourceStart" (#2150)
// 2021-08-30 0x75
OnPlayerResourceStart,

//
// 1.5.9 RELEASED - 2021-10-01
//

// Remove "old" Discord implementation (#2499)
// 2022-01-16 0x76
Discord_Cleanup,

//
// 1.6.0 RELEASED - 2023-04-07
//

CEntityAddPacket_ObjectBreakable,

// Add serverside setWorldSpecialPropertyEnabled
// 2023-08-17
WorldSpecialProperties,

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

// Send server name to player in CPlayerJoinCompletePacket
// 2023-10-12
CPlayerJoinCompletePacket_ServerName,

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

// Add "extendedwatercannons" to setWorldSpecialPropertyEnabled
// 2024-05-23
WorldSpecialProperty_ExtendedWaterCannons,

// Add breakObject to serverside as well
// 2024-05-31
BreakObject_Serverside,

// Ped syncronization revision
// 2024-06-16
PedSync_Revision,

// Add "tunnelweatherblend" to setWorldSpecialPropertyEnabled
// 2024-06-30
WorldSpecialProperty_TunnelWeatherBlend,

// Checkpoint & arrow alpha fix
// 2024-07-03
Marker_IgnoreAlphaLimits,

// Add "setMarkerTargetArrowProperties"
// 2024-07-05
SetMarkerTargetArrowProperties,

// Add respawnObject and toggleObjectRespawn to serverside
// 2024-09-04
RespawnObject_Serverside,

// Add check_duplicate_serials
// 2024-09-04
CheckDuplicateSerials,

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

// Fix iPedSyncerDistance and iUnoccupiedVehicleSyncerDistance sync
// 2024-11-22
FixSyncerDistance,

// Add onPlayerChangesWorldSpecialProperty
// 2024-11-26
WorldSpecialPropertyEvent,

// Add setElementOnFire function
// 2024-12-30
SetElementOnFire,

// Add "spawnFlyingComponent" to setVehiclePanelState
// 2024-12-31
SetVehiclePanelState_SpawnFlyingComponent,

// Ped animations synchronization
// 2025-01-01
AnimationsSync,

// Add server side isPedReloadingWeapon
// 2025-01-09
IsPedReloadingWeapon,

// Add "flyingcomponents" to setWorldSpecialPropertyEnabled
// 2025-01-10
WorldSpecialProperty_FlyingComponents,

// Ped's camera synchronization
// 2025-01-29
PedSync_CameraRotation,

// Add "vehicleburnexplosions" to setWorldSpecialPropertyEnabled
// 2025-02-20
WorldSpecialProperty_VehicleBurnExplosions,

//Add setElementCollidableWith serverside
// 2025-03-14
SetElementCollidableWith_Serverside,

// Add serverside building support
// 2025-05-26
ServersideBuildingElement,

// Add "vehenginemanualmode" to setWorldSpecialPropertyEnabled
// 2025-06-02
WorldSpecialProperty_VehicleEngineAutoStart,

// DESCRIPTION
// YYYY-MM-DD
// Name,
Expand Down
2 changes: 2 additions & 0 deletions Shared/sdk/net/rpc_enums.h
Original file line number Diff line number Diff line change
Expand Up @@ -293,5 +293,7 @@ enum eElementRPCFunctions

SET_ELEMENT_ON_FIRE,

SET_ELEMENT_COLLIDABLE_WITH,

NUM_RPC_FUNCS // Add above this line
};