AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
GameObjectModel.h File Reference
#include "Define.h"
#include <G3D/AABox.h>
#include <G3D/Matrix3.h>
#include <G3D/Ray.h>
#include <G3D/Vector3.h>

Go to the source code of this file.

Classes

class  GameObjectModelOwnerBase
 
class  GameObjectModel
 

Namespaces

namespace  VMAP
 

Functions

void LoadGameObjectModelList (std::string const &dataPath)
 

Function Documentation

◆ LoadGameObjectModelList()

void LoadGameObjectModelList ( std::string const &  dataPath)
46{
47 uint32 oldMSTime = getMSTime();
48
49 FILE* model_list_file = fopen((dataPath + "vmaps/" + VMAP::GAMEOBJECT_MODELS).c_str(), "rb");
50 if (!model_list_file)
51 {
52 LOG_ERROR("maps", "Unable to open '{}' file.", VMAP::GAMEOBJECT_MODELS);
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 {
59 LOG_ERROR("maps", "File '{}' has wrong header, expected {}.", VMAP::GAMEOBJECT_MODELS, VMAP::VMAP_MAGIC);
60 fclose(model_list_file);
61 return;
62 }
63
64 uint32 name_length, displayId;
65 uint8 isWmo;
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)) // EOF flag is only set after failed reading attempt
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 {
83 LOG_ERROR("maps", "File '{}' seems to be corrupted!", VMAP::GAMEOBJECT_MODELS);
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!",
91 VMAP::GAMEOBJECT_MODELS, std::string(buff, name_length), v1.toString(), v2.toString());
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
100 LOG_INFO("server.loading", ">> Loaded {} GameObject Models in {} ms", uint32(model_list.size()), GetMSTimeDiffToNow(oldMSTime));
101 LOG_INFO("server.loading", " ");
102}
ModelList model_list
Definition: GameObjectModel.cpp:43
std::uint8_t uint8
Definition: Define.h:110
std::uint32_t uint32
Definition: Define.h:108
#define LOG_INFO(filterType__,...)
Definition: Log.h:165
#define LOG_ERROR(filterType__,...)
Definition: Log.h:157
uint32 GetMSTimeDiffToNow(uint32 oldMSTime)
Definition: Timer.h:131
uint32 getMSTime()
Definition: Timer.h:103
const char VMAP_MAGIC[]
Definition: VMapDefinitions.h:26
const char GAMEOBJECT_MODELS[]
Definition: VMapDefinitions.h:28

References VMAP::GAMEOBJECT_MODELS, getMSTime(), GetMSTimeDiffToNow(), LOG_ERROR, LOG_INFO, model_list, and VMAP::VMAP_MAGIC.

Referenced by World::SetInitialWorldSettings().