Example #1
0
BOOL KLogClient::Init()
{
    BOOL               bResult          = false;
    BOOL               bRetCode         = false;
    IIniFile*	       piIniFile        = NULL;

    piIniFile = g_OpenIniFile(GS_SETTINGS_FILENAME);
    KGLOG_PROCESS_ERROR(piIniFile);

    bRetCode = piIniFile->GetString(LOG_SERVER_SECTION_GAMESERVER, "IP", "127.0.0.1", m_szLogServerAddr, sizeof(m_szLogServerAddr));
    KGLOG_PROCESS_ERROR(bRetCode);

    bRetCode = piIniFile->GetInteger(LOG_SERVER_SECTION_GAMESERVER, "Port", 5004, &m_nRelayPort);
    KGLOG_PROCESS_ERROR(bRetCode);

    bRetCode = piIniFile->GetInteger(LOG_SERVER_SECTION_GAMESERVER, "PingCycle", 20, &m_nPingCycle);
    KGLOG_PROCESS_ERROR(bRetCode);

    m_bRunFlag = true;

    bRetCode = m_WorkThread.Create(WorkThreadFunction, this);
    KGLOG_PROCESS_ERROR(bRetCode);

    bResult = true;
Exit0:
    if (!bResult)
    {
        KG_COM_RELEASE(m_piSocketStream);
    }

    KG_COM_RELEASE(piIniFile);
    return bResult;
}
Example #2
0
int KGSFXModelViewPage::FillTreeFromFileMap()
{
	int nResult  = false;
	int nRetCode = false;

	char szSection[32] = TEXT("");
	char szKeyName[32] = TEXT("");
	char szKeyData[32] = TEXT("");
	char szKeyType[32] = TEXT("");

	TCHAR szMapFileName[MAX_PATH];
	sprintf(szMapFileName, "%s%s", g_szDefWorkDirectory, TEXT("\\sfx_editor_file_map.ini"));

	m_tree.DeleteAllItems();
	IIniFile* pMapFile = NULL;
	pMapFile = g_OpenIniFile(szMapFileName);

	KG_PROCESS_ERROR(pMapFile);

	while (pMapFile->GetNextKey(TEXT("Main"), szKeyName, szKeyName))
	{
		pMapFile->GetString(TEXT("Main"), szKeyName, TEXT(""), szKeyData, sizeof(szKeyData));
		pMapFile->GetString(TEXT("Type"), szKeyData, TEXT(""), szKeyType, sizeof(szKeyType));
		_FillTreeFromFileMap(&m_tree, NULL, pMapFile, szKeyData, GetImageIndex(szKeyType));
	}

	nResult = true;
Exit0:
	SAFE_RELEASE(pMapFile);
	return nResult;
}
BOOL KAIManager::Init()
{
    BOOL        bResult     = false;
    BOOL        bRetCode    = false;
    IIniFile*   piIniFile   = NULL;

    RegisterActionFunctions();

    KGLogPrintf(KGLOG_INFO, "[AI] loading ... ...");

    bRetCode = LoadAITabFile();
    KGLOG_PROCESS_ERROR(bRetCode);

    KGLogPrintf(KGLOG_INFO, "[AI] %u AI loaded !", m_AITable.size());

    memset(m_ActionRunTimeStatisticsArray, 0, sizeof(m_ActionRunTimeStatisticsArray));
    m_NpcAIRunTimeStatisticsMap.clear();

    m_bLogAIRuntimeStat = 0;

    piIniFile = g_OpenIniFile(GS_SETTINGS_FILENAME);
    KGLOG_PROCESS_ERROR(piIniFile);

    bRetCode = piIniFile->GetInteger("AI", "LogAIRuntimeStat", 0, &m_bLogAIRuntimeStat);
    //KGLOG_PROCESS_ERROR(bRetCode);

    bResult = true;
Exit0:
    KG_COM_RELEASE(piIniFile);
    return bResult;
}
Example #4
0
void KUiWndFrameTabControl::SaveData()
{
    KG_PROCESS_ERROR(m_hListWnd);
    KG_PROCESS_ERROR(m_szName[0]);
    IIniFile *pIni = g_Ui.GetIni();
    KG_PROCESS_ERROR(pIni);

    int nMaxNum = 0;
    int i = 0;
    char szKey[128] = "";
    char szKeyValue[128] = "";
    pIni->GetInteger(m_szName, "ItemCount", 0, &nMaxNum);
    for (i = 0; i < nMaxNum; i++) 
    {
        sprintf(szKey, "Item_%d", i);
        pIni->EraseKey(m_szName, szKey);
    }

    nMaxNum = ListView_GetItemCount(m_hListWnd);
    pIni->WriteInteger(m_szName, "ItemCount", nMaxNum);
    for (i = 0; i < nMaxNum; i++) 
    {
        sprintf(szKey, "Item_%d", i);
        ListView_GetItemText(m_hListWnd, i, 0, szKeyValue, sizeof(szKeyValue));
        pIni->WriteString(m_szName, szKey, szKeyValue);
    }

	g_ClientManager.UpDataWndInClient(g_Ui.GetIni(true));
    ShowErrorInformation();

Exit0:
    return;
}
Example #5
0
BOOL KGameServer::_LoadMiniServerScene()
{
	IIniFile* pIniFile = g_OpenIniFile(KDF_SERVER_CFG);
	QCONFIRM_RET_FALSE(pIniFile);

	INT nSceneCount = 0;
	pIniFile->GetInteger("PreloadScene", "Count", 0, &nSceneCount);

	if (nSceneCount > 0)
	{
		INT* pSceneTemplateIds = new INT[nSceneCount];
		INT nActualCount = pIniFile->GetMultiInteger("PreloadScene", "Scenes", pSceneTemplateIds, nSceneCount);
		QCONFIRM(nActualCount == nSceneCount);
		nSceneCount = nActualCount;

		for (INT j = 0; j < nSceneCount; j++)
		{
			INT nSceneId = pSceneTemplateIds[j];
			if (nSceneId > 0)
				g_pSceneMgr->LoadScene((DWORD)nSceneId, 0);
		}
	}

	return TRUE;
}
Example #6
0
void KGT_g_OpenIniFileFromArgumentsTest::Test_g_OpenFileFromArguments_09()
{
    int nResult = false;
    int nRetCode = false;

    IIniFile *piIniFile = NULL;
    char *szArgv[] = {
        "KG_GoddessD.exe",
        "--Database.password="******"value的长度为0", "");

    piIniFile = g_OpenIniFileFromArguments(nArgc, szArgv);
    KG_PROCESS_ERROR(piIniFile);

    nRetCode = piIniFile->GetSectionCount();
    KG_PROCESS_ERROR(nRetCode == 1);

    nRetCode = piIniFile->GetString("Database", "password", "root", szRetValue, sizeof(szRetValue) / sizeof(szRetValue[0]));
    KG_PROCESS_ERROR(nRetCode);

    KG_PROCESS_ERROR(szRetValue[0] == '\0');

    nResult = true;
Exit0:
    KG_COM_RELEASE(piIniFile);
    CPPUNIT_ASSERT(nResult);
}
Example #7
0
BOOL KLogClient::Init()
{
    BOOL               bResult          = false;
    BOOL               bRetCode         = false;
    IIniFile*	       piIniFile        = NULL;
    int                nPort            = 0;
    char               szIP[16];

    piIniFile = g_OpenIniFile(GS_SETTINGS_FILENAME);
    KGLOG_PROCESS_ERROR(piIniFile);

    bRetCode = piIniFile->GetString("LogServer", "IP", "127.0.0.1", szIP, sizeof(szIP));
    KGLOG_PROCESS_ERROR(bRetCode);

    bRetCode = piIniFile->GetInteger("LogServer", "Port", 5005, &nPort);
    KGLOG_PROCESS_ERROR(bRetCode);

    bRetCode = piIniFile->GetInteger("LogServer", "PingCycle", 30, &m_nPingCycle);
    KGLOG_PROCESS_ERROR(bRetCode);
    KGLOG_PROCESS_ERROR(m_nPingCycle > 0);

    bRetCode = piIniFile->GetString("LogServer", "Identity", "", m_szIdentity, sizeof(m_szIdentity));
    KGLOG_PROCESS_ERROR(bRetCode);
    m_szIdentity[sizeof(m_szIdentity) - 1] = '\0';

    // 无论连上与否,均视为成功
    LoginServer(szIP, nPort, m_szIdentity);

    bResult = true;
Exit0:
    KG_COM_RELEASE(piIniFile);
    return bResult;
}
Example #8
0
void KGT_GetNextSectionTest::TestGetNextSection_06()
{
    int nResult = false;
    int nRetCode = false;

    IIniFile *piIniFile = NULL;
    char *szArgv[] = {
        "KG_GoddessD.exe", 
        "--AVersion.version=2", 
        "--BDatabase.user=root", 
        "--CNameServer.user=root", 
        "--DLogServer.user=root"
    };
    int nArgc = sizeof(szArgv) / sizeof(szArgv[0]);
    char *pszSection = "EGoddessServer";
    char szNextSection[IIniFile::INI_MAX_SUPPORT_SECTION_AND_KEY_SIZE];
    szNextSection[0] = '\0';

    KG_CASE_INFO("不存在的记录的下一个section", "KG_Ini_SectionMap有多条记录");

    piIniFile = g_OpenIniFileFromArguments(nArgc, szArgv);
    KG_PROCESS_ERROR(piIniFile);

    nRetCode = piIniFile->GetNextSection(pszSection, szNextSection);
    KG_PROCESS_ERROR(!nRetCode);
    szNextSection[sizeof(szNextSection) - 1] = '\0';

    KG_PROCESS_ERROR(szNextSection[0] == '\0');    //szNextSection保持不变

    nResult = true;
Exit0:
    KG_COM_RELEASE(piIniFile);
    CPPUNIT_ASSERT(nResult);
}
Example #9
0
BOOL KSndaAgency::LoadConfig()
{
	BOOL        bResult     = false;
	BOOL        bRetCode    = false;
	IIniFile*   piIniFile   = NULL;

	piIniFile = g_OpenIniFile(GATEWAY_CONFIG_FILE);
	LOG_PROCESS_ERROR(piIniFile);

	m_bOpen = true;
	bRetCode = piIniFile->IsSectionExist("SDOA");
	if (!bRetCode)
	{
		m_bOpen = false;
		goto EXIT1;
	}

	bRetCode = piIniFile->GetString("SDOA", "AdultIDCard", "not configed", m_szAdultIDCard, sizeof(m_szAdultIDCard)); 
	LOG_PROCESS_ERROR(bRetCode);

EXIT1:
	bResult = true;
EXIT0:
	SAFE_RELEASE(piIniFile);
	return bResult;
}
Example #10
0
void KGT_GetNextSectionTest::TestGetNextSection_11()
{
    int nResult = false;
    int nRetCode = false;

    IIniFile *piIniFile = NULL;
    char *szArgv[] = {
        "KG_GoddessD.exe"
    };
    int nArgc = sizeof(szArgv) / sizeof(szArgv[0]);
    char *pszSection = "Version";
    char szNextSection[IIniFile::INI_MAX_SUPPORT_SECTION_AND_KEY_SIZE];
    szNextSection[0] = '\0';

    KG_CASE_INFO("非空值下一个section", "KG_Ini_SectionMap没有记录");

    piIniFile = g_OpenIniFileFromArguments(nArgc, szArgv);
    KG_PROCESS_ERROR(piIniFile);

    nRetCode = piIniFile->GetNextSection(pszSection, szNextSection);
    KG_PROCESS_ERROR(!nRetCode);
    szNextSection[sizeof(szNextSection) - 1] = '\0';

    KG_PROCESS_ERROR(szNextSection[0] == '\0');

    nResult = true;
Exit0:
    KG_COM_RELEASE(piIniFile);
    CPPUNIT_ASSERT(nResult);
}
Example #11
0
int KUiWndCheckBoxCommon::SelAnimate(int *pnSelResult)
{
    int nResult     = false;
    int nRetCode    = false;
    char szUiTexFileName[MAX_PATH];
    char szRoot[MAX_PATH];
    int nSelAinmate = 0;
    IIniFile *pIni = NULL;

    pIni = g_Ui.GetIni();
    KG_PROCESS_ERROR(pIni);

    g_GetRootPath(szRoot);
    KG_PROCESS_ERROR(szRoot[0] != '\0');

    szUiTexFileName[0] = '\0';
    pIni->GetString(m_szName, "Image", "", szUiTexFileName, sizeof(szUiTexFileName));
    KG_PROCESS_ERROR(szUiTexFileName[0] != '\0');

    strcat(szRoot, "\\");
    strcat(szRoot, szUiTexFileName);
    strcpy(szUiTexFileName, szRoot);

    nSelAinmate = SELANIMATE::OnSelAnimate(szUiTexFileName, m_hWnd);    
    KG_PROCESS_ERROR(nSelAinmate != -1);

    *pnSelResult = nSelAinmate;

    nResult = true;
Exit0:
    return nResult;
}
Example #12
0
HRESULT KG3DScenePvsEditor::UnInit()
{
    IIniFile* pIniFile = g_OpenIniFile("data\\public\\PvsEditorSetting.ini", false, true);

    if (pIniFile)
    {
        GetEnvironment().SaveMapSetting(pIniFile);
        pIniFile->Save("data\\public\\PvsEditorSetting.ini");
    }

    if (m_lpPointLightRender)
        m_lpPointLightRender->UnInit();
    SAFE_DELETE(m_lpPointLightRender);

    SAFE_RELEASE(pIniFile);


    KG3DSceneSelectionTool& selTool = this->GetSelectionTool();
    selTool.ClearSelection();

	SAFE_DELETE(m_lpLightMapBaker);

    SAFE_RELEASE(m_pGroundGridVertexs);
    SAFE_RELEASE(m_pPvs);
    SAFE_RELEASE(m_pHandObj);
    SAFE_DELETE(m_pHandPtl);
    SAFE_DELETE(m_pRunder);


	KG3DSceneEditorBase::UnInit();

    return S_OK;
}
Example #13
0
File: main.cpp Project: viticm/pap2
int LoadConfig(BOOL *pnIsClient, char *pszDir, unsigned uSize)
{
    int nResult = false;
    int nRetCode = false;
    const char CONFIGFILE[] = "KG_BoneChecker.ini";
    IIniFile *piFile = NULL;

    *pnIsClient = false;

    piFile = g_OpenIniFile(CONFIGFILE);
    KGLOG_PROCESS_ERROR(piFile);
    
    nRetCode = piFile->GetString("BoneChecker", "SO3ClientDir", "", pszDir, uSize);
    KGLOG_PROCESS_ERROR(nRetCode);

    if (strcmp(pszDir, ""))
    {
        *pnIsClient = true;
        KG_PROCESS_SUCCESS(true);
    }

    nRetCode = piFile->GetString("BoneChecker", "bipdir", "", pszDir, uSize);
    KGLOG_PROCESS_ERROR(nRetCode);

Exit1:
    nResult = true;
Exit0:
    if (!nResult)
        puts("!!!Read Config File Failed.");
    KG_COM_RELEASE(piFile);
    return nResult;
}
Example #14
0
    bool KFilePathMgr::Init()
    {
        bool bResult = false;
        char szPath[MAX_PATH];
        char szKey[128];
        IIniFile *pIni = NULL;

#ifdef KG_PUBLISH
		pIni = g_OpenIniFileInPak("\\ui\\configfilepath.ini");
		if (!pIni)
			pIni = g_OpenIniFile("\\ui\\configfilepath.ini");
		KGLOG_PROCESS_ERROR(pIni && "open ini file ui\\configfilepath.ini failed!\n");
#else
		pIni = g_OpenIniFile("\\ui\\configfilepath.ini");
		KGLOG_PROCESS_ERROR(pIni && "open ini file ui\\configfilepath.ini failed!\n");
#endif

        szKey[0] = '\0';
    	while (pIni->GetNextKey("FILE_PATH", szKey, szKey))
        {
            pIni->GetString("FILE_PATH", szKey, "", szPath, _countof(szPath));
            FormatFilePath(szPath);

            m_KeyToPath[szKey] = szPath;
        }

        bResult = true;
Exit0:
        SAFE_RELEASE(pIni);
        return bResult;
    }
