Merge pull request #340 from Arkshine/fix/cstrike-lower-command
Fix CS_OnBuy* not triggered from alias containing uppercase letters
This commit is contained in:
commit
0462ca02c8
|
@ -158,8 +158,11 @@ DETOUR_DECL_STATIC1(C_ClientCommand, void, edict_t*, pEdict) // void ClientComma
|
|||
if (get_pdata<CUnifiedSignals>(pEdict, SignalsDesc.fieldOffset).GetState() & SIGNAL_BUY) // Are we inside the buy zone?
|
||||
{
|
||||
AliasInfo info;
|
||||
char commandLowered[32];
|
||||
|
||||
if (ItemsManager.GetAliasInfosFromBuy(command, &info))
|
||||
UTIL_StringToLower(command, commandLowered, sizeof(commandLowered));
|
||||
|
||||
if (ItemsManager.GetAliasInfosFromBuy(commandLowered, &info))
|
||||
{
|
||||
CurrentItemId = info.itemid;
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
//
|
||||
|
||||
#include "amxxmodule.h"
|
||||
#include <amtl/am-algorithm.h>
|
||||
|
||||
extern int MessageIdTextMsg;
|
||||
|
||||
|
@ -47,3 +48,22 @@ bool UTIL_CheckForPublic(const char *publicname)
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
void UTIL_StringToLower(const char *str, char *buffer, size_t maxlength)
|
||||
{
|
||||
auto length = ke::Min(strlen(str), maxlength - 1);
|
||||
|
||||
for (size_t i = 0; i < length; ++i)
|
||||
{
|
||||
if (str[i] >= 'A' && str[i] <= 'Z')
|
||||
{
|
||||
buffer[i] = tolower(str[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer[i] = str[i];
|
||||
}
|
||||
}
|
||||
|
||||
buffer[length] = '\0';
|
||||
}
|
|
@ -21,6 +21,7 @@ extern HLTypeConversion TypeConversion;
|
|||
bool UTIL_IsPlayer(edict_t *pPlayer);
|
||||
void UTIL_TextMsg_Generic(edict_t* pPlayer, const char* message);
|
||||
bool UTIL_CheckForPublic(const char *publicname);
|
||||
void UTIL_StringToLower(const char *str, char *buffer, size_t maxlength);
|
||||
|
||||
#define GETINFOKEYBUFFER (*g_engfuncs.pfnGetInfoKeyBuffer)
|
||||
#define SETCLIENTKEYVALUE (*g_engfuncs.pfnSetClientKeyValue)
|
||||
|
|
Loading…
Reference in New Issue
Block a user