Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 11, 2010, 10:20:44 AM (14 years ago)
Author:
dafrick
Message:

Merged notifications branch back to trunk.

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/modules/notifications/Notification.cc

    r7401 r7403  
    3535
    3636#include "core/CoreIncludes.h"
     37#include "network/NetworkFunction.h"
    3738#include "NotificationManager.h"
    3839
     
    4243    CreateUnloadableFactory(Notification);
    4344
     45    registerMemberNetworkFunction(Notification, sendHelper);
     46
    4447    /**
    4548    @brief
    4649        Default constructor. Initializes the object.
     50    @param creator
     51        The object that created this Notification
    4752    */
    48     Notification::Notification(BaseObject* creator) : BaseObject(creator)
     53    Notification::Notification(BaseObject* creator) : BaseObject(creator), Synchronisable(creator)
    4954    {
    5055        RegisterObject(Notification);
    5156        this->initialize();
     57        this->registerVariables();
    5258    }
    5359
     
    5662        Constructor. Creates a Notification with the input message.
    5763    @param creator
    58         The object that created this Notification
     64        The creator.
    5965    @param message
    6066        The message of the Notification.
    6167    */
    62     Notification::Notification(BaseObject* creator, const std::string & message) : BaseObject(creator)
     68    Notification::Notification(BaseObject* creator, const std::string & message) : BaseObject(creator), Synchronisable(creator)
    6369    {
    6470        RegisterObject(Notification);
    6571        this->initialize();
    6672        this->message_ = message;
     73        this->registerVariables();
    6774    }
    6875
     
    8794    }
    8895
    89     /**
    90     @brief
    91         Sends the Notification to the Notificationmanager, with sender NetificationManager::NONE.
    92     @return
    93         Returns true if successful.
    94     */
    95     bool Notification::send(void)
     96    void Notification::registerVariables(void)
    9697    {
    97         return this->send(NotificationManager::NONE);
     98        registerVariable(this->message_);
     99        registerVariable(this->sender_);
     100        registerVariable(this->sent_);
    98101    }
    99102
     
    106109        Returns true if successful.
    107110    */
    108     bool Notification::send(const std::string & sender)
     111    bool Notification::send(unsigned int clientId, const std::string & sender = NotificationManager::NONE)
     112    {
     113
     114        if(GameMode::isStandalone())
     115        {
     116            this->sendHelper(sender);
     117        }
     118        else
     119        {
     120            callMemberNetworkFunction(Notification, sendHelper, this->getObjectID(), clientId, sender);
     121        }
     122
     123        return true;
     124    }
     125
     126    bool Notification::sendHelper(const std::string& sender)
    109127    {
    110128        if(this->isSent()) //TODO: Needed?
    111129            return false;
    112        
     130
    113131        this->sender_ = sender;
    114132        bool successful = NotificationManager::getInstance().registerNotification(this);
Note: See TracChangeset for help on using the changeset viewer.