From 1ffde196cebd8a3ed4859ce75e8febcf332ed9a0 Mon Sep 17 00:00:00 2001 From: Lynx3d Date: Fri, 10 Jun 2011 18:49:58 +0200 Subject: [PATCH] [11620] Make equipment manager handle "ignore this slot" option properly. Also fix SQL fields to use unsigned values as expected in code, otherwise large values will get lost. --- sql/characters.sql | 41 ++++++++++--------- ..._01_characters_character_equipmentsets.sql | 24 +++++++++++ src/game/CharacterHandler.cpp | 14 ++++++- src/game/Player.cpp | 29 ++++++++----- src/game/Player.h | 3 +- src/shared/revision_nr.h | 2 +- src/shared/revision_sql.h | 2 +- 7 files changed, 81 insertions(+), 34 deletions(-) create mode 100644 sql/updates/11620_01_characters_character_equipmentsets.sql diff --git a/sql/characters.sql b/sql/characters.sql index df077652b..3bd4c7859 100644 --- a/sql/characters.sql +++ b/sql/characters.sql @@ -21,7 +21,7 @@ DROP TABLE IF EXISTS `character_db_version`; CREATE TABLE `character_db_version` ( - `required_11436_01_characters_character_queststatus` bit(1) default NULL + `required_11620_01_characters_character_equipmentsets` bit(1) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Last applied sql update to DB'; -- @@ -460,25 +460,26 @@ CREATE TABLE `character_equipmentsets` ( `setindex` tinyint(4) NOT NULL default '0', `name` varchar(100) NOT NULL, `iconname` varchar(100) NOT NULL, - `item0` int(11) NOT NULL default '0', - `item1` int(11) NOT NULL default '0', - `item2` int(11) NOT NULL default '0', - `item3` int(11) NOT NULL default '0', - `item4` int(11) NOT NULL default '0', - `item5` int(11) NOT NULL default '0', - `item6` int(11) NOT NULL default '0', - `item7` int(11) NOT NULL default '0', - `item8` int(11) NOT NULL default '0', - `item9` int(11) NOT NULL default '0', - `item10` int(11) NOT NULL default '0', - `item11` int(11) NOT NULL default '0', - `item12` int(11) NOT NULL default '0', - `item13` int(11) NOT NULL default '0', - `item14` int(11) NOT NULL default '0', - `item15` int(11) NOT NULL default '0', - `item16` int(11) NOT NULL default '0', - `item17` int(11) NOT NULL default '0', - `item18` int(11) 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`), INDEX `Idx_setindex` (`setindex`) diff --git a/sql/updates/11620_01_characters_character_equipmentsets.sql b/sql/updates/11620_01_characters_character_equipmentsets.sql new file mode 100644 index 000000000..5739e964f --- /dev/null +++ b/sql/updates/11620_01_characters_character_equipmentsets.sql @@ -0,0 +1,24 @@ +ALTER TABLE character_db_version CHANGE COLUMN required_11436_01_characters_character_queststatus required_11620_01_characters_character_equipmentsets bit; + +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; diff --git a/src/game/CharacterHandler.cpp b/src/game/CharacterHandler.cpp index ae5a9728a..ac8857dff 100644 --- a/src/game/CharacterHandler.cpp +++ b/src/game/CharacterHandler.cpp @@ -95,7 +95,7 @@ bool LoginQueryHolder::Initialize() res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADARENAINFO, "SELECT arenateamid, played_week, played_season, wons_season, personal_rating FROM arena_team_member WHERE guid='%u'", m_guid.GetCounter()); res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADACHIEVEMENTS, "SELECT achievement, date FROM character_achievement WHERE guid = '%u'", m_guid.GetCounter()); res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADCRITERIAPROGRESS,"SELECT criteria, counter, date FROM character_achievement_progress WHERE guid = '%u'", m_guid.GetCounter()); - res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADEQUIPMENTSETS, "SELECT setguid, setindex, name, iconname, item0, item1, item2, item3, item4, item5, item6, item7, item8, item9, item10, item11, item12, item13, item14, item15, item16, item17, item18 FROM character_equipmentsets WHERE guid = '%u' ORDER BY setindex", m_guid.GetCounter()); + res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADEQUIPMENTSETS, "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 = '%u' ORDER BY setindex", m_guid.GetCounter()); res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADBGDATA, "SELECT instance_id, team, join_x, join_y, join_z, join_o, join_map, taxi_start, taxi_end, mount_spell FROM character_battleground_data WHERE guid = '%u'", m_guid.GetCounter()); res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADACCOUNTDATA, "SELECT type, time, data FROM character_account_data WHERE guid='%u'", m_guid.GetCounter()); res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADTALENTS, "SELECT talent_id, current_rank, spec FROM character_talent WHERE guid = '%u'", m_guid.GetCounter()); @@ -1242,6 +1242,14 @@ void WorldSession::HandleEquipmentSetSaveOpcode(WorldPacket &recv_data) recv_data >> itemGuid.ReadAsPacked(); + // equipment manager sends "1" (as raw GUID) for slots set to "ignore" (not touch slot at equip set) + if (itemGuid.GetRawValue() == 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 @@ -1282,6 +1290,10 @@ void WorldSession::HandleEquipmentSetUseOpcode(WorldPacket &recv_data) DEBUG_LOG("Item (%s): srcbag %u, srcslot %u", itemGuid.GetString().c_str(), srcbag, srcslot); + // check if item slot is set to "ignored" (raw value == 1), must not be unequipped then + if (itemGuid.GetRawValue() == 1) + continue; + Item *item = _player->GetItemByGuid(itemGuid); uint16 dstpos = i | (INVENTORY_SLOT_BAG_0 << 8); diff --git a/src/game/Player.cpp b/src/game/Player.cpp index fd569be65..9fe80b4b7 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -15233,7 +15233,7 @@ void Player::_LoadArenaTeamInfo(QueryResult *result) void Player::_LoadEquipmentSets(QueryResult *result) { - // SetPQuery(PLAYER_LOGIN_QUERY_LOADEQUIPMENTSETS, "SELECT setguid, setindex, name, iconname, item0, item1, item2, item3, item4, item5, item6, item7, item8, item9, item10, item11, item12, item13, item14, item15, item16, item17, item18 FROM character_equipmentsets WHERE guid = '%u' ORDER BY setindex", GUID_LOPART(m_guid)); + // SetPQuery(PLAYER_LOGIN_QUERY_LOADEQUIPMENTSETS, "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 = '%u' ORDER BY setindex", GUID_LOPART(m_guid)); if (!result) return; @@ -15244,14 +15244,15 @@ void Player::_LoadEquipmentSets(QueryResult *result) EquipmentSet eqSet; - eqSet.Guid = fields[0].GetUInt64(); - uint32 index = fields[1].GetUInt32(); - eqSet.Name = fields[2].GetCppString(); - eqSet.IconName = fields[3].GetCppString(); - eqSet.state = EQUIPMENT_SET_UNCHANGED; + eqSet.Guid = fields[0].GetUInt64(); + uint32 index = fields[1].GetUInt32(); + eqSet.Name = fields[2].GetCppString(); + eqSet.IconName = fields[3].GetCppString(); + 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; @@ -22405,7 +22406,13 @@ void Player::SendEquipmentSetList() data << itr->second.Name; data << itr->second.IconName; for(uint32 i = 0; i < EQUIPMENT_SLOT_END; ++i) - data << ObjectGuid(HIGHGUID_ITEM, itr->second.Items[i]).WriteAsPacked(); + { + // ignored slots stored in IgnoreMask, client wants "1" as raw GUID, so no HIGHGUID_ITEM + if (itr->second.IgnoreMask & (1 << i)) + data << ObjectGuid(uint64(1)).WriteAsPacked(); + else + data << ObjectGuid(HIGHGUID_ITEM, itr->second.Items[i]).WriteAsPacked(); + } ++count; // client have limit but it checked at loading and set } @@ -22471,12 +22478,13 @@ void Player::_SaveEquipmentSets() break; // nothing do case EQUIPMENT_SET_CHANGED: { - SqlStatement stmt = CharacterDatabase.CreateStatement(updSets, "UPDATE character_equipmentsets SET name=?, iconname=?, item0=?, item1=?, item2=?, item3=?, item4=?, " + SqlStatement stmt = CharacterDatabase.CreateStatement(updSets, "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=?"); stmt.addString(eqset.Name); stmt.addString(eqset.IconName); + stmt.addUInt32(eqset.IgnoreMask); for (int i = 0; i < EQUIPMENT_SLOT_END; ++i) stmt.addUInt32(eqset.Items[i]); @@ -22493,12 +22501,13 @@ void Player::_SaveEquipmentSets() } case EQUIPMENT_SET_NEW: { - SqlStatement stmt = CharacterDatabase.CreateStatement(insSets, "INSERT INTO character_equipmentsets VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); + SqlStatement stmt = CharacterDatabase.CreateStatement(insSets, "INSERT INTO character_equipmentsets VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); stmt.addUInt32(GetGUIDLow()); stmt.addUInt64(eqset.Guid); stmt.addUInt32(index); stmt.addString(eqset.Name); stmt.addString(eqset.IconName); + stmt.addUInt32(eqset.IgnoreMask); for (int i = 0; i < EQUIPMENT_SLOT_END; ++i) stmt.addUInt32(eqset.Items[i]); diff --git a/src/game/Player.h b/src/game/Player.h index 8954eceff..3221656ca 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -707,7 +707,7 @@ enum EquipmentSetUpdateState struct EquipmentSet { - EquipmentSet() : Guid(0), state(EQUIPMENT_SET_NEW) + EquipmentSet() : Guid(0), IgnoreMask(0), state(EQUIPMENT_SET_NEW) { for(int i = 0; i < EQUIPMENT_SLOT_END; ++i) Items[i] = 0; @@ -716,6 +716,7 @@ struct EquipmentSet uint64 Guid; std::string Name; std::string IconName; + uint32 IgnoreMask; uint32 Items[EQUIPMENT_SLOT_END]; EquipmentSetUpdateState state; }; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index cb41e678f..9fa047b34 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "11619" + #define REVISION_NR "11620" #endif // __REVISION_NR_H__ diff --git a/src/shared/revision_sql.h b/src/shared/revision_sql.h index 177df37c7..eb5085920 100644 --- a/src/shared/revision_sql.h +++ b/src/shared/revision_sql.h @@ -1,6 +1,6 @@ #ifndef __REVISION_SQL_H__ #define __REVISION_SQL_H__ - #define REVISION_DB_CHARACTERS "required_11436_01_characters_character_queststatus" + #define REVISION_DB_CHARACTERS "required_11620_01_characters_character_equipmentsets" #define REVISION_DB_MANGOS "required_11613_01_mangos_spell_bonus_data" #define REVISION_DB_REALMD "required_10008_01_realmd_realmd_db_version" #endif // __REVISION_SQL_H__