当前位置: 首页>>代码示例>>C++>>正文


C++ LocalPlayer::getName方法代码示例

本文整理汇总了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));
		}
	}
}
开发者ID:EXio4,项目名称:minetest,代码行数:25,代码来源:client.cpp

示例2: l_get_name

int LuaLocalPlayer::l_get_name(lua_State *L)
{
	LocalPlayer *player = getobject(L, 1);

	lua_pushstring(L, player->getName());
	return 1;
}
开发者ID:MultiCraftProject,项目名称:MultiCraft,代码行数:7,代码来源:l_localplayer.cpp

示例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
}
开发者ID:cyisfor,项目名称:freeminer,代码行数:26,代码来源:client.cpp

示例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);
	}
}
开发者ID:DarkDracoon,项目名称:minetest,代码行数:29,代码来源:client.cpp

示例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);
}
开发者ID:stevecotton,项目名称:Aethyra,代码行数:28,代码来源:charselect.cpp

示例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;
}
开发者ID:EXio4,项目名称:minetest,代码行数:43,代码来源:client.cpp

示例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);
	}
}
开发者ID:BlockMen,项目名称:minetest,代码行数:22,代码来源:client.cpp

示例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;
}
开发者ID:stevecotton,项目名称:Aethyra,代码行数:22,代码来源:charselect.cpp

示例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();
			}
//.........这里部分代码省略.........
开发者ID:EXio4,项目名称:minetest,代码行数:101,代码来源:client.cpp

示例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);

//.........这里部分代码省略.........
开发者ID:DarkDracoon,项目名称:minetest,代码行数:101,代码来源:client.cpp


注:本文中的LocalPlayer::getName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。