chiark / gitweb /
Revert "hidden: Change type of Occultation::pieces to contain Index"
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 1 Mar 2021 18:24:56 +0000 (18:24 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 1 Mar 2021 18:24:56 +0000 (18:24 +0000)
We are going to do this differently.

This reverts commit 97d536cba692b1f0030262c168a4ec875ac1b749.

src/hidden.rs
src/prelude.rs

index 1705e15e5f88626b87778cff1cc0539e298116c0..9cdd2722a380e984bde4e83f233ef64f343b4956 100644 (file)
@@ -24,15 +24,11 @@ pub struct PieceOccult {
   passive: Option<OccId>, // kept in synch with Occultation::pieces
 }
 
-pub type DisplacementIndex = usize;
-
 #[derive(Clone,Debug,Serialize,Deserialize)]
 pub struct Occultation {
   region: Area, // automatically affect pieces here
   occulter: PieceId, // kept in synch with PieceOccult::active
-  // kept synch with PO::passive.  indices are either 0 or dense, 0..len()
-  // except after recalculate_occultation_general and before xxx tbd
-  pieces: BTreeMap<PieceId, DisplacementIndex>,
+  pieces: BTreeSet<PieceId>, // kept in synch with PieceOccult::passive
   #[serde(flatten)] views: OccultationViews,
 }
 
@@ -411,7 +407,7 @@ fn recalculate_occultation_general<
       }
     };
     update_pieces(ONI::Old, &|opcs|{ opcs.remove(&piece); });
-    update_pieces(ONI::New, &|opcs|{ opcs.insert(piece,0); });
+    update_pieces(ONI::New, &|opcs|{ opcs.insert(piece); });
     gpieces.byid_mut(piece).unwrap().occult.passive = *occids.new();
   })(); // <- no ?, infallible commitment
 
@@ -653,14 +649,14 @@ pub fn remove_occultation(
     pieces_fallback_buf = gpieces
       .iter()
       .filter_map(|(ppiece, pgpc)| {
-        if pgpc.occult.passive == Some(occid) { Some((ppiece,0)) }
+        if pgpc.occult.passive == Some(occid) { Some(ppiece) }
         else { None }
       })
       .collect();
     &pieces_fallback_buf
   };
   
-  for (&ppiece,_) in pieces.iter() {
+  for &ppiece in pieces.iter() {
     recalculate_occultation_ofmany(gplayers, gpieces, goccults, ipieces,
                                    &mut to_recompute,
                                    ppiece, &mut updates)
index 25c67022a1ee0bba13f6d5f55f842790f818e898..17d4d232ad9c187a77298edec5bb80d657328b20 100644 (file)
@@ -11,7 +11,7 @@ pub use std::borrow::Borrow;
 pub use std::borrow::Cow;
 pub use std::cmp::{self, max, min, Ordering};
 pub use std::collections::VecDeque;
-pub use std::collections::{btree_map, btree_set, BTreeMap, BTreeSet};
+pub use std::collections::{btree_set, BTreeSet};
 pub use std::collections::{hash_map, HashMap, HashSet};
 pub use std::convert::{Infallible, TryFrom, TryInto};
 pub use std::env;