Files
bl/common/core/info/ServerInfo.go
昔念 720294ad27 refactor(blazing): 重构项目并优化数据结构
- 更新 LoginUserInfo 结构体,将 uint64 类型改为 uint32
- 调整 ServerInfo 结构体,将 IP 字段从 []byte 改为 string
- 移除未使用的 ArraySerialize 结构体
- 更新 ByteArray 类,修改相关方法名
- 删除未使用的 serialize 相关代码
- 优化模块导入,移除冗余依赖
2025-06-22 12:05:07 +08:00

42 lines
956 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package info
// ServerInfo 服务器信息结构体
type ServerInfo struct {
// 连接ID, 即服务器序号
OnlineID uint32
// 当前服务器玩家在线数量, 供SWF显示
UserCnt uint32
// 服务器IP, 16字节UTF-8, 不足16补齐到16
IP string `serialize:"fixed:16"` // 定长模式16字节
// 端口
Port uint16
// 好友在线的个数
Friends uint32
}
// NewServerInfo 创建新的服务器信息实例
func NewServerInfo() *ServerInfo {
return &ServerInfo{
OnlineID: 0,
UserCnt: 0,
IP: "",
Port: 0,
Friends: 0,
}
}
// // SetIP 设置IP地址并自动填充到16字节
// func (s *ServerInfo) SetIP(ip string) {
// copy(s.IP[:], ip)
// if len(ip) < 16 {
// for i := len(ip); i < 16; i++ {
// s.IP[i] = 0 // 用0填充剩余字节
// }
// }
// }
// // GetIP 获取IP地址去除填充的0
// func (s *ServerInfo) GetIP() string {
// return strings.TrimRight(string(s.IP[:]), "\x00")
// }