本文整理汇总了C++中raknet::BitStream::Read方法的典型用法代码示例。如果您正苦于以下问题:C++ BitStream::Read方法的具体用法?C++ BitStream::Read怎么用?C++ BitStream::Read使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类raknet::BitStream
的用法示例。
在下文中一共展示了BitStream::Read方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readInitValuesFromBitstream
//------------------------------------------------------------------------------
void Missile::readInitValuesFromBitstream(RakNet::BitStream & stream, GameState * game_state, uint32_t timestamp)
{
Projectile::readInitValuesFromBitstream(stream, game_state, timestamp);
stream.Read(speed_);
stream.Read(agility_);
}
示例2: ToggleHUDComponent
RPC_CALLBACK CRPCCallback::ToggleHUDComponent(RakNet::BitStream& bsData, int iExtra)
{
unsigned char ucComponent, bToggle;
if (bsData.Read(ucComponent) && bsData.Read(bToggle))
CHUD::ToggleComponent(ucComponent, bToggle);
}
示例3: onSessionKeyReceived
/**
* Our job is done. Emit an observable event, then die gracefully.
*/
void ClientLogon::onSessionKeyReceived(RakNet::BitStream & stream)
{
stream.Read(user_id_);
stream.Read(session_key_);
emit(CLOE_AUTHORIZATION_SUCCESSFUL);
scheduleSuicide();
}
示例4: onMatchStatsReceived
//------------------------------------------------------------------------------
void GameLogicClientSoccer::onMatchStatsReceived(RakNet::BitStream & args)
{
network::ranking::StatisticsSoccer stats;
stats.readFromBitstream(args);
// read the mapping from ranking id to system address
std::map<uint32_t, SystemAddress> id_map;
uint32_t num_players;
args.Read(num_players);
for (unsigned i=0; i<num_players; ++i)
{
uint32_t ranking_id;
SystemAddress address;
args.Read(ranking_id);
args.Read(address);
id_map[ranking_id] = address;
}
GUIMatchSummarySoccer * gmss = dynamic_cast<GUIMatchSummarySoccer*>(gui_match_summary_.get());
std::ostringstream ss_poss0, ss_distr0, ss_poss1, ss_distr1;
std::string match_text_left, match_text_right;
match_text_left = "Goals (Blue/Red):\n\nBall possession:\n\nMatch distribution:";
match_text_right = toString(stats.goals_blue_) + ":" + toString(stats.goals_red_) + "\n\n";
// write correct ball possession
ss_poss0 << std::fixed << std::setprecision(2) << (stats.ball_possession_ * 100.0f);
ss_poss1 << std::fixed << std::setprecision(2) << (1.0f - stats.ball_possession_) * 100.0f;
match_text_right += ss_poss0.str() + " % : " + ss_poss1.str() + " %\n\n";
// write correct game distribution
ss_distr0 << std::fixed << std::setprecision(2) << (stats.game_distribution_) * 100.0f;
ss_distr1 << std::fixed << std::setprecision(2) << (1.0f - stats.game_distribution_) * 100.0f;
match_text_right += ss_distr0.str() + " % : " + ss_distr1.str() + " %\n";
gmss->setMatchSummaryText(match_text_left, match_text_right);
for (std::map<uint32_t, network::ranking::ScoreStats>::const_iterator it = stats.score_stats_.begin();
it != stats.score_stats_.end();
++it)
{
Player * player = puppet_master_->getLocalOrRemotePlayer(id_map[it->first]);
if (!player) continue;
bool selected = (player->getId() == puppet_master_->getLocalPlayer()->getId());
std::ostringstream ss_skill, ss_delta;
ss_skill << std::fixed << std::setprecision(2) << it->second.new_score_;
ss_delta << std::fixed << std::showpos << std::setprecision(2) << it->second.delta_;
gmss->addSkillElement(player->getName(),ss_skill.str(), ss_delta.str() ,selected);
}
gmss->show(1.0f);
}
示例5: sizeof
ServerInfo::ServerInfo(RakNet::BitStream& stream, const char* ip)
{
strncpy(hostname, ip, sizeof(hostname));
hostname[sizeof(hostname) - 1] = 0;
stream.Read(activegames);
stream.Read(gamespeed);
stream.Read(name, sizeof(name));
stream.Read(waitingplayer, sizeof(waitingplayer));
stream.Read(description, sizeof(description));
}
示例6: SetHUDComponentColour
RPC_CALLBACK CRPCCallback::SetHUDComponentColour(RakNet::BitStream& bsData, int iExtra)
{
unsigned char ucComponent;
DWORD dwColour;
if (bsData.Read(ucComponent) && bsData.Read(dwColour))
{
RakNet::BitStream::ReverseBytesInPlace((unsigned char*)&dwColour, sizeof(DWORD));
CHUD::SetComponentColour(ucComponent, dwColour);
}
}
示例7: gameWon
//------------------------------------------------------------------------------
void GameLogicClientSoccer::gameWon (RakNet::BitStream & args)
{
GameLogicClientCommon::gameWon();
TEAM_ID own_team = score_.getTeamId(puppet_master_->getLocalPlayer()->getId());
TEAM_ID winner_team;
args.Read(winner_team);
std::string game_info_label;
if (winner_team == INVALID_TEAM_ID)
{
game_info_label = "Round draw.";
} else if (own_team == INVALID_TEAM_ID)
{
game_info_label = " " + team_[winner_team].getName() + " wins.";
} else if (winner_team == score_.getTeamId(puppet_master_->getLocalPlayer()->getId()))
{
game_info_label = "Congratulations! You are the winner!";
} else
{
game_info_label = "You have lost the match.";
}
s_log << Log::debug('l') << game_info_label;
puppet_master_->getHud()->setStatusLine(game_info_label);
// gui_score_->show(1.0f);
// SoundSource * snd = NULL;
// if(team_id == TEAM_ID_ATTACKER)
// {
// snd = s_soundmanager.playSimpleEffect(s_params.get<std::string>("sfx.attacker_wins"),
// s_soundmanager.getListenerInfo().position_);
// } else
// {
// snd = s_soundmanager.playSimpleEffect(s_params.get<std::string>("sfx.defender_wins"),
// s_soundmanager.getListenerInfo().position_);
// }
// snd->setRolloffFactor(0.0f);
spectator_camera_.setMode(CM_TRACKING_3RD_CONSTANT_DIR);
// // winning camera
// if (winning_player && winning_player->getControllable())
// {
// const Vector OFFSET = Vector(0,1,3);
// ControllableVisual * visual = (ControllableVisual*)winning_player->getControllable()->getUserData();
// Matrix new_pos = visual->getTrackingPos(Vector(0,0,0));
// new_pos.getTranslation() += new_pos.transformVector(OFFSET);
// new_pos.loadOrientation(winning_player->getControllable()->getPosition() - new_pos.getTranslation(), Vector(0,1,0));
// spectator_camera_.trackPlayer(winning_player->getId());
// spectator_camera_.setMode(CM_TRACKING_3RD_CONSTANT_DIR);
// spectator_camera_.setTransform(new_pos);
// }
}
示例8: SetRadioStation
RPC_CALLBACK CRPCCallback::SetRadioStation(RakNet::BitStream& bsData, int iExtra)
{
unsigned char ucStation;
if (bsData.Read(ucStation))
CGame::SetRadioStation(ucStation);
}
示例9: switch
// Returning false prevents the proxy from forwarding current packet to the client
bool
CProxy::HandleLoginSrvPacket(RakNet::Packet* pPacket, RakNet::SystemAddress& clientAddr, RakNet::BitStream& inStr, uchar opCode)
{
uint off = inStr.GetReadOffset();
switch (opCode)
{
case Opcodes::OP_LOGIN:
bool bLoggedIn = false;
inStr.Read(bLoggedIn);
if (bLoggedIn)
{
ff::fmt(pan::debug, "({0}) Player successfully logged in.", clientAddr.ToString(false));
// Do the switch to Area server here
}
break;
}
inStr.SetReadOffset(off);
return true;
}
示例10: readStateFromBitstream
//------------------------------------------------------------------------------
void Tank::readStateFromBitstream(RakNet::BitStream & stream, unsigned type, uint32_t timestamp)
{
Controllable::readStateFromBitstream(stream, type, timestamp);
if (type & OST_CORE)
{
stream.Read(doing_stabilization_);
#ifdef DISABLE_NETWORK_OPTIMIZATIONS
stream.Read(target_yaw_);
if (!doing_stabilization_) stream.Read(target_pitch_);
else stream.Read(last_target_global_pitch_);
stream.Read(target_steer_angle_);
#else
network::readAngleFromBitstream(stream, target_yaw_);
// we want the pitch to be in the range [-PI;PI]
if (!doing_stabilization_)
{
network::readAngleFromBitstream(stream, target_pitch_);
if (target_pitch_ > PI) target_pitch_ -= 2*PI;
} else
{
network::readAngleFromBitstream(stream, last_target_global_pitch_);
if (last_target_global_pitch_ > PI) last_target_global_pitch_ -= 2*PI;
}
network::readAngleFromBitstream(stream, target_steer_angle_);
if (target_steer_angle_ > PI) target_steer_angle_ -= 2*PI;
#endif
}
if (type & OST_EXTRA)
{
HitpointTracker::readStateFromBitstream(stream);
for(unsigned w=0; w < NUM_WEAPON_SLOTS; w++)
{
weapon_system_[w]->readStateFromBitstream(stream);
}
}
}
示例11: SetWaveHeight
RPC_CALLBACK CRPCCallback::SetWaveHeight(RakNet::BitStream& bsData, int iExtra)
{
float fHeight;
if (bsData.Read(fHeight))
CGame::SetWaveHeight(fHeight);
}
示例12: TogglePauseMenu
RPC_CALLBACK CRPCCallback::TogglePauseMenu(RakNet::BitStream& bsData, int iExtra)
{
unsigned char ucToggle;
if (bsData.Read(ucToggle))
CGame::PauseMenuEnabled = ucToggle;
}
示例13: readInitValuesFromBitstream
//------------------------------------------------------------------------------
void TankMine::readInitValuesFromBitstream(RakNet::BitStream & stream, GameState * game_state, uint32_t timestamp)
{
RigidBody::readInitValuesFromBitstream(stream, game_state, timestamp);
TEAM_ID team_id;
stream.Read(team_id);
setTeamId(team_id);
}
示例14: mID
NetworkPlayer::NetworkPlayer(PlayerID id, RakNet::BitStream stream) : mID(id)
{
int playerSide;
stream.Read(playerSide);
mDesiredSide = (PlayerSide)playerSide;
// Read the Playername
char charName[16];
stream.Read(charName, sizeof(charName));
// ensures that charName is null terminated
charName[sizeof(charName)-1] = '\0';
// read colour data
int color;
stream.Read(color);
mIdentity = PlayerIdentity(charName, color, false);
}
示例15: createNewObject
void Server::createNewObject(RakNet::BitStream& bsIn, RakNet::SystemAddress& ownerSysAddress)
{
GameObject newGameObject;
bsIn.Read(newGameObject);
newGameObject.uiOwnerClientID = systemAddressToClientID(ownerSysAddress);
newGameObject.uiObjectID = m_uiConnectionCounter++;
m_gameObjects.push_back(newGameObject);
sendGameObjectBackToClient(newGameObject);
}