widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #15421
[Merge] lp:~widelands-dev/widelands/bug-1802629-territorial-crash into lp:widelands
GunChleoc has proposed merging lp:~widelands-dev/widelands/bug-1802629-territorial-crash into lp:widelands.
Commit message:
In territorial win conditions, remember the winning player's name in case the player got defeated a few milliseconds before the name is queried. More checks for defeated player.
Requested reviews:
Widelands Developers (widelands-dev)
Related bugs:
Bug #1802629 in widelands: "crash on terratorial win"
https://bugs.launchpad.net/widelands/+bug/1802629
For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/bug-1802629-territorial-crash/+merge/359227
--
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-1802629-territorial-crash into lp:widelands.
=== modified file 'data/scripting/win_conditions/territorial_functions.lua'
--- data/scripting/win_conditions/territorial_functions.lua 2018-10-16 06:53:20 +0000
+++ data/scripting/win_conditions/territorial_functions.lua 2018-11-23 08:52:32 +0000
@@ -86,6 +86,8 @@
-- last_winning_team = -1,
-- -- The currently winning player, if any. -1 means that no player is currently winning.
-- last_winning_player = -1,
+-- -- The name of the currently winning player, if any. Empty means that no player is currently winning.
+-- last_winning_player_name = "",
-- -- Remaining time in secs for victory by > 50% territory. Default value is also used to calculate whether to send a report to players.
-- remaining_time = 10,
-- -- Points by player
@@ -98,6 +100,9 @@
-- TODO(GunChleoc): We want to be able to list multiple winners in case of a draw.
last_winning_team = -1,
last_winning_player = -1,
+ -- 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,
all_player_points = {},
points = {}
@@ -140,6 +145,7 @@
winning_teams[teaminfo.team] = true
territory_points.last_winning_team = teaminfo.team
territory_points.last_winning_player = -1
+ territory_points.last_winning_player_name = ""
else
winning_teams[teaminfo.team] = nil
end
@@ -150,6 +156,7 @@
territory_was_kept = winning_players[playerinfo.number] ~= nil
winning_players[playerinfo.number] = true
territory_points.last_winning_player = playerinfo.number
+ territory_points.last_winning_player_name = players[playerinfo.number].name
territory_points.last_winning_team = -1
else
winning_players[playerinfo.number] = nil
@@ -248,7 +255,7 @@
if territory_points.last_winning_team >= 0 then
winner_name = team_str:format(territory_points.last_winning_team)
elseif territory_points.last_winning_player >= 0 then
- winner_name = players[territory_points.last_winning_player].name
+ winner_name = territory_points.last_winning_player_name
end
local remaining_minutes = math.max(0, math.floor(territory_points.remaining_time / 60))
=== modified file 'data/scripting/win_conditions/territorial_lord.lua'
--- data/scripting/win_conditions/territorial_lord.lua 2018-09-28 18:05:24 +0000
+++ data/scripting/win_conditions/territorial_lord.lua 2018-11-23 08:52:32 +0000
@@ -42,6 +42,8 @@
local function _send_state()
set_textdomain("win_conditions")
+ check_player_defeated(plrs, lost_game.title, lost_game.body, wc_descname, wc_version)
+
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
=== modified file 'data/scripting/win_conditions/territorial_time.lua'
--- data/scripting/win_conditions/territorial_time.lua 2018-09-28 18:05:24 +0000
+++ data/scripting/win_conditions/territorial_time.lua 2018-11-23 08:52:32 +0000
@@ -46,6 +46,8 @@
local function _send_state()
set_textdomain("win_conditions")
+ check_player_defeated(plrs, lost_game.title, lost_game.body, wc_descname, wc_version)
+
local remaining_max_minutes = remaining_max_time // 60
for idx, player in ipairs(plrs) do
local msg = ""
Follow ups
-
[Merge] lp:~widelands-dev/widelands/bug-1802629-territorial-crash into lp:widelands
From: noreply, 2018-12-26
-
Re: [Merge] lp:~widelands-dev/widelands/bug-1802629-territorial-crash into lp:widelands
From: Toni Förster, 2018-12-26
-
[Merge] lp:~widelands-dev/widelands/bug-1802629-territorial-crash into lp:widelands
From: bunnybot, 2018-12-26
-
[Merge] lp:~widelands-dev/widelands/bug-1802629-territorial-crash into lp:widelands
From: bunnybot, 2018-12-13
-
[Merge] lp:~widelands-dev/widelands/bug-1802629-territorial-crash into lp:widelands
From: bunnybot, 2018-12-13
-
[Merge] lp:~widelands-dev/widelands/bug-1802629-territorial-crash into lp:widelands
From: GunChleoc, 2018-12-12
-
Re: [Merge] lp:~widelands-dev/widelands/bug-1802629-territorial-crash into lp:widelands
From: GunChleoc, 2018-12-12
-
Re: [Merge] lp:~widelands-dev/widelands/bug-1802629-territorial-crash into lp:widelands
From: hessenfarmer, 2018-12-05
-
Re: [Merge] lp:~widelands-dev/widelands/bug-1802629-territorial-crash into lp:widelands
From: GunChleoc, 2018-12-05
-
Re: [Merge] lp:~widelands-dev/widelands/bug-1802629-territorial-crash into lp:widelands
From: hessenfarmer, 2018-12-03
-
Re: [Merge] lp:~widelands-dev/widelands/bug-1802629-territorial-crash into lp:widelands
From: hessenfarmer, 2018-12-03
-
Re: [Merge] lp:~widelands-dev/widelands/bug-1802629-territorial-crash into lp:widelands
From: hessenfarmer, 2018-11-27
-
Re: [Merge] lp:~widelands-dev/widelands/bug-1802629-territorial-crash into lp:widelands
From: hessenfarmer, 2018-11-26
-
Re: [Merge] lp:~widelands-dev/widelands/bug-1802629-territorial-crash into lp:widelands
From: hessenfarmer, 2018-11-26
-
[Merge] lp:~widelands-dev/widelands/bug-1802629-territorial-crash into lp:widelands
From: GunChleoc, 2018-11-26
-
Re: [Merge] lp:~widelands-dev/widelands/bug-1802629-territorial-crash into lp:widelands
From: GunChleoc, 2018-11-26
-
Re: [Merge] lp:~widelands-dev/widelands/bug-1802629-territorial-crash into lp:widelands
From: hessenfarmer, 2018-11-25
-
[Merge] lp:~widelands-dev/widelands/bug-1802629-territorial-crash into lp:widelands
From: bunnybot, 2018-11-23