コード例 #1
0
ファイル: PrivManager.cpp プロジェクト: adi97ida/Server
//
// @version 05/06/07	Bang2ni - 이미 보너스가 적용 된 길드에 보너스 설정
//
void CPrivManager::AddGuildPriv(DWORD guild_id, BYTE type, int value, time_t duration_sec)
{
	if (MAX_PRIV_NUM <= type)
	{
		sys_err("PRIV_MANAGER: AddGuildPriv: wrong guild priv type(%u) recved", type);
		return;
	}

	typeof(m_aPrivGuild[type].begin()) it = m_aPrivGuild[type].find(guild_id);

	time_t now = CClientManager::instance().GetCurrentTime();
	time_t end = now + duration_sec;
	TPrivGuildData * p = new TPrivGuildData(type, value, guild_id, end);
	m_pqPrivGuild.push(std::make_pair(end, p));

	// ADD_GUILD_PRIV_TIME
	// 이미 보너스가 설정되 있다면 map 의 value 를 갱신해 준다.
	// 이전 value 의 포인터는 priority queue 에서 삭제될 때 해제된다.
	if (it != m_aPrivGuild[type].end())
		it->second = p;
	else
		m_aPrivGuild[type].insert(std::make_pair(guild_id, p));

	SendChangeGuildPriv(guild_id, type, value, end);
	// END_OF_ADD_GUILD_PRIV_TIME

	sys_log(0, "Guild Priv guild(%d) type(%d) value(%d) duration_sec(%d)", guild_id, type, value, duration_sec);
}
コード例 #2
0
ファイル: PrivManager.cpp プロジェクト: Rarder44/Server
//
// @version 05/06/07	Bang2ni - АМ№М єёіКЅє°Ў Аыїл µИ ±жµеїЎ єёіКЅє јіБ¤
//
void CPrivManager::AddGuildPriv(DWORD guild_id, BYTE type, int value, time_t duration_sec)
{
	if (MAX_PRIV_NUM <= type)
	{
		sys_err("PRIV_MANAGER: AddGuildPriv: wrong guild priv type(%u) recved", type);
		return;
	}

	PrivGuildDataMap::iterator it = m_aPrivGuild[type].find(guild_id);

	time_t now = CClientManager::instance().GetCurrentTime();
	time_t end = now + duration_sec;
	TPrivGuildData * p = new TPrivGuildData(type, value, guild_id, end);
	m_pqPrivGuild.push(std::make_pair(end, p));

	// ADD_GUILD_PRIV_TIME
	// АМ№М єёіКЅє°Ў јіБ¤µЗ АЦґЩёй map АЗ value ё¦ °»ЅЕЗШ БШґЩ.
	// АМАь value АЗ ЖчАОЕНґВ priority queue їЎј­ »иБ¦µЙ ¶§ ЗШБ¦µИґЩ.
	if (it != m_aPrivGuild[type].end())
		it->second = p;
	else
		m_aPrivGuild[type].insert(std::make_pair(guild_id, p));

	SendChangeGuildPriv(guild_id, type, value, end);
	// END_OF_ADD_GUILD_PRIV_TIME

	sys_log(0, "Guild Priv guild(%d) type(%d) value(%d) duration_sec(%d)", guild_id, type, value, duration_sec);
}
コード例 #3
0
ファイル: PrivManager.cpp プロジェクト: Rarder44/Server
//
// @version 05/06/07	Bang2ni - БЯє№АыАё·О єёіКЅє°Ў Аыїл µИ ±жµеїЎ ґлЗС Гіё®
//
void CPrivManager::Update()
{
	time_t now = CClientManager::instance().GetCurrentTime();

	while (!m_pqPrivGuild.empty() && m_pqPrivGuild.top().first <= now)
	{
		TPrivGuildData* p = m_pqPrivGuild.top().second;
		m_pqPrivGuild.pop();

		if (p->value != 0 && !p->bRemoved)
		{

			PrivGuildDataMap::const_iterator it = m_aPrivGuild[p->type].find(p->guild_id);

			// ADD_GUILD_PRIV_TIME
			// ±жµеїЎ БЯє№АыАё·О єёіКЅє°Ў јіБ¤µЗѕъА» °жїм map АЗ value °Ў °»ЅЕ(јцБ¤) µЗѕъАё№З·О
			// TPrivGuildData АЗ ЖчАОЕН°Ў °°А»¶§ ЅЗБ¦·О »иБ¦ЗШ БЦ°н °ФАУј­№цµйїЎ°Ф cast ЗШ БШґЩ.
			if (it != m_aPrivGuild[p->type].end() && it->second == p) {
				m_aPrivGuild[p->type].erase(it);
				SendChangeGuildPriv(p->guild_id, p->type, 0, 0);
				// END_OF_ADD_GUILD_PRIV_TIME
			}
		}

		delete p;
	}

	while (!m_pqPrivEmpire.empty() && m_pqPrivEmpire.top().first <= now)
	{
		TPrivEmpireData* p = (m_pqPrivEmpire.top().second);
		m_pqPrivEmpire.pop();

		if (p->value != 0 && !p->bRemoved)
		{
			SendChangeEmpirePriv(p->empire, p->type, 0, 0);
			m_aaPrivEmpire[p->type][p->empire] = 0;
		}

		delete p;
	}

	while (!m_pqPrivChar.empty() && m_pqPrivChar.top().first <= now)
	{
		TPrivCharData* p = (m_pqPrivChar.top().second);
		m_pqPrivChar.pop();

		if (!p->bRemoved)
		{
			// TODO send packet
			SendChangeCharPriv(p->pid, p->type, 0);
			PrivCharDataMap::const_iterator it = m_aPrivChar[p->type].find(p->pid);

			if (it != m_aPrivChar[p->type].end())
				m_aPrivChar[p->type].erase(it);
		}
		delete p;
	}
}
コード例 #4
0
ファイル: PrivManager.cpp プロジェクト: adi97ida/Server
//
// @version 05/06/07	Bang2ni - 중복적으로 보너스가 적용 된 길드에 대한 처리
//
void CPrivManager::Update()
{
	time_t now = CClientManager::instance().GetCurrentTime();

	while (!m_pqPrivGuild.empty() && m_pqPrivGuild.top().first <= now)
	{
		TPrivGuildData* p = m_pqPrivGuild.top().second;
		m_pqPrivGuild.pop();

		if (p->value != 0 && !p->bRemoved)
		{

			typeof(m_aPrivGuild[p->type].begin()) it = m_aPrivGuild[p->type].find(p->guild_id);

			// ADD_GUILD_PRIV_TIME
			// 길드에 중복적으로 보너스가 설정되었을 경우 map 의 value 가 갱신(수정) 되었으므로
			// TPrivGuildData 의 포인터가 같을때 실제로 삭제해 주고 게임서버들에게 cast 해 준다.
			if (it != m_aPrivGuild[p->type].end() && it->second == p) {
				m_aPrivGuild[p->type].erase(it);
				SendChangeGuildPriv(p->guild_id, p->type, 0, 0);
				// END_OF_ADD_GUILD_PRIV_TIME
			}
		}

		delete p;
	}

	while (!m_pqPrivEmpire.empty() && m_pqPrivEmpire.top().first <= now)
	{
		TPrivEmpireData* p = (m_pqPrivEmpire.top().second);
		m_pqPrivEmpire.pop();

		if (p->value != 0 && !p->bRemoved)
		{
			SendChangeEmpirePriv(p->empire, p->type, 0, 0);
			m_aaPrivEmpire[p->type][p->empire] = 0;
		}

		delete p;
	}

	while (!m_pqPrivChar.empty() && m_pqPrivChar.top().first <= now)
	{
		TPrivCharData* p = (m_pqPrivChar.top().second);
		m_pqPrivChar.pop();

		if (!p->bRemoved)
		{
			// TODO send packet
			SendChangeCharPriv(p->pid, p->type, 0);
			typeof(m_aPrivChar[p->type].begin()) it = m_aPrivChar[p->type].find(p->pid);
			if (it != m_aPrivChar[p->type].end())
				m_aPrivChar[p->type].erase(it);
		}
		delete p;
	}
}