@@ -47,7 +47,7 @@ bool CUnit::isEconomy() {
4747
4848bool CUnit::reclaim (float3 pos, float radius) {
4949Command c = createPosCommand (CMD_RECLAIM, pos, radius);
50- if (c.id != 0 ) {
50+ if (c.GetID () != 0 ) {
5151ai->cb ->GiveOrder (key, &c);
5252ai->unittable ->idle [key] = false ;
5353return true ;
@@ -57,9 +57,9 @@ bool CUnit::reclaim(float3 pos, float radius) {
5757
5858bool CUnit::reclaim (int target, bool enqueue) {
5959Command c = createTargetCommand (CMD_RECLAIM, target);
60- if (c.id != 0 ) {
60+ if (c.GetID () != 0 ) {
6161if (enqueue)
62- c.options |= SHIFT_KEY;
62+ c.SetOpts ( SHIFT_KEY) ;
6363ai->cb ->GiveOrder (key, &c);
6464ai->unittable ->idle [key] = false ;
6565return true ;
@@ -73,9 +73,9 @@ int CUnit::queueSize() {
7373
7474bool CUnit::attack (int target, bool enqueue) {
7575Command c = createTargetCommand (CMD_ATTACK, target);
76- if (c.id != 0 ) {
76+ if (c.GetID () != 0 ) {
7777if (enqueue)
78- c.options |= SHIFT_KEY;
78+ c.SetOpts ( SHIFT_KEY) ;
7979ai->cb ->GiveOrder (key, &c);
8080ai->unittable ->idle [key] = false ;
8181return true ;
@@ -91,7 +91,7 @@ bool CUnit::moveForward(float dist, bool enqueue) {
9191bool CUnit::setOnOff (bool on) {
9292Command c = createTargetCommand (CMD_ONOFF, on);
9393
94- if (c.id != 0 ) {
94+ if (c.GetID () != 0 ) {
9595ai->cb ->GiveOrder (key, &c);
9696return true ;
9797}
@@ -113,9 +113,9 @@ bool CUnit::moveRandom(float radius, bool enqueue) {
113113bool CUnit::move (const float3 &pos, bool enqueue) {
114114Command c = createPosCommand (CMD_MOVE, pos);
115115
116- if (c.id != 0 ) {
116+ if (c.GetID () != 0 ) {
117117if (enqueue)
118- c.options |= SHIFT_KEY;
118+ c.SetOpts ( SHIFT_KEY) ;
119119ai->cb ->GiveOrder (key, &c);
120120ai->unittable ->idle [key] = false ;
121121return true ;
@@ -126,9 +126,9 @@ bool CUnit::move(const float3 &pos, bool enqueue) {
126126bool CUnit::guard (int target, bool enqueue) {
127127Command c = createTargetCommand (CMD_GUARD, target);
128128
129- if (c.id != 0 ) {
129+ if (c.GetID () != 0 ) {
130130if (enqueue)
131- c.options |= SHIFT_KEY;
131+ c.SetOpts ( SHIFT_KEY) ;
132132ai->cb ->GiveOrder (key, &c);
133133ai->unittable ->idle [key] = false ;
134134return true ;
@@ -139,9 +139,9 @@ bool CUnit::guard(int target, bool enqueue) {
139139bool CUnit::patrol (const float3& pos, bool enqueue) {
140140Command c = createPosCommand (CMD_PATROL, pos);
141141
142- if (c.id != 0 ) {
142+ if (c.GetID () != 0 ) {
143143if (enqueue)
144- c.options |= SHIFT_KEY;
144+ c.SetOpts ( SHIFT_KEY) ;
145145ai->cb ->GiveOrder (key, &c);
146146ai->unittable ->idle [key] = false ;
147147return true ;
@@ -152,7 +152,7 @@ bool CUnit::patrol(const float3& pos, bool enqueue) {
152152bool CUnit::cloak (bool on) {
153153Command c = createTargetCommand (CMD_CLOAK, on);
154154
155- if (c.id != 0 ) {
155+ if (c.GetID () != 0 ) {
156156ai->cb ->GiveOrder (key, &c);
157157return true ;
158158}
@@ -162,7 +162,7 @@ bool CUnit::cloak(bool on) {
162162bool CUnit::repair (int target) {
163163Command c = createTargetCommand (CMD_REPAIR, target);
164164
165- if (c.id != 0 ) {
165+ if (c.GetID () != 0 ) {
166166ai->cb ->GiveOrder (key, &c);
167167ai->unittable ->idle [key] = false ;
168168return true ;
@@ -207,7 +207,7 @@ bool CUnit::build(UnitType* toBuild, const float3& pos) {
207207
208208// NOTE: using of negative unit id is valid for Legacy C++ API only
209209Command c = createPosCommand (-(toBuild->def ->id ), goal, -1 .0f , f);
210- if (c.id != 0 ) {
210+ if (c.GetID () != 0 ) {
211211ai->cb ->GiveOrder (key, &c);
212212ai->unittable ->idle [key] = false ;
213213return true ;
@@ -217,16 +217,14 @@ bool CUnit::build(UnitType* toBuild, const float3& pos) {
217217}
218218
219219bool CUnit::stop () {
220- Command c;
221- c.id = CMD_STOP;
220+ Command c (CMD_STOP);
222221ai->cb ->GiveOrder (key, &c);
223222return true ;
224223}
225224
226225bool CUnit::wait () {
227226if (!waiting) {
228- Command c;
229- c.id = CMD_WAIT;
227+ Command c (CMD_WAIT);
230228ai->cb ->GiveOrder (key, &c);
231229waiting = true ;
232230}
@@ -235,8 +233,7 @@ bool CUnit::wait() {
235233
236234bool CUnit::unwait () {
237235if (waiting) {
238- Command c;
239- c.id = CMD_WAIT;
236+ Command c (CMD_WAIT);
240237ai->cb ->GiveOrder (key, &c);
241238waiting = false ;
242239}
@@ -247,8 +244,7 @@ bool CUnit::stockpile() {
247244if (!type->def ->stockpileWeaponDef )
248245return false ;
249246
250- Command c;
251- c.id = CMD_STOCKPILE;
247+ Command c (CMD_STOCKPILE);
252248ai->cb ->GiveOrder (key, &c);
253249return true ;
254250}
@@ -273,19 +269,18 @@ bool CUnit::micro(bool on) {
273269}
274270
275271bool CUnit::factoryBuild (UnitType *ut, bool enqueue) {
276- Command c;
272+ Command c (-(ut-> def -> id )) ;
277273if (enqueue)
278- c.options |= SHIFT_KEY;
279- c. id = -(ut-> def -> id );
274+ c.SetOpts ( SHIFT_KEY) ;
275+
280276ai->cb ->GiveOrder (key, &c);
281277ai->unittable ->idle [key] = false ;
282278return true ;
283279}
284280
285281Command CUnit::createTargetCommand (int cmd, int target) {
286- Command c;
287- c.id = cmd;
288- c.params .push_back (target);
282+ Command c (cmd);
283+ c.PushParam (target);
289284return c;
290285}
291286
@@ -302,17 +297,14 @@ Command CUnit::createPosCommand(int cmd, float3 pos, float radius, facing f) {
302297if (pos.y < 0 )
303298pos.y = 0 ;
304299
305- Command c;
306- c.id = cmd;
307- c.params .push_back (pos.x );
308- c.params .push_back (pos.y );
309- c.params .push_back (pos.z );
300+ Command c (cmd);
301+ c.PushPos (pos);
310302
311303if (f != NONE)
312- c.params . push_back (f);
304+ c.PushParam (f);
313305
314306if (radius > 0 .0f )
315- c.params . push_back (radius);
307+ c.PushParam (radius);
316308return c;
317309}
318310
0 commit comments