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:
mkdir -p ../platform/data.pk3dir
$(CC) menu-fn/progs.src
$(CC) menu-vgui/progs.src
#$(CC) menu-vgui/progs.src
games:
mkdir -p ../valve/data.pk3dir

View file

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

View file

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

View file

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

View file

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