mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-13 19:54:17 +02:00
Fix list of treasures getting overwriteen leading to weird bugs
... such as having Grail in crypts or getting relics as starting artifact
This commit is contained in:
@@ -740,35 +740,36 @@ void CArtHandler::erasePickedArt(const ArtifactID & id)
|
|||||||
{
|
{
|
||||||
CArtifact *art = objects[id];
|
CArtifact *art = objects[id];
|
||||||
|
|
||||||
if(!(art->aClass & CArtifact::ART_SPECIAL))
|
std::vector<CArtifact*> * artifactList = nullptr;
|
||||||
|
switch(art->aClass)
|
||||||
{
|
{
|
||||||
auto & artifactList = treasures;
|
case CArtifact::ART_TREASURE:
|
||||||
switch(art->aClass)
|
artifactList = &treasures;
|
||||||
{
|
break;
|
||||||
case CArtifact::ART_MINOR:
|
case CArtifact::ART_MINOR:
|
||||||
artifactList = minors;
|
artifactList = &minors;
|
||||||
break;
|
break;
|
||||||
case CArtifact::ART_MAJOR:
|
case CArtifact::ART_MAJOR:
|
||||||
artifactList = majors;
|
artifactList = &majors;
|
||||||
break;
|
break;
|
||||||
case CArtifact::ART_RELIC:
|
case CArtifact::ART_RELIC:
|
||||||
artifactList = relics;
|
artifactList = &relics;
|
||||||
break;
|
break;
|
||||||
}
|
default:
|
||||||
if(artifactList.empty())
|
logMod->warn("Problem: cannot find list for artifact %s, strange class. (special?)", art->getNameTranslated());
|
||||||
fillList(artifactList, art->aClass);
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
auto itr = vstd::find(artifactList, art);
|
if(artifactList->empty())
|
||||||
if(itr != artifactList.end())
|
fillList(*artifactList, art->aClass);
|
||||||
{
|
|
||||||
artifactList.erase(itr);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
logMod->warn("Problem: cannot erase artifact %s from list, it was not present", art->getNameTranslated());
|
|
||||||
|
|
||||||
|
auto itr = vstd::find(*artifactList, art);
|
||||||
|
if(itr != artifactList->end())
|
||||||
|
{
|
||||||
|
artifactList->erase(itr);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
logMod->warn("Problem: cannot find list for artifact %s, strange class. (special?)", art->getNameTranslated());
|
logMod->warn("Problem: cannot erase artifact %s from list, it was not present", art->getNameTranslated());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CArtHandler::fillList( std::vector<CArtifact*> &listToBeFilled, CArtifact::EartClass artifactClass )
|
void CArtHandler::fillList( std::vector<CArtifact*> &listToBeFilled, CArtifact::EartClass artifactClass )
|
||||||
|
Reference in New Issue
Block a user