mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-14 07:21:48 +00:00
SaveCursor
This commit is contained in:
parent
bcf282da91
commit
95208eb24e
@ -99,27 +99,26 @@ uint32 SharedDatabase::GetTotalTimeEntitledOnAccount(uint32 AccountID) {
|
|||||||
|
|
||||||
bool SharedDatabase::SaveCursor(uint32 char_id, std::list<ItemInst*>::const_iterator &start, std::list<ItemInst*>::const_iterator &end)
|
bool SharedDatabase::SaveCursor(uint32 char_id, std::list<ItemInst*>::const_iterator &start, std::list<ItemInst*>::const_iterator &end)
|
||||||
{
|
{
|
||||||
iter_queue it;
|
|
||||||
int i;
|
|
||||||
bool ret = true;
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
|
||||||
char* query = 0;
|
|
||||||
// Delete cursor items
|
// Delete cursor items
|
||||||
if ((ret = RunQuery(query, MakeAnyLenString(&query, "DELETE FROM inventory WHERE charid = %i AND ((slotid >= 8000 AND slotid <= 8999) OR slotid = %i OR (slotid >= %i AND slotid <= %i))",
|
std::string query = StringFormat("DELETE FROM inventory WHERE charid = %i "
|
||||||
char_id, MainCursor, EmuConstants::CURSOR_BAG_BEGIN, EmuConstants::CURSOR_BAG_END), errbuf))) {
|
"AND ((slotid >= 8000 AND slotid <= 8999) "
|
||||||
|
"OR slotid = %i OR (slotid >= %i AND slotid <= %i) )",
|
||||||
|
char_id, MainCursor,
|
||||||
|
EmuConstants::CURSOR_BAG_BEGIN, EmuConstants::CURSOR_BAG_END);
|
||||||
|
auto results = QueryDatabase(query);
|
||||||
|
if (!results.Success()) {
|
||||||
|
std::cout << "Clearing cursor failed: " << results.ErrorMessage() << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
for (it = start, i = 8000; it != end; ++it, i++) {
|
int i = 8000;
|
||||||
ItemInst *inst = *it;
|
for(auto it = start; it != end; ++it, i++) {
|
||||||
if (!(ret = SaveInventory(char_id, inst, (i == 8000) ? MainCursor : i)))
|
ItemInst *inst = *it;
|
||||||
break;
|
if (!SaveInventory(char_id,inst,(i == 8000) ? MainCursor : i))
|
||||||
}
|
return false;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
std::cout << "Clearing cursor failed: " << errbuf << std::endl;
|
|
||||||
}
|
|
||||||
safe_delete_array(query);
|
|
||||||
|
|
||||||
return ret;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SharedDatabase::VerifyInventory(uint32 account_id, int16 slot_id, const ItemInst* inst)
|
bool SharedDatabase::VerifyInventory(uint32 account_id, int16 slot_id, const ItemInst* inst)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user