From 98afa4434bb6c8bc12ec574e204d9b0abcbd91da Mon Sep 17 00:00:00 2001
From: "p.kosyh"
Date: Sun, 17 Apr 2011 15:33:04 +0000
Subject: [PATCH] idf go on
---
src/sdl-instead/SDL_anigif.c | 5 +++--
src/sdl-instead/graphics.c | 10 ++++++----
src/sdl-instead/sound.c | 9 ++++++---
3 files changed, 15 insertions(+), 9 deletions(-)
diff --git a/src/sdl-instead/SDL_anigif.c b/src/sdl-instead/SDL_anigif.c
index 3524e39..c8f801d 100644
--- a/src/sdl-instead/SDL_anigif.c
+++ b/src/sdl-instead/SDL_anigif.c
@@ -22,7 +22,8 @@
#include
#include "SDL_anigif.h"
#include "util.h"
-
+#include "idf.h"
+extern idf_t game_idf;
/* Code from here to end of file has been adapted from XPaint: */
/* +-------------------------------------------------------------------+ */
@@ -137,7 +138,7 @@ int AG_LoadGIF( const char* file, AG_Frame* frames, int size, int *loop )
{
int n = 0;
- SDL_RWops* src = SDL_RWFromFile( dirpath(file), "rb" );
+ SDL_RWops* src = RWFromIdf(game_idf, file);
if ( src )
{
diff --git a/src/sdl-instead/graphics.c b/src/sdl-instead/graphics.c
index be7922c..619c57d 100644
--- a/src/sdl-instead/graphics.c
+++ b/src/sdl-instead/graphics.c
@@ -761,6 +761,7 @@ cache_t gfx_image_cache(void)
static img_t _gfx_load_image(char *filename, int combined)
{
+ SDL_RWops *rw;
SDL_Surface *img;
int nr = 0;
filename = strip(filename);
@@ -782,13 +783,14 @@ static img_t _gfx_load_image(char *filename, int combined)
anigif_add(agif);
return agif->frames[0].surface;
}
- img = IMG_Load(dirpath(filename));
- if (!img) {
+ rw = RWFromIdf(game_idf, filename);
+
+ if (!rw || !(img = IMG_Load_RW(rw, 1)))
return NULL;
- }
+
if (img->format->BitsPerPixel == 32) { /* hack for 32 bit BMP :( */
SDL_RWops *rwop;
- rwop = SDL_RWFromFile(dirpath(filename), "rb");
+ rwop = RWFromIdf(game_idf, filename);
if (rwop) {
if (IMG_isBMP(rwop))
SDL_SetAlpha(img, 0, SDL_ALPHA_OPAQUE);
diff --git a/src/sdl-instead/sound.c b/src/sdl-instead/sound.c
index 37f3f14..b82f929 100644
--- a/src/sdl-instead/sound.c
+++ b/src/sdl-instead/sound.c
@@ -118,14 +118,17 @@ int snd_volume_mus(int vol)
wav_t snd_load_wav(const char *fname)
{
+ SDL_RWops *rw;
wav_t r;
if (!sound_on)
return NULL;
- if (!fname)
+ if (!fname || !*fname)
return NULL;
- r = (wav_t)Mix_LoadWAV(dirpath(fname));
- if (!r)
+ rw = RWFromIdf(game_idf, fname);
+ if (!rw || !(r = (wav_t)Mix_LoadWAV_RW(rw, 1))) {
fprintf(stderr,"Can't load '%s'.\n", fname);
+ return NULL;
+ }
return r;
}