Project

General

Profile

Bug #1909 ยป 0057-sdl-Fix-flagless-unit-crash-on-win-chance-display.patch

Marko Lindqvist, 01/17/2026 12:55 PM

View differences:

client/gui-sdl2/dialogs.c
astr_free(&addition);
} else {
int att_chance, def_chance;
fc_snprintf(cbuf , sizeof(cbuf), _("%s %s %s(A:%d D:%d M:%s FP:%d) HP:%d%%"),
nation_adjective_for_player(unit_owner(punit)),
(vetname != NULL ? vetname : ""),
utype_name_translation(punittype),
punittype->attack_strength,
punittype->defense_strength,
move_points_text(punittype->move_rate, FALSE),
punittype->firepower,
(punit->hp * 100 / punittype->hp + 9) / 10);
struct player *owner = unit_owner(punit);
if (owner != nullptr) {
fc_snprintf(cbuf , sizeof(cbuf), _("%s %s %s(A:%d D:%d M:%s FP:%d) HP:%d%%"),
nation_adjective_for_player(owner),
(vetname != NULL ? vetname : ""),
utype_name_translation(punittype),
punittype->attack_strength,
punittype->defense_strength,
move_points_text(punittype->move_rate, FALSE),
punittype->firepower,
(punit->hp * 100 / punittype->hp + 9) / 10);
} else {
fc_snprintf(cbuf , sizeof(cbuf), _("%s %s(A:%d D:%d M:%s FP:%d) HP:%d%%"),
(vetname != NULL ? vetname : ""),
utype_name_translation(punittype),
punittype->attack_strength,
punittype->defense_strength,
move_points_text(punittype->move_rate, FALSE),
punittype->firepower,
(punit->hp * 100 / punittype->hp + 9) / 10);
}
/* Calculate chance to win */
if (sdl_get_chance_to_win(&att_chance, &def_chance, punit, focus)) {
client/gui-sdl3/dialogs.c
astr_free(&addition);
} else {
int att_chance, def_chance;
fc_snprintf(cbuf , sizeof(cbuf), _("%s %s %s(A:%d D:%d M:%s FP:%d) HP:%d%%"),
nation_adjective_for_player(unit_owner(punit)),
(vetname != NULL ? vetname : ""),
utype_name_translation(punittype),
punittype->attack_strength,
punittype->defense_strength,
move_points_text(punittype->move_rate, FALSE),
punittype->firepower,
(punit->hp * 100 / punittype->hp + 9) / 10);
struct player *owner = unit_owner(punit);
if (owner != nullptr) {
fc_snprintf(cbuf , sizeof(cbuf), _("%s %s %s(A:%d D:%d M:%s FP:%d) HP:%d%%"),
nation_adjective_for_player(owner),
(vetname != NULL ? vetname : ""),
utype_name_translation(punittype),
punittype->attack_strength,
punittype->defense_strength,
move_points_text(punittype->move_rate, FALSE),
punittype->firepower,
(punit->hp * 100 / punittype->hp + 9) / 10);
} else {
fc_snprintf(cbuf , sizeof(cbuf), _("%s %s(A:%d D:%d M:%s FP:%d) HP:%d%%"),
(vetname != NULL ? vetname : ""),
utype_name_translation(punittype),
punittype->attack_strength,
punittype->defense_strength,
move_points_text(punittype->move_rate, FALSE),
punittype->firepower,
(punit->hp * 100 / punittype->hp + 9) / 10);
}
/* Calculate chance to win */
if (sdl_get_chance_to_win(&att_chance, &def_chance, punit, focus)) {
    (1-1/1)