Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 16, 2008, 6:01:13 PM (16 years ago)
Author:
landauf
Message:

Merged objecthierarchy2 into presentation branch

Couln't merge 2 lines in Gamestate.cc and a whole block of code in GSDedicated.cc (it seems like oli implemented in both branches something like a network-tick-limiter but with different approaches)

Not yet tested in network mode and with bots
The SpaceShips movement is also not yet fully adopted to the new physics (see Engine class)

Location:
code/branches/presentation
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation

  • code/branches/presentation/src/core/BaseObject.h

    r2171 r2485  
    3636#ifndef _BaseObject_H__
    3737#define _BaseObject_H__
     38
     39#define SetMainState(classname, statename, setfunction, getfunction) \
     40    if (this->getMainStateName() == statename) \
     41    { \
     42        this->functorSetMainState_ = createFunctor(&classname::setfunction)->setObject(this); \
     43        this->functorGetMainState_ = createFunctor(&classname::getfunction)->setObject(this); \
     44    }
    3845
    3946#include <map>
     
    100107            virtual void changedVisibility() {}
    101108
     109            void setMainState(bool state);
     110            bool getMainState() const;
     111
     112            void setMainStateName(const std::string& name);
     113            inline const std::string& getMainStateName() const { return this->mainStateName_; }
     114            virtual void changedMainState();
     115
    102116            /** @brief Sets a pointer to the xml file that loaded this object. @param file The pointer to the XMLFile */
    103117            inline void setFile(const XMLFile* file) { this->file_ = file; }
     
    121135            inline Scene* getScene() const { return this->scene_; }
    122136
    123             inline void setGametype(Gametype* gametype) { this->oldGametype_ = this->gametype_; this->gametype_ = gametype; this->changedGametype(); }
     137            inline void setGametype(Gametype* gametype)
     138            {
     139                if (gametype != this->gametype_)
     140                {
     141                    this->oldGametype_ = this->gametype_;
     142                    this->gametype_ = gametype;
     143                    this->changedGametype();
     144                }
     145            }
    124146            inline Gametype* getGametype() const { return this->gametype_; }
    125147            inline Gametype* getOldGametype() const { return this->oldGametype_; }
    126             virtual inline void changedGametype() {}
     148            virtual void changedGametype() {}
    127149
    128150            void fireEvent();
     
    153175            std::string name_;                          //!< The name of the object
    154176            std::string oldName_;                       //!< The old name of the object
    155             mbool bActive_;                             //!< True = the object is active
    156             mbool bVisible_;                            //!< True = the object is visible
     177            mbool       bActive_;                       //!< True = the object is active
     178            mbool       bVisible_;                      //!< True = the object is visible
     179            std::string mainStateName_;
     180            Functor*    functorSetMainState_;
     181            Functor*    functorGetMainState_;
    157182
    158183        private:
     
    160185            Template* getTemplate(unsigned int index) const;
    161186
    162             bool                  bInitialized_;         //!< True if the object was initialized (passed the object registration)
    163             const XMLFile*        file_;                 //!< The XMLFile that loaded this object
    164             std::string           loaderIndentation_;    //!< Indentation of the debug output in the Loader
    165             Namespace*            namespace_;
    166             BaseObject*           creator_;
    167             Scene*                scene_;
    168             Gametype*             gametype_;
    169             Gametype*             oldGametype_;
    170             std::set<Template*>   templates_;
    171             std::map<BaseObject*, std::string> eventListeners_;
     187            bool                   bInitialized_;         //!< True if the object was initialized (passed the object registration)
     188            const XMLFile*         file_;                 //!< The XMLFile that loaded this object
     189            std::string            loaderIndentation_;    //!< Indentation of the debug output in the Loader
     190            Namespace*             namespace_;
     191            BaseObject*            creator_;
     192            Scene*                 scene_;
     193            Gametype*              gametype_;
     194            Gametype*              oldGametype_;
     195            std::set<Template*>    templates_;
     196            std::map<BaseObject*,  std::string> eventListeners_;
    172197            std::list<BaseObject*> events_;
    173198            std::map<std::string, EventContainer*> eventContainers_;
     
    178203    SUPER_FUNCTION(3, BaseObject, changedVisibility, false);
    179204    SUPER_FUNCTION(4, BaseObject, processEvent, false);
     205    SUPER_FUNCTION(6, BaseObject, changedMainState, false);
     206    SUPER_FUNCTION(9, BaseObject, changedName, false);
     207    SUPER_FUNCTION(10, BaseObject, changedGametype, false);
    180208}
    181209
Note: See TracChangeset for help on using the changeset viewer.