@@ -1417,7 +1417,6 @@ surf_set_colorkey(pgSurfaceObject *self, PyObject *args)
1417
1417
SDL_Surface * surf = pgSurface_AsSurface (self );
1418
1418
Uint32 flags = 0 , color = 0 ;
1419
1419
PyObject * rgba_obj = NULL ;
1420
- int result ;
1421
1420
int hascolor = SDL_FALSE ;
1422
1421
1423
1422
if (!PyArg_ParseTuple (args , "|Oi" , & rgba_obj , & flags )) {
@@ -1436,22 +1435,22 @@ surf_set_colorkey(pgSurfaceObject *self, PyObject *args)
1436
1435
}
1437
1436
1438
1437
pgSurface_Prep (self );
1439
- result = 0 ;
1438
+ bool success = true ;
1440
1439
if (hascolor && PG_SURF_BytesPerPixel (surf ) == 1 ) {
1441
1440
/* For an indexed surface, remove the previous colorkey first.
1442
1441
*/
1443
- result = SDL_SetColorKey (surf , SDL_FALSE , color );
1442
+ success = PG_SetSurfaceColorKey (surf , SDL_FALSE , color );
1444
1443
}
1445
- if (result == 0 && hascolor ) {
1446
- result = SDL_SetSurfaceRLE (
1444
+ if (success && hascolor ) {
1445
+ success = PG_SetSurfaceRLE (
1447
1446
surf , (flags & PGS_RLEACCEL ) ? SDL_TRUE : SDL_FALSE );
1448
1447
}
1449
- if (result == 0 ) {
1450
- result = SDL_SetColorKey (surf , hascolor , color );
1448
+ if (success ) {
1449
+ success = PG_SetSurfaceColorKey (surf , hascolor , color );
1451
1450
}
1452
1451
pgSurface_Unprep (self );
1453
1452
1454
- if (result == -1 ) {
1453
+ if (! success ) {
1455
1454
return RAISE (pgExc_SDLError , SDL_GetError ());
1456
1455
}
1457
1456
@@ -1496,7 +1495,7 @@ surf_set_alpha(pgSurfaceObject *self, PyObject *args)
1496
1495
Uint32 flags = 0 ;
1497
1496
PyObject * alpha_obj = NULL , * intobj = NULL ;
1498
1497
Uint8 alpha ;
1499
- int result , alphaval = 255 ;
1498
+ int alphaval = 255 ;
1500
1499
SDL_Rect sdlrect ;
1501
1500
SDL_Surface * surface ;
1502
1501
@@ -1544,8 +1543,8 @@ surf_set_alpha(pgSurfaceObject *self, PyObject *args)
1544
1543
}
1545
1544
}
1546
1545
pgSurface_Prep (self );
1547
- result =
1548
- SDL_SetSurfaceRLE (surf , (flags & PGS_RLEACCEL ) ? SDL_TRUE : SDL_FALSE );
1546
+ bool success =
1547
+ PG_SetSurfaceRLE (surf , (flags & PGS_RLEACCEL ) ? SDL_TRUE : SDL_FALSE );
1549
1548
/* HACK HACK HACK */
1550
1549
if ((surf -> flags & SDL_RLEACCEL ) && (!(flags & PGS_RLEACCEL ))) {
1551
1550
/* hack to strip SDL_RLEACCEL flag off surface immediately when
@@ -1561,12 +1560,12 @@ surf_set_alpha(pgSurfaceObject *self, PyObject *args)
1561
1560
SDL_FreeSurface (surface );
1562
1561
}
1563
1562
/* HACK HACK HACK */
1564
- if (result == 0 ) {
1565
- result = ! PG_SetSurfaceAlphaMod (surf , alpha );
1563
+ if (success ) {
1564
+ success = PG_SetSurfaceAlphaMod (surf , alpha );
1566
1565
}
1567
1566
pgSurface_Unprep (self );
1568
1567
1569
- if (result != 0 ) {
1568
+ if (! success ) {
1570
1569
return RAISE (pgExc_SDLError , SDL_GetError ());
1571
1570
}
1572
1571
@@ -1814,7 +1813,7 @@ surf_convert(pgSurfaceObject *self, PyObject *args)
1814
1813
1815
1814
if (has_colorkey ) {
1816
1815
colorkey = SDL_MapSurfaceRGBA (newsurf , key_r , key_g , key_b , key_a );
1817
- if (SDL_SetColorKey (newsurf , SDL_TRUE , colorkey ) != 0 ) {
1816
+ if (! PG_SetSurfaceColorKey (newsurf , SDL_TRUE , colorkey )) {
1818
1817
PyErr_SetString (pgExc_SDLError , SDL_GetError ());
1819
1818
SDL_FreeSurface (newsurf );
1820
1819
return NULL ;
@@ -1977,7 +1976,7 @@ surf_convert(pgSurfaceObject *self, PyObject *args)
1977
1976
1978
1977
if (has_colorkey ) {
1979
1978
colorkey = SDL_MapRGBA (newsurf -> format , key_r , key_g , key_b , key_a );
1980
- if (SDL_SetColorKey (newsurf , SDL_TRUE , colorkey ) != 0 ) {
1979
+ if (! PG_SetSurfaceColorKey (newsurf , SDL_TRUE , colorkey )) {
1981
1980
PyErr_SetString (pgExc_SDLError , SDL_GetError ());
1982
1981
SDL_FreeSurface (newsurf );
1983
1982
return NULL ;
@@ -3237,7 +3236,7 @@ surf_subsurface(PyObject *self, PyObject *args)
3237
3236
SDL_FreeSurface (sub );
3238
3237
return NULL ;
3239
3238
}
3240
- if (SDL_SetSurfacePalette (sub , pal ) != 0 ) {
3239
+ if (! PG_SetSurfacePalette (sub , pal )) {
3241
3240
PyErr_SetString (pgExc_SDLError , SDL_GetError ());
3242
3241
SDL_FreePalette (pal );
3243
3242
SDL_FreeSurface (sub );
@@ -3259,7 +3258,7 @@ surf_subsurface(PyObject *self, PyObject *args)
3259
3258
}
3260
3259
if (SDL_HasColorKey (surf )) {
3261
3260
SDL_GetColorKey (surf , & colorkey );
3262
- if (SDL_SetColorKey (sub , SDL_TRUE , colorkey ) != 0 ) {
3261
+ if (! PG_SetSurfaceColorKey (sub , SDL_TRUE , colorkey )) {
3263
3262
PyErr_SetString (pgExc_SDLError , SDL_GetError ());
3264
3263
SDL_FreeSurface (sub );
3265
3264
return NULL ;
0 commit comments