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:
parent
63da454de8
commit
7cb413111e
@ -57,7 +57,9 @@ CCStr GetSkinName(Uint32 id)
|
||||
void SetSkinName(Uint32 id, CCStr name)
|
||||
{
|
||||
if (id <= 159)
|
||||
{
|
||||
CS_Skin_Names[id].assign(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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user