diff src/paranormal/drawing.c @ 304:3d0b7ca9c8eb trunk

[svn] - add pn_draw_dot() and convert some functions to use that instead of redundant checks all over the code.
author nenolod
date Thu, 23 Nov 2006 00:02:25 -0800
parents fd4dcd3fe08f
children 8aab955fb114
line wrap: on
line diff
--- a/src/paranormal/drawing.c	Wed Nov 22 23:00:31 2006 -0800
+++ b/src/paranormal/drawing.c	Thu Nov 23 00:02:25 2006 -0800
@@ -7,6 +7,15 @@
 extern SDL_Surface *screen;
 
 void
+pn_draw_dot (guint x, guint y, guchar value)
+{
+  if (x > pn_image_data->width || x < 0 || y > pn_image_data->height || y < 0)
+    return;
+
+  pn_image_data->surface[0][PN_IMG_INDEX(x, y)] = value;
+}
+
+void
 pn_draw_line (guint _x0, guint _y0, guint _x1, guint _y1, guchar value)
 {
   gint x0 = _x0;
@@ -17,10 +26,7 @@
   gint dx = x1 - x0;
   gint dy = y1 - y0;
 
-  if (x0 > pn_image_data->width || x0 < 0 || y0 > pn_image_data->height || y0 < 0)
-     return;
-
-  pn_image_data->surface[0][PN_IMG_INDEX(x0, y0)] = value;
+  pn_draw_dot(x0, y0, value);
 
   if (dx != 0)
     {
@@ -33,10 +39,7 @@
           x0 += dx;
           y0 = m * x0 + b;
 
-          if (x0 > pn_image_data->width || x0 < 0 || y0 > pn_image_data->height || y0 < 0)
-            continue;
-
-          pn_image_data->surface[0][PN_IMG_INDEX(x0, y0)] = value;
+          pn_draw_dot(x0, y0, value);
         }
     }
 }