let player = iad.ident;
let c = {
let mut ig = iad.g.lock().map_err(|e| anyhow!("lock poison {:?}",&e))?;
- let _pl = ig.gs.players.get_mut(player)
- .ok_or_else(|| anyhow!("player deleted"))?;
+ let _pl = ig.gs.players.byid_mut(player)?;
let cl = Client { player };
let client = ig.clients.insert(cl);
type Entry;
#[throws(OE)]
fn byid(&self, t: Self::Id) -> &Self::Entry;
+ #[throws(OE)]
+ fn byid_mut(&mut self, t: Self::Id) -> &mut Self::Entry;
}
impl<I:AccessId+slotmap::Key, T> ById for DenseSlotMap<I,T> {
fn byid(&self, t: Self::Id) -> Result<&Self::Entry, OE> {
self.get(t).ok_or(<I as AccessId>::ERROR)
}
+ fn byid_mut(&mut self, t: Self::Id) -> Result<&mut Self::Entry, OE> {
+ self.get_mut(t).ok_or(<I as AccessId>::ERROR)
+ }
}
impl<I:AccessId+slotmap::Key, T> ById for SecondarySlotMap<I,T> {
type Id = I;
fn byid(&self, t: Self::Id) -> Result<&Self::Entry, OE> {
self.get(t).ok_or(<I as AccessId>::ERROR)
}
+ fn byid_mut(&mut self, t: Self::Id) -> Result<&mut Self::Entry, OE> {
+ self.get_mut(t).ok_or(<I as AccessId>::ERROR)
+ }
}