-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat (core\db): Server Mail Reward System (#162)
- Loading branch information
1 parent
22fd8b8
commit 6303bcc
Showing
10 changed files
with
247 additions
and
2 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
data/sql/updates/pending_db_characters/rev_1693343760497114600.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
DROP TABLE IF EXISTS `mail_server_character`; | ||
CREATE TABLE IF NOT EXISTS `mail_server_character` ( | ||
`guid` INT UNSIGNED NOT NULL, | ||
`mailId` INT UNSIGNED NOT NULL, | ||
PRIMARY KEY (`guid`, `mailId`) | ||
) ENGINE=INNODB DEFAULT CHARSET=UTF8MB4; | ||
|
||
DROP TABLE IF EXISTS `mail_server_template`; | ||
CREATE TABLE IF NOT EXISTS `mail_server_template` ( | ||
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT, | ||
`reqLevel` TINYINT UNSIGNED NOT NULL DEFAULT '0', | ||
`reqPlayTime` INT UNSIGNED NOT NULL DEFAULT '0', | ||
`moneyA` INT UNSIGNED NOT NULL DEFAULT '0', | ||
`moneyH` INT UNSIGNED NOT NULL DEFAULT '0', | ||
`itemA` INT UNSIGNED NOT NULL DEFAULT '0', | ||
`itemCountA` INT UNSIGNED NOT NULL DEFAULT '0', | ||
`itemH` INT UNSIGNED NOT NULL DEFAULT '0', | ||
`itemCountH` INT UNSIGNED NOT NULL DEFAULT '0', | ||
`subject` TEXT NOT NULL, | ||
`body` TEXT NOT NULL, | ||
`active` TINYINT UNSIGNED NOT NULL DEFAULT '1', | ||
PRIMARY KEY (`id`) | ||
) ENGINE=INNODB DEFAULT CHARSET=UTF8MB4; |
3 changes: 3 additions & 0 deletions
3
data/sql/updates/pending_db_world/rev_1693344185076263500.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
DELETE FROM `command` WHERE `name`='reload mail_server_template'; | ||
INSERT INTO `command` (`name`, `help`) VALUES | ||
('reload mail_server_template', 'Syntax: .reload mail_server_template\nReload server_mail_template table.'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* This file is part of the FirelandsCore 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 2 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 Affero General Public License along | ||
* with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include "DatabaseEnv.h" | ||
#include "ObjectMgr.h" | ||
#include "Player.h" | ||
#include "QueryResult.h" | ||
#include "ScriptMgr.h" | ||
#include "WorldSession.h" | ||
|
||
class ServerMailReward : public PlayerScript | ||
{ | ||
public: | ||
ServerMailReward() : PlayerScript("ServerMailReward") {} | ||
|
||
// CHARACTER_LOGIN = 8 | ||
void OnLogin(Player* player, bool /*firstLogin*/) | ||
{ | ||
for (auto const& servMail : sObjectMgr->GetAllServerMailStore()) | ||
{ | ||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_MAIL_SERVER_CHARACTER); | ||
stmt->setUInt32(0, player->GetGUID().GetCounter()); | ||
stmt->setUInt32(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(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters