- small optimization for moving units when source and destintation position are the same

This commit is contained in:
Mark Vejvoda 2010-08-25 00:29:56 +00:00
parent c781982e57
commit c9ca56e91b
1 changed files with 6 additions and 2 deletions

View File

@ -533,8 +533,12 @@ void World::moveUnitCells(Unit *unit){
//newPos must be free or the same pos as current
assert(map.getCell(unit->getPos())->getUnit(unit->getCurrField())==unit || map.isFreeCell(newPos, unit->getCurrField()));
map.clearUnitCells(unit, unit->getPos());
map.putUnitCells(unit, newPos);
// Only change cell plaement in map if the new position is different
// from the old one
if(newPos != unit->getPos()) {
map.clearUnitCells(unit, unit->getPos());
map.putUnitCells(unit, newPos);
}
//water splash
if(tileset.getWaterEffects() && unit->getCurrField()==fLand){