示例#1
0
int Team5_DB::GetUserInfo(char *Name, UserInfo &RetInfo)
{
	RetInfo.ID = GetUserID(Name);
	if (RetInfo.ID < 0)
	{
		printf("GetUserInfo Error\n");
		return -1;
	}
	strcpy(RetInfo.Name, Name);
	if (GetUserPassword(Name, RetInfo.Password))
	{
		printf("GetUserInfo Error\n");
		return -1;
	}
	RetInfo.Score = GetUserScore(Name);
	if (RetInfo.Score < 0)
	{
		printf("GetUserInfo Error\n");
		return -1;
	}
	RetInfo.Rank = GetUserRank(Name);
	if (RetInfo.Rank < 0)
	{
		printf("GetUserInfo Error\n");
		return -1;
	}

	return 0;
}
示例#2
0
void CGameClient::Disconnect( const char *fmt, ... )
{
	va_list		argptr;
	char		reason[1024];

	if ( m_nSignonState == SIGNONSTATE_NONE )
		return;	// no recursion

	va_start (argptr,fmt);
	Q_vsnprintf (reason, sizeof( reason ), fmt,argptr);
	va_end (argptr);

	// notify other clients of player leaving the game
	// send the username and network id so we don't depend on the CBasePlayer pointer
	IGameEvent *event = g_GameEventManager.CreateEvent( "player_disconnect" );

	if ( event )
	{
		event->SetInt("userid", GetUserID() );
		event->SetString("reason", reason );
		event->SetString("name", GetClientName() );
		event->SetString("networkid", GetNetworkIDString() ); 
		g_GameEventManager.FireEvent( event );
	}

	m_Server->RemoveClientFromGame( this );

	CBaseClient::Disconnect( "%s", reason );
}
	bool		SmallNineAndroid::OnUpdateTime(float fElapsed)
	{
		m_fElapsed += fElapsed;
		if ((m_fElapsed / 60) >= m_fOnlineTime)
		{
			if (isSelf(m_wCurBanker))
			{
				m_fOnlineTime	= AndroidTimer::rdit(5, 15);
				m_fElapsed		= 0;
			}
			else
			{
				if (m_nChipInScore <= 0)
				{
					CString szMessage;
					szMessage.Format("[%d][%d]到达在线时间, 立刻下线", GetUserID(), GetGameID());
					LogEvent(szMessage, TraceLevel_Exception);

					BankerManager::GetSingleton().Remove(m_dwUserID);

					SetStatus(US_OFFLINE);
				}
				else
				{
					m_fOnlineTime	= AndroidTimer::rdit(5, 15);
					m_fElapsed		= 0;
				}
			}
		}
		return true;
	}
示例#4
0
//缺失值填充
bool TCManager::FillMissing(TCPacket &inP, AnaWord &aw, string szVO, TCPacket &outP)
{
	int nUserID = GetUserID(inP);
	if (nUserID==0)
		return SetResultState(false,outP,GetLanguage(UserIDIsNotFound));

	string szTableName = "";
	int nCount = aw.GetWordCount();
	for (int i=0;i<nCount;i++)
	{
		if (aw.GetAt(i) == "/DATA" &&  i< nCount-2 )
		{
			szTableName = aw.GetAt(i+2);
			break;
		}
	}
	if (szTableName.size()==0)
		return SetResultState(false,outP,GetLanguage(FormatIsError));
	//接口指针
	CDataInterface *pDI = g_system.GetCurData(nUserID,szTableName);
	if (pDI ==NULL)
	{
		if (g_system.OpenTable(nUserID,szTableName,szTableName)==false)
			return SetResultState(false,outP,GetLanguage(OperationFail)); 
		
		pDI = g_system.GetCurData(nUserID,szTableName);
		if (pDI ==NULL)
			return SetResultState(false,outP,GetLanguage(UserTableIsNotFound));
	}
#ifdef WINPLAT
	CTString szPath = "tlBase.dll";
	TCSystem::GetModulePath(szPath);
	szPath += "/DataDeal.dll";	
	HINSTANCE hmod = LoadLibrary(szPath.GetData());
	if (hmod==NULL)
	{//没有找到对应的DLL
		SetResultState(false,outP,GetLanguage(DLLFileNotFind));//"没有找到对应的DLL"
		return false;
	}
	
	typedef int (*pFillMissing)(CDataInterface *pData, LPCTSTR lpszVO);
	pFillMissing proc;
	proc = (pFillMissing)GetProcAddress(hmod,"FillMissing");
	if (proc==NULL)
	{//"没有找到对应的过程名"
		SetResultState(false,outP,GetLanguage(ProcNameNotFind));
		return false;
	}
	
	int rst = (*proc)(pDI,szVO.c_str());
	if (rst == 0)
		return SetResultState(false,outP,"");
	else
		return SetResultState(true,outP);
	
#else
	
#endif
	return SetResultState(true,outP);
}
示例#5
0
//Text	DeleteRowText表名 开始行号 行数
bool TCManager::DeleteRowText(TCPacket &inP,AnaWord &aw, TCPacket &outP)
{
	int nUserID = GetUserID(inP);
	if (nUserID==0)
		return SetResultState(false,outP,GetLanguage(UserIDIsNotFound));

	CDataInterface *pDI = g_system.GetCurData(nUserID,aw.GetAt(1));
	if (pDI ==NULL)
		return SetResultState(false,outP,GetLanguage(CurrentDataIsNULL));

	string sStartNo = aw.GetAt(2);
	string sRowNum = aw.GetAt(3);
	int nStartNo = atoi(sStartNo.c_str());
	int nRowNum  = atoi(sRowNum.c_str());
	if (nStartNo <=0 || nRowNum+nStartNo>pDI->GetRowCount()+1)
		return SetResultState(false,outP,GetLanguage(FormatIsError));

	
	pDI->m_DataAccess.SetCurRecNo(nStartNo);
	for (int i=0;i<nRowNum;i++)
	{
		pDI->m_DataAccess.Delete();
	}

	return SetResultState(true,outP);
}
	bool		SmallNineAndroid::OnApplyBanker(const void* pBuffer, WORD wDataSize)
	{
		if (wDataSize != sizeof(CMD_S_ApplyBanker)) 
			return 0;

		CMD_S_ApplyBanker* pApplyBanker = (CMD_S_ApplyBanker *)pBuffer;

		SUser* pUser = m_pUserManager->Search(pApplyBanker->szAccount);
		if (pUser != NULL)
		{
			if (pApplyBanker->bApplyBanker)
			{
				if (BankerManager::GetSingleton().Search(pUser->dwUserID) == NULL)
				{
					BankerManager::GetSingleton().Insert(
						new SBanker(pApplyBanker->szAccount, pApplyBanker->lScore, pUser->dwUserID)
						);
				}
			}
			else
			{
				BankerManager::GetSingleton().Remove(pUser->dwUserID);
			}

			if (isSelf(pUser->dwUserID))
			{
				BankerManager::GetSingleton().RemoveRequest(pUser->dwUserID);

				CString szMessage;
				szMessage.Format("[%d][%d]已移除上庄请求,当前请求次数%d", GetUserID(), GetGameID(), BankerManager::GetSingleton().GetRequestCount());
				LogEvent(szMessage, TraceLevel_Debug);
			}
		}
		return true;
	}
