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
UniverseUtil Namespace Reference

Classes

class  PythonUnitIter
 

Functions

void startMenuInterface (bool firstTime, string error)
 
UnitWrapper newGetPlayer ()
 
void setOwner (int obj, UnitWrapper un)
 
void playVictoryTune ()
 
int musicAddList (string str)
 
void musicLayerSkip (int layer)
 this skips the current music track, at a specific layer (and goes to the next in the currently playing list) More...
 
void musicLayerStop (int layer)
 this stops the music currently playing at a specific layer - with a nice fadeout More...
 
void musicLayerPlaySong (string str, int layer)
 
void musicLayerPlayList (int which, int layer)
 this plays msuci from a given list, at a specific layer (where the int is what was returned by musicAddList) More...
 
void musicLayerLoopList (int numloops, int layer)
 this plays msuci from a given list, at a specific layer (where the int is what was returned by musicAddList) More...
 
void musicLayerSetSoftVolume (float vol, float latency_override, int layer)
 sets the software volume, with smooth transitions (latency_override==-1 uses default transition time) More...
 
void musicLayerSetHardVolume (float vol, int layer)
 sets the hardware volume, does not support transitions of any kind. More...
 
void musicSetSoftVolume (float vol, float latency_override)
 sets the software volume, with smooth transitions (latency_override==-1 uses default transition time) More...
 
void musicSetHardVolume (float vol)
 sets the hardware volume, does not support transitions of any kind. More...
 
void musicMute (bool stopSound)
 this mutes sound - or unmutes it More...
 
void playSound (string soundName, QVector loc, Vector speed)
 
void playSoundCockpit (string soundName)
 
void StopAllSounds (void)
 
void cacheAnimation (string aniName)
 
void playAnimation (string aniName, QVector loc, float size)
 
void playAnimationGrow (string aniName, QVector loc, float size, float growpercent)
 
unsigned int getCurrentPlayer ()
 
unsigned int maxMissions ()
 
void addParticle (QVector loc, Vector velocity, Vector color, float size)
 
void loadGame (const string &savename)
 
void saveGame (const string &savename)
 
void showSplashScreen (const string &filename)
 
void showSplashMessage (const string &text)
 
void showSplashProgress (float progress)
 
void hideSplashScreen ()
 
bool isSplashScreenShowing ()
 
void sendCustom (int cp, string cmd, string args, string id)
 
std::string LookupUnitStat (const std::string &unitname, const std::string &faction, const std::string &statname)
 
UnitGetUnitFromSerial (ObjSerial serial)
 
UnitGetMasterPartList ()
 this gets a unit with 1 of each cargo type in it More...
 
void pushSystem (std::string name)
 this function sets the "current" system to be "name" where name may be something like "Sol/Sol" or "Crucible/Cephid_17" this function may take some time if the system has not been loaded before More...
 
bool systemInMemory (std::string name)
 
void popSystem ()
 this function restores the active system.... there must be an equal number of pushSystems ans popSystems or else Vega Strike may behave unpredictably More...
 
std::string getSystemFile ()
 This function gets the current system's official name. More...
 
std::string getSystemName ()
 this function gets the current system's nickname (not useful) More...
 
PythonUnitIter getUnitList ()
 this function gets an iterator into the units in the current system... do NOT keep an iterator across a frame–it may get deleted! More...
 
UnitgetUnit (int index)
 This function gets a unit given a number (how many iterations to go down in the iterator) More...
 
UnitgetUnitByName (std::string name)
 This function gets a unit given a name. More...
 
UnitgetUnitByPtr (void *ptr, Unit *finder=0, bool allowslowness=true)
 This function gets a unit given an unreferenceable pointer to it - much faster if finder is provided. More...
 
UnitgetScratchUnit ()
 
void setScratchUnit (Unit *)
 
void precacheUnit (std::string name, std::string faction)
 
QVector getScratchVector ()
 
void setScratchVector (QVector)
 
int getNumUnits ()
 
void cacheAnimation (std::string anim)
 
UnitlaunchJumppoint (std::string name_string, std::string faction_string, std::string type_string, std::string unittype_string, std::string ai_string, int nr_of_ships, int nr_of_waves, QVector pos, std::string squadlogo, std::string destinations)
 this function launches a wormhole or a jump point. More...
 
std::string vsConfig (std::string category, std::string option, std::string def)
 
Unitlaunch (std::string name_string, std::string type_string, std::string faction_string, std::string unittype, std::string ai_string, int nr_of_ships, int nr_of_waves, QVector pos, std::string sqadlogo)
 this function launches a normal fighter the name is the flightgroup name, the type is the ship type, the faction is who it belongs to, the unittype is usually "unit" unless you want to make asteroids or nebulae or jump points or planets. the aistring is either a python filename or "default" the nr of ships is the number of ships to be launched with this group, the number of waves is num reinforcements... the position is a tuple (x,y,z) where they appear and the squadlogo is a squadron image...you can leave this the empty string '' for the default squadron logo. More...
 
Cargo getRandCargo (int quantity, std::string category)
 this gets a random cargo type (useful for cargo missions) from either any category if category is '' or else from a specific category 'Contraband' comes to mind! More...
 
std::string GetAdjacentSystem (std::string str, int which)
 this gets a string which has in it a space delimited list of neighmoring systems More...
 
std::string GetGalaxyProperty (std::string sys, std::string prop)
 this gets a specific property of this system as found in universe/milky_way.xml More...
 
std::vector< std::string > GetJumpPath (std::string from, std::string to)
 get the shortest path between systems as found in universe/milky_way.xml More...
 
std::string GetGalaxyPropertyDefault (std::string sys, std::string prop, std::string def)
 this gets a specific property of this system as found in universe/milky_way.xml and returns a default value if not found More...
 
std::string GetGalaxyFaction (std::string sys)
 
void SetGalaxyFaction (std::string sys, std::string fac)
 
int GetNumAdjacentSystems (std::string sysname)
 this gets the number of systems adjacent to the sysname More...
 
float GetGameTime ()
 this gets the current game time since last start in seconds More...
 
float getStarTime ()
 this gets the current absolute startime in seconds More...
 
string getStarDate ()
 this gets the current stardate string More...
 
void SetTimeCompression ()
 this sets the time compresison value to zero More...
 
int musicAddList (std::string str)
 this adds a playlist to the music and may be triggered with an int More...
 
void musicLayerPlaySong (std::string str, int layer)
 this plays a specific song, at a specific layer More...
 
void musicPlaySong (std::string str)
 this plays a specific song, through the crossfader construct More...
 
void musicPlayList (int which)
 this plays msuci from a given list (where the int is what was returned by musicAddList) More...
 
void musicLoopList (int numloops)
 this plays msuci from a given list (where the int is what was returned by musicAddList) More...
 
void musicSkip ()
 this skips the current music track (and goes to the next in the currently playing list) More...
 
void musicStop ()
 this stops the music currently playing - with a nice fadeout More...
 
float GetDifficulty ()
 this gets the difficutly of the game... ranges between 0 and 1... many missions depend on it never going past .99 unless it's always at one. More...
 
void SetDifficulty (float diff)
 this sets the difficulty More...
 
void playSound (std::string soundName, QVector loc, Vector speed)
 this plays a sound at a location...if the sound has dual channels it will play in the center More...
 
void playSoundCockpit (std::string soundName)
 this plays a sound at full volume in the cockpit More...
 
void playAnimation (std::string aniName, QVector loc, float size)
 this plays an image (explosion or warp animation) at a location More...
 
void playAnimationGrow (std::string aniName, QVector loc, float size, float growpercent)
 
void TargetEachOther (std::string fgname, std::string faction, std::string enfgname, std::string enfaction)
 tells the respective flightgroups in this system to start shooting at each other More...
 
void StopTargettingEachOther (std::string fgname, std::string faction, std::string enfgname, std::string enfaction)
 tells the respective flightgroups in this system to stop killing each other urgently...they may still attack–just not warping and stuff More...
 
void terminateMission (bool term)
 this ends the mission with either success or failure More...
 
UnitgetPlayer ()
 this gets the player belonging to this mission More...
 
UnitgetPlayerX (int which)
 this gets a player number (if in splitscreen mode) More...
 
int getNumPlayers ()
 this gets the number of active players More...
 
void setTargetLabel (std::string label)
 
std::string getTargetLabel ()
 
float getRelationModifierInt (int which_cp, int faction)
 
float getRelationModifier (int which_cp, string faction)
 
float getFGRelationModifier (int which_cp, string fg)
 
void adjustRelationModifierInt (int which_cp, int faction, float delta)
 
void adjustRelationModifier (int which_cp, string faction, float delta)
 
void adjustFGRelationModifier (int which_cp, string fg, float delta)
 
void AdjustRelation (std::string myfaction, std::string theirfaction, float factor, float rank)
 
float GetRelation (std::string myfaction, std::string theirfaction)
 
void clearObjectives ()
 
void eraseObjective (int which)
 
