Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 2, 2010, 10:06:51 AM (14 years ago)
Author:
dafrick
Message:

Hiding MultiTrigger behind PlayerTrigger for consistency of use.
Trying some things out with notifications.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/notifications/src/modules/notifications/Notification.cc

    r7193 r7324  
    3535
    3636#include "core/CoreIncludes.h"
     37#include "network/NetworkFunction.h"
    3738#include "NotificationManager.h"
    3839
     
    4243    CreateUnloadableFactory(Notification);
    4344
     45    registerMemberNetworkFunction(Notification, send);
     46
    4447    /**
    4548    @brief
    4649        Default constructor. Initializes the object.
    4750    */
    48     Notification::Notification(BaseObject* creator) : BaseObject(creator)
     51    Notification::Notification(BaseObject* creator) : BaseObject(creator), Synchronisable(creator)
    4952    {
    5053        RegisterObject(Notification);
    5154        this->initialize();
     55        this->registerVariables();
    5256    }
    5357
     
    5862        The message of the Notification.
    5963    */
    60     Notification::Notification(BaseObject* creator, const std::string & message) : BaseObject(creator)
     64    Notification::Notification(BaseObject* creator, const std::string & message) : BaseObject(creator), Synchronisable(creator)
    6165    {
    6266        RegisterObject(Notification);
    6367        this->initialize();
    6468        this->message_ = message;
     69        this->registerVariables();
    6570    }
    6671
     
    8590    }
    8691
    87     /**
    88     @brief
    89         Sends the Notification to the Notificationmanager, with sender NetificationManager::NONE.
    90     @return
    91         Returns true if successful.
    92     */
    93     bool Notification::send(void)
     92    void Notification::registerVariables(void)
    9493    {
    95         return this->send(NotificationManager::NONE);
     94        registerVariable(this->message_);
     95        registerVariable(this->sender_);
     96        registerVariable(this->sent_);
    9697    }
    9798
     
    104105        Returns true if successful.
    105106    */
    106     bool Notification::send(const std::string & sender)
     107    bool Notification::send(unsigned int clientId, const std::string & sender = NotificationManager::NONE)
    107108    {
    108         if(this->isSent()) //TODO: Needed?
    109             return false;
    110        
    111         this->sender_ = sender;
    112         bool successful = NotificationManager::getInstance().registerNotification(this);
    113         if(!successful)
    114             return false;
    115         this->sent_ = true;
     109        if(GameMode::isMaster())
     110        {
     111            if(this->isSent()) //TODO: Needed?
     112                return false;
    116113
    117         COUT(3) << "Notification \"" << this->getMessage() << "\" sent." << std::endl;
     114            this->sender_ = sender;
     115            bool successful = NotificationManager::getInstance().registerNotification(this);
     116            if(!successful)
     117                return false;
     118            this->sent_ = true;
     119
     120            COUT(3) << "Notification \"" << this->getMessage() << "\" sent." << std::endl;
     121        }
     122        else
     123        {
     124            callMemberNetworkFunction(Notification, send, this->getObjectID(), clientId, clientId, sender);
     125        }
    118126
    119127        return true;
Note: See TracChangeset for help on using the changeset viewer.