Skip to content

Commit

Permalink
fix(vendor.roborock): Fix roborock virtual restrictions counting vert…
Browse files Browse the repository at this point in the history
…ices incorrectly

this fixes #1423
  • Loading branch information
Hypfer committed Feb 21, 2022
1 parent 411fab5 commit cc5e37b
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class RoborockCombinedVirtualRestrictionsCapability extends CombinedVirtualRestr
*/
async setVirtualRestrictions(virtualRestrictions) {
const roborockPayload = [];
let vertexCount = 0;

virtualRestrictions.virtualWalls.forEach(wall => {
roborockPayload.push([
Expand All @@ -28,6 +29,8 @@ class RoborockCombinedVirtualRestrictionsCapability extends CombinedVirtualRestr
Math.floor(wall.points.pB.x * 10),
Math.floor(RoborockMapParser.DIMENSION_MM - wall.points.pB.y * 10),
]);

vertexCount = vertexCount + 2;
});

virtualRestrictions.restrictedZones.forEach(zone => {
Expand All @@ -54,12 +57,12 @@ class RoborockCombinedVirtualRestrictionsCapability extends CombinedVirtualRestr
Math.floor(zone.points.pD.x * 10),
Math.floor(RoborockMapParser.DIMENSION_MM - zone.points.pD.y * 10)
]);

vertexCount = vertexCount + 4;
});

if (roborockPayload.reduce((total, currentElem) => {
return total + currentElem.length - 1;
}, 0) > 68) {
throw new Error("too many forbidden markers to save!");
if (vertexCount > 68) {
throw new Error("Too many vertices to save");
}


Expand Down

0 comments on commit cc5e37b

Please sign in to comment.