Skip to content

Commit 29b05fb

Browse files
author
Jesper Torp Kristensen
committed
Fixing warnings and errors
1 parent 7fe5729 commit 29b05fb

20 files changed

+35
-46
lines changed

src/board_2.cxx

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -296,11 +296,10 @@ bool Board2::legal_move(Move& move) const {
296296
if (num_checks == 2) return false;
297297
if (move.blah & PROTECTS_KING) {
298298
// ARGHH!!!:
299-
// Denne kode tager højde for tilfælde som fx loadfen K1r1Q1q1///////7k w - -
300-
// check_if_moved will være true for Q, da der vil
301-
// være en skakkende brik på denne linje.
299+
// This code fixes fx loadfen K1r1Q1q1///////7k w - -
300+
// check_if_moved will be true for Q as this line will contain a checking piece
302301
// loadfen 4Q1q1/K1r5//////7k w - -
303-
// DI... = DI... nødvendiggøres af fx loadfen K2Qq/2n//////k w - -
302+
// DI... = DI... is made necessry by eg loadfen K2Qq/2n//////k w - -
304303
return threat_elim[move.to] &&
305304
DIRECTION[move.from][king_pos[player]] == DIRECTION[move.from][move.to];
306305
}
@@ -381,7 +380,7 @@ bool Board2::next_move_fixed_destination(Move &move, Piece piece_kind) const {
381380
bool Board2::next_move(Move &move, Piece piece_kind) const {
382381
assert(move.blah & 7); // cerr << "next_move called on:\n" << move;
383382

384-
// The line below is not nescessary if next_move will never
383+
// The line below is not necessary if next_move will never
385384
// again be called on the same move after it has previously returned false.
386385
if (!legal_pos(move.from)) return false;
387386

@@ -457,8 +456,8 @@ Undo Board2::execute_move(Move move) {
457456
if (move.special_move) {
458457

459458
if (move.is_pawn_promotion()) {
460-
// rækkefølgen af remove og insert er nødvendig for at brikken
461-
// kan beholde sit nummer (piece_number's stack-system)
459+
// The order of remove and insert are necessary for the piece to
460+
// keep its number (piece_number's stack-system)
462461
remove_piece(move.from);
463462
insert_piece(move.to, move.special_move);
464463

@@ -529,8 +528,8 @@ void Board2::undo_move(Move move, Undo undo) {
529528
if (move.special_move) {
530529

531530
if (move.is_pawn_promotion()) {
532-
// rækkefølgen af remove og insert er nødvendig for at brikken
533-
// kan beholde sit nummer (piece_number's stack-system)
531+
// The order of remove and insert are necessary for the piece
532+
// to keep its number (piece_number's stack-system)
534533
remove_piece(move.to);
535534
insert_piece(move.from, player ? BLACK_PAWN : WHITE_PAWN);
536535

@@ -783,7 +782,7 @@ bool Board2::clr_board2(Board *board, ostream& os, vector<string> &p) {
783782
} else if (dot_demand(p, 3, "retro", "move", (uintptr_t)0)) {
784783
vector<triple<Move,Undo,int> > rm = b.get_retro_moves(true, true, true, true);
785784
uint n = atoi(p[2].c_str());
786-
if (0<=n && n<rm.size()) {
785+
if (n<rm.size()) {
787786
os << "Undoing retro move number " << n;
788787
if (rm[n].third) {
789788
os << " (transf " << rm[n].third << " nescessary)\n";
@@ -1786,7 +1785,7 @@ Board2::get_retro_moves(bool allow_pawn_promotion, bool allow_castling,
17861785
int pawn = player ? BPAWN : WPAWN;
17871786

17881787
for (int c=0; c<8; c++) {
1789-
if (board[offset+c]==pawn || (allow_captures && PIECE_COLOR[board[offset+c]] == player^1)) {
1788+
if (board[offset+c]==pawn || (allow_captures && PIECE_COLOR[board[offset+c]] == (player^1))) {
17901789
int lpawn = c != 0 && board[offset+c-1]+pawn==WPAWN+BPAWN;
17911790
int rpawn = c != 7 && board[offset+c+1]+pawn==WPAWN+BPAWN;
17921791
if (lpawn | rpawn) {

src/board_2_plus_help_classes.hxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ public:
322322
*/
323323

324324
void init_iterator(Position pos) {
325-
iterator_current = &(move_lists[pos].move_index[-1]);
325+
iterator_current = &(move_lists[pos].move_index[0]) - 1;
326326
iterator_end = &(move_lists[pos].move_index[move_lists[pos].count]);
327327
}
328328
bool iterate() {

src/board_3_class_implementation.hxx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,6 @@ void ClassName::undo_move(Move move, Undo undo) {
247247
--cannot_undo_before;
248248
}
249249

250-
move_stack[moves_played-1] != move;
251-
undo_stack[moves_played-1] != undo;
252-
253250
Board2::undo_move(move, undo);
254251

255252
hash_value = partial_hash_value;

src/board_constants.hxx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define _BOARD_CONSTANTS_
33

44
#include <stdint.h>
5+
#include <stdlib.h>
56
#include <string>
67

78
#include "board_defines.hxx"

src/compression/bdd_compression.hxx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#ifndef _BDT_COMPRESSION_
22
#define _BDT_COMPRESSION_
33

4-
using namespace std;
5-
64
typedef unsigned int uint;
75

86
#include <vector>
@@ -16,7 +14,7 @@ typedef unsigned int uint;
1614
// pairs[i] = yalla_result[pairs[i]]
1715
// a lot of the pairs will have the property
1816
// pairs[2*i]+1 = pairs[2*i+1]
19-
vector<uint> yalla(int shuffle_size, uint *pairs, int num_pairs, int barrier = 0);
17+
std::vector<uint> yalla(int shuffle_size, uint *pairs, int num_pairs, int barrier = 0);
2018

2119
void test_yalla();
2220

src/compression/binary_decision_diagram.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ void BinaryDecisionDiagram::init(const TYPE *table, int _log_size, uint max_valu
673673
}
674674

675675
#ifndef NDEBUG
676-
if (!(0<=j && j<index_split[layer-1])) {
676+
if (j>=index_split[layer-1]) {
677677
cerr << "j = " << j << ", index_split[layer-1] = " << index_split[layer-1]
678678
<< ", permutation.size() = " << permutation.size()
679679
<< ", layer = " << layer << "\n";

src/compression/binary_decision_diagram.hxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public:
9292
}
9393
void update(int index, uint value) {
9494
#ifndef NDEBUG
95-
if (!(0<=value && (int)value<(1<<bits_per_value)))
95+
if ((int)value >= (1<<bits_per_value))
9696
cerr << "index = " << index << ", value = " << value << ", btv = " << bits_per_value << "\n";
9797
assert(0<=value && (int)value<(1<<bits_per_value));
9898
#endif

src/compression/clustering_algorithm.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ vector<int> find_clusters(const vector<vector<TYPE> > &elements,
8787
int num_tries = 0;
8888
int picked;
8989
do {
90-
double cut_w = weight_sum*(1.0/((RAND_MAX+1)-1))*(rand()+1);
90+
double cut_w = weight_sum*(1.0/((RAND_MAX+1.0)-1))*(rand()+1);
9191
// 0 < cut_w < weight_sum, but the <'s are close to <=
9292
double prefix_sum = 0.0;
9393
picked = -1;

src/compression/run_length_encoding/bit_stream.hxx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ public:
290290
// Used for huff tree reduction
291291
int average_bit_size() { return 8*sizeof(TYPE); }
292292

293-
// En tilfældig ordensrelation mellem elementerne
293+
// An arbitrary relation
294294
bool operator()(const TYPE &e1, const TYPE &e2) {
295295
const uint8_t *p1 = reinterpret_cast<const uint8_t *>(&e1);
296296
const uint8_t *p2 = reinterpret_cast<const uint8_t *>(&e2);
@@ -303,7 +303,7 @@ public:
303303

304304
//------------
305305

306-
class Elias_int_streamer {//: public DefaultElementStreamer<uint> {
306+
class Elias_int_streamer : public DefaultElementStreamer<uint> {
307307
public:
308308
template<class INPUT_MODEL>
309309
void readElement(ibstream<INPUT_MODEL> &in, uint &n) {
@@ -325,7 +325,7 @@ public:
325325
}
326326
}
327327

328-
int average_bit_size() {
328+
const int average_bit_size() {
329329
return 12;// More or less arbitrary
330330
}
331331

@@ -335,10 +335,10 @@ public:
335335
return string(tmp);
336336
}
337337

338-
bool operator()(const uint &n1, const uint &n2) { return n1<n2; }
338+
bool operator()(const uint &n1, const uint &n2) const { return n1<n2; }
339339
};
340340

341-
class bit_streamer {//: public DefaultElementStreamer<bool> {
341+
class bit_streamer : public DefaultElementStreamer<bool> {
342342
public:
343343
template<class INPUT_MODEL>
344344
bool readElement(ibstream<INPUT_MODEL> &in, bool &element) {

src/compression/run_length_encoding/huffman_codec_templ.hxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,10 @@ void Huffman<TYPE, ElementStreamer>::init(vector<pair<TYPE, int> > &elem_counts,
116116

117117
// cerr << "Hertil " << insuf_count << " " << index << "\n";
118118

119-
if (dummy_active = insuf_count) {
119+
if ((dummy_active = insuf_count)) {
120120
// A non-empty set of elements was not worth storing.
121-
// A least occuring element (elem_counts[0].first) will now be used to represent
122-
// the set of these low-frequently occuring symbols.
121+
// A least occurring element (elem_counts[0].first) will now be used to represent
122+
// the set of these low-frequently occurring symbols.
123123
dummy = elem_counts[0].first;
124124
for (int i=0; i<index; i++) {
125125
ignored_elements[elem_counts[i].first] = true;

0 commit comments

Comments
 (0)