mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-23 18:36:31 +01:00
Convert misc commands in commandscript
This commit is contained in:
@@ -67,17 +67,6 @@ static size_t appendCommandTable(ChatCommand* target, const ChatCommand* source)
|
||||
|
||||
ChatCommand* ChatHandler::getCommandTable()
|
||||
{
|
||||
static ChatCommand channelSetCommandTable[] =
|
||||
{
|
||||
{ "ownership", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleChannelSetOwnership>, "", NULL },
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
|
||||
static ChatCommand channelCommandTable[] =
|
||||
{
|
||||
{ "set", SEC_ADMINISTRATOR, true, NULL, "", channelSetCommandTable },
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
|
||||
static ChatCommand groupCommandTable[] =
|
||||
{
|
||||
@@ -87,14 +76,6 @@ ChatCommand* ChatHandler::getCommandTable()
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
|
||||
static ChatCommand petCommandTable[] =
|
||||
{
|
||||
{ "create", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleCreatePetCommand>, "", NULL },
|
||||
{ "learn", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandlePetLearnCommand>, "", NULL },
|
||||
{ "unlearn", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandlePetUnlearnCommand>, "", NULL },
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
|
||||
static ChatCommand pdumpCommandTable[] =
|
||||
{
|
||||
{ "load", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandlePDumpLoadCommand>, "", NULL },
|
||||
@@ -102,81 +83,11 @@ ChatCommand* ChatHandler::getCommandTable()
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
|
||||
static ChatCommand sendCommandTable[] =
|
||||
{
|
||||
{ "items", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleSendItemsCommand>, "", NULL },
|
||||
{ "mail", SEC_MODERATOR, true, OldHandler<&ChatHandler::HandleSendMailCommand>, "", NULL },
|
||||
{ "message", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleSendMessageCommand>, "", NULL },
|
||||
{ "money", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleSendMoneyCommand>, "", NULL },
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
|
||||
static ChatCommand commandTable[] =
|
||||
{
|
||||
{ "pdump", SEC_ADMINISTRATOR, true, NULL, "", pdumpCommandTable },
|
||||
{ "group", SEC_ADMINISTRATOR, false, NULL, "", groupCommandTable },
|
||||
|
||||
{ "channel", SEC_ADMINISTRATOR, true, NULL, "", channelCommandTable },
|
||||
|
||||
{ "pet", SEC_GAMEMASTER, false, NULL, "", petCommandTable },
|
||||
|
||||
{ "aura", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleAuraCommand>, "", NULL },
|
||||
{ "unaura", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleUnAuraCommand>, "", NULL },
|
||||
{ "nameannounce", SEC_MODERATOR, true, OldHandler<&ChatHandler::HandleNameAnnounceCommand>, "", NULL },
|
||||
{ "gmnameannounce", SEC_MODERATOR, true, OldHandler<&ChatHandler::HandleGMNameAnnounceCommand>, "", NULL },
|
||||
{ "announce", SEC_MODERATOR, true, OldHandler<&ChatHandler::HandleAnnounceCommand>, "", NULL },
|
||||
{ "gmannounce", SEC_MODERATOR, true, OldHandler<&ChatHandler::HandleGMAnnounceCommand>, "", NULL },
|
||||
{ "notify", SEC_MODERATOR, true, OldHandler<&ChatHandler::HandleNotifyCommand>, "", NULL },
|
||||
{ "gmnotify", SEC_MODERATOR, true, OldHandler<&ChatHandler::HandleGMNotifyCommand>, "", NULL },
|
||||
{ "appear", SEC_MODERATOR, false, OldHandler<&ChatHandler::HandleAppearCommand>, "", NULL },
|
||||
{ "summon", SEC_MODERATOR, false, OldHandler<&ChatHandler::HandleSummonCommand>, "", NULL },
|
||||
{ "groupsummon", SEC_MODERATOR, false, OldHandler<&ChatHandler::HandleGroupSummonCommand>, "", NULL },
|
||||
{ "commands", SEC_PLAYER, true, OldHandler<&ChatHandler::HandleCommandsCommand>, "", NULL },
|
||||
{ "die", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleDieCommand>, "", NULL },
|
||||
{ "revive", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReviveCommand>, "", NULL },
|
||||
{ "dismount", SEC_PLAYER, false, OldHandler<&ChatHandler::HandleDismountCommand>, "", NULL },
|
||||
{ "guid", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleGUIDCommand>, "", NULL },
|
||||
{ "help", SEC_PLAYER, true, OldHandler<&ChatHandler::HandleHelpCommand>, "", NULL },
|
||||
{ "itemmove", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleItemMoveCommand>, "", NULL },
|
||||
{ "cooldown", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleCooldownCommand>, "", NULL },
|
||||
{ "unlearn", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleUnLearnCommand>, "", NULL },
|
||||
{ "distance", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleGetDistanceCommand>, "", NULL },
|
||||
{ "recall", SEC_MODERATOR, false, OldHandler<&ChatHandler::HandleRecallCommand>, "", NULL },
|
||||
{ "save", SEC_PLAYER, false, OldHandler<&ChatHandler::HandleSaveCommand>, "", NULL },
|
||||
{ "saveall", SEC_MODERATOR, true, OldHandler<&ChatHandler::HandleSaveAllCommand>, "", NULL },
|
||||
{ "kick", SEC_GAMEMASTER, true, OldHandler<&ChatHandler::HandleKickPlayerCommand>, "", NULL },
|
||||
{ "start", SEC_PLAYER, false, OldHandler<&ChatHandler::HandleStartCommand>, "", NULL },
|
||||
{ "taxicheat", SEC_MODERATOR, false, OldHandler<&ChatHandler::HandleTaxiCheatCommand>, "", NULL },
|
||||
{ "linkgrave", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleLinkGraveCommand>, "", NULL },
|
||||
{ "neargrave", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleNearGraveCommand>, "", NULL },
|
||||
{ "explorecheat", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleExploreCheatCommand>, "", NULL },
|
||||
{ "levelup", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleLevelUpCommand>, "", NULL },
|
||||
{ "showarea", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleShowAreaCommand>, "", NULL },
|
||||
{ "hidearea", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleHideAreaCommand>, "", NULL },
|
||||
{ "additem", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleAddItemCommand>, "", NULL },
|
||||
{ "additemset", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleAddItemSetCommand>, "", NULL },
|
||||
{ "bank", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleBankCommand>, "", NULL },
|
||||
{ "wchange", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleChangeWeather>, "", NULL },
|
||||
{ "maxskill", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleMaxSkillCommand>, "", NULL },
|
||||
{ "setskill", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleSetSkillCommand>, "", NULL },
|
||||
{ "whispers", SEC_MODERATOR, false, OldHandler<&ChatHandler::HandleWhispersCommand>, "", NULL },
|
||||
{ "pinfo", SEC_GAMEMASTER, true, OldHandler<&ChatHandler::HandlePInfoCommand>, "", NULL },
|
||||
{ "respawn", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleRespawnCommand>, "", NULL },
|
||||
{ "send", SEC_MODERATOR, true, NULL, "", sendCommandTable },
|
||||
{ "mute", SEC_MODERATOR, true, OldHandler<&ChatHandler::HandleMuteCommand>, "", NULL },
|
||||
{ "unmute", SEC_MODERATOR, true, OldHandler<&ChatHandler::HandleUnmuteCommand>, "", NULL },
|
||||
{ "movegens", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleMovegensCommand>, "", NULL },
|
||||
{ "cometome", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleComeToMeCommand>, "", NULL },
|
||||
{ "damage", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleDamageCommand>, "", NULL },
|
||||
{ "combatstop", SEC_GAMEMASTER, true, OldHandler<&ChatHandler::HandleCombatStopCommand>, "", NULL },
|
||||
{ "flusharenapoints", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleFlushArenaPointsCommand>, "", NULL },
|
||||
{ "repairitems", SEC_GAMEMASTER, true, OldHandler<&ChatHandler::HandleRepairitemsCommand>, "", NULL },
|
||||
{ "waterwalk", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleWaterwalkCommand>, "", NULL },
|
||||
|
||||
{ "freeze", SEC_MODERATOR, false, OldHandler<&ChatHandler::HandleFreezeCommand>, "", NULL },
|
||||
{ "unfreeze", SEC_MODERATOR, false, OldHandler<&ChatHandler::HandleUnFreezeCommand>, "", NULL },
|
||||
{ "listfreeze", SEC_MODERATOR, false, OldHandler<&ChatHandler::HandleListFreezeCommand>, "", NULL },
|
||||
|
||||
{ "possess", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandlePossessCommand>, "", NULL },
|
||||
{ "unpossess", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleUnPossessCommand>, "", NULL },
|
||||
{ "bindsight", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleBindSightCommand>, "", NULL },
|
||||
|
||||
@@ -123,24 +123,14 @@ class ChatHandler
|
||||
void SetSentErrorMessage(bool val){ sentErrorMessage = val; }
|
||||
static bool LoadCommandTable() { return load_command_table; }
|
||||
static void SetLoadCommandTable(bool val) { load_command_table = val; }
|
||||
|
||||
// cs_character
|
||||
void HandleCharacterLevel(Player* player, uint64 playerGuid, uint32 oldLevel, uint32 newLevel);
|
||||
|
||||
bool ShowHelpForCommand(ChatCommand* table, const char* cmd);
|
||||
protected:
|
||||
explicit ChatHandler() : m_session(NULL) {} // for CLI subclass
|
||||
static bool SetDataForCommandInTable(ChatCommand* table, const char* text, uint32 security, std::string const& help, std::string const& fullcommand);
|
||||
bool ExecuteCommandInTable(ChatCommand* table, const char* text, const std::string& fullcmd);
|
||||
bool ShowHelpForCommand(ChatCommand* table, const char* cmd);
|
||||
bool ShowHelpForSubCommands(ChatCommand* table, char const* cmd, char const* subcmd);
|
||||
|
||||
bool HandleNameAnnounceCommand(const char* args);
|
||||
bool HandleGMNameAnnounceCommand(const char* args);
|
||||
bool HandleGMAnnounceCommand(const char* args);
|
||||
bool HandleGMNotifyCommand(const char* args);
|
||||
|
||||
bool HandleChannelSetOwnership(const char *args);
|
||||
|
||||
bool HandlePossessCommand(const char* args);
|
||||
bool HandleUnPossessCommand(const char* args);
|
||||
bool HandleBindSightCommand(const char* args);
|
||||
@@ -149,95 +139,11 @@ class ChatHandler
|
||||
bool HandlePDumpLoadCommand(const char *args);
|
||||
bool HandlePDumpWriteCommand(const char *args);
|
||||
|
||||
bool HandleSendItemsCommand(const char* args);
|
||||
bool HandleSendMailCommand(const char* args);
|
||||
bool HandleSendMessageCommand(const char * args);
|
||||
bool HandleSendMoneyCommand(const char* args);
|
||||
|
||||
bool HandleHelpCommand(const char* args);
|
||||
bool HandleCommandsCommand(const char* args);
|
||||
bool HandleStartCommand(const char* args);
|
||||
bool HandleDismountCommand(const char* args);
|
||||
bool HandleSaveCommand(const char* args);
|
||||
|
||||
bool HandleSummonCommand(const char* args);
|
||||
bool HandleAppearCommand(const char* args);
|
||||
bool HandleGroupSummonCommand(const char* args);
|
||||
bool HandleRecallCommand(const char* args);
|
||||
bool HandleAnnounceCommand(const char* args);
|
||||
bool HandleNotifyCommand(const char* args);
|
||||
bool HandleTaxiCheatCommand(const char* args);
|
||||
bool HandleWhispersCommand(const char* args);
|
||||
|
||||
bool HandleGUIDCommand(const char* args);
|
||||
bool HandleItemMoveCommand(const char* args);
|
||||
bool HandleDeMorphCommand(const char* args);
|
||||
bool HandlePInfoCommand(const char* args);
|
||||
bool HandleMuteCommand(const char* args);
|
||||
bool HandleUnmuteCommand(const char* args);
|
||||
bool HandleMovegensCommand(const char* args);
|
||||
bool HandleFreezeCommand(const char *args);
|
||||
bool HandleUnFreezeCommand(const char *args);
|
||||
bool HandleListFreezeCommand(const char* args);
|
||||
|
||||
bool HandleCooldownCommand(const char* args);
|
||||
bool HandleUnLearnCommand(const char* args);
|
||||
bool HandleGetDistanceCommand(const char* args);
|
||||
bool HandleDieCommand(const char* args);
|
||||
bool HandleDamageCommand(const char *args);
|
||||
bool HandleReviveCommand(const char* args);
|
||||
bool HandleAuraCommand(const char* args);
|
||||
bool HandleUnAuraCommand(const char* args);
|
||||
bool HandleLinkGraveCommand(const char* args);
|
||||
bool HandleNearGraveCommand(const char* args);
|
||||
bool HandleActivateObjectCommand(const char* args);
|
||||
bool HandleSpawnTransportCommand(const char* args);
|
||||
bool HandleExploreCheatCommand(const char* args);
|
||||
bool HandleWaterwalkCommand(const char* args);
|
||||
bool HandleLevelUpCommand(const char* args);
|
||||
bool HandleShowAreaCommand(const char* args);
|
||||
bool HandleHideAreaCommand(const char* args);
|
||||
bool HandleAddItemCommand(const char* args);
|
||||
bool HandleAddItemSetCommand(const char* args);
|
||||
bool HandlePetUnlearnCommand(const char* args);
|
||||
bool HandlePetLearnCommand(const char* args);
|
||||
bool HandleCreatePetCommand(const char* args);
|
||||
|
||||
bool HandleGroupLeaderCommand(const char* args);
|
||||
bool HandleGroupDisbandCommand(const char* args);
|
||||
bool HandleGroupRemoveCommand(const char* args);
|
||||
|
||||
bool HandleBankCommand(const char* args);
|
||||
bool HandleChangeWeather(const char* args);
|
||||
bool HandleKickPlayerCommand(const char * args);
|
||||
|
||||
bool HandleMaxSkillCommand(const char* args);
|
||||
bool HandleSetSkillCommand(const char* args);
|
||||
bool HandleRespawnCommand(const char* args);
|
||||
bool HandleComeToMeCommand(const char *args);
|
||||
bool HandleCombatStopCommand(const char *args);
|
||||
|
||||
/*bool HandleCharDeleteCommand(const char *args);
|
||||
bool HandleSendMessageCommand(const char * args);*/
|
||||
|
||||
bool HandleFlushArenaPointsCommand(const char *args);
|
||||
bool HandlePlayAllCommand(const char* args);
|
||||
bool HandleRepairitemsCommand(const char* args);
|
||||
|
||||
bool HandleTempGameObjectCommand(const char* args);
|
||||
|
||||
//! Development Commands
|
||||
|
||||
/*bool HandleQuestAdd(const char * args);
|
||||
bool HandleQuestRemove(const char * args);
|
||||
bool HandleQuestComplete(const char * args);*/
|
||||
|
||||
//bool HandleSet32Bit(const char* args);
|
||||
bool HandleSaveAllCommand(const char* args);
|
||||
|
||||
// Utility methods for commands
|
||||
void HandleLearnSkillRecipesHelper(Player* player, uint32 skill_id);
|
||||
|
||||
private:
|
||||
WorldSession* m_session; // != NULL for chat command call and NULL for CLI command
|
||||
|
||||
|
||||
@@ -1,129 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/>
|
||||
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "Common.h"
|
||||
#include "World.h"
|
||||
#include "Player.h"
|
||||
#include "Chat.h"
|
||||
#include "ObjectAccessor.h"
|
||||
#include "Language.h"
|
||||
#include "AccountMgr.h"
|
||||
#include "SystemConfig.h"
|
||||
#include "revision.h"
|
||||
#include "Util.h"
|
||||
|
||||
bool ChatHandler::HandleHelpCommand(const char* args)
|
||||
{
|
||||
char* cmd = strtok((char*)args, " ");
|
||||
if (!cmd)
|
||||
{
|
||||
ShowHelpForCommand(getCommandTable(), "help");
|
||||
ShowHelpForCommand(getCommandTable(), "");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!ShowHelpForCommand(getCommandTable(), cmd))
|
||||
SendSysMessage(LANG_NO_HELP_CMD);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleCommandsCommand(const char* /*args*/)
|
||||
{
|
||||
ShowHelpForCommand(getCommandTable(), "");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleStartCommand(const char* /*args*/)
|
||||
{
|
||||
Player* player = m_session->GetPlayer();
|
||||
|
||||
if (player->isInFlight())
|
||||
{
|
||||
SendSysMessage(LANG_YOU_IN_FLIGHT);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (player->isInCombat())
|
||||
{
|
||||
SendSysMessage(LANG_YOU_IN_COMBAT);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (player->isDead() || player->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST))
|
||||
{
|
||||
// if player is dead and stuck, send ghost to graveyard
|
||||
player->RepopAtGraveyard();
|
||||
return true;
|
||||
}
|
||||
|
||||
// cast spell Stuck
|
||||
player->CastSpell(player, 7355, false);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleDismountCommand(const char* /*args*/)
|
||||
{
|
||||
Player* player = m_session->GetPlayer();
|
||||
|
||||
//If player is not mounted, so go out :)
|
||||
if (!player->IsMounted())
|
||||
{
|
||||
SendSysMessage(LANG_CHAR_NON_MOUNTED);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (player->isInFlight())
|
||||
{
|
||||
SendSysMessage(LANG_YOU_IN_FLIGHT);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
player->Dismount();
|
||||
player->RemoveAurasByType(SPELL_AURA_MOUNTED);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleSaveCommand(const char* /*args*/)
|
||||
{
|
||||
Player* player = m_session->GetPlayer();
|
||||
|
||||
// save GM account without delay and output message
|
||||
if (!AccountMgr::IsPlayerAccount(m_session->GetSecurity()))
|
||||
{
|
||||
if (Player* target = getSelectedPlayer())
|
||||
target->SaveToDB();
|
||||
else
|
||||
player->SaveToDB();
|
||||
SendSysMessage(LANG_PLAYER_SAVED);
|
||||
return true;
|
||||
}
|
||||
|
||||
// save if the player has last been saved over 20 seconds ago
|
||||
uint32 save_interval = sWorld->getIntConfig(CONFIG_INTERVAL_SAVE);
|
||||
if (save_interval == 0 || (save_interval > 20 * IN_MILLISECONDS && player->GetSaveTimer() <= save_interval - 20 * IN_MILLISECONDS))
|
||||
player->SaveToDB();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,629 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/>
|
||||
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "Common.h"
|
||||
#include "DatabaseEnv.h"
|
||||
#include "WorldPacket.h"
|
||||
#include "WorldSession.h"
|
||||
#include "World.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "TicketMgr.h"
|
||||
#include "Player.h"
|
||||
#include "AccountMgr.h"
|
||||
#include "Opcodes.h"
|
||||
#include "Chat.h"
|
||||
#include "Log.h"
|
||||
#include "MapManager.h"
|
||||
#include "ObjectAccessor.h"
|
||||
#include "Language.h"
|
||||
#include "CellImpl.h"
|
||||
#include "InstanceSaveMgr.h"
|
||||
#include "Util.h"
|
||||
#include "Group.h"
|
||||
|
||||
#ifdef _DEBUG_VMAPS
|
||||
#include "VMapFactory.h"
|
||||
#endif
|
||||
|
||||
bool ChatHandler::HandleNameAnnounceCommand(const char* args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
std::string name("Console");
|
||||
if (WorldSession* session = GetSession())
|
||||
name = session->GetPlayer()->GetName();
|
||||
|
||||
sWorld->SendWorldText(LANG_ANNOUNCE_COLOR, name.c_str(), args);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleGMNameAnnounceCommand(const char* args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
std::string name("Console");
|
||||
if (WorldSession* session = GetSession())
|
||||
name = session->GetPlayer()->GetName();
|
||||
|
||||
sWorld->SendGMText(LANG_GM_ANNOUNCE_COLOR, name.c_str(), args);
|
||||
return true;
|
||||
}
|
||||
|
||||
// global announce
|
||||
bool ChatHandler::HandleAnnounceCommand(const char* args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
char buff[2048];
|
||||
sprintf(buff, GetTrinityString(LANG_SYSTEMMESSAGE), args);
|
||||
sWorld->SendServerMessage(SERVER_MSG_STRING, buff);
|
||||
return true;
|
||||
}
|
||||
|
||||
// announce to logged in GMs
|
||||
bool ChatHandler::HandleGMAnnounceCommand(const char* args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
sWorld->SendGMText(LANG_GM_BROADCAST, args);
|
||||
return true;
|
||||
}
|
||||
|
||||
//notification player at the screen
|
||||
bool ChatHandler::HandleNotifyCommand(const char* args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
std::string str = GetTrinityString(LANG_GLOBAL_NOTIFY);
|
||||
str += args;
|
||||
|
||||
WorldPacket data(SMSG_NOTIFICATION, (str.size()+1));
|
||||
data << str;
|
||||
sWorld->SendGlobalMessage(&data);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//notification GM at the screen
|
||||
bool ChatHandler::HandleGMNotifyCommand(const char* args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
std::string str = GetTrinityString(LANG_GM_NOTIFY);
|
||||
str += args;
|
||||
|
||||
WorldPacket data(SMSG_NOTIFICATION, (str.size()+1));
|
||||
data << str;
|
||||
sWorld->SendGlobalGMMessage(&data);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//Summon Player
|
||||
bool ChatHandler::HandleSummonCommand(const char* 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();
|
||||
if (target == _player || target_guid == _player->GetGUID())
|
||||
{
|
||||
PSendSysMessage(LANG_CANT_TELEPORT_SELF);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (target)
|
||||
{
|
||||
std::string nameLink = playerLink(target_name);
|
||||
// check online security
|
||||
if (HasLowerSecurity(target, 0))
|
||||
return false;
|
||||
|
||||
if (target->IsBeingTeleported())
|
||||
{
|
||||
PSendSysMessage(LANG_IS_TELEPORTED, nameLink.c_str());
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
Map* map = m_session->GetPlayer()->GetMap();
|
||||
|
||||
if (map->IsBattlegroundOrArena())
|
||||
{
|
||||
// only allow if gm mode is on
|
||||
if (!_player->isGameMaster())
|
||||
{
|
||||
PSendSysMessage(LANG_CANNOT_GO_TO_BG_GM, nameLink.c_str());
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
// if both players are in different bgs
|
||||
else if (target->GetBattlegroundId() && m_session->GetPlayer()->GetBattlegroundId() != target->GetBattlegroundId())
|
||||
target->LeaveBattleground(false); // Note: should be changed so target gets no Deserter debuff
|
||||
|
||||
// all's well, set bg id
|
||||
// when porting out from the bg, it will be reset to 0
|
||||
target->SetBattlegroundId(m_session->GetPlayer()->GetBattlegroundId(), m_session->GetPlayer()->GetBattlegroundTypeId());
|
||||
// remember current position as entry point for return at bg end teleportation
|
||||
if (!target->GetMap()->IsBattlegroundOrArena())
|
||||
target->SetBattlegroundEntryPoint();
|
||||
}
|
||||
else if (map->IsDungeon())
|
||||
{
|
||||
Map* cMap = target->GetMap();
|
||||
|
||||
if (cMap->Instanceable() && cMap->GetInstanceId() != map->GetInstanceId())
|
||||
target->UnbindInstance(map->GetInstanceId(), target->GetDungeonDifficulty(), true);
|
||||
|
||||
// we are in instance, and can summon only player in our group with us as lead
|
||||
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());
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
PSendSysMessage(LANG_SUMMONING, nameLink.c_str(), "");
|
||||
if (needReportToTarget(target))
|
||||
ChatHandler(target).PSendSysMessage(LANG_SUMMONED_BY, playerLink(_player->GetName()).c_str());
|
||||
|
||||
// stop flight if need
|
||||
if (target->isInFlight())
|
||||
{
|
||||
target->GetMotionMaster()->MovementExpired();
|
||||
target->CleanupAfterTaxiFlight();
|
||||
}
|
||||
// save only in non-flight case
|
||||
else
|
||||
target->SaveRecallPosition();
|
||||
|
||||
// before GM
|
||||
float x, y, z;
|
||||
m_session->GetPlayer()->GetClosePoint(x, y, z, target->GetObjectSize());
|
||||
target->TeleportTo(m_session->GetPlayer()->GetMapId(), x, y, z, target->GetOrientation());
|
||||
target->SetPhaseMask(m_session->GetPlayer()->GetPhaseMask(), true);
|
||||
}
|
||||
else
|
||||
{
|
||||
// check offline security
|
||||
if (HasLowerSecurity(NULL, target_guid))
|
||||
return false;
|
||||
|
||||
std::string nameLink = playerLink(target_name);
|
||||
|
||||
PSendSysMessage(LANG_SUMMONING, nameLink.c_str(), GetTrinityString(LANG_OFFLINE));
|
||||
|
||||
// in point where GM stay
|
||||
Player::SavePositionInDB(m_session->GetPlayer()->GetMapId(),
|
||||
m_session->GetPlayer()->GetPositionX(),
|
||||
m_session->GetPlayer()->GetPositionY(),
|
||||
m_session->GetPlayer()->GetPositionZ(),
|
||||
m_session->GetPlayer()->GetOrientation(),
|
||||
m_session->GetPlayer()->GetZoneId(),
|
||||
target_guid);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//Teleport to Player
|
||||
bool ChatHandler::HandleAppearCommand(const char* 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();
|
||||
if (target == _player || target_guid == _player->GetGUID())
|
||||
{
|
||||
SendSysMessage(LANG_CANT_TELEPORT_SELF);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (target)
|
||||
{
|
||||
// check online security
|
||||
if (HasLowerSecurity(target, 0))
|
||||
return false;
|
||||
|
||||
std::string chrNameLink = playerLink(target_name);
|
||||
|
||||
Map* cMap = target->GetMap();
|
||||
if (cMap->IsBattlegroundOrArena())
|
||||
{
|
||||
// only allow if gm mode is on
|
||||
if (!_player->isGameMaster())
|
||||
{
|
||||
PSendSysMessage(LANG_CANNOT_GO_TO_BG_GM, chrNameLink.c_str());
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
// if both players are in different bgs
|
||||
else if (_player->GetBattlegroundId() && _player->GetBattlegroundId() != target->GetBattlegroundId())
|
||||
_player->LeaveBattleground(false); // Note: should be changed so _player gets no Deserter debuff
|
||||
|
||||
// all's well, set bg id
|
||||
// when porting out from the bg, it will be reset to 0
|
||||
_player->SetBattlegroundId(target->GetBattlegroundId(), target->GetBattlegroundTypeId());
|
||||
// remember current position as entry point for return at bg end teleportation
|
||||
if (!_player->GetMap()->IsBattlegroundOrArena())
|
||||
_player->SetBattlegroundEntryPoint();
|
||||
}
|
||||
else if (cMap->IsDungeon())
|
||||
{
|
||||
// we have to go to instance, and can go to player only if:
|
||||
// 1) we are in his group (either as leader or as member)
|
||||
// 2) we are not bound to any group and have GM mode on
|
||||
if (_player->GetGroup())
|
||||
{
|
||||
// we are in group, we can go only if we are in the player group
|
||||
if (_player->GetGroup() != target->GetGroup())
|
||||
{
|
||||
PSendSysMessage(LANG_CANNOT_GO_TO_INST_PARTY, chrNameLink.c_str());
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// we are not in group, let's verify our GM mode
|
||||
if (!_player->isGameMaster())
|
||||
{
|
||||
PSendSysMessage(LANG_CANNOT_GO_TO_INST_GM, chrNameLink.c_str());
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// 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(target->GetMapId(), target->GetDifficulty(cMap->IsRaid()));
|
||||
if (!pBind)
|
||||
{
|
||||
Group* group = _player->GetGroup();
|
||||
// if no bind exists, create a solo bind
|
||||
InstanceGroupBind* gBind = group ? group->GetBoundInstance(target) : NULL; // if no bind exists, create a solo bind
|
||||
if (!gBind)
|
||||
if (InstanceSave* save = sInstanceSaveMgr->GetInstanceSave(target->GetInstanceId()))
|
||||
_player->BindToInstance(save, !save->CanReset());
|
||||
}
|
||||
|
||||
if (cMap->IsRaid())
|
||||
_player->SetRaidDifficulty(target->GetRaidDifficulty());
|
||||
else
|
||||
_player->SetDungeonDifficulty(target->GetDungeonDifficulty());
|
||||
}
|
||||
|
||||
PSendSysMessage(LANG_APPEARING_AT, chrNameLink.c_str());
|
||||
|
||||
// stop flight if need
|
||||
if (_player->isInFlight())
|
||||
{
|
||||
_player->GetMotionMaster()->MovementExpired();
|
||||
_player->CleanupAfterTaxiFlight();
|
||||
}
|
||||
// save only in non-flight case
|
||||
else
|
||||
_player->SaveRecallPosition();
|
||||
|
||||
// to point to see at target with same orientation
|
||||
float x, y, z;
|
||||
target->GetContactPoint(_player, x, y, z);
|
||||
|
||||
_player->TeleportTo(target->GetMapId(), x, y, z, _player->GetAngle(target), TELE_TO_GM_MODE);
|
||||
_player->SetPhaseMask(target->GetPhaseMask(), true);
|
||||
}
|
||||
else
|
||||
{
|
||||
// check offline security
|
||||
if (HasLowerSecurity(NULL, target_guid))
|
||||
return false;
|
||||
|
||||
std::string nameLink = playerLink(target_name);
|
||||
|
||||
PSendSysMessage(LANG_APPEARING_AT, nameLink.c_str());
|
||||
|
||||
// to point where player stay (if loaded)
|
||||
float x, y, z, o;
|
||||
uint32 map;
|
||||
bool in_flight;
|
||||
if (!Player::LoadPositionFromDB(map, x, y, z, o, in_flight, target_guid))
|
||||
return false;
|
||||
|
||||
// stop flight if need
|
||||
if (_player->isInFlight())
|
||||
{
|
||||
_player->GetMotionMaster()->MovementExpired();
|
||||
_player->CleanupAfterTaxiFlight();
|
||||
}
|
||||
// save only in non-flight case
|
||||
else
|
||||
_player->SaveRecallPosition();
|
||||
|
||||
_player->TeleportTo(map, x, y, z, _player->GetOrientation());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Teleport player to last position
|
||||
bool ChatHandler::HandleRecallCommand(const char* args)
|
||||
{
|
||||
Player* target;
|
||||
if (!extractPlayerTarget((char*)args, &target))
|
||||
return false;
|
||||
|
||||
// check online security
|
||||
if (HasLowerSecurity(target, 0))
|
||||
return false;
|
||||
|
||||
if (target->IsBeingTeleported())
|
||||
{
|
||||
PSendSysMessage(LANG_IS_TELEPORTED, GetNameLink(target).c_str());
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
// stop flight if need
|
||||
if (target->isInFlight())
|
||||
{
|
||||
target->GetMotionMaster()->MovementExpired();
|
||||
target->CleanupAfterTaxiFlight();
|
||||
}
|
||||
|
||||
target->TeleportTo(target->m_recallMap, target->m_recallX, target->m_recallY, target->m_recallZ, target->m_recallO);
|
||||
return true;
|
||||
}
|
||||
|
||||
//Enable On\OFF all taxi paths
|
||||
bool ChatHandler::HandleTaxiCheatCommand(const char* args)
|
||||
{
|
||||
if (!*args)
|
||||
{
|
||||
SendSysMessage(LANG_USE_BOL);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string argstr = (char*)args;
|
||||
|
||||
Player* chr = getSelectedPlayer();
|
||||
|
||||
if (!chr)
|
||||
chr = m_session->GetPlayer();
|
||||
else if (HasLowerSecurity(chr, 0)) // check online security
|
||||
return false;
|
||||
|
||||
if (argstr == "on")
|
||||
{
|
||||
chr->SetTaxiCheater(true);
|
||||
PSendSysMessage(LANG_YOU_GIVE_TAXIS, GetNameLink(chr).c_str());
|
||||
if (needReportToTarget(chr))
|
||||
ChatHandler(chr).PSendSysMessage(LANG_YOURS_TAXIS_ADDED, GetNameLink().c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (argstr == "off")
|
||||
{
|
||||
chr->SetTaxiCheater(false);
|
||||
PSendSysMessage(LANG_YOU_REMOVE_TAXIS, GetNameLink(chr).c_str());
|
||||
if (needReportToTarget(chr))
|
||||
ChatHandler(chr).PSendSysMessage(LANG_YOURS_TAXIS_REMOVED, GetNameLink().c_str());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
SendSysMessage(LANG_USE_BOL);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
//Enable\Dissable accept whispers (for GM)
|
||||
bool ChatHandler::HandleWhispersCommand(const char* args)
|
||||
{
|
||||
if (!*args)
|
||||
{
|
||||
PSendSysMessage(LANG_COMMAND_WHISPERACCEPTING, m_session->GetPlayer()->isAcceptWhispers() ? GetTrinityString(LANG_ON) : GetTrinityString(LANG_OFF));
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string argstr = (char*)args;
|
||||
// whisper on
|
||||
if (argstr == "on")
|
||||
{
|
||||
m_session->GetPlayer()->SetAcceptWhispers(true);
|
||||
SendSysMessage(LANG_COMMAND_WHISPERON);
|
||||
return true;
|
||||
}
|
||||
|
||||
// whisper off
|
||||
if (argstr == "off")
|
||||
{
|
||||
// Remove all players from the Gamemaster's whisper whitelist
|
||||
m_session->GetPlayer()->ClearWhisperWhiteList();
|
||||
m_session->GetPlayer()->SetAcceptWhispers(false);
|
||||
SendSysMessage(LANG_COMMAND_WHISPEROFF);
|
||||
return true;
|
||||
}
|
||||
|
||||
SendSysMessage(LANG_USE_BOL);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
//Save all players in the world
|
||||
bool ChatHandler::HandleSaveAllCommand(const char* /*args*/)
|
||||
{
|
||||
sObjectAccessor->SaveAllPlayers();
|
||||
SendSysMessage(LANG_PLAYERS_SAVED);
|
||||
return true;
|
||||
}
|
||||
|
||||
//Send mail by command
|
||||
bool ChatHandler::HandleSendMailCommand(const char* args)
|
||||
{
|
||||
// format: name "subject text" "mail text"
|
||||
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)
|
||||
return false;
|
||||
|
||||
char* msgSubject = extractQuotedArg(tail1);
|
||||
if (!msgSubject)
|
||||
return false;
|
||||
|
||||
char* tail2 = strtok(NULL, "");
|
||||
if (!tail2)
|
||||
return false;
|
||||
|
||||
char* msgText = extractQuotedArg(tail2);
|
||||
if (!msgText)
|
||||
return false;
|
||||
|
||||
// msgSubject, msgText isn't NUL after prev. check
|
||||
std::string subject = msgSubject;
|
||||
std::string text = msgText;
|
||||
|
||||
// from console show not existed sender
|
||||
MailSender sender(MAIL_NORMAL, m_session ? m_session->GetPlayer()->GetGUIDLow() : 0, MAIL_STATIONERY_GM);
|
||||
|
||||
//- TODO: Fix poor design
|
||||
SQLTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
MailDraft(subject, text)
|
||||
.SendMailTo(trans, MailReceiver(target, GUID_LOPART(target_guid)), sender);
|
||||
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
|
||||
std::string nameLink = playerLink(target_name);
|
||||
PSendSysMessage(LANG_MAIL_SENT, nameLink.c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
//Summon group of player
|
||||
bool ChatHandler::HandleGroupSummonCommand(const char* args)
|
||||
{
|
||||
Player* target;
|
||||
if (!extractPlayerTarget((char*)args, &target))
|
||||
return false;
|
||||
|
||||
// check online security
|
||||
if (HasLowerSecurity(target, 0))
|
||||
return false;
|
||||
|
||||
Group* grp = target->GetGroup();
|
||||
|
||||
std::string nameLink = GetNameLink(target);
|
||||
|
||||
if (!grp)
|
||||
{
|
||||
PSendSysMessage(LANG_NOT_IN_GROUP, nameLink.c_str());
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
Map* gmMap = m_session->GetPlayer()->GetMap();
|
||||
bool to_instance = gmMap->Instanceable();
|
||||
|
||||
// we are in instance, and can summon only player in our group with us as lead
|
||||
if (to_instance && (
|
||||
!m_session->GetPlayer()->GetGroup() || (grp->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
|
||||
{
|
||||
SendSysMessage(LANG_CANNOT_SUMMON_TO_INST);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
|
||||
{
|
||||
Player* player = itr->getSource();
|
||||
|
||||
if (!player || player == m_session->GetPlayer() || !player->GetSession())
|
||||
continue;
|
||||
|
||||
// check online security
|
||||
if (HasLowerSecurity(player, 0))
|
||||
return false;
|
||||
|
||||
std::string plNameLink = GetNameLink(player);
|
||||
|
||||
if (player->IsBeingTeleported() == true)
|
||||
{
|
||||
PSendSysMessage(LANG_IS_TELEPORTED, plNameLink.c_str());
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (to_instance)
|
||||
{
|
||||
Map* plMap = player->GetMap();
|
||||
|
||||
if (plMap->Instanceable() && plMap->GetInstanceId() != gmMap->GetInstanceId())
|
||||
{
|
||||
// cannot summon from instance to instance
|
||||
PSendSysMessage(LANG_CANNOT_SUMMON_TO_INST, plNameLink.c_str());
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
PSendSysMessage(LANG_SUMMONING, plNameLink.c_str(), "");
|
||||
if (needReportToTarget(player))
|
||||
ChatHandler(player).PSendSysMessage(LANG_SUMMONED_BY, GetNameLink().c_str());
|
||||
|
||||
// stop flight if need
|
||||
if (player->isInFlight())
|
||||
{
|
||||
player->GetMotionMaster()->MovementExpired();
|
||||
player->CleanupAfterTaxiFlight();
|
||||
}
|
||||
// save only in non-flight case
|
||||
else
|
||||
player->SaveRecallPosition();
|
||||
|
||||
// before GM
|
||||
float x, y, z;
|
||||
m_session->GetPlayer()->GetClosePoint(x, y, z, player->GetObjectSize());
|
||||
player->TeleportTo(m_session->GetPlayer()->GetMapId(), x, y, z, player->GetOrientation());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1,679 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/>
|
||||
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "Common.h"
|
||||
#include "DatabaseEnv.h"
|
||||
#include "DBCStores.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "Player.h"
|
||||
#include "Item.h"
|
||||
#include "GameObject.h"
|
||||
#include "Opcodes.h"
|
||||
#include "Chat.h"
|
||||
#include "MapManager.h"
|
||||
#include "Language.h"
|
||||
#include "World.h"
|
||||
#include "GameEventMgr.h"
|
||||
#include "SpellMgr.h"
|
||||
#include "PoolMgr.h"
|
||||
#include "AccountMgr.h"
|
||||
#include "WaypointManager.h"
|
||||
#include "Util.h"
|
||||
#include <cctype>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <map>
|
||||
#include "OutdoorPvPMgr.h"
|
||||
#include "Transport.h"
|
||||
#include "TargetedMovementGenerator.h" // for HandleNpcUnFollowCommand
|
||||
#include "CreatureGroups.h"
|
||||
#include "ace/INET_Addr.h"
|
||||
|
||||
//mute player for some times
|
||||
bool ChatHandler::HandleMuteCommand(const char* args)
|
||||
{
|
||||
char* nameStr;
|
||||
char* delayStr;
|
||||
extractOptFirstArg((char*)args, &nameStr, &delayStr);
|
||||
if (!delayStr)
|
||||
return false;
|
||||
|
||||
char *mutereason = strtok(NULL, "\r");
|
||||
std::string mutereasonstr = "No reason";
|
||||
if (mutereason != NULL)
|
||||
mutereasonstr = mutereason;
|
||||
|
||||
Player* target;
|
||||
uint64 target_guid;
|
||||
std::string target_name;
|
||||
if (!extractPlayerTarget(nameStr, &target, &target_guid, &target_name))
|
||||
return false;
|
||||
|
||||
uint32 accountId = target ? target->GetSession()->GetAccountId() : sObjectMgr->GetPlayerAccountIdByGUID(target_guid);
|
||||
|
||||
// find only player from same account if any
|
||||
if (!target)
|
||||
if (WorldSession* session = sWorld->FindSession(accountId))
|
||||
target = session->GetPlayer();
|
||||
|
||||
uint32 notspeaktime = (uint32) atoi(delayStr);
|
||||
|
||||
// must have strong lesser security level
|
||||
if (HasLowerSecurity (target, target_guid, true))
|
||||
return false;
|
||||
|
||||
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_MUTE_TIME);
|
||||
|
||||
if (target)
|
||||
{
|
||||
// Target is online, mute will be in effect right away.
|
||||
int64 muteTime = time(NULL) + notspeaktime * MINUTE;
|
||||
target->GetSession()->m_muteTime = muteTime;
|
||||
|
||||
stmt->setInt64(0, muteTime);
|
||||
|
||||
ChatHandler(target).PSendSysMessage(LANG_YOUR_CHAT_DISABLED, notspeaktime, mutereasonstr.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
// Target is offline, mute will be in effect starting from the next login.
|
||||
int32 muteTime = -int32(notspeaktime * MINUTE);
|
||||
|
||||
stmt->setInt64(0, muteTime);
|
||||
}
|
||||
|
||||
stmt->setUInt32(1, accountId);
|
||||
|
||||
LoginDatabase.Execute(stmt);
|
||||
|
||||
std::string nameLink = playerLink(target_name);
|
||||
|
||||
PSendSysMessage(target ? LANG_YOU_DISABLE_CHAT : LANG_COMMAND_DISABLE_CHAT_DELAYED, nameLink.c_str(), notspeaktime, mutereasonstr.c_str());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//unmute player
|
||||
bool ChatHandler::HandleUnmuteCommand(const char* args)
|
||||
{
|
||||
Player* target;
|
||||
uint64 target_guid;
|
||||
std::string target_name;
|
||||
if (!extractPlayerTarget((char*)args, &target, &target_guid, &target_name))
|
||||
return false;
|
||||
|
||||
uint32 accountId = target ? target->GetSession()->GetAccountId() : sObjectMgr->GetPlayerAccountIdByGUID(target_guid);
|
||||
|
||||
// find only player from same account if any
|
||||
if (!target)
|
||||
if (WorldSession* session = sWorld->FindSession(accountId))
|
||||
target = session->GetPlayer();
|
||||
|
||||
// must have strong lesser security level
|
||||
if (HasLowerSecurity (target, target_guid, true))
|
||||
return false;
|
||||
|
||||
if (target)
|
||||
{
|
||||
if (target->CanSpeak())
|
||||
{
|
||||
SendSysMessage(LANG_CHAT_ALREADY_ENABLED);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
target->GetSession()->m_muteTime = 0;
|
||||
}
|
||||
|
||||
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_MUTE_TIME);
|
||||
|
||||
stmt->setInt64(0, 0);
|
||||
stmt->setUInt32(1, accountId);
|
||||
|
||||
LoginDatabase.Execute(stmt);
|
||||
|
||||
if (target)
|
||||
ChatHandler(target).PSendSysMessage(LANG_YOUR_CHAT_ENABLED);
|
||||
|
||||
std::string nameLink = playerLink(target_name);
|
||||
|
||||
PSendSysMessage(LANG_YOU_ENABLE_CHAT, nameLink.c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleGUIDCommand(const char* /*args*/)
|
||||
{
|
||||
uint64 guid = m_session->GetPlayer()->GetSelection();
|
||||
|
||||
if (guid == 0)
|
||||
{
|
||||
SendSysMessage(LANG_NO_SELECTION);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
PSendSysMessage(LANG_OBJECT_GUID, GUID_LOPART(guid), GUID_HIPART(guid));
|
||||
return true;
|
||||
}
|
||||
|
||||
//move item to other slot
|
||||
bool ChatHandler::HandleItemMoveCommand(const char* args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
char* pParam1 = strtok((char*)args, " ");
|
||||
if (!pParam1)
|
||||
return false;
|
||||
|
||||
char* pParam2 = strtok(NULL, " ");
|
||||
if (!pParam2)
|
||||
return false;
|
||||
|
||||
uint8 srcslot = (uint8)atoi(pParam1);
|
||||
uint8 dstslot = (uint8)atoi(pParam2);
|
||||
|
||||
if (srcslot == dstslot)
|
||||
return true;
|
||||
|
||||
if (!m_session->GetPlayer()->IsValidPos(INVENTORY_SLOT_BAG_0, srcslot, true))
|
||||
return false;
|
||||
|
||||
if (!m_session->GetPlayer()->IsValidPos(INVENTORY_SLOT_BAG_0, dstslot, false))
|
||||
return false;
|
||||
|
||||
uint16 src = ((INVENTORY_SLOT_BAG_0 << 8) | srcslot);
|
||||
uint16 dst = ((INVENTORY_SLOT_BAG_0 << 8) | dstslot);
|
||||
|
||||
m_session->GetPlayer()->SwapItem(src, dst);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//kick player
|
||||
bool ChatHandler::HandleKickPlayerCommand(const char *args)
|
||||
{
|
||||
Player* target = NULL;
|
||||
std::string playerName;
|
||||
if (!extractPlayerTarget((char*)args, &target, NULL, &playerName))
|
||||
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;
|
||||
|
||||
if (sWorld->getBoolConfig(CONFIG_SHOW_KICK_IN_WORLD))
|
||||
sWorld->SendWorldText(LANG_COMMAND_KICKMESSAGE, playerName.c_str());
|
||||
else
|
||||
PSendSysMessage(LANG_COMMAND_KICKMESSAGE, playerName.c_str());
|
||||
|
||||
target->GetSession()->KickPlayer();
|
||||
return true;
|
||||
}
|
||||
|
||||
//show info of player
|
||||
bool ChatHandler::HandlePInfoCommand(const char* args)
|
||||
{
|
||||
Player* target;
|
||||
uint64 target_guid;
|
||||
std::string target_name;
|
||||
|
||||
uint32 parseGUID = MAKE_NEW_GUID(atol((char*)args), 0, HIGHGUID_PLAYER);
|
||||
|
||||
if (sObjectMgr->GetPlayerNameByGUID(parseGUID, target_name))
|
||||
{
|
||||
target = sObjectMgr->GetPlayerByLowGUID(parseGUID);
|
||||
target_guid = parseGUID;
|
||||
}
|
||||
else if (!extractPlayerTarget((char*)args, &target, &target_guid, &target_name))
|
||||
return false;
|
||||
|
||||
uint32 accId = 0;
|
||||
uint32 money = 0;
|
||||
uint32 total_player_time = 0;
|
||||
uint8 level = 0;
|
||||
uint32 latency = 0;
|
||||
uint8 race;
|
||||
uint8 Class;
|
||||
int64 muteTime = 0;
|
||||
int64 banTime = -1;
|
||||
uint32 mapId;
|
||||
uint32 areaId;
|
||||
uint32 phase = 0;
|
||||
|
||||
// get additional information from Player object
|
||||
if (target)
|
||||
{
|
||||
// check online security
|
||||
if (HasLowerSecurity(target, 0))
|
||||
return false;
|
||||
|
||||
accId = target->GetSession()->GetAccountId();
|
||||
money = target->GetMoney();
|
||||
total_player_time = target->GetTotalPlayedTime();
|
||||
level = target->getLevel();
|
||||
latency = target->GetSession()->GetLatency();
|
||||
race = target->getRace();
|
||||
Class = target->getClass();
|
||||
muteTime = target->GetSession()->m_muteTime;
|
||||
mapId = target->GetMapId();
|
||||
areaId = target->GetAreaId();
|
||||
phase = target->GetPhaseMask();
|
||||
}
|
||||
// get additional information from DB
|
||||
else
|
||||
{
|
||||
// check offline security
|
||||
if (HasLowerSecurity(NULL, target_guid))
|
||||
return false;
|
||||
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_PINFO);
|
||||
stmt->setUInt32(0, GUID_LOPART(target_guid));
|
||||
PreparedQueryResult result = CharacterDatabase.Query(stmt);
|
||||
|
||||
if (!result)
|
||||
return false;
|
||||
|
||||
Field* fields = result->Fetch();
|
||||
total_player_time = fields[0].GetUInt32();
|
||||
level = fields[1].GetUInt8();
|
||||
money = fields[2].GetUInt32();
|
||||
accId = fields[3].GetUInt32();
|
||||
race = fields[4].GetUInt8();
|
||||
Class = fields[5].GetUInt8();
|
||||
mapId = fields[6].GetUInt16();
|
||||
areaId = fields[7].GetUInt16();
|
||||
}
|
||||
|
||||
std::string username = GetTrinityString(LANG_ERROR);
|
||||
std::string email = GetTrinityString(LANG_ERROR);
|
||||
std::string last_ip = GetTrinityString(LANG_ERROR);
|
||||
uint32 security = 0;
|
||||
std::string last_login = GetTrinityString(LANG_ERROR);
|
||||
|
||||
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_PINFO);
|
||||
stmt->setInt32(0, int32(realmID));
|
||||
stmt->setUInt32(1, accId);
|
||||
PreparedQueryResult result = LoginDatabase.Query(stmt);
|
||||
|
||||
if (result)
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
username = fields[0].GetString();
|
||||
security = fields[1].GetUInt8();
|
||||
email = fields[2].GetString();
|
||||
muteTime = fields[5].GetUInt64();
|
||||
|
||||
if (email.empty())
|
||||
email = "-";
|
||||
|
||||
if (!m_session || m_session->GetSecurity() >= AccountTypes(security))
|
||||
{
|
||||
last_ip = fields[3].GetString();
|
||||
last_login = fields[4].GetString();
|
||||
|
||||
uint32 ip = inet_addr(last_ip.c_str());
|
||||
#if TRINITY_ENDIAN == BIGENDIAN
|
||||
EndianConvertReverse(ip);
|
||||
#endif
|
||||
|
||||
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_IP2NATION_COUNTRY);
|
||||
|
||||
stmt->setUInt32(0, ip);
|
||||
|
||||
PreparedQueryResult result2 = WorldDatabase.Query(stmt);
|
||||
|
||||
if (result2)
|
||||
{
|
||||
Field* fields2 = result2->Fetch();
|
||||
last_ip.append(" (");
|
||||
last_ip.append(fields2[0].GetString());
|
||||
last_ip.append(")");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
last_ip = "-";
|
||||
last_login = "-";
|
||||
}
|
||||
}
|
||||
|
||||
std::string nameLink = playerLink(target_name);
|
||||
|
||||
PSendSysMessage(LANG_PINFO_ACCOUNT, (target?"":GetTrinityString(LANG_OFFLINE)), nameLink.c_str(), GUID_LOPART(target_guid), username.c_str(), accId, email.c_str(), security, last_ip.c_str(), last_login.c_str(), latency);
|
||||
|
||||
std::string bannedby = "unknown";
|
||||
std::string banreason = "";
|
||||
|
||||
stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_PINFO_BANS);
|
||||
stmt->setUInt32(0, accId);
|
||||
PreparedQueryResult result2 = LoginDatabase.Query(stmt);
|
||||
if (!result2)
|
||||
{
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PINFO_BANS);
|
||||
stmt->setUInt32(0, GUID_LOPART(target_guid));
|
||||
result2 = CharacterDatabase.Query(stmt);
|
||||
}
|
||||
|
||||
if (result2)
|
||||
{
|
||||
Field* fields = result2->Fetch();
|
||||
banTime = int64(fields[1].GetBool() ? 0 : fields[0].GetUInt32());
|
||||
bannedby = fields[2].GetString();
|
||||
banreason = fields[3].GetString();
|
||||
}
|
||||
|
||||
if (muteTime > 0)
|
||||
PSendSysMessage(LANG_PINFO_MUTE, secsToTimeString(muteTime - time(NULL), true).c_str());
|
||||
|
||||
if (banTime >= 0)
|
||||
PSendSysMessage(LANG_PINFO_BAN, banTime > 0 ? secsToTimeString(banTime - time(NULL), true).c_str() : "permanently", bannedby.c_str(), banreason.c_str());
|
||||
|
||||
std::string race_s, Class_s;
|
||||
switch (race)
|
||||
{
|
||||
case RACE_HUMAN: race_s = "Human"; break;
|
||||
case RACE_ORC: race_s = "Orc"; break;
|
||||
case RACE_DWARF: race_s = "Dwarf"; break;
|
||||
case RACE_NIGHTELF: race_s = "Night Elf"; break;
|
||||
case RACE_UNDEAD_PLAYER: race_s = "Undead"; break;
|
||||
case RACE_TAUREN: race_s = "Tauren"; break;
|
||||
case RACE_GNOME: race_s = "Gnome"; break;
|
||||
case RACE_TROLL: race_s = "Troll"; break;
|
||||
case RACE_BLOODELF: race_s = "Blood Elf"; break;
|
||||
case RACE_DRAENEI: race_s = "Draenei"; break;
|
||||
}
|
||||
switch (Class)
|
||||
{
|
||||
case CLASS_WARRIOR: Class_s = "Warrior"; break;
|
||||
case CLASS_PALADIN: Class_s = "Paladin"; break;
|
||||
case CLASS_HUNTER: Class_s = "Hunter"; break;
|
||||
case CLASS_ROGUE: Class_s = "Rogue"; break;
|
||||
case CLASS_PRIEST: Class_s = "Priest"; break;
|
||||
case CLASS_DEATH_KNIGHT: Class_s = "Death Knight"; break;
|
||||
case CLASS_SHAMAN: Class_s = "Shaman"; break;
|
||||
case CLASS_MAGE: Class_s = "Mage"; break;
|
||||
case CLASS_WARLOCK: Class_s = "Warlock"; break;
|
||||
case CLASS_DRUID: Class_s = "Druid"; break;
|
||||
}
|
||||
|
||||
std::string timeStr = secsToTimeString(total_player_time, true, true);
|
||||
uint32 gold = money /GOLD;
|
||||
uint32 silv = (money % GOLD) / SILVER;
|
||||
uint32 copp = (money % GOLD) % SILVER;
|
||||
PSendSysMessage(LANG_PINFO_LEVEL, race_s.c_str(), Class_s.c_str(), timeStr.c_str(), level, gold, silv, copp);
|
||||
|
||||
// Add map, zone, subzone and phase to output
|
||||
int locale = GetSessionDbcLocale();
|
||||
std::string areaName = "<unknown>";
|
||||
std::string zoneName = "";
|
||||
|
||||
MapEntry const* map = sMapStore.LookupEntry(mapId);
|
||||
|
||||
AreaTableEntry const* area = GetAreaEntryByAreaID(areaId);
|
||||
if (area)
|
||||
{
|
||||
areaName = area->area_name[locale];
|
||||
|
||||
AreaTableEntry const* zone = GetAreaEntryByAreaID(area->zone);
|
||||
|
||||
if (zone)
|
||||
zoneName = zone->area_name[locale];
|
||||
}
|
||||
|
||||
if (target)
|
||||
{
|
||||
if (!zoneName.empty())
|
||||
PSendSysMessage(LANG_PINFO_MAP_ONLINE, map->name[locale], zoneName.c_str(), areaName.c_str(), phase);
|
||||
else
|
||||
PSendSysMessage(LANG_PINFO_MAP_ONLINE, map->name[locale], areaName.c_str(), "<unknown>", phase);
|
||||
}
|
||||
else
|
||||
PSendSysMessage(LANG_PINFO_MAP_OFFLINE, map->name[locale], areaName.c_str());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleCombatStopCommand(const char* args)
|
||||
{
|
||||
Player* target = NULL;
|
||||
|
||||
if (args && strlen(args) > 0)
|
||||
{
|
||||
target = sObjectAccessor->FindPlayerByName(args);
|
||||
if (!target)
|
||||
{
|
||||
SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!target)
|
||||
if (!extractPlayerTarget((char*)args, &target))
|
||||
return false;
|
||||
|
||||
// check online security
|
||||
if (HasLowerSecurity(target, 0))
|
||||
return false;
|
||||
|
||||
target->CombatStop();
|
||||
target->getHostileRefManager().deleteReferences();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool ChatHandler::HandleRepairitemsCommand(const char* args)
|
||||
{
|
||||
Player* target;
|
||||
if (!extractPlayerTarget((char*)args, &target))
|
||||
return false;
|
||||
|
||||
// check online security
|
||||
if (HasLowerSecurity(target, 0))
|
||||
return false;
|
||||
|
||||
// Repair items
|
||||
target->DurabilityRepairAll(false, 0, false);
|
||||
|
||||
PSendSysMessage(LANG_YOU_REPAIR_ITEMS, GetNameLink(target).c_str());
|
||||
if (needReportToTarget(target))
|
||||
ChatHandler(target).PSendSysMessage(LANG_YOUR_ITEMS_REPAIRED, GetNameLink().c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleWaterwalkCommand(const char* args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
Player* player = getSelectedPlayer();
|
||||
|
||||
if (!player)
|
||||
{
|
||||
PSendSysMessage(LANG_NO_CHAR_SELECTED);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
// check online security
|
||||
if (HasLowerSecurity(player, 0))
|
||||
return false;
|
||||
|
||||
if (strncmp(args, "on", 3) == 0)
|
||||
player->SetMovement(MOVE_WATER_WALK); // ON
|
||||
else if (strncmp(args, "off", 4) == 0)
|
||||
player->SetMovement(MOVE_LAND_WALK); // OFF
|
||||
else
|
||||
{
|
||||
SendSysMessage(LANG_USE_BOL);
|
||||
return false;
|
||||
}
|
||||
|
||||
PSendSysMessage(LANG_YOU_SET_WATERWALK, args, GetNameLink(player).c_str());
|
||||
if (needReportToTarget(player))
|
||||
ChatHandler(player).PSendSysMessage(LANG_YOUR_WATERWALK_SET, args, GetNameLink().c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleCreatePetCommand(const char* /*args*/)
|
||||
{
|
||||
Player* player = m_session->GetPlayer();
|
||||
Creature* creatureTarget = getSelectedCreature();
|
||||
|
||||
if (!creatureTarget || creatureTarget->isPet() || creatureTarget->GetTypeId() == TYPEID_PLAYER)
|
||||
{
|
||||
PSendSysMessage(LANG_SELECT_CREATURE);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
CreatureTemplate const* cInfo = sObjectMgr->GetCreatureTemplate(creatureTarget->GetEntry());
|
||||
// Creatures with family 0 crashes the server
|
||||
if (cInfo->family == 0)
|
||||
{
|
||||
PSendSysMessage("This creature cannot be tamed. (family id: 0).");
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (player->GetPetGUID())
|
||||
{
|
||||
PSendSysMessage("You already have a pet");
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Everything looks OK, create new pet
|
||||
Pet* pet = new Pet(player, HUNTER_PET);
|
||||
if (!pet->CreateBaseAtCreature(creatureTarget))
|
||||
{
|
||||
delete pet;
|
||||
PSendSysMessage("Error 1");
|
||||
return false;
|
||||
}
|
||||
|
||||
creatureTarget->setDeathState(JUST_DIED);
|
||||
creatureTarget->RemoveCorpse();
|
||||
creatureTarget->SetHealth(0); // just for nice GM-mode view
|
||||
|
||||
pet->SetUInt64Value(UNIT_FIELD_CREATEDBY, player->GetGUID());
|
||||
pet->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE, player->getFaction());
|
||||
|
||||
if (!pet->InitStatsForLevel(creatureTarget->getLevel()))
|
||||
{
|
||||
sLog->outError("InitStatsForLevel() in EffectTameCreature failed! Pet deleted.");
|
||||
PSendSysMessage("Error 2");
|
||||
delete pet;
|
||||
return false;
|
||||
}
|
||||
|
||||
// prepare visual effect for levelup
|
||||
pet->SetUInt32Value(UNIT_FIELD_LEVEL, creatureTarget->getLevel()-1);
|
||||
|
||||
pet->GetCharmInfo()->SetPetNumber(sObjectMgr->GeneratePetNumber(), true);
|
||||
// this enables pet details window (Shift+P)
|
||||
pet->InitPetCreateSpells();
|
||||
pet->SetFullHealth();
|
||||
|
||||
pet->GetMap()->AddToMap(pet->ToCreature());
|
||||
|
||||
// visual effect for levelup
|
||||
pet->SetUInt32Value(UNIT_FIELD_LEVEL, creatureTarget->getLevel());
|
||||
|
||||
player->SetMinion(pet, true);
|
||||
pet->SavePetToDB(PET_SAVE_AS_CURRENT);
|
||||
player->PetSpellInitialize();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandlePetLearnCommand(const char* args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
Player* player = m_session->GetPlayer();
|
||||
Pet* pet = player->GetPet();
|
||||
|
||||
if (!pet)
|
||||
{
|
||||
PSendSysMessage("You have no pet");
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32 spellId = extractSpellIdFromLink((char*)args);
|
||||
|
||||
if (!spellId || !sSpellMgr->GetSpellInfo(spellId))
|
||||
return false;
|
||||
|
||||
// Check if pet already has it
|
||||
if (pet->HasSpell(spellId))
|
||||
{
|
||||
PSendSysMessage("Pet already has spell: %u", spellId);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if spell is valid
|
||||
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
|
||||
if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo))
|
||||
{
|
||||
PSendSysMessage(LANG_COMMAND_SPELL_BROKEN, spellId);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
pet->learnSpell(spellId);
|
||||
|
||||
PSendSysMessage("Pet has learned spell %u", spellId);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandlePetUnlearnCommand(const char *args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
Player* player = m_session->GetPlayer();
|
||||
Pet* pet = player->GetPet();
|
||||
|
||||
if (!pet)
|
||||
{
|
||||
PSendSysMessage("You have no pet");
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32 spellId = extractSpellIdFromLink((char*)args);
|
||||
|
||||
if (pet->HasSpell(spellId))
|
||||
pet->removeSpell(spellId, false);
|
||||
else
|
||||
PSendSysMessage("Pet doesn't have that spell");
|
||||
|
||||
return true;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -60,6 +60,7 @@ void AddSC_instance_commandscript();
|
||||
void AddSC_learn_commandscript();
|
||||
void AddSC_list_commandscript();
|
||||
void AddSC_lookup_commandscript();
|
||||
void AddSC_message_commandscript();
|
||||
void AddSC_misc_commandscript();
|
||||
void AddSC_modify_commandscript();
|
||||
void AddSC_npc_commandscript();
|
||||
@@ -672,6 +673,7 @@ void AddCommandScripts()
|
||||
AddSC_learn_commandscript();
|
||||
AddSC_lookup_commandscript();
|
||||
AddSC_list_commandscript();
|
||||
AddSC_message_commandscript();
|
||||
AddSC_misc_commandscript();
|
||||
AddSC_modify_commandscript();
|
||||
AddSC_npc_commandscript();
|
||||
|
||||
@@ -26,6 +26,7 @@ set(scripts_STAT_SRCS
|
||||
Commands/cs_learn.cpp
|
||||
Commands/cs_list.cpp
|
||||
Commands/cs_lookup.cpp
|
||||
Commands/cs_message.cpp
|
||||
Commands/cs_misc.cpp
|
||||
Commands/cs_modify.cpp
|
||||
Commands/cs_npc.cpp
|
||||
|
||||
@@ -60,6 +60,7 @@ public:
|
||||
static ChatCommand commandTable[] =
|
||||
{
|
||||
{ "character", SEC_GAMEMASTER, true, NULL, "", characterCommandTable},
|
||||
{ "levelup", SEC_ADMINISTRATOR, false, &HandleLevelUpCommand, "", NULL },
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
return commandTable;
|
||||
@@ -218,6 +219,34 @@ public:
|
||||
sWorld->AddCharacterNameData(delInfo.lowGuid, delInfo.name, (*result)[2].GetUInt8(), (*result)[0].GetUInt8(), (*result)[1].GetUInt8());
|
||||
}
|
||||
|
||||
static void HandleCharacterLevel(Player* player, uint64 playerGuid, uint32 oldLevel, uint32 newLevel, ChatHandler* handler)
|
||||
{
|
||||
if (player)
|
||||
{
|
||||
player->GiveLevel(newLevel);
|
||||
player->InitTalentForLevel();
|
||||
player->SetUInt32Value(PLAYER_XP, 0);
|
||||
|
||||
if (handler->needReportToTarget(player))
|
||||
{
|
||||
if (oldLevel == newLevel)
|
||||
ChatHandler(player).PSendSysMessage(LANG_YOURS_LEVEL_PROGRESS_RESET, handler->GetNameLink().c_str());
|
||||
else if (oldLevel < newLevel)
|
||||
ChatHandler(player).PSendSysMessage(LANG_YOURS_LEVEL_UP, handler->GetNameLink().c_str(), newLevel);
|
||||
else // if (oldlevel > newlevel)
|
||||
ChatHandler(player).PSendSysMessage(LANG_YOURS_LEVEL_DOWN, handler->GetNameLink().c_str(), newLevel);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Update level and reset XP, everything else will be updated at login
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_LEVEL);
|
||||
stmt->setUInt8(0, uint8(newLevel));
|
||||
stmt->setUInt32(1, GUID_LOPART(playerGuid));
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
}
|
||||
|
||||
static bool HandleCharacterTitlesCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
if (!*args)
|
||||
@@ -326,7 +355,7 @@ public:
|
||||
if (newlevel > STRONG_MAX_LEVEL) // hardcoded maximum level
|
||||
newlevel = STRONG_MAX_LEVEL;
|
||||
|
||||
handler->HandleCharacterLevel(target, targetGuid, oldlevel, newlevel);
|
||||
HandleCharacterLevel(target, targetGuid, oldlevel, newlevel, handler);
|
||||
if (!handler->GetSession() || handler->GetSession()->GetPlayer() != target) // including player == NULL
|
||||
{
|
||||
std::string nameLink = handler->playerLink(targetName);
|
||||
@@ -671,6 +700,46 @@ public:
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleLevelUpCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
char* nameStr;
|
||||
char* levelStr;
|
||||
handler->extractOptFirstArg((char*)args, &nameStr, &levelStr);
|
||||
|
||||
// exception opt second arg: .character level $name
|
||||
if (levelStr && isalpha(levelStr[0]))
|
||||
{
|
||||
nameStr = levelStr;
|
||||
levelStr = NULL; // current level will used
|
||||
}
|
||||
|
||||
Player* target;
|
||||
uint64 targetGuid;
|
||||
std::string targetName;
|
||||
if (!handler->extractPlayerTarget(nameStr, &target, &targetGuid, &targetName))
|
||||
return false;
|
||||
|
||||
int32 oldlevel = target ? target->getLevel() : Player::GetLevelFromDB(targetGuid);
|
||||
int32 addlevel = levelStr ? atoi(levelStr) : 1;
|
||||
int32 newlevel = oldlevel + addlevel;
|
||||
|
||||
if (newlevel < 1)
|
||||
newlevel = 1;
|
||||
|
||||
if (newlevel > STRONG_MAX_LEVEL) // hardcoded maximum level
|
||||
newlevel = STRONG_MAX_LEVEL;
|
||||
|
||||
HandleCharacterLevel(target, targetGuid, oldlevel, newlevel, handler);
|
||||
|
||||
if (!handler->GetSession() || handler->GetSession()->GetPlayer() != target) // including chr == NULL
|
||||
{
|
||||
std::string nameLink = handler->playerLink(targetName);
|
||||
handler->PSendSysMessage(LANG_YOU_CHANGE_LVL, nameLink.c_str(), newlevel);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
void AddSC_character_commandscript()
|
||||
|
||||
@@ -22,10 +22,10 @@ Comment: All learn related commands
|
||||
Category: commandscripts
|
||||
EndScriptData */
|
||||
|
||||
#include "Chat.h"
|
||||
#include "ScriptMgr.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "SpellMgr.h"
|
||||
#include "Chat.h"
|
||||
#include "SpellInfo.h"
|
||||
|
||||
class learn_commandscript : public CommandScript
|
||||
@@ -37,35 +37,36 @@ public:
|
||||
{
|
||||
static ChatCommand learnAllMyCommandTable[] =
|
||||
{
|
||||
{ "class", SEC_ADMINISTRATOR, false, &HandleLearnAllMyClassCommand, "", NULL },
|
||||
{ "pettalents", SEC_ADMINISTRATOR, false, &HandleLearnAllMyPetTalentsCommand, "", NULL },
|
||||
{ "spells", SEC_ADMINISTRATOR, false, &HandleLearnAllMySpellsCommand, "", NULL },
|
||||
{ "talents", SEC_ADMINISTRATOR, false, &HandleLearnAllMyTalentsCommand, "", NULL },
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
{ "class", SEC_ADMINISTRATOR, false, &HandleLearnAllMyClassCommand, "", NULL },
|
||||
{ "pettalents", SEC_ADMINISTRATOR, false, &HandleLearnAllMyPetTalentsCommand, "", NULL },
|
||||
{ "spells", SEC_ADMINISTRATOR, false, &HandleLearnAllMySpellsCommand, "", NULL },
|
||||
{ "talents", SEC_ADMINISTRATOR, false, &HandleLearnAllMyTalentsCommand, "", NULL },
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
|
||||
static ChatCommand learnAllCommandTable[] =
|
||||
{
|
||||
{ "my", SEC_ADMINISTRATOR, false, NULL, "", learnAllMyCommandTable },
|
||||
{ "gm", SEC_GAMEMASTER, false, &HandleLearnAllGMCommand, "", NULL },
|
||||
{ "crafts", SEC_GAMEMASTER, false, &HandleLearnAllCraftsCommand, "", NULL },
|
||||
{ "default", SEC_MODERATOR, false, &HandleLearnAllDefaultCommand, "", NULL },
|
||||
{ "lang", SEC_MODERATOR, false, &HandleLearnAllLangCommand, "", NULL },
|
||||
{ "recipes", SEC_GAMEMASTER, false, &HandleLearnAllRecipesCommand, "", NULL },
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
{ "my", SEC_ADMINISTRATOR, false, NULL, "", learnAllMyCommandTable },
|
||||
{ "gm", SEC_GAMEMASTER, false, &HandleLearnAllGMCommand, "", NULL },
|
||||
{ "crafts", SEC_GAMEMASTER, false, &HandleLearnAllCraftsCommand, "", NULL },
|
||||
{ "default", SEC_MODERATOR, false, &HandleLearnAllDefaultCommand, "", NULL },
|
||||
{ "lang", SEC_MODERATOR, false, &HandleLearnAllLangCommand, "", NULL },
|
||||
{ "recipes", SEC_GAMEMASTER, false, &HandleLearnAllRecipesCommand, "", NULL },
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
|
||||
static ChatCommand learnCommandTable[] =
|
||||
{
|
||||
{ "all", SEC_ADMINISTRATOR, false, NULL, "", learnAllCommandTable },
|
||||
{ "", SEC_ADMINISTRATOR, false, &HandleLearnCommand, "", NULL },
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
{ "all", SEC_ADMINISTRATOR, false, NULL, "", learnAllCommandTable },
|
||||
{ "", SEC_ADMINISTRATOR, false, &HandleLearnCommand, "", NULL },
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
|
||||
static ChatCommand commandTable[] =
|
||||
{
|
||||
{ "learn", SEC_MODERATOR, false, NULL, "", learnCommandTable },
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
{ "learn", SEC_MODERATOR, false, NULL, "", learnCommandTable },
|
||||
{ "unlearn", SEC_ADMINISTRATOR, false, &HandleUnLearnCommand, "", NULL },
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
return commandTable;
|
||||
}
|
||||
@@ -466,6 +467,41 @@ public:
|
||||
player->learnSpell(skillLine->spellId, false);
|
||||
}
|
||||
}
|
||||
|
||||
static bool HandleUnLearnCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
// number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r
|
||||
uint32 spellId = handler->extractSpellIdFromLink((char*)args);
|
||||
if (!spellId)
|
||||
return false;
|
||||
|
||||
char const* allStr = strtok(NULL, " ");
|
||||
bool allRanks = allStr ? (strncmp(allStr, "all", strlen(allStr)) == 0) : false;
|
||||
|
||||
Player* target = handler->getSelectedPlayer();
|
||||
if (!target)
|
||||
{
|
||||
handler->SendSysMessage(LANG_NO_CHAR_SELECTED);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (allRanks)
|
||||
spellId = sSpellMgr->GetFirstSpellInChain (spellId);
|
||||
|
||||
if (target->HasSpell(spellId))
|
||||
target->removeSpell(spellId, false, !allRanks);
|
||||
else
|
||||
handler->SendSysMessage(LANG_FORGET_SPELL);
|
||||
|
||||
if (GetTalentSpellCost(spellId))
|
||||
target->SendTalentsInfoData(false);
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
void AddSC_learn_commandscript()
|
||||
|
||||
215
src/server/scripts/Commands/cs_message.cpp
Normal file
215
src/server/scripts/Commands/cs_message.cpp
Normal file
@@ -0,0 +1,215 @@
|
||||
/*
|
||||
* Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* ScriptData
|
||||
Name: message_commandscript
|
||||
%Complete: 100
|
||||
Comment: All message related commands
|
||||
Category: commandscripts
|
||||
EndScriptData */
|
||||
|
||||
#include "ScriptMgr.h"
|
||||
#include "Chat.h"
|
||||
#include "ChannelMgr.h"
|
||||
|
||||
class message_commandscript : public CommandScript
|
||||
{
|
||||
public:
|
||||
message_commandscript() : CommandScript("message_commandscript") { }
|
||||
|
||||
ChatCommand* GetCommands() const
|
||||
{
|
||||
static ChatCommand channelSetCommandTable[] =
|
||||
{
|
||||
{ "ownership", SEC_ADMINISTRATOR, false, &HandleChannelSetOwnership, "", NULL },
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
static ChatCommand channelCommandTable[] =
|
||||
{
|
||||
{ "set", SEC_ADMINISTRATOR, true, NULL, "", channelSetCommandTable },
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
static ChatCommand commandTable[] =
|
||||
{
|
||||
{ "channel", SEC_ADMINISTRATOR, true, NULL, "", channelCommandTable },
|
||||
{ "nameannounce", SEC_MODERATOR, true, &HandleNameAnnounceCommand, "", NULL },
|
||||
{ "gmnameannounce", SEC_MODERATOR, true, &HandleGMNameAnnounceCommand, "", NULL },
|
||||
{ "announce", SEC_MODERATOR, true, &HandleAnnounceCommand, "", NULL },
|
||||
{ "gmannounce", SEC_MODERATOR, true, &HandleGMAnnounceCommand, "", NULL },
|
||||
{ "notify", SEC_MODERATOR, true, &HandleNotifyCommand, "", NULL },
|
||||
{ "gmnotify", SEC_MODERATOR, true, &HandleGMNotifyCommand, "", NULL },
|
||||
{ "whispers", SEC_MODERATOR, false, &HandleWhispersCommand, "", NULL },
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
return commandTable;
|
||||
}
|
||||
|
||||
static bool HandleChannelSetOwnership(ChatHandler* handler, char const* args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
char const* channelStr = strtok((char*)args, " ");
|
||||
char const* argStr = strtok(NULL, "");
|
||||
|
||||
if (!channelStr || !argStr)
|
||||
return false;
|
||||
|
||||
Player* player = handler->GetSession()->GetPlayer();
|
||||
Channel* channcel = NULL;
|
||||
|
||||
if (ChannelMgr* cMgr = channelMgr(player->GetTeam()))
|
||||
channcel = cMgr->GetChannel(channelStr, player);
|
||||
|
||||
if (strcmp(argStr, "on") == 0)
|
||||
{
|
||||
if (channcel)
|
||||
channcel->SetOwnership(true);
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHANNEL_OWNERSHIP);
|
||||
stmt->setUInt8 (0, 1);
|
||||
stmt->setString(1, channelStr);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
handler->PSendSysMessage(LANG_CHANNEL_ENABLE_OWNERSHIP, channelStr);
|
||||
}
|
||||
else if (strcmp(argStr, "off") == 0)
|
||||
{
|
||||
if (channcel)
|
||||
channcel->SetOwnership(false);
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHANNEL_OWNERSHIP);
|
||||
stmt->setUInt8 (0, 0);
|
||||
stmt->setString(1, channelStr);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
handler->PSendSysMessage(LANG_CHANNEL_DISABLE_OWNERSHIP, channelStr);
|
||||
}
|
||||
else
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleNameAnnounceCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
std::string name("Console");
|
||||
if (WorldSession* session = handler->GetSession())
|
||||
name = session->GetPlayer()->GetName();
|
||||
|
||||
sWorld->SendWorldText(LANG_ANNOUNCE_COLOR, name.c_str(), args);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleGMNameAnnounceCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
std::string name("Console");
|
||||
if (WorldSession* session = handler->GetSession())
|
||||
name = session->GetPlayer()->GetName();
|
||||
|
||||
sWorld->SendGMText(LANG_GM_ANNOUNCE_COLOR, name.c_str(), args);
|
||||
return true;
|
||||
}
|
||||
// global announce
|
||||
static bool HandleAnnounceCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
char buff[2048];
|
||||
sprintf(buff, handler->GetTrinityString(LANG_SYSTEMMESSAGE), args);
|
||||
sWorld->SendServerMessage(SERVER_MSG_STRING, buff);
|
||||
return true;
|
||||
}
|
||||
// announce to logged in GMs
|
||||
static bool HandleGMAnnounceCommand(ChatHandler* /*handler*/, char const* args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
sWorld->SendGMText(LANG_GM_BROADCAST, args);
|
||||
return true;
|
||||
}
|
||||
// notification player at the screen
|
||||
static bool HandleNotifyCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
std::string str = handler->GetTrinityString(LANG_GLOBAL_NOTIFY);
|
||||
str += args;
|
||||
|
||||
WorldPacket data(SMSG_NOTIFICATION, (str.size()+1));
|
||||
data << str;
|
||||
sWorld->SendGlobalMessage(&data);
|
||||
|
||||
return true;
|
||||
}
|
||||
// notification GM at the screen
|
||||
static bool HandleGMNotifyCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
std::string str = handler->GetTrinityString(LANG_GM_NOTIFY);
|
||||
str += args;
|
||||
|
||||
WorldPacket data(SMSG_NOTIFICATION, (str.size()+1));
|
||||
data << str;
|
||||
sWorld->SendGlobalGMMessage(&data);
|
||||
|
||||
return true;
|
||||
}
|
||||
// Enable\Dissable accept whispers (for GM)
|
||||
static bool HandleWhispersCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
if (!*args)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_COMMAND_WHISPERACCEPTING, handler->GetSession()->GetPlayer()->isAcceptWhispers() ? handler->GetTrinityString(LANG_ON) : handler->GetTrinityString(LANG_OFF));
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string argStr = (char*)args;
|
||||
// whisper on
|
||||
if (argStr == "on")
|
||||
{
|
||||
handler->GetSession()->GetPlayer()->SetAcceptWhispers(true);
|
||||
handler->SendSysMessage(LANG_COMMAND_WHISPERON);
|
||||
return true;
|
||||
}
|
||||
|
||||
// whisper off
|
||||
if (argStr == "off")
|
||||
{
|
||||
// Remove all players from the Gamemaster's whisper whitelist
|
||||
handler->GetSession()->GetPlayer()->ClearWhisperWhiteList();
|
||||
handler->GetSession()->GetPlayer()->SetAcceptWhispers(false);
|
||||
handler->SendSysMessage(LANG_COMMAND_WHISPEROFF);
|
||||
return true;
|
||||
}
|
||||
|
||||
handler->SendSysMessage(LANG_USE_BOL);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
void AddSC_message_commandscript()
|
||||
{
|
||||
new message_commandscript();
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user