Program: 86683
Project: 86683
Buggy source:
private List<Layer> parseLayers(LeoArray layers,TilesetAtlas atlas,boolean loadImages,int tileWidth,int tileHeight,SurfaceType[][] surfaces) throws Exception {
  List<Layer> mapLayers=new ArrayList<Layer>(layers.size());
  int index=0;
  for (  LeoObject l : layers) {
    LeoMap layer=l.as();
    LeoArray data=layer.getByString("String_Node_Str").as();
    int width=layer.getInt("String_Node_Str");
    int height=layer.getInt("String_Node_Str");
    boolean isCollidable=false;
    boolean isForeground=false;
    boolean isProperty=false;
    boolean isSurfaceTypes=false;
    boolean isDestructable=false;
    boolean isVisible=layer.getBoolean("String_Node_Str");
    int heightMask=0;
    if (layer.has(LeoString.valueOf("String_Node_Str"))) {
      LeoMap properties=layer.getByString("String_Node_Str").as();
      isCollidable=properties.getString("String_Node_Str").equals("String_Node_Str");
      isForeground=properties.getString("String_Node_Str").equals("String_Node_Str");
      isDestructable=properties.getString("String_Node_Str").equals("String_Node_Str");
      if (properties.containsKeyByString("String_Node_Str")) {
        String strMask=properties.getString("String_Node_Str");
        heightMask=Integer.parseInt(strMask);
      }
      if (properties.containsKeyByString("String_Node_Str")) {
        isProperty=true;
      }
      if (properties.containsKeyByString("String_Node_Str")) {
        isSurfaceTypes=true;
      }
    }
    if (isSurfaceTypes) {
      parseSurfaces(surfaces,atlas,data,width,tileWidth,tileHeight);
      continue;
    }
    Layer mapLayer=new Layer(layer.getString("String_Node_Str"),isCollidable,isForeground,isDestructable,isProperty,isVisible,index,heightMask,height);
    mapLayers.add(mapLayer);
    if (!isForeground) {
      index++;
    }
    Tile[] row=null;
    int y=-tileHeight;
    int rowIndex=0;
    for (int x=0; x < data.size(); x++) {
      int tileId=data.get(x).asInt();
      boolean flippedHorizontally=(tileId & FLIPPED_HORIZONTALLY_FLAG) != 0;
      boolean flippedVertically=(tileId & FLIPPED_VERTICALLY_FLAG) != 0;
      boolean flippedDiagonally=(tileId & FLIPPED_DIAGONALLY_FLAG) != 0;
      tileId&=~(FLIPPED_HORIZONTALLY_FLAG | FLIPPED_VERTICALLY_FLAG | FLIPPED_DIAGONALLY_FLAG);
      if (x % width == 0) {
        row=new Tile[width];
        mapLayer.addRow(rowIndex++,row);
        y+=tileHeight;
      }
      if (loadImages) {
        TextureRegion image=atlas.getTile(tileId);
        if (image != null) {
          Tile tile=null;
          if (atlas.isAnimatedTile(tileId)) {
            tile=new AnimatedTile(atlas.getAnimatedTile(tileId),tileWidth,tileHeight);
            mapLayer.setContainsAnimations(true);
          }
 else {
            tile=new Tile(image,tileWidth,tileHeight);
          }
          tile.setPosition((x % width) * tileWidth,y);
          tile.setFlips(flippedHorizontally,flippedVertically,flippedDiagonally);
          if (isCollidable) {
            int collisionId=atlas.getTileId(tileId);
            tile.setCollisionMaskById(collisionId);
          }
          row[x % width]=tile;
        }
 else {
          row[x % width]=null;
        }
      }
 else {
        if (tileId != 0) {
          Tile tile=new Tile(null,tileWidth,tileHeight);
          tile.setPosition((x % width) * tileWidth,y);
          if (isCollidable) {
            int collisionId=atlas.getTileId(tileId);
            tile.setCollisionMaskById(collisionId);
          }
          row[x % width]=tile;
        }
 else {
          row[x % width]=null;
        }
      }
    }
    mapLayer.applyHeightMask();
  }
  return mapLayers;
}

