summaryrefslogtreecommitdiff
path: root/src/server/scripts
diff options
context:
space:
mode:
authorKitzunu <24550914+Kitzunu@users.noreply.github.com>2022-04-19 23:43:14 +0200
committerGitHub <noreply@github.com>2022-04-19 23:43:14 +0200
commit7ecd73867419c807c9869ebeb73c7ca4e39cd1c8 (patch)
tree50f14d73d21c01316fb2cf33e83f4e4e2f6deada /src/server/scripts
parentb801274b895bbafc222f18a38d946dbf2b307b58 (diff)
feat(Core/Mail): Server mail (#10628)
Diffstat (limited to 'src/server/scripts')
-rw-r--r--src/server/scripts/Commands/cs_reload.cpp10
-rw-r--r--src/server/scripts/World/server_mail.cpp52
-rw-r--r--src/server/scripts/World/world_script_loader.cpp2
3 files changed, 64 insertions, 0 deletions
diff --git a/src/server/scripts/Commands/cs_reload.cpp b/src/server/scripts/Commands/cs_reload.cpp
index a705a82e22..6f3b9ca740 100644
--- a/src/server/scripts/Commands/cs_reload.cpp
+++ b/src/server/scripts/Commands/cs_reload.cpp
@@ -125,6 +125,7 @@ public:
{ "quest_request_item_locale", HandleReloadLocalesQuestRequestItemsCommand, SEC_ADMINISTRATOR, Console::Yes },
{ "mail_level_reward", HandleReloadMailLevelRewardCommand, SEC_ADMINISTRATOR, Console::Yes },
{ "mail_loot_template", HandleReloadLootTemplatesMailCommand, SEC_ADMINISTRATOR, Console::Yes },
+ { "mail_server_template", HandleReloadMailServerTemplateCommand, SEC_ADMINISTRATOR, Console::Yes },
{ "milling_loot_template", HandleReloadLootTemplatesMillingCommand, SEC_ADMINISTRATOR, Console::Yes },
{ "npc_spellclick_spells", HandleReloadSpellClickSpellsCommand, SEC_ADMINISTRATOR, Console::Yes },
{ "npc_trainer", HandleReloadNpcTrainerCommand, SEC_ADMINISTRATOR, Console::Yes },
@@ -197,6 +198,7 @@ public:
HandleReloadDungeonAccessCommand(handler);
HandleReloadMailLevelRewardCommand(handler);
+ HandleReloadMailServerTemplateCommand(handler);
HandleReloadCommandCommand(handler);
HandleReloadReservedNameCommand(handler);
HandleReloadAcoreStringCommand(handler);
@@ -1148,6 +1150,14 @@ public:
return true;
}
+ static bool HandleReloadMailServerTemplateCommand(ChatHandler* handler)
+ {
+ LOG_INFO("server.loading", "Re-Loading `server_mail_template` table");
+ sObjectMgr->LoadMailServerTemplates();
+ handler->SendGlobalGMSysMessage("DB table `server_mail_template` reloaded.");
+ return true;
+ }
+
static bool HandleReloadAuctionsCommand(ChatHandler* handler)
{
///- Reload dynamic data tables from the database
diff --git a/src/server/scripts/World/server_mail.cpp b/src/server/scripts/World/server_mail.cpp
new file mode 100644
index 0000000000..5776753d63
--- /dev/null
+++ b/src/server/scripts/World/server_mail.cpp
@@ -0,0 +1,52 @@
+/*
+ * This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Affero General Public License as published by the
+ * Free Software Foundation; either version 3 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "Player.h"
+#include "ScriptMgr.h"
+#include "Mail.h"
+#include "ObjectMgr.h"
+#include "QueryResult.h"
+
+class ServerMailReward : public PlayerScript
+{
+public:
+ ServerMailReward() : PlayerScript("ServerMailReward") { }
+
+ // CHARACTER_LOGIN = 8
+ void OnLogin(Player* player) override
+ {
+ for (auto const& servMail : sObjectMgr->GetAllServerMailStore())
+ {
+ CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_MAIL_SERVER_CHARACTER);
+ stmt->SetData(0, player->GetGUID().GetCounter());
+ stmt->SetData(1, servMail.second.id);
+
+ WorldSession* mySess = player->GetSession();
+ mySess->GetQueryProcessor().AddCallback(CharacterDatabase.AsyncQuery(stmt)
+ .WithPreparedCallback([mySess, servMail](PreparedQueryResult result)
+ {
+ if (!result)
+ sObjectMgr->SendServerMail(mySess->GetPlayer(), servMail.second.id, servMail.second.reqLevel, servMail.second.reqPlayTime, servMail.second.moneyA, servMail.second.moneyH, servMail.second.itemA, servMail.second.itemCountA, servMail.second.itemH, servMail.second.itemCountH, servMail.second.subject, servMail.second.body, servMail.second.active);
+ }));
+ }
+ }
+};
+
+void AddSC_server_mail()
+{
+ new ServerMailReward();
+}
diff --git a/src/server/scripts/World/world_script_loader.cpp b/src/server/scripts/World/world_script_loader.cpp
index e5006a218d..cda3d4ba41 100644
--- a/src/server/scripts/World/world_script_loader.cpp
+++ b/src/server/scripts/World/world_script_loader.cpp
@@ -31,6 +31,7 @@ void AddSC_chat_log(); // location: scripts\World\chat_log.cpp
void AddSC_action_ip_logger(); // location: scripts\World\action_ip_logger.cpp
void AddSC_player_scripts();
void AddSC_npc_stave_of_ancients();
+void AddSC_server_mail();
// The name of this function should match:
// void Add${NameOfDirectory}Scripts()
@@ -51,4 +52,5 @@ void AddWorldScripts()
AddSC_action_ip_logger(); // location: scripts\World\action_ip_logger.cpp
AddSC_player_scripts();
AddSC_npc_stave_of_ancients();
+ AddSC_server_mail();
}