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

#include <adtfile.h>

Public Member Functions

 ADTFile (char *filename)
 
 ~ADTFile ()
 
bool init (uint32 map_num, uint32 tileX, uint32 tileY)
 

Public Attributes

int nWMO
 
int nMDX
 
std::vector< std::string > WmoInstanceNames
 
std::vector< std::string > ModelInstanceNames
 

Private Attributes

MPQFile ADT
 
std::string Adtfilename
 

Constructor & Destructor Documentation

ADTFile::ADTFile ( char *  filename)
82  : ADT(CascStorage, filename, false), nWMO(0), nMDX(0)
83 {
84  Adtfilename.append(filename);
85 }
int nMDX
Definition: adtfile.h:121
MPQFile ADT
Definition: adtfile.h:114
std::string Adtfilename
Definition: adtfile.h:116
HANDLE CascStorage
Definition: System.cpp:69
int nWMO
Definition: adtfile.h:120
ADTFile::~ADTFile ( )
204 {
205  ADT.close();
206 }
void close()
Definition: mpqfile.cpp:81
MPQFile ADT
Definition: adtfile.h:114

+ Here is the call graph for this function:

Member Function Documentation

bool ADTFile::init ( uint32  map_num,
uint32  tileX,
uint32  tileY 
)
88 {
89  if (ADT.isEof())
90  return false;
91 
92  uint32 size;
93  std::string dirname = std::string(szWorkDirWmo) + "/dir_bin";
94  FILE *dirfile;
95  dirfile = fopen(dirname.c_str(), "ab");
96  if(!dirfile)
97  {
98  printf("Can't open dirfile!'%s'\n", dirname.c_str());
99  return false;
100  }
101 
102  while (!ADT.isEof())
103  {
104  char fourcc[5];
105  ADT.read(&fourcc,4);
106  ADT.read(&size, 4);
107  flipcc(fourcc);
108  fourcc[4] = 0;
109 
110  size_t nextpos = ADT.getPos() + size;
111 
112  if (!strcmp(fourcc,"MCIN"))
113  {
114  }
115  else if (!strcmp(fourcc,"MTEX"))
116  {
117  }
118  else if (!strcmp(fourcc,"MMDX"))
119  {
120  if (size)
121  {
122  char* buf = new char[size];
123  ADT.read(buf, size);
124  char* p = buf;
125  while (p < buf + size)
126  {
127  std::string path(p);
128 
129  char* s = GetPlainName(p);
130  FixNameCase(s, strlen(s));
131  FixNameSpaces(s, strlen(s));
132 
133  ModelInstanceNames.push_back(s);
134 
135  ExtractSingleModel(path);
136 
137  p += strlen(p) + 1;
138  }
139  delete[] buf;
140  }
141  }
142  else if (!strcmp(fourcc,"MWMO"))
143  {
144  if (size)
145  {
146  char* buf = new char[size];
147  ADT.read(buf, size);
148  char* p = buf;
149  while (p < buf + size)
150  {
151  char* s = GetPlainName(p);
152  FixNameCase(s, strlen(s));
153  FixNameSpaces(s, strlen(s));
154 
155  WmoInstanceNames.push_back(s);
156 
157  p += strlen(p) + 1;
158  }
159  delete[] buf;
160  }
161  }
162  //======================
163  else if (!strcmp(fourcc,"MDDF"))
164  {
165  if (size)
166  {
167  nMDX = (int)size / 36;
168  for (int i=0; i<nMDX; ++i)
169  {
170  uint32 id;
171  ADT.read(&id, 4);
172  ModelInstance inst(ADT, ModelInstanceNames[id].c_str(), map_num, tileX, tileY, dirfile);
173  }
174 
175  ModelInstanceNames.clear();
176  }
177  }
178  else if (!strcmp(fourcc,"MODF"))
179  {
180  if (size)
181  {
182  nWMO = (int)size / 64;
183  for (int i=0; i<nWMO; ++i)
184  {
185  uint32 id;
186  ADT.read(&id, 4);
187  WMOInstance inst(ADT, WmoInstanceNames[id].c_str(), map_num, tileX, tileY, dirfile);
188  }
189 
190  WmoInstanceNames.clear();
191  }
192  }
193 
194  //======================
195  ADT.seek(nextpos);
196  }
197 
198  ADT.close();
199  fclose(dirfile);
200  return true;
201 }
void flipcc(char *fcc)
Definition: mpqfile.h:57
int nMDX
Definition: adtfile.h:121
Definition: model.h:53
size_t getPos()
Definition: mpqfile.h:48
std::vector< std::string > WmoInstanceNames
Definition: adtfile.h:122
bool ExtractSingleModel(std::string &fname)
Definition: gameobject_extract.cpp:27
void close()
Definition: mpqfile.cpp:81
MPQFile ADT
Definition: adtfile.h:114
bool isEof()
Definition: mpqfile.h:51
void FixNameCase(char *name, size_t len)
Definition: adtfile.cpp:47
std::vector< std::string > ModelInstanceNames
Definition: adtfile.h:123
void FixNameSpaces(char *name, size_t len)
Definition: adtfile.cpp:64
uint32_t uint32
Definition: Define.h:150
size_t read(void *dest, size_t bytes)
Definition: mpqfile.cpp:52
Definition: wmo.h:120
char const * GetPlainName(char const *FileName)
Definition: adtfile.cpp:29
int nWMO
Definition: adtfile.h:120
const char * szWorkDirWmo
Definition: vmapexport.cpp:81
void seek(int offset)
Definition: mpqfile.cpp:69
void printf(BasicWriter< Char > &w, BasicCStringRef< Char > format, ArgList args)
Definition: format.h:3083

+ Here is the call graph for this function:

Member Data Documentation

MPQFile ADTFile::ADT
private
std::string ADTFile::Adtfilename
private
std::vector<std::string> ADTFile::ModelInstanceNames
int ADTFile::nMDX
int ADTFile::nWMO
std::vector<std::string> ADTFile::WmoInstanceNames

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