Checking if a client can access an item in the itemcomponent serialization methods
This commit is contained in:
@@ -236,8 +236,13 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
public void ServerRead(Lidgren.Network.NetIncomingMessage msg, Barotrauma.Networking.Client c)
|
||||
{
|
||||
FlowPercentage = msg.ReadRangedInteger(-10, 10) * 10.0f;
|
||||
IsActive = msg.ReadBoolean();
|
||||
float flowPercentage = msg.ReadRangedInteger(-10, 10) * 10.0f;
|
||||
bool isActive = msg.ReadBoolean();
|
||||
|
||||
if (!item.CanClientAccess(c)) return;
|
||||
|
||||
FlowPercentage = flowPercentage;
|
||||
IsActive = isActive;
|
||||
}
|
||||
|
||||
public void ServerWrite(Lidgren.Network.NetBuffer msg, Barotrauma.Networking.Client c, object[] extraData = null)
|
||||
|
||||
@@ -433,7 +433,11 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
public void ServerRead(Lidgren.Network.NetIncomingMessage msg, Barotrauma.Networking.Client c)
|
||||
{
|
||||
IsActive = msg.ReadBoolean();
|
||||
bool isActive = msg.ReadBoolean();
|
||||
|
||||
if (!item.CanClientAccess(c)) return;
|
||||
|
||||
IsActive = isActive;
|
||||
isActiveTickBox.Selected = IsActive;
|
||||
|
||||
item.CreateServerEvent(this);
|
||||
|
||||
@@ -563,11 +563,18 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
public void ServerRead(NetIncomingMessage msg, Client c)
|
||||
{
|
||||
AutoTemp = msg.ReadBoolean();
|
||||
ShutDownTemp = msg.ReadRangedSingle(0.0f, 10000.0f, 8);
|
||||
bool autoTemp = msg.ReadBoolean();
|
||||
float shutDownTemp = msg.ReadRangedSingle(0.0f, 10000.0f, 8);
|
||||
float coolingRate = msg.ReadRangedSingle(0.0f, 100.0f, 8);
|
||||
float fissionRate = msg.ReadRangedSingle(0.0f, 100.0f, 8);
|
||||
|
||||
CoolingRate = msg.ReadRangedSingle(0.0f, 100.0f, 8);
|
||||
FissionRate = msg.ReadRangedSingle(0.0f, 100.0f, 8);
|
||||
if (!item.CanClientAccess(c)) return;
|
||||
|
||||
AutoTemp = autoTemp;
|
||||
ShutDownTemp = shutDownTemp;
|
||||
|
||||
CoolingRate = coolingRate;
|
||||
FissionRate = fissionRate;
|
||||
|
||||
//need to create a server event to notify all clients of the changed state
|
||||
unsentChanges = true;
|
||||
|
||||
@@ -488,7 +488,11 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
public void ServerRead(Lidgren.Network.NetIncomingMessage msg, Barotrauma.Networking.Client c)
|
||||
{
|
||||
AutoPilot = msg.ReadBoolean();
|
||||
bool autoPilot = msg.ReadBoolean();
|
||||
|
||||
if (!item.CanClientAccess(c)) return;
|
||||
|
||||
AutoPilot = autoPilot;
|
||||
|
||||
if (!AutoPilot)
|
||||
{
|
||||
|
||||
@@ -1356,6 +1356,11 @@ namespace Barotrauma
|
||||
return Vector2.Distance(WorldPosition, worldPosition) < PickDistance;
|
||||
}
|
||||
|
||||
public bool CanClientAccess(Client c)
|
||||
{
|
||||
return c != null && c.Character != null && c.Character.CanAccessItem(this);
|
||||
}
|
||||
|
||||
public bool Pick(Character picker, bool ignoreRequiredItems=false, bool forceSelectKey=false, bool forceActionKey=false)
|
||||
{
|
||||
bool hasRequiredSkills = true;
|
||||
|
||||
Reference in New Issue
Block a user