mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-02-02 15:17:27 +01:00
[7839] Rafactoring player targeting code in chat command and related cleanups/improvments.
* New extractOptFirstArg function for easy get 2 args in case option playe name as first arg.
* New extractPlayerTarget function for get player pointer/guid/name for online/offline player base at provided name
or if not provided by current seelction with error cases processing.
* Property apply mute/unmute in case use different character name from loggined currently for account.
* .reset commands can be used from console now
* .repairitems comamnd can be used from console now but only to online player.
Author: VladimirMangos
--HG--
branch : trunk
This commit is contained in:
@@ -751,26 +751,28 @@ bool ChatHandler::HandleGPSCommand(const char* args)
|
||||
//Summon Player
|
||||
bool ChatHandler::HandleNamegoCommand(const char* args)
|
||||
{
|
||||
if(!*args)
|
||||
Player* target;
|
||||
uint64 target_guid;
|
||||
std::string target_name;
|
||||
if (!extractPlayerTarget((char*)args,&target,&target_guid,&target_name))
|
||||
return false;
|
||||
|
||||
std::string name = extractPlayerNameFromLink((char*)args);
|
||||
if(name.empty())
|
||||
Player* _player = m_session->GetPlayer();
|
||||
if (target == _player || target_guid == _player->GetGUID())
|
||||
{
|
||||
SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
PSendSysMessage(LANG_CANT_TELEPORT_SELF);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
Player *chr = objmgr.GetPlayer(name.c_str());
|
||||
if (chr)
|
||||
if (target)
|
||||
{
|
||||
std::string nameLink = playerLink(name);
|
||||
std::string nameLink = playerLink(target_name);
|
||||
// check online security
|
||||
if (HasLowerSecurity(chr, 0))
|
||||
if (HasLowerSecurity(target, 0))
|
||||
return false;
|
||||
|
||||
if(chr->IsBeingTeleported())
|
||||
if (target->IsBeingTeleported())
|
||||
{
|
||||
PSendSysMessage(LANG_IS_TELEPORTED, nameLink.c_str());
|
||||
SetSentErrorMessage(true);
|
||||
@@ -779,32 +781,32 @@ bool ChatHandler::HandleNamegoCommand(const char* args)
|
||||
|
||||
Map* pMap = m_session->GetPlayer()->GetMap();
|
||||
|
||||
if(pMap->IsBattleGroundOrArena())
|
||||
if (pMap->IsBattleGroundOrArena())
|
||||
{
|
||||
// only allow if gm mode is on
|
||||
if (!chr->isGameMaster())
|
||||
if (!target->isGameMaster())
|
||||
{
|
||||
PSendSysMessage(LANG_CANNOT_GO_TO_BG_GM, nameLink.c_str());
|
||||
PSendSysMessage(LANG_CANNOT_GO_TO_BG_GM,nameLink.c_str());
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
// if both players are in different bgs
|
||||
else if (chr->GetBattleGroundId() && m_session->GetPlayer()->GetBattleGroundId() != chr->GetBattleGroundId())
|
||||
else if (target->GetBattleGroundId() && m_session->GetPlayer()->GetBattleGroundId() != target->GetBattleGroundId())
|
||||
{
|
||||
PSendSysMessage(LANG_CANNOT_GO_TO_BG_FROM_BG, nameLink.c_str());
|
||||
PSendSysMessage(LANG_CANNOT_GO_TO_BG_FROM_BG,nameLink.c_str());
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
// all's well, set bg id
|
||||
// when porting out from the bg, it will be reset to 0
|
||||
chr->SetBattleGroundId(m_session->GetPlayer()->GetBattleGroundId(), m_session->GetPlayer()->GetBattleGroundTypeId());
|
||||
target->SetBattleGroundId(m_session->GetPlayer()->GetBattleGroundId(), m_session->GetPlayer()->GetBattleGroundTypeId());
|
||||
// remember current position as entry point for return at bg end teleportation
|
||||
chr->SetBattleGroundEntryPoint(chr->GetMapId(),chr->GetPositionX(),chr->GetPositionY(),chr->GetPositionZ(),chr->GetOrientation());
|
||||
target->SetBattleGroundEntryPoint(target->GetMapId(),target->GetPositionX(),target->GetPositionY(),target->GetPositionZ(),target->GetOrientation());
|
||||
}
|
||||
else if(pMap->IsDungeon())
|
||||
else if (pMap->IsDungeon())
|
||||
{
|
||||
Map* cMap = chr->GetMap();
|
||||
if( cMap->Instanceable() && cMap->GetInstanceId() != pMap->GetInstanceId() )
|
||||
Map* cMap = target->GetMap();
|
||||
if (cMap->Instanceable() && cMap->GetInstanceId() != pMap->GetInstanceId())
|
||||
{
|
||||
// cannot summon from instance to instance
|
||||
PSendSysMessage(LANG_CANNOT_SUMMON_TO_INST,nameLink.c_str());
|
||||
@@ -813,9 +815,9 @@ bool ChatHandler::HandleNamegoCommand(const char* args)
|
||||
}
|
||||
|
||||
// we are in instance, and can summon only player in our group with us as lead
|
||||
if ( !m_session->GetPlayer()->GetGroup() || !chr->GetGroup() ||
|
||||
(chr->GetGroup()->GetLeaderGUID() != m_session->GetPlayer()->GetGUID()) ||
|
||||
(m_session->GetPlayer()->GetGroup()->GetLeaderGUID() != m_session->GetPlayer()->GetGUID()) )
|
||||
if (!m_session->GetPlayer()->GetGroup() || !target->GetGroup() ||
|
||||
(target->GetGroup()->GetLeaderGUID() != m_session->GetPlayer()->GetGUID()) ||
|
||||
(m_session->GetPlayer()->GetGroup()->GetLeaderGUID() != m_session->GetPlayer()->GetGUID()))
|
||||
// the last check is a bit excessive, but let it be, just in case
|
||||
{
|
||||
PSendSysMessage(LANG_CANNOT_SUMMON_TO_INST,nameLink.c_str());
|
||||
@@ -825,31 +827,31 @@ bool ChatHandler::HandleNamegoCommand(const char* args)
|
||||
}
|
||||
|
||||
PSendSysMessage(LANG_SUMMONING, nameLink.c_str(),"");
|
||||
if (needReportToTarget(chr))
|
||||
ChatHandler(chr).PSendSysMessage(LANG_SUMMONED_BY, GetNameLink().c_str());
|
||||
if (needReportToTarget(target))
|
||||
ChatHandler(target).PSendSysMessage(LANG_SUMMONED_BY, nameLink.c_str());
|
||||
|
||||
// stop flight if need
|
||||
if(chr->isInFlight())
|
||||
if (target->isInFlight())
|
||||
{
|
||||
chr->GetMotionMaster()->MovementExpired();
|
||||
chr->m_taxi.ClearTaxiDestinations();
|
||||
target->GetMotionMaster()->MovementExpired();
|
||||
target->m_taxi.ClearTaxiDestinations();
|
||||
}
|
||||
// save only in non-flight case
|
||||
else
|
||||
chr->SaveRecallPosition();
|
||||
target->SaveRecallPosition();
|
||||
|
||||
// before GM
|
||||
float x,y,z;
|
||||
m_session->GetPlayer()->GetClosePoint(x,y,z,chr->GetObjectSize());
|
||||
chr->TeleportTo(m_session->GetPlayer()->GetMapId(),x,y,z,chr->GetOrientation());
|
||||
m_session->GetPlayer()->GetClosePoint(x,y,z,target->GetObjectSize());
|
||||
target->TeleportTo(m_session->GetPlayer()->GetMapId(),x,y,z,target->GetOrientation());
|
||||
}
|
||||
else if (uint64 guid = objmgr.GetPlayerGUIDByName(name))
|
||||
else
|
||||
{
|
||||
// check offline security
|
||||
if (HasLowerSecurity(NULL, guid))
|
||||
if (HasLowerSecurity(NULL, target_guid))
|
||||
return false;
|
||||
|
||||
std::string nameLink = playerLink(name);
|
||||
std::string nameLink = playerLink(target_name);
|
||||
|
||||
PSendSysMessage(LANG_SUMMONING, nameLink.c_str(),GetTrinityString(LANG_OFFLINE));
|
||||
|
||||
@@ -860,12 +862,7 @@ bool ChatHandler::HandleNamegoCommand(const char* args)
|
||||
m_session->GetPlayer()->GetPositionZ(),
|
||||
m_session->GetPlayer()->GetOrientation(),
|
||||
m_session->GetPlayer()->GetZoneId(),
|
||||
guid);
|
||||
}
|
||||
else
|
||||
{
|
||||
PSendSysMessage(LANG_NO_PLAYER, args);
|
||||
SetSentErrorMessage(true);
|
||||
target_guid);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -874,30 +871,31 @@ bool ChatHandler::HandleNamegoCommand(const char* args)
|
||||
//Teleport to Player
|
||||
bool ChatHandler::HandleGonameCommand(const char* args)
|
||||
{
|
||||
if(!*args)
|
||||
Player* target;
|
||||
uint64 target_guid;
|
||||
std::string target_name;
|
||||
if (!extractPlayerTarget((char*)args,&target,&target_guid,&target_name))
|
||||
return false;
|
||||
|
||||
Player* _player = m_session->GetPlayer();
|
||||
|
||||
std::string name = extractPlayerNameFromLink((char*)args);
|
||||
if(name.empty())
|
||||
if (target == _player || target_guid == _player->GetGUID())
|
||||
{
|
||||
SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
SendSysMessage(LANG_CANT_TELEPORT_SELF);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
Player *chr = objmgr.GetPlayer(name.c_str());
|
||||
if (chr)
|
||||
|
||||
if (target)
|
||||
{
|
||||
// check online security
|
||||
if (HasLowerSecurity(chr, 0))
|
||||
if (HasLowerSecurity(target, 0))
|
||||
return false;
|
||||
|
||||
std::string chrNameLink = playerLink(name);
|
||||
std::string chrNameLink = playerLink(target_name);
|
||||
|
||||
Map* cMap = chr->GetMap();
|
||||
if(cMap->IsBattleGroundOrArena())
|
||||
Map* cMap = target->GetMap();
|
||||
if (cMap->IsBattleGroundOrArena())
|
||||
{
|
||||
// only allow if gm mode is on
|
||||
if (!_player->isGameMaster())
|
||||
@@ -907,7 +905,7 @@ bool ChatHandler::HandleGonameCommand(const char* args)
|
||||
return false;
|
||||
}
|
||||
// if both players are in different bgs
|
||||
else if (_player->GetBattleGroundId() && _player->GetBattleGroundId() != chr->GetBattleGroundId())
|
||||
else if (_player->GetBattleGroundId() && _player->GetBattleGroundId() != target->GetBattleGroundId())
|
||||
{
|
||||
PSendSysMessage(LANG_CANNOT_GO_TO_BG_FROM_BG,chrNameLink.c_str());
|
||||
SetSentErrorMessage(true);
|
||||
@@ -915,7 +913,7 @@ bool ChatHandler::HandleGonameCommand(const char* args)
|
||||
}
|
||||
// all's well, set bg id
|
||||
// when porting out from the bg, it will be reset to 0
|
||||
_player->SetBattleGroundId(chr->GetBattleGroundId(), chr->GetBattleGroundTypeId());
|
||||
_player->SetBattleGroundId(target->GetBattleGroundId(), target->GetBattleGroundTypeId());
|
||||
// remember current position as entry point for return at bg end teleportation
|
||||
_player->SetBattleGroundEntryPoint(_player->GetMapId(),_player->GetPositionX(),_player->GetPositionY(),_player->GetPositionZ(),_player->GetOrientation());
|
||||
}
|
||||
@@ -929,7 +927,7 @@ bool ChatHandler::HandleGonameCommand(const char* args)
|
||||
if (_player->GetGroup())
|
||||
{
|
||||
// we are in group, we can go only if we are in the player group
|
||||
if (_player->GetGroup() != chr->GetGroup())
|
||||
if (_player->GetGroup() != target->GetGroup())
|
||||
{
|
||||
PSendSysMessage(LANG_CANNOT_GO_TO_INST_PARTY,chrNameLink.c_str());
|
||||
SetSentErrorMessage(true);
|
||||
@@ -949,28 +947,27 @@ bool ChatHandler::HandleGonameCommand(const char* args)
|
||||
|
||||
// if the player or the player's group is bound to another instance
|
||||
// the player will not be bound to another one
|
||||
InstancePlayerBind *pBind = _player->GetBoundInstance(chr->GetMapId(), chr->GetDifficulty());
|
||||
if(!pBind)
|
||||
InstancePlayerBind *pBind = _player->GetBoundInstance(target->GetMapId(), target->GetDifficulty());
|
||||
if (!pBind)
|
||||
{
|
||||
Group *group = _player->GetGroup();
|
||||
InstanceGroupBind *gBind = group ? group->GetBoundInstance(chr->GetMapId(), chr->GetDifficulty()) : NULL;
|
||||
if(!gBind)
|
||||
{
|
||||
// if no bind exists, create a solo bind
|
||||
InstanceSave *save = sInstanceSaveManager.GetInstanceSave(chr->GetInstanceId());
|
||||
if(save) _player->BindToInstance(save, !save->CanReset());
|
||||
}
|
||||
// if no bind exists, create a solo bind
|
||||
InstanceGroupBind *gBind = group ? group->GetBoundInstance(target->GetMapId(), target->GetDifficulty()) : NULL;
|
||||
// if no bind exists, create a solo bind
|
||||
if (!gBind)
|
||||
if (InstanceSave *save = sInstanceSaveManager.GetInstanceSave(target->GetInstanceId()))
|
||||
_player->BindToInstance(save, !save->CanReset());
|
||||
}
|
||||
|
||||
_player->SetDifficulty(chr->GetDifficulty());
|
||||
_player->SetDifficulty(target->GetDifficulty());
|
||||
}
|
||||
|
||||
PSendSysMessage(LANG_APPEARING_AT, chrNameLink.c_str());
|
||||
if (_player->IsVisibleGloballyFor(chr))
|
||||
ChatHandler(chr).PSendSysMessage(LANG_APPEARING_TO, GetNameLink().c_str());
|
||||
if (needReportToTarget(target))
|
||||
ChatHandler(target).PSendSysMessage(LANG_APPEARING_TO, GetNameLink().c_str());
|
||||
|
||||
// stop flight if need
|
||||
if(_player->isInFlight())
|
||||
if (_player->isInFlight())
|
||||
{
|
||||
_player->GetMotionMaster()->MovementExpired();
|
||||
_player->m_taxi.ClearTaxiDestinations();
|
||||
@@ -981,20 +978,17 @@ bool ChatHandler::HandleGonameCommand(const char* args)
|
||||
|
||||
// to point to see at target with same orientation
|
||||
float x,y,z;
|
||||
chr->GetContactPoint(m_session->GetPlayer(),x,y,z);
|
||||
target->GetContactPoint(_player,x,y,z);
|
||||
|
||||
_player->TeleportTo(chr->GetMapId(), x, y, z, _player->GetAngle( chr ), TELE_TO_GM_MODE);
|
||||
|
||||
return true;
|
||||
_player->TeleportTo(target->GetMapId(), x, y, z, _player->GetAngle(target), TELE_TO_GM_MODE);
|
||||
}
|
||||
|
||||
if (uint64 guid = objmgr.GetPlayerGUIDByName(name))
|
||||
else
|
||||
{
|
||||
// check offline security
|
||||
if (HasLowerSecurity(NULL, guid))
|
||||
if (HasLowerSecurity(NULL, target_guid))
|
||||
return false;
|
||||
|
||||
std::string nameLink = playerLink(name);
|
||||
std::string nameLink = playerLink(target_name);
|
||||
|
||||
PSendSysMessage(LANG_APPEARING_AT, nameLink.c_str());
|
||||
|
||||
@@ -1002,83 +996,51 @@ bool ChatHandler::HandleGonameCommand(const char* args)
|
||||
float x,y,z,o;
|
||||
uint32 map;
|
||||
bool in_flight;
|
||||
if(Player::LoadPositionFromDB(map,x,y,z,o,in_flight,guid))
|
||||
{
|
||||
// stop flight if need
|
||||
if(_player->isInFlight())
|
||||
{
|
||||
_player->GetMotionMaster()->MovementExpired();
|
||||
_player->m_taxi.ClearTaxiDestinations();
|
||||
}
|
||||
// save only in non-flight case
|
||||
else
|
||||
_player->SaveRecallPosition();
|
||||
if (!Player::LoadPositionFromDB(map,x,y,z,o,in_flight,target_guid))
|
||||
return false;
|
||||
|
||||
_player->TeleportTo(map, x, y, z,_player->GetOrientation());
|
||||
return true;
|
||||
// stop flight if need
|
||||
if (_player->isInFlight())
|
||||
{
|
||||
_player->GetMotionMaster()->MovementExpired();
|
||||
_player->m_taxi.ClearTaxiDestinations();
|
||||
}
|
||||
// save only in non-flight case
|
||||
else
|
||||
_player->SaveRecallPosition();
|
||||
|
||||
_player->TeleportTo(map, x, y, z,_player->GetOrientation());
|
||||
}
|
||||
|
||||
PSendSysMessage(LANG_NO_PLAYER, args);
|
||||
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Teleport player to last position
|
||||
bool ChatHandler::HandleRecallCommand(const char* args)
|
||||
{
|
||||
Player* chr = NULL;
|
||||
Player* target;
|
||||
if(!extractPlayerTarget((char*)args,&target))
|
||||
return false;
|
||||
|
||||
if(!*args)
|
||||
// check online security
|
||||
if (HasLowerSecurity(target, 0))
|
||||
return false;
|
||||
|
||||
if (target->IsBeingTeleported())
|
||||
{
|
||||
chr = getSelectedPlayer();
|
||||
if(!chr)
|
||||
chr = m_session->GetPlayer();
|
||||
|
||||
// check online security
|
||||
else if (HasLowerSecurity(chr, 0))
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string name = extractPlayerNameFromLink((char*)args);
|
||||
if(name.empty())
|
||||
{
|
||||
SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
chr = objmgr.GetPlayer(name.c_str());
|
||||
|
||||
if(!chr)
|
||||
{
|
||||
PSendSysMessage(LANG_NO_PLAYER, args);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
// check online security
|
||||
if (HasLowerSecurity(chr, 0))
|
||||
return false;
|
||||
}
|
||||
|
||||
if(chr->IsBeingTeleported())
|
||||
{
|
||||
PSendSysMessage(LANG_IS_TELEPORTED, GetNameLink(chr).c_str());
|
||||
PSendSysMessage(LANG_IS_TELEPORTED, GetNameLink(target).c_str());
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
// stop flight if need
|
||||
if(chr->isInFlight())
|
||||
if(target->isInFlight())
|
||||
{
|
||||
chr->GetMotionMaster()->MovementExpired();
|
||||
chr->m_taxi.ClearTaxiDestinations();
|
||||
target->GetMotionMaster()->MovementExpired();
|
||||
target->m_taxi.ClearTaxiDestinations();
|
||||
}
|
||||
|
||||
chr->TeleportTo(chr->m_recallMap, chr->m_recallX, chr->m_recallY, chr->m_recallZ, chr->m_recallO);
|
||||
target->TeleportTo(target->m_recallMap, target->m_recallX, target->m_recallY, target->m_recallZ, target->m_recallO);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2407,18 +2369,12 @@ bool ChatHandler::HandleSaveAllCommand(const char* /*args*/)
|
||||
//Send mail by command
|
||||
bool ChatHandler::HandleSendMailCommand(const char* args)
|
||||
{
|
||||
if(!*args)
|
||||
return false;
|
||||
|
||||
// format: name "subject text" "mail text"
|
||||
|
||||
std::string name = extractPlayerNameFromLink((char*)args);
|
||||
if(name.empty())
|
||||
{
|
||||
SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
SetSentErrorMessage(true);
|
||||
Player* target;
|
||||
uint64 target_guid;
|
||||
std::string target_name;
|
||||
if(!extractPlayerTarget((char*)args,&target,&target_guid,&target_name))
|
||||
return false;
|
||||
}
|
||||
|
||||
char* tail1 = strtok(NULL, "");
|
||||
if(!tail1)
|
||||
@@ -2460,14 +2416,6 @@ bool ChatHandler::HandleSendMailCommand(const char* args)
|
||||
std::string subject = msgSubject;
|
||||
std::string text = msgText;
|
||||
|
||||
uint64 receiver_guid = objmgr.GetPlayerGUIDByName(name);
|
||||
if(!receiver_guid)
|
||||
{
|
||||
SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
// from console show not existed sender
|
||||
uint32 sender_guidlo = m_session ? m_session->GetPlayer()->GetGUIDLow() : 0;
|
||||
|
||||
@@ -2475,11 +2423,9 @@ bool ChatHandler::HandleSendMailCommand(const char* args)
|
||||
uint32 stationery = MAIL_STATIONERY_GM;
|
||||
uint32 itemTextId = !text.empty() ? objmgr.CreateItemText( text ) : 0;
|
||||
|
||||
Player *receiver = objmgr.GetPlayer(receiver_guid);
|
||||
WorldSession::SendMailTo(target,messagetype, stationery, sender_guidlo, GUID_LOPART(target_guid), subject, itemTextId, NULL, 0, 0, MAIL_CHECK_MASK_NONE);
|
||||
|
||||
WorldSession::SendMailTo(receiver,messagetype, stationery, sender_guidlo, GUID_LOPART(receiver_guid), subject, itemTextId, NULL, 0, 0, MAIL_CHECK_MASK_NONE);
|
||||
|
||||
std::string nameLink = playerLink(name);
|
||||
std::string nameLink = playerLink(target_name);
|
||||
PSendSysMessage(LANG_MAIL_SENT, nameLink.c_str());
|
||||
return true;
|
||||
}
|
||||
@@ -2487,23 +2433,20 @@ bool ChatHandler::HandleSendMailCommand(const char* args)
|
||||
// teleport player to given game_tele.entry
|
||||
bool ChatHandler::HandleTeleNameCommand(const char * args)
|
||||
{
|
||||
if(!*args)
|
||||
char* nameStr;
|
||||
char* teleStr;
|
||||
extractOptFirstArg((char*)args,&nameStr,&teleStr);
|
||||
if(!teleStr)
|
||||
return false;
|
||||
|
||||
std::string name = extractPlayerNameFromLink((char*)args);
|
||||
if(name.empty())
|
||||
{
|
||||
SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
char* tail = strtok(NULL, "");
|
||||
if(!tail)
|
||||
|
||||
Player* target;
|
||||
uint64 target_guid;
|
||||
std::string target_name;
|
||||
if(!extractPlayerTarget(teleStr,&target,&target_guid,&target_name))
|
||||
return false;
|
||||
|
||||
// id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r
|
||||
GameTele const* tele = extractGameTeleFromLink(tail);
|
||||
GameTele const* tele = extractGameTeleFromLink(teleStr);
|
||||
if(!tele)
|
||||
{
|
||||
SendSysMessage(LANG_COMMAND_TELE_NOTFOUND);
|
||||
@@ -2511,7 +2454,7 @@ bool ChatHandler::HandleTeleNameCommand(const char * args)
|
||||
return false;
|
||||
}
|
||||
|
||||
MapEntry const * me = sMapStore.LookupEntry(tele->mapId);
|
||||
/* MapEntry const * me = sMapStore.LookupEntry(tele->mapId);
|
||||
if(!me || me->IsBattleGroundOrArena())
|
||||
{
|
||||
SendSysMessage(LANG_CANNOT_TELE_TO_BG);
|
||||
@@ -2519,16 +2462,17 @@ bool ChatHandler::HandleTeleNameCommand(const char * args)
|
||||
return false;
|
||||
}
|
||||
|
||||
Player *chr = objmgr.GetPlayer(name.c_str());
|
||||
if (chr)
|
||||
Player *chr = objmgr.GetPlayer(name.c_str());*/
|
||||
|
||||
if (target)
|
||||
{
|
||||
// check online security
|
||||
if (HasLowerSecurity(chr, 0))
|
||||
if (HasLowerSecurity(target, 0))
|
||||
return false;
|
||||
|
||||
std::string chrNameLink = playerLink(name);
|
||||
std::string chrNameLink = playerLink(target_name);
|
||||
|
||||
if(chr->IsBeingTeleported()==true)
|
||||
if(target->IsBeingTeleported()==true)
|
||||
{
|
||||
PSendSysMessage(LANG_IS_TELEPORTED, chrNameLink.c_str());
|
||||
SetSentErrorMessage(true);
|
||||
@@ -2536,35 +2480,33 @@ bool ChatHandler::HandleTeleNameCommand(const char * args)
|
||||
}
|
||||
|
||||
PSendSysMessage(LANG_TELEPORTING_TO, chrNameLink.c_str(),"", tele->name.c_str());
|
||||
if (needReportToTarget(chr))
|
||||
ChatHandler(chr).PSendSysMessage(LANG_TELEPORTED_TO_BY, GetNameLink().c_str());
|
||||
if (needReportToTarget(target))
|
||||
ChatHandler(target).PSendSysMessage(LANG_TELEPORTED_TO_BY, GetNameLink().c_str());
|
||||
|
||||
// stop flight if need
|
||||
if(chr->isInFlight())
|
||||
if(target->isInFlight())
|
||||
{
|
||||
chr->GetMotionMaster()->MovementExpired();
|
||||
chr->m_taxi.ClearTaxiDestinations();
|
||||
target->GetMotionMaster()->MovementExpired();
|
||||
target->m_taxi.ClearTaxiDestinations();
|
||||
}
|
||||
// save only in non-flight case
|
||||
else
|
||||
chr->SaveRecallPosition();
|
||||
target->SaveRecallPosition();
|
||||
|
||||
chr->TeleportTo(tele->mapId,tele->position_x,tele->position_y,tele->position_z,tele->orientation);
|
||||
target->TeleportTo(tele->mapId,tele->position_x,tele->position_y,tele->position_z,tele->orientation);
|
||||
}
|
||||
else if (uint64 guid = objmgr.GetPlayerGUIDByName(name))
|
||||
else
|
||||
{
|
||||
// check offline security
|
||||
if (HasLowerSecurity(NULL, guid))
|
||||
if (HasLowerSecurity(NULL, target_guid))
|
||||
return false;
|
||||
|
||||
std::string nameLink = playerLink(name);
|
||||
std::string nameLink = playerLink(target_name);
|
||||
|
||||
PSendSysMessage(LANG_TELEPORTING_TO, nameLink.c_str(), GetMangosString(LANG_OFFLINE), tele->name.c_str());
|
||||
Player::SavePositionInDB(tele->mapId,tele->position_x,tele->position_y,tele->position_z,tele->orientation,
|
||||
MapManager::Instance().GetZoneId(tele->mapId,tele->position_x,tele->position_y,tele->position_z),guid);
|
||||
MapManager::Instance().GetZoneId(tele->mapId,tele->position_x,tele->position_y,tele->position_z),target_guid);
|
||||
}
|
||||
else
|
||||
PSendSysMessage(LANG_NO_PLAYER, name.c_str());
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -2656,32 +2598,17 @@ bool ChatHandler::HandleTeleGroupCommand(const char * args)
|
||||
//Summon group of player
|
||||
bool ChatHandler::HandleGroupgoCommand(const char* args)
|
||||
{
|
||||
if(!*args)
|
||||
Player* target;
|
||||
if(!extractPlayerTarget((char*)args,&target))
|
||||
return false;
|
||||
|
||||
std::string name = extractPlayerNameFromLink((char*)args);
|
||||
if(name.empty())
|
||||
{
|
||||
SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
Player *player = objmgr.GetPlayer(name.c_str());
|
||||
if (!player)
|
||||
{
|
||||
PSendSysMessage(LANG_NO_PLAYER, args);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
// check online security
|
||||
if (HasLowerSecurity(player, 0))
|
||||
if (HasLowerSecurity(target, 0))
|
||||
return false;
|
||||
|
||||
Group *grp = player->GetGroup();
|
||||
Group *grp = target->GetGroup();
|
||||
|
||||
std::string nameLink = playerLink(name);
|
||||
std::string nameLink = GetNameLink(target);
|
||||
|
||||
if(!grp)
|
||||
{
|
||||
@@ -2715,7 +2642,7 @@ bool ChatHandler::HandleGroupgoCommand(const char* args)
|
||||
if (HasLowerSecurity(pl, 0))
|
||||
return false;
|
||||
|
||||
std::string plNameLink = playerLink(pl->GetName());
|
||||
std::string plNameLink = GetNameLink(pl);
|
||||
|
||||
if(pl->IsBeingTeleported()==true)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user