- Timestamp:
- Sep 21, 2010, 11:15:44 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/modules/notifications/NotificationDispatcher.cc
r7456 r7474 35 35 36 36 #include "core/CoreIncludes.h" 37 #include "core/EventIncludes.h" 37 38 #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 39 46 #include "Notification.h" 40 47 #include "NotificationManager.h" 41 #include "interfaces/PlayerTrigger.h"42 #include "infos/PlayerInfo.h"43 #include "worldentities/pawns/Pawn.h"44 48 45 49 namespace orxonox … … 48 52 CreateUnloadableFactory(NotificationDispatcher); 49 53 54 registerMemberNetworkFunction(NotificationDispatcher, dispatch); 55 50 56 /** 51 57 @brief 52 58 Default constructor. Initializes the object. 53 59 */ 54 NotificationDispatcher::NotificationDispatcher(BaseObject* creator) : BaseObject(creator) 60 NotificationDispatcher::NotificationDispatcher(BaseObject* creator) : BaseObject(creator), Synchronisable(creator) 55 61 { 56 62 RegisterObject(NotificationDispatcher); 57 63 58 64 this->sender_ = NotificationManager::NONE; 65 this->registerVariables(); 59 66 } 60 67 … … 86 93 } 87 94 95 void NotificationDispatcher::registerVariables(void) 96 { 97 registerVariable(this->sender_, VariableDirection::ToClient); 98 } 99 88 100 /** 89 101 @brief … … 94 106 void NotificationDispatcher::dispatch(unsigned int clientId) 95 107 { 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 } 100 117 } 101 118 … … 123 140 if(pTrigger != NULL) 124 141 { 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. 126 143 return false; 127 144 else … … 133 150 if(pawn == NULL) 134 151 { 135 COUT(4) << "The QuestEffectBeaconwas 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; 136 153 return false; 137 154 } 138 155 139 // !Extract the PlayerInfo from the Pawn.156 // Extract the PlayerInfo from the Pawn. 140 157 PlayerInfo* player = pawn->getPlayer(); 141 158
Note: See TracChangeset
for help on using the changeset viewer.