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:
Kargatum 2020-07-22 13:43:16 +07:00 committed by GitHub
parent 3cce44469a
commit 833611f1c5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 13497 additions and 843 deletions

View 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));
}