Using constants for save and config filenames.

This commit is contained in:
Steve 2016-04-11 08:44:36 +01:00
parent 476308175c
commit 8e6fcf81fa
5 changed files with 9 additions and 6 deletions

View File

@ -39,6 +39,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define TO_RAIDANS(angleDegrees) (angleDegrees * PI / 180.0)
#define TO_DEGREES(angleRadians) (angleRadians * 180.0 / PI)
#define SAVE_FILENAME "game.save"
#define CONFIG_FILENAME "config.json"
#define SCREEN_WIDTH 1280
#define SCREEN_HEIGHT 720

View File

@ -183,7 +183,7 @@ static void handleArguments(int argc, char *argv[])
if (!testingMission)
{
if (fileExists(getSaveFilePath("game.save")))
if (fileExists(getSaveFilePath(SAVE_FILENAME)))
{
loadGame();
}

View File

@ -207,7 +207,7 @@ static void loadConfig(void)
cJSON *root, *controlsJSON, *node;
char *text, *configFilename;
configFilename = getSaveFilePath("config.json");
configFilename = getSaveFilePath(CONFIG_FILENAME);
if (fileExists(configFilename))
{
@ -215,7 +215,7 @@ static void loadConfig(void)
}
else
{
text = readFile("data/app/config.json");
text = readFile("data/app/"CONFIG_FILENAME);
}
root = cJSON_Parse(text);
@ -263,7 +263,7 @@ void saveConfig(void)
char *out, *configFilename;
cJSON *root, *controlsJSON, *keysJSON, *mouseJSON;
configFilename = getSaveFilePath("config.json");
configFilename = getSaveFilePath(CONFIG_FILENAME);
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, "Saving config ...");

View File

@ -30,7 +30,7 @@ void loadGame(void)
cJSON *root, *gameJSON;
char *text;
text = readFile(getSaveFilePath("game.save"));
text = readFile(getSaveFilePath(SAVE_FILENAME));
root = cJSON_Parse(text);
gameJSON = cJSON_GetObjectItem(root, "game");

View File

@ -46,7 +46,7 @@ void saveGame(void)
out = cJSON_Print(root);
writeFile(getSaveFilePath("game.save"), out);
writeFile(getSaveFilePath(SAVE_FILENAME), out);
cJSON_Delete(root);
free(out);