anchor.diff:    end;
     THouseMappingArray = array [HOUSE_MIN..HOUSE_MAX] of THouseMapping;
   
  +
  +  TKMBuildState = (bsNoBuild = 0, bsHousePlan = 1, bsFieldPlan = 2, bsRoadPlan = 3, bsRoad = 4, bsBuild = 9, bsTree = 10, bsForest = 11, bsCoal = 12, bsDebug = 200, bsReserved = 255);
  +  TKMBuildInfo = record
  +    Visited, VisitedHouse: Byte;
  +    State: TKMBuildState;
  +    Next,Distance,Y: Word;
  +  end;
  +
  +  TKMHouseRequirements = record
  +    HouseType: TKMHouseType;
  +    IgnoreTrees,IgnoreAvoidBuilding: Boolean;
  +    MaxCnt, MaxDist: Word;
  +  end;
  +
  +
  +  TKMBuildInfoArray = array of TKMBuildInfo;
  +
  +  // This class transforms all house placing requirements into 1 array to avoid overlapping conditions
  +  // Placing new house is then question of internal house tiles
  +  TKMBuildFF = class
  +  private
  +    fOwner: TKMHandIndex;
  +    fVisitIdx, fVisitIdxHouse: Byte;
  +    fStartQueue, fEndQueue, fQueueCnt, fMapX, fMapY: Word;
  +    fUpdateTick: Cardinal;
  +    fHouseReq: TKMHouseRequirements;
  +    fHMA: THouseMappingArray;
  +    fLocs: TKMPointList;
  +    fInfoArr: TKMBuildInfoArray;
  +
  +    function GetInfo(const aY,aX: Word): TKMBuildInfo;
  +    procedure SetInfo(const aY,aX,aNext,aDistance: Word; const aVisited: Byte; const aState: TKMBuildState);
  +    function GetVisited(const aY,aX: Word): Byte;
  +    procedure SetVisited(const aY,aX: Word; const aVisited: Byte);
  +    function GetState(const aY,aX: Word): TKMBuildState;
  +    procedure SetState(const aY,aX: Word; const aState: TKMBuildState);
  +    function GetStateFromIdx(const aIdx: Word): TKMBuildState;
  +    function GetDistance(const aPoint: TKMPoint): Word;
  +    function GetNext(const aY,aX: Word): Word;
  +    procedure SetNext(const aY,aX,aNext: Word);
  +
  +  protected
  +    procedure InitQueue(aHouseFF: Boolean);
  +    function InsertInQueue(const aIdx: Word): Word;
  +    function RemoveFromQueue(var aX,aY,aIdx: Word): Boolean;
  +
  +    function CanBeVisited(const aX,aY,aIdx: Word; const aHouseQueue: Boolean = False): Boolean; overload;
  +    procedure MarkAsVisited(const aY,aIdx,aDistance: Word; const aState: TKMBuildState); overload;
  +    procedure MarkAsVisited(const aX,aY,aIdx,aDistance: Word); overload;
  +
  +    function CanBePlacedHouse(const aLoc: TKMPoint): Boolean;
  +    function GetTerrainState(const aX,aY: Word): TKMBuildState;
  +    procedure MarkPlans();
  +    procedure TerrainFF();
  +    procedure HouseFF();
  +  public
  +    constructor Create();
  +    destructor Destroy(); override;
  +
  +    //property Info[const aY,aX: Word]: TKMBuildInfo read GetInfo write SetInfo;
  +    property VisitIdx: Byte read fVisitIdx;
  +    property VisitIdxHouse: Byte read fVisitIdxHouse;
  +    property Visited[const aY,aX: Word]: Byte read GetVisited write SetVisited;
  +    property State[const aY,aX: Word]: TKMBuildState read GetState write SetState;
  +    property StateIdx[const aIdx: Word]: TKMBuildState read GetStateFromIdx;
  +    property Distance[const aPoint: TKMPoint]: Word read GetDistance;
  +    property Next[const aY,aX: Word]: Word read GetNext write SetNext;
  +    property Locs: TKMPointList read fLocs write fLocs;
  +
  +    procedure UpdateState();
  +    procedure OwnerUpdate(aPlayer: TKMHandIndex);
  +    procedure FindPlaceForHouse(aHouseReq: TKMHouseRequirements; InitPointsArr: TKMPointArray; aClearHouseList: Boolean = True);
  +  end;
   
     TKMSearchResource = class(TKMQuickFlood)
     private
  
positive.code: 
  implementation
  uses
    KM_Terrain, KM_Hand, KM_Resource, KM_AIFields, KM_HandsCollection, KM_RenderAux, KM_ResMapElements,
    KM_NavMesh;
  
  
  
negative.code: procedure TKMEye.OwnerUpdate(aPlayer: TKMHandIndex);
  begin
    fOwner := aPlayer;
    fBuildFF.OwnerUpdate(aPlayer);
    //fFinder.OwnerUpdate(fOwner);
  end;
  
  