void KSceneEditorDialogAutoGrass::LoadTextureSettings()
{
	CString strTextureName;
	TCHAR strIniFileName[MAX_PATH];
	int nCurSel = m_ComboxBoxTexture.GetCurSel();
	IIniFile* pInIFile = NULL;
	int nReturnCode = 0;

	KG_PROCESS_ERROR(nCurSel != CB_ERR);

	m_ComboxBoxTexture.GetLBText(nCurSel, strTextureName);
	sprintf(strIniFileName, "%s%s.ini", m_GrassTexturePath, strTextureName);
	
	////把文件的只读属性去掉////////////////////////////////////by huangjinshou
	DWORD dwFileAttribute = ::GetFileAttributes(strIniFileName);
	dwFileAttribute &=~FILE_ATTRIBUTE_READONLY; 
	::SetFileAttributes(strIniFileName,dwFileAttribute);
	///////////////////////////////////////////////////////////
	pInIFile = g_OpenIniFile(strIniFileName, false, true);
	KG_PROCESS_ERROR(pInIFile);

	pInIFile->GetInteger("Texture", "StrideX", 1, &m_nWidhtCount);
	pInIFile->GetInteger("Texture", "StrideY", 1, &m_nHeightCount);

	UpdateData(FALSE);
Exit0:
	SAFE_RELEASE(pInIFile);
	return;
}
Example #16
0
BOOL KPlayerManager::Init()
{
    BOOL                        bResult                = false;
    BOOL                        bRetCode               = false;
    BOOL                        nSocketServerInitFlag  = false;
    IIniFile*                   piIniFile              = NULL;
    int                         nPort                  = 0;
    char                        szIP[_NAME_LEN];

    m_pSocketEvents = new KG_SOCKET_EVENT[MAX_SOCKET_EVENT];
    KGLOG_PROCESS_ERROR(m_pSocketEvents);

    m_pSockerServer = new KG_SocketServerAcceptor();
    KGLOG_PROCESS_ERROR(m_pSockerServer);

    piIniFile = g_OpenIniFile(GATEWAY_CONFIG_FILE);
    KGLOG_PROCESS_ERROR(piIniFile);

    bRetCode = piIniFile->GetInteger("Player", "MaxPlayer", 8192, &m_nMaxPlayer);
    KGLOG_PROCESS_ERROR(bRetCode);

    bRetCode = piIniFile->GetString("Player", "IP", "", szIP, (unsigned int)sizeof(szIP));
    KGLOG_PROCESS_ERROR(bRetCode);

    bRetCode = piIniFile->GetInteger("Player", "Port", 0, &nPort);
    KGLOG_PROCESS_ERROR(bRetCode);

    bRetCode = piIniFile->GetInteger("Player", "PingCycle", 20, &m_nPingCycle);
    KGLOG_PROCESS_ERROR(bRetCode);

    bRetCode = m_pSockerServer->Init(
        szIP, nPort, MAX_WAIT_ACCEPT, 
        1024 * 4, 1024 * 16, KSG_ENCODE_DECODE, NULL
    );
    KGLOG_PROCESS_ERROR(bRetCode);
    nSocketServerInitFlag = true;

    bResult = true;
Exit0:

    KGLogPrintf(KGLOG_INFO, "Start service at %s:%d ... ... [%s]\n", szIP, nPort, bResult ? "OK" : "Failed");

    if (!bResult)
    {
        if (nSocketServerInitFlag)
        {
            m_pSockerServer->UnInit(NULL);
            nSocketServerInitFlag = false;
        }
        KG_DELETE(m_pSockerServer);
        KG_DELETE_ARRAY(m_pSocketEvents);
    }
    KG_COM_RELEASE(piIniFile);
    return bResult;
}
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);
	;
}
Example #18
0
BOOL KGameServer::_InitEnv()
{
	// Get GameCenter Ip/Port
	IIniFile* pIniFile = g_OpenIniFile(KDF_SERVER_CFG);
	QCONFIRM_RET_FALSE(pIniFile);

	//pIniFile->GetInteger("GameCenter", "Port", 5135, &m_nGameCenterPort);
	//pIniFile->GetString("GameCenter", "Ip", "", m_szGameCenterIp, countof(m_szGameCenterIp));

	pIniFile->GetInteger("GameServer", "ServerId", 0, &g_cOrpgWorld.m_nServerId);
	pIniFile->GetInteger("GameServer", "ServerMode", 0, &g_cOrpgWorld.m_nServerMode);
	return TRUE;
}
Example #19
0
int KG_LoadMySQLDatabaseParameter(const char cszConfigFileName[], KG_MYSQL_PARAM *pRetParam)
{
	int nResult  = false;
	int nRetCode = false;
    IIniFile *piIniFile = NULL;
    char szPassword[64];

    KGLOG_PROCESS_ERROR(cszConfigFileName);
    KGLOG_PROCESS_ERROR(cszConfigFileName[0]);
    KGLOG_PROCESS_ERROR(pRetParam);

    piIniFile = g_OpenIniFile(cszConfigFileName);
    KGLOG_PROCESS_ERROR(piIniFile && "g_OpenIniFile()");

    nRetCode = piIniFile->GetString(
        "DatabaseServer", "Server", NULL, pRetParam->szServer, sizeof(pRetParam->szServer)
    );
    KGLOG_PROCESS_ERROR(nRetCode && "Unable load \"[DatabaseServer]:Server\"");

    nRetCode = piIniFile->GetString(
        "DatabaseServer", "Database", NULL, pRetParam->szDatabase, sizeof(pRetParam->szDatabase)
    );
    KGLOG_PROCESS_ERROR(nRetCode && "Unable load \"[DatabaseServer]:Database\"");

    nRetCode = piIniFile->GetString(
        "DatabaseServer", "UserName", NULL, pRetParam->szUserName, sizeof(pRetParam->szUserName)
    );
    KGLOG_PROCESS_ERROR(nRetCode && "Unable load \"[DatabaseServer]:UserName\"");

    nRetCode = piIniFile->GetString("DatabaseServer", "Password", NULL, szPassword, sizeof(szPassword));
    KGLOG_PROCESS_ERROR(nRetCode && "Unable load \"[DatabaseServer]:Password\"");

#ifdef _DEBUG
    strncpy(pRetParam->szPassword, szPassword, sizeof(pRetParam->szPassword));
    KGLOG_PROCESS_ERROR(pRetParam->szPassword[sizeof(pRetParam->szPassword) -1] == '\0');
#else
    nRetCode = (int)strlen(szPassword);
    KGLOG_PROCESS_ERROR((nRetCode == PG_RESULTLENSTD) && "Password error");
    nRetCode = SimplyDecryptPassword(pRetParam->szPassword, szPassword);
    KGLOG_PROCESS_ERROR(nRetCode && "Password error");
#endif

	nResult = true;
Exit0:
    KG_COM_RELEASE(piIniFile);
    if (!nResult && cszConfigFileName)
        KGLogPrintf(KGLOG_DEBUG, "Failed to load parameter from the file : %s", cszConfigFileName);
	return nResult;
}
Example #20
0
void KGT_g_OpenIniFileFromArgumentsTest::Test_g_OpenFileFromArguments_10()
{
    int nResult = false;
    int nRetCode = false;

    IIniFile *piIniFile = NULL;
    int nArgc = 0;
    char *pszArgv[2] = {0};
    char szArgv[2][IIniFile::INI_MAX_SUPPORT_VALUE_SIZE + 100] = {0};
    nArgc = sizeof(szArgv) / sizeof(szArgv[0]);
    char szValue[IIniFile::INI_MAX_SUPPORT_VALUE_SIZE];
    szValue[0] = '\0';
    char szRetValue[IIniFile::INI_MAX_SUPPORT_VALUE_SIZE];
    szRetValue[0] = '\0';

    pszArgv[0] = szArgv[0];
    pszArgv[1] = szArgv[1];

    strncpy(szArgv[0], "KG_GoddessD.exe", sizeof(szArgv[0]));
    szArgv[0][IIniFile::INI_MAX_SUPPORT_SECTION_AND_KEY_SIZE] = '\0';

    KG_CASE_INFO("value的长度为最大值", "");

    nRetCode = _DataGenerator(sizeof(szValue), szValue);
    KG_PROCESS_ERROR(nRetCode);

    nRetCode = _snprintf(
        szArgv[1],
        sizeof(szArgv[1]) / sizeof(szArgv[1][0]) - 1,
        "--Database.name=%s",
        szValue
    );
    KG_PROCESS_ERROR(nRetCode > 0);

    piIniFile = g_OpenIniFileFromArguments(nArgc, pszArgv);
    KG_PROCESS_ERROR(piIniFile);

    nRetCode = piIniFile->GetString("Database", "name", "", szRetValue, sizeof(szRetValue) / sizeof(szRetValue[0]));
    KG_PROCESS_ERROR(nRetCode);

    nRetCode = strcmp(szValue, szRetValue);
    KG_PROCESS_ERROR(nRetCode == 0);

    nResult = true;
Exit0:
    KG_COM_RELEASE(piIniFile);
    CPPUNIT_ASSERT(nResult);
}
Example #21
0
int KGTestMapDisuseResource::FindResInModelset(const char cszResourceName[], set<string>& vecResList)
{
	//参照KG3DRepresentObjectSet::LoadFromIniFile
	int nRetCode = false;
	int nResult  = false;
	IIniFile* pIniFile = NULL;
	char szSourcePathName[MAX_PATH] = {0};

	KG_ASSERT_EXIT(cszResourceName);
	KGLOG_PROCESS_ERROR(cszResourceName[0] != '\0');

	nRetCode = _snprintf_s(szSourcePathName,
		sizeof(szSourcePathName),
		sizeof(szSourcePathName) - 1,
		"%s%s",
		m_szClientPath,
		cszResourceName);
	KGLOG_PROCESS_ERROR(nRetCode > 0);

	pIniFile = g_OpenIniFile(szSourcePathName);
	KGLOG_PROCESS_ERROR(pIniFile);

	int nCount = 0;
	pIniFile->GetInteger("MAIN", "Count", 0, &nCount);

	for (int i = 0; i < nCount; i++)
	{
		char szSecName[MAX_PATH]  = {0};
		char szMeshName[MAX_PATH] = {0};
		char szMtlName[MAX_PATH]  = {0};

		nRetCode = _snprintf_s(szSecName, sizeof(szSecName), sizeof(szSecName) - 1, "Model%d", i);
		KGLOG_PROCESS_ERROR(nRetCode> 0);
		pIniFile->GetString(szSecName, "MeshName", "", szMeshName, sizeof(szMeshName));
		FindResource(szMeshName, vecResList);
		pIniFile->GetString(szSecName, "MtlName", "", szMtlName, sizeof(szMtlName));
		FindResource(szMtlName, vecResList);
	}

	nResult = true;
Exit0:
	if (pIniFile)
	{	
		pIniFile->Release();
		pIniFile = NULL;
	}
	return nResult;
}
Example #22
0
HRESULT KG3DTerrainRepresentInfo::InitDis()
{
    HRESULT hResult = E_FAIL;
    IIniFile* pFile = NULL;

    pFile = g_OpenIniFile(s_strGroundEffectConfigFile);
    KG_PROCESS_ERROR(pFile);
    
    pFile->GetFloat("ROOT","GroundEffectDis",500.0,&m_fDis);
    pFile->GetFloat("ROOT","GroundEffectWaterDis",500.0,&m_fwaterDis);

    hResult = S_OK;
Exit0:
    SAFE_RELEASE(pFile);
    return hResult;
}
Example #23
0
LRESULT KGSFXGlobPage::OnColorBkDialogClose(WPARAM w, LPARAM l)
{
    GET_SFX_EDITOR_RET(0);

    TCHAR szIniPath[MAX_PATH];
    g_GetFullPath(szIniPath, TEXT("config.ini"));
    IIniFile* pIniFile = g_OpenIniFile(szIniPath, true, true);

    if (pIniFile)
    {
        pIniFile->WriteStruct(TEXT("SfxEditor"), TEXT("bkcolor"), pScene->GetBkColorPtr(), sizeof(DWORD));
        pIniFile->Save(szIniPath);
        pIniFile->Release();
    }

    return 1;
}
Example #24
0
void KGT_g_OpenIniFileFromArgumentsTest::Test_g_OpenFileFromArguments_04()
{
    int nResult = false;
    int nRetCode = false;

    IIniFile *piIniFile = NULL;
    char *pszArgv[] = {
        "KG_GoddessD.exe",
        "--Version.version=2",
        "--Database.name=mysql"
    };
    int nArgc = sizeof(pszArgv) / sizeof(pszArgv[0]);
    char szRetVersion[IIniFile::INI_MAX_SUPPORT_SECTION_AND_KEY_SIZE];
    szRetVersion[0] = '\0';
    char szRetName[IIniFile::INI_MAX_SUPPORT_SECTION_AND_KEY_SIZE];
    szRetName[0] = '\0';

    KG_CASE_INFO("不同的section不同的key", "");

    piIniFile = g_OpenIniFileFromArguments(nArgc, pszArgv);
    KG_PROCESS_ERROR(piIniFile);

    nRetCode = piIniFile->IsSectionExist("Version");
    KG_PROCESS_ERROR(nRetCode);

    nRetCode = piIniFile->IsSectionExist("Database");
    KG_PROCESS_ERROR(nRetCode);

    nRetCode = piIniFile->GetString("Version", "version", "", szRetVersion, sizeof(szRetVersion) / sizeof(szRetVersion[0]));
    KG_PROCESS_ERROR(nRetCode);
    szRetVersion[sizeof(szRetVersion) / sizeof(szRetVersion[0]) -1] = '\0';
    nRetCode = strncmp(szRetVersion, "2", sizeof(szRetVersion) / sizeof(szRetVersion[0]));
    KG_PROCESS_ERROR(nRetCode == 0);

    nRetCode = piIniFile->GetString("Database", "name", "", szRetName, sizeof(szRetName) / sizeof(szRetName[0]));
    KG_PROCESS_ERROR(nRetCode);
    szRetName[sizeof(szRetName) / sizeof(szRetName[0]) -1] = '\0';
    nRetCode = strncmp(szRetName, "mysql", sizeof(szRetName) / sizeof(szRetName[0]));
    KG_PROCESS_ERROR(nRetCode == 0);

    nResult = true;
Exit0:
    KG_COM_RELEASE(piIniFile);
    CPPUNIT_ASSERT(nResult);
}
Example #25
0
void KGT_g_OpenIniFileFromArgumentsTest::Test_g_OpenFileFromArguments_07()
{
    int nResult = false;
    int nRetCode = false;

    IIniFile *piIniFile = NULL;
    int nRetValue = 0;
    int nArgc = 0;
    char *pszArgv[2] = {0};
    char szArgv[2][IIniFile::INI_MAX_SUPPORT_SECTION_AND_KEY_SIZE * 2] = {0};
    nArgc = sizeof(szArgv) / sizeof(szArgv[0]);
    char szKey[IIniFile::INI_MAX_SUPPORT_SECTION_AND_KEY_SIZE];
    szKey[0] = '\0';
    pszArgv[0] = szArgv[0];
    pszArgv[1] = szArgv[1];

    strncpy(szArgv[0], "KG_GoddessD.exe", sizeof(szArgv[0]));
    szArgv[0][IIniFile::INI_MAX_SUPPORT_SECTION_AND_KEY_SIZE] = '\0';

    KG_CASE_INFO("key的长度为最大值", "");

    nRetCode = _DataGenerator(sizeof(szKey), szKey);
    KG_PROCESS_ERROR(nRetCode);

    nRetCode = _snprintf(
        szArgv[1],
        sizeof(szArgv[1]) / sizeof(szArgv[1][0]) - 1,
        "--Version.%s=2",
        szKey
    );
    KG_PROCESS_ERROR(nRetCode > 0);

    piIniFile = g_OpenIniFileFromArguments(nArgc, pszArgv);
    KG_PROCESS_ERROR(piIniFile);

    nRetCode = piIniFile->GetInteger("Version", szKey, 0, &nRetValue);
    KG_PROCESS_ERROR(nRetCode);

    KG_PROCESS_ERROR(nRetValue == 2);

    nResult = true;
Exit0:
    KG_COM_RELEASE(piIniFile);
    CPPUNIT_ASSERT(nResult);
}
Example #26
0
void KG3DSelector::UnInit()
{
	IIniFile *pConfig = g_OpenIniFile(g_szConfigFilePath, false, true);
	int nResult = 0;
	KG_PROCESS_ERROR(pConfig);

	nResult = pConfig->WriteInteger("KG3DENGINE", "SelectorScale", static_cast<int>(m_nScale));
	KG_PROCESS_ERROR(nResult);

	pConfig->Save(g_szConfigFilePath);

Exit0:
	SAFE_RELEASE(pConfig);
	SAFE_RELEASE(m_pStencilRT);
	SAFE_RELEASE(m_pStencilDepth);
	SAFE_RELEASE(m_pRT);
	SAFE_RELEASE(m_pResult);
}
Example #27
0
BOOL KRelayAgency::Init()
{
	BOOL                  bResult               = false;
	int                   nRetCode              = false;
	IIniFile*             piIniFile             = NULL;
	ISocketStream*     piSocket              = NULL;
	int                   nPort                 = 0;
	char                  szIP[_NAME_LEN];
	QSocketConnector    Connector;
	timeval               TimeoutValue;

	piIniFile = g_OpenIniFile(GATEWAY_CONFIG_FILE);
	LOG_PROCESS_ERROR(piIniFile);

	nRetCode = piIniFile->GetString("Relay", "IP", "", szIP, sizeof(szIP));
	LOG_PROCESS_ERROR(nRetCode);

	nRetCode = piIniFile->GetInteger("Relay", "Port", 0, &nPort);
	LOG_PROCESS_ERROR(nRetCode);

	nRetCode = piIniFile->GetInteger("Relay", "PingCycle", 20, &m_nPingCycle);
	LOG_PROCESS_ERROR(nRetCode);

	piSocket = Connector.Connect(szIP, nPort);
	LOG_PROCESS_ERROR(piSocket);

	TimeoutValue.tv_sec  = 1;
	TimeoutValue.tv_usec = 0;

	nRetCode = piSocket->SetTimeout(&TimeoutValue);
	LOG_PROCESS_ERROR(nRetCode);

	m_piSocket = piSocket;
	m_piSocket->AddRef();
	m_bSocketError = false;

	bResult = true;
EXIT0:
	QLogPrintf(LOG_INFO, "Connect to Relay %s:%d ... ... [%s]\n", szIP, nPort, bResult ? "OK" : "Failed");
	SAFE_RELEASE(piSocket);
	SAFE_RELEASE(piIniFile);
	return bResult;
}
Example #28
0
HRESULT KG3DTerrainRepresentInfo::InitDefaultSfx()
{
    HRESULT hResult = E_FAIL;
    HRESULT hRetCode = E_FAIL;
    IIniFile *pFile = NULL;
    pFile = g_OpenIniFile(s_strGroundEffectConfigFile);
    KG_PROCESS_ERROR(pFile);

    pFile->GetString("ROOT","DefaultSfx1","",m_DefaultSfx.str_DefaultSfx[0],MAX_PATH);
    pFile->GetString("ROOT","DefaultSfx2","",m_DefaultSfx.str_DefaultSfx[1],MAX_PATH);
    pFile->GetString("ROOT","DefaultSfx3","",m_DefaultSfx.str_DefaultSfx[2],MAX_PATH);
    pFile->GetString("ROOT","DefaultSfx4","",m_DefaultSfx.str_DefaultSfx[3],MAX_PATH);
    pFile->GetString("ROOT","DefaultSfxTerrain","",m_DefaultSfx.str_DefaultSfxTerrain,MAX_PATH);
    pFile->GetFloat("ROOT","DefaultSfxTerrainPlayRate",0.0,&m_DefaultSfx.fPlayRate);

    hResult = S_OK;
Exit0:
    SAFE_RELEASE(pFile);
    return hResult;
}
Example #29
0
BOOL KSO3Gateway::LoadConfig()
{
    BOOL        bResult     = false;
    BOOL        bRetCode    = false;
    IIniFile*   piIniFile   = NULL;

    piIniFile = g_OpenIniFile(GATEWAY_CONFIG_FILE);
    KGLOG_PROCESS_ERROR(piIniFile);

    bRetCode = piIniFile->GetString("Global", "Locale", "", m_szLocale, sizeof(m_szLocale));
    KGLOG_PROCESS_ERROR(bRetCode);

    bRetCode = piIniFile->GetBool("Global", "SD", &m_bSndaAgent);
    KGLOG_PROCESS_ERROR(bRetCode);

    bResult = true;
Exit0:
    KG_COM_RELEASE(piIniFile);
    return bResult;
}
Example #30
0
BOOL KSOEditor::Init()
{
    BOOL        bResult             = false;
    int         nRetCode            = 0;
    BOOL        bNetWorkInitFlag    = false;
    IIniFile*   piFile              = NULL;
    int         nPort               = 0;
    int         nMaxConnection      = 0;
    char        szLocalIP[32];

    g_SetRootPath(NULL);

    piFile = g_OpenIniFile("KSOEditorServer.ini");
    KGLOG_PROCESS_ERROR(piFile);

    piFile->GetString("Server", "IP", "127.0.0.1", szLocalIP, sizeof(szLocalIP));
    piFile->GetInteger("Server", "Port", 0, &nPort);
    piFile->GetInteger("Server", "MaxConnection", 100, &nMaxConnection);

    m_pNetworkMgr = new KNetworkMgr;
    KGLOG_PROCESS_ERROR(m_pNetworkMgr);
    
    nRetCode = m_pNetworkMgr->Init(szLocalIP, nPort, nMaxConnection);
    KGLOG_PROCESS_ERROR(nRetCode);
    bNetWorkInitFlag = true;

    bResult = true;
Exit0:
    if (!bResult)
    {
        if (bNetWorkInitFlag)
        {
            m_pNetworkMgr->UnInit();
            bNetWorkInitFlag = false;
        }
        SAFE_DELETE(m_pNetworkMgr);
    }

    KG_COM_RELEASE(piFile);
    return bResult;
}