Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Order Class Reference

#include <order.h>

Inheritance diagram for Order:
AIScript CloakFor CommunicatingAI FireKeyboard Orders::AutoDocking Orders::ChangeHeading Orders::ExecuteFor Orders::FireAllYouGot Orders::Join Orders::MatchAngularVelocity Orders::MatchLinearVelocity Orders::MatchRoll Orders::MoveTo Orders::Sequence PlanetaryOrbit

Public Types

enum  ORDERTYPES {
  MOVEMENT =1, FACING =2, WEAPON =4, CLOAKING =8,
  ALLTYPES =(1|2|4|8)
}
 The varieties of order types MOVEMENT,FACING, and WEAPON orders may not be mutually executed (lest one engine goes left, the other right) More...
 
enum  SUBORDERTYPES { SLOCATION =1, STARGET =2, SSELF =4 }
 

Public Member Functions

virtual void ChooseTarget ()
 this function calls the destructor (needs to be overridden for python; More...
 
virtual bool PursueTarget (Unit *, bool isleader)
 
void ClearMessages ()
 clears the messasges of this order More...
 
 Order ()
 The default constructor setting everything to NULL and no dependency on order. More...
 
 Order (int type, int subtype)
 The constructor that specifies what order dependencies this order has. More...
 
virtual void Destroy ()
 The virutal function that unrefs all memory then calls Destruct () which takes care of unreffing this or calling delete on this. More...
 
virtual void Execute ()
 The function that gets called and executes all queued suborders. More...
 
OrderqueryType (unsigned int type)
 returns a pointer to the first order that may be bitwised ored with that type More...
 
OrderqueryAny (unsigned int type)
 returns a pointer to the first order that may be bitwise ored with any type More...
 
void eraseType (unsigned int type)
 Erases all orders that bitwise OR with that type. More...
 
bool AttachOrder (Unit *targets)
 Attaches a group of targets to this order (used for strategery-type games) More...
 
bool AttachOrder (QVector target)
 Attaches a navigation point to this order. More...
 
bool AttachSelfOrder (Unit *targets)
 Attaches a group (form up) to this order. More...
 
OrderEnqueueOrder (Order *ord)
 Enqueues another order that will be executed (in parallel perhaps) when next void Execute() is called. More...
 
OrderReplaceOrder (Order *ord)
 Replaces the first order of that type in the order queue. More...
 
bool Done ()
 
int getType ()
 
int getSubType ()
 
virtual void SetParent (Unit *parent1)
 Sets the parent of this Unit. Any virtual functions must call this one. More...
 
UnitGetParent () const
 
virtual void Communicate (const class CommunicationMessage &c)
 Sends a communication message from the Unit (encapulated in c) to this unit. More...
 
virtual void ProcessCommMessage (class CommunicationMessage &c)
 processes a single message...generally called by the Messages() func More...
 
virtual void ProcessCommunicationMessages (float CommRepsonseTime, bool RemoveMessageProcessed)
 responds (or does not) to certain messages in the message queue More...
 
OrderfindOrder (Order *ord)
 return pointer to order or NULL if not found More...
 
void eraseOrder (Order *ord)
 erase that order from the list More...
 
OrderEnqueueOrderFirst (Order *ord)
 enqueue order as first order More...
 
virtual olist_tgetOrderList ()
 returns the orderlist (NULL for orders that haven't got any) More...
 
virtual void AdjustRelationTo (Unit *un, float factor)
 
virtual std::string getOrderDescription ()
 
OrderfindOrderList ()
 searches the suborders recursively for the first order that has an orderlist More...
 
std::string createFullOrderDescription (int level=0)
 
void setActionString (std::string astring)
 
std::string getActionString ()
 
virtual float getMood ()
 

Protected Member Functions

virtual ~Order ()
 
virtual void Destructor ()
 changes the local relation of this unit to another...may inform superiors about "good" or bad! behavior depending on the AI More...
 

Protected Attributes

Unitparent
 The unit this order is attached to. More...
 
unsigned int type
 The bit code (from ORDERTYPES) that this order is (for parallel execution) More...
 
unsigned int subtype
 
bool done
 Whether or not this order is done. More...
 
UnitContainer group
 If this order applies to a group of units (as in form up with this group) More...
 
QVector targetlocation
 If this order applies to a physical location in world space. More...
 
std::vector< Order * > suborders
 The queue of suborders that will be executed in parallel according to bit code. More...
 
std::list< class
CommunicationMessage * > 
messagequeue
 a bunch of communications that have not been answered CommunicationMessages are actually containing reference to a nice Finite State Machine that can allow a player to have a reasonable conversation with an AI More...
 
std::string actionstring
 

Detailed Description

Definition at line 44 of file order.h.

Member Enumeration Documentation

The varieties of order types MOVEMENT,FACING, and WEAPON orders may not be mutually executed (lest one engine goes left, the other right)

Enumerator
MOVEMENT 
FACING 
WEAPON 
CLOAKING 
ALLTYPES 

Definition at line 84 of file order.h.

84 {MOVEMENT=1, FACING=2, WEAPON=4, CLOAKING=8, ALLTYPES=(1|2|4|8)};
Enumerator
SLOCATION 
STARGET 
SSELF 

Definition at line 85 of file order.h.

85 {SLOCATION=1, STARGET=2, SSELF=4};

Constructor & Destructor Documentation

Order::~Order ( )
protectedvirtual

Definition at line 158 of file order.cpp.

References VSDESTRUCT1.

159 {
161 }
Order::Order ( )
inline

The default constructor setting everything to NULL and no dependency on order.

Definition at line 87 of file order.h.

References VSCONSTRUCT1.

Referenced by OrderFactory::newOrder().

88  : parent(NULL),
89  type(0),
90  subtype(0),
91  done(false),
92  targetlocation( 0, 0, 0 )
93  {
94  VSCONSTRUCT1( 'O' )
95  }
Order::Order ( int  type,
int  subtype 
)
inline

The constructor that specifies what order dependencies this order has.

Definition at line 97 of file order.h.

References VSCONSTRUCT1.

98  : parent(NULL),
99  type(type),
100  subtype(subtype),
101  done(false),
102  targetlocation( 0, 0, 0 )
103  {
104  VSCONSTRUCT1( 'O' )
105  }

Member Function Documentation

void Order::AdjustRelationTo ( Unit un,
float  factor 
)
virtual

Reimplemented in CommunicatingAI.

Definition at line 8 of file order_comm.cpp.

Referenced by CommunicatingAI::AdjustRelationTo(), Communicate(), and FireKeyboard::DoSpeechAndAni().

9 {
10  //virtual stub function
11 }
bool Order::AttachOrder ( Unit targets)

Attaches a group of targets to this order (used for strategery-type games)

Definition at line 118 of file order.cpp.

References AttachSelfOrder(), parent, SSELF, STARGET, subtype, and Unit::Target().

Referenced by Orders::AggressiveAI::AggressiveAI(), and PlanetaryOrbit::PlanetaryOrbit().

119 {
120  if ( !(subtype&STARGET) ) {
121  if (subtype&SSELF)
122  return AttachSelfOrder( targets1 ); //can use attach order to do shit
123 
124  return false;
125  }
126  parent->Target( targets1 );
127  return true;
128 }
bool Order::AttachOrder ( QVector  target)

Attaches a navigation point to this order.

Definition at line 138 of file order.cpp.

References SLOCATION, subtype, and targetlocation.

139 {
140  if ( !(subtype&SLOCATION) )
141  return false;
142  targetlocation = targetv;
143  return true;
144 }
bool Order::AttachSelfOrder ( Unit targets)

Attaches a group (form up) to this order.

Definition at line 130 of file order.cpp.

References group, UnitContainer::SetUnit(), SSELF, and subtype.

Referenced by AttachOrder(), PlanetaryOrbit::PlanetaryOrbit(), Orders::AggressiveAI::ProcessCurrentFgDirective(), Orders::FormUp::SetParent(), Orders::FormUpToOwner::SetParent(), and Orders::FaceDirection::SetParent().

131 {
132  if ( !(subtype&SSELF) )
133  return false;
134  group.SetUnit( targets1 );
135  return true;
136 }
virtual void Order::ChooseTarget ( )
inlinevirtual

this function calls the destructor (needs to be overridden for python;

Reimplemented in Orders::FireAt.

Definition at line 73 of file order.h.

Referenced by Pilot::adjustSpecificRelationship().

74  {
75  /*not implemented see fire.cpp*/
76  }
void Order::ClearMessages ( )

clears the messasges of this order

Definition at line 185 of file order.cpp.

References i, messagequeue, and suborders.

186 {
187  unsigned int i;
188  for (i = 0; i < suborders.size(); i++)
189  suborders[i]->ClearMessages();
190  {
191  for (list< CommunicationMessage* >::iterator i = messagequeue.begin(); i != messagequeue.end(); i++)
192  delete (*i);
193  }
194  messagequeue.clear();
195 }
void Order::Communicate ( const class CommunicationMessage c)
virtual

Sends a communication message from the Unit (encapulated in c) to this unit.

Definition at line 13 of file order_comm.cpp.

References _Universe, AdjustRelationTo(), FACING, CommunicationMessage::getDeltaRelation(), Unit::GetSerial(), getType(), UnitContainer::GetUnit(), VegaConfig::getVariable(), i, messagequeue, MOVEMENT, Universe::netLocked(), Network, parent, XMLSupport::parse_bool(), XMLSupport::parse_float(), NetServer::sendCommunication(), CommunicationMessage::sender, SERVER, suborders, vs_config, VSServer, WEAPON, and Universe::whichPlayerStarship().

Referenced by Unit::ApplyDamage(), BaseInterface::Room::Launch::Click(), BaseInterface::Room::Eject::Click(), DoDockingOps(), FireKeyboard::Execute(), GetMadAt(), HelpOut(), CommunicatingAI::InitiateContrabandSearch(), CommunicatingAI::ProcessCommMessage(), ProcessCommunicationMessages(), Orders::AggressiveAI::ProcessCurrentFgDirective(), RequestClearence(), ScoreKill(), CommunicatingAI::TerminateContrabandSearch(), TryDock(), and CommunicatingAI::UpdateContrabandSearch().

14 {
15  if (this == NULL)
16  return;
17  if ( Network != NULL && !_Universe->netLocked() ) {
18  //Stupid constness rules...
19  int cp = _Universe->whichPlayerStarship( const_cast< UnitContainer& > (c.sender).GetUnit() );
20  if (cp != -1 && parent && parent->GetSerial() != 0)
21  Network[cp].communicationRequest( c, parent->GetSerial() );
22  return;
23  }
24  int completed = 0;
25  unsigned int i = 0;
27  for (i = 0; i < suborders.size(); i++)
28  if ( ( completed&( (suborders[i])->getType()&(MOVEMENT|FACING|WEAPON) ) ) == 0 ) {
29  (suborders[i])->Communicate( *newC );
30  completed |= (suborders[i])->getType();
31  }
32  Unit *un;
33  bool already_communicated = false;
34  for (list< CommunicationMessage* >::iterator ii = messagequeue.begin(); ii != messagequeue.end(); ii++) {
35  un = (*ii)->sender.GetUnit();
36  bool thisissender = ( un == newC->sender.GetUnit() );
37  if (un == NULL || thisissender) {
38  delete (*ii);
39  if (thisissender) already_communicated = true;
40  if ( ( ii = messagequeue.erase( ii ) ) == messagequeue.end() )
41  break;
42  }
43  }
44  if ( ( un = newC->sender.GetUnit() ) ) {
45  if (un != parent) {
46  static bool talk_more_helps = XMLSupport::parse_bool( vs_config->getVariable( "AI", "talking_faster_helps", "true" ) );
47  static float talk_factor = XMLSupport::parse_float( vs_config->getVariable( "AI", "talk_relation_factor", ".5" ) );
48  if (talk_more_helps || !already_communicated)
49  AdjustRelationTo( un, newC->getDeltaRelation()*talk_factor );
50  messagequeue.push_back( newC );
51  }
52  }
53  if (SERVER) {
54  Unit *plr = const_cast< UnitContainer& > (c.sender).GetUnit();
56  if (cp >= 1)
58  }
59 }
string Order::createFullOrderDescription ( int  level = 0)

Definition at line 228 of file order.cpp.

References getOrderDescription(), i, j, BeamXML::level, and suborders.

229 {
230  string tabs;
231  for (int i = 0; i < level; i++)
232  tabs = tabs+" ";
233  string desc = tabs+"+"+getOrderDescription()+"\n";
234  for (unsigned int j = 0; j < suborders.size(); j++)
235  desc = desc+suborders[j]->createFullOrderDescription( level+1 );
236  return desc;
237 }
void Order::Destroy ( )
virtual

The virutal function that unrefs all memory then calls Destruct () which takes care of unreffing this or calling delete on this.

Reimplemented in Orders::ExecuteFor, FlyByKeyboard, Orders::DockingOps, and CommunicatingAI.

Definition at line 166 of file order.cpp.

References Destructor(), getOrderDescription(), i, messagequeue, and suborders.

Referenced by CommunicatingAI::Destroy(), Orders::DockingOps::Destroy(), FlyByKeyboard::Destroy(), Orders::ExecuteFor::Destroy(), Unit::DisableTurretAI(), FlyByKeyboard::Execute(), ReplaceOrder(), and Unit::SetTurretAI().

167 {
168  unsigned int i;
169  for (i = 0; i < suborders.size(); i++) {
170  if (suborders[i] == NULL) {
171  printf( "ORDER: a null order\n" );
172  printf( "this order: %s\n", getOrderDescription().c_str() );
173  } else {
174  suborders[i]->Destroy();
175  }
176  }
177  {
178  for (list< CommunicationMessage* >::iterator i = messagequeue.begin(); i != messagequeue.end(); i++)
179  delete (*i);
180  }
181  messagequeue.clear();
182  suborders.clear();
183  this->Destructor();
184 }
void Order::Destructor ( )
protectedvirtual

changes the local relation of this unit to another...may inform superiors about "good" or bad! behavior depending on the AI

Definition at line 162 of file order.cpp.

Referenced by Destroy().

163 {
164  delete this;
165 }
bool Order::Done ( )
inline

Definition at line 127 of file order.h.

References done.

Referenced by Orders::AutoDocking::DepartureState(), Orders::ChangeHeading::Execute(), Orders::Join::Execute(), and Orders::Sequence::Execute().

128  {
129  return done;
130  }
Order * Order::EnqueueOrder ( Order ord)

Enqueues another order that will be executed (in parallel perhaps) when next void Execute() is called.

Definition at line 80 of file order.cpp.

References getOrderDescription(), parent, SetParent(), and suborders.

Referenced by AddOrd(), AfterburnVeerAndTurnAway(), Orders::AutoDocking::EnqueuePort(), Orders::AggressiveAI::ExecuteLogicItem(), GoTo(), Orders::Join::Join(), Orders::DockingOps::Movement(), Orders::DockingOps::PerformDockingOperations(), and Orders::Sequence::Sequence().

81 {
82  if (ord == NULL) {
83  printf( "NOT ENQEUEING NULL ORDER\n" );
84  printf( "this order: %s\n", getOrderDescription().c_str() );
85  return NULL;
86  }
87  ord->SetParent( parent );
88  suborders.push_back( ord );
89  return this;
90 }
Order * Order::EnqueueOrderFirst ( Order ord)

enqueue order as first order

Definition at line 91 of file order.cpp.

References getOrderDescription(), parent, SetParent(), and suborders.

Referenced by FlyByKeyboard::Execute(), and Orders::AggressiveAI::ProcessCurrentFgDirective().

92 {
93  if (ord == NULL) {
94  printf( "NOT ENQEUEING NULL ORDER\n" );
95  printf( "this order: %s\n", getOrderDescription().c_str() );
96  return NULL;
97  }
98  ord->SetParent( parent );
99 
100  vector< Order* >::iterator first_elem = suborders.begin();
101  suborders.insert( first_elem, ord );
102  return this;
103 }
void Order::eraseOrder ( Order ord)

erase that order from the list

Definition at line 196 of file order.cpp.

References getOrderDescription(), i, j, and suborders.

197 {
198  bool found = false;
199  if (ord == NULL) {
200  printf( "NOT ERASING A NULL ORDER\n" );
201  printf( "this order: %s\n", getOrderDescription().c_str() );
202  return;
203  }
204  for (unsigned int i = 0; i < suborders.size() && found == false; i++)
205  if (suborders[i] == ord) {
206  suborders[i]->Destroy();
207  vector< Order* >::iterator j = suborders.begin()+i;
208  suborders.erase( j );
209  found = true;
210  }
211  if (!found) {
212  printf( "TOLD TO ERASE AN ORDER - NOT FOUND\n" );
213  printf( "this order: %s\n", getOrderDescription().c_str() );
214  }
215 }
void Order::eraseType ( unsigned int  type)

Erases all orders that bitwise OR with that type.

Definition at line 69 of file order.cpp.

References i, j, suborders, and type.

Referenced by Orders::AutoDocking::EraseOrders(), Orders::AggressiveAI::Execute(), FlyByKeyboard::Execute(), GoTo(), Orders::AggressiveAI::ProcessCurrentFgDirective(), and Orders::AggressiveAI::ProcessLogic().

70 {
71  for (unsigned int i = 0; i < suborders.size(); i++)
72  if ( (suborders[i]->type&type) == type ) {
73  suborders[i]->Destroy();
74  vector< Order* >::iterator j = suborders.begin()+i;
75  suborders.erase( j );
76  i--;
77  }
78 }
void Order::Execute ( )
virtual

The function that gets called and executes all queued suborders.

Reimplemented in FlyTo, Orders::FacePerpendicular, Orders::LoopAroundAgro, Orders::LoopAround, Orders::Sequence, Orders::Join, Orders::ExecuteFor, Orders::FaceDirection, FlyByWire, Orders::FormUpToOwner, Orders::FormUp, Orders::FaceTargetITTS, FireKeyboard, EvadeLeftRightC, Orders::AutoLongHaul, Orders::MatchVelocity, Orders::FaceTarget, Orders::ChangeHeading, Orders::MatchRoll, FlyByKeyboard, Orders::MatchAngularVelocity, Orders::MoveTo, Orders::AutoDocking, Orders::FireAt, Orders::AggressiveAI, AImissionScript, PlanetaryOrbit, AIScript, Orders::MatchLinearVelocity, Orders::DockingOps, CloakFor, FlyByJoystick, Orders::Ikarus, Orders::TurretAI, and Orders::FireAllYouGot.

Definition at line 31 of file order.cpp.

References ALLTYPES, done, getType(), VegaConfig::getVariable(), i, XMLSupport::parse_float(), ProcessCommunicationMessages(), suborders, and vs_config.

Referenced by Orders::AutoDocking::ApproachState(), Orders::AutoDocking::DepartureState(), Orders::Ikarus::Execute(), AIScript::Execute(), AImissionScript::Execute(), PlanetaryOrbit::Execute(), Orders::FireAt::Execute(), Orders::MatchAngularVelocity::Execute(), FlyByKeyboard::Execute(), Orders::MatchRoll::Execute(), Orders::ChangeHeading::Execute(), Orders::ExecuteFor::Execute(), Orders::Join::Execute(), and Orders::Sequence::Execute().

32 {
33  static float airesptime = XMLSupport::parse_float( vs_config->getVariable( "AI", "CommResponseTime", "3" ) );
34  ProcessCommunicationMessages( airesptime, true );
35  int completed = 0;
36  unsigned int i = 0;
37  for (i = 0; i < suborders.size(); i++)
38  if ( ( completed&( (suborders[i])->getType()&(ALLTYPES) ) ) == 0 ) {
39  (suborders[i])->Execute();
40  completed |= (suborders[i])->getType();
41  if ( (suborders[i])->Done() ) {
42  vector< Order* >::iterator ord = suborders.begin()+i;
43  (*ord)->Destroy();
44  suborders.erase( ord );
45  i--;
46  }
47  }
48  if (suborders.size() == 0)
49  done = true;
50  else
51  done = false;
52 }
Order * Order::findOrder ( Order ord)

return pointer to order or NULL if not found

Definition at line 146 of file order.cpp.

References getOrderDescription(), i, and suborders.

147 {
148  if (ord == NULL) {
149  printf( "FINDING EMPTY ORDER\n" );
150  printf( "this order: %s\n", getOrderDescription().c_str() );
151  return NULL;
152  }
153  for (unsigned int i = 0; i < suborders.size(); i++)
154  if (suborders[i] == ord)
155  return suborders[i];
156  return NULL;
157 }
Order * Order::findOrderList ( )

searches the suborders recursively for the first order that has an orderlist

Definition at line 217 of file order.cpp.

References getOrderList(), i, and suborders.

Referenced by Mission::DirectorShipDestroyed().

218 {
219  olist_t *orderlist = getOrderList();
220  if (orderlist)
221  return this;
222  Order *found_order = NULL;
223  for (unsigned int i = 0; i < suborders.size() && found_order == NULL; i++)
224  found_order = suborders[i]->findOrderList();
225  return found_order;
226 }
std::string Order::getActionString ( )
inline

Definition at line 179 of file order.h.

References actionstring.

Referenced by AImissionScript::getOrderDescription().

180  {
181  return actionstring;
182  }
virtual float Order::getMood ( )
inlinevirtual

Reimplemented in CommunicatingAI.

Definition at line 183 of file order.h.

184  {
185  return 0;
186  }
virtual olist_t* Order::getOrderList ( )
inlinevirtual

returns the orderlist (NULL for orders that haven't got any)

Reimplemented in AIOrderList.

Definition at line 161 of file order.h.

Referenced by Mission::DirectorShipDestroyed(), and findOrderList().

162  {
163  return NULL;
164  }
Unit* Order::GetParent ( ) const
inline

Definition at line 144 of file order.h.

References parent.

Referenced by Orders::AutoDocking::Execute(), Orders::FireAt::GetParent(), and CommunicatingAI::GetRandomUnit().

145  {
146  return parent;
147  }
int Order::getSubType ( )
inline

Definition at line 135 of file order.h.

References subtype.

Referenced by Orders::Join::Join().

136  {
137  return subtype;
138  }
int Order::getType ( )
inline

Definition at line 131 of file order.h.

References type.

Referenced by Communicate(), Execute(), Orders::ExecuteFor::Execute(), Orders::Join::Join(), and ReplaceOrder().

132  {
133  return type;
134  }
void Order::ProcessCommMessage ( class CommunicationMessage c)
virtual

processes a single message...generally called by the Messages() func

Reimplemented in FireKeyboard, and CommunicatingAI.

Definition at line 61 of file order_comm.cpp.

Referenced by CommunicatingAI::ProcessCommMessage(), and ProcessCommunicationMessages().

61 {}
void Order::ProcessCommunicationMessages ( float  CommRepsonseTime,
bool  RemoveMessageProcessed 
)
virtual

responds (or does not) to certain messages in the message queue

Definition at line 62 of file order_comm.cpp.

References c, Communicate(), CommunicationMessage::fsm, FSM::GetAbleToDockNode(), Unit::getAIState(), Unit::getFlightgroup(), Unit::getRelation(), FSM::GetUnAbleToDockNode(), messagequeue, Flightgroup::name, parent, ProcessCommMessage(), Unit::RequestClearance(), CommunicationMessage::SetCurrentState(), and SIMULATION_ATOM.

Referenced by Execute(), and FireKeyboard::Execute().

63 {
64  float time = AICommresponseTime/SIMULATION_ATOM;
65  if (time <= .001)
66  time += .001;
67  if ( !messagequeue.empty() ) {
68  bool cleared = false;
69  if ( messagequeue.back()->curstate == messagequeue.back()->fsm->GetRequestLandNode() ) {
70  cleared = true;
71  RemoveMessageProcessed = true;
72  Unit *un = messagequeue.back()->sender.GetUnit();
73  if (un) {
74  CommunicationMessage c( parent, un, NULL, 0 );
75  if ( parent->getRelation( un ) >= 0
76  || (parent->getFlightgroup() && parent->getFlightgroup()->name == "Base") ) {
77  parent->RequestClearance( un );
78  c.SetCurrentState( c.fsm->GetAbleToDockNode(), NULL, 0 );
79  } else {
80  c.SetCurrentState( c.fsm->GetUnAbleToDockNode(), NULL, 0 );
81  }
82  Order *o = un->getAIState();
83  if (o)
84  o->Communicate( c );
85  }
86  }
87  if ( cleared || ( ( (float) rand() )/RAND_MAX ) < (1/time) ) {
88  FSM::Node *n;
89  if ( ( n = messagequeue.back()->getCurrentState() ) )
91  if (RemoveMessageProcessed) {
92  delete messagequeue.back();
93  messagequeue.pop_back();
94  } else {
95  messagequeue.push_front( messagequeue.back() );
96  messagequeue.pop_back();
97  }
98  }
99  }
100 }
virtual bool Order::PursueTarget ( Unit ,
bool  isleader 
)
inlinevirtual

Reimplemented in Orders::FireAt.

Definition at line 77 of file order.h.

Referenced by Unit::AutoPilotToErrorMessage().

78  {
79  return false;
80  }
Order * Order::queryAny ( unsigned int  type)

returns a pointer to the first order that may be bitwise ored with any type

Definition at line 61 of file order.cpp.

References i, and suborders.

Referenced by Orders::AggressiveAI::Execute().

62 {
63  for (unsigned int i = 0; i < suborders.size(); i++)
64  if ( (suborders[i]->type&type) != 0 )
65  return suborders[i];
66  return NULL;
67 }
Order * Order::queryType ( unsigned int  type)

returns a pointer to the first order that may be bitwised ored with that type

Definition at line 54 of file order.cpp.

References i, suborders, and type.

Referenced by FlyByKeyboard::Execute(), and Orders::AggressiveAI::ProcessLogicItem().

55 {
56  for (unsigned int i = 0; i < suborders.size(); i++)
57  if ( (suborders[i]->type&type) == type )
58  return suborders[i];
59  return NULL;
60 }
Order * Order::ReplaceOrder ( Order ord)

Replaces the first order of that type in the order queue.

Definition at line 104 of file order.cpp.

References ALLTYPES, Destroy(), getType(), and suborders.

Referenced by GoTo(), Orders::AggressiveAI::ProcessCurrentFgDirective(), and ReplaceOrd().

105 {
106  for (vector< Order* >::iterator ordd = suborders.begin(); ordd != suborders.end();) {
107  if ( ( ord->getType()&(*ordd)->getType()&(ALLTYPES) ) ) {
108  (*ordd)->Destroy();
109  ordd = suborders.erase( ordd );
110  } else {
111  ordd++;
112  }
113  }
114  suborders.push_back( ord );
115  return this;
116 }
void Order::setActionString ( std::string  astring)
inline

Definition at line 175 of file order.h.

References actionstring.

176  {
177  actionstring = astring;
178  }

Member Data Documentation

std::string Order::actionstring
protected

Definition at line 188 of file order.h.

Referenced by AImissionScript::AImissionScript(), getActionString(), and setActionString().

UnitContainer Order::group
protected

If this order applies to a group of units (as in form up with this group)

Definition at line 59 of file order.h.

Referenced by AttachSelfOrder(), PlanetaryOrbit::Execute(), Orders::AutoLongHaul::Execute(), Orders::FormUp::Execute(), Orders::FormUpToOwner::Execute(), Orders::FaceDirection::Execute(), and Orders::AutoLongHaul::SetParent().

std::list< class CommunicationMessage* > Order::messagequeue
protected

a bunch of communications that have not been answered CommunicationMessages are actually containing reference to a nice Finite State Machine that can allow a player to have a reasonable conversation with an AI

Definition at line 65 of file order.h.

Referenced by ClearMessages(), Communicate(), Destroy(), CommunicatingAI::ProcessCommMessage(), ProcessCommunicationMessages(), and CommunicatingAI::RandomInitiateCommunication().

Unit* Order::parent
protected

The unit this order is attached to.

Definition at line 51 of file order.h.

Referenced by FlyByWire::Accel(), Orders::FireAt::AddReplaceLastOrder(), CommunicatingAI::AdjustRelationTo(), FlyByWire::Afterburn(), Orders::AggressiveAI::AfterburnerJumpTurnTowards(), AttachOrder(), Orders::FireAt::ChangeLocalDirection(), FlyByKeyboard::clamp_axis(), Communicate(), CommunicatingAI::Destroy(), Orders::DockingOps::Destroy(), FlyByWire::DirectThrustFront(), FlyByWire::DirectThrustRight(), FlyByWire::DirectThrustUp(), Orders::DockingOps::DockToTarget(), EnqueueOrder(), EnqueueOrderFirst(), Orders::FireAllYouGot::Execute(), Orders::TurretAI::Execute(), FlyByJoystick::Execute(), Orders::Ikarus::Execute(), CloakFor::Execute(), Orders::DockingOps::Execute(), PlanetaryOrbit::Execute(), AImissionScript::Execute(), Orders::AggressiveAI::Execute(), Orders::MatchAngularVelocity::Execute(), FlyByKeyboard::Execute(), FireKeyboard::Execute(), FlyByWire::Execute(), Orders::ExecuteFor::Execute(), Orders::AggressiveAI::ExecuteNoEnemies(), CommunicatingAI::GetMadAt(), GetParent(), CommunicatingAI::GetRandomUnit(), FlyByWire::InertialFlight(), CommunicatingAI::InitiateContrabandSearch(), Orders::FireAt::MatchAngularVelocity(), Orders::FireAt::MatchLinearVelocity(), FlyByWire::MatchSpeed(), Orders::FireAt::MatchVelocity(), Orders::DockingOps::Movement(), Orders::DockingOps::PerformDockingOperations(), CommunicatingAI::ProcessCommMessage(), FireKeyboard::ProcessCommMessage(), ProcessCommunicationMessages(), Orders::AggressiveAI::ProcessCurrentFgDirective(), Orders::AggressiveAI::ProcessLogicItem(), Orders::FireAt::PursueTarget(), CommunicatingAI::RandomInitiateCommunication(), Orders::AggressiveAI::ReCommandWing(), FlyByKeyboard::reduce_axis(), Orders::DockingOps::RequestClearence(), Orders::DockingOps::RestoreOldAI(), FlyByWire::Right(), FlyByWire::RollRight(), CommunicatingAI::selectCommunicationMessage(), CommunicatingAI::selectCommunicationMessageMood(), Orders::DockingOps::SetParent(), FireKeyboard::SetParent(), Orders::AggressiveAI::SetParent(), SetParent(), Orders::AggressiveAI::SignalChosenTarget(), FlyByWire::Stop(), CommunicatingAI::TerminateContrabandSearch(), FlyByWire::ThrustFront(), FlyByWire::ThrustRight(), FlyByWire::ThrustUp(), Orders::DockingOps::Undock(), FlyByWire::Up(), CommunicatingAI::UpdateContrabandSearch(), AImissionScript::~AImissionScript(), CloakFor::~CloakFor(), and PlanetaryOrbit::~PlanetaryOrbit().

std::vector< Order* > Order::suborders
protected
QVector Order::targetlocation
protected

If this order applies to a physical location in world space.

Definition at line 61 of file order.h.

Referenced by AttachOrder(), PlanetaryOrbit::Execute(), Orders::MoveTo::Execute(), Orders::MoveTo::MoveTo(), and Orders::MoveTo::SetDest().


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