aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreeston <treeston.mmoc@gmail.com>2018-08-30 20:17:27 +0200
committerTreeston <treeston.mmoc@gmail.com>2018-08-30 20:17:51 +0200
commit6a0870a9993f5a1016439644d4a9ab3fd89277e5 (patch)
tree2407c5578dfc196c0144be189b88e8998133a8c9
parentc78f454c0ee74000ab7f77463e8b44ff7480fdec (diff)
Scripts/Commands: New command ".go instance". Goes to an instance.
-rw-r--r--sql/base/auth_database.sql4
-rw-r--r--sql/updates/auth/3.3.5/2018_08_30_00_auth.sql9
-rw-r--r--sql/updates/world/3.3.5/2018_08_30_02_world.sql6
-rw-r--r--src/server/game/Accounts/RBAC.h1
-rw-r--r--src/server/game/Globals/ObjectMgr.h1
-rw-r--r--src/server/scripts/Commands/cs_go.cpp117
6 files changed, 137 insertions, 1 deletions
diff --git a/sql/base/auth_database.sql b/sql/base/auth_database.sql
index 22c3ae3ef74..53d407aa651 100644
--- a/sql/base/auth_database.sql
+++ b/sql/base/auth_database.sql
@@ -965,6 +965,7 @@ INSERT INTO `rbac_linked_permissions` VALUES
(198,760),
(198,852),
(198,855),
+(198,874),
(199,217),
(199,221),
(199,222),
@@ -1664,7 +1665,8 @@ INSERT INTO `rbac_permissions` VALUES
(870,'Command: debug threatinfo'),
(871,'Command: debug instancespawn'),
(872,'Command: server debug'),
-(873,'Command: reload creature_movement_override');
+(873,'Command: reload creature_movement_override'),
+(874,'Command: go instance');
/*!40000 ALTER TABLE `rbac_permissions` ENABLE KEYS */;
UNLOCK TABLES;
diff --git a/sql/updates/auth/3.3.5/2018_08_30_00_auth.sql b/sql/updates/auth/3.3.5/2018_08_30_00_auth.sql
new file mode 100644
index 00000000000..1ee1f8d7ee4
--- /dev/null
+++ b/sql/updates/auth/3.3.5/2018_08_30_00_auth.sql
@@ -0,0 +1,9 @@
+--
+DELETE FROM `rbac_permissions` WHERE `id`=874;
+INSERT INTO `rbac_permissions` (`id`,`name`) VALUES
+(874, "Command: go instance");
+
+SET @parent := (SELECT `id` FROM `rbac_linked_permissions` WHERE `linkedId`=852);
+DELETE FROM `rbac_linked_permissions` WHERE `linkedId`=874;
+INSERT INTO `rbac_linked_permissions` (`id`,`linkedId`) VALUES
+(@parent, 874);
diff --git a/sql/updates/world/3.3.5/2018_08_30_02_world.sql b/sql/updates/world/3.3.5/2018_08_30_02_world.sql
new file mode 100644
index 00000000000..d8b3b9c4b10
--- /dev/null
+++ b/sql/updates/world/3.3.5/2018_08_30_02_world.sql
@@ -0,0 +1,6 @@
+--
+DELETE FROM `command` WHERE `name`="go instance";
+INSERT INTO `command` (`name`,`permission`,`help`) VALUES
+('go instance', 874, 'Syntax: .go instance [mapid | name]
+
+Teleports you to entrance of instance with script name matching input (or given mapid)');
diff --git a/src/server/game/Accounts/RBAC.h b/src/server/game/Accounts/RBAC.h
index 522ab23f330..865b45d3625 100644
--- a/src/server/game/Accounts/RBAC.h
+++ b/src/server/game/Accounts/RBAC.h
@@ -779,6 +779,7 @@ enum RBACPermissions
RBAC_PERM_COMMAND_DEBUG_INSTANCESPAWN = 871,
RBAC_PERM_COMMAND_SERVER_DEBUG = 872,
RBAC_PERM_COMMAND_RELOAD_CREATURE_MOVEMENT_OVERRIDE = 873,
+ RBAC_PERM_COMMAND_GO_INSTANCE = 874,
//
// IF YOU ADD NEW PERMISSIONS, ADD THEM IN MASTER BRANCH AS WELL!
//
diff --git a/src/server/game/Globals/ObjectMgr.h b/src/server/game/Globals/ObjectMgr.h
index dbbdefc9874..ee423badea8 100644
--- a/src/server/game/Globals/ObjectMgr.h
+++ b/src/server/game/Globals/ObjectMgr.h
@@ -957,6 +957,7 @@ class TC_GAME_API ObjectMgr
return nullptr;
}
+ InstanceTemplateContainer const& GetInstanceTemplates() const { return _instanceTemplateStore; }
InstanceTemplate const* GetInstanceTemplate(uint32 mapId) const;
PetLevelInfo const* GetPetLevelInfo(uint32 creature_id, uint8 level) const;
diff --git a/src/server/scripts/Commands/cs_go.cpp b/src/server/scripts/Commands/cs_go.cpp
index a3d4c6f13c9..87f48eff658 100644
--- a/src/server/scripts/Commands/cs_go.cpp
+++ b/src/server/scripts/Commands/cs_go.cpp
@@ -53,6 +53,7 @@ public:
{ "xyz", rbac::RBAC_PERM_COMMAND_GO_XYZ, false, &HandleGoXYZCommand, "" },
{ "ticket", rbac::RBAC_PERM_COMMAND_GO_TICKET, false, &HandleGoTicketCommand, "" },
{ "offset", rbac::RBAC_PERM_COMMAND_GO_OFFSET, false, &HandleGoOffsetCommand, "" },
+ { "instance", rbac::RBAC_PERM_COMMAND_GO_INSTANCE, false, &HandleGoInstanceCommand, "" }
};
static std::vector<ChatCommand> commandTable =
@@ -556,6 +557,122 @@ public:
player->TeleportTo(player->GetMapId(), x, y, z, o);
return true;
}
+
+ static bool HandleGoInstanceCommand(ChatHandler* handler, char const* args)
+ {
+ if (!*args)
+ return false;
+
+ std::vector<std::string> labels;
+
+ // tokenize and convert to lowercase
+ char* pos = const_cast<char*>(args);
+ char* last = nullptr;
+ do
+ {
+ if (*pos == ' ')
+ {
+ if (last)
+ {
+ *pos = '\0';
+ labels.emplace_back(last);
+ last = nullptr;
+ }
+ }
+ else
+ {
+ if (!last)
+ last = pos;
+ *pos = tolower(*pos);
+ }
+ } while (*++pos);
+ if (last)
+ labels.emplace_back(last);
+ // tokenizing done
+
+ uint32 mapid = 0;
+ if (labels.size() == 1)
+ {
+ try { mapid = std::stoi(labels[0]); }
+ catch (...) {}
+ }
+
+ if (!mapid)
+ {
+ std::multimap<uint32, std::pair<uint16, std::string>> matches;
+ for (auto const& pair : sObjectMgr->GetInstanceTemplates())
+ {
+ uint32 count = 0;
+ std::string const& scriptName = sObjectMgr->GetScriptName(pair.second.ScriptId);
+ for (std::string const& label : labels)
+ if (scriptName.find(label) != std::string::npos)
+ ++count;
+
+ if (count)
+ matches.emplace(count, decltype(matches)::mapped_type({ pair.first, scriptName }));
+ }
+ if (matches.empty())
+ {
+ handler->SendSysMessage("No matches found for your input");
+ return false;
+ }
+ auto it = matches.rbegin();
+ uint32 maxCount = it->first;
+ mapid = it->second.first;
+ if (++it != matches.rend() && it->first == maxCount)
+ {
+ handler->SendSysMessage("Multiple matches found for your input - please specify:");
+ --it;
+ do
+ handler->PSendSysMessage("* Map %03u: '%s'", it->second.first, it->second.second);
+ while (++it != matches.rend() && it->first == maxCount);
+ handler->SetSentErrorMessage(true);
+ return false;
+ }
+ }
+
+ ASSERT(mapid);
+
+ InstanceTemplate const* temp = sObjectMgr->GetInstanceTemplate(mapid);
+ if (!temp)
+ {
+ handler->PSendSysMessage("Map %u is not instanced", mapid);
+ handler->SetSentErrorMessage(true);
+ return false;
+ }
+ std::string const& scriptname = sObjectMgr->GetScriptName(temp->ScriptId);
+
+ AreaTrigger const* entrance = sObjectMgr->GetMapEntranceTrigger(mapid);
+ if (!entrance)
+ {
+ handler->PSendSysMessage("Could not find entrance for instance %u (%s)", mapid, scriptname);
+ handler->SetSentErrorMessage(true);
+ return false;
+ }
+
+ Player* player = handler->GetSession()->GetPlayer();
+ if (player->IsInFlight())
+ player->FinishTaxiFlight();
+ else
+ player->SaveRecallPosition();
+
+ if (player->TeleportTo(entrance->target_mapId, entrance->target_X, entrance->target_Y, entrance->target_Z, entrance->target_Orientation))
+ handler->PSendSysMessage("Teleported you to entrance of mapid %u (%s)", mapid, scriptname);
+ else
+ {
+ AreaTrigger const* exit = sObjectMgr->GetGoBackTrigger(mapid);
+ if (player->TeleportTo(exit->target_mapId, exit->target_X, exit->target_Y, exit->target_Z, exit->target_Orientation + M_PI))
+ handler->PSendSysMessage("Teleported you in front of entrance to mapid %u (%s)", mapid, scriptname);
+ else
+ {
+ handler->PSendSysMessage("Failed to teleport you to entrance of mapid %u (%s) - missing attunement/expansion for parent map?", mapid, scriptname);
+ handler->SetSentErrorMessage(true);
+ return false;
+ }
+ }
+
+ return true;
+ }
};
void AddSC_go_commandscript()