Re: [Widelands-dev] [Merge] lp:~widelands-dev/widelands/bug-1821506-new-scenario-crash into lp:widelands

2019-03-26 Thread hessenfarmer
Review: Approve test review

Tested this. Works well. Code LGTM. 

@bunnybot merge
-- 
https://code.launchpad.net/~widelands-dev/widelands/bug-1821506-new-scenario-crash/+merge/365002
Your team Widelands Developers is subscribed to branch 
lp:~widelands-dev/widelands/bug-1821506-new-scenario-crash.

___
Mailing list: https://launchpad.net/~widelands-dev
Post to : widelands-dev@lists.launchpad.net
Unsubscribe : https://launchpad.net/~widelands-dev
More help   : https://help.launchpad.net/ListHelp


[Widelands-dev] [Merge] lp:~widelands-dev/widelands/bug-1817550-Statistics-hook-Winconditions into lp:widelands

2019-03-26 Thread hessenfarmer
hessenfarmer has proposed merging 
lp:~widelands-dev/widelands/bug-1817550-Statistics-hook-Winconditions into 
lp:widelands.

Commit message:
- Added statistics hook for territorial Win conditions
- Added statistics hook for artifacts wincondition
- fixed a bug in artifacts which led to coroutine error if Player defeated when 
reaching win condition

Requested reviews:
  Widelands Developers (widelands-dev)
Related bugs:
  Bug #1645837 in widelands: "Number of conquered artifacts should be shown in 
statistics"
  https://bugs.launchpad.net/widelands/+bug/1645837
  Bug #1817550 in widelands: "Add statistics hook for Territorial functions"
  https://bugs.launchpad.net/widelands/+bug/1817550

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/bug-1817550-Statistics-hook-Winconditions/+merge/365086

This is for Build 21. 

Win condition statictic Windows will be shown showing the percentage of 
territory owned for territorial and artifacts owned for artifact wc.
-- 
Your team Widelands Developers is requested to review the proposed merge of 
lp:~widelands-dev/widelands/bug-1817550-Statistics-hook-Winconditions into 
lp:widelands.
=== added file 'data/images/wui/stats/genstats_artifacts.png'
Binary files data/images/wui/stats/genstats_artifacts.png	1970-01-01 00:00:00 + and data/images/wui/stats/genstats_artifacts.png	2019-03-26 07:43:29 + differ
=== added file 'data/images/wui/stats/genstats_territorial_big.png'
Binary files data/images/wui/stats/genstats_territorial_big.png	1970-01-01 00:00:00 + and data/images/wui/stats/genstats_territorial_big.png	2019-03-26 07:43:29 + differ
=== added file 'data/images/wui/stats/genstats_territorial_small.png'
Binary files data/images/wui/stats/genstats_territorial_small.png	1970-01-01 00:00:00 + and data/images/wui/stats/genstats_territorial_small.png	2019-03-26 07:43:29 + differ
=== modified file 'data/scripting/win_conditions/artifacts.lua'
--- data/scripting/win_conditions/artifacts.lua	2019-02-23 09:12:18 +
+++ data/scripting/win_conditions/artifacts.lua	2019-03-26 07:43:29 +
@@ -15,6 +15,7 @@
 local wc_descname = _("Artifacts")
 local wc_version = 1
 local wc_desc = _ "Search for ancient artifacts. Once all of them are found, the team who owns most of them will win the game."
+local wc_artifacts = _"Artifacts owned"
 
 -- Table of all artifacts to conquer
 local artifact_fields = {}
@@ -50,7 +51,22 @@
  end
   end
 
+  local artifacts_owner = {}
   local plrs = wl.Game().players
+
+  -- statistic variables and functions
+  -- initializing artifacts owned table
+  local artifacts_per_player = {}
+  -- funtion to calculate actual number of owned artifacts per player
+  local function _calcowned()
+ for idx, plr in ipairs(wl.Game().players) do
+artifacts_per_player[plr.number] = 0
+ end
+ for idx, plr in pairs(artifacts_owner) do
+ artifacts_per_player[plr.number] = artifacts_per_player[plr.number] + 1
+ end
+  end
+
   if #artifact_fields == 0 then
  for idx, plr in ipairs(plrs) do
 send_message(plr, _"No Artifacts", p(_"There are no artifacts on this map. This should not happen. Please file a bug report on %s and specify your Widelands version and the map you tried to load."):bformat("https://wl.widelands.org/wiki/ReportingBugs/";), {popup = true})
@@ -85,11 +101,22 @@
 end
  end
   end
