Esempio n. 1
0
bool CParticleSystemConfig::bLoadParticleEmitters( const char *i_pConfigFile, CParticleSystem *o_pParent )
{
	IrrXMLReader* xml;
	bool result = true;
	strcpy(effectPath, i_pConfigFile);
	char* lastSlash = strrchr(effectPath, '/');
	*(lastSlash+1) = '\0';
	std::string cfgFile(i_pConfigFile);

	printd(INFO, "CParticleSystemConfig::bLoadParticleEmitters(): Trying to load Particles of file %s\n", i_pConfigFile);
	if (!fileExists(cfgFile))
	{
		printd(ERROR, "CParticleSystemConfig::bLoadParticleEmitters(): ERROR: could not find config-file %s\n", i_pConfigFile);
		return false;
	} // if

	xml = createIrrXMLReader(i_pConfigFile);

	while(xml && xml->read()) {
		switch (xml -> getNodeType()) {
			case EXN_ELEMENT:
				if (!strcmp("origin", xml->getNodeName())) 
				{
					o_pParent->SetRadius(xml->getAttributeValueAsFloat("size"));
					result = result | parseParticleOrigin(xml, o_pParent);
				} // if
				break;
			case EXN_ELEMENT_END:
				break;
			default:
				break;
		} // switch
	} // while
	delete xml;

	return true;
}
Esempio n. 2
0
bool CollisionMap::loadCollisionWorld(std::string cfgFile, CollisionLineSetFactory* factory) {
	unsigned collMapId, tileType;
	float yRotation = 0;
	std::string fileType, fileName;
	TransformationData trans;
	CollisionLineSet* collLineSet;
	IrrXMLReader * xml;

	if (!fileExists(cfgFile)) {
		printd(ERROR, "CollisionMap::loadCollisionWorld(): ERROR: could not find config-file %s\n",
				cfgFile.c_str());
		return false;
	} // if

	xml = createIrrXMLReader(cfgFile.c_str());

	printd(INFO, "CollisionMap::loadCollisionWorld(): loading from file: %s\n", cfgFile.c_str());
	while (xml && xml->read()) {
		switch (xml -> getNodeType()) {
		case EXN_ELEMENT:
			if (!strcmp("collisionMapConfig", xml->getNodeName())) {
			} // if
			else if (!strcmp("collisionMaps", xml->getNodeName())) {
			} // else if
			else if (!strcmp("collisionMap", xml->getNodeName())) {
				collMapId = xml->getAttributeValueAsInt("id");
			} // else if
			else if (!strcmp("trans", xml->getNodeName())) {
				yRotation = xml->getAttributeValueAsFloat("yRotation");
			} // else if
			else if (!strcmp("file", xml->getNodeName())) {
				fileType = xml->getAttributeValue("type");
			} // else if
			else if (!strcmp("fileName", xml->getNodeName())) {
				fileName = xml->getAttributeValue("name");
			} // else if
			else if (!strcmp("mapping", xml->getNodeName())) {
			} // else if
			else if (!strcmp("tile", xml->getNodeName())) {
				tileType = xml->getAttributeValueAsInt("type");
				collMapId = xml->getAttributeValueAsInt("collisionMapId");
				tileMap[tileType] = objectMap[collMapId];
			} // else if
			break;
		case EXN_ELEMENT_END:
			if (!strcmp("collisionMap", xml->getNodeName())) {
				// TODO: also allow other collision primitives, not only lineSets
				trans = identityTransformation();
				setQuatfAsAxisAngleDeg(trans.orientation, 0, 1, 0, yRotation);
				// TODO: add extra path for CollisionMaps
				collLineSet = loadCollisionLineSet(Configuration::getPath("Tiles") + fileName,
						trans, factory);
				if (collLineSet)
					objectMap[collMapId] = collLineSet;
			} // if
			break;
		default:
			break;
		} // switch
	} // while

	delete xml;
	return true;
} // loadCollisionWorld
Esempio n. 3
0
        bool bCharger(std::string _cCheminFichier = "")
        {
            bool bRetour = false;
            if(_cCheminFichier != "")
            {
                cCheminFichier = _cCheminFichier;
            }
            
            if(cCheminFichier != "")
            {
                if (bCharge == true)
                {
                    vNettoyer();
                }
                
                xml = createIrrXMLReader(cCheminFichier.c_str());
                
                while(xml && xml->read())
                {
                        switch(xml->getNodeType())
                        {
                            case EXN_TEXT:
                                /*if(strcmp("messageText", xml->getNodeName()))
                                {
                                    messageText = xml->getNodeData();
                                }*/
                                break;
                            case EXN_ELEMENT:
                                {
                                        if (!strcmp("antialiazing", xml->getNodeName()))
                                                antialiazing = (!strcmp(xml->getAttributeValue("value"),"ON")?true:false);
                                        else
                                        if (!strcmp("fullscreen", xml->getNodeName()))
                                                fullscreen = (!strcmp(xml->getAttributeValue("value"),"ON")?true:false);
                                        else
                                        if (!strcmp("musicAndFX", xml->getNodeName()))
                                                musicAndFX = (!strcmp(xml->getAttributeValue("value"),"ON")?true:false);
                                        else
                                        if (!strcmp("realTimeShadows", xml->getNodeName()))
                                                realTimeShadows = (!strcmp(xml->getAttributeValue("value"),"ON")?true:false);
                                        else
                                        if (!strcmp("verticalSynch", xml->getNodeName()))
                                                verticalSynch = (!strcmp(xml->getAttributeValue("value"),"ON")?true:false);
                                        else
                                        if (!strcmp("oldHWBlending", xml->getNodeName()))
                                                oldHWBlending = (!strcmp(xml->getAttributeValue("value"),"ON")?true:false);
                                        else
                                        if (!strcmp("driver", xml->getNodeName()))
                                                driver = (E_DRIVER_TYPE)atoi(xml->getAttributeValue("value"));
                                        else
                                        if (!strcmp("windowSize", xml->getNodeName()))
                                        {
                                                width = atoi(xml->getAttributeValue("width"));
                                                height = atoi(xml->getAttributeValue("height"));
                                        }
                                }
                                break;
                        }
                }

                // delete the xml parser after usage
                delete xml;
                xml = NULL;
                bCharge = true;
            }
            
            return bRetour;
        }
