本文整理汇总了C++中NetBuffer::Reset方法的典型用法代码示例。如果您正苦于以下问题:C++ NetBuffer::Reset方法的具体用法?C++ NetBuffer::Reset怎么用?C++ NetBuffer::Reset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NetBuffer
的用法示例。
在下文中一共展示了NetBuffer::Reset方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sendLoginAccept
void NetServer::sendLoginAccept( ClientPtr clt, Cockpit *cp )
{
COUT<<"enter "<<__PRETTY_FUNCTION__<<endl;
//Verify that client already has a character
NetBuffer netbuf;
Unit *un = cp->GetParent();
if (!un) {
sendLoginError( clt );
return;
}
//Put the save parts in buffers in order to load them properly
netbuf.Reset();
string datestr = _Universe->current_stardate.GetFullTrekDate();
netbuf.addString( datestr );
netbuf.addString( clt->savegame[0] );
netbuf.addString( clt->savegame[1] );
Packet packet2;
//Create a cockpit for the player and parse its savegame
ObjSerial cltserial = un->GetSerial();
COUT<<">>> SEND LOGIN ACCEPT =( serial #"<<cltserial<<" )= --------------------------------------"<<endl;
COUT<<"SAVE="<<clt->savegame[0].length()<<" bytes - XML="<<clt->savegame[1].length()<<" bytes"<<endl;
cerr<<"SENDING STARDATE : "<<datestr<<endl;
//Add the initial star system filename + hash if crypto++ support too
string sysname = cp->savegame->GetStarSystem();
string relsys = sysname+".system";
netbuf.addString( relsys );
//Generate the starsystem before addclient so that it already contains serials
StarSystem *sts = zonemgr->addZone( sysname );
#ifdef CRYPTO
unsigned char *digest = new unsigned char[FileUtil::Hash.DigestSize()];
string sysxml;
if ( !( sysxml = zonemgr->getSystem( relsys ) ).empty() )
FileUtil::HashStringCompute( sysxml, digest );
else if ( !sysname.empty() )
FileUtil::HashFileCompute( relsys, digest, SystemFile );
netbuf.addShort( FileUtil::Hash.DigestSize() );
netbuf.addBuffer( digest, FileUtil::Hash.DigestSize() );
delete[] digest;
#else
netbuf.addShort( 0 );
#endif
int zoneid = _Universe->StarSystemIndex( sts );
netbuf.addShort( zoneid );
//Add system string to packet...
//Long, I know, but is there any other way to keep all the proper graphics-related data that the server discards?
//netbuf.addString( zonemgr->getSystem(sysname) );
packet2.send( LOGIN_ACCEPT, cltserial, netbuf.getData(),
netbuf.getDataLength(), SENDRELIABLE, &clt->cltadr, clt->tcp_sock, __FILE__, PSEUDO__LINE__( 241 ) );
//Now that we have a starsystem, we will want to make a mission.
if (Mission::getNthPlayerMission( _Universe->whichPlayerStarship( un ), 0 ) == NULL) {
if (active_missions.size() == 1)
active_missions[0]->DirectorInitgame();
//Make a mission specially for this cockpit.
unsigned int oldcp = _Universe->CurrentCockpit();
_Universe->SetActiveCockpit( cp );
_Universe->pushActiveStarSystem( _Universe->AccessCockpit()->activeStarSystem );
LoadMission( "", vs_config->getVariable( "server", "serverscript", "import server;my_obj=server.player()" ), false );
_Universe->popActiveStarSystem();
_Universe->SetActiveCockpit( oldcp );
}
}