浏览代码

Replace std::remove_if with vstd::erase_if

Vadim Markovtsev 9 年之前
父节点
当前提交
40cb48d65e
共有 3 个文件被更改,包括 19 次插入19 次删除
  1. 15 15
      client/battle/CBattleInterface.cpp
  2. 2 2
      lib/CGameState.cpp
  3. 2 2
      lib/mapObjects/JsonRandom.cpp

+ 15 - 15
client/battle/CBattleInterface.cpp

@@ -1017,7 +1017,7 @@ void CBattleInterface::stackRemoved(int stackID)
 			setActiveStack(nullptr);
 		}
 	}
-	
+
 	delete creAnims[stackID];
 	creAnims.erase(stackID);
 	creDir.erase(stackID);
@@ -1201,18 +1201,18 @@ void CBattleInterface::stackIsCatapulting(const CatapultAttack & ca)
 		for(auto attackInfo : ca.attackedParts)
 		{
 			addNewAnim(new CShootingAnimation(this, stack, attackInfo.destinationTile, nullptr, true, attackInfo.damageDealt));
-		}		
+		}
 	}
 	else
 	{
-		//no attacker stack, assume spell-related (earthquake) - only hit animation 
+		//no attacker stack, assume spell-related (earthquake) - only hit animation
 		for(auto attackInfo : ca.attackedParts)
 		{
 			Point destPos = CClickableHex::getXYUnitAnim(attackInfo.destinationTile, nullptr, this) + Point(99, 120);
-	
+
 			addNewAnim(new CSpellEffectAnimation(this, "SGEXPL.DEF", destPos.x, destPos.y));
 		}
-	}	
+	}
 
 	waitForAnims();
 
@@ -1323,9 +1323,9 @@ void CBattleInterface::spellCast( const BattleSpellCast * sc )
 
 	//displaying message in console
 	std::vector<std::string> logLines;
-	
+
 	spell.prepareBattleLog(curInt->cb.get(), sc, logLines);
-	
+
 	for(auto line : logLines)
 		console->addText(line);
 
@@ -1427,15 +1427,15 @@ void CBattleInterface::displayEffect(ui32 effect, int destTile, bool areaEffect)
 }
 
 void CBattleInterface::displaySpellAnimation(const CSpell::TAnimation & animation, BattleHex destinationTile, bool areaEffect)
-{	
+{
 	if(animation.pause > 0)
 	{
-		addNewAnim(new CDummyAnimation(this, animation.pause));	
+		addNewAnim(new CDummyAnimation(this, animation.pause));
 	}
 	else
 	{
-		addNewAnim(new CSpellEffectAnimation(this, animation.resourceName, destinationTile, false, animation.verticalPosition == VerticalPosition::BOTTOM));	
-	}	
+		addNewAnim(new CSpellEffectAnimation(this, animation.resourceName, destinationTile, false, animation.verticalPosition == VerticalPosition::BOTTOM));
+	}
 }
 
 void CBattleInterface::displaySpellCast(SpellID spellID, BattleHex destinationTile, bool areaEffect)
@@ -1444,11 +1444,11 @@ void CBattleInterface::displaySpellCast(SpellID spellID, BattleHex destinationTi
 
 	if(spell == nullptr)
 		return;
-		
+
 	for(const CSpell::TAnimation & animation : spell->animationInfo.cast)
 	{
 		displaySpellAnimation(animation, destinationTile, areaEffect);
-	}	
+	}
 }
 
 void CBattleInterface::displaySpellEffect(SpellID spellID, BattleHex destinationTile, bool areaEffect)
@@ -1933,7 +1933,7 @@ void CBattleInterface::bTacticNextStack(const CStack *current /*= nullptr*/)
 	waitForAnims();
 
 	TStacks stacksOfMine = tacticianInterface->cb->battleGetStacks(CBattleCallback::ONLY_MINE);
-	stacksOfMine.erase(std::remove_if(stacksOfMine.begin(), stacksOfMine.end(), &immobile), stacksOfMine.end());
+	vstd::erase_if(stacksOfMine, &immobile);
 	auto it = vstd::find(stacksOfMine, current);
 	if(it != stacksOfMine.end() && ++it != stacksOfMine.end())
 		stackActivated(*it);
@@ -2072,7 +2072,7 @@ void CBattleInterface::handleHex(BattleHex myNumber, int eventType)
 			case ANY_CREATURE:
 				if (shere && shere->alive() && isCastingPossibleHere (sactive, shere, myNumber))
 					legalAction = true;
-				break;				
+				break;
 			case HOSTILE_CREATURE_SPELL:
 				if (shere && shere->alive() && !ourStack && isCastingPossibleHere (sactive, shere, myNumber))
 					legalAction = true;

+ 2 - 2
lib/CGameState.cpp

@@ -1219,8 +1219,8 @@ CGameState::CrossoverHeroesList CGameState::getCrossoverHeroesFromPreviousScenar
 				// remove heroes which didn't reached the end of the scenario, but were available at the start
 				for(auto hero : lostCrossoverHeroes)
 				{
-					crossoverHeroes.heroesFromAnyPreviousScenarios.erase(range::remove_if(crossoverHeroes.heroesFromAnyPreviousScenarios,
-						CGObjectInstanceBySubIdFinder(hero)), crossoverHeroes.heroesFromAnyPreviousScenarios.end());
+					vstd::erase_if(crossoverHeroes.heroesFromAnyPreviousScenarios,
+					               CGObjectInstanceBySubIdFinder(hero));
 				}
 
 				// now add heroes which completed the scenario

+ 2 - 2
lib/mapObjects/JsonRandom.cpp

@@ -133,10 +133,10 @@ namespace JsonRandom
 		if (value["type"].getType() == JsonNode::DATA_STRING)
 			return SpellID(VLC->modh->identifiers.getIdentifier("spell", value["type"]).get());
 
-		spells.erase(std::remove_if(spells.begin(), spells.end(), [=](SpellID spell)
+		vstd::erase_if(spells, [=](SpellID spell)
 		{
 			return VLC->spellh->objects[spell]->level != si32(value["level"].Float());
-		}), spells.end());
+		});
 
 		return SpellID(*RandomGeneratorUtil::nextItem(spells, rng));
 	}