Esempio n. 4
0
int main(int argc, char** argv)
{
	CCmdLineInfo cmdLine(argc, argv);
	IrrXMLReader* pXML = NULL;
	vector<string> arrStrings;

	print_title();
	if ( cmdLine.GetArgCount() < 2 )
	{
		print_usage();
		return 1;
	}

  string option;
	string src_file = cmdLine.GetArg(1);
	string target_file = cmdLine.GetArg(2);

  if ( src_file[0] == '-' )
  {
    option = src_file;
    src_file = cmdLine.GetArg(2);
    target_file = cmdLine.GetArg(3);

    if ( option == "-wide" )
    {
      g_ExportWideStrings= true;
      printf("[CONFIG] Exporting wide strings\n");
    }
  }

	pXML = createIrrXMLReader( src_file.c_str() );

	if ( pXML )
	{
		string elemName, string_id, string_val;

		while ( pXML->read() )
		{
			switch ( pXML->getNodeType() )
			{
			case	EXN_ELEMENT:
				elemName = pXML->getNodeName();
				if ( elemName == "String" )
				{
					string_id = pXML->getAttributeValue( "id" );
					arrStrings.push_back(string_id);
				}
				break;

			default:
				break;
			}
		}

		ofstream fs_target;

		fs_target.open( target_file.c_str() );
		if ( fs_target.is_open() )
		{
			write_h_header(fs_target, src_file);
			vector<string>::iterator it = arrStrings.begin();

			while ( it != arrStrings.end() )
			{
				write_h_stringdef(fs_target, *it);
				it++;
			}
		}
		fs_target.close();
	}

	printf("%ld string definitions written to %s\n", arrStrings.size(), target_file.c_str());

	return 0;
}
Esempio n. 5
0
int updateFinder(const char* TITLE_ID, int env_choose, PSN_Update* game){
	const char *env[3] = {"np","sp-int","prod-qa"};
	int size = strlen(TITLE_ID)*2+49+strlen(env[env_choose])*2;
	char *xml_url = (char*) malloc(size);

	snprintf(xml_url,size,"https://a0.ww.%s.dl.playstation.net/tpl/%s/%s/%s-ver.xml",env[env_choose],env[env_choose],TITLE_ID,TITLE_ID);
	download_game_update(xml_url,CACHE_PATH2"/game-update.xml", progress, NULL);
	free((void*)xml_url);
	
	size = get_size(CACHE_PATH2"/game-update.xml");
	if(size == 16 || size == 241 || size == 0){ //Update not found
		file_delete(CACHE_PATH2"/game-update.xml");
		return 0;
	}
	
	if(get_download_status()==DOWNLOAD_FAILED){
		file_delete(CACHE_PATH2"/game-update.xml");
		return 0;
	}
	
	
	IrrXMLReader* xml = createIrrXMLReader(CACHE_PATH2"/game-update.xml");
	int i=-1;
	PSN_Update game_tmp;
	game_tmp.version = new string  [10];
	game_tmp.link    = new string  [10];
	game_tmp.size    = new uint32_t[10];
	game_tmp.min_ver = new float   [10];
	game_tmp.pkgs	 = 0;
	while(xml && xml->read() && i<10){
		//printf("debug: %s\n", xml->getNodeData());
 		switch(xml->getNodeType())
		{
			case EXN_NONE:
				break;
			case EXN_ELEMENT:
			{
				if (!strcmp("package", xml->getNodeName())){
					++i;
					char tmp[10];
					game_tmp.version[i] = xml->getAttributeValue("version");
					game_tmp.size[i]    = xml->getAttributeValueAsInt("size");
					game_tmp.link[i]    = xml->getAttributeValue("url");
					game_tmp.min_ver[i] = xml->getAttributeValueAsFloat("ps3_system_ver");
					game_tmp.pkgs++;
					break;
				}else if (!strcmp("TITLE", xml->getNodeName())){
					xml->read();
					game_tmp.name = xml->getNodeData();
					break;
				}
			}
			case EXN_ELEMENT_END:
				break;
			case EXN_TEXT:
				break;
			case EXN_COMMENT:
				break;
			case EXN_CDATA:
				break;
			case EXN_UNKNOWN:
				break;
		}
	}
	delete xml;
	game->name    = game_tmp.name.c_str();
	game->version = new string  [game_tmp.pkgs];
	game->link    = new string  [game_tmp.pkgs];
	game->size    = new uint32_t[game_tmp.pkgs];
	game->min_ver = new float   [game_tmp.pkgs];
	game->pkgs    = game_tmp.pkgs;
	for(u8 j=0; j<game_tmp.pkgs; ++j){
		game->version[j] = game_tmp.version[j];
		game->link[j]    = game_tmp.link[j];
		game->size[j]    = game_tmp.size[j];
		game->min_ver[j] = game_tmp.min_ver[j];
	}
	
	delete [] game_tmp.version;
	delete [] game_tmp.link;
	delete [] game_tmp.size;
	
	file_delete(CACHE_PATH2"/game-update.xml");
	return 1;
}
Esempio n. 6
0
int BrewologyLoadStringsFromXML(const char* filename, PSC_Application *App){
	IrrXMLReader* xml = createIrrXMLReader(filename);
	App->n_elem    = 1014;
	App->name      = new string[1020];
	App->version   = new string[1020];
	App->author    = new string[1020];
	App->img_file  = new string[1020];
	App->type_file = new int   [1020];
	App->pkg       = new links [1020];

/*
	App->link      = new string[1020];
	App->pkg_file  = new string[1020];
	App->file_size = new u32   [1020];
*/
	int i=-1;
	bool name_app = false;
	App->downloaded = false;
	while(xml && xml->read()){
 		switch(xml->getNodeType())
		{
			case EXN_NONE:
				break;
			case EXN_ELEMENT:
			{
				if (!strcmp("error", xml->getNodeName())){
					xml->read();
					xml->read();
					update = xml->getNodeData();
					return PSC_OLDVERSION;
				}
				if (!strcmp("homebrew", xml->getNodeName())){
					++i;
					App->type_file[i] = PSC_PACKAGE;
					break;
				}else if (!strcmp("name", xml->getNodeName())){ //homebrew name
					xml->read();
					App->name[i] = xml->getNodeData();
					break;
				}else if (!strcmp("author", xml->getNodeName())){
					xml->read();
					App->author[i] = xml->getNodeData();
					break;
				}else if (!strcmp("icon", xml->getNodeName())){
					xml->read();
					App->img_file[i] = xml->getNodeData();
					break;
				}else if (!strcmp("pkgs", xml->getNodeName())){
					string name[50];
					string link[50];
					u32    size[50];
					u8     pkg=0;
					do{
						switch(xml->getNodeType()){
							case EXN_ELEMENT:
							{
								if (!strcmp("name", xml->getNodeName())){
									xml->read();
									name[pkg] = xml->getNodeData();
								}else if (!strcmp("version", xml->getNodeName())){
									xml->read();
									App->version[i] = xml->getNodeData();
									break;
								}else if (!strcmp("size", xml->getNodeName())){
									xml->read();
									size[pkg] = atoi(xml->getNodeData());
								}else if (!strcmp("location", xml->getNodeName())){
									xml->read();
									link[pkg] = xml->getNodeData();
									++pkg;
								}
							}break;
							case EXN_ELEMENT_END:
							{
								if(!strcmp("pkgs", xml->getNodeName()))
									goto back;
							}break;
						}
					}while(pkg<50 && xml->read());
					back:
					
					App->pkg[i].pkg_num = pkg;
					App->pkg[i].link    = new string [pkg];
					App->pkg[i].name    = new string [pkg];
					App->pkg[i].size    = new u32    [pkg];
					
					for(u8 j=0; j<pkg; ++j){
						App->pkg[i].link[j] = link[j];
						App->pkg[i].size[j] = size[j];
						App->pkg[i].name[j] = name[j];
						App->pkg[i].name[j] += ".pkg";
					}
					
					break;
				}

				break;
			}
			case EXN_ELEMENT_END:
				break;
			case EXN_TEXT:
				break;
			case EXN_COMMENT:
				break;
			case EXN_CDATA:
				break;
			case EXN_UNKNOWN:
				break;
		}
	}
	i++;
	App->n_elem = i;
	for(;i < 1020;++i){
		App->name[i]        = "";
		App->author[i]      = "";
		App->version[i]     = "";
	//	App->link[i]        = "";
	//	App->pkg_file[i]    = "";
		App->img_file[i]    = "";
	//	App->file_size[i]   =  0;
		App->type_file[i]   = -1;
		App->pkg[i].pkg_num =  0;
		
	}

	delete xml;
	return 1;
}
Esempio n. 7
0
int LoadStringsFromXML(const char* filename, PSC_Application *App){
	IrrXMLReader* xml = createIrrXMLReader(filename);
	int i=-1;
	while(xml && xml->read()){
 		switch(xml->getNodeType())
		{
			case EXN_ELEMENT:
			{
				if (!strcmp("elements", xml->getNodeName())){
					App->n_elem  = xml->getAttributeValueAsInt("n");
					App->name      = new string[App->n_elem+1];
					App->version   = new string[App->n_elem+1];
					App->link      = new string[App->n_elem+1];
					App->pkg_file  = new string[App->n_elem+1];
					App->img_file  = new string[App->n_elem+1];
					App->type_file = new int[App->n_elem+1];
				}
				if (!strcmp("app", xml->getNodeName()))
					i++;
				if (!strcmp("NameApp", xml->getNodeName()))
					App->name[i]    = xml->getAttributeValue("name");
				if (!strcmp("Version", xml->getNodeName()))
					App->version[i] = xml->getAttributeValue("v");
				if (!strcmp("Link", xml->getNodeName()))
					App->link[i]    = xml->getAttributeValue("link");
				if (!strcmp("Pkg", xml->getNodeName()))
					App->pkg_file[i]    = xml->getAttributeValue("file");
				if (!strcmp("Image", xml->getNodeName()))
					App->img_file[i]    = xml->getAttributeValue("img");
				if (!strcmp("Type", xml->getNodeName()))
					App->type_file[i]   = xml->getAttributeValueAsInt("type");
				break;
			}
			case EXN_NONE:
				break;
			case EXN_ELEMENT_END:
				break;
			case EXN_TEXT:
				break;
			case EXN_COMMENT:
				break;
			case EXN_CDATA:
				break;
			case EXN_UNKNOWN:
				break;
		}
		if(i == App->n_elem)
			break;

	}
	if(i > App->n_elem)
		App->n_elem = i;

	App->name[App->n_elem] =      "";
	App->version[App->n_elem] =   "";
	App->link[App->n_elem] =      "";
	App->pkg_file[App->n_elem] =  "";
	App->img_file[App->n_elem] =  "";
	App->type_file[App->n_elem] = -1;
	delete xml;
	return 1;
}
Esempio n. 8
0
bool CParser::parseIrrXml(string xmlFile, string method){
	IrrXMLReader* xml = createIrrXMLReader(xmlFile.c_str());
	if(!xml){
		ELOG("CParser", "parseIrrXml", string("Plik XML nie istnieje: ") + xmlFile);
		return false;
	}
	int status = 0;
	Entity entity;
	ClearEntity(&entity);

	while(xml && xml->read()){
		switch(xml->getNodeType()){
		case EXN_ELEMENT:
			{
				string get = xml->getNodeName();
				if(get == "node"){
					string type = xml->getAttributeValue("type");
					if(type == "mesh"){
						if(status == 0){
							status = 1; //zaczynamy parsowanie modelu (dzieki temu omijamy zbedne poczatkowe znaczniki)
							//ELOGEX("DEBUG: WYKRYTO MESHA");
						}else{
							if(!CallLuaFunction(method, &entity)) {
								break;
							}else{
								//ELOGEX("DEBUG: WYKRYTO MESHA");
							}
						}
					}
				}else if(get == "vector3d" && status == 1){
					string name = xml->getAttributeValue("name");
					if(name == "Position"){
						string position = xml->getAttributeValue("value");
						entity.position = strToVec(position);
					}else if(name == "Rotation"){						
						string rotation = xml->getAttributeValue("value");
						entity.rotation = strToVec(rotation);
					}else if(name == "Scale"){
						string scale = xml->getAttributeValue("value");
						entity.scale = strToVec(scale);
					}
				}else if(get == "string" && status == 1){
					string name = xml->getAttributeValue("name");
					if(name == "Mesh"){
						string model = cutDir(xml->getAttributeValue("value"));
						entity.mesh = model;
					}else if(name == "Name"){
						string nazwa = xml->getAttributeValue("value");
						entity.name = nazwa;
					}
				}else if(get == "texture" && status == 1){
					string name = xml->getAttributeValue("name");
					if(name == "Texture1"){
						string filename = cutDir(xml->getAttributeValue("value"));
						entity.texture = filename;
					}
				}
			}
			break;
		}
	}
	CallLuaFunction(method, &entity);
	delete xml;
	return true;
}