Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool ChatHandler::HandleServerShutDownCommand(const char* args)
- {
- if(!*args)
- return false;
- char* time_str = strtok ((char*) args, " ");
- char* exitcode_str = strtok (NULL, "");
- int32 time = atoi (time_str);
- ///- Prevent interpret wrong arg value as 0 secs shutdown time
- if (time == 0 && (time_str[0]!='0' || time_str[1]!='\0') || time < 0)
- return false;
- if (exitcode_str)
- {
- int32 exitcode = atoi (exitcode_str);
- // Handle atoi() errors
- if (exitcode == 0 && (exitcode_str[0] != '0' || exitcode_str[1] != '\0'))
- return false;
- // Exit code should be in range of 0-125, 126-255 is used
- // in many shells for their own return codes and code > 255
- // is not supported in many others
- if (exitcode < 0 || exitcode > 125)
- return false;
- sWorld.ShutdownServ (time, 0, exitcode);
- }
- else
- sWorld.ShutdownServ(time,0,SHUTDOWN_EXIT_CODE);
- return true;
- }
Add Comment
Please, Sign In to add comment