repair buildings patch from David Slimp
This commit is contained in:
parent
82168d5ebc
commit
1a7073dafc
2 changed files with 14 additions and 8 deletions
src
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue