diff --git a/src/d_deh.c b/src/d_deh.c index c3334e6dd..8568257ec 100644 --- a/src/d_deh.c +++ b/src/d_deh.c @@ -1503,6 +1503,8 @@ char *deh_weapon[] = // mbf21 "Ammo per shot", // .ammopershot "MBF21 Bits", // .flags + // id24 + "Carousel icon", // .carouselicon }; // CHEATS - Dehacked block name = "Cheat" @@ -2566,7 +2568,20 @@ void deh_procWeapon(DEHFILE *fpin, FILE* fpout, char *line) weaponinfo[indexnum].flags = value; } - else + else + if (!strcasecmp(key, deh_weapon[8])) // Carousel icon + { + char candidate[9] = {0}; + M_CopyLumpName(candidate, ptr_lstrip(strval)); + int len = strlen(candidate); + if (len < 1 || len > 7) + { + if (fpout) fprintf(fpout,"Bad length for carousel icon name '%s'\n",candidate); + continue; + } + weaponinfo[indexnum].carouselicon = M_StringDuplicate(candidate); + } + else if (fpout) fprintf(fpout,"Invalid weapon string index for '%s'\n",key); } return; @@ -3397,7 +3412,7 @@ void rstrip(char *s) // strip trailing whitespace // char *ptr_lstrip(char *p) // point past leading whitespace { - while (*p >= 0 && isspace(*p)) + while (*p && isspace(*p)) p++; return p; } diff --git a/src/d_items.h b/src/d_items.h index a120a69b9..b53624806 100644 --- a/src/d_items.h +++ b/src/d_items.h @@ -59,6 +59,7 @@ typedef struct int flags; // id24 int slot; + const char *carouselicon; } weaponinfo_t; extern weaponinfo_t weaponinfo[NUMWEAPONS+2]; diff --git a/src/st_carousel.c b/src/st_carousel.c index a0fabd5c4..e01522137 100644 --- a/src/st_carousel.c +++ b/src/st_carousel.c @@ -13,6 +13,7 @@ #include +#include "d_items.h" #include "d_player.h" #include "doomdef.h" #include "doomtype.h" @@ -164,8 +165,17 @@ void ST_UpdateCarousel(player_t *player) static void DrawIcon(int x, int y, sbarelem_t *elem, weapon_icon_t icon) { char lump[9] = {0}; - M_snprintf(lump, sizeof(lump), "%s%d", names[icon.weapon], - icon.state == wpi_selected); + const char *name; + if (weaponinfo[icon.weapon].carouselicon) + { + name = weaponinfo[icon.weapon].carouselicon; + } + else + { + name = names[icon.weapon]; + } + + M_snprintf(lump, sizeof(lump), "%s%d", name, icon.state == wpi_selected); patch_t *patch = V_CachePatchName(lump, PU_CACHE);