1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2024-11-08 08:47:17 +01:00

Adjust range checks when converting skin name to identifier.

This commit is contained in:
Sandu Liviu Catalin 2016-07-28 00:10:15 +03:00
parent 63da454de8
commit 7cb413111e

View File

@ -57,8 +57,10 @@ CCStr GetSkinName(Uint32 id)
void SetSkinName(Uint32 id, CCStr name)
{
if (id <= 159)
{
CS_Skin_Names[id].assign(name);
}
}
// ------------------------------------------------------------------------------------------------
Int32 GetSkinID(CCStr name)
@ -71,19 +73,23 @@ Int32 GetSkinID(CCStr name)
std::transform(str.begin(), str.end(), str.begin(), ::tolower);
// See if we still have a valid name after the cleanup
if(str.empty())
{
return SQMOD_UNKNOWN;
}
// Grab the actual length of the string
Uint32 len = static_cast< Uint32 >(str.length());
const Uint32 len = static_cast< Uint32 >(str.length());
// Get the most significant characters used to identify a skin
CharT a = str[0], b = 0, c = 0, d = str[len-1];
// Look for deeper specifiers
if (len >= 3)
if (len > 2)
{
b = str[1];
c = str[2];
}
else if (len >= 2)
else if (len > 1)
{
b = str[1];
}
// Search for a pattern in the name
switch (a)
{