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]
 
std::vector< char > GroupNames
 
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)
150{
151 //printf("Convert RootWmo...\n");
152
153 fwrite(VMAP::RAW_VMAP_MAGIC, 1, 8, pOutfile);
154 unsigned int nVectors = 0;
155 fwrite(&nVectors, sizeof(nVectors), 1, pOutfile); // will be filled later
156 fwrite(&nGroups, 4, 1, pOutfile);
157 fwrite(&RootWMOID, 4, 1, pOutfile);
158 return true;
159}
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 else if (!strcmp(fourcc, "MOGN"))
107 {
108 GroupNames.resize(size);
109 f.read(GroupNames.data(), size);
110 }
111 /*
112 else if (!strcmp(fourcc,"MOTX"))
113 {
114 }
115 else if (!strcmp(fourcc,"MOMT"))
116 {
117 }
118 else if (!strcmp(fourcc,"MOGN"))
119 {
120 }
121 else if (!strcmp(fourcc,"MOGI"))
122 {
123 }
124 else if (!strcmp(fourcc,"MOLT"))
125 {
126 }
127 else if (!strcmp(fourcc,"MOSB"))
128 {
129 }
130 else if (!strcmp(fourcc,"MOPV"))
131 {
132 }
133 else if (!strcmp(fourcc,"MOPT"))
134 {
135 }
136 else if (!strcmp(fourcc,"MOPR"))
137 {
138 }
139 else if (!strcmp(fourcc,"MFOG"))
140 {
141 }
142 */
143 f.seek((int)nextpos);
144 }
145 f.close ();
146 return true;
147}
std::uint32_t uint32
Definition Define.h:107
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
std::vector< char > GroupNames
Definition wmo.h:88
WMODoodadData DoodadData
Definition wmo.h:89
std::unordered_set< uint32 > ValidDoodadNames
Definition wmo.h:90
bool ExtractSingleModel(std::string &fname)
Definition gameobject_extract.cpp:24
void flipcc(char *fcc)
Definition mpq_libmpq04.h:98
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
Definition wmo.h:58
Definition wmo.h:50

References bbcorn1, bbcorn2, MPQFile::close(), color, DoodadData, ExtractSingleModel(), filename, fixname2(), fixnamen(), flags, flipcc(), GetPlainName(), MPQFile::getPointer(), MPQFile::getPos(), GroupNames, 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().

◆ GroupNames

std::vector<char> WMORoot::GroupNames

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

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


The documentation for this class was generated from the following files: