Blob Blame History Raw
diff -up widelands-build20/src/graphic/gl/fields_to_draw.h~ widelands-build20/src/graphic/gl/fields_to_draw.h
--- widelands-build20/src/graphic/gl/fields_to_draw.h~	2019-05-02 07:23:39.000000000 +0200
+++ widelands-build20/src/graphic/gl/fields_to_draw.h	2019-07-14 21:39:12.805869365 +0200
@@ -102,15 +102,11 @@ private:
 	// coordinates in the map. Returns kInvalidIndex if this field is not in the
 	// fields_to_draw.
 	inline int calculate_index(int fx, int fy) const {
-		uint16_t xidx = fx - min_fx_;
-		if (xidx >= w_) {
+		if (fx < min_fx_ || fx > max_fx_ ||
+		    fy < min_fy_ || fy > max_fy_) {
 			return kInvalidIndex;
 		}
-		uint16_t yidx = fy - min_fy_;
-		if (yidx >= h_) {
-			return kInvalidIndex;
-		}
-		return yidx * w_ + xidx;
+		return (fy - min_fy_) * w_ + (fx - min_fx_);
 	}
 
 	// Minimum and maximum field coordinates (geometric) to render. Can be negative.