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

commands.h File Reference
#include "vec2i.h"

Go to the source code of this file.

commands.h - The commands header file.

#define FlushCommands   1
 
typedef unsigned short UnitRef
 
void CommandQuit (int player)
 Prepare command quit. More...
 
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 *dest, 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 &, 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 &what, int flush)
 Prepare command train. More...
 
void CommandCancelTraining (CUnit &unit, int slot, const CUnitType *type)
 Prepare command cancel training. More...
 
void CommandUpgradeTo (CUnit &unit, CUnitType &what, int flush, bool instant=false)
 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=false)
 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 player, bool state, int opponent)
 Prepare shared vision command. More...
 
void SendCommandStopUnit (CUnit &unit)
 Send stop command. More...
 
void SendCommandStandGround (CUnit &unit, int flush)
 Send stand ground command. More...
 
void SendCommandDefend (CUnit &unit, CUnit &dest, int flush)
 Send defend command. More...
 
void SendCommandFollow (CUnit &unit, CUnit &dest, int flush)
 Send follow command. More...
 
void SendCommandMove (CUnit &unit, const Vec2i &pos, int flush)
 Send move command. More...
 
void SendCommandRepair (CUnit &unit, const Vec2i &pos, CUnit *dest, int flush)
 Send repair command. More...
 
void SendCommandAutoRepair (CUnit &unit, int on)
 Send auto repair command. More...
 
void SendCommandAttack (CUnit &unit, const Vec2i &pos, CUnit *dest, int flush)
 Send attack command. More...
 
void SendCommandAttackGround (CUnit &unit, const Vec2i &pos, int flush)
 Send attack ground command. More...
 
void SendCommandPatrol (CUnit &unit, const Vec2i &pos, int flush)
 Send patrol command. More...
 
void SendCommandBoard (CUnit &unit, CUnit &dest, int flush)
 Send board command. More...
 
void SendCommandUnload (CUnit &unit, const Vec2i &pos, CUnit *what, int flush)
 Send unload command. More...
 
void SendCommandBuildBuilding (CUnit &unit, const Vec2i &pos, CUnitType &what, int flush)
 Send build building command. More...
 
void SendCommandExplore (CUnit &unit, int flush)
 Send explore command. More...
 
void SendCommandDismiss (CUnit &unit)
 Send cancel building command. More...
 
void SendCommandResourceLoc (CUnit &unit, const Vec2i &pos, int flush)
 Send harvest location command. More...
 
void SendCommandResource (CUnit &unit, CUnit &dest, int flush)
 Send harvest command. More...
 
void SendCommandReturnGoods (CUnit &unit, CUnit *dest, int flush)
 Send return goods command. More...
 
void SendCommandTrainUnit (CUnit &unit, CUnitType &what, int flush)
 Send train command. More...
 
void SendCommandCancelTraining (CUnit &unit, int slot, const CUnitType *type)
 Send cancel training command. More...
 
void SendCommandUpgradeTo (CUnit &unit, CUnitType &what, int flush)
 Send upgrade to command. More...
 
void SendCommandCancelUpgradeTo (CUnit &unit)
 Send cancel upgrade to command. More...
 
void SendCommandResearch (CUnit &unit, CUpgrade &what, int flush)
 Send research command. More...
 
void SendCommandCancelResearch (CUnit &unit)
 Send cancel research command. More...
 
void SendCommandSpellCast (CUnit &unit, const Vec2i &pos, CUnit *dest, int spellid, int flush)
 Send spell cast command. More...
 
void SendCommandAutoSpellCast (CUnit &unit, int spellid, int on)
 Send auto spell cast command. More...
 
void SendCommandDiplomacy (int player, int state, int opponent)
 Send diplomacy command. More...
 
void SendCommandSharedVision (int player, bool state, int opponent)
 Send shared vision command. More...
 
void ExecCommand (unsigned char type, UnitRef unum, unsigned short x, unsigned short y, UnitRef dest)
 Execute a command (from network). More...
 
