diff --git a/code/hud/hudconfig.cpp b/code/hud/hudconfig.cpp index 8a3634134d8..71644811579 100644 --- a/code/hud/hudconfig.cpp +++ b/code/hud/hudconfig.cpp @@ -610,8 +610,8 @@ void hud_config_init_ui(bool API_Access, int x, int y, int w) HC_gauge_coords.resize(NUM_HUD_GAUGES); // Clear the mouse coords array - for (int count = 0; count < NUM_HUD_GAUGES; ++count) { - HC_gauge_mouse_coords[count] = {-1, -1, -1, -1}; + for (auto& coord : HC_gauge_mouse_coords) { + coord = {-1, -1, -1, -1}; } if (w < 0) { diff --git a/code/hud/hudconfig.h b/code/hud/hudconfig.h index de6477a1ee6..965f4dd6788 100644 --- a/code/hud/hudconfig.h +++ b/code/hud/hudconfig.h @@ -107,10 +107,10 @@ class BoundingBox { bool isOverlapping(const BoundingBox& other) const { - return !(x2 < other.x1 || // Completely to the left - x1 > other.x2 || // Completely to the right - y2 < other.y1 || // Completely above - y1 > other.y2); // Completely below + return (x2 >= other.x1 && // Not completely to the left + x1 <= other.x2 && // Not completely to the right + y2 >= other.y1 && // Not completely above + y1 <= other.y2); // Not completely below } // Check if the bounding box is valid (no negative coordinates)