int LoadStringsFromXML(const char* filename, PSC_Application2 *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; } } 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; }
//--------------------------------------------------------------------- void Nave::LeAtributos(const char *arquivo) { IrrXMLReader* xml = createIrrXMLReader(arquivo); while(xml && xml->read()) { switch(xml->getNodeType()) { case EXN_ELEMENT: if (!strcmp("atributos", xml->getNodeName())) { Objeto::LeModelo(xml->getAttributeValue("arquivo")); velocidadeMaxima = xml->getAttributeValueAsFloat("velocidadeMaxima"); } else if (!strcmp("tiro", xml->getNodeName())) { if (!strcmp("laser", xml->getAttributeValue("qualBasico"))) tipoTiroBasico = TIPO_LASER; else if (!strcmp("missil", xml->getAttributeValue("qualBasico"))) tipoTiroBasico = TIPO_MISSIL; if (!strcmp("multiplo", xml->getAttributeValue("qualBasico"))) tipoTiroBasico = TIPO_MULTIPLO; } else if (!strcmp("recargaLaser", xml->getNodeName())) { tempoDeRecargaTotal[TIPO_LASER] = xml->getAttributeValueAsInt("tempo"); } else if (!strcmp("recargaMissil", xml->getNodeName())) { tempoDeRecargaTotal[TIPO_MISSIL] = xml->getAttributeValueAsInt("tempo"); } else if (!strcmp("recargaMultiplo", xml->getNodeName())) { tempoDeRecargaTotal[TIPO_MULTIPLO] = xml->getAttributeValueAsInt("tempo"); } break; } } }
void ConfigurationData::loadFile(std::string fp){ IrrXMLReader* xml = createIrrXMLReader(fp.c_str()); std::string pack_id; while (xml && xml->read()){ switch (xml->getNodeType()){ case EXN_ELEMENT: if (!strcmp(xml->getNodeName(), "Window")){ this->SCREEN_SIZE.x = xml->getAttributeValueAsInt("SIZE_X"); this->SCREEN_SIZE.y = xml->getAttributeValueAsInt("SIZE_Y"); this->WINDOW_TITLE = xml->getAttributeValue("TITLE"); } if (!strcmp(xml->getNodeName(), "Paddle")){ this->PADDLE_SPEED = xml->getAttributeValueAsFloat("SPEED"); this->PADDLE_SPEED_CAP = xml->getAttributeValueAsFloat("SPEED_CAP"); this->PADDLE_VELOCITY_DECAY = xml->getAttributeValueAsFloat("VELOCITY_DECAY"); } if (!strcmp(xml->getNodeName(), "Ball")){ this->BALL_INITIAL_VELOCITY.x = xml->getAttributeValueAsFloat("INITIAL_VELOCITY_X"); this->BALL_INITIAL_VELOCITY.y = xml->getAttributeValueAsFloat("INITIAL_VELOCITY_Y"); this->BALL_VELOCITY_INCREASE = xml->getAttributeValueAsFloat("VELOCITY_INCREASE"); } if (!strcmp(xml->getNodeName(), "Skinpacks")){ pack_id = xml->getAttributeValue("pack_id"); } if (!strcmp(xml->getNodeName(), "Pack")){ if (xml->getAttributeValue("pack_id") == pack_id){ this->background_tex_path = xml->getAttributeValue("BG_TEX_PATH"); this->paddle_tex_path = xml->getAttributeValue("PADDLE_TEX_PATH"); this->ball_tex_path = xml->getAttributeValue("BALL_TEX_PATH"); } } break; } } delete xml; }
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
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; }