From 991b2e46b05b636e8cd9bf5e43dd1320403fddcd Mon Sep 17 00:00:00 2001 From: nsubiron Date: Tue, 2 May 2017 15:17:13 +0100 Subject: [PATCH] Fix crash when player goes out of road map --- Source/Carla/MapGen/RoadMap.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Source/Carla/MapGen/RoadMap.cpp b/Source/Carla/MapGen/RoadMap.cpp index 31fe87d66..960c3994e 100644 --- a/Source/Carla/MapGen/RoadMap.cpp +++ b/Source/Carla/MapGen/RoadMap.cpp @@ -12,9 +12,10 @@ static uint32 ClampFloatToUInt(const float Value, int32 Min, int32 Max) const FRoadMapPixelData &URoadMap::GetDataAt(const FVector &WorldLocation) const { + check(IsValid()); const FVector Location = WorldToMap.TransformPosition(WorldLocation); - uint32 X = ClampFloatToUInt(PixelsPerCentimeter * Location.X, 0, Width); - uint32 Y = ClampFloatToUInt(PixelsPerCentimeter * Location.Y, 0, Height); + uint32 X = ClampFloatToUInt(PixelsPerCentimeter * Location.X, 0, Width - 1); + uint32 Y = ClampFloatToUInt(PixelsPerCentimeter * Location.Y, 0, Height - 1); return GetDataAt(X, Y); }