TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
VMAP::ModelSpawn Class Reference

#include <ModelInstance.h>

Public Member Functions

bool operator== (const ModelSpawn &other) const
 
const G3D::AABoxgetBounds () 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
 

Member Function Documentation

const G3D::AABox& VMAP::ModelSpawn::getBounds ( ) const
inline
57 { return iBound; }
G3D::AABox iBound
Definition: ModelInstance.h:52

+ Here is the caller graph for this function:

bool VMAP::ModelSpawn::operator== ( const ModelSpawn other) const
inline
54 { return ID == other.ID; }
uint32 ID
Definition: ModelInstance.h:48
bool VMAP::ModelSpawn::readFromFile ( FILE *  rf,
ModelSpawn spawn 
)
static
155  {
156  uint32 check = 0, nameLen;
157  check += fread(&spawn.flags, sizeof(uint32), 1, rf);
158  // EoF?
159  if (!check)
160  {
161  if (ferror(rf))
162  std::cout << "Error reading ModelSpawn!\n";
163  return false;
164  }
165  check += fread(&spawn.adtId, sizeof(uint16), 1, rf);
166  check += fread(&spawn.ID, sizeof(uint32), 1, rf);
167  check += fread(&spawn.iPos, sizeof(float), 3, rf);
168  check += fread(&spawn.iRot, sizeof(float), 3, rf);
169  check += fread(&spawn.iScale, sizeof(float), 1, rf);
170  bool has_bound = (spawn.flags & MOD_HAS_BOUND) != 0;
171  if (has_bound) // only WMOs have bound in MPQ, only available after computation
172  {
173  Vector3 bLow, bHigh;
174  check += fread(&bLow, sizeof(float), 3, rf);
175  check += fread(&bHigh, sizeof(float), 3, rf);
176  spawn.iBound = G3D::AABox(bLow, bHigh);
177  }
178  check += fread(&nameLen, sizeof(uint32), 1, rf);
179  if (check != uint32(has_bound ? 17 : 11))
180  {
181  std::cout << "Error reading ModelSpawn!\n";
182  return false;
183  }
184  char nameBuff[500];
185  if (nameLen > 500) // file names should never be that long, must be file error
186  {
187  std::cout << "Error reading ModelSpawn, file name too long!\n";
188  return false;
189  }
190  check = fread(nameBuff, sizeof(char), nameLen, rf);
191  if (check != nameLen)
192  {
193  std::cout << "Error reading ModelSpawn!\n";
194  return false;
195  }
196  spawn.name = std::string(nameBuff, nameLen);
197  return true;
198  }
Definition: Vector3.h:58
uint32_t uint32
Definition: Define.h:150
uint16_t uint16
Definition: Define.h:151
Definition: ModelInstance.h:39
Definition: AABox.h:32
uint32_t uint32
Definition: g3dmath.h:168
T check(T value)
Definition: format.h:305

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool VMAP::ModelSpawn::writeToFile ( FILE *  rw,
const ModelSpawn spawn 
)
static
201  {
202  uint32 check=0;
203  check += fwrite(&spawn.flags, sizeof(uint32), 1, wf);
204  check += fwrite(&spawn.adtId, sizeof(uint16), 1, wf);
205  check += fwrite(&spawn.ID, sizeof(uint32), 1, wf);
206  check += fwrite(&spawn.iPos, sizeof(float), 3, wf);
207  check += fwrite(&spawn.iRot, sizeof(float), 3, wf);
208  check += fwrite(&spawn.iScale, sizeof(float), 1, wf);
209  bool has_bound = (spawn.flags & MOD_HAS_BOUND) != 0;
210  if (has_bound) // only WMOs have bound in MPQ, only available after computation
211  {
212  check += fwrite(&spawn.iBound.low(), sizeof(float), 3, wf);
213  check += fwrite(&spawn.iBound.high(), sizeof(float), 3, wf);
214  }
215  uint32 nameLen = spawn.name.length();
216  check += fwrite(&nameLen, sizeof(uint32), 1, wf);
217  if (check != uint32(has_bound ? 17 : 11)) return false;
218  check = fwrite(spawn.name.c_str(), sizeof(char), nameLen, wf);
219  if (check != nameLen) return false;
220  return true;
221  }
uint32_t uint32
Definition: Define.h:150
uint16_t uint16
Definition: Define.h:151
Definition: ModelInstance.h:39
uint32_t uint32
Definition: g3dmath.h:168
T check(T value)
Definition: format.h:305

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

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

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