Ejemplo n.º 1
0
// Config Loading---------------------------------------------
bool Save::load(){
	char*	line		= new char[256];
	char**	keys		= new char*[3];
	u8		value;

	if (!selectFile())
		return false;
	while(!feof(file)){
		getLine(line);
		if (strlen(line) > 1 && getKeysAndValue(line, keys, &value)){
			switch(currentPart){
				// KAOSS
				case 0:
					parseKaoss(keys, value);
					break;
				// MIXER
				case 2:
					parseMixer(keys, value);
					break;
				//SLIDERS
				case 3:
					parseSliders(keys, value);
					break;
				//GENERAL
				case 4:
					parseGeneral(keys[0], value);
					break;
				//DEBUG
				case 5:
					parseDebug(keys[0], value);
					break;
				//MIDIIN
				case 6:
					parseMidiIn(keys[0], value);
					break;
			}
		}
	}
	delete line;
	delete keys;
	return true;
}
Ejemplo n.º 2
0
void GameConfig::parseConfig()
{
	m_regionInfos.clear();
	m_tableConfigs.clear();
	m_goodInfos.clear();
	m_levelInfos.clear();
	m_webUrls.clear();
	m_servers.m_shardVec.clear();
	m_resVersion.clear();
	m_vipInfos.clear();
	m_mysShops.clear();
	m_switchs.clear();

	xmlDocPtr   pdoc = NULL;
    xmlNodePtr  proot = NULL;
    xmlNodePtr  curNode = NULL;
    
	unsigned long nSize = 0;
	unsigned char* pBuffer = CCFileUtils::sharedFileUtils()->getFileData("game_config.xml", "rb", &nSize);

    pdoc = xmlParseMemory ((char*)pBuffer, nSize);
    
    if (pdoc == NULL)
    {
        return;
    }
    
    // 获取 xml 文档对象的根节对象
    proot = xmlDocGetRootElement (pdoc);
    
    if (proot == NULL)
    {
        return;
    }
    
	curNode = proot->xmlChildrenNode;
	while (curNode != NULL)
	{
		if (xmlStrcmp(curNode->name, BAD_CAST "game")==0)
		{
			parseGameId(curNode);
		}
		else if (xmlStrcmp(curNode->name, BAD_CAST "levels")==0)
		{
			parseLevelInfo(curNode);
		}
		else if (xmlStrcmp(curNode->name, BAD_CAST "webs")==0)
		{
			parseWebs(curNode);
		}
		else if (xmlStrcmp(curNode->name, BAD_CAST "debug")==0)
		{
			parseDebug(curNode);
		}
		curNode = curNode->next;
	}
    
    /* 关闭和清理 */
    xmlFreeDoc(pdoc);
    xmlCleanupParser();
}