From 40ec688b2cb1371091ee2ca01b0401f5048c38c0 Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Thu, 22 Jul 2010 08:33:26 +0400 Subject: [PATCH] [10244] Implement .stable gm command for open pet stable anywhere. Maybe command not so useful for stable case because spell can be learned, but it example how can be packet allowed depndent from player possibility when some functionality base at many packets recieved from client. Same way possible can be used for auction anywhere, maybe some other cases. Also it will very usefull for 2.x/1.x branches where no another way... ;) --- sql/mangos.sql | 3 ++- sql/updates/10244_01_mangos_command.sql | 5 +++++ sql/updates/Makefile.am | 2 ++ src/game/Chat.cpp | 1 + src/game/Chat.h | 1 + src/game/Level3.cpp | 7 +++++++ src/game/NPCHandler.cpp | 4 +++- src/game/WorldSession.h | 2 +- src/shared/revision_nr.h | 2 +- src/shared/revision_sql.h | 2 +- 10 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 sql/updates/10244_01_mangos_command.sql diff --git a/sql/mangos.sql b/sql/mangos.sql index b27c2c7af..4a85be202 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_10237_01_mangos_spell_bonus_data` bit(1) default NULL + `required_10244_01_mangos_command` bit(1) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes'; -- @@ -766,6 +766,7 @@ INSERT INTO `command` VALUES ('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.'), +('stable',3,'Syntax: .stable\r\n\r\nShow your pet stable.'), ('start',0,'Syntax: .start\r\n\r\nTeleport you to the starting area of your character.'), ('taxicheat',1,'Syntax: .taxicheat on/off\r\n\r\nTemporary grant access or remove to all taxi routes for the selected character. If no character is selected, hide or reveal all routes to you.\r\n\r\nVisited taxi nodes sill accessible after removing access.'), ('tele',1,'Syntax: .tele #location\r\n\r\nTeleport player to a given location.'), diff --git a/sql/updates/10244_01_mangos_command.sql b/sql/updates/10244_01_mangos_command.sql new file mode 100644 index 000000000..253ad6936 --- /dev/null +++ b/sql/updates/10244_01_mangos_command.sql @@ -0,0 +1,5 @@ +ALTER TABLE db_version CHANGE COLUMN required_10237_01_mangos_spell_bonus_data required_10244_01_mangos_command bit; + +DELETE FROM command WHERE name = 'stable'; +INSERT INTO command (name, security, help) VALUES +('stable',3,'Syntax: .stable\r\n\r\nShow your pet stable.'); diff --git a/sql/updates/Makefile.am b/sql/updates/Makefile.am index 966f83e83..4ee08133c 100644 --- a/sql/updates/Makefile.am +++ b/sql/updates/Makefile.am @@ -119,6 +119,7 @@ pkgdata_DATA = \ 10219_01_mangos_spell_proc_event.sql \ 10223_01_mangos_spell_proc_event.sql \ 10237_01_mangos_spell_bonus_data.sql \ + 10244_01_mangos_command.sql \ README ## Additional files to include when running 'make dist' @@ -218,4 +219,5 @@ EXTRA_DIST = \ 10219_01_mangos_spell_proc_event.sql \ 10223_01_mangos_spell_proc_event.sql \ 10237_01_mangos_spell_bonus_data.sql \ + 10244_01_mangos_command.sql \ README diff --git a/src/game/Chat.cpp b/src/game/Chat.cpp index 26f66ddfe..73f59b26b 100644 --- a/src/game/Chat.cpp +++ b/src/game/Chat.cpp @@ -701,6 +701,7 @@ ChatCommand * ChatHandler::getCommandTable() { "combatstop", SEC_GAMEMASTER, false, &ChatHandler::HandleCombatStopCommand, "", NULL }, { "flusharenapoints",SEC_ADMINISTRATOR, false, &ChatHandler::HandleFlushArenaPointsCommand, "", NULL }, { "repairitems", SEC_GAMEMASTER, true, &ChatHandler::HandleRepairitemsCommand, "", NULL }, + { "stable", SEC_ADMINISTRATOR, false, &ChatHandler::HandleStableCommand, "", NULL }, { "waterwalk", SEC_GAMEMASTER, false, &ChatHandler::HandleWaterwalkCommand, "", NULL }, { "quit", SEC_CONSOLE, true, &ChatHandler::HandleQuitCommand, "", NULL }, diff --git a/src/game/Chat.h b/src/game/Chat.h index 3e764b160..f18440aaa 100644 --- a/src/game/Chat.h +++ b/src/game/Chat.h @@ -525,6 +525,7 @@ class ChatHandler bool HandleCombatStopCommand(const char *args); bool HandleFlushArenaPointsCommand(const char *args); bool HandleRepairitemsCommand(const char* args); + bool HandleStableCommand(const char* args); bool HandleWaterwalkCommand(const char* args); bool HandleQuitCommand(const char* args); diff --git a/src/game/Level3.cpp b/src/game/Level3.cpp index d3bcbb824..b52ce0724 100644 --- a/src/game/Level3.cpp +++ b/src/game/Level3.cpp @@ -4144,6 +4144,13 @@ bool ChatHandler::HandleBankCommand(const char* /*args*/) return true; } +bool ChatHandler::HandleStableCommand(const char* /*args*/) +{ + m_session->SendStablePet(m_session->GetPlayer()->GetGUID()); + + return true; +} + bool ChatHandler::HandleChangeWeather(const char* args) { if(!*args) diff --git a/src/game/NPCHandler.cpp b/src/game/NPCHandler.cpp index 9992eb69d..e9f03b165 100644 --- a/src/game/NPCHandler.cpp +++ b/src/game/NPCHandler.cpp @@ -33,6 +33,7 @@ #include "Creature.h" #include "Pet.h" #include "Guild.h" +#include "Chat.h" enum StableResultCode { @@ -545,7 +546,8 @@ bool WorldSession::CheckStableMaster(ObjectGuid guid) // spell case or GM if (guid == GetPlayer()->GetObjectGuid()) { - if (!GetPlayer()->isGameMaster() && !GetPlayer()->HasAuraType(SPELL_AURA_OPEN_STABLE)) + // command case will return only if player have real access to command + if (!GetPlayer()->HasAuraType(SPELL_AURA_OPEN_STABLE) && !ChatHandler(GetPlayer()).FindCommand("stable")) { DEBUG_LOG("%s attempt open stable in cheating way.", guid.GetString().c_str()); return false; diff --git a/src/game/WorldSession.h b/src/game/WorldSession.h index d466008c7..dd3dbc6c4 100644 --- a/src/game/WorldSession.h +++ b/src/game/WorldSession.h @@ -232,7 +232,7 @@ class MANGOS_DLL_SPEC WorldSession //pet void SendPetNameQuery(uint64 guid, uint32 petnumber); - void SendStablePet(ObjectGuid guid ); + void SendStablePet(ObjectGuid guid); void SendStableResult(uint8 res); bool CheckStableMaster(ObjectGuid guid); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index bfd9464c8..acad5aa34 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 "10243" + #define REVISION_NR "10244" #endif // __REVISION_NR_H__ diff --git a/src/shared/revision_sql.h b/src/shared/revision_sql.h index 00cc605e5..a513bf367 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_10160_02_characters_pet_aura" - #define REVISION_DB_MANGOS "required_10237_01_mangos_spell_bonus_data" + #define REVISION_DB_MANGOS "required_10244_01_mangos_command" #define REVISION_DB_REALMD "required_10008_01_realmd_realmd_db_version" #endif // __REVISION_SQL_H__