예제 #1
0
BOOL KGMInfoList::Init()
{
    BOOL        bResult     = false;
    int         nRetCode    = false;
    ITabFile*   piTabFile   = NULL;
    char        szFilePath[MAX_PATH];

    snprintf(szFilePath, sizeof(szFilePath), "%s/%s", SETTING_DIR, GMACCOUNT_LIST_FILE_NAME);
    szFilePath[sizeof(szFilePath) - 1] = '\0';

    piTabFile = g_OpenTabFile(szFilePath);
    KGLOG_PROCESS_ERROR(piTabFile);

    for (int nRowIndex = 2; nRowIndex <= piTabFile->GetHeight(); nRowIndex++)
    {
        GMAccountInfo NewGMAccount;

        piTabFile->GetString(nRowIndex, "szAccount", "", NewGMAccount.szGMAccount, sizeof(NewGMAccount.szGMAccount));
        NewGMAccount.szGMAccount[countof(NewGMAccount.szGMAccount) - 1] = '\0';
        KGLOG_PROCESS_ERROR(NewGMAccount.szGMAccount != '\0');

        m_GMAccountInfoList.push_back(NewGMAccount);
    }

    bResult = true;
Exit0:
    KG_COM_RELEASE(piTabFile);
    return bResult;
}
예제 #2
0
BOOL KQuestInfoList::LoadRandomQuestGroup()
{
    BOOL        bResult         = false;
    int         nRetCode        = false;
    int         nHeight         = 0;
    ITabFile*   piTabFile       = NULL;
    DWORD       dwTemplateID    = 0;
    DWORD       dwQuestID       = 0;
    KQuestInfo* pQuestInfo      = NULL;
    char        szFilePath[MAX_PATH];
    char        szColName[64];
    std::set<DWORD>::iterator setIt;
    int         nID             = 0;

    nRetCode = (int)snprintf(szFilePath, sizeof(szFilePath), "%s/%s", SETTING_DIR, RANDOM_QUEST_FILE_NAME);
    KGLOG_PROCESS_ERROR(nRetCode > 0 && nRetCode < (int)sizeof(szFilePath));

    piTabFile = g_OpenTabFile(szFilePath);
    KGLOG_PROCESS_ERROR(piTabFile);

    nHeight = piTabFile->GetHeight();
    if (nHeight >= 2)
    {
        for (int i = 2; i <= nHeight; ++i)
        {
            KQUEST_GROUP QuestGroupInfo;

            nRetCode = piTabFile->GetInteger(i, "ID", 0, &nID);
            KGLOG_PROCESS_ERROR(nRetCode > 0);

            for (int j = 0; j < RANDOM_QUEST_COUNT_PER_GROUP; ++j)
            {
                snprintf(szColName, sizeof(szColName), "Quest%d", j + 1);
                szColName[sizeof(szColName) - 1] = '\0';

                nRetCode = piTabFile->GetInteger(i, szColName, 0, (int*)&dwQuestID);

                if (dwQuestID == 0)
                    break;

                pQuestInfo = GetQuestInfo(dwQuestID);
                KGLOG_PROCESS_ERROR(pQuestInfo);

                KGLOG_PROCESS_ERROR(pQuestInfo->bAccept);
                KGLOG_PROCESS_ERROR(pQuestInfo->bRepeat);

                QuestGroupInfo.push_back(dwQuestID);
            }
        
            m_RandomQuestGroup[nID] = QuestGroupInfo;
        }
    }
    
Exit1:
    bResult = true;
Exit0:
    KG_COM_RELEASE(piTabFile);
    return bResult;
}
예제 #3
0
파일: KEntryList.cpp 프로젝트: 1suming/pap2
BOOL KEntryList::Init()
{
    BOOL            bResult         = false;
    int             nRetCode        = false;
    ITabFile*       piTabFile       = NULL;
    int             nTabHeight      = 0;
    char            szFileName[PATH_MAX];

    snprintf(szFileName, sizeof(szFileName), "%s/EntryList.tab", SETTING_DIR);
    szFileName[sizeof(szFileName) - 1] = '\0';

    piTabFile = g_OpenTabFile(szFileName);
    if (!piTabFile)
    {
        KGLogPrintf(KGLOG_ERR, "[EntryList] Failed to open entry list file : %s\n", szFileName);
        goto Exit0;
    }

    nTabHeight = piTabFile->GetHeight();

    for (int nLine = 2; nLine <= nTabHeight; nLine++)
    {
        __int64     nKey        = 0;
        int         nMapID      = 0;
        int         nIndex      = 0;
        KMapEntry   EntryInfo;

        nRetCode = piTabFile->GetInteger(nLine, "Map", 0, &nMapID);
        KGLOG_PROCESS_ERROR(nRetCode == 1);

        nRetCode = piTabFile->GetInteger(nLine, "Index", 0, &nIndex);
        KGLOG_PROCESS_ERROR(nRetCode == 1);

        nRetCode = piTabFile->GetInteger(nLine, "PosX", 0, &EntryInfo.nPosX);
        KGLOG_PROCESS_ERROR(nRetCode == 1);

        nRetCode = piTabFile->GetInteger(nLine, "PosY", 0, &EntryInfo.nPosY);
        KGLOG_PROCESS_ERROR(nRetCode == 1);

        nRetCode = piTabFile->GetInteger(nLine, "PosZ", 0, &EntryInfo.nPosZ);
        KGLOG_PROCESS_ERROR(nRetCode == 1);

        nRetCode = piTabFile->GetInteger(nLine, "Direction", 0, &EntryInfo.nDirection);
        KGLOG_PROCESS_ERROR(nRetCode == 1);

        nKey = MAKE_INT64(nMapID, nIndex);
        
        m_EntryList[nKey] = EntryInfo;
    }

    bResult = true;
Exit0:
    KG_COM_RELEASE(piTabFile);
    if (!bResult)
    {
        m_EntryList.clear();
    }
    return bResult;
}
예제 #4
0
BOOL OpenseSetting::ReadOpenseTemplate()
{
	m_MapOpenseCfg.clear();
	INT nFileHeight = 0;
	ITabFile* tabFile = g_OpenTabFile(OPENSE_FILE_PATH);

	CHAR szFilePath[_MAX_PATH];
	QString szFileTemp;
	ITabFile* pFile = NULL;
	LOG_PROCESS_ERROR(tabFile);

	nFileHeight = tabFile->GetHeight();

	for (INT i = 3; i <= nFileHeight; i++)  // µÚ3ÐÐ
	{
		OpenseCfg* openseTemplate = new OpenseCfg();
		tabFile->GetInteger(i, "id", 0, &openseTemplate->nId);
		tabFile->GetInteger(i, "awardId", 0, &openseTemplate->nAwardId);
		tabFile->GetInteger(i, "autoGive", 0, &openseTemplate->nAutoGive);
		tabFile->GetString(i, "conditionPath", "", szFilePath, _MAX_PATH);

		szFileTemp = OPENSE_DAY_FOLD;
		szFileTemp = szFileTemp + szFilePath;
		pFile = g_OpenTabFile(szFileTemp.CStr());
		QCONFIRM_RET_FALSE(pFile);
		for (int j = 3; j <= pFile->GetHeight(); j++)
		{
			OpenseDayCfg* openseDay = new OpenseDayCfg();
			pFile->GetInteger(j, "id", 0, &openseDay->nId);
			pFile->GetInteger(j, "awardId", 0, &openseDay->nAwardId);
			pFile->GetInteger(j, "finishCount", 0, &openseDay->nFinishCount);
			pFile->GetInteger(j, "autoGive", 0, &openseDay->nAutoGive);

			openseTemplate->mapOpenseDay.insert(std::make_pair(openseDay->nId, openseDay));
		}
		m_MapOpenseCfg.insert(std::make_pair(openseTemplate->nId, openseTemplate));
	}

	return TRUE;

EXIT0:
	return FALSE;
}
예제 #5
0
BOOL KQuestInfoList::Reload()
{
    BOOL        bResult     = false;
    int         nRetCode    = false;
    int         nHeight     = 0;
    ITabFile*   piTabFile   = NULL;
    char        szFilePath[MAX_PATH];
    DWORD       dwQuestID    = 0;
    KQuestInfo* pQuestInfo  = NULL;

    nRetCode = (int)snprintf(szFilePath, sizeof(szFilePath), "%s/%s", SETTING_DIR, QUEST_FILE_NAME);
    KGLOG_PROCESS_ERROR(nRetCode > 0 && nRetCode < (int)sizeof(szFilePath));

    piTabFile = g_OpenTabFile(szFilePath);
    KGLOG_PROCESS_ERROR(piTabFile);

    nHeight = piTabFile->GetHeight();
    KGLOG_PROCESS_ERROR(nHeight > 1);

    nRetCode = LoadQuestInfo(piTabFile, 2, &m_DefaultQuestInfo);
    KGLOG_PROCESS_ERROR(nRetCode);

    m_DailyQuest.clear();
    m_RandomQuestGroup.clear();

    for (int nIndex = 3; nIndex <= nHeight; nIndex++)
    {
        KQuestInfo	TempQuestInfo;

        nRetCode = piTabFile->GetInteger(nIndex, "QuestID", m_DefaultQuestInfo.dwQuestID, (int*)&dwQuestID);
        KGLOG_PROCESS_ERROR(nRetCode);
        KGLOG_PROCESS_ERROR(dwQuestID < MAX_QUEST_COUNT);

        pQuestInfo = GetQuestInfo(dwQuestID);

        if (pQuestInfo == NULL)
            pQuestInfo = &TempQuestInfo;

        nRetCode = LoadQuestInfo(piTabFile, nIndex, pQuestInfo);
        KGLOG_PROCESS_ERROR(nRetCode);

        m_mapID2QuestInfo[dwQuestID] = *pQuestInfo;

        if (pQuestInfo->bDaily)
            m_DailyQuest.push_back(pQuestInfo->dwQuestID);
    }

    nRetCode = LoadRandomQuestGroup();
    KGLOG_PROCESS_ERROR(nRetCode);

    bResult = true;
Exit0:
    KG_COM_RELEASE(piTabFile);
    return bResult;
}
예제 #6
0
BOOL KCoolDownList::Init()
{
    BOOL        bResult                 = false;
    int         nRetCode                = false;
    ITabFile*   piTabFile               = NULL;
    int         nItemCount              = 0;
    char        szFileName[MAX_PATH];
    KCOOL_DWON_INFO Info;

    nRetCode = snprintf(szFileName, sizeof(szFileName), "%s/%s", SETTING_DIR, COOL_DOWN_TAB_FILE);
    szFileName[sizeof(szFileName) - 1] = '\0';
    KGLOG_PROCESS_ERROR(nRetCode > 0);

	piTabFile = g_OpenTabFile(szFileName);
	KGLOG_PROCESS_ERROR(piTabFile);

    // 第一行是名称(ID, Duration)
    nItemCount = piTabFile->GetHeight() - 1; 
    KGLOG_PROCESS_ERROR(nItemCount >= 0);
    KGLOG_PROCESS_ERROR(nItemCount < MAX_COOL_DOWN_COUNT);

    for (int i = 0; i < nItemCount; ++i)
    {
        float fDuration = 0.0f;

		nRetCode = piTabFile->GetInteger(2 + i, "ID", 0, (int*)&Info.dwID);
		KGLOG_PROCESS_ERROR(nRetCode);
        KGLOG_PROCESS_ERROR(Info.dwID > 0 && Info.dwID < USHRT_MAX);

        // 策划填写数值时填秒数即可,这里转换为游戏帧数
		nRetCode = piTabFile->GetFloat(2 + i, "Duration", 0, &fDuration);
		KGLOG_PROCESS_ERROR(nRetCode);
        KGLOG_PROCESS_ERROR(fDuration > 0);

        Info.nDuration = (int)(fDuration * GAME_FPS);

        nRetCode = piTabFile->GetInteger(2 + i, "NeedSave", 0, (int*)&Info.bNeedSave);
		KGLOG_PROCESS_ERROR(nRetCode);

        nRetCode = piTabFile->GetInteger(2 + i, "GroupID", 0, (int*)&Info.nGroupID);
		KGLOG_PROCESS_ERROR(nRetCode);

        m_CoolDownTable[Info.dwID] = Info;
    }

    bResult = true;
Exit0:
    if (!bResult)
    {
        m_CoolDownTable.clear();
    }
    KG_COM_RELEASE(piTabFile);
    return bResult;
}
예제 #7
0
파일: KTrackList.cpp 프로젝트: 1suming/pap2
BOOL KTrackList::Load()
{
    BOOL        bResult     = false;
    int         nRetCode    = 0;
    ITabFile*   piTabFile   = NULL;
    int         nTabHeight  = 0;
    char        szFileName[MAX_PATH];

    snprintf(szFileName, sizeof(szFileName), "%s/%s/track.tab", SETTING_DIR, TRACK_DIR);
    szFileName[sizeof(szFileName) - 1] = '\0';

    piTabFile = g_OpenTabFile(szFileName);
    KGLOG_PROCESS_ERROR(piTabFile);

    nTabHeight = piTabFile->GetHeight();
    KGLOG_PROCESS_ERROR(nTabHeight >= 2);

    for (int nLine = 2; nLine <= nTabHeight; nLine++)
    {
        DWORD       dwID        = 0;
        KTRACK*     pTrack      = NULL;
        KTRACK_INFO TrackInfo;
        pair<KTRACK_TABLE::iterator, bool> IntResult;
        
        nRetCode = piTabFile->GetInteger(nLine, COL_ID, 0, (int*)&dwID);
        KGLOG_PROCESS_ERROR(nRetCode);

        nRetCode = piTabFile->GetInteger(nLine, COL_MAP, 0, (int*)&TrackInfo.dwMapID);
        KGLOG_PROCESS_ERROR(nRetCode);

        nRetCode = piTabFile->GetString(nLine, COL_DESC, "?", TrackInfo.szDesc, sizeof(TrackInfo.szDesc));
        KGLOG_PROCESS_ERROR(nRetCode);

        IntResult = m_TrackTable.insert(KTRACK_TABLE::value_type(dwID, TrackInfo));
        KGLOG_PROCESS_ERROR(IntResult.second);
        pTrack = &IntResult.first->second.Track;
        
        nRetCode = LoadTrack(dwID, pTrack);
        KGLOG_PROCESS_ERROR(nRetCode);

        nRetCode = CalculateCriticalFrame(pTrack);
        KGLOG_PROCESS_ERROR(nRetCode);
    }

    bResult = true;
Exit0:
    if (!bResult)
    {
        m_TrackTable.clear();
    }
    KG_COM_RELEASE(piTabFile);
    return bResult;
}
예제 #8
0
BOOL KBattleFieldQueueManager::LoadBattleFieldQueueTab(const char* szFileName)
{
    BOOL        bResult     = false;
    BOOL        bRetCode    = false;
    ITabFile*   piTabFile   = NULL;
    int         nHieght     = 0;
    
    piTabFile = g_OpenTabFile(szFileName);
    KGLOG_PROCESS_ERROR(piTabFile);

    nHieght = piTabFile->GetHeight();
    KGLOG_PROCESS_ERROR(nHieght > 1);

    for (int nIndex = 2; nIndex <= nHieght; nIndex++)
    {
        DWORD           dwMapID = 0;
        KBattleField    BattleField;

        bRetCode = piTabFile->GetInteger(nIndex, "MapID", 0, (int*)&dwMapID);
        KGLOG_PROCESS_ERROR(bRetCode && "Get MapID");

        BattleField.dwMapID = dwMapID;

        bRetCode = piTabFile->GetInteger(nIndex, "MinLevelRequire", 0, &BattleField.nMinJoinLevel);
        KGLOG_PROCESS_ERROR(bRetCode && "Get MinLevelRequire");

        bRetCode = piTabFile->GetInteger(nIndex, "MaxLevelRequire", 0, &BattleField.nMaxJoinLevel);
        KGLOG_PROCESS_ERROR(bRetCode && "Get MaxLevelRequire");

        for (int i = 0; i < QUEUE_PER_BATTLE; i++)
        {
            int  nRetCode               = 0;
            char szColName[_NAME_LEN];

            nRetCode = snprintf(szColName, sizeof(szColName), "ForceMask%d", i + 1);
            KGLOG_PROCESS_ERROR(nRetCode >= 0 && nRetCode < sizeof(szColName));

            bRetCode = piTabFile->GetInteger(nIndex, szColName, 0, (int*)&BattleField.dwForcMask[i]);
            KGLOG_PROCESS_ERROR(bRetCode && "Get ForceMask");

            BattleField.QueueList[i].clear();
            BattleField.nAvgQueueTime[i] = 0;
        }

        m_QueueTable.insert(std::make_pair(dwMapID, BattleField));
    }

    bResult = true;
Exit0:
    KG_COM_RELEASE(piTabFile);
    return bResult;
}
예제 #9
0
void KG3DAnimationSoundTagInfo::Init()
{
	int nHeight = 0;
	ITabFile *pTabFile = NULL;
    IIniFile *pIniFile = NULL;
    pTabFile = g_OpenTabFile(s_strConfigTabFile);
	KG_PROCESS_ERROR(pTabFile);
	m_SoundType.clear();
	m_AnimationSoundTagInfo.clear();
	for (size_t i = 0 ; i < sizeof(s_strSoundType) / sizeof(TCHAR *) ; i ++)
	{
		std::string strFirst = s_strSoundType[i];
		m_SoundType[strFirst] = i;
	}
	nHeight = pTabFile->GetHeight();
	for (int i = 2 ; i <= nHeight ; i ++)
	{
		AnimationSoundTagInfo Info;
		TCHAR strSoundType[MAX_PATH];
		std::string SoundTypetemp;
		iter it = m_SoundType.begin();
		int nSoundType = 0;
		pTabFile->GetString(i,COL_SOUNDTYPE,"",strSoundType,MAX_PATH);
		pTabFile->GetString(i,COL_FILENAME,"",Info.strFileName,MAX_PATH);
		pTabFile->GetFloat(i,COL_RATE,0.0f,&Info.fRate);
		_strlwr_s(strSoundType,MAX_PATH);
		SoundTypetemp = strSoundType;
		KG_PROCESS_ERROR(m_SoundType.find(SoundTypetemp) != m_SoundType.end());
		Info.soundType = static_cast<SoundType>(m_SoundType[SoundTypetemp]);
		nSoundType = m_SoundType[SoundTypetemp];
		if(m_AnimationSoundTagInfo.find(nSoundType) 
			!= m_AnimationSoundTagInfo.end())
		{
			m_AnimationSoundTagInfo[nSoundType].push_back(Info);
		}
		else
		{
			std::vector<AnimationSoundTagInfo> vec;
			vec.push_back(Info);
			m_AnimationSoundTagInfo[nSoundType] = vec;
		}
	}
	Adjust();
    pIniFile = g_OpenIniFile(s_strConfigIniFile);
    KG_PROCESS_ERROR(pIniFile);
    pIniFile->GetInteger("ROOT","SaveVersion3Data",0,&m_nSaveVersion3Data);
	m_bInit = TRUE;
Exit0:
    SAFE_RELEASE(pTabFile);
    SAFE_RELEASE(pIniFile);
	;
}
예제 #10
0
BOOL KAwardSetting::ReadExpAwardConfigs()
{
	INT nExpAwardId = 0;
	CHAR szPath[_MAX_PATH];
	QString szFileTemp;
	ITabFile* pExpAwardFile = NULL;
	ITabFile* pTabFile = g_OpenTabFile(EXP_AWARD_FILE);
	QCONFIRM_RET_FALSE(pTabFile);

	for (INT i = 2; i < pTabFile->GetHeight(); i++)
	{
		pTabFile->GetInteger(i + 1, "ExpAwardId", 0, &nExpAwardId);
		pTabFile->GetString(i + 1, "Path", "", szPath, _MAX_PATH);

		szFileTemp = EXP_AWARD_FILE_FOLDER;
		szFileTemp = szFileTemp + szPath;

		pExpAwardFile = g_OpenTabFile(szFileTemp.CStr());
		QCONFIRM_RET_FALSE(pExpAwardFile);

		MAP_EXP_AWARD mapExpAward;

		for (INT j = 2; j < pExpAwardFile->GetHeight(); j++)
		{
			KExpAward sAward;
			
			pExpAwardFile->GetInteger(j + 1, "Level", 0, &sAward.nLevel);
			pExpAwardFile->GetInteger(j + 1, "Percent", 0, &sAward.nPercent);
			mapExpAward[sAward.nLevel] = sAward;
		}

		m_mapExpAwards[nExpAwardId] = mapExpAward;
	}

	return TRUE;
}
예제 #11
0
BOOL FactionManager::Init()
{
	INT nRowNum = 0;
	// 读取门派技能表
    ITabFile* pTabFile = NULL;//g_OpenTabFile(KD_FACTION_SKILL_LIST_TABLE);
	//LOG_PROCESS_ERROR(pTabFile);

	// 读取门派成长数值表
	pTabFile = g_OpenTabFile(KD_FACTION_ABILITY_TABLE);
	LOG_PROCESS_ERROR(pTabFile);

	nRowNum = pTabFile->GetHeight();
	for (INT i = 3; i < nRowNum; i++)
	{
		INT  nFactionId = 0, nRouteId = 0;
		pTabFile->GetInteger(i, "FactionId", 0, &nFactionId);
		pTabFile->GetInteger(i, "RouteId", 0, &nRouteId);

		INT nEnumId = (nFactionId << 16) | nRouteId; // 联合id
		if (m_cFactionData.mapFactionGrowthData.find(nEnumId) == m_cFactionData.mapFactionGrowthData.end())
		{
			m_cFactionData.mapFactionGrowthData.insert(
				std::pair<INT, std::vector<CHARACTER_BASE_ATTRIBUTE*> >(nEnumId, std::vector<CHARACTER_BASE_ATTRIBUTE*>())
			);
			// m_cFactionData.mapFactionGrowthData[nEnumId] = std::vector<CHARACTER_BASE_ATTRIBUTE*>();
		}

		std::vector<CHARACTER_BASE_ATTRIBUTE*>& arrFactionAbility = m_cFactionData.mapFactionGrowthData[nEnumId];

		CHARACTER_BASE_ATTRIBUTE* pBaseAttribute = new CHARACTER_BASE_ATTRIBUTE;
		LOG_PROCESS_ERROR(pBaseAttribute);

		memset(pBaseAttribute, 0, sizeof(CHARACTER_BASE_ATTRIBUTE));

		pTabFile->GetInteger(i, "Level", 0, &pBaseAttribute->nLevel);
		pTabFile->GetInteger(i, "Con", 0, &pBaseAttribute->nConstitution);
		pTabFile->GetInteger(i, "Str", 0, &pBaseAttribute->nStrength);
		pTabFile->GetInteger(i, "Agi", 0, &pBaseAttribute->nAgile);
		pTabFile->GetInteger(i, "Int", 0, &pBaseAttribute->nIntelligence);
		pTabFile->GetInteger(i, "Spi", 0, &pBaseAttribute->nSpirit);

		arrFactionAbility.push_back(pBaseAttribute);
	}

    return TRUE;
EXIT0:
	return FALSE;
}
예제 #12
0
BOOL KNpcHelper::ReadNpcIntensityTable()
{
	BOOL bResult = FALSE;
	ITabFile* pFile = g_OpenTabFile(DF_NPC_INTENSITY);
	QCONFIRM_RET_FALSE(pFile);

	DWORD dwNpcID;
	DWORD dwNpcLevel;
	NPC_INTENSITY cIntensity;
	INT nTmp = 0;
	for (INT n = 2; n <= pFile->GetHeight(); ++n)
	{
		pFile->GetInteger(n, "ID", 0, &nTmp);
		dwNpcID = (DWORD)nTmp;
		pFile->GetInteger(n, "Level", 0, &nTmp);
		dwNpcLevel = (DWORD)nTmp;
		cIntensity.nLevel = dwNpcLevel;
		pFile->GetInteger(n, "LevelRate", 0, &cIntensity.nLevelRate);
        pFile->GetInteger(n, "Life", 0, &cIntensity.nNpcHp);
		pFile->GetInteger(n, "LifeReplenish", 0, &cIntensity.nNpcHpReplenish);
		pFile->GetInteger(n, "Mana", 0, &cIntensity.nMana);
		pFile->GetInteger(n, "ManaReplenish", 0, &cIntensity.nManaReplenish);
		pFile->GetInteger(n, "Exp", 0, &cIntensity.nExp);
		pFile->GetInteger(n, "ExpType", 0, &cIntensity.nExpType);
		pFile->GetInteger(n, "Hit", 0, &cIntensity.nHit);
		pFile->GetInteger(n, "Duck", 0, &cIntensity.nDuck);
		pFile->GetInteger(n, "Armor", 0, &cIntensity.nArmor);
		pFile->GetInteger(n, "Attack", 0, &cIntensity.nAttack);
		pFile->GetInteger(n, "Critical", 0, &cIntensity.nCritical);
		pFile->GetInteger(n, "DeCritical", 0, &cIntensity.nDeCritical);
		pFile->GetInteger(n, "WalkSpeed", 0, &cIntensity.nWalkSpeed);
		pFile->GetInteger(n, "RunSpeed", 0, &cIntensity.nRunSpeed);
		pFile->GetInteger(n, "IgnoreDef", 0, &cIntensity.nIgnoreDef);

		if (m_mapNpcIntensityTable.find(dwNpcID) == m_mapNpcIntensityTable.end())
		{
			m_mapNpcIntensityTable[dwNpcID] = std::map<DWORD, NPC_INTENSITY>();
		}

		std::map<DWORD, NPC_INTENSITY>& mapNpcIntensity = m_mapNpcIntensityTable[dwNpcID];
		mapNpcIntensity[dwNpcLevel] = cIntensity;
	}

	SAFE_RELEASE(pFile);
    return TRUE;
}
예제 #13
0
BOOL KRelationList::Init(const char* szSettingFile)
{
	BOOL bResult = false;
	int nSize = 0;
	int nRetCode = 0;
	ITabFile*	pTabFile = NULL;
	char	szFileName[MAX_PATH];

	KGLOG_PROCESS_ERROR(szSettingFile);

	snprintf(szFileName, sizeof(szFileName), "%s/%s", SETTING_DIR, szSettingFile);
    szFileName[sizeof(szFileName) - 1] = '\0';

	pTabFile = g_OpenTabFile(szFileName);
	KGLOG_PROCESS_ERROR(pTabFile);

	nSize = pTabFile->GetHeight() - 1;
	KGLOG_PROCESS_ERROR(nSize > 0);
	assert(m_nRelation == NULL);

	m_nRelation = new int*[nSize];
	for (int i = 0; i < nSize; i++)
	{
		m_nRelation[i] = new int[nSize];
	}
	m_nSize = nSize;

	for (int i = 2; i < nSize + 2; i++)
	{
		int nId = 0;
		nRetCode = pTabFile->GetInteger(i, RELATION_ID, 0, &nId);
		KGLOG_PROCESS_ERROR(nRetCode && nId == i - 2);
		for (int j = 0; j < nSize; j++)
		{
			char szKey[256];
			sprintf(szKey, "%d", j);
			nRetCode = pTabFile->GetInteger(i, szKey, 0, &m_nRelation[i - 2][j]);
			KGLOG_PROCESS_ERROR(nRetCode != 0);
		}
	}

	bResult = true;
Exit0:
	KG_COM_RELEASE(pTabFile);
	return bResult;
}
예제 #14
0
BOOL KQuestInfoList::Init(void)
{
    BOOL        bResult     = false;
    int         nRetCode    = false;
    int         nHeight     = 0;
    ITabFile*   piTabFile   = NULL;
	char        szFilePath[MAX_PATH];
    std::pair<MAP_ID_2_QUEST_INFO::iterator, bool> InsRet;

	nRetCode = (int)snprintf(szFilePath, sizeof(szFilePath), "%s/%s", SETTING_DIR, QUEST_FILE_NAME);
    KGLOG_PROCESS_ERROR(nRetCode > 0 && nRetCode < (int)sizeof(szFilePath));

	piTabFile = g_OpenTabFile(szFilePath);
	KGLOG_PROCESS_ERROR(piTabFile);

	nHeight = piTabFile->GetHeight();
	KGLOG_PROCESS_ERROR(nHeight > 1);

    memset(&m_DefaultQuestInfo, 0, sizeof(m_DefaultQuestInfo));

	nRetCode = LoadQuestInfo(piTabFile, 2, &m_DefaultQuestInfo);
	KGLOG_PROCESS_ERROR(nRetCode);

	for (int nIndex = 3; nIndex <= nHeight; nIndex++)
	{
		KQuestInfo	TempQuestInfo;

		nRetCode = LoadQuestInfo(piTabFile, nIndex, &TempQuestInfo);
		KGLOG_PROCESS_ERROR(nRetCode);

		nRetCode = MakeQuestMap(&TempQuestInfo);
        KGLOG_PROCESS_ERROR(nRetCode);

#ifdef _SERVER
        InsRet = m_mapID2QuestInfo.insert(std::make_pair(TempQuestInfo.dwQuestID, TempQuestInfo));
        KGLOG_PROCESS_ERROR(InsRet.second);
#endif
	}

    bResult = true;
Exit0:
	KG_COM_RELEASE(piTabFile);
	return bResult;
}
예제 #15
0
BOOL KAwardMgr::LoadAllAward()
{
    BOOL        bResult     = false;
    BOOL        bRetCode    = false;
    ITabFile*	piTabFile   = NULL;
    DWORD       dwAwardID   = 0;
    char        szAwardFileName[MAX_PATH];
    char        szFilePath[MAX_PATH];
    std::pair<KAWARD_TABLE_MAP::iterator, bool> InsRet;
    KAwardTable* pAwardTable = NULL;

    snprintf(szFilePath, sizeof(szFilePath), "%s/%s", SETTING_DIR, "award/award.tab");
    szFilePath[sizeof(szFilePath) - 1] = '\0';

    piTabFile = g_OpenTabFile(szFilePath);
    KGLOG_PROCESS_ERROR(piTabFile);

    for (int nRowIndex = 2; nRowIndex <= piTabFile->GetHeight(); nRowIndex++)
    {
        bRetCode = piTabFile->GetInteger(nRowIndex, "ID", 0, (int*)&dwAwardID);
        KGLOG_PROCESS_ERROR(bRetCode > 0);

        bRetCode = piTabFile->GetString(nRowIndex, "AwardItem", "", szAwardFileName, sizeof(szAwardFileName));
        KGLOG_PROCESS_ERROR(bRetCode > 0);
        KGLOG_PROCESS_ERROR(szAwardFileName[0] != '\0');

        InsRet = m_AwardTable.insert(std::make_pair(dwAwardID, KAwardTable()));
        KGLOG_PROCESS_ERROR(InsRet.second);

        pAwardTable = &InsRet.first->second;

        bRetCode = LoadOneAward(szAwardFileName, pAwardTable);
        if (!bRetCode)
        {
            KGLogPrintf(KGLOG_DEBUG, "Load award file:%s failed!", szAwardFileName);
            goto Exit0;
        }
    }

    bResult = true;
Exit0:
    KG_COM_RELEASE(piTabFile);
    return bResult;
}
예제 #16
0
HRESULT KG3DTerrainRepresentInfo::Init()
{
	HRESULT hResult = E_FAIL;
    HRESULT hRetCode = E_FAIL;
	int nHeight = 0;
	
	m_TerrainRepresentInfo.clear();

	ITabFile *pTabFile = g_OpenTabFile(s_strConfigFile);
	KG_PROCESS_ERROR(pTabFile);

	nHeight = pTabFile->GetHeight();
	for (int i = 2; i <= nHeight; i++)
	{
		TerrainRepresentInfo Info;
		int nGroundType = 0;
		TCHAR strLower[MAX_PATH];
		pTabFile->GetString(i, COL_FILENAME, "", Info.strFileName, MAX_PATH);
		strcpy_s(strLower, MAX_PATH, Info.strFileName);
		_strlwr_s(strLower, MAX_PATH);
		DWORD dwHash = g_FileNameHash(strLower);
		pTabFile->GetString(i, COL_ANNOTATE, "", Info.strAnnotate, MAX_PATH);
		pTabFile->GetInteger(i, COL_TYPE, INVALID_GROUNDTYPE, &nGroundType);
		Info.dwType = static_cast<DWORD>(nGroundType);

        pTabFile->GetString(i,COL_SFX,"",Info.strSfx[COL_SFX-COL_SFX],MAX_PATH);
        pTabFile->GetString(i,COL_SFX1,"",Info.strSfx[COL_SFX1-COL_SFX],MAX_PATH);
        pTabFile->GetString(i,COL_SFX2,"",Info.strSfx[COL_SFX2-COL_SFX],MAX_PATH);
        pTabFile->GetString(i,COL_SFX3,"",Info.strSfx[COL_SFX3-COL_SFX],MAX_PATH);
        pTabFile->GetString(i,COL_SFXTERRAIN,"",Info.strSfxTerrain,MAX_PATH);

		pTabFile->GetFloat(i, COL_SFX_RATE, 1.0f, &Info.fSfxPlayRate);//不填默认100%
		m_TerrainRepresentInfo[dwHash] = Info;
	}
    hRetCode = InitDis();
    KG_COM_PROCESS_ERROR(hRetCode);
    hRetCode = InitDefaultSfx();
    KG_COM_PROCESS_ERROR(hRetCode);
	hResult = S_OK;
Exit0:
	SAFE_RELEASE(pTabFile);
	return hResult;
}
예제 #17
0
	BOOL KColorSchemeMgr::Init()
	{
		KSmartTabFile TabFile;
		LPCSTR szFilePath = NULL;
		int nRowCount = 0;
		KColorScheme* pScheme = NULL;
		
		szFilePath = g_pUI->m_FilePathMgr.GetFilePath("SchemeElemColor");
        KGLOG_PROCESS_ERROR(szFilePath);

		TabFile = g_OpenTabFile(szFilePath);
		KGLOG_PROCESS_ERROR(TabFile);

		m_nSchemeCount = TabFile->GetHeight() - 1;
		KGLOG_PROCESS_ERROR(m_nSchemeCount > 0);

		pScheme = (KColorScheme*)realloc(m_pScheme, sizeof(KColorScheme) * m_nSchemeCount);
		KGLOG_PROCESS_ERROR(pScheme);

		m_pScheme = pScheme;

		for (int nIndex = 0; nIndex < (int)m_nSchemeCount; ++nIndex)
		{
			char szName[COLOR_NAME_MAX_LEN] = { 0 };
			int	nRed = 0;
			int nGreen = 0;
			int nBlue = 0;

			TabFile->GetString(nIndex + 2, "name", "", szName, _countof(szName));
			TabFile->GetInteger(nIndex + 2, "r", 0, &nRed);
			TabFile->GetInteger(nIndex + 2, "g", 0, &nGreen);
			TabFile->GetInteger(nIndex + 2, "b", 0, &nBlue);

			wcsncpy(m_pScheme[nIndex].wszSchemeName, ATL::CA2W(szName, GetCodePage()), COLOR_NAME_MAX_LEN - 1);
			m_pScheme[nIndex].wszSchemeName[COLOR_NAME_MAX_LEN - 1] = L'\0';

			m_pScheme[nIndex].dwColor = D3DCOLOR_XRGB((BYTE)nRed, (BYTE)nGreen, (BYTE)nBlue);
		}

		return TRUE;
Exit0:
		return FALSE;
	}
