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 | |
parent | 11734a337451aa2d6b9d2aa2fef2674073e04046 (diff) | |
download | mplemmings-3f4026dd46e0eba4c6f60e78e58069c58cb1cb5c.tar.gz mplemmings-3f4026dd46e0eba4c6f60e78e58069c58cb1cb5c.tar.bz2 mplemmings-3f4026dd46e0eba4c6f60e78e58069c58cb1cb5c.zip |
Debut implementataion loader mais début d'orage aussi
-rw-r--r-- | src/include/loader.h | 2 | ||||
-rw-r--r-- | src/loader.c | 20 | ||||
-rw-r--r-- | src/parser.c | 6 |
3 files changed, 23 insertions, 5 deletions
diff --git a/src/include/loader.h b/src/include/loader.h index adf8777..81c39cb 100644 --- a/src/include/loader.h +++ b/src/include/loader.h @@ -5,6 +5,6 @@ #include "data_ress.h" // Load all textures needed for style and level from gIni -int loadRessources(gameIni_t *gIni, char databasepath[], gameRess_t *gRess); +int loadRessources(gameIni_t *gIni, char data_basepath[], gameRess_t *gRess); #endif /*LOADER_H*/ 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 } diff --git a/src/parser.c b/src/parser.c index 0720881..d34197d 100644 --- a/src/parser.c +++ b/src/parser.c @@ -61,9 +61,9 @@ } \ } while(0) -int callback_ini_style (const mTCHAR *section, const mTCHAR *key, const mTCHAR *value, const void *userData); -int callback_ini_levelpack (const mTCHAR *section, const mTCHAR *key, const mTCHAR *value, const void *userData); -int callback_ini_level(const mTCHAR *section, const mTCHAR *key, const mTCHAR *value, const void *userData); +int callback_ini_style (const mTCHAR *section, const mTCHAR *key, const mTCHAR *value, const void *userData); +int callback_ini_levelpack(const mTCHAR *section, const mTCHAR *key, const mTCHAR *value, const void *userData); +int callback_ini_level (const mTCHAR *section, const mTCHAR *key, const mTCHAR *value, const void *userData); // struct for void *UserData pointer (app context passed to each callback func) #define MAX_LINELEN 256 |