aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Del Campo Romero <xavi.dcr@tutanota.com>2022-06-26 23:39:46 +0200
committerXavier Del Campo Romero <xavi.dcr@tutanota.com>2022-06-26 23:42:34 +0200
commit7196c6a0cc89ea3683e67ee34b90dbadb69aebfe (patch)
tree39c692974f6a20e732d73b05c03d701de1774688
parentafc554167ea215ab10fa079e4ef541c45da1f867 (diff)
Fix hp bar not being displayed when carrying
-rw-r--r--src/player/src/human_player_gui.c13
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);
}
}