示例#7
0
/*
 *用户取消
 */
bool TCManager::Logout(TCPacket &inP,TCPacket &outP)
{
	int nUserID = GetUserID(inP);

	g_system.RemoveUser(nUserID);
	return SetResultState(true,outP);
}
示例#8
0
	virtual const wchar_t* GetDisplayName()
	{
		const wchar_t* name = GetAlias();
		if(name == 0 || *name == 0)
			name = GetUserID();
		return name;
	}
示例#9
0
/*
#往当前表添加数据
>Command
	Text
		AddRowText 表名  {行数据}
//	Data
//		二进制数据
<Command
	Text
		State OK|Fail [错误信息]
 */
bool TCManager::AddRowText(TCPacket &inP,AnaWord &aw, TCPacket &outP)
{
	int nUserID = GetUserID(inP);
	if (nUserID==0)
		return SetResultState(false,outP,GetLanguage(UserIDIsNotFound));

	CDataInterface *pDI = g_system.GetCurData(nUserID,aw.GetAt(1));
	if (pDI ==NULL)
		return SetResultState(false,outP,GetLanguage(CurrentDataIsNULL));

	AnaWord awNew;
	if (AnaSyntax::GetMidWords(aw,"{","}","",awNew)==false)
		return SetResultState(false,outP,GetLanguage(FormatIsError));

	int nCnt = awNew.GetWordCount()	;
	//awNew.Print();

	int nFieldCount = pDI->m_DataAccess.GetFieldCount();
	if (nCnt%nFieldCount != 0 )
		return SetResultState(false,outP,GetLanguage(FormatIsError));
	
	for (int i=0;i<nCnt;i++)
	{
		if (i%nFieldCount == 0 )
			pDI->m_DataAccess.Append();
		pDI->m_DataAccess.FieldByIndex(i%nFieldCount)->SetAsString(awNew.GetAt(i));
	}

	return SetResultState(true,outP);
}
示例#10
0
/*
	DeleteCol表名 所在列号 列数
	列号是从0开始(-1表示从后面追加)
 */
bool TCManager::DeleteCol(TCPacket &inP,AnaWord &aw, TCPacket &outP)
{
	if (aw.GetWordCount() !=4)
		return SetResultState(false,outP,GetLanguage(FormatIsError)); 

	int nUserID = GetUserID(inP);
	if (nUserID==0)
		return SetResultState(false,outP,GetLanguage(UserIDIsNotFound));

	CDataInterface *pDI = g_system.GetCurData(nUserID,aw.GetAt(1));
	if (pDI ==NULL)
		return SetResultState(false,outP,GetLanguage(UserTableIsNotFound));
	

	string sColStart = aw.GetAt(2);
	int nColStart = atoi(sColStart.c_str());
	string sColNum = aw.GetAt(3);
	int nColNum = atoi(sColNum.c_str());
	if (nColStart<0 || nColStart+nColNum-1 > pDI->GetColCount())
		return SetResultState(false,outP,GetLanguage(ColIndexOutOfRangeFail)); 

	while (nColNum)
	{
		pDI->m_DataAccess.m_pFieldList->Delete(nColStart);
		nColNum--;
	}


	return SetResultState(true,outP);
}
示例#11
0
/*
数据过滤
Filter /DATA =表名 /EXPR \"条件表达式\"
 */
