New item "Upload to Examin" in Action menu, calls UploadGameEvent().
Use SAN moves to upload game to ICS, rather than long algebraic
(The ICS did not understand long-algebraic promotion moves)
Use bsetup within examine to set position onFICS, and also variant.
Castling rights do not work yet for FRC. Totally different set of
commands are needed on FICS and ICC.
FICS does not understand w23 or wild/23, but needs 'crazyhouse' in the
besetup command that specifies the variant. XBoard variant names are
used, except for fischerandom, which is 'fr'. Things like nocastle will
probably still not work.
}
void
+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" };
+ if(gameMode == IcsObserving || gameMode == IcsPlayingBlack || gameMode == IcsPlayingWhite) {
+ DisplayError("You cannot do this while you are playing or observing", 0);
+ return;
+ }
+ if(gameMode != IcsExamining) { // is this ever not the case?
+ char buf[MSG_SIZ], *p, *fen, command[MSG_SIZ], bsetup = 0;
+
+ if(ics_type == ICS_ICC) { // on ICC match ourselves in applicable variant
+ sprintf(command, "match %s", ics_handle);
+ } else { // on FICS we must first go to general examine mode
+ strcpy(command, "examine\nbsetup"); // and specify variant within it with bsetups
+ }
+ if(gameInfo.variant != VariantNormal) {
+ // try figure out wild number, as xboard names are not always valid on ICS
+ for(i=1; i<=36; i++) {
+ sprintf(buf, "wild/%d", i);
+ if(StringToVariant(buf) == gameInfo.variant) break;
+ }
+ if(i<=36 && ics_type == ICS_ICC) sprintf(buf, "%s w%d\n", command, i);
+ else if(i == 22) sprintf(buf, "%s fr\n", command);
+ else sprintf(buf, "%s %s\n", command, VariantName(gameInfo.variant));
+ } else sprintf(buf, "%s\n", ics_type == ICS_ICC ? command : "examine\n"); // match yourself or examine
+ SendToICS(ics_prefix);
+ SendToICS(buf);
+ if(startedFromSetupPosition || backwardMostMove != 0) {
+ fen = PositionToFEN(backwardMostMove, NULL);
+ if(ics_type == ICS_ICC) { // on ICC we can simply send a complete FEN to set everything
+ sprintf(buf, "loadfen %s\n", fen);
+ SendToICS(buf);
+ } else { // FICS: everything has to set by separate bsetup commands
+ p = strchr(fen, ' '); p[0] = NULLCHAR; // cut after board
+ sprintf(buf, "bsetup fen %s\n", fen);
+ SendToICS(buf);
+ if(!WhiteOnMove(backwardMostMove)) {
+ SendToICS("bsetup tomove black\n");
+ }
+ i = (strchr(p+3, 'K') != NULL) + 2*(strchr(p+3, 'Q') != NULL);
+ sprintf(buf, "bsetup wcastle %s\n", castlingStrings[i]);
+ SendToICS(buf);
+ i = (strchr(p+3, 'k') != NULL) + 2*(strchr(p+3, 'q') != NULL);
+ sprintf(buf, "bsetup bcastle %s\n", castlingStrings[i]);
+ SendToICS(buf);
+ i = boards[backwardMostMove][EP_STATUS];
+ if(i >= 0) { // set e.p.
+ sprintf(buf, "bsetup eppos %c\n", i+AAA);
+ SendToICS(buf);
+ }
+ bsetup++;
+ }
+ }
+ if(bsetup || ics_type != ICS_ICC && gameInfo.variant != VariantNormal)
+ SendToICS("bsetup done\n"); // switch to normal examining.
+ }
+ for(i = backwardMostMove; i<last; i++) {
+ char buf[20];
+ sprintf(buf, "%s\n", parseList[i]);
+ SendToICS(buf);
+ }
+ SendToICS(ics_prefix);
+ SendToICS(ics_type == ICS_ICC ? "tag result Game in progress\n" : "commit\n");
+}
+
+void
CoordsToComputerAlgebraic(rf, ff, rt, ft, promoChar, move)
int rf, ff, rt, ft;
char promoChar;
void AnalysisPeriodicEvent P((int force));
void SetWhiteToPlayEvent P((void));
void SetBlackToPlayEvent P((void));
+void UploadGameEvent P((void));
void InitBackEnd1 P((void));
void InitBackEnd2 P((void));
int HasPromotionChoice P((int fromX, int fromY, int toX, int toY, char *choice));
#define IDM_TruncateGame 158\r
#define IDM_MoveNow 159\r
#define IDM_RetractMove 160\r
+#define IDM_Upload 161\r
#define IDM_MailMove 164\r
#define IDM_ReloadCMailMsg 165\r
#define IDM_Book 166\r
StopExaminingEvent();\r
break;\r
\r
+ case IDM_Upload:\r
+ UploadGameEvent();\r
+ break;\r
+\r
case IDM_TypeInMove:\r
PopUpMoveDialog('\000');\r
break;\r
{ IDM_Adjourn, MF_BYCOMMAND|MF_GRAYED },\r
{ IDM_StopExamining, MF_BYCOMMAND|MF_GRAYED },\r
{ IDM_StopObserving, MF_BYCOMMAND|MF_GRAYED },\r
+ { IDM_Upload, MF_BYCOMMAND|MF_GRAYED },\r
{ IDM_Revert, MF_BYCOMMAND|MF_GRAYED },\r
{ IDM_NewChat, MF_BYCOMMAND|MF_GRAYED },\r
{ -1, -1 }\r
MENUITEM SEPARATOR\r
MENUITEM "Stop &Observing\tF10", IDM_StopObserving\r
MENUITEM "Stop E&xamining\tF11", IDM_StopExamining\r
+ MENUITEM "&Upload to Examine", IDM_Upload\r
MENUITEM SEPARATOR\r
MENUITEM "Adjudicate to &White", IDM_UserAdjudication_White\r
MENUITEM "Adjudicate to &Black", IDM_UserAdjudication_Black\r
Cardinal *nprms));
void StopExaminingProc P((Widget w, XEvent *event, String *prms,
Cardinal *nprms));
+void UploadProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
void BackwardProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
void ForwardProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
void ToStartProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
{"----", NothingProc},
{N_("Stop Observing"), StopObservingProc},
{N_("Stop Examining"), StopExaminingProc},
+ {N_("Upload to Examine"), UploadProc},
{"----", NothingProc},
{N_("Adjudicate to White"), AdjuWhiteProc},
{N_("Adjudicate to Black"), AdjuBlackProc},
{ "DownKeyProc", DownKeyProc },
{ "StopObservingProc", StopObservingProc },
{ "StopExaminingProc", StopExaminingProc },
+ { "UploadProc", UploadProc },
{ "BackwardProc", BackwardProc },
{ "ForwardProc", ForwardProc },
{ "ToStartProc", ToStartProc },
{ "menuAction.Adjourn", False },
{ "menuAction.Stop Examining", False },
{ "menuAction.Stop Observing", False },
+ { "menuAction.Upload to Examine", False },
{ "menuStep.Revert", False },
{ "menuOptions.Auto Comment", False },
{ "menuOptions.Auto Observe", False },
StopExaminingEvent();
}
+void UploadProc(w, event, prms, nprms)
+ Widget w;
+ XEvent *event;
+ String *prms;
+ Cardinal *nprms;
+{
+ UploadGameEvent();
+}
+
void ForwardProc(w, event, prms, nprms)
Widget w;