예제 #1
0
inline void LoadDB2(uint32& availableDb2Locales, StoreProblemList1& errlist, DB2Storage<T>& storage, const std::string& db2_path, const std::string& filename)
{
    // compatibility format and C++ structure sizes
    ASSERT(DB2FileLoader::GetFormatRecordSize(storage.GetFormat()) == sizeof(T) || LoadDB2_assert_print(DB2FileLoader::GetFormatRecordSize(storage.GetFormat()), sizeof(T), filename));

    std::string db2_filename = db2_path + filename;
    if (storage.Load(db2_filename.c_str()))
    {
        //bar.step();
    }
    else
    {
        // sort problematic db2 to (1) non compatible and (2) nonexistent
        FILE * f = fopen(db2_filename.c_str(), "rb");
        if (f)
        {
            char buf[100];
            snprintf(buf, 100,"(exist, but have %d fields instead " SIZEFMTD ") Wrong client version DBC file?", storage.GetFieldCount(), strlen(storage.GetFormat()));
            errlist.push_back(db2_filename + buf);
            fclose(f);
        }
        else
            errlist.push_back(db2_filename);
    }
}
예제 #2
0
inline void LoadDB2(uint32& availableDb2Locales, StoreProblemList1& errlist, DB2Storage<T>& storage, const std::string& db2_path, const std::string& filename)
{
    // compatibility format and C++ structure sizes
    ASSERT(DB2FileLoader::GetFormatRecordSize(storage.GetFormat()) == sizeof(T) || LoadDB2_assert_print(DB2FileLoader::GetFormatRecordSize(storage.GetFormat()), sizeof(T), filename));

    ++DB2FilesCount;
    std::string db2_filename = db2_path + filename;
    if (storage.Load(db2_filename.c_str()))
    {
        for (uint8 loc = 1; loc < TOTAL_LOCALES; ++loc)
        {
            if (!(availableDb2Locales & (1 << loc)))
                continue;

            std::string localizedFileName = db2_path + localeNames[loc] + "/" + filename;
            if (!storage.LoadStringsFrom(localizedFileName.c_str(), loc))
                availableDb2Locales &= ~(1<<loc);             // mark locale as not available
        }
    }
    else
    {
        // sort problematic db2 to (1) non compatible and (2) nonexistent
        FILE * f = fopen(db2_filename.c_str(), "rb");
        if (f)
        {
            char buf[100];
            snprintf(buf, 100, "(exist, but have %d fields instead " SIZEFMTD ") Wrong client version DBC file?", storage.GetFieldCount(), strlen(storage.GetFormat()));
            errlist.push_back(db2_filename + buf);
            fclose(f);
        }
        else
            errlist.push_back(db2_filename);
    }
}
예제 #3
0
inline void LoadDB2(uint32& availableDb2Locales, StoreProblemList1& errlist, DB2Storage<T>& storage, const std::string& db2_path, const std::string& filename)
{
	// compatibility format and C++ structure sizes
	ASSERT(DB2FileLoader::GetFormatRecordSize(storage.GetFormat()) == sizeof(T) || LoadDB2_assert_print(DB2FileLoader::GetFormatRecordSize(storage.GetFormat()), sizeof(T), filename));

	++DB2FilesCount;

	std::string db2_filename = db2_path + filename;
	if (storage.Load(db2_filename.c_str(), uint32(sWorld->GetDefaultDbcLocale())))
	{
		for (uint32 i = 0; i < TOTAL_LOCALES; ++i)
		{
			if (!(availableDb2Locales & (1 << i)))
				continue;

			if (uint32(sWorld->GetDefaultDbcLocale()) == i)
				continue;

			std::string localizedName(db2_path);
			localizedName.append(localeNames[i]);
			localizedName.push_back('/');
			localizedName.append(filename);

			if (!storage.LoadStringsFrom(localizedName.c_str(), i))
				availableDb2Locales &= ~(1 << i);             // mark as not available for speedup next checks
		}
	}
	else
	{
		// sort problematic db2 to (1) non compatible and (2) nonexistent
		if (FILE* f = fopen(db2_filename.c_str(), "rb"))
		{
			char buf[100];
			snprintf(buf, 100, "(exist, but have %d fields instead " SIZEFMTD ") Wrong client version DBC file?", storage.GetFieldCount(), strlen(storage.GetFormat()));
			errlist.push_back(db2_filename + buf);
			fclose(f);
		}
		else
			errlist.push_back(db2_filename);
	}

	DB2Stores[storage.GetHash()] = &storage;
}
예제 #4
0
inline void LoadDB2(LocalDB2Data& localeData, StoreProblemList1& errors, DB2Storage<T>& storage, std::string const& db2Path, std::string const& filename)
{
    // compatibility format and C++ structure sizes
    MANGOS_ASSERT(DB2FileLoader::GetFormatRecordSize(storage.GetFormat()) == sizeof(T) || LoadDB2_assert_print(DB2FileLoader::GetFormatRecordSize(storage.GetFormat()), sizeof(T), filename));

    ++DB2FileCount;
    std::string db2Filename = db2Path + filename;
    if (storage.Load(db2Filename.c_str(), localeData.defaultLocale))
    {
        for(uint8 i = 0; fullLocaleNameList[i].name; ++i)
        {
            if (!(localeData.availableDb2Locales & (1 << i)))
                continue;

            LocaleNameStr const* localStr = &fullLocaleNameList[i];

            std::string db2_dir_loc = db2Path + localStr->name + "/";

            std::string localizedName = db2Path + localStr->name + "/" + filename;
            if(!storage.LoadStringsFrom(localizedName.c_str(), localStr->locale))
                localeData.availableDb2Locales &= ~(1<<i);  // mark as not available for speedup next checks
        }
    }
    else
    {
        // sort problematic db2 to (1) non compatible and (2) nonexistent
        if (FILE* f = fopen(db2Filename.c_str(), "rb"))
        {
            char buf[100];
            snprintf(buf, 100, " (exist, but have %d fields instead " SIZEFMTD ") Wrong client version DB2 file?", storage.GetFieldCount(), strlen(storage.GetFormat()));
            errors.push_back(db2Filename + buf);
            fclose(f);
        }
        else
            errors.push_back(db2Filename);
    }
}