1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-26 03:52:01 +02:00

Several fixes to combined artifacts added via mods.

This commit is contained in:
DjWarmonger 2013-03-02 09:11:52 +00:00
parent 63cfb5de7e
commit 5f4fb22f53
4 changed files with 14 additions and 12 deletions

View File

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

View File

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

View File

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

View File

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