Complete.Org: Mailing Lists: Archives: freeciv-dev: January 2003:
[Freeciv-Dev] (PR#2937) SDL client: GET_SURF()
Home

[Freeciv-Dev] (PR#2937) SDL client: GET_SURF()

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients:;
Subject: [Freeciv-Dev] (PR#2937) SDL client: GET_SURF()
From: "Jason Short via RT" <rt@xxxxxxxxxxxxxx>
Date: Wed, 29 Jan 2003 10:35:10 -0800
Reply-to: rt@xxxxxxxxxxxxxx

Currently the SDL client uses a big hack to avoid having to deal with 
the struct Sprite:

   struct Sprite {

   };

and then the sprite pointer is used just as a (SDL_Surface *) and 
accessed as (SDL_Surface *)s.

Aside from being very ugly, it is not typesafe.  You could accidentally 
throw any pointer in there and it would compile.

My patch to change this introduces in graphics.h:

   struct Sprite {
     SDL_Surface surf;
   }

   #define GET_SURF(s) (&s->surf)

this way the same hack is preserved in implementation (there is no 
struct Sprite, only SDL_Surface), but the access isn't quite as ugly (it 
calls GET_SURF) and it is type-safe.  The compiled code is probably 
completely identical...

jason

Index: client/gui-sdl/citydlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-sdl/citydlg.c,v
retrieving revision 1.6
diff -u -r1.6 citydlg.c
--- client/gui-sdl/citydlg.c    2003/01/24 00:51:02     1.6
+++ client/gui-sdl/citydlg.c    2003/01/29 18:31:19
@@ -561,9 +561,8 @@
   pStr = create_str16_from_char(cBuf, 12);
   pStr->style |= TTF_STYLE_BOLD;
 
-  pBuf =
-      create_iconlabel((SDL_Surface *)get_unit_type(pUnit->type)->sprite,
-                      pStr, 0);
+  pBuf = create_iconlabel(GET_SURF(get_unit_type(pUnit->type)->sprite),
+                         pStr, 0);
 
   if (ww < pBuf->size.w) {
     ww = pBuf->size.w;
@@ -1163,21 +1162,24 @@
   case 0x20:
     new ^= 0x20;
     new ^= 0x40;
-    pWidget->gfx = (SDL_Surface *)get_citizen_sprite(CITIZEN_TAXMAN, 0, 
pCityDlg->pCity);
+    pWidget->gfx = GET_SURF(get_citizen_sprite(CITIZEN_TAXMAN, 0,
+                                              pCityDlg->pCity));
     pWidget->ID = MAX_ID - 0x40;
     redraw_ibutton(pWidget);
     refresh_rect(pWidget->size);
     break;
   case 0x40:
     new &= 0x1f;
-    pWidget->gfx = (SDL_Surface *)get_citizen_sprite(CITIZEN_ELVIS, 0, 
pCityDlg->pCity);
+    pWidget->gfx = GET_SURF(get_citizen_sprite(CITIZEN_ELVIS, 0,
+                                              pCityDlg->pCity));
     pWidget->ID = MAX_ID - 0x60;
     redraw_ibutton(pWidget);
     refresh_rect(pWidget->size);
     break;
   case 0x60:
     new |= 0x20;
-    pWidget->gfx = (SDL_Surface *)get_citizen_sprite(CITIZEN_SCIENTIST, 0, 
pCityDlg->pCity);
+    pWidget->gfx = GET_SURF(get_citizen_sprite(CITIZEN_SCIENTIST, 0,
+                                              pCityDlg->pCity));
     pWidget->ID = MAX_ID - 0x20;
     redraw_ibutton(pWidget);
     refresh_rect(pWidget->size);
@@ -1307,16 +1309,19 @@
   change_ptsize16(pStr, 13);
 
   if (pCity->city_options & 0x20) {
-    pSurf = (SDL_Surface *)get_citizen_sprite(CITIZEN_SCIENTIST, 0, 
pCityDlg->pCity);
+    pSurf = GET_SURF(get_citizen_sprite(CITIZEN_SCIENTIST, 0,
+                                       pCityDlg->pCity));
     pBuf = create_icon_button(pSurf, pStr, WF_ICON_CENTER_RIGHT);
     add_to_gui_list(MAX_ID - 0x20, pBuf);
   } else {
     if (pCity->city_options & 0x40) {
-      pSurf = (SDL_Surface *)get_citizen_sprite(CITIZEN_TAXMAN, 0, 
pCityDlg->pCity);
+      pSurf = GET_SURF(get_citizen_sprite(CITIZEN_TAXMAN, 0,
+                                         pCityDlg->pCity));
       pBuf = create_icon_button(pSurf, pStr, WF_ICON_CENTER_RIGHT);
       add_to_gui_list(MAX_ID - 0x40, pBuf);
     } else {
-      pSurf = (SDL_Surface *)get_citizen_sprite(CITIZEN_ELVIS, 0, 
pCityDlg->pCity);
+      pSurf = GET_SURF(get_citizen_sprite(CITIZEN_ELVIS, 0,
+                                         pCityDlg->pCity));
       pBuf = create_icon_button(pSurf, pStr, WF_ICON_CENTER_RIGHT);
       add_to_gui_list(MAX_ID - 0x60, pBuf);
     }
@@ -1923,7 +1928,7 @@
       pStr->style |= TTF_STYLE_BOLD;
 #endif
 
-      pBuf = create_iconlabel((SDL_Surface *) pImpr->sprite, pStr,
+      pBuf = create_iconlabel(GET_SURF(pImpr->sprite), pStr,
                WF_DRAW_THEME_TRANSPARENT|WF_DRAW_TEXT_LABEL_WITH_SPACE);
 
       /* pBuf->string16->style &= ~SF_CENTER; */
@@ -1972,7 +1977,7 @@
       pStr->style |= TTF_STYLE_BOLD;
 #endif
       
-      pTemp_Surf = make_flag_surface_smaler((SDL_Surface *) pUnit->sprite);
+      pTemp_Surf = make_flag_surface_smaler(GET_SURF(pUnit->sprite));
 
       if ( pTemp_Surf->h > 26 )
       {
@@ -3502,9 +3507,9 @@
        count = 0;
 
        if (city_got_building(pCity, B_TEMPLE)) {
-         pTmp1 = ZoomSurface((SDL_Surface *)
-                             get_improvement_type(B_TEMPLE)->sprite, 0.5,
-                             0.5, 1);
+         pTmp1 =
+           ZoomSurface(GET_SURF(get_improvement_type(B_TEMPLE)->sprite),
+                       0.5, 0.5, 1);
          count += (pTmp1->h + 1);
          pSurf = pTmp1;
        } else {
@@ -3512,9 +3517,9 @@
        }
 
        if (city_got_building(pCity, B_COLOSSEUM)) {
-         pTmp2 = ZoomSurface((SDL_Surface *)
-                             get_improvement_type(B_COLOSSEUM)->sprite,
-                             0.5, 0.5, 1);
+         pTmp2 =
+           ZoomSurface(GET_SURF(get_improvement_type(B_COLOSSEUM)->sprite),
+                       0.5, 0.5, 1);
          count += (pTmp2->h + 1);
          if (!pSurf) {
            pSurf = pTmp2;
@@ -3525,9 +3530,9 @@
 
        if (city_got_building(pCity, B_CATHEDRAL) ||
            city_affected_by_wonder(pCity, B_MICHELANGELO)) {
-         pTmp3 = ZoomSurface((SDL_Surface *)
-                             get_improvement_type(B_CATHEDRAL)->sprite,
-                             0.5, 0.5, 1);
+         pTmp3 =
+           ZoomSurface(GET_SURF(get_improvement_type(B_CATHEDRAL)->sprite),
+                       0.5, 0.5, 1);
          count += (pTmp3->h + 1);
          if (!pSurf) {
            pSurf = pTmp3;
@@ -3578,8 +3583,8 @@
 
        if (city_affected_by_wonder(pCity, B_CURE)) {
          pTmp1 =
-             ZoomSurface((SDL_Surface *) get_improvement_type(B_CURE)->
-                         sprite, 0.5, 0.5, 1);
+           ZoomSurface(GET_SURF(get_improvement_type(B_CURE)->sprite),
+                       0.5, 0.5, 1);
          count += (pTmp1->h + 1);
          pSurf = pTmp1;
        } else {
@@ -3587,8 +3592,8 @@
        }
 
        if (city_affected_by_wonder(pCity, B_SHAKESPEARE)) {
-         pTmp2 = ZoomSurface((SDL_Surface *)
-                             get_improvement_type(B_SHAKESPEARE)->sprite,
+         pTmp2 = ZoomSurface(GET_SURF(get_improvement_type(B_SHAKESPEARE)
+                                      ->sprite),
                              0.5, 0.5, 1);
          count += (pTmp2->h + 1);
          if (!pSurf) {
@@ -3600,8 +3605,8 @@
 
        if (city_affected_by_wonder(pCity, B_BACH)) {
          pTmp3 =
-             ZoomSurface((SDL_Surface *) get_improvement_type(B_BACH)->
-                         sprite, 0.5, 0.5, 1);
+           ZoomSurface(GET_SURF(get_improvement_type(B_BACH)->sprite),
+                       0.5, 0.5, 1);
          count += (pTmp3->h + 1);
          if (!pSurf) {
            pSurf = pTmp3;
@@ -3611,9 +3616,9 @@
        }
 
        if (city_affected_by_wonder(pCity, B_HANGING)) {
-         pTmp4 = ZoomSurface((SDL_Surface *)
-                             get_improvement_type(B_HANGING)->sprite, 0.5,
-                             0.5, 1);
+         pTmp4 =
+           ZoomSurface(GET_SURF(get_improvement_type(B_HANGING)->sprite),
+                       0.5, 0.5, 1);
          count += (pTmp4->h + 1);
          if (!pSurf) {
            pSurf = pTmp4;
@@ -4384,7 +4389,7 @@
 
     pStr->text = convert_to_utf16(pUnit->name);
 
-    src = get_smaller_surface_rect((SDL_Surface *) pUnit->sprite);
+    src = get_smaller_surface_rect(GET_SURF(pUnit->sprite));
 
     pBuf = create_text_surf_from_str16(pStr);
 
@@ -4392,8 +4397,7 @@
     dest.y = pWindow->size.y + 233;
 
     /* blit unit icon */
-    SDL_BlitSurface((SDL_Surface *) pUnit->sprite, &src, Main.screen,
-                   &dest);
+    SDL_BlitSurface(GET_SURF(pUnit->sprite), &src, Main.screen, &dest);
 
     dest.y += (src.h - pBuf->h) / 2;
     dest.x += src.w + 5;
@@ -4425,7 +4429,7 @@
     }
 
     pStr->text = convert_to_utf16(pImpr->name);
-    pBuf = (SDL_Surface *) pImpr->sprite;
+    pBuf = GET_SURF(pImpr->sprite);
 
     /* blit impr icon */
     dest.x = pWindow->size.x + 6 + (185 - pBuf->w) / 2;
@@ -4530,7 +4534,7 @@
       pCity->ppl_unhappy[4] + pCity->ppl_angry[4] +
       pCity->ppl_elvis + pCity->ppl_scientist + pCity->ppl_taxman;
 
-  pBuf = (SDL_Surface *)get_citizen_sprite(CITIZEN_ELVIS, 0, pCity);
+  pBuf = GET_SURF(get_citizen_sprite(CITIZEN_ELVIS, 0, pCity));
   if (count > 13) {
     step = (400 - pBuf->w) / (12 + count - 13);
   } else {
@@ -4543,7 +4547,7 @@
 
   if (pCity->ppl_happy[4]) {
     for (i = 0; i < pCity->ppl_happy[4]; i++) {
-      pBuf = (SDL_Surface *)get_citizen_sprite(CITIZEN_HAPPY, i, pCity);
+      pBuf = GET_SURF(get_citizen_sprite(CITIZEN_HAPPY, i, pCity));
       SDL_BlitSurface(pBuf, NULL, Main.screen, &dest);
       dest.x += step;
     }
@@ -4551,7 +4555,7 @@
 
   if (pCity->ppl_content[4]) {
     for (i = 0; i < pCity->ppl_content[4]; i++) {
-      pBuf = (SDL_Surface *)get_citizen_sprite(CITIZEN_CONTENT, i, pCity);
+      pBuf = GET_SURF(get_citizen_sprite(CITIZEN_CONTENT, i, pCity));
       SDL_BlitSurface(pBuf, NULL, Main.screen, &dest);
       dest.x += step;
     }
@@ -4559,7 +4563,7 @@
 
   if (pCity->ppl_unhappy[4]) {
     for (i = 0; i < pCity->ppl_unhappy[4]; i++) {
-      pBuf = (SDL_Surface *)get_citizen_sprite(CITIZEN_UNHAPPY, i, pCity);
+      pBuf = GET_SURF(get_citizen_sprite(CITIZEN_UNHAPPY, i, pCity));
       SDL_BlitSurface(pBuf, NULL, Main.screen, &dest);
       dest.x += step;
     }
@@ -4567,7 +4571,7 @@
 
   if (pCity->ppl_angry[4]) {
     for (i = 0; i < pCity->ppl_angry[4]; i++) {
-      pBuf = (SDL_Surface *)get_citizen_sprite(CITIZEN_ANGRY, i, pCity);
+      pBuf = GET_SURF(get_citizen_sprite(CITIZEN_ANGRY, i, pCity));
       SDL_BlitSurface(pBuf, NULL, Main.screen, &dest);
       dest.x += step;
     }
@@ -4578,7 +4582,7 @@
   FREE(pCityDlg->specs_area[2]);
 
   if (pCity->ppl_elvis) {
-    pBuf = (SDL_Surface *)get_citizen_sprite(CITIZEN_ELVIS, 0, pCity);
+    pBuf = GET_SURF(get_citizen_sprite(CITIZEN_ELVIS, 0, pCity));
     pCityDlg->specs_area[0] = MALLOC(sizeof(SDL_Rect));
     pCityDlg->specs_area[0]->x = dest.x;
     pCityDlg->specs_area[0]->y = dest.y;
@@ -4593,7 +4597,7 @@
   }
 
   if (pCity->ppl_taxman) {
-    pBuf = (SDL_Surface *)get_citizen_sprite(CITIZEN_TAXMAN, 0, pCity);
+    pBuf = GET_SURF(get_citizen_sprite(CITIZEN_TAXMAN, 0, pCity));
     pCityDlg->specs_area[1] = MALLOC(sizeof(SDL_Rect));
     pCityDlg->specs_area[1]->x = dest.x;
     pCityDlg->specs_area[1]->y = dest.y;
@@ -4608,7 +4612,7 @@
   }
 
   if (pCity->ppl_scientist) {
-    pBuf = (SDL_Surface *)get_citizen_sprite(CITIZEN_SCIENTIST, 0, pCity);
+    pBuf = GET_SURF(get_citizen_sprite(CITIZEN_SCIENTIST, 0, pCity));
     pCityDlg->specs_area[2] = MALLOC(sizeof(SDL_Rect));
     pCityDlg->specs_area[2]->x = dest.x;
     pCityDlg->specs_area[2]->y = dest.y;
@@ -4687,7 +4691,7 @@
 
     pStr->style |= TTF_STYLE_BOLD;
 
-    pLogo = ResizeSurface((SDL_Surface *) pImpr->sprite, 18, 11, 1);
+    pLogo = ResizeSurface(GET_SURF(pImpr->sprite), 18, 11, 1);
 
     pBuf =
        create_iconlabel(pLogo, pStr,
Index: client/gui-sdl/dialogs.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-sdl/dialogs.c,v
retrieving revision 1.6
diff -u -r1.6 dialogs.c
--- client/gui-sdl/dialogs.c    2003/01/27 22:53:01     1.6
+++ client/gui-sdl/dialogs.c    2003/01/29 18:31:21
@@ -3115,7 +3115,7 @@
       pGov = &governments[i];
       pStr = create_str16_from_char(pGov->name, 12);
       pGov_Button =
-         create_icon_button((SDL_Surface *) pGov->sprite, pStr, 0);
+         create_icon_button(GET_SURF(pGov->sprite), pStr, 0);
       pGov_Button->action = government_dlg_callback;
 
       if (pGov_Button->size.w > max_w)
@@ -3598,7 +3598,7 @@
 **************************************************************************/
 static SDL_Surface *get_city_style_surf(int style)
 {
-  return (SDL_Surface *) sprites.city.tile[style][2];
+  return GET_SURF(sprites.city.tile[style][2]);
 }
 
 /**************************************************************************
@@ -3760,7 +3760,7 @@
   struct GUI *pEndNationButtons = NULL;
 
   /* init list */
-  pTmp_flag = (SDL_Surface *) get_nation_by_idx(0)->flag_sprite;
+  pTmp_flag = GET_SURF(get_nation_by_idx(0)->flag_sprite);
   pTmp_flag = make_flag_surface_smaler(pTmp_flag);
   pTmp_flag_zoomed = ZoomSurface(pTmp_flag, 0.5, 0.5, 0);
   FREESURFACE(pTmp_flag);
@@ -3781,7 +3781,7 @@
 
   /* fill list */
   for (i = 1; i < game.playable_nation_count; i++) {
-    pTmp_flag = (SDL_Surface *) get_nation_by_idx(i)->flag_sprite;
+    pTmp_flag = GET_SURF(get_nation_by_idx(i)->flag_sprite);
 
     pTmp_flag = make_flag_surface_smaler(pTmp_flag);
     pTmp_flag_zoomed = ZoomSurface(pTmp_flag, 0.5, 0.5, 0);
@@ -4099,9 +4099,7 @@
   /* end redraw window widgets */
 
   if (pNations->nation) {
-    pTmp =
-       (SDL_Surface *) get_nation_by_idx(pNations->nation -
-                                         1)->flag_sprite;
+    pTmp = GET_SURF(get_nation_by_idx(pNations->nation - 1)->flag_sprite);
     pTmp = ZoomSurface(pTmp, 3.0, 3.0, 1);
     SDL_SetColorKey(pTmp, SDL_SRCCOLORKEY, 0x0);
 
Index: client/gui-sdl/graphics.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-sdl/graphics.c,v
retrieving revision 1.8
diff -u -r1.8 graphics.c
--- client/gui-sdl/graphics.c   2003/01/29 05:10:49     1.8
+++ client/gui-sdl/graphics.c   2003/01/29 18:31:21
@@ -1751,7 +1751,7 @@
   SDL_Rect src_rect =
       { (Sint16) x, (Sint16) y, (Uint16) width, (Uint16) height };
   SDL_Surface *pNew, *pTmp =
-      crop_rect_from_surface((SDL_Surface *) source, &src_rect);
+      crop_rect_from_surface(GET_SURF(source), &src_rect);
 
   if (pTmp->format->Amask) {
     SDL_SetAlpha(pTmp, SDL_SRCALPHA, 255);
Index: client/gui-sdl/graphics.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-sdl/graphics.h,v
retrieving revision 1.3
diff -u -r1.3 graphics.h
--- client/gui-sdl/graphics.h   2003/01/15 02:35:04     1.3
+++ client/gui-sdl/graphics.h   2003/01/29 18:31:21
@@ -29,8 +29,10 @@
 #define        RECT_LIMIT      50
 
 struct Sprite {
-  struct SDL_Surface;
+  struct SDL_Surface surf;
 };
+
+#define GET_SURF(s) (&s->surf)
 
 struct Sdl {
   int rects_count;             /* update rect. list counter */
Index: client/gui-sdl/gui_tilespec.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-sdl/gui_tilespec.c,v
retrieving revision 1.4
diff -u -r1.4 gui_tilespec.c
--- client/gui-sdl/gui_tilespec.c       2003/01/25 18:36:40     1.4
+++ client/gui-sdl/gui_tilespec.c       2003/01/29 18:31:22
@@ -63,69 +63,69 @@
   FREESURFACE( pIcons->pSpec_Sci ); /* Scientist */
 
   /* allocate icons */
-  pIcons->pMale_Happy = ResizeSurface( 
-    (SDL_Surface *)get_citizen_sprite( CITIZEN_HAPPY, 0, pCity ),
-                                                           15 , 26, 1 );
+  pIcons->pMale_Happy =
+    ResizeSurface(GET_SURF(get_citizen_sprite(CITIZEN_HAPPY, 0, pCity)),
+                 15, 26, 1);
   SDL_SetColorKey( pIcons->pMale_Happy , SDL_SRCCOLORKEY|SDL_RLEACCEL , 
                            getpixel( pIcons->pMale_Happy , 0 ,0 ) );
     
-  pIcons->pFemale_Happy = ResizeSurface( 
-    (SDL_Surface *)get_citizen_sprite( CITIZEN_HAPPY, 1, pCity ) ,
-                                                            15 , 26, 1 );
+  pIcons->pFemale_Happy =
+    ResizeSurface(GET_SURF(get_citizen_sprite(CITIZEN_HAPPY, 1, pCity)),
+                 15, 26, 1);
   SDL_SetColorKey( pIcons->pFemale_Happy , SDL_SRCCOLORKEY|SDL_RLEACCEL , 
                            getpixel( pIcons->pFemale_Happy , 0 ,0 ) );
     
-  pIcons->pMale_Content = ResizeSurface( 
-    (SDL_Surface *)get_citizen_sprite( CITIZEN_CONTENT, 0, pCity ) ,
-                                                            15 , 26, 1 );
+  pIcons->pMale_Content =
+    ResizeSurface(GET_SURF(get_citizen_sprite(CITIZEN_CONTENT, 0, pCity)),
+                 15, 26, 1);
   SDL_SetColorKey( pIcons->pMale_Content , SDL_SRCCOLORKEY|SDL_RLEACCEL , 
                            getpixel( pIcons->pMale_Content , 0 ,0 ) );
     
-  pIcons->pFemale_Content = ResizeSurface( 
-    (SDL_Surface *)get_citizen_sprite( CITIZEN_CONTENT, 1, pCity ),
-                                                             15 , 26, 1 );
+  pIcons->pFemale_Content =
+    ResizeSurface(GET_SURF(get_citizen_sprite(CITIZEN_CONTENT, 1, pCity)),
+                 15, 26, 1);
   SDL_SetColorKey( pIcons->pFemale_Content , SDL_SRCCOLORKEY|SDL_RLEACCEL , 
                            getpixel( pIcons->pFemale_Content , 0 ,0 ) );
     
-  pIcons->pMale_Unhappy = ResizeSurface( 
-    (SDL_Surface *)get_citizen_sprite( CITIZEN_UNHAPPY, 0, pCity ),
-                                                           15 , 26, 1 );
+  pIcons->pMale_Unhappy =
+    ResizeSurface(GET_SURF(get_citizen_sprite(CITIZEN_UNHAPPY, 0, pCity)),
+                          15, 26, 1);
   SDL_SetColorKey( pIcons->pMale_Unhappy , SDL_SRCCOLORKEY|SDL_RLEACCEL , 
                            getpixel( pIcons->pMale_Unhappy , 0 ,0 ) );
     
-  pIcons->pFemale_Unhappy = ResizeSurface( 
-    (SDL_Surface *)get_citizen_sprite( CITIZEN_UNHAPPY, 1, pCity ),
-                                                          15 , 26, 1 );
+  pIcons->pFemale_Unhappy =
+    ResizeSurface(GET_SURF(get_citizen_sprite(CITIZEN_UNHAPPY, 1, pCity)),
+                 15, 26, 1);
   SDL_SetColorKey( pIcons->pFemale_Unhappy , SDL_SRCCOLORKEY|SDL_RLEACCEL , 
                            getpixel( pIcons->pFemale_Unhappy , 0 ,0 ) );
     
-  pIcons->pMale_Angry = ResizeSurface( 
-    (SDL_Surface *)get_citizen_sprite( CITIZEN_ANGRY, 0, pCity ),
-                                                           15 , 26, 1 );
+  pIcons->pMale_Angry =
+    ResizeSurface(GET_SURF(get_citizen_sprite(CITIZEN_ANGRY, 0, pCity)),
+                 15, 26, 1);
   SDL_SetColorKey( pIcons->pMale_Angry , SDL_SRCCOLORKEY|SDL_RLEACCEL , 
                            getpixel( pIcons->pMale_Angry , 0 ,0 ) );
     
-  pIcons->pFemale_Angry = ResizeSurface( 
-    (SDL_Surface *)get_citizen_sprite( CITIZEN_ANGRY, 1, pCity ),
-                                                           15 , 26, 1 );
+  pIcons->pFemale_Angry =
+    ResizeSurface(GET_SURF(get_citizen_sprite(CITIZEN_ANGRY, 1, pCity)),
+                 15, 26, 1);
   SDL_SetColorKey( pIcons->pFemale_Angry , SDL_SRCCOLORKEY|SDL_RLEACCEL , 
                            getpixel( pIcons->pFemale_Angry , 0 ,0 ) );
     
-  pIcons->pSpec_Lux = ResizeSurface( 
-    (SDL_Surface *)get_citizen_sprite( CITIZEN_ELVIS, 0, pCity ) ,
-                                                            15 , 26, 1 );
+  pIcons->pSpec_Lux =
+    ResizeSurface(GET_SURF(get_citizen_sprite(CITIZEN_ELVIS, 0, pCity)),
+                 15, 26, 1);
   SDL_SetColorKey( pIcons->pSpec_Lux , SDL_SRCCOLORKEY|SDL_RLEACCEL , 
                            getpixel( pIcons->pSpec_Lux , 0 ,0 ) );
     
-  pIcons->pSpec_Tax = ResizeSurface( 
-    (SDL_Surface *)get_citizen_sprite( CITIZEN_TAXMAN, 0, pCity )
-                                                          , 15 , 26, 1 );
+  pIcons->pSpec_Tax =
+    ResizeSurface(GET_SURF(get_citizen_sprite(CITIZEN_TAXMAN, 0, pCity)),
+                 15, 26, 1);
   SDL_SetColorKey( pIcons->pSpec_Tax , SDL_SRCCOLORKEY|SDL_RLEACCEL , 
                            getpixel( pIcons->pSpec_Tax , 0 ,0 ) );
     
-  pIcons->pSpec_Sci = ResizeSurface( 
-    (SDL_Surface *)get_citizen_sprite( CITIZEN_SCIENTIST, 0, pCity ) ,
-                                                            15 , 26, 1 );
+  pIcons->pSpec_Sci =
+    ResizeSurface(GET_SURF(get_citizen_sprite(CITIZEN_SCIENTIST, 0, pCity)),
+                 15, 26, 1);
   SDL_SetColorKey( pIcons->pSpec_Sci , SDL_SRCCOLORKEY|SDL_RLEACCEL , 
                            getpixel( pIcons->pSpec_Sci , 0 ,0 ) );
     
Index: client/gui-sdl/mapctrl.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-sdl/mapctrl.c,v
retrieving revision 1.5
diff -u -r1.5 mapctrl.c
--- client/gui-sdl/mapctrl.c    2003/01/24 00:51:02     1.5
+++ client/gui-sdl/mapctrl.c    2003/01/29 18:31:22
@@ -537,7 +537,7 @@
   /* ========================= Cooling/Warming ========================== */
 
   /* cooling icon */
-  pBuf = create_iconlabel((SDL_Surface *) sprites.cooling[0], NULL, 0);
+  pBuf = create_iconlabel(GET_SURF(sprites.cooling[0]), NULL, 0);
 
   pBuf->size.x = Main.screen->w - 10 - pBuf->size.w;
   pBuf->size.y = 10;
@@ -545,7 +545,7 @@
   add_to_gui_list(ID_COOLING_ICON, pBuf);
 
   /* warming icon */
-  pBuf = create_iconlabel((SDL_Surface *) sprites.warming[0], NULL, 0);
+  pBuf = create_iconlabel(GET_SURF(sprites.warming[0]), NULL, 0);
 
   pBuf->size.x = Main.screen->w - 10 - pBuf->size.w * 2;
   pBuf->size.y = 10;
Index: client/gui-sdl/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-sdl/mapview.c,v
retrieving revision 1.12
diff -u -r1.12 mapview.c
--- client/gui-sdl/mapview.c    2003/01/29 17:14:13     1.12
+++ client/gui-sdl/mapview.c    2003/01/29 18:31:23
@@ -188,8 +188,8 @@
 */
        
   if (!normalize_map_pos(&x, &y)) {
-    blit_entire_src( (SDL_Surface *)sprites.black_tile ,
-                       Main.screen , canvas_x , canvas_y );
+    blit_entire_src(GET_SURF(sprites.black_tile),
+                   Main.screen, canvas_x, canvas_y);
     return;  
   }
   
@@ -468,7 +468,7 @@
 
 
       /* draw unit sprite */
-      pBuf_Surf = (SDL_Surface *)unit_type(pUnit)->sprite;
+      pBuf_Surf = GET_SURF(unit_type(pUnit)->sprite);
 #if 0
       pBuf_Surf = ZoomSurface(pBuf_Surf2, 1.5, 1.5, 1);
       SDL_SetColorKey(pBuf_Surf, COLORKEYFLAG,
@@ -923,12 +923,12 @@
   flake = CLIP(0, flake, NUM_TILES_PROGRESS - 1);
 
   pBuf = get_widget_pointer_form_main_list(ID_WARMING_ICON);
-  pBuf->theme = (SDL_Surface *) sprites.warming[sol];
+  pBuf->theme = GET_SURF(sprites.warming[sol]);
   redraw_label(pBuf);
   add_refresh_rect(pBuf->size);
 
   pBuf = get_widget_pointer_form_main_list(ID_COOLING_ICON);
-  pBuf->theme = (SDL_Surface *) sprites.cooling[flake];
+  pBuf->theme = GET_SURF(sprites.cooling[flake]);
   redraw_label(pBuf);
   add_refresh_rect(pBuf->size);
 
@@ -949,7 +949,7 @@
 
     pBuf = get_widget_pointer_form_main_list(ID_REVOLUTION);
     set_new_icon_theme(pBuf,
-                      create_icon_theme_surf((SDL_Surface *) sprite));
+                      create_icon_theme_surf(GET_SURF(sprite)));
     SDL_Client_Flags &= ~CF_REVOLUTION;
   }
 #if 0
@@ -960,8 +960,7 @@
   
   pBuf = get_widget_pointer_form_main_list(ID_RESEARCH);
   set_new_icon_theme(pBuf,
-                    create_icon_theme_surf((SDL_Surface *) sprites.
-                                           bulb[bulb]));
+                    create_icon_theme_surf(GET_SURF(sprites.bulb[bulb])));
 }
 
 /* ===================================================================== */
@@ -1477,7 +1476,7 @@
                                     
 
   if (count == -1) { /* tile is unknown */
-    SDL_BlitSurface((SDL_Surface *) sprites.black_tile,
+    SDL_BlitSurface(GET_SURF(sprites.black_tile),
                    NULL, Main.screen, &des);
   
     return;
@@ -1644,7 +1643,7 @@
   /*** City and various terrain improvements ***/
   /*if (contains_special(special, S_FORTRESS) && draw_fortress_airbase) {*/
   if ((special & S_FORTRESS) && draw_fortress_airbase) {
-    SDL_BlitSurface((SDL_Surface *) sprites.tx.fortress_back,
+    SDL_BlitSurface(GET_SURF(sprites.tx.fortress_back),
                    NULL, pBufSurface, &des);
     des = dst;   
   }
@@ -1656,21 +1655,21 @@
 
   /*if (contains_special(special, S_AIRBASE) && draw_fortress_airbase) {*/
   if ((special & S_AIRBASE) && draw_fortress_airbase) {
-    SDL_BlitSurface((SDL_Surface *) sprites.tx.airbase,
+    SDL_BlitSurface(GET_SURF(sprites.tx.airbase),
                    NULL, pBufSurface, &des);
     des = dst;
   }
 
   /*if (contains_special(special, S_FALLOUT) && draw_pollution) {*/
   if ((special & S_FALLOUT) && draw_pollution) {
-    SDL_BlitSurface((SDL_Surface *) sprites.tx.fallout,
+    SDL_BlitSurface(GET_SURF(sprites.tx.fallout),
                    NULL, pBufSurface, &des);
     des = dst;
   }
 
   /*if (contains_special(special, S_POLLUTION) && draw_pollution) {*/
   if ((special & S_POLLUTION) && draw_pollution) {
-    SDL_BlitSurface((SDL_Surface *) sprites.tx.pollution,
+    SDL_BlitSurface(GET_SURF(sprites.tx.pollution),
                    NULL, pBufSurface, &des);
     des = dst;   
   }
@@ -1680,13 +1679,12 @@
   if ( !( SDL_Client_Flags & CF_CIV3_CITY_TEXT_STYLE ) &&
                                     pCity && draw_cities) {
     if (pCity->size >= 10) {
-      SDL_BlitSurface((SDL_Surface *) sprites.city.
-                     size_tens[pCity->size / 10], NULL, pBufSurface,
-                     &des);
+      SDL_BlitSurface(GET_SURF(sprites.city.size_tens[pCity->size / 10]),
+                     NULL, pBufSurface, &des);
       des = dst;           
     }
 
-    SDL_BlitSurface((SDL_Surface *) sprites.city.size[pCity->size % 10],
+    SDL_BlitSurface(GET_SURF(sprites.city.size[pCity->size % 10]),
                    NULL, pBufSurface, &des);
     des = dst;    
   }
@@ -1700,7 +1698,7 @@
     if (!pCity
        && unit_list_size( &(pTile->units) ) > 1) {
       des.y -= NORMAL_TILE_HEIGHT / 2;   
-      SDL_BlitSurface((SDL_Surface *) sprites.unit.stack, NULL,
+      SDL_BlitSurface(GET_SURF(sprites.unit.stack), NULL,
                      pBufSurface, &des);
       des = dst;               
     }
@@ -1708,8 +1706,8 @@
 
   /*if (contains_special(special, S_FORTRESS) && draw_fortress_airbase) {*/
   if ((special & S_FORTRESS) && draw_fortress_airbase) {
-/*    assert((SDL_Surface *) sprites.tx.fortress);*/
-    SDL_BlitSurface((SDL_Surface *) sprites.tx.fortress,
+/*    assert(sprites.tx.fortress != NULL); */
+    SDL_BlitSurface(GET_SURF(sprites.tx.fortress),
                    NULL, pBufSurface, &des);
     des = dst;   
   }
@@ -1948,7 +1946,7 @@
       /* blit explosion */
       dest.x = canvas_x + NORMAL_TILE_WIDTH / 4;
 
-      SDL_BlitSurface((SDL_Surface *) sprites.explode.unit[i],
+      SDL_BlitSurface(GET_SURF(sprites.explode.unit[i]),
                      NULL, Main.screen, &dest);
       refresh_rect(dest);
 
@@ -2069,7 +2067,7 @@
            (col == CITY_MAP_SIZE - 1 && row == CITY_MAP_SIZE - 1)) {
          /* draw black corners */
 
-         SDL_BlitSurface((SDL_Surface *) sprites.black_tile,
+         SDL_BlitSurface(GET_SURF(sprites.black_tile),
                          NULL, pDest, &dest);
        } else {
          /* draw map cell */
@@ -2078,7 +2076,7 @@
              map_get_terrain(real_col, real_row) != T_UNKNOWN) {
            if (!pTile) {
              /* make mask */
-             SDL_BlitSurface((SDL_Surface *) sprites.black_tile,
+             SDL_BlitSurface(GET_SURF(sprites.black_tile),
                              NULL, pTmpSurface, NULL);
 
              SDL_SetColorKey(pTmpSurface, SDL_SRCCOLORKEY,
@@ -2201,10 +2199,10 @@
   SDL_Rect des = { 0 , 0 , 0, 0 };
   SDL_Surface *pBuf[4];
   
-  pBuf[0] = (SDL_Surface *)sprites.tx.coast_cape_iso[0][0];
-  pBuf[1] = (SDL_Surface *)sprites.tx.coast_cape_iso[0][1];
-  pBuf[2] = (SDL_Surface *)sprites.tx.coast_cape_iso[0][2];
-  pBuf[3] = (SDL_Surface *)sprites.tx.coast_cape_iso[0][3];
+  pBuf[0] = GET_SURF(sprites.tx.coast_cape_iso[0][0]);
+  pBuf[1] = GET_SURF(sprites.tx.coast_cape_iso[0][1]);
+  pBuf[2] = GET_SURF(sprites.tx.coast_cape_iso[0][2]);
+  pBuf[3] = GET_SURF(sprites.tx.coast_cape_iso[0][3]);
   
   /* top */
   des.y = 0;
@@ -2290,7 +2288,7 @@
       continue;
     }
       
-    pTerrain_Surface = (SDL_Surface *)get_tile_type(terrain)->sprite[0];
+    pTerrain_Surface = GET_SURF(get_tile_type(terrain)->sprite[0]);
     
     for( i = 0; i < 4; i++ )
     {
Index: client/gui-sdl/repodlgs.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-sdl/repodlgs.c,v
retrieving revision 1.6
diff -u -r1.6 repodlgs.c
--- client/gui-sdl/repodlgs.c   2003/01/24 00:51:02     1.6
+++ client/gui-sdl/repodlgs.c   2003/01/29 18:31:23
@@ -156,10 +156,9 @@
 #endif
 
   pEndScienceDlg->prev->theme =
-      (SDL_Surface *) advances[game.player_ptr->research.researching].
-      sprite;
+    GET_SURF(advances[game.player_ptr->research.researching].sprite);
   pEndScienceDlg->prev->prev->theme =
-      (SDL_Surface *) advances[game.player_ptr->ai.tech_goal].sprite;
+    GET_SURF(advances[game.player_ptr->ai.tech_goal].sprite);
 
   redraw_group(pBeginScienceDlg, pEndScienceDlg, 0);
   /* ------------------------------------- */
@@ -280,9 +279,9 @@
   impr_type_iterate(imp)
       pImpr = get_improvement_type(imp);
   if (pImpr->tech_req == game.player_ptr->research.researching) {
-    SDL_BlitSurface((SDL_Surface *) pImpr->sprite, NULL, Main.screen,
+    SDL_BlitSurface(GET_SURF(pImpr->sprite), NULL, Main.screen,
                    &dest);
-    dest.x += ((SDL_Surface *) pImpr->sprite)->w + 1;
+    dest.x += GET_SURF(pImpr->sprite)->w + 1;
   } impr_type_iterate_end;
 
   dest.x += 5;
@@ -290,8 +289,8 @@
   unit_type_iterate(un)
       pUnit = get_unit_type(un);
   if (pUnit->tech_requirement == game.player_ptr->research.researching) {
-    src = get_smaller_surface_rect((SDL_Surface *) pUnit->sprite);
-    SDL_BlitSurface((SDL_Surface *) pUnit->sprite, &src, Main.screen,
+    src = get_smaller_surface_rect(GET_SURF(pUnit->sprite));
+    SDL_BlitSurface(GET_SURF(pUnit->sprite), &src, Main.screen,
                    &dest);
     dest.x += src.w + 2;
   } unit_type_iterate_end;
@@ -332,9 +331,9 @@
   impr_type_iterate(imp) {
     pImpr = get_improvement_type(imp);
     if (pImpr->tech_req == game.player_ptr->ai.tech_goal) {
-      SDL_BlitSurface((SDL_Surface *) pImpr->sprite, NULL, Main.screen,
+      SDL_BlitSurface(GET_SURF(pImpr->sprite), NULL, Main.screen,
                      &dest);
-      dest.x += ((SDL_Surface *) pImpr->sprite)->w + 1;
+      dest.x += GET_SURF(pImpr->sprite)->w + 1;
     }
   } impr_type_iterate_end;
 
@@ -343,8 +342,8 @@
   unit_type_iterate(un) {
     pUnit = get_unit_type(un);
     if (pUnit->tech_requirement == game.player_ptr->ai.tech_goal) {
-      src = get_smaller_surface_rect((SDL_Surface *) pUnit->sprite);
-      SDL_BlitSurface((SDL_Surface *) pUnit->sprite, &src, Main.screen,
+      src = get_smaller_surface_rect(GET_SURF(pUnit->sprite));
+      SDL_BlitSurface(GET_SURF(pUnit->sprite), &src, Main.screen,
                      &dest);
       dest.x += src.w + 2;
     }
@@ -471,7 +470,7 @@
       FREESURFACE(pText);
 
       /* draw tech icon */
-      pText = (SDL_Surface *) advances[i].sprite;
+      pText = GET_SURF(advances[i].sprite);
       dst.x = (100 - pText->w) / 2;
       SDL_BlitSurface(pText, NULL, pSurf, &dst);
 
@@ -482,7 +481,7 @@
       impr_type_iterate(imp) {
        pImpr = get_improvement_type(imp);
        if (pImpr->tech_req == i) {
-         Surf_Array[w++] = (SDL_Surface *) pImpr->sprite;
+         Surf_Array[w++] = GET_SURF(pImpr->sprite);
        }
       } impr_type_iterate_end;
 
@@ -519,7 +518,7 @@
       unit_type_iterate(un) {
        pUnit = get_unit_type(un);
        if (pUnit->tech_requirement == i) {
-         Surf_Array[w++] = (SDL_Surface *) pUnit->sprite;
+         Surf_Array[w++] = GET_SURF(pUnit->sprite);
        }
       } unit_type_iterate_end;
 
@@ -912,9 +911,9 @@
   add_to_gui_list(ID_SCIENCE_DLG_WINDOW, pWindow);
   /* ------ */
 
-  pBuf = create_icon2((SDL_Surface *)
-                     advances[game.player_ptr->research.researching].
-                     sprite, WF_DRAW_THEME_TRANSPARENT);
+  pBuf = create_icon2(GET_SURF(advances[game.player_ptr->
+                                       research.researching].sprite),
+                     WF_DRAW_THEME_TRANSPARENT);
 
   pBuf->action = change_research;
   set_wstate(pBuf, WS_NORMAL);
@@ -925,9 +924,9 @@
   add_to_gui_list(ID_SCIENCE_DLG_CHANGE_REASARCH_BUTTON, pBuf);
 
   /* ------ */
-  pBuf =
-      create_icon2((SDL_Surface *) advances[game.player_ptr->ai.tech_goal].
-                  sprite, WF_DRAW_THEME_TRANSPARENT);
+  pBuf = create_icon2(GET_SURF(advances[game.player_ptr->
+                                       ai.tech_goal].sprite),
+                     WF_DRAW_THEME_TRANSPARENT);
 
   pBuf->action = change_research_goal;
   set_wstate(pBuf, WS_NORMAL);

[Prev in Thread] Current Thread [Next in Thread]