|
|
@ -19,19 +19,22 @@ type room struct {
|
|
|
|
|
|
|
|
|
|
|
|
func (r *room) update(dt time.Duration) {
|
|
|
|
func (r *room) update(dt time.Duration) {
|
|
|
|
for _, p := range r.players {
|
|
|
|
for _, p := range r.players {
|
|
|
|
for _, req := range p.pending {
|
|
|
|
if p.pending == nil {
|
|
|
|
res := req.Wants.exec(r, p, req.Seq)
|
|
|
|
continue
|
|
|
|
p.outbox <- wire.Response{Re: req.Seq, Body: res.reply}
|
|
|
|
}
|
|
|
|
if res.announce != nil {
|
|
|
|
req := p.pending
|
|
|
|
for _, p2 := range r.players {
|
|
|
|
p.pending = nil
|
|
|
|
if p2 == p {
|
|
|
|
|
|
|
|
continue
|
|
|
|
res := req.Wants.exec(r, p, req.Seq)
|
|
|
|
}
|
|
|
|
p.outbox <- wire.Response{Re: req.Seq, Body: res.reply}
|
|
|
|
p2.outbox <- wire.Response{Body: res.announce}
|
|
|
|
if res.announce != nil {
|
|
|
|
|
|
|
|
for _, p2 := range r.players {
|
|
|
|
|
|
|
|
if p2 == p {
|
|
|
|
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
p2.outbox <- wire.Response{Body: res.announce}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
p.pending = p.pending[0:0]
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for _, t := range r.tiles {
|
|
|
|
for _, t := range r.tiles {
|
|
|
|