Example #1
0
double CScript::OpenBouns(const char* CmdStr, char* retStr)
{
	if(p_SrcShape == NULL) 
		return 0;

	CPlayer *pPlayer = dynamic_cast<CPlayer*>(p_SrcShape);

	if(pPlayer == NULL)
		return 0.0;


	if(pPlayer->GetCurrentProgress() != CPlayer::PROGRESS_NONE)
		return 0.0;

	DWORD dwCurTime = timeGetTime();
	if(dwCurTime - pPlayer->GetBounsTime() < CGlobeSetup::GetSetup()->lOperBounsTime)
	{
		return 0.0;
	}
	pPlayer->SetBounsTime(dwCurTime);

	CMessage msg(MSG_S2BDS_BOUNS_LOAD);
	msg.Add(pPlayer->GetAccount());
	msg.Add(pPlayer->GetExID());
	msg.Add(GetGame()->GetWSNumber());
	msg.SendToBounsServer();
	return 1.0;
} 
void CDPCoreClient::OnJoin( CAr & ar, DPID dpid )
{
	CMclAutoLock	Lock( CPlayerMng::Instance()->m_AddRemoveLock );

	DWORD dwSerial;
	BYTE byData;
	ar >> dwSerial;
	ar >> byData;	// 사용하지 않는다.

	CPlayer* pPlayer	= CPlayerMng::Instance()->GetPlayerBySerial( dwSerial );
	if( pPlayer == NULL )
	{
		WriteLog( "CDPCoreClient::OnJoin - player not found" );
		return;
	}

	CDPClient* pClient = g_DPClientArray.GetClient( pPlayer->GetChannel(), pPlayer->GetWorld(), D3DXVECTOR3(0.0f, 0.0f, 0.0f) );
	if( pClient )
	{
		pPlayer->SetClient( pClient );
		pClient->SendJoin( pPlayer );
	}
	else
	{
		WriteLog( "CDPCoreClient.OnJoin: server not found id: %d account: %s player: %s world: %d",
			      pPlayer->GetPlayerId(), pPlayer->GetAccount(), pPlayer->GetPlayer(), pPlayer->GetWorld() );
		g_DPCacheSrvr.DestroyPlayer( dpid );
	}
}
Example #3
0
void CExchangeGoods::CommitExchange(CPlayer *pDestPlayer, bool isSrc, DWORD dwVerifyID4CardPoint)
{
	if (!pDestPlayer)
		return;

	CPlayer *pSrcPlayer = static_cast<CPlayer *>(this);
	if (!pSrcPlayer)
		return;

	CPlayer *pPlayer = isSrc ? pSrcPlayer : pDestPlayer;
    SExchangeBox *pExchangeBox = isSrc ? &m_MyBox : &m_YouBox;

	if (!pPlayer || !pExchangeBox)
	{
		rfalse(4, 1, "ExchangeGoods.cpp - CommitExchange() - !pPlayer || !pExchangeBox");
		return;
	}

	// 还没有确认
	if (!(m_MyBox.m_bLocked && m_YouBox.m_bLocked))
	{
		TalkToDnid(pPlayer->m_ClientIndex, "一方或双方没有锁定,无法提交交易");
		return;
	}

	if (pExchangeBox->m_bCommit)
		return;

    pExchangeBox->m_bCommit = true;

	if (!(m_MyBox.m_bCommit && m_YouBox.m_bCommit))
    {
		TalkToDnid(pPlayer->m_ClientIndex, "对方还没有提交,请等待");

		// 通知交易双方,有一个人已经确认了
		SAExchangeOperationMsg opmsg;
        opmsg.dwSrcGID	= pSrcPlayer->GetGID();
        opmsg.dwDestGID = pDestPlayer->GetGID();
        opmsg.isSrc		= isSrc;
        opmsg.operation = SAExchangeOperationMsg::COMMIT;

		g_StoreMessage(pSrcPlayer->m_ClientIndex, &opmsg, sizeof(SAExchangeOperationMsg));
		g_StoreMessage(pDestPlayer->m_ClientIndex, &opmsg, sizeof(SAExchangeOperationMsg));
        return;
    }

	// 双方都已确认,可以开始交易了,检测金钱的合法性
	MY_ASSERT(pSrcPlayer->m_Property.m_Money >= m_MyBox.m_dwMoney);
	MY_ASSERT(pDestPlayer->m_Property.m_Money >= m_YouBox.m_dwMoney);

	if ((pSrcPlayer->m_Property.m_Money < m_MyBox.m_dwMoney) || (pDestPlayer->m_Property.m_Money < m_YouBox.m_dwMoney))
		return;
	
	bool succeed = false;
	// 这里要确认他们至少交换过一个道具,或者一分钱
	if (0 == m_MyBox.m_dwMoney && 0 == m_YouBox.m_dwMoney && !m_MyBox.m_SellNumber && !m_YouBox.m_SellNumber)
		goto goto_finish;
	else
	{
		// 检验交易发起方能否容纳金钱
		DWORD canGet = 0xffffffff - pSrcPlayer->m_Property.m_Money + m_MyBox.m_dwMoney;
		if (canGet < m_YouBox.m_dwMoney)
		{
			TalkToDnid(pSrcPlayer->m_ClientIndex, "您钱包太满了!");
			TalkToDnid(pDestPlayer->m_ClientIndex, "对方钱包太满了!");

			// 交易发起方无法容纳金钱
			pSrcPlayer->ExchangeCancel(pDestPlayer, isSrc);
			return;
		}

		// 检测交易目的方能否容纳金钱
		canGet = 0xffffffff - pDestPlayer->m_Property.m_Money + m_YouBox.m_dwMoney;
		if (canGet < m_MyBox.m_dwMoney)
		{
			TalkToDnid(pSrcPlayer->m_ClientIndex, "对方钱包太满了!");
			TalkToDnid(pDestPlayer->m_ClientIndex, "你钱包太满了!");

			// 交易目的方无法容纳金钱
			pSrcPlayer->ExchangeCancel(pDestPlayer, isSrc);
			return;
		}

		std::list<SAddItemInfo> itemList;

		// 检查交易目的玩家的背包状况
		for (int i=0; i<m_YouBox.m_SellNumber; i++)
			itemList.push_back(SAddItemInfo(m_YouBox.m_GoodsArray[i].wIndex, m_YouBox.m_GoodsArray[i].overlap));

		if (itemList.size() && !pSrcPlayer->CanAddItems(itemList, m_MyBox.m_SellNumber))
		{
			// 交易发起方的背包无法满足交易目的道具
			pSrcPlayer->SendStatusMsg(SANotifyStatus::NS_EXT_SELF_PACKAGE_LACK);
			pDestPlayer->SendStatusMsg(SANotifyStatus::NS_EXT_DEST_PACKAGE_LACK);

			pSrcPlayer->ExchangeCancel(pDestPlayer, isSrc);
			return;
		}
		
		itemList.clear();
		
		for (int i=0; i<m_MyBox.m_SellNumber; i++)
			itemList.push_back(SAddItemInfo(m_MyBox.m_GoodsArray[i].wIndex, m_MyBox.m_GoodsArray[i].overlap));
		
		if (itemList.size() && !pDestPlayer->CanAddItems(itemList, m_YouBox.m_SellNumber))
		{
			// 交易目的的背包无法满足交易目的道具
			pSrcPlayer->SendStatusMsg(SANotifyStatus::NS_EXT_DEST_PACKAGE_LACK);
			pDestPlayer->SendStatusMsg(SANotifyStatus::NS_EXT_SELF_PACKAGE_LACK);

			pSrcPlayer->ExchangeCancel(pDestPlayer, isSrc);
			return;
		}
	
	
		succeed = true; //背包检测成功,位置足够,可以开始交易,首先删除道具
		for (int i=0; i<m_MyBox.m_SellNumber; i++)
		{
			SPackageItem *pItem = pSrcPlayer->FindItemByPos(m_MyBox.m_GoodsArray[i].wCellPos, XYD_FT_ONLYLOCK);
			if (!pItem)
			{
				rfalse(4, 1, "ExchangeGoods.cpp - CommitExchange() - !pItem - 2");
				return;
			}
			MY_ASSERT(pItem);

			pSrcPlayer->DelItem(*pItem, "交易删除", true);
		}
	
		for (int i=0; i<m_YouBox.m_SellNumber; i++)
		{
			SPackageItem *pItem = pDestPlayer->FindItemByPos(m_YouBox.m_GoodsArray[i].wCellPos, XYD_FT_ONLYLOCK);
			if (!pItem)
			{
				rfalse(4, 1, "ExchangeGoods.cpp - CommitExchange() - !pItem");
				return;
			}
			MY_ASSERT(pItem);

			pDestPlayer->DelItem(*pItem, "交易删除", true);
		}
		
		// 给交易发起方添加道具
		for (int i=0; i<m_YouBox.m_SellNumber; i++)
		{
			const SItemBaseData *pData = CItemService::GetInstance().GetItemBaseData(m_YouBox.m_GoodsArray[i].wIndex);
			if (!pData)
			{
				rfalse(4, 1, "ExchangeGoods.cpp - CommitExchange() - !pData");
				return;
			}
			MY_ASSERT(pData);
		
			WORD willCreate = pSrcPlayer->TryPossibleMerge(m_YouBox.m_GoodsArray[i].wIndex, m_YouBox.m_GoodsArray[i].overlap, pData->m_Overlay);
			pSrcPlayer->InsertItem(m_YouBox.m_GoodsArray[i].wIndex, willCreate, pData, m_YouBox.m_GoodsArray[i], false);
		}

		// 给交易目的放添加道具
		for (int i=0; i<m_MyBox.m_SellNumber; i++)
		{
			const SItemBaseData *pData = CItemService::GetInstance().GetItemBaseData(m_MyBox.m_GoodsArray[i].wIndex);
			if (!pData)
			{
				rfalse(4, 1, "ExchangeGoods.cpp - CommitExchange() - !pData - 2");
			}
			MY_ASSERT(pData);

			WORD willCreate = pDestPlayer->TryPossibleMerge(m_MyBox.m_GoodsArray[i].wIndex, m_MyBox.m_GoodsArray[i].overlap, pData->m_Overlay);
			pDestPlayer->InsertItem(m_MyBox.m_GoodsArray[i].wIndex, willCreate, pData, m_MyBox.m_GoodsArray[i], false);
		}

		if (m_MyBox.m_dwMoney || m_YouBox.m_dwMoney)
		{
			pSrcPlayer->m_Property.m_Money  -= m_MyBox.m_dwMoney;
			pDestPlayer->m_Property.m_Money -= m_YouBox.m_dwMoney;

			pSrcPlayer->m_Property.m_Money	+= m_YouBox.m_dwMoney;
			pDestPlayer->m_Property.m_Money += m_MyBox.m_dwMoney;
	
			pSrcPlayer->m_PlayerPropertyStatus[XA_UNBIND_MONEY-XA_MAX_EXP] = true;
			pDestPlayer->m_PlayerPropertyStatus[XA_UNBIND_MONEY-XA_MAX_EXP] = true;
		}
	}
	
goto_finish:
	// 交易完成,清除当前的交易状态
	memset((CExchangeGoods*)pSrcPlayer, 0, sizeof(CExchangeGoods));
	memset((CExchangeGoods*)pDestPlayer, 0, sizeof(CExchangeGoods));

	// 通知客户端交易成功完成,可以关闭交易窗口了
	SAExchangeOperationMsg opmsg;
	opmsg.dwSrcGID	= pSrcPlayer->GetGID();
	opmsg.dwDestGID = pDestPlayer->GetGID();
	opmsg.isSrc		= isSrc;
	opmsg.operation = SAExchangeOperationMsg::SUCCEED;
	g_StoreMessage(pSrcPlayer->m_ClientIndex, &opmsg, sizeof(SAExchangeOperationMsg));
	g_StoreMessage(pDestPlayer->m_ClientIndex, &opmsg, sizeof(SAExchangeOperationMsg));


	//发送交易成功后保存数据
	if (!succeed) return;

	// 保存玩家道具
	SPackageItem *pItems = pSrcPlayer->m_Property.m_BaseGoods;
	memset(pItems, 0, PackageAllCells * sizeof(SPackageItem));
	for (DWORD i = 0; i < PackageAllCells; i++, pItems++)
	{
		SPackageItem *curItem = pSrcPlayer->FindItemByPos(i, XYD_FT_WHATEVER);
		if (curItem)
			*pItems = *curItem;
	}


	SPackageItem *pdestItems = pDestPlayer->m_Property.m_BaseGoods;
	memset(pdestItems, 0, PackageAllCells * sizeof(SPackageItem));
	for (DWORD i = 0; i < PackageAllCells; i++, pdestItems++)
	{
		SPackageItem *curItem = pDestPlayer->FindItemByPos(i, XYD_FT_WHATEVER);
		if (curItem)
			*pdestItems = *curItem;
	}

	SDoubleSavePlayerMsg sdsavemsg;
	dwt::strcpy(sdsavemsg.account[0],pSrcPlayer->GetAccount(),MAX_ACCOUNT);
    dwt::strcpy(sdsavemsg.account[1],pDestPlayer->GetAccount(),MAX_ACCOUNT);
	sdsavemsg.gid[0] = pSrcPlayer->GetGID();
	sdsavemsg.gid[1] = pDestPlayer->GetGID();
	
	SFixProperty *pSreData = dynamic_cast<SFixProperty *>(&pSrcPlayer->m_Property);
	SFixProperty *pDestData =dynamic_cast<SFixProperty *>(&pDestPlayer->m_Property);
	memcpy(&sdsavemsg.data[0],pSreData,sizeof(SFixProperty));
	memcpy(&sdsavemsg.data[1],pDestData,sizeof(SFixProperty));
	int num = SectionMessageManager::getInstance().evaluateDevidedAmount(sizeof(sdsavemsg));
	int id = 0;
	BOOL ret;
	for (int i = 0;i < num;i++)
	{
		SSectionMsg sMsg;
		id = SectionMessageManager::getInstance().devideMessage(i,num,&sMsg,&sdsavemsg,sizeof(sdsavemsg),id);
		ret = SendToLoginServer(&sMsg,sizeof(SSectionMsg));
	}
	//SectionMessageManager::getInstance().
	//SendToLoginServer(&sdsavemsg,sizeof(SDoubleSavePlayerMsg));
//	g_StoreMessage(pSrcPlayer->m_ClientIndex,&sdsavemsg,sizeof(SDoubleSavePlayerMsg));
	

	return;
}
// 响应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);

			//_snprintf(pszLogingInfo,512,"the cdkey(%s) MSG_L2W_LOG_QUEST_PLAYERBASELIST!", szCdkey);
			//PutStringToFile("Login_WS_Info",pszLogingInfo);