int addObjective (std::string objective)
 this adds an objective for the cockpit to view ("go here and do this) More...
 
void setObjective (int which, std::string newobjective)
 this sets the objective's completeness (the int was returned by add objective) More...
 
void setCompleteness (int which, float completeNess)
 this sets the completeness of a particular objective... chanigng the color onscreen More...
 
float getCompleteness (int which)
 this gets that completeness More...
 
void setOwnerII (int which, Unit *owner)
 this sets the owner of a completeness More...
 
UnitgetOwner (int which)
 this gets an owner of a completeness (NULL means all players can see this objective) More...
 
int getMissionOwner ()
 
void setMissionOwner (int)
 
int numActiveMissions ()
 returns number missions running to tweak difficulty More...
 
void IOmessage (int delay, std::string from, std::string to, std::string message)
 this sends an IO message... I'm not sure if delay currently works, but from, to and message do :-) ... if you want to send to the bar do "bar" as the to string... if you want to make news for the news room specify "news" More...
 
UnitGetContrabandList (std::string faction)
 this gets a unit with a faction's contraband list... may be null (check with isNull) More...
 
void SetAutoStatus (int global_auto, int player_auto)
 this sets whether or not a player may autopilot. Normally they are both 0 and the autopiloting is allowed based on if enemies are near... if you pass in 1 then autopilot will be allowed no matter who is near... if you set -1 then autopilot is never allowed. global affects all players... player just affects the player who accepted the mission. More...
 
void LoadMission (std::string missionname)
 
void LoadMissionScript (std::string scriptcontents)
 
void LoadNamedMissionScript (std::string missiontitle, std::string scriptcontents)
 
QVector SafeEntrancePoint (QVector, float radial_size=-1)
 
QVector SafeStarSystemEntrancePoint (StarSystem *sts, QVector, float radial_size=-1)
 
float getPlanetRadiusPercent ()
 
bool networked ()
 
bool isserver ()
 
void receivedCustom (int cp, bool trusted, string cmd, string args, string id)
 
std::string getVariable (std::string section, std::string name, std::string def)
 
std::string getSubVariable (std::string section, std::string subsection, std::string name, std::string def)
 
double timeofday ()
 
double sqrt (double)
 
double log (double)
 
double exp (double)
 
double cos (double)
 
double sin (double)
 
double acos (double)
 
double asin (double)
 
double atan (double)
 
double tan (double)
 
void micro_sleep (int n)
 
void ComputeGalaxySerials (std::vector< std::string > &stak)
 
void ComputeSystemSerials (std::string &systempath)
 
std::string getSaveDir ()
 
std::string getSaveInfo (const std::string &filename, bool formatForTextbox)
 
std::string getCurrentSaveGame ()
 
std::string setCurrentSaveGame (const std::string &newsave)
 
std::string getNewGameSaveName ()
 
void loadGame (const std::string &savename)
 
void saveGame (const std::string &savename)
 
void showSplashScreen (const std::string &filename)
 
void showSplashMessage (const std::string &text)
 
UnitlaunchJumppoint (string name_string, string faction_string, string type_string, string unittype_string, string ai_string, int nr_of_ships, int nr_of_waves, QVector pos, string squadlogo, string destinations)
 
Cargo getRandCargo (int quantity, string category)
 
void pushSystem (string name)
 
void TargetEachOther (string fgname, string faction, string enfgname, string enfaction)
 tells the respective flightgroups in this system to start shooting at each other More...
 
void StopTargettingEachOther (string fgname, string faction, string enfgname, string enfaction)
 tells the respective flightgroups in this system to stop killing each other urgently...they may still attack–just not warping and stuff More...
 
bool systemInMemory (string nam)
 
string GetAdjacentSystem (string str, int which)
 
string GetGalaxyProperty (string sys, string prop)
 
string GetGalaxyPropertyDefault (string sys, string prop, string def)
 
string GetGalaxyFaction (string sys)
 
void SetGalaxyFaction (string sys, string fac)
 
int GetNumAdjacentSystems (string sysname)
 
static string dontBlankOut (string objective)
 
int addObjective (string objective)
 
void setObjective (int which, string newobjective)
 
void IOmessage (int delay, string from, string to, string message)
 
UnitGetContrabandList (string faction)
 
void LoadMission (string missionname)
 
void LoadNamedMissionScript (string title, string missionscript)
 
void LoadMissionScript (string missionscript)
 
Unitlaunch (string name_string, string type_string, string faction_string, string unittype, string ai_string, int nr_of_ships, int nr_of_waves, QVector pos, string sqadlogo)
 
string LookupUnitStat (const string &unitname, const string &faction, const string &statname)
 
void precacheUnit (string type_string, string faction_string)
 
void securepythonstr (string &message)
 
static std::string simplePrettySystem (std::string system)
 
static std::string simplePrettyShip (std::string ship)
 
string setCurrentSaveGame (const string &newsave)
 
vector< string > GetJumpPath (string from, string to)
 

Variables

static UnitContainer scratch_unit
 
static QVector scratch_vector
 
static std::vector< Unit * > cachedUnits
 

Function Documentation

int UniverseUtil::addObjective ( std::string  objective)

this adds an objective for the cockpit to view ("go here and do this)

int UniverseUtil::addObjective ( string  objective)

Definition at line 550 of file universe_util_generic.cpp.

References dontBlankOut(), mission, Subcmd::Objective, Mission::objectives, Mission::player_num, NetServer::sendSaveData(), SERVER, Subcmd::SetValue, and VSServer.

551 {
552  float status = 0;
553  if (SERVER)
555  mission->objectives.size(), NULL, mission, &objective, &status );
556  mission->objectives.push_back( Mission::Objective( status, dontBlankOut( objective ) ) );
557  return mission->objectives.size()-1;
558 }
void UniverseUtil::addParticle ( QVector  loc,
Vector  velocity,
Vector  color,
float  size 
)

Definition at line 135 of file universe_util.cpp.

References ParticleTrail::AddParticle(), ParticlePoint::col, ParticlePoint::loc, and particleTrail.

136 {
137  ParticlePoint p;
138  p.loc = loc;
139  p.col = color;
140  particleTrail.AddParticle( p, velocity, size );
141 }
void UniverseUtil::adjustFGRelationModifier ( int  which_cp,
string  fg,
float  delta 
)

Definition at line 405 of file universe_util_generic.cpp.

References getSaveData(), getSaveDataLength(), pushSaveData(), and putSaveData().

Referenced by CommunicatingAI::AdjustRelationTo(), and Pilot::DoHit().

406 {
407  fg = "FG_Relation_"+fg;
408  if (getSaveDataLength( which_cp, fg ) == 0) {
409  pushSaveData( which_cp, fg, delta );
410  return;
411  }
412  putSaveData( which_cp, fg, 0, getSaveData( which_cp, fg, 0 )+delta );
413 }
void UniverseUtil::AdjustRelation ( std::string  myfaction,
std::string  theirfaction,
float  factor,
float  rank 
)

Definition at line 355 of file universe_util_generic.cpp.

References _Universe, Universe::AccessCockpit(), adjustRelationModifierInt(), Universe::CurrentCockpit(), Unit::faction, FactionUtil::GetFactionIndex(), and Cockpit::GetParent().

356 {
357  int myfac = FactionUtil::GetFactionIndex( myfaction );
358  int theirfac = FactionUtil::GetFactionIndex( theirfaction );
359  float realfactor = factor*rank;
360  int cp = _Universe->CurrentCockpit();
362  if (!un) return;
363  if (myfac == theirfac)
364  return;
365  else if (myfac == un->faction)
366  return adjustRelationModifierInt( cp, theirfac, realfactor );
367  else if (theirfac == un->faction)
368  return adjustRelationModifierInt( cp, myfac, realfactor );
369 }
void UniverseUtil::adjustRelationModifier ( int  which_cp,
string  faction,
float  delta 
)

Definition at line 401 of file universe_util_generic.cpp.

References adjustRelationModifierInt(), and FactionUtil::GetFactionIndex().

Referenced by Arrested().

402 {
404 }
void UniverseUtil::adjustRelationModifierInt ( int  which_cp,
int  faction,
float  delta 
)

Definition at line 391 of file universe_util_generic.cpp.

References FactionUtil::GetFactionName(), getSaveData(), getSaveDataLength(), pushSaveData(), and putSaveData().

Referenced by AdjustRelation(), adjustRelationModifier(), CommunicatingAI::AdjustRelationTo(), AllUnitsCloseAndEngage(), Arrested(), Pilot::DoHit(), and ScoreKill().

392 {
393  if (delta > 1) delta = 1;
394  string saveVar = "Relation_to_"+FactionUtil::GetFactionName( faction );
395  if (getSaveDataLength( which_cp, saveVar ) == 0)
396  pushSaveData( which_cp, saveVar, delta );
397  float val = getSaveData( which_cp, saveVar, 0 )+delta;
398  if (val > 1) val = 1;
399  return putSaveData( which_cp, saveVar, 0, val );
400 }
double UniverseUtil::asin ( double  x)
double UniverseUtil::atan ( double  x)
void UniverseUtil::cacheAnimation ( std::string  anim)
void UniverseUtil::cacheAnimation ( string  aniName)

Definition at line 114 of file universe_util.cpp.

References anis.

Referenced by Unit::AutoPilotToErrorMessage(), and Unit::ResolveForces().

115 {
116  static vector< Animation* >anis;
117  anis.push_back( new Animation( aniName.c_str() ) );
118 }
void UniverseUtil::clearObjectives ( )

Definition at line 601 of file universe_util_generic.cpp.

References Subcmd::EraseValue, mission, Subcmd::Objective, Mission::objectives, Mission::player_num, NetServer::sendSaveData(), SERVER, and VSServer.

602 {
603  if ( mission->objectives.size() ) {
604  mission->objectives.clear();
605  if (SERVER)
607  -1, NULL, mission, NULL, NULL );
608  }
609 }
void UniverseUtil::ComputeGalaxySerials ( std::vector< std::string > &  stak)

Definition at line 931 of file universe_util_generic.cpp.

References ComputeSystemSerials().

932 {
933  cout<<"Going through "<<stak.size()<<" sectors"<<endl;
934  cout<<"Generating random serial numbers :"<<endl;
935  for (; !stak.empty();) {
936  string sys( stak.back()+".system" );
937  stak.pop_back();
938  ComputeSystemSerials( sys );
939  }
940  cout<<"Computing done."<<endl;
941 }
void UniverseUtil::ComputeSystemSerials ( std::string &  systempath)

Definition at line 857 of file universe_util_generic.cpp.

References NetServer::addSystem(), f, getUniqueSerial(), VSFileSystem::Ok, SERVER, VSFileSystem::SystemFile, XMLSupport::tostring5(), VSExit(), and VSServer.

Referenced by ComputeGalaxySerials(), and Universe::Generate1().

