Rewrote parts of HUD_SlotSelect to be no longer recursive.

This commit is contained in:
Marco Cawthorne 2020-04-20 11:47:22 +02:00
parent 2cee375ce5
commit e643ab58a7
5 changed files with 78 additions and 58 deletions

View file

@ -9,7 +9,7 @@ all:
menu: menu:
mkdir -p ../platform/data.pk3dir mkdir -p ../platform/data.pk3dir
$(CC) menu-fn/progs.src $(CC) menu-fn/progs.src
$(CC) menu-vgui/progs.src #$(CC) menu-vgui/progs.src
games: games:
mkdir -p ../valve/data.pk3dir mkdir -p ../valve/data.pk3dir

View file

@ -149,22 +149,23 @@ HUD_SlotSelect(int slot)
} }
} }
} else { } else {
/* increment our current selected weapon by 1 */ int first = -1;
pSeat->m_iHUDWeaponSelected++; for (i = 1; i < g_weapons.length; i++) {
pSeat->m_flHUDWeaponSelectTime = time + 3; if (g_weapons[i].slot == slot && pl.g_items & g_weapons[i].id) {
if (i < pSeat->m_iHUDWeaponSelected && first == -1) {
/* haven't got it. */ first = i;
if (!(pl.g_items & g_weapons[pSeat->m_iHUDWeaponSelected].id)) { } else if (i > pSeat->m_iHUDWeaponSelected) {
HUD_SlotSelect(slot); first = -1;
pSeat->m_iHUDWeaponSelected = i;
pSeat->m_flHUDWeaponSelectTime = time + 3;
break;
}
}
} }
/* reset when out of bounds or outside slot area */ if (first > 0) {
if (pSeat->m_iHUDWeaponSelected >= g_weapons.length) { pSeat->m_iHUDWeaponSelected = first;
pSeat->m_iHUDWeaponSelected = 0; pSeat->m_flHUDWeaponSelectTime = time + 3;
HUD_SlotSelect(slot);
} else if (g_weapons[pSeat->m_iHUDWeaponSelected].slot != slot) {
pSeat->m_iHUDWeaponSelected = 0;
HUD_SlotSelect(slot);
} }
} }
} }

View file

@ -129,6 +129,11 @@ HUD_SlotSelect(int slot)
int curslot = g_weapons[pSeat->m_iHUDWeaponSelected].slot; int curslot = g_weapons[pSeat->m_iHUDWeaponSelected].slot;
int i; int i;
if (g_textmenu != "") {
Textmenu_Input(slot);
return;
}
/* hack to see if we have ANY weapons at all. */ /* hack to see if we have ANY weapons at all. */
if (!pl.activeweapon) { if (!pl.activeweapon) {
return; return;
@ -150,22 +155,23 @@ HUD_SlotSelect(int slot)
} }
} }
} else { } else {
/* increment our current selected weapon by 1 */ int first = -1;
pSeat->m_iHUDWeaponSelected++; for (i = 1; i < g_weapons.length; i++) {
pSeat->m_flHUDWeaponSelectTime = time + 3; if (g_weapons[i].slot == slot && pl.g_items & g_weapons[i].id) {
if (i < pSeat->m_iHUDWeaponSelected && first == -1) {
/* haven't got it. */ first = i;
if (!(pl.g_items & g_weapons[pSeat->m_iHUDWeaponSelected].id)) { } else if (i > pSeat->m_iHUDWeaponSelected) {
HUD_SlotSelect(slot); first = -1;
pSeat->m_iHUDWeaponSelected = i;
pSeat->m_flHUDWeaponSelectTime = time + 3;
break;
}
}
} }
/* reset when out of bounds or outside slot area */ if (first > 0) {
if (pSeat->m_iHUDWeaponSelected >= g_weapons.length) { pSeat->m_iHUDWeaponSelected = first;
pSeat->m_iHUDWeaponSelected = 0; pSeat->m_flHUDWeaponSelectTime = time + 3;
HUD_SlotSelect(slot);
} else if (g_weapons[pSeat->m_iHUDWeaponSelected].slot != slot) {
pSeat->m_iHUDWeaponSelected = 0;
HUD_SlotSelect(slot);
} }
} }
} }

View file

