aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShocker <none@none>2010-09-05 04:03:02 +0300
committerShocker <none@none>2010-09-05 04:03:02 +0300
commitf769e88f5c4f76e4f7ce98ccde3e9d3e007bd3c5 (patch)
tree5b20872fcd87ed6f8f64e66f86dec885ee641fd1
parentadf1ae62866ece2f78616829b9a2f81769338b97 (diff)
Core/Commands: Implement possibility to unbind specific maps/difficulties with .instance unbind, based on svetilo12's idea, closes issue 3792
--HG-- branch : trunk
-rw-r--r--sql/base/world_database.sql2
-rw-r--r--sql/updates/9768_world_command.sql3
-rw-r--r--src/server/game/Chat/Commands/Level3.cpp50
3 files changed, 34 insertions, 21 deletions
diff --git a/sql/base/world_database.sql b/sql/base/world_database.sql
index 82e8840a920..4d77a07a18d 100644
--- a/sql/base/world_database.sql
+++ b/sql/base/world_database.sql
@@ -436,7 +436,7 @@ INSERT INTO `command` VALUES
('instance listbinds',3,'Syntax: .instance listbinds\r\n Lists the binds of the selected player.'),
('instance savedata',3,'Syntax: .instance savedata\r\n Save the InstanceData for the current player''s map to the DB.'),
('instance stats',3,'Syntax: .instance stats\r\n Shows statistics about instances.'),
-('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 <mapid|all> [difficulty]\r\n Clear all/some of player\'s binds'),
('itemmove',2,'Syntax: .itemmove #sourceslotid #destinationslotid\r\n\r\nMove an item from slots #sourceslotid to #destinationslotid in your inventory\r\n\r\nNot yet implemented'),
('kick',2,'Syntax: .kick [$charactername] [$reason]\r\n\r\nKick the given character name from the world with or without reason. If no character name is provided then the selected player (except for yourself) will be kicked. If no reason is provided, default is \"No Reason\".'),
('learn',3,'Syntax: .learn #spell [all]\r\n\r\nSelected character learn a spell of id #spell. If ''all'' provided then all ranks learned.'),
diff --git a/sql/updates/9768_world_command.sql b/sql/updates/9768_world_command.sql
new file mode 100644
index 00000000000..b9b88adbcf7
--- /dev/null
+++ b/sql/updates/9768_world_command.sql
@@ -0,0 +1,3 @@
+DELETE FROM `command` WHERE `name` LIKE 'instance unbind';
+INSERT INTO `command` (`name`,`security`,`help`) VALUES
+('instance unbind',3,'Syntax: .instance unbind <mapid|all> [difficulty]\r\n Clear all/some of player\'s binds');
diff --git a/src/server/game/Chat/Commands/Level3.cpp b/src/server/game/Chat/Commands/Level3.cpp
index 66e18011033..54206226890 100644
--- a/src/server/game/Chat/Commands/Level3.cpp
+++ b/src/server/game/Chat/Commands/Level3.cpp
@@ -6588,7 +6588,8 @@ 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: %d canReset: %s TTR: %s", itr->first, save->GetInstanceId(), itr->second.perm ? "yes" : "no", save->GetDifficulty(), save->CanReset() ? "yes" : "no", timeleft.c_str()); counter++;
+ PSendSysMessage("map: %d inst: %d perm: %s diff: %d canReset: %s TTR: %s", itr->first, save->GetInstanceId(), itr->second.perm ? "yes" : "no", save->GetDifficulty(), save->CanReset() ? "yes" : "no", timeleft.c_str());
+ counter++;
}
}
}
@@ -6602,31 +6603,40 @@ 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();
+
+ char* pMap = strtok((char*)args, " ");
+ char* pDiff = strtok(NULL, " ");
+ int8 diff = -1;
+ if (pDiff)
+ diff = atoi(pDiff);
+ uint16 counter = 0;
+ int16 MapId = 0;
+
+ if (strcmp(pMap, "all"))
+ if (!(MapId = atoi(pMap)))
+ return false;
+
+ for(uint8 i = 0; i < MAX_DIFFICULTY; ++i)
{
- Player* player = getSelectedPlayer();
- if (!player) player = m_session->GetPlayer();
- uint32 counter = 0;
- 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();)
+ InstanceSave *save = itr->second.save;
+ if(itr->first != player->GetMapId() && (!MapId || MapId == itr->first) && (diff == -1 || diff == save->GetDifficulty()))
{
- if (itr->first != player->GetMapId())
- {
- InstanceSave *save = itr->second.save;
- std::string timeleft = GetTimeString(save->GetResetTime() - time(NULL));
- PSendSysMessage("unbinding map: %d inst: %d perm: %s diff: %d canReset: %s TTR: %s", itr->first, save->GetInstanceId(), itr->second.perm ? "yes" : "no", save->GetDifficulty(), save->CanReset() ? "yes" : "no", timeleft.c_str());
- player->UnbindInstance(itr, Difficulty(i));
- counter++;
- }
- else
- ++itr;
+ std::string timeleft = GetTimeString(save->GetResetTime() - time(NULL));
+ PSendSysMessage("unbinding map: %d inst: %d perm: %s diff: %d canReset: %s TTR: %s", itr->first, save->GetInstanceId(), itr->second.perm ? "yes" : "no", save->GetDifficulty(), save->CanReset() ? "yes" : "no", timeleft.c_str());
+ player->UnbindInstance(itr, Difficulty(i));
+ counter++;
}
+ else
+ ++itr;
}
- PSendSysMessage("instances unbound: %d", counter);
}
+ PSendSysMessage("instances unbound: %d", counter);
return true;
}