diff --git a/src/openrct2/interface/Viewport.cpp b/src/openrct2/interface/Viewport.cpp index 9d6b51dacc..3a2015accc 100644 --- a/src/openrct2/interface/Viewport.cpp +++ b/src/openrct2/interface/Viewport.cpp @@ -1858,9 +1858,7 @@ InteractionInfo SetInteractionInfoFromPaintSession(PaintSession* session, uint32 #pragma GCC diagnostic ignored "-Wnull-dereference" for (AttachedPaintStruct* attached_ps = ps->Attached; attached_ps != nullptr; attached_ps = attached_ps->next) { - if (IsSpriteInteractedWith( - session->DPI, attached_ps->image_id, - { (attached_ps->x + ps->ScreenPos.x), (attached_ps->y + ps->ScreenPos.y) })) + if (IsSpriteInteractedWith(session->DPI, attached_ps->image_id, ps->ScreenPos + attached_ps->RelativePos)) { if (PSSpriteTypeIsInFilter(ps, filter) && GetPaintStructVisibility(ps, viewFlags) != VisibilityKind::Hidden) { diff --git a/src/openrct2/paint/Paint.cpp b/src/openrct2/paint/Paint.cpp index f15c4c3b05..7e3e5b6d68 100644 --- a/src/openrct2/paint/Paint.cpp +++ b/src/openrct2/paint/Paint.cpp @@ -564,7 +564,7 @@ static void PaintAttachedPS(DrawPixelInfo& dpi, PaintStruct* ps, uint32_t viewFl AttachedPaintStruct* attached_ps = ps->Attached; for (; attached_ps != nullptr; attached_ps = attached_ps->next) { - auto screenCoords = ScreenCoordsXY{ attached_ps->x + ps->ScreenPos.x, attached_ps->y + ps->ScreenPos.y }; + const auto screenCoords = ps->ScreenPos + attached_ps->RelativePos; auto imageId = PaintPSColourifyImage(ps, attached_ps->image_id, viewFlags); if (attached_ps->IsMasked) @@ -806,8 +806,7 @@ bool PaintAttachToPreviousAttach(PaintSession& session, const ImageId imageId, i } ps->image_id = imageId; - ps->x = x; - ps->y = y; + ps->RelativePos = { x, y }; ps->IsMasked = false; ps->next = nullptr; @@ -839,8 +838,7 @@ bool PaintAttachToPreviousPS(PaintSession& session, const ImageId image_id, int3 } ps->image_id = image_id; - ps->x = x; - ps->y = y; + ps->RelativePos = { x, y }; ps->IsMasked = false; AttachedPaintStruct* oldFirstAttached = masterPs->Attached; diff --git a/src/openrct2/paint/Paint.h b/src/openrct2/paint/Paint.h index 78db3ff575..be62e93d23 100644 --- a/src/openrct2/paint/Paint.h +++ b/src/openrct2/paint/Paint.h @@ -31,8 +31,8 @@ struct AttachedPaintStruct AttachedPaintStruct* next; ImageId image_id; ImageId ColourImageId; - int32_t x; - int32_t y; + // This is relative to the parent where we are attached to. + ScreenCoordsXY RelativePos; bool IsMasked; };