Advanced Strategic Command
moveunit.cpp
Go to the documentation of this file.
1 /*
2  This file is part of Advanced Strategic Command; http://www.asc-hq.de
3  Copyright (C) 1994-2010 Martin Bickel and Marc Schellenberger
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program; see the file COPYING. If not, write to the
17  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
18  Boston, MA 02111-1307 USA
19 */
20 
21 #include <cmath>
22 
23 #include "moveunit.h"
24 #include "unitfieldregistration.h"
25 #include "changeunitproperty.h"
26 #include "consumeresource.h"
27 #include "changeview.h"
28 #include "convertcontainer.h"
29 #include "discoverresources.h"
30 #include "changeunitmovement.h"
31 #include "action-registry.h"
32 
33 #include "../vehicle.h"
34 #include "../gamemap.h"
35 #include "../reactionfire.h"
36 #include "../soundList.h"
37 #include "../controls.h"
38 #include "../gameoptions.h"
39 #include "../mapdisplayinterface.h"
40 #include "../viewcalculation.h"
41 #include "../spfst.h"
42 #include "../gameeventsystem.h"
43 
44 
45 void printTimer( int i )
46 {
47 #if 0
48  static int lastTimer = 0;
49  if ( i == 1 )
50  lastTimer = SDL_GetTicks();
51  else {
52  printf("%d - %d : %d \n", i-1, i, SDL_GetTicks() - lastTimer);
53  lastTimer = SDL_GetTicks();
54  }
55 #endif
56 }
57 
58 
59 MoveUnit::MoveUnit( Vehicle* veh, AStar3D::Path& pathToMove, bool dontInterrupt )
60  : UnitAction( veh->getMap(), veh->networkid )
61 {
62  this->pathToMove = pathToMove;
63  this->dontInterrupt = dontInterrupt;
64  this->originalUnitMovement = veh->getMovement(false,false);
65 }
66 
67 
69 {
70  ASCString res = "Move unit ";
71  if ( getUnit(false) )
72  res += getUnit(false)->getName();
73 
74  return res;
75 }
76 
77 
78 static const int moveUnitStreamVersion = 2;
79 
80 void MoveUnit::readData ( tnstream& stream )
81 {
82  UnitAction::readData( stream );
83  int version = stream.readInt();
84  if ( version < 1 || version > moveUnitStreamVersion )
85  throw tinvalidversion ( "ChangeUnitMovement", moveUnitStreamVersion, version );
86 
87  dontInterrupt = stream.readInt();
88  readClassContainerStaticConstructor( pathToMove, stream );
89  if ( version >= 2 )
90  originalUnitMovement = stream.readInt();
91  else
92  originalUnitMovement = -1;
93 };
94 
95 
96 void MoveUnit::writeData ( tnstream& stream ) const
97 {
98  UnitAction::writeData( stream );
100  stream.writeInt( dontInterrupt );
101  writeClassContainer( pathToMove, stream );
102  stream.writeInt( originalUnitMovement );
103 };
104 
105 
107 {
109 }
110 
111 
113 {
114  Vehicle* vehicle = getUnit();
115 
116 
117  auto_ptr<WindMovement> wind;
118 
119  if ( (vehicle->typ->height & ( chtieffliegend | chfliegend | chhochfliegend )) && getMap()->weather.windSpeed ) {
120  wind.reset( new WindMovement ( vehicle ) );
121  }
122 
123  MapField* oldfield = getMap()->getField( vehicle->getPosition() );
124 
125  AStar3D::Path::iterator pos = pathToMove.begin();
126  AStar3D::Path::iterator stop = pathToMove.end()-1;
127 
129  treactionfire* rf = &srfu;
130 
131  int orgMovement = vehicle->getMovement( false );
132  int orgHeight = vehicle->height;
133 
134  rf->init( vehicle, pathToMove );
135 
136  if ( oldfield->vehicle == vehicle)
137  (new UnitFieldRegistration( vehicle, vehicle->getPosition(), UnitFieldRegistration::RemoveView ))->execute( context );
138 
139  {
140  ActionResult res = (new UnitFieldRegistration( vehicle, vehicle->getPosition(), UnitFieldRegistration::UnregisterOnField ))->execute( context );
141  if ( !res.successful())
142  return res;
143  }
144 
145  int soundHeight = -1;
146  if ( pos->getRealHeight() >= 0 )
147  soundHeight = pos->getRealHeight();
148  else
149  soundHeight = stop->getRealHeight();
150 
151  SoundLoopManager slm ( SoundList::getInstance().getSound( SoundList::moving, vehicle->typ->movemalustyp, vehicle->typ->movementSoundLabel, soundHeight ), false );
152 
153  int cancelmovement = 0;
154 
155  int movedist = 0;
156  int fueldist = 0;
157  int networkID = vehicle->networkid;
158  int operatingPlayer = context.actingPlayer->getPosition();
159 
160  bool viewInputChanged= false;
161  bool mapDisplayUpToDate = true;
162  bool finalRedrawNecessary = false;
163 
164  bool inhibitAttack = false;
165  while ( pos != stop && vehicle && cancelmovement!=1 ) {
166 
167  if ( cancelmovement > 1 )
168  cancelmovement--;
169 
170  AStar3D::Path::iterator next = pos+1;
171 
172 
173  bool container2container = pos->getNumericalHeight()==-1 && next->getNumericalHeight() == -1;
174  pair<int,int> mm = calcMoveMalus( *pos, next->getRealPos(), vehicle, wind.get(), &inhibitAttack, container2container );
175  movedist += mm.first;
176  fueldist += mm.second;
177 
178  if ( next->hasAttacked )
179  vehicle->setAttacked( true, context );
180 
181 
182  if ( next->getRealHeight() != pos->getRealHeight() && next->getRealHeight() >= 0 )
183  (new ChangeUnitProperty( vehicle, ChangeUnitProperty::Height, 1 << next->getRealHeight() ))->execute( context );
184 
185  int pathStepNum = beeline ( *pos, *next ) / maxmalq;
186  int pathStep = 0;
187  if ( !pathStepNum )
188  pathStepNum = 1;
189 
190  MapCoordinate3D to = *pos;
191  do {
192  MapCoordinate3D from;
193  from.setnum ( to.x, to.y, pos->getRealHeight() );
194  if ( next->x != from.x || next->y != from.y )
195  to = getNeighbouringFieldCoordinate ( to, getdirection ( to, *next ));
196  to.setnum ( to.x, to.y, next->getRealHeight() );
197 
198  MapField* dest = getMap()->getField ( to );
199 
200 
201  if ( vehicle ) {
202  vehicle->setnewposition(to, context );
203  (new UnitFieldRegistration( vehicle, to, UnitFieldRegistration::AddView ))->execute( context );
205  (new DiscoverResources(vehicle))->execute(context);
206  }
207 
208 
209  printTimer(1);
210 
211  {
212  int dir = getdirection( from, to );
213  if ( dir >= 0 && dir <= 5 )
214  (new ChangeUnitProperty( vehicle, ChangeUnitProperty::Direction, dir ))->execute( context );
215  }
216 
217 
218  if ( context.display ) {
219  // displaymap();
220  if ( next == stop && to.x==next->x && to.y==next->y) // the unit will reach its destination
221  slm.fadeOut ( CGameOptions::Instance()->movespeed * 10 );
222  context.display->displayMovingUnit ( from, to, vehicle, pathStep, pathStepNum, MapDisplayInterface::SoundStartCallback( &slm, &SoundLoopManager::activate ), context.display->getUnitMovementDuration() );
223  finalRedrawNecessary = true;
224  mapDisplayUpToDate = false;
225  }
226  pathStep++;
227 
228  printTimer(4);
229 
230  if ( vehicle ) {
231  if ( vehicle->spawnMoveObjects( from, to, context ) )
232  mapDisplayUpToDate = false;
233 
234 
235  if ( inhibitAttack )
236  vehicle->setAttacked( true, context );
237  }
238 
239 
240  printTimer(5);
241  {
242  dest->secondvehicle = vehicle;
243  int fieldsWidthChangedVisibility;
244  if ( context.viewingPlayer >= 0 )
245  fieldsWidthChangedVisibility = evaluateviewcalculation ( getMap(), 1 << context.viewingPlayer, false, &context );
246  else
247  fieldsWidthChangedVisibility = evaluateviewcalculation ( getMap(), 0, false, &context );
248 
249 
250  if ( fieldsWidthChangedVisibility )
251  mapDisplayUpToDate = false;
252 
253  dest->secondvehicle = NULL;
254  printTimer(6);
255  }
256 
257  viewInputChanged = false;
258 
259  if ( vehicle ) {
260 
261  if ( context.display && fieldvisiblenow ( dest, vehicle, context.viewingPlayer ) ) {
262  // here comes an ugly hack to get the shadow of starting / descending aircraft right
263 
264  int oldheight = vehicle->height;
265  if ( next->getRealHeight() > pos->getRealHeight() && pathStep < pathStepNum )
266  vehicle->height = 1 << pos->getRealHeight();
267 
268  if ( !mapDisplayUpToDate ) {
269  context.display->displayMap( vehicle );
270  mapDisplayUpToDate = true;
271  finalRedrawNecessary = false;
272  }
273 
274  vehicle->height = oldheight;
275  }
276 
277  dest->secondvehicle = vehicle;
278  if ( rf->checkfield ( to, vehicle, context )) {
279  cancelmovement = 1;
280  vehicle = getMap()->getUnit ( networkID );
281  }
282 
283  if ( vehicle && dest->mineattacks ( vehicle )) {
284  tmineattacksunit battle ( to, -1, vehicle );
285 
286  if ( context.display && (fieldvisiblenow ( dest, context.viewingPlayer) || dest->mineowner() == context.viewingPlayer ))
287  context.display->showBattle( battle );
288  else
289  battle.calc();
290 
291  battle.setresult ( context );
292  if ( battle.dv.damage >= 100 ) {
293  vehicle = NULL;
294  viewInputChanged = true;
295  }
296 
297  updateFieldInfo();
298  cancelmovement = 1;
299  mapDisplayUpToDate = false;
300  }
301  dest->secondvehicle = NULL;
302 
303 
304 
305  if ( !vehicle && context.display ) {
306  context.display->displayMap();
307  mapDisplayUpToDate = true;
308  finalRedrawNecessary = false;
309 
310  viewInputChanged = true;
311  }
312  } else
313  if ( context.display ) {
314  context.display->displayMap();
315  mapDisplayUpToDate = true;
316  finalRedrawNecessary = false;
317  }
318 
319  printTimer(7);
320 
321 
322 
323  if ( vehicle )
324  if ( !(stop->x == to.x && stop->y == to.y && next == stop ))
325  (new UnitFieldRegistration( vehicle, to, UnitFieldRegistration::RemoveView ))->execute( context );
326 
327  if ( cancelmovement == 1 )
328  if ( dest->vehicle || dest->building )
329  cancelmovement++;
330 
331  if ( vehicle )
332  if ( dontInterrupt )
333  cancelmovement = 0;
334 
335  if ( vehicle ) {
336  dest->secondvehicle = vehicle;
338  fieldCrossed( context );
339 
341  fieldCrossed( context );
342  dest->secondvehicle = NULL;
343  }
344  printTimer(8);
345  } while ( (to.x != next->x || to.y != next->y) && vehicle );
346 
347  pos = next;
348  }
349 
350  MapField* fld = getMap()->getField ( pos->x, pos->y );
351 
352  if ( vehicle ) {
353 
354  int newMovement = orgMovement - pos->dist;
355 
356  vehicle->setnewposition( *pos, context );
357 
358  if ( vehicle->typ->movement[getFirstBit(orgHeight)] ) {
359  if ( orgHeight != vehicle->height ) {
360  // first we are converting the original movement to the new height
361  int move = int(floor(vehicle->maxMovement() * float(orgMovement) / float(vehicle->typ->movement[getFirstBit(orgHeight)]) + 0.5));
362  (new ChangeUnitMovement( vehicle, move, false, ChangeUnitMovement::NONE ))->execute(context);
363  }
364 
365 
366  int nm = int(floor(vehicle->maxMovement() * float(newMovement) / float(vehicle->typ->movement[getFirstBit(orgHeight)]) + 0.5));
367 
368  (new ChangeUnitMovement( vehicle, nm, false, ChangeUnitMovement::NORMAL))->execute(context);
369 
370  // the unit will be shaded if movement is exhausted
371  if ( vehicle->getMovement() < 10 )
372  finalRedrawNecessary = true;
373  }
374 
375 
376  (new ConsumeResource( vehicle, Resources(0,0,fueldist * vehicle->typ->fuelConsumption / maxmalq )))->execute( context );
377 
378  if ( fld->vehicle || fld->building ) {
379  (new ChangeUnitMovement( vehicle, 0, false, ChangeUnitMovement::NONE))->execute(context);
380  vehicle->setAttacked( false, context );
381  }
382 
383  if ( vehicle ) {
384  if ((fld->vehicle == NULL) && (fld->building == NULL)) {
385  if ( !vehicle->isViewing() ) {
386  (new UnitFieldRegistration( vehicle, *pos, UnitFieldRegistration::AddView ))->execute( context );
387  viewInputChanged = true;
388 
389  // do we really need this check?
390  /*
391  if ( rf->checkfield ( *pos, vehicle, context )) {
392  vehicle = getMap()->getUnit ( networkID );
393  }
394  */
395 
396  (new UnitFieldRegistration( vehicle, *pos, UnitFieldRegistration::RegisterOnField ))->execute( context );
397 
398  } else {
399  (new UnitFieldRegistration( vehicle, *pos, UnitFieldRegistration::RegisterOnField ))->execute( context );
400  int orgVisibility = fld->visible;
401  for ( int i = 0; i < getMap()->getPlayerCount(); ++i )
403 
404  if ( fld->visible != orgVisibility ) {
405  ChangeView::ViewState viewState;
406  viewState[MapCoordinate(pos->x,pos->y)] = fld->visible;
407  fld->visible = orgVisibility;
408  (new ChangeView(getMap(),viewState))->execute(context);
409  }
410  }
411 
412  } else {
413  ContainerBase* cn = fld->getContainer();
414  if ( vehicle->isViewing() ) {
415  (new UnitFieldRegistration( vehicle, *pos, UnitFieldRegistration::RemoveView ))->execute( context );
416  viewInputChanged = true;
417  }
418 
419  (new UnitFieldRegistration( vehicle, *pos, UnitFieldRegistration::RegisterOnField ))->execute( context );
420 
421  if (cn->getOwner() != vehicle->getOwner() && fld->building && getMap()->getPlayer(fld->building).diplomacy.isHostile( vehicle) ) {
422  (new ConvertContainer( fld->building, vehicle->getOwner()))->execute(context);
423  if ( fieldvisiblenow ( fld, context.viewingPlayer ) || context.viewingPlayer == vehicle->getOwner() )
425  viewInputChanged = true;
426  }
427  mapDisplayUpToDate = false;
428 
429  }
430 
431  }
432  }
433 
434  if ( rf->finalCheck( operatingPlayer, context ))
435  finalRedrawNecessary = true;
436 
437  // we do it anyway
438  finalRedrawNecessary = true;
439 
440  if ( viewInputChanged ) {
441  int fieldschanged;
442  if ( context.viewingPlayer >= 0 )
443  fieldschanged = evaluateviewcalculation ( getMap(), 1 << context.viewingPlayer, false, &context );
444  else
445  fieldschanged = evaluateviewcalculation ( getMap(), 0, false, &context );
446 
447  if ( fieldschanged )
448  mapDisplayUpToDate = false;
449 
450  }
451 
452  if ( context.display ) {
453  context.display->resetMovement();
454  // if ( fieldschanged > 0 )
455  if (finalRedrawNecessary || !mapDisplayUpToDate)
456  context.display->displayMap();
457  // else
458  // mapDisplay->displayPosition ( pos->x, pos->y );
459  }
460 
461  return ActionResult(0);
462 }
463 
464 
466 {
467  if ( originalUnitMovement != -1 )
468  getUnit()->setMovement( originalUnitMovement, 0 );
469 
470  return ActionResult(0);
471 }
472 
474 {
475  return ActionResult(0);
476 }
477 
479 {
480  return ActionResult(0);
481 }
482 
483 
484 
485 namespace {
486  const bool r1 = registerAction<MoveUnit> ( ActionRegistry::MoveUnit );
487 }
Player * actingPlayer
Definition: context.h:37
void readClassContainerStaticConstructor(C &c, tnstream &stream)
Definition: basestrm.h:769
Player & getPlayer(PlayerID p)
Definition: gamemap.h:257
virtual void writeInt(int i)
Writes a 32 bit signed Integer. In the stream little-endian byte order is used and a translation is p...
Definition: basestrm.cpp:363
virtual int finalCheck(int currentPlayer, const Context &context)=0
void printTimer(int i)
Definition: moveunit.cpp:45
struct tfight::tavalues dv
int maxMovement() const
the maximum distance that the unit can drive in a single turn on the current level of height ...
Definition: vehicle.cpp:1069
int GameActionID
Definition: action.h:35
Vehicle * vehicle
Definition: mapfield.h:89
bool isHostile(PlayerID towardsPlayer) const
Definition: player.h:80
int connection
are any events connected to this field
Definition: mapfield.h:164
virtual ActionResult runAction(const Context &context)
Definition: moveunit.cpp:112
void setnewposition(int x, int y)
checks whether the unit can construct a building of the given type.
Definition: vehicle.cpp:808
map< MapCoordinate, int > ViewState
Definition: changeview.h:32
void move(Vehicle *veh, const MapCoordinate &dest)
bool isViewing() const
returns true if the units view is currently added to the maps global visibility.
Definition: vehicle.h:342
virtual int readInt(void)
Reads a 32 bit signed Integer. In the stream little-endian byte order is used and a translation is pe...
Definition: basestrm.cpp:284
int getPosition() const
Definition: player.h:112
int getFirstBit(int zahl)
Count the number of zero bits on the LSB side of "zahl".
Definition: misc.cpp:45
virtual ActionResult undoAction(const Context &context)
Definition: moveunit.cpp:465
DiplomaticStateVector diplomacy
Definition: player.h:209
bool hasFunction(ContainerFunctions function) const
static SoundList & getInstance()
Definition: soundList.cpp:60
void writeData(tnstream &stream) const
Definition: unitaction.cpp:75
void setMovement(int newmove, double cargoDivisor=-1)
sets a new distance that the unit can move
Definition: vehicle.cpp:527
int getOwner() const
returns the number of the player this vehicle/building belongs to
static const int moveUnitStreamVersion
Definition: moveunit.cpp:78
MapCoordinate3D getPosition() const
returns the units position
Definition: vehicle.cpp:1552
void activate(int dummy)
Definition: soundList.cpp:50
#define chhochfliegend
Definition: typen.h:416
int mineowner(void)
the player who placed the mines on this field.
Definition: mapfield.cpp:454
GameMap * getMap()
Definition: action.h:92
int evaluatevisibilityfield(GameMap *gamemap, MapField *fld, int player, int add, int initial)
evaluates the view on a given field and saves it for that field.
ContainerBase * getContainer()
returns a pointer to the ContainerBase of the field or NULL if there is none
Definition: mapfield.cpp:331
The interface for all kinds of IO stream.
a single field of the map
Definition: mapfield.h:26
The ASCString class provides an abstract way to manipulate strings.
Definition: ascstring.h:14
sigc::signal< void, const Context & > fieldCrossed
Definition: spfst.cpp:54
ASCString getDescription() const
Definition: moveunit.cpp:68
void calc(void)
Performs the calculation of the attack. The result is only stored in the av and dv structures and is ...
Definition: attack.cpp:178
vector< int > movement
the distance a unit can travel each round. One value for each of the 8 levels of height ...
Definition: vehicletype.h:203
int height
the current level of height ( BITMAPPED ! )
Definition: vehicle.h:118
int beeline(const Vehicle *a, const Vehicle *b)
returns the distance between the units a and b
pair< int, int > calcMoveMalus(const MapCoordinate3D &start, const MapCoordinate3D &dest, const Vehicle *vehicle, WindMovement *wm, bool *inhibitAttack, bool container2container)
Definition: controls.cpp:64
void fadeOut(int ms)
Definition: soundList.h:26
virtual void resetMovement(void)=0
bool fieldvisiblenow(const MapField *pe, Vehicle *veh, int player)
{@
Definition: spfst.cpp:399
#define maxmalq
Constants that specify the layout of ASC.
Definition: typen.h:429
ActionResult execute(const Context &context)
Definition: action.cpp:41
Loki::Functor< void, LOKI_TYPELIST_1(int) > SoundStartCallback
void setresult(const Context &context)
Writes the result of the attack calculation to the actual units.
Definition: attack.cpp:693
Vehicle * getUnit(bool dontThrow=false)
Definition: unitaction.cpp:47
#define chtieffliegend
Definition: typen.h:414
virtual int displayMovingUnit(const MapCoordinate3D &start, const MapCoordinate3D &dest, Vehicle *vehicle, int fieldnum, int totalmove, SoundStartCallback startSound, int duration)=0
Coordinate on the twodimensional map.
Definition: typen.h:202
virtual int checkfield(const MapCoordinate3D &pos, Vehicle *&eht, const Context &context)=0
int movemalustyp
The category of the unit. Original used only to distinguish only between different movement costs for...
Definition: vehicletype.h:206
ASCString getName() const
returns the units name or, if it does not exist, the unit type's name or description ...
Definition: vehicle.cpp:1569
virtual void displayMap(void)=0
Uint16 visible
can this field be seen be the player. Variable is bitmapped; two bits for each player. These two bits can have the states defined in VisibilityStates
Definition: mapfield.h:63
int evaluateviewcalculation(GameMap *gamemap, int player_fieldcount_mask, bool disableShareView, const Context *context)
evaluates the view on the whole map.
void setnum(int _x, int _y, int numericalz)
Definition: typen.h:250
virtual void init(Vehicle *eht, const AStar3D::Path &fieldlist)=0
A helper class for managing looping sounds.
Definition: soundList.h:19
int viewingPlayer
Definition: context.h:40
the loaded units get their movement changed too, by the normal fraction (loaded units less than carri...
sigc::signal< void > updateFieldInfo
Definition: spfst.cpp:47
void setAttacked()
the the unit and all cargo to attacked = true
Definition: vehicle.cpp:1049
bool successful() const
Vehicle * getUnit(int x, int y, int nwid)
Definition: gamemap.cpp:1215
MapDisplayInterface * display
Definition: context.h:39
static CGameOptions * Instance()
returns the only Instance
Definition: gameoptions.cpp:38
Sound * playSound(Sample snd, int subType=0, bool looping=false, const ASCString &label="")
Definition: soundList.cpp:265
caches some calculations for the effects that wind has on the movement of units
int getgameparameter(GameParameter num) const
Definition: gamemap.cpp:1047
int height
the levels of height which this unit can enter
int connection
if events are triggered by this unit (if it is lost for example), this will set connection != 0 ...
Definition: vehicle.h:133
int fuelConsumption
the fuel consumption to move a single field
Definition: vehicletype.h:200
virtual void writeData(tnstream &stream) const
Definition: moveunit.cpp:96
deque< PathPoint > Path
Definition: astar2.h:48
virtual GameActionID getID() const
Definition: moveunit.cpp:106
const VehicleType * typ
Definition: vehicle.h:83
Coordinate on the map including height.
Definition: typen.h:238
Building * building
Definition: mapfield.h:102
virtual ActionResult postCheck()
postCheck is called after an action has been redone and should check that the state of the map is exa...
Definition: moveunit.cpp:478
Vehicle * secondvehicle
two units and the same field are only allowed temporary during movement
Definition: mapfield.h:92
ASCString movementSoundLabel
this label can select a special sound to be played when moving
Definition: vehicletype.h:274
void writeClassContainer(const C &c, tnstream &stream)
Definition: basestrm.h:742
The parent class of Vehicle and Building; The name Container originates from Battle Isle...
Definition: containerbase.h:40
virtual void readData(tnstream &stream)
Definition: moveunit.cpp:80
Resources are basically the currency of ASC.
Definition: typen.h:97
virtual void showBattle(tfight &battle)=0
int getdirection(const MapCoordinate &start, const MapCoordinate &dest)
int getPlayerCount() const
Definition: gamemap.h:255
#define chfliegend
Definition: typen.h:415
int networkid
a unique identification of the unit that is used everywhere in ASC (and not only the network protocol...
Definition: vehicle.h:140
int getMovement(bool checkFuel=true, bool checkRF=true) const
returns the movement points the unit has left for this turn. CheckFuel should almost always be true...
Definition: vehicle.cpp:558
only the unit itself gets its movement changed
bool spawnMoveObjects(const MapCoordinate &start, const MapCoordinate &dest, const Context &context)
add the objects like tracks or broken ice
Definition: vehicle.cpp:621
int mineattacks(const Vehicle *veh)
can any of the mines on this field attack this unit
Definition: mapfield.cpp:194
virtual int getUnitMovementDuration() const =0
void readData(tnstream &stream)
Definition: unitaction.cpp:65
MapCoordinate3D getNeighbouringFieldCoordinate(const MapCoordinate3D &pos, int direc)
returns the coordinate of the field that is adjecent to the given field in the direction of direc ...
virtual ActionResult preCheck()
preCheck is called before an action is redone and should check the preconditions for the action...
Definition: moveunit.cpp:473
MapField * getField(int x, int y)
Definition: gamemap.h:465