mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-25 11:21:58 +01:00
Scripts/Commands: Convert argument parsing of some misc commands to new system (#25308)
* Core/Shared: Make WeatherType smart
* Scripts/Commands: Convert argument parsing of some misc commands to new system
(cherry picked from commit 5bab0e43c6)
This commit is contained in:
committed by
Shauren
parent
53b28572bf
commit
1a6564f42f
@@ -60,6 +60,8 @@
|
||||
#undef GetClassName
|
||||
#endif
|
||||
|
||||
using namespace Trinity::ChatCommands;
|
||||
|
||||
class misc_commandscript : public CommandScript
|
||||
{
|
||||
public:
|
||||
@@ -95,7 +97,7 @@ public:
|
||||
{ "listfreeze", rbac::RBAC_PERM_COMMAND_LISTFREEZE, false, &HandleListFreezeCommand, "" },
|
||||
{ "movegens", rbac::RBAC_PERM_COMMAND_MOVEGENS, false, &HandleMovegensCommand, "" },
|
||||
{ "mute", rbac::RBAC_PERM_COMMAND_MUTE, true, &HandleMuteCommand, "" },
|
||||
{ "mutehistory", rbac::RBAC_PERM_COMMAND_MUTEHISTORY, true, &HandleMuteInfoCommand, "" },
|
||||
{ "mutehistory", rbac::RBAC_PERM_COMMAND_MUTEHISTORY, true, &HandleMuteHistoryCommand, "" },
|
||||
{ "neargrave", rbac::RBAC_PERM_COMMAND_NEARGRAVE, false, &HandleNearGraveCommand, "" },
|
||||
{ "pinfo", rbac::RBAC_PERM_COMMAND_PINFO, true, &HandlePInfoCommand, "" },
|
||||
{ "playall", rbac::RBAC_PERM_COMMAND_PLAYALL, false, &HandlePlayAllCommand, "" },
|
||||
@@ -123,7 +125,7 @@ public:
|
||||
return commandTable;
|
||||
}
|
||||
|
||||
static bool HandlePvPstatsCommand(ChatHandler * handler, char const* /*args*/)
|
||||
static bool HandlePvPstatsCommand(ChatHandler* handler)
|
||||
{
|
||||
if (sWorld->getBoolConfig(CONFIG_BATTLEGROUND_STORE_STATISTICS_ENABLE))
|
||||
{
|
||||
@@ -152,32 +154,28 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleDevCommand(ChatHandler* handler, Optional<std::string> enable)
|
||||
static bool HandleDevCommand(ChatHandler* handler, Optional<bool> enableArg)
|
||||
{
|
||||
Player* player = handler->GetSession()->GetPlayer();
|
||||
|
||||
if (!enable)
|
||||
if (!enableArg)
|
||||
{
|
||||
handler->GetSession()->SendNotification(player->IsDeveloper() ? LANG_DEV_ON : LANG_DEV_OFF);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (*enable == "on")
|
||||
if (*enableArg)
|
||||
{
|
||||
player->SetDeveloper(true);
|
||||
handler->GetSession()->SendNotification(LANG_DEV_ON);
|
||||
return true;
|
||||
}
|
||||
else if (*enable == "off")
|
||||
else
|
||||
{
|
||||
player->SetDeveloper(false);
|
||||
handler->GetSession()->SendNotification(LANG_DEV_OFF);
|
||||
return true;
|
||||
}
|
||||
|
||||
handler->SendSysMessage(LANG_USE_BOL);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleGPSCommand(ChatHandler* handler, char const* args)
|
||||
@@ -303,7 +301,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleAuraCommand(ChatHandler* handler, char const* args)
|
||||
static bool HandleAuraCommand(ChatHandler* handler, SpellInfo const* spell)
|
||||
{
|
||||
Unit* target = handler->getSelectedUnit();
|
||||
if (!target)
|
||||
@@ -313,22 +311,19 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
// number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
|
||||
uint32 spellId = handler->extractSpellIdFromLink((char*)args);
|
||||
if(!spell)
|
||||
return false;
|
||||
|
||||
if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId, target->GetMap()->GetDifficultyID()))
|
||||
{
|
||||
ObjectGuid castId = ObjectGuid::Create<HighGuid::Cast>(SPELL_CAST_SOURCE_NORMAL, target->GetMapId(), spellId, target->GetMap()->GenerateLowGuid<HighGuid::Cast>());
|
||||
AuraCreateInfo createInfo(castId, spellInfo, target->GetMap()->GetDifficultyID(), MAX_EFFECT_MASK, target);
|
||||
createInfo.SetCaster(target);
|
||||
ObjectGuid castId = ObjectGuid::Create<HighGuid::Cast>(SPELL_CAST_SOURCE_NORMAL, target->GetMapId(), spell->Id, target->GetMap()->GenerateLowGuid<HighGuid::Cast>());
|
||||
AuraCreateInfo createInfo(castId, spell, target->GetMap()->GetDifficultyID(), MAX_EFFECT_MASK, target);
|
||||
createInfo.SetCaster(target);
|
||||
|
||||
Aura::TryRefreshStackOrCreate(createInfo);
|
||||
}
|
||||
Aura::TryRefreshStackOrCreate(createInfo);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleUnAuraCommand(ChatHandler* handler, char const* args)
|
||||
static bool HandleUnAuraCommand(ChatHandler* handler, Variant<SpellInfo const*, ExactSequence<'a', 'l', 'l'>> spellArg)
|
||||
{
|
||||
Unit* target = handler->getSelectedUnit();
|
||||
if (!target)
|
||||
@@ -338,22 +333,21 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string argstr = args;
|
||||
if (argstr == "all")
|
||||
if (spellArg.holds_alternative<ExactSequence<'a', 'l', 'l'>>())
|
||||
{
|
||||
target->RemoveAllAuras();
|
||||
return true;
|
||||
}
|
||||
|
||||
// number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
|
||||
uint32 spellId = handler->extractSpellIdFromLink((char*)args);
|
||||
if (!spellId)
|
||||
return false;
|
||||
if (SpellInfo const* spellInfo = spellArg.get<SpellInfo const*>())
|
||||
{
|
||||
target->RemoveAurasDueToSpell(spellInfo->Id);
|
||||
return true;
|
||||
}
|
||||
|
||||
target->RemoveAurasDueToSpell(spellId);
|
||||
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Teleport to Player
|
||||
static bool HandleAppearCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
@@ -492,6 +486,7 @@ public:
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Summon Player
|
||||
static bool HandleSummonCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
@@ -611,13 +606,13 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleCommandsCommand(ChatHandler* handler, char const* /*args*/)
|
||||
static bool HandleCommandsCommand(ChatHandler* handler)
|
||||
{
|
||||
handler->ShowHelpForCommand(handler->getCommandTable(), "");
|
||||
handler->ShowHelpForCommand(ChatHandler::getCommandTable(), "");
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleDieCommand(ChatHandler* handler, char const* /*args*/)
|
||||
static bool HandleDieCommand(ChatHandler* handler)
|
||||
{
|
||||
Unit* target = handler->getSelectedUnit();
|
||||
|
||||
@@ -665,7 +660,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleDismountCommand(ChatHandler* handler, char const* /*args*/)
|
||||
static bool HandleDismountCommand(ChatHandler* handler)
|
||||
{
|
||||
Player* player = handler->getSelectedPlayerOrSelf();
|
||||
|
||||
@@ -689,7 +684,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleGUIDCommand(ChatHandler* handler, char const* /*args*/)
|
||||
static bool HandleGUIDCommand(ChatHandler* handler)
|
||||
{
|
||||
ObjectGuid guid = handler->GetSession()->GetPlayer()->GetTarget();
|
||||
|
||||
@@ -704,39 +699,25 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleHelpCommand(ChatHandler* handler, char const* args)
|
||||
static bool HandleHelpCommand(ChatHandler* handler, Optional<std::string> cmdArg)
|
||||
{
|
||||
char const* cmd = strtok((char*)args, " ");
|
||||
if (!cmd)
|
||||
if (!cmdArg)
|
||||
{
|
||||
handler->ShowHelpForCommand(handler->getCommandTable(), "help");
|
||||
handler->ShowHelpForCommand(handler->getCommandTable(), "");
|
||||
handler->ShowHelpForCommand(ChatHandler::getCommandTable(), "help");
|
||||
handler->ShowHelpForCommand(ChatHandler::getCommandTable(), "");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!handler->ShowHelpForCommand(handler->getCommandTable(), cmd))
|
||||
if (!handler->ShowHelpForCommand(ChatHandler::getCommandTable(), cmdArg->c_str()))
|
||||
handler->SendSysMessage(LANG_NO_HELP_CMD);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// move item to other slot
|
||||
static bool HandleItemMoveCommand(ChatHandler* handler, char const* args)
|
||||
static bool HandleItemMoveCommand(ChatHandler* handler, uint8 srcSlot, uint8 dstSlot)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
char const* param1 = strtok((char*)args, " ");
|
||||
if (!param1)
|
||||
return false;
|
||||
|
||||
char const* param2 = strtok(nullptr, " ");
|
||||
if (!param2)
|
||||
return false;
|
||||
|
||||
uint8 srcSlot = uint8(atoi(param1));
|
||||
uint8 dstSlot = uint8(atoi(param2));
|
||||
|
||||
if (srcSlot == dstSlot)
|
||||
return true;
|
||||
|
||||
@@ -754,7 +735,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleCooldownCommand(ChatHandler* handler, char const* args)
|
||||
static bool HandleCooldownCommand(ChatHandler* handler, Optional<SpellInfo const*> spellArg)
|
||||
{
|
||||
Unit* target = handler->getSelectedUnit();
|
||||
if (!target)
|
||||
@@ -773,7 +754,7 @@ public:
|
||||
|
||||
std::string nameLink = handler->GetNameLink(owner);
|
||||
|
||||
if (!*args)
|
||||
if (!spellArg)
|
||||
{
|
||||
target->GetSpellHistory()->ResetAllCooldowns();
|
||||
target->GetSpellHistory()->ResetAllCharges();
|
||||
@@ -781,22 +762,16 @@ public:
|
||||
}
|
||||
else
|
||||
{
|
||||
// number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
|
||||
uint32 spellIid = handler->extractSpellIdFromLink((char*)args);
|
||||
if (!spellIid)
|
||||
return false;
|
||||
|
||||
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellIid, target->GetMap()->GetDifficultyID());
|
||||
if (!spellInfo)
|
||||
if (!*spellArg)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_UNKNOWN_SPELL, owner == handler->GetSession()->GetPlayer() ? handler->GetTrinityString(LANG_YOU) : nameLink.c_str());
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
target->GetSpellHistory()->ResetCooldown(spellIid, true);
|
||||
target->GetSpellHistory()->ResetCharges(spellInfo->ChargeCategoryId);
|
||||
handler->PSendSysMessage(LANG_REMOVE_COOLDOWN, spellIid, owner == handler->GetSession()->GetPlayer() ? handler->GetTrinityString(LANG_YOU) : nameLink.c_str());
|
||||
target->GetSpellHistory()->ResetCooldown((*spellArg)->Id, true);
|
||||
target->GetSpellHistory()->ResetCharges((*spellArg)->ChargeCategoryId);
|
||||
handler->PSendSysMessage(LANG_REMOVE_COOLDOWN, (*spellArg)->Id, owner == handler->GetSession()->GetPlayer() ? handler->GetTrinityString(LANG_YOU) : nameLink.c_str());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -862,6 +837,7 @@ public:
|
||||
handler->PSendSysMessage(LANG_DISTANCE, handler->GetSession()->GetPlayer()->GetDistance(object), handler->GetSession()->GetPlayer()->GetDistance2d(object), handler->GetSession()->GetPlayer()->GetExactDist(object), handler->GetSession()->GetPlayer()->GetExactDist2d(object));
|
||||
return true;
|
||||
}
|
||||
|
||||
// Teleport player to last position
|
||||
static bool HandleRecallCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
@@ -886,7 +862,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleSaveCommand(ChatHandler* handler, char const* /*args*/)
|
||||
static bool HandleSaveCommand(ChatHandler* handler)
|
||||
{
|
||||
Player* player = handler->GetSession()->GetPlayer();
|
||||
|
||||
@@ -910,7 +886,7 @@ public:
|
||||
}
|
||||
|
||||
// Save all players in the world
|
||||
static bool HandleSaveAllCommand(ChatHandler* handler, char const* /*args*/)
|
||||
static bool HandleSaveAllCommand(ChatHandler* handler)
|
||||
{
|
||||
ObjectAccessor::SaveAllPlayers();
|
||||
handler->SendSysMessage(LANG_PLAYERS_SAVED);
|
||||
@@ -1033,26 +1009,15 @@ public:
|
||||
|
||||
}
|
||||
|
||||
static bool HandleLinkGraveCommand(ChatHandler* handler, char const* args)
|
||||
static bool HandleLinkGraveCommand(ChatHandler* handler, uint32 graveyardId, Optional<std::string> teamArg)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
char* px = strtok((char*)args, " ");
|
||||
if (!px)
|
||||
return false;
|
||||
|
||||
uint32 graveyardId = atoul(px);
|
||||
|
||||
uint32 team;
|
||||
|
||||
char* px2 = strtok(nullptr, " ");
|
||||
|
||||
if (!px2)
|
||||
if (!teamArg)
|
||||
team = 0;
|
||||
else if (strncmp(px2, "horde", 6) == 0)
|
||||
else if (StringEqualI(*teamArg, "horde"))
|
||||
team = HORDE;
|
||||
else if (strncmp(px2, "alliance", 9) == 0)
|
||||
else if (StringEqualI(*teamArg, "alliance"))
|
||||
team = ALLIANCE;
|
||||
else
|
||||
return false;
|
||||
@@ -1086,17 +1051,15 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleNearGraveCommand(ChatHandler* handler, char const* args)
|
||||
static bool HandleNearGraveCommand(ChatHandler* handler, Optional<std::string> teamArg)
|
||||
{
|
||||
uint32 team;
|
||||
|
||||
size_t argStr = strlen(args);
|
||||
|
||||
if (!*args)
|
||||
if (!teamArg)
|
||||
team = 0;
|
||||
else if (strncmp((char*)args, "horde", argStr) == 0)
|
||||
else if (StringEqualI(*teamArg, "horde"))
|
||||
team = HORDE;
|
||||
else if (strncmp((char*)args, "alliance", argStr) == 0)
|
||||
else if (StringEqualI(*teamArg, "alliance"))
|
||||
team = ALLIANCE;
|
||||
else
|
||||
return false;
|
||||
@@ -1148,11 +1111,8 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleShowAreaCommand(ChatHandler* handler, char const* args)
|
||||
static bool HandleShowAreaCommand(ChatHandler* handler, uint32 areaId)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
Player* playerTarget = handler->getSelectedPlayer();
|
||||
if (!playerTarget)
|
||||
{
|
||||
@@ -1161,7 +1121,7 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
AreaTableEntry const* area = sAreaTableStore.LookupEntry(atoi(args));
|
||||
AreaTableEntry const* area = sAreaTableStore.LookupEntry(areaId);
|
||||
if (!area)
|
||||
{
|
||||
handler->SendSysMessage(LANG_BAD_VALUE);
|
||||
@@ -1191,11 +1151,8 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleHideAreaCommand(ChatHandler* handler, char const* args)
|
||||
static bool HandleHideAreaCommand(ChatHandler* handler, uint32 areaId)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
Player* playerTarget = handler->getSelectedPlayer();
|
||||
if (!playerTarget)
|
||||
{
|
||||
@@ -1204,7 +1161,7 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
AreaTableEntry const* area = sAreaTableStore.LookupEntry(atoi(args));
|
||||
AreaTableEntry const* area = sAreaTableStore.LookupEntry(areaId);
|
||||
if (!area)
|
||||
{
|
||||
handler->SendSysMessage(LANG_BAD_VALUE);
|
||||
@@ -1390,19 +1347,10 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleAddItemSetCommand(ChatHandler* handler, char const* args)
|
||||
static bool HandleAddItemSetCommand(ChatHandler* handler, Variant<Hyperlink<itemset>, uint32> itemSetId)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
char const* id = handler->extractKeyFromLink((char*)args, "Hitemset"); // number or [name] Shift-click form |color|Hitemset:itemset_id|h[name]|h|r
|
||||
if (!id)
|
||||
return false;
|
||||
|
||||
uint32 itemSetId = atoul(id);
|
||||
|
||||
// prevent generation all items with itemset field value '0'
|
||||
if (itemSetId == 0)
|
||||
if (*itemSetId == 0)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_NO_ITEMS_FROM_ITEMSET_FOUND, itemSetId);
|
||||
handler->SetSentErrorMessage(true);
|
||||
@@ -1437,7 +1385,7 @@ public:
|
||||
ItemTemplateContainer const& its = sObjectMgr->GetItemTemplateStore();
|
||||
for (auto const& itemTemplatePair : its)
|
||||
{
|
||||
if (itemTemplatePair.second.GetItemSet() != itemSetId)
|
||||
if (itemTemplatePair.second.GetItemSet() != *itemSetId)
|
||||
continue;
|
||||
|
||||
found = true;
|
||||
@@ -1479,17 +1427,14 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleBankCommand(ChatHandler* handler, char const* /*args*/)
|
||||
static bool HandleBankCommand(ChatHandler* handler)
|
||||
{
|
||||
handler->GetSession()->SendShowBank(handler->GetSession()->GetPlayer()->GetGUID());
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleChangeWeather(ChatHandler* handler, char const* args)
|
||||
static bool HandleChangeWeather(ChatHandler* handler, WeatherType type, float intensity)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
// Weather is OFF
|
||||
if (!sWorld->getBoolConfig(CONFIG_WEATHER))
|
||||
{
|
||||
@@ -1498,16 +1443,6 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
// *Change the weather of a cell
|
||||
char const* px = strtok((char*)args, " ");
|
||||
char const* py = strtok(nullptr, " ");
|
||||
|
||||
if (!px || !py)
|
||||
return false;
|
||||
|
||||
uint32 type = uint32(atoi(px)); //0 to 3, 0: fine, 1: rain, 2: snow, 3: sand
|
||||
float grade = float(atof(py)); //0 to 1, sending -1 is instand good weather
|
||||
|
||||
Player* player = handler->GetSession()->GetPlayer();
|
||||
uint32 zoneid = player->GetZoneId();
|
||||
|
||||
@@ -1519,34 +1454,13 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
weather->SetWeather(WeatherType(type), grade);
|
||||
weather->SetWeather(type, intensity);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleSetSkillCommand(ChatHandler* handler, char const* args)
|
||||
static bool HandleSetSkillCommand(ChatHandler* handler, Variant<Hyperlink<skill>, uint32> skillId, uint32 level, Optional<uint32> maxSkillArg)
|
||||
{
|
||||
// number or [name] Shift-click form |color|Hskill:skill_id|h[name]|h|r
|
||||
char const* skillStr = handler->extractKeyFromLink((char*)args, "Hskill");
|
||||
if (!skillStr)
|
||||
return false;
|
||||
|
||||
char const* levelStr = strtok(nullptr, " ");
|
||||
if (!levelStr)
|
||||
return false;
|
||||
|
||||
char const* maxPureSkill = strtok(nullptr, " ");
|
||||
|
||||
uint32 skill = atoul(skillStr);
|
||||
if (skill == 0)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_INVALID_SKILL_ID, skill);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32 level = atoul(levelStr);
|
||||
|
||||
Player* target = handler->getSelectedPlayerOrSelf();
|
||||
if (!target)
|
||||
{
|
||||
@@ -1555,19 +1469,19 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
SkillLineEntry const* skillLine = sSkillLineStore.LookupEntry(skill);
|
||||
SkillLineEntry const* skillLine = sSkillLineStore.LookupEntry(skillId);
|
||||
if (!skillLine)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_INVALID_SKILL_ID, skill);
|
||||
handler->PSendSysMessage(LANG_INVALID_SKILL_ID, skillId);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool targetHasSkill = target->GetSkillValue(skill) != 0;
|
||||
bool targetHasSkill = target->GetSkillValue(skillId) != 0;
|
||||
|
||||
// If our target does not yet have the skill they are trying to add to them, the chosen level also becomes
|
||||
// the max level of the new profession.
|
||||
uint16 max = maxPureSkill ? atoul(maxPureSkill) : targetHasSkill ? target->GetPureMaxSkillValue(skill) : uint16(level);
|
||||
uint16 max = maxSkillArg.value_or(targetHasSkill ? target->GetPureMaxSkillValue(skillId) : level);
|
||||
|
||||
if (level == 0 || level > max)
|
||||
return false;
|
||||
@@ -1575,8 +1489,8 @@ public:
|
||||
// If the player has the skill, we get the current skill step. If they don't have the skill, we
|
||||
// add the skill to the player's book with step 1 (which is the first rank, in most cases something
|
||||
// like 'Apprentice <skill>'.
|
||||
target->SetSkill(skill, targetHasSkill ? target->GetSkillStep(skill) : 1, level, max);
|
||||
handler->PSendSysMessage(LANG_SET_SKILL, skill, skillLine->DisplayName[handler->GetSessionDbcLocale()], handler->GetNameLink(target).c_str(), level, max);
|
||||
target->SetSkill(skillId, targetHasSkill ? target->GetSkillStep(skillId) : 1, level, max);
|
||||
handler->PSendSysMessage(LANG_SET_SKILL, skillId, skillLine->DisplayName[handler->GetSessionDbcLocale()], handler->GetNameLink(target).c_str(), level, max);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1597,7 +1511,6 @@ public:
|
||||
*
|
||||
* @return Several pieces of information about the character and the account
|
||||
**/
|
||||
|
||||
static bool HandlePInfoCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
// Define ALL the player variables!
|
||||
@@ -1965,7 +1878,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleRespawnCommand(ChatHandler* handler, char const* /*args*/)
|
||||
static bool HandleRespawnCommand(ChatHandler* handler)
|
||||
{
|
||||
Player* player = handler->GetSession()->GetPlayer();
|
||||
|
||||
@@ -2004,7 +1917,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
// mute player for some times
|
||||
// mute player for the specified duration
|
||||
static bool HandleMuteCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
char* nameStr;
|
||||
@@ -2134,16 +2047,8 @@ public:
|
||||
}
|
||||
|
||||
// mutehistory command
|
||||
static bool HandleMuteInfoCommand(ChatHandler* handler, char const* args)
|
||||
static bool HandleMuteHistoryCommand(ChatHandler* handler, std::string accountName)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
char *nameStr = strtok((char*)args, "");
|
||||
if (!nameStr)
|
||||
return false;
|
||||
|
||||
std::string accountName = nameStr;
|
||||
if (!Utf8ToUpperOnlyLatin(accountName))
|
||||
{
|
||||
handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str());
|
||||
@@ -2158,11 +2063,11 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
return HandleMuteInfoHelper(accountId, accountName.c_str(), handler);
|
||||
return HandleMuteHistoryHelper(accountId, accountName.c_str(), handler);
|
||||
}
|
||||
|
||||
// helper for mutehistory
|
||||
static bool HandleMuteInfoHelper(uint32 accountId, char const* accountName, ChatHandler *handler)
|
||||
static bool HandleMuteHistoryHelper(uint32 accountId, char const* accountName, ChatHandler *handler)
|
||||
{
|
||||
LoginDatabasePreparedStatement *stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_MUTE_INFO);
|
||||
stmt->setUInt32(0, accountId);
|
||||
@@ -2193,7 +2098,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleMovegensCommand(ChatHandler* handler, char const* /*args*/)
|
||||
static bool HandleMovegensCommand(ChatHandler* handler)
|
||||
{
|
||||
Unit* unit = handler->getSelectedUnit();
|
||||
if (!unit)
|
||||
@@ -2276,7 +2181,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleComeToMeCommand(ChatHandler* handler, char const* /*args*/)
|
||||
static bool HandleComeToMeCommand(ChatHandler* handler)
|
||||
{
|
||||
Creature* caster = handler->getSelectedCreature();
|
||||
if (!caster)
|
||||
@@ -2588,15 +2493,14 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool HandleUnFreezeCommand(ChatHandler* handler, char const*args)
|
||||
static bool HandleUnFreezeCommand(ChatHandler* handler, Optional<std::string> targetNameArg)
|
||||
{
|
||||
std::string name;
|
||||
Player* player;
|
||||
char* targetName = strtok((char*)args, " "); // Get entered name
|
||||
|
||||
if (targetName)
|
||||
if (targetNameArg)
|
||||
{
|
||||
name = targetName;
|
||||
name = *targetNameArg;
|
||||
normalizePlayerName(name);
|
||||
player = ObjectAccessor::FindPlayerByName(name);
|
||||
}
|
||||
@@ -2618,7 +2522,7 @@ public:
|
||||
}
|
||||
else
|
||||
{
|
||||
if (targetName)
|
||||
if (targetNameArg)
|
||||
{
|
||||
// Check for offline players
|
||||
ObjectGuid guid = sCharacterCache->GetCharacterGuidByName(name);
|
||||
@@ -2646,7 +2550,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleListFreezeCommand(ChatHandler* handler, char const* /*args*/)
|
||||
static bool HandleListFreezeCommand(ChatHandler* handler)
|
||||
{
|
||||
// Get names from DB
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_AURA_FROZEN);
|
||||
@@ -2682,15 +2586,8 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandlePlayAllCommand(ChatHandler* handler, char const* args)
|
||||
static bool HandlePlayAllCommand(ChatHandler* handler, uint32 soundId, Optional<int32> broadcastTextId)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
char const* soundIdToken = strtok((char*)args, " ");
|
||||
|
||||
uint32 soundId = atoul(soundIdToken);
|
||||
|
||||
if (!sSoundKitStore.LookupEntry(soundId))
|
||||
{
|
||||
handler->PSendSysMessage(LANG_SOUND_NOT_EXIST, soundId);
|
||||
@@ -2698,18 +2595,13 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32 broadcastTextId = 0;
|
||||
char const* broadcastTextIdToken = strtok(nullptr, " ");
|
||||
if (broadcastTextIdToken)
|
||||
broadcastTextId = atoul(broadcastTextIdToken);
|
||||
|
||||
sWorld->SendGlobalMessage(WorldPackets::Misc::PlaySound(handler->GetSession()->GetPlayer()->GetGUID(), soundId, broadcastTextId).Write());
|
||||
sWorld->SendGlobalMessage(WorldPackets::Misc::PlaySound(handler->GetSession()->GetPlayer()->GetGUID(), soundId, broadcastTextId.value_or(0)).Write());
|
||||
|
||||
handler->PSendSysMessage(LANG_COMMAND_PLAYED_TO_ALL, soundId);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandlePossessCommand(ChatHandler* handler, char const* /*args*/)
|
||||
static bool HandlePossessCommand(ChatHandler* handler)
|
||||
{
|
||||
Unit* unit = handler->getSelectedUnit();
|
||||
if (!unit)
|
||||
@@ -2719,7 +2611,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleUnPossessCommand(ChatHandler* handler, char const* /*args*/)
|
||||
static bool HandleUnPossessCommand(ChatHandler* handler)
|
||||
{
|
||||
Unit* unit = handler->getSelectedUnit();
|
||||
if (!unit)
|
||||
@@ -2730,7 +2622,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleBindSightCommand(ChatHandler* handler, char const* /*args*/)
|
||||
static bool HandleBindSightCommand(ChatHandler* handler)
|
||||
{
|
||||
Unit* unit = handler->getSelectedUnit();
|
||||
if (!unit)
|
||||
@@ -2740,7 +2632,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleUnbindSightCommand(ChatHandler* handler, char const* /*args*/)
|
||||
static bool HandleUnbindSightCommand(ChatHandler* handler)
|
||||
{
|
||||
Player* player = handler->GetSession()->GetPlayer();
|
||||
|
||||
@@ -2751,7 +2643,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleMailBoxCommand(ChatHandler* handler, char const* /*args*/)
|
||||
static bool HandleMailBoxCommand(ChatHandler* handler)
|
||||
{
|
||||
Player* player = handler->GetSession()->GetPlayer();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user