Changeset 7486
- Timestamp:
- Sep 23, 2010, 11:54:16 PM (14 years ago)
- Location:
- code/trunk/src/modules
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/modules/notifications/Notification.h
r7484 r7486 40 40 #include <string> 41 41 #include "core/BaseObject.h" 42 #include "network/synchronisable/Synchronisable.h"43 42 44 43 namespace orxonox -
code/trunk/src/modules/notifications/NotificationManager.cc
r7484 r7486 116 116 @param sender 117 117 The sender that sent the notification. 118 */ 119 /*static*/ void NotificationManager::sendNotification(const std::string& message, unsigned int clientId, const std::string& sender) 118 @param isLocal 119 If this is set to true (false is default), then the Notification is sent to the client where this function is executed, meaning the Notification is sent locally. 120 */ 121 /*static*/ void NotificationManager::sendNotification(const std::string& message, unsigned int clientId, const std::string& sender, bool isLocal) 120 122 { 121 123 // If we're in standalone mode or we're already no the right client we create and send the Notification. 122 if(GameMode::isStandalone() || Host::getPlayerID() == clientId)124 if(GameMode::isStandalone() || isLocal || Host::getPlayerID() == clientId) 123 125 { 124 126 Notification* notification = new Notification(message); -
code/trunk/src/modules/notifications/NotificationManager.h
r7484 r7486 76 76 77 77 //! Sends a Notification with the specified message to the specified client from the specified sender. 78 static void sendNotification(const std::string& message, unsigned int clientId, const std::string& sender = NotificationManager::NONE );78 static void sendNotification(const std::string& message, unsigned int clientId, const std::string& sender = NotificationManager::NONE, bool isLocal = false); 79 79 80 80 bool registerNotification(Notification* notification); //!< Registers a Notification within the NotificationManager. -
code/trunk/src/modules/notifications/NotificationQueue.h
r7484 r7486 58 58 }; 59 59 60 //! Struct to allow ordering of NotificationContainers.60 //! Struct to allow ordering of @ref orxonox::NotificationContainer "NotificationContainers". 61 61 struct NotificationContainerCompare { 62 62 bool operator() (const NotificationContainer* const & a, const NotificationContainer* const & b) const … … 73 73 - 'size': The size of the NotificationQueue, it specifies how many @ref orxonox::Notification "Notifications" are displayed at once at the most. 74 74 - 'displayTime': The time a @ref orxonox::Notification "Notification" is displayed with this NotificationQueue. 75 75 76 @author 76 77 Damian 'Mozork' Frick -
code/trunk/src/modules/objects/Script.cc
r7483 r7486 61 61 The creator of this object. 62 62 */ 63 Script::Script(BaseObject* creator) : BaseObject(creator) , Synchronisable(creator)63 Script::Script(BaseObject* creator) : BaseObject(creator) 64 64 { 65 65 RegisterObject(Script); … … 79 79 Script::~Script() 80 80 { 81 //if(this->isInitialized() && this->luaState_ != NULL) 82 // delete this->luaState_; 81 83 82 } 84 83 … … 105 104 106 105 if(this->isOnLoad()) // If the object is onLoad the code is executed at once for the server. 107 this->execute(0 );106 this->execute(0, true); 108 107 } 109 108 … … 178 177 @param clientId 179 178 The Id of the client the Script should be executed for. 180 @param fromCallback181 Whether this method is executed in response to the connectedCallback().182 */ 183 void Script::execute(unsigned int clientId, bool fromCallback)179 @param onLoad 180 Whether this method is executed as a result of the onLoad parameter being set to true. Default is false. 181 */ 182 void Script::execute(unsigned int clientId, bool onLoad) 184 183 { 185 184 // If this is the server or we're in standalone mode we check whether we still want to execute the code and if so decrease the number of remaining executions. 186 if(GameMode::is Server() || GameMode::isStandalone())185 if(GameMode::isMaster()) 187 186 { 188 187 // If the number of executions have been used up. … … 194 193 if(GameMode::isStandalone() || Host::getPlayerID() == clientId) 195 194 { 196 this->executeHelper(this->getCode(), this->getMode(), this->getNeedsGraphics()); 195 this->executeHelper(this->getCode(), this->getMode(), this->getNeedsGraphics()); 196 if(GameMode::isMaster() && !onLoad && this->times_ != Script::INF) // Decrement the number of remaining executions. 197 this->remainingExecutions_--; 197 198 } 198 199 199 200 // If this is the server and we're not on the client we want to be. 200 if(!GameMode::isStandalone() && GameMode::isServer() && Host::getPlayerID() != clientId) 201 { 202 // If this is not the result of a clientConnected callback and we want to execute the code for all clients. 203 //TODO: In this case does the server get executed as well? 204 if(!fromCallback && this->isForAll()) 201 if(GameMode::isServer() && Host::getPlayerID() != clientId) 202 { 203 // If we want to execute the code for all clients and the server. 204 if(this->isForAll()) 205 205 { 206 206 const std::map<unsigned int, PlayerInfo*> clients = PlayerManager::getInstance().getClients(); … … 251 251 { 252 252 // If this is the server and the Script is specified as being 'onLoad'. 253 if( !GameMode::isStandalone() &&GameMode::isServer() && this->isOnLoad())254 { 255 this->execute(clientId, true);253 if(GameMode::isServer() && this->isOnLoad()) 254 { 255 callStaticNetworkFunction(Script::executeHelper, clientId, this->getCode(), this->getMode(), this->getNeedsGraphics()); 256 256 } 257 257 } -
code/trunk/src/modules/objects/Script.h
r7484 r7486 37 37 38 38 #include "core/BaseObject.h" 39 #include "network/synchronisable/Synchronisable.h"40 39 #include "network/ClientConnectionListener.h" 41 40 … … 84 83 Damian 'Mozork' Frick 85 84 */ 86 class _ObjectsExport Script : public BaseObject, public Synchronisable, publicClientConnectionListener85 class _ObjectsExport Script : public BaseObject, public ClientConnectionListener 87 86 { 88 87 public: … … 94 93 95 94 bool trigger(bool triggered, BaseObject* trigger); //!< Is called when an event comes in trough the event port. 96 void execute(unsigned int clientId, bool fromCallback= false); //!< Executes the Scripts code for the input client, depending on the mode.95 void execute(unsigned int clientId, bool onLoad = false); //!< Executes the Scripts code for the input client, depending on the mode. 97 96 static void executeHelper(const std::string& code, const std::string& mode, bool needsGraphics); //!< Helper method that is used to reach this Script object on other clients. 98 97
Note: See TracChangeset
for help on using the changeset viewer.