summaryrefslogtreecommitdiff
path: root/src/client/image.c
diff options
context:
space:
mode:
authorTomas Chvatal (scarabeus) <tomas.chvatal@gmail.com>2008-10-22 22:53:48 +0200
committerTomas Chvatal (scarabeus) <tomas.chvatal@gmail.com>2008-10-22 22:53:48 +0200
commit130d45bfc935da1702a7b5c246a099ea3b4a0bdf (patch)
tree5cc4b029f24e7a3cfaf1fcbc671772059a9b8e73 /src/client/image.c
parent44daf03024fbf7cbffa10349044786f6ab784821 (diff)
Ident all code correctly.
Diffstat (limited to 'src/client/image.c')
-rwxr-xr-xsrc/client/image.c195
1 files changed, 101 insertions, 94 deletions
diff --git a/src/client/image.c b/src/client/image.c
index 4c4010c..3ed4403 100755
--- a/src/client/image.c
+++ b/src/client/image.c
@@ -14,79 +14,82 @@ static list_t *listStorage;
static bool_t isImageDataInit = FALSE;
-bool_t isImageInicialized()
+bool_t
+isImageInicialized()
{
- return isImageDataInit;
+ return isImageDataInit;
}
/*
* Inicializuje globalny zoznam obrazkov
*/
-void initImageData()
+void
+initImageData()
{
- assert( isInterfaceInicialized() == TRUE );
+ assert(isInterfaceInicialized() == TRUE);
#ifdef DEBUG
- printf(_("Initializing image database\n"));
+ printf(_("Initializing image database\n"));
#endif
- listStorage = newStorage();
- isImageDataInit = TRUE;
+ listStorage = newStorage();
+ isImageDataInit = TRUE;
}
-static SDL_Surface *loadImage(const char *filename, int alpha)
+static SDL_Surface *
+loadImage(const char *filename, int alpha)
{
- SDL_Surface *tmp;
- SDL_Surface *ret;
-
- char str[STR_PATH_SIZE];
-
-
- if( isFillPath(filename) )
- {
- strcpy(str, filename);
- }
- else
- {
- sprintf(str, PATH_IMAGE "%s", filename);
- }
-
- accessExistFile(str);
-
- if( ( tmp = IMG_Load(str) ) == NULL )
- {
- fprintf(stderr, "%s\n", SDL_GetError());
- return NULL;
- }
-
- if( ( ret = (alpha) ? SDL_DisplayFormatAlpha(tmp) : SDL_DisplayFormat(tmp) ) == NULL )
- {
- fprintf(stderr, "%s\n", SDL_GetError());
- SDL_FreeSurface(tmp);
- return NULL;
- }
-
- SDL_FreeSurface(tmp);
- return ret;
+ SDL_Surface *tmp;
+ SDL_Surface *ret;
+
+ char str[STR_PATH_SIZE];
+
+
+ if (isFillPath(filename)) {
+ strcpy(str, filename);
+ }
+ else {
+ sprintf(str, PATH_IMAGE "%s", filename);
+ }
+
+ accessExistFile(str);
+
+ if ((tmp = IMG_Load(str)) == NULL) {
+ fprintf(stderr, "%s\n", SDL_GetError());
+ return NULL;
+ }
+
+ if ((ret =
+ (alpha) ? SDL_DisplayFormatAlpha(tmp) : SDL_DisplayFormat(tmp)) ==
+ NULL) {
+ fprintf(stderr, "%s\n", SDL_GetError());
+ SDL_FreeSurface(tmp);
+ return NULL;
+ }
+
+ SDL_FreeSurface(tmp);
+ return ret;
}
-image_t* newImage(SDL_Surface *surface)
+image_t *
+newImage(SDL_Surface * surface)
{
- image_t *new;
+ image_t *new;
- assert( surface != NULL );
+ assert(surface != NULL);
- new = malloc( sizeof(image_t) );
- new->image = surface;
- new->w = surface->w;
- new->h = surface->h;
+ new = malloc(sizeof(image_t));
+ new->image = surface;
+ new->w = surface->w;
+ new->h = surface->h;
- return new;
+ return new;
}
-static void destroyImage(image_t *p)
+static void
+destroyImage(image_t * p)
{
- assert( p != NULL );
- SDL_FreeSurface((SDL_Surface *)p->image);
- free(p);
+ assert(p != NULL);
+ SDL_FreeSurface((SDL_Surface *) p->image);
+ free(p);
}
/*
@@ -95,82 +98,86 @@ static void destroyImage(image_t *p)
* *name - nazov obrazku ( pouzije sa ako vyhadavaci retazec v zazanem )
* alpha - 0 - nema alpha kanal | 1 - ma alpha kanal
*/
-image_t* addImageData(char *file, int alpha, char *name, char *group)
+image_t *
+addImageData(char *file, int alpha, char *name, char *group)
{
- SDL_Surface *surface;
- image_t *new;
+ SDL_Surface *surface;
+ image_t *new;
- assert( file != NULL );
- assert( name != NULL );
- assert( group != NULL );
+ assert(file != NULL);
+ assert(name != NULL);
+ assert(group != NULL);
- surface = loadImage(file, alpha);
- new = newImage(surface);
+ surface = loadImage(file, alpha);
+ new = newImage(surface);
- addItemToStorage(listStorage, group, name, new );
+ addItemToStorage(listStorage, group, name, new);
#ifdef DEBUG
- printf(_("Loading image %s\n"), file);
+ printf(_("Loading image %s\n"), file);
#endif
- return new;
+ return new;
}
/*
* Vrati odkaz na image_data v globalnom zozname obrazkov
* a nazvom *s
*/
-image_t* getImage(char *group, char *name)
+image_t *
+getImage(char *group, char *name)
{
- assert( group != NULL );
- assert( name != NULL );
+ assert(group != NULL);
+ assert(name != NULL);
- return getItemFromStorage(listStorage, group, name);
+ return getItemFromStorage(listStorage, group, name);
}
-void delImage(char *group, char *name)
+void
+delImage(char *group, char *name)
{
- assert( group != NULL );
- assert( name != NULL );
-
- delItemFromStorage(listStorage, group, name, destroyImage);
+ assert(group != NULL);
+ assert(name != NULL);
+
+ delItemFromStorage(listStorage, group, name, destroyImage);
}
-void delAllImageInGroup(char *group)
+void
+delAllImageInGroup(char *group)
{
- assert( group != NULL );
+ assert(group != NULL);
- delAllItemFromStorage(listStorage, group, destroyImage);
+ delAllItemFromStorage(listStorage, group, destroyImage);
}
-void drawImage(image_t *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;
+ static SDL_Surface *screen = NULL;
+ SDL_Rect dst_rect, src_rect;
- if( screen == NULL )
- {
- screen = getSDL_Screen();
- }
+ if (screen == NULL) {
+ screen = getSDL_Screen();
+ }
- dst_rect.x = x;
- dst_rect.y = y;
+ dst_rect.x = x;
+ dst_rect.y = y;
- src_rect.x = px;
- src_rect.y = py;
- src_rect.w = w;
- src_rect.h = h;
+ src_rect.x = px;
+ src_rect.y = py;
+ src_rect.w = w;
+ src_rect.h = h;
- SDL_BlitSurface(p->image, &src_rect, screen, &dst_rect);
+ SDL_BlitSurface(p->image, &src_rect, screen, &dst_rect);
}
/*
* Odstrani zoznam obrazkov z pamate
*/
-void quitImageData()
+void
+quitImageData()
{
#ifdef DEBUG
- printf(_("Quitting image database\n"));
+ printf(_("Quitting image database\n"));
#endif
- destroyStorage(listStorage, destroyImage);
- isImageDataInit = FALSE;
+ destroyStorage(listStorage, destroyImage);
+ isImageDataInit = FALSE;
}
-