Advanced Strategic Command
commands.cpp
Go to the documentation of this file.
1 
7 /*
8  This file is part of Advanced Strategic Command; http://www.asc-hq.de
9  Copyright (C) 1994-2010 Martin Bickel
10 
11  This program is free software; you can redistribute it and/or modify
12  it under the terms of the GNU General Public License as published by
13  the Free Software Foundation; either version 2 of the License, or
14  (at your option) any later version.
15 
16  This program is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  GNU General Public License for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with this program; see the file COPYING. If not, write to the
23  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
24  Boston, MA 02111-1307 USA
25 */
26 
27 
28 #include "../sg.h"
29 #include "../ascstring.h"
30 #include "../vehicle.h"
31 #include "../gamemap.h"
32 #include "../spfst.h"
33 #include "../spfst-legacy.h"
34 #include "../itemrepository.h"
35 
36 #include "../turncontrol.h"
37 #include "../pg_mapdisplay.h"
38 
39 #include "../actions/attackcommand.h"
40 #include "../actions/moveunitcommand.h"
41 #include "../actions/putminecommand.h"
42 #include "../actions/putobjectcommand.h"
43 #include "../actions/destructbuildingcommand.h"
44 #include "../actions/transfercontrolcommand.h"
45 #include "../actions/trainunitcommand.h"
46 #include "../actions/constructunitcommand.h"
47 #include "../actions/constructbuildingcommand.h"
48 #include "../actions/servicecommand.h"
49 #include "../actions/repairunitcommand.h"
50 #include "../actions/reactionfireswitchcommand.h"
51 #include "../actions/jumpdrivecommand.h"
52 #include "../actions/destructunitcommand.h"
53 #include "../actions/recycleunitcommand.h"
54 #include "../actions/buildproductionlinecommand.h"
55 #include "../actions/removeproductionlinecommand.h"
56 #include "../actions/powergenerationswitchcommand.h"
57 #include "../actions/repairbuildingcommand.h"
58 #include "../actions/setresourceprocessingratecommand.h"
59 #include "../actions/cargomovecommand.h"
60 #include "../actions/diplomacycommand.h"
61 #include "../actions/cancelresearchcommand.h"
62 #include "../actions/directresearchcommand.h"
63 #include "../actions/renamecontainercommand.h"
64 
65 GameMap* loadGameLua( const char* filename )
66 {
67  loadGameFromFile( filename );
68  repaintMap();
69  return actmap;
70 }
71 
72 ActionResult unitAttack( GameMap* actmap, int veh, const MapCoordinate& target, int weapon )
73 {
74  if ( !actmap )
75  return ActionResult( 23500 );
76 
77  Vehicle* unit = actmap->getUnit( veh );
78  if ( !unit )
79  return ActionResult(120);
80 
81  if ( !AttackCommand::avail( unit ))
82  return ActionResult(202);
83 
84  auto_ptr<AttackCommand> ac( new AttackCommand(unit) );
85  ac->setTarget( target, weapon);
86  ActionResult res = ac->execute( createContext( actmap ) );
87  if ( res.successful() )
88  ac.release();
89 
90  return res;
91 }
92 
93 
94 ActionResult unitMovement( GameMap* actmap, int unitID, const MapCoordinate& destination, int destinationHeigth )
95 {
96  if ( !actmap )
97  return ActionResult( 23500 );
98 
99  Vehicle* unit = actmap->getUnit( unitID );
100  if ( !unit )
101  return ActionResult(120);
102 
103  if ( !MoveUnitCommand::avail( unit ))
104  return ActionResult(23411);
105 
106  auto_ptr<MoveUnitCommand> ac( new MoveUnitCommand(unit) );
107  if ( destinationHeigth < 0 )
108  ac->setDestination( destination );
109  else
110  ac->setDestination( MapCoordinate3D( destination, 1 << destinationHeigth ));
111  ActionResult res = ac->execute( createContext( actmap ) );
112  if ( res.successful() )
113  ac.release();
114 
115  return res;
116 }
117 
118 ActionResult unitMovement( GameMap* actmap, int unitID, const MapCoordinate& destination )
119 {
120  return unitMovement( actmap, unitID, destination, -1 );
121 }
122 
123 ActionResult putMineFunc( GameMap* actmap, int veh, const MapCoordinate& destination, int mineType )
124 {
125  if ( !actmap )
126  return ActionResult( 23500 );
127 
128  Vehicle* unit = actmap->getUnit( veh );
129  if ( !unit )
130  return ActionResult(120);
131 
132  if ( !PutMineCommand::avail( unit ))
133  return ActionResult(23411);
134 
135  auto_ptr<PutMineCommand> ac( new PutMineCommand(unit) );
136  ac->setCreationTarget( destination, (MineTypes)mineType );
137  ActionResult res = ac->execute( createContext( actmap ) );
138  if ( res.successful() )
139  ac.release();
140 
141  return res;
142 }
143 
144 ActionResult removeMineFunc( GameMap* actmap, int veh, const MapCoordinate& destination )
145 {
146  if ( !actmap )
147  return ActionResult( 23500 );
148 
149  Vehicle* unit = actmap->getUnit( veh );
150  if ( !unit )
151  return ActionResult(120);
152 
153  if ( !PutMineCommand::avail( unit ))
154  return ActionResult(23411);
155 
156  auto_ptr<PutMineCommand> ac( new PutMineCommand(unit) );
157  ac->setRemovalTarget( destination );
158  ActionResult res = ac->execute( createContext( actmap ) );
159  if ( res.successful() )
160  ac.release();
161 
162  return res;
163 }
164 
165 
166 
167 ActionResult unitPutObject( GameMap* actmap, int veh, const MapCoordinate& destination, int objectID )
168 {
169  if ( !actmap )
170  return ActionResult( 23500 );
171 
172  Vehicle* unit = actmap->getUnit( veh );
173  if ( !unit )
174  return ActionResult(120);
175 
176  if ( !PutObjectCommand::avail( unit ))
177  return ActionResult(23411);
178 
179  auto_ptr<PutObjectCommand> ac( new PutObjectCommand(unit) );
180  ac->setTarget( destination, objectID );
181  ActionResult res = ac->execute( createContext( actmap ) );
182  if ( res.successful() )
183  ac.release();
184 
185  return res;
186 }
187 
188 ActionResult unitRemoveObject( GameMap* actmap, int veh, const MapCoordinate& destination, int objectID )
189 {
190  return unitPutObject( actmap, veh, destination, objectID );
191 }
192 
193 
195 {
196  if ( !actmap )
197  return ActionResult( 23500 );
198 
199  Vehicle* unit = actmap->getUnit( veh );
200  if ( !unit )
201  return ActionResult(120);
202 
203  if ( !DestructBuildingCommand::avail( unit ))
204  return ActionResult(23411);
205 
206  auto_ptr<DestructBuildingCommand> ac( new DestructBuildingCommand(unit) );
207  ac->setTargetPosition( destination );
208  ActionResult res = ac->execute( createContext( actmap ) );
209  if ( res.successful() )
210  ac.release();
211 
212  return res;
213 }
214 
215 ActionResult transferControl( GameMap* actmap, int containerID, int newOwner )
216 {
217  if ( !actmap )
218  return ActionResult( 23500 );
219 
220  ContainerBase* c = actmap->getContainer( containerID);
221  if ( !c )
222  return ActionResult(23410);
223 
224  if ( !TransferControlCommand::avail( c ))
225  return ActionResult(23411);
226 
227  if ( newOwner < 0 || newOwner > 7 )
228  return ActionResult(22801);
229 
230 
231  auto_ptr<TransferControlCommand> ac( new TransferControlCommand(c) );
232  ac->setReceiver( &actmap->getPlayer( newOwner) );
233  ActionResult res = ac->execute( createContext( actmap ) );
234  if ( res.successful() )
235  ac.release();
236 
237  return res;
238 }
239 
240 ActionResult trainUnit( GameMap* actmap, int containerID, int unitID )
241 {
242  if ( !actmap )
243  return ActionResult( 23500 );
244 
245  ContainerBase* c = actmap->getContainer( containerID);
246  if ( !c )
247  return ActionResult(23410);
248 
249  Vehicle* v = actmap->getUnit( unitID );
250  if ( !v )
251  return ActionResult( 21001 );
252 
253  if ( !TrainUnitCommand::avail( c, v ))
254  return ActionResult(23411);
255 
256 
257  auto_ptr<TrainUnitCommand> ac( new TrainUnitCommand(c) );
258  ac->setUnit( v );
259  ActionResult res = ac->execute( createContext( actmap ) );
260  if ( res.successful() )
261  ac.release();
262 
263  return res;
264 }
265 
266 ActionResult constructUnit( GameMap* actmap, int containerID, const MapCoordinate& position, int unitID )
267 {
268  if ( !actmap )
269  return ActionResult( 23500 );
270 
271  ContainerBase* c = actmap->getContainer( containerID );
272  if ( !c )
273  return ActionResult(23410);
274 
275  VehicleType* v = vehicleTypeRepository.getObject_byID( unitID );
276  if ( !v )
277  return ActionResult( 21701 );
278 
279  if ( !ConstructUnitCommand::avail( c ))
280  return ActionResult(23411);
281 
282 
283  auto_ptr<ConstructUnitCommand> ac( new ConstructUnitCommand(c) );
284  ac->setVehicleType( v );
285 
286  if ( position.valid() ) {
287  if ( position != c->getPosition())
288  ac->setMode( ConstructUnitCommand::external );
289  else
290  ac->setMode( ConstructUnitCommand::internal );
291 
292  ac->setTargetPosition( position );
293  } else
294  ac->setMode( ConstructUnitCommand::internal );
295 
296  ActionResult res = ac->execute( createContext( actmap ) );
297  if ( res.successful() )
298  ac.release();
299 
300  return res;
301 }
302 
303 
304 ActionResult constructBuilding( GameMap* actmap, int unitID, const MapCoordinate& position, int buildingTypeID )
305 {
306  if ( !actmap )
307  return ActionResult( 23500 );
308 
309  Vehicle* unit = actmap->getUnit( unitID );
310  if ( !unit )
311  return ActionResult(120);
312 
313  if ( !ConstructBuildingCommand::avail( unit ))
314  return ActionResult(23411);
315 
316  BuildingType* v = buildingTypeRepository.getObject_byID( buildingTypeID );
317  if ( !v )
318  return ActionResult( 21701 );
319 
320 
321  auto_ptr<ConstructBuildingCommand> ac( new ConstructBuildingCommand(unit) );
322  ac->setBuildingType( v );
323  ac->setTargetPosition( position );
324 
325  ActionResult res = ac->execute( createContext( actmap ) );
326  if ( res.successful() )
327  ac.release();
328 
329  return res;
330 }
331 
332 ActionResult serviceCommand( GameMap* actmap, int providingContainerID, int receivingContainerID, int type, int amount )
333 {
334  if ( !actmap )
335  return ActionResult( 23500 );
336 
337  ContainerBase* pro = actmap->getContainer( providingContainerID );
338  ContainerBase* rec = actmap->getContainer( receivingContainerID );
339  if ( !pro || !rec )
340  return ActionResult(23410);
341 
342  auto_ptr<ServiceCommand> ac( new ServiceCommand(pro) );
343  ac->setDestination( rec );
344 
345  TransferHandler::Transfers& transfers = ac->getTransferHandler().getTransfers();
346 
347  for ( TransferHandler::Transfers::iterator i = transfers.begin(); i != transfers.end(); ++i )
348  if ( (*i)->getID() == type )
349  (*i)->setAmount( rec, amount );
350 
351  if ( transfers.size() > 0 ) {
352  ac->saveTransfers();
353  ActionResult res = ac->execute( createContext( actmap ) );
354  if ( res.successful() )
355  ac.release();
356 
357  return res;
358  } else {
359  return ActionResult(23301);
360  }
361 }
362 
363 ActionResult repairUnit( GameMap* actmap, int repairerID, int damagedUnitID )
364 {
365  if ( !actmap )
366  return ActionResult( 23500 );
367 
368  ContainerBase* c = actmap->getContainer( repairerID);
369  if ( !c )
370  return ActionResult(23410);
371 
372  Vehicle* v = actmap->getUnit( damagedUnitID );
373  if ( !v )
374  return ActionResult( 21001 );
375 
376  if ( !RepairUnitCommand::avail( c ))
377  return ActionResult(23411);
378 
379 
380  auto_ptr<RepairUnitCommand> ac( new RepairUnitCommand(c) );
381  ac->setTarget( v );
382  ActionResult res = ac->execute( createContext( actmap ) );
383  if ( res.successful() )
384  ac.release();
385 
386  return res;
387 }
388 
389 ActionResult unitReactionFireEnable( GameMap* actmap, int unitID, bool enabled )
390 {
391  if ( !actmap )
392  return ActionResult( 23500 );
393 
394  Vehicle* unit = actmap->getUnit( unitID );
395  if ( !unit )
396  return ActionResult(120);
397 
398  if ( !ReactionFireSwitchCommand::avail( unit, enabled ))
399  return ActionResult(23411);
400 
401  auto_ptr<ReactionFireSwitchCommand> ac( new ReactionFireSwitchCommand(unit) );
402  ac->setNewState( enabled );
403  ActionResult res = ac->execute( createContext( actmap ) );
404  if ( res.successful() )
405  ac.release();
406 
407  return res;
408 }
409 
411 {
412  if ( !actmap )
413  return ActionResult( 23500 );
414 
415  Vehicle* unit = actmap->getUnit( unitID );
416  if ( !unit )
417  return ActionResult(120);
418 
419  if ( !PowerGenerationSwitchCommand::avail( unit, enabled ))
420  return ActionResult(23411);
421 
422  auto_ptr<PowerGenerationSwitchCommand> ac( new PowerGenerationSwitchCommand(unit) );
423  ac->setNewState( enabled );
424  ActionResult res = ac->execute( createContext( actmap ) );
425  if ( res.successful() )
426  ac.release();
427 
428  return res;
429 }
430 
431 ActionResult unitJump( GameMap* actmap, int veh, const MapCoordinate& destination )
432 {
433  if ( !actmap )
434  return ActionResult( 23500 );
435 
436  Vehicle* unit = actmap->getUnit( veh );
437  if ( !unit )
438  return ActionResult(120);
439 
441  if ( !aa.ready())
442  return ActionResult(23411, aa.getMessage() );
443 
444  auto_ptr<JumpDriveCommand> ac( new JumpDriveCommand(unit) );
445  ac->setDestination( destination );
446  ActionResult res = ac->execute( createContext( actmap ) );
447  if ( res.successful() )
448  ac.release();
449 
450  return res;
451 }
452 
454 {
455  if ( !actmap )
456  return ActionResult( 23500 );
457 
458  ContainerBase* c = actmap->getContainer( containerID );
459  if ( !c )
460  return ActionResult(23410);
461 
462  if ( !DestructUnitCommand::avail( c ))
463  return ActionResult(23411);
464 
465  auto_ptr<DestructUnitCommand> ac( new DestructUnitCommand(c) );
466  ActionResult res = ac->execute( createContext( actmap ) );
467  if ( res.successful() )
468  ac.release();
469 
470  return res;
471 }
472 
473 ActionResult recycleUnit( GameMap* actmap, int containerID, int unitID )
474 {
475  if ( !actmap )
476  return ActionResult( 23500 );
477 
478  ContainerBase* c = actmap->getContainer( containerID );
479  if ( !c )
480  return ActionResult(23410);
481 
482  Vehicle* v = actmap->getUnit( unitID );
483  if ( !v )
484  return ActionResult( 21001 );
485 
486  if ( !RecycleUnitCommand::avail( c, v ))
487  return ActionResult(23411);
488 
489 
490  auto_ptr<RecycleUnitCommand> ac( new RecycleUnitCommand(c) );
491  ac->setUnit( v );
492  ActionResult res = ac->execute( createContext( actmap ) );
493  if ( res.successful() )
494  ac.release();
495 
496  return res;
497 }
498 
499 ActionResult buildProductionLine( GameMap* actmap, int containerID, int vehicleTypeID )
500 {
501  if ( !actmap )
502  return ActionResult( 23500 );
503 
504  ContainerBase* c = actmap->getContainer( containerID );
505  if ( !c )
506  return ActionResult(23410);
507 
508  VehicleType* v = vehicleTypeRepository.getObject_byID( vehicleTypeID );
509  if ( !v )
510  return ActionResult( 21701 );
511 
513  return ActionResult(23411);
514 
515 
516  auto_ptr<BuildProductionLineCommand> ac( new BuildProductionLineCommand(c) );
517  ac->setProduction( v );
518  ActionResult res = ac->execute( createContext( actmap ) );
519  if ( res.successful() )
520  ac.release();
521 
522  return res;
523 }
524 
525 ActionResult removeProductionLine( GameMap* actmap, int containerID, int vehicleTypeID )
526 {
527  if ( !actmap )
528  return ActionResult( 23500 );
529 
530  ContainerBase* c = actmap->getContainer( containerID );
531  if ( !c )
532  return ActionResult(23410);
533 
534  VehicleType* v = vehicleTypeRepository.getObject_byID( vehicleTypeID );
535  if ( !v )
536  return ActionResult( 21701 );
537 
539  return ActionResult(23411);
540 
541  auto_ptr<RemoveProductionLineCommand> ac( new RemoveProductionLineCommand(c) );
542  ac->setRemoval( v );
543  ActionResult res = ac->execute( createContext( actmap ) );
544  if ( res.successful() )
545  ac.release();
546 
547  return res;
548 }
549 
551 {
552  if ( !actmap )
553  return ActionResult( 23500 );
554 
555  ContainerBase* c = actmap->getContainer( buildingID );
556  if ( !c )
557  return ActionResult(23410);
558 
559  Building* b = dynamic_cast<Building*>(c);
560  if ( !b )
561  return ActionResult(23410);
562 
563  if ( !RepairBuildingCommand::avail( b ))
564  return ActionResult(23411);
565 
566  auto_ptr<RepairBuildingCommand> ac( new RepairBuildingCommand(b) );
567  ActionResult res = ac->execute( createContext( actmap ) );
568  if ( res.successful() )
569  ac.release();
570 
571  return res;
572 }
573 
574 ActionResult setResourceProcessingRate( GameMap* actmap, int containerID, int amount )
575 {
576  if ( !actmap )
577  return ActionResult( 23500 );
578 
579  ContainerBase* c = actmap->getContainer( containerID );
580  if ( !c )
581  return ActionResult(23410);
582 
584  return ActionResult(23411);
585 
586  auto_ptr<SetResourceProcessingRateCommand> ac( new SetResourceProcessingRateCommand(c, amount ) );
587  ActionResult res = ac->execute( createContext( actmap ) );
588  if ( res.successful() )
589  ac.release();
590 
591  return res;
592 }
593 
594 ActionResult cargoUnitMove( GameMap* actmap, int unitID, int targetContainerID )
595 {
596  if ( !actmap )
597  return ActionResult( 23500 );
598 
599  Vehicle* unit = actmap->getUnit( unitID );
600  if ( !unit )
601  return ActionResult(120);
602 
603  auto_ptr<CargoMoveCommand> ac( new CargoMoveCommand(unit) );
604 
605  Vehicle* target = NULL;
606  if ( targetContainerID != -1 ) {
607  target = actmap->getUnit( targetContainerID );
608  if ( !target )
609  return ActionResult(23410);
610 
611  if ( !CargoMoveCommand::moveInAvail( unit, target ))
612  return ActionResult(23411);
613 
614  ac->setMode( CargoMoveCommand::moveInwards );
615  ac->setTargetCarrier( target );
616 
617  } else {
618  if ( !CargoMoveCommand::moveOutAvail( unit ))
619  return ActionResult(23411);
620 
621  ac->setMode( CargoMoveCommand::moveOutwards );
622  }
623 
624  ActionResult res = ac->execute( createContext( actmap ) );
625  if ( res.successful() )
626  ac.release();
627 
628  return res;
629 }
630 
631 ActionResult setDiplomacy( GameMap* actmap, int actingPlayer, int towardsPlayer, bool sneak, int newState )
632 {
633  if ( !actmap )
634  return ActionResult( 23500 );
635 
636  if ( actingPlayer < 0 || actingPlayer >= actmap->getPlayerCount() )
637  return ActionResult( 23100 );
638 
639  if ( towardsPlayer < 0 || towardsPlayer >= actmap->getPlayerCount() )
640  return ActionResult( 23100 );
641 
642 
643 
644  auto_ptr<DiplomacyCommand> ac( new DiplomacyCommand(actmap->getPlayer(actingPlayer)) );
645  if ( sneak )
646  ac->sneakAttack( actmap->getPlayer(towardsPlayer) );
647  else {
648  if ( newState < 0 || newState >= diplomaticStateNum )
649  return ActionResult( 23501 );
650 
651  DiplomaticStates state = (DiplomaticStates) newState;
652  ac->newstate( state, actmap->getPlayer(towardsPlayer));
653  }
654  ActionResult res = ac->execute( createContext( actmap ) );
655  if ( res.successful() )
656  ac.release();
657 
658  return res;
659 }
660 
662 {
663  if ( !actmap )
664  return ActionResult( 23500 );
665 
666  if ( actingPlayer < 0 || actingPlayer >= actmap->getPlayerCount() )
667  return ActionResult( 23100 );
668 
669  auto_ptr<CancelResearchCommand> ac( new CancelResearchCommand( actmap ) );
670  ac->setPlayer( actmap->getPlayer( actingPlayer ));
671  ActionResult res = ac->execute( createContext( actmap ) );
672  if ( res.successful() )
673  ac.release();
674 
675  return res;
676 
677 }
678 
679 ActionResult setResearchGoal( GameMap* actmap, int actingPlayer, int techID )
680 {
681  if ( !actmap )
682  return ActionResult( 23500 );
683 
684  if ( actingPlayer < 0 || actingPlayer >= actmap->getPlayerCount() )
685  return ActionResult( 23100 );
686 
687  Player& p = actmap->getPlayer( actingPlayer );
688 
690  return ActionResult(23411);
691 
692  Technology* t = technologyRepository.getObject_byID( techID );
693  if ( !t )
694  return ActionResult( 23205 );
695 
696  auto_ptr<DirectResearchCommand> ac( new DirectResearchCommand( p ) );
697  ac->setTechnology( t );
698  ActionResult res = ac->execute( createContext( actmap ) );
699  if ( res.successful() )
700  ac.release();
701 
702  return res;
703 
704 }
705 
707  public:
708  bool continueWhenLastPlayer() const {
709  return false;
710  }
711 
712  bool authenticate( GameMap* actmap ) const {
713  int humanCount = 0;
714  for ( int p = 0; p < actmap->getPlayerCount(); ++p )
715  if ( actmap->getPlayer(p).isHuman() )
716  ++humanCount;
717 
718  return humanCount <= 1;
719  }
720 } ;
721 
722 
723 void endTurn()
724 {
726 }
727 
728 void endTurn_headLess( GameMap* gamemap )
729 {
730  next_turn( gamemap, NextTurnStrategy_Abort(), NULL, -1 );
731 }
732 
734 {
735  MapField* fld = map->getField( map->getCursor() );
736  if ( !fld )
737  return NULL;
738 
739  if ( fld->vehicle && fld->vehicle->getOwner() == map->actplayer )
740  return fld->vehicle;
741  else
742  return NULL;
743 }
744 
745 ActionResult renameContainer( GameMap* actmap, int unitID, const ASCString& publicName, const ASCString& privateName )
746 {
747  if ( !actmap )
748  return ActionResult( 23500 );
749 
750  Vehicle* v = actmap->getUnit( unitID );
751  if ( !v )
752  return ActionResult(23410);
753 
754 
755  auto_ptr<RenameContainerCommand> rcc ( new RenameContainerCommand(v) );
756  rcc->setName( publicName, privateName );
757  ActionResult res = rcc->execute( createContext( actmap ) );
758  if ( res.successful() )
759  rcc.release();
760 
761  return res;
762 }
763 
764 
ActionResult renameContainer(GameMap *actmap, int unitID, const ASCString &publicName, const ASCString &privateName)
Definition: commands.cpp:745
ActionResult recycleUnit(GameMap *actmap, int containerID, int unitID)
Definition: commands.cpp:473
static bool avail(const Building *building)
static bool avail(const ContainerBase *factory)
Player & getPlayer(PlayerID p)
Definition: gamemap.h:257
MapCoordinate & getCursor()
Definition: gamemap.cpp:933
MapDisplayInterface & getDefaultMapDisplay()
describes the behavier that next_turn() shall do when it finds out that the current player is the las...
Definition: turncontrol.h:42
bool authenticate(GameMap *actmap) const
Definition: commands.cpp:712
DiplomaticStates
Definition: player.h:53
ActionResult constructUnit(GameMap *actmap, int containerID, const MapCoordinate &position, int unitID)
Definition: commands.cpp:266
static bool avail(const Vehicle *unit, bool newState)
ActionResult unitPowerGenerationEnable(GameMap *actmap, int unitID, int enabled)
Definition: commands.cpp:410
Vehicle * vehicle
Definition: mapfield.h:89
bool valid() const
Definition: typen.h:221
static bool avail(const ContainerBase *carrier, const Vehicle *unit)
ActionResult unitJump(GameMap *actmap, int veh, const MapCoordinate &destination)
Definition: commands.cpp:431
static bool avail(const Vehicle *eht)
ActionResult serviceCommand(GameMap *actmap, int providingContainerID, int receivingContainerID, int type, int amount)
Definition: commands.cpp:332
Context createContext(GameMap *gamemap)
static bool avail(const ContainerBase *factory)
int getOwner() const
returns the number of the player this vehicle/building belongs to
static bool moveOutAvail(const Vehicle *movingUnit)
ContainerBase * getContainer(int nwid)
Definition: gamemap.cpp:1231
static bool avail(const ContainerBase *unit)
static bool moveInAvail(const Vehicle *movingUnit, Vehicle *newCarrier)
bool isHuman() const
Definition: player.h:152
void endTurn()
Definition: commands.cpp:723
static bool avail(Vehicle *eht)
ActionResult unitMovement(GameMap *actmap, int unitID, const MapCoordinate &destination, int destinationHeigth)
Definition: commands.cpp:94
sigc::signal< void > repaintMap
}@
Definition: spfst.cpp:45
ItemRepositoryLoader< BuildingType > buildingTypeRepository("buildingtype")
a single field of the map
Definition: mapfield.h:26
ItemRepositoryLoader< Technology > technologyRepository("technology")
ActionResult constructBuilding(GameMap *actmap, int unitID, const MapCoordinate &position, int buildingTypeID)
Definition: commands.cpp:304
The ASCString class provides an abstract way to manipulate strings.
Definition: ascstring.h:14
GameMap * loadGameLua(const char *filename)
Definition: commands.cpp:65
ActionResult setDiplomacy(GameMap *actmap, int actingPlayer, int towardsPlayer, bool sneak, int newState)
Definition: commands.cpp:631
bool loadGameFromFile(const ASCString &filename)
Definition: sg.cpp:309
static bool avail(const ContainerBase *factory)
const int diplomaticStateNum
Definition: player.h:52
MineTypes
Definition: objects.h:70
The class describing properties that are common to all vehicles of a certain kind.
Definition: vehicletype.h:177
void next_turn(GameMap *gamemap, const NextTurnStrategy &nextTurnStrategy, MapDisplayInterface *display, int playerView)
ActionResult repairBuilding(GameMap *actmap, int buildingID)
Definition: commands.cpp:550
void endTurn_headLess(GameMap *gamemap)
ends a turn. All user interaction is avoided. Intended for unit tests and other automated tasks ...
Definition: commands.cpp:728
The class describing properties that are common to all buildings of a certain kind.
Definition: buildingtype.h:35
ItemRepositoryLoader< VehicleType > vehicleTypeRepository("vehicletype")
ActionResult putMineFunc(GameMap *actmap, int veh, const MapCoordinate &destination, int mineType)
Definition: commands.cpp:123
ActionResult setResearchGoal(GameMap *actmap, int actingPlayer, int techID)
Definition: commands.cpp:679
ActionResult unitDestructBuilding(GameMap *actmap, int veh, const MapCoordinate &destination)
Definition: commands.cpp:194
ActionResult unitRemoveObject(GameMap *actmap, int veh, const MapCoordinate &destination, int objectID)
Definition: commands.cpp:188
static ActionAvailability available(const Vehicle *unit)
Coordinate on the twodimensional map.
Definition: typen.h:202
static bool avail(const ContainerBase *item)
static bool avail(const ContainerBase *servicer)
ActionResult selfDestruct(GameMap *actmap, int containerID)
Definition: commands.cpp:453
static bool avail(Vehicle *eht)
ActionResult cargoUnitMove(GameMap *actmap, int unitID, int targetContainerID)
Definition: commands.cpp:594
ActionResult removeMineFunc(GameMap *actmap, int veh, const MapCoordinate &destination)
Definition: commands.cpp:144
static bool avail(Vehicle *eht)
signed char actplayer
the player who is currently making his moves (may be human or AI)
Definition: gamemap.h:232
ActionResult repairUnit(GameMap *actmap, int repairerID, int damagedUnitID)
Definition: commands.cpp:363
bool successful() const
Vehicle * getUnit(int x, int y, int nwid)
Definition: gamemap.cpp:1215
static bool avail(const Vehicle *eht)
bool continueWhenLastPlayer() const
Definition: commands.cpp:708
static bool avail(Vehicle *eht)
Vehicle * getSelectedUnit(GameMap *map)
Definition: commands.cpp:733
ActionResult trainUnit(GameMap *actmap, int containerID, int unitID)
Definition: commands.cpp:240
ActionResult transferControl(GameMap *actmap, int containerID, int newOwner)
Definition: commands.cpp:215
ActionResult removeProductionLine(GameMap *actmap, int containerID, int vehicleTypeID)
Definition: commands.cpp:525
Coordinate on the map including height.
Definition: typen.h:238
static bool available(const Player &player)
static bool avail(const ContainerBase *carrier, const Vehicle *unit)
ActionResult unitReactionFireEnable(GameMap *actmap, int unitID, bool enabled)
Definition: commands.cpp:389
ActionResult cancelResearch(GameMap *actmap, int actingPlayer)
Definition: commands.cpp:661
ActionResult setResourceProcessingRate(GameMap *actmap, int containerID, int amount)
Definition: commands.cpp:574
GameMap * actmap
Definition: spfst.cpp:64
The parent class of Vehicle and Building; The name Container originates from Battle Isle...
Definition: containerbase.h:40
An actual building on the map, which references a BuildingType Buildings have an owner,.
Definition: buildings.h:38
ActionResult buildProductionLine(GameMap *actmap, int containerID, int vehicleTypeID)
Definition: commands.cpp:499
static bool avail(const Vehicle *unit, bool newState)
the different players in ASC. There may be 8 players (0..7) and neutral units (8) ...
Definition: player.h:99
ASCString getMessage() const
static bool avail(const ContainerBase *eht)
ActionResult unitAttack(GameMap *actmap, int veh, const MapCoordinate &target, int weapon)
Definition: commands.cpp:72
ActionResult unitPutObject(GameMap *actmap, int veh, const MapCoordinate &destination, int objectID)
Definition: commands.cpp:167
int getPlayerCount() const
Definition: gamemap.h:255
The map. THE central structure of ASC, which holds everything not globally available together...
Definition: gamemap.h:182
MapField * getField(int x, int y)
Definition: gamemap.h:465
virtual MapCoordinate3D getPosition() const =0