XML ShopData

Results 1 to 1 of 1
  1. #1
    Moderator GigaToni is offline
    ModeratorRank
    Aug 2009 Join Date
    GER / FRLocation
    2,329Posts

    XML ShopData

    Thought I share my code for XML ShopData :)

    Replace the whole ApiGetShopData function with this:

    (Everything from
    int CUserProfile::ApiGetShopData()
    {
    to
    }
    )

    Code:
    CWOBackendReq req(this, "api_GetShop5.aspx");
    	if(!req.Issue())
    	{
    		r3dOutToLog("GetShopData FAILED, code: %d\n", req.resultCode_);
    		return req.resultCode_;
    	}
    
    	g_NumStoreItems = 0;
    
    	pugi::xml_document xmlFile;
    	req.ParseXML(xmlFile);
    
    	pugi::xml_node xmlNode = xmlFile.child("shopInfo");
    		pugi::xml_node xmlSkills = xmlNode.child("skills").first_child();
    		while(!xmlSkills.empty())
    		{
    			uint32_t skillID = xmlSkills.attribute("SkillID").as_uint();
    			
    			if(skillID == 0xFFFF)
    				break;
    			r3d_assert(skillID < CUserSkills::CLASS_MAX * CUserSkills::SKILL_CLASS_MULT);
    
    			uint32_t Lv1 = xmlSkills.attribute("Lv1").as_uint();
    			uint32_t Lv2 = xmlSkills.attribute("Lv2").as_uint();
    			uint32_t Lv3 = xmlSkills.attribute("Lv3").as_uint();
    			uint32_t Lv4 = xmlSkills.attribute("Lv4").as_uint();
    			uint32_t Lv5 = xmlSkills.attribute("Lv5").as_uint();
    
    			ShopSkillCosts2[skillID][0] = Lv1;
    			ShopSkillCosts2[skillID][1] = Lv2;
    			ShopSkillCosts2[skillID][2] = Lv3;
    			ShopSkillCosts2[skillID][3] = Lv4;
    			ShopSkillCosts2[skillID][4] = Lv5;
                            xmlSkills = xmlSkills.next_sibling();
    		}
    
    		pugi::xml_node xmlItems = xmlNode.child("items").first_child();
    		while(!xmlItems.empty())
    		{
    			uint32_t itemId = xmlItems.attribute("itemId").as_uint();
    			uint32_t price1d = xmlItems.attribute("price1d").as_uint();
    			uint32_t price7d = xmlItems.attribute("price7d").as_uint();
    			uint32_t price30d = xmlItems.attribute("price30d").as_uint();
    			uint32_t pricePerm = xmlItems.attribute("pricePerm").as_uint();
    			uint32_t gd_price1d = xmlItems.attribute("gd_price1d").as_uint();
    			uint32_t gd_price7d = xmlItems.attribute("gd_price7d").as_uint();
    			uint32_t gd_price30d = xmlItems.attribute("gd_price30d").as_uint();
    			uint32_t gd_pricePerm = xmlItems.attribute("gd_pricePerm").as_uint();
    
    			addItemToStore(itemId, price1d, price7d, price30d, pricePerm,
    				gd_price1d, gd_price7d, gd_price30d, gd_pricePerm);
                            xmlItems = xmlItems.next_sibling();
    		}
    Because (again) I'm not using the stupid aspx site I don't have a code for asp.net only for PHP so here it is for PHP:
    http://pastebin.com/MBNYaPYY

    BTW If somebody says it doesn't compile:

    Last edited by GigaToni; 20-07-14 at 11:28 AM.




Advertisement