Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 20, 2010, 10:36:48 PM (14 years ago)
Author:
dafrick
Message:

A lot of cleanup, mostly increasing output levels, which means, that the console is no longer cluttered by lots and lots of Quest-stuff (the log file still is, but that should be ok…).
Also some possible bugs (or let's say pitfalls) removed, which have been around for a long time and didn't cause any problems so far. Now they never will.
Also, regarding my previous commit. Quests seem tu work just fine, even the second time the level is loaded, which is awesome.

Ergo: Questsystem/Notificationsystem segfault upon loading a level with Quests/Notifications in it twice is now officially resolved.

Location:
code/branches/presentation3/src/modules/questsystem/notifications
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation3/src/modules/questsystem/notifications/Notification.cc

    r6417 r6945  
    4040{
    4141
     42    CreateUnloadableFactory(Notification);
     43   
    4244    /**
    4345    @brief
     
    5658        The message of the Notification.
    5759    */
    58     Notification::Notification(const std::string & message) : BaseObject(NULL)
     60    Notification::Notification(BaseObject* creator, const std::string & message) : BaseObject(creator)
    5961    {
    6062        this->message_ = message;
     
    6769    Notification::~Notification()
    6870    {
     71       
    6972    }
    7073
  • code/branches/presentation3/src/modules/questsystem/notifications/Notification.h

    r5781 r6945  
    5353        public:
    5454            Notification(BaseObject* creator);
    55             Notification(const std::string & message);
     55            Notification(BaseObject* creator, const std::string & message);
    5656            virtual ~Notification();
    5757
  • code/branches/presentation3/src/modules/questsystem/notifications/NotificationManager.cc

    r6944 r6945  
    118118    @brief
    119119        Unregisters a Notification within the NotificationManager.
     120    @param notification
     121        A pointer to the Notification to be unregistered.
     122    @param listener
     123        A pointer to the NotificationListener the Notification is unregistered for.
    120124    */
    121125    void NotificationManager::unregisterNotification(Notification* notification, NotificationListener* listener)
     
    124128        assert(listener);
    125129
     130        // If the Notification was removed from the list of Notifications of the input NotificationListener, the counter for the Notification of the number of NotificationListeners it is present in is decremented.
    126131        if(this->removeNotification(notification, *(this->notificationLists_.find(this->listenerList_.find(listener)->second)->second)))
    127132            this->listenerCounter_[notification] = this->listenerCounter_[notification] - 1;
     133
     134        // If the Notification is no longer present in any of the NotificationListeners it can be removed from the map of all Notifications and be destroyed.
    128135        if(this->listenerCounter_[notification] == (unsigned int) 0)
    129136        {
    130137            this->removeNotification(notification, this->allNotificationsList_);
     138            this->listenerCounter_.erase(notification);
    131139            notification->destroy();
    132140        }
     
    138146    @brief
    139147        Helper method that removes an input notification form an input map.
     148    @param notification
     149        A pointer to the notification to be removed.
     150    @param map
     151        The map the notification should be removed from.
     152    @return
     153        Returns true if successful.
    140154    */
    141155    bool NotificationManager::removeNotification(Notification* notification, std::multimap<std::time_t, Notification*>& map)
    142156    {
     157        // Iterates through all items in the map until the Notification is found.
     158        //TODO: Do more efficiently?
    143159        for(std::multimap<std::time_t, Notification*>::iterator it = map.begin(); it != map.end(); it++)
    144160        {
     
    222238        this->listenerList_.erase(listener);
    223239        this->notificationLists_.erase(identifier);
    224         delete map;
     240
     241        // If the map is not the map of all notifications, delete it.
     242        if(map != &this->allNotificationsList_)
     243            delete map;
    225244
    226245        COUT(4) << "NotificationListener unregistered with the NotificationManager." << std::endl;
  • code/branches/presentation3/src/modules/questsystem/notifications/NotificationManager.h

    r6944 r6945  
    6060            virtual ~NotificationManager();
    6161
    62             static const std::string ALL;
    63             static const std::string NONE;
     62            static const std::string ALL; //!< Static string to indicate a sender that sends to all NotificationListeners.
     63            static const std::string NONE; //!< Static string to indicare a sender that sends to no specific NotificationListener.
    6464
    6565            bool registerNotification(Notification* notification); //!< Registers a Notification within the NotificationManager.
     
    9999            std::map<Notification*, unsigned int> listenerCounter_; //!< A container to store the number of NotificationListeners a Notification is registered with.
    100100
    101             bool removeNotification(Notification* notification, std::multimap<std::time_t, Notification*>& map);
    102 
     101            bool removeNotification(Notification* notification, std::multimap<std::time_t, Notification*>& map); //!< Helper method that removes an input notification form an input map.
    103102
    104103    };
  • code/branches/presentation3/src/modules/questsystem/notifications/NotificationQueue.cc

    r6944 r6945  
    124124        XMLPortParam(NotificationQueue, "position", setPosition, getPosition, xmlElement, mode);
    125125
    126         COUT(3) << "NotificationQueue created." << std::endl;
     126        COUT(3) << "NotificationQueue '" << this->getName() << "' created." << std::endl;
    127127    }
    128128
     
    179179        delete notifications;
    180180
    181         COUT(3) << "NotificationQueue updated." << std::endl;
     181        COUT(4) << "NotificationQueue '" << this->getName() << "' updated." << std::endl;
    182182    }
    183183
     
    202202        }
    203203
    204         COUT(3) << "NotificationQueue updated. A new Notifications has been added." << std::endl;
     204        COUT(4) << "NotificationQueue '" << this->getName() << "' updated. A new Notifications has been added." << std::endl;
    205205    }
    206206
     
    429429            return false;
    430430
     431        // Unregister the NotificationQueue with the NotificationManager.
    431432        NotificationManager::getInstance().unregisterNotification(container->notification, this);
    432433       
  • code/branches/presentation3/src/modules/questsystem/notifications/NotificationQueue.h

    r6944 r6945  
    7171
    7272        Creating a NotificationQueue through XML goes as follows:
     73        Be aware that the NotificationQueue must be inside the <Level></Level> tags or bad things will happen.
    7374        <NotificationQueue
    7475            name = "SuperQueue" //Name of your OverlayQueue.
Note: See TracChangeset for help on using the changeset viewer.