From cbbaeb5c65aa5d652558fb33aa9f99514ab1c904 Mon Sep 17 00:00:00 2001 From: Ivan Mogilko Date: Mon, 7 Oct 2024 19:25:07 +0300 Subject: [PATCH] Engine: fixed unintended int->uint cast in MaskRouteFinder This fixes negative coordinates overflow. --- Engine/ac/route_finder.cpp | 4 ++-- Engine/ac/route_finder.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Engine/ac/route_finder.cpp b/Engine/ac/route_finder.cpp index 374b7ff647..06d84013b9 100644 --- a/Engine/ac/route_finder.cpp +++ b/Engine/ac/route_finder.cpp @@ -63,11 +63,11 @@ bool MaskRouteFinder::FindRoute(std::vector &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(); } diff --git a/Engine/ac/route_finder.h b/Engine/ac/route_finder.h index 8b7b3f5526..65871b9e20 100644 --- a/Engine/ac/route_finder.h +++ b/Engine/ac/route_finder.h @@ -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 @@ -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; };