Hi everybody,
I am facing the following problem with the new libfat 1.0.2 library.
For some unknown reason sometimes a file (highscore.xml) stored on the SD(HC) card is not found during start up of my game. The previous version of libfat did not have this problem. Do anybody know a solution for this issue.
Sample code
void loadHighScoreFile(char* filename)
{
int i;
FILE *fp;
mxml_node_t *tree=NULL;
mxml_node_t *data=NULL;
const char *tmp;
char temp[100];
/*Load our xml file! */
fp = fopen(filename, "r");
if (fp!=NULL)
{
tree = mxmlLoadFile(NULL, fp, MXML_NO_CALLBACK);
fclose(fp);
for(i=0; i<=MAX_LEVEL; i++)
{
sprintf(temp, "level%d", i);
data = mxmlFindElement(tree, tree, temp, NULL, NULL, MXML_DESCEND);
tmp=mxmlElementGetAttr(data,"localTime");
if (tmp!=NULL) highscores
.localTime=atoi(tmp); else highscores.localTime=0;
tmp=mxmlElementGetAttr(data,"levelTime");
if (tmp!=NULL) highscores.levelTime=atoi(tmp); else highscores.levelTime=0;
tmp=mxmlElementGetAttr(data,"player1Score");
if (tmp!=NULL) highscores.player1Score=atoi(tmp); else highscores.player1Score=0;
tmp=mxmlElementGetAttr(data,"player2Score");
if (tmp!=NULL) highscores.player2Score=atoi(tmp); else highscores.player2Score=0;
}
}
else
{
// If file not found, create empty highscore list.
for(i=0; i<=MAX_LEVEL; i++)
{
highscores.localTime=0;
highscores.levelTime=0;
highscores.player1Score=0;
highscores.player2Score=0;
}
}
mxmlDelete(data);
mxmlDelete(tree);
}
wplaat
Edited 1 time(s). Last edit at 12/25/2008 02:23PM by wplaat.