void Game::pushState(GameState* state) { deque<Animation*>& animations = state->animations(); GameState* copy; copy = new GameState(); *copy = *state; animations = copy->animations(); if(animations.size() == 0 || !Config::instance()->animate()) { SDL_LockMutex(m_stateLock); m_states.push_back(state); updateBoundary(state); stripState(state); SDL_UnlockMutex(m_stateLock); delete copy; return; } while(animations.size() > 0) { splitState(copy); updateBoundary(copy); SDL_LockMutex(m_stateLock); m_states.push_back(copy); copy = new GameState(); *copy = *m_states.back(); animations = copy->animations(); stripState(m_states.back()); SDL_UnlockMutex(m_stateLock); } delete copy; }