858 {
859  using namespace VSFileSystem;
860  //Read the file
861  VSFile f;
862  VSError err = f.OpenReadOnly( systempath, SystemFile );
863  if (err <= Ok) {
864  cout<<"\t\tcomputing serials for "<<systempath<<"...";
865  std::string system = f.ReadFull();
866 
867  //Now looking for "<planet ", "<Planet ", "<PLANET ", "<unit ", "<Unit ", "<UNIT ", same for nebulas
868  std::vector< std::string >search_patterns;
869 
870  bool newserials = true;
871  if (system.find( "serial=", 0 ) != std::string::npos) {
872  newserials = false;
873  cout<<"Found serial in system file : replacing serials..."<<endl;
874  } else {
875  cout<<"Found no serial in system file : generating..."<<endl;
876  }
877  search_patterns.push_back( "<planet " );
878  search_patterns.push_back( "<Planet " );
879  search_patterns.push_back( "<PLANET " );
880  search_patterns.push_back( "<unit " );
881  search_patterns.push_back( "<Unit " );
882  search_patterns.push_back( "<UNIT " );
883  search_patterns.push_back( "<nebula " );
884  search_patterns.push_back( "<Nebula " );
885  search_patterns.push_back( "<NEBULA " );
886  search_patterns.push_back( "<jump " );
887  search_patterns.push_back( "<Jump " );
888  search_patterns.push_back( "<JUMP " );
889  for (std::vector< std::string >::iterator ti = search_patterns.begin(); ti != search_patterns.end(); ++ti) {
890  std::string search( (*ti) );
891  std::string::size_type search_length = (*ti).length();
892  std::string::size_type curpos = 0;
893  int nboc = 0;
894  while ( ( curpos = system.find( search, curpos ) ) != std::string::npos ) {
895  ObjSerial new_serial = getUniqueSerial();
896  std::string serial_str( (*ti)+"serial=\""+XMLSupport::tostring5( new_serial )+"\" " );
897  //If there are already serial in the file we replace that kind of string : <planet serial="XXXXX"
898  //of length search_length + 14 (length of serial="XXXXX")
899  if (newserials)
900  system.replace( curpos, search_length, serial_str );
901  else
902  system.replace( curpos, search_length+15, serial_str );
903  ++nboc;
904  curpos += search_length;
905  }
906  cerr<<"\t\tFound "<<nboc<<" occurences of "<<search<<endl;
907  }
908  //Add the system xml string to the server
909  if (SERVER) VSServer->addSystem( systempath, system );
910  //Overwrite the system files with the buffer containing serials
911  f.Close();
912  //Should generate the modified system file in homedir
913  err = f.OpenCreateWrite( systempath, SystemFile );
914  if (err > Ok) {
915  cerr<<"!!! ERROR : opening "<<systempath<<" for writing"<<endl;
916  VSExit( 1 );
917  }
918  if ( f.Write( system ) != system.length() ) {
919  cerr<<"!!! ERROR : writing system file"<<endl;
920  VSExit( 1 );
921  }
922  f.Close();
923 
924  cout<<" OK !"<<endl;
925  } else {
926  cerr<<"ERROR cannot open system file : "<<systempath<<endl;
927  VSExit( 1 );
928  }
929 }
static string UniverseUtil::dontBlankOut ( string  objective)
static

Definition at line 540 of file universe_util_generic.cpp.

Referenced by addObjective(), and setObjective().

541 {
542  while (1) {
543  std::string::size_type where = objective.find( ".blank" );
544  if (where != string::npos)
545  objective = objective.substr( 0, where )+objective.substr( where+strlen( ".blank" ) );
546  else return objective;
547  }
548  return objective;
549 }
void UniverseUtil::eraseObjective ( int  which)

Definition at line 592 of file universe_util_generic.cpp.

References Subcmd::EraseValue, mission, Subcmd::Objective, Mission::objectives, Mission::player_num, NetServer::sendSaveData(), SERVER, and VSServer.

593 {
594  if (which < (int) mission->objectives.size() && which >= 0) {
595  if (SERVER)
597  which, NULL, mission, NULL, NULL );
598  mission->objectives.erase( mission->objectives.begin()+which );
599  }
600 }
double UniverseUtil::exp ( double  x)
std::string UniverseUtil::GetAdjacentSystem ( std::string  str,
int  which 
)

this gets a string which has in it a space delimited list of neighmoring systems

Referenced by NavigationSystem::CachedSystemIterator::init(), NavigationSystem::SystemIterator::operator++(), and Cockpit::visitSystem().

string UniverseUtil::GetAdjacentSystem ( string  str,
int  which 
)

Definition at line 489 of file universe_util_generic.cpp.

References _Universe, and Universe::getAdjacentStarSystems().

490 {
491  return _Universe->getAdjacentStarSystems( str )[which];
492 }
float UniverseUtil::getCompleteness ( int  which)

this gets that completeness

Definition at line 577 of file universe_util_generic.cpp.

References mission, and Mission::objectives.

578 {
579  if (which < (int) mission->objectives.size() && which >= 0)
580  return mission->objectives[which].completeness;
581  else
582  return 0;
583 }
Unit* UniverseUtil::GetContrabandList ( std::string  faction)

this gets a unit with a faction's contraband list... may be null (check with isNull)

Unit* UniverseUtil::GetContrabandList ( string  faction)
unsigned int UniverseUtil::getCurrentPlayer ( )
string UniverseUtil::getCurrentSaveGame ( )

Definition at line 1035 of file universe_util_generic.cpp.

References GetCurrentSaveGame().

1036 {
1037  return GetCurrentSaveGame();
1038 }
float UniverseUtil::GetDifficulty ( )

this gets the difficutly of the game... ranges between 0 and 1... many missions depend on it never going past .99 unless it's always at one.

Definition at line 525 of file universe_util_generic.cpp.

References game_data_t::difficulty, and g_game.

526 {
527  return g_game.difficulty;
528 }
float UniverseUtil::getFGRelationModifier ( int  which_cp,
string  fg 
)

Definition at line 384 of file universe_util_generic.cpp.

References getSaveData(), and getSaveDataLength().

Referenced by Pilot::getAnger().

385 {
386  fg = "FG_Relation_"+fg;
387  if (getSaveDataLength( which_cp, fg ) == 0)
388  return 0.;
389  return getSaveData( which_cp, fg, 0 );
390 }
string UniverseUtil::GetGalaxyFaction ( string  sys)

Definition at line 503 of file universe_util_generic.cpp.

References _Universe, Universe::AccessCockpit(), DEFAULT_FACTION_SAVENAME, Universe::getGalaxyProperty(), SaveGame::getMissionStringData(), and Cockpit::savegame.

504 {
505  string fac = _Universe->getGalaxyProperty( sys, "faction" );
506  vector< std::string > *ans =
508  if ( ans->size() )
509  fac = (*ans)[0];
510  return fac;
511 }
std::string UniverseUtil::GetGalaxyProperty ( std::string  sys,
std::string  prop 
)

this gets a specific property of this system as found in universe/milky_way.xml

string UniverseUtil::GetGalaxyProperty ( string  sys,
string  prop 
)

Definition at line 493 of file universe_util_generic.cpp.

References _Universe, and Universe::getGalaxyProperty().

494 {
495  return _Universe->getGalaxyProperty( sys, prop );
496 }
std::string UniverseUtil::GetGalaxyPropertyDefault ( std::string  sys,
std::string  prop,
std::string  def 
)

this gets a specific property of this system as found in universe/milky_way.xml and returns a default value if not found

string UniverseUtil::GetGalaxyPropertyDefault ( string  sys,
string  prop,
string  def 
)

Definition at line 497 of file universe_util_generic.cpp.

References _Universe, and Universe::getGalaxyPropertyDefault().

498 {
499  return _Universe->getGalaxyPropertyDefault( sys, prop, def );
500 }
std::vector< std::string > UniverseUtil::GetJumpPath ( std::string  from,
std::string  to 
)

get the shortest path between systems as found in universe/milky_way.xml

vector< string > UniverseUtil::GetJumpPath ( string  from,
string  to 
)

Definition at line 1051 of file universe_util_generic.cpp.

References _Universe, and Universe::getJumpPath().

1052 {
1053  vector< string > path;
1054  _Universe->getJumpPath(from, to, path);
1055  return path;
1056 }
Unit * UniverseUtil::GetMasterPartList ( )

this gets a unit with 1 of each cargo type in it

Definition at line 242 of file universe_util_generic.cpp.

References UnitFactory::getMasterPartList().

Referenced by buyShip(), Enslave(), Unit::ForceDock(), and sellShip().

243 {
245 }
int UniverseUtil::getMissionOwner ( )

Definition at line 419 of file universe_util_generic.cpp.

References mission, and Mission::player_num.

420 {
421  return mission->player_num;
422 }
string UniverseUtil::getNewGameSaveName ( )

Definition at line 1045 of file universe_util_generic.cpp.

Referenced by BaseComputer::actionNewGame().

1046 {
1047  static string ngsn( "New_Game" );
1048  return ngsn;
1049 }
int UniverseUtil::GetNumAdjacentSystems ( std::string  sysname)

this gets the number of systems adjacent to the sysname

Referenced by NavigationSystem::CachedSystemIterator::init(), NavigationSystem::SystemIterator::operator++(), and Cockpit::visitSystem().

int UniverseUtil::GetNumAdjacentSystems ( string  sysname)

Definition at line 521 of file universe_util_generic.cpp.

References _Universe, and Universe::getAdjacentStarSystems().

522 {
523  return _Universe->getAdjacentStarSystems( sysname ).size();
524 }
int UniverseUtil::getNumPlayers ( )

this gets the number of active players

Definition at line 790 of file universe_util_generic.cpp.

References _Universe, and Universe::numPlayers().

Referenced by getPlayerX().

791 {
792  return _Universe->numPlayers();
793 }
int UniverseUtil::getNumUnits ( )

Definition at line 464 of file universe_util_generic.cpp.

References activeSys, UnitCollection::UnitIterator::advance(), and UnitCollection::UnitIterator::current().

