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
NavigationSystem::SystemIterator Class Reference

#include <navscreen.h>

Public Member Functions

 SystemIterator (string current_system, unsigned int max=2)
 
bool done () const
 
QVector Position ()
 
string operator* ()
 
SystemIteratornext ()
 
SystemIteratoroperator++ ()
 

Detailed Description

Definition at line 21 of file navscreen.h.

Constructor & Destructor Documentation

NavigationSystem::SystemIterator::SystemIterator ( string  current_system,
unsigned int  max = 2 
)

Definition at line 238 of file drawgalaxy.cpp.

References max().

239 {
240  count = 0;
241  maxcount = max;
242  vstack.push_back( current_system );
243  visited[current_system] = true;
244  which = 0;
245 }

Member Function Documentation

bool NavigationSystem::SystemIterator::done ( ) const

Definition at line 247 of file drawgalaxy.cpp.

Referenced by GalaxyXML::SGalaxy::processGalaxy().

248 {
249  return which >= vstack.size();
250 }
NavigationSystem::SystemIterator & NavigationSystem::SystemIterator::next ( )

Definition at line 283 of file drawgalaxy.cpp.

284 {
285  return ++(*this);
286 }
string NavigationSystem::SystemIterator::operator* ( )

Definition at line 276 of file drawgalaxy.cpp.

277 {
278  if ( which < vstack.size() )
279  return vstack[which];
280  return "-";
281 }
NavigationSystem::SystemIterator & NavigationSystem::SystemIterator::operator++ ( )

Definition at line 302 of file drawgalaxy.cpp.

References UniverseUtil::GetAdjacentSystem(), UniverseUtil::GetNumAdjacentSystems(), i, j, and testandset().

303 {
304  which += 1;
305  if ( which >= vstack.size() ) {
306  vector< string >newsys;
307  for (unsigned int i = 0; i < vstack.size(); ++i) {
308  int nas = UniverseUtil::GetNumAdjacentSystems( vstack[i] );
309  for (int j = 0; j < nas; ++j) {
310  string n = UniverseUtil::GetAdjacentSystem( vstack[i], j );
311  if ( !testandset( visited[n], true ) )
312 //if (checkedVisited(n)) {
313  newsys.push_back( n );
314 //}
315  }
316  }
317  vstack.swap( newsys );
318  count += 1;
319  which = 0;
320  if (count > maxcount)
321  vstack.clear();
322  }
323  return *this;
324 }
QVector NavigationSystem::SystemIterator::Position ( )

Definition at line 252 of file drawgalaxy.cpp.

References _Universe, UniverseUtil::cos(), done, float, Universe::getGalaxyProperty(), k, QVector, screensmash, UniverseUtil::sin(), and start.

Referenced by GalaxyXML::SGalaxy::processGalaxy().

253 {
254  if ( done() )
255  return QVector( 0, 0, 0 );
256  string currentsystem = (**this);
257  string xyz = _Universe->getGalaxyProperty( currentsystem, "xyz" );
258  QVector pos;
259  if ( xyz.size() && (sscanf( xyz.c_str(), "%lf %lf %lf", &pos.i, &pos.j, &pos.k ) >= 3) ) {
260  pos.j = -pos.j;
261  return pos;
262  } else {
263  float ratio = ( (float) count )/maxcount;
264  float locatio = ( (float) which )/vstack.size();
265  unsigned int k = 0;
266  std::string::const_iterator start = vstack[which].begin();
267  std::string::const_iterator end = vstack[which].end();
268  for (; start != end; start++)
269  k += (k*128)+*start;
270  k %= 200000;
271 //float y = (k-100000)/(200000.);
272  return QVector( ratio*cos( locatio*2*3.1415926536 ), ratio*sin( locatio*2*3.1415926536 ), 0 )*screensmash;
273  }
274 }

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