Minor networking fixes

- Don't spam the shit out of status updates (TODO: send update
immediately on drastic changes)
- Fixed some potential message misreading
- Readded homoglyph name comparison
This commit is contained in:
juanjp600
2017-12-21 16:00:04 -03:00
parent 40a46f96e2
commit c593fdb7c6
8 changed files with 56 additions and 37 deletions

View File

@@ -145,6 +145,10 @@ namespace Barotrauma
float rotation = msg.ReadFloat();
ReadStatus(msg);
msg.ReadPadBits();
int index = 0;
if (GameMain.NetworkMember.Character == this)
{
@@ -193,9 +197,6 @@ namespace Barotrauma
IsRemotePlayer = ownerID > 0;
}
break;
case 2:
ReadStatus(msg);
break;
}
break;

View File

@@ -36,7 +36,7 @@
<DebugSymbols>true</DebugSymbols>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\x86\ReleaseLinux</OutputPath>
<OutputPath>..\bin\ReleaseLinux</OutputPath>
<DefineConstants>TRACE;SERVER</DefineConstants>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
@@ -45,7 +45,7 @@
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\x86\DebugLinux</OutputPath>
<OutputPath>..\bin\DebugLinux</OutputPath>
<DefineConstants>TRACE;SERVER;DEBUG</DefineConstants>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
@@ -54,7 +54,7 @@
<DebugSymbols>true</DebugSymbols>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\x86\ReleaseWindows</OutputPath>
<OutputPath>..\bin\ReleaseWindows</OutputPath>
<DefineConstants>TRACE;SERVER</DefineConstants>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
@@ -63,7 +63,7 @@
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\x86\DebugWindows</OutputPath>
<OutputPath>..\bin\DebugWindows</OutputPath>
<DefineConstants>TRACE;SERVER;DEBUG</DefineConstants>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>

View File

@@ -12,7 +12,7 @@
<WeldedSprite texture ="door.png" sourcerect="99,0,32,188" depth="0.0" origin="0.5,0.5"/>
<BrokenSprite texture ="door.png" sourcerect="133,0,58,208" depth="0.051" origin="0.5,0.0" scale="true"/>
<sound file="door.ogg" type="OnUse" range="500.0"/>
<sound file="Content/Items/Tools/Crowbar.ogg" type="OnPicked" range="2000.0"/>
<sound file="Content/Items/Tools/crowbar.ogg" type="OnPicked" range="2000.0"/>
</Door>
<AiTarget sightrange="500.0"/>
@@ -159,4 +159,4 @@
<output name="proximity_sensor"/>
</ConnectionPanel>
</Item>
</Items>
</Items>

View File

