Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6358075
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:17:53+00:00 2026-05-24T23:17:53+00:00

This is openFrameworks C++ code. It’s saving information about each move made in a

  • 0

This is openFrameworks C++ code. It’s saving information about each move made in a game, but each new game wipes out all of the values inside <MOVE> <PLAYER/> <MOVE/> for any previous <GAME><GAME/> tags.

bool My_xml::setup() {
  XML.loadFile(ofxiPhoneGetDocumentsDirectory() + "scoresAndSettings.xml")

  //read the settings from XML
  //if the settings file doesn't exist we assign default values

  globalsettings.user_id = XML.getValue("GLOBALSETTINGS:USERID", ofRandom(std::numeric_limits<float>::max() - 1));
  if (globalsettings.user_id == 0) { // for first game only
    XML.setValue("GLOBALSETTINGS:USERID", globalsettings.user_id);
  }
  globalsettings.playing_big_board = XML.getValue("GLOBALSETTINGS:BIGBOARD", false);
  globalsettings.drawCrossHairs = XML.getValue("GLOBALSETTINGS:DRAWCROSSHAIRS", false);
  globalsettings.graphFFT = XML.getValue("GLOBALSETTINGS:GRAPHFFT", true); //
  globalsettings.showDebugText = XML.getValue("GLOBALSETTINGS:SHOWDEBUGTEXT", false);

  gameNumber = XML.addTag("GAME");
  XML.setAttribute("GAME", "number", gameNumber+1, gameNumber);
  XML.setAttribute("GAME", "start", makeTimeStamp(), gameNumber);
  XML.pushTag("GAME", gameNumber);

  return true;
}

void My_xml::saveMoveInfo() {
  int moveNumber    = XML.addTag("MOVE");
  if( XML.pushTag("MOVE", moveNumber) ){
    // put in data from this move
    int player = ((testApp*)ofGetAppPtr())->gameplay->whoseTurnIsIt;
    string playerTag = "PLAYER " + ofToString(player);
    int tagNum = XML.addTag(playerTag);
    XML.addAttribute(playerTag, "move", moveNumber++, tagNum);
    XML.addAttribute(playerTag, "duration", lastMoveDuration, tagNum);
    XML.addAttribute(playerTag, "wait", waitBeforeThisMove, tagNum);
    XML.addAttribute(playerTag, "timestamp", makeTimeStamp(), tagNum);
    XML.popTag();
  }

  XML.saveFile( ofxiPhoneGetDocumentsDirectory() + "scoresAndSettings.xml" );
}

void My_xml::winGame() {
  writeToFile();
}

void My_xml::writeToFile() {
  XML.popTag();
  XML.setAttribute("GAME", "lat", ofToString(coreLocation->getLatitude(), 10), gameNumber);
  XML.setAttribute("GAME", "long", ofToString(coreLocation->getLongitude(), 10), gameNumber);
  XML.setAttribute("GAME", "end", makeTimeStamp(), gameNumber);
  XML.saveFile( ofxiPhoneGetDocumentsDirectory() + "scoresAndSettings.xml" );
}

EDIT/Addition: This code, which stores calibration data, doesn’t get overwritten/cleared/eaten each game.

  if (animations->training != NOT_TRAINING) {
    int numGameTags = XML.XML.getNumTags("GAME");
    XML.XML.pushTag("GAME", numGameTags-1);
    int moveNumber  = XML.XML.addTag("CALIBRATION");

    if (gameplay->whoseTurnIsIt < 2) { // PLAYER 1
      switch (animations->training) {
        case TRAINING_UP:
          XML.player1settings.pitch_high = gameplay->high_pitch_thresh;
          XML.XML.setAttribute("CALIBRATION", "player", gameplay->whoseTurnIsIt, moveNumber);
          XML.XML.setAttribute("CALIBRATION", "type", "pitch", moveNumber);
          XML.XML.setAttribute("CALIBRATION", "level", "high", moveNumber);
          XML.XML.setValue("CALIBRATION", gameplay->high_pitch_thresh, moveNumber);
          break;
        // etc.
        default:
          break;
      } 
    } else { // PLAYER 2
      switch (animations->training) {
        case TRAINING_UP:
          XML.player2settings.pitch_high = gameplay->high_pitch_thresh;
          XML.XML.setAttribute("CALIBRATION", "player", gameplay->whoseTurnIsIt, moveNumber);
          XML.XML.setAttribute("CALIBRATION", "type", "pitch", moveNumber);
          XML.XML.setAttribute("CALIBRATION", "level", "high", moveNumber);
          XML.XML.setValue("CALIBRATION", gameplay->high_pitch_thresh, moveNumber);
          break;
        // etc.
        default:
          break;
      } // end switch
    } // end else
    XML.XML.popTag();
  }

EDIT 2:
I just noticed that the XML tags are actually being altered, not just having the contents removed. Note that the tag is <PLAYER 1> or <PLAYER 2> in the most recent game, but just <PLAYER /> in all the old data…

<GAME number="3" start="2011-08-19|16:00:59|2.7" lat="51.38325077" long="-2.36163312" end="2011-08-19|16:01:29|32.8">
    <PLAYER />
</GAME>
<GAME number="4" start="2011-08-19|16:14:12|2.6">
    <PLAYER />
</GAME>
<GAME number="5" start="2011-08-19|16:16:10|2.9">
    <PLAYER 1 col="0" row="2" err="0" move="1" duration="0.012999" wait="19.784000" timestamp="2011-08-19|16:16:30|22.8"></PLAYER 1>
    <PLAYER 2 col="0" row="2" err="-2" move="1" duration="0.219000" wait="1.605001" timestamp="2011-08-19|16:16:32|24.6"></PLAYER 2>
    <PLAYER 2 col="0" row="2" err="-2" move="2" duration="0.226000" wait="1.500000" timestamp="2011-08-19|16:16:34|26.4"></PLAYER 2>
</GAME>

EDIT3: Aaaaand that’s it. No spaces in a tag name. Sheesh.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T23:17:55+00:00Added an answer on May 24, 2026 at 11:17 pm

    XML tags can’t have spaces in them.

    <PLAYER 1> tags were getting eaten when the file was reopened, regardless of whatever my code was doing to it.

    <PLAYER1> is fine, and fixes the problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a normalization thing, but I want I have to hold information about
Okay this one may be a bit out from left field, but I'm going
This is a sort of trivial question but something I've been wondering about. In
This is my code: OleDbConnection connection = new OleDbConnection( Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\\Offline.accdb;Persist Security Info=False); connection.Open();
This is probably pretty subjective, but how do people generally lay out their loop
This is kind of simple (I know) but yet I cant figure it out.
This is a bit of a long shot, but if anyone can figure it
This is starting to vex me. I recently decided to clear out my FTP,
This is kinda oddball, but I was poking around with the GNU assembler today
This might seem like a stupid question I admit. But I'm in a small

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.