summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/being/actor.h198
-rw-r--r--src/being/actorsprite.h335
-rw-r--r--src/being/compoundsprite.h145
-rw-r--r--src/being/playerrelations.cpp186
4 files changed, 433 insertions, 431 deletions
diff --git a/src/being/actor.h b/src/being/actor.h
index 6907ef9e5..2cec1f227 100644
--- a/src/being/actor.h
+++ b/src/being/actor.h
@@ -37,105 +37,105 @@ typedef Actors::const_iterator ActorsCIter;
class Actor notfinal
{
-public:
- A_DELETE_COPY(Actor)
-
- virtual ~Actor();
-
- /**
- * Draws the Actor to the given graphics context.
- *
- * Note: this function could be simplified if the graphics context
- * would support setting a translation offset. It already does this
- * partly with the clipping rectangle support.
- */
- virtual void draw(Graphics *const graphics,
- const int offsetX, const int offsetY) const = 0;
-
- /**
- * Returns the horizontal size of the actors graphical representation
- * in pixels or 0 when it is undefined.
- */
- virtual int getWidth() const A_WARN_UNUSED
- { return 0; }
-
- /**
- * Returns the vertical size of the actors graphical representation
- * in pixels or 0 when it is undefined.
- */
- virtual int getHeight() const A_WARN_UNUSED
- { return 0; }
-
- /**
- * Returns the pixel position of this actor.
- */
- const Vector &getPosition() const A_WARN_UNUSED
- { return mPos; }
-
- /**
- * Sets the pixel position of this actor.
- */
- virtual void setPosition(const Vector &pos)
- { mPos = pos; }
-
- /**
- * Returns the pixels X coordinate of the actor.
- */
- int getPixelX() const A_WARN_UNUSED
- { return static_cast<int>(mPos.x); }
-
- /**
- * Returns the pixel Y coordinate of the actor.
- */
- virtual int getPixelY() const A_WARN_UNUSED
- { return static_cast<int>(mPos.y); }
-
- /**
- * Returns the pixel Y coordinate of the actor for sorting only.
- */
- virtual int getSortPixelY() const A_WARN_UNUSED
- { return static_cast<int>(mPos.y) - mYDiff; }
-
- /**
- * Returns the x coordinate in tiles of the actor.
- */
- virtual int getTileX() const A_WARN_UNUSED;
-
- /**
- * Returns the y coordinate in tiles of the actor.
- */
- virtual int getTileY() const A_WARN_UNUSED;
-
- /**
- * Returns the number of Image layers used to draw the actor.
- */
- virtual int getNumberOfLayers() const A_WARN_UNUSED
- { return 0; }
-
- /**
- * Returns the current alpha value used to draw the actor.
- */
- virtual float getAlpha() const A_WARN_UNUSED = 0;
-
- /**
- * Sets the alpha value used to draw the actor.
- */
- virtual void setAlpha(float alpha) = 0;
-
- virtual void setMap(Map *const map);
-
- const Map* getMap() const A_WARN_UNUSED
- { return mMap; }
-
-protected:
- Actor();
-
- Map *mMap;
- Vector mPos; /**< Position in pixels relative to map. */
- int mYDiff;
-
-private:
- Actors::iterator mMapActor;
+ public:
+ A_DELETE_COPY(Actor)
+
+ virtual ~Actor();
+
+ /**
+ * Draws the Actor to the given graphics context.
+ *
+ * Note: this function could be simplified if the graphics context
+ * would support setting a translation offset. It already does this
+ * partly with the clipping rectangle support.
+ */
+ virtual void draw(Graphics *const graphics,
+ const int offsetX, const int offsetY) const = 0;
+
+ /**
+ * Returns the horizontal size of the actors graphical representation
+ * in pixels or 0 when it is undefined.
+ */
+ virtual int getWidth() const A_WARN_UNUSED
+ { return 0; }
+
+ /**
+ * Returns the vertical size of the actors graphical representation
+ * in pixels or 0 when it is undefined.
+ */
+ virtual int getHeight() const A_WARN_UNUSED
+ { return 0; }
+
+ /**
+ * Returns the pixel position of this actor.
+ */
+ const Vector &getPosition() const A_WARN_UNUSED
+ { return mPos; }
+
+ /**
+ * Sets the pixel position of this actor.
+ */
+ virtual void setPosition(const Vector &pos)
+ { mPos = pos; }
+
+ /**
+ * Returns the pixels X coordinate of the actor.
+ */
+ int getPixelX() const A_WARN_UNUSED
+ { return static_cast<int>(mPos.x); }
+
+ /**
+ * Returns the pixel Y coordinate of the actor.
+ */
+ virtual int getPixelY() const A_WARN_UNUSED
+ { return static_cast<int>(mPos.y); }
+
+ /**
+ * Returns the pixel Y coordinate of the actor for sorting only.
+ */
+ virtual int getSortPixelY() const A_WARN_UNUSED
+ { return static_cast<int>(mPos.y) - mYDiff; }
+
+ /**
+ * Returns the x coordinate in tiles of the actor.
+ */
+ virtual int getTileX() const A_WARN_UNUSED;
+
+ /**
+ * Returns the y coordinate in tiles of the actor.
+ */
+ virtual int getTileY() const A_WARN_UNUSED;
+
+ /**
+ * Returns the number of Image layers used to draw the actor.
+ */
+ virtual int getNumberOfLayers() const A_WARN_UNUSED
+ { return 0; }
+
+ /**
+ * Returns the current alpha value used to draw the actor.
+ */
+ virtual float getAlpha() const A_WARN_UNUSED = 0;
+
+ /**
+ * Sets the alpha value used to draw the actor.
+ */
+ virtual void setAlpha(float alpha) = 0;
+
+ virtual void setMap(Map *const map);
+
+ const Map* getMap() const A_WARN_UNUSED
+ { return mMap; }
+
+ protected:
+ Actor();
+
+ Map *mMap;
+ Vector mPos; /**< Position in pixels relative to map. */
+ int mYDiff;
+
+ private:
+ Actors::iterator mMapActor;
};
#endif // BEING_ACTOR_H
diff --git a/src/being/actorsprite.h b/src/being/actorsprite.h
index 7cffa3213..b4b6d8433 100644
--- a/src/being/actorsprite.h
+++ b/src/being/actorsprite.h
@@ -47,189 +47,190 @@ struct SpriteDisplay;
class ActorSprite notfinal : public CompoundSprite, public Actor
{
-public:
- explicit ActorSprite(const int id);
+ public:
+ explicit ActorSprite(const int id);
- A_DELETE_COPY(ActorSprite)
+ A_DELETE_COPY(ActorSprite)
- virtual ~ActorSprite();
+ virtual ~ActorSprite();
- int getId() const A_WARN_UNUSED
- { return mId; }
+ int getId() const A_WARN_UNUSED
+ { return mId; }
- void setId(const int id)
- { mId = id; }
+ void setId(const int id)
+ { mId = id; }
- /**
- * Returns the type of the ActorSprite.
- */
- virtual ActorType::Type getType() const A_WARN_UNUSED
- { return ActorType::UNKNOWN; }
+ /**
+ * Returns the type of the ActorSprite.
+ */
+ virtual ActorType::Type getType() const A_WARN_UNUSED
+ { return ActorType::UNKNOWN; }
- void draw1(Graphics *const graphics,
- const int offsetX,
- const int offsetY) const;
+ void draw1(Graphics *const graphics,
+ const int offsetX,
+ const int offsetY) const;
- virtual void logic();
+ virtual void logic();
- static void actorLogic();
+ static void actorLogic();
- void setMap(Map *const map) override;
+ void setMap(Map *const map) override;
- /**
- * Gets the way the object blocks pathfinding for other objects
- */
- virtual BlockType::BlockType getBlockType() const A_WARN_UNUSED
- { return BlockType::NONE; }
+ /**
+ * Gets the way the object blocks pathfinding for other objects
+ */
+ virtual BlockType::BlockType getBlockType() const A_WARN_UNUSED
+ { return BlockType::NONE; }
- /**
- * Take control of a particle.
- */
- void controlParticle(Particle *const particle);
-
- /**
- * Returns the required size of a target cursor for this being.
- */
- virtual TargetCursorSize::Size getTargetCursorSize() const A_WARN_UNUSED
- { return TargetCursorSize::MEDIUM; }
-
- virtual int getTargetOffsetX() const A_WARN_UNUSED
- { return 0; }
-
- virtual int getTargetOffsetY() const A_WARN_UNUSED
- { return 0; }
-
- /**
- * Sets the target animation for this actor.
- */
- void setTargetType(const TargetCursorType::Type type);
-
- /**
- * Untargets the actor.
- */
- void untarget()
- { mUsedTargetCursor = nullptr; }
-
- /**
- * Sets the actor's stun mode. If zero, the being is `normal', otherwise it
- * is `stunned' in some fashion.
- */
- void setStunMode(const uint16_t stunMode)
- {
- if (mStunMode != stunMode)
- updateStunMode(mStunMode, stunMode);
- mStunMode = stunMode;
- }
+ /**
+ * Take control of a particle.
+ */
+ void controlParticle(Particle *const particle);
+
+ /**
+ * Returns the required size of a target cursor for this being.
+ */
+ virtual TargetCursorSize::Size getTargetCursorSize() const
+ A_WARN_UNUSED
+ { return TargetCursorSize::MEDIUM; }
+
+ virtual int getTargetOffsetX() const A_WARN_UNUSED
+ { return 0; }
+
+ virtual int getTargetOffsetY() const A_WARN_UNUSED
+ { return 0; }
+
+ /**
+ * Sets the target animation for this actor.
+ */
+ void setTargetType(const TargetCursorType::Type type);
+
+ /**
+ * Untargets the actor.
+ */
+ void untarget()
+ { mUsedTargetCursor = nullptr; }
+
+ /**
+ * Sets the actor's stun mode. If zero, the being is `normal',
+ * otherwise it is `stunned' in some fashion.
+ */
+ void setStunMode(const uint16_t stunMode)
+ {
+ if (mStunMode != stunMode)
+ updateStunMode(mStunMode, stunMode);
+ mStunMode = stunMode;
+ }
- void setStatusEffect(const int index, const bool active);
-
- /**
- * A status effect block is a 16 bit mask of status effects. We assign each
- * such flag a block ID of offset + bitnr.
- *
- * These are NOT the same as the status effect indices.
- */
- void setStatusEffectBlock(const int offset, const uint16_t flags);
+ void setStatusEffect(const int index, const bool active);
+
+ /**
+ * A status effect block is a 16 bit mask of status effects. We assign
+ * each such flag a block ID of offset + bitnr.
+ *
+ * These are NOT the same as the status effect indices.
+ */
+ void setStatusEffectBlock(const int offset, const uint16_t flags);
+
+ virtual void setAlpha(const float alpha) override final
+ { CompoundSprite::setAlpha(alpha); }
+
+ virtual float getAlpha() const override final A_WARN_UNUSED
+ { return CompoundSprite::getAlpha(); }
+
+ virtual int getWidth() const override A_WARN_UNUSED
+ { return CompoundSprite::getWidth(); }
+
+ virtual int getHeight() const override A_WARN_UNUSED
+ { return CompoundSprite::getHeight(); }
+
+ static void load();
+
+ static void unload();
+
+ /**
+ * Add an ActorSprite listener.
+ */
+ void addActorSpriteListener(ActorSpriteListener *const listener);
+
+ /**
+ * Remove an ActorSprite listener.
+ */
+ void removeActorSpriteListener(ActorSpriteListener *const listener);
+
+ int getActorX() const A_WARN_UNUSED
+ { return getPixelX() - mapTileSize / 2; }
+
+ int getActorY() const A_WARN_UNUSED
+ { return getPixelY() - mapTileSize; }
+
+ void setPoison(const bool b)
+ { mPoison = b; }
+
+ bool getPoison() const A_WARN_UNUSED
+ { return mPoison; }
+
+ protected:
+ /**
+ * Notify self that the stun mode has been updated. Invoked by
+ * setStunMode if something changed.
+ */
+ virtual void updateStunMode(const int oldMode, const int newMode);
+
+ /**
+ * Notify self that a status effect has flipped.
+ * The new flag is passed.
+ */
+ virtual void updateStatusEffect(const int index, const bool newStatus);
+
+ /**
+ * Handle an update to a status or stun effect
+ *
+ * \param The StatusEffect to effect
+ * \param effectId -1 for stun, otherwise the effect index
+ */
+ virtual void handleStatusEffect(const StatusEffect *const effect,
+ const int effectId);
+
+ void setupSpriteDisplay(const SpriteDisplay &display,
+ const bool forceDisplay = true,
+ const int imageType = 0,
+ const std::string &color = "");
+
+ std::set<int> mStatusEffects; /**< set of active status effects */
+
+ ParticleList mStunParticleEffects;
+ ParticleVector mStatusParticleEffects;
+ ParticleList mChildParticleEffects;
+ int mId;
+ uint16_t mStunMode; /**< Stun mode; zero if not stunned */
+
+ private:
+ /** Load the target cursors into memory */
+ static void initTargetCursor();
+
+ /** Remove the target cursors from memory */
+ static void cleanupTargetCursors();
+
+ /** Animated target cursors. */
+ static AnimatedSprite *targetCursor[TargetCursorType::NUM_TCT]
+ [TargetCursorSize::NUM_TC];
+
+ static bool loaded;
- virtual void setAlpha(const float alpha) override final
- { CompoundSprite::setAlpha(alpha); }
+ /** Target cursor being used */
+ AnimatedSprite *mUsedTargetCursor;
- virtual float getAlpha() const override final A_WARN_UNUSED
- { return CompoundSprite::getAlpha(); }
+ typedef std::list<ActorSpriteListener*> ActorSpriteListeners;
+ typedef ActorSpriteListeners::iterator ActorSpriteListenerIterator;
+ ActorSpriteListeners mActorSpriteListeners;
- virtual int getWidth() const override A_WARN_UNUSED
- { return CompoundSprite::getWidth(); }
+ int mCursorPaddingX;
+ int mCursorPaddingY;
- virtual int getHeight() const override A_WARN_UNUSED
- { return CompoundSprite::getHeight(); }
-
- static void load();
-
- static void unload();
-
- /**
- * Add an ActorSprite listener.
- */
- void addActorSpriteListener(ActorSpriteListener *const listener);
-
- /**
- * Remove an ActorSprite listener.
- */
- void removeActorSpriteListener(ActorSpriteListener *const listener);
-
- int getActorX() const A_WARN_UNUSED
- { return getPixelX() - mapTileSize / 2; }
-
- int getActorY() const A_WARN_UNUSED
- { return getPixelY() - mapTileSize; }
-
- void setPoison(const bool b)
- { mPoison = b; }
-
- bool getPoison() const A_WARN_UNUSED
- { return mPoison; }
-
-protected:
- /**
- * Notify self that the stun mode has been updated. Invoked by
- * setStunMode if something changed.
- */
- virtual void updateStunMode(const int oldMode, const int newMode);
-
- /**
- * Notify self that a status effect has flipped.
- * The new flag is passed.
- */
- virtual void updateStatusEffect(const int index, const bool newStatus);
-
- /**
- * Handle an update to a status or stun effect
- *
- * \param The StatusEffect to effect
- * \param effectId -1 for stun, otherwise the effect index
- */
- virtual void handleStatusEffect(const StatusEffect *const effect,
- const int effectId);
-
- void setupSpriteDisplay(const SpriteDisplay &display,
- const bool forceDisplay = true,
- const int imageType = 0,
- const std::string &color = "");
-
- std::set<int> mStatusEffects; /**< set of active status effects */
-
- ParticleList mStunParticleEffects;
- ParticleVector mStatusParticleEffects;
- ParticleList mChildParticleEffects;
- int mId;
- uint16_t mStunMode; /**< Stun mode; zero if not stunned */
-
-private:
- /** Load the target cursors into memory */
- static void initTargetCursor();
-
- /** Remove the target cursors from memory */
- static void cleanupTargetCursors();
-
- /** Animated target cursors. */
- static AnimatedSprite *targetCursor[TargetCursorType::NUM_TCT]
- [TargetCursorSize::NUM_TC];
-
- static bool loaded;
-
- /** Target cursor being used */
- AnimatedSprite *mUsedTargetCursor;
-
- typedef std::list<ActorSpriteListener*> ActorSpriteListeners;
- typedef ActorSpriteListeners::iterator ActorSpriteListenerIterator;
- ActorSpriteListeners mActorSpriteListeners;
-
- int mCursorPaddingX;
- int mCursorPaddingY;
-
- /** Reset particle status effects on next redraw? */
- bool mMustResetParticles;
- bool mPoison;
+ /** Reset particle status effects on next redraw? */
+ bool mMustResetParticles;
+ bool mPoison;
};
#endif // BEING_ACTORSPRITE_H
diff --git a/src/being/compoundsprite.h b/src/being/compoundsprite.h
index 02c057ef7..2b7d8215a 100644
--- a/src/being/compoundsprite.h
+++ b/src/being/compoundsprite.h
@@ -34,114 +34,115 @@ class Image;
class CompoundSprite notfinal : public Sprite
{
-public:
- typedef std::vector<Sprite*>::iterator SpriteIterator;
- typedef std::vector<Sprite*>::const_iterator SpriteConstIterator;
+ public:
+ typedef std::vector<Sprite*>::iterator SpriteIterator;
+ typedef std::vector<Sprite*>::const_iterator SpriteConstIterator;
- CompoundSprite();
+ CompoundSprite();
- A_DELETE_COPY(CompoundSprite)
+ A_DELETE_COPY(CompoundSprite)
- virtual ~CompoundSprite();
+ virtual ~CompoundSprite();
- virtual bool reset() override final;
+ virtual bool reset() override final;
- virtual bool play(const std::string &action) override final;
+ virtual bool play(const std::string &action) override final;
- virtual bool update(const int time) override final;
+ virtual bool update(const int time) override final;
- virtual void draw(Graphics *const graphics,
- const int posX, const int posY) const override;
+ virtual void draw(Graphics *const graphics,
+ const int posX, const int posY) const override;
- /**
- * Gets the width in pixels of the first sprite in the list.
- */
- virtual int getWidth() const override A_WARN_UNUSED;
+ /**
+ * Gets the width in pixels of the first sprite in the list.
+ */
+ virtual int getWidth() const override A_WARN_UNUSED;
- /**
- * Gets the height in pixels of the first sprite in the list.
- */
- virtual int getHeight() const override A_WARN_UNUSED;
+ /**
+ * Gets the height in pixels of the first sprite in the list.
+ */
+ virtual int getHeight() const override A_WARN_UNUSED;
- virtual const Image *getImage() const override final A_WARN_UNUSED;
+ virtual const Image *getImage() const override final A_WARN_UNUSED;
- virtual bool setSpriteDirection(const SpriteDirection::Type direction)
- override final;
+ virtual bool setSpriteDirection(const SpriteDirection::Type direction)
+ override final;
- int getNumberOfLayers() const A_WARN_UNUSED;
+ int getNumberOfLayers() const A_WARN_UNUSED;
- unsigned int getCurrentFrame() const override final A_WARN_UNUSED;
+ unsigned int getCurrentFrame() const override final A_WARN_UNUSED;
- unsigned int getFrameCount() const override final A_WARN_UNUSED;
+ unsigned int getFrameCount() const override final A_WARN_UNUSED;
- size_t size() const A_WARN_UNUSED
- { return mSprites.size(); }
+ size_t size() const A_WARN_UNUSED
+ { return mSprites.size(); }
- bool empty() const A_WARN_UNUSED
- { return mSprites.empty(); }
+ bool empty() const A_WARN_UNUSED
+ { return mSprites.empty(); }
- void addSprite(Sprite *const sprite);
+ void addSprite(Sprite *const sprite);
- void setSprite(const int layer, Sprite *const sprite);
+ void setSprite(const int layer, Sprite *const sprite);
- Sprite *getSprite(int layer) const A_WARN_UNUSED
- { return mSprites.at(layer); }
+ Sprite *getSprite(int layer) const A_WARN_UNUSED
+ { return mSprites.at(layer); }
- void removeSprite(const int layer);
+ void removeSprite(const int layer);
- void clear();
+ void clear();
- void ensureSize(size_t layerCount);
+ void ensureSize(size_t layerCount);
- virtual void drawSprites(Graphics *const graphics,
- int posX, int posY) const;
+ virtual void drawSprites(Graphics *const graphics,
+ int posX, int posY) const;
- virtual void drawSpritesSDL(Graphics *const graphics,
- int posX, int posY) const;
+ virtual void drawSpritesSDL(Graphics *const graphics,
+ int posX, int posY) const;
- /**
- * Returns the curent frame in the current animation of the given layer.
- */
- virtual unsigned int getCurrentFrame(unsigned int layer)
- const A_WARN_UNUSED;
+ /**
+ * Returns the curent frame in the current animation of the given
+ * layer.
+ */
+ virtual unsigned int getCurrentFrame(unsigned int layer)
+ const A_WARN_UNUSED;
- /**
- * Returns the frame count in the current animation of the given layer.
- */
- virtual unsigned int getFrameCount(unsigned int layer) A_WARN_UNUSED;
+ /**
+ * Returns the frame count in the current animation of the given layer.
+ */
+ virtual unsigned int getFrameCount(unsigned int layer) A_WARN_UNUSED;
- virtual void setAlpha(float alpha) override;
+ virtual void setAlpha(float alpha) override;
- bool updateNumber(const unsigned num) override final;
+ bool updateNumber(const unsigned num) override final;
- static void setEnableDelay(bool b)
- { mEnableDelay = b; }
+ static void setEnableDelay(bool b)
+ { mEnableDelay = b; }
-private:
- void redraw() const;
+ private:
+ void redraw() const;
- void updateImages() const;
+ void updateImages() const;
- bool updateFromCache() const;
+ bool updateFromCache() const;
- void initCurrentCacheItem() const;
+ void initCurrentCacheItem() const;
- typedef std::list<CompoundItem*> ImagesCache;
- mutable ImagesCache imagesCache;
- mutable CompoundItem *mCacheItem;
+ typedef std::list<CompoundItem*> ImagesCache;
+ mutable ImagesCache imagesCache;
+ mutable CompoundItem *mCacheItem;
- mutable Image *mImage;
- mutable Image *mAlphaImage;
+ mutable Image *mImage;
+ mutable Image *mAlphaImage;
- mutable int mOffsetX;
- mutable int mOffsetY;
- std::vector<Sprite*> mSprites;
- mutable int mNextRedrawTime;
- static bool mEnableDelay;
- mutable bool mNeedsRedraw;
- bool mEnableAlphaFix;
- bool mDisableAdvBeingCaching;
- bool mDisableBeingCaching;
+ mutable int mOffsetX;
+ mutable int mOffsetY;
+ std::vector<Sprite*> mSprites;
+ mutable int mNextRedrawTime;
+ static bool mEnableDelay;
+ mutable bool mNeedsRedraw;
+ bool mEnableAlphaFix;
+ bool mDisableAdvBeingCaching;
+ bool mDisableBeingCaching;
};
#endif // BEING_COMPOUNDSPRITE_H
diff --git a/src/being/playerrelations.cpp b/src/being/playerrelations.cpp
index 486713434..42f15d1ba 100644
--- a/src/being/playerrelations.cpp
+++ b/src/being/playerrelations.cpp
@@ -75,43 +75,43 @@ namespace
public ConfigurationListManager<std::pair<std::string,
PlayerRelation *>, std::map<std::string, PlayerRelation *> *>
{
- public:
- ConfigurationObject *writeConfigItem(
- const std::pair<std::string, PlayerRelation *> &value,
- ConfigurationObject *const cobj) const override final
- {
- if (!cobj || !value.second)
- return nullptr;
- cobj->setValue(NAME, value.first);
- cobj->setValue(RELATION, toString(
- static_cast<int>(value.second->mRelation)));
-
- return cobj;
- }
+ public:
+ ConfigurationObject *writeConfigItem(
+ const std::pair<std::string, PlayerRelation *> &value,
+ ConfigurationObject *const cobj) const override final
+ {
+ if (!cobj || !value.second)
+ return nullptr;
+ cobj->setValue(NAME, value.first);
+ cobj->setValue(RELATION, toString(
+ static_cast<int>(value.second->mRelation)));
- std::map<std::string, PlayerRelation *> *
- readConfigItem(const ConfigurationObject *const cobj,
- std::map<std::string, PlayerRelation *>
- *const container) const override final
- {
- if (!cobj)
- return container;
- const std::string name = cobj->getValue(NAME, "");
- if (name.empty())
- return container;
+ return cobj;
+ }
- if (!(*container)[name])
+ std::map<std::string, PlayerRelation *> *
+ readConfigItem(const ConfigurationObject *const cobj,
+ std::map<std::string, PlayerRelation *>
+ *const container) const override final
{
- const int v = cobj->getValueInt(RELATION,
- static_cast<int>(PlayerRelation::NEUTRAL));
+ if (!cobj)
+ return container;
+ const std::string name = cobj->getValue(NAME, "");
+ if (name.empty())
+ return container;
+
+ if (!(*container)[name])
+ {
+ const int v = cobj->getValueInt(RELATION,
+ static_cast<int>(PlayerRelation::NEUTRAL));
+
+ (*container)[name] = new PlayerRelation(
+ static_cast<PlayerRelation::Relation>(v));
+ }
+ // otherwise ignore the duplicate entry
- (*container)[name] = new PlayerRelation(
- static_cast<PlayerRelation::Relation>(v));
+ return container;
}
- // otherwise ignore the duplicate entry
-
- return container;
- }
};
static PlayerConfSerialiser player_conf_serialiser; // stateless singleton
@@ -460,87 +460,87 @@ bool PlayerRelationsManager::checkBadRelation(const std::string &name) const
class PIS_nothing final : public PlayerIgnoreStrategy
{
-public:
- PIS_nothing() :
- PlayerIgnoreStrategy()
- {
- // TRANSLATORS: ignore/unignore action
- mDescription = _("Completely ignore");
- mShortName = PLAYER_IGNORE_STRATEGY_NOP;
- }
+ public:
+ PIS_nothing() :
+ PlayerIgnoreStrategy()
+ {
+ // TRANSLATORS: ignore/unignore action
+ mDescription = _("Completely ignore");
+ mShortName = PLAYER_IGNORE_STRATEGY_NOP;
+ }
- void ignore(Being *const being A_UNUSED,
- const unsigned int flags A_UNUSED) const override final
- {
- }
+ void ignore(Being *const being A_UNUSED,
+ const unsigned int flags A_UNUSED) const override final
+ {
+ }
};
class PIS_dotdotdot final : public PlayerIgnoreStrategy
{
-public:
- PIS_dotdotdot() :
- PlayerIgnoreStrategy()
- {
- // TRANSLATORS: ignore/unignore action
- mDescription = _("Print '...'");
- mShortName = "dotdotdot";
- }
+ public:
+ PIS_dotdotdot() :
+ PlayerIgnoreStrategy()
+ {
+ // TRANSLATORS: ignore/unignore action
+ mDescription = _("Print '...'");
+ mShortName = "dotdotdot";
+ }
- void ignore(Being *const being,
- const unsigned int flags A_UNUSED) const override final
- {
- if (!being)
- return;
+ void ignore(Being *const being,
+ const unsigned int flags A_UNUSED) const override final
+ {
+ if (!being)
+ return;
- logger->log("ignoring: " + being->getName());
- being->setSpeech("...");
- }
+ logger->log("ignoring: " + being->getName());
+ being->setSpeech("...");
+ }
};
class PIS_blinkname final : public PlayerIgnoreStrategy
{
-public:
- PIS_blinkname() :
- PlayerIgnoreStrategy()
- {
- // TRANSLATORS: ignore/unignore action
- mDescription = _("Blink name");
- mShortName = "blinkname";
- }
+ public:
+ PIS_blinkname() :
+ PlayerIgnoreStrategy()
+ {
+ // TRANSLATORS: ignore/unignore action
+ mDescription = _("Blink name");
+ mShortName = "blinkname";
+ }
- void ignore(Being *const being,
- const unsigned int flags A_UNUSED) const override final
- {
- if (!being)
- return;
+ void ignore(Being *const being,
+ const unsigned int flags A_UNUSED) const override final
+ {
+ if (!being)
+ return;
- logger->log("ignoring: " + being->getName());
- being->flashName(200);
- }
+ logger->log("ignoring: " + being->getName());
+ being->flashName(200);
+ }
};
class PIS_emote final : public PlayerIgnoreStrategy
{
-public:
- PIS_emote(const uint8_t emote_nr, const std::string &description,
- const std::string &shortname) :
- PlayerIgnoreStrategy(),
- mEmotion(emote_nr)
- {
- mDescription = description;
- mShortName = shortname;
- }
+ public:
+ PIS_emote(const uint8_t emote_nr, const std::string &description,
+ const std::string &shortname) :
+ PlayerIgnoreStrategy(),
+ mEmotion(emote_nr)
+ {
+ mDescription = description;
+ mShortName = shortname;
+ }
- void ignore(Being *const being,
- const unsigned int flags A_UNUSED) const override final
- {
- if (!being)
- return;
+ void ignore(Being *const being,
+ const unsigned int flags A_UNUSED) const override final
+ {
+ if (!being)
+ return;
- being->setEmote(mEmotion, IGNORE_EMOTE_TIME);
- }
- uint8_t mEmotion;
+ being->setEmote(mEmotion, IGNORE_EMOTE_TIME);
+ }
+ uint8_t mEmotion;
};
std::vector<PlayerIgnoreStrategy *> *