feat(Core/Mail): Server mail (#10628)

This commit is contained in:
Kitzunu
2022-04-19 23:43:14 +02:00
committed by GitHub
parent b801274b89
commit 7ecd738674
11 changed files with 238 additions and 0 deletions

View File

@@ -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();
}

View File

@@ -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();
}