aboutsummaryrefslogtreecommitdiff
path: root/src/server/game
diff options
context:
space:
mode:
authorRochet2 <rochet2@post.com>2017-03-11 12:29:37 +0100
committerShauren <shauren.trinity@gmail.com>2017-03-11 12:29:37 +0100
commit80cf4e3070dd099e19f5b303f7eeaf0475b8acd6 (patch)
tree36135f45483f434cc546bdf667092aa345b7b2e5 /src/server/game
parent6067d19dfc43f40590a2052d3ce9b75a14920aa3 (diff)
* Scripts/Commands: Fix guid usage and enhance commands
- Fix targeting gameobjects and creatures for .dist and .gps. The old code used DB guid to search from core generated guid lists. - Fix some error messages saying 'no player found' even if creatures and gameobjects and players were searched - Change atoi to atoul when receiving lowguids as string or other uint32 values - Use ObjectGuid::LowType instead of uint32 for lowguid type - Allow .gob info to take in gameobject guid link as well as entry link in addition to gameobject entry and update the documentation of the command - Change .gob delete to post the spawnid (dbguid) instead of the ingame generated guid (which is basically never seen or used by the player in any other commands that I see) - Allow spawntimesecs to be negative when spawning a gameobject - Disable searching by ingame spawn id in commands. (it makes little sense for a user to provide a number which is then attempted to be used as DB guid and non DB guid when both could have a match) - Update .gob turn documentation to tell about possibility to provide orientation in command - Correct the types in .gob add command result trinity_string - Correct the creature search for .npc del - Change .event to .event info - Add .go offset command - Remove the .go command for empty string (no subcommand given) because it just used .go xyz - Extend .gob info to show size, faction, flags and model dimensions - Remove some unnecessary casts - Document .wp show better (first and last were not documented) - Insert spawnid to .wp show info error message - Fix spawntime printing for .gobject target - Fix guid targetting for .npc set movetype - Fix query by spawnid for .wp show info - Fix deleting of existing waypoints when twice doing the command .wp show on - Fix deleting of existing waypoints when doing the command .wp show off - Change wpguid column in DB and in core to uint32, which is what the spawnid type is in core and db. Closes #18978
Diffstat (limited to 'src/server/game')
-rw-r--r--src/server/game/Accounts/RBAC.h1
-rw-r--r--src/server/game/Chat/Chat.cpp78
-rw-r--r--src/server/game/Chat/Chat.h5
-rw-r--r--src/server/game/Miscellaneous/Language.h5
4 files changed, 49 insertions, 40 deletions
diff --git a/src/server/game/Accounts/RBAC.h b/src/server/game/Accounts/RBAC.h
index 9fd7d4d3a70..efeb3d93465 100644
--- a/src/server/game/Accounts/RBAC.h
+++ b/src/server/game/Accounts/RBAC.h
@@ -756,6 +756,7 @@ enum RBACPermissions
RBAC_PERM_COMMAND_LIST_SCENES = 849,
RBAC_PERM_COMMAND_RELOAD_SCENE_TEMPLATE = 850,
RBAC_PERM_COMMAND_RELOAD_AREATRIGGER_TEMPLATE = 851,
+ RBAC_PERM_COMMAND_GO_OFFSET = 852,
// custom permissions 1000+
RBAC_PERM_MAX
diff --git a/src/server/game/Chat/Chat.cpp b/src/server/game/Chat/Chat.cpp
index 3bbe05dd813..88c718c19e7 100644
--- a/src/server/game/Chat/Chat.cpp
+++ b/src/server/game/Chat/Chat.cpp
@@ -770,25 +770,30 @@ GameObject* ChatHandler::GetNearbyGameObject()
return obj;
}
-GameObject* ChatHandler::GetObjectGlobalyWithGuidOrNearWithDbGuid(ObjectGuid::LowType lowguid, uint32 entry)
+GameObject* ChatHandler::GetObjectFromPlayerMapByDbGuid(ObjectGuid::LowType lowguid)
{
if (!m_session)
return nullptr;
+ auto bounds = m_session->GetPlayer()->GetMap()->GetGameObjectBySpawnIdStore().equal_range(lowguid);
+ if (bounds.first != bounds.second)
+ return bounds.first->second;
+ return nullptr;
+}
- Player* pl = m_session->GetPlayer();
-
- GameObject* obj = pl->GetMap()->GetGameObject(ObjectGuid::Create<HighGuid::GameObject>(pl->GetMapId(), entry, lowguid));
-
- if (!obj && sObjectMgr->GetGOData(lowguid)) // guid is DB guid of object
+Creature* ChatHandler::GetCreatureFromPlayerMapByDbGuid(ObjectGuid::LowType lowguid)
+{
+ if (!m_session)
+ return nullptr;
+ // Select the first alive creature or a dead one if not found
+ Creature* creature = nullptr;
+ auto bounds = m_session->GetPlayer()->GetMap()->GetCreatureBySpawnIdStore().equal_range(lowguid);
+ for (auto it = bounds.first; it != bounds.second; ++it)
{
- auto bounds = pl->GetMap()->GetGameObjectBySpawnIdStore().equal_range(lowguid);
- if (bounds.first == bounds.second)
- return nullptr;
-
- return bounds.first->second;
+ creature = it->second;
+ if (it->second->IsAlive())
+ break;
}
-
- return obj;
+ return creature;
}
enum SpellLinkType
@@ -874,9 +879,9 @@ GameTele const* ChatHandler::extractGameTeleFromLink(char* text)
enum GuidLinkType
{
- SPELL_LINK_PLAYER = 0, // must be first for selection in not link case
- SPELL_LINK_CREATURE = 1,
- SPELL_LINK_GAMEOBJECT = 2
+ GUID_LINK_PLAYER = 0, // must be first for selection in not link case
+ GUID_LINK_CREATURE = 1,
+ GUID_LINK_GAMEOBJECT = 2
};
static char const* const guidKeys[] =
@@ -887,7 +892,7 @@ static char const* const guidKeys[] =
nullptr
};
-ObjectGuid ChatHandler::extractGuidFromLink(char* text)
+ObjectGuid::LowType ChatHandler::extractLowGuidFromLink(char* text, HighGuid& guidHigh)
{
int type = 0;
@@ -896,43 +901,42 @@ ObjectGuid ChatHandler::extractGuidFromLink(char* text)
// |color|Hplayer:name|h[name]|h|r
char* idS = extractKeyFromLink(text, guidKeys, &type);
if (!idS)
- return ObjectGuid::Empty;
+ return 0;
switch (type)
{
- case SPELL_LINK_PLAYER:
+ case GUID_LINK_PLAYER:
{
+ guidHigh = HighGuid::Player;
std::string name = idS;
if (!normalizePlayerName(name))
- return ObjectGuid::Empty;
+ return 0;
if (Player* player = ObjectAccessor::FindPlayerByName(name))
- return player->GetGUID();
+ return player->GetGUID().GetCounter();
+
+ ObjectGuid guid = ObjectMgr::GetPlayerGUIDByName(name);
+ if (guid.IsEmpty())
+ return 0;
- return ObjectMgr::GetPlayerGUIDByName(name);
+ return guid.GetCounter();
}
- case SPELL_LINK_CREATURE:
+ case GUID_LINK_CREATURE:
{
- ObjectGuid::LowType lowguid = strtoull(idS, nullptr, 10);
-
- if (CreatureData const* data = sObjectMgr->GetCreatureData(lowguid))
- return ObjectGuid::Create<HighGuid::Creature>(data->mapid, data->id, lowguid);
- else
- return ObjectGuid::Empty;
+ guidHigh = HighGuid::Creature;
+ ObjectGuid::LowType lowguid = atoull(idS);
+ return lowguid;
}
- case SPELL_LINK_GAMEOBJECT:
+ case GUID_LINK_GAMEOBJECT:
{
- ObjectGuid::LowType lowguid = strtoull(idS, nullptr, 10);
-
- if (GameObjectData const* data = sObjectMgr->GetGOData(lowguid))
- return ObjectGuid::Create<HighGuid::GameObject>(data->mapid, data->id, lowguid);
- else
- return ObjectGuid::Empty;
+ guidHigh = HighGuid::GameObject;
+ ObjectGuid::LowType lowguid = atoull(idS);
+ return lowguid;
}
}
// unknown type?
- return ObjectGuid::Empty;
+ return 0;
}
std::string ChatHandler::extractPlayerNameFromLink(char* text)
diff --git a/src/server/game/Chat/Chat.h b/src/server/game/Chat/Chat.h
index dfadccfaa91..697a92e65bb 100644
--- a/src/server/game/Chat/Chat.h
+++ b/src/server/game/Chat/Chat.h
@@ -123,7 +123,7 @@ class TC_GAME_API ChatHandler
char* extractQuotedArg(char* args);
uint32 extractSpellIdFromLink(char* text);
- ObjectGuid extractGuidFromLink(char* text);
+ ObjectGuid::LowType extractLowGuidFromLink(char* text, HighGuid& guidHigh);
GameTele const* extractGameTeleFromLink(char* text);
bool GetPlayerGroupAndGUIDByName(const char* cname, Player*& player, Group*& group, ObjectGuid& guid, bool offline = false);
std::string extractPlayerNameFromLink(char* text);
@@ -134,7 +134,8 @@ class TC_GAME_API ChatHandler
std::string GetNameLink(Player* chr) const;
GameObject* GetNearbyGameObject();
- GameObject* GetObjectGlobalyWithGuidOrNearWithDbGuid(ObjectGuid::LowType lowguid, uint32 entry);
+ GameObject* GetObjectFromPlayerMapByDbGuid(ObjectGuid::LowType lowguid);
+ Creature* GetCreatureFromPlayerMapByDbGuid(ObjectGuid::LowType lowguid);
bool HasSentErrorMessage() const { return sentErrorMessage; }
void SetSentErrorMessage(bool val){ sentErrorMessage = val; }
diff --git a/src/server/game/Miscellaneous/Language.h b/src/server/game/Miscellaneous/Language.h
index a9a6832e8db..e27e389cefc 100644
--- a/src/server/game/Miscellaneous/Language.h
+++ b/src/server/game/Miscellaneous/Language.h
@@ -114,7 +114,10 @@ enum TrinityStrings
LANG_PVPSTATS_DISABLED = 81,
LANG_COMMAND_NEARGRAVEYARD = 82,
LANG_COMMAND_NEARGRAVEYARD_NOTFOUND = 83,
- // Free 84 - 95
+ LANG_GOINFO_SIZE = 84,
+ LANG_GOINFO_ADDON = 85,
+ LANG_GOINFO_MODEL = 86,
+ // Free 87 - 95
LANG_GUILD_RENAME_ALREADY_EXISTS = 96,