本网站可以出售:只需60000元直接拥有。QQ:939804642
您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ MAKE_NEW_GUID函数代码示例

51自学网 2021-06-01 22:01:47
  C++
这篇教程C++ MAKE_NEW_GUID函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中MAKE_NEW_GUID函数的典型用法代码示例。如果您正苦于以下问题:C++ MAKE_NEW_GUID函数的具体用法?C++ MAKE_NEW_GUID怎么用?C++ MAKE_NEW_GUID使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了MAKE_NEW_GUID函数的22个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: CHECK_PACKET_SIZE

void WorldSession::HandleLootMasterGiveOpcode( WorldPacket & recv_data ){    CHECK_PACKET_SIZE(recv_data,8+1+8);    uint8 slotid;    uint64 lootguid, target_playerguid;    recv_data >> lootguid >> slotid >> target_playerguid;    if(!_player->GetGroup() || _player->GetGroup()->GetLooterGuid() != _player->GetGUID())    {        _player->SendLootRelease(GetPlayer()->GetLootGUID());        return;    }    Player *target = ObjectAccessor::FindPlayer(MAKE_NEW_GUID(target_playerguid, 0, HIGHGUID_PLAYER));    if(!target)        return;    sLog.outDebug("WorldSession::HandleLootMasterGiveOpcode (CMSG_LOOT_MASTER_GIVE, 0x02A3) Target = [%s].", target->GetName());    if(_player->GetLootGUID() != lootguid)        return;    Loot *pLoot = NULL;    if(IS_CREATURE_GUID(GetPlayer()->GetLootGUID()))    {        Creature *pCreature = ObjectAccessor::GetCreature(*GetPlayer(), lootguid);        if(!pCreature)            return;        pLoot = &pCreature->loot;    }    else if(IS_GAMEOBJECT_GUID(GetPlayer()->GetLootGUID()))    {        GameObject *pGO = ObjectAccessor::GetGameObject(*GetPlayer(), lootguid);        if(!pGO)            return;        pLoot = &pGO->loot;    }    if(!pLoot)        return;    if (slotid > pLoot->items.size())    {        sLog.outDebug("AutoLootItem: Player %s might be using a hack! (slot %d, size %d)",GetPlayer()->GetName(), slotid, pLoot->items.size());        return;    }    LootItem& item = pLoot->items[slotid];    ItemPosCountVec dest;    uint8 msg = target->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, item.itemid, item.count );    if ( msg != EQUIP_ERR_OK )    {        target->SendEquipError( msg, NULL, NULL );        _player->SendEquipError( msg, NULL, NULL );         // send duplicate of error massage to master looter        return;    }    // not move item from loot to target inventory    Item * newitem = target->StoreNewItem( dest, item.itemid, true, item.randomPropertyId );    target->SendNewItem(newitem, uint32(item.count), false, false, true );    // mark as looted    item.count=0;    item.is_looted=true;    pLoot->NotifyItemRemoved(slotid);    --pLoot->unlootedCount;}
开发者ID:Artea,项目名称:mangos-svn,代码行数:75,


示例2: TC_LOG_DEBUG

void WorldSession::HandleOfferPetitionOpcode(WorldPacket& recvData){    TC_LOG_DEBUG("network", "Received opcode CMSG_OFFER_PETITION");   // ok    uint8 playerCount = 0;    ObjectGuid petitionGuid, playerGuid;    uint32 type;    Player* player;    recvData.read_skip<uint32>();    recvData.ReadGuidMask(playerGuid, 4, 1);    petitionGuid[2] = recvData.ReadBit();    playerGuid[6] = recvData.ReadBit();    petitionGuid[1] = recvData.ReadBit();    playerGuid[2] = recvData.ReadBit();    petitionGuid[4] = recvData.ReadBit();    recvData.ReadGuidMask(playerGuid, 3, 7);    recvData.ReadGuidMask(petitionGuid, 0, 6);    recvData.ReadGuidMask(playerGuid, 5, 0);    recvData.ReadGuidMask(petitionGuid, 3, 5, 7);    recvData.ReadByteSeq(playerGuid[7]);    recvData.ReadGuidBytes(petitionGuid, 1, 4, 2);    recvData.ReadByteSeq(playerGuid[6]);    recvData.ReadGuidBytes(petitionGuid, 3, 0, 5);    recvData.ReadGuidBytes(playerGuid, 0, 2, 5, 3, 4);    recvData.ReadByteSeq(petitionGuid[7]);    recvData.ReadByteSeq(playerGuid[1]);    recvData.ReadByteSeq(petitionGuid[6]);    player = ObjectAccessor::FindPlayer(playerGuid);    if (!player)        return;    PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PETITION_TYPE);    stmt->setUInt32(0, GUID_LOPART(petitionGuid));    PreparedQueryResult result = CharacterDatabase.Query(stmt);    if (!result)        return;    Field* fields = result->Fetch();    type = fields[0].GetUInt8();    TC_LOG_DEBUG("network", "OFFER PETITION: type %u, GUID1 %u, to player id: %u", type, GUID_LOPART(petitionGuid), GUID_LOPART(playerGuid));    if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD) && GetPlayer()->GetTeam() != player->GetTeam())    {        Guild::SendCommandResult(this, GUILD_COMMAND_CREATE, ERR_GUILD_NOT_ALLIED);        return;    }    if (player->GetGuildId())    {        Guild::SendCommandResult(this, GUILD_COMMAND_INVITE, ERR_ALREADY_IN_GUILD_S, _player->GetName());        return;    }    if (player->GetGuildIdInvited())    {        Guild::SendCommandResult(this, GUILD_COMMAND_INVITE, ERR_ALREADY_INVITED_TO_GUILD_S, _player->GetName());        return;    }    stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PETITION_SIGNATURE);    stmt->setUInt32(0, GUID_LOPART(petitionGuid));    result = CharacterDatabase.Query(stmt);    // result == NULL also correct charter without signs    if (result)        playerCount = uint8(result->GetRowCount());    ObjectGuid* playerGuids = new ObjectGuid[playerCount];    for (uint8 i = 0; i < playerCount; ++i)    {        Field* fields2 = result->Fetch();        uint32 lowGuid = fields2[0].GetUInt32();        playerGuids[i] = MAKE_NEW_GUID(lowGuid, 0, HIGHGUID_PLAYER);        result->NextRow();    }    WorldPacket data(SMSG_PETITION_SHOW_SIGNATURES, (9 + 9 + 3 + 4 + playerCount * (9 + 4)));    data.WriteBit(playerGuid[1]);    data.WriteBit(petitionGuid[3]);    data.WriteBit(playerGuid[3]);    data.WriteGuidMask(petitionGuid, 4, 0);    data.WriteGuidMask(playerGuid, 7, 5);    data.WriteGuidMask(petitionGuid, 1, 5, 7);    data.WriteGuidMask(playerGuid, 0, 6);    data.WriteBit(petitionGuid[6]);    data.WriteGuidMask(playerGuid, 2, 4);    data.WriteBits(playerCount, 21);    for (int i = 0; i < playerCount; i++)//.........这里部分代码省略.........
开发者ID:Caydan,项目名称:mop548,代码行数:101,


示例3: SetEntry

bool Item::LoadFromDB(uint32 guid, uint64 owner_guid, Field* fields, uint32 entry){    //                                                    0                1      2         3        4      5             6                 7           8           9    10    //result = CharacterDatabase.PQuery("SELECT creatorGuid, giftCreatorGuid, count, duration, charges, flags, enchantments, randomPropertyId, durability, playedTime, text FROM item_instance WHERE guid = '%u'", guid);    // 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);    // Set entry, MUST be before proto check    SetEntry(entry);    SetFloatValue(OBJECT_FIELD_SCALE_X, 1.0f);    ItemTemplate const* proto = GetTemplate();    if (!proto)        return false;    // set owner (not if item is only loaded for gbank/auction/mail    if (owner_guid != 0)        SetOwnerGUID(owner_guid);    bool need_save = false;                                 // need explicit save data at load fixes    SetUInt64Value(ITEM_FIELD_CREATOR, MAKE_NEW_GUID(fields[0].GetUInt32(), 0, HIGHGUID_PLAYER));    SetUInt64Value(ITEM_FIELD_GIFTCREATOR, MAKE_NEW_GUID(fields[1].GetUInt32(), 0, HIGHGUID_PLAYER));    SetCount(fields[2].GetUInt32());    uint32 duration = fields[3].GetUInt32();    SetUInt32Value(ITEM_FIELD_DURATION, duration);    // update duration if need, and remove if not need    if ((proto->Duration == 0) != (duration == 0))    {        SetUInt32Value(ITEM_FIELD_DURATION, abs(proto->Duration));        need_save = true;    }    Tokens tokens(fields[4].GetString(), ' ', MAX_ITEM_PROTO_SPELLS);    if (tokens.size() == MAX_ITEM_PROTO_SPELLS)        for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)            SetSpellCharges(i, atoi(tokens[i]));    SetUInt32Value(ITEM_FIELD_FLAGS, fields[5].GetUInt32());    // Remove bind flag for items vs NO_BIND set    if (IsSoulBound() && proto->Bonding == NO_BIND)    {        ApplyModFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_SOULBOUND, false);        need_save = true;    }    std::string enchants = fields[6].GetString();    _LoadIntoDataField(enchants.c_str(), ITEM_FIELD_ENCHANTMENT_1_1, MAX_ENCHANTMENT_SLOT * MAX_ENCHANTMENT_OFFSET);    SetInt32Value(ITEM_FIELD_RANDOM_PROPERTIES_ID, fields[7].GetInt16());    // recalculate suffix factor    if (GetItemRandomPropertyId() < 0)        UpdateItemSuffixFactor();    uint32 durability = fields[8].GetUInt16();    SetUInt32Value(ITEM_FIELD_DURABILITY, durability);    // update max durability (and durability) if need    SetUInt32Value(ITEM_FIELD_MAXDURABILITY, proto->MaxDurability);    if (durability > proto->MaxDurability)    {        SetUInt32Value(ITEM_FIELD_DURABILITY, proto->MaxDurability);        need_save = true;    }    SetUInt32Value(ITEM_FIELD_CREATE_PLAYED_TIME, fields[9].GetUInt32());    SetText(fields[10].GetString());    if (need_save)                                           // normal item changed state set not work at loading    {        PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPDATE_ITEM_INSTANCE_ON_LOAD);        stmt->setUInt32(0, GetUInt32Value(ITEM_FIELD_DURATION));        stmt->setUInt32(1, GetUInt32Value(ITEM_FIELD_FLAGS));        stmt->setUInt32(2, GetUInt32Value(ITEM_FIELD_DURABILITY));        stmt->setUInt32(3, guid);        CharacterDatabase.Execute(stmt);    }    return true;}
开发者ID:hodobaj,项目名称:Darkcore,代码行数:80,


示例4: HandleLootMasterGiveOpcode

void WorldSession::HandleLootMasterGiveOpcode(WorldPacket& recvData){    uint8 slotid;    uint64 lootguid, target_playerguid;    recvData >> lootguid >> slotid >> target_playerguid;    if (!_player->GetGroup() || _player->GetGroup()->GetMasterLooterGuid() != _player->GetGUID() || _player->GetGroup()->GetLootMethod() != MASTER_LOOT)    {        _player->SendLootRelease(GetPlayer()->GetLootGUID());        return;    }    Player* target = ObjectAccessor::FindPlayer(MAKE_NEW_GUID(target_playerguid, 0, HIGHGUID_PLAYER));    if (!target)        return;    TC_LOG_DEBUG("network", "WorldSession::HandleLootMasterGiveOpcode (CMSG_LOOT_MASTER_GIVE, 0x02A3) Target = [%s].", target->GetName().c_str());    if (_player->GetLootGUID() != lootguid)        return;    if (!_player->IsInRaidWith(target) || !_player->IsInMap(target))    {        TC_LOG_INFO("loot", "MasterLootItem: Player %s tried to give an item to ineligible player %s !", GetPlayer()->GetName().c_str(), target->GetName().c_str());        return;    }    Loot* loot = NULL;    if (IS_CRE_OR_VEH_GUID(GetPlayer()->GetLootGUID()))    {        Creature* creature = GetPlayer()->GetMap()->GetCreature(lootguid);        if (!creature)            return;        loot = &creature->loot;    }    else if (IS_GAMEOBJECT_GUID(GetPlayer()->GetLootGUID()))    {        GameObject* pGO = GetPlayer()->GetMap()->GetGameObject(lootguid);        if (!pGO)            return;        loot = &pGO->loot;    }    if (!loot)        return;    if (slotid >= loot->items.size() + loot->quest_items.size())    {        TC_LOG_DEBUG("loot", "MasterLootItem: Player %s might be using a hack! (slot %d, size %lu)",            GetPlayer()->GetName().c_str(), slotid, (unsigned long)loot->items.size());        return;    }    LootItem& item = slotid >= loot->items.size() ? loot->quest_items[slotid - loot->items.size()] : loot->items[slotid];    ItemPosCountVec dest;    InventoryResult msg = target->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, item.itemid, item.count);    if (item.follow_loot_rules && !item.AllowedForPlayer(target))        msg = EQUIP_ERR_YOU_CAN_NEVER_USE_THAT_ITEM;    if (msg != EQUIP_ERR_OK)    {        target->SendEquipError(msg, NULL, NULL, item.itemid);        // send duplicate of error massage to master looter        _player->SendEquipError(msg, NULL, NULL, item.itemid);        return;    }    // list of players allowed to receive this item in trade    AllowedLooterSet looters = item.GetAllowedLooters();    // not move item from loot to target inventory    Item* newitem = target->StoreNewItem(dest, item.itemid, true, item.randomPropertyId, looters);    target->SendNewItem(newitem, uint32(item.count), false, false, true);    target->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LOOT_ITEM, item.itemid, item.count);    target->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LOOT_TYPE, loot->loot_type, item.count);    target->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LOOT_EPIC_ITEM, item.itemid, item.count);    // mark as looted    item.count=0;    item.is_looted=true;    loot->NotifyItemRemoved(slotid);    --loot->unlootedCount;}
开发者ID:JayK31,项目名称:TrinityCore,代码行数:88,


示例5: GUID_LOPART

void WorldSession::SendPetitionQueryOpcode(uint64 petitionGuid){    ObjectGuid ownerGuid = 0;    uint32 type;    std::string name = "NO_NAME_FOR_GUID";    PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PETITION);    stmt->setUInt32(0, GUID_LOPART(petitionGuid));    PreparedQueryResult result = CharacterDatabase.Query(stmt);    if (result)    {        Field* fields = result->Fetch();        ownerGuid = MAKE_NEW_GUID(fields[0].GetUInt32(), 0, HIGHGUID_PLAYER);        name      = fields[1].GetString();        type      = fields[2].GetUInt8();    }    else    {        TC_LOG_DEBUG("network", "CMSG_PETITION_QUERY failed for petition (GUID: %u)", GUID_LOPART(petitionGuid));        return;    }    WorldPacket data(SMSG_PETITION_QUERY_RESPONSE, (4+8+name.size()+1+1+4*12+2+10));    data << uint32(GUID_LOPART(petitionGuid));              // guild/team guid (in Trinity always same as GUID_LOPART(petition guid)    data.WriteBit(1); // hasData;    for (int i = 0; i < 10; i++)        data.WriteBits(0, 6); // Unk strings;    data.WriteGuidMask(ownerGuid, 2, 4);    data.WriteBits(0, 12);    data.WriteGuidMask(ownerGuid, 0, 7, 3, 6, 5);    data.WriteBits(name.size(), 7); //NameLen    data.WriteBit(ownerGuid[1]);    data.FlushBits();    data.WriteByteSeq(ownerGuid[5]);    data << uint32(0);    data.WriteString(name);    data << uint32(0);    data.WriteByteSeq(ownerGuid[4]);    data << uint32(type); // Type - 4 guild    data.WriteByteSeq(ownerGuid[6]);    data << uint32(0);    data << uint32(sWorld->getIntConfig(CONFIG_MIN_PETITION_SIGNS)); // Required sign count    data.WriteGuidBytes(ownerGuid, 1, 7, 0);    data << uint32(0);    data << uint32(0);    data.WriteByteSeq(ownerGuid[2]);    data << uint32(time(NULL) + YEAR); // Deadline    data << uint16(0);    data << uint32(0);    data.WriteByteSeq(ownerGuid[3]);    data << uint32(0);    data << uint32(0);    data << uint32(0);    data << uint32(0);    SendPacket(&data);}
开发者ID:Caydan,项目名称:mop548,代码行数:63,


示例6: strtok

bool ChatHandler::HandleCharacterWhisperCommand(const char* args){    if(!*args)        return false;    char *character_name_str = strtok((char*)args, " ");    if(!character_name_str)        return false;    std::string character_name = character_name_str;    if(!normalizePlayerName(character_name))        return false;    char *from_name_str = strtok(NULL, " ");    if(!from_name_str)        return false;    std::string from_name = from_name_str;    if(!normalizePlayerName(from_name))        return false;    Player *player = sObjectMgr.GetPlayer(character_name.c_str());    if(!player || !player->GetSession())    {        PSendSysMessage("Character %s not found or not online", character_name.c_str());        return true;    }    from_name = std::string("[GM]") + from_name;    // set GM name for replies - more than one GM cannot speak with same player at same time    // maybe also needed in ::HandleNameQueryOpcode()  ?    // force SMSG_NAME_QUERY_RESPONSE if name changed to update client display    // note : guid 1 should be reserved dummy !!!    if (player->rcGmName != from_name)    {        player->rcGmName = from_name;        WorldPacket data( SMSG_NAME_QUERY_RESPONSE, (8+1+1+1+1+1+1+10) );        data.appendPackGUID(MAKE_NEW_GUID(1, 0, HIGHGUID_PLAYER));        data << uint8(0);             // added in 3.1        data << from_name.c_str();        data << uint32(0);            // not needed here data        data << uint8(0);             // is not declined        player->GetSession()->SendPacket(&data);    }    // all the tailing text is our msg    char* msgStr = strtok(NULL, "");    if(!msgStr)        return false;    WorldPacket data(SMSG_MESSAGECHAT, 200);    data << (uint8)CHAT_MSG_WHISPER;    data << (uint32)LANG_UNIVERSAL;    data << (uint64)1;              // from guid - reserved dummy    data << (uint32)LANG_UNIVERSAL;    data << (uint64)player->GetGUID();    data << (uint32)(strlen(msgStr)+1);    data << msgStr;    data << (uint8)4;    player->GetSession()->SendPacket(&data);    return true;}
开发者ID:Lirok,项目名称:mangos,代码行数:64,


示例7: HandleGroupListCommand

    static bool HandleGroupListCommand(ChatHandler* handler, char const* args)    {        Player* playerTarget;        uint64 guidTarget;        std::string nameTarget;        uint32 parseGUID = MAKE_NEW_GUID(atol((char*)args), 0, HIGHGUID_PLAYER);        if (sObjectMgr->GetPlayerNameByGUID(parseGUID, nameTarget))        {            playerTarget = sObjectMgr->GetPlayerByLowGUID(parseGUID);            guidTarget = parseGUID;        }        else if (!handler->extractPlayerTarget((char*)args, &playerTarget, &guidTarget, &nameTarget))            return false;        Group* groupTarget = NULL;        if (playerTarget)            groupTarget = playerTarget->GetGroup();        if (!groupTarget)        {            PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_GROUP_MEMBER);            stmt->setUInt32(0, guidTarget);            PreparedQueryResult resultGroup = CharacterDatabase.Query(stmt);            if (resultGroup)                groupTarget = sGroupMgr->GetGroupByDbStoreId((*resultGroup)[0].GetUInt32());        }        if (!groupTarget)        {            handler->PSendSysMessage(LANG_GROUP_NOT_IN_GROUP, nameTarget.c_str());            handler->SetSentErrorMessage(true);            return false;        }        handler->PSendSysMessage(LANG_GROUP_TYPE, (groupTarget->isRaidGroup() ? "raid" : "party"));        Group::MemberSlotList const& members = groupTarget->GetMemberSlots();        for (Group::MemberSlotList::const_iterator itr = members.begin(); itr != members.end(); ++itr)        {            Group::MemberSlot const& slot = *itr;            std::string flags;            if (slot.flags & MEMBER_FLAG_ASSISTANT)                flags = "Assistant";            if (slot.flags & MEMBER_FLAG_MAINTANK)            {                if (!flags.empty())                    flags.append(", ");                flags.append("MainTank");            }            if (slot.flags & MEMBER_FLAG_MAINASSIST)            {                if (!flags.empty())                    flags.append(", ");                flags.append("MainAssist");            }            if (flags.empty())                flags = "None";            Player* p = ObjectAccessor::FindPlayer((*itr).guid);            const char* onlineState = (p && p->IsInWorld()) ? "online" : "offline";            handler->PSendSysMessage(LANG_GROUP_PLAYER_NAME_GUID, slot.name.c_str(), onlineState,                GUID_LOPART(slot.guid), flags.c_str());        }        return true;    }
开发者ID:Dekadencee,项目名称:trinityone,代码行数:72,


示例8: 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() );    }    //Set extended cost for refundable item    if(HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_REFUNDABLE))    {        QueryResult *result_ext = CharacterDatabase.PQuery("SELECT ExtendedCost, price FROM item_instance WHERE guid = '%u'", guid);        if(result_ext)        {            m_ExtendedCostId = result_ext->Fetch()[0].GetUInt32();            m_price = result_ext->Fetch()[1].GetUInt32();//.........这里部分代码省略.........
开发者ID:christof69,项目名称:fusion,代码行数:101,


示例9: GetPlayer

//.........这里部分代码省略.........        }    }    //do not allow to have more than 100 mails in mailbox.. mails count is in opcode uint8!!! - so max can be 255..    if (mails_count > 100)    {        pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_RECIPIENT_CAP_REACHED);        return;    }    // test the receiver's Faction...    if (!sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_MAIL) && pl->GetTeam() != rc_team && GetSecurity() == SEC_PLAYER)    {        pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_NOT_YOUR_TEAM);        return;    }    uint32 rc_account = 0;    if(receive)        rc_account = receive->GetSession()->GetAccountId();    else        rc_account = objmgr.GetPlayerAccountIdByGUID(rc);    if (items_count)    {        for(MailItemMap::iterator mailItemIter = mi.begin(); mailItemIter != mi.end(); ++mailItemIter)        {            MailItem& mailItem = mailItemIter->second;            if(!mailItem.item_guidlow)            {                pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_MAIL_ATTACHMENT_INVALID);                return;            }            mailItem.item = pl->GetItemByGuid(MAKE_NEW_GUID(mailItem.item_guidlow, 0, HIGHGUID_ITEM));            // prevent sending bag with items (cheat: can be placed in bag after adding equipped empty bag to mail)            if(!mailItem.item)            {                pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_MAIL_ATTACHMENT_INVALID);                return;            }            if(!mailItem.item->CanBeTraded(true))            {                pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_EQUIP_ERROR, EQUIP_ERR_MAIL_BOUND_ITEM);                return;            }            if(mailItem.item->IsBoundAccountWide() && mailItem.item->IsSoulBound() && pl->GetSession()->GetAccountId() != rc_account)            {                pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_EQUIP_ERROR, EQUIP_ERR_ARTEFACTS_ONLY_FOR_OWN_CHARACTERS);                return;            }            if (mailItem.item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_CONJURED) || mailItem.item->GetUInt32Value(ITEM_FIELD_DURATION))            {                pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_EQUIP_ERROR, EQUIP_ERR_MAIL_BOUND_ITEM);                return;            }            if(COD && mailItem.item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_WRAPPED))            {                pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_CANT_SEND_WRAPPED_COD);                return;            }        }    }
开发者ID:web0316,项目名称:WOW,代码行数:67,


示例10: data

//called when player lists his received mailsvoid WorldSession::HandleGetMailList(WorldPacket & recv_data ){    uint64 mailbox;    recv_data >> mailbox;    if (!GetPlayer()->GetGameObjectIfCanInteractWith(mailbox, GAMEOBJECT_TYPE_MAILBOX))        return;    Player* pl = _player;    //load players mails, and mailed items    if(!pl->m_mailsLoaded)        pl ->_LoadMail();    // client can't work with packets > max int16 value    const uint32 maxPacketSize = 32767;    uint32 mails_count = 0;                                 // real send to client mails amount    WorldPacket data(SMSG_MAIL_LIST_RESULT, (200));         // guess size    data << uint8(0);                                       // mail's count    time_t cur_time = time(NULL);    for(PlayerMails::iterator itr = pl->GetmailBegin(); itr != pl->GetmailEnd(); ++itr)    {        // skip deleted or not delivered (deliver delay not expired) mails        if ((*itr)->state == MAIL_STATE_DELETED || cur_time < (*itr)->deliver_time)            continue;        uint8 item_count = (*itr)->items.size();            // max count is MAX_MAIL_ITEMS (12)        size_t next_mail_size = 2+4+1+8+4*8+((*itr)->subject.size()+1)+1+item_count*(1+4+4+6*3*4+4+4+1+4+4+4);        if(data.wpos()+next_mail_size > maxPacketSize)            break;        uint32 show_flags = 0;        if ((*itr)->messageType != MAIL_NORMAL)            show_flags |= MAIL_SHOW_DELETE;        if ((*itr)->messageType == MAIL_AUCTION)            show_flags |= MAIL_SHOW_AUCTION;        if ((*itr)->HasItems() && (*itr)->messageType == MAIL_NORMAL)            show_flags |= MAIL_SHOW_RETURN;        data << (uint16) 0x0040;                            // unknown 2.3.0, different values        data << (uint32) (*itr)->messageID;                 // Message ID        data << (uint8) (*itr)->messageType;                // Message Type        switch((*itr)->messageType)        {            case MAIL_NORMAL:                               // sender guid                data << uint64(MAKE_NEW_GUID((*itr)->sender, 0, HIGHGUID_PLAYER));                break;            case MAIL_CREATURE:            case MAIL_GAMEOBJECT:            case MAIL_AUCTION:                data << (uint32) (*itr)->sender;            // creature/gameobject entry, auction id                break;            case MAIL_ITEM:                                 // item entry (?) sender = "Unknown", NYI                break;        }        data << (uint32) (*itr)->COD;                       // COD        data << (uint32) (*itr)->itemTextId;                // sure about this        data << (uint32) 0;                                 // unknown        data << (uint32) (*itr)->stationery;                // stationery (Stationery.dbc)        data << (uint32) (*itr)->money;                     // Gold        data << (uint32) show_flags;                        // unknown, 0x4 - auction, 0x10 - normal                                                            // Time        data << (float)  ((*itr)->expire_time-time(NULL))/DAY;        data << (uint32) (*itr)->mailTemplateId;            // mail template (MailTemplate.dbc)        data << (*itr)->subject;                            // Subject string - once 00, when mail type = 3        data << (uint8) item_count;                         // client limit is 0x10        for(uint8 i = 0; i < item_count; ++i)        {            Item *item = pl->GetMItem((*itr)->items[i].item_guid);            // item index (0-6?)            data << (uint8)  i;            // item guid low?            data << (uint32) (item ? item->GetGUIDLow() : 0);            // entry            data << (uint32) (item ? item->GetEntry() : 0);            for(uint8 j = 0; j < MAX_INSPECTED_ENCHANTMENT_SLOT; ++j)            {                // unsure                data << (uint32) (item ? item->GetEnchantmentCharges((EnchantmentSlot)j) : 0);                // unsure                data << (uint32) (item ? item->GetEnchantmentDuration((EnchantmentSlot)j) : 0);                // unsure                data << (uint32) (item ? item->GetEnchantmentId((EnchantmentSlot)j) : 0);            }            // can be negative            data << (uint32) (item ? item->GetItemRandomPropertyId() : 0);            // unk            data << (uint32) (item ? item->GetItemSuffixFactor() : 0);            // stack count            data << (uint32) (item ? item->GetCount() : 0);//.........这里部分代码省略.........
开发者ID:web0316,项目名称:WOW,代码行数:101,


示例11: HandleGoCreatureCommand

    //teleport to creature    static bool HandleGoCreatureCommand(ChatHandler* handler, char const* args)    {        if (!*args)            return false;        Player* player = handler->GetSession()->GetPlayer();        // "id" or number or [name] Shift-click form |color|Hcreature_entry:creature_id|h[name]|h|r        char* param1 = handler->extractKeyFromLink((char*)args, "Hcreature");        if (!param1)            return false;        std::ostringstream whereClause;        // User wants to teleport to the NPC's template entry        if (strcmp(param1, "id") == 0)        {            // Get the "creature_template.entry"            // number or [name] Shift-click form |color|Hcreature_entry:creature_id|h[name]|h|r            char* tail = strtok(NULL, "");            if (!tail)                return false;            char* id = handler->extractKeyFromLink(tail, "Hcreature_entry");            if (!id)                return false;            int32 entry = atoi(id);            if (!entry)                return false;            whereClause << "WHERE id = '" << entry << '/'';        }        else        {            int32 guid = atoi(param1);            // Number is invalid - maybe the user specified the mob's name            if (!guid)            {                std::string name = param1;                WorldDatabase.EscapeString(name);                whereClause << ", creature_template WHERE creature.id = creature_template.entry AND creature_template.name "_LIKE_" '" << name << '/'';            }            else                whereClause <<  "WHERE guid = '" << guid << '/'';        }        QueryResult result = WorldDatabase.PQuery("SELECT position_x, position_y, position_z, orientation, map, guid, id FROM creature %s", whereClause.str().c_str());        if (!result)        {            handler->SendSysMessage(LANG_COMMAND_GOCREATNOTFOUND);            handler->SetSentErrorMessage(true);            return false;        }        if (result->GetRowCount() > 1)            handler->SendSysMessage(LANG_COMMAND_GOCREATMULTIPLE);        Field* fields = result->Fetch();        float x = fields[0].GetFloat();        float y = fields[1].GetFloat();        float z = fields[2].GetFloat();        float ort = fields[3].GetFloat();        int mapId = fields[4].GetUInt16();        uint32 guid = fields[5].GetUInt32();        uint32 id = fields[6].GetUInt32();        // if creature is in same map with caster go at its current location        if (Creature* creature = sObjectAccessor->GetCreature(*player, MAKE_NEW_GUID(guid, id, HIGHGUID_UNIT)))        {            x = creature->GetPositionX();            y = creature->GetPositionY();            z = creature->GetPositionZ();            ort = creature->GetOrientation();        }        if (!MapManager::IsValidMapCoord(mapId, x, y, z, ort))        {            handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, mapId);            handler->SetSentErrorMessage(true);            return false;        }        // stop flight if need        if (player->isInFlight())        {            player->GetMotionMaster()->MovementExpired();            player->CleanupAfterTaxiFlight();        }        // save only in non-flight case        else            player->SaveRecallPosition();        player->TeleportTo(mapId, x, y, z, ort);        return true;    }
开发者ID:hodobaj,项目名称:Darkcore,代码行数:96,


示例12: GetSlot

bool ArenaTeam::LoadMembersFromDB(QueryResult arenaTeamMembersResult){    if (!arenaTeamMembersResult)        return false;    bool captainPresentInTeam = false;    do    {        Field *fields = arenaTeamMembersResult->Fetch();        //prevent crash if db records are broken, when all members in result are already processed and current team hasn't got any members        if (!fields)            break;        uint32 arenaTeamId        = fields[0].GetUInt32();        if (arenaTeamId < m_TeamId)        {            //there is in table arena_team_member record which doesn't have arenateamid in arena_team table, report error            sLog.outErrorDb("ArenaTeam %u does not exist but it has record in arena_team_member table, deleting it!", arenaTeamId);            CharacterDatabase.PExecute("DELETE FROM arena_team_member WHERE arenateamid = '%u'", arenaTeamId);            continue;        }        if (arenaTeamId > m_TeamId)            //we loaded all members for this arena_team already, break cycle            break;        uint32 player_guid = fields[1].GetUInt32();        QueryResult result = CharacterDatabase.PQuery(            "SELECT personal_rating, matchmaker_rating FROM character_arena_stats WHERE guid = '%u' AND slot = '%u'", player_guid, GetSlot());        uint32 personalrating = 0;        uint32 matchmakerrating = 1500;        if (result)        {            personalrating = (*result)[0].GetUInt32();            matchmakerrating = (*result)[1].GetUInt32();        }        ArenaTeamMember newmember;        newmember.guid              = MAKE_NEW_GUID(player_guid, 0, HIGHGUID_PLAYER);        newmember.games_week        = fields[2].GetUInt32();        newmember.wins_week         = fields[3].GetUInt32();        newmember.games_season      = fields[4].GetUInt32();        newmember.wins_season       = fields[5].GetUInt32();        newmember.name              = fields[6].GetString();        newmember.Class             = fields[7].GetUInt8();        newmember.personal_rating   = personalrating;        newmember.matchmaker_rating = matchmakerrating;        //check if member exists in characters table        if (newmember.name.empty())        {            sLog.outErrorDb("ArenaTeam %u has member with empty name - probably player %u doesn't exist, deleting him from memberlist!", arenaTeamId, GUID_LOPART(newmember.guid));            this->DelMember(newmember.guid);            continue;        }        if (newmember.guid == GetCaptain())            captainPresentInTeam = true;        m_members.push_back(newmember);    }while (arenaTeamMembersResult->NextRow());    if (Empty() || !captainPresentInTeam)    {        // arena team is empty or captain is not in team, delete from db        sLog.outErrorDb("ArenaTeam %u does not have any members or its captain is not in team, disbanding it...", m_TeamId);        return false;    }    return true;}
开发者ID:sensibob,项目名称:tempestcore,代码行数:74,


示例13: MAKE_NEW_GUID

void WorldSession::HandleCalendarEventInvite(WorldPacket& recvData){    sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_CALENDAR_EVENT_INVITE");    uint64 playerGuid = _player->GetGUID();    uint64 eventId;    uint64 inviteId;    std::string name;    bool isPreInvite;    bool isGuildEvent;    uint64 inviteeGuid = 0;    uint32 inviteeTeam = 0;    uint32 inviteeGuildId = 0;    recvData >> eventId >> inviteId >> name >> isPreInvite >> isGuildEvent;    if (Player* player = sObjectAccessor->FindPlayerByName(name.c_str()))    {        // Invitee is online        inviteeGuid = player->GetGUID();        inviteeTeam = player->GetTeam();        inviteeGuildId = player->GetGuildId();    }    else    {        // Invitee offline, get data from database        PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_GUID_RACE_ACC_BY_NAME);        stmt->setString(0, name);        if (PreparedQueryResult result = CharacterDatabase.Query(stmt))        {            Field* fields = result->Fetch();            inviteeGuid = MAKE_NEW_GUID(fields[0].GetUInt32(), 0, HIGHGUID_PLAYER);            inviteeTeam = Player::TeamForRace(fields[1].GetUInt8());            inviteeGuildId = Player::GetGuildIdFromDB(inviteeGuid);        }    }    if (!inviteeGuid)    {        sCalendarMgr->SendCalendarCommandResult(playerGuid, CALENDAR_ERROR_PLAYER_NOT_FOUND);        return;    }    if (_player->GetTeam() != inviteeTeam && !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CALENDAR))    {        sCalendarMgr->SendCalendarCommandResult(playerGuid, CALENDAR_ERROR_NOT_ALLIED);        return;    }    if (QueryResult result = CharacterDatabase.PQuery("SELECT flags FROM character_social WHERE guid = " UI64FMTD " AND friend = " UI64FMTD, inviteeGuid, playerGuid))    {        Field* fields = result->Fetch();        if (fields[0].GetUInt8() & SOCIAL_FLAG_IGNORED)        {            sCalendarMgr->SendCalendarCommandResult(playerGuid, CALENDAR_ERROR_IGNORING_YOU_S, name.c_str());            return;        }    }    if (!isPreInvite)    {        if (CalendarEvent* calendarEvent = sCalendarMgr->GetEvent(eventId))        {            if (calendarEvent->IsGuildEvent() && calendarEvent->GetGuildId() == inviteeGuildId)            {                // we can't invite guild members to guild events                sCalendarMgr->SendCalendarCommandResult(playerGuid, CALENDAR_ERROR_NO_GUILD_INVITES);                return;            }            // 946684800 is 01/01/2000 00:00:00 - default response time            CalendarInvite* invite = new CalendarInvite(sCalendarMgr->GetFreeInviteId(), eventId, inviteeGuid, playerGuid, 946684800, CALENDAR_STATUS_INVITED, CALENDAR_RANK_PLAYER, "");            sCalendarMgr->AddInvite(calendarEvent, invite);        }        else            sCalendarMgr->SendCalendarCommandResult(playerGuid, CALENDAR_ERROR_EVENT_INVALID);    }    else    {        if (isGuildEvent && inviteeGuildId == _player->GetGuildId())        {            sCalendarMgr->SendCalendarCommandResult(playerGuid, CALENDAR_ERROR_NO_GUILD_INVITES);            return;        }        // 946684800 is 01/01/2000 00:00:00 - default response time        CalendarInvite* invite = new CalendarInvite(inviteId, 0, inviteeGuid, playerGuid, 946684800, CALENDAR_STATUS_INVITED, CALENDAR_RANK_PLAYER, "");        sCalendarMgr->SendCalendarEventInvite(*invite);    }}
开发者ID:Arphenion-Dev,项目名称:Source,代码行数:92,


示例14: GetAItem

//does not clear ramvoid AuctionHouseMgr::SendAuctionWonMail( AuctionEntry *auction ){    Item *pItem = GetAItem(auction->item_guidlow);    if(!pItem)        return;    uint64 bidder_guid = MAKE_NEW_GUID(auction->bidder, 0, HIGHGUID_PLAYER);    Player *bidder = objmgr.GetPlayer(bidder_guid);    uint32 bidder_accId = 0;    // data for gm.log    if( sWorld.getConfig(CONFIG_GM_LOG_TRADE) )    {        uint32 bidder_security = 0;        std::string bidder_name;        if (bidder)        {            bidder_accId = bidder->GetSession()->GetAccountId();            bidder_security = bidder->GetSession()->GetSecurity();            bidder_name = bidder->GetName();        }        else        {            bidder_accId = objmgr.GetPlayerAccountIdByGUID(bidder_guid);            bidder_security = accmgr.GetSecurity(bidder_accId);            if(bidder_security > SEC_PLAYER )               // not do redundant DB requests            {                if(!objmgr.GetPlayerNameByGUID(bidder_guid,bidder_name))                    bidder_name = objmgr.GetMangosStringForDBCLocale(LANG_UNKNOWN);            }        }        if( bidder_security > SEC_PLAYER )        {            std::string owner_name;            if(!objmgr.GetPlayerNameByGUID(auction->owner,owner_name))                owner_name = objmgr.GetMangosStringForDBCLocale(LANG_UNKNOWN);            uint32 owner_accid = objmgr.GetPlayerAccountIdByGUID(auction->owner);            sLog.outCommand(bidder_accId,"GM %s (Account: %u) won item in auction: %s (Entry: %u Count: %u) and pay money: %u. Original owner %s (Account: %u)",                            bidder_name.c_str(),bidder_accId,pItem->GetProto()->Name1,pItem->GetEntry(),pItem->GetCount(),auction->bid,owner_name.c_str(),owner_accid);        }    }    else if(!bidder)        bidder_accId = objmgr.GetPlayerAccountIdByGUID(bidder_guid);    // receiver exist    if(bidder || bidder_accId)    {        std::ostringstream msgAuctionWonSubject;        msgAuctionWonSubject << auction->item_template << ":0:" << AUCTION_WON;        std::ostringstream msgAuctionWonBody;        msgAuctionWonBody.width(16);        msgAuctionWonBody << std::right << std::hex << auction->owner;        msgAuctionWonBody << std::dec << ":" << auction->bid << ":" << auction->buyout;        sLog.outDebug( "AuctionWon body string : %s", msgAuctionWonBody.str().c_str() );        //prepare mail data... :        uint32 itemTextId = objmgr.CreateItemText( msgAuctionWonBody.str() );        // set owner to bidder (to prevent delete item with sender char deleting)        // owner in `data` will set at mail receive and item extracting        CharacterDatabase.PExecute("UPDATE item_instance SET owner_guid = '%u' WHERE guid='%u'",auction->bidder,pItem->GetGUIDLow());        CharacterDatabase.CommitTransaction();        MailItemsInfo mi;        mi.AddItem(auction->item_guidlow, auction->item_template, pItem);        if (bidder)            bidder->GetSession()->SendAuctionBidderNotification( auction->GetHouseId(), auction->Id, bidder_guid, 0, 0, auction->item_template);        else            RemoveAItem(pItem->GetGUIDLow());               // we have to remove the item, before we delete it !!        // will delete item or place to receiver mail list        WorldSession::SendMailTo(bidder, MAIL_AUCTION, MAIL_STATIONERY_AUCTION, auction->GetHouseId(), auction->bidder, msgAuctionWonSubject.str(), itemTextId, &mi, 0, 0, MAIL_CHECK_MASK_AUCTION);    }    // receiver not exist    else    {        CharacterDatabase.PExecute("DELETE FROM item_instance WHERE guid='%u'", pItem->GetGUIDLow());        RemoveAItem(pItem->GetGUIDLow());                   // we have to remove the item, before we delete it !!        delete pItem;    }}
开发者ID:opivfx,项目名称:mangos,代码行数:89,


示例15: HandleWpModifyCommand

    static bool HandleWpModifyCommand(ChatHandler* handler, const char* args)    {        if (!*args)            return false;        // first arg: add del text emote spell waittime move        char* show_str = strtok((char*)args, " ");        if (!show_str)        {            return false;        }        std::string show = show_str;        // Check        // Remember: "show" must also be the name of a column!        if ((show != "delay") && (show != "action") && (show != "action_chance")            && (show != "move_flag") && (show != "del") && (show != "move") && (show != "wpadd")            )        {            return false;        }        // Next arg is: <PATHID> <WPNUM> <ARGUMENT>        char* arg_str = NULL;        // Did user provide a GUID        // or did the user select a creature?        // -> variable lowguid is filled with the GUID of the NPC        uint32 pathid = 0;        uint32 point = 0;        uint32 wpGuid = 0;        Creature* target = handler->getSelectedCreature();        if (!target || target->GetEntry() != VISUAL_WAYPOINT)        {            handler->SendSysMessage("|cffff33ffERROR: You must select a waypoint.|r");            return false;        }        // The visual waypoint        wpGuid = target->GetGUIDLow();        // User did select a visual waypoint?        // Check the creature        QueryResult result = WorldDatabase.PQuery("SELECT id, point FROM waypoint_data WHERE wpguid = %u", wpGuid);        if (!result)        {            handler->PSendSysMessage(LANG_WAYPOINT_NOTFOUNDSEARCH, target->GetGUIDLow());            // Select waypoint number from database            // Since we compare float values, we have to deal with            // some difficulties.            // Here we search for all waypoints that only differ in one from 1 thousand            // (0.001) - There is no other way to compare C++ floats with mySQL floats            // See also: http://dev.mysql.com/doc/refman/5.0/en/problems-with-float.html            const char* maxDIFF = "0.01";            result = WorldDatabase.PQuery("SELECT id, point FROM waypoint_data WHERE (abs(position_x - %f) <= %s) and (abs(position_y - %f) <= %s) and (abs(position_z - %f) <= %s)",                target->GetPositionX(), maxDIFF, target->GetPositionY(), maxDIFF, target->GetPositionZ(), maxDIFF);            if (!result)            {                handler->PSendSysMessage(LANG_WAYPOINT_NOTFOUNDDBPROBLEM, wpGuid);                return true;            }        }        do        {            Field* fields = result->Fetch();            pathid = fields[0].GetUInt32();            point  = fields[1].GetUInt32();        }        while (result->NextRow());        // We have the waypoint number and the GUID of the "master npc"        // Text is enclosed in "<>", all other arguments not        arg_str = strtok((char*)NULL, " ");        // Check for argument        if (show != "del" && show != "move" && arg_str == NULL)        {            handler->PSendSysMessage(LANG_WAYPOINT_ARGUMENTREQ, show_str);            return false;        }        if (show == "del" && target)        {            handler->PSendSysMessage("|cff00ff00DEBUG: wp modify del, PathID: |r|cff00ffff%u|r", pathid);            // wpCreature            Creature* wpCreature = NULL;            if (wpGuid != 0)            {                wpCreature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(wpGuid, VISUAL_WAYPOINT, HIGHGUID_UNIT));                wpCreature->CombatStop();                wpCreature->DeleteFromDB();                wpCreature->AddObjectToRemoveList();            }//.........这里部分代码省略.........
开发者ID:TDMarko,项目名称:SkyFireEMU_rebase,代码行数:101,


示例16: while

//.........这里部分代码省略.........                }                break;            case SCRIPT_COMMAND_CALLSCRIPT_TO_UNIT:            {                if (!step.script->CallScript.CreatureEntry)                {                    sLog->outError("%s creature entry is not specified, skipping.", step.script->GetDebugInfo().c_str());                    break;                }                if (!step.script->CallScript.ScriptID)                {                    sLog->outError("%s script id is not specified, skipping.", step.script->GetDebugInfo().c_str());                    break;                }                Creature* cTarget = NULL;                if (source) //using grid searcher                {                    WorldObject* wSource = dynamic_cast <WorldObject*> (source);                    CellCoord p(Trinity::ComputeCellCoord(wSource->GetPositionX(), wSource->GetPositionY()));                    Cell cell(p);                    Trinity::CreatureWithDbGUIDCheck target_check(wSource, step.script->CallScript.CreatureEntry);                    Trinity::CreatureSearcher<Trinity::CreatureWithDbGUIDCheck> checker(wSource, cTarget, target_check);                    TypeContainerVisitor<Trinity::CreatureSearcher <Trinity::CreatureWithDbGUIDCheck>, GridTypeMapContainer > unit_checker(checker);                    cell.Visit(p, unit_checker, *wSource->GetMap(), *wSource, wSource->GetGridActivationRange());                }                else //check hashmap holders                {                    if (CreatureData const* data = sObjectMgr->GetCreatureData(step.script->CallScript.CreatureEntry))                        cTarget = ObjectAccessor::GetObjectInWorld<Creature>(data->mapid, data->posX, data->posY, MAKE_NEW_GUID(step.script->CallScript.CreatureEntry, data->id, HIGHGUID_UNIT), cTarget);                }                if (!cTarget)                {                    sLog->outError("%s target was not found (entry: %u)", step.script->GetDebugInfo().c_str(), step.script->CallScript.CreatureEntry);                    break;                }                //Lets choose our ScriptMap map                ScriptMapMap* datamap = GetScriptsMapByType(ScriptsType(step.script->CallScript.ScriptType));                //if no scriptmap present...                if (!datamap)                {                    sLog->outError("%s unknown scriptmap (%u) specified, skipping.", step.script->GetDebugInfo().c_str(), step.script->CallScript.ScriptType);                    break;                }                // Insert script into schedule but do not start it                ScriptsStart(*datamap, step.script->CallScript.ScriptID, cTarget, NULL);                break;            }            case SCRIPT_COMMAND_KILL:                // Source or target must be Creature.                if (Creature* cSource = _GetScriptCreatureSourceOrTarget(source, target, step.script))                {                    if (cSource->isDead())                        sLog->outError("%s creature is already dead (Entry: %u, GUID: %u)",                            step.script->GetDebugInfo().c_str(), cSource->GetEntry(), cSource->GetGUIDLow());                    else                    {                        cSource->setDeathState(JUST_DIED);
开发者ID:whit33r,项目名称:TrinityCore,代码行数:67,


示例17: HandleWpShowCommand

//.........这里部分代码省略.........                handler->PSendSysMessage("|cff00ff00Show info: delay: |r|cff00ffff%u|r", delay);                handler->PSendSysMessage("|cff00ff00Show info: Move flag: |r|cff00ffff%u|r", flag);                handler->PSendSysMessage("|cff00ff00Show info: Waypoint event: |r|cff00ffff%u|r", ev_id);                handler->PSendSysMessage("|cff00ff00Show info: Event chance: |r|cff00ffff%u|r", ev_chance);            }            while (result->NextRow());            return true;        }        if (show == "on")        {            QueryResult result = WorldDatabase.PQuery("SELECT point, position_x, position_y, position_z FROM waypoint_data WHERE id = '%u'", pathid);            if (!result)            {                handler->SendSysMessage("|cffff33ffPath no found.|r");                handler->SetSentErrorMessage(true);                return false;            }            handler->PSendSysMessage("|cff00ff00DEBUG: wp on, PathID: |cff00ffff%u|r", pathid);            // Delete all visuals for this NPC            QueryResult result2 = WorldDatabase.PQuery("SELECT wpguid FROM waypoint_data WHERE id = '%u' and wpguid <> 0", pathid);            if (result2)            {                bool hasError = false;                do                {                    Field* fields = result2->Fetch();                    uint32 wpguid = fields[0].GetUInt32();                    Creature* creature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(wpguid, VISUAL_WAYPOINT, HIGHGUID_UNIT));                    if (!creature)                    {                        handler->PSendSysMessage(LANG_WAYPOINT_NOTREMOVED, wpguid);                        hasError = true;                        WorldDatabase.PExecute("DELETE FROM creature WHERE guid = '%u'", wpguid);                    }                    else                    {                        creature->CombatStop();                        creature->DeleteFromDB();                        creature->AddObjectToRemoveList();                    }                }                while (result2->NextRow());                if (hasError)                {                    handler->PSendSysMessage(LANG_WAYPOINT_TOOFAR1);                    handler->PSendSysMessage(LANG_WAYPOINT_TOOFAR2);                    handler->PSendSysMessage(LANG_WAYPOINT_TOOFAR3);                }            }            do            {                Field* fields = result->Fetch();                uint32 point    = fields[0].GetUInt32();                float x         = fields[1].GetFloat();                float y         = fields[2].GetFloat();                float z         = fields[3].GetFloat();
开发者ID:TDMarko,项目名称:SkyFireEMU_rebase,代码行数:66,


示例18: MAKE_NEW_GUID

//show info of playerbool ChatHandler::HandlePInfoCommand(const char* args){    Player* target;    uint64 target_guid;    std::string target_name;    uint32 parseGUID = MAKE_NEW_GUID(atol((char*)args), 0, HIGHGUID_PLAYER);    if (sObjectMgr->GetPlayerNameByGUID(parseGUID, target_name))    {        target = sObjectMgr->GetPlayerByLowGUID(parseGUID);        target_guid = parseGUID;    }    else if (!extractPlayerTarget((char*)args, &target, &target_guid, &target_name))        return false;    uint32 accId             = 0;    uint32 money             = 0;    uint32 total_player_time = 0;    uint8 level              = 0;    uint32 latency           = 0;    uint8 race;    uint8 Class;    int64 muteTime           = 0;    int64 banTime            = -1;    uint32 mapId;    uint32 areaId;    uint32 phase             = 0;    // get additional information from Player object    if (target)    {        // check online security        if (HasLowerSecurity(target, 0))            return false;        accId             = target->GetSession()->GetAccountId();        money             = target->GetMoney();        total_player_time = target->GetTotalPlayedTime();        level             = target->getLevel();        latency           = target->GetSession()->GetLatency();        race              = target->getRace();        Class             = target->getClass();        muteTime          = target->GetSession()->m_muteTime;        mapId             = target->GetMapId();        areaId            = target->GetAreaId();        phase             = target->GetPhaseMask();    }    // get additional information from DB    else    {        // check offline security        if (HasLowerSecurity(NULL, target_guid))            return false;        PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_PINFO);        stmt->setUInt32(0, GUID_LOPART(target_guid));        PreparedQueryResult result = CharacterDatabase.Query(stmt);        if (!result)            return false;        Field* fields     = result->Fetch();        total_player_time = fields[0].GetUInt32();        level             = fields[1].GetUInt8();        money             = fields[2].GetUInt32();        accId             = fields[3].GetUInt32();        race              = fields[4].GetUInt8();        Class             = fields[5].GetUInt8();        mapId             = fields[6].GetUInt16();        areaId            = fields[7].GetUInt16();    }    std::string username   = GetTrinityString(LANG_ERROR);    std::string email      = GetTrinityString(LANG_ERROR);    std::string last_ip    = GetTrinityString(LANG_ERROR);    uint32 security        = 0;    std::string last_login = GetTrinityString(LANG_ERROR);    PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_PINFO);    stmt->setInt32(0, int32(realmID));    stmt->setUInt32(1, accId);    PreparedQueryResult result = LoginDatabase.Query(stmt);    if (result)    {        Field* fields = result->Fetch();        username      = fields[0].GetString();        security      = fields[1].GetUInt8();        email         = fields[2].GetString();        muteTime      = fields[5].GetUInt64();        if (email.empty())            email = "-";        if (!m_session || m_session->GetSecurity() >= AccountTypes(security))        {            last_ip = fields[3].GetString();            last_login = fields[4].GetString();//.........这里部分代码省略.........
开发者ID:Laintime,项目名称:BattleArenas,代码行数:101,


示例19: GetAItem

//does not clear ramvoid AuctionHouseMgr::SendAuctionWonMail(AuctionEntry* auction, SQLTransaction& trans){    Item* pItem = GetAItem(auction->itemGUIDLow);    if (!pItem)        return;    uint32 bidderAccId = 0;    uint64 bidderGuid = MAKE_NEW_GUID(auction->bidder, 0, HIGHGUID_PLAYER);    Player* bidder = ObjectAccessor::FindPlayer(bidderGuid);    // data for gm.log    std::string bidderName;    bool logGmTrade = false;    if (bidder)    {        bidderAccId = bidder->GetSession()->GetAccountId();        bidderName = bidder->GetName();        logGmTrade = bidder->GetSession()->HasPermission(RBAC_PERM_LOG_GM_TRADE);    }    else    {        bidderAccId = sObjectMgr->GetPlayerAccountIdByGUID(bidderGuid);        logGmTrade = AccountMgr::HasPermission(bidderAccId, RBAC_PERM_LOG_GM_TRADE, realmID);        if (logGmTrade && !sObjectMgr->GetPlayerNameByGUID(bidderGuid, bidderName))            bidderName = sObjectMgr->GetTrinityStringForDBCLocale(LANG_UNKNOWN);    }    if (logGmTrade)    {        std::string ownerName;        if (!sObjectMgr->GetPlayerNameByGUID(auction->owner, ownerName))            ownerName = sObjectMgr->GetTrinityStringForDBCLocale(LANG_UNKNOWN);        uint32 ownerAccId = sObjectMgr->GetPlayerAccountIdByGUID(auction->owner);        sLog->outCommand(bidderAccId, "GM %s (Account: %u) won item in auction: %s (Entry: %u Count: %u) and pay money: %u. Original owner %s (Account: %u)",            bidderName.c_str(), bidderAccId, pItem->GetTemplate()->Name1.c_str(), pItem->GetEntry(), pItem->GetCount(), auction->bid, ownerName.c_str(), ownerAccId);    }    // receiver exist    if (bidder || bidderAccId)    {        // set owner to bidder (to prevent delete item with sender char deleting)        // owner in `data` will set at mail receive and item extracting        PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ITEM_OWNER);        stmt->setUInt32(0, auction->bidder);        stmt->setUInt32(1, pItem->GetGUIDLow());        trans->Append(stmt);        if (bidder)        {            bidder->GetSession()->SendAuctionBidderNotification(auction->GetHouseId(), auction->Id, bidderGuid, 0, 0, auction->itemEntry);            // FIXME: for offline player need also            bidder->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_WON_AUCTIONS, 1);        }        MailDraft(auction->BuildAuctionMailSubject(AUCTION_WON), AuctionEntry::BuildAuctionMailBody(auction->owner, auction->bid, auction->buyout, 0, 0))            .AddItem(pItem)            .SendMailTo(trans, MailReceiver(bidder, auction->bidder), auction, MAIL_CHECK_MASK_COPIED);    }}
开发者ID:Hobito,项目名称:TrinityCore,代码行数:63,


示例20:

void PoolGroup<Creature>::ReSpawn1Object(PoolObject* obj){    if (CreatureData const* data = sObjectMgr->GetCreatureData(obj->guid))        if (Creature* pCreature = ObjectAccessor::GetObjectInWorld(MAKE_NEW_GUID(obj->guid, data->id, HIGHGUID_UNIT), (Creature*)NULL))            pCreature->GetMap()->Add(pCreature);}
开发者ID:sacel,项目名称:StrawberryEMU,代码行数:6,


示例21: GetPlayer

//this function is called when client bids or buys out auctionvoid WorldSession::HandleAuctionPlaceBid(WorldPacket & recv_data){    uint64 auctioneer;    uint32 auctionId;    uint64 price;    recv_data >> auctioneer;    recv_data >> auctionId >> price;    if (!auctionId || !price)        return;                                             //check for cheaters    Creature *pCreature = GetPlayer()->GetNPCIfCanInteractWith(auctioneer, UNIT_NPC_FLAG_AUCTIONEER);    if (!pCreature)    {        sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: HandleAuctionPlaceBid - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(auctioneer)));        return;    }    // remove fake death    if (GetPlayer()->HasUnitState(UNIT_STAT_DIED))        GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);    AuctionHouseObject *auctionHouse = sAuctionMgr->GetAuctionsMap(pCreature->getFaction());    AuctionEntry *auction = auctionHouse->GetAuction(auctionId);    Player *pl = GetPlayer();    if (!auction || auction->owner == pl->GetGUIDLow())    {        //you cannot bid your own auction:        SendAuctionCommandResult(0, AUCTION_PLACE_BID, CANNOT_BID_YOUR_AUCTION_ERROR);        return;    }    // impossible have online own another character (use this for speedup check in case online owner)    Player* auction_owner = sObjectMgr->GetPlayer(MAKE_NEW_GUID(auction->owner, 0, HIGHGUID_PLAYER));    if (!auction_owner && sObjectMgr->GetPlayerAccountIdByGUID(MAKE_NEW_GUID(auction->owner, 0, HIGHGUID_PLAYER)) == pl->GetSession()->GetAccountId())    {        //you cannot bid your another character auction:        SendAuctionCommandResult(0, AUCTION_PLACE_BID, CANNOT_BID_YOUR_AUCTION_ERROR);        return;    }    // cheating    if (price <= auction->bid || price < auction->startbid)        return;    // price too low for next bid if not buyout    if ((price < auction->buyout || auction->buyout == 0) &&        price < auction->bid + auction->GetAuctionOutBid())    {        //auction has already higher bid, client tests it!        return;    }    if (!pl->HasEnoughMoney((uint32)price))    {        //you don't have enought money!, client tests!        //SendAuctionCommandResult(auction->auctionId, AUCTION_PLACE_BID, ???);        return;    }    SQLTransaction trans = CharacterDatabase.BeginTransaction();    if (price < auction->buyout || auction->buyout == 0)    {        if (auction->bidder > 0)        {            if (auction->bidder == pl->GetGUIDLow())                pl->ModifyMoney(-int32(price - auction->bid));            else            {                // mail to last bidder and return money                sAuctionMgr->SendAuctionOutbiddedMail(auction, price, GetPlayer(), trans);                pl->ModifyMoney(-int32(price));            }        }        else            pl->ModifyMoney(-int32(price));        auction->bidder = pl->GetGUIDLow();        auction->bid = price;        GetPlayer()->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_BID, price);        trans->PAppend("UPDATE auctionhouse SET buyguid = '%u', lastbid = '%u' WHERE id = '%u'", auction->bidder, auction->bid, auction->Id);        SendAuctionCommandResult(auction->Id, AUCTION_PLACE_BID, AUCTION_OK, 0);    }    else    {        //buyout:        if (pl->GetGUIDLow() == auction->bidder)            pl->ModifyMoney(-int32(auction->buyout - auction->bid));        else        {            pl->ModifyMoney(-int32(auction->buyout));            if (auction->bidder)                          //buyout for bidded auction ..                sAuctionMgr->SendAuctionOutbiddedMail(auction, auction->buyout, GetPlayer(), trans);        }//.........这里部分代码省略.........
开发者ID:H4D3S,项目名称:DarkmoonCore-Cataclysm,代码行数:101,


示例22: SetEntry

bool Item::LoadFromDB(uint32 guid, uint64 owner_guid, Field* fields, uint32 entry){    //                                                    0                1      2         3        4      5             6                 7           8           9    10    //result = CharacterDatabase.PQuery("SELECT creatorGuid, giftCreatorGuid, count, duration, charges, flags, enchantments, randomPropertyId, durability, playedTime, text FROM item_instance WHERE guid = '%u'", guid);    // 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);    // Set entry, MUST be before proto check    SetEntry(entry);    SetFloatValue(OBJECT_FIELD_SCALE_X, 1.0f);    ItemTemplate const* proto = GetTemplate();    if (!proto)        return false;    // set owner (not if item is only loaded for gbank/auction/mail    if (owner_guid != 0)        SetOwnerGUID(owner_guid);    bool need_save = false;                                 // need explicit save data at load fixes    SetUInt64Value(ITEM_FIELD_CREATOR, MAKE_NEW_GUID(fields[0].GetUInt32(), 0, HIGHGUID_PLAYER));    SetUInt64Value(ITEM_FIELD_GIFTCREATOR, MAKE_NEW_GUID(fields[1].GetUInt32(), 0, HIGHGUID_PLAYER));    SetCount(fields[2].GetUInt32());    uint32 duration = fields[3].GetUInt32();    SetUInt32Value(ITEM_FIELD_DURATION, duration);    // update duration if need, and remove if not need    if ((proto->Duration == 0) != (duration == 0))    {        SetUInt32Value(ITEM_FIELD_DURATION, abs(proto->Duration));        need_save = true;    }    Tokens tokens(fields[4].GetString(), ' ', MAX_ITEM_PROTO_SPELLS);    if (tokens.size() == MAX_ITEM_PROTO_SPELLS)        for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)            SetSpellCharges(i, atoi(tokens[i]));    SetUInt32Value(ITEM_FIELD_FLAGS, fields[5].GetUInt32());    // Remove bind flag for items vs NO_BIND set    if (IsSoulBound() && proto->Bonding == NO_BIND)    {        ApplyModFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_SOULBOUND, false);        need_save = true;    }    std::string enchants = fields[6].GetString();    //_LoadIntoDataField(enchants.c_str(), ITEM_FIELD_ENCHANTMENT_1_1, MAX_ENCHANTMENT_SLOT * MAX_ENCHANTMENT_OFFSET);    {        // NOTE:        // in the recent update of reforge system, definition of EnchantmentSlot has been changed,        // and MAX_ENCHANTMENT_SLOT has been changed from 13 to 14,        // which makes enchantments column of item_instance table incompatible with previous version.        // in this case we will load only first 9 enchantment slots (0-8, for permanent, temporary, sockets, bonus, prismatic and reforge)        // and ignore the remaining ones (9-13, for random properties).        // which means item random properties will be lost after this update.        // after player logging in and saving the inventory, enchantments column will be properly updated.        uint32 count = MAX_ENCHANTMENT_SLOT * MAX_ENCHANTMENT_OFFSET;        Tokens tokens(enchants, ' ', count);        if (tokens.size() < MAX_ENCHANTMENT_SLOT * MAX_ENCHANTMENT_OFFSET)            count = REFORGE_ENCHANTMENT_SLOT * MAX_ENCHANTMENT_OFFSET;        for (uint32 index = 0; index < count; ++index)            m_uint32Values[ITEM_FIELD_ENCHANTMENT_1_1 + index] = index < tokens.size() ? atol(tokens[index]) : 0;    }    SetInt32Value(ITEM_FIELD_RANDOM_PROPERTIES_ID, fields[7].GetInt16());    // recalculate suffix factor    if (GetItemRandomPropertyId() < 0)        UpdateItemSuffixFactor();    uint32 durability = fields[8].GetUInt16();    SetUInt32Value(ITEM_FIELD_DURABILITY, durability);    // update max durability (and durability) if need    SetUInt32Value(ITEM_FIELD_MAXDURABILITY, proto->MaxDurability);    if (durability > proto->MaxDurability)    {        SetUInt32Value(ITEM_FIELD_DURABILITY, proto->MaxDurability);        need_save = true;    }    SetUInt32Value(ITEM_FIELD_CREATE_PLAYED_TIME, fields[9].GetUInt32());    SetText(fields[10].GetString());    if (need_save)                                           // normal item changed state set not work at loading    {        PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPDATE_ITEM_INSTANCE_ON_LOAD);        stmt->setUInt32(0, GetUInt32Value(ITEM_FIELD_DURATION));        stmt->setUInt32(1, GetUInt32Value(ITEM_FIELD_FLAGS));        stmt->setUInt32(2, GetUInt32Value(ITEM_FIELD_DURABILITY));        stmt->setUInt32(3, guid);        CharacterDatabase.Execute(stmt);    }    return true;}
开发者ID:Bootz,项目名称:TrilliumEMU-1,代码行数:99,



注:本文中的MAKE_NEW_GUID函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ MAKE_PAIR函数代码示例
C++ MAKE_ID函数代码示例
51自学网自学EXCEL、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。
京ICP备13026421号-1