+  
+
+  -- Install statistics hook
+  hooks.custom_statistic = {
+ name = wc_artifacts,
+ pic = "images/wui/stats/genstats_artifacts.png",
+ calculator = function(p)
+_calcowned(p)
+return artifacts_per_player[p.number] or 0
+ end,
+  }
 
   -- Iterate all players, if one is defeated, remove him
   -- from the list, send him a defeated message and give him full vision
   -- Check if all artifacts have been found (i.e. controlled by a player)
-  local artifacts_owner = {}
+
   repeat
  sleep(1000)
  check_player_defeated(plrs, lost_game.title, lost_game.body, wc_descname, wc_version)
@@ -115,7 +142,7 @@
 
   -- All artifacts are found, the game is over.
   local artifacts_per_team = {}
-  for idx, plr in ipairs(plrs) do
+  for idx, plr in ipairs(wl.Game().players) do
  artifacts_per_team[_getkey(plr)] = 0
   end
 
@@ -164,7 +191,6 @@
  msg = msg .. p((_"Team %1$i (%2$s) owns %3$s."):bformat(t[1].team, members, artifacts))
   end
 
-
   for idx, plr in ipairs(plrs) do
  local key = _getkey(plr)
  -- If two or more teams have the same amount of artifacts, they are all considered winners.
@@ -177,4 +203,5 @@
  end
   end
end,
+
 }

=== modified file 'data/scripting/win_conditions/territorial_lord.lua'
--- data/scripting/win_conditions/territorial_lord.lua	2019-03-09 10:55:24 +
+++ data/scripting/win_conditio

[Widelands-dev] [Merge] lp:~widelands-dev/widelands/bug-1821506-new-scenario-crash into lp:widelands

2019-03-26 Thread noreply
The proposal to merge 
lp:~widelands-dev/widelands/bug-1821506-new-scenario-crash into lp:widelands 
has been updated.

Status: Needs review => Merged

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/bug-1821506-new-scenario-crash/+merge/365002
-- 
Your team Widelands Developers is subscribed to branch 
lp:~widelands-dev/widelands/bug-1821506-new-scenario-crash.

___
Mailing list: https://launchpad.net/~widelands-dev
Post to : widelands-dev@lists.launchpad.net
Unsubscribe : https://launchpad.net/~widelands-dev
More help   : https://help.launchpad.net/ListHelp


[Widelands-dev] [Merge] lp:~widelands-dev/widelands/cleanup-soundhandler into lp:widelands

2019-03-26 Thread bunnybot
Continuous integration builds have changed state:

Travis build 4648. State: failed. Details: 
https://travis-ci.org/widelands/widelands/builds/511299575.
Appveyor build 4435. State: success. Details: 
https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_cleanup_soundhandler-4435.
-- 
https://code.launchpad.net/~widelands-dev/widelands/cleanup-soundhandler/+merge/365001
Your team Widelands Developers is requested to review the proposed merge of 
lp:~widelands-dev/widelands/cleanup-soundhandler into lp:widelands.

___
Mailing list: https://launchpad.net/~widelands-dev
Post to : widelands-dev@lists.launchpad.net
Unsubscribe : https://launchpad.net/~widelands-dev
More help   : https://help.launchpad.net/ListHelp


[Widelands-dev] [Merge] lp:~widelands-dev/widelands/bug-1817550-Statistics-hook-Winconditions into lp:widelands

2019-03-26 Thread bunnybot
Continuous integration builds have changed state:

Travis build 4649. State: passed. Details: 
https://travis-ci.org/widelands/widelands/builds/511361384.
Appveyor build 4436. State: success. Details: 
https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_1817550_Statistics_hook_Winconditions-4436.
-- 
https://code.launchpad.net/~widelands-dev/widelands/bug-1817550-Statistics-hook-Winconditions/+merge/365086
Your team Widelands Developers is requested to review the proposed merge of 
lp:~widelands-dev/widelands/bug-1817550-Statistics-hook-Winconditions into 
lp:widelands.

___
Mailing list: https://launchpad.net/~widelands-dev
Post to : widelands-dev@lists.launchpad.net
Unsubscribe : https://launchpad.net/~widelands-dev
More help   : https://help.launchpad.net/ListHelp


[Widelands-dev] [Merge] lp:~widelands-dev/widelands/bridges into lp:widelands

2019-03-26 Thread bunnybot
Continuous integration builds have changed state:

Travis build 4651. State: failed. Details: 
https://travis-ci.org/widelands/widelands/builds/511385042.
Appveyor build 4438. State: failed. Details: 
https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bridges-4438.
-- 
https://code.launchpad.net/~widelands-dev/widelands/bridges/+merge/364318
Your team Widelands Developers is subscribed to branch 
lp:~widelands-dev/widelands/ferry.

___
Mailing list: https://launchpad.net/~widelands-dev
Post to : widelands-dev@lists.launchpad.net
Unsubscribe : https://launchpad.net/~widelands-dev
More help   : https://help.launchpad.net/ListHelp


