summaryrefslogtreecommitdiff
path: root/src/loader.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/loader.c')
-rw-r--r--src/loader.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/loader.c b/src/loader.c
index 7a3d328..6e53298 100644
--- a/src/loader.c
+++ b/src/loader.c
@@ -1,6 +1,7 @@
#include "loader.h"
#include "utils.h" /* mpl_check */
+#include <SDL_stdinc.h>
#include <SDL_image.h>
#if ! SDL_VERSION_ATLEAST(2,0,0)
#error "This code is only for SDL 2+. No backward compatibility with previous SDL versions, sorry."
@@ -8,7 +9,24 @@
SDL_Texture * my_sdl_load_texture(SDL_Renderer *rend, char *giffilepath, SDL_Rect *size);
-int loadRessources(gameIni_t *gIni, char databasepath[], gameRess_t *gRess) {
+int loadRessources(gameIni_t *gIni, char data_basepath[], gameRess_t *gRess) {
+ int i, res, maxlen;
+ char *filepath;
+
+ /* This is the lenght of the longest filepath we need in this proc */
+ maxlen = strlen(databasepath) + 2*strlen(gIni->style.name) + sizeof("/style//om_00.gif");
+ filepath = SDL_malloc(maxlen+1);
+
+ for(i=0; i < gIni->style.tiles ; ++i) {
+ (void) SDL_snprintf(filepath, maxlen, "%s/style/%s/%s_%d.gif", data_basepath, gIni->style.name, gIni->style.name, i);
+ gRess->style.tiles[i] = loadGif(filepath);
+ if(gRess->style.tiles[i]==NULL) {
+ logs2(LOG_WARN, "loadRessources(), loadGif() error for ", filepath);
+ return 2;
+ }
+ }
+
+ SDL_free(filepath);
return 1; //FIXME
}