bool TCManager::Filter(TCPacket &inP,AnaWord &aw, TCPacket &outP)
{
	int nUserID = GetUserID(inP);
	if (nUserID==0)
		return SetResultState(false,outP,GetLanguage(UserIDIsNotFound));

	int nTableIndex = -1;
	int nConditionIndex = -1;
	for (int i=2;i<aw.GetWordCount();i++)
	{
		if (aw.GetAt(i-2)=="/DATA" && aw.GetAt(i-1)=="=")
		{
			nTableIndex = i;
		}
		if (aw.GetAt(i-1)=="/EXPR")
		{
			nConditionIndex = i;
		}
	}

	if (nTableIndex == -1 || nConditionIndex == -1)
		return SetResultState(false,outP,GetLanguage(FormatIsError)); 
	
	CDataInterface *pDI = g_system.GetCurData(nUserID,aw.GetAt(nTableIndex));
	if (pDI ==NULL)
		return SetResultState(false,outP,GetLanguage(UserTableIsNotFound));
	

	string sCondition = aw.GetAt(nConditionIndex);

#ifdef WINPLAT
	CTString szPath = "tlBase.dll";
	TCSystem::GetModulePath(szPath);
	szPath += "/DataDeal.dll";	
	HINSTANCE hmod = LoadLibrary(szPath.GetData());
	if (hmod==NULL)
	{//没有找到对应的DLL
		return SetResultState(false,outP,GetLanguage(DLLFileNotFind));//"没有找到对应的DLL"
	}
	
	typedef int (*pFilter)(CDataInterface *pData, LPCSTR  sCondition);
	pFilter proc;
	proc = (pFilter)GetProcAddress(hmod,"Filter");
	if (proc==NULL)
	{//"没有找到对应的过程名"
		return SetResultState(false,outP,GetLanguage(ProcNameNotFind));
	}

	int rst = (*proc)(pDI,sCondition.c_str());
	if (rst == 0)
		return SetResultState(false,outP,"");
	else
		return SetResultState(true,outP);
			
#else

#endif

	return SetResultState(true,outP);
}
// -------------------------------------------
// OTAccount, OTTransaction, OTItem, and OTLedger are all derived from
// this class (OTTransactionType). Therefore they can all quickly identify
// whether one of the other components belongs to the same account, using 
// this method.
//
bool OTTransactionType::IsSameAccount(const OTTransactionType & rhs) const
{
    if (
        (GetUserID()        != rhs.GetUserID())        ||
        (GetRealAccountID() != rhs.GetRealAccountID()) ||
        (GetRealServerID()  != rhs.GetRealServerID())
        )
        return false;
    return true;
}
示例#13
0
/*

数据排序
Sort  /DATA =表名 /EXPR \"[字段名1] ASC [字段名2] DESC ...\"
 */
bool TCManager::Sort(TCPacket &inP,AnaWord &aw, TCPacket &outP)
{
	int nUserID = GetUserID(inP);
	if (nUserID==0)
		return SetResultState(false,outP,GetLanguage(UserIDIsNotFound));
	
	int nTableIndex = -1;
	int nExprIndex = -1;

	int i=0;
	for (i=2;i<aw.GetWordCount();i++)
	{
		if (aw.GetAt(i-2)=="/DATA" && aw.GetAt(i-1)=="=")
			nTableIndex = i;
		if (aw.GetAt(i-1)=="/EXPR")
			nExprIndex = i;
	}
 
	if (nTableIndex == -1 ||  nExprIndex == -1)
		return SetResultState(false,outP,GetLanguage(FormatIsError)); 
	CDataInterface *pDI = g_system.GetCurData(nUserID,aw.GetAt(nTableIndex));
	if (pDI ==NULL)
		return SetResultState(false,outP,GetLanguage(UserTableIsNotFound));
	

	string strExpr = aw.GetAt(nExprIndex);
	AnaWord aw2;
	aw2.Import(strExpr);
	if (aw2.GetWordCount()%2 != 0)
		return SetResultState(false,outP,GetLanguage(FormatIsError)); 

	CTArray<int,int> sortAry;
	for (i=0;i<aw2.GetWordCount()/4;i++)
	{
		string strLeft  = aw2.GetAt(i*4);
		string strRight = aw2.GetAt(i*4+2);
		if (strLeft != "[" || strRight != "]")
			return SetResultState(false,outP,GetLanguage(FormatIsError));
		string strField = aw2.GetAt(i*4+1);
		int nIndex = pDI->IndexByName(strField.c_str());
		if (nIndex ==-1)
			return SetResultState(false,outP,GetLanguage(FormatIsError));
		string strDirection = aw2.GetAt(i*4 + 3);
		nIndex++;
		if (strDirection == "DESC")
			nIndex = -nIndex;
		else if (strDirection != "ASC")
			return SetResultState(false,outP,GetLanguage(FormatIsError)); 
		sortAry.Add(nIndex);
	}

	pDI->m_DataAccess.MergeSort(sortAry);

	return SetResultState(true,outP);
}
示例#14
0
/*
 *清除当前用户ID的数据集
 */
