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
Universe Class Reference

#include <universe_generic.h>

Inheritance diagram for Universe:
GameUniverse

Public Member Functions

void netLock (bool enable)
 A list of all factions. More...
 
bool netLocked ()
 
bool isServer ()
 
CockpitisPlayerStarship (const Unit *fighter)
 
CockpitisPlayerStarshipVoid (const void *pointercompare)
 
int whichPlayerStarship (const Unit *fighter)
 
CockpitAccessCockpit ()
 
CockpitAccessCockpit (int i)
 
unsigned int CurrentCockpit ()
 
virtual CameraAccessCamera (int num)
 Wrapper function for Star System. More...
 
virtual CameraAccessCamera ()
 
virtual CameraAccessHudCamera ()
 Returns the current hud cam. More...
 
virtual void SetViewport ()
 Wrapper function for star system. More...
 
void SetActiveCockpit (int whichcockpit)
 
void SetActiveCockpit (Cockpit *which)
 
virtual void WriteSaveGame (bool auto_save)
 
virtual void SetupCockpits (std::vector< std::string >players)
 
virtual void activateLightMap (int stage=1)
 
virtual TexturegetLightMap ()
 
virtual void SelectCamera (int cam)
 
CockpitcreateCockpit (std::string player)
 
void getJumpPath (const std::string &from, const std::string &to, std::vector< std::string > &path) const
 
const std::vector< std::string > & getAdjacentStarSystems (const std::string &ss) const
 
std::string getGalaxyProperty (const std::string &sys, const std::string &prop)
 
std::string getGalaxyPropertyDefault (const std::string &sys, const std::string &prop, const std::string def="")
 
GalaxyXML::GalaxygetGalaxy ()
 
bool StillExists (StarSystem *ss)
 
void setActiveStarSystem (StarSystem *ss)
 
void pushActiveStarSystem (StarSystem *ss)
 
void popActiveStarSystem ()
 
void clearAllSystems ()
 
StarSystemgetActiveStarSystem (unsigned int size)
 
unsigned int getNumActiveStarSystem ()
 
void LoadStarSystem (StarSystem *ss)
 
void UnloadStarSystem (StarSystem *ss)
 
void Generate1 (const char *file, const char *jumpback)
 
void Generate2 (StarSystem *ss)
 
virtual StarSystemGenerateStarSystem (const char *file, const char *jumpback, Vector origin)
 
void LoadFactionXML (const char *factfile)
 Loads and parses factions. More...
 
 Universe ()
 inits graphics with args More...
 
 Universe (int argc, char **argv, const char *galaxy, bool server=false)
 
void Init (const char *gal)
 
virtual ~Universe ()
 
virtual class StarSystemInit (string systemfile, const Vector &centroid=Vector(0, 0, 0), const string planetname=string())
 Loads Defaults in Graphics Drivers. More...
 
virtual void StartDraw ()
 Begins a scene. More...
 
void Update ()
 
virtual void Loop (void f())
 Runs the main loop. More...
 
StarSystemactiveStarSystem ()
 returns active star system More...
 
unsigned int numPlayers ()
 Wrapper function for Star System. More...
 
StarSystemgetStarSystem (string name)
 Wrapper function for Star System. More...
 
StarSystemscriptStarSystem ()
 
bool setScriptSystem (string name)
 
int StarSystemIndex (StarSystem *ss)
 

Public Attributes

StarDate current_stardate
 
std::vector< StarSystem * > star_system
 

Protected Attributes

std::auto_ptr< GalaxyXML::Galaxygalaxy
 
unsigned int current_cockpit
 The users cockpit. More...
 
std::vector< Cockpit * > cockpit
 
std::vector< StarSystem * > active_star_system
 a generic camera facing the HUD More...
 
StarSystemscript_system
 
bool is_server
 
bool network_lock
 

Friends

class Faction
 Many C++ implementations count classes within as friends. (not all) More...
 

Detailed Description

Definition at line 50 of file universe_generic.h.

Constructor & Destructor Documentation

Universe::Universe ( )

inits graphics with args

Definition at line 183 of file universe_generic.cpp.

References is_server.

184  : current_cockpit( 0 )
185  , script_system( NULL )
186 {
187  is_server = false;
188 }
Universe::Universe ( int  argc,
char **  argv,
const char *  galaxy,
bool  server = false 
)

Definition at line 174 of file universe_generic.cpp.

References Init(), is_server, and network_lock.

175  : current_cockpit( 0 )
176  , script_system( NULL )
177 {
178  this->Init( galaxy_str );
179  network_lock = false;
180  is_server = server;
181 }
Universe::~Universe ( )
virtual

