Program: 44444
Project: 44444
Buggy source:
protected void activateTarget(Glyphs.Target target){
  if (_active != null) {
    _active.layer.setVisible(true);
  }
  _active=target;
  _active.layer.setVisible(false);
  int mypidx=0;
  restoreZoom();
  if (_ctrls == null) {
    GroupLayer scores=_glyph.layer.parent();
    scores.remove(_glyph.layer);
    tiles.add(_glyph.layer);
    _glyph.layer.transform().translate(scores.transform().tx() - tiles.transform().tx(),scores.transform().ty() - tiles.transform().ty());
    _ctrls=new Glyphs.Tile();
    float quadw=Media.TERRAIN_WIDTH / 2, quadh=Media.TERRAIN_HEIGHT / 2;
    _ctrls.layer.add(_rotate=Atlantis.media.getActionTile(Media.ROTATE_ACTION));
    _rotate.setTranslation(quadw / 2,quadh / 2);
    _ctrls.layer.add(_commit=Atlantis.media.getActionTile(Media.OK_ACTION));
    _commit.setTranslation(3 * quadw / 2,3 * quadh / 2);
    _ctrls.layer.add(_placep=Atlantis.media.getPiecenTile(mypidx));
    _placep.setTranslation(3 * quadw / 2,3 * quadh / 2);
    _placep.setAlpha(0.5f);
    tiles.add(_ctrls.layer);
    _piecens=graphics().createGroupLayer();
    Rectangle pbounds=new Rectangle(Media.PIECEN_SIZE);
    for (int fidx=0; fidx < _placing.terrain.features.length; fidx++) {
      Feature f=_placing.terrain.features[fidx];
      ImageLayer pimg=Atlantis.media.getPiecenTile(mypidx);
      pimg.setTranslation(f.piecenSpot.getX(),f.piecenSpot.getY());
      _piecens.add(pimg);
      final Piecen p=new Piecen(Piecen.Color.values()[mypidx],_active.loc,fidx);
      Atlantis.input.register(new Input.LayerReactor(pimg,pbounds){
        @Override public boolean hitTest(        IPoint p){
          return _piecens.visible() && super.hitTest(p);
        }
        public void onTrigger(){
          commitPlacement(p);
        }
      }
);
    }
    _glyph.layer.add(_piecens);
    IRectangle abounds=new Rectangle(Media.ACTION_SIZE);
    Atlantis.input.register(_rotate,abounds,new Input.Action(){
      public void onTrigger(){
        int cidx=_orients.indexOf(_glyph.getOrient());
        _glyph.setOrient(_orients.get((cidx + 1) % _orients.size()),true);
      }
    }
);
    Atlantis.input.register(_commit,abounds,new Input.Action(){
      public void onTrigger(){
        commitPlacement(null);
      }
    }
);
    Atlantis.input.register(_placep,pbounds,new Input.Action(){
      public void onTrigger(){
        _placep.setVisible(false);
        zoomInOn(_active);
        _piecens.setVisible(true);
        int idx=0;
        for (        Feature f : _placing.terrain.features) {
          int claim=Logic.computeClaim(_plays,_placing,_glyph.getOrient(),_active.loc,f);
          _piecens.get(idx).setVisible(claim == 0);
          idx++;
        }
        _commit.setVisible(true);
      }
    }
);
  }
  _ctrls.layer.setVisible(false);
  _piecens.setVisible(false);
  _orients=Logic.computeLegalOrients(_plays,_placing,_active.loc);
  if (!_orients.contains(_glyph.getOrient())) {
    _glyph.setOrient(_orients.get(0),true);
  }
  _glyph.setLocation(_active.loc,true,new Runnable(){
    public void run(){
      _ctrls.layer.setVisible(true);
      _placep.setVisible(true);
    }
  }
);
  _ctrls.setLocation(_active.loc,false,null);
  boolean canRotate=(_orients.size() > 1);
  _rotate.setVisible(canRotate);
  boolean havePiecens=true;
  _placep.setVisible(false);
  _commit.setVisible(!havePiecens);
}

