@@ -1417,7 +1417,6 @@ surf_set_colorkey(pgSurfaceObject *self, PyObject *args)
14171417 SDL_Surface * surf = pgSurface_AsSurface (self );
14181418 Uint32 flags = 0 , color = 0 ;
14191419 PyObject * rgba_obj = NULL ;
1420- int result ;
14211420 int hascolor = SDL_FALSE ;
14221421
14231422 if (!PyArg_ParseTuple (args , "|Oi" , & rgba_obj , & flags )) {
@@ -1436,22 +1435,22 @@ surf_set_colorkey(pgSurfaceObject *self, PyObject *args)
14361435 }
14371436
14381437 pgSurface_Prep (self );
1439- result = 0 ;
1438+ bool success = true ;
14401439 if (hascolor && PG_SURF_BytesPerPixel (surf ) == 1 ) {
14411440 /* For an indexed surface, remove the previous colorkey first.
14421441 */
1443- result = SDL_SetColorKey (surf , SDL_FALSE , color );
1442+ success = PG_SetSurfaceColorKey (surf , SDL_FALSE , color );
14441443 }
1445- if (result == 0 && hascolor ) {
1446- result = SDL_SetSurfaceRLE (
1444+ if (success && hascolor ) {
1445+ success = PG_SetSurfaceRLE (
14471446 surf , (flags & PGS_RLEACCEL ) ? SDL_TRUE : SDL_FALSE );
14481447 }
1449- if (result == 0 ) {
1450- result = SDL_SetColorKey (surf , hascolor , color );
1448+ if (success ) {
1449+ success = PG_SetSurfaceColorKey (surf , hascolor , color );
14511450 }
14521451 pgSurface_Unprep (self );
14531452
1454- if (result == -1 ) {
1453+ if (! success ) {
14551454 return RAISE (pgExc_SDLError , SDL_GetError ());
14561455 }
14571456
@@ -1496,7 +1495,7 @@ surf_set_alpha(pgSurfaceObject *self, PyObject *args)
14961495 Uint32 flags = 0 ;
14971496 PyObject * alpha_obj = NULL , * intobj = NULL ;
14981497 Uint8 alpha ;
1499- int result , alphaval = 255 ;
1498+ int alphaval = 255 ;
15001499 SDL_Rect sdlrect ;
15011500 SDL_Surface * surface ;
15021501
@@ -1544,8 +1543,8 @@ surf_set_alpha(pgSurfaceObject *self, PyObject *args)
15441543 }
15451544 }
15461545 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 );
15491548 /* HACK HACK HACK */
15501549 if ((surf -> flags & SDL_RLEACCEL ) && (!(flags & PGS_RLEACCEL ))) {
15511550 /* hack to strip SDL_RLEACCEL flag off surface immediately when
@@ -1561,12 +1560,12 @@ surf_set_alpha(pgSurfaceObject *self, PyObject *args)
15611560 SDL_FreeSurface (surface );
15621561 }
15631562 /* HACK HACK HACK */
1564- if (result == 0 ) {
1565- result = ! PG_SetSurfaceAlphaMod (surf , alpha );
1563+ if (success ) {
1564+ success = PG_SetSurfaceAlphaMod (surf , alpha );
15661565 }
15671566 pgSurface_Unprep (self );
15681567
1569- if (result != 0 ) {
1568+ if (! success ) {
15701569 return RAISE (pgExc_SDLError , SDL_GetError ());
15711570 }
15721571
@@ -1814,7 +1813,7 @@ surf_convert(pgSurfaceObject *self, PyObject *args)
18141813
18151814 if (has_colorkey ) {
18161815 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 )) {
18181817 PyErr_SetString (pgExc_SDLError , SDL_GetError ());
18191818 SDL_FreeSurface (newsurf );
18201819 return NULL ;
@@ -1977,7 +1976,7 @@ surf_convert(pgSurfaceObject *self, PyObject *args)
19771976
19781977 if (has_colorkey ) {
19791978 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 )) {
19811980 PyErr_SetString (pgExc_SDLError , SDL_GetError ());
19821981 SDL_FreeSurface (newsurf );
19831982 return NULL ;
@@ -3237,7 +3236,7 @@ surf_subsurface(PyObject *self, PyObject *args)
32373236 SDL_FreeSurface (sub );
32383237 return NULL ;
32393238 }
3240- if (SDL_SetSurfacePalette (sub , pal ) != 0 ) {
3239+ if (! PG_SetSurfacePalette (sub , pal )) {
32413240 PyErr_SetString (pgExc_SDLError , SDL_GetError ());
32423241 SDL_FreePalette (pal );
32433242 SDL_FreeSurface (sub );
@@ -3259,7 +3258,7 @@ surf_subsurface(PyObject *self, PyObject *args)
32593258 }
32603259 if (SDL_HasColorKey (surf )) {
32613260 SDL_GetColorKey (surf , & colorkey );
3262- if (SDL_SetColorKey (sub , SDL_TRUE , colorkey ) != 0 ) {
3261+ if (! PG_SetSurfaceColorKey (sub , SDL_TRUE , colorkey )) {
32633262 PyErr_SetString (pgExc_SDLError , SDL_GetError ());
32643263 SDL_FreeSurface (sub );
32653264 return NULL ;
0 commit comments