Changeset 8891 for code/trunk/src/modules
- Timestamp:
- Oct 12, 2011, 7:50:43 PM (13 years ago)
- Location:
- code/trunk
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
-
code/trunk/src/modules/notifications/NotificationDispatcher.cc
r8858 r8891 50 50 CreateUnloadableFactory(NotificationDispatcher); 51 51 52 registerMemberNetworkFunction(NotificationDispatcher, broadcastHelper); 52 53 registerMemberNetworkFunction(NotificationDispatcher, dispatch); 53 54 … … 61 62 62 63 this->sender_ = NotificationListener::NONE; 64 this->bBroadcast_ = false; 63 65 this->registerVariables(); 64 66 } … … 81 83 SUPER(NotificationDispatcher, XMLPort, xmlelement, mode); 82 84 83 XMLPortParam(NotificationDispatcher, "sender", getSender, setSender, xmlelement, mode); 84 85 XMLPortEventSink(NotificationDispatcher, BaseObject, "trigger", trigger, xmlelement, mode); //TODO: Change BaseObject to MultiTrigger as soon as MultiTrigger is the base of all triggers. 85 XMLPortParam(NotificationDispatcher, "sender", setSender, getSender, xmlelement, mode); 86 XMLPortParam(NotificationDispatcher, "broadcast", setBroadcasting, isBroadcasting, xmlelement, mode); 87 88 XMLPortEventSink(NotificationDispatcher, BaseObject, "trigger", trigger, xmlelement, mode); 86 89 } 87 90 … … 100 103 { 101 104 registerVariable(this->sender_, VariableDirection::ToClient); 105 } 106 107 /** 108 @brief 109 Broadcasts a specific Notification. 110 */ 111 void NotificationDispatcher::broadcast(void) 112 { 113 // TODO: Needed? 114 const std::string message = this->createNotificationMessage(); 115 NotificationListener::sendNotification(message, this->getSender(), notificationMessageType::info, notificationSendMode::local); 116 117 // Broadcast 118 if(!GameMode::isStandalone()) 119 { 120 callMemberNetworkFunction(NotificationDispatcher, broadcastHelper, this->getObjectID(), NETWORK_PEER_ID_BROADCAST); 121 } 122 } 123 124 /** 125 @brief 126 Helper function for broadcast. 127 */ 128 void NotificationDispatcher::broadcastHelper(void) 129 { 130 this->dispatch(Host::getPlayerID()); 102 131 } 103 132 … … 110 139 void NotificationDispatcher::dispatch(unsigned int clientId) 111 140 { 112 if(GameMode::isStandalone() || Host::getPlayerID() == clientId || this->getSyncMode() == 0x0) 141 // We don't call sendNotification() directly on the server, because if might be necessary that createNotificationMessage() is executed on the client as the message may be client-specific. 142 if(GameMode::isStandalone() || Host::getPlayerID() == clientId || this->getSyncMode() == ObjectDirection::None) 113 143 { 114 144 const std::string message = this->createNotificationMessage(); … … 139 169 orxout(verbose, context::notifications) << "NotificationDispatcher (&" << this << ") triggered." << endl; 140 170 171 // If the NotificationDispatcher is set to broadcast. 172 if(this->isBroadcasting()) 173 { 174 this->broadcast(); 175 return true; 176 } 177 141 178 PlayerTrigger* pTrigger = orxonox_cast<PlayerTrigger*>(trigger); 142 179 PlayerInfo* player = NULL; -
code/trunk/src/modules/notifications/NotificationDispatcher.h
r7552 r8891 50 50 A NotificationDispatcher is an entity that, upon being triggered, dispatches (or sends) a specified @ref orxonox::Notification "Notification". 51 51 52 There is one parameter to be set, the @b sender . The sender specifies the part of Orxonox the sent @ref orxonox::Notification "Notification" comes from. The default value is set by the classes implementing NotificationDispatcher. 52 There are two parameter to be set: 53 - The @b sender . The sender specifies the part of Orxonox the sent @ref orxonox::Notification "Notification" comes from. The default value is set by the classes implementing NotificationDispatcher. 54 - The @b broadcast . Specifies whether messages are broadcast (i.e. sent to all clients) or just sent to a specific player. 53 55 54 56 Its standard usage is: … … 62 64 </NotificationDispatcher> 63 65 @endcode 64 But keep in mind, that NotificationDispatcher is an abstract class and in this example @ref orxonox::PlayerTrigger "PlayerTrigger" stands for any event that is caused by a @ref orxonox::PlayerTrigger "PlayerTrigger", so instead of @ref orxonox::PlayerTrigger "PlayerTrigger", there could be a @ref orxonox::DistanceTrigger "DistanceTrigger", or a @ref orxonox::DistanceMultiTrigger "DistanceMutliTrigger", or even an @ref orxonox::EventListener "EventListener" that waits for an event coming from any kind of @ref orxonox::PlayerTrigger "PlayerTrigger". 66 But keep in mind, that NotificationDispatcher is an abstract class. 67 Also in this example @ref orxonox::PlayerTrigger "PlayerTrigger" stands for any event that is caused by a @ref orxonox::PlayerTrigger "PlayerTrigger", so instead of @ref orxonox::PlayerTrigger "PlayerTrigger", there could be a @ref orxonox::DistanceTrigger "DistanceTrigger", or a @ref orxonox::DistanceMultiTrigger "DistanceMutliTrigger", or even an @ref orxonox::EventListener "EventListener" that waits for an event coming from any kind of @ref orxonox::PlayerTrigger "PlayerTrigger". 68 If the NotificationDispatcher is not set to broadcast only events caused by @ref orxonox::PlayerTrigger "PlayerTriggers" trigger a message since the information obtained by the @ref orxonox::PlayerTrigger "PlayerTrigger" is used to identify the client to which the message should be sent. 65 69 66 70 @author … … 84 88 const std::string& getSender(void) const 85 89 { return this->sender_; } 86 90 /** 87 91 @brief Set the sender of the Notification dispatched by this NotificationDispatcher. 88 92 @param sender The name of the sender. … … 91 95 { this->sender_ = sender; } 92 96 93 void dispatch(unsigned int clientId); //!< Dispatches a specific Notification. 97 /** 98 @brief Check whether the NotificationDispatcher is set to broadcast. 99 @return Returns true if the NotificationDispatcher is set to broadcast. 100 */ 101 bool isBroadcasting(void) const 102 { return this->bBroadcast_; } 103 /** 104 @brief Set the NotificationDispatcher to broadcast. 105 @param broadcast Whether the NotificationDispatcher is set to broadcast or singlecast. 106 */ 107 void setBroadcasting(bool v) 108 { this->bBroadcast_ = v; } 109 110 void broadcast(void); //!< Broadcasts a specific Notification. 111 void broadcastHelper(void); //!< Helper function for broadcast. 112 void dispatch(unsigned int clientId); //!< Dispatches a specific Notification to a given client. 94 113 bool trigger(bool triggered, BaseObject* trigger); //!< Is called when the NotificationDispatcher is triggered. 95 114 96 115 protected: 97 116 std::string sender_; //!< The name of the sender of the Notification dispatched by this NotificationDispatcher. 117 bool bBroadcast_; //!< Whether the NotificationDispatcher is broadcasting. 98 118 99 119 void registerVariables(void); //!< Register some variables for synchronisation. … … 105 125 */ 106 126 virtual const std::string& createNotificationMessage(void) 107 { return *(new std::string("")); }127 { return BLANKSTRING; } 108 128 109 129 }; -
code/trunk/src/modules/overlays/hud/HUDNavigation.cc
r8858 r8891 63 63 { 64 64 SetConfigValue(markerLimit_, 3); 65 65 66 } 66 67 … … 77 78 setTextSize ( 0.05f ); 78 79 setNavMarkerSize ( 0.05f ); 80 setDetectionLimit( 10000.0f ); 79 81 } 80 82 … … 95 97 SUPER ( HUDNavigation, XMLPort, xmlelement, mode ); 96 98 97 XMLPortParam ( HUDNavigation, "font", setFont, getFont, xmlelement, mode ); 98 XMLPortParam ( HUDNavigation, "textSize", setTextSize, getTextSize, xmlelement, mode ); 99 XMLPortParam ( HUDNavigation, "navMarkerSize", setNavMarkerSize, getNavMarkerSize, xmlelement, mode ); 99 XMLPortParam ( HUDNavigation, "font", setFont, getFont, xmlelement, mode ); 100 XMLPortParam ( HUDNavigation, "textSize", setTextSize, getTextSize, xmlelement, mode ); 101 XMLPortParam ( HUDNavigation, "navMarkerSize", setNavMarkerSize, getNavMarkerSize, xmlelement, mode ); 102 XMLPortParam ( HUDNavigation, "detectionLimit", setDetectionLimit, getDetectionLimit, xmlelement, mode ); 100 103 } 101 104 … … 161 164 162 165 unsigned int markerCount_ = 0; 163 166 bool closeEnough_ = false; //only display objects that are close enough to be relevant for the player 164 167 // for (ObjectMap::iterator it = activeObjectList_.begin(); it != activeObjectList_.end(); ++it) 165 168 for ( sortedList::iterator listIt = sortedObjectList_.begin(); listIt != sortedObjectList_.end(); ++markerCount_, ++listIt ) 166 169 { 167 170 ObjectMap::iterator it = activeObjectList_.find ( listIt->first ); 168 169 if ( markerCount_ < markerLimit_ )171 closeEnough_ = listIt->second < detectionLimit_ ; 172 if ( markerCount_ < markerLimit_ && (closeEnough_ || detectionLimit_ < 0) ) // display on HUD if the statement is true 170 173 { 171 174 … … 277 280 it->second.text_->show(); 278 281 } 279 else 282 else // do not display on HUD 280 283 { 281 284 it->second.panel_->hide(); … … 309 312 void HUDNavigation::addObject ( RadarViewable* object ) 310 313 { 311 if( showObject(object) ==false )314 if( showObject(object) == false ) 312 315 return; 313 316 … … 396 399 return false; 397 400 assert( rv->getWorldEntity() ); 398 if ( rv->getWorldEntity()->isVisible() ==false || rv->getRadarVisibility()==false )401 if ( rv->getWorldEntity()->isVisible() == false || rv->getRadarVisibility() == false ) 399 402 return false; 400 403 return true; -
code/trunk/src/modules/overlays/hud/HUDNavigation.h
r7401 r8891 85 85 { return navMarkerSize_; } 86 86 87 void setDetectionLimit( float limit ) 88 { this->detectionLimit_ = limit; } 89 float getDetectionLimit() const 90 { return this->detectionLimit_; } 91 87 92 void setTextSize ( float size ); 88 93 float getTextSize() const; … … 102 107 float textSize_; 103 108 104 unsigned int markerLimit_; ;//TODO: is it possible to set this over the console and/or the IG-Setting105 106 109 unsigned int markerLimit_; //TODO: is it possible to set this over the console and/or the IG-Setting 110 float detectionLimit_; //!< Objects that are more far away than detectionLimit_ are not displayed on the HUD. 10000.0f is the default value. 111 //!< In order to bypass this behaviour, set a negative detectionLimit_. Then the detection range is "infinite". 107 112 }; 108 113 } -
code/trunk/src/modules/overlays/hud/HUDRadar.cc
r8858 r8891 64 64 this->shapeMaterials_[RadarViewable::Triangle] = "RadarTriangle.png"; 65 65 this->shapeMaterials_[RadarViewable::Square] = "RadarSquare.png"; 66 66 this->setDetectionLimit( 10000.0f ); 67 67 this->owner_ = 0; 68 68 } … … 93 93 { 94 94 if (object == dynamic_cast<RadarViewable*>(this->owner_)) 95 return; 96 if( showObject(object) == false ) //do not show objects that are "invisible" or "radar invisible" 95 97 return; 96 98 … … 123 125 124 126 void HUDRadar::objectChanged( RadarViewable* rv ) 125 { 126 if (rv == dynamic_cast<RadarViewable*>(this->owner_)) 127 return; 128 assert( this->radarObjects_.find(rv) != this->radarObjects_.end() ); 129 Ogre::PanelOverlayElement* panel = this->radarObjects_[rv]; 130 panel->setMaterialName(TextureGenerator::getMaterialName( 131 shapeMaterials_[rv->getRadarObjectShape()], rv->getRadarObjectColour())); 127 {// The new implementation behaves more precisely, since inactive RadarViewables are not displayed anymore. 128 this->removeObject(rv); 129 this->addObject(rv); 132 130 } 133 131 … … 174 172 coord *= math::pi / 3.5f; // small adjustment to make it fit the texture 175 173 it->second->setPosition((1.0f + coord.x - size) * 0.5f, (1.0f - coord.y - size) * 0.5f); 176 it->second->show(); 174 if( distance < detectionLimit_ || detectionLimit_ < 0 ) 175 it->second->show(); 176 else 177 it->second->hide(); 177 178 178 179 // if this object is in focus, then set the focus marker … … 186 187 } 187 188 189 bool HUDRadar::showObject(RadarViewable* rv) 190 { 191 if ( rv == dynamic_cast<RadarViewable*> ( this->getOwner() ) ) 192 return false; 193 assert( rv->getWorldEntity() ); 194 if ( rv->getWorldEntity()->isVisible()==false || rv->getRadarVisibility()==false ) 195 return false; 196 return true; 197 } 198 199 188 200 void HUDRadar::changedOwner() 189 201 { -
code/trunk/src/modules/overlays/hud/HUDRadar.h
r7880 r8891 57 57 void setHalfDotSizeDistance(float distance) { this->halfDotSizeDistance_ = distance; } 58 58 59 void setDetectionLimit( float limit ) 60 { this->detectionLimit_ = limit; } 61 float getDetectionLimit() const 62 { return this->detectionLimit_; } 63 59 64 float getMaximumDotSize() const { return this->maximumDotSize_; } 60 65 void setMaximumDotSize(float size) { this->maximumDotSize_ = size; } … … 69 74 virtual void objectChanged( RadarViewable* rv ); 70 75 void radarTick(float dt); 76 bool showObject( RadarViewable* rv ); //!< Do not display an object on radar, if showObject(.) is false. 71 77 72 78 void gatherObjects(); … … 83 89 84 90 float sensitivity_; 85 91 float detectionLimit_; 86 92 ControllableEntity* owner_; 87 93 }; -
code/trunk/src/modules/pickup/PickupSpawner.cc
r8858 r8891 181 181 if(GameMode::isMaster() && this->isActive()) 182 182 { 183 SmartPtr<PickupSpawner> temp = this; //Create a smart pointer to keep the PickupSpawner alive until we iterated through all Pawns (in case a Pawn takes the last pickup)183 WeakPtr<PickupSpawner> spawner = this; // Create a smart pointer to keep the PickupSpawner alive until we iterated through all Pawns (in case a Pawn takes the last pickup) 184 184 185 185 // Remove PickupCarriers from the blocked list if they have exceeded their time. … … 195 195 for(ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); ++it) 196 196 { 197 if(spawner == NULL) // Stop if the PickupSpawner has been deleted (e.g. because it has run out of pickups to distribute). 198 break; 199 197 200 Vector3 distance = it->getWorldPosition() - this->getWorldPosition(); 198 201 PickupCarrier* carrier = dynamic_cast<PickupCarrier*>(*it); 199 // If a PickupCarrier, that fits the target-range of the Pickupable spawned by this PickupSpawn der, is in trigger-distance and the carrier is not blocked.202 // If a PickupCarrier, that fits the target-range of the Pickupable spawned by this PickupSpawner, is in trigger-distance and the carrier is not blocked. 200 203 if(distance.length() < this->triggerDistance_ && carrier != NULL && this->blocked_.find(carrier) == this->blocked_.end()) 201 204 { -
code/trunk/src/modules/questsystem/QuestItem.h
r7552 r8891 105 105 QuestDescription* description_; //!< The QuestDescription of the QuestItem. 106 106 107 bool registered_; 107 bool registered_; //!< Whether the QuestItem is registered with the QuestManager. 108 108 109 109 }; -
code/trunk/src/modules/questsystem/QuestManager.cc
r8858 r8891 35 35 36 36 #include "util/Exception.h" 37 #include "util/OrxAssert.h" 37 38 #include "util/ScopedSingletonManager.h" 38 39 #include "core/command/ConsoleCommand.h" … … 60 61 { 61 62 RegisterRootObject(QuestManager); 62 63 63 orxout(internal_info, context::quests) << "QuestManager created." << endl; 64 64 } … … 95 95 bool QuestManager::registerQuest(Quest* quest) 96 96 { 97 assert(quest); 97 if(quest == NULL) 98 { 99 COUT(1) << "Quest pointer is NULL." << endl; 100 return false; 101 } 98 102 99 103 std::pair<std::map<std::string, Quest*>::iterator,bool> result; … … 133 137 bool QuestManager::registerHint(QuestHint* hint) 134 138 { 135 assert(hint); 139 if(hint == NULL) 140 { 141 COUT(1) << "Hint pointer is NULL." << endl; 142 return false; 143 } 136 144 137 145 std::pair<std::map<std::string, QuestHint*>::iterator,bool> result; … … 361 369 Quest* QuestManager::getParentQuest(Quest* quest) 362 370 { 371 OrxAssert(quest, "The input Quest is NULL."); 363 372 return quest->getParentQuest(); 364 373 } … … 374 383 QuestDescription* QuestManager::getDescription(Quest* item) 375 384 { 385 OrxAssert(item, "The input Quest is NULL."); 376 386 return item->getDescription(); 377 387 } … … 387 397 QuestDescription* QuestManager::getDescription(QuestHint* item) 388 398 { 399 OrxAssert(item, "The input QuestHint is NULL."); 389 400 return item->getDescription(); 390 401 } … … 400 411 const std::string QuestManager::getId(Quest* item) const 401 412 { 413 OrxAssert(item, "The input Quest is NULL."); 402 414 return item->getId(); 403 415 } … … 413 425 const std::string QuestManager::getId(QuestHint* item) const 414 426 { 427 OrxAssert(item, "The input QuestHint is NULL."); 415 428 return item->getId(); 416 429 } -
code/trunk/src/modules/weapons/projectiles/Rocket.cc
r8855 r8891 66 66 this->localAngularVelocity_ = 0; 67 67 this->lifetime_ = 100.0f; 68 this->bIsRocket_= true; 68 69 69 70 if (GameMode::isMaster()) … … 134 135 if(this->isInitialized()) 135 136 { 137 this->bIsRocket_= false; 136 138 if (GameMode::isMaster()) 137 139 {
Note: See TracChangeset
for help on using the changeset viewer.