1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-10-08 23:22:25 +02:00

Merge pull request #6148 from MichalZr6/fix_remove_artifacts

Minor fixes for artifact removal during map load and handling null map objects
This commit is contained in:
Ivan Savenko
2025-10-05 11:55:02 +03:00
committed by GitHub
5 changed files with 13 additions and 4 deletions

View File

@@ -925,8 +925,7 @@ void CMapLoaderH3M::loadArtifactsOfHero(CGHeroInstance * hero)
logGlobal->debug("Hero %d at %s has set artifacts twice (in map properties and on adventure map instance). Using the latter set...", hero->getHeroTypeID().getNum(), hero->anchorPos().toString());
hero->artifactsInBackpack.clear();
while(!hero->artifactsWorn.empty())
hero->removeArtifact(hero->artifactsWorn.begin()->first);
hero->artifactsWorn.clear();
}
for(int i = 0; i < features.artifactSlotsCount; i++)

View File

@@ -618,6 +618,9 @@ void MainWindow::saveMap()
for(auto obj : controller.map()->objects)
{
if(!obj)
continue;
if(obj->ID == Obj::HERO_PLACEHOLDER)
{
auto hero = dynamic_cast<CGHeroPlaceholder *>(obj.get());

View File

@@ -746,6 +746,8 @@ ModCompatibilityInfo MapController::modAssessmentMap(const CMap & map)
for(auto obj : map.objects)
{
if(!obj)
continue;
modAssessmentObject(obj.get(), result);
}
return result;

View File

@@ -20,8 +20,11 @@ void Translations::cleanupRemovedItems(CMap & map)
{
std::set<std::string> existingObjects{"map", "header"};
for(auto object : map.objects)
existingObjects.insert(object->instanceName);
{
if(object)
existingObjects.insert(object->instanceName);
}
for(auto & translations : map.translations.Struct())
{
JsonNode updateTranslations;

View File

@@ -79,6 +79,8 @@ std::set<Validator::Issue> Validator::validate(const CMap * map)
//checking all objects in the map
for(auto o : map->objects)
{
if(!o)
continue;
//owners for objects
if(o->getOwner() == PlayerColor::UNFLAGGABLE)
{