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

Classes

struct  Color
 
class  Vector
 
struct  GradColor
 
struct  PlanetInfo
 
struct  StarInfo
 

Functions

float mmax (float a, float b)
 
int rnd (int lower, int upper)
 
string getGenericName (vector< string > &s)
 
string getRandName (vector< string > &s)
 
float grand ()
 
static void Tab ()
 
float difffunc (float inputdiffuse)
 
void WriteLight (unsigned int i)
 
void ResetGlobalVariables ()
 
void readColorGrads (vector< string > &entity, const char *file)
 
float clamp01 (float a)
 
float getcolor (float c, float var)
 
GradColor whichGradColor (float r, unsigned int &j)
 
Color StarColor (float radius, unsigned int &entityindex)
 
GFXColor getStarColorFromRadius (float radius)
 
float LengthOfYear (Vector r, Vector s)
 
void CreateLight (unsigned int i)
 
Vector generateCenter (float minradii, bool jumppoint)
 
float makeRS (Vector &r, Vector &s, float minradii, bool jumppoint)
 
void Updateradii (float orbitsize, float thisplanetradius)
 
Vector generateAndUpdateRS (Vector &r, Vector &s, float thisplanetradius, bool jumppoint)
 
vector< string > parseBigUnit (const string &input)
 
void WriteUnit (const string &tag, const string &name, const string &filename, const Vector &r, const Vector &s, const Vector &center, const string &nebfile, const string &destination, bool faction, float thisloy=0)
 
string getJumpTo (const string &s)
 
string starin (const string &input)
 
string GetNebFile (string &input)
 
string AnalyzeType (string &input, string &nebfile, float &radius)
 
void MakeSmallUnit ()
 
void MakeJump (float radius, bool forceRS=false, Vector R=Vector(0, 0, 0), Vector S=Vector(0, 0, 0), Vector center=Vector(0, 0, 0), float thisloy=0)
 
void MakeBigUnit (int callingentitytype, string name=string(), float orbitalradius=0)
 
void MakeMoons (float callingradius, int callingentitytype)
 
void MakeJumps (float callingradius, int callingentitytype, int numberofjumps)
 
void MakePlanet (float radius, int entitytype, string texturename, string unitname, string technique, int texturenum, int numberofjumps, int numberofstarbases)
 
void beginStar ()
 
void endStar ()
 
void CreateStar ()
 
void CreateFirstStar ()
 
void CreatePrimaries ()
 
void CreateStarSystem ()
 
void readentity (vector< string > &entity, const char *filename)
 
const char * noslash (const char *in)
 

Variables

const char nada [1] = ""
 
vector< Colorlights
 
VSFile f
 
int xmllevel
 
const int STAR = 0
 
const int PLANET = 1
 
const int MOON = 2
 
const int JUMP = 3
 
vector< string > starentities
 
vector< string > jumps
 
vector< string > gradtex
 
vector< string > naturalphenomena
 
vector< string > starbases
 
unsigned int numstarbases
 
unsigned int numnaturalphenomena
 
unsigned int numstarentities
 
vector< string > background
 
vector< string > names
 
vector< string > rings
 
const float moonofmoonprob = .01
 
string systemname
 
vector< floatradii
 
const float minspeed = .001
 
const float maxspeed = 8
 
vector< floatstarradius
 
string faction
 
vector< GradColorcolorGradiant
 
float compactness = 2
 
float jumpcompactness = 2
 
vector< StarInfostars
 
unsigned int planetoffset
 
unsigned int staroffset
 
unsigned int moonlevel
 

Function Documentation

string StarSystemGent::AnalyzeType ( string &  input,
string &  nebfile,
float radius 
)

Definition at line 620 of file galaxy_gen.cpp.

References GetNebFile().

Referenced by MakeBigUnit(), and MakeSmallUnit().

621 {
622  if ( input.empty() )
623  return "";
624  char ptr = *input.begin();
625  string ip;
626  if ( 0 == sscanf( GetNebFile( input ).c_str(), "%f", &radius ) ) {
627  radius = 100;
628  ip = (input.c_str()+1);
629  } else {
630  ip = (input);
631  }
632  string retval;
633  switch (ptr)
634  {
635  case 'N':
636  nebfile = GetNebFile( input );
637  retval = "Nebula";
638  break;
639  case 'A':
640  retval = "Asteroid";
641  break;
642  case 'B':
643  retval = "Building";
644  break;
645  case 'E':
646  retval = "Enhancement";
647  break;
648  case 'U':
649  default:
650  retval = "Unit";
651  }
652  return retval;
653 }
void StarSystemGent::beginStar ( )

Definition at line 1019 of file galaxy_gen.cpp.

References b, center, f, float, g, generateAndUpdateRS(), VegaConfig::getVariable(), grand(), StarSystemGent::Vector::i, i, int, StarSystemGent::Vector::j, jumps, StarSystemGent::Vector::k, LengthOfYear(), lights, MakeBigUnit(), MakeJumps(), MakeMoons(), MakeSmallUnit(), numnaturalphenomena, numstarentities, XMLSupport::parse_float(), planetoffset, radii, STAR, starentities, staroffset, starradius, stars, systemname, Tab(), vs_config, VSFileSystem::vs_fprintf(), and xmllevel.

Referenced by CreateFirstStar(), and CreateStar().

