本文整理汇总了C++中NetworkString::removeFront方法的典型用法代码示例。如果您正苦于以下问题:C++ NetworkString::removeFront方法的具体用法?C++ NetworkString::removeFront怎么用?C++ NetworkString::removeFront使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NetworkString
的用法示例。
在下文中一共展示了NetworkString::removeFront方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: notifyEventAsynchronous
bool KartUpdateProtocol::notifyEventAsynchronous(Event* event)
{
if (event->type != EVENT_TYPE_MESSAGE)
return true;
NetworkString ns = event->data();
if (ns.size() < 36)
{
Log::info("KartUpdateProtocol", "Message too short.");
return true;
}
ns.removeFront(4);
while(ns.size() >= 16)
{
uint32_t kart_id = ns.getUInt32(0);
float a,b,c;
a = ns.getFloat(4);
b = ns.getFloat(8);
c = ns.getFloat(12);
float d,e,f,g;
d = ns.getFloat(16);
e = ns.getFloat(20);
f = ns.getFloat(24);
g = ns.getFloat(28);
pthread_mutex_trylock(&m_positions_updates_mutex);
m_next_positions.push_back(Vec3(a,b,c));
m_next_quaternions.push_back(btQuaternion(d,e,f,g));
m_karts_ids.push_back(kart_id);
pthread_mutex_unlock(&m_positions_updates_mutex);
ns.removeFront(32);
}
return true;
}
示例2: playerMinorVote
/*! \brief Called when a player votes for a minor race mode.
* \param event : Event providing the information.
*
* Format of the data :
* Byte 0 1 5 6 7
* ----------------------------------------
* Size | 1 | 4 | 1 | 1 |
* Data | 4 | priv token | 1 | minor mode vote |
* ----------------------------------------
*/
void ServerLobbyRoomProtocol::playerMinorVote(Event* event)
{
NetworkString data = event->data();
STKPeer* peer = *(event->peer);
if (!checkDataSizeAndToken(event, 7))
return;
if (!isByteCorrect(event, 5, 1))
return;
uint8_t player_id = peer->getPlayerProfile()->race_id;
m_setup->getRaceConfig()->setPlayerMinorVote(player_id, data[6]);
// Send the vote to everybody (including the sender)
NetworkString other;
other.ai8(1).ai8(player_id); // add the player id
data.removeFront(5); // remove the token
other += data; // add the data
NetworkString prefix;
prefix.ai8(0xc2); // prefix the token with the ype
sendMessageToPeersChangingToken(prefix, other);
}