當前位置: 首頁>>代碼示例>>C++>>正文


C++ GetOwnerGUID函數代碼示例

本文整理匯總了C++中GetOwnerGUID函數的典型用法代碼示例。如果您正苦於以下問題:C++ GetOwnerGUID函數的具體用法?C++ GetOwnerGUID怎麽用?C++ GetOwnerGUID使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了GetOwnerGUID函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: GetOwner

Player* Item::GetOwner()const
{
    return objmgr.GetPlayer(GetOwnerGUID());
}
開發者ID:Golgotha29,項目名稱:mangos,代碼行數:4,代碼來源:Item.cpp

示例2: GetOwnerGUID

Unit* GameObject::GetOwner() const
{
    return ObjectAccessor::GetUnit(*this, GetOwnerGUID());
}
開發者ID:yunishaa,項目名稱:mangos-112,代碼行數:4,代碼來源:GameObject.cpp

示例3: switch


//.........這裏部分代碼省略.........

            // cast this spell later if provided
            spellId = info->goober.spellId;

            break;
        }
        case GAMEOBJECT_TYPE_CAMERA:                        //13
        {
            GameObjectInfo const* info = GetGOInfo();
            if(!info)
                return;

            if(user->GetTypeId()!=TYPEID_PLAYER)
                return;

            Player* player = (Player*)user;

            if(info->camera.cinematicId)
            {
                WorldPacket data(SMSG_TRIGGER_CINEMATIC, 4);
                data << info->camera.cinematicId;
                player->GetSession()->SendPacket(&data);
            }
            return;
        }
        //fishing bobber
        case GAMEOBJECT_TYPE_FISHINGNODE:                   //17
        {
            if(user->GetTypeId()!=TYPEID_PLAYER)
                return;

            Player* player = (Player*)user;

            if(player->GetGUID() != GetOwnerGUID())
                return;

            switch(getLootState())
            {
                case GO_READY:                              // ready for loot
                {
                    // 1) skill must be >= base_zone_skill
                    // 2) if skill == base_zone_skill => 5% chance
                    // 3) chance is linear dependence from (base_zone_skill-skill)

                    uint32 subzone = GetAreaId();

                    int32 zone_skill = objmgr.GetFishingBaseSkillLevel( subzone );
                    if(!zone_skill)
                        zone_skill = objmgr.GetFishingBaseSkillLevel( GetZoneId() );

                    //provide error, no fishable zone or area should be 0
                    if(!zone_skill)
                        sLog.outErrorDb("Fishable areaId %u are not properly defined in `skill_fishing_base_level`.",subzone);

                    int32 skill = player->GetSkillValue(SKILL_FISHING);
                    int32 chance = skill - zone_skill + 5;
                    int32 roll = irand(1,100);

                    DEBUG_LOG("Fishing check (skill: %i zone min skill: %i chance %i roll: %i",skill,zone_skill,chance,roll);

                    if(skill >= zone_skill && chance >= roll)
                    {
                        // prevent removing GO at spell cancel
                        player->RemoveGameObject(this,false);
                        SetOwnerGUID(player->GetGUID());
開發者ID:yunishaa,項目名稱:mangos-112,代碼行數:66,代碼來源:GameObject.cpp

示例4: GetGUIDLow

void Item::SaveToDB()
{
    uint32 guid = GetGUIDLow();
    switch (uState)
    {
        case ITEM_NEW:
        {
            std::string text = m_text;
            CharacterDatabase.escape_string(text);
            CharacterDatabase.PExecute( "DELETE FROM item_instance WHERE guid = '%u'", guid );
            std::ostringstream ss;
            ss << "INSERT INTO item_instance (guid,owner_guid,data,text) VALUES (" << guid << "," << GUID_LOPART(GetOwnerGUID()) << ",'";
            for(uint16 i = 0; i < m_valuesCount; ++i )
                ss << GetUInt32Value(i) << " ";
            ss << "', '" << text << "')";
            CharacterDatabase.Execute( ss.str().c_str() );
        } break;
        case ITEM_CHANGED:
        {
            std::string text = m_text;
            CharacterDatabase.escape_string(text);
            std::ostringstream ss;
            ss << "UPDATE item_instance SET data = '";
            for(uint16 i = 0; i < m_valuesCount; ++i )
                ss << GetUInt32Value(i) << " ";
            ss << "', owner_guid = '" << GUID_LOPART(GetOwnerGUID());
            ss << "', text = '" << text << "' WHERE guid = '" << guid << "'";

            CharacterDatabase.Execute( ss.str().c_str() );

            if (HasFlag(ITEM_FIELD_FLAGS, ITEM_DYNFLAG_WRAPPED))
                CharacterDatabase.PExecute("UPDATE character_gifts SET guid = '%u' WHERE item_guid = '%u'", GUID_LOPART(GetOwnerGUID()),GetGUIDLow());
        } break;
        case ITEM_REMOVED:
        {
            CharacterDatabase.PExecute("DELETE FROM item_instance WHERE guid = '%u'", guid);
            if (HasFlag(ITEM_FIELD_FLAGS, ITEM_DYNFLAG_WRAPPED))
                CharacterDatabase.PExecute("DELETE FROM character_gifts WHERE item_guid = '%u'", GetGUIDLow());

            if (HasSavedLoot())
                CharacterDatabase.PExecute("DELETE FROM item_loot WHERE guid = '%u'", GetGUIDLow());

            delete this;
            return;
        }
        case ITEM_UNCHANGED:
            return;
    }

    if (m_lootState == ITEM_LOOT_CHANGED || m_lootState == ITEM_LOOT_REMOVED)
        CharacterDatabase.PExecute("DELETE FROM item_loot WHERE guid = '%u'", GetGUIDLow());

    if (m_lootState == ITEM_LOOT_NEW || m_lootState == ITEM_LOOT_CHANGED)
    {
        if(Player* owner = GetOwner())
        {
            // save money as 0 itemid data
            if (loot.gold)
                CharacterDatabase.PExecute("INSERT INTO item_loot (guid,owner_guid,itemid,amount,suffix,property) "
                    "VALUES (%u, %u, 0, %u, 0, 0)",
                    GetGUIDLow(), owner->GetGUIDLow(), loot.gold);

            // save items and quest items (at load its all will added as normal, but this not important for item loot case)
            for (size_t i = 0; i < loot.GetMaxSlotInLootFor(owner); ++i)
            {
                QuestItem *qitem = NULL;

                LootItem *item = loot.LootItemInSlot(i,owner,&qitem);
                if(!item)
                    continue;

                // questitems use the blocked field for other purposes
                if (!qitem && item->is_blocked)
                    continue;

                CharacterDatabase.PExecute("INSERT INTO item_loot (guid,owner_guid,itemid,amount,suffix,property) "
                    "VALUES (%u, %u, %u, %u, %u, %i)",
                    GetGUIDLow(), owner->GetGUIDLow(), item->itemid, item->count, item->randomSuffix, item->randomPropertyId);
            }
        }

    }

    if (m_lootState != ITEM_LOOT_NONE && m_lootState != ITEM_LOOT_TEMPORARY)
        SetLootState(ITEM_LOOT_UNCHANGED);

    SetState(ITEM_UNCHANGED);
}
開發者ID:Choices,項目名稱:mangos,代碼行數:88,代碼來源:Item.cpp

示例5: MAKE_NEW_GUID

bool Item::LoadFromDB(uint32 guid, uint64 owner_guid, QueryResult *result)
{
    // create item before any checks for store correct guid
    // and allow use "FSetState(ITEM_REMOVED); SaveToDB();" for deleting item from DB
    Object::_Create(guid, 0, HIGHGUID_ITEM);

    bool delete_result = false;
    if(!result)
    {
        result = CharacterDatabase.PQuery("SELECT data FROM item_instance WHERE guid = '%u'", guid);
        delete_result = true;
    }

    if (!result)
    {
        sLog.outError("Item (GUID: %u owner: %u) not found in table `item_instance`, can't load. ",guid,GUID_LOPART(owner_guid));
        return false;
    }

    Field *fields = result->Fetch();

    if(!LoadValues(fields[0].GetString()))
    {
        sLog.outError("Item #%d have broken data in `data` field. Can't be loaded.",guid);
        if (delete_result) delete result;
        return false;
    }

    bool need_save = false;                                 // need explicit save data at load fixes

    // overwrite possible wrong/corrupted guid
    uint64 new_item_guid = MAKE_NEW_GUID(guid,0, HIGHGUID_ITEM);
    if(GetUInt64Value(OBJECT_FIELD_GUID) != new_item_guid)
    {
        SetUInt64Value(OBJECT_FIELD_GUID, MAKE_NEW_GUID(guid,0, HIGHGUID_ITEM));
        need_save = true;
    }

    if (delete_result) delete result;

    ItemPrototype const* proto = GetProto();
    if(!proto)
        return false;

    // update max durability (and durability) if need
    if(proto->MaxDurability!= GetUInt32Value(ITEM_FIELD_MAXDURABILITY))
    {
        SetUInt32Value(ITEM_FIELD_MAXDURABILITY,proto->MaxDurability);
        if(GetUInt32Value(ITEM_FIELD_DURABILITY) > proto->MaxDurability)
            SetUInt32Value(ITEM_FIELD_DURABILITY,proto->MaxDurability);

        need_save = true;
    }

    // recalculate suffix factor
    if(GetItemRandomPropertyId() < 0)
    {
        if(UpdateItemSuffixFactor())
            need_save = true;
    }

    // Remove bind flag for items vs NO_BIND set
    if (IsSoulBound() && proto->Bonding == NO_BIND)
    {
        ApplyModFlag(ITEM_FIELD_FLAGS,ITEM_FLAGS_BINDED, false);
        need_save = true;
    }

    // update duration if need, and remove if not need
    if ((proto->Duration == 0) != (GetUInt32Value(ITEM_FIELD_DURATION) == 0))
    {
        SetUInt32Value(ITEM_FIELD_DURATION, proto->Duration);
        need_save = true;
    }

    // set correct owner
    if (owner_guid != 0 && GetOwnerGUID() != owner_guid)
    {
        SetOwnerGUID(owner_guid);
        need_save = true;
    }

    if (need_save)                                          // normal item changed state set not work at loading
    {
        std::ostringstream ss;
        ss << "UPDATE item_instance SET data = '";
        for(uint16 i = 0; i < m_valuesCount; ++i )
            ss << GetUInt32Value(i) << " ";
        ss << "', owner_guid = '" << GUID_LOPART(GetOwnerGUID()) << "' WHERE guid = '" << guid << "'";

        CharacterDatabase.Execute( ss.str().c_str() );
    }

    return true;
}
開發者ID:Choices,項目名稱:ChoicesCore,代碼行數:95,代碼來源:Item.cpp

示例6: GetGUIDLow

void Corpse::DeleteFromDB()
{
    if(GetType() == CORPSE_BONES)
        // only specific bones
        CharacterDatabase.PExecute("DELETE FROM corpse WHERE guid = '%d'", GetGUIDLow());
    else
        // all corpses (not bones)
        CharacterDatabase.PExecute("DELETE FROM corpse WHERE player = '%d' AND corpse_type <> '0'",  GUID_LOPART(GetOwnerGUID()));
}
開發者ID:Lamron333,項目名稱:mangos,代碼行數:9,代碼來源:Corpse.cpp

示例7: GetGiftCreatorGUID

void Item::SaveToDB(int8 containerslot, int8 slot, bool firstsave, QueryBuffer* buf)
{
    if(GetOwner() && GetOwner()->IsSaveBlocked())
        return;
    if(!m_isDirty && !firstsave)
        return;

    uint64 GiftCreatorGUID = GetGiftCreatorGUID();
    uint64 CreatorGUID = GetCreatorGUID();

    std::stringstream ss;

    ss << "DELETE FROM playeritems WHERE guid = " << GetLowGUID() << ";";

    if(firstsave)
        CharacterDatabase.WaitExecute(ss.str().c_str());
    else
    {
        if(buf == NULL)
            CharacterDatabase.Execute(ss.str().c_str());
        else
            buf->AddQueryNA(ss.str().c_str());
    }


    ss.rdbuf()->str("");

    uint64 ownerGUID = GetOwnerGUID();

    ss << "INSERT INTO playeritems VALUES(";

    ss << (Arcemu::Util::GUID_LOPART(ownerGUID)) << ",";
    ss << GetLowGUID() << ",";
    ss << GetEntry() << ",";
    ss << wrapped_item_id << ",";
    ss << (Arcemu::Util::GUID_LOPART(GiftCreatorGUID)) << ",";
    ss << (Arcemu::Util::GUID_LOPART(CreatorGUID)) << ",";

    ss << GetStackCount() << ",";
    ss << int32(GetChargesLeft()) << ",";
    ss << uint32(m_uint32Values[ ITEM_FIELD_FLAGS ]) << ",";
    ss << random_prop << ", " << random_suffix << ", ";
    ss << 0 << ",";
    ss << GetDurability() << ",";
    ss << static_cast<int>(containerslot) << ",";
    ss << static_cast<int>(slot) << ",'";

    // Pack together enchantment fields
    if(Enchantments.size() > 0)
    {
        EnchantmentMap::iterator itr = Enchantments.begin();
        for(; itr != Enchantments.end(); ++itr)
        {
            if(itr->second.RemoveAtLogout)
                continue;

            uint32 elapsed_duration = uint32(UNIXTIME - itr->second.ApplyTime);
            int32 remaining_duration = itr->second.Duration - elapsed_duration;
            if(remaining_duration < 0)
                remaining_duration = 0;

            try
            {
                if(itr->second.Enchantment && (remaining_duration > 5 || itr->second.Duration == 0))
                {
                    ss << itr->second.Enchantment->Id << ",";
                    ss << remaining_duration << ",";
                    ss << itr->second.Slot << ";";
                }
            }
            catch (...)
            {
                printf("Caught fatal exception: Item.cpp < void Item::SaveToDB(...)\n");
            }
        }
    }
    ss << "','";
    ss << ItemExpiresOn << "','";

////////////////////////////////////////////////// Refund stuff /////////////////////////////////

    // Check if the owner is instantiated. When sending mail he/she obviously will not be :P
    if(this->GetOwner() != NULL)
    {
        std::pair< time_t, uint32 > refundentry;

        refundentry.first = 0;
        refundentry.second = 0;

        refundentry = this->GetOwner()->GetItemInterface()->LookupRefundable(this->GetGUID());

        ss << uint32(refundentry.first) << "','";
        ss << uint32(refundentry.second);

    }
    else
    {
        ss << uint32(0) << "','";
        ss << uint32(0);
    }
//.........這裏部分代碼省略.........
開發者ID:treetrees,項目名稱:Edge-of-Chaos,代碼行數:101,代碼來源:Item.cpp

示例8: GUID_LOPART

void Bag::SaveToDB()
{
    Item::SaveToDB();

    if(GetSlot()!=NULL_SLOT)                                // equiped bag
    {
        sDatabase.PExecute("DELETE FROM `character_inventory` WHERE `guid` = '%u' AND `bag` = '%u'", GUID_LOPART(GetOwnerGUID()), GetSlot());
        for (uint8 i = 0; i < GetProto()->ContainerSlots; i++)
        {
            if (m_bagslot[i])
            {
                sDatabase.PExecute("INSERT INTO `character_inventory`  (`guid`,`bag`,`slot`,`item`,`item_template`) VALUES ('%u', '%u', '%u', '%u', '%u')", GUID_LOPART(GetOwnerGUID()), GetSlot(), i, m_bagslot[i]->GetGUIDLow(), m_bagslot[i]->GetEntry());
                m_bagslot[i]->SaveToDB();
            }
        }
    }
}
開發者ID:Artea,項目名稱:mangos-svn,代碼行數:17,代碼來源:Bag.cpp

示例9: SetUInt64Value

bool Bag::LoadFromDB(uint32 guid, uint64 owner_guid, uint32 auctioncheck)
{
    if(!Item::LoadFromDB(guid, owner_guid, auctioncheck))
        return false;

    // cleanup bag content related item value fields (its will be filled correctly from `character_inventory`)
    for (uint32 i = 0; i < GetProto()->ContainerSlots; i++)
    {
        SetUInt64Value(CONTAINER_FIELD_SLOT_1 + (i*2), 0);
        if (m_bagslot[i])
        {
            delete m_bagslot[i];
            m_bagslot[i] = NULL;
        }
    }

    if(GetSlot()!=NULL_SLOT)                                // equiped bag
    {
        QueryResult *result = sDatabase.PQuery("SELECT `slot`,`item`,`item_template` FROM `character_inventory` WHERE `guid` = '%u' AND `bag` = '%u'", GUID_LOPART(GetOwnerGUID()), GetSlot());

        if (result)
        {
            do
            {
                Field *fields = result->Fetch();
                uint8  slot      = fields[0].GetUInt8();
                uint32 item_guid = fields[1].GetUInt32();
                uint32 item_id   = fields[2].GetUInt32();

                ItemPrototype const *proto = objmgr.GetItemPrototype(item_id);

                if(!proto)
                {
                    sLog.outError( "Bag::LoadFromDB: Player %d have unknown item (id: #%u) in bag #%u, skipped.", GUID_LOPART(GetOwnerGUID()), item_id, GetSlot());
                    continue;
                }

                Item *item = NewItemOrBag(proto);
                item->SetSlot(NULL_SLOT);
                if(!item->LoadFromDB(item_guid, owner_guid, 1))
                    continue;
                StoreItem( slot, item, true );
            } while (result->NextRow());

            delete result;
        }
    }
    return true;
}
開發者ID:Artea,項目名稱:mangos-svn,代碼行數:49,代碼來源:Bag.cpp

示例10: GetGUIDLow

void Item::SaveToDB()
{
    uint32 guid = GetGUIDLow();
    switch (uState)
    {
        case ITEM_NEW:
        {
            static SqlStatementID deleteItem;
            static SqlStatementID saveItem;

            SqlStatement stmt = RealmDataDatabase.CreateStatement(deleteItem, "DELETE FROM item_instance WHERE guid = ?");
            stmt.PExecute(guid);

            stmt = RealmDataDatabase.CreateStatement(saveItem, "INSERT INTO item_instance (guid, owner_guid, data) VALUES (?, ?, ?)");

            std::ostringstream ss;
            for (uint16 i = 0; i < m_valuesCount; i++)
                ss << GetUInt32Value(i) << " ";

            stmt.PExecute(guid, GUID_LOPART(GetOwnerGUID()), ss.str().c_str());
        }
        break;
        case ITEM_CHANGED:
        {
            static SqlStatementID updateItem;
            static SqlStatementID updateGift;

            SqlStatement stmt = RealmDataDatabase.CreateStatement(updateItem, "UPDATE item_instance SET data = ?,  owner_guid = ? WHERE guid = ?");

            std::ostringstream ss;
            for (uint16 i = 0; i < m_valuesCount; i++)
                ss << GetUInt32Value(i) << " ";

            stmt.PExecute(ss.str().c_str(), GUID_LOPART(GetOwnerGUID()), guid);

            if (HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_WRAPPED))
            {
                stmt = RealmDataDatabase.CreateStatement(updateGift, "UPDATE character_gifts SET guid = ? WHERE item_guid = ?");
                stmt.PExecute(GUID_LOPART(GetOwnerGUID()), GetGUIDLow());
            }
        }
        break;
        case ITEM_REMOVED:
        {
            static SqlStatementID deleteItem;
            static SqlStatementID deleteItemText;
            static SqlStatementID deleteGift;

            SqlStatement stmt = RealmDataDatabase.CreateStatement(deleteItem, "DELETE FROM item_instance WHERE guid = ?");
            stmt.PExecute(guid);

            if (GetUInt32Value(ITEM_FIELD_ITEM_TEXT_ID) > 0)
            {
                stmt = RealmDataDatabase.CreateStatement(deleteItemText, "DELETE FROM item_text WHERE id = ?");
                stmt.PExecute(GetUInt32Value(ITEM_FIELD_ITEM_TEXT_ID));
            }

            if (HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_WRAPPED))
            {
                stmt = RealmDataDatabase.CreateStatement(deleteGift, "DELETE FROM character_gifts WHERE item_guid = ?");
                stmt.PExecute(GetGUIDLow());
            }

            delete this;
            return;
        }
        case ITEM_UNCHANGED:
            break;
    }
    SetState(ITEM_UNCHANGED);
}
開發者ID:Dolmero,項目名稱:L4G_Core,代碼行數:71,代碼來源:Item.cpp

示例11: SetLootState

void Item::LoadLootFromDB(Field *fields)
{
    uint32 item_id     = fields[1].GetUInt32();
    uint32 item_amount = fields[2].GetUInt32();
    uint32 item_suffix = fields[3].GetUInt32();
    int32  item_propid = fields[4].GetInt32();

    // money value special case
    if (item_id == 0)
    {
        loot.gold = item_amount;
        SetLootState(ITEM_LOOT_UNCHANGED);
        return;
    }

    // normal item case
    ItemPrototype const* proto = ObjectMgr::GetItemPrototype(item_id);

    if(!proto)
    {
        CharacterDatabase.PExecute("DELETE FROM item_loot WHERE guid = '%u' AND itemid = '%u'", GetGUIDLow(), item_id);
        sLog.outError("Item::LoadLootFromDB: %s has an unknown item (id: #%u) in item_loot, deleted.", ObjectGuid(GetOwnerGUID()).GetString().c_str(), item_id);
        return;
    }

    loot.items.push_back(LootItem(item_id, item_amount, item_suffix, item_propid));
    ++loot.unlootedCount;

    SetLootState(ITEM_LOOT_UNCHANGED);
}
開發者ID:Choices,項目名稱:mangos,代碼行數:30,代碼來源:Item.cpp

示例12: ObjectGuid

bool Item::LoadFromDB(uint32 guidLow, uint64 owner_guid, Field *fields)
{
    // create item before any checks for store correct guid
    // and allow use "FSetState(ITEM_REMOVED); SaveToDB();" for deleting item from DB
    Object::_Create(guidLow, 0, HIGHGUID_ITEM);

    if (!LoadValues(fields[0].GetString()))
    {
        sLog.outError("Item #%d have broken data in `data` field. Can't be loaded.", guidLow);
        return false;
    }

    bool need_save = false;                                 // need explicit save data at load fixes

    // overwrite possible wrong/corrupted guid
    ObjectGuid new_item_guid = ObjectGuid(HIGHGUID_ITEM, guidLow);
    if (GetGuidValue(OBJECT_FIELD_GUID) != new_item_guid)
    {
        SetGuidValue(OBJECT_FIELD_GUID, new_item_guid);
        need_save = true;
    }

    ItemPrototype const* proto = GetProto();
    if(!proto)
        return false;

    // update max durability (and durability) if need
    if(proto->MaxDurability!= GetUInt32Value(ITEM_FIELD_MAXDURABILITY))
    {
        SetUInt32Value(ITEM_FIELD_MAXDURABILITY,proto->MaxDurability);
        if(GetUInt32Value(ITEM_FIELD_DURABILITY) > proto->MaxDurability)
            SetUInt32Value(ITEM_FIELD_DURABILITY,proto->MaxDurability);

        need_save = true;
    }

    // recalculate suffix factor
    if(GetItemRandomPropertyId() < 0)
    {
        if(UpdateItemSuffixFactor())
            need_save = true;
    }

    // Remove bind flag for items vs NO_BIND set
    if (IsSoulBound() && proto->Bonding == NO_BIND)
    {
        ApplyModFlag(ITEM_FIELD_FLAGS, ITEM_DYNFLAG_BINDED, false);
        need_save = true;
    }

    // update duration if need, and remove if not need
    if ((proto->Duration == 0) != (GetUInt32Value(ITEM_FIELD_DURATION) == 0))
    {
        SetUInt32Value(ITEM_FIELD_DURATION, proto->Duration);
        need_save = true;
    }

    // set correct owner
    if (owner_guid != 0 && GetOwnerGUID() != owner_guid)
    {
        SetOwnerGUID(owner_guid);
        need_save = true;
    }

    // set correct wrapped state
    if (HasFlag(ITEM_FIELD_FLAGS, ITEM_DYNFLAG_WRAPPED))
    {
        // wrapped item must be wrapper (used version that not stackable)
        if (!(proto->Flags & ITEM_FLAG_WRAPPER) || GetMaxStackCount() > 1)
        {
            RemoveFlag(ITEM_FIELD_FLAGS, ITEM_DYNFLAG_WRAPPED);
            need_save = true;

            // also cleanup for sure gift table
            CharacterDatabase.PExecute("DELETE FROM character_gifts WHERE item_guid = '%u'", GetGUIDLow());
        }
    }

    if (need_save)                                          // normal item changed state set not work at loading
    {
        std::ostringstream ss;
        ss << "UPDATE item_instance SET data = '";
        for(uint16 i = 0; i < m_valuesCount; ++i )
            ss << GetUInt32Value(i) << " ";
        ss << "', owner_guid = '" << GUID_LOPART(GetOwnerGUID()) << "' WHERE guid = '" << guidLow << "'";

        CharacterDatabase.Execute( ss.str().c_str() );
    }

    return true;
}
開發者ID:Choices,項目名稱:mangos,代碼行數:91,代碼來源:Item.cpp

示例13: GetOwner

Player* Item::GetOwner()const
{
    return ObjectAccessor::FindPlayer(GetOwnerGUID());
}
開發者ID:Devilcleave,項目名稱:TrilliumEMU,代碼行數:4,代碼來源:Item.cpp

示例14: time_t

bool Corpse::LoadFromDB(uint32 lowguid, Field *fields)
{
    ////                                                    0            1       2                  3                  4                  5                   6
    //QueryResult *result = CharacterDatabase.Query("SELECT corpse.guid, player, corpse.position_x, corpse.position_y, corpse.position_z, corpse.orientation, corpse.map,"
    ////   7     8            9         10         11      12    13     14           15            16              17       18
    //    "time, corpse_type, instance, phaseMask, gender, race, class, playerBytes, playerBytes2, equipmentCache, guildId, playerFlags FROM corpse"
    uint32 playerLowGuid= fields[1].GetUInt32();
    float positionX     = fields[2].GetFloat();
    float positionY     = fields[3].GetFloat();
    float positionZ     = fields[4].GetFloat();
    float orientation   = fields[5].GetFloat();
    uint32 mapid        = fields[6].GetUInt32();

    Object::_Create(lowguid, 0, HIGHGUID_CORPSE);

    m_time = time_t(fields[7].GetUInt64());
    m_type = CorpseType(fields[8].GetUInt32());

    if(m_type >= MAX_CORPSE_TYPE)
    {
        sLog.outError("Corpse (guidlow %d, owner %d) have wrong corpse type, not load.",GetGUIDLow(),GUID_LOPART(GetOwnerGUID()));
        return false;
    }

    uint32 instanceid   = fields[9].GetUInt32();
    uint32 phaseMask    = fields[10].GetUInt32();
    uint8 gender        = fields[11].GetUInt8();
    uint8 race          = fields[12].GetUInt8();
    uint8 _class        = fields[13].GetUInt8();
    uint32 playerBytes  = fields[14].GetUInt32();
    uint32 playerBytes2 = fields[15].GetUInt32();
    uint32 guildId      = fields[17].GetUInt32();
    uint32 playerFlags  = fields[18].GetUInt32();

    ObjectGuid guid = ObjectGuid(HIGHGUID_CORPSE, lowguid);
    ObjectGuid playerGuid = ObjectGuid(HIGHGUID_PLAYER, playerLowGuid);

    // overwrite possible wrong/corrupted guid
    SetGuidValue(OBJECT_FIELD_GUID, guid);
    SetGuidValue(CORPSE_FIELD_OWNER, playerGuid);

    SetObjectScale(DEFAULT_OBJECT_SCALE);

    PlayerInfo const *info = sObjectMgr.GetPlayerInfo(race, _class);
    if(!info)
    {
        sLog.outError("Player %u has incorrect race/class pair.", GetGUIDLow());
        return false;
    }
    SetUInt32Value(CORPSE_FIELD_DISPLAY_ID, gender == GENDER_FEMALE ? info->displayId_f : info->displayId_m);

    // Load equipment
    Tokens data = StrSplit(fields[16].GetCppString(), " ");
    for (uint8 slot = 0; slot < EQUIPMENT_SLOT_END; slot++)
    {
        uint32 visualbase = slot * 2;
        uint32 item_id = GetUInt32ValueFromArray(data, visualbase);
        const ItemPrototype * proto = ObjectMgr::GetItemPrototype(item_id);
        if(!proto)
        {
            SetUInt32Value(CORPSE_FIELD_ITEM + slot, 0);
            continue;
        }

        SetUInt32Value(CORPSE_FIELD_ITEM + slot, proto->DisplayInfoID | (proto->InventoryType << 24));
    }

    uint8 skin       = (uint8)(playerBytes);
    uint8 face       = (uint8)(playerBytes >> 8);
    uint8 hairstyle  = (uint8)(playerBytes >> 16);
    uint8 haircolor  = (uint8)(playerBytes >> 24);
    uint8 facialhair = (uint8)(playerBytes2);
    SetUInt32Value( CORPSE_FIELD_BYTES_1, ((0x00) | (race << 8) | (gender << 16) | (skin << 24)) );
    SetUInt32Value( CORPSE_FIELD_BYTES_2, ((face) | (hairstyle << 8) | (haircolor << 16) | (facialhair << 24)) );

    SetUInt32Value(CORPSE_FIELD_GUILD, guildId);

    uint32 flags = CORPSE_FLAG_UNK2;
    if(playerFlags & PLAYER_FLAGS_HIDE_HELM)
        flags |= CORPSE_FLAG_HIDE_HELM;
    if(playerFlags & PLAYER_FLAGS_HIDE_CLOAK)
        flags |= CORPSE_FLAG_HIDE_CLOAK;
    SetUInt32Value( CORPSE_FIELD_FLAGS, flags );

    // no need to mark corpse as lootable, because corpses are not saved in battle grounds

    // place
    SetLocationInstanceId(instanceid);
    SetLocationMapId(mapid);
    SetPhaseMask(phaseMask, false);
    Relocate(positionX, positionY, positionZ, orientation);

    if(!IsPositionValid())
    {
        sLog.outError("Corpse (guidlow %d, owner %d) not created. Suggested coordinates isn't valid (X: %f Y: %f)",
                      GetGUIDLow(), GUID_LOPART(GetOwnerGUID()), GetPositionX(), GetPositionY());
        return false;
    }

    m_grid = MaNGOS::ComputeGridPair(GetPositionX(), GetPositionY());
//.........這裏部分代碼省略.........
開發者ID:klaas-netherstorm,項目名稱:Mangos,代碼行數:101,代碼來源:Corpse.cpp

示例15: DeleteFromDB

void Corpse::DeleteFromDB(SQLTransaction& trans)
{
    DeleteFromDB(GetOwnerGUID(), trans);
}
開發者ID:Keader,項目名稱:TrinityCore,代碼行數:4,代碼來源:Corpse.cpp


注:本文中的GetOwnerGUID函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。