diff --git a/sql/mangos.sql b/sql/mangos.sql index 6a603bc4e..dddc5c54f 100644 --- a/sql/mangos.sql +++ b/sql/mangos.sql @@ -22,7 +22,7 @@ DROP TABLE IF EXISTS `db_version`; CREATE TABLE `db_version` ( `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'; -- @@ -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 "".'), ('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 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 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 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',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 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 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.'), ('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.'), diff --git a/sql/updates/2008_11_16_01_mangos_command.sql b/sql/updates/2008_11_16_01_mangos_command.sql new file mode 100644 index 000000000..bc8f75b65 --- /dev/null +++ b/sql/updates/2008_11_16_01_mangos_command.sql @@ -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.'); diff --git a/sql/updates/Makefile.am b/sql/updates/Makefile.am index b743c6d15..a919714a8 100644 --- a/sql/updates/Makefile.am +++ b/sql/updates/Makefile.am @@ -132,7 +132,9 @@ pkgdata_DATA = \ 2008_11_09_03_mangos_mangos_string.sql \ 2008_11_11_01_mangos_db_script_string.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_16_01_mangos_command.sql README ## Additional files to include when running 'make dist' @@ -248,4 +250,5 @@ EXTRA_DIST = \ 2008_11_11_02_mangos_scripts.sql \ 2008_11_12_01_character_character_aura.sql \ 2008_11_14_01_mangos_scripts.sql \ + 2008_11_16_01_mangos_command.sql README diff --git a/src/game/Chat.cpp b/src/game/Chat.cpp index 068476c19..0eaaeabc4 100644 --- a/src/game/Chat.cpp +++ b/src/game/Chat.cpp @@ -61,16 +61,44 @@ ChatCommand * ChatHandler::getCommandTable() { 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[] = { { "corpses", SEC_GAMEMASTER, true, &ChatHandler::HandleServerCorpsesCommand, "", NULL }, { "exit", SEC_CONSOLE, true, &ChatHandler::HandleServerExitCommand, "", NULL }, - { "idlerestart", SEC_ADMINISTRATOR, true, &ChatHandler::HandleIdleRestartCommand, "", NULL }, - { "idleshutdown", SEC_ADMINISTRATOR, true, &ChatHandler::HandleIdleShutDownCommand, "", NULL }, + { "idlerestart", SEC_ADMINISTRATOR, true, NULL, "", serverIdleRestartCommandTable }, + { "idleshutdown", SEC_ADMINISTRATOR, true, NULL, "", serverShutdownCommandTable }, { "info", SEC_PLAYER, true, &ChatHandler::HandleServerInfoCommand, "", NULL }, { "motd", SEC_PLAYER, true, &ChatHandler::HandleServerMotdCommand, "", NULL }, - { "restart", SEC_ADMINISTRATOR, true, &ChatHandler::HandleRestartCommand, "", NULL }, - { "shutdown", SEC_ADMINISTRATOR, true, &ChatHandler::HandleShutDownCommand, "", NULL }, + { "restart", SEC_ADMINISTRATOR, true, NULL, "", serverRestartCommandTable }, + { "shutdown", SEC_ADMINISTRATOR, true, NULL, "", serverShutdownCommandTable }, { "set", SEC_ADMINISTRATOR, true, NULL, "", serverSetCommandTable }, { NULL, 0, false, NULL, "", NULL } }; diff --git a/src/game/Chat.h b/src/game/Chat.h index 77a9d514a..73e0d6d50 100644 --- a/src/game/Chat.h +++ b/src/game/Chat.h @@ -269,10 +269,15 @@ class ChatHandler bool HandleServerCorpsesCommand(const char* args); bool HandleServerExitCommand(const char* args); + bool HandleServerIdleRestartCommand(const char* args); + bool HandleServerIdleShutDownCommand(const char* args); bool HandleServerInfoCommand(const char* args); bool HandleServerMotdCommand(const char* args); + bool HandleServerRestartCommand(const char* args); bool HandleServerSetMotdCommand(const char* args); bool HandleServerSetLogLevelCommand(const char* args); + bool HandleServerShutDownCommand(const char* args); + bool HandleServerShutDownCancelCommand(const char* args); bool HandleAddHonorCommand(const char* args); bool HandleHonorAddKillCommand(const char* args); @@ -322,10 +327,6 @@ class ChatHandler bool HandleBanListAccountCommand(const char* args); bool HandleBanListCharacterCommand(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 HandleGoXYZCommand(const char* args); bool HandleGoZoneXYCommand(const char* args); diff --git a/src/game/Level3.cpp b/src/game/Level3.cpp index a7e6836ff..f10c9c96f 100644 --- a/src/game/Level3.cpp +++ b/src/game/Level3.cpp @@ -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; } diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 46606a548..886eebf40 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "6830" + #define REVISION_NR "6831" #endif // __REVISION_NR_H__