Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 17, 2016, 10:29:21 PM (8 years ago)
Author:
landauf
Message:

merged branch cpp11_v3 back to trunk

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/orxonox/interfaces/NotificationListener.cc

    r10624 r11071  
    7474        The type of the notification, can be either 'info' or 'important'.
    7575    */
    76     /*static*/ void NotificationListener::sendNetworkHelper(const std::string& message, const std::string& sender, notificationSendMode::Value sendMode, unsigned int clientId, bool isCommand, notificationMessageType::Value messageType)
     76    /*static*/ void NotificationListener::sendNetworkHelper(const std::string& message, const std::string& sender, NotificationSendMode sendMode, unsigned int clientId, bool isCommand, NotificationMessageType messageType)
    7777    {
    7878        // If we're in standalone mode or we're already no the right client we create and send the notification/command.
    79         if(GameMode::isStandalone() || sendMode == notificationSendMode::local || (sendMode ==  notificationSendMode::network && Host::getPlayerID() == clientId))
     79        if(GameMode::isStandalone() || sendMode == NotificationSendMode::local || (sendMode ==  NotificationSendMode::network && Host::getPlayerID() == clientId))
    8080        {
    8181            sendHelper(message, sender, isCommand, messageType);
    8282        }
    8383        // If we're on the server (and the server is not the intended recipient of the notification/command) we send it over the network.
    84         else if(GameMode::isServer() && sendMode == notificationSendMode::network && Host::getPlayerID() != clientId)
     84        else if(GameMode::isServer() && sendMode == NotificationSendMode::network && Host::getPlayerID() != clientId)
    8585        {
    86             callStaticNetworkFunction(&NotificationListener::sendHelper, clientId, message, sender, isCommand, (unsigned int)messageType);
     86            callStaticNetworkFunction(&NotificationListener::sendHelper, clientId, message, sender, isCommand, messageType);
    8787        }
    88         else if(GameMode::isServer() && sendMode == notificationSendMode::broadcast)
     88        else if(GameMode::isServer() && sendMode == NotificationSendMode::broadcast)
    8989        {
    9090            // TODO: Works as intended?
    91             callStaticNetworkFunction(&NotificationListener::sendHelper, NETWORK_PEER_ID_BROADCAST, message, sender, isCommand, (unsigned int)messageType);
     91            callStaticNetworkFunction(&NotificationListener::sendHelper, NETWORK_PEER_ID_BROADCAST, message, sender, isCommand, messageType);
    9292        }
    9393    }
     
    105105        The type of the notification.
    106106    */
    107     /*static*/ void NotificationListener::sendHelper(const std::string& message, const std::string& sender, bool isCommand, unsigned int messageType)
     107    /*static*/ void NotificationListener::sendHelper(const std::string& message, const std::string& sender, bool isCommand, NotificationMessageType type)
    108108    {
    109109        // Iterate through all NotificationListeners and notify them by calling the method they overloaded.
    110         for(ObjectList<NotificationListener>::iterator it = ObjectList<NotificationListener>::begin(); it != ObjectList<NotificationListener>::end(); ++it)
     110        for(NotificationListener* listener : ObjectList<NotificationListener>())
    111111        {
    112112            // If the notification is a message.
    113113            if(!isCommand)
    114                 it->registerNotification(message, sender, notificationMessageType::Value(messageType));
     114                listener->registerNotification(message, sender, type);
    115115
    116116            // If the notification is a command.
    117117            if(isCommand)
    118118            {
    119                 notificationCommand::Value command = str2Command(message);
    120                 if(command != notificationCommand::none)
    121                     it->executeCommand(command, sender);
     119                NotificationCommand command = str2Command(message);
     120                if(command != NotificationCommand::none)
     121                    listener->executeCommand(command, sender);
    122122            }
    123123        }
     
    130130        The string to be converted.
    131131    @return
    132         Returns the corresponding enum, notificationCommand::none if the command doesn't exist.
     132        Returns the corresponding enum, NotificationCommand::none if the command doesn't exist.
    133133    */
    134     /*static*/ notificationCommand::Value NotificationListener::str2Command(const std::string& string)
     134    /*static*/ NotificationCommand NotificationListener::str2Command(const std::string& string)
    135135    {
    136         notificationCommand::Value command = notificationCommand::none;
     136        NotificationCommand command = NotificationCommand::none;
    137137
    138138        if(string == NotificationListener::COMMAND_CLEAR)
    139             command = notificationCommand::clear;
     139            command = NotificationCommand::clear;
    140140
    141141        return command;
     
    150150        Returns the corresponding string.
    151151    */
    152     /*static*/ const std::string& NotificationListener::command2Str(notificationCommand::Value command)
     152    /*static*/ const std::string& NotificationListener::command2Str(NotificationCommand command)
    153153    {
    154154        switch(command)
    155155        {
    156             case notificationCommand::clear:
     156            case NotificationCommand::clear:
    157157                return NotificationListener::COMMAND_CLEAR;
    158158            default:
Note: See TracChangeset for help on using the changeset viewer.