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:
phosit 2025-09-21 16:28:12 +02:00
parent 130ea06ce8
commit f35595610a
No known key found for this signature in database
GPG key ID: C9430B600671C268

View file

@ -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;
};