本文整理汇总了C++中RemotePlayer类的典型用法代码示例。如果您正苦于以下问题:C++ RemotePlayer类的具体用法?C++ RemotePlayer怎么用?C++ RemotePlayer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RemotePlayer类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: checkobject
// get_player_control(self)
int ObjectRef::l_get_player_control(lua_State *L)
{
NO_MAP_LOCK_REQUIRED;
ObjectRef *ref = checkobject(L, 1);
RemotePlayer *player = getplayer(ref);
if (player == NULL) {
lua_pushlstring(L, "", 0);
return 1;
}
const PlayerControl &control = player->getPlayerControl();
lua_newtable(L);
lua_pushboolean(L, control.up);
lua_setfield(L, -2, "up");
lua_pushboolean(L, control.down);
lua_setfield(L, -2, "down");
lua_pushboolean(L, control.left);
lua_setfield(L, -2, "left");
lua_pushboolean(L, control.right);
lua_setfield(L, -2, "right");
lua_pushboolean(L, control.jump);
lua_setfield(L, -2, "jump");
lua_pushboolean(L, control.aux1);
lua_setfield(L, -2, "aux1");
lua_pushboolean(L, control.sneak);
lua_setfield(L, -2, "sneak");
lua_pushboolean(L, control.LMB);
lua_setfield(L, -2, "LMB");
lua_pushboolean(L, control.RMB);
lua_setfield(L, -2, "RMB");
return 1;
}
示例2: checkobject
// get_sky(self)
int ObjectRef::l_get_sky(lua_State *L)
{
NO_MAP_LOCK_REQUIRED;
ObjectRef *ref = checkobject(L, 1);
RemotePlayer *player = getplayer(ref);
if (player == NULL)
return 0;
video::SColor bgcolor(255, 255, 255, 255);
std::string type;
std::vector<std::string> params;
bool clouds;
player->getSky(&bgcolor, &type, ¶ms, &clouds);
type = type == "" ? "regular" : type;
push_ARGB8(L, bgcolor);
lua_pushlstring(L, type.c_str(), type.size());
lua_newtable(L);
s16 i = 1;
for (std::vector<std::string>::iterator it = params.begin();
it != params.end(); ++it) {
lua_pushlstring(L, it->c_str(), it->size());
lua_rawseti(L, -2, i);
i++;
}
lua_pushboolean(L, clouds);
return 3;
}
示例3: getClientIDs
void ClientInterface::UpdatePlayerList()
{
if (m_env) {
std::vector<u16> clients = getClientIDs();
m_clients_names.clear();
if(!clients.empty())
infostream<<"Players:"<<std::endl;
for (u16 i : clients) {
RemotePlayer *player = m_env->getPlayer(i);
if (player == NULL)
continue;
infostream << "* " << player->getName() << "\t";
{
MutexAutoLock clientslock(m_clients_mutex);
RemoteClient* client = lockedGetClientNoEx(i);
if (client)
client->PrintInfo(infostream);
}
m_clients_names.emplace_back(player->getName());
}
}
}
示例4: checkobject
// get_look_yaw2(self)
int ObjectRef::l_get_look_horizontal(lua_State *L)
{
NO_MAP_LOCK_REQUIRED;
ObjectRef *ref = checkobject(L, 1);
RemotePlayer *player = getplayer(ref);
if (player == NULL) return 0;
// Do it
lua_pushnumber(L, player->getRadYaw());
return 1;
}
示例5: log_deprecated
// DEPRECATED
// get_look_yaw(self)
int ObjectRef::l_get_look_yaw(lua_State *L)
{
NO_MAP_LOCK_REQUIRED;
log_deprecated(L,
"Deprecated call to get_look_yaw, use get_look_horizontal instead");
ObjectRef *ref = checkobject(L, 1);
RemotePlayer *player = getplayer(ref);
if (player == NULL) return 0;
// Do it
lua_pushnumber(L, player->getRadYawDep());
return 1;
}
示例6: RemotePlayer
void Game::injectPlayerJoined(NetworkMessage::PlayerJoined *message){
if(!mGameRunning){
Ogre::LogManager::getSingletonPtr()->logMessage("Adding new player");
RemotePlayer *rp = new RemotePlayer(message->getNickname(), mWorld, mBombManager);
rp->setStartingPosition(
message->getX(),
message->getY(),
message->getZ()
);
mPlayerList->addPlayer(rp);
}
}
示例7: luaL_checkstring
// get_player_by_name(name)
int ModApiEnvMod::l_get_player_by_name(lua_State *L)
{
GET_ENV_PTR;
// Do it
const char *name = luaL_checkstring(L, 1);
RemotePlayer *player = dynamic_cast<RemotePlayer *>(env->getPlayer(name));
if (player == NULL){
lua_pushnil(L);
return 1;
}
PlayerSAO *sao = player->getPlayerSAO();
if(sao == NULL){
lua_pushnil(L);
return 1;
}
// Put player on stack
getScriptApiBase(L)->objectrefGetOrCreate(L, sao);
return 1;
}
示例8: luaL_checkstring
// get_player_ip()
int ModApiServer::l_get_player_ip(lua_State *L)
{
NO_MAP_LOCK_REQUIRED;
const char * name = luaL_checkstring(L, 1);
RemotePlayer *player = dynamic_cast<ServerEnvironment *>(getEnv(L))->getPlayer(name);
if(player == NULL)
{
lua_pushnil(L); // no such player
return 1;
}
try
{
Address addr = getServer(L)->getPeerAddress(player->getPeerId());
std::string ip_str = addr.serializeString();
lua_pushstring(L, ip_str.c_str());
return 1;
} catch (const con::PeerNotFoundException &) {
dstream << FUNCTION_NAME << ": peer was not found" << std::endl;
lua_pushnil(L); // error
return 1;
}
}
示例9: DSTACK
void RemoteClient::GetNextBlocks (
ServerEnvironment *env,
EmergeManager * emerge,
float dtime,
std::vector<PrioritySortedBlockTransfer> &dest)
{
DSTACK(FUNCTION_NAME);
// Increment timers
m_nothing_to_send_pause_timer -= dtime;
m_nearest_unsent_reset_timer += dtime;
if(m_nothing_to_send_pause_timer >= 0)
return;
RemotePlayer *player = env->getPlayer(peer_id);
// This can happen sometimes; clients and players are not in perfect sync.
if (!player)
return;
PlayerSAO *sao = player->getPlayerSAO();
if (!sao)
return;
// Won't send anything if already sending
if(m_blocks_sending.size() >= g_settings->getU16
("max_simultaneous_block_sends_per_client"))
{
//infostream<<"Not sending any blocks, Queue full."<<std::endl;
return;
}
v3f playerpos = sao->getBasePosition();
const v3f &playerspeed = player->getSpeed();
v3f playerspeeddir(0,0,0);
if(playerspeed.getLength() > 1.0*BS)
playerspeeddir = playerspeed / playerspeed.getLength();
// Predict to next block
v3f playerpos_predicted = playerpos + playerspeeddir*MAP_BLOCKSIZE*BS;
v3s16 center_nodepos = floatToInt(playerpos_predicted, BS);
v3s16 center = getNodeBlockPos(center_nodepos);
// Camera position and direction
v3f camera_pos = sao->getEyePosition();
v3f camera_dir = v3f(0,0,1);
camera_dir.rotateYZBy(sao->getPitch());
camera_dir.rotateXZBy(sao->getYaw());
/*infostream<<"camera_dir=("<<camera_dir.X<<","<<camera_dir.Y<<","
<<camera_dir.Z<<")"<<std::endl;*/
/*
Get the starting value of the block finder radius.
*/
if(m_last_center != center)
{
m_nearest_unsent_d = 0;
m_last_center = center;
}
/*infostream<<"m_nearest_unsent_reset_timer="
<<m_nearest_unsent_reset_timer<<std::endl;*/
// Reset periodically to workaround for some bugs or stuff
if(m_nearest_unsent_reset_timer > 20.0)
{
m_nearest_unsent_reset_timer = 0;
m_nearest_unsent_d = 0;
//infostream<<"Resetting m_nearest_unsent_d for "
// <<server->getPlayerName(peer_id)<<std::endl;
}
//s16 last_nearest_unsent_d = m_nearest_unsent_d;
s16 d_start = m_nearest_unsent_d;
//infostream<<"d_start="<<d_start<<std::endl;
u16 max_simul_sends_setting = g_settings->getU16
("max_simultaneous_block_sends_per_client");
u16 max_simul_sends_usually = max_simul_sends_setting;
/*
Check the time from last addNode/removeNode.
Decrease send rate if player is building stuff.
*/
m_time_from_building += dtime;
if(m_time_from_building < g_settings->getFloat(
"full_block_send_enable_min_time_from_building"))
{
max_simul_sends_usually
= LIMITED_MAX_SIMULTANEOUS_BLOCK_SENDS;
}
/*
Number of blocks sending + number of blocks selected for sending
//.........这里部分代码省略.........
示例10: glScissor
//.........这里部分代码省略.........
for (i = 0; i < maxShots; i++)
{
const ShotPath* shot = myTank->getShot(i);
if (shot)
{
const float cs = colorScale(shot->getPosition()[2], muzzleHeight, BZDBCache::enhancedRadar);
glColor3f(1.0f * cs, 1.0f * cs, 1.0f * cs);
shot->radarRender();
}
}
//draw world weapon shots
WorldPlayer *worldWeapons = World::getWorld()->getWorldWeapons();
maxShots = worldWeapons->getMaxShots();
for (i = 0; i < maxShots; i++)
{
const ShotPath* shot = worldWeapons->getShot(i);
if (shot)
{
const float cs = colorScale(shot->getPosition()[2], muzzleHeight, BZDBCache::enhancedRadar);
glColor3f(1.0f * cs, 1.0f * cs, 1.0f * cs);
shot->radarRender();
}
}
// draw other tanks (and any flags on them)
// note about flag drawing. each line segment is drawn twice
// (once in each direction); this degrades the antialiasing
// but on systems that don't do correct filtering of endpoints
// not doing it makes (half) the endpoints jump wildly.
const int curMaxPlayers = world.getCurMaxPlayers();
for (i = 0; i < curMaxPlayers; i++) {
RemotePlayer* player = world.getPlayer(i);
if (!player || !player->isAlive() || ((player->getFlag() == Flags::Stealth) &&
(myTank->getFlag() != Flags::Seer)))
continue;
GLfloat x = player->getPosition()[0];
GLfloat y = player->getPosition()[1];
GLfloat z = player->getPosition()[2];
if (player->getFlag() != Flags::Null) {
glColor3fv(player->getFlag()->getColor());
drawFlagOnTank(x, y, z);
}
if (player->isPaused() || player->isNotResponding()) {
const float dimfactor = 0.4f;
const float *color = Team::getRadarColor(myTank->getFlag() ==
Flags::Colorblindness ? RogueTeam : player->getTeam());
float dimmedcolor[3];
dimmedcolor[0] = color[0] * dimfactor;
dimmedcolor[1] = color[1] * dimfactor;
dimmedcolor[2] = color[2] * dimfactor;
glColor3fv(dimmedcolor);
} else {
glColor3fv(Team::getRadarColor(myTank->getFlag() ==
Flags::Colorblindness ? RogueTeam : player->getTeam()));
}
// If this tank is hunted flash it on the radar
if (player->isHunted() && myTank->getFlag() != Flags::Colorblindness) {
if (flashTank.isOn()) {
if (!toggleTank) {
float flashcolor[3];
flashcolor[0] = 0.0f;
flashcolor[1] = 0.8f;
示例11: getClient
//.........这里部分代码省略.........
!checkPriv(playername, "privs") &&
!checkPriv(playername, "password") &&
playername != g_settings->get("name")) {
actionstream << "Server: " << playername << " tried to join, but there"
<< " are already max_users="
<< g_settings->getU16("max_users") << " players." << std::endl;
DenyAccess(peer_id, "Too many users.");
return;
}
std::string checkpwd; // Password hash to check against
bool has_auth = m_script->getAuth(playername, &checkpwd, NULL);
// If no authentication info exists for user, create it
if(!has_auth) {
if(!isSingleplayer() &&
g_settings->getBool("disallow_empty_password") &&
given_password == "") {
actionstream << "Server: " << playername
<< " 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 =
translate_password(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"
<< " at " << addr_s
<< 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) {
if (given_password.size()) {
actionstream << "Server: " << playername << " rejoining" << std::endl;
DenyAccessVerCompliant(player->peer_id, player->protocol_version, SERVER_ACCESSDENIED_ALREADY_CONNECTED);
player->getPlayerSAO()->removingFromEnvironment();
m_env->removePlayer(player);
player = nullptr;
} else {
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_LEGACY, 6);
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);
PACK(TOCLIENT_INIT_PROTOCOL_VERSION_FM, SERVER_PROTOCOL_VERSION_FM);
PACK(TOCLIENT_INIT_WEATHER, g_settings->getBool("weather"));
// Send as reliable
m_clients.send(peer_id, 0, buffer, true);
m_clients.event(peer_id, CSE_InitLegacy);
}
return;
}