This file is indexed.

/usr/include/osl/piece.h is in libosl-dev 0.4.2-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
#ifndef OSL_PIECE_H
#define OSL_PIECE_H
#include "osl/misc/loki.h"
#include "osl/player.h"
#include "osl/square.h"
#include "osl/ptype.h"

#include <iosfwd>
namespace osl
{
  class Piece;
  inline bool operator==(Piece l, Piece r);
  const int EMPTY_NUM=0x80;
  const int EDGE_NUM=0x40;
  /**
   * 駒.
   * 駒はptypeo(-15 - 15), 番号(0-39), ポジション(0-0xff)からなる 
   * 上位16 bitでptypeo, 8bitで番号, 8bitでポジションとする.
   * 空きマスは 黒,PTYPE_EMPTY, 番号 0x80, ポジション 0
   * 盤外は     白,PTYPE_EDGE,  番号 0x40, ポジション 0
   */
  class Piece
  {
    int piece;
    Piece(int p) : piece(p)
    {
    }
  public:
    static const int SIZE=40;
    static const Piece makeDirect(int value) { return Piece(value); }
    int intValue() const { return piece; }
    static const Piece EMPTY()  { return Piece(BLACK,PTYPE_EMPTY,EMPTY_NUM,Square::STAND()); }
    static const Piece EDGE() { return Piece(WHITE,PTYPE_EDGE,EDGE_NUM,Square::STAND()); }
    static const int BitOffsetPtype=16;
    static const int BitOffsetPromote=BitOffsetPtype+3;
    static const int BitOffsetMovePromote=BitOffsetPromote+4;
    
    Piece(Player owner, Ptype ptype, int num, Square square)
      : piece((static_cast<int>(owner)<<20)
	      +(static_cast<int>(ptype)<<BitOffsetPtype)
	      +((num)<<8)+ square.uintValue())
    {
    }
    Piece() : piece(EMPTY().piece)
    {
    }
    /**
     * 玉を作る
     */
    static const Piece
#ifdef __GNUC__
	__attribute__ ((pure))
#endif
    makeKing(Player owner, Square square);

    Ptype ptype() const {
      return static_cast<Ptype>((piece>>BitOffsetPtype)&0xf);
    }
    PtypeO ptypeO() const {
      return static_cast<PtypeO>(piece>>BitOffsetPtype);
    }

    int number() const {
      return ((piece&0xff00)>>8);
    }

    const Square square() const {
      return Square::makeDirect(piece&0xff);
    }

    Piece& operator+=(Offset offset) {
      piece += offset.intValue();
      return *this;
    }

    void setSquare(Square square) {
      piece = (piece&0xffffff00)+square.uintValue();
    }
  private:
    bool isOnBoardByOwner(Int2Type<BLACK>) const {
      return static_cast<int>(static_cast<unsigned int>(piece)&0x800000ff)>0;
    }
    /**
     * opteronでは,
     *  return static_cast<int>((piece+0x80000000)&0x800000ff)>0;
     * の方が速かった.
     */
    bool isOnBoardByOwner(Int2Type<WHITE>) const {
      return static_cast<int>((-piece)&0x800000ff)>0;
    }
  public:
    /**
     * piece がプレイヤーPの持ち物でかつボード上にある駒の場合は true.
     * 敵の駒だったり,駒台の駒だったり,Piece::EMPTY(), PIECE_EDGEの場合は false
     * @param P(template) - プレイヤー
     * @param piece - 
     */
    template<Player P>
    bool isOnBoardByOwner() const { return isOnBoardByOwner(Int2Type<P>()); }
    /**
     * isOnBoardByOwner の通常関数のバージョン.
     */
    bool isOnBoardByOwner(Player owner) const
    {
      if(owner==BLACK)
	return isOnBoardByOwner<BLACK>();
      else
	return isOnBoardByOwner<WHITE>();
    }

    /* 成る.  PROMOTE不可なpieceに適用不可 */
    const Piece promote() const {
      assert(canPromote(ptype()));
      return Piece(piece-0x80000);
    }

    /* 成りを戻す.  PROMOTE不可なpieceに適用可  */
    const Piece unpromote() const {
      return Piece((int)piece|0x80000);
    }

    /**
     * 取られたpieceを作成. unpromoteして,Squareは0に
     * 相手の持ちものにする
     */
    const Piece captured() const {
      // return (Piece)((((int)piece|0x80000)&0xffffff00)^0xfff00000);
      // をoptimizeする
      return Piece((piece&0xfff7ff00)^0xfff80000);
    }

