Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7911


Ignore:
Timestamp:
Feb 18, 2011, 12:08:00 AM (13 years ago)
Author:
landauf
Message:

Pong gametype should delete the objects it created

Location:
code/trunk/src/modules/pong
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/modules/pong/Pong.cc

    r7865 r7911  
    6060
    6161        this->botclass_ = Class(PongBot);
     62    }
     63
     64    Pong::~Pong()
     65    {
     66        if (this->isInitialized())
     67            this->cleanup();
     68    }
     69
     70    void Pong::cleanup()
     71    {
     72        if (this->ball_)
     73        {
     74            this->ball_->destroy();
     75            this->ball_ = 0;
     76        }
     77
     78        for (size_t i = 0; i < 2; ++i)
     79        {
     80            if (this->bat_[0])
     81            {
     82                this->bat_[0]->destroy();
     83                this->bat_[0] = 0;
     84            }
     85        }
    6286    }
    6387
     
    123147    void Pong::end()
    124148    {
    125         if (this->ball_)
    126         {
    127             this->ball_->destroy();
    128             this->ball_ = 0;
    129         }
     149        this->cleanup();
    130150
    131151        Deathmatch::end();
  • code/trunk/src/modules/pong/Pong.h

    r7865 r7911  
    4141        public:
    4242            Pong(BaseObject* creator);
    43             virtual ~Pong() {}
     43            virtual ~Pong();
    4444
    4545            virtual void start();
     
    6060
    6161            void startBall();
     62            void cleanup();
    6263
    6364            WeakPtr<PongCenterpoint> center_;
Note: See TracChangeset for help on using the changeset viewer.