Definition at line 190 of file universe_generic.cpp.

References cockpit, and factions.

191 {
192  factions.clear();
193  cockpit.clear();
194 }

Member Function Documentation

virtual Camera* Universe::AccessCamera ( )
inlinevirtual

Reimplemented in GameUniverse.

Definition at line 109 of file universe_generic.h.

110  {
111  return NULL;
112  }
Cockpit* Universe::AccessCockpit ( )
inline

Definition at line 92 of file universe_generic.h.

References cockpit, and current_cockpit.

Referenced by CockpitKeys::_PitchDown(), CockpitKeys::_PitchUp(), CockpitKeys::_YawLeft(), CockpitKeys::_YawRight(), GameUniverse::AccessCamera(), NavPath::addNewPath(), AddUnitToSystem(), UniverseUtil::AdjustRelation(), FlyByWire::Afterburn(), CockpitKeys::Behind(), bootstrap_main_loop(), buildShipDescription(), BaseComputer::buySelectedCargo(), buyShip(), BaseComputer::buyUpgrade(), Mission::call_unit_launch(), checkedVisited(), Orders::FireAt::ChooseTargets(), clearSaveData(), clearSaveString(), Beam::Collide(), ComputeAutoGuarantee(), BaseComputer::BuyUpgradeOperation::concludeTransaction(), BaseComputer::SellUpgradeOperation::concludeTransaction(), BaseComputer::configureUpgradeCommitControls(), createObjects(), Unit::DealDamageToHullReturnArmor(), CommunicatingAI::Destroy(), ZoneInfo::display(), ZoneMgr::displayNPCs(), FireKeyboard::DockKey(), DockToSavedBases(), FireKeyboard::DoSpeechAndAni(), GameStarSystem::Draw(), GameUnit< UnitType >::Draw(), NavigationSystem::Draw(), NavigationSystem::DrawMission(), NavigationSystem::DrawObjectives(), NavigationSystem::DrawShip(), NavigationSystem::DrawSystem(), eraseSaveData(), eraseSaveString(), NavPath::evaluate(), ExamineWhenTargetKey(), Orders::AggressiveAI::Execute(), FireKeyboard::Execute(), Orders::FormUp::Execute(), Orders::FormUpToOwner::Execute(), FlyTo::Execute(), ExecuteDirector(), Orders::AggressiveAI::ExecuteNoEnemies(), GameUnit< UnitType >::Explode(), NetActionConfirm::finalizeJoinGame(), Mount::Fire(), Unit::ForceDock(), AbsolutePathNode::getDescription(), UniverseUtil::GetGalaxyFaction(), UnitUtil::getPhysicsPriority(), UniverseUtil::getPlayer(), UniverseUtil::getPlayerX(), CommunicatingAI::GetRandomUnit(), UniverseUtil::GetRelation(), getSaveData(), getSaveDataLength(), getSaveString(), getSaveStringLength(), SaveNetUtil::GetSaveStrings(), getStringList(), GetSystemColor(), UniverseUtil::getTargetLabel(), HelpOut(), CockpitKeys::InitPanInside(), CurrentPathNode::initSearchQueue(), TargetPathNode::initSearchQueue(), CockpitKeys::Inside(), CockpitKeys::InsideBack(), CockpitKeys::InsideLeft(), CockpitKeys::InsideRight(), CriteriaContains::isDestination(), CriteriaOwnedBy::isDestination(), CriteriaSector::isDestination(), CurrentPathNode::isDestination(), TargetPathNode::isDestination(), isPlayerFaction(), FireKeyboard::JoinFg(), FlyByKeyboard::JumpKey(), StarSystem::JumpTo(), LeadMe(), UniverseUtil::loadGame(), LoadMission(), BaseComputer::loadMissionsMasterList(), BaseComputer::loadShipDealerControls(), loadStringList(), CockpitKeys::LookDown(), CockpitKeys::LookLeft(), CockpitKeys::LookRight(), CockpitKeys::LookUp(), BaseComputer::maxQuantityForPlayer(), MyFunction(), GameCockpit::NavScreen(), NearestSystem(), NebulaUpdate(), CockpitKeys::OutsideTarget(), CockpitKeys::Pan(), CockpitKeys::PanTarget(), Unit::PerformDockingOperations(), FireKeyboard::ProcessCommMessage(), processDelayedMissions(), StarSystem::ProcessPendingJumps(), pushSaveData(), pushSaveString(), putSaveData(), putSaveString(), Enhancement::reactToCollision(), BaseComputer::recalcTitle(), UniverseUtil::receivedCustom(), NetClient::Reconnect(), RefreshGUI(), NavPath::removeOldPath(), NetClient::Respawn(), RespawnNow(), Unit::RestoreGodliness(), NetServer::saveAccount(), saveDataList(), UniverseUtil::saveGame(), saveStringList(), ScoreKill(), CockpitKeys::ScrollDown(), CockpitKeys::ScrollUp(), GameUniverse::SelectCamera(), BaseComputer::sellSelectedCargo(), BaseComputer::sellUpgrade(), NetServer::sendCustom(), NetServer::sendMessage(), NetServer::sendMission(), NetServer::sendSaveData(), NavPath::setDestinationNode(), UniverseUtil::SetGalaxyFaction(), NavPath::setSourceNode(), UniverseUtil::setTargetLabel(), NavigationSystem::Setup(), GameUniverse::SetViewport(), BaseComputer::showPlayerInfo(), starSystemOK(), GameUniverse::StartDraw(), NetClient::startGame(), SuicideKey(), CockpitKeys::SwitchLVDU(), CockpitKeys::SwitchMVDU(), CockpitKeys::SwitchRVDU(), CockpitKeys::SwitchULVDU(), CockpitKeys::SwitchUMVDU(), SwitchUnits(), SwitchUnits2(), CockpitKeys::SwitchURVDU(), SwitchVDUTo(), NetClient::synchronizeTime(), TargIncomingMissile(), Mission::terminateMission(), CockpitKeys::TextMessageCallback(), GameUnit< UnitType >::Thrust(), GameUnit< UnitType >::TransferUnitToSystem(), Unit::UnDock(), FireKeyboard::UnDockKey(), StarSystem::Update(), Cockpit::Update(), Cockpit::updateAttackers(), UpdateCameraSnds(), UpdateMasterPartList(), GameNebula::UpdatePhysics2(), BaseComputer::updateTransactionControlsForSelection(), CockpitKeys::ViewTarget(), GameUniverse::WriteSaveGame(), WriteSaveGame(), CockpitKeys::ZoomIn(), CockpitKeys::ZoomOut(), and CockpitKeys::ZoomReset().

