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

2019-01-30 Thread Toni Förster
Toni Förster has proposed merging 
lp:~widelands-dev/widelands/territorial_unify_notifications into lp:widelands 
with lp:~widelands-dev/widelands/collectors_notification as a prerequisite.

Commit message:
- Notifications for Territorial are unified.
- Notifications are properly formatted (hour and minute)
- remaining time notifications and winning/losing status
  notifications are not mixed up any more
- new string added to territorial_lord
- string removed from territorial_time

Requested reviews:
  Widelands Developers (widelands-dev)

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

Further details are here: https://wl.widelands.org/forum/post/26905/
-- 
Your team Widelands Developers is requested to review the proposed merge of 
lp:~widelands-dev/widelands/territorial_unify_notifications into lp:widelands.
=== modified file 'data/scripting/win_conditions/collectors.lua'
--- data/scripting/win_conditions/collectors.lua	2019-01-30 23:12:08 +
+++ data/scripting/win_conditions/collectors.lua	2019-01-30 23:12:09 +
@@ -170,7 +170,7 @@
 .. h2(ngettext("Team Total: %i point", "Team Total: %i points", points)):format(points)
  msg = msg .. vspace(8) .. message
   end
-  
+
   broadcast(plrs, game_status.title, msg, {popup = show_popup})
end
 

=== modified file 'data/scripting/win_conditions/territorial_functions.lua'
--- data/scripting/win_conditions/territorial_functions.lua	2018-12-03 20:30:01 +
+++ data/scripting/win_conditions/territorial_functions.lua	2019-01-30 23:12:09 +
@@ -103,7 +103,7 @@
-- We record the last winning player name here to prevent crashes with retrieving
-- the player name when the player was just defeated a few ms ago
last_winning_player_name = "",
-   remaining_time = 10,
+   remaining_time = 1201,
all_player_points = {},
points = {}
 }
@@ -167,10 +167,15 @@
-- Set the remaining time according to whether the winner is still the same
if territory_was_kept then
   -- Still the same winner
-  territory_points.remaining_time = territory_points.remaining_time - 30
+  territory_points.remaining_time = territory_points.remaining_time - 1
elseif winning_points == -1 then
   -- No winner. This value is used to calculate whether to send a report to players.
-  territory_points.remaining_time = 10
+  if territory_points.remaining_time == 1800 then
+ territory_points.remaining_time = 1201
+  elseif territory_points.remaining_time ~= 1201 then
+ territory_points.remaining_time = 1800
+  end
+  
else
   -- Winner changed
   territory_points.remaining_time = 20 * 60 -- 20 minutes

=== modified file 'data/scripting/win_conditions/territorial_lord.lua'
--- data/scripting/win_conditions/territorial_lord.lua	2018-12-03 20:30:01 +
+++ data/scripting/win_conditions/territorial_lord.lua	2019-01-30 23:12:09 +
@@ -39,25 +39,30 @@
   -- Get all valueable fields of the map
   local fields = get_buildable_fields()
 
-  local function _send_state()
+  local function _send_state(show_popup)
  set_textdomain("win_conditions")
 
  for idx, player in ipairs(plrs) do
 local msg = ""
-if territory_points.last_winning_team == player.team or territory_points.last_winning_player == player.number then
-   msg = msg .. winning_status_header() .. vspace(8)
+if (territory_points.last_winning_team >= 0 or territory_points.last_winning_player >= 0) then
+   if territory_points.last_winning_team == player.team or territory_points.last_winning_player == player.number then
+  msg = msg .. winning_status_header()
+   else
+  msg = msg .. losing_status_header(plrs)
+   end
 else
-   msg = msg .. losing_status_header(plrs) .. vspace(8)
-end
-msg = msg .. vspace(8) .. game_status.body .. territory_status(fields, "has")
- send_message(player, game_status.title, msg, {popup = true})
+   msg = p(_"Currently no faction owns more than half of the map’s area.")
+end
+   msg = msg .. vspace(8) .. game_status.body .. territory_status(fields, "has")
+   player:send_message(game_status.title, msg, {popup = show_popup})
+end
  end
   end
 
   -- here is the main loop!!!
-  while true do
- -- Sleep 30 seconds == STATISTICS_SAMPLE_TIME
- sleep(3)
+  while count_factions(plrs) > 1 or territory_points.remaining_time > 0 do
+ -- Sleep 1 second
+ sleep(1000)
 
  -- A player might have been defeated since the last calculation
  check_player_defeated(plrs, lost_game.title, lost_game.body)
@@ -65,16 +70,15 @@
  -- Check if a player or team is a candidate and update variables
  

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

2019-01-30 Thread Toni Förster
The proposal to merge 
lp:~widelands-dev/widelands/territorial_unify_notifications into lp:widelands 
has been updated.

Commit message changed to:

- Notifications for Territorial are unified.
- Notifications are properly formatted (hour and minute)
- remaining time notifications and winning/losing status
  notifications are not mixed up any more
- new string added to territorial_lord
- string removed from territorial_time

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/territorial_unify_notifications/+merge/362502
-- 
Your team Widelands Developers is requested to review the proposed merge of 
lp:~widelands-dev/widelands/territorial_unify_notifications 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


Re: [Widelands-dev] [Merge] lp:~widelands-dev/widelands/bug-1811583-desync-with-territorial into lp:widelands

2019-01-30 Thread Notabilis
Sorry for the late response. Currently, these functions are indeed called for 
all players in parallel within the win condition scripts. But if this would 
change for whichever reason, the game would desync. A point where this happened 
are the functions within ui.lua which call the sleep() function in 
coroutines.lua for only some players. It could happen that a similar construct 
is created at some time in the future again.
I think the comment in coroutines.lua should be something like:

Do not use these functions in multiplayer scripting (scenarios and
winconditions) for only some players of a game. Make sure they are
called for none or all players in parallel, otherwise the games will
desynchronize.
-- 
https://code.launchpad.net/~widelands-dev/widelands/bug-1811583-desync-with-territorial/+merge/362272
Your team Widelands Developers is subscribed to branch 
lp:~widelands-dev/widelands/bug-1811583-desync-with-territorial.

___
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


Re: [Widelands-dev] [Merge] lp:~widelands-dev/widelands/bug-1811583-desync-with-territorial into lp:widelands

2019-01-30 Thread Klaus Halfmann
Review: Approve compile, testplay

We played this to the End on a 3vs3 Game on some 
large Map and had no problems whatsover.

This way I finally learned Tonis game-name.

Traviss had an error with apt.llvm.org port one build only.

@bunnbot merge
-- 
https://code.launchpad.net/~widelands-dev/widelands/bug-1811583-desync-with-territorial/+merge/362272
Your team Widelands Developers is subscribed to branch 
lp:~widelands-dev/widelands/bug-1811583-desync-with-territorial.

___
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