Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 8, 2008, 5:13:18 PM (15 years ago)
Author:
landauf
Message:

added mbool (bool with memory) to fix particlespawner-on-client problem. maybe further changes are needed if a similar problem affects other classes.

if the mbool changes from true to false and back to true within one server tick, the value stays true on the client, but a callback is called.
if you have to switch the state also on the client, a more advanced control logic is needed, but also possible with mbool (you could use 2 mbools, synchronize one and compare with the other).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/objecthierarchy/src/core/BaseObject.h

    r2144 r2155  
    4545#include "XMLIncludes.h"
    4646#include "Event.h"
     47#include "util/mbool.h"
    4748
    4849namespace orxonox
     
    7374            /** @brief Sets the state of the objects activity. @param bActive True = active */
    7475            inline void setActive(bool bActive)
    75             { 
    76                 bool bTemp = this->bActive_;
    77                 this->bActive_ = bActive;
    78                 if ( bTemp != bActive )
     76            {
     77                if (this->bActive_ != bActive)
     78                {
     79                    this->bActive_ = bActive;
    7980                    this->changedActivity();
     81                }
    8082            }
    8183            /** @brief Returns the state of the objects activity. @return The state of the activity */
    82             inline bool isActive() const { return this->bActive_; }
     84            inline const mbool& isActive() const { return this->bActive_; }
    8385            /** @brief This function gets called if the activity of the object changes. */
    8486            virtual void changedActivity() {}
    8587
    8688            /** @brief Sets the state of the objects visibility. @param bVisible True = visible */
    87             inline void setVisible(bool bVisible) { this->bVisible_ = bVisible; this->changedVisibility(); }
     89            inline void setVisible(bool bVisible)
     90            {
     91                if (this->bVisible_ != bVisible)
     92                {
     93                    this->bVisible_ = bVisible;
     94                    this->changedVisibility();
     95                }
     96            }
    8897            /** @brief Returns the state of the objects visibility. @return The state of the visibility */
    89             inline bool isVisible() const { return this->bVisible_; }
     98            inline const mbool& isVisible() const { return this->bVisible_; }
    9099            /** @brief This function gets called if the visibility of the object changes. */
    91100            virtual void changedVisibility() {}
     
    144153            std::string name_;                          //!< The name of the object
    145154            std::string oldName_;                       //!< The old name of the object
    146             bool bActive_;                              //!< True = the object is active
    147             bool bVisible_;                             //!< True = the object is visible
     155            mbool bActive_;                             //!< True = the object is active
     156            mbool bVisible_;                            //!< True = the object is visible
    148157
    149158        private:
Note: See TracChangeset for help on using the changeset viewer.