⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 globaluserlist.cpp

📁 真正的传奇源代码
💻 CPP
字号:


#include "stdafx.h"
#include "globalUserList.h"
#include "..\Def\_OrzEx\error.h"


static CGlobalUserList s_globalUserList;


CGlobalUserList::CGlobalUserList()
: m_fixedMemory( GLOBALLIST_MAXLIST )
{
	if ( !m_listUser.InitHashTable( GLOBALLIST_MAXBUCKET, IHT_ROUNDUP ) )
		throw CError( "CGlobalUserList::CGlobalUserList 秦浆抛捞喉 积己 角菩" );

	m_listUser.SetGetKeyFunction( __cbGetKey );
}


CGlobalUserList::~CGlobalUserList()
{
	m_listUser.UninitHashTable( false );
}


bool CGlobalUserList::Insert( char *pID, char *pIP )
{
	if ( strlen( pID ) >= CUserInfo::MAXID || strlen( pIP ) >= CUserInfo::MAXIP )
		return false;

	CUserInfo *pUser = m_fixedMemory.Alloc();
	if ( !pUser )
		return false;

	strcpy( pUser->szID, pID );
	strcpy( pUser->szIP, pIP );

	Lock();
	if ( !m_listUser.Insert( pUser ) )
	{
		Unlock();
	
		m_fixedMemory.Free( pUser );
		return false;
	}
	Unlock();

	return true;
}


CGlobalUserList::CUserInfo * CGlobalUserList::Search( char *pID )
{
	Lock();
	CUserInfo *pUser = m_listUser.SearchKey( pID );
	Unlock();

	return pUser;
}


void CGlobalUserList::Remove( char *pID )
{
	Lock();
	m_fixedMemory.Free( m_listUser.Remove( (CUserInfo *) pID ) );
	Unlock();
}


char * CGlobalUserList::__cbGetKey( CUserInfo *pUser )
{
	return pUser->szID;
}




CGlobalUserList * GetGlobalUserList()
{
	return &s_globalUserList;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -