Advanced Strategic Command
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
GameAction Class Referenceabstract

A GameAction is an modification of something on a map. More...

#include <action.h>

Inheritance diagram for GameAction:
Inheritance graph
[legend]

Public Member Functions

ActionResult execute (const Context &context)
 
ActionResult undo (const Context &context)
 
void read (tnstream &stream)
 
void write (tnstream &stream) const
 
void write (tnstream &stream, bool persistChildren) const
 
virtual ASCString getDescription () const =0
 
virtual ~GameAction ()
 

Static Public Member Functions

static GameActionreadFromStream (tnstream &stream, GameMap *map)
 

Protected Member Functions

void deleteChildren ()
 
 GameAction (GameMap *map)
 
void addChild (GameAction *action)
 adds a child action. Ownership of the child action is passed to THIS More...
 
virtual ActionResult runAction (const Context &context)=0
 
virtual ActionResult undoAction (const Context &context)=0
 
virtual ActionResult preCheck ()
 preCheck is called before an action is redone and should check the preconditions for the action. More...
 
virtual ActionResult postCheck ()
 postCheck is called after an action has been redone and should check that the state of the map is exactly the same as it was after the action has been executed the first time. More...
 
virtual bool undoOrderChildFirst () const
 determines the order in which the child actions are undone. More...
 
virtual void readData (tnstream &stream)=0
 
virtual void writeData (tnstream &stream) const =0
 
virtual GameActionID getID () const =0
 
GameMapgetMap ()
 
const GameMapgetMap () const
 

Detailed Description

A GameAction is an modification of something on a map.

See Also
gameinteraction for an exhaustive description how this works

Definition at line 45 of file action.h.

Constructor & Destructor Documentation

GameAction::GameAction ( GameMap map)
protected

Definition at line 28 of file action.cpp.

virtual GameAction::~GameAction ( )
inlinevirtual

Definition at line 105 of file action.h.

Member Function Documentation

void GameAction::addChild ( GameAction action)
protected

adds a child action. Ownership of the child action is passed to THIS

Definition at line 36 of file action.cpp.

Referenced by execute(), and read().

void GameAction::deleteChildren ( )
protected

Definition at line 159 of file action.cpp.

Referenced by MoveUnitCommand::rearm(), and Command::redo().

ActionResult GameAction::execute ( const Context context)
virtual ASCString GameAction::getDescription ( ) const
pure virtual
virtual GameActionID GameAction::getID ( ) const
protectedpure virtual
GameMap* GameAction::getMap ( )
inlineprotected

Definition at line 92 of file action.h.

