mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-12 05:21:29 +00:00
[Bug Fix] Limit merchant temp item list to zone and instance (#2346)
This prevents issues with a merchant being in more than one zone as well as guild hall merchants sharing a list of temp items
This commit is contained in:
parent
53b599518a
commit
c6cfcc3ea9
@ -34,7 +34,7 @@
|
|||||||
* Manifest: https://github.com/EQEmu/Server/blob/master/utils/sql/db_update_manifest.txt
|
* Manifest: https://github.com/EQEmu/Server/blob/master/utils/sql/db_update_manifest.txt
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define CURRENT_BINARY_DATABASE_VERSION 9195
|
#define CURRENT_BINARY_DATABASE_VERSION 9196
|
||||||
|
|
||||||
#ifdef BOTS
|
#ifdef BOTS
|
||||||
#define CURRENT_BINARY_BOTS_DATABASE_VERSION 9029
|
#define CURRENT_BINARY_BOTS_DATABASE_VERSION 9029
|
||||||
|
|||||||
@ -449,6 +449,7 @@
|
|||||||
9193|2022_07_16_task_timer_groups.sql|SHOW COLUMNS FROM `tasks` LIKE 'replay_timer_group'|empty|
|
9193|2022_07_16_task_timer_groups.sql|SHOW COLUMNS FROM `tasks` LIKE 'replay_timer_group'|empty|
|
||||||
9194|2022_07_23_dz_switch_id.sql|SHOW COLUMNS FROM `doors` LIKE 'dz_switch_id'|empty|
|
9194|2022_07_23_dz_switch_id.sql|SHOW COLUMNS FROM `doors` LIKE 'dz_switch_id'|empty|
|
||||||
9195|2022_07_23_dz_templates.sql|SHOW TABLES like 'dynamic_zone_templates'|empty|
|
9195|2022_07_23_dz_templates.sql|SHOW TABLES like 'dynamic_zone_templates'|empty|
|
||||||
|
9196|2022_07_30_merchantlist_temp.sql|SHOW COLUMNS FROM `merchantlist_temp` LIKE 'zone_id'|empty|
|
||||||
|
|
||||||
# Upgrade conditions:
|
# Upgrade conditions:
|
||||||
# This won't be needed after this system is implemented, but it is used database that are not
|
# This won't be needed after this system is implemented, but it is used database that are not
|
||||||
|
|||||||
3
utils/sql/git/required/2022_07_30_merchantlist_temp.sql
Normal file
3
utils/sql/git/required/2022_07_30_merchantlist_temp.sql
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
ALTER TABLE `merchantlist_temp` ADD COLUMN `zone_id` INT(11) NOT NULL DEFAULT '0' AFTER `slot`;
|
||||||
|
ALTER TABLE `merchantlist_temp` ADD COLUMN `instance_id` INT(11) NOT NULL DEFAULT '0' AFTER `zone_id`;
|
||||||
|
ALTER TABLE `merchantlist_temp` DROP PRIMARY KEY, ADD PRIMARY KEY (`npcid`, `slot`, `zone_id`, `instance_id`);
|
||||||
@ -433,10 +433,10 @@ int Zone::SaveTempItem(uint32 merchantid, uint32 npcid, uint32 item, int32 charg
|
|||||||
ml.origslot = ml.slot;
|
ml.origslot = ml.slot;
|
||||||
}
|
}
|
||||||
if (ml.charges > 0) {
|
if (ml.charges > 0) {
|
||||||
database.SaveMerchantTemp(npcid, ml.origslot, item, ml.charges);
|
database.SaveMerchantTemp(npcid, ml.origslot, GetZoneID(), GetInstanceID(), item, ml.charges);
|
||||||
tmp_merlist.push_back(ml);
|
tmp_merlist.push_back(ml);
|
||||||
} else {
|
} else {
|
||||||
database.DeleteMerchantTemp(npcid, ml.origslot);
|
database.DeleteMerchantTemp(npcid, ml.origslot, GetZoneID(), GetInstanceID());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -494,7 +494,7 @@ int Zone::SaveTempItem(uint32 merchantid, uint32 npcid, uint32 item, int32 charg
|
|||||||
|
|
||||||
first_empty_mslot = idx;
|
first_empty_mslot = idx;
|
||||||
|
|
||||||
database.SaveMerchantTemp(npcid, first_empty_slot, item, charges);
|
database.SaveMerchantTemp(npcid, first_empty_slot, GetZoneID(), GetInstanceID(), item, charges);
|
||||||
tmp_merlist = tmpmerchanttable[npcid];
|
tmp_merlist = tmpmerchanttable[npcid];
|
||||||
TempMerchantList ml2;
|
TempMerchantList ml2;
|
||||||
ml2.charges = charges;
|
ml2.charges = charges;
|
||||||
@ -565,8 +565,11 @@ void Zone::LoadTempMerchantData()
|
|||||||
itemid
|
itemid
|
||||||
FROM merchantlist_temp
|
FROM merchantlist_temp
|
||||||
WHERE npcid IN ({})
|
WHERE npcid IN ({})
|
||||||
|
AND zone_id = {}
|
||||||
|
AND instance_id = {}
|
||||||
),
|
),
|
||||||
Strings::Implode(", ", npc_ids)
|
Strings::Implode(", ", npc_ids),
|
||||||
|
GetZoneID(), GetInstanceID()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -3133,15 +3133,16 @@ uint8 ZoneDatabase::GetGridType(uint32 grid, uint32 zoneid ) {
|
|||||||
return atoi(row[0]);
|
return atoi(row[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZoneDatabase::SaveMerchantTemp(uint32 npcid, uint32 slot, uint32 item, uint32 charges){
|
void ZoneDatabase::SaveMerchantTemp(uint32 npcid, uint32 slot, uint32 zone_id, uint32 instance_id, uint32 item, uint32 charges){
|
||||||
|
|
||||||
std::string query = StringFormat("REPLACE INTO merchantlist_temp (npcid, slot, itemid, charges) "
|
std::string query = StringFormat("REPLACE INTO merchantlist_temp (npcid, slot, zone_id, instance_id, itemid, charges) "
|
||||||
"VALUES(%d, %d, %d, %d)", npcid, slot, item, charges);
|
"VALUES(%d, %d, %d, %d, %d, %d)", npcid, slot, zone_id, instance_id, item, charges);
|
||||||
QueryDatabase(query);
|
QueryDatabase(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZoneDatabase::DeleteMerchantTemp(uint32 npcid, uint32 slot){
|
void ZoneDatabase::DeleteMerchantTemp(uint32 npcid, uint32 slot, uint32 zone_id, uint32 instance_id) {
|
||||||
std::string query = StringFormat("DELETE FROM merchantlist_temp WHERE npcid=%d AND slot=%d", npcid, slot);
|
std::string query = StringFormat("DELETE FROM merchantlist_temp WHERE npcid=%d AND slot=%d AND zone_id=%d AND instance_id=%d",
|
||||||
|
npcid, slot, zone_id, instance_id);
|
||||||
QueryDatabase(query);
|
QueryDatabase(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -526,8 +526,8 @@ public:
|
|||||||
void RefreshPetitionsFromDB();
|
void RefreshPetitionsFromDB();
|
||||||
|
|
||||||
/* Merchants */
|
/* Merchants */
|
||||||
void SaveMerchantTemp(uint32 npcid, uint32 slot, uint32 item, uint32 charges);
|
void SaveMerchantTemp(uint32 npcid, uint32 slot, uint32 zone_id, uint32 instance_id, uint32 item, uint32 charges);
|
||||||
void DeleteMerchantTemp(uint32 npcid, uint32 slot);
|
void DeleteMerchantTemp(uint32 npcid, uint32 slot, uint32 zone_id, uint32 instance_id);
|
||||||
|
|
||||||
/* Tradeskills */
|
/* Tradeskills */
|
||||||
bool GetTradeRecipe(const EQ::ItemInstance* container, uint8 c_type, uint32 some_id, uint32 char_id, DBTradeskillRecipe_Struct *spec);
|
bool GetTradeRecipe(const EQ::ItemInstance* container, uint8 c_type, uint32 some_id, uint32 char_id, DBTradeskillRecipe_Struct *spec);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user