-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathcreateWDT.cpp
More file actions
104 lines (95 loc) · 4.94 KB
/
Copy pathcreateWDT.cpp
File metadata and controls
104 lines (95 loc) · 4.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#include "createWDT.h"
#include <vector>
#include <set>
/**************************************************************
* All WDT's start with 0x4d564552 (REVM), 0x04, 0x12, *
* 0x4d504844 (DHPM), and 0x20. All of those are 1 byte *
* in length. The next byte contains the flags. 0x01 is *
* for WMO-based maps, and 0x08 is probably for maps that *
* contain phasing. The other two flags are unknown. After *
* the flag byte, there appears to be 7 empty bytes. After *
* those bytes, all WDT files seem to contain: 0x4d41494e *
* (NIAM), and 0x8000 (weird C symbol). After these bytes, *
* there is a giant array of 64x64 bytes which contains 0x0 *
* for ADT files that don't exist and 0x1 for ADT's that do *
* exist. *
**************************************************************/
void createWDT(ZoneGroup& zGroup){
if(zGroup.getSize()){ //Guard against empty zoneFile
std::ofstream wdtFile;
wdtFile.open((zGroup.getAdtBase(0) + ".wdt").c_str(), std::fstream::out | std::fstream::binary);
UInt32 buffer;
buffer=0x4d564552;
wdtFile.write((char*)&buffer, 4*1);
buffer=0x04;
wdtFile.write((char*)&buffer, 4*1);
buffer=0x12;
wdtFile.write((char*)&buffer, 4*1);
buffer=0x4d504844; //DHPM
wdtFile.write((char*)&buffer, 4*1);
buffer=0x20;
wdtFile.write((char*)&buffer, 4*1);
/**************************************************************
* This next part uses a hard-coded database that compares *
* the name supplied by the user to a list of known maps to *
* "automagically" determine the flag state. If the name is *
* not found, then a default of 0x0 for the flag will be used.*
**************************************************************/
std::string a=zGroup.getOnlyMapName();
if( a == "test" || a == "Test" || a == "StormwindJail" ||
a == "StormwindPrison" || a == "Collin" || a == "WailingCaverns" ||
a == "Monastery" || a == "Blackfathom" || a == "Uldaman" ||
a == "GnomeragonInstance" || a == "SunkenTemple" || a == "BlackRockSpire" ||
a == "BlackrockDepths" || a == "OnyxiaLairInstance" || a == "Mauradon" ||
a == "DeeprunTram" || a == "OrgrimmarInstance" || a == "MoltenCore" ||
a == "DireMaul" || a == "AlliancePVPBarracks" || a == "HordePVPBarracks" ||
a == "HellfireMilitary" || a == "HellfireDemon" || a == "HellfireRaid" ||
a == "CoilfangPumping" || a == "CoilfangMarsh" || a == "CoilfangDraenei" ||
a == "CoilfangRaid" || a == "TempestKeepRaid" || a == "TempestKeepArcane" ||
a == "TempestKeepAtrium" || a == "TempestKeepFactor" || a == "AuchindounShadow" ||
a == "AuchindounDemon" || a == "AuchindounEthereal" || a == "AuchindounDraenei" ||
a == "GruulsLair" || a == "Nexus70" || a == "Sunwell5Man")
buffer=0x01;
else if( a == "CraigTest")
buffer = 0x04;
else if( a == "ExteriorTest" || a == "Valgarde70" || a == "UtgardePinnacle" ||
a == "Nexus80" || a == "Sunwell5ManFix" || a == "Ulduar70" ||
a == "DrakTheronKeep" || a == "Azjol_Uppercity" || a == "Ulduar80" ||
a == "UlduarRaid" || a == "GunDrak")
buffer = 0x06;
else if( a == "development_nonweighted")
buffer = 0x08;
else if( a == "Northrend" || a == "QA_DVD" || a == "NorthrendBG" ||
a == "DalaranPrison" || a == "DeathKnightStart" || a == "ChamberOfAspectsBlack" ||
a == "NexusRaid" || a == "DalaranArena" || a == "OrgrimmarArena" ||
a == "Azjol_LowerCity" || a == "WintergraspRaid")
buffer = 0x0E;
else buffer = 0x00;
wdtFile.write((char*)&buffer, 4*1);
buffer = 0x00; //Create 7 empty bytes
for(int i=0; i < 7; i++)
wdtFile.write((char*)&buffer, 4*1);
buffer = 0x4d41494e; //NIAM
wdtFile.write((char*)&buffer, 4*1);
buffer = 0x8000; //Weird C symbol
wdtFile.write((char*)&buffer, 4*1);
std::vector<int> xValues(zGroup.getSize());
std::vector<int> yValues(zGroup.getSize());
std::set<std::pair<int, int>> tiles;
for (int i = 0; i < zGroup.getSize(); ++i) {
tiles.insert(std::make_pair(zGroup.getAdtX(i), zGroup.getAdtY(i)));
}
for(int y=0; y < 64; y++)
for(int x=0; x < 64; x++){
buffer = tiles.find(std::make_pair(x, y)) != tiles.end() ? 0x01 : 0x00;
wdtFile.write((char*)&buffer, 4*1);
buffer = 0x00;
wdtFile.write((char*)&buffer, 4*1);
}
buffer = 0x4d574d4f; //OMWM
wdtFile.write((char*)&buffer, 4*1);
buffer = 0x00;
wdtFile.write((char*)&buffer, 4*1);
wdtFile.close();
}
}