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

src/action/command.cpp File Reference

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "stratagus.h"
#include "unittype.h"
#include "player.h"
#include "unit.h"
#include "actions.h"
#include "tileset.h"
#include "map.h"
#include "upgrade.h"
#include "pathfinder.h"
#include "spells.h"
#include "interface.h"
#include "ui.h"

Functions

command.cpp - Give units a command.
static void ReleaseOrders (CUnit &unit)
static COrderPtr GetNextOrder (CUnit &unit, int flush)
static void RemoveOrder (CUnit &unit, int order)
static void ClearSavedAction (CUnit &unit)
void CommandStopUnit (CUnit &unit)
 Prepare command stop.
void CommandAnyOrder (CUnit &unit, COrderPtr cpyorder, int flush)
void CommandMoveOrder (CUnit &unit, int src, int dst)
 Send any command.
void CommandStandGround (CUnit &unit, int flush)
 Prepare command stand ground.
void CommandFollow (CUnit &unit, CUnit &dest, int flush)
 Prepare command follow.
void CommandMove (CUnit &unit, const Vec2i &pos, int flush)
void CommandRepair (CUnit &unit, const Vec2i &pos, CUnit *dest, int flush)
void CommandAutoRepair (CUnit &unit, int on)
 Send auto repair command.
void CommandAttack (CUnit &unit, const Vec2i &pos, CUnit *attack, int flush)
void CommandAttackGround (CUnit &unit, const Vec2i &pos, int flush)
void CommandPatrolUnit (CUnit &unit, const Vec2i &pos, int flush)
void CommandBoard (CUnit &unit, CUnit &dest, int flush)
 Prepare command board.
void CommandUnload (CUnit &unit, const Vec2i &pos, CUnit *what, int flush)
void CommandBuildBuilding (CUnit &unit, const Vec2i &pos, CUnitType &what, int flush)
void CommandDismiss (CUnit &unit)
 Prepare command dismiss.
void CommandResourceLoc (CUnit &unit, const Vec2i &pos, int flush)
void CommandResource (CUnit &unit, CUnit &dest, int flush)
 Prepare command resource.
void CommandReturnGoods (CUnit &unit, CUnit *goal, int flush)
 Prepare command return.
void CommandTrainUnit (CUnit &unit, CUnitType &type, int)
 Prepare command train.
void CommandCancelTraining (CUnit &unit, int slot, const CUnitType *type)
 Prepare command cancel training.
void CommandUpgradeTo (CUnit &unit, CUnitType &type, int flush)
 Prepare command upgrade to.
void CommandTransformIntoType (CUnit &unit, CUnitType &type)
 immediate transforming into type.
void CommandCancelUpgradeTo (CUnit &unit)
 Prepare command cancel upgrade to.
void CommandResearch (CUnit &unit, CUpgrade *what, int flush)
 Prepare command research.
void CommandCancelResearch (CUnit &unit)
 Prepare command cancel research.
void CommandSpellCast (CUnit &unit, const Vec2i &pos, CUnit *dest, SpellType *spell, int flush)
void CommandAutoSpellCast (CUnit &unit, int spellid, int on)
 Prepare command auto spellcast.
void CommandDiplomacy (int player, int state, int opponent)
 Prepare diplomacy command.
void CommandSetResource (int player, int resource, int value)
 Prepare set resources command.
void CommandSharedVision (int player, bool state, int opponent)
 Prepare shared vision command.
void CommandQuit (int player)
 Hash calculated to find sync failures.

Function Documentation

static void ClearSavedAction ( CUnit unit  )  [static]

Clear the saved action.

Parameters:
unit Unit 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.

void CommandAnyOrder ( CUnit unit,
COrderPtr  cpyorder,
int  flush 
)

Order an already formed Order structure

Parameters:
unit pointer to unit
cpyorder pointer to valid order
flush if true, flush command queue.

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

Attack with unit at new position

Parameters:
unit pointer to unit.
pos map position to attack.
attack or unit to be attacked.
flush if true, flush command queue.

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

Attack ground with unit.

Parameters:
unit pointer to unit.
pos map position to fire on.
flush if true, flush command queue.

void CommandAutoRepair ( CUnit unit,
int  on 
)

Send auto repair command.

Auto repair.

Parameters:
unit pointer to unit.
on 1 for auto repair on, 0 for off.

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

Prepare command auto spellcast.

Auto spell cast.

Parameters:
unit pointer to unit.
spellid Spell id.
on 1 for auto cast on, 0 for off.

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

Prepare command board.

Board a transporter with unit.

Parameters:
unit pointer to unit.
dest unit to be boarded.
flush if true, flush command queue.

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

Send a unit building

