X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=backend.c;h=3e9109993fbf57fa8644103675f36652af52cdb6;hb=4e062d14429ed3a3a251c971690bade4c8cba946;hp=46a0df4ac157a68bfd932cf1b1b5f2cdc15c24f3;hpb=e70077aab0199817f37aef9ed0bdba1bbca93b45;p=xboard.git diff --git a/backend.c b/backend.c index 46a0df4..3e91099 100644 --- a/backend.c +++ b/backend.c @@ -312,7 +312,7 @@ int promoDefaultAltered; #define TN_PORT 23 char* -safeStrCpy( char *dst, const char *src, size_t count ) +safeStrCpy (char *dst, const char *src, size_t count) { // [HGM] made safe int i; assert( dst != NULL ); @@ -340,7 +340,7 @@ safeStrCpy( char *dst, const char *src, size_t count ) * We used this for all compiler */ double -u64ToDouble(u64 value) +u64ToDouble (u64 value) { double r; u64 tmp = value & u64Const(0x7fffffffffffffff); @@ -358,7 +358,7 @@ u64ToDouble(u64 value) by this function. */ int -PosFlags(index) +PosFlags (index) { int flags = F_ALL_CASTLE_OK; if ((index % 2) == 0) flags |= F_WHITE_ON_MOVE; @@ -643,8 +643,7 @@ Board initialPosition; "++++", etc. Also strips ()'s */ int -string_to_rating(str) - char *str; +string_to_rating (char *str) { while(*str && !isdigit(*str)) ++str; if (!*str) @@ -654,7 +653,7 @@ string_to_rating(str) } void -ClearProgramStats() +ClearProgramStats () { /* Init programStats */ programStats.movelist[0] = 0; @@ -670,7 +669,7 @@ ClearProgramStats() } void -CommonEngineInit() +CommonEngineInit () { // [HGM] moved some code here from InitBackend1 that has to be done after both engines have contributed their settings if (appData.firstPlaysBlack) { first.twoMachinesColor = "black\n"; @@ -704,7 +703,7 @@ CommonEngineInit() } void -UnloadEngine(ChessProgramState *cps) +UnloadEngine (ChessProgramState *cps) { /* Kill off first chess program */ if (cps->isr != NULL) @@ -723,7 +722,7 @@ UnloadEngine(ChessProgramState *cps) } void -ClearOptions(ChessProgramState *cps) +ClearOptions (ChessProgramState *cps) { int i; cps->nrOptions = cps->comboCnt = 0; @@ -739,7 +738,7 @@ char *engineNames[] = { }; void -InitEngine(ChessProgramState *cps, int n) +InitEngine (ChessProgramState *cps, int n) { // [HGM] all engine initialiation put in a function that does one engine ClearOptions(cps); @@ -832,7 +831,7 @@ InitEngine(ChessProgramState *cps, int n) ChessProgramState *savCps; void -LoadEngine() +LoadEngine () { int i; if(WaitForEngine(savCps, LoadEngine)) return; @@ -852,7 +851,7 @@ LoadEngine() } void -ReplaceEngine(ChessProgramState *cps, int n) +ReplaceEngine (ChessProgramState *cps, int n) { EditGameEvent(); UnloadEngine(cps); @@ -874,7 +873,7 @@ static char resetOptions[] = "-firstOptions \"\" -firstNPS -1 -fn \"\""; void -Load(ChessProgramState *cps, int i) +Load (ChessProgramState *cps, int i) { char *p, *q, buf[MSG_SIZ], command[MSG_SIZ], buf2[MSG_SIZ]; if(engineLine && engineLine[0]) { // an engine was selected from the combo box @@ -931,7 +930,7 @@ Load(ChessProgramState *cps, int i) } void -InitTimeControls() +InitTimeControls () { int matched, min, sec; /* @@ -962,7 +961,7 @@ InitTimeControls() } void -InitBackEnd1() +InitBackEnd1 () { ShowThinkingEvent(); // [HGM] thinking: make sure post/nopost state is set according to options @@ -1126,7 +1125,8 @@ InitBackEnd1() } -int NextIntegerFromString( char ** str, long * value ) +int +NextIntegerFromString (char ** str, long * value) { int result = -1; char * s = *str; @@ -1151,7 +1151,8 @@ int NextIntegerFromString( char ** str, long * value ) return result; } -int NextTimeControlFromString( char ** str, long * value ) +int +NextTimeControlFromString (char ** str, long * value) { long temp; int result = NextIntegerFromString( str, &temp ); @@ -1168,7 +1169,8 @@ int NextTimeControlFromString( char ** str, long * value ) return result; } -int NextSessionFromString( char ** str, int *moves, long * tc, long *inc, int *incType) +int +NextSessionFromString (char ** str, int *moves, long * tc, long *inc, int *incType) { /* [HGM] routine added to read '+moves/time' for secondary time control. */ int result = -1, type = 0; long temp, temp2; @@ -1209,7 +1211,8 @@ int NextSessionFromString( char ** str, int *moves, long * tc, long *inc, int *i return result; } -int GetTimeQuota(int movenr, int lastUsed, char *tcString) +int +GetTimeQuota (int movenr, int lastUsed, char *tcString) { /* [HGM] get time to add from the multi-session time-control string */ int incType, moves=1; /* kludge to force reading of first session */ long time, increment; @@ -1232,10 +1235,7 @@ int GetTimeQuota(int movenr, int lastUsed, char *tcString) } int -ParseTimeControl(tc, ti, mps) - char *tc; - float ti; - int mps; +ParseTimeControl (char *tc, float ti, int mps) { long tc1; long tc2; @@ -1298,7 +1298,7 @@ ParseTimeControl(tc, ti, mps) } void -InitBackEnd2() +InitBackEnd2 () { if (appData.debugMode) { fprintf(debugFP, "%s\n", programVersion); @@ -1328,7 +1328,7 @@ InitBackEnd2() } int -CalculateIndex(int index, int gameNr) +CalculateIndex (int index, int gameNr) { // [HGM] autoinc: absolute way to determine load index from game number (taking auto-inc and rewind into account) int res; if(index > 0) return index; // fixed nmber @@ -1339,7 +1339,7 @@ CalculateIndex(int index, int gameNr) } int -LoadGameOrPosition(int gameNr) +LoadGameOrPosition (int gameNr) { // [HGM] taken out of MatchEvent and NextMatchGame (to combine it) if (*appData.loadGameFile != NULLCHAR) { if (!LoadGameFromFile(appData.loadGameFile, @@ -1360,7 +1360,7 @@ LoadGameOrPosition(int gameNr) } void -ReserveGame(int gameNr, char resChar) +ReserveGame (int gameNr, char resChar) { FILE *tf = fopen(appData.tourneyFile, "r+"); char *p, *q, c, buf[MSG_SIZ]; @@ -1402,7 +1402,7 @@ ReserveGame(int gameNr, char resChar) } void -MatchEvent(int mode) +MatchEvent (int mode) { // [HGM] moved out of InitBackend3, to make it callable when match starts through menu int dummy; if(matchMode) { // already in match mode: switch it off @@ -1655,7 +1655,7 @@ InitBackEnd3 P((void)) } void -HistorySet( char movelist[][2*MOVE_LEN], int first, int last, int current ) +HistorySet (char movelist[][2*MOVE_LEN], int first, int last, int current) { DisplayBook(current+1); @@ -1673,7 +1673,7 @@ HistorySet( char movelist[][2*MOVE_LEN], int first, int last, int current ) * Returns 0 if okay, error code if not. */ int -establish() +establish () { char buf[MSG_SIZ]; @@ -1714,7 +1714,8 @@ establish() } } -void EscapeExpand(char *p, char *q) +void +EscapeExpand (char *p, char *q) { // [HGM] initstring: routine to shape up string arguments while(*p++ = *q++) if(p[-1] == '\\') switch(*q++) { @@ -1728,10 +1729,7 @@ void EscapeExpand(char *p, char *q) } void -show_bytes(fp, buf, count) - FILE *fp; - char *buf; - int count; +show_bytes (FILE *fp, char *buf, int count) { while (count--) { if (*buf < 040 || *(unsigned char *) buf > 0177) { @@ -1746,11 +1744,7 @@ show_bytes(fp, buf, count) /* Returns an errno value */ int -OutputMaybeTelnet(pr, message, count, outError) - ProcRef pr; - char *message; - int count; - int *outError; +OutputMaybeTelnet (ProcRef pr, char *message, int count, int *outError) { char buf[8192], *p, *q, *buflim; int left, newcount, outcount; @@ -1804,12 +1798,7 @@ OutputMaybeTelnet(pr, message, count, outError) } void -read_from_player(isr, closure, message, count, error) - InputSourceRef isr; - VOIDSTAR closure; - char *message; - int count; - int error; +read_from_player (InputSourceRef isr, VOIDSTAR closure, char *message, int count, int error) { int outError, outCount; static int gotEof = 0; @@ -1831,7 +1820,7 @@ read_from_player(isr, closure, message, count, error) } void -KeepAlive() +KeepAlive () { // [HGM] alive: periodically send dummy (date) command to ICS to prevent time-out if(!connectionAlive) DisplayFatalError("No response from ICS", 0, 1); connectionAlive = FALSE; // only sticks if no response to 'date' command. @@ -1840,7 +1829,8 @@ KeepAlive() } /* added routine for printf style output to ics */ -void ics_printf(char *format, ...) +void +ics_printf (char *format, ...) { char buffer[MSG_SIZ]; va_list args; @@ -1853,8 +1843,7 @@ void ics_printf(char *format, ...) } void -SendToICS(s) - char *s; +SendToICS (char *s) { int count, outCount, outError; @@ -1871,9 +1860,7 @@ SendToICS(s) without a delay causes problems when using timestamp on ICC (at least on my machine). */ void -SendToICSDelayed(s,msdelay) - char *s; - long msdelay; +SendToICSDelayed (char *s, long msdelay) { int count, outCount, outError; @@ -1897,8 +1884,7 @@ SendToICSDelayed(s,msdelay) Also deletes any suffix starting with '(' */ char * -StripHighlightAndTitle(s) - char *s; +StripHighlightAndTitle (char *s) { static char retbuf[MSG_SIZ]; char *p = retbuf; @@ -1922,8 +1908,7 @@ StripHighlightAndTitle(s) /* Remove all highlighting escape sequences in s */ char * -StripHighlight(s) - char *s; +StripHighlight (char *s) { static char retbuf[MSG_SIZ]; char *p = retbuf; @@ -1943,8 +1928,7 @@ StripHighlight(s) char *variantNames[] = VARIANT_NAMES; char * -VariantName(v) - VariantClass v; +VariantName (VariantClass v) { return variantNames[v]; } @@ -1953,8 +1937,7 @@ VariantName(v) /* Identify a variant from the strings the chess servers use or the PGN Variant tag names we use. */ VariantClass -StringToVariant(e) - char *e; +StringToVariant (char *e) { char *p; int wnum = -1; @@ -2165,10 +2148,7 @@ char star_match[STAR_MATCH_N][MSG_SIZ]; copied into star_match. */ int -looking_at(buf, index, pattern) - char *buf; - int *index; - char *pattern; +looking_at ( char *buf, int *index, char *pattern) { char *bufp = &buf[*index], *patternp = pattern; int star_count = 0; @@ -2206,9 +2186,7 @@ looking_at(buf, index, pattern) } void -SendToPlayer(data, length) - char *data; - int length; +SendToPlayer (char *data, int length) { int error, outCount; outCount = OutputToProcess(NoProc, data, length, &error); @@ -2218,9 +2196,7 @@ SendToPlayer(data, length) } void -PackHolding(packed, holding) - char packed[]; - char *holding; +PackHolding (char packed[], char *holding) { char *p = holding; char *q = packed; @@ -2255,8 +2231,7 @@ PackHolding(packed, holding) /* Telnet protocol requests from the front end */ void -TelnetRequest(ddww, option) - unsigned char ddww, option; +TelnetRequest (unsigned char ddww, unsigned char option) { unsigned char msg[3]; int outCount, outError; @@ -2304,21 +2279,21 @@ TelnetRequest(ddww, option) } void -DoEcho() +DoEcho () { if (!appData.icsActive) return; TelnetRequest(TN_DO, TN_ECHO); } void -DontEcho() +DontEcho () { if (!appData.icsActive) return; TelnetRequest(TN_DONT, TN_ECHO); } void -CopyHoldings(Board board, char *holdings, ChessSquare lowestPiece) +CopyHoldings (Board board, char *holdings, ChessSquare lowestPiece) { /* put the holdings sent to us by the server on the board holdings area */ int i, j, holdingsColumn, holdingsStartRow, direction, countsColumn; @@ -2360,7 +2335,7 @@ CopyHoldings(Board board, char *holdings, ChessSquare lowestPiece) void -VariantSwitch(Board board, VariantClass newVariant) +VariantSwitch (Board board, VariantClass newVariant) { int newHoldingsWidth, newWidth = 8, newHeight = 8, i, j; static Board oldBoard; @@ -2471,7 +2446,7 @@ int hMargin = 10, vMargin = 20, h, w; extern int squareSize, lineGap; void -PlotSeekAd(int i) +PlotSeekAd (int i) { int x, y, color = 0, r = ratingList[i]; float tc = tcList[i]; xList[i] = yList[i] = -100; // outside graph, so cannot be clicked @@ -2493,7 +2468,7 @@ PlotSeekAd(int i) } void -AddAd(char *handle, char *rating, int base, int inc, char rated, char *type, int nr, Boolean plot) +AddAd (char *handle, char *rating, int base, int inc, char rated, char *type, int nr, Boolean plot) { char buf[MSG_SIZ], *ext = ""; VariantClass v = StringToVariant(type); @@ -2517,7 +2492,7 @@ AddAd(char *handle, char *rating, int base, int inc, char rated, char *type, in } void -EraseSeekDot(int i) +EraseSeekDot (int i) { int x = xList[i], y = yList[i], d=squareSize/4, k; DrawSeekBackground(x-squareSize/8, y-squareSize/8, x+squareSize/8+1, y+squareSize/8+1); @@ -2531,7 +2506,7 @@ EraseSeekDot(int i) } void -RemoveSeekAd(int nr) +RemoveSeekAd (int nr) { int i; for(i=0; i 0) { @@ -4844,8 +4814,7 @@ GetMoveListEvent() } void -AnalysisPeriodicEvent(force) - int force; +AnalysisPeriodicEvent (int force) { if (((programStats.ok_to_send == 0 || programStats.line_is_book) && !force) || !appData.periodicUpdates) @@ -4861,16 +4830,14 @@ AnalysisPeriodicEvent(force) programStats.ok_to_send = 0; } -void ics_update_width(new_width) - int new_width; +void +ics_update_width (int new_width) { ics_printf("set width %d\n", new_width); } void -SendMoveToProgram(moveNum, cps) - int moveNum; - ChessProgramState *cps; +SendMoveToProgram (int moveNum, ChessProgramState *cps) { char buf[MSG_SIZ]; @@ -4948,10 +4915,7 @@ SendMoveToProgram(moveNum, cps) } void -SendMoveToICS(moveType, fromX, fromY, toX, toY, promoChar) - ChessMove moveType; - int fromX, fromY, toX, toY; - char promoChar; +SendMoveToICS (ChessMove moveType, int fromX, int fromY, int toX, int toY, char promoChar) { char user_move[MSG_SIZ]; char suffix[4]; @@ -5028,7 +4992,7 @@ SendMoveToICS(moveType, fromX, fromY, toX, toY, promoChar) } void -UploadGameEvent() +UploadGameEvent () { // [HGM] upload: send entire stored game to ICS as long-algebraic moves. int i, last = forwardMostMove; // make sure ICS reply cannot pre-empt us by clearing fmm static char *castlingStrings[4] = { "none", "kside", "qside", "both" }; @@ -5095,10 +5059,7 @@ UploadGameEvent() } void -CoordsToComputerAlgebraic(rf, ff, rt, ft, promoChar, move) - int rf, ff, rt, ft; - char promoChar; - char move[7]; +CoordsToComputerAlgebraic (int rf, int ff, int rt, int ft, char promoChar, char move[7]) { if (rf == DROP_RANK) { if(ff == EmptySquare) sprintf(move, "@@@@\n"); else // [HGM] pass @@ -5116,8 +5077,7 @@ CoordsToComputerAlgebraic(rf, ff, rt, ft, promoChar, move) } void -ProcessICSInitScript(f) - FILE *f; +ProcessICSInitScript (FILE *f) { char buf[MSG_SIZ]; @@ -5132,7 +5092,7 @@ ProcessICSInitScript(f) static int lastX, lastY, selectFlag, dragging; void -Sweep(int step) +Sweep (int step) { ChessSquare king = WhiteKing, pawn = WhitePawn, last = promoSweep; if(gameInfo.variant == VariantKnightmate) king = WhiteUnicorn; @@ -5153,7 +5113,8 @@ Sweep(int step) ChangeDragPiece(promoSweep); } -int PromoScroll(int x, int y) +int +PromoScroll (int x, int y) { int step = 0; @@ -5169,7 +5130,7 @@ int PromoScroll(int x, int y) } void -NextPiece(int step) +NextPiece (int step) { ChessSquare piece = boards[currentMove][toY][toX]; do { @@ -5184,7 +5145,7 @@ NextPiece(int step) } /* [HGM] Shogi move preprocessor: swap digits for letters, vice versa */ void -AlphaRank(char *move, int n) +AlphaRank (char *move, int n) { // char *p = move, c; int x, y; @@ -5236,12 +5197,7 @@ char yy_textstr[8000]; /* Parser for moves from gnuchess, ICS, or user typein box */ Boolean -ParseOneMove(move, moveNum, moveType, fromX, fromY, toX, toY, promoChar) - char *move; - int moveNum; - ChessMove *moveType; - int *fromX, *fromY, *toX, *toY; - char *promoChar; +ParseOneMove (char *move, int moveNum, ChessMove *moveType, int *fromX, int *fromY, int *toX, int *toY, char *promoChar) { *moveType = yylexstr(moveNum, move, yy_textstr, sizeof yy_textstr); @@ -5324,7 +5280,7 @@ Boolean pushed = FALSE; char *lastParseAttempt; void -ParsePV(char *pv, Boolean storeComments, Boolean atEnd) +ParsePV (char *pv, Boolean storeComments, Boolean atEnd) { // Parse a string of PV moves, and append to current game, behind forwardMostMove int fromX, fromY, toX, toY; char promoChar; ChessMove moveType; @@ -5390,7 +5346,7 @@ fprintf(debugFP,"parsePV: %d %c%c%c%c yy='%s'\nPV = '%s'\n", valid, fromX+AAA, f } int -MultiPV(ChessProgramState *cps) +MultiPV (ChessProgramState *cps) { // check if engine supports MultiPV, and if so, return the number of the option that sets it int i; for(i=0; inrOptions; i++) @@ -5400,7 +5356,7 @@ MultiPV(ChessProgramState *cps) } Boolean -LoadMultiPV(int x, int y, char *buf, int index, int *start, int *end) +LoadMultiPV (int x, int y, char *buf, int index, int *start, int *end) { int startPV, multi, lineStart, origIndex = index; char *p, buf2[MSG_SIZ]; @@ -5430,7 +5386,7 @@ LoadMultiPV(int x, int y, char *buf, int index, int *start, int *end) } char * -PvToSAN(char *pv) +PvToSAN (char *pv) { static char buf[10*MSG_SIZ]; int i, k=0, savedEnd=endPV, saveFMM = forwardMostMove; @@ -5449,7 +5405,7 @@ PvToSAN(char *pv) } Boolean -LoadPV(int x, int y) +LoadPV (int x, int y) { // called on right mouse click to load PV int which = gameMode == TwoMachinesPlay && (WhiteOnMove(forwardMostMove) == (second.twoMachinesColor[0] == 'w')); lastX = x; lastY = y; @@ -5458,7 +5414,7 @@ LoadPV(int x, int y) } void -UnLoadPV() +UnLoadPV () { int oldFMM = forwardMostMove; // N.B.: this was currentMove before PV was loaded! if(endPV < 0) return; @@ -5484,7 +5440,7 @@ UnLoadPV() } void -MovePV(int x, int y, int h) +MovePV (int x, int y, int h) { // step through PV based on mouse coordinates (called on mouse move) int margin = h>>3, step = 0, threshold = (pieceSweep == EmptySquare ? 10 : 15); @@ -5519,7 +5475,8 @@ int squaresLeft[4]; int piecesLeft[(int)BlackPawn]; int seed, nrOfShuffles; -void GetPositionNumber() +void +GetPositionNumber () { // sets global variable seed int i; @@ -5531,7 +5488,8 @@ void GetPositionNumber() } } -int put(Board board, int pieceType, int rank, int n, int shade) +int +put (Board board, int pieceType, int rank, int n, int shade) // put the piece on the (n-1)-th empty squares of the given shade { int i; @@ -5549,7 +5507,8 @@ int put(Board board, int pieceType, int rank, int n, int shade) } -void AddOnePiece(Board board, int pieceType, int rank, int shade) +void +AddOnePiece (Board board, int pieceType, int rank, int shade) // calculate where the next piece goes, (any empty square), and put it there { int i; @@ -5560,7 +5519,8 @@ void AddOnePiece(Board board, int pieceType, int rank, int shade) put(board, pieceType, rank, i, shade); } -void AddTwoPieces(Board board, int pieceType, int rank) +void +AddTwoPieces (Board board, int pieceType, int rank) // calculate where the next 2 identical pieces go, (any empty square), and put it there { int i, n=squaresLeft[ANY], j=n-1, k; @@ -5575,7 +5535,8 @@ void AddTwoPieces(Board board, int pieceType, int rank) put(board, pieceType, rank, i, ANY); } -void SetUpShuffle(Board board, int number) +void +SetUpShuffle (Board board, int number) { int i, p, first=1; @@ -5663,7 +5624,8 @@ void SetUpShuffle(Board board, int number) if(number >= 0) appData.defaultFrcPosition %= nrOfShuffles; // normalize } -int SetCharTable( char *table, const char * map ) +int +SetCharTable (char *table, const char * map) /* [HGM] moved here from winboard.c because of its general usefulness */ /* Basically a safe strcpy that uses the last character as King */ { @@ -5687,7 +5649,8 @@ int SetCharTable( char *table, const char * map ) return result; } -void Prelude(Board board) +void +Prelude (Board board) { // [HGM] superchess: random selection of exo-pieces int i, j, k; ChessSquare p; static ChessSquare exoPieces[4] = { WhiteAngel, WhiteMarshall, WhiteSilver, WhiteLance }; @@ -5724,8 +5687,7 @@ void Prelude(Board board) } void -InitPosition(redraw) - int redraw; +InitPosition (int redraw) { ChessSquare (* pieces)[BOARD_FILES]; int i, j, pawnRow, overrule, @@ -6019,9 +5981,7 @@ InitPosition(redraw) } void -SendBoard(cps, moveNum) - ChessProgramState *cps; - int moveNum; +SendBoard (ChessProgramState *cps, int moveNum) { char message[MSG_SIZ]; @@ -6097,7 +6057,7 @@ SendBoard(cps, moveNum) } ChessSquare -DefaultPromoChoice(int white) +DefaultPromoChoice (int white) { ChessSquare result; if(gameInfo.variant == VariantShatranj || gameInfo.variant == VariantCourier || gameInfo.variant == VariantMakruk) @@ -6114,7 +6074,7 @@ DefaultPromoChoice(int white) static int autoQueen; // [HGM] oneclick int -HasPromotionChoice(int fromX, int fromY, int toX, int toY, char *promoChoice, int sweepSelect) +HasPromotionChoice (int fromX, int fromY, int toX, int toY, char *promoChoice, int sweepSelect) { /* [HGM] rewritten IsPromotion to only flag promotions that offer a choice */ /* [HGM] add Shogi promotions */ @@ -6216,8 +6176,7 @@ HasPromotionChoice(int fromX, int fromY, int toX, int toY, char *promoChoice, in } int -InPalace(row, column) - int row, column; +InPalace (int row, int column) { /* [HGM] for Xiangqi */ if( (row < 3 || row > BOARD_HEIGHT-4) && column < (BOARD_WIDTH + 4)/2 && @@ -6226,9 +6185,7 @@ InPalace(row, column) } int -PieceForSquare (x, y) - int x; - int y; +PieceForSquare (int x, int y) { if (x < 0 || x >= BOARD_WIDTH || y < 0 || y >= BOARD_HEIGHT) return -1; @@ -6237,8 +6194,7 @@ PieceForSquare (x, y) } int -OKToStartUserMove(x, y) - int x, y; +OKToStartUserMove (int x, int y) { ChessSquare from_piece; int white_piece; @@ -6338,7 +6294,8 @@ OKToStartUserMove(x, y) } Boolean -OnlyMove(int *x, int *y, Boolean captures) { +OnlyMove (int *x, int *y, Boolean captures) +{ DisambiguateClosure cl; if (appData.zippyPlay || !appData.testLegality) return FALSE; switch(gameMode) { @@ -6402,9 +6359,7 @@ char lastLoadGameTitle[MSG_SIZ], lastLoadPositionTitle[MSG_SIZ]; ChessMove lastLoadGameStart = EndOfFile; void -UserMoveEvent(fromX, fromY, toX, toY, promoChar) - int fromX, fromY, toX, toY; - int promoChar; +UserMoveEvent(int fromX, int fromY, int toX, int toY, int promoChar) { ChessMove moveType; ChessSquare pdown, pup; @@ -6579,10 +6534,7 @@ UserMoveEvent(fromX, fromY, toX, toY, promoChar) /* Common tail of UserMoveEvent and DropMenuEvent */ int -FinishMove(moveType, fromX, fromY, toX, toY, promoChar) - ChessMove moveType; - int fromX, fromY, toX, toY; - /*char*/int promoChar; +FinishMove (ChessMove moveType, int fromX, int fromY, int toX, int toY, int promoChar) { char *bookHit = 0; @@ -6767,12 +6719,7 @@ FinishMove(moveType, fromX, fromY, toX, toY, promoChar) } void -Mark(board, flags, kind, rf, ff, rt, ft, closure) - Board board; - int flags; - ChessMove kind; - int rf, ff, rt, ft; - VOIDSTAR closure; +Mark (Board board, int flags, ChessMove kind, int rf, int ff, int rt, int ft, VOIDSTAR closure) { typedef char Markers[BOARD_RANKS][BOARD_FILES]; Markers *m = (Markers *) closure; @@ -6784,7 +6731,7 @@ Mark(board, flags, kind, rf, ff, rt, ft, closure) } void -MarkTargetSquares(int clear) +MarkTargetSquares (int clear) { int x, y; if(!appData.markers || !appData.highlightDragging || appData.icsActive && gameInfo.variant < VariantShogi || @@ -6804,7 +6751,7 @@ MarkTargetSquares(int clear) } int -Explode(Board board, int fromX, int fromY, int toX, int toY) +Explode (Board board, int fromX, int fromY, int toX, int toY) { if(gameInfo.variant == VariantAtomic && (board[toY][toX] != EmptySquare || // capture? @@ -6819,7 +6766,8 @@ Explode(Board board, int fromX, int fromY, int toX, int toY) ChessSquare gatingPiece = EmptySquare; // exported to front-end, for dragging -int CanPromote(ChessSquare piece, int y) +int +CanPromote (ChessSquare piece, int y) { if(gameMode == EditPosition) return FALSE; // no promotions when editing position // some variants have fixed promotion piece, no promotion at all, or another selection mechanism @@ -6833,7 +6781,8 @@ int CanPromote(ChessSquare piece, int y) piece == WhiteLance && y == BOARD_HEIGHT-2 ); } -void LeftClick(ClickType clickType, int xPix, int yPix) +void +LeftClick (ClickType clickType, int xPix, int yPix) { int x, y; Boolean saveAnimate; @@ -7131,7 +7080,8 @@ void LeftClick(ClickType clickType, int xPix, int yPix) } } -int RightClick(ClickType action, int x, int y, int *fromX, int *fromY) +int +RightClick (ClickType action, int x, int y, int *fromX, int *fromY) { // front-end-free part taken out of PieceMenuPopup int whichMenu; int xSqr, ySqr; @@ -7221,7 +7171,8 @@ int RightClick(ClickType action, int x, int y, int *fromX, int *fromY) return whichMenu; } -void SendProgramStatsToFrontend( ChessProgramState * cps, ChessProgramStats * cpstats ) +void +SendProgramStatsToFrontend (ChessProgramState * cps, ChessProgramStats * cpstats) { // char * hint = lastHint; FrontEndProgramStats stats; @@ -7248,7 +7199,7 @@ void SendProgramStatsToFrontend( ChessProgramState * cps, ChessProgramStats * cp } void -ClearEngineOutputPane(int which) +ClearEngineOutputPane (int which) { static FrontEndProgramStats dummyStats; dummyStats.which = which; @@ -7259,7 +7210,7 @@ ClearEngineOutputPane(int which) #define MAXPLAYERS 500 char * -TourneyStandings(int display) +TourneyStandings (int display) { int i, w, b, color, wScore, bScore, dummy, nr=0, nPlayers=0; int score[MAXPLAYERS], ranking[MAXPLAYERS], points[MAXPLAYERS], games[MAXPLAYERS]; @@ -7303,7 +7254,7 @@ TourneyStandings(int display) } void -Count(Board board, int pCnt[], int *nW, int *nB, int *wStale, int *bStale, int *bishopColor) +Count (Board board, int pCnt[], int *nW, int *nB, int *wStale, int *bStale, int *bishopColor) { // count all piece types int p, f, r; *nB = *nW = *wStale = *bStale = *bishopColor = 0; @@ -7321,7 +7272,7 @@ Count(Board board, int pCnt[], int *nW, int *nB, int *wStale, int *bStale, int * } int -SufficientDefence(int pCnt[], int side, int nMine, int nHis) +SufficientDefence (int pCnt[], int side, int nMine, int nHis) { int myPawns = pCnt[WhitePawn+side]; // my total Pawn count; int majorDefense = pCnt[BlackRook-side] + pCnt[BlackCannon-side] + pCnt[BlackKnight-side]; @@ -7350,7 +7301,7 @@ SufficientDefence(int pCnt[], int side, int nMine, int nHis) } int -MatingPotential(int pCnt[], int side, int nMine, int nHis, int stale, int bisColor) +MatingPotential (int pCnt[], int side, int nMine, int nHis, int stale, int bisColor) { VariantClass v = gameInfo.variant; @@ -7400,7 +7351,7 @@ MatingPotential(int pCnt[], int side, int nMine, int nHis, int stale, int bisCol } int -CompareWithRights(Board b1, Board b2) +CompareWithRights (Board b1, Board b2) { int rights = 0; if(!CompareBoards(b1, b2)) return FALSE; @@ -7422,7 +7373,7 @@ CompareWithRights(Board b1, Board b2) } int -Adjudicate(ChessProgramState *cps) +Adjudicate (ChessProgramState *cps) { // [HGM] some adjudications useful with buggy engines // [HGM] adjudicate: made into separate routine, which now can be called after every move // In any case it determnes if the game is a claimable draw (filling in EP_STATUS). @@ -7731,7 +7682,8 @@ Adjudicate(ChessProgramState *cps) return 0; } -char *SendMoveToBookUser(int moveNr, ChessProgramState *cps, int initial) +char * +SendMoveToBookUser (int moveNr, ChessProgramState *cps, int initial) { // [HGM] book: this routine intercepts moves to simulate book replies char *bookHit = NULL; @@ -7781,7 +7733,8 @@ char *SendMoveToBookUser(int moveNr, ChessProgramState *cps, int initial) char *savedMessage; ChessProgramState *savedState; -void DeferredBookMove(void) +void +DeferredBookMove (void) { if(savedState->lastPing != savedState->lastPong) ScheduleDelayedEvent(DeferredBookMove, 10); @@ -7792,9 +7745,7 @@ void DeferredBookMove(void) static int savedWhitePlayer, savedBlackPlayer, pairingReceived; void -HandleMachineMove(message, cps) - char *message; - ChessProgramState *cps; +HandleMachineMove (char *message, ChessProgramState *cps) { char machineMove[MSG_SIZ], buf1[MSG_SIZ*10], buf2[MSG_SIZ]; char realname[MSG_SIZ]; @@ -8892,8 +8843,7 @@ if(appData.debugMode) fprintf(debugFP, "nodes = %d, %lld\n", (int) programStats. The display is not updated in any way. */ void -ParseGameHistory(game) - char *game; +ParseGameHistory (char *game) { ChessMove moveType; int fromX, fromY, toX, toY, boardIndex; @@ -9076,10 +9026,7 @@ ParseGameHistory(game) /* Apply a move to the given board */ void -ApplyMove(fromX, fromY, toX, toY, promoChar, board) - int fromX, fromY, toX, toY; - int promoChar; - Board board; +ApplyMove (int fromX, int fromY, int toX, int toY, int promoChar, Board board) { ChessSquare captured = board[toY][toX], piece, king; int p, oldEP = EP_NONE, berolina = 0; int promoRank = gameInfo.variant == VariantMakruk || gameInfo.variant == VariantGrand ? 3 : 1; @@ -9382,9 +9329,7 @@ ApplyMove(fromX, fromY, toX, toY, promoChar, board) /* Updates forwardMostMove */ void -MakeMove(fromX, fromY, toX, toY, promoChar) - int fromX, fromY, toX, toY; - int promoChar; +MakeMove (int fromX, int fromY, int toX, int toY, int promoChar) { // forwardMostMove++; // [HGM] bare: moved downstream @@ -9489,7 +9434,7 @@ MakeMove(fromX, fromY, toX, toY, promoChar) /* Updates currentMove if not pausing */ void -ShowMove(fromX, fromY, toX, toY) +ShowMove (int fromX, int fromY, int toX, int toY) { int instant = (gameMode == PlayFromGameFile) ? (matchMode || (appData.timeDelay == 0 && !pausing)) : pausing; @@ -9515,7 +9460,8 @@ ShowMove(fromX, fromY, toX, toY) HistorySet(parseList,backwardMostMove,forwardMostMove,currentMove-1); } -void SendEgtPath(ChessProgramState *cps) +void +SendEgtPath (ChessProgramState *cps) { /* [HGM] EGT: match formats given in feature with those given by user, and send info for each match */ char buf[MSG_SIZ], name[MSG_SIZ], *p; @@ -9549,9 +9495,8 @@ void SendEgtPath(ChessProgramState *cps) } void -InitChessProgram(cps, setup) - ChessProgramState *cps; - int setup; /* [HGM] needed to setup FRC opening position */ +InitChessProgram (ChessProgramState *cps, int setup) +/* setup needed to setup FRC opening position */ { char buf[MSG_SIZ], b[MSG_SIZ]; int overruled; if (appData.noChessProgram) return; @@ -9672,8 +9617,7 @@ InitChessProgram(cps, setup) void -StartChessProgram(cps) - ChessProgramState *cps; +StartChessProgram (ChessProgramState *cps) { char buf[MSG_SIZ]; int err; @@ -9740,7 +9684,7 @@ TwoMachinesEventIfReady P((void)) } char * -MakeName(char *template) +MakeName (char *template) { time_t clock; struct tm *tm; @@ -9769,7 +9713,7 @@ MakeName(char *template) } int -CountPlayers(char *p) +CountPlayers (char *p) { int n = 0; while(p = strchr(p, '\n')) p++, n++; // count participants @@ -9777,7 +9721,7 @@ CountPlayers(char *p) } FILE * -WriteTourneyFile(char *results, FILE *f) +WriteTourneyFile (char *results, FILE *f) { // write tournament parameters on tourneyFile; on success return the stream pointer for closing if(f == NULL) f = fopen(appData.tourneyFile, "w"); if(f == NULL) DisplayError(_("Could not write on tourney file"), 0); else { @@ -9811,7 +9755,8 @@ WriteTourneyFile(char *results, FILE *f) #define MAXENGINES 1000 char *command[MAXENGINES], *mnemonic[MAXENGINES]; -void Substitute(char *participants, int expunge) +void +Substitute (char *participants, int expunge) { int i, changed, changes=0, nPlayers=0; char *p, *q, *r, buf[MSG_SIZ]; @@ -9869,7 +9814,7 @@ void Substitute(char *participants, int expunge) } int -CreateTourney(char *name) +CreateTourney (char *name) { FILE *f; if(matchMode && strcmp(name, appData.tourneyFile)) { @@ -9901,7 +9846,8 @@ CreateTourney(char *name) return 1; } -void NamesToList(char *names, char **engineList, char **engineMnemonic) +void +NamesToList (char *names, char **engineList, char **engineMnemonic) { char buf[MSG_SIZ], *p, *q; int i=1; @@ -9929,7 +9875,8 @@ void NamesToList(char *names, char **engineList, char **engineMnemonic) // following implemented as macro to avoid type limitations #define SWAP(item, temp) temp = appData.item[0]; appData.item[0] = appData.item[n]; appData.item[n] = temp; -void SwapEngines(int n) +void +SwapEngines (int n) { // swap settings for first engine and other engine (so far only some selected options) int h; char *p; @@ -9949,7 +9896,7 @@ void SwapEngines(int n) } void -SetPlayer(int player) +SetPlayer (int player) { // [HGM] find the engine line of the partcipant given by number, and parse its options. int i; char buf[MSG_SIZ], *engineName, *p = appData.participants; @@ -9966,7 +9913,7 @@ SetPlayer(int player) } int -Pairing(int nr, int nPlayers, int *whitePlayer, int *blackPlayer, int *syncInterval) +Pairing (int nr, int nPlayers, int *whitePlayer, int *blackPlayer, int *syncInterval) { // determine players from game number int curCycle, curRound, curPairing, gamesPerCycle, gamesPerRound, roundsPerCycle=1, pairingsPerRound=1; @@ -10012,7 +9959,7 @@ Pairing(int nr, int nPlayers, int *whitePlayer, int *blackPlayer, int *syncInter } int -NextTourneyGame(int nr, int *swapColors) +NextTourneyGame (int nr, int *swapColors) { // !!!major kludge!!! fiddle appData settings to get everything in order for next tourney game char *p, *q; int whitePlayer, blackPlayer, firstBusy=1000000000, syncInterval = 0, nPlayers; @@ -10078,7 +10025,7 @@ NextTourneyGame(int nr, int *swapColors) } void -NextMatchGame() +NextMatchGame () { // performs game initialization that does not invoke engines, and then tries to start the game int res, firstWhite, swapColors = 0; if(!NextTourneyGame(nextGame, &swapColors)) return; // this sets matchGame, -fcp / -scp and other options for next game, if needed @@ -10095,7 +10042,8 @@ NextMatchGame() TwoMachinesEvent(); } -void UserAdjudicationEvent( int result ) +void +UserAdjudicationEvent (int result) { ChessMove gameResult = GameIsDrawn; @@ -10113,7 +10061,8 @@ void UserAdjudicationEvent( int result ) // [HGM] save: calculate checksum of game to make games easily identifiable -int StringCheckSum(char *s) +int +StringCheckSum (char *s) { int i = 0; if(s==NULL) return 0; @@ -10121,7 +10070,8 @@ int StringCheckSum(char *s) return i; } -int GameCheckSum() +int +GameCheckSum () { int i, sum=0; for(i=backwardMostMove; i 2) { @@ -13021,7 +12936,7 @@ ExitEvent(status) } void -PauseEvent() +PauseEvent () { if (appData.debugMode) fprintf(debugFP, "PauseEvent(): pausing %d\n", pausing); @@ -13086,7 +13001,7 @@ PauseEvent() } void -EditCommentEvent() +EditCommentEvent () { char title[MSG_SIZ]; @@ -13103,7 +13018,7 @@ EditCommentEvent() void -EditTagsEvent() +EditTagsEvent () { char *tags = PGNTags(&gameInfo); bookUp = FALSE; @@ -13112,7 +13027,7 @@ EditTagsEvent() } void -AnalyzeModeEvent() +AnalyzeModeEvent () { if (appData.noChessProgram || gameMode == AnalyzeMode) return; @@ -13140,7 +13055,7 @@ AnalyzeModeEvent() } void -AnalyzeFileEvent() +AnalyzeFileEvent () { if (appData.noChessProgram || gameMode == AnalyzeFile) return; @@ -13167,7 +13082,7 @@ AnalyzeFileEvent() } void -MachineWhiteEvent() +MachineWhiteEvent () { char buf[MSG_SIZ]; char *bookHit = NULL; @@ -13248,7 +13163,7 @@ MachineWhiteEvent() } void -MachineBlackEvent() +MachineBlackEvent () { char buf[MSG_SIZ]; char *bookHit = NULL; @@ -13324,7 +13239,7 @@ MachineBlackEvent() void -DisplayTwoMachinesTitle() +DisplayTwoMachinesTitle () { char buf[MSG_SIZ]; if (appData.matchGames > 0) { @@ -13352,7 +13267,7 @@ DisplayTwoMachinesTitle() } void -SettingsMenuIfReady() +SettingsMenuIfReady () { if (second.lastPing != second.lastPong) { DisplayMessage("", _("Waiting for second chess program")); @@ -13365,7 +13280,7 @@ SettingsMenuIfReady() } int -WaitForEngine(ChessProgramState *cps, DelayedEventCallback retry) +WaitForEngine (ChessProgramState *cps, DelayedEventCallback retry) { char buf[MSG_SIZ]; if (cps->pr == NoProc) { @@ -13522,7 +13437,7 @@ TwoMachinesEvent P((void)) } void -TrainingEvent() +TrainingEvent () { if (gameMode == Training) { SetTrainingModeOff(); @@ -13545,7 +13460,7 @@ TrainingEvent() } void -IcsClientEvent() +IcsClientEvent () { if (!appData.icsActive) return; switch (gameMode) { @@ -13579,9 +13494,8 @@ IcsClientEvent() return; } - void -EditGameEvent() +EditGameEvent () { int i; @@ -13671,7 +13585,7 @@ EditGameEvent() void -EditPositionEvent() +EditPositionEvent () { if (gameMode == EditPosition) { EditGameEvent(); @@ -13695,7 +13609,7 @@ EditPositionEvent() } void -ExitAnalyzeMode() +ExitAnalyzeMode () { /* [DM] icsEngineAnalyze - possible call from other functions */ if (appData.icsEngineAnalyze) { @@ -13711,7 +13625,7 @@ ExitAnalyzeMode() } void -EditPositionDone(Boolean fakeRights) +EditPositionDone (Boolean fakeRights) { int king = gameInfo.variant == VariantKnightmate ? WhiteUnicorn : WhiteKing; @@ -13754,8 +13668,7 @@ EditPositionDone(Boolean fakeRights) /* Pause for `ms' milliseconds */ /* !! Ugh, this is a kludge. Fix it sometime. --tpm */ void -TimeDelay(ms) - long ms; +TimeDelay (long ms) { TimeMark m1, m2; @@ -13767,8 +13680,7 @@ TimeDelay(ms) /* !! Ugh, this is a kludge. Fix it sometime. --tpm */ void -SendMultiLineToICS(buf) - char *buf; +SendMultiLineToICS (char *buf) { char temp[MSG_SIZ+1], *p; int len; @@ -13793,7 +13705,7 @@ SendMultiLineToICS(buf) } void -SetWhiteToPlayEvent() +SetWhiteToPlayEvent () { if (gameMode == EditPosition) { blackPlaysFirst = FALSE; @@ -13805,7 +13717,7 @@ SetWhiteToPlayEvent() } void -SetBlackToPlayEvent() +SetBlackToPlayEvent () { if (gameMode == EditPosition) { blackPlaysFirst = TRUE; @@ -13819,9 +13731,7 @@ SetBlackToPlayEvent() } void -EditPositionMenuEvent(selection, x, y) - ChessSquare selection; - int x, y; +EditPositionMenuEvent (ChessSquare selection, int x, int y) { char buf[MSG_SIZ]; ChessSquare piece = boards[0][y][x]; @@ -13949,9 +13859,7 @@ EditPositionMenuEvent(selection, x, y) void -DropMenuEvent(selection, x, y) - ChessSquare selection; - int x, y; +DropMenuEvent (ChessSquare selection, int x, int y) { ChessMove moveType; @@ -13992,7 +13900,7 @@ DropMenuEvent(selection, x, y) } void -AcceptEvent() +AcceptEvent () { /* Accept a pending offer of any kind from opponent */ @@ -14017,7 +13925,7 @@ AcceptEvent() } void -DeclineEvent() +DeclineEvent () { /* Decline a pending offer of any kind from opponent */ @@ -14042,7 +13950,7 @@ DeclineEvent() } void -RematchEvent() +RematchEvent () { /* Issue ICS rematch command */ if (appData.icsActive) { @@ -14052,7 +13960,7 @@ RematchEvent() } void -CallFlagEvent() +CallFlagEvent () { /* Call your opponent's flag (claim a win on time) */ if (appData.icsActive) { @@ -14089,7 +13997,7 @@ CallFlagEvent() } void -ClockClick(int which) +ClockClick (int which) { // [HGM] code moved to back-end from winboard.c if(which) { // black clock if (gameMode == EditPosition || gameMode == IcsExamining) { @@ -14119,7 +14027,7 @@ ClockClick(int which) } void -DrawEvent() +DrawEvent () { /* Offer draw or accept pending draw offer from opponent */ @@ -14161,7 +14069,7 @@ DrawEvent() } void -AdjournEvent() +AdjournEvent () { /* Offer Adjourn or accept pending Adjourn offer from opponent */ @@ -14175,7 +14083,7 @@ AdjournEvent() void -AbortEvent() +AbortEvent () { /* Offer Abort or accept pending Abort offer from opponent */ @@ -14188,7 +14096,7 @@ AbortEvent() } void -ResignEvent() +ResignEvent () { /* Resign. You can do this even if it's not your turn. */ @@ -14222,7 +14130,7 @@ ResignEvent() void -StopObservingEvent() +StopObservingEvent () { /* Stop observing current games */ SendToICS(ics_prefix); @@ -14230,7 +14138,7 @@ StopObservingEvent() } void -StopExaminingEvent() +StopExaminingEvent () { /* Stop observing current game */ SendToICS(ics_prefix); @@ -14238,8 +14146,7 @@ StopExaminingEvent() } void -ForwardInner(target) - int target; +ForwardInner (int target) { int limit; @@ -14306,7 +14213,7 @@ ForwardInner(target) void -ForwardEvent() +ForwardEvent () { if (gameMode == IcsExamining && !pausing) { SendToICS(ics_prefix); @@ -14317,7 +14224,7 @@ ForwardEvent() } void -ToEndEvent() +ToEndEvent () { if (gameMode == AnalyzeMode || gameMode == AnalyzeFile) { /* to optimze, we temporarily turn off analysis mode while we feed @@ -14347,8 +14254,7 @@ ToEndEvent() } void -BackwardInner(target) - int target; +BackwardInner (int target) { int full_redraw = TRUE; /* [AS] Was FALSE, had to change it! */ @@ -14418,7 +14324,7 @@ BackwardInner(target) } void -BackwardEvent() +BackwardEvent () { if (gameMode == IcsExamining && !pausing) { SendToICS(ics_prefix); @@ -14429,7 +14335,7 @@ BackwardEvent() } void -ToStartEvent() +ToStartEvent () { if (gameMode == AnalyzeMode || gameMode == AnalyzeFile) { /* to optimize, we temporarily turn off analysis mode while we undo @@ -14458,7 +14364,7 @@ ToStartEvent() } void -ToNrEvent(int to) +ToNrEvent (int to) { if (gameMode == PlayFromGameFile && !pausing) PauseEvent(); if (to >= forwardMostMove) to = forwardMostMove; @@ -14471,7 +14377,7 @@ ToNrEvent(int to) } void -RevertEvent(Boolean annotate) +RevertEvent (Boolean annotate) { if(PopTail(annotate)) { // [HGM] vari: restore old game tail return; @@ -14489,7 +14395,7 @@ RevertEvent(Boolean annotate) } void -RetractMoveEvent() +RetractMoveEvent () { switch (gameMode) { case MachinePlaysWhite: @@ -14528,7 +14434,7 @@ RetractMoveEvent() } void -MoveNowEvent() +MoveNowEvent () { ChessProgramState *cps; @@ -14563,7 +14469,7 @@ MoveNowEvent() } void -TruncateGameEvent() +TruncateGameEvent () { EditGameEvent(); if (gameMode != EditGame) return; @@ -14571,7 +14477,7 @@ TruncateGameEvent() } void -TruncateGame() +TruncateGame () { CleanupTail(); // [HGM] vari: only keep current variation if we explicitly truncate if (forwardMostMove > currentMove) { @@ -14587,7 +14493,7 @@ TruncateGame() } void -HintEvent() +HintEvent () { if (appData.noChessProgram) return; switch (gameMode) { @@ -14613,7 +14519,7 @@ HintEvent() } void -BookEvent() +BookEvent () { if (appData.noChessProgram) return; switch (gameMode) { @@ -14644,7 +14550,7 @@ BookEvent() } void -AboutGameEvent() +AboutGameEvent () { char *tags = PGNTags(&gameInfo); TagsPopUp(tags, CmailMsg()); @@ -14654,9 +14560,7 @@ AboutGameEvent() /* end button procedures */ void -PrintPosition(fp, move) - FILE *fp; - int move; +PrintPosition (FILE *fp, int move) { int i, j; @@ -14674,8 +14578,7 @@ PrintPosition(fp, move) } void -PrintOpponents(fp) - FILE *fp; +PrintOpponents (FILE *fp) { if (gameInfo.white != NULL) { fprintf(fp, "\t%s vs. %s\n", gameInfo.white, gameInfo.black); @@ -14686,8 +14589,7 @@ PrintOpponents(fp) /* Find last component of program's own name, using some heuristics */ void -TidyProgramName(prog, host, buf) - char *prog, *host, buf[MSG_SIZ]; +TidyProgramName (char *prog, char *host, char buf[MSG_SIZ]) { char *p, *q; int local = (strcmp(host, "localhost") == 0); @@ -14716,7 +14618,7 @@ TidyProgramName(prog, host, buf) } char * -TimeControlTagValue() +TimeControlTagValue () { char buf[MSG_SIZ]; if (!appData.clockMode) { @@ -14732,7 +14634,7 @@ TimeControlTagValue() } void -SetGameInfo() +SetGameInfo () { /* This routine is used only for certain modes */ VariantClass v = gameInfo.variant; @@ -14830,9 +14732,7 @@ SetGameInfo() } void -ReplaceComment(index, text) - int index; - char *text; +ReplaceComment (int index, char *text) { int len; char *p; @@ -14873,8 +14773,7 @@ ReplaceComment(index, text) } void -CrushCRs(text) - char *text; +CrushCRs (char *text) { char *p = text; char *q = text; @@ -14888,10 +14787,8 @@ CrushCRs(text) } void -AppendComment(index, text, addBraces) - int index; - char *text; - Boolean addBraces; // [HGM] braces: tells if we should add {} +AppendComment (int index, char *text, Boolean addBraces) +/* addBraces tells if we should add {} */ { int oldlen, len; char *old; @@ -14938,7 +14835,8 @@ if(appData.debugMode) fprintf(debugFP, "Append: in='%s' %d\n", text, addBraces); } } -static char * FindStr( char * text, char * sub_text ) +static char * +FindStr (char * text, char * sub_text) { char * result = strstr( text, sub_text ); @@ -14951,7 +14849,8 @@ static char * FindStr( char * text, char * sub_text ) /* [AS] Try to extract PV info from PGN comment */ /* [HGM] PV time: and then remove it, to prevent it appearing twice */ -char *GetInfoFromComment( int index, char * text ) +char * +GetInfoFromComment (int index, char * text) { char * sep = text, *p; @@ -15046,9 +14945,7 @@ char *GetInfoFromComment( int index, char * text ) } void -SendToProgram(message, cps) - char *message; - ChessProgramState *cps; +SendToProgram (char *message, ChessProgramState *cps) { int count, outCount, error; char buf[MSG_SIZ]; @@ -15088,12 +14985,7 @@ SendToProgram(message, cps) } void -ReceiveFromProgram(isr, closure, message, count, error) - InputSourceRef isr; - VOIDSTAR closure; - char *message; - int count; - int error; +ReceiveFromProgram (InputSourceRef isr, VOIDSTAR closure, char *message, int count, int error) { char *end_str; char buf[MSG_SIZ]; @@ -15183,10 +15075,7 @@ ReceiveFromProgram(isr, closure, message, count, error) void -SendTimeControl(cps, mps, tc, inc, sd, st) - ChessProgramState *cps; - int mps, inc, sd, st; - long tc; +SendTimeControl (ChessProgramState *cps, int mps, long tc, int inc, int sd, int st) { char buf[MSG_SIZ]; int seconds; @@ -15250,7 +15139,8 @@ SendTimeControl(cps, mps, tc, inc, sd, st) } } -ChessProgramState *WhitePlayer() +ChessProgramState * +WhitePlayer () /* [HGM] return pointer to 'first' or 'second', depending on who plays white */ { if(gameMode == TwoMachinesPlay && first.twoMachinesColor[0] == 'b' || @@ -15260,9 +15150,7 @@ ChessProgramState *WhitePlayer() } void -SendTimeRemaining(cps, machineWhite) - ChessProgramState *cps; - int /*boolean*/ machineWhite; +SendTimeRemaining (ChessProgramState *cps, int machineWhite) { char message[MSG_SIZ]; long time, otime; @@ -15295,11 +15183,7 @@ SendTimeRemaining(cps, machineWhite) } int -BoolFeature(p, name, loc, cps) - char **p; - char *name; - int *loc; - ChessProgramState *cps; +BoolFeature (char **p, char *name, int *loc, ChessProgramState *cps) { char buf[MSG_SIZ]; int len = strlen(name); @@ -15319,11 +15203,7 @@ BoolFeature(p, name, loc, cps) } int -IntFeature(p, name, loc, cps) - char **p; - char *name; - int *loc; - ChessProgramState *cps; +IntFeature (char **p, char *name, int *loc, ChessProgramState *cps) { char buf[MSG_SIZ]; int len = strlen(name); @@ -15339,11 +15219,7 @@ IntFeature(p, name, loc, cps) } int -StringFeature(p, name, loc, cps) - char **p; - char *name; - char loc[]; - ChessProgramState *cps; +StringFeature (char **p, char *name, char loc[], ChessProgramState *cps) { char buf[MSG_SIZ]; int len = strlen(name); @@ -15361,7 +15237,7 @@ StringFeature(p, name, loc, cps) } int -ParseOption(Option *opt, ChessProgramState *cps) +ParseOption (Option *opt, ChessProgramState *cps) // [HGM] options: process the string that defines an engine option, and determine // name, type, default value, and allowed value range { @@ -15452,9 +15328,7 @@ ParseOption(Option *opt, ChessProgramState *cps) } void -FeatureDone(cps, val) - ChessProgramState* cps; - int val; +FeatureDone (ChessProgramState *cps, int val) { DelayedEventCallback cb = GetDelayedEvent(); if ((cb == InitBackEnd3 && cps == &first) || @@ -15469,9 +15343,7 @@ FeatureDone(cps, val) /* Parse feature command from engine */ void -ParseFeatures(args, cps) - char* args; - ChessProgramState *cps; +ParseFeatures (char *args, ChessProgramState *cps) { char *p = args; char *q; @@ -15563,8 +15435,7 @@ ParseFeatures(args, cps) } void -PeriodicUpdatesEvent(newState) - int newState; +PeriodicUpdatesEvent (int newState) { if (newState == appData.periodicUpdates) return; @@ -15582,8 +15453,7 @@ PeriodicUpdatesEvent(newState) } void -PonderNextMoveEvent(newState) - int newState; +PonderNextMoveEvent (int newState) { if (newState == appData.ponderNextMove) return; if (gameMode == EditPosition) EditPositionDone(TRUE); @@ -15603,9 +15473,7 @@ PonderNextMoveEvent(newState) } void -NewSettingEvent(option, feature, command, value) - char *command; - int option, value, *feature; +NewSettingEvent (int option, int *feature, char *command, int value) { char buf[MSG_SIZ]; @@ -15618,7 +15486,7 @@ NewSettingEvent(option, feature, command, value) } void -ShowThinkingEvent() +ShowThinkingEvent () // [HGM] thinking: this routine is now also called from "Options -> Engine..." popup { static int oldState = 2; // kludge alert! Neither true nor fals, so first time oldState is always updated @@ -15645,8 +15513,7 @@ ShowThinkingEvent() } void -AskQuestionEvent(title, question, replyPrefix, which) - char *title; char *question; char *replyPrefix; char *which; +AskQuestionEvent (char *title, char *question, char *replyPrefix, char *which) { ProcRef pr = (which[0] == '1') ? first.pr : second.pr; if (pr == NoProc) return; @@ -15654,7 +15521,7 @@ AskQuestionEvent(title, question, replyPrefix, which) } void -TypeInEvent(char firstChar) +TypeInEvent (char firstChar) { if ((gameMode == BeginningOfGame && !appData.icsActive) || gameMode == MachinePlaysWhite || gameMode == MachinePlaysBlack || @@ -15668,7 +15535,7 @@ TypeInEvent(char firstChar) } void -TypeInDoneEvent(char *move) +TypeInDoneEvent (char *move) { Board board; int n, fromX, fromY, toX, toY; @@ -15703,8 +15570,7 @@ TypeInDoneEvent(char *move) } void -DisplayMove(moveNumber) - int moveNumber; +DisplayMove (int moveNumber) { char message[MSG_SIZ]; char res[MSG_SIZ]; @@ -15761,9 +15627,7 @@ DisplayMove(moveNumber) } void -DisplayComment(moveNumber, text) - int moveNumber; - char *text; +DisplayComment (int moveNumber, char *text) { char title[MSG_SIZ]; @@ -15785,8 +15649,7 @@ DisplayComment(moveNumber, text) * ioctl, which does not work properly on some flavors of Unix. */ void -Attention(cps) - ChessProgramState *cps; +Attention (ChessProgramState *cps) { #if ATTENTION if (!cps->useSigint) return; @@ -15813,7 +15676,7 @@ Attention(cps) } int -CheckFlags() +CheckFlags () { if (whiteTimeRemaining <= 0) { if (!whiteFlag) { @@ -15863,7 +15726,7 @@ CheckFlags() } void -CheckTimeControl() +CheckTimeControl () { if (!appData.clockMode || appData.icsActive || searchTime || // [HGM] st: no inc in st mode gameMode == PlayFromGameFile || forwardMostMove == 0) return; @@ -15888,7 +15751,7 @@ CheckTimeControl() } void -DisplayBothClocks() +DisplayBothClocks () { int wom = gameMode == EditPosition ? !blackPlaysFirst : WhiteOnMove(currentMove); @@ -15910,8 +15773,7 @@ DisplayBothClocks() /* Get the current time as a TimeMark */ void -GetTimeMark(tm) - TimeMark *tm; +GetTimeMark (TimeMark *tm) { #if HAVE_GETTIMEOFDAY @@ -15943,8 +15805,7 @@ GetTimeMark(tm) time marks. We assume the difference will fit in a long! */ long -SubtractTimeMarks(tm2, tm1) - TimeMark *tm2, *tm1; +SubtractTimeMarks (TimeMark *tm2, TimeMark *tm1) { return 1000L*(tm2->sec - tm1->sec) + (long) (tm2->ms - tm1->ms); @@ -15965,8 +15826,7 @@ static TimeMark tickStartTM; static long intendedTickLength; long -NextTickLength(timeRemaining) - long timeRemaining; +NextTickLength (long timeRemaining) { long nominalTickLength, nextTickLength; @@ -15982,7 +15842,7 @@ NextTickLength(timeRemaining) /* Adjust clock one minute up or down */ void -AdjustClock(Boolean which, int dir) +AdjustClock (Boolean which, int dir) { if(appData.autoCallFlag) { DisplayError(_("Clock adjustment not allowed in auto-flag mode"), 0); return; } if(which) blackTimeRemaining += 60000*dir; @@ -15993,7 +15853,7 @@ AdjustClock(Boolean which, int dir) /* Stop clocks and reset to a fresh time control */ void -ResetClocks() +ResetClocks () { (void) StopClockTimer(); if (appData.icsActive) { @@ -16019,7 +15879,7 @@ ResetClocks() /* Decrement running clock by amount of time that has passed */ void -DecrementClocks() +DecrementClocks () { long timeRemaining; long lastTickLength, fudge; @@ -16099,7 +15959,7 @@ DecrementClocks() from the color that is *not* on move now. */ void -SwitchClocks(int newMoveNr) +SwitchClocks (int newMoveNr) { long lastTickLength; TimeMark now; @@ -16162,7 +16022,7 @@ SwitchClocks(int newMoveNr) /* Stop both clocks */ void -StopClocks() +StopClocks () { long lastTickLength; TimeMark now; @@ -16188,7 +16048,7 @@ StopClocks() /* Start clock of player on move. Time may have been reset, so if clock is already running, stop and restart it. */ void -StartClocks() +StartClocks () { (void) StopClockTimer(); /* in case it was running already */ DisplayBothClocks(); @@ -16219,8 +16079,7 @@ StartClocks() } char * -TimeString(ms) - long ms; +TimeString (long ms) { long second, minute, hour, day; char *sign = ""; @@ -16267,8 +16126,7 @@ TimeString(ms) * This is necessary because some C libraries aren't ANSI C compliant yet. */ char * -StrStr(string, match) - char *string, *match; +StrStr (char *string, char *match) { int i, length; @@ -16282,8 +16140,7 @@ StrStr(string, match) } char * -StrCaseStr(string, match) - char *string, *match; +StrCaseStr (char *string, char *match) { int i, j, length; @@ -16302,8 +16159,7 @@ StrCaseStr(string, match) #ifndef _amigados int -StrCaseCmp(s1, s2) - char *s1, *s2; +StrCaseCmp (char *s1, char *s2) { char c1, c2; @@ -16318,24 +16174,21 @@ StrCaseCmp(s1, s2) int -ToLower(c) - int c; +ToLower (int c) { return isupper(c) ? tolower(c) : c; } int -ToUpper(c) - int c; +ToUpper (int c) { return islower(c) ? toupper(c) : c; } #endif /* !_amigados */ char * -StrSave(s) - char *s; +StrSave (char *s) { char *ret; @@ -16347,8 +16200,7 @@ StrSave(s) } char * -StrSavePtr(s, savePtr) - char *s, **savePtr; +StrSavePtr (char *s, char **savePtr) { if (*savePtr) { free(*savePtr); @@ -16360,7 +16212,7 @@ StrSavePtr(s, savePtr) } char * -PGNDate() +PGNDate () { time_t clock; struct tm *tm; @@ -16375,9 +16227,7 @@ PGNDate() char * -PositionToFEN(move, overrideCastling) - int move; - char *overrideCastling; +PositionToFEN (int move, char *overrideCastling) { int i, j, fromX, fromY, toX, toY; int whiteToPlay; @@ -16545,10 +16395,7 @@ PositionToFEN(move, overrideCastling) } Boolean -ParseFEN(board, blackPlaysFirst, fen) - Board board; - int *blackPlaysFirst; - char *fen; +ParseFEN (Board board, int *blackPlaysFirst, char *fen) { int i, j; char *p, c; @@ -16788,7 +16635,7 @@ ParseFEN(board, blackPlaysFirst, fen) } void -EditPositionPasteFEN(char *fen) +EditPositionPasteFEN (char *fen) { if (fen != NULL) { Board initial_position; @@ -16811,7 +16658,8 @@ EditPositionPasteFEN(char *fen) static char cseq[12] = "\\ "; -Boolean set_cont_sequence(char *new_seq) +Boolean +set_cont_sequence (char *new_seq) { int len; Boolean ret; @@ -16836,7 +16684,8 @@ Boolean set_cont_sequence(char *new_seq) for the dest buffer. lp argument indicats line position upon entry, and it's passed back upon exit. */ -int wrap(char *dest, char *src, int count, int width, int *lp) +int +wrap (char *dest, char *src, int count, int width, int *lp) { int len, i, ansi, cseq_len, line, old_line, old_i, old_len, clen; @@ -16920,7 +16769,7 @@ int wrap(char *dest, char *src, int count, int width, int *lp) Boolean modeRestore = FALSE; void -PushInner(int firstMove, int lastMove) +PushInner (int firstMove, int lastMove) { int i, j, nrMoves = lastMove - firstMove; @@ -16951,7 +16800,7 @@ PushInner(int firstMove, int lastMove) } void -PushTail(int firstMove, int lastMove) +PushTail (int firstMove, int lastMove) { if(appData.icsActive) { // only in local mode forwardMostMove = currentMove; // mimic old ICS behavior @@ -16965,7 +16814,7 @@ PushTail(int firstMove, int lastMove) } void -PopInner(Boolean annotate) +PopInner (Boolean annotate) { int i, j, nrMoves; char buf[8000], moveBuf[20]; @@ -17012,7 +16861,7 @@ PopInner(Boolean annotate) } Boolean -PopTail(Boolean annotate) +PopTail (Boolean annotate) { if(appData.icsActive) return FALSE; // only in local mode if(!storedGames) return FALSE; // sanity @@ -17027,7 +16876,7 @@ PopTail(Boolean annotate) } void -CleanupTail() +CleanupTail () { // remove all shelved variations int i; for(i=0; i