bool TCManager::ClearCurData(TCPacket &inP,AnaWord &aw, TCPacket &outP)
{
	int nUserID = GetUserID(inP);
	if (nUserID==0)
		return SetResultState(false,outP,GetLanguage(UserIDIsNotFound));
	CDataInterface *pDI = g_system.GetCurData(nUserID,aw.GetAt(1));
	if (pDI ==NULL)
		return SetResultState(false,outP,GetLanguage(UserTableIsNotFound));
	pDI->m_DataAccess.NewFile();
	return SetResultState(true,outP);
}
示例#15
0
/*
	PasteCol 表名 源列名称 目标列名称
 */
bool TCManager::PasteCol(TCPacket &inP,AnaWord &aw, TCPacket &outP)
{
	if (aw.GetWordCount() !=4)
		return SetResultState(false,outP,GetLanguage(FormatIsError)); 

	int nUserID = GetUserID(inP);
	if (nUserID==0)
		return SetResultState(false,outP,GetLanguage(UserIDIsNotFound));
	
	string sTableName = aw.GetAt(1);
	string sSrcName  = aw.GetAt(2);
	string sDstName  = aw.GetAt(3);
	CDataInterface *pDI = g_system.GetCurData(nUserID,aw.GetAt(1));
	if (pDI == NULL)
		return SetResultState(false,outP,GetLanguage(UserTableIsNotFound));
	CField *pSrcField = pDI->FieldByName(sSrcName.c_str());
	if (pSrcField == NULL)
		return SetResultState(false,outP,GetLanguage(FieldNameNotFind)); 
	CFieldType ft = pSrcField->GetFieldType();
	CField *pDstField = pDI->FieldByName(sDstName.c_str());
	if (pDstField == NULL)
	{
		pDstField = pDI->m_DataAccess.m_pFieldList->CreateField(ft);
		pDstField->SetFieldName(sDstName);
		pDstField->SetWidth(pSrcField->GetWidth());
		pDI->m_DataAccess.m_pFieldList->Add(pDstField);
	}
	pDI->m_DataAccess.First();
	while (!pDI->m_DataAccess.Eof())
	{
		pDI->m_DataAccess.Edit();
		if (pSrcField->IsNull())
		{
			pDstField->SetNull();
		}
		else
		{
			if (ft == fDouble)
				pDstField->SetAsDouble(pSrcField->GetAsDouble());
			else if (ft == fInt)
				pDstField->SetAsInteger(pSrcField->GetAsInteger());
			else if (ft == fBoolean)
				pDstField->SetAsBool(pSrcField->GetAsBool());
			else if (ft == fString)
				pDstField->SetAsString(pSrcField->GetAsString());
			else
				pDstField->SetAsDateTime(&pSrcField->GetAsDateTime());
		}
		pDI->m_DataAccess.Next();
	}
	return SetResultState(true,outP);
}
示例#16
0
/***********************************************************************************************************
 * 程序创建:赵进军                     程序修改:赵进军
 * 函数功能:根据文件ID获取对应的用户ID
 * 参数说明:
 *  lFileID:文件ID
 * 注意事项:null
 * 修改日期:2015/10/31 10:47:00
 ***********************************************************************************************************/
