24#include <boost/filesystem/path.hpp>
45 std::ifstream stream(path.string());
53 if (!std::getline(stream, headers))
59 std::vector<std::string_view> columnDefs =
Trinity::Tokenize(headers,
'\t',
false);
61 ASSERT(columnDefs.size() - 1 ==
sizeof(T) /
sizeof(
float),
62 "GameTable '%s' has different count of columns " SZFMTD " than expected by size of C++ structure (" SZFMTD ").",
63 path.string().c_str(), columnDefs.size() - 1,
sizeof(T) /
sizeof(
float));
69 while (std::getline(stream, line))
77 auto end = values.begin() + values.size() - 1;
78 while (end->empty() && end != values.begin())
81 if (values.begin() == end)
86 ASSERT(std::size_t(std::distance(values.begin(), end)) == columnDefs.size(),
SZFMTD " == " SZFMTD, std::size_t(std::distance(values.begin(), end)), columnDefs.size());
94 float* row =
reinterpret_cast<float*
>(&data.back());
95 for (
auto itr = values.begin() + 1; itr != end; ++itr)
96 *row++ = Trinity::StringTo<float>(*itr, 10).value_or(0.0f);
99 storage.
SetData(std::move(data));
107 boost::filesystem::path gtPath(dataPath);
110 std::vector<std::string> bad_gt_files;
111 uint32 gameTableCount = 0, expectedGameTableCount = 0;
113 auto LOAD_GT = [&]<
typename T>(
GameTable<T>& gameTable,
char const* file)
115 gameTableCount +=
LoadGameTable(bad_gt_files, gameTable, gtPath / file);
116 ++expectedGameTableCount;
136 if (gameTableCount != expectedGameTableCount)
138 std::ostringstream str;
139 for (std::string
const& err : bad_gt_files)
140 str << err << std::endl;
142 WPFatal(
false,
"Some required *.txt GameTable files (" SZFMTD ") not found or not compatible:\n%s", bad_gt_files.size(), str.str().c_str());
155 return row->JewelryMultiplier;
158 return row->TrinketMultiplier;
168 return row->WeaponMultiplier;
171 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)
Default TC string format function.