mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-25 22:42:04 +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:
@@ -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());
|
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();
|
hero->artifactsInBackpack.clear();
|
||||||
while(!hero->artifactsWorn.empty())
|
hero->artifactsWorn.clear();
|
||||||
hero->removeArtifact(hero->artifactsWorn.begin()->first);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i = 0; i < features.artifactSlotsCount; i++)
|
for(int i = 0; i < features.artifactSlotsCount; i++)
|
||||||
|
|||||||
@@ -618,6 +618,9 @@ void MainWindow::saveMap()
|
|||||||
|
|
||||||
for(auto obj : controller.map()->objects)
|
for(auto obj : controller.map()->objects)
|
||||||
{
|
{
|
||||||
|
if(!obj)
|
||||||
|
continue;
|
||||||
|
|
||||||
if(obj->ID == Obj::HERO_PLACEHOLDER)
|
if(obj->ID == Obj::HERO_PLACEHOLDER)
|
||||||
{
|
{
|
||||||
auto hero = dynamic_cast<CGHeroPlaceholder *>(obj.get());
|
auto hero = dynamic_cast<CGHeroPlaceholder *>(obj.get());
|
||||||
|
|||||||
@@ -746,6 +746,8 @@ ModCompatibilityInfo MapController::modAssessmentMap(const CMap & map)
|
|||||||
|
|
||||||
for(auto obj : map.objects)
|
for(auto obj : map.objects)
|
||||||
{
|
{
|
||||||
|
if(!obj)
|
||||||
|
continue;
|
||||||
modAssessmentObject(obj.get(), result);
|
modAssessmentObject(obj.get(), result);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -20,7 +20,10 @@ void Translations::cleanupRemovedItems(CMap & map)
|
|||||||
{
|
{
|
||||||
std::set<std::string> existingObjects{"map", "header"};
|
std::set<std::string> existingObjects{"map", "header"};
|
||||||
for(auto object : map.objects)
|
for(auto object : map.objects)
|
||||||
existingObjects.insert(object->instanceName);
|
{
|
||||||
|
if(object)
|
||||||
|
existingObjects.insert(object->instanceName);
|
||||||
|
}
|
||||||
|
|
||||||
for(auto & translations : map.translations.Struct())
|
for(auto & translations : map.translations.Struct())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -79,6 +79,8 @@ std::set<Validator::Issue> Validator::validate(const CMap * map)
|
|||||||
//checking all objects in the map
|
//checking all objects in the map
|
||||||
for(auto o : map->objects)
|
for(auto o : map->objects)
|
||||||
{
|
{
|
||||||
|
if(!o)
|
||||||
|
continue;
|
||||||
//owners for objects
|
//owners for objects
|
||||||
if(o->getOwner() == PlayerColor::UNFLAGGABLE)
|
if(o->getOwner() == PlayerColor::UNFLAGGABLE)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user