24#include <boost/filesystem/path.hpp>
46 std::ifstream stream(path.string());
54 if (!std::getline(stream, headers))
60 std::vector<std::string_view> columnDefs =
Trinity::Tokenize(headers,
'\t',
false);
62 ASSERT(columnDefs.size() - 1 ==
sizeof(T) /
sizeof(
float),
63 "GameTable '%s' has different count of columns " SZFMTD " than expected by size of C++ structure (" SZFMTD ").",
64 path.string().c_str(), columnDefs.size() - 1,
sizeof(T) /
sizeof(
float));
70 while (std::getline(stream, line))
78 auto end = values.begin() + values.size() - 1;
79 while (end->empty() && end != values.begin())
82 if (values.begin() == end)
87 ASSERT(std::size_t(std::distance(values.begin(), end)) == columnDefs.size(),
SZFMTD " == " SZFMTD, std::size_t(std::distance(values.begin(), end)), columnDefs.size());
95 float* row =
reinterpret_cast<float*
>(&data.back());
96 for (
auto itr = values.begin() + 1; itr != end; ++itr)
97 *row++ = Trinity::StringTo<float>(*itr, 10).value_or(0.0f);
100 storage.
SetData(std::move(data));
108 boost::filesystem::path gtPath(dataPath);
111 std::vector<std::string> bad_gt_files;
112 uint32 gameTableCount = 0, expectedGameTableCount = 0;
114 auto LOAD_GT = [&]<
typename T>(
GameTable<T>& gameTable,
char const* file)
116 gameTableCount +=
LoadGameTable(bad_gt_files, gameTable, gtPath / file);
117 ++expectedGameTableCount;
138 if (gameTableCount != expectedGameTableCount)
140 std::ostringstream str;
141 for (std::string
const& err : bad_gt_files)
142 str << err << std::endl;
144 WPFatal(
false,
"Some required *.txt GameTable files (" SZFMTD ") not found or not compatible:\n%s", bad_gt_files.size(), str.str().c_str());
157 return row->JewelryMultiplier;
160 return row->TrinketMultiplier;
170 return row->WeaponMultiplier;
173 return row->ArmorMultiplier;
#define WPFatal(cond,...)
#define TC_LOG_INFO(filterType__, message__,...)
uint32 GetMSTimeDiffToNow(uint32 oldMSTime)
TC_COMMON_API Optional< std::size_t > RemoveCRLF(std::string &str)
TC_COMMON_API std::vector< std::string_view > Tokenize(std::string_view str, char sep, bool keepEmpty)
std::string StringFormat(FormatString< Args... > fmt, Args &&... args) noexcept
Default TC string format function.