本文整理汇总了C++中LocalPlayer类的典型用法代码示例。如果您正苦于以下问题:C++ LocalPlayer类的具体用法?C++ LocalPlayer怎么用?C++ LocalPlayer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LocalPlayer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
}
示例2: getobject
int LuaLocalPlayer::l_get_breath(lua_State *L)
{
LocalPlayer *player = getobject(L, 1);
lua_pushinteger(L, player->getBreath());
return 1;
}
示例3: sendChatMessage
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: 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);
}
示例5: sendChatMessage
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));
}
}
}
示例6: deleteAuthData
void Client::handleCommand_AuthAccept(NetworkPacket* pkt)
{
deleteAuthData();
v3f playerpos;
*pkt >> playerpos >> m_map_seed >> m_recommended_send_interval
>> m_sudo_auth_methods;
playerpos -= v3f(0, BS / 2, 0);
// Set player position
LocalPlayer *player = m_env.getLocalPlayer();
assert(player != NULL);
player->setPosition(playerpos);
infostream << "Client: received map seed: " << m_map_seed << std::endl;
infostream << "Client: received recommended send interval "
<< m_recommended_send_interval<<std::endl;
// Reply to server
std::string lang = gettext("LANG_CODE");
if (lang == "LANG_CODE")
lang = "";
NetworkPacket resp_pkt(TOSERVER_INIT2, sizeof(u16) + lang.size());
resp_pkt << lang;
Send(&resp_pkt);
m_state = LC_Init;
}
示例7: switch
void InputMenu::callback(HUDuiControl* w, void* data) {
HUDuiList* list = (HUDuiList*)w;
std::vector<std::string> *options = &list->getList();
std::string selectedOption = (*options)[list->getIndex()];
switch (((const char*)data)[0]) {
case 'J':
BZDB.set("joystickname", selectedOption);
getMainWindow()->initJoystick(selectedOption);
break;
case 'F':
{
LocalPlayer* myTank = LocalPlayer::getMyTank();
// Do we force or not?
if (selectedOption == "Do not force") {
BZDB.set("allowInputChange", "1");
} else {
BZDB.set("allowInputChange", "0");
BZDB.set("forceInputDevice", selectedOption);
// Set the current input device to whatever we're forced to
if (myTank) {
myTank->setInputMethod(BZDB.get("forceInputDevice"));
}
}
}
break;
case 'G':
bool grabbing = (selectedOption == "yes");
if (grabbing)
BZDB.set("mousegrab", "true");
else
BZDB.set("mousegrab", "false");
getMainWindow()->enableGrabMouse(grabbing);
break;
}
}
示例8: selectPlayerItem
void Client::selectPlayerItem(u16 item)
{
LocalPlayer *player = m_env.getLocalPlayer();
assert(player != NULL);
player->wieldItem(item);
sendPlayerItem(item);
}
示例9: sendPlayerPos
void Client::sendPlayerPos()
{
LocalPlayer *myplayer = m_env.getLocalPlayer();
if (!myplayer)
return;
ClientMap &map = m_env.getClientMap();
u8 camera_fov = map.getCameraFov();
u8 wanted_range = map.getControl().wanted_range;
// Save bandwidth by only updating position when something changed
if(myplayer->last_position == myplayer->getPosition() &&
myplayer->last_speed == myplayer->getSpeed() &&
myplayer->last_pitch == myplayer->getPitch() &&
myplayer->last_yaw == myplayer->getYaw() &&
myplayer->last_keyPressed == myplayer->keyPressed &&
myplayer->last_camera_fov == camera_fov &&
myplayer->last_wanted_range == wanted_range)
return;
myplayer->last_position = myplayer->getPosition();
myplayer->last_speed = myplayer->getSpeed();
myplayer->last_pitch = myplayer->getPitch();
myplayer->last_yaw = myplayer->getYaw();
myplayer->last_keyPressed = myplayer->keyPressed;
myplayer->last_camera_fov = camera_fov;
myplayer->last_wanted_range = wanted_range;
NetworkPacket pkt(TOSERVER_PLAYERPOS, 12 + 12 + 4 + 4 + 4 + 1 + 1);
writePlayerPos(myplayer, &map, &pkt);
Send(&pkt);
}
示例10: getLocalPlayer
BaseLocalPlayer* getLocalPlayer(PlayerId id)
{
LocalPlayer *myTank = LocalPlayer::getMyTank();
if (myTank->getId() == id) return myTank;
#ifdef ROBOT
for (int i = 0; i < numRobots; i++)
if (robots[i]->getId() == id)
return robots[i];
#endif
return NULL;
}
示例11: lookupPlayer
Player* lookupPlayer(PlayerId id)
{
// check my tank first
LocalPlayer *myTank = LocalPlayer::getMyTank();
if (myTank->getId() == id)
return myTank;
if (id == ServerPlayer)
return World::getWorld()->getWorldWeapons();
if (id < curMaxPlayers && player[id] && player[id]->getId() == id)
return player[id];
// it's nobody we know about
return NULL;
}
示例12: sendPlayerPos
void Client::sendPlayerPos()
{
LocalPlayer *myplayer = m_env.getLocalPlayer();
if(myplayer == NULL)
return;
ClientMap &map = m_env.getClientMap();
u8 camera_fov = map.getCameraFov();
u8 wanted_range = map.getControl().wanted_range;
// Save bandwidth by only updating position when something changed
if(myplayer->last_position == myplayer->getPosition() &&
myplayer->last_speed == myplayer->getSpeed() &&
myplayer->last_pitch == myplayer->getPitch() &&
myplayer->last_yaw == myplayer->getYaw() &&
myplayer->last_keyPressed == myplayer->keyPressed &&
myplayer->last_camera_fov == camera_fov &&
myplayer->last_wanted_range == wanted_range)
return;
myplayer->last_position = myplayer->getPosition();
myplayer->last_speed = myplayer->getSpeed();
myplayer->last_pitch = myplayer->getPitch();
myplayer->last_yaw = myplayer->getYaw();
myplayer->last_keyPressed = myplayer->keyPressed;
myplayer->last_camera_fov = camera_fov;
myplayer->last_wanted_range = wanted_range;
//infostream << "Sending Player Position information" << std::endl;
u16 our_peer_id;
{
//MutexAutoLock lock(m_con_mutex); //bulk comment-out
our_peer_id = m_con.GetPeerID();
}
// Set peer id if not set already
if(myplayer->peer_id == PEER_ID_INEXISTENT)
myplayer->peer_id = our_peer_id;
assert(myplayer->peer_id == our_peer_id);
NetworkPacket pkt(TOSERVER_PLAYERPOS, 12 + 12 + 4 + 4 + 4 + 1 + 1);
writePlayerPos(myplayer, &map, &pkt);
Send(&pkt);
}
示例13: switch
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;
}
示例14: sendChatMessage
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);
}
}
示例15: 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;
}