mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +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
This commit is contained in:
committed by
GitHub
parent
cefac75a7d
commit
5bab0e43c6
@@ -5985,7 +5985,7 @@ void Player::UpdateWeaponsSkillsToMaxSkillsForLevel()
|
||||
|
||||
// This functions sets a skill line value (and adds if doesn't exist yet)
|
||||
// To "remove" a skill line, set it's values to zero
|
||||
void Player::SetSkill(uint16 id, uint16 step, uint16 newVal, uint16 maxVal)
|
||||
void Player::SetSkill(uint32 id, uint16 step, uint16 newVal, uint16 maxVal)
|
||||
{
|
||||
if (!id)
|
||||
return;
|
||||
@@ -6099,7 +6099,7 @@ bool Player::HasSkill(uint32 skill) const
|
||||
return (itr != mSkillStatus.end() && itr->second.uState != SKILL_DELETED);
|
||||
}
|
||||
|
||||
uint16 Player::GetSkillStep(uint16 skill) const
|
||||
uint16 Player::GetSkillStep(uint32 skill) const
|
||||
{
|
||||
if (!skill)
|
||||
return 0;
|
||||
|
||||
@@ -1731,7 +1731,7 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
|
||||
void UpdateWeaponSkill(Unit* victim, WeaponAttackType attType);
|
||||
void UpdateCombatSkills(Unit* victim, WeaponAttackType attType, bool defense);
|
||||
|
||||
void SetSkill(uint16 id, uint16 step, uint16 newVal, uint16 maxVal);
|
||||
void SetSkill(uint32 id, uint16 step, uint16 newVal, uint16 maxVal);
|
||||
uint16 GetMaxSkillValue(uint32 skill) const; // max + perm. bonus + temp bonus
|
||||
uint16 GetPureMaxSkillValue(uint32 skill) const; // max
|
||||
uint16 GetSkillValue(uint32 skill) const; // skill value + perm. bonus + temp bonus
|
||||
@@ -1739,7 +1739,7 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
|
||||
uint16 GetPureSkillValue(uint32 skill) const; // skill value
|
||||
int16 GetSkillPermBonusValue(uint32 skill) const;
|
||||
int16 GetSkillTempBonusValue(uint32 skill) const;
|
||||
uint16 GetSkillStep(uint16 skill) const; // 0...6
|
||||
uint16 GetSkillStep(uint32 skill) const; // 0...6
|
||||
bool HasSkill(uint32 skill) const;
|
||||
void LearnSkillRewardedSpells(uint32 skillId, uint32 skillValue);
|
||||
|
||||
|
||||
@@ -57,6 +57,8 @@
|
||||
#undef GetClassName
|
||||
#endif
|
||||
|
||||
using namespace Trinity::ChatCommands;
|
||||
|
||||
class misc_commandscript : public CommandScript
|
||||
{
|
||||
public:
|
||||
@@ -94,7 +96,7 @@ public:
|
||||
{ "maxskill", rbac::RBAC_PERM_COMMAND_MAXSKILL, false, &HandleMaxSkillCommand, "" },
|
||||
{ "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, "" },
|
||||
@@ -121,7 +123,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))
|
||||
{
|
||||
@@ -150,32 +152,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)
|
||||
@@ -299,7 +297,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)
|
||||
@@ -309,21 +307,18 @@ 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))
|
||||
{
|
||||
AuraCreateInfo createInfo(spellInfo, MAX_EFFECT_MASK, target);
|
||||
createInfo.SetCaster(target);
|
||||
AuraCreateInfo createInfo(spell, 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)
|
||||
@@ -333,22 +328,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)
|
||||
{
|
||||
@@ -483,6 +477,7 @@ public:
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Summon Player
|
||||
static bool HandleSummonCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
@@ -601,13 +596,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();
|
||||
|
||||
@@ -655,7 +650,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleDismountCommand(ChatHandler* handler, char const* /*args*/)
|
||||
static bool HandleDismountCommand(ChatHandler* handler)
|
||||
{
|
||||
Player* player = handler->getSelectedPlayerOrSelf();
|
||||
|
||||
@@ -679,7 +674,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleGUIDCommand(ChatHandler* handler, char const* /*args*/)
|
||||
static bool HandleGUIDCommand(ChatHandler* handler)
|
||||
{
|
||||
ObjectGuid guid = handler->GetSession()->GetPlayer()->GetTarget();
|
||||
|
||||
@@ -694,39 +689,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;
|
||||
|
||||
@@ -744,7 +725,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)
|
||||
@@ -763,28 +744,22 @@ public:
|
||||
|
||||
std::string nameLink = handler->GetNameLink(owner);
|
||||
|
||||
if (!*args)
|
||||
if (!spellArg)
|
||||
{
|
||||
target->GetSpellHistory()->ResetAllCooldowns();
|
||||
handler->PSendSysMessage(LANG_REMOVEALL_COOLDOWN, nameLink.c_str());
|
||||
}
|
||||
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);
|
||||
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);
|
||||
handler->PSendSysMessage(LANG_REMOVE_COOLDOWN, spellIid, owner == handler->GetSession()->GetPlayer() ? handler->GetTrinityString(LANG_YOU) : nameLink.c_str());
|
||||
target->GetSpellHistory()->ResetCooldown((*spellArg)->Id, true);
|
||||
handler->PSendSysMessage(LANG_REMOVE_COOLDOWN, (*spellArg)->Id, owner == handler->GetSession()->GetPlayer() ? handler->GetTrinityString(LANG_YOU) : nameLink.c_str());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -850,6 +825,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)
|
||||
{
|
||||
@@ -874,7 +850,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleSaveCommand(ChatHandler* handler, char const* /*args*/)
|
||||
static bool HandleSaveCommand(ChatHandler* handler)
|
||||
{
|
||||
Player* player = handler->GetSession()->GetPlayer();
|
||||
|
||||
@@ -898,7 +874,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);
|
||||
@@ -1003,26 +979,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 = uint32(atoi(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;
|
||||
@@ -1056,17 +1021,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;
|
||||
@@ -1118,11 +1081,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)
|
||||
{
|
||||
@@ -1131,7 +1091,7 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
AreaTableEntry const* area = sAreaTableStore.LookupEntry(atoi(args));
|
||||
AreaTableEntry const* area = sAreaTableStore.LookupEntry(areaId);
|
||||
if (!area)
|
||||
{
|
||||
handler->SendSysMessage(LANG_BAD_VALUE);
|
||||
@@ -1155,11 +1115,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)
|
||||
{
|
||||
@@ -1168,7 +1125,7 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
AreaTableEntry const* area = sAreaTableStore.LookupEntry(atoi(args));
|
||||
AreaTableEntry const* area = sAreaTableStore.LookupEntry(areaId);
|
||||
if (!area)
|
||||
{
|
||||
handler->SendSysMessage(LANG_BAD_VALUE);
|
||||
@@ -1320,19 +1277,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);
|
||||
@@ -1350,7 +1298,7 @@ public:
|
||||
ItemTemplateContainer const& its = sObjectMgr->GetItemTemplateStore();
|
||||
for (auto const& itemTemplatePair : its)
|
||||
{
|
||||
if (itemTemplatePair.second.ItemSet != itemSetId)
|
||||
if (itemTemplatePair.second.ItemSet != *itemSetId)
|
||||
continue;
|
||||
|
||||
found = true;
|
||||
@@ -1385,17 +1333,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))
|
||||
{
|
||||
@@ -1404,16 +1349,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();
|
||||
|
||||
@@ -1425,13 +1360,12 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
weather->SetWeather(WeatherType(type), grade);
|
||||
weather->SetWeather(type, intensity);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static bool HandleMaxSkillCommand(ChatHandler* handler, char const* /*args*/)
|
||||
static bool HandleMaxSkillCommand(ChatHandler* handler)
|
||||
{
|
||||
Player* player = handler->getSelectedPlayerOrSelf();
|
||||
if (!player)
|
||||
@@ -1446,29 +1380,8 @@ public:
|
||||
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, " ");
|
||||
|
||||
int32 skill = atoi(skillStr);
|
||||
if (skill <= 0)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_INVALID_SKILL_ID, skill);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
int32 level = atol(levelStr);
|
||||
|
||||
Player* target = handler->getSelectedPlayerOrSelf();
|
||||
if (!target)
|
||||
{
|
||||
@@ -1477,19 +1390,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;
|
||||
@@ -1497,8 +1410,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;
|
||||
}
|
||||
|
||||
@@ -1519,7 +1432,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!
|
||||
@@ -1891,7 +1803,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleRespawnCommand(ChatHandler* handler, char const* /*args*/)
|
||||
static bool HandleRespawnCommand(ChatHandler* handler)
|
||||
{
|
||||
Player* player = handler->GetSession()->GetPlayer();
|
||||
|
||||
@@ -1930,7 +1842,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;
|
||||
@@ -2060,16 +1972,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());
|
||||
@@ -2084,11 +1988,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);
|
||||
@@ -2119,7 +2023,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleMovegensCommand(ChatHandler* handler, char const* /*args*/)
|
||||
static bool HandleMovegensCommand(ChatHandler* handler)
|
||||
{
|
||||
Unit* unit = handler->getSelectedUnit();
|
||||
if (!unit)
|
||||
@@ -2202,7 +2106,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleComeToMeCommand(ChatHandler* handler, char const* /*args*/)
|
||||
static bool HandleComeToMeCommand(ChatHandler* handler)
|
||||
{
|
||||
Creature* caster = handler->getSelectedCreature();
|
||||
if (!caster)
|
||||
@@ -2395,7 +2299,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleFlushArenaPointsCommand(ChatHandler* /*handler*/, char const* /*args*/)
|
||||
static bool HandleFlushArenaPointsCommand(ChatHandler* /*handler*/)
|
||||
{
|
||||
sArenaTeamMgr->DistributeArenaPoints();
|
||||
return true;
|
||||
@@ -2519,15 +2423,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);
|
||||
}
|
||||
@@ -2549,7 +2452,7 @@ public:
|
||||
}
|
||||
else
|
||||
{
|
||||
if (targetName)
|
||||
if (targetNameArg)
|
||||
{
|
||||
// Check for offline players
|
||||
ObjectGuid guid = sCharacterCache->GetCharacterGuidByName(name);
|
||||
@@ -2577,7 +2480,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);
|
||||
@@ -2613,13 +2516,8 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandlePlayAllCommand(ChatHandler* handler, char const* args)
|
||||
static bool HandlePlayAllCommand(ChatHandler* handler, uint32 soundId)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
uint32 soundId = atoi((char*)args);
|
||||
|
||||
if (!sSoundEntriesStore.LookupEntry(soundId))
|
||||
{
|
||||
handler->PSendSysMessage(LANG_SOUND_NOT_EXIST, soundId);
|
||||
@@ -2633,7 +2531,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandlePossessCommand(ChatHandler* handler, char const* /*args*/)
|
||||
static bool HandlePossessCommand(ChatHandler* handler)
|
||||
{
|
||||
Unit* unit = handler->getSelectedUnit();
|
||||
if (!unit)
|
||||
@@ -2643,7 +2541,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleUnPossessCommand(ChatHandler* handler, char const* /*args*/)
|
||||
static bool HandleUnPossessCommand(ChatHandler* handler)
|
||||
{
|
||||
Unit* unit = handler->getSelectedUnit();
|
||||
if (!unit)
|
||||
@@ -2654,7 +2552,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleBindSightCommand(ChatHandler* handler, char const* /*args*/)
|
||||
static bool HandleBindSightCommand(ChatHandler* handler)
|
||||
{
|
||||
Unit* unit = handler->getSelectedUnit();
|
||||
if (!unit)
|
||||
@@ -2664,7 +2562,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleUnbindSightCommand(ChatHandler* handler, char const* /*args*/)
|
||||
static bool HandleUnbindSightCommand(ChatHandler* handler)
|
||||
{
|
||||
Player* player = handler->GetSession()->GetPlayer();
|
||||
|
||||
@@ -2675,7 +2573,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleMailBoxCommand(ChatHandler* handler, char const* /*args*/)
|
||||
static bool HandleMailBoxCommand(ChatHandler* handler)
|
||||
{
|
||||
Player* player = handler->GetSession()->GetPlayer();
|
||||
|
||||
|
||||
@@ -3133,6 +3133,7 @@ enum CorpseDynFlags
|
||||
|
||||
#define PLAYER_CORPSE_LOOT_ENTRY 1
|
||||
|
||||
// EnumUtils: DESCRIBE THIS
|
||||
enum WeatherType
|
||||
{
|
||||
WEATHER_TYPE_FINE = 0,
|
||||
|
||||
@@ -2063,6 +2063,57 @@ TC_API_EXPORT size_t EnumUtils<Emote>::ToIndex(Emote value)
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************\
|
||||
|* data for enum 'WeatherType' in 'SharedDefines.h' auto-generated *|
|
||||
\*******************************************************************/
|
||||
template <>
|
||||
TC_API_EXPORT EnumText EnumUtils<WeatherType>::ToString(WeatherType value)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case WEATHER_TYPE_FINE: return { "WEATHER_TYPE_FINE", "WEATHER_TYPE_FINE", "" };
|
||||
case WEATHER_TYPE_RAIN: return { "WEATHER_TYPE_RAIN", "WEATHER_TYPE_RAIN", "" };
|
||||
case WEATHER_TYPE_SNOW: return { "WEATHER_TYPE_SNOW", "WEATHER_TYPE_SNOW", "" };
|
||||
case WEATHER_TYPE_STORM: return { "WEATHER_TYPE_STORM", "WEATHER_TYPE_STORM", "" };
|
||||
case WEATHER_TYPE_THUNDERS: return { "WEATHER_TYPE_THUNDERS", "WEATHER_TYPE_THUNDERS", "" };
|
||||
case WEATHER_TYPE_BLACKRAIN: return { "WEATHER_TYPE_BLACKRAIN", "WEATHER_TYPE_BLACKRAIN", "" };
|
||||
default: throw std::out_of_range("value");
|
||||
}
|
||||
}
|
||||
|
||||
template <>
|
||||
TC_API_EXPORT size_t EnumUtils<WeatherType>::Count() { return 6; }
|
||||
|
||||
template <>
|
||||
TC_API_EXPORT WeatherType EnumUtils<WeatherType>::FromIndex(size_t index)
|
||||
{
|
||||
switch (index)
|
||||
{
|
||||
case 0: return WEATHER_TYPE_FINE;
|
||||
case 1: return WEATHER_TYPE_RAIN;
|
||||
case 2: return WEATHER_TYPE_SNOW;
|
||||
case 3: return WEATHER_TYPE_STORM;
|
||||
case 4: return WEATHER_TYPE_THUNDERS;
|
||||
case 5: return WEATHER_TYPE_BLACKRAIN;
|
||||
default: throw std::out_of_range("index");
|
||||
}
|
||||
}
|
||||
|
||||
template <>
|
||||
TC_API_EXPORT size_t EnumUtils<WeatherType>::ToIndex(WeatherType value)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case WEATHER_TYPE_FINE: return 0;
|
||||
case WEATHER_TYPE_RAIN: return 1;
|
||||
case WEATHER_TYPE_SNOW: return 2;
|
||||
case WEATHER_TYPE_STORM: return 3;
|
||||
case WEATHER_TYPE_THUNDERS: return 4;
|
||||
case WEATHER_TYPE_BLACKRAIN: return 5;
|
||||
default: throw std::out_of_range("value");
|
||||
}
|
||||
}
|
||||
|
||||
/************************************************************************\
|
||||
|* data for enum 'SpellFamilyNames' in 'SharedDefines.h' auto-generated *|
|
||||
\************************************************************************/
|
||||
|
||||
Reference in New Issue
Block a user