Core/Player: Fix issues with 'ignore this slot' option on equipment manager usage

This commit is contained in:
NNN666
2012-07-13 15:16:37 +02:00
committed by Odyssey
parent 176a2c1080
commit e757ebf6ba
6 changed files with 70 additions and 25 deletions

View File

@@ -547,25 +547,26 @@ CREATE TABLE `character_equipmentsets` (
`setindex` tinyint(3) unsigned NOT NULL DEFAULT '0',
`name` varchar(31) NOT NULL,
`iconname` varchar(100) NOT NULL,
`item0` int(10) unsigned NOT NULL DEFAULT '0',
`item1` int(10) unsigned NOT NULL DEFAULT '0',
`item2` int(10) unsigned NOT NULL DEFAULT '0',
`item3` int(10) unsigned NOT NULL DEFAULT '0',
`item4` int(10) unsigned NOT NULL DEFAULT '0',
`item5` int(10) unsigned NOT NULL DEFAULT '0',
`item6` int(10) unsigned NOT NULL DEFAULT '0',
`item7` int(10) unsigned NOT NULL DEFAULT '0',
`item8` int(10) unsigned NOT NULL DEFAULT '0',
`item9` int(10) unsigned NOT NULL DEFAULT '0',
`item10` int(10) unsigned NOT NULL DEFAULT '0',
`item11` int(10) unsigned NOT NULL DEFAULT '0',
`item12` int(10) unsigned NOT NULL DEFAULT '0',
`item13` int(10) unsigned NOT NULL DEFAULT '0',
`item14` int(10) unsigned NOT NULL DEFAULT '0',
`item15` int(10) unsigned NOT NULL DEFAULT '0',
`item16` int(10) unsigned NOT NULL DEFAULT '0',
`item17` int(10) unsigned NOT NULL DEFAULT '0',
`item18` int(10) unsigned NOT NULL DEFAULT '0',
`ignore_mask` int(11) unsigned NOT NULL DEFAULT '0',
`item0` int(11) unsigned NOT NULL DEFAULT '0',
`item1` int(11) unsigned NOT NULL DEFAULT '0',
`item2` int(11) unsigned NOT NULL DEFAULT '0',
`item3` int(11) unsigned NOT NULL DEFAULT '0',
`item4` int(11) unsigned NOT NULL DEFAULT '0',
`item5` int(11) unsigned NOT NULL DEFAULT '0',
`item6` int(11) unsigned NOT NULL DEFAULT '0',
`item7` int(11) unsigned NOT NULL DEFAULT '0',
`item8` int(11) unsigned NOT NULL DEFAULT '0',
`item9` int(11) unsigned NOT NULL DEFAULT '0',
`item10` int(11) unsigned NOT NULL DEFAULT '0',
`item11` int(11) unsigned NOT NULL DEFAULT '0',
`item12` int(11) unsigned NOT NULL DEFAULT '0',
`item13` int(11) unsigned NOT NULL DEFAULT '0',
`item14` int(11) unsigned NOT NULL DEFAULT '0',
`item15` int(11) unsigned NOT NULL DEFAULT '0',
`item16` int(11) unsigned NOT NULL DEFAULT '0',
`item17` int(11) unsigned NOT NULL DEFAULT '0',
`item18` int(11) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`setguid`),
UNIQUE KEY `idx_set` (`guid`,`setguid`,`setindex`),
KEY `Idx_setindex` (`setindex`)

View File

@@ -0,0 +1,22 @@
ALTER TABLE `character_equipmentsets`
MODIFY COLUMN `item0` int(11) unsigned NOT NULL DEFAULT 0,
MODIFY COLUMN `item1` int(11) unsigned NOT NULL DEFAULT 0,
MODIFY COLUMN `item2` int(11) unsigned NOT NULL DEFAULT 0,
MODIFY COLUMN `item3` int(11) unsigned NOT NULL DEFAULT 0,
MODIFY COLUMN `item4` int(11) unsigned NOT NULL DEFAULT 0,
MODIFY COLUMN `item5` int(11) unsigned NOT NULL DEFAULT 0,
MODIFY COLUMN `item6` int(11) unsigned NOT NULL DEFAULT 0,
MODIFY COLUMN `item7` int(11) unsigned NOT NULL DEFAULT 0,
MODIFY COLUMN `item8` int(11) unsigned NOT NULL DEFAULT 0,
MODIFY COLUMN `item9` int(11) unsigned NOT NULL DEFAULT 0,
MODIFY COLUMN `item10` int(11) unsigned NOT NULL DEFAULT 0,
MODIFY COLUMN `item11` int(11) unsigned NOT NULL DEFAULT 0,
MODIFY COLUMN `item12` int(11) unsigned NOT NULL DEFAULT 0,
MODIFY COLUMN `item13` int(11) unsigned NOT NULL DEFAULT 0,
MODIFY COLUMN `item14` int(11) unsigned NOT NULL DEFAULT 0,
MODIFY COLUMN `item15` int(11) unsigned NOT NULL DEFAULT 0,
MODIFY COLUMN `item16` int(11) unsigned NOT NULL DEFAULT 0,
MODIFY COLUMN `item17` int(11) unsigned NOT NULL DEFAULT 0,
MODIFY COLUMN `item18` int(11) unsigned NOT NULL DEFAULT 0;
ALTER TABLE `character_equipmentsets` ADD COLUMN `ignore_mask` int(11) unsigned NOT NULL DEFAULT 0 AFTER `iconname`;