j_long_t CMySQLAccess::GetUserIDFrmFile(long lFileID)
{
	if (!m_bConnected)
		return -1;
	long retResult = -1;
	char strCmd[128] = { 0 };
	sprintf(strCmd, "SELECT UserID FROM transfile WHERE FileID='%d';", lFileID);
	retResult = GetUserID(strCmd);
	if (retResult >= 0)
		return retResult;
	else
		return -1;
}
示例#17
0
//连接数据库
void CADO::CreateDBCNT( CONNECTPTR& cnt )
{
	try
	{
		cnt.time = CTime::GetCurrentTime();//2012.07.20 无条件的记录一个时间
		cnt.pConn.CreateInstance(__uuidof(Connection));
		cnt.pConn->ConnectionTimeout=30;//连接超时时间设置,单位秒
		CString str;
#ifdef XWB_SQL_LINK
		//Provider=SQLOLEDB;Data Source=192.168.0.102; Initial Catalog=hsrun10; User ID=sa; Password=hs2003info
		str.Format("Provider=SQLOLEDB;Data Source=%s; Initial Catalog=%s; User ID=%s; Password=%s",
			GetDataSource(),GetInitialCatalog(),GetUserID(),GetPassword() );
#else
		str.Format("Provider=OraOLEDB.Oracle;Data Source=%s;User ID=%s;Password=%s;PLSQLRSet=1",
			GetDataSource(),GetUserID(),GetPassword() );
#endif
		_variant_t varSRC( (LPSTR)(LPCTSTR)str );
		_bstr_t bsConnect(varSRC);
		if (S_OK != cnt.pConn->Open(bsConnect, "", "", adModeUnknown))
		{//连接失败
			if(cnt.pConn->State)
				cnt.pConn->Close();
			cnt.pConn = NULL;
		}
		else
		{//连接成功
#ifdef XWB_SQL_LINK //2013.06.13 xuwb: SQL SERVER兼容读取出参和数据集
			cnt.pConn->CursorLocation = adUseClient;
#endif
			cnt.pCommand.CreateInstance(__uuidof(Command));
			cnt.pCommand->ActiveConnection = cnt.pConn;
		}
	}
	catch(...)
	{
		cnt.pConn = NULL;
		cnt.pCommand = NULL;
	}
}
示例#18
0
BOOL CRemindApp::GetNetworkUserId(LPSTR lplzNetworkUserName, LPSTR pszMessage)
{
	*pszMessage = '\0';

	CString csUserFileName;
	CString csMessage;
	
	TRY
	{
		csUserFileName = PmwDirectory;
		csUserFileName += USERS_DAT_FILE_NAME;

		// Cheat for now!
		m_nNetworkUserId = GetUserID(lplzNetworkUserName+1, csUserFileName, &m_nNetworkUserCount);

		if (m_nNetworkUserId < 0)
		{
			switch (m_nNetworkUserId)
			{
				case NetIDError_FileInUse:
				{
					csMessage.LoadString(IDS_NETWORK_FILE_IN_USE);
					break;
				}
				case NetIDError_Corrupt:
				{
					csMessage.LoadString(IDS_NETWORK_FILE_CORRUPTED);
					break;
				}
				case NetIDError_Create:
				{
					csMessage.LoadString(IDS_NETWORK_FILE_CANT_CREATE);
					break;
				}
				default:
				{
					// Should not get here.
					ASSERT(FALSE);
					break;
				}
			}
		}
	}
	END_TRY

	strcpy(pszMessage, csMessage);

   TRACE("ID: %d Count: %d\n", m_nNetworkUserId, m_nNetworkUserCount);

	return *pszMessage == 0;
}
示例#19
0
//InsertRowText 表名 开始行号 行数 [\{ 行数据 \}]
bool TCManager::InsertRowText(TCPacket &inP,AnaWord &aw, TCPacket &outP)
{
	int nUserID = GetUserID(inP);
	if (nUserID==0)
		return SetResultState(false,outP,GetLanguage(UserIDIsNotFound));

	CDataInterface *pDI = g_system.GetCurData(nUserID,aw.GetAt(1));
	if (pDI ==NULL)
		return SetResultState(false,outP,GetLanguage(CurrentDataIsNULL));

	string sStartNo = aw.GetAt(2);
	string sRowNum = aw.GetAt(3);
	int nStartNo = atoi(sStartNo.c_str());
	int nRowNum  = atoi(sRowNum.c_str());
	if (nStartNo <=0 )
		return SetResultState(false,outP,GetLanguage(FormatIsError));

	if (aw.GetWordCount() == 4)
	{//插入全为空值
		pDI->m_DataAccess.SetCurRecNo(nStartNo);
		for (int i=0;i<nRowNum; i++)
			pDI->m_DataAccess.Insert();
		return SetResultState(true,outP);

	}

	AnaWord awNew;
	if (AnaSyntax::GetMidWords(aw,"{","}","",awNew)==false)
		return SetResultState(false,outP,GetLanguage(FormatIsError));

	int nCnt = awNew.GetWordCount()	;
	//awNew.Print();

	int nFieldCount = pDI->m_DataAccess.GetFieldCount();
	if (nCnt%nFieldCount != 0 )
		return SetResultState(false,outP,GetLanguage(FormatIsError));
	
	
	pDI->m_DataAccess.SetCurRecNo(nStartNo+1);
	for (int i=0;i<nCnt;i++)
	{
		if (i%nFieldCount == 0 )
		{
			pDI->m_DataAccess.Insert();
		}

		pDI->m_DataAccess.FieldByIndex(i%nFieldCount)->SetAsString(awNew.GetAt(i));
	}

	return SetResultState(true,outP);
}
示例#20
0
/*  关闭一个表
Text	
	CloseTable 表名  
*/
bool TCManager::CloseTable(TCPacket &inP,AnaWord &aw, TCPacket &outP)
{
	int nUserID = GetUserID(inP);
	if (nUserID==0)
		return SetResultState(false,outP,GetLanguage(UserIDIsNotFound));

	if (aw.GetWordCount()!=2)
		return SetResultState(false,outP,GetLanguage(FormatIsError)); 

	if (g_system.CloseTable(nUserID,aw.GetAt(1))==false)
		return SetResultState(false,outP,GetLanguage(OperationFail)); 
	else
		return SetResultState(true,outP);
}
示例#21
0
/*
#获取字段和记录信息 文件名没有,则返回当前表信息
>Command
	Text
		GetDataInfo 表名
<Command
	Text
		ColInfo	列信息
		Fail 错误信息
 */
