mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-09-21 20:06:40 +00: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:
@@ -311,6 +311,11 @@ EntityCollection.prototype.addEnt = function(ent)
|
|||||||
if (this._entities.has(ent.id()))
|
if (this._entities.has(ent.id()))
|
||||||
return false;
|
return false;
|
||||||
this._entities.set(ent.id(), ent);
|
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;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user