aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/search.js10
1 files changed, 6 insertions, 4 deletions
diff --git a/tools/search.js b/tools/search.js
index e365214..378f316 100644
--- a/tools/search.js
+++ b/tools/search.js
@@ -14,9 +14,9 @@ function getComp(index){
function Search(){ // searchBlock should be a Space object.
this.tiles = {}; // Object which stores Spaces.
- this.sort = [[],[]]; // Vertically/horizontally sorted list of tiles for fast addition, deletion, and searching
- this.spaces = [];
- this.calls = [];
+ this.sort = [[],[]]; // Vertically/horizontally sorted list of indexed tiles for fast addition, deletion, and searching
+ this.spaces = []; // if spaces[i] is detected,
+ this.calls = []; // calls[i](coords, send, searchspace)
this.add = function(loc, space, send){ // loc should be [tileY,tileX] and space Space.
this.tiles[loc] = space;
@@ -77,8 +77,10 @@ function Search(){ // searchBlock should be a Space object.
}
this.update = function(space){ // Must be a space w/ valid loc; allows overlay of some arbitrary text (in the space) mostly for recording updates from the server without directly cataloguing them
+ if (space.loc.length === 0) throw "Update space must have valid loc";
let tiles = raster(space); // Returns a this.tiles-style binding: {'2,-3':Space object}
- for (let tile in tiles){
+ for (let tile in tiles) {
+ tile = tile.split(',').map(s => parseInt(s));
if (this.tiles[tile]) this.tiles[tile].comb(tiles[tile], comb.flip(comb.add));
else this.add(tile, tiles[tile]);
}