int PartyMatchInfo(LPMSG_PARTYMATCHING_INFO_REQ lpMsg,PARTYMATCH_INFO* pBodyMsg,int& count,int& pages) { char szQuery[256]; long dwLen = 0; int TotalPages = 0; #ifdef ZTEAMDB sprintf(szQuery,"EXEC PartyMatching_GetList ?,%d,%d,'%s',%d,%d,%d", lpMsg->RequestPage,lpMsg->ReqType,lpMsg->szSearch, lpMsg->Level,lpMsg->Class,lpMsg->Gens); #else sprintf(szQuery,"EXEC WZ_PM_Listinfo ?,%d,%d,'%s',%d,%d,%d", lpMsg->RequestPage,lpMsg->ReqType,lpMsg->szSearch, lpMsg->Level,lpMsg->Class,lpMsg->Gens); #endif g_PartyMatchDB.BindParameterIntOutput(1,&TotalPages,&dwLen); if( !g_PartyMatchDB.Exec(szQuery) ) { g_PartyMatchDB.Clear(); return -1; } count = 0; int fResult; while( (fResult = g_PartyMatchDB.Fetch()) != SQL_NO_DATA && fResult != SQL_ERROR ) { pBodyMsg[count].btPartyCount = g_PartyMatchDB.GetInt("PartyCount"); pBodyMsg[count].LeaderLevel = g_PartyMatchDB.GetInt("LeaderLevel"); pBodyMsg[count].LeaderClass = g_PartyMatchDB.GetInt("LeaderClass"); pBodyMsg[count].LeaderChannel = g_PartyMatchDB.GetInt("LeaderChannel"); pBodyMsg[count].btClass = g_PartyMatchDB.GetInt("Class"); pBodyMsg[count].MinLevel = g_PartyMatchDB.GetInt("MinLevel"); pBodyMsg[count].MaxLevel = g_PartyMatchDB.GetInt("MaxLevel"); pBodyMsg[count].MoveReqId = g_PartyMatchDB.GetInt("MoveReqId"); pBodyMsg[count].Gens = g_PartyMatchDB.GetInt("Gens"); char szTmpPassword[8] = {0}; g_PartyMatchDB.GetStr("Password",szTmpPassword); pBodyMsg[count].btIsPassword = (strlen(szTmpPassword) > 1) ? TRUE : FALSE; g_PartyMatchDB.GetStr("PartyLeader",pBodyMsg[count].szLeader); g_PartyMatchDB.GetStr("Description",pBodyMsg[count].szDescription); count++; } while( g_PartyMatchDB.MoreResults() != SQL_NO_DATA ) { } pages = TotalPages; g_PartyMatchDB.Clear(); return 0; }
void ReqMarry(LPMSG_REQ_MARRYINFO lpMsg,int aIndex) { char szQuery[256]; char szName[MAX_IDSTRING+1] = {0}; char szTargetName[MAX_IDSTRING+1] = {0}; memcpy(szName,lpMsg->ReqName,MAX_IDSTRING); PMSG_ANS_MARRY pMsg; pMsg.h.c = 0xC1; pMsg.h.size = sizeof( pMsg ); pMsg.h.headcode = 0x66; pMsg.h.subcode = 0x02; pMsg.Result = FALSE; pMsg.ReqIndex = lpMsg->ReqIndex; memcpy(pMsg.ReqName,szName,MAX_IDSTRING); sprintf(szQuery,"SELECT * FROM wedding WHERE husband = '%s' OR wife = '%s'", szName,szName); if( g_MyEventDB.Exec(szQuery) == TRUE ) { if( g_MyEventDB.Fetch() != SQL_NO_DATA ) { pMsg.Result = 2; char szWife[11] = {0}; char szHusband[11] = {0}; g_MyEventDB.GetStr("husband",szHusband); g_MyEventDB.GetStr("wife",szWife); if( strcmp(szWife,szName) == NULL) { memcpy(pMsg.MarriedName,szHusband,MAX_IDSTRING); } else { memcpy(pMsg.MarriedName,szWife,MAX_IDSTRING); } } else { pMsg.Result = 1; } } g_MyEventDB.Clear(); DataSend(aIndex,(LPBYTE)&pMsg,sizeof( pMsg )); }
void Divorce(LPMSG_REQ_DIVORCE lpMsg,int aIndex) { char szQuery[256]; char szName[MAX_IDSTRING+1] = {0}; memcpy(szName,lpMsg->szName,MAX_IDSTRING); sprintf(szQuery,"SELECT * FROM wedding WHERE husband = '%s' OR wife = '%s'", szName,szName); PMSG_ANS_DIVORCE pMsg; pMsg.h.c = 0xC1; pMsg.h.size = sizeof(pMsg); pMsg.h.headcode = 0x66; pMsg.h.subcode = 0x04; pMsg.btResult = FALSE; if( g_MyEventDB.Exec(szQuery) == TRUE ) { if( g_MyEventDB.Fetch() == SQL_NO_DATA ) { pMsg.btResult =2; } else { g_MyEventDB.GetStr("wife",pMsg.Wife); g_MyEventDB.GetStr("husband",pMsg.Husband); g_MyEventDB.Clear(); sprintf(szQuery,"DELETE FROM wedding WHERE husband = '%s' OR wife = '%s'",szName,szName); if( g_MyEventDB.Exec(szQuery) == TRUE ) { pMsg.btResult = TRUE; } } } g_MyEventDB.Clear(); DataSend(aIndex,(LPBYTE)&pMsg,sizeof( pMsg )); }
void DGPartyMatchReqList(PARTYMATCH_GDREQ_REQUESTLIST* lpData, int aIndex) { const int MaxSize = sizeof(PARTYMATCH_DGANS_REQUESTLIST_COUNT) + sizeof(PARTYMATCH_DGANS_REQUESTLIST_INFO) * 80; BYTE Buffer[MaxSize + 1] = { 0 }; int Offset = sizeof(PARTYMATCH_DGANS_REQUESTLIST_COUNT); // ---- PARTYMATCH_DGANS_REQUESTLIST_COUNT* lpAnswerCount = (PARTYMATCH_DGANS_REQUESTLIST_COUNT*)Buffer; PARTYMATCH_DGANS_REQUESTLIST_INFO* lpAnswerInfo = (PARTYMATCH_DGANS_REQUESTLIST_INFO*)&Buffer[Offset]; // ---- lpAnswerCount->h.c = PMHC_WORD; lpAnswerCount->h.headcode = 0xEF; lpAnswerCount->h.subcode = 0x04; lpAnswerCount->h.sizeH = SET_NUMBERH(Offset); lpAnswerCount->h.sizeL = SET_NUMBERL(Offset); lpAnswerCount->UserIndex = lpData->UserIndex; // ---- char Query[256]; long Len = 0; // ---- sprintf(Query, "EXEC PartyMatching_GetRequestList '%s'", lpData->PartyLeader); // ---- if( !g_PartyMatchDB.Exec(Query) ) { g_PartyMatchDB.Clear(); DataSend(aIndex, (LPBYTE)lpAnswerCount, Offset); return; } // ---- int Result, Count = 0; // ---- while( (Result = g_PartyMatchDB.Fetch()) != SQL_NO_DATA && Result != SQL_ERROR ) { g_PartyMatchDB.GetStr("Name", lpAnswerInfo[Count].Character); lpAnswerInfo[Count].Class = g_PartyMatchDB.GetInt("SenderClass"); lpAnswerInfo[Count].Level = g_PartyMatchDB.GetInt("SenderLevel"); Offset += sizeof(PARTYMATCH_DGANS_REQUESTLIST_INFO); Count++; } // ---- while( g_PartyMatchDB.MoreResults() != SQL_NO_DATA ) { } // ---- g_PartyMatchDB.Clear(); // ---- lpAnswerCount->h.sizeH = SET_NUMBERH(Offset); lpAnswerCount->h.sizeL = SET_NUMBERL(Offset); lpAnswerCount->Count = Count; // ---- DataSend(aIndex, (LPBYTE)Buffer, Offset); }
//--------------------Database Operations---------------------- BOOL CArena::Load( void ) { CQuery* pQuery = new CQuery; if( pQuery->Connect( 3, "Character01", "", "" ) == FALSE ) { pQuery->DisConnect(); SAFE_DELETE( pQuery ); return FALSE; } if( pQuery->Exec( "SELECT * FROM dbo.ARENA" ) == FALSE ) { pQuery->DisConnect(); SAFE_DELETE( pQuery ); return FALSE; } while( pQuery->Fetch() ) { char szQryName[MAX_NAME] = { 0, }; ARENAPLAYER dbPlayer; u_long idPlayer = static_cast<u_long>( pQuery->GetInt64( "m_idPlayer" ) ); dbPlayer.nKill = static_cast<u_int>( pQuery->GetInt64( "m_nKill" ) ); dbPlayer.nDeath = static_cast<u_int>( pQuery->GetInt64( "m_nDeath" ) ); dbPlayer.nRow = static_cast<u_int>( pQuery->GetInt64( "m_nRow" ) ); dbPlayer.nJob = static_cast<u_int>( pQuery->GetInt64( "m_nJob" ) ); dbPlayer.nDeathMatchWin = static_cast<u_int>( pQuery->GetInt64( "m_nDeathMatchWin" ) ); dbPlayer.nDeathMatchLose = static_cast<u_int>( pQuery->GetInt64( "m_nDeathMatchLose" ) ); dbPlayer.nDuelWin = static_cast<u_int>( pQuery->GetInt64( "m_nDuelWin" ) ); dbPlayer.nDuelLose = static_cast<u_int>( pQuery->GetInt64( "m_nDuelLose" ) ); dbPlayer.n64ArenaPoint = pQuery->GetInt64( "m_nArenaPoint" ); pQuery->GetStr( "m_szName", szQryName ); dbPlayer.szName = CString( szQryName ); m_mArenaMap.insert( make_pair( idPlayer, dbPlayer ) ); } pQuery->DisConnect(); SAFE_DELETE( pQuery ); return TRUE; }
int PartyMatchWaitInfo(char* szName,int& ServerCode,char* szPartyLeader) { char szQuery[256]; #ifdef ZTEAMDB sprintf(szQuery,"EXEC PartyMatching_Waiting '%s'",szName); #else sprintf(szQuery,"EXEC WZ_PM_Waiting '%s'",szName); #endif if( !g_PartyMatchDB.Exec(szQuery) || g_PartyMatchDB.Fetch() == SQL_NO_DATA ) { g_PartyMatchDB.Clear(); return -1; } ServerCode = g_PartyMatchDB.GetInt("PartyChannel"); g_PartyMatchDB.GetStr("PartyLeader",szPartyLeader); g_PartyMatchDB.Clear(); return 0; }
int IsUser(char *szId, char *pass, char * JoominNumber, char & Block, int & DBNumber) { char szQuery[512]; sprintf(szQuery,"SELECT memb_guid, memb___id, sno__numb, bloc_code from MEMB_INFO WHERE memb___id='%s'", szId); if(g_JoinServerDB.Exec(szQuery) == FALSE) { g_Window.ServerLogAdd(ST_JOINSERVER,"error-L3 : ID:'%s' PASS:'******'",szId, pass); g_JoinServerDB.Clear(); return 2; } if(g_JoinServerDB.Fetch() == SQL_NO_DATA) { g_JoinServerDB.Clear(); if( g_JSInfo.bAutoreg == TRUE && strlen(szId) >= g_JSInfo.AutoRegMinLength && strlen(pass) >= g_JSInfo.AutoRegMinLength ) { if( g_JSInfo.bMD5 == TRUE ) { sprintf(szQuery,"INSERT INTO MEMB_INFO (memb___id,memb__pwd,bloc_code,ctl1_code) VALUES ('%s',dbo.fn_md5('%s','%s'),0,0)", szId,pass,szId); } else { sprintf(szQuery,"INSERT INTO MEMB_INFO (memb___id,memb__pwd,bloc_code,ctl1_code) VALUES ('%s','%s',0,0)", szId,pass); } if( g_JoinServerDB.Exec(szQuery) == FALSE ) { g_Window.ServerLogAdd(ST_JOINSERVER,"error-L3 : ID:'%s' PASS:'******'",szId, pass); g_JoinServerDB.Clear(); return 2; } g_JoinServerDB.Clear(); sprintf(szQuery,"SELECT memb_guid, memb___id, sno__numb, bloc_code from MEMB_INFO WHERE memb___id='%s'",szId); if(g_JoinServerDB.Exec(szQuery) == FALSE) { g_Window.ServerLogAdd(ST_JOINSERVER,"error-L3 : ID:'%s' PASS:'******'",szId, pass); g_JoinServerDB.Clear(); return 2; } if(g_JoinServerDB.Fetch() == SQL_NO_DATA) { g_JoinServerDB.Clear(); return 2; } } else { return 2; } } DBNumber = g_JoinServerDB.GetInt("memb_guid"); char szBlock[2]=""; g_JoinServerDB.GetStr("sno__numb", JoominNumber); g_JoinServerDB.GetStr("bloc_code", szBlock); Block = szBlock[0]; if(g_JSInfo.bMD5 == TRUE) { BYTE btPass[16]={0}; g_JoinServerDB.Clear(); sprintf(szQuery,"SELECT memb__pwd FROM MEMB_INFO WHERE memb___id = '%s'",szId); if(g_JoinServerDB.ReadBlob(szQuery,btPass) <= 0) { g_JoinServerDB.Clear(); return 0; } DWORD dwAccKey = MakeAccountKey(szId); MD5 pMD5Hash; if( pMD5Hash.MD5_CheckValue(pass, (char*)btPass, dwAccKey) == FALSE ) { g_JoinServerDB.Clear(); return 0; } } else { char szPass[MAX_IDSTRING+1] = {0}; g_JoinServerDB.Clear(); sprintf(szQuery,"SELECT memb__pwd FROM MEMB_INFO WHERE memb___id = '%s'",szId); if(g_JoinServerDB.Exec(szQuery) == FALSE || g_JoinServerDB.Fetch() == SQL_NO_DATA) { g_JoinServerDB.Clear(); return 0; } g_JoinServerDB.GetStr("memb__pwd",szPass); g_JoinServerDB.Clear(); if(strlen(szPass) < 1) { return 0; } if(strcmp(szPass,pass) != NULL) { return 0; } } g_JoinServerDB.Clear(); return TRUE; }