mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-18 03:15:41 +00:00
feat(Core/Command): Use timestring with all commands (#12050)
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -79,7 +79,8 @@ public:
|
||||
* selected player, with the provided duration in seconds.
|
||||
*
|
||||
* @param handler The ChatHandler, passed by the system.
|
||||
* @param time The provided duration in seconds.
|
||||
* @param playerName Player by name. Optional, defaults to selected or self.
|
||||
* @param time The provided duration as TimeString. Optional, defaults to bg/instance default time.
|
||||
* @param isInstance provided by the relaying functions, so we don't have
|
||||
* to write that much code :)
|
||||
*
|
||||
@@ -87,40 +88,80 @@ public:
|
||||
*
|
||||
* Example Usage:
|
||||
* @code
|
||||
* .deserter instance add 3600 (one hour)
|
||||
* .deserter instance add 1h30m
|
||||
* -or-
|
||||
* .deserter bg add 3600 (one hour)
|
||||
* .deserter bg add 1h30m
|
||||
* @endcode
|
||||
*/
|
||||
static bool HandleDeserterAdd(ChatHandler* handler, Optional<PlayerIdentifier> player, uint32 time, bool isInstance)
|
||||
static bool HandleDeserterAdd(ChatHandler* handler, Optional<std::string> playerName, Optional<std::string> time, bool isInstance)
|
||||
{
|
||||
if (!player)
|
||||
Player* target = handler->getSelectedPlayerOrSelf();
|
||||
ObjectGuid guid;
|
||||
|
||||
if (playerName)
|
||||
{
|
||||
player = PlayerIdentifier::FromTargetOrSelf(handler);
|
||||
if (!normalizePlayerName(*playerName))
|
||||
{
|
||||
handler->SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
guid = sCharacterCache->GetCharacterGuidByName(*playerName);
|
||||
if (guid)
|
||||
{
|
||||
target = ObjectAccessor::FindPlayerByName(*playerName);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (time)
|
||||
{
|
||||
handler->SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
time = playerName;
|
||||
playerName = "";
|
||||
}
|
||||
}
|
||||
|
||||
if (!player)
|
||||
if (!playerName || playerName->empty())
|
||||
{
|
||||
handler->SendSysMessage(LANG_NO_CHAR_SELECTED);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
if (!handler->GetSession())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
playerName = target->GetName();
|
||||
guid = target->GetGUID();
|
||||
}
|
||||
|
||||
if (!time)
|
||||
{
|
||||
time = isInstance ? "30m" : "15m";
|
||||
}
|
||||
|
||||
int32 duration = TimeStringToSecs(*time);
|
||||
|
||||
if (duration == 0)
|
||||
{
|
||||
duration = Acore::StringTo<int32>(*time).value_or(0);
|
||||
}
|
||||
|
||||
if (duration == 0)
|
||||
{
|
||||
handler->SendSysMessage(LANG_BAD_VALUE);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
Player* target = player->GetConnectedPlayer();
|
||||
|
||||
if (target)
|
||||
{
|
||||
Aura* aura = target->GetAura(isInstance ? LFG_SPELL_DUNGEON_DESERTER : BG_SPELL_DESERTER);
|
||||
if (aura && aura->GetDuration() >= (int32)time * IN_MILLISECONDS)
|
||||
if (aura && aura->GetDuration() >= duration * IN_MILLISECONDS)
|
||||
{
|
||||
handler->PSendSysMessage("Player %s already has a longer %s Deserter active.", handler->playerLink(player->GetName()), isInstance ? "Instance" : "Battleground");
|
||||
handler->PSendSysMessage("Player %s already has a longer %s Deserter active.", handler->playerLink(*playerName), isInstance ? "Instance" : "Battleground");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -131,29 +172,29 @@ public:
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
aura->SetDuration(time * IN_MILLISECONDS);
|
||||
aura->SetDuration(duration * IN_MILLISECONDS);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int32 duration = 0;
|
||||
if (QueryResult result = CharacterDatabase.Query("SELECT remainTime FROM character_aura WHERE guid = {} AND spell = {}", player->GetGUID().GetCounter(), isInstance ? LFG_SPELL_DUNGEON_DESERTER : BG_SPELL_DESERTER))
|
||||
int32 remainTime = 0;
|
||||
if (QueryResult result = CharacterDatabase.Query("SELECT remainTime FROM character_aura WHERE guid = {} AND spell = {}", guid.GetCounter(), isInstance ? LFG_SPELL_DUNGEON_DESERTER : BG_SPELL_DESERTER))
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
duration = fields[0].Get<int32>();
|
||||
remainTime = fields[0].Get<int32>();
|
||||
|
||||
if (duration < 0 || duration >= (int32)time * IN_MILLISECONDS)
|
||||
if (remainTime < 0 || remainTime >= duration * IN_MILLISECONDS)
|
||||
{
|
||||
handler->PSendSysMessage("Player %s already has a longer %s Deserter active.", handler->playerLink(player->GetName()), isInstance ? "Instance" : "Battleground");
|
||||
handler->PSendSysMessage("Player %s already has a longer %s Deserter active.", handler->playerLink(*playerName), isInstance ? "Instance" : "Battleground");
|
||||
return true;
|
||||
}
|
||||
CharacterDatabase.Query("DELETE FROM character_aura WHERE guid = {} AND spell = {}", player->GetGUID().GetCounter(), isInstance ? LFG_SPELL_DUNGEON_DESERTER : BG_SPELL_DESERTER);
|
||||
CharacterDatabase.Query("DELETE FROM character_aura WHERE guid = {} AND spell = {}", guid.GetCounter(), isInstance ? LFG_SPELL_DUNGEON_DESERTER : BG_SPELL_DESERTER);
|
||||
}
|
||||
|
||||
uint8 index = 0;
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_AURA);
|
||||
stmt->SetData(index++, player->GetGUID().GetCounter());
|
||||
stmt->SetData(index++, player->GetGUID().GetCounter());
|
||||
stmt->SetData(index++, guid.GetCounter());
|
||||
stmt->SetData(index++, guid.GetCounter());
|
||||
stmt->SetData(index++, 0);
|
||||
stmt->SetData(index++, isInstance ? LFG_SPELL_DUNGEON_DESERTER : BG_SPELL_DESERTER);
|
||||
stmt->SetData(index++, 1);
|
||||
@@ -166,7 +207,7 @@ public:
|
||||
stmt->SetData(index++, 0);
|
||||
stmt->SetData(index++, 0);
|
||||
stmt->SetData(index++, isInstance ? 1800000 : 900000);
|
||||
stmt->SetData(index++, time * 1000);
|
||||
stmt->SetData(index++, duration * 1000);
|
||||
stmt->SetData(index, 0);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
@@ -240,15 +281,15 @@ public:
|
||||
}
|
||||
|
||||
/// @sa HandleDeserterAdd()
|
||||
static bool HandleDeserterInstanceAdd(ChatHandler* handler, Optional<PlayerIdentifier> player, uint32 time)
|
||||
static bool HandleDeserterInstanceAdd(ChatHandler* handler, Optional<std::string> playerName, Optional<std::string> time)
|
||||
{
|
||||
return HandleDeserterAdd(handler, player, time, true);
|
||||
return HandleDeserterAdd(handler, playerName, time, true);
|
||||
}
|
||||
|
||||
/// @sa HandleDeserterAdd()
|
||||
static bool HandleDeserterBGAdd(ChatHandler* handler, Optional<PlayerIdentifier> player, uint32 time)
|
||||
static bool HandleDeserterBGAdd(ChatHandler* handler, Optional<std::string> playerName, Optional<std::string> time)
|
||||
{
|
||||
return HandleDeserterAdd(handler, player, time, false);
|
||||
return HandleDeserterAdd(handler, playerName, time, false);
|
||||
}
|
||||
|
||||
/// @sa HandleDeserterRemove()
|
||||
|
||||
@@ -2374,10 +2374,22 @@ public:
|
||||
}
|
||||
|
||||
// mute player for some times
|
||||
static bool HandleMuteCommand(ChatHandler* handler, Optional<PlayerIdentifier> player, uint32 notSpeakTime, Tail muteReason)
|
||||
static bool HandleMuteCommand(ChatHandler* handler, Optional<PlayerIdentifier> player, std::string notSpeakTime, Tail muteReason)
|
||||
{
|
||||
std::string muteReasonStr{ muteReason };
|
||||
|
||||
if (notSpeakTime.empty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Acore::StringTo<int32>(notSpeakTime).value_or(0) < 0)
|
||||
{
|
||||
handler->SendSysMessage(LANG_BAD_VALUE);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (muteReason.empty())
|
||||
{
|
||||
muteReasonStr = handler->GetAcoreString(LANG_NO_REASON);
|
||||
@@ -2412,6 +2424,19 @@ public:
|
||||
}
|
||||
|
||||
LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_MUTE_TIME);
|
||||
int32 muteDuration = TimeStringToSecs(notSpeakTime);
|
||||
if (muteDuration <= 0)
|
||||
{
|
||||
muteDuration = Acore::StringTo<int32>(notSpeakTime).value_or(0);
|
||||
}
|
||||
|
||||
if (muteDuration <= 0)
|
||||
{
|
||||
handler->SendSysMessage(LANG_BAD_VALUE);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string muteBy = "";
|
||||
if (handler->GetSession())
|
||||
{
|
||||
@@ -2425,22 +2450,22 @@ public:
|
||||
if (target)
|
||||
{
|
||||
// Target is online, mute will be in effect right away.
|
||||
int64 muteTime = GameTime::GetGameTime().count() + notSpeakTime * MINUTE;
|
||||
int64 muteTime = GameTime::GetGameTime().count() + muteDuration;
|
||||
target->GetSession()->m_muteTime = muteTime;
|
||||
stmt->SetData(0, muteTime);
|
||||
std::string nameLink = handler->playerLink(player->GetName());
|
||||
|
||||
if (sWorld->getBoolConfig(CONFIG_SHOW_MUTE_IN_WORLD))
|
||||
{
|
||||
sWorld->SendWorldText(LANG_COMMAND_MUTEMESSAGE_WORLD, muteBy.c_str(), nameLink.c_str(), notSpeakTime, muteReasonStr.c_str());
|
||||
sWorld->SendWorldText(LANG_COMMAND_MUTEMESSAGE_WORLD, muteBy.c_str(), nameLink.c_str(), secsToTimeString(muteDuration, true).c_str(), muteReasonStr.c_str());
|
||||
}
|
||||
|
||||
ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOUR_CHAT_DISABLED, notSpeakTime, muteBy.c_str(), muteReasonStr.c_str());
|
||||
ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOUR_CHAT_DISABLED, secsToTimeString(muteDuration, true).c_str(), muteBy.c_str(), muteReasonStr.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
// Target is offline, mute will be in effect starting from the next login.
|
||||
stmt->SetData(0, -int32(notSpeakTime * MINUTE));
|
||||
stmt->SetData(0, -int32(muteDuration));
|
||||
}
|
||||
|
||||
stmt->SetData(1, muteReasonStr);
|
||||
@@ -2450,7 +2475,7 @@ public:
|
||||
|
||||
stmt = LoginDatabase.GetPreparedStatement(LOGIN_INS_ACCOUNT_MUTE);
|
||||
stmt->SetData(0, accountId);
|
||||
stmt->SetData(1, notSpeakTime);
|
||||
stmt->SetData(1, muteDuration / MINUTE);
|
||||
stmt->SetData(2, muteBy);
|
||||
stmt->SetData(3, muteReasonStr);
|
||||
LoginDatabase.Execute(stmt);
|
||||
@@ -2459,7 +2484,7 @@ public:
|
||||
|
||||
if (sWorld->getBoolConfig(CONFIG_SHOW_MUTE_IN_WORLD) && !target)
|
||||
{
|
||||
sWorld->SendWorldText(LANG_COMMAND_MUTEMESSAGE_WORLD, muteBy.c_str(), nameLink.c_str(), notSpeakTime, muteReasonStr.c_str());
|
||||
sWorld->SendWorldText(LANG_COMMAND_MUTEMESSAGE_WORLD, muteBy.c_str(), nameLink.c_str(), secsToTimeString(muteDuration, true).c_str(), muteReasonStr.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2469,7 +2494,7 @@ public:
|
||||
for (HashMapHolder<Player>::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr)
|
||||
if (itr->second->GetSession()->GetSecurity())
|
||||
ChatHandler(itr->second->GetSession()).PSendSysMessage(target ? LANG_YOU_DISABLE_CHAT : LANG_COMMAND_DISABLE_CHAT_DELAYED,
|
||||
(handler->GetSession() ? handler->GetSession()->GetPlayerName().c_str() : handler->GetAcoreString(LANG_CONSOLE)), nameLink.c_str(), notSpeakTime, muteReasonStr.c_str());
|
||||
(handler->GetSession() ? handler->GetSession()->GetPlayerName().c_str() : handler->GetAcoreString(LANG_CONSOLE)), nameLink.c_str(), secsToTimeString(muteDuration, true).c_str(), muteReasonStr.c_str());
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -987,19 +987,44 @@ public:
|
||||
}
|
||||
|
||||
//spawn time handling
|
||||
static bool HandleNpcSetSpawnTimeCommand(ChatHandler* handler, uint32 spawnTime)
|
||||
static bool HandleNpcSetSpawnTimeCommand(ChatHandler* handler, std::string spawnTimeStr)
|
||||
{
|
||||
if (spawnTimeStr.empty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Acore::StringTo<int32>(spawnTimeStr).value_or(0) < 0)
|
||||
{
|
||||
handler->SendSysMessage(LANG_BAD_VALUE);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
Creature* creature = handler->getSelectedCreature();
|
||||
if (!creature)
|
||||
return false;
|
||||
|
||||
int32 spawnTime = TimeStringToSecs(spawnTimeStr);
|
||||
if (spawnTime <= 0)
|
||||
{
|
||||
spawnTime = Acore::StringTo<int32>(spawnTimeStr).value_or(0);
|
||||
}
|
||||
|
||||
if (spawnTime <= 0)
|
||||
{
|
||||
handler->SendSysMessage(LANG_BAD_VALUE);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_CREATURE_SPAWN_TIME_SECS);
|
||||
stmt->SetData(0, spawnTime);
|
||||
stmt->SetData(1, creature->GetSpawnId());
|
||||
WorldDatabase.Execute(stmt);
|
||||
|
||||
creature->SetRespawnDelay(spawnTime);
|
||||
handler->PSendSysMessage(LANG_COMMAND_SPAWNTIME, spawnTime);
|
||||
handler->PSendSysMessage(LANG_COMMAND_SPAWNTIME, secsToTimeString(spawnTime, true).c_str());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -269,11 +269,23 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleServerShutDownCommand(ChatHandler* /*handler*/, int32 time, Optional<int32> exitCode, Tail reason)
|
||||
static bool HandleServerShutDownCommand(ChatHandler* handler, std::string time, Optional<int32> exitCode, Tail reason)
|
||||
{
|
||||
std::wstring wReason = std::wstring();
|
||||
std::string strReason = std::string();
|
||||
|
||||
if (time.empty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Acore::StringTo<int32>(time).value_or(0) < 0)
|
||||
{
|
||||
handler->SendSysMessage(LANG_BAD_VALUE);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!reason.empty())
|
||||
{
|
||||
if (!Utf8toWStr(reason, wReason))
|
||||
@@ -287,23 +299,48 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
int32 delay = TimeStringToSecs(time);
|
||||
if (delay <= 0)
|
||||
{
|
||||
delay = Acore::StringTo<int32>(time).value_or(0);
|
||||
}
|
||||
|
||||
if (delay <= 0)
|
||||
{
|
||||
handler->SendSysMessage(LANG_BAD_VALUE);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (exitCode && *exitCode >= 0 && *exitCode <= 125)
|
||||
{
|
||||
sWorld->ShutdownServ(time, 0, *exitCode);
|
||||
sWorld->ShutdownServ(delay, 0, *exitCode);
|
||||
}
|
||||
else
|
||||
{
|
||||
sWorld->ShutdownServ(time, 0, SHUTDOWN_EXIT_CODE, strReason);
|
||||
sWorld->ShutdownServ(delay, 0, SHUTDOWN_EXIT_CODE, strReason);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleServerRestartCommand(ChatHandler* /*handler*/, int32 time, Optional<int32> exitCode, Tail reason)
|
||||
static bool HandleServerRestartCommand(ChatHandler* handler, std::string time, Optional<int32> exitCode, Tail reason)
|
||||
{
|
||||
std::wstring wReason = std::wstring();
|
||||
std::string strReason = std::string();
|
||||
|
||||
if (time.empty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Acore::StringTo<int32>(time).value_or(0) < 0)
|
||||
{
|
||||
handler->SendSysMessage(LANG_BAD_VALUE);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!reason.empty())
|
||||
{
|
||||
if (!Utf8toWStr(reason, wReason))
|
||||
@@ -317,23 +354,48 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
int32 delay = TimeStringToSecs(time);
|
||||
if (delay <= 0)
|
||||
{
|
||||
delay = Acore::StringTo<int32>(time).value_or(0);
|
||||
}
|
||||
|
||||
if (delay <= 0)
|
||||
{
|
||||
handler->SendSysMessage(LANG_BAD_VALUE);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (exitCode && *exitCode >= 0 && *exitCode <= 125)
|
||||
{
|
||||
sWorld->ShutdownServ(time, SHUTDOWN_MASK_RESTART, *exitCode);
|
||||
sWorld->ShutdownServ(delay, SHUTDOWN_MASK_RESTART, *exitCode);
|
||||
}
|
||||
else
|
||||
{
|
||||
sWorld->ShutdownServ(time, SHUTDOWN_MASK_RESTART, RESTART_EXIT_CODE, strReason);
|
||||
sWorld->ShutdownServ(delay, SHUTDOWN_MASK_RESTART, RESTART_EXIT_CODE, strReason);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleServerIdleRestartCommand(ChatHandler* /*handler*/, int32 time, Optional<int32> exitCode, Tail reason)
|
||||
static bool HandleServerIdleRestartCommand(ChatHandler* handler, std::string time, Optional<int32> exitCode, Tail reason)
|
||||
{
|
||||
std::wstring wReason = std::wstring();
|
||||
std::string strReason = std::string();
|
||||
|
||||
if (time.empty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Acore::StringTo<int32>(time).value_or(0) < 0)
|
||||
{
|
||||
handler->SendSysMessage(LANG_BAD_VALUE);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!reason.empty())
|
||||
{
|
||||
if (!Utf8toWStr(reason, wReason))
|
||||
@@ -347,23 +409,48 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
int32 delay = TimeStringToSecs(time);
|
||||
if (delay <= 0)
|
||||
{
|
||||
delay = Acore::StringTo<int32>(time).value_or(0);
|
||||
}
|
||||
|
||||
if (delay <= 0)
|
||||
{
|
||||
handler->SendSysMessage(LANG_BAD_VALUE);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (exitCode && *exitCode >= 0 && *exitCode <= 125)
|
||||
{
|
||||
sWorld->ShutdownServ(time, SHUTDOWN_MASK_RESTART | SHUTDOWN_MASK_IDLE, *exitCode);
|
||||
sWorld->ShutdownServ(delay, SHUTDOWN_MASK_RESTART | SHUTDOWN_MASK_IDLE, *exitCode);
|
||||
}
|
||||
else
|
||||
{
|
||||
sWorld->ShutdownServ(time, SHUTDOWN_MASK_RESTART | SHUTDOWN_MASK_IDLE, RESTART_EXIT_CODE, strReason);
|
||||
sWorld->ShutdownServ(delay, SHUTDOWN_MASK_RESTART | SHUTDOWN_MASK_IDLE, RESTART_EXIT_CODE, strReason);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleServerIdleShutDownCommand(ChatHandler* /*handler*/, int32 time, Optional<int32> exitCode, Tail reason)
|
||||
static bool HandleServerIdleShutDownCommand(ChatHandler* handler, std::string time, Optional<int32> exitCode, Tail reason)
|
||||
{
|
||||
std::wstring wReason = std::wstring();
|
||||
std::string strReason = std::string();
|
||||
|
||||
if (time.empty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Acore::StringTo<int32>(time).value_or(0) < 0)
|
||||
{
|
||||
handler->SendSysMessage(LANG_BAD_VALUE);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!reason.empty())
|
||||
{
|
||||
if (!Utf8toWStr(reason, wReason))
|
||||
@@ -377,13 +464,26 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
int32 delay = TimeStringToSecs(time);
|
||||
if (delay <= 0)
|
||||
{
|
||||
delay = Acore::StringTo<int32>(time).value_or(0);
|
||||
}
|
||||
|
||||
if (delay <= 0)
|
||||
{
|
||||
handler->SendSysMessage(LANG_BAD_VALUE);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (exitCode && *exitCode >= 0 && *exitCode <= 125)
|
||||
{
|
||||
sWorld->ShutdownServ(time, SHUTDOWN_MASK_IDLE, *exitCode);
|
||||
sWorld->ShutdownServ(delay, SHUTDOWN_MASK_IDLE, *exitCode);
|
||||
}
|
||||
else
|
||||
{
|
||||
sWorld->ShutdownServ(time, SHUTDOWN_MASK_IDLE, SHUTDOWN_EXIT_CODE, strReason);
|
||||
sWorld->ShutdownServ(delay, SHUTDOWN_MASK_IDLE, SHUTDOWN_EXIT_CODE, strReason);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user