View File

@@ -16677,10 +16677,11 @@ void Player::_LoadEquipmentSets(PreparedQueryResult result)
uint8 index = fields[1].GetUInt8();
eqSet.Name = fields[2].GetString();
eqSet.IconName = fields[3].GetString();
eqSet.IgnoreMask = fields[4].GetUInt32();
eqSet.state = EQUIPMENT_SET_UNCHANGED;
for (uint32 i = 0; i < EQUIPMENT_SLOT_END; ++i)
eqSet.Items[i] = fields[4+i].GetUInt32();
eqSet.Items[i] = fields[5+i].GetUInt32();
m_EquipmentSets[index] = eqSet;
@@ -24822,7 +24823,13 @@ void Player::SendEquipmentSetList()
data << itr->second.Name;
data << itr->second.IconName;
for (uint32 i = 0; i < EQUIPMENT_SLOT_END; ++i)
data.appendPackGUID(MAKE_NEW_GUID(itr->second.Items[i], 0, HIGHGUID_ITEM));
{
// ignored slots stored in IgnoreMask, client wants "1" as raw GUID, so no HIGHGUID_ITEM
if (itr->second.IgnoreMask & (1 << i))
data.appendPackGUID(MAKE_NEW_GUID(uint64(1)));
else
data.appendPackGUID(MAKE_NEW_GUID(itr->second.Items[i], 0, HIGHGUID_ITEM));
}
++count; // client have limit but it checked at loading and set
}
@@ -24888,6 +24895,7 @@ void Player::_SaveEquipmentSets(SQLTransaction& trans)
stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_EQUIP_SET);
stmt->setString(j++, eqset.Name.c_str());
stmt->setString(j++, eqset.IconName.c_str());
stmt->setUInt32(j++, eqset.IgnoreMask);
for (uint8 i=0; i<EQUIPMENT_SLOT_END; ++i)
stmt->setUInt32(j++, eqset.Items[i]);
stmt->setUInt32(j++, GetGUIDLow());
@@ -24904,6 +24912,7 @@ void Player::_SaveEquipmentSets(SQLTransaction& trans)
stmt->setUInt32(j++, index);
stmt->setString(j++, eqset.Name.c_str());
stmt->setString(j++, eqset.IconName.c_str());
stmt->setUInt32(j++, eqset.IgnoreMask);
for (uint8 i=0; i<EQUIPMENT_SLOT_END; ++i)
stmt->setUInt32(j++, eqset.Items[i]);
trans->Append(stmt);

View File

