mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-02-10 03:59:05 +01:00
Core/Vmaps: Reduce memory used by vmaps (and their size, slightly)
This commit is contained in:
@@ -224,10 +224,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);
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace ADT
|
||||
|
||||
struct ADTOutputCache
|
||||
{
|
||||
uint32 Flags;
|
||||
uint8 Flags;
|
||||
std::vector<uint8> Data;
|
||||
};
|
||||
|
||||
|
||||
@@ -163,16 +163,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 flags = MOD_M2;
|
||||
uint8 flags = MOD_M2;
|
||||
if (mapID != originalMapId)
|
||||
flags |= MOD_PARENT_SPAWN;
|
||||
|
||||
//write mapID, Flags, NameSet, UniqueId, Pos, Rot, Scale, name
|
||||
fwrite(&mapID, sizeof(uint32), 1, pDirfile);
|
||||
fwrite(&flags, sizeof(uint32), 1, pDirfile);
|
||||
fwrite(&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(&doodadDef.Rotation, sizeof(Vec3D), 1, pDirfile);
|
||||
@@ -187,7 +187,7 @@ void Doodad::Extract(ADT::MDDF const& doodadDef, char const* ModelInstName, uint
|
||||
ADTOutputCache& cacheModelData = dirfileCache->back();
|
||||
cacheModelData.Flags = flags & ~MOD_PARENT_SPAWN;
|
||||
cacheModelData.Data.resize(
|
||||
sizeof(uint16) + // nameSet
|
||||
sizeof(uint8) + // nameSet
|
||||
sizeof(uint32) + // uniqueId
|
||||
sizeof(Vec3D) + // position
|
||||
sizeof(Vec3D) + // doodadDef.Rotation
|
||||
@@ -198,7 +198,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);
|
||||
@@ -273,16 +273,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);
|
||||
@@ -296,7 +296,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
|
||||
@@ -305,7 +305,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);
|
||||
|
||||
@@ -563,14 +563,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);
|
||||
@@ -586,7 +587,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
|
||||
@@ -598,7 +599,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(&mapObjDef.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);
|
||||
|
||||
Reference in New Issue
Block a user