[Widelands-dev] [Merge] lp:~widelands-dev/widelands/bridges into lp:widelands

2019-03-26 Thread bunnybot
Continuous integration builds have changed state:

Travis build 4652. State: errored. Details: 
https://travis-ci.org/widelands/widelands/builds/511593017.
Appveyor build 4439. State: success. Details: 
https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bridges-4439.
-- 
https://code.launchpad.net/~widelands-dev/widelands/bridges/+merge/364318
Your team Widelands Developers is subscribed to branch 
lp:~widelands-dev/widelands/ferry.

___
Mailing list: https://launchpad.net/~widelands-dev
Post to : widelands-dev@lists.launchpad.net
Unsubscribe : https://launchpad.net/~widelands-dev
More help   : https://help.launchpad.net/ListHelp


[Widelands-dev] [Merge] lp:~widelands-dev/widelands/cleanup-statistics-plotter into lp:widelands

2019-03-26 Thread Toni Förster
Toni Förster has proposed merging 
lp:~widelands-dev/widelands/cleanup-statistics-plotter into lp:widelands.

Commit message:
Clean-up statistics' plotter:
  
- add ticks at 1/4 and 3/4 on the y-axes
- move y-axes ticks to the right
- draw max_value atop the y-axes
- draw a 0 instead of -0
- draw min value instead of 0
- make min_value green

Requested reviews:
  Widelands Developers (widelands-dev)

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/cleanup-statistics-plotter/+merge/365138

The old plot was a little hard to read, so I did some tweaking.

Here are some comparison pictures:

https://fosuta.org/pics/old_stats_1.png
https://fosuta.org/pics/new_stats_1.png

https://fosuta.org/pics/old_stats_2.png
https://fosuta.org/pics/new_stats_2.png

https://fosuta.org/pics/old_stats_2.png
https://fosuta.org/pics/new_stats_3.png

Since it there a no breaking changes, it would be nice if it could
be part of b20. Assumed you agree with the changes.
-- 
Your team Widelands Developers is requested to review the proposed merge of 
lp:~widelands-dev/widelands/cleanup-statistics-plotter into lp:widelands.
=== modified file 'src/wui/general_statistics_menu.cc'
--- src/wui/general_statistics_menu.cc	2019-02-23 11:00:49 +
+++ src/wui/general_statistics_menu.cc	2019-03-26 22:42:04 +
@@ -42,7 +42,7 @@
 
 using namespace Widelands;
 
-#define PLOT_HEIGHT 130
+#define PLOT_HEIGHT 145
 #define NR_BASE_DATASETS 11
 
 GeneralStatisticsMenu::GeneralStatisticsMenu(InteractiveGameBase& parent,

=== modified file 'src/wui/plot_area.cc'
--- src/wui/plot_area.cc	2019-02-23 11:00:49 +
+++ src/wui/plot_area.cc	2019-03-26 22:42:04 +
@@ -245,7 +245,7 @@
 	   kAxisLineColor, kAxisLinesWidth);
 
 	//  Y Axis
