mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-16 05:13:58 -07:00
Sort entitycollections when adding entities
On joining clients entitycollections are always sorted. To stay in sync non-joining clients also have to sort entitycollections.
This commit is contained in:
parent
130ea06ce8
commit
f35595610a
1 changed files with 5 additions and 0 deletions
|
|
@ -311,6 +311,11 @@ EntityCollection.prototype.addEnt = function(ent)
|
|||
if (this._entities.has(ent.id()))
|
||||
return false;
|
||||
this._entities.set(ent.id(), ent);
|
||||
const temp = this.toEntityArray();
|
||||
temp.sort((a, b) => a.id() - b.id());
|
||||
this._entities.clear();
|
||||
for (const e of temp)
|
||||
this._entities.set(e.id(), e);
|
||||
return true;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue