예제 #1
0
// Called when before render is available
bool ShortcutsManager::awake(pugi::xml_node& node)
{
	bool ret = true;

	// Resolvers:
	action_resolver.insert(pair<string, ACTIONS>("FOCUS_ATTACK", FOCUS_ATTACK));
	action_resolver.insert(pair<string, ACTIONS>("LOCATE_JIM_RAYNOR", LOCATE_JIM_RAYNOR));
	action_resolver.insert(pair<string, ACTIONS>("LOCATE_COMMAND_CENTER", LOCATE_COMMAND_CENTER));
	action_resolver.insert(pair<string, ACTIONS>("LOCATE_LAST_ATTACK_POSITION", LOCATE_LAST_ATTACK_POSITION));
	action_resolver.insert(pair<string, ACTIONS>("SAVE_GAME", SAVE_GAME));
	action_resolver.insert(pair<string, ACTIONS>("LOAD_GAME", LOAD_GAME));

	input_type_resolver.insert(pair<string, INPUT_TYPE>("DOWN", DOWN));
	input_type_resolver.insert(pair<string, INPUT_TYPE>("UP", UP));
	input_type_resolver.insert(pair<string, INPUT_TYPE>("REPEAT", REPEAT));

	//Loading shortcuts path xml
	for (node = node.child("shortcut"); node && ret; node = node.next_sibling("shortcut"))
	{
		ShortCut* shortcut = new ShortCut();
		shortcut->type = input_type_resolver.at(node.attribute("type").as_string());
		shortcut->action = action_resolver.at(node.attribute("action").as_string());
		
		shortcut->name = node.attribute("name_action").as_string();
		shortcut->command = node.attribute("key_associated").as_string();

		key_to_action.insert(pair<string, ACTIONS>(shortcut->command, shortcut->action));

		shortcut->active = false;
		shortcuts_list.push_back(shortcut);
	}

	return ret;
}
예제 #2
0
int32_t
GCConfigTest::triggerOperation(pugi::xml_node node)
{
	OMRPORT_ACCESS_FROM_OMRPORT(gcTestEnv->portLib);
	int32_t rt = 0;
	for (; node; node = node.next_sibling()) {
		if (0 == strcmp(node.name(), "systemCollect")) {
			const char *gcCodeStr = node.attribute("gcCode").value();
			if (0 == strcmp(gcCodeStr, "")) {
				/* gcCode defaults to J9MMCONSTANT_IMPLICIT_GC_DEFAULT */
				gcCodeStr = "0";
			}
			uint32_t gcCode = (uint32_t)atoi(gcCodeStr);
			omrtty_printf("Invoking gc system collect with gcCode %d...\n", gcCode);
			rt = (int32_t)OMR_GC_SystemCollect(exampleVM->_omrVMThread, gcCode);
			if (OMR_ERROR_NONE != rt) {
				omrtty_printf("%s:%d Failed to perform OMR_GC_SystemCollect with error code %d.\n", __FILE__, __LINE__, rt);
				goto done;
			}
			OMRGCTEST_CHECK_RT(rt);
			verboseManager->getWriterChain()->endOfCycle(env);
		}
	}
done:
	return rt;
}
예제 #3
0
void CUserProfile::ParseBackpacks(pugi::xml_node& xmlItem)
{
	// enter into items list
	xmlItem = xmlItem.first_child();
	while(!xmlItem.empty())
	{
		uint32_t CharID  = xmlItem.attribute("CharID").as_uint();
		r3d_assert(CharID);
		
		bool found = true;
		for(int i=0; i<ProfileData.NumSlots; i++) 
		{
			if(ProfileData.ArmorySlots[i].LoadoutID == CharID) 
			{
				parseCharBackpack(xmlItem, ProfileData.ArmorySlots[i]);
				found = true;
				break;
			}
		}
		
		if(!found)
			r3dError("bad backpack data for charid %d", CharID);

		xmlItem = xmlItem.next_sibling();
	}
}
예제 #4
0
std::vector<pugi::xml_node> GetChildNodes(pugi::xml_node& node)
{
    std::vector<pugi::xml_node> childNodes;
    node = node.first_child();

    while (node != NULL)
    {
        childNodes.push_back(node);
        node = node.next_sibling();
    }

    return childNodes;
}
예제 #5
0
void CUserProfile::ParseInventory(pugi::xml_node& xmlItem)
{
	ProfileData.NumItems = 0;

	// enter into items list
	xmlItem = xmlItem.first_child();
	while(!xmlItem.empty())
	{
		wiInventoryItem& itm = ProfileData.Inventory[ProfileData.NumItems++];
		r3d_assert(ProfileData.NumItems < wiUserProfile::MAX_INVENTORY_SIZE);

		parseInventoryItem(xmlItem, itm);

		xmlItem = xmlItem.next_sibling();
	}
}
예제 #6
0
static void parseCharBackpack(pugi::xml_node xmlItem, wiCharDataFull& w)
{
	// enter into items list
	xmlItem = xmlItem.first_child();
	while(!xmlItem.empty())
	{
		wiInventoryItem itm;
		parseInventoryItem(xmlItem, itm);

		int slot = xmlItem.attribute("s").as_int();

		r3d_assert(slot >= 0 && slot < w.BackpackSize);
		r3d_assert(w.Items[slot].InventoryID == 0);
		w.Items[slot] = itm;

		xmlItem = xmlItem.next_sibling();
	}

	
	return;
}
예제 #7
0
void CJobGetServerNotes::parseNotes(pugi::xml_node xmlNote)
{
	AllNotes.clear();

	// enter into items list
	xmlNote = xmlNote.first_child();
	while(!xmlNote.empty())
	{
		obj_Note::data_s note;
		note.NoteID     = xmlNote.attribute("NoteID").as_int();
		note.CreateDate = xmlNote.attribute("CreateDate").as_int64();
		note.ExpireMins = xmlNote.attribute("ExpireMins").as_int64();
		note.TextFrom   = xmlNote.attribute("TextFrom").value();
		note.TextSubj   = xmlNote.attribute("TextSubj").value();

		note.in_GamePos = r3dPoint3D(0, 0, 0);
		sscanf(xmlNote.attribute("GamePos").value(), "%f %f %f", &note.in_GamePos.x, &note.in_GamePos.y, &note.in_GamePos.z);
		
		AllNotes.push_back(note);
		xmlNote = xmlNote.next_sibling();
	}
	
	return;
}
예제 #8
0
파일: tile.cpp 프로젝트: MentatKhan/game
/*
Grabs the names and loads the tile sets for the level
spider must be able to get to the "tileset" tags in one edge
stores them in the level::tileset.vector
*/
void level::create_tilesets( pugi::xml_node spider )
{
  //temporary container for tileset image pointer
  SDL_Surface* temp;
  int first, Twidth ,id , last;

  //holds path to source
  char str[256];
  pugi::xml_node name;
  //traverses the Tileset tags in the TMX file
  for( spider = spider.child("tileset"); spider != 0; spider = spider.next_sibling("tileset") )
    {
      //spider is in the <tileset> tag
      //sets first so we can know which prototile we are setting for each tileset
      first = spider.attribute("firstgid").as_int();
      Twidth = spider.attribute("tilewidth").as_int();
      //std::cout << "present tileset first Gid " << temp.first << std::endl;
      name = spider.child("image");

      //makes it so we can open the TMX files 
      strcpy(str, "assets/");
      strcat(str , (char*)name.attribute("source").value() );
      
      if( loadMedia( str  , temp , engine->get_screen()) )
	{
	  //add to vector of tilesets
	  tilesets.push_back(temp);
	  //tiles in this tileset
	  last = name.attribute("width").as_int()/Twidth  ;
	  prototile.resize ( prototile.size() +  last);
	  std::cout <<"prototile is "<< prototile.size() << " tiles big.\n";
	  //set up our prototiles with some basic attributes
	  for(int i = first; i < prototile.size(); i++)
	    {
	      prototile[i] = tile_helper( temp, 16, i-first);
	    }
	  //name.attribute("width").as_int()/Twidth ;
	  //runs through the tile properties and creates prototile vector
	  for( name = name.next_sibling("tile"); name != 0; name = name.next_sibling("tile") );
	    {//in tag <tile> if exists
	      id = name.attribute("id").as_int();
	      
	      
	      
	      //std::cout << "tile id:" << id << " has colision attribute : " << name.child("properties").child_value("property") << std::endl;
	      
	      //prototile[first+id].solid = name.child("properties").child("property").attribute("value").as_int();
	    }
	       
	}
      else
	{
	  SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR,
				   "Tileset creation error",
				   "Now you f****d up This was ment to happen\n go change teh false thing",
				   NULL);
	  exit( 1 );
	}
    }

}
예제 #9
0
파일: items.cpp 프로젝트: Codex-NG/rme
bool ItemDatabase::loadItemFromGameXml(pugi::xml_node itemNode, int id)
{
	ClientVersionID clientVersion = gui.GetCurrentVersionID();
	if(clientVersion < CLIENT_VERSION_980 && id > 20000 && id < 20100) {
		itemNode = itemNode.next_sibling();
		return true;
	} else if(id > 30000 && id < 30100) {
		itemNode = itemNode.next_sibling();
		return true;
	}

	ItemType& it = getItemType(id);

	it.name = itemNode.attribute("name").as_string();
	it.editorsuffix = itemNode.attribute("editorsuffix").as_string();

	pugi::xml_attribute attribute;
	for(pugi::xml_node itemAttributesNode = itemNode.first_child(); itemAttributesNode; itemAttributesNode = itemAttributesNode.next_sibling()) {
		if(!(attribute = itemAttributesNode.attribute("key"))) {
			continue;
		}

		std::string key = attribute.as_string();
		to_lower_str(key);
		if(key == "type") {
			if(!(attribute = itemAttributesNode.attribute("value"))) {
				continue;
			}

			std::string typeValue = attribute.as_string();
			to_lower_str(key);
			if(typeValue == "magicfield") {
				it.group = ITEM_GROUP_MAGICFIELD;
				it.type = ITEM_TYPE_MAGICFIELD;
			} else if(typeValue == "key") {
				it.type = ITEM_TYPE_KEY;
			} else if(typeValue == "depot") {
				it.type = ITEM_TYPE_DEPOT;
			} else if(typeValue == "teleport") {
				it.type = ITEM_TYPE_TELEPORT;
			} else if(typeValue == "bed") {
				it.type = ITEM_TYPE_BED;
			} else if(typeValue == "door") {
				it.type = ITEM_TYPE_DOOR;
			} else {
				// We ignore many types, no need to complain
				//warnings.push_back("items.xml: Unknown type " + typeValue);
			}
		} else if(key == "name") {
			if((attribute = itemAttributesNode.attribute("value"))) {
				it.name = attribute.as_string();
			}
		} else if(key == "description") {
			if((attribute = itemAttributesNode.attribute("value"))) {
				it.description = attribute.as_string();
			}
		}else if(key == "runespellName") {
			/*if((attribute = itemAttributesNode.attribute("value"))) {
				it.runeSpellName = attribute.as_string();
			}*/
		} else if(key == "weight") {
			if((attribute = itemAttributesNode.attribute("value"))) {
				it.weight = pugi::cast<int32_t>(attribute.value()) / 100.f;
			}
		} else if(key == "armor") {
			if((attribute = itemAttributesNode.attribute("value"))) {
				it.armor = pugi::cast<int32_t>(attribute.value());
			}
		} else if(key == "defense") {
			if((attribute = itemAttributesNode.attribute("value"))) {
				it.defense = pugi::cast<int32_t>(attribute.value());
			}
		} else if(key == "rotateto") {
			if((attribute = itemAttributesNode.attribute("value"))) {
				it.rotateTo = pugi::cast<int32_t>(attribute.value());
			}
		} else if(key == "containersize") {
			if((attribute = itemAttributesNode.attribute("value"))) {
				it.volume = pugi::cast<int32_t>(attribute.value());
			}
		} else if(key == "readable") {
			if((attribute = itemAttributesNode.attribute("value"))) {
				it.canReadText = attribute.as_bool();
			}
		} else if(key == "writeable") {
			if((attribute = itemAttributesNode.attribute("value"))) {
				it.canWriteText = it.canReadText = attribute.as_bool();
			}
		} else if(key == "decayto") {
			it.decays = true;
		} else if(key == "maxtextlen" || key == "maxtextlength") {
			if((attribute = itemAttributesNode.attribute("value"))) {
				it.maxTextLen = pugi::cast<int32_t>(attribute.value());
				it.canReadText = it.maxTextLen > 0;
			}
		} else if(key == "writeonceitemid") {
			/*if((attribute = itemAttributesNode.attribute("value"))) {
				it.writeOnceItemId = pugi::cast<int32_t>(attribute.value());
			}*/
		} else if(key == "allowdistread") {
			if((attribute = itemAttributesNode.attribute("value"))) {
				it.allowDistRead = attribute.as_bool();
			}
		} else if(key == "charges") {
			if((attribute = itemAttributesNode.attribute("value"))) {
				it.charges = pugi::cast<int32_t>(attribute.value());
				it.extra_chargeable = true;
			}
		}
	}
	return true;
}
예제 #10
0
void load_equation(Equation& current_node, pugi::xml_node& xml_equ) {

    pugi::xml_node eq_type = xml_equ.first_child();
    current_node.type = eq_type.name();

    if( std::strcmp(eq_type.name(),"assign") == 0) {

        pugi::xml_node current = eq_type.first_child();

        while(std::strcmp(current.name(),"defines") == 0) {
            current_node.lhs.insert(current.attribute("name").value());
            current = current.next_sibling();
        }


        while(std::strcmp(current.name(),"depends") == 0) {
            current_node.rhs.insert(current.attribute("name").value());
            current = current.next_sibling();
        }

        current_node.cost = 1;
    }
    else if( std::strcmp(eq_type.name(),"statement") == 0) {

        pugi::xml_node current = eq_type.first_child();

        while(std::strcmp(current.name(),"defines") == 0) {
            current_node.lhs.insert(current.attribute("name").value());
            current = current.next_sibling();
        }


        while(std::strcmp(current.name(),"depends") == 0) {
            current_node.rhs.insert(current.attribute("name").value());
            current = current.next_sibling();
        }

        current_node.cost = 1;
    }
    else if( std::strcmp(eq_type.name(),"when") == 0) {

        pugi::xml_node current = eq_type.first_child();
        current_node.rhs.insert(current.child_value());
        current = current.next_sibling();

        while(std::strcmp(current.name(),"defines") == 0) {
            current_node.lhs.insert(current.attribute("name").value());
            current = current.next_sibling();
        }


        while(std::strcmp(current.name(),"depends") == 0) {
            current_node.rhs.insert(current.attribute("name").value());
            current = current.next_sibling();
        }

        current_node.cost = 2;
    }

    else if( std::strcmp(eq_type.name(),"linear") == 0) {

        pugi::xml_node current = eq_type.first_child();

        int ls_size = 0;
        while(std::strcmp(current.name(),"defines") == 0) {
            current_node.lhs.insert(current.attribute("name").value());
            current = current.next_sibling();
            ++ls_size;
        }

        while(std::strcmp(current.name(),"depends") == 0) {
            current_node.rhs.insert(current.attribute("name").value());
            current = current.next_sibling();
        }

        current_node.cost = ls_size;
        utility::warning() << current_node.index << ": Linear equations not fully handled yet: " << ls_size << newl;
    }

    else if( std::strcmp(eq_type.name(),"nonlinear") == 0) {

        pugi::xml_node current = eq_type.first_child();

        int nls_size = 0;
        while(std::strcmp(current.name(),"defines") == 0) {
            current_node.lhs.insert(current.attribute("name").value());
            current = current.next_sibling();
            ++nls_size;
        }

        while(std::strcmp(current.name(),"depends") == 0) {
            current_node.rhs.insert(current.attribute("name").value());
            current = current.next_sibling();
        }

        current_node.cost = nls_size;
        utility::warning() << current_node.index << ": Non linear equations not fully handled yet: " << nls_size << newl;
    }

    else if( std::strcmp(eq_type.name(),"mixed") == 0) {

        int mix_size = eq_type.attribute("size").as_int();

        pugi::xml_node current = eq_type.first_child();

        while(std::strcmp(current.name(),"defines") == 0) {
            current_node.lhs.insert(current.attribute("name").value());
            current = current.next_sibling();
        }

        current_node.cost = mix_size;

        for(int count = 0; count < mix_size; ++count) {
            xml_equ = xml_equ.next_sibling();
            Equation mix_eq_node;
            load_node(mix_eq_node, xml_equ);
            current_node.lhs.insert(mix_eq_node.lhs.begin(), mix_eq_node.lhs.end());
            current_node.rhs.insert(mix_eq_node.rhs.begin(), mix_eq_node.rhs.end());
        }

        utility::warning() << current_node.index << ": Mixed equations not fully handled yet: " << mix_size << newl;
    }

    else {
        current_node.cost = 1;
        utility::error() << current_node.index << ": Unknown Equation type." << eq_type.name() << newl;
    }


}
예제 #11
0
void CUserProfile::ParseLoadouts(pugi::xml_node& xmlItem)
{
	// reset current backpacks
	for(int i=0; i<ProfileData.NumSlots; i++) {
		for(int j=0; j<ProfileData.ArmorySlots[i].BackpackSize; j++) {
			ProfileData.ArmorySlots[i].Items[j].Reset();
		}
	}

	ProfileData.NumSlots = 0;
	
	// parse all slots
	xmlItem = xmlItem.first_child();
	while(!xmlItem.empty())
	{
		wiCharDataFull& w = ProfileData.ArmorySlots[ProfileData.NumSlots++];
		wiStats& st = w.Stats;
		if(ProfileData.NumSlots > wiUserProfile::MAX_LOADOUT_SLOTS)
			r3dError("more that 6 profiles!");

		w.LoadoutID   = xmlItem.attribute("CharID").as_uint();
		r3dscpy(w.Gamertag, xmlItem.attribute("Gamertag").value());
		w.Alive       = xmlItem.attribute("Alive").as_int();
		w.Hardcore    = xmlItem.attribute("Hardcore").as_int();
		st.XP         = xmlItem.attribute("XP").as_int();
		st.TimePlayed = xmlItem.attribute("TimePlayed").as_int();
		w.Health      = xmlItem.attribute("Health").as_float();
		w.Hunger      = xmlItem.attribute("Hunger").as_float();
		w.Thirst      = xmlItem.attribute("Thirst").as_float();
		w.Toxic       = xmlItem.attribute("Toxic").as_float();
		st.Reputation = xmlItem.attribute("Reputation").as_int();
		w.DeathUtcTime= xmlItem.attribute("DeathTime").as_int64();
		w.SecToRevive = xmlItem.attribute("SecToRevive").as_int();

		w.GameMapId   = xmlItem.attribute("GameMapId").as_int();
		w.GameServerId= xmlItem.attribute("GameServerId").as_int();
		w.GamePos = r3dPoint3D(0, 0, 0);
	    if (w.GameMapId == 5) // Colorado_pve
            sscanf(xmlItem.attribute("GamePos2").value(), "%f %f %f %f", &w.GamePos.x, &w.GamePos.y, &w.GamePos.z, &w.GameDir);
		else if (w.GameMapId == 6) // ATLANTA
            sscanf(xmlItem.attribute("GamePos3").value(), "%f %f %f %f", &w.GamePos.x, &w.GamePos.y, &w.GamePos.z, &w.GameDir);	
		else if (w.GameMapId == 8) // VALLEY
            sscanf(xmlItem.attribute("GamePos4").value(), "%f %f %f %f", &w.GamePos.x, &w.GamePos.y, &w.GamePos.z, &w.GameDir);	
		else	
		sscanf(xmlItem.attribute("GamePos").value(), "%f %f %f %f", &w.GamePos.x, &w.GamePos.y, &w.GamePos.z, &w.GameDir);
		w.GameFlags   = xmlItem.attribute("GameFlags").as_int();

		w.HeroItemID  = xmlItem.attribute("HeroItemID").as_int();
		w.HeadIdx     = xmlItem.attribute("HeadIdx").as_int();
		w.BodyIdx     = xmlItem.attribute("BodyIdx").as_int();
		w.LegsIdx     = xmlItem.attribute("LegsIdx").as_int();

		w.ClanID      = xmlItem.attribute("ClanID").as_int();
		w.GroupID      = xmlItem.attribute("GroupID").as_int();//ViruZ Group
		w.ClanRank    = xmlItem.attribute("ClanRank").as_int();
		r3dscpy(w.ClanTag, xmlItem.attribute("ClanTag").value());
		w.ClanTagColor= xmlItem.attribute("ClanTagColor").as_int();

		const char* attm1 = xmlItem.attribute("attm1").value();
		const char* attm2 = xmlItem.attribute("attm2").value();
		parseCharAttachments(attm1, w.Attachment[0]);
		parseCharAttachments(attm2, w.Attachment[1]);

		w.BackpackID   = xmlItem.attribute("BackpackID").as_uint();
		w.BackpackSize = xmlItem.attribute("BackpackSize").as_int();
		
		// trackable stats
		st.KilledZombies   = xmlItem.attribute("ts00").as_int();
		st.KilledSurvivors = xmlItem.attribute("ts01").as_int();
		st.KilledBandits   = xmlItem.attribute("ts02").as_int();

		// skill xp
		st.SkillXPPool = st.XP;

		//SkillSystem
		st.skillid0 = xmlItem.attribute("SkillID0").as_int();
		st.skillid1 = xmlItem.attribute("SkillID1").as_int();
		st.skillid2 = xmlItem.attribute("SkillID2").as_int();
		st.skillid3 = xmlItem.attribute("SkillID3").as_int();
		st.skillid4 = xmlItem.attribute("SkillID4").as_int();
		st.skillid5 = xmlItem.attribute("SkillID5").as_int();
		st.skillid6 = xmlItem.attribute("SkillID6").as_int();
		st.skillid7 = xmlItem.attribute("SkillID7").as_int();
		st.skillid8 = xmlItem.attribute("SkillID8").as_int();
		st.skillid9 = xmlItem.attribute("SkillID9").as_int();
		st.skillid10 = xmlItem.attribute("SkillID10").as_int();
		st.skillid11 = xmlItem.attribute("SkillID11").as_int();
		st.skillid12 = xmlItem.attribute("SkillID12").as_int();
		st.skillid13 = xmlItem.attribute("SkillID13").as_int();
		st.skillid14 = xmlItem.attribute("SkillID14").as_int();
		st.skillid15 = xmlItem.attribute("SkillID15").as_int();
		st.skillid16 = xmlItem.attribute("SkillID16").as_int();
		st.skillid17 = xmlItem.attribute("SkillID17").as_int();
		st.skillid18 = xmlItem.attribute("SkillID18").as_int();
		st.skillid19 = xmlItem.attribute("SkillID19").as_int();
		st.skillid20 = xmlItem.attribute("SkillID20").as_int();
		st.skillid21 = xmlItem.attribute("SkillID21").as_int();
		st.skillid22 = xmlItem.attribute("SkillID22").as_int();
		st.skillid23 = xmlItem.attribute("SkillID23").as_int();
		st.skillid24 = xmlItem.attribute("SkillID24").as_int();
		st.skillid25 = xmlItem.attribute("SkillID25").as_int();
		st.skillid26 = xmlItem.attribute("SkillID26").as_int();
		st.skillid27 = xmlItem.attribute("SkillID27").as_int();
		st.skillid28 = xmlItem.attribute("SkillID28").as_int();
		st.skillid29 = xmlItem.attribute("SkillID29").as_int();
		st.skillid30 = xmlItem.attribute("SkillID30").as_int();
		st.skillid31 = xmlItem.attribute("SkillID31").as_int();
		st.skillid32 = xmlItem.attribute("SkillID32").as_int();
		st.skillid33 = xmlItem.attribute("SkillID33").as_int();

		xmlItem = xmlItem.next_sibling();
	}
}