47{
49
51 if (!model_list_file)
52 {
54 return;
55 }
56
57 char magic[8];
58 if (fread(magic, 1, 8, model_list_file) != 8 || memcmp(magic,
VMAP::VMAP_MAGIC, 8) != 0)
59 {
61 fclose(model_list_file);
62 return;
63 }
64
65 uint32 name_length, displayId;
67 char buff[500];
68 while (true)
69 {
70 Vector3 v1, v2;
71 if (fread(&displayId,
sizeof(
uint32), 1, model_list_file) != 1)
72 if (feof(model_list_file))
73 {
74 break;
75 }
76
77 if (fread(&isWmo,
sizeof(
uint8), 1, model_list_file) != 1
78 || fread(&name_length,
sizeof(
uint32), 1, model_list_file) != 1
79 || name_length >= sizeof(buff)
80 || fread(&buff, sizeof(char), name_length, model_list_file) != name_length
81 || fread(&v1, sizeof(Vector3), 1, model_list_file) != 1
82 || fread(&v2, sizeof(Vector3), 1, model_list_file) != 1)
83 {
85 fclose(model_list_file);
86 break;
87 }
88
89 if (v1.isNaN() || v2.isNaN())
90 {
91 LOG_ERROR(
"maps",
"File '{}' Model '{}' has invalid v1{} v2{} values!",
93 continue;
94 }
95
96 model_list.emplace(std::piecewise_construct, std::forward_as_tuple(displayId), std::forward_as_tuple(&buff[0], name_length, v1, v2, isWmo != 0));
97 }
98
99 fclose(model_list_file);
100
103}
std::uint8_t uint8
Definition Define.h:109
std::uint32_t uint32
Definition Define.h:107
ModelList model_list
Definition GameObjectModel.cpp:44
#define LOG_INFO(filterType__,...)
Definition Log.h:166
#define LOG_ERROR(filterType__,...)
Definition Log.h:158
uint32 GetMSTimeDiffToNow(uint32 oldMSTime)
Definition Timer.h:131
uint32 getMSTime()
Definition Timer.h:103
const char VMAP_MAGIC[]
Definition VMapDefinitions.h:25
const char GAMEOBJECT_MODELS[]
Definition VMapDefinitions.h:27