Implement RemoveObject and RemoveObject2 tags

This commit is contained in:
Mike Welsh 2016-09-07 22:48:20 -07:00
parent 95c3e12c4f
commit 26d9158fb4
3 changed files with 25 additions and 0 deletions

View File

@ -349,6 +349,20 @@ impl<R: Read> Reader<R> {
Some(TagCode::PlaceObject2) => try!(tag_reader.read_place_object_2()),
//Some(TagCode::PlaceObject3) => try!(tag_reader.read_place_object_3()),
Some(TagCode::RemoveObject) => {
Tag::RemoveObject {
character_id: Some(try!(tag_reader.read_u16())),
depth: try!(tag_reader.read_i16()),
}
},
Some(TagCode::RemoveObject2) => {
Tag::RemoveObject {
depth: try!(tag_reader.read_i16()),
character_id: None,
}
},
_ => {
let size = length as usize;
let mut data = Vec::with_capacity(size);

View File

@ -180,6 +180,7 @@ pub enum Tag {
SetBackgroundColor(Color),
PlaceObject(Box<PlaceObject>),
RemoveObject { depth: Depth, character_id: Option<CharacterId> },
FileAttributes(FileAttributes),

View File

@ -317,6 +317,16 @@ impl<W: Write> Writer<W> {
_ => return Err(Error::new(ErrorKind::InvalidData, "Invalid PlaceObject version.")),
},
&Tag::RemoveObject { depth, character_id } => {
if let Some(id) = character_id {
try!(self.write_tag_header(TagCode::RemoveObject, 4));
try!(self.write_u16(id));
} else {
try!(self.write_tag_header(TagCode::RemoveObject2, 2));
}
try!(self.write_i16(depth));
},
&Tag::FileAttributes(ref attributes) => {
try!(self.write_tag_header(TagCode::FileAttributes, 4));
let mut flags = 0u32;