This repository has been archived by the owner on Mar 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
map.h
executable file
·170 lines (147 loc) · 6.62 KB
/
map.h
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
/*
Copyright [2008] [Trevor Hogan]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
CODE PORTED FROM THE ORIGINAL GHOST PROJECT: http://ghost.pwner.org/
*/
#ifndef MAP_H
#define MAP_H
#define MAPSPEED_SLOW 1
#define MAPSPEED_NORMAL 2
#define MAPSPEED_FAST 3
#define MAPVIS_HIDETERRAIN 1
#define MAPVIS_EXPLORED 2
#define MAPVIS_ALWAYSVISIBLE 3
#define MAPVIS_DEFAULT 4
#define MAPOBS_NONE 1
#define MAPOBS_ONDEFEAT 2
#define MAPOBS_ALLOWED 3
#define MAPOBS_REFEREES 4
#define MAPFLAG_TEAMSTOGETHER 1
#define MAPFLAG_FIXEDTEAMS 2
#define MAPFLAG_UNITSHARE 4
#define MAPFLAG_RANDOMHERO 8
#define MAPFLAG_RANDOMRACES 16
#define MAPOPT_HIDEMINIMAP 1 << 0
#define MAPOPT_MODIFYALLYPRIORITIES 1 << 1
#define MAPOPT_MELEE 1 << 2 // the bot cares about this one...
#define MAPOPT_REVEALTERRAIN 1 << 4
#define MAPOPT_FIXEDPLAYERSETTINGS 1 << 5 // and this one...
#define MAPOPT_CUSTOMFORCES 1 << 6 // and this one, the rest don't affect the bot's logic
#define MAPOPT_CUSTOMTECHTREE 1 << 7
#define MAPOPT_CUSTOMABILITIES 1 << 8
#define MAPOPT_CUSTOMUPGRADES 1 << 9
#define MAPOPT_WATERWAVESONCLIFFSHORES 1 << 11
#define MAPOPT_WATERWAVESONSLOPESHORES 1 << 12
#define MAPFILTER_MAKER_USER 1
#define MAPFILTER_MAKER_BLIZZARD 2
#define MAPFILTER_TYPE_MELEE 1
#define MAPFILTER_TYPE_SCENARIO 2
#define MAPFILTER_SIZE_SMALL 1
#define MAPFILTER_SIZE_MEDIUM 2
#define MAPFILTER_SIZE_LARGE 4
#define MAPFILTER_OBS_FULL 1
#define MAPFILTER_OBS_ONDEATH 2
#define MAPFILTER_OBS_NONE 4
#define MAPGAMETYPE_UNKNOWN0 1 // always set except for saved games?
// AuthenticatedMakerBlizzard = 1 << 3
// OfficialMeleeGame = 1 << 5
#define MAPGAMETYPE_SAVEDGAME 1 << 9
#define MAPGAMETYPE_PRIVATEGAME 1 << 11
#define MAPGAMETYPE_MAKERUSER 1 << 13
#define MAPGAMETYPE_MAKERBLIZZARD 1 << 14
#define MAPGAMETYPE_TYPEMELEE 1 << 15
#define MAPGAMETYPE_TYPESCENARIO 1 << 16
#define MAPGAMETYPE_SIZESMALL 1 << 17
#define MAPGAMETYPE_SIZEMEDIUM 1 << 18
#define MAPGAMETYPE_SIZELARGE 1 << 19
#define MAPGAMETYPE_OBSFULL 1 << 20
#define MAPGAMETYPE_OBSONDEATH 1 << 21
#define MAPGAMETYPE_OBSNONE 1 << 22
#include "gameslot.h"
//
// CMap
//
class CMap
{
public:
CGHost *m_GHost;
private:
bool m_Valid;
std::string m_CFGFile;
std::string m_MapPath; // config value: map path
BYTEARRAY m_MapSize; // config value: map size (4 bytes)
BYTEARRAY m_MapInfo; // config value: map info (4 bytes) -> this is the real CRC
BYTEARRAY m_MapCRC; // config value: map crc (4 bytes) -> this is not the real CRC, it's the "xoro" value
BYTEARRAY m_MapSHA1; // config value: map sha1 (20 bytes)
unsigned char m_MapSpeed;
unsigned char m_MapVisibility;
unsigned char m_MapObservers;
unsigned char m_MapFlags;
unsigned char m_MapFilterMaker;
unsigned char m_MapFilterType;
unsigned char m_MapFilterSize;
unsigned char m_MapFilterObs;
uint32_t m_MapOptions;
std::vector<std::string> m_MapSupportedModesDescription; // config value
std::vector<std::string> m_MapSupportedModes; // config value
BYTEARRAY m_MapWidth; // config value: map width (2 bytes)
BYTEARRAY m_MapHeight; // config value: map height (2 bytes)
std::string m_MapType; // config value: map type (for stats class)
std::string m_MapMatchMakingCategory; // config value: map matchmaking category (for matchmaking)
std::string m_MapStatsW3MMDCategory; // config value: map stats w3mmd category (for saving w3mmd stats)
std::string m_MapDefaultHCL; // config value: map default HCL to use (this should really be specified elsewhere and not part of the map config)
uint32_t m_MapDefaultPlayerScore; // config value: map default player score (for matchmaking)
std::string m_MapLocalPath; // config value: map local path
bool m_MapLoadInGame; // config value: another way to load game
bool m_MapEvenPlayersStartup; // config value: startup on even players count
std::string m_MapData; // the map data itself, for sending the map to players
uint32_t m_MapNumPlayers;
uint32_t m_MapNumTeams;
std::vector<CGameSlot> m_Slots;
public:
CMap( CGHost *nGHost );
CMap( CGHost *nGHost, CConfig *CFG, std::string nCFGFile );
~CMap( );
bool GetValid( ) { return m_Valid; }
std::string GetCFGFile( ) { return m_CFGFile; }
std::string GetMapPath( ) { return m_MapPath; }
BYTEARRAY GetMapSize( ) { return m_MapSize; }
BYTEARRAY GetMapInfo( ) { return m_MapInfo; }
BYTEARRAY GetMapCRC( ) { return m_MapCRC; }
BYTEARRAY GetMapSHA1( ) { return m_MapSHA1; }
unsigned char GetMapSpeed( ) { return m_MapSpeed; }
unsigned char GetMapVisibility( ) { return m_MapVisibility; }
unsigned char GetMapObservers( ) { return m_MapObservers; }
unsigned char GetMapFlags( ) { return m_MapFlags; }
BYTEARRAY GetMapGameFlags( );
uint32_t GetMapGameType( );
uint32_t GetMapOptions( ) { return m_MapOptions; }
unsigned char GetMapLayoutStyle( );
BYTEARRAY GetMapWidth( ) { return m_MapWidth; }
BYTEARRAY GetMapHeight( ) { return m_MapHeight; }
std::string GetMapType( ) { return m_MapType; }
std::string GetMapMatchMakingCategory( ) { return m_MapMatchMakingCategory; }
std::string GetMapStatsW3MMDCategory( ) { return m_MapStatsW3MMDCategory; }
std::string GetMapDefaultHCL( ) { return m_MapDefaultHCL; }
uint32_t GetMapDefaultPlayerScore( ) { return m_MapDefaultPlayerScore; }
std::string GetMapLocalPath( ) { return m_MapLocalPath; }
bool GetMapLoadInGame( ) { return m_MapLoadInGame; }
bool GetMapEvenPlayersStartup( ) { return m_MapEvenPlayersStartup; }
std::string *GetMapData( ) { return &m_MapData; }
uint32_t GetMapNumPlayers( ) { return m_MapNumPlayers; }
uint32_t GetMapNumTeams( ) { return m_MapNumTeams; }
std::vector<CGameSlot> GetSlots( ) { return m_Slots; }
std::vector<std::string> GetMapSupportedModes() { return m_MapSupportedModesDescription; }
void Load( CConfig *CFG, std::string nCFGFile );
void CheckValid( );
uint32_t XORRotateLeft( unsigned char *data, uint32_t length );
};
#endif