void qGoBoardNetworkInterface::slotSendComment() { QString our_name = boardwindow->getBoardDispatch()->getUsername(); boardwindow->getBoardDispatch()->sendKibitz(boardwindow->getUi()->commentEdit2->text()); // why isn't this added to SGF files?? FIXME // qGoBoard::kibitzReceived has the code for adding this // to the tree and thus to the file, but we shouldn't // be calling same code from two different places, so the whole // thing should be fixed up. /* Its also ugly adding this to the sgf comments both here and in kibitzRecieved FIXME */ QString ourcomment; QString txt = tree->getCurrent()->getComment(); bool prepend_with_movenumber = false; if(stated_mv_count != tree->findLastMoveInMainBranch()->getMoveNumber()) { stated_mv_count = tree->findLastMoveInMainBranch()->getMoveNumber(); prepend_with_movenumber = true; } ourcomment = our_name + "[" + boardwindow->getBoardDispatch()->getOurRank() + "]: " + boardwindow->getUi()->commentEdit2->text(); if (boardwindow->getUi()->commentEdit2->text().isEmpty()) ourcomment.append('\n'); if(boardwindow->getGamePhase() != phaseEnded) txt.append(ourcomment); tree->getCurrent()->setComment(txt); /* Kibitz echoes from self are blocked in network code */ if(prepend_with_movenumber) ourcomment.prepend( "(" + QString::number(getMoveNumber()) + ") "); boardwindow->getUi()->commentEdit->append(ourcomment); boardwindow->getUi()->commentEdit2->clear(); }
pgn::Move* pgn::Parser::getMove(std::string::const_iterator &itr1, const std::string::const_iterator &itr2) { std::string::const_iterator local_itr = itr1; // looking for move number std::string movenumber; int dotsCount; if (! getMoveNumber(local_itr, itr2, movenumber, dotsCount)) return 0; itr1 = local_itr; // possibilita`: // // <move_number><dots> <ply> <result> // <move_number><dots> <ply> <move_number> // <move_number><dots> <ply> <ply> <result> // <move_number><dots> <ply> <ply> <move_number> // looking for first ply (mandatory) skipBlanks(local_itr, itr2); pgn::Ply *firstPly=0; if ((firstPly = getPly(local_itr, itr2)) == 0) throw std::runtime_error("Error parsing move"); skipBlanks(local_itr, itr2); pgn::Ply *secondPly=0; // second ply, game result or another move number? // a ply always begins with an uppercase or lowercase alphabetic char. // digits and '*' have lesser ascii values. // if we meet a "[" that's owned by the next game, so game result is // missing if (*local_itr > '9' && *local_itr != '[') { // looking for second ply (optional) secondPly = getPly(local_itr, itr2); skipBlanks(local_itr, itr2); } itr1 = local_itr; pgn::Move *m = new pgn::Move(firstPly, secondPly, atoi(movenumber.c_str())); delete firstPly; delete secondPly; moveCount_++; return m; }
extern void CommandExportPositionText(char *sz) { FILE *pf; int fHistory; moverecord *pmr; int iMove; GString *gsz; sz = NextToken(&sz); if (ms.gs == GAME_NONE) { outputl(_("No game in progress (type `new game' to start one).")); return; } if (!sz || !*sz) { outputl(_("You must specify a file to export to (see `help export " "position text').")); return; } pmr = get_current_moverecord(&fHistory); if (!confirmOverwrite(sz, fConfirmSave)) return; if (!strcmp(sz, "-")) pf = stdout; else if ((pf = g_fopen(sz, "w")) == 0) { outputerr(sz); return; } gsz = g_string_new(NULL); TextPrologue(gsz, &ms, getGameNumber(plGame)); fputs(gsz->str, pf); g_string_free(gsz, TRUE); if (exsExport.fIncludeMatchInfo) TextMatchInfo(pf, &mi); if (fHistory) iMove = getMoveNumber(plGame, pmr) - 1; else if (plLastMove) iMove = getMoveNumber(plGame, plLastMove->p); else iMove = -1; gsz = g_string_new(NULL); TextBoardHeader(gsz, &ms, getGameNumber(plGame), iMove); fputs(gsz->str, pf); g_string_free(gsz, TRUE); printTextBoard(pf, &ms); if (pmr) { gsz = g_string_new(NULL); TextAnalysis(gsz, &ms, pmr); fputs(gsz->str, pf); g_string_free(gsz, TRUE); if (exsExport.fIncludeAnnotation) TextPrintComment(pf, pmr); } TextEpilogue(pf, &ms); if (pf != stdout) fclose(pf); setDefaultFileName(sz); }