diff options
-rw-r--r-- | sql/base/world_database.sql | 2 | ||||
-rw-r--r-- | sql/updates/8605_world_playercreateinfo_item.sql | 1 | ||||
-rw-r--r-- | src/server/game/Globals/ObjectMgr.cpp | 58 | ||||
-rw-r--r-- | src/server/game/Globals/ObjectMgr.h | 1 |
4 files changed, 57 insertions, 5 deletions
diff --git a/sql/base/world_database.sql b/sql/base/world_database.sql index 5cf85d68cab..4ef57d79fdd 100644 --- a/sql/base/world_database.sql +++ b/sql/base/world_database.sql @@ -4105,7 +4105,7 @@ CREATE TABLE `playercreateinfo_item` ( `race` tinyint(3) unsigned NOT NULL DEFAULT '0', `class` tinyint(3) unsigned NOT NULL DEFAULT '0', `itemid` mediumint(8) unsigned NOT NULL DEFAULT '0', - `amount` tinyint(3) unsigned NOT NULL DEFAULT '1', + `amount` tinyint(3) NOT NULL DEFAULT '1', KEY `playercreateinfo_race_class_index` (`race`,`class`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; diff --git a/sql/updates/8605_world_playercreateinfo_item.sql b/sql/updates/8605_world_playercreateinfo_item.sql new file mode 100644 index 00000000000..c5d423c1744 --- /dev/null +++ b/sql/updates/8605_world_playercreateinfo_item.sql @@ -0,0 +1 @@ +ALTER TABLE `playercreateinfo_item` CHANGE `amount` `amount` tinyint(3) NOT NULL DEFAULT '1'; diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index 89ce93b5d80..e78dc02a93f 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -2660,6 +2660,47 @@ PetLevelInfo const* ObjectMgr::GetPetLevelInfo(uint32 creature_id, uint8 level) return &itr->second[level-1]; // data for level 1 stored in [0] array element, ... } +void ObjectMgr::PlayerCreateInfoAddItemHelper(uint32 race_, uint32 class_, uint32 itemId, int32 count) +{ + if (count > 0) + playerInfo[race_][class_].item.push_back(PlayerCreateInfoItem(itemId, count)); + else + { + if (count < -1) + sLog.outErrorDb("Invalid count %i specified on item %u be removed from original player create info (use -1)!", count, itemId); + + uint32 RaceClass = (race_) | (class_ << 8); + bool doneOne = false; + for (uint32 i = 1; i < sCharStartOutfitStore.GetNumRows(); ++i) + { + if (CharStartOutfitEntry const* entry = sCharStartOutfitStore.LookupEntry(i)) + { + if (entry->RaceClassGender == RaceClass || entry->RaceClassGender == (RaceClass | (1 << 16))) + { + bool found = false; + for (uint8 x = 0; x < MAX_OUTFIT_ITEMS; ++x) + { + if (entry->ItemId[x] == itemId) + { + found = true; + const_cast<CharStartOutfitEntry*>(entry)->ItemId[x] = 0; + break; + } + } + + if (!found) + sLog.outErrorDb("Item %u specified to be removed from original create info not found in dbc!", itemId); + + if (!doneOne) + doneOne = true; + else + break; + } + } + } + } +} + void ObjectMgr::LoadPlayerInfo() { // Load playercreate @@ -2790,8 +2831,6 @@ void ObjectMgr::LoadPlayerInfo() continue; } - PlayerInfo* pInfo = &playerInfo[current_race][current_class]; - uint32 item_id = fields[2].GetUInt32(); if (!GetItemPrototype(item_id)) @@ -2800,7 +2839,7 @@ void ObjectMgr::LoadPlayerInfo() continue; } - uint32 amount = fields[3].GetUInt32(); + int32 amount = fields[3].GetInt32(); if (!amount) { @@ -2808,7 +2847,18 @@ void ObjectMgr::LoadPlayerInfo() continue; } - pInfo->item.push_back(PlayerCreateInfoItem(item_id, amount)); + if (!current_race || !current_class) + { + uint32 min_race = current_race ? current_race : 1; + uint32 max_race = current_race ? current_race + 1 : MAX_RACES; + uint32 min_class = current_class ? current_class : 1; + uint32 max_class = current_class ? current_class + 1 : MAX_CLASSES; + for (uint32 r = min_race; r < max_race; ++r) + for (uint32 c = min_class; c < max_class; ++c) + PlayerCreateInfoAddItemHelper(r, c, item_id, amount); + } + else + PlayerCreateInfoAddItemHelper(current_race, current_class, item_id, amount); bar.step(); ++count; diff --git a/src/server/game/Globals/ObjectMgr.h b/src/server/game/Globals/ObjectMgr.h index a5e3989d452..824eb237756 100644 --- a/src/server/game/Globals/ObjectMgr.h +++ b/src/server/game/Globals/ObjectMgr.h @@ -1035,6 +1035,7 @@ class ObjectMgr void LoadCreatureAddons(SQLStorage& creatureaddons, char const* entryName, char const* comment); void ConvertCreatureAddonAuras(CreatureDataAddon* addon, char const* table, char const* guidEntryStr); void LoadQuestRelationsHelper(QuestRelations& map,char const* table); + void PlayerCreateInfoAddItemHelper(uint32 race_, uint32 class_, uint32 itemId, int32 count); MailLevelRewardMap m_mailLevelRewardMap; |