本文整理汇总了C++中LocalPlayer::getName方法的典型用法代码示例。如果您正苦于以下问题:C++ LocalPlayer::getName方法的具体用法?C++ LocalPlayer::getName怎么用?C++ LocalPlayer::getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LocalPlayer
的用法示例。
在下文中一共展示了LocalPlayer::getName方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: typeChatMessage
void Client::typeChatMessage(const std::wstring &message)
{
// Discard empty line
if (message.empty())
return;
// If message was ate by script API, don't send it to server
if (m_script->on_sending_message(wide_to_utf8(message))) {
return;
}
// Send to others
sendChatMessage(message);
// Show locally
if (message[0] != L'/') {
// compatibility code
if (m_proto_ver < 29) {
LocalPlayer *player = m_env.getLocalPlayer();
assert(player);
std::wstring name = narrow_to_wide(player->getName());
pushToChatQueue(new ChatMessage(CHATMESSAGE_TYPE_NORMAL, message, name));
}
}
}
示例2: l_get_name
int LuaLocalPlayer::l_get_name(lua_State *L)
{
LocalPlayer *player = getobject(L, 1);
lua_pushstring(L, player->getName());
return 1;
}
示例3: typeChatMessage
void Client::typeChatMessage(const std::string &message)
{
// Discard empty line
if(message.empty())
return;
// Send to others
sendChatMessage(message);
// Show locally
if (message[0] == '/')
{
m_chat_queue.push("issued command: " + message);
}
//freeminer display self message after recieving from server
#if MINETEST_PROTO
else
{
LocalPlayer *player = m_env.getLocalPlayer();
assert(player != NULL);
std::string name = (player->getName());
m_chat_queue.push(std::string() + "<" + name + "> " + message);
}
#endif
}
示例4: sendChangePassword
void Client::sendChangePassword(const std::string &oldpassword,
const std::string &newpassword)
{
LocalPlayer *player = m_env.getLocalPlayer();
if (player == NULL)
return;
std::string playername = player->getName();
if (m_proto_ver >= 25) {
// get into sudo mode and then send new password to server
m_password = oldpassword;
m_new_password = newpassword;
startAuth(choseAuthMech(m_sudo_auth_methods));
} else {
std::string oldpwd = translate_password(playername, oldpassword);
std::string newpwd = translate_password(playername, newpassword);
NetworkPacket pkt(TOSERVER_PASSWORD_LEGACY, 2 * PASSWORD_SIZE);
for (u8 i = 0; i < PASSWORD_SIZE; i++) {
pkt << (u8) (i < oldpwd.length() ? oldpwd[i] : 0);
}
for (u8 i = 0; i < PASSWORD_SIZE; i++) {
pkt << (u8) (i < newpwd.length() ? newpwd[i] : 0);
}
Send(&pkt);
}
}
示例5: updatePlayerInfo
void CharSelectDialog::updatePlayerInfo()
{
LocalPlayer *pi = mCharInfo->getEntry();
if (pi)
{
mNameLabel->setCaption(strprintf(_("Name: %s"), pi->getName().c_str()));
mLevelLabel->setCaption(strprintf(_("Level: %d"), pi->mLevel));
mJobLevelLabel->setCaption(strprintf(_("Job Level: %d"), pi->mJobLevel));
mMoneyLabel->setCaption(strprintf(_("Gold: %d"), pi->mGp));
if (!mCharSelected)
{
mNewDelCharButton->setCaption(_("Delete"));
mSelectButton->setEnabled(true);
}
}
else
{
mNameLabel->setCaption(strprintf(_("Name: %s"), ""));
mLevelLabel->setCaption(strprintf(_("Level: %d"), 0));
mJobLevelLabel->setCaption(strprintf(_("Job Level: %d"), 0));
mMoneyLabel->setCaption(strprintf(_("Money: %s"), ""));
mNewDelCharButton->setCaption(_("New"));
mSelectButton->setEnabled(false);
}
mBeingBox->setBeing(pi);
}
示例6: getInventory
Inventory* Client::getInventory(const InventoryLocation &loc)
{
switch(loc.type){
case InventoryLocation::UNDEFINED:
{}
break;
case InventoryLocation::CURRENT_PLAYER:
{
LocalPlayer *player = m_env.getLocalPlayer();
assert(player);
return &player->inventory;
}
break;
case InventoryLocation::PLAYER:
{
// Check if we are working with local player inventory
LocalPlayer *player = m_env.getLocalPlayer();
if (!player || strcmp(player->getName(), loc.name.c_str()) != 0)
return NULL;
return &player->inventory;
}
break;
case InventoryLocation::NODEMETA:
{
NodeMetadata *meta = m_env.getMap().getNodeMetadata(loc.p);
if(!meta)
return NULL;
return meta->getInventory();
}
break;
case InventoryLocation::DETACHED:
{
if (m_detached_inventories.count(loc.name) == 0)
return NULL;
return m_detached_inventories[loc.name];
}
break;
default:
FATAL_ERROR("Invalid inventory location type.");
break;
}
return NULL;
}
示例7: typeChatMessage
void Client::typeChatMessage(const std::wstring &message)
{
// Discard empty line
if(message == L"")
return;
// Send to others
sendChatMessage(message);
// Show locally
if (message[0] == L'/')
{
m_chat_queue.push((std::wstring)L"issued command: " + message);
}
else
{
LocalPlayer *player = m_env.getLocalPlayer();
assert(player != NULL);
std::wstring name = narrow_to_wide(player->getName());
m_chat_queue.push((std::wstring)L"<" + name + L"> " + message);
}
}
示例8: selectByName
bool CharSelectDialog::selectByName(const std::string &name)
{
if (mCharInfo->isLocked())
return false;
unsigned int oldPos = mCharInfo->getPos();
mCharInfo->select(0);
do
{
LocalPlayer *player = mCharInfo->getEntry();
if (player && player->getName() == name)
return true;
mCharInfo->next();
} while (mCharInfo->getPos());
mCharInfo->select(oldPos);
return false;
}
示例9: step
void Client::step(float dtime)
{
// Limit a bit
if(dtime > 2.0)
dtime = 2.0;
if(m_ignore_damage_timer > dtime)
m_ignore_damage_timer -= dtime;
else
m_ignore_damage_timer = 0.0;
m_animation_time += dtime;
if(m_animation_time > 60.0)
m_animation_time -= 60.0;
m_time_of_day_update_timer += dtime;
ReceiveAll();
/*
Packet counter
*/
{
float &counter = m_packetcounter_timer;
counter -= dtime;
if(counter <= 0.0)
{
counter = 20.0;
infostream << "Client packetcounter (" << m_packetcounter_timer
<< "):"<<std::endl;
m_packetcounter.print(infostream);
m_packetcounter.clear();
}
}
// UGLY hack to fix 2 second startup delay caused by non existent
// server client startup synchronization in local server or singleplayer mode
static bool initial_step = true;
if (initial_step) {
initial_step = false;
}
else if(m_state == LC_Created) {
float &counter = m_connection_reinit_timer;
counter -= dtime;
if(counter <= 0.0) {
counter = 2.0;
LocalPlayer *myplayer = m_env.getLocalPlayer();
FATAL_ERROR_IF(myplayer == NULL, "Local player not found in environment.");
sendInit(myplayer->getName());
}
// Not connected, return
return;
}
/*
Do stuff if connected
*/
/*
Run Map's timers and unload unused data
*/
const float map_timer_and_unload_dtime = 5.25;
if(m_map_timer_and_unload_interval.step(dtime, map_timer_and_unload_dtime)) {
ScopeProfiler sp(g_profiler, "Client: map timer and unload");
std::vector<v3s16> deleted_blocks;
m_env.getMap().timerUpdate(map_timer_and_unload_dtime,
g_settings->getFloat("client_unload_unused_data_timeout"),
g_settings->getS32("client_mapblock_limit"),
&deleted_blocks);
/*
Send info to server
NOTE: This loop is intentionally iterated the way it is.
*/
std::vector<v3s16>::iterator i = deleted_blocks.begin();
std::vector<v3s16> sendlist;
for(;;) {
if(sendlist.size() == 255 || i == deleted_blocks.end()) {
if(sendlist.empty())
break;
/*
[0] u16 command
[2] u8 count
[3] v3s16 pos_0
[3+6] v3s16 pos_1
...
*/
sendDeletedBlocks(sendlist);
if(i == deleted_blocks.end())
break;
sendlist.clear();
}
//.........这里部分代码省略.........
示例10: step
void Client::step(float dtime)
{
DSTACK(FUNCTION_NAME);
// Limit a bit
if(dtime > 2.0)
dtime = 2.0;
if(m_ignore_damage_timer > dtime)
m_ignore_damage_timer -= dtime;
else
m_ignore_damage_timer = 0.0;
m_animation_time += dtime;
if(m_animation_time > 60.0)
m_animation_time -= 60.0;
m_time_of_day_update_timer += dtime;
ReceiveAll();
/*
Packet counter
*/
{
float &counter = m_packetcounter_timer;
counter -= dtime;
if(counter <= 0.0)
{
counter = 20.0;
infostream << "Client packetcounter (" << m_packetcounter_timer
<< "):"<<std::endl;
m_packetcounter.print(infostream);
m_packetcounter.clear();
}
}
// UGLY hack to fix 2 second startup delay caused by non existent
// server client startup synchronization in local server or singleplayer mode
static bool initial_step = true;
if (initial_step) {
initial_step = false;
}
else if(m_state == LC_Created) {
float &counter = m_connection_reinit_timer;
counter -= dtime;
if(counter <= 0.0) {
counter = 2.0;
LocalPlayer *myplayer = m_env.getLocalPlayer();
FATAL_ERROR_IF(myplayer == NULL, "Local player not found in environment.");
u16 proto_version_min = g_settings->getFlag("send_pre_v25_init") ?
CLIENT_PROTOCOL_VERSION_MIN_LEGACY : CLIENT_PROTOCOL_VERSION_MIN;
if (proto_version_min < 25) {
// Send TOSERVER_INIT_LEGACY
// [0] u16 TOSERVER_INIT_LEGACY
// [2] u8 SER_FMT_VER_HIGHEST_READ
// [3] u8[20] player_name
// [23] u8[28] password (new in some version)
// [51] u16 minimum supported network protocol version (added sometime)
// [53] u16 maximum supported network protocol version (added later than the previous one)
char pName[PLAYERNAME_SIZE];
char pPassword[PASSWORD_SIZE];
memset(pName, 0, PLAYERNAME_SIZE * sizeof(char));
memset(pPassword, 0, PASSWORD_SIZE * sizeof(char));
std::string hashed_password = translate_password(myplayer->getName(), m_password);
snprintf(pName, PLAYERNAME_SIZE, "%s", myplayer->getName());
snprintf(pPassword, PASSWORD_SIZE, "%s", hashed_password.c_str());
sendLegacyInit(pName, pPassword);
}
if (CLIENT_PROTOCOL_VERSION_MAX >= 25)
sendInit(myplayer->getName());
}
// Not connected, return
return;
}
/*
Do stuff if connected
*/
/*
Run Map's timers and unload unused data
*/
const float map_timer_and_unload_dtime = 5.25;
if(m_map_timer_and_unload_interval.step(dtime, map_timer_and_unload_dtime)) {
ScopeProfiler sp(g_profiler, "Client: map timer and unload");
std::vector<v3s16> deleted_blocks;
m_env.getMap().timerUpdate(map_timer_and_unload_dtime,
g_settings->getFloat("client_unload_unused_data_timeout"),
g_settings->getS32("client_mapblock_limit"),
&deleted_blocks);
//.........这里部分代码省略.........