28 if((szTemp = strrchr(FileName,
'\\')) !=
nullptr)
29 FileName = szTemp + 1;
37 if((szTemp = strrchr(FileName,
'\\')) !=
nullptr)
38 FileName = szTemp + 1;
44 char* ptr = name + len - 1;
47 for (; *ptr !=
'.'; --ptr)
50 for (; ptr >= name; --ptr)
52 if (ptr > name && *ptr >=
'A' && *ptr <=
'Z' && isalpha(*(ptr - 1)))
54 else if ((ptr == name || !isalpha(*(ptr - 1))) && *ptr >=
'a' && *ptr <=
'z')
64 for (
size_t i = 0; i < len - 3; i++)
71 if (len >= 4 && !memcmp(name,
"FILE", 4))
80 if (
char* szTemp = strrchr(FileName,
'.'))
108 std::string dirname = std::string(
szWorkDirWmo) +
"/dir_bin";
109 FILE* dirfile = fopen(dirname.c_str(),
"ab");
112 printf(
"Can't open dirfile!'%s'\n", dirname.c_str());
129 if (!strcmp(fourcc,
"MMDX"))
133 char* buf =
new char[
size];
136 while (p < buf +
size)
152 else if (!strcmp(fourcc,
"MWMO"))
156 char* buf =
new char[
size];
159 while (p < buf +
size)
176 else if (!strcmp(fourcc,
"MDDF"))
181 for (
uint32 i = 0; i < doodadCount; ++i)
185 if (!(doodadDef.
Flags & 0x40))
200 else if (!strcmp(fourcc,
"MODF"))
205 for (
uint32 i = 0; i < mapObjectCount; ++i)
209 if (!(mapObjDef.
Flags & 0x8))
241 std::string dirname = std::string(
szWorkDirWmo) +
"/dir_bin";
242 FILE* dirfile = fopen(dirname.c_str(),
"ab");
245 printf(
"Can't open dirfile!'%s'\n", dirname.c_str());
251 fwrite(&map_num,
sizeof(
uint32), 1, dirfile);
253 if (map_num != originalMapId)
256 fwrite(cached.Data.data(), cached.Data.size(), 1, dirfile);
std::shared_ptr< CASC::Storage > CascStorage
char const * GetPlainName(char const *FileName)
void FixNameCase(char *name, size_t len)
char * GetExtension(char *FileName)
void FixNameSpaces(char *name, size_t len)
void NormalizeFileName(char *name, size_t len)
ADTFile(std::string const &filename, bool cache)
std::vector< std::string > ModelInstanceNames
std::vector< ADTOutputCache > * dirfileCache
std::vector< std::string > WmoInstanceNames
bool init(uint32 map_num, uint32 originalMapId)
bool initFromCache(uint32 map_num, uint32 originalMapId)
size_t read(void *dest, size_t bytes)
void Extract(ADT::MDDF const &doodadDef, char const *ModelInstName, uint32 mapID, uint32 originalMapId, FILE *pDirfile, std::vector< ADTOutputCache > *dirfileCache)
void ExtractSet(WMODoodadData const &doodadData, ADT::MODF const &wmo, bool isGlobalWmo, uint32 mapID, uint32 originalMapId, FILE *pDirfile, std::vector< ADTOutputCache > *dirfileCache)
void Extract(ADT::MODF const &mapObjDef, char const *WmoInstName, bool isGlobalWmo, uint32 mapID, uint32 originalMapId, FILE *pDirfile, std::vector< ADTOutputCache > *dirfileCache)
std::string StringFormat(FormatString< Args... > fmt, Args &&... args)
Default TC string format function.
constexpr std::size_t size()
std::unordered_map< std::string, WMODoodadData > WmoDoodads
char const * szWorkDirWmo
bool ExtractSingleWmo(std::string &fname)