feat: Added unit clustering and other small performance and loadtime improvements

This commit is contained in:
Davide Passoni
2025-03-21 16:11:57 +01:00
parent 99e742498d
commit 3ab10af98b
12 changed files with 380 additions and 98 deletions

View File

@@ -215,7 +215,7 @@ export class ServerManager {
}
getUnits(callback: CallableFunction, refresh: boolean = false, errorCallback: CallableFunction = () => {}) {
this.GET(callback, errorCallback, UNITS_URI, { time: refresh ? 0 : this.#lastUpdateTimes[UNITS_URI] }, "arraybuffer", refresh);
this.GET(callback, errorCallback, UNITS_URI, { time: refresh ? 0 : this.#lastUpdateTimes[UNITS_URI] }, "arraybuffer", false);
}
getWeapons(callback: CallableFunction, refresh: boolean = false, errorCallback: CallableFunction = () => {}) {
@@ -342,7 +342,13 @@ export class ServerManager {
this.PUT(data, callback);
}
cloneUnits(units: { ID: number; location: LatLng }[], deleteOriginal: boolean, spawnPoints: number, coalition: Coalition, callback: CallableFunction = () => {}) {
cloneUnits(
units: { ID: number; location: LatLng }[],
deleteOriginal: boolean,
spawnPoints: number,
coalition: Coalition,
callback: CallableFunction = () => {}
) {
var command = {
units: units,
coalition: coalition,
@@ -582,7 +588,7 @@ export class ServerManager {
targetingRange: targetingRange,
aimMethodRange: aimMethodRange,
acquisitionRange: acquisitionRange,
}
};
var data = { setEngagementProperties: command };
this.PUT(data, callback);
@@ -618,11 +624,14 @@ export class ServerManager {
loadEnvResources() {
/* Load the drawings */
this.getDrawings((drawingsData: { drawings: Record<string, Record<string, any>> }) => {
if (drawingsData) {
getApp().getDrawingsManager()?.initDrawings(drawingsData);
}
}, () => {});
this.getDrawings(
(drawingsData: { drawings: Record<string, Record<string, any>> }) => {
if (drawingsData) {
getApp().getDrawingsManager()?.initDrawings(drawingsData);
}
},
() => {}
);
// TODO: load navPoints
}
@@ -790,10 +799,12 @@ export class ServerManager {
return time;
}, true);
this.getUnits((buffer: ArrayBuffer) => {
var time = getApp().getUnitsManager()?.update(buffer, true);
return time;
}, true);
window.setInterval(() => {
this.getUnits((buffer: ArrayBuffer) => {
var time = getApp().getUnitsManager()?.update(buffer, true);
return time;
}, true);
}, 500);
}
checkSessionHash(newSessionHash: string) {