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

commands.cpp File Reference
#include "stratagus.h"
#include "commands.h"
#include "actions.h"
#include "fov.h"
#include "net_message.h"
#include "network.h"
#include "replay.h"
#include "spells.h"
#include "unit.h"
#include "unit_manager.h"
#include "unittype.h"

Functions

commands.cpp - Global command handler - network support.
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 *attack, 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 *goal, 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...
 
parse
void ExecCommand (unsigned char msgnr, UnitRef unum, unsigned short x, unsigned short y, UnitRef dstnr)
 Execute a command (from network). More...
 
static const char * GetDiplomacyName (enum _diplomacy_ e)
 
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...
 

Function Documentation

◆ 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(...);

◆ GetDiplomacyName()

static const char* GetDiplomacyName ( enum _diplomacy_  e)
static

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