mirror of
https://github.com/tobspr/shapez.io.git
synced 2024-10-27 20:34:29 +00:00
Do not overload analytics server if entity arrays get too big
This commit is contained in:
parent
a110abc192
commit
91e713fc00
@ -23,7 +23,7 @@ export class ShapezGameAnalytics extends GameAnalyticsInterface {
|
|||||||
initialize() {
|
initialize() {
|
||||||
this.syncKey = null;
|
this.syncKey = null;
|
||||||
|
|
||||||
setInterval(() => this.sendTimePoints(), 30 * 1000);
|
setInterval(() => this.sendTimePoints(), 120 * 1000);
|
||||||
|
|
||||||
// Retrieve sync key from player
|
// Retrieve sync key from player
|
||||||
return this.app.storage.readFileAsync(analyticsLocalFile).then(
|
return this.app.storage.readFileAsync(analyticsLocalFile).then(
|
||||||
@ -158,26 +158,29 @@ export class ShapezGameAnalytics extends GameAnalyticsInterface {
|
|||||||
|
|
||||||
const entities = root.entityMgr.getAllWithComponent(StaticMapEntityComponent);
|
const entities = root.entityMgr.getAllWithComponent(StaticMapEntityComponent);
|
||||||
|
|
||||||
for (let i = 0; i < entities.length; ++i) {
|
// Limit the entities
|
||||||
const entity = entities[i];
|
if (entities.length < 5000) {
|
||||||
const staticComp = entity.components.StaticMapEntity;
|
for (let i = 0; i < entities.length; ++i) {
|
||||||
const payload = {};
|
const entity = entities[i];
|
||||||
payload.origin = staticComp.origin;
|
const staticComp = entity.components.StaticMapEntity;
|
||||||
payload.tileSize = staticComp.tileSize;
|
const payload = {};
|
||||||
payload.rotation = staticComp.rotation;
|
payload.origin = staticComp.origin;
|
||||||
|
payload.tileSize = staticComp.tileSize;
|
||||||
|
payload.rotation = staticComp.rotation;
|
||||||
|
|
||||||
if (entity.components.Belt) {
|
if (entity.components.Belt) {
|
||||||
payload.type = "belt";
|
payload.type = "belt";
|
||||||
} else if (entity.components.UndergroundBelt) {
|
} else if (entity.components.UndergroundBelt) {
|
||||||
payload.type = "tunnel";
|
payload.type = "tunnel";
|
||||||
} else if (entity.components.ItemProcessor) {
|
} else if (entity.components.ItemProcessor) {
|
||||||
payload.type = entity.components.ItemProcessor.type;
|
payload.type = entity.components.ItemProcessor.type;
|
||||||
} else if (entity.components.Miner) {
|
} else if (entity.components.Miner) {
|
||||||
payload.type = "extractor";
|
payload.type = "extractor";
|
||||||
} else {
|
} else {
|
||||||
logger.warn("Unkown entity type", entity);
|
logger.warn("Unkown entity type", entity);
|
||||||
|
}
|
||||||
|
staticEntities.push(payload);
|
||||||
}
|
}
|
||||||
staticEntities.push(payload);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
Loading…
Reference in New Issue
Block a user