bool TCManager::GetDataInfo(TCPacket &inP,AnaWord &aw,TCPacket &outP)
{
	if (aw.GetWordCount()!=2)
		return SetResultState(false,outP,GetLanguage(FormatIsError)); 

	int nUserID = GetUserID(inP);
	if (nUserID==0)
		return SetResultState(false,outP,GetLanguage(UserIDIsNotFound));

	CDataInterface *pDI = g_system.GetCurData(nUserID,aw.GetAt(1));
	if (pDI ==NULL)
	{
		return SetResultState(false,outP,GetLanguage(UserTableIsNotFound));
	}

	CDataAccess &da = pDI->m_DataAccess;

	
	string strScript ;
	int nCnt = da.GetRecordCount();
	char  buffer[50];
	memset(buffer,0,50);
	sprintf(buffer,"%d",nCnt);
	string sRecordCount = buffer;
	for (int i=0;i<da.GetFieldCount();i++)
	{
		CField *pField = da.FieldByIndex(i);
		string ss = (const char*)pField->GetFieldName();				
		ss = AnaWord::GetUniquely(ss);
		CFieldType ft = pField->GetFieldType();
		if (ft ==fString )
			ss = ss + " s ";
		else if (ft == fDate)
			ss = ss + " d ";
		else if (ft == fInt)
			ss = ss + " n ";
		else if (ft == fDouble)
			ss = ss + " f ";
		else if (ft == fBoolean)
			ss = ss + " b ";
		
		char buf[10];
		sprintf(buf," %d ",pField->GetWidth());
		string sWidth = buf;
		strScript = strScript+ " "+ ss +sWidth;
	}
	sRecordCount = "ColInfo "+sRecordCount + strScript;
	outP.AddItem("Text",sRecordCount);
	return SetResultState(true,outP);
}
示例#22
0
/*
	EditCol 表名 所在列号 {字段名A 类型 长度}
	列号是从0开始(-1表示从后面追加),类型表示,s 字符串 d 日期类型 n 数字类型
 */
bool TCManager::EditCol(TCPacket &inP,AnaWord &aw, TCPacket &outP)
{
	if (aw.GetWordCount()%3 !=0)//保证是3的整数倍
		return SetResultState(false,outP,GetLanguage(FormatIsError)); 

	int nUserID = GetUserID(inP);
	if (nUserID==0)
		return SetResultState(false,outP,GetLanguage(UserIDIsNotFound));

	CDataInterface *pDI = g_system.GetCurData(nUserID,aw.GetAt(1));
	if (pDI ==NULL)
		return SetResultState(false,outP,GetLanguage(UserTableIsNotFound));
	

	string sColStart = aw.GetAt(2);
	int nColStart = atoi(sColStart.c_str());
	if (nColStart<0 || nColStart+aw.GetWordCount()/3-1 > pDI->GetColCount())
		return SetResultState(false,outP,GetLanguage(ColIndexOutOfRangeFail)); 

	for (int i=1;i<	aw.GetWordCount()/3 ;i++)
	{
		string sName =aw.GetAt(i*3+0);
		string sType =aw.GetAt(i*3+1);
		string sLength =aw.GetAt(i*3+2);
		CFieldType ft = fDouble;
		if (sType == "s" || sType == "S")
			ft = fString;
		else if (sType == "d" || sType == "D")
			ft = fDate;
		else if (sType == "n" || sType == "N")
			ft = fInt;
		else if (sType == "f" || sType == "F")
			ft = fDouble;
		else if (sType == "b" || sType == "B")
			ft = fBoolean;

		CField *pField = pDI->m_DataAccess.m_pFieldList->CreateField(ft);
		pField->SetWidth(atoi(sLength.c_str()));
		//pDI->m_DataAccess.m_pFieldList->Insert(pField,nColStart++);
		pDI->m_DataAccess.m_pFieldList->Modify(nColStart++,pField);
		if (pField->SetFieldName(sName)==false)
			return SetResultState(false,outP,GetLanguage(SetFieldNameFail));
	}


	return SetResultState(true,outP);
}
示例#23
0
void CGameClient::ActivatePlayer( void )
{
	CBaseClient::ActivatePlayer();

	COM_TimestampedLog( "CGameClient::ActivatePlayer -start" );

	// call the spawn function
	if ( !sv.m_bLoadgame )
	{
		g_ServerGlobalVariables.curtime = sv.GetTime();

		COM_TimestampedLog( "g_pServerPluginHandler->ClientPutInServer" );

		g_pServerPluginHandler->ClientPutInServer( edict, m_Name );
	}

    COM_TimestampedLog( "g_pServerPluginHandler->ClientActive" );

	g_pServerPluginHandler->ClientActive( edict, sv.m_bLoadgame );

	COM_TimestampedLog( "g_pServerPluginHandler->ClientSettingsChanged" );

	g_pServerPluginHandler->ClientSettingsChanged( edict );

	COM_TimestampedLog( "GetTestScriptMgr()->CheckPoint" );

	GetTestScriptMgr()->CheckPoint( "client_connected" );

	// don't send signonstate to client, client will switch to FULL as soon 
	// as the first full entity update packets has been received

	// fire a activate event
	IGameEvent *event = g_GameEventManager.CreateEvent( "player_activate" );

	if ( event )
	{
		event->SetInt( "userid", GetUserID() );
		g_GameEventManager.FireEvent( event );
	}

	COM_TimestampedLog( "CGameClient::ActivatePlayer -end" );
}
bool NFCLoginNet_HttpServerModule::OnWorldSelect(const NFHttpRequest & req)
{
	std::string strResponse;
	NFIResponse xResponse;

	std::string user = GetUserID(req);

	NFRequestSelectWorld xRequestSelectWorld;
	ajson::load_from_buff(xRequestSelectWorld, req.body.c_str());
	if (xRequestSelectWorld.id == 0)
	{
		xResponse.code = NFIResponse::ResponseType::RES_TYPE_FAILED;

		ajson::string_stream ss;
		ajson::save_to(ss, xResponse);
		strResponse = ss.str();

		return m_pHttpNetModule->ResponseMsg(req, strResponse, NFWebStatus::WEB_OK);
	}

	NFMsg::ReqConnectWorld xData;
	xData.set_world_id(xRequestSelectWorld.id);
	xData.set_login_id(pPluginManager->GetAppID());
	xData.mutable_sender()->CopyFrom(NFINetModule::NFToPB(NFGUID()));
	xData.set_account(user);

	m_pNetClientModule->SendSuitByPB(NF_SERVER_TYPES::NF_ST_MASTER, user, NFMsg::EGameMsgID::EGMI_REQ_CONNECT_WORLD, xData);
	/*
	while (true)
	{
		YieldCo();

		if ()
		{
			break;
		}
	}
	*/

	return m_pHttpNetModule->ResponseMsg(req, strResponse, NFWebStatus::WEB_OK);
}
示例#25
0
/*
#创建新文件和字段结构 [] 表示可以为空
CreateTable  \{ 列名 类型 长度 {,列名 类型 长度} \}	

类型的话,s 字符串 d 日期类型 n 数字类型
返回 Text :表名

 */
