From 45c388b1f1751d95d79a3d68bf0b9a18d4f1c270 Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 24 Sep 2022 02:47:52 -0700 Subject: [PATCH] Fix HUD drawing crash if 1 or more KITEM_NONE blame 375fb72de --- src/k_hud.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/k_hud.c b/src/k_hud.c index 9608a8fa6..88fab4921 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -612,7 +612,7 @@ const char *K_GetItemPatch(UINT8 item, boolean tiny) } } -static patch_t **K_GetItemPatchTable(INT32 item) +static patch_t *K_GetCachedItemPatch(INT32 item, UINT8 offset) { patch_t **kp[1 + NUMKARTITEMS] = { kp_sadface, @@ -640,8 +640,8 @@ static patch_t **K_GetItemPatchTable(INT32 item) kp_droptarget, }; - if (item >= KITEM_SAD && item < NUMKARTITEMS) - return kp[item - KITEM_SAD]; + if (item == KITEM_SAD || (item > KITEM_NONE && item < NUMKARTITEMS)) + return kp[item - KITEM_SAD][offset]; else return NULL; } @@ -950,7 +950,7 @@ static void K_drawKartItem(void) localpatch = localinv; break; default: - localpatch = K_GetItemPatchTable(item)[offset]; + localpatch = K_GetCachedItemPatch(item, offset); } } else @@ -1044,7 +1044,7 @@ static void K_drawKartItem(void) /*FALLTHRU*/ default: - localpatch = K_GetItemPatchTable(stplyr->itemtype)[offset]; + localpatch = K_GetCachedItemPatch(stplyr->itemtype, offset); if (localpatch == NULL) localpatch = kp_nodraw; // diagnose underflows