From 42c6f4fe92e60bda2f1d274cf81fd4b80652b009 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 86d37c62a..9f14d882a 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -695,7 +695,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, @@ -723,8 +723,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; } @@ -1146,7 +1146,7 @@ static void K_drawKartItem(void) break; default: - localpatch = K_GetItemPatchTable(item)[offset]; + localpatch = K_GetCachedItemPatch(item, offset); } } else @@ -1224,7 +1224,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