本文整理汇总了C++中MAKE_NEW_GUID函数的典型用法代码示例。如果您正苦于以下问题:C++ MAKE_NEW_GUID函数的具体用法?C++ MAKE_NEW_GUID怎么用?C++ MAKE_NEW_GUID使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MAKE_NEW_GUID函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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,代码来源:LootHandler.cpp
示例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,代码来源:PetitionsHandler.cpp
示例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,代码来源:Item.cpp
示例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,代码来源:LootHandler.cpp
示例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,代码来源:PetitionsHandler.cpp
示例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,代码来源:CliRunnable.cpp
示例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,代码来源:cs_group.cpp
示例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,代码来源:Item.cpp
示例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,代码来源:Mail.cpp
示例10: data
//called when player lists his received mails
void 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,代码来源:Mail.cpp
示例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,代码来源:cs_go.cpp
示例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,代码来源:ArenaTeam.cpp
示例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,代码来源:CalendarHandler.cpp
示例14: GetAItem
//does not clear ram
void 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());
|
请发表评论