示例#1
0
void SceneManager::sceneChange() {
	int activeScreenNumber = 0;

	// Handle removing the scene
	if (_scene) {
		activeScreenNumber = _scene->_activeScreenNumber;
		_scene->remove();
	}

	// Clear the scene objects
	SynchronizedList<SceneObject *>::iterator io = g_globals->_sceneObjects->begin();
	while (io != g_globals->_sceneObjects->end()) {
		SceneObject *sceneObj = *io;
		++io;
		sceneObj->removeObject();
	}

	// Clear the hotspot list
	SynchronizedList<SceneItem *>::iterator ii = g_globals->_sceneItems.begin();
	while (ii != g_globals->_sceneItems.end()) {
		SceneItem *sceneItem = *ii;
		++ii;
		sceneItem->remove();
	}

	// TODO: Clear _list_45BAA list

	// If there is an active scene, deactivate it
	if (_scene) {
		_previousScene = _sceneNumber;

		delete _scene;
		_scene = NULL;
		_sceneNumber = -1;
	}

	// Set the next scene to be active
	_sceneNumber = _nextSceneNumber;

	// Free any regions
	disposeRegions();

	// Ensure that the same number of objects are registered now as when the scene started
	if (_objectCount > 0) {
		assert(_objectCount == g_saver->getObjectCount());
	}
	_objectCount = g_saver->getObjectCount();
	g_globals->_sceneHandler->_delayTicks = 2;

	// Instantiate and set the new scene
	_scene = getNewScene();

	if (!g_saver->getMacroRestoreFlag())
		_scene->postInit();
	else
		_scene->loadScene(activeScreenNumber);
}
示例#2
0
// free all the memory malloced for the game
void disposeGame(Game g) {
    if (g->mostARCs->ARCGrants == 0) {
        free(g->mostARCs);
    }
    if (g->mostPubs->papers == 0) {
        free(g->mostPubs);
    }

    disposeEdgesAndPlayers(g);
    disposePoints(g);
    disposeRegions(g);

    free(g->gameBoard);
    free(g);
}