@@ -640,7 +640,7 @@ enum EquipmentSetUpdateState
struct EquipmentSet
{
EquipmentSet() : Guid(0), state(EQUIPMENT_SET_NEW)
EquipmentSet() : Guid(0), IgnoreMask(0), state(EQUIPMENT_SET_NEW)
{
for (uint8 i = 0; i < EQUIPMENT_SLOT_END; ++i)
Items[i] = 0;
@@ -649,6 +649,7 @@ struct EquipmentSet
uint64 Guid;
std::string Name;
std::string IconName;
uint32 IgnoreMask;
uint32 Items[EQUIPMENT_SLOT_END];
EquipmentSetUpdateState state;
};

View File

@@ -1514,6 +1514,14 @@ void WorldSession::HandleEquipmentSetSave(WorldPacket &recv_data)
uint64 itemGuid;
recv_data.readPackGUID(itemGuid);
// equipment manager sends "1" (as raw GUID) for slots set to "ignore" (don't touch slot at equip set)
if (itemGuid == 1)
{
// ignored slots saved as bit mask because we have no free special values for Items[i]
eqSet.IgnoreMask |= 1 << i;
continue;
}
Item* item = _player->GetItemByPos(INVENTORY_SLOT_BAG_0, i);
if (!item && itemGuid) // cheating check 1
@@ -1555,6 +1563,10 @@ void WorldSession::HandleEquipmentSetUse(WorldPacket &recv_data)
sLog->outDebug(LOG_FILTER_PLAYER_ITEMS, "Item " UI64FMTD ": srcbag %u, srcslot %u", itemGuid, srcbag, srcslot);
// check if item slot is set to "ignored" (raw value == 1), must not be unequipped then
if (itemGuid == 1)
continue;
Item* item = _player->GetItemByGuid(itemGuid);
uint16 dstpos = i | (INVENTORY_SLOT_BAG_0 << 8);

View File

@@ -94,7 +94,7 @@ void CharacterDatabaseConnection::DoPrepareStatements()
PREPARE_STATEMENT(CHAR_SEL_GUILD_MEMBER, "SELECT guildid, rank FROM guild_member WHERE guid = ?", CONNECTION_BOTH)
PREPARE_STATEMENT(CHAR_SEL_CHARACTER_ACHIEVEMENTS, "SELECT achievement, date FROM character_achievement WHERE guid = ?", CONNECTION_ASYNC)
PREPARE_STATEMENT(CHAR_SEL_CHARACTER_CRITERIAPROGRESS, "SELECT criteria, counter, date FROM character_achievement_progress WHERE guid = ?", CONNECTION_ASYNC)
PREPARE_STATEMENT(CHAR_SEL_CHARACTER_EQUIPMENTSETS, "SELECT setguid, setindex, name, iconname, item0, item1, item2, item3, item4, item5, item6, item7, item8, "
PREPARE_STATEMENT(CHAR_SEL_CHARACTER_EQUIPMENTSETS, "SELECT setguid, setindex, name, iconname, ignore_mask, item0, item1, item2, item3, item4, item5, item6, item7, item8, "
"item9, item10, item11, item12, item13, item14, item15, item16, item17, item18 FROM character_equipmentsets WHERE guid = ? ORDER BY setindex", CONNECTION_ASYNC)
PREPARE_STATEMENT(CHAR_SEL_CHARACTER_BGDATA, "SELECT instanceId, team, joinX, joinY, joinZ, joinO, joinMapId, taxiStart, taxiEnd, mountSpell FROM character_battleground_data WHERE guid = ?", CONNECTION_ASYNC)
PREPARE_STATEMENT(CHAR_SEL_CHARACTER_GLYPHS, "SELECT spec, glyph1, glyph2, glyph3, glyph4, glyph5, glyph6 FROM character_glyphs WHERE guid = ?", CONNECTION_ASYNC)
@@ -235,8 +235,8 @@ void CharacterDatabaseConnection::DoPrepareStatements()
PREPARE_STATEMENT(CHAR_DEL_OLD_CHANNELS, "DELETE FROM channels WHERE ownership = 1 AND lastUsed + ? < UNIX_TIMESTAMP()", CONNECTION_ASYNC)
// Equipmentsets
PREPARE_STATEMENT(CHAR_UPD_EQUIP_SET, "UPDATE character_equipmentsets SET name=?, iconname=?, item0=?, item1=?, item2=?, item3=?, item4=?, item5=?, item6=?, item7=?, item8=?, item9=?, item10=?, item11=?, item12=?, item13=?, item14=?, item15=?, item16=?, item17=?, item18=? WHERE guid=? AND setguid=? AND setindex=?", CONNECTION_ASYNC)
PREPARE_STATEMENT(CHAR_INS_EQUIP_SET, "INSERT INTO character_equipmentsets (guid, setguid, setindex, name, iconname, item0, item1, item2, item3, item4, item5, item6, item7, item8, item9, item10, item11, item12, item13, item14, item15, item16, item17, item18) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC)
PREPARE_STATEMENT(CHAR_UPD_EQUIP_SET, "UPDATE character_equipmentsets SET name=?, iconname=?, ignore_mask=?, item0=?, item1=?, item2=?, item3=?, item4=?, item5=?, item6=?, item7=?, item8=?, item9=?, item10=?, item11=?, item12=?, item13=?, item14=?, item15=?, item16=?, item17=?, item18=? WHERE guid=? AND setguid=? AND setindex=?", CONNECTION_ASYNC)
PREPARE_STATEMENT(CHAR_INS_EQUIP_SET, "INSERT INTO character_equipmentsets (guid, setguid, setindex, name, iconname, ignore_mask, item0, item1, item2, item3, item4, item5, item6, item7, item8, item9, item10, item11, item12, item13, item14, item15, item16, item17, item18) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC)
PREPARE_STATEMENT(CHAR_DEL_EQUIP_SET, "DELETE FROM character_equipmentsets WHERE setguid=?", CONNECTION_ASYNC)
// Auras