diff options
author | Ludovic Pouzenc <lpouzenc@gmail.com> | 2013-07-17 18:10:43 +0200 |
---|---|---|
committer | Ludovic Pouzenc <lpouzenc@gmail.com> | 2013-07-17 18:10:43 +0200 |
commit | 3f4026dd46e0eba4c6f60e78e58069c58cb1cb5c (patch) | |
tree | 449f9e3d8b640317f4e0eecaedb407a1b5ce6268 /src/loader.c | |
parent | 11734a337451aa2d6b9d2aa2fef2674073e04046 (diff) | |
download | mplemmings-3f4026dd46e0eba4c6f60e78e58069c58cb1cb5c.tar.gz mplemmings-3f4026dd46e0eba4c6f60e78e58069c58cb1cb5c.tar.bz2 mplemmings-3f4026dd46e0eba4c6f60e78e58069c58cb1cb5c.zip |
Debut implementataion loader mais début d'orage aussi
Diffstat (limited to 'src/loader.c')
-rw-r--r-- | src/loader.c | 20 |
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 } |