    const Piece promoteWithMask(int promote_mask) const {
      assert(! (isPromoted() && promote_mask));
      assert(promote_mask==0 || promote_mask==(1<<23));
      return Piece(piece - (promote_mask>>(BitOffsetMovePromote-BitOffsetPromote)));
    }

    const Piece checkPromote(bool promotep) const {
      return Piece(piece - (promotep<<19));
    }

    /**
     * promoteした駒かどうかをチェックする
     */
    bool isPromoted() const { return (piece&(1<<19))==0; }

    /**
     * promoteしていないOnBoardの駒であることのチェック
     * Lance位しか使い道がない?
     */
    bool isOnBoardNotPromoted() const{
      int mask=piece&((1<<19)|0xff);
      return mask>(1<<19);
    }
    bool isPromotedNotKingGold() const {
      assert(ptype()!=KING && ptype()!=GOLD);
      return isPromoted();
    }

    bool isEmpty() const {
      return (piece&0x8000)!=0;
    }
    static bool isEmptyNum(int num) {
      return (num&0x80)!=0;
    }
    bool isEdge() const { 
      return (piece&0x4000)!=0;
    }
    static bool isEdgeNum(int num){
      assert(!isEmptyNum(num));
       return (num&0x40)!=0;
    }
    static bool isPieceNum(int num){
      return (num&0xc0)==0;
    }
    template<Ptype T>
    bool isPtype() const{
      return (piece&0xf0000)==((T)<<BitOffsetPtype);
    }
    /**
     * あるpieceがPlayer pの持ち物でPtype ptypeであるかどうかをチェックする.
     * TはEMPTY, EDGEではない.
     */
    bool isPlayerPtype(Player pl,Ptype ptype) const{
      assert(PTYPE_PIECE_MIN<=ptype && ptype<=PTYPE_MAX);
      return (piece&0x1f0000)==(((ptype)<<BitOffsetPtype)|(pl&0x100000));
    }
    /**
     * あるpieceがPlayer pの持ち物でBASIC typeがptypeであるかどうかをチェックする.
     * TはEMPTY, EDGEではない.
     */
    bool isPlayerBasicPtype(Player pl,Ptype ptype) const{
      assert(PTYPE_PIECE_MIN<=ptype && ptype<=PTYPE_MAX);
      assert(isBasic(ptype));
      if(canPromote(ptype))
	return (piece&0x170000)==(((osl::promote(ptype))<<BitOffsetPtype)|(pl&0x100000));
      else
	return isPlayerPtype(pl,ptype);
    }
    bool isPiece() const {
      return (piece&0xc000)==0;
    }
    /**
     * pieceであることが分かっている時に,更にBlackかどうかをチェックする.
     */
    bool pieceIsBlack() const{
      assert(isPiece());
      return static_cast<int>(piece)>=0;
    }
    Player owner() const
    {
      assert(isPiece());
      return static_cast<Player>(piece>>20);
    }

  private:
    /**
     * PIECE_EMPTY 0x00008000
     * BLACK_PIECE 0x000XxxYY X>=2, YY>0
     * PIECE_EDGE  0xfff14000
     * WHITE_PIECE 0xfffXxxYY X>=2, YY>0
     */
    bool canMoveOn(Int2Type<BLACK>) const {
      return ((piece+0xe0000)&0x104000)==0;
    }
    bool canMoveOn(Int2Type<WHITE>) const {
      return piece>=0;
    }
  public:
    /** Player Pの駒が,thisの上に移動できるか?
     * @return thisが相手の駒かEMPTYならtrue
     * @param P 手番
     */
    template<Player P>
    bool canMoveOn() const { return canMoveOn(Int2Type<P>()); }

    bool canMoveOn(Player pl) const{
      if(pl==BLACK) 
	return canMoveOn<BLACK>();
      else 
	return canMoveOn<WHITE>();
    }

    bool isOnBoard() const {
      assert(square().isValid());
      return ! square().isPieceStand();
    }
  };

  inline bool operator<(Piece l, Piece r)
  {
    return l.intValue() < r.intValue();
  }
  inline bool operator==(Piece l, Piece r)
  {
    return l.intValue() == r.intValue();
  }
  inline bool operator!=(Piece l, Piece r)
  {
    return ! (l == r);
  }

  std::ostream& operator<<(std::ostream& os,const Piece piece);
}

#endif /* OSL_PIECE_H */
// ;;; Local Variables:
// ;;; mode:c++
// ;;; c-basic-offset:2
// ;;; End: