aboutsummaryrefslogtreecommitdiff
path: root/src/tools
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2021-04-24 23:28:42 +0200
committerShauren <shauren.trinity@gmail.com>2021-04-25 00:11:36 +0200
commitbb8f22ed2013f8cb6b9d61c738f2ebd96b83722f (patch)
tree37e089d220d7c5967266fc71b30ef36de81e67c3 /src/tools
parent4e00cb7c157a0bd25a0b48a80a1f71a1817010bf (diff)
Core/Vmaps: Reduce memory used by vmaps (and their size, slightly)
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/vmap4_extractor/adtfile.cpp4
-rw-r--r--src/tools/vmap4_extractor/adtfile.h2
-rw-r--r--src/tools/vmap4_extractor/model.cpp24
-rw-r--r--src/tools/vmap4_extractor/wmo.cpp11
4 files changed, 21 insertions, 20 deletions
diff --git a/src/tools/vmap4_extractor/adtfile.cpp b/src/tools/vmap4_extractor/adtfile.cpp
index 7d3cea55de7..b643fdf40ae 100644
--- a/src/tools/vmap4_extractor/adtfile.cpp
+++ b/src/tools/vmap4_extractor/adtfile.cpp
@@ -250,10 +250,10 @@ bool ADTFile::initFromCache(uint32 map_num, uint32 originalMapId)
for (ADTOutputCache const& cached : *dirfileCache)
{
fwrite(&map_num, sizeof(uint32), 1, dirfile);
- uint32 flags = cached.Flags;
+ uint8 flags = cached.Flags;
if (map_num != originalMapId)
flags |= MOD_PARENT_SPAWN;
- fwrite(&flags, sizeof(uint32), 1, dirfile);
+ fwrite(&flags, sizeof(uint8), 1, dirfile);
fwrite(cached.Data.data(), cached.Data.size(), 1, dirfile);
}
diff --git a/src/tools/vmap4_extractor/adtfile.h b/src/tools/vmap4_extractor/adtfile.h
index ddedd7a1b82..8c03da3b58b 100644
--- a/src/tools/vmap4_extractor/adtfile.h
+++ b/src/tools/vmap4_extractor/adtfile.h
@@ -52,7 +52,7 @@ namespace ADT
struct ADTOutputCache
{
- uint32 Flags;
+ uint8 Flags;
std::vector<uint8> Data;
};
diff --git a/src/tools/vmap4_extractor/model.cpp b/src/tools/vmap4_extractor/model.cpp
index 690571703b5..0ab2a8ad4b3 100644
--- a/src/tools/vmap4_extractor/model.cpp
+++ b/src/tools/vmap4_extractor/model.cpp
@@ -173,16 +173,16 @@ void Doodad::Extract(ADT::MDDF const& doodadDef, char const* ModelInstName, uint
Vec3D position = fixCoords(doodadDef.Position);
- uint16 nameSet = 0;// not used for models
+ uint8 nameSet = 0;// not used for models
uint32 uniqueId = GenerateUniqueObjectId(doodadDef.UniqueId, 0);
- uint32 tcflags = MOD_M2;
+ uint8 tcflags = MOD_M2;
if (mapID != originalMapId)
tcflags |= MOD_PARENT_SPAWN;
//write mapID, Flags, NameSet, UniqueId, Pos, Rot, Scale, name
fwrite(&mapID, sizeof(uint32), 1, pDirfile);
- fwrite(&tcflags, sizeof(uint32), 1, pDirfile);
- fwrite(&nameSet, sizeof(uint16), 1, pDirfile);
+ fwrite(&tcflags, sizeof(uint8), 1, pDirfile);
+ fwrite(&nameSet, sizeof(uint8), 1, pDirfile);
fwrite(&uniqueId, sizeof(uint32), 1, pDirfile);
fwrite(&position, sizeof(Vec3D), 1, pDirfile);
fwrite(&doodadDef.Rotation, sizeof(Vec3D), 1, pDirfile);
@@ -197,7 +197,7 @@ void Doodad::Extract(ADT::MDDF const& doodadDef, char const* ModelInstName, uint
ADTOutputCache& cacheModelData = dirfileCache->back();
cacheModelData.Flags = tcflags & ~MOD_PARENT_SPAWN;
cacheModelData.Data.resize(
- sizeof(uint16) + // nameSet
+ sizeof(uint8) + // nameSet
sizeof(uint32) + // uniqueId
sizeof(Vec3D) + // position
sizeof(Vec3D) + // doodadDef.Rotation
@@ -208,7 +208,7 @@ void Doodad::Extract(ADT::MDDF const& doodadDef, char const* ModelInstName, uint
uint8* cacheData = cacheModelData.Data.data();
#define CACHE_WRITE(value, size, cnt, dest) memcpy(dest, value, size * cnt); dest += size * cnt;
- CACHE_WRITE(&nameSet, sizeof(uint16), 1, cacheData);
+ CACHE_WRITE(&nameSet, sizeof(uint8), 1, cacheData);
CACHE_WRITE(&uniqueId, sizeof(uint32), 1, cacheData);
CACHE_WRITE(&position, sizeof(Vec3D), 1, cacheData);
CACHE_WRITE(&doodadDef.Rotation, sizeof(Vec3D), 1, cacheData);
@@ -288,16 +288,16 @@ void Doodad::ExtractSet(WMODoodadData const& doodadData, ADT::MODF const& wmo, b
rotation.x = G3D::toDegrees(rotation.x);
rotation.y = G3D::toDegrees(rotation.y);
- uint16 nameSet = 0; // not used for models
+ uint8 nameSet = 0; // not used for models
uint32 uniqueId = GenerateUniqueObjectId(wmo.UniqueId, doodadId);
- uint32 tcflags = MOD_M2;
+ uint8 tcflags = MOD_M2;
if (mapID != originalMapId)
tcflags |= MOD_PARENT_SPAWN;
//write mapID, Flags, NameSet, UniqueId, Pos, Rot, Scale, name
fwrite(&mapID, sizeof(uint32), 1, pDirfile);
- fwrite(&tcflags, sizeof(uint32), 1, pDirfile);
- fwrite(&nameSet, sizeof(uint16), 1, pDirfile);
+ fwrite(&tcflags, sizeof(uint8), 1, pDirfile);
+ fwrite(&nameSet, sizeof(uint8), 1, pDirfile);
fwrite(&uniqueId, sizeof(uint32), 1, pDirfile);
fwrite(&position, sizeof(Vec3D), 1, pDirfile);
fwrite(&rotation, sizeof(Vec3D), 1, pDirfile);
@@ -311,7 +311,7 @@ void Doodad::ExtractSet(WMODoodadData const& doodadData, ADT::MODF const& wmo, b
ADTOutputCache& cacheModelData = dirfileCache->back();
cacheModelData.Flags = tcflags & ~MOD_PARENT_SPAWN;
cacheModelData.Data.resize(
- sizeof(uint16) + // nameSet
+ sizeof(uint8) + // nameSet
sizeof(uint32) + // uniqueId
sizeof(Vec3D) + // position
sizeof(Vec3D) + // rotation
@@ -320,7 +320,7 @@ void Doodad::ExtractSet(WMODoodadData const& doodadData, ADT::MODF const& wmo, b
nlen); // ModelInstName
uint8* cacheData = cacheModelData.Data.data();
- CACHE_WRITE(&nameSet, sizeof(uint16), 1, cacheData);
+ CACHE_WRITE(&nameSet, sizeof(uint8), 1, cacheData);
CACHE_WRITE(&uniqueId, sizeof(uint32), 1, cacheData);
CACHE_WRITE(&position, sizeof(Vec3D), 1, cacheData);
CACHE_WRITE(&rotation, sizeof(Vec3D), 1, cacheData);
diff --git a/src/tools/vmap4_extractor/wmo.cpp b/src/tools/vmap4_extractor/wmo.cpp
index 3cffab838d7..9da996bc923 100644
--- a/src/tools/vmap4_extractor/wmo.cpp
+++ b/src/tools/vmap4_extractor/wmo.cpp
@@ -605,14 +605,15 @@ void MapObject::Extract(ADT::MODF const& mapObjDef, char const* WmoInstName, boo
if (mapObjDef.Flags & 0x4)
scale = mapObjDef.Scale / 1024.0f;
uint32 uniqueId = GenerateUniqueObjectId(mapObjDef.UniqueId, 0);
- uint32 flags = MOD_HAS_BOUND;
+ uint8 flags = MOD_HAS_BOUND;
+ uint8 nameSet = mapObjDef.NameSet;
if (mapID != originalMapId)
flags |= MOD_PARENT_SPAWN;
//write mapID, Flags, NameSet, UniqueId, Pos, Rot, Scale, Bound_lo, Bound_hi, name
fwrite(&mapID, sizeof(uint32), 1, pDirfile);
- fwrite(&flags, sizeof(uint32), 1, pDirfile);
- fwrite(&mapObjDef.NameSet, sizeof(uint16), 1, pDirfile);
+ fwrite(&flags, sizeof(uint8), 1, pDirfile);
+ fwrite(&nameSet, sizeof(uint8), 1, pDirfile);
fwrite(&uniqueId, sizeof(uint32), 1, pDirfile);
fwrite(&position, sizeof(Vec3D), 1, pDirfile);
fwrite(&mapObjDef.Rotation, sizeof(Vec3D), 1, pDirfile);
@@ -628,7 +629,7 @@ void MapObject::Extract(ADT::MODF const& mapObjDef, char const* WmoInstName, boo
ADTOutputCache& cacheModelData = dirfileCache->back();
cacheModelData.Flags = flags & ~MOD_PARENT_SPAWN;
cacheModelData.Data.resize(
- sizeof(uint16) + // mapObjDef.NameSet
+ sizeof(uint8) + // nameSet
sizeof(uint32) + // uniqueId
sizeof(Vec3D) + // position
sizeof(Vec3D) + // mapObjDef.Rotation
@@ -640,7 +641,7 @@ void MapObject::Extract(ADT::MODF const& mapObjDef, char const* WmoInstName, boo
uint8* cacheData = cacheModelData.Data.data();
#define CACHE_WRITE(value, size, count, dest) memcpy(dest, value, size * count); dest += size * count;
- CACHE_WRITE(&mapObjDef.NameSet, sizeof(uint16), 1, cacheData);
+ CACHE_WRITE(&nameSet, sizeof(uint8), 1, cacheData);
CACHE_WRITE(&uniqueId, sizeof(uint32), 1, cacheData);
CACHE_WRITE(&position, sizeof(Vec3D), 1, cacheData);
CACHE_WRITE(&mapObjDef.Rotation, sizeof(Vec3D), 1, cacheData);