Browse Source

Minor fixes:
- properly re-enable necessary mods during update
- do not crash if building border is fully-colored

Ivan Savenko 12 năm trước cách đây
mục cha
commit
5de70ba235
3 tập tin đã thay đổi với 36 bổ sung21 xóa
  1. 20 18
      client/CCastleInterface.cpp
  2. 15 2
      launcher/modManager/cmodlistview_moc.cpp
  3. 1 1
      lib/CTownHandler.cpp

+ 20 - 18
client/CCastleInterface.cpp

@@ -168,27 +168,29 @@ void CBuildingRect::show(SDL_Surface * to)
 				blitAtLoc(border,0,0,to);
 			return;
 		}
-		// key colors in glowing border
-		SDL_Color c1 = {200, 200, 200, 255};
-		SDL_Color c2 = {120, 100,  60, 255};
-		SDL_Color c3 = {200, 180, 110, 255};
-
-		ui32 colorID = SDL_MapRGB(border->format, c3.r, c3.g, c3.b);
-		SDL_Color oldColor = border->format->palette->colors[colorID];
-		SDL_Color newColor;
+		if (border->format->palette != nullptr)
+		{
+			// key colors in glowing border
+			SDL_Color c1 = {200, 200, 200, 255};
+			SDL_Color c2 = {120, 100,  60, 255};
+			SDL_Color c3 = {200, 180, 110, 255};
 
-		if (stateCounter < S2_WHITE_B)
-			newColor = multiplyColors(c1, c2, static_cast<double>(stateCounter % stageDelay) / stageDelay);
-		else
-		if (stateCounter < S3_YELLOW_B)
-			newColor = multiplyColors(c2, c3, static_cast<double>(stateCounter % stageDelay) / stageDelay);
-		else
-			newColor = oldColor;
+			ui32 colorID = SDL_MapRGB(border->format, c3.r, c3.g, c3.b);
+			SDL_Color oldColor = border->format->palette->colors[colorID];
+			SDL_Color newColor;
 
-		SDL_SetColors(border, &newColor, colorID, 1);
-		blitAtLoc(border,0,0,to);
-		SDL_SetColors(border, &oldColor, colorID, 1);
+			if (stateCounter < S2_WHITE_B)
+				newColor = multiplyColors(c1, c2, static_cast<double>(stateCounter % stageDelay) / stageDelay);
+			else
+			if (stateCounter < S3_YELLOW_B)
+				newColor = multiplyColors(c2, c3, static_cast<double>(stateCounter % stageDelay) / stageDelay);
+			else
+				newColor = oldColor;
 
+			SDL_SetColors(border, &newColor, colorID, 1);
+			blitAtLoc(border,0,0,to);
+			SDL_SetColors(border, &oldColor, colorID, 1);
+		}
 	}
 	if (stateCounter < BUILDED)
 		stateCounter++;

+ 15 - 2
launcher/modManager/cmodlistview_moc.cpp

@@ -506,11 +506,24 @@ void CModListView::installMods(QStringList archives)
 		modNames.push_back(modName);
 	}
 
+	QStringList modsToEnable;
+
 	// disable mod(s), to properly recalculate dependencies, if changed
 	for (QString mod : boost::adaptors::reverse(modNames))
 	{
-		if (modModel->getMod(mod).isInstalled())
-			manager->disableMod(mod);
+		CModEntry entry = modModel->getMod(mod);
+		if (entry.isInstalled())
+		{
+			// enable mod if installed and enabled
+			if (entry.isEnabled())
+				modsToEnable.push_back(mod);
+		}
+		else
+		{
+			// enable mod if m
+			if (settings["launcher"]["enableInstalledMods"].Bool())
+				modsToEnable.push_back(mod);
+		}
 	}
 
 	// uninstall old version of mod, if installed

+ 1 - 1
lib/CTownHandler.cpp

@@ -369,7 +369,7 @@ void CTownHandler::loadStructure(CTown &town, const std::string & stringID, cons
 		}
 		else
 		{
-			VLC->modh->identifiers.tryRequestIdentifier("building." + town.faction->identifier, source["builds"], [=, &town](si32 identifier) mutable
+			VLC->modh->identifiers.requestIdentifier("building." + town.faction->identifier, source["builds"], [=, &town](si32 identifier) mutable
 			{
 				ret->buildable = town.buildings[BuildingID(identifier)];
 			});