Skip to content

Commit 399a375

Browse files
authored
Merge pull request #24 from harishjp/master
Fix column duplication because during worker message processing.
2 parents 0dc3de5 + dd3246e commit 399a375

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

resources/js/WorldLoader.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -486,12 +486,12 @@ function readTiles(reader, world) {
486486

487487
tilesProcessed += world.height;
488488

489-
if (x % 2 == 0) {
489+
if (x % 2 == 1) {
490490
self.postMessage({
491491
'status': "Reading tile " + tilesProcessed.toLocaleString() + " of " + world.totalTileCount.toLocaleString(),
492492
// 'tilesProcessed': tilesProcessed,
493493
// 'totalTileCount': world.totalTileCount,
494-
'x': x,
494+
'x': x - 1,
495495
'tiles': tiles,
496496
});
497497
tiles = [];

resources/js/main.js

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -764,17 +764,12 @@ function onWorldLoaderWorkerMessage(e) {
764764
if(e.data.status)
765765
$("#status").html(e.data.status);
766766

767-
var x = 0;
768-
var i = 0;
769-
var tile;
770-
771767
if(e.data.tiles) {
772-
x = e.data.x;
773-
774-
for(x = e.data.x; x <= e.data.x + 1; x++) {
775-
for(y = 0; y < e.data.tiles.length / 2; y++) {
776-
tile = e.data.tiles[y];
777-
768+
let xlimit = e.data.x + e.data.tiles.length / world.height;
769+
let i = 0;
770+
for(let x = e.data.x; x < xlimit; x++) {
771+
for(let y = 0; y < world.height; y++) {
772+
let tile = e.data.tiles[i++];
778773
if(tile) {
779774
tile.info = getTileInfo(tile);
780775
world.tiles.push(tile);

0 commit comments

Comments
 (0)