mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 16:37:01 +00:00
[7219] Improvements ins shift-links work.
* Implement support 'Hplayer' link type. Mostly as player name highlights in command messages. * Support shift-links parsing withoyt '|c' color prefix * Many related code cleanups.
This commit is contained in:
parent
a26f327314
commit
4039fa8a4a
6 changed files with 284 additions and 224 deletions
|
|
@ -1788,13 +1788,11 @@ bool ChatHandler::HandleLearnAllLangCommand(const char* /*args*/)
|
|||
|
||||
bool ChatHandler::HandleLearnAllDefaultCommand(const char* args)
|
||||
{
|
||||
char* pName = strtok((char*)args, "");
|
||||
Player *player = NULL;
|
||||
if (pName)
|
||||
if (*args)
|
||||
{
|
||||
std::string name = pName;
|
||||
|
||||
if(!normalizePlayerName(name))
|
||||
std::string name = extractPlayerNameFromLink((char*)args);
|
||||
if(name.empty())
|
||||
{
|
||||
SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
SetSentErrorMessage(true);
|
||||
|
|
@ -1816,7 +1814,9 @@ bool ChatHandler::HandleLearnAllDefaultCommand(const char* args)
|
|||
player->learnDefaultSpells();
|
||||
player->learnQuestRewardedSpells();
|
||||
|
||||
PSendSysMessage(LANG_COMMAND_LEARN_ALL_DEFAULT_AND_QUEST,player->GetName());
|
||||
std::string nameLink = playerLink(player->GetName());
|
||||
|
||||
PSendSysMessage(LANG_COMMAND_LEARN_ALL_DEFAULT_AND_QUEST,nameLink.c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -3064,11 +3064,11 @@ bool ChatHandler::HandleGuildInviteCommand(const char *args)
|
|||
if (!targetGuild)
|
||||
return false;
|
||||
|
||||
std::string plName = par1;
|
||||
if (!normalizePlayerName (plName))
|
||||
std::string plName = extractPlayerNameFromLink(par1);
|
||||
if(plName.empty())
|
||||
{
|
||||
SendSysMessage (LANG_PLAYER_NOT_FOUND);
|
||||
SetSentErrorMessage (true);
|
||||
SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -3076,7 +3076,7 @@ bool ChatHandler::HandleGuildInviteCommand(const char *args)
|
|||
if (Player* targetPlayer = ObjectAccessor::Instance ().FindPlayerByName (plName.c_str ()))
|
||||
plGuid = targetPlayer->GetGUID ();
|
||||
else
|
||||
plGuid = objmgr.GetPlayerGUIDByName (plName.c_str ());
|
||||
plGuid = objmgr.GetPlayerGUIDByName (plName);
|
||||
|
||||
if (!plGuid)
|
||||
false;
|
||||
|
|
@ -3097,11 +3097,11 @@ bool ChatHandler::HandleGuildUninviteCommand(const char *args)
|
|||
if(!par1)
|
||||
return false;
|
||||
|
||||
std::string plName = par1;
|
||||
if (!normalizePlayerName (plName))
|
||||
std::string plName = extractPlayerNameFromLink(par1);
|
||||
if(plName.empty())
|
||||
{
|
||||
SendSysMessage (LANG_PLAYER_NOT_FOUND);
|
||||
SetSentErrorMessage (true);
|
||||
SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -3114,7 +3114,7 @@ bool ChatHandler::HandleGuildUninviteCommand(const char *args)
|
|||
}
|
||||
else
|
||||
{
|
||||
plGuid = objmgr.GetPlayerGUIDByName (plName.c_str ());
|
||||
plGuid = objmgr.GetPlayerGUIDByName (plName);
|
||||
glId = Player::GetGuildIdFromDB (plGuid);
|
||||
}
|
||||
|
||||
|
|
@ -3139,14 +3139,16 @@ bool ChatHandler::HandleGuildRankCommand(const char *args)
|
|||
char* par2 = strtok (NULL, " ");
|
||||
if (!par1 || !par2)
|
||||
return false;
|
||||
std::string plName = par1;
|
||||
if (!normalizePlayerName (plName))
|
||||
|
||||
std::string plName = extractPlayerNameFromLink(par1);
|
||||
if(plName.empty())
|
||||
{
|
||||
SendSysMessage (LANG_PLAYER_NOT_FOUND);
|
||||
SetSentErrorMessage (true);
|
||||
SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
uint64 plGuid = 0;
|
||||
uint32 glId = 0;
|
||||
if (Player* targetPlayer = ObjectAccessor::Instance ().FindPlayerByName (plName.c_str ()))
|
||||
|
|
@ -3156,7 +3158,7 @@ bool ChatHandler::HandleGuildRankCommand(const char *args)
|
|||
}
|
||||
else
|
||||
{
|
||||
plGuid = objmgr.GetPlayerGUIDByName (plName.c_str ());
|
||||
plGuid = objmgr.GetPlayerGUIDByName (plName);
|
||||
glId = Player::GetGuildIdFromDB (plGuid);
|
||||
}
|
||||
|
||||
|
|
@ -3405,8 +3407,8 @@ bool ChatHandler::HandleReviveCommand(const char* args)
|
|||
|
||||
if (*args)
|
||||
{
|
||||
std::string name = args;
|
||||
if(!normalizePlayerName(name))
|
||||
std::string name = extractPlayerNameFromLink((char*)args);
|
||||
if(name.empty())
|
||||
{
|
||||
SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
SetSentErrorMessage(true);
|
||||
|
|
@ -3766,8 +3768,8 @@ bool ChatHandler::HandleLevelUpCommand(const char* args)
|
|||
|
||||
if(pname) // player by name
|
||||
{
|
||||
name = pname;
|
||||
if(!normalizePlayerName(name))
|
||||
name = extractPlayerNameFromLink(pname);
|
||||
if(name.empty())
|
||||
{
|
||||
SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
SetSentErrorMessage(true);
|
||||
|
|
@ -3835,7 +3837,10 @@ bool ChatHandler::HandleLevelUpCommand(const char* args)
|
|||
}
|
||||
|
||||
if(m_session->GetPlayer() != chr) // including chr==NULL
|
||||
PSendSysMessage(LANG_YOU_CHANGE_LVL,name.c_str(),newlevel);
|
||||
{
|
||||
std::string nameLink = playerLink(name);
|
||||
PSendSysMessage(LANG_YOU_CHANGE_LVL,nameLink.c_str(),newlevel);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -4293,15 +4298,15 @@ bool ChatHandler::HandleResetHonorCommand (const char * args)
|
|||
Player *player = NULL;
|
||||
if (pName)
|
||||
{
|
||||
std::string name = pName;
|
||||
if(!normalizePlayerName(name))
|
||||
std::string name = extractPlayerNameFromLink(pName);
|
||||
if(name.empty())
|
||||
{
|
||||
SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
uint64 guid = objmgr.GetPlayerGUIDByName(name.c_str());
|
||||
uint64 guid = objmgr.GetPlayerGUIDByName(name);
|
||||
player = objmgr.GetPlayer(guid);
|
||||
}
|
||||
else
|
||||
|
|
@ -4383,15 +4388,15 @@ bool ChatHandler::HandleResetLevelCommand(const char * args)
|
|||
Player *player = NULL;
|
||||
if (pName)
|
||||
{
|
||||
std::string name = pName;
|
||||
if(!normalizePlayerName(name))
|
||||
std::string name = extractPlayerNameFromLink(pName);
|
||||
if(name.empty())
|
||||
{
|
||||
SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
uint64 guid = objmgr.GetPlayerGUIDByName(name.c_str());
|
||||
uint64 guid = objmgr.GetPlayerGUIDByName(name);
|
||||
player = objmgr.GetPlayer(guid);
|
||||
}
|
||||
else
|
||||
|
|
@ -4436,15 +4441,15 @@ bool ChatHandler::HandleResetStatsCommand(const char * args)
|
|||
Player *player = NULL;
|
||||
if (pName)
|
||||
{
|
||||
std::string name = pName;
|
||||
if(!normalizePlayerName(name))
|
||||
std::string name = extractPlayerNameFromLink(pName);
|
||||
if(name.empty())
|
||||
{
|
||||
SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
uint64 guid = objmgr.GetPlayerGUIDByName(name.c_str());
|
||||
uint64 guid = objmgr.GetPlayerGUIDByName(name);
|
||||
player = objmgr.GetPlayer(guid);
|
||||
}
|
||||
else
|
||||
|
|
@ -4476,9 +4481,8 @@ bool ChatHandler::HandleResetSpellsCommand(const char * args)
|
|||
uint64 playerGUID = 0;
|
||||
if (pName)
|
||||
{
|
||||
std::string name = pName;
|
||||
|
||||
if(!normalizePlayerName(name))
|
||||
std::string name = extractPlayerNameFromLink(pName);
|
||||
if(name.empty())
|
||||
{
|
||||
SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
SetSentErrorMessage(true);
|
||||
|
|
@ -4487,7 +4491,7 @@ bool ChatHandler::HandleResetSpellsCommand(const char * args)
|
|||
|
||||
player = objmgr.GetPlayer(name.c_str());
|
||||
if(!player)
|
||||
playerGUID = objmgr.GetPlayerGUIDByName(name.c_str());
|
||||
playerGUID = objmgr.GetPlayerGUIDByName(name);
|
||||
}
|
||||
else
|
||||
player = getSelectedPlayer();
|
||||
|
|
@ -4506,7 +4510,10 @@ bool ChatHandler::HandleResetSpellsCommand(const char * args)
|
|||
ChatHandler(player).SendSysMessage(LANG_RESET_SPELLS);
|
||||
|
||||
if(m_session->GetPlayer()!=player)
|
||||
PSendSysMessage(LANG_RESET_SPELLS_ONLINE,player->GetName());
|
||||
{
|
||||
std::string nameLink = playerLink(player->GetName());
|
||||
PSendSysMessage(LANG_RESET_SPELLS_ONLINE,nameLink.c_str());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -4524,8 +4531,8 @@ bool ChatHandler::HandleResetTalentsCommand(const char * args)
|
|||
uint64 playerGUID = 0;
|
||||
if (pName)
|
||||
{
|
||||
std::string name = pName;
|
||||
if(!normalizePlayerName(name))
|
||||
std::string name = extractPlayerNameFromLink(pName);
|
||||
if(name.empty())
|
||||
{
|
||||
SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
SetSentErrorMessage(true);
|
||||
|
|
@ -4534,7 +4541,7 @@ bool ChatHandler::HandleResetTalentsCommand(const char * args)
|
|||
|
||||
player = objmgr.GetPlayer(name.c_str());
|
||||
if(!player)
|
||||
playerGUID = objmgr.GetPlayerGUIDByName(name.c_str());
|
||||
playerGUID = objmgr.GetPlayerGUIDByName(name);
|
||||
}
|
||||
else
|
||||
player = getSelectedPlayer();
|
||||
|
|
@ -4546,13 +4553,17 @@ bool ChatHandler::HandleResetTalentsCommand(const char * args)
|
|||
ChatHandler(player).SendSysMessage(LANG_RESET_TALENTS);
|
||||
|
||||
if(m_session->GetPlayer()!=player)
|
||||
PSendSysMessage(LANG_RESET_TALENTS_ONLINE,player->GetName());
|
||||
{
|
||||
std::string nameLink = playerLink(player->GetName());
|
||||
PSendSysMessage(LANG_RESET_TALENTS_ONLINE,nameLink.c_str());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if (playerGUID)
|
||||
{
|
||||
CharacterDatabase.PExecute("UPDATE characters SET at_login = at_login | '%u' WHERE guid = '%u'",uint32(AT_LOGIN_RESET_TALENTS), GUID_LOPART(playerGUID) );
|
||||
PSendSysMessage(LANG_RESET_TALENTS_OFFLINE,pName);
|
||||
std::string nameLink = playerLink(pName);
|
||||
PSendSysMessage(LANG_RESET_TALENTS_OFFLINE,nameLink.c_str());
|
||||
return true;
|
||||
}
|
||||
// Try reset talenents as Hunter Pet
|
||||
|
|
@ -4566,7 +4577,10 @@ bool ChatHandler::HandleResetTalentsCommand(const char * args)
|
|||
player = (Player *)owner;
|
||||
ChatHandler(player).SendSysMessage(LANG_RESET_TALENTS);
|
||||
if(m_session->GetPlayer()!=player)
|
||||
PSendSysMessage(LANG_RESET_TALENTS_ONLINE,player->GetName());
|
||||
{
|
||||
std::string nameLink = playerLink(player->GetName());
|
||||
PSendSysMessage(LANG_RESET_TALENTS_ONLINE,nameLink.c_str());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
@ -5130,12 +5144,8 @@ bool ChatHandler::HandleBanInfoCharacterCommand(const char* args)
|
|||
if(!args)
|
||||
return false;
|
||||
|
||||
char* cname = strtok ((char*)args, "");
|
||||
if(!cname)
|
||||
return false;
|
||||
|
||||
std::string name = cname;
|
||||
if(!normalizePlayerName(name))
|
||||
std::string name = extractPlayerNameFromLink((char*)args);
|
||||
if(name.empty())
|
||||
{
|
||||
SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
SetSentErrorMessage(true);
|
||||
|
|
@ -5635,12 +5645,11 @@ bool ChatHandler::HandleWritePDumpCommand(const char *args)
|
|||
guid = atoi(p2);
|
||||
else
|
||||
{
|
||||
std::string name = p2;
|
||||
|
||||
if (!normalizePlayerName (name))
|
||||
std::string name = extractPlayerNameFromLink(p2);
|
||||
if(name.empty())
|
||||
{
|
||||
SendSysMessage (LANG_PLAYER_NOT_FOUND);
|
||||
SetSentErrorMessage (true);
|
||||
SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -6253,9 +6262,13 @@ bool ChatHandler::HandleSendItemsCommand(const char* args)
|
|||
|
||||
// format: name "subject text" "mail text" item1[:count1] item2[:count2] ... item12[:count12]
|
||||
|
||||
char* pName = strtok((char*)args, " ");
|
||||
if(!pName)
|
||||
std::string name = extractPlayerNameFromLink((char*)args);
|
||||
if(name.empty())
|
||||
{
|
||||
SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
char* tail1 = strtok(NULL, "");
|
||||
if(!tail1)
|
||||
|
|
@ -6293,8 +6306,7 @@ bool ChatHandler::HandleSendItemsCommand(const char* args)
|
|||
if (!msgText)
|
||||
return false;
|
||||
|
||||
// pName, msgSubject, msgText isn't NUL after prev. check
|
||||
std::string name = pName;
|
||||
// msgSubject, msgText isn't NUL after prev. check
|
||||
std::string subject = msgSubject;
|
||||
std::string text = msgText;
|
||||
|
||||
|
|
@ -6352,13 +6364,6 @@ bool ChatHandler::HandleSendItemsCommand(const char* args)
|
|||
}
|
||||
}
|
||||
|
||||
if(!normalizePlayerName(name))
|
||||
{
|
||||
SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
uint64 receiver_guid = objmgr.GetPlayerGUIDByName(name);
|
||||
if(!receiver_guid)
|
||||
{
|
||||
|
|
@ -6390,7 +6395,8 @@ bool ChatHandler::HandleSendItemsCommand(const char* args)
|
|||
|
||||
WorldSession::SendMailTo(receiver,messagetype, stationery, sender_guidlo, GUID_LOPART(receiver_guid), subject, itemTextId, &mi, 0, 0, MAIL_CHECK_MASK_NONE);
|
||||
|
||||
PSendSysMessage(LANG_MAIL_SENT, name.c_str());
|
||||
std::string nameLink = playerLink(name);
|
||||
PSendSysMessage(LANG_MAIL_SENT, nameLink.c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -6402,9 +6408,13 @@ bool ChatHandler::HandleSendMoneyCommand(const char* args)
|
|||
|
||||
/// format: name "subject text" "mail text" money
|
||||
|
||||
char* pName = strtok((char*)args, " ");
|
||||
if (!pName)
|
||||
std::string name = extractPlayerNameFromLink((char*)args);
|
||||
if(name.empty())
|
||||
{
|
||||
SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
char* tail1 = strtok(NULL, "");
|
||||
if (!tail1)
|
||||
|
|
@ -6447,18 +6457,10 @@ bool ChatHandler::HandleSendMoneyCommand(const char* args)
|
|||
if (money <= 0)
|
||||
return false;
|
||||
|
||||
// pName, msgSubject, msgText isn't NUL after prev. check
|
||||
std::string name = pName;
|
||||
// msgSubject, msgText isn't NUL after prev. check
|
||||
std::string subject = msgSubject;
|
||||
std::string text = msgText;
|
||||
|
||||
if (!normalizePlayerName(name))
|
||||
{
|
||||
SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
uint64 receiver_guid = objmgr.GetPlayerGUIDByName(name);
|
||||
if (!receiver_guid)
|
||||
{
|
||||
|
|
@ -6480,7 +6482,8 @@ bool ChatHandler::HandleSendMoneyCommand(const char* args)
|
|||
|
||||
WorldSession::SendMailTo(receiver,messagetype, stationery, sender_guidlo, GUID_LOPART(receiver_guid), subject, itemTextId, NULL, money, 0, MAIL_CHECK_MASK_NONE);
|
||||
|
||||
PSendSysMessage(LANG_MAIL_SENT, name.c_str());
|
||||
std::string nameLink = playerLink(name);
|
||||
PSendSysMessage(LANG_MAIL_SENT, nameLink.c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -6488,15 +6491,16 @@ bool ChatHandler::HandleSendMoneyCommand(const char* args)
|
|||
bool ChatHandler::HandleSendMessageCommand(const char* args)
|
||||
{
|
||||
///- Get the command line arguments
|
||||
char* name_str = strtok((char*)args, " ");
|
||||
char* msg_str = strtok(NULL, "");
|
||||
|
||||
if(!name_str || !msg_str)
|
||||
std::string name = extractPlayerNameFromLink((char*)args);
|
||||
if(name.empty())
|
||||
{
|
||||
SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string name = name_str;
|
||||
|
||||
if(!normalizePlayerName(name))
|
||||
char* msg_str = strtok(NULL, "");
|
||||
if(!msg_str)
|
||||
return false;
|
||||
|
||||
///- Find the player and check that he is not logging out.
|
||||
|
|
@ -6521,7 +6525,8 @@ bool ChatHandler::HandleSendMessageCommand(const char* args)
|
|||
rPlayer->GetSession()->SendAreaTriggerMessage("|cffff0000[Message from administrator]:|r");
|
||||
|
||||
//Confirmation message
|
||||
PSendSysMessage(LANG_SENDMESSAGE,name.c_str(),msg_str);
|
||||
std::string nameLink = playerLink(name);
|
||||
PSendSysMessage(LANG_SENDMESSAGE,nameLink.c_str(),msg_str);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue