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
flightgroup.h
Go to the documentation of this file.
1 #ifndef _FLIGHTGROUP_H_
2 #define _FLIGHTGROUP_H_
3 #include "config.h"
4 #include "cmd/container.h"
5 #include "mission.h"
6 #include <string>
7 #include <vector>
8 #include <gnuhash.h>
9 
10 class Texture;
11 
13 {
14 private:
15  std::string squadLogoStr;
16 public:
17  UnitContainer leader; //I'm on the leader
18  UnitContainer target; //this is my target, what i'm doing with it depends on things
19  int leader_decision; //-1 if decision is made
20  Texture *squadLogo; //null if not there
21  std::string directive; //"a" for attack target "b" for attack at will "h" for help out "f" for form up.... missions can get this..and set this
22  std::string name; //flightgroup name
23  std::string type;
24  std::string ainame; //.agg.xml and .int.xml get appended to this
25  std::string faction;
26  int flightgroup_nr; //running fg number
27  int nr_ships; //total ships nr
31  vsUMap< std::string, std::string >ordermap;
32  std::vector< class varInst* > *orderlist;
33 //removes a ship from the flightgroup below
34  void Decrement( Unit *trashed )
35  {
36  nr_ships--;
37  nr_ships_left--;
38  if (leader.GetUnit() == trashed)
39  leader.SetUnit( NULL );
40  }
41  static Flightgroup*newFlightgroup( const std::string&name,
42  const std::string&type,
43  const std::string&faction,
44  const std::string&order,
45  int num_ships,
46  int num_waves,
47  const std::string&texname,
48  const std::string&alphname,
49  class Mission*mis );
50  Flightgroup() : pos( 0, 0, 0 )
51  {
52  //betterto have a flightgroup constructor
53  //fprintf (stderr,"constructing FG 0x%x\n",this);
54  orderlist = NULL;
56  leader_decision = -1;
57  squadLogo = NULL;
58  }
59  void Init( Flightgroup *fg,
60  const std::string &name,
61  const std::string &type,
62  const std::string &faction,
63  const std::string &order,
64  int num_ships,
65  int num_waves,
66  Mission *mis )
67  {
68  bool new_fg = false;
69  if (fg == NULL) {
70  new_fg = true;
71  this->name = name;
72  this->directive = "b";
73  this->faction = faction;
74  } else {
75  new_fg = (this->nr_waves_left == 0 && this->nr_ships_left == 0);
76  }
77  if (new_fg) {
78  this->nr_waves_left = num_waves-1;
79  mission->AddFlightgroup( this );
80  }
81  this->target = NULL;
82  this->leader = NULL;
83  this->ainame = order;
84  this->type = type;
85  this->nr_ships += num_ships;
86  this->nr_ships_left += num_ships;
87  }
89  {
90  *this = other;
91  }
93  ~Flightgroup();
94 };
95 
97 {
98 public:
100  int terrain_nr; //which terrain to use. -1 for normal unit -2 for mission ter
102  int waves, nr_ships; //number of waves, number of ships per wave
103  float rot[3];
105 };
106 
107 #endif
108