mirror of
				https://github.com/vcmi/vcmi.git
				synced 2025-10-31 00:07:39 +02:00 
			
		
		
		
	Merge pull request #5335 from IvanSavenko/bugfixing_164
Fixes for bugs for 1.6.4
This commit is contained in:
		| @@ -164,10 +164,10 @@ void CPlayerInterface::initGameInterface(std::shared_ptr<Environment> ENV, std:: | ||||
| 	cb = CB; | ||||
| 	env = ENV; | ||||
|  | ||||
| 	pathfinderCache = std::make_unique<PathfinderCache>(cb.get(), PathfinderOptions(cb.get())); | ||||
| 	CCS->musich->loadTerrainMusicThemes(); | ||||
| 	initializeHeroTownList(); | ||||
|  | ||||
| 	pathfinderCache = std::make_unique<PathfinderCache>(cb.get(), PathfinderOptions(cb.get())); | ||||
| 	adventureInt.reset(new AdventureMapInterface()); | ||||
| } | ||||
|  | ||||
| @@ -628,7 +628,6 @@ void CPlayerInterface::buildChanged(const CGTownInstance *town, BuildingID build | ||||
| 			switch(what) | ||||
| 			{ | ||||
| 			case 1: | ||||
| 				CCS->soundh->playSound(soundBase::newBuilding); | ||||
| 				castleInt->addBuilding(buildingID); | ||||
| 				break; | ||||
| 			case 2: | ||||
| @@ -1415,7 +1414,6 @@ void CPlayerInterface::newObject( const CGObjectInstance * obj ) | ||||
| 		&& LOCPLINT->castleInt | ||||
| 		&&  obj->visitablePos() == LOCPLINT->castleInt->town->bestLocation()) | ||||
| 	{ | ||||
| 		CCS->soundh->playSound(soundBase::newBuilding); | ||||
| 		LOCPLINT->castleInt->addBuilding(BuildingID::SHIP); | ||||
| 	} | ||||
| } | ||||
|   | ||||
| @@ -171,7 +171,7 @@ void GlobalLobbyClient::receiveChatMessage(const JsonNode & json) | ||||
| 		lobbyWindowPtr->onGameChatMessage(message.displayName, message.messageText, message.timeFormatted, channelType, channelName); | ||||
| 		lobbyWindowPtr->refreshChatText(); | ||||
|  | ||||
| 		if(channelType == "player" || lobbyWindowPtr->isChannelOpen(channelType, channelName)) | ||||
| 		if(channelType == "player" || (lobbyWindowPtr->isChannelOpen(channelType, channelName) && lobbyWindowPtr->isActive())) | ||||
| 			CCS->soundh->playSound(AudioPath::builtin("CHAT")); | ||||
| 	} | ||||
| } | ||||
|   | ||||
| @@ -252,7 +252,7 @@ SDLImageShared::SDLImageShared(const SDLImageShared * from, int integerScaleFact | ||||
|  | ||||
| 	upscalingInProgress = true; | ||||
|  | ||||
| 	auto scaler = std::make_shared<SDLImageScaler>(from->surf, Rect(from->margins, from->fullSize)); | ||||
| 	auto scaler = std::make_shared<SDLImageScaler>(from->surf, Rect(from->margins, from->fullSize), true); | ||||
|  | ||||
| 	const auto & scalingTask = [this, algorithm, scaler]() | ||||
| 	{ | ||||
| @@ -278,7 +278,7 @@ std::shared_ptr<const ISharedImage> SDLImageShared::scaleTo(const Point & size, | ||||
| 	if (palette && surf->format->palette) | ||||
| 		SDL_SetSurfacePalette(surf, palette); | ||||
|  | ||||
| 	SDLImageScaler scaler(surf, Rect(margins, fullSize)); | ||||
| 	SDLImageScaler scaler(surf, Rect(margins, fullSize), true); | ||||
|  | ||||
| 	scaler.scaleSurface(size, EScalingAlgorithm::XBRZ_ALPHA); | ||||
|  | ||||
|   | ||||
| @@ -196,16 +196,25 @@ void SDLImageScaler::scaleSurfaceIntegerFactor(int factor, EScalingAlgorithm alg | ||||
| } | ||||
|  | ||||
| SDLImageScaler::SDLImageScaler(SDL_Surface * surf) | ||||
| 	:SDLImageScaler(surf, Rect(0,0,surf->w, surf->h)) | ||||
| 	:SDLImageScaler(surf, Rect(0,0,surf->w, surf->h), false) | ||||
| { | ||||
| } | ||||
|  | ||||
| SDLImageScaler::SDLImageScaler(SDL_Surface * surf, const Rect & virtualDimensions) | ||||
| SDLImageScaler::SDLImageScaler(SDL_Surface * surf, const Rect & virtualDimensions, bool optimizeImage) | ||||
| { | ||||
| 	SDLImageOptimizer optimizer(surf, virtualDimensions); | ||||
| 	optimizer.optimizeSurface(screen); | ||||
| 	intermediate = optimizer.acquireResultSurface(); | ||||
| 	virtualDimensionsInput = optimizer.getResultDimensions(); | ||||
| 	if (optimizeImage) | ||||
| 	{ | ||||
| 		SDLImageOptimizer optimizer(surf, virtualDimensions); | ||||
| 		optimizer.optimizeSurface(screen); | ||||
| 		intermediate = optimizer.acquireResultSurface(); | ||||
| 		virtualDimensionsInput = optimizer.getResultDimensions(); | ||||
| 	} | ||||
| 	else | ||||
| 	{ | ||||
| 		intermediate = surf; | ||||
| 		intermediate->refcount += 1; | ||||
| 		virtualDimensionsInput = virtualDimensions; | ||||
| 	} | ||||
|  | ||||
| 	if (intermediate == surf) | ||||
| 	{ | ||||
|   | ||||
| @@ -43,7 +43,7 @@ class SDLImageScaler : boost::noncopyable | ||||
|  | ||||
| public: | ||||
| 	SDLImageScaler(SDL_Surface * surf); | ||||
| 	SDLImageScaler(SDL_Surface * surf, const Rect & virtualDimensions); | ||||
| 	SDLImageScaler(SDL_Surface * surf, const Rect & virtualDimensions, bool optimizeImage); | ||||
| 	~SDLImageScaler(); | ||||
|  | ||||
| 	/// Performs upscaling or downscaling to a requested dimensions | ||||
|   | ||||
| @@ -24,6 +24,7 @@ | ||||
| #include "../gui/Shortcut.h" | ||||
| #include "../gui/WindowHandler.h" | ||||
| #include "../media/IMusicPlayer.h" | ||||
| #include "../media/ISoundPlayer.h" | ||||
| #include "../widgets/MiscWidgets.h" | ||||
| #include "../widgets/CComponent.h" | ||||
| #include "../widgets/CGarrisonInt.h" | ||||
| @@ -1435,6 +1436,9 @@ void CCastleInterface::townChange() | ||||
|  | ||||
| void CCastleInterface::addBuilding(BuildingID bid) | ||||
| { | ||||
| 	if (town->getTown()->buildings.at(bid)->mode != CBuilding::BUILD_AUTO) | ||||
| 		CCS->soundh->playSound(soundBase::newBuilding); | ||||
|  | ||||
| 	deactivate(); | ||||
| 	builds->addBuilding(bid); | ||||
| 	recreateIcons(); | ||||
|   | ||||
| @@ -48,6 +48,10 @@ | ||||
| 			{ | ||||
| 				"type" : "SHOOTER" | ||||
| 			}, | ||||
| 			"noDistancePenalty" : | ||||
| 			{ | ||||
| 				"type" : "NO_DISTANCE_PENALTY" // hide shooting range visualization | ||||
| 			}, | ||||
| 			"siegeMachine" : | ||||
| 			{ | ||||
| 				"type" : "CATAPULT", | ||||
|   | ||||
| @@ -267,6 +267,12 @@ public: | ||||
| 		return hex < other.hex; | ||||
| 	} | ||||
|  | ||||
| 	[[nodiscard]] bool operator <=(const BattleHex & other) const noexcept | ||||
| 	{ | ||||
| 		return hex <= other.hex; | ||||
| 	} | ||||
|  | ||||
|  | ||||
| 	template <typename Handler> | ||||
| 	void serialize(Handler & h) | ||||
| 	{ | ||||
|   | ||||
| @@ -51,7 +51,7 @@ static bool sameSideOfWall(const BattleHex & pos1, const BattleHex & pos2) | ||||
|  | ||||
| static bool isInsideWalls(const BattleHex & pos) | ||||
| { | ||||
| 	return lineToWallHex(pos.getY()) < pos; | ||||
| 	return lineToWallHex(pos.getY()) <= pos; | ||||
| } | ||||
|  | ||||
| // parts of wall | ||||
|   | ||||
| @@ -605,17 +605,18 @@ uint8_t CUnitState::getRangedFullDamageDistance() const | ||||
| 	if(!isShooter()) | ||||
| 		return 0; | ||||
|  | ||||
| 	uint8_t rangedFullDamageDistance = GameConstants::BATTLE_SHOOTING_PENALTY_DISTANCE; | ||||
|  | ||||
| 	// overwrite full ranged damage distance with the value set in Additional info field of LIMITED_SHOOTING_RANGE bonus | ||||
| 	if(hasBonusOfType(BonusType::LIMITED_SHOOTING_RANGE)) | ||||
| 	{ | ||||
| 		auto bonus = this->getBonus(Selector::type()(BonusType::LIMITED_SHOOTING_RANGE)); | ||||
| 		if(bonus != nullptr && bonus->additionalInfo != CAddInfo::NONE) | ||||
| 			rangedFullDamageDistance = bonus->additionalInfo[0]; | ||||
| 			return bonus->additionalInfo[0]; | ||||
| 	} | ||||
|  | ||||
| 	return rangedFullDamageDistance; | ||||
| 	if (hasBonusOfType(BonusType::NO_DISTANCE_PENALTY)) | ||||
| 		return GameConstants::BATTLE_SHOOTING_RANGE_DISTANCE; | ||||
|  | ||||
| 	return GameConstants::BATTLE_SHOOTING_PENALTY_DISTANCE; | ||||
| } | ||||
|  | ||||
| uint8_t CUnitState::getShootingRangeDistance() const | ||||
|   | ||||
| @@ -325,7 +325,7 @@ void LobbyServer::onDisconnected(const NetworkConnectionPtr & connection, const | ||||
|  | ||||
| 	if(activeProxies.count(connection)) | ||||
| 	{ | ||||
| 		const auto & otherConnection = activeProxies.at(connection); | ||||
| 		const auto otherConnection = activeProxies.at(connection); | ||||
|  | ||||
| 		if (otherConnection) | ||||
| 			otherConnection->close(); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user