1020 {
1021  float radius = starradius[staroffset];
1022  Vector r, s;
1023  unsigned int i;
1024  Vector center = generateAndUpdateRS( r, s, radius, false ); //WTF why was this commented out--that means all stars start on top of each other
1025  planetoffset = 0;
1026 
1027  char b[3] = " A";
1028  b[1] += staroffset;
1029  Tab();
1030  f.Fprintf( "<Planet name=\"%s%s\" file=\"%s\" ", systemname.c_str(), b, starentities[staroffset].c_str() );
1031  f.Fprintf( "ri=\"%f\" rj=\"%f\" rk=\"%f\" si=\"%f\" sj=\"%f\" sk=\"%f\" ", r.i, r.j, r.k, s.i, s.j, s.k );
1032  if (staroffset != 0)
1033  f.Fprintf( "radius=\"%f\" x=\"%f\" y=\"%f\" z=\"%f\" ", radius, center.i, center.j, center.k );
1034  else
1035  f.Fprintf( "radius=\"%f\" x=\"0\" y=\"0\" z=\"0\" ", radius );
1036  float loy = LengthOfYear( r, s );
1037  if (loy) {
1038  f.Fprintf( "year= \"%f\" ", loy );
1039  loy *= grand();
1040  if (loy)
1041  f.Fprintf( "day=\"%f\" ", loy );
1042  }
1043  f.Fprintf( " Red=\"%f\" Green=\"%f\" Blue=\"%f\" ReflectNoLight=\"true\" light=\"%d\">\n", lights[staroffset].r,
1045  f.Fprintf(
1046  "<fog>\n\t<FogElement file=\"atmXatm.bfxm\" ScaleAtmosphereHeight=\".900\" red=\"%f\" blue=\"%f\" green=\"%f\" alpha=\"1.0\" dired=\"%f\" diblue=\"%f\" digreen=\"%f\" dialpha=\"1\" concavity=\".3\" focus=\".6\" minalpha=\".7\" maxalpha=\"1\"/>\n\t<FogElement file=\"atmXhalo.bfxm\" ScaleAtmosphereHeight=\".9000\" red=\"%f\" blue=\"%f\" green=\"%f\" alpha=\"1.0\" dired=\"%f\" diblue=\"%f\" digreen=\"%f\" dialpha=\"1\" concavity=\".3\" focus=\".6\" minalpha=\".7\" maxalpha=\"1\"/>\n</fog>\n",
1047  lights[staroffset].r,
1048  lights[staroffset].g,
1049  lights[staroffset].b,
1050  lights[staroffset].r,
1051  lights[staroffset].g,
1052  lights[staroffset].b,
1053  lights[staroffset].r,
1054  lights[staroffset].g,
1055  lights[staroffset].b,
1056  lights[staroffset].r,
1057  lights[staroffset].g,
1058  lights[staroffset].b );
1059  radii.push_back( 1.5*radius );
1060  static float planet_size_compared_to_sun =
1061  XMLSupport::parse_float( vs_config->getVariable( "galaxy", "RockyRelativeToPrimary", ".05" ) );
1062  xmllevel++;
1063  unsigned int numu;
1064  if (numstarentities) {
1065  numu = numnaturalphenomena
1068  } else {
1069  numu = 1;
1070  }
1071  if ( (int) staroffset == (int) (numstarentities-staroffset)-1 )
1072  numu = numnaturalphenomena;
1073  for (i = 0; i < numu; ++i)
1074  MakeBigUnit( STAR );
1075  for (i = 0; i < stars[staroffset].numstarbases; ++i)
1076  MakeSmallUnit();
1077  MakeJumps( 100+grand()*300, STAR, stars[staroffset].numjumps );
1078  MakeMoons( planet_size_compared_to_sun*radius, STAR );
1079  //Fixme: no jumps should be made around the star.
1080  if ( !jumps.empty() )
1081  VSFileSystem::vs_fprintf( stderr, "ERROR: jumps not empty() Size==%u!!!!!\n", jumps.size() );
1082  staroffset++;
1083 }
float StarSystemGent::clamp01 ( float  a)

Definition at line 371 of file galaxy_gen.cpp.

References a.

Referenced by getcolor().

372 {
373  if (a > 1)
374  a = 1;
375  if (a < 0)
376  a = 0;
377  return a;
378 }
void StarSystemGent::CreateFirstStar ( )

Definition at line 1097 of file galaxy_gen.cpp.

References beginStar(), CreateStar(), endStar(), grand(), numstarentities, and staroffset.

Referenced by CreatePrimaries().

1098 {
1099  beginStar();
1100  while (staroffset < numstarentities) {
1101  if (grand() > .5) {
1102  CreateFirstStar();
1103  break;
1104  } else {
1105  CreateStar();
1106  }
1107  }
1108  endStar();
1109 }
void StarSystemGent::CreateLight ( unsigned int  i)

Definition at line 420 of file galaxy_gen.cpp.

References gradtex, grand(), h, lights, numstarentities, StarColor(), starentities, starradius, and WriteLight().

Referenced by CreatePrimaries().

421 {
422  if (i == 0) {
423  assert( !starradius.empty() );
424  assert( starradius[0] );
425  } else {
426  assert( starradius.size() == i );
427  starradius.push_back( starradius[0]*(.5+grand()*.5) );
428  }
429  unsigned int gradindex;
430  lights.push_back( StarColor( starradius[i], gradindex ) );
431  starentities.push_back( gradtex[gradindex] );
432  float h = lights.back().r;
433  if (h < lights.back().g) h = lights.back().g;
434  if (h < lights.back().b) h = lights.back().b;
435  float norm = (.5+.5/numstarentities);
436  if (h > .001) {
437  lights.back().nr = lights.back().r/h;
438  lights.back().ng = lights.back().g/h;
439  lights.back().nb = lights.back().b/h;
440 
441  lights.back().r *= norm/h;
442  lights.back().g *= norm/h;
443  lights.back().b *= norm/h;
444  } else {
445  lights.back().nr = 0;
446  lights.back().ng = 0;
447  lights.back().nb = 0;
448  }
449  WriteLight( i );
450 }
void StarSystemGent::CreatePrimaries ( )

Definition at line 1111 of file galaxy_gen.cpp.

References CreateFirstStar(), CreateLight(), i, and numstarentities.

Referenced by CreateStarSystem().

1112 {
1113  unsigned int i;
1114  for (i = 0; i < numstarentities || i == 0; i++)
1115  CreateLight( i );
1116  CreateFirstStar();
1117 }
void StarSystemGent::CreateStar ( )

Definition at line 1092 of file galaxy_gen.cpp.

References beginStar(), and endStar().

Referenced by CreateFirstStar().

1093 {
1094  beginStar();
1095  endStar();
1096 }
void StarSystemGent::CreateStarSystem ( )

Definition at line 1119 of file galaxy_gen.cpp.

References background, CreatePrimaries(), f, getRandName(), starradius, systemname, Tab(), and xmllevel.

Referenced by generateStarSystem().

1120 {
1121  assert( !starradius.empty() );
1122  assert( starradius[0] );
1123  xmllevel = 0;
1124  Tab();
1125  f.Fprintf( "<?xml version=\"1.0\" ?>\n<system name=\"%s\" background=\"%s\">\n", systemname.c_str(),
1126  getRandName( background ).c_str() );
1127  xmllevel++;
1128  CreatePrimaries();
1129  xmllevel--;
1130  Tab();
1131  f.Fprintf( "</system>\n" );
1132 }
float StarSystemGent::difffunc ( float  inputdiffuse)

Definition at line 225 of file galaxy_gen.cpp.

References UniverseUtil::sqrt().

Referenced by WriteLight().

226 {
227  return sqrt( ( (inputdiffuse) ) );
228 }
void StarSystemGent::endStar ( )

Definition at line 1085 of file galaxy_gen.cpp.

References f, radii, Tab(), and xmllevel.

Referenced by CreateFirstStar(), and CreateStar().

1086 {
1087  radii.pop_back();
1088  xmllevel--;
1089  Tab();
1090  f.Fprintf( "</Planet>\n" );
1091 }
Vector StarSystemGent::generateAndUpdateRS ( Vector r,
Vector s,
float  thisplanetradius,
bool  jumppoint 
)

Definition at line 524 of file galaxy_gen.cpp.

References generateCenter(), makeRS(), radii, starradius, Updateradii(), and Vector.

Referenced by beginStar(), MakeBigUnit(), MakeJump(), MakePlanet(), and MakeSmallUnit().

525 {
526  if ( radii.empty() ) {
527  r = Vector( 0, 0, 0 );
528  s = Vector( 0, 0, 0 );
529  return generateCenter( starradius[0], jumppoint );
530  }
531  float tmp = radii.back()+thisplanetradius;
532  Updateradii( makeRS( r, s, tmp, jumppoint ), thisplanetradius );
533  return generateCenter( tmp, jumppoint );
534 }
Vector StarSystemGent::generateCenter ( float  minradii,
bool  jumppoint 
)

Definition at line 452 of file galaxy_gen.cpp.

References compactness, grand(), StarSystemGent::Vector::i, i, StarSystemGent::Vector::j, jumpcompactness, StarSystemGent::Vector::k, rnd(), and Vector.

Referenced by generateAndUpdateRS().

453 {
454  Vector r;
455  float tmpcompactness = compactness;
456  if (jumppoint)
457  tmpcompactness = jumpcompactness;
458  r = Vector( tmpcompactness*grand()+1, tmpcompactness*grand()+1, tmpcompactness*grand()+1 );
459  r.i *= minradii;
460  r.j *= minradii;
461  r.k *= minradii;
462  int i = ( rnd( 0, 8 ) );
463  r.i = (i&1) ? -r.i : r.i;
464  r.j = (i&2) ? -r.j : r.j;
465  r.k = (i&4) ? -r.k : r.k;
466  return r;
467 }
float StarSystemGent::getcolor ( float  c,
float  var 
)

Definition at line 379 of file galaxy_gen.cpp.

References clamp01(), and grand().

Referenced by StarColor().

380 {
381  return clamp01( c-var+2*var*grand() );
382 }
string StarSystemGent::getGenericName ( vector< string > &  s)

Definition at line 88 of file galaxy_gen.cpp.

References nada, and rnd().

89 {
90  if ( s.empty() )
91  return string( nada );
92  return s[rnd( 0, s.size() )];
93 }
string StarSystemGent::getJumpTo ( const string &  s)

Definition at line 582 of file galaxy_gen.cpp.

Referenced by MakeBigUnit(), and MakeJump().

583 {
584  char tmp[1000] = "";
585  if ( 1 == sscanf( s.c_str(), "Jump_To_%s", tmp ) )
586  tmp[0] = tolower( tmp[0] );
587  else return s;
588  return string( tmp );
589 }
string StarSystemGent::GetNebFile ( string &  input)

Definition at line 604 of file galaxy_gen.cpp.

References i.

Referenced by AnalyzeType().

605 {
606  string ip = input.c_str();
607  char *ptr = strdup( ip.c_str() );
608  for (unsigned int i = 0; ptr[i] != '\0'; i++)
609  if (ptr[i] == '^') {
610  ptr[i] = '\0';
611  string ans( ptr );
612  input = ptr+i+1;
613  free( ptr );
614  return ans;
615  }
616  free( ptr );
617  return string();
618 }
string StarSystemGent::getRandName ( vector< string > &  s)

Definition at line 95 of file galaxy_gen.cpp.

References i, k, nada, and rnd().

Referenced by CreateStarSystem(), MakeBigUnit(), MakeJump(), MakePlanet(), and MakeSmallUnit().

96 {
97  if ( s.empty() )
98  return string( nada );
99  unsigned int i = rnd( 0, s.size() );
100  string k = s[i];
101  s.erase( s.begin()+i );
102  return k;
103 }
GFXColor StarSystemGent::getStarColorFromRadius ( float  radius)

Definition at line 406 of file galaxy_gen.cpp.

References VegaConfig::getVariable(), XMLSupport::parse_float(), StarColor(), and vs_config.

Referenced by AllocVerticesForSystem().

407 {
408  unsigned int myint = 0;
409  static float radiusscale = XMLSupport::parse_float( vs_config->getVariable( "galaxy", "StarRadiusScale", "1000" ) );
410  Color tmp = StarColor( radius*radiusscale, myint );
411  return GFXColor( tmp.r, tmp.g, tmp.b, 1 );
412 }
float StarSystemGent::grand ( )
float StarSystemGent::LengthOfYear ( Vector  r,
Vector  s 
)

Definition at line 413 of file galaxy_gen.cpp.

References a, grand(), M_PI, StarSystemGent::Vector::Mag(), maxspeed, minspeed, mmax(), and speed.

Referenced by beginStar(), MakeBigUnit(), MakeJump(), MakePlanet(), and WriteUnit().

414 {
415  float a = 2*M_PI*mmax( r.Mag(), s.Mag() );
416  float speed = minspeed+(maxspeed-minspeed)*grand();
417  return a/speed;
418 }
void StarSystemGent::MakeBigUnit ( int  callingentitytype,
string  name = string(),
float  orbitalradius = 0 
)

Definition at line 726 of file galaxy_gen.cpp.

References AnalyzeType(), center, first(), generateAndUpdateRS(), getJumpTo(), getRandName(), i, jumps, LengthOfYear(), MakeJump(), naturalphenomena, numnaturalphenomena, parseBigUnit(), S, size, STAR, starin(), and WriteUnit().

Referenced by beginStar().

727 {
728  vector< string >fullname;
729  if (name.length() == 0) {
730  string s = getRandName( naturalphenomena );
731  if (s.length() == 0)
732  return;
733  fullname = parseBigUnit( s );
734  } else {
735  fullname.push_back( name );
736  }
737  if ( fullname.empty() )
738  return;
740  Vector r, s;
741 
742  float stdloy = 0;
743  bool first = false;
744  float size = 0;
745  string tmp;
746  Vector center( 0, 0, 0 );
747  string nebfile( "" );
748  for (unsigned int i = 0; i < fullname.size(); i++) {
749  if ( 1 == sscanf( fullname[i].c_str(), "jump%f", &size ) ) {
750  if (!first) {
751  first = true;
752  center = generateAndUpdateRS( r, s, size, callingentitytype != STAR );
753  stdloy = LengthOfYear( r, s );
754  }
755  MakeJump( size, true, r, s, center, stdloy );
756  //We still want jumps inside asteroid fields, etcVvv.
757  } else if ( 1
758  == sscanf( fullname[i].c_str(), "planet%f",
759  &size ) || 1
760  == sscanf( fullname[i].c_str(), "moon%f", &size ) || 1 == sscanf( fullname[i].c_str(), "gas%f", &size ) ) {
761  //FIXME: Obsolete/not supported/too lazy to implement.
762  } else if ( ( tmp = starin( fullname[i] ) ).length() > 0 ) {
763  if (!first) {
764  first = true;
765  center = generateAndUpdateRS( r, s, size, callingentitytype != STAR );
766  stdloy = LengthOfYear( r, s );
767  }
768  string S = getRandName( jumps );
769  if (S.length() > 0) {
770  string type = AnalyzeType( tmp, nebfile, size );
771  WriteUnit( type, S, tmp, r, s, center, nebfile, getJumpTo( S ), false, stdloy );
772  }
773  } else {
774  string type = AnalyzeType( fullname[i], nebfile, size );
775  if (!first) {
776  first = true;
777  center = generateAndUpdateRS( r, s, size, callingentitytype != STAR ? type == "Unit" : false );
778  stdloy = LengthOfYear( r, s );
779  }
780  WriteUnit( type, "", fullname[i], r, s, center, nebfile, string( "" ), i != 0, stdloy );
781  }
782  }
783 }
void StarSystemGent::MakeJump ( float  radius,
bool  forceRS = false,
Vector  R = Vector( 0, 0, 0 ),
Vector  S = Vector( 0,                                                                                                    0,                                                                                                    0 ),
Vector  center = Vector(                   0,                   0,                   0 ),
float  thisloy = 0 
)

writes out some pretty planet tags

Definition at line 681 of file galaxy_gen.cpp.

References center, f, faction, generateAndUpdateRS(), getJumpTo(), getRandName(), getStarSystemName(), grand(), StarSystemGent::Vector::i, StarSystemGent::Vector::j, jumps, StarSystemGent::Vector::k, LengthOfYear(), VSFileSystem::LookForFile(), StarSystemGent::Vector::Mag(), mmax(), VSFileSystem::Ok, R, S, Tab(), VSFileSystem::TextureFile, and Updateradii().

Referenced by MakeBigUnit(), MakeJumps(), and MakePlanet().

687 {
688  string s = getRandName( jumps );
689  if (s.length() == 0)
690  return;
691  Vector RR, SS;
692  if (forceRS) {
693  RR = R;
694  SS = S;
695  Updateradii( mmax( RR.Mag(), SS.Mag() ), radius );
696  } else {
697  center = generateAndUpdateRS( RR, SS, radius, true );
698  }
699  string thisname;
700  thisname = string( "Jump_To_" )+getStarSystemName( s );
701  if (thisname.length() > 8)
702  *(thisname.begin()+8) = toupper( *(thisname.begin()+8) );
703  Tab();
704  //backwards compatibility
705  static bool usePNGFilename = (VSFileSystem::LookForFile( "jump.png", VSFileSystem::TextureFile ) <= VSFileSystem::Ok);
706  static const char *jumpFilename = usePNGFilename ? "jump.png" : "jump.texture";
707  f.Fprintf( "<Jump name=\"%s\" file=\"%s\" ", thisname.c_str(), jumpFilename );
708  f.Fprintf( "ri=\"%f\" rj=\"%f\" rk=\"%f\" si=\"%f\" sj=\"%f\" sk=\"%f\" ", RR.i, RR.j, RR.k, SS.i, SS.j, SS.k );
709  f.Fprintf( "radius=\"%f\" ", radius );
710  f.Fprintf( "x=\"%f\" y=\"%f\" z=\"%f\" ", center.i, center.j, center.k );
711  float loy = LengthOfYear( RR, SS );
712  float temprandom = .1*fmod( loy, 10 ); //use this so as not to alter state here
713  if (loy || thisloy) {
714  f.Fprintf( "year= \"%f\" ", thisloy ? thisloy : loy );
715  temprandom = grand();
716  loy = 864*temprandom;
717  if (loy)
718  f.Fprintf( "day=\"%f\" ", loy );
719  }
720  f.Fprintf( "alpha=\"ONE ONE\" destination=\"%s\" faction=\"%s\" />\n", getJumpTo(
721  s ).c_str(), StarSystemGent::faction.c_str() );
722 
724 }
void StarSystemGent::MakeJumps ( float  callingradius,
int  callingentitytype,
int  numberofjumps 
)

Definition at line 1003 of file galaxy_gen.cpp.

References grand(), i, and MakeJump().

Referenced by beginStar(), and MakePlanet().

1004 {
1005  for (int i = 0; i < numberofjumps; i++)
1006  MakeJump( ( .5+.5*grand() )*callingradius );
1007 }
void StarSystemGent::MakeMoons ( float  callingradius,
int  callingentitytype 
)

Definition at line 1008 of file galaxy_gen.cpp.

References grand(), MakePlanet(), MOON, moonlevel, StarSystemGent::PlanetInfo::name, StarSystemGent::PlanetInfo::num, StarSystemGent::PlanetInfo::numjumps, StarSystemGent::PlanetInfo::numstarbases, PLANET, planetoffset, STAR, staroffset, stars, StarSystemGent::PlanetInfo::technique, and StarSystemGent::PlanetInfo::unitname.

Referenced by beginStar(), and MakePlanet().

1009 {
1010  while (planetoffset < stars[staroffset].planets.size() && stars[staroffset].planets[planetoffset].moonlevel == moonlevel) {
1011  PlanetInfo &infos = stars[staroffset].planets[planetoffset++];
1012  MakePlanet(
1013  ( .5+.5*grand() )*callingradius, callingentitytype == STAR ? PLANET : MOON,
1014  infos.name, infos.unitname, infos.technique,
1015  infos.num, infos.numjumps,
1016  infos.numstarbases );
1017  }
1018 }
void StarSystemGent::MakePlanet ( float  radius,
int  entitytype,
string  texturename,
string  unitname,
string  technique,
int  texturenum,
int  numberofjumps,
int  numberofstarbases 
)

Definition at line 786 of file galaxy_gen.cpp.

References _Universe, a, b, center, f, g, generateAndUpdateRS(), Universe::getGalaxy(), GalaxyXML::Galaxy::getPlanetVariable(), getRandName(), VegaConfig::getVariable(), GetWrapXY(), grand(), StarSystemGent::Vector::i, i, StarSystemGent::Vector::j, UnitXML::JUMP, StarSystemGent::Vector::k, LengthOfYear(), StarSystemGent::Vector::Mag(), MakeJump(), MakeJumps(), MakeMoons(), makeRS(), MakeSmallUnit(), MOON, moonlevel, CommXML::NAME, names, XMLSupport::parse_float(), PLANET, radii, rings, rnd(), Tab(), XMLSupport::tostring(), vs_config, and xmllevel.

Referenced by MakeMoons().

787 {
788  if (entitytype == JUMP) {
789  MakeJump( radius );
790  return;
791  }
792  if (texturename.length() == 0) //FIXME?
793  return;
794  Vector RR, SS;
795  Vector center = generateAndUpdateRS( RR, SS, radius, false );
796  string thisname;
797  thisname = getRandName( names );
798  Tab();
799  static string default_atmosphere = vs_config->getVariable( "galaxy",
800  "DefaultAtmosphereTexture",
801  "sol/earthcloudmaptrans.png" );
802  string atmosphere = _Universe->getGalaxy()->getPlanetVariable( texturename, "atmosphere", "false" );
803  if (atmosphere == "false")
804  atmosphere = "";
805  else if (atmosphere == "true")
806  atmosphere = default_atmosphere;
807  string cname;
808  string planetlites = _Universe->getGalaxy()->getPlanetVariable( texturename, "lights", "" );
809  if ( !planetlites.empty() ) {
810  planetlites = ' '+planetlites;
811  vector< string::size_type >lites;
812  lites.push_back( 0 );
813  while (lites.back() != string::npos)
814  lites.push_back( planetlites.find( lites.back()+1, ' ' ) );
815  unsigned randomnum = rnd( 0, lites.size()-1 );
816  cname = planetlites.substr( lites[randomnum]+1, lites[randomnum+1] );
817  }
818  f.Fprintf( "<Planet name=\"%s\" file=\"%s\" unit=\"%s\" ", thisname.c_str(), texturename.c_str(), unitname.c_str() );
819  if (!technique.empty())
820  f.Fprintf( "technique=\"%s\" ", technique.c_str() );
821  if (texturename.find_first_of('|') != string::npos)
822  f.Fprintf("Red=\"0\" Green=\"0\" Blue=\"0\" DRed=\"0.87\" DGreen=\"0.87\" DBlue=\"0.87\" SRed=\"0.85\" SGreen=\"0.85\" SBlue=\"0.85\" ");
823  f.Fprintf( "ri=\"%f\" rj=\"%f\" rk=\"%f\" si=\"%f\" sj=\"%f\" sk=\"%f\" ", RR.i, RR.j, RR.k, SS.i, SS.j, SS.k );
824  f.Fprintf( "radius=\"%f\" ", radius );
825  f.Fprintf( "x=\"%f\" y=\"%f\" z=\"%f\" ", center.i, center.j, center.k );
826  float loy = LengthOfYear( RR, SS );
827  float temprandom = .1*fmod( loy, 10 ); //use this so as not to alter state here
828  if (loy) {
829  f.Fprintf( "year= \"%f\" ", loy );
830  temprandom = grand();
831  loy = 864*temprandom;
832  if (loy)
833  f.Fprintf( "day=\"%f\" ", loy );
834  }
835  f.Fprintf( ">\n" );
836  xmllevel++;
837  if ( !cname.empty() ) {
838  int wrapx = 1;
839  int wrapy = 1;
840  cname = GetWrapXY( cname, wrapx, wrapy );
841  string::size_type t;
842  while ( ( t = cname.find( '*' ) ) != string::npos )
843  cname.replace( t, 1, texturenum == 0 ? "" : XMLSupport::tostring( texturenum ) );
844  Tab();
845  f.Fprintf( "<CityLights file=\"%s\" wrapx=\"%d\" wrapy=\"%d\"/>\n", cname.c_str(), wrapx, wrapy );
846  }
847  static float atmosphere_prob = XMLSupport::parse_float( vs_config->getVariable( "galaxy", "AtmosphereProbability", "0.5" ) );
848  if ( (entitytype == PLANET && temprandom < atmosphere_prob) && ( !atmosphere.empty() ) ) {
849  string NAME = thisname+" Atmosphere";
850  {
851  bool doalphaatmosphere = (temprandom< .08 || temprandom >.3);
852  if (doalphaatmosphere) {
853  float fograd = radius*1.007;
854  if (.007*radius > 2500.0)
855  fograd = radius+2500.0;
856  Tab();
857  f.Fprintf( "<Atmosphere file=\"%s\" alpha=\"SRCALPHA INVSRCALPHA\" radius=\"%f\"/>\n",
858  atmosphere.c_str(), fograd );
859  }
860  float r = .9, g = .9, b = 1, a = 1;
861  float dr = .9, dg = .9, db = 1, da = 1;
862  if (!doalphaatmosphere) {
863  if (temprandom > .26 || temprandom < .09) {
864  r = .5;
865  g = 1;
866  b = .5;
867  } else if (temprandom > .24 || temprandom < .092) {
868  r = 1;
869  g = .6;
870  b = .5;
871  }
872  }
873 
874 /*----------------------------------------------------------------------------------------*\
875 | **************************************************************************************** |
876 | ********************************* FIXME: USE BFXM ************************************* |
877 | **************************************************************************************** |
878 \*----------------------------------------------------------------------------------------*/
879 
880  Tab();
881  f.Fprintf( "<Fog>\n" );
882  xmllevel++;
883  Tab();
884  f.Fprintf(
885  "<FogElement file=\"atmXatm.bfxm\" ScaleAtmosphereHeight=\"1.0\" red=\"%f\" blue=\"%f\" green=\"%f\" alpha=\"%f\" dired=\"%f\" diblue=\"%f\" digreen=\"%f\" dialpha=\"%f\" concavity=\".3\" focus=\".6\" minalpha=\"0\" maxalpha=\"0.7\"/>\n",
886  r,
887  g,
888  b,
889  a,
890  dr,
891  dg,
892  db,
893  da );
894  Tab();
895  f.Fprintf(
896  "<FogElement file=\"atmXhalo.bfxm\" ScaleAtmosphereHeight=\"1.0\" red=\"%f\" blue=\"%f\" green=\"%f\" alpha=\"%f\" dired=\"%f\" diblue=\"%f\" digreen=\"%f\" dialpha=\"%f\" concavity=\"1\" focus=\".6\" minalpha=\"0\" maxalpha=\"0.7\"/>\n",
897  r,
898  g,
899  b,
900  a,
901  dr,
902  dg,
903  db,
904  da );
905  xmllevel--;
906  Tab();
907  f.Fprintf( "</Fog>\n" );
908  }
909  }
910 //FIRME: need scaling of radius based on planet type.
911  radii.push_back( radius );
912 
913  static float ringprob = XMLSupport::parse_float( vs_config->getVariable( "galaxy", "RingProbability", ".1" ) );
914  static float dualringprob = XMLSupport::parse_float( vs_config->getVariable( "galaxy", "DoubleRingProbability", ".025" ) );
915  if (entitytype == PLANET) {
916  float ringrand = grand();
917  if (ringrand < ringprob) {
918  string ringname = getRandName( rings );
919  static float innerRingRadMin = XMLSupport::parse_float( vs_config->getVariable( "galaxy", "InnerRingRadius", "1.5" ) );
920  static float outerRingRadMin = XMLSupport::parse_float( vs_config->getVariable( "galaxy", "OuterRingRadius", "2.5" ) );
921  double inner_rad = ( innerRingRadMin*(1+grand()*.5) )*radius;
922  double outer_rad = inner_rad+( outerRingRadMin*grand() )*radius;
923  int wrapx = 1;
924  int wrapy = 1;
925  if ( ringname.empty() ) {
926  static string defringname = vs_config->getVariable( "galaxy",
927  "DefaultRingTexture",
928  "planets/ring.pngwrapx36wrapy2" );
929  ringname = defringname;
930  }
931  ringname = GetWrapXY( ringname, wrapx, wrapy );
932  Vector r, s;
933  makeRS( r, s, 1, false );
934  float rmag = r.Mag();
935  if (rmag > .001) {
936  r.i /= rmag;
937  r.j /= rmag;
938  r.k /= rmag;
939  }
940  float smag = s.Mag();
941  if (smag > .001) {
942  s.i /= smag;
943  s.j /= smag;
944  s.k /= smag;
945  }
946  if ( ringrand < (1-dualringprob) ) {
947  Tab();
948  f.Fprintf(
949  "<Ring file=\"%s\" ri=\"%f\" rj=\"%f\" rk=\"%f\" si=\"%f\" sj=\"%f\" sk=\"%f\" innerradius=\"%f\" outerradius=\"%f\" wrapx=\"%d\" wrapy=\"%d\" />\n",
950  ringname.c_str(),
951  r.i,
952  r.j,
953  r.k,
954  s.i,
955  s.j,
956  s.k,
957  inner_rad,
958  outer_rad,
959  wrapx,
960  wrapy );
961  }
962  if ( ringrand < dualringprob || ringrand >= (ringprob-dualringprob) ) {
963  double movable = grand();
964  static float second_ring_move =
965  XMLSupport::parse_float( vs_config->getVariable( "galaxy", "SecondRingDifference", ".4" ) );
966  inner_rad = outer_rad*( 1+.1*(second_ring_move+second_ring_move*movable) );
967  outer_rad = inner_rad*(outerRingRadMin*movable);
968  Tab();
969  f.Fprintf(
970  "<Ring file=\"%s\" ri=\"%f\" rj=\"%f\" rk=\"%f\" si=\"%f\" sj=\"%f\" sk=\"%f\" innerradius=\"%f\" outerradius=\"%f\" wrapx=\"%d\" wrapy=\"%d\" />\n",
971  ringname.c_str(),
972  r.i,
973  r.j,
974  r.k,
975  s.i,
976  s.j,
977  s.k,
978  inner_rad,
979  outer_rad,
980  wrapx,
981  wrapy );
982  }
983  }
984  }
985  for (int i = 0; i < numberofstarbases; i++)
986  MakeSmallUnit();
987  static float moon_size_compared_to_planet =
988  XMLSupport::parse_float( vs_config->getVariable( "galaxy", "MoonRelativeToPlanet", ".4" ) );
989  static float moon_size_compared_to_moon =
990  XMLSupport::parse_float( vs_config->getVariable( "galaxy", "MoonRelativeToMoon", ".8" ) );
991  moonlevel++;
992  MakeMoons( entitytype != MOON ? moon_size_compared_to_planet*radius : moon_size_compared_to_moon*radius, entitytype );
993  MakeJumps( 100+grand()*300, entitytype, numberofjumps );
994  moonlevel--;
995  radii.pop_back();
996  xmllevel--;
997  Tab();
998  f.Fprintf( "</Planet>\n" );
999 
1000  //writes out some pretty planet tags
1001 }
float StarSystemGent::makeRS ( Vector r,
Vector s,
float  minradii,
bool  jumppoint 
)

Definition at line 468 of file galaxy_gen.cpp.

References compactness, StarSystemGent::Vector::Cross(), grand(), StarSystemGent::Vector::i, i, StarSystemGent::Vector::j, jumpcompactness, k, StarSystemGent::Vector::k, StarSystemGent::Vector::Mag(), mmax(), rnd(), and Vector.

Referenced by generateAndUpdateRS(), and MakePlanet().

469 {
470  r = Vector( grand(), grand(), grand() );
471  int i = ( rnd( 0, 8 ) );
472  r.i = (i&1) ? -r.i : r.i;
473  r.j = (i&2) ? -r.j : r.j;
474  r.k = (i&4) ? -r.k : r.k;
475 
476  Vector k( grand(), grand(), grand() );
477  i = ( rnd( 0, 8 ) );
478  k.i = (i&1) ? -k.i : k.i;
479  k.j = (i&2) ? -k.j : k.j;
480  k.k = (i&4) ? -k.k : k.k;
481 
482  s = r.Cross( k );
483  float sm = s.Mag();
484  if (sm < .01)
485  return makeRS( r, s, minradii, jumppoint );
486  s.i /= sm;
487  s.j /= sm;
488  s.k /= sm;
489  sm = r.Mag();
490  r.i /= sm;
491  r.j /= sm;
492  r.k /= sm;
493  bool tmp = false;
494  float rm;
495  float tmpcompactness = compactness;
496  if (jumppoint)
497  tmpcompactness = jumpcompactness;
498  rm = (tmpcompactness*grand()+1);
499  if (rm < 1) {
500  rm = (1+grand()*.5);
501  tmp = true;
502  }
503  rm *= minradii;
504  r.i *= rm;
505  r.j *= rm;
506  r.k *= rm;
507  sm = (tmpcompactness*grand()+1);
508  if (tmp) sm = (1+grand()*.5);
509  sm *= minradii;
510  s.i *= sm;
511  s.j *= sm;
512  s.k *= sm;
513  return mmax( rm, sm );
514 }
void StarSystemGent::MakeSmallUnit ( )

Definition at line 654 of file galaxy_gen.cpp.

References AnalyzeType(), center, generateAndUpdateRS(), getRandName(), jumps, numstarbases, R, S, starbases, starin(), and WriteUnit().

Referenced by beginStar(), and MakePlanet().

655 {
656  Vector R, S;
657 
658  string nam;
659  string s = string( "" );
660  while (s.length() == 0) {
661  nam = getRandName( starbases );
662  if (nam.length() == 0)
663  return;
664  string tmp;
665  if ( ( tmp = starin( nam ) ).length() > 0 ) {
666  nam = (tmp);
667  s = getRandName( jumps );
668  } else {
669  break;
670  }
671  }
672  numstarbases--;
673  string nebfile( "" );
674  float radius;
675  string type = AnalyzeType( nam, nebfile, radius );
676  Vector center = generateAndUpdateRS( R, S, radius, true );
677 
678  WriteUnit( type, "", nam, R, S, center, nebfile, s, true );
679 }
float StarSystemGent::mmax ( float  a,
float  b 
)

Definition at line 76 of file galaxy_gen.cpp.

References b.

Referenced by LengthOfYear(), MakeJump(), and makeRS().

77 {
78  return (a > b) ? a : b;
79 }
const char* StarSystemGent::noslash ( const char *  in)

Definition at line 1147 of file galaxy_gen.cpp.

Referenced by getStarSystemName().

1148 {
1149  const char *tmp = in;
1150  while (*tmp != '\0' && *tmp != '/')
1151  tmp++;
1152  if (*tmp != '\0')
1153  tmp++;
1154  else
1155  return in;
1156  const char *tmp2 = tmp;
1157  tmp2 = noslash( tmp2 );
1158  if (tmp2[0] != '\0')
1159  return tmp2;
1160  else
1161  return tmp;
1162 }
vector< string > StarSystemGent::parseBigUnit ( const string &  input)

Definition at line 536 of file galaxy_gen.cpp.

Referenced by MakeBigUnit().

537 {
538  char *mystr = strdup( input.c_str() );
539  char *ptr = mystr;
540  char *oldptr = mystr;
541  vector< string >ans;
542  while (*ptr != '\0') {
543  while (*ptr != '&' && *ptr != '\0')
544  ptr++;
545  if (*ptr == '&') {
546  *ptr = '\0';
547  ptr++;
548  }
549  ans.push_back( string( oldptr ) );
550  oldptr = ptr;
551  }
552  free( mystr );
553  return ans;
554 }
void StarSystemGent::readColorGrads ( vector< string > &  entity,
const char *  file 
)

Definition at line 342 of file galaxy_gen.cpp.

References StarSystemGent::GradColor::b, VSFileSystem::VSFile::Close(), colorGradiant, VSFileSystem::VSFile::Eof(), f, StarSystemGent::GradColor::g, g, VegaConfig::getVariable(), input_buffer, StarSystemGent::GradColor::minrad, VSFileSystem::Ok, VSFileSystem::VSFile::OpenReadOnly(), XMLSupport::parse_float(), StarSystemGent::GradColor::r, VSFileSystem::VSFile::ReadLine(), VSFileSystem::UniverseFile, StarSystemGent::GradColor::variance, and vs_config.

Referenced by generateStarSystem(), and whichGradColor().

343 {
344  VSFile f;
346  static float radiusscale = XMLSupport::parse_float( vs_config->getVariable( "galaxy", "StarRadiusScale", "1000" ) );
347  if (err > Ok) {
348  printf( "Failed to load %s", file );
349  GradColor( g );
350  g.minrad = 0;
351  g.r = g.g = g.b = .9;
352  g.variance = .1;
353  entity.push_back( "white_star.png" );
354  colorGradiant.push_back( g );
355  return;
356  }
357  char input_buffer[1000];
358  char output_buffer[1000];
359  GradColor g;
360  while ( !f.Eof() ) {
361  f.ReadLine( input_buffer, 999 );
362  if (sscanf( input_buffer, "%f %f %f %f %f %s", &g.minrad, &g.r, &g.g, &g.b, &g.variance, output_buffer ) == 6) {
363  g.minrad *= radiusscale;
364  colorGradiant.push_back( g );
365  entity.push_back( output_buffer );
366  }
367  }
368  f.Close();
369 }
void StarSystemGent::readentity ( vector< string > &  entity,
const char *  filename 
)

warning... obvious vulnerability

Definition at line 1134 of file galaxy_gen.cpp.

References VSFileSystem::VSFile::Close(), f, VSFileSystem::VSFile::Fscanf(), input_buffer, VSFileSystem::Ok, VSFileSystem::VSFile::OpenReadOnly(), and VSFileSystem::UniverseFile.

Referenced by generateStarSystem().

1135 {
1136  VSFile f;
1137  VSError err = f.OpenReadOnly( filename, UniverseFile );
1138  if (err > Ok)
1139  return;
1141  char input_buffer[1000];
1142  while ( 1 == f.Fscanf( "%s", input_buffer ) )
1143  entity.push_back( input_buffer );
1144  f.Close();
1145 }
void StarSystemGent::ResetGlobalVariables ( )

Definition at line 314 of file galaxy_gen.cpp.

References background, colorGradiant, compactness, faction, gradtex, jumpcompactness, jumps, lights, moonlevel, names, naturalphenomena, numnaturalphenomena, numstarbases, numstarentities, planetoffset, radii, rings, starbases, starentities, staroffset, starradius, stars, systemname, and xmllevel.

Referenced by generateStarSystem().

315 {
316  xmllevel = 0;
317  lights.clear();
318  gradtex.clear();
319  naturalphenomena.clear();
320  starbases.clear();
321  starentities.clear();
322  numstarentities = 0;
323  numstarbases = 0;
325  background.clear();
326  stars.clear();
327  planetoffset = 0;
328  staroffset = 0;
329  moonlevel = 0;
330  names.clear();
331  jumps.clear();
332  rings.clear();
333  systemname.erase();
334  starradius.clear();
335  faction.erase();
336  colorGradiant.clear();
337  compactness = 2;
338  jumpcompactness = 2;
339  radii.clear();
340 }
int StarSystemGent::rnd ( int  lower,
int  upper 
)

Definition at line 81 of file galaxy_gen.cpp.

References ssrand().

82 {
83  if (upper > lower)
84  return lower+ssrand()%(upper-lower);
85  else return lower;
86 }
Color StarSystemGent::StarColor ( float  radius,
unsigned int entityindex 
)

Definition at line 398 of file galaxy_gen.cpp.

References b, StarSystemGent::GradColor::b, StarSystemGent::GradColor::g, g, getcolor(), StarSystemGent::GradColor::r, StarSystemGent::GradColor::variance, and whichGradColor().

Referenced by CreateLight(), and getStarColorFromRadius().

399 {
400  GradColor gc = whichGradColor( radius, entityindex );
401  float r = getcolor( gc.r, gc.variance );
402  float g = getcolor( gc.g, gc.variance );
403  float b = getcolor( gc.b, gc.variance );
404  return Color( r, g, b );
405 }
string StarSystemGent::starin ( const string &  input)

Definition at line 590 of file galaxy_gen.cpp.

References i.

Referenced by MakeBigUnit(), and MakeSmallUnit().

591 {
592  char *tmp = strdup( input.c_str() );
593  for (unsigned int i = 0; tmp[i] != '\0'; i++)
594  if (tmp[i] == '*') {
595  tmp[i] = '\0';
596  string ans( tmp );
597  free( tmp );
598  return ans;
599  }
600  free( tmp );
601  return string();
602 }
static void StarSystemGent::Tab ( )
static

Definition at line 219 of file galaxy_gen.cpp.

References f, i, and xmllevel.

Referenced by beginStar(), CreateStarSystem(), endStar(), MakeJump(), MakePlanet(), Tab(), XMLnode::Write(), WriteLight(), and WriteUnit().

220 {
221  for (int i = 0; i < xmllevel; i++)
222  f.Fprintf( "\t" );
223 }
void StarSystemGent::Updateradii ( float  orbitsize,
float  thisplanetradius 
)

Definition at line 516 of file galaxy_gen.cpp.

References radii.

Referenced by generateAndUpdateRS(), and MakeJump().

517 {
518 #ifdef HUGE_SYSTEMS
519  orbitsize += thisplanetradius;
520  radii.back() = orbitsize;
521 #endif
522 }
GradColor StarSystemGent::whichGradColor ( float  r,
unsigned int j 
)

Definition at line 383 of file galaxy_gen.cpp.

References colorGradiant, i, and readColorGrads().

Referenced by StarColor().

384 {
385  unsigned int i;
386  if ( colorGradiant.empty() ) {
387  vector< string >entity;
388  string fullpath = "stars.txt";
389  readColorGrads( entity, fullpath.c_str() );
390  }
391  for (i = 1; i < colorGradiant.size(); i++)
392  if (colorGradiant[i].minrad > r)
393  break;
394  j = i-1;
395  return colorGradiant[i-1];
396 }
void StarSystemGent::WriteLight ( unsigned int  i)

Definition at line 229 of file galaxy_gen.cpp.

References b, difffunc(), f, g, VegaConfig::getVariable(), lights, XMLSupport::parse_float(), Tab(), vs_config, and xmllevel.

Referenced by CreateLight().

230 {
231  static float ambientColorFactor = XMLSupport::parse_float( vs_config->getVariable( "galaxy", "AmbientLightFactor", "0" ) );
232  float ambient = (lights[i].r+lights[i].g+lights[i].b);
233 
234  ambient *= ambientColorFactor;
235  Tab();
236  f.Fprintf( "<Light>\n" );
237  xmllevel++;
238  Tab();
239  f.Fprintf( "<ambient red=\"%f\" green=\"%f\" blue=\"%f\"/>\n", ambient, ambient, ambient );
240  Tab();
241  f.Fprintf( "<diffuse red=\"%f\" green=\"%f\" blue=\"%f\"/>\n", difffunc( lights[i].r ), difffunc( lights[i].g ),
242  difffunc( lights[i].b ) );
243  Tab();
244  f.Fprintf( "<specular red=\"%f\" green=\"%f\" blue=\"%f\"/>\n", lights[i].nr, lights[i].ng, lights[i].nb );
245  xmllevel--;
246  Tab();
247  f.Fprintf( "</Light>\n" );
248 }
void StarSystemGent::WriteUnit ( const string &  tag,
const string &  name,
const string &  filename,
const Vector r,
const Vector s,
const Vector center,
const string &  nebfile,
const string &  destination,
bool  faction,
float  thisloy = 0 
)

Definition at line 556 of file galaxy_gen.cpp.

References f, faction, StarSystemGent::Vector::i, StarSystemGent::Vector::j, StarSystemGent::Vector::k, LengthOfYear(), and Tab().

Referenced by MakeBigUnit(), and MakeSmallUnit().

566 {
567  Tab();
568  f.Fprintf( "<%s name=\"%s\" file=\"%s\" ", tag.c_str(), name.c_str(), filename.c_str() );
569  if (nebfile.length() > 0)
570  f.Fprintf( "nebfile=\"%s\" ", nebfile.c_str() );
571  f.Fprintf( "ri=\"%f\" rj=\"%f\" rk=\"%f\" si=\"%f\" sj=\"%f\" sk=\"%f\" ", r.i, r.j, r.k, s.i, s.j, s.k );
572  f.Fprintf( "x=\"%f\" y=\"%f\" z=\"%f\" ", center.i, center.j, center.k );
573  float loy = LengthOfYear( r, s );
574  if (loy || thisloy)
575  f.Fprintf( "year= \"%f\" ", thisloy ? thisloy : loy );
576  if ( destination.length() )
577  f.Fprintf( "destination=\"%s\" ", destination.c_str() );
578  else if (faction)
579  f.Fprintf( "faction=\"%s\" ", StarSystemGent::faction.c_str() );
580  f.Fprintf( "/>\n" );
581 }

Variable Documentation

vector< string > StarSystemGent::background
vector< GradColor > StarSystemGent::colorGradiant

Definition at line 282 of file galaxy_gen.cpp.

Referenced by readColorGrads(), ResetGlobalVariables(), and whichGradColor().

float StarSystemGent::compactness = 2

Definition at line 283 of file galaxy_gen.cpp.

Referenced by generateCenter(), generateStarSystem(), makeRS(), and ResetGlobalVariables().

VSFile StarSystemGent::f

Definition at line 216 of file galaxy_gen.cpp.

string StarSystemGent::faction

Definition at line 281 of file galaxy_gen.cpp.

Referenced by AddMeshes(), AddSubUnits(), FactionUtil::AdjustIntRelation(), Faction::beginElement(), StarSystem::Statistics::CheckVitals(), CreateGameTurret(), CreateGenericTurret(), UnitFactory::createUnit(), HaloSystem::Draw(), GameUnit< UnitType >::Draw(), GameUnit< UnitType >::DrawNow(), NavigationSystem::DrawSystem(), Unit::EjectCargo(), GameUnit< UnitType >::Explode(), Unit::FilterDowngradeList(), generateStarSystem(), FactionUtil::GetAnimation(), FactionUtil::GetContraband(), FactionUtil::GetConversation(), StarDate::GetCurrentStarTime(), StarDate::GetElapsedStarTime(), FactionUtil::getForceLogo(), FactionUtil::GetNumAnimation(), FactionUtil::GetRandCommAnimation(), FactionUtil::getSquadLogo(), getStaticAsteroidFlightgroup(), getStaticBaseFlightgroup(), getStaticNebulaFlightgroup(), getStaticStarFlightgroup(), getStaticUnknownFlightgroup(), GetWarpMesh(), MeshAnimation::Init(), FactionUtil::isCitizenInt(), CriteriaOwnedBy::isDestination(), LaunchOneParticle(), Mesh::LoadMeshes(), FactionUtil::LoadSerializedFaction(), loadUnitByCache(), LookupUnitRow(), makeBlankUpgrade(), MakeJump(), makeTemplateUpgrade(), Mesh::Mesh(), Faction::ParseAllAllies(), Faction::ParseAllies(), UnitFactory::parseAsteroidBuffer(), UnitFactory::parseMissileBuffer(), UnitFactory::parseNebulaBuffer(), UnitFactory::parsePlanetBuffer(), UnitFactory::parseUnitBuffer(), fg_util::PurgeZeroShips(), Unit::reactToCollision(), Unit::RepairUpgrade(), ResetGlobalVariables(), ScoreKill(), FactionUtil::SerializeFaction(), Unit::SetFaction(), SaveGame::SetPlayerFaction(), setStaticFlightgroup(), GameUnit< UnitType >::Split(), BaseComputer::SellUpgradeOperation::start(), Unit::Upgrade(), and WriteUnit().

vector< string > StarSystemGent::gradtex

Definition at line 266 of file galaxy_gen.cpp.

Referenced by CreateLight(), generateStarSystem(), and ResetGlobalVariables().

const int StarSystemGent::JUMP = 3

Definition at line 261 of file galaxy_gen.cpp.

float StarSystemGent::jumpcompactness = 2

Definition at line 284 of file galaxy_gen.cpp.

Referenced by generateCenter(), generateStarSystem(), makeRS(), and ResetGlobalVariables().

vector< string > StarSystemGent::jumps
const float StarSystemGent::maxspeed = 8
const float StarSystemGent::minspeed = .001

Definition at line 278 of file galaxy_gen.cpp.

Referenced by LengthOfYear().

const int StarSystemGent::MOON = 2

Definition at line 260 of file galaxy_gen.cpp.

Referenced by MakeMoons(), and MakePlanet().

unsigned int StarSystemGent::moonlevel

Definition at line 312 of file galaxy_gen.cpp.

Referenced by MakeMoons(), MakePlanet(), and ResetGlobalVariables().

const float StarSystemGent::moonofmoonprob = .01

Definition at line 275 of file galaxy_gen.cpp.

const char StarSystemGent::nada[1] = ""

Definition at line 87 of file galaxy_gen.cpp.

Referenced by getGenericName(), and getRandName().

vector< string > StarSystemGent::names
vector< string > StarSystemGent::naturalphenomena

Definition at line 267 of file galaxy_gen.cpp.

Referenced by generateStarSystem(), MakeBigUnit(), and ResetGlobalVariables().

unsigned int StarSystemGent::numnaturalphenomena

Definition at line 270 of file galaxy_gen.cpp.

Referenced by beginStar(), generateStarSystem(), MakeBigUnit(), and ResetGlobalVariables().

unsigned int StarSystemGent::numstarbases
unsigned int StarSystemGent::numstarentities
const int StarSystemGent::PLANET = 1
unsigned int StarSystemGent::planetoffset

Definition at line 312 of file galaxy_gen.cpp.

Referenced by beginStar(), MakeMoons(), and ResetGlobalVariables().

vector< string > StarSystemGent::rings

Definition at line 274 of file galaxy_gen.cpp.

Referenced by generateStarSystem(), MakePlanet(), and ResetGlobalVariables().

const int StarSystemGent::STAR = 0

Definition at line 258 of file galaxy_gen.cpp.

Referenced by beginStar(), MakeBigUnit(), and MakeMoons().

vector< string > StarSystemGent::starbases

Definition at line 268 of file galaxy_gen.cpp.

Referenced by generateStarSystem(), MakeSmallUnit(), and ResetGlobalVariables().

vector< string > StarSystemGent::starentities

Definition at line 264 of file galaxy_gen.cpp.

Referenced by beginStar(), CreateLight(), and ResetGlobalVariables().

unsigned int StarSystemGent::staroffset

Definition at line 312 of file galaxy_gen.cpp.

Referenced by beginStar(), CreateFirstStar(), MakeMoons(), and ResetGlobalVariables().

vector< float > StarSystemGent::starradius
vector< StarInfo > StarSystemGent::stars

Definition at line 311 of file galaxy_gen.cpp.

Referenced by beginStar(), generateStarSystem(), MakeMoons(), and ResetGlobalVariables().

int StarSystemGent::xmllevel