mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-22 23:06:18 +00:00
Changed: #142 Replace atoi and sscanf by fromString when it's possible
This commit is contained in:
parent
0f9a569d2a
commit
a1d2e9354f
2 changed files with 13 additions and 10 deletions
|
@ -1897,16 +1897,18 @@ uint32 CObject::instanceIdToUint32(const std::string& instanceId)
|
|||
|
||||
std::string clientIdStr = instanceId.substr(6, clientIdIt-6);
|
||||
std::string componentIdStr = instanceId.substr(clientIdIt+1, size - clientIdIt);
|
||||
char* ko=NULL;
|
||||
uint32 clientId = static_cast<uint32>(strtol(clientIdStr.c_str(), &ko, 10));
|
||||
if (*ko != '\0')
|
||||
bool ko;
|
||||
uint32 clientId;
|
||||
ko = NLMISC::fromString(clientIdStr, clientId);
|
||||
if (!ko)
|
||||
{
|
||||
nlwarning("R2Share: Wrong InstanceId(%s)", instanceId.c_str());
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32 componentId = static_cast<uint32>(strtol(componentIdStr.c_str(), &ko, 10));
|
||||
if (*ko != '\0')
|
||||
uint32 componentId;
|
||||
ko = NLMISC::fromString(componentIdStr, componentId);
|
||||
if (!ko)
|
||||
{
|
||||
nlwarning("R2Share: Wrong InstanceId(%s)", instanceId.c_str());
|
||||
return 0;
|
||||
|
|
|
@ -3932,14 +3932,15 @@ void CServerAnimationModule::activateEasterEgg(class NLNET::IModuleProxy * /* ai
|
|||
|
||||
DROP_IF( itemAndQt.size() != 2, "Syntax error in activateEasterEgg", return );
|
||||
|
||||
char* ok = 0;
|
||||
uint32 item = static_cast<uint32>(strtol(itemAndQt[0].c_str(), &ok, 10));
|
||||
uint32 item;
|
||||
bool ok = NLMISC::fromString(itemAndQt[0], item);
|
||||
|
||||
DROP_IF( *ok != '\0', "Error activateEasterEgg", return);
|
||||
DROP_IF( !ok, "Error activateEasterEgg", return);
|
||||
|
||||
uint32 qt = static_cast<uint32>(strtol(itemAndQt[1].c_str(), &ok, 10));
|
||||
uint32 qt;
|
||||
ok = NLMISC::fromString(itemAndQt[1], qt);
|
||||
|
||||
DROP_IF( *ok != '\0', "Error in activateEasterEgg", return);
|
||||
DROP_IF( !ok, "Error in activateEasterEgg", return);
|
||||
DROP_IF( qt > 255, "Error in activateEasterEgg", return);
|
||||
DROP_IF( item >= session->MissionItems.size(), "Error activateEasterEgg", return);
|
||||
|
||||
|
|
Loading…
Reference in a new issue