mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-22 05:06:24 +00:00
feat(Core/DBC): rework load DBC (#3002)
* Move DBC load system from TC * Add db tables for all dbc * Support override data from db * Support override spells from db (#2994)
This commit is contained in:
129
src/server/shared/DataStores/DBCDatabaseLoader.cpp
Normal file
129
src/server/shared/DataStores/DBCDatabaseLoader.cpp
Normal file
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU GPL v2 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-GPL2
|
||||
* Copyright (C) 2008-2020 TrinityCore <http://www.trinitycore.org/>
|
||||
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
|
||||
*/
|
||||
|
||||
#include "DBCDatabaseLoader.h"
|
||||
#include "Common.h"
|
||||
#include "DatabaseEnv.h"
|
||||
#include "Errors.h"
|
||||
#include "Log.h"
|
||||
#include "StringFormat.h"
|
||||
#include <sstream>
|
||||
|
||||
DBCDatabaseLoader::DBCDatabaseLoader(char const* tableName, char const* dbcFormatString, std::vector<char*>& stringPool)
|
||||
: _sqlTableName(tableName),
|
||||
_dbcFormat(dbcFormatString),
|
||||
_sqlIndexPos(0),
|
||||
_recordSize(0),
|
||||
_stringPool(stringPool)
|
||||
{
|
||||
// Get sql index position
|
||||
int32 indexPos = -1;
|
||||
_recordSize = DBCFileLoader::GetFormatRecordSize(_dbcFormat, &indexPos);
|
||||
|
||||
ASSERT(_recordSize);
|
||||
}
|
||||
|
||||
char* DBCDatabaseLoader::Load(uint32& records, char**& indexTable)
|
||||
{
|
||||
std::string query = acore::StringFormat("SELECT * FROM `%s` ORDER BY `ID` DESC", _sqlTableName);
|
||||
|
||||
// no error if empty set
|
||||
QueryResult result = WorldDatabase.Query(query.c_str());
|
||||
if (!result)
|
||||
return nullptr;
|
||||
|
||||
// Check if sql index pos is valid
|
||||
if (int32(result->GetFieldCount() - 1) < _sqlIndexPos)
|
||||
{
|
||||
ASSERT(false, "Invalid index pos for dbc: '%s'", _sqlTableName);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Resize index table
|
||||
// database query *MUST* contain ORDER BY `index_field` DESC clause
|
||||
uint32 indexTableSize = std::max(records, (*result)[_sqlIndexPos].GetUInt32() + 1);
|
||||
if (indexTableSize > records)
|
||||
{
|
||||
char** tmpIdxTable = new char*[indexTableSize];
|
||||
memset(tmpIdxTable, 0, indexTableSize * sizeof(char*));
|
||||
memcpy(tmpIdxTable, indexTable, records * sizeof(char*));
|
||||
delete[] indexTable;
|
||||
indexTable = tmpIdxTable;
|
||||
}
|
||||
|
||||
std::unique_ptr<char[]> dataTable = std::make_unique<char[]>(result->GetRowCount() * _recordSize);
|
||||
std::unique_ptr<uint32[]> newIndexes = std::make_unique<uint32[]>(result->GetRowCount());
|
||||
uint32 newRecords = 0;
|
||||
|
||||
// Insert sql data into the data array
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
uint32 indexValue = fields[_sqlIndexPos].GetUInt32();
|
||||
char* dataValue = indexTable[indexValue];
|
||||
|
||||
// If exist in DBC file override from DB
|
||||
newIndexes[newRecords] = indexValue;
|
||||
dataValue = &dataTable[newRecords++ * _recordSize];
|
||||
|
||||
uint32 dataOffset = 0;
|
||||
uint32 sqlColumnNumber = 0;
|
||||
char const* dbcFormat = _dbcFormat;
|
||||
|
||||
for (; (*dbcFormat); ++dbcFormat)
|
||||
{
|
||||
switch (*dbcFormat)
|
||||
{
|
||||
case FT_FLOAT:
|
||||
*reinterpret_cast<float*>(&dataValue[dataOffset]) = fields[sqlColumnNumber].GetFloat();
|
||||
dataOffset += sizeof(float);
|
||||
break;
|
||||
case FT_IND:
|
||||
case FT_INT:
|
||||
*reinterpret_cast<uint32*>(&dataValue[dataOffset]) = fields[sqlColumnNumber].GetUInt32();
|
||||
dataOffset += sizeof(uint32);
|
||||
break;
|
||||
case FT_BYTE:
|
||||
*reinterpret_cast<uint8*>(&dataValue[dataOffset]) = fields[sqlColumnNumber].GetUInt8();
|
||||
dataOffset += sizeof(uint8);
|
||||
break;
|
||||
case FT_STRING:
|
||||
*reinterpret_cast<char**>(&dataValue[dataOffset]) = CloneStringToPool(fields[sqlColumnNumber].GetString());
|
||||
dataOffset += sizeof(char*);
|
||||
break;
|
||||
case FT_SORT:
|
||||
case FT_NA:
|
||||
break;
|
||||
default:
|
||||
ASSERT(false, "Unsupported data type '%c' in table '%s'", *dbcFormat, _sqlTableName);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
++sqlColumnNumber;
|
||||
}
|
||||
|
||||
ASSERT(sqlColumnNumber == result->GetFieldCount(), "SQL format string does not match database for table: '%s'", _sqlTableName);
|
||||
ASSERT(dataOffset == _recordSize);
|
||||
} while (result->NextRow());
|
||||
|
||||
ASSERT(newRecords == result->GetRowCount());
|
||||
|
||||
// insert new records to index table
|
||||
for (uint32 i = 0; i < newRecords; ++i)
|
||||
indexTable[newIndexes[i]] = &dataTable[i * _recordSize];
|
||||
|
||||
records = indexTableSize;
|
||||
|
||||
return dataTable.release();
|
||||
}
|
||||
|
||||
char* DBCDatabaseLoader::CloneStringToPool(std::string const& str)
|
||||
{
|
||||
char* buf = new char[str.size() + 1];
|
||||
memcpy(buf, str.c_str(), str.size() + 1);
|
||||
_stringPool.push_back(buf);
|
||||
return buf;
|
||||
}
|
||||
32
src/server/shared/DataStores/DBCDatabaseLoader.h
Normal file
32
src/server/shared/DataStores/DBCDatabaseLoader.h
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU GPL v2 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-GPL2
|
||||
* Copyright (C) 2008-2020 TrinityCore <http://www.trinitycore.org/>
|
||||
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
|
||||
*/
|
||||
|
||||
#ifndef DBCDatabaseLoader_h__
|
||||
#define DBCDatabaseLoader_h__
|
||||
|
||||
#include "DBCFileLoader.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
struct DBCDatabaseLoader
|
||||
{
|
||||
DBCDatabaseLoader(char const* dbTable, char const* dbcFormatString, std::vector<char*>& stringPool);
|
||||
|
||||
char* Load(uint32& records, char**& indexTable);
|
||||
|
||||
private:
|
||||
char const* _sqlTableName;
|
||||
char const* _dbcFormat;
|
||||
int32 _sqlIndexPos;
|
||||
uint32 _recordSize;
|
||||
std::vector<char*>& _stringPool;
|
||||
char* CloneStringToPool(std::string const& str);
|
||||
|
||||
DBCDatabaseLoader(DBCDatabaseLoader const& right) = delete;
|
||||
DBCDatabaseLoader& operator=(DBCDatabaseLoader const& right) = delete;
|
||||
};
|
||||
|
||||
#endif // DBCDatabaseLoader_h__
|
||||
435
src/server/shared/DataStores/DBCEnums.h
Normal file
435
src/server/shared/DataStores/DBCEnums.h
Normal file
@@ -0,0 +1,435 @@
|
||||
/*
|
||||
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU GPL v2 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-GPL2
|
||||
* Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
|
||||
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
|
||||
*/
|
||||
|
||||
#ifndef DBCENUMS_H
|
||||
#define DBCENUMS_H
|
||||
|
||||
// Client expected level limitation, like as used in DBC item max levels for "until max player level"
|
||||
// use as default max player level, must be fit max level for used client
|
||||
// also see MAX_LEVEL and STRONG_MAX_LEVEL define
|
||||
#define DEFAULT_MAX_LEVEL 80
|
||||
|
||||
// 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 BattlegroundBracketId // bracketId for level ranges
|
||||
{
|
||||
BG_BRACKET_ID_FIRST = 0,
|
||||
BG_BRACKET_ID_LAST = 15
|
||||
};
|
||||
|
||||
// must be max value in PvPDificulty slot+1
|
||||
#define MAX_BATTLEGROUND_BRACKETS 16
|
||||
|
||||
enum AreaTeams
|
||||
{
|
||||
AREATEAM_NONE = 0,
|
||||
AREATEAM_ALLY = 2,
|
||||
AREATEAM_HORDE = 4,
|
||||
AREATEAM_ANY = 6
|
||||
};
|
||||
|
||||
enum AchievementFaction
|
||||
{
|
||||
ACHIEVEMENT_FACTION_HORDE = 0,
|
||||
ACHIEVEMENT_FACTION_ALLIANCE = 1,
|
||||
ACHIEVEMENT_FACTION_ANY = -1,
|
||||
};
|
||||
|
||||
enum AchievementFlags
|
||||
{
|
||||
ACHIEVEMENT_FLAG_COUNTER = 0x00000001, // Just count statistic (never stop and complete)
|
||||
ACHIEVEMENT_FLAG_HIDDEN = 0x00000002, // Not sent to client - internal use only
|
||||
ACHIEVEMENT_FLAG_STORE_MAX_VALUE = 0x00000004, // Store only max value? used only in "Reach level xx"
|
||||
ACHIEVEMENT_FLAG_SUMM = 0x00000008, // Use summ criteria value from all reqirements (and calculate max value)
|
||||
ACHIEVEMENT_FLAG_MAX_USED = 0x00000010, // Show max criteria (and calculate max value ??)
|
||||
ACHIEVEMENT_FLAG_REQ_COUNT = 0x00000020, // Use not zero req count (and calculate max value)
|
||||
ACHIEVEMENT_FLAG_AVERAGE = 0x00000040, // Show as average value (value / time_in_days) depend from other flag (by def use last criteria value)
|
||||
ACHIEVEMENT_FLAG_BAR = 0x00000080, // Show as progress bar (value / max vale) depend from other flag (by def use last criteria value)
|
||||
ACHIEVEMENT_FLAG_REALM_FIRST_REACH = 0x00000100, //
|
||||
ACHIEVEMENT_FLAG_REALM_FIRST_KILL = 0x00000200, //
|
||||
};
|
||||
|
||||
#define MAX_CRITERIA_REQUIREMENTS 2
|
||||
|
||||
enum AchievementCriteriaCondition
|
||||
{
|
||||
ACHIEVEMENT_CRITERIA_CONDITION_NONE = 0,
|
||||
ACHIEVEMENT_CRITERIA_CONDITION_NO_DEATH = 1, // reset progress on death
|
||||
ACHIEVEMENT_CRITERIA_CONDITION_UNK1 = 2, // only used in "Complete a daily quest every day for five consecutive days"
|
||||
ACHIEVEMENT_CRITERIA_CONDITION_BG_MAP = 3, // requires you to be on specific map, reset at change
|
||||
ACHIEVEMENT_CRITERIA_CONDITION_NO_LOSE = 4, // only used in "Win 10 arenas without losing"
|
||||
ACHIEVEMENT_CRITERIA_CONDITION_NO_SPELL_HIT = 9, // requires the player not to be hit by specific spell
|
||||
ACHIEVEMENT_CRITERIA_CONDITION_NOT_IN_GROUP = 10, // requires the player not to be in group
|
||||
ACHIEVEMENT_CRITERIA_CONDITION_UNK3 = 13, // unk
|
||||
ACHIEVEMENT_CRITERIA_CONDITION_TOTAL = 14
|
||||
};
|
||||
|
||||
enum AchievementCriteriaFlags
|
||||
{
|
||||
ACHIEVEMENT_CRITERIA_FLAG_SHOW_PROGRESS_BAR = 0x00000001, // Show progress as bar
|
||||
ACHIEVEMENT_CRITERIA_FLAG_HIDDEN = 0x00000002, // Not show criteria in client
|
||||
ACHIEVEMENT_CRITERIA_FLAG_FAIL_ACHIEVEMENT = 0x00000004, // BG related??
|
||||
ACHIEVEMENT_CRITERIA_FLAG_RESET_ON_START = 0x00000008, //
|
||||
ACHIEVEMENT_CRITERIA_FLAG_IS_DATE = 0x00000010, // not used
|
||||
ACHIEVEMENT_CRITERIA_FLAG_MONEY_COUNTER = 0x00000020 // Displays counter as money
|
||||
};
|
||||
|
||||
enum AchievementCriteriaTimedTypes
|
||||
{
|
||||
ACHIEVEMENT_TIMED_TYPE_EVENT = 1, // Timer is started by internal event with id in timerStartEvent
|
||||
ACHIEVEMENT_TIMED_TYPE_QUEST = 2, // Timer is started by accepting quest with entry in timerStartEvent
|
||||
ACHIEVEMENT_TIMED_TYPE_SPELL_CASTER = 5, // Timer is started by casting a spell with entry in timerStartEvent
|
||||
ACHIEVEMENT_TIMED_TYPE_SPELL_TARGET = 6, // Timer is started by being target of spell with entry in timerStartEvent
|
||||
ACHIEVEMENT_TIMED_TYPE_CREATURE = 7, // Timer is started by killing creature with entry in timerStartEvent
|
||||
ACHIEVEMENT_TIMED_TYPE_ITEM = 9, // Timer is started by using item with entry in timerStartEvent
|
||||
|
||||
ACHIEVEMENT_TIMED_TYPE_MAX,
|
||||
};
|
||||
|
||||
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,
|
||||
ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_DAILY_QUEST_DAILY = 10, // you have to complete a daily quest x times in a row
|
||||
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,
|
||||
ACHIEVEMENT_CRITERIA_TYPE_HONORABLE_KILL = 35,
|
||||
ACHIEVEMENT_CRITERIA_TYPE_OWN_ITEM = 36,
|
||||
ACHIEVEMENT_CRITERIA_TYPE_WIN_RATED_ARENA = 37, // TODO: the archievements 1162 and 1163 requires a special rating which can't be found in the dbc
|
||||
ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_TEAM_RATING = 38,
|
||||
ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_PERSONAL_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,
|
||||
ACHIEVEMENT_CRITERIA_TYPE_VISIT_BARBER_SHOP = 48, // note: rewarded as soon as the player payed, not at taking place at the seat
|
||||
ACHIEVEMENT_CRITERIA_TYPE_EQUIP_EPIC_ITEM = 49,
|
||||
ACHIEVEMENT_CRITERIA_TYPE_ROLL_NEED_ON_LOOT = 50, // TODO: itemlevel is mentioned in text but not present in dbc
|
||||
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,
|
||||
ACHIEVEMENT_CRITERIA_TYPE_GET_KILLING_BLOWS = 56, // TODO: in some cases map not present, and in some cases need do without die
|
||||
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,
|
||||
ACHIEVEMENT_CRITERIA_TYPE_ON_LOGIN = 74, // TODO: title id is not mentioned in dbc
|
||||
ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILLLINE_SPELLS = 75,
|
||||
ACHIEVEMENT_CRITERIA_TYPE_WIN_DUEL = 76,
|
||||
ACHIEVEMENT_CRITERIA_TYPE_LOSE_DUEL = 77,
|
||||
ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE_TYPE = 78, // TODO: creature type (demon, undead etc.) is not stored in dbc
|
||||
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,
|
||||
ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL2 = 110, // TODO: target entry is missing
|
||||
ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LINE = 112,
|
||||
ACHIEVEMENT_CRITERIA_TYPE_EARN_HONORABLE_KILL = 113,
|
||||
ACHIEVEMENT_CRITERIA_TYPE_ACCEPTED_SUMMONINGS = 114,
|
||||
ACHIEVEMENT_CRITERIA_TYPE_EARN_ACHIEVEMENT_POINTS = 115,
|
||||
ACHIEVEMENT_CRITERIA_TYPE_USE_LFD_TO_GROUP_WITH_PLAYERS = 119,
|
||||
ACHIEVEMENT_CRITERIA_TYPE_TOTAL = 124, // 0..123 => 124 criteria types total
|
||||
};
|
||||
|
||||
enum AchievementCategory
|
||||
{
|
||||
CATEGORY_CHILDRENS_WEEK = 163,
|
||||
};
|
||||
|
||||
enum AreaFlags
|
||||
{
|
||||
AREA_FLAG_UNK0 = 0x00000001, // Unknown
|
||||
AREA_FLAG_UNK1 = 0x00000002, // Razorfen Downs, Naxxramas and Acherus: The Ebon Hold (3.3.5a)
|
||||
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_ALLOW_DUELS = 0x00000040, // allow to duel here
|
||||
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, // Respawn alive at the graveyard without corpse
|
||||
AREA_FLAG_UNUSED1 = 0x00002000, // Unused in 3.3.5a
|
||||
AREA_FLAG_OUTLAND2 = 0x00004000, // expansion zones? (only Circle of Blood Arena not have this flag, but have 0x00000400 flag)
|
||||
AREA_FLAG_OUTDOOR_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, // Unused in 3.3.5a
|
||||
AREA_FLAG_CONTESTED_AREA = 0x00040000, // On PvP servers these areas are considered contested, even though the zone it is contained in is a Horde/Alliance territory.
|
||||
AREA_FLAG_UNK4 = 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_REST_ZONE_HORDE = 0x00400000, // Instead of using areatriggers, the zone will act as one for Horde players (Warsong Hold, Acherus: The Ebon Hold, New Agamand Inn, Vengeance Landing Inn, Sunreaver Pavilion, etc)
|
||||
AREA_FLAG_REST_ZONE_ALLIANCE = 0x00800000, // Instead of using areatriggers, the zone will act as one for Alliance players (Valgarde, Acherus: The Ebon Hold, Westguard Inn, Silver Covenant Pavilion, etc)
|
||||
AREA_FLAG_WINTERGRASP = 0x01000000, // Wintergrasp and it's subzones
|
||||
AREA_FLAG_INSIDE = 0x02000000, // used for determinating spell related inside/outside questions in Map::IsOutdoors
|
||||
AREA_FLAG_OUTSIDE = 0x04000000, // used for determinating spell related inside/outside questions in Map::IsOutdoors
|
||||
AREA_FLAG_WINTERGRASP_2 = 0x08000000, // Can Hearth And Resurrect From Area
|
||||
AREA_FLAG_NO_FLY_ZONE = 0x20000000 // Marks zones where you cannot fly
|
||||
};
|
||||
|
||||
enum Difficulty
|
||||
{
|
||||
REGULAR_DIFFICULTY = 0,
|
||||
|
||||
DUNGEON_DIFFICULTY_NORMAL = 0,
|
||||
DUNGEON_DIFFICULTY_HEROIC = 1,
|
||||
DUNGEON_DIFFICULTY_EPIC = 2,
|
||||
|
||||
RAID_DIFFICULTY_10MAN_NORMAL = 0,
|
||||
RAID_DIFFICULTY_25MAN_NORMAL = 1,
|
||||
RAID_DIFFICULTY_10MAN_HEROIC = 2,
|
||||
RAID_DIFFICULTY_25MAN_HEROIC = 3,
|
||||
};
|
||||
|
||||
#define RAID_DIFFICULTY_MASK_25MAN 1 // since 25man difficulties are 1 and 3, we can check them like that
|
||||
|
||||
#define MAX_DUNGEON_DIFFICULTY 3
|
||||
#define MAX_RAID_DIFFICULTY 4
|
||||
#define MAX_DIFFICULTY 4
|
||||
|
||||
enum SpawnMask
|
||||
{
|
||||
SPAWNMASK_CONTINENT = (1 << REGULAR_DIFFICULTY), // any any maps without spawn modes
|
||||
|
||||
SPAWNMASK_DUNGEON_NORMAL = (1 << DUNGEON_DIFFICULTY_NORMAL),
|
||||
SPAWNMASK_DUNGEON_HEROIC = (1 << DUNGEON_DIFFICULTY_HEROIC),
|
||||
SPAWNMASK_DUNGEON_ALL = (SPAWNMASK_DUNGEON_NORMAL | SPAWNMASK_DUNGEON_HEROIC),
|
||||
|
||||
SPAWNMASK_RAID_10MAN_NORMAL = (1 << RAID_DIFFICULTY_10MAN_NORMAL),
|
||||
SPAWNMASK_RAID_25MAN_NORMAL = (1 << RAID_DIFFICULTY_25MAN_NORMAL),
|
||||
SPAWNMASK_RAID_NORMAL_ALL = (SPAWNMASK_RAID_10MAN_NORMAL | SPAWNMASK_RAID_25MAN_NORMAL),
|
||||
|
||||
SPAWNMASK_RAID_10MAN_HEROIC = (1 << RAID_DIFFICULTY_10MAN_HEROIC),
|
||||
SPAWNMASK_RAID_25MAN_HEROIC = (1 << RAID_DIFFICULTY_25MAN_HEROIC),
|
||||
SPAWNMASK_RAID_HEROIC_ALL = (SPAWNMASK_RAID_10MAN_HEROIC | SPAWNMASK_RAID_25MAN_HEROIC),
|
||||
|
||||
SPAWNMASK_RAID_ALL = (SPAWNMASK_RAID_NORMAL_ALL | SPAWNMASK_RAID_HEROIC_ALL),
|
||||
};
|
||||
|
||||
enum FactionTemplateFlags
|
||||
{
|
||||
FACTION_TEMPLATE_FLAG_PVP = 0x00000800, // flagged for PvP
|
||||
FACTION_TEMPLATE_FLAG_CONTESTED_GUARD = 0x00001000, // faction will attack players that were involved in PvP combats
|
||||
FACTION_TEMPLATE_FLAG_HOSTILE_BY_DEFAULT= 0x00002000,
|
||||
};
|
||||
|
||||
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 // Lua_IsInInstance
|
||||
{
|
||||
MAP_COMMON = 0, // none
|
||||
MAP_INSTANCE = 1, // party
|
||||
MAP_RAID = 2, // raid
|
||||
MAP_BATTLEGROUND = 3, // pvp
|
||||
MAP_ARENA = 4 // arena
|
||||
};
|
||||
|
||||
enum MapFlags
|
||||
{
|
||||
MAP_FLAG_DYNAMIC_DIFFICULTY = 0x100
|
||||
};
|
||||
|
||||
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 ItemLimitCategoryMode
|
||||
{
|
||||
ITEM_LIMIT_CATEGORY_MODE_HAVE = 0, // limit applied to amount items in inventory/bank
|
||||
ITEM_LIMIT_CATEGORY_MODE_EQUIP = 1, // limit applied to amount equipped items (including used gems)
|
||||
};
|
||||
|
||||
enum SpellCategoryFlags
|
||||
{
|
||||
SPELL_CATEGORY_FLAG_COOLDOWN_SCALES_WITH_WEAPON_SPEED = 0x01, // unused
|
||||
SPELL_CATEGORY_FLAG_COOLDOWN_STARTS_ON_EVENT = 0x04
|
||||
};
|
||||
|
||||
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 SummonPropGroup
|
||||
{
|
||||
SUMMON_PROP_GROUP_UNKNOWN1 = 0, // 1160 spells in 3.0.3
|
||||
SUMMON_PROP_GROUP_UNKNOWN2 = 1, // 861 spells in 3.0.3
|
||||
SUMMON_PROP_GROUP_PETS = 2, // 52 spells in 3.0.3, pets mostly
|
||||
SUMMON_PROP_GROUP_CONTROLLABLE = 3, // 13 spells in 3.0.3, mostly controllable
|
||||
SUMMON_PROP_GROUP_UNKNOWN3 = 4 // 86 spells in 3.0.3, taxi/mounts
|
||||
};
|
||||
|
||||
// SummonProperties.dbc, col 5
|
||||
enum SummonPropFlags
|
||||
{
|
||||
SUMMON_PROP_FLAG_NONE = 0x00000000, // 1342 spells in 3.0.3
|
||||
SUMMON_PROP_FLAG_UNK1 = 0x00000001, // 75 spells in 3.0.3, something unfriendly
|
||||
SUMMON_PROP_FLAG_UNK2 = 0x00000002, // 616 spells in 3.0.3, something friendly
|
||||
SUMMON_PROP_FLAG_UNK3 = 0x00000004, // 22 spells in 3.0.3, no idea...
|
||||
SUMMON_PROP_FLAG_UNK4 = 0x00000008, // 49 spells in 3.0.3, some mounts
|
||||
SUMMON_PROP_FLAG_UNK5 = 0x00000010, // 25 spells in 3.0.3, quest related?
|
||||
SUMMON_PROP_FLAG_UNK6 = 0x00000020, // 0 spells in 3.3.5, unused
|
||||
SUMMON_PROP_FLAG_UNK7 = 0x00000040, // 12 spells in 3.0.3, no idea
|
||||
SUMMON_PROP_FLAG_UNK8 = 0x00000080, // 4 spells in 3.0.3, no idea
|
||||
SUMMON_PROP_FLAG_UNK9 = 0x00000100, // 51 spells in 3.0.3, no idea, many quest related
|
||||
SUMMON_PROP_FLAG_UNK10 = 0x00000200, // 51 spells in 3.0.3, something defensive
|
||||
SUMMON_PROP_FLAG_UNK11 = 0x00000400, // 3 spells, requires something near?
|
||||
SUMMON_PROP_FLAG_UNK12 = 0x00000800, // 30 spells in 3.0.3, no idea
|
||||
SUMMON_PROP_FLAG_UNK13 = 0x00001000, // Lightwell, Jeeves, Gnomish Alarm-o-bot, Build vehicles(wintergrasp)
|
||||
SUMMON_PROP_FLAG_UNK14 = 0x00002000, // Guides, player follows
|
||||
SUMMON_PROP_FLAG_UNK15 = 0x00004000, // Force of Nature, Shadowfiend, Feral Spirit, Summon Water Elemental
|
||||
SUMMON_PROP_FLAG_UNK16 = 0x00008000, // Light/Dark Bullet, Soul/Fiery Consumption, Twisted Visage, Twilight Whelp. Phase related?
|
||||
};
|
||||
|
||||
enum VehicleSeatFlags
|
||||
{
|
||||
VEHICLE_SEAT_FLAG_HAS_LOWER_ANIM_FOR_ENTER = 0x00000001,
|
||||
VEHICLE_SEAT_FLAG_HAS_LOWER_ANIM_FOR_RIDE = 0x00000002,
|
||||
VEHICLE_SEAT_FLAG_UNK3 = 0x00000004,
|
||||
VEHICLE_SEAT_FLAG_SHOULD_USE_VEH_SEAT_EXIT_ANIM_ON_VOLUNTARY_EXIT = 0x00000008,
|
||||
VEHICLE_SEAT_FLAG_UNK5 = 0x00000010,
|
||||
VEHICLE_SEAT_FLAG_UNK6 = 0x00000020,
|
||||
VEHICLE_SEAT_FLAG_UNK7 = 0x00000040,
|
||||
VEHICLE_SEAT_FLAG_UNK8 = 0x00000080,
|
||||
VEHICLE_SEAT_FLAG_UNK9 = 0x00000100,
|
||||
VEHICLE_SEAT_FLAG_HIDE_PASSENGER = 0x00000200, // Passenger is hidden
|
||||
VEHICLE_SEAT_FLAG_ALLOW_TURNING = 0x00000400, // needed for CGCamera__SyncFreeLookFacing
|
||||
VEHICLE_SEAT_FLAG_CAN_CONTROL = 0x00000800, // Lua_UnitInVehicleControlSeat
|
||||
VEHICLE_SEAT_FLAG_CAN_CAST_MOUNT_SPELL = 0x00001000, // Can cast spells with SPELL_AURA_MOUNTED from seat (possibly 4.x only, 0 seats on 3.3.5a)
|
||||
VEHICLE_SEAT_FLAG_UNCONTROLLED = 0x00002000, // can override !& VEHICLE_SEAT_FLAG_CAN_ENTER_OR_EXIT
|
||||
VEHICLE_SEAT_FLAG_CAN_ATTACK = 0x00004000, // Can attack, cast spells and use items from vehicle
|
||||
VEHICLE_SEAT_FLAG_SHOULD_USE_VEH_SEAT_EXIT_ANIM_ON_FORCED_EXIT = 0x00008000,
|
||||
VEHICLE_SEAT_FLAG_UNK17 = 0x00010000,
|
||||
VEHICLE_SEAT_FLAG_UNK18 = 0x00020000,
|
||||
VEHICLE_SEAT_FLAG_HAS_VEH_EXIT_ANIM_VOLUNTARY_EXIT = 0x00040000,
|
||||
VEHICLE_SEAT_FLAG_HAS_VEH_EXIT_ANIM_FORCED_EXIT = 0x00080000,
|
||||
VEHICLE_SEAT_FLAG_PASSENGER_NOT_SELECTABLE = 0x00100000,
|
||||
VEHICLE_SEAT_FLAG_UNK22 = 0x00200000,
|
||||
VEHICLE_SEAT_FLAG_REC_HAS_VEHICLE_ENTER_ANIM = 0x00400000,
|
||||
VEHICLE_SEAT_FLAG_IS_USING_VEHICLE_CONTROLS = 0x00800000, // Lua_IsUsingVehicleControls
|
||||
VEHICLE_SEAT_FLAG_ENABLE_VEHICLE_ZOOM = 0x01000000,
|
||||
VEHICLE_SEAT_FLAG_CAN_ENTER_OR_EXIT = 0x02000000, // Lua_CanExitVehicle - can enter and exit at free will
|
||||
VEHICLE_SEAT_FLAG_CAN_SWITCH = 0x04000000, // Lua_CanSwitchVehicleSeats
|
||||
VEHICLE_SEAT_FLAG_HAS_START_WARITING_FOR_VEH_TRANSITION_ANIM_ENTER = 0x08000000,
|
||||
VEHICLE_SEAT_FLAG_HAS_START_WARITING_FOR_VEH_TRANSITION_ANIM_EXIT = 0x10000000,
|
||||
VEHICLE_SEAT_FLAG_CAN_CAST = 0x20000000, // Lua_UnitHasVehicleUI
|
||||
VEHICLE_SEAT_FLAG_UNK2 = 0x40000000, // checked in conjunction with 0x800 in CastSpell2
|
||||
VEHICLE_SEAT_FLAG_ALLOWS_INTERACTION = 0x80000000
|
||||
};
|
||||
|
||||
enum VehicleSeatFlagsB
|
||||
{
|
||||
VEHICLE_SEAT_FLAG_B_NONE = 0x00000000,
|
||||
VEHICLE_SEAT_FLAG_B_USABLE_FORCED = 0x00000002,
|
||||
VEHICLE_SEAT_FLAG_B_TARGETS_IN_RAIDUI = 0x00000008, // Lua_UnitTargetsVehicleInRaidUI
|
||||
VEHICLE_SEAT_FLAG_B_EJECTABLE = 0x00000020, // ejectable
|
||||
VEHICLE_SEAT_FLAG_B_USABLE_FORCED_2 = 0x00000040,
|
||||
VEHICLE_SEAT_FLAG_B_USABLE_FORCED_3 = 0x00000100,
|
||||
VEHICLE_SEAT_FLAG_B_KEEP_PET = 0x00020000,
|
||||
VEHICLE_SEAT_FLAG_B_USABLE_FORCED_4 = 0x02000000,
|
||||
VEHICLE_SEAT_FLAG_B_CAN_SWITCH = 0x04000000,
|
||||
VEHICLE_SEAT_FLAG_B_VEHICLE_PLAYERFRAME_UI = 0x80000000, // Lua_UnitHasVehiclePlayerFrameUI - actually checked for flagsb &~ 0x80000000
|
||||
};
|
||||
|
||||
#endif
|
||||
58
src/server/shared/DataStores/DBCStorageIterator.h
Normal file
58
src/server/shared/DataStores/DBCStorageIterator.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU GPL v2 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-GPL2
|
||||
* Copyright (C) 2008-2020 TrinityCore <http://www.trinitycore.org/>
|
||||
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
|
||||
*/
|
||||
|
||||
#ifndef DBCStorageIterator_h__
|
||||
#define DBCStorageIterator_h__
|
||||
|
||||
#include "Define.h"
|
||||
#include <iterator>
|
||||
|
||||
template <class T>
|
||||
class DBCStorageIterator : public std::iterator<std::forward_iterator_tag, T>
|
||||
{
|
||||
public:
|
||||
DBCStorageIterator() : _index(nullptr), _pos(0), _end(0) { }
|
||||
DBCStorageIterator(T** index, uint32 size, uint32 pos = 0) : _index(index), _pos(pos), _end(size)
|
||||
{
|
||||
if (_pos < _end)
|
||||
{
|
||||
while (_pos < _end && !_index[_pos])
|
||||
++_pos;
|
||||
}
|
||||
}
|
||||
|
||||
T const* operator->() { return _index[_pos]; }
|
||||
T const* operator*() { return _index[_pos]; }
|
||||
|
||||
bool operator==(DBCStorageIterator const& right) const { /*ASSERT(_index == right._index, "Iterator belongs to a different container")*/ return _pos == right._pos; }
|
||||
bool operator!=(DBCStorageIterator const& right) const { return !(*this == right); }
|
||||
|
||||
DBCStorageIterator& operator++()
|
||||
{
|
||||
if (_pos < _end)
|
||||
{
|
||||
do
|
||||
++_pos;
|
||||
while (_pos < _end && !_index[_pos]);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
DBCStorageIterator operator++(int)
|
||||
{
|
||||
DBCStorageIterator tmp = *this;
|
||||
++*this;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
private:
|
||||
T** _index;
|
||||
uint32 _pos;
|
||||
uint32 _end;
|
||||
};
|
||||
|
||||
#endif // DBCStorageIterator_h__
|
||||
66
src/server/shared/DataStores/DBCStore.cpp
Normal file
66
src/server/shared/DataStores/DBCStore.cpp
Normal file
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU GPL v2 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-GPL2
|
||||
* Copyright (C) 2008-2020 TrinityCore <http://www.trinitycore.org/>
|
||||
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
|
||||
*/
|
||||
|
||||
#include "DBCStore.h"
|
||||
#include "DBCDatabaseLoader.h"
|
||||
|
||||
DBCStorageBase::DBCStorageBase(char const* fmt) : _fieldCount(0), _fileFormat(fmt), _dataTable(nullptr), _indexTableSize(0)
|
||||
{
|
||||
}
|
||||
|
||||
DBCStorageBase::~DBCStorageBase()
|
||||
{
|
||||
delete[] _dataTable;
|
||||
for (char* strings : _stringPool)
|
||||
delete[] strings;
|
||||
}
|
||||
|
||||
bool DBCStorageBase::Load(char const* path, char**& indexTable)
|
||||
{
|
||||
indexTable = nullptr;
|
||||
|
||||
DBCFileLoader dbc;
|
||||
|
||||
// Check if load was sucessful, only then continue
|
||||
if (!dbc.Load(path, _fileFormat))
|
||||
return false;
|
||||
|
||||
_fieldCount = dbc.GetCols();
|
||||
|
||||
// load raw non-string data
|
||||
_dataTable = dbc.AutoProduceData(_fileFormat, _indexTableSize, indexTable);
|
||||
|
||||
// load strings from dbc data
|
||||
if (char* stringBlock = dbc.AutoProduceStrings(_fileFormat, _dataTable))
|
||||
_stringPool.push_back(stringBlock);
|
||||
|
||||
// error in dbc file at loading if NULL
|
||||
return indexTable != nullptr;
|
||||
}
|
||||
|
||||
bool DBCStorageBase::LoadStringsFrom(char const* path, char** indexTable)
|
||||
{
|
||||
// DBC must be already loaded using Load
|
||||
if (!indexTable)
|
||||
return false;
|
||||
|
||||
DBCFileLoader dbc;
|
||||
|
||||
// Check if load was successful, only then continue
|
||||
if (!dbc.Load(path, _fileFormat))
|
||||
return false;
|
||||
|
||||
// load strings from another locale dbc data
|
||||
if (char* stringBlock = dbc.AutoProduceStrings(_fileFormat, _dataTable))
|
||||
_stringPool.push_back(stringBlock);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void DBCStorageBase::LoadFromDB(char const* table, char const* format, char**& indexTable)
|
||||
{
|
||||
_stringPool.push_back(DBCDatabaseLoader(table, format, _stringPool).Load(_indexTableSize, indexTable));
|
||||
}
|
||||
113
src/server/shared/DataStores/DBCStore.h
Normal file
113
src/server/shared/DataStores/DBCStore.h
Normal file
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU GPL v2 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-GPL2
|
||||
* Copyright (C) 2008-2020 TrinityCore <http://www.trinitycore.org/>
|
||||
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
|
||||
*/
|
||||
|
||||
#ifndef DBCSTORE_H
|
||||
#define DBCSTORE_H
|
||||
|
||||
#include "Common.h"
|
||||
#include "DBCStorageIterator.h"
|
||||
#include "Errors.h"
|
||||
#include <vector>
|
||||
|
||||
/// Interface class for common access
|
||||
class DBCStorageBase
|
||||
{
|
||||
public:
|
||||
DBCStorageBase(char const* fmt);
|
||||
virtual ~DBCStorageBase();
|
||||
|
||||
char const* GetFormat() const { return _fileFormat; }
|
||||
uint32 GetFieldCount() const { return _fieldCount; }
|
||||
|
||||
virtual bool Load(char const* path) = 0;
|
||||
virtual bool LoadStringsFrom(char const* path) = 0;
|
||||
virtual void LoadFromDB(char const* table, char const* format) = 0;
|
||||
|
||||
protected:
|
||||
bool Load(char const* path, char**& indexTable);
|
||||
bool LoadStringsFrom(char const* path, char** indexTable);
|
||||
void LoadFromDB(char const* table, char const* format, char**& indexTable);
|
||||
|
||||
uint32 _fieldCount;
|
||||
char const* _fileFormat;
|
||||
char* _dataTable;
|
||||
std::vector<char*> _stringPool;
|
||||
uint32 _indexTableSize;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class DBCStorage : public DBCStorageBase
|
||||
{
|
||||
public:
|
||||
typedef DBCStorageIterator<T> iterator;
|
||||
|
||||
explicit DBCStorage(char const* fmt) : DBCStorageBase(fmt)
|
||||
{
|
||||
_indexTable.AsT = nullptr;
|
||||
}
|
||||
|
||||
~DBCStorage()
|
||||
{
|
||||
delete[] reinterpret_cast<char*>(_indexTable.AsT);
|
||||
}
|
||||
|
||||
T const* LookupEntry(uint32 id) const { return (id >= _indexTableSize) ? nullptr : _indexTable.AsT[id]; }
|
||||
T const* AssertEntry(uint32 id) const { return ASSERT_NOTNULL(LookupEntry(id)); }
|
||||
|
||||
#ifdef ELUNA
|
||||
void SetEntry(uint32 id, T* t)
|
||||
{
|
||||
if (id >= _indexTableSize)
|
||||
{
|
||||
// Resize
|
||||
typedef char* ptr;
|
||||
size_t newSize = id + 1;
|
||||
ptr* newArr = new ptr[newSize];
|
||||
memset(newArr, 0, newSize * sizeof(ptr));
|
||||
memcpy(newArr, _indexTable.AsChar, _indexTableSize * sizeof(ptr));
|
||||
delete[] reinterpret_cast<char*>(_indexTable.AsT);
|
||||
_indexTable.AsChar = newArr;
|
||||
_indexTableSize = newSize;
|
||||
}
|
||||
|
||||
delete _indexTable.AsT[id];
|
||||
_indexTable.AsT[id] = t;
|
||||
}
|
||||
#endif
|
||||
|
||||
uint32 GetNumRows() const { return _indexTableSize; }
|
||||
|
||||
bool Load(char const* path) override
|
||||
{
|
||||
return DBCStorageBase::Load(path, _indexTable.AsChar);
|
||||
}
|
||||
|
||||
bool LoadStringsFrom(char const* path) override
|
||||
{
|
||||
return DBCStorageBase::LoadStringsFrom(path, _indexTable.AsChar);
|
||||
}
|
||||
|
||||
void LoadFromDB(char const* table, char const* format) override
|
||||
{
|
||||
DBCStorageBase::LoadFromDB(table, format, _indexTable.AsChar);
|
||||
}
|
||||
|
||||
iterator begin() { return iterator(_indexTable.AsT, _indexTableSize); }
|
||||
iterator end() { return iterator(_indexTable.AsT, _indexTableSize, _indexTableSize); }
|
||||
|
||||
private:
|
||||
union
|
||||
{
|
||||
T** AsT;
|
||||
char** AsChar;
|
||||
}
|
||||
_indexTable;
|
||||
|
||||
DBCStorage(DBCStorage const& right) = delete;
|
||||
DBCStorage& operator=(DBCStorage const& right) = delete;
|
||||
};
|
||||
|
||||
#endif
|
||||
2129
src/server/shared/DataStores/DBCStructure.h
Normal file
2129
src/server/shared/DataStores/DBCStructure.h
Normal file
File diff suppressed because it is too large
Load Diff
114
src/server/shared/DataStores/DBCfmt.h
Normal file
114
src/server/shared/DataStores/DBCfmt.h
Normal file
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU GPL v2 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-GPL2
|
||||
* Copyright (C) 2008-2020 TrinityCore <http://www.trinitycore.org/>
|
||||
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
|
||||
*/
|
||||
|
||||
#ifndef ACORE_DBCSFRM_H
|
||||
#define ACORE_DBCSFRM_H
|
||||
|
||||
char constexpr Achievementfmt[] = "niixssssssssssssssssxxxxxxxxxxxxxxxxxxiixixxxxxxxxxxxxxxxxxxii";
|
||||
char constexpr AchievementCategoryfmt[] = "nixxxxxxxxxxxxxxxxxx";
|
||||
char constexpr AchievementCriteriafmt[] = "niiiiiiiixxxxxxxxxxxxxxxxxiiiix";
|
||||
char constexpr AreaTableEntryfmt[] = "niiiixxxxxissssssssssssssssxiiiiixxx";
|
||||
char constexpr AreaGroupEntryfmt[] = "niiiiiii";
|
||||
char constexpr AreaPOIEntryfmt[] = "niiiiiiiiiiifffixixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxix";
|
||||
char constexpr AuctionHouseEntryfmt[] = "niiixxxxxxxxxxxxxxxxx";
|
||||
char constexpr BankBagSlotPricesEntryfmt[] = "ni";
|
||||
char constexpr BarberShopStyleEntryfmt[] = "nixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxiii";
|
||||
char constexpr BattlemasterListEntryfmt[] = "niiiiiiiiixssssssssssssssssxiixx";
|
||||
char constexpr CharStartOutfitEntryfmt[] = "dbbbXiiiiiiiiiiiiiiiiiiiiiiiixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
|
||||
char constexpr CharTitlesEntryfmt[] = "nxssssssssssssssssxssssssssssssssssxi";
|
||||
char constexpr ChatChannelsEntryfmt[] = "nixssssssssssssssssxxxxxxxxxxxxxxxxxx"; // ChatChannelsEntryfmt, index not used (more compact store)
|
||||
char constexpr ChrClassesEntryfmt[] = "nxixssssssssssssssssxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxixii";
|
||||
char constexpr ChrRacesEntryfmt[] = "nxixiixixxxxixssssssssssssssssxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxi";
|
||||
char constexpr CinematicSequencesEntryfmt[] = "nxxxxxxxxx";
|
||||
char constexpr CreatureDisplayInfofmt[] = "nixxfxxxxxxxxxxx";
|
||||
char constexpr CreatureFamilyfmt[] = "nfifiiiiixssssssssssssssssxx";
|
||||
char constexpr CreatureModelDatafmt[] = "nxxxfxxxxxxxxxxffxxxxxxxxxxx";
|
||||
char constexpr CreatureSpellDatafmt[] = "niiiixxxx";
|
||||
char constexpr CreatureTypefmt[] = "nxxxxxxxxxxxxxxxxxx";
|
||||
char constexpr CurrencyTypesfmt[] = "xnxi";
|
||||
char constexpr DestructibleModelDatafmt[] = "nxxixxxixxxixxxixxx";
|
||||
char constexpr DungeonEncounterfmt[] = "niixissssssssssssssssxx";
|
||||
char constexpr DurabilityCostsfmt[] = "niiiiiiiiiiiiiiiiiiiiiiiiiiiii";
|
||||
char constexpr DurabilityQualityfmt[] = "nf";
|
||||
char constexpr EmotesEntryfmt[] = "nxxiiix";
|
||||
char constexpr EmotesTextEntryfmt[] = "nxixxxxxxxxxxxxxxxx";
|
||||
char constexpr FactionEntryfmt[] = "niiiiiiiiiiiiiiiiiiffixssssssssssssssssxxxxxxxxxxxxxxxxxx";
|
||||
char constexpr FactionTemplateEntryfmt[] = "niiiiiiiiiiiii";
|
||||
char constexpr GameObjectDisplayInfofmt[] = "nsxxxxxxxxxxffffffx";
|
||||
char constexpr GemPropertiesEntryfmt[] = "nixxi";
|
||||
char constexpr GlyphPropertiesfmt[] = "niii";
|
||||
char constexpr GlyphSlotfmt[] = "nii";
|
||||
char constexpr GtBarberShopCostBasefmt[] = "df";
|
||||
char constexpr GtCombatRatingsfmt[] = "df";
|
||||
char constexpr GtChanceToMeleeCritBasefmt[] = "df";
|
||||
char constexpr GtChanceToMeleeCritfmt[] = "df";
|
||||
char constexpr GtChanceToSpellCritBasefmt[] = "df";
|
||||
char constexpr GtChanceToSpellCritfmt[] = "df";
|
||||
char constexpr GtNPCManaCostScalerfmt[] = "df";
|
||||
char constexpr GtOCTClassCombatRatingScalarfmt[] = "df";
|
||||
char constexpr GtOCTRegenHPfmt[] = "df";
|
||||
//char constexpr GtOCTRegenMPfmt[] = "f";
|
||||
char constexpr GtRegenHPPerSptfmt[] = "df";
|
||||
char constexpr GtRegenMPPerSptfmt[] = "df";
|
||||
char constexpr Holidaysfmt[] = "niiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiixxsiix";
|
||||
char constexpr ItemBagFamilyfmt[] = "nxxxxxxxxxxxxxxxxx";
|
||||
char constexpr ItemDisplayTemplateEntryfmt[] = "nxxxxsxxxxxxxxxxxxxxxxxxx";
|
||||
//char constexpr ItemCondExtCostsEntryfmt[] = "xiii";
|
||||
char constexpr ItemExtendedCostEntryfmt[] = "niiiiiiiiiiiiiix";
|
||||
char constexpr ItemLimitCategoryEntryfmt[] = "nxxxxxxxxxxxxxxxxxii";
|
||||
char constexpr ItemRandomPropertiesfmt[] = "nxiiiiissssssssssssssssx";
|
||||
char constexpr ItemRandomSuffixfmt[] = "nssssssssssssssssxxiiiiiiiiii";
|
||||
char constexpr ItemSetEntryfmt[] = "dssssssssssssssssxiiiiiiiiiixxxxxxxiiiiiiiiiiiiiiiiii";
|
||||
char constexpr LFGDungeonEntryfmt[] = "nssssssssssssssssxiiiiiiiiixxixixxxxxxxxxxxxxxxxx";
|
||||
char constexpr LightEntryfmt[] = "nifffxxxxxxxxxx";
|
||||
char constexpr LiquidTypefmt[] = "nxxixixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
|
||||
char constexpr LockEntryfmt[] = "niiiiiiiiiiiiiiiiiiiiiiiixxxxxxxx";
|
||||
char constexpr MailTemplateEntryfmt[] = "nxxxxxxxxxxxxxxxxxssssssssssssssssx";
|
||||
char constexpr MapEntryfmt[] = "nxiixssssssssssssssssxixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxixiffxiii";
|
||||
char constexpr MapDifficultyEntryfmt[] = "diisxxxxxxxxxxxxxxxxiix";
|
||||
char constexpr MovieEntryfmt[] = "nxx";
|
||||
char constexpr OverrideSpellDatafmt[] = "niiiiiiiiiix";
|
||||
char constexpr PowerDisplayfmt[] = "nixxxx";
|
||||
char constexpr QuestSortEntryfmt[] = "nxxxxxxxxxxxxxxxxx";
|
||||
char constexpr QuestXPfmt[] = "niiiiiiiiii";
|
||||
char constexpr QuestFactionRewardfmt[] = "niiiiiiiiii";
|
||||
char constexpr PvPDifficultyfmt[] = "diiiii";
|
||||
char constexpr RandomPropertiesPointsfmt[] = "niiiiiiiiiiiiiii";
|
||||
char constexpr ScalingStatDistributionfmt[] = "niiiiiiiiiiiiiiiiiiiii";
|
||||
char constexpr ScalingStatValuesfmt[] = "iniiiiiiiiiiiiiiiiiiiiii";
|
||||
char constexpr SkillLinefmt[] = "nixssssssssssssssssxxxxxxxxxxxxxxxxxxixxxxxxxxxxxxxxxxxi";
|
||||
char constexpr SkillLineAbilityfmt[] = "niiiixxiiiiixx";
|
||||
char constexpr SoundEntriesfmt[] = "nxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
|
||||
char constexpr SpellCastTimefmt[] = "nixx";
|
||||
char constexpr SpellCategoryfmt[] = "ni";
|
||||
char constexpr SpellDifficultyfmt[] = "niiii";
|
||||
char constexpr SpellDurationfmt[] = "niii";
|
||||
char constexpr SpellEntryfmt[] = "niiiiiiiiiiiixixiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiifxiiiiiiiiiiiiiiiiiiiiiiiiiiiifffiiiiiiiiiiiiiiiiiiiiifffiiiiiiiiiiiiiiifffiiiiiiiiiiiiixssssssssssssssssxssssssssssssssssxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxiiiiiiiiiiixfffxxxiiiiixxfffxx";
|
||||
char constexpr SpellFocusObjectfmt[] = "nxxxxxxxxxxxxxxxxx";
|
||||
char constexpr SpellItemEnchantmentfmt[] = "niiiiiiixxxiiissssssssssssssssxiiiiiii";
|
||||
char constexpr SpellItemEnchantmentConditionfmt[] = "nbbbbbxxxxxbbbbbbbbbbiiiiiXXXXX";
|
||||
char constexpr SpellRadiusfmt[] = "nfff";
|
||||
char constexpr SpellRangefmt[] = "nffffixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
|
||||
char constexpr SpellRuneCostfmt[] = "niiii";
|
||||
char constexpr SpellShapeshiftfmt[] = "nxxxxxxxxxxxxxxxxxxiixiiixxiiiiiiii";
|
||||
char constexpr StableSlotPricesfmt[] = "ni";
|
||||
char constexpr SummonPropertiesfmt[] = "niiiii";
|
||||
char constexpr TalentEntryfmt[] = "niiiiiiiixxxxixxixxixxx";
|
||||
char constexpr TalentTabEntryfmt[] = "nxxxxxxxxxxxxxxxxxxxiiix";
|
||||
char constexpr TaxiNodesEntryfmt[] = "nifffssssssssssssssssxii";
|
||||
char constexpr TaxiPathEntryfmt[] = "niii";
|
||||
char constexpr TaxiPathNodeEntryfmt[] = "diiifffiiii";
|
||||
char constexpr TeamContributionPointsfmt[] = "df";
|
||||
char constexpr TotemCategoryEntryfmt[] = "nxxxxxxxxxxxxxxxxxii";
|
||||
char constexpr TransportAnimationfmt[] = "diifffx";
|
||||
char constexpr TransportRotationfmt[] = "diiffff";
|
||||
char constexpr VehicleEntryfmt[] = "niffffiiiiiiiifffffffffffffffssssfifiixx";
|
||||
char constexpr VehicleSeatEntryfmt[] = "niiffffffffffiiiiiifffffffiiifffiiiiiiiffiiiiixxxxxxxxxxxx";
|
||||
char constexpr WMOAreaTableEntryfmt[] = "niiixxxxxiixxxxxxxxxxxxxxxxx";
|
||||
char constexpr WorldMapAreaEntryfmt[] = "xinxffffixx";
|
||||
char constexpr WorldMapOverlayEntryfmt[] = "nxiiiixxxxxxxxxxx";
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user