Using constants for save and config filenames.
This commit is contained in:
parent
476308175c
commit
8e6fcf81fa
|
@ -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_RAIDANS(angleDegrees) (angleDegrees * PI / 180.0)
|
||||||
#define TO_DEGREES(angleRadians) (angleRadians * 180.0 / PI)
|
#define TO_DEGREES(angleRadians) (angleRadians * 180.0 / PI)
|
||||||
|
|
||||||
|
#define SAVE_FILENAME "game.save"
|
||||||
|
#define CONFIG_FILENAME "config.json"
|
||||||
|
|
||||||
#define SCREEN_WIDTH 1280
|
#define SCREEN_WIDTH 1280
|
||||||
#define SCREEN_HEIGHT 720
|
#define SCREEN_HEIGHT 720
|
||||||
|
|
||||||
|
|
|
@ -183,7 +183,7 @@ static void handleArguments(int argc, char *argv[])
|
||||||
|
|
||||||
if (!testingMission)
|
if (!testingMission)
|
||||||
{
|
{
|
||||||
if (fileExists(getSaveFilePath("game.save")))
|
if (fileExists(getSaveFilePath(SAVE_FILENAME)))
|
||||||
{
|
{
|
||||||
loadGame();
|
loadGame();
|
||||||
}
|
}
|
||||||
|
|
|
@ -207,7 +207,7 @@ static void loadConfig(void)
|
||||||
cJSON *root, *controlsJSON, *node;
|
cJSON *root, *controlsJSON, *node;
|
||||||
char *text, *configFilename;
|
char *text, *configFilename;
|
||||||
|
|
||||||
configFilename = getSaveFilePath("config.json");
|
configFilename = getSaveFilePath(CONFIG_FILENAME);
|
||||||
|
|
||||||
if (fileExists(configFilename))
|
if (fileExists(configFilename))
|
||||||
{
|
{
|
||||||
|
@ -215,7 +215,7 @@ static void loadConfig(void)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
text = readFile("data/app/config.json");
|
text = readFile("data/app/"CONFIG_FILENAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
root = cJSON_Parse(text);
|
root = cJSON_Parse(text);
|
||||||
|
@ -263,7 +263,7 @@ void saveConfig(void)
|
||||||
char *out, *configFilename;
|
char *out, *configFilename;
|
||||||
cJSON *root, *controlsJSON, *keysJSON, *mouseJSON;
|
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 ...");
|
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, "Saving config ...");
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ void loadGame(void)
|
||||||
cJSON *root, *gameJSON;
|
cJSON *root, *gameJSON;
|
||||||
char *text;
|
char *text;
|
||||||
|
|
||||||
text = readFile(getSaveFilePath("game.save"));
|
text = readFile(getSaveFilePath(SAVE_FILENAME));
|
||||||
root = cJSON_Parse(text);
|
root = cJSON_Parse(text);
|
||||||
|
|
||||||
gameJSON = cJSON_GetObjectItem(root, "game");
|
gameJSON = cJSON_GetObjectItem(root, "game");
|
||||||
|
|
|
@ -46,7 +46,7 @@ void saveGame(void)
|
||||||
|
|
||||||
out = cJSON_Print(root);
|
out = cJSON_Print(root);
|
||||||
|
|
||||||
writeFile(getSaveFilePath("game.save"), out);
|
writeFile(getSaveFilePath(SAVE_FILENAME), out);
|
||||||
|
|
||||||
cJSON_Delete(root);
|
cJSON_Delete(root);
|
||||||
free(out);
|
free(out);
|
||||||
|
|
Loading…
Reference in New Issue