chiark / gitweb /
fix playerid
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 27 Jun 2020 12:57:46 +0000 (13:57 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 27 Jun 2020 12:57:46 +0000 (13:57 +0100)
src/gamestate.rs
src/global.rs
src/keydata.rs

index 244edf7bd9ef4c9b5335e30f6c3dd858424d1dcc..042de128d3343a85cbf4158edc4e43fcd977c948 100644 (file)
@@ -5,8 +5,7 @@ slotmap::new_key_type!{
   pub struct PieceId;
 }
 
-visible_slotmap_key!{VisiblePieceId}
-display_consequential_impls!{VisiblePieceId}
+visible_slotmap_key!{ VisiblePieceId('.') }
 
 pub fn make_pieceid_visible(p : PieceId) -> VisiblePieceId {
   // xxx need to do censorship mapping here
index 6b39b44d1e800072deb5eeeae57fb24218989130..8a97b467a9d7f330d2de8b1ec332f2a1df211121 100644 (file)
@@ -8,8 +8,7 @@ slotmap::new_key_type!{
   pub struct ClientId;
 }
 
-visible_slotmap_key!{PlayerId}
-display_consequential_impls!{PlayerId}
+visible_slotmap_key!{ PlayerId('#') }
 
 #[derive(Clone,Debug,Eq,PartialEq,Ord,PartialOrd,Hash)]
 struct RawToken (String);
index 7b4c77d93c36dfaec693fc05d4ea610f02d26549..2b8799b7976a6ac456f00873b8fdad62121e037e 100644 (file)
@@ -36,7 +36,7 @@ pub fn slotkey_write(k : SKD, sep : char, f : &mut fmt::Formatter) {
 
 #[macro_export]
 macro_rules! visible_slotmap_key {
-  ( $x:ident ) => {
+  ( $x:ident($sep:expr) ) => {
 
     #[derive(Copy,Clone,Eq,PartialEq,Ord,PartialOrd,Serialize,Deserialize)]
     #[serde(into="String")]
@@ -45,13 +45,13 @@ macro_rules! visible_slotmap_key {
 
     impl Display for $x {
       #[throws(fmt::Error)]
-      fn fmt(&self, f : &mut fmt::Formatter) { slotkey_write(self.0,'.',f)? }
+      fn fmt(&self, f : &mut fmt::Formatter) { slotkey_write(self.0,$sep,f)? }
     }
 
     impl TryFrom<&str> for $x {
       type Error = AE;
       #[throws(AE)]
-      fn try_from(s : &str) -> $x { $x(slotkey_parse(s,'.')?) }
+      fn try_from(s : &str) -> $x { $x(slotkey_parse(s,$sep)?) }
     }
 
     impl slotmap::Key for $x { }
@@ -63,6 +63,8 @@ macro_rules! visible_slotmap_key {
         p.0
       }
     }
+
+    display_consequential_impls!{$x}
   }
 }
 pub use crate::visible_slotmap_key; // this is madness!