本文整理汇总了C++中StarSystem::SwapIn方法的典型用法代码示例。如果您正苦于以下问题:C++ StarSystem::SwapIn方法的具体用法?C++ StarSystem::SwapIn怎么用?C++ StarSystem::SwapIn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StarSystem
的用法示例。
在下文中一共展示了StarSystem::SwapIn方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: StartDraw
void GameUniverse::StartDraw()
{
#ifndef WIN32
RESETTIME();
#endif
GFXBeginScene();
unsigned int i;
StarSystem * lastStarSystem = NULL;
for (i=0;i<cockpit.size();++i) {
SetActiveCockpit (i);
float x,y,w,h;
CalculateCoords (i,cockpit.size(),x,y,w,h);
AccessCamera()->SetSubwindow (x,y,w,h);
if (cockpit.size()>1&&AccessCockpit(i)->activeStarSystem!=lastStarSystem) {
active_star_system[0]->SwapOut();
lastStarSystem=AccessCockpit()->activeStarSystem;
active_star_system[0]=lastStarSystem;
lastStarSystem->SwapIn();
}
AccessCockpit()->SelectProperCamera();
if (cockpit.size()>0)
AccessCamera()->UpdateGFX();
if (!RefreshGUI() && !UniverseUtil::isSplashScreenShowing()) {
activeStarSystem()->Draw();
}
AccessCamera()->SetSubwindow (0,0,1,1);
}
UpdateTime();
UpdateTimeCompressionSounds();
_Universe->SetActiveCockpit (((int)(rand01()*cockpit.size()))%cockpit.size());
for (i=0;i<star_system.size()&&i<game_options.NumRunningSystems;++i) {
star_system[i]->Update((i==0)?1:game_options.InactiveSystemTime/i,true);
}
StarSystem::ProcessPendingJumps();
for (i=0;i<cockpit.size();++i) {
SetActiveCockpit(i);
pushActiveStarSystem(AccessCockpit(i)->activeStarSystem);
ProcessInput(i); //input neesd to be taken care of;
popActiveStarSystem();
}
if (screenshotkey) {
KBData b;
Screenshot(b,PRESS);
screenshotkey=false;
}
GFXEndScene();
//so we don't starve the audio thread
micro_sleep (getmicrosleep());
//remove systems not recently visited?
static int sorttime=0;
if (game_options.garbagecollectfrequency!=0) {
//don't want to delete something when there is something pending to jump therexo
if (PendingJumpsEmpty()) {
if ((++sorttime)%game_options.garbagecollectfrequency==1) {
SortStarSystems(star_system,active_star_system.back());
if (star_system.size() > game_options.numoldsystems && game_options.deleteoldsystems) {
if (std::find (active_star_system.begin(),active_star_system.end(),star_system.back())==active_star_system.end()) {
delete star_system.back();
star_system.pop_back();
}
else {
VSFileSystem::vs_fprintf (stderr,"error with active star system list\n");
}
}
}
}
}
}
示例2: Update
//.........这里部分代码省略.........
if (active_missions.size() > 1) {
for (int i = active_missions.size()-1; i > 0; --i) //don't terminate zeroth mission
if (active_missions[i]->player_num == k)
active_missions[i]->terminateMission();
}
unsigned int whichcp = k;
string newsystem;
QVector pos;
bool setplayerXloc;
savegame->SetStarSystem( "" );
QVector tmpoldpos = savegame->GetPlayerLocation();
savegame->SetPlayerLocation( QVector( FLT_MAX, FLT_MAX, FLT_MAX ) );
vector< string > packedInfo;
savegame->ParseSaveGame( savegamefile,
newsystem,
newsystem,
pos,
setplayerXloc,
this->credits,
packedInfo,
k );
UnpackUnitInfo(packedInfo);
if (pos.i == FLT_MAX && pos.j == FLT_MAX && pos.k == FLT_MAX)
pos = tmpoldpos;
savegame->SetPlayerLocation( pos );
CopySavedShips( savegame->GetCallsign(), whichcp, packedInfo, true );
bool actually_have_save = false;
static bool persistent_on_load =
XMLSupport::parse_bool( vs_config->getVariable( "physics", "persistent_on_load", "true" ) );
if (savegame->GetStarSystem() != "") {
actually_have_save = true;
newsystem = savegame->GetStarSystem()+".system";
} else {
newsystem = _Universe->activeStarSystem()->getFileName();
if (newsystem.find( ".system" ) == string::npos)
newsystem += ".system";
}
Background::BackgroundClone savedtextures = {
{NULL, NULL, NULL, NULL, NULL, NULL, NULL}
};
if (persistent_on_load) {
_Universe->getActiveStarSystem( 0 )->SwapOut();
} else {
Background *tmp = _Universe->activeStarSystem()->getBackground();
savedtextures = tmp->Cache();
_Universe->clearAllSystems();
}
StarSystem *ss = _Universe->GenerateStarSystem( newsystem.c_str(), "", Vector( 0, 0, 0 ) );
if (!persistent_on_load)
savedtextures.FreeClone();
this->activeStarSystem = ss;
_Universe->pushActiveStarSystem( ss );
vector< StarSystem* >saved;
while ( _Universe->getNumActiveStarSystem() ) {
saved.push_back( _Universe->activeStarSystem() );
_Universe->popActiveStarSystem();
}
if ( !saved.empty() )
saved.back() = ss;
unsigned int mysize = saved.size();
for (unsigned int i = 0; i < mysize; i++) {
_Universe->pushActiveStarSystem( saved.back() );
saved.pop_back();
}
ss->SwapIn();
int fgsnumber = 0;
if (fg) {
fgsnumber = fg->flightgroup_nr++;
fg->nr_ships++;
fg->nr_ships_left++;
}
Unit *un = UnitFactory::createUnit(
GetUnitFileName().c_str(), false, this->unitfaction, unitmodname, fg, fgsnumber );
un->SetCurPosition( UniverseUtil::SafeEntrancePoint( savegame->GetPlayerLocation() ) );
ss->AddUnit( un );
this->SetParent( un, GetUnitFileName().c_str(), unitmodname.c_str(), savegame->GetPlayerLocation() );
SwitchUnits( NULL, un );
this->credits = savegame->GetSavedCredits();
DoCockpitKeys();
_Universe->popActiveStarSystem();
_Universe->pushActiveStarSystem( ss );
savegame->ReloadPickledData();
savegame->LoadSavedMissions();
if (actually_have_save && !SERVER && Network == NULL) {
QVector vec;
DockToSavedBases( whichcp, vec );
}
UniverseUtil::hideSplashScreen();
_Universe->popActiveStarSystem();
if (!persistent_on_load)
_Universe->pushActiveStarSystem( ss );
return true;
}
}
}
}
return false;
}