BOOL KSkillManager::LoadSkillBinaryData(KMAP_SKILL_DATA& allBinarySkillData) { BOOL bResult = false; BOOL bRetCode = false; IFile* piFile = NULL; BYTE* pBuffer = NULL; size_t uBufferSize = 0; uint64_t uSkillKey = 0; KSkillBinaryData* pBinaryData = NULL; KAnchor* pAnchor = NULL; KSkillSegmentInfo* pSegmentInfo = NULL; KSkillLogicInfo* pLogicData = NULL; unsigned int uEnd = 0; BYTE* pBufferEnd = NULL; piFile = g_OpenFile(SETTING_DIR"/SkillAction.skilllogic"); KGLOG_PROCESS_ERROR(piFile); pBuffer = (BYTE*)piFile->GetBuffer(); KGLOG_PROCESS_ERROR(pBuffer); uBufferSize = piFile->Size(); KGLOG_PROCESS_ERROR(uBufferSize); bRetCode = g_DoBufferSkip(pBuffer, uBufferSize, sizeof(KSkillLogicFileHeader)); KG_PROCESS_ERROR(bRetCode); while (uBufferSize) { bRetCode = g_ReadFromBufferTo(pBuffer, uBufferSize, uEnd); KGLOG_PROCESS_ERROR(bRetCode); pBufferEnd = pBuffer + uEnd; bRetCode = g_ReadFromBufferAs(pBuffer, uBufferSize, pLogicData); KGLOG_PROCESS_ERROR(bRetCode); uSkillKey = MAKE_INT64(pLogicData->skillID, pLogicData->skillStep); pBinaryData = &allBinarySkillData[uSkillKey]; pBinaryData->dwID = pLogicData->skillID; pBinaryData->dwStep = pLogicData->skillStep; pBinaryData->nTotalFrame = pLogicData->frameCount; bRetCode = LoadAnchors(pBuffer, uBufferSize, pBinaryData->Anchors); KGLOG_PROCESS_ERROR(bRetCode); bRetCode = LoadSegments(pBuffer, uBufferSize, pBinaryData->Segments); KGLOG_PROCESS_ERROR(bRetCode); KGLOG_PROCESS_ERROR(pBufferEnd == pBuffer); } bResult = true; Exit0: KG_COM_RELEASE(piFile); return bResult; }
KSkill* KSkillManager::GetSkill(DWORD dwSkillID, DWORD dwStepID/*=0U*/) { KSkill* pResult = NULL; KSkillTable::iterator it; uint64_t uKey = MAKE_INT64(dwSkillID, dwStepID); KG_PROCESS_ERROR(dwSkillID != ERROR_ID); it = m_SkillTable.find(uKey); KG_PROCESS_ERROR(it != m_SkillTable.end()); pResult = &(it->second); Exit0: return pResult; }
const KMapEntry* KEntryList::GetMapEntry(DWORD dwMapID, int nIndex) { KMapEntry* pResult = NULL; __int64 nKey = 0; KMAP_ENTRY_LIST::iterator it; nKey = MAKE_INT64(dwMapID, nIndex); it = m_EntryList.find(nKey); KGLOG_PROCESS_ERROR(it != m_EntryList.end()); pResult = &it->second; Exit0: return pResult; }
void KCollisionMgr::OnCollisionEnd(KSceneObject* pSource, KSceneObject* pDest) { BOOL bRetCode = false; int64_t llKey = 0; KMAP_TO_COLLISION_PROCESSOR::iterator it; KCollisionProcessor Func = NULL; llKey = MAKE_INT64(pSource->GetType(), pDest->GetType()); it = m_mapToCollisionProcessor.find(llKey); KG_PROCESS_SUCCESS(it == m_mapToCollisionProcessor.end()); Func = it->second.EndFun; KG_PROCESS_SUCCESS(Func == NULL); (this->*Func)(pSource, pDest); Exit1: Exit0: return; }
static void render(int type, SKMATRIX *mat, mapView_t *mapView, CSkPainter *pPainter, bool eqOnly, int x, int y, int spcx, int spcy) { if (x < 0) { x += 129600000; } else if (x >= 129600000) { x -= 129600000; } if (y < 0 || y > 64800000) { return; } radec_t rd[4]; if (mSet.contains(MAKE_INT64(x, y))) { // already rendered return; } QColor col = g_skSet.map.grid[type].color; QPen pen1 = QPen(col, 1); QPen pen3 = QPen(col, 3); rd[0].Ra = TORA(x); rd[0].Dec = TODEC(y); rd[1].Ra = TORA(x + spcx); rd[1].Dec = TODEC(y); rd[2].Ra = rd[1].Ra; rd[2].Dec = TODEC(y + spcy); rd[3].Ra = TORA(x); rd[3].Dec = rd[2].Dec; double dec = rd[0].Dec; double ra = rd[0].Ra; if (type == SMCT_ALT_AZM) { for (int i = 0; i < 4; i++) { rd[i].Dec -= cAstro.getInvAtmRef(rd[i].Dec); } } if (y + spcy > 64800000 && depth > 0) { return; } if (y + spcy < 00 && depth > 0) { return; } SKPOINT pt[4]; SKPOINT opt[4]; for (int i = 0; i < 4; i++) { trfRaDecToPointNoCorrect(&rd[i], &pt[i], mat); opt[i] = pt[i]; } if (!SKPLANECheckFrustumToPolygon(trfGetFrustum(), pt, 4)) { // out of screen return; } pPainter->setPen(pen1); ren++; if (!eqOnly && trfProjectLine(&pt[0], &pt[3])) { if ((y + spcy < 64800000 && y > 0) || (x == 0 || x == FROMRA(90) || x == FROMRA(180) || x == FROMRA(270))) { pPainter->setClipRect(clipSize, clipSize, scrWidth - clipSize * 2, scrHeight - clipSize * 2); pPainter->drawLine(pt[0].sx, pt[0].sy, pt[3].sx, pt[3].sy); pPainter->setClipping(false); int cx, cy; if (getClipPoint(cx, cy, pt[0].sx, pt[0].sy, pt[3].sx, pt[3].sy)) { QString text; if (g_skSet.map.showGridLabels && g_showLabels) { if (type == SMCT_RA_DEC) { text = getStrRA(ra, true); } else if (type == SMCT_ECL) { text = getStrDeg(ra, true); } else { double value = R360 - ra; rangeDbl(&value, R360); text = getStrDeg(value, true); } drawEdgeAlignTextY(pPainter, cx, cy, text); } } } } else { QPointF fpt[2]; if (eqOnly && y == 32400000 && trfProjectLine(&pt[0], &pt[3], fpt)) { QString text; if (g_skSet.map.showGridLabels && g_showLabels) { if (type == SMCT_RA_DEC) { text = getStrRA(ra, true); } else if (type == SMCT_ECL) { text = getStrDeg(ra, true); } else { double value = R360 - ra; rangeDbl(&value, R360); text = getStrDeg(value, true); } SKVECTOR v; double l = 10; QPointF fpt2[2]; trfProjectLine(&pt[0], &pt[1], fpt2); v.x = fpt2[0].x() - fpt2[1].x(); v.y = fpt2[0].y() - fpt2[1].y(); v.z = 0; SKVecNormalize(&v, &v); pPainter->setClipRect(clipSize, clipSize, scrWidth - clipSize * 2, scrHeight - clipSize * 2); pPainter->setPen(pen1); pPainter->drawLine(fpt[0].x(), fpt[0].y(), fpt[0].x() - v.y * l, fpt[0].y() + v.x * l); pPainter->drawLine(fpt[0].x(), fpt[0].y(), fpt[0].x() + v.y * l, fpt[0].y() - v.x * l); setSetFontColor(FONT_GRID, pPainter); pPainter->renderText(fpt[0].x(), fpt[0].y(), 10, text, RT_BOTTOM); pPainter->setClipping(false); } } } if ((eqOnly && y == 32400000) || !eqOnly) { int cx, cy; if (y == 32400000) { pPainter->setPen(pen3); } else { pPainter->setPen(pen1); } pPainter->setClipRect(clipSize, clipSize, scrWidth - clipSize * 2, scrHeight - clipSize * 2); if (drawInterpolatedLineRD(mat, 5, &rd[0], &rd[1], pPainter, cx, cy)) { pPainter->setClipping(false); if (g_skSet.map.showGridLabels && g_showLabels) { drawEdgeAlignTextX(pPainter, cx, cy, QString("%1").arg(getStrDeg(dec, true))); } } pPainter->setClipping(false); } mSet.insert(MAKE_INT64(x, y)); depth++; render(type, mat, mapView, pPainter, eqOnly, x - spcx, y, spcx, spcy); render(type, mat, mapView, pPainter, eqOnly, x + spcx, y, spcx, spcy); render(type, mat, mapView, pPainter, eqOnly, x, y + spcy, spcx, spcy); render(type, mat, mapView, pPainter, eqOnly, x, y - spcy, spcx, spcy); }
BOOL KSkillManager::LoadSkillTable() { BOOL bResult = false; BOOL bRetCode = false; DWORD dwSkillID = 0; DWORD dwStepID = 0; KSkill* pSkill = NULL; ITabFile* piTabFile = NULL; std::pair<KSkillTable::iterator, bool> InsRet; const int MAX_COLUMN_NAME_LEN = 64; char szMoveState[MAX_COLUMN_NAME_LEN] = ""; KAttribData AttributeData; KMAP_SKILL_DATA cSkillBinaryData; KMAP_SKILL_DATA::iterator it; char szValue[64]; char szScriptName[MAX_PATH]; bRetCode = LoadSkillBinaryData(cSkillBinaryData); KGLOG_PROCESS_ERROR(bRetCode); piTabFile = g_OpenTabFile(SETTING_DIR"/"SKILL_LIST_FILE_NAME); KGLOG_PROCESS_ERROR(piTabFile); for (int nRowIndex = 2; nRowIndex <= piTabFile->GetHeight(); nRowIndex++) { bRetCode = piTabFile->GetInteger(nRowIndex, "ID", 0, (int*)(&dwSkillID)); KGLOG_PROCESS_ERROR(bRetCode > 0); bRetCode = piTabFile->GetInteger(nRowIndex, "Step", 0, (int*)(&dwStepID)); KGLOG_PROCESS_ERROR(bRetCode); KGLOG_PROCESS_ERROR(dwStepID >= 0); InsRet = m_SkillTable.insert(std::make_pair(MAKE_INT64(dwSkillID, dwStepID), KSkill())); KGLOG_PROCESS_ERROR(InsRet.second); pSkill = &(InsRet.first->second); pSkill->m_dwID = dwSkillID; pSkill->m_dwStepID = dwStepID; bRetCode = piTabFile->GetInteger(nRowIndex, "NirvanaSkill", 0, &pSkill->m_bNirvanaSkill); KGLOG_PROCESS_ERROR(bRetCode); bRetCode = piTabFile->GetString(nRowIndex, "BelongToSlot", "", szValue, sizeof(szValue)); KGLOG_PROCESS_ERROR(bRetCode); bRetCode = g_ParseMutiInteger(szValue, ";", pSkill->m_vecBelongToSlots); KGLOG_PROCESS_ERROR(bRetCode); bRetCode = piTabFile->GetInteger(nRowIndex, "SrcBuffID", 0, (int*)(&pSkill->m_dwSrcBuffID)); KGLOG_PROCESS_ERROR(bRetCode); bRetCode = piTabFile->GetInteger(nRowIndex, "DestBuffID", 0, (int*)(&pSkill->m_dwDestBuffID)); KGLOG_PROCESS_ERROR(bRetCode); bRetCode = piTabFile->GetInteger(nRowIndex, "AimType", 0, (int*)(&pSkill->m_dwAimType)); KGLOG_PROCESS_ERROR(bRetCode); for (int i = 1; i <= 8; i++) { bRetCode = LoadAttribute(piTabFile, nRowIndex, "SrcAttribute", i, &AttributeData); KGLOG_PROCESS_ERROR(bRetCode); if (AttributeData.nKey != atInvalid) { APPEND_ATTRIB(pSkill->m_pSrcAttribute, AttributeData); } bRetCode = LoadAttribute(piTabFile, nRowIndex, "DestAttribute", i, &AttributeData); KGLOG_PROCESS_ERROR(bRetCode); if (AttributeData.nKey != atInvalid) { APPEND_ATTRIB(pSkill->m_pDestAttribute, AttributeData); } } bRetCode = piTabFile->GetInteger(nRowIndex, "CanCastWithBall", 0, &pSkill->m_bCanCastWithBall); KGLOG_PROCESS_ERROR(bRetCode); bRetCode = piTabFile->GetInteger(nRowIndex, "SkillType", skilltypeInvalid, (int*)&pSkill->m_eSkillType); KGLOG_PROCESS_ERROR(bRetCode); bRetCode = piTabFile->GetInteger(nRowIndex, "AttackIntervalFrame", 0, &pSkill->m_nAttackIntervalFrame); KGLOG_PROCESS_ERROR(bRetCode); bRetCode = piTabFile->GetInteger(nRowIndex, "TargetCostEndurance", 0, &pSkill->m_nTargetCostEndurance); KGLOG_PROCESS_ERROR(bRetCode); bRetCode = piTabFile->GetInteger(nRowIndex, "TargetCostStamina", 0, &pSkill->m_nTargetCostStamina); KGLOG_PROCESS_ERROR(bRetCode); bRetCode = piTabFile->GetInteger(nRowIndex, "TargetCostEndurancePercent", 0, &pSkill->m_nTargetCostEndurancePercent); KGLOG_PROCESS_ERROR(bRetCode); bRetCode = piTabFile->GetInteger(nRowIndex, "TargetCostStaminaPercent", 0, &pSkill->m_nTargetCostStaminaPercent); KGLOG_PROCESS_ERROR(bRetCode); bRetCode = piTabFile->GetString(nRowIndex, "MoveState", "cmsInvalid", szMoveState, sizeof(szMoveState)); KGLOG_PROCESS_ERROR(bRetCode); bRetCode = ENUM_STR2INT(HERO_MOVESTATE, szMoveState, pSkill->m_nMoveState); KGLOG_PROCESS_ERROR(bRetCode); bRetCode = piTabFile->GetInteger(nRowIndex, "MoveStateFrame", 0, &pSkill->m_nMoveStateFrame); KGLOG_PROCESS_ERROR(bRetCode); pSkill->m_nMoveStateFrame = pSkill->m_nMoveStateFrame * GAME_FPS / cdTimeBase; bRetCode = piTabFile->GetInteger(nRowIndex, "StepMinTime", 0, &pSkill->m_nStepMinFrame); KGLOG_PROCESS_ERROR(bRetCode); pSkill->m_nStepMinFrame = pSkill->m_nStepMinFrame * GAME_FPS / cdTimeBase; bRetCode = piTabFile->GetInteger(nRowIndex, "StepMaxTime", 0, &pSkill->m_nStepMaxFrame); KGLOG_PROCESS_ERROR(bRetCode); pSkill->m_nStepMaxFrame = pSkill->m_nStepMaxFrame * GAME_FPS / cdTimeBase; bRetCode = piTabFile->GetInteger(nRowIndex, "EndType", 0, (int*)&pSkill->m_eEndType); KGLOG_PROCESS_ERROR(bRetCode); bRetCode = piTabFile->GetInteger(nRowIndex, "EndFrame", 0, &pSkill->m_nEndFrame); KGLOG_PROCESS_ERROR(bRetCode); bRetCode = piTabFile->GetInteger(nRowIndex, "InterruptLevel", 0, &pSkill->m_nInterruptLevel); KGLOG_PROCESS_ERROR(bRetCode); bRetCode = piTabFile->GetString(nRowIndex, "Script", "", szScriptName, sizeof(szScriptName)); KGLOG_PROCESS_ERROR(bRetCode); szScriptName[sizeof(szScriptName) - 1] = '\0'; if (szScriptName[0] != '\0') pSkill->m_dwScriptID = g_FileNameHash(szScriptName); else pSkill->m_dwScriptID = 0; for (int i = 0; i < countof(pSkill->m_SubSkill); ++i) { char szKey[32] = ""; sprintf(szKey, "SubSkillID%d", i+1); bRetCode = piTabFile->GetInteger(nRowIndex, szKey, ERROR_ID, (int*)&pSkill->m_SubSkill[i].dwID); KGLOG_PROCESS_ERROR(bRetCode); sprintf(szKey, "SubSkillTriggerType%d", i+1); bRetCode = piTabFile->GetInteger(nRowIndex, szKey, KSKILL_TRIGGER_TYPE_INVALID, (int*)&pSkill->m_SubSkill[i].eType); KGLOG_PROCESS_ERROR(bRetCode); sprintf(szKey, "SubSkillTriggerTimer%d", i+1); bRetCode = piTabFile->GetInteger(nRowIndex, szKey, 0, &pSkill->m_SubSkill[i].nFrame); KGLOG_PROCESS_ERROR(bRetCode); pSkill->m_SubSkill[i].nFrame = pSkill->m_SubSkill[i].nFrame * GAME_FPS / cdTimeBase; sprintf(szKey, "SubSkillRate%d", i+1); bRetCode = piTabFile->GetInteger(nRowIndex, szKey, 0, (int*)&pSkill->m_SubSkill[i].dwRate); KGLOG_PROCESS_ERROR(bRetCode); } bRetCode = piTabFile->GetInteger(nRowIndex, "SelfAddAngry", 0, &pSkill->m_nSelfAddAngry); KGLOG_PROCESS_ERROR(bRetCode); bRetCode = piTabFile->GetInteger(nRowIndex, "TargetAddAngry", 0, &pSkill->m_nTargetAddAngry); KGLOG_PROCESS_ERROR(bRetCode); bRetCode = piTabFile->GetInteger(nRowIndex, "NeedAngry", 0, &pSkill->m_nNeedAngry); KGLOG_PROCESS_ERROR(bRetCode); bRetCode = piTabFile->GetInteger(nRowIndex, "CostAngry", 0, &pSkill->m_nCostAngry); KGLOG_PROCESS_ERROR(bRetCode); bRetCode = piTabFile->GetInteger(nRowIndex, "CostAngryPercent", 0, &pSkill->m_nCostAngryPercent); KGLOG_PROCESS_ERROR(bRetCode); bRetCode = piTabFile->GetInteger(nRowIndex, "TargetBuffLimit", 0, (int*)&pSkill->m_dwTargetBuffLimit); KGLOG_PROCESS_ERROR(bRetCode); bRetCode = piTabFile->GetInteger(nRowIndex, "CanCastCountInAir", 0, &pSkill->m_nCanCastCountInAir); KGLOG_PROCESS_ERROR(bRetCode); bRetCode = piTabFile->GetInteger(nRowIndex, "SpasticityTime", 0, &pSkill->m_nSpasticityFrame); KGLOG_PROCESS_ERROR(bRetCode); pSkill->m_nSpasticityFrame = pSkill->m_nSpasticityFrame * GAME_FPS / cdTimeBase; bRetCode = piTabFile->GetInteger(nRowIndex, "DelayEffect", 0, &pSkill->m_bDelayApplySkillEffect); KGLOG_PROCESS_ERROR(bRetCode); bRetCode = piTabFile->GetInteger(nRowIndex, "Invincible", 0, &pSkill->m_bInvincibleOnSpasticity); KGLOG_PROCESS_ERROR(bRetCode); bRetCode = piTabFile->GetInteger(nRowIndex, "IsCommonSkill", 0, (int*)&pSkill->m_bIsCommonSkill); KGLOG_PROCESS_ERROR(bRetCode); bRetCode = piTabFile->GetInteger(nRowIndex, "RequireLevel", 0, (int*)&pSkill->m_nRequireLevel); KGLOG_PROCESS_ERROR(bRetCode); bRetCode = piTabFile->GetInteger(nRowIndex, "GravityPercent", 0, &pSkill->m_nGravityPercent); KGLOG_PROCESS_ERROR(bRetCode > 0); bRetCode = piTabFile->GetInteger(nRowIndex, "JudgeBoxMinX", 0, &pSkill->m_nJudgeBoxMinX); KGLOG_PROCESS_ERROR(bRetCode > 0); bRetCode = piTabFile->GetInteger(nRowIndex, "JudgeBoxMaxX", 0, &pSkill->m_nJudgeBoxMaxX); KGLOG_PROCESS_ERROR(bRetCode > 0); bRetCode = piTabFile->GetInteger(nRowIndex, "JudgeBoxMinY", 0, &pSkill->m_nJudgeBoxMinY); KGLOG_PROCESS_ERROR(bRetCode > 0); bRetCode = piTabFile->GetInteger(nRowIndex, "JudgeBoxMaxY", 0, &pSkill->m_nJudgeBoxMaxY); KGLOG_PROCESS_ERROR(bRetCode > 0); bRetCode = piTabFile->GetInteger(nRowIndex, "JudgeBoxMinZ", 0, &pSkill->m_nJudgeBoxMinZ); KGLOG_PROCESS_ERROR(bRetCode > 0); bRetCode = piTabFile->GetInteger(nRowIndex, "JudgeBoxMaxZ", 0, &pSkill->m_nJudgeBoxMaxZ); KGLOG_PROCESS_ERROR(bRetCode > 0); bRetCode = piTabFile->GetInteger(nRowIndex, "CanSpecifyCastDir", 0, &pSkill->m_bCanSpecifyCastDir); KGLOG_PROCESS_ERROR(bRetCode > 0); bRetCode = piTabFile->GetInteger(nRowIndex, "CanSpecifyCastingDir", 0, &pSkill->m_bCanSpecifyCastingDir); KGLOG_PROCESS_ERROR(bRetCode > 0); bRetCode = piTabFile->GetString(nRowIndex, "RestraintType", "", szValue, countof(szValue)); KGLOG_PROCESS_ERROR(bRetCode > 0); szValue[countof(szValue) - 1] = '\0'; bRetCode = EnumStr2Int("RESTRAINT_TYPE", szValue, &pSkill->m_nRestraintType); KGLOG_PROCESS_ERROR(bRetCode); bRetCode = piTabFile->GetInteger(nRowIndex, "ClearVelocityAtEnd", 0, &pSkill->m_bClearVelocityAtEnd); KGLOG_PROCESS_ERROR(bRetCode > 0); bRetCode = piTabFile->GetInteger(nRowIndex, "Series", 0, &pSkill->m_nSeries); KGLOG_PROCESS_ERROR(bRetCode); bRetCode = piTabFile->GetInteger(nRowIndex, "FireAIEvent", 0, &pSkill->m_bFireAIEvent); KGLOG_PROCESS_ERROR(bRetCode); bRetCode = piTabFile->GetInteger(nRowIndex, "AIEventMinX", 0, &pSkill->m_nAIEventMinX); KGLOG_PROCESS_ERROR(bRetCode); bRetCode = piTabFile->GetInteger(nRowIndex, "AIEventMaxX", 0, &pSkill->m_nAIEventMaxX); KGLOG_PROCESS_ERROR(bRetCode); bRetCode = piTabFile->GetInteger(nRowIndex, "AIEventMinY", 0, &pSkill->m_nAIEventMinY); KGLOG_PROCESS_ERROR(bRetCode); bRetCode = piTabFile->GetInteger(nRowIndex, "AIEventMaxY", 0, &pSkill->m_nAIEventMaxY); KGLOG_PROCESS_ERROR(bRetCode); bRetCode = piTabFile->GetInteger(nRowIndex, "AIEventMinZ", 0, &pSkill->m_nAIEventMinZ); KGLOG_PROCESS_ERROR(bRetCode); bRetCode = piTabFile->GetInteger(nRowIndex, "AIEventMaxZ", 0, &pSkill->m_nAIEventMaxZ); KGLOG_PROCESS_ERROR(bRetCode); it = cSkillBinaryData.find(InsRet.first->first); if (it != cSkillBinaryData.end()) { pSkill->SetBinaryData(it->second); } // 以下代码用于验证输入内容的合法性 KGLOG_PROCESS_ERROR(pSkill->m_eSkillType > skilltypeInvalid && pSkill->m_eSkillType < skilltypeTotal); KGLOG_PROCESS_ERROR(pSkill->m_nMoveState >= cmsInvalid && pSkill->m_nMoveState < cmsTotal); KGLOG_PROCESS_ERROR(pSkill->m_eEndType >= KSKILL_END_TYPE_NONE && pSkill->m_eEndType < KSKILL_END_TYPE_TOTAL); // KGLOG_PROCESS_ERROR(pSkill->m_eSkillType != skilltypeGrab || pSkill->m_eEndType == KSKILL_END_TYPE_BY_TIME); KGLOG_PROCESS_ERROR(pSkill->m_eEndType != KSKILL_END_TYPE_BY_TIME || pSkill->m_nEndFrame >= 0); KGLOG_PROCESS_ERROR(pSkill->m_nSpasticityFrame >= 0); KGLOG_PROCESS_ERROR(pSkill->m_nSpasticityFrame != 0 || !pSkill->m_bDelayApplySkillEffect); KGLOG_PROCESS_ERROR(pSkill->m_nSpasticityFrame != 0 || !pSkill->m_bInvincibleOnSpasticity); for (int i = 0; i < countof(pSkill->m_SubSkill); ++i) { KGLOG_PROCESS_ERROR(pSkill->m_SubSkill[i].eType >= KSKILL_TRIGGER_TYPE_INVALID && pSkill->m_SubSkill[i].eType < KSKILL_TRIGGER_TYPE_TOTAL); KGLOG_PROCESS_ERROR(pSkill->m_SubSkill[i].dwRate >=0 && pSkill->m_SubSkill[i].dwRate <= SKILL_RATE_BASE); KGLOG_PROCESS_ERROR(pSkill->m_SubSkill[i].eType != KSKILL_TRIGGER_TYPE_TIMER || pSkill->m_SubSkill[i].nFrame > 0); } KGLOG_PROCESS_ERROR(pSkill->m_nSpasticityFrame >= 0); KGLOG_PROCESS_ERROR(pSkill->m_nAIEventMinX <= pSkill->m_nAIEventMaxX); KGLOG_PROCESS_ERROR(pSkill->m_nAIEventMinY <= pSkill->m_nAIEventMaxY); KGLOG_PROCESS_ERROR(pSkill->m_nAIEventMinZ <= pSkill->m_nAIEventMaxZ); } for (KSkillTable::iterator it = m_SkillTable.begin(); it != m_SkillTable.end(); ++it) { dwSkillID = it->second.m_dwID; bRetCode = it->second.UpdateOnSkillLoaded(); KGLOG_PROCESS_ERROR(bRetCode); } bResult = true; Exit0: if (!bResult) KGLogPrintf(KGLOG_ERR, "ID = %u", dwSkillID); KG_COM_RELEASE(piTabFile); return bResult; }
BOOL KAIManager::LoadAITabFile() { BOOL bResult = false; int nRetCode = false; ITabFile* piAITabFile = NULL; char szFilePath[] = SETTING_DIR"/AIType.tab"; int nHeight = 0; char szColumnName[MAX_PATH] = ""; BOOL bAILevelValid = false; uint64_t u64Key = 0; std::pair<KAI_TABLE::iterator, bool> RetPair; piAITabFile = g_OpenTabFile(szFilePath); if (!piAITabFile) { KGLogPrintf(KGLOG_ERR, "[AI] Unable to open table file \"%s\"\n", szFilePath); goto Exit0; } nHeight = piAITabFile->GetHeight(); KGLOG_PROCESS_ERROR(nHeight > 1); m_nMaxAILevel = 0; for (int nRow = 2; nRow <= nHeight; nRow++) { int nAIType = 0; DWORD dwScriptID = 0; char szScriptPath[MAX_PATH]; KAIInfo AIInfo; nRetCode = piAITabFile->GetInteger(nRow, "AIType", 0, &nAIType); KGLOG_PROCESS_ERROR(nRetCode); KGLOG_PROCESS_ERROR(nAIType >= 0); nRetCode = piAITabFile->GetString(nRow, "ScriptFile", "", szScriptPath, sizeof(szScriptPath)); KGLOG_PROCESS_ERROR(nRetCode); dwScriptID = g_FileNameHash(szScriptPath); KGLOG_PROCESS_ERROR(dwScriptID); AIInfo.dwScriptID = dwScriptID; for (int i = 0; i < countof(AIInfo.nAIOP); ++i) { sprintf(szColumnName, "AIOperation%02d", i + 1); nRetCode = piAITabFile->GetInteger(nRow, szColumnName, 0, &AIInfo.nAIOP[i]); KGLOG_PROCESS_ERROR(nRetCode); } nRetCode = piAITabFile->GetInteger(nRow, "AILevelValid", 0, &bAILevelValid); KGLOG_PROCESS_ERROR(nRetCode > 0); AIInfo.bAILevelValid = bAILevelValid; AIInfo.nAILevel = 0; AIInfo.dwAIGroupID = 0; if (bAILevelValid) { nRetCode = piAITabFile->GetInteger(nRow, "AILevel", 0, &AIInfo.nAILevel); KGLOG_PROCESS_ERROR(nRetCode > 0); nRetCode = piAITabFile->GetInteger(nRow, "AIGroupID", DEFAULT_AI_GROUP_ID, (int*)&AIInfo.dwAIGroupID); KGLOG_PROCESS_ERROR(nRetCode); u64Key = MAKE_INT64(AIInfo.dwAIGroupID, AIInfo.nAILevel); m_AILevelTable[u64Key].push_back(nAIType); if (AIInfo.nAILevel > m_nMaxAILevel) m_nMaxAILevel = AIInfo.nAILevel; } AIInfo.pLogic = NULL; m_AITable[nAIType] = AIInfo; } { int nCount = (int)m_AITable.size(); int nIndex = 1; for (KAI_TABLE::iterator it = m_AITable.begin();it != m_AITable.end(); ++it, ++nIndex) { #if (defined(_MSC_VER) || defined(__ICL)) //WINDOWS cprintf("******************************>: Setup AI scripts : %d/%d\r", nIndex, nCount); #endif it->second.pLogic = CreateAI(it->first, it->second.dwScriptID); } #if (defined(_MSC_VER) || defined(__ICL)) //WINDOWS cprintf("\n"); #endif } bResult = true; Exit0: if (!bResult) { m_AITable.clear(); } KG_COM_RELEASE(piAITabFile); return bResult; }