浏览代码

Several fixes to combined artifacts added via mods.

DjWarmonger 12 年之前
父节点
当前提交
5f4fb22f53
共有 4 个文件被更改,包括 14 次插入12 次删除
  1. 10 11
      lib/CArtHandler.cpp
  2. 1 0
      lib/CArtHandler.h
  3. 2 0
      lib/CModHandler.cpp
  4. 1 1
      lib/Mapping/MapFormatH3M.cpp

+ 10 - 11
lib/CArtHandler.cpp

@@ -361,9 +361,10 @@ void CArtHandler::loadArtifacts(bool onlyTxt)
 		return;
 
 	addBonuses();
+}
 
-	// Populate reverse mappings of combinational artifacts.
-	//TODO: do that also for new artifacts read from mods
+void CArtHandler::reverseMapArtifactConstituents() // Populate reverse mappings of combinational artifacts.
+{
 	BOOST_FOREACH(CArtifact *artifact, artifacts)
 	{
 		if (artifact->constituents != NULL)
@@ -758,9 +759,12 @@ void CArtHandler::clearHlpLists()
 
 bool CArtHandler::legalArtifact(ArtifactID id)
 {
-	return (artifacts[id]->possibleSlots[ArtBearer::HERO].size() ||
-			(artifacts[id]->possibleSlots[ArtBearer::COMMANDER].size() && VLC->modh->modules.COMMANDERS)) ||
-			(artifacts[id]->possibleSlots[ArtBearer::CREATURE].size() && VLC->modh->modules.STACK_ARTIFACT);
+	auto art = artifacts[id];
+	//assert ( (!art->constituents) || art->constituents->size() ); //artifacts is not combined or has some components
+	return (art->possibleSlots[ArtBearer::HERO].size() ||
+			(art->possibleSlots[ArtBearer::COMMANDER].size() && VLC->modh->modules.COMMANDERS) ||
+			(art->possibleSlots[ArtBearer::CREATURE].size() && VLC->modh->modules.STACK_ARTIFACT)) &&
+			!(art->constituents); //no combo artifacts spawning
 }
 
 void CArtHandler::initAllowedArtifactsList(const std::vector<bool> &allowed)
@@ -781,14 +785,9 @@ void CArtHandler::initAllowedArtifactsList(const std::vector<bool> &allowed)
 	}
 	for (int i = GameConstants::ARTIFACTS_QUANTITY; i < artifacts.size(); ++i) //allow all new artifacts by default
 	{
-		 if (artifacts[i]->possibleSlots[ArtBearer::HERO].size())
+		if (legalArtifact(ArtifactID(i)))
 			allowedArtifacts.push_back(artifacts[i]);
-		 else //check if active modules allow artifact to be every used
-		 {
-			 if (legalArtifact(ArtifactID(i)))
-				 allowedArtifacts.push_back(artifacts[i]);
 			 //keep im mind that artifact can be worn by more than one type of bearer
-		 }
 	}
 }
 

+ 1 - 0
lib/CArtHandler.h

@@ -207,6 +207,7 @@ public:
 	CArtifact * loadArtifact(const JsonNode & node);
 	///read (optional) components of combined artifact
 	void readComponents (const JsonNode & node, CArtifact * art);
+	void reverseMapArtifactConstituents ();
 
 	void sortArts();
 	void addBonuses();

+ 2 - 0
lib/CModHandler.cpp

@@ -346,6 +346,8 @@ void CModHandler::reload()
 				VLC->dobjinfo->gobjs[Obj::ARTIFACT][art->id] = info;
 			}
 		}
+
+		VLC->arth->reverseMapArtifactConstituents();
 	}
 
 	{

+ 1 - 1
lib/Mapping/MapFormatH3M.cpp

@@ -675,7 +675,7 @@ CArtifactInstance * CMapLoaderH3M::createArtifact(int aid, int spellID /*= -1*/)
 			a = CArtifactInstance::createScroll(SpellID(spellID).toSpell());
 		}
 	}
-	else
+	else //FIXME: create combined artifact instance for random combined artifacts, just in case
 	{
 		a = new CArtifactInstance();
 	}