From e5c0576f354d2b5ecddbc1a6b94ec1bcc91cecda Mon Sep 17 00:00:00 2001 From: megamage Date: Fri, 27 Mar 2009 10:00:42 -0600 Subject: *Add and remove files. --HG-- branch : trunk --- src/shared/Database/DBCEnums.h | 323 ------- src/shared/Database/DBCFileLoader.h | 107 +++ src/shared/Database/DBCStore.h | 94 ++ src/shared/Database/DBCStores.cpp | 719 --------------- src/shared/Database/DBCStores.h | 230 ----- src/shared/Database/DBCStructure.h | 1675 ----------------------------------- src/shared/Database/DBCfmt.cpp | 101 --- src/shared/Database/dbcfile.cpp | 261 ------ src/shared/Database/dbcfile.h | 110 --- 9 files changed, 201 insertions(+), 3419 deletions(-) delete mode 100644 src/shared/Database/DBCEnums.h create mode 100644 src/shared/Database/DBCFileLoader.h create mode 100644 src/shared/Database/DBCStore.h delete mode 100644 src/shared/Database/DBCStores.cpp delete mode 100644 src/shared/Database/DBCStores.h delete mode 100644 src/shared/Database/DBCStructure.h delete mode 100644 src/shared/Database/DBCfmt.cpp delete mode 100644 src/shared/Database/dbcfile.cpp delete mode 100644 src/shared/Database/dbcfile.h (limited to 'src/shared/Database') diff --git a/src/shared/Database/DBCEnums.h b/src/shared/Database/DBCEnums.h deleted file mode 100644 index c5801c7b315..00000000000 --- a/src/shared/Database/DBCEnums.h +++ /dev/null @@ -1,323 +0,0 @@ -/* -* Copyright (C) 2005-2009 MaNGOS -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU 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 General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifndef DBCENUMS_H -#define DBCENUMS_H - -// client supported max level for player/pets/etc. Avoid overflow or client stability affected. -// also see GT_MAX_LEVEL define -#define MAX_LEVEL 100 - -// Server side limitation. Base at used code requirements. -// also see MAX_LEVEL and GT_MAX_LEVEL define -#define STRONG_MAX_LEVEL 255 - -enum AreaTeams -{ - AREATEAM_NONE = 0, - AREATEAM_ALLY = 2, - AREATEAM_HORDE = 4 -}; - -enum AchievementFactionFlags -{ - ACHIEVEMENT_FACTION_FLAG_HORDE = 0x00000000, - ACHIEVEMENT_FACTION_FLAG_ALLIANCE = 0x00000001, -}; - -enum AchievementFlags -{ - ACHIEVEMENT_FLAG_COUNTER = 0x00000001, - ACHIEVEMENT_FLAG_REACH_LEVEL = 0x00000004, - ACHIEVEMENT_FLAG_RERERED_MAX = 0x00000010, // displays the maximum criteria of a refered achievement - ACHIEVEMENT_FLAG_AVERAGE = 0x00000040, - ACHIEVEMENT_FLAG_REALM_FIRST_REACH= 0x00000100, - ACHIEVEMENT_FLAG_REALM_FIRST_KILL = 0x00000200, -}; - -enum AchievementCriteriaCondition -{ - ACHIEVEMENT_CRITERIA_CONDITION_NONE = 0, - ACHIEVEMENT_CRITERIA_CONDITION_NO_DEATH = 1, - ACHIEVEMENT_CRITERIA_CONDITION_UNK1 = 2, // only used in "Complete a daily quest every day for five consecutive days" - ACHIEVEMENT_CRITERIA_CONDITION_MAP = 3, // requires you to be on specific map - ACHIEVEMENT_CRITERIA_CONDITION_NO_LOOSE = 4, // only used in "Win 10 arenas without losing" - ACHIEVEMENT_CRITERIA_CONDITION_UNK2 = 9, // unk - ACHIEVEMENT_CRITERIA_CONDITION_UNK3 = 13, // unk -}; - -enum AchievementCriteriaCompletionFlags -{ - // some Achievements (like 698) have several criteria but only one has to be fulfilled. These are identified by this flag. - ACHIEVEMENT_CRITERIA_COMPLETE_FLAG_ALL = 2, -}; - -enum AchievementCriteriaGroupFlags -{ - // you mustn't be in a group while fulfilling this achievement - ACHIEVEMENT_CRITERIA_GROUP_NOT_IN_GROUP = 2, -}; - -enum AchievementCriteriaTypes -{ - ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE = 0, - ACHIEVEMENT_CRITERIA_TYPE_WIN_BG = 1, - ACHIEVEMENT_CRITERIA_TYPE_REACH_LEVEL = 5, - ACHIEVEMENT_CRITERIA_TYPE_REACH_SKILL_LEVEL = 7, - ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_ACHIEVEMENT = 8, - ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUEST_COUNT = 9, - // you have to complete a daily quest x times in a row - ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_DAILY_QUEST_DAILY = 10, - ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUESTS_IN_ZONE = 11, - ACHIEVEMENT_CRITERIA_TYPE_DAMAGE_DONE = 13, - ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_DAILY_QUEST = 14, - ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_BATTLEGROUND= 15, - ACHIEVEMENT_CRITERIA_TYPE_DEATH_AT_MAP= 16, - ACHIEVEMENT_CRITERIA_TYPE_DEATH= 17, - ACHIEVEMENT_CRITERIA_TYPE_DEATH_IN_DUNGEON = 18, - ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_RAID = 19, - ACHIEVEMENT_CRITERIA_TYPE_KILLED_BY_CREATURE = 20, - ACHIEVEMENT_CRITERIA_TYPE_KILLED_BY_PLAYER = 23, - ACHIEVEMENT_CRITERIA_TYPE_FALL_WITHOUT_DYING = 24, - ACHIEVEMENT_CRITERIA_TYPE_DEATHS_FROM = 26, - ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUEST = 27, - ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET = 28, - ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL= 29, - ACHIEVEMENT_CRITERIA_TYPE_BG_OBJECTIVE_CAPTURE = 30, - ACHIEVEMENT_CRITERIA_TYPE_HONORABLE_KILL_AT_AREA = 31, - ACHIEVEMENT_CRITERIA_TYPE_WIN_ARENA = 32, - ACHIEVEMENT_CRITERIA_TYPE_PLAY_ARENA = 33, - ACHIEVEMENT_CRITERIA_TYPE_LEARN_SPELL = 34, - // TODO: this criteria has additional conditions which can not be found in the dbcs - ACHIEVEMENT_CRITERIA_TYPE_HONORABLE_KILL = 35, - ACHIEVEMENT_CRITERIA_TYPE_OWN_ITEM = 36, - // TODO: the archievements 1162 and 1163 requires a special rating which can't be found in the dbc - ACHIEVEMENT_CRITERIA_TYPE_WIN_RATED_ARENA = 37, - ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_TEAM_RATING = 38, - ACHIEVEMENT_CRITERIA_TYPE_REACH_TEAM_RATING = 39, - ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LEVEL = 40, - ACHIEVEMENT_CRITERIA_TYPE_USE_ITEM = 41, - ACHIEVEMENT_CRITERIA_TYPE_LOOT_ITEM= 42, - ACHIEVEMENT_CRITERIA_TYPE_EXPLORE_AREA = 43, - ACHIEVEMENT_CRITERIA_TYPE_OWN_RANK= 44, - ACHIEVEMENT_CRITERIA_TYPE_BUY_BANK_SLOT= 45, - ACHIEVEMENT_CRITERIA_TYPE_GAIN_REPUTATION= 46, - ACHIEVEMENT_CRITERIA_TYPE_GAIN_EXALTED_REPUTATION= 47, - // noted: rewarded as soon as the player payed, not at taking place at the seat - ACHIEVEMENT_CRITERIA_TYPE_VISIT_BARBER_SHOP= 48, - ACHIEVEMENT_CRITERIA_TYPE_EQUIP_EPIC_ITEM = 49, - // TODO: itemlevel is mentioned in text but not present in dbc - ACHIEVEMENT_CRITERIA_TYPE_ROLL_NEED_ON_LOOT = 50, - ACHIEVEMENT_CRITERIA_TYPE_ROLL_GREED_ON_LOOT= 51, - ACHIEVEMENT_CRITERIA_TYPE_HK_CLASS = 52, - ACHIEVEMENT_CRITERIA_TYPE_HK_RACE = 53, - ACHIEVEMENT_CRITERIA_TYPE_DO_EMOTE = 54, - ACHIEVEMENT_CRITERIA_TYPE_HEALING_DONE = 55, - // TODO: in some cases map not present, and in some cases need do without die - ACHIEVEMENT_CRITERIA_TYPE_GET_KILLING_BLOWS = 56, - ACHIEVEMENT_CRITERIA_TYPE_EQUIP_ITEM = 57, - ACHIEVEMENT_CRITERIA_TYPE_MONEY_FROM_VENDORS = 59, - ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_FOR_TALENTS = 60, - ACHIEVEMENT_CRITERIA_TYPE_NUMBER_OF_TALENT_RESETS = 61, - ACHIEVEMENT_CRITERIA_TYPE_MONEY_FROM_QUEST_REWARD = 62, - ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_FOR_TRAVELLING = 63, - ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_AT_BARBER = 65, - ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_FOR_MAIL = 66, - ACHIEVEMENT_CRITERIA_TYPE_LOOT_MONEY = 67, - ACHIEVEMENT_CRITERIA_TYPE_USE_GAMEOBJECT = 68, - ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET2= 69, - ACHIEVEMENT_CRITERIA_TYPE_SPECIAL_PVP_KILL= 70, - ACHIEVEMENT_CRITERIA_TYPE_FISH_IN_GAMEOBJECT = 72, - // TODO: title id is not mentioned in dbc - ACHIEVEMENT_CRITERIA_TYPE_EARNED_PVP_TITLE = 74, - ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILLLINE_SPELLS= 75, - ACHIEVEMENT_CRITERIA_TYPE_WIN_DUEL = 76, - ACHIEVEMENT_CRITERIA_TYPE_LOSE_DUEL = 77, - // TODO: creature type (demon, undead etc.) is not stored in dbc - ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE_TYPE = 78, - ACHIEVEMENT_CRITERIA_TYPE_GOLD_EARNED_BY_AUCTIONS= 80, - ACHIEVEMENT_CRITERIA_TYPE_CREATE_AUCTION= 82, - ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_BID= 83, - ACHIEVEMENT_CRITERIA_TYPE_WON_AUCTIONS= 84, - ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_SOLD = 85, - ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_GOLD_VALUE_OWNED = 86, - ACHIEVEMENT_CRITERIA_TYPE_GAIN_REVERED_REPUTATION = 87, - ACHIEVEMENT_CRITERIA_TYPE_GAIN_HONORED_REPUTATION = 88, - ACHIEVEMENT_CRITERIA_TYPE_KNOWN_FACTIONS = 89, - ACHIEVEMENT_CRITERIA_TYPE_LOOT_EPIC_ITEM = 90, - ACHIEVEMENT_CRITERIA_TYPE_RECEIVE_EPIC_ITEM = 91, - ACHIEVEMENT_CRITERIA_TYPE_ROLL_NEED = 93, - ACHIEVEMENT_CRITERIA_TYPE_ROLL_GREED = 94, - ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HEALTH = 95, - ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_POWER = 96, - ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_STAT = 97, - ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_SPELLPOWER = 98, - ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_ARMOR = 99, - ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_RATING = 100, - ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HIT_DEALT = 101, - ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HIT_RECEIVED = 102, - ACHIEVEMENT_CRITERIA_TYPE_TOTAL_DAMAGE_RECEIVED = 103, - ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HEAL_CASTED = 104, - ACHIEVEMENT_CRITERIA_TYPE_TOTAL_HEALING_RECEIVED = 105, - ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HEALING_RECEIVED = 106, - ACHIEVEMENT_CRITERIA_TYPE_QUEST_ABANDONED = 107, - ACHIEVEMENT_CRITERIA_TYPE_FLIGHT_PATHS_TAKEN = 108, - ACHIEVEMENT_CRITERIA_TYPE_LOOT_TYPE = 109, - // TODO: target entry is missing - ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL2 = 110, - ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LINE= 112, - ACHIEVEMENT_CRITERIA_TYPE_EARN_HONORABLE_KILL = 113, - ACHIEVEMENT_CRITERIA_TYPE_ACCEPTED_SUMMONINGS = 114, - // 0..114 => 115 criteria types total - ACHIEVEMENT_CRITERIA_TYPE_TOTAL = 115, -}; - -enum AreaFlags -{ - AREA_FLAG_SNOW = 0x00000001, // snow (only Dun Morogh, Naxxramas, Razorfen Downs and Winterspring) - AREA_FLAG_UNK1 = 0x00000002, // may be necropolis? - AREA_FLAG_UNK2 = 0x00000004, // Only used for areas on map 571 (development before) - AREA_FLAG_SLAVE_CAPITAL = 0x00000008, // city and city subsones - AREA_FLAG_UNK3 = 0x00000010, // can't find common meaning - AREA_FLAG_SLAVE_CAPITAL2 = 0x00000020, // slave capital city flag? - AREA_FLAG_UNK4 = 0x00000040, // many zones have this flag - AREA_FLAG_ARENA = 0x00000080, // arena, both instanced and world arenas - AREA_FLAG_CAPITAL = 0x00000100, // main capital city flag - AREA_FLAG_CITY = 0x00000200, // only for one zone named "City" (where it located?) - AREA_FLAG_OUTLAND = 0x00000400, // expansion zones? (only Eye of the Storm not have this flag, but have 0x00004000 flag) - AREA_FLAG_SANCTUARY = 0x00000800, // sanctuary area (PvP disabled) - AREA_FLAG_NEED_FLY = 0x00001000, // only Netherwing Ledge, Socrethar's Seat, Tempest Keep, The Arcatraz, The Botanica, The Mechanar, Sorrow Wing Point, Dragonspine Ridge, Netherwing Mines, Dragonmaw Base Camp, Dragonmaw Skyway - AREA_FLAG_UNUSED1 = 0x00002000, // not used now (no area/zones with this flag set in 3.0.3) - AREA_FLAG_OUTLAND2 = 0x00004000, // expansion zones? (only Circle of Blood Arena not have this flag, but have 0x00000400 flag) - AREA_FLAG_PVP = 0x00008000, // pvp objective area? (Death's Door also has this flag although it's no pvp object area) - AREA_FLAG_ARENA_INSTANCE = 0x00010000, // used by instanced arenas only - AREA_FLAG_UNUSED2 = 0x00020000, // not used now (no area/zones with this flag set in 3.0.3) - AREA_FLAG_UNK5 = 0x00040000, // only used for Amani Pass, Hatchet Hills - AREA_FLAG_UNK6 = 0x00080000, // Valgarde and Acherus: The Ebon Hold - AREA_FLAG_LOWLEVEL = 0x00100000, // used for some starting areas with area_level <=15 - AREA_FLAG_TOWN = 0x00200000, // small towns with Inn - AREA_FLAG_UNK7 = 0x00400000, // Warsong Hold, Acherus: The Ebon Hold, New Agamand Inn, Vengeance Landing Inn - AREA_FLAG_UNK8 = 0x00800000, // Westguard Inn, Acherus: The Ebon Hold, Valgarde - AREA_FLAG_OUTDOOR_PVP = 0x01000000, // Wintergrasp and it's subzones - AREA_FLAG_UNK9 = 0x02000000, // unknown - AREA_FLAG_UNK10 = 0x04000000, // unknown - AREA_FLAG_OUTDOOR_PVP2 = 0x08000000 // Wintergrasp and it's subzones -}; - -enum FactionTemplateFlags -{ - FACTION_TEMPLATE_FLAG_CONTESTED_GUARD = 0x00001000, // faction will attack players that were involved in PvP combats -}; - -enum FactionMasks -{ - FACTION_MASK_PLAYER = 1, // any player - FACTION_MASK_ALLIANCE = 2, // player or creature from alliance team - FACTION_MASK_HORDE = 4, // player or creature from horde team - FACTION_MASK_MONSTER = 8 // aggressive creature from monster team - // if none flags set then non-aggressive creature -}; - -enum MapTypes -{ - MAP_COMMON = 0, - MAP_INSTANCE = 1, - MAP_RAID = 2, - MAP_BATTLEGROUND = 3, - MAP_ARENA = 4 -}; - -enum AbilytyLearnType -{ - ABILITY_LEARNED_ON_GET_PROFESSION_SKILL = 1, - ABILITY_LEARNED_ON_GET_RACE_OR_CLASS_SKILL = 2 -}; - -enum ItemEnchantmentType -{ - ITEM_ENCHANTMENT_TYPE_NONE = 0, - ITEM_ENCHANTMENT_TYPE_COMBAT_SPELL = 1, - ITEM_ENCHANTMENT_TYPE_DAMAGE = 2, - ITEM_ENCHANTMENT_TYPE_EQUIP_SPELL = 3, - ITEM_ENCHANTMENT_TYPE_RESISTANCE = 4, - ITEM_ENCHANTMENT_TYPE_STAT = 5, - ITEM_ENCHANTMENT_TYPE_TOTEM = 6, - ITEM_ENCHANTMENT_TYPE_USE_SPELL = 7, - ITEM_ENCHANTMENT_TYPE_PRISMATIC_SOCKET = 8 -}; - -enum TotemCategoryType -{ - TOTEM_CATEGORY_TYPE_KNIFE = 1, - TOTEM_CATEGORY_TYPE_TOTEM = 2, - TOTEM_CATEGORY_TYPE_ROD = 3, - TOTEM_CATEGORY_TYPE_PICK = 21, - TOTEM_CATEGORY_TYPE_STONE = 22, - TOTEM_CATEGORY_TYPE_HAMMER = 23, - TOTEM_CATEGORY_TYPE_SPANNER = 24 -}; - -// SummonProperties.dbc, col 1 -/*enum SummonGroup -{ - SUMMON_GROUP_UNKNOWN1 = 0, // 1160 spells in 3.0.3 - SUMMON_GROUP_UNKNOWN2 = 1, // 861 spells in 3.0.3 - SUMMON_GROUP_PETS = 2, // 52 spells in 3.0.3, pets mostly - SUMMON_GROUP_CONTROLLABLE = 3, // 13 spells in 3.0.3, mostly controllable - SUMMON_GROUP_UNKNOWN3 = 4 // 86 spells in 3.0.3, taxi/mounts -}; - -// SummonProperties.dbc, col 3 -enum SummonType -{ - SUMMON_TYPE_UNKNOWN = 0, // different summons, 1330 spells in 3.0.3 - SUMMON_TYPE_SUMMON = 1, // generic summons, 49 spells in 3.0.3 - SUMMON_TYPE_GUARDIAN = 2, // summon guardian, 393 spells in 3.0.3 - SUMMON_TYPE_ARMY = 3, // summon army, 5 spells in 3.0.3 - SUMMON_TYPE_TOTEM = 4, // summon totem, 169 spells in 3.0.3 - SUMMON_TYPE_CRITTER = 5, // critter/minipet, 195 spells in 3.0.3 - SUMMON_TYPE_DK = 6, // summon DRW/Ghoul, 2 spells in 3.0.3 - SUMMON_TYPE_BOMB = 7, // summon bot/bomb, 4 spells in 3.0.3 - SUMMON_TYPE_PHASING = 8, // something todo with DK prequest line, 2 spells in 3.0.3 - SUMMON_TYPE_SIEGE_VEH = 9, // summon different vehicles, 14 spells in 3.0.3 - SUMMON_TYPE_DRAKE_VEH = 10, // summon drake (vehicle), 3 spells - SUMMON_TYPE_LIGHTWELL = 11 // summon lightwell, 6 spells in 3.0.3 -}; - -// SummonProperties.dbc, col 5 -enum SummonFlags -{ - SUMMON_FLAG_NONE = 0x0000, // 1342 spells in 3.0.3 - SUMMON_FLAG_UNK1 = 0x0001, // 75 spells in 3.0.3, something unfriendly - SUMMON_FLAG_UNK2 = 0x0002, // 616 spells in 3.0.3, something friendly - SUMMON_FLAG_UNK3 = 0x0004, // 22 spells in 3.0.3, no idea... - SUMMON_FLAG_UNK4 = 0x0008, // 49 spells in 3.0.3, some mounts - SUMMON_FLAG_UNK5 = 0x0010, // 25 spells in 3.0.3, quest related? - SUMMON_FLAG_UNK6 = 0x0020, // 0 spells in 3.0.3, unused - SUMMON_FLAG_UNK7 = 0x0040, // 12 spells in 3.0.3, no idea - SUMMON_FLAG_UNK8 = 0x0080, // 4 spells in 3.0.3, no idea - SUMMON_FLAG_UNK9 = 0x0100, // 51 spells in 3.0.3, no idea, many quest related - SUMMON_FLAG_UNK10 = 0x0200, // 51 spells in 3.0.3, something defensive - SUMMON_FLAG_UNK11 = 0x0400, // 3 spells, requires something near? - SUMMON_FLAG_UNK12 = 0x0800, // 30 spells in 3.0.3, no idea - SUMMON_FLAG_UNK13 = 0x1000, // 8 spells in 3.0.3, siege vehicle - SUMMON_FLAG_UNK14 = 0x2000, // 2 spells in 3.0.3, escort? -}; -*/ -#endif - diff --git a/src/shared/Database/DBCFileLoader.h b/src/shared/Database/DBCFileLoader.h new file mode 100644 index 00000000000..13562148dfc --- /dev/null +++ b/src/shared/Database/DBCFileLoader.h @@ -0,0 +1,107 @@ +/* + * Copyright (C) 2005-2009 MaNGOS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef DBC_FILE_LOADER_H +#define DBC_FILE_LOADER_H +#include "Platform/Define.h" +#include "Utilities/ByteConverter.h" +#include + +enum +{ + FT_NA='x', //not used or unknown, 4 byte size + FT_NA_BYTE='X', //not used or unknown, byte + FT_STRING='s', //char* + FT_FLOAT='f', //float + FT_INT='i', //uint32 + FT_BYTE='b', //uint8 + FT_SORT='d', //sorted by this field, field is not included + FT_IND='n', //the same,but parsed to data + FT_LOGIC='l' //Logical (boolean) +}; + +class DBCFileLoader +{ + public: + DBCFileLoader(); + ~DBCFileLoader(); + + bool Load(const char *filename, const char *fmt); + + class Record + { + public: + float getFloat(size_t field) const + { + assert(field < file.fieldCount); + float val = *reinterpret_cast(offset+file.GetOffset(field)); + EndianConvert(val); + return val; + } + uint32 getUInt(size_t field) const + { + assert(field < file.fieldCount); + uint32 val = *reinterpret_cast(offset+file.GetOffset(field)); + EndianConvert(val); + return val; + } + uint8 getUInt8(size_t field) const + { + assert(field < file.fieldCount); + return *reinterpret_cast(offset+file.GetOffset(field)); + } + + const char *getString(size_t field) const + { + assert(field < file.fieldCount); + size_t stringOffset = getUInt(field); + assert(stringOffset < file.stringSize); + return reinterpret_cast(file.stringTable + stringOffset); + } + + private: + Record(DBCFileLoader &file_, unsigned char *offset_): offset(offset_), file(file_) {} + unsigned char *offset; + DBCFileLoader &file; + + friend class DBCFileLoader; + + }; + + // Get record by id + Record getRecord(size_t id); + /// Get begin iterator over records + + uint32 GetNumRows() const { return recordCount;} + uint32 GetCols() const { return fieldCount; } + uint32 GetOffset(size_t id) const { return (fieldsOffset != NULL && id < fieldCount) ? fieldsOffset[id] : 0; } + bool IsLoaded() {return (data!=NULL);} + char* AutoProduceData(const char* fmt, uint32& count, char**& indexTable); + char* AutoProduceStrings(const char* fmt, char* dataTable); + static uint32 GetFormatRecordSize(const char * format, int32 * index_pos = NULL); + private: + + uint32 recordSize; + uint32 recordCount; + uint32 fieldCount; + uint32 stringSize; + uint32 *fieldsOffset; + unsigned char *data; + unsigned char *stringTable; +}; +#endif diff --git a/src/shared/Database/DBCStore.h b/src/shared/Database/DBCStore.h new file mode 100644 index 00000000000..523d5c5a0b3 --- /dev/null +++ b/src/shared/Database/DBCStore.h @@ -0,0 +1,94 @@ +/* + * Copyright (C) 2005-2009 MaNGOS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef DBCSTORE_H +#define DBCSTORE_H + +#include "DBCFileLoader.h" + +template +class DBCStorage +{ + typedef std::list StringPoolList; + public: + explicit DBCStorage(const char *f) : nCount(0), fieldCount(0), fmt(f), indexTable(NULL), m_dataTable(NULL) { } + ~DBCStorage() { Clear(); } + + T const* LookupEntry(uint32 id) const { return (id>=nCount)?NULL:indexTable[id]; } + uint32 GetNumRows() const { return nCount; } + char const* GetFormat() const { return fmt; } + uint32 GetFieldCount() const { return fieldCount; } + + bool Load(char const* fn) + { + DBCFileLoader dbc; + // Check if load was sucessful, only then continue + if(!dbc.Load(fn, fmt)) + return false; + + fieldCount = dbc.GetCols(); + m_dataTable = (T*)dbc.AutoProduceData(fmt,nCount,(char**&)indexTable); + m_stringPoolList.push_back(dbc.AutoProduceStrings(fmt,(char*)m_dataTable)); + + // error in dbc file at loading if NULL + return indexTable!=NULL; + } + + bool LoadStringsFrom(char const* fn) + { + // DBC must be already loaded using Load + if(!indexTable) + return false; + + DBCFileLoader dbc; + // Check if load was successful, only then continue + if(!dbc.Load(fn, fmt)) + return false; + + m_stringPoolList.push_back(dbc.AutoProduceStrings(fmt,(char*)m_dataTable)); + + return true; + } + + void Clear() + { + if (!indexTable) + return; + + delete[] ((char*)indexTable); + indexTable = NULL; + delete[] ((char*)m_dataTable); + m_dataTable = NULL; + + while(!m_stringPoolList.empty()) + { + delete[] m_stringPoolList.front(); + m_stringPoolList.pop_front(); + } + nCount = 0; + } + + private: + uint32 nCount; + uint32 fieldCount; + char const* fmt; + T** indexTable; + T* m_dataTable; + StringPoolList m_stringPoolList; +}; +#endif diff --git a/src/shared/Database/DBCStores.cpp b/src/shared/Database/DBCStores.cpp deleted file mode 100644 index ba61b028203..00000000000 --- a/src/shared/Database/DBCStores.cpp +++ /dev/null @@ -1,719 +0,0 @@ -/* - * Copyright (C) 2005-2009 MaNGOS - * - * Copyright (C) 2008-2009 Trinity - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "DBCStores.h" -//#include "DataStore.h" -#include "Policies/SingletonImp.h" -#include "Log.h" -#include "ProgressBar.h" - -#include "DBCfmt.cpp" - -#include - -typedef std::map AreaFlagByAreaID; -typedef std::map AreaFlagByMapID; - -DBCStorage sAreaStore(AreaTableEntryfmt); -DBCStorage sAreaGroupStore(AreaGroupEntryfmt); -static AreaFlagByAreaID sAreaFlagByAreaID; -static AreaFlagByMapID sAreaFlagByMapID; // for instances without generated *.map files - -DBCStorage sAchievementStore(Achievementfmt); -DBCStorage sAchievementCriteriaStore(AchievementCriteriafmt); -DBCStorage sAreaTriggerStore(AreaTriggerEntryfmt); -DBCStorage sAuctionHouseStore(AuctionHouseEntryfmt); -DBCStorage sBankBagSlotPricesStore(BankBagSlotPricesEntryfmt); -DBCStorage sBattlemasterListStore(BattlemasterListEntryfmt); -DBCStorage sBarberShopStyleStore(BarberShopStyleEntryfmt); -DBCStorage sCharStartOutfitStore(CharStartOutfitEntryfmt); -DBCStorage sCharTitlesStore(CharTitlesEntryfmt); -DBCStorage sChatChannelsStore(ChatChannelsEntryfmt); -DBCStorage sChrClassesStore(ChrClassesEntryfmt); -DBCStorage sChrRacesStore(ChrRacesEntryfmt); -DBCStorage sCreatureDisplayInfoStore(CreatureDisplayInfofmt); -DBCStorage sCreatureFamilyStore(CreatureFamilyfmt); -DBCStorage sCreatureSpellDataStore(CreatureSpellDatafmt); -DBCStorage sCreatureTypeStore(CreatureTypefmt); -DBCStorage sCurrencyTypesStore(CurrencyTypesfmt); - -DBCStorage sDurabilityQualityStore(DurabilityQualityfmt); -DBCStorage sDurabilityCostsStore(DurabilityCostsfmt); - -DBCStorage sEmotesTextStore(EmoteEntryfmt); - -typedef std::map FactionTeamMap; -static FactionTeamMap sFactionTeamMap; -DBCStorage sFactionStore(FactionEntryfmt); -DBCStorage sFactionTemplateStore(FactionTemplateEntryfmt); - -DBCStorage sGemPropertiesStore(GemPropertiesEntryfmt); -DBCStorage sGlyphPropertiesStore(GlyphPropertiesfmt); -DBCStorage sGlyphSlotStore(GlyphSlotfmt); - -DBCStorage sGtBarberShopCostBaseStore(GtBarberShopCostBasefmt); -DBCStorage sGtCombatRatingsStore(GtCombatRatingsfmt); -DBCStorage sGtChanceToMeleeCritBaseStore(GtChanceToMeleeCritBasefmt); -DBCStorage sGtChanceToMeleeCritStore(GtChanceToMeleeCritfmt); -DBCStorage sGtChanceToSpellCritBaseStore(GtChanceToSpellCritBasefmt); -DBCStorage sGtChanceToSpellCritStore(GtChanceToSpellCritfmt); -DBCStorage sGtOCTRegenHPStore(GtOCTRegenHPfmt); -//DBCStorage sGtOCTRegenMPStore(GtOCTRegenMPfmt); -- not used currently -DBCStorage sGtRegenHPPerSptStore(GtRegenHPPerSptfmt); -DBCStorage sGtRegenMPPerSptStore(GtRegenMPPerSptfmt); -DBCStorage sHolidaysStore(Holidaysfmt); -DBCStorage sItemStore(Itemfmt); -DBCStorage sItemBagFamilyStore(ItemBagFamilyfmt); -//DBCStorage sItemCondExtCostsStore(ItemCondExtCostsEntryfmt); -//DBCStorage sItemDisplayInfoStore(ItemDisplayTemplateEntryfmt); -- not used currently -DBCStorage sItemExtendedCostStore(ItemExtendedCostEntryfmt); -DBCStorage sItemLimitCategoryStore(ItemLimitCategoryEntryfmt); -DBCStorage sItemRandomPropertiesStore(ItemRandomPropertiesfmt); -DBCStorage sItemRandomSuffixStore(ItemRandomSuffixfmt); -DBCStorage sItemSetStore(ItemSetEntryfmt); - -DBCStorage sLockStore(LockEntryfmt); - -DBCStorage sMailTemplateStore(MailTemplateEntryfmt); -DBCStorage sMapStore(MapEntryfmt); - -DBCStorage sQuestSortStore(QuestSortEntryfmt); - -DBCStorage sRandomPropertiesPointsStore(RandomPropertiesPointsfmt); -DBCStorage sScalingStatDistributionStore(ScalingStatDistributionfmt); -DBCStorage sScalingStatValuesStore(ScalingStatValuesfmt); - -DBCStorage sSkillLineStore(SkillLinefmt); -DBCStorage sSkillLineAbilityStore(SkillLineAbilityfmt); - -DBCStorage sSoundEntriesStore(SoundEntriesfmt); - -DBCStorage sSpellItemEnchantmentStore(SpellItemEnchantmentfmt); -DBCStorage sSpellItemEnchantmentConditionStore(SpellItemEnchantmentConditionfmt); -DBCStorage sSpellStore(SpellEntryfmt); -SpellCategoryStore sSpellCategoryStore; -PetFamilySpellsStore sPetFamilySpellsStore; - -DBCStorage sSpellCastTimesStore(SpellCastTimefmt); -DBCStorage sSpellDurationStore(SpellDurationfmt); -DBCStorage sSpellFocusObjectStore(SpellFocusObjectfmt); -DBCStorage sSpellRadiusStore(SpellRadiusfmt); -DBCStorage sSpellRangeStore(SpellRangefmt); -DBCStorage sSpellRuneCostStore(SpellRuneCostfmt); -DBCStorage sSpellShapeshiftStore(SpellShapeshiftfmt); -DBCStorage sStableSlotPricesStore(StableSlotPricesfmt); -DBCStorage sSummonPropertiesStore(SummonPropertiesfmt); -DBCStorage sTalentStore(TalentEntryfmt); -TalentSpellPosMap sTalentSpellPosMap; -DBCStorage sTalentTabStore(TalentTabEntryfmt); - -// store absolute bit position for first rank for talent inspect -typedef std::map TalentInspectMap; -static TalentInspectMap sTalentPosInInspect; -static TalentInspectMap sTalentTabSizeInInspect; -static uint32 sTalentTabPages[12/*MAX_CLASSES*/][3]; - -DBCStorage sTaxiNodesStore(TaxiNodesEntryfmt); -TaxiMask sTaxiNodesMask; - -// DBC used only for initialization sTaxiPathSetBySource at startup. -TaxiPathSetBySource sTaxiPathSetBySource; -DBCStorage sTaxiPathStore(TaxiPathEntryfmt); - -// DBC used only for initialization sTaxiPathSetBySource at startup. -TaxiPathNodesByPath sTaxiPathNodesByPath; - -static DBCStorage sTaxiPathNodeStore(TaxiPathNodeEntryfmt); -DBCStorage sTotemCategoryStore(TotemCategoryEntryfmt); -DBCStorage sVehicleStore(VehicleEntryfmt); -DBCStorage sVehicleSeatStore(VehicleSeatEntryfmt); -DBCStorage sWorldMapAreaStore(WorldMapAreaEntryfmt); -DBCStorage sWorldSafeLocsStore(WorldSafeLocsEntryfmt); -DBCStorage sWorldMapOverlayStore(WorldMapOverlayEntryfmt); - -typedef std::list StoreProblemList; - -static bool LoadDBC_assert_print(uint32 fsize,uint32 rsize, const std::string& filename) -{ - sLog.outError("ERROR: Size of '%s' setted by format string (%u) not equal size of C++ structure (%u).",filename.c_str(),fsize,rsize); - - // assert must fail after function call - return false; -} - -template -inline void LoadDBC(uint32& availableDbcLocales,barGoLink& bar, StoreProblemList& errlist, DBCStorage& storage, const std::string& dbc_path, const std::string& filename) -{ - // compatibility format and C++ structure sizes - assert(DBCFile::GetFormatRecordSize(storage.GetFormat()) == sizeof(T) || LoadDBC_assert_print(DBCFile::GetFormatRecordSize(storage.GetFormat()),sizeof(T),filename)); - - std::string dbc_filename = dbc_path + filename; - if(storage.Load(dbc_filename.c_str())) - { - bar.step(); - for(uint8 i = 0; i < MAX_LOCALE; ++i) - { - if(!(availableDbcLocales & (1 << i))) - continue; - - std::string dbc_filename_loc = dbc_path + localeNames[i] + "/" + filename; - if(!storage.LoadStringsFrom(dbc_filename_loc.c_str())) - availableDbcLocales &= ~(1<DBC records - sAreaFlagByAreaID.insert(AreaFlagByAreaID::value_type(uint16(area->ID),area->exploreFlag)); - - // fill MapId->DBC records ( skip sub zones and continents ) - if(area->zone==0 && area->mapid != 0 && area->mapid != 1 && area->mapid != 530 && area->mapid != 571 ) - sAreaFlagByMapID.insert(AreaFlagByMapID::value_type(area->mapid,area->exploreFlag)); - } - } - - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sAchievementStore, dbcPath,"Achievement.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sAchievementCriteriaStore, dbcPath,"Achievement_Criteria.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sAreaTriggerStore, dbcPath,"AreaTrigger.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sAreaGroupStore, dbcPath,"AreaGroup.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sAuctionHouseStore, dbcPath,"AuctionHouse.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sBankBagSlotPricesStore, dbcPath,"BankBagSlotPrices.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sBattlemasterListStore, dbcPath,"BattlemasterList.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sBarberShopStyleStore, dbcPath,"BarberShopStyle.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sCharStartOutfitStore, dbcPath,"CharStartOutfit.dbc"); - - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sCharTitlesStore, dbcPath,"CharTitles.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sChatChannelsStore, dbcPath,"ChatChannels.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sChrClassesStore, dbcPath,"ChrClasses.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sChrRacesStore, dbcPath,"ChrRaces.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sCreatureDisplayInfoStore, dbcPath,"CreatureDisplayInfo.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sCreatureFamilyStore, dbcPath,"CreatureFamily.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sCreatureSpellDataStore, dbcPath,"CreatureSpellData.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sCreatureTypeStore, dbcPath,"CreatureType.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sCurrencyTypesStore, dbcPath,"CurrencyTypes.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sDurabilityCostsStore, dbcPath,"DurabilityCosts.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sDurabilityQualityStore, dbcPath,"DurabilityQuality.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sEmotesTextStore, dbcPath,"EmotesText.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sFactionStore, dbcPath,"Faction.dbc"); - for (uint32 i=0;iteam) - { - SimpleFactionsList &flist = sFactionTeamMap[faction->team]; - flist.push_back(i); - } - } - - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sFactionTemplateStore, dbcPath,"FactionTemplate.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGemPropertiesStore, dbcPath,"GemProperties.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGlyphPropertiesStore, dbcPath,"GlyphProperties.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGlyphSlotStore, dbcPath,"GlyphSlot.dbc"); - - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGtBarberShopCostBaseStore,dbcPath,"gtBarberShopCostBase.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGtCombatRatingsStore, dbcPath,"gtCombatRatings.dbc"); - - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGtChanceToMeleeCritBaseStore, dbcPath,"gtChanceToMeleeCritBase.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGtChanceToMeleeCritStore, dbcPath,"gtChanceToMeleeCrit.dbc"); - - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGtChanceToSpellCritBaseStore, dbcPath,"gtChanceToSpellCritBase.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGtChanceToSpellCritStore, dbcPath,"gtChanceToSpellCrit.dbc"); - - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGtOCTRegenHPStore, dbcPath,"gtOCTRegenHP.dbc"); - //LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGtOCTRegenMPStore, dbcPath,"gtOCTRegenMP.dbc"); -- not used currently - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGtRegenHPPerSptStore, dbcPath,"gtRegenHPPerSpt.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGtRegenMPPerSptStore, dbcPath,"gtRegenMPPerSpt.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sHolidaysStore, dbcPath,"Holidays.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sItemStore, dbcPath,"Item.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sItemBagFamilyStore, dbcPath,"ItemBagFamily.dbc"); - //LoadDBC(availableDbcLocales,bar,bad_dbc_files,sItemDisplayInfoStore, dbcPath,"ItemDisplayInfo.dbc"); -- not used currently - //LoadDBC(availableDbcLocales,bar,bad_dbc_files,sItemCondExtCostsStore, dbcPath,"ItemCondExtCosts.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sItemExtendedCostStore, dbcPath,"ItemExtendedCost.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sItemLimitCategoryStore, dbcPath,"ItemLimitCategory.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sItemRandomPropertiesStore,dbcPath,"ItemRandomProperties.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sItemRandomSuffixStore, dbcPath,"ItemRandomSuffix.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sItemSetStore, dbcPath,"ItemSet.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sLockStore, dbcPath,"Lock.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sMailTemplateStore, dbcPath,"MailTemplate.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sMapStore, dbcPath,"Map.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sQuestSortStore, dbcPath,"QuestSort.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sRandomPropertiesPointsStore, dbcPath,"RandPropPoints.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sScalingStatDistributionStore, dbcPath,"ScalingStatDistribution.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sScalingStatValuesStore, dbcPath,"ScalingStatValues.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSkillLineStore, dbcPath,"SkillLine.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSkillLineAbilityStore, dbcPath,"SkillLineAbility.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSoundEntriesStore, dbcPath,"SoundEntries.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSpellStore, dbcPath,"Spell.dbc"); - for(uint32 i = 1; i < sSpellStore.GetNumRows(); ++i) - { - SpellEntry const * spell = sSpellStore.LookupEntry(i); - if(spell && spell->Category) - sSpellCategoryStore[spell->Category].insert(i); - - /*// DBC not support uint64 fields but SpellEntry have SpellFamilyFlags mapped at 2 uint32 fields - // uint32 field already converted to bigendian if need, but must be swapped for correct uint64 bigendian view - #if TRINITY_ENDIAN == TRINITY_BIGENDIAN - std::swap(*((uint32*)(&spell->SpellFamilyFlags)),*(((uint32*)(&spell->SpellFamilyFlags))+1)); - #endif*/ - } - - for (uint32 j = 0; j < sSkillLineAbilityStore.GetNumRows(); ++j) - { - SkillLineAbilityEntry const *skillLine = sSkillLineAbilityStore.LookupEntry(j); - - if(!skillLine) - continue; - - SpellEntry const* spellInfo = sSpellStore.LookupEntry(skillLine->spellId); - - if(spellInfo && (spellInfo->Attributes & 0x1D0) == 0x1D0) - { - for (unsigned int i = 1; i < sCreatureFamilyStore.GetNumRows(); ++i) - { - CreatureFamilyEntry const* cFamily = sCreatureFamilyStore.LookupEntry(i); - if(!cFamily) - continue; - - if(skillLine->skillId != cFamily->skillLine[0] && skillLine->skillId != cFamily->skillLine[1]) - continue; - - sPetFamilySpellsStore[i].insert(spellInfo->Id); - } - } - } - - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSpellCastTimesStore, dbcPath,"SpellCastTimes.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSpellDurationStore, dbcPath,"SpellDuration.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSpellFocusObjectStore, dbcPath,"SpellFocusObject.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSpellItemEnchantmentStore,dbcPath,"SpellItemEnchantment.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSpellItemEnchantmentConditionStore,dbcPath,"SpellItemEnchantmentCondition.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSpellRadiusStore, dbcPath,"SpellRadius.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSpellRangeStore, dbcPath,"SpellRange.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSpellRuneCostStore, dbcPath,"SpellRuneCost.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSpellShapeshiftStore, dbcPath,"SpellShapeshiftForm.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sStableSlotPricesStore, dbcPath,"StableSlotPrices.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSummonPropertiesStore, dbcPath,"SummonProperties.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sTalentStore, dbcPath,"Talent.dbc"); - - // create talent spells set - for (unsigned int i = 0; i < sTalentStore.GetNumRows(); ++i) - { - TalentEntry const *talentInfo = sTalentStore.LookupEntry(i); - if (!talentInfo) continue; - for (int j = 0; j < MAX_TALENT_RANK; j++) - if(talentInfo->RankID[j]) - sTalentSpellPosMap[talentInfo->RankID[j]] = TalentSpellPos(i,j); - } - - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sTalentTabStore, dbcPath,"TalentTab.dbc"); - - // prepare fast data access to bit pos of talent ranks for use at inspecting - { - // fill table by amount of talent ranks and fill sTalentTabBitSizeInInspect - // store in with (row,col,talent)->size key for correct sorting by (row,col) - typedef std::map TalentBitSize; - TalentBitSize sTalentBitSize; - for(uint32 i = 1; i < sTalentStore.GetNumRows(); ++i) - { - TalentEntry const *talentInfo = sTalentStore.LookupEntry(i); - if (!talentInfo) continue; - - TalentTabEntry const *talentTabInfo = sTalentTabStore.LookupEntry( talentInfo->TalentTab ); - if(!talentTabInfo) - continue; - - // find talent rank - uint32 curtalent_maxrank = 0; - for(uint32 k = MAX_TALENT_RANK; k > 0; --k) - { - if(talentInfo->RankID[k-1]) - { - curtalent_maxrank = k; - break; - } - } - - sTalentBitSize[(talentInfo->Row<<24) + (talentInfo->Col<<16)+talentInfo->TalentID] = curtalent_maxrank; - sTalentTabSizeInInspect[talentInfo->TalentTab] += curtalent_maxrank; - } - - // now have all max ranks (and then bit amount used for store talent ranks in inspect) - for(uint32 talentTabId = 1; talentTabId < sTalentTabStore.GetNumRows(); ++talentTabId) - { - TalentTabEntry const *talentTabInfo = sTalentTabStore.LookupEntry( talentTabId ); - if(!talentTabInfo) - continue; - - // store class talent tab pages - uint32 cls = 1; - for(uint32 m=1;!(m & talentTabInfo->ClassMask) && cls < 12 /*MAX_CLASSES*/;m <<=1, ++cls) {} - - sTalentTabPages[cls][talentTabInfo->tabpage]=talentTabId; - - // add total amount bits for first rank starting from talent tab first talent rank pos. - uint32 pos = 0; - for(TalentBitSize::iterator itr = sTalentBitSize.begin(); itr != sTalentBitSize.end(); ++itr) - { - uint32 talentId = itr->first & 0xFFFF; - TalentEntry const *talentInfo = sTalentStore.LookupEntry( talentId ); - if(!talentInfo) - continue; - - if(talentInfo->TalentTab != talentTabId) - continue; - - sTalentPosInInspect[talentId] = pos; - pos+= itr->second; - } - } - } - - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sTaxiNodesStore, dbcPath,"TaxiNodes.dbc"); - - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sTaxiPathStore, dbcPath,"TaxiPath.dbc"); - for(uint32 i = 1; i < sTaxiPathStore.GetNumRows(); ++i) - if(TaxiPathEntry const* entry = sTaxiPathStore.LookupEntry(i)) - sTaxiPathSetBySource[entry->from][entry->to] = TaxiPathBySourceAndDestination(entry->ID,entry->price); - uint32 pathCount = sTaxiPathStore.GetNumRows(); - - //## TaxiPathNode.dbc ## Loaded only for initialization different structures - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sTaxiPathNodeStore, dbcPath,"TaxiPathNode.dbc"); - // Calculate path nodes count - std::vector pathLength; - pathLength.resize(pathCount); // 0 and some other indexes not used - for(uint32 i = 1; i < sTaxiPathNodeStore.GetNumRows(); ++i) - if(TaxiPathNodeEntry const* entry = sTaxiPathNodeStore.LookupEntry(i)) - { - if (pathLength[entry->path] < entry->index + 1) - pathLength[entry->path] = entry->index + 1; - } - // Set path length - sTaxiPathNodesByPath.resize(pathCount); // 0 and some other indexes not used - for(uint32 i = 1; i < sTaxiPathNodesByPath.size(); ++i) - sTaxiPathNodesByPath[i].resize(pathLength[i]); - // fill data - for(uint32 i = 1; i < sTaxiPathNodeStore.GetNumRows(); ++i) - if(TaxiPathNodeEntry const* entry = sTaxiPathNodeStore.LookupEntry(i)) - sTaxiPathNodesByPath[entry->path][entry->index] = TaxiPathNode(entry->mapid,entry->x,entry->y,entry->z,entry->actionFlag,entry->delay); - sTaxiPathNodeStore.Clear(); - - // Initialize global taxinodes mask - // include existed nodes that have at least single not spell base (scripted) path - { - std::set spellPaths; - for(uint32 i = 1; i < sSpellStore.GetNumRows (); ++i) - if(SpellEntry const* sInfo = sSpellStore.LookupEntry (i)) - for(int j=0; j < 3; ++j) - if(sInfo->Effect[j]==123 /*SPELL_EFFECT_SEND_TAXI*/) - spellPaths.insert(sInfo->EffectMiscValue[j]); - - memset(sTaxiNodesMask,0,sizeof(sTaxiNodesMask)); - for(uint32 i = 1; i < sTaxiNodesStore.GetNumRows(); ++i) - { - if(!sTaxiNodesStore.LookupEntry(i)) - continue; - - TaxiPathSetBySource::const_iterator src_i = sTaxiPathSetBySource.find(i); - if(src_i!=sTaxiPathSetBySource.end() && !src_i->second.empty()) - { - bool ok = false; - for(TaxiPathSetForSource::const_iterator dest_i = src_i->second.begin();dest_i != src_i->second.end(); ++dest_i) - { - // not spell path - if(spellPaths.find(dest_i->second.ID)==spellPaths.end()) - { - ok = true; - break; - } - } - - if(!ok) - continue; - } - - // valid taxi netowrk node - uint8 field = (uint8)((i - 1) / 32); - uint32 submask = 1<<((i-1)%32); - sTaxiNodesMask[field] |= submask; - } - } - - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sTotemCategoryStore, dbcPath,"TotemCategory.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sVehicleStore, dbcPath,"Vehicle.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sVehicleSeatStore, dbcPath,"VehicleSeat.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sWorldMapAreaStore, dbcPath,"WorldMapArea.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sWorldSafeLocsStore, dbcPath,"WorldSafeLocs.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sWorldMapOverlayStore, dbcPath,"WorldMapOverlay.dbc"); - - // error checks - if(bad_dbc_files.size() >= DBCFilesCount ) - { - sLog.outError("\nIncorrect DataDir value in Trinityd.conf or ALL required *.dbc files (%d) not found by path: %sdbc",DBCFilesCount,dataPath.c_str()); - exit(1); - } - else if(!bad_dbc_files.empty() ) - { - std::string str; - for(std::list::iterator i = bad_dbc_files.begin(); i != bad_dbc_files.end(); ++i) - str += *i + "\n"; - - sLog.outError("\nSome required *.dbc files (%u from %d) not found or not compatible:\n%s",(uint32)bad_dbc_files.size(),DBCFilesCount,str.c_str()); - exit(1); - } - - // Check loaded DBC files proper version - if( !sSpellStore.LookupEntry(62735) || // last added spell in 3.0.9 - !sMapStore.LookupEntry(624) || // last map added in 3.0.8a/3.0.9 - !sGemPropertiesStore.LookupEntry(1557) || // last gem property added in 3.0.8a/3.0.9 - !sItemExtendedCostStore.LookupEntry(2589) || // last item extended cost added in 3.0.8a/3.0.9 - !sCharTitlesStore.LookupEntry(144) || // last char title added in 3.0.8a/3.0.9 - !sAreaStore.LookupEntry(2769) || // last area (areaflag) added in 3.0.8a/3.0.9 - !sItemStore.LookupEntry(45037) ) // last client known item added in 3.0.9 - { - sLog.outError("\nYou have _outdated_ DBC files. Please extract correct versions from current using client."); - exit(1); - } - - sLog.outString(""); - sLog.outString( ">> Initialized %d data stores", DBCFilesCount ); -} - -SimpleFactionsList const* GetFactionTeamList(uint32 faction) -{ - FactionTeamMap::const_iterator itr = sFactionTeamMap.find(faction); - if(itr==sFactionTeamMap.end()) - return NULL; - return &itr->second; -} - -char* GetPetName(uint32 petfamily, uint32 dbclang) -{ - if(!petfamily) - return NULL; - CreatureFamilyEntry const *pet_family = sCreatureFamilyStore.LookupEntry(petfamily); - if(!pet_family) - return NULL; - return pet_family->Name[dbclang]?pet_family->Name[dbclang]:NULL; -} - -TalentSpellPos const* GetTalentSpellPos(uint32 spellId) -{ - TalentSpellPosMap::const_iterator itr = sTalentSpellPosMap.find(spellId); - if(itr==sTalentSpellPosMap.end()) - return NULL; - - return &itr->second; -} - -uint32 GetTalentSpellCost(uint32 spellId) -{ - if(TalentSpellPos const* pos = GetTalentSpellPos(spellId)) - return pos->rank+1; - - return 0; -} - -int32 GetAreaFlagByAreaID(uint32 area_id) -{ - AreaFlagByAreaID::iterator i = sAreaFlagByAreaID.find(area_id); - if(i == sAreaFlagByAreaID.end()) - return -1; - - return i->second; -} - -AreaTableEntry const* GetAreaEntryByAreaID(uint32 area_id) -{ - int32 areaflag = GetAreaFlagByAreaID(area_id); - if(areaflag < 0) - return NULL; - - return sAreaStore.LookupEntry(areaflag ); -} - -AreaTableEntry const* GetAreaEntryByAreaFlagAndMap(uint32 area_flag,uint32 map_id) -{ - if(area_flag) - return sAreaStore.LookupEntry(area_flag); - - if(MapEntry const* mapEntry = sMapStore.LookupEntry(map_id)) - return GetAreaEntryByAreaID(mapEntry->linked_zone); - - return NULL; -} - -uint32 GetAreaFlagByMapId(uint32 mapid) -{ - AreaFlagByMapID::iterator i = sAreaFlagByMapID.find(mapid); - if(i == sAreaFlagByMapID.end()) - return 0; - else - return i->second; -} - -uint32 GetVirtualMapForMapAndZone(uint32 mapid, uint32 zoneId) -{ - if(mapid != 530 && mapid != 571) // speed for most cases - return mapid; - - if(WorldMapAreaEntry const* wma = sWorldMapAreaStore.LookupEntry(zoneId)) - return wma->virtual_map_id >= 0 ? wma->virtual_map_id : wma->map_id; - - return mapid; -} - -ContentLevels GetContentLevelsForMapAndZone(uint32 mapid, uint32 zoneId) -{ - mapid = GetVirtualMapForMapAndZone(mapid,zoneId); - if(mapid < 2) - return CONTENT_1_60; - - MapEntry const* mapEntry = sMapStore.LookupEntry(mapid); - if(!mapEntry) - return CONTENT_1_60; - - switch(mapEntry->Expansion()) - { - default: return CONTENT_1_60; - case 1: return CONTENT_61_70; - case 2: return CONTENT_71_80; - } -} - -ChatChannelsEntry const* GetChannelEntryFor(uint32 channel_id) -{ - // not sorted, numbering index from 0 - for(uint32 i = 0; i < sChatChannelsStore.GetNumRows(); ++i) - { - ChatChannelsEntry const* ch = sChatChannelsStore.LookupEntry(i); - if(ch && ch->ChannelID == channel_id) - return ch; - } - return NULL; -} - -bool IsTotemCategoryCompatiableWith(uint32 itemTotemCategoryId, uint32 requiredTotemCategoryId) -{ - if(requiredTotemCategoryId==0) - return true; - if(itemTotemCategoryId==0) - return false; - - TotemCategoryEntry const* itemEntry = sTotemCategoryStore.LookupEntry(itemTotemCategoryId); - if(!itemEntry) - return false; - TotemCategoryEntry const* reqEntry = sTotemCategoryStore.LookupEntry(requiredTotemCategoryId); - if(!reqEntry) - return false; - - if(itemEntry->categoryType!=reqEntry->categoryType) - return false; - - return (itemEntry->categoryMask & reqEntry->categoryMask)==reqEntry->categoryMask; -} - -void Zone2MapCoordinates(float& x,float& y,uint32 zone) -{ - WorldMapAreaEntry const* maEntry = sWorldMapAreaStore.LookupEntry(zone); - - // if not listed then map coordinates (instance) - if(!maEntry) - return; - - std::swap(x,y); // at client map coords swapped - x = x*((maEntry->x2-maEntry->x1)/100)+maEntry->x1; - y = y*((maEntry->y2-maEntry->y1)/100)+maEntry->y1; // client y coord from top to down -} - -void Map2ZoneCoordinates(float& x,float& y,uint32 zone) -{ - WorldMapAreaEntry const* maEntry = sWorldMapAreaStore.LookupEntry(zone); - - // if not listed then map coordinates (instance) - if(!maEntry) - return; - - x = (x-maEntry->x1)/((maEntry->x2-maEntry->x1)/100); - y = (y-maEntry->y1)/((maEntry->y2-maEntry->y1)/100); // client y coord from top to down - std::swap(x,y); // client have map coords swapped -} - -uint32 GetTalentInspectBitPosInTab(uint32 talentId) -{ - TalentInspectMap::const_iterator itr = sTalentPosInInspect.find(talentId); - if(itr == sTalentPosInInspect.end()) - return 0; - - return itr->second; -} - -uint32 GetTalentTabInspectBitSize(uint32 talentTabId) -{ - TalentInspectMap::const_iterator itr = sTalentTabSizeInInspect.find(talentTabId); - if(itr == sTalentTabSizeInInspect.end()) - return 0; - - return itr->second; -} - -uint32 const* GetTalentTabPages(uint32 cls) -{ - return sTalentTabPages[cls]; -} - -// script support functions -TRINITY_DLL_SPEC DBCStorage const* GetSoundEntriesStore() { return &sSoundEntriesStore; } -TRINITY_DLL_SPEC DBCStorage const* GetSpellStore() { return &sSpellStore; } -TRINITY_DLL_SPEC DBCStorage const* GetSpellRangeStore() { return &sSpellRangeStore; } -TRINITY_DLL_SPEC DBCStorage const* GetFactionStore() { return &sFactionStore; } -TRINITY_DLL_SPEC DBCStorage const* GetItemDisplayStore() { return &sItemStore; } -TRINITY_DLL_SPEC DBCStorage const* GetCreatureDisplayStore() { return &sCreatureDisplayInfoStore; } diff --git a/src/shared/Database/DBCStores.h b/src/shared/Database/DBCStores.h deleted file mode 100644 index 3e8d3280596..00000000000 --- a/src/shared/Database/DBCStores.h +++ /dev/null @@ -1,230 +0,0 @@ -/* - * Copyright (C) 2005-2009 MaNGOS - * - * Copyright (C) 2008-2009 Trinity - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef DBCSTORES_H -#define DBCSTORES_H - -#include "Common.h" -//#include "DataStore.h" -#include "dbcfile.h" -#include "DBCStructure.h" - -#include - -typedef std::list SimpleFactionsList; - -SimpleFactionsList const* GetFactionTeamList(uint32 faction); -char* GetPetName(uint32 petfamily, uint32 dbclang); -uint32 GetTalentSpellCost(uint32 spellId); -TalentSpellPos const* GetTalentSpellPos(uint32 spellId); - -int32 GetAreaFlagByAreaID(uint32 area_id); // -1 if not found -AreaTableEntry const* GetAreaEntryByAreaID(uint32 area_id); -AreaTableEntry const* GetAreaEntryByAreaFlagAndMap(uint32 area_flag,uint32 map_id); -uint32 GetAreaFlagByMapId(uint32 mapid); - -uint32 GetVirtualMapForMapAndZone(uint32 mapid, uint32 zoneId); - -enum ContentLevels -{ - CONTENT_1_60 = 0, - CONTENT_61_70, - CONTENT_71_80 -}; -ContentLevels GetContentLevelsForMapAndZone(uint32 mapid, uint32 zoneId); - -ChatChannelsEntry const* GetChannelEntryFor(uint32 channel_id); - -bool IsTotemCategoryCompatiableWith(uint32 itemTotemCategoryId, uint32 requiredTotemCategoryId); - -void Zone2MapCoordinates(float& x,float& y,uint32 zone); -void Map2ZoneCoordinates(float& x,float& y,uint32 zone); - -uint32 GetTalentInspectBitPosInTab(uint32 talentId); -uint32 GetTalentTabInspectBitSize(uint32 talentTabId); -uint32 const* /*[3]*/ GetTalentTabPages(uint32 cls); - -template -class DBCStorage -{ - typedef std::list StringPoolList; - public: - explicit DBCStorage(const char *f) : nCount(0), fieldCount(0), fmt(f), indexTable(NULL), m_dataTable(NULL) { } - ~DBCStorage() { Clear(); } - - T const* LookupEntry(uint32 id) const { return (id>=nCount)?NULL:indexTable[id]; } - uint32 GetNumRows() const { return nCount; } - char const* GetFormat() const { return fmt; } - uint32 GetFieldCount() const { return fieldCount; } - - bool Load(char const* fn) - { - DBCFile dbc; - // Check if load was sucessful, only then continue - if(!dbc.Load(fn, fmt)) - return false; - - fieldCount = dbc.GetCols(); - m_dataTable = (T*)dbc.AutoProduceData(fmt,nCount,(char**&)indexTable); - m_stringPoolList.push_back(dbc.AutoProduceStrings(fmt,(char*)m_dataTable)); - - // error in dbc file at loading if NULL - return indexTable!=NULL; - } - - bool LoadStringsFrom(char const* fn) - { - // DBC must be already loaded using Load - if(!indexTable) - return false; - - DBCFile dbc; - // Check if load was successful, only then continue - if(!dbc.Load(fn, fmt)) - return false; - - m_stringPoolList.push_back(dbc.AutoProduceStrings(fmt,(char*)m_dataTable)); - - return true; - } - - void Clear() - { - if (!indexTable) - return; - - delete[] ((char*)indexTable); - indexTable = NULL; - delete[] ((char*)m_dataTable); - m_dataTable = NULL; - - while(!m_stringPoolList.empty()) - { - delete[] m_stringPoolList.front(); - m_stringPoolList.pop_front(); - } - nCount = 0; - } - - private: - uint32 nCount; - uint32 fieldCount; - char const* fmt; - T** indexTable; - T* m_dataTable; - StringPoolList m_stringPoolList; -}; - -extern DBCStorage sAchievementStore; -extern DBCStorage sAchievementCriteriaStore; -extern DBCStorage sAreaStore;// recommend access using functions -extern DBCStorage sAreaGroupStore; -extern DBCStorage sAreaTriggerStore; -extern DBCStorage sAuctionHouseStore; -extern DBCStorage sBankBagSlotPricesStore; -extern DBCStorage sBarberShopStyleStore; -extern DBCStorage sBattlemasterListStore; -//extern DBCStorage sChatChannelsStore; -- accessed using function, no usable index -extern DBCStorage sCharStartOutfitStore; -extern DBCStorage sCharTitlesStore; -extern DBCStorage sChrClassesStore; -extern DBCStorage sChrRacesStore; -extern DBCStorage sCreatureDisplayInfoStore; -extern DBCStorage sCreatureFamilyStore; -extern DBCStorage sCreatureSpellDataStore; -extern DBCStorage sCreatureTypeStore; -extern DBCStorage sCurrencyTypesStore; -extern DBCStorage sDurabilityCostsStore; -extern DBCStorage sDurabilityQualityStore; -extern DBCStorage sEmotesTextStore; -extern DBCStorage sFactionStore; -extern DBCStorage sFactionTemplateStore; -extern DBCStorage sGemPropertiesStore; -extern DBCStorage sGlyphPropertiesStore; -extern DBCStorage sGlyphSlotStore; - -extern DBCStorage sGtBarberShopCostBaseStore; -extern DBCStorage sGtCombatRatingsStore; -extern DBCStorage sGtChanceToMeleeCritBaseStore; -extern DBCStorage sGtChanceToMeleeCritStore; -extern DBCStorage sGtChanceToSpellCritBaseStore; -extern DBCStorage sGtChanceToSpellCritStore; -extern DBCStorage sGtOCTRegenHPStore; -//extern DBCStorage sGtOCTRegenMPStore; -- not used currently -extern DBCStorage sGtRegenHPPerSptStore; -extern DBCStorage sGtRegenMPPerSptStore; -extern DBCStorage sHolidaysStore; -extern DBCStorage sItemStore; -extern DBCStorage sItemBagFamilyStore; -//extern DBCStorage sItemDisplayInfoStore; -- not used currently -extern DBCStorage sItemExtendedCostStore; -extern DBCStorage sItemLimitCategoryStore; -extern DBCStorage sItemRandomPropertiesStore; -extern DBCStorage sItemRandomSuffixStore; -extern DBCStorage sItemSetStore; -extern DBCStorage sLockStore; -extern DBCStorage sMailTemplateStore; -extern DBCStorage sMapStore; -extern DBCStorage sQuestSortStore; -extern DBCStorage sRandomPropertiesPointsStore; -extern DBCStorage sScalingStatDistributionStore; -extern DBCStorage sScalingStatValuesStore; -extern DBCStorage sSkillLineStore; -extern DBCStorage sSkillLineAbilityStore; -extern DBCStorage sSoundEntriesStore; -extern DBCStorage sSpellCastTimesStore; -extern DBCStorage sSpellDurationStore; -extern DBCStorage sSpellFocusObjectStore; -extern DBCStorage sSpellItemEnchantmentStore; -extern DBCStorage sSpellItemEnchantmentConditionStore; -extern SpellCategoryStore sSpellCategoryStore; -extern PetFamilySpellsStore sPetFamilySpellsStore; -extern DBCStorage sSpellRadiusStore; -extern DBCStorage sSpellRangeStore; -extern DBCStorage sSpellRuneCostStore; -extern DBCStorage sSpellShapeshiftStore; -extern DBCStorage sSpellStore; -extern DBCStorage sStableSlotPricesStore; -extern DBCStorage sSummonPropertiesStore; -extern DBCStorage sTalentStore; -extern DBCStorage sTalentTabStore; -extern DBCStorage sTaxiNodesStore; -extern DBCStorage sTaxiPathStore; -extern TaxiMask sTaxiNodesMask; -extern TaxiPathSetBySource sTaxiPathSetBySource; -extern TaxiPathNodesByPath sTaxiPathNodesByPath; -extern DBCStorage sTotemCategoryStore; -extern DBCStorage sVehicleStore; -extern DBCStorage sVehicleSeatStore; -//extern DBCStorage sWorldMapAreaStore; -- use Zone2MapCoordinates and Map2ZoneCoordinates -extern DBCStorage sWorldSafeLocsStore; -extern DBCStorage sWorldMapOverlayStore; - -void LoadDBCStores(const std::string& dataPath); - -// script support functions -TRINITY_DLL_SPEC DBCStorage const* GetSoundEntriesStore(); -TRINITY_DLL_SPEC DBCStorage const* GetSpellStore(); -TRINITY_DLL_SPEC DBCStorage const* GetSpellRangeStore(); -TRINITY_DLL_SPEC DBCStorage const* GetFactionStore(); -TRINITY_DLL_SPEC DBCStorage const* GetItemDisplayStore(); -TRINITY_DLL_SPEC DBCStorage const* GetCreatureDisplayStore(); -#endif - diff --git a/src/shared/Database/DBCStructure.h b/src/shared/Database/DBCStructure.h deleted file mode 100644 index 32f78faa509..00000000000 --- a/src/shared/Database/DBCStructure.h +++ /dev/null @@ -1,1675 +0,0 @@ -/* - * Copyright (C) 2005-2009 MaNGOS - * - * Copyright (C) 2008-2009 Trinity - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef DBCSTRUCTURE_H -#define DBCSTRUCTURE_H - -#include "DBCEnums.h" -#include "Platform/Define.h" -#include "Util.h" - -#include -#include -#include - -// Structures using to access raw DBC data and required packing to portability - -// GCC have alternative #pragma pack(N) syntax and old gcc version not support pack(push,N), also any gcc version not support it at some platform -#if defined( __GNUC__ ) -#pragma pack(1) -#else -#pragma pack(push,1) -#endif - -struct AchievementEntry -{ - uint32 ID; // 0 - uint32 factionFlag; // 1 -1=all, 0=horde, 1=alliance - uint32 mapID; // 2 -1=none - //uint32 parentAchievement; // 3 its Achievement parent (can`t start while parent uncomplete, use its Criteria if don`t have own, use its progress on begin) - //char *name[16]; // 4-19 - //uint32 name_flags; // 20 - //char *description[16]; // 21-36 - //uint32 desc_flags; // 37 - uint32 categoryId; // 38 - uint32 points; // 39 reward points - //uint32 OrderInCategory; // 40 - uint32 flags; // 41 - //uint32 icon; // 42 icon (from SpellIcon.dbc) - //char *titleReward[16]; // 43-58 - //uint32 titleReward_flags; // 59 - //uint32 count; // 60 - need this count Criteria for complete - uint32 refAchievement; // 61 - related achievement? -}; - -struct AchievementCategoryEntry -{ - uint32 ID; // 0 - uint32 parentCategory; // 1 -1 for main category - //char *name[16]; // 2-17 - //uint32 name_flags; // 18 - //uint32 sortOrder; // 19 -}; - -struct AchievementCriteriaEntry -{ - uint32 ID; // 0 - uint32 referredAchievement; // 1 - uint32 requiredType; // 2 - union - { - // ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE = 0 - // TODO: also used for player deaths.. - struct - { - uint32 creatureID; // 3 - uint32 creatureCount; // 4 - } kill_creature; - - // ACHIEVEMENT_CRITERIA_TYPE_WIN_BG = 1 - // TODO: there are further criterias instead just winning - struct - { - uint32 bgMapID; // 3 - uint32 winCount; // 4 - } win_bg; - - // ACHIEVEMENT_CRITERIA_TYPE_REACH_LEVEL = 5 - struct - { - uint32 unused; // 3 - uint32 level; // 4 - } reach_level; - - // ACHIEVEMENT_CRITERIA_TYPE_REACH_SKILL_LEVEL = 7 - struct - { - uint32 skillID; // 3 - uint32 skillLevel; // 4 - } reach_skill_level; - - // ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_ACHIEVEMENT = 8 - struct - { - uint32 linkedAchievement; // 3 - } complete_achievement; - - // ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUEST_COUNT = 9 - struct - { - uint32 unused; // 3 - uint32 totalQuestCount; // 4 - } complete_quest_count; - - // ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_DAILY_QUEST_DAILY = 10 - struct - { - uint32 unused; // 3 - uint32 numberOfDays; // 4 - } complete_daily_quest_daily; - - // ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUESTS_IN_ZONE = 11 - struct - { - uint32 zoneID; // 3 - uint32 questCount; // 4 - } complete_quests_in_zone; - - // ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_DAILY_QUEST = 14 - struct - { - uint32 unused; // 3 - uint32 questCount; // 4 - } complete_daily_quest; - - // ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_BATTLEGROUND = 15 - struct - { - uint32 mapID; // 3 - } complete_battleground; - - // ACHIEVEMENT_CRITERIA_TYPE_DEATH_AT_MAP = 16 - struct - { - uint32 mapID; // 3 - } death_at_map; - - // ACHIEVEMENT_CRITERIA_TYPE_DEATH_IN_DUNGEON = 18 - struct - { - uint32 manLimit; // 3 - } death_in_dungeon; - - // ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_RAID = 19 - struct - { - uint32 groupSize; // 3 can be 5, 10 or 25 - } complete_raid; - - // ACHIEVEMENT_CRITERIA_TYPE_KILLED_BY_CREATURE = 20 - struct - { - uint32 creatureEntry; // 3 - } killed_by_creature; - - // ACHIEVEMENT_CRITERIA_TYPE_FALL_WITHOUT_DYING = 24 - struct - { - uint32 unused; // 3 - uint32 fallHeight; // 4 - } fall_without_dying; - - // ACHIEVEMENT_CRITERIA_TYPE_DEATHS_FROM = 26 - struct - { - uint32 type; // 3, see enum EnviromentalDamage - } death_from; - - // ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUEST = 27 - struct - { - uint32 questID; // 3 - uint32 questCount; // 4 - } complete_quest; - - // ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET = 28 - // ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET2 = 69 - struct - { - uint32 spellID; // 3 - uint32 spellCount; // 4 - } be_spell_target; - - // ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL = 29 - // ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL2 = 110 - struct - { - uint32 spellID; // 3 - uint32 castCount; // 4 - } cast_spell; - - // ACHIEVEMENT_CRITERIA_TYPE_HONORABLE_KILL_AT_AREA = 31 - struct - { - uint32 areaID; // 3 Reference to AreaTable.dbc - uint32 killCount; // 4 - } honorable_kill_at_area; - - // ACHIEVEMENT_CRITERIA_TYPE_WIN_ARENA = 32 - struct - { - uint32 mapID; // 3 Reference to Map.dbc - } win_arena; - - // ACHIEVEMENT_CRITERIA_TYPE_PLAY_ARENA = 33 - struct - { - uint32 mapID; // 3 Reference to Map.dbc - } play_arena; - - // ACHIEVEMENT_CRITERIA_TYPE_LEARN_SPELL = 34 - struct - { - uint32 spellID; // 3 Reference to Map.dbc - } learn_spell; - - // ACHIEVEMENT_CRITERIA_TYPE_OWN_ITEM = 36 - struct - { - uint32 itemID; // 3 - uint32 itemCount; // 4 - } own_item; - - // ACHIEVEMENT_CRITERIA_TYPE_WIN_RATED_ARENA = 37 - struct - { - uint32 unused; // 3 - uint32 count; // 4 - uint32 flag; // 5 4=in a row - } win_rated_arena; - - // ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_TEAM_RATING = 38 - struct - { - uint32 teamtype; // 3 {2,3,5} - } highest_team_rating; - - // ACHIEVEMENT_CRITERIA_TYPE_REACH_TEAM_RATING = 39 - struct - { - uint32 teamtype; // 3 {2,3,5} - uint32 teamrating; // 4 - } reach_team_rating; - - // ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LEVEL = 40 - struct - { - uint32 skillID; // 3 - uint32 skillLevel; // 4 apprentice=1, journeyman=2, expert=3, artisan=4, master=5, grand master=6 - } learn_skill_level; - - // ACHIEVEMENT_CRITERIA_TYPE_USE_ITEM = 41 - struct - { - uint32 itemID; // 3 - uint32 itemCount; // 4 - } use_item; - - // ACHIEVEMENT_CRITERIA_TYPE_LOOT_ITEM = 42 - struct - { - uint32 itemID; // 3 - uint32 itemCount; // 4 - } loot_item; - - // ACHIEVEMENT_CRITERIA_TYPE_EXPLORE_AREA = 43 - struct - { - // TODO: This rank is _NOT_ the index from AreaTable.dbc - uint32 areaReference; // 3 - } explore_area; - - // ACHIEVEMENT_CRITERIA_TYPE_OWN_RANK = 44 - struct - { - // TODO: This rank is _NOT_ the index from CharTitles.dbc - uint32 rank; // 3 - } own_rank; - - // ACHIEVEMENT_CRITERIA_TYPE_BUY_BANK_SLOT = 45 - struct - { - uint32 unused; // 3 - uint32 numberOfSlots; // 4 - } buy_bank_slot; - - // ACHIEVEMENT_CRITERIA_TYPE_GAIN_REPUTATION = 46 - struct - { - uint32 factionID; // 3 - uint32 reputationAmount; // 4 Total reputation amount, so 42000 = exalted - } gain_reputation; - - // ACHIEVEMENT_CRITERIA_TYPE_GAIN_EXALTED_REPUTATION= 47 - struct - { - uint32 unused; // 3 - uint32 numberOfExaltedFactions; // 4 - } gain_exalted_reputation; - - // ACHIEVEMENT_CRITERIA_TYPE_VISIT_BARBER_SHOP = 48 - struct - { - uint32 unused; // 3 - uint32 numberOfVisits; // 4 - } visit_barber; - - // ACHIEVEMENT_CRITERIA_TYPE_EQUIP_EPIC_ITEM = 49 - // TODO: where is the required itemlevel stored? - struct - { - uint32 itemSlot; // 3 - } equip_epic_item; - - // ACHIEVEMENT_CRITERIA_TYPE_ROLL_NEED_ON_LOOT = 50 - struct - { - uint32 rollValue; // 3 - uint32 count; // 4 - } roll_need_on_loot; - // ACHIEVEMENT_CRITERIA_TYPE_ROLL_GREED_ON_LOOT = 51 - struct - { - uint32 rollValue; // 3 - uint32 count; // 4 - } roll_greed_on_loot; - - // ACHIEVEMENT_CRITERIA_TYPE_HK_CLASS = 52 - struct - { - uint32 classID; // 3 - uint32 count; // 4 - } hk_class; - - // ACHIEVEMENT_CRITERIA_TYPE_HK_RACE = 53 - struct - { - uint32 raceID; // 3 - uint32 count; // 4 - } hk_race; - - // ACHIEVEMENT_CRITERIA_TYPE_DO_EMOTE = 54 - // TODO: where is the information about the target stored? - struct - { - uint32 emoteID; // 3 enum TextEmotes - uint32 count; // 4 count of emotes, always required special target or requirements - } do_emote; - // ACHIEVEMENT_CRITERIA_TYPE_DAMAGE_DONE = 13 - // ACHIEVEMENT_CRITERIA_TYPE_HEALING_DONE = 55 - // ACHIEVEMENT_CRITERIA_TYPE_GET_KILLING_BLOWS = 56 - struct - { - uint32 unused; // 3 - uint32 count; // 4 - uint32 flag; // 5 =3 for battleground healing - uint32 mapid; // 6 - } healing_done; - - // ACHIEVEMENT_CRITERIA_TYPE_EQUIP_ITEM = 57 - struct - { - uint32 itemID; // 3 - uint32 count; // 4 - } equip_item; - - // ACHIEVEMENT_CRITERIA_TYPE_MONEY_FROM_QUEST_REWARD= 62 - struct - { - uint32 unused; // 3 - uint32 goldInCopper; // 4 - } quest_reward_money; - - - // ACHIEVEMENT_CRITERIA_TYPE_LOOT_MONEY = 67 - struct - { - uint32 unused; // 3 - uint32 goldInCopper; // 4 - } loot_money; - - // ACHIEVEMENT_CRITERIA_TYPE_USE_GAMEOBJECT = 68 - struct - { - uint32 goEntry; // 3 - uint32 useCount; // 4 - } use_gameobject; - - // ACHIEVEMENT_CRITERIA_TYPE_SPECIAL_PVP_KILL = 70 - // TODO: are those special criteria stored in the dbc or do we have to add another sql table? - struct - { - uint32 unused; // 3 - uint32 killCount; // 4 - } special_pvp_kill; - - // ACHIEVEMENT_CRITERIA_TYPE_FISH_IN_GAMEOBJECT = 72 - struct - { - uint32 goEntry; // 3 - uint32 lootCount; // 4 - } fish_in_gameobject; - - // ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILLLINE_SPELLS = 75 - struct - { - uint32 skillLine; // 3 - uint32 spellCount; // 4 - } learn_skilline_spell; - - // ACHIEVEMENT_CRITERIA_TYPE_WIN_DUEL = 76 - struct - { - uint32 unused; // 3 - uint32 duelCount; // 4 - } win_duel; - - // ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_POWER = 96 - struct - { - uint32 powerType; // 3 mana=0, 1=rage, 3=energy, 6=runic power - } highest_power; - - // ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_STAT = 97 - struct - { - uint32 statType; // 3 4=spirit, 3=int, 2=stamina, 1=agi, 0=strength - } highest_stat; - - // ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_SPELLPOWER = 98 - struct - { - uint32 spellSchool; // 3 - } highest_spellpower; - - // ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_RATING = 100 - struct - { - uint32 ratingType; // 3 - } highest_rating; - - // ACHIEVEMENT_CRITERIA_TYPE_LOOT_TYPE = 109 - struct - { - uint32 lootType; // 3 3=fishing, 2=pickpocket, 4=disentchant - uint32 lootTypeCount; // 4 - } loot_type; - - // ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LINE = 112 - struct - { - uint32 skillLine; // 3 - uint32 spellCount; // 4 - } learn_skill_line; - - // ACHIEVEMENT_CRITERIA_TYPE_EARN_HONORABLE_KILL = 113 - struct - { - uint32 unused; // 3 - uint32 killCount; // 4 - } honorable_kill; - - struct - { - uint32 field3; // 3 main requirement - uint32 field4; // 4 main requirement count - uint32 additionalRequirement1_type; // 5 additional requirement 1 type - uint32 additionalRequirement1_value; // 6 additional requirement 1 value - uint32 additionalRequirement2_type; // 7 additional requirement 2 type - uint32 additionalRequirement2_value; // 8 additional requirement 1 value - } raw; - }; - //char* name[16]; // 9-24 - //uint32 name_flags; // 25 - uint32 completionFlag; // 26 - uint32 groupFlag; // 27 - //uint32 unk1; // 28 - uint32 timeLimit; // 29 time limit in seconds - //uint32 showOrder; // 30 show order -}; - -struct AreaTableEntry -{ - uint32 ID; // 0 - uint32 mapid; // 1 - uint32 zone; // 2 if 0 then it's zone, else it's zone id of this area - uint32 exploreFlag; // 3, main index - uint32 flags; // 4, unknown value but 312 for all cities - // 5-9 unused - int32 area_level; // 10 - char* area_name[16]; // 11-26 - // 27, string flags, unused - uint32 team; // 28 -}; - -struct AreaGroupEntry -{ - uint32 AreaGroupId; // 0 - uint32 AreaId[7]; // 1-7 -}; - -struct AreaTriggerEntry -{ - uint32 id; // 0 m_ID - uint32 mapid; // 1 m_ContinentID - float x; // 2 m_x - float y; // 3 m_y - float z; // 4 m_z - float radius; // 5 m_radius - float box_x; // 6 m_box_length - float box_y; // 7 m_box_width - float box_z; // 8 m_box_heigh - float box_orientation; // 9 m_box_yaw -}; - -struct AuctionHouseEntry -{ - uint32 houseId; // 0 index - uint32 faction; // 1 id of faction.dbc for player factions associated with city - uint32 depositPercent; // 2 1/3 from real - uint32 cutPercent; // 3 - //char* name[16]; // 4-19 - // 20 string flag, unused -}; - -struct BankBagSlotPricesEntry -{ - uint32 ID; - uint32 price; -}; - -struct BarberShopStyleEntry -{ - uint32 Id; // 0 - uint32 type; // 1 value 0 -> hair, value 2 -> facialhair - //char* name[16]; // 2-17 name of hair style - //uint32 name_flags; // 18 - //uint32 unk_name[16]; // 19-34, all empty - //uint32 unk_flags; // 35 - //float CostMultiplier; // 36 values 1 and 0.75 - uint32 race; // 37 race - uint32 gender; // 38 0 -> male, 1 -> female - uint32 hair_id; // 39 real ID to hair/facial hair -}; - -struct BattlemasterListEntry -{ - uint32 id; // 0 - int32 mapid[8]; // 1-8 mapid - uint32 type; // 9 (3 - BG, 4 - arena) - uint32 minlvl; // 10 - uint32 maxlvl; // 11 - uint32 maxplayersperteam; // 12 - // 13 minplayers - // 14 0 or 9 - // 15 - char* name[16]; // 16-31 - // 32 string flag, unused - // 33 unused -}; - -#define MAX_OUTFIT_ITEMS 24 - -struct CharStartOutfitEntry -{ - //uint32 Id; // 0 - uint32 RaceClassGender; // 1 (UNIT_FIELD_BYTES_0 & 0x00FFFFFF) comparable (0 byte = race, 1 byte = class, 2 byte = gender) - int32 ItemId[MAX_OUTFIT_ITEMS]; // 2-13 - //int32 ItemDisplayId[MAX_OUTFIT_ITEMS]; // 14-25 not required at server side - //int32 ItemInventorySlot[MAX_OUTFIT_ITEMS]; // 26-37 not required at server side - //uint32 Unknown1; // 38, unique values (index-like with gaps ordered in other way as ids) - //uint32 Unknown2; // 39 - //uint32 Unknown3; // 40 -}; - -struct CharTitlesEntry -{ - uint32 ID; // 0, title ids, for example in Quest::GetCharTitleId() - //uint32 unk1; // 1 flags? - //char* name[16]; // 2-17, unused - // 18 string flag, unused - //char* name2[16]; // 19-34, unused - // 35 string flag, unused - uint32 bit_index; // 36 used in PLAYER_CHOSEN_TITLE and 1<