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