chiark / gitweb /
rename IPieces and GPieces
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 27 Feb 2021 13:25:55 +0000 (13:25 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 27 Feb 2021 13:25:55 +0000 (13:25 +0000)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/gamestate.rs
src/global.rs
src/hidden.rs

index c091edc2d97e7b0c7cf97acf532b8c56d1a0d788..9bf15cb0ec61ccf8a83ea40864f7f4bdd9bab0e6 100644 (file)
@@ -53,7 +53,7 @@ pub struct ZLevel {
 pub struct GameState {
   pub table_colour: Colour,
   pub table_size: Pos,
-  pub pieces: Pieces,
+  pub pieces: GPieces,
   pub gen: Generation,
   pub log: VecDeque<(Generation, Arc<CommittedLogEntry>)>,
   pub max_z: ZCoord,
@@ -171,7 +171,7 @@ pub trait Piece: Outline + Send + Debug {
 #[derive(Debug)]
 pub struct ApiPieceOpArgs<'a> {
   pub gs: &'a mut GameState,
-  pub ipieces: &'a PiecesLoaded,
+  pub ipieces: &'a IPieces,
   pub player: PlayerId,
   pub piece: PieceId,
   pub p: &'a dyn Piece,
index cad764ea5c7cb421f210c2d98c078d60fc1c54cd..5159df2cbbc5435995500d37afcb0b5dcff3d736 100644 (file)
@@ -45,7 +45,7 @@ deref_to_field_mut!{LinksTable, EnumMap<LinkKind, Option<String>>, 0}
 pub struct Instance {
   pub name: Arc<InstanceName>,
   pub gs: GameState,
-  pub ipieces: PiecesLoaded,
+  pub ipieces: IPieces,
   pub clients: DenseSlotMap<ClientId, Client>,
   pub iplayers: SecondarySlotMap<PlayerId, PlayerRecord>,
   pub tokens_players: TokenRegistry<PlayerId>,
@@ -69,15 +69,15 @@ pub struct IPlayerState {
 
 #[derive(Debug,Serialize,Deserialize)]
 #[serde(transparent)]
-pub struct PiecesLoaded(ActualPiecesLoaded);
-pub type ActualPiecesLoaded = SecondarySlotMap<PieceId, Box<dyn Piece>>;
+pub struct IPieces(ActualIPieces);
+pub type ActualIPieces = SecondarySlotMap<PieceId, Box<dyn Piece>>;
 #[derive(Copy,Clone,Debug)]
 pub struct ModifyingPieces(());
 
 #[derive(Debug,Serialize,Deserialize,Default)]
 #[serde(transparent)]
-pub struct Pieces(pub(in crate::global) ActualPieces);
-type ActualPieces = DenseSlotMap<PieceId, PieceState>;
+pub struct GPieces(pub(in crate::global) ActualGPieces);
+type ActualGPieces = DenseSlotMap<PieceId, PieceState>;
 
 #[derive(Debug)]
 pub struct Client {
@@ -296,7 +296,7 @@ impl Instance {
     let g = Instance {
       name: name.clone(),
       gs, acl,
-      ipieces: PiecesLoaded(default()),
+      ipieces: IPieces(default()),
       clients: default(),
       iplayers: default(),
       tokens_players: default(),
@@ -1009,7 +1009,7 @@ impl InstanceGuard<'_> {
   fn load_game(accounts: &AccountsGuard,
                games: &mut GamesGuard,
                name: InstanceName) -> Option<InstanceRef> {
-    let InstanceSaveAccesses::<String,ActualPiecesLoaded>
+    let InstanceSaveAccesses::<String,ActualIPieces>
     { tokens_players, mut ipieces, mut aplayers, acl, links }
     = match Self::load_something(&name, "a-") {
       Ok(data) => data,
@@ -1073,7 +1073,7 @@ impl InstanceGuard<'_> {
     let g = Instance {
       gs, iplayers, links,
       acl: acl.into(),
-      ipieces: PiecesLoaded(ipieces),
+      ipieces: IPieces(ipieces),
       name: name.clone(),
       clients: default(),
       tokens_clients: default(),
@@ -1246,12 +1246,12 @@ pub fn process_all_players_for_account<
 
 // ========== instance pieces data access ==========
 
-impl PiecesLoaded {
+impl IPieces {
   pub fn get(&self, piece: PieceId) -> Option<&Box<dyn Piece>> {
     self.0.get(piece)
   }
 
-  pub fn as_mut(&mut self, _: ModifyingPieces) -> &mut ActualPiecesLoaded {
+  pub fn as_mut(&mut self, _: ModifyingPieces) -> &mut ActualIPieces {
     &mut self.0
   }
 }
@@ -1259,21 +1259,21 @@ impl PiecesLoaded {
 // ---------- gamestate pieces table ----------
 
 // No DerefMut to make sure we send updates, save, etc.
-deref_to_field!{Pieces, ActualPieces, 0}
+deref_to_field!{GPieces, ActualGPieces, 0}
 
-impl Pieces {
+impl GPieces {
   pub fn get_mut(&mut self, piece: PieceId) -> Option<&mut PieceState> {
     self.0.get_mut(piece)
   }
   pub fn values_mut(&mut self) -> sm::ValuesMut<PieceId, PieceState> {
     self.0.values_mut()
   }
-  pub fn as_mut(&mut self, _: ModifyingPieces) -> &mut ActualPieces {
+  pub fn as_mut(&mut self, _: ModifyingPieces) -> &mut ActualGPieces {
     &mut self.0
   }
 }
 
-impl ById for Pieces {
+impl ById for GPieces {
   type Id = PieceId;
   type Entry = PieceState;
   type Error = OnlineError;
@@ -1292,7 +1292,7 @@ impl ById for Pieces {
   type IntoIter = sm::Iter<'p, PieceId, PieceState>;
   fn into_iter(self) -> Self::IntoIter { (&self.0).into_iter() }
 }*/
-impl<'p> IntoIterator for &'p mut Pieces {
+impl<'p> IntoIterator for &'p mut GPieces {
   type Item = (PieceId, &'p mut PieceState);
   type IntoIter = sm::IterMut<'p, PieceId, PieceState>;
   fn into_iter(self) -> Self::IntoIter { (&mut self.0).into_iter() }
index 5c8d8e8731891780bc4288d261e5051b999fef7d..66712bdd761d0df1eeedad1c63976315c7d5def7 100644 (file)
@@ -228,7 +228,7 @@ fn recalculate_occultation_general<
   RF: FnOnce(PieceUpdateOps_PerPlayer, LD) -> RD,     // ret_callback
 >(
   gs: &mut GameState,
-  ipieces: &PiecesLoaded,
+  ipieces: &IPieces,
   piece: PieceId,
   // if no change, we return ret_vanilla(log_visible)
   log_visible: LD,
@@ -385,7 +385,7 @@ fn recalculate_occultation_general<
 pub fn recalculate_occultation_piece(
   gs: &mut GameState,
   who_by: Html,
-  ipieces: &PiecesLoaded,
+  ipieces: &IPieces,
   piece: PieceId,
   (vanilla_wrc, vanilla_op, vanilla_log): PUFOS,
 )
@@ -414,7 +414,7 @@ pub fn recalculate_occultation_piece(
 #[throws(IE)]
 fn recalculate_occultation_ofmany(
   gs: &mut GameState,
-  ipieces: &PiecesLoaded,
+  ipieces: &IPieces,
   ppiece: PieceId,
   updates: &mut Vec<(PieceId, PieceUpdateOps)>,
 ){
@@ -466,7 +466,7 @@ impl OccultationViewDef for OwnerOccultationView {
 #[throws(OnlineError)]
 pub fn create_occultation(
   gs: &mut GameState,
-  ipieces: &PiecesLoaded,
+  ipieces: &IPieces,
   region: Area,
   occulter: PieceId,
   views: OccultationViews,
@@ -530,7 +530,7 @@ pub fn create_occultation(
 #[throws(IE)]
 pub fn remove_occultation(
   gs: &mut GameState,
-  ipieces: &PiecesLoaded,
+  ipieces: &IPieces,
   occulter: PieceId,
 ) -> Vec<(PieceId, PieceUpdateOps)> {
   let mut aggerr = AggregatedIE::new();