From c9ca56e91b72d5f5d11fc7955fa8d0ff318b4890 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Wed, 25 Aug 2010 00:29:56 +0000 Subject: [PATCH] - small optimization for moving units when source and destintation position are the same --- source/glest_game/world/world.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/source/glest_game/world/world.cpp b/source/glest_game/world/world.cpp index 8f60bad5..68076ee6 100644 --- a/source/glest_game/world/world.cpp +++ b/source/glest_game/world/world.cpp @@ -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){