wc: fix #9012 error when deserter list is empty (#9094)

we no longer show the deserter option if no deserters are avilable
This commit is contained in:
gfgtdf 2024-07-16 22:31:57 +02:00 committed by GitHub
parent 2660c0e086
commit abb79ab055
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -73,7 +73,7 @@ function wc2_show_invest_dialog_impl(dialog_args)
if show_heroes then
local node = root_node:add_invest_category(_ "Heroes")
if available_commanders then
if available_commanders and #available_commanders > 0 then
local desc = _ "Commanders will take your leaders place when the leader dies, possible commanders:"
for j,v in ipairs(available_commanders) do
desc = desc .. "\n" .. wesnoth.unit_types[v].name
@ -98,7 +98,7 @@ function wc2_show_invest_dialog_impl(dialog_args)
}
page.unit_info.unit = unit_type
end
if available_deserters then
if available_deserters and #available_deserters > 0 then
local desc = "<b>" .. _ "possible units:" .. "</b>"
for j,v in ipairs(available_deserters) do
desc = desc .. "\n" .. wesnoth.unit_types[v].name