-
Notifications
You must be signed in to change notification settings - Fork 271
/
OrderTypes.cpp
executable file
·277 lines (274 loc) · 10 KB
/
OrderTypes.cpp
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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
#include "OrderTypes.h"
#include <BWAPI/Unit.h>
#include <BWAPI/Unitset.h>
#include <BWAPI/Order.h>
#include <BWAPI/Race.h>
#include "../../../Debug.h"
namespace BW
{
namespace Orders
{
//--------------------------------------- ATTACK LOCATION CONSTRUCTOR -----------------------------------
Attack::Attack(BWAPI::Unit target, BWAPI::Order OrderID, bool queued)
: target(target)
, order(static_cast<u8>(OrderID))
, type(queued ? 1 : 0)
{
}
//--------------------------------------- ATTACK LOCATION CONSTRUCTOR -----------------------------------
Attack::Attack(const BW::Position& target, BWAPI::Order OrderID, bool queued)
: target(target)
, order(static_cast<u8>(OrderID))
, type(queued ? 1 : 0)
{
}
Attack::Attack(int x, int y, BWAPI::Order OrderID, bool queued)
: target(x,y)
, order(static_cast<u8>(OrderID))
, type(queued ? 1 : 0)
{
}
//--------------------------------------- ATTACK LOCATION CONSTRUCTOR -----------------------------------
Attack::Attack(const PositionUnitTarget& target, BWAPI::Order OrderID, bool queued)
: target(target)
, order(static_cast<u8>(OrderID))
, type(queued ? 1 : 0)
{
}
//--------------------------------------- RIGHT CLICK CONSTRUCTOR ---------------------------------------
RightClick::RightClick(BWAPI::Unit target, bool queued)
: target(target)
, type(queued ? 1 : 0)
{
}
//--------------------------------------- RIGHT CLICK CONSTRUCTOR ---------------------------------------
RightClick::RightClick(const BW::Position& target, bool queued)
: target(target)
, type(queued ? 1 : 0)
{
}
RightClick::RightClick(int x, int y, bool queued)
: target(x,y)
, type(queued ? 1 : 0)
{
}
//--------------------------------------- RIGHT CLICK CONSTRUCTOR ---------------------------------------
RightClick::RightClick(const PositionUnitTarget& target, bool queued)
: target(target)
, type(queued ? 1 : 0)
{
}
//--------------------------------------- SHIFT SELECT CONSTRUCTOR ---------------------------------------
SelectAdd::SelectAdd(int count, const BWAPI::Unit *units)
{
targCount = 0;
for (int i = 0; i < count && i < MAX_SELECTION_COUNT; ++i)
{
if (units[i])
targets[targCount++] = UnitTarget(units[i]);
}
}
SelectAdd::SelectAdd(int count, const BW::CUnit **units)
{
targCount = 0;
for (int i = 0; i < count && i < MAX_SELECTION_COUNT; ++i)
{
if (units[i])
targets[targCount++] = UnitTarget(units[i]);
}
}
size_t SelectAdd::size() const
{
return 2 + targCount * 2;
}
//----------------------------------------- SELECT CONSTRUCTOR -------------------------------------------
Select::Select(int count, const BWAPI::Unit *units)
{
targCount = 0;
for (int i = 0; i < count && i < MAX_SELECTION_COUNT; ++i)
{
if (units[i])
targets[targCount++] = UnitTarget(units[i]);
}
}
Select::Select(int count, const BW::CUnit **units)
{
targCount = 0;
for (int i = 0; i < count && i < MAX_SELECTION_COUNT; ++i)
{
if (units[i])
targets[targCount++] = UnitTarget(units[i]);
}
}
Select::Select(const std::vector<BWAPI::Unit>& units)
: Select(static_cast<int>(units.size()), units.data())
{
}
size_t Select::size() const
{
return 2 + targCount * 2;
}
//---------------------------------------- TRAIN UNIT CONSTRUCTOR ----------------------------------------
TrainUnit::TrainUnit(BWAPI::UnitType type)
: type(static_cast<u16>(type))
{
}
//--------------------------------------------- MAKE BULDING ---------------------------------------------
MakeBuilding::MakeBuilding(BW::TilePosition position, BWAPI::UnitType type)
: position(position)
, type(static_cast<u16>(type))
{
switch( BWAPI::UnitType(type).getRace() )
{
case BWAPI::Races::Enum::Zerg:
raceDependant = BWAPI::Orders::Enum::DroneStartBuild;
break;
case BWAPI::Races::Enum::Terran:
raceDependant = BWAPI::Orders::Enum::PlaceBuilding;
break;
case BWAPI::Races::Enum::Protoss:
raceDependant = BWAPI::Orders::Enum::PlaceProtossBuilding;
break;
default:
break;
}
}
MakeBuilding::MakeBuilding(int tileX, int tileY, BWAPI::UnitType type)
: MakeBuilding(BW::TilePosition(static_cast<s16>(tileX), static_cast<s16>(tileY)), type)
{
}
//---------------------------------------------- PLACE COP -----------------------------------------------
PlaceCOP::PlaceCOP(BW::TilePosition position, BWAPI::UnitType type)
: position(position)
, type(static_cast<u16>(type))
{
}
PlaceCOP::PlaceCOP(int x, int y, BWAPI::UnitType type)
: PlaceCOP(BW::TilePosition(static_cast<s16>(x), static_cast<s16>(y)), type)
{
}
//--------------------------------------------- INVENT TECH ----------------------------------------------
Invent::Invent(int tech)
: tech(static_cast<u8>(tech))
{
}
//----------------------------------------------- UPGRADE ------------------------------------------------
Upgrade::Upgrade(int upgrade)
: upgrade(static_cast<u8>(upgrade))
{
}
//---------------------------------------------- MAKE ADDON ----------------------------------------------
MakeAddon::MakeAddon(BW::TilePosition position, BWAPI::UnitType type)
: position(position)
, type(static_cast<u16>(type))
{
}
MakeAddon::MakeAddon(int tileX, int tileY, BWAPI::UnitType type)
: MakeAddon(BW::TilePosition(static_cast<s16>(tileX), static_cast<s16>(tileY)), type)
{
}
//---------------------------------------------- MAKE NYDUS ----------------------------------------------
MakeNydusExit::MakeNydusExit(BW::TilePosition position)
: position(position)
{
}
MakeNydusExit::MakeNydusExit(int tileX, int tileY)
: position(static_cast<s16>(tileX), static_cast<s16>(tileY))
{
}
//------------------------------------------- MOVE CONSTRUCTOR -------------------------------------------
ChangeSlot::ChangeSlot(int slotID, SlotType type)
: slotID(static_cast<u8>(slotID))
, slotType(static_cast<u8>(type))
{
}
//--------------------------------------- CHANGE RACE CONSTRUCTOR ----------------------------------------
RequestChangeRace::RequestChangeRace(int slot, int race)
: slotID(static_cast<u8>(slot))
, race(static_cast<u8>(race))
{
}
UpdateSlot::UpdateSlot(int slot, int stormPlayerID, int owner, int newRace, int team)
: bSlot(static_cast<u8>(slot))
, bStormPlayerID(static_cast<u8>(stormPlayerID))
, nType(static_cast<u8>(owner))
, bNewRace(static_cast<u8>(newRace))
, nTeam(static_cast<u8>(team))
{
}
//------------------------------------------ RESUME CONSTRUCTOR ------------------------------------------
LeaveGame::LeaveGame(int type)
: type(static_cast<u8>(type))
{
}
//-------------------------------------------- MINIMAP PING ----------------------------------------------
MinimapPing::MinimapPing(BW::Position position)
: position(position)
{
}
MinimapPing::MinimapPing(int x, int y)
: position(static_cast<s16>(x), static_cast<s16>(y))
{
}
//---------------------------------------- BUILDING MORPH CONSTRUCTOR ------------------------------------
BuildingMorph::BuildingMorph(BWAPI::UnitType type)
: type(static_cast<u16>(type))
{
}
//------------------------------------------------- LAND -------------------------------------------------
Land::Land(BW::TilePosition position, BWAPI::UnitType type)
: position(position)
, type(static_cast<u16>(type))
{
}
Land::Land(int x, int y, BWAPI::UnitType type)
: Land(BW::TilePosition(static_cast<s16>(x), static_cast<s16>(y)), type)
{
}
//--------------------------------------------- HOLD POSITION --------------------------------------------
HoldPosition::HoldPosition(bool queued)
: type(queued ? 1 : 0)
{
}
//------------------------------------------------ UNLOAD UNIT -------------------------------------------
UnloadUnit::UnloadUnit(BWAPI::Unit unload)
: target(unload)
{
}
//----------------------------------------- UNIT MORPH CONSTRUCTOR ---------------------------------------
UnitMorph::UnitMorph(BWAPI::UnitType type)
: type(static_cast<u16>(type))
{
}
//------------------------------------------ RETURN CARGO ------------------------------------------------
ReturnCargo::ReturnCargo(bool queued)
: type(queued ? 1 : 0)
{
}
//------------------------------------------------ STOP --------------------------------------------------
Stop::Stop(bool queued)
: type(queued ? 1 : 0)
{
}
//--------------------------------------------- CANCEL TRAIN ---------------------------------------------
CancelTrain::CancelTrain(int slot)
: slot((s8)slot)
{
}
//------------------------------------------------ USE CHEAT ---------------------------------------------
UseCheat::UseCheat(u32 flags)
: flags(flags)
{
}
//------------------------------------------------ SET ALLIES --------------------------------------------
SetAllies::SetAllies(u32 allies)
: allies(allies)
{
}
//------------------------------------------------ SET VISION --------------------------------------------
SetVision::SetVision(u16 vision)
: vision(vision)
{
}
}
};