465 {
466 #ifdef USE_STL_COLLECTION
467  return activeSys->getUnitList().size();
468 
469 #else
470  //Implentation-safe getNumUnits().
471  int count = 0;
472  un_iter iter = activeSys->getUnitList().createIterator();
473  while ( iter.current() ) {
474  iter.advance();
475  count++;
476  }
477  return count;
478 #endif
479 }
Unit * UniverseUtil::getOwner ( int  which)

this gets an owner of a completeness (NULL means all players can see this objective)

Definition at line 615 of file universe_util_generic.cpp.

References mission, and Mission::objectives.

616 {
617  if ( which < (int) mission->objectives.size() )
618  return mission->objectives[which].getOwner();
619  else
620  return 0;
621 }
Unit * UniverseUtil::getPlayer ( )

this gets the player belonging to this mission

Definition at line 752 of file universe_util_generic.cpp.

References _Universe, Universe::AccessCockpit(), and Cockpit::GetParent().

Referenced by BaseUtil::LoadBaseInterface(), newGetPlayer(), and ShipCommands::setkps().

753 {
754  return _Universe->AccessCockpit()->GetParent();
755 }
Unit * UniverseUtil::getPlayerX ( int  which)

this gets a player number (if in splitscreen mode)

Definition at line 794 of file universe_util_generic.cpp.

References _Universe, Universe::AccessCockpit(), getNumPlayers(), and Cockpit::GetParent().

Referenced by drawlistitem(), NavigationSystem::DrawMission(), NavigationSystem::DrawSystem(), and BaseComputer::showPlayerInfo().

795 {
796  if ( which >= getNumPlayers() )
797  return NULL;
798  return _Universe->AccessCockpit( which )->GetParent();
799 }
Cargo UniverseUtil::getRandCargo ( int  quantity,
std::string  category 
)

this gets a random cargo type (useful for cargo missions) from either any category if category is '' or else from a specific category 'Contraband' comes to mind!

Cargo UniverseUtil::getRandCargo ( int  quantity,
string  category 
)

Definition at line 191 of file universe_util_generic.cpp.

References Unit::GetCargo(), Cargo::GetContent(), Unit::GetSortedCargoCat(), GetUnitMasterPartList(), i, max(), Unit::numCargo(), and Cargo::quantity.

192 {
193  Cargo *ret = NULL;
194  Unit *mpl = &GetUnitMasterPartList();
195  unsigned int max = mpl->numCargo();
196  if ( !category.empty() ) {
197  size_t Begin, End;
198  mpl->GetSortedCargoCat( category, Begin, End );
199  if (Begin < End) {
200  unsigned int i = Begin+( rand()%(End-Begin) );
201  ret = &mpl->GetCargo( i );
202  }
203  } else if ( mpl->numCargo() ) {
204  for (unsigned int i = 0; i < 500; ++i) {
205  ret = &mpl->GetCargo( rand()%max );
206  if (ret->GetContent().find( "mission" ) == string::npos)
207  break;
208  }
209  }
210  if (ret) {
211  Cargo tempret = *ret;
212  tempret.quantity = quantity;
213  return tempret; //uses copy
214  } else {
215  Cargo newret;
216  newret.quantity = 0;
217  return newret;
218  }
219 }
float UniverseUtil::GetRelation ( std::string  myfaction,
std::string  theirfaction 
)

Definition at line 339 of file universe_util_generic.cpp.

References _Universe, Universe::AccessCockpit(), Universe::CurrentCockpit(), Unit::faction, FactionUtil::GetFactionIndex(), FactionUtil::GetIntRelation(), Cockpit::GetParent(), and getRelationModifierInt().

340 {
341  int myfac = FactionUtil::GetFactionIndex( myfaction );
342  int theirfac = FactionUtil::GetFactionIndex( theirfaction );
343  int cp = _Universe->CurrentCockpit();
345  if (!un) return FactionUtil::GetIntRelation( myfac, theirfac );
346  if (myfac == theirfac)
347  return 0;
348  else if (myfac == un->faction)
349  return getRelationModifierInt( cp, theirfac );
350  else if (theirfac == un->faction)
351  return getRelationModifierInt( cp, myfac );
352  else
353  return FactionUtil::GetIntRelation( myfac, theirfac );
354 }
float UniverseUtil::getRelationModifier ( int  which_cp,
string  faction 
)

Definition at line 380 of file universe_util_generic.cpp.

References FactionUtil::GetFactionIndex(), and getRelationModifierInt().

381 {
383 }
float UniverseUtil::getRelationModifierInt ( int  which_cp,
int  faction 
)

Definition at line 371 of file universe_util_generic.cpp.

References FactionUtil::GetFactionName(), getSaveData(), and getSaveDataLength().

Referenced by UnitUtil::getFactionRelation(), GetRelation(), UnitUtil::getRelationFromFaction(), getRelationModifier(), UnitUtil::getRelationToFaction(), and ScoreKill().

372 {
373  string saveVar = "Relation_to_"+FactionUtil::GetFactionName( faction );
374  if (getSaveDataLength( which_cp, saveVar ) == 0)
375  return 0.;
376  float val = getSaveData( which_cp, saveVar, 0 );
377  if (val > 1) val = 1;
378  return val;
379 }
string UniverseUtil::getSaveDir ( )

Definition at line 943 of file universe_util_generic.cpp.

References GetSaveDir().

Referenced by getSaveInfo().

944 {
945  return GetSaveDir();
946 }
string UniverseUtil::getSaveInfo ( const std::string &  filename,
bool  formatForTextbox 
)

Definition at line 968 of file universe_util_generic.cpp.

References _Universe, vs_options::campaigns, Universe::CurrentCockpit(), SaveGame::getMissionData(), SaveGame::getMissionStringData(), getSaveDir(), VegaConfig::getVariable(), i, SaveGame::ParseSaveGame(), vs_options::quick_savegame_summaries, QVector, setCurrentSaveGame(), SaveGame::SetStarSystem(), simplePrettyShip(), simplePrettySystem(), XMLSupport::tostring(), and vs_config.

Referenced by GarnerInfoFromSaveGame().

969 {
970  static SaveGame savegame( "" );
971  static set< string >campaign_score_vars;
972  static bool campaign_score_vars_init = false;
973  if (!campaign_score_vars_init) {
974  string campaign_score = vs_config->getVariable( "physics", "campaigns", "privateer_campaign vegastrike_campaign" );
975 
976  string::size_type where = 0, when = game_options.campaigns.find( ' ' );
977  while (where != string::npos) {
978  campaign_score_vars.insert( game_options.campaigns.substr( where, ( (when == string::npos) ? when : when-where ) ) );
979  where = (when == string::npos) ? when : when+1;
980  when = game_options.campaigns.find( ' ', where );
981  }
982  campaign_score_vars_init = true;
983  }
984  std::string system;
985  std::string lf = (formatForTextbox ? "#n#" : "\n");
986  QVector pos( 0, 0, 0 );
987  bool updatepos = false;
988  float creds;
989  vector< std::string >Ships;
990  std::string sillytemp = UniverseUtil::setCurrentSaveGame( filename );
991  savegame.SetStarSystem( "" );
992  savegame.ParseSaveGame( filename, system, "", pos, updatepos, creds, Ships,
993  _Universe->CurrentCockpit(), "", true, false, game_options.quick_savegame_summaries, true, true,
994  campaign_score_vars );
996  string text;
997  text += filename;
998  text = "Savegame: "+text+lf+"_________________"+lf;
999  {
1000  struct stat attrib;
1001  if ( 0 == stat( (getSaveDir()+filename).c_str(), &attrib ) ) {
1002  text += "Saved on: ";
1003  text += ctime( &attrib.st_mtime )+lf;
1004  }
1005  }
1006  text += "Credits: "+XMLSupport::tostring( (unsigned int) creds )+"."+XMLSupport::tostring(
1007  ( (unsigned int) (creds*100) )%100 )+lf;
1008  text += simplePrettySystem( system )+lf;
1009  if ( Ships.size() ) {
1010  text += "Starship: "+simplePrettyShip( Ships[0] )+lf;
1011  if (Ships.size() > 2) {
1012  text += "Fleet:"+lf;
1013  for (unsigned int i = 2; i < Ships.size(); i += 2)
1014  text += " "+simplePrettyShip( Ships[i-1] )+lf+" Located At:"+lf+" "+simplePrettySystem( Ships[i] )+lf;
1015  }
1016  }
1018  bool hit = false;
1019  for (set< string >::const_iterator it = campaign_score_vars.begin(); it != campaign_score_vars.end(); ++it) {
1020  string var = *it;
1021  unsigned int curscore = savegame.getMissionData( var ).size()+savegame.getMissionStringData( var ).size();
1022  if (curscore > 0) {
1023  hit = true;
1024  if (var.length() > 0)
1025  var[0] = toupper( var[0] );
1026  text += var.substr( 0, var.find( "_" ) )+" Campaign Score: "+XMLSupport::tostring( curscore )+lf;
1027  }
1028  }
1029  if (!hit)
1030  text += "Campaign Score: 0"+lf;
1031  }
1032  return text;
1033 }
Unit * UniverseUtil::getScratchUnit ( )

Definition at line 246 of file universe_util_generic.cpp.

References UnitContainer::GetUnit(), and scratch_unit.

Referenced by ChooseNavPoint().

247 {
248  return scratch_unit.GetUnit();
249 }
QVector UniverseUtil::getScratchVector ( )

Definition at line 255 of file universe_util_generic.cpp.

References scratch_vector.

256 {
257  return scratch_vector;
258 }
string UniverseUtil::getStarDate ( )

this gets the current stardate string

Definition at line 230 of file universe_util_generic.cpp.

References _Universe, Universe::current_stardate, and StarDate::GetFullTrekDate().

231 {
233 }
float UniverseUtil::getStarTime ( )

this gets the current absolute startime in seconds

Definition at line 225 of file universe_util_generic.cpp.

