int _IsParentVersionExist(const TCHAR cszParentPath[]) { int nResult = false; int nRetCode = false; tstring strPakFileName; ASSERT(cszParentPath); ASSERT(cszParentPath[0]); strPakFileName = tstring(cszParentPath) + _T("pak\\Data_1.pak"); nRetCode = _taccess(strPakFileName.c_str(), 0); KG_PROCESS_ERROR(nRetCode == 0); nResult = true; Exit0: return nResult; }
void KDlgNPCBindInfo::OnBnClickedButtonClear() { KG_PROCESS_ERROR(m_pScene); for (int i = 0; i < 6; i++) { if (static_cast<CButton*>(GetDlgItem(IDC_RADIO_LEFTHAND + i))->GetCheck() == BST_CHECKED) { m_BindInfo.strNames[i + 1] = ""; UpdateData(FALSE); m_pScene->UnBind(i + 1); break; } } Exit0: return; }
BOOL KLogClient::LogPlayerLeaveTeam(KPlayer* pPlayer) { BOOL bResult = false; BOOL bRetCode = false; assert(pPlayer); bRetCode = LogPlayerAction( PLAYER_ACTION_LEAVE_TEAM, 100, "LEAVE_TEAM", pPlayer->m_szAccount, pPlayer->m_szName, 0, NULL ); KG_PROCESS_ERROR(bRetCode); bResult = true; Exit0: return bResult; }
int KTestCommon::RestoreRegData() { int nResult = false; int nRetCode = false; HKEY hKey = NULL; //打开注册表键 nRetCode = ::RegOpenKeyEx(REG_ROOT_KEY, REG_SUB_KEY, 0, KEY_SET_VALUE, &hKey); KG_PROCESS_ERROR(nRetCode == ERROR_SUCCESS); //恢复安装目录注册表数据 nRetCode = ::RegSetValueEx( hKey, REG_INSTALL_PATH_NAME, 0, REG_SZ, (LPBYTE)g_szRegInstallPath, MAX_PATH ); if(nRetCode != ERROR_SUCCESS) { KGLogPrintf(KGLOG_ERR, "Restore Reg Install Path Failed"); } //恢复版本信息注册表数据 nRetCode = ::RegSetValueEx( hKey, REG_CURRENT_VERSION_NAME, 0, REG_SZ, (LPBYTE)g_szRegVersion, MAX_VERSION_LENGTH ); if(nRetCode != ERROR_SUCCESS) { KGLogPrintf(KGLOG_ERR, "Restore Reg Version Failed"); } nResult = true; Exit0: if (hKey) { ::RegCloseKey(hKey); hKey = NULL; } return nResult; }
int KSystemScriptTable::LuaSwapMouseButton(Lua_State* L) { ASSERT(L); int nSwap = FALSE; KG_PROCESS_ERROR(lua_gettop(L) == 1); if (lua_isboolean(L, 1)) nSwap = (int)Lua_ValueToBoolean(L, 1); else nSwap = (int)Lua_ValueToNumber(L, 1); ::SwapMouseButton(nSwap); Exit0: return 0; }
BOOL KApexProxy::Send(IKG_Buffer* piBuffer) { BOOL bResult = false; int nRetCode = 0; KG_PROCESS_ERROR(m_piSocketStream); nRetCode = m_piSocketStream->Send(piBuffer); KGLOG_PROCESS_ERROR(nRetCode == 1); bResult = true; Exit0: if (!bResult) m_bSendErrorFlag = true; return bResult; }
HTREEITEM KGTreeCtrl::GetLastSibingItem(HTREEITEM hTreeItem) { HTREEITEM hResultItem = NULL; HTREEITEM hNextItem = NULL; KG_PROCESS_ERROR(hTreeItem); hNextItem = hTreeItem; while (hNextItem) { hResultItem = hNextItem; hNextItem = GetNextSiblingItem(hNextItem); } Exit0: return hResultItem; }
HTREEITEM KGTreeCtrl::GetFirstSibingItem(HTREEITEM hTreeItem) { HTREEITEM hResultItem = NULL; HTREEITEM hPrevItem = NULL; KG_PROCESS_ERROR(hTreeItem); hPrevItem = hTreeItem; while (hPrevItem) { hResultItem = hPrevItem; hPrevItem = GetPrevSiblingItem(hPrevItem); } Exit0: return hResultItem; }
int InitProtocolStruct(KG_AGENT_PROTOCOL *AgentProtocol) { int nResult = false; KG_PROCESS_ERROR(AgentProtocol); AgentProtocol->pszCommand = NULL; AgentProtocol->nProtocolType = KG_AGENT_PROTOCOL_TYPE_INVALID; AgentProtocol->nSequenceID = KG_AGENT_SEQUENCE_ID_INVALID; AgentProtocol->nResult = 0; AgentProtocol->pszContext = NULL; AgentProtocol->CommandParameterMap.clear(); nResult = true; Exit0: return nResult; }
int KGSFXModelViewPage::FillComb() { int nResult = false; TCHAR szFilePath[MAX_PATH]; TCHAR szFullPath[MAX_PATH]; TCHAR* pExt = NULL; CFileFind fileFind; g_GetFullPath(szFullPath, m_strSelPath.GetBuffer()); pExt = strrchr(szFullPath, '\\'); KG_PROCESS_ERROR(pExt); *pExt = '\0'; m_comb.ResetContent(); sprintf(szFilePath, "%s%s", szFullPath, TEXT("\\*.*")); BOOL bWorking = fileFind.FindFile(szFilePath); while (bWorking) { bWorking = fileFind.FindNextFile(); if (fileFind.IsDots()) continue; CString strPath = fileFind.GetFilePath(); CString strName = fileFind.GetFileName(); if (fileFind.IsDirectory()) continue; TCHAR szName[MAX_PATH]; strncpy(szName, strName.GetBuffer(), sizeof(szName)); TCHAR* pszExt = strrchr(szName, '.'); if (!pszExt) continue; if (!stricmp(pszExt, TEXT(".ani"))) m_comb.AddString(szName); else continue; } m_comb.AddString(TEXT("浏览......")); fileFind.Close(); nResult = true; Exit0: return nResult; }
HRESULT KG3DMesh::RefreshOption(unsigned uOption) { HRESULT hrResult = E_FAIL; HRESULT hrRetCode = E_FAIL; KG_PROCESS_SUCCESS(m_eDynamicLoadState == STATE_VIDEOMEM); KG_PROCESS_SUCCESS(uOption == m_uOption); //在加载为立即加载的时候 if ((uOption & MLO_MULTI) == 0) { switch (m_eDynamicLoadState) { //什么都还没有做 case STATE_NONE: hrRetCode = LoadFromFile(m_scName.c_str(), 0, uOption); KGLOG_COM_PROCESS_ERROR(hrRetCode); break; case STATE_LOADFAILED: KG_PROCESS_ERROR(false); break; //正在动态加载 case STATE_MULTITHREAD_PREPEAR: { while (m_eDynamicLoadState == STATE_MULTITHREAD_PREPEAR) { Sleep(1); // wait hrRetCode = CheckLoadingState(); //KGLOG_COM_PROCESS_ERROR(hrRetCode); } KGLOG_PROCESS_ERROR(m_eDynamicLoadState == STATE_VIDEOMEM); goto Exit1; break; } default: assert(0); } } m_uOption = uOption; Exit1: hrResult = S_OK; Exit0: return hrResult; }
void KStatDataManager::UpdateMoneyStat(KRole* pRole, int nMoney, const char cszMethod[]) { const char* pszGain = (nMoney >= 0 ? "GAIN" : "COST"); char szVarName[STAT_DATA_NAME_LEN]; KG_PROCESS_ERROR(nMoney != 0); snprintf(szVarName, sizeof(szVarName), "MONEY|%s|%lu|%d|%s", pszGain, pRole->m_dwMapID, pRole->m_byLevel, cszMethod); szVarName[sizeof(szVarName) - 1] = '\0'; if (nMoney < 0) nMoney = -nMoney; Update(szVarName, nMoney); Exit0: return; }
int KDumpFile::InitMiniDumpType() { int nResult = FALSE; int nValue = 0; nValue = (int)GetPrivateProfileInt( _T("MiniDumpType"), _T("EnableFullMemory"), 0, MINIDUMP_CONFIG ); KG_PROCESS_ERROR(nValue == 0 || nValue == 1); m_nFullMemoryFlag = nValue; nResult = TRUE; Exit0: return nResult; }
BOOL KGFellowshipMgr::RefreshDailyCount(DWORD dwPlayerID) { BOOL bResult = false; BOOL bRetCode = false; _RefreshDailyCountFunc RefreshDailyCountFunc; KGLOG_PROCESS_ERROR(dwPlayerID != ERROR_ID); RefreshDailyCountFunc.m_pConstList = &(g_pSO3World->m_Settings.m_ConstList); RefreshDailyCountFunc.m_pFellowshipMgr = this; bRetCode = TraverseFellowshipID(dwPlayerID, RefreshDailyCountFunc); KG_PROCESS_ERROR(bRetCode); bResult = true; Exit0: return bResult; }
int KUiShowWndTree::Expand(HWND hTree, KSHOWWNDNODE *pNode) { int nResult = false; KSHOWWNDNODE *pParent = NULL; KG_PROCESS_ERROR(pNode); TreeView_Expand(hTree, pNode->hItem, TVM_EXPAND); pParent = pNode->pParentNode; while (pParent) { TreeView_Expand(hTree, pParent->hItem, TVM_EXPAND); pParent = pParent->pParentNode; } nResult = true; Exit0: return nResult; }
int IsBipFileExist(const char cszBipName[]) { int nResult = false; int nRetCode = false; ASSERT(cszBipName); nRetCode = g_IsFileExist(cszBipName); KG_PROCESS_ERROR(nRetCode); nResult = true; Exit0: if (!nResult) { KGLogPrintf(KGLOG_INFO, "can't find bip file!! \"%s\"", cszBipName); } return nResult; }
BOOL KLogClient::LogTrainvalueChange(int nAddValue, const char* pszAccount, const char* pszRoleName) { BOOL bResult = false; int nRetCode = 0; char szAddValue[10]; KG_PROCESS_ERROR(nAddValue != 0); nRetCode = snprintf(szAddValue, sizeof(szAddValue), "%d", nAddValue); KGLOG_PROCESS_ERROR(nRetCode >= 0 && nRetCode < (int)sizeof(szAddValue)); bResult = LogPlayerAction( PLAYER_ACTION_TRAINVALUE_CHANGE, 50, szAddValue, pszAccount, pszRoleName, 0, NULL ); Exit0: return bResult; }
int KHero::LuaLoseStamina(Lua_State* L) { BOOL bResult = false; int nTopIndex = 0; int nLoseStamina = 0; nTopIndex = Lua_GetTopIndex(L); KG_PROCESS_ERROR(nTopIndex == 1); nLoseStamina = (int)Lua_ValueToNumber(L, 1); LoseStamina(nLoseStamina); bResult = true; Exit0: Lua_PushNumber(L, bResult); return 1; }
int KCoolDownList::GetCoolDownValue(DWORD dwCoolDownID) { int nResult = 0; KCOOL_DOWN_MAP::iterator it; KG_PROCESS_ERROR(dwCoolDownID != 0); it = m_CoolDownTable.find(dwCoolDownID); if (it == m_CoolDownTable.end()) { KGLogPrintf(KGLOG_DEBUG, "GetCoolDownValue %u Faild!", dwCoolDownID); goto Exit0; } nResult = it->second.nDuration; Exit0: return nResult; }
BOOL KScriptManager::Call(const char* pszScriptName, const char* pszFuncName, int nResults) { BOOL bResult = false; BOOL bRetCode = false; DWORD dwScriptID = 0; assert(pszScriptName); assert(nResults >= 0); dwScriptID = g_FileNameHash(pszScriptName); bRetCode = Call(dwScriptID, pszFuncName, nResults); KG_PROCESS_ERROR(bRetCode); bResult = true; Exit0: return bResult; }
void KCollisionMgr::OnHeroCollisionBananaPeel(KSceneObject* pSource, KSceneObject* pDest) { BOOL bRetCode = false; KHero* pHero = NULL; KBananaPeel* pBananaPeel = NULL; assert(pSource->Is(sotHero)); pHero = (KHero*)pSource; assert(pDest->Is(sotBananaPeel)); pBananaPeel = (KBananaPeel*)pDest; bRetCode = pBananaPeel->CollidedByHero(pHero); KG_PROCESS_ERROR(bRetCode); Exit0: return; }
void KCollisionMgr::OnBallCollisionCandyBag(KSceneObject* pSource, KSceneObject* pDest) { BOOL bRetCode = false; KBall* pBall = NULL; KCandyBag* pCandyBag = NULL; assert(pSource->Is(sotBall)); pBall = (KBall*)(pSource); assert(pDest->Is(sotCandyBag)); pCandyBag = (KCandyBag*)(pDest); bRetCode = pCandyBag->CollidedByBall(pBall); KG_PROCESS_ERROR(bRetCode); Exit0: return; }
HRESULT KG3DMesh::_LoadBSPFileFromMemory(IKG_Buffer *piBSPFile) { HRESULT hrResult = E_FAIL; HRESULT hrRetCode = E_FAIL; DWORD dwBSPVertexCount = 0; DWORD dwBSPFaceCount = 0; DWORD dwMeshVerticesCount = 0; DWORD dwMeshFacesCount = 0; LPD3DXMESH piMesh = m_ppMeshes[SMBT_NORMAL]; KG3DBsp *pBSP = NULL; ASSERT(piBSPFile); KGLOG_PROCESS_ERROR(piMesh); dwMeshFacesCount = piMesh->GetNumFaces(); dwMeshVerticesCount = piMesh->GetNumVertices(); pBSP = new KG3DBsp; KGLOG_PROCESS_ERROR(pBSP); hrRetCode = pBSP->LoadFromMemory(piBSPFile); KGLOG_COM_PROCESS_ERROR(hrRetCode); hrRetCode = pBSP->GetMeshInfo(&dwBSPVertexCount, &dwBSPFaceCount); KGLOG_COM_PROCESS_ERROR(hrRetCode); if ((dwBSPVertexCount != dwMeshVerticesCount) || (dwBSPFaceCount != dwMeshFacesCount)) { KGLogPrintf(KGLOG_ERR, "%s, BSP unmatch Mesh :(", m_scName.c_str()); KG_PROCESS_ERROR(FALSE); } ASSERT(!m_lpBsp); m_lpBsp = pBSP; pBSP = NULL; hrResult = S_OK; Exit0: KG_DELETE(pBSP); if(FAILED(hrResult)) { KGLogPrintf(KGLOG_ERR, "%s BSP加载失败", m_scName.c_str()); } return hrResult; }
HRESULT KSceneSettingPageRegionSplit::ShowRegionMap(BOOL bShow) { IEKG3DRegionInfoManager* pRI = this->GetCurRIM(); KG_PROCESS_ERROR(pRI); { if (bShow) { BOOL bRet = FALSE; BOOL bExist = FALSE; INT nID = -1; HRESULT hr = pRI->GetRegionTexState(&bExist, &nID, NULL, 0); if (SUCCEEDED(hr) && bExist) { _KG3D_DEBUG_FAIL_REPORT(nID != -1); bRet = AddOutputTexWnd(nID); } else { DWORD dwTexID = 0; HRESULT hr = pRI->GenerateRegionTex(0, &dwTexID); if (SUCCEEDED(hr)) { bRet= AddOutputTexWnd(dwTexID); } } if (!bRet) { MessageBox("添加贴图输出失败"); } KSH::SynACButtonWithABool(m_ckShowRegionMap, TRUE, TRUE); m_bNeedShowRegionMap = TRUE; } else { this->RemoveOutputTexWnd(); KSH::SynACButtonWithABool(m_ckShowRegionMap, FALSE, FALSE); m_bNeedShowRegionMap = FALSE; } } return S_OK; Exit0: return E_FAIL; }
HRESULT KG3DMesh::Helper_LoadSocketFromBuffer(KG3DBufferReader *pBufferReader) { HRESULT hrResult = E_FAIL; int nRetCode = false; TCHAR *pszParentBone = NULL; ASSERT(pBufferReader); nRetCode = pBufferReader->Read(&m_dwNumSocket, sizeof(DWORD)); KGLOG_PROCESS_ERROR(nRetCode); m_pSockets = new Socket1[m_dwNumSocket]; KG_PROCESS_ERROR(m_pSockets); for (DWORD i = 0; i < m_dwNumSocket; i++) { ASSERT(sizeof(m_pSockets[i].strSocketName) >= sizeof(TCHAR) * MAX_BONE_NAME_LENGTH); nRetCode = pBufferReader->Read(m_pSockets[i].strSocketName, sizeof(TCHAR) * MAX_BONE_NAME_LENGTH); KGLOG_PROCESS_ERROR(nRetCode); m_pSockets[i].strSocketName[countof(m_pSockets[i].strSocketName) - 1] = '\0'; strlwr(m_pSockets[i].strSocketName); nRetCode = pBufferReader->ReferenceRead((void **)&pszParentBone, sizeof(TCHAR) * MAX_BONE_NAME_LENGTH); KGLOG_PROCESS_ERROR(nRetCode); nRetCode = pBufferReader->Read(&m_pSockets[i].matMatrixOffset, sizeof(D3DXMATRIX)); KGLOG_PROCESS_ERROR(nRetCode); int nParentIndex = FindBone(pszParentBone); KGLOG_PROCESS_ERROR((nParentIndex >= 0) && "can't find parent bone for socket"); m_pSockets[i].dwParentBoneIndex = nParentIndex; D3DXMatrixMultiply(&m_pSockets[i].matCurMatrix, &m_pSockets[i].matMatrixOffset, &m_pBoneInfo[nParentIndex].CurMatrix); } hrResult = S_OK; Exit0: if (FAILED(hrResult)) { KG_DELETE_ARRAY(m_pSockets); m_dwNumSocket = 0; } return hrResult; }
void KGSFXSuedeBindToolBar::OnBnClickedMDLPlay() { IEKG3DModel* pBindModel = NULL; IKG3DAnimationController *piAniController = NULL; UpdateData(); GET_SFX_EDITOR(); pScene->GetBindModel(&pBindModel); KG_PROCESS_ERROR(pBindModel); pBindModel->IEGetAnimationController(&piAniController); if (m_checkMDLPlay) piAniController->PauseAnimation(FALSE); else piAniController->PauseAnimation(TRUE); Exit0: return; }
BOOL KAwardMgr::CanAwardAll(KPlayer* pPlayer, DWORD dwAwardTableID) { BOOL bResult = false; BOOL bRetCode = false; KAwardTable* pAwardTable = NULL; KGLOG_PROCESS_ERROR(pPlayer); KGLOG_PROCESS_ERROR(dwAwardTableID); pAwardTable = GetAwardTable(dwAwardTableID); KGLOG_PROCESS_ERROR(pAwardTable); bRetCode = HasEnoughBagToAwardAll(pPlayer, dwAwardTableID); KG_PROCESS_ERROR(bRetCode); bResult = true; Exit0: return bResult; }
BOOL KCoolDownList::IsCoolDownNeedSave(DWORD dwCoolDownID) { BOOL bResult = false; BOOL bRetCode = false; KCOOL_DOWN_MAP::iterator it; it = m_CoolDownTable.find(dwCoolDownID); if (it == m_CoolDownTable.end()) { KGLogPrintf(KGLOG_DEBUG, "GetCoolDownValue %u Faild!", dwCoolDownID); goto Exit0; } KG_PROCESS_ERROR(it->second.bNeedSave); bResult = true; Exit0: return bResult; }
BOOL KMailBox::SendGlobalMail(KMail* pMail) { BOOL bResult = false; KMail* pNewMail = NULL; size_t uMailLen = 0; std::pair<KMailTable::iterator, bool> InsRet; assert(pMail); KG_PROCESS_ERROR(m_MailTable.size() < KMAILBOX_MAX_MAIL_COUNT); uMailLen = sizeof(KMail) + pMail->wTextLen; for (int i = 0; i < KMAIL_MAX_ITEM_COUNT; i++) { uMailLen += pMail->ItemDesc[i].byDataLen; } pNewMail = (KMail*)KMemory::Alloc(uMailLen); KGLOG_PROCESS_ERROR(pNewMail); memcpy(pNewMail, pMail, uMailLen); pNewMail->bRead = false; pNewMail->dwMailID = m_dwNextMailID++; InsRet = m_MailTable.insert(std::make_pair(pNewMail->dwMailID, pNewMail)); KGLOG_PROCESS_ERROR(InsRet.second); if (m_nBaseTime == 0) { m_nBaseTime = (pMail->nRecvTime / KMAIL_WITHDRAW_CYCLE + 1) * KMAIL_WITHDRAW_CYCLE; } m_bSaved = false; bResult = true; Exit0: if (!bResult) { KMEMORY_FREE(pNewMail); } return bResult; }
HRESULT KG3DMeshBone::GetSelBoneName(TCHAR szName[], INT nLen, DWORD *pdwType) { HRESULT hResult = E_FAIL; KG_PROCESS_ERROR(szName); if (m_nSelSubIndex != -1) { strncpy(szName, m_vecSubMeshInfo[m_nSelSubIndex].szBoneName, nLen); *pdwType = m_vecSubMeshInfo[m_nSelSubIndex].dwType; } else { strncpy(szName, TEXT(""), nLen); *pdwType = 1; } hResult = S_OK; Exit0: return hResult; }