BOOL CWordFilter::InitWordFliter() { SGDP::ISDDBSession* pDBSession = gsapi::GetDBMgr()->GetPayDBSession(); if(NULL == pDBSession) { return FALSE; } SGDP::ISDDBRecordSet* pRes = NULL; UINT32 dwErrID = 0; string strErr; INT32 nRet = pDBSession->ExecuteSqlRs("select * from wordfilter;", &pRes, &dwErrID, &strErr); if(SDDB_HAS_RECORDSET != nRet) { SYS_CRITICAL(_SDT("[%s: %d]: has no data!"), MSG_MARK); return FALSE; } int nLen = 0; TWordFilterData stWordFilterData; //查询的表结果 while(pRes->GetRecord())// 当有行结果时 { stWordFilterData.Init(); nLen = pRes->GetFieldLengthByName("Words"); nLen = nLen >= MAX_WORD_FILTER ? MAX_WORD_FILTER - 1 : nLen; string strWords = pRes->GetFieldValueByName("Words"); string strTmp = SDStrlwr(strWords); _SDTStrncpy(stWordFilterData.m_szWordFilters, strTmp.c_str(), nLen); //_SDTStrncpy(stWordFilterData.m_szWordFilters, pRecordSet->GetFieldValueByName("Words"), nLen); string strkey = stWordFilterData.m_szWordFilters; if(m_mapWordFilterData.find(strkey) == m_mapWordFilterData.end()) { m_mapWordFilterData[strkey] = stWordFilterData; } } if(NULL != pRes) { pRes->Release(); pRes = NULL; } CWordFilterDataMapItr itr; for(itr = m_mapWordFilterData.begin(); itr != m_mapWordFilterData.end(); itr++) { KMP_GetNext(itr->second.m_szWordFilters, itr->second.m_kmpvalue); // 得到一个与内容有关的数值m_kmpvalue[i] } return TRUE; }
BOOL CGetPlayerDataCMD::GetHeroBase(SGDP::ISDDBConnection* poDBConn, UINT32 dwPlayerID, DT_PLAYER_NOPVP_DATA& stPlayerNoPvpData) { //CAutoCycle oAutoCycle(__FUNCTION__); CHAR szSQL[128] = {0}; sprintf(szSQL, "select * from player_heros where PlayerID='%u' and Coach != 2", dwPlayerID); ISDDBRecordSet* pRecordSet = NULL; string strError; INT32 nRet = poDBConn->ExecuteSqlRs(szSQL, &pRecordSet, 0, &strError ); UINT32 dwLen = 0; DT_HERO_DATA_LIST& stHeroData = stPlayerNoPvpData.stHeroData; if(SDDB_HAS_RECORDSET == nRet) { while(pRecordSet->GetRecord() && stHeroData.wHeroNum < MAX_HERO_NUM) { DT_HERO_BASE_DATA& stHeroBase = stHeroData.astHeroInfoLst[stHeroData.wHeroNum++].stHeroBaseData; stHeroBase.wKindID = SDAtou( pRecordSet->GetFieldValueByName("HeroID") ); stHeroBase.byPos = SDAtou( pRecordSet->GetFieldValueByName("Pos") ); stHeroBase.byCoach = SDAtou( pRecordSet->GetFieldValueByName("Coach") ); stHeroBase.wTalent = SDAtou( pRecordSet->GetFieldValueByName("Talent") ); stHeroBase.wLevel = SDAtou( pRecordSet->GetFieldValueByName("Level") ); stHeroBase.qwExperience = SDAtou64( pRecordSet->GetFieldValueByName("Exp") ); stHeroBase.byFormationIdx = SDAtou( pRecordSet->GetFieldValueByName("FormationIdx") ); stHeroBase.byRecuitedFlag = SDAtou( pRecordSet->GetFieldValueByName("RecuitedFlag") ); stHeroBase.byVisitNum = SDAtou( pRecordSet->GetFieldValueByName("VisitNum") ); stHeroBase.byLastUseDrugLevel = SDAtou( pRecordSet->GetFieldValueByName("LastUseDrugLevel") ); GetDateTime2Stamp(stHeroBase.qwLastUseDrugTime, "LastUseDrugTime"); stHeroBase.byUseExperienceDrugPerDay = SDAtou( pRecordSet->GetFieldValueByName("UseExpdrugPerDay") ); GetDateTime2Stamp(stHeroBase.qwLastUseExperienceDrugTime, "LastUseExpDrugTime"); GetEncodeDataFromDB3("BattleAttribute", stHeroBase.stBattleAttribute, dwPlayerID); GetEncodeDataFromDB3("HideBattleAttr", stHeroBase.stHideBattleAttr, dwPlayerID); GetEncodeDataFromDB3("UpdateAttrInfo", stHeroBase.stUpdateAttrInfo, dwPlayerID); stHeroBase.dwFlyExp = SDAtou(pRecordSet->GetFieldValueByName("FlyExp")); } } else { SYS_CRITICAL( _SDT("Player[%d] no hero data"), dwPlayerID); return FALSE; } if(NULL != pRecordSet) { pRecordSet->Release(); pRecordSet = NULL; } return TRUE; }
BOOL CSmsMgr::Init() { m_bStop = FALSE; CURL *curl = NULL; CURLcode code; code = curl_global_init(CURL_GLOBAL_DEFAULT); if (code != CURLE_OK) { SYS_CRITICAL( _SDT( "[%s: %d]:Failed to global init default [%d]!" ), MSG_MARK, code ); return FALSE; } return Start(); }
BOOL CDBMgr::Init() { SGDP::SDDBAccount account; if(!((CNSApplication*)SDGetApp())->GetNSConfig()->GetDBAccount(account)) { SYS_CRITICAL(_SDT("[%s: %d]:GetDBAccount failed"), MSG_MARK); return FALSE; } m_pDBModule = SGDP::SDDBGetModule(&(SGDP::SGDP_VERSION)); if(NULL == m_pDBModule) { SYS_CRITICAL(_SDT("[%s: %d]:SDDBGetModule failed"), MSG_MARK); return FALSE; } m_pDBSession = m_pDBModule->GetDBSession(&account, ((CNSApplication*)SDGetApp())->GetNSConfig()->GetPoolCoreSize(), ((CNSApplication*)SDGetApp())->GetNSConfig()->GetPoolMaxSize()); if(NULL == m_pDBSession) { SYS_CRITICAL(_SDT("[%s: %d]:GetDBSession failed"), MSG_MARK); return FALSE; } return TRUE; }
BOOL CJewelryPropMgr::LoadStrengAttrFromDB() { SGDP::ISDDBSession* pDBSession = gsapi::GetDBMgr()->GetCfgDBSession(); if(NULL == pDBSession) { return FALSE; } SGDP::ISDDBRecordSet* pRes = NULL; UINT32 dwErrID = 0; string strErr; INT32 nRet = pDBSession->ExecuteSqlRs(GetPropTableSelectSql("jewelrystrengprop", " order by JewelryLevel, ColorType").c_str(), &pRes, &dwErrID, &strErr); if(SDDB_HAS_RECORDSET != nRet) { SYS_CRITICAL(_SDT("[%s: %d]: has no data!"), MSG_MARK); return FALSE; } // 打印查询的表结果 while(pRes->GetRecord())// 当有行结果时 { SJewelryStrengProp stProp; stProp.wJewelryLevel = SDAtou(pRes->GetFieldValueByName("JewelryLevel")); stProp.wStrengLevel = SDAtou(pRes->GetFieldValueByName("StrengLevel")); stProp.byColorType = SDAtou(pRes->GetFieldValueByName("ColorType")); stProp.byExtAttrID = SDAtou(pRes->GetFieldValueByName("ExtAttrID")); stProp.dwExtValue = SDAtou(pRes->GetFieldValueByName("ExtValue")); UINT32 dwRandomKey = CLogicFunc::Get1616Key(stProp.wJewelryLevel, stProp.byColorType); if ( m_mapAttrRandom.find(dwRandomKey) == m_mapAttrRandom.end()) { C3232Map mapRandom; mapRandom[stProp.byExtAttrID] = m_mapExtIDRandom[stProp.byExtAttrID]; m_mapAttrRandom[dwRandomKey] = mapRandom; } else { m_mapAttrRandom[dwRandomKey].insert( make_pair(stProp.byExtAttrID, m_mapExtIDRandom[stProp.byExtAttrID]) ); } UINT32 dwSecondKey = CLogicFunc::Get1616Key(stProp.wStrengLevel, stProp.byExtAttrID); m_mapJewelryStrengProp[CLogicFunc::Get3232Key(dwRandomKey, dwSecondKey)] = stProp; } if(NULL != pRes) { pRes->Release(); pRes = NULL; } return TRUE; }
UINT32 CPlayer::GetHeroAttrValue( UINT32 dwPerCountAddValue, UINT16 wCount, UINT8 byAttr, CHero *pHero ) { if( EAST_HP == byAttr ) { return static_cast<UINT32>(dwPerCountAddValue * wCount + pHero->GetDT_BATTLE_ATTRIBUTE().qwHP); } else if( EAST_ATTACK == byAttr ) { return dwPerCountAddValue * wCount + pHero->GetDT_BATTLE_ATTRIBUTE().dwAttack; } else { SYS_CRITICAL( _SDT("[%s: %d]unknow attr kind:%d"), MSG_MARK, byAttr ); return 0; } }
BOOL CJewelryPropMgr::LoadUpgradeFromDB() { SGDP::ISDDBSession* pDBSession = gsapi::GetDBMgr()->GetCfgDBSession(); if(NULL == pDBSession) { return FALSE; } SGDP::ISDDBRecordSet* pRes = NULL; UINT32 dwErrID = 0; string strErr; INT32 nRet = pDBSession->ExecuteSqlRs(GetPropTableSelectSql("jewelryupgradecost", " order by JewelryLevel, Strenglevel").c_str(), &pRes, &dwErrID, &strErr); if(SDDB_HAS_RECORDSET != nRet) { SYS_CRITICAL(_SDT("[%s: %d]: has no data!"), MSG_MARK); return FALSE; } // 打印查询的表结果 while(pRes->GetRecord())// 当有行结果时 { SJewelryUpgradeProp stProp; stProp.wJewelryLevel = SDAtou(pRes->GetFieldValueByName("JewelryLevel")); stProp.wStrengLevel = SDAtou(pRes->GetFieldValueByName("StrengLevel")); stProp.dwUpgradeItemID = SDAtou(pRes->GetFieldValueByName("UpgradeItemID")); stProp.wUpgradeNum = SDAtou(pRes->GetFieldValueByName("UpgradeNum")); m_mapJewelryUpgradeProp[CLogicFunc::Get1616Key(stProp.wJewelryLevel, stProp.wStrengLevel)] = stProp; if ( 1 != stProp.wStrengLevel ) { CMapUpgradeItemNum mapItemNum = m_mapLevelToItemProp[CLogicFunc::Get1616Key(stProp.wJewelryLevel, stProp.wStrengLevel - 1)]; mapItemNum[stProp.dwUpgradeItemID] += stProp.wUpgradeNum; m_mapLevelToItemProp[CLogicFunc::Get1616Key(stProp.wJewelryLevel, stProp.wStrengLevel)] = mapItemNum; } else { CMapUpgradeItemNum mapItemNum; mapItemNum[stProp.dwUpgradeItemID] = stProp.wUpgradeNum; m_mapLevelToItemProp[CLogicFunc::Get1616Key(stProp.wJewelryLevel, stProp.wStrengLevel)] = mapItemNum; } } if(NULL != pRes) { pRes->Release(); pRes = NULL; } return TRUE; }
VOID CSavePlayersPlunderDataCMD::OnExecuted() { if(!m_bSuccess) { SYS_CRITICAL(_SDT("[%s: %d]: save plays plunder data failed!"), MSG_MARK); m_poPlayersPlunderSaveInfo->m_wErrCode = FAIL; } else { m_poPlayersPlunderSaveInfo->m_wErrCode = SUCCESS; } gsapi::GetDBProcessor()->OnSavePlayersPlunderDataAck(m_poPlayersPlunderSaveInfo, m_dwTransID); }
//已战胜全部精英BOSS UINT16 CCollectGas::OpenGenGasTab(PKT_CLIGS_OPEN_GEN_GAS_TAB_ACK& stAck) { if(!m_poOwner->GetBuild(EBK_COLLECTGAS)) { return ERR_OPEN_GEN_GAS_TAB::ID_COLLECT_GAS_UNLOCK; } Recover(); GetDT_GEN_GAS_DATA_CLI(stAck.stGenGasInfo); DT_INSTANCE_ID &stDT_INSTANCE_ID = m_poOwner->GetInstance().GetMaxEliteInstanceID(); SGasNumProp * poGasNumProp = CCollectGasPropMgr::Instance()->GetNextGenGasNumProp((UINT8)m_poOwner->GetLevel(), m_poOwner->GetDT_PLAYER_BASE_DATA().byVipLevel, stDT_INSTANCE_ID.byTownIdx, stDT_INSTANCE_ID.byInstanceIdx); if (NULL == poGasNumProp) { SDStrcpy(stAck.aszTipsInfo, CMsgDefMgr::Instance()->GetErrMsg("HAVE_WIN_ALL_ELITE") .c_str()); return ERR_OPEN_GEN_GAS_TAB::ID_SUCCESS; } //获取副本信息 SInstanceProp *poInstanceProp = CInstancePropMgr::Instance()->GetInstanceProp(EIT_ELITE, poGasNumProp->byTownIdx, poGasNumProp->byInstanceIdx); if (NULL == poInstanceProp) { SDStrcpy(stAck.aszTipsInfo, CMsgDefMgr::Instance()->GetErrMsg("HAVE_WIN_ALL_ELITE") .c_str()); SYS_CRITICAL(_SDT("[%s: %d]: OpenGenGasTab configure failed!"), MSG_MARK); //配置出错,当前配置的副本在精武英雄副本中找不到 return ERR_OPEN_GEN_GAS_TAB::ID_SUCCESS; } //CHAR szNum[56] = {0}; //sprintf(szNum, "%u", poGasNumProp->byValue); //SDStrcat(stAck.aszTipsInfo, SDGBK2UTF8("战胜精英").c_str()); //SDStrcat(stAck.aszTipsInfo, poInstanceProp->strName.c_str()); //SDStrcat(stAck.aszTipsInfo, SDGBK2UTF8(",每天聚魂次数增至").c_str()); //SDStrcat(stAck.aszTipsInfo, SDGBK2UTF8(szNum).c_str()); //SDStrcat(stAck.aszTipsInfo, SDGBK2UTF8("次").c_str()); vector<string> vecFillMsg; CHAR szBuff[32] = {0}; sprintf(szBuff, "%s", poInstanceProp->strName.c_str()); vecFillMsg.push_back(szBuff); sprintf(szBuff, "%u", poGasNumProp->byValue); vecFillMsg.push_back(szBuff); SDStrncpy(stAck.aszTipsInfo, CMsgDefMgr::Instance()->GetErrMsg("OPEN_GEN_GAS_PROMPT", &vecFillMsg).c_str(), MAX_GEN_GAS_INFO_LEN - 1); return ERR_OPEN_GEN_GAS_TAB::ID_SUCCESS; }
BOOL CJewelryPropMgr::LoadBaseAttrFromDB() { SGDP::ISDDBSession* pDBSession = gsapi::GetDBMgr()->GetCfgDBSession(); if(NULL == pDBSession) { return FALSE; } SGDP::ISDDBRecordSet* pRes = NULL; UINT32 dwErrID = 0; string strErr; INT32 nRet = pDBSession->ExecuteSqlRs(GetPropTableSelectSql("jewelryprop", " order by KindID").c_str(), &pRes, &dwErrID, &strErr); if(SDDB_HAS_RECORDSET != nRet) { SYS_CRITICAL(_SDT("[%s: %d]: has no data!"), MSG_MARK); return FALSE; } // 打印查询的表结果 while(pRes->GetRecord())// 当有行结果时 { SJewelryProp stProp = {0}; stProp.wKindID = SDAtou(pRes->GetFieldValueByName("KindID")); stProp.wDressLevel = SDAtou(pRes->GetFieldValueByName("DressLevel")); stProp.byColorType = SDAtou(pRes->GetFieldValueByName("ColorType")); SDStrncpy(stProp.aszName, pRes->GetFieldValueByName("Name"), NORMAL_MSG_LEN - 1); stProp.dwHP = SDAtou(pRes->GetFieldValueByName("HP")); stProp.dwAttack = SDAtou(pRes->GetFieldValueByName("Attack")); stProp.dwDefend = SDAtou(pRes->GetFieldValueByName("Defend")); stProp.dwCriRate = SDAtou(pRes->GetFieldValueByName("CriRate")); stProp.dwDecRitRate = SDAtou(pRes->GetFieldValueByName("DecRitRate")); stProp.dwDodgeRate = SDAtou(pRes->GetFieldValueByName("DodgeRate")); stProp.dwHitRate = SDAtou(pRes->GetFieldValueByName("HitRate")); stProp.byPosKindID = SDAtou(pRes->GetFieldValueByName("PosKindID")); stProp.dwFirstBase = SDAtou(pRes->GetFieldValueByName("FirstBase")); stProp.dwSecondBase = SDAtou(pRes->GetFieldValueByName("SecondBase")); m_mapJewelryProp[stProp.wKindID] = stProp; m_mapJewelryPropByLevel[CLogicFunc::Get1616Key( stProp.wDressLevel, CLogicFunc::Get88Key( stProp.byColorType, stProp.byPosKindID))] = stProp; } if(NULL != pRes) { pRes->Release(); pRes = NULL; } return TRUE; }
void CPushPlayerInfoHttpCMD::EscapeFields() { CNGString strTemp; char *szEscape = NULL; m_strfields.append("playerid="); strTemp = m_stPlayerInfo.dwPlayerID; szEscape = curl_easy_escape(m_pEasyHandle, strTemp.c_str(), 0); m_strfields.append(szEscape); curl_free(szEscape); m_strfields.append("&level="); strTemp = m_stPlayerInfo.wLevel; szEscape = curl_easy_escape(m_pEasyHandle, strTemp.c_str(), 0); m_strfields.append(szEscape); curl_free(szEscape); m_strfields.append("&careerid="); strTemp = m_stPlayerInfo.wCoachHeroID; szEscape = curl_easy_escape(m_pEasyHandle, strTemp.c_str(), 0); m_strfields.append(szEscape); curl_free(szEscape); m_strfields.append("&viplevel="); strTemp = m_stPlayerInfo.byVipLv; szEscape = curl_easy_escape(m_pEasyHandle, strTemp.c_str(), 0); m_strfields.append(szEscape); curl_free(szEscape); m_strfields.append("&_ch="); strTemp = m_stPlayerInfo.byAuthType; szEscape = curl_easy_escape(m_pEasyHandle, strTemp.c_str(), 0); m_strfields.append(szEscape); curl_free(szEscape); m_strfields.append("&name="); szEscape = curl_easy_escape(m_pEasyHandle, m_stPlayerInfo.strNickName.c_str(), 0); if(NULL == szEscape) { SYS_CRITICAL( _SDT( "[%s: %d]: curl_easy_escape playerid[%u] nickname [%s] failed"), MSG_MARK, m_stPlayerInfo.dwPlayerID, m_stPlayerInfo.strNickName.c_str()); } m_strfields.append(szEscape); curl_free(szEscape); }
BOOL CGoods::Init(VOID* pData, CPlayer* poOwner) { if(NULL == poOwner) { return FALSE; } SGoodsProp* pstGoodsProp = CGoodsPropMgr::Instance()->GetPropByPrimaryKey(((DT_GOODS_DATA*)(pData))->wKindID); if(NULL == pstGoodsProp) { SYS_CRITICAL(_SDT("[%s: %d]: pstGoodsProp is NULL,KindID[%d]!"), MSG_MARK, ((DT_GOODS_DATA*)(pData))->wKindID); return FALSE; } memcpy(&m_stDT_GOODS_DATA, pData, sizeof(DT_GOODS_DATA)); m_poOwner = poOwner; return TRUE; }
void SessionMgr::save(Session* pSession) { if (NULL == pSession) { return; } unsigned __int64 sid = pSession->getSId(); if (0 == sid) { return; } SKeyInfo key; key.qKey = sid; unsigned int now = GetCurTime(); if (now >= pSession->getDestroyTime()) { m_db->Delete(m_writeOpt, key.nKey[1]); return; } string& str = pSession->getData(); if (str.empty()) { return; } static char szSaveBuff[1024 * 32]; SSessionTime* pTime = (SSessionTime*)szSaveBuff; pTime->uCreateTime = key.nKey[0]; pTime->uDestroyTime = pSession->getDestroyTime(); memcpy(szSaveBuff + sizeof(SSessionTime), str.c_str(), str.size()); string strData; strData.append(szSaveBuff, sizeof(SSessionTime) + str.size()); leveldb::Status ret = m_db->Put(m_writeOpt, key.nKey[1], strData); if (!ret.ok()) { SYS_CRITICAL("save session failed, sid = %llu", sid); } }
BOOL CDrugUpradePropMgr::LoadFromDB() { return TRUE; //已经废弃 UINT8 byTotal = 0; SGDP::ISDDBSession* pDBSession = gsapi::GetDBMgr()->GetCfgDBSession(); if(NULL == pDBSession) { return FALSE; } SGDP::ISDDBRecordSet* pRes = NULL; UINT32 dwErrID = 0; string strErr; INT32 nRet = pDBSession->ExecuteSqlRs(GetPropTableSelectSql("drugupgradeprop", " order by SrcLevel").c_str(), &pRes, &dwErrID, &strErr); if(SDDB_HAS_RECORDSET != nRet) { SYS_CRITICAL(_SDT("[%s: %d]: has no data!"), MSG_MARK); return FALSE; } // 查询的表结果 while(pRes->GetRecord() && byTotal < MAX_DRUG_LEVEL)// 当有行结果时 { SDrugUpradeProp stDrugUpradeProp; memset(&stDrugUpradeProp, 0x00, sizeof(SDrugUpradeProp)); stDrugUpradeProp.dwSrcLevel = SGDP::SDAtou(pRes->GetFieldValueByName("SrcLevel")); //丹药等级 stDrugUpradeProp.dwSrcNum = SGDP::SDAtou(pRes->GetFieldValueByName("SrcNum")); //合成丹药的个数 stDrugUpradeProp.dwLevel1Rate = SGDP::SDAtou(pRes->GetFieldValueByName("Level1Rate")); stDrugUpradeProp.dwLevel2Rate = SGDP::SDAtou(pRes->GetFieldValueByName("Level2Rate")); // stDrugUpradeProp.dwLevel3Rate = SGDP::SDAtou(pRes->GetFieldValueByName("Level3Rate")); // stDrugUpradeProp.dwLevel4Rate = SGDP::SDAtou(pRes->GetFieldValueByName("Level4Rate")); // stDrugUpradeProp.dwLevel5Rate = SGDP::SDAtou(pRes->GetFieldValueByName("Level5Rate")); // stDrugUpradeProp.dwLevel6Rate = SGDP::SDAtou(pRes->GetFieldValueByName("Level6Rate")); // m_mapUpradePropDrug[stDrugUpradeProp.dwSrcLevel] = stDrugUpradeProp; m_byDrugNum[byTotal] = static_cast<UINT8>(stDrugUpradeProp.dwSrcNum); } if(NULL != pRes) { pRes->Release(); pRes = NULL; } return TRUE; }
bool DBAsk::setSQL(const char* pDBName, const char* pSql) { if (NULL == pDBName || NULL == pSql) { return false; } SDBMysqlSN* pSN = ServerWork::Instance().getBaseMysqlSN(pDBName); if (NULL == pSN) {// 没有找到对应的数据库连接 SYS_CRITICAL("can not find dbname [%s]", pDBName); return false; } m_baseSN = *pSN; m_strSQL = pSql; return true; }
void ThemeWidget::themeActivated ( const QModelIndex &index) { QString codeName; ThemeDescriptor *descr = 0; SYS_DEBUG ("*** index at %d, %d", index.row(), index.column()); if (m_ThemeDialog) { SYS_DEBUG ("We already have a dialog, returning."); return; } codeName = m_Proxy->data(index, ThemeListModel::CodeNameRole).toString(); /* * If the user selects the current theme we don't do anything. */ if (codeName == m_ThemeBusinessLogic->currentThemeCodeName()) return; #if 0 /* * For debugging purposes it is possible to leave out the dialog and change * the theme here. */ m_ThemeBusinessLogic->changeTheme (codeName); return; #endif descr = m_ThemeBusinessLogic->themeByCodename (codeName); if (descr == 0) { SYS_CRITICAL("codename not found: %s", SYS_STR(codeName)); return; } m_ThemeDialog = new ThemeDialog (m_ThemeBusinessLogic, descr); connect (m_ThemeDialog, SIGNAL(themeChangeCancelled()), this, SLOT(selectCurrentTheme())); m_ThemeDialog->showDialog (); }
BOOL CPlayer::AddAttrUpdateCnt( CHero *pHero, UINT8 byAttrKind, UINT32 dwPerCountAddValue, UINT16 &wCntResult ) { if( EAST_HP == byAttrKind ) { wCntResult = pHero->GetDT_HERO_BASE_DATA().stUpdateAttrInfo.wAttrHP++; pHero->GetDT_HERO_BASE_DATA().stBattleAttribute.dwHP += dwPerCountAddValue; } else if( EAST_ATTACK == byAttrKind ) { wCntResult = pHero->GetDT_HERO_BASE_DATA().stUpdateAttrInfo.wAttrAttack++; pHero->GetDT_HERO_BASE_DATA().stBattleAttribute.dwAttack += dwPerCountAddValue; } else { SYS_CRITICAL( _SDT("[%s: %d]:unknow attr kind:%d"), MSG_MARK, byAttrKind ); return FALSE; } return TRUE; }
BOOL CBuildPropMgr::InitBuyEquipCliData() { UINT8 byEquipPos = 1; UINT8 byIdx = 0; for(CPos2EquipIDMapItr itr = m_mapPos2EquipID.begin(); ((itr != m_mapPos2EquipID.end()) && (byIdx < EQUIP_POS_NUM)); itr++) { DT_BUY_EQUIP_DATA& stByEquipInfo = m_astByEquipInfo[byIdx++]; UINT16 wEquipID = itr->second; stByEquipInfo.wEquipID = wEquipID; SEquipProp* pstProp = CEquipPropMgr::Instance()->GetProp(wEquipID); if(NULL == pstProp) { SYS_CRITICAL(_SDT("[%s: %d]: pstProp is NULL[EquipID=%d]!"), MSG_MARK, wEquipID); return FALSE; } stByEquipInfo.dwBuyCoin = pstProp->dwBuyCoin; } return TRUE; }
VOID CPKPktBuilder::SyncPlayer(UINT32 dwPKGroupID, CPlayer *poPlayer) { if(NULL == poPlayer) { return; } ZERO_PACKET(PKT_GSPK_RET_PLAYER_ACK); DT_SYNC_PLAYER &stSyncPlayer = pstAck->astPlayerList[0]; BOOL bSucc = CPKPktBuilder::Instance()->BuildRetPlayer(stSyncPlayer, poPlayer); if(FALSE == bSucc) { SYS_CRITICAL(_SDT("[%s: %d]: sync player[%u] failed, groupID = %u!"), MSG_MARK, poPlayer->GetID(), dwPKGroupID); return; } pstAck->dwPKGroupID = dwPKGroupID; pstAck->byRetCnt = 1; gsapi::SendMsg2PK((CHAR*)pstAck, GSPK_RET_PLAYER_ACK); }
BOOL CPlayUpgrateCMD::UpdateLevel(SGDP::ISDDBConnection* poDBConn, UINT32 dwPlayerID, UINT16 wPlayerLevel) { CHAR szSQL[1024] = {0}; //更新用户信息 sprintf(szSQL, "update userzone set PlayerLevel='%d' where PlayerID = '%d';", wPlayerLevel, dwPlayerID); UINT32 dwErr; string strError; INT32 nRet = poDBConn->ExecuteSql(szSQL, NULL, NULL, &dwErr, &strError); if(nRet < 0) { //异常 SYS_CRITICAL(_SDT("[%s: %d]: ExecuteSqlRs[%s] failed[%s]!"), MSG_MARK, szSQL, strError.c_str()); return FALSE; } return TRUE; }
BOOL CSpecialEffectPropMgr::LoadPropFromDB() { SGDP::ISDDBSession* pDBSession = gsapi::GetDBMgr()->GetCfgDBSession(); SGDP::ISDDBRecordSet* pRes = NULL; UINT32 dwErrID = 0; string strErr; INT32 nRet = pDBSession->ExecuteSqlRs("select * from specialeffectprop order by EffectID, EffectSmallType", &pRes, &dwErrID, &strErr); if(SDDB_HAS_RECORDSET != nRet) { SYS_CRITICAL(_SDT("[%s: %d]: specialeffectprop has no data!"), MSG_MARK); return FALSE; } while(pRes->GetRecord()) { SSpecialEffectProp stProp; stProp.wEffectID = SDAtou(pRes->GetFieldValueByName("EffectID")); stProp.strEffectName = pRes->GetFieldValueByName("EffectName"); stProp.byEffectBigType = SDAtou(pRes->GetFieldValueByName("EffectBigType")); stProp.byEffectSmallType = SDAtou(pRes->GetFieldValueByName("EffectSmallType")); stProp.byUnlockLevel = SDAtou(pRes->GetFieldValueByName("UnlockLevel")); stProp.wTriggerProb = SDAtou(pRes->GetFieldValueByName("TriggerProb")); stProp.wEffectPercent = SDAtou(pRes->GetFieldValueByName("EffectPercent")); stProp.wLimitNum = SDAtou(pRes->GetFieldValueByName("LimitNum")); m_mapSpecialEffect.insert(make_pair( stProp.wEffectID, stProp)); m_mapSpecialEffectByType[CLogicFunc::Get1616Key(stProp.wEffectID, stProp.byEffectSmallType)] = stProp; } if(pRes) { pRes->Release(); pRes = NULL; } return TRUE; }
BOOL CGetPlayerDataCMD::GetBag(SGDP::ISDDBConnection* poDBConn, UINT32 dwPlayerID, DT_PLAYER_NOPVP_DATA& stPlayerNoPvpData) { CHAR szSQL[128] = {0}; sprintf(szSQL, "select * from player_bags where PlayerID='%u'", dwPlayerID); ISDDBRecordSet* pRecordSet = NULL; string strError; INT32 nRet = poDBConn->ExecuteSqlRs(szSQL, &pRecordSet, 0, &strError ); if((SDDB_HAS_RECORDSET == nRet) && (pRecordSet->GetRecord())) { GetEncodeDataFromDB3("Equip", stPlayerNoPvpData.stBagEquipData, dwPlayerID ); GetEncodeDataFromDB3("Goods", stPlayerNoPvpData.stBagGoodsData, dwPlayerID ); GetEncodeDataFromDB3("Jewelry", stPlayerNoPvpData.stBagJewelryInfo, dwPlayerID ); } else { //不要提交 if ( SDDB_NO_RECORDSET != nRet) { if(NULL != pRecordSet) { pRecordSet->Release(); pRecordSet = NULL; } SYS_CRITICAL( _SDT("Player[%d] no bag data"), dwPlayerID); return FALSE; } } if(NULL != pRecordSet) { pRecordSet->Release(); pRecordSet = NULL; } return TRUE; }
// 从数据源获取数据 BOOL CCropSeedPropMgr::LoadFromDB() { SGDP::ISDDBSession* pDBSession = gsapi::GetDBMgr()->GetCfgDBSession(); if(NULL == pDBSession) { return FALSE; } SGDP::ISDDBRecordSet* pRes = NULL; UINT32 dwErrID = 0; string strErr; INT32 nRet = pDBSession->ExecuteSqlRs(GetPropTableSelectSql("cropprop").c_str(), &pRes, &dwErrID, &strErr); if(SDDB_HAS_RECORDSET != nRet) { SYS_CRITICAL(_SDT("[%s: %d]: has no data!"), MSG_MARK); return FALSE; } //查询的表结果 while(pRes->GetRecord())// 当有行结果时 { SCropProp stCropProp; memset(&stCropProp, 0, sizeof(stCropProp)); stCropProp.wCropKindID = SGDP::SDAtou(pRes->GetFieldValueByName("CropKindID")); _SDTStrncpy(stCropProp.szName, _SDTUTF82T(pRes->GetFieldValueByName("Name")), NAME_LEN_MAX); stCropProp.byType = SGDP::SDAtou(pRes->GetFieldValueByName("Type")); stCropProp.byLevel = SGDP::SDAtou(pRes->GetFieldValueByName("Level")); stCropProp.wObtainCD = SGDP::SDAtou(pRes->GetFieldValueByName("ObtainCD")); stCropProp.dwObtainValue = SGDP::SDAtou(pRes->GetFieldValueByName("ObtainValue")); stCropProp.wObtainKindID = SGDP::SDAtou(pRes->GetFieldValueByName("ObtainKindID")); m_mapCropProp[stCropProp.wCropKindID] = stCropProp; } if(NULL != pRes) { pRes->Release(); pRes = NULL; } return TRUE; }
BOOL CTaskPropMgr::Init() { //初始化字符串到枚举 InitStr2Enum(); // 读取配置文件 if(!ReadTaskFromXML()) { SYS_CRITICAL(_SDT("[%s: %d]: ReadMainTaskFromXML failed!"), MSG_MARK); return FALSE; } /* if(!ReadDailyTaskFromXML()) { SYS_CRITICAL(_SDT("[%s: %d]: ReadDailyTaskFromXML failed!"), MSG_MARK); return FALSE; } */ InitNextTaskIdx(); return TRUE; }
BOOL CSetAppPayProcessed::SetPayProcessed(SGDP::ISDDBConnection* poDBConn) { CAutoSqlBuf oAutoSqlBuf; CHAR* pszSql = oAutoSqlBuf.GetSqlBuf(); if((NULL == pszSql)) { SYS_CRITICAL(_SDT("[%s: %d]: GetSQLMemory is NULL"), MSG_MARK); return FALSE; } // sprintf( pszSql, "select * from %s where OrderID='%s'", m_stAppPayProcessed.strTableName.c_str(), m_stAppPayProcessed.strOrderID.c_str() ); // ISDDBRecordSet *pRecordSetSelect=NULL; // string strErrorSelect; // INT32 nRetSelect = poDBConn->ExecuteSqlRs(pszSql, &pRecordSetSelect, NULL, &strErrorSelect); // CDBLock lock( poDBConn, m_stAppPayProcessed.strTableName ); { CAutoSqlBuf oAutoSqlBufSelect; CHAR *pszSqlSelect = oAutoSqlBufSelect.GetSqlBuf(); if( !pszSqlSelect ) { SYS_CRITICAL(_SDT("[%s: %d]: GetSQLMemory is NULL"), MSG_MARK); return FALSE; } ISDDBRecordSet*pRecordSetSelect = NULL; sprintf( pszSqlSelect, "select * from %s where OrderID='%s'", m_stAppPayProcessed.strTableName.c_str(), m_stAppPayProcessed.strOrderID.c_str() ); string strErrorSelect; INT32 nRet = poDBConn->ExecuteSqlRs(pszSqlSelect, &pRecordSetSelect, NULL, &strErrorSelect ); if( SDDB_HAS_RECORDSET == nRet && pRecordSetSelect->GetRecord() ) { BOOL bProcessed = BOOL( SDAtou( pRecordSetSelect->GetFieldValueByName( "IsProcess" ) ) ); pRecordSetSelect->Release(); //如果已经处理过,则不重复处理 if( bProcessed ) { return FALSE; } } else { return FALSE; } } sprintf( pszSql, "update %s set DateProcess=now(), Amount='%u', RMB='%u', IsProcess=1, PayBuyEvn=%u where OrderID='%s' and IsProcess=0", m_stAppPayProcessed.strTableName.c_str(), m_stAppPayProcessed.dwGold, m_stAppPayProcessed.dwRMB, m_stAppPayProcessed.bBuyEnv, m_stAppPayProcessed.strOrderID.c_str() ); ISDDBRecordSet*pRecordSet = NULL; string strError; INT32 nRet = poDBConn->ExecuteSqlRs(pszSql, &pRecordSet, NULL, &strError); if(NULL != pRecordSet) { pRecordSet->Release(); pRecordSet = NULL; SYS_CRITICAL(_SDT("[%s: %d]: exec sql failed! player[%d], error:%s"), MSG_MARK, m_stAppPayProcessed.dwPlayerID, strError.c_str()); return FALSE; } if(nRet < 0) { SYS_CRITICAL(_SDT("[%s: %d]: exec sql failed! player[%d], error:%s"), MSG_MARK, m_stAppPayProcessed.dwPlayerID, strError.c_str()); return FALSE; } m_bSuccess = TRUE; return TRUE; }
VOID CLoginExHttpCMD::ProcessResult() { USR_INFO( _SDT( "ack:%s" ), SDUTF82Local(m_strResult.c_str()).c_str()); CC_LOOP_DO Json::Value root; Json::Reader reader; if( !reader.parse( m_strResult, root ) ) { break; } //检测数据个数,如果为零刚为出错,防止崩溃 if (!root.isObject()) { break; } //解析返回的状态码 if (!root["errcode"].isInt()) { break; } stAck.wErrCode = root["errcode"].asInt(); if (!root["datas"].isObject()) { break; } Json::Value datas = root["datas"]; UINT32 dwUserID = 0; if (!datas["userid"].isInt()) { break; } dwUserID = datas["userid"].asInt(); Json::Value jsVersionInfo; if (!datas["versioninfo"].isObject()) { break; } jsVersionInfo = datas["versioninfo"]; if (!jsVersionInfo["versionid"].isInt()) { break; } stAck.stVersionInfo.dwVersionID = jsVersionInfo["versionid"].asInt(); if (!jsVersionInfo["forceupdateflag"].isInt()) { break; } stAck.stVersionInfo.byForceUpdateFlag = jsVersionInfo["forceupdateflag"].asInt(); if (!jsVersionInfo["updatecontent"].isString()) { break; } SDStrncpy(stAck.stVersionInfo.aszUpdateContent, jsVersionInfo["updatecontent"].asCString(), MAX_CONTENT_SIZE); if (!jsVersionInfo["updateurl"].isString()) { break; } SDStrncpy(stAck.stVersionInfo.aszUpdateURL, jsVersionInfo["updateurl"].asCString(), MAX_CONTENT_SIZE); //通知 Json::Value jsNoticeInfo; if (!datas["noticeinfo"].isObject()) { break; } jsNoticeInfo = datas["noticeinfo"]; if (!jsNoticeInfo["noticeid"].isInt()) { break; } stAck.stNoticeInfo.dwNoticeID = jsVersionInfo["noticeid"].asInt(); if (!jsNoticeInfo["forcepopflag"].isInt()) { break; } stAck.stNoticeInfo.byForcePopFlag = jsVersionInfo["forcepopflag"].asInt(); if (!jsNoticeInfo["urlflag"].isInt()) { break; } stAck.stNoticeInfo.byUrlFlag = jsVersionInfo["urlflag"].asInt(); if (!jsNoticeInfo["noticecontent"].isString()) { break; } SDStrncpy(stAck.stNoticeInfo.aszNoticeContent, jsNoticeInfo["noticecontent"].asCString(), MAX_CONTENT_SIZE); //////////////////////////////////////////////////////////////////////// if (!datas["otherdeviceloginflag"].isInt()) { break; } stAck.byOtherDeviceLoginFlag = datas["otherdeviceloginflag"].asInt(); if (!datas["authtype"].isInt()) { break; } stAck.byAuthType = datas["authtype"].asInt(); if (!datas["deviceid"].isString()) { break; } SDStrncpy((char*)stAck.aszDeviceID, datas["deviceid"].asCString(), DEVICEID_LEN); if (!datas["notifyid"].isString()) { break; } SDStrncpy((char*)stAck.aszNotifyID, datas["notifyid"].asCString(), NOTIFYID_LEN); if (!datas["username"].isString()) { break; } SDStrncpy((char*)stAck.aszUserName, datas["username"].asCString(), USERNAME_LEN); if (!datas["zoneid"].isInt()) { break; } stAck.wZoneID = datas["zoneid"].asInt(); if (!datas["oldzoneid"].isInt()) { break; } m_wOriZoneID = datas["oldzoneid"].asInt(); if (!datas["zonename"].isString()) { break; } SDStrncpy(stAck.aszZoneName, datas["zonename"].asCString(), ZONENAME_LEN); if (!datas["playerid"].isInt()) { break; } stAck.dwPlayerID = datas["playerid"].asInt(); if (!datas["careerid"].isInt()) { break; } stAck.wCareerID = datas["careerid"].asInt(); if (datas["minresver"].isInt()) { stAck.stExtFuncParamLst.astExtFuncParaInfo[0].dwParam3 = datas["minresver"].asInt(); } stAck.stExtFuncParamLst.byFuncNum = 1; UINT8 byDaiChong = 0; if (datas["daichong"].isInt()) { byDaiChong = datas["daichong"].asInt(); } stAck.stExtFuncParamLst.byFuncNum = 1; OnLoginExAck_Success(dwUserID, byDaiChong); return; CC_LOOP_WHILE(0) SYS_CRITICAL( _SDT( "json parse error, result:%s" ), SDUTF82Local(m_strResult.c_str()).c_str() ); OnLoginExAck_Failed( ERR_LOGIN::ID_LS_SERVER_NOT_STARTUP); }
BOOL CGetPlayerDataCMD::GetPvp(SGDP::ISDDBConnection* poDBConn, UINT32 dwPlayerID, DT_PLAYER_PVP_DATA& stPlayerPvpData) { //CAutoCycle oAutoCycle(__FUNCTION__); CHAR szSQL[128] = {0}; sprintf(szSQL, "select * from player_pvp where PlayerID='%u'", dwPlayerID); ISDDBRecordSet* pRecordSet = NULL; string strError; INT32 nRet = poDBConn->ExecuteSqlRs(szSQL, &pRecordSet, 0, &strError ); if(SDDB_HAS_RECORDSET == nRet) { while(pRecordSet->GetRecord()) { UINT16 wKey = SDAtou( pRecordSet->GetFieldValueByName("KeyID") ); switch(wKey) { case EMDT_RaceData: { GetEncodeDataFromDB2( stPlayerPvpData.stRaceData.stRaceBaseData, dwPlayerID ); } break; case EMDT_RaceBattleLog: { GetEncodeDataFromDB2( stPlayerPvpData.stRaceData.stRaceBattleLog, dwPlayerID ); } break; case EMDT_PlunderBaseData: { GetEncodeDataFromDB2( stPlayerPvpData.stPlunderData.stPlunderBaseData, dwPlayerID ); } break; case EMDT_PlunderBattleLog: { GetEncodeDataFromDB2( stPlayerPvpData.stPlunderData.stPlunderBattleLog, dwPlayerID ); } break; case EMDT_CaptureData: { GetEncodeDataFromDB2( stPlayerPvpData.stPlunderData.stCaptureData, dwPlayerID ); } break; case EMDT_EnemyData: { GetEncodeDataFromDB2( stPlayerPvpData.stEnemyData, dwPlayerID ); } break; default: SYS_CRITICAL( _SDT("Get Player[%d] ext data, key[%d] invalid"), dwPlayerID, wKey ); break; } } } if(NULL != pRecordSet) { pRecordSet->Release(); pRecordSet = NULL; } return TRUE; }
BOOL CGetPlayerDataCMD::GetHeroExt(SGDP::ISDDBConnection* poDBConn, UINT32 dwPlayerID, DT_PLAYER_NOPVP_DATA& stPlayerNoPvpData) { //CAutoCycle oAutoCycle(__FUNCTION__); CHAR szSQL[128] = {0}; sprintf(szSQL, "select * from player_hero_ext where PlayerID='%u' order by HeroID;", dwPlayerID); ISDDBRecordSet* pRecordSet = NULL; string strError; INT32 nRet = poDBConn->ExecuteSqlRs(szSQL, &pRecordSet, 0, &strError ); DT_HERO_DATA_LIST& stHeroDataLst = stPlayerNoPvpData.stHeroData; map<UINT16, DT_HERO_DATA*> mapHero; map<UINT16, DT_JEWELRY_DATA_LST*> mapHeroJewelry; map<UINT16, DT_HERO_SOUL_DATA*> mapSoul; UINT16 wHeroNum = stHeroDataLst.wHeroNum; for(UINT8 byIdx = 0; byIdx < wHeroNum; byIdx++) { mapHero[stHeroDataLst.astHeroInfoLst[byIdx].stHeroBaseData.wKindID] = &(stHeroDataLst.astHeroInfoLst[byIdx]); mapHeroJewelry[stHeroDataLst.astHeroInfoLst[byIdx].stHeroBaseData.wKindID] = &(stHeroDataLst.astjewelryInfoLst[byIdx]); mapSoul[stHeroDataLst.astHeroInfoLst[byIdx].stHeroBaseData.wKindID] = &(stHeroDataLst.astSoulInfoLst[byIdx]); } if(SDDB_HAS_RECORDSET == nRet) { while(pRecordSet->GetRecord()) { UINT16 wHeroID = SDAtou( pRecordSet->GetFieldValueByName("HeroID") ); DT_HERO_DATA* pstDT_HERO_DATA = mapHero[wHeroID]; DT_JEWELRY_DATA_LST* pstJewelryDatalst = mapHeroJewelry[wHeroID]; DT_HERO_SOUL_DATA* pSoul = mapSoul[wHeroID]; if(NULL == pstDT_HERO_DATA || NULL == pSoul) { continue; } UINT16 wKey = SDAtou( pRecordSet->GetFieldValueByName("KeyID") ); switch(wKey) { case EHEDT_Equip: { GetEncodeDataFromDB2( pstDT_HERO_DATA->stEquipDataInfo, dwPlayerID ); } break; case EHEDT_Drug: { GetEncodeDataFromDB2( pstDT_HERO_DATA->stDrugDataInfo, dwPlayerID ); } break; case EHEDT_Godweapon: { GetEncodeDataFromDB2( pstDT_HERO_DATA->stGodweaponInfo, dwPlayerID ); } break; case EHEDT_Skill: { GetEncodeDataFromDB2( pstDT_HERO_DATA->stSkillInfo, dwPlayerID ); } break; case EHEDT_Study: { GetEncodeDataFromDB2( pstDT_HERO_DATA->stStudyInfo, dwPlayerID ); } break; case EHEDT_Absorb: { GetEncodeDataFromDB2( pstDT_HERO_DATA->stAbsorbInfo, dwPlayerID ); } break; case EHEDT_Jewelry: { GetEncodeDataFromDB2( (*pstJewelryDatalst), dwPlayerID); } break; case EHEDT_SOUL: { GetEncodeDataFromDB2((*pSoul), dwPlayerID); } break; default: SYS_CRITICAL( _SDT("Get Player[%d] hero ext data, key[%d] invalid"), dwPlayerID, wKey ); break; } } } else { SYS_CRITICAL( _SDT("Player[%d] no hero ext data"), dwPlayerID); return FALSE; } if(NULL != pRecordSet) { pRecordSet->Release(); pRecordSet = NULL; } return TRUE; }
BOOL CGetPlayerDataCMD::GetPlayerExt(SGDP::ISDDBConnection* poDBConn, UINT32 dwPlayerID, DT_PLAYER_NOPVP_DATA& stPlayerNoPvpData) { //CAutoCycle oAutoCycle(__FUNCTION__); CHAR szSQL[128] = {0}; sprintf(szSQL, "select * from player_ext where PlayerID='%u'", dwPlayerID); ISDDBRecordSet* pRecordSet = NULL; string strError; INT32 nRet = poDBConn->ExecuteSqlRs(szSQL, &pRecordSet, 0, &strError ); if(SDDB_HAS_RECORDSET == nRet) { while(pRecordSet->GetRecord()) { UINT16 wKey = SDAtou( pRecordSet->GetFieldValueByName("KeyID") ); switch(wKey) { case EMDT_LocaleData: { GetEncodeDataFromDB2( stPlayerNoPvpData.stLocaleData, dwPlayerID ); } break; case EMDT_CurState: { GetEncodeDataFromDB2( stPlayerNoPvpData.stCurState, dwPlayerID ); } break; case EMDT_OnlineEncRecdData: { GetEncodeDataFromDB2( stPlayerNoPvpData.stOnlineEncRecdData, dwPlayerID ); } break; case EMDT_LoginEncRecdData: { GetEncodeDataFromDB2( stPlayerNoPvpData.stLoginEncRecdData, dwPlayerID ); } break; case EMDT_MoneyTreeData: { GetEncodeDataFromDB2( stPlayerNoPvpData.stMoneyTreeData, dwPlayerID ); } break; case EMDT_CommonBattleRcd: { GetEncodeDataFromDB2( stPlayerNoPvpData.stInstanceData.stCommonBattleRcd, dwPlayerID ); } break; case EMDT_EliteBattleRcd: { GetEncodeDataFromDB2( stPlayerNoPvpData.stInstanceData.stEliteBattleRcd, dwPlayerID ); } break; case EMDT_JingJieData: { GetEncodeDataFromDB2( stPlayerNoPvpData.stJingJieData, dwPlayerID ); } break; case EMDT_PhystrengthData: { GetEncodeDataFromDB2( stPlayerNoPvpData.stPhystrengthData, dwPlayerID ); } break; case EMDT_FewParamData: { GetEncodeDataFromDB2( stPlayerNoPvpData.stFewParamData, dwPlayerID ); } break; case EMDT_CropData: { GetEncodeDataFromDB2( stPlayerNoPvpData.stCropData, dwPlayerID ); } break; case EMDT_ScienceTree: { GetEncodeDataFromDB2( stPlayerNoPvpData.stScienceTree, dwPlayerID ); } break; case EMDT_FormationInfo: { GetEncodeDataFromDB2( stPlayerNoPvpData.stFormationInfo, dwPlayerID ); } break; case EMDT_EatBreadInfo: { GetEncodeDataFromDB2( stPlayerNoPvpData.stEatBreadInfo, dwPlayerID ); } break; case EMDT_YabiaoInfo: { GetEncodeDataFromDB2( stPlayerNoPvpData.stYabiaoInfo.stYabiaoBaseInfo, dwPlayerID ); } break; case EMDT_ClimbTowerBattleRcd: { GetEncodeDataFromDB2( stPlayerNoPvpData.stInstanceData.stClimbTowerBattleRcd, dwPlayerID ); } break; case EMDT_YabiaoBattleLog: { GetEncodeDataFromDB2( stPlayerNoPvpData.stYabiaoInfo.stYabiaoBattleLog, dwPlayerID ); } break; case EMDT_ClimbTowerData: { GetEncodeDataFromDB2( stPlayerNoPvpData.stClimbTowerData, dwPlayerID ); } break; case EMDT_AwakenData: { GetEncodeDataFromDB2( stPlayerNoPvpData.stAwakenData, dwPlayerID ); } break; case EMDT_VipExtData: { GetEncodeDataFromDB2( stPlayerNoPvpData.stVipExtData, dwPlayerID ); } break; case EMDT_LuaActivityRecordData: { GetEncodeDataFromDB2( stPlayerNoPvpData.stLuaActivityRecordData, dwPlayerID ); } break; case EMDT_GasCollectData: { GetEncodeDataFromDB2( stPlayerNoPvpData.stGasCollectData, dwPlayerID ); } break; case EMDT_BossBattleData: { GetEncodeDataFromDB2( stPlayerNoPvpData.stBossBattlePlayerDataInfo.stBossBattleData, dwPlayerID ); } break; case EMDT_ACTIVITY_ENCOURAGE: { GetEncodeDataFromDB2( stPlayerNoPvpData.stActivityEncourageData, dwPlayerID ); } break; case EMDT_BossBBL: { GetEncodeDataFromDB2( stPlayerNoPvpData.stBossBattlePlayerDataInfo.stBossBBLData, dwPlayerID ); } break; case EMDT_RdChallengeData: { GetEncodeDataFromDB2( stPlayerNoPvpData.stRdChallengeData, dwPlayerID ); } break; case EMDT_WorshipData: { GetEncodeDataFromDB2( stPlayerNoPvpData.stWorshipData, dwPlayerID ); } break; case EMDT_ScoreData: { GetEncodeDataFromDB2( stPlayerNoPvpData.stScoreData, dwPlayerID ); } break; case EMDT_EquipComposeData: { GetEncodeDataFromDB2( stPlayerNoPvpData.stEquipComposeData, dwPlayerID ); } break; case EMDT_GatherScienceData: { GetEncodeDataFromDB2( stPlayerNoPvpData.stGatherScienceData, dwPlayerID ); } break; case EMDT_BegBlueData: { GetEncodeDataFromDB2(stPlayerNoPvpData.stBegBlueData, dwPlayerID); } break; case EMDT_FriendsBaseData: { GetEncodeDataFromDB2(stPlayerNoPvpData.stFriendsData.stFriendsBaseData, dwPlayerID); } break; case EMDT_Courage: { GetEncodeDataFromDB2(stPlayerNoPvpData.stCourageData, dwPlayerID); } break; case EMDT_PlayerFactionData: { GetEncodeDataFromDB2(stPlayerNoPvpData.stPlayerFactionData, dwPlayerID); } break; case EMDT_EquipMaster: { GetEncodeDataFromDB2(stPlayerNoPvpData.stEquipMasterData, dwPlayerID); } break; case EMDT_ExchangeResultLog: { GetEncodeDataFromDB2(stPlayerNoPvpData.stExchangeResultLog, dwPlayerID); } break; case EMDT_GVGData: { GetEncodeDataFromDB2(stPlayerNoPvpData.stGvGData, dwPlayerID); } break; case EMDT_SoulData: { GetEncodeDataFromDB2(stPlayerNoPvpData.stSoulData, dwPlayerID); } break; case EMDT_MedalData: { GetEncodeDataFromDB2(stPlayerNoPvpData.stMedalData, dwPlayerID); } break; case EMDT_PetData: { GetEncodeDataFromDB2(stPlayerNoPvpData.stPetData, dwPlayerID); } break; default: { SYS_CRITICAL( _SDT("Get Player[%d] ext data, key[%d] invalid"), dwPlayerID, wKey ); break; } } } } if(NULL != pRecordSet) { pRecordSet->Release(); pRecordSet = NULL; } return TRUE; }
INT32 CGetPlayerDataCMD::CheckAndProcessBackupSql( SGDP::ISDDBConnection *poDBConn, UINT32 dwPlayerID ) { //如果是在登录时获取,需要判断是否发生存储错误,如果发生存储错误,则需要再次保存数据,如果依然失败,则不允许登录,并返回错误 if( gsapi::GetDBMgr()->IsExistErrorInfo(ERROR_PLAYER, dwPlayerID )) { ISDDBRecordSet* pRecordSet = NULL; string strError; CHAR szSql[512] = {0}; UINT64 qwDBUpdateTime = 0; sprintf(szSql, "select UpdateTime from players where PlayerID='%u';", dwPlayerID); INT32 nRet = poDBConn->ExecuteSqlRs(szSql, &pRecordSet, 0, &strError ); if((SDDB_HAS_RECORDSET == nRet) && (pRecordSet->GetRecord())) { GetDateTime2Stamp(qwDBUpdateTime, "UpdateTime"); } if(NULL != pRecordSet) { pRecordSet->Release(); pRecordSet = NULL; } if(nRet < 0) { SYS_CRITICAL(_SDT("[%s: %d]: exec sql failed! player[%d], error:%s"), MSG_MARK, dwPlayerID, strError.c_str()); return REFUSE_LOGIN; } //若文件保存的时间比DB的更加新,则执行文件sql if(gsapi::GetDBMgr()->GetErrorFileUpdateTime(ERROR_PLAYER, dwPlayerID) > qwDBUpdateTime) { BOOL m_bError = FALSE; vector<string> vecStrList = gsapi::GetDBMgr()->GetSqlList(ERROR_PLAYER, dwPlayerID ); poDBConn->BeginTransaction(); for( INT32 nIndex = 0; nIndex < INT32(vecStrList.size()); ++nIndex ) { string strError; UINT64 qwInsertId = 0; UINT32 dwErr = 0; INT32 nRet = poDBConn->ExecuteSql(vecStrList[nIndex].c_str(), &qwInsertId, NULL, &dwErr, &strError ); if(nRet < 0) { SYS_CRITICAL(_SDT("[%s: %d]: exec sql failed! player[%d], error:%s"), MSG_MARK, dwPlayerID, strError.c_str()); m_bError = TRUE; break; } } if( m_bError ) { poDBConn->RollbackTransaction(); //m_pstGetPlayerData->stGetPlayerDataAck.wErrCode=REFUSE_LOGIN; return REFUSE_LOGIN; } poDBConn->CommitTransaction(); } //删除失败,下次保存时再删除 if( !gsapi::GetDBMgr()->DeleteErrorInfo(ERROR_PLAYER, dwPlayerID ) ) { //删除文件失败 SYS_CRITICAL(_SDT("[%s: %d]: DeleteErrorInfo failed, PlayerID[%d]!"), MSG_MARK, dwPlayerID); } } return SUCCESS; }