← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~majcherlk/widelands/bug-1243700 into lp:widelands

 

Lukasz has proposed merging lp:~majcherlk/widelands/bug-1243700 into lp:widelands.

Requested reviews:
  Widelands Developers (widelands-dev)

For more details, see:
https://code.launchpad.net/~majcherlk/widelands/bug-1243700/+merge/255765

Changes in displaying statistics in order to fix bug 1243700. The time displayed in statistics is rounded to integer: game_time/ticks so everytime number of ticks was not divisible by time game we got incorrect time value. Now game time is always divisible by number of ticks. Another way to solve this bug is to display fractional time but I think the first way is more user friendly. Any suggestions?
-- 
Your team Widelands Developers is requested to review the proposed merge of lp:~majcherlk/widelands/bug-1243700 into lp:widelands.
=== modified file 'src/wui/plot_area.cc'
--- src/wui/plot_area.cc	2014-12-11 12:38:10 +0000
+++ src/wui/plot_area.cc	2015-04-10 01:34:13 +0000
@@ -156,26 +156,19 @@
 	max_x = ms_to_unit(unit, time_ms);
 
 	// Find a nice division of max_x
-	if (max_x % 5 == 0) {
-		if (max_x <= 10) {
-			how_many_ticks = 5;
-		} else {
-			how_many_ticks = max_x / 5;
-			while (how_many_ticks > 7 && how_many_ticks % 2 == 0) {
-				how_many_ticks /= 2;
-			}
-			while (how_many_ticks > 7 && how_many_ticks % 3 == 0) {
-				how_many_ticks /= 3;
-			}
-			while (how_many_ticks > 7 && how_many_ticks % 5 == 0) {
-				how_many_ticks /= 5;
-			}
-			while (how_many_ticks > 7 && how_many_ticks % 7 == 0) {
-				how_many_ticks /= 7;
-			}
-		}
-	} else {
-		how_many_ticks = 4;
+	how_many_ticks = max_x;
+
+	while (how_many_ticks > 10 && how_many_ticks % 5 == 0) {
+			how_many_ticks /= 5;
+	}
+	while (how_many_ticks > 7 && how_many_ticks % 2 == 0) {
+		how_many_ticks /= 2;
+	}
+	while (how_many_ticks > 7 && how_many_ticks % 3 == 0) {
+		how_many_ticks /= 3;
+	}
+	while (how_many_ticks > 7 && how_many_ticks % 7 == 0) {
+		how_many_ticks /= 7;
 	}
 
 	// first, tile the background