_________ __                 __
        /   _____//  |_____________ _/  |______     ____  __ __  ______
        \_____  \\   __\_  __ \__  \\   __\__  \   / ___\|  |  \/  ___/
        /        \|  |  |  | \// __ \|  |  / __ \_/ /_/  >  |  /\___ \
       /_______  /|__|  |__|  (____  /__| (____  /\___  /|____//____  >
               \/                  \/          \//_____/            \/
    ______________________                           ______________________
                          T H E   W A R   B E G I N S
                   Stratagus - A free fantasy real time strategy game engine

command.cpp File Reference
#include "stratagus.h"
#include "actions.h"
#include "action/action_built.h"
#include "action/action_build.h"
#include "action/action_research.h"
#include "action/action_train.h"
#include "action/action_upgradeto.h"
#include "commands.h"
#include "map.h"
#include "pathfinder.h"
#include "player.h"
#include "spells.h"
#include "translate.h"
#include "upgrade.h"
#include "ui.h"
#include "unit.h"
#include "unit_manager.h"
#include "unittype.h"

Functions

command.cpp - Give units a command.
static void ReleaseOrders (CUnit &unit)
 
static COrderPtrGetNextOrder (CUnit &unit, int flush)
 
static void RemoveOrder (CUnit &unit, unsigned int order)
 
static void ClearNewAction (CUnit &unit)
 
static void ClearSavedAction (CUnit &unit)
 
static bool IsUnitValidForNetwork (const CUnit &unit)
 
void CommandStopUnit (CUnit &unit)
 Prepare command stop. More...
 
void CommandStandGround (CUnit &unit, int flush)
 Prepare command stand ground. More...
 
void CommandDefend (CUnit &unit, CUnit &dest, int flush)
 Prepare command defend. More...
 
void CommandFollow (CUnit &unit, CUnit &dest, int flush)
 Prepare command follow. More...
 
void CommandMove (CUnit &unit, const Vec2i &pos, int flush)
 Prepare command move. More...
 
void CommandRepair (CUnit &unit, const Vec2i &pos, CUnit *dest, int flush)
 Prepare command repair. More...
 
void CommandAutoRepair (CUnit &unit, int on)
 Send auto repair command. More...
 
void CommandAttack (CUnit &unit, const Vec2i &pos, CUnit *target, int flush)
 Prepare command attack. More...
 
void CommandAttackGround (CUnit &unit, const Vec2i &pos, int flush)
 Prepare command attack ground. More...
 
void CommandPatrolUnit (CUnit &unit, const Vec2i &pos, int flush)
 Prepare command patrol. More...
 
void CommandBoard (CUnit &unit, CUnit &dest, int flush)
 Prepare command board. More...
 
void CommandUnload (CUnit &unit, const Vec2i &pos, CUnit *what, int flush)
 Prepare command unload. More...
 
void CommandBuildBuilding (CUnit &unit, const Vec2i &pos, CUnitType &what, int flush)
 Prepare command build. More...
 
void CommandExplore (CUnit &unit, int flush)
 Prepare command explore. More...
 
void CommandDismiss (CUnit &unit)
 Prepare command dismiss. More...
 
void CommandResourceLoc (CUnit &unit, const Vec2i &pos, int flush)
 Prepare command resource location. More...
 
void CommandResource (CUnit &unit, CUnit &dest, int flush)
 Prepare command resource. More...
 
void CommandReturnGoods (CUnit &unit, CUnit *depot, int flush)
 Prepare command return. More...
 
void CommandTrainUnit (CUnit &unit, CUnitType &type, int)
 Prepare command train. More...
 
void CommandCancelTraining (CUnit &unit, int slot, const CUnitType *type)
 Prepare command cancel training. More...
 
void CommandUpgradeTo (CUnit &unit, CUnitType &type, int flush, bool instant)
 Prepare command upgrade to. More...
 
void CommandTransformIntoType (CUnit &unit, CUnitType &type)
 immediate transforming into type. More...
 
void CommandCancelUpgradeTo (CUnit &unit)
 Prepare command cancel upgrade to. More...
 
void CommandResearch (CUnit &unit, CUpgrade &what, int flush)
 Prepare command research. More...
 
void CommandCancelResearch (CUnit &unit)
 Prepare command cancel research. More...
 
void CommandSpellCast (CUnit &unit, const Vec2i &pos, CUnit *dest, const SpellType &spell, int flush, bool isAutocast)
 Prepare command spellcast. More...
 
void CommandAutoSpellCast (CUnit &unit, int spellid, int on)
 Prepare command auto spellcast. More...
 
void CommandDiplomacy (int player, int state, int opponent)
 Prepare diplomacy command. More...
 
void CommandSharedVision (int playerIndex, bool state, int opponentIndex)
 Prepare shared vision command. More...
 
void CommandQuit (int player)
 Prepare command quit. More...
 

Function Documentation

◆ ClearNewAction()

static void ClearNewAction ( CUnit unit)
static

◆ ClearSavedAction()

static void ClearSavedAction ( CUnit unit)
static

Clear the saved action.

Parameters
unitUnit pointer, that get the saved action cleared.
Note
If we make a new order, we must clear any saved actions.
Internal functions, must protect it, if needed.

◆ CommandAttack()

void CommandAttack ( CUnit unit,
const Vec2i pos,
CUnit target,
int  flush 
)

Prepare command attack.

Attack with unit at new position

Parameters
unitpointer to unit.
posmap position to attack.
targetor unit to be attacked.
flushif true, flush command queue.

◆ CommandAttackGround()

void CommandAttackGround ( CUnit unit,
const Vec2i pos,
int  flush 
)

Prepare command attack ground.

Attack ground with unit.

Parameters
unitpointer to unit.
posmap position to fire on.
flushif true, flush command queue.

◆ CommandAutoRepair()

void CommandAutoRepair ( CUnit unit,
int  on 
)

Send auto repair command.

Auto repair.

Parameters
unitpointer to unit.
on1 for auto repair on, 0 for off.

◆ CommandAutoSpellCast()

void CommandAutoSpellCast ( CUnit unit,
int  spellid,
int  on 
)

Prepare command auto spellcast.

Auto spell cast.

Parameters
unitpointer to unit.
spellidSpell id.
on1 for auto cast on, 0 for off.

◆ CommandBoard()

void CommandBoard ( CUnit unit,
CUnit dest,
int  flush 
)

Prepare command board.

Board a transporter with unit.

Parameters
unitpointer to unit.
destunit to be boarded.
flushif true, flush command queue.

◆ CommandBuildBuilding()

void CommandBuildBuilding ( CUnit unit,
const Vec2i pos,
CUnitType what,
int  flush 
)

Prepare command build.

Send a unit building

Parameters
unitpointer to unit.
posmap position to build.
whatUnit type to build.
flushif true, flush command queue.

◆ CommandCancelResearch()

void CommandCancelResearch ( CUnit unit)

Prepare command cancel research.

Cancel Building researching.

Parameters
unitPointer to unit.

◆ CommandCancelTraining()

void CommandCancelTraining ( CUnit unit,
int  slot,
const CUnitType type 
)

Prepare command cancel training.

Cancel the training of an unit.

Parameters
unitpointer to unit.
slotslot number to cancel.
typeUnit-type to cancel.

◆ CommandCancelUpgradeTo()

void CommandCancelUpgradeTo ( CUnit unit)

Prepare command cancel upgrade to.

Cancel building upgrading to.

Parameters
unitpointer to unit.

◆ CommandDefend()

void CommandDefend ( CUnit unit,
CUnit dest,
int  flush 
)

Prepare command defend.

Follow unit and defend it

Parameters
unitpointer to unit.
destunit to follow
flushif true, flush command queue.

◆ CommandDiplomacy()

void CommandDiplomacy ( int  player,
int  state,
int  opponent 
)

Prepare diplomacy command.

Diplomacy changed.

Parameters
playerPlayer which changes his state.
stateNew diplomacy state.
opponentOpponent.

◆ CommandDismiss()

void CommandDismiss ( CUnit unit)

Prepare command dismiss.

Cancel the building construction, or kill a unit.

Parameters
unitpointer to unit.

◆ CommandExplore()

void CommandExplore ( CUnit unit,
int  flush 
)

Prepare command explore.

Send a unit exploring

Parameters
unitpointer to unit.
flushif true, flush command queue.

◆ CommandFollow()

void CommandFollow ( CUnit unit,
CUnit dest,
int  flush 
)

Prepare command follow.

Follow unit to new position

Parameters
unitpointer to unit.
destunit to be followed
flushif true, flush command queue.

◆ CommandMove()

void CommandMove ( CUnit unit,
const Vec2i pos,
int  flush 
)

Prepare command move.

Move unit to new position

Parameters
unitpointer to unit.
posmap position to move to.
flushif true, flush command queue.

◆ CommandPatrolUnit()

void CommandPatrolUnit ( CUnit unit,
const Vec2i pos,
int  flush 
)

Prepare command patrol.

Let a unit patrol from current to new position

FIXME: want to support patroling between units.

Parameters
unitpointer to unit.
posmap position to patrol between.
flushif true, flush command queue.

◆ CommandQuit()

void CommandQuit ( int  player)

Prepare command quit.

Player quit.

Parameters
playerPlayer number that quit.

◆ CommandRepair()

void CommandRepair ( CUnit unit,
const Vec2i pos,
CUnit dest,
int  flush 
)

Prepare command repair.

Repair unit

Parameters
unitpointer to unit.
posmap position to repair.
destor unit to be repaired. FIXME: not supported
flushif true, flush command queue.

◆ CommandResearch()

void CommandResearch ( CUnit unit,
CUpgrade what,
int  flush 
)

Prepare command research.

Building starts researching.

Parameters
unitpointer to unit.
whatwhat to research.
flushif true, flush command queue.

◆ CommandResource()

void CommandResource ( CUnit unit,
CUnit dest,
int  flush 
)

Prepare command resource.

Send unit to harvest resources

Parameters
unitpointer to unit.
destdestination unit.
flushif true, flush command queue.

◆ CommandResourceLoc()

void CommandResourceLoc ( CUnit unit,
const Vec2i pos,
int  flush 
)

Prepare command resource location.

Send unit harvest a location

Parameters
unitpointer to unit.
posmap position for harvest.
flushif true, flush command queue.

◆ CommandReturnGoods()

void CommandReturnGoods ( CUnit unit,
CUnit depot,
int  flush 
)

Prepare command return.

Let unit returning goods.

Parameters
unitpointer to unit.
depotbring goods to this depot.
flushif true, flush command queue.

◆ CommandSharedVision()

void CommandSharedVision ( int  playerIndex,
bool  state,
int  opponentIndex 
)

Prepare shared vision command.

Shared vision changed.

Parameters
playerIndexPlayer which changes his state.
stateNew shared vision state.
opponentIndexOpponent.

TODO: change ThisPlayer to currently rendered player/players #RenderTargets

◆ CommandSpellCast()

void CommandSpellCast ( CUnit unit,
const Vec2i pos,
CUnit dest,
const SpellType spell,
int  flush,
bool  isAutocast 
)

Prepare command spellcast.

Cast a spell at position or unit.

Parameters
unitPointer to unit.
posmap position to spell cast on.
destSpell cast on unit (if exist).
spellSpell type pointer.
flushIf true, flush command queue.

◆ CommandStandGround()

void CommandStandGround ( CUnit unit,
int  flush 
)

Prepare command stand ground.

Stand ground.

Parameters
unitpointer to unit.
flushif true, flush command queue.

◆ CommandStopUnit()

void CommandStopUnit ( CUnit unit)

Prepare command stop.

Stop unit.

Parameters
unitpointer to unit.

◆ CommandTrainUnit()

void CommandTrainUnit ( CUnit unit,
CUnitType type,
int   
)

Prepare command train.

Building starts training an unit.

Parameters
unitpointer to unit.
typeunit type to train.
flushif true, flush command queue.

◆ CommandTransformIntoType()

void CommandTransformIntoType ( CUnit unit,
CUnitType type 
)

immediate transforming into type.

Immediate transforming unit into type.

Parameters
unitpointer to unit.
typeupgrade to type

◆ CommandUnload()

void CommandUnload ( CUnit unit,
const Vec2i pos,
CUnit what,
int  flush 
)

Prepare command unload.

Unload a transporter.

Parameters
unitpointer to unit.
posmap position to unload.
whatunit to be unloaded, NULL for all.
flushif true, flush command queue.

◆ CommandUpgradeTo()

void CommandUpgradeTo ( CUnit unit,
CUnitType type,
int  flush,
bool  instant 
)

Prepare command upgrade to.

Building starts upgrading to.

Parameters
unitpointer to unit.
typeupgrade to type
flushif true, flush command queue.

◆ GetNextOrder()

static COrderPtr* GetNextOrder ( CUnit unit,
int  flush 
)
static

Get next free order slot.

Parameters
unitpointer to unit.
flushif true, flush order queue.
Returns
Pointer to next free order slot.

◆ IsUnitValidForNetwork()

static bool IsUnitValidForNetwork ( const CUnit unit)
static

◆ ReleaseOrders()

static void ReleaseOrders ( CUnit unit)
static

Release all orders of a unit.

Parameters
unitPointer to unit.

◆ RemoveOrder()

static void RemoveOrder ( CUnit unit,
unsigned int  order 
)
static

Remove an order from the list of orders pending

Parameters
unitpointer to unit
ordernumber of the order to remove
(C) Copyright 1998-2012 by The Stratagus Project under the GNU General Public License.
All trademarks and copyrights on this page are owned by their respective owners.