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

#include <wdtfile.h>

Public Member Functions

 WDTFile (char *file_name, char *file_name1)
 
 ~WDTFile (void)
 
bool init (char *map_id, unsigned int mapID)
 
ADTFileGetMap (int x, int z)
 

Public Attributes

std::vector< std::string > gWmoInstansName
 
int gnWMO
 

Private Attributes

MPQFile WDT
 
std::string filename
 

Constructor & Destructor Documentation

WDTFile::WDTFile ( char *  file_name,
char *  file_name1 
)
35  :WDT(CascStorage, file_name), gnWMO(0)
36 {
37  filename.append(file_name1,strlen(file_name1));
38 }
int gnWMO
Definition: wdtfile.h:41
MPQFile WDT
Definition: wdtfile.h:33
HANDLE CascStorage
Definition: System.cpp:69
std::string filename
Definition: wdtfile.h:34
WDTFile::~WDTFile ( void  )
115 {
116  WDT.close();
117 }
void close()
Definition: mpqfile.cpp:81
MPQFile WDT
Definition: wdtfile.h:33

+ Here is the call graph for this function:

Member Function Documentation

ADTFile * WDTFile::GetMap ( int  x,
int  z 
)
120 {
121  if(!(x>=0 && z >= 0 && x<64 && z<64))
122  return NULL;
123 
124  char name[512];
125 
126  sprintf(name,"World\\Maps\\%s\\%s_%d_%d_obj0.adt", filename.c_str(), filename.c_str(), x, z);
127  return new ADTFile(name);
128 }
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: adtfile.h:110
std::string sprintf(CStringRef format, ArgList args)
Definition: format.h:3096
G3D::int16 z
Definition: Vector3int16.h:46
G3D::int16 x
Definition: Vector2int16.h:37
std::string filename
Definition: wdtfile.h:34

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool WDTFile::init ( char *  map_id,
unsigned int  mapID 
)
41 {
42  if (WDT.isEof())
43  {
44  //printf("Can't find WDT file.\n");
45  return false;
46  }
47 
48  char fourcc[5];
49  uint32 size;
50 
51  std::string dirname = std::string(szWorkDirWmo) + "/dir_bin";
52  FILE *dirfile;
53  dirfile = fopen(dirname.c_str(), "ab");
54  if(!dirfile)
55  {
56  printf("Can't open dirfile!'%s'\n", dirname.c_str());
57  return false;
58  }
59 
60  while (!WDT.isEof())
61  {
62  WDT.read(fourcc,4);
63  WDT.read(&size, 4);
64 
65  flipcc(fourcc);
66  fourcc[4] = 0;
67 
68  size_t nextpos = WDT.getPos() + size;
69 
70  if (!strcmp(fourcc,"MAIN"))
71  {
72  }
73  if (!strcmp(fourcc,"MWMO"))
74  {
75  // global map objects
76  if (size)
77  {
78  char *buf = new char[size];
79  WDT.read(buf, size);
80  char *p = buf;
81  while (p < buf + size)
82  {
83  char* s = wdtGetPlainName(p);
84  FixNameCase(s, strlen(s));
85  p = p + strlen(p) + 1;
86  gWmoInstansName.push_back(s);
87  }
88  delete[] buf;
89  }
90  }
91  else if (!strcmp(fourcc, "MODF"))
92  {
93  // global wmo instance data
94  if (size)
95  {
96  gnWMO = (int)size / 64;
97 
98  for (int i = 0; i < gnWMO; ++i)
99  {
100  int id;
101  WDT.read(&id, 4);
102  WMOInstance inst(WDT, gWmoInstansName[id].c_str(), mapID, 65, 65, dirfile);
103  }
104  }
105  }
106  WDT.seek((int)nextpos);
107  }
108 
109  WDT.close();
110  fclose(dirfile);
111  return true;
112 }
void flipcc(char *fcc)
Definition: mpqfile.h:57
size_t getPos()
Definition: mpqfile.h:48
int gnWMO
Definition: wdtfile.h:41
std::vector< std::string > gWmoInstansName
Definition: wdtfile.h:40
void close()
Definition: mpqfile.cpp:81
bool isEof()
Definition: mpqfile.h:51
char * wdtGetPlainName(char *FileName)
Definition: wdtfile.cpp:24
void FixNameCase(char *name, size_t len)
Definition: adtfile.cpp:47
uint32_t uint32
Definition: Define.h:150
MPQFile WDT
Definition: wdtfile.h:33
size_t read(void *dest, size_t bytes)
Definition: mpqfile.cpp:52
Definition: wmo.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:

+ Here is the caller graph for this function:

Member Data Documentation

std::string WDTFile::filename
private
int WDTFile::gnWMO
std::vector<std::string> WDTFile::gWmoInstansName
MPQFile WDTFile::WDT
private

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