diff options
author | Shauren <shauren.trinity@gmail.com> | 2018-04-07 21:56:19 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2019-02-23 22:00:05 +0100 |
commit | 8d1bb258fc4a777b2bd145efd9cadb22d4ec84a2 (patch) | |
tree | 408161f067a32dfd63c8a1c52bbdd15104a5cc7e /src/common/Collision/Models/GameObjectModel.cpp | |
parent | fd30618f12b3414e92acd0ffc8b196bfd295ce00 (diff) |
Tools:
* mapextractor - fixed compressing liquid data
* vmapextractor - fixed extracting liquids inside WMOs
* vmapextractor - implemented new WMO flags
* vmapextractor - store model type for gameobject models
* mmap_generator - fixed processing liquids broken in e5d23103f37c40d2e946fa0e2db66d2f527ad9af
(cherry picked from commit 2c64bb97e6fddcbd15ef39fde3d0828bbf600ec6)
Diffstat (limited to 'src/common/Collision/Models/GameObjectModel.cpp')
-rw-r--r-- | src/common/Collision/Models/GameObjectModel.cpp | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/src/common/Collision/Models/GameObjectModel.cpp b/src/common/Collision/Models/GameObjectModel.cpp index 3165ee0b8f0..ffe0636176b 100644 --- a/src/common/Collision/Models/GameObjectModel.cpp +++ b/src/common/Collision/Models/GameObjectModel.cpp @@ -30,11 +30,12 @@ using G3D::AABox; struct GameobjectModelData { - GameobjectModelData(std::string const& name_, AABox const& box) : - bound(box), name(name_) { } + GameobjectModelData(char const* name_, uint32 nameLength, Vector3 const& lowBound, Vector3 const& highBound, bool isWmo_) : + bound(lowBound, highBound), name(name_, nameLength), isWmo(isWmo_) { } AABox bound; std::string name; + bool isWmo; }; typedef std::unordered_map<uint32, GameobjectModelData> ModelList; @@ -53,7 +54,16 @@ void LoadGameObjectModelList(std::string const& dataPath) return; } + char magic[8]; + if (fread(magic, 1, 8, model_list_file) != 8 + || memcmp(magic, VMAP::VMAP_MAGIC, 8) != 0) + { + TC_LOG_ERROR("misc", "File '%s' has wrong header, expected %s.", VMAP::GAMEOBJECT_MODELS, VMAP::VMAP_MAGIC); + return; + } + uint32 name_length, displayId; + uint8 isWmo; char buff[500]; while (true) { @@ -62,7 +72,8 @@ void LoadGameObjectModelList(std::string const& dataPath) if (feof(model_list_file)) // EOF flag is only set after failed reading attempt break; - if (fread(&name_length, sizeof(uint32), 1, model_list_file) != 1 + if (fread(&isWmo, sizeof(uint8), 1, model_list_file) != 1 + || fread(&name_length, sizeof(uint32), 1, model_list_file) != 1 || name_length >= sizeof(buff) || fread(&buff, sizeof(char), name_length, model_list_file) != name_length || fread(&v1, sizeof(Vector3), 1, model_list_file) != 1 @@ -78,10 +89,7 @@ void LoadGameObjectModelList(std::string const& dataPath) continue; } - model_list.insert - ( - ModelList::value_type(displayId, GameobjectModelData(std::string(buff, name_length), AABox(v1, v2))) - ); + model_list.emplace(std::piecewise_construct, std::forward_as_tuple(displayId), std::forward_as_tuple(&buff[0], name_length, v1, v2, isWmo != 0)); } fclose(model_list_file); |