From 4a2c7716034ad634cd26dadb1312ae1572a7a660 Mon Sep 17 00:00:00 2001 From: Adam <897017+aSemy@users.noreply.github.com> Date: Sun, 24 Apr 2022 11:32:34 +0200 Subject: [PATCH] experiment with optimising map-chunk message --- .../main/events/onMapChunkEventListeners.ts | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/modules/events-mod/src/main/typescript/main/events/onMapChunkEventListeners.ts b/modules/events-mod/src/main/typescript/main/events/onMapChunkEventListeners.ts index e30886d..75c9f7c 100644 --- a/modules/events-mod/src/main/typescript/main/events/onMapChunkEventListeners.ts +++ b/modules/events-mod/src/main/typescript/main/events/onMapChunkEventListeners.ts @@ -41,6 +41,43 @@ function mapTilesUpdateDebounce( protos: {}, } + + // let maxX = 0 + // let minX = 0 + // let maxY = 0 + // let minY = 0 + // for (const tile of tiles) { + // //@formatter:off + // if (tile.position.x < minX) minX = tile.position.x + // if (tile.position.x > maxX) maxX = tile.position.x + // if (tile.position.y > minY) minY = tile.position.y + // if (tile.position.y > maxY) maxY = tile.position.y + // //@formatter:on + // } + // + // const noTileProto = 0 + // + // const grid: int[][] = [] + // for (let x = 0; x < maxX; x++) { + // grid[x] = [] + // for (let y = 0; y < maxY; y++) { + // grid[x][y] = noTileProto + // } + // } + // data.tileDictionary.protos["no-tile"] = noTileProto + // + // let protosCount2: uint = 0 + // for (const tile of tiles) { + // const x = tile.position.x - minX + // const y = tile.position.y - minY + // + // data.tileDictionary.protos[tile.name] ??= protosCount2++ + // grid[x][y] = data.tileDictionary.protos[tile.name] + // } + // + // const grid2: string[] = grid.map(row => table.concat(row)) + + let protosCount: uint = 0 for (const tile of tiles) { data.tileDictionary.protos[tile.name] ??= protosCount++