Exemple #1
0
/**
**  Cleanup modules.
**
**  Call each module to clean up.
*/
void CleanModules()
{
	EndReplayLog();
	CleanMessages();

	CleanIcons();
	CleanCursors();
	CleanUserInterface();
	CleanFonts();
	CleanTriggers();
	FreeAi();
	PlayerRaces.Clean();
	CleanConstructions();
	CleanDecorations();
	CleanMissiles();
	CleanUnits();
	CleanUnitTypes();
	CleanPlayers();
	CleanSelections();
	CleanGroups();
	CleanUpgrades();
	CleanDependencies();
	CleanButtons();
	CleanMissileTypes();
	Map.Clean();
	Map.CleanFogOfWar();
	CParticleManager::exit();
	CleanReplayLog();
	CleanSpells();
	FreePathfinder();

	UnitTypeVar.Init(); // internal script. should be to a better place, don't find for restart.
}
Exemple #2
0
void StartReplay(const std::string &filename, bool reveal)
{
	std::string replay;

	CleanPlayers();
	ExpandPath(replay, filename);
	LoadReplay(replay);

	ReplayRevealMap = reveal;

	StartMap(CurrentMapPath, false);
}
void StartSavedGame(const std::string &filename)
{
	std::string path;

	SaveGameLoading = true;
	CleanPlayers();
	ExpandPath(path, filename);
	LoadGame(path);

	StartMap(filename, false);
	//SetDefaultTextColors(nc, rc);
}
Exemple #4
0
/**
**  Load a game to file.
**
**  @param filename  File name to be loaded.
*/
void LoadGame(const std::string &filename)
{
	//Wyrmgus start
	CleanPlayers(); //clean players, as they may not have been cleansed after a scenario
	CurrentCustomHero = nullptr; //otherwise the loaded game will have an extra hero for the current custom hero
	//Wyrmgus end
	
	// log will be enabled if found in the save game
	CommandLogDisabled = true;
	SaveGameLoading = true;

	//Wyrmgus start
//	SetDefaultTextColors(FontYellow, FontWhite);
	SetDefaultTextColors(UI.NormalFontColor, UI.ReverseFontColor);
	//Wyrmgus end
	LoadFonts();
	
	//Wyrmgus start
	InitPlayers();
	//Wyrmgus end

	LuaGarbageCollect();
	InitUnitTypes(1);
	//Wyrmgus start
	CalculateItemsToLoad();
	//Wyrmgus end
	LuaLoadFile(filename);
	LuaGarbageCollect();

	PlaceUnits();

	const unsigned long game_cycle = GameCycle;
	const unsigned long long current_total_hours = CDate::CurrentTotalHours;
	const unsigned syncrand = SyncRandSeed;
	const unsigned synchash = SyncHash;

	InitModules();
	LoadModules();

	GameCycle = game_cycle;
	CDate::CurrentTotalHours = current_total_hours;
	SyncRandSeed = syncrand;
	SyncHash = synchash;
	SelectionChanged();
}
Exemple #5
0
void StartMap(const std::string &filename, bool clean)
{
	std::string nc, rc;

	gcn::Widget *oldTop = Gui->getTop();
	gcn::Container *container = new gcn::Container();
	Containers.push_back(container);
	container->setDimension(gcn::Rectangle(0, 0, Video.Width, Video.Height));
	container->setOpaque(false);
	Gui->setTop(container);

	NetConnectRunning = 0;
	InterfaceState = IfaceStateNormal;

	//  Create the game.
	DebugPrint("Creating game with map: %s\n" _C_ filename.c_str());
	if (clean) {
		CleanPlayers();
	}
	GetDefaultTextColors(nc, rc);

	CreateGame(filename.c_str(), &Map);

	UI.StatusLine.Set(NameLine);
	SetMessage("%s", _("Do it! Do it now!"));

	//  Play the game.
	GameMainLoop();

	//  Clear screen
	Video.ClearScreen();
	Invalidate();

	CleanGame();
	InterfaceState = IfaceStateMenu;
	SetDefaultTextColors(nc, rc);

	Gui->setTop(oldTop);
	Containers.erase(std::find(Containers.begin(), Containers.end(), container));
	delete container;
}
Exemple #6
0
/**
**  Cleanup modules.
**
**  Call each module to clean up.
*/
void CleanModules()
{
	EndReplayLog();
	CleanMessages();

	CleanIcons();
	CleanCursors();
	CleanUserInterface();
	CleanFonts();
	CTrigger::ClearTriggers();
	FreeAi();
	PlayerRaces.Clean();
	CAge::ClearAges();
	CCalendar::ClearCalendars();
	CCharacter::ClearCharacters();
	CCivilization::ClearCivilizations();
	CleanConstructions();
	CCurrency::ClearCurrencies();
	CleanDecorations();
	CDeity::ClearDeities();
	//Wyrmgus start
	CDialogue::ClearDialogues();
	CDeityDomain::ClearDeityDomains();
	CleanGrandStrategyEvents();
	//Wyrmgus end
	CHistoricalUnit::ClearHistoricalUnits();
	CMapTemplate::ClearMapTemplates();
	CleanMissiles();
	CPantheon::ClearPantheons();
	//Wyrmgus start
	CPlane::ClearPlanes();
	CleanProvinces();
	CleanQuests();
	CReligion::ClearReligions();
	CSchoolOfMagic::ClearSchoolsOfMagic();
	CSite::ClearSites();
	CleanTexts();
	CleanUniqueItems();
	//Wyrmgus end
	CTimeline::ClearTimelines();
	CleanUnits();
	CleanUnitTypes();
	CWorld::ClearWorlds();
	CleanPlayers();
	CleanSelections();
	CleanGroups();
	CleanUpgrades();
	CleanButtons();
	CButtonLevel::ClearButtonLevels();
	CleanMissileTypes();
	Map.Clean();
	Map.CleanFogOfWar();
	CTerrainType::ClearTerrainTypes();
	CTimeOfDay::ClearTimesOfDay();
	CTimeOfDaySchedule::ClearTimeOfDaySchedules();
	CSeason::ClearSeasons();
	CSeasonSchedule::ClearSeasonSchedules();
	CParticleManager::exit();
	CleanReplayLog();
	CSpell::ClearSpells();
	FreePathfinder();

	UnitTypeVar.Init(); // internal script. should be to a better place, don't find for restart.
}