From 4978661ebe59852abde1d721f80edd4a3705e21b Mon Sep 17 00:00:00 2001 From: Vaqtincha <51029683+Vaqtincha@users.noreply.github.com> Date: Sun, 22 Sep 2019 19:16:07 +0500 Subject: [PATCH] Autobuy/Rebuy Fixes (#421) * "Old Menus" rebuy fix --- regamedll/dlls/client.cpp | 79 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 73 insertions(+), 6 deletions(-) diff --git a/regamedll/dlls/client.cpp b/regamedll/dlls/client.cpp index c39fdabe..5d6a1f90 100644 --- a/regamedll/dlls/client.cpp +++ b/regamedll/dlls/client.cpp @@ -2990,43 +2990,67 @@ void EXT_FUNC InternalCommand(edict_t *pEntity, const char *pcmd, const char *pa } case Menu_BuyPistol: { - if (canOpenOldMenu()) { + if (canOpenOldMenu()) + { BuyPistol(pPlayer, slot); +#ifdef REGAMEDLL_FIXES + pPlayer->BuildRebuyStruct(); +#endif } break; } case Menu_BuyShotgun: { - if (canOpenOldMenu()) { + if (canOpenOldMenu()) + { BuyShotgun(pPlayer, slot); +#ifdef REGAMEDLL_FIXES + pPlayer->BuildRebuyStruct(); +#endif } break; } case Menu_BuySubMachineGun: { - if (canOpenOldMenu()) { + if (canOpenOldMenu()) + { BuySubMachineGun(pPlayer, slot); +#ifdef REGAMEDLL_FIXES + pPlayer->BuildRebuyStruct(); +#endif } break; } case Menu_BuyRifle: { - if (canOpenOldMenu()) { + if (canOpenOldMenu()) + { BuyRifle(pPlayer, slot); +#ifdef REGAMEDLL_FIXES + pPlayer->BuildRebuyStruct(); +#endif } break; } case Menu_BuyMachineGun: { - if (canOpenOldMenu()) { + if (canOpenOldMenu()) + { BuyMachineGun(pPlayer, slot); +#ifdef REGAMEDLL_FIXES + pPlayer->BuildRebuyStruct(); +#endif } break; } case Menu_BuyItem: { - if (canOpenOldMenu()) { + if (canOpenOldMenu()) + { BuyItem(pPlayer, slot); +#ifdef REGAMEDLL_FIXES + pPlayer->BuildRebuyStruct(); +#endif } break; } @@ -3171,6 +3195,46 @@ void EXT_FUNC InternalCommand(edict_t *pEntity, const char *pcmd, const char *pa pPlayer->Observer_FindNextPlayer(false, parg1); } } +#ifdef REGAMEDLL_FIXES + else if (FStrEq(pcmd, "cl_setautobuy")) + { + if (pPlayer->pev->deadflag != DEAD_NO && pPlayer->m_autoBuyString[0] != '\0') + return; + + pPlayer->ClearAutoBuyData(); + + for (int i = 1; i < CMD_ARGC_(); i++) + { + pPlayer->AddAutoBuyData(CMD_ARGV_(i)); + } + + if (pPlayer->m_signals.GetState() & SIGNAL_BUY) + { + bool oldval = g_bClientPrintEnable; + g_bClientPrintEnable = false; + pPlayer->AutoBuy(); + g_bClientPrintEnable = oldval; + } + } + else if (FStrEq(pcmd, "cl_setrebuy")) + { + if (pPlayer->pev->deadflag != DEAD_NO && m_rebuyString) + return; + + if (CMD_ARGC_() == 2) + { + pPlayer->InitRebuyData(parg1); + + if (pPlayer->m_signals.GetState() & SIGNAL_BUY) + { + bool oldval = g_bClientPrintEnable; + g_bClientPrintEnable = false; + pPlayer->Rebuy(); + g_bClientPrintEnable = oldval; + } + } + } +#endif else { if (g_pGameRules->ClientCommand_DeadOrAlive(GetClassPtr((CBasePlayer *)pev), pcmd)) @@ -3404,6 +3468,8 @@ void EXT_FUNC InternalCommand(edict_t *pEntity, const char *pcmd, const char *pa } } } +#ifndef REGAMEDLL_FIXES + // Moved to above else if (FStrEq(pcmd, "cl_setautobuy")) { pPlayer->ClearAutoBuyData(); @@ -3430,6 +3496,7 @@ void EXT_FUNC InternalCommand(edict_t *pEntity, const char *pcmd, const char *pa g_bClientPrintEnable = oldval; } } +#endif else if (FStrEq(pcmd, "cl_autobuy")) { if (pPlayer->m_signals.GetState() & SIGNAL_BUY)