Browse Source

[tweaks] IImage * -> auto

AlexVinS 7 years ago
parent
commit
43acfa160b

+ 1 - 1
client/CMessage.cpp

@@ -76,7 +76,7 @@ void CMessage::init()
 
         for(int j=0; j < dialogBorders[i]->size(0); j++)
 		{
-			IImage * image = dialogBorders[i]->getImage(j, 0);
+			auto image = dialogBorders[i]->getImage(j, 0);
 			//assume blue color initially
 			if(i != 1)
 				image->playerColored(PlayerColor(i));

+ 1 - 1
client/Graphics.cpp

@@ -303,7 +303,7 @@ void Graphics::loadFogOfWar()
 	for(const int rotation : rotations)
 	{
 		fogOfWarPartialHide->duplicateImage(0, rotation, 0);
-		IImage * image = fogOfWarPartialHide->getImage(size, 0);
+		auto image = fogOfWarPartialHide->getImage(size, 0);
 		image->verticalFlip();
 		size++;
 	}

+ 2 - 2
client/battle/CBattleAnimations.cpp

@@ -830,7 +830,7 @@ bool CShootingAnimation::init()
 		spi.dx = animSpeed;
 		spi.dy = 0;
 
-		IImage * img = owner->idToProjectile[spi.creID]->getImage(0);
+		auto img = owner->idToProjectile[spi.creID]->getImage(0);
 
 		// Add explosion anim
 		Point animPos(destPos.x - 126 + img->width() / 2,
@@ -1100,7 +1100,7 @@ bool CEffectAnimation::init()
 	if(Vflip)
 		animation->verticalFlip();
 
-	IImage * first = animation->getImage(0, 0, true);
+	auto first = animation->getImage(0, 0, true);
 	if(!first)
 	{
 		endAnim();

+ 9 - 9
client/battle/CBattleInterface.cpp

@@ -269,7 +269,7 @@ CBattleInterface::CBattleInterface(const CCreatureSet *army1, const CCreatureSet
 
 		attackingHero = new CBattleHero(battleImage, false, hero1->tempOwner, hero1->tempOwner == curInt->playerID ? hero1 : nullptr, this);
 
-		IImage * img = attackingHero->animation->getImage(0, 0, true);
+		auto img = attackingHero->animation->getImage(0, 0, true);
 		if(img)
 			attackingHero->pos = genRect(img->height(), img->width(), pos.x - 43, pos.y - 19);
 	}
@@ -287,7 +287,7 @@ CBattleInterface::CBattleInterface(const CCreatureSet *army1, const CCreatureSet
 
 		defendingHero = new CBattleHero(battleImage, true, hero2->tempOwner, hero2->tempOwner == curInt->playerID ? hero2 : nullptr, this);
 
-		IImage * img = defendingHero->animation->getImage(0, 0, true);
+		auto img = defendingHero->animation->getImage(0, 0, true);
 		if(img)
 			defendingHero->pos = genRect(img->height(), img->width(), pos.x + 693, pos.y - 19);
 	}
@@ -1345,7 +1345,7 @@ void CBattleInterface::spellCast(const BattleSpellCast * sc)
 			//TODO: calculate inside CEffectAnimation
 			std::shared_ptr<CAnimation> tmp = std::make_shared<CAnimation>(animToDisplay);
 			tmp->load(0, 0);
-			IImage * first = tmp->getImage(0, 0);
+			auto first = tmp->getImage(0, 0);
 
 			//displaying animation
 			double diffX = (destcoord.x - srccoord.x)*(destcoord.x - srccoord.x);
@@ -2773,7 +2773,7 @@ void CBattleInterface::obstaclePlaced(const CObstacleInstance & oi)
 	auto animation = std::make_shared<CAnimation>(defname);
 	animation->preload();
 
-	IImage * first = animation->getImage(0, 0);
+	auto first = animation->getImage(0, 0);
 	if(!first)
 		return;
 
@@ -3101,7 +3101,7 @@ void CBattleInterface::showAbsoluteObstacles(SDL_Surface * to)
 	{
 		if(oi->obstacleType == CObstacleInstance::ABSOLUTE_OBSTACLE)
 		{
-			IImage * img = getObstacleImage(*oi);
+			auto img = getObstacleImage(*oi);
 			if(img)
 				img->draw(to, pos.x + oi->getInfo().width, pos.y + oi->getInfo().height);
 		}
@@ -3226,7 +3226,7 @@ void CBattleInterface::showProjectiles(SDL_Surface *to)
 		}
 
 		size_t group = it->reverse ? 1 : 0;
-		IImage * image = idToProjectile[it->creID]->getImage(it->frameNum, group, true);
+		auto image = idToProjectile[it->creID]->getImage(it->frameNum, group, true);
 
 		if(image)
 		{
@@ -3419,7 +3419,7 @@ void CBattleInterface::showObstacles(SDL_Surface * to, std::vector<std::shared_p
 {
 	for(auto & obstacle : obstacles)
 	{
-		IImage * img = getObstacleImage(*obstacle);
+		auto img = getObstacleImage(*obstacle);
 		if(img)
 		{
 			Point p = getObstaclePosition(img, *obstacle);
@@ -3435,7 +3435,7 @@ void CBattleInterface::showBattleEffects(SDL_Surface *to, const std::vector<cons
 		int currentFrame = floor(elem->currentFrame);
 		currentFrame %= elem->animation->size();
 
-		IImage * img = elem->animation->getImage(currentFrame);
+		auto img = elem->animation->getImage(currentFrame);
 
 		SDL_Rect temp_rect = genRect(img->height(), img->width(), elem->x, elem->y);
 
@@ -3703,7 +3703,7 @@ void CBattleInterface::redrawBackgroundWithHexes(const CStack *activeStack)
 	{
 		if(oi->obstacleType == CObstacleInstance::ABSOLUTE_OBSTACLE)
 		{
-			IImage * img = getObstacleImage(*oi);
+			auto img = getObstacleImage(*oi);
 			if(img)
 				img->draw(backgroundWithHexes, oi->getInfo().width, oi->getInfo().height);
 		}

+ 2 - 2
client/battle/CBattleInterfaceClasses.cpp

@@ -129,7 +129,7 @@ CBattleConsole::CBattleConsole() : lastShown(-1), alterTxt(""), whoSetAlter(0)
 
 void CBattleHero::show(SDL_Surface * to)
 {
-	IImage * flagFrame = flagAnimation->getImage(flagAnim, 0, true);
+	auto flagFrame = flagAnimation->getImage(flagAnim, 0, true);
 
 	if(!flagFrame)
 		return;
@@ -159,7 +159,7 @@ void CBattleHero::show(SDL_Surface * to)
 	//animation of hero
 	SDL_Rect rect = pos;
 
-	IImage * heroFrame = animation->getImage(currentFrame, phase, true);
+	auto heroFrame = animation->getImage(currentFrame, phase, true);
 	if(!heroFrame)
 		return;
 

+ 1 - 1
client/battle/CCreatureAnimation.cpp

@@ -173,7 +173,7 @@ CCreatureAnimation::CCreatureAnimation(const std::string & name_, TSpeedControll
 	}
 
 	//TODO: get dimensions form CAnimation
-	IImage * first = forward->getImage(0, type, true);
+	auto first = forward->getImage(0, type, true);
 
 	if(!first)
 	{

+ 6 - 6
client/gui/CAnimation.cpp

@@ -1348,7 +1348,7 @@ IImage * CAnimation::getFromExtraDef(std::string filename)
 		frame = atoi(filename.c_str()+pos);
 	}
 	anim.load(frame ,group);
-	IImage * ret = anim.images[group][frame];
+	auto ret = anim.images[group][frame];
 	anim.images.clear();
 	return ret;
 }
@@ -1361,7 +1361,7 @@ bool CAnimation::loadFrame(size_t frame, size_t group)
 		return false;
 	}
 
-	IImage * image = getImage(frame, group, false);
+	auto image = getImage(frame, group, false);
 	if(image)
 	{
 		image->increaseRef();
@@ -1391,7 +1391,7 @@ bool CAnimation::loadFrame(size_t frame, size_t group)
 	}
 	else //load from separate file
 	{
-		IImage * img = getFromExtraDef(source[group][frame]["file"].String());
+		auto img = getFromExtraDef(source[group][frame]["file"].String());
 		if(!img)
 			img = new SDLImage(source[group][frame]);
 
@@ -1403,7 +1403,7 @@ bool CAnimation::loadFrame(size_t frame, size_t group)
 
 bool CAnimation::unloadFrame(size_t frame, size_t group)
 {
-	IImage *image = getImage(frame, group, false);
+	auto image = getImage(frame, group, false);
 	if (image)
 	{
 		//decrease ref count for image and delete if needed
@@ -1478,7 +1478,7 @@ void CAnimation::exportBitmaps(const boost::filesystem::path& path) const
 		for(const auto & imagePair : groupPair.second)
 		{
 			size_t frame = imagePair.first;
-			const IImage * img = imagePair.second;
+			const auto img = imagePair.second;
 
 			boost::format fmt("%d_%d.bmp");
 			fmt % group % frame;
@@ -1696,7 +1696,7 @@ void CAnimation::createFlippedGroup(const size_t sourceGroup, const size_t targe
 	{
 		duplicateImage(sourceGroup, frame, targetGroup);
 
-		IImage * image = getImage(frame, targetGroup);
+		auto image = getImage(frame, targetGroup);
 		image->verticalFlip();
 	}
 }

+ 15 - 15
client/mapHandler.cpp

@@ -199,7 +199,7 @@ void CMapHandler::initTerrainGraphics()
 
 				for(int j = 0; j < views; j++)
 				{
-					IImage * image = animation[i][rotation]->getImage(j);
+					auto image = animation[i][rotation]->getImage(j);
 
 					if(rotation == 2 || rotation == 3)
 						image->horizontalFlip();
@@ -307,7 +307,7 @@ void CMapHandler::initObjectRects()
 		if(animation->size(0) == 0)
 			continue;
 
-		IImage * image = animation->getImage(0,0);
+		auto image = animation->getImage(0,0);
 
 		for(int fx=0; fx < obj->getWidth(); ++fx)
 		{
@@ -538,7 +538,7 @@ void CMapHandler::CMapWorldViewBlitter::calculateWorldViewCameraPos()
 
 void CMapHandler::CMapWorldViewBlitter::drawElement(EMapCacheType cacheType, const IImage * source, SDL_Rect * sourceRect, SDL_Surface * targetSurf, SDL_Rect * destRect) const
 {
-	IImage * scaled = parent->cache.requestWorldViewCacheOrCreate(cacheType, source);
+	auto scaled = parent->cache.requestWorldViewCacheOrCreate(cacheType, source);
 
 	if(scaled)
 		scaled->draw(targetSurf, destRect, sourceRect);
@@ -548,7 +548,7 @@ void CMapHandler::CMapWorldViewBlitter::drawTileOverlay(SDL_Surface * targetSurf
 {
 	auto drawIcon = [this,targetSurf](Obj id, si32 subId, PlayerColor owner)
 	{
-		IImage * wvIcon = this->objectToIcon(id, subId, owner);
+		auto wvIcon = this->objectToIcon(id, subId, owner);
 
 		if(nullptr != wvIcon)
 		{
@@ -593,7 +593,7 @@ void CMapHandler::CMapWorldViewBlitter::drawOverlayEx(SDL_Surface * targetSurf)
 		realPos.x = initPos.x + (iconInfo.pos.x - topTile.x) * tileSize;
 		realPos.y = initPos.x + (iconInfo.pos.y - topTile.y) * tileSize;
 
-		IImage * wvIcon = this->objectToIcon(iconInfo.id, iconInfo.subId, iconInfo.owner);
+		auto wvIcon = this->objectToIcon(iconInfo.id, iconInfo.subId, iconInfo.owner);
 
 		if(nullptr != wvIcon)
 		{
@@ -679,7 +679,7 @@ void CMapHandler::CMapPuzzleViewBlitter::drawObjects(SDL_Surface * targetSurf, c
 	// grail X mark
 	if(pos.x == info->grailPos.x && pos.y == info->grailPos.y)
 	{
-		const IImage * mark = graphics->heroMoveArrows->getImage(0);
+		const auto mark = graphics->heroMoveArrows->getImage(0);
 		mark->draw(targetSurf,realTileRect.x,realTileRect.y);
 	}
 }
@@ -985,10 +985,10 @@ CMapHandler::AnimBitmapHolder CMapHandler::CMapBlitter::findHeroBitmap(const CGH
         if(animation->size(group) > 0)
 		{
 			int frame = anim % animation->size(group);
-			IImage * heroImage = animation->getImage(frame, group);
+			auto heroImage = animation->getImage(frame, group);
 
 			//get flag overlay only if we have main image
-			IImage * flagImage = findFlagBitmap(hero, anim, &hero->tempOwner, group);
+			auto flagImage = findFlagBitmap(hero, anim, &hero->tempOwner, group);
 
 			return CMapHandler::AnimBitmapHolder(heroImage, flagImage, moving);
 		}
@@ -1070,7 +1070,7 @@ CMapHandler::AnimBitmapHolder CMapHandler::CMapBlitter::findObjectBitmap(const C
     if(groupSize == 0)
 		return CMapHandler::AnimBitmapHolder();
 
-	IImage * bitmap = animation->getImage((anim + getPhaseShift(obj)) % groupSize);
+	auto bitmap = animation->getImage((anim + getPhaseShift(obj)) % groupSize);
 	if(!bitmap)
 		return CMapHandler::AnimBitmapHolder();
 
@@ -1200,7 +1200,7 @@ bool CMapHandler::printObject(const CGObjectInstance * obj, bool fadein)
 	if(!animation)
 		return false;
 
-	IImage * bitmap = animation->getImage(0);
+	auto bitmap = animation->getImage(0);
 
 	if(!bitmap)
 		return false;
@@ -1322,13 +1322,13 @@ void CMapHandler::updateWater() //shift colors in palettes of water tiles
 {
 	for(auto & elem : terrainImages[7])
 	{
-		for(IImage * img : elem)
+		for(auto img : elem)
 			img->shiftPalette(246, 9);
 	}
 
 	for(auto & elem : terrainImages[8])
 	{
-		for(IImage * img : elem)
+		for(auto img : elem)
 		{
 			img->shiftPalette(229, 12);
 			img->shiftPalette(242, 14);
@@ -1337,7 +1337,7 @@ void CMapHandler::updateWater() //shift colors in palettes of water tiles
 
 	for(auto & elem : riverImages[0])
 	{
-		for(IImage * img : elem)
+		for(auto img : elem)
 		{
 			img->shiftPalette(183, 12);
 			img->shiftPalette(195, 6);
@@ -1346,7 +1346,7 @@ void CMapHandler::updateWater() //shift colors in palettes of water tiles
 
 	for(auto & elem : riverImages[2])
 	{
-		for(IImage * img : elem)
+		for(auto img : elem)
 		{
 			img->shiftPalette(228, 12);
 			img->shiftPalette(183, 6);
@@ -1356,7 +1356,7 @@ void CMapHandler::updateWater() //shift colors in palettes of water tiles
 
 	for(auto & elem : riverImages[3])
 	{
-		for(IImage * img : elem)
+		for(auto img : elem)
 			img->shiftPalette(240, 9);
 	}
 }

+ 2 - 2
client/widgets/Images.cpp

@@ -247,7 +247,7 @@ void CAnimImage::init()
 	if (flags & CShowableAnim::BASE)
 		anim->load(0,group);
 
-	IImage *img = anim->getImage(frame, group);
+	auto img = anim->getImage(frame, group);
 	if (img)
 	{
 		pos.w = img->width();
@@ -421,7 +421,7 @@ void CShowableAnim::blitImage(size_t frame, size_t group, SDL_Surface *to)
 {
 	assert(to);
 	Rect src( xOffset, yOffset, pos.w, pos.h);
-	IImage * img = anim->getImage(frame, group);
+	auto img = anim->getImage(frame, group);
 	if (img)
 		img->draw(to, pos.x-xOffset, pos.y-yOffset, &src, alpha);
 }

+ 1 - 1
client/windows/CAdvmapInterface.cpp

@@ -308,7 +308,7 @@ void CTerrainRect::showPath(const SDL_Rect * extRect, SDL_Surface * to)
 			pn+=25;
 		if (pn>=0)
 		{
-			const IImage * arrow = graphics->heroMoveArrows->getImage(pn);
+			const auto arrow = graphics->heroMoveArrows->getImage(pn);
 
 			int x = 32*(curPos.x-adventureInt->position.x)+CGI->mh->offsetX + pos.x,
 				y = 32*(curPos.y-adventureInt->position.y)+CGI->mh->offsetY + pos.y;