예제 #18
0
BOOL KLevelMoneyDropList::Init(char* pszFileName)
{
	BOOL        bResult     = false;
	BOOL        bRetCode    = FALSE;
	ITabFile*   piTabFile   = NULL;

	piTabFile = g_OpenTabFile(pszFileName);
	if (!piTabFile)
	{
		KGLogPrintf(KGLOG_ERR, "[KLevelDropList] Failed to open file \"%s\" !\n", pszFileName);
		goto Exit0;
	}

	m_dwSize = piTabFile->GetHeight() - 1;

	m_LevelMoneyDropList = new LEVEL_MONEY_DROP[m_dwSize];
	KGLOG_PROCESS_ERROR(m_LevelMoneyDropList);

	for (DWORD dwIndex = 0; dwIndex < m_dwSize; dwIndex++)
	{
		bRetCode = piTabFile->GetInteger(dwIndex + 2, DROP_LEVEL, 0, 
			(int*)&(m_LevelMoneyDropList[dwIndex].nLevel));
		KGLOG_PROCESS_ERROR(bRetCode);

		bRetCode = piTabFile->GetInteger(dwIndex + 2, DROP_CLASS_ID, 0,
			(int*)&(m_LevelMoneyDropList[dwIndex].nClassID));
		KGLOG_PROCESS_ERROR(bRetCode);

		bRetCode = piTabFile->GetInteger(dwIndex + 2, DROP_MIN_MONEY, 0, 
			(int*)&(m_LevelMoneyDropList[dwIndex].nMinMoney));
		KGLOG_PROCESS_ERROR(bRetCode);

		bRetCode = piTabFile->GetInteger(dwIndex + 2, DROP_MAX_MONEY, 0, 
			(int*)&(m_LevelMoneyDropList[dwIndex].nMaxMoney));
		KGLOG_PROCESS_ERROR(bRetCode);
	}


	bResult = true;
Exit0:
	KG_COM_RELEASE(piTabFile);
	return bResult;
}
예제 #19
0
KQuestInfo* KQuestInfoList::GetQuestInfo(DWORD dwQuestID)
{
    KQuestInfo* pResult     = NULL;
	BOOL        bRetCode    = false;
    ITabFile*   piTabFile   = NULL;
    int         nHeight     = 0;
    KQuestInfo  TempQuest;
    char        szFilePath[MAX_PATH];

	MAP_ID_2_QUEST_INFO::iterator it;
    std::pair<MAP_ID_2_QUEST_INFO::iterator, bool> InsRet;

    KGLOG_PROCESS_ERROR(dwQuestID > 0);

	it = m_mapID2QuestInfo.find(dwQuestID);

    if (it != m_mapID2QuestInfo.end())
    {
        pResult = &(it->second);
        goto Exit0;
    }
	
    snprintf(szFilePath, sizeof(szFilePath), "%s/%s", SETTING_DIR, QUEST_FILE_NAME);
    szFilePath[sizeof(szFilePath) - 1] = '\0';

    piTabFile = g_OpenTabFile(szFilePath);
    KGLOG_PROCESS_ERROR(piTabFile);

    nHeight = piTabFile->GetHeight();
    KGLOG_PROCESS_ERROR(nHeight > 1);

    bRetCode = LoadQuestInfoByID(piTabFile, dwQuestID, &TempQuest);
    KGLOG_PROCESS_ERROR(bRetCode);

    InsRet = m_mapID2QuestInfo.insert(std::make_pair(dwQuestID, TempQuest));
    KGLOG_PROCESS_ERROR(InsRet.second);

    pResult = &((InsRet.first)->second);
Exit0:
    KG_COM_RELEASE(piTabFile);
	return pResult;
}
예제 #20
0
BOOL KCampManager::Init()
{
    BOOL        bResult     = false;
    int         nRetCode    = 0;
    ITabFile*	piTabFile   = NULL;
    char		szFileName[MAX_PATH];
    char        szColumn[32];
    
    m_nScore    = 0;
    m_nLevel    = INIT_CAMP_LEVEL; // ³õʼµÈ¼¶

	snprintf(szFileName, sizeof(szFileName), "%s/%s", SETTING_DIR, "CampLevelParam.tab");
    szFileName[sizeof(szFileName) - 1] = '\0';

	piTabFile = g_OpenTabFile(szFileName);
	KGLOG_PROCESS_ERROR(piTabFile);
    
    for (int i = 0; i < CAMP_LEVEL_COUNT; i++)
    {
        snprintf(szColumn, sizeof(szColumn), "Level%d", i);
        szColumn[sizeof(szColumn) - 1] = '\0';

        nRetCode = piTabFile->GetInteger("Score", szColumn, 0, &m_nLevelScore[i]);
        KGLOG_PROCESS_ERROR(nRetCode == 1);
    }

    for (int i = 0; i < CAMP_LEVEL_COUNT; ++i)
    {
        KGLOG_PROCESS_ERROR(m_nLevelScore[i] >= 0);
    }
    
    memset(m_nActivePlayerCount, 0, sizeof(m_nActivePlayerCount));

    m_bUpdate = false;

    bResult = true;
Exit0:
    KG_COM_RELEASE(piTabFile);
    return bResult;
}
예제 #21
0
파일: KTrackList.cpp 프로젝트: 1suming/pap2
BOOL KTrackList::LoadTrack(DWORD dwID, KTRACK* pTrack)
{
    BOOL        bResult     = false;
    int         nRetCode    = 0;
    ITabFile*   piTabFile   = NULL;
    int         nTabHeight  = 0;
    char        szFileName[MAX_PATH];

    snprintf(szFileName, sizeof(szFileName), "%s/%s/track%u.tab", SETTING_DIR, TRACK_DIR, dwID);
    szFileName[sizeof(szFileName) - 1] = '\0';

    piTabFile = g_OpenTabFile(szFileName);
    KGLOG_PROCESS_ERROR(piTabFile);

    nTabHeight = piTabFile->GetHeight();
    KGLOG_PROCESS_ERROR(nTabHeight >= 3);

    for (int nLine = 2; nLine <= nTabHeight; nLine++)
    {
        KCRITICAL_POINT point;
        
        nRetCode = piTabFile->GetInteger(nLine, COL_X, 0, &point.nX);
        KGLOG_PROCESS_ERROR(nRetCode == 1);

        nRetCode = piTabFile->GetInteger(nLine, COL_Y, 0, &point.nY);
        KGLOG_PROCESS_ERROR(nRetCode == 1);

        nRetCode = piTabFile->GetInteger(nLine, COL_Z, 0, &point.nZ);
        KGLOG_PROCESS_ERROR(nRetCode == 1);

        point.nFrame = 0; // 稍后计算

        pTrack->push_back(point);
    }

    bResult = true;
Exit0:
    KG_COM_RELEASE(piTabFile);
    return bResult;
}
예제 #22
0
BOOL KDoodadMgr::LoadDoodadTemplate()
{
	BOOL bResult = FALSE;

	ITabFile* pFile = g_OpenTabFile(KDF_DOODAD_LIST);
	LOG_PROCESS_ERROR(pFile);

	// 第一行行是中英文字段头描述
	for (INT n = 2; n <= pFile->GetHeight(); ++n)
	{
		INT nTmp = 0;
		KDOODAD_TEMPLATE sDoodadInfo;
		CHAR szBuf[MAX_NAME_LEN] = "";

		bResult = pFile->GetInteger(n, "TemplateId", KD_BAD_ID, &nTmp);
		sDoodadInfo.dwTemplateId = (DWORD)nTmp;

		bResult = pFile->GetString(n, "DisplayName", "", szBuf, countof(szBuf));
		sDoodadInfo.strDisplayName = szBuf;

		bResult = pFile->GetString(n, "Class", "", szBuf, countof(szBuf));
		sDoodadInfo.strClassName = szBuf;

		bResult = pFile->GetInteger(n, "Visible", KD_BAD_ID, &nTmp);
		sDoodadInfo.nVisibleMode = (DWORD)nTmp;

		bResult = pFile->GetInteger(n, "RepresentId", KD_BAD_ID, &nTmp);
		sDoodadInfo.dwRepresentId = (DWORD)nTmp;

		bResult = pFile->GetInteger(n, "ActiveTime", 0, &nTmp);
		sDoodadInfo.dwActiveTime = (DWORD)nTmp;

		QCONFIRM_RET_FALSE(m_mapDoodadTemplate.insert(std::make_pair(sDoodadInfo.dwTemplateId, sDoodadInfo)).second);
	}

	bResult = TRUE;
EXIT0:
	SAFE_RELEASE(pFile);
	return bResult;
}
예제 #23
0
BOOL KFightFlagList::Init()
{
	char		szFile[MAX_PATH];
	ITabFile*	pTabFile;
	BOOL		bResult = FALSE;
	BOOL		bRetCode = FALSE;
	int			nId = 0;

	sprintf(szFile, "%s/%s", SETTING_DIR, RELATION_FORCE_FILE_NAME);
	pTabFile = g_OpenTabFile(szFile);
	KGLOG_PROCESS_ERROR(pTabFile);

	m_nSize = pTabFile->GetHeight() - 1;
	KGLOG_PROCESS_ERROR(m_nSize > 0);

	m_ForceDefault = new FORCE_DEFAULT[m_nSize];
	KGLOG_PROCESS_ERROR(m_ForceDefault);

	for (int i = 0; i < m_nSize; i++)
	{
		bRetCode = pTabFile->GetInteger(i + 2, RELATION_ID, 0, &nId);
		KGLOG_PROCESS_ERROR(bRetCode && nId == i);

		bRetCode = pTabFile->GetInteger(i + 2, DEFAULT_FLAG, 0, &m_ForceDefault[i].bDefaultFlag);
		KGLOG_PROCESS_ERROR(bRetCode);

		bRetCode = pTabFile->GetInteger(i + 2, FLAG_IS_LOCKED, 0, &m_ForceDefault[i].bLockedFlag);
		KGLOG_PROCESS_ERROR(bRetCode);

		bRetCode = pTabFile->GetInteger(i + 2, DEFAULT_REPUTE, 0, &m_ForceDefault[i].nRepute);
		KGLOG_PROCESS_ERROR(bRetCode);
	}
	
	bResult = TRUE;
Exit0:
	return bResult;
}
예제 #24
0
BOOL KCustomEquipInfoList::Load(const char cszFileName[])
{
	BOOL                    bResult         = false;
	BOOL                    bRetCode        = false;
	ITabFile*               piTabFile           = NULL;
    int                     nHeight         = 0;
	KCustomEquipInfo	    DefaultInfo;
	std::pair<KCUSTOM_EQUIP_INFO_LIST::iterator, bool> InsRet;

	piTabFile = g_OpenTabFile(cszFileName);
	KG_PROCESS_ERROR(piTabFile);

	ZeroMemory(&DefaultInfo, sizeof(KCustomEquipInfo));

	nHeight = piTabFile->GetHeight();
	KGLOG_PROCESS_ERROR(nHeight > 1);
    
    bRetCode = LoadLine(piTabFile, 2, &DefaultInfo, DefaultInfo);
    KGLOG_PROCESS_ERROR(bRetCode);

	for (int nIndex = 3; nIndex <= nHeight; nIndex++)
	{
        KCustomEquipInfo    EquipInfo;

	    bRetCode = LoadLine(piTabFile, nIndex, &EquipInfo, DefaultInfo);
        KGLOG_PROCESS_ERROR(bRetCode);
	
		InsRet = m_EquipInfoList.insert(std::make_pair(EquipInfo.dwID, EquipInfo));
		KGLOG_PROCESS_ERROR(InsRet.second);
	}

	bResult = true;
Exit0:
	KG_COM_RELEASE(piTabFile);
	return bResult;
}
예제 #25
0
BOOL KAwardSetting::ReadNumericalAwardConfigs()
{
	CHAR szStageAwardName[_MAX_PATH];
	CHAR szLevelAwardName[_MAX_PATH];
	ITabFile* pStageAwardFile = NULL;
	ITabFile* pLevelAwardFile = NULL;
	QString szFileTemp;

	ITabFile* pTabFile = g_OpenTabFile(NUMERICAL_TABLE_FILE);
	QCONFIRM_RET_FALSE(pTabFile);

	for (INT i = 1; i < pTabFile->GetHeight(); i++)
	{
		QModuleNumericalAward* pModuleAward = new QModuleNumericalAward();
		QCONFIRM_RET_FALSE(pModuleAward);

		pTabFile->GetString(i + 1, "ModuleName", "", pModuleAward->szModuleName, MAX_NAME_LEN);
		pTabFile->GetString(i + 1, "StageAwardName", "", szStageAwardName, _MAX_PATH);
		pTabFile->GetString(i + 1, "LevelAwardName", "", szLevelAwardName, _MAX_PATH);

		szFileTemp = AWARD_TABLE_FILE_FOLDER;
		szFileTemp = szFileTemp + szStageAwardName;
		pStageAwardFile = g_OpenTabFile(szFileTemp.CStr());
		QCONFIRM_RET_FALSE(pStageAwardFile);

		for (INT j = 2; j < pStageAwardFile->GetHeight(); j++)
		{
			QNumericalStageAward* pNumericalStageAward = new QNumericalStageAward();
			QCONFIRM_RET_FALSE(pNumericalStageAward);

			pStageAwardFile->GetInteger(j + 1, "StageID", 0, &pNumericalStageAward->nStageId);
			pStageAwardFile->GetInteger(j + 1, "MinLineNum", 0, &pNumericalStageAward->nStartIndex);
			pStageAwardFile->GetInteger(j + 1, "MaxLineNum", 0, &pNumericalStageAward->nEndIndex);

			// 减去开头的2行,从0开始
			pNumericalStageAward->nStartIndex -= 2;
			pNumericalStageAward->nEndIndex -= 2;

			pModuleAward->mapNumericalStageAwards[pNumericalStageAward->nStageId] = pNumericalStageAward;
		}

		szFileTemp = AWARD_TABLE_FILE_FOLDER;
		szFileTemp = szFileTemp + szLevelAwardName;
		pLevelAwardFile = g_OpenTabFile(szFileTemp.CStr());
		QCONFIRM_RET_FALSE(pLevelAwardFile);

		for (INT j = 2; j < pLevelAwardFile->GetHeight(); j++)
		{
			QNumericalAward* pNumericalAward = new QNumericalAward();
			QCONFIRM_RET_FALSE(pNumericalAward);
			pLevelAwardFile->GetInteger(j + 1, "Level", 0, &pNumericalAward->nLevel);
			pLevelAwardFile->GetInteger(j + 1, "Life", 0, &pNumericalAward->nLife);
			pLevelAwardFile->GetInteger(j + 1, "Ability", 0, &pNumericalAward->nAbility);
			pLevelAwardFile->GetInteger(j + 1, "Attack", 0, &pNumericalAward->nAttack);
			pLevelAwardFile->GetInteger(j + 1, "Defense", 0, &pNumericalAward->nDefense);
			pLevelAwardFile->GetInteger(j + 1, "Hit", 0, &pNumericalAward->nHit);
			pLevelAwardFile->GetInteger(j + 1, "Dodge", 0, &pNumericalAward->nDodge);
			pLevelAwardFile->GetInteger(j + 1, "Crit", 0, &pNumericalAward->nCrit);
			pLevelAwardFile->GetInteger(j + 1, "Resist", 0, &pNumericalAward->nResist);
			pLevelAwardFile->GetInteger(j + 1, "Cost", 0, &pNumericalAward->nCost);

			pModuleAward->vecNumericalAwards.push_back(pNumericalAward);
			pModuleAward->vecNumericalIDs.push_back(pNumericalAward->nLevel);
		}

		m_vecModuleNumericalAwards.push_back(pModuleAward);
	}

	return TRUE;
}
예제 #26
0
BOOL KAwardSetting::ReadAssetAwardConfigs()
{
	CHAR szLevelAwardName[_MAX_PATH];
	ITabFile* pAssetAwardFile = NULL;
	QString szFileTemp;

	ITabFile* pTabFile = g_OpenTabFile(ASSET_AWARD_FILE);
	QCONFIRM_RET_FALSE(pTabFile);

	for (INT i = 1; i < pTabFile->GetHeight(); i++)
	{
		QModuleAssetAward* pModuleAssetAward = new QModuleAssetAward();
		QCONFIRM_RET_FALSE(pModuleAssetAward);

		pTabFile->GetString(i + 1, "ModuleName", "", pModuleAssetAward->szModuleName, MAX_NAME_LEN);
		pTabFile->GetString(i + 1, "LevelAwardName", "", szLevelAwardName, _MAX_PATH);

		szFileTemp = ASSET_AWARD_FILE_FOLDER;
		szFileTemp = szFileTemp + szLevelAwardName;

		pAssetAwardFile = g_OpenTabFile(szFileTemp.CStr());
		assert(pAssetAwardFile);
		QCONFIRM_RET_FALSE(pAssetAwardFile);

		for (INT j = 2; j < pAssetAwardFile->GetHeight(); j++)
		{
			QAssetAward* pAssetAward = new QAssetAward();
			QCONFIRM_RET_FALSE(pAssetAward);

			pAssetAwardFile->GetInteger(j + 1, "Level", 0, &pAssetAward->nLevel);

			pAssetAwardFile->GetInteger(j + 1, "IsSave", 0, &pAssetAward->nSave);
			pAssetAwardFile->GetInteger(j + 1, "OverlayDay", 0, &pAssetAward->nOverlayDay);
			pAssetAwardFile->GetInteger(j + 1, "AutoGive", 0, &pAssetAward->nAutoGive);
			pAssetAwardFile->GetInteger(j + 1, "IsSync", 0, &pAssetAward->nSync);

			pAssetAwardFile->GetInteger(j + 1, "FightingSpirit", 0, &pAssetAward->nFightingSpirit);
			pAssetAwardFile->GetInteger(j + 1, "Energy", 0, &pAssetAward->nEnergy);
			pAssetAwardFile->GetInteger(j + 1, "Prestige", 0, &pAssetAward->nPrestige);
			pAssetAwardFile->GetInteger(j + 1, "Silver", 0, &pAssetAward->nSilver);
			pAssetAwardFile->GetInteger(j + 1, "Exp", 0, &pAssetAward->nExpAwardId);

			ZeroMemory(&pAssetAward->arrAwardItem, sizeof(pAssetAward->arrAwardItem));

			for(INT k = 0; k < ASSET_AWARD_MAX_ITEM_NUM; ++k)
			{
				CHAR szItem[20];
				CHAR szTabItem[10];
				CHAR szTabItemAmountMin[20];
				CHAR szTabItemAmountMax[20];
				CHAR szTabItemRate[15];
				CHAR szTabItemTimeOut[20];

				snprintf(szTabItem, sizeof(szTabItem), "Item%d", k + 1);
				snprintf(szTabItemAmountMin, sizeof(szTabItemAmountMin), "Item%dAmountMin", k + 1);
				snprintf(szTabItemAmountMax, sizeof(szTabItemAmountMax), "Item%dAmountMax", k + 1);
				snprintf(szTabItemRate, sizeof(szTabItemRate), "Item%dRate", k + 1);
				snprintf(szTabItemTimeOut, sizeof(szTabItemTimeOut), "Item%dTimeOut", k + 1);

				pAssetAwardFile->GetString(j + 1, szTabItem, "", szItem, 20);
				std::string strItem(szItem);

				if(!strItem.size())
				{
					pAssetAward->nItemNum = k;
					break;
				}

				{
					INT nIdx = 0;
					std::basic_string<char>::size_type iBegin = 0, iEnd = 0;
					while((iEnd = strItem.find(',', iBegin)) != std::string::npos)
					{
						switch(nIdx++)
						{
						case 0:
							pAssetAward->arrAwardItem[k].sIndex.nGenre = atoi((strItem.substr(iBegin, iEnd - iBegin)).c_str());
							break;
						case 1:
							pAssetAward->arrAwardItem[k].sIndex.nDetailType = atoi((strItem.substr(iBegin, iEnd - iBegin)).c_str());
							break;
						case 2:
							pAssetAward->arrAwardItem[k].sIndex.nParticular = atoi((strItem.substr(iBegin, iEnd - iBegin)).c_str());
							break;
						default:
							ASSERT(FALSE);
						}
						iBegin = iEnd + 1;
					}
					if(iBegin < strItem.size())
					{
						pAssetAward->arrAwardItem[k].sIndex.nLevel = atoi((strItem.substr(iBegin, strItem.size() - iBegin)).c_str());
					}
				}

				pAssetAwardFile->GetInteger(j + 1, szTabItemAmountMin, 0, &pAssetAward->arrAwardItem[k].nAmountMin);
				pAssetAwardFile->GetInteger(j + 1, szTabItemAmountMax, 0, &pAssetAward->arrAwardItem[k].nAmountMax);
				pAssetAwardFile->GetInteger(j + 1, szTabItemRate, 0, &pAssetAward->arrAwardItem[k].nRate);
				pAssetAwardFile->GetInteger(j + 1, szTabItemTimeOut, 0, &pAssetAward->arrAwardItem[k].nTimeOut);

			}
			pModuleAssetAward->mapAssetAwards[pAssetAward->nLevel] = pAssetAward;
		}

		m_vecModuleAssetAwards.push_back(pModuleAssetAward);
	}

	return TRUE;
}
예제 #27
0
BOOL KActiveSettings::LoadData()
{
	BOOL 		bResult 	= false;
	BOOL 		bRetCode 	= false;
	int  		nHeight 	= 0;
    int         nEvent      = 0;
	DWORD       dwID        = ERROR_ID;
    DWORD       dwNextID    = 1;
    ITabFile* 	piTabFile 	= NULL;
    char        szEvent[64] = {0};
    KActiveSettingsItem* pActiveInfo = NULL;
    KVEC_ACTIVE_UPDATOR* pvecActive = NULL;
    KMAP_ACTIVE_UPDATOR::iterator it;

	piTabFile = g_OpenTabFile(SETTING_DIR"/ActivePlayer.tab");
	KGLOG_PROCESS_ERROR(piTabFile);
    
	nHeight = piTabFile->GetHeight();    
    m_vecActive.resize(nHeight - 1);

    for(int nRow = 2; nRow <= nHeight; ++nRow)
	{
        bRetCode = piTabFile->GetInteger(nRow, "ID", 0, (int*)&dwID);
        KGLOG_PROCESS_ERROR(bRetCode > 0);

        KGLOG_PROCESS_ERROR(dwID == dwNextID);
        ++dwNextID;

        pActiveInfo = &m_vecActive[dwID - 1];
        pActiveInfo->dwID = dwID;

        szEvent[0] = '\0';
        bRetCode = piTabFile->GetString(nRow, "Event", "peInvalid", szEvent, sizeof(szEvent));
        KGLOG_PROCESS_ERROR(bRetCode);

        bRetCode = ENUM_STR2INT(PLAYER_EVENT_TYPE, szEvent, pActiveInfo->nEvent);
        KGLOG_PROCESS_ERROR(bRetCode);

        bRetCode = piTabFile->GetInteger(nRow, "FinishValue", 0, (int*)&(pActiveInfo->nFininshValue));
        KGLOG_PROCESS_ERROR(bRetCode > 0);

        bRetCode = piTabFile->GetInteger(nRow, "UnLimitCount", 0, (BOOL*)&(pActiveInfo->bUnLimit));
        KGLOG_PROCESS_ERROR(bRetCode > 0);

        bRetCode = piTabFile->GetInteger(nRow, "ActivePoint", 0, (int*)&(pActiveInfo->nAwardActive));
        KGLOG_PROCESS_ERROR(bRetCode > 0);

        it = m_mapValueUpdator.find(pActiveInfo->nEvent);
        if (it == m_mapValueUpdator.end())
        {
            pvecActive = KMEMORY_NEW(KVEC_ACTIVE_UPDATOR);
            m_mapValueUpdator[pActiveInfo->nEvent] = pvecActive;
        }
        else
        {
            pvecActive = it->second;
        }

        pvecActive->push_back(dwID);
        pvecActive = NULL;
	}

Exit1:
	bResult = true;
Exit0:
	KG_COM_RELEASE(piTabFile);
	return bResult;
}
예제 #28
0
BOOL KAwardMgr::LoadOneAward(const char cszAwardFile[], KAwardTable* pAwardTable)
{
    BOOL        bResult         = false;
    BOOL        bRetCode        = false;
    ITabFile*	piTabFile       = NULL;
    DWORD       dwAwardItemID   = 0;
    char        szFilePath[MAX_PATH];
    std::pair<KAWARD_ITEM_MAP::iterator, bool> InsRet;
    KAWARD_ITEM* pAwardItem = NULL;
    char        szValue[64];

    assert(cszAwardFile);
    assert(pAwardTable);

    snprintf(szFilePath, sizeof(szFilePath), "%s/%s/%s", SETTING_DIR, "award", cszAwardFile);
    szFilePath[sizeof(szFilePath) - 1] = '\0';

    strncpy(pAwardTable->m_szAwardTableName, szFilePath, sizeof(pAwardTable->m_szAwardTableName));
    pAwardTable->m_szAwardTableName[countof(pAwardTable->m_szAwardTableName) - 1] = '\0';

    piTabFile = g_OpenTabFile(szFilePath);
    KGLOG_PROCESS_ERROR(piTabFile);

    for (int nRowIndex = 2; nRowIndex <= piTabFile->GetHeight(); nRowIndex++)
    {
        bRetCode = piTabFile->GetInteger(nRowIndex, "ID", 0, (int*)&dwAwardItemID);
        KGLOG_PROCESS_ERROR(bRetCode);
        KGLOG_PROCESS_ERROR(dwAwardItemID > 0);

        InsRet = pAwardTable->m_mapAwardItem.insert(std::make_pair(dwAwardItemID, KAWARD_ITEM()));
        KGLOG_PROCESS_ERROR(InsRet.second);

        pAwardItem = &InsRet.first->second;
        pAwardItem->dwID = dwAwardItemID;

        bRetCode = piTabFile->GetInteger(nRowIndex, "Tabtype", 0, (int*)&pAwardItem->dwTabType);
        KGLOG_PROCESS_ERROR(bRetCode);

        bRetCode = piTabFile->GetInteger(nRowIndex, "TabIndex", 0, (int*)&pAwardItem->dwIndex);
        KGLOG_PROCESS_ERROR(bRetCode);

        bRetCode = piTabFile->GetInteger(nRowIndex, "Stacknum", 0, (int*)&pAwardItem->nStackNum);
        KGLOG_PROCESS_ERROR(bRetCode);

        bRetCode = piTabFile->GetInteger(nRowIndex, "MoneyType", emotMoney, (int*)&pAwardItem->eMoneyType);
        KGLOG_PROCESS_ERROR(bRetCode);
        KGLOG_PROCESS_ERROR(pAwardItem->eMoneyType == emotMoney || pAwardItem->eMoneyType == emotMenterPoint);
 
        bRetCode = piTabFile->GetInteger(nRowIndex, "Money", 0, (int*)&pAwardItem->nMoney);
        KGLOG_PROCESS_ERROR(bRetCode);

        bRetCode = piTabFile->GetInteger(nRowIndex, "BuffID", 0, (int*)&pAwardItem->dwBuffID);
        KGLOG_PROCESS_ERROR(bRetCode);

        bRetCode = piTabFile->GetInteger(nRowIndex, "AwardItemRate", 0, (int*)&pAwardItem->nAwardItemRate);
        KGLOG_PROCESS_ERROR(bRetCode);

        pAwardItem->nQualityLevel = -1;
        bRetCode = piTabFile->GetString(nRowIndex, "QualityLevel", "", szValue, sizeof(szValue));
        KGLOG_PROCESS_ERROR(bRetCode); 
        szValue[countof(szValue) - 1] = '\0';
        if (bRetCode > 0)
        {
            bRetCode = ENUM_STR2INT(ENUM_EQUIP_QUALITY, szValue, pAwardItem->nQualityLevel);
            KGLOG_PROCESS_ERROR(bRetCode);
        }

        bRetCode = piTabFile->GetInteger(nRowIndex, "MinValuePoint", 0, &pAwardItem->nMinValuePoint);
        KGLOG_PROCESS_ERROR(bRetCode);
        
        bRetCode = piTabFile->GetInteger(nRowIndex, "MaxValuePoint", 0, &pAwardItem->nMaxValuePoint);
        KGLOG_PROCESS_ERROR(bRetCode);
        
        KGLOG_PROCESS_ERROR(pAwardItem->nMaxValuePoint >= pAwardItem->nMinValuePoint && pAwardItem->nMinValuePoint >= 0);
        
        bRetCode = piTabFile->GetInteger(nRowIndex, "IsBroadcast", 0, &pAwardItem->bIsBroadcast);
        KGLOG_PROCESS_ERROR(bRetCode);
    }

    pAwardTable->RatePreProcess();

    bResult = true;
Exit0:
    KG_COM_RELEASE(piTabFile);
    return bResult;
}
예제 #29
0
BOOL KMapListFile::Init(void)
{
    BOOL        bResult     = false;
	BOOL        bRetCode    = false;
	ITabFile*	piTabFile   = NULL;
	char        szFilePath[MAX_PATH];

	snprintf(szFilePath, sizeof(szFilePath), "%s/%s", SETTING_DIR, MAP_LIST_FILE_NAME);
    szFilePath[sizeof(szFilePath) - 1] = '\0';

	piTabFile = g_OpenTabFile(szFilePath);
	KGLOG_PROCESS_ERROR(piTabFile);

	for (int nRowIndex = 2; nRowIndex <= piTabFile->GetHeight(); nRowIndex++)
	{
        KMapParams  MapParam;
        memset(&MapParam, 0, sizeof(MapParam));

		bRetCode = piTabFile->GetInteger(nRowIndex, "ID", 0, (int*)&MapParam.dwMapID);
		KGLOG_PROCESS_ERROR(bRetCode && MapParam.dwMapID <= MAX_MAP_ID);

		bRetCode = piTabFile->GetString(nRowIndex, "Name", "", MapParam.szMapName, sizeof(MapParam.szMapName));
		KGLOG_PROCESS_ERROR(bRetCode && MapParam.szMapName[0] != '\0');

        bRetCode = piTabFile->GetInteger(nRowIndex, "Type", 1, &MapParam.nType);
        KGLOG_PROCESS_ERROR(bRetCode);

        bRetCode = piTabFile->GetInteger(nRowIndex, "AllScenePlayerInFight", 0, &MapParam.bAllScenePlayerInFight);
        KGLOG_PROCESS_ERROR(bRetCode);

		bRetCode = piTabFile->GetInteger(nRowIndex, "Broadcast", 1, &MapParam.nBroadcast);
		KGLOG_PROCESS_ERROR(bRetCode);

        bRetCode = piTabFile->GetInteger(nRowIndex, "bCanPK", 1, &MapParam.bCanPK);
		KGLOG_PROCESS_ERROR(bRetCode);

        bRetCode = piTabFile->GetInteger(nRowIndex, "CampType", emctAllProtect, &MapParam.nCampType);
        KGLOG_PROCESS_ERROR(bRetCode);
        KGLOG_PROCESS_ERROR(MapParam.nCampType > emctInvalid && MapParam.nCampType < emctTotal);

		bRetCode = piTabFile->GetString(nRowIndex, "MapDrop", "", MapParam.szDropName, sizeof(MapParam.szDropName));
		KGLOG_PROCESS_ERROR(bRetCode);

		bRetCode = piTabFile->GetString(nRowIndex, "ResourcePath", "", MapParam.szResourceFilePath, sizeof(MapParam.szResourceFilePath));
		KGLOG_PROCESS_ERROR(bRetCode);

        bRetCode = piTabFile->GetInteger(nRowIndex, "ReviveInSitu", 0, (int*)&MapParam.bReviveInSitu);
        KGLOG_PROCESS_ERROR(bRetCode);

        bRetCode = piTabFile->GetInteger(nRowIndex, "MaxPlayerCount", 0, (int*)&MapParam.nMaxPlayerCount);
        KGLOG_PROCESS_ERROR(bRetCode);

        bRetCode = piTabFile->GetInteger(nRowIndex, "BanSkillMask", 0, (int*)&MapParam.dwBanSkillMask);
        KGLOG_PROCESS_ERROR(bRetCode);

        bRetCode = piTabFile->GetInteger(nRowIndex, "BattleRelationMask", 0, (int*)&MapParam.dwBattleRelationMask);
        KGLOG_PROCESS_ERROR(bRetCode);

        bRetCode = piTabFile->GetInteger(nRowIndex, "DoNotGoThroughRoof", 0, (int*)&MapParam.bDoNotGoThroughRoof);
        KGLOG_PROCESS_ERROR(bRetCode);
        
        bRetCode = piTabFile->GetInteger(nRowIndex, "RefreshCycle", 0, (int*)&MapParam.nRefreshCycle);
        KGLOG_PROCESS_ERROR(bRetCode);

        bRetCode = piTabFile->GetInteger(nRowIndex, "QuestCountAchID", -1, &MapParam.nQuestCountAchID);
        KGLOG_PROCESS_ERROR(bRetCode);
        
        bRetCode = piTabFile->GetInteger(nRowIndex, "LimitTimes", 0, &MapParam.nLimitTimes);
        KGLOG_PROCESS_ERROR(bRetCode);
        
        MapParam.nRefreshCycle *= 60;

        m_MapParamTable[MapParam.dwMapID] = MapParam;
	}

    bResult = true;
Exit0:
	KG_COM_RELEASE(piTabFile);
	return bResult;
}
예제 #30
0
BOOL KPlayerValueInfoList::LoadData()
{
	BOOL 		bResult 	= false;
	BOOL 		bRetCode 	= false;
	int  		nHeight 	= 0;
	ITabFile* 	piTabFile 	= NULL;
    DWORD       dwNextID    = 1;
    size_t      uBitCount       = 0;
    DWORD       dwID        = 0;
    size_t      uOffset     = 0;
    char        szTemp[_NAME_LEN];
    KPlayerValueInfo* pPlayerValueInfo = NULL;

	piTabFile = g_OpenTabFile(SETTING_DIR"/PlayerValue.tab");
	KGLOG_PROCESS_ERROR(piTabFile);

	nHeight = piTabFile->GetHeight();
    KGLOG_PROCESS_ERROR(nHeight > 0);

    m_vecPlayerValueInfo.resize(nHeight - 1);
    m_vecDailyReset.reserve(nHeight - 1);
    m_vecDailyReset.reserve(nHeight - 1);
	for(int nRow = 2; nRow <= nHeight; ++nRow)
	{
		bRetCode = piTabFile->GetInteger(nRow, "ID", 0, (int*)&dwID);
        KGLOG_PROCESS_ERROR(bRetCode > 0);

        KGLOG_PROCESS_ERROR(dwID == dwNextID);
        ++dwNextID;

        pPlayerValueInfo = &m_vecPlayerValueInfo[dwID - 1];
        memset(pPlayerValueInfo, 0, sizeof(KPlayerValueInfo));
        pPlayerValueInfo->dwID      = dwID;
        pPlayerValueInfo->uOffset   = uOffset;

        bRetCode = piTabFile->GetString(nRow, "Type", "", szTemp, sizeof(szTemp));
        KGLOG_PROCESS_ERROR(bRetCode > 0);
        szTemp[countof(szTemp) - 1] = '\0';
        bRetCode = ENUM_STR2INT(PLAYER_VALUE_TYPE, szTemp, pPlayerValueInfo->nType);
        KGLOG_PROCESS_ERROR(bRetCode);
        KGLOG_PROCESS_ERROR(pPlayerValueInfo->nType == KPLAYER_VALUE_TYPE_BOOLEAN || uOffset % UINT32_BIT_COUNT == 0 );

        bRetCode = piTabFile->GetInteger(nRow, "IsInUse", 0, &pPlayerValueInfo->bIsInUse);
        KGLOG_PROCESS_ERROR(bRetCode > 0);

        bRetCode = piTabFile->GetString(nRow, "SetType", "", szTemp, sizeof(szTemp));
        KGLOG_PROCESS_ERROR(bRetCode > 0);
        bRetCode = ENUM_STR2INT(KPLAYERVALUE_SET_TYPE, szTemp, pPlayerValueInfo->nSetType);
        KGLOG_PROCESS_ERROR(bRetCode);

        bRetCode = piTabFile->GetString(nRow, "ResetType", "", szTemp, sizeof(szTemp));
        KGLOG_PROCESS_ERROR(bRetCode > 0);
        bRetCode = ENUM_STR2INT(KRESET_TYPE, szTemp, pPlayerValueInfo->nResetType);
        KGLOG_PROCESS_ERROR(bRetCode);

        bRetCode = GetBitCountOfType(pPlayerValueInfo->nType, uBitCount);
        KGLOG_PROCESS_ERROR(bRetCode);

        bRetCode = piTabFile->GetString(nRow, "ActivityGroup", "KACTIVITY_GROUP_INVALID", szTemp, sizeof(szTemp));
        KGLOG_PROCESS_ERROR(bRetCode);
        bRetCode = ENUM_STR2INT(KACTIVITY_GROUP, szTemp, pPlayerValueInfo->nActivityGroup);
        KGLOG_PROCESS_ERROR(bRetCode);

        uOffset += uBitCount;

        switch(pPlayerValueInfo->nResetType)
        {
        case KRESET_TYPE_DAILY:
            m_vecDailyReset.push_back(pPlayerValueInfo);
            break;
        case KRESET_TYPE_WEEKLY:
            m_vecWeeklyReset.push_back(pPlayerValueInfo);
            break;
        case KRESET_TYPE_MONTHLY:
            m_vecMonthlyReset.push_back(pPlayerValueInfo);
            break;
        default:
            break;
        }

        m_PlayerValueGroup[pPlayerValueInfo->nActivityGroup].push_back(pPlayerValueInfo);
	}

    m_uTotalBytes = uOffset / 8 + 1;
    KGLOG_PROCESS_ERROR(m_uTotalBytes <= MAX_PLAYERVALUE_BYTES);

	bResult = true;
Exit0:
    if (!bResult)
    {
        KGLogPrintf(KGLOG_DEBUG, "ID:%u", dwID);
    }
	KG_COM_RELEASE(piTabFile);
	return bResult;
}