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
160 {
161 uint32 check = 0, nameLen;
162 check += fread(&spawn.flags, sizeof(uint32), 1, rf);
163 // EoF?
164 if (!check)
165 {
166 if (ferror(rf))
167 {
168 std::cout << "Error reading ModelSpawn!\n";
169 }
170 return false;
171 }
172 check += fread(&spawn.adtId, sizeof(uint16), 1, rf);
173 check += fread(&spawn.ID, sizeof(uint32), 1, rf);
174 check += fread(&spawn.iPos, sizeof(float), 3, rf);
175 check += fread(&spawn.iRot, sizeof(float), 3, rf);
176 check += fread(&spawn.iScale, sizeof(float), 1, rf);
177 bool has_bound = (spawn.flags & MOD_HAS_BOUND);
178 if (has_bound) // only WMOs have bound in MPQ, only available after computation
179 {
180 Vector3 bLow, bHigh;
181 check += fread(&bLow, sizeof(float), 3, rf);
182 check += fread(&bHigh, sizeof(float), 3, rf);
183 spawn.iBound = G3D::AABox(bLow, bHigh);
184 }
185 check += fread(&nameLen, sizeof(uint32), 1, rf);
186 if (check != uint32(has_bound ? 17 : 11))
187 {
188 std::cout << "Error reading ModelSpawn!\n";
189 return false;
190 }
191 char nameBuff[500];
192 if (nameLen > 500) // file names should never be that long, must be file error
193 {
194 std::cout << "Error reading ModelSpawn, file name too long!\n";
195 return false;
196 }
197 check = fread(nameBuff, sizeof(char), nameLen, rf);
198 if (check != nameLen)
199 {
200 std::cout << "Error reading ModelSpawn!\n";
201 return false;
202 }
203 spawn.name = std::string(nameBuff, nameLen);
204 return true;
205 }
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
208 {
209 uint32 check = 0;
210 check += fwrite(&spawn.flags, sizeof(uint32), 1, wf);
211 check += fwrite(&spawn.adtId, sizeof(uint16), 1, wf);
212 check += fwrite(&spawn.ID, sizeof(uint32), 1, wf);
213 check += fwrite(&spawn.iPos, sizeof(float), 3, wf);
214 check += fwrite(&spawn.iRot, sizeof(float), 3, wf);
215 check += fwrite(&spawn.iScale, sizeof(float), 1, wf);
216 bool has_bound = (spawn.flags & MOD_HAS_BOUND);
217 if (has_bound) // only WMOs have bound in MPQ, only available after computation
218 {
219 check += fwrite(&spawn.iBound.low(), sizeof(float), 3, wf);
220 check += fwrite(&spawn.iBound.high(), sizeof(float), 3, wf);
221 }
222 uint32 nameLen = spawn.name.length();
223 check += fwrite(&nameLen, sizeof(uint32), 1, wf);
224 if (check != uint32(has_bound ? 17 : 11)) { return false; }
225 check = fwrite(spawn.name.c_str(), sizeof(char), nameLen, wf);
226 if (check != nameLen) { return false; }
227 return true;
228 }

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