Jelajahi Sumber

Water heroes will now be correctly banned on random maps.

Tomasz Zieliński 2 tahun lalu
induk
melakukan
fbd1d728ec
2 mengubah file dengan 20 tambahan dan 0 penghapusan
  1. 19 0
      lib/rmg/CMapGenerator.cpp
  2. 1 0
      lib/rmg/CMapGenerator.h

+ 19 - 0
lib/rmg/CMapGenerator.cpp

@@ -413,6 +413,7 @@ void CMapGenerator::addHeaderInfo()
 	m.difficulty = 1;
 	addPlayerInfo();
 	m.waterMap = (mapGenOptions.getWaterContent() != EWaterContent::EWaterContent::NONE);
+	banWaterHeroes();
 }
 
 int CMapGenerator::getNextMonlithIndex()
@@ -452,6 +453,24 @@ const std::vector<ArtifactID> & CMapGenerator::getAllPossibleQuestArtifacts() co
 	return questArtifacts;
 }
 
+void CMapGenerator::banWaterHeroes()
+{
+	//This also bans only-land heroes on wazter maps
+	auto isWaterMap = map->getMap(this).isWaterMap();
+
+	for (int j = 0; j < map->getMap(this).allowedHeroes.size(); j++)
+	{
+		if (map->getMap(this).allowedHeroes[j])
+		{
+			auto* h = dynamic_cast<const CHero*>(VLC->heroTypes()->getByIndex(j));
+			if ((h->onlyOnWaterMap && !isWaterMap) || (h->onlyOnMapWithoutWater && isWaterMap)) //TODO: Refactor? Move to hero?
+			{
+				banHero(HeroTypeID(j));
+			}
+		}
+	}
+}
+
 const std::vector<HeroTypeID> CMapGenerator::getAllPossibleHeroes() const
 {
 	auto isWaterMap = map->getMap(this).isWaterMap();

+ 1 - 0
lib/rmg/CMapGenerator.h

@@ -63,6 +63,7 @@ public:
 	int getPrisonsRemaning() const;
 	std::shared_ptr<CZonePlacer> getZonePlacer() const;
 	const std::vector<ArtifactID> & getAllPossibleQuestArtifacts() const;
+	void banWaterHeroes();
 	const std::vector<HeroTypeID> getAllPossibleHeroes() const;
 	void banQuestArt(const ArtifactID & id);
 	void banHero(const HeroTypeID& id);