vegastrike  0.5.1.r1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
faction_generic.h
Go to the documentation of this file.
1 #ifndef __FACTIONGENERIC_H
2 #define __FACTIONGENERIC_H
3 #include "config.h"
4 #include <string>
5 #include <boost/shared_ptr.hpp>
6 //#include <gnuhash.h>
7 
8 #include "xml_support.h"
9 
10 class FSM;
11 class Animation;
12 class Unit;
13 class Texture;
14 typedef vsUMap< std::string, float >MapStringFloat;
15 
16 class Faction
17 {
18 public:
27  {
30  {
31  int index;
32  char *name;
33  }
34  stats;
36  float relationship;
37  boost::shared_ptr<FSM> conversation; //a conversation any two factions can have
39  };
40 public:
45  bool citizen;
46  int playlist;
47  float sparkcolor[4];
48  std::vector< faction_stuff >faction;
50  std::string logoName;
51  std::string logoAlphaName;
53  std::string secondaryLogoName;
56  Texture *logo;
57 //if the squadron doens't; have its own particular logo
58  Texture *secondaryLogo;
60  char *factionname;
61  struct comm_face_t
62  {
63  std::vector< class Animation* >animations;
64  enum CHOICE {CNO, CYES, CEITHER};
68  , base( CEITHER ) {}
69  };
70  std::vector< comm_face_t > comm_faces;
71  std::vector< boost::shared_ptr<Animation> >explosion;
72  std::vector< std::string > explosion_name;
73  std::vector< unsigned char > comm_face_sex;
75  // This should be a std::auto_ptr, but then "cmd/unit.h" has to be included
76  boost::shared_ptr<Unit> contraband;
78  static void ParseAllAllies( /*Universe * thisuni*/ );
79  void ParseAllies( /*Universe * thisuni,*/ unsigned int whichfaction );
80  static void LoadXML( const char *factionfile, char *xmlbuffer = NULL, int buflength = 0 );
81  static void beginElement( void *userData, const XML_Char *name, const XML_Char **atts );
82  static void endElement( void *userData, const XML_Char *name );
84  {
85  playlist = -1;
86  citizen = false;
87  logo = secondaryLogo = NULL;
88  factionname = NULL;
89  sparkcolor[0] = .5;
90  sparkcolor[1] = .5;
91  sparkcolor[2] = 1;
92  sparkcolor[3] = 1;
93  }
94  ~Faction(); //destructor
95 };
96 
97 extern std::vector< boost::shared_ptr<Faction> >factions; //the factions
98 
99 namespace FactionUtil
100 {
101 extern int upgradefac;
102 extern int neutralfac;
103 extern int planetfac;
104 std::vector< class Animation* > * GetRandCommAnimation( int faction, Unit *unit, unsigned char &sex );
105 void SerializeFaction( FILE *file );
106 std::string SerializeFaction();
107 void LoadSerializedFaction( FILE *file );
108 void LoadSerializedFaction( char* &buf );
109 int numnums( const char *str );
111 //int GetFaction (const char *factionname);
112 int GetNumAnimation( int faction );
113 class Unit * GetContraband( int faction );
114 
115 const char * GetFaction( int faction );
116 
122 int GetFactionIndex( const std::string& name );
123 
124 inline int GetUpgradeFaction()
125 {
126  return upgradefac;
127 }
128 
129 inline int GetNeutralFaction()
130 {
131  return neutralfac;
132 }
133 
134 inline int GetPlanetFaction()
135 {
136  return planetfac;
137 }
138 
139 inline float GetIntRelation( const int myfaction, const int theirfaction )
140 {
141  return factions[myfaction]->faction[theirfaction].relationship;
142 }
143 
144 //float GetRelation (std::string myfaction, std::string theirfaction);
145 std::string GetFactionName( int index );
146 bool isCitizenInt( int index );
147 bool isCitizen( const std::string& name );
148 void AdjustIntRelation( const int myfaction, const int theirfaction, const float factor, const float rank );
149 //void AdjustRelation(std::string myfaction,std::string theirfaction, float factor, float rank);
150 int GetPlaylist( const int myfaction );
151 const float * GetSparkColor( const int myfaction );
152 unsigned int GetNumFactions();
153 //Returns a conversation that a myfaction might have with a theirfaction
154 FSM * GetConversation( const int myfaction, const int theirfaction );
155 Texture * getForceLogo( int faction );
156 Texture * getSquadLogo( int faction );
157 
158 Animation * createAnimation( const char *anim );
159 Texture * createTexture( const char *tex, const char *tmp, bool force = false );
160 Texture * createTexture( const char *tex, bool force = false );
161 std::vector< class Animation* > * GetAnimation( int faction, int n, unsigned char &sex );
162 Animation * GetRandExplosionAnimation( int whichfaction, std::string &which );
163 void LoadFactionPlaylists();
165 void LoadContrabandLists();
166 };
167 
168 #endif
169