mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-23 20:53:40 -04:00
Don't waste resources creating absolute positon updates when bot hasn't moved and hasn't rotated. Partially addresses #459.
This commit is contained in:
parent
16e87c8c3a
commit
5e0fcf6119
@ -19,6 +19,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using MCGalaxy.Bots;
|
||||
using MCGalaxy.Maths;
|
||||
using MCGalaxy.Network;
|
||||
|
||||
namespace MCGalaxy {
|
||||
|
||||
@ -127,11 +128,13 @@ namespace MCGalaxy {
|
||||
DoMove();
|
||||
}
|
||||
|
||||
// TODO: check if external code modified pos/rot
|
||||
byte[] packet = Entities.GetPositionPacket(this, false);
|
||||
lastPos = Pos; lastRot = Rot;
|
||||
if (packet == null) return;
|
||||
byte[] extPacket = Entities.GetPositionPacket(this, true);
|
||||
Position pos = Pos; Orientation rot = Rot;
|
||||
if (pos == lastPos && rot.HeadX == lastRot.HeadX && rot.RotY == lastRot.RotY) return;
|
||||
lastPos = pos; lastRot = rot;
|
||||
|
||||
// TODO: relative position updates, combine packets
|
||||
byte[] packet = Packet.Teleport(id, pos, rot, false);
|
||||
byte[] extPacket = Packet.Teleport(id, pos, rot, true);
|
||||
|
||||
Player[] players = PlayerInfo.Online.Items;
|
||||
foreach (Player p in players) {
|
||||
|
@ -235,11 +235,6 @@ namespace MCGalaxy {
|
||||
|
||||
#region Position updates
|
||||
|
||||
public static byte[] GetPositionPacket(PlayerBot bot, bool extPos) {
|
||||
// TODO: not sure why bots only work with absolute packets
|
||||
return Packet.Teleport(bot.id, bot.Pos, bot.Rot, extPos);
|
||||
}
|
||||
|
||||
public unsafe static void GetPositionPacket(ref byte* ptr, byte id, bool srcExtPos, bool extPos,
|
||||
Position pos, Position oldPos, Orientation rot, Orientation oldRot) {
|
||||
Position delta = GetDelta(pos, oldPos, srcExtPos);
|
||||
|
Loading…
x
Reference in New Issue
Block a user