Bläddra i källkod

Fix events on .vmap's not activating on hero visit

Ivan Savenko 3 månader sedan
förälder
incheckning
4fc63427b9
2 ändrade filer med 18 tillägg och 6 borttagningar
  1. 8 1
      lib/mapObjects/CGPandoraBox.cpp
  2. 10 5
      lib/mapObjects/CGPandoraBox.h

+ 8 - 1
lib/mapObjects/CGPandoraBox.cpp

@@ -275,6 +275,12 @@ void CGPandoraBox::serializeJsonOptions(JsonSerializeFormat & handler)
 	}
 }
 
+CGEvent::CGEvent(IGameInfoCallback * cb)
+	: CGPandoraBox(cb)
+	, availableFor(PlayerColor::ALL_PLAYERS().begin(), PlayerColor::ALL_PLAYERS().end())
+{
+}
+
 void CGEvent::init()
 {
 	blockVisit = false;
@@ -333,7 +339,8 @@ void CGEvent::serializeJsonOptions(JsonSerializeFormat & handler)
 	handler.serializeBool("aIActivable", computerActivate, false);
 	handler.serializeBool("humanActivable", humanActivate, true);
 	handler.serializeBool("removeAfterVisit", removeAfterVisit, false);
-	handler.serializeIdArray("availableFor", availableFor);
+	if (handler.saving || !handler.getCurrent()["availableFor"].isNull())
+		handler.serializeIdArray("availableFor", availableFor); // else - keep default value
 }
 
 VCMI_LIB_NAMESPACE_END

+ 10 - 5
lib/mapObjects/CGPandoraBox.h

@@ -43,12 +43,17 @@ protected:
 class DLL_LINKAGE CGEvent : public CGPandoraBox  //event objects
 {
 public:
-	using CGPandoraBox::CGPandoraBox;
+	CGEvent(IGameInfoCallback *cb);
 
-	bool removeAfterVisit = false; //true if event is removed after occurring
-	std::set<PlayerColor> availableFor; //players whom this event is available for
-	bool computerActivate = false; //true if computer player can activate this event
-	bool humanActivate = false; //true if human player can activate this event
+	//players whom this event is available for
+	std::set<PlayerColor> availableFor;
+
+	//true if event is removed after occurring
+	bool removeAfterVisit = false;
+	//true if computer player can activate this event
+	bool computerActivate = false;
+	//true if human player can activate this event
+	bool humanActivate = false;
 
 	template <typename Handler> void serialize(Handler &h)
 	{