本文整理汇总了C++中Mission::getVariable方法的典型用法代码示例。如果您正苦于以下问题:C++ Mission::getVariable方法的具体用法?C++ Mission::getVariable怎么用?C++ Mission::getVariable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mission
的用法示例。
在下文中一共展示了Mission::getVariable方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadFromNewGame
bool NetServer::loadFromNewGame( ClientPtr clt, Cockpit *cp, string fighter )
{
ObjSerial cltserial = getUniqueSerial();
string PLAYER_SHIPNAME = fighter;
Mission *mission = NULL;
if (active_missions.size() > 0)
mission = active_missions[0];
if (!mission) {
COUT<<"Cannot login player without acctserver: No missions available";
sendLoginError( clt );
return false;
}
int saved_faction = 0; //NETFIXME: Send faction over network too!
cp->savegame->SetSavedCredits( XMLSupport::parse_float( mission->getVariable( "credits", "0" ) ) );
cp->savegame->SetStarSystem( mission->getVariable( "system", "Sol/Sol" ) );
if ( !mission->flightgroups.empty() )
cp->savegame->SetPlayerFaction( mission->flightgroups[0]->faction );
COUT<<"\tcredits = "<<cp->savegame->GetSavedCredits()<<endl;
COUT<<"\tfaction = "<<cp->savegame->GetPlayerFaction()<<endl;
COUT<<"-> SAVE LOADED"<<endl;
cp->credits = cp->savegame->GetSavedCredits();
//WARNING : WE DON'T SAVE FACTION NOR FLIGHTGROUP YET
COUT<<"-> UNIT FACTORY WITH XML"<<endl;
//We may have to determine which is the current ship of the player if we handle several ships for one player
string PLAYER_FACTION_STRING = cp->savegame->GetPlayerFaction();
saved_faction = FactionUtil::GetFactionIndex( PLAYER_FACTION_STRING );
bool exist = true; //(VSFileSystem::LookForFile( savedships[0], VSFileSystem::UnitFile)<=VSFileSystem::Ok);
static std::string loadfailed( "LOAD_FAILED" );
Unit *un = NULL;
if ( !PLAYER_SHIPNAME.empty() ) {
un = UnitFactory::createUnit( PLAYER_SHIPNAME.c_str(),
false,
saved_faction,
string( "" ),
Flightgroup::newFlightgroup( clt->callsign, PLAYER_SHIPNAME, PLAYER_FACTION_STRING,
"default", 1, 1, "", "", mission ),
0 );
}
if (!un) {
exist = false;
} else if (un->name == loadfailed) {
exist = false;
un->Kill();
}
if (!exist) {
//We can't find the unit saved for player -> send a login error
this->sendLoginError( clt );
cerr<<"WARNING : Unit file ("<<PLAYER_SHIPNAME<<") not found for "<<clt->callsign<<endl;
return false;
}
COUT<<"\tAFTER UNIT FACTORY WITH XML"<<endl;
clt->game_unit.SetUnit( un );
//Assign its serial to client*
un->SetSerial( cltserial );
un->PrimeOrders(); //Accept Comm messages
//Affect the created unit to the cockpit
COUT<<"-> UNIT LOADED"<<endl;
QVector tmpvec( 0, 0, 0 );
cp->SetParent( un, PLAYER_SHIPNAME.c_str(), "", tmpvec );
COUT<<"-> COCKPIT AFFECTED TO UNIT"<<endl;
{
string savestr, xmlstr;
clt->savegame.resize( 0 );
//Get the save parts in a string array
cp->activeStarSystem = zonemgr->addZone( cp->savegame->GetStarSystem() ); //Needed for GetSaveStrings.
SaveNetUtil::GetSaveStrings( clt, savestr, xmlstr, true );
clt->savegame.push_back( savestr );
clt->savegame.push_back( xmlstr );
}
return true;
}