mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 22:37:03 +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
|
|
@ -57,11 +57,13 @@ bool ChatHandler::HandleMuteCommand(const char* args)
|
|||
if (!*args)
|
||||
return false;
|
||||
|
||||
char *charname = strtok((char*)args, " ");
|
||||
if (!charname)
|
||||
std::string name = extractPlayerNameFromLink((char*)args);
|
||||
if(name.empty())
|
||||
{
|
||||
SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
|
||||
std::string cname = charname;
|
||||
}
|
||||
|
||||
char *timetonotspeak = strtok(NULL, " ");
|
||||
if(!timetonotspeak)
|
||||
|
|
@ -69,14 +71,7 @@ bool ChatHandler::HandleMuteCommand(const char* args)
|
|||
|
||||
uint32 notspeaktime = (uint32) atoi(timetonotspeak);
|
||||
|
||||
if(!normalizePlayerName(cname))
|
||||
{
|
||||
SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
uint64 guid = objmgr.GetPlayerGUIDByName(cname.c_str());
|
||||
uint64 guid = objmgr.GetPlayerGUIDByName(name);
|
||||
if(!guid)
|
||||
{
|
||||
SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
|
|
@ -102,7 +97,9 @@ bool ChatHandler::HandleMuteCommand(const char* args)
|
|||
if(chr)
|
||||
ChatHandler(chr).PSendSysMessage(LANG_YOUR_CHAT_DISABLED, notspeaktime);
|
||||
|
||||
PSendSysMessage(LANG_YOU_DISABLE_CHAT, cname.c_str(), notspeaktime);
|
||||
std::string nameLink = playerLink(name);
|
||||
|
||||
PSendSysMessage(LANG_YOU_DISABLE_CHAT, nameLink.c_str(), notspeaktime);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -113,20 +110,15 @@ bool ChatHandler::HandleUnmuteCommand(const char* args)
|
|||
if (!*args)
|
||||
return false;
|
||||
|
||||
char *charname = strtok((char*)args, " ");
|
||||
if (!charname)
|
||||
return false;
|
||||
|
||||
std::string cname = charname;
|
||||
|
||||
if(!normalizePlayerName(cname))
|
||||
std::string name = extractPlayerNameFromLink((char*)args);
|
||||
if(name.empty())
|
||||
{
|
||||
SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
uint64 guid = objmgr.GetPlayerGUIDByName(cname.c_str());
|
||||
uint64 guid = objmgr.GetPlayerGUIDByName(name);
|
||||
if(!guid)
|
||||
{
|
||||
SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
|
|
@ -159,7 +151,9 @@ bool ChatHandler::HandleUnmuteCommand(const char* args)
|
|||
if(chr)
|
||||
ChatHandler(chr).PSendSysMessage(LANG_YOUR_CHAT_ENABLED);
|
||||
|
||||
PSendSysMessage(LANG_YOU_ENABLE_CHAT, cname.c_str());
|
||||
std::string nameLink = playerLink(name);
|
||||
|
||||
PSendSysMessage(LANG_YOU_ENABLE_CHAT, nameLink.c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -1662,8 +1656,7 @@ bool ChatHandler::HandleNpcFactionIdCommand(const char* args)
|
|||
//kick player
|
||||
bool ChatHandler::HandleKickPlayerCommand(const char *args)
|
||||
{
|
||||
char* kickName = strtok((char*)args, " ");
|
||||
if (!kickName)
|
||||
if (!args)
|
||||
{
|
||||
Player* player = getSelectedPlayer();
|
||||
|
||||
|
|
@ -1689,8 +1682,8 @@ bool ChatHandler::HandleKickPlayerCommand(const char *args)
|
|||
}
|
||||
else
|
||||
{
|
||||
std::string name = kickName;
|
||||
if(!normalizePlayerName(name))
|
||||
std::string name = extractPlayerNameFromLink((char*)args);
|
||||
if(name.empty())
|
||||
{
|
||||
SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
SetSentErrorMessage(true);
|
||||
|
|
@ -1709,12 +1702,14 @@ bool ChatHandler::HandleKickPlayerCommand(const char *args)
|
|||
if (player && HasLowerSecurity(player, 0))
|
||||
return false;
|
||||
|
||||
std::string nameLink = playerLink(name);
|
||||
|
||||
if(sWorld.KickPlayer(name))
|
||||
{
|
||||
PSendSysMessage(LANG_COMMAND_KICKMESSAGE,name.c_str());
|
||||
PSendSysMessage(LANG_COMMAND_KICKMESSAGE,nameLink.c_str());
|
||||
}
|
||||
else
|
||||
PSendSysMessage(LANG_COMMAND_KICKNOTFOUNDPLAYER,name.c_str());
|
||||
PSendSysMessage(LANG_COMMAND_KICKNOTFOUNDPLAYER,nameLink.c_str());
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
@ -1754,12 +1749,8 @@ bool ChatHandler::HandlePInfoCommand(const char* args)
|
|||
|
||||
if (px)
|
||||
{
|
||||
name = px;
|
||||
|
||||
name = extractPlayerNameFromLink(px);
|
||||
if(name.empty())
|
||||
return false;
|
||||
|
||||
if(!normalizePlayerName(name))
|
||||
{
|
||||
SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
SetSentErrorMessage(true);
|
||||
|
|
@ -1871,7 +1862,9 @@ bool ChatHandler::HandlePInfoCommand(const char* args)
|
|||
delete result;
|
||||
}
|
||||
|
||||
PSendSysMessage(LANG_PINFO_ACCOUNT, (target?"":GetMangosString(LANG_OFFLINE)), name.c_str(), GUID_LOPART(targetGUID), username.c_str(), accId, security, last_ip.c_str(), last_login.c_str(), latency);
|
||||
std::string nameLink = playerLink(name);
|
||||
|
||||
PSendSysMessage(LANG_PINFO_ACCOUNT, (target?"":GetMangosString(LANG_OFFLINE)), nameLink.c_str(), GUID_LOPART(targetGUID), username.c_str(), accId, security, last_ip.c_str(), last_login.c_str(), latency);
|
||||
|
||||
std::string timeStr = secsToTimeString(total_player_time,true,true);
|
||||
uint32 gold = money /GOLD;
|
||||
|
|
@ -1928,7 +1921,9 @@ void ChatHandler::ShowTicket(uint64 guid, char const* text, char const* time)
|
|||
if(!objmgr.GetPlayerNameByGUID(guid,name))
|
||||
name = GetMangosString(LANG_UNKNOWN);
|
||||
|
||||
PSendSysMessage(LANG_COMMAND_TICKETVIEW, name.c_str(),time,text);
|
||||
std::string nameLink = playerLink(name);
|
||||
|
||||
PSendSysMessage(LANG_COMMAND_TICKETVIEW, nameLink.c_str(),time,text);
|
||||
}
|
||||
|
||||
//ticket commands
|
||||
|
|
@ -2008,9 +2003,8 @@ bool ChatHandler::HandleTicketCommand(const char* args)
|
|||
return true;
|
||||
}
|
||||
|
||||
std::string name = px;
|
||||
|
||||
if(!normalizePlayerName(name))
|
||||
std::string name = extractPlayerNameFromLink(px);
|
||||
if(name.empty())
|
||||
{
|
||||
SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
SetSentErrorMessage(true);
|
||||
|
|
@ -2079,9 +2073,8 @@ bool ChatHandler::HandleDelTicketCommand(const char *args)
|
|||
return true;
|
||||
}
|
||||
|
||||
std::string name = px;
|
||||
|
||||
if(!normalizePlayerName(name))
|
||||
std::string name = extractPlayerNameFromLink(px);
|
||||
if(name.empty())
|
||||
{
|
||||
SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
SetSentErrorMessage(true);
|
||||
|
|
@ -2100,7 +2093,9 @@ bool ChatHandler::HandleDelTicketCommand(const char *args)
|
|||
if(Player* sender = objmgr.GetPlayer(guid))
|
||||
sender->GetSession()->SendGMTicketGetTicket(0x0A,0);
|
||||
|
||||
PSendSysMessage(LANG_COMMAND_TICKETPLAYERDEL,px);
|
||||
std::string nameLink = playerLink(name);
|
||||
|
||||
PSendSysMessage(LANG_COMMAND_TICKETPLAYERDEL,nameLink.c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -3333,9 +3328,8 @@ bool ChatHandler::HandleRenameCommand(const char* args)
|
|||
|
||||
if(px)
|
||||
{
|
||||
oldname = px;
|
||||
|
||||
if(!normalizePlayerName(oldname))
|
||||
oldname = extractPlayerNameFromLink(px);
|
||||
if(oldname.empty())
|
||||
{
|
||||
SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
SetSentErrorMessage(true);
|
||||
|
|
@ -3366,7 +3360,9 @@ bool ChatHandler::HandleRenameCommand(const char* args)
|
|||
if (HasLowerSecurity(target, 0))
|
||||
return false;
|
||||
|
||||
PSendSysMessage(LANG_RENAME_PLAYER, target->GetName());
|
||||
std::string tNameLink = playerLink(target->GetName());
|
||||
|
||||
PSendSysMessage(LANG_RENAME_PLAYER, tNameLink.c_str());
|
||||
target->SetAtLoginFlag(AT_LOGIN_RENAME);
|
||||
CharacterDatabase.PExecute("UPDATE characters SET at_login = at_login | '1' WHERE guid = '%u'", target->GetGUIDLow());
|
||||
}
|
||||
|
|
@ -3376,7 +3372,9 @@ bool ChatHandler::HandleRenameCommand(const char* args)
|
|||
if (HasLowerSecurity(NULL, targetGUID))
|
||||
return false;
|
||||
|
||||
PSendSysMessage(LANG_RENAME_PLAYER_GUID, oldname.c_str(), GUID_LOPART(targetGUID));
|
||||
std::string oldNameLink = playerLink(oldname);
|
||||
|
||||
PSendSysMessage(LANG_RENAME_PLAYER_GUID, oldNameLink.c_str(), GUID_LOPART(targetGUID));
|
||||
CharacterDatabase.PExecute("UPDATE characters SET at_login = at_login | '1' WHERE guid = '%u'", GUID_LOPART(targetGUID));
|
||||
}
|
||||
|
||||
|
|
@ -3394,9 +3392,8 @@ bool ChatHandler::HandleCustomizeCommand(const char* args)
|
|||
|
||||
if(px)
|
||||
{
|
||||
oldname = px;
|
||||
|
||||
if(!normalizePlayerName(oldname))
|
||||
oldname = extractPlayerNameFromLink(px);
|
||||
if(oldname.empty())
|
||||
{
|
||||
SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
SetSentErrorMessage(true);
|
||||
|
|
@ -3423,13 +3420,17 @@ bool ChatHandler::HandleCustomizeCommand(const char* args)
|
|||
|
||||
if(target)
|
||||
{
|
||||
PSendSysMessage(LANG_CUSTOMIZE_PLAYER, target->GetName());
|
||||
std::string tNameLink = playerLink(target->GetName());
|
||||
|
||||
PSendSysMessage(LANG_CUSTOMIZE_PLAYER, tNameLink.c_str());
|
||||
target->SetAtLoginFlag(AT_LOGIN_CUSTOMIZE);
|
||||
CharacterDatabase.PExecute("UPDATE characters SET at_login = at_login | '8' WHERE guid = '%u'", target->GetGUIDLow());
|
||||
}
|
||||
else
|
||||
{
|
||||
PSendSysMessage(LANG_CUSTOMIZE_PLAYER_GUID, oldname.c_str(), GUID_LOPART(targetGUID));
|
||||
std::string oldNameLink = playerLink(oldname);
|
||||
|
||||
PSendSysMessage(LANG_CUSTOMIZE_PLAYER_GUID, oldNameLink.c_str(), GUID_LOPART(targetGUID));
|
||||
CharacterDatabase.PExecute("UPDATE characters SET at_login = at_login | '8' WHERE guid = '%u'", GUID_LOPART(targetGUID));
|
||||
}
|
||||
|
||||
|
|
@ -3801,9 +3802,8 @@ bool ChatHandler::HandleCombatStopCommand(const char* args)
|
|||
|
||||
if(*args)
|
||||
{
|
||||
std::string playername = args;
|
||||
|
||||
if(!normalizePlayerName(playername))
|
||||
std::string playername = extractPlayerNameFromLink((char*)args);
|
||||
if(playername.empty())
|
||||
{
|
||||
SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
SetSentErrorMessage(true);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue