From 1a7073dafc339acbf55edfbb3c2d4bec805aa71e Mon Sep 17 00:00:00 2001 From: johns <> Date: Thu, 1 Jun 2000 12:48:22 +0000 Subject: [PATCH] repair buildings patch from David Slimp --- src/action/command.cpp | 12 ++++++++++-- src/unit/unit_find.cpp | 10 ++++------ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/action/command.cpp b/src/action/command.cpp index 716492bc7..43c5cedf6 100644 --- a/src/action/command.cpp +++ b/src/action/command.cpp @@ -202,11 +202,19 @@ global void CommandRepair(Unit* unit,int x,int y,Unit* dest,int flush) return; } + if ( !(dest=RepairableOnMapTile(x,y)) ) { + // FIXME: don't work for automatic repairs. + command->Action=UnitActionStill; + return; + } + command->Action=UnitActionRepair; command->Data.Move.Fast=1; - command->Data.Move.Goal=RepairableOnMapTile(x,y); + command->Data.Move.Goal=dest; #ifdef NEW_UNIT - command->Data.Move.Goal->Refs++; + if( dest ) { + dest->Refs++; + } #endif command->Data.Move.Range=REPAIR_RANGE; command->Data.Move.SX=unit->X; diff --git a/src/unit/unit_find.cpp b/src/unit/unit_find.cpp index c99f490ea..4c10e3adc 100644 --- a/src/unit/unit_find.cpp +++ b/src/unit/unit_find.cpp @@ -177,15 +177,13 @@ global Unit* RepairableOnMapTile(unsigned tx,unsigned ty) n=SelectUnitsOnTile(tx,ty,table); for( i=0; i<n; ++i ) { - if( UnitUnusable(table[i]) ) { - continue; - } - // FIXME: could use more or less for repair? - if( table[i]->Type->Building ) { + // FIXME: could use more or less for repair? Repair of ships/catapults. + // Only repairable if target is a building and it's HP is not at max + if( table[i]->Type->Building + && table[i]->HP < table[i]->Stats->HitPoints ) { return table[i]; } } - return NoUnitP; }