From ad4bc9bd2156c7a74ba2c50bc2c4772b9bcb216f Mon Sep 17 00:00:00 2001 From: fgenesis Date: Sat, 15 Dec 2012 22:46:39 +0100 Subject: [PATCH] Revert "Changed a bunch of enums in Entity.h" This reverts commit 8b67ece9075a0135b8e2a63b976609ee6249b3b7. --- Aquaria/Entity.cpp | 15 +++-- Aquaria/Entity.h | 126 ++++++++++++++++++------------------ Aquaria/ScriptInterface.cpp | 4 +- 3 files changed, 73 insertions(+), 72 deletions(-) diff --git a/Aquaria/Entity.cpp b/Aquaria/Entity.cpp index c4d5d70..cf49e82 100644 --- a/Aquaria/Entity.cpp +++ b/Aquaria/Entity.cpp @@ -1614,12 +1614,15 @@ void Entity::moveOutOfWall() void Entity::clearDamageTargets() { - disabledDamageTypes.reset(); + disabledDamageTypes.clear(); } void Entity::setDamageTarget(DamageType dt, bool v) { - disabledDamageTypes.set(dt, !v); + if (v) + disabledDamageTypes.erase(dt); + else + disabledDamageTypes.insert(dt); } void Entity::setEatType(EatType et, const std::string &file) @@ -1640,17 +1643,17 @@ void Entity::setAllDamageTargets(bool v) else { for (int i = DT_ENEMY; i < DT_ENEMY_REALMAX; i++) - disabledDamageTypes.set(DamageType(i)); + disabledDamageTypes.insert(DamageType(i)); for (int i = DT_AVATAR; i < DT_AVATAR_REALMAX; i++) - disabledDamageTypes.set(DamageType(i)); + disabledDamageTypes.insert(DamageType(i)); for (int i = DT_AVATAR_MAX; i < DT_REALMAX; i++) - disabledDamageTypes.set(DamageType(i)); + disabledDamageTypes.insert(DamageType(i)); } } bool Entity::isDamageTarget(DamageType dt) { - return disabledDamageTypes.test(dt); + return disabledDamageTypes.find(dt) == disabledDamageTypes.end(); } float Entity::getHealthPerc() diff --git a/Aquaria/Entity.h b/Aquaria/Entity.h index 3786187..76f10b3 100644 --- a/Aquaria/Entity.h +++ b/Aquaria/Entity.h @@ -21,8 +21,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef ENTITY_H #define ENTITY_H -#include - #include "../BBGE/StateMachine.h" #include "../ExternalLibs/tinyxml.h" #include "../BBGE/SkeletalSprite.h" @@ -77,70 +75,70 @@ enum EV enum DamageType { - DT_NONE, - DT_ENEMY, - DT_ENEMY_ENERGYBLAST, - DT_ENEMY_SHOCK, - DT_ENEMY_BITE, - DT_ENEMY_TRAP, - DT_ENEMY_WEB, - DT_ENEMY_BEAM, - DT_ENEMY_GAS, - DT_ENEMY_INK, - DT_ENEMY_POISON, - DT_ENEMY_ACTIVEPOISON, - DT_ENEMY_CREATOR, - DT_ENEMY_MANTISBOMB, - DT_ENEMY_REALMAX, - DT_ENEMY_MAX, - - DT_AVATAR, - DT_AVATAR_ENERGYBLAST, - DT_AVATAR_SHOCK, - DT_AVATAR_BITE, - DT_AVATAR_VOMIT, - DT_AVATAR_ACID, - DT_AVATAR_SPORECHILD, - DT_AVATAR_LIZAP, - DT_AVATAR_NATURE, - DT_AVATAR_ENERGYROLL, - DT_AVATAR_VINE, - DT_AVATAR_EAT, - DT_AVATAR_EAT_BASICSHOT, - DT_AVATAR_EAT_MAX, - DT_AVATAR_LANCEATTACH, - DT_AVATAR_LANCE, - DT_AVATAR_CREATORSHOT, - DT_AVATAR_DUALFORMLI, - DT_AVATAR_DUALFORMNAIJA, - DT_AVATAR_BUBBLE, - DT_AVATAR_SEED, - DT_AVATAR_PET, - DT_AVATAR_PETNAUTILUS, - DT_AVATAR_PETBITE, - DT_AVATAR_REALMAX, - DT_AVATAR_MAX, - DT_TOUCH, - DT_CRUSH, - DT_SPIKES, - DT_STEAM, + DT_NONE = -1, + DT_ENEMY = 0, + DT_ENEMY_ENERGYBLAST = 1, + DT_ENEMY_SHOCK = 2, + DT_ENEMY_BITE = 3, + DT_ENEMY_TRAP = 4, + DT_ENEMY_WEB = 5, + DT_ENEMY_BEAM = 6, + DT_ENEMY_GAS = 7, + DT_ENEMY_INK = 8, + DT_ENEMY_POISON = 9, + DT_ENEMY_ACTIVEPOISON = 10, + DT_ENEMY_CREATOR = 11, + DT_ENEMY_MANTISBOMB = 12, + DT_ENEMY_REALMAX , + DT_ENEMY_MAX = 13, + + DT_AVATAR = 1000, + DT_AVATAR_ENERGYBLAST = 1001, + DT_AVATAR_SHOCK = 1002, + DT_AVATAR_BITE = 1003, + DT_AVATAR_VOMIT = 1004, + DT_AVATAR_ACID = 1005, + DT_AVATAR_SPORECHILD = 1006, + DT_AVATAR_LIZAP = 1007, + DT_AVATAR_NATURE = 1008, + DT_AVATAR_ENERGYROLL = 1009, + DT_AVATAR_VINE = 1010, + DT_AVATAR_EAT = 1011, + DT_AVATAR_EAT_BASICSHOT = 1011, + DT_AVATAR_EAT_MAX = 1012, + DT_AVATAR_LANCEATTACH = 1013, + DT_AVATAR_LANCE = 1014, + DT_AVATAR_CREATORSHOT = 1015, + DT_AVATAR_DUALFORMLI = 1016, + DT_AVATAR_DUALFORMNAIJA = 1017, + DT_AVATAR_BUBBLE = 1018, + DT_AVATAR_SEED = 1019, + DT_AVATAR_PET = 1020, + DT_AVATAR_PETNAUTILUS = 1021, + DT_AVATAR_PETBITE = 1022, + DT_AVATAR_REALMAX , + DT_AVATAR_MAX = 1030, + DT_TOUCH = 1031, + DT_CRUSH = 1032, + DT_SPIKES = 1033, + DT_STEAM = 1034, DT_REALMAX }; enum EatType { - EAT_NONE, - EAT_DEFAULT, - EAT_FILE, + EAT_NONE = -1, + EAT_DEFAULT = 0, + EAT_FILE = 1, EAT_MAX }; enum ObsCheck { - OBSCHECK_RANGE, - OBSCHECK_4DIR, - OBSCHECK_DOWN, - OBSCHECK_8DIR, + OBSCHECK_RANGE = 0, + OBSCHECK_4DIR = 1, + OBSCHECK_DOWN = 2, + OBSCHECK_8DIR = 3 }; class Shot; @@ -171,13 +169,13 @@ struct DamageData enum EntityType { - ET_NOTYPE, - ET_AVATAR, - ET_ENEMY, - ET_PET, - ET_FLOCK, - ET_NEUTRAL, - ET_INGREDIENT, + ET_NOTYPE =-1, + ET_AVATAR =0, + ET_ENEMY =1, + ET_PET =2, + ET_FLOCK =3, + ET_NEUTRAL =4, + ET_INGREDIENT =5 }; enum EntityProperty @@ -404,7 +402,7 @@ public: void setDamageTarget(DamageType dt, bool v); bool isDamageTarget(DamageType dt); - typedef std::bitset DisabledDamageTypes; + typedef std::set DisabledDamageTypes; int targetRange; int getTargetRange() { return targetRange; } diff --git a/Aquaria/ScriptInterface.cpp b/Aquaria/ScriptInterface.cpp index 705f76e..b11b028 100644 --- a/Aquaria/ScriptInterface.cpp +++ b/Aquaria/ScriptInterface.cpp @@ -6297,9 +6297,9 @@ luaFunc(entity_getNearestEntity) Entity *e = *i; if (e != me && e != ignore && e->isPresent() && e->isNormalLayer()) { - if (type == ET_NOTYPE || e->getEntityType() == type) + if (type == 0 || e->getEntityType() == type) { - if (damageTarget == DT_NONE || e->isDamageTarget((DamageType)damageTarget)) + if (damageTarget == 0 || e->isDamageTarget((DamageType)damageTarget)) { if (!name || ((nocasecmp(e->name, name)==0) == nameCheck)) {