diff --git a/data/sql/updates/pending_db_world/rev_1654372051309044400.sql b/data/sql/updates/pending_db_world/rev_1654372051309044400.sql new file mode 100644 index 000000000..e19b8912d --- /dev/null +++ b/data/sql/updates/pending_db_world/rev_1654372051309044400.sql @@ -0,0 +1,18 @@ +-- +DELETE FROM `acore_string` WHERE `entry` IN (283,298,300,301,11003); +INSERT INTO `acore_string` (`entry`, `content_default`, `locale_koKR`, `locale_frFR`, `locale_deDE`, `locale_zhCN`, `locale_zhTW`, `locale_esES`, `locale_esMX`, `locale_ruRU`) VALUES +(283, "%s has disabled %s's chat for %s, effective at the player's next login. Reason: %s.", NULL, NULL, "Ihr habt dem Spieler %s das chatten für %s gesperrt, beginnend mit dem nächsten Login des Spielers. Grund: %s.", "你已经被 %s 禁言 %s,将在下一次登陆时生效。原因: %s。", NULL, "%s ha deshabilitado el chat de %s por %s, efectivo en el próximo ingreso del jugador. Razón: %s.", "%s ha deshabilitado el chat de %s por %s, efectivo en el próximo ingreso del jugador. Razón: %s.", NULL), +(298, "Spawn time changed to: %s", NULL, NULL, "Spawnzeit wurde auf: %s abgeändert", "复生时间改变为: %s", NULL, "Tiempo de desove cambiado a: %s", "Tiempo de desove cambiado a: %s", NULL), +(300, "Your chat has been disabled for %s. By: %s, Reason: %s.", NULL, NULL, "Euer Chat wurde für %s abgeschaltet. Von: %s, Grund: %s", "你将被禁言 %s.", NULL, "Tu chat ha sido desactivado durante %u. Por: %s ,Razón: %s.", "Tu chat ha sido desactivado durante %u. Por: %s ,Razón: %s.", NULL), +(301, "%s has disabled %s's chat for %s. Reason: %s.", NULL, NULL, "Ihr hab den Chat von %s für %s abgeschaltet. Von: %s, Grund: %s", NULL, NULL, "%s ha desactivado el chat de %s durante %s. Razón: %s.", "%s ha desactivado el chat de %s durante %s. Razón: %s.", NULL), +(11003, "Server: %s has muted %s for %s, reason: %s", NULL, NULL, NULL, "系统公告: %s has muted %s for %s, 原因: %s", NULL, NULL, NULL, "Server: %s замутил %s на %s, причина: %s"); + +UPDATE `command` SET `help` = "Syntax: .mute [$playerName] $mutetime [$reason]\r\nDisible chat messaging for any character from account of character $playerName (or currently selected) at $mutetime time. Player can be offline.\n$mutetime: use a timestring like \"1d15h33s\"." WHERE `name` = "mute"; +UPDATE `command` SET `help` = "Syntax: .npc set spawntime #time\r\nAdjust spawntime of selected creature to #time.\n#time: use a timestring like \"10m30s\"." WHERE `name` = "npc set spawntime"; +UPDATE `command` SET `help` = "Syntax: .server idlerestart #delay\r\nRestart the server after #delay if no active connections are present (no players). Use #exist_code or 2 as program exist code.\n#delay: use a timestring like \"1h15m30s\"." WHERE `name` = "server idlerestart"; +UPDATE `command` SET `help` = "Syntax: .server idleshutdown #delay [#exist_code]\r\nShut the server down after #delay if no active connections are present (no players). Use #exist_code or 0 as program exist code.\n#delay: use a timestring like \"1h15m30s\"." WHERE `name` = "server idleshutdown"; +UPDATE `command` SET `help` = "Syntax: .server restart #delay\r\nRestart the server after #delay. Use #exist_code or 2 as program exist code.\n#delay: use a timestring like \"1h15m30s\"." WHERE `name` = "server restart"; +UPDATE `command` SET `help` = "Syntax: .server shutdown #delay [#exit_code]\r\nShut the server down after #delay. Use #exit_code or 0 as program exit code.\n#delay: use a timestring like \"1h15m30s\"." WHERE `name` = "server shutdown"; +UPDATE `command` SET `help` = "Syntax: .bf timer #battleid #timer\n#timer: use a timestring like \"1h15m30s\"." WHERE `name` = "bf timer"; +UPDATE `command` SET `help` = "Syntax: .deserter bg add $playerName <$time>\r\nAdds the bg deserter debuff to a player or your target with $time.\nOptional $time: use a timestring like \"1h15m30s\".Default: 15m" WHERE `name` = "deserter bg add"; +UPDATE `command` SET `help` = "Syntax: .deserter instance add $playerName <$time>\r\nAdds the instance deserter debuff to a player or your target with $time.\nOptional $time: use a timestring like \"1h15m30s\". Default: 30m" WHERE `name` = "deserter instance add"; \ No newline at end of file diff --git a/src/server/scripts/Commands/cs_bf.cpp b/src/server/scripts/Commands/cs_bf.cpp index 06bf77871..2610a2c62 100644 --- a/src/server/scripts/Commands/cs_bf.cpp +++ b/src/server/scripts/Commands/cs_bf.cpp @@ -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(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(timeStr).value_or(0); + } + + if (time <= 0) + { + handler->SendSysMessage(LANG_BAD_VALUE); + handler->SetSentErrorMessage(true); + return false; + } + Battlefield* bf = sBattlefieldMgr->GetBattlefieldByBattleId(battleId); if (!bf) diff --git a/src/server/scripts/Commands/cs_deserter.cpp b/src/server/scripts/Commands/cs_deserter.cpp index 648464186..17761aaf6 100644 --- a/src/server/scripts/Commands/cs_deserter.cpp +++ b/src/server/scripts/Commands/cs_deserter.cpp @@ -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 player, uint32 time, bool isInstance) + static bool HandleDeserterAdd(ChatHandler* handler, Optional playerName, Optional 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(*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(); + remainTime = fields[0].Get(); - 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 player, uint32 time) + static bool HandleDeserterInstanceAdd(ChatHandler* handler, Optional playerName, Optional time) { - return HandleDeserterAdd(handler, player, time, true); + return HandleDeserterAdd(handler, playerName, time, true); } /// @sa HandleDeserterAdd() - static bool HandleDeserterBGAdd(ChatHandler* handler, Optional player, uint32 time) + static bool HandleDeserterBGAdd(ChatHandler* handler, Optional playerName, Optional time) { - return HandleDeserterAdd(handler, player, time, false); + return HandleDeserterAdd(handler, playerName, time, false); } /// @sa HandleDeserterRemove() diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp index d6b9bbd8e..33ed6b6d1 100644 --- a/src/server/scripts/Commands/cs_misc.cpp +++ b/src/server/scripts/Commands/cs_misc.cpp @@ -2374,10 +2374,22 @@ public: } // mute player for some times - static bool HandleMuteCommand(ChatHandler* handler, Optional player, uint32 notSpeakTime, Tail muteReason) + static bool HandleMuteCommand(ChatHandler* handler, Optional player, std::string notSpeakTime, Tail muteReason) { std::string muteReasonStr{ muteReason }; + if (notSpeakTime.empty()) + { + return false; + } + + if (Acore::StringTo(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(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::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; diff --git a/src/server/scripts/Commands/cs_npc.cpp b/src/server/scripts/Commands/cs_npc.cpp index 2490c1d40..d722a5478 100644 --- a/src/server/scripts/Commands/cs_npc.cpp +++ b/src/server/scripts/Commands/cs_npc.cpp @@ -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(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(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; } diff --git a/src/server/scripts/Commands/cs_server.cpp b/src/server/scripts/Commands/cs_server.cpp index 2e0c47200..2e60148a2 100644 --- a/src/server/scripts/Commands/cs_server.cpp +++ b/src/server/scripts/Commands/cs_server.cpp @@ -269,11 +269,23 @@ public: return true; } - static bool HandleServerShutDownCommand(ChatHandler* /*handler*/, int32 time, Optional exitCode, Tail reason) + static bool HandleServerShutDownCommand(ChatHandler* handler, std::string time, Optional exitCode, Tail reason) { std::wstring wReason = std::wstring(); std::string strReason = std::string(); + if (time.empty()) + { + return false; + } + + if (Acore::StringTo(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(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 exitCode, Tail reason) + static bool HandleServerRestartCommand(ChatHandler* handler, std::string time, Optional exitCode, Tail reason) { std::wstring wReason = std::wstring(); std::string strReason = std::string(); + if (time.empty()) + { + return false; + } + + if (Acore::StringTo(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(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 exitCode, Tail reason) + static bool HandleServerIdleRestartCommand(ChatHandler* handler, std::string time, Optional exitCode, Tail reason) { std::wstring wReason = std::wstring(); std::string strReason = std::string(); + if (time.empty()) + { + return false; + } + + if (Acore::StringTo(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(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 exitCode, Tail reason) + static bool HandleServerIdleShutDownCommand(ChatHandler* handler, std::string time, Optional exitCode, Tail reason) { std::wstring wReason = std::wstring(); std::string strReason = std::string(); + if (time.empty()) + { + return false; + } + + if (Acore::StringTo(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(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;