Commits

Anonymous committed 59f981c

small enhancements

Comments (0)

Files changed (4)

 # BREAK = change breaks existing code
 # BUG	= fixed a bug that was (or could have been) crashing
 
+October 19, 2002
+    	can free software surfaces without video initialized
+	added "x", "y", "w", and "h" attribs to Rect (like SDL)
+	RenderUpdates.draw() doesn't union nonoverlapping
+
 October 16, 2002
 	fix crash with subsubsurface blits [BUG]
 	added Surface.get_offset() and get_abs_offset()
             if r is 0:
                 dirty_append(newrect)
             else:
-                dirty_append(newrect.union(r))
+                if newrect.colliderect(r):
+                    dirty_append(newrect.union(r))
+                else:
+                    dirty_append(newrect)
+                    dirty_append(r)
             spritedict[s] = newrect
         return dirty
 
 	PyObject *ret = NULL;
 	GAME_Rect *r = &self->r;
 	
-	if(!strcmp(name, "top"))
+	if(!strcmp(name, "top") || !strcmp(name, "y"))
 		ret = PyInt_FromLong(r->y);
 	else if(!strcmp(name, "bottom"))
 		ret = PyInt_FromLong(r->y + r->h);
-	else if(!strcmp(name, "left"))
+	else if(!strcmp(name, "left") || !strcmp(name, "x"))
 		ret = PyInt_FromLong(r->x);
 	else if(!strcmp(name, "right"))
 		ret = PyInt_FromLong(r->x + r->w);
-	else if(!strcmp(name, "width"))
+	else if(!strcmp(name, "width") || !strcmp(name, "w"))
 		ret = PyInt_FromLong(r->w);
-	else if(!strcmp(name, "height"))
+	else if(!strcmp(name, "height") || !strcmp(name, "h"))
 		ret = PyInt_FromLong(r->h);
 	else if(!strcmp(name, "centerx"))
 		ret = PyInt_FromLong(r->x+r->w/2);
 	short val1, val2;
 	GAME_Rect *r = &self->r;
 	
-	if(!strcmp(name, "top"))
+	if(!strcmp(name, "top") || !strcmp(name, "y"))
 	{
 		if(ShortFromObj(op, &val1))
 			ret = Rect_SetTop(r, val1);
 		if(ShortFromObj(op, &val1))
 			ret = Rect_SetBottom(r, val1);
 	}	
-	else if(!strcmp(name, "left"))
+	else if(!strcmp(name, "left") || !strcmp(name, "x"))
 	{
 		if(ShortFromObj(op, &val1))
 			ret = Rect_SetLeft(r, val1);
 		if(ShortFromObj(op, &val1))
 			ret = Rect_SetRight(r, val1);
 	}	
-	else if(!strcmp(name, "width"))
+	else if(!strcmp(name, "width") || !strcmp(name, "w"))
 	{
 		if(ShortFromObj(op, &val1))
 			ret = Rect_SetWidth(r, val1);
 	}	
-	else if(!strcmp(name, "height"))
+	else if(!strcmp(name, "height") || !strcmp(name, "h"))
 	{
 		if(ShortFromObj(op, &val1))
 			ret = Rect_SetHeight(r, val1);
 {
 	PySurfaceObject* surf = (PySurfaceObject*)self;
 	struct SubSurface_Data* data = ((PySurfaceObject*)self)->subsurface;
-	
-	if(SDL_WasInit(SDL_INIT_VIDEO))
+	int flags=0;
+
+	if(PySurface_AsSurface(surf))
+	    flags = PySurface_AsSurface(surf)->flags;
+	if(!(flags&SDL_HWSURFACE) || SDL_WasInit(SDL_INIT_VIDEO))
 	{
+	    	/*unsafe to free hardware surfaces without video init*/
 		while(surf->lockcount > 0)
 			PySurface_Unlock(self);
 		SDL_FreeSurface(surf->surf);
 		PyMem_Del(data);
 	}
 
-	PyObject_DEL(self);	
+	PyObject_DEL(self);
 }