本文整理汇总了C++中PlayerSAO::getPlayer方法的典型用法代码示例。如果您正苦于以下问题:C++ PlayerSAO::getPlayer方法的具体用法?C++ PlayerSAO::getPlayer怎么用?C++ PlayerSAO::getPlayer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlayerSAO
的用法示例。
在下文中一共展示了PlayerSAO::getPlayer方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getplayersao
RemotePlayer *ObjectRef::getplayer(ObjectRef *ref)
{
PlayerSAO *playersao = getplayersao(ref);
if (playersao == NULL)
return NULL;
return playersao->getPlayer();
}
示例2: handleCommand_ClientReady
void Server::handleCommand_ClientReady(NetworkPacket* pkt) {
const auto peer_id = pkt->getPeerId();
auto & packet = *(pkt->packet);
u16 peer_proto_ver = getClient(peer_id, CS_InitDone)->net_proto_version;
// clients <= protocol version 22 did not send ready message,
// they're already initialized
if (peer_proto_ver <= 22) {
infostream << "Client sent message not expected by a "
<< "client using protocol version <= 22,"
<< "disconnecting peer_id: " << peer_id << std::endl;
m_con.DisconnectPeer(peer_id);
return;
}
PlayerSAO* playersao = StageTwoClientInit(peer_id);
// If failed, cancel
if (playersao == NULL) {
errorstream
<< "TOSERVER_CLIENT_READY stage 2 client init failed for peer_id: "
<< peer_id << std::endl;
m_con.DisconnectPeer(peer_id);
return;
}
int version_patch = 0, version_tweak = 0;
packet.convert_safe(TOSERVER_CLIENT_READY_VERSION_PATCH, version_patch);
packet.convert_safe(TOSERVER_CLIENT_READY_VERSION_TWEAK, version_tweak);
if (version_tweak) {} //no warn todo remove
m_clients.setClientVersion(
peer_id,
packet[TOSERVER_CLIENT_READY_VERSION_MAJOR].as<int>(),
packet[TOSERVER_CLIENT_READY_VERSION_MINOR].as<int>(),
version_patch,
//version_tweak,
packet[TOSERVER_CLIENT_READY_VERSION_STRING].as<std::string>()
);
m_clients.event(peer_id, CSE_SetClientReady);
m_script->on_joinplayer(playersao);
stat.add("join", playersao->getPlayer()->getName());
}
示例3: l_getvelocity
// getvelocity(self)
int ObjectRef::l_getvelocity(lua_State *L)
{
NO_MAP_LOCK_REQUIRED;
ObjectRef *ref = checkobject(L, 1);
{
PlayerSAO* co = getplayersao(ref);
if (co) {
v3f v = co->getPlayer()->getSpeed();
pushFloatPos(L, v);
return 1;
}
}
LuaEntitySAO *co = getluaobject(ref);
if (co == NULL) return 0;
// Do it
v3f v = co->getVelocity();
pushFloatPos(L, v);
return 1;
}
示例4: ProcessData
//.........这里部分代码省略.........
<<" supplied empty password"<<std::endl;
DenyAccess(peer_id, "Empty passwords are "
"disallowed. Set a password and try again.");
return;
}
std::string raw_default_password = g_settings->get("default_password");
std::string initial_password =
translatePassword(playername, raw_default_password);
// If default_password is empty, allow any initial password
if (raw_default_password.length() == 0)
initial_password = given_password;
m_script->createAuth(playername, initial_password);
}
has_auth = m_script->getAuth(playername, &checkpwd, NULL);
if(!has_auth){
actionstream<<"Server: "<<playername<<" cannot be authenticated"
<<" (auth handler does not work?)"<<std::endl;
DenyAccess(peer_id, "Not allowed to login");
return;
}
if(given_password != checkpwd){
actionstream<<"Server: "<<playername<<" supplied wrong password"
<<std::endl;
DenyAccess(peer_id, "Wrong password");
return;
}
RemotePlayer *player =
static_cast<RemotePlayer*>(m_env->getPlayer(playername.c_str()));
if(player && player->peer_id != 0){
errorstream<<"Server: "<<playername<<": Failed to emerge player"
<<" (player allocated to an another client)"<<std::endl;
DenyAccess(peer_id, "Another client is connected with this "
"name. If your client closed unexpectedly, try again in "
"a minute.");
}
m_clients.setPlayerName(peer_id,playername);
/*
Answer with a TOCLIENT_INIT
*/
{
MSGPACK_PACKET_INIT(TOCLIENT_INIT, 4);
PACK(TOCLIENT_INIT_DEPLOYED, deployed);
PACK(TOCLIENT_INIT_SEED, m_env->getServerMap().getSeed());
PACK(TOCLIENT_INIT_STEP, g_settings->getFloat("dedicated_server_step"));
//if (player) //todo : remake me
// PACK(TOCLIENT_INIT_POS, player->getPosition());
Settings params;
m_emerge->params.save(params);
PACK(TOCLIENT_INIT_MAP_PARAMS, params);
// Send as reliable
m_clients.send(peer_id, 0, buffer, true);
m_clients.event(peer_id, CSE_Init);
}