Selaa lähdekoodia

Fix crash on using two mods that add battlefield with same identifier

Ivan Savenko 1 vuosi sitten
vanhempi
sitoutus
fbdceb4f71
2 muutettua tiedostoa jossa 3 lisäystä ja 1 poistoa
  1. 2 1
      lib/BattleFieldHandler.cpp
  2. 1 0
      lib/BattleFieldHandler.h

+ 2 - 1
lib/BattleFieldHandler.cpp

@@ -21,6 +21,7 @@ BattleFieldInfo * BattleFieldHandler::loadFromJson(const std::string & scope, co
 
 	auto * info = new BattleFieldInfo(BattleField(index), identifier);
 
+	info->modScope = scope;
 	info->graphics = ImagePath::fromJson(json["graphics"]);
 	info->icon = json["icon"].String();
 	info->name = json["name"].String();
@@ -66,7 +67,7 @@ int32_t BattleFieldInfo::getIconIndex() const
 
 std::string BattleFieldInfo::getJsonKey() const
 {
-	return identifier;
+	return modScope + ':' + identifier;
 }
 
 std::string BattleFieldInfo::getNameTextID() const

+ 1 - 0
lib/BattleFieldHandler.h

@@ -27,6 +27,7 @@ public:
 	bool isSpecial;
 	ImagePath graphics;
 	std::string name;
+	std::string modScope;
 	std::string identifier;
 	std::string icon;
 	si32 iconIndex;