AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
VMAP::ModelSpawn Class Reference

#include "ModelInstance.h"

Inheritance diagram for VMAP::ModelSpawn:
VMAP::ModelInstance

Public Member Functions

bool operator== (const ModelSpawn &other) const
 
const G3D::AABox & GetBounds () const
 

Static Public Member Functions

static bool readFromFile (FILE *rf, ModelSpawn &spawn)
 
static bool writeToFile (FILE *rw, const ModelSpawn &spawn)
 

Public Attributes

uint32 flags
 
uint16 adtId
 
uint32 ID
 
G3D::Vector3 iPos
 
G3D::Vector3 iRot
 
float iScale
 
G3D::AABox iBound
 
std::string name
 

Detailed Description

Member Function Documentation

◆ GetBounds()

const G3D::AABox & VMAP::ModelSpawn::GetBounds ( ) const
inline
56{ return iBound; }
G3D::AABox iBound
Definition: ModelInstance.h:51

References iBound.

Referenced by BoundsTrait< VMAP::ModelSpawn * >::GetBounds().

◆ operator==()

bool VMAP::ModelSpawn::operator== ( const ModelSpawn other) const
inline
53{ return ID == other.ID; }
uint32 ID
Definition: ModelInstance.h:47

References ID.

◆ readFromFile()

bool VMAP::ModelSpawn::readFromFile ( FILE *  rf,
ModelSpawn spawn 
)
static
161 {
162 uint32 check = 0, nameLen;
163 check += fread(&spawn.flags, sizeof(uint32), 1, rf);
164 // EoF?
165 if (!check)
166 {
167 if (ferror(rf))
168 {
169 std::cout << "Error reading ModelSpawn!\n";
170 }
171 return false;
172 }
173 check += fread(&spawn.adtId, sizeof(uint16), 1, rf);
174 check += fread(&spawn.ID, sizeof(uint32), 1, rf);
175 check += fread(&spawn.iPos, sizeof(float), 3, rf);
176 check += fread(&spawn.iRot, sizeof(float), 3, rf);
177 check += fread(&spawn.iScale, sizeof(float), 1, rf);
178 bool has_bound = (spawn.flags & MOD_HAS_BOUND);
179 if (has_bound) // only WMOs have bound in MPQ, only available after computation
180 {
181 Vector3 bLow, bHigh;
182 check += fread(&bLow, sizeof(float), 3, rf);
183 check += fread(&bHigh, sizeof(float), 3, rf);
184 spawn.iBound = G3D::AABox(bLow, bHigh);
185 }
186 check += fread(&nameLen, sizeof(uint32), 1, rf);
187 if (check != uint32(has_bound ? 17 : 11))
188 {
189 std::cout << "Error reading ModelSpawn!\n";
190 return false;
191 }
192 char nameBuff[500];
193 if (nameLen > 500) // file names should never be that long, must be file error
194 {
195 std::cout << "Error reading ModelSpawn, file name too long!\n";
196 return false;
197 }
198 check = fread(nameBuff, sizeof(char), nameLen, rf);
199 if (check != nameLen)
200 {
201 std::cout << "Error reading ModelSpawn!\n";
202 return false;
203 }
204 spawn.name = std::string(nameBuff, nameLen);
205 return true;
206 }
std::uint32_t uint32
Definition: Define.h:107
std::uint16_t uint16
Definition: Define.h:108
@ MOD_HAS_BOUND
Definition: ModelInstance.h:38

References adtId, flags, iBound, ID, iPos, iRot, iScale, VMAP::MOD_HAS_BOUND, and name.

Referenced by VMAP::StaticMapTree::InitMap(), VMAP::StaticMapTree::LoadMapTile(), VMAP::TileAssembler::readMapSpawns(), and VMAP::StaticMapTree::UnloadMapTile().

◆ writeToFile()

bool VMAP::ModelSpawn::writeToFile ( FILE *  rw,
const ModelSpawn spawn 
)
static
209 {
210 uint32 check = 0;
211 check += fwrite(&spawn.flags, sizeof(uint32), 1, wf);
212 check += fwrite(&spawn.adtId, sizeof(uint16), 1, wf);
213 check += fwrite(&spawn.ID, sizeof(uint32), 1, wf);
214 check += fwrite(&spawn.iPos, sizeof(float), 3, wf);
215 check += fwrite(&spawn.iRot, sizeof(float), 3, wf);
216 check += fwrite(&spawn.iScale, sizeof(float), 1, wf);
217 bool has_bound = (spawn.flags & MOD_HAS_BOUND);
218 if (has_bound) // only WMOs have bound in MPQ, only available after computation
219 {
220 check += fwrite(&spawn.iBound.low(), sizeof(float), 3, wf);
221 check += fwrite(&spawn.iBound.high(), sizeof(float), 3, wf);
222 }
223 uint32 nameLen = spawn.name.length();
224 check += fwrite(&nameLen, sizeof(uint32), 1, wf);
225 if (check != uint32(has_bound ? 17 : 11)) { return false; }
226 check = fwrite(spawn.name.c_str(), sizeof(char), nameLen, wf);
227 if (check != nameLen) { return false; }
228 return true;
229 }

References adtId, flags, iBound, ID, iPos, iRot, iScale, VMAP::MOD_HAS_BOUND, and name.

Referenced by VMAP::TileAssembler::convertWorld2().

Member Data Documentation

◆ adtId

◆ flags

◆ iBound

◆ ID

◆ iPos

◆ iRot

◆ iScale

◆ name