gcc: Fix build error

This commit is contained in:
Calcitem 2021-02-11 14:09:53 +08:00
parent e8ad3559bd
commit 043d1f5a04
6 changed files with 22 additions and 13 deletions

View File

@ -26,6 +26,15 @@
#include "option.h"
#include "position.h"
const char *loseReasonNoWayStr = "Player%d no way to go. Player%d win!";
const char *loseReasonTimeOverStr = "Time over. Player%d win!";
const char *drawReasonThreefoldRepetitionStr = "Threefold Repetition. Draw!";
const char *drawReasonRule50Str = "Fifty-move rule. Draw!";
const char *loseReasonBoardIsFullStr = "Full. Player2 win!";
const char *drawReasonBoardIsFullStr = "Full. In draw!";
const char *loseReasonlessThanThreeStr = "Player%d win!";
const char *loseReasonResignStr = "Player%d give up!";
namespace Mills
{

View File

@ -22,14 +22,14 @@
#include "types.h"
#include "config.h"
static const char *loseReasonNoWayStr = "Player%d no way to go. Player%d win!";
static const char *loseReasonTimeOverStr = "Time over. Player%d win!";
static const char *drawReasonThreefoldRepetitionStr = "Threefold Repetition. Draw!";
static const char *drawReasonRule50Str = "Fifty-move rule. Draw!";
static const char *loseReasonBoardIsFullStr = "Full. Player2 win!";
static const char *drawReasonBoardIsFullStr = "Full. In draw!";
static const char *loseReasonlessThanThreeStr = "Player%d win!";
static const char *loseReasonResignStr = "Player%d give up!";
extern const char *loseReasonNoWayStr;
extern const char *loseReasonTimeOverStr;
extern const char *drawReasonThreefoldRepetitionStr;
extern const char *drawReasonRule50Str;
extern const char *loseReasonBoardIsFullStr;
extern const char *drawReasonBoardIsFullStr;
extern const char *loseReasonlessThanThreeStr;
extern const char *loseReasonResignStr;
namespace Mills
{

View File

@ -590,7 +590,7 @@ bool Position::reset()
break;
}
if (snprintf(record, RECORD_LEN_MAX, "r%1d s%03d t%02d",
if (snprintf(record, RECORD_LEN_MAX, "r%1d s%03zu t%02d",
r + 1, rule.maxStepsLedToDraw, 0) > 0) {
return true;
}
@ -955,7 +955,7 @@ Color Position::get_winner() const noexcept
return winner;
}
inline void Position::set_gameover(Color w, GameOverReason reason)
void Position::set_gameover(Color w, GameOverReason reason)
{
phase = Phase::gameOver;
gameOverReason = reason;

View File

@ -52,7 +52,7 @@ struct Rule
// Player may fly if he is down to three pieces.
bool mayFly;
int maxStepsLedToDraw;
size_t maxStepsLedToDraw;
};
#define N_RULES 4

View File

@ -119,7 +119,7 @@ void on_mayFly(const Option &o)
void on_maxStepsLedToDraw(const Option &o)
{
rule.maxStepsLedToDraw = (int)o;
rule.maxStepsLedToDraw = (size_t)o;
}
/// Our case insensitive less() function as required by UCI protocol

View File

@ -385,7 +385,7 @@ void Game::setRule(int ruleNo, int stepLimited /*= -1*/, int timeLimited /*= -1*
elapsedSeconds[BLACK] = elapsedSeconds[WHITE] = 0;
char record[64] = { 0 };
if (snprintf(record, Position::RECORD_LEN_MAX, "r%1d s%03d t%02d", r + 1, rule.maxStepsLedToDraw, 0) <= 0) {
if (snprintf(record, Position::RECORD_LEN_MAX, "r%1d s%03zu t%02d", r + 1, rule.maxStepsLedToDraw, 0) <= 0) {
assert(0);
}
string cmd(record);