Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Toggle main menu visibility
Loading...
Searching...
No Matches
wdtfile.cpp
Go to the documentation of this file.
1
/*
2
* This file is part of Project SkyFire https://www.projectskyfire.org.
3
* See LICENSE.md file for Copyright information
4
*/
5
6
#include "
vmapexport.h
"
7
#include "
wdtfile.h
"
8
#include "
adtfile.h
"
9
#include <cstdio>
10
11
char
*
wdtGetPlainName
(
char
* FileName)
12
{
13
char
* szTemp;
14
15
if
((szTemp = strrchr(FileName,
'\\'
)) != NULL)
16
FileName = szTemp + 1;
17
return
FileName;
18
}
19
20
extern
HANDLE
WorldMpq
;
21
22
WDTFile::WDTFile
(
char
* file_name,
char
* file_name1):
WDT
(
WorldMpq
, file_name),
gnWMO
(0)
23
{
24
filename
.append(file_name1,strlen(file_name1));
25
}
26
27
bool
WDTFile::init
(
char
*
/*map_id*/
,
unsigned
int
mapID)
28
{
29
if
(
WDT
.isEof())
30
{
31
//printf("Can't find WDT file.\n");
32
return
false
;
33
}
34
35
char
fourcc[5];
36
uint32
size;
37
38
std::string dirname = std::string(
szWorkDirWmo
) +
"/dir_bin"
;
39
FILE *dirfile;
40
dirfile = fopen(dirname.c_str(),
"ab"
);
41
if
(!dirfile)
42
{
43
printf(
"Can't open dirfile!'%s'\n"
, dirname.c_str());
44
return
false
;
45
}
46
47
while
(!
WDT
.isEof())
48
{
49
WDT
.read(fourcc,4);
50
WDT
.read(&size, 4);
51
52
flipcc
(fourcc);
53
fourcc[4] = 0;
54
55
size_t
nextpos =
WDT
.getPos() + size;
56
57
if
(!strcmp(fourcc,
"MAIN"
))
58
{
59
}
60
if
(!strcmp(fourcc,
"MWMO"
))
61
{
62
// global map objects
63
if
(size)
64
{
65
char
*buf =
new
char
[size];
66
WDT
.read(buf, size);
67
char
*p = buf;
68
while
(p < buf + size)
69
{
70
char
* s=
wdtGetPlainName
(p);
71
FixNameCase
(s,strlen(s));
72
p=p+strlen(p)+1;
73
gWmoInstansName
.push_back(s);
74
}
75
delete
[] buf;
76
}
77
}
78
else
if
(!strcmp(fourcc,
"MODF"
))
79
{
80
// global wmo instance data
81
if
(size)
82
{
83
gnWMO
= (int)size / 64;
84
85
for
(
int
i = 0; i <
gnWMO
; ++i)
86
{
87
int
id;
88
WDT
.read(&
id
, 4);
89
WMOInstance
inst(
WDT
,
gWmoInstansName
[
id
].c_str(), mapID, 65, 65, dirfile);
90
}
91
}
92
}
93
WDT
.seek((
int
)nextpos);
94
}
95
96
WDT
.close();
97
fclose(dirfile);
98
return
true
;
99
}
100
101
WDTFile::~WDTFile
(
void
)
102
{
103
WDT
.close();
104
}
105
106
ADTFile
*
WDTFile::GetMap
(
int
x,
int
z)
107
{
108
if
(!(x>=0 && z >= 0 && x<64 && z<64))
109
return
NULL;
110
111
char
name[512];
112
113
snprintf(name,
sizeof
(name),
"World\\Maps\\%s\\%s_%d_%d_obj0.adt"
,
filename
.c_str(),
filename
.c_str(), x, z);
114
return
new
ADTFile
(name);
115
}
uint32
std::uint32_t uint32
Definition
Define.h:77
WorldMpq
HANDLE WorldMpq
Definition
System.cpp:49
FixNameCase
void FixNameCase(char *name, size_t len)
Definition
adtfile.cpp:34
adtfile.h
ADTFile
Definition
adtfile.h:99
WDTFile::gWmoInstansName
std::vector< std::string > gWmoInstansName
Definition
wdtfile.h:27
WDTFile::WDTFile
WDTFile(char *file_name, char *file_name1)
Definition
wdtfile.cpp:22
WDTFile::~WDTFile
~WDTFile(void)
Definition
wdtfile.cpp:101
WDTFile::gnWMO
int gnWMO
Definition
wdtfile.h:28
WDTFile::init
bool init(char *map_id, unsigned int mapID)
Definition
wdtfile.cpp:27
WDTFile::GetMap
ADTFile * GetMap(int x, int z)
Definition
wdtfile.cpp:106
WDTFile::filename
std::string filename
Definition
wdtfile.h:21
WDTFile::WDT
MPQFile WDT
Definition
wdtfile.h:20
WMOInstance
Definition
wmo.h:105
flipcc
void flipcc(char *fcc)
Definition
mpqfile.h:75
szWorkDirWmo
const char * szWorkDirWmo
Definition
vmapexport.cpp:115
vmapexport.h
wdtGetPlainName
char * wdtGetPlainName(char *FileName)
Definition
wdtfile.cpp:11
wdtfile.h
src
tools
vmap4_extractor
wdtfile.cpp
Generated on
for Project SkyFire Core by
1.17.0