@@ -344,18 +344,18 @@ namespace Barotrauma
if (GameMain.Client != null) return;
float newHealth = MathHelper.Clamp(value, minHealth, maxHealth);
if (newHealth == health) return;
//if (newHealth == health) return;
health = newHealth;
if (GameMain.Server != null)
/*if (GameMain.Server != null)
{
if (Math.Abs(health - lastSentHealth) > (maxHealth - minHealth) / 255.0f || Math.Sign(health) != Math.Sign(lastSentHealth))
{
GameMain.Server.CreateEntityEvent(this, new object[] { NetEntityEvent.Type.Status });
lastSentHealth = health;
}
}
}*/
}
}
@@ -373,12 +373,12 @@ namespace Barotrauma
if (GameMain.Client != null) return;
float newBleeding = MathHelper.Clamp(value, 0.0f, 5.0f);
if (newBleeding == bleeding) return;
//if (newBleeding == bleeding) return;
bleeding = newBleeding;
if (GameMain.Server != null)
GameMain.Server.CreateEntityEvent(this, new object[] { NetEntityEvent.Type.Status });
/*if (GameMain.Server != null)
GameMain.Server.CreateEntityEvent(this, new object[] { NetEntityEvent.Type.Status });*/
}
}
@@ -1534,11 +1534,11 @@ namespace Barotrauma
if (stunTimer > 0.0f)
{
stunTimer -= deltaTime;
if (stunTimer < 0.0f && GameMain.Server != null)
/*if (stunTimer < 0.0f && GameMain.Server != null)
{
//stun ended -> notify clients
GameMain.Server.CreateEntityEvent(this, new object[] { NetEntityEvent.Type.Status });
}
} */
}
//Skip health effects as critical health handles it differently
@@ -1568,8 +1568,8 @@ namespace Barotrauma
if (IsRagdolled)
{
if (AnimController is HumanoidAnimController) ((HumanoidAnimController)AnimController).Crouching = false;
if(GameMain.Server != null)
GameMain.Server.CreateEntityEvent(this, new object[] { NetEntityEvent.Type.Status });
/*if(GameMain.Server != null)
GameMain.Server.CreateEntityEvent(this, new object[] { NetEntityEvent.Type.Status });*/
AnimController.ResetPullJoints();
selectedConstruction = null;
return;
@@ -1815,11 +1815,11 @@ namespace Barotrauma
if ((newStun <= stunTimer && !allowStunDecrease) || !MathUtils.IsValid(newStun)) return;
if (GameMain.Server != null &&
/*if (GameMain.Server != null &&
(Math.Sign(newStun) != Math.Sign(stunTimer) || Math.Abs(newStun - stunTimer) > 0.1f))
{
GameMain.Server.CreateEntityEvent(this, new object[] { NetEntityEvent.Type.Status });
}
}*/
if (Math.Sign(newStun) != Math.Sign(stunTimer)) AnimController.ResetPullJoints();
@@ -1878,11 +1878,11 @@ namespace Barotrauma
return;
}
if (GameMain.NetworkMember != null)
/*if (GameMain.NetworkMember != null)
{
if (GameMain.Server != null)
GameMain.Server.CreateEntityEvent(this, new object[] { NetEntityEvent.Type.Status });
}
}*/
AnimController.Frozen = false;

View File

@@ -332,6 +332,7 @@ namespace Barotrauma
inventory.ServerRead(type, msg, c);
break;
case 1:
bool doingCPR = msg.ReadBoolean();
if (c.Character != this)
{
#if DEBUG
@@ -340,7 +341,6 @@ namespace Barotrauma
return;
}
bool doingCPR = msg.ReadBoolean();
AnimController.Anim = doingCPR ? AnimController.Animation.CPR : AnimController.Animation.None;
break;
case 2:
@@ -358,7 +358,15 @@ namespace Barotrauma
}
break;
case 3:
AnimController.GrabLimb = (LimbType)msg.ReadUInt16();
LimbType grabLimb = (LimbType)msg.ReadUInt16();
if (c.Character != this)
{
#if DEBUG
DebugConsole.Log("Received a character update message from a client who's not controlling the character");
#endif
return;
}
AnimController.GrabLimb = grabLimb;
break;
}
break;
@@ -384,10 +392,6 @@ namespace Barotrauma
Client owner = ((Client)extraData[1]);
msg.Write(owner == null ? (byte)0 : owner.ID);
break;
case NetEntityEvent.Type.Status:
msg.WriteRangedInteger(0, 2, 2);
WriteStatus(msg);
break;
}
msg.WritePadBits();
}
@@ -474,6 +478,8 @@ namespace Barotrauma
tempBuffer.Write(SimPosition.Y);
tempBuffer.Write(AnimController.Collider.Rotation);
WriteStatus(tempBuffer);
tempBuffer.WritePadBits();
msg.Write((byte)tempBuffer.LengthBytes);

View File

@@ -126,7 +126,7 @@ namespace Barotrauma.Networking
public static bool IsValidName(string name)
{
if (name.Contains("\n") || name.Contains("\r\n")) return false;
if (name.Contains("\n") || name.Contains("\r")) return false;
return (name.All(c =>
c != ';' &&

View File

@@ -172,7 +172,7 @@ namespace Barotrauma.Networking
DebugConsole.NewMessage(clName + " (" + inc.SenderConnection.RemoteEndPoint.Address.ToString() + ") couldn't join the server (invalid name)", Color.Red);
return;
}
if (clName.ToLower() == Name.ToLower())
if (Homoglyphs.Compare(clName.ToLower(),Name.ToLower()))
{
DisconnectUnauthClient(inc, unauthClient, "That name is taken.");
Log(clName + " (" + inc.SenderConnection.RemoteEndPoint.Address.ToString() + ") couldn't join the server (name taken by the server)", ServerLog.MessageType.Error);

View File

@@ -22,26 +22,38 @@
<ApplicationIcon>Icon.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'ReleaseLinux|x86' ">
<Optimize>false</Optimize>
<OutputPath>bin\x86\ReleaseLinux</OutputPath>
<DebugSymbols>true</DebugSymbols>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\bin\ReleaseLinux</OutputPath>
<DefineConstants>TRACE;LINUX;CLIENT</DefineConstants>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'DebugLinux|x86' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\x86\DebugLinux</OutputPath>
<OutputPath>..\bin\DebugLinux</OutputPath>
<DefineConstants>TRACE;LINUX;CLIENT;DEBUG</DefineConstants>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'ReleaseWindows|x86' ">
<Optimize>false</Optimize>
<OutputPath>bin\x86\ReleaseWindows</OutputPath>
<DebugSymbols>true</DebugSymbols>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\bin\ReleaseWindows</OutputPath>
<DefineConstants>TRACE;WINDOWS;CLIENT</DefineConstants>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'DebugWindows|x86' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\x86\DebugWindows</OutputPath>
<OutputPath>..\bin\DebugWindows</OutputPath>
<DefineConstants>TRACE;WINDOWS;CLIENT;DEBUG</DefineConstants>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>