本文整理汇总了C++中GetOwnerGUID函数的典型用法代码示例。如果您正苦于以下问题:C++ GetOwnerGUID函数的具体用法?C++ GetOwnerGUID怎么用?C++ GetOwnerGUID使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetOwnerGUID函数的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: GetOwner
Player* Item::GetOwner()const
{
return objmgr.GetPlayer(GetOwnerGUID());
}
开发者ID:Golgotha29,项目名称:mangos,代码行数:4,代码来源:Item.cpp
示例2: GetOwnerGUID
Unit* GameObject::GetOwner() const
{
return ObjectAccessor::GetUnit(*this, GetOwnerGUID());
}
开发者ID:yunishaa,项目名称:mangos-112,代码行数:4,代码来源:GameObject.cpp
示例3: switch
//.........这里部分代码省略.........
// cast this spell later if provided
spellId = info->goober.spellId;
break;
}
case GAMEOBJECT_TYPE_CAMERA: //13
{
GameObjectInfo const* info = GetGOInfo();
if(!info)
return;
if(user->GetTypeId()!=TYPEID_PLAYER)
return;
Player* player = (Player*)user;
if(info->camera.cinematicId)
{
WorldPacket data(SMSG_TRIGGER_CINEMATIC, 4);
data << info->camera.cinematicId;
player->GetSession()->SendPacket(&data);
}
return;
}
//fishing bobber
case GAMEOBJECT_TYPE_FISHINGNODE: //17
{
if(user->GetTypeId()!=TYPEID_PLAYER)
return;
Player* player = (Player*)user;
if(player->GetGUID() != GetOwnerGUID())
return;
switch(getLootState())
{
case GO_READY: // ready for loot
{
// 1) skill must be >= base_zone_skill
// 2) if skill == base_zone_skill => 5% chance
// 3) chance is linear dependence from (base_zone_skill-skill)
uint32 subzone = GetAreaId();
int32 zone_skill = objmgr.GetFishingBaseSkillLevel( subzone );
if(!zone_skill)
zone_skill = objmgr.GetFishingBaseSkillLevel( GetZoneId() );
//provide error, no fishable zone or area should be 0
if(!zone_skill)
sLog.outErrorDb("Fishable areaId %u are not properly defined in `skill_fishing_base_level`.",subzone);
int32 skill = player->GetSkillValue(SKILL_FISHING);
int32 chance = skill - zone_skill + 5;
int32 roll = irand(1,100);
DEBUG_LOG("Fishing check (skill: %i zone min skill: %i chance %i roll: %i",skill,zone_skill,chance,roll);
if(skill >= zone_skill && chance >= roll)
{
// prevent removing GO at spell cancel
player->RemoveGameObject(this,false);
SetOwnerGUID(player->GetGUID());
开发者ID:yunishaa,项目名称:mangos-112,代码行数:66,代码来源:GameObject.cpp
示例4: GetGUIDLow
void Item::SaveToDB()
{
uint32 guid = GetGUIDLow();
switch (uState)
{
case ITEM_NEW:
{
std::string text = m_text;
CharacterDatabase.escape_string(text);
CharacterDatabase.PExecute( "DELETE FROM item_instance WHERE guid = '%u'", guid );
std::ostringstream ss;
ss << "INSERT INTO item_instance (guid,owner_guid,data,text) VALUES (" << guid << "," << GUID_LOPART(GetOwnerGUID()) << ",'";
for(uint16 i = 0; i < m_valuesCount; ++i )
ss << GetUInt32Value(i) << " ";
ss << "', '" << text << "')";
CharacterDatabase.Execute( ss.str().c_str() );
} break;
case ITEM_CHANGED:
{
std::string text = m_text;
CharacterDatabase.escape_string(text);
std::ostringstream ss;
ss << "UPDATE item_instance SET data = '";
for(uint16 i = 0; i < m_valuesCount; ++i )
ss << GetUInt32Value(i) << " ";
ss << "', owner_guid = '" << GUID_LOPART(GetOwnerGUID());
ss << "', text = '" << text << "' WHERE guid = '" << guid << "'";
CharacterDatabase.Execute( ss.str().c_str() );
if (HasFlag(ITEM_FIELD_FLAGS, ITEM_DYNFLAG_WRAPPED))
CharacterDatabase.PExecute("UPDATE character_gifts SET guid = '%u' WHERE item_guid = '%u'", GUID_LOPART(GetOwnerGUID()),GetGUIDLow());
} break;
case ITEM_REMOVED:
{
CharacterDatabase.PExecute("DELETE FROM item_instance WHERE guid = '%u'", guid);
if (HasFlag(ITEM_FIELD_FLAGS, ITEM_DYNFLAG_WRAPPED))
CharacterDatabase.PExecute("DELETE FROM character_gifts WHERE item_guid = '%u'", GetGUIDLow());
if (HasSavedLoot())
CharacterDatabase.PExecute("DELETE FROM item_loot WHERE guid = '%u'", GetGUIDLow());
delete this;
return;
}
case ITEM_UNCHANGED:
return;
}
if (m_lootState == ITEM_LOOT_CHANGED || m_lootState == ITEM_LOOT_REMOVED)
CharacterDatabase.PExecute("DELETE FROM item_loot WHERE guid = '%u'", GetGUIDLow());
if (m_lootState == ITEM_LOOT_NEW || m_lootState == ITEM_LOOT_CHANGED)
{
if(Player* owner = GetOwner())
{
// save money as 0 itemid data
if (loot.gold)
CharacterDatabase.PExecute("INSERT INTO item_loot (guid,owner_guid,itemid,amount,suffix,property) "
"VALUES (%u, %u, 0, %u, 0, 0)",
GetGUIDLow(), owner->GetGUIDLow(), loot.gold);
// save items and quest items (at load its all will added as normal, but this not important for item loot case)
for (size_t i = 0; i < loot.GetMaxSlotInLootFor(owner); ++i)
{
QuestItem *qitem = NULL;
LootItem *item = loot.LootItemInSlot(i,owner,&qitem);
if(!item)
continue;
// questitems use the blocked field for other purposes
if (!qitem && item->is_blocked)
continue;
CharacterDatabase.PExecute("INSERT INTO item_loot (guid,owner_guid,itemid,amount,suffix,property) "
"VALUES (%u, %u, %u, %u, %u, %i)",
GetGUIDLow(), owner->GetGUIDLow(), item->itemid, item->count, item->randomSuffix, item->randomPropertyId);
}
}
}
if (m_lootState != ITEM_LOOT_NONE && m_lootState != ITEM_LOOT_TEMPORARY)
SetLootState(ITEM_LOOT_UNCHANGED);
SetState(ITEM_UNCHANGED);
}
开发者ID:Choices,项目名称:mangos,代码行数:88,代码来源:Item.cpp
示例5: MAKE_NEW_GUID
bool Item::LoadFromDB(uint32 guid, uint64 owner_guid, QueryResult *result)
{
// create item before any checks for store correct guid
// and allow use "FSetState(ITEM_REMOVED); SaveToDB();" for deleting item from DB
Object::_Create(guid, 0, HIGHGUID_ITEM);
bool delete_result = false;
if(!result)
{
result = CharacterDatabase.PQuery("SELECT data FROM item_instance WHERE guid = '%u'", guid);
delete_result = true;
}
if (!result)
{
sLog.outError("Item (GUID: %u owner: %u) not found in table `item_instance`, can't load. ",guid,GUID_LOPART(owner_guid));
return false;
}
Field *fields = result->Fetch();
if(!LoadValues(fields[0].GetString()))
{
sLog.outError("Item #%d have broken data in `data` field. Can't be loaded.",guid);
if (delete_result) delete result;
return false;
}
bool need_save = false; // need explicit save data at load fixes
// overwrite possible wrong/corrupted guid
uint64 new_item_guid = MAKE_NEW_GUID(guid,0, HIGHGUID_ITEM);
if(GetUInt64Value(OBJECT_FIELD_GUID) != new_item_guid)
{
SetUInt64Value(OBJECT_FIELD_GUID, MAKE_NEW_GUID(guid,0, HIGHGUID_ITEM));
need_save = true;
}
if (delete_result) delete result;
ItemPrototype const* proto = GetProto();
if(!proto)
return false;
// update max durability (and durability) if need
if(proto->MaxDurability!= GetUInt32Value(ITEM_FIELD_MAXDURABILITY))
{
SetUInt32Value(ITEM_FIELD_MAXDURABILITY,proto->MaxDurability);
if(GetUInt32Value(ITEM_FIELD_DURABILITY) > proto->MaxDurability)
SetUInt32Value(ITEM_FIELD_DURABILITY,proto->MaxDurability);
need_save = true;
}
// recalculate suffix factor
if(GetItemRandomPropertyId() < 0)
{
if(UpdateItemSuffixFactor())
need_save = true;
}
// Remove bind flag for items vs NO_BIND set
if (IsSoulBound() && proto->Bonding == NO_BIND)
{
ApplyModFlag(ITEM_FIELD_FLAGS,ITEM_FLAGS_BINDED, false);
need_save = true;
}
// update duration if need, and remove if not need
if ((proto->Duration == 0) != (GetUInt32Value(ITEM_FIELD_DURATION) == 0))
{
SetUInt32Value(ITEM_FIELD_DURATION, proto->Duration);
need_save = true;
}
// set correct owner
if (owner_guid != 0 && GetOwnerGUID() != owner_guid)
{
SetOwnerGUID(owner_guid);
need_save = true;
}
if (need_save) // normal item changed state set not work at loading
{
std::ostringstream ss;
ss << "UPDATE item_instance SET data = '";
for(uint16 i = 0; i < m_valuesCount; ++i )
ss << GetUInt32Value(i) << " ";
ss << "', owner_guid = '" << GUID_LOPART(GetOwnerGUID()) << "' WHERE guid = '" << guid << "'";
CharacterDatabase.Execute( ss.str().c_str() );
}
return true;
}
开发者ID:Choices,项目名称:ChoicesCore,代码行数:95,代码来源:Item.cpp
示例6: GetGUIDLow
void Corpse::DeleteFromDB()
{
if(GetType() == CORPSE_BONES)
// only specific bones
CharacterDatabase.PExecute("DELETE FROM corpse WHERE guid = '%d'", GetGUIDLow());
else
// all corpses (not bones)
CharacterDatabase.PExecute("DELETE FROM corpse WHERE player = '%d' AND corpse_type <> '0'", GUID_LOPART(GetOwnerGUID()));
}
开发者ID:Lamron333,项目名称:mangos,代码行数:9,代码来源:Corpse.cpp
示例7: GetGiftCreatorGUID
void Item::SaveToDB(int8 containerslot, int8 slot, bool firstsave, QueryBuffer* buf)
{
if(GetOwner() && GetOwner()->IsSaveBlocked())
return;
if(!m_isDirty && !firstsave)
return;
uint64 GiftCreatorGUID = GetGiftCreatorGUID();
uint64 CreatorGUID = GetCreatorGUID();
std::stringstream ss;
ss << "DELETE FROM playeritems WHERE guid = " << GetLowGUID() << ";";
if(firstsave)
CharacterDatabase.WaitExecute(ss.str().c_str());
else
{
if(buf == NULL)
CharacterDatabase.Execute(ss.str().c_str());
else
buf->AddQueryNA(ss.str().c_str());
}
ss.rdbuf()->str("");
uint64 ownerGUID = GetOwnerGUID();
ss << "INSERT INTO playeritems VALUES(";
ss << (Arcemu::Util::GUID_LOPART(ownerGUID)) << ",";
ss << GetLowGUID() << ",";
ss << GetEntry() << ",";
ss << wrapped_item_id << ",";
ss << (Arcemu::Util::GUID_LOPART(GiftCreatorGUID)) << ",";
ss << (Arcemu::Util::GUID_LOPART(CreatorGUID)) << ",";
ss << GetStackCount() << ",";
ss << int32(GetChargesLeft()) << ",";
ss << uint32(m_uint32Values[ ITEM_FIELD_FLAGS ]) << ",";
ss << random_prop << ", " << random_suffix << ", ";
ss << 0 << ",";
ss << GetDurability() << ",";
ss << static_cast<int>(containerslot) << ",";
ss << static_cast<int>(slot) << ",'";
// Pack together enchantment fields
if(Enchantments.size() > 0)
{
EnchantmentMap::iterator itr = Enchantments.begin();
for(; itr != Enchantments.end(); ++itr)
{
if(itr->second.RemoveAtLogout)
continue;
uint32 elapsed_duration = uint32(UNIXTIME - itr->second.ApplyTime);
int32 remaining_duration = itr->second.Duration - elapsed_duration;
if(remaining_duration < 0)
remaining_duration = 0;
try
{
if(itr->second.Enchantment && (remaining_duration > 5 || itr->second.Duration == 0))
{
ss << itr->second.Enchantment->Id << ",";
ss << remaining_duration << ",";
ss << itr->second.Slot << ";";
}
}
catch (...)
{
printf("Caught fatal exception: Item.cpp < void Item::SaveToDB(...)\n");
}
}
}
ss << "','";
ss << ItemExpiresOn << "','";
////////////////////////////////////////////////// Refund stuff /////////////////////////////////
// Check if the owner is instantiated. When sending mail he/she obviously will not be :P
if(this->GetOwner() != NULL)
{
std::pair< time_t, uint32 > refundentry;
refundentry.first = 0;
refundentry.second = 0;
refundentry = this->GetOwner()->GetItemInterface()->LookupRefundable(this->GetGUID());
ss << uint32(refundentry.first) << "','";
ss << uint32(refundentry.second);
}
else
{
ss << uint32(0) << "','";
ss << uint32(0);
}
//.........这里部分代码省略.........
开发者ID:treetrees,项目名称:Edge-of-Chaos,代码行数:101,代码来源:Item.cpp
示例8: GUID_LOPART
void Bag::SaveToDB()
{
Item::SaveToDB();
if(GetSlot()!=NULL_SLOT) // equiped bag
{
sDatabase.PExecute("DELETE FROM `character_inventory` WHERE `guid` = '%u' AND `bag` = '%u'", GUID_LOPART(GetOwnerGUID()), GetSlot());
for (uint8 i = 0; i < GetProto()->ContainerSlots; i++)
{
if (m_bagslot[i])
{
sDatabase.PExecute("INSERT INTO `character_inventory` (`guid`,`bag`,`slot`,`item`,`item_template`) VALUES ('%u', '%u', '%u', '%u', '%u')", GUID_LOPART(GetOwnerGUID()), GetSlot(), i, m_bagslot[i]->GetGUIDLow(), m_bagslot[i]->GetEntry());
m_bagslot[i]->SaveToDB();
}
}
}
}
开发者ID:Artea,项目名称:mangos-svn,代码行数:17,代码来源:Bag.cpp
示例9: SetUInt64Value
bool Bag::LoadFromDB(uint32 guid, uint64 owner_guid, uint32 auctioncheck)
{
if(!Item::LoadFromDB(guid, owner_guid, auctioncheck))
return false;
// cleanup bag content related item value fields (its will be filled correctly from `character_inventory`)
for (uint32 i = 0; i < GetProto()->ContainerSlots; i++)
{
SetUInt64Value(CONTAINER_FIELD_SLOT_1 + (i*2), 0);
if (m_bagslot[i])
{
delete m_bagslot[i];
m_bagslot[i] = NULL;
}
}
if(GetSlot()!=NULL_SLOT) // equiped bag
{
QueryResult *result = sDatabase.PQuery("SELECT `slot`,`item`,`item_template` FROM `character_inventory` WHERE `guid` = '%u' AND `bag` = '%u'", GUID_LOPART(GetOwnerGUID()), GetSlot());
if (result)
{
do
{
Field *fields = result->Fetch();
uint8 slot = fields[0].GetUInt8();
uint32 item_guid = fields[1].GetUInt32();
uint32 item_id = fields[2].GetUInt32();
ItemPrototype const *proto = objmgr.GetItemPrototype(item_id);
if(!proto)
{
sLog.outError( "Bag::LoadFromDB: Player %d have unknown item (id: #%u) in bag #%u, skipped.", GUID_LOPART(GetOwnerGUID()), item_id, GetSlot());
continue;
}
Item *item = NewItemOrBag(proto);
item->SetSlot(NULL_SLOT);
if(!item->LoadFromDB(item_guid, owner_guid, 1))
continue;
StoreItem( slot, item, true );
} while (result->NextRow());
delete result;
}
}
return true;
}
开发者ID:Artea,项目名称:mangos-svn,代码行数:49,代码来源:Bag.cpp
示例10: GetGUIDLow
void Item::SaveToDB()
{
uint32 guid = GetGUIDLow();
switch (uState)
{
case ITEM_NEW:
{
static SqlStatementID deleteItem;
static SqlStatementID saveItem;
SqlStatement stmt = RealmDataDatabase.CreateStatement(deleteItem, "DELETE FROM item_instance WHERE guid = ?");
stmt.PExecute(guid);
stmt = RealmDataDatabase.CreateStatement(saveItem, "INSERT INTO item_instance (guid, owner_guid, data) VALUES (?, ?, ?)");
std::ostringstream ss;
for (uint16 i = 0; i < m_valuesCount; i++)
ss << GetUInt32Value(i) << " ";
stmt.PExecute(guid, GUID_LOPART(GetOwnerGUID()), ss.str().c_str());
}
break;
case ITEM_CHANGED:
{
static SqlStatementID updateItem;
static SqlStatementID updateGift;
SqlStatement stmt = RealmDataDatabase.CreateStatement(updateItem, "UPDATE item_instance SET data = ?, owner_guid = ? WHERE guid = ?");
std::ostringstream ss;
for (uint16 i = 0; i < m_valuesCount; i++)
ss << GetUInt32Value(i) << " ";
stmt.PExecute(ss.str().c_str(), GUID_LOPART(GetOwnerGUID()), guid);
if (HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_WRAPPED))
{
stmt = RealmDataDatabase.CreateStatement(updateGift, "UPDATE character_gifts SET guid = ? WHERE item_guid = ?");
stmt.PExecute(GUID_LOPART(GetOwnerGUID()), GetGUIDLow());
}
}
break;
case ITEM_REMOVED:
{
static SqlStatementID deleteItem;
static SqlStatementID deleteItemText;
static SqlStatementID deleteGift;
SqlStatement stmt = RealmDataDatabase.CreateStatement(deleteItem, "DELETE FROM item_instance WHERE guid = ?");
stmt.PExecute(guid);
if (GetUInt32Value(ITEM_FIELD_ITEM_TEXT_ID) > 0)
{
stmt = RealmDataDatabase.CreateStatement(deleteItemText, "DELETE FROM item_text WHERE id = ?");
stmt.PExecute(GetUInt32Value(ITEM_FIELD_ITEM_TEXT_ID));
}
if (HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_WRAPPED))
{
stmt = RealmDataDatabase.CreateStatement(deleteGift, "DELETE FROM character_gifts WHERE item_guid = ?");
stmt.PExecute(GetGUIDLow());
}
delete this;
return;
}
case ITEM_UNCHANGED:
break;
}
SetState(ITEM_UNCHANGED);
}
开发者ID:Dolmero,项目名称:L4G_Core,代码行数:71,代码来源:Item.cpp
示例11: SetLootState
void Item::LoadLootFromDB(Field *fields)
{
uint32 item_id = fields[1].GetUInt32();
uint32 item_amount = fields[2].GetUInt32();
uint32 item_suffix = fields[3].GetUInt32();
int32 item_propid = fields[4].GetInt32();
// money value special case
if (item_id == 0)
{
loot.gold = item_amount;
SetLootState(ITEM_LOOT_UNCHANGED);
return;
}
// normal item case
ItemPrototype const* proto = ObjectMgr::GetItemPrototype(item_id);
if(!proto)
{
CharacterDatabase.PExecute("DELETE FROM item_loot WHERE guid = '%u' AND itemid = '%u'", GetGUIDLow(), item_id);
sLog.outError("Item::LoadLootFromDB: %s has an unknown item (id: #%u) in item_loot, deleted.", ObjectGuid(GetOwnerGUID()).GetString().c_str(), item_id);
return;
}
loot.items.push_back(LootItem(item_id, item_amount, item_suffix, item_propid));
++loot.unlootedCount;
SetLootState(ITEM_LOOT_UNCHANGED);
}
开发者ID:Choices,项目名称:mangos,代码行数:30,代码来源:Item.cpp
示例12: ObjectGuid
bool Item::LoadFromDB(uint32 guidLow, uint64 owner_guid, Field *fields)
{
// create item before any checks for store correct guid
// and allow use "FSetState(ITEM_REMOVED); SaveToDB();" for deleting item from DB
Object::_Create(guidLow, 0, HIGHGUID_ITEM);
if (!LoadValues(fields[0].GetString()))
{
sLog.outError("Item #%d have broken data in `data` field. Can't be loaded.", guidLow);
return false;
}
bool need_save = false; // need explicit save data at load fixes
// overwrite possible wrong/corrupted guid
ObjectGuid new_item_guid = ObjectGuid(HIGHGUID_ITEM, guidLow);
if (GetGuidValue(OBJECT_FIELD_GUID) != new_item_guid)
{
SetGuidValue(OBJECT_FIELD_GUID, new_item_guid);
need_save = true;
}
ItemPrototype const* proto = GetProto();
if(!proto)
return false;
// update max durability (and durability) if need
if(proto->MaxDurability!= GetUInt32Value(ITEM_FIELD_MAXDURABILITY))
{
SetUInt32Value(ITEM_FIELD_MAXDURABILITY,proto->MaxDurability);
if(GetUInt32Value(ITEM_FIELD_DURABILITY) > proto->MaxDurability)
SetUInt32Value(ITEM_FIELD_DURABILITY,proto->MaxDurability);
need_save = true;
}
// recalculate suffix factor
if(GetItemRandomPropertyId() < 0)
{
if(UpdateItemSuffixFactor())
need_save = true;
}
// Remove bind flag for items vs NO_BIND set
if (IsSoulBound() && proto->Bonding == NO_BIND)
{
ApplyModFlag(ITEM_FIELD_FLAGS, ITEM_DYNFLAG_BINDED, false);
need_save = true;
}
// update duration if need, and remove if not need
if ((proto->Duration == 0) != (GetUInt32Value(ITEM_FIELD_DURATION) == 0))
{
SetUInt32Value(ITEM_FIELD_DURATION, proto->Duration);
need_save = true;
}
// set correct owner
if (owner_guid != 0 && GetOwnerGUID() != owner_guid)
{
SetOwnerGUID(owner_guid);
need_save = true;
}
// set correct wrapped state
if (HasFlag(ITEM_FIELD_FLAGS, ITEM_DYNFLAG_WRAPPED))
{
// wrapped item must be wrapper (used version that not stackable)
if (!(proto->Flags & ITEM_FLAG_WRAPPER) || GetMaxStackCount() > 1)
{
RemoveFlag(ITEM_FIELD_FLAGS, ITEM_DYNFLAG_WRAPPED);
need_save = true;
// also cleanup for sure gift table
CharacterDatabase.PExecute("DELETE FROM character_gifts WHERE item_guid = '%u'", GetGUIDLow());
}
}
if (need_save) // normal item changed state set not work at loading
{
std::ostringstream ss;
ss << "UPDATE item_instance SET data = '";
for(uint16 i = 0; i < m_valuesCount; ++i )
ss << GetUInt32Value(i) << " ";
ss << "', owner_guid = '" << GUID_LOPART(GetOwnerGUID()) << "' WHERE guid = '" << guidLow << "'";
CharacterDatabase.Execute( ss.str().c_str() );
}
return true;
}
开发者ID:Choices,项目名称:mangos,代码行数:91,代码来源:Item.cpp
示例13: GetOwner
Player* Item::GetOwner()const
{
return ObjectAccessor::FindPlayer(GetOwnerGUID());
}
开发者ID:Devilcleave,项目名称:TrilliumEMU,代码行数:4,代码来源:Item.cpp
示例14: time_t
bool Corpse::LoadFromDB(uint32 lowguid, Field *fields)
{
//// 0 1 2 3 4 5 6
//QueryResult *result = CharacterDatabase.Query("SELECT corpse.guid, player, corpse.position_x, corpse.position_y, corpse.position_z, corpse.orientation, corpse.map,"
//// 7 8 9 10 11 12 13 14 15 16 17 18
// "time, corpse_type, instance, phaseMask, gender, race, class, playerBytes, playerBytes2, equipmentCache, guildId, playerFlags FROM corpse"
uint32 playerLowGuid= fields[1].GetUInt32();
float positionX = fields[2].GetFloat();
float positionY = fields[3].GetFloat();
float positionZ = fields[4].GetFloat();
float orientation = fields[5].GetFloat();
uint32 mapid = fields[6].GetUInt32();
Object::_Create(lowguid, 0, HIGHGUID_CORPSE);
m_time = time_t(fields[7].GetUInt64());
m_type = CorpseType(fields[8].GetUInt32());
if(m_type >= MAX_CORPSE_TYPE)
{
sLog.outError("Corpse (guidlow %d, owner %d) have wrong corpse type, not load.",GetGUIDLow(),GUID_LOPART(GetOwnerGUID()));
return false;
}
uint32 instanceid = fields[9].GetUInt32();
uint32 phaseMask = fields[10].GetUInt32();
uint8 gender = fields[11].GetUInt8();
uint8 race = fields[12].GetUInt8();
uint8 _class = fields[13].GetUInt8();
uint32 playerBytes = fields[14].GetUInt32();
uint32 playerBytes2 = fields[15].GetUInt32();
uint32 guildId = fields[17].GetUInt32();
uint32 playerFlags = fields[18].GetUInt32();
ObjectGuid guid = ObjectGuid(HIGHGUID_CORPSE, lowguid);
ObjectGuid playerGuid = ObjectGuid(HIGHGUID_PLAYER, playerLowGuid);
// overwrite possible wrong/corrupted guid
SetGuidValue(OBJECT_FIELD_GUID, guid);
SetGuidValue(CORPSE_FIELD_OWNER, playerGuid);
SetObjectScale(DEFAULT_OBJECT_SCALE);
PlayerInfo const *info = sObjectMgr.GetPlayerInfo(race, _class);
if(!info)
{
sLog.outError("Player %u has incorrect race/class pair.", GetGUIDLow());
return false;
}
SetUInt32Value(CORPSE_FIELD_DISPLAY_ID, gender == GENDER_FEMALE ? info->displayId_f : info->displayId_m);
// Load equipment
Tokens data = StrSplit(fields[16].GetCppString(), " ");
for (uint8 slot = 0; slot < EQUIPMENT_SLOT_END; slot++)
{
uint32 visualbase = slot * 2;
uint32 item_id = GetUInt32ValueFromArray(data, visualbase);
const ItemPrototype * proto = ObjectMgr::GetItemPrototype(item_id);
if(!proto)
{
SetUInt32Value(CORPSE_FIELD_ITEM + slot, 0);
continue;
}
SetUInt32Value(CORPSE_FIELD_ITEM + slot, proto->DisplayInfoID | (proto->InventoryType << 24));
}
uint8 skin = (uint8)(playerBytes);
uint8 face = (uint8)(playerBytes >> 8);
uint8 hairstyle = (uint8)(playerBytes >> 16);
uint8 haircolor = (uint8)(playerBytes >> 24);
uint8 facialhair = (uint8)(playerBytes2);
SetUInt32Value( CORPSE_FIELD_BYTES_1, ((0x00) | (race << 8) | (gender << 16) | (skin << 24)) );
SetUInt32Value( CORPSE_FIELD_BYTES_2, ((face) | (hairstyle << 8) | (haircolor << 16) | (facialhair << 24)) );
SetUInt32Value(CORPSE_FIELD_GUILD, guildId);
uint32 flags = CORPSE_FLAG_UNK2;
if(playerFlags & PLAYER_FLAGS_HIDE_HELM)
flags |= CORPSE_FLAG_HIDE_HELM;
if(playerFlags & PLAYER_FLAGS_HIDE_CLOAK)
flags |= CORPSE_FLAG_HIDE_CLOAK;
SetUInt32Value( CORPSE_FIELD_FLAGS, flags );
// no need to mark corpse as lootable, because corpses are not saved in battle grounds
// place
SetLocationInstanceId(instanceid);
SetLocationMapId(mapid);
SetPhaseMask(phaseMask, false);
Relocate(positionX, positionY, positionZ, orientation);
if(!IsPositionValid())
{
sLog.outError("Corpse (guidlow %d, owner %d) not created. Suggested coordinates isn't valid (X: %f Y: %f)",
GetGUIDLow(), GUID_LOPART(GetOwnerGUID()), GetPositionX(), GetPositionY());
return false;
}
m_grid = MaNGOS::ComputeGridPair(GetPositionX(), GetPositionY());
//.........这里部分代码省略.........
开发者ID:klaas-netherstorm,项目名称:Mangos,代码行数:101,代码来源:Corpse.cpp
示例15: DeleteFromDB
void Corpse::DeleteFromDB(SQLTransaction& trans)
{
DeleteFromDB(GetOwnerGUID(), trans);
}
开发者ID:Keader,项目名称:TrinityCore,代码行数:4,代码来源:Corpse.cpp
示例16: GetOwner
Player* Item::GetOwner()const
{
return sObjectMgr.GetPlayer(GetOwnerGUID());
}
开发者ID:Choices,项目名称:ChoicesCore,代码行数:4,代码来源:Item.cpp
示例17: switch
void GameObject::Update(uint32 p_time)
{
if (GUID_HIPART(GetGUID()) == HIGHGUID_TRANSPORT)
{
//((Transport*)this)->Update(p_time);
return;
}
switch (m_lootState)
{
case GO_NOT_READY:
if (GetGoType()==GAMEOBJECT_TYPE_FISHINGNODE)
{
// fishing code (bobber ready)
if( time(NULL) > m_respawnTime - FISHING_BOBBER_READY_TIME )
{
// splash bobber (bobber ready now)
Unit* caster = GetOwner();
if(caster && caster->GetTypeId()==TYPEID_PLAYER)
{
SetUInt32Value(GAMEOBJECT_STATE, 0);
SetUInt32Value(GAMEOBJECT_FLAGS, 32);
UpdateData udata;
WorldPacket packet;
BuildValuesUpdateBlockForPlayer(&udata,((Player*)caster));
udata.BuildPacket(&packet);
((Player*)caster)->GetSession()->SendPacket(&packet);
WorldPacket data(SMSG_GAMEOBJECT_CUSTOM_ANIM,8+4);
data << GetGUID();
data << (uint32)(0);
((Player*)caster)->SendMessageToSet(&data,true);
}
m_lootState = GO_CLOSED; // can be succesfully open with some chance
}
return;
}
m_lootState = GO_CLOSED; // for not bobber is same as GO_CLOSED
// NO BREAK
case GO_CLOSED:
if (m_respawnTime > 0)
// timer on
{
if (m_respawnTime <= time(NULL)) // timer expired
{
m_respawnTime = 0;
m_SkillupList.clear();
m_usetimes = 0;
switch (GetGoType())
{
case GAMEOBJECT_TYPE_FISHINGNODE: // can't fish now
{
Unit* caster = GetOwner();
if(caster && caster->GetTypeId()==TYPEID_PLAYER)
{
if(caster->m_currentSpells[CURRENT_CHANNELED_SPELL])
{
caster->m_currentSpells[CURRENT_CHANNELED_SPELL]->SendChannelUpdate(0);
caster->m_currentSpells[CURRENT_CHANNELED_SPELL]->finish(false);
}
WorldPacket data(SMSG_FISH_NOT_HOOKED,0);
((Player*)caster)->GetSession()->SendPacket(&data);
}
m_lootState = GO_LOOTED; // can be delete
return;
}
case GAMEOBJECT_TYPE_DOOR:
case GAMEOBJECT_TYPE_BUTTON:
SetUInt32Value (GAMEOBJECT_FLAGS, m_flags);
SetUInt32Value (GAMEOBJECT_STATE, 1);
break;
case GAMEOBJECT_TYPE_TRAP:
break;
default:
if(!m_spawnedByDefault) // despawn timer
{
if(GetOwnerGUID())
{
Delete();
return;
}
SetLootState(GO_LOOTED); // can be despawned
return;
}
// respawn timer
MapManager::Instance().GetMap(GetMapId(), this)->Add(this);
break;
}
}
}
break;
case GO_OPEN:
break;
//.........这里部分代码省略.........
开发者ID:Artea,项目名称:mangos-svn,代码行数:101,代码来源:GameObject.cpp
示例18: GetGUIDLow
void Item::SaveToDB(SQLTransaction& trans)
{
bool isInTransaction = !(trans.null());
if (!isInTransaction)
trans = CharacterDatabase.BeginTransaction();
uint32 guid = GetGUIDLow();
switch (uState)
{
case ITEM_NEW:
case ITEM_CHANGED:
{
uint8 index = 0;
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(uState == ITEM_NEW ? CHAR_REP_ITEM_INSTANCE : CHAR_UPD_ITEM_INSTANCE);
stmt->setUInt32( index, GetEntry());
stmt->setUInt32(++index, GUID_LOPART(GetOwnerGUID()));
stmt->setUInt32(++index, GUID_LOPART(GetUInt64Value(ITEM_FIELD_CREATOR)));
stmt->setUInt32(++index, GUID_LOPART(GetUInt64Value(ITEM_FIELD_GIFTCREATOR)));
stmt->setUInt32(++index, GetCount());
stmt->setUInt32(++index, GetUInt32Value(ITEM_FIELD_DURATION));
std::ostringstream ssSpells;
for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
ssSpells << GetSpellCharges(i) << ' ';
stmt->setString(++index, ssSpells.str());
stmt->setUInt32(++index, GetUInt32Value(ITEM_FIELD_FLAGS));
std::ostringstream ssEnchants;
for (uint8 i = 0; i < MAX_ENCHANTMENT_SLOT; ++i)
{
ssEnchants << GetEnchantmentId(EnchantmentSlot(i)) << ' ';
ssEnchants << GetEnchantmentDuration(EnchantmentSlot(i)) << ' ';
ssEnchants << GetEnchantmentCharges(EnchantmentSlot(i)) << ' ';
}
stmt->setString(++index, ssEnchants.str());
stmt->setInt16 (++index, GetItemRandomPropertyId());
stmt->setUInt16(++index, GetUInt32Value(ITEM_FIELD_DURABILITY));
stmt->setUInt32(++index, GetUInt32Value(ITEM_FIELD_CREATE_PLAYED_TIME));
stmt->setString(++index, m_text);
stmt->setUInt32(++index, guid);
trans->Append(stmt);
if ((uState == ITEM_CHANGED) && HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_WRAPPED))
{
stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GIFT_OWNER);
stmt->setUInt32(0, GUID_LOPART(GetOwnerGUID()));
stmt->setUInt32(1, guid);
trans->Append(stmt);
}
break;
}
case ITEM_REMOVED:
{
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_INSTANCE);
stmt->setUInt32(0, guid);
trans->Append(stmt);
if (HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_WRAPPED))
{
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GIFT);
stmt->setUInt32(0, guid);
trans->Append(stmt);
}
if (!isInTransaction)
CharacterDatabase.CommitTransaction(trans);
delete this;
return;
}
case ITEM_UNCHANGED:
break;
}
SetState(ITEM_UNCHANGED);
if (!isInTransaction)
CharacterDatabase.CommitTransaction(trans);
}
开发者ID:Aristoo,项目名称:TrinityCore,代码行数:82,代码来源:Item.cpp
示例19: CorpseType
bool Corpse::LoadFromDB (uint32 guid, Field *fields)
{
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
// SELECT posX, posY, posZ, orientation, mapId, displayId, itemCache, bytes1, bytes2, flags, dynFlags, time, corpseType, instanceId, phaseMask, corpseGuid, guid FROM corpse WHERE corpseType <> 0
uint32 ownerGuid = fields[16].GetUInt32();
m_type = CorpseType(fields[12].GetUInt8());
if (m_type >= MAX_CORPSE_TYPE)
{
sLog->outError("Corpse (guid: %u, owner: %u) have wrong corpse type (%u), not loading.", guid, ownerGuid, m_type);
return false;
}
if (m_type != CORPSE_BONES)
m_isWorldObject = true;
float posX = fields[0].GetFloat();
float posY = fields[1].GetFloat();
float posZ = fields[2].GetFloat();
float o = fields[3].GetFloat();
uint32 mapId = fields[4].GetUInt16();
Object::_Create(guid, 0, HIGHGUID_CORPSE);
SetUInt32Value(CORPSE_FIELD_DISPLAY_ID, fields[5].GetUInt32());
_LoadIntoDataField(fields[6].GetCString(), CORPSE_FIELD_ITEM, EQUIPMENT_SLOT_END);
SetUInt32Value(CORPSE_FIELD_BYTES_1, fields[7].GetUInt32());
SetUInt32Value(CORPSE_FIELD_BYTES_2, fields[8].GetUInt32());
SetUInt32Value(CORPSE_FIELD_FLAGS, fields[9].GetUInt8());
SetUInt32Value(CORPSE_FIELD_DYNAMIC_FLAGS, fields[10].GetUInt8());
SetUInt64Value(CORPSE_FIELD_OWNER, MAKE_NEW_GUID(ownerGuid, 0, HIGHGUID_PLAYER));
m_time = time_t(fields[11].GetUInt32());
uint32 instanceId = fields[13].GetUInt32();
uint32 phaseMask = fields[14].GetUInt16();
// place
SetLocationInstanceId(instanceId);
SetLocationMapId(mapId);
SetPhaseMask(phaseMask, false);
Relocate(posX, posY, posZ, o);
if (!IsPositionValid())
{
sLog->outError("Corpse (guid: %u, owner: %u) is not created, given coordinates are not valid (X: %f, Y: %f, Z: %f)", GetGUIDLow(), GUID_LOPART(GetOwnerGUID()), posX, posY, posZ);
return false;
}
m_grid = Trinity::ComputeGridPair(GetPositionX(), GetPositionY());
return true;
}
开发者ID:55887MX,项目名称:CCORE,代码行数:50,代码来源:Corpse.cpp
注:本文中的GetOwnerGUID函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛 |
请发表评论