bool TCManager::CreateTable(TCPacket &inP,AnaWord &aw, TCPacket &outP)
{
	int nUserID = GetUserID(inP);
	if (nUserID==0)
		return SetResultState(false,outP,GetLanguage(UserIDIsNotFound));

	string sTableName = g_system.CreateUserData(nUserID);
	CDataInterface *pDI = g_system.GetCurData(nUserID,sTableName);

	AnaWord awNew;
	if (AnaSyntax::GetMidWords(aw,"{","}",",",awNew)==false)
	{
		outP.AddItem("Text",FormatIsError);
		return false;
	}

	int nCnt = awNew.GetWordCount();
	for (int i=0;i<nCnt/3;i++)
	{
		CTString sType = awNew.GetAt(3*i+1);
		CFieldType ft = fDouble;
		if (sType == "s" || sType == "S")
			ft = fString;
		else if (sType == "d" || sType == "D")
			ft = fDate;
		else if (sType == "n" || sType == "N")
			ft = fInt;
		else if (sType == "f" || sType == "F")
			ft = fDouble;
		else if (sType == "b" || sType == "B")
			ft = fBoolean;

		int nWidth = atoi(awNew.GetAt(3*i+2).c_str());
		pDI->m_DataAccess.AddField(awNew.GetAt(3*i),ft,nWidth);
	}
	outP.AddItem("Text",sTableName);//返回表名

	return SetResultState(true,outP);
}
示例#26
0
int CPacketProcess::ClientLogin(CUser * pUser)
{
	char szNickname[MAX_NICKNAME_LEN];
	char szPassword[MAX_NICKNAME_LEN];
		
	if(!pUser->GetRecvPacket()->GetString(szNickname, MAX_NICKNAME_LEN))
	{
		ServerLog()->Log("Login Message : Nickname get Error.");
		return PROCEDURE_ERROR;
	}
	if(!pUser->GetRecvPacket()->GetString(szPassword, MAX_NICKNAME_LEN))
	{
		ServerLog()->Log("Login Message : Password get Error.");
		return PROCEDURE_ERROR;
	}

	pUser->SetIsAlive(true);

	ServerLog()->Log("User Login Nickname : %s", szNickname);

	if(!GetUserID(pUser, szNickname, szPassword))
		return PROCEDURE_SENDNCLOSE;

	BroadcastNewUser(pUser);

	// User Info Setting
	pUser->SetUserNickname(szNickname);
	pUser->SetOnline(true);

	// Server Info Update
	SMemManager()->CurrentUserIncrease();
	ServerLog()->Log("Add Current User, Count : %d", SMemManager()->GetCurrentUser());
	ServerLog()->Log("(Login User) Nickname : %s, DataBase ID : %d", pUser->GetUserNickname(), pUser->GetDatabaseID());

	SendUserInfo(pUser);

	return PROCEDURE_SUCCESS;
}
示例#27
0
/*
 *	以文件方式获得数据
>Command
	Text
		GetDataRowText 表名 (rowstart,rowend)
	
<Command
	Text
		TableText 数据

 */
bool TCManager::GetDataRowText(TCPacket &inP,AnaWord &aw, TCPacket &outP)
{
	if (aw.GetWordCount()!=7)
		return SetResultState(false,outP,GetLanguage(FormatIsError)); 

	int nUserID = GetUserID(inP);
	if (nUserID==0)
		return SetResultState(false,outP,GetLanguage(UserIDIsNotFound));

	CDataInterface *pDI = g_system.GetCurData(nUserID,aw.GetAt(1));
	if (pDI ==NULL)
		return SetResultState(false,outP,GetLanguage(UserTableIsNotFound));
	

	string sRowStart = aw.GetAt(3);
	string sRowEnd = aw.GetAt(5);
	int nRowStart = atoi(sRowStart.c_str());
	int nEndRow = atoi(sRowEnd.c_str());
	
	pDI->m_DataAccess.SetCurRecNo(nRowStart+1);
	string strOut = "TableText";
	for (int i=0;i<nEndRow-nRowStart+1 ;i++)
	{
		for (int j=0;j<pDI->m_DataAccess.GetFieldCount();j++)
		{
			CTString str = pDI->m_DataAccess.FieldByIndex(j)->GetAsString();
			string ss =(char*) str;
			if (ss.size()==0)
				ss = ".";
			strOut = strOut + " " +ss ;
			
		}
		
		pDI->m_DataAccess.Next();
	}
	outP.AddItem("Text",strOut);
	return SetResultState(true,outP);
}
示例#28
0
/*
	SetWeight 表名 字段名 
 */
