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

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

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: jdorje@xxxxxxxxxxxxxxxxxxxxx
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#2937) SDL client: GET_SURF()
From: "Raimar Falke via RT" <rt@xxxxxxxxxxxxxx>
Date: Wed, 29 Jan 2003 12:21:44 -0800
Reply-to: rt@xxxxxxxxxxxxxx

On Wed, Jan 29, 2003 at 10:35:10AM -0800, Jason Short via RT wrote:
> 
> 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...

This is just a band-aid for the current hack. Not the real solution.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 Make a software that is foolproof, and only fools will want to use it.




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