void ExecExtendedCommand (unsigned char type, int status, unsigned char arg1, unsigned short arg2, unsigned short arg3, unsigned short arg4)
 Execute an extended command (from network). More...
 

Macro Definition Documentation

◆ FlushCommands

#define FlushCommands   1

Typedef Documentation

◆ UnitRef

typedef unsigned short UnitRef

Unit references over network, or for memory saving.

Function Documentation

◆ 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.

This function gives a unit a new command. If the command is given by the user the function with Send prefix should be used.

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.

◆ ExecCommand()

void ExecCommand ( unsigned char  msgnr,
UnitRef  unum,
unsigned short  x,
unsigned short  y,
UnitRef  dstnr 
)

Execute a command (from network).

Execute a command (from network).

Parameters
msgnrNetwork message type
unumUnit number (slot) that receive the command.
xoptional X map position.
yoptional y map position.
dstnroptional destination unit.

◆ ExecExtendedCommand()

void ExecExtendedCommand ( unsigned char  type,
int  status,
unsigned char  arg1,
unsigned short  arg2,
unsigned short  arg3,
unsigned short  arg4 
)

Execute an extended command (from network).

Execute an extended command (from network).

Parameters
typeNetwork extended message type
statusBit 7 of message type
arg1Messe argument 1
arg2Messe argument 2
arg3Messe argument 3
arg4Messe argument 4

arg1: 0:true / 1:false

CommandLog(...);

CommandLog(...);

arg1: 0:cShadowCasting / 1:cSimpleRadial

CommandLog(...);

CommandLog(...);

Arg2: Opaque fields flags

CommandLog(...);

CommandLog(...);

arg1: enable/disable fog

arg2: request for update

CommandLog(...);

◆ SendCommandAttack()

void SendCommandAttack ( CUnit unit,
const Vec2i pos,
CUnit attack,
int  flush 
)

Send attack command.

Send command: Unit attack unit or at position.

Parameters
unitpointer to unit.
posmap tile position to attack.
attackor !=NoUnitP unit to be attacked.
flushFlag flush all pending commands.

◆ SendCommandAttackGround()

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

Send attack ground command.

Send command: Unit attack ground.

Parameters
unitpointer to unit.
posmap tile position to fire on.
flushFlag flush all pending commands.

◆ SendCommandAutoRepair()

void SendCommandAutoRepair ( CUnit unit,
int  on 
)

Send auto repair command.

Send command: Unit auto repair.

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

◆ SendCommandAutoSpellCast()

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

Send auto spell cast command.

Send command: Unit auto spell cast.

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

◆ SendCommandBoard()

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

Send board command.

Send command: Unit board unit.

Parameters
unitpointer to unit.
destDestination to be boarded.
flushFlag flush all pending commands.

◆ SendCommandBuildBuilding()

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

Send build building command.

Send command: Unit builds building at position.

Parameters
unitpointer to unit.
posmap tile position of construction.
whatpointer to unit-type of the building.
flushFlag flush all pending commands.

◆ SendCommandCancelResearch()

void SendCommandCancelResearch ( CUnit unit)

Send cancel research command.

Send command: Cancel Building/unit research.

Parameters
unitpointer to unit.

◆ SendCommandCancelTraining()

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

Send cancel training command.

Send command: Cancel training.

Parameters
unitPointer to unit.
slotSlot of training queue to cancel.
typeUnit-type of unit to cancel.

◆ SendCommandCancelUpgradeTo()

void SendCommandCancelUpgradeTo ( CUnit unit)

Send cancel upgrade to command.

Send command: Cancel building upgrading to.

Parameters
unitPointer to unit.

◆ SendCommandDefend()

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

Send defend command.

Send command: Defend some unit.

Parameters
unitpointer to unit.
destdefend this unit.
flushFlag flush all pending commands.

◆ SendCommandDiplomacy()

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

Send diplomacy command.

Send command: Diplomacy changed.

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

