mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-02-01 18:13:48 +00:00
fix(Scripts/Command): prevent crash on set motd (#18203)
* prevent crash on set motd * updated version * another version * Update cs_server.cpp --------- Co-authored-by: Kitzunu <24550914+Kitzunu@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,2 @@
|
|||||||
|
--
|
||||||
|
UPDATE `command` SET `help`='Syntax: .server set motd Optional($realmId) $MOTD\r\n\r\nSet server Message of the day for the specified $realmId.\r\nIf $realmId is not provided it will update for the current realm.' WHERE `name`='server set motd';
|
||||||
@@ -514,40 +514,32 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Define the 'Message of the day' for the realm
|
// Define the 'Message of the day' for the realm
|
||||||
static bool HandleServerSetMotdCommand(ChatHandler* handler, std::string realmId, Tail motd)
|
static bool HandleServerSetMotdCommand(ChatHandler* handler, Optional<int32> realmId, Tail motd)
|
||||||
{
|
{
|
||||||
std::wstring wMotd = std::wstring();
|
std::wstring wMotd = std::wstring();
|
||||||
std::string strMotd = std::string();
|
std::string strMotd = std::string();
|
||||||
|
|
||||||
if (realmId.empty())
|
if (!realmId)
|
||||||
{
|
realmId = static_cast<int32>(realm.Id.Realm);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (motd.empty())
|
if (motd.empty())
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
if (!Utf8toWStr(motd, wMotd))
|
if (!Utf8toWStr(motd, wMotd))
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
if (!WStrToUtf8(wMotd, strMotd))
|
if (!WStrToUtf8(wMotd, strMotd))
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
LoginDatabaseTransaction trans = LoginDatabase.BeginTransaction();
|
LoginDatabaseTransaction trans = LoginDatabase.BeginTransaction();
|
||||||
LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_REP_MOTD);
|
LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_REP_MOTD);
|
||||||
stmt->SetData(0, Acore::StringTo<int32>(realmId).value());
|
stmt->SetData(0, realmId.value());
|
||||||
stmt->SetData(1, strMotd);
|
stmt->SetData(1, strMotd);
|
||||||
trans->Append(stmt);
|
trans->Append(stmt);
|
||||||
LoginDatabase.CommitTransaction(trans);
|
LoginDatabase.CommitTransaction(trans);
|
||||||
|
|
||||||
sMotdMgr->LoadMotd();
|
sMotdMgr->LoadMotd();
|
||||||
handler->PSendSysMessage(LANG_MOTD_NEW, Acore::StringTo<int32>(realmId).value(), strMotd);
|
handler->PSendSysMessage(LANG_MOTD_NEW, realmId.value(), strMotd);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user