93  {
94  return cockpit[current_cockpit];
95  }
Cockpit* Universe::AccessCockpit ( int  i)
inline

Definition at line 96 of file universe_generic.h.

References cockpit.

97  {
98  return cockpit[i];
99  }
virtual Camera* Universe::AccessHudCamera ( )
inlinevirtual

Returns the current hud cam.

Reimplemented in GameUniverse.

Definition at line 114 of file universe_generic.h.

115  {
116  return NULL;
117  }
virtual void Universe::activateLightMap ( int  stage = 1)
inlinevirtual
StarSystem* Universe::activeStarSystem ( )
inline

returns active star system

Definition at line 200 of file universe_generic.h.

References active_star_system.

Referenced by NetClient::AddClientObject(), AddUnitToSystem(), AllUnitsCloseAndEngage(), Arrested(), GameCockpit::AutoLanding(), Unit::AutoPilotToErrorMessage(), Bolt::Bolt(), BoltDestroyGeneric(), buyShip(), CalculateNearestWarpUnit(), CollideMap::CheckCollisions(), CollideChecker< T, canbebolt >::CheckCollisionsInner(), CollideMap::CheckUnitCollisions(), ChooseNavPoint(), ChooseNearNavPoint(), Orders::FireAt::ChooseTargets(), ChooseTargets(), Terrain::Collide(), Bolt::Collide(), Unit::Collide(), Bolt::CollideAnon(), CreateCargoForOwnerStarship(), createObjects(), Bolt::Destroy(), Missile::Discharge(), DoDockingOps(), Bolt::Draw(), GameStarSystem::Draw(), GameUnit< UnitType >::Draw(), GameCockpit::Draw(), UnitDrawer::draw(), NavigationSystem::DrawSystem(), GamePlanet::DrawTerrain(), Unit::EjectCargo(), FireKeyboard::Execute(), GameUnit< UnitType >::Explode(), Radar::Sensor::FindTracksInRange(), findUnitInStarsystem(), getAtmospheric(), NavigationSystem::getCurrentSystem(), NavigationSystem::getDestinationSystem(), NavigationSystem::getFocusedSystem(), getNearestTarget(), getNearestTargetUnit(), CommunicatingAI::GetRandomUnit(), NavigationSystem::getSelectedSystem(), Unit::getStarSystem(), GetThreat(), UnitUtil::getUnitSystemFile(), HelpOut(), CockpitKeys::Inside(), Unit::jumpReactToCollision(), StarSystem::JumpTo(), KillDuplicateUnits(), LoadMission(), main_loop(), Mount::PhysicsAlignedFire(), Orders::AggressiveAI::ProcessCurrentFgDirective(), processDelayedMissions(), StarSystem::ProcessPendingJumps(), Unit::RemoveFromSystem(), NetClient::Respawn(), RestoreFirstPassState(), Unit::ReTargetFg(), UniverseUtil::SafeEntrancePoint(), scriptStarSystem(), sellShip(), NetServer::sendJump(), NetServer::sendMessage(), Orders::FormUpToOwner::SetParent(), Cockpit::SetParent(), NavigationSystem::Setup(), starSystemOK(), GameUniverse::StartDraw(), UniverseUtil::StopTargettingEachOther(), SwapInNewShipName(), TableLocationChanged(), Unit::Target(), UniverseUtil::TargetEachOther(), GameUnit< UnitType >::TransferUnitToSystem(), UnDockNow(), Unit::UpAndDownGrade(), Bolt::Update(), Atmosphere::Update(), Cockpit::Update(), Cockpit::updateAttackers(), UpdateBackpointers< Unit::UNIT_ONLY >::updateBackpointer(), Unit::UpdatePhysics(), GameNebula::UpdatePhysics2(), Unit::UpdateSubunitPhysics(), GameUniverse::WriteSaveGame(), and StarSystem::~StarSystem().

