anchor.diff:      end;
     end;
   
  +  //Pack generated terrain id identification info into 2 bytes (Word)
  +  //6 bits are for terKind       (supports up to 64 terKinds)
  +  //2 bits for mask subType      (supports up to 4 mask subTypes)
  +  //4 bits for mask Kind         (supports up to 16 mask kinds)
  +  //4 bits for mask Type (MType) (supports up to 16 mask types)
  +  function PackTerrainGenInfo(aGenInfo: TKMGenTerrainInfo): Word;
  +  begin
  +    Result := Byte(aGenInfo.TerKind) shl 10;
  +    Result := Result or (Byte(aGenInfo.Mask.SubType) shl 8);
  +    Result := Result or (Byte(aGenInfo.Mask.Kind) shl 4);
  +    Result := Result or Byte(aGenInfo.Mask.MType);
  +  end;
  +
   var
     L: Integer;
  +  GenInfo: TKMGenTerrainInfo;
   begin
     S.Write(aTileBasic.BaseLayer.Terrain);  //1
     //Map file stores terrain, not the fields placed over it, so save OldRotation rather than Rotation
  
positive.code: 
  
  class procedure TKMTerrain.ReadTileFromStream(aStream: TKMemoryStream; var aTileBasic: TKMTerrainTileBasic; aGameRev: Integer = 0);
  var
    I: Integer;
    TerrainB, ObjectB, Rot, Corners: Byte;
    LayersCorners: array[0..3] of Byte;
    UseKaMFormat: Boolean;
  begin
    UseKaMFormat := ( aGameRev = 0 );
  
  
negative.code:       aTileBasic.BaseLayer.Corners := [];
        for I := 0 to aTileBasic.LayersCnt - 1 do
        begin
          aStream.Read(TerIdentInfo); //Read packed info
          GenInfo := UnpackTerrainGenInfo(TerIdentInfo);
          //Get current generated terrain id by identification info
          //We could add more masks and terKinds in future, so we can't stick with generated terrainId,
          //but need to save/load its generation parameters (terKind/mask types etc)
          aTileBasic.Layer[I].Terrain := gGenTerrainTransitions[GenInfo.TerKind, GenInfo.Mask.Kind,
                                                                GenInfo.Mask.MType, GenInfo.Mask.SubType];
          aStream.Read(aTileBasic.Layer[I].Rotation);
          aTileBasic.Layer[I].Corners := [];
        end;
  