本文整理汇总了C++中net::CBuffer类的典型用法代码示例。如果您正苦于以下问题:C++ CBuffer类的具体用法?C++ CBuffer怎么用?C++ CBuffer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CBuffer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: deserialize
void CMessageHoundCharge::deserialize(Net::CBuffer& buffer) {
buffer.read( &_isActive, sizeof(_isActive) );
// Solo si la habilidad esta activa se mandan el resto
// de los atributos
if(_isActive) {
buffer.read( &_filterMask, sizeof(_filterMask) );
buffer.read( &_force, sizeof(_force) );
}
}
示例2: serialize
Net::CBuffer CMessageHoundCharge::serialize() {
Net::CBuffer buffer;
buffer.serialize( std::string("CMessageHoundCharge"), true );
buffer.write( &_isActive, sizeof(_isActive) );
// El resto de los atributos nos interesan solo si se
// activa la habilidad
if(_isActive) {
buffer.write( &_filterMask, sizeof(_filterMask) );
buffer.write( &_force, sizeof(_force) );
}
return buffer;
}//
示例3: deserialize
void CMessageInt::deserialize(Net::CBuffer &data)
{
CMessage::deserialize(data);
data.read(&_int, sizeof(_int));
} // deserialize
示例4: serialize
void CMessageBool::serialize(Net::CBuffer &data)
{
CMessage::serialize(data);
data.write((void*) (&_bool), sizeof(_bool));
} // serialize
示例5: deserialize
void CMessageSetOwner::deserialize(Net::CBuffer& buffer) {
TEntityID id;
// Por problemas con enumerados utilizamos directamente
// el read en vez del deserialize
buffer.read( &id, sizeof(id) );
_entity = Logic::CServer::getSingletonPtr()->getMap()->getEntityByID(id);
}
示例6: deserialize
void CMessageBool::deserialize(Net::CBuffer &data)
{
CMessage::deserialize(data);
data.read(&_bool, sizeof(_bool));
} // deserialize
示例7: serialize
// TODO FRS no es necesario enviar todo el transform siempre -> solo posicion / rotacion en eje vertical
void CMessageTF::serialize(Net::CBuffer &data)
{
CMessage::serialize(data);
for(int i = 0; i < 4; ++i)
for(int j = 0; j < 4; ++j)
data.write((void*)&_transform[i][j], sizeof(_transform[i][j]));
} // serialize
示例8: deserialize
void CMessageTF::deserialize(Net::CBuffer &data)
{
CMessage::deserialize(data);
for(int i = 0; i < 4; ++i)
for(int j = 0; j < 4; ++j)
data.read(&_transform[i][j], sizeof(_transform[i][j]));
} // deserialize
示例9: disconnectionPacketReceived
void CGameServerState::disconnectionPacketReceived(Net::CPaquete* packet) {
// Obtenemos el puntero al gestor de jugadores y el id de red del cliente que se quiere desconectar
Net::NetID playerNetId = packet->getConexion()->getId();
// Eliminamos la entidad manejada por el cliente que se quiere desconectar.
// Para ello comprobamos si tiene asignado un id de entidad. Si no lo tiene, es que
// no ha sido creada ninguna entidad (podria estar conectandose).
if( _playersMgr->existsByNetId(playerNetId) ) {
std::pair<Logic::TEntityID, bool> logicIdPair = _playersMgr->getPlayerId(playerNetId);
if(logicIdPair.second) {
Logic::CEntity* entityToBeDeleted = _map->getEntityByID(logicIdPair.first);
Logic::CEntityFactory::getSingletonPtr()->deferredDeleteEntity(entityToBeDeleted, true);
// A nivel logico, conviene que los clientes sepan quien se desconecta,
// especialmente para eliminar cosas del hud
Net::NetMessageType ackMsg = Net::PLAYER_OFF_MATCH;
Net::CBuffer disconnectMsg;
disconnectMsg.write(&ackMsg, sizeof(ackMsg));
disconnectMsg.write(&playerNetId, sizeof(playerNetId));
disconnectMsg.serialize(entityToBeDeleted->getName(), false);
_netMgr->broadcast(disconnectMsg.getbuffer(), disconnectMsg.getSize());
}
// Eliminamos el jugador que se desconecta del manager de jugadores
_playersMgr->removePlayer(playerNetId);
}
} // disconnexionPacketReceived
示例10: serialize
void CMessageAudio::serialize(Net::CBuffer &data)
{
CMessage::serialize(data);
unsigned int size = _path.size();
data.write(&size,sizeof(size));
data.write((void*)_path.c_str(),size);
size = _id.size();
data.write(&size,sizeof(size));
data.write((void*)_id.c_str(),size);
data.write((void*)(&_position.x), sizeof(_position.x));
data.write((void*)(&_position.y), sizeof(_position.y));
data.write((void*)(&_position.z), sizeof(_position.z));
data.write((void*) (&_notIfPlay), sizeof(_notIfPlay));
data.write((void*) (&_isPlayer), sizeof(_isPlayer));
}
示例11: deserialize
void CMessageAudio::deserialize(Net::CBuffer &data) {
unsigned int size;
data.read(&size, sizeof(size));
char* aux = new char[size];
data.read(aux, size);
_path.assign(aux,size);
delete[] aux;
unsigned int size1;
data.read(&size1, sizeof(size1));
char* aux1 = new char[size1];
data.read(aux1, size1);
_id.assign(aux1,size1);
delete[] aux1;
data.read(&_position.x, sizeof(_position.x));
data.read(&_position.y, sizeof(_position.y));
data.read(&_position.z, sizeof(_position.z));
data.read(&_notIfPlay, sizeof(_notIfPlay));
data.read(&_isPlayer, sizeof(_isPlayer));
}
示例12: deserialize
void CMessageControl::deserialize(Net::CBuffer& buffer) {
buffer.deserialize(_seq);
buffer.read(&_controlType, sizeof(_controlType));
}
示例13: deserialize
void CMessagePrimarySpell::deserialize(Net::CBuffer& buffer) {
buffer.deserialize(_spell);
}
示例14: deserialize
void CMessagePrimaryShoot::deserialize(Net::CBuffer& buffer) {
buffer.deserialize(_shoot);
}
示例15: deserialize
void CMessageMouse::deserialize(Net::CBuffer& buffer) {
_controlType = Control::MOUSE;
buffer.deserialize(_seq);
buffer.deserialize(_mouse[0]);
buffer.deserialize(_mouse[1]);
}