8#define DEBUG_RACEINFOS 1
14 const DB2Table* chrRaceXChrModel =
WOWDB.getTable(
"ChrRaceXChrModel");
17 const DB2Table* creatureDisplayInfo =
WOWDB.getTable(
"CreatureDisplayInfo");
18 const DB2Table* creatureModelData =
WOWDB.getTable(
"CreatureModelData");
20 if (!chrRaceXChrModel || !chrRaces || !chrModel || !creatureDisplayInfo || !creatureModelData)
22 LOG_ERROR <<
"Unable to collect race information from game database";
26 for (
const auto& xRow : *chrRaceXChrModel)
28 const uint32_t chrRacesID = xRow.getUInt(
"ChrRacesID");
29 const uint32_t chrModelID = xRow.getUInt(
"ChrModelID");
34 if (!raceRow || !modelRow)
37 const uint32_t displayID = modelRow.
getUInt(
"DisplayID");
38 DB2Row displayRow = creatureDisplayInfo->
getRow(displayID);
42 const uint32_t modelDataID = displayRow.
getUInt(
"ModelID");
43 DB2Row modelDataRow = creatureModelData->
getRow(modelDataID);
52 auto modelfileid =
static_cast<int>(modelDataRow.
getUInt(
"FileDataID"));
76 infos.
ChrModelID.push_back(
static_cast<int>(chrModelID));
78 infos.
isHD =
GAMEDIRECTORY.getFile(modelfileid)->fullname().find(
"_hd") != std::string::npos;
82 RACES[modelfileid] = infos;
86 auto id =
static_cast<int>(chrModelID);
93#if DEBUG_RACEINFOS > 0
94 for (
const auto& r :
RACES)
96 LOG_INFO <<
"---------------------------";
97 LOG_INFO <<
"modelfileid ->" << r.first;
99 LOG_INFO <<
"infos.textureLayoutID =" << r.second.textureLayoutID;
100 LOG_INFO <<
"infos.raceID =" << r.second.raceID;
101 LOG_INFO <<
"infos.sexID =" << r.second.sexID;
102 LOG_INFO <<
"infos.isHD =" << r.second.isHD;
103 LOG_INFO <<
"infos.modelFallbackRaceID =" << r.second.modelFallbackRaceID;
104 LOG_INFO <<
"infos.modelFallbackSexID =" << r.second.modelFallbackSexID;
105 LOG_INFO <<
"infos.textureFallbackRaceID =" << r.second.textureFallbackRaceID;
106 LOG_INFO <<
"infos.textureFallbackSexID =" << r.second.textureFallbackSexID;
107 for (
const auto& it : r.second.ChrModelID)
108 LOG_INFO <<
"infos.ChrModelID ->" << it;
109 LOG_INFO <<
"---------------------------";
116 auto result = fileid;
118 const auto it =
RACES.find(fileid);
119 if (it !=
RACES.end() && !it->second.isHD)
121 const auto raceID = it->second.raceID;
122 const auto sexID = it->second.sexID;
124 for (
const auto& r :
RACES)
126 if (r.second.raceID ==
raceID && r.second.sexID ==
sexID && r.second.isHD)
142 infos = raceInfosIt->second;
151 for (
const auto& r :
RACES)
153 if (r.second.raceID == race && r.second.sexID == sex)
Lightweight handle to a single row in a DB2Table.
std::string getString(const std::string &field, unsigned int arrayIndex=0) const
int32_t getInt(const std::string &field, unsigned int arrayIndex=0) const
uint32_t recordID() const
uint32_t getUInt(const std::string &field, unsigned int arrayIndex=0) const
Provides typed, field-name-based access to records in a WDC DB2 file.
DB2Row getRow(uint32_t id) const
Stores per-race/sex metadata loaded from ChrRaces / ChrModel database tables.
std::vector< int > ChrModelID
ChrModel IDs for this race/sex.
bool isHD
Whether this is an HD model.
int sexID
0 = male, 1 = female.
static std::map< int, RaceInfos > RACES
static int getHDModelForFileID(int)
Get the HD model file ID for a given file ID.
static int getFileIDForRaceSex(const int &race, const int &sex)
Get the model file ID for a specific race and sex.
static void init()
Initialise the global race info table from the database.
bool barefeet
Whether the race shows bare feet by default.
int textureLayoutID
Texture layout ID for compositing.
int modelFallbackSexID
Fallback sex for the model.
int textureFallbackSexID
Fallback sex for textures.
static bool getRaceInfosForFileID(int, RaceInfos &)
Populate a RaceInfos struct from a model file ID.
std::string prefix
Race name prefix used for file lookups.
int raceID
Race ID (-1 = invalid).
int textureFallbackRaceID
Fallback race for textures.
int modelFallbackRaceID
Fallback race for the model.