AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
WMORoot Class Reference

#include "wmo.h"

Public Member Functions

 WMORoot (std::string const &filename)
 
bool open ()
 
bool ConvertToVMAPRootWmo (FILE *output)
 

Public Attributes

unsigned int color
 
uint32 nTextures
 
uint32 nGroups
 
uint32 nPortals
 
uint32 nLights
 
uint32 nDoodadNames
 
uint32 nDoodadDefs
 
uint32 nDoodadSets
 
uint32 RootWMOID
 
uint32 flags
 
float bbcorn1 [3]
 
float bbcorn2 [3]
 
WMODoodadData DoodadData
 
std::unordered_set< uint32ValidDoodadNames
 

Private Attributes

std::string filename
 

Detailed Description

Constructor & Destructor Documentation

◆ WMORoot()

WMORoot::WMORoot ( std::string const &  filename)
34{
35 memset(bbcorn1, 0, sizeof(bbcorn1));
36 memset(bbcorn2, 0, sizeof(bbcorn2));
37}
float bbcorn1[3]
Definition: wmo.h:85
uint32 nDoodadSets
Definition: wmo.h:84
uint32 nDoodadDefs
Definition: wmo.h:84
uint32 nLights
Definition: wmo.h:84
uint32 nPortals
Definition: wmo.h:84
float bbcorn2[3]
Definition: wmo.h:86
uint32 nGroups
Definition: wmo.h:84
std::string filename
Definition: wmo.h:81
uint32 nDoodadNames
Definition: wmo.h:84
unsigned int color
Definition: wmo.h:83
uint32 nTextures
Definition: wmo.h:84
uint32 flags
Definition: wmo.h:84
uint32 RootWMOID
Definition: wmo.h:84

References bbcorn1, and bbcorn2.

Member Function Documentation

◆ ConvertToVMAPRootWmo()

bool WMORoot::ConvertToVMAPRootWmo ( FILE *  output)
146{
147 //printf("Convert RootWmo...\n");
148
149 fwrite(VMAP::RAW_VMAP_MAGIC, 1, 8, pOutfile);
150 unsigned int nVectors = 0;
151 fwrite(&nVectors, sizeof(nVectors), 1, pOutfile); // will be filled later
152 fwrite(&nGroups, 4, 1, pOutfile);
153 fwrite(&RootWMOID, 4, 1, pOutfile);
154 return true;
155}
const char RAW_VMAP_MAGIC[]
Definition: VMapDefinitions.h:26

References nGroups, VMAP::RAW_VMAP_MAGIC, and RootWMOID.

Referenced by ExtractSingleWmo().

◆ open()