#ifdef _RUNSTACKINFO1_
			CMessage::AsyWriteFile(GetGame().GetStatckFileName(),pszLogingInfo);
#endif

			// 判断DBS是否准备好了
			if (!GetGame().GetInitVarLoadFlag() 
				|| !GetGame().GetInitRegionLoadFlag()
				|| !GetGame().GetInitFactionLoadFlag()
				|| !GetGame().GetInitUnionLoadFlag()
				|| !GetNetHandler().IsServerReady(NF_DB_SERVER)
				|| !GetGame().GetInitPersonalHouseLoadFlag()
				|| ( GetInst( Business::CBusinessManager ).IsEnable() &&
				!GetInst( Business::CBusinessManager ).IsDBLoaded() ) 
                || !GetInst( AH::OrderMgr ).IsDBLoaded() )
			{
				Log4c::Trace(ROOT_MODULE,FormatText("WS_LOGINMSG_40", 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.SendToServer(NF_LOGIN_SERVER);
				return;
			}

			// 判断GS是否准备好了
            if (!CMessage::IsGSReady(-1))
            {
                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.SendToServer(NF_LOGIN_SERVER);
                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 = new Account;
					if(acc)
					{
						CGUID accGuid;
						CGUID::CreateGUID(accGuid);
						acc->SetGUID(accGuid);
						acc->SetName(szCdkey);
					}
					GetGame().GetEntityManager()->CreateLoadAccountSession(acc);
					SAFE_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);
                Log4c::Warn(ROOT_MODULE,"MSG_L2W_LOG_QUEST_PLAYERDATA! Account[%s] Is Null!", szCdkey);
				CMessage msg(MSG_W2L_LOG_ANSWER_PLAYERDATA);
				msg.Add((long)0xFFFFFFFF);
				msg.Add((char)LOGIN_QUEST_PLAYERDATA_FAILED);
				msg.Add(szCdkey);
				msg.SendToServer(NF_LOGIN_SERVER);
				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);

                Log4c::Trace(ROOT_MODULE,"MSG_W2L_LOG_ANSWER_PLAYERDATA 玩家ID[%s],Cdkey[%s] 验证码错误!", szGUID, szCdkey);
				
				// 现在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.SendToServer(NF_LOGIN_SERVER);
				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,AppFrame::GetText("WS_LOGMESSAGE_0"), szCdkey);
