Browse Source

代码格式化

修正日志
master
aceld 6 years ago
parent
commit
159be740a8
  1. 2
      zinx_app_demo/mmo_game/core/aoi.go
  2. 6
      zinx_app_demo/mmo_game/core/player.go
  3. 2
      znet/connection.go

2
zinx_app_demo/mmo_game/core/aoi.go

@ -143,7 +143,7 @@ func (m *AOIManager) GetPidsByPos(x, y float32) (playerIDs []int) {
grids := m.GetSurroundGridsByGid(gID)
for _, v := range grids {
playerIDs = append(playerIDs, v.GetPlyerIDs()...)
fmt.Printf("===> grid ID : %d, pids : %v ====", v.GID, v.GetPlyerIDs())
//fmt.Printf("===> grid ID : %d, pids : %v ====", v.GID, v.GetPlyerIDs())
}
return

6
zinx_app_demo/mmo_game/core/player.go

@ -149,7 +149,6 @@ func (p *Player) Talk(content string) {
}
}
//广播玩家位置移动
func (p *Player) UpdatePos(x float32, y float32, z float32, v float32) {
//更新玩家的位置信息
@ -214,20 +213,19 @@ func (p *Player) LostConnection() {
WorldMgrObj.RemovePlayerByPid(p.Pid)
}
/*
发送消息给客户端
主要是将pb的protobuf数据序列化之后发送
*/
func (p *Player) SendMsg(msgId uint32, data proto.Message) {
fmt.Printf("before Marshal data = %+v\n", data)
//fmt.Printf("before Marshal data = %+v\n", data)
//将proto Message结构体序列化
msg, err := proto.Marshal(data)
if err != nil {
fmt.Println("marshal msg err: ", err)
return
}
fmt.Printf("after Marshal data = %+v\n", msg)
//fmt.Printf("after Marshal data = %+v\n", msg)
if p.Conn == nil {
fmt.Println("connection in player is nil")

2
znet/connection.go

@ -69,7 +69,7 @@ func (c *Connection) StartWriter() {
fmt.Println("Send Data error:, ", err, " Conn Writer exit")
return
}
fmt.Printf("Send data succ! data = %+v\n", data)
//fmt.Printf("Send data succ! data = %+v\n", data)
case data, ok := <-c.msgBuffChan:
if ok {
//有数据要写给客户端

Loading…
Cancel
Save