bool WMORoot::open ( )
40{
41 MPQFile f(filename.c_str());
42 if (f.isEof ())
43 {
44 printf("No such file.\n");
45 return false;
46 }
47
48 uint32 size;
49 char fourcc[5];
50
51 while (!f.isEof())
52 {
53 f.read(fourcc, 4);
54 f.read(&size, 4);
55
56 flipcc(fourcc);
57 fourcc[4] = 0;
58
59 std::size_t nextpos = f.getPos() + size;
60
61 if (!strcmp(fourcc, "MOHD")) // header
62 {
63 f.read(&nTextures, 4);
64 f.read(&nGroups, 4);
65 f.read(&nPortals, 4);
66 f.read(&nLights, 4);
67 f.read(&nDoodadNames, 4);
68 f.read(&nDoodadDefs, 4);
69 f.read(&nDoodadSets, 4);
70 f.read(&color, 4);
71 f.read(&RootWMOID, 4);
72 f.read(bbcorn1, 12);
73 f.read(bbcorn2, 12);
74 f.read(&flags, 4);
75 }
76 else if (!strcmp(fourcc, "MODS"))
77 {
78 DoodadData.Sets.resize(size / sizeof(WMO::MODS));
79 f.read(DoodadData.Sets.data(), size);
80 }
81 else if (!strcmp(fourcc,"MODN"))
82 {
83 char* ptr = f.getPointer();
84 char* end = ptr + size;
85 DoodadData.Paths = std::make_unique<char[]>(size);
86 memcpy(DoodadData.Paths.get(), ptr, size);
87 while (ptr < end)
88 {
89 std::string path = ptr;
90
91 char* s = GetPlainName(ptr);
92 fixnamen(s, strlen(s));
93 fixname2(s, strlen(s));
94
95 uint32 doodadNameIndex = ptr - f.getPointer();
96 ptr += path.length() + 1;
97
98 if (ExtractSingleModel(path))
99 ValidDoodadNames.insert(doodadNameIndex);
100 }
101 }
102 else if (!strcmp(fourcc,"MODD"))
103 {
104 DoodadData.Spawns.resize(size / sizeof(WMO::MODD));
105 f.read(DoodadData.Spawns.data(), size);
106 }
107 /*
108 else if (!strcmp(fourcc,"MOTX"))
109 {
110 }
111 else if (!strcmp(fourcc,"MOMT"))
112 {
113 }
114 else if (!strcmp(fourcc,"MOGN"))
115 {
116 }
117 else if (!strcmp(fourcc,"MOGI"))
118 {
119 }
120 else if (!strcmp(fourcc,"MOLT"))
121 {
122 }
123 else if (!strcmp(fourcc,"MOSB"))
124 {
125 }
126 else if (!strcmp(fourcc,"MOPV"))
127 {
128 }
129 else if (!strcmp(fourcc,"MOPT"))
130 {
131 }
132 else if (!strcmp(fourcc,"MOPR"))
133 {
134 }
135 else if (!strcmp(fourcc,"MFOG"))
136 {
137 }
138 */
139 f.seek((int)nextpos);
140 }
141 f.close ();
142 return true;
143}
char const * GetPlainName(char const *FileName)
Definition: adtfile.cpp:27
void fixnamen(char *name, std::size_t len)
Definition: adtfile.cpp:45
void fixname2(char *name, std::size_t len)
Definition: adtfile.cpp:63
bool ExtractSingleModel(std::string &fname)
Definition: gameobject_extract.cpp:25
std::uint32_t uint32
Definition: Define.h:107
Definition: mpq_libmpq04.h:75
Definition: wmo.h:50
Definition: wmo.h:58
std::vector< WMO::MODS > Sets
Definition: wmo.h:72
std::vector< WMO::MODD > Spawns
Definition: wmo.h:74
std::unique_ptr< char[]> Paths
Definition: wmo.h:73
WMODoodadData DoodadData
Definition: wmo.h:88
std::unordered_set< uint32 > ValidDoodadNames
Definition: wmo.h:89
void flipcc(char *fcc)
Definition: mpq_libmpq04.h:99

References bbcorn1, bbcorn2, MPQFile::close(), color, DoodadData, ExtractSingleModel(), filename, fixname2(), fixnamen(), flags, flipcc(), GetPlainName(), MPQFile::getPointer(), MPQFile::getPos(), MPQFile::isEof(), nDoodadDefs, nDoodadNames, nDoodadSets, nGroups, nLights, nPortals, nTextures, WMODoodadData::Paths, MPQFile::read(), RootWMOID, MPQFile::seek(), WMODoodadData::Sets, WMODoodadData::Spawns, and ValidDoodadNames.

Referenced by ExtractSingleWmo().

Member Data Documentation

◆ bbcorn1

float WMORoot::bbcorn1[3]

Referenced by open(), and WMORoot().

◆ bbcorn2

float WMORoot::bbcorn2[3]

Referenced by open(), and WMORoot().

◆ color

unsigned int WMORoot::color

Referenced by open().

◆ DoodadData

WMODoodadData WMORoot::DoodadData

Referenced by ExtractSingleWmo(), and open().

◆ filename

std::string WMORoot::filename
private

Referenced by open().

◆ flags

uint32 WMORoot::flags

Referenced by open(), and WMOGroup::open().

◆ nDoodadDefs

uint32 WMORoot::nDoodadDefs

Referenced by open().

◆ nDoodadNames

uint32 WMORoot::nDoodadNames

Referenced by open().

◆ nDoodadSets

uint32 WMORoot::nDoodadSets

Referenced by open().

◆ nGroups

uint32 WMORoot::nGroups

◆ nLights

uint32 WMORoot::nLights

Referenced by open().

◆ nPortals

uint32 WMORoot::nPortals

Referenced by open().

◆ nTextures

uint32 WMORoot::nTextures

Referenced by open().

◆ RootWMOID

uint32 WMORoot::RootWMOID

Referenced by ConvertToVMAPRootWmo(), and open().

◆ ValidDoodadNames

std::unordered_set<uint32> WMORoot::ValidDoodadNames

Referenced by ExtractSingleWmo(), and open().