diff options
| author | Xavier Del Campo Romero <xavi.dcr@tutanota.com> | 2022-06-26 23:39:46 +0200 |
|---|---|---|
| committer | Xavier Del Campo Romero <xavi.dcr@tutanota.com> | 2022-06-26 23:42:34 +0200 |
| commit | 272fd5381003e6e91a21b6f1c743d7cb11f1fc46 (patch) | |
| tree | 04b212e1d6690ea4a49991a5665fcec01bf016b8 /src | |
| parent | 231bc704ffd5276fb129402f544f47ba249deb03 (diff) | |
| download | jancity-272fd5381003e6e91a21b6f1c743d7cb11f1fc46.tar.gz | |
Fix hp bar not being displayed when carrying
Diffstat (limited to 'src')
| -rw-r--r-- | src/player/src/human_player_gui.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/player/src/human_player_gui.c b/src/player/src/human_player_gui.c index 93228c8..b5caeea 100644 --- a/src/player/src/human_player_gui.c +++ b/src/player/src/human_player_gui.c @@ -143,26 +143,25 @@ static int render_sel_single_unit(const struct human_player *const h, hpl.text = hp_str; gui_add_child(r, &hpl.common); + char c_str[sizeof "255"]; + struct gui_label cl; + if (unit_can_harvest(u)) { const struct unit_harvester *const uh = &u->us.harvester; if (uh->carry) { - char c_str[sizeof "255"]; const int rs = snprintf(c_str, sizeof c_str, "%hhu", uh->carry); - struct gui_label cl; + + if (rs < 0 || rs >= sizeof c_str) + return -1; gui_label_init(&cl); cl.common.x = CARRY_X; cl.common.y = CARRY_Y; cl.text = c_str; gui_add_child(r, &cl.common); - - if (rs < 0 || rs >= sizeof c_str) - return -1; - - return gui_render(r); } } |
