-
Notifications
You must be signed in to change notification settings - Fork 0
/
MapInfo.hpp
184 lines (165 loc) · 8.78 KB
/
MapInfo.hpp
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
#include <bitset>
#include <glm/vec2.hpp>
#define GLM_ENABLE_EXPERIMENTAL
#include <glm/ext.hpp>
#include <vector>
#include "BinaryReader.h"
int load_map(std::ostream* out, std::string& input, bool debug)
{
std::ifstream fin(input, std::ios_base::binary);
fin.seekg(0, std::ios::end);
const size_t fileSize = fin.tellg();
fin.seekg(0, std::ios::beg);
std::vector<uint8_t> buffer(fileSize);
fin.read(reinterpret_cast<char*>(buffer.data()), fileSize);
fin.close();
BinaryReader reader(buffer);
int version;
*out << "Version: " << (version = reader.read<uint32_t>()) << '\n'
<< "Map version: " << reader.read<uint32_t>() << '\n'
<< "Editor version: " << reader.read<uint32_t>() << '\n'
<< "Game version: " << reader.read<uint32_t>() << '.'<< reader.read<uint32_t>() << '.'<< reader.read<uint32_t>() << '.'<< reader.read<uint32_t>() << '\n'
<< "Map name: " << reader.read_c_string() << '\n'
<< "Author name: " << reader.read_c_string() << '\n'
<< "Description: " << reader.read_c_string() << '\n'
<< "Suggested players: " << reader.read_c_string() << '\n'
<< "Camera bottom left: " << glm::to_string(reader.read<glm::vec2>()) << '\n'
<< "Camera top right: " << glm::to_string(reader.read<glm::vec2>()) << '\n'
<< "Camera top left: " << glm::to_string(reader.read<glm::vec2>()) << '\n'
<< "Camera bottom right: " << glm::to_string(reader.read<glm::vec2>()) << '\n'
<< "Camera complements: " << glm::to_string(reader.read<glm::ivec4>()) << '\n'
<< "Playable width: " << reader.read<uint32_t>() << '\n'
<< "Playable height: " << reader.read<uint32_t>() << '\n';
const int flags = reader.read<uint32_t>();
*out << "Hide minimap preview: " << std::boolalpha << (bool)(flags & 0x0001) << '\n'
<< "Modified ally properties: " << (bool)(flags & 0x00002) << '\n'
<< "Melee: " << (bool)(flags & 0x00004) << '\n'
<< "Was large: " << (bool)(flags & 0x00008) << '\n'
<< "Partial masked area visibility: " << (bool)(flags & 0x00010) << '\n'
<< "Fixed player settings: " << (bool)(flags & 0x00020) << '\n'
<< "Custom forces: " << (bool)(flags & 0x00040) << '\n'
<< "Custom techtree: " << (bool)(flags & 0x00080) << '\n'
<< "Custom abilities: " << (bool)(flags & 0x00100) << '\n'
<< "Custom upgrades: " << (bool)(flags & 0x00200) << '\n'
<< "Properties menu opened: " << (bool)(flags & 0x00400) << '\n'
<< "Cliff shore waves: " << (bool)(flags & 0x00800) << '\n'
<< "Rolling shore waves: " << (bool)(flags & 0x01000) << '\n'
<< "Terrain fog: " << (bool)(flags & 0x02000) << '\n'
<< "Expansion required: " << (bool)(flags & 0x04000) << '\n'
<< "Item classification: " << (bool)(flags & 0x08000) << '\n'
<< "Water tinting: " << (bool)(flags & 0x10000) << '\n'
<< "Accurate probablility: " << (bool)(flags & 0x20000) << '\n'
<< "Ability skins: " << (bool)(flags & 0x40000) << '\n'
<< "Tileset: " << reader.read_string(1) << '\n'
<< "Loading screen number: " << reader.read<int32_t>() << '\n'
<< "Loading screen model: " << reader.read_c_string() << '\n'
<< "Loading screen text: " << reader.read_c_string() << '\n'
<< "Loading screen title: " << reader.read_c_string() << '\n'
<< "Loading screen subtitle: " << reader.read_c_string() << '\n'
<< "Game data set: " << reader.read<uint32_t>() << '\n'
<< "Prologue screen model: " << reader.read_c_string() << '\n'
<< "Prologue screen text: " << reader.read_c_string() << '\n'
<< "Prologue screen title: " << reader.read_c_string() << '\n'
<< "Prologue screen subtitle: " << reader.read_c_string() << '\n'
<< "Fog style: " << reader.read<uint32_t>() << '\n'
<< "Fog start Z: " << reader.read<float>() << '\n'
<< "Fog end Z: " << reader.read<float>() << '\n'
<< "Fog density: " << reader.read<float>() << '\n'
<< "Fog colour: " << glm::to_string(reader.read<glm::u8vec4>()) << '\n'
<< "Weather ID: " << reader.read<uint32_t>() << '\n'
<< "Custom sound path: " << reader.read_c_string() << '\n'
<< "Custom light tileset: " << reader.read<uint8_t>() << '\n'
<< "Water colour: " << glm::to_string(reader.read<glm::u8vec4>()) << '\n'
<< "Lua: " << (bool)reader.read<uint32_t>() << '\n';
if (version >= 31)
{
const int modes = reader.read<uint32_t>();
*out << "Supports SD: " << (bool)(modes & 0x0001) << '\n'
<< "Supports HD: " << (bool)(modes & 0x0002) << '\n'
<< "TFT game data: " << (bool)(reader.read<uint32_t>() - 1) << "\n\n";
}
uint32_t players = reader.read<uint32_t>();
//*out << "Number of players: " << players << "\n\n";
for (uint32_t i = 0; i < players; i++)
{
*out << "Number: " << reader.read<uint32_t>() << '\n'
<< "Type: " << reader.read<uint32_t>() << '\n'
<< "Race: " << reader.read<uint32_t>() << '\n'
<< "Fixed start position: " << (bool)reader.read<uint32_t>() << '\n'
<< "Name: " << reader.read_c_string() << '\n'
<< "Starting position: " << glm::to_string(reader.read<glm::vec2>()) << '\n'
<< "Ally low priorities: " << std::bitset<32>(reader.read<uint32_t>()) << '\n'
<< "Ally high priorities: " << std::bitset<32>(reader.read<uint32_t>()) << '\n';
if (version >= 31)
*out << "Enemy low priorities: " << std::bitset<32>(reader.read<uint32_t>()) << '\n'
<< "Enemy high priorities: " << std::bitset<32>(reader.read<uint32_t>()) << '\n';
}
uint32_t forces = reader.read<uint32_t>();
//*out << "Number of buttons: " << buttons << "\n\n";
for (uint32_t i = 0; i < forces; i++)
{
const uint32_t force_flags = reader.read<uint32_t>();
*out << "Allied: " << (bool)(force_flags & 0x0001) << '\n'
<< "Allied victory: " << (bool)(force_flags & 0x00002) << '\n'
<< "Share vision: " << (bool)(force_flags & 0x00004) << '\n'
<< "Share unit control: " << (bool)(force_flags & 0x00008) << '\n'
<< "Share advanced unit control: " << (bool)(force_flags & 0x00010) << '\n'
<< "Players: " << std::bitset<32>(reader.read<uint32_t>()) << '\n'
<< "Name: " << reader.read_c_string() << "\n\n";
}
uint32_t upgrades = reader.read<uint32_t>();
//*out << "Number of upgrades: " << upgrades << "\n\n";
for (uint32_t i = 0; i < upgrades; i++)
{
*out << "Upgrade Players: " << std::bitset<32>(reader.read<uint32_t>()) << '\n'
<< "Upgrade ID: " << reader.read_string(4) << '\n'
<< "Affected level: " << (reader.read<uint32_t>() + 1) << '\n'
<< "Availability: " << reader.read<uint32_t>() << "\n\n";
}
uint32_t tech = reader.read<uint32_t>();
//*out << "Number of tech modifications: " << tech << "\n\n";
for (uint32_t i = 0; i < tech; i++)
{
*out << "Tech Unavailable for Players: " << std::bitset<32>(reader.read<uint32_t>()) << '\n'
<< "Tech ID: " << reader.read_string(4) << "\n\n";
}
uint32_t unit_groups = reader.read<uint32_t>();
//*out << "Number of unit groups: " << unit_groups << "\n\n";
for (uint32_t i = 0; i < unit_groups; i++)
{
*out << "\nGroup number: " << reader.read<uint32_t>() << '\n'
<< "Group name: " << reader.read_c_string() << '\n';
uint32_t positions = reader.read<uint32_t>();
for (uint32_t j = 0; j < positions; j++)
{
*out << "Table type: " << reader.read<uint32_t>() << '\n';
}
uint32_t lines = reader.read<uint32_t>();
for (uint32_t j = 0; j < lines; j++)
{
*out << "Line chance: " << reader.read<uint32_t>() << '\n'
<< "Unit IDs: ";
for (uint32_t k = 0; k < positions; k++)
*out << reader.read_string(4) << ' ';
*out << '\n';
}
*out << '\n';
}
uint32_t item_groups = reader.read<uint32_t>();
//*out << "Number of item groups: " << item_groups << "\n\n";
for (uint32_t i = 0; i < item_groups; i++)
{
*out << "\nGroup number: " << reader.read<uint32_t>() << '\n'
<< "Group name: " << reader.read_c_string() << '\n';
uint32_t positions = reader.read<uint32_t>();
uint32_t lines = reader.read<uint32_t>();
for (uint32_t j = 0; j < lines; j++)
{
*out << "Line chance: " << reader.read<uint32_t>() << '\n';
for (uint32_t k = 0; k < positions; k++)
*out << "Item ID: " << reader.read_string(4) << ' ';
*out << '\n';
}
}
return 0;
}