Fixed version (ground truth):
private List<Layer> parseLayers(LeoArray layers,TilesetAtlas atlas,boolean loadImages,int tileWidth,int tileHeight,SurfaceType[][] surfaces) throws Exception {
  List<Layer> mapLayers=new ArrayList<Layer>(layers.size());
  int index=0;
  for (  LeoObject l : layers) {
    LeoMap layer=l.as();
    LeoArray data=layer.getByString("String_Node_Str").as();
    int width=layer.getInt("String_Node_Str");
    int height=layer.getInt("String_Node_Str");
    boolean isCollidable=false;
    boolean isForeground=false;
    boolean isProperty=false;
    boolean isSurfaceTypes=false;
    boolean isDestructable=false;
    boolean isVisible=layer.getBoolean("String_Node_Str");
    int heightMask=0;
    if (layer.has(LeoString.valueOf("String_Node_Str"))) {
      LeoMap properties=layer.getByString("String_Node_Str").as();
      isCollidable=properties.getString("String_Node_Str").equals("String_Node_Str");
      isForeground=properties.getString("String_Node_Str").equals("String_Node_Str");
      isDestructable=properties.getString("String_Node_Str").equals("String_Node_Str");
      if (properties.containsKeyByString("String_Node_Str")) {
        String strMask=properties.getString("String_Node_Str");
        heightMask=Integer.parseInt(strMask);
      }
      if (properties.containsKeyByString("String_Node_Str")) {
        isProperty=true;
      }
      if (properties.containsKeyByString("String_Node_Str")) {
        isSurfaceTypes=true;
      }
    }
    if (isSurfaceTypes) {
      parseSurfaces(surfaces,atlas,data,width,tileWidth,tileHeight);
      continue;
    }
    Layer mapLayer=new Layer(layer.getString("String_Node_Str"),isCollidable,isForeground,isDestructable,isProperty,isVisible,index,heightMask,height);
    mapLayers.add(mapLayer);
    Tile[] row=null;
    int y=-tileHeight;
    int rowIndex=0;
    for (int x=0; x < data.size(); x++) {
      int tileId=data.get(x).asInt();
      boolean flippedHorizontally=(tileId & FLIPPED_HORIZONTALLY_FLAG) != 0;
      boolean flippedVertically=(tileId & FLIPPED_VERTICALLY_FLAG) != 0;
      boolean flippedDiagonally=(tileId & FLIPPED_DIAGONALLY_FLAG) != 0;
      tileId&=~(FLIPPED_HORIZONTALLY_FLAG | FLIPPED_VERTICALLY_FLAG | FLIPPED_DIAGONALLY_FLAG);
      if (x % width == 0) {
        row=new Tile[width];
        mapLayer.addRow(rowIndex++,row);
        y+=tileHeight;
      }
      if (loadImages) {
        TextureRegion image=atlas.getTile(tileId);
        if (image != null) {
          Tile tile=null;
          if (atlas.isAnimatedTile(tileId)) {
            tile=new AnimatedTile(atlas.getAnimatedTile(tileId),index,tileWidth,tileHeight);
            mapLayer.setContainsAnimations(true);
          }
 else {
            tile=new Tile(image,index,tileWidth,tileHeight);
          }
          tile.setPosition((x % width) * tileWidth,y);
          tile.setFlips(flippedHorizontally,flippedVertically,flippedDiagonally);
          if (isCollidable) {
            int collisionId=atlas.getTileId(tileId);
            tile.setCollisionMaskById(collisionId);
          }
          row[x % width]=tile;
        }
 else {
          row[x % width]=null;
        }
      }
 else {
        if (tileId != 0) {
          Tile tile=new Tile(null,index,tileWidth,tileHeight);
          tile.setPosition((x % width) * tileWidth,y);
          if (isCollidable) {
            int collisionId=atlas.getTileId(tileId);
            tile.setCollisionMaskById(collisionId);
          }
          row[x % width]=tile;
        }
 else {
          row[x % width]=null;
        }
      }
    }
    if (!isForeground) {
      index++;
    }
    mapLayer.applyHeightMask();
  }
  return mapLayers;
}