@@ -674,8 +674,8 @@ surface_init(pgSurfaceObject *self, PyObject *args, PyObject *kwds)
674674 /* Give the surface something other than an all white palette.
675675 * */
676676 SDL_Palette * surf_palette = SDL_CreateSurfacePalette (surface );
677- if (SDL_SetPaletteColors (surf_palette , default_palette_colors , 0 ,
678- default_palette_size - 1 ) != 0 ) {
677+ if (! PG_SetPaletteColors (surf_palette , default_palette_colors , 0 ,
678+ default_palette_size - 1 )) {
679679 PyErr_SetString (pgExc_SDLError , SDL_GetError ());
680680 SDL_FreeSurface (surface );
681681 return -1 ;
@@ -858,9 +858,9 @@ surface_init(pgSurfaceObject *self, PyObject *args, PyObject *kwds)
858858 if (SDL_ISPIXELFORMAT_INDEXED (PG_SURF_FORMATENUM (surface ))) {
859859 /* Give the surface something other than an all white palette.
860860 * */
861- if (SDL_SetPaletteColors (surface -> format -> palette ,
861+ if (! PG_SetPaletteColors (surface -> format -> palette ,
862862 default_palette_colors , 0 ,
863- default_palette_size - 1 ) != 0 ) {
863+ default_palette_size - 1 )) {
864864 PyErr_SetString (pgExc_SDLError , SDL_GetError ());
865865 SDL_FreeSurface (surface );
866866 return -1 ;
@@ -1332,7 +1332,7 @@ surf_set_palette(PyObject *self, PyObject *seq)
13321332 }
13331333
13341334 if (!pal ) {
1335- return RAISE (pgExc_SDLError , "Surface is not palettitized \n" );
1335+ return RAISE (pgExc_SDLError , "Surface is not palettized \n" );
13361336 }
13371337 old_colors = pal -> colors ;
13381338
@@ -1360,8 +1360,7 @@ surf_set_palette(PyObject *self, PyObject *seq)
13601360 colors [i ].a = (unsigned char )old_colors [i ].a ;
13611361 }
13621362
1363- ecode = SDL_SetPaletteColors (pal , colors , 0 , len );
1364- if (ecode != 0 ) {
1363+ if (!PG_SetPaletteColors (pal , colors , 0 , len )) {
13651364 return RAISE (pgExc_SDLError , SDL_GetError ());
13661365 }
13671366 Py_RETURN_NONE ;
@@ -1405,7 +1404,7 @@ surf_set_palette_at(PyObject *self, PyObject *args)
14051404 color .b = rgba [2 ];
14061405 color .a = pal -> colors [_index ].a ; /* May be a colorkey color. */
14071406
1408- if (SDL_SetPaletteColors (pal , & color , _index , 1 ) != 0 ) {
1407+ if (! PG_SetPaletteColors (pal , & color , _index , 1 )) {
14091408 return RAISE (pgExc_SDLError , SDL_GetError ());
14101409 }
14111410
@@ -1518,12 +1517,12 @@ surf_set_alpha(pgSurfaceObject *self, PyObject *args)
15181517 return RAISE (PyExc_TypeError , "invalid alpha argument" );
15191518 }
15201519
1521- if (SDL_SetSurfaceBlendMode (surf , SDL_BLENDMODE_BLEND ) != 0 ) {
1520+ if (! PG_SetSurfaceBlendMode (surf , SDL_BLENDMODE_BLEND )) {
15221521 return RAISE (pgExc_SDLError , SDL_GetError ());
15231522 }
15241523 }
15251524 else {
1526- if (SDL_SetSurfaceBlendMode (surf , SDL_BLENDMODE_NONE ) != 0 ) {
1525+ if (! PG_SetSurfaceBlendMode (surf , SDL_BLENDMODE_NONE )) {
15271526 return RAISE (pgExc_SDLError , SDL_GetError ());
15281527 }
15291528 }
@@ -1540,7 +1539,7 @@ surf_set_alpha(pgSurfaceObject *self, PyObject *args)
15401539
15411540 if (alpha == 255 && (PG_SURF_BytesPerPixel (surf ) == 1 )) {
15421541 /* Can't blend with a surface alpha of 255 and 8bit surfaces */
1543- if (SDL_SetSurfaceBlendMode (surf , SDL_BLENDMODE_NONE ) != 0 ) {
1542+ if (! PG_SetSurfaceBlendMode (surf , SDL_BLENDMODE_NONE )) {
15441543 return RAISE (pgExc_SDLError , SDL_GetError ());
15451544 }
15461545 }
@@ -1563,11 +1562,11 @@ surf_set_alpha(pgSurfaceObject *self, PyObject *args)
15631562 }
15641563 /* HACK HACK HACK */
15651564 if (result == 0 ) {
1566- result = SDL_SetSurfaceAlphaMod (surf , alpha );
1565+ result = ! PG_SetSurfaceAlphaMod (surf , alpha );
15671566 }
15681567 pgSurface_Unprep (self );
15691568
1570- if (result == -1 ) {
1569+ if (result != 0 ) {
15711570 return RAISE (pgExc_SDLError , SDL_GetError ());
15721571 }
15731572
@@ -1583,15 +1582,15 @@ surf_get_alpha(pgSurfaceObject *self, PyObject *_null)
15831582
15841583 SURF_INIT_CHECK (surf )
15851584
1586- if (SDL_GetSurfaceBlendMode (surf , & mode ) != 0 ) {
1585+ if (! PG_GetSurfaceBlendMode (surf , & mode )) {
15871586 return RAISE (pgExc_SDLError , SDL_GetError ());
15881587 }
15891588
15901589 if (mode != SDL_BLENDMODE_BLEND ) {
15911590 Py_RETURN_NONE ;
15921591 }
15931592
1594- if (SDL_GetSurfaceAlphaMod (surf , & alpha ) != 0 ) {
1593+ if (! PG_GetSurfaceAlphaMod (surf , & alpha )) {
15951594 return RAISE (pgExc_SDLError , SDL_GetError ());
15961595 }
15971596
@@ -1606,7 +1605,7 @@ surf_get_blendmode(PyObject *self, PyObject *_null)
16061605
16071606 SURF_INIT_CHECK (surf )
16081607
1609- if (SDL_GetSurfaceBlendMode (surf , & mode ) != 0 ) {
1608+ if (! PG_GetSurfaceBlendMode (surf , & mode )) {
16101609 return RAISE (pgExc_SDLError , SDL_GetError ());
16111610 }
16121611 return PyLong_FromLong ((long )mode );
@@ -2971,7 +2970,7 @@ static int
29712970_PgSurface_SrcAlpha (SDL_Surface * surf )
29722971{
29732972 SDL_BlendMode mode ;
2974- if (SDL_GetSurfaceBlendMode (surf , & mode ) < 0 ) {
2973+ if (! PG_GetSurfaceBlendMode (surf , & mode )) {
29752974 PyErr_SetString (pgExc_SDLError , SDL_GetError ());
29762975 return -1 ;
29772976 }
@@ -3232,7 +3231,7 @@ surf_subsurface(PyObject *self, PyObject *args)
32323231 SDL_FreeSurface (sub );
32333232 return NULL ;
32343233 }
3235- if (SDL_SetPaletteColors (pal , colors , 0 , ncolors ) != 0 ) {
3234+ if (! PG_SetPaletteColors (pal , colors , 0 , ncolors )) {
32363235 PyErr_SetString (pgExc_SDLError , SDL_GetError ());
32373236 SDL_FreePalette (pal );
32383237 SDL_FreeSurface (sub );
@@ -3246,13 +3245,13 @@ surf_subsurface(PyObject *self, PyObject *args)
32463245 }
32473246 SDL_FreePalette (pal );
32483247 }
3249- if (SDL_GetSurfaceAlphaMod (surf , & alpha ) != 0 ) {
3248+ if (! PG_GetSurfaceAlphaMod (surf , & alpha )) {
32503249 PyErr_SetString (pgExc_SDLError , SDL_GetError ());
32513250 SDL_FreeSurface (sub );
32523251 return NULL ;
32533252 }
32543253 if (alpha != 255 ) {
3255- if (SDL_SetSurfaceAlphaMod (sub , alpha ) != 0 ) {
3254+ if (! PG_SetSurfaceAlphaMod (sub , alpha )) {
32563255 PyErr_SetString (pgExc_SDLError , SDL_GetError ());
32573256 SDL_FreeSurface (sub );
32583257 return NULL ;
@@ -4516,7 +4515,7 @@ pgSurface_Blit(pgSurfaceObject *dstobj, pgSurfaceObject *srcobj,
45164515 /* can't blit alpha to 8bit, crashes SDL */
45174516 else if (PG_SURF_BytesPerPixel (dst ) == 1 &&
45184517 (SDL_ISPIXELFORMAT_ALPHA (PG_SURF_FORMATENUM (src )) ||
4519- ((SDL_GetSurfaceAlphaMod (src , & alpha ) == 0 && alpha != 255 )))) {
4518+ ((PG_GetSurfaceAlphaMod (src , & alpha ) && alpha != 255 )))) {
45204519 /* Py_BEGIN_ALLOW_THREADS */
45214520 if (PG_SURF_BytesPerPixel (src ) == 1 ) {
45224521 result = pygame_Blit (src , srcrect , dst , dstrect , 0 );
0 commit comments