22 using namespace GalaxyXML;
28 while ( star_system.size() ) {
29 star_system.back()->RemoveStarsystemFromUniverse();
30 delete star_system.back();
31 star_system.pop_back();
33 active_star_system.clear();
40 cockpit.push_back( cp );
56 Unit *closestUnit = NULL;
64 if (closestUnit == NULL || dist < lastdist) {
71 dock_position = closestUnit->
Position();
78 if ( i >= dprt.size() ) {
82 if (!dprt[i].IsOccupied())
94 safevec = dock_position;
95 return ( closestUnit && closestUnit->
isDocked( plr ) ) ? closestUnit : NULL;
102 if (!doNotDereference)
104 for (std::vector< Cockpit* >::iterator iter = cockpit.begin(); iter < cockpit.end(); iter++)
105 if ( doNotDereference == ( *(iter) )->GetParent() )
112 if (!doNotDereference)
114 for (
unsigned int i = 0;
i < cockpit.size();
i++)
115 if ( doNotDereference == cockpit[
i]->GetParent() )
123 if ( i < 0 || i >= cockpit.size() )
131 for (
unsigned int i = 0;
i < cockpit.size();
i++)
132 if (cockpit[
i] == cp) {
133 SetActiveCockpit(
i );
140 for (
unsigned int i = 0;
i < playerNames.size();
i++)
141 cockpit.push_back(
new Cockpit(
"", NULL, playerNames[
i] ) );
146 if ( ( *ss.begin() ) == drawn )
148 vector< StarSystem* >::iterator drw = std::find( ss.begin(), ss.end(), drawn );
149 if ( drw != ss.end() ) {
151 vector< StarSystem* >::iterator
i = ss.begin();
168 LoadFactionXML(
"factions.xml" );
171 script_system = NULL;
175 : current_cockpit( 0 )
176 , script_system( NULL )
178 this->
Init( galaxy_str );
184 : current_cockpit( 0 )
185 , script_system( NULL )
198 std::cerr<<
"Loading a starsystem"<<std::endl;
227 string fullname = systemfile+
".system";
233 vector< StarSystem* >::iterator iter;
244 using namespace VSFileSystem;
248 static bool ss_generating_active =
false;
251 static const std::string empty;
253 ss_generating_active =
true;
255 }
else if (ss_generating_active) {
257 ss_generating_active =
false;
273 string filestr( file );
281 LoadStarSystem( ss );
282 pushActiveStarSystem( ss );
283 static int num_times_to_simulate_new_star_system =
285 for (
unsigned int tume = 0; tume <= num_times_to_simulate_new_star_system*
SIM_QUEUE_SIZE+1; ++tume)
288 StarSystem *old_script_system = script_system;
291 const vector< std::string > &adjacent = getAdjacentStarSystems( ss->
getFileName() );
292 for (
unsigned int i = 0;
i < adjacent.size();
i++) {
295 static bool first =
true;
299 script_system = old_script_system;
300 popActiveStarSystem();
301 if ( active_star_system.empty() ) {
302 pushActiveStarSystem( ss );
305 activeStarSystem()->SwapIn();
318 this->Generate1( file, jumpback );
320 this->Generate2( ss );
327 float systime = nonactivesystemtime;
328 for (
unsigned int i = 0;
i < star_system.size(); ++
i)
330 star_system[
i]->
Update( (
i == 0) ? 1 : systime/
i );
335 for (
unsigned int i = 0;
i < star_system.size();
i++)
336 if (star_system[
i] == ss)
346 while (unitdata.length() != 0) {
347 string::size_type where = unitdata.find(
" " ), where2 = where;
348 if (where == string::npos)
349 where = unitdata.length();
350 string tmp = unitdata.substr( 0, where );
356 if (where2 == string::npos)
break;
357 unitdata = unitdata.substr( where+1, unitdata.length() );