예제 #1
0
void Resource::loadGame(const XmlNode *rootNode, int index,const TechTree *techTree) {
	vector<XmlNode *> resourceNodeList = rootNode->getChildList("Resource");

	if(index < resourceNodeList.size()) {
		XmlNode *resourceNode = resourceNodeList[index];

		amount = resourceNode->getAttribute("amount")->getIntValue();
		type = techTree->getResourceType(resourceNode->getAttribute("type")->getValue());
		pos = Vec2i::strToVec2(resourceNode->getAttribute("pos")->getValue());
		balance = resourceNode->getAttribute("balance")->getIntValue();
	}
}
예제 #2
0
파일: skill_type.cpp 프로젝트: glestadv/GAE
void MoveSkillType::load(const XmlNode *sn, const string &dir, const TechTree *tt, const UnitType *ft) {
	SkillType::load(sn, dir, tt, ft);

	XmlNode *visibleOnlyNode = sn->getOptionalChild("visible-only");
	if (visibleOnlyNode) {
		visibleOnly = visibleOnlyNode->getAttribute("value")->getBoolValue();
	}
}
예제 #3
0
Glib::ustring MameXmlReader::parseRomBlock(XmlNode& node)
{
	Glib::ustring crc;

	/*
	 * Estructura de un bloque rom:
	 *
	 * <rom/disk name="" bios="" size="" crc="" md5="" sha1="" merge="" region="" offset="" status="baddump|nodump|good" date="" optional="yes/no" />
	 *
	 */
	// Obtenemos el nombre del set
		node.getAttribute("crc", crc);
		return crc;
}
예제 #4
0
void Selection::loadGame(const XmlNode *rootNode, World *world) {

	const XmlNode *selectionNode = rootNode->getChild("Selection");

	factionIndex = selectionNode->getAttribute("factionIndex")->getIntValue();
	teamIndex = selectionNode->getAttribute("teamIndex")->getIntValue();
	if(selectionNode->hasAttribute("allowSharedTeamUnits") == true) {
		allowSharedTeamUnits = (selectionNode->getAttribute("allowSharedTeamUnits")->getIntValue() != 0);
	}

	vector<XmlNode *> selectedUnitsNodeList = selectionNode->getChildList("selectedUnits");
	for(unsigned int i = 0; i < selectedUnitsNodeList.size(); ++i) {
		XmlNode *selectedUnitsNode = selectedUnitsNodeList[i];

		int unitId = selectedUnitsNode->getAttribute("unitId")->getIntValue();
		Unit *unit = world->findUnitById(unitId);
		//assert(unit != NULL);
		//printf("#1 Unit [%s], group: %d\n",unit->getType()->getName().c_str(),i);
		selectedUnits.push_back(unit);
	}

	vector<XmlNode *> groupsNodeList = selectionNode->getChildList("groups");
	for(unsigned int i = 0; i < groupsNodeList.size(); ++i) {
		XmlNode *groupsNode = groupsNodeList[i];

		vector<XmlNode *> selectedGroupsUnitsNodeList = groupsNode->getChildList("selectedUnits");
		for(unsigned int j = 0; j < selectedGroupsUnitsNodeList.size(); ++j) {
			XmlNode *selectedGroupsUnitsNode = selectedGroupsUnitsNodeList[j];

			int unitId = selectedGroupsUnitsNode->getAttribute("unitId")->getIntValue();
			Unit *unit = world->findUnitById(unitId);
			//assert(unit != NULL);
			//printf("Unit #2 [%s], group: %d\n",unit->getType()->getName().c_str(),i);
			groups[i].push_back(unit);
		}
	}
}
예제 #5
0
void Stats::loadGame(const XmlNode *rootNode) {
	const XmlNode *statsNode = rootNode->getChild("Stats");

	//	PlayerStats playerStats[GameConstants::maxPlayers];

	vector<XmlNode *> statsNodePlayerList = statsNode->getChildList("Player");
	for(unsigned int i = 0; i < statsNodePlayerList.size(); ++i) {
		XmlNode *statsNodePlayer = statsNodePlayerList[i];
		PlayerStats &stat = playerStats[i];

	//		ControlType control;
		stat.control = static_cast<ControlType>(statsNodePlayer->getAttribute("control")->getIntValue());
	//		float resourceMultiplier;
		stat.resourceMultiplier = statsNodePlayer->getAttribute("resourceMultiplier")->getFloatValue();
	//		string factionTypeName;
		stat.factionTypeName = statsNodePlayer->getAttribute("factionTypeName")->getValue();
	//		FactionPersonalityType personalityType;
		stat.personalityType = static_cast<FactionPersonalityType>(statsNodePlayer->getAttribute("personalityType")->getIntValue());
	//		int teamIndex;
		stat.teamIndex = statsNodePlayer->getAttribute("teamIndex")->getIntValue();
	//		bool victory;
		stat.victory = statsNodePlayer->getAttribute("victory")->getIntValue() != 0;
	//		int kills;
		stat.kills = statsNodePlayer->getAttribute("kills")->getIntValue();
	//		int enemykills;
		stat.enemykills = statsNodePlayer->getAttribute("enemykills")->getIntValue();
	//		int deaths;
		stat.deaths = statsNodePlayer->getAttribute("deaths")->getIntValue();
	//		int unitsProduced;
		stat.unitsProduced = statsNodePlayer->getAttribute("unitsProduced")->getIntValue();
	//		int resourcesHarvested;
		stat.resourcesHarvested = statsNodePlayer->getAttribute("resourcesHarvested")->getIntValue();
	//		string playerName;
		stat.playerName = statsNodePlayer->getAttribute("playerName")->getValue();
	//		Vec3f playerColor;
		stat.playerColor = Vec3f::strToVec3(statsNodePlayer->getAttribute("playerColor")->getValue());
	}
	//	string description;
	//statsNode->addAttribute("description",description, mapTagReplacements);
	description = statsNode->getAttribute("description")->getValue();
	//	int factionCount;
	factionCount = statsNode->getAttribute("factionCount")->getIntValue();
	//	int thisFactionIndex;
	thisFactionIndex = statsNode->getAttribute("thisFactionIndex")->getIntValue();
	//
	//	float worldTimeElapsed;
	worldTimeElapsed = statsNode->getAttribute("worldTimeElapsed")->getFloatValue();
	//	int framesPlayed;
	framesPlayed = statsNode->getAttribute("framesPlayed")->getIntValue();
	//	int framesToCalculatePlaytime;
	framesToCalculatePlaytime = statsNode->getAttribute("framesToCalculatePlaytime")->getIntValue();
	//	int maxConcurrentUnitCount;
	maxConcurrentUnitCount = statsNode->getAttribute("maxConcurrentUnitCount")->getIntValue();
	//	int totalEndGameConcurrentUnitCount;
	totalEndGameConcurrentUnitCount = statsNode->getAttribute("totalEndGameConcurrentUnitCount")->getIntValue();
	//	bool isMasterserverMode;
}
예제 #6
0
bool MameXmlReader::parseGameBlock(DatSet& set, XmlNode& node)
{
	Glib::ustring value;
	XmlNode::iterator iter;

	/*
	 * Estructura de un bloque game:
	 *
	 *	<game name="" sourcefile="" isbios=yes/no isdevice=yes/no ismechanical=yes/no runnable="yes/no" cloneof="" romof="" sampleof="" >
	 *		<description></description>
	 *		<year></year>
	 *		<manufacturer></manufacturer>
	 *		<biosset />
	 *		<rom />
	 *		<disk />
	 *		<device_ref />
	 *		<sample />
	 *		<chip />
	 *		<display />
	 *		<sound />
	 *		<input service=yes/no tilt=yes/no players="" buttons="" coins=""></input>
	 *		<dipswitch></dipswitch>
	 *		<configuration></configuration>
	 *		<port></port>
	 *		<adjuster />
	 *		<category></category>	// Aparece en xml's viejos, pero nunca se usa
	 *		<driver />
	 *		<device></device>
	 *		<slot></slot>
	 *		<softwarelist />
	 *		<ramoption />
	 *	</game>
	 *
	 */
	set.name.clear();
	set.description.clear();
	set.year.clear();
	set.manufacturer.clear();
	set.clone_of.clear();
	set.crc.clear();
	set.players = 1;

	node.getAttribute("name", set.name);
	// Comprobamos si es un set bios y si debemos parserlos
	node.getAttribute("isbios", value);
	set.is_bios = (value == "yes" ? true : false);
	node.getAttribute("cloneof", set.clone_of);
	// Recorremos todos los nodos del set
	for (iter = node.begin(); iter != node.end(); ++iter)
	{
		value = iter->getName();
		if (value == "description")
		{
			iter->getContent(set.description);
		}
		else if (value == "year")
		{
			iter->getContent(set.year);
		}
		else if (value == "manufacturer")
		{
			iter->getContent(set.manufacturer);
		}
		else if ((value == "rom") && set.crc.empty())
		{
			set.crc = parseRomBlock(*iter);
		}
		else if (value == "input")
		{
			iter->getAttribute("players", set.players);
		}
	}
	return true;
}