|
|
@ -25,14 +25,10 @@ func (r *room) update(dt time.Duration) {
|
|
|
|
p.pending = nil
|
|
|
|
p.pending = nil
|
|
|
|
|
|
|
|
|
|
|
|
res := req.Wants.exec(r, p, req.Seq)
|
|
|
|
res := req.Wants.exec(r, p, req.Seq)
|
|
|
|
p.outbox <- wire.Response{Re: req.Seq, Body: res.reply}
|
|
|
|
if res.reply != nil {
|
|
|
|
if res.announce != nil {
|
|
|
|
p.outbox <- wire.Response{Re: req.Seq, Body: res.reply}
|
|
|
|
for _, p2 := range r.players {
|
|
|
|
} else {
|
|
|
|
if p2 == p {
|
|
|
|
p.outbox <- wire.Response{Re: req.Seq, Body: wire.OK{}}
|
|
|
|
continue
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
p2.outbox <- wire.Response{Body: res.announce}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -41,19 +37,40 @@ func (r *room) update(dt time.Duration) {
|
|
|
|
t.here.update(dt)
|
|
|
|
t.here.update(dt)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
frame := wire.Frame{
|
|
|
|
|
|
|
|
Entities: r.allEntities(),
|
|
|
|
|
|
|
|
Players: r.playerAvatars(),
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for _, p := range r.players {
|
|
|
|
|
|
|
|
p.outbox <- wire.Response{Body: frame}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (r *room) allEntities() map[int]*entity {
|
|
|
|
func (r *room) allEntities() map[int]wire.Entity {
|
|
|
|
all := make(map[int]*entity, 4)
|
|
|
|
all := make(map[int]wire.Entity, 4)
|
|
|
|
for _, t := range r.tiles {
|
|
|
|
for _, t := range r.tiles {
|
|
|
|
if t.here != nil {
|
|
|
|
if t.here != nil {
|
|
|
|
e := t.here
|
|
|
|
e := t.here
|
|
|
|
all[e.ID] = e
|
|
|
|
all[e.ID] = wire.Entity{
|
|
|
|
|
|
|
|
ID: e.ID,
|
|
|
|
|
|
|
|
Position: e.Position,
|
|
|
|
|
|
|
|
Glyph: e.Glyph,
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return all
|
|
|
|
return all
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (r *room) playerAvatars() map[string]int {
|
|
|
|
|
|
|
|
all := make(map[string]int, len(r.players))
|
|
|
|
|
|
|
|
for nick, p := range r.players {
|
|
|
|
|
|
|
|
all[nick] = p.avatar.ID
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return all
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (r *room) addPlayer(p *player) {
|
|
|
|
func (r *room) addPlayer(p *player) {
|
|
|
|
r.players[p.name] = p
|
|
|
|
r.players[p.name] = p
|
|
|
|
}
|
|
|
|
}
|
|
|
|