(5218c43a0) Server sends the IDs of both selected characters and selected items to the clients. Previously this wasn't needed, because it wasn't possible to have both a character and an item selected at the same time. Fixes characters floating mid-air client-side when dragging others up stairs, and probably some other undiscovered bugs as well.

This commit is contained in:
Joonas Rikkonen
2019-04-01 22:50:11 +03:00
parent ae6b797d73
commit d511ecd4e3
7 changed files with 97 additions and 70 deletions
@@ -30,12 +30,13 @@ namespace Barotrauma
else
{
var posInfo = new CharacterStateInfo(
SimPosition,
AnimController.Collider.Rotation,
LastNetworkUpdateID,
AnimController.TargetDir,
SelectedCharacter == null ? (Entity)SelectedConstruction : (Entity)SelectedCharacter,
AnimController.Anim);
SimPosition,
AnimController.Collider.Rotation,
LastNetworkUpdateID,
AnimController.TargetDir,
SelectedCharacter,
SelectedConstruction,
AnimController.Anim);
memLocalState.Add(posInfo);
@@ -187,14 +188,17 @@ namespace Barotrauma
}
bool entitySelected = msg.ReadBoolean();
Entity selectedEntity = null;
Character selectedCharacter = null;
Item selectedItem = null;
AnimController.Animation animation = AnimController.Animation.None;
if (entitySelected)
{
ushort entityID = msg.ReadUInt16();
selectedEntity = FindEntityByID(entityID);
if (selectedEntity is Character)
ushort characterID = msg.ReadUInt16();
ushort itemID = msg.ReadUInt16();
selectedCharacter = FindEntityByID(characterID) as Character;
selectedItem = FindEntityByID(itemID) as Item;
if (selectedCharacter != null)
{
bool doingCpr = msg.ReadBoolean();
if (doingCpr && SelectedCharacter != null)
@@ -235,7 +239,11 @@ namespace Barotrauma
int index = 0;
if (GameMain.Client.Character == this && AllowInput)
{
var posInfo = new CharacterStateInfo(pos, rotation, networkUpdateID, facingRight ? Direction.Right : Direction.Left, selectedEntity, animation);
var posInfo = new CharacterStateInfo(
pos, rotation,
networkUpdateID,
facingRight ? Direction.Right : Direction.Left,
selectedCharacter, selectedItem, animation);
while (index < memState.Count && NetIdUtils.IdMoreRecent(posInfo.ID, memState[index].ID))
index++;
@@ -243,7 +251,11 @@ namespace Barotrauma
}
else
{
var posInfo = new CharacterStateInfo(pos, rotation, linearVelocity, angularVelocity, sendingTime, facingRight ? Direction.Right : Direction.Left, selectedEntity, animation);
var posInfo = new CharacterStateInfo(
pos, rotation,
linearVelocity, angularVelocity,
sendingTime, facingRight ? Direction.Right : Direction.Left,
selectedCharacter, selectedItem, animation);
while (index < memState.Count && posInfo.Timestamp > memState[index].Timestamp)
index++;