diff --git a/src/client/object/player-entity.ts b/src/client/object/player-entity.ts index 4fe477f..ebeb191 100644 --- a/src/client/object/player-entity.ts +++ b/src/client/object/player-entity.ts @@ -8,7 +8,7 @@ import { ChatBubble } from './chat-bubble'; const chatBuilder = new CanvasUtils(); export class PlayerEntity extends PonyEntity { - private uncommittedPacket: Packet = {}; + private uncommittedPackets: Packet[] = []; private _chats: ChatBubble[] = []; constructor(public user: IcyNetUser) { @@ -85,7 +85,7 @@ export class PlayerEntity extends PonyEntity { } public addUncommittedChanges(packet: Packet) { - this.uncommittedPacket = { ...this.uncommittedPacket, ...packet }; + this.uncommittedPackets.push(packet); } public update(dt: number) { @@ -116,7 +116,8 @@ export class PlayerEntity extends PonyEntity { } private commitServerUpdate() { - this.setFromPacket(this.uncommittedPacket); - this.uncommittedPacket = {}; + if (this.uncommittedPackets.length) { + this.setFromPacket(this.uncommittedPackets.splice(0, 1)[0]); + } } }