-	dst.draw_line_strip({Vector2f(inner_w - kSpaceRight, kSpacing),
+	dst.draw_line_strip({Vector2f(inner_w - kSpaceRight, kSpacing * 3),
 	 Vector2f(inner_w - kSpaceRight, inner_h - kSpaceBottom)},
 	kAxisLineColor, kAxisLinesWidth);
 	//  No Arrow here, since this doesn't continue.
@@ -260,7 +260,7 @@
 
 		// The space at the end is intentional to have the tick centered
 		// over the number, not to the left
-		if (how_many_ticks != 0) {
+		if (how_many_ticks != 0 && i != 0) {
 			std::shared_ptr xtick = UI::g_fh->render(
 			   xtick_text_style((boost::format("-%u ") % (max_x / how_many_ticks * i)).str()));
 			Vector2i pos(posx, inner_h - kSpaceBottom + 10);
@@ -271,13 +271,29 @@
 		posx -= sub;
 	}
 
-	//  draw yticks, one at full, one at half
-	dst.draw_line_strip(
-	   {Vector2f(inner_w - kSpaceRight, kSpacing), Vector2f(inner_w - kSpaceRight - 3, kSpacing)},
-	   kAxisLineColor, kAxisLinesWidth);
-	dst.draw_line_strip(
-	   {Vector2f(inner_w - kSpaceRight, kSpacing + ((inner_h - kSpaceBottom) - kSpacing) / 2),
-	Vector2f(inner_w - kSpaceRight - 3, kSpacing + ((inner_h - kSpaceBottom) - kSpacing) / 2)},
+	//  draw yticks, one at full, one at three-quarter, one at half, one at quarter & 0
+	dst.draw_line_strip(
+	   {Vector2f(inner_w - kSpaceRight + 3 , kSpacing * 3), Vector2f(inner_w - kSpaceRight - 3, kSpacing * 3)},
+	   kAxisLineColor, kAxisLinesWidth);
+
+	dst.draw_line_strip(
+	   {Vector2f(inner_w - kSpaceRight + 2, kSpacing * 3 + inner_h - kSpaceBottom) + kSpacing * 3) / 2) - kSpacing * 3) / 2),
+	Vector2f(inner_w - kSpaceRight, kSpacing * 3 + inner_h - kSpaceBottom) + kSpacing * 3) / 2) - kSpacing * 3) / 2)},
+	   kAxisLineColor, kAxisLinesWidth);
+
+	dst.draw_line_strip(
+	   {Vector2f(inner_w - kSpaceRight + 3, ((inner_h - kSpaceBottom) + kSpacing * 3) / 2),
+	Vector2f(inner_w - kSpaceRight, ((inner_h - kSpaceBottom) + kSpacing * 3) / 2)},
+	   kAxisLineColor, kAxisLinesWidth);
+
+	dst.draw_line_strip(
+	   {Vector2f(inner_w - kSpaceRight + 2, inner_h - kSpaceBottom - (inner_h - kSpaceBottom - ((inner_h - kSpaceBottom) + kSpacing * 3) / 2) / 2),
+	Vector2f(inner_w - kSpaceRight, inner_h - kSpaceBottom - (inner_h - kSpaceBottom - ((inner_h - kSpaceBottom) + kSpacing * 3) / 2) / 2)},
+	   kAxisLineColor, kAxisLinesWidth);
+
+	dst.draw_line_strip(
+	   {Vector2f(inner_w - kSpaceRight + 3, inner_h - kSpaceBottom),
+	Vector2f(inner_w - kSpaceRight, inner_h - kSpaceBottom)},
 	   kAxisLineColor, kAxisLinesWidth);
 
 	//  print the used unit
@@ -303,7 +319,7 @@
  needs_update_(true),
  lastupdate_(0),
  xline_length_(get_inner_w() - kSpaceRight - kSpacing),
- yline_length_(get_inner_h() - kSpaceBottom - kSpacing),
+ yline_length_(get_inner_h() - kSpaceBottom - kSpacing * 3),
  time_ms_(0),
  highest_scale_(0),
  sub_(0),
@@ -463,6 +479,9 @@
 	dst.tile(Recti(Vector2i::zero(), get_inner_w(), get_inner_h()), g_gr->images().get(BG_PIC),
 	 Vector2i::zero());
 	draw_plot(dst, get_inner_h() - kSpaceBottom, std::to_string(highest_scale_), highest_scale_);
+	// Print the 0
+	draw_value((boost::format("%u") % (0)).str(), RGBColor(255, 0, 0),
+	   Vector2i(get_inner_w() - kSpaceRi

[Widelands-dev] [Merge] lp:~widelands-dev/widelands/ferry into lp:widelands

2019-03-26 Thread bunnybot
Continuous integration builds have changed state:

Travis build 4653. State: passed. Details: 
https://travis-ci.org/widelands/widelands/builds/511594641.
Appveyor build 4440. State: success. Details: 
https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_ferry-4440.
-- 
https://code.launchpad.net/~widelands-dev/widelands/ferry/+merge/351880
Your team Widelands Developers is requested to review the proposed merge of 
lp:~widelands-dev/widelands/ferry into lp:widelands.

___
Mailing list: https://launchpad.net/~widelands-dev
Post to : widelands-dev@lists.launchpad.net
Unsubscribe : https://launchpad.net/~widelands-dev
More help   : https://help.launchpad.net/ListHelp


[Widelands-dev] [Merge] lp:~widelands-dev/widelands/cleanup-statistics-plotter into lp:widelands

2019-03-26 Thread bunnybot
Continuous integration builds have changed state:

Travis build 4654. State: errored. Details: 
https://travis-ci.org/widelands/widelands/builds/511761507.
Appveyor build 4441. State: success. Details: 
https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_cleanup_statistics_plotter-4441.
-- 
https://code.launchpad.net/~widelands-dev/widelands/cleanup-statistics-plotter/+merge/365138
Your team Widelands Developers is requested to review the proposed merge of 
lp:~widelands-dev/widelands/cleanup-statistics-plotter into lp:widelands.

___
Mailing list: https://launchpad.net/~widelands-dev
Post to : widelands-dev@lists.launchpad.net
Unsubscribe : https://launchpad.net/~widelands-dev
More help   : https://help.launchpad.net/ListHelp