Merge lp:~widelands-dev/widelands/bug-1815283-nil-value-territorial into lp:widelands

Proposed by Toni Förster
Status: Merged
Merged at revision: 8982
Proposed branch: lp:~widelands-dev/widelands/bug-1815283-nil-value-territorial
Merge into: lp:widelands
Diff against target: 41 lines (+4/-4)
2 files modified
data/scripting/win_conditions/territorial_functions.lua (+2/-2)
data/scripting/win_conditions/win_condition_functions.lua (+2/-2)
To merge this branch: bzr merge lp:~widelands-dev/widelands/bug-1815283-nil-value-territorial
Reviewer Review Type Date Requested Status
GunChleoc Approve
Review via email: mp+363079@code.launchpad.net

Commit message

add player name to rank_players()

To post a comment you must log in.
Revision history for this message
kaputtnik (franku) wrote :

I looked also into this issue and stumbled over player.number and the description of players: https://wl.widelands.org/documentation/autogen_wl_bases/#wl.bases.EditorGameBase.players

So, assuming the second slot of a three players map is deactivated, the result will be:

for idx, player in ipairs(wl.Game().players) do
  print(idx, player.name, player.number)
end

Output:

1 Player 1 1
2 Player 3 3

So i am not sure if we should get rid of player.number at all? Don't know if it is feasible.

Revision history for this message
GunChleoc (gunchleoc) wrote :

I had the same bug when I did my refactoring of the territorial win conditions last year... which led me to my new forum sig :P

@bunnybot merge

review: Approve
Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 4464. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/492316621.
Appveyor build 4252. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_1815283_nil_value_territorial-4252.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'data/scripting/win_conditions/territorial_functions.lua'
2--- data/scripting/win_conditions/territorial_functions.lua 2019-01-02 13:47:23 +0000
3+++ data/scripting/win_conditions/territorial_functions.lua 2019-02-12 17:47:26 +0000
4@@ -153,13 +153,13 @@
5 territory_was_kept = winning_players[playerinfo.number] ~= nil
6 winning_players[playerinfo.number] = true
7 territory_points.last_winning_player = playerinfo.number
8- territory_points.last_winning_player_name = players[playerinfo.number].name
9+ territory_points.last_winning_player_name = playerinfo.name
10 territory_points.last_winning_team = -1
11 else
12 winning_players[playerinfo.number] = nil
13 end
14 if teaminfo.team == 0 then
15- points[#points + 1] = { players[playerinfo.number].name, playerinfo.points }
16+ points[#points + 1] = { playerinfo.name, playerinfo.points }
17 end
18 end
19 end
20
21=== modified file 'data/scripting/win_conditions/win_condition_functions.lua'
22--- data/scripting/win_conditions/win_condition_functions.lua 2019-02-10 11:36:10 +0000
23+++ data/scripting/win_conditions/win_condition_functions.lua 2019-02-12 17:47:26 +0000
24@@ -200,7 +200,7 @@
25 team = 0,
26 points = player_points,
27 players = {
28- { number = player.number, points = player_points }
29+ { number = player.number, name = player.name, points = player_points }
30 }
31 }
32 table.insert(ranked_players_and_teams, team_table)
33@@ -222,7 +222,7 @@
34 }
35 for idx, player in ipairs(plrs) do
36 if player.team == team then
37- table.insert(team_table.players, { number = player.number, points = all_player_points[player.number] })
38+ table.insert(team_table.players, { number = player.number, name = player.name, points = all_player_points[player.number] })
39 end
40 end
41 table.insert(ranked_players_and_teams, team_table)

Subscribers

People subscribed via source and target branches

to status/vote changes: