[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:
+83
-11
@@ -495,13 +495,13 @@ ChatCommand * ChatHandler::getCommandTable()
|
||||
|
||||
static ChatCommand resetCommandTable[] =
|
||||
{
|
||||
{ "achievements", SEC_ADMINISTRATOR, false, &ChatHandler::HandleResetAchievementsCommand, "", NULL },
|
||||
{ "honor", SEC_ADMINISTRATOR, false, &ChatHandler::HandleResetHonorCommand, "", NULL },
|
||||
{ "level", SEC_ADMINISTRATOR, false, &ChatHandler::HandleResetLevelCommand, "", NULL },
|
||||
{ "spells", SEC_ADMINISTRATOR, false, &ChatHandler::HandleResetSpellsCommand, "", NULL },
|
||||
{ "stats", SEC_ADMINISTRATOR, false, &ChatHandler::HandleResetStatsCommand, "", NULL },
|
||||
{ "talents", SEC_ADMINISTRATOR, false, &ChatHandler::HandleResetTalentsCommand, "", NULL },
|
||||
{ "all", SEC_ADMINISTRATOR, false, &ChatHandler::HandleResetAllCommand, "", NULL },
|
||||
{ "achievements", SEC_ADMINISTRATOR, true, &ChatHandler::HandleResetAchievementsCommand, "", NULL },
|
||||
{ "honor", SEC_ADMINISTRATOR, true, &ChatHandler::HandleResetHonorCommand, "", NULL },
|
||||
{ "level", SEC_ADMINISTRATOR, true, &ChatHandler::HandleResetLevelCommand, "", NULL },
|
||||
{ "spells", SEC_ADMINISTRATOR, true, &ChatHandler::HandleResetSpellsCommand, "", NULL },
|
||||
{ "stats", SEC_ADMINISTRATOR, true, &ChatHandler::HandleResetStatsCommand, "", NULL },
|
||||
{ "talents", SEC_ADMINISTRATOR, true, &ChatHandler::HandleResetTalentsCommand, "", NULL },
|
||||
{ "all", SEC_ADMINISTRATOR, true, &ChatHandler::HandleResetAllCommand, "", NULL },
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
|
||||
@@ -634,7 +634,7 @@ ChatCommand * ChatHandler::getCommandTable()
|
||||
{ "pdump", SEC_ADMINISTRATOR, true, NULL, "", pdumpCommandTable },
|
||||
{ "guild", SEC_ADMINISTRATOR, true, NULL, "", guildCommandTable },
|
||||
{ "cast", SEC_ADMINISTRATOR, false, NULL, "", castCommandTable },
|
||||
{ "reset", SEC_ADMINISTRATOR, false, NULL, "", resetCommandTable },
|
||||
{ "reset", SEC_ADMINISTRATOR, true, NULL, "", resetCommandTable },
|
||||
{ "instance", SEC_ADMINISTRATOR, true, NULL, "", instanceCommandTable },
|
||||
{ "server", SEC_ADMINISTRATOR, true, NULL, "", serverCommandTable },
|
||||
|
||||
@@ -680,7 +680,6 @@ ChatCommand * ChatHandler::getCommandTable()
|
||||
{ "neargrave", SEC_ADMINISTRATOR, false, &ChatHandler::HandleNearGraveCommand, "", NULL },
|
||||
{ "explorecheat", SEC_ADMINISTRATOR, false, &ChatHandler::HandleExploreCheatCommand, "", NULL },
|
||||
{ "hover", SEC_ADMINISTRATOR, false, &ChatHandler::HandleHoverCommand, "", NULL },
|
||||
{ "waterwalk", SEC_ADMINISTRATOR, false, &ChatHandler::HandleWaterwalkCommand, "", NULL },
|
||||
{ "levelup", SEC_ADMINISTRATOR, false, &ChatHandler::HandleLevelUpCommand, "", NULL },
|
||||
{ "showarea", SEC_ADMINISTRATOR, false, &ChatHandler::HandleShowAreaCommand, "", NULL },
|
||||
{ "hidearea", SEC_ADMINISTRATOR, false, &ChatHandler::HandleHideAreaCommand, "", NULL },
|
||||
@@ -702,7 +701,9 @@ ChatCommand * ChatHandler::getCommandTable()
|
||||
{ "damage", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDamageCommand, "", NULL },
|
||||
{ "combatstop", SEC_GAMEMASTER, false, &ChatHandler::HandleCombatStopCommand, "", NULL },
|
||||
{ "flusharenapoints",SEC_ADMINISTRATOR, false, &ChatHandler::HandleFlushArenaPointsCommand, "", NULL },
|
||||
{ "repairitems", SEC_GAMEMASTER, false, &ChatHandler::HandleRepairitemsCommand, "", NULL },
|
||||
{ "repairitems", SEC_GAMEMASTER, true, &ChatHandler::HandleRepairitemsCommand, "", NULL },
|
||||
{ "waterwalk", SEC_GAMEMASTER, false, &ChatHandler::HandleWaterwalkCommand, "", NULL },
|
||||
|
||||
{ "freeze", SEC_ADMINISTRATOR, false, &ChatHandler::HandleFreezeCommand, "", NULL },
|
||||
{ "unfreeze", SEC_ADMINISTRATOR, false, &ChatHandler::HandleUnFreezeCommand, "", NULL },
|
||||
{ "listfreeze", SEC_ADMINISTRATOR, false, &ChatHandler::HandleListFreezeCommand, "", NULL },
|
||||
@@ -1315,7 +1316,7 @@ char* ChatHandler::extractKeyFromLink(char* text, char const* linkType, char** s
|
||||
*something1 = strtok(NULL, ":|"); // 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 retturn from function
|
||||
strtok(NULL, " "); // skip link tail (to allow continue strtok(NULL,s) use after return from function
|
||||
return cKey;
|
||||
}
|
||||
|
||||
@@ -1593,6 +1594,77 @@ std::string ChatHandler::extractPlayerNameFromLink(char* text)
|
||||
return name;
|
||||
}
|
||||
|
||||
bool ChatHandler::extractPlayerTarget(char* args, Player** player, uint64* player_guid /*=NULL*/,std::string* player_name /*= NULL*/)
|
||||
{
|
||||
if (args && *args)
|
||||
{
|
||||
std::string name = extractPlayerNameFromLink(args);
|
||||
if (name.empty())
|
||||
{
|
||||
SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
Player* pl = objmgr.GetPlayer(name.c_str());
|
||||
|
||||
// if allowed player pointer
|
||||
if(player)
|
||||
*player = pl;
|
||||
|
||||
// if need guid value from DB (in name case for check player existence)
|
||||
uint64 guid = !pl && (player_guid || player_name) ? objmgr.GetPlayerGUIDByName(name) : 0;
|
||||
|
||||
// if allowed player guid (if no then only online players allowed)
|
||||
if(player_guid)
|
||||
*player_guid = pl ? pl->GetGUID() : guid;
|
||||
|
||||
if(player_name)
|
||||
*player_name = pl || guid ? name : "";
|
||||
}
|
||||
else
|
||||
{
|
||||
Player* pl = getSelectedPlayer();
|
||||
// if allowed player pointer
|
||||
if(player)
|
||||
*player = pl;
|
||||
// if allowed player guid (if no then only online players allowed)
|
||||
if(player_guid)
|
||||
*player_guid = pl ? pl->GetGUID() : 0;
|
||||
|
||||
if(player_name)
|
||||
*player_name = pl ? pl->GetName() : "";
|
||||
}
|
||||
|
||||
// some from req. data must be provided (note: name is empty if player not exist)
|
||||
if((!player || !*player) && (!player_guid || !*player_guid) && (!player_name || player_name->empty()))
|
||||
{
|
||||
SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ChatHandler::extractOptFirstArg(char* args, char** arg1, char** arg2)
|
||||
{
|
||||
char* p1 = strtok(args, " ");
|
||||
char* p2 = strtok(NULL, " ");
|
||||
|
||||
if(!p2)
|
||||
{
|
||||
p2 = p1;
|
||||
p1 = NULL;
|
||||
}
|
||||
|
||||
if(arg1)
|
||||
*arg1 = p1;
|
||||
|
||||
if(arg2)
|
||||
*arg2 = p2;
|
||||
}
|
||||
|
||||
bool ChatHandler::needReportToTarget(Player* chr) const
|
||||
{
|
||||
Player* pl = m_session->GetPlayer();
|
||||
|
||||
@@ -560,11 +560,16 @@ class ChatHandler
|
||||
char* extractKeyFromLink(char* text, char const* linkType, char** something1 = NULL);
|
||||
char* extractKeyFromLink(char* text, char const* const* linkTypes, int* found_idx, char** something1 = NULL);
|
||||
|
||||
// if args have single value then it return in arg2 and arg1 == NULL
|
||||
void extractOptFirstArg(char* args, char** arg1, char** arg2);
|
||||
|
||||
uint32 extractSpellIdFromLink(char* text);
|
||||
uint64 extractGuidFromLink(char* text);
|
||||
GameTele const* extractGameTeleFromLink(char* text);
|
||||
bool GetPlayerGroupAndGUIDByName(const char* cname, Player* &plr, Group* &group, uint64 &guid, bool offline = false);
|
||||
std::string extractPlayerNameFromLink(char* text);
|
||||
// select by arg (name/link) or in-game selection online/offline player
|
||||
bool extractPlayerTarget(char* args, Player** player, uint64* player_guid = NULL, std::string* player_name = NULL);
|
||||
|
||||
std::string playerLink(std::string const& name) const { return m_session ? "|cffffffff|Hplayer:"+name+"|h["+name+"]|h|r" : name; }
|
||||
virtual std::string GetNameLink() const { return GetNameLink(m_session->GetPlayer()); }
|
||||
|
||||
+4
-5
@@ -96,7 +96,6 @@ enum TrinityStrings
|
||||
LANG_CANNOT_GO_TO_INST_GM = 105,
|
||||
LANG_CANNOT_GO_INST_INST = 106,
|
||||
LANG_CANNOT_SUMMON_INST_INST = 107,
|
||||
|
||||
LANG_SUMMONING = 108,
|
||||
LANG_SUMMONED_BY = 109,
|
||||
LANG_TELEPORTING_TO = 110,
|
||||
@@ -104,7 +103,6 @@ enum TrinityStrings
|
||||
LANG_NO_PLAYER = 112,
|
||||
LANG_APPEARING_AT = 113,
|
||||
LANG_APPEARING_TO = 114,
|
||||
|
||||
LANG_BAD_VALUE = 115,
|
||||
LANG_NO_CHAR_SELECTED = 116,
|
||||
LANG_NOT_IN_GROUP = 117,
|
||||
@@ -169,7 +167,7 @@ enum TrinityStrings
|
||||
|
||||
LANG_MAIL_SENT = 169,
|
||||
LANG_SOUND_NOT_EXIST = 170,
|
||||
LANG_TELEPORTED_TO_BY_CONSOLE = 171,
|
||||
LANG_CANT_TELEPORT_SELF = 171,
|
||||
LANG_CONSOLE_COMMAND = 172,
|
||||
LANG_YOU_CHANGE_RUNIC_POWER = 173,
|
||||
LANG_YOURS_RUNIC_POWER_CHANGED = 174,
|
||||
@@ -268,7 +266,7 @@ enum TrinityStrings
|
||||
LANG_COMMAND_ADDVENDORITEMITEMS = 280,
|
||||
LANG_COMMAND_KICKSELF = 281,
|
||||
LANG_COMMAND_KICKMESSAGE = 282,
|
||||
LANG_COMMAND_KICKNOTFOUNDPLAYER = 283,
|
||||
// 283, not used
|
||||
LANG_COMMAND_WHISPERACCEPTING = 284,
|
||||
LANG_COMMAND_WHISPERON = 285,
|
||||
LANG_COMMAND_WHISPEROFF = 286,
|
||||
@@ -855,7 +853,8 @@ enum TrinityStrings
|
||||
//LANG_INSTANCE_NOT_AS_GHOST = 5008,
|
||||
LANG_COMMAND_PLAYED_TO_ALL = 5009,
|
||||
LANG_NPCINFO_LINKGUID = 5010,
|
||||
// Room for more Trinity strings 5011-9999
|
||||
LANG_TELEPORTED_TO_BY_CONSOLE = 5011,
|
||||
// Room for more Trinity strings 5012-9999
|
||||
// Used for GM Announcements
|
||||
LANG_GM_BROADCAST = 6613,
|
||||
LANG_GM_NOTIFY = 6614,
|
||||
|
||||
+134
-207
@@ -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)
|
||||
{
|
||||
|
||||
+113
-254
@@ -56,104 +56,89 @@ static uint32 ReputationRankStrIndex[MAX_REPUTATION_RANK] =
|
||||
//mute player for some times
|
||||
bool ChatHandler::HandleMuteCommand(const char* args)
|
||||
{
|
||||
if (!*args)
|
||||
char* nameStr;
|
||||
char* delayStr;
|
||||
extractOptFirstArg((char*)args,&nameStr,&delayStr);
|
||||
if(!delayStr)
|
||||
return false;
|
||||
|
||||
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(nameStr,&target,&target_guid,&target_name))
|
||||
return false;
|
||||
|
||||
uint32 account_id = target ? target->GetSession()->GetAccountId() : objmgr.GetPlayerAccountIdByGUID(target_guid);
|
||||
|
||||
// find only player from same account if any
|
||||
if(!target)
|
||||
{
|
||||
if(WorldSession* session = sWorld.FindSession(account_id))
|
||||
target = session->GetPlayer();
|
||||
}
|
||||
|
||||
char *timetonotspeak = strtok(NULL, " ");
|
||||
if(!timetonotspeak)
|
||||
return false;
|
||||
|
||||
uint32 notspeaktime = (uint32) atoi(timetonotspeak);
|
||||
|
||||
uint64 guid = objmgr.GetPlayerGUIDByName(name);
|
||||
if(!guid)
|
||||
{
|
||||
SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
Player *chr = objmgr.GetPlayer(guid);
|
||||
uint32 notspeaktime = (uint32) atoi(delayStr);
|
||||
|
||||
// must have strong lesser security level
|
||||
if(HasLowerSecurity (chr,guid,true))
|
||||
if(HasLowerSecurity (target,target_guid,true))
|
||||
return false;
|
||||
|
||||
uint32 account_id = chr ? chr->GetSession()->GetAccountId() : objmgr.GetPlayerAccountIdByGUID(guid);
|
||||
|
||||
time_t mutetime = time(NULL) + notspeaktime*60;
|
||||
|
||||
if (chr)
|
||||
chr->GetSession()->m_muteTime = mutetime;
|
||||
if (target)
|
||||
target->GetSession()->m_muteTime = mutetime;
|
||||
|
||||
LoginDatabase.PExecute("UPDATE account SET mutetime = " I64FMTD " WHERE id = '%u'",uint64(mutetime), account_id );
|
||||
|
||||
if(chr)
|
||||
ChatHandler(chr).PSendSysMessage(LANG_YOUR_CHAT_DISABLED, notspeaktime);
|
||||
if(target)
|
||||
ChatHandler(target).PSendSysMessage(LANG_YOUR_CHAT_DISABLED, notspeaktime);
|
||||
|
||||
std::string nameLink = playerLink(name);
|
||||
std::string nameLink = playerLink(target_name);
|
||||
|
||||
PSendSysMessage(LANG_YOU_DISABLE_CHAT, nameLink.c_str(), notspeaktime);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//unmute player
|
||||
bool ChatHandler::HandleUnmuteCommand(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())
|
||||
uint32 account_id = target ? target->GetSession()->GetAccountId() : objmgr.GetPlayerAccountIdByGUID(target_guid);
|
||||
|
||||
// find only player from same account if any
|
||||
if(!target)
|
||||
{
|
||||
SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
if(WorldSession* session = sWorld.FindSession(account_id))
|
||||
target = session->GetPlayer();
|
||||
}
|
||||
|
||||
uint64 guid = objmgr.GetPlayerGUIDByName(name);
|
||||
if(!guid)
|
||||
{
|
||||
SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
Player *chr = objmgr.GetPlayer(guid);
|
||||
|
||||
// must have strong lesser security level
|
||||
if(HasLowerSecurity (chr,guid,true))
|
||||
if(HasLowerSecurity (target,target_guid,true))
|
||||
return false;
|
||||
|
||||
uint32 account_id = chr ? chr->GetSession()->GetAccountId() : objmgr.GetPlayerAccountIdByGUID(guid);
|
||||
|
||||
if (chr)
|
||||
if (target)
|
||||
{
|
||||
if(chr->CanSpeak())
|
||||
if(target->CanSpeak())
|
||||
{
|
||||
SendSysMessage(LANG_CHAT_ALREADY_ENABLED);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
chr->GetSession()->m_muteTime = 0;
|
||||
target->GetSession()->m_muteTime = 0;
|
||||
}
|
||||
|
||||
LoginDatabase.PExecute("UPDATE account SET mutetime = '0' WHERE id = '%u'", account_id );
|
||||
|
||||
if(chr)
|
||||
ChatHandler(chr).PSendSysMessage(LANG_YOUR_CHAT_ENABLED);
|
||||
if(target)
|
||||
ChatHandler(target).PSendSysMessage(LANG_YOUR_CHAT_ENABLED);
|
||||
|
||||
std::string nameLink = playerLink(name);
|
||||
std::string nameLink = playerLink(target_name);
|
||||
|
||||
PSendSysMessage(LANG_YOU_ENABLE_CHAT, nameLink.c_str());
|
||||
return true;
|
||||
@@ -2127,7 +2112,7 @@ bool ChatHandler::HandleModifyMorphCommand(const char* args)
|
||||
//kick player
|
||||
bool ChatHandler::HandleKickPlayerCommand(const char *args)
|
||||
{
|
||||
const char* kickName = strtok((char*)args, " ");
|
||||
/* const char* kickName = strtok((char*)args, " ");
|
||||
char* kickReason = strtok(NULL, "\n");
|
||||
std::string reason = "No Reason";
|
||||
std::string kicker = "Console";
|
||||
@@ -2218,7 +2203,25 @@ bool ChatHandler::HandleKickPlayerCommand(const char *args)
|
||||
PSendSysMessage(LANG_COMMAND_KICKNOTFOUNDPLAYER,nameLink.c_str());
|
||||
return false;
|
||||
}
|
||||
}*/
|
||||
Player* target;
|
||||
if(!extractPlayerTarget((char*)args,&target))
|
||||
return false;
|
||||
|
||||
if (m_session && target==m_session->GetPlayer())
|
||||
{
|
||||
SendSysMessage(LANG_COMMAND_KICKSELF);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
// check online security
|
||||
if (HasLowerSecurity(target, 0))
|
||||
return false;
|
||||
|
||||
// send before target pointer invalidate
|
||||
PSendSysMessage(LANG_COMMAND_KICKMESSAGE,GetNameLink(target).c_str());
|
||||
target->GetSession()->KickPlayer();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2246,48 +2249,15 @@ bool ChatHandler::HandleModifyPhaseCommand(const char* args)
|
||||
//show info of player
|
||||
bool ChatHandler::HandlePInfoCommand(const char* args)
|
||||
{
|
||||
Player* target = NULL;
|
||||
uint64 targetGUID = 0;
|
||||
char* nameStr;
|
||||
char* subcommandStr;
|
||||
extractOptFirstArg((char*)args,&nameStr,&subcommandStr);
|
||||
|
||||
char* px = strtok((char*)args, " ");
|
||||
char* py = NULL;
|
||||
|
||||
std::string name;
|
||||
|
||||
if (px)
|
||||
{
|
||||
name = extractPlayerNameFromLink(px);
|
||||
if(name.empty())
|
||||
{
|
||||
SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
target = objmgr.GetPlayer(name.c_str());
|
||||
if (target)
|
||||
py = strtok(NULL, " ");
|
||||
else
|
||||
{
|
||||
targetGUID = objmgr.GetPlayerGUIDByName(name);
|
||||
if(targetGUID)
|
||||
py = strtok(NULL, " ");
|
||||
else
|
||||
py = px;
|
||||
}
|
||||
}
|
||||
|
||||
if(!target && !targetGUID)
|
||||
{
|
||||
target = getSelectedPlayer();
|
||||
}
|
||||
|
||||
if(!target && !targetGUID)
|
||||
{
|
||||
SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
SetSentErrorMessage(true);
|
||||
Player* target;
|
||||
uint64 target_guid;
|
||||
std::string target_name;
|
||||
if(!extractPlayerTarget(nameStr,&target,&target_guid,&target_name))
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32 accId = 0;
|
||||
uint32 money = 0;
|
||||
@@ -2302,8 +2272,6 @@ bool ChatHandler::HandlePInfoCommand(const char* args)
|
||||
if (HasLowerSecurity(target, 0))
|
||||
return false;
|
||||
|
||||
targetGUID = target->GetGUID();
|
||||
name = target->GetName(); // re-read for case getSelectedPlayer() target
|
||||
accId = target->GetSession()->GetAccountId();
|
||||
money = target->GetMoney();
|
||||
total_player_time = target->GetTotalPlayedTime();
|
||||
@@ -2314,32 +2282,25 @@ bool ChatHandler::HandlePInfoCommand(const char* args)
|
||||
else
|
||||
{
|
||||
// check offline security
|
||||
if (HasLowerSecurity(NULL, targetGUID))
|
||||
if (HasLowerSecurity(NULL, target_guid))
|
||||
return false;
|
||||
|
||||
// 0
|
||||
QueryResult *result = CharacterDatabase.PQuery("SELECT totaltime FROM characters WHERE guid = '%u'", GUID_LOPART(targetGUID));
|
||||
QueryResult *result = CharacterDatabase.PQuery("SELECT totaltime FROM characters WHERE guid = '%u'", GUID_LOPART(target_guid));
|
||||
if (!result)
|
||||
{
|
||||
SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
Field *fields = result->Fetch();
|
||||
total_player_time = fields[0].GetUInt32();
|
||||
delete result;
|
||||
|
||||
Tokens data;
|
||||
if (!Player::LoadValuesArrayFromDB(data,targetGUID))
|
||||
{
|
||||
SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
SetSentErrorMessage(true);
|
||||
if (!Player::LoadValuesArrayFromDB(data,target_guid))
|
||||
return false;
|
||||
}
|
||||
|
||||
money = Player::GetUInt32ValueFromArray(data, PLAYER_FIELD_COINAGE);
|
||||
level = Player::GetUInt32ValueFromArray(data, UNIT_FIELD_LEVEL);
|
||||
accId = objmgr.GetPlayerAccountIdByGUID(targetGUID);
|
||||
accId = objmgr.GetPlayerAccountIdByGUID(target_guid);
|
||||
}
|
||||
|
||||
std::string username = GetTrinityString(LANG_ERROR);
|
||||
@@ -2368,9 +2329,9 @@ bool ChatHandler::HandlePInfoCommand(const char* args)
|
||||
delete result;
|
||||
}
|
||||
|
||||
std::string nameLink = playerLink(name);
|
||||
std::string nameLink = playerLink(target_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);
|
||||
PSendSysMessage(LANG_PINFO_ACCOUNT, (target?"":GetMangosString(LANG_OFFLINE)), nameLink.c_str(), GUID_LOPART(target_guid), 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;
|
||||
@@ -2378,7 +2339,7 @@ bool ChatHandler::HandlePInfoCommand(const char* args)
|
||||
uint32 copp = (money % GOLD) % SILVER;
|
||||
PSendSysMessage(LANG_PINFO_LEVEL, timeStr.c_str(), level, gold,silv,copp );
|
||||
|
||||
if ( py && strncmp(py, "rep", 3) == 0 )
|
||||
if( subcommandStr && strncmp(subcommandStr, "rep", 3) == 0 )
|
||||
{
|
||||
if(!target)
|
||||
{
|
||||
@@ -2507,27 +2468,18 @@ bool ChatHandler::HandleTicketCommand(const char* args)
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string name = extractPlayerNameFromLink(px);
|
||||
if(name.empty())
|
||||
{
|
||||
SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
uint64 guid = objmgr.GetPlayerGUIDByName(name);
|
||||
|
||||
if(!guid)
|
||||
uint64 target_guid;
|
||||
if(!extractPlayerTarget(px,NULL,&target_guid))
|
||||
return false;
|
||||
|
||||
// ticket $char_name
|
||||
GMTicket* ticket = ticketmgr.GetGMTicket(GUID_LOPART(guid));
|
||||
GMTicket* ticket = ticketmgr.GetGMTicket(GUID_LOPART(target_guid));
|
||||
if(!ticket)
|
||||
return false;
|
||||
|
||||
std::string time = TimeToTimestampStr(ticket->GetLastUpdate());
|
||||
|
||||
ShowTicket(guid, ticket->GetText(), time.c_str());
|
||||
ShowTicket(target_guid, ticket->GetText(), time.c_str());
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -2577,27 +2529,20 @@ bool ChatHandler::HandleDelTicketCommand(const char *args)
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string name = extractPlayerNameFromLink(px);
|
||||
if(name.empty())
|
||||
{
|
||||
SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
uint64 guid = objmgr.GetPlayerGUIDByName(name);
|
||||
|
||||
if(!guid)
|
||||
Player* target;
|
||||
uint64 target_guid;
|
||||
std::string target_name;
|
||||
if(!extractPlayerTarget(px,&target,&target_guid,&target_name))
|
||||
return false;
|
||||
|
||||
// delticket $char_name
|
||||
ticketmgr.Delete(GUID_LOPART(guid));
|
||||
ticketmgr.Delete(GUID_LOPART(target_guid));
|
||||
|
||||
// notify players about ticket deleting
|
||||
if(Player* sender = objmgr.GetPlayer(guid))
|
||||
sender->GetSession()->SendGMTicketGetTicket(0x0A,0);
|
||||
if(target)
|
||||
target->GetSession()->SendGMTicketGetTicket(0x0A,0);
|
||||
|
||||
std::string nameLink = playerLink(name);
|
||||
std::string nameLink = playerLink(target_name);
|
||||
|
||||
PSendSysMessage(LANG_COMMAND_TICKETPLAYERDEL,nameLink.c_str());
|
||||
return true;
|
||||
@@ -3644,39 +3589,11 @@ bool ChatHandler::HandleWpShowCommand(const char* args)
|
||||
//rename characters
|
||||
bool ChatHandler::HandleCharacterRenameCommand(const char* args)
|
||||
{
|
||||
Player* target = NULL;
|
||||
uint64 targetGUID = 0;
|
||||
std::string oldname;
|
||||
|
||||
char* px = strtok((char*)args, " ");
|
||||
|
||||
if(px)
|
||||
{
|
||||
oldname = extractPlayerNameFromLink(px);
|
||||
if(oldname.empty())
|
||||
{
|
||||
SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
target = objmgr.GetPlayer(oldname.c_str());
|
||||
|
||||
if (!target)
|
||||
targetGUID = objmgr.GetPlayerGUIDByName(oldname);
|
||||
}
|
||||
|
||||
if(!target && !targetGUID)
|
||||
{
|
||||
target = getSelectedPlayer();
|
||||
}
|
||||
|
||||
if(!target && !targetGUID)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
if(target)
|
||||
{
|
||||
@@ -3691,13 +3608,13 @@ bool ChatHandler::HandleCharacterRenameCommand(const char* args)
|
||||
else
|
||||
{
|
||||
// check offline security
|
||||
if (HasLowerSecurity(NULL, targetGUID))
|
||||
if (HasLowerSecurity(NULL, target_guid))
|
||||
return false;
|
||||
|
||||
std::string oldNameLink = playerLink(oldname);
|
||||
std::string oldNameLink = playerLink(target_name);
|
||||
|
||||
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));
|
||||
PSendSysMessage(LANG_RENAME_PLAYER_GUID, oldNameLink.c_str(), GUID_LOPART(target_guid));
|
||||
CharacterDatabase.PExecute("UPDATE characters SET at_login = at_login | '1' WHERE guid = '%u'", GUID_LOPART(target_guid));
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -3706,39 +3623,11 @@ bool ChatHandler::HandleCharacterRenameCommand(const char* args)
|
||||
// customize characters
|
||||
bool ChatHandler::HandleCharacterCustomizeCommand(const char* args)
|
||||
{
|
||||
Player* target = NULL;
|
||||
uint64 targetGUID = 0;
|
||||
std::string oldname;
|
||||
|
||||
char* px = strtok((char*)args, " ");
|
||||
|
||||
if(px)
|
||||
{
|
||||
oldname = extractPlayerNameFromLink(px);
|
||||
if(oldname.empty())
|
||||
{
|
||||
SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
target = objmgr.GetPlayer(oldname.c_str());
|
||||
|
||||
if (!target)
|
||||
targetGUID = objmgr.GetPlayerGUIDByName(oldname);
|
||||
}
|
||||
|
||||
if(!target && !targetGUID)
|
||||
{
|
||||
target = getSelectedPlayer();
|
||||
}
|
||||
|
||||
if(!target && !targetGUID)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
if(target)
|
||||
{
|
||||
@@ -3748,10 +3637,10 @@ bool ChatHandler::HandleCharacterCustomizeCommand(const char* args)
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string oldNameLink = playerLink(oldname);
|
||||
std::string oldNameLink = playerLink(target_name);
|
||||
|
||||
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));
|
||||
PSendSysMessage(LANG_CUSTOMIZE_PLAYER_GUID, oldNameLink.c_str(), GUID_LOPART(target_guid));
|
||||
CharacterDatabase.PExecute("UPDATE characters SET at_login = at_login | '8' WHERE guid = '%u'", GUID_LOPART(target_guid));
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -4035,41 +3924,16 @@ bool ChatHandler::HandleEventStopCommand(const char* args)
|
||||
|
||||
bool ChatHandler::HandleCombatStopCommand(const char* args)
|
||||
{
|
||||
Player *player;
|
||||
|
||||
if(*args)
|
||||
{
|
||||
std::string playername = extractPlayerNameFromLink((char*)args);
|
||||
if(playername.empty())
|
||||
{
|
||||
SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
player = objmgr.GetPlayer(playername.c_str());
|
||||
|
||||
if(!player)
|
||||
{
|
||||
SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
player = getSelectedPlayer();
|
||||
|
||||
if (!player)
|
||||
player = m_session->GetPlayer();
|
||||
}
|
||||
|
||||
// check online security
|
||||
if (HasLowerSecurity(player, 0))
|
||||
Player* target;
|
||||
if(!extractPlayerTarget((char*)args,&target))
|
||||
return false;
|
||||
|
||||
player->CombatStop();
|
||||
player->getHostilRefManager().deleteReferences();
|
||||
// check online security
|
||||
if (HasLowerSecurity(target, 0))
|
||||
return false;
|
||||
|
||||
target->CombatStop();
|
||||
target->getHostilRefManager().deleteReferences();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -4303,16 +4167,11 @@ bool ChatHandler::HandleServerCorpsesCommand(const char* /*args*/)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleRepairitemsCommand(const char* /*args*/)
|
||||
bool ChatHandler::HandleRepairitemsCommand(const char* args)
|
||||
{
|
||||
Player *target = getSelectedPlayer();
|
||||
|
||||
if(!target)
|
||||
{
|
||||
PSendSysMessage(LANG_NO_CHAR_SELECTED);
|
||||
SetSentErrorMessage(true);
|
||||
Player* target;
|
||||
if(!extractPlayerTarget((char*)args,&target))
|
||||
return false;
|
||||
}
|
||||
|
||||
// check online security
|
||||
if (HasLowerSecurity(target, 0))
|
||||
@@ -4498,7 +4357,7 @@ bool ChatHandler::HandlePetUnlearnCommand(const char *args)
|
||||
uint32 spellId = extractSpellIdFromLink((char*)args);
|
||||
|
||||
if(pet->HasSpell(spellId))
|
||||
pet->removeSpell(spellId);
|
||||
pet->removeSpell(spellId, false);
|
||||
else
|
||||
PSendSysMessage("Pet doesn't have that spell");
|
||||
|
||||
|
||||
+188
-569
File diff suppressed because it is too large
Load Diff
+71
-26
@@ -275,7 +275,7 @@ bool Pet::LoadPetFromDB( Player* owner, uint32 petentry, uint32 petnumber, bool
|
||||
_LoadSpells();
|
||||
_LoadSpellCooldowns();
|
||||
LearnPetPassives();
|
||||
learnLevelupSpells();
|
||||
InitLevelupSpellsForLevel();
|
||||
CastPetAuras(current);
|
||||
|
||||
// Load action bar data
|
||||
@@ -352,6 +352,8 @@ bool Pet::LoadPetFromDB( Player* owner, uint32 petentry, uint32 petnumber, bool
|
||||
}
|
||||
}
|
||||
|
||||
//InitLevelupSpellsForLevel();
|
||||
|
||||
m_loading = false;
|
||||
|
||||
SynchronizeLevelWithOwner();
|
||||
@@ -660,6 +662,9 @@ bool Pet::CanTakeMoreActiveSpells(uint32 spellid)
|
||||
|
||||
for (PetSpellMap::const_iterator itr = m_spells.begin(); itr != m_spells.end(); ++itr)
|
||||
{
|
||||
if(itr->second.state == PETSPELL_REMOVED)
|
||||
continue;
|
||||
|
||||
if(IsPassiveSpell(itr->first))
|
||||
continue;
|
||||
|
||||
@@ -736,8 +741,8 @@ void Pet::GivePetLevel(uint32 level)
|
||||
return;
|
||||
|
||||
InitStatsForLevel(level);
|
||||
InitLevelupSpellsForLevel();
|
||||
InitTalentForLevel();
|
||||
learnLevelupSpells();
|
||||
}
|
||||
|
||||
bool Pet::CreateBaseAtCreature(Creature* creature)
|
||||
@@ -1095,7 +1100,7 @@ void Pet::_LoadSpells()
|
||||
{
|
||||
Field *fields = result->Fetch();
|
||||
|
||||
addSpell(fields[0].GetUInt32(), fields[1].GetUInt16(), PETSPELL_UNCHANGED);
|
||||
addSpell(fields[0].GetUInt32(), ActiveStates(fields[1].GetUInt16()), PETSPELL_UNCHANGED);
|
||||
}
|
||||
while( result->NextRow() );
|
||||
|
||||
@@ -1227,7 +1232,7 @@ void Pet::_SaveAuras()
|
||||
}
|
||||
}
|
||||
|
||||
bool Pet::addSpell(uint32 spell_id,uint16 active /*= ACT_DECIDE*/, PetSpellState state /*= PETSPELL_NEW*/, PetSpellType type /*= PETSPELL_NORMAL*/)
|
||||
bool Pet::addSpell(uint32 spell_id,ActiveStates active /*= ACT_DECIDE*/, PetSpellState state /*= PETSPELL_NEW*/, PetSpellType type /*= PETSPELL_NORMAL*/)
|
||||
{
|
||||
SpellEntry const *spellInfo = sSpellStore.LookupEntry(spell_id);
|
||||
if (!spellInfo)
|
||||
@@ -1303,26 +1308,33 @@ bool Pet::addSpell(uint32 spell_id,uint16 active /*= ACT_DECIDE*/, PetSpellState
|
||||
// skip unknown ranks
|
||||
if(!HasSpell(rankSpellId))
|
||||
continue;
|
||||
removeSpell(rankSpellId);
|
||||
removeSpell(rankSpellId,false);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(uint32 chainstart = spellmgr.GetFirstSpellInChain(spell_id))
|
||||
else if(spellmgr.GetSpellRank(spell_id)!=0)
|
||||
{
|
||||
for (PetSpellMap::const_iterator itr2 = m_spells.begin(); itr2 != m_spells.end(); ++itr2)
|
||||
{
|
||||
if(itr2->second.state == PETSPELL_REMOVED) continue;
|
||||
|
||||
if(spellmgr.GetFirstSpellInChain(itr2->first) == chainstart)
|
||||
if( spellmgr.IsRankSpellDueToSpell(spellInfo,itr2->first) )
|
||||
{
|
||||
newspell.active = itr2->second.active;
|
||||
// replace by new high rank
|
||||
if(spellmgr.IsHighRankOfSpell(spell_id,itr2->first))
|
||||
{
|
||||
newspell.active = itr2->second.active;
|
||||
|
||||
if(newspell.active == ACT_ENABLED)
|
||||
ToggleAutocast(itr2->first, false);
|
||||
if(newspell.active == ACT_ENABLED)
|
||||
ToggleAutocast(itr2->first, false);
|
||||
|
||||
oldspell_id = itr2->first;
|
||||
unlearnSpell(itr2->first);
|
||||
break;
|
||||
oldspell_id = itr2->first;
|
||||
unlearnSpell(itr2->first,false);
|
||||
break;
|
||||
}
|
||||
// ignore new lesser rank
|
||||
else if(spellmgr.IsHighRankOfSpell(itr2->first,spell_id))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1331,7 +1343,8 @@ bool Pet::addSpell(uint32 spell_id,uint16 active /*= ACT_DECIDE*/, PetSpellState
|
||||
|
||||
if (IsPassiveSpell(spell_id))
|
||||
CastSpell(this, spell_id, true);
|
||||
else if(state == PETSPELL_NEW)
|
||||
else
|
||||
//m_charmInfo->AddSpellToAB(oldspell_id, spell_id);
|
||||
m_charmInfo->AddSpellToAB(oldspell_id, spell_id, (ActiveStates)active);
|
||||
|
||||
if(newspell.active == ACT_ENABLED)
|
||||
@@ -1365,22 +1378,33 @@ bool Pet::learnSpell(uint32 spell_id)
|
||||
return true;
|
||||
}
|
||||
|
||||
void Pet::learnLevelupSpells()
|
||||
void Pet::InitLevelupSpellsForLevel()
|
||||
{
|
||||
PetLevelupSpellMap const * spell_map = spellmgr.GetPetLevelupSpellMap();
|
||||
int8 level = getLevel();
|
||||
for(PetLevelupSpellMap::const_iterator itr = spell_map->lower_bound(GetCreatureInfo()->family); itr != spell_map->upper_bound(GetCreatureInfo()->family); ++itr)
|
||||
uint32 family = GetCreatureInfo()->family;
|
||||
if(!family)
|
||||
return;
|
||||
|
||||
PetLevelupSpellSet const *levelupSpells = spellmgr.GetPetLevelupSpellList(family);
|
||||
if(!levelupSpells)
|
||||
return;
|
||||
|
||||
uint32 level = getLevel();
|
||||
|
||||
// PetLevelupSpellSet ordered by levels, process in reversed order
|
||||
for(PetLevelupSpellSet::const_reverse_iterator itr = levelupSpells->rbegin(); itr != levelupSpells->rend(); ++itr)
|
||||
{
|
||||
if(itr->second.first <= level)
|
||||
learnSpell(itr->second.second);
|
||||
// will called first if level down
|
||||
if(itr->first > level)
|
||||
unlearnSpell(itr->second,true); // will learn prev rank if any
|
||||
// will called if level up
|
||||
else
|
||||
unlearnSpell(itr->second.second);
|
||||
learnSpell(itr->second); // will unlearn prev rank if any
|
||||
}
|
||||
}
|
||||
|
||||
bool Pet::unlearnSpell(uint32 spell_id)
|
||||
bool Pet::unlearnSpell(uint32 spell_id, bool learn_prev)
|
||||
{
|
||||
if(removeSpell(spell_id))
|
||||
if(removeSpell(spell_id,learn_prev))
|
||||
{
|
||||
if(!m_loading)
|
||||
{
|
||||
@@ -1393,7 +1417,7 @@ bool Pet::unlearnSpell(uint32 spell_id)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Pet::removeSpell(uint32 spell_id)
|
||||
bool Pet::removeSpell(uint32 spell_id, bool learn_prev)
|
||||
{
|
||||
PetSpellMap::iterator itr = m_spells.find(spell_id);
|
||||
if (itr == m_spells.end())
|
||||
@@ -1421,6 +1445,27 @@ bool Pet::removeSpell(uint32 spell_id)
|
||||
SetFreeTalentPoints(free_points > 0 ? free_points : 0);
|
||||
}
|
||||
|
||||
if (learn_prev)
|
||||
{
|
||||
if (uint32 prev_id = spellmgr.GetPrevSpellInChain (spell_id))
|
||||
{
|
||||
// replace to next spell
|
||||
if(!talentCost && !IsPassiveSpell(prev_id))
|
||||
m_charmInfo->AddSpellToAB(spell_id, prev_id);
|
||||
|
||||
learnSpell(prev_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_charmInfo->AddSpellToAB(spell_id, 0);
|
||||
|
||||
// need update action bar for last removed rank
|
||||
if (Unit* owner = GetOwner())
|
||||
if (owner->GetTypeId() == TYPEID_PLAYER)
|
||||
((Player*)owner)->PetSpellInitialize();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1462,7 +1507,7 @@ void Pet::InitPetCreateSpells()
|
||||
}
|
||||
|
||||
LearnPetPassives();
|
||||
learnLevelupSpells();
|
||||
InitLevelupSpellsForLevel();
|
||||
|
||||
CastPetAuras(false);
|
||||
}
|
||||
@@ -1557,7 +1602,7 @@ bool Pet::resetTalents(bool no_cost)
|
||||
// unlearn if first rank is talent or learned by talent
|
||||
if (itrFirstId == talentInfo->RankID[j] || spellmgr.IsSpellLearnToSpell(talentInfo->RankID[j],itrFirstId))
|
||||
{
|
||||
removeSpell(itr->first);
|
||||
removeSpell(itr->first,false);
|
||||
itr = m_spells.begin();
|
||||
continue;
|
||||
}
|
||||
|
||||
+6
-6
@@ -70,7 +70,7 @@ enum PetSpellType
|
||||
|
||||
struct PetSpell
|
||||
{
|
||||
uint16 active;
|
||||
ActiveStates active : 16;
|
||||
|
||||
PetSpellState state : 8;
|
||||
PetSpellType type : 8;
|
||||
@@ -199,12 +199,12 @@ class Pet : public Guardian
|
||||
void _LoadSpells();
|
||||
void _SaveSpells();
|
||||
|
||||
bool addSpell(uint32 spell_id,uint16 active = ACT_DECIDE, PetSpellState state = PETSPELL_NEW, PetSpellType type = PETSPELL_NORMAL);
|
||||
bool addSpell(uint32 spell_id,ActiveStates active = ACT_DECIDE, PetSpellState state = PETSPELL_NEW, PetSpellType type = PETSPELL_NORMAL);
|
||||
bool learnSpell(uint32 spell_id);
|
||||
void learnSpellHighRank(uint32 spellid);
|
||||
void learnLevelupSpells();
|
||||
bool unlearnSpell(uint32 spell_id);
|
||||
bool removeSpell(uint32 spell_id);
|
||||
void InitLevelupSpellsForLevel();
|
||||
bool unlearnSpell(uint32 spell_id, bool learn_prev);
|
||||
bool removeSpell(uint32 spell_id, bool learn_prev);
|
||||
|
||||
PetSpellMap m_spells;
|
||||
TeachSpellMap m_teachspells;
|
||||
@@ -255,5 +255,5 @@ class Pet : public Guardian
|
||||
assert(false);
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
+13
-4
@@ -1944,6 +1944,8 @@ void SpellMgr::LoadPetLevelupSpellMap()
|
||||
mPetLevelupSpellMap.clear(); // need for reload case
|
||||
|
||||
uint32 count = 0;
|
||||
uint32 family_count = 0;
|
||||
|
||||
for (uint32 i = 0; i < sCreatureFamilyStore.GetNumRows(); ++i)
|
||||
{
|
||||
CreatureFamilyEntry const *creatureFamily = sCreatureFamilyStore.LookupEntry(i);
|
||||
@@ -1968,17 +1970,24 @@ void SpellMgr::LoadPetLevelupSpellMap()
|
||||
continue;
|
||||
|
||||
SpellEntry const *spell = sSpellStore.LookupEntry(skillLine->spellId);
|
||||
// not exist or triggered or talent
|
||||
if(!spell || !spell->spellLevel)
|
||||
if(!spell) // not exist or triggered or talent
|
||||
continue;
|
||||
mPetLevelupSpellMap.insert(PetLevelupSpellMap::value_type(creatureFamily->ID, std::make_pair(spell->spellLevel , spell->Id )));
|
||||
|
||||
if(!spell->spellLevel)
|
||||
continue;
|
||||
|
||||
PetLevelupSpellSet& spellSet = mPetLevelupSpellMap[creatureFamily->ID];
|
||||
if(spellSet.empty())
|
||||
++family_count;
|
||||
|
||||
spellSet.insert(PetLevelupSpellSet::value_type(spell->spellLevel,spell->Id));
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sLog.outString();
|
||||
sLog.outString( ">> Loaded %u pet levelup spells", count );
|
||||
sLog.outString( ">> Loaded %u pet levelup and default spells for %u families", count, family_count );
|
||||
}
|
||||
|
||||
/// Some checks for spells, to prevent adding deprecated/broken spells for trainers, spell book, etc
|
||||
|
||||
+11
-8
@@ -668,9 +668,8 @@ typedef std::multimap<uint32, SpellLearnSpellNode> SpellLearnSpellMap;
|
||||
|
||||
typedef std::multimap<uint32, SkillLineAbilityEntry const*> SkillLineAbilityMap;
|
||||
|
||||
//typedef std::multimap<uint32, uint32> PetLevelupSpellSet;
|
||||
//typedef std::map<uint32, PetLevelupSpellSet> PetLevelupSpellMap;
|
||||
typedef std::multimap<uint32, std::pair < uint32,uint32 > >PetLevelupSpellMap;
|
||||
typedef std::multimap<uint32, uint32> PetLevelupSpellSet;
|
||||
typedef std::map<uint32, PetLevelupSpellSet> PetLevelupSpellMap;
|
||||
|
||||
inline bool IsPrimaryProfessionSkill(uint32 skill)
|
||||
{
|
||||
@@ -969,6 +968,15 @@ class SpellMgr
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PetLevelupSpellSet const* GetPetLevelupSpellList(uint32 petFamily) const
|
||||
{
|
||||
PetLevelupSpellMap::const_iterator itr = mPetLevelupSpellMap.find(petFamily);
|
||||
if(itr != mPetLevelupSpellMap.end())
|
||||
return &itr->second;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
uint32 GetSpellCustomAttr(uint32 spell_id) const
|
||||
{
|
||||
if(spell_id >= mSpellCustomAttr.size())
|
||||
@@ -1016,11 +1024,6 @@ class SpellMgr
|
||||
return SpellAreaForAreaMapBounds(mSpellAreaForAreaMap.lower_bound(area_id),mSpellAreaForAreaMap.upper_bound(area_id));
|
||||
}
|
||||
|
||||
PetLevelupSpellMap const * GetPetLevelupSpellMap() const
|
||||
{
|
||||
return &mPetLevelupSpellMap;
|
||||
}
|
||||
|
||||
// Modifiers
|
||||
public:
|
||||
static SpellMgr& Instance();
|
||||
|
||||
+24
-13
@@ -11767,20 +11767,30 @@ void CharmInfo::InitCharmCreateSpells()
|
||||
|
||||
bool CharmInfo::AddSpellToAB(uint32 oldid, uint32 newid, ActiveStates newstate)
|
||||
{
|
||||
for(uint8 i = 0; i < 10; i++)
|
||||
{
|
||||
if((PetActionBar[i].Type == ACT_DISABLED || PetActionBar[i].Type == ACT_ENABLED || PetActionBar[i].Type == ACT_PASSIVE) && PetActionBar[i].SpellOrAction == oldid)
|
||||
{
|
||||
PetActionBar[i].SpellOrAction = newid;
|
||||
if(!oldid)
|
||||
{
|
||||
if(newstate == ACT_DECIDE)
|
||||
PetActionBar[i].Type = ACT_DISABLED;
|
||||
else
|
||||
PetActionBar[i].Type = newstate;
|
||||
}
|
||||
// new spell already listed for example in case prepered switch to lesser rank in Pet::removeSpell
|
||||
for(uint8 i = 0; i < 10; ++i)
|
||||
if (PetActionBar[i].Type == ACT_DISABLED || PetActionBar[i].Type == ACT_ENABLED || PetActionBar[i].Type == ACT_PASSIVE)
|
||||
if (newid && PetActionBar[i].SpellOrAction == newid)
|
||||
return true;
|
||||
|
||||
return true;
|
||||
// old spell can be leasted for example in case learn high rank
|
||||
for(uint8 i = 0; i < 10; ++i)
|
||||
{
|
||||
if (PetActionBar[i].Type == ACT_DISABLED || PetActionBar[i].Type == ACT_ENABLED || PetActionBar[i].Type == ACT_PASSIVE)
|
||||
{
|
||||
if (PetActionBar[i].SpellOrAction == oldid)
|
||||
{
|
||||
PetActionBar[i].SpellOrAction = newid;
|
||||
if (!oldid)
|
||||
{
|
||||
if (newstate == ACT_DECIDE)
|
||||
PetActionBar[i].Type = ACT_DISABLED;
|
||||
else
|
||||
PetActionBar[i].Type = newstate;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@@ -12795,6 +12805,7 @@ Pet* Unit::CreateTamedPetFrom(Creature* creatureTarget,uint32 spell_id)
|
||||
pet->GetCharmInfo()->SetPetNumber(objmgr.GeneratePetNumber(), true);
|
||||
// this enables pet details window (Shift+P)
|
||||
pet->InitPetCreateSpells();
|
||||
//pet->InitLevelupSpellsForLevel();
|
||||
pet->InitTalentForLevel();
|
||||
pet->SetHealth(pet->GetMaxHealth());
|
||||
|
||||
|
||||
@@ -2830,31 +2830,6 @@ void World::KickAllLess(AccountTypes sec)
|
||||
itr->second->KickPlayer();
|
||||
}
|
||||
|
||||
/// Kick (and save) the designated player
|
||||
bool World::KickPlayer(const std::string& playerName)
|
||||
{
|
||||
SessionMap::const_iterator itr;
|
||||
|
||||
// session not removed at kick and will removed in next update tick
|
||||
for (itr = m_sessions.begin(); itr != m_sessions.end(); ++itr)
|
||||
{
|
||||
if(!itr->second)
|
||||
continue;
|
||||
Player *player = itr->second->GetPlayer();
|
||||
if(!player)
|
||||
continue;
|
||||
if( player->IsInWorld() )
|
||||
{
|
||||
if (playerName == player->GetName())
|
||||
{
|
||||
itr->second->KickPlayer();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// Ban an account or ban an IP address, duration will be parsed using TimeStringToSecs if it is positive, otherwise permban
|
||||
BanReturn World::BanAccount(BanMode mode, std::string nameOrIP, std::string duration, std::string reason, std::string author)
|
||||
{
|
||||
|
||||
@@ -526,7 +526,6 @@ class World
|
||||
bool IsPvPRealm() { return (getConfig(CONFIG_GAME_TYPE) == REALM_TYPE_PVP || getConfig(CONFIG_GAME_TYPE) == REALM_TYPE_RPPVP || getConfig(CONFIG_GAME_TYPE) == REALM_TYPE_FFA_PVP); }
|
||||
bool IsFFAPvPRealm() { return getConfig(CONFIG_GAME_TYPE) == REALM_TYPE_FFA_PVP; }
|
||||
|
||||
bool KickPlayer(const std::string& playerName);
|
||||
void KickAll();
|
||||
void KickAllLess(AccountTypes sec);
|
||||
BanReturn BanAccount(BanMode mode, std::string nameOrIP, std::string duration, std::string reason, std::string author);
|
||||
|
||||
Reference in New Issue
Block a user