コード例 #1
0
ファイル: xml.cpp プロジェクト: ArkyRomania/ufoai
/**
 * @brief add a Pos2 data to the XML Tree
 * @param[out] parent XML Node structure to add to
 * @param[in] name Name of the node to add
 * @param[in] pos Pos2 structure with position data
 * @note it creates a new node and adds coordinate(s) to the node as attributes
 */
void XML_AddPos2 (xmlNode_t* parent, const char* name, const vec2_t pos)
{
	xmlNode_t* t;
	t = mxmlNewElement(parent, name);
	XML_AddFloat(t, "x", pos[0]);
	XML_AddFloat(t, "y", pos[1]);
}
コード例 #2
0
ファイル: cp_installation.c プロジェクト: kevlund/ufoai
/**
 * @brief Save callback for savegames in xml
 * @param[out] p XML Node structure, where we write the information to
 * @sa INS_LoadXML
 * @sa SAV_GameSaveXML
 */
qboolean INS_SaveXML (xmlNode_t *p)
{
	xmlNode_t *n;
	installation_t *inst;

	n = XML_AddNode(p, SAVE_INSTALLATION_INSTALLATIONS);
	Com_RegisterConstList(saveInstallationConstants);
	INS_Foreach(inst) {
		xmlNode_t *s, *ss;

		s = XML_AddNode(n, SAVE_INSTALLATION_INSTALLATION);
		XML_AddString(s, SAVE_INSTALLATION_TEMPLATEID, inst->installationTemplate->id);
		XML_AddInt(s, SAVE_INSTALLATION_IDX, inst->idx);
		XML_AddString(s, SAVE_INSTALLATION_NAME, inst->name);
		XML_AddPos3(s, SAVE_INSTALLATION_POS, inst->pos);
		XML_AddString(s, SAVE_INSTALLATION_STATUS, Com_GetConstVariable(SAVE_INSTALLATIONSTATUS_NAMESPACE, inst->installationStatus));
		XML_AddInt(s, SAVE_INSTALLATION_DAMAGE, inst->installationDamage);
		XML_AddFloat(s, SAVE_INSTALLATION_ALIENINTEREST, inst->alienInterest);
		XML_AddInt(s, SAVE_INSTALLATION_BUILDSTART, inst->buildStart);

		ss = XML_AddNode(s, SAVE_INSTALLATION_BATTERIES);
		XML_AddIntValue(ss, SAVE_INSTALLATION_NUM, inst->numBatteries);
		B_SaveBaseSlotsXML(inst->batteries, inst->numBatteries, ss);
	}
	Com_UnregisterConstList(saveInstallationConstants);
	return qtrue;
}
コード例 #3
0
/**
 * @brief Save callback for savegames in XML Format
 * @param[out] parent XML Node structure, where we write the information to
 */
qboolean AIRFIGHT_SaveXML (xmlNode_t *parent)
{
	int i;

	for (i = 0; i < ccs.numProjectiles; i++) {
		int j;
		aircraftProjectile_t *projectile = &ccs.projectiles[i];
		xmlNode_t *node = XML_AddNode(parent, SAVE_AIRFIGHT_PROJECTILE);

		XML_AddString(node, SAVE_AIRFIGHT_ITEMID, projectile->aircraftItem->id);
		for (j = 0; j < projectile->numProjectiles; j++)
			XML_AddPos2(node, SAVE_AIRFIGHT_POS, projectile->pos[j]);
		XML_AddPos3(node, SAVE_AIRFIGHT_IDLETARGET, projectile->idleTarget);

		XML_AddInt(node, SAVE_AIRFIGHT_TIME, projectile->time);
		XML_AddFloat(node, SAVE_AIRFIGHT_ANGLE, projectile->angle);
		XML_AddBoolValue(node, SAVE_AIRFIGHT_BULLET, projectile->bullets);
		XML_AddBoolValue(node, SAVE_AIRFIGHT_BEAM, projectile->beam);

		if (projectile->attackingAircraft) {
			xmlNode_t *attacking =  XML_AddNode(node, SAVE_AIRFIGHT_ATTACKINGAIRCRAFT);

			XML_AddBoolValue(attacking, SAVE_AIRFIGHT_ISUFO, projectile->attackingAircraft->type == AIRCRAFT_UFO);
			if (projectile->attackingAircraft->type == AIRCRAFT_UFO)
				XML_AddInt(attacking, SAVE_AIRFIGHT_AIRCRAFTIDX, UFO_GetGeoscapeIDX(projectile->attackingAircraft));
			else
				XML_AddInt(attacking, SAVE_AIRFIGHT_AIRCRAFTIDX, projectile->attackingAircraft->idx);
		}

		if (projectile->aimedAircraft) {
			xmlNode_t *aimed =  XML_AddNode(node, SAVE_AIRFIGHT_AIMEDAIRCRAFT);

			XML_AddBoolValue(aimed, SAVE_AIRFIGHT_ISUFO, projectile->aimedAircraft->type == AIRCRAFT_UFO);
			if (projectile->aimedAircraft->type == AIRCRAFT_UFO)
				XML_AddInt(aimed, SAVE_AIRFIGHT_AIRCRAFTIDX, UFO_GetGeoscapeIDX(projectile->aimedAircraft));
			else
				XML_AddInt(aimed, SAVE_AIRFIGHT_AIRCRAFTIDX, projectile->aimedAircraft->idx);
		}
	}

	return qtrue;
}