@@ -674,8 +674,8 @@ surface_init(pgSurfaceObject *self, PyObject *args, PyObject *kwds)
674
674
/* Give the surface something other than an all white palette.
675
675
* */
676
676
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 )) {
679
679
PyErr_SetString (pgExc_SDLError , SDL_GetError ());
680
680
SDL_FreeSurface (surface );
681
681
return -1 ;
@@ -858,9 +858,9 @@ surface_init(pgSurfaceObject *self, PyObject *args, PyObject *kwds)
858
858
if (SDL_ISPIXELFORMAT_INDEXED (PG_SURF_FORMATENUM (surface ))) {
859
859
/* Give the surface something other than an all white palette.
860
860
* */
861
- if (SDL_SetPaletteColors (surface -> format -> palette ,
861
+ if (! PG_SetPaletteColors (surface -> format -> palette ,
862
862
default_palette_colors , 0 ,
863
- default_palette_size - 1 ) != 0 ) {
863
+ default_palette_size - 1 )) {
864
864
PyErr_SetString (pgExc_SDLError , SDL_GetError ());
865
865
SDL_FreeSurface (surface );
866
866
return -1 ;
@@ -1332,7 +1332,7 @@ surf_set_palette(PyObject *self, PyObject *seq)
1332
1332
}
1333
1333
1334
1334
if (!pal ) {
1335
- return RAISE (pgExc_SDLError , "Surface is not palettitized \n" );
1335
+ return RAISE (pgExc_SDLError , "Surface is not palettized \n" );
1336
1336
}
1337
1337
old_colors = pal -> colors ;
1338
1338
@@ -1360,8 +1360,7 @@ surf_set_palette(PyObject *self, PyObject *seq)
1360
1360
colors [i ].a = (unsigned char )old_colors [i ].a ;
1361
1361
}
1362
1362
1363
- ecode = SDL_SetPaletteColors (pal , colors , 0 , len );
1364
- if (ecode != 0 ) {
1363
+ if (!PG_SetPaletteColors (pal , colors , 0 , len )) {
1365
1364
return RAISE (pgExc_SDLError , SDL_GetError ());
1366
1365
}
1367
1366
Py_RETURN_NONE ;
@@ -1405,7 +1404,7 @@ surf_set_palette_at(PyObject *self, PyObject *args)
1405
1404
color .b = rgba [2 ];
1406
1405
color .a = pal -> colors [_index ].a ; /* May be a colorkey color. */
1407
1406
1408
- if (SDL_SetPaletteColors (pal , & color , _index , 1 ) != 0 ) {
1407
+ if (! PG_SetPaletteColors (pal , & color , _index , 1 )) {
1409
1408
return RAISE (pgExc_SDLError , SDL_GetError ());
1410
1409
}
1411
1410
@@ -1518,12 +1517,12 @@ surf_set_alpha(pgSurfaceObject *self, PyObject *args)
1518
1517
return RAISE (PyExc_TypeError , "invalid alpha argument" );
1519
1518
}
1520
1519
1521
- if (SDL_SetSurfaceBlendMode (surf , SDL_BLENDMODE_BLEND ) != 0 ) {
1520
+ if (! PG_SetSurfaceBlendMode (surf , SDL_BLENDMODE_BLEND )) {
1522
1521
return RAISE (pgExc_SDLError , SDL_GetError ());
1523
1522
}
1524
1523
}
1525
1524
else {
1526
- if (SDL_SetSurfaceBlendMode (surf , SDL_BLENDMODE_NONE ) != 0 ) {
1525
+ if (! PG_SetSurfaceBlendMode (surf , SDL_BLENDMODE_NONE )) {
1527
1526
return RAISE (pgExc_SDLError , SDL_GetError ());
1528
1527
}
1529
1528
}
@@ -1540,7 +1539,7 @@ surf_set_alpha(pgSurfaceObject *self, PyObject *args)
1540
1539
1541
1540
if (alpha == 255 && (PG_SURF_BytesPerPixel (surf ) == 1 )) {
1542
1541
/* 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 )) {
1544
1543
return RAISE (pgExc_SDLError , SDL_GetError ());
1545
1544
}
1546
1545
}
@@ -1563,11 +1562,11 @@ surf_set_alpha(pgSurfaceObject *self, PyObject *args)
1563
1562
}
1564
1563
/* HACK HACK HACK */
1565
1564
if (result == 0 ) {
1566
- result = SDL_SetSurfaceAlphaMod (surf , alpha );
1565
+ result = ! PG_SetSurfaceAlphaMod (surf , alpha );
1567
1566
}
1568
1567
pgSurface_Unprep (self );
1569
1568
1570
- if (result == -1 ) {
1569
+ if (result != 0 ) {
1571
1570
return RAISE (pgExc_SDLError , SDL_GetError ());
1572
1571
}
1573
1572
@@ -1583,15 +1582,15 @@ surf_get_alpha(pgSurfaceObject *self, PyObject *_null)
1583
1582
1584
1583
SURF_INIT_CHECK (surf )
1585
1584
1586
- if (SDL_GetSurfaceBlendMode (surf , & mode ) != 0 ) {
1585
+ if (! PG_GetSurfaceBlendMode (surf , & mode )) {
1587
1586
return RAISE (pgExc_SDLError , SDL_GetError ());
1588
1587
}
1589
1588
1590
1589
if (mode != SDL_BLENDMODE_BLEND ) {
1591
1590
Py_RETURN_NONE ;
1592
1591
}
1593
1592
1594
- if (SDL_GetSurfaceAlphaMod (surf , & alpha ) != 0 ) {
1593
+ if (! PG_GetSurfaceAlphaMod (surf , & alpha )) {
1595
1594
return RAISE (pgExc_SDLError , SDL_GetError ());
1596
1595
}
1597
1596
@@ -1606,7 +1605,7 @@ surf_get_blendmode(PyObject *self, PyObject *_null)
1606
1605
1607
1606
SURF_INIT_CHECK (surf )
1608
1607
1609
- if (SDL_GetSurfaceBlendMode (surf , & mode ) != 0 ) {
1608
+ if (! PG_GetSurfaceBlendMode (surf , & mode )) {
1610
1609
return RAISE (pgExc_SDLError , SDL_GetError ());
1611
1610
}
1612
1611
return PyLong_FromLong ((long )mode );
@@ -2971,7 +2970,7 @@ static int
2971
2970
_PgSurface_SrcAlpha (SDL_Surface * surf )
2972
2971
{
2973
2972
SDL_BlendMode mode ;
2974
- if (SDL_GetSurfaceBlendMode (surf , & mode ) < 0 ) {
2973
+ if (! PG_GetSurfaceBlendMode (surf , & mode )) {
2975
2974
PyErr_SetString (pgExc_SDLError , SDL_GetError ());
2976
2975
return -1 ;
2977
2976
}
@@ -3232,7 +3231,7 @@ surf_subsurface(PyObject *self, PyObject *args)
3232
3231
SDL_FreeSurface (sub );
3233
3232
return NULL ;
3234
3233
}
3235
- if (SDL_SetPaletteColors (pal , colors , 0 , ncolors ) != 0 ) {
3234
+ if (! PG_SetPaletteColors (pal , colors , 0 , ncolors )) {
3236
3235
PyErr_SetString (pgExc_SDLError , SDL_GetError ());
3237
3236
SDL_FreePalette (pal );
3238
3237
SDL_FreeSurface (sub );
@@ -3246,13 +3245,13 @@ surf_subsurface(PyObject *self, PyObject *args)
3246
3245
}
3247
3246
SDL_FreePalette (pal );
3248
3247
}
3249
- if (SDL_GetSurfaceAlphaMod (surf , & alpha ) != 0 ) {
3248
+ if (! PG_GetSurfaceAlphaMod (surf , & alpha )) {
3250
3249
PyErr_SetString (pgExc_SDLError , SDL_GetError ());
3251
3250
SDL_FreeSurface (sub );
3252
3251
return NULL ;
3253
3252
}
3254
3253
if (alpha != 255 ) {
3255
- if (SDL_SetSurfaceAlphaMod (sub , alpha ) != 0 ) {
3254
+ if (! PG_SetSurfaceAlphaMod (sub , alpha )) {
3256
3255
PyErr_SetString (pgExc_SDLError , SDL_GetError ());
3257
3256
SDL_FreeSurface (sub );
3258
3257
return NULL ;
@@ -4516,7 +4515,7 @@ pgSurface_Blit(pgSurfaceObject *dstobj, pgSurfaceObject *srcobj,
4516
4515
/* can't blit alpha to 8bit, crashes SDL */
4517
4516
else if (PG_SURF_BytesPerPixel (dst ) == 1 &&
4518
4517
(SDL_ISPIXELFORMAT_ALPHA (PG_SURF_FORMATENUM (src )) ||
4519
- ((SDL_GetSurfaceAlphaMod (src , & alpha ) == 0 && alpha != 255 )))) {
4518
+ ((PG_GetSurfaceAlphaMod (src , & alpha ) && alpha != 255 )))) {
4520
4519
/* Py_BEGIN_ALLOW_THREADS */
4521
4520
if (PG_SURF_BytesPerPixel (src ) == 1 ) {
4522
4521
result = pygame_Blit (src , srcrect , dst , dstrect , 0 );
0 commit comments