Stop race event manager if exiting lobby

This commit is contained in:
Benau 2018-04-18 13:41:21 +08:00
parent 9a32bdcbe1
commit b6caf00bfc
3 changed files with 18 additions and 21 deletions

View File

@ -42,6 +42,8 @@ LobbyProtocol::LobbyProtocol(CallbackObject* callback_object)
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
LobbyProtocol::~LobbyProtocol() LobbyProtocol::~LobbyProtocol()
{ {
if (RaceEventManager::getInstance())
RaceEventManager::getInstance()->stop();
delete m_game_setup; delete m_game_setup;
} // ~LobbyProtocol } // ~LobbyProtocol

View File

@ -49,19 +49,6 @@ void RaceEventManager::update(int ticks)
} }
} // update } // update
// ----------------------------------------------------------------------------
void RaceEventManager::start(std::shared_ptr<GameEventsProtocol> gep)
{
m_game_events_protocol = gep;
m_running = true;
} // start
// ----------------------------------------------------------------------------
void RaceEventManager::stop()
{
m_running = false;
} // stop
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
bool RaceEventManager::isRaceOver() bool RaceEventManager::isRaceOver()
{ {

View File

@ -48,17 +48,25 @@ private:
virtual ~RaceEventManager(); virtual ~RaceEventManager();
public: public:
// ------------------------------------------------------------------------
void update(int ticks); void update(int ticks);
// ------------------------------------------------------------------------
void start(std::shared_ptr<GameEventsProtocol> gep); void start(std::shared_ptr<GameEventsProtocol> gep)
void stop(); {
bool isRaceOver(); m_game_events_protocol = gep;
m_running = true;
void collectedItem(Item *item, AbstractKart *kart); }
void kartFinishedRace(AbstractKart *kart, float time); // ------------------------------------------------------------------------
void stop() { m_running = false; }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Returns if this instance is in running state or not. */ /** Returns if this instance is in running state or not. */
bool isRunning() { return m_running; } bool isRunning() { return m_running; }
// ------------------------------------------------------------------------
bool isRaceOver();
// ------------------------------------------------------------------------
void collectedItem(Item *item, AbstractKart *kart);
// ------------------------------------------------------------------------
void kartFinishedRace(AbstractKart *kart, float time);
}; };