GCSplitItemResult 是当前旧版项目仍在使用的道具拆分结果包。它由固定 11 字节包头加一段 ItemInfo 组成,现役 Lua 会在背包堆叠道具拆分成功或失败后返回它。
包信息
| 项目 |
内容 |
| 封包 ID |
174 |
| 包名 |
GCSplitItemResult |
| 方向 |
Server -> Client |
| 包长 |
变长,11 + ItemInfo |
| 对应请求 |
CGSplitItem |
| 当前 Lua 协议定义 |
已实现 |
| 作用 |
返回新拆分出的目标格与新物品数据 |
包体结构
| 偏移 |
长度 |
字段 |
类型 |
含义 |
0x00 |
0x02 |
con_index |
int16 |
新物品所在目标格索引;失败时通常保持默认值 |
0x02 |
0x04 |
is_null |
uint32 |
当前 Lua 成功时写 0 |
0x06 |
0x04 |
container |
uint32 |
容器类型,现役主链会回显请求里的容器值 |
0x0A |
0x01 |
result |
uint8 |
拆分结果码 |
0x0B |
变长 |
item |
bytes[n] |
新拆分物品的 ItemInfo 数据 |
当前 Lua 保留的结果枚举为:
| 值 |
名称 |
含义 |
0 |
RESULT_FALSE |
失败 |
1 |
RESULT_FALSE_NOGRID |
保留枚举,当前背包拆分主链未实际使用 |
2 |
RESULT_SUCCEED |
成功 |
当前实际行为
- 当前
Game.exe 中,GetPacketID() 返回 174,GetPacketSize() 为 ItemInfo + 11。
- 当前 Lua 只在
human:split_item() 的背包容器分支里发送这条包:
- 请求容器必须是
BAG_CON
- 物品不存在、目标没有空格或拆分失败时,返回失败结果
- 拆分成功时,返回新物品所在格索引与新堆
ItemInfo
- 成功场景下:
con_index = 新空格索引
is_null = 0
container = 请求中的容器
result = RESULT_SUCCEED
item = 新拆出的道具
- 发送完
GCSplitItemResult 后,当前 Lua 还会继续发送一条 GCItemInfo,同步原堆叠物品被扣减后的状态。
服务端落点
- 协议定义:
/home/ubuntu/Game2/services/game/packet.lua
- 现役发送点:
/home/ubuntu/Game2/services/scene/obj/human.lua
关键代码
packet.GCSplitItemResult = {
RESULT = {
RESULT_FALSE = 0,
RESULT_FALSE_NOGRID = 1,
RESULT_SUCCEED = 2,
},
bis = function(self, buffer)
local stream = bistream.new()
stream:attach(buffer)
self.con_index = stream:readshort()
self.is_null = stream:readuint()
self.container = stream:readuint()
self.result = stream:readuchar()
self.item = packet.ItemInfo.new()
self.item:bis(stream)
end
}
if ret then
msg.item = container:get_item(empty_index):copy_raw_data()
msg.result = msg.RESULT.RESULT_SUCCEED
msg.is_null = 0
msg.con_index = empty_index
self.scene:send2client(self, msg)
else
msg.item = Item_cls.new():copy_raw_data()
msg.result = msg.RESULT.RESULT_FALSE
self.scene:send2client(self, msg)
end
结论
GCSplitItemResult(174) 是当前版本现役的拆分结果包。它的固定包头已经可以明确写成 con_index + is_null + container + result,后面再拼接一段 ItemInfo;当前 Lua 只在背包拆分链路里实际发送它。
|