35 if (fname.length() < 4)
38 std::string_view extension = std::string_view(fname).substr(fname.length() - 4, 4);
40 fname.replace(fname.length() - 2, 2,
"2");
42 std::string originalName = fname;
54 auto stateGuard = Trinity::make_unique_ptr_with_deleter<&ExtractedModelData::Fail>(model);
56 Model mdl(originalName);
67 stateGuard->Complete();
68 return stateGuard.release();
76 std::unique_ptr<CASC::File> file(
CascStorage->OpenFile(fileName.c_str(), CASC_LOCALE_ALL_WOW));
80 uint32 bytesToRead =
uint32(magic->size() *
sizeof(std::remove_pointer_t<
decltype(magic)>::value_type));
82 if (!file->ReadFile(magic->data(), bytesToRead, &bytesRead) || bytesRead != bytesToRead)
90 printf(
"Extracting GameObject models...\n");
98 catch (std::exception
const& e)
100 printf(
"Fatal error: Invalid GameObjectDisplayInfo.db2 file format!\n%s\n", e.what());
107 std::string modelListPath = basepath +
"temp_gameobject_models";
108 FILE*
model_list = fopen(modelListPath.c_str(),
"wb");
111 printf(
"Fatal error: Could not open file %s\n", modelListPath.c_str());
129 std::array<char, 4> headerRaw;
133 std::string_view header(headerRaw.data(), headerRaw.size());
134 if (header ==
"REVM")
139 else if (header ==
"MD20" || header ==
"MD21")
141 else if (header ==
"BLP2")
151 uint32 path_length = fileName.length();
154 fwrite(fileName.c_str(),
sizeof(
char), path_length,
model_list);
#define STRING_VIEW_FMT_ARG(str)
TC_COMMON_API bool StringEqualI(std::string_view str1, std::string_view str2)
void NormalizeFileName(std::string &name)
std::string_view GetPlainName(std::string_view fileName)
void Load(DB2FileSource *source, DB2FileLoadInfo const *loadInfo)
DB2Record GetRecord(uint32 recordNumber) const
uint32 GetRecordCount() const
uint32 GetUInt32(uint32 field, uint32 arrayIndex) const
bool ConvertToVMAPModel(char const *outfilename)
std::string StringFormat(FormatString< Args... > fmt, Args &&... args) noexcept
Default TC string format function.
const char RAW_VMAP_MAGIC[]
static constexpr DB2LoadInfo Instance
ExtractedModelData const * ExtractSingleWmo(std::string &fname)
char const * szWorkDirWmo
std::pair< ExtractedModelData *, bool > BeginModelExtraction(std::string const &outputName)