References _Universe, Universe::current_stardate, and StarDate::GetCurrentStarTime().

226 {
228 }
std::string UniverseUtil::getSubVariable ( std::string  section,
std::string  subsection,
std::string  name,
std::string  def 
)

Definition at line 808 of file universe_util_generic.cpp.

References VegaConfig::getVariable(), and vs_config.

809 {
810  return vs_config->getVariable( section, subsection, name, def );
811 }
string UniverseUtil::getSystemFile ( )

This function gets the current system's official name.

Definition at line 273 of file universe_util_generic.cpp.

References activeSys.

Referenced by Arrested(), BaseComputer::getColorForGroup(), and NavigationSystem::Setup().

274 {
275  if (!activeSys) return "";
276  return activeSys->getFileName();
277 }
string UniverseUtil::getSystemName ( )

this function gets the current system's nickname (not useful)

Definition at line 279 of file universe_util_generic.cpp.

References activeSys.

Referenced by buildCargoDescription().

280 {
281  if (!activeSys) return "";
282  return activeSys->getName();
283 }
std::string UniverseUtil::getTargetLabel ( )

Definition at line 588 of file universe_util_generic.cpp.

References _Universe, Universe::AccessCockpit(), and Cockpit::getTargetLabel().

589 {
591 }
Unit * UniverseUtil::getUnit ( int  index)

This function gets a unit given a number (how many iterations to go down in the iterator)

Definition at line 427 of file universe_util_generic.cpp.

References activeSys, Unit::GetHull(), and i.

Referenced by getNetworkUnit().

428 {
429  un_iter iter = activeSys->getUnitList().createIterator();
430  Unit *un = NULL;
431  for (int i = -1; (un = *iter) && i < index; ++iter) {
432  if (un->GetHull() > 0)
433  ++i;
434  if (i == index)
435  break;
436  }
437  return un;
438 }
Unit * UniverseUtil::getUnitByName ( std::string  name)

This function gets a unit given a name.

Definition at line 457 of file universe_util_generic.cpp.

References activeSys, UnitUtil::getName(), and UnitCollection::UnitIterator::notDone().

458 {
459  un_iter iter = activeSys->getUnitList().createIterator();
460  while (iter.notDone() && UnitUtil::getName( *iter ) != name)
461  ++iter;
462  return iter.notDone() ? (*iter) : NULL;
463 }
Unit * UniverseUtil::getUnitByPtr ( void *  ptr,
Unit finder = 0,
bool  allowslowness = true 
)

This function gets a unit given an unreferenceable pointer to it - much faster if finder is provided.

Definition at line 439 of file universe_util_generic.cpp.

References activeSys, findObjects(), Unit::isSubUnit(), Unit::location, UnitCollection::UnitIterator::notDone(), UnitPtrLocator::retval, and Unit::UNIT_ONLY.

Referenced by ChooseTargetClass< numTuple >::init().

440 {
441  if (finder) {
442  UnitPtrLocator unitLocator( ptr );
443  findObjects( activeSys->collidemap[Unit::UNIT_ONLY], finder->location[Unit::UNIT_ONLY], &unitLocator );
444  if (unitLocator.retval)
445  return reinterpret_cast< Unit* > (ptr);
446 
447  else if ( !finder->isSubUnit() )
448  return 0;
449  }
450  if (!allowslowness)
451  return 0;
452  un_iter it = activeSys->getUnitList().createIterator();
453  while ( it.notDone() && ( (void*) (*it) != ptr ) )
454  ++it;
455  return ( (void*) (*it) == ptr ) ? reinterpret_cast< Unit* > (ptr) : 0;
456 }
Unit * UniverseUtil::GetUnitFromSerial ( ObjSerial  serial)

Definition at line 133 of file universe_util_generic.cpp.

References getUnitList().

Referenced by UnitFactory::parsePlanetBuffer().

134 {
135  Unit *un;
136  if (serial == 0)
137  return NULL;
138  //Find the unit
139  for (un_iter it = UniverseUtil::getUnitList(); (un = *it); ++it)
140  if ( (*it)->GetSerial() == serial )
141  break;
142  if (un == NULL)
143  cout<<"ERROR --> no unit for serial "<<serial<<endl;
144  return un;
145 }
UniverseUtil::PythonUnitIter UniverseUtil::getUnitList ( )

this function gets an iterator into the units in the current system... do NOT keep an iterator across a frame–it may get deleted!

Definition at line 423 of file universe_util_generic.cpp.

References activeSys.

Referenced by NavigationSystem::DrawSystem(), GetUnitFromSerial(), and UnitUtil::owner().

424 {
425  return activeSys->getUnitList().createIterator();
426 }
std::string UniverseUtil::getVariable ( std::string  section,
std::string  name,
std::string  def 
)

Definition at line 804 of file universe_util_generic.cpp.

References VegaConfig::getVariable(), and vs_config.

Referenced by Unit::ResolveForces().

805 {
806  return vs_config->getVariable( section, name, def );
807 }
void UniverseUtil::hideSplashScreen ( )
void UniverseUtil::IOmessage ( int  delay,
std::string  from,
std::string  to,
std::string  message 
)

this sends an IO message... I'm not sure if delay currently works, but from, to and message do :-) ... if you want to send to the bar do "bar" as the to string... if you want to make news for the news room specify "news"

Referenced by Arrested(), bootstrap_main_loop(), GameCockpit::DoAutoLanding(), NetworkCommunication::RecvMessage(), and Unit::RegenShields().

void UniverseUtil::IOmessage ( int  delay,
string  from,
string  to,
string  message 
)

Definition at line 631 of file universe_util_generic.cpp.

References _Universe, MessageCenter::add(), i, mission, Mission::msgcenter, vs_options::news_from_cargolist, Universe::numPlayers(), and pushSaveString().

632 {
633  if ( to == "news" && (!game_options.news_from_cargolist) )
634  for (unsigned int i = 0; i < _Universe->numPlayers(); i++)
635  pushSaveString( i, "news", string( "#" )+message );
636  else
637  mission->msgcenter->add( from, to, message, delay );
638 }
bool UniverseUtil::isserver ( )

Definition at line 760 of file universe_util_generic.cpp.

References SERVER.

761 {
762  return SERVER;
763 }
bool UniverseUtil::isSplashScreenShowing ( )

Definition at line 200 of file universe_util.cpp.

References GetStarSystemLoading().

Referenced by NetActionConfirm::finalizeJoinGame(), ss_generating(), and GameUniverse::StartDraw().

201 {
202  return GetStarSystemLoading();
203 }
Unit * UniverseUtil::launch ( std::string  name_string,
std::string  type_string,
std::string  faction_string,
std::string  unittype,
std::string  ai_string,
int  nr_of_ships,
int  nr_of_waves,
QVector  pos,
std::string  sqadlogo 
)

this function launches a normal fighter the name is the flightgroup name, the type is the ship type, the faction is who it belongs to, the unittype is usually "unit" unless you want to make asteroids or nebulae or jump points or planets. the aistring is either a python filename or "default" the nr of ships is the number of ships to be launched with this group, the number of waves is num reinforcements... the position is a tuple (x,y,z) where they appear and the squadlogo is a squadron image...you can leave this the empty string '' for the default squadron logo.

Unit* UniverseUtil::launch ( string  name_string,
string  type_string,
string  faction_string,
string  unittype,
string  ai_string,
int  nr_of_ships,
int  nr_of_waves,
QVector  pos,
string  sqadlogo 
)

Definition at line 714 of file universe_util_generic.cpp.

References launchJumppoint(), and Network.

723 {
724  if (Network) return NULL;
725  return launchJumppoint( name_string,
726  faction_string,
727  type_string,
728  unittype,
729  ai_string,
730  nr_of_ships,
731  nr_of_waves,
732  pos,
733  sqadlogo,
734  "" );
735 }
Unit * UniverseUtil::launchJumppoint ( std::string  name_string,
std::string  faction_string,
std::string  type_string,
std::string  unittype_string,
std::string  ai_string,
int  nr_of_ships,
int  nr_of_waves,
QVector  pos,
std::string  squadlogo,
std::string  destinations 
)

this function launches a wormhole or a jump point.

this function launches a wormhole or ajump point.

Referenced by launch().

Unit* UniverseUtil::launchJumppoint ( string  name_string,
string  faction_string,
string  type_string,
string  unittype_string,
string  ai_string,
int  nr_of_ships,
int  nr_of_waves,
QVector  pos,
string  squadlogo,
string  destinations 
)

Definition at line 151 of file universe_util_generic.cpp.

References ASTEROIDPTR, Mission::call_unit_launch(), CreateFlightgroup::fg, mission, NEBULAPTR, Network, Flightgroup::newFlightgroup(), CreateFlightgroup::nr_ships, Mission::number_of_ships, PLANETPTR, Flightgroup::pos, CreateFlightgroup::rot, CreateFlightgroup::terrain_nr, CreateFlightgroup::UNIT, UNITPTR, CreateFlightgroup::unittype, and CreateFlightgroup::waves.

161 {
162  if (Network) return NULL;
163  int clstype = UNITPTR;
164  if (unittype_string == "planet")
165  clstype = PLANETPTR;
166  else if (unittype_string == "asteroid")
167  clstype = ASTEROIDPTR;
168  else if (unittype_string == "nebula")
169  clstype = NEBULAPTR;
171  cf.fg = Flightgroup::newFlightgroup( name_string,
172  type_string,
173  faction_string,
174  ai_string,
175  nr_of_ships,
176  nr_of_waves,
177  squadlogo,
178  "",
179  mission );
181  cf.terrain_nr = -1;
182  cf.waves = nr_of_waves;
183  cf.nr_ships = nr_of_ships;
184  cf.fg->pos = pos;
185  cf.rot[0] = cf.rot[1] = cf.rot[2] = 0.0f;
186  Unit *tmp = mission->call_unit_launch( &cf, clstype, destinations );
187  mission->number_of_ships += nr_of_ships;
188 
189  return tmp;
190 }
void UniverseUtil::loadGame ( const string &  savename)

