Skip to content

Commit

Permalink
Engine: fixed unintended int->uint cast in MaskRouteFinder
Browse files Browse the repository at this point in the history
This fixes negative coordinates overflow.
  • Loading branch information
ivan-mogilko committed Oct 7, 2024
1 parent 35dcccc commit cbbaeb5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Engine/ac/route_finder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ bool MaskRouteFinder::FindRoute(std::vector<Point> &path, int srcx, int srcy, in
return true;
}

void MaskRouteFinder::SetWalkableArea(const AGS::Common::Bitmap *walkablearea, uint32_t coord_scale)
void MaskRouteFinder::SetWalkableArea(const AGS::Common::Bitmap *walkablearea, int coord_scale)
{
_walkablearea = walkablearea;
assert(coord_scale > 0);
_coordScale = std::max(1u, coord_scale);
_coordScale = std::max(1, coord_scale);
OnSetWalkableArea();
}

Expand Down
4 changes: 2 additions & 2 deletions Engine/ac/route_finder.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class MaskRouteFinder : public IRouteFinder
// Assign a walkable mask, and an optional coordinate scale factor which will be used
// to convert (divide) input coordinates, and resulting path back (multiply).
// Note that this may make routefinder to generate additional data, taking more time.
void SetWalkableArea(const AGS::Common::Bitmap *walkablearea, uint32_t coord_scale = 1);
void SetWalkableArea(const AGS::Common::Bitmap *walkablearea, int coord_scale = 1);

protected:
// Update the implementation after a new walkable area is set
Expand All @@ -75,7 +75,7 @@ class MaskRouteFinder : public IRouteFinder
bool exact_dest, bool ignore_walls) = 0;

const Common::Bitmap *_walkablearea = nullptr;
uint32_t _coordScale = 1;
int _coordScale = 1;
};


Expand Down

0 comments on commit cbbaeb5

Please sign in to comment.