本文整理汇总了C++中PlayerSAO::checkMovementCheat方法的典型用法代码示例。如果您正苦于以下问题:C++ PlayerSAO::checkMovementCheat方法的具体用法?C++ PlayerSAO::checkMovementCheat怎么用?C++ PlayerSAO::checkMovementCheat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlayerSAO
的用法示例。
在下文中一共展示了PlayerSAO::checkMovementCheat方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ProcessData
//.........这里部分代码省略.........
}
PlayerSAO *playersao = player->getPlayerSAO();
if(playersao == NULL) {
errorstream<<"Server::ProcessData(): Canceling: "
"No player object for peer_id="<<peer_id
<< " disconnecting peer!" <<std::endl;
m_con.DisconnectPeer(peer_id);
return;
}
if(command == TOSERVER_PLAYERPOS)
{
// If player is dead we don't care of this packet
if (player->hp != 0 && playersao->m_ms_from_last_respawn > 1000)
player->setPosition(packet[TOSERVER_PLAYERPOS_POSITION].as<v3f>());
player->setSpeed(packet[TOSERVER_PLAYERPOS_SPEED].as<v3f>());
player->setPitch(modulo360f(packet[TOSERVER_PLAYERPOS_PITCH].as<f32>()));
player->setYaw(modulo360f(packet[TOSERVER_PLAYERPOS_YAW].as<f32>()));
u32 keyPressed = packet[TOSERVER_PLAYERPOS_KEY_PRESSED].as<u32>();
player->keyPressed = keyPressed;
player->control.up = (bool)(keyPressed&1);
player->control.down = (bool)(keyPressed&2);
player->control.left = (bool)(keyPressed&4);
player->control.right = (bool)(keyPressed&8);
player->control.jump = (bool)(keyPressed&16);
player->control.aux1 = (bool)(keyPressed&32);
player->control.sneak = (bool)(keyPressed&64);
player->control.LMB = (bool)(keyPressed&128);
player->control.RMB = (bool)(keyPressed&256);
auto old_pos = playersao->m_last_good_position;
if(playersao->checkMovementCheat()){
// Call callbacks
m_script->on_cheat(playersao, "moved_too_fast");
SendMovePlayer(peer_id);
}
else if (playersao->m_ms_from_last_respawn > 3000) {
auto dist = (old_pos/BS).getDistanceFrom(playersao->m_last_good_position/BS);
if (dist)
stat.add("move", playersao->getPlayer()->getName(), dist);
}
if (playersao->m_ms_from_last_respawn > 2000) {
auto obj = playersao; // copypasted from server step:
auto uptime = m_uptime.get();
if (!obj->m_uptime_last) // not very good place, but minimum modifications
obj->m_uptime_last = uptime - 0.1;
if (uptime - obj->m_uptime_last > 0.5) {
obj->step(uptime - obj->m_uptime_last, true); //todo: maybe limit count per time
obj->m_uptime_last = uptime;
}
}
/*infostream<<"Server::ProcessData(): Moved player "<<peer_id<<" to "
<<"("<<position.X<<","<<position.Y<<","<<position.Z<<")"
<<" pitch="<<pitch<<" yaw="<<yaw<<std::endl;*/
}
else if(command == TOSERVER_DELETEDBLOCKS)
{
std::vector<v3s16> deleted_blocks;
packet[TOSERVER_DELETEDBLOCKS_DATA].convert(&deleted_blocks);
RemoteClient *client = getClient(peer_id);
for (auto &block : deleted_blocks)
client->SetBlockDeleted(block);