Synchronize owner attribute locks for links and active switchbot
This commit is contained in:
@@ -0,0 +1,20 @@
|
|||||||
|
# 属性锁定:聊天链接和活动洗练槽
|
||||||
|
|
||||||
|
2026-10-18,接续其他视图提示。客户端完整说明见 `metin2-client/docs/AVA2-ATTR-LOCK-SNAPSHOTS.md`。
|
||||||
|
|
||||||
|
`port_attr_lock.cpp` 的 `PortAttrLockSend` 通过现有服务端命令发送 `AttrLockItem window cell vnum mask`,顺序紧随自有物品设置/删除/更新、锁定变更或switchbot物品更新。只给 `SwitchbotHelper::IsClientSupported` 识别的新客户端发送,只支持本人 INVENTORY/EQUIPMENT/SWITCHBOT。SQL失败返回mask=-1,不能伪装成未锁定。
|
||||||
|
|
||||||
|
`/attr_lock_sync` 在客户端进入游戏后一秒触发,只同步本人背包/装备及五个有效洗练槽,不接受目标角色参数。两秒限频,跳过多格物品占位格;结束返回 `AttrLockSync`。客户端最多重试三次,断线清缓存,防止加载界面丢命令和重登残留。经典物品封包、锁定规则和数据库结构均不变。
|
||||||
|
|
||||||
|
客户端以属性/孔快照匹配缓存;聊天链接保留发送时的七属性槽和 `mtlock1:mask` 后缀,并支持转发。活动槽保留原“正在自动洗练”说明,追加黄色 `<<锁定属性>>`,停止后恢复普通提示。
|
||||||
|
|
||||||
|
验证:
|
||||||
|
|
||||||
|
- `python3 tests/features/test_attr_lock_snapshots.py` 编译真实发送和同步函数,覆盖版本/窗口、删除、addon锁定组、SQL失败、多格去重和限频。
|
||||||
|
- `python3 tests/features/test_attr_lock_views.py` 原视图权限/归属检查回归通过。
|
||||||
|
- 客户端132项测试、macOS和Android离线构建通过。macOS/sbtest首次登录同步、聊天链接/转发、实际自动洗练、停止/移回和同进程重登通过;手机真机暂停。
|
||||||
|
- 证据:客户端 `build/parity-acceptance-20261018/lock-snapshots-proof-accepted.log`、`lock-snapshots-{link,active,moved,relogin}.json`。测试驱动不进入发行包。
|
||||||
|
|
||||||
|
仅部署sbtest:`game.ava2-parity` SHA256 `8622d6bcd5077609015bf8556bc094236e3100a4d6ed6ee490b3e55f372960a2`。备份与夹具在 `/root/deploy-features/20261018-ava2-parity/attr-snapshots`,其中 `game-before` 为上一轮测试二进制;SQL恢复必须先停止sbtest以刷新缓存。正式服game仍 `40335e41…`,没有修改正式库或服务进程。
|
||||||
|
|
||||||
|
验收后停止sbtest缓存并恢复测试武器原属性/背包159格、原无锁状态及902个71084,原装备1900000015仍为装备槽4;`attr-snapshots/cleanup-result.json` 已保存核对结果。最终中文说明框实际宽348、最长文字308,40像素余量通过。
|
||||||
@@ -85,3 +85,5 @@ CG is registered in `packet_info.cpp` with `Set(..., true)` and GG with `Set(...
|
|||||||
2026-10-18,sbtest临时频道5:13040和频道6:13050均仅加载地图1。按 AVA2 启用的 do_cmd→MoveChannel、MoveChannelDialog 完成5→6→5,无额外人工查询辅助,active全程为1、两套目标表相同,第4条锁定属性 (4,6) 保持,71084总数1034→976→919。往返后主动停止,武器返回背包159格并解锁,数据库锁表记录为0。
|
2026-10-18,sbtest临时频道5:13040和频道6:13050均仅加载地图1。按 AVA2 启用的 do_cmd→MoveChannel、MoveChannelDialog 完成5→6→5,无额外人工查询辅助,active全程为1、两套目标表相同,第4条锁定属性 (4,6) 保持,71084总数1034→976→919。往返后主动停止,武器返回背包159格并解锁,数据库锁表记录为0。
|
||||||
|
|
||||||
同频道、未开放频道、倒计时取消和任务选择中拒绝均通过;另测换到6后退出重登仍在6/auth11040,回5后关闭辅助核心,列表只剩5且拒绝旧目标6。详见 FEATURE-AVA2-NATIVE-CHANNEL.md。恢复两个原CONFIG并关闭辅助核心,sbtest已重启;正式服game仍40335e41…,本轮换线没有正式部署,Android真机按用户要求暂停。
|
同频道、未开放频道、倒计时取消和任务选择中拒绝均通过;另测换到6后退出重登仍在6/auth11040,回5后关闭辅助核心,列表只剩5且拒绝旧目标6。详见 FEATURE-AVA2-NATIVE-CHANNEL.md。恢复两个原CONFIG并关闭辅助核心,sbtest已重启;正式服game仍40335e41…,本轮换线没有正式部署,Android真机按用户要求暂停。
|
||||||
|
|
||||||
|
2026-10-18 后续:聊天链接和活动洗练槽已补锁定快照并通过sbtest联机验证;见 `FEATURE-ATTR-LOCK-SNAPSHOTS.md`。经典七属性封包保持不变,正式服部署与Android真机验收仍待做。
|
||||||
|
|||||||
@@ -494,6 +494,7 @@ void CHARACTER::SetItem(TItemPos Cell, LPITEM pItem)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
PortAttrLockSend(this,pItem,Cell.window_type,Cell.cell);
|
||||||
}
|
}
|
||||||
|
|
||||||
LPITEM CHARACTER::GetWear(BYTE bCell) const
|
LPITEM CHARACTER::GetWear(BYTE bCell) const
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ ACMD(do_setpickupmode);
|
|||||||
ACMD(do_track_window);
|
ACMD(do_track_window);
|
||||||
ACMD(do_channel_list);
|
ACMD(do_channel_list);
|
||||||
ACMD(do_attr_lock_info);
|
ACMD(do_attr_lock_info);
|
||||||
|
ACMD(do_attr_lock_sync);
|
||||||
ACMD(do_open_shop);
|
ACMD(do_open_shop);
|
||||||
ACMD(do_port_chest);
|
ACMD(do_port_chest);
|
||||||
ACMD(do_chest_drop);
|
ACMD(do_chest_drop);
|
||||||
@@ -615,6 +616,7 @@ struct command_info cmd_info[] =
|
|||||||
{ "channel_list",do_channel_list,0,POS_DEAD,GM_PLAYER },
|
{ "channel_list",do_channel_list,0,POS_DEAD,GM_PLAYER },
|
||||||
{ "move_channel",do_cmd,SCMD_CHANGE_CHANNEL,POS_DEAD,GM_PLAYER },
|
{ "move_channel",do_cmd,SCMD_CHANGE_CHANNEL,POS_DEAD,GM_PLAYER },
|
||||||
{ "attr_lock_info",do_attr_lock_info,0,POS_DEAD,GM_PLAYER },
|
{ "attr_lock_info",do_attr_lock_info,0,POS_DEAD,GM_PLAYER },
|
||||||
|
{ "attr_lock_sync",do_attr_lock_sync,0,POS_DEAD,GM_PLAYER },
|
||||||
{ "setpickupmode",do_setpickupmode,0,POS_DEAD,GM_PLAYER },
|
{ "setpickupmode",do_setpickupmode,0,POS_DEAD,GM_PLAYER },
|
||||||
{ "mt_pickup", do_port_pickup, 0, POS_DEAD, GM_PLAYER },
|
{ "mt_pickup", do_port_pickup, 0, POS_DEAD, GM_PLAYER },
|
||||||
{ "chest_drop", do_chest_drop, 0, POS_DEAD, GM_PLAYER },
|
{ "chest_drop", do_chest_drop, 0, POS_DEAD, GM_PLAYER },
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
#include "port_attr_lock.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "char.h"
|
#include "char.h"
|
||||||
@@ -228,6 +229,7 @@ void CItem::UpdatePacket()
|
|||||||
|
|
||||||
sys_log(2, "UpdatePacket %s -> %s", GetName(), m_pOwner->GetName());
|
sys_log(2, "UpdatePacket %s -> %s", GetName(), m_pOwner->GetName());
|
||||||
m_pOwner->GetDesc()->Packet(&pack, sizeof(pack));
|
m_pOwner->GetDesc()->Packet(&pack, sizeof(pack));
|
||||||
|
PortAttrLockSend(m_pOwner,this,GetWindow(),GetCell());
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD CItem::GetCount()
|
DWORD CItem::GetCount()
|
||||||
|
|||||||
@@ -5,6 +5,36 @@
|
|||||||
#include "item.h"
|
#include "item.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "port_attr_lock.h"
|
#include "port_attr_lock.h"
|
||||||
|
#include "port_switchbot.h"
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
void PortAttrLockSend(CHARACTER* ch,CItem* item,unsigned window,unsigned cell) {
|
||||||
|
if (!ch || !ch->GetDesc() || !SwitchbotHelper::IsClientSupported(ch)) return;
|
||||||
|
if (window!=INVENTORY && window!=EQUIPMENT && window!=SWITCHBOT) return;
|
||||||
|
int mask=0;
|
||||||
|
if (item && PortAttrFilled(item)) {
|
||||||
|
mask=PortAttrLockEffective(PortAttrLockGet(item),PortAttrFilled(item),item->GetProto() && item->GetProto()->sAddonType);
|
||||||
|
if (!item->m_portAttrLockLoaded) mask=-1;
|
||||||
|
}
|
||||||
|
ch->ChatPacket(CHAT_TYPE_COMMAND,"AttrLockItem %u %u %u %d",window,cell,item?item->GetVnum():0,mask);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Requested only after GameWindow.Open: item loading precedes the game's command receiver.
|
||||||
|
ACMD(do_attr_lock_sync) {
|
||||||
|
if (!ch || !ch->IsPC() || !SwitchbotHelper::IsClientSupported(ch)) return;
|
||||||
|
const int now=get_global_time();
|
||||||
|
if (ch->GetProtectTime("attr_lock_sync")>now) return;
|
||||||
|
ch->SetProtectTime("attr_lock_sync",now+2);
|
||||||
|
for (unsigned cell=0;cell<INVENTORY_AND_EQUIP_SLOT_MAX;++cell) {
|
||||||
|
LPITEM item=ch->GetItem(TItemPos(INVENTORY,cell));
|
||||||
|
if (item && item->GetCell()==cell) PortAttrLockSend(ch,item,INVENTORY,cell);
|
||||||
|
}
|
||||||
|
for (unsigned cell=0;cell<SWITCHBOT_SLOT_COUNT_REAL;++cell) {
|
||||||
|
LPITEM item=ch->GetItem(TItemPos(SWITCHBOT,cell));
|
||||||
|
if (item) PortAttrLockSend(ch,item,SWITCHBOT,cell);
|
||||||
|
}
|
||||||
|
ch->ChatPacket(CHAT_TYPE_COMMAND,"AttrLockSync");
|
||||||
|
}
|
||||||
|
|
||||||
void PortAttrLockBoot() {
|
void PortAttrLockBoot() {
|
||||||
std::unique_ptr<SQLMsg> msg(DBManager::instance().DirectQuery(
|
std::unique_ptr<SQLMsg> msg(DBManager::instance().DirectQuery(
|
||||||
@@ -34,6 +64,7 @@ bool PortAttrLockSet(CHARACTER* ch,CItem* item,unsigned mask) {
|
|||||||
item->m_portAttrLock=BYTE(mask);item->m_portAttrLockLoaded=true;
|
item->m_portAttrLock=BYTE(mask);item->m_portAttrLockLoaded=true;
|
||||||
char hint[16];snprintf(hint,sizeof(hint),"%u",mask);
|
char hint[16];snprintf(hint,sizeof(hint),"%u",mask);
|
||||||
if(ch)LogManager::instance().ItemLog(ch,item,"ATTR_LOCK",hint);
|
if(ch)LogManager::instance().ItemLog(ch,item,"ATTR_LOCK",hint);
|
||||||
|
if (item->GetOwner()) PortAttrLockSend(item->GetOwner(),item,item->GetWindow(),item->GetCell());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,8 @@ inline const char* PortAttrLockToggle(unsigned mask,unsigned slot,unsigned fille
|
|||||||
class CItem;
|
class CItem;
|
||||||
class CHARACTER;
|
class CHARACTER;
|
||||||
void PortAttrLockBoot();
|
void PortAttrLockBoot();
|
||||||
|
// Sent after the matching owner item packet; classic item layouts stay unchanged.
|
||||||
|
void PortAttrLockSend(CHARACTER* ch,CItem* item,unsigned window,unsigned cell);
|
||||||
bool PortAttrLockSelect(CHARACTER* ch,CItem* material,unsigned index);
|
bool PortAttrLockSelect(CHARACTER* ch,CItem* material,unsigned index);
|
||||||
// Cached on the item after the first lookup. A failed lookup returns 0 and is retried next time.
|
// Cached on the item after the first lookup. A failed lookup returns 0 and is retried next time.
|
||||||
unsigned PortAttrLockGet(CItem* item);
|
unsigned PortAttrLockGet(CItem* item);
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
// - The attribute list has two pseudo sets after ATTRIBUTE_SET_MAX_NUM: 8 = rings (port_rings.cpp) and
|
// - The attribute list has two pseudo sets after ATTRIBUTE_SET_MAX_NUM: 8 = rings (port_rings.cpp) and
|
||||||
// 9 = talismans (port_pendant.cpp), whose pools are not in item_attr.
|
// 9 = talismans (port_pendant.cpp), whose pools are not in item_attr.
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
#include "port_attr_lock.h"
|
||||||
#include "constants.h"
|
#include "constants.h"
|
||||||
#include "port_switchbot.h"
|
#include "port_switchbot.h"
|
||||||
#include "desc.h"
|
#include "desc.h"
|
||||||
@@ -474,6 +475,7 @@ void CSwitchbot::SendItemUpdate(LPCHARACTER ch, BYTE slot, LPITEM item)
|
|||||||
tmp_buf.write(&pack, sizeof(pack));
|
tmp_buf.write(&pack, sizeof(pack));
|
||||||
tmp_buf.write(&update, sizeof(update));
|
tmp_buf.write(&update, sizeof(update));
|
||||||
desc->Packet(tmp_buf.read_peek(), tmp_buf.size());
|
desc->Packet(tmp_buf.read_peek(), tmp_buf.size());
|
||||||
|
PortAttrLockSend(ch,item,SWITCHBOT,slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
CSwitchbotManager::~CSwitchbotManager()
|
CSwitchbotManager::~CSwitchbotManager()
|
||||||
|
|||||||
@@ -0,0 +1,56 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Compile the owner snapshot sender, including client/window gates and failed DB reads."""
|
||||||
|
from pathlib import Path
|
||||||
|
import subprocess,tempfile
|
||||||
|
root=Path(__file__).resolve().parents[2]/'src/server/game/src'
|
||||||
|
s=(root/'port_attr_lock.cpp').read_text();s=s[s.index('void PortAttrLockSend('):s.index('\nvoid PortAttrLockBoot(')]
|
||||||
|
code=r'''
|
||||||
|
#include <cassert>
|
||||||
|
#include <cstdarg>
|
||||||
|
#include <cstdio>
|
||||||
|
#include <string>
|
||||||
|
#define INVENTORY 1
|
||||||
|
#define EQUIPMENT 2
|
||||||
|
#define SWITCHBOT 7
|
||||||
|
#define CHAT_TYPE_COMMAND 1
|
||||||
|
#define ACMD(name) void name(CHARACTER* ch,const char* argument)
|
||||||
|
#define INVENTORY_AND_EQUIP_SLOT_MAX 300
|
||||||
|
#define SWITCHBOT_SLOT_COUNT_REAL 5
|
||||||
|
using LPITEM=struct CItem*;
|
||||||
|
struct TItemPos {unsigned window,cell;TItemPos(unsigned w,unsigned c):window(w),cell(c){}};
|
||||||
|
int get_global_time(){return 100;}
|
||||||
|
struct Proto {int sAddonType=0;};
|
||||||
|
struct CItem {unsigned vnum=19,mask=8,filled=31;bool m_portAttrLockLoaded=true;Proto proto;
|
||||||
|
unsigned GetCell(){return 159;}unsigned GetVnum(){return vnum;}unsigned GetAttributeType(unsigned i){return (filled>>i)&1;}Proto* GetProto(){return &proto;}};
|
||||||
|
struct CHARACTER {bool desc=true,supported=true;std::string reply;int protect=0,calls=0;CItem* item=nullptr;
|
||||||
|
bool IsPC(){return true;}int GetProtectTime(const char*){return protect;}void SetProtectTime(const char*,int n){protect=n;}
|
||||||
|
CItem* GetItem(TItemPos pos){return (pos.window==INVENTORY && (pos.cell==159 || pos.cell==160)) || (pos.window==SWITCHBOT && pos.cell==0)?item:nullptr;}
|
||||||
|
void* GetDesc(){return desc?this:nullptr;}
|
||||||
|
void ChatPacket(int,const char* fmt,...){++calls;char b[512];va_list a;va_start(a,fmt);vsnprintf(b,sizeof(b),fmt,a);va_end(a);reply=b;}};
|
||||||
|
#include "port_attr_lock.h"
|
||||||
|
unsigned PortAttrLockGet(CItem* item){return item->mask;}
|
||||||
|
struct SwitchbotHelper {static bool IsClientSupported(CHARACTER* ch){return ch->supported;}};
|
||||||
|
'''+s+r'''
|
||||||
|
int main(){
|
||||||
|
CHARACTER ch;CItem item;
|
||||||
|
PortAttrLockSend(&ch,&item,INVENTORY,159);assert(ch.reply=="AttrLockItem 1 159 19 8");
|
||||||
|
PortAttrLockSend(&ch,&item,EQUIPMENT,229);assert(ch.reply=="AttrLockItem 2 229 19 8");
|
||||||
|
PortAttrLockSend(&ch,&item,SWITCHBOT,0);assert(ch.reply=="AttrLockItem 7 0 19 8");
|
||||||
|
PortAttrLockSend(&ch,nullptr,INVENTORY,159);assert(ch.reply=="AttrLockItem 1 159 0 0");
|
||||||
|
item.mask=1;item.proto.sAddonType=1;PortAttrLockSend(&ch,&item,INVENTORY,159);assert(ch.reply=="AttrLockItem 1 159 19 3");
|
||||||
|
item.m_portAttrLockLoaded=false;PortAttrLockSend(&ch,&item,INVENTORY,159);assert(ch.reply=="AttrLockItem 1 159 19 -1");
|
||||||
|
item.filled=0;PortAttrLockSend(&ch,&item,INVENTORY,159);assert(ch.reply=="AttrLockItem 1 159 19 0");
|
||||||
|
ch.reply.clear();PortAttrLockSend(&ch,&item,3,0);assert(ch.reply.empty());
|
||||||
|
ch.supported=false;PortAttrLockSend(&ch,&item,INVENTORY,159);assert(ch.reply.empty());
|
||||||
|
ch.supported=true;ch.desc=false;PortAttrLockSend(&ch,&item,INVENTORY,159);assert(ch.reply.empty());
|
||||||
|
PortAttrLockSend(nullptr,&item,INVENTORY,159);
|
||||||
|
ch.desc=true;ch.item=&item;ch.calls=0;do_attr_lock_sync(&ch,"");assert(ch.calls==3 && ch.protect==102 && ch.reply=="AttrLockSync");
|
||||||
|
do_attr_lock_sync(&ch,"");assert(ch.calls==3); // repeated requests throttled, footprint cell 160 not duplicated
|
||||||
|
ch.protect=0;ch.supported=false;do_attr_lock_sync(&ch,"");assert(ch.calls==3);
|
||||||
|
}
|
||||||
|
'''
|
||||||
|
with tempfile.TemporaryDirectory() as d:
|
||||||
|
p=Path(d);(p/'test.cpp').write_text(code)
|
||||||
|
subprocess.run(['c++','-std=c++17','-I'+str(root),str(p/'test.cpp'),'-o',str(p/'test')],check=True)
|
||||||
|
subprocess.run([str(p/'test')],check=True)
|
||||||
|
print('Attr lock owner snapshots: version/window gates, removal, addon pair and SQL failure: PASS')
|
||||||
Reference in New Issue
Block a user