bool TCManager::SetWeight(TCPacket &inP,AnaWord &aw, TCPacket &outP)
{
	if (aw.GetWordCount() !=3)//保证是3的整数倍
		return SetResultState(false,outP,GetLanguage(FormatIsError)); 

	int nUserID = GetUserID(inP);
	if (nUserID==0)
		return SetResultState(false,outP,GetLanguage(UserIDIsNotFound));

	CDataInterface *pDI = g_system.GetCurData(nUserID,aw.GetAt(1));
	if (pDI ==NULL)
		return SetResultState(false,outP,GetLanguage(UserTableIsNotFound));
	

	string sField = aw.GetAt(2);
	int nIndex = pDI->m_DataAccess.IndexByName(sField);
	if (nIndex == -1)
		return SetResultState(false,outP,GetLanguage(FieldNameNotFind));

	pDI->SetWeightNumb(nIndex);
	return SetResultState(true,outP);

}
NFWebStatus NFCLoginNet_HttpServerModule::OnFilter(const NFHttpRequest & req)
{
	std::string user = GetUserID(req);
	std::string jwt = GetUserJWT(req);

	bool bRet = CheckUserJWT(user, jwt);
	if (bRet)
	{
		return NFWebStatus::WEB_OK;
	}

	return NFWebStatus::WEB_AUTH;
	/*
	std::cout << "OnFilter: " << std::endl;

	std::cout << "url: " << req.url << std::endl;
	std::cout << "path: " << req.path << std::endl;
	std::cout << "type: " << req.type << std::endl;
	std::cout << "body: " << req.body << std::endl;

	std::cout << "params: " << std::endl;

	for (auto item : req.params)
	{
		std::cout << item.first << ":" << item.second << std::endl;
	}

	std::cout << "headers: " << std::endl;

	for (auto item : req.headers)
	{
		std::cout << item.first << ":" << item.second << std::endl;
	}

	return NFWebStatus::WEB_OK;
	*/
}
示例#30
0
void RosterItem::DrawItem(BView *owner, BRect frame, bool complete)
{
	// protection
	if (StalePointer()) {
		return;
	}

	// get online status
	UserID::online_status status = _userid->OnlineStatus();
	std::string exact_status = _userid->ExactOnlineStatus();

	// text characteristics
	owner->SetFont(be_plain_font);
	owner->SetFontSize(11);
	
				//owner->GetFont(&statusFont);
				//statusFont.SetFace(B_ITALIC_FACE);
				//owner->SetFont(&statusFont);

	// clear rectangle
	if (IsSelected())
	{
		// font color is based on online status
		if (status == UserID::ONLINE)
		{
			if (exact_status == "xa") 		 owner->SetHighColor(255, 220, 220, 255);
			else if (exact_status == "away") owner->SetHighColor(255, 230, 210, 255); 
			else if (exact_status == "dnd")  owner->SetHighColor(255, 192, 192, 255); 
			else 							 owner->SetHighColor(192, 255, 192, 255); 
		}
		else if (status == UserID::OFFLINE)
		{
			owner->SetHighColor(220, 220, 220, 255);
		}
		else
		{
			owner->SetHighColor(220, 246, 250, 255);
		}
	}
	else
	{
		owner->SetHighColor(owner->ViewColor());
	}

	owner->FillRect(frame);

	float height;

	// construct name
	std::string name = GetUserID()->FriendlyName();

	if (name.empty()) {
		name = GetUserID()->Handle();

		if (name.empty()) {
			name = "<anonymous>";
		}
	}

	BFont statusFont;
			
	// font color is based on online status
	if (status == UserID::ONLINE)
	{
		if (exact_status == "xa") 			owner->SetHighColor(139, 0, 0, 255);
		else if (exact_status == "away")	owner->SetHighColor(255, 140, 0, 255);
		else if (exact_status == "dnd")		owner->SetHighColor(255, 0, 0, 255);
		else								owner->SetHighColor(0, 100, 0, 255);
	}
	else if (status == UserID::OFFLINE)
	{
		owner->SetHighColor(90, 90, 90, 255); // gray
	}
	else
	{
		owner->SetHighColor(0, 0, 255, 255); // blue
	}

	// construct text positioning
	font_height fh;
	owner->GetFontHeight(&fh);

	height = fh.ascent + fh.descent;

	// draw name
	owner->DrawString(name.c_str(),
		BPoint(frame.left/* + 13*/, frame.bottom - ((frame.Height() - height) / 2) - fh.descent));

	// draw show
	if (!GetUserID()->MoreExactOnlineStatus().empty()) {
		owner->SetHighColor(90, 90, 90, 255);

		owner->DrawString(": ");
		owner->DrawString(GetUserID()->MoreExactOnlineStatus().c_str());
		owner->DrawString("");
	}

}