From a2bb6555016a90fc57ea9bd8a58d4f133b276521 Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Thu, 10 Dec 2009 19:19:05 +0300 Subject: [PATCH] [8965] Implement `quit` command for close RA connection. World only in RA comandline. --- sql/mangos.sql | 4 +++- sql/updates/8965_01_mangos_mangos_string.sql | 6 ++++++ sql/updates/8965_02_mangos_command.sql | 6 ++++++ sql/updates/Makefile.am | 4 ++++ src/game/Chat.cpp | 1 + src/game/Chat.h | 1 + src/game/Language.h | 3 ++- src/game/MovementHandler.cpp | 1 - src/mangosd/CliRunnable.cpp | 8 ++++++++ src/mangosd/RASocket.cpp | 5 ++++- src/shared/revision_nr.h | 2 +- src/shared/revision_sql.h | 2 +- 12 files changed, 37 insertions(+), 6 deletions(-) create mode 100644 sql/updates/8965_01_mangos_mangos_string.sql create mode 100644 sql/updates/8965_02_mangos_command.sql diff --git a/sql/mangos.sql b/sql/mangos.sql index 125747865..3fa594ec1 100644 --- a/sql/mangos.sql +++ b/sql/mangos.sql @@ -24,7 +24,7 @@ CREATE TABLE `db_version` ( `version` varchar(120) default NULL, `creature_ai_version` varchar(120) default NULL, `cache_id` int(10) default '0', - `required_8950_01_mangos_spell_proc_event` bit(1) default NULL + `required_8965_02_mangos_command` bit(1) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes'; -- @@ -705,6 +705,7 @@ INSERT INTO `command` VALUES ('quest add',3,'Syntax: .quest add #quest_id\r\n\r\nAdd to character quest log quest #quest_id. Quest started from item can\'t be added by this command but correct .additem call provided in command output.'), ('quest complete',3,'Syntax: .quest complete #questid\r\nMark all quest objectives as completed for target character active quest. After this target character can go and get quest reward.'), ('quest remove',3,'Syntax: .quest remove #quest_id\r\n\r\nSet quest #quest_id state to not completed and not active (and remove from active quest list) for selected player.'), +('quit',4,'Syntax: quit\r\n\r\nClose RA connection. Command must be typed fully (quit).'), ('recall',1,'Syntax: .recall [$playername]\r\n\r\nTeleport $playername or selected player to the place where he has been before last use of a teleportation command. If no $playername is entered and no player is selected, it will teleport you.'), ('reload all',3,'Syntax: .reload all\r\n\r\nReload all tables with reload support added and that can be _safe_ reloaded.'), ('reload all_area',3,'Syntax: .reload all_area\r\n\r\nReload all `areatrigger_*` tables if reload support added for this table and this table can be _safe_ reloaded.'), @@ -3555,6 +3556,7 @@ INSERT INTO `mangos_string` VALUES (1012,'===========================================================================',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), (1013,'|%15s| %20s | %15s |%4d| %9d |',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), (1014,'No online players.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(1015,'Used not fully typed quit command, need type it fully (quit), or command used not in RA command line.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), (1100,'Account %s (Id: %u) have up to %u expansion allowed now.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), (1101,'Message of the day changed to:\r\n%s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), (1102,'Message sent to %s: %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), diff --git a/sql/updates/8965_01_mangos_mangos_string.sql b/sql/updates/8965_01_mangos_mangos_string.sql new file mode 100644 index 000000000..19937c686 --- /dev/null +++ b/sql/updates/8965_01_mangos_mangos_string.sql @@ -0,0 +1,6 @@ +ALTER TABLE db_version CHANGE COLUMN required_8950_01_mangos_spell_proc_event required_8965_01_mangos_mangos_string bit; + +DELETE FROM mangos_string WHERE entry in (1015); + +INSERT INTO mangos_string VALUES + (1015,'Used not fully typed quit command, need type it fully (quit), or command used not in RA command line.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL); diff --git a/sql/updates/8965_02_mangos_command.sql b/sql/updates/8965_02_mangos_command.sql new file mode 100644 index 000000000..4a143e4ee --- /dev/null +++ b/sql/updates/8965_02_mangos_command.sql @@ -0,0 +1,6 @@ +ALTER TABLE db_version CHANGE COLUMN required_8965_01_mangos_mangos_string required_8965_02_mangos_command bit; + +DELETE FROM command where name IN ('quit'); + +INSERT INTO `command` VALUES +('quit',4,'Syntax: quit\r\n\r\nClose RA connection. Command must be typed fully (quit).'); diff --git a/sql/updates/Makefile.am b/sql/updates/Makefile.am index 101077bde..f4ea2d3db 100644 --- a/sql/updates/Makefile.am +++ b/sql/updates/Makefile.am @@ -198,6 +198,8 @@ pkgdata_DATA = \ 8943_01_mangos_spell_chain.sql \ 8946_01_mangos_spell_proc_event.sql \ 8950_01_mangos_spell_proc_event.sql \ + 8965_01_mangos_mangos_string.sql \ + 8965_02_mangos_command.sql \ README ## Additional files to include when running 'make dist' @@ -376,4 +378,6 @@ EXTRA_DIST = \ 8943_01_mangos_spell_chain.sql \ 8946_01_mangos_spell_proc_event.sql \ 8950_01_mangos_spell_proc_event.sql \ + 8965_01_mangos_mangos_string.sql \ + 8965_02_mangos_command.sql \ README diff --git a/src/game/Chat.cpp b/src/game/Chat.cpp index b49aab964..f510fc0e4 100644 --- a/src/game/Chat.cpp +++ b/src/game/Chat.cpp @@ -667,6 +667,7 @@ ChatCommand * ChatHandler::getCommandTable() { "flusharenapoints",SEC_ADMINISTRATOR, false, &ChatHandler::HandleFlushArenaPointsCommand, "", NULL }, { "repairitems", SEC_GAMEMASTER, true, &ChatHandler::HandleRepairitemsCommand, "", NULL }, { "waterwalk", SEC_GAMEMASTER, false, &ChatHandler::HandleWaterwalkCommand, "", NULL }, + { "quit", SEC_CONSOLE, true, &ChatHandler::HandleQuitCommand, "", NULL }, { NULL, 0, false, NULL, "", NULL } }; diff --git a/src/game/Chat.h b/src/game/Chat.h index 665696a10..84231ac11 100644 --- a/src/game/Chat.h +++ b/src/game/Chat.h @@ -498,6 +498,7 @@ class ChatHandler bool HandleFlushArenaPointsCommand(const char *args); bool HandleRepairitemsCommand(const char* args); bool HandleWaterwalkCommand(const char* args); + bool HandleQuitCommand(const char* args); //! Development Commands bool HandleSaveAllCommand(const char* args); diff --git a/src/game/Language.h b/src/game/Language.h index 9f9f7afad..986f28872 100644 --- a/src/game/Language.h +++ b/src/game/Language.h @@ -780,7 +780,8 @@ enum MangosStrings LANG_ACCOUNT_LIST_BAR = 1012, LANG_ACCOUNT_LIST_LINE = 1013, LANG_ACCOUNT_LIST_EMPTY = 1014, - // Room for more level 4 1015-1099 not used + LANG_QUIT_WRONG_USE_ERROR = 1015, + // Room for more level 4 1016-1099 not used // Level 3 (continue) LANG_ACCOUNT_SETADDON = 1100, diff --git a/src/game/MovementHandler.cpp b/src/game/MovementHandler.cpp index 4620556cd..76d6545be 100644 --- a/src/game/MovementHandler.cpp +++ b/src/game/MovementHandler.cpp @@ -238,7 +238,6 @@ void WorldSession::HandleMovementOpcodes( WorldPacket & recv_data ) ReadMovementInfo(recv_data, &movementInfo); /*----------------*/ - recv_data.rpos(recv_data.wpos()); // prevent warnings spam if (!MaNGOS::IsValidMapCoord(movementInfo.x, movementInfo.y, movementInfo.z, movementInfo.o)) { recv_data.rpos(recv_data.wpos()); // prevent warnings spam diff --git a/src/mangosd/CliRunnable.cpp b/src/mangosd/CliRunnable.cpp index d84bd79cf..a97fd7fb6 100644 --- a/src/mangosd/CliRunnable.cpp +++ b/src/mangosd/CliRunnable.cpp @@ -152,6 +152,14 @@ bool ChatHandler::HandleCharacterDeleteCommand(const char* args) return true; } +/// Close RA connection +bool ChatHandler::HandleQuitCommand(const char* /*args*/) +{ + // processed in RASocket + SendSysMessage(LANG_QUIT_WRONG_USE_ERROR); + return true; +} + /// Exit the realm bool ChatHandler::HandleServerExitCommand(const char* /*args*/) { diff --git a/src/mangosd/RASocket.cpp b/src/mangosd/RASocket.cpp index db03c6ae9..cceff509b 100644 --- a/src/mangosd/RASocket.cpp +++ b/src/mangosd/RASocket.cpp @@ -225,7 +225,10 @@ void RASocket::OnRead() if (strlen(buff)) { sLog.outRALog("Got '%s' cmd.\n",buff); - sWorld.QueueCliCommand(&RASocket::zprint , buff); + if (strncmp(buff,"quit",4)==0) + SetCloseAndDelete(); + else + sWorld.QueueCliCommand(&RASocket::zprint, buff); } else Sendf("mangos>"); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 355bad342..5b9d1f85a 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 "8964" + #define REVISION_NR "8965" #endif // __REVISION_NR_H__ diff --git a/src/shared/revision_sql.h b/src/shared/revision_sql.h index 7dfbed989..21a7eef2a 100644 --- a/src/shared/revision_sql.h +++ b/src/shared/revision_sql.h @@ -1,6 +1,6 @@ #ifndef __REVISION_SQL_H__ #define __REVISION_SQL_H__ #define REVISION_DB_CHARACTERS "required_8874_01_characters_character_skills" - #define REVISION_DB_MANGOS "required_8950_01_mangos_spell_proc_event" + #define REVISION_DB_MANGOS "required_8965_02_mangos_command" #define REVISION_DB_REALMD "required_8728_01_realmd_account" #endif // __REVISION_SQL_H__