201  {
202  return active_star_system.empty() ? NULL
203  : active_star_system.back();
204  }
void Universe::clearAllSystems ( )

Definition at line 26 of file universe_generic.cpp.

Referenced by NetActionConfirm::finalizeJoinGame(), NetClient::Reconnect(), NetClient::Respawn(), NetClient::startGame(), and Cockpit::Update().

27 {
28  while ( star_system.size() ) {
29  star_system.back()->RemoveStarsystemFromUniverse();
30  delete star_system.back();
31  star_system.pop_back();
32  }
33  active_star_system.clear();
34  script_system = NULL;
35 }
Cockpit * Universe::createCockpit ( std::string  player)

Definition at line 37 of file universe_generic.cpp.

Referenced by NetClient::startGame().

38 {
39  Cockpit *cp = new Cockpit( "", NULL, player );
40  cockpit.push_back( cp );
41  return cp;
42 }
void Universe::Generate1 ( const char *  file,
const char *  jumpback 
)

Definition at line 261 of file universe_generic.cpp.

References UniverseUtil::ComputeSystemSerials(), f, VegaConfig::getVariable(), MakeStarSystem(), VSFileSystem::Ok, VSFileSystem::VSFile::OpenReadOnly(), XMLSupport::parse_bool(), RemoveDotSystem(), SERVER, ss_generating(), VSFileSystem::SystemFile, and vs_config.

Referenced by GameUniverse::GenerateStarSystem().

262 {
263  int count = 0;
264  static bool show_loading = XMLSupport::parse_bool( vs_config->getVariable( "splash", "while_loading_starsystem", "false" ) );
265  if (show_loading)
266  ss_generating( true );
267  VSFile f;
268  VSError err = f.OpenReadOnly( file, SystemFile );
269  //If the file is not found we generate a system
270  if (err > Ok)
271  MakeStarSystem( file, galaxy.get(), RemoveDotSystem( jumpback ), count );
272  if (SERVER) {
273  string filestr( file );
275  }
276 }
void Universe::Generate2 ( StarSystem ss)

Definition at line 278 of file universe_generic.cpp.

References Mission::DirectorStartStarSystem(), first(), firsttime, StarSystem::getFileName(), VegaConfig::getVariable(), i, mission, XMLSupport::parse_int(), SIM_QUEUE_SIZE, ss_generating(), StarSystem::SwapOut(), StarSystem::UpdateUnitPhysics(), vs_config, and VSFileSystem::vs_fprintf().

Referenced by GameUniverse::GenerateStarSystem().

