mirror of
https://github.com/EQEmu/Server.git
synced 2026-04-16 01:22:25 +00:00
VerifyInventory converted to QueryDatabase
This commit is contained in:
parent
95208eb24e
commit
2fbd170188
@ -123,39 +123,36 @@ bool SharedDatabase::SaveCursor(uint32 char_id, std::list<ItemInst*>::const_iter
|
|||||||
|
|
||||||
bool SharedDatabase::VerifyInventory(uint32 account_id, int16 slot_id, const ItemInst* inst)
|
bool SharedDatabase::VerifyInventory(uint32 account_id, int16 slot_id, const ItemInst* inst)
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
|
||||||
char* query = 0;
|
|
||||||
MYSQL_RES *result;
|
|
||||||
MYSQL_ROW row;
|
|
||||||
// Delete cursor items
|
// Delete cursor items
|
||||||
if (!RunQuery(query, MakeAnyLenString(&query,
|
std::string query = StringFormat("SELECT itemid, charges FROM sharedbank "
|
||||||
"SELECT itemid,charges FROM sharedbank "
|
"WHERE acctid = %d AND slotid = %d",
|
||||||
"WHERE acctid=%d AND slotid=%d",
|
account_id, slot_id);
|
||||||
account_id, slot_id), errbuf, &result)) {
|
auto results = QueryDatabase(query);
|
||||||
LogFile->write(EQEMuLog::Error, "Error runing inventory verification query '%s': %s", query, errbuf);
|
if (!results.Success()) {
|
||||||
safe_delete_array(query);
|
LogFile->write(EQEMuLog::Error, "Error runing inventory verification query '%s': %s", query.c_str(), results.ErrorMessage().c_str());
|
||||||
//returning true is less harmful in the face of a query error
|
//returning true is less harmful in the face of a query error
|
||||||
return(true);
|
return true;
|
||||||
}
|
}
|
||||||
safe_delete_array(query);
|
|
||||||
|
|
||||||
row = mysql_fetch_row(result);
|
if (results.RowCount() == 0)
|
||||||
bool found = false;
|
return false;
|
||||||
if(row) {
|
|
||||||
uint32 id = atoi(row[0]);
|
|
||||||
uint16 charges = atoi(row[1]);
|
|
||||||
|
|
||||||
uint16 expect_charges = 0;
|
auto row = results.begin();
|
||||||
if(inst->GetCharges() >= 0)
|
|
||||||
expect_charges = inst->GetCharges();
|
|
||||||
else
|
|
||||||
expect_charges = 0x7FFF;
|
|
||||||
|
|
||||||
if(id == inst->GetItem()->ID && charges == expect_charges)
|
uint32 id = atoi(row[0]);
|
||||||
found = true;
|
uint16 charges = atoi(row[1]);
|
||||||
}
|
|
||||||
mysql_free_result(result);
|
uint16 expect_charges = 0;
|
||||||
return(found);
|
|
||||||
|
if(inst->GetCharges() >= 0)
|
||||||
|
expect_charges = inst->GetCharges();
|
||||||
|
else
|
||||||
|
expect_charges = 0x7FFF;
|
||||||
|
|
||||||
|
if(id != inst->GetItem()->ID || charges != expect_charges)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SharedDatabase::SaveInventory(uint32 char_id, const ItemInst* inst, int16 slot_id) {
|
bool SharedDatabase::SaveInventory(uint32 char_id, const ItemInst* inst, int16 slot_id) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user