mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-24 05:03:34 -04:00
Cache position at start of GlobalUpdate(), avoids very rare issue of player positions being offset wrongly to other players when their positon changes mid-way through GlobalUpdate().
This commit is contained in:
parent
5ec756c064
commit
a793a164ba
@ -252,10 +252,16 @@ namespace MCGalaxy {
|
||||
|
||||
public static void GlobalUpdate() {
|
||||
Player[] players = PlayerInfo.Online.Items;
|
||||
// We need to cache the player's position before iterating.
|
||||
// Avoids the very rare issue of player's position changing mid-way through iteration,
|
||||
// which can cause this player to show minorly offset to other players.
|
||||
foreach (Player p in players)
|
||||
p.tempPos = p.pos;
|
||||
|
||||
foreach (Player p in players)
|
||||
UpdatePosition(p);
|
||||
foreach (Player p in players) {
|
||||
p.oldpos = p.pos; p.oldrot = p.rot;
|
||||
p.oldpos = p.tempPos; p.oldrot = p.rot;
|
||||
}
|
||||
}
|
||||
|
||||
@ -266,7 +272,7 @@ namespace MCGalaxy {
|
||||
foreach (Player pl in players) {
|
||||
if (p == pl || p.level != pl.level || !CanSeeEntity(p, pl)) continue;
|
||||
byte pitch = p.hasChangeModel ? MakePitch(pl) : MakeClassicPitch(pl);
|
||||
Entities.GetPositionPacket(ref ptr, pl.id, pl.pos, pl.oldpos, pl.rot, pl.oldrot, pitch);
|
||||
Entities.GetPositionPacket(ref ptr, pl.id, pl.tempPos, pl.oldpos, pl.rot, pl.oldrot, pitch);
|
||||
}
|
||||
|
||||
int count = (int)(ptr - src);
|
||||
|
@ -263,12 +263,12 @@ namespace MCGalaxy {
|
||||
public bool Loading = true; //True if player is loading a map.
|
||||
internal bool usingGoto = false;
|
||||
public Vec3U16 lastClick = Vec3U16.Zero;
|
||||
public ushort[] beforeTeleportPos = new ushort[] { 0, 0, 0 };
|
||||
public ushort[] beforeTeleportPos = new ushort[3];
|
||||
public string beforeTeleportMap = "";
|
||||
public ushort[] pos = new ushort[] { 0, 0, 0 };
|
||||
internal ushort[] oldpos = new ushort[] { 0, 0, 0 };
|
||||
public byte[] rot = new byte[] { 0, 0 };
|
||||
internal byte[] oldrot = new byte[] { 0, 0 };
|
||||
public ushort[] pos = new ushort[3];
|
||||
public byte[] rot = new byte[2];
|
||||
internal ushort[] oldpos = new ushort[3], tempPos = new ushort[3];
|
||||
internal byte[] oldrot = new byte[2];
|
||||
|
||||
//ushort[] clippos = new ushort[3] { 0, 0, 0 };
|
||||
//byte[] cliprot = new byte[2] { 0, 0 };
|
||||
|
Loading…
x
Reference in New Issue
Block a user