Parameters:
unit pointer to unit.
pos map position to build.
what Unit type to build.
flush if true, flush command queue.

void CommandCancelResearch ( CUnit unit  ) 

Prepare command cancel research.

Cancel Building researching.

Parameters:
unit Pointer to unit.

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

Prepare command cancel training.

Cancel the training of an unit.

Parameters:
unit pointer to unit.
slot slot number to cancel.
type Unit-type to cancel.

void CommandCancelUpgradeTo ( CUnit unit  ) 

Prepare command cancel upgrade to.

Cancel building upgrading to.

Parameters:
unit pointer to unit.

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

Prepare diplomacy command.

Diplomacy changed.

Parameters:
player Player which changes his state.
state New diplomacy state.
opponent Opponent.

void CommandDismiss ( CUnit unit  ) 

Prepare command dismiss.

Cancel the building construction, or kill a unit.

Parameters:
unit pointer to unit.

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

Prepare command follow.

Follow unit to new position

Parameters:
unit pointer to unit.
dest unit to be followed
flush if true, flush command queue.

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

Move unit to new position

Parameters:
unit pointer to unit.
pos map position to move to.
flush if true, flush command queue.

void CommandMoveOrder ( CUnit unit,
int  src,
int  dst 
)

Send any command.

Move an order in the order queue. ( Cannot move the order 0 ! )

Parameters:
unit pointer to unit
src the order to move
dst the new position of the order

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

Let a unit patrol from current to new position

FIXME: want to support patroling between units.

Parameters:
unit pointer to unit.
pos map position to patrol between.
flush if true, flush command queue.

void CommandQuit ( int  player  ) 

Hash calculated to find sync failures.

Player quit.

Parameters:
player Player number that quit.

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

Repair unit

Parameters:
unit pointer to unit.
pos map position to repair.
dest or unit to be repaired. FIXME: not supported
flush if true, flush command queue.

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

Prepare command research.

Building starts researching.

Parameters:
unit pointer to unit.
what what to research.
flush if true, flush command queue.

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

Prepare command resource.

Send unit to harvest resources

Parameters:
unit pointer to unit.
dest destination unit.
flush if true, flush command queue.

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

Send unit harvest a location

Parameters:
unit pointer to unit.
pos map position for harvest.
flush if true, flush command queue.

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

Prepare command return.

Let unit returning goods.

Parameters:
unit pointer to unit.
goal bring goods to this depot.
flush if true, flush command queue.

void CommandSetResource ( int  player,
int  resource,
int  value 
)

Prepare set resources command.

Set new resources count for player.

Parameters:
player Player which changes his state.
resource Resource index
value New value

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

Prepare shared vision command.

Shared vision changed.

Parameters:
player Player which changes his state.
state New shared vision state.
opponent Opponent.

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

Cast a spell at position or unit.

Parameters:
unit Pointer to unit.
pos map position to spell cast on.
dest Spell cast on unit (if exist).
spell Spell type pointer.
flush If true, flush command queue.

void CommandStandGround ( CUnit unit,
int  flush 
)

Prepare command stand ground.

Stand ground.

Parameters:
unit pointer to unit.
flush if true, flush command queue.

void CommandStopUnit ( CUnit unit  ) 

Prepare command stop.

Stop unit.

Parameters:
unit pointer to unit.

void CommandTrainUnit ( CUnit unit,
CUnitType type,
int   
)

Prepare command train.

Building starts training an unit.

Parameters:
unit pointer to unit.
type unit type to train.
flush if true, flush command queue.

void CommandTransformIntoType ( CUnit unit,
CUnitType type 
)

immediate transforming into type.

Immediate transforming unit into type.

Parameters:
unit pointer to unit.
type upgrade to type

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

Unload a transporter.

Parameters:
unit pointer to unit.
pos map position to unload.
what unit to be unloaded, NoUnitP all.
flush if true, flush command queue.

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

Prepare command upgrade to.

Building starts upgrading to.

Parameters:
unit pointer to unit.
type upgrade to type
flush if true, flush command queue.

static COrderPtr GetNextOrder ( CUnit unit,
int  flush 
) [static]

Get next free order slot.

Parameters:
unit pointer to unit.
flush if true, flush order queue.
Returns:
Pointer to next free order slot.

static void ReleaseOrders ( CUnit unit  )  [static]

Release all orders of a unit.

Parameters:
unit Pointer to unit.

static void RemoveOrder ( CUnit unit,
int  order 
) [static]

Remove an order from the list of orders pending

Parameters:
unit pointer to unit
order number of the order to remove

(C) Copyright 1998-2011 by The Stratagus Project under the GNU General Public License.
All trademarks and copyrights on this page are owned by their respective owners.