← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~widelands-dev/widelands/gcc9 into lp:widelands

 

GunChleoc has proposed merging lp:~widelands-dev/widelands/gcc9 into lp:widelands.

Commit message:
Patch for GCC9.

Requested reviews:
  Widelands Developers (widelands-dev)
Related bugs:
  Bug #1831359 in widelands: "Implement support for GCC 9"
  https://bugs.launchpad.net/widelands/+bug/1831359

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/gcc9/+merge/370692

Tested by kaputtnik
-- 
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/gcc9 into lp:widelands.
=== modified file 'src/graphic/gl/fields_to_draw.h'
--- src/graphic/gl/fields_to_draw.h	2019-05-29 15:43:40 +0000
+++ src/graphic/gl/fields_to_draw.h	2019-07-28 11:07:18 +0000
@@ -100,15 +100,10 @@
 	// coordinates in the map. Returns INVALID_INDEX 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_) {
-			return kInvalidIndex;
-		}
-		uint16_t yidx = fy - min_fy_;
-		if (yidx >= h_) {
-			return kInvalidIndex;
-		}
-		return yidx * w_ + xidx;
+		if (fx < min_fx_ || fx > max_fx_ || fy < min_fy_ || fy > max_fy_) {
+			return kInvalidIndex;
+		}
+		return (fy - min_fy_) * w_ + (fx - min_fx_);
 	}
 
 private:


Follow ups