Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 16, 2008, 6:01:13 PM (15 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/Super.h

    r2171 r2485  
    9999            \
    100100            static void apply(void* temp) {} \
     101            \
    101102            static void apply(baseclass* temp) \
    102103            { \
     
    104105                for (std::set<const Identifier*>::iterator it = identifier->getDirectChildrenIntern().begin(); it != identifier->getDirectChildrenIntern().end(); ++it) \
    105106                { \
     107                    if (((ClassIdentifier<T>*)(*it))->bSuperFunctionCaller_##functionname##_isFallback_ && ((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_) \
     108                    { \
     109                        delete ((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_; \
     110                        ((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_ = 0; \
     111                        ((ClassIdentifier<T>*)(*it))->bSuperFunctionCaller_##functionname##_isFallback_ = false; \
     112                    } \
     113                    \
    106114                    if (!((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_) \
    107115                    { \
     
    163171                for (std::set<const Identifier*>::iterator it = identifier->getDirectChildrenIntern().begin(); it != identifier->getDirectChildrenIntern().end(); ++it)
    164172                {
     173                    // Check if the caller is a fallback-caller
     174                    if (((ClassIdentifier<T>*)(*it))->bSuperFunctionCaller_##functionname##_isFallback_ && ((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_)
     175                    {
     176                        // Delete the fallback caller an prepare to get a real caller
     177                        delete ((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_;
     178                        ((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_ = 0;
     179                        ((ClassIdentifier<T>*)(*it))->bSuperFunctionCaller_##functionname##_isFallback_ = false;
     180                    }
     181
    165182                    // Check if there's not already a caller
    166183                    if (!((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_)
     
    183200        struct SuperFunctionCondition<functionnumber, baseclass, 0, templatehack2> \
    184201        { \
    185             // The check function just behaves like the fallback - it advances to the check for the next super-function (functionnumber + 1)
     202            // The check function acts like the fallback - it advances to the check for the next super-function (functionnumber + 1)
    186203            static void check() \
    187204            { \
     
    233250    #define SUPER_processEvent(classname, functionname, ...) \
    234251        SUPER_ARGS(classname, functionname, __VA_ARGS__)
     252
     253    #define SUPER_changedScale(classname, functionname, ...) \
     254        SUPER_NOARGS(classname, functionname)
     255
     256    #define SUPER_changedMainState(classname, functionname, ...) \
     257        SUPER_NOARGS(classname, functionname)
     258
     259    #define SUPER_changedOwner(classname, functionname, ...) \
     260        SUPER_NOARGS(classname, functionname)
     261
     262    #define SUPER_changedOverlayGroup(classname, functionname, ...) \
     263        SUPER_NOARGS(classname, functionname)
     264
     265    #define SUPER_changedName(classname, functionname, ...) \
     266        SUPER_NOARGS(classname, functionname)
     267
     268    #define SUPER_changedGametype(classname, functionname, ...) \
     269        SUPER_NOARGS(classname, functionname)
    235270    // (1/3) --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <--
    236271
     
    292327            }; \
    293328            \
     329            class _CoreExport SuperFunctionCaller_##functionname \
     330            { \
     331                public: \
     332                    virtual void operator()( SUPER_CALL_ARGUMENTS##hasarguments(__VA_ARGS__) ) = 0; \
     333                    virtual ~SuperFunctionCaller_##functionname () {} \
     334            }; \
     335            \
     336            template <class T> \
     337            class SuperFunctionClassCaller_purevirtualfallback_##functionname : public SuperFunctionCaller_##functionname \
     338            { \
     339                public: \
     340                    inline void operator()( SUPER_CALL_ARGUMENTS##hasarguments(__VA_ARGS__) ) \
     341                    { \
     342                    } \
     343            }; \
     344            \
    294345            template <class T> \
    295346            struct SuperFunctionInitialization<functionnumber, T> \
     
    297348                static void initialize(ClassIdentifier<T>* identifier) \
    298349                { \
    299                     identifier->superFunctionCaller_##functionname##_ = 0; \
     350                    identifier->superFunctionCaller_##functionname##_ = new SuperFunctionClassCaller_purevirtualfallback_##functionname <T>; \
     351                    identifier->bSuperFunctionCaller_##functionname##_isFallback_ = true; \
    300352                    SuperFunctionInitialization<functionnumber + 1, T>::initialize(identifier); \
    301353                } \
     
    313365            }; \
    314366            \
    315             class _CoreExport SuperFunctionCaller_##functionname \
    316             { \
    317                 public: \
    318                     virtual void operator()( SUPER_CALL_ARGUMENTS##hasarguments(__VA_ARGS__) ) = 0; \
    319                     virtual ~SuperFunctionCaller_##functionname () {} \
    320             }; \
    321             \
    322367            template <class T> \
    323368            class SuperFunctionClassCaller_##functionname : public SuperFunctionCaller_##functionname \
     
    366411        };
    367412
    368         // Initializes the SuperFunctionCaller-pointer with zero.
     413        // Baseclass of the super-function caller. The real call will be done by a
     414        // templatized subclass through the virtual () operator.
     415        class _CoreExport SuperFunctionCaller_##functionname
     416        {
     417            public:
     418                virtual void operator()( SUPER_CALL_ARGUMENTS##hasarguments(__VA_ARGS__) ) = 0;
     419                virtual ~SuperFunctionCaller_##functionname () {}
     420        };
     421
     422        // Fallback if the base is pure virtual
     423        template <class T>
     424        class SuperFunctionClassCaller_purevirtualfallback_##functionname : public SuperFunctionCaller_##functionname
     425        {
     426            public:
     427                // Fallback does nothing
     428                inline void operator()( SUPER_CALL_ARGUMENTS##hasarguments(__VA_ARGS__) )
     429                {
     430                }
     431        };
     432
     433        // Initializes the SuperFunctionCaller-pointer with a fallback caller in case the base function is pure virtual
    369434        template <class T>
    370435        struct SuperFunctionInitialization<functionnumber, T>
     
    372437            static void initialize(ClassIdentifier<T>* identifier)
    373438            {
    374                 identifier->superFunctionCaller_##functionname##_ = 0;
     439                identifier->superFunctionCaller_##functionname##_ = new SuperFunctionClassCaller_purevirtualfallback_##functionname <T>;
     440                identifier->bSuperFunctionCaller_##functionname##_isFallback_ = true;
    375441
    376442                // Calls the initialization of the next super-function (functionnumber + 1)
     
    391457                SuperFunctionDestruction<functionnumber + 1, T>::destroy(identifier);
    392458            }
    393         };
    394 
    395         // Baseclass of the super-function caller. The real call will be done by a
    396         // templatized subclass through the virtual () operator.
    397         class _CoreExport SuperFunctionCaller_##functionname
    398         {
    399             public:
    400                 virtual void operator()( SUPER_CALL_ARGUMENTS##hasarguments(__VA_ARGS__) ) = 0;
    401                 virtual ~SuperFunctionCaller_##functionname () {}
    402459        };
    403460
     
    441498            (event)
    442499        SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
     500
     501        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(5, changedScale, false)
     502            ()
     503        SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
     504
     505        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(6, changedMainState, false)
     506            ()
     507        SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
     508
     509        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(7, changedOwner, false)
     510            ()
     511        SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
     512
     513        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(8, changedOverlayGroup, false)
     514            ()
     515        SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
     516
     517        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(9, changedName, false)
     518            ()
     519        SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
     520
     521        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(10, changedGametype, false)
     522            ()
     523        SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
    443524        // (2/3) --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <--
    444525
     
    476557        #ifndef SUPER_INTRUSIVE_DECLARATION
    477558          #define SUPER_INTRUSIVE_DECLARATION(functionname) \
    478             SuperFunctionCaller_##functionname * superFunctionCaller_##functionname##_
     559            SuperFunctionCaller_##functionname * superFunctionCaller_##functionname##_; \
     560            bool bSuperFunctionCaller_##functionname##_isFallback_
    479561        #endif
    480562
     
    488570    SUPER_INTRUSIVE_DECLARATION(changedVisibility);
    489571    SUPER_INTRUSIVE_DECLARATION(processEvent);
     572    SUPER_INTRUSIVE_DECLARATION(changedScale);
     573    SUPER_INTRUSIVE_DECLARATION(changedMainState);
     574    SUPER_INTRUSIVE_DECLARATION(changedOwner);
     575    SUPER_INTRUSIVE_DECLARATION(changedOverlayGroup);
     576    SUPER_INTRUSIVE_DECLARATION(changedName);
     577    SUPER_INTRUSIVE_DECLARATION(changedGametype);
    490578    // (3/3) --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <--
    491579
Note: See TracChangeset for help on using the changeset viewer.