diff --git a/main.cpp b/main.cpp index 744fd99..b333d57 100644 --- a/main.cpp +++ b/main.cpp @@ -161,13 +161,13 @@ void gameOver(int score){ printf("Input your name (without spaces!) and press ENTER to return to main menu."); SetCursorPosition((paMaxX/2)-19,(paMaxY/2)+6); printf("Enter you name: "); - //Save player scores at $HOME/.config/cursedSnakeGameScores + //Save player scores at $HOME/.local/share/cursedSnakeGameScores FILE *cmd=popen("echo -n $HOME", "r"); char result[100]={0x0}; fgets(result, sizeof(result), cmd); pclose(cmd); string fullpath=result; - fullpath+="/.config/cursedSnakeGameScores"; + fullpath+="/.local/share/cursedSnakeGameScores"; FILE *fptr = fopen(fullpath.c_str(),"a"); if (fptr == NULL) @@ -306,7 +306,8 @@ int mainMenu() { void showScores() { endwin(); - system("sort $HOME/.config/cursedSnakeGameScores -nr > $HOME/.config/cursedSnakeGameScores.tmp && mv $HOME/.config/cursedSnakeGameScores.tmp $HOME/.config/cursedSnakeGameScores"); + system("if [[ ! -f $HOME/.local/share/cursedSnakeGameScores ]]; then touch $HOME/.local/share/cursedSnakeGameScores; fi"); + system("sort $HOME/.local/share/cursedSnakeGameScores -nr > $HOME/.local/share/cursedSnakeGameScores.tmp && mv $HOME/.local/share/cursedSnakeGameScores.tmp $HOME/.local/share/cursedSnakeGameScores"); int line=0,currentLine=0; char c; //UserInputCharacter FILE *cmd=popen("echo -n $HOME", "r"); @@ -314,11 +315,13 @@ void showScores() { fgets(result, sizeof(result), cmd); pclose(cmd); string fullpath=result; - fullpath+="/.config/cursedSnakeGameScores"; + fullpath+="/.local/share/cursedSnakeGameScores"; FILE *fptr = fopen(fullpath.c_str(),"r"); if(fptr == NULL) { - perror("Error in opening file"); + perror("Error in opening file, creating data file."); + system("touch $HOME/.local/share/cursedSnakeGameScores"); + sleep(3); return; } do {