Browse Source

Fix loading of preset artifacts and creatures on some custom maps

Ivan Savenko 1 year ago
parent
commit
6730ec64d5
2 changed files with 12 additions and 5 deletions
  1. 6 2
      lib/mapObjects/CGCreature.cpp
  2. 6 3
      lib/mapObjects/MiscObjects.cpp

+ 6 - 2
lib/mapObjects/CGCreature.cpp

@@ -215,8 +215,12 @@ void CGCreature::pickRandomObject(CRandomGenerator & rand)
 			subID = VLC->creh->pickRandomMonster(rand, 7);
 			break;
 	}
-	ID = MapObjectID::MONSTER;
-	setType(ID, subID);
+
+	if (ID != MapObjectID::MONSTER)
+	{
+		ID = MapObjectID::MONSTER;
+		setType(ID, subID);
+	}
 }
 
 void CGCreature::initObj(CRandomGenerator & rand)

+ 6 - 3
lib/mapObjects/MiscObjects.cpp

@@ -739,10 +739,13 @@ void CGArtifact::pickRandomObject(CRandomGenerator & rand)
 			break;
 	}
 
-	if (ID != Obj::SPELL_SCROLL)
+	if (ID != MapObjectID::SPELL_SCROLL && ID != MapObjectID::ARTIFACT)
+	{
+		ID = MapObjectID::ARTIFACT;
+		setType(ID, subID);
+	}
+	else if (ID != MapObjectID::SPELL_SCROLL)
 		ID = MapObjectID::ARTIFACT;
-
-	setType(ID, subID);
 }
 
 void CGArtifact::initObj(CRandomGenerator & rand)