Browse Source

Formatting

Ivan Savenko 2 years ago
parent
commit
58aa5c0427

+ 0 - 3
client/CPlayerInterface.h

@@ -125,9 +125,6 @@ public:
 	std::shared_ptr<CBattleGameInterface> autofightingAI; //AI that makes decisions
 	bool isAutoFightOn; //Flag, switch it to stop quick combat. Don't touch if there is no battle interface.
 
-	const CArmedInstance * getSelection();
-	void setSelection(const CArmedInstance * obj);
-
 	struct SpellbookLastSetting
 	{
 		int spellbookLastPageBattle, spellbokLastPageAdvmap; //on which page we left spellbook

+ 17 - 19
client/adventureMap/MapAudioPlayer.cpp

@@ -10,16 +10,16 @@
 #include "StdInc.h"
 #include "MapAudioPlayer.h"
 
-#include "../mapView/mapHandler.h"
-#include "../CPlayerInterface.h"
-#include "../CGameInfo.h"
 #include "../CCallback.h"
+#include "../CGameInfo.h"
 #include "../CMusicHandler.h"
+#include "../CPlayerInterface.h"
+#include "../mapView/mapHandler.h"
 
-#include "../../lib/mapping/CMap.h"
+#include "../../lib/TerrainHandler.h"
 #include "../../lib/mapObjects/CArmedInstance.h"
 #include "../../lib/mapObjects/CGHeroInstance.h"
-#include "../../lib/TerrainHandler.h"
+#include "../../lib/mapping/CMap.h"
 
 bool MapAudioPlayer::hasOngoingAnimations()
 {
@@ -28,25 +28,25 @@ bool MapAudioPlayer::hasOngoingAnimations()
 
 void MapAudioPlayer::onHeroMoved(const CGHeroInstance * obj, const int3 & from, const int3 & dest)
 {
-	if (obj == currentSelection)
+	if(obj == currentSelection)
 		update();
 }
 
 void MapAudioPlayer::onAfterHeroTeleported(const CGHeroInstance * obj, const int3 & from, const int3 & dest)
 {
-	if (obj == currentSelection)
+	if(obj == currentSelection)
 		update();
 }
 
 void MapAudioPlayer::onAfterHeroEmbark(const CGHeroInstance * obj, const int3 & from, const int3 & dest)
 {
-	if (obj == currentSelection)
+	if(obj == currentSelection)
 		update();
 }
 
 void MapAudioPlayer::onAfterHeroDisembark(const CGHeroInstance * obj, const int3 & from, const int3 & dest)
 {
-	if (obj == currentSelection)
+	if(obj == currentSelection)
 		update();
 }
 
@@ -72,7 +72,7 @@ void MapAudioPlayer::onObjectInstantRemove(const CGObjectInstance * obj)
 
 void MapAudioPlayer::addObject(const CGObjectInstance * obj)
 {
-	if (obj->isTile2Terrain())
+	if(obj->isTile2Terrain())
 	{
 		// terrain overlay - all covering tiles act as sound source
 		for(int fx = 0; fx < obj->getWidth(); ++fx)
@@ -88,7 +88,7 @@ void MapAudioPlayer::addObject(const CGObjectInstance * obj)
 		return;
 	}
 
-	if (obj->isVisitable())
+	if(obj->isVisitable())
 	{
 		// visitable object - visitable tile acts as sound source
 		int3 currTile = obj->visitablePos();
@@ -99,12 +99,12 @@ void MapAudioPlayer::addObject(const CGObjectInstance * obj)
 		return;
 	}
 
-	if (!obj->isVisitable())
+	if(!obj->isVisitable())
 	{
 		// static object - blocking tiles act as sound source
 		auto tiles = obj->getBlockedOffsets();
 
-		for (const auto & tile : tiles)
+		for(const auto & tile : tiles)
 		{
 			int3 currTile = obj->pos + tile;
 
@@ -123,7 +123,6 @@ void MapAudioPlayer::removeObject(const CGObjectInstance * obj)
 				vstd::erase(objects[z][x][y], obj->id);
 }
 
-
 std::vector<std::string> MapAudioPlayer::getAmbientSounds(const int3 & tile)
 {
 	std::vector<std::string> result;
@@ -145,7 +144,7 @@ std::vector<std::string> MapAudioPlayer::getAmbientSounds(const int3 & tile)
 void MapAudioPlayer::updateAmbientSounds()
 {
 	std::map<std::string, int> currentSounds;
-	auto updateSounds = [&](std::string soundId, int distance) -> void
+	auto updateSounds = [&](const std::string& soundId, int distance) -> void
 	{
 		if(vstd::contains(currentSounds, soundId))
 			currentSounds[soundId] = std::min(currentSounds[soundId], distance);
@@ -162,20 +161,19 @@ void MapAudioPlayer::updateAmbientSounds()
 
 		for(auto & soundName : getAmbientSounds(tile))
 			updateSounds(soundName, dist);
-
 	}
 	CCS->soundh->ambientUpdateChannels(currentSounds);
 }
 
 void MapAudioPlayer::updateMusic()
 {
-	if (audioPlaying && playerMakingTurn && currentSelection)
+	if(audioPlaying && playerMakingTurn && currentSelection)
 	{
 		const auto * terrain = LOCPLINT->cb->getTile(currentSelection->visitablePos())->terType;
 		CCS->musich->playMusicFromSet("terrain", terrain->getJsonKey(), true, false);
 	}
 
-	if (audioPlaying && enemyMakingTurn)
+	if(audioPlaying && enemyMakingTurn)
 	{
 		CCS->musich->playMusicFromSet("enemy-turn", true, false);
 	}
@@ -185,7 +183,7 @@ void MapAudioPlayer::update()
 {
 	updateMusic();
 
-	if (audioPlaying && playerMakingTurn && currentSelection)
+	if(audioPlaying && playerMakingTurn && currentSelection)
 		updateAmbientSounds();
 }
 

+ 1 - 1
client/adventureMap/MapAudioPlayer.h

@@ -49,7 +49,7 @@ protected:
 
 public:
 	MapAudioPlayer();
-	~MapAudioPlayer();
+	~MapAudioPlayer() override;
 
 	/// Called whenever current adventure map selection changes
 	void onSelectionChanged(const CArmedInstance * newSelection);

+ 1 - 1
client/mapView/IMapRendererContext.h

@@ -56,7 +56,7 @@ public:
 	virtual Point objectImageOffset(ObjectInstanceID objectID, const int3 & coordinates) const = 0;
 
 	/// returns object animation transparency. IF set to 0, object will not be visible
-	virtual double objectTransparency(ObjectInstanceID objectID, const int3 &coordinates) const = 0;
+	virtual double objectTransparency(ObjectInstanceID objectID, const int3 & coordinates) const = 0;
 
 	/// returns animation frame for selected object
 	virtual size_t objectImageIndex(ObjectInstanceID objectID, size_t groupSize) const = 0;

+ 4 - 4
client/mapView/IMapRendererObserver.h

@@ -44,9 +44,9 @@ public:
 	virtual void onBeforeHeroTeleported(const CGHeroInstance * obj, const int3 & from, const int3 & dest) {}
 	virtual void onAfterHeroTeleported(const CGHeroInstance * obj, const int3 & from, const int3 & dest) {}
 
-	virtual void onBeforeHeroEmbark(const CGHeroInstance * obj, const int3 & from, const int3 & dest) {};
-	virtual void onAfterHeroEmbark(const CGHeroInstance * obj, const int3 & from, const int3 & dest) {};
+	virtual void onBeforeHeroEmbark(const CGHeroInstance * obj, const int3 & from, const int3 & dest){};
+	virtual void onAfterHeroEmbark(const CGHeroInstance * obj, const int3 & from, const int3 & dest){};
 
-	virtual void onBeforeHeroDisembark(const CGHeroInstance * obj, const int3 & from, const int3 & dest) {};
-	virtual void onAfterHeroDisembark(const CGHeroInstance * obj, const int3 & from, const int3 & dest) {};
+	virtual void onBeforeHeroDisembark(const CGHeroInstance * obj, const int3 & from, const int3 & dest){};
+	virtual void onAfterHeroDisembark(const CGHeroInstance * obj, const int3 & from, const int3 & dest){};
 };

+ 2 - 2
client/mapView/MapRendererContext.cpp

@@ -19,10 +19,10 @@
 #include "../CPlayerInterface.h"
 #include "../adventureMap/CAdvMapInt.h"
 
+#include "../../lib/CPathfinder.h"
 #include "../../lib/Point.h"
 #include "../../lib/mapObjects/CGHeroInstance.h"
 #include "../../lib/mapping/CMap.h"
-#include "../../lib/CPathfinder.h"
 
 MapRendererBaseContext::MapRendererBaseContext(const MapRendererContextState & viewState)
 	: viewState(viewState)
@@ -411,7 +411,7 @@ double MapRendererSpellViewContext::objectTransparency(ObjectInstanceID objectID
 
 bool MapRendererSpellViewContext::isVisible(const int3 & coordinates) const
 {
-	if (showAllTerrain)
+	if(showAllTerrain)
 		return isInMap(coordinates);
 	return MapRendererBaseContext::isVisible(coordinates);
 }

+ 1 - 1
client/mapView/MapRendererContextState.cpp

@@ -14,10 +14,10 @@
 #include "IMapRendererContext.h"
 #include "mapHandler.h"
 
+#include "../../CCallback.h"
 #include "../CGameInfo.h"
 #include "../CPlayerInterface.h"
 #include "../adventureMap/CAdvMapInt.h"
-#include "../../CCallback.h"
 
 #include "../../lib/mapObjects/CGHeroInstance.h"
 #include "../../lib/mapping/CMap.h"

+ 1 - 1
client/mapView/MapRendererContextState.h

@@ -9,8 +9,8 @@
  */
 #pragma once
 
-#include "../lib/int3.h"
 #include "../lib/GameConstants.h"
+#include "../lib/int3.h"
 
 VCMI_LIB_NAMESPACE_BEGIN
 struct ObjectPosInfo;

+ 2 - 2
client/mapView/MapView.h

@@ -73,10 +73,10 @@ public:
 	void onCenteredObject(const CGObjectInstance * target);
 
 	/// Switches view to "View Earth" / "View Air" mode, displaying downscaled map with overlay
-	void onViewSpellActivated( uint32_t tileSize, const std::vector<ObjectPosInfo>& objectPositions, bool showTerrain);
+	void onViewSpellActivated(uint32_t tileSize, const std::vector<ObjectPosInfo> & objectPositions, bool showTerrain);
 
 	/// Switches view to downscaled View World
-	void onViewWorldActivated( uint32_t tileSize);
+	void onViewWorldActivated(uint32_t tileSize);
 
 	/// Switches view from View World mode back to standard view
 	void onViewMapActivated();

+ 8 - 8
client/mapView/MapViewActions.cpp

@@ -11,8 +11,8 @@
 #include "MapViewActions.h"
 
 #include "IMapRendererContext.h"
-#include "MapViewModel.h"
 #include "MapView.h"
+#include "MapViewModel.h"
 
 #include "../CGameInfo.h"
 #include "../adventureMap/CAdvMapInt.h"
@@ -21,7 +21,7 @@
 
 #include "../../lib/CConfigHandler.h"
 
-MapViewActions::MapViewActions(MapView & owner, const std::shared_ptr<MapViewModel>& model)
+MapViewActions::MapViewActions(MapView & owner, const std::shared_ptr<MapViewModel> & model)
 	: model(model)
 	, owner(owner)
 	, curHoveredTile(-1, -1, -1)
@@ -51,7 +51,7 @@ void MapViewActions::activate()
 void MapViewActions::deactivate()
 {
 	CIntObject::deactivate();
-	curHoveredTile = int3(-1,-1,-1); //we lost info about hovered tile when disabling
+	curHoveredTile = int3(-1, -1, -1); //we lost info about hovered tile when disabling
 }
 
 void MapViewActions::clickLeft(tribool down, bool previousState)
@@ -74,7 +74,7 @@ void MapViewActions::clickLeft(tribool down, bool previousState)
 
 	int3 tile = model->getTileAtPoint(GH.getCursorPosition() - pos.topLeft());
 
-	if (context->isInMap(tile))
+	if(context->isInMap(tile))
 		adventureInt->onTileLeftClicked(tile);
 }
 
@@ -85,7 +85,7 @@ void MapViewActions::clickRight(tribool down, bool previousState)
 
 	int3 tile = model->getTileAtPoint(GH.getCursorPosition() - pos.topLeft());
 
-	if (down && context->isInMap(tile))
+	if(down && context->isInMap(tile))
 		adventureInt->onTileRightClicked(tile);
 }
 
@@ -116,7 +116,7 @@ void MapViewActions::handleSwipeMove(const Point & cursorPosition)
 		Point distance = (cursorPosition - swipeInitialRealPos);
 
 		// try to distinguish if this touch was meant to be a swipe or just fat-fingering press
-		if( std::abs(distance.x) + std::abs(distance.y) > touchSwipeSlop)
+		if(std::abs(distance.x) + std::abs(distance.y) > touchSwipeSlop)
 			isSwiping = true;
 	}
 
@@ -155,7 +155,7 @@ void MapViewActions::handleHover(const Point & cursorPosition)
 		return;
 	}
 
-	if (tile != curHoveredTile)
+	if(tile != curHoveredTile)
 	{
 		curHoveredTile = tile;
 		adventureInt->onTileHovered(tile);
@@ -164,7 +164,7 @@ void MapViewActions::handleHover(const Point & cursorPosition)
 
 void MapViewActions::hover(bool on)
 {
-	if (!on)
+	if(!on)
 	{
 		GH.statusbar->clear();
 		CCS->curh->set(Cursor::Map::POINTER);

+ 3 - 3
client/mapView/MapViewActions.h

@@ -9,8 +9,8 @@
  */
 #pragma once
 
-#include "../gui/CIntObject.h"
 #include "../../lib/int3.h"
+#include "../gui/CIntObject.h"
 
 class IMapRendererContext;
 class MapViewModel;
@@ -35,7 +35,7 @@ class MapViewActions : public CIntObject
 	bool handleSwipeStateChange(bool btnPressed);
 
 public:
-	MapViewActions(MapView & owner, const std::shared_ptr<MapViewModel>& model);
+	MapViewActions(MapView & owner, const std::shared_ptr<MapViewModel> & model);
 
 	void setContext(const std::shared_ptr<IMapRendererContext> & context);
 
@@ -45,5 +45,5 @@ public:
 	void clickRight(tribool down, bool previousState) override;
 	void clickMiddle(tribool down, bool previousState) override;
 	void hover(bool on) override;
-	void mouseMoved (const Point & cursorPosition) override;
+	void mouseMoved(const Point & cursorPosition) override;
 };

+ 6 - 6
client/mapView/MapViewCache.cpp

@@ -61,21 +61,21 @@ void MapViewCache::invalidate(const std::shared_ptr<IMapRendererContext> & conte
 
 	auto & entry = terrainChecksum[cacheX][cacheY];
 
-	if (entry.tileX == tile.x && entry.tileY ==tile.y)
+	if(entry.tileX == tile.x && entry.tileY == tile.y)
 		entry = TileChecksum{};
 }
 
 void MapViewCache::invalidate(const std::shared_ptr<IMapRendererContext> & context, const ObjectInstanceID & object)
 {
-	for (size_t cacheY = 0; cacheY < terrainChecksum.shape()[1]; ++cacheY)
+	for(size_t cacheY = 0; cacheY < terrainChecksum.shape()[1]; ++cacheY)
 	{
-		for (size_t cacheX = 0; cacheX < terrainChecksum.shape()[0]; ++cacheX)
+		for(size_t cacheX = 0; cacheX < terrainChecksum.shape()[0]; ++cacheX)
 		{
 			auto & entry = terrainChecksum[cacheX][cacheY];
 
-			int3 tile( entry.tileX, entry.tileY, cachedLevel);
+			int3 tile(entry.tileX, entry.tileY, cachedLevel);
 
-			if (context->isInMap(tile) && vstd::contains(context->getObjects(tile), object))
+			if(context->isInMap(tile) && vstd::contains(context->getObjects(tile), object))
 				entry = TileChecksum{};
 		}
 	}
@@ -108,7 +108,7 @@ void MapViewCache::updateTile(const std::shared_ptr<IMapRendererContext> & conte
 		target.drawScaled(*intermediate, Point(0, 0), model->getSingleTileSize());
 	}
 
-	if (context->filterGrayscale())
+	if(context->filterGrayscale())
 		target.applyGrayscale();
 
 	oldCacheEntry = newCacheEntry;

+ 4 - 3
client/mapView/MapViewCache.h

@@ -30,9 +30,9 @@ class MapViewCache
 	{
 		int tileX = std::numeric_limits<int>::min();
 		int tileY = std::numeric_limits<int>::min();
-		std::array<uint8_t, 8> checksum {};
+		std::array<uint8_t, 8> checksum{};
 
-		bool operator == (const TileChecksum & other) const
+		bool operator==(const TileChecksum & other) const
 		{
 			return tileX == other.tileX && tileY == other.tileY && checksum == other.checksum;
 		}
@@ -57,6 +57,7 @@ class MapViewCache
 	void updateTile(const std::shared_ptr<IMapRendererContext> & context, const int3 & coordinates);
 
 	std::shared_ptr<IImage> getOverlayImageForTile(const std::shared_ptr<IMapRendererContext> & context, const int3 & coordinates);
+
 public:
 	explicit MapViewCache(const std::shared_ptr<MapViewModel> & model);
 	~MapViewCache();
@@ -68,5 +69,5 @@ public:
 	void update(const std::shared_ptr<IMapRendererContext> & context);
 
 	/// renders updated terrain cache onto provided canvas
-	void render(const std::shared_ptr<IMapRendererContext> &context, Canvas & target, bool fullRedraw);
+	void render(const std::shared_ptr<IMapRendererContext> & context, Canvas & target, bool fullRedraw);
 };

+ 36 - 42
client/mapView/MapViewController.cpp

@@ -13,17 +13,17 @@
 
 #include "MapRendererContext.h"
 #include "MapRendererContextState.h"
-#include "MapViewModel.h"
 #include "MapViewCache.h"
+#include "MapViewModel.h"
 
-#include "../adventureMap/CAdvMapInt.h"
 #include "../CPlayerInterface.h"
+#include "../adventureMap/CAdvMapInt.h"
 
 #include "../../lib/CConfigHandler.h"
+#include "../../lib/CPathfinder.h"
 #include "../../lib/mapObjects/CGHeroInstance.h"
 #include "../../lib/mapObjects/MiscObjects.h"
 #include "../../lib/spells/ViewSpellInt.h"
-#include "../../lib/CPathfinder.h"
 
 void MapViewController::setViewCenter(const int3 & position)
 {
@@ -34,9 +34,9 @@ void MapViewController::setViewCenter(const int3 & position)
 void MapViewController::setViewCenter(const Point & position, int level)
 {
 	Point upperLimit = Point(context->getMapSize()) * model->getSingleTileSize() + model->getSingleTileSize();
-	Point lowerLimit = Point(0,0);
+	Point lowerLimit = Point(0, 0);
 
-	if (worldViewContext)
+	if(worldViewContext)
 	{
 		Point area = model->getPixelsVisibleDimensions();
 		Point mapCenter = upperLimit / 2;
@@ -44,12 +44,12 @@ void MapViewController::setViewCenter(const Point & position, int level)
 		Point desiredLowerLimit = lowerLimit + area / 2;
 		Point desiredUpperLimit = upperLimit - area / 2;
 
-		Point actualLowerLimit {
+		Point actualLowerLimit{
 			std::min(desiredLowerLimit.x, mapCenter.x),
 			std::min(desiredLowerLimit.y, mapCenter.y)
 		};
 
-		Point actualUpperLimit {
+		Point actualUpperLimit{
 			std::max(desiredUpperLimit.x, mapCenter.x),
 			std::max(desiredUpperLimit.y, mapCenter.y)
 		};
@@ -58,15 +58,12 @@ void MapViewController::setViewCenter(const Point & position, int level)
 		lowerLimit = actualLowerLimit;
 	}
 
-	Point betterPosition = {
-		vstd::clamp(position.x, lowerLimit.x, upperLimit.x),
-		vstd::clamp(position.y, lowerLimit.y, upperLimit.y)
-	};
+	Point betterPosition = {vstd::clamp(position.x, lowerLimit.x, upperLimit.x), vstd::clamp(position.y, lowerLimit.y, upperLimit.y)};
 
 	model->setViewCenter(betterPosition);
 	model->setLevel(vstd::clamp(level, 0, context->getMapSize().z));
 
-	if (adventureInt) // may be called before adventureInt is initialized
+	if(adventureInt) // may be called before adventureInt is initialized
 		adventureInt->onMapViewMoved(model->getTilesTotalRect(), model->getLevel());
 }
 
@@ -109,17 +106,16 @@ void MapViewController::update(uint32_t timeDelta)
 	if(movementContext)
 	{
 		const auto * object = context->getObject(movementContext->target);
-		const auto * hero = dynamic_cast<const CGHeroInstance*>(object);
-		const auto * boat = dynamic_cast<const CGBoat*>(object);
+		const auto * hero = dynamic_cast<const CGHeroInstance *>(object);
+		const auto * boat = dynamic_cast<const CGBoat *>(object);
 
 		assert(boat || hero);
 
-		if (!hero)
+		if(!hero)
 			hero = boat->hero;
 
-		double heroMoveTime =
-			LOCPLINT->makingTurn ?
-			settings["adventure"]["heroMoveTime"].Float():
+		double heroMoveTime = LOCPLINT->makingTurn ?
+			settings["adventure"]["heroMoveTime"].Float() :
 			settings["adventure"]["enemyMoveTime"].Float();
 
 		movementContext->progress += timeDelta / heroMoveTime;
@@ -174,7 +170,7 @@ void MapViewController::update(uint32_t timeDelta)
 		}
 	}
 
-	if (adventureContext)
+	if(adventureContext)
 	{
 		adventureContext->animationTime += timeDelta;
 		adventureContext->settingsSessionSpectate = settings["session"]["spectate"].Bool();
@@ -188,13 +184,13 @@ void MapViewController::update(uint32_t timeDelta)
 
 bool MapViewController::isEventVisible(const CGObjectInstance * obj)
 {
-	if (adventureContext == nullptr)
+	if(adventureContext == nullptr)
 		return false;
 
-	if (!LOCPLINT->makingTurn && settings["adventure"]["enemyMoveTime"].Float() < 0)
+	if(!LOCPLINT->makingTurn && settings["adventure"]["enemyMoveTime"].Float() < 0)
 		return false; // enemy move speed set to "hidden/none"
 
-	if (obj->isVisitable())
+	if(obj->isVisitable())
 		return context->isVisible(obj->visitablePos());
 	else
 		return context->isVisible(obj->pos);
@@ -202,16 +198,16 @@ bool MapViewController::isEventVisible(const CGObjectInstance * obj)
 
 bool MapViewController::isEventVisible(const CGHeroInstance * obj, const int3 & from, const int3 & dest)
 {
-	if (adventureContext == nullptr)
+	if(adventureContext == nullptr)
 		return false;
 
-	if (!LOCPLINT->makingTurn && settings["adventure"]["enemyMoveTime"].Float() < 0)
+	if(!LOCPLINT->makingTurn && settings["adventure"]["enemyMoveTime"].Float() < 0)
 		return false; // enemy move speed set to "hidden/none"
 
-	if (context->isVisible(obj->convertToVisitablePos(from)))
+	if(context->isVisible(obj->convertToVisitablePos(from)))
 		return true;
 
-	if (context->isVisible(obj->convertToVisitablePos(dest)))
+	if(context->isVisible(obj->convertToVisitablePos(dest)))
 		return true;
 
 	return false;
@@ -253,7 +249,7 @@ void MapViewController::addObject(const CGObjectInstance * obj)
 
 void MapViewController::onBeforeHeroEmbark(const CGHeroInstance * obj, const int3 & from, const int3 & dest)
 {
-	if (isEventVisible(obj, from, dest))
+	if(isEventVisible(obj, from, dest))
 	{
 		onObjectFadeOut(obj);
 		setViewCenter(obj->getSightCenter());
@@ -264,19 +260,19 @@ void MapViewController::onBeforeHeroEmbark(const CGHeroInstance * obj, const int
 
 void MapViewController::onAfterHeroEmbark(const CGHeroInstance * obj, const int3 & from, const int3 & dest)
 {
-	if (isEventVisible(obj, from, dest))
+	if(isEventVisible(obj, from, dest))
 		setViewCenter(obj->getSightCenter());
 }
 
 void MapViewController::onBeforeHeroDisembark(const CGHeroInstance * obj, const int3 & from, const int3 & dest)
 {
-	if (isEventVisible(obj, from, dest))
+	if(isEventVisible(obj, from, dest))
 		setViewCenter(obj->getSightCenter());
 }
 
 void MapViewController::onAfterHeroDisembark(const CGHeroInstance * obj, const int3 & from, const int3 & dest)
 {
-	if (isEventVisible(obj, from, dest))
+	if(isEventVisible(obj, from, dest))
 	{
 		onObjectFadeIn(obj);
 		setViewCenter(obj->getSightCenter());
@@ -288,7 +284,7 @@ void MapViewController::onObjectFadeIn(const CGObjectInstance * obj)
 {
 	assert(!hasOngoingAnimations());
 
-	if (isEventVisible(obj))
+	if(isEventVisible(obj))
 		fadeInObject(obj);
 
 	addObject(obj);
@@ -298,7 +294,7 @@ void MapViewController::onObjectFadeOut(const CGObjectInstance * obj)
 {
 	assert(!hasOngoingAnimations());
 
-	if (isEventVisible(obj))
+	if(isEventVisible(obj))
 		fadeOutObject(obj);
 	else
 		removeObject(obj);
@@ -318,7 +314,7 @@ void MapViewController::onBeforeHeroTeleported(const CGHeroInstance * obj, const
 {
 	assert(!hasOngoingAnimations());
 
-	if (isEventVisible(obj, from, dest))
+	if(isEventVisible(obj, from, dest))
 	{
 		// TODO: generate view with old state
 		setViewCenter(obj->getSightCenter());
@@ -330,7 +326,7 @@ void MapViewController::onAfterHeroTeleported(const CGHeroInstance * obj, const
 {
 	assert(!hasOngoingAnimations());
 
-	if (isEventVisible(obj, from, dest))
+	if(isEventVisible(obj, from, dest))
 	{
 		// TODO: animation
 		setViewCenter(obj->getSightCenter());
@@ -348,7 +344,7 @@ void MapViewController::onHeroMoved(const CGHeroInstance * obj, const int3 & fro
 	assert(!hasOngoingAnimations());
 
 	// revisiting via spacebar, no need to animate
-	if (from == dest)
+	if(from == dest)
 		return;
 
 	const CGObjectInstance * movingObject = obj;
@@ -357,15 +353,14 @@ void MapViewController::onHeroMoved(const CGHeroInstance * obj, const int3 & fro
 
 	removeObject(movingObject);
 
-	if (!isEventVisible(obj, from, dest))
+	if(!isEventVisible(obj, from, dest))
 	{
 		addObject(movingObject);
 		return;
 	}
 
-	double movementTime =
-		LOCPLINT->playerID == obj->tempOwner ?
-		settings["adventure"]["heroMoveTime"].Float():
+	double movementTime = LOCPLINT->playerID == obj->tempOwner ?
+		settings["adventure"]["heroMoveTime"].Float() :
 		settings["adventure"]["enemyMoveTime"].Float();
 
 	if(movementTime > 1)
@@ -419,7 +414,7 @@ void MapViewController::activateAdventureContext()
 
 void MapViewController::activateWorldViewContext()
 {
-	if (worldViewContext)
+	if(worldViewContext)
 		return;
 
 	resetContext();
@@ -430,7 +425,7 @@ void MapViewController::activateWorldViewContext()
 
 void MapViewController::activateSpellViewContext()
 {
-	if (spellViewContext)
+	if(spellViewContext)
 		return;
 
 	resetContext();
@@ -479,4 +474,3 @@ void MapViewController::setOverlayVisibility(const std::vector<ObjectPosInfo> &
 	assert(spellViewContext);
 	spellViewContext->additionalOverlayIcons = objectPositions;
 }
-

+ 0 - 1
client/mapView/MapViewController.h

@@ -92,5 +92,4 @@ public:
 
 	void setTerrainVisibility(bool showAllTerrain);
 	void setOverlayVisibility(const std::vector<ObjectPosInfo> & objectPositions);
-
 };

+ 27 - 26
client/mapView/mapHandler.cpp

@@ -9,24 +9,24 @@
  */
 
 #include "StdInc.h"
-#include "mapHandler.h"
 #include "IMapRendererObserver.h"
+#include "mapHandler.h"
 
+#include "../CCallback.h"
 #include "../CGameInfo.h"
 #include "../CPlayerInterface.h"
-#include "../CCallback.h"
 
+#include "../../lib/CGeneralTextHandler.h"
+#include "../../lib/TerrainHandler.h"
 #include "../../lib/UnlockGuard.h"
 #include "../../lib/mapObjects/CGHeroInstance.h"
 #include "../../lib/mapObjects/CObjectClassesHandler.h"
 #include "../../lib/mapping/CMap.h"
-#include "../../lib/CGeneralTextHandler.h"
-#include "../../lib/TerrainHandler.h"
 
 bool CMapHandler::hasOngoingAnimations()
 {
-	for (auto * observer : observers)
-		if (observer->hasOngoingAnimations())
+	for(auto * observer : observers)
+		if(observer->hasOngoingAnimations())
 			return true;
 
 	return false;
@@ -34,7 +34,7 @@ bool CMapHandler::hasOngoingAnimations()
 
 void CMapHandler::waitForOngoingAnimations()
 {
-	while (CGI->mh->hasOngoingAnimations())
+	while(CGI->mh->hasOngoingAnimations())
 	{
 		auto unlockPim = vstd::makeUnlockGuard(*CPlayerInterface::pim);
 		boost::this_thread::sleep(boost::posix_time::milliseconds(1));
@@ -61,9 +61,10 @@ std::string CMapHandler::getTerrainDescr(const int3 & pos, bool rightClick) cons
 
 	if(LOCPLINT->cb->getTileDigStatus(pos, false) == EDiggingStatus::CAN_DIG)
 	{
-		return boost::str(boost::format(rightClick ? "%s\r\n%s" : "%s %s") // New line for the Message Box, space for the Status Bar
-			% result
-			% CGI->generaltexth->allTexts[330]); // 'digging ok'
+		return boost::str(
+			boost::format(rightClick ? "%s\r\n%s" : "%s %s") // New line for the Message Box, space for the Status Bar
+			% result % CGI->generaltexth->allTexts[330]
+		); // 'digging ok'
 	}
 
 	return result;
@@ -131,77 +132,77 @@ const CMap * CMapHandler::getMap()
 	return map;
 }
 
-bool CMapHandler::isInMap( const int3 & tile)
+bool CMapHandler::isInMap(const int3 & tile)
 {
 	return map->isInTheMap(tile);
 }
 
 void CMapHandler::onObjectFadeIn(const CGObjectInstance * obj)
 {
-	for (auto * observer : observers)
+	for(auto * observer : observers)
 		observer->onObjectFadeIn(obj);
 }
 
 void CMapHandler::onObjectFadeOut(const CGObjectInstance * obj)
 {
-	for (auto * observer : observers)
+	for(auto * observer : observers)
 		observer->onObjectFadeOut(obj);
 }
 
-void CMapHandler::onBeforeHeroEmbark(const CGHeroInstance *obj, const int3 &from, const int3 &dest)
+void CMapHandler::onBeforeHeroEmbark(const CGHeroInstance * obj, const int3 & from, const int3 & dest)
 {
-	for (auto * observer : observers)
+	for(auto * observer : observers)
 		observer->onBeforeHeroEmbark(obj, from, dest);
 }
 
-void CMapHandler::onAfterHeroEmbark(const CGHeroInstance *obj, const int3 &from, const int3 &dest)
+void CMapHandler::onAfterHeroEmbark(const CGHeroInstance * obj, const int3 & from, const int3 & dest)
 {
-	for (auto * observer : observers)
+	for(auto * observer : observers)
 		observer->onAfterHeroEmbark(obj, from, dest);
 }
 
-void CMapHandler::onBeforeHeroDisembark(const CGHeroInstance *obj, const int3 &from, const int3 &dest)
+void CMapHandler::onBeforeHeroDisembark(const CGHeroInstance * obj, const int3 & from, const int3 & dest)
 {
-	for (auto * observer : observers)
+	for(auto * observer : observers)
 		observer->onBeforeHeroDisembark(obj, from, dest);
 }
 
-void CMapHandler::onAfterHeroDisembark(const CGHeroInstance *obj, const int3 &from, const int3 &dest)
+void CMapHandler::onAfterHeroDisembark(const CGHeroInstance * obj, const int3 & from, const int3 & dest)
 {
-	for (auto * observer : observers)
+	for(auto * observer : observers)
 		observer->onAfterHeroDisembark(obj, from, dest);
 }
 
 void CMapHandler::onObjectInstantAdd(const CGObjectInstance * obj)
 {
-	for (auto * observer : observers)
+	for(auto * observer : observers)
 		observer->onObjectInstantAdd(obj);
 }
 
 void CMapHandler::onObjectInstantRemove(const CGObjectInstance * obj)
 {
-	for (auto * observer : observers)
+	for(auto * observer : observers)
 		observer->onObjectInstantRemove(obj);
 }
 
 void CMapHandler::onAfterHeroTeleported(const CGHeroInstance * obj, const int3 & from, const int3 & dest)
 {
 	assert(obj->pos == dest);
-	for (auto * observer : observers)
+	for(auto * observer : observers)
 		observer->onAfterHeroTeleported(obj, from, dest);
 }
 
 void CMapHandler::onBeforeHeroTeleported(const CGHeroInstance * obj, const int3 & from, const int3 & dest)
 {
 	assert(obj->pos == from);
-	for (auto * observer : observers)
+	for(auto * observer : observers)
 		observer->onBeforeHeroTeleported(obj, from, dest);
 }
 
 void CMapHandler::onHeroMoved(const CGHeroInstance * obj, const int3 & from, const int3 & dest)
 {
 	assert(obj->pos == dest);
-	for (auto * observer : observers)
+	for(auto * observer : observers)
 		observer->onHeroMoved(obj, from, dest);
 }
 

+ 3 - 4
client/mapView/mapHandler.h

@@ -11,17 +11,16 @@
 
 #include "../gui/CIntObject.h"
 
+#include "../../lib/Rect.h"
 #include "../../lib/int3.h"
 #include "../../lib/spells/ViewSpellInt.h"
-#include "../../lib/Rect.h"
-
 
 #ifdef IN
-#undef IN
+#	undef IN
 #endif
 
 #ifdef OUT
-#undef OUT
+#	undef OUT
 #endif
 
 VCMI_LIB_NAMESPACE_BEGIN