```
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful

feat(common/cool): 更新GetClient函数支持端口参数

更新GetClient函数签名以接收端口参数,并修改客户端映射键的计算方式,
添加GetClientOnly函数用于仅通过uid获取客户端。

fix(common/rpc): 修复RPC调用中的客户端获取方法

将GetClient调用替换为GetClientOnly,确保正确的客户端获取逻辑。

refactor(logic/controller): 重命名Port字段为UID并优化道具列表处理

将Controller结构体中的Port字段重命名为UID以更好地反映其用途,
优化GetUserItemList函数中道具列表的初始化和填充逻辑。

perf(logic): 调整性能分析web服务启动位置

将PprofWeb服务从全局启动移至调试模式下启动,优化服务配置。

refactor(logic/server): 更新服务器UID生成逻辑

修改Maincontroller的UID字段设置方式,使用服务器ID和端口组合生成唯一标识。

refactor(logic/service/player): 移除未使用的导入并优化怪物生成

移除未使用的service导入,优化怪物生成逻辑中的地图数据访问。

feat(logic/service/space): 添加PitS缓存映射并重构空间初始化

添加新的PitS字段
This commit is contained in:
昔念
2026-03-02 23:59:15 +08:00
parent dab4862f28
commit 79d4343cdc
17 changed files with 103 additions and 55 deletions

View File

@@ -77,7 +77,7 @@ func (s *BaseSysRoleService) GetByUser(userId uint) []string {
)
res, _ := cool.DBM(baseSysUserRole).Where("userId", userId).Array("roleId")
for _, v := range res {
roles = append(roles, gconv.String(v))
roles = append(roles, v.String())
}
return roles
}

View File

@@ -36,7 +36,7 @@ func (this *ServerController) Quit(ctx context.Context, req *QuitSReq) (res *coo
res = &cool.BaseRes{}
serv := service.NewServerService().GetServerID(req.ID)
aa, ok := cool.GetClient(serv.OnlineID*100000 + serv.Port)
aa, ok := cool.GetClient(serv.OnlineID, serv.Port)
if ok && aa != nil { //如果已经存在且这个端口已经被存过
aa.QuitSelf(req.Code)
}

View File

@@ -3,8 +3,6 @@ package service
import (
"blazing/cool"
"blazing/modules/config/model"
"github.com/samber/lo"
)
type MapPitService struct {
@@ -22,24 +20,20 @@ func NewMapPitService() *MapPitService {
},
}
}
func (s *MapPitService) GetData(mapid, pos uint32) []model.MapPit {
// func (s *MapPitService) GetData(mapid, pos uint32) []model.MapPit {
// var pet []model.MapPit //一个特性应该是唯一的,但是我们要获取默认随机特性
// dbm_enable(s.Model).Where("map_id", mapid).Wheref(`pos @> ARRAY[?]::integer[]`, pos).Scan(&pet)
// return pet
// }
func (s *MapPitService) GetDataALL(mapid uint32) []model.MapPit {
var pet []model.MapPit //一个特性应该是唯一的,但是我们要获取默认随机特性
dbm_enable(s.Model).Where("map_id", mapid).Wheref(`pos @> ARRAY[?]::integer[]`, pos).Scan(&pet)
dbm_enable(s.Model).Where("map_id", mapid).Scan(&pet)
return pet
}
func (s *MapPitService) GetDataALL(mapid uint32) []uint32 {
var pet []model.MapPit //一个特性应该是唯一的,但是我们要获取默认随机特性
dbm_enable(s.Model).Where("map_id", mapid).Scan(&pet)
var ret []uint32
for _, v := range pet {
ret = append(ret, v.RefreshID...)
}
return lo.Union(ret)
}

View File

@@ -29,7 +29,7 @@ func NewServerService() *ServerService {
var rr []g.MapStrAny
r, _ := gconv.Map(data)["list"].(gdb.Result)
for i := 0; i < len(r); i++ {
t, ok := cool.GetClient(10000*gconv.Uint32(r[i].Map()["online_id"])+gconv.Uint32(r[i].Map()["port"]))
t, ok := cool.GetClient(gconv.Uint32(r[i].Map()["online_id"]), gconv.Uint32(r[i].Map()["port"]))
// tt.Friends = v.Friends
subm := r[i].GMap()

View File

@@ -30,7 +30,11 @@ func (s *DictInfoService) Data(ctx context.Context, types []string) (data interf
dictInfoModel = model.NewDictInfo()
dictTypeModel = model.NewDictType()
)
mType := cool.DBM(dictTypeModel)
mType := cool.DBM(dictTypeModel).Cache(gdb.CacheOption{
// Duration: time.Hour,
Force: false,
})
// 如果types不为空, 则查询指定类型的数据
if len(types) > 0 {
mType = mType.Where("key in (?)", types)

View File

@@ -160,7 +160,7 @@ func (s *InfoService) Kick(id uint32) error {
return err
}
cl, ok := cool.GetClient(useid1)
cl, ok := cool.GetClientOnly(useid1)
if ok {
err := cl.KickPerson(id) //实现指定服务器踢人
if err != nil {

View File

@@ -22,7 +22,7 @@ func (s *ItemService) Get(min, max uint32) []model.Item {
s.dbm(s.Model).Where(g.Map{
"item_id <=": max,
"item_id >=": min,
}).Scan(&ttt)
}).Where("item_cnt >", 0).Scan(&ttt)
return ttt