Code change for the acquisition of the locale

The original code was making use of a structure that is used for races
(Human, Orc, etc), which was rather an odd thing to do.

Seeing as the code would not work in this core, I took the opportunity
to rewrite it so that it checked that actual local file instead.
This commit is contained in:
Charles A Edwards 2016-08-03 16:31:45 +01:00 committed by Antz
parent 3a9b00aafd
commit 95f9c41ab0
3 changed files with 47 additions and 2 deletions

View file

@ -289,6 +289,23 @@ static bool ReadDBCBuildFileText(const std::string& dbc_path, char const* locale
return false;
}
int ReadDBCLocale(const std::string sDataPath)
{
std::string sDBCpath = sDataPath + "dbc/";
std::string sFilename;
for (int uLocaleIndex = 0; uLocaleIndex < MAX_LOCALE; ++uLocaleIndex)
{
sFilename = sDBCpath + "component.wow-" + fullLocaleNameList[uLocaleIndex].name + ".txt";
if (FILE* file = fopen(sFilename.c_str(), "rb"))
{
return uLocaleIndex; // Successfully located the locale
}
}
return -1; // Failed to locate or access the component.wow<locale>.txt file
}
static uint32 ReadDBCBuild(const std::string& dbc_path, LocaleNameStr const*&localeNameStr)
{
std::string text;

View file

@ -34,6 +34,15 @@
bool IsAcceptableClientBuild(uint32 build);
std::string AcceptableClientBuildsListStr();
/**
* This function checks to see if there is a valid locale file (component.wow-<locale>.txt)
* and returns an index to the locale or -1 if not found
* @PARAM dataPath full path to the data directory
* @RETURN index number representing the location of the locale in the its structure,
* LocaleNameStr in Common.cpp
*/
int ReadDBCLocale(const std::string sDataPath);
typedef std::list<uint32> SimpleFactionsList;
SimpleFactionsList const* GetFactionTeamList(uint32 faction);
@ -48,8 +57,8 @@ uint32 GetAreaFlagByMapId(uint32 mapid);
WMOAreaTableEntry const* GetWMOAreaTableEntryByTripple(int32 rootid, int32 adtid, int32 groupid);
AreaTableEntry const* GetAreaEntryByAreaID(uint32 area_id);
AreaTableEntry const* GetAreaEntryByAreaFlagAndMap(uint32 area_flag, uint32 map_id);
AreaTableEntry const* GetAreaEntryByAreaID(uint32 area_id);
AreaTableEntry const* GetAreaEntryByAreaFlagAndMap(uint32 area_flag, uint32 map_id);
uint32 GetVirtualMapForMapAndZone(uint32 mapid, uint32 zoneId);