// 					PutStringToFile("Login_WS_Info",pszLogingInfo);

                    Log4c::Trace(ROOT_MODULE,FormatText("WS_LOGMESSAGE_0", szCdkey));

					CMessage msg(MSG_W2L_LOG_ANSWER_PLAYERDATA);	
					msg.Add((long)-1);
					msg.Add((char)LOGIN_QUEST_PLAYERDATA_FAILED);
					msg.Add(szCdkey);
					msg.SendToServer(NF_LOGIN_SERVER);

					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.SendToServer(NF_LOGIN_SERVER);

				//char szGUID[128];
				//guid.tostring(szGUID);
				/*_snprintf(pszLogingInfo,512, AppFrame::GetText("WS_LOGMESSAGE_QUESTPROPERTYNOCREATEORLOADBASE"), szGUID, szCdkey);
				PutStringToFile("Login_WS_Info",pszLogingInfo);*/
				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);

                Log4c::Warn(ROOT_MODULE,"MSG_S2W_LOG_QUEST_PLAYERDATA! Account[%s] Is Null!", szCdkey);
				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);

                Log4c::Warn(ROOT_MODULE,"MSG_S2W_LOG_QUEST_PLAYERDATA 玩家ID[%s],Cdkey[%s] 验证码错误!", 
                    szGUID, lPlayer->GetStringAttr(string("Account")));
				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)
					{	
						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);
						
						// 更新WS上该玩家数据
						DBReadSet setReadDB;
						pMsg->GetDBReadSet(setReadDB);
						pPlayer->DecodeFromDataBlock(setReadDB);
						if(pPlayer)
						{
							if(GetNetHandler().IsServerReady(NF_DB_SERVER))
							{
								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);

						if(GetNetHandler().IsServerReady(NF_DB_SERVER))
						{
							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);	
						}
					}
					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);

                    Log4c::Warn(ROOT_MODULE,"玩家[%s]退出时异常,退出标志[%d],请检查代码逻辑!",szGuid, lFlag);

					CPlayer* pPlayer = GetGame().GetMapPlayer(PlayerGuid);
					if(pPlayer)
					{
						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.SendToGS(gsid);
							}
							else
							{
								tLoginInfo->SetPlayerState(PLAYER_STATE_BACKTOLOGIN);
								CMessage msg(MSG_W2L_LOG_PLAYERQUIT);
								msg.Add(strCDKey);
								msg.Add(0L);
								msg.SendToServer(NF_LOGIN_SERVER);//send to loginserver
							}
							
