diff --git a/lib/src/saves/def/mod.rs b/lib/src/saves/def/mod.rs index abaff76..e9e3f25 100644 --- a/lib/src/saves/def/mod.rs +++ b/lib/src/saves/def/mod.rs @@ -25,6 +25,12 @@ pub type AreaId = u16; /// The root of a celeste save file #[derive(Serialize, Deserialize, Debug, Clone)] pub struct SaveData { + #[doc(hidden)] + #[serde(rename(serialize = "@xmlns:xsi", deserialize = "@xmlns:xsi"))] + xsi_url: String, + #[doc(hidden)] + #[serde(rename(serialize = "@xmlns:xsd", deserialize = "@xmlns:xsd"))] + xsd_url: String, /// The last celeste version that the save file was opened with #[serde(rename = "Version")] pub version: String, diff --git a/lib/src/saves/ops/mod.rs b/lib/src/saves/ops/mod.rs index 4943940..7952b24 100644 --- a/lib/src/saves/ops/mod.rs +++ b/lib/src/saves/ops/mod.rs @@ -24,6 +24,8 @@ pub mod session; pub mod util; pub mod vanilla; +const XML_VERSION_HEADER: &str = r#""#; + fn area_sid_matches(area: &AreaStats, sid: &str) -> bool { area.def.sid.as_ref().is_some_and(|a_sid| a_sid == sid) } @@ -39,10 +41,13 @@ impl SaveData { } pub fn to_string(&self) -> Result { - quick_xml::se::to_string(&self) + let mut xml = XML_VERSION_HEADER.to_owned(); + xml.push_str(&quick_xml::se::to_string(&self)?); + Ok(xml) } - pub fn to_writer(&self, writer: impl Write) -> Result<(), DeError> { + pub fn to_writer(&self, mut writer: impl Write) -> Result<(), DeError> { + writer.write_str(XML_VERSION_HEADER)?; quick_xml::se::to_writer(writer, &self) }