aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHolden Rohrer <hr@hrhr.dev>2020-07-16 13:41:19 -0400
committerHolden Rohrer <hr@hrhr.dev>2020-07-16 13:41:19 -0400
commitf26b5af8c272628da9a46d7e4bf79634fb8dbae3 (patch)
tree4eb219a9627e5c6bfecc370b09be4da1a9e6ece7
parentdd26190c2ebaac4a7a3b8e8a29ea51f8be03f529 (diff)
search.update passing incorrect stringy loc, improved search.js doc
-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]);
}