Exemplo n.º 1
0
// 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;
        case DTT_ITEM_TEXT: fieldname = "id";        guids = &texts; 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
                case DTT_ITEM:
                    StoreGUID(result, 0, ITEM_FIELD_ITEM_TEXT_ID, texts); break;
                    // item text id collection
                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)
                    StoreGUID(result, 7, texts); break;     // item text id collection
                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
}
Exemplo n.º 2
0
// 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_AutoPtr 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;
}
Exemplo n.º 3
0
// Writing - High-level functions
bool PlayerDumpWriter::DumpTable(std::string& dump, ObjectGuid::LowType guid, char const* tableFrom, char const* tableTo, DumpTableType type)
{
    DumpGuidSet const* guids = nullptr;
    char const* fieldname = nullptr;

    switch (type)
    {
        case DTT_CURRENCY:  fieldname = "CharacterGuid";             break;
        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
    DumpGuidSet::const_iterator guidsItr;
    if (guids)
        guidsItr = guids->begin();

    do
    {
        std::string wherestr;

        if (guids)                                              // set case, get next guids string
            wherestr = GenerateWhereStr(fieldname, *guids, guidsItr);
        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);                // item guid collection (character_inventory.item)
                    break;
                case DTT_PET:
                    StoreGUID(result, 0, pets);                 // pet petnumber collection (character_pet.id)
                    break;
                case DTT_MAIL:
                    StoreGUID(result, 0, mails);                // mail id collection (mail.id)
                    break;
                case DTT_MAIL_ITEM:
                    StoreGUID(result, 1, items);                // item guid collection (mail_items.item_guid)
                    break;
                case DTT_CHARACTER:
                {
                    if (result->GetFieldCount() <= 64)          // avoid crashes on next check
                    {
                        TC_LOG_FATAL("misc", "PlayerDumpWriter::DumpTable - Trying to access non-existing or wrong positioned field (`deleteInfos_Account`) in `characters` table.");
                        return false;
                    }

                    if (result->Fetch()[64].GetUInt32())        // characters.deleteInfos_Account - if filled error
                        return false;
                    break;
                }
                default:
                    break;
            }

            dump += CreateDumpString(tableTo, result);
            dump += "\n";
        }
        while (result->NextRow());
    }
    while (guids && guidsItr != guids->end());                  // not set case iterate single time, set case iterate for all guids
    return true;
}