Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2155 for code/branches


Ignore:
Timestamp:
Nov 8, 2008, 5:13:18 PM (16 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).

Location:
code/branches/objecthierarchy/src
Files:
1 added
4 edited

Legend:

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

    r2074 r2155  
    4141#include "Template.h"
    4242#include "util/String.h"
     43#include "util/mbool.h"
    4344
    4445namespace orxonox
  • 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:
  • code/branches/objecthierarchy/src/orxonox/objects/worldentities/pawns/Spectator.cc

    r2112 r2155  
    203203                {
    204204                    if (this->getGametype()->isStartCountdownRunning())
    205                         this->hudmode_ = 2 + 10*ceil(this->getGametype()->getStartCountdown());
     205                        this->hudmode_ = 2 + 10*(int)ceil(this->getGametype()->getStartCountdown());
    206206                    else
    207207                        this->hudmode_ = 3;
  • code/branches/objecthierarchy/src/util/Math.h

    r2114 r2155  
    3939#include <ostream>
    4040#include <string>
     41#include <cmath>
    4142#include <boost/static_assert.hpp>
    4243
     
    145146    {
    146147        return x*x*x;
    147     }
    148 
    149     /**
    150         @brief Rounds the value down.
    151     */
    152     template <typename T>
    153     inline int floor(T x)
    154     {
    155         return (int)(x);
    156     }
    157 
    158     /**
    159         @brief Rounds the value up.
    160     */
    161     template <typename T>
    162     inline int ceil(T x)
    163     {
    164         int temp = floor(x);
    165         return (temp != x) ? (temp + 1) : temp;
    166148    }
    167149
Note: See TracChangeset for help on using the changeset viewer.