Definition at line 143 of file universe_util.cpp.

References _Universe, Universe::AccessCockpit(), Universe::CurrentCockpit(), NetClient::dieRequest(), Cockpit::GetParent(), globalWindowManager(), Unit::Kill(), Network, RespawnNow(), setCurrentSaveGame(), WindowManager::shutDown(), and TerminateCurrentBase().

144 {
145  Cockpit *cockpit = _Universe->AccessCockpit();
146  Unit *player = cockpit->GetParent();
148  if (player) {
149  if (Network)
151  else
152  player->Kill();
153  }
154  RespawnNow( cockpit );
157 }
void UniverseUtil::loadGame ( const std::string &  savename)
void UniverseUtil::LoadMission ( std::string  missionname)
void UniverseUtil::LoadMission ( string  missionname)

Definition at line 643 of file universe_util_generic.cpp.

References LoadMission().

644 {
645  ::LoadMission( missionname.c_str(), "", false );
646 }
void UniverseUtil::LoadMissionScript ( std::string  scriptcontents)
void UniverseUtil::LoadMissionScript ( string  missionscript)

Definition at line 653 of file universe_util_generic.cpp.

References LoadMission().

654 {
655  ::LoadMission( "nothing.mission", missionscript, false );
656 }
void UniverseUtil::LoadNamedMissionScript ( std::string  missiontitle,
std::string  scriptcontents 
)
void UniverseUtil::LoadNamedMissionScript ( string  title,
string  missionscript 
)

Definition at line 648 of file universe_util_generic.cpp.

References LoadMission().

649 {
650  ::LoadMission( ("#"+title).c_str(), missionscript, false );
651 }
double UniverseUtil::log ( double  x)

Definition at line 820 of file universe_util_generic.cpp.

Referenced by computeStarColor(), and linear2log().

821 {
822  return ::log( x );
823 }
std::string UniverseUtil::LookupUnitStat ( const std::string &  unitname,
const std::string &  faction,
const std::string &  statname 
)
string UniverseUtil::LookupUnitStat ( const string &  unitname,
const string &  faction,
const string &  statname 
)

Definition at line 737 of file universe_util_generic.cpp.

References LookupUnitRow(), and CSVRow::success().

738 {
739  CSVRow tmp( LookupUnitRow( unitname, faction ) );
740  if ( tmp.success() )
741  return tmp[statname];
742 
743  else
744  return string();
745 }
unsigned int UniverseUtil::maxMissions ( )

Definition at line 131 of file universe_util.cpp.

References vs_options::max_missions.

Referenced by BaseComputer::isTransactionOK().

132 {
133  return game_options.max_missions;
134 }
void UniverseUtil::micro_sleep ( int  n)

Definition at line 852 of file universe_util_generic.cpp.

References micro_sleep.

853 {
854  ::micro_sleep( n );
855 }
int UniverseUtil::musicAddList ( string  str)

Definition at line 52 of file universe_util.cpp.

References Music::Addlist(), and muzak.

53 {
54  return muzak->Addlist( str.c_str() );
55 }
int UniverseUtil::musicAddList ( std::string  str)

this adds a playlist to the music and may be triggered with an int

void UniverseUtil::musicLayerLoopList ( int  numloops,
int  layer 
)

this plays msuci from a given list, at a specific layer (where the int is what was returned by musicAddList)

Definition at line 73 of file universe_util.cpp.

References muzak, and Music::SetLoops().

Referenced by musicLoopList().

74 {
75  muzak->SetLoops( numloops, layer );
76 }
void UniverseUtil::musicLayerPlayList ( int  which,
int  layer 
)

this plays msuci from a given list, at a specific layer (where the int is what was returned by musicAddList)

Definition at line 68 of file universe_util.cpp.

References muzak, and Music::SkipRandSong().

Referenced by musicPlayList().

69 {
70  if (which != -1)
71  muzak->SkipRandSong( which, layer );
72 }
void UniverseUtil::musicLayerPlaySong ( string  str,
int  layer 
)

Definition at line 64 of file universe_util.cpp.

References Music::GotoSong(), and muzak.

Referenced by musicPlaySong().

65 {
66  muzak->GotoSong( str, layer );
67 }
void UniverseUtil::musicLayerPlaySong ( std::string  str,
int  layer 
)

this plays a specific song, at a specific layer

void UniverseUtil::musicLayerSetHardVolume ( float  vol,
int  layer 
)

sets the hardware volume, does not support transitions of any kind.

Definition at line 81 of file universe_util.cpp.

References Music::SetVolume().

Referenced by musicSetHardVolume().

82 {
83  Music::SetVolume( vol, layer, true );
84 }
void UniverseUtil::musicLayerSetSoftVolume ( float  vol,
float  latency_override,
int  layer 
)

sets the software volume, with smooth transitions (latency_override==-1 uses default transition time)

Definition at line 77 of file universe_util.cpp.

References Music::SetVolume().

Referenced by musicSetSoftVolume().

78 {
79  Music::SetVolume( vol, layer, false, latency_override );
80 }
void UniverseUtil::musicLayerSkip ( int  layer)

this skips the current music track, at a specific layer (and goes to the next in the currently playing list)

Definition at line 56 of file universe_util.cpp.

References muzak, and Music::Skip().

Referenced by musicSkip().

57 {
58  muzak->Skip( layer );
59 }
void UniverseUtil::musicLayerStop ( int  layer)

this stops the music currently playing at a specific layer - with a nice fadeout

Definition at line 60 of file universe_util.cpp.

References muzak, and Music::Stop().

Referenced by musicStop().

61 {
62  muzak->Stop( layer );
63 }
void UniverseUtil::musicLoopList ( int  numloops)
inline

this plays msuci from a given list (where the int is what was returned by musicAddList)

Definition at line 207 of file universe_util.h.

References musicLayerLoopList().

208 {
209  musicLayerLoopList( numloops, -1 );
210 }
void UniverseUtil::musicMute ( bool  stopSound)

this mutes sound - or unmutes it

Definition at line 93 of file universe_util.cpp.

References Music::Mute(), and muzak.

Referenced by Unit::UpdatePhysics().

94 {
95  muzak->Mute( stopSound );
96 }
void UniverseUtil::musicPlayList ( int  which)
inline

this plays msuci from a given list (where the int is what was returned by musicAddList)

Definition at line 201 of file universe_util.h.

References musicLayerPlayList().

202 {
203  musicLayerPlayList( which, -1 );
204 }
void UniverseUtil::musicPlaySong ( std::string  str)
inline

this plays a specific song, through the crossfader construct

this plays a specific song

Definition at line 195 of file universe_util.h.

References musicLayerPlaySong().

196 {
197  musicLayerPlaySong( str, -1 );
198 }
void UniverseUtil::musicSetHardVolume ( float  vol)

sets the hardware volume, does not support transitions of any kind.

Definition at line 89 of file universe_util.cpp.

References musicLayerSetHardVolume().

90 {
91  musicLayerSetHardVolume( vol, -1 );
92 }
void UniverseUtil::musicSetSoftVolume ( float  vol,
float  latency_override 
)

sets the software volume, with smooth transitions (latency_override==-1 uses default transition time)

Definition at line 85 of file universe_util.cpp.

References musicLayerSetSoftVolume().

86 {
87  musicLayerSetSoftVolume( vol, latency_override, -1 );
88 }
void UniverseUtil::musicSkip ( )
inline

this skips the current music track (and goes to the next in the currently playing list)

Definition at line 213 of file universe_util.h.

References musicLayerSkip().

214 {
215  musicLayerSkip( -1 );
216 }
void UniverseUtil::musicStop ( )
inline

this stops the music currently playing - with a nice fadeout

Definition at line 219 of file universe_util.h.

References musicLayerStop().

220 {
221  musicLayerStop( -1 );
222 }
bool UniverseUtil::networked ( )

Definition at line 756 of file universe_util_generic.cpp.

References Network.

Referenced by Unit::SetNetworkMode(), and GameUnit< UnitType >::UpdatePhysics2().

757 {
758  return Network != NULL;
759 }
UnitWrapper UniverseUtil::newGetPlayer ( )

Definition at line 38 of file unit_wrapper.cpp.

References getPlayer().

39 {
40  return UniverseUtil::getPlayer();
41 }
int UniverseUtil::numActiveMissions ( )

returns number missions running to tweak difficulty

Definition at line 622 of file universe_util_generic.cpp.

References _Universe, active_missions, Universe::CurrentCockpit(), i, and num_delayed_missions().

623 {
624  int num = 0;
625  unsigned int cp = _Universe->CurrentCockpit();
626  for (unsigned int i = 0; i < active_missions.size(); ++i)
627  if (active_missions[i]->player_num == cp)
628  num++;
629  return num+::num_delayed_missions();
630 }
void UniverseUtil::playAnimation ( string  aniName,
QVector  loc,
float  size 
)

Definition at line 119 of file universe_util.cpp.

References AddAnimation().

Referenced by DoEnterExitAni().

120 {
121  AddAnimation( loc, size, true, aniName, 1 );
122 }
void UniverseUtil::playAnimation ( std::string  aniName,
QVector  loc,
float  size 
)

this plays an image (explosion or warp animation) at a location

void UniverseUtil::playAnimationGrow ( string  aniName,
QVector  loc,
float  size,
float  growpercent 
)

Definition at line 123 of file universe_util.cpp.

References AddAnimation().

Referenced by Unit::AutoPilotToErrorMessage(), and Unit::ResolveForces().

124 {
125  AddAnimation( loc, size, true, aniName, growpercent );
126 }
void UniverseUtil::playAnimationGrow ( std::string  aniName,
QVector  loc,
float  size,
float  growpercent 
)
void UniverseUtil::playSound ( string  soundName,
QVector  loc,
Vector  speed 
)

Definition at line 97 of file universe_util.cpp.

