Fixed characters occasionally teleporting around at the clients' end after respawning. The position syncing logic assumed that all coordinates above the level are in sub-relative space, even though the world position of the respawn shuttle can also be above the level.
This commit is contained in:
@@ -1234,18 +1234,20 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
if (GameMain.NetworkMember == null) return;
|
if (GameMain.NetworkMember == null) return;
|
||||||
|
|
||||||
|
float lowestSubPos = ConvertUnits.ToSimUnits(Submarine.Loaded.Min(s => s.HiddenSubPosition.Y - s.Borders.Height));
|
||||||
|
|
||||||
for (int i = 0; i < character.MemState.Count; i++ )
|
for (int i = 0; i < character.MemState.Count; i++ )
|
||||||
{
|
{
|
||||||
if (character.Submarine == null)
|
if (character.Submarine == null)
|
||||||
{
|
{
|
||||||
//transform in-sub coordinates to outside coordinates
|
//transform in-sub coordinates to outside coordinates
|
||||||
if (character.MemState[i].Position.Y > ConvertUnits.ToSimUnits(Level.Loaded.Size.Y))
|
if (character.MemState[i].Position.Y > lowestSubPos)
|
||||||
character.MemState[i].TransformInToOutside();
|
character.MemState[i].TransformInToOutside();
|
||||||
}
|
}
|
||||||
else if (currentHull != null)
|
else if (currentHull != null)
|
||||||
{
|
{
|
||||||
//transform outside coordinates to in-sub coordinates
|
//transform outside coordinates to in-sub coordinates
|
||||||
if (character.MemState[i].Position.Y < ConvertUnits.ToSimUnits(Level.Loaded.Size.Y))
|
if (character.MemState[i].Position.Y <lowestSubPos)
|
||||||
character.MemState[i].TransformOutToInside(currentHull.Submarine);
|
character.MemState[i].TransformOutToInside(currentHull.Submarine);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1313,14 +1315,18 @@ namespace Barotrauma
|
|||||||
if (character.Submarine == null)
|
if (character.Submarine == null)
|
||||||
{
|
{
|
||||||
//transform in-sub coordinates to outside coordinates
|
//transform in-sub coordinates to outside coordinates
|
||||||
if (character.MemLocalState[i].Position.Y > ConvertUnits.ToSimUnits(Level.Loaded.Size.Y))
|
if (character.MemLocalState[i].Position.Y > lowestSubPos)
|
||||||
|
{
|
||||||
character.MemLocalState[i].TransformInToOutside();
|
character.MemLocalState[i].TransformInToOutside();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (currentHull != null)
|
else if (currentHull != null)
|
||||||
{
|
{
|
||||||
//transform outside coordinates to in-sub coordinates
|
//transform outside coordinates to in-sub coordinates
|
||||||
if (character.MemLocalState[i].Position.Y < ConvertUnits.ToSimUnits(Level.Loaded.Size.Y))
|
if (character.MemLocalState[i].Position.Y < lowestSubPos)
|
||||||
|
{
|
||||||
character.MemLocalState[i].TransformOutToInside(currentHull.Submarine);
|
character.MemLocalState[i].TransformOutToInside(currentHull.Submarine);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user