~widelands-dev/widelands/bug-1796364-blinking-buildings

« back to all changes in this revision

Viewing changes to data/scripting/win_conditions/territorial_time.lua

Merged lp:~widelands-dev/widelands/bug-1802629-territorial-crash:
In territorial win conditions, check if player still exists before making it the winning player. Player will also win if there are no other players left.

Show diffs side-by-side

added added

removed removed

Lines of Context:
78
78
         sleep(30000)
79
79
 
80
80
         remaining_max_time = remaining_max_time - 30
81
 
 
 
81
         -- A player might have been defeated since the last calculation
 
82
         check_player_defeated(plrs, lost_game.title, lost_game.body)
82
83
         -- Check if a player or team is a candidate and update variables
83
84
         -- Returns the names and points for the teams and players without a team
84
 
         calculate_territory_points(fields, plrs, wc_descname, wc_version)
 
85
         calculate_territory_points(fields, wl.Game().players)
85
86
 
86
87
         -- Game is over, do stuff after loop
87
 
         if territory_points.remaining_time <= 0 or remaining_max_time <= 0 then break end
 
88
         if territory_points.remaining_time <= 0 or remaining_max_time <= 0 or count_factions(plrs) <= 1 then break end
88
89
 
89
90
         -- at the beginning send remaining max time message only each 30 minutes
90
91
         -- if only 30 minutes or less are left, send each 5 minutes
97
98
      end
98
99
 
99
100
      -- Game has ended
100
 
      territory_game_over(fields, plrs, wc_descname, wc_version)
 
101
      territory_game_over(fields, wl.Game().players, wc_descname, wc_version)
101
102
   end
102
103
}