Map local guids 6.x -> 4.3.4

Ported the following commits:
ca83e14f8b
ee1c1b97be
18e4ab6911
bf37446b3c
cb854a2b7b
This commit is contained in:
ariel-
2016-01-10 19:19:19 -03:00
parent 694c89d76d
commit b3ea9fbbe5
163 changed files with 2448 additions and 2328 deletions

View File

@@ -40,7 +40,7 @@ static size_t getCommandTableSize(const ChatCommand* commands)
if (!commands)
return 0;
size_t count = 0;
while (commands[count].Name != NULL)
while (commands[count].Name != nullptr)
count++;
return count;
}
@@ -59,7 +59,7 @@ ChatCommand* ChatHandler::getCommandTable()
// cache for commands, needed because some commands are loaded dynamically through ScriptMgr
// cache is never freed and will show as a memory leak in diagnostic tools
// can't use vector as vector storage is implementation-dependent, eg, there can be alignment gaps between elements
static ChatCommand* commandTableCache = NULL;
static ChatCommand* commandTableCache = nullptr;
if (LoadCommandTable())
{
@@ -113,7 +113,7 @@ bool ChatHandler::isAvailable(ChatCommand const& cmd) const
bool ChatHandler::HasLowerSecurity(Player* target, ObjectGuid guid, bool strong)
{
WorldSession* target_session = NULL;
WorldSession* target_session = nullptr;
uint32 target_account = 0;
if (target)
@@ -148,7 +148,7 @@ bool ChatHandler::HasLowerSecurityAccount(WorldSession* target, uint32 target_ac
else if (target_account)
target_sec = AccountMgr::GetSecurity(target_account, realmHandle.Index);
else
return true; // caller must report error for (target == NULL && target_account == 0)
return true; // caller must report error for (target == nullptr && target_account == 0)
AccountTypes target_ac_sec = AccountTypes(target_sec);
if (m_session->GetSecurity() < target_ac_sec || (strong && m_session->GetSecurity() <= target_ac_sec))
@@ -216,7 +216,7 @@ void ChatHandler::SendSysMessage(const char *str, bool escapeCharacters)
while (char* line = LineFromMessage(pos))
{
BuildChatPacket(data, CHAT_MSG_SYSTEM, LANG_UNIVERSAL, NULL, NULL, line);
BuildChatPacket(data, CHAT_MSG_SYSTEM, LANG_UNIVERSAL, nullptr, nullptr, line);
m_session->SendPacket(&data);
}
@@ -234,7 +234,7 @@ void ChatHandler::SendGlobalSysMessage(const char *str)
while (char* line = LineFromMessage(pos))
{
BuildChatPacket(data, CHAT_MSG_SYSTEM, LANG_UNIVERSAL, NULL, NULL, line);
BuildChatPacket(data, CHAT_MSG_SYSTEM, LANG_UNIVERSAL, nullptr, nullptr, line);
sWorld->SendGlobalMessage(&data);
}
@@ -252,7 +252,7 @@ void ChatHandler::SendGlobalGMSysMessage(const char *str)
while (char* line = LineFromMessage(pos))
{
BuildChatPacket(data, CHAT_MSG_SYSTEM, LANG_UNIVERSAL, NULL, NULL, line);
BuildChatPacket(data, CHAT_MSG_SYSTEM, LANG_UNIVERSAL, nullptr, nullptr, line);
sWorld->SendGlobalGMMessage(&data);
}
@@ -277,7 +277,7 @@ bool ChatHandler::ExecuteCommandInTable(ChatCommand* table, const char* text, st
while (*text == ' ') ++text;
for (uint32 i = 0; table[i].Name != NULL; ++i)
for (uint32 i = 0; table[i].Name != nullptr; ++i)
{
if (!hasStringAbbr(table[i].Name, cmd.c_str()))
continue;
@@ -285,7 +285,7 @@ bool ChatHandler::ExecuteCommandInTable(ChatCommand* table, const char* text, st
bool match = false;
if (strlen(table[i].Name) > cmd.length())
{
for (uint32 j = 0; table[j].Name != NULL; ++j)
for (uint32 j = 0; table[j].Name != nullptr; ++j)
{
if (!hasStringAbbr(table[j].Name, cmd.c_str()))
continue;
@@ -301,7 +301,7 @@ bool ChatHandler::ExecuteCommandInTable(ChatCommand* table, const char* text, st
continue;
// select subcommand from child commands list
if (table[i].ChildCommands != NULL)
if (table[i].ChildCommands != nullptr)
{
if (!ExecuteCommandInTable(table[i].ChildCommands, text, fullcmd))
{
@@ -378,14 +378,14 @@ bool ChatHandler::SetDataForCommandInTable(ChatCommand* table, char const* text,
while (*text == ' ') ++text;
for (uint32 i = 0; table[i].Name != NULL; i++)
for (uint32 i = 0; table[i].Name != nullptr; i++)
{
// for data fill use full explicit command names
if (table[i].Name != cmd)
continue;
// select subcommand from child commands list (including "")
if (table[i].ChildCommands != NULL)
if (table[i].ChildCommands != nullptr)
{
if (SetDataForCommandInTable(table[i].ChildCommands, text, permission, help, fullcommand))
return true;
@@ -521,7 +521,7 @@ Valid examples:
bool ChatHandler::ShowHelpForSubCommands(ChatCommand* table, char const* cmd, char const* subcmd)
{
std::string list;
for (uint32 i = 0; table[i].Name != NULL; ++i)
for (uint32 i = 0; table[i].Name != nullptr; ++i)
{
// must be available (ignore handler existence for show command with possible available subcommands)
if (!isAvailable(table[i]))
@@ -560,7 +560,7 @@ bool ChatHandler::ShowHelpForCommand(ChatCommand* table, const char* cmd)
{
if (*cmd)
{
for (uint32 i = 0; table[i].Name != NULL; ++i)
for (uint32 i = 0; table[i].Name != nullptr; ++i)
{
// must be available (ignore handler existence for show command with possible available subcommands)
if (!isAvailable(table[i]))
@@ -570,7 +570,7 @@ bool ChatHandler::ShowHelpForCommand(ChatCommand* table, const char* cmd)
continue;
// have subcommand
char const* subcmd = (*cmd) ? strtok(NULL, " ") : "";
char const* subcmd = (*cmd) ? strtok(nullptr, " ") : "";
if (table[i].ChildCommands && subcmd && *subcmd)
{
@@ -590,7 +590,7 @@ bool ChatHandler::ShowHelpForCommand(ChatCommand* table, const char* cmd)
}
else
{
for (uint32 i = 0; table[i].Name != NULL; ++i)
for (uint32 i = 0; table[i].Name != nullptr; ++i)
{
// must be available (ignore handler existence for show command with possible available subcommands)
if (!isAvailable(table[i]))
@@ -744,7 +744,7 @@ size_t ChatHandler::BuildChatPacket(WorldPacket& data, ChatMsg chatType, Languag
Player* ChatHandler::getSelectedPlayer()
{
if (!m_session)
return NULL;
return nullptr;
ObjectGuid selected = m_session->GetPlayer()->GetTarget();
if (!selected)
@@ -756,7 +756,7 @@ Player* ChatHandler::getSelectedPlayer()
Unit* ChatHandler::getSelectedUnit()
{
if (!m_session)
return NULL;
return nullptr;
if (Unit* selected = m_session->GetPlayer()->GetSelectedUnit())
return selected;
@@ -767,7 +767,7 @@ Unit* ChatHandler::getSelectedUnit()
WorldObject* ChatHandler::getSelectedObject()
{
if (!m_session)
return NULL;
return nullptr;
ObjectGuid guid = m_session->GetPlayer()->GetTarget();
@@ -780,7 +780,7 @@ WorldObject* ChatHandler::getSelectedObject()
Creature* ChatHandler::getSelectedCreature()
{
if (!m_session)
return NULL;
return nullptr;
return ObjectAccessor::GetCreatureOrPetOrVehicle(*m_session->GetPlayer(), m_session->GetPlayer()->GetTarget());
}
@@ -788,7 +788,7 @@ Creature* ChatHandler::getSelectedCreature()
Player* ChatHandler::getSelectedPlayerOrSelf()
{
if (!m_session)
return NULL;
return nullptr;
ObjectGuid selected = m_session->GetPlayer()->GetTarget();
if (!selected)
@@ -807,14 +807,14 @@ char* ChatHandler::extractKeyFromLink(char* text, char const* linkType, char** s
{
// skip empty
if (!text)
return NULL;
return nullptr;
// skip spaces
while (*text == ' '||*text == '\t'||*text == '\b')
++text;
if (!*text)
return NULL;
return nullptr;
// return non link case
if (text[0] != '|')
@@ -826,28 +826,28 @@ char* ChatHandler::extractKeyFromLink(char* text, char const* linkType, char** s
char* check = strtok(text, "|"); // skip color
if (!check)
return NULL; // end of data
return nullptr; // end of data
char* cLinkType = strtok(NULL, ":"); // linktype
char* cLinkType = strtok(nullptr, ":"); // linktype
if (!cLinkType)
return NULL; // end of data
return nullptr; // end of data
if (strcmp(cLinkType, linkType) != 0)
{
strtok(NULL, " "); // skip link tail (to allow continue strtok(NULL, s) use after retturn from function
strtok(nullptr, " "); // skip link tail (to allow continue strtok(nullptr, s) use after retturn from function
SendSysMessage(LANG_WRONG_LINK_TYPE);
return NULL;
return nullptr;
}
char* cKeys = strtok(NULL, "|"); // extract keys and values
char* cKeysTail = strtok(NULL, "");
char* cKeys = strtok(nullptr, "|"); // extract keys and values
char* cKeysTail = strtok(nullptr, "");
char* cKey = strtok(cKeys, ":|"); // extract key
if (something1)
*something1 = strtok(NULL, ":|"); // extract something
*something1 = strtok(nullptr, ":|"); // extract something
strtok(cKeysTail, "]"); // restart scan tail and skip name with possible spaces
strtok(NULL, " "); // skip link tail (to allow continue strtok(NULL, s) use after return from function
strtok(nullptr, " "); // skip link tail (to allow continue strtok(nullptr, s) use after return from function
return cKey;
}
@@ -855,14 +855,14 @@ char* ChatHandler::extractKeyFromLink(char* text, char const* const* linkTypes,
{
// skip empty
if (!text)
return NULL;
return nullptr;
// skip spaces
while (*text == ' '||*text == '\t'||*text == '\b')
++text;
if (!*text)
return NULL;
return nullptr;
// return non link case
if (text[0] != '|')
@@ -880,48 +880,48 @@ char* ChatHandler::extractKeyFromLink(char* text, char const* const* linkTypes,
{
char* check = strtok(text, "|"); // skip color
if (!check)
return NULL; // end of data
return nullptr; // end of data
tail = strtok(NULL, ""); // tail
tail = strtok(nullptr, ""); // tail
}
else
tail = text+1; // skip first |
char* cLinkType = strtok(tail, ":"); // linktype
if (!cLinkType)
return NULL; // end of data
return nullptr; // end of data
for (int i = 0; linkTypes[i]; ++i)
{
if (strcmp(cLinkType, linkTypes[i]) == 0)
{
char* cKeys = strtok(NULL, "|"); // extract keys and values
char* cKeysTail = strtok(NULL, "");
char* cKeys = strtok(nullptr, "|"); // extract keys and values
char* cKeysTail = strtok(nullptr, "");
char* cKey = strtok(cKeys, ":|"); // extract key
if (something1)
*something1 = strtok(NULL, ":|"); // extract something
*something1 = strtok(nullptr, ":|"); // extract something
strtok(cKeysTail, "]"); // restart scan tail and skip name with possible spaces
strtok(NULL, " "); // skip link tail (to allow continue strtok(NULL, s) use after return from function
strtok(nullptr, " "); // skip link tail (to allow continue strtok(nullptr, s) use after return from function
if (found_idx)
*found_idx = i;
return cKey;
}
}
strtok(NULL, " "); // skip link tail (to allow continue strtok(NULL, s) use after return from function
strtok(nullptr, " "); // skip link tail (to allow continue strtok(nullptr, s) use after return from function
SendSysMessage(LANG_WRONG_LINK_TYPE);
return NULL;
return nullptr;
}
GameObject* ChatHandler::GetNearbyGameObject()
{
if (!m_session)
return NULL;
return nullptr;
Player* pl = m_session->GetPlayer();
GameObject* obj = NULL;
GameObject* obj = nullptr;
Trinity::NearestGameObjectCheck check(*pl);
Trinity::GameObjectLastSearcher<Trinity::NearestGameObjectCheck> searcher(pl, obj, check);
pl->VisitNearbyGridObject(SIZE_OF_GRIDS, searcher);
@@ -931,23 +931,16 @@ GameObject* ChatHandler::GetNearbyGameObject()
GameObject* ChatHandler::GetObjectGlobalyWithGuidOrNearWithDbGuid(uint32 lowguid, uint32 entry)
{
if (!m_session)
return NULL;
return nullptr;
Player* pl = m_session->GetPlayer();
GameObject* obj = pl->GetMap()->GetGameObject(ObjectGuid(HIGHGUID_GAMEOBJECT, entry, lowguid));
GameObject* obj = pl->GetMap()->GetGameObject(ObjectGuid(HighGuid::GameObject, entry, lowguid));
if (!obj && sObjectMgr->GetGOData(lowguid)) // guid is DB guid of object
{
// search near player then
CellCoord p(Trinity::ComputeCellCoord(pl->GetPositionX(), pl->GetPositionY()));
Cell cell(p);
Trinity::GameObjectWithDbGUIDCheck go_check(*pl, lowguid);
Trinity::GameObjectSearcher<Trinity::GameObjectWithDbGUIDCheck> checker(pl, obj, go_check);
TypeContainerVisitor<Trinity::GameObjectSearcher<Trinity::GameObjectWithDbGUIDCheck>, GridTypeMapContainer > object_checker(checker);
cell.Visit(p, object_checker, *pl->GetMap(), *pl, pl->GetGridActivationRange());
auto bounds = pl->GetMap()->GetGameObjectBySpawnIdStore().equal_range(lowguid);
if (bounds.first != bounds.second)
obj = bounds.first->second;
}
return obj;
@@ -980,7 +973,7 @@ uint32 ChatHandler::extractSpellIdFromLink(char* text)
// number or [name] Shift-click form |color|Htalent:talent_id, rank|h[name]|h|r
// number or [name] Shift-click form |color|Htrade:spell_id, skill_id, max_value, cur_value|h[name]|h|r
int type = 0;
char* param1_str = NULL;
char* param1_str = nullptr;
char* idS = extractKeyFromLink(text, spellKeys, &type, &param1_str);
if (!idS)
return 0;
@@ -1028,7 +1021,7 @@ GameTele const* ChatHandler::extractGameTeleFromLink(char* text)
// id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r
char* cId = extractKeyFromLink(text, "Htele");
if (!cId)
return NULL;
return nullptr;
// id case (explicit or from shift link)
if (cId[0] >= '0' || cId[0] >= '9')
@@ -1085,7 +1078,7 @@ ObjectGuid ChatHandler::extractGuidFromLink(char* text)
uint32 lowguid = atoul(idS);
if (CreatureData const* data = sObjectMgr->GetCreatureData(lowguid))
return ObjectGuid(HIGHGUID_UNIT, data->id, lowguid);
return ObjectGuid(HighGuid::Unit, data->id, lowguid);
else
return ObjectGuid::Empty;
}
@@ -1094,7 +1087,7 @@ ObjectGuid ChatHandler::extractGuidFromLink(char* text)
uint32 lowguid = atoul(idS);
if (GameObjectData const* data = sObjectMgr->GetGOData(lowguid))
return ObjectGuid(HIGHGUID_GAMEOBJECT, data->id, lowguid);
return ObjectGuid(HighGuid::GameObject, data->id, lowguid);
else
return ObjectGuid::Empty;
}
@@ -1118,7 +1111,7 @@ std::string ChatHandler::extractPlayerNameFromLink(char* text)
return name;
}
bool ChatHandler::extractPlayerTarget(char* args, Player** player, ObjectGuid* player_guid /*=NULL*/, std::string* player_name /*= NULL*/)
bool ChatHandler::extractPlayerTarget(char* args, Player** player, ObjectGuid* player_guid /*=nullptr*/, std::string* player_name /*= nullptr*/)
{
if (args && *args)
{
@@ -1174,12 +1167,12 @@ bool ChatHandler::extractPlayerTarget(char* args, Player** player, ObjectGuid* p
void ChatHandler::extractOptFirstArg(char* args, char** arg1, char** arg2)
{
char* p1 = strtok(args, " ");
char* p2 = strtok(NULL, " ");
char* p2 = strtok(nullptr, " ");
if (!p2)
{
p2 = p1;
p1 = NULL;
p1 = nullptr;
}
if (arg1)
@@ -1192,7 +1185,7 @@ void ChatHandler::extractOptFirstArg(char* args, char** arg1, char** arg2)
char* ChatHandler::extractQuotedArg(char* args)
{
if (!*args)
return NULL;
return nullptr;
if (*args == '"')
return strtok(args+1, "\"");
@@ -1205,9 +1198,9 @@ char* ChatHandler::extractQuotedArg(char* args)
continue;
}
// return NULL if we reached the end of the string
// return nullptr if we reached the end of the string
if (!*args)
return NULL;
return nullptr;
// since we skipped all spaces, we expect another token now
if (*args == '"')
@@ -1225,7 +1218,7 @@ char* ChatHandler::extractQuotedArg(char* args)
return strtok(args + 1, "\"");
}
else
return NULL;
return nullptr;
}
}
@@ -1279,7 +1272,7 @@ bool CliHandler::needReportToTarget(Player* /*chr*/) const
bool ChatHandler::GetPlayerGroupAndGUIDByName(const char* cname, Player*& player, Group*& group, ObjectGuid& guid, bool offline)
{
player = NULL;
player = nullptr;
guid.Clear();
if (cname)