Explorar o código

Fixed CID 1243181, CID 1197449, CID 1366374, CID 1366377, CID 1366359

AlexVinS %!s(int64=9) %!d(string=hai) anos
pai
achega
db40e125eb

+ 1 - 1
client/CPreGame.cpp

@@ -1309,7 +1309,7 @@ SelectionTab::SelectionTab(CMenuScreen::EState Type, const std::function<void(CM
 			selectFName("Maps/Arrogance");
 		else
 			selectFName(settings["session"]["lastMap"].String());
-			
+
 		break;
 	case CMenuScreen::campaignList:
 		select(0);

+ 1 - 0
client/widgets/Buttons.cpp

@@ -41,6 +41,7 @@ void ClickableArea::addCallback(std::function<void()> callback)
 void ClickableArea::setArea(CIntObject * object)
 {
 	delete area;
+	area = object;
 	addChild(area);
 	pos.w = object->pos.w;
 	pos.h = object->pos.h;

+ 5 - 7
lib/BattleState.cpp

@@ -102,14 +102,12 @@ ui32 BattleInfo::calculateDmg( const CStack* attacker, const CStack* defender,
 
 	if(range.first != range.second)
 	{
-		int valuesToAverage[10];
-		int howManyToAv = std::min<ui32>(10, attacker->count);
-		for (int g=0; g<howManyToAv; ++g)
-		{
-			valuesToAverage[g] = rand.nextInt(range.first, range.second);
-		}
+		ui32 sum = 0;
+		ui32 howManyToAv = std::min<ui32>(10, attacker->count);
+		for(int g=0; g<howManyToAv; ++g)
+			sum += (ui32)rand.nextInt(range.first, range.second);
 
-		return std::accumulate(valuesToAverage, valuesToAverage + howManyToAv, 0) / howManyToAv;
+		return sum / howManyToAv;
 	}
 	else
 		return range.first;

+ 7 - 4
lib/CCreatureHandler.cpp

@@ -46,10 +46,13 @@ int CCreature::estimateCreatureCount(ui32 countID)
 {
 	static const int creature_count[] = { 0, 3, 8, 15, 35, 75, 175, 375, 750, 2500 };
 
-	if (countID > 9)
-		assert("Wrong countID!");
-
-	return creature_count[countID];
+	if(countID > 9)
+	{
+		logGlobal->error("Wrong countID %d!", countID);
+		return 0;
+	}
+	else
+		return creature_count[countID];
 }
 
 bool CCreature::isDoubleWide() const

+ 1 - 1
lib/rmg/CRmgTemplateStorage.cpp

@@ -251,7 +251,7 @@ CRmgTemplate::CSize CRmgTemplateStorage::parseMapTemplateSize(const std::string
 	if(it == mapSizeMapping.end())
 	{
 		// Map size is given as a number representation
-		const auto & numericalRep = parts[0];
+		const std::string numericalRep = parts[0];
 		parts.clear();
 		boost::split(parts, numericalRep, boost::is_any_of("x"));
 		assert(parts.size() == 3);

+ 0 - 2
lib/rmg/CRmgTemplateZone.cpp

@@ -2374,8 +2374,6 @@ ObjectInfo CRmgTemplateZone::getRandomObject(CMapGenerator* gen, CTreasurePileIn
 		});
 		return *(it->second);
 	}
-
-	return ObjectInfo(); // unreachable
 }
 
 void CRmgTemplateZone::addAllPossibleObjects(CMapGenerator* gen)