diff formats/src/th06/anm0.rs @ 765:2a5279168d5a

formats: Use a BTreeMap instead of a HashMap for scripts
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Tue, 30 Aug 2022 17:03:02 +0200
parents 21b186be2590
children 8a3b8e2ffa24
line wrap: on
line diff
--- a/formats/src/th06/anm0.rs
+++ b/formats/src/th06/anm0.rs
@@ -7,7 +7,7 @@ use nom::{
     sequence::tuple,
     multi::{many_m_n, many0},
 };
-use std::collections::HashMap;
+use std::collections::BTreeMap;
 
 /// Coordinates of a sprite into the image.
 #[derive(Debug, Clone)]
@@ -45,7 +45,7 @@ pub struct Script {
     pub instructions: Vec<Call>,
 
     /// List of interrupts in this script.
-    pub interrupts: HashMap<i32, u8>
+    pub interrupts: BTreeMap<i32, u8>
 }
 
 /// Main struct of the ANM0 animation format.
@@ -67,7 +67,7 @@ pub struct Anm0 {
     pub sprites: Vec<Sprite>,
 
     /// A map of scripts.
-    pub scripts: HashMap<u8, Script>,
+    pub scripts: BTreeMap<u8, Script>,
 }
 
 impl Anm0 {
@@ -216,7 +216,7 @@ fn parse_anm0(input: &[u8]) -> IResult<&
         sprites.push(sprite);
     }
 
-    let mut scripts = HashMap::new();
+    let mut scripts = BTreeMap::new();
     for (index, offset) in script_offsets.into_iter().map(|(index, offset)| (index as u8, offset as usize)) {
         if input.len() < offset {
             return Err(nom::Err::Failure(nom::error::Error::new(input, nom::error::ErrorKind::Eof)));
@@ -237,7 +237,7 @@ fn parse_anm0(input: &[u8]) -> IResult<&
                 break;
             }
         }
-        let mut interrupts = HashMap::new();
+        let mut interrupts = BTreeMap::new();
         let mut j = 0;
         for Call { time: _, instr } in &mut instructions {
             match instr {