Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 21, 2010, 11:15:44 PM (14 years ago)
Author:
dafrick
Message:

Synchronizing Notifications.
In the course of that, notifications are not longer sent by creating a Notification and the calling notification.send() bur by letting the NotificationManager handle all this: NotificationManager::getInstance().sendNotification(message)
This made QuestNotification obsolete, thus it was removde.

Also did some work on synchronizing the Script class. It should work properly most of the time, but the current solution is unreliable and unsatisfactory. So this will change as soon as I know how.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/modules/notifications/NotificationDispatcher.cc

    r7456 r7474  
    3535
    3636#include "core/CoreIncludes.h"
     37#include "core/EventIncludes.h"
    3738#include "core/XMLPort.h"
    38 #include "core/EventIncludes.h"
     39#include "network/NetworkFunction.h"
     40#include "network/Host.h"
     41
     42#include "infos/PlayerInfo.h"
     43#include "interfaces/PlayerTrigger.h"
     44#include "worldentities/pawns/Pawn.h"
     45
    3946#include "Notification.h"
    4047#include "NotificationManager.h"
    41 #include "interfaces/PlayerTrigger.h"
    42 #include "infos/PlayerInfo.h"
    43 #include "worldentities/pawns/Pawn.h"
    4448
    4549namespace orxonox
     
    4852    CreateUnloadableFactory(NotificationDispatcher);
    4953
     54    registerMemberNetworkFunction(NotificationDispatcher, dispatch);
     55
    5056    /**
    5157    @brief
    5258        Default constructor. Initializes the object.
    5359    */
    54     NotificationDispatcher::NotificationDispatcher(BaseObject* creator) : BaseObject(creator)
     60    NotificationDispatcher::NotificationDispatcher(BaseObject* creator) : BaseObject(creator), Synchronisable(creator)
    5561    {
    5662        RegisterObject(NotificationDispatcher);
    5763
    5864        this->sender_ = NotificationManager::NONE;
     65        this->registerVariables();
    5966    }
    6067
     
    8693    }
    8794
     95    void NotificationDispatcher::registerVariables(void)
     96    {
     97        registerVariable(this->sender_, VariableDirection::ToClient);
     98    }
     99
    88100    /**
    89101    @brief
     
    94106    void NotificationDispatcher::dispatch(unsigned int clientId)
    95107    {
    96         const std::string message = this->createNotificationMessage();
    97         Notification* notification = new Notification(this, message);
    98 
    99         notification->send(clientId, this->getSender());
     108        if(GameMode::isStandalone() || Host::getPlayerID() == clientId || this->getSyncMode() == 0x0)
     109        {
     110            const std::string message = this->createNotificationMessage();
     111            NotificationManager::sendNotification(message, clientId, this->getSender());
     112        }
     113        else if(GameMode::isServer())
     114        {
     115            callMemberNetworkFunction(NotificationDispatcher, dispatch, this->getObjectID(), clientId, clientId);
     116        }
    100117    }
    101118
     
    123140        if(pTrigger != NULL)
    124141        {
    125             if(!pTrigger->isForPlayer())  //!< The PlayerTrigger is not exclusively for Pawns which means we cannot extract one.
     142            if(!pTrigger->isForPlayer())  // The PlayerTrigger is not exclusively for Pawns which means we cannot extract one.
    126143                return false;
    127144            else
     
    133150        if(pawn == NULL)
    134151        {
    135             COUT(4) << "The QuestEffectBeacon was triggered by an entity other than a Pawn. (" << trigger->getIdentifier()->getName() << ")" << std::endl;
     152            COUT(4) << "The NotificationDispatcher was triggered by an entity other than a Pawn. (" << trigger->getIdentifier()->getName() << ")" << std::endl;
    136153            return false;
    137154        }
    138155
    139         //! Extract the PlayerInfo from the Pawn.
     156        // Extract the PlayerInfo from the Pawn.
    140157        PlayerInfo* player = pawn->getPlayer();
    141158
Note: See TracChangeset for help on using the changeset viewer.