diff --git a/sql/mangos.sql b/sql/mangos.sql index 37ba033a7..41efdb7a8 100644 --- a/sql/mangos.sql +++ b/sql/mangos.sql @@ -24,7 +24,7 @@ CREATE TABLE `db_version` ( `version` varchar(120) default NULL, `creature_ai_version` varchar(120) default NULL, `cache_id` int(10) default '0', - `required_8731_01_mangos_creature_template` bit(1) default NULL + `required_8749_01_mangos_mail_loot_template` bit(1) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes'; -- @@ -2711,6 +2711,33 @@ LOCK TABLES `locales_quest` WRITE; /*!40000 ALTER TABLE `locales_quest` ENABLE KEYS */; UNLOCK TABLES; +-- +-- Table structure for table `mail_loot_template` +-- + +DROP TABLE IF EXISTS `mail_loot_template`; +CREATE TABLE `mail_loot_template` ( + `entry` mediumint(8) unsigned NOT NULL default '0', + `item` mediumint(8) unsigned NOT NULL default '0', + `ChanceOrQuestChance` float NOT NULL default '100', + `groupid` tinyint(3) unsigned NOT NULL default '0', + `mincountOrRef` mediumint(9) NOT NULL default '1', + `maxcount` tinyint(3) unsigned NOT NULL default '1', + `lootcondition` tinyint(3) unsigned NOT NULL default '0', + `condition_value1` mediumint(8) unsigned NOT NULL default '0', + `condition_value2` mediumint(8) unsigned NOT NULL default '0', + PRIMARY KEY (`entry`,`item`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Loot System'; + +-- +-- Dumping data for table `mail_loot_template` +-- + +LOCK TABLES `mail_loot_template` WRITE; +/*!40000 ALTER TABLE `mail_loot_template` DISABLE KEYS */; +/*!40000 ALTER TABLE `mail_loot_template` ENABLE KEYS */; +UNLOCK TABLES; + -- -- Table structure for table `mangos_string` -- @@ -13561,33 +13588,6 @@ LOCK TABLES `quest_start_scripts` WRITE; /*!40000 ALTER TABLE `quest_start_scripts` ENABLE KEYS */; UNLOCK TABLES; --- --- Table structure for table `quest_mail_loot_template` --- - -DROP TABLE IF EXISTS `quest_mail_loot_template`; -CREATE TABLE `quest_mail_loot_template` ( - `entry` mediumint(8) unsigned NOT NULL default '0', - `item` mediumint(8) unsigned NOT NULL default '0', - `ChanceOrQuestChance` float NOT NULL default '100', - `groupid` tinyint(3) unsigned NOT NULL default '0', - `mincountOrRef` mediumint(9) NOT NULL default '1', - `maxcount` tinyint(3) unsigned NOT NULL default '1', - `lootcondition` tinyint(3) unsigned NOT NULL default '0', - `condition_value1` mediumint(8) unsigned NOT NULL default '0', - `condition_value2` mediumint(8) unsigned NOT NULL default '0', - PRIMARY KEY (`entry`,`item`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Loot System'; - --- --- Dumping data for table `quest_mail_loot_template` --- - -LOCK TABLES `quest_mail_loot_template` WRITE; -/*!40000 ALTER TABLE `quest_mail_loot_template` DISABLE KEYS */; -/*!40000 ALTER TABLE `quest_mail_loot_template` ENABLE KEYS */; -UNLOCK TABLES; - -- -- Table structure for table `quest_template` -- diff --git a/sql/updates/8749_01_mangos_mail_loot_template.sql b/sql/updates/8749_01_mangos_mail_loot_template.sql new file mode 100644 index 000000000..1cf772675 --- /dev/null +++ b/sql/updates/8749_01_mangos_mail_loot_template.sql @@ -0,0 +1,6 @@ +ALTER TABLE db_version CHANGE COLUMN required_8731_01_mangos_creature_template required_8749_01_mangos_mail_loot_template bit; + +RENAME TABLE quest_mail_loot_template TO mail_loot_template; + +UPDATE mail_loot_template, quest_template + SET entry = quest_template.RewMailTemplateId WHERE mail_loot_template.entry = quest_template.entry; diff --git a/sql/updates/Makefile.am b/sql/updates/Makefile.am index 86d301969..36fc7b84b 100644 --- a/sql/updates/Makefile.am +++ b/sql/updates/Makefile.am @@ -145,6 +145,7 @@ pkgdata_DATA = \ 8726_01_mangos_spell_proc_event.sql \ 8728_01_realmd_account.sql \ 8731_01_mangos_creature_template.sql \ + 8749_01_mangos_mail_loot_template.sql \ README ## Additional files to include when running 'make dist' @@ -270,4 +271,5 @@ EXTRA_DIST = \ 8726_01_mangos_spell_proc_event.sql \ 8728_01_realmd_account.sql \ 8731_01_mangos_creature_template.sql \ + 8749_01_mangos_mail_loot_template.sql \ README diff --git a/src/game/Chat.cpp b/src/game/Chat.cpp index 47786c4d2..ef0984b61 100644 --- a/src/game/Chat.cpp +++ b/src/game/Chat.cpp @@ -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_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 }, { "npc_gossip", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadNpcGossipCommand, "", NULL }, @@ -443,7 +444,6 @@ ChatCommand * ChatHandler::getCommandTable() { "points_of_interest", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadPointsOfInterestCommand, "",NULL}, { "prospecting_loot_template", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadLootTemplatesProspectingCommand,"", NULL }, { "quest_end_scripts", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadQuestEndScriptsCommand, "", NULL }, - { "quest_mail_loot_template", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadLootTemplatesQuestMailCommand, "", NULL }, { "quest_start_scripts", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadQuestStartScriptsCommand, "", NULL }, { "quest_template", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadQuestTemplateCommand, "", NULL }, { "reference_loot_template", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadLootTemplatesReferenceCommand, "", NULL }, diff --git a/src/game/Chat.h b/src/game/Chat.h index 271640e6c..880d5b335 100644 --- a/src/game/Chat.h +++ b/src/game/Chat.h @@ -351,11 +351,11 @@ class ChatHandler bool HandleReloadLootTemplatesFishingCommand(const char* args); bool HandleReloadLootTemplatesGameobjectCommand(const char* args); bool HandleReloadLootTemplatesItemCommand(const char* args); + bool HandleReloadLootTemplatesMailCommand(const char* args); bool HandleReloadLootTemplatesMillingCommand(const char* args); bool HandleReloadLootTemplatesPickpocketingCommand(const char* args); bool HandleReloadLootTemplatesProspectingCommand(const char* args); bool HandleReloadLootTemplatesReferenceCommand(const char* args); - bool HandleReloadLootTemplatesQuestMailCommand(const char* args); bool HandleReloadLootTemplatesSkinningCommand(const char* args); bool HandleReloadLootTemplatesSpellCommand(const char* args); bool HandleReloadMangosStringCommand(const char* args); diff --git a/src/game/Level3.cpp b/src/game/Level3.cpp index c37723c22..edef1c641 100644 --- a/src/game/Level3.cpp +++ b/src/game/Level3.cpp @@ -360,12 +360,12 @@ bool ChatHandler::HandleReloadLootTemplatesProspectingCommand(const char*) return true; } -bool ChatHandler::HandleReloadLootTemplatesQuestMailCommand(const char*) +bool ChatHandler::HandleReloadLootTemplatesMailCommand(const char*) { - sLog.outString( "Re-Loading Loot Tables... (`quest_mail_loot_template`)" ); - LoadLootTemplates_QuestMail(); - LootTemplates_QuestMail.CheckLootRefs(); - SendGlobalSysMessage("DB table `quest_mail_loot_template` reloaded."); + sLog.outString( "Re-Loading Loot Tables... (`mail_loot_template`)" ); + LoadLootTemplates_Mail(); + LootTemplates_Mail.CheckLootRefs(); + SendGlobalSysMessage("DB table `mail_loot_template` reloaded."); return true; } diff --git a/src/game/LootMgr.cpp b/src/game/LootMgr.cpp index 343a93074..f3cfccdae 100644 --- a/src/game/LootMgr.cpp +++ b/src/game/LootMgr.cpp @@ -35,17 +35,17 @@ static Rates const qualityToRate[MAX_ITEM_QUALITY] = { RATE_DROP_ITEM_ARTIFACT, // ITEM_QUALITY_ARTIFACT }; -LootStore LootTemplates_Creature( "creature_loot_template", "creature entry", true); -LootStore LootTemplates_Disenchant( "disenchant_loot_template", "item disenchant id", true); -LootStore LootTemplates_Fishing( "fishing_loot_template", "area id", true); -LootStore LootTemplates_Gameobject( "gameobject_loot_template", "gameobject entry", true); -LootStore LootTemplates_Item( "item_loot_template", "item entry", true); -LootStore LootTemplates_Milling( "milling_loot_template", "item entry (herb)", true); -LootStore LootTemplates_Pickpocketing("pickpocketing_loot_template","creature pickpocket lootid", true); -LootStore LootTemplates_Prospecting( "prospecting_loot_template", "item entry (ore)", true); -LootStore LootTemplates_QuestMail( "quest_mail_loot_template", "quest id (with mail template)",false); -LootStore LootTemplates_Reference( "reference_loot_template", "reference id", false); -LootStore LootTemplates_Skinning( "skinning_loot_template", "creature skinning id", true); +LootStore LootTemplates_Creature( "creature_loot_template", "creature entry", true); +LootStore LootTemplates_Disenchant( "disenchant_loot_template", "item disenchant id", true); +LootStore LootTemplates_Fishing( "fishing_loot_template", "area id", true); +LootStore LootTemplates_Gameobject( "gameobject_loot_template", "gameobject entry", true); +LootStore LootTemplates_Item( "item_loot_template", "item entry", true); +LootStore LootTemplates_Mail( "mail_loot_template", "mail template id", false); +LootStore LootTemplates_Milling( "milling_loot_template", "item entry (herb)", true); +LootStore LootTemplates_Pickpocketing("pickpocketing_loot_template","creature pickpocket lootid", true); +LootStore LootTemplates_Prospecting( "prospecting_loot_template", "item entry (ore)", true); +LootStore LootTemplates_Reference( "reference_loot_template", "reference id", false); +LootStore LootTemplates_Skinning( "skinning_loot_template", "creature skinning id", true); LootStore LootTemplates_Spell( "spell_loot_template", "spell id (random item creating)",false); class LootTemplate::LootGroup // A set of loot definitions for items (refs are not allowed) @@ -1256,28 +1256,20 @@ void LoadLootTemplates_Prospecting() LootTemplates_Prospecting.ReportUnusedIds(ids_set); } -void LoadLootTemplates_QuestMail() +void LoadLootTemplates_Mail() { LootIdSet ids_set; - LootTemplates_QuestMail.LoadAndCollectLootIds(ids_set); + LootTemplates_Mail.LoadAndCollectLootIds(ids_set); // remove real entries and check existence loot ObjectMgr::QuestMap const& questMap = objmgr.GetQuestTemplates(); for(ObjectMgr::QuestMap::const_iterator itr = questMap.begin(); itr != questMap.end(); ++itr ) - { - if(!itr->second->GetRewMailTemplateId()) - continue; - - if(ids_set.count(itr->first)) - ids_set.erase(itr->first); - /* disabled reporting: some quest mails not include items - else - LootTemplates_QuestMail.ReportNotExistedId(itr->first); - */ - } + if(uint32 mail_template_id = itr->second->GetRewMailTemplateId()) + if(ids_set.count(mail_template_id)) + ids_set.erase(mail_template_id); // output error for any still listed (not referenced from appropriate table) ids - LootTemplates_QuestMail.ReportUnusedIds(ids_set); + LootTemplates_Mail.ReportUnusedIds(ids_set); } void LoadLootTemplates_Skinning() @@ -1354,7 +1346,7 @@ void LoadLootTemplates_Reference() LootTemplates_Skinning.CheckLootRefs(&ids_set); LootTemplates_Disenchant.CheckLootRefs(&ids_set); LootTemplates_Prospecting.CheckLootRefs(&ids_set); - LootTemplates_QuestMail.CheckLootRefs(&ids_set); + LootTemplates_Mail.CheckLootRefs(&ids_set); LootTemplates_Reference.CheckLootRefs(&ids_set); // output error for any still listed ids (not referenced from any loot table) diff --git a/src/game/LootMgr.h b/src/game/LootMgr.h index 1381c1206..88c7280b5 100644 --- a/src/game/LootMgr.h +++ b/src/game/LootMgr.h @@ -321,24 +321,24 @@ extern LootStore LootTemplates_Creature; extern LootStore LootTemplates_Fishing; extern LootStore LootTemplates_Gameobject; extern LootStore LootTemplates_Item; +extern LootStore LootTemplates_Mail; extern LootStore LootTemplates_Milling; extern LootStore LootTemplates_Pickpocketing; extern LootStore LootTemplates_Skinning; extern LootStore LootTemplates_Disenchant; extern LootStore LootTemplates_Prospecting; -extern LootStore LootTemplates_QuestMail; extern LootStore LootTemplates_Spell; void LoadLootTemplates_Creature(); void LoadLootTemplates_Fishing(); void LoadLootTemplates_Gameobject(); void LoadLootTemplates_Item(); +void LoadLootTemplates_Mail(); void LoadLootTemplates_Milling(); void LoadLootTemplates_Pickpocketing(); void LoadLootTemplates_Skinning(); void LoadLootTemplates_Disenchant(); void LoadLootTemplates_Prospecting(); -void LoadLootTemplates_QuestMail(); void LoadLootTemplates_Spell(); void LoadLootTemplates_Reference(); @@ -349,12 +349,12 @@ inline void LoadLootTables() LoadLootTemplates_Fishing(); LoadLootTemplates_Gameobject(); LoadLootTemplates_Item(); + LoadLootTemplates_Mail(); LoadLootTemplates_Milling(); LoadLootTemplates_Pickpocketing(); LoadLootTemplates_Skinning(); LoadLootTemplates_Disenchant(); LoadLootTemplates_Prospecting(); - LoadLootTemplates_QuestMail(); LoadLootTemplates_Spell(); LoadLootTemplates_Reference(); diff --git a/src/game/Mail.cpp b/src/game/Mail.cpp index 3190d12dd..fd94d86e9 100644 --- a/src/game/Mail.cpp +++ b/src/game/Mail.cpp @@ -899,3 +899,60 @@ void WorldSession::SendMailTo(Player* receiver, uint8 messageType, uint8 station } CharacterDatabase.CommitTransaction(); } + +void WorldSession::SendMailTo(Player* receiver, Object* sender, uint8 stationery, uint32 receiver_guidlow, std::string subject, uint32 itemTextId, MailItemsInfo* mi, uint32 money, uint32 COD, uint32 checked, uint32 deliver_delay, uint16 mailTemplateId) +{ + MailMessageType mailType; + uint32 senderGuidOrEntry; + switch(sender->GetTypeId()) + { + case TYPEID_UNIT: + mailType = MAIL_CREATURE; + senderGuidOrEntry = sender->GetEntry(); + break; + case TYPEID_GAMEOBJECT: + mailType = MAIL_GAMEOBJECT; + senderGuidOrEntry = sender->GetEntry(); + break; + case TYPEID_ITEM: + mailType = MAIL_ITEM; + senderGuidOrEntry = sender->GetEntry(); + break; + case TYPEID_PLAYER: + mailType = MAIL_NORMAL; + senderGuidOrEntry = sender->GetGUIDLow(); + break; + default: + mailType = MAIL_NORMAL; + senderGuidOrEntry = receiver_guidlow; + sLog.outError( "WorldSession::SendMailTo - Mail have unexpected sender typeid (%u), sent from receiver to self", sender->GetTypeId()); + break; + } + + SendMailTo(receiver, mailType, stationery, senderGuidOrEntry, receiver_guidlow, subject, itemTextId, mi, money, COD, checked,deliver_delay,mailTemplateId); +} + +void WorldSession::SendMailTemplateTo(Player* receiver, Object* sender, uint8 stationery, uint16 mailTemplateId, uint32 money, uint32 COD, uint32 checked, uint32 deliver_delay) +{ + Loot mailLoot; + + mailLoot.FillLoot(mailTemplateId, LootTemplates_Mail, receiver,true); + + // fill mail + MailItemsInfo mi; // item list preparing + + uint32 max_slot = mailLoot.GetMaxSlotInLootFor(receiver); + for(uint32 i = 0; mi.size() < MAX_MAIL_ITEMS && i < max_slot; ++i) + { + if (LootItem* lootitem = mailLoot.LootItemInSlot(i,receiver)) + { + if (Item* item = Item::CreateItem(lootitem->itemid,lootitem->count,receiver)) + { + item->SaveToDB(); // save for prevent lost at next mail load, if send fail then item will deleted + mi.AddItem(item->GetGUIDLow(), item->GetEntry(), item); + } + } + } + + WorldSession::SendMailTo(receiver, sender, stationery, receiver->GetGUIDLow(), "", 0, &mi, money, COD, checked,deliver_delay,mailTemplateId); +} diff --git a/src/game/Player.cpp b/src/game/Player.cpp index b63a7848c..8bacc46cc 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -12714,56 +12714,8 @@ void Player::RewardQuest( Quest const *pQuest, uint32 reward, Object* questGiver } // Send reward mail - if (pQuest->GetRewMailTemplateId()) - { - MailMessageType mailType; - uint32 senderGuidOrEntry; - switch(questGiver->GetTypeId()) - { - case TYPEID_UNIT: - mailType = MAIL_CREATURE; - senderGuidOrEntry = questGiver->GetEntry(); - break; - case TYPEID_GAMEOBJECT: - mailType = MAIL_GAMEOBJECT; - senderGuidOrEntry = questGiver->GetEntry(); - break; - case TYPEID_ITEM: - mailType = MAIL_ITEM; - senderGuidOrEntry = questGiver->GetEntry(); - break; - case TYPEID_PLAYER: - mailType = MAIL_NORMAL; - senderGuidOrEntry = questGiver->GetGUIDLow(); - break; - default: - mailType = MAIL_NORMAL; - senderGuidOrEntry = GetGUIDLow(); - break; - } - - Loot questMailLoot; - - questMailLoot.FillLoot(pQuest->GetQuestId(), LootTemplates_QuestMail, this,true); - - // fill mail - MailItemsInfo mi; // item list preparing - - uint32 max_slot = questMailLoot.GetMaxSlotInLootFor(this); - for(uint32 i = 0; mi.size() < MAX_MAIL_ITEMS && i < max_slot; ++i) - { - if (LootItem* lootitem = questMailLoot.LootItemInSlot(i,this)) - { - if (Item* item = Item::CreateItem(lootitem->itemid,lootitem->count,this)) - { - item->SaveToDB(); // save for prevent lost at next mail load, if send fail then item will deleted - mi.AddItem(item->GetGUIDLow(), item->GetEntry(), item); - } - } - } - - WorldSession::SendMailTo(this, mailType, MAIL_STATIONERY_NORMAL, senderGuidOrEntry, GetGUIDLow(), "", 0, &mi, 0, 0, MAIL_CHECK_MASK_NONE,pQuest->GetRewMailDelaySecs(),pQuest->GetRewMailTemplateId()); - } + if (uint32 mail_template_id = pQuest->GetRewMailTemplateId()) + WorldSession::SendMailTemplateTo(this, questGiver, MAIL_STATIONERY_NORMAL, mail_template_id, 0, 0, MAIL_CHECK_MASK_NONE, pQuest->GetRewMailDelaySecs()); if (pQuest->IsDaily()) { diff --git a/src/game/Player.h b/src/game/Player.h index a637fe5c8..0e69a8bd7 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -1297,6 +1297,7 @@ class MANGOS_DLL_SPEC Player : public Unit void CompleteQuest( uint32 quest_id ); void IncompleteQuest( uint32 quest_id ); void RewardQuest( Quest const *pQuest, uint32 reward, Object* questGiver, bool announce = true ); + void FailQuest( uint32 quest_id ); bool SatisfyQuestSkillOrClass( Quest const* qInfo, bool msg ); bool SatisfyQuestLevel( Quest const* qInfo, bool msg ); diff --git a/src/game/WorldSession.h b/src/game/WorldSession.h index cf8ca9cb5..3a7f583ea 100644 --- a/src/game/WorldSession.h +++ b/src/game/WorldSession.h @@ -226,6 +226,8 @@ class MANGOS_DLL_SPEC WorldSession bool SendItemInfo( uint32 itemid, WorldPacket data ); static void SendReturnToSender(uint8 messageType, uint32 sender_acc, uint32 sender_guid, uint32 receiver_guid, const std::string& subject, uint32 itemTextId, MailItemsInfo *mi, uint32 money, uint16 mailTemplateId = 0); static void SendMailTo(Player* receiver, uint8 messageType, uint8 stationery, uint32 sender_guidlow_or_entry, uint32 received_guidlow, std::string subject, uint32 itemTextId, MailItemsInfo* mi, uint32 money, uint32 COD, uint32 checked, uint32 deliver_delay = 0, uint16 mailTemplateId = 0); + static void SendMailTo(Player* receiver, Object* sender, uint8 stationery, uint32 received_guidlow, std::string subject, uint32 itemTextId, MailItemsInfo* mi, uint32 money, uint32 COD, uint32 checked, uint32 deliver_delay = 0, uint16 mailTemplateId = 0); + static void SendMailTemplateTo(Player* receiver, Object* sender, uint8 stationery, uint16 mailTemplateId, uint32 money, uint32 COD, uint32 checked, uint32 deliver_delay = 0); //auction void SendAuctionHello( uint64 guid, Creature * unit ); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index e7aa21f86..61b75000e 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "8748" + #define REVISION_NR "8749" #endif // __REVISION_NR_H__ diff --git a/src/shared/revision_sql.h b/src/shared/revision_sql.h index ed97f2ba0..c562c32e9 100644 --- a/src/shared/revision_sql.h +++ b/src/shared/revision_sql.h @@ -1,6 +1,6 @@ #ifndef __REVISION_SQL_H__ #define __REVISION_SQL_H__ #define REVISION_DB_CHARACTERS "required_8721_01_characters_guild" - #define REVISION_DB_MANGOS "required_8731_01_mangos_creature_template" + #define REVISION_DB_MANGOS "required_8749_01_mangos_mail_loot_template" #define REVISION_DB_REALMD "required_8728_01_realmd_account" #endif // __REVISION_SQL_H__