Skip to content

Commit c97136d

Browse files
committed
Engine: fixed unintended int->uint cast in MaskRouteFinder
This fixes negative coordinates overflow.
1 parent 93b50b6 commit c97136d

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

Engine/ac/route_finder.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ bool MaskRouteFinder::FindRoute(std::vector<Point> &path, int srcx, int srcy, in
5656
return false;
5757

5858
// convert input to the mask coords
59-
srcx /= _coordScale;
60-
srcy /= _coordScale;
61-
dstx /= _coordScale;
62-
dsty /= _coordScale;
59+
srcx = _coordScale;
60+
srcy = _coordScale;
61+
dstx = _coordScale;
62+
dsty = _coordScale;
6363

6464
if (!FindRouteImpl(path, srcx, srcy, dstx, dsty, exact_dest, ignore_walls))
6565
return false;
@@ -70,11 +70,11 @@ bool MaskRouteFinder::FindRoute(std::vector<Point> &path, int srcx, int srcy, in
7070
return true;
7171
}
7272

73-
void MaskRouteFinder::SetWalkableArea(const AGS::Common::Bitmap *walkablearea, uint32_t coord_scale)
73+
void MaskRouteFinder::SetWalkableArea(const AGS::Common::Bitmap *walkablearea, int coord_scale)
7474
{
7575
_walkablearea = walkablearea;
7676
assert(coord_scale > 0);
77-
_coordScale = std::max(1u, coord_scale);
77+
_coordScale = std::max(1, coord_scale);
7878
OnSetWalkableArea();
7979
}
8080

Engine/ac/route_finder.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class MaskRouteFinder : public IRouteFinder
6767
// Assign a walkable mask, and an optional coordinate scale factor which will be used
6868
// to convert (divide) input coordinates, and resulting path back (multiply).
6969
// Note that this may make routefinder to generate additional data, taking more time.
70-
void SetWalkableArea(const AGS::Common::Bitmap *walkablearea, uint32_t coord_scale = 1);
70+
void SetWalkableArea(const AGS::Common::Bitmap *walkablearea, int coord_scale = 1);
7171

7272
protected:
7373
// Update the implementation after a new walkable area is set
@@ -79,7 +79,7 @@ class MaskRouteFinder : public IRouteFinder
7979
bool exact_dest, bool ignore_walls) = 0;
8080

8181
const Common::Bitmap *_walkablearea = nullptr;
82-
uint32_t _coordScale = 1;
82+
int _coordScale = 1;
8383
};
8484

8585
//

0 commit comments

Comments
 (0)