/* * traverses the tree from move 't', and stores SGF code into 'stream' */ void SGFParser::traverse(Move *t, GameData *gameData) { QString txt; *stream << "("; int col = -1, cnt = 6; do { if (isRoot) { writeGameHeader(gameData); txt = t->saveMove(isRoot).toUtf8(); //utf8 might only be necessary if gameData->codec is set, but should be okay either way *stream << txt; isRoot = false; } else { // do some formatting: add single B[]/W[] properties to one line, max: 10 // if more properties, e.g. B[]PL[]C] -> new line txt = t->saveMove(false).toUtf8(); if(txt == ";") //don't save empty nodes txt = ""; int cnt_old = cnt; cnt = txt.length(); if (col % 10 == 0 || (col == 1 && cnt != 6) || cnt_old != 6 || col == -1) { *stream << endl; col = 0; } *stream << txt; col++; } Move *tmp = t->son; if (tmp != NULL && tmp->brother != NULL) { do { *stream << endl; traverse(tmp, NULL); } while ((tmp = tmp->brother) != NULL); break; } } while ((t = t->son) != NULL); *stream << endl << ")"; }
void SGFParser::traverse(Move *t, GameData *gameData) { *stream << "("; int col = -1, cnt = 6; do { if (isRoot) { writeGameHeader(gameData); *stream << t->saveMove(isRoot); isRoot = false; } else { // do some formatting: add single B[]/W[] properties to one line, max: 10 // if more properties, e.g. B[]PL[]C] -> new line QString txt = t->saveMove(false); int cnt_old = cnt; cnt = txt.length(); if (col % 10 == 0 || col == 1 && cnt != 6 || cnt_old != 6 || col == -1) { *stream << endl; col = 0; } *stream << txt; col++; } Move *tmp = t->son; if (tmp != NULL && tmp->brother != NULL) { do { *stream << endl; traverse(tmp, NULL); } while ((tmp = tmp->brother) != NULL); break; } } while ((t = t->son) != NULL); *stream << endl << ")"; }