本文整理汇总了C++中NetworkString::getFloat方法的典型用法代码示例。如果您正苦于以下问题:C++ NetworkString::getFloat方法的具体用法?C++ NetworkString::getFloat怎么用?C++ NetworkString::getFloat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NetworkString
的用法示例。
在下文中一共展示了NetworkString::getFloat方法的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: kartFinishedRace
/** This function is called on a client when it receives a kartFinishedRace
* event from the server. It updates the game with this information.
* \param ns The message from the server.
*/
void GameEventsProtocol::kartFinishedRace(const NetworkString &ns)
{
if (ns.size() < 5)
{
Log::warn("GameEventsProtocol", "kartFinisheRace: Too short message.");
return;
}
uint8_t kart_id = ns.getUInt8();
float time = ns.getFloat();
if (race_manager->modeHasLaps())
{
World::getWorld()->getKart(kart_id)
->setPosition(m_last_finished_position++);
}
World::getWorld()->getKart(kart_id)->finishedRace(time,
/*from_server*/true);
} // kartFinishedRace