// 							_snprintf(pszLogingInfo,512,AppFrame::GetText("WS_LOGMESSAGE_12"), strCDKey);
// 							PutStringToFile("Login_WS_Info",pszLogingInfo);

                            Log4c::Trace(ROOT_MODULE,FormatText("WS_LOGMESSAGE_12", strCDKey));
							return;
						}
					}
				}
			}

			CMessage msg(MSG_W2L_LOG_PLAYERQUIT);
			msg.Add(strCDKey);
			msg.Add(0L);
			msg.SendToServer(NF_LOGIN_SERVER);//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;//GetGame().GetEntityManager()->FindLoginPlayer(guid);
			Account* tLoginInfo = GetGame().GetEntityManager()->FindAccount(cdkey);
			if(!tLoginInfo)
			{
// 				_snprintf(pszLogingInfo,512,"DeleteRole::未先创建账号对象[%s]!", cdkey);
// 				PutStringToFile("Login_WS_Info",pszLogingInfo);
                Log4c::Warn(ROOT_MODULE,"DeleteRole::未先创建账号对象[%s]!", cdkey);
				CMessage msg(MSG_W2L_LOG_DELETEROLE);
				msg.Add((char)LOGIN_DELETEROLE_FAILED);
				msg.Add(guid);
				msg.Add(cdkey);
				msg.SendToServer(NF_LOGIN_SERVER);//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.SendToServer(NF_LOGIN_SERVER);//send to loginserver
// 				_snprintf(pszLogingInfo,512,AppFrame::GetText("WS_LOGMESSAGE_14"), cdkey, szGUID);
// 				PutStringToFile("Login_WS_Info",pszLogingInfo);

                Log4c::Trace(ROOT_MODULE,FormatText("WS_LOGMESSAGE_14", cdkey, szGUID));
				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.SendToServer(NF_LOGIN_SERVER);//send to loginserver
		
// 				_snprintf(pszLogingInfo,512,AppFrame::GetText("WS_LOGMESSAGE_15"), 
// 					tLoginInfo->GetPlayerState(), cdkey, szGUID);
// 				PutStringToFile("Login_WS_Info",pszLogingInfo);

                Log4c::Trace(ROOT_MODULE,FormatText("WS_LOGMESSAGE_15",tLoginInfo->GetPlayerState(), cdkey, szGUID));
				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.SendToServer(NF_LOGIN_SERVER);//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.SendToServer(NF_LOGIN_SERVER);//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.SendToServer(NF_LOGIN_SERVER);//send to loginserver
				return;
			}

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

			char szGuid[40] = {0};
			guid.tostring(szGuid);			
