Lookup tables for mapping inventory item indexes to icons (and vice versa). DONT_BUILD.

git-svn-id: https://svn.eduke32.com/eduke32@5696 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2016-04-13 04:03:55 +00:00
parent f93e06ffd4
commit 552c88b879
3 changed files with 29 additions and 76 deletions

View file

@ -3504,32 +3504,24 @@ nullquote:
case CON_ADDINVENTORY:
{
insptr += 2;
switch (*(insptr-1))
int const item = *(insptr-1);
switch (item)
{
case GET_STEROIDS:
ps->inv_amount[GET_STEROIDS] = *insptr;
ps->inven_icon = ICON_STEROIDS;
case GET_SCUBA:
case GET_HOLODUKE:
case GET_JETPACK:
case GET_HEATS:
case GET_FIRSTAID:
case GET_BOOTS:
ps->inven_icon = inv_to_icon[item];
ps->inv_amount[item] = *insptr;
break;
case GET_SHIELD:
ps->inv_amount[GET_SHIELD] += *insptr;// 100;
if (ps->inv_amount[GET_SHIELD] > ps->max_shield_amount)
ps->inv_amount[GET_SHIELD] = ps->max_shield_amount;
break;
case GET_SCUBA:
ps->inv_amount[GET_SCUBA] = *insptr;// 1600;
ps->inven_icon = ICON_SCUBA;
break;
case GET_HOLODUKE:
ps->inv_amount[GET_HOLODUKE] = *insptr;// 1600;
ps->inven_icon = ICON_HOLODUKE;
break;
case GET_JETPACK:
ps->inv_amount[GET_JETPACK] = *insptr;// 1600;
ps->inven_icon = ICON_JETPACK;
ps->inv_amount[GET_SHIELD] = max(ps->inv_amount[GET_SHIELD] + *insptr, ps->max_shield_amount);
break;
case GET_ACCESS:
@ -3547,22 +3539,8 @@ nullquote:
}
break;
case GET_HEATS:
ps->inv_amount[GET_HEATS] = *insptr;
ps->inven_icon = ICON_HEATS;
break;
case GET_FIRSTAID:
ps->inven_icon = ICON_FIRSTAID;
ps->inv_amount[GET_FIRSTAID] = *insptr;
break;
case GET_BOOTS:
ps->inven_icon = ICON_BOOTS;
ps->inv_amount[GET_BOOTS] = *insptr;
break;
default:
CON_ERRPRINTF("Invalid inventory ID %d\n", (int32_t)*(insptr-1));
CON_ERRPRINTF("Invalid inventory ID %d\n", item);
break;
}
insptr++;

View file

@ -50,6 +50,12 @@ enum dukeinvicon_t {
ICON_MAX
};
static int const icon_to_inv[ICON_MAX] = { GET_FIRSTAID, GET_FIRSTAID, GET_STEROIDS, GET_HOLODUKE,
GET_JETPACK, GET_HEATS, GET_SCUBA, GET_BOOTS };
static int const inv_to_icon[GET_MAX] = { ICON_STEROIDS, ICON_NONE, ICON_SCUBA, ICON_HOLODUKE, ICON_JETPACK, ICON_NONE,
ICON_NONE, ICON_HEATS, ICON_NONE, ICON_FIRSTAID, ICON_BOOTS };
enum dukeweapon_t {
KNEE_WEAPON, // 0
PISTOL_WEAPON,

View file

@ -2478,21 +2478,11 @@ void P_HandleSharedKeys(int32_t snum)
{
switch (p->inven_icon)
{
case ICON_JETPACK:
sb_snum |= BIT(SK_JETPACK);
break;
case ICON_HOLODUKE:
sb_snum |= BIT(SK_HOLODUKE);
break;
case ICON_HEATS:
sb_snum |= BIT(SK_NIGHTVISION);
break;
case ICON_FIRSTAID:
sb_snum |= BIT(SK_MEDKIT);
break;
case ICON_STEROIDS:
sb_snum |= BIT(SK_STEROIDS);
break;
case ICON_JETPACK: sb_snum |= BIT(SK_JETPACK); break;
case ICON_HOLODUKE: sb_snum |= BIT(SK_HOLODUKE); break;
case ICON_HEATS: sb_snum |= BIT(SK_NIGHTVISION); break;
case ICON_FIRSTAID: sb_snum |= BIT(SK_MEDKIT); break;
case ICON_STEROIDS: sb_snum |= BIT(SK_STEROIDS); break;
}
}
}
@ -2532,11 +2522,10 @@ void P_HandleSharedKeys(int32_t snum)
{
p->invdisptime = GAMETICSPERSEC*2;
if (TEST_SYNC_KEY(sb_snum, SK_INV_RIGHT)) k = 1;
else k = 0;
int32_t k = !!(TEST_SYNC_KEY(sb_snum, SK_INV_RIGHT));
if (p->refresh_inventory) p->refresh_inventory = 0;
dainv = p->inven_icon;
int32_t dainv = p->inven_icon;
i = 0;
@ -2548,25 +2537,11 @@ CHECKINV1:
switch (dainv)
{
case ICON_JETPACK:
if (p->inv_amount[GET_JETPACK] > 0 && i > 1)
break;
if (k) dainv++;
else dainv--;
goto CHECKINV1;
case ICON_SCUBA:
if (p->inv_amount[GET_SCUBA] > 0 && i > 1)
break;
if (k) dainv++;
else dainv--;
goto CHECKINV1;
case ICON_STEROIDS:
if (p->inv_amount[GET_STEROIDS] > 0 && i > 1)
break;
if (k) dainv++;
else dainv--;
goto CHECKINV1;
case ICON_HOLODUKE:
if (p->inv_amount[GET_HOLODUKE] > 0 && i > 1)
case ICON_HEATS:
if (p->inv_amount[icon_to_inv[dainv]] > 0 && i > 1)
break;
if (k) dainv++;
else dainv--;
@ -2578,12 +2553,6 @@ CHECKINV1:
if (k) dainv = 2;
else dainv = 7;
goto CHECKINV1;
case ICON_HEATS:
if (p->inv_amount[GET_HEATS] > 0 && i > 1)
break;
if (k) dainv++;
else dainv--;
goto CHECKINV1;
case ICON_BOOTS:
if (p->inv_amount[GET_BOOTS] > 0 && i > 1)
break;