Referenced by ConstructBuildingCommand::buildingFits(), ConstructBuildingCommand::buildingProductionPrerequisites(), MoveUnitCommand::calcPath(), ContainerCommand::checkExecutionPrecondition(), UnitCommand::checkExecutionPrecondition(), RepairUnitCommand::checkExecutionPrecondition(), ServiceCommand::checkExecutionPrecondition(), DiscoverResources::DiscoverResources(), JumpDriveCommand::fieldReachable(), DirectResearchCommand::getAvailableTechnologies(), SpawnBuilding::getBuilding(), ContainerCommand::getContainer(), ContainerAction::getContainer(), SpawnBuilding::getDescription(), SpawnObject::getDescription(), PowerGenerationSwitchCommand::getDescription(), ReactionFireSwitchCommand::getDescription(), TrainUnitCommand::getDescription(), RecycleUnitCommand::getDescription(), SpawnUnit::getDescription(), DiplomacyCommand::getDescription(), TransferControlCommand::getDescription(), ConstructBuildingCommand::getDescription(), ConstructUnitCommand::getDescription(), PutObjectCommand::getDescription(), JumpDriveCommand::getDestinations(), DestructBuildingCommand::getFields(), ConstructUnitCommand::getProducedUnit(), TransferControlCommand::getReceivers(), UnitAction::getUnit(), UnitCommand::getUnit(), SpawnUnit::getUnit(), UnitCommand::getUnitTypeID(), CancelResearchCommand::go(), DestructUnitCommand::go(), DirectResearchCommand::go(), CargoMoveCommand::go(), DiplomacyCommand::go(), TrainUnitCommand::go(), RecycleUnitCommand::go(), JumpDriveCommand::go(), RepairUnitCommand::go(), TransferControlCommand::go(), ConstructBuildingCommand::go(), DestructBuildingCommand::go(), ConstructUnitCommand::go(), PutObjectCommand::go(), AttackCommand::go(), PutMineCommand::go(), MoveUnitCommand::go(), MoveUnitCommand::longDistAvailable(), CancelResearchCommand::preCheck(), BuildProductionLineCommand::productionLinesBuyable(), read(), VehicleAttackAction::runAction(), ChangeDiplomaticState::runAction(), ChangeView::runAction(), SpawnBuilding::runAction(), MoveUnit::runAction(), SpawnObject::runAction(), RemoveMine::runAction(), RemoveObject::runAction(), SpawnMine::runAction(), UnitFieldRegistration::runAction(), SpawnUnit::runAction(), DestructContainer::runAction(), DiscoverResources::runAction(), PutObjectCommand::searchFields(), PutMineCommand::searchFields(), MoveUnitCommand::searchFields(), AttackCommand::searchTargets(), PutMineCommand::setCreationTarget(), MoveUnitCommand::setDestination(), PutMineCommand::setRemovalTarget(), PutObjectCommand::setTarget(), AttackCommand::setTarget(), DestructBuildingCommand::setTargetPosition(), ConstructBuildingCommand::setTargetPosition(), ConstructUnitCommand::setTargetPosition(), ConstructUnitCommand::setVehicleType(), VehicleAttackAction::undoAction(), CancelResearchCommand::undoAction(), ChangeView::undoAction(), SpawnBuilding::undoAction(), SpawnObject::undoAction(), RemoveMine::undoAction(), ChangeDiplomaticState::undoAction(), RemoveObject::undoAction(), SpawnMine::undoAction(), UnitFieldRegistration::undoAction(), DirectResearchCommand::undoAction(), SpawnUnit::undoAction(), DestructContainer::undoAction(), DiscoverResources::undoAction(), ConstructUnitCommand::unitProductionPrerequisites(), SpawnMine::verify(), and SpawnUnit::verify().

const GameMap* GameAction::getMap ( ) const
inlineprotected

Definition at line 93 of file action.h.

virtual ActionResult GameAction::postCheck ( )
inlineprotectedvirtual

postCheck is called after an action has been redone and should check that the state of the map is exactly the same as it was after the action has been executed the first time.

The cheat detection of Replays heavily relies on this mechanism.

Reimplemented in ChangeUnitMovement, ChangeObjectProperty, ChangeUnitProperty, ConsumeAmmo, ChangeContainerProperty, UnitFieldRegistration, MoveUnit, ViewRegistration, ConvertContainer, InflictDamage, ConsumeResource, and ConsumeResource.

Definition at line 80 of file action.h.

virtual ActionResult GameAction::preCheck ( )
inlineprotectedvirtual

preCheck is called before an action is redone and should check the preconditions for the action.

The map should be in exactly the same state as it was when the action was first run. This method should check various key indicators to insurce the unmodifiedness of the map. The cheat detection of Replays heavily relies on this mechanism.

Reimplemented in ChangeUnitMovement, ChangeObjectProperty, ChangeUnitProperty, ChangeContainerProperty, UnitFieldRegistration, MoveUnit, ViewRegistration, CancelResearchCommand, and ConvertContainer.

Definition at line 74 of file action.h.

void GameAction::read ( tnstream stream)
virtual void GameAction::readData ( tnstream stream)
protectedpure virtual
GameAction * GameAction::readFromStream ( tnstream stream,
GameMap map 
)
static
virtual ActionResult GameAction::runAction ( const Context context)
protectedpure virtual
ActionResult GameAction::undo ( const Context context)
virtual ActionResult GameAction::undoAction ( const Context context)
protectedpure virtual
virtual bool GameAction::undoOrderChildFirst ( ) const
inlineprotectedvirtual

determines the order in which the child actions are undone.

If true, then the children are undone first and then this action will be undone. If false, then this action will be undone first and the children after that

Reimplemented in SpawnObject.

Definition at line 85 of file action.h.

Referenced by undo().

void GameAction::write ( tnstream stream) const

Definition at line 145 of file action.cpp.

Referenced by LogActionIntoReplayInfo::saveCommand(), and write().

void GameAction::write ( tnstream stream,
bool  persistChildren 
) const

Definition at line 131 of file action.cpp.

References getID(), write(), writeData(), and tnstream::writeInt().

virtual void GameAction::writeData ( tnstream stream) const
protectedpure virtual

The documentation for this class was generated from the following files: