From 9825e39f4fe28597f02ed5364e7fe6aab380d3ba Mon Sep 17 00:00:00 2001 From: Steve Date: Thu, 3 Dec 2015 08:43:26 +0000 Subject: [PATCH] Install path bug fixes. --- common.mk | 2 +- src/system/io.c | 6 ++++-- src/system/sound.c | 2 +- src/system/widgets.c | 4 ++-- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/common.mk b/common.mk index d879f35..eeee9cf 100644 --- a/common.mk +++ b/common.mk @@ -6,7 +6,7 @@ VERSION = 0.4 REVISION = $(shell date +"%y%m%d") DEBUG = 0 -CXXFLAGS += `sdl2-config --cflags` -DVERSION=$(VERSION) -DREVISION=$(REVISION) -DDEBUG=$(DEBUG) +CXXFLAGS += `sdl2-config --cflags` -DVERSION=$(VERSION) -DREVISION=$(REVISION) -DDEBUG=$(DEBUG) -DDATA_DIR=\"$(DATA_DIR)\" CXXFLAGS += -Wall -ansi -pedantic -Werror -Wstrict-prototypes CXXFLAGS += -g -lefence diff --git a/src/system/io.c b/src/system/io.c index 471b827..3308c45 100644 --- a/src/system/io.c +++ b/src/system/io.c @@ -66,6 +66,7 @@ int writeFile(char *filename, char *data) char *getSaveFilePath(char *filename) { static char path[MAX_FILENAME_LENGTH]; + memset(path, '\0', MAX_FILENAME_LENGTH); sprintf(path, "%s/%s", app.saveDir, filename); @@ -77,13 +78,14 @@ char *getSaveFilePath(char *filename) char *getFileLocation(char *filename) { static char path[MAX_FILENAME_LENGTH]; - + memset(path, '\0', MAX_FILENAME_LENGTH); + if (fileExists(filename)) { return filename; } - sprintf(path, "%s/%s\n", DATA_DIR, filename); + sprintf(path, DATA_DIR"/%s", filename); return path; } diff --git a/src/system/sound.c b/src/system/sound.c index 1906402..df3f53e 100644 --- a/src/system/sound.c +++ b/src/system/sound.c @@ -46,7 +46,7 @@ void playMusic(char *filename) music = NULL; } - music = Mix_LoadMUS(filename); + music = Mix_LoadMUS(getFileLocation(filename)); Mix_PlayMusic(music, -1); } diff --git a/src/system/widgets.c b/src/system/widgets.c index 8bf0adf..ab69d0d 100644 --- a/src/system/widgets.c +++ b/src/system/widgets.c @@ -45,7 +45,7 @@ void initWidgets(void) optionsLeft = getTexture("gfx/widgets/optionsLeft.png"); optionsRight = getTexture("gfx/widgets/optionsRight.png"); - loadWidgets(getFileLocation("data/widgets/list.json")); + loadWidgets("data/widgets/list.json"); drawingWidgets = 0; } @@ -236,7 +236,7 @@ static void loadWidgets(char *filename) for (node = root->child ; node != NULL ; node = node->next) { - loadWidgetSet(getFileLocation(node->valuestring)); + loadWidgetSet(node->valuestring); } cJSON_Delete(root);