Fixed version (ground truth):
protected void activateTarget(Glyphs.Target target){
  if (_active != null) {
    _active.layer.setVisible(true);
  }
  _active=target;
  _active.layer.setVisible(false);
  int mypidx=0;
  restoreZoom();
  if (_ctrls == null) {
    GroupLayer scores=_glyph.layer.parent();
    scores.remove(_glyph.layer);
    flight.add(_glyph.layer);
    _glyph.layer.transform().translate(scores.transform().tx() - tiles.transform().tx(),scores.transform().ty() - tiles.transform().ty());
    _ctrls=new Glyphs.Tile();
    float quadw=Media.TERRAIN_WIDTH / 2, quadh=Media.TERRAIN_HEIGHT / 2;
    _ctrls.layer.add(_rotate=Atlantis.media.getActionTile(Media.ROTATE_ACTION));
    _rotate.setTranslation(quadw / 2,quadh / 2);
    _ctrls.layer.add(_commit=Atlantis.media.getActionTile(Media.OK_ACTION));
    _commit.setTranslation(3 * quadw / 2,3 * quadh / 2);
    _ctrls.layer.add(_placep=Atlantis.media.getPiecenTile(mypidx));
    _placep.setTranslation(3 * quadw / 2,3 * quadh / 2);
    _placep.setAlpha(0.5f);
    tiles.add(_ctrls.layer);
    _piecens=graphics().createGroupLayer();
    Rectangle pbounds=new Rectangle(Media.PIECEN_SIZE);
    for (int fidx=0; fidx < _placing.terrain.features.length; fidx++) {
      Feature f=_placing.terrain.features[fidx];
      ImageLayer pimg=Atlantis.media.getPiecenTile(mypidx);
      pimg.setTranslation(f.piecenSpot.getX(),f.piecenSpot.getY());
      _piecens.add(pimg);
      final Piecen p=new Piecen(Piecen.Color.values()[mypidx],_active.loc,fidx);
      Atlantis.input.register(new Input.LayerReactor(pimg,pbounds){
        @Override public boolean hitTest(        IPoint p){
          return _piecens.visible() && super.hitTest(p);
        }
        public void onTrigger(){
          commitPlacement(p);
        }
      }
);
    }
    _glyph.layer.add(_piecens);
    IRectangle abounds=new Rectangle(Media.ACTION_SIZE);
    Atlantis.input.register(_rotate,abounds,new Input.Action(){
      public void onTrigger(){
        int cidx=_orients.indexOf(_glyph.getOrient());
        _glyph.setOrient(_orients.get((cidx + 1) % _orients.size()),true);
      }
    }
);
    Atlantis.input.register(_commit,abounds,new Input.Action(){
      public void onTrigger(){
        commitPlacement(null);
      }
    }
);
    Atlantis.input.register(_placep,pbounds,new Input.Action(){
      public void onTrigger(){
        _placep.setVisible(false);
        zoomInOn(_active);
        _piecens.setVisible(true);
        int idx=0;
        for (        Feature f : _placing.terrain.features) {
          int claim=Logic.computeClaim(_plays,_placing,_glyph.getOrient(),_active.loc,f);
          _piecens.get(idx).setVisible(claim == 0);
          idx++;
        }
        _commit.setVisible(true);
      }
    }
);
  }
  _ctrls.layer.setVisible(false);
  _piecens.setVisible(false);
  _orients=Logic.computeLegalOrients(_plays,_placing,_active.loc);
  if (!_orients.contains(_glyph.getOrient())) {
    _glyph.setOrient(_orients.get(0),true);
  }
  _glyph.setLocation(_active.loc,true,new Runnable(){
    public void run(){
      if (_glyph.layer.parent() == flight) {
        flight.remove(_glyph.layer);
        tiles.add(0,_glyph.layer);
      }
      _ctrls.layer.setVisible(true);
      _placep.setVisible(true);
    }
  }
);
  _ctrls.setLocation(_active.loc,false,null);
  boolean canRotate=(_orients.size() > 1);
  _rotate.setVisible(canRotate);
  boolean havePiecens=true;
  _placep.setVisible(false);
  _commit.setVisible(!havePiecens);
}