From 6c448e76d058751de593b35e7a294c8d822ab8ba Mon Sep 17 00:00:00 2001 From: mr-russ <> Date: Thu, 9 Jan 2003 06:14:56 +0000 Subject: [PATCH] Code Cleanup NEW_FOW check to only update sight range, if something actually changed. --- src/unit/unit.cpp | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/unit/unit.cpp b/src/unit/unit.cpp index fe180f804..2ed84f7fd 100644 --- a/src/unit/unit.cpp +++ b/src/unit/unit.cpp @@ -487,7 +487,7 @@ global void PlaceUnit(Unit* unit,int x,int y) // // Update fog of war, if unit belongs to player on this computer // - if ( unit->Host ) { + if( unit->Host ) { MapUnmarkSight(unit->Player,unit->Host->X+unit->Host->Type->TileWidth/2 ,unit->Host->Y+unit->Host->Type->TileHeight/2 ,unit->CurrentSightRange); @@ -568,6 +568,7 @@ global Unit* MakeUnitAndPlace(int x,int y,UnitType* type,Player* player) ** Update map. ** ** @param unit Pointer to unit. +** @param host Pointer to housing unit. */ global void RemoveUnit(Unit* unit, Unit* host) { @@ -577,14 +578,21 @@ global void RemoveUnit(Unit* unit, Unit* host) unsigned flags; #ifdef NEW_FOW - MapUnmarkSight(unit->Player,unit->X+unit->Type->TileWidth/2 - ,unit->Y+unit->Type->TileHeight/2 - ,unit->CurrentSightRange); - if ( host ) { - unit->CurrentSightRange=host->CurrentSightRange; - MapMarkSight(unit->Player,host->X+host->Type->TileWidth/2 - ,host->Y+host->Type->TileWidth/2 + if ( !(host && + unit->X+unit->Type->TileWidth/2 == host->X+host->Type->TileWidth/2 && + unit->Y+unit->Type->TileHeight/2 == host->Y+host->Type->TileWidth/2 && + unit->CurrentSightRange == unit->CurrentSightRange) ) { + MapUnmarkSight(unit->Player,unit->X+unit->Type->TileWidth/2 + ,unit->Y+unit->Type->TileHeight/2 ,unit->CurrentSightRange); + if( host ) { + unit->CurrentSightRange=host->CurrentSightRange; + MapMarkSight(unit->Player,host->X+host->Type->TileWidth/2, + host->Y+host->Type->TileWidth/2, + unit->CurrentSightRange); + } + } + if( host ) { unit->Host=host; } #endif