1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-15 00:05:02 +02:00

Remove allowed artifacts list from arthandler

1. Handlers should not contain non-const game state data
2. This field was duplicating same field in CMap
3. Due to removal of VLC serialization, this field is not updated on map
load leading to issues with artifact randomization
This commit is contained in:
Ivan Savenko
2023-12-11 15:06:04 +02:00
parent 6fe8ed7a03
commit 7ffe014d6b
4 changed files with 11 additions and 22 deletions

View File

@ -195,7 +195,6 @@ void CGameState::init(const IMapService * mapService, StartInfo * si, Load::Prog
logGlobal->error("Wrong mode: %d", static_cast<int>(scenarioOps->mode));
return;
}
VLC->arth->initAllowedArtifactsList(map->allowedArtifact);
logGlobal->info("Map loaded!");
checkMapChecksum();
@ -1947,8 +1946,13 @@ ArtifactID CGameState::pickRandomArtifact(CRandomGenerator & rand, int flags, st
std::set<ArtifactID> potentialPicks;
// Select artifacts that satisfy provided criterias
for (auto const * artifact : VLC->arth->allowedArtifacts)
for (auto const & artifactID : map->allowedArtifact)
{
if (!VLC->arth->legalArtifact(artifactID))
continue;
auto const * artifact = artifactID.toArtifact();
assert(artifact->aClass != CArtifact::ART_SPECIAL); // should be filtered out when allowedArtifacts is initialized
if ((flags & CArtifact::ART_TREASURE) == 0 && artifact->aClass == CArtifact::ART_TREASURE)