本文整理汇总了C++中hasBitSet函数的典型用法代码示例。如果您正苦于以下问题:C++ hasBitSet函数的具体用法?C++ hasBitSet怎么用?C++ hasBitSet使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了hasBitSet函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: getIcon
IconType Condition::getIcon() const
{
IconType icons = ICON_NONE;
for(IconType::iterator i = ICON_POISON; i != IconType::end(); ++i){
if(hasBitSet((*i).value(), flags)){
icons |= *i;
}
}
switch(combatType.value()){
case enums::COMBAT_ENERGYDAMAGE: icons |= ICON_ENERGY; break;
case enums::COMBAT_EARTHDAMAGE: icons |= ICON_POISON; break;
case enums::COMBAT_FIREDAMAGE: icons |= ICON_BURN; break;
case enums::COMBAT_DROWNDAMAGE: icons |= ICON_DROWNING; break;
case enums::COMBAT_ICEDAMAGE: icons |= ICON_FREEZING; break;
case enums::COMBAT_HOLYDAMAGE: icons |= ICON_DAZZLED; break;
case enums::COMBAT_DEATHDAMAGE: icons |= ICON_CURSED; break;
default:
break;
}
return icons;
}
示例2: __queryAdd
ReturnValue Depot::__queryAdd(int32_t index, const Thing* thing, uint32_t count,
uint32_t flags) const
{
const Item* item = thing->getItem();
if(item == NULL){
return RET_NOTPOSSIBLE;
}
if(!hasBitSet(FLAG_IGNORECAPACITY, flags)){
int addCount = 0;
if((item->isStackable() && item->getItemCount() != count)){
addCount = 1;
}
if(item->getTopParent() != this){
if(const Container* container = item->getContainer()){
addCount = container->getItemHoldingCount() + 1;
}
else{
addCount = 1;
}
}
if(getItemHoldingCount() + addCount > maxDepotLimit){
return RET_DEPOTISFULL;
}
}
return Container::__queryAdd(index, thing, count, flags);
}
示例3: hasBitSet
ReturnValue DepotChest::queryAdd(int32_t index, const Thing& thing, uint32_t count,
uint32_t flags, Creature* actor/* = nullptr*/) const
{
const Item* item = thing.getItem();
if (item == nullptr) {
return RETURNVALUE_NOTPOSSIBLE;
}
bool skipLimit = hasBitSet(FLAG_NOLIMIT, flags);
if (!skipLimit) {
int32_t addCount = 0;
if ((item->isStackable() && item->getItemCount() != count)) {
addCount = 1;
}
if (item->getTopParent() != this) {
if (const Container* container = item->getContainer()) {
addCount = container->getItemHoldingCount() + 1;
} else {
addCount = 1;
}
}
if (getItemHoldingCount() + addCount > maxDepotItems) {
return RETURNVALUE_DEPOTISFULL;
}
}
return Container::queryAdd(index, thing, count, flags, actor);
}
示例4: __queryMaxCount
ReturnValue Container::__queryMaxCount(int32_t index, const Thing* thing, uint32_t count,
uint32_t& maxQueryCount, uint32_t flags) const
{
const Item* item = thing->getItem();
if(item == NULL)
{
maxQueryCount = 0;
return RET_NOTPOSSIBLE;
}
if(hasBitSet(FLAG_NOLIMIT, flags))
{
maxQueryCount = std::max<uint32_t>(1, count);
return RET_NOERROR;
}
int32_t freeSlots = std::max<int32_t>(capacity() - size(), 0);
if(item->isStackable())
{
uint32_t n = 0;
if(index == INDEX_WHEREEVER)
{
//Iterate through every item and check how much free stackable slots there is.
uint32_t slotIndex = 0;
for(ItemDeque::const_iterator cit = itemlist.begin(); cit != itemlist.end(); ++cit, ++slotIndex)
{
if((*cit) != item && (*cit)->getID() == item->getID() && (*cit)->getItemCount() < 100)
{
uint32_t remainder = (100 - (*cit)->getItemCount());
if(__queryAdd(slotIndex, item, remainder, flags) == RET_NOERROR)
n += remainder;
}
}
}
else
{
const Item* destItem = getItem(index);
if(destItem && destItem->getID() == item->getID() && destItem->getItemCount() < 100)
{
uint32_t remainder = 100 - destItem->getItemCount();
if(__queryAdd(index, item, remainder, flags) == RET_NOERROR)
n = remainder;
}
}
maxQueryCount = freeSlots * 100 + n;
if(maxQueryCount < count)
return RET_CONTAINERNOTENOUGHROOM;
}
else
{
maxQueryCount = freeSlots;
if(maxQueryCount == 0)
return RET_CONTAINERNOTENOUGHROOM;
}
return RET_NOERROR;
}
示例5: hasBitSet
ReturnValue Inbox::__queryAdd(int32_t index, const Thing* thing, uint32_t count,
uint32_t flags, Creature* actor/* = NULL*/) const
{
bool skipLimit = hasBitSet(FLAG_NOLIMIT, flags);
if(!skipLimit)
return RET_CONTAINERNOTENOUGHROOM;
return Container::__queryAdd(index, thing, count, flags, actor);
}
示例6: hasBitSet
ReturnValue Container::__queryAdd(int32_t index, const Thing* thing, uint32_t count,
uint32_t flags, Creature* actor/* = NULL*/) const
{
bool childIsOwner = hasBitSet(FLAG_CHILDISOWNER, flags);
if(childIsOwner)
{
//a child container is querying, since we are the top container (not carried by a player)
//just return with no error.
return RET_NOERROR;
}
const Item* item = thing->getItem();
if(!item)
return RET_NOTPOSSIBLE;
if(!item->isPickupable())
return RET_CANNOTPICKUP;
if(item == this)
return RET_THISISIMPOSSIBLE;
bool isInbox = false;
if(const Container* container = item->getContainer())
{
for(const Cylinder* cylinder = getParent(); cylinder; cylinder = cylinder->getParent())
{
if(cylinder == container)
return RET_THISISIMPOSSIBLE;
if(!hasBitSet(FLAG_NOLIMIT, flags) && !isInbox && dynamic_cast<const Inbox*>(cylinder))
isInbox = true;
}
}
if(isInbox || (index == INDEX_WHEREEVER && size() >= capacity() && !hasBitSet(FLAG_NOLIMIT, flags)))
return RET_CONTAINERNOTENOUGHROOM;
const Cylinder* topParent = getTopParent();
if(topParent != this)
return topParent->__queryAdd(INDEX_WHEREEVER, item, count, flags | FLAG_CHILDISOWNER, actor);
return RET_NOERROR;
}
示例7: __getIndexOfThing
ReturnValue Tile::__queryRemove(const Thing* thing, uint32_t count, uint32_t flags) const
{
int32_t index = __getIndexOfThing(thing);
if(index == -1)
return RET_NOTPOSSIBLE;
const Item* item = thing->getItem();
if(!item || !count || (item->isStackable() && count > item->getItemCount())
|| (item->isNotMoveable() && !hasBitSet(FLAG_IGNORENOTMOVEABLE, flags)))
return RET_NOTPOSSIBLE;
return RET_NOERROR;
}
示例8: queryMaxCount
ReturnValue Container::queryMaxCount(int32_t index, const Thing& thing, uint32_t count,
uint32_t& maxQueryCount, uint32_t flags) const
{
const Item* item = thing.getItem();
if (item == nullptr) {
maxQueryCount = 0;
return RETURNVALUE_NOTPOSSIBLE;
}
if (hasBitSet(FLAG_NOLIMIT, flags)) {
maxQueryCount = std::max<uint32_t>(1, count);
return RETURNVALUE_NOERROR;
}
int32_t freeSlots = std::max<int32_t>(capacity() - size(), 0);
if (item->isStackable()) {
uint32_t n = 0;
if (index == INDEX_WHEREEVER) {
//Iterate through every item and check how much free stackable slots there is.
uint32_t slotIndex = 0;
for (Item* containerItem : itemlist) {
if (containerItem != item && containerItem->equals(item) && containerItem->getItemCount() < 100) {
uint32_t remainder = (100 - containerItem->getItemCount());
if (queryAdd(slotIndex++, *item, remainder, flags) == RETURNVALUE_NOERROR) {
n += remainder;
}
}
}
} else {
const Item* destItem = getItemByIndex(index);
if (item->equals(destItem) && destItem->getItemCount() < 100) {
uint32_t remainder = 100 - destItem->getItemCount();
if (queryAdd(index, *item, remainder, flags) == RETURNVALUE_NOERROR) {
n = remainder;
}
}
}
maxQueryCount = freeSlots * 100 + n;
if (maxQueryCount < count) {
return RETURNVALUE_CONTAINERNOTENOUGHROOM;
}
} else {
maxQueryCount = freeSlots;
if (maxQueryCount == 0) {
return RETURNVALUE_CONTAINERNOTENOUGHROOM;
}
}
return RETURNVALUE_NOERROR;
}
示例9: __getIndexOfThing
ReturnValue Container::__queryRemove(const Thing* thing, uint32_t count, uint32_t flags, Creature*) const
{
int32_t index = __getIndexOfThing(thing);
if(index == -1)
return RET_NOTPOSSIBLE;
const Item* item = thing->getItem();
if(item == NULL)
return RET_NOTPOSSIBLE;
if(count == 0 || (item->isStackable() && count > item->getItemCount()))
return RET_NOTPOSSIBLE;
if(!item->isMovable() && !hasBitSet(FLAG_IGNORENOTMOVABLE, flags))
return RET_NOTMOVABLE;
return RET_NOERROR;
}
示例10: getThingIndex
ReturnValue Container::queryRemove(const Thing& thing, uint32_t count, uint32_t flags) const
{
int32_t index = getThingIndex(&thing);
if (index == -1) {
return RETURNVALUE_NOTPOSSIBLE;
}
const Item* item = thing.getItem();
if (item == nullptr) {
return RETURNVALUE_NOTPOSSIBLE;
}
if (count == 0 || (item->isStackable() && count > item->getItemCount())) {
return RETURNVALUE_NOTPOSSIBLE;
}
if (!item->isMoveable() && !hasBitSet(FLAG_IGNORENOTMOVEABLE, flags)) {
return RETURNVALUE_NOTMOVEABLE;
}
return RETURNVALUE_NOERROR;
}
示例11: __getIndexOfThing
ReturnValue Container::__queryRemove(const Thing* thing, uint32_t count, uint32_t flags) const
{
int32_t index = __getIndexOfThing(thing);
if (index == -1) {
return RET_NOTPOSSIBLE;
}
const Item* item = thing->getItem();
if (item == nullptr) {
return RET_NOTPOSSIBLE;
}
if (count == 0 || (item->isStackable() && count > item->getItemCount())) {
return RET_NOTPOSSIBLE;
}
if (item->isNotMoveable() && !hasBitSet(FLAG_IGNORENOTMOVEABLE, flags)) {
return RET_NOTMOVEABLE;
}
return RET_NOERROR;
}
示例12: __queryAdd
ReturnValue Inbox::__queryAdd(int32_t index, const Thing* thing, uint32_t count,
uint32_t flags, Creature* actor/* = nullptr*/) const
{
if (!hasBitSet(FLAG_NOLIMIT, flags)) {
return RET_CONTAINERNOTENOUGHROOM;
}
const Item* item = thing->getItem();
if (!item) {
return RET_NOTPOSSIBLE;
}
if (item == this) {
return RET_THISISIMPOSSIBLE;
}
if (!item->isPickupable()) {
return RET_CANNOTPICKUP;
}
return RET_NOERROR;
}
示例13: queryAdd
ReturnValue Inbox::queryAdd(int32_t, const Thing& thing, uint32_t,
uint32_t flags, Creature*) const
{
if (!hasBitSet(FLAG_NOLIMIT, flags)) {
return RETURNVALUE_CONTAINERNOTENOUGHROOM;
}
const Item* item = thing.getItem();
if (!item) {
return RETURNVALUE_NOTPOSSIBLE;
}
if (item == this) {
return RETURNVALUE_THISISIMPOSSIBLE;
}
if (!item->isPickupable()) {
return RETURNVALUE_CANNOTPICKUP;
}
return RETURNVALUE_NOERROR;
}
示例14: getCreatureEvents
bool Creature::onKilledCreature(Creature* target, uint32_t& flags, DeathEntry& entry)
{
bool ret = true;
if(master)
ret = master->onKilledCreature(target, flags, entry);
CreatureEventList killEvents = getCreatureEvents(CREATURE_EVENT_KILL);
if(!hasBitSet((uint32_t)KILLFLAG_LASTHIT, flags))
{
for(CreatureEventList::iterator it = killEvents.begin(); it != killEvents.end(); ++it)
(*it)->executeKill(this, target, false);
return true;
}
for(CreatureEventList::iterator it = killEvents.begin(); it != killEvents.end(); ++it)
{
if(!(*it)->executeKill(this, target, true) && ret)
ret = false;
}
return ret;
}
示例15: hasBitSet
ReturnValue Container::queryAdd(int32_t index, const Thing& thing, uint32_t count,
uint32_t flags, Creature* actor/* = nullptr*/) const
{
bool childIsOwner = hasBitSet(FLAG_CHILDISOWNER, flags);
if (childIsOwner) {
//a child container is querying, since we are the top container (not carried by a player)
//just return with no error.
return RETURNVALUE_NOERROR;
}
if (!unlocked) {
return RETURNVALUE_NOTPOSSIBLE;
}
const Item* item = thing.getItem();
if (item == nullptr) {
return RETURNVALUE_NOTPOSSIBLE;
}
if (!item->isPickupable()) {
return RETURNVALUE_CANNOTPICKUP;
}
if (item == this) {
return RETURNVALUE_THISISIMPOSSIBLE;
}
const Cylinder* cylinder = getParent();
if (!hasBitSet(FLAG_NOLIMIT, flags)) {
while (cylinder) {
if (cylinder == &thing) {
return RETURNVALUE_THISISIMPOSSIBLE;
}
if (dynamic_cast<const Inbox*>(cylinder)) {
return RETURNVALUE_CONTAINERNOTENOUGHROOM;
}
cylinder = cylinder->getParent();
}
if (index == INDEX_WHEREEVER && size() >= capacity()) {
return RETURNVALUE_CONTAINERNOTENOUGHROOM;
}
} else {
while (cylinder) {
if (cylinder == &thing) {
return RETURNVALUE_THISISIMPOSSIBLE;
}
cylinder = cylinder->getParent();
}
}
const Cylinder* topParent = getTopParent();
if (topParent != this) {
return topParent->queryAdd(INDEX_WHEREEVER, *item, count, flags | FLAG_CHILDISOWNER, actor);
} else {
return RETURNVALUE_NOERROR;
}
}