예제 #1
0
BOOL KPlayerMgr::RemoveById( DWORD dwId )
{
	KPlayer* pPlayer = m_cObjMgr.GetById(dwId);
	QCONFIRM_RET_FALSE(pPlayer);

	// 擦除映射表
	m_mapNameToPlayer.erase(pPlayer->GetStrName());
	pPlayer->Uninit();

	return m_cObjMgr.Remove(dwId);
}
예제 #2
0
BOOL KPlayerMgr::RemoveByIndex( INT nIndex )
{
	KPlayer* pPlayer = m_cObjMgr.GetByIndex(nIndex);
	QCONFIRM_RET_FALSE(pPlayer);

	// 擦除映射表
	m_mapNameToPlayer.erase(pPlayer->GetStrName());
	pPlayer->Uninit();

	return m_cObjMgr.RemoveByIndex(nIndex);
}
예제 #3
0
KPlayer* KPlayerMgr::Add2(LPCSTR pszName, DWORD dwId /*= KD_BAD_ID*/ )
{
	INT nIndex = m_cObjMgr.Add(dwId);

	KPlayer* pPlayer = m_cObjMgr.GetByIndex(nIndex);
	QCONFIRM_RET_FALSE(pPlayer);

	BOOL bOk = pPlayer->Init(nIndex, pszName);
	QCONFIRM_RET_FALSE(bOk && "Player Init Failed!");

	// 名字到对象映射表
	m_mapNameToPlayer.insert(std::map<QString, KPlayer*>::value_type(pPlayer->GetStrName(), pPlayer));

	return pPlayer;
}
예제 #4
0
INT KPlayerMgr::Add(LPCSTR pszName, DWORD dwId /*= KD_BAD_ID*/ )
{
	INT nIndex = m_cObjMgr.Add(dwId);

	KPlayer* pPlayer = m_cObjMgr.GetByIndex(nIndex);
	QCONFIRM_RET_FALSE(pPlayer);

	// TODO: 人物创建时应该先SyncToNeighborPlayers,否则周围玩家的SetVar会失效 kk

	BOOL bOk = pPlayer->Init(nIndex, pszName);
	QCONFIRM_RET_FALSE(bOk && "Player Init Failed!");

	// 名字到对象映射表
	m_mapNameToPlayer.insert(std::map<QString, KPlayer*>::value_type(pPlayer->GetStrName(), pPlayer));

	return nIndex;
}