From cb3d6232efb74b3eb89455f8532fb8b8f70cf91d Mon Sep 17 00:00:00 2001 From: johns <> Date: Sun, 25 Mar 2001 22:02:43 +0000 Subject: [PATCH] Fixed bug: Repair command, didn't repair units. --- src/action/command.cpp | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/action/command.cpp b/src/action/command.cpp index 60b6d571f..d3b8f0ff9 100644 --- a/src/action/command.cpp +++ b/src/action/command.cpp @@ -424,16 +424,23 @@ global void CommandRepair(Unit* unit,int x,int y,Unit* dest,int flush) // Should be handled in action, but is not possible! // Unit::Refs is used as timeout counter. // - if( dest->Destroyed ) { - order->X=dest->X+dest->Type->TileWidth/2; - order->Y=dest->Y+dest->Type->TileHeight/2; - order->Goal=NoUnitP; - order->RangeX=order->RangeY=0; + if( dest ) { + if( dest->Destroyed ) { + order->X=dest->X+dest->Type->TileWidth/2; + order->Y=dest->Y+dest->Type->TileHeight/2; + order->Goal=NoUnitP; + order->RangeX=order->RangeY=0; + } else { + order->X=order->Y=-1; + order->Goal=dest; + RefsDebugCheck( !dest->Refs ); + dest->Refs++; + order->RangeX=order->RangeY=REPAIR_RANGE; + } } else { - order->X=order->Y=-1; - order->Goal=dest; - RefsDebugCheck( !dest->Refs ); - dest->Refs++; + order->X=x; + order->Y=y; + order->Goal=NoUnitP; order->RangeX=order->RangeY=REPAIR_RANGE; } order->Type=NULL;