279 {
280  static bool firsttime = true;
281  LoadStarSystem( ss );
282  pushActiveStarSystem( ss );
283  static int num_times_to_simulate_new_star_system =
284  XMLSupport::parse_int( vs_config->getVariable( "physics", "num_times_to_simulate_new_star_system", "20" ) );
285  for (unsigned int tume = 0; tume <= num_times_to_simulate_new_star_system*SIM_QUEUE_SIZE+1; ++tume)
286  ss->UpdateUnitPhysics( true );
287  //notify the director that a new system is loaded (gotta have at least one active star system)
288  StarSystem *old_script_system = script_system;
289  script_system = ss;
290  VSFileSystem::vs_fprintf( stderr, "Loading Star System %s\n", ss->getFileName().c_str() );
291  const vector< std::string > &adjacent = getAdjacentStarSystems( ss->getFileName() );
292  for (unsigned int i = 0; i < adjacent.size(); i++) {
293  VSFileSystem::vs_fprintf( stderr, " Next To: %s\n", adjacent[i].c_str() );
294  }
295  static bool first = true;
296  if (!first)
298  first = false;
299  script_system = old_script_system;
301  if ( active_star_system.empty() ) {
302  pushActiveStarSystem( ss );
303  } else {
304  ss->SwapOut();
306  }
307  if (firsttime) {
308  firsttime = false;
309  } else {}
310  ss_generating( false );
311 }
StarSystem * Universe::GenerateStarSystem ( const char *  file,
const char *  jumpback,
Vector  origin 
)
virtual

Reimplemented in GameUniverse.

Definition at line 313 of file universe_generic.cpp.

References GetLoadedStarSystem(), and StarSystem::StarSystem().

Referenced by ZoneMgr::addZone(), Init(), StarSystem::JumpTo(), UniverseUtil::pushSystem(), NetClient::Respawn(), and Cockpit::Update().

314 {
315  StarSystem *tmpcache;
316  if ( ( tmpcache = GetLoadedStarSystem( file ) ) )
317  return tmpcache;
318  this->Generate1( file, jumpback );
319  StarSystem *ss = new StarSystem( file, center );
320  this->Generate2( ss );
321  return ss;
322 }
StarSystem* Universe::getActiveStarSystem ( unsigned int  size)
inline
const vector< std::string > & Universe::getAdjacentStarSystems ( const std::string &  ss) const

Definition at line 258 of file galaxy.cpp.

References getStarSystemName(), getStarSystemSector(), ParseDestinations(), and RemoveDotSystem().

Referenced by UniverseUtil::GetAdjacentSystem(), UniverseUtil::GetNumAdjacentSystems(), and NavigationSystem::CachedSystemIterator::SystemInfo::loadData().

259 {
260  string sector = getStarSystemSector( file );
261  string name = RemoveDotSystem( getStarSystemName( file ).c_str() );
262  return ParseDestinations( galaxy->getVariable( sector, name, "jumps", "" ) );
263 }
std::string Universe::getGalaxyProperty ( const std::string &  sys,
const std::string &  prop 
)

Definition at line 243 of file galaxy.cpp.

References getStarSystemName(), getStarSystemSector(), and RemoveDotSystem().

Referenced by AllocVerticesForSystem(), BaseComputer::getColorForGroup(), UniverseUtil::GetGalaxyFaction(), UniverseUtil::GetGalaxyProperty(), NavigationSystem::CachedSystemIterator::SystemInfo::loadData(), NavigationSystem::SystemIterator::Position(), and SystemLocation().

244 {
245  string sector = getStarSystemSector( sys );
246  string name = RemoveDotSystem( getStarSystemName( sys ).c_str() );
247  return galaxy->getVariable( sector, name, prop,
248  galaxy->getVariable( sector, prop, galaxy->getVariable( "unknown_sector", "min", prop, "" ) ) );
249 }
std::string Universe::getGalaxyPropertyDefault ( const std::string &  sys,
const std::string &  prop,
const std::string  def = "" 
)

Definition at line 251 of file galaxy.cpp.

References getStarSystemName(), getStarSystemSector(), and RemoveDotSystem().

Referenced by UniverseUtil::GetGalaxyPropertyDefault().

252 {
253  string sector = getStarSystemSector( sys );
254  string name = RemoveDotSystem( getStarSystemName( sys ).c_str() );
255  return galaxy->getVariable( sector, name, prop, def );
256 }
void Universe::getJumpPath ( const std::string &  from,
const std::string &  to,
std::vector< std::string > &  path 
) const

Definition at line 265 of file galaxy.cpp.

References i.

Referenced by CreateCargoForOwnerStarship(), and UniverseUtil::GetJumpPath().