// 			_snprintf(pszLogingInfo,512,AppFrame::GetText("WS_LOGMESSAGE_16"), szGuid);
// 			PutStringToFile("Login_WS_Info",pszLogingInfo);

            Log4c::Trace(ROOT_MODULE,FormatText("WS_LOGMESSAGE_16", szGuid));
			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);
                Log4c::Warn(ROOT_MODULE,"RestoreRole::未先创建账号对象[%s]!", cdkey);
				CMessage msg(MSG_W2L_LOG_RESTOREROLE);
				msg.Add((char)LOGIN_RESTOREROLE_FAILED);
				msg.Add(guid);
				msg.Add(cdkey);
				msg.SendToServer(NF_LOGIN_SERVER);//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.SendToServer(NF_LOGIN_SERVER);//send to loginserver
// 				_snprintf(pszLogingInfo,512,AppFrame::GetText("WS_LOGMESSAGE_17"), cdkey, szGUID);
// 				PutStringToFile("Login_WS_Info",pszLogingInfo);

                Log4c::Trace(ROOT_MODULE,FormatText("WS_LOGMESSAGE_17", cdkey, szGUID));
				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.SendToServer(NF_LOGIN_SERVER);//send to loginserver
// 				_snprintf(pszLogingInfo,512,AppFrame::GetText("WS_LOGMESSAGE_18"), 
// 					tLoginInfo->GetPlayerState(), cdkey, szGUID);
// 				PutStringToFile("Login_WS_Info",pszLogingInfo);

                Log4c::Trace(ROOT_MODULE,FormatText("WS_LOGMESSAGE_18", 
                    tLoginInfo->GetPlayerState(), cdkey, szGUID));
				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 = (BYTE)GlobalSetup::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.SendToServer(NF_LOGIN_SERVER);
				return;
			}

			// 结合创建列表和数据库,检测角色是否被建满。
			// 检测职业和性别是否符合条件
			GlobalSetup::GetSetup()->btMaxCharactersNum;
			bool bValid = false;
			//判断职业是否合法
			if(nOccupation < 0 || nOccupation >= OCC_Max)
				return;
			//判断性别是否合法
			if( nSex < 0 || nSex >= PlayerList::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.SendToServer(NF_LOGIN_SERVER);

// 				_snprintf(pszLogingInfo,512,AppFrame::GetText("WS_LOGMESSAGE_19"),btCountry);
// 				PutStringToFile("Login_WS_Info",pszLogingInfo);

                Log4c::Trace(ROOT_MODULE,FormatText("WS_LOGMESSAGE_19",btCountry));
				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.SendToServer(NF_LOGIN_SERVER);
				return;
			}

			// 角色名也被使用(先list和MapPlayer 最后DBS)
			if(	GetGame().IsNameExistInMapPlayer(szName) )
			{
				CMessage msg(MSG_W2L_LOG_CREATEROLE);
				msg.Add((BYTE)LOGIN_CREATEROLE_NAMEEXIST);
				msg.Add(szCdkey);
				msg.SendToServer(NF_LOGIN_SERVER);
				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);

                Log4c::Trace(ROOT_MODULE,"MSG_W2L_LOG_CREATEROLE! LoginInfo[%s] Is Null!", szCdkey);

				CMessage msg(MSG_W2L_LOG_CREATEROLE);
				msg.Add((BYTE)LOGIN_CREATEROLE_FAILED);
				msg.Add(szCdkey);
				msg.SendToServer(NF_LOGIN_SERVER);
				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.SendToServer(NF_LOGIN_SERVER);
								return;
							}
						}
					}
				}
			}

			
			// 创建一个创建玩家会话
			GetGame().GetEntityManager()->CreatePlayerCreateSession(szCdkey, szName, nOccupation, nSex, nHead, nFace,
				btCountry, btMaxCharactersNum,byConstellation,bSelectRecommCountry);		
// 			_snprintf(pszLogingInfo,512,AppFrame::GetText("WS_LOGMESSAGE_20"), szName);
// 			PutStringToFile("Login_WS_Info",pszLogingInfo);

            Log4c::Trace(ROOT_MODULE,FormatText("WS_LOGMESSAGE_20", szName));
		}
		break;
	}
}