mirror of
				https://github.com/vcmi/vcmi.git
				synced 2025-10-31 00:07:39 +02:00 
			
		
		
		
	minor fixes
This commit is contained in:
		| @@ -442,7 +442,7 @@ BattleHexArray BattleFieldController::getRangeHexes(BattleHex sourceHex, uint8_t | ||||
| 	return rangeHexes; | ||||
| } | ||||
|  | ||||
| BattleHexArray BattleFieldController::getRangeLimitHexes(BattleHex hoveredHex, BattleHexArray rangeHexes, uint8_t distanceToLimit) | ||||
| BattleHexArray BattleFieldController::getRangeLimitHexes(BattleHex hoveredHex, const BattleHexArray & rangeHexes, uint8_t distanceToLimit) | ||||
| { | ||||
| 	BattleHexArray rangeLimitHexes; | ||||
|  | ||||
| @@ -456,7 +456,7 @@ BattleHexArray BattleFieldController::getRangeLimitHexes(BattleHex hoveredHex, B | ||||
| 	return rangeLimitHexes; | ||||
| } | ||||
|  | ||||
| bool BattleFieldController::IsHexInRangeLimit(BattleHex hex, BattleHexArray & rangeLimitHexes, int * hexIndexInRangeLimit) | ||||
| bool BattleFieldController::IsHexInRangeLimit(BattleHex hex, const BattleHexArray & rangeLimitHexes, int * hexIndexInRangeLimit) | ||||
| { | ||||
| 	bool  hexInRangeLimit = false; | ||||
|  | ||||
| @@ -470,7 +470,8 @@ bool BattleFieldController::IsHexInRangeLimit(BattleHex hex, BattleHexArray & ra | ||||
| 	return hexInRangeLimit; | ||||
| } | ||||
|  | ||||
| std::vector<std::vector<BattleHex::EDir>> BattleFieldController::getOutsideNeighbourDirectionsForLimitHexes(BattleHexArray wholeRangeHexes, BattleHexArray rangeLimitHexes) | ||||
| std::vector<std::vector<BattleHex::EDir>> BattleFieldController::getOutsideNeighbourDirectionsForLimitHexes( | ||||
| 	const BattleHexArray & wholeRangeHexes, const BattleHexArray & rangeLimitHexes) | ||||
| { | ||||
| 	std::vector<std::vector<BattleHex::EDir>> output; | ||||
|  | ||||
| @@ -481,7 +482,7 @@ std::vector<std::vector<BattleHex::EDir>> BattleFieldController::getOutsideNeigh | ||||
| 	{ | ||||
| 		// get all neighbours and their directions | ||||
| 		 | ||||
| 		auto neighbouringTiles = BattleHexArray::generateAllNeighbouringTiles(hex); | ||||
| 		const BattleHexArray & neighbouringTiles = BattleHexArray::getAllNeighbouringTiles(hex); | ||||
|  | ||||
| 		std::vector<BattleHex::EDir> outsideNeighbourDirections; | ||||
|  | ||||
| @@ -679,7 +680,7 @@ BattleHex BattleFieldController::getHexAtPosition(Point hoverPos) | ||||
| BattleHex::EDir BattleFieldController::selectAttackDirection(BattleHex myNumber) | ||||
| { | ||||
| 	const bool doubleWide = owner.stacksController->getActiveStack()->doubleWide(); | ||||
| 	auto neighbours = BattleHexArray::generateAllNeighbouringTiles(myNumber); | ||||
| 	const BattleHexArray & neighbours = BattleHexArray::getAllNeighbouringTiles(myNumber); | ||||
| 	//   0 1 | ||||
| 	//  5 x 2 | ||||
| 	//   4 3 | ||||
|   | ||||
| @@ -68,13 +68,13 @@ class BattleFieldController : public CIntObject | ||||
| 	BattleHexArray getRangeHexes(BattleHex sourceHex, uint8_t distance); | ||||
|  | ||||
| 	/// get only hexes at the limit of a range | ||||
| 	BattleHexArray getRangeLimitHexes(BattleHex hoveredHex, BattleHexArray hexRange, uint8_t distanceToLimit); | ||||
| 	BattleHexArray getRangeLimitHexes(BattleHex hoveredHex, const BattleHexArray & hexRange, uint8_t distanceToLimit); | ||||
|  | ||||
| 	/// calculate if a hex is in range limit and return its index in range | ||||
| 	bool IsHexInRangeLimit(BattleHex hex, BattleHexArray & rangeLimitHexes, int * hexIndexInRangeLimit); | ||||
| 	bool IsHexInRangeLimit(BattleHex hex, const BattleHexArray & rangeLimitHexes, int * hexIndexInRangeLimit); | ||||
|  | ||||
| 	/// get an array that has for each hex in range, an array with all directions where an outside neighbour hex exists | ||||
| 	std::vector<std::vector<BattleHex::EDir>> getOutsideNeighbourDirectionsForLimitHexes(BattleHexArray rangeHexes, BattleHexArray rangeLimitHexes); | ||||
| 	std::vector<std::vector<BattleHex::EDir>> getOutsideNeighbourDirectionsForLimitHexes(const BattleHexArray & rangeHexes, const BattleHexArray & rangeLimitHexes); | ||||
|  | ||||
| 	/// calculates what image to use as range limit, depending on the direction of neighbours | ||||
| 	/// a mask is used internally to mark the directions of all neighbours | ||||
|   | ||||
| @@ -34,14 +34,14 @@ | ||||
| #include "../../lib/mapping/CMapDefines.h" | ||||
| #include "../../lib/pathfinder/CGPathNode.h" | ||||
|  | ||||
| struct neighbourTilesInfo | ||||
| struct NeighborTilesInfo | ||||
| { | ||||
| 	//567 | ||||
| 	//3 4 | ||||
| 	//012 | ||||
| 	std::bitset<8> d; | ||||
|  | ||||
| 	neighbourTilesInfo(IMapRendererContext & context, const int3 & pos) | ||||
| 	NeighborTilesInfo(IMapRendererContext & context, const int3 & pos) | ||||
| 	{ | ||||
| 		auto checkTile = [&](int dx, int dy) | ||||
| 		{ | ||||
| @@ -340,9 +340,9 @@ void MapRendererFow::renderTile(IMapRendererContext & context, Canvas & target, | ||||
| { | ||||
| 	assert(!context.isVisible(coordinates)); | ||||
|  | ||||
| 	const neighbourTilesInfo neighbourInfo(context, coordinates); | ||||
| 	const NeighborTilesInfo neighborInfo(context, coordinates); | ||||
|  | ||||
| 	int retBitmapID = neighbourInfo.getBitmapID(); // >=0 -> partial hide, <0 - full hide | ||||
| 	int retBitmapID = neighborInfo.getBitmapID(); // >=0 -> partial hide, <0 - full hide | ||||
| 	if(retBitmapID < 0) | ||||
| 	{ | ||||
| 		// generate a number that is predefined for each tile, | ||||
| @@ -367,8 +367,8 @@ uint8_t MapRendererFow::checksum(IMapRendererContext & context, const int3 & coo | ||||
| 	if (context.showSpellRange(coordinates)) | ||||
| 		return 0xff - 2; | ||||
|  | ||||
| 	const neighbourTilesInfo neighbourInfo(context, coordinates); | ||||
| 	int retBitmapID = neighbourInfo.getBitmapID(); | ||||
| 	const NeighborTilesInfo neighborInfo(context, coordinates); | ||||
| 	int retBitmapID = neighborInfo.getBitmapID(); | ||||
| 	if(retBitmapID < 0) | ||||
| 		return 0xff - 1; | ||||
| 	return retBitmapID; | ||||
| @@ -738,9 +738,9 @@ MapRenderer::TileChecksum MapRenderer::getTileChecksum(IMapRendererContext & con | ||||
| 		return result; | ||||
| 	} | ||||
|  | ||||
| 	const neighbourTilesInfo neighbourInfo(context, coordinates); | ||||
| 	const NeighborTilesInfo neighborInfo(context, coordinates); | ||||
|  | ||||
| 	if(!context.isVisible(coordinates) && neighbourInfo.areAllHidden()) | ||||
| 	if(!context.isVisible(coordinates) && neighborInfo.areAllHidden()) | ||||
| 	{ | ||||
| 		result[7] = rendererFow.checksum(context, coordinates); | ||||
| 	} | ||||
| @@ -769,9 +769,9 @@ void MapRenderer::renderTile(IMapRendererContext & context, Canvas & target, con | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
| 	const neighbourTilesInfo neighbourInfo(context, coordinates); | ||||
| 	const NeighborTilesInfo neighborInfo(context, coordinates); | ||||
|  | ||||
| 	if(!context.isVisible(coordinates) && neighbourInfo.areAllHidden()) | ||||
| 	if(!context.isVisible(coordinates) && neighborInfo.areAllHidden()) | ||||
| 	{ | ||||
| 		rendererFow.renderTile(context, target, coordinates); | ||||
| 	} | ||||
|   | ||||
| @@ -674,7 +674,7 @@ SDL_Surface * CSDL_Ext::scaleSurfaceIntegerFactor(SDL_Surface * surf, int factor | ||||
| 	switch (algorithm) | ||||
| 	{ | ||||
| 		case EScalingAlgorithm::NEAREST: | ||||
| 			xbrz::nearestneighbourScale(srcPixels, intermediate->w, intermediate->h, dstPixels, ret->w, ret->h); | ||||
| 			xbrz::nearestNeighborScale(srcPixels, intermediate->w, intermediate->h, dstPixels, ret->w, ret->h); | ||||
| 			break; | ||||
| 		case EScalingAlgorithm::BILINEAR: | ||||
| 			xbrz::bilinearScale(srcPixels, intermediate->w, intermediate->h, dstPixels, ret->w, ret->h); | ||||
|   | ||||
| @@ -1273,10 +1273,10 @@ void xbrz::bilinearScale(const uint32_t* src, int srcWidth, int srcHeight, | ||||
| } | ||||
|  | ||||
|  | ||||
| void xbrz::nearestneighbourScale(const uint32_t* src, int srcWidth, int srcHeight, | ||||
| void xbrz::nearestNeighborScale(const uint32_t* src, int srcWidth, int srcHeight, | ||||
|                                 /**/  uint32_t* trg, int trgWidth, int trgHeight) | ||||
| { | ||||
|     nearestneighbourScale(src, srcWidth, srcHeight, srcWidth * sizeof(uint32_t), | ||||
|     nearestNeighborScale(src, srcWidth, srcHeight, srcWidth * sizeof(uint32_t), | ||||
|                          trg, trgWidth, trgHeight, trgWidth * sizeof(uint32_t), | ||||
|     0, trgHeight, [](uint32_t pix) { return pix; }); | ||||
| } | ||||
|   | ||||
| @@ -69,7 +69,7 @@ void scale(size_t factor, //valid range: 2 - SCALE_FACTOR_MAX | ||||
| void bilinearScale(const uint32_t* src, int srcWidth, int srcHeight, | ||||
|                    /**/  uint32_t* trg, int trgWidth, int trgHeight); | ||||
|  | ||||
| void nearestneighbourScale(const uint32_t* src, int srcWidth, int srcHeight, | ||||
| void nearestNeighborScale(const uint32_t* src, int srcWidth, int srcHeight, | ||||
|                           /**/  uint32_t* trg, int trgWidth, int trgHeight); | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -67,9 +67,9 @@ void fillBlock(Pix* trg, int pitch /*[bytes]*/, Pix col, int blockWidth, int blo | ||||
| } | ||||
|  | ||||
|  | ||||
| //nearest-neighbour (going over target image - slow for upscaling, since source is read multiple times missing out on cache! Fast for similar image sizes!) | ||||
| //nearest-neighbor (going over target image - slow for upscaling, since source is read multiple times missing out on cache! Fast for similar image sizes!) | ||||
| template <class PixSrc, class PixTrg, class PixConverter> | ||||
| void nearestneighbourScale(const PixSrc* src, int srcWidth, int srcHeight, int srcPitch /*[bytes]*/, | ||||
| void nearestNeighborScale(const PixSrc* src, int srcWidth, int srcHeight, int srcPitch /*[bytes]*/, | ||||
|                           /**/  PixTrg* trg, int trgWidth, int trgHeight, int trgPitch /*[bytes]*/, | ||||
|                           int yFirst, int yLast, PixConverter pixCvrt /*convert PixSrc to PixTrg*/) | ||||
| { | ||||
| @@ -104,9 +104,9 @@ void nearestneighbourScale(const PixSrc* src, int srcWidth, int srcHeight, int s | ||||
| } | ||||
|  | ||||
|  | ||||
| //nearest-neighbour (going over source image - fast for upscaling, since source is read only once | ||||
| //nearest-neighbor (going over source image - fast for upscaling, since source is read only once | ||||
| template <class PixSrc, class PixTrg, class PixConverter> | ||||
| void nearestneighbourScaleOverSource(const PixSrc* src, int srcWidth, int srcHeight, int srcPitch /*[bytes]*/, | ||||
| void nearestNeighborScaleOverSource(const PixSrc* src, int srcWidth, int srcHeight, int srcPitch /*[bytes]*/, | ||||
|                                     /**/  PixTrg* trg, int trgWidth, int trgHeight, int trgPitch /*[bytes]*/, | ||||
|                                     int yFirst, int yLast, PixConverter pixCvrt /*convert PixSrc to PixTrg*/) | ||||
| { | ||||
|   | ||||
| @@ -18,7 +18,7 @@ VCMI_LIB_NAMESPACE_BEGIN | ||||
| bool AccessibilityInfo::tileAccessibleWithGate(BattleHex tile, BattleSide side) const | ||||
| { | ||||
| 	//at(otherHex) != EAccessibility::ACCESSIBLE && (at(otherHex) != EAccessibility::GATE || side != BattleSide::DEFENDER) | ||||
| 	auto accessibility = at(tile); | ||||
| 	const auto & accessibility = at(tile); | ||||
|  | ||||
| 	if(accessibility == EAccessibility::ALIVE_STACK) | ||||
| 	{ | ||||
|   | ||||
| @@ -63,16 +63,24 @@ public: | ||||
|  | ||||
| 	/// returns all tiles, unavailable tiles will be set as invalid | ||||
| 	/// order of returned tiles matches EDir enum | ||||
| 	static BattleHexArray generateAllNeighbouringTiles(BattleHex hex) | ||||
| 	static BattleHexArray getAllNeighbouringTiles(BattleHex hex) | ||||
| 	{ | ||||
| 		BattleHexArray ret; | ||||
| 		static ArrayOfBattleHexArrays cache; | ||||
| 		static bool initialized = false; | ||||
|  | ||||
| 		ret.resize(6); | ||||
| 		if(initialized) | ||||
| 			return cache[hex.hex]; | ||||
|  | ||||
| 		for(auto dir : BattleHex::hexagonalDirections()) | ||||
| 			ret.set(dir, hex.cloneInDirection(dir, false)); | ||||
| 		for(BattleHex h = 0; h < GameConstants::BFIELD_SIZE; h.hex++) | ||||
| 		{ | ||||
| 			cache[h].resize(6); | ||||
|  | ||||
| 		return ret; | ||||
| 			for(auto dir : BattleHex::hexagonalDirections()) | ||||
| 				cache[h].set(dir, h.cloneInDirection(dir, false)); | ||||
| 		} | ||||
| 		initialized = true; | ||||
|  | ||||
| 		return cache[hex.hex]; | ||||
| 	} | ||||
|  | ||||
| 	void checkAndPush(BattleHex tile) | ||||
|   | ||||
| @@ -640,11 +640,11 @@ BattleHexArray CBattleInfoCallback::battleGetAvailableHexes(const battle::Unit * | ||||
| 		{ | ||||
| 			// Return true if given hex has at least one available neighbour. | ||||
| 			// Available hexes are already present in ret vector. | ||||
| 			auto availableneighbour = boost::find_if(ret, [=] (BattleHex availableHex) | ||||
| 			auto availableNeighbour = boost::find_if(ret, [=] (BattleHex availableHex) | ||||
| 			{ | ||||
| 				return BattleHex::mutualPosition(hex, availableHex) >= 0; | ||||
| 			}); | ||||
| 			return availableneighbour != ret.end(); | ||||
| 			return availableNeighbour != ret.end(); | ||||
| 		}; | ||||
| 		for(const auto * otherSt : battleAliveUnits(otherSide(unit->unitSide()))) | ||||
| 		{ | ||||
| @@ -1112,9 +1112,8 @@ bool CBattleInfoCallback::isInObstacle( | ||||
| 	const BattleHexArray & obstacleHexes, | ||||
| 	const ReachabilityInfo::Parameters & params) const | ||||
| { | ||||
| 	const BattleHexArray & occupiedHexes = battle::Unit::getHexes(hex, params.doubleWide, params.side); | ||||
|  | ||||
| 	for(auto occupiedHex : occupiedHexes) | ||||
| 	for(auto occupiedHex : battle::Unit::getHexes(hex, params.doubleWide, params.side)) | ||||
| 	{ | ||||
| 		if(params.ignoreKnownAccessible && params.knownAccessible->contains(occupiedHex)) | ||||
| 			continue; | ||||
|   | ||||
| @@ -220,6 +220,7 @@ ILimiter::EDecision UnitOnHexLimiter::limit(const BonusLimitationContext &contex | ||||
| 		return ILimiter::EDecision::DISCARD; | ||||
|  | ||||
| 	auto accept = false; | ||||
|  | ||||
| 	for (auto hex : stack->getHexes()) | ||||
| 		accept |= applicableHexes.contains(hex); | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user