References AUDAdjustSound(), AUDCreateSoundWAV(), AUDDeleteSound(), and AUDStartPlaying().

Referenced by buyShip(), and BaseComputer::updateTransactionControlsForSelection().

98 {
99  int sound = AUDCreateSoundWAV( soundName, false );
100  AUDAdjustSound( sound, loc, speed );
101  AUDStartPlaying( sound );
102  AUDDeleteSound( sound );
103 }
void UniverseUtil::playSound ( std::string  soundName,
QVector  loc,
Vector  speed 
)

this plays a sound at a location...if the sound has dual channels it will play in the center

void UniverseUtil::playSoundCockpit ( string  soundName)

Definition at line 104 of file universe_util.cpp.

References AUDCreateSoundWAV(), AUDDeleteSound(), and AUDStartPlaying().

105 {
106  int sound = AUDCreateSoundWAV( soundName, false );
107  AUDStartPlaying( sound );
108  AUDDeleteSound( sound );
109 }
void UniverseUtil::playSoundCockpit ( std::string  soundName)

this plays a sound at full volume in the cockpit

void UniverseUtil::playVictoryTune ( )

Definition at line 48 of file universe_util.cpp.

References Music::GotoSong(), vs_options::missionvictorysong, and muzak.

Referenced by terminateMission().

void UniverseUtil::popSystem ( )

this function restores the active system.... there must be an equal number of pushSystems ans popSystems or else Vega Strike may behave unpredictably

Definition at line 269 of file universe_util_generic.cpp.

References _Universe, and Universe::popActiveStarSystem().

270 {
272 }
void UniverseUtil::precacheUnit ( std::string  name,
std::string  faction 
)
void UniverseUtil::precacheUnit ( string  type_string,
string  faction_string 
)

Definition at line 748 of file universe_util_generic.cpp.

References cachedUnits, UnitFactory::createUnit(), and FactionUtil::GetFactionIndex().

749 {
750  cachedUnits.push_back( UnitFactory::createUnit( type_string.c_str(), true, FactionUtil::GetFactionIndex( faction_string ) ) );
751 }
void UniverseUtil::pushSystem ( std::string  name)

this function sets the "current" system to be "name" where name may be something like "Sol/Sol" or "Crucible/Cephid_17" this function may take some time if the system has not been loaded before

void UniverseUtil::pushSystem ( string  name)

Definition at line 264 of file universe_util_generic.cpp.

References _Universe, Universe::GenerateStarSystem(), Universe::pushActiveStarSystem(), and Vector.

265 {
266  StarSystem *ss = _Universe->GenerateStarSystem( name.c_str(), "", Vector( 0, 0, 0 ) );
268 }
void UniverseUtil::receivedCustom ( int  cp,
bool  trusted,
string  cmd,
string  args,
string  id 
)

Definition at line 771 of file universe_util_generic.cpp.

References _Universe, Universe::AccessCockpit(), Cockpit::activeStarSystem, COUT, Universe::CurrentCockpit(), vs_options::custompython, Universe::popActiveStarSystem(), Universe::pushActiveStarSystem(), securepythonstr(), and Universe::SetActiveCockpit().

Referenced by sendCustom(), and CockpitKeys::TextMessageCallback().

772 {
773  int cp_orig = _Universe->CurrentCockpit();
776  securepythonstr( cmd );
777  securepythonstr( args );
778  securepythonstr( id );
779  string pythonCode = game_options.custompython+"("+(trusted ? "True" : "False")
780  +", r\'"+cmd+"\', r\'"+args+"\', r\'"+id+"\')\n";
781  COUT<<"Executing python command: "<<endl;
782  cout<<" "<<pythonCode;
783  const char *cpycode = pythonCode.c_str();
784  ::Python::reseterrors();
785  PyRun_SimpleString( const_cast< char* > (cpycode) );
786  ::Python::reseterrors();
788  _Universe->SetActiveCockpit( cp_orig );
789 }
QVector UniverseUtil::SafeStarSystemEntrancePoint ( StarSystem sts,
QVector  pos,
float  radial_size = -1 
)

Definition at line 673 of file universe_util_generic.cpp.

References UnitCollection::createIterator(), StarSystem::getUnitList(), i, UnitUtil::isAsteroid(), Unit::isUnit(), k, Unit::LocalPosition(), Magnitude(), NEBULAPTR, QVector, vs_options::respawn_unit_size, and Unit::rSize().

Referenced by SafeEntrancePoint().

674 {
675  if (radial_size < 0)
676  radial_size = game_options.respawn_unit_size;
677  for (unsigned int k = 0; k < 10; ++k) {
678  Unit *un;
679  bool collision = false;
680  {
681  //fixme, make me faster, use collide map
682  for (un_iter i = sts->getUnitList().createIterator(); (un = *i) != NULL; ++i) {
683  if (UnitUtil::isAsteroid( un ) || un->isUnit() == NEBULAPTR)
684  continue;
685  double dist = ( pos-un->LocalPosition() ).Magnitude()-un->rSize()-/*def_un_size-*/ radial_size;
686  if (dist < 0) {
687  QVector delta = pos-un->LocalPosition();
688  double mag = delta.Magnitude();
689  if (mag > .01)
690  delta = delta/mag;
691  else
692  delta.Set( 0, 0, 1 );
693  delta = delta.Scale( dist+un->rSize()+radial_size );
694  if (k < 5) {
695  pos = pos+delta;
696  collision = true;
697  } else {
698  QVector r( .5, .5, .5 );
699  pos += ( radial_size+un->rSize() )*r;
700  collision = true;
701  }
702  }
703  }
704  if (collision == false)
705  break;
706  }
707  }
708  return pos;
709 }
void UniverseUtil::saveGame ( const string &  savename)
void UniverseUtil::saveGame ( const std::string &  savename)
void UniverseUtil::securepythonstr ( string &  message)

Definition at line 764 of file universe_util_generic.cpp.

Referenced by receivedCustom().

765 {
766  std::replace( message.begin(), message.end(), '\'', '\"' );
767  std::replace( message.begin(), message.end(), '\\', '/' );
768  std::replace( message.begin(), message.end(), '\n', ' ' );
769  std::replace( message.begin(), message.end(), '\r', ' ' );
770 }
void UniverseUtil::sendCustom ( int  cp,
string  cmd,
string  args,
string  id 
)

Definition at line 205 of file universe_util.cpp.

References _Universe, fprintf, Network, Universe::numPlayers(), receivedCustom(), and NetClient::sendCustom().

206 {
207  if ( cp < 0 || cp >= static_cast<int>(_Universe->numPlayers()) ) {
208  fprintf( stderr, "sendCustom %s with invalid player %d\n", cmd.c_str(), cp );
209  return;
210  }
211  if (Network != NULL)
212  Network[cp].sendCustom( cmd, args, id );
213  else
214  receivedCustom( cp, true, cmd, args, id );
215 }
void UniverseUtil::SetAutoStatus ( int  global_auto,
int  player_auto 
)

this sets whether or not a player may autopilot. Normally they are both 0 and the autopiloting is allowed based on if enemies are near... if you pass in 1 then autopilot will be allowed no matter who is near... if you set -1 then autopilot is never allowed. global affects all players... player just affects the player who accepted the mission.

Definition at line 658 of file universe_util_generic.cpp.

References Mission::AUTO_NORMAL, Mission::AUTO_OFF, Mission::AUTO_ON, Mission::global_autopilot, mission, and Mission::player_autopilot.

659 {
660  if (global_auto == 1)
662  else if (global_auto == -1)
664  else
666  if (player_auto == 1)
668  else if (player_auto == -1)
670  else
672 }
void UniverseUtil::setCompleteness ( int  which,
float  completeNess 
)

this sets the completeness of a particular objective... chanigng the color onscreen

Definition at line 568 of file universe_util_generic.cpp.

References mission, Subcmd::Objective, Mission::objectives, Mission::player_num, NetServer::sendSaveData(), SERVER, Subcmd::SetValue, and VSServer.

569 {
570  if (which < (int) mission->objectives.size() && which >= 0) {
571  if (SERVER)
573  which, NULL, mission, &mission->objectives[which].objective, &completeNess );
574  mission->objectives[which].completeness = completeNess;
575  }
576 }
std::string UniverseUtil::setCurrentSaveGame ( const std::string &  newsave)
string UniverseUtil::setCurrentSaveGame ( const string &  newsave)

Definition at line 1040 of file universe_util_generic.cpp.

References SetCurrentSaveGame().

1041 {
1042  return SetCurrentSaveGame( newsave );
1043 }
void UniverseUtil::SetDifficulty ( float  diff)

this sets the difficulty

Definition at line 529 of file universe_util_generic.cpp.

References game_data_t::difficulty, and g_game.

530 {
531  g_game.difficulty = diff;
532 }
void UniverseUtil::SetGalaxyFaction ( std::string  sys,
std::string  fac 
)
void UniverseUtil::SetGalaxyFaction ( string  sys,
string  fac 
)

Definition at line 512 of file universe_util_generic.cpp.

References _Universe, Universe::AccessCockpit(), DEFAULT_FACTION_SAVENAME, SaveGame::getMissionStringData(), and Cockpit::savegame.

513 {
514  vector< std::string > *ans =
516  if ( ans->size() )
517  (*ans)[0] = fac;
518  else
519  ans->push_back( std::string( fac ) );
520 }
void UniverseUtil::setMissionOwner ( int  whichplayer)

Definition at line 415 of file universe_util_generic.cpp.

References mission, and Mission::player_num.

416 {
417  mission->player_num = whichplayer;
418 }
void UniverseUtil::setObjective ( int  which,
std::string  newobjective 
)

this sets the objective's completeness (the int was returned by add objective)

void UniverseUtil::setObjective ( int  which,
string  newobjective 
)

Definition at line 559 of file universe_util_generic.cpp.

References dontBlankOut(), mission, Subcmd::Objective, Mission::objectives, Mission::player_num, NetServer::sendSaveData(), SERVER, Subcmd::SetValue, and VSServer.

