Browse Source

Fix translations in map editor / fix crash on game end

nordsoft 2 years ago
parent
commit
043f54698b

+ 5 - 2
client/CServerHandler.cpp

@@ -681,8 +681,11 @@ void CServerHandler::endGameplay(bool closeConnection, bool restart)
 		}
 	}
 	
-	c->enterLobbyConnectionMode();
-	c->disableStackSendingByID();
+	if(c)
+	{
+		c->enterLobbyConnectionMode();
+		c->disableStackSendingByID();
+	}
 	
 	//reset settings
 	Settings saveSession = settings.write["server"]["reconnect"];

+ 1 - 1
lib/mapping/CMapHeader.cpp

@@ -157,7 +157,7 @@ void CMapHeader::registerMapStrings()
 		mapLanguages.insert(translation.first);
 	}
 	
-	if(maxStrings == 0 || mapBaseLanguages.empty())
+	if(maxStrings == 0 || mapLanguages.empty())
 	{
 		logGlobal->info("Map %s doesn't have any supported translation", name.toString());
 		return;

+ 9 - 1
mapeditor/mapsettings/loseconditions.cpp

@@ -117,7 +117,7 @@ void LoseConditions::initialize(MapController & c)
 void LoseConditions::update()
 {
 	//loss messages
-	controller->map()->defeatMessage = MetaString::createFromTextID(mapRegisterLocalizedString("map", *controller->map(), TextIdentifier("header", "defeatMessage"), ui->defeatMessageEdit->text().toStdString()));
+	bool customMessage = true;
 
 	//loss conditions
 	EventCondition defeatCondition(EventCondition::DAYS_WITHOUT_TOWN);
@@ -138,6 +138,7 @@ void LoseConditions::update()
 		controller->map()->triggeredEvents.push_back(standardDefeat);
 		controller->map()->defeatIconIndex = 3;
 		controller->map()->defeatMessage = MetaString::createFromTextID("core.lcdesc.0");
+		customMessage = false;
 	}
 	else
 	{
@@ -163,6 +164,7 @@ void LoseConditions::update()
 				specialDefeat.onFulfill.appendTextID("core.genrltxt.251");
 				specialDefeat.trigger = EventExpression(noneOf);
 				controller->map()->defeatMessage = MetaString::createFromTextID("core.lcdesc.1");
+				customMessage = false;
 				break;
 			}
 
@@ -177,6 +179,7 @@ void LoseConditions::update()
 				specialDefeat.onFulfill.appendTextID("core.genrltxt.253");
 				specialDefeat.trigger = EventExpression(noneOf);
 				controller->map()->defeatMessage = MetaString::createFromTextID("core.lcdesc.2");
+				customMessage = false;
 				break;
 			}
 
@@ -187,6 +190,7 @@ void LoseConditions::update()
 				specialDefeat.onFulfill.appendTextID("core.genrltxt.254");
 				specialDefeat.trigger = EventExpression(cond);
 				controller->map()->defeatMessage = MetaString::createFromTextID("core.lcdesc.3");
+				customMessage = false;
 				break;
 			}
 
@@ -215,6 +219,10 @@ void LoseConditions::update()
 		controller->map()->triggeredEvents.push_back(specialDefeat);
 	}
 
+	if(customMessage)
+	{
+		controller->map()->defeatMessage = MetaString::createFromTextID(mapRegisterLocalizedString("map", *controller->map(), TextIdentifier("header", "defeatMessage"), ui->defeatMessageEdit->text().toStdString()));
+	}
 }
 
 void LoseConditions::on_loseComboBox_currentIndexChanged(int index)

+ 9 - 1
mapeditor/mapsettings/victoryconditions.cpp

@@ -179,7 +179,7 @@ void VictoryConditions::initialize(MapController & c)
 void VictoryConditions::update()
 {
 	//victory messages
-	controller->map()->victoryMessage = MetaString::createFromTextID(mapRegisterLocalizedString("map", *controller->map(), TextIdentifier("header", "victoryMessage"), ui->victoryMessageEdit->text().toStdString()));
+	bool customMessage = true;
 
 	//victory conditions
 	EventCondition victoryCondition(EventCondition::STANDARD_WIN);
@@ -199,6 +199,7 @@ void VictoryConditions::update()
 		controller->map()->triggeredEvents.push_back(standardVictory);
 		controller->map()->victoryIconIndex = 11;
 		controller->map()->victoryMessage = MetaString::createFromTextID("core.vcdesc.0");
+		customMessage = false;
 	}
 	else
 	{
@@ -211,6 +212,7 @@ void VictoryConditions::update()
 
 		controller->map()->victoryIconIndex = vicCondition;
 		controller->map()->victoryMessage = MetaString::createFromTextID("core.vcdesc." + std::to_string(vicCondition + 1));
+		customMessage = false;
 
 		switch(vicCondition)
 		{
@@ -327,9 +329,15 @@ void VictoryConditions::update()
 			controller->map()->victoryMessage.appendRawString(" / ");
 			controller->map()->victoryMessage.appendTextID("core.vcdesc.0");
 			controller->map()->triggeredEvents.push_back(standardVictory);
+			customMessage = false;
 		}
 		controller->map()->triggeredEvents.push_back(specialVictory);
 	}
+	
+	if(customMessage)
+	{
+		controller->map()->victoryMessage = MetaString::createFromTextID(mapRegisterLocalizedString("map", *controller->map(), TextIdentifier("header", "victoryMessage"), ui->victoryMessageEdit->text().toStdString()));
+	}
 }
 
 VictoryConditions::~VictoryConditions()