找回密码
 registerss
搜索
查看: 27|回复: 0

洱海月 v0-07-0300 封包解析:ID 334 GCAskServerTime(服务器时间结果)

[复制链接]
  • 打卡等级:本地老炮
  • 打卡总天数:603
  • 打卡月天数:1
  • 打卡总奖励:600
  • 最近打卡:2026-10-03 06:32:28
Waylee 发表于 2026-4-15 11:02 | 显示全部楼层 |阅读模式 | Google Chrome | Windows 10

马上注册,查看网站隐藏内容!!

您需要 登录 才可以下载或查看,没有账号?registerss

×

GCAskServerTime 是请求服务器时间后的结果包,会返回年月日时分秒、请求类型和 Unix 时间戳。

包信息

项目 内容
封包 ID 334
包名 GCAskServerTime
方向 Server -> Client
对应请求 CGAskServerTime
固定包长 15
作用 返回当前服务器日期时间与时间戳

包体结构

偏移 长度 字段 类型 含义
0x00 0x02 year uint16 年
0x02 0x01 month uint8 月;当前 Lua 按 0 基月值写入
0x03 0x01 day uint8 日
0x04 0x01 hour uint8 时
0x05 0x01 minute uint8 分
0x06 0x01 second uint8 秒
0x07 0x04 ask_type uint32 原样回传的请求类型
0x0B 0x04 ansi_time uint32 Unix 时间戳

总长度:

15 字节

当前实际行为

  • 当前 msgagent.lua 收到 CGAskServerTime 后,会用 os.time() 和 os.date("*t") 组包。
  • 现役实现会把请求里的 ask_type 原样写回。
  • month 当前按 date.month - 1 写入,所以这是旧客户端风格的 0 基月份。

服务端落点

  • 协议定义:/home/ubuntu/Game2/services/game/packet.lua
  • 发送点:/home/ubuntu/Game2/services/msgagent.lua
  • 对应请求文档:/home/ubuntu/Game2/docs/07_登录_网络_封包/packet.CGAskServerTime.md

关键代码

function request:CGAskServerTime()
    local ret = packet_def.GCAskServerTime.new()
    ret.ask_type = self.ask_type
    ret.ansi_time = os.time()
    local date = os.date("*t")
    ret.year = date.year
    ret.month = date.month - 1
    ret.day = date.day
    ret.hour = date.hour
    ret.minute = date.min
    ret.second = date.sec
    Net:send(ret)
end

结论

  1. GCAskServerTime(334) 是服务器时间结果包。
  2. 结构固定 15 字节,字段已经全部明确。
  3. 当前最需要记住的细节,是月份按 0 基值写入。
您需要登录后才可以回帖 登录 | registerss

本版积分规则

QQ|手机版|雪舞知识库 ( 浙ICP备15015590号-1 | 萌ICP备20232229号|浙公网安备33048102000118号 )|天天打卡

GMT+8, 2026-10-4 11:26 , Processed in 0.063446 second(s), 26 queries .

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表