From b8d66fc783f9b98ff2ad50fa5caa13c5f3b9e39d Mon Sep 17 00:00:00 2001 From: Patric Stout Date: Sat, 3 Jun 2023 23:09:41 +0200 Subject: [PATCH] Codechange: simplify UpdateCursorPositionRelative The function is only called with fix_at=true, so don't support the other cases. --- src/gfx.cpp | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/src/gfx.cpp b/src/gfx.cpp index 43a2072d4a..eeafa04c06 100644 --- a/src/gfx.cpp +++ b/src/gfx.cpp @@ -1942,27 +1942,17 @@ void SetAnimatedMouseCursor(const AnimCursor *table) } /** - * Update cursor position on mouse movement for relative modes. + * Update cursor position based on a relative change. + * * @param delta_x How much change in the X position. * @param delta_y How much change in the Y position. */ void CursorVars::UpdateCursorPositionRelative(int delta_x, int delta_y) { - if (this->fix_at) { - this->delta.x = delta_x; - this->delta.y = delta_y; - } else { - int last_position_x = this->pos.x; - int last_position_y = this->pos.y; + assert(this->fix_at); - this->pos.x = Clamp(this->pos.x + delta_x, 0, _cur_resolution.width - 1); - this->pos.y = Clamp(this->pos.y + delta_y, 0, _cur_resolution.height - 1); - - this->delta.x = last_position_x - this->pos.x; - this->delta.y = last_position_y - this->pos.y; - - this->dirty = true; - } + this->delta.x = delta_x; + this->delta.y = delta_y; } /**