summaryrefslogtreecommitdiff
path: root/src/client/image.c
diff options
context:
space:
mode:
authororoborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e>2008-07-17 20:49:03 +0000
committeroroborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e>2008-07-17 20:49:03 +0000
commit77465c2629ef63629d69c97a0af60a47a07ce7f5 (patch)
tree3d361898d0f29f4b789e52682e0945c741df6cb0 /src/client/image.c
parentb6af4e925f4cf9dd284728e846b99e1de776ec31 (diff)
- opravena chyba, tux mophol pomocou bombballu vybuchnuteho v objekte do ktoreho sa dostal ako duch pridavat itemy
- kod namiesto SDL_Surface pouziva moj typ image_t git-svn-id: http://opensvn.csie.org/tuxanci_ng@154 0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e
Diffstat (limited to 'src/client/image.c')
-rwxr-xr-xsrc/client/image.c39
1 files changed, 28 insertions, 11 deletions
diff --git a/src/client/image.c b/src/client/image.c
index 3c3b40f..e76e1cf 100755
--- a/src/client/image.c
+++ b/src/client/image.c
@@ -60,10 +60,25 @@ static SDL_Surface *loadImage(const char *filename, int alpha)
return ret;
}
-static void destroySDLSurface(void *p)
+image_t* newImage(SDL_Surface *surface)
+{
+ image_t *new;
+
+ assert( surface != NULL );
+
+ new = malloc( sizeof(image_t) );
+ new->image = surface;
+ new->w = surface->w;
+ new->h = surface->h;
+
+ return new;
+}
+
+static void destroyImage(image_t *p)
{
assert( p != NULL );
- SDL_FreeSurface((SDL_Surface *)p);
+ SDL_FreeSurface((SDL_Surface *)p->image);
+ free(p);
}
/*
@@ -72,15 +87,17 @@ static void destroySDLSurface(void *p)
* *name - nazov obrazku ( pouzije sa ako vyhadavaci retazec v zazanem )
* alpha - 0 - nema alpha kanal | 1 - ma alpha kanal
*/
-SDL_Surface* addImageData(char *file, int alpha, char *name, char *group)
+image_t* addImageData(char *file, int alpha, char *name, char *group)
{
- SDL_Surface *new;
+ SDL_Surface *surface;
+ image_t *new;
assert( file != NULL );
assert( name != NULL );
assert( group != NULL );
- new = loadImage(file, alpha);
+ surface = loadImage(file, alpha);
+ new = newImage(surface);
addItemToStorage(listStorage, group, name, new );
@@ -93,7 +110,7 @@ SDL_Surface* addImageData(char *file, int alpha, char *name, char *group)
* Vrati odkaz na image_data v globalnom zozname obrazkov
* a nazvom *s
*/
-SDL_Surface* getImage(char *group, char *name)
+image_t* getImage(char *group, char *name)
{
assert( group != NULL );
assert( name != NULL );
@@ -106,17 +123,17 @@ void delImage(char *group, char *name)
assert( group != NULL );
assert( name != NULL );
- delItemFromStorage(listStorage, group, name, destroySDLSurface);
+ delItemFromStorage(listStorage, group, name, destroyImage);
}
void delAllImageInGroup(char *group)
{
assert( group != NULL );
- delAllItemFromStorage(listStorage, group, destroySDLSurface);
+ delAllItemFromStorage(listStorage, group, destroyImage);
}
-void drawImage(SDL_Surface *p, int x,int y, int px, int py, int w, int h)
+void drawImage(image_t *p, int x,int y, int px, int py, int w, int h)
{
static SDL_Surface *screen = NULL;
SDL_Rect dst_rect, src_rect;
@@ -134,7 +151,7 @@ void drawImage(SDL_Surface *p, int x,int y, int px, int py, int w, int h)
src_rect.w = w;
src_rect.h = h;
- SDL_BlitSurface(p, &src_rect, screen, &dst_rect);
+ SDL_BlitSurface(p->image, &src_rect, screen, &dst_rect);
}
/*
@@ -143,7 +160,7 @@ void drawImage(SDL_Surface *p, int x,int y, int px, int py, int w, int h)
void quitImageData()
{
printf("quit image database..\n");
- destroyStorage(listStorage, destroySDLSurface);
+ destroyStorage(listStorage, destroyImage);
isImageDataInit = FALSE;
}