@ -118,12 +118,18 @@ int HUD_InSlotPos(int slot, int pos)
return -1; return -1;
} }
void HUD_SlotSelect(int slot) void
HUD_SlotSelect(int slot)
{ {
player pl = (player)pSeat->m_ePlayer; player pl = (player)pSeat->m_ePlayer;
int curslot = g_weapons[pSeat->m_iHUDWeaponSelected].slot; int curslot = g_weapons[pSeat->m_iHUDWeaponSelected].slot;
int i; int i;
if (g_textmenu != "") {
Textmenu_Input(slot);
return;
}
/* hack to see if we have ANY weapons at all. */ /* hack to see if we have ANY weapons at all. */
if (!pl.activeweapon) { if (!pl.activeweapon) {
return; return;
@ -145,22 +151,23 @@ void HUD_SlotSelect(int slot)
} }
} }
} else { } else {
/* increment our current selected weapon by 1 */ int first = -1;
pSeat->m_iHUDWeaponSelected++; for (i = 1; i < g_weapons.length; i++) {
pSeat->m_flHUDWeaponSelectTime = time + 3; if (g_weapons[i].slot == slot && pl.g_items & g_weapons[i].id) {
if (i < pSeat->m_iHUDWeaponSelected && first == -1) {
/* haven't got it. */ first = i;
if (!(pl.g_items & g_weapons[pSeat->m_iHUDWeaponSelected].id)) { } else if (i > pSeat->m_iHUDWeaponSelected) {
HUD_SlotSelect(slot); first = -1;
pSeat->m_iHUDWeaponSelected = i;
pSeat->m_flHUDWeaponSelectTime = time + 3;
break;
}
}
} }
/* reset when out of bounds or outside slot area */ if (first > 0) {
if (pSeat->m_iHUDWeaponSelected >= g_weapons.length) { pSeat->m_iHUDWeaponSelected = first;
pSeat->m_iHUDWeaponSelected = 0; pSeat->m_flHUDWeaponSelectTime = time + 3;
HUD_SlotSelect(slot);
} else if (g_weapons[pSeat->m_iHUDWeaponSelected].slot != slot) {
pSeat->m_iHUDWeaponSelected = 0;
HUD_SlotSelect(slot);
} }
} }
} }

View file

@ -123,6 +123,11 @@ HUD_SlotSelect(int slot)
int curslot = g_weapons[pSeat->m_iHUDWeaponSelected].slot; int curslot = g_weapons[pSeat->m_iHUDWeaponSelected].slot;
int i; int i;
if (g_textmenu != "") {
Textmenu_Input(slot);
return;
}
/* hack to see if we have ANY weapons at all. */ /* hack to see if we have ANY weapons at all. */
if (!pl.activeweapon) { if (!pl.activeweapon) {
return; return;
@ -144,22 +149,23 @@ HUD_SlotSelect(int slot)
} }
} }
} else { } else {
/* increment our current selected weapon by 1 */ int first = -1;
pSeat->m_iHUDWeaponSelected++; for (i = 1; i < g_weapons.length; i++) {
pSeat->m_flHUDWeaponSelectTime = time + 3; if (g_weapons[i].slot == slot && pl.g_items & g_weapons[i].id) {
if (i < pSeat->m_iHUDWeaponSelected && first == -1) {
/* haven't got it. */ first = i;
if (!(pl.g_items & g_weapons[pSeat->m_iHUDWeaponSelected].id)) { } else if (i > pSeat->m_iHUDWeaponSelected) {
HUD_SlotSelect(slot); first = -1;
pSeat->m_iHUDWeaponSelected = i;
pSeat->m_flHUDWeaponSelectTime = time + 3;
break;
}
}
} }
/* reset when out of bounds or outside slot area */ if (first > 0) {
if (pSeat->m_iHUDWeaponSelected >= g_weapons.length) { pSeat->m_iHUDWeaponSelected = first;
pSeat->m_iHUDWeaponSelected = 0; pSeat->m_flHUDWeaponSelectTime = time + 3;
HUD_SlotSelect(slot);
} else if (g_weapons[pSeat->m_iHUDWeaponSelected].slot != slot) {
pSeat->m_iHUDWeaponSelected = 0;
HUD_SlotSelect(slot);
} }
} }
} }