[6831] [2008_11_16_01_mangos_command.sql] Let use short names for cancel word in .server shutdown cancel (like ".ser s c") and similar commands.

This commit is contained in:
VladimirMangos 2008-11-16 14:29:10 +03:00
parent 528a9d830a
commit b992056123
7 changed files with 178 additions and 140 deletions

View file

@ -4572,171 +4572,149 @@ bool ChatHandler::HandleResetAllCommand(const char * args)
return true;
}
bool ChatHandler::HandleShutDownCommand(const char* args)
bool ChatHandler::HandleServerShutDownCancelCommand(const char* args)
{
if(!*args)
return false;
if(std::string(args)=="cancel")
{
sWorld.ShutdownCancel();
}
else
{
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);
}
sWorld.ShutdownCancel();
return true;
}
bool ChatHandler::HandleRestartCommand(const char* args)
bool ChatHandler::HandleServerShutDownCommand(const char* args)
{
if(!*args)
return false;
if(std::string(args)=="cancel")
{
sWorld.ShutdownCancel();
}
else
{
char* time_str = strtok ((char*) args, " ");
char* exitcode_str = strtok (NULL, "");
char* time_str = strtok ((char*) args, " ");
char* exitcode_str = strtok (NULL, "");
int32 time = atoi (time_str);
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)
///- 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;
if (exitcode_str)
{
int32 exitcode = atoi (exitcode_str);
// 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;
// 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, SHUTDOWN_MASK_RESTART, exitcode);
}
else
sWorld.ShutdownServ(time, SHUTDOWN_MASK_RESTART, RESTART_EXIT_CODE);
sWorld.ShutdownServ (time, 0, exitcode);
}
else
sWorld.ShutdownServ(time,0,SHUTDOWN_EXIT_CODE);
return true;
}
bool ChatHandler::HandleIdleRestartCommand(const char* args)
bool ChatHandler::HandleServerRestartCommand(const char* args)
{
if(!*args)
return false;
if(std::string(args)=="cancel")
{
sWorld.ShutdownCancel();
}
else
{
char* time_str = strtok ((char*) args, " ");
char* exitcode_str = strtok (NULL, "");
char* time_str = strtok ((char*) args, " ");
char* exitcode_str = strtok (NULL, "");
int32 time = atoi (time_str);
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)
///- 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;
if (exitcode_str)
{
int32 exitcode = atoi (exitcode_str);
// 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;
// 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, SHUTDOWN_MASK_RESTART|SHUTDOWN_MASK_IDLE, exitcode);
}
else
sWorld.ShutdownServ(time,SHUTDOWN_MASK_RESTART|SHUTDOWN_MASK_IDLE,RESTART_EXIT_CODE);
sWorld.ShutdownServ (time, SHUTDOWN_MASK_RESTART, exitcode);
}
else
sWorld.ShutdownServ(time, SHUTDOWN_MASK_RESTART, RESTART_EXIT_CODE);
return true;
}
bool ChatHandler::HandleIdleShutDownCommand(const char* args)
bool ChatHandler::HandleServerIdleRestartCommand(const char* args)
{
if(!*args)
return false;
if(std::string(args)=="cancel")
{
sWorld.ShutdownCancel();
}
else
{
char* time_str = strtok ((char*) args, " ");
char* exitcode_str = strtok (NULL, "");
char* time_str = strtok ((char*) args, " ");
char* exitcode_str = strtok (NULL, "");
int32 time = atoi (time_str);
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)
///- 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;
if (exitcode_str)
{
int32 exitcode = atoi (exitcode_str);
// 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;
// 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, SHUTDOWN_MASK_IDLE, exitcode);
}
else
sWorld.ShutdownServ(time,SHUTDOWN_MASK_IDLE,SHUTDOWN_EXIT_CODE);
sWorld.ShutdownServ (time, SHUTDOWN_MASK_RESTART|SHUTDOWN_MASK_IDLE, exitcode);
}
else
sWorld.ShutdownServ(time,SHUTDOWN_MASK_RESTART|SHUTDOWN_MASK_IDLE,RESTART_EXIT_CODE);
return true;
}
bool ChatHandler::HandleServerIdleShutDownCommand(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, SHUTDOWN_MASK_IDLE, exitcode);
}
else
sWorld.ShutdownServ(time,SHUTDOWN_MASK_IDLE,SHUTDOWN_EXIT_CODE);
return true;
}