render: perform proper null checks for item_get_name()
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I007a86584f618f990f7a5ed569115aeb6a6a6964
This commit is contained in:
parent
6281c756a8
commit
6050083293
1 changed files with 6 additions and 4 deletions
10
src/render.c
10
src/render.c
|
|
@ -373,10 +373,12 @@ void render_inventory_overlay(const Player *p, int selected) {
|
||||||
|
|
||||||
// Item name
|
// Item name
|
||||||
const char *name = item_get_name(item);
|
const char *name = item_get_name(item);
|
||||||
Color name_color = (item->type == ITEM_POTION) ? (Color){255, 140, 140, 255}
|
if (name) {
|
||||||
: (item->type == ITEM_WEAPON) ? (Color){255, 255, 140, 255}
|
Color name_color = (item->type == ITEM_POTION) ? (Color){255, 140, 140, 255}
|
||||||
: (Color){140, 140, 255, 255};
|
: (item->type == ITEM_WEAPON) ? (Color){255, 255, 140, 255}
|
||||||
DrawText(name, overlay.x + 45, y_pos + 4, 14, name_color);
|
: (Color){140, 140, 255, 255};
|
||||||
|
DrawText(name, overlay.x + 45, y_pos + 4, 14, name_color);
|
||||||
|
}
|
||||||
|
|
||||||
// Power
|
// Power
|
||||||
snprintf(slot_text, sizeof(slot_text), "+%d", item->power);
|
snprintf(slot_text, sizeof(slot_text), "+%d", item->power);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue