mirror of
https://github.com/Sarjuuk/aowow.git
synced 2025-11-29 15:58:16 +08:00
Map/ShowOnMap
* fix pins being combined across multiple floors
This commit is contained in:
@@ -505,12 +505,13 @@ ShowOnMap.prototype.checkMenu = function(path) {
|
|||||||
ShowOnMap.combinePins = function(pins, dailyOnly, hasPaths) {
|
ShowOnMap.combinePins = function(pins, dailyOnly, hasPaths) {
|
||||||
var combined = {};
|
var combined = {};
|
||||||
var coord = null, tmpCoord = null;
|
var coord = null, tmpCoord = null;
|
||||||
var x, y;
|
var x, y, l;
|
||||||
var nPins = 0;
|
var nPins = 0;
|
||||||
|
|
||||||
var getCoord = function(coord, tight) {
|
var getCoord = function(coord, level, tight) {
|
||||||
var x = Math.floor(coord[0]);
|
var x = Math.floor(coord[0]);
|
||||||
var y = Math.floor(coord[1]);
|
var y = Math.floor(coord[1]);
|
||||||
|
var l = level || 0;
|
||||||
if (!tight) {
|
if (!tight) {
|
||||||
if (x % 2 == 1) {
|
if (x % 2 == 1) {
|
||||||
x += 1;
|
x += 1;
|
||||||
@@ -520,11 +521,14 @@ ShowOnMap.combinePins = function(pins, dailyOnly, hasPaths) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (combined[x] === undefined) {
|
if (combined[l] === undefined) {
|
||||||
combined[x] = {};
|
combined[l] = {};
|
||||||
}
|
}
|
||||||
if (combined[x][y] === undefined) {
|
if (combined[l][x] === undefined) {
|
||||||
combined[x][y] = [];
|
combined[l][x] = {};
|
||||||
|
}
|
||||||
|
if (combined[l][x][y] === undefined) {
|
||||||
|
combined[l][x][y] = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
return [x, y];
|
return [x, y];
|
||||||
@@ -577,36 +581,38 @@ ShowOnMap.combinePins = function(pins, dailyOnly, hasPaths) {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (var c = 0; c < pin.coords.length; ++c) {
|
for (var c = 0; c < pin.coords.length; ++c) {
|
||||||
coord = getCoord(pin.coords[c]);
|
coord = getCoord(pin.coords[c], pin.level);
|
||||||
x = coord[0]; y = coord[1];
|
x = coord[0]; y = coord[1]; l = pin.level || 0;
|
||||||
var newPin = $WH.dO(pin);
|
var newPin = $WH.dO(pin);
|
||||||
newPin.coord = pin.coords[c];
|
newPin.coord = pin.coords[c];
|
||||||
|
|
||||||
if (combined[x][y].length > 3) {
|
if (combined[l][x][y].length > 3) {
|
||||||
var temp = combined[x][y];
|
var temp = combined[l][x][y];
|
||||||
combined[x][y] = [];
|
combined[l][x][y] = [];
|
||||||
for (var i = 0; i < temp.length; ++i) {
|
for (var i = 0; i < temp.length; ++i) {
|
||||||
tmpCoord = getCoord(temp[i].coord, true);
|
tmpCoord = getCoord(temp[i].coord, temp[i].level, true);
|
||||||
combined[tmpCoord[0]][tmpCoord[1]].push(temp[i]);
|
combined[temp[i].level][tmpCoord[0]][tmpCoord[1]].push(temp[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
combined[x][y].push(newPin);
|
combined[l][x][y].push(newPin);
|
||||||
nPins++;
|
nPins++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var complete = [];
|
var complete = [];
|
||||||
for (x in combined) {
|
for (l in combined) {
|
||||||
for (y in combined[x]) {
|
for (x in combined[l]) {
|
||||||
|
for (y in combined[l][x]) {
|
||||||
complete.push({
|
complete.push({
|
||||||
coord: [combined[x][y][0].coord[0], combined[x][y][0].coord[1]],
|
coord: [combined[l][x][y][0].coord[0], combined[l][x][y][0].coord[1]],
|
||||||
level: combined[x][y][0].level,
|
level: l,
|
||||||
list: combined[x][y]
|
list: combined[l][x][y]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return [complete, nPins];
|
return [complete, nPins];
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user