◆ SendCommandDismiss()

void SendCommandDismiss ( CUnit unit)

Send cancel building command.

Send command: Cancel this building construction.

Parameters
unitpointer to unit.

◆ SendCommandExplore()

void SendCommandExplore ( CUnit unit,
int  flush 
)

Send explore command.

Send command: Unit explores the map.

Parameters
unitpointer to unit.
flushFlag flush all pending commands.

◆ SendCommandFollow()

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

Send follow command.

Send command: Follow unit to position.

Parameters
unitpointer to unit.
destfollow this unit.
flushFlag flush all pending commands.

◆ SendCommandMove()

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

Send move command.

Send command: Move unit to position.

Parameters
unitpointer to unit.
posmap tile position to move to.
flushFlag flush all pending commands.

◆ SendCommandPatrol()

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

Send patrol command.

Send command: Unit patrol between current and position.

Parameters
unitpointer to unit.
posmap tile position to patrol between.
flushFlag flush all pending commands.

◆ SendCommandRepair()

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

Send repair command.

Send command: Unit repair.

Parameters
unitPointer to unit.
posmap tile position to repair.
destUnit to be repaired.
flushFlag flush all pending commands.

◆ SendCommandResearch()

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

Send research command.

Send command: Building/unit research.

Parameters
unitpointer to unit.
whatresearch-type of the research.
flushFlag flush all pending commands.

◆ SendCommandResource()

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

Send harvest command.

Send command: Unit harvest resources

Parameters
unitpointer to unit.
destpointer to destination (oil-platform,gold mine).
flushFlag flush all pending commands.

◆ SendCommandResourceLoc()

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

Send harvest location command.

Send command: Unit harvests a location (wood for now).

Parameters
unitpointer to unit.
posmap tile position where to harvest.
flushFlag flush all pending commands.

◆ SendCommandReturnGoods()

void SendCommandReturnGoods ( CUnit unit,
CUnit goal,
int  flush 
)

Send return goods command.

Send command: Unit return goods.

Parameters
unitpointer to unit.
goalpointer to destination of the goods. (NULL=search best)
flushFlag flush all pending commands.

◆ SendCommandSharedVision()

void SendCommandSharedVision ( int  player,
bool  state,
int  opponent 
)

Send shared vision command.

Send command: Shared vision changed.

Parameters
playerPlayer which changes his state.
stateNew shared vision state.
opponentOpponent.

◆ SendCommandSpellCast()

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

Send spell cast command.

Send command: Unit spell cast on position/unit.

Parameters
unitpointer to unit.
posmap tile position where to cast spell.
destCast spell on unit (if exist).
spellidSpell type id.
flushFlag flush all pending commands.

◆ SendCommandStandGround()

void SendCommandStandGround ( CUnit unit,
int  flush 
)

Send stand ground command.

Send command: Unit stand ground.

Parameters
unitpointer to unit.
flushFlag flush all pending commands.

◆ SendCommandStopUnit()

void SendCommandStopUnit ( CUnit unit)

Send stop command.

Send command: Unit stop.

Parameters
unitpointer to unit.

◆ SendCommandTrainUnit()

void SendCommandTrainUnit ( CUnit unit,
CUnitType what,
int  flush 
)

Send train command.

Send command: Building/unit train new unit.

Parameters
unitpointer to unit.
whatpointer to unit-type of the unit to be trained.
flushFlag flush all pending commands.

◆ SendCommandUnload()

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

Send unload command.

Send command: Unit unload unit.

Parameters
unitpointer to unit.
posmap tile position of unload.
whatPassagier to be unloaded.
flushFlag flush all pending commands.

◆ SendCommandUpgradeTo()

void SendCommandUpgradeTo ( CUnit unit,
CUnitType what,
int  flush 
)

Send upgrade to command.

Send command: Building starts upgrading to.

Parameters
unitpointer to unit.
whatpointer to unit-type of the unit upgrade.
flushFlag flush all pending commands.
(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.