// Writing - High-level functions void PlayerDumpWriter::DumpTableContent(std::string& dump, uint32 guid, char const* tableFrom, char const* tableTo, DumpTableType type) { GUIDs const* guids = NULL; char const* fieldname = NULL; switch (type) { case DTT_ITEM: fieldname = "guid"; guids = &items; break; case DTT_ITEM_GIFT: fieldname = "item_guid"; guids = &items; break; case DTT_ITEM_LOOT: fieldname = "guid"; guids = &items; break; case DTT_PET: fieldname = "owner"; break; case DTT_PET_TABLE: fieldname = "guid"; guids = &pets; break; case DTT_PET_DECL: fieldname = "id"; break; case DTT_MAIL: fieldname = "receiver"; break; case DTT_MAIL_ITEM: fieldname = "mail_id"; guids = &mails; break; default: fieldname = "guid"; break; } // for guid set stop if set is empty if (guids && guids->empty()) { return; } // nothing to do // setup for guids case start position GUIDs::const_iterator guids_itr; if (guids) { guids_itr = guids->begin(); } do { std::string wherestr; if (guids) // set case, get next guids string { wherestr = GenerateWhereStr(fieldname, *guids, guids_itr); } else // not set case, get single guid string { wherestr = GenerateWhereStr(fieldname, guid); } QueryResult* result = CharacterDatabase.PQuery("SELECT * FROM %s WHERE %s", tableFrom, wherestr.c_str()); if (!result) { return; } do { // collect guids switch (type) { case DTT_INVENTORY: StoreGUID(result, 3, items); break; // item guid collection (character_inventory.item) case DTT_PET: StoreGUID(result, 0, pets); break; // pet petnumber collection (character_pet.id) case DTT_MAIL: StoreGUID(result, 0, mails); // mail id collection (mail.id) case DTT_MAIL_ITEM: StoreGUID(result, 1, items); break; // item guid collection (mail_items.item_guid) default: break; } dump += CreateDumpString(tableTo, result); dump += "\n"; } while (result->NextRow()); delete result; } while (guids && guids_itr != guids->end()); // not set case iterate single time, set case iterate for all guids }
// Writing - High-level functions bool PlayerDumpWriter::DumpTable(std::string& dump, uint32 guid, char const*tableFrom, char const*tableTo, DumpTableType type) { GUIDs const* guids = NULL; char const* fieldname = NULL; switch(type) { case DTT_ITEM: fieldname = "guid"; guids = &items; break; case DTT_ITEM_GIFT: fieldname = "item_guid"; guids = &items; break; case DTT_PET: fieldname = "owner"; break; case DTT_PET_TABLE: fieldname = "guid"; guids = &pets; break; case DTT_MAIL: fieldname = "receiver"; break; case DTT_MAIL_ITEM: fieldname = "mail_id"; guids = &mails; break; default: fieldname = "guid"; break; } // for guid set stop if set is empty if(guids && guids->empty()) return true; // nothing to do // setup for guids case start position GUIDs::const_iterator guids_itr; if(guids) guids_itr = guids->begin(); do { std::string wherestr; if(guids) // set case, get next guids string wherestr = GenerateWhereStr(fieldname, *guids, guids_itr); else // not set case, get single guid string wherestr = GenerateWhereStr(fieldname, guid); QueryResult result = CharacterDatabase.PQuery("SELECT * FROM %s WHERE %s", tableFrom, wherestr.c_str()); if(!result) return true; do { // collect guids switch(type) { case DTT_INVENTORY: StoreGUID(result, 3, items); break; // item guid collection (character_inventory.item) case DTT_PET: StoreGUID(result, 0, pets); break; // pet petnumber collection (character_pet.id) case DTT_MAIL: StoreGUID(result, 0, mails); // mail id collection (mail.id) case DTT_MAIL_ITEM: StoreGUID(result, 1, items); break; // item guid collection (mail_items.item_guid) case DTT_CHARACTER: { if(result->GetFieldCount() <= 67) // avoid crashes on next check return true; if(result->Fetch()[67].GetUInt32()) // characters.deleteInfos_Account - if filled error return false; break; } default: break; } dump += CreateDumpString(tableTo, result); dump += "\n"; } while(result->NextRow()); } while(guids && guids_itr != guids->end()); // not set case iterate single time, set case iterate for all guids return true; }