Skip to content

Commit

Permalink
Heretic|HUD: Don't warn about missing resources for unavailable ammo …
Browse files Browse the repository at this point in the history
…types

Some ammo types are unavailable in shareware, so don't attempt to
declare their nonexistent HUD icon patches.
  • Loading branch information
danij-deng committed Apr 14, 2014
1 parent c621c98 commit 215647d
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 14 deletions.
15 changes: 14 additions & 1 deletion doomsday/plugins/heretic/include/doomdef.h
Expand Up @@ -191,7 +191,7 @@ typedef enum {
#define NUMWEAPLEVELS 2 // Number of weapon power levels.

/**
* Ammunition types.
* Ammunition type identifier.
*/
typedef enum {
AT_FIRST,
Expand All @@ -206,6 +206,19 @@ typedef enum {
AT_NOAMMO // Takes no ammo, used for staff, gauntlets.
} ammotype_t;

/**
* Ammunition type definition.
*/
typedef struct {
int gameModeBits; ///< Game modes the ammo type is available in.
char const *hudIcon; ///< Name of the Patch to use in headup displays.
} AmmoDef;

/**
* Returns the AmmoDef for the specified ammunition @a type; otherwise @c 0.
*/
AmmoDef const *P_AmmoDef(ammotype_t type);

/**
* Powers, bestowable upon players only.
*/
Expand Down
18 changes: 18 additions & 0 deletions doomsday/plugins/heretic/src/p_pspr.c
Expand Up @@ -43,6 +43,24 @@
#define WEAPONBOTTOM (128)
#define WEAPONTOP (32)

static AmmoDef ammoDefs[NUM_AMMO_TYPES] = {
/*AT_CRYSTAL*/ { GM_ANY, "INAMGLD" },
/*AT_ARROW*/ { GM_ANY, "INAMBOW" },
/*AT_ORB*/ { GM_ANY, "INAMBST" },
/*AT_RUNE*/ { GM_NOT_SHAREWARE, "INAMRAM" },
/*AT_FIREORB*/ { GM_NOT_SHAREWARE, "INAMPNX" },
/*AT_MSPHERE*/ { GM_NOT_SHAREWARE, "INAMLOB" }
};

AmmoDef const *P_AmmoDef(ammotype_t type)
{
if(type >= AT_FIRST && type < AT_FIRST + NUM_AMMO_TYPES)
{
return &ammoDefs[type];
}
return 0; // Not found.
}

/*
AT_CRYSTAL,
AT_ARROW,
Expand Down
21 changes: 8 additions & 13 deletions doomsday/plugins/heretic/src/st_stuff.c
Expand Up @@ -2469,7 +2469,7 @@ void ST_loadGraphics(void)

// Inventory item flash anim.
{
const char invItemFlashAnim[5][9] = {
char const invItemFlashAnim[5][9] = {
{"USEARTIA"},
{"USEARTIB"},
{"USEARTIC"},
Expand All @@ -2484,20 +2484,15 @@ void ST_loadGraphics(void)
}

// Ammo icons.
{
const char ammoPic[NUM_AMMO_TYPES][9] = {
{"INAMGLD"},
{"INAMBOW"},
{"INAMBST"},
{"INAMRAM"},
{"INAMPNX"},
{"INAMLOB"}
};

memset(pAmmoIcons, 0, sizeof(pAmmoIcons));
for(i = 0; i < NUM_AMMO_TYPES; ++i)
{
pAmmoIcons[i] = R_DeclarePatch(ammoPic[i]);
}
AmmoDef const *def = P_AmmoDef((ammotype_t)i);
// Available in the current game mode?
if(def->gameModeBits & gameModeBits)
{
pAmmoIcons[i] = R_DeclarePatch(def->hudIcon);
}
}

// Key cards.
Expand Down

0 comments on commit 215647d

Please sign in to comment.