mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 07:37:01 +00:00
[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:
parent
528a9d830a
commit
b992056123
7 changed files with 178 additions and 140 deletions
|
|
@ -22,7 +22,7 @@
|
||||||
DROP TABLE IF EXISTS `db_version`;
|
DROP TABLE IF EXISTS `db_version`;
|
||||||
CREATE TABLE `db_version` (
|
CREATE TABLE `db_version` (
|
||||||
`version` varchar(120) default NULL,
|
`version` varchar(120) default NULL,
|
||||||
`required_2008_11_14_01_mangos_scripts` bit(1) default NULL
|
`required_2008_11_16_01_mangos_command` bit(1) default NULL
|
||||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes';
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes';
|
||||||
|
|
||||||
--
|
--
|
||||||
|
|
@ -408,15 +408,19 @@ INSERT INTO `command` VALUES
|
||||||
('sendmoney','3','Syntax: .sendmoney #playername "#subject" "#text" #money\r\n\r\nSend mail with money to a player. Subject and mail text must be in "".'),
|
('sendmoney','3','Syntax: .sendmoney #playername "#subject" "#text" #money\r\n\r\nSend mail with money to a player. Subject and mail text must be in "".'),
|
||||||
('sendmessage',3,'Syntax: .sendmessage $playername $message\r\n\r\nSend screen message to player from ADMINISTRATOR.'),
|
('sendmessage',3,'Syntax: .sendmessage $playername $message\r\n\r\nSend screen message to player from ADMINISTRATOR.'),
|
||||||
('server corpses',2,'Syntax: .server corpses\r\n\r\nTriggering corpses expire check in world.'),
|
('server corpses',2,'Syntax: .server corpses\r\n\r\nTriggering corpses expire check in world.'),
|
||||||
('server exit',4,'Syntax: .server exit\r\n\r\nTerminate mangosd NOW.'),
|
('server exit',4,'Syntax: .server exit\r\n\r\nTerminate mangosd NOW. Exit code 0.'),
|
||||||
('server info',0,'Syntax: .server info\r\n\r\nDisplay server version and the number of connected players.'),
|
('server info',0,'Syntax: .server info\r\n\r\nDisplay server version and the number of connected players.'),
|
||||||
('server idleshutdown',3,'Syntax: .server idleshutdown #delay|cancel\r\n\r\nShut the server down after #delay seconds if no active connections are present (no players) or cancel the restart/shutdown if cancel value is used.'),
|
('server idleshutdown',3,'Syntax: .server idleshutdown #delay [#exist_code]\r\n\r\nShut the server down after #delay seconds if no active connections are present (no players). Use #exist_code or 0 as program exist code.'),
|
||||||
('server idlerestart',3,'Syntax: .server idlerestart #delay|cancel\r\n\r\nRestart the server after #delay seconds if no active connections are present (no players) or cancel the restart/shutdown if cancel value is used.'),
|
('server idleshutdown cancel',3,'Syntax: .server idleshutdown cancel\r\n\r\nCancel the restart/shutdown timer if any.'),
|
||||||
|
('server idlerestart',3,'Syntax: .server idlerestart #delay\r\n\r\nRestart the server after #delay seconds if no active connections are present (no players). Use #exist_code or 2 as program exist code.'),
|
||||||
|
('server idlerestart cancel',3,'Syntax: .server idlerestart cancel\r\n\r\nCancel the restart/shutdown timer if any.'),
|
||||||
('server motd',0,'Syntax: .server motd\r\n\r\nShow server Message of the day.'),
|
('server motd',0,'Syntax: .server motd\r\n\r\nShow server Message of the day.'),
|
||||||
('server restart',3,'Syntax: .server restart seconds\r\n\r\nRestart the server after given seconds and show "Restart server in X" or cancel the restart/shutdown if cancel value is used.'),
|
('server restart',3,'Syntax: .server restart #delay\r\n\r\nRestart the server after #delay seconds. Use #exist_code or 2 as program exist code.'),
|
||||||
|
('server restart cancel',3,'Syntax: .server restart cancel\r\n\r\nCancel the restart/shutdown timer if any.'),
|
||||||
('server set loglevel',4,'Syntax: .server set loglevel #level\r\n\r\nSet server log level (0 - errors only, 1 - basic, 2 - detail, 3 - debug).'),
|
('server set loglevel',4,'Syntax: .server set loglevel #level\r\n\r\nSet server log level (0 - errors only, 1 - basic, 2 - detail, 3 - debug).'),
|
||||||
('server set motd',3,'Syntax: .server set motd $MOTD\r\n\r\nSet server Message of the day.'),
|
('server set motd',3,'Syntax: .server set motd $MOTD\r\n\r\nSet server Message of the day.'),
|
||||||
('server shutdown',3,'Syntax: .server shutdown seconds\r\n\r\nShut the server down after given seconds and show "Off server in X" or cancel the restart/shutdown if cancel value is used.'),
|
('server shutdown',3,'Syntax: .server shutdown #delay [#exist_code]\r\n\r\nShut the server down after #delay seconds. Use #exist_code or 0 as program exist code.'),
|
||||||
|
('server shutdown cancel',3,'Syntax: .server shutdown cancel\r\n\r\nCancel the restart/shutdown timer if any.'),
|
||||||
('setskill',3,'Syntax: .setskill #skill #level [#max]\r\n\r\nSet a skill of id #skill with a current skill value of #level and a maximum value of #max (or equal current maximum if not provide) for the selected character. If no character is selected, you learn the skill.'),
|
('setskill',3,'Syntax: .setskill #skill #level [#max]\r\n\r\nSet a skill of id #skill with a current skill value of #level and a maximum value of #max (or equal current maximum if not provide) for the selected character. If no character is selected, you learn the skill.'),
|
||||||
('showarea',3,'Syntax: .showarea #areaid\r\n\r\nReveal the area of #areaid to the selected character. If no character is selected, reveal this area to you.'),
|
('showarea',3,'Syntax: .showarea #areaid\r\n\r\nReveal the area of #areaid to the selected character. If no character is selected, reveal this area to you.'),
|
||||||
('start',0,'Syntax: .start\r\n\r\nTeleport you to the starting area of your character.'),
|
('start',0,'Syntax: .start\r\n\r\nTeleport you to the starting area of your character.'),
|
||||||
|
|
|
||||||
24
sql/updates/2008_11_16_01_mangos_command.sql
Normal file
24
sql/updates/2008_11_16_01_mangos_command.sql
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
ALTER TABLE db_version CHANGE COLUMN required_2008_11_14_01_mangos_scripts required_2008_11_16_01_mangos_command bit;
|
||||||
|
|
||||||
|
DELETE FROM `command` WHERE `name` IN (
|
||||||
|
'server exit',
|
||||||
|
'server idleshutdown',
|
||||||
|
'server idleshutdown cancel',
|
||||||
|
'server idlerestart',
|
||||||
|
'server idlerestart cancel',
|
||||||
|
'server restart',
|
||||||
|
'server restart cancel',
|
||||||
|
'server shutdown',
|
||||||
|
'server shutdown cancel'
|
||||||
|
);
|
||||||
|
|
||||||
|
INSERT INTO `command` (`name`, `security`, `help`) VALUES
|
||||||
|
('server exit',4,'Syntax: .server exit\r\n\r\nTerminate mangosd NOW. Exit code 0.'),
|
||||||
|
('server idleshutdown',3,'Syntax: .server idleshutdown #delay [#exist_code]\r\n\r\nShut the server down after #delay seconds if no active connections are present (no players). Use #exist_code or 0 as program exist code.'),
|
||||||
|
('server idleshutdown cancel',3,'Syntax: .server idleshutdown cancel\r\n\r\nCancel the restart/shutdown timer if any.'),
|
||||||
|
('server idlerestart',3,'Syntax: .server idlerestart #delay\r\n\r\nRestart the server after #delay seconds if no active connections are present (no players). Use #exist_code or 2 as program exist code.'),
|
||||||
|
('server idlerestart cancel',3,'Syntax: .server idlerestart cancel\r\n\r\nCancel the restart/shutdown timer if any.'),
|
||||||
|
('server restart',3,'Syntax: .server restart #delay\r\n\r\nRestart the server after #delay seconds. Use #exist_code or 2 as program exist code.'),
|
||||||
|
('server restart cancel',3,'Syntax: .server restart cancel\r\n\r\nCancel the restart/shutdown timer if any.'),
|
||||||
|
('server shutdown',3,'Syntax: .server shutdown #delay [#exist_code]\r\n\r\nShut the server down after #delay seconds. Use #exist_code or 0 as program exist code.'),
|
||||||
|
('server shutdown cancel',3,'Syntax: .server shutdown cancel\r\n\r\nCancel the restart/shutdown timer if any.');
|
||||||
|
|
@ -132,7 +132,9 @@ pkgdata_DATA = \
|
||||||
2008_11_09_03_mangos_mangos_string.sql \
|
2008_11_09_03_mangos_mangos_string.sql \
|
||||||
2008_11_11_01_mangos_db_script_string.sql \
|
2008_11_11_01_mangos_db_script_string.sql \
|
||||||
2008_11_11_02_mangos_scripts.sql \
|
2008_11_11_02_mangos_scripts.sql \
|
||||||
|
2008_11_12_01_character_character_aura.sql \
|
||||||
2008_11_14_01_mangos_scripts.sql \
|
2008_11_14_01_mangos_scripts.sql \
|
||||||
|
2008_11_16_01_mangos_command.sql
|
||||||
README
|
README
|
||||||
|
|
||||||
## Additional files to include when running 'make dist'
|
## Additional files to include when running 'make dist'
|
||||||
|
|
@ -248,4 +250,5 @@ EXTRA_DIST = \
|
||||||
2008_11_11_02_mangos_scripts.sql \
|
2008_11_11_02_mangos_scripts.sql \
|
||||||
2008_11_12_01_character_character_aura.sql \
|
2008_11_12_01_character_character_aura.sql \
|
||||||
2008_11_14_01_mangos_scripts.sql \
|
2008_11_14_01_mangos_scripts.sql \
|
||||||
|
2008_11_16_01_mangos_command.sql
|
||||||
README
|
README
|
||||||
|
|
|
||||||
|
|
@ -61,16 +61,44 @@ ChatCommand * ChatHandler::getCommandTable()
|
||||||
{ NULL, 0, false, NULL, "", NULL }
|
{ NULL, 0, false, NULL, "", NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static ChatCommand serverIdleRestartCommandTable[] =
|
||||||
|
{
|
||||||
|
{ "cancel", SEC_ADMINISTRATOR, true, &ChatHandler::HandleServerShutDownCancelCommand,"", NULL },
|
||||||
|
{ "" , SEC_ADMINISTRATOR, true, &ChatHandler::HandleServerIdleRestartCommand, "", NULL },
|
||||||
|
{ NULL, 0, false, NULL, "", NULL }
|
||||||
|
};
|
||||||
|
|
||||||
|
static ChatCommand serverIdleShutdownCommandTable[] =
|
||||||
|
{
|
||||||
|
{ "cancel", SEC_ADMINISTRATOR, true, &ChatHandler::HandleServerShutDownCancelCommand,"", NULL },
|
||||||
|
{ "" , SEC_ADMINISTRATOR, true, &ChatHandler::HandleServerIdleShutDownCommand, "", NULL },
|
||||||
|
{ NULL, 0, false, NULL, "", NULL }
|
||||||
|
};
|
||||||
|
|
||||||
|
static ChatCommand serverRestartCommandTable[] =
|
||||||
|
{
|
||||||
|
{ "cancel", SEC_ADMINISTRATOR, true, &ChatHandler::HandleServerShutDownCancelCommand,"", NULL },
|
||||||
|
{ "" , SEC_ADMINISTRATOR, true, &ChatHandler::HandleServerRestartCommand, "", NULL },
|
||||||
|
{ NULL, 0, false, NULL, "", NULL }
|
||||||
|
};
|
||||||
|
|
||||||
|
static ChatCommand serverShutdownCommandTable[] =
|
||||||
|
{
|
||||||
|
{ "cancel", SEC_ADMINISTRATOR, true, &ChatHandler::HandleServerShutDownCancelCommand,"", NULL },
|
||||||
|
{ "" , SEC_ADMINISTRATOR, true, &ChatHandler::HandleServerShutDownCommand, "", NULL },
|
||||||
|
{ NULL, 0, false, NULL, "", NULL }
|
||||||
|
};
|
||||||
|
|
||||||
static ChatCommand serverCommandTable[] =
|
static ChatCommand serverCommandTable[] =
|
||||||
{
|
{
|
||||||
{ "corpses", SEC_GAMEMASTER, true, &ChatHandler::HandleServerCorpsesCommand, "", NULL },
|
{ "corpses", SEC_GAMEMASTER, true, &ChatHandler::HandleServerCorpsesCommand, "", NULL },
|
||||||
{ "exit", SEC_CONSOLE, true, &ChatHandler::HandleServerExitCommand, "", NULL },
|
{ "exit", SEC_CONSOLE, true, &ChatHandler::HandleServerExitCommand, "", NULL },
|
||||||
{ "idlerestart", SEC_ADMINISTRATOR, true, &ChatHandler::HandleIdleRestartCommand, "", NULL },
|
{ "idlerestart", SEC_ADMINISTRATOR, true, NULL, "", serverIdleRestartCommandTable },
|
||||||
{ "idleshutdown", SEC_ADMINISTRATOR, true, &ChatHandler::HandleIdleShutDownCommand, "", NULL },
|
{ "idleshutdown", SEC_ADMINISTRATOR, true, NULL, "", serverShutdownCommandTable },
|
||||||
{ "info", SEC_PLAYER, true, &ChatHandler::HandleServerInfoCommand, "", NULL },
|
{ "info", SEC_PLAYER, true, &ChatHandler::HandleServerInfoCommand, "", NULL },
|
||||||
{ "motd", SEC_PLAYER, true, &ChatHandler::HandleServerMotdCommand, "", NULL },
|
{ "motd", SEC_PLAYER, true, &ChatHandler::HandleServerMotdCommand, "", NULL },
|
||||||
{ "restart", SEC_ADMINISTRATOR, true, &ChatHandler::HandleRestartCommand, "", NULL },
|
{ "restart", SEC_ADMINISTRATOR, true, NULL, "", serverRestartCommandTable },
|
||||||
{ "shutdown", SEC_ADMINISTRATOR, true, &ChatHandler::HandleShutDownCommand, "", NULL },
|
{ "shutdown", SEC_ADMINISTRATOR, true, NULL, "", serverShutdownCommandTable },
|
||||||
{ "set", SEC_ADMINISTRATOR, true, NULL, "", serverSetCommandTable },
|
{ "set", SEC_ADMINISTRATOR, true, NULL, "", serverSetCommandTable },
|
||||||
{ NULL, 0, false, NULL, "", NULL }
|
{ NULL, 0, false, NULL, "", NULL }
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -269,10 +269,15 @@ class ChatHandler
|
||||||
|
|
||||||
bool HandleServerCorpsesCommand(const char* args);
|
bool HandleServerCorpsesCommand(const char* args);
|
||||||
bool HandleServerExitCommand(const char* args);
|
bool HandleServerExitCommand(const char* args);
|
||||||
|
bool HandleServerIdleRestartCommand(const char* args);
|
||||||
|
bool HandleServerIdleShutDownCommand(const char* args);
|
||||||
bool HandleServerInfoCommand(const char* args);
|
bool HandleServerInfoCommand(const char* args);
|
||||||
bool HandleServerMotdCommand(const char* args);
|
bool HandleServerMotdCommand(const char* args);
|
||||||
|
bool HandleServerRestartCommand(const char* args);
|
||||||
bool HandleServerSetMotdCommand(const char* args);
|
bool HandleServerSetMotdCommand(const char* args);
|
||||||
bool HandleServerSetLogLevelCommand(const char* args);
|
bool HandleServerSetLogLevelCommand(const char* args);
|
||||||
|
bool HandleServerShutDownCommand(const char* args);
|
||||||
|
bool HandleServerShutDownCancelCommand(const char* args);
|
||||||
|
|
||||||
bool HandleAddHonorCommand(const char* args);
|
bool HandleAddHonorCommand(const char* args);
|
||||||
bool HandleHonorAddKillCommand(const char* args);
|
bool HandleHonorAddKillCommand(const char* args);
|
||||||
|
|
@ -322,10 +327,6 @@ class ChatHandler
|
||||||
bool HandleBanListAccountCommand(const char* args);
|
bool HandleBanListAccountCommand(const char* args);
|
||||||
bool HandleBanListCharacterCommand(const char* args);
|
bool HandleBanListCharacterCommand(const char* args);
|
||||||
bool HandleBanListIPCommand(const char* args);
|
bool HandleBanListIPCommand(const char* args);
|
||||||
bool HandleIdleRestartCommand(const char* args);
|
|
||||||
bool HandleIdleShutDownCommand(const char* args);
|
|
||||||
bool HandleShutDownCommand(const char* args);
|
|
||||||
bool HandleRestartCommand(const char* args);
|
|
||||||
bool HandleGoXYCommand(const char* args);
|
bool HandleGoXYCommand(const char* args);
|
||||||
bool HandleGoXYZCommand(const char* args);
|
bool HandleGoXYZCommand(const char* args);
|
||||||
bool HandleGoZoneXYCommand(const char* args);
|
bool HandleGoZoneXYCommand(const char* args);
|
||||||
|
|
|
||||||
|
|
@ -4572,171 +4572,149 @@ bool ChatHandler::HandleResetAllCommand(const char * args)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ChatHandler::HandleShutDownCommand(const char* args)
|
bool ChatHandler::HandleServerShutDownCancelCommand(const char* args)
|
||||||
{
|
{
|
||||||
if(!*args)
|
sWorld.ShutdownCancel();
|
||||||
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);
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ChatHandler::HandleRestartCommand(const char* args)
|
bool ChatHandler::HandleServerShutDownCommand(const char* args)
|
||||||
{
|
{
|
||||||
if(!*args)
|
if(!*args)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(std::string(args)=="cancel")
|
char* time_str = strtok ((char*) args, " ");
|
||||||
{
|
char* exitcode_str = strtok (NULL, "");
|
||||||
sWorld.ShutdownCancel();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
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
|
///- Prevent interpret wrong arg value as 0 secs shutdown time
|
||||||
if(time == 0 && (time_str[0]!='0' || time_str[1]!='\0') || time < 0)
|
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;
|
return false;
|
||||||
|
|
||||||
if (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
|
||||||
int32 exitcode = atoi (exitcode_str);
|
// is not supported in many others
|
||||||
|
if (exitcode < 0 || exitcode > 125)
|
||||||
|
return false;
|
||||||
|
|
||||||
// Handle atoi() errors
|
sWorld.ShutdownServ (time, 0, exitcode);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
sWorld.ShutdownServ(time,0,SHUTDOWN_EXIT_CODE);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ChatHandler::HandleIdleRestartCommand(const char* args)
|
bool ChatHandler::HandleServerRestartCommand(const char* args)
|
||||||
{
|
{
|
||||||
if(!*args)
|
if(!*args)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(std::string(args)=="cancel")
|
char* time_str = strtok ((char*) args, " ");
|
||||||
{
|
char* exitcode_str = strtok (NULL, "");
|
||||||
sWorld.ShutdownCancel();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
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
|
///- Prevent interpret wrong arg value as 0 secs shutdown time
|
||||||
if(time == 0 && (time_str[0]!='0' || time_str[1]!='\0') || time < 0)
|
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;
|
return false;
|
||||||
|
|
||||||
if (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
|
||||||
int32 exitcode = atoi (exitcode_str);
|
// is not supported in many others
|
||||||
|
if (exitcode < 0 || exitcode > 125)
|
||||||
|
return false;
|
||||||
|
|
||||||
// Handle atoi() errors
|
sWorld.ShutdownServ (time, SHUTDOWN_MASK_RESTART, exitcode);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
sWorld.ShutdownServ(time, SHUTDOWN_MASK_RESTART, RESTART_EXIT_CODE);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ChatHandler::HandleIdleShutDownCommand(const char* args)
|
bool ChatHandler::HandleServerIdleRestartCommand(const char* args)
|
||||||
{
|
{
|
||||||
if(!*args)
|
if(!*args)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(std::string(args)=="cancel")
|
char* time_str = strtok ((char*) args, " ");
|
||||||
{
|
char* exitcode_str = strtok (NULL, "");
|
||||||
sWorld.ShutdownCancel();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
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
|
///- Prevent interpret wrong arg value as 0 secs shutdown time
|
||||||
if(time == 0 && (time_str[0]!='0' || time_str[1]!='\0') || time < 0)
|
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;
|
return false;
|
||||||
|
|
||||||
if (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
|
||||||
int32 exitcode = atoi (exitcode_str);
|
// is not supported in many others
|
||||||
|
if (exitcode < 0 || exitcode > 125)
|
||||||
|
return false;
|
||||||
|
|
||||||
// Handle atoi() errors
|
sWorld.ShutdownServ (time, SHUTDOWN_MASK_RESTART|SHUTDOWN_MASK_IDLE, exitcode);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "6830"
|
#define REVISION_NR "6831"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue