vegastrike  0.5.1.r1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
universe_util.h
Go to the documentation of this file.
1 #ifndef _UNIVERSE_UTILGENERIC_H__
4 #define _UNIVERSE_UTILGENERIC_H__
5 #include "cmd/collection.h"
6 #include "gfx/vec.h"
7 #include "networking/const.h"
8 #include "cmd/unit_util.h"
9 
10 #include <string>
11 #include <vector>
12 
13 class Unit;
14 class StarSystem;
15 class Cargo;
16 
17 namespace UniverseUtil
18 {
19 class PythonUnitIter : public un_iter
20 {
21 public: PythonUnitIter() : UnitIterator() {}
22 //PythonUnitIterator (UnitListNode * start):UnitIterator(start){}
23  PythonUnitIter( const UnitCollection::UnitIterator &t ) : UnitIterator( t ) {}
25  Unit * current();
26  inline void advance()
27  {
28  UnitIterator::advance();
29  }
30  void advanceSignificant();
31  void advanceInsignificant();
32  void advancePlanet();
33  void advanceJumppoint();
34  void advanceN( int );
35  void advanceNSignificant( int n );
36  void advanceNInsignificant( int n );
37  void advanceNPlanet( int n );
38  void advanceNJumppoint( int n );
39  inline void preinsert( Unit *unit )
40  {
41  UnitIterator::preinsert( unit );
42  }
43  inline bool isDone()
44  {
45  return UnitIterator::isDone();
46  }
47  inline bool notDone()
48  {
49  return UnitIterator::notDone();
50  }
51  inline void remove()
52  {
53  UnitIterator::remove();
54  }
55  inline class Unit * next()
56  {
57  advance();
58  return current();
59  }
60 };
61 
62 std::string LookupUnitStat( const std::string &unitname, const std::string &faction, const std::string &statname );
63 
64 Unit * GetUnitFromSerial( ObjSerial serial );
65 
67 Unit * GetMasterPartList();
68 
70 
71 void pushSystem( std::string name );
72 bool systemInMemory( std::string name );
73 
75 void popSystem();
76 
78 std::string getSystemFile();
79 
81 std::string getSystemName();
82 
84 PythonUnitIter getUnitList();
85 
86 
88 Unit * getUnit( int index );
89 
91 Unit * getUnitByName( std::string name );
92 
94 Unit * getUnitByPtr( void *ptr, Unit *finder = 0, bool allowslowness = true );
95 Unit * getScratchUnit();
96 void setScratchUnit( Unit* );
97 
98 void precacheUnit( std::string name, std::string faction );
99 QVector getScratchVector();
100 void setScratchVector( QVector );
101 int getNumUnits();
102 void cacheAnimation( std::string anim );
103 
105 Unit * launchJumppoint( std::string name_string,
106  std::string faction_string,
107  std::string type_string,
108  std::string unittype_string,
109  std::string ai_string,
110  int nr_of_ships,
111  int nr_of_waves,
112  QVector pos,
113  std::string squadlogo,
114  std::string destinations );
115 std::string vsConfig( std::string category, std::string option, std::string def );
116 
118 Unit * launch( std::string name_string,
119  std::string type_string,
120  std::string faction_string,
121  std::string unittype,
122  std::string ai_string,
123  int nr_of_ships,
124  int nr_of_waves,
125  QVector pos,
126  std::string sqadlogo );
127 
129 Cargo getRandCargo( int quantity, std::string category );
130 
132 std::string GetAdjacentSystem( std::string str, int which );
133 
135 std::string GetGalaxyProperty( std::string sys, std::string prop );
136 
138 std::vector< std::string > GetJumpPath( std::string from, std::string to );
139 
141 std::string GetGalaxyPropertyDefault( std::string sys, std::string prop, std::string def );
142 
143 std::string GetGalaxyFaction( std::string sys );
144 void SetGalaxyFaction( std::string sys, std::string fac );
145 
147 int GetNumAdjacentSystems( std::string sysname );
148 
150 float GetGameTime();
151 
153 float getStarTime();
154 
156 string getStarDate();
157 
159 void SetTimeCompression();
160 
162 int musicAddList( std::string str );
163 
165 void musicSetSoftVolume( float vol, float latency_override );
166 
168 void musicSetHardVolume( float vol );
169 
171 void musicLayerPlaySong( std::string str, int layer );
172 
174 void musicLayerPlayList( int which, int layer );
175 
177 void musicLayerLoopList( int numloops, int layer );
178 
180 void musicLayerSkip( int layer );
181 
183 void musicLayerStop( int layer );
184 
186 void musicLayerSetSoftVolume( float vol, float latency_override, int layer );
187 
189 void musicLayerSetHardVolume( float vol, int layer );
190 
192 void musicMute( bool stopSound );
193 
195 inline void musicPlaySong( std::string str )
196 {
197  musicLayerPlaySong( str, -1 );
198 }
199 
201 inline void musicPlayList( int which )
202 {
203  musicLayerPlayList( which, -1 );
204 }
205 
207 inline void musicLoopList( int numloops )
208 {
209  musicLayerLoopList( numloops, -1 );
210 }
211 
213 inline void musicSkip()
214 {
215  musicLayerSkip( -1 );
216 }
217 
219 inline void musicStop()
220 {
221  musicLayerStop( -1 );
222 }
223 
225 float GetDifficulty();
226 
228 void SetDifficulty( float diff );
229 
231 void playSound( std::string soundName, QVector loc, Vector speed );
232 
234 void playSoundCockpit( std::string soundName );
235 
237 void playAnimation( std::string aniName, QVector loc, float size );
238 void playAnimationGrow( std::string aniName, QVector loc, float size, float growpercent );
239 
241 void TargetEachOther( std::string fgname, std::string faction, std::string enfgname, std::string enfaction );
242 
244 void StopTargettingEachOther( std::string fgname, std::string faction, std::string enfgname, std::string enfaction );
245 
247 void terminateMission( bool term );
248 
250 Unit * getPlayer();
251 
253 Unit * getPlayerX( int which );
254 unsigned int getCurrentPlayer();
255 
257 int getNumPlayers();
258 
259 //Clears all objectives (used for server-side when it's easy to get inconsistent.
260 void setTargetLabel( std::string label );
261 std::string getTargetLabel();
262 
263 float getRelationModifierInt( int which_cp, int faction );
264 float getRelationModifier( int which_cp, string faction );
265 float getFGRelationModifier( int which_cp, string fg );
266 void adjustRelationModifierInt( int which_cp, int faction, float delta );
267 void adjustRelationModifier( int which_cp, string faction, float delta );
268 void adjustFGRelationModifier( int which_cp, string fg, float delta );
269 
270 void AdjustRelation( std::string myfaction, std::string theirfaction, float factor, float rank );
271 float GetRelation( std::string myfaction, std::string theirfaction );
272 
273 void clearObjectives();
274 //Erases an objective.
275 void eraseObjective( int which );
276 
278 int addObjective( std::string objective );
279 
281 void setObjective( int which, std::string newobjective );
282 
284 void setCompleteness( int which, float completeNess );
285 
287 float getCompleteness( int which );
288 
290 void setOwnerII( int which, Unit *owner );
291 
293 Unit * getOwner( int which );
294 //gets the owner of this mission
295 int getMissionOwner();
296 //sets the owner of this mission to be a particular cockpit
297 void setMissionOwner( int );
298 
300 int numActiveMissions();
301 
303 void IOmessage( int delay, std::string from, std::string to, std::string message );
304 
306 Unit * GetMasterPartList();
307 
309 Unit * GetContrabandList( std::string faction );
310 
312 void SetAutoStatus( int global_auto, int player_auto );
313 void LoadMission( std::string missionname );
314 void LoadMissionScript( std::string scriptcontents );
315 void LoadNamedMissionScript( std::string missiontitle, std::string scriptcontents );
316 QVector SafeEntrancePoint( QVector, float radial_size = -1 );
317 QVector SafeStarSystemEntrancePoint( StarSystem*sts, QVector, float radial_size = -1 );
318 float getPlanetRadiusPercent();
319 
320 void cacheAnimation( std::string anim );
321 
323 Unit * launchJumppoint( std::string name_string,
324  std::string faction_string,
325  std::string type_string,
326  std::string unittype_string,
327  std::string ai_string,
328  int nr_of_ships,
329  int nr_of_waves,
330  QVector pos,
331  std::string squadlogo,
332  std::string destinations );
333 
335 Unit * launch( std::string name_string,
336  std::string type_string,
337  std::string faction_string,
338  std::string unittype,
339  std::string ai_string,
340  int nr_of_ships,
341  int nr_of_waves,
342  QVector pos,
343  std::string sqadlogo );
344 
346 Cargo getRandCargo( int quantity, std::string category );
347 
349 //float GetGameTime();
350 
352 //float getStarTime();
353 
355 void SetTimeCompression();
356 
358 int musicAddList( std::string str );
359 
361 void musicPlaySong( std::string str );
362 
364 void musicPlayList( int which );
365 
367 void musicLoopList( int numloops );
368 
370 void playSound( std::string soundName, QVector loc, Vector speed );
371 
373 void playAnimation( std::string aniName, QVector loc, float size );
374 void playAnimationGrow( std::string aniName, QVector loc, float size, float growpercent );
375 
377 Unit * getPlayer();
378 
380 Unit * getPlayerX( int which );
381 void StopAllSounds( void );
382 unsigned int getCurrentPlayer();
383 
385 int getNumPlayers();
386 unsigned int maxMissions();
387 bool networked();
388 bool isserver();
389 //Forwards this request onto the server if this is a client, or send back to client.
390 void sendCustom( int cp, string cmd, string args, string id );
391 //Executes a python script
392 void receivedCustom( int cp, bool trusted, string cmd, string args, string id );
393 
394 std::string getVariable( std::string section, std::string name, std::string def );
395 std::string getSubVariable( std::string section, std::string subsection, std::string name, std::string def );
396 double timeofday();
397 double sqrt( double );
398 double log( double );
399 double exp( double );
400 double cos( double );
401 double sin( double );
402 double acos( double );
403 double asin( double );
404 double atan( double );
405 double tan( double );
406 void micro_sleep( int n );
407 void addParticle( QVector loc, Vector velocity, Vector color, float size );
408 
409 void ComputeGalaxySerials( std::vector< std::string > &stak );
410 void ComputeSystemSerials( std::string &systempath );
411 
412 std::string getSaveDir();
413 std::string getSaveInfo( const std::string &filename, bool formatForTextbox );
414 std::string getCurrentSaveGame();
415 std::string setCurrentSaveGame( const std::string &newsave );
416 std::string getNewGameSaveName();
417 void loadGame( const std::string &savename );
418 void saveGame( const std::string &savename );
419 
420 //Splash stuff
421 void showSplashScreen( const std::string &filename );
422 void showSplashMessage( const std::string &text );
423 void showSplashProgress( float progress );
424 void hideSplashScreen();
425 bool isSplashScreenShowing();
426 
427 //Defined in gamemenu.cpp for vegastrike, universe_util_server.cpp for vegaserver.
428 void startMenuInterface( bool firsttime, string alert = string() ); //If game fails, bring it back to a common starting point.
429 }
430 
431 #undef activeSys
432 #endif
433