Exemplo n.º 1
0
////修改一条组件记录在ServerDllInfo表中
bool CServiceManage::ModifCom(CListCtrl * pListCtrl,SC_ServiceInfoStruct * avantp,SC_ServiceInfoStruct pServiceInfo)
{
	HANDLE hDatabase=sqlAddConnection("BZGameLocal.BCF");
	if(hDatabase<(HANDLE)0x1000)
		return false;
	HANDLE hRecord=sqlSPSetName(hDatabase,"SP_EditGameServer",true);
	if(hRecord<(HANDLE)0x1000)
	{
		sqlSPClose(hDatabase,hRecord);
		return false;
	}


	sqlSPAddPara(hDatabase,hRecord,"@ServerInfoID",pServiceInfo.uServiceID);
	sqlSPAddPara(hDatabase,hRecord,"@NameID",pServiceInfo.ServiceInfo.uNameID);
	sqlSPAddPara(hDatabase,hRecord,"@DeskPeople",pServiceInfo.ServiceInfo.uDeskPeople);
	sqlSPAddPara(hDatabase,hRecord,"@SuppoerType",pServiceInfo.ServiceInfo.uSupportType);
	sqlSPAddPara(hDatabase,hRecord,"@ServerVer",pServiceInfo.ServiceInfo.uServiceVer);
	sqlSPAddPara(hDatabase,hRecord,"@GameName",pServiceInfo.ServiceInfo.szGameName,sizeof(pServiceInfo.ServiceInfo.szGameName));
	sqlSPAddPara(hDatabase,hRecord,"@GameTable",pServiceInfo.ServiceInfo.szGameTable,sizeof(pServiceInfo.ServiceInfo.szGameTable));
	sqlSPAddPara(hDatabase,hRecord,"@DllFileName",pServiceInfo.ServiceInfo.szDLLFileName,sizeof(pServiceInfo.ServiceInfo.szDLLFileName));

	sqlSPExec(hDatabase,hRecord);

	int ret=sqlSPGetReturnValue(hDatabase,hRecord);
	sqlCloseConnection(hDatabase);
	//使无重复ID
	if (ret==1)
	{
		if (m_pIMessage!=NULL) m_pIMessage->ShowMessage("ServerDllInfo 表中无此ServerInfoID相同的组件,请刷新组件! ");
		//AfxMessageBox("ServerDllInfo 表中无此ServerInfoID相同的组件,请刷新组件! ");
		return false;
	}

	for(int i=0;i<= m_ServiceInfo.GetUpperBound();i++)
	{
		SC_ServiceInfoStruct *p;
		p = (SC_ServiceInfoStruct *) m_ServiceInfo.GetAt(i);
		if(p->uServiceID==pServiceInfo.uServiceID)
		{
			m_ServiceInfo.RemoveAt(i);//删除旧的记录(要么?)
			break;
		}
	}
	m_ServiceInfo.Add(&pServiceInfo);//同时把新的组件加到m_ServiceInfo中
	UpdateComDLLList(pListCtrl);
	return true;

}
Exemplo n.º 2
0
// 删除数据库房间信息 
bool CServiceManage::DeleteGameRoomInfo(SC_GameRoomInitStruct * pComRoomInfo)
{
	try
	{

		HANDLE hDatabase=sqlAddConnection("BZGameLocal.bcf");
		if(hDatabase<(HANDLE)0x1000)
		{
			
			return false;
		}
		HANDLE hRecord=sqlSPSetName(hDatabase,"SP_EraseRoomInfo");
		if(hRecord<(HANDLE)0x1000)
		{
			sqlSPClose(hDatabase,hRecord);
			return false;
		}

		sqlSPAddPara(hDatabase,hRecord,"@RoomID",pComRoomInfo->InitInfo.uRoomID);

		sqlSPExec(hDatabase,hRecord);

		sqlCloseConnection(hDatabase);

		SC_GameRoomInitStruct *p;
		for(int i = 0;i<=m_ComRoomInfo.GetUpperBound();i++)
		{
			p=(SC_GameRoomInitStruct *)m_ComRoomInfo.GetAt(i);
			if(p->uServiceID==pComRoomInfo->uServiceID && p->InitInfo.szGameRoomName==pComRoomInfo->InitInfo.szGameRoomName)
			{
				m_ComRoomInfo.RemoveAt(i);
				break;
			}
		}

		if (m_pIMessage!=NULL) m_pIMessage->ShowMessage(TEXT("删除组件的子实例信息完成!"));
		return true;
	}
	catch (...) 
	{ TRACE("CATCH:%s with %s\n",__FILE__,__FUNCTION__);
		if (m_pIMessage!=NULL) m_pIMessage->ShowMessage(TEXT("删除组件的子实例信息发生错误,稍后再次尝试..."));
	}
	return false;
}
Exemplo n.º 3
0
//增加一条组件记录在ServerDllInfo表中,同时把新的组件加到m_ServiceInfo中
bool CServiceManage::SetupCom(CListCtrl * pListCtrl,SC_ServiceInfoStruct pServiceInfo)
{

	HANDLE hDatabase=sqlAddConnection("BZGameLocal.BCF");
	if(hDatabase<(HANDLE)0x1000)
	{
		
		return false;
	}
	HANDLE hRecord=sqlSPSetName(hDatabase,"SP_AddGameServer",true);
	if(hRecord<(HANDLE)0x1000)
	{
		sqlSPClose(hDatabase,hRecord);
		return false;
	}

	sqlSPAddPara(hDatabase,hRecord,"@ServerInfoID",pServiceInfo.uServiceID);
	sqlSPAddPara(hDatabase,hRecord,"@NameID",pServiceInfo.ServiceInfo.uNameID);
	sqlSPAddPara(hDatabase,hRecord,"@DeskPeople",pServiceInfo.ServiceInfo.uDeskPeople);
	sqlSPAddPara(hDatabase,hRecord,"@SuppoerType",pServiceInfo.ServiceInfo.uSupportType);
	sqlSPAddPara(hDatabase,hRecord,"@ServerVer",pServiceInfo.ServiceInfo.uServiceVer);
	sqlSPAddPara(hDatabase,hRecord,"@GameName",pServiceInfo.ServiceInfo.szGameName,sizeof(pServiceInfo.ServiceInfo.szGameName));
	sqlSPAddPara(hDatabase,hRecord,"@GameTable",pServiceInfo.ServiceInfo.szGameTable,sizeof(pServiceInfo.ServiceInfo.szGameTable));
	sqlSPAddPara(hDatabase,hRecord,"@DllFileName",pServiceInfo.ServiceInfo.szDLLFileName,sizeof(pServiceInfo.ServiceInfo.szDLLFileName));

	sqlSPExec(hDatabase,hRecord);

	int ret=sqlSPGetReturnValue(hDatabase,hRecord);
	sqlCloseConnection(hDatabase);

	if(ret==1)
	{
		if (m_pIMessage!=NULL) m_pIMessage->ShowMessage("不能新建和现有组件ServerInfoID相同的组件,请重新填写! :-) ");//AfxMessageBox("不能新建和现有组件ServerInfoID相同的组件,请重新填写! :-) ");
		return false;
	}

	m_ServiceInfo.Add(&pServiceInfo);//同时把新的组件加到m_ServiceInfo中
	UpdateComDLLList(pListCtrl);
	return true;

}
Exemplo n.º 4
0
void CServiceManage::ClearRoomTWRecode(int iRoomID)
{
	HANDLE hDatabase=sqlAddConnection("BZGameLocal.BCF");
	if(hDatabase<(HANDLE)0x1000)
		return;

	HANDLE hRecord=sqlSPSetName(hDatabase,"SP_GetGameServerList",true);
	if(hRecord<(HANDLE)0x1000)
		return;

	sqlCloseRecord(hDatabase, hRecord);
    sqlSPClose(hDatabase, hRecord);

    hRecord=sqlSPSetName(hDatabase,"SP_ClearRoomTWLoginRecord");
    if(hRecord>=(HANDLE)0x1000)
    {
		sqlSPAddPara(hDatabase,hRecord,"@RoomID", iRoomID);
        sqlSPExec(hDatabase,hRecord);
        sqlCloseRecord(hDatabase, hRecord);
        sqlSPClose(hDatabase, hRecord);
    }
	sqlCloseConnection(hDatabase);
}
Exemplo n.º 5
0
//更新游戏列表
bool CServerGameListManage0::UpdateGameListBuffer(HANDLE hDatabase)
{
	//try
	//{
	//读取游戏类型列表
	HANDLE hRecord=sqlSPSetName(hDatabase,"SP_GetGameKind");
	if(hRecord<(HANDLE)0x1000)
		return false;

	if(!sqlSPExec(hDatabase,hRecord,true))
		return false;

	DWORD dwReadKindCount=(DWORD)sqlGetRecordCount(hDatabase,hRecord);


	if (dwReadKindCount>m_dwKindBufCount)
	{
		delete [] m_pKindPtr;
		m_pKindPtr=new ComKindInfo [dwReadKindCount];
		if (m_pKindPtr==NULL) 
		{
			sqlSPClose(hDatabase,hRecord); // zxj dfw 2009-11-12
			return false;
		}
		m_dwKindBufCount=dwReadKindCount;
	}

	//读取数据库获取游戏类型
	ComKindInfo KindRead;
	KindRead.Head.uSize=sizeof(KindRead);
	KindRead.Head.bDataType=GLK_GAME_KIND;
	m_dwKindCount=dwReadKindCount;
	int iCount=0;
	while(!sqlEndOfFile(hDatabase,hRecord))
	{
		sqlGetValue(hDatabase,hRecord,TEXT("KindID"),KindRead.uKindID);
		sqlGetValue(hDatabase,hRecord,TEXT("KindName"),KindRead.szKindName,sizeof(KindRead.szKindName));

		// duanxiaohui 20111107
		sqlGetValue(hDatabase,hRecord,TEXT("ParentKindID"),KindRead.uParentKindID);
		// end duanxiaohui

		*(m_pKindPtr+(iCount++))=KindRead;

		sqlMoveNext(hDatabase,hRecord);
	}
	sqlSPClose(hDatabase,hRecord);

	//读取名字信息
	hRecord=sqlSPSetName(hDatabase,"SP_GetGameName");
	if(hRecord<(HANDLE)0x1000)
		return false;

	if(!sqlSPExec(hDatabase,hRecord,true))
		return false;

	DWORD dwReadNameCount=(DWORD)sqlGetRecordCount(hDatabase,hRecord);
	if (dwReadNameCount>m_dwNameBufCount)
	{
		delete [] m_pNamePtr;
		m_pNamePtr=new ComNameInfo [dwReadNameCount];
		if (m_pNamePtr==NULL) 
		{
			sqlSPClose(hDatabase,hRecord); // zxj dfw 2009-11-12
			return false;
		}
		m_dwNameBufCount=dwReadNameCount;
	}

	//读取数据库
	ComNameInfo NameRead;
	NameRead.Head.uSize=sizeof(NameRead);
	NameRead.Head.bDataType=GLK_GAME_NAME;
	m_dwNameCount=dwReadNameCount;
	iCount=0;
	while(!sqlEndOfFile(hDatabase,hRecord))
	{
		sqlGetValue(hDatabase,hRecord,TEXT("KindID"),NameRead.uKindID);
		sqlGetValue(hDatabase,hRecord,TEXT("NameID"),NameRead.uNameID);
		sqlGetValue(hDatabase,hRecord,TEXT("ComName"),NameRead.szGameName,sizeof(NameRead.szGameName));
		sqlGetValue(hDatabase,hRecord,TEXT("ComProcess"),NameRead.szGameProcess,sizeof(NameRead.szGameProcess));
		*(m_pNamePtr+(iCount++))=NameRead;
		sqlMoveNext(hDatabase,hRecord);
		TRACE("SP_GetGameName: %d %d %s %s\n",NameRead.uKindID,NameRead.uNameID,NameRead.szGameName,NameRead.szGameProcess);
	}
	sqlSPClose(hDatabase,hRecord);


	//读取房间信息
	hRecord=sqlSPSetName(hDatabase,"SP_GetOnlineRoom");
	if(hRecord<(HANDLE)0x1000)
		return false;

	if(!sqlSPExec(hDatabase,hRecord,true))
		return false;

	DWORD dwReadRoomCount=(DWORD)sqlGetRecordCount(hDatabase,hRecord);

	bool bNew=false;
	if (dwReadRoomCount>m_dwRoomBufCount)
	{
		delete [] m_pRoomPtr;
		m_pRoomPtr=new ComRoomInfo [dwReadRoomCount];
		if (m_pRoomPtr==NULL) 
		{
			sqlSPClose(hDatabase,hRecord); // zxj dfw 2009-11-12
			throw DTR_GP_ERROR_UNKNOW;
		}
		m_dwRoomBufCount=dwReadRoomCount;
		bNew=true;
	}

	//读取数据库
	ComRoomInfo RoomRead;
	RoomRead.Head.uSize=sizeof(RoomRead);
	RoomRead.Head.bDataType=GLK_GAME_ROOM;
	m_dwRoomCount=dwReadRoomCount;
	iCount=0;
	bool b=false;
	while(!sqlEndOfFile(hDatabase,hRecord))
	{
		b=sqlGetValue(hDatabase,hRecord,TEXT("GameKindID"),RoomRead.uKindID);
		b=sqlGetValue(hDatabase,hRecord,TEXT("GameNameID"),RoomRead.uNameID);
		b=sqlGetValue(hDatabase,hRecord,TEXT("RoomID"),RoomRead.uRoomID);
		b=sqlGetValue(hDatabase,hRecord,TEXT("GameTypeID"),RoomRead.uComType);
		if(bNew)
			RoomRead.uPeopleCount=0;
		//sqlGetValue(hDatabase,hRecord,TEXT("OnLineCount"),RoomRead.uPeopleCount);
		b=sqlGetValue(hDatabase,hRecord,TEXT("VirtualUser"),RoomRead.uVirtualUser);//20081211 , Fred Huang
		RoomRead.uPeopleCount+=RoomRead.uVirtualUser;//20081211 , Fred Huang
		b=sqlGetValue(hDatabase,hRecord,TEXT("VirtualGameTime"),RoomRead.uVirtualGameTime);//20081211 , Fred Huang
		b=sqlGetValue(hDatabase,hRecord,TEXT("RoomRule"),RoomRead.dwRoomRule);//20081211 , Fred Huang

		b=sqlGetValue(hDatabase,hRecord,TEXT("SocketPort"),RoomRead.uServicePort);
		b=sqlGetValue(hDatabase,hRecord,TEXT("DeskPeople"),RoomRead.uDeskPeople);
		b=sqlGetValue(hDatabase,hRecord,TEXT("DeskCount"),RoomRead.uDeskCount);
		b=sqlGetValue(hDatabase,hRecord,TEXT("ServerIP"),RoomRead.szServiceIP,sizeof(RoomRead.szServiceIP));
		//wushuqun 2009.6.5
		//混战场房间名称   --begin
		b=sqlGetValue(hDatabase,hRecord,TEXT("BattleRoomID"),RoomRead.uBattleRoomID);
		b=sqlGetValue(hDatabase,hRecord,TEXT("BattleMatchTable"),RoomRead.szBattleGameTable,sizeof(RoomRead.szBattleGameTable));

		RoomRead.i64TimeStart = 0;
		RoomRead.i64TimeEnd = 0;
		if (RoomRead.dwRoomRule & GRR_CONTEST)
		{
			int nYear = 0, nMonth = 0, nDate = 0, nHour = 0, nMin = 0, nSec = 0, nss = 0;  
			CString temp;
			sqlGetValue(hDatabase, hRecord, TEXT("StartTime"), temp);
			if (temp != "")
			{
				sscanf(temp.GetBuffer(), TEXT("%d-%d-%d %d:%d:%d.%d"), &nYear, &nMonth, &nDate, &nHour, &nMin, &nSec, &nss);

				CTime _t(nYear, nMonth, nDate, nHour, nMin, nSec); 
				RoomRead.i64TimeStart = _t.GetTime();
			}
			else
			{
				RoomRead.i64TimeStart = 0;
			}
			sqlGetValue(hDatabase, hRecord, TEXT("EndTime"), temp);
			if (temp != "")
			{
				sscanf(temp.GetBuffer(), TEXT("%d-%d-%d %d:%d:%d.%d"), &nYear, &nMonth, &nDate, &nHour, &nMin, &nSec, &nss);

				CTime _t(nYear, nMonth, nDate, nHour, nMin, nSec); 
				RoomRead.i64TimeEnd = _t.GetTime();
			}
			else
			{
				RoomRead.i64TimeEnd = 0;
			}
			sqlGetValue(hDatabase, hRecord, TEXT("ContestID"), RoomRead.iContestID);
		}
		
		char szRoomName[61];
		memset(szRoomName,0,sizeof(szRoomName));
		if (RoomRead.uBattleRoomID > 0)
		{
			HANDLE hRecordTmp=sqlSPSetName(hDatabase,"SP_GetBattleRoomName");
			sqlSPAddPara(hDatabase,hRecordTmp,"@BattleRoomID",RoomRead.uBattleRoomID);
			sqlSPExec(hDatabase,hRecordTmp,true);
			sqlGetValue(hDatabase,hRecordTmp,TEXT("RoomName"),szRoomName,sizeof(szRoomName));
			sqlSPClose(hDatabase,hRecordTmp); // zxj dfw 2009-11-12
		}
		else
		{
			sqlGetValue(hDatabase,hRecord,TEXT("RoomName"),szRoomName,sizeof(szRoomName));
		}
		memcpy(RoomRead.szGameRoomName,szRoomName,sizeof(szRoomName));  
		//--end

		int iVIPRoom = 0;
		b=sqlGetValue(hDatabase,hRecord,TEXT("VIPRoom"),iVIPRoom);
		RoomRead.bVIPRoom = (iVIPRoom!=0);
		b=sqlGetValue(hDatabase,hRecord,TEXT("Version"),RoomRead.uVer);

		//{{Add by lxl 20101008 判断该房间是否具有密码
		char szPassWord[61];
		memset(szPassWord, 0, sizeof(szPassWord));
		b=sqlGetValue(hDatabase,hRecord,TEXT("RoomPassword"), szPassWord, sizeof(szPassWord));
		if (strlen(szPassWord)>10) // MD5密码一定有16字节以上,如果没这么多,表示是个无效的字符串
		{
			RoomRead.bHasPassword = true;
		}
		else
		{
			RoomRead.bHasPassword = false;
		}

		//租赁房间ID与时间
		sqlGetValue(hDatabase,hRecord,TEXT("tenancyID"), RoomRead.iLeaseID);
		if (RoomRead.iLeaseID != 0)
		{
			int nYear = 0, nMonth = 0, nDate = 0, nHour = 0, nMin = 0, nSec = 0, nss = 0;  
			CString temp;
			sqlGetValue(hDatabase, hRecord, TEXT("OpenRoomDate"), temp);
			if (temp != "")
			{
				sscanf(temp.GetBuffer(), TEXT("%d-%d-%d %d:%d:%d.%d"), &nYear, &nMonth, &nDate, &nHour, &nMin, &nSec, &nss);

				CTime _t(nYear, nMonth, nDate, nHour, nMin, nSec); 
				RoomRead.i64LeaseTimeStart = _t.GetTime();
			}
			else
			{
				RoomRead.i64LeaseTimeStart = 0;
			}
			int idays = 0;
			sqlGetValue(hDatabase,hRecord,TEXT("AppleyDays"),idays);
			RoomRead.i64LeaseTimeEnd = RoomRead.i64LeaseTimeStart + idays * 24 * 60 * 60;
		}


		*(m_pRoomPtr+(iCount++))=RoomRead;
		sqlMoveNext(hDatabase,hRecord);
	}
	sqlSPClose(hDatabase,hRecord);
	return true;

}
Exemplo n.º 6
0
//更新组件列表
bool CServiceManage::UpdateComDLLList(CListCtrl * pListCtrl)
{
	
	HANDLE hDatabase=sqlAddConnection("BZGameLocal.BCF");
	if(hDatabase<(HANDLE)0x1000)
	{
		
		return false;
	}

	HANDLE hRecord=sqlSPSetName(hDatabase,"SP_GetGameServerList",true);
	if(hRecord<(HANDLE)0x1000)
	{
		sqlSPClose(hDatabase,hRecord);
		return false;
	}

	sqlSPExec(hDatabase,hRecord,true);
	//写入数据前应清空记录
	pListCtrl->DeleteAllItems();
	m_ServiceInfo.RemoveAll();

	//读取资料
	TCHAR szBuffer[50];

	while(!sqlEndOfFile(hDatabase,hRecord))
	{
		//定义变量
		SC_ServiceInfoStruct * pServiceInfo=new SC_ServiceInfoStruct;
		memset(pServiceInfo,0,sizeof(SC_ServiceInfoStruct));
		m_ServiceInfo.Add(pServiceInfo);

		//读取数据
		sqlGetValue(hDatabase,hRecord,TEXT("ServerInfoID"),pServiceInfo->uServiceID);
		sqlGetValue(hDatabase,hRecord,TEXT("NameID"),pServiceInfo->ServiceInfo.uNameID);
		sqlGetValue(hDatabase,hRecord,TEXT("DeskPeople"),pServiceInfo->ServiceInfo.uDeskPeople);
		sqlGetValue(hDatabase,hRecord,TEXT("SupportType"),pServiceInfo->ServiceInfo.uSupportType);
		sqlGetValue(hDatabase,hRecord,TEXT("ServiceVer"),pServiceInfo->ServiceInfo.uServiceVer);
		sqlGetValue(hDatabase,hRecord,TEXT("GameName"),pServiceInfo->ServiceInfo.szGameName,sizeof(pServiceInfo->ServiceInfo.szGameName));
		sqlGetValue(hDatabase,hRecord,TEXT("GameTable"),pServiceInfo->ServiceInfo.szGameTable,sizeof(pServiceInfo->ServiceInfo.szGameTable));
		sqlGetValue(hDatabase,hRecord,TEXT("DLLFileName"),pServiceInfo->ServiceInfo.szDLLFileName,sizeof(pServiceInfo->ServiceInfo.szDLLFileName));
		//sqlGetValue(hDatabase,hRecord,TEXT("Writer"),pServiceInfo->ServiceInfo.szWriter,sizeof(pServiceInfo->ServiceInfo.szWriter));
		//sqlGetValue(hDatabase,hRecord,TEXT("DllNote"),pServiceInfo->ServiceInfo.szDllNote,sizeof(pServiceInfo->ServiceInfo.szDllNote));

        // PengJiLin, 2011-4-2, 指定哪些游戏是可用的
        if(FALSE == m_GameSelecter.GameIsUsable(pServiceInfo->ServiceInfo.uNameID))
        {
            memset(pServiceInfo,0,sizeof(SC_ServiceInfoStruct));
            sqlMoveNext(hDatabase,hRecord);
            continue;
        }

		//写入数据
		struct stat FileStat;
		int iItem=pListCtrl->InsertItem(pListCtrl->GetItemCount(),ltoa(pServiceInfo->uServiceID,szBuffer,10));
		pListCtrl->SetItem(iItem,1,1,pServiceInfo->ServiceInfo.szGameName,0,0,0,0);
		if (stat(pServiceInfo->ServiceInfo.szDLLFileName,&FileStat)==0) 
		{
			pListCtrl->SetItem(iItem,2,1,TEXT("已安装"),0,0,0,0);
			pServiceInfo->uServiceStation = 1;
		}
		else 
		{
			pListCtrl->SetItem(iItem,2,1,TEXT("未安装"),0,0,0,0);
			pServiceInfo->uServiceStation = 0;
		}
		pListCtrl->SetItem(iItem,3,1,ltoa(pServiceInfo->ServiceInfo.uServiceVer,szBuffer,10),0,0,0,0);
		pListCtrl->SetItem(iItem,4,1,ltoa(pServiceInfo->ServiceInfo.uDeskPeople,szBuffer,10),0,0,0,0);
		pListCtrl->SetItem(iItem,5,1,pServiceInfo->ServiceInfo.szGameTable,0,0,0,0);
		pListCtrl->SetItem(iItem,6,1,pServiceInfo->ServiceInfo.szDLLFileName,0,0,0,0);
		//pListCtrl->SetItem(iItem,7,1,pServiceInfo->ServiceInfo.szDllNote,0,0,0,0);
		pListCtrl->SetItemData(iItem,(DWORD_PTR)pServiceInfo);
		//pList->SendMessage(LVM_SETEXTENDEDLISTVIEWSTYLE,LVS_EX_FULLROWSELECT,LVS_EX_FULLROWSELECT);
		//pList->InsertColumn(0,TEXT("组件 ID"),LVCFMT_LEFT,60);
		//pList->InsertColumn(1,TEXT("组件名字"),LVCFMT_LEFT,100);
		//pList->InsertColumn(2,TEXT("组件状态"),LVCFMT_LEFT,80);
		//pList->InsertColumn(3,TEXT("版本号码"),LVCFMT_LEFT,60);
		//pList->InsertColumn(4,TEXT("游戏人数"),LVCFMT_LEFT,60);
		//pList->InsertColumn(5,TEXT("默认信息表"),LVCFMT_LEFT,100);
		//pList->InsertColumn(6,TEXT("模块名字"),LVCFMT_LEFT,150);
		sqlMoveNext(hDatabase,hRecord);
	}

    // PengJiLin, 2011-4-21, 清 TWLoginRecord 相关内容,避免崩溃后无法登陆
    sqlCloseRecord(hDatabase, hRecord);
    sqlSPClose(hDatabase, hRecord);

    hRecord=sqlSPSetName(hDatabase,"SP_ClearTWLoginRecord");
    if(hRecord>=(HANDLE)0x1000)
    {
        sqlSPAddPara(hDatabase,hRecord,"@ServiceName",m_ServiceName,m_ServiceName.GetLength());
        sqlSPExec(hDatabase,hRecord);
        sqlCloseRecord(hDatabase, hRecord);
        sqlSPClose(hDatabase, hRecord);
    }

	sqlCloseConnection(hDatabase);

	return true;

}
Exemplo n.º 7
0
void CServiceManage::CountOnLinePeople(CListCtrl * everyDLL, CListCtrl * everyRoom)
{
	long timeStamp=0;
	static int licCount=0;
	if(++licCount>=10)
		licCount=0;
	try
	{
		long licExpires=0;

		HANDLE hDatabase=sqlAddConnection("BZGameLocal.BCF");
		if(hDatabase<(HANDLE)0x1000)
			return;
		if(licCount==0)
			timeStamp=coreGetTimeStamp();
		HANDLE hRecord=sqlSPSetName(hDatabase,"SP_GetRoomList");
		if(hRecord<(HANDLE)0x1000)
			return;


		sqlSPSetName(hDatabase,"SP_GetOnlinePeopleCount");
		sqlSPAddPara(hDatabase,hRecord,"@ServiceName",m_ServiceName,sizeof(m_ServiceName));
		sqlSPExec(hDatabase,hRecord);

		TCHAR szBuffer[50];
		if(licCount==0)
			licExpires=coreGetLicenseExpires();
		while(!sqlEndOfFile(hDatabase,hRecord))
		{
			UINT uServerInfoID=0,uSocketPort=0,uOnLineCount=0;//无符号

			//读取ServerInfoID信息
			sqlGetValue(hDatabase,hRecord,TEXT("ServerInfoID"),uServerInfoID);
			//读取socketPort
			sqlGetValue(hDatabase,hRecord,TEXT("SocketPort"),uSocketPort);
			for(int i=0;i<m_ComRoomInfo.GetCount();i++)
			{
				SC_GameRoomInitStruct * p;
				p = (SC_GameRoomInitStruct *)m_ComRoomInfo.GetAt(i);
				if(uServerInfoID==p->uServiceID&&uSocketPort==p->InitInfo.uListenPort)
				{
					sqlGetValue(hDatabase,hRecord,TEXT("OnLineCount"),uOnLineCount);
					everyRoom->SetItem(i,9,1,ltoa(uOnLineCount,szBuffer,10),0,0,0,0);
				}
			}
			sqlMoveNext(hDatabase,hRecord);
		}
		sqlCloseConnection(hDatabase);

	#ifdef BZ_LICENSE
		
		if(timeStamp>licExpires && licCount==0)//edit..........
		{
			everyDLL->GetParent()->KillTimer(1);
			for(int i=0;i<=m_ComRoomInfo.GetUpperBound();i++)
			{
				SC_GameRoomInitStruct *p;
				p = (SC_GameRoomInitStruct*) m_ComRoomInfo.GetAt(i);
				if(p->hDllInstance==NULL||p->pIManageService==NULL)
					continue;
				StopGameRoom(p);
			}
			//修改提示
			UpdateRoomListInfo(everyRoom);
			
			CString s,code=coreGetCode();
			s.Format("您的服务器未注册或已过期,请与服务商联系。\n\n请将以下机器码发送给服务商,获取注册码文件:\n\n%s\n\n",code);
			everyDLL->GetParent()->MessageBox(s,"提示",MB_ICONERROR);
			everyDLL->GetParent()->GetParentFrame()->DestroyWindow();
			return;
		}

	#endif // BZ_LICENSE

		return;
	}
	catch (...) 
	{ 
		TRACE("CATCH:%s with %s\n",__FILE__,__FUNCTION__);
	}
	return ;
}
Exemplo n.º 8
0
///desc:获得所有游戏房间信息//W_0002.2
bool CServiceManage::GetRoomListInfo()
{
	////注册码检测////
	//bool bCheck = false;
	//bCheck = CheckLicense();
	//if(!bCheck)
	//{
	//	return false;
	//}

	//AfxMessageBox("GetRoomListInfo!");

	HANDLE hDatabase=sqlAddConnection("BZGameLocal.BCF");
	if(hDatabase<(HANDLE)0x1000)
		return false;
	HANDLE hRecord=sqlSPSetName(hDatabase,"SP_GetRoomList");
	if(hRecord<(HANDLE)0x1000)
		return false;

	try
	{

		sqlSPAddPara(hDatabase,hRecord,"@ServiceName",m_ServiceName,m_ServiceName.GetLength());
		sqlSPExec(hDatabase,hRecord,true);
		while(!sqlEndOfFile(hDatabase,hRecord))
		{
			bool goOn=false,update=false;
			UINT ui=0,uID=0,uPort=0;//无符号
			__int64 i64 = 0;
			//INT ui=0;//符号
			//定义变量
			SC_GameRoomInitStruct * pGameRoomInitInfo=new SC_GameRoomInitStruct;
			memset(pGameRoomInitInfo,0,sizeof(SC_GameRoomInitStruct));

            // PengJiLin, 2011-4-2, 指定哪些游戏是可用的
            sqlGetValue(hDatabase,hRecord,TEXT("NameID"),ui);
			pGameRoomInitInfo->InitInfo.iGameID = ui;
            if(FALSE == m_GameSelecter.GameIsUsable(ui))
            {
                sqlMoveNext(hDatabase,hRecord);
                delete pGameRoomInitInfo;
                continue;
            }

			//已经读取过的不加
			sqlGetValue(hDatabase,hRecord,TEXT("ServerInfoID"),uID);
			sqlGetValue(hDatabase,hRecord,TEXT("SocketPort"),uPort);
			for(int i=0;i<m_ComRoomInfo.GetCount();i++)
			{
				SC_GameRoomInitStruct * p;
				p = (SC_GameRoomInitStruct *)m_ComRoomInfo.GetAt(i);
				//启动的房间
				if(p->uServiceID==uID&&p->InitInfo.uListenPort==uPort&&p->hDllInstance!=NULL&&p->pIManageService!=NULL)
				{

					goOn=true;
					break;
				}
				//停止的房间
				if(p->uServiceID==uID&&p->InitInfo.uListenPort==uPort&&p->hDllInstance==NULL&&p->pIManageService==NULL)
				{
					update=true;
					delete pGameRoomInitInfo;
					pGameRoomInitInfo=p;
					break;
				}
			}
			if(goOn)
			{
				//移动下一条
				sqlMoveNext(hDatabase,hRecord);
				continue;
			}
			if(!update)
				m_ComRoomInfo.Add(pGameRoomInitInfo);
			//读取附加信息
			sqlGetValue(hDatabase,hRecord,TEXT("IDSort"),ui);
			pGameRoomInitInfo->uSortID=ui;
			sqlGetValue(hDatabase,hRecord,TEXT("KindID"),ui);
			pGameRoomInitInfo->uKindID=ui;
			sqlGetValue(hDatabase,hRecord,TEXT("EnableRoom"),pGameRoomInitInfo->bEnable);

			sqlGetValue(hDatabase,hRecord,TEXT("ServerInfoID"),ui);

			pGameRoomInitInfo->uServiceID=ui;////////////////
			//sqlGetValue(hDatabase,hRecord,TEXT("Note"),pGameRoomInitInfo->szRoomNote,sizeof(pGameRoomInitInfo->szRoomNote));
			//读取组件信息
			sqlGetValue(hDatabase,hRecord,TEXT("NameID"),ui);
			pGameRoomInitInfo->ServiceInfo.uNameID=ui;////////////
			sqlGetValue(hDatabase,hRecord,TEXT("DeskPeople"),ui);
			pGameRoomInitInfo->ServiceInfo.uDeskPeople=ui;
			sqlGetValue(hDatabase,hRecord,TEXT("SupportType"),ui);
			pGameRoomInitInfo->ServiceInfo.uSupportType=ui;
			sqlGetValue(hDatabase,hRecord,TEXT("ServiceVer"),ui);
			pGameRoomInitInfo->ServiceInfo.uServiceVer=ui;
			sqlGetValue(hDatabase,hRecord,TEXT("GameName"),pGameRoomInitInfo->ServiceInfo.szGameName,sizeof(pGameRoomInitInfo->ServiceInfo.szGameName));
			sqlGetValue(hDatabase,hRecord,TEXT("GameTable"),pGameRoomInitInfo->ServiceInfo.szGameTable,sizeof(pGameRoomInitInfo->ServiceInfo.szGameTable));
			sqlGetValue(hDatabase,hRecord,TEXT("DLLFileName"),pGameRoomInitInfo->ServiceInfo.szDLLFileName,sizeof(pGameRoomInitInfo->ServiceInfo.szDLLFileName));
			//sqlGetValue(hDatabase,hRecord,TEXT("Writer"),pGameRoomInitInfo->ServiceInfo.szWriter,sizeof(pGameRoomInitInfo->ServiceInfo.szWriter));
			//sqlGetValue(hDatabase,hRecord,TEXT("DllNote"),pGameRoomInitInfo->ServiceInfo.szDllNote,sizeof(pGameRoomInitInfo->ServiceInfo.szDllNote));

			//读取房间信息
			sqlGetValue(hDatabase,hRecord,TEXT("RoomRule"),ui);
			pGameRoomInitInfo->InitInfo.dwRoomRule=ui;
			sqlGetValue(hDatabase,hRecord,TEXT("UserPower"),ui);
			pGameRoomInitInfo->InitInfo.dwUserPower=ui;
			sqlGetValue(hDatabase,hRecord,TEXT("GameTypeID"),ui);
			pGameRoomInitInfo->InitInfo.uComType=ui;
			sqlGetValue(hDatabase,hRecord,TEXT("BasePoint"),ui);
			pGameRoomInitInfo->InitInfo.uBasePoint=ui;
			sqlGetValue(hDatabase,hRecord,TEXT("LessPoint"),ui);
			pGameRoomInitInfo->InitInfo.uLessPoint=ui;
			sqlGetValue(hDatabase,hRecord,TEXT("MaxPoint"),ui);
			pGameRoomInitInfo->InitInfo.uMaxPoint=ui;
			sqlGetValue(hDatabase,hRecord,TEXT("MaxLimite"),ui);
			pGameRoomInitInfo->InitInfo.uMaxLimite=ui;
			sqlGetValue(hDatabase,hRecord,TEXT("RunPublish"),ui);
			pGameRoomInitInfo->InitInfo.uRunPublish=ui;				
			sqlGetValue(hDatabase,hRecord,TEXT("Tax"),ui);
			pGameRoomInitInfo->InitInfo.uTax=ui;
			sqlGetValue(hDatabase,hRecord,TEXT("SocketPort"),ui);
			pGameRoomInitInfo->InitInfo.uListenPort=ui;
			sqlGetValue(hDatabase,hRecord,TEXT("MaxPeople"),ui);
			pGameRoomInitInfo->InitInfo.uMaxPeople=ui;
			pGameRoomInitInfo->InitInfo.iSocketSecretKey = SECRET_KEY;
			/////////////////////////////////////////////////////////
			/////////Kylin 20090116 Vip登陆功能
			sqlGetValue(hDatabase,hRecord,TEXT("VipResever"),ui);
			pGameRoomInitInfo->InitInfo.uVipReseverCount=ui;
			/////////////////////////////////////////////////////////
			//////////////////////////////////////////////////////////////////////////
			//20081211 , Fred Huang  Start
			sqlGetValue(hDatabase,hRecord,TEXT("VirtualUser"),ui);
			pGameRoomInitInfo->InitInfo.uVirtualUser=ui;
			sqlGetValue(hDatabase,hRecord,TEXT("VirtualGameTime"),ui);
			pGameRoomInitInfo->InitInfo.uVirtualGameTime=ui;
			//20081211 , Fred Huang  Stop
			//////////////////////////////////////////////////////////////////////////

			//wushuqun 2009.6.5
			//添加游戏混战场--begin
			sqlGetValue(hDatabase,hRecord,TEXT("BattleRoomID"),ui);
			pGameRoomInitInfo->InitInfo.uBattleRoomID = ui;
			sqlGetValue(hDatabase,hRecord,TEXT("BattleMatchTable"),pGameRoomInitInfo->InitInfo.szBattleGameTable,
				sizeof(pGameRoomInitInfo->InitInfo.szBattleGameTable));
			////////////////--end

			///< 金葫芦二代,是否VIP房间(VIP房间设置密码)
			sqlGetValue(hDatabase,hRecord,TEXT("VIPRoom"),ui);
			pGameRoomInitInfo->InitInfo.bVIPRoom = (ui!=0);

			sqlGetValue(hDatabase,hRecord,TEXT("DeskCount"),ui);
			pGameRoomInitInfo->InitInfo.uDeskCount=ui;
			sqlGetValue(hDatabase,hRecord,TEXT("RoomID"),ui);
			pGameRoomInitInfo->InitInfo.uRoomID=ui;
			sqlGetValue(hDatabase,hRecord,TEXT("StopLogon"),ui);
			pGameRoomInitInfo->InitInfo.uStopLogon=0;
			sqlGetValue(hDatabase,hRecord,TEXT("RoomName"),pGameRoomInitInfo->InitInfo.szGameRoomName,sizeof(pGameRoomInitInfo->InitInfo.szGameRoomName));
			sqlGetValue(hDatabase,hRecord,TEXT("ServerIP"),m_Info.m_szServiceIP,sizeof(m_Info.m_szServiceIP));
			sqlGetValue(hDatabase,hRecord,TEXT("TableLock"),pGameRoomInitInfo->InitInfo.szLockTable,sizeof(pGameRoomInitInfo->InitInfo.szLockTable));
			//wushuqun 2009.6.5
			if (pGameRoomInitInfo->InitInfo.uBattleRoomID > 0)
			{
				memcpy(pGameRoomInitInfo->InitInfo.szGameTable,
					pGameRoomInitInfo->InitInfo.szBattleGameTable,
					sizeof(pGameRoomInitInfo->InitInfo.szBattleGameTable));
			}
			else
			{
				sqlGetValue(hDatabase,hRecord,TEXT("TableMatch"),pGameRoomInitInfo->InitInfo.szGameTable,sizeof(pGameRoomInitInfo->InitInfo.szGameTable));
			}
			////////////////////
			sqlGetValue(hDatabase,hRecord,TEXT("TableIPRule"),pGameRoomInitInfo->InitInfo.szIPRuleTable,sizeof(pGameRoomInitInfo->InitInfo.szIPRuleTable));
			sqlGetValue(hDatabase,hRecord,TEXT("TableUserNameRule"),pGameRoomInitInfo->InitInfo.szNameRuleTable,sizeof(pGameRoomInitInfo->InitInfo.szNameRuleTable));
			//sqlGetValue(hDatabase,hRecord,TEXT("CenterSQLIP"),pGameRoomInitInfo->InitInfo.szSQLIP,sizeof(pGameRoomInitInfo->InitInfo.szSQLIP));
			//sqlGetValue(hDatabase,hRecord,TEXT("LogonSQLIP"),pGameRoomInitInfo->InitInfo.szLogonSQLIP,sizeof(pGameRoomInitInfo->InitInfo.szLogonSQLIP));
			//sqlGetValue(hDatabase,hRecord,TEXT("NativaSQLIP"),pGameRoomInitInfo->InitInfo.szNativeSQLIP,sizeof(pGameRoomInitInfo->InitInfo.szNativeSQLIP));
			// 增加百家乐桌型 add by wlr 20090714

			//{{ Add by lxl 2010-10-08 房间密码
			sqlGetValue(hDatabase,hRecord,TEXT("RoomPassword"),pGameRoomInitInfo->InitInfo.szRoomPassWord,sizeof(pGameRoomInitInfo->InitInfo.szRoomPassWord));
			/// 看是不是百家乐类型的游戏
			char cKey[10];
			CString sPath=CBcfFile::GetAppPath();
			int iResult = 0;
			if (CBcfFile::IsFileExist(sPath + "SpecialRule.bcf"))
			{
				CBcfFile fsr( sPath + "SpecialRule.bcf");
				sprintf(cKey, "%d", pGameRoomInitInfo->ServiceInfo.uNameID);
				iResult = fsr.GetKeyVal (_T("BJLType"), cKey, 0);
			}
			
			if (iResult!=0)
			{
				pGameRoomInitInfo->InitInfo.uDeskType = DESK_TYPE_BJL;
			}
			else
			{
				pGameRoomInitInfo->InitInfo.uDeskType = DESK_TYPE_NORMAL;
			}
			//end of add by wlr 20090714



			//比赛rongqiufen20120106
			if (pGameRoomInitInfo->InitInfo.dwRoomRule & GRR_CONTEST)
			{
				CTime _Now = CTime::GetCurrentTime();
				int nYear = 0, nMonth = 0, nDate = 0, nHour = 0, nMin = 0, nSec = 0, nss = 0;  
				CString temp;
			//	sqlGetValue(hDatabase, hRecord, TEXT("StartTime"), temp);
				if (temp != "")
				{
					sscanf(temp.GetBuffer(), TEXT("%d-%d-%d %d:%d:%d.%d"), &nYear, &nMonth, &nDate, &nHour, &nMin, &nSec, &nss);

					CTime _t(nYear, nMonth, nDate, nHour, nMin, nSec); 
					pGameRoomInitInfo->InitInfo.i64TimeStart = _t.GetTime();
				}
				else
				{
					pGameRoomInitInfo->InitInfo.i64TimeStart = 0;
				}
			//	sqlGetValue(hDatabase, hRecord, TEXT("EndTime"), temp);
				if (temp != "")
				{
					sscanf(temp.GetBuffer(), TEXT("%d-%d-%d %d:%d:%d.%d"), &nYear, &nMonth, &nDate, &nHour, &nMin, &nSec, &nss);

					CTime _t(nYear, nMonth, nDate, nHour, nMin, nSec); 
					pGameRoomInitInfo->InitInfo.i64TimeEnd = _t.GetTime();
				}
				else
				{
					pGameRoomInitInfo->InitInfo.i64TimeEnd = 0;
				}
				
				sqlGetValue(hDatabase,hRecord,TEXT("Chip"), pGameRoomInitInfo->InitInfo.i64Chip);
				sqlGetValue(hDatabase,hRecord,TEXT("LowChip"), pGameRoomInitInfo->InitInfo.i64LowChip);
				sqlGetValue(hDatabase,hRecord,TEXT("LowCount"), ui);
				pGameRoomInitInfo->InitInfo.iLowCount = ui; 
				sqlGetValue(hDatabase,hRecord,TEXT("ContestID"), ui);
				pGameRoomInitInfo->InitInfo.iContestID = ui; 
				sqlGetValue(hDatabase,hRecord,TEXT("Timeout"), ui);
				pGameRoomInitInfo->InitInfo.iTimeout = ui;
				sqlGetValue(hDatabase,hRecord,TEXT("LeastPeople"), ui);
				pGameRoomInitInfo->InitInfo.iLeasePeople = ui;
				sqlGetValue(hDatabase,hRecord,TEXT("UpPeople"), ui);
				pGameRoomInitInfo->InitInfo.iUpPeople = ui;
				pGameRoomInitInfo->InitInfo.uLessPoint = 0;
			}
			//租赁房间ID与时间
			sqlGetValue(hDatabase,hRecord,TEXT("tenancyID"), pGameRoomInitInfo->InitInfo.iLeaseID);
			if (pGameRoomInitInfo->InitInfo.iLeaseID != 0)
			{
				int nYear = 0, nMonth = 0, nDate = 0, nHour = 0, nMin = 0, nSec = 0, nss = 0;  
				CString temp;
				sqlGetValue(hDatabase, hRecord, TEXT("OpenRoomDate"), temp);
				if (temp != "")
				{
					sscanf(temp.GetBuffer(), TEXT("%d-%d-%d %d:%d:%d.%d"), &nYear, &nMonth, &nDate, &nHour, &nMin, &nSec, &nss);

					CTime _t(nYear, nMonth, nDate, nHour, nMin, nSec); 
					pGameRoomInitInfo->InitInfo.i64LeaseTimeStart = _t.GetTime();
				}
				else
				{
					pGameRoomInitInfo->InitInfo.i64LeaseTimeStart = 0;
				}
				int idays = 0;
				sqlGetValue(hDatabase,hRecord,TEXT("AppleyDays"),idays);
				pGameRoomInitInfo->InitInfo.i64LeaseTimeEnd = pGameRoomInitInfo->InitInfo.i64LeaseTimeStart + idays * 24 * 60 * 60;
			}

			//每局时长送金币
			sqlGetValue(hDatabase,hRecord,TEXT("SendTimeLength"), pGameRoomInitInfo->InitInfo.iTimeLength);
			sqlGetValue(hDatabase,hRecord,TEXT("SendCount"), pGameRoomInitInfo->InitInfo.iSendCount);

			sqlMoveNext(hDatabase,hRecord);
		}
		sqlCloseConnection(hDatabase);

		return true;
	}
	catch (...) 
	{ 
		TRACE("CATCH:%s with %s\n",__FILE__,__FUNCTION__);
		if (m_pIMessage!=NULL) 
			m_pIMessage->ShowMessage(TEXT("组件的子实例信息读取发生错误,稍后再次尝试..."));
	}

}