Add safe AVA2 lock material selection and tooltip query
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
# AVA2 属性锁定选择与展示
|
||||
|
||||
2026-10-18;仅 sbtest,game SHA256 `a324f3d0646ce8e8579c34237bbdc54855be2d5578f54476a27005f0af364765`。正式服未变更。
|
||||
|
||||
补齐 AVA2 char_item.cpp 的材料使用契约:无目标使用 50348/50349 进入选择 quest,socket 0 保存1~5;拖放时锁定或解锁。选择返回按 ID 重新解析物品,校验所有者、库存与交易/角色状态。选择不扣材料,锁定只有持久保存成功才扣一张;数据库读取失败拒绝覆盖已有状态。处理放在时装/护符专用分支之前。独立 mt_item_attr_lock 表及现有 ChangeAttribute 保留算法继续使用。
|
||||
|
||||
`/attr_lock_info TOKEN WINDOW CELL` 只读查询自己的背包、装备或洗练槽(每秒限频),含请求序号和 vnum 的响应让客户端拒绝过时提示;SQL 错误发未知掩码而非未锁定。
|
||||
|
||||
两种材料原型从 AVA2 客户端 DumpProto 读取并只合并两行;归档没有材料的选择 quest,中文 attr_lock.quest 根据 C++ 契约补齐。安装器和详细验证见客户端 tools/server/ava2-attr-lock/README.md。
|
||||
|
||||
已实际验证选择4、掩码8、锁定消耗4→3、洗练卷20→19且第4条保持、重复锁定不消耗、重启测试 db/auth/game 和客户端后读回、取消不消耗、解锁4→3。备份为 /root/deploy-features/20261018-ava2-parity/backup-attr-lock 和 backup-attr-lock-install-recheck;QA 专属夹具保存在该目录 private-attr-lock-*,勿纳入发布包。
|
||||
|
||||
直接函数测试 test_attr_lock_use.py 与原 ChangeAttribute 测试 test_attr_lock.py 通过。还未闭合其他玩家/交易/商店锁定提示、物理输入和 Android 联机。客户端脚本在 OnUpdate 内操作重新登录触发的窗口遍历崩溃单独记录,不能计作重连通过。
|
||||
@@ -12,6 +12,6 @@ shop12 不占已有 shop manager ID,只有八个原始报价;使用原 CShop
|
||||
|
||||
测试:`python3 tests/features/test_ava2_track.py`、`test_ava2_dungeon_track.py`、`test_ava2_ticket_shop.py`。FreeBSD 编译必须同时指定 BINDIR 与 GAMEDIR,默认 Makefile 输出会覆盖生产目录。
|
||||
|
||||
sbtest 最新 game SHA256:`8640644b94005a463e9e8244e6c414f1700ab675950e7bd3b0958bee289b1119`。部署及构建日志在 `/root/deploy-features/20261018-ava2-parity/`,此次兼容读取前的 game 备份为 `game-before-legacy-track`。只可用 sbtest stop/restart 脚本切换,不能用生产重启脚本。
|
||||
本批追踪部署时的 game SHA256:`8640644b94005a463e9e8244e6c414f1700ab675950e7bd3b0958bee289b1119`。部署及构建日志在 `/root/deploy-features/20261018-ava2-parity/`,此次兼容读取前的 game 备份为 `game-before-legacy-track`。只可用 sbtest stop/restart 脚本切换,不能用生产重启脚本。
|
||||
|
||||
尚未完成:八副本原版任务/门票/等级全量迁移、真实跨核心故障切换、Android 触控、全套资源缺口修复、正式服发布。冷却状态不能替代入口 NPC 的队伍/门票/房间权限检查。
|
||||
|
||||
@@ -67,3 +67,7 @@ CG is registered in `packet_info.cpp` with `Set(..., true)` and GG with `Set(...
|
||||
- Same-core map change (1 → 21 → 1) keeps rolling with the targets kept; it only pauses during the warp.
|
||||
- The cross-core P2P hand-over is not tested yet (the test cluster has one core).
|
||||
- Not deployed. The live 203 still runs v1. Rings and talismans need the whole feature/ava2-unlock (with its protos), and the server and client must be deployed together.
|
||||
|
||||
## 2026-10-18 补充验收
|
||||
|
||||
独立 sbtest 的 QA1017,武器起初无类型9;三个备选均只设释放速度9≥1。未手动停止,实际消耗13个71084后,最终含 (9,10),active=0、finished=1,约1.315秒。客户端证据 switchbot-cast-natural.json。跨核心续洗仍未验收,不能将本项扩大解释为全部洗练场景通过。
|
||||
|
||||
@@ -137,3 +137,6 @@ $(OBJDIR)/ava2_track.o $(OBJDIR)/questlua_dungeon.o $(OBJDIR)/input_db.o $(OBJDI
|
||||
$(OBJDIR)/ava2_ticket_shop.o $(OBJDIR)/shop_manager.o $(OBJDIR)/cmd_general.o: ava2_ticket_shop.h
|
||||
|
||||
$(OBJDIR)/cmd_general.o $(OBJDIR)/ava2_track.o: port_dungeon_settings.h
|
||||
|
||||
$(OBJDIR)/cmd_general.o: ava2_attr_lock_commands.h port_attr_lock.h
|
||||
$(OBJDIR)/questlua_item.o: port_attr_lock.h
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
// Read-only presentation bridge: this port keeps AVA2 lock indices in an independent table.
|
||||
#include "port_attr_lock.h"
|
||||
#include <sstream>
|
||||
ACMD(do_attr_lock_info) {
|
||||
if (!ch || !ch->IsPC()) return;
|
||||
unsigned token=0,window=0,cell=0;std::string extra;std::istringstream args(argument);
|
||||
if (!(args>>token>>window>>cell) || (args>>extra) || token>2147483647 || window>255 || cell>65535 ||
|
||||
(window!=INVENTORY && window!=EQUIPMENT && window!=SWITCHBOT)) return;
|
||||
quest::PC* pc=quest::CQuestManager::instance().GetPCForce(ch->GetPlayerID());
|
||||
if (!pc || !pc->IsLoaded()) return;
|
||||
const int now=get_global_time();
|
||||
if (ch->GetProtectTime("attr_lock_query")>now) return;
|
||||
ch->SetProtectTime("attr_lock_query",now+1);
|
||||
const TItemPos pos{BYTE(window),WORD(cell)};
|
||||
if (window==SWITCHBOT ? cell>=SWITCHBOT_SLOT_COUNT : cell>=INVENTORY_AND_EQUIP_SLOT_MAX) return;
|
||||
LPITEM target=ch->GetItem(pos);int mask=0;
|
||||
if (target && PortAttrFilled(target)) {
|
||||
mask=PortAttrLockEffective(PortAttrLockGet(target),PortAttrFilled(target),target->GetProto() && target->GetProto()->sAddonType);
|
||||
if (!target->m_portAttrLockLoaded) mask=-1; // SQL failure is not an unlocked item.
|
||||
}
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND,"AttrLockInfo %u %u %u %u %d",token,window,cell,target?target->GetVnum():0,mask);
|
||||
}
|
||||
@@ -4560,10 +4560,26 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell)
|
||||
case USE_ADD_ATTRIBUTE:
|
||||
case USE_ADD_ATTRIBUTE2:
|
||||
{
|
||||
// AVA2: using a lock material without a destination selects its 1-based index in a quest.
|
||||
if ((item->GetVnum()==50348 || item->GetVnum()==50349) &&
|
||||
(!IsValidItemPosition(DestCell) || !GetItem(DestCell))) {
|
||||
quest::CQuestManager::instance().RegisterNPCVnum(item->GetVnum());
|
||||
quest::CQuestManager::instance().UseItem(GetPlayerID(),item,false);
|
||||
return true;
|
||||
}
|
||||
LPITEM item2;
|
||||
if (!IsValidItemPosition(DestCell) || !(item2 = GetItem(DestCell)))
|
||||
return false;
|
||||
|
||||
// AVA2 lock materials carry the selected 1-based attribute in socket 0.
|
||||
if (item->GetVnum() == 50348 || item->GetVnum() == 50349)
|
||||
{
|
||||
const long index = item->GetSocket(0);
|
||||
const char* error = index < 1 || index > 5 ? "slot" :
|
||||
PortAttrLockUse(this, item2, unsigned(index - 1), item);
|
||||
ChatPacket(CHAT_TYPE_COMMAND,"AttrLockResult %s",error?error:"ok");
|
||||
return error == NULL;
|
||||
}
|
||||
if (item->IsCostumeEnchant())
|
||||
return CostumeEnchantUse(item, item2);
|
||||
|
||||
@@ -4633,15 +4649,7 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell)
|
||||
break;
|
||||
|
||||
case USE_CHANGE_ATTRIBUTE :
|
||||
// AVA2 lock materials carry the selected 1-based attribute in socket 0.
|
||||
if (item->GetVnum() == 50348 || item->GetVnum() == 50349)
|
||||
{
|
||||
const long index = item->GetSocket(0);
|
||||
const char* error = index < 1 || index > 5 ? "slot" :
|
||||
PortAttrLockUse(this, item2, unsigned(index - 1), item);
|
||||
if (error) ChatPacket(CHAT_TYPE_INFO, "Attribute lock: %s", error);
|
||||
return error == NULL;
|
||||
}
|
||||
|
||||
if (item2->GetAttributeSetIndex() == -1 && !item2->IsNewRing())
|
||||
{
|
||||
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("속성을 변경할 수 없는 아이템입니다."));
|
||||
|
||||
@@ -13,6 +13,7 @@ ACMD(do_port_features);
|
||||
ACMD(do_port_pickup);
|
||||
ACMD(do_setpickupmode);
|
||||
ACMD(do_track_window);
|
||||
ACMD(do_attr_lock_info);
|
||||
ACMD(do_open_shop);
|
||||
ACMD(do_port_chest);
|
||||
ACMD(do_chest_drop);
|
||||
@@ -610,6 +611,7 @@ struct command_info cmd_info[] =
|
||||
{ "mt_features", do_port_features, 0, POS_DEAD, GM_PLAYER },
|
||||
{ "open_shop",do_open_shop,0,POS_DEAD,GM_PLAYER },
|
||||
{ "track_window",do_track_window,0,POS_DEAD,GM_PLAYER },
|
||||
{ "attr_lock_info",do_attr_lock_info,0,POS_DEAD,GM_PLAYER },
|
||||
{ "setpickupmode",do_setpickupmode,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 },
|
||||
|
||||
@@ -2724,3 +2724,5 @@ ACMD(do_open_shop)
|
||||
if (!(in>>shop) || (in>>extra) || shop!=12) return;
|
||||
if (!Ava2OpenTicketShop(ch)) ch->ChatPacket(CHAT_TYPE_COMMAND,"TrackError busy");
|
||||
}
|
||||
|
||||
#include "ava2_attr_lock_commands.h"
|
||||
|
||||
@@ -42,7 +42,9 @@ const char* PortAttrLockUse(CHARACTER* ch,CItem* item,unsigned slot,CItem* mater
|
||||
if(!material || material==item || material->GetOwner()!=ch || material->IsExchanging() || material->isLocked() ||
|
||||
material->IsEquipped() || material->GetCount()<1)return "material";
|
||||
const bool addon=item->GetProto() && item->GetProto()->sAddonType;
|
||||
const unsigned old=PortAttrLockEffective(PortAttrLockGet(item),PortAttrFilled(item),addon);
|
||||
const unsigned stored=PortAttrLockGet(item);
|
||||
if (!item->m_portAttrLockLoaded)return "db";
|
||||
const unsigned old=PortAttrLockEffective(stored,PortAttrFilled(item),addon);
|
||||
const bool removing=slot<5 && (old>>slot&1);
|
||||
if(material->GetVnum()!=(removing?50349u:50348u))return "material";
|
||||
unsigned mask=0;
|
||||
@@ -51,3 +53,12 @@ const char* PortAttrLockUse(CHARACTER* ch,CItem* item,unsigned slot,CItem* mater
|
||||
material->SetCount(material->GetCount()-1);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Quest selection changes only the material's index; dragging it remains the sole lock mutation path.
|
||||
bool PortAttrLockSelect(CHARACTER* ch,CItem* material,unsigned index) {
|
||||
if (!ch || !material || material->GetOwner()!=ch || material->GetWindow()!=INVENTORY ||
|
||||
(material->GetVnum()!=50348 && material->GetVnum()!=50349) || index<1 || index>5 ||
|
||||
material->GetCount()<1 || material->IsEquipped() || material->IsExchanging() || material->isLocked() ||
|
||||
ch->IsDead() || ch->IsStun() || !ch->CanHandleItem() || ch->GetShop() || ch->GetExchange() || ch->IsOpenSafebox()) return false;
|
||||
material->SetSocket(0,index);material->Save();return true;
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@ inline const char* PortAttrLockToggle(unsigned mask,unsigned slot,unsigned fille
|
||||
class CItem;
|
||||
class CHARACTER;
|
||||
void PortAttrLockBoot();
|
||||
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.
|
||||
unsigned PortAttrLockGet(CItem* item);
|
||||
// Writes synchronously (a following warp loads the new value on the next core); false on SQL error.
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "item_manager.h"
|
||||
#include "over9refine.h"
|
||||
#include "log.h"
|
||||
#include "port_attr_lock.h"
|
||||
|
||||
#undef sys_err
|
||||
#ifndef __WIN32__
|
||||
@@ -467,6 +468,15 @@ namespace quest
|
||||
return 1;
|
||||
}
|
||||
|
||||
int item_select_attr_lock(lua_State* L) {
|
||||
// The quest can yield while the original item moves or is destroyed. Resolve its ID again.
|
||||
const double index=lua_tonumber(L,1),id=lua_tonumber(L,2);
|
||||
if (!lua_isnumber(L,1) || !lua_isnumber(L,2) || !(index>=1 && index<=5) || index!=int(index) ||
|
||||
!(id>0 && id<=4294967295.0) || id!=DWORD(id)) {lua_pushboolean(L,0);return 1;}
|
||||
LPITEM material=ITEM_MANAGER::instance().Find(DWORD(id));
|
||||
lua_pushboolean(L,PortAttrLockSelect(CQuestManager::instance().GetCurrentCharacterPtr(),material,unsigned(index)));return 1;
|
||||
}
|
||||
|
||||
void RegisterITEMFunctionTable()
|
||||
{
|
||||
|
||||
@@ -479,6 +489,7 @@ namespace quest
|
||||
{ "remove", item_remove },
|
||||
{ "get_socket", item_get_socket },
|
||||
{ "set_socket", item_set_socket },
|
||||
{ "select_attr_lock",item_select_attr_lock },
|
||||
{ "set_attribute", item_set_attribute },
|
||||
{ "get_vnum", item_get_vnum },
|
||||
{ "has_flag", item_has_flag },
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Execute the real lock material selection/payment paths, including stale quest and SQL failure."""
|
||||
from pathlib import Path
|
||||
import subprocess,tempfile
|
||||
root=Path(__file__).resolve().parents[2]/'src/server/game/src'
|
||||
source=(root/'port_attr_lock.cpp').read_text()
|
||||
use=source[source.index('const char* PortAttrLockUse('):source.index('// Quest selection')]
|
||||
select=source[source.index('bool PortAttrLockSelect('):]
|
||||
code=r'''
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#define INVENTORY 1
|
||||
struct CHARACTER {bool dead=false,stun=false,busy=false,shop=false,trade=false,safe=false;
|
||||
bool IsDead(){return dead;}bool IsStun(){return stun;}bool CanHandleItem(){return !busy;}
|
||||
bool GetShop(){return shop;}bool GetExchange(){return trade;}bool IsOpenSafebox(){return safe;}
|
||||
};
|
||||
struct Proto {int sAddonType=0;};
|
||||
struct CItem {
|
||||
CHARACTER* owner=nullptr;unsigned vnum=50348,count=3,window=1,mask=0,filled=31,socket=0;bool equipped=false,exchange=false,locked=false,loaded=true,m_portAttrLockLoaded=true;Proto proto;
|
||||
CHARACTER* GetOwner(){return owner;}bool IsEquipped(){return equipped;}bool IsExchanging(){return exchange;}bool isLocked(){return locked;}
|
||||
unsigned GetVnum(){return vnum;}unsigned GetCount(){return count;}unsigned GetWindow(){return window;}
|
||||
const Proto* GetProto(){return &proto;}void SetCount(unsigned n){count=n;}void SetSocket(int,unsigned n){socket=n;}void Save(){}
|
||||
unsigned GetAttributeType(unsigned i){return filled>>i&1;}
|
||||
};
|
||||
#include "port_attr_lock.h"
|
||||
static bool saveOk=true;
|
||||
unsigned PortAttrLockGet(CItem* i){i->m_portAttrLockLoaded=i->loaded;return i->mask;}
|
||||
bool PortAttrLockSet(CHARACTER*,CItem* i,unsigned mask){if(!saveOk)return false;i->mask=mask;return true;}
|
||||
'''+use+select+r'''
|
||||
int main(){
|
||||
CHARACTER ch,other;CItem material,target;material.owner=target.owner=&ch;target.vnum=100;
|
||||
assert(PortAttrLockSelect(&ch,&material,4) && material.socket==4 && material.count==3);
|
||||
assert(!PortAttrLockSelect(&ch,&material,0) && !PortAttrLockSelect(&ch,&material,6));
|
||||
assert(!PortAttrLockSelect(&other,&material,1));material.exchange=true;assert(!PortAttrLockSelect(&ch,&material,1));material.exchange=false;
|
||||
ch.shop=true;assert(!PortAttrLockSelect(&ch,&material,1));ch.shop=false;
|
||||
assert(!PortAttrLockUse(&ch,&target,3,&material) && target.mask==8 && material.count==2);
|
||||
assert(!strcmp(PortAttrLockUse(&ch,&target,3,&material),"material") && material.count==2);
|
||||
material.vnum=50349;assert(!PortAttrLockUse(&ch,&target,3,&material) && target.mask==0 && material.count==1);
|
||||
material.vnum=50348;target.loaded=false;assert(!strcmp(PortAttrLockUse(&ch,&target,1,&material),"db") && material.count==1 && target.mask==0);
|
||||
target.loaded=true;saveOk=false;assert(!strcmp(PortAttrLockUse(&ch,&target,1,&material),"db") && material.count==1 && target.mask==0);saveOk=true;
|
||||
target.equipped=true;assert(!strcmp(PortAttrLockUse(&ch,&target,1,&material),"item"));target.equipped=false;
|
||||
target.owner=&other;assert(!strcmp(PortAttrLockUse(&ch,&target,1,&material),"item"));target.owner=&ch;
|
||||
material.locked=true;assert(!strcmp(PortAttrLockUse(&ch,&target,1,&material),"material"));
|
||||
}
|
||||
'''
|
||||
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: selection ownership/state/index, payment, wrong material, SQL load/save failure, equipped/trade guards: PASS')
|
||||
Reference in New Issue
Block a user