Synchronize owner attribute locks for links and active switchbot
This commit is contained in:
@@ -494,6 +494,7 @@ void CHARACTER::SetItem(TItemPos Cell, LPITEM pItem)
|
||||
break;
|
||||
}
|
||||
}
|
||||
PortAttrLockSend(this,pItem,Cell.window_type,Cell.cell);
|
||||
}
|
||||
|
||||
LPITEM CHARACTER::GetWear(BYTE bCell) const
|
||||
|
||||
@@ -15,6 +15,7 @@ ACMD(do_setpickupmode);
|
||||
ACMD(do_track_window);
|
||||
ACMD(do_channel_list);
|
||||
ACMD(do_attr_lock_info);
|
||||
ACMD(do_attr_lock_sync);
|
||||
ACMD(do_open_shop);
|
||||
ACMD(do_port_chest);
|
||||
ACMD(do_chest_drop);
|
||||
@@ -615,6 +616,7 @@ struct command_info cmd_info[] =
|
||||
{ "channel_list",do_channel_list,0,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_sync",do_attr_lock_sync,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 },
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "stdafx.h"
|
||||
#include "port_attr_lock.h"
|
||||
#include "utils.h"
|
||||
#include "config.h"
|
||||
#include "char.h"
|
||||
@@ -228,6 +229,7 @@ void CItem::UpdatePacket()
|
||||
|
||||
sys_log(2, "UpdatePacket %s -> %s", GetName(), m_pOwner->GetName());
|
||||
m_pOwner->GetDesc()->Packet(&pack, sizeof(pack));
|
||||
PortAttrLockSend(m_pOwner,this,GetWindow(),GetCell());
|
||||
}
|
||||
|
||||
DWORD CItem::GetCount()
|
||||
|
||||
@@ -5,6 +5,36 @@
|
||||
#include "item.h"
|
||||
#include "log.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() {
|
||||
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;
|
||||
char hint[16];snprintf(hint,sizeof(hint),"%u",mask);
|
||||
if(ch)LogManager::instance().ItemLog(ch,item,"ATTR_LOCK",hint);
|
||||
if (item->GetOwner()) PortAttrLockSend(item->GetOwner(),item,item->GetWindow(),item->GetCell());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -47,6 +47,8 @@ inline const char* PortAttrLockToggle(unsigned mask,unsigned slot,unsigned fille
|
||||
class CItem;
|
||||
class CHARACTER;
|
||||
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);
|
||||
// Cached on the item after the first lookup. A failed lookup returns 0 and is retried next time.
|
||||
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
|
||||
// 9 = talismans (port_pendant.cpp), whose pools are not in item_attr.
|
||||
#include "stdafx.h"
|
||||
#include "port_attr_lock.h"
|
||||
#include "constants.h"
|
||||
#include "port_switchbot.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(&update, sizeof(update));
|
||||
desc->Packet(tmp_buf.read_peek(), tmp_buf.size());
|
||||
PortAttrLockSend(ch,item,SWITCHBOT,slot);
|
||||
}
|
||||
|
||||
CSwitchbotManager::~CSwitchbotManager()
|
||||
|
||||
Reference in New Issue
Block a user