From b8c44ee41ba9e6c1c7cf2c345f49d2843c9a4c75 Mon Sep 17 00:00:00 2001 From: Akkadius Date: Sat, 18 Apr 2020 18:19:59 -0500 Subject: [PATCH] Fix container interaction [skip ci] --- zone/object.cpp | 7 ++++--- zone/zonedb.cpp | 36 +++++++++++++++++++++++------------- 2 files changed, 27 insertions(+), 16 deletions(-) diff --git a/zone/object.cpp b/zone/object.cpp index aa0564c9f..21ce0721a 100644 --- a/zone/object.cpp +++ b/zone/object.cpp @@ -652,9 +652,10 @@ uint32 ZoneDatabase::AddObject(uint32 type, uint32 icon, const Object_Struct& ob return 0; } - // Save container contents, if container - if (inst && inst->IsType(EQEmu::item::ItemClassBag)) - SaveWorldContainer(object.zone_id, database_id, inst); + // Save container contents, if container + if (inst && inst->IsType(EQEmu::item::ItemClassBag)) { + SaveWorldContainer(object.zone_id, database_id, inst); + } return database_id; } diff --git a/zone/zonedb.cpp b/zone/zonedb.cpp index e27ff5636..a1313eacd 100755 --- a/zone/zonedb.cpp +++ b/zone/zonedb.cpp @@ -755,27 +755,37 @@ void ZoneDatabase::SaveWorldContainer(uint32 zone_id, uint32 parent_id, const EQ } } - std::string query = StringFormat("REPLACE INTO object_contents " - "(zoneid, parentid, bagidx, itemid, charges, " - "augslot1, augslot2, augslot3, augslot4, augslot5, augslot6, droptime) " - "VALUES (%i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, now())", - zone_id, parent_id, index, item_id, inst->GetCharges(), - augslot[0], augslot[1], augslot[2], augslot[3], augslot[4], augslot[5]); - auto results = QueryDatabase(query); - if (!results.Success()) - LogError("Error in ZoneDatabase::SaveWorldContainer: [{}]", results.ErrorMessage().c_str()); + std::string query = StringFormat( + "REPLACE INTO object_contents " + "(zoneid, parentid, bagidx, itemid, charges, " + "augslot1, augslot2, augslot3, augslot4, augslot5, augslot6, droptime) " + "VALUES (%i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, now())", + zone_id, parent_id, index, item_id, inst->GetCharges(), + augslot[0], augslot[1], augslot[2], augslot[3], augslot[4], augslot[5] + ); - } + auto results = database.QueryDatabase(query); + if (!results.Success()) { + LogError("Error in ZoneDatabase::SaveWorldContainer: [{}]", results.ErrorMessage().c_str()); + } + + } } // Remove all child objects inside a world container (i.e., forge, bag dropped to ground, etc) void ZoneDatabase::DeleteWorldContainer(uint32 parent_id, uint32 zone_id) { - std::string query = StringFormat("DELETE FROM object_contents WHERE parentid = %i AND zoneid = %i", parent_id, zone_id); - auto results = QueryDatabase(query); - if (!results.Success()) + std::string query = StringFormat( + "DELETE FROM object_contents WHERE parentid = %i AND zoneid = %i", + parent_id, + zone_id + ); + + auto results = database.QueryDatabase(query); + if (!results.Success()) { LogError("Error in ZoneDatabase::DeleteWorldContainer: [{}]", results.ErrorMessage().c_str()); + } }