Skip to content

Commit

Permalink
Merge pull request #13 from inada-s/fix-room-time
Browse files Browse the repository at this point in the history
fix initial broken lobby entry count
  • Loading branch information
inada-s authored Oct 26, 2019
2 parents 8d5e4fc + 0846f78 commit ac8f0a9
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 12 deletions.
19 changes: 16 additions & 3 deletions pkg/lobby/app_core.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ func (a *App) OnEntryLobbyBattle(p *AppPeer, side byte) {
continue
}
NoticeChatMessage(peer, "SERVER", ">", msg)
// NoticeEntryUserCount(peer, lobby.Id, aeug, titans)
}
}
}
Expand Down Expand Up @@ -692,7 +693,12 @@ func (a *App) OnGetRoomRestTime(p *AppPeer, roomId uint16) uint16 {
if !ok {
return 0
}
return uint16(room.Deadline.Sub(time.Now()).Seconds() + 1)

t := room.Deadline.Sub(time.Now()).Seconds()
if t < 0 {
t = 0
}
return uint16(t)
}

func (a *App) OnGetRoomMember(p *AppPeer, roomId uint16) (count uint16, users []string) {
Expand Down Expand Up @@ -748,7 +754,9 @@ func (a *App) OnEntryRoomMatch(p *AppPeer, side byte) {
continue
}
NoticeChatMessage(peer, "SERVER", ">", msg)
// NoticeEntryUserCount(peer, p.Room.Id, aeug, titans)
}

}

func (a *App) OnEnterRoom(p *AppPeer, roomId, _, _ uint16) bool {
Expand Down Expand Up @@ -833,8 +841,13 @@ func (a *App) OnExitRoom(p *AppPeer) {

}

func (a *App) OnGetRoomMatchEntryUserCount(p *AppPeer, roomId uint16) {
//保留
func (a *App) OnGetRoomMatchEntryUserCount(p *AppPeer, roomId uint16) (aeug uint16, titans uint16) {
if p.Lobby != nil {
if room, ok := p.Lobby.Rooms[roomId]; ok {
return room.GetEntryUserCount()
}
}
return
}

func (a *App) OnNoticeRoomBattleStart(p *AppPeer) {
Expand Down
1 change: 1 addition & 0 deletions pkg/lobby/msg_lobby.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ func NoticeLobbyUserCount(p *AppPeer, lobbyId, inLobby, inBattle uint16) {
}

func NoticeEntryUserCount(p *AppPeer, lobbyId, aeug, titans uint16) {
// Doesn't work..
n := NewServerNotice(0x640F)
w := n.Writer()
w.Write16(lobbyId)
Expand Down
23 changes: 14 additions & 9 deletions pkg/lobby/msg_room.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package lobby

import (
"github.com/golang/glog"
. "zdxsv/pkg/lobby/message"

"github.com/golang/glog"
)

var _ = register(0x6401, "GetRoomCount", func(p *AppPeer, m *Message) {
Expand Down Expand Up @@ -40,11 +41,15 @@ var _ = register(0x640B, "GetRoomJoinInfo", func(p *AppPeer, m *Message) {
var _ = register(0x6403, "GetRoomUserCount", func(p *AppPeer, m *Message) {
roomId := m.Reader().Read16()
count := p.app.OnGetRoomUserCount(p, roomId)
maxCount := p.app.OnGetRoomJoinInfo(p, roomId)
a := NewServerAnswer(m)
w := a.Writer()
w.Write16(roomId)
w.Write16(count) // 現在人数
// なんかこの後にWrite16したらティターンズの人数が変わったがメモリ的な問題っぽい
w.Write16(0) // ???
w.Write16(maxCount)
w.Write16(count) // ???
p.SendMessage(a)
})

Expand Down Expand Up @@ -276,10 +281,10 @@ var _ = register(0x6504, "EntryRoomMatch", func(p *AppPeer, m *Message) {
var _ = register(0x6406, "EnterRoom", func(p *AppPeer, m *Message) {
r := m.Reader()
roomId := r.Read16()
hoge := r.Read16()
huga := r.Read16()
p.app.OnEnterRoom(p, roomId, hoge, huga)
glog.Infoln("EnterRoom", roomId, hoge, huga)
unk1 := r.Read16()
unk2 := r.Read16()
p.app.OnEnterRoom(p, roomId, unk1, unk2)
glog.Infoln("EnterRoom", roomId, unk1, unk2)
p.SendMessage(NewServerAnswer(m))
})

Expand All @@ -291,13 +296,13 @@ var _ = register(0x6501, "ExitRoom", func(p *AppPeer, m *Message) {
var _ = register(0x6412, "GetRoomMatchEntryUserCount", func(p *AppPeer, m *Message) {
r := m.Reader()
roomId := r.Read16()
p.app.OnGetRoomMatchEntryUserCount(p, roomId)
aeug, titans := p.app.OnGetRoomMatchEntryUserCount(p, roomId)
a := NewServerAnswer(m)
w := a.Writer()
w.Write16(roomId)
w.Write16(0) // うまく動かん
w.Write16(0) // うまく動かん
p.SendMessage(NewServerAnswer(m))
w.Write16(aeug)
w.Write16(titans)
p.SendMessage(a)
})

var _ = register(0x6508, "NoticeRoomBattleStart", func(p *AppPeer, m *Message) {
Expand Down

0 comments on commit ac8f0a9

Please sign in to comment.