mirror of
https://github.com/mangosfour/server.git
synced 2025-12-30 01:37:03 +00:00
[8769] Implement mails sending at player levelup.
This commit is contained in:
parent
d009994f59
commit
e078d0dd03
12 changed files with 149 additions and 3 deletions
|
|
@ -431,6 +431,7 @@ ChatCommand * ChatHandler::getCommandTable()
|
|||
{ "locales_page_text", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadLocalesPageTextCommand, "", NULL },
|
||||
{ "locales_points_of_interest", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadLocalesPointsOfInterestCommand, "", NULL },
|
||||
{ "locales_quest", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadLocalesQuestCommand, "", NULL },
|
||||
{ "mail_level_reward", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadMailLevelRewardCommand, "", NULL },
|
||||
{ "mail_loot_template", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadLootTemplatesMailCommand, "", NULL },
|
||||
{ "mangos_string", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadMangosStringCommand, "", NULL },
|
||||
{ "milling_loot_template", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadLootTemplatesMillingCommand, "", NULL },
|
||||
|
|
|
|||
|
|
@ -358,6 +358,7 @@ class ChatHandler
|
|||
bool HandleReloadLootTemplatesReferenceCommand(const char* args);
|
||||
bool HandleReloadLootTemplatesSkinningCommand(const char* args);
|
||||
bool HandleReloadLootTemplatesSpellCommand(const char* args);
|
||||
bool HandleReloadMailLevelRewardCommand(const char* args);
|
||||
bool HandleReloadMangosStringCommand(const char* args);
|
||||
bool HandleReloadNpcGossipCommand(const char* args);
|
||||
bool HandleReloadNpcOptionCommand(const char* args);
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@ bool ChatHandler::HandleReloadAllCommand(const char*)
|
|||
HandleReloadAllItemCommand("");
|
||||
HandleReloadAllLocalesCommand("");
|
||||
|
||||
HandleReloadMailLevelRewardCommand("");
|
||||
HandleReloadCommandCommand("");
|
||||
HandleReloadReservedNameCommand("");
|
||||
HandleReloadMangosStringCommand("");
|
||||
|
|
@ -822,6 +823,14 @@ bool ChatHandler::HandleReloadLocalesQuestCommand(const char* /*arg*/)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleReloadMailLevelRewardCommand(const char* /*arg*/)
|
||||
{
|
||||
sLog.outString( "Re-Loading Player level dependent mail rewards..." );
|
||||
objmgr.LoadMailLevelRewards();
|
||||
SendGlobalSysMessage("DB table `mail_level_reward` reloaded.");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleLoadScriptsCommand(const char* args)
|
||||
{
|
||||
if(!LoadScriptingModule(args)) return true;
|
||||
|
|
|
|||
|
|
@ -7518,6 +7518,72 @@ bool ObjectMgr::DeleteGameTele(const std::string& name)
|
|||
return false;
|
||||
}
|
||||
|
||||
void ObjectMgr::LoadMailLevelRewards()
|
||||
{
|
||||
m_mailLevelRewardMap.clear(); // for reload case
|
||||
|
||||
uint32 count = 0;
|
||||
QueryResult *result = WorldDatabase.Query("SELECT level, raceMask, mailTemplateId, senderEntry FROM mail_level_reward");
|
||||
|
||||
if( !result )
|
||||
{
|
||||
barGoLink bar( 1 );
|
||||
|
||||
bar.step();
|
||||
|
||||
sLog.outString();
|
||||
sLog.outErrorDb(">> Loaded `mail_level_reward`, table is empty!");
|
||||
return;
|
||||
}
|
||||
|
||||
barGoLink bar( result->GetRowCount() );
|
||||
|
||||
do
|
||||
{
|
||||
bar.step();
|
||||
|
||||
Field *fields = result->Fetch();
|
||||
|
||||
uint8 level = fields[0].GetUInt8();
|
||||
uint32 raceMask = fields[1].GetUInt32();
|
||||
uint32 mailTemplateId = fields[2].GetUInt32();
|
||||
uint32 senderEntry = fields[3].GetUInt32();
|
||||
|
||||
if(level > MAX_LEVEL)
|
||||
{
|
||||
sLog.outErrorDb("Table `mail_level_reward` have data for level %u that more supported by client (%u), ignoring.",level,MAX_LEVEL);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!(raceMask & RACEMASK_ALL_PLAYABLE))
|
||||
{
|
||||
sLog.outErrorDb("Table `mail_level_reward` have raceMask (%u) for level %u that not include any player races, ignoring.",raceMask,level);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!sMailTemplateStore.LookupEntry(mailTemplateId))
|
||||
{
|
||||
sLog.outErrorDb("Table `mail_level_reward` have invalid mailTemplateId (%u) for level %u that invalid not include any player races, ignoring.",mailTemplateId,level);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!GetCreatureTemplateStore(senderEntry))
|
||||
{
|
||||
sLog.outErrorDb("Table `mail_level_reward` have not existed sender creature entry (%u) for level %u that invalid not include any player races, ignoring.",senderEntry,level);
|
||||
continue;
|
||||
}
|
||||
|
||||
m_mailLevelRewardMap[level].push_back(MailLevelReward(raceMask,mailTemplateId,senderEntry));
|
||||
|
||||
++count;
|
||||
}
|
||||
while (result->NextRow());
|
||||
delete result;
|
||||
|
||||
sLog.outString();
|
||||
sLog.outString( ">> Loaded %u level dependent mail rewards,", count );
|
||||
}
|
||||
|
||||
void ObjectMgr::LoadTrainerSpell()
|
||||
{
|
||||
// For reload case
|
||||
|
|
|
|||
|
|
@ -179,6 +179,19 @@ struct PetLevelInfo
|
|||
uint16 armor;
|
||||
};
|
||||
|
||||
struct MailLevelReward
|
||||
{
|
||||
MailLevelReward() : raceMask(0), mailTemplateId(0), senderEntry(0) {}
|
||||
MailLevelReward(uint32 _raceMask, uint32 _mailTemplateId, uint32 _senderEntry) : raceMask(_raceMask), mailTemplateId(_mailTemplateId), senderEntry(_senderEntry) {}
|
||||
|
||||
uint32 raceMask;
|
||||
uint32 mailTemplateId;
|
||||
uint32 senderEntry;
|
||||
};
|
||||
|
||||
typedef std::list<MailLevelReward> MailLevelRewardList;
|
||||
typedef UNORDERED_MAP<uint8,MailLevelRewardList> MailLevelRewardMap;
|
||||
|
||||
struct ReputationOnKillEntry
|
||||
{
|
||||
uint32 repfaction1;
|
||||
|
|
@ -515,6 +528,7 @@ class ObjectMgr
|
|||
void LoadNpcOptionLocales();
|
||||
void LoadPointOfInterestLocales();
|
||||
void LoadInstanceTemplate();
|
||||
void LoadMailLevelRewards();
|
||||
|
||||
void LoadGossipText();
|
||||
|
||||
|
|
@ -584,6 +598,19 @@ class ObjectMgr
|
|||
typedef std::multimap<int32, uint32> ExclusiveQuestGroups;
|
||||
ExclusiveQuestGroups mExclusiveQuestGroups;
|
||||
|
||||
MailLevelReward const* GetMailLevelReward(uint32 level,uint32 raceMask)
|
||||
{
|
||||
MailLevelRewardMap::const_iterator map_itr = m_mailLevelRewardMap.find(level);
|
||||
if (map_itr == m_mailLevelRewardMap.end())
|
||||
return NULL;
|
||||
|
||||
for(MailLevelRewardList::const_iterator set_itr = map_itr->second.begin(); set_itr != map_itr->second.end(); ++set_itr)
|
||||
if (set_itr->raceMask & raceMask)
|
||||
return &*set_itr;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
WeatherZoneChances const* GetWeatherChances(uint32 zone_id) const
|
||||
{
|
||||
WeatherZoneMap::const_iterator itr = mWeatherZoneMap.find(zone_id);
|
||||
|
|
@ -844,6 +871,8 @@ class ObjectMgr
|
|||
void ConvertCreatureAddonAuras(CreatureDataAddon* addon, char const* table, char const* guidEntryStr);
|
||||
void LoadQuestRelationsHelper(QuestRelations& map,char const* table);
|
||||
|
||||
MailLevelRewardMap m_mailLevelRewardMap;
|
||||
|
||||
typedef std::map<uint32,PetLevelInfo*> PetLevelInfoMap;
|
||||
// PetLevelInfoMap[creature_id][level]
|
||||
PetLevelInfoMap petInfo; // [creature_id][level]
|
||||
|
|
|
|||
|
|
@ -2452,6 +2452,9 @@ void Player::GiveLevel(uint32 level)
|
|||
if (Pet* pet = GetPet())
|
||||
pet->SynchronizeLevelWithOwner();
|
||||
|
||||
if (MailLevelReward const* mailReward = objmgr.GetMailLevelReward(level,getRaceMask()))
|
||||
MailDraft(mailReward->mailTemplateId).SendMailTo(this,MailSender(MAIL_CREATURE,mailReward->senderEntry));
|
||||
|
||||
GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_REACH_LEVEL);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1338,6 +1338,9 @@ void World::SetInitialWorldSettings()
|
|||
sLog.outString( "Loading Player Corpses..." );
|
||||
objmgr.LoadCorpses();
|
||||
|
||||
sLog.outString( "Loading Player level dependent mail rewards..." );
|
||||
objmgr.LoadMailLevelRewards();
|
||||
|
||||
sLog.outString( "Loading Loot Tables..." );
|
||||
sLog.outString();
|
||||
LoadLootTables();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue