feat(Core/Command): Use timestring with all commands (#12050)

This commit is contained in:
Kempec Halk
2022-06-13 19:05:26 +02:00
committed by GitHub
parent d236dc9d07
commit 3c434cee12
6 changed files with 285 additions and 51 deletions

View File

@@ -117,8 +117,33 @@ public:
return true;
}
static bool HandleBattlefieldTimer(ChatHandler* handler, uint32 battleId, uint32 time)
static bool HandleBattlefieldTimer(ChatHandler* handler, uint32 battleId, std::string timeStr)
{
if (timeStr.empty())
{
return false;
}
if (Acore::StringTo<int32>(timeStr).value_or(0) < 0)
{
handler->SendSysMessage(LANG_BAD_VALUE);
handler->SetSentErrorMessage(true);
return false;
}
int32 time = TimeStringToSecs(timeStr);
if (time <= 0)
{
time = Acore::StringTo<int32>(timeStr).value_or(0);
}
if (time <= 0)
{
handler->SendSysMessage(LANG_BAD_VALUE);
handler->SetSentErrorMessage(true);
return false;
}
Battlefield* bf = sBattlefieldMgr->GetBattlefieldByBattleId(battleId);
if (!bf)