本文整理汇总了C++中GetGUIDLow函数的典型用法代码示例。如果您正苦于以下问题:C++ GetGUIDLow函数的具体用法?C++ GetGUIDLow怎么用?C++ GetGUIDLow使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetGUIDLow函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
示例2: GetGUIDLow
void Item::SaveToDB(SQLTransaction& trans)
{
uint32 guid = GetGUIDLow();
switch (uState)
{
case ITEM_NEW:
case ITEM_CHANGED:
{
uint8 index = 0;
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(uState == ITEM_NEW ? CHAR_ADD_ITEM_INSTANCE : CHAR_UPDATE_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->setInt32 (++index, GetItemRandomPropertyId());
stmt->setUInt32(++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_UPDATE_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);
}
delete this;
return;
}
case ITEM_UNCHANGED:
break;
}
SetState(ITEM_UNCHANGED);
}
示例3: DeleteFromInventoryDB
void Item::DeleteFromInventoryDB()
{
CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE item = '%u'",GetGUIDLow());
}
示例4: ObjectGuid
bool Item::LoadFromDB(uint32 guidLow, Field* fields, ObjectGuid ownerGuid)
{
// 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;
}
// 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 (ownerGuid && GetOwnerGuid() != ownerGuid)
{
SetOwnerGuid(ownerGuid);
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;
static SqlStatementID delGifts ;
// also cleanup for sure gift table
SqlStatement stmt = CharacterDatabase.CreateStatement(delGifts, "DELETE FROM character_gifts WHERE item_guid = ?");
stmt.PExecute(GetGUIDLow());
}
}
if (need_save) // normal item changed state set not work at loading
{
static SqlStatementID updItem ;
SqlStatement stmt = CharacterDatabase.CreateStatement(updItem, "UPDATE item_instance SET data = ?, owner_guid = ? WHERE guid = ?");
std::ostringstream ss;
for (uint16 i = 0; i < m_valuesCount; ++i)
ss << GetUInt32Value(i) << " ";
stmt.addString(ss);
stmt.addUInt32(GetOwnerGuid().GetCounter());
stmt.addUInt32(guidLow);
stmt.Execute();
}
return true;
}
示例5: GetOwnerGUID
GameObject::~GameObject()
{
if(m_uint32Values) // field array can be not exist if GameOBject not loaded
{
// crash possable at access to deleted GO in Unit::m_gameobj
uint64 owner_guid = GetOwnerGUID();
if(owner_guid)
{
Unit* owner = ObjectAccessor::GetUnit(*this,owner_guid);
if(owner)
owner->RemoveGameObject(this,false);
else if(!IS_PLAYER_GUID(owner_guid))
sLog.outError("Delete GameObject (GUID: %u Entry: %u ) that have references in not found creature %u GO list. Crash possable later.",GetGUIDLow(),GetGOInfo()->id,GUID_LOPART(owner_guid));
}
}
}
示例6: 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
// "time, corpse_type, instance, 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("%s Owner %s have wrong corpse type (%i), not load.", GetGuidStr().c_str(), GetOwnerGuid().GetString().c_str(), m_type);
return false;
}
uint32 instanceid = fields[9].GetUInt32();
uint8 gender = fields[10].GetUInt8();
uint8 race = fields[11].GetUInt8();
uint8 _class = fields[12].GetUInt8();
uint32 playerBytes = fields[13].GetUInt32();
uint32 playerBytes2 = fields[14].GetUInt32();
uint32 guildId = fields[16].GetUInt32();
uint32 playerFlags = fields[17].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[15].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);
Relocate(positionX, positionY, positionZ, orientation);
if (!IsPositionValid())
{
sLog.outError("%s Owner %s not created. Suggested coordinates isn't valid (X: %f Y: %f)",
GetGuidStr().c_str(), GetOwnerGuid().GetString().c_str(), GetPositionX(), GetPositionY());
return false;
}
m_grid = MaNGOS::ComputeGridPair(GetPositionX(), GetPositionY());
return true;
//.........这里部分代码省略.........
示例7: switch
void GameObject::Update(uint32 /*p_time*/)
{
if (IS_MO_TRANSPORT(GetGUID()))
{
//((Transport*)this)->Update(p_time);
return;
}
switch (m_lootState)
{
case GO_NOT_READY:
{
switch(GetGoType())
{
case GAMEOBJECT_TYPE_TRAP:
{
// Arming Time for GAMEOBJECT_TYPE_TRAP (6)
Unit* owner = GetOwner();
if (owner && ((Player*)owner)->isInCombat())
m_cooldownTime = time(NULL) + GetGOInfo()->trap.startDelay;
m_lootState = GO_READY;
break;
}
case 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)
{
SetGoState(GO_STATE_ACTIVE);
SetUInt32Value(GAMEOBJECT_FLAGS, GO_FLAG_NODESPAWN);
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_READY; // can be successfully open with some chance
}
return;
}
default:
m_lootState = GO_READY; // for other GOis same switched without delay to GO_READY
break;
}
// NO BREAK for switch (m_lootState)
}
case GO_READY:
{
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)
{
caster->FinishSpell(CURRENT_CHANNELED_SPELL);
WorldPacket data(SMSG_FISH_NOT_HOOKED,0);
((Player*)caster)->GetSession()->SendPacket(&data);
}
// can be delete
m_lootState = GO_JUST_DEACTIVATED;
return;
}
case GAMEOBJECT_TYPE_DOOR:
case GAMEOBJECT_TYPE_BUTTON:
//we need to open doors if they are closed (add there another condition if this code breaks some usage, but it need to be here for battlegrounds)
if (GetGoState() != GO_STATE_READY)
ResetDoorOrButton();
//flags in AB are type_button and we need to add them here so no break!
default:
if (!m_spawnedByDefault) // despawn timer
{
// can be despawned or destroyed
SetLootState(GO_JUST_DEACTIVATED);
return;
}
// respawn timer
uint16 poolid = sPoolMgr.IsPartOfAPool(GetGUIDLow(), TYPEID_GAMEOBJECT);
if (poolid)
sPoolMgr.UpdatePool(poolid, GetGUIDLow(), TYPEID_GAMEOBJECT);
//.........这里部分代码省略.........
示例8: GetFakeEntry
uint32 Item::GetFakeEntry() // custom
{
ItemFakeEntryContainer::const_iterator itr = sObjectMgr->_itemFakeEntryStore.find(GetGUIDLow());
if (itr == sObjectMgr->_itemFakeEntryStore.end()) return NULL;
return itr->second;
}
示例9: DeleteFromInventoryDB
void Item::DeleteFromInventoryDB(SQLTransaction& trans, uint32 playerGuid)
{
DeleteFromInventoryDB(trans, GetGUIDLow(), playerGuid);
}
示例10: GetGUIDLow
void Item::DeleteRefundDataFromDB(SQLTransaction* trans)
{
if (trans && !trans->null())
(*trans)->PAppend("DELETE FROM item_refund_instance WHERE item_guid = '%u'", GetGUIDLow());
}
示例11: RemoveFakeDisplay
void Item::DeleteFromDB(SQLTransaction& trans)
{
RemoveFakeDisplay();
DeleteFromDB(trans, GetGUIDLow());
}
示例12: SetUInt64Value
bool Bag::LoadFromDB(uint32 guid, uint64 owner_guid)
{
if(!Item::LoadFromDB(guid, owner_guid))
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(!IsInBag()) // equiped bag
{
QueryResult *result = sDatabase.PQuery("SELECT `slot`,`item`,`item_template` FROM `character_inventory` WHERE `guid` = '%u' AND `bag` = '%u'", GUID_LOPART(GetOwnerGUID()), GetGUIDLow());
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))
{
delete item;
continue;
}
StoreItem( slot, item, true );
item->SetState(ITEM_UNCHANGED);
} while (result->NextRow());
delete result;
}
}
return true;
}
示例13: 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 << "," << GetOwnerGuid().GetCounter() << ",'";
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 = '" << GetOwnerGuid().GetCounter();
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'", GetOwnerGuid().GetCounter(), 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);
}
示例14: GetOwner
void Item::SetFakeEntry(uint32 entry) // custom
{
GetOwner()->UpdateUInt32Value(PLAYER_VISIBLE_ITEM_1_ENTRYID + (GetSlot() * 2), entry);
sObjectMgr->_itemFakeEntryStore[GetGUIDLow()] = entry;
CharacterDatabase.PExecute("REPLACE INTO custom_transmogrification (GUID, FakeEntry) VALUES (%u, %u)", GetGUIDLow(), entry);
}
示例15: ON
bool Creature::LoadFromDB(uint32 guid, QueryResult *result, uint32 InstanceId)
{
bool external = (result != NULL);
if (!external)
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
result = sDatabase.PQuery("SELECT `id`,`map`,`position_x`,`position_y`,`position_z`,`orientation`,`spawntimesecs`,`spawndist`,`spawn_position_x`,`spawn_position_y`,`spawn_position_z`,`curhealth`,`curmana`,`respawntime`,`DeathState`,`MovementType`,`auras` "
"FROM `creature` LEFT JOIN `creature_respawn` ON ((`creature`.`guid`=`creature_respawn`.`guid`) AND (`creature_respawn`.`instance` = '%u')) WHERE `creature`.`guid` = '%u'", InstanceId, guid);
if(!result)
{
sLog.outErrorDb("Creature (GUID: %u) not found in table `creature`, can't load. ",guid);
return false;
}
Field *fields = result->Fetch();
uint32 stored_guid = guid;
if (InstanceId != 0) guid = objmgr.GenerateLowGuid(HIGHGUID_UNIT);
SetInstanceId(InstanceId);
if(!Create(guid,fields[1].GetUInt32(),fields[2].GetFloat(),fields[3].GetFloat(),
fields[4].GetFloat(),fields[5].GetFloat(),fields[0].GetUInt32()))
{
if (!external) delete result;
return false;
}
m_DBTableGuid = stored_guid;
if(GetCreatureInfo()->rank > 0)
this->m_corpseDelay *= 3; //if creature is elite, then remove corpse later
SetHealth(fields[11].GetUInt32());
SetPower(POWER_MANA,fields[12].GetUInt32());
m_respawnradius = fields[7].GetFloat();
respawn_cord[0] = fields[8].GetFloat();
respawn_cord[1] = fields[9].GetFloat();
respawn_cord[2] = fields[10].GetFloat();
m_respawnDelay = fields[6].GetUInt32();
m_deathState = (DeathState)fields[14].GetUInt32();
if(m_deathState == JUST_DIED) // Dont must be set to JUST_DEAD, see Creature::setDeathState JUST_DIED -> CORPSE promoting.
{
sLog.outErrorDb("Creature (GUIDLow: %u Entry: %u ) in wrong state: JUST_DEAD (1). State set to ALIVE.",GetGUIDLow(),GetEntry());
m_deathState = ALIVE;
}
else
if(m_deathState < ALIVE || m_deathState > DEAD)
{
sLog.outErrorDb("Creature (GUIDLow: %u Entry: %u ) in wrong state: %d. State set to ALIVE.",GetGUIDLow(),GetEntry(),m_deathState);
m_deathState = ALIVE;
}
m_respawnTime = (time_t)fields[13].GetUInt64();
if(m_respawnTime > time(NULL)) // not ready to respawn
m_deathState = DEAD;
else // ready to respawn
{
m_respawnTime = 0;
sDatabase.PExecute("DELETE FROM `creature_respawn` WHERE `guid` = '%u' AND `instance` = '%u'", m_DBTableGuid, GetInstanceId());
}
{
uint32 mtg = fields[15].GetUInt32();
if(mtg < MAX_DB_MOTION_TYPE)
m_defaultMovementType = MovementGeneratorType(mtg);
else
{
m_defaultMovementType = IDLE_MOTION_TYPE;
sLog.outErrorDb("Creature (GUID: %u ID: %u) have wrong movement generator type value %u, ignore and set to IDLE.",guid,GetEntry(),mtg);
}
}
if(!external) delete result;
LoadFlagRelatedData();
AIM_Initialize();
return true;
}