From 49c52ddf9c91ad1a882918b72df72a48a6ccec16 Mon Sep 17 00:00:00 2001 From: balrok Date: Thu, 8 Oct 2009 00:17:55 +0200 Subject: [PATCH] [8600] allow unbinding instances also per map so command can be called as .instance unbind all or .instance unbind #mapid now output also the mapname next to the mapid for the humanoid users among us ;) --- sql/mangos.sql | 4 +- sql/updates/8600_01_mangos_command.sql | 8 +++ sql/updates/Makefile.am | 2 + src/game/Level3.cpp | 69 +++++++++++++++++++------- src/shared/revision_nr.h | 2 +- src/shared/revision_sql.h | 2 +- 6 files changed, 65 insertions(+), 22 deletions(-) create mode 100644 sql/updates/8600_01_mangos_command.sql diff --git a/sql/mangos.sql b/sql/mangos.sql index ef4f2ce41..055418eeb 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_8589_10_mangos_spell_proc_event` bit(1) default NULL + `required_8600_01_mangos_command` bit(1) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes'; -- @@ -434,7 +434,7 @@ INSERT INTO `command` VALUES ('honor addkill',2,'Syntax: .honor addkikll\r\n\r\nAdd the targeted unit as one of your pvp kills today (you only get honor if it\'s a racial leader or a player)'), ('honor update',2,'Syntax: .honor update\r\n\r\nForce the yesterday\'s honor fields to be updated with today\'s data, which will get reset for the selected player.'), ('hover',3,'Syntax: .hover #flag\r\n\r\nEnable or disable hover mode for your character.\r\n\r\nUse a #flag of value 1 to enable, use a #flag value of 0 to disable hover.'), -('instance unbind',3,'Syntax: .instance unbind all\r\n All of the selected player\'s binds will be cleared.'), +('instance unbind',3,'Syntax: .instance unbind all\r\n All of the selected player\'s binds will be cleared.\r\n.instance unbind #mapid\r\n Only the specified #mapid instance will be cleared.'), ('instance listbinds',3,'Syntax: .instance listbinds\r\n Lists the binds of the selected player.'), ('instance stats',3,'Syntax: .instance stats\r\n Shows statistics about instances.'), ('instance savedata',3,'Syntax: .instance savedata\r\n Save the InstanceData for the current player\'s map to the DB.'), diff --git a/sql/updates/8600_01_mangos_command.sql b/sql/updates/8600_01_mangos_command.sql new file mode 100644 index 000000000..af77965fd --- /dev/null +++ b/sql/updates/8600_01_mangos_command.sql @@ -0,0 +1,8 @@ +ALTER TABLE db_version CHANGE COLUMN required_8589_10_mangos_spell_proc_event required_8600_01_mangos_command bit; + +DELETE FROM command where name='instance unbind'; + +INSERT INTO `command` VALUES +('instance unbind',3,'Syntax: .instance unbind all\r\n All of the selected +player\'s binds will be cleared.\r\n.instance unbind #mapid\r\n Only the +specified #mapid instance will be cleared.'); diff --git a/sql/updates/Makefile.am b/sql/updates/Makefile.am index 3295f9571..5a18403b4 100644 --- a/sql/updates/Makefile.am +++ b/sql/updates/Makefile.am @@ -129,6 +129,7 @@ pkgdata_DATA = \ 8589_10_mangos_spell_proc_event.sql \ 8589_11_characters_characters.sql \ 8596_01_characters_bugreport.sql \ + 8600_01_mangos_command.sql \ README ## Additional files to include when running 'make dist' @@ -238,4 +239,5 @@ EXTRA_DIST = \ 8589_10_mangos_spell_proc_event.sql \ 8589_11_characters_characters.sql \ 8596_01_characters_bugreport.sql \ + 8600_01_mangos_command.sql \ README diff --git a/src/game/Level3.cpp b/src/game/Level3.cpp index 3e3e65082..35164c1b7 100644 --- a/src/game/Level3.cpp +++ b/src/game/Level3.cpp @@ -5920,7 +5920,14 @@ bool ChatHandler::HandleInstanceListBindsCommand(const char* /*args*/) { InstanceSave *save = itr->second.save; std::string timeleft = GetTimeString(save->GetResetTime() - time(NULL)); - PSendSysMessage("map: %d inst: %d perm: %s diff: %s canReset: %s TTR: %s", itr->first, save->GetInstanceId(), itr->second.perm ? "yes" : "no", save->GetDifficulty() == DUNGEON_DIFFICULTY_NORMAL ? "normal" : "heroic", save->CanReset() ? "yes" : "no", timeleft.c_str()); + if (const MapEntry* entry = sMapStore.LookupEntry(itr->first)) + { + PSendSysMessage("map: %d (%s) inst: %d perm: %s diff: %s canReset: %s TTR: %s", + itr->first, entry->name[m_session->GetSessionDbcLocale()], save->GetInstanceId(), itr->second.perm ? "yes" : "no", + save->GetDifficulty() == DUNGEON_DIFFICULTY_NORMAL ? "normal" : "heroic", save->CanReset() ? "yes" : "no", timeleft.c_str()); + } + else + PSendSysMessage("bound for a nonexistant map %u", itr->first); counter++; } } @@ -5936,7 +5943,14 @@ bool ChatHandler::HandleInstanceListBindsCommand(const char* /*args*/) { InstanceSave *save = itr->second.save; std::string timeleft = GetTimeString(save->GetResetTime() - time(NULL)); - PSendSysMessage("map: %d inst: %d perm: %s diff: %s canReset: %s TTR: %s", itr->first, save->GetInstanceId(), itr->second.perm ? "yes" : "no", save->GetDifficulty() == DUNGEON_DIFFICULTY_NORMAL ? "normal" : "heroic", save->CanReset() ? "yes" : "no", timeleft.c_str()); + if (const MapEntry* entry = sMapStore.LookupEntry(itr->first)) + { + PSendSysMessage("map: %d (%s) inst: %d perm: %s diff: %s canReset: %s TTR: %s", + itr->first, entry->name[m_session->GetSessionDbcLocale()], save->GetInstanceId(), itr->second.perm ? "yes" : "no", + save->GetDifficulty() == DUNGEON_DIFFICULTY_NORMAL ? "normal" : "heroic", save->CanReset() ? "yes" : "no", timeleft.c_str()); + } + else + PSendSysMessage("bound for a nonexistant map %u", itr->first); counter++; } } @@ -5951,31 +5965,50 @@ bool ChatHandler::HandleInstanceUnbindCommand(const char* args) if(!*args) return false; - std::string cmd = args; - if(cmd == "all") + Player* player = getSelectedPlayer(); + if (!player) + player = m_session->GetPlayer(); + uint32 counter = 0; + uint32 mapid = 0; + bool got_map = false; + + if (args != "all") { - Player* player = getSelectedPlayer(); - if (!player) player = m_session->GetPlayer(); - uint32 counter = 0; - for(uint8 i = 0; i < MAX_DIFFICULTY; ++i) + got_map = true; + mapid = atoi(args); + } + + for(uint8 i = 0; i < MAX_DIFFICULTY; ++i) + { + Player::BoundInstancesMap &binds = player->GetBoundInstances(Difficulty(i)); + for(Player::BoundInstancesMap::iterator itr = binds.begin(); itr != binds.end();) { - Player::BoundInstancesMap &binds = player->GetBoundInstances(Difficulty(i)); - for(Player::BoundInstancesMap::iterator itr = binds.begin(); itr != binds.end();) + if (got_map && mapid != itr->first) { - if(itr->first != player->GetMapId()) + ++itr; + continue; + } + if(itr->first != player->GetMapId()) + { + InstanceSave *save = itr->second.save; + std::string timeleft = GetTimeString(save->GetResetTime() - time(NULL)); + + if (const MapEntry* entry = sMapStore.LookupEntry(itr->first)) { - InstanceSave *save = itr->second.save; - std::string timeleft = GetTimeString(save->GetResetTime() - time(NULL)); - PSendSysMessage("unbinding map: %d inst: %d perm: %s diff: %s canReset: %s TTR: %s", itr->first, save->GetInstanceId(), itr->second.perm ? "yes" : "no", save->GetDifficulty() == DUNGEON_DIFFICULTY_NORMAL ? "normal" : "heroic", save->CanReset() ? "yes" : "no", timeleft.c_str()); - player->UnbindInstance(itr, Difficulty(i)); - counter++; + PSendSysMessage("unbinding map: %d (%s) inst: %d perm: %s diff: %s canReset: %s TTR: %s", + itr->first, entry->name[m_session->GetSessionDbcLocale()], save->GetInstanceId(), itr->second.perm ? "yes" : "no", + save->GetDifficulty() == DUNGEON_DIFFICULTY_NORMAL ? "normal" : "heroic", save->CanReset() ? "yes" : "no", timeleft.c_str()); } else - ++itr; + PSendSysMessage("bound for a nonexistant map %u", itr->first); + player->UnbindInstance(itr, Difficulty(i)); + counter++; } + else + ++itr; } - PSendSysMessage("instances unbound: %d", counter); } + PSendSysMessage("instances unbound: %d", counter); return true; } diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 32c85f480..94f860d26 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 "8599" + #define REVISION_NR "8600" #endif // __REVISION_NR_H__ diff --git a/src/shared/revision_sql.h b/src/shared/revision_sql.h index a58fe07e0..93bae364c 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_8596_01_characters_bugreport" - #define REVISION_DB_MANGOS "required_8589_10_mangos_spell_proc_event" + #define REVISION_DB_MANGOS "required_8600_01_mangos_command" #define REVISION_DB_REALMD "required_8332_01_realmd_realmcharacters" #endif // __REVISION_SQL_H__