560 {
561  if (which < (int) mission->objectives.size() && which >= 0) {
562  if (SERVER)
564  which, NULL, mission, &newobjective, &mission->objectives[which].completeness );
565  mission->objectives[which].objective = dontBlankOut( newobjective );
566  }
567 }
void UniverseUtil::setOwner ( int  obj,
UnitWrapper  un 
)

Definition at line 42 of file unit_wrapper.cpp.

References UnitContainer::GetUnit(), and setOwnerII().

43 {
44  setOwnerII( obj, un.GetUnit() );
45 }
void UniverseUtil::setOwnerII ( int  which,
Unit owner 
)

this sets the owner of a completeness

Definition at line 610 of file universe_util_generic.cpp.

References mission, and Mission::objectives.

Referenced by setOwner().

611 {
612  if ( which < (int) mission->objectives.size() )
613  mission->objectives[which].setOwner( owner );
614 }
void UniverseUtil::setScratchUnit ( Unit un)

Definition at line 250 of file universe_util_generic.cpp.

References scratch_unit, and UnitContainer::SetUnit().

Referenced by ChooseNavPoint(), and DockedScript().

251 {
252  scratch_unit.SetUnit( un );
253 }
void UniverseUtil::setScratchVector ( QVector  un)
void UniverseUtil::setTargetLabel ( std::string  label)

Definition at line 584 of file universe_util_generic.cpp.

References _Universe, Universe::AccessCockpit(), and Cockpit::setTargetLabel().

585 {
587 }
void UniverseUtil::SetTimeCompression ( )

this sets the time compresison value to zero

this gets the current game time since last start in seconds

this gets the current absolute startime in seconds this sets the time compresison value to zero

Definition at line 235 of file universe_util_generic.cpp.

References setTimeCompression().

236 {
237  setTimeCompression( 1.0 );
238 }
void UniverseUtil::showSplashMessage ( const string &  text)

Definition at line 185 of file universe_util.cpp.

References bootstrap_draw().

Referenced by BaseComputer::actionConfirmedLoadGame(), and NetActionConfirm::finalizeJoinGame().

186 {
187  bootstrap_draw( text, 0 );
188 }
void UniverseUtil::showSplashMessage ( const std::string &  text)
void UniverseUtil::showSplashProgress ( float  progress)

Definition at line 190 of file universe_util.cpp.

191 {
192  //Unimplemented
193 }
void UniverseUtil::showSplashScreen ( const string &  filename)

Definition at line 169 of file universe_util.cpp.

References bootstrap_draw(), GetSplashScreen(), ParseDestinations(), SetStarSystemLoading(), and vs_options::splash_screen.

Referenced by BaseComputer::actionConfirmedLoadGame(), bootstrap_main_loop(), NetActionConfirm::confirmedJoinGame(), NetActionConfirm::finalizeJoinGame(), NetClient::Reconnect(), and ss_generating().

170 {
171  static Animation *curSplash = 0;
172  if ( !filename.empty() ) {
173  if (curSplash)
174  delete curSplash;
175  curSplash = new Animation( filename.c_str(), 0 );
176  } else if ( !curSplash && !GetSplashScreen() ) {
177  static std::vector< std::string >s = ParseDestinations( game_options.splash_screen );
178  int snum = time( NULL )%s.size();
179  curSplash = new Animation( s[snum].c_str(), 0 );
180  }
181  SetStarSystemLoading( true );
182  bootstrap_draw( "Loading...", curSplash );
183 }
void UniverseUtil::showSplashScreen ( const std::string &  filename)
static std::string UniverseUtil::simplePrettyShip ( std::string  ship)
static

Definition at line 956 of file universe_util_generic.cpp.

Referenced by getSaveInfo().

957 {
958  if (ship.length() > 0)
959  ship[0] = toupper( ship[0] );
960  std::string::size_type where = ship.find( "." );
961  if (where != string::npos) {
962  ship = ship.substr( 0, where );
963  ship = "Refurbished "+ship;
964  }
965  return ship;
966 }
static std::string UniverseUtil::simplePrettySystem ( std::string  system)
static

Definition at line 948 of file universe_util_generic.cpp.

Referenced by getSaveInfo().

949 {
950  std::string::size_type where = system.find_first_of( '/' );
951  std::string::size_type basewhere = system.find_first_of( '@', where );
952  return std::string( "Sec:" )+system.substr( 0, where )
953  +" Sys:"+( where == string::npos ? std::string("") : system.substr( where+1, (basewhere!=string::npos) ? basewhere-where-1 : string::npos ) )
954  +( basewhere == string::npos ? std::string("") : std::string(" ")+system.substr( basewhere+1 ) );
955 }
void UniverseUtil::StopAllSounds ( void  )

Definition at line 110 of file universe_util.cpp.

References AUDStopAllSounds().

Referenced by buyShip(), and BaseComputer::updateTransactionControlsForSelection().

111 {
113 }
void UniverseUtil::StopTargettingEachOther ( std::string  fgname,
std::string  faction,
std::string  enfgname,
std::string  enfaction 
)

tells the respective flightgroups in this system to stop killing each other urgently...they may still attack–just not warping and stuff

void UniverseUtil::StopTargettingEachOther ( string  fgname,
string  faction,
string  enfgname,
string  enfaction 
)

tells the respective flightgroups in this system to stop killing each other urgently...they may still attack–just not warping and stuff

Definition at line 312 of file universe_util_generic.cpp.

References _Universe, Universe::activeStarSystem(), UnitCollection::createIterator(), Unit::faction, FactionUtil::GetFactionIndex(), UnitUtil::getFlightgroupName(), StarSystem::getUnitList(), i, and UnitUtil::setFgDirective().

313 {
315  int enfac = FactionUtil::GetFactionIndex( enfaction );
316  Unit *un;
317  int clear = 0;
318  for (un_iter i = _Universe->activeStarSystem()->getUnitList().createIterator(); (un = *i) && clear != 3; ++i) {
319  if ( (un->faction == enfac && UnitUtil::getFlightgroupName( un ) == enfgname) ) {
320  clear |= 1;
321  UnitUtil::setFgDirective( un, "b" );
322  } else if (un->faction == fac && UnitUtil::getFlightgroupName( un ) == fgname) {
323  clear |= 2;
324  UnitUtil::setFgDirective( un, "b" );
325  //check to see that its' in this flightgroup or something :-)
326  }
327  }
328 }
bool UniverseUtil::systemInMemory ( std::string  name)
bool UniverseUtil::systemInMemory ( string  nam)

Definition at line 330 of file universe_util_generic.cpp.

References _Universe, i, and Universe::star_system.

331 {
332  unsigned int nass = _Universe->star_system.size();
333  for (unsigned int i = 0; i < nass; ++i)
334  if (_Universe->star_system[i]->getFileName() == nam)
335  return true;
336  return false;
337 }
double UniverseUtil::tan ( double  x)

Definition at line 848 of file universe_util_generic.cpp.

Referenced by GameCockpit::GameCockpit().

849 {
850  return ::tan( x );
851 }
void UniverseUtil::TargetEachOther ( std::string  fgname,
std::string  faction,
std::string  enfgname,
std::string  enfaction 
)

tells the respective flightgroups in this system to start shooting at each other

void UniverseUtil::TargetEachOther ( string  fgname,
string  faction,
string  enfgname,
string  enfaction 
)

tells the respective flightgroups in this system to start shooting at each other

Definition at line 285 of file universe_util_generic.cpp.

References _Universe, Universe::activeStarSystem(), UnitCollection::createIterator(), Unit::faction, FactionUtil::GetFactionIndex(), UnitUtil::getFlightgroupName(), StarSystem::getUnitList(), i, UnitUtil::setFgDirective(), UnitUtil::setFlightgroupLeader(), and Unit::Target().

286 {
288  int enfac = FactionUtil::GetFactionIndex( enfaction );
289  Unit *un;
290  Unit *en = NULL;
291  Unit *al = NULL;
292  for (un_iter i = _Universe->activeStarSystem()->getUnitList().createIterator(); (un = *i) && ( (!en) || (!al) ); ++i) {
293  if (un->faction == enfac && UnitUtil::getFlightgroupName( un ) == enfgname)
294  if ( (NULL == en) || (rand()%3 == 0) )
295  en = un;
296  if (un->faction == fac && UnitUtil::getFlightgroupName( un ) == fgname)
297  al = un;
298  }
299  if (en && al) {
301  al->Target( en );
302  //attack target, darent change target!
303  UnitUtil::setFgDirective( al, "A." );
305  en->Target( al );
306  //help me out here!
307  UnitUtil::setFgDirective( en, "h" );
308  }
309 }
void UniverseUtil::terminateMission ( bool  term)

this ends the mission with either success or failure

Definition at line 534 of file universe_util_generic.cpp.

References mission, playVictoryTune(), and Mission::terminateMission().

Referenced by SaveGame::LoadSavedMissions().

535 {
536  if (Win)
537  playVictoryTune();
539 }
double UniverseUtil::timeofday ( )

Definition at line 812 of file universe_util_generic.cpp.

References getNewTime().

813 {
814  return getNewTime();
815 }
std::string UniverseUtil::vsConfig ( std::string  category,
std::string  option,
std::string  def 
)

Definition at line 146 of file universe_util_generic.cpp.

References VegaConfig::getVariable(), and vs_config.

147 {
148  return vs_config->getVariable( category, option, def );
149 }

Variable Documentation

std::vector< Unit* > UniverseUtil::cachedUnits
static

Definition at line 747 of file universe_util_generic.cpp.

Referenced by precacheUnit().

UnitContainer UniverseUtil::scratch_unit
static

Definition at line 239 of file universe_util_generic.cpp.

Referenced by getScratchUnit(), and setScratchUnit().

QVector UniverseUtil::scratch_vector
static

Definition at line 240 of file universe_util_generic.cpp.

Referenced by getScratchVector(), and setScratchVector().