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)
33{
34 memset(bbcorn1, 0, sizeof(bbcorn1));
35 memset(bbcorn2, 0, sizeof(bbcorn2));
36}
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)
145{
146 //printf("Convert RootWmo...\n");
147
148 fwrite(VMAP::RAW_VMAP_MAGIC, 1, 8, pOutfile);
149 unsigned int nVectors = 0;
150 fwrite(&nVectors, sizeof(nVectors), 1, pOutfile); // will be filled later
151 fwrite(&nGroups, 4, 1, pOutfile);
152 fwrite(&RootWMOID, 4, 1, pOutfile);
153 return true;
154}
const char RAW_VMAP_MAGIC[]
Definition: VMapDefinitions.h:26

References nGroups, VMAP::RAW_VMAP_MAGIC, and RootWMOID.

Referenced by ExtractSingleWmo().

◆ open()

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

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().