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

洱海月 v0-07-0300 封包解析:ID 647 GCBankAddItem(道具存入仓库结果)

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

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

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

×

包信息

项目 值
PacketID 647
方向 Server -> Client
长度 4
作用 通知客户端一次背包道具存入仓库的处理结果,携带来源容器、来源格、目标仓库格和结果字节

包体结构

偏移 长度 字段 类型 含义
0x00 0x01 from_bag uint8 来源容器类型,当前 Lua 直接回写 CGBankAddItem.from_bag
0x01 0x01 from_index uint8 来源背包格索引
0x02 0x01 to_index uint8 目标仓库格索引;当前 Lua 无有效目标格时写 255
0x03 0x01 result uint8 结果字节;当前 Lua 主链写 1/0,客户端额外保留 2 分支

当前实际行为 / 模式说明

  • request:CGBankAddItem() 会把请求直接转发到 scenecore:char_bank_add_item()。
  • 当前服务端真正取来源道具时固定使用人物普通背包容器 prop_bag_container:get_item(from_index),from_bag 在当前 Lua 主链里主要用于回包回显。
  • 服务端会先检查来源道具是否存在、是否处于交易中、是否已锁定,不满足条件时直接弹提示并返回,不发送 GCBankAddItem。
  • 可叠加物品存仓时,当前 Lua 会优先尝试把数量合并到银行里已有的同类未满格物品上。
  • 只要发生叠加合并,服务端就不再发送 GCBankAddItem,而是改走 char_bank_item_info()、char_bank_acquire_list() 和 char_prop_item_info() 的刷新链。
  • 只有“未发生合并”的直移路径,当前 Lua 才会发送 GCBankAddItem:
    • result = 1:移动成功
    • result = 0:移动失败
    • to_index = 255:当前没有合法目标仓库格
  • 当前 Game.exe 客户端执行函数会按 from_bag == 1 进入正常背包入仓处理;其中 result == 1 走“放入空仓库格”分支,result == 2 走“目标格交换”分支。
  • 当前 Lua 主链未见写入 result = 2 的发送点,因此本版本 GCBankAddItem 实际主要使用的是 result = 1/0。
  • 当前 Game.exe 里还保留了失败提示键 GCBankAddItemHandler_Info_Item_Save_To_Bank_False 和成功提示键 GCBankAddItemHandler_Info_Item_Save_To_Bank_Ok。

服务端落点

  • /home/ubuntu/Game2/services/game/packet.lua
  • /home/ubuntu/Game2/services/msgagent.lua
  • /home/ubuntu/Game2/services/scene/scenecore.lua

关键代码

-- /home/ubuntu/Game2/services/game/packet.lua
self.from_bag = stream:readuchar()
self.from_index = stream:readuchar()
self.to_index = stream:readuchar()
self.result = stream:readuchar()
-- /home/ubuntu/Game2/services/scene/scenecore.lua
if merged then
    if new_bank_slot == define.INVAILD_ID then
        ...
    else
        self:char_bank_acquire_list(who)
    end
    self:char_prop_item_info(who, from_index)
else
    msg.from_bag = add.from_bag
    msg.from_index = from_index
    msg.to_index = final_to_index == define.INVAILD_ID and 255 or final_to_index
    msg.result = result and 1 or 0
    self:send2client(human, msg)
end
-- /home/ubuntu/Game2/services/msgagent.lua
function request:CGBankAddItem()
    skynet.call(my_scene, "lua", "char_bank_add_item", my_obj_id, self)
end
// Game.exe
GetPacketID()   = 647;
GetPacketSize() = 4;
Read()  : read(a1 + 24, 1); read(a1 + 25, 1); read(a1 + 26, 1); read(a1 + 27, 1);
Write() : write(a1 + 24, 1); write(a1 + 25, 1); write(a1 + 26, 1); write(a1 + 27, 1);
Execute():
  if (from_bag == 1 && result == 1) move bag[from_index] -> bank[to_index];
  if (from_bag == 1 && result == 2) swap bag[from_index] with bank[to_index];

结论

GCBankAddItem 是当前版本背包道具存入仓库的结果回包,固定长度 4 字节,结构为 from_bag + from_index + to_index + result。当前 Lua 只在“未发生堆叠合并”的直移路径发送它;一旦进入堆叠合并,服务端会改走仓库格刷新或全量仓库刷新,不再发这条单包通知。

您需要登录后才可以回帖 登录 | registerss

本版积分规则

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

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

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

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