anchor.diff:      and not fDemand[iD].Loc_House.IsComplete then
     begin
       //Give priority to almost built houses
  -    Result := Result - 2*fDemand[iD].Loc_House.GetBuildResDeliveredPercent;
  +    aBidBasicValue := aBidBasicValue - 2*fDemand[iD].Loc_House.GetBuildResDeliveredPercent;
       //Only add a small amount so houses at different distances will be prioritized separately
       if (fDemand[iD].Ware = wt_Stone) then
  -      Result := Result + 0.1;
  +      aBidBasicValue := aBidBasicValue + 0.1;
     end
     else
       //For all other deliveries, add some random element so in the case of identical
       //bids the same resource will not always be chosen (e.g. weapons storehouse->barracks
       //should take random weapon types not sequentially)
  -    Result := Result + KaMRandom(5);
  +    aBidBasicValue := aBidBasicValue + KaMRandom(5);
   
     if (fDemand[iD].Ware = wt_All)        // Always prefer deliveries House>House instead of House>Store
       or ((aOfferHouseType = ht_Store)    // Prefer taking wares from House rather than Store...
       and (fDemand[iD].Ware <> wt_Warfare)) then //...except weapons Store>Barracks, that is also prefered
  -    Result := Result + 1000;
  +    aBidBasicValue := aBidBasicValue + 1000;
   
     {$IFDEF WDC}
  -  if CACHE_DELIVERY_BIDS then
  -    fOfferToDemandCache.Add(BidKey, Result);
  +  TryAddToCache(BidKey, aBidBasicValue);
     {$ENDIF}
   
  -  Result := Result + SerfBidValue;
  -end;
  -
  -
  -function TKMDeliveries.CalculateBid(iO, iD: Integer; aSerf: TKMUnitSerf = nil): Single;
  -begin
  -  Result := CalculateBidBasic(iO, iD, aSerf);
  +  aBidBasicValue := aBidBasicValue + SerfBidValue;
  +end;
  +
  +
  +function TKMDeliveries.TryCalculateBid(iO, iD: Integer; var aBidValue: Single; aSerf: TKMUnitSerf = nil): Boolean;
  +begin
  +  Result := TryCalculateBidBasic(iO, iD, aBidValue, aSerf);
  +
  +  if not Result then
  +    Exit;
   
     //Modifications for bidding system
     if (fDemand[iD].Loc_House <> nil) //Prefer delivering to houses with fewer supply
       and (fDemand[iD].Ware <> wt_All)
       and (fDemand[iD].Ware <> wt_Warfare) then //Except Barracks and Store, where supply doesn't matter or matter less
  -    Result := Result + 20 * fDemand[iD].Loc_House.CheckResIn(fDemand[iD].Ware);
  +    aBidValue := aBidValue + 20 * fDemand[iD].Loc_House.CheckResIn(fDemand[iD].Ware);
   
     //Delivering weapons from store to barracks, make it lowest priority when there are >50 of that weapon in the barracks.
     //In some missions the storehouse has vast amounts of weapons, and we don't want the serfs to spend the whole game moving these.
  
positive.code:           for iO := 1 to fQueue.fOfferCount do
              if (fQueue.fOffer[iO].Ware <> wt_None)
                and fQueue.ValidDelivery(iO,iD)
                and AnySerfCanDoDelivery(iO,iD) then //Only choose this delivery if at least one of the serfs can do it
              begin
                Bid := fQueue.CalculateBid(iO,iD,nil);
                if (Bid < BestBid) or (fQueue.fDemand[iD].Importance > BestImportance) then
                begin
                  BestBid := Bid;
                  BestImportance := fQueue.fDemand[iD].Importance;
                  FoundO := iO;
                  FoundD := iD;
                end;
              end;
  
        //FoundO and FoundD give us the best delivery to do at this moment. Now find the best serf for the job.
  
negative.code: 
    //Also prefer deliveries near to the serf
    if aSerf <> nil then
      Result := TryCalcRouteCost(aSerf.GetPosition, BelowOfferPos, [tpWalk], aSerfBidValue); //Serf gets to first house with tpWalk
  
    {$IFDEF WDC}
    if CACHE_DELIVERY_BIDS then
    begin
      fSerfToOfferCache.Add(BidKey, aSerfBidValue);
    end;
    {$ENDIF}
  end;
  
  