anchor.diff:    H: TKMHouse;
     Res: TWareType;
   begin
  -  Res := WareIndexToType[aType];
  -  if (aHouseID > 0) then
  -  begin
  +  if (aHouseID > 0) and (aType in [Low(WareIndexToType)..High(WareIndexToType)]) then
  +  begin
  +    Res := WareIndexToType[aType];
       H := fIDCache.GetHouse(aHouseID);
       if H <> nil then
         //Store/barracks mix input/output (add to input, take from output) so we must process them together
  
positive.code:   Res: TWareType;
    I: Integer;
  begin
    Res := WareIndexToType[aWareType];
    if (aHouseID > 0) and (Res in [WARE_MIN..WARE_MAX]) and InRange(aAmount, 0, MAX_WARES_ORDER) then
    begin
      H := fIDCache.GetHouse(aHouseID);
      if (H <> nil) then
        for I := 1 to 4 do
  
negative.code: 
  
  function TKMScriptStates.HouseTypeToOccupantType(aHouseType: Integer): Integer;
  begin
    Result := -1;
    if aHouseType in [Low(HouseIndexToType)..High(HouseIndexToType)] then
  