refactor(fight): 优化战斗逻辑代码结构,清理冗余代码

This commit is contained in:
1
2025-11-06 18:24:51 +00:00
parent ce770e6cf1
commit b4e1129c56

View File

@@ -3,12 +3,22 @@ package controller
import (
"blazing/common/rpc"
"blazing/common/socket/errorcode"
"blazing/logic/service/user"
"golang.org/x/sync/singleflight"
"github.com/panjf2000/gnet/v2"
)
var sg singleflight.Group
var ServerList []rpc.ServerInfo
func fetchData() (any, error) {
ServerList = rpc.GetServerInfoList() //todo 待修改增加缓存
return ServerList, nil
}
// 处理命令: 105
func (h *Controller) COMMEND_ONLINE(data *user.SidInfo, c gnet.Conn) (result *rpc.CommendSvrInfo, err errorcode.ErrorCode) { //这个时候player应该是空的
result = rpc.NewInInfo()
@@ -16,8 +26,9 @@ func (h *Controller) COMMEND_ONLINE(data *user.SidInfo, c gnet.Conn) (result *rp
if data.Head.UserID < 100000 {
result.IsVip = 1
}
v, _, _ := sg.Do("GetServerInfoList", fetchData)
result.ServerList = rpc.GetServerInfoList() //todo 待修改增加缓存
result.ServerList = v.([]rpc.ServerInfo) //todo 待修改增加缓存
return