266 {
267  map< string, unsigned int > visited;
268  vector< const string* > origin;
269  deque< const string* > open;
270 
271  // seed with starting point
272  visited[from] = 0;
273  origin.push_back(NULL);
274  open.push_back(&from);
275 
276  // Textbook BFS search
277  while (!open.empty()) {
278  const string *system = open.front();
279  open.pop_front();
280 
281  const vector< std::string > &adjacent = getAdjacentStarSystems(*system);
282  for (vector< std::string >::const_iterator i = adjacent.begin(); i != adjacent.end(); ++i) {
283  map< string, unsigned int >::const_iterator velem = visited.find(*i);
284  if (velem == visited.end()) {
285  visited[*i] = origin.size();
286  origin.push_back(system);
287  velem = visited.find(*i);
288 
289  if (*i == to) {
290  // finished we are
291  open.clear();
292  break;
293  } else {
294  open.push_back(&velem->first);
295  }
296  }
297  }
298  }
299 
300  // Backtrack to get a reverse path
301  path.clear();
302  map< string, unsigned int >::const_iterator velem = visited.find(to);
303  while (velem != visited.end()) {
304  path.push_back(velem->first);
305  if (origin[velem->second] == NULL)
306  velem = visited.end();
307  else
308  velem = visited.find(*origin[velem->second]);
309  }
310 
311  // Reverse to get the straight path
312  reverse(path.begin(), path.end());
313 }
virtual Texture* Universe::getLightMap ( )
inlinevirtual

Reimplemented in GameUniverse.

Definition at line 125 of file universe_generic.h.

Referenced by Background::Draw().

126  {
127  return NULL;
128  }
unsigned int Universe::getNumActiveStarSystem ( )
inline

Definition at line 165 of file universe_generic.h.

References active_star_system.

Referenced by Unit::UpAndDownGrade(), Cockpit::Update(), and StarSystem::~StarSystem().

166  {
167  return active_star_system.size();
168  }
StarSystem * Universe::getStarSystem ( string  name)

Wrapper function for Star System.

Wrapper function for star system Returns the current hud cam Wrapper function for star system

Definition at line 231 of file universe_generic.cpp.

References StarSystem::getName(), StarSystem::name, and star_system.

Referenced by setScriptSystem().

232 {
233  vector< StarSystem* >::iterator iter;
234  for (iter = star_system.begin(); iter != star_system.end(); iter++) {
235  StarSystem *ss = *iter;
236  if (ss->getName() == name)
237  return ss;
238  }
239  return NULL;
240 }
void Universe::Init ( const char *  gal)

Definition at line 161 of file universe_generic.cpp.

References firsttime, ROLES::getAllRolePriorities(), LoadWeapons(), and VSFileSystem::weapon_list.

Referenced by bootstrap_main_loop(), GameUniverse::Init(), NetClient::startGame(), and Universe().

162 {
165  galaxy.reset(new GalaxyXML::Galaxy( gal ));
166  static bool firsttime = false;
167  if (!firsttime) {
168  LoadFactionXML( "factions.xml" );
169  firsttime = true;
170  }
171  script_system = NULL;
172 }
StarSystem * Universe::Init ( string  systemfile,
const Vector centroid = Vector( 0,                                                                                         0,                                                                                         0 ),
const string  planetname = string() 
)
virtual

Loads Defaults in Graphics Drivers.

Should load the Universe data file. Now just inits system with test.xml

Reimplemented in GameUniverse.

Definition at line 225 of file universe_generic.cpp.

References GenerateStarSystem().

226 {
227  string fullname = systemfile+".system";
228  return GenerateStarSystem( (char*) fullname.c_str(), "", centr );
229 }
Cockpit * Universe::isPlayerStarship ( const Unit fighter)

Definition at line 99 of file universe_generic.cpp.

Referenced by BaseComputer::actionConfirmedLoadGame(), BaseComputer::actionConfirmedSaveGame(), BaseComputer::actionLoadGame(), BaseComputer::actionSaveGame(), UnitUtil::addCredits(), Unit::AddVelocity(), Unit::ApplyDamage(), Unit::ApplyLocalDamage(), Unit::ApplyNetDamage(), GameUnit< UnitType >::ArmorDamageSound(), Unit::AutoPilotToErrorMessage(), Mission::call_unit_launch(), Beam::Collide(), Unit::Collide(), UnitUtil::commAnimation(), UnitUtil::communicateTo(), ComputeAutoGuarantee(), Unit::DealDamageToHullReturnArmor(), GameUnit< UnitType >::DealDamageToShield(), ZoneInfo::display(), Unit::EjectCargo(), FlyByKeyboard::Execute(), FireKeyboard::Execute(), FlyByWire::Execute(), GameUnit< UnitType >::Explode(), Unit::FilterUpgradeList(), BaseComputer::fixUpgrade(), Pilot::getAnger(), UnitUtil::getCredits(), UnitUtil::getPhysicsPriority(), Unit::getStarSystem(), Unit::getTractorability(), Unit::GetVelocityDifficultyMult(), GameUnit< UnitType >::HullDamageSound(), isPlayerStarshipVoid(), BaseComputer::isTransactionOK(), Unit::jumpReactToCollision(), StarSystem::JumpTo(), LeadMe(), GameCockpit::OnDockEnd(), GameCockpit::OnJumpBegin(), GameCockpit::OnJumpEnd(), StarSystem::ProcessPendingJumps(), GamePlanet::reactToCollision(), Unit::reactToCollision(), Unit::RegenShields(), Unit::ResolveForces(), BaseComputer::sellShip(), sellShip(), Orders::FireAt::ShouldFire(), Unit::Target(), GameUnit< UnitType >::Thrust(), Unit::TransferUnitToSystem(), Cockpit::Update(), Unit::UpdatePhysics(), Unit::UpdatePhysics2(), and WARPENERGYMULTIPLIER().

100 {
101  using std::vector;
102  if (!doNotDereference)
103  return NULL;
104  for (std::vector< Cockpit* >::iterator iter = cockpit.begin(); iter < cockpit.end(); iter++)
105  if ( doNotDereference == ( *(iter) )->GetParent() )
106  return *(iter);
107  return NULL;
108 }
Cockpit* Universe::isPlayerStarshipVoid ( const void *  pointercompare)
inline

Definition at line 85 of file universe_generic.h.

References isPlayerStarship().

Referenced by Unit::ApplyDamage(), Orders::TurretAI::Execute(), and Mount::PhysicsAlignedFire().

86  {
87 //void *newp = const_cast<void *>(pointercompare);
88 //return this->isPlayerStarship(reinterpret_cast<Unit*>(newp));
89  return isPlayerStarship( (const Unit*) pointercompare );
90  }
bool Universe::isServer ( )
inline

Definition at line 80 of file universe_generic.h.

References is_server.

81  {
82  return is_server;
83  }
void Universe::LoadFactionXML ( const char *  factfile)
inline

Loads and parses factions.

Definition at line 175 of file universe_generic.h.

References Faction::LoadXML().

176  {
177  Faction::LoadXML( factfile );
178  }
void Universe::LoadStarSystem ( StarSystem ss)

Definition at line 196 of file universe_generic.cpp.

References SortStarSystems(), and star_system.

197 {
198  std::cerr<<"Loading a starsystem"<<std::endl;
199  star_system.push_back( s );
200  SortStarSystems( star_system, s ); //dont' want instadie
201 }
virtual void Universe::Loop ( void   f())
inlinevirtual

Runs the main loop.

Reimplemented in GameUniverse.

Definition at line 198 of file universe_generic.h.

References f.

Referenced by bootstrap_first_loop(), bootstrap_main_loop(), and main().

198 {}
void Universe::netLock ( bool  enable)

A list of all factions.

Definition at line 213 of file universe_generic.cpp.

References Network, network_lock, and SERVER.

Referenced by ZoneMgr::addClient(), ZoneMgr::addZone(), UnitFactory::createPlanet(), and Unit::Kill().

214 {
215  network_lock = false;
216  if (Network || SERVER)
217  network_lock = enable;
218 }
bool Universe::netLocked ( )
StarSystem* Universe::scriptStarSystem ( )
inline

Definition at line 241 of file universe_generic.h.

References activeStarSystem(), and script_system.

Referenced by Mission::call_unit_launch().

242  {
243  if (script_system != NULL) return script_system;
244 
245  else return activeStarSystem();
246  ;
247  }
virtual void Universe::SelectCamera ( int  cam)
inlinevirtual

Reimplemented in GameUniverse.

Definition at line 129 of file universe_generic.h.

129 {}
void Universe::SetActiveCockpit ( int  whichcockpit)

Definition at line 120 of file universe_generic.cpp.

References VSFileSystem::vs_fprintf().

Referenced by createObjects(), ExecuteDirector(), kbGetInput(), processDelayedMissions(), UniverseUtil::receivedCustom(), NetClient::Respawn(), GameUniverse::StartDraw(), and StarSystem::Update().

121 {
122 #ifdef VS_DEBUG
123  if ( i < 0 || i >= cockpit.size() )
124  VSFileSystem::vs_fprintf( stderr, "ouch invalid cockpit %d", i );
125 #endif
126  current_cockpit = i;
127 }
void Universe::SetActiveCockpit ( Cockpit which)

Definition at line 129 of file universe_generic.cpp.

References i.

130 {
131  for (unsigned int i = 0; i < cockpit.size(); i++)
132  if (cockpit[i] == cp) {
133  SetActiveCockpit( i );
134  return;
135  }
136 }
void Universe::setActiveStarSystem ( StarSystem ss)
inline

Definition at line 142 of file universe_generic.h.

References active_star_system, and pushActiveStarSystem().

Referenced by StarSystem::ProcessPendingJumps(), and GameUnit< UnitType >::TransferUnitToSystem().

143  {
144  if ( active_star_system.empty() )
145  pushActiveStarSystem( ss );
146  else
147  active_star_system.back() = ss;
148  }
bool Universe::setScriptSystem ( string  name)
inline

Definition at line 248 of file universe_generic.h.

References getStarSystem(), and script_system.

249  {
250  if (name == "-active-") {
251  script_system = NULL;
252  return true;
253  }
254  StarSystem *ss = getStarSystem( name );
255  if (script_system != NULL) {
256  script_system = ss;
257  return true;
258  }
259  return false;
260  }
void Universe::SetupCockpits ( std::vector< std::string >  players)
virtual

Reimplemented in GameUniverse.

Definition at line 138 of file universe_generic.cpp.

References i.

Referenced by bootstrap_main_loop().

139 {
140  for (unsigned int i = 0; i < playerNames.size(); i++)
141  cockpit.push_back( new Cockpit( "", NULL, playerNames[i] ) );
142 }
virtual void Universe::SetViewport ( )
inlinevirtual

Wrapper function for star system.

Reimplemented in GameUniverse.

Definition at line 119 of file universe_generic.h.

119 {}
int Universe::StarSystemIndex ( StarSystem ss)

Definition at line 333 of file universe_generic.cpp.

References i.

334 {
335  for (unsigned int i = 0; i < star_system.size(); i++)
336  if (star_system[i] == ss)
337  return i;
338  return -1;
339 }
virtual void Universe::StartDraw ( )
inlinevirtual

Begins a scene.

Reimplemented in GameUniverse.

Definition at line 194 of file universe_generic.h.

Referenced by main_loop().

194 {}
bool Universe::StillExists ( StarSystem ss)

Definition at line 203 of file universe_generic.cpp.

References star_system.

Referenced by StarSystem::ProcessPendingJumps().

204 {
205  return std::find( star_system.begin(), star_system.end(), s ) != star_system.end();
206 }
void Universe::UnloadStarSystem ( StarSystem ss)

Definition at line 220 of file universe_generic.cpp.

221 {
222  //not sure what to do here? serialize?
223 }
void Universe::Update ( )

Definition at line 324 of file universe_generic.cpp.

References VegaConfig::getVariable(), i, XMLSupport::parse_floatf(), StarSystem::Update(), and vs_config.

Referenced by GameUniverse::StartDraw().

325 {
326  static float nonactivesystemtime = XMLSupport::parse_floatf( vs_config->getVariable( "physics", "InactiveSystemTime", ".3" ) );
327  float systime = nonactivesystemtime;
328  for (unsigned int i = 0; i < star_system.size(); ++i)
329  //Calls the update function for server
330  star_system[i]->Update( (i == 0) ? 1 : systime/i );
331 }
virtual void Universe::WriteSaveGame ( bool  auto_save)
inlinevirtual

Reimplemented in GameUniverse.

Definition at line 122 of file universe_generic.h.

Referenced by cleanup(), and CockpitKeys::QuitNow().

122 {}

Friends And Related Function Documentation

friend class Faction
friend

Many C++ implementations count classes within as friends. (not all)

Definition at line 71 of file universe_generic.h.

Member Data Documentation

std::vector< StarSystem* > Universe::active_star_system
protected

a generic camera facing the HUD

init proc currently only 1 star system is stored

Definition at line 62 of file universe_generic.h.

Referenced by activeStarSystem(), getActiveStarSystem(), getNumActiveStarSystem(), popActiveStarSystem(), pushActiveStarSystem(), setActiveStarSystem(), and GameUniverse::StartDraw().

std::vector< Cockpit* > Universe::cockpit
protected
unsigned int Universe::current_cockpit
protected

The users cockpit.

Definition at line 55 of file universe_generic.h.

Referenced by AccessCockpit(), CurrentCockpit(), and GameUniverse::Init().

std::auto_ptr<GalaxyXML::Galaxy> Universe::galaxy
protected

Definition at line 53 of file universe_generic.h.

Referenced by getGalaxy().

bool Universe::is_server
protected

Definition at line 66 of file universe_generic.h.

Referenced by GameUniverse::GameUniverse(), isServer(), and Universe().

bool Universe::network_lock
protected

Definition at line 67 of file universe_generic.h.

Referenced by netLock(), netLocked(), and Universe().

StarSystem* Universe::script_system
protected

Definition at line 65 of file universe_generic.h.

Referenced by scriptStarSystem(), and setScriptSystem().


The documentation for this class was generated from the following files: