AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
GameObjectModel.cpp File Reference
#include "GameObjectModel.h"
#include "Log.h"
#include "MapTree.h"
#include "ModelInstance.h"
#include "Timer.h"
#include "VMapDefinitions.h"
#include "VMapFactory.h"
#include "VMapMgr2.h"
#include "WorldModel.h"
#include "WorldModelStore.h"

Go to the source code of this file.

Classes

struct  GameobjectModelData
 

Typedefs

typedef std::unordered_map< uint32, GameobjectModelDataModelList
 

Functions

void LoadGameObjectModelList (std::string const &dataPath)
 

Variables

ModelList model_list
 

Typedef Documentation

◆ ModelList

typedef std::unordered_map<uint32, GameobjectModelData> ModelList

Function Documentation

◆ LoadGameObjectModelList()

void LoadGameObjectModelList ( std::string const &  dataPath)
47{
48 uint32 oldMSTime = getMSTime();
49
50 FILE* model_list_file = fopen((dataPath + "vmaps/" + VMAP::GAMEOBJECT_MODELS).c_str(), "rb");
51 if (!model_list_file)
52 {
53 LOG_ERROR("maps", "Unable to open '{}' file.", VMAP::GAMEOBJECT_MODELS);
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 {
60 LOG_ERROR("maps", "File '{}' has wrong header, expected {}.", VMAP::GAMEOBJECT_MODELS, VMAP::VMAP_MAGIC);
61 fclose(model_list_file);
62 return;
63 }
64
65 uint32 name_length, displayId;
66 uint8 isWmo;
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)) // EOF flag is only set after failed reading attempt
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 {
84 LOG_ERROR("maps", "File '{}' seems to be corrupted!", VMAP::GAMEOBJECT_MODELS);
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!",
92 VMAP::GAMEOBJECT_MODELS, std::string(buff, name_length), v1.toString(), v2.toString());
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
101 LOG_INFO("server.loading", ">> Loaded {} GameObject Models in {} ms", uint32(model_list.size()), GetMSTimeDiffToNow(oldMSTime));
102 LOG_INFO("server.loading", " ");
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

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

Referenced by World::SetInitialWorldSettings().

Variable Documentation

◆ model_list