Esempio n. 1
0
ContentDownloadRequest ContentManager::WhatContentForBattleIsRequired(
		const IBattle& battle) {

	ContentDownloadRequest contentNeeded = ContentDownloadRequest();

	const std::string engineVersion = battle.GetBattleOptions().engineVersion;
	const std::string engineName = battle.GetBattleOptions().engineName;

	/*Engine is needed*/
	if (IsHavingSpringVersion(engineName, engineVersion) == false) {
		contentNeeded.EngineRequired(engineVersion);
	}

	/*Map is needed*/
	if (battle.MapExists() == false) {
		contentNeeded.MapRequired(battle.GetHostMapName(), battle.GetHostMapHash());
	}

	/*Game is needed*/
	if (battle.GameExists() == false) {
		contentNeeded.GameRequired(battle.GetHostGameName(), battle.GetHostGameHash());
	}

	return contentNeeded;
}
Esempio n. 2
0
void BattleDataViewCtrl::OnDLMod(wxCommandEvent& /*event*/) {
	const IBattle* battle = GetSelectedItem();

	if (battle == nullptr) {
		return;
	} else {
		ContentDownloadRequest req;
		req.GameRequired(battle->GetHostGameName(), battle->GetHostGameHash());
		try{
			ContentManager::Instance()->DownloadContent(req);
		}catch(Exception& e) {
			wxLogError(_("Failed to download mod: ") + e.Reason());
		}
	}
}
Esempio n. 3
0
bool ContentManager::DownloadContent(const ContentDownloadRequest& request) {
	if (request.NothingIsRequired()) {
		return false;
	}

	//TODO: check if content already exists on HDD or was just downloaded!

	if (request.IsEngineRequested()) {
		if (IsContentAlreadyBeingDownloaded(request.GetEngineVersion())) {
			throw Exception(_("Engine being downloaded already! Please wait!"));
		}
		prDownloader().Download(DownloadEnum::CAT_ENGINE, request.GetEngineVersion(), "");
	}

	if (request.IsMapRequested()) {
		if (IsContentAlreadyBeingDownloaded(request.GetMapName())) {
			throw Exception(_("Map being downloaded already! Please wait!"));
		}
		prDownloader().Download(DownloadEnum::CAT_MAP, request.GetMapName(), request.GetMapHash());
	}

	if (request.IsGameRequested()) {
		if (IsContentAlreadyBeingDownloaded(request.GetGameName())) {
			throw Exception(_("Game being downloaded already! Please wait!"));
		}
		prDownloader().Download(DownloadEnum::CAT_GAME, request.GetGameName(), request.GetGameHash());
	}

	return true;
}
Esempio n. 4
0
bool ContentManager::DownloadContent(const ContentDownloadRequest& request) {
	if (request.NothingIsRequired()) {
		return false;
	}

	//TODO: check if content already exists on HDD or was just downloaded!

	if (request.IsEngineRequested()) {
		if (IsContentAlreadyBeingDownloaded(request.GetEngineVersion())) {
			throw Exception(_("Engine being downloaded already! Please wait!"));
		}
		ServerManager::Instance()->DownloadContent(PrDownloader::GetEngineCat(), request.GetEngineVersion(), "");
	}

	if (request.IsMapRequested()) {
		if (IsContentAlreadyBeingDownloaded(request.GetMapName())) {
			throw Exception(_("Map being downloaded already! Please wait!"));
		}
		ServerManager::Instance()->DownloadContent("map", request.GetMapName(), request.GetMapHash());
	}

	if (request.IsGameRequested()) {
		if (IsContentAlreadyBeingDownloaded(request.GetGameName())) {
			throw Exception(_("Game being downloaded already! Please wait!"));
		}
		ServerManager::Instance()